i386.c (index_register_operand): New.
[official-gcc.git] / gcc / config / i386 / i386.md
bloba306509c4465793ac2952ddd46e304c1ffffb626
1 ;; GCC machine description for IA-32 and x86-64.
2 ;; Copyright (C) 1988, 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002
3 ;; Free Software Foundation, Inc.
4 ;; Mostly by William Schelter.
5 ;; x86_64 support added by Jan Hubicka
6 ;;
7 ;; This file is part of GNU CC.
8 ;;
9 ;; GNU CC is free software; you can redistribute it and/or modify
10 ;; it under the terms of the GNU General Public License as published by
11 ;; the Free Software Foundation; either version 2, or (at your option)
12 ;; any later version.
14 ;; GNU CC is distributed in the hope that it will be useful,
15 ;; but WITHOUT ANY WARRANTY; without even the implied warranty of
16 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
17 ;; GNU General Public License for more details.
19 ;; You should have received a copy of the GNU General Public License
20 ;; along with GNU CC; see the file COPYING.  If not, write to
21 ;; the Free Software Foundation, 59 Temple Place - Suite 330,
22 ;; Boston, MA 02111-1307, USA.  */
24 ;; The original PO technology requires these to be ordered by speed,
25 ;; so that assigner will pick the fastest.
27 ;; See file "rtl.def" for documentation on define_insn, match_*, et. al.
29 ;; Macro #define NOTICE_UPDATE_CC in file i386.h handles condition code
30 ;; updates for most instructions.
32 ;; Macro REG_CLASS_FROM_LETTER in file i386.h defines the register
33 ;; constraint letters.
35 ;; The special asm out single letter directives following a '%' are:
36 ;; 'z' mov%z1 would be movl, movw, or movb depending on the mode of
37 ;;     operands[1].
38 ;; 'L' Print the opcode suffix for a 32-bit integer opcode.
39 ;; 'W' Print the opcode suffix for a 16-bit integer opcode.
40 ;; 'B' Print the opcode suffix for an 8-bit integer opcode.
41 ;; 'Q' Print the opcode suffix for a 64-bit float opcode.
42 ;; 'S' Print the opcode suffix for a 32-bit float opcode.
43 ;; 'T' Print the opcode suffix for an 80-bit extended real XFmode float opcode.
44 ;; 'J' Print the appropriate jump operand.
46 ;; 'b' Print the QImode name of the register for the indicated operand.
47 ;;     %b0 would print %al if operands[0] is reg 0.
48 ;; 'w' Likewise, print the HImode name of the register.
49 ;; 'k' Likewise, print the SImode name of the register.
50 ;; 'h' Print the QImode name for a "high" register, either ah, bh, ch or dh.
51 ;; 'y' Print "st(0)" instead of "st" as a register.
53 ;; UNSPEC usage:
55 (define_constants
56   [; Relocation specifiers
57    (UNSPEC_GOT                  0)
58    (UNSPEC_GOTOFF               1)
59    (UNSPEC_GOTPCREL             2)
60    (UNSPEC_GOTTPOFF             3)
61    (UNSPEC_TPOFF                4)
62    (UNSPEC_NTPOFF               5)
63    (UNSPEC_DTPOFF               6)
65    ; Prologue support
66    (UNSPEC_STACK_PROBE          10)
67    (UNSPEC_STACK_ALLOC          11)
68    (UNSPEC_SET_GOT              12)
69    (UNSPEC_SSE_PROLOGUE_SAVE    13)
71    ; TLS support
72    (UNSPEC_TP                   15)
73    (UNSPEC_TLS_GD               16)
74    (UNSPEC_TLS_LD_BASE          17)
76    ; Other random patterns
77    (UNSPEC_SCAS                 20)
78    (UNSPEC_SIN                  21)
79    (UNSPEC_COS                  22)
80    (UNSPEC_BSF                  23)
81    (UNSPEC_FNSTSW               24)
82    (UNSPEC_SAHF                 25)
83    (UNSPEC_FSTCW                26)
84    (UNSPEC_ADD_CARRY            27)
85    (UNSPEC_FLDCW                28)
87    ; For SSE/MMX support:
88    (UNSPEC_FIX                  30)
89    (UNSPEC_MASKMOV              32)
90    (UNSPEC_MOVMSK               33)
91    (UNSPEC_MOVNT                34)
92    (UNSPEC_MOVA                 38)
93    (UNSPEC_MOVU                 39)
94    (UNSPEC_SHUFFLE              41)
95    (UNSPEC_RCP                  42)
96    (UNSPEC_RSQRT                43)
97    (UNSPEC_SFENCE               44)
98    (UNSPEC_NOP                  45)     ; prevents combiner cleverness
99    (UNSPEC_PAVGUSB              49)
100    (UNSPEC_PFRCP                50)
101    (UNSPEC_PFRCPIT1             51)
102    (UNSPEC_PFRCPIT2             52)
103    (UNSPEC_PFRSQRT              53)
104    (UNSPEC_PFRSQIT1             54)
105    (UNSPEC_PSHUFLW              55)
106    (UNSPEC_PSHUFHW              56)
107    (UNSPEC_MFENCE               59)
108    (UNSPEC_LFENCE               60)
109    (UNSPEC_PSADBW               61)
110   ])
112 (define_constants
113   [(UNSPECV_BLOCKAGE            0)
114    (UNSPECV_EH_RETURN           13)
115    (UNSPECV_EMMS                31)
116    (UNSPECV_LDMXCSR             37)
117    (UNSPECV_STMXCSR             40)
118    (UNSPECV_FEMMS               46)
119    (UNSPECV_CLFLUSH             57)
120   ])
122 ;; Insns whose names begin with "x86_" are emitted by gen_FOO calls
123 ;; from i386.c.
125 ;; In C guard expressions, put expressions which may be compile-time
126 ;; constants first.  This allows for better optimization.  For
127 ;; example, write "TARGET_64BIT && reload_completed", not
128 ;; "reload_completed && TARGET_64BIT".
131 ;; Processor type.  This attribute must exactly match the processor_type
132 ;; enumeration in i386.h.
133 (define_attr "cpu" "i386,i486,pentium,pentiumpro,k6,athlon,pentium4"
134   (const (symbol_ref "ix86_cpu")))
136 ;; A basic instruction type.  Refinements due to arguments to be
137 ;; provided in other attributes.
138 (define_attr "type"
139   "other,multi,
140    alu,alu1,negnot,imov,imovx,lea,
141    incdec,ishift,rotate,imul,idiv,
142    icmp,test,ibr,setcc,icmov,
143    push,pop,call,callv,
144    str,cld,
145    fmov,fop,fsgn,fmul,fdiv,fpspc,fcmov,fcmp,fxch,fistp,
146    sselog,sseiadd,sseishft,sseimul,
147    sse,ssemov,sseadd,ssemul,ssecmp,ssecvt,ssediv,
148    mmx,mmxmov,mmxadd,mmxmul,mmxcmp,mmxcvt,mmxshft"
149   (const_string "other"))
151 ;; Main data type used by the insn
152 (define_attr "mode"
153   "unknown,none,QI,HI,SI,DI,unknownfp,SF,DF,XF,TI,V4SF,V2DF,V2SF"
154   (const_string "unknown"))
156 ;; The CPU unit operations uses.
157 (define_attr "unit" "integer,i387,sse,mmx,unknown"
158   (cond [(eq_attr "type" "fmov,fop,fsgn,fmul,fdiv,fpspc,fcmov,fcmp,fxch,fistp")
159            (const_string "i387")
160          (eq_attr "type" "sselog,sseiadd,sseishft,sseimul,
161                           sse,ssemov,sseadd,ssemul,ssecmp,ssecvt,ssediv")
162            (const_string "sse")
163          (eq_attr "type" "mmx,mmxmov,mmxadd,mmxmul,mmxcmp,mmxcvt,mmxshft")
164            (const_string "mmx")]
165          (const_string "integer")))
167 ;; The (bounding maximum) length of an instruction immediate.
168 (define_attr "length_immediate" ""
169   (cond [(eq_attr "type" "incdec,setcc,icmov,str,cld,lea,other,multi,idiv")
170            (const_int 0)
171          (eq_attr "unit" "i387,sse,mmx")
172            (const_int 0)
173          (eq_attr "type" "alu,alu1,negnot,imovx,ishift,rotate,imul,
174                           icmp,push,pop")
175            (symbol_ref "ix86_attr_length_immediate_default(insn,1)")
176          (eq_attr "type" "imov,test")
177            (symbol_ref "ix86_attr_length_immediate_default(insn,0)")
178          (eq_attr "type" "call")
179            (if_then_else (match_operand 0 "constant_call_address_operand" "")
180              (const_int 4)
181              (const_int 0))
182          (eq_attr "type" "callv")
183            (if_then_else (match_operand 1 "constant_call_address_operand" "")
184              (const_int 4)
185              (const_int 0))
186          (eq_attr "type" "ibr")
187            (if_then_else (and (ge (minus (match_dup 0) (pc))
188                                   (const_int -128))
189                               (lt (minus (match_dup 0) (pc))
190                                   (const_int 124)))
191              (const_int 1)
192              (const_int 4))
193          ]
194          (symbol_ref "/* Update immediate_length and other attributes! */
195                       abort(),1")))
197 ;; The (bounding maximum) length of an instruction address.
198 (define_attr "length_address" ""
199   (cond [(eq_attr "type" "str,cld,other,multi,fxch")
200            (const_int 0)
201          (and (eq_attr "type" "call")
202               (match_operand 0 "constant_call_address_operand" ""))
203              (const_int 0)
204          (and (eq_attr "type" "callv")
205               (match_operand 1 "constant_call_address_operand" ""))
206              (const_int 0)
207          ]
208          (symbol_ref "ix86_attr_length_address_default (insn)")))
210 ;; Set when length prefix is used.
211 (define_attr "prefix_data16" ""
212   (if_then_else (ior (eq_attr "mode" "HI")
213                      (and (eq_attr "unit" "sse") (eq_attr "mode" "V2DF")))
214     (const_int 1)
215     (const_int 0)))
217 ;; Set when string REP prefix is used.
218 (define_attr "prefix_rep" "" 
219   (if_then_else (and (eq_attr "unit" "sse") (eq_attr "mode" "SF,DF"))
220     (const_int 1)
221     (const_int 0)))
223 ;; Set when 0f opcode prefix is used.
224 (define_attr "prefix_0f" ""
225   (if_then_else 
226     (eq_attr "type" 
227              "imovx,setcc,icmov,
228               sselog,sseiadd,sseishft,sseimul,
229               sse,ssemov,sseadd,ssemul,ssecmp,ssecvt,ssediv,
230               mmx,mmxmov,mmxadd,mmxmul,mmxcmp,mmxcvt,mmxshft")
231     (const_int 1)
232     (const_int 0)))
234 ;; Set when modrm byte is used.
235 (define_attr "modrm" ""
236   (cond [(eq_attr "type" "str,cld")
237            (const_int 0)
238          (eq_attr "unit" "i387")
239            (const_int 0)
240          (and (eq_attr "type" "incdec")
241               (ior (match_operand:SI 1 "register_operand" "")
242                    (match_operand:HI 1 "register_operand" "")))
243            (const_int 0)
244          (and (eq_attr "type" "push")
245               (not (match_operand 1 "memory_operand" "")))
246            (const_int 0)
247          (and (eq_attr "type" "pop")
248               (not (match_operand 0 "memory_operand" "")))
249            (const_int 0)
250          (and (eq_attr "type" "imov")
251               (and (match_operand 0 "register_operand" "")
252                    (match_operand 1 "immediate_operand" "")))
253            (const_int 0)
254          (and (eq_attr "type" "call")
255               (match_operand 0 "constant_call_address_operand" ""))
256              (const_int 0)
257          (and (eq_attr "type" "callv")
258               (match_operand 1 "constant_call_address_operand" ""))
259              (const_int 0)
260          ]
261          (const_int 1)))
263 ;; The (bounding maximum) length of an instruction in bytes.
264 ;; ??? fistp is in fact fldcw/fistp/fldcw sequence.  Later we may want
265 ;; to split it and compute proper length as for other insns.
266 (define_attr "length" ""
267   (cond [(eq_attr "type" "other,multi,fistp")
268            (const_int 16)
269          (eq_attr "unit" "i387")
270            (plus (const_int 2)
271                  (plus (attr "prefix_data16")
272                        (attr "length_address")))]
273          (plus (plus (attr "modrm")
274                      (plus (attr "prefix_0f")
275                            (const_int 1)))
276                (plus (attr "prefix_rep")
277                      (plus (attr "prefix_data16")
278                            (plus (attr "length_immediate")
279                                  (attr "length_address")))))))
281 ;; The `memory' attribute is `none' if no memory is referenced, `load' or
282 ;; `store' if there is a simple memory reference therein, or `unknown'
283 ;; if the instruction is complex.
285 (define_attr "memory" "none,load,store,both,unknown"
286   (cond [(eq_attr "type" "other,multi,str")
287            (const_string "unknown")
288          (eq_attr "type" "lea,fcmov,fpspc,cld")
289            (const_string "none")
290          (eq_attr "type" "fistp")
291            (const_string "both")
292          (eq_attr "type" "push")
293            (if_then_else (match_operand 1 "memory_operand" "")
294              (const_string "both")
295              (const_string "store"))
296          (eq_attr "type" "pop,setcc")
297            (if_then_else (match_operand 0 "memory_operand" "")
298              (const_string "both")
299              (const_string "load"))
300          (eq_attr "type" "icmp,test,ssecmp,mmxcmp,fcmp")
301            (if_then_else (ior (match_operand 0 "memory_operand" "")
302                               (match_operand 1 "memory_operand" ""))
303              (const_string "load")
304              (const_string "none"))
305          (eq_attr "type" "ibr")
306            (if_then_else (match_operand 0 "memory_operand" "")
307              (const_string "load")
308              (const_string "none"))
309          (eq_attr "type" "call")
310            (if_then_else (match_operand 0 "constant_call_address_operand" "")
311              (const_string "none")
312              (const_string "load"))
313          (eq_attr "type" "callv")
314            (if_then_else (match_operand 1 "constant_call_address_operand" "")
315              (const_string "none")
316              (const_string "load"))
317          (and (eq_attr "type" "alu1,negnot")
318               (match_operand 1 "memory_operand" ""))
319            (const_string "both")
320          (and (match_operand 0 "memory_operand" "")
321               (match_operand 1 "memory_operand" ""))
322            (const_string "both")
323          (match_operand 0 "memory_operand" "")
324            (const_string "store")
325          (match_operand 1 "memory_operand" "")
326            (const_string "load")
327          (and (eq_attr "type"
328                  "!alu1,negnot,
329                    imov,imovx,icmp,test,
330                    fmov,fcmp,fsgn,
331                    sse,ssemov,ssecmp,ssecvt,
332                    mmx,mmxmov,mmxcmp,mmxcvt")
333               (match_operand 2 "memory_operand" ""))
334            (const_string "load")
335          (and (eq_attr "type" "icmov")
336               (match_operand 3 "memory_operand" ""))
337            (const_string "load")
338         ]
339         (const_string "none")))
341 ;; Indicates if an instruction has both an immediate and a displacement.
343 (define_attr "imm_disp" "false,true,unknown"
344   (cond [(eq_attr "type" "other,multi")
345            (const_string "unknown")
346          (and (eq_attr "type" "icmp,test,imov")
347               (and (match_operand 0 "memory_displacement_operand" "")
348                    (match_operand 1 "immediate_operand" "")))
349            (const_string "true")
350          (and (eq_attr "type" "alu,ishift,rotate,imul,idiv")
351               (and (match_operand 0 "memory_displacement_operand" "")
352                    (match_operand 2 "immediate_operand" "")))
353            (const_string "true")
354         ]
355         (const_string "false")))
357 ;; Indicates if an FP operation has an integer source.
359 (define_attr "fp_int_src" "false,true"
360   (const_string "false"))
362 ;; Describe a user's asm statement.
363 (define_asm_attributes
364   [(set_attr "length" "128")
365    (set_attr "type" "multi")])
367 (include "pentium.md")
368 (include "ppro.md")
369 (include "k6.md")
370 (include "athlon.md")
372 ;; Compare instructions.
374 ;; All compare insns have expanders that save the operands away without
375 ;; actually generating RTL.  The bCOND or sCOND (emitted immediately
376 ;; after the cmp) will actually emit the cmpM.
378 (define_expand "cmpdi"
379   [(set (reg:CC 17)
380         (compare:CC (match_operand:DI 0 "nonimmediate_operand" "")
381                     (match_operand:DI 1 "x86_64_general_operand" "")))]
382   ""
384   if (GET_CODE (operands[0]) == MEM && GET_CODE (operands[1]) == MEM)
385     operands[0] = force_reg (DImode, operands[0]);
386   ix86_compare_op0 = operands[0];
387   ix86_compare_op1 = operands[1];
388   DONE;
391 (define_expand "cmpsi"
392   [(set (reg:CC 17)
393         (compare:CC (match_operand:SI 0 "cmpsi_operand" "")
394                     (match_operand:SI 1 "general_operand" "")))]
395   ""
397   if (GET_CODE (operands[0]) == MEM && GET_CODE (operands[1]) == MEM)
398     operands[0] = force_reg (SImode, operands[0]);
399   ix86_compare_op0 = operands[0];
400   ix86_compare_op1 = operands[1];
401   DONE;
404 (define_expand "cmphi"
405   [(set (reg:CC 17)
406         (compare:CC (match_operand:HI 0 "nonimmediate_operand" "")
407                     (match_operand:HI 1 "general_operand" "")))]
408   ""
410   if (GET_CODE (operands[0]) == MEM && GET_CODE (operands[1]) == MEM)
411     operands[0] = force_reg (HImode, operands[0]);
412   ix86_compare_op0 = operands[0];
413   ix86_compare_op1 = operands[1];
414   DONE;
417 (define_expand "cmpqi"
418   [(set (reg:CC 17)
419         (compare:CC (match_operand:QI 0 "nonimmediate_operand" "")
420                     (match_operand:QI 1 "general_operand" "")))]
421   "TARGET_QIMODE_MATH"
423   if (GET_CODE (operands[0]) == MEM && GET_CODE (operands[1]) == MEM)
424     operands[0] = force_reg (QImode, operands[0]);
425   ix86_compare_op0 = operands[0];
426   ix86_compare_op1 = operands[1];
427   DONE;
430 (define_insn "cmpdi_ccno_1_rex64"
431   [(set (reg 17)
432         (compare (match_operand:DI 0 "nonimmediate_operand" "r,?mr")
433                  (match_operand:DI 1 "const0_operand" "n,n")))]
434   "TARGET_64BIT && ix86_match_ccmode (insn, CCNOmode)"
435   "@
436    test{q}\t{%0, %0|%0, %0}
437    cmp{q}\t{%1, %0|%0, %1}"
438   [(set_attr "type" "test,icmp")
439    (set_attr "length_immediate" "0,1")
440    (set_attr "mode" "DI")])
442 (define_insn "*cmpdi_minus_1_rex64"
443   [(set (reg 17)
444         (compare (minus:DI (match_operand:DI 0 "nonimmediate_operand" "rm,r")
445                            (match_operand:DI 1 "x86_64_general_operand" "re,mr"))
446                  (const_int 0)))]
447   "TARGET_64BIT && ix86_match_ccmode (insn, CCGOCmode)"
448   "cmp{q}\t{%1, %0|%0, %1}"
449   [(set_attr "type" "icmp")
450    (set_attr "mode" "DI")])
452 (define_expand "cmpdi_1_rex64"
453   [(set (reg:CC 17)
454         (compare:CC (match_operand:DI 0 "nonimmediate_operand" "")
455                     (match_operand:DI 1 "general_operand" "")))]
456   "TARGET_64BIT"
457   "")
459 (define_insn "cmpdi_1_insn_rex64"
460   [(set (reg 17)
461         (compare (match_operand:DI 0 "nonimmediate_operand" "mr,r")
462                  (match_operand:DI 1 "x86_64_general_operand" "re,mr")))]
463   "TARGET_64BIT && ix86_match_ccmode (insn, CCmode)"
464   "cmp{q}\t{%1, %0|%0, %1}"
465   [(set_attr "type" "icmp")
466    (set_attr "mode" "DI")])
469 (define_insn "*cmpsi_ccno_1"
470   [(set (reg 17)
471         (compare (match_operand:SI 0 "nonimmediate_operand" "r,?mr")
472                  (match_operand:SI 1 "const0_operand" "n,n")))]
473   "ix86_match_ccmode (insn, CCNOmode)"
474   "@
475    test{l}\t{%0, %0|%0, %0}
476    cmp{l}\t{%1, %0|%0, %1}"
477   [(set_attr "type" "test,icmp")
478    (set_attr "length_immediate" "0,1")
479    (set_attr "mode" "SI")])
481 (define_insn "*cmpsi_minus_1"
482   [(set (reg 17)
483         (compare (minus:SI (match_operand:SI 0 "nonimmediate_operand" "rm,r")
484                            (match_operand:SI 1 "general_operand" "ri,mr"))
485                  (const_int 0)))]
486   "ix86_match_ccmode (insn, CCGOCmode)"
487   "cmp{l}\t{%1, %0|%0, %1}"
488   [(set_attr "type" "icmp")
489    (set_attr "mode" "SI")])
491 (define_expand "cmpsi_1"
492   [(set (reg:CC 17)
493         (compare:CC (match_operand:SI 0 "nonimmediate_operand" "rm,r")
494                     (match_operand:SI 1 "general_operand" "ri,mr")))]
495   ""
496   "")
498 (define_insn "*cmpsi_1_insn"
499   [(set (reg 17)
500         (compare (match_operand:SI 0 "nonimmediate_operand" "rm,r")
501                  (match_operand:SI 1 "general_operand" "ri,mr")))]
502   "(GET_CODE (operands[0]) != MEM || GET_CODE (operands[1]) != MEM)
503     && ix86_match_ccmode (insn, CCmode)"
504   "cmp{l}\t{%1, %0|%0, %1}"
505   [(set_attr "type" "icmp")
506    (set_attr "mode" "SI")])
508 (define_insn "*cmphi_ccno_1"
509   [(set (reg 17)
510         (compare (match_operand:HI 0 "nonimmediate_operand" "r,?mr")
511                  (match_operand:HI 1 "const0_operand" "n,n")))]
512   "ix86_match_ccmode (insn, CCNOmode)"
513   "@
514    test{w}\t{%0, %0|%0, %0}
515    cmp{w}\t{%1, %0|%0, %1}"
516   [(set_attr "type" "test,icmp")
517    (set_attr "length_immediate" "0,1")
518    (set_attr "mode" "HI")])
520 (define_insn "*cmphi_minus_1"
521   [(set (reg 17)
522         (compare (minus:HI (match_operand:HI 0 "nonimmediate_operand" "rm,r")
523                            (match_operand:HI 1 "general_operand" "ri,mr"))
524                  (const_int 0)))]
525   "ix86_match_ccmode (insn, CCGOCmode)"
526   "cmp{w}\t{%1, %0|%0, %1}"
527   [(set_attr "type" "icmp")
528    (set_attr "mode" "HI")])
530 (define_insn "*cmphi_1"
531   [(set (reg 17)
532         (compare (match_operand:HI 0 "nonimmediate_operand" "rm,r")
533                  (match_operand:HI 1 "general_operand" "ri,mr")))]
534   "(GET_CODE (operands[0]) != MEM || GET_CODE (operands[1]) != MEM)
535    && ix86_match_ccmode (insn, CCmode)"
536   "cmp{w}\t{%1, %0|%0, %1}"
537   [(set_attr "type" "icmp")
538    (set_attr "mode" "HI")])
540 (define_insn "*cmpqi_ccno_1"
541   [(set (reg 17)
542         (compare (match_operand:QI 0 "nonimmediate_operand" "q,?mq")
543                  (match_operand:QI 1 "const0_operand" "n,n")))]
544   "ix86_match_ccmode (insn, CCNOmode)"
545   "@
546    test{b}\t{%0, %0|%0, %0}
547    cmp{b}\t{$0, %0|%0, 0}"
548   [(set_attr "type" "test,icmp")
549    (set_attr "length_immediate" "0,1")
550    (set_attr "mode" "QI")])
552 (define_insn "*cmpqi_1"
553   [(set (reg 17)
554         (compare (match_operand:QI 0 "nonimmediate_operand" "qm,q")
555                  (match_operand:QI 1 "general_operand" "qi,mq")))]
556   "(GET_CODE (operands[0]) != MEM || GET_CODE (operands[1]) != MEM)
557     && ix86_match_ccmode (insn, CCmode)"
558   "cmp{b}\t{%1, %0|%0, %1}"
559   [(set_attr "type" "icmp")
560    (set_attr "mode" "QI")])
562 (define_insn "*cmpqi_minus_1"
563   [(set (reg 17)
564         (compare (minus:QI (match_operand:QI 0 "nonimmediate_operand" "qm,q")
565                            (match_operand:QI 1 "general_operand" "qi,mq"))
566                  (const_int 0)))]
567   "ix86_match_ccmode (insn, CCGOCmode)"
568   "cmp{b}\t{%1, %0|%0, %1}"
569   [(set_attr "type" "icmp")
570    (set_attr "mode" "QI")])
572 (define_insn "*cmpqi_ext_1"
573   [(set (reg 17)
574         (compare
575           (match_operand:QI 0 "general_operand" "Qm")
576           (subreg:QI
577             (zero_extract:SI
578               (match_operand 1 "ext_register_operand" "Q")
579               (const_int 8)
580               (const_int 8)) 0)))]
581   "!TARGET_64BIT && ix86_match_ccmode (insn, CCmode)"
582   "cmp{b}\t{%h1, %0|%0, %h1}"
583   [(set_attr "type" "icmp")
584    (set_attr "mode" "QI")])
586 (define_insn "*cmpqi_ext_1_rex64"
587   [(set (reg 17)
588         (compare
589           (match_operand:QI 0 "register_operand" "Q")
590           (subreg:QI
591             (zero_extract:SI
592               (match_operand 1 "ext_register_operand" "Q")
593               (const_int 8)
594               (const_int 8)) 0)))]
595   "TARGET_64BIT && ix86_match_ccmode (insn, CCmode)"
596   "cmp{b}\t{%h1, %0|%0, %h1}"
597   [(set_attr "type" "icmp")
598    (set_attr "mode" "QI")])
600 (define_insn "*cmpqi_ext_2"
601   [(set (reg 17)
602         (compare
603           (subreg:QI
604             (zero_extract:SI
605               (match_operand 0 "ext_register_operand" "Q")
606               (const_int 8)
607               (const_int 8)) 0)
608           (match_operand:QI 1 "const0_operand" "n")))]
609   "ix86_match_ccmode (insn, CCNOmode)"
610   "test{b}\t%h0, %h0"
611   [(set_attr "type" "test")
612    (set_attr "length_immediate" "0")
613    (set_attr "mode" "QI")])
615 (define_expand "cmpqi_ext_3"
616   [(set (reg:CC 17)
617         (compare:CC
618           (subreg:QI
619             (zero_extract:SI
620               (match_operand 0 "ext_register_operand" "")
621               (const_int 8)
622               (const_int 8)) 0)
623           (match_operand:QI 1 "general_operand" "")))]
624   ""
625   "")
627 (define_insn "cmpqi_ext_3_insn"
628   [(set (reg 17)
629         (compare
630           (subreg:QI
631             (zero_extract:SI
632               (match_operand 0 "ext_register_operand" "Q")
633               (const_int 8)
634               (const_int 8)) 0)
635           (match_operand:QI 1 "general_operand" "Qmn")))]
636   "!TARGET_64BIT && ix86_match_ccmode (insn, CCmode)"
637   "cmp{b}\t{%1, %h0|%h0, %1}"
638   [(set_attr "type" "icmp")
639    (set_attr "mode" "QI")])
641 (define_insn "cmpqi_ext_3_insn_rex64"
642   [(set (reg 17)
643         (compare
644           (subreg:QI
645             (zero_extract:SI
646               (match_operand 0 "ext_register_operand" "Q")
647               (const_int 8)
648               (const_int 8)) 0)
649           (match_operand:QI 1 "nonmemory_operand" "Qn")))]
650   "TARGET_64BIT && ix86_match_ccmode (insn, CCmode)"
651   "cmp{b}\t{%1, %h0|%h0, %1}"
652   [(set_attr "type" "icmp")
653    (set_attr "mode" "QI")])
655 (define_insn "*cmpqi_ext_4"
656   [(set (reg 17)
657         (compare
658           (subreg:QI
659             (zero_extract:SI
660               (match_operand 0 "ext_register_operand" "Q")
661               (const_int 8)
662               (const_int 8)) 0)
663           (subreg:QI
664             (zero_extract:SI
665               (match_operand 1 "ext_register_operand" "Q")
666               (const_int 8)
667               (const_int 8)) 0)))]
668   "ix86_match_ccmode (insn, CCmode)"
669   "cmp{b}\t{%h1, %h0|%h0, %h1}"
670   [(set_attr "type" "icmp")
671    (set_attr "mode" "QI")])
673 ;; These implement float point compares.
674 ;; %%% See if we can get away with VOIDmode operands on the actual insns,
675 ;; which would allow mix and match FP modes on the compares.  Which is what
676 ;; the old patterns did, but with many more of them.
678 (define_expand "cmpxf"
679   [(set (reg:CC 17)
680         (compare:CC (match_operand:XF 0 "cmp_fp_expander_operand" "")
681                     (match_operand:XF 1 "cmp_fp_expander_operand" "")))]
682   "!TARGET_64BIT && TARGET_80387"
684   ix86_compare_op0 = operands[0];
685   ix86_compare_op1 = operands[1];
686   DONE;
689 (define_expand "cmptf"
690   [(set (reg:CC 17)
691         (compare:CC (match_operand:TF 0 "cmp_fp_expander_operand" "")
692                     (match_operand:TF 1 "cmp_fp_expander_operand" "")))]
693   "TARGET_80387"
695   ix86_compare_op0 = operands[0];
696   ix86_compare_op1 = operands[1];
697   DONE;
700 (define_expand "cmpdf"
701   [(set (reg:CC 17)
702         (compare:CC (match_operand:DF 0 "cmp_fp_expander_operand" "")
703                     (match_operand:DF 1 "cmp_fp_expander_operand" "")))]
704   "TARGET_80387 || TARGET_SSE2"
706   ix86_compare_op0 = operands[0];
707   ix86_compare_op1 = operands[1];
708   DONE;
711 (define_expand "cmpsf"
712   [(set (reg:CC 17)
713         (compare:CC (match_operand:SF 0 "cmp_fp_expander_operand" "")
714                     (match_operand:SF 1 "cmp_fp_expander_operand" "")))]
715   "TARGET_80387 || TARGET_SSE"
717   ix86_compare_op0 = operands[0];
718   ix86_compare_op1 = operands[1];
719   DONE;
722 ;; FP compares, step 1:
723 ;; Set the FP condition codes.
725 ;; CCFPmode     compare with exceptions
726 ;; CCFPUmode    compare with no exceptions
728 ;; %%% It is an unfortunate fact that ftst has no non-popping variant,
729 ;; and that fp moves clobber the condition codes, and that there is
730 ;; currently no way to describe this fact to reg-stack.  So there are
731 ;; no splitters yet for this.
733 ;; %%% YIKES!  This scheme does not retain a strong connection between 
734 ;; the real compare and the ultimate cc0 user, so CC_REVERSE does not
735 ;; work!  Only allow tos/mem with tos in op 0.
737 ;; Hmm, of course, this is what the actual _hardware_ does.  Perhaps
738 ;; things aren't as bad as they sound...
740 (define_insn "*cmpfp_0"
741   [(set (match_operand:HI 0 "register_operand" "=a")
742         (unspec:HI
743           [(compare:CCFP (match_operand 1 "register_operand" "f")
744                          (match_operand 2 "const0_operand" "X"))]
745           UNSPEC_FNSTSW))]
746   "TARGET_80387
747    && FLOAT_MODE_P (GET_MODE (operands[1]))
748    && GET_MODE (operands[1]) == GET_MODE (operands[2])"
750   if (find_regno_note (insn, REG_DEAD, REGNO (operands[1])))
751     return "ftst\;fnstsw\t%0\;fstp\t%y0";
752   else
753     return "ftst\;fnstsw\t%0";
755   [(set_attr "type" "multi")
756    (set_attr "mode" "unknownfp")])
758 ;; We may not use "#" to split and emit these, since the REG_DEAD notes
759 ;; used to manage the reg stack popping would not be preserved.
761 (define_insn "*cmpfp_2_sf"
762   [(set (reg:CCFP 18)
763         (compare:CCFP
764           (match_operand:SF 0 "register_operand" "f")
765           (match_operand:SF 1 "nonimmediate_operand" "fm")))]
766   "TARGET_80387"
767   "* return output_fp_compare (insn, operands, 0, 0);"
768   [(set_attr "type" "fcmp")
769    (set_attr "mode" "SF")])
771 (define_insn "*cmpfp_2_sf_1"
772   [(set (match_operand:HI 0 "register_operand" "=a")
773         (unspec:HI
774           [(compare:CCFP
775              (match_operand:SF 1 "register_operand" "f")
776              (match_operand:SF 2 "nonimmediate_operand" "fm"))]
777           UNSPEC_FNSTSW))]
778   "TARGET_80387"
779   "* return output_fp_compare (insn, operands, 2, 0);"
780   [(set_attr "type" "fcmp")
781    (set_attr "mode" "SF")])
783 (define_insn "*cmpfp_2_df"
784   [(set (reg:CCFP 18)
785         (compare:CCFP
786           (match_operand:DF 0 "register_operand" "f")
787           (match_operand:DF 1 "nonimmediate_operand" "fm")))]
788   "TARGET_80387"
789   "* return output_fp_compare (insn, operands, 0, 0);"
790   [(set_attr "type" "fcmp")
791    (set_attr "mode" "DF")])
793 (define_insn "*cmpfp_2_df_1"
794   [(set (match_operand:HI 0 "register_operand" "=a")
795         (unspec:HI
796           [(compare:CCFP
797              (match_operand:DF 1 "register_operand" "f")
798              (match_operand:DF 2 "nonimmediate_operand" "fm"))]
799           UNSPEC_FNSTSW))]
800   "TARGET_80387"
801   "* return output_fp_compare (insn, operands, 2, 0);"
802   [(set_attr "type" "multi")
803    (set_attr "mode" "DF")])
805 (define_insn "*cmpfp_2_xf"
806   [(set (reg:CCFP 18)
807         (compare:CCFP
808           (match_operand:XF 0 "register_operand" "f")
809           (match_operand:XF 1 "register_operand" "f")))]
810   "!TARGET_64BIT && TARGET_80387"
811   "* return output_fp_compare (insn, operands, 0, 0);"
812   [(set_attr "type" "fcmp")
813    (set_attr "mode" "XF")])
815 (define_insn "*cmpfp_2_tf"
816   [(set (reg:CCFP 18)
817         (compare:CCFP
818           (match_operand:TF 0 "register_operand" "f")
819           (match_operand:TF 1 "register_operand" "f")))]
820   "TARGET_80387"
821   "* return output_fp_compare (insn, operands, 0, 0);"
822   [(set_attr "type" "fcmp")
823    (set_attr "mode" "XF")])
825 (define_insn "*cmpfp_2_xf_1"
826   [(set (match_operand:HI 0 "register_operand" "=a")
827         (unspec:HI
828           [(compare:CCFP
829              (match_operand:XF 1 "register_operand" "f")
830              (match_operand:XF 2 "register_operand" "f"))]
831           UNSPEC_FNSTSW))]
832   "!TARGET_64BIT && TARGET_80387"
833   "* return output_fp_compare (insn, operands, 2, 0);"
834   [(set_attr "type" "multi")
835    (set_attr "mode" "XF")])
837 (define_insn "*cmpfp_2_tf_1"
838   [(set (match_operand:HI 0 "register_operand" "=a")
839         (unspec:HI
840           [(compare:CCFP
841              (match_operand:TF 1 "register_operand" "f")
842              (match_operand:TF 2 "register_operand" "f"))]
843           UNSPEC_FNSTSW))]
844   "TARGET_80387"
845   "* return output_fp_compare (insn, operands, 2, 0);"
846   [(set_attr "type" "multi")
847    (set_attr "mode" "XF")])
849 (define_insn "*cmpfp_2u"
850   [(set (reg:CCFPU 18)
851         (compare:CCFPU
852           (match_operand 0 "register_operand" "f")
853           (match_operand 1 "register_operand" "f")))]
854   "TARGET_80387
855    && FLOAT_MODE_P (GET_MODE (operands[0]))
856    && GET_MODE (operands[0]) == GET_MODE (operands[1])"
857   "* return output_fp_compare (insn, operands, 0, 1);"
858   [(set_attr "type" "fcmp")
859    (set_attr "mode" "unknownfp")])
861 (define_insn "*cmpfp_2u_1"
862   [(set (match_operand:HI 0 "register_operand" "=a")
863         (unspec:HI
864           [(compare:CCFPU
865              (match_operand 1 "register_operand" "f")
866              (match_operand 2 "register_operand" "f"))]
867           UNSPEC_FNSTSW))]
868   "TARGET_80387
869    && FLOAT_MODE_P (GET_MODE (operands[1]))
870    && GET_MODE (operands[1]) == GET_MODE (operands[2])"
871   "* return output_fp_compare (insn, operands, 2, 1);"
872   [(set_attr "type" "multi")
873    (set_attr "mode" "unknownfp")])
875 ;; Patterns to match the SImode-in-memory ficom instructions.
877 ;; %%% Play games with accepting gp registers, as otherwise we have to
878 ;; force them to memory during rtl generation, which is no good.  We
879 ;; can get rid of this once we teach reload to do memory input reloads 
880 ;; via pushes.
882 (define_insn "*ficom_1"
883   [(set (reg:CCFP 18)
884         (compare:CCFP
885           (match_operand 0 "register_operand" "f,f")
886           (float (match_operand:SI 1 "nonimmediate_operand" "m,?r"))))]
887   "0 && TARGET_80387 && FLOAT_MODE_P (GET_MODE (operands[0]))
888    && GET_MODE (XEXP (SET_SRC (PATTERN (insn)), 1)) == GET_MODE (operands[0])"
889   "#")
891 ;; Split the not-really-implemented gp register case into a
892 ;; push-op-pop sequence.
894 ;; %%% This is most efficient, but am I gonna get in trouble
895 ;; for separating cc0_setter and cc0_user?
897 (define_split
898   [(set (reg:CCFP 18)
899         (compare:CCFP
900           (match_operand:SF 0 "register_operand" "")
901           (float (match_operand:SI 1 "register_operand" ""))))]
902   "0 && TARGET_80387 && reload_completed"
903   [(set (mem:SI (pre_dec:SI (reg:SI 7))) (match_dup 1))
904    (set (reg:CCFP 18) (compare:CCFP (match_dup 0) (match_dup 2)))
905    (parallel [(set (match_dup 1) (mem:SI (reg:SI 7)))
906               (set (reg:SI 7) (plus:SI (reg:SI 7) (const_int 4)))])]
907   "operands[2] = gen_rtx_MEM (Pmode, stack_pointer_rtx);
908    operands[2] = gen_rtx_FLOAT (GET_MODE (operands[0]), operands[2]);")
910 ;; FP compares, step 2
911 ;; Move the fpsw to ax.
913 (define_insn "x86_fnstsw_1"
914   [(set (match_operand:HI 0 "register_operand" "=a")
915         (unspec:HI [(reg 18)] UNSPEC_FNSTSW))]
916   "TARGET_80387"
917   "fnstsw\t%0"
918   [(set_attr "length" "2")
919    (set_attr "mode" "SI")
920    (set_attr "unit" "i387")
921    (set_attr "ppro_uops" "few")])
923 ;; FP compares, step 3
924 ;; Get ax into flags, general case.
926 (define_insn "x86_sahf_1"
927   [(set (reg:CC 17)
928         (unspec:CC [(match_operand:HI 0 "register_operand" "a")] UNSPEC_SAHF))]
929   "!TARGET_64BIT"
930   "sahf"
931   [(set_attr "length" "1")
932    (set_attr "athlon_decode" "vector")
933    (set_attr "mode" "SI")
934    (set_attr "ppro_uops" "one")])
936 ;; Pentium Pro can do steps 1 through 3 in one go.
938 (define_insn "*cmpfp_i"
939   [(set (reg:CCFP 17)
940         (compare:CCFP (match_operand 0 "register_operand" "f")
941                       (match_operand 1 "register_operand" "f")))]
942   "TARGET_80387 && TARGET_CMOVE
943    && !SSE_FLOAT_MODE_P (GET_MODE (operands[0]))
944    && FLOAT_MODE_P (GET_MODE (operands[0]))
945    && GET_MODE (operands[0]) == GET_MODE (operands[0])"
946   "* return output_fp_compare (insn, operands, 1, 0);"
947   [(set_attr "type" "fcmp")
948    (set_attr "mode" "unknownfp")
949    (set_attr "athlon_decode" "vector")])
951 (define_insn "*cmpfp_i_sse"
952   [(set (reg:CCFP 17)
953         (compare:CCFP (match_operand 0 "register_operand" "f#x,x#f")
954                       (match_operand 1 "nonimmediate_operand" "f#x,xm#f")))]
955   "TARGET_80387
956    && SSE_FLOAT_MODE_P (GET_MODE (operands[0]))
957    && GET_MODE (operands[0]) == GET_MODE (operands[0])"
958   "* return output_fp_compare (insn, operands, 1, 0);"
959   [(set_attr "type" "fcmp,ssecmp")
960    (set_attr "mode" "unknownfp")
961    (set_attr "athlon_decode" "vector")])
963 (define_insn "*cmpfp_i_sse_only"
964   [(set (reg:CCFP 17)
965         (compare:CCFP (match_operand 0 "register_operand" "x")
966                       (match_operand 1 "nonimmediate_operand" "xm")))]
967   "SSE_FLOAT_MODE_P (GET_MODE (operands[0]))
968    && GET_MODE (operands[0]) == GET_MODE (operands[0])"
969   "* return output_fp_compare (insn, operands, 1, 0);"
970   [(set_attr "type" "ssecmp")
971    (set_attr "mode" "unknownfp")
972    (set_attr "athlon_decode" "vector")])
974 (define_insn "*cmpfp_iu"
975   [(set (reg:CCFPU 17)
976         (compare:CCFPU (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[1])"
982   "* return output_fp_compare (insn, operands, 1, 1);"
983   [(set_attr "type" "fcmp")
984    (set_attr "mode" "unknownfp")
985    (set_attr "athlon_decode" "vector")])
987 (define_insn "*cmpfp_iu_sse"
988   [(set (reg:CCFPU 17)
989         (compare:CCFPU (match_operand 0 "register_operand" "f#x,x#f")
990                        (match_operand 1 "nonimmediate_operand" "f#x,xm#f")))]
991   "TARGET_80387
992    && SSE_FLOAT_MODE_P (GET_MODE (operands[0]))
993    && GET_MODE (operands[0]) == GET_MODE (operands[1])"
994   "* return output_fp_compare (insn, operands, 1, 1);"
995   [(set_attr "type" "fcmp,ssecmp")
996    (set_attr "mode" "unknownfp")
997    (set_attr "athlon_decode" "vector")])
999 (define_insn "*cmpfp_iu_sse_only"
1000   [(set (reg:CCFPU 17)
1001         (compare:CCFPU (match_operand 0 "register_operand" "x")
1002                        (match_operand 1 "nonimmediate_operand" "xm")))]
1003   "SSE_FLOAT_MODE_P (GET_MODE (operands[0]))
1004    && GET_MODE (operands[0]) == GET_MODE (operands[1])"
1005   "* return output_fp_compare (insn, operands, 1, 1);"
1006   [(set_attr "type" "ssecmp")
1007    (set_attr "mode" "unknownfp")
1008    (set_attr "athlon_decode" "vector")])
1010 ;; Move instructions.
1012 ;; General case of fullword move.
1014 (define_expand "movsi"
1015   [(set (match_operand:SI 0 "nonimmediate_operand" "")
1016         (match_operand:SI 1 "general_operand" ""))]
1017   ""
1018   "ix86_expand_move (SImode, operands); DONE;")
1020 ;; Push/pop instructions.  They are separate since autoinc/dec is not a
1021 ;; general_operand.
1023 ;; %%% We don't use a post-inc memory reference because x86 is not a 
1024 ;; general AUTO_INC_DEC host, which impacts how it is treated in flow.
1025 ;; Changing this impacts compiler performance on other non-AUTO_INC_DEC
1026 ;; targets without our curiosities, and it is just as easy to represent
1027 ;; this differently.
1029 (define_insn "*pushsi2"
1030   [(set (match_operand:SI 0 "push_operand" "=<")
1031         (match_operand:SI 1 "general_no_elim_operand" "ri*m"))]
1032   "!TARGET_64BIT"
1033   "push{l}\t%1"
1034   [(set_attr "type" "push")
1035    (set_attr "mode" "SI")])
1037 ;; For 64BIT abi we always round up to 8 bytes.
1038 (define_insn "*pushsi2_rex64"
1039   [(set (match_operand:SI 0 "push_operand" "=X")
1040         (match_operand:SI 1 "nonmemory_no_elim_operand" "ri"))]
1041   "TARGET_64BIT"
1042   "push{q}\t%q1"
1043   [(set_attr "type" "push")
1044    (set_attr "mode" "SI")])
1046 (define_insn "*pushsi2_prologue"
1047   [(set (match_operand:SI 0 "push_operand" "=<")
1048         (match_operand:SI 1 "general_no_elim_operand" "ri*m"))
1049    (clobber (mem:BLK (scratch)))]
1050   "!TARGET_64BIT"
1051   "push{l}\t%1"
1052   [(set_attr "type" "push")
1053    (set_attr "mode" "SI")])
1055 (define_insn "*popsi1_epilogue"
1056   [(set (match_operand:SI 0 "nonimmediate_operand" "=r*m")
1057         (mem:SI (reg:SI 7)))
1058    (set (reg:SI 7)
1059         (plus:SI (reg:SI 7) (const_int 4)))
1060    (clobber (mem:BLK (scratch)))]
1061   "!TARGET_64BIT"
1062   "pop{l}\t%0"
1063   [(set_attr "type" "pop")
1064    (set_attr "mode" "SI")])
1066 (define_insn "popsi1"
1067   [(set (match_operand:SI 0 "nonimmediate_operand" "=r*m")
1068         (mem:SI (reg:SI 7)))
1069    (set (reg:SI 7)
1070         (plus:SI (reg:SI 7) (const_int 4)))]
1071   "!TARGET_64BIT"
1072   "pop{l}\t%0"
1073   [(set_attr "type" "pop")
1074    (set_attr "mode" "SI")])
1076 (define_insn "*movsi_xor"
1077   [(set (match_operand:SI 0 "register_operand" "=r")
1078         (match_operand:SI 1 "const0_operand" "i"))
1079    (clobber (reg:CC 17))]
1080   "reload_completed && (!TARGET_USE_MOV0 || optimize_size)"
1081   "xor{l}\t{%0, %0|%0, %0}"
1082   [(set_attr "type" "alu1")
1083    (set_attr "mode" "SI")
1084    (set_attr "length_immediate" "0")])
1086 (define_insn "*movsi_or"
1087   [(set (match_operand:SI 0 "register_operand" "=r")
1088         (match_operand:SI 1 "immediate_operand" "i"))
1089    (clobber (reg:CC 17))]
1090   "reload_completed && GET_CODE (operands[1]) == CONST_INT
1091    && INTVAL (operands[1]) == -1
1092    && (TARGET_PENTIUM || optimize_size)"
1094   operands[1] = constm1_rtx;
1095   return "or{l}\t{%1, %0|%0, %1}";
1097   [(set_attr "type" "alu1")
1098    (set_attr "mode" "SI")
1099    (set_attr "length_immediate" "1")])
1101 ; The first alternative is used only to compute proper length of instruction.
1102 ; Reload's algorithm does not take into account the cost of spill instructions
1103 ; needed to free register in given class, so avoid it from choosing the first
1104 ; alternative when eax is not available.
1106 (define_insn "*movsi_1"
1107   [(set (match_operand:SI 0 "nonimmediate_operand" "=*?a,r,*?a,m,!*y,!rm,!*y,!*Y,!rm,!*Y")
1108         (match_operand:SI 1 "general_operand" "im,rinm,rinm,rin,rm,*y,*y,rm,*Y,*Y"))]
1109   "GET_CODE (operands[0]) != MEM || GET_CODE (operands[1]) != MEM"
1111   switch (get_attr_type (insn))
1112     {
1113     case TYPE_SSEMOV:
1114       if (get_attr_mode (insn) == TImode)
1115         return "movdqa\t{%1, %0|%0, %1}";
1116       return "movd\t{%1, %0|%0, %1}";
1118     case TYPE_MMXMOV:
1119       if (get_attr_mode (insn) == DImode)
1120         return "movq\t{%1, %0|%0, %1}";
1121       return "movd\t{%1, %0|%0, %1}";
1123     case TYPE_LEA:
1124       return "lea{l}\t{%1, %0|%0, %1}";
1126     default:
1127       if (flag_pic && !LEGITIMATE_PIC_OPERAND_P (operands[1]))
1128         abort();
1129       return "mov{l}\t{%1, %0|%0, %1}";
1130     }
1132   [(set (attr "type")
1133      (cond [(eq_attr "alternative" "4,5,6")
1134               (const_string "mmxmov")
1135             (eq_attr "alternative" "7,8,9")
1136               (const_string "ssemov")
1137             (and (ne (symbol_ref "flag_pic") (const_int 0))
1138                  (match_operand:SI 1 "symbolic_operand" ""))
1139               (const_string "lea")
1140            ]
1141            (const_string "imov")))
1142    (set_attr "modrm" "0,*,0,*,*,*,*,*,*,*")
1143    (set_attr "mode" "SI,SI,SI,SI,SI,SI,DI,TI,SI,SI")])
1145 ;; Stores and loads of ax to arbitary constant address.
1146 ;; We fake an second form of instruction to force reload to load address
1147 ;; into register when rax is not available
1148 (define_insn "*movabssi_1_rex64"
1149   [(set (mem:SI (match_operand:DI 0 "x86_64_movabs_operand" "i,r,r"))
1150         (match_operand:SI 1 "nonmemory_operand" "a,er,i"))]
1151   "TARGET_64BIT"
1152   "@
1153    movabs{l}\t{%1, %P0|%P0, %1}
1154    mov{l}\t{%1, %a0|%a0, %1}
1155    movabs{l}\t{%1, %a0|%a0, %1}"
1156   [(set_attr "type" "imov")
1157    (set_attr "modrm" "0,*,*")
1158    (set_attr "length_address" "8,0,0")
1159    (set_attr "length_immediate" "0,*,*")
1160    (set_attr "memory" "store")
1161    (set_attr "mode" "SI")])
1163 (define_insn "*movabssi_2_rex64"
1164   [(set (match_operand:SI 0 "register_operand" "=a,r")
1165         (mem:SI (match_operand:DI 1 "x86_64_movabs_operand" "i,r")))]
1166   "TARGET_64BIT"
1167   "@
1168    movabs{l}\t{%P1, %0|%0, %P1}
1169    mov{l}\t{%a1, %0|%0, %a1}"
1170   [(set_attr "type" "imov")
1171    (set_attr "modrm" "0,*")
1172    (set_attr "length_address" "8,0")
1173    (set_attr "length_immediate" "0")
1174    (set_attr "memory" "load")
1175    (set_attr "mode" "SI")])
1177 (define_insn "*swapsi"
1178   [(set (match_operand:SI 0 "register_operand" "+r")
1179         (match_operand:SI 1 "register_operand" "+r"))
1180    (set (match_dup 1)
1181         (match_dup 0))]
1182   ""
1183   "xchg{l}\t%1, %0"
1184   [(set_attr "type" "imov")
1185    (set_attr "pent_pair" "np")
1186    (set_attr "athlon_decode" "vector")
1187    (set_attr "mode" "SI")
1188    (set_attr "modrm" "0")
1189    (set_attr "ppro_uops" "few")])
1191 (define_expand "movhi"
1192   [(set (match_operand:HI 0 "nonimmediate_operand" "")
1193         (match_operand:HI 1 "general_operand" ""))]
1194   ""
1195   "ix86_expand_move (HImode, operands); DONE;")
1197 (define_insn "*pushhi2"
1198   [(set (match_operand:HI 0 "push_operand" "=<,<")
1199         (match_operand:HI 1 "general_no_elim_operand" "n,r*m"))]
1200   "!TARGET_64BIT"
1201   "@
1202    push{w}\t{|WORD PTR }%1
1203    push{w}\t%1"
1204   [(set_attr "type" "push")
1205    (set_attr "mode" "HI")])
1207 ;; For 64BIT abi we always round up to 8 bytes.
1208 (define_insn "*pushhi2_rex64"
1209   [(set (match_operand:HI 0 "push_operand" "=X")
1210         (match_operand:HI 1 "nonmemory_no_elim_operand" "ri"))]
1211   "TARGET_64BIT"
1212   "push{q}\t%q1"
1213   [(set_attr "type" "push")
1214    (set_attr "mode" "QI")])
1216 ; The first alternative is used only to compute proper length of instruction.
1217 ; Reload's algorithm does not take into account the cost of spill instructions
1218 ; needed to free register in given class, so avoid it from choosing the first
1219 ; alternative when eax is not available.
1221 (define_insn "*movhi_1"
1222   [(set (match_operand:HI 0 "nonimmediate_operand" "=*?a,r,r,*?a,r,m")
1223         (match_operand:HI 1 "general_operand" "i,r,rn,rm,rm,rn"))]
1224   "GET_CODE (operands[0]) != MEM || GET_CODE (operands[1]) != MEM"
1226   switch (get_attr_type (insn))
1227     {
1228     case TYPE_IMOVX:
1229       /* movzwl is faster than movw on p2 due to partial word stalls,
1230          though not as fast as an aligned movl.  */
1231       return "movz{wl|x}\t{%1, %k0|%k0, %1}";
1232     default:
1233       if (get_attr_mode (insn) == MODE_SI)
1234         return "mov{l}\t{%k1, %k0|%k0, %k1}";
1235       else
1236         return "mov{w}\t{%1, %0|%0, %1}";
1237     }
1239   [(set (attr "type")
1240      (cond [(and (eq_attr "alternative" "0,1")
1241                  (ior (eq (symbol_ref "TARGET_PARTIAL_REG_STALL")
1242                           (const_int 0))
1243                       (eq (symbol_ref "TARGET_HIMODE_MATH")
1244                           (const_int 0))))
1245               (const_string "imov")
1246             (and (eq_attr "alternative" "2,3,4")
1247                  (match_operand:HI 1 "aligned_operand" ""))
1248               (const_string "imov")
1249             (and (ne (symbol_ref "TARGET_MOVX")
1250                      (const_int 0))
1251                  (eq_attr "alternative" "0,1,3,4"))
1252               (const_string "imovx")
1253            ]
1254            (const_string "imov")))
1255     (set (attr "mode")
1256       (cond [(eq_attr "type" "imovx")
1257                (const_string "SI")
1258              (and (eq_attr "alternative" "2,3,4")
1259                   (match_operand:HI 1 "aligned_operand" ""))
1260                (const_string "SI")
1261              (and (eq_attr "alternative" "0,1")
1262                   (ior (eq (symbol_ref "TARGET_PARTIAL_REG_STALL")
1263                            (const_int 0))
1264                        (eq (symbol_ref "TARGET_HIMODE_MATH")
1265                            (const_int 0))))
1266                (const_string "SI")
1267             ]
1268             (const_string "HI")))
1269    (set_attr "modrm" "0,*,*,0,*,*")])
1271 ;; Stores and loads of ax to arbitary constant address.
1272 ;; We fake an second form of instruction to force reload to load address
1273 ;; into register when rax is not available
1274 (define_insn "*movabshi_1_rex64"
1275   [(set (mem:HI (match_operand:DI 0 "x86_64_movabs_operand" "i,r,r"))
1276         (match_operand:HI 1 "nonmemory_operand" "a,er,i"))]
1277   "TARGET_64BIT"
1278   "@
1279    movabs{w}\t{%1, %P0|%P0, %1}
1280    mov{w}\t{%1, %a0|%a0, %1}
1281    movabs{w}\t{%1, %a0|%a0, %1}"
1282   [(set_attr "type" "imov")
1283    (set_attr "modrm" "0,*,*")
1284    (set_attr "length_address" "8,0,0")
1285    (set_attr "length_immediate" "0,*,*")
1286    (set_attr "memory" "store")
1287    (set_attr "mode" "HI")])
1289 (define_insn "*movabshi_2_rex64"
1290   [(set (match_operand:HI 0 "register_operand" "=a,r")
1291         (mem:HI (match_operand:DI 1 "x86_64_movabs_operand" "i,r")))]
1292   "TARGET_64BIT"
1293   "@
1294    movabs{w}\t{%P1, %0|%0, %P1}
1295    mov{w}\t{%a1, %0|%0, %a1}"
1296   [(set_attr "type" "imov")
1297    (set_attr "modrm" "0,*")
1298    (set_attr "length_address" "8,0")
1299    (set_attr "length_immediate" "0")
1300    (set_attr "memory" "load")
1301    (set_attr "mode" "HI")])
1303 (define_insn "*swaphi_1"
1304   [(set (match_operand:HI 0 "register_operand" "+r")
1305         (match_operand:HI 1 "register_operand" "+r"))
1306    (set (match_dup 1)
1307         (match_dup 0))]
1308   "TARGET_PARTIAL_REG_STALL"
1309   "xchg{w}\t%1, %0"
1310   [(set_attr "type" "imov")
1311    (set_attr "pent_pair" "np")
1312    (set_attr "mode" "HI")
1313    (set_attr "modrm" "0")
1314    (set_attr "ppro_uops" "few")])
1316 (define_insn "*swaphi_2"
1317   [(set (match_operand:HI 0 "register_operand" "+r")
1318         (match_operand:HI 1 "register_operand" "+r"))
1319    (set (match_dup 1)
1320         (match_dup 0))]
1321   "! TARGET_PARTIAL_REG_STALL"
1322   "xchg{l}\t%k1, %k0"
1323   [(set_attr "type" "imov")
1324    (set_attr "pent_pair" "np")
1325    (set_attr "mode" "SI")
1326    (set_attr "modrm" "0")
1327    (set_attr "ppro_uops" "few")])
1329 (define_expand "movstricthi"
1330   [(set (strict_low_part (match_operand:HI 0 "nonimmediate_operand" ""))
1331         (match_operand:HI 1 "general_operand" ""))]
1332   "! TARGET_PARTIAL_REG_STALL || optimize_size"
1334   /* Don't generate memory->memory moves, go through a register */
1335   if (GET_CODE (operands[0]) == MEM && GET_CODE (operands[1]) == MEM)
1336     operands[1] = force_reg (HImode, operands[1]);
1339 (define_insn "*movstricthi_1"
1340   [(set (strict_low_part (match_operand:HI 0 "nonimmediate_operand" "+rm,r"))
1341         (match_operand:HI 1 "general_operand" "rn,m"))]
1342   "(! TARGET_PARTIAL_REG_STALL || optimize_size)
1343    && (GET_CODE (operands[0]) != MEM || GET_CODE (operands[1]) != MEM)"
1344   "mov{w}\t{%1, %0|%0, %1}"
1345   [(set_attr "type" "imov")
1346    (set_attr "mode" "HI")])
1348 (define_insn "*movstricthi_xor"
1349   [(set (strict_low_part (match_operand:HI 0 "register_operand" "+r"))
1350         (match_operand:HI 1 "const0_operand" "i"))
1351    (clobber (reg:CC 17))]
1352   "reload_completed
1353    && ((!TARGET_USE_MOV0 && !TARGET_PARTIAL_REG_STALL) || optimize_size)"
1354   "xor{w}\t{%0, %0|%0, %0}"
1355   [(set_attr "type" "alu1")
1356    (set_attr "mode" "HI")
1357    (set_attr "length_immediate" "0")])
1359 (define_expand "movqi"
1360   [(set (match_operand:QI 0 "nonimmediate_operand" "")
1361         (match_operand:QI 1 "general_operand" ""))]
1362   ""
1363   "ix86_expand_move (QImode, operands); DONE;")
1365 ;; emit_push_insn when it calls move_by_pieces requires an insn to
1366 ;; "push a byte".  But actually we use pushw, which has the effect
1367 ;; of rounding the amount pushed up to a halfword.
1369 (define_insn "*pushqi2"
1370   [(set (match_operand:QI 0 "push_operand" "=X,X")
1371         (match_operand:QI 1 "nonmemory_no_elim_operand" "n,r"))]
1372   "!TARGET_64BIT"
1373   "@
1374    push{w}\t{|word ptr }%1
1375    push{w}\t%w1"
1376   [(set_attr "type" "push")
1377    (set_attr "mode" "HI")])
1379 ;; For 64BIT abi we always round up to 8 bytes.
1380 (define_insn "*pushqi2_rex64"
1381   [(set (match_operand:QI 0 "push_operand" "=X")
1382         (match_operand:QI 1 "nonmemory_no_elim_operand" "qi"))]
1383   "TARGET_64BIT"
1384   "push{q}\t%q1"
1385   [(set_attr "type" "push")
1386    (set_attr "mode" "QI")])
1388 ;; Situation is quite tricky about when to choose full sized (SImode) move
1389 ;; over QImode moves.  For Q_REG -> Q_REG move we use full size only for
1390 ;; partial register dependency machines (such as AMD Athlon), where QImode
1391 ;; moves issue extra dependency and for partial register stalls machines
1392 ;; that don't use QImode patterns (and QImode move cause stall on the next
1393 ;; instruction).
1395 ;; For loads of Q_REG to NONQ_REG we use full sized moves except for partial
1396 ;; register stall machines with, where we use QImode instructions, since
1397 ;; partial register stall can be caused there.  Then we use movzx.
1398 (define_insn "*movqi_1"
1399   [(set (match_operand:QI 0 "nonimmediate_operand" "=q,q ,q ,r,r ,?r,m")
1400         (match_operand:QI 1 "general_operand"      " q,qn,qm,q,rn,qm,qn"))]
1401   "GET_CODE (operands[0]) != MEM || GET_CODE (operands[1]) != MEM"
1403   switch (get_attr_type (insn))
1404     {
1405     case TYPE_IMOVX:
1406       if (!ANY_QI_REG_P (operands[1]) && GET_CODE (operands[1]) != MEM)
1407         abort ();
1408       return "movz{bl|x}\t{%1, %k0|%k0, %1}";
1409     default:
1410       if (get_attr_mode (insn) == MODE_SI)
1411         return "mov{l}\t{%k1, %k0|%k0, %k1}";
1412       else
1413         return "mov{b}\t{%1, %0|%0, %1}";
1414     }
1416   [(set (attr "type")
1417      (cond [(and (eq_attr "alternative" "3")
1418                  (ior (eq (symbol_ref "TARGET_PARTIAL_REG_STALL")
1419                           (const_int 0))
1420                       (eq (symbol_ref "TARGET_QIMODE_MATH")
1421                           (const_int 0))))
1422               (const_string "imov")
1423             (eq_attr "alternative" "3,5")
1424               (const_string "imovx")
1425             (and (ne (symbol_ref "TARGET_MOVX")
1426                      (const_int 0))
1427                  (eq_attr "alternative" "2"))
1428               (const_string "imovx")
1429            ]
1430            (const_string "imov")))
1431    (set (attr "mode")
1432       (cond [(eq_attr "alternative" "3,4,5")
1433                (const_string "SI")
1434              (eq_attr "alternative" "6")
1435                (const_string "QI")
1436              (eq_attr "type" "imovx")
1437                (const_string "SI")
1438              (and (eq_attr "type" "imov")
1439                   (and (eq_attr "alternative" "0,1,2")
1440                        (ne (symbol_ref "TARGET_PARTIAL_REG_DEPENDENCY")
1441                            (const_int 0))))
1442                (const_string "SI")
1443              ;; Avoid partial register stalls when not using QImode arithmetic
1444              (and (eq_attr "type" "imov")
1445                   (and (eq_attr "alternative" "0,1,2")
1446                        (and (ne (symbol_ref "TARGET_PARTIAL_REG_STALL")
1447                                 (const_int 0))
1448                             (eq (symbol_ref "TARGET_QIMODE_MATH")
1449                                 (const_int 0)))))
1450                (const_string "SI")
1451            ]
1452            (const_string "QI")))])
1454 (define_expand "reload_outqi"
1455   [(parallel [(match_operand:QI 0 "" "=m")
1456               (match_operand:QI 1 "register_operand" "r")
1457               (match_operand:QI 2 "register_operand" "=&q")])]
1458   ""
1460   rtx op0, op1, op2;
1461   op0 = operands[0]; op1 = operands[1]; op2 = operands[2];
1463   if (reg_overlap_mentioned_p (op2, op0))
1464     abort ();
1465   if (! q_regs_operand (op1, QImode))
1466     {
1467       emit_insn (gen_movqi (op2, op1));
1468       op1 = op2;
1469     }
1470   emit_insn (gen_movqi (op0, op1));
1471   DONE;
1474 (define_insn "*swapqi"
1475   [(set (match_operand:QI 0 "register_operand" "+r")
1476         (match_operand:QI 1 "register_operand" "+r"))
1477    (set (match_dup 1)
1478         (match_dup 0))]
1479   ""
1480   "xchg{b}\t%1, %0"
1481   [(set_attr "type" "imov")
1482    (set_attr "pent_pair" "np")
1483    (set_attr "mode" "QI")
1484    (set_attr "modrm" "0")
1485    (set_attr "ppro_uops" "few")])
1487 (define_expand "movstrictqi"
1488   [(set (strict_low_part (match_operand:QI 0 "nonimmediate_operand" ""))
1489         (match_operand:QI 1 "general_operand" ""))]
1490   "! TARGET_PARTIAL_REG_STALL"
1492   /* Don't generate memory->memory moves, go through a register.  */
1493   if (GET_CODE (operands[0]) == MEM && GET_CODE (operands[1]) == MEM)
1494     operands[1] = force_reg (QImode, operands[1]);
1497 (define_insn "*movstrictqi_1"
1498   [(set (strict_low_part (match_operand:QI 0 "nonimmediate_operand" "+qm,q"))
1499         (match_operand:QI 1 "general_operand" "*qn,m"))]
1500   "! TARGET_PARTIAL_REG_STALL
1501    && (GET_CODE (operands[0]) != MEM || GET_CODE (operands[1]) != MEM)"
1502   "mov{b}\t{%1, %0|%0, %1}"
1503   [(set_attr "type" "imov")
1504    (set_attr "mode" "QI")])
1506 (define_insn "*movstrictqi_xor"
1507   [(set (strict_low_part (match_operand:QI 0 "q_regs_operand" "+q"))
1508         (match_operand:QI 1 "const0_operand" "i"))
1509    (clobber (reg:CC 17))]
1510   "reload_completed && (!TARGET_USE_MOV0 || optimize_size)"
1511   "xor{b}\t{%0, %0|%0, %0}"
1512   [(set_attr "type" "alu1")
1513    (set_attr "mode" "QI")
1514    (set_attr "length_immediate" "0")])
1516 (define_insn "*movsi_extv_1"
1517   [(set (match_operand:SI 0 "register_operand" "=R")
1518         (sign_extract:SI (match_operand 1 "ext_register_operand" "Q")
1519                          (const_int 8)
1520                          (const_int 8)))]
1521   ""
1522   "movs{bl|x}\t{%h1, %0|%0, %h1}"
1523   [(set_attr "type" "imovx")
1524    (set_attr "mode" "SI")])
1526 (define_insn "*movhi_extv_1"
1527   [(set (match_operand:HI 0 "register_operand" "=R")
1528         (sign_extract:HI (match_operand 1 "ext_register_operand" "Q")
1529                          (const_int 8)
1530                          (const_int 8)))]
1531   ""
1532   "movs{bl|x}\t{%h1, %k0|%k0, %h1}"
1533   [(set_attr "type" "imovx")
1534    (set_attr "mode" "SI")])
1536 (define_insn "*movqi_extv_1"
1537   [(set (match_operand:QI 0 "nonimmediate_operand" "=Qm,?r")
1538         (sign_extract:QI (match_operand 1 "ext_register_operand" "Q,Q")
1539                          (const_int 8)
1540                          (const_int 8)))]
1541   "!TARGET_64BIT"
1543   switch (get_attr_type (insn))
1544     {
1545     case TYPE_IMOVX:
1546       return "movs{bl|x}\t{%h1, %k0|%k0, %h1}";
1547     default:
1548       return "mov{b}\t{%h1, %0|%0, %h1}";
1549     }
1551   [(set (attr "type")
1552      (if_then_else (and (match_operand:QI 0 "register_operand" "")
1553                         (ior (not (match_operand:QI 0 "q_regs_operand" ""))
1554                              (ne (symbol_ref "TARGET_MOVX")
1555                                  (const_int 0))))
1556         (const_string "imovx")
1557         (const_string "imov")))
1558    (set (attr "mode")
1559      (if_then_else (eq_attr "type" "imovx")
1560         (const_string "SI")
1561         (const_string "QI")))])
1563 (define_insn "*movqi_extv_1_rex64"
1564   [(set (match_operand:QI 0 "register_operand" "=Q,?R")
1565         (sign_extract:QI (match_operand 1 "ext_register_operand" "Q,Q")
1566                          (const_int 8)
1567                          (const_int 8)))]
1568   "TARGET_64BIT"
1570   switch (get_attr_type (insn))
1571     {
1572     case TYPE_IMOVX:
1573       return "movs{bl|x}\t{%h1, %k0|%k0, %h1}";
1574     default:
1575       return "mov{b}\t{%h1, %0|%0, %h1}";
1576     }
1578   [(set (attr "type")
1579      (if_then_else (and (match_operand:QI 0 "register_operand" "")
1580                         (ior (not (match_operand:QI 0 "q_regs_operand" ""))
1581                              (ne (symbol_ref "TARGET_MOVX")
1582                                  (const_int 0))))
1583         (const_string "imovx")
1584         (const_string "imov")))
1585    (set (attr "mode")
1586      (if_then_else (eq_attr "type" "imovx")
1587         (const_string "SI")
1588         (const_string "QI")))])
1590 ;; Stores and loads of ax to arbitary constant address.
1591 ;; We fake an second form of instruction to force reload to load address
1592 ;; into register when rax is not available
1593 (define_insn "*movabsqi_1_rex64"
1594   [(set (mem:QI (match_operand:DI 0 "x86_64_movabs_operand" "i,r,r"))
1595         (match_operand:QI 1 "nonmemory_operand" "a,er,i"))]
1596   "TARGET_64BIT"
1597   "@
1598    movabs{b}\t{%1, %P0|%P0, %1}
1599    mov{b}\t{%1, %a0|%a0, %1}
1600    movabs{b}\t{%1, %a0|%a0, %1}"
1601   [(set_attr "type" "imov")
1602    (set_attr "modrm" "0,*,*")
1603    (set_attr "length_address" "8,0,0")
1604    (set_attr "length_immediate" "0,*,*")
1605    (set_attr "memory" "store")
1606    (set_attr "mode" "QI")])
1608 (define_insn "*movabsqi_2_rex64"
1609   [(set (match_operand:QI 0 "register_operand" "=a,r")
1610         (mem:QI (match_operand:DI 1 "x86_64_movabs_operand" "i,r")))]
1611   "TARGET_64BIT"
1612   "@
1613    movabs{b}\t{%P1, %0|%0, %P1}
1614    mov{b}\t{%a1, %0|%0, %a1}"
1615   [(set_attr "type" "imov")
1616    (set_attr "modrm" "0,*")
1617    (set_attr "length_address" "8,0")
1618    (set_attr "length_immediate" "0")
1619    (set_attr "memory" "load")
1620    (set_attr "mode" "QI")])
1622 (define_insn "*movsi_extzv_1"
1623   [(set (match_operand:SI 0 "register_operand" "=R")
1624         (zero_extract:SI (match_operand 1 "ext_register_operand" "Q")
1625                          (const_int 8)
1626                          (const_int 8)))]
1627   ""
1628   "movz{bl|x}\t{%h1, %0|%0, %h1}"
1629   [(set_attr "type" "imovx")
1630    (set_attr "mode" "SI")])
1632 (define_insn "*movqi_extzv_2"
1633   [(set (match_operand:QI 0 "nonimmediate_operand" "=Qm,?R")
1634         (subreg:QI (zero_extract:SI (match_operand 1 "ext_register_operand" "Q,Q")
1635                                     (const_int 8)
1636                                     (const_int 8)) 0))]
1637   "!TARGET_64BIT"
1639   switch (get_attr_type (insn))
1640     {
1641     case TYPE_IMOVX:
1642       return "movz{bl|x}\t{%h1, %k0|%k0, %h1}";
1643     default:
1644       return "mov{b}\t{%h1, %0|%0, %h1}";
1645     }
1647   [(set (attr "type")
1648      (if_then_else (and (match_operand:QI 0 "register_operand" "")
1649                         (ior (not (match_operand:QI 0 "q_regs_operand" ""))
1650                              (ne (symbol_ref "TARGET_MOVX")
1651                                  (const_int 0))))
1652         (const_string "imovx")
1653         (const_string "imov")))
1654    (set (attr "mode")
1655      (if_then_else (eq_attr "type" "imovx")
1656         (const_string "SI")
1657         (const_string "QI")))])
1659 (define_insn "*movqi_extzv_2_rex64"
1660   [(set (match_operand:QI 0 "register_operand" "=Q,?R")
1661         (subreg:QI (zero_extract:SI (match_operand 1 "ext_register_operand" "Q,Q")
1662                                     (const_int 8)
1663                                     (const_int 8)) 0))]
1664   "TARGET_64BIT"
1666   switch (get_attr_type (insn))
1667     {
1668     case TYPE_IMOVX:
1669       return "movz{bl|x}\t{%h1, %k0|%k0, %h1}";
1670     default:
1671       return "mov{b}\t{%h1, %0|%0, %h1}";
1672     }
1674   [(set (attr "type")
1675      (if_then_else (ior (not (match_operand:QI 0 "q_regs_operand" ""))
1676                         (ne (symbol_ref "TARGET_MOVX")
1677                             (const_int 0)))
1678         (const_string "imovx")
1679         (const_string "imov")))
1680    (set (attr "mode")
1681      (if_then_else (eq_attr "type" "imovx")
1682         (const_string "SI")
1683         (const_string "QI")))])
1685 (define_insn "movsi_insv_1"
1686   [(set (zero_extract:SI (match_operand 0 "ext_register_operand" "+Q")
1687                          (const_int 8)
1688                          (const_int 8))
1689         (match_operand:SI 1 "general_operand" "Qmn"))]
1690   "!TARGET_64BIT"
1691   "mov{b}\t{%b1, %h0|%h0, %b1}"
1692   [(set_attr "type" "imov")
1693    (set_attr "mode" "QI")])
1695 (define_insn "*movsi_insv_1_rex64"
1696   [(set (zero_extract:SI (match_operand 0 "ext_register_operand" "+Q")
1697                          (const_int 8)
1698                          (const_int 8))
1699         (match_operand:SI 1 "nonmemory_operand" "Qn"))]
1700   "TARGET_64BIT"
1701   "mov{b}\t{%b1, %h0|%h0, %b1}"
1702   [(set_attr "type" "imov")
1703    (set_attr "mode" "QI")])
1705 (define_insn "*movqi_insv_2"
1706   [(set (zero_extract:SI (match_operand 0 "ext_register_operand" "+Q")
1707                          (const_int 8)
1708                          (const_int 8))
1709         (and:SI (lshiftrt:SI (match_operand:SI 1 "register_operand" "Q")
1710                              (const_int 8))
1711                 (const_int 255)))]
1712   ""
1713   "mov{b}\t{%h1, %h0|%h0, %h1}"
1714   [(set_attr "type" "imov")
1715    (set_attr "mode" "QI")])
1717 (define_expand "movdi"
1718   [(set (match_operand:DI 0 "nonimmediate_operand" "")
1719         (match_operand:DI 1 "general_operand" ""))]
1720   ""
1721   "ix86_expand_move (DImode, operands); DONE;")
1723 (define_insn "*pushdi"
1724   [(set (match_operand:DI 0 "push_operand" "=<")
1725         (match_operand:DI 1 "general_no_elim_operand" "riF*m"))]
1726   "!TARGET_64BIT"
1727   "#")
1729 (define_insn "pushdi2_rex64"
1730   [(set (match_operand:DI 0 "push_operand" "=<,!<")
1731         (match_operand:DI 1 "general_no_elim_operand" "re*m,n"))]
1732   "TARGET_64BIT"
1733   "@
1734    push{q}\t%1
1735    #"
1736   [(set_attr "type" "push,multi")
1737    (set_attr "mode" "DI")])
1739 ;; Convert impossible pushes of immediate to existing instructions.
1740 ;; First try to get scratch register and go through it.  In case this
1741 ;; fails, push sign extended lower part first and then overwrite
1742 ;; upper part by 32bit move.
1743 (define_peephole2
1744   [(match_scratch:DI 2 "r")
1745    (set (match_operand:DI 0 "push_operand" "")
1746         (match_operand:DI 1 "immediate_operand" ""))]
1747   "TARGET_64BIT && !symbolic_operand (operands[1], DImode)
1748    && !x86_64_immediate_operand (operands[1], DImode)"
1749   [(set (match_dup 2) (match_dup 1))
1750    (set (match_dup 0) (match_dup 2))]
1751   "")
1753 ;; We need to define this as both peepholer and splitter for case
1754 ;; peephole2 pass is not run.
1755 (define_peephole2
1756   [(set (match_operand:DI 0 "push_operand" "")
1757         (match_operand:DI 1 "immediate_operand" ""))]
1758   "TARGET_64BIT && !symbolic_operand (operands[1], DImode)
1759    && !x86_64_immediate_operand (operands[1], DImode) && 1"
1760   [(set (match_dup 0) (match_dup 1))
1761    (set (match_dup 2) (match_dup 3))]
1762   "split_di (operands + 1, 1, operands + 2, operands + 3);
1763    operands[1] = gen_lowpart (DImode, operands[2]);
1764    operands[2] = gen_rtx_MEM (SImode, gen_rtx_PLUS (DImode, stack_pointer_rtx,
1765                                                     GEN_INT (4)));
1766   ")
1768 (define_split
1769   [(set (match_operand:DI 0 "push_operand" "")
1770         (match_operand:DI 1 "immediate_operand" ""))]
1771   "TARGET_64BIT && (flow2_completed || (reload_completed && !flag_peephole2))
1772    && !symbolic_operand (operands[1], DImode)
1773    && !x86_64_immediate_operand (operands[1], DImode)"
1774   [(set (match_dup 0) (match_dup 1))
1775    (set (match_dup 2) (match_dup 3))]
1776   "split_di (operands + 1, 1, operands + 2, operands + 3);
1777    operands[1] = gen_lowpart (DImode, operands[2]);
1778    operands[2] = gen_rtx_MEM (SImode, gen_rtx_PLUS (DImode, stack_pointer_rtx,
1779                                                     GEN_INT (4)));
1780   ")
1782 (define_insn "*pushdi2_prologue_rex64"
1783   [(set (match_operand:DI 0 "push_operand" "=<")
1784         (match_operand:DI 1 "general_no_elim_operand" "re*m"))
1785    (clobber (mem:BLK (scratch)))]
1786   "TARGET_64BIT"
1787   "push{q}\t%1"
1788   [(set_attr "type" "push")
1789    (set_attr "mode" "DI")])
1791 (define_insn "*popdi1_epilogue_rex64"
1792   [(set (match_operand:DI 0 "nonimmediate_operand" "=r*m")
1793         (mem:DI (reg:DI 7)))
1794    (set (reg:DI 7)
1795         (plus:DI (reg:DI 7) (const_int 8)))
1796    (clobber (mem:BLK (scratch)))]
1797   "TARGET_64BIT"
1798   "pop{q}\t%0"
1799   [(set_attr "type" "pop")
1800    (set_attr "mode" "DI")])
1802 (define_insn "popdi1"
1803   [(set (match_operand:DI 0 "nonimmediate_operand" "=r*m")
1804         (mem:DI (reg:DI 7)))
1805    (set (reg:DI 7)
1806         (plus:DI (reg:DI 7) (const_int 8)))]
1807   "TARGET_64BIT"
1808   "pop{q}\t%0"
1809   [(set_attr "type" "pop")
1810    (set_attr "mode" "DI")])
1812 (define_insn "*movdi_xor_rex64"
1813   [(set (match_operand:DI 0 "register_operand" "=r")
1814         (match_operand:DI 1 "const0_operand" "i"))
1815    (clobber (reg:CC 17))]
1816   "TARGET_64BIT && (!TARGET_USE_MOV0 || optimize_size)
1817    && reload_completed"
1818   "xor{l}\t{%k0, %k0|%k0, %k0}"
1819   [(set_attr "type" "alu1")
1820    (set_attr "mode" "SI")
1821    (set_attr "length_immediate" "0")])
1823 (define_insn "*movdi_or_rex64"
1824   [(set (match_operand:DI 0 "register_operand" "=r")
1825         (match_operand:DI 1 "const_int_operand" "i"))
1826    (clobber (reg:CC 17))]
1827   "TARGET_64BIT && (TARGET_PENTIUM || optimize_size)
1828    && reload_completed
1829    && GET_CODE (operands[1]) == CONST_INT
1830    && INTVAL (operands[1]) == -1"
1832   operands[1] = constm1_rtx;
1833   return "or{q}\t{%1, %0|%0, %1}";
1835   [(set_attr "type" "alu1")
1836    (set_attr "mode" "DI")
1837    (set_attr "length_immediate" "1")])
1839 (define_insn "*movdi_2"
1840   [(set (match_operand:DI 0 "nonimmediate_operand" "=r,o,!m*y,!*y,!m,!*Y,!*Y")
1841         (match_operand:DI 1 "general_operand" "riFo,riF,*y,m,*Y,*Y,m"))]
1842   "!TARGET_64BIT
1843    && (GET_CODE (operands[0]) != MEM || GET_CODE (operands[1]) != MEM)"
1844   "@
1845    #
1846    #
1847    movq\t{%1, %0|%0, %1}
1848    movq\t{%1, %0|%0, %1}
1849    movq\t{%1, %0|%0, %1}
1850    movdqa\t{%1, %0|%0, %1}
1851    movq\t{%1, %0|%0, %1}"
1852   [(set_attr "type" "*,*,mmx,mmx,ssemov,ssemov,ssemov")
1853    (set_attr "mode" "DI,DI,DI,DI,DI,TI,DI")])
1855 (define_split
1856   [(set (match_operand:DI 0 "push_operand" "")
1857         (match_operand:DI 1 "general_operand" ""))]
1858   "!TARGET_64BIT && reload_completed
1859    && (! MMX_REG_P (operands[1]) && !SSE_REG_P (operands[1]))"
1860   [(const_int 0)]
1861   "ix86_split_long_move (operands); DONE;")
1863 ;; %%% This multiword shite has got to go.
1864 (define_split
1865   [(set (match_operand:DI 0 "nonimmediate_operand" "")
1866         (match_operand:DI 1 "general_operand" ""))]
1867   "!TARGET_64BIT && reload_completed
1868    && (!MMX_REG_P (operands[0]) && !SSE_REG_P (operands[0]))
1869    && (!MMX_REG_P (operands[1]) && !SSE_REG_P (operands[1]))"
1870   [(const_int 0)]
1871   "ix86_split_long_move (operands); DONE;")
1873 (define_insn "*movdi_1_rex64"
1874   [(set (match_operand:DI 0 "nonimmediate_operand" "=r,r,r,mr,!mr,!m*y,!*y,!*Y,!m,!*Y")
1875         (match_operand:DI 1 "general_operand" "Z,rem,i,re,n,*y,m,*Y,*Y,*m"))]
1876   "TARGET_64BIT
1877    && (GET_CODE (operands[0]) != MEM || GET_CODE (operands[1]) != MEM)"
1879   switch (get_attr_type (insn))
1880     {
1881     case TYPE_SSEMOV:
1882       if (register_operand (operands[0], DImode)
1883           && register_operand (operands[1], DImode))
1884           return "movdqa\t{%1, %0|%0, %1}";
1885       /* FALLTHRU */
1886     case TYPE_MMXMOV:
1887       return "movq\t{%1, %0|%0, %1}";
1888     case TYPE_MULTI:
1889       return "#";
1890     case TYPE_LEA:
1891       return "lea{q}\t{%a1, %0|%0, %a1}";
1892     default:
1893       if (flag_pic && !LEGITIMATE_PIC_OPERAND_P (operands[1]))
1894         abort ();
1895       if (get_attr_mode (insn) == MODE_SI)
1896         return "mov{l}\t{%k1, %k0|%k0, %k1}";
1897       else if (which_alternative == 2)
1898         return "movabs{q}\t{%1, %0|%0, %1}";
1899       else
1900         return "mov{q}\t{%1, %0|%0, %1}";
1901     }
1903   [(set (attr "type")
1904      (cond [(eq_attr "alternative" "5,6")
1905               (const_string "mmxmov")
1906             (eq_attr "alternative" "7,8")
1907               (const_string "ssemov")
1908             (eq_attr "alternative" "4")
1909               (const_string "multi")
1910             (and (ne (symbol_ref "flag_pic") (const_int 0))
1911                  (match_operand:DI 1 "symbolic_operand" ""))
1912               (const_string "lea")
1913            ]
1914            (const_string "imov")))
1915    (set_attr "modrm" "*,0,0,*,*,*,*,*,*,*")
1916    (set_attr "length_immediate" "*,4,8,*,*,*,*,*,*,*")
1917    (set_attr "mode" "SI,DI,DI,DI,SI,DI,DI,DI,TI,DI")])
1919 ;; Stores and loads of ax to arbitary constant address.
1920 ;; We fake an second form of instruction to force reload to load address
1921 ;; into register when rax is not available
1922 (define_insn "*movabsdi_1_rex64"
1923   [(set (mem:DI (match_operand:DI 0 "x86_64_movabs_operand" "i,r,r"))
1924         (match_operand:DI 1 "nonmemory_operand" "a,er,i"))]
1925   "TARGET_64BIT"
1926   "@
1927    movabs{q}\t{%1, %P0|%P0, %1}
1928    mov{q}\t{%1, %a0|%a0, %1}
1929    movabs{q}\t{%1, %a0|%a0, %1}"
1930   [(set_attr "type" "imov")
1931    (set_attr "modrm" "0,*,*")
1932    (set_attr "length_address" "8,0,0")
1933    (set_attr "length_immediate" "0,*,*")
1934    (set_attr "memory" "store")
1935    (set_attr "mode" "DI")])
1937 (define_insn "*movabsdi_2_rex64"
1938   [(set (match_operand:DI 0 "register_operand" "=a,r")
1939         (mem:DI (match_operand:DI 1 "x86_64_movabs_operand" "i,r")))]
1940   "TARGET_64BIT"
1941   "@
1942    movabs{q}\t{%P1, %0|%0, %P1}
1943    mov{q}\t{%a1, %0|%0, %a1}"
1944   [(set_attr "type" "imov")
1945    (set_attr "modrm" "0,*")
1946    (set_attr "length_address" "8,0")
1947    (set_attr "length_immediate" "0")
1948    (set_attr "memory" "load")
1949    (set_attr "mode" "DI")])
1951 ;; Convert impossible stores of immediate to existing instructions.
1952 ;; First try to get scratch register and go through it.  In case this
1953 ;; fails, move by 32bit parts.
1954 (define_peephole2
1955   [(match_scratch:DI 2 "r")
1956    (set (match_operand:DI 0 "memory_operand" "")
1957         (match_operand:DI 1 "immediate_operand" ""))]
1958   "TARGET_64BIT && !symbolic_operand (operands[1], DImode)
1959    && !x86_64_immediate_operand (operands[1], DImode)"
1960   [(set (match_dup 2) (match_dup 1))
1961    (set (match_dup 0) (match_dup 2))]
1962   "")
1964 ;; We need to define this as both peepholer and splitter for case
1965 ;; peephole2 pass is not run.
1966 (define_peephole2
1967   [(set (match_operand:DI 0 "memory_operand" "")
1968         (match_operand:DI 1 "immediate_operand" ""))]
1969   "TARGET_64BIT && !symbolic_operand (operands[1], DImode)
1970    && !x86_64_immediate_operand (operands[1], DImode) && 1"
1971   [(set (match_dup 2) (match_dup 3))
1972    (set (match_dup 4) (match_dup 5))]
1973   "split_di (operands, 2, operands + 2, operands + 4);")
1975 (define_split
1976   [(set (match_operand:DI 0 "memory_operand" "")
1977         (match_operand:DI 1 "immediate_operand" ""))]
1978   "TARGET_64BIT && (flow2_completed || (reload_completed && !flag_peephole2))
1979    && !symbolic_operand (operands[1], DImode)
1980    && !x86_64_immediate_operand (operands[1], DImode)"
1981   [(set (match_dup 2) (match_dup 3))
1982    (set (match_dup 4) (match_dup 5))]
1983   "split_di (operands, 2, operands + 2, operands + 4);")
1985 (define_insn "*swapdi_rex64"
1986   [(set (match_operand:DI 0 "register_operand" "+r")
1987         (match_operand:DI 1 "register_operand" "+r"))
1988    (set (match_dup 1)
1989         (match_dup 0))]
1990   "TARGET_64BIT"
1991   "xchg{q}\t%1, %0"
1992   [(set_attr "type" "imov")
1993    (set_attr "pent_pair" "np")
1994    (set_attr "athlon_decode" "vector")
1995    (set_attr "mode" "DI")
1996    (set_attr "modrm" "0")
1997    (set_attr "ppro_uops" "few")])
1999   
2000 (define_expand "movsf"
2001   [(set (match_operand:SF 0 "nonimmediate_operand" "")
2002         (match_operand:SF 1 "general_operand" ""))]
2003   ""
2004   "ix86_expand_move (SFmode, operands); DONE;")
2006 (define_insn "*pushsf"
2007   [(set (match_operand:SF 0 "push_operand" "=<,<,<")
2008         (match_operand:SF 1 "general_no_elim_operand" "f#rx,rFm#fx,x#rf"))]
2009   "!TARGET_64BIT"
2011   switch (which_alternative)
2012     {
2013     case 0:
2014       /* %%% We loose REG_DEAD notes for controling pops if we split late.  */
2015       operands[0] = gen_rtx_MEM (SFmode, stack_pointer_rtx);
2016       operands[2] = stack_pointer_rtx;
2017       operands[3] = GEN_INT (4);
2018       if (find_regno_note (insn, REG_DEAD, REGNO (operands[1])))
2019         return "sub{l}\t{%3, %2|%2, %3}\;fstp%z0\t%y0";
2020       else
2021         return "sub{l}\t{%3, %2|%2, %3}\;fst%z0\t%y0";
2023     case 1:
2024       return "push{l}\t%1";
2025     case 2:
2026       return "#";
2028     default:
2029       abort ();
2030     }
2032   [(set_attr "type" "multi,push,multi")
2033    (set_attr "mode" "SF,SI,SF")])
2035 (define_insn "*pushsf_rex64"
2036   [(set (match_operand:SF 0 "push_operand" "=X,X,X")
2037         (match_operand:SF 1 "nonmemory_no_elim_operand" "f#rx,rF#fx,x#rf"))]
2038   "TARGET_64BIT"
2040   switch (which_alternative)
2041     {
2042     case 0:
2043       /* %%% We loose REG_DEAD notes for controling pops if we split late.  */
2044       operands[0] = gen_rtx_MEM (SFmode, stack_pointer_rtx);
2045       operands[2] = stack_pointer_rtx;
2046       operands[3] = GEN_INT (8);
2047       if (find_regno_note (insn, REG_DEAD, REGNO (operands[1])))
2048         return "sub{q}\t{%3, %2|%2, %3}\;fstp%z0\t%y0";
2049       else
2050         return "sub{q}\t{%3, %2|%2, %3}\;fst%z0\t%y0";
2052     case 1:
2053       return "push{q}\t%q1";
2055     case 2:
2056       return "#";
2058     default:
2059       abort ();
2060     }
2062   [(set_attr "type" "multi,push,multi")
2063    (set_attr "mode" "SF,DI,SF")])
2065 (define_split
2066   [(set (match_operand:SF 0 "push_operand" "")
2067         (match_operand:SF 1 "memory_operand" ""))]
2068   "reload_completed
2069    && GET_CODE (operands[1]) == MEM
2070    && GET_CODE (XEXP (operands[1], 0)) == SYMBOL_REF
2071    && CONSTANT_POOL_ADDRESS_P (XEXP (operands[1], 0))"
2072   [(set (match_dup 0)
2073         (match_dup 1))]
2074   "operands[1] = get_pool_constant (XEXP (operands[1], 0));")
2077 ;; %%% Kill this when call knows how to work this out.
2078 (define_split
2079   [(set (match_operand:SF 0 "push_operand" "")
2080         (match_operand:SF 1 "register_operand" ""))]
2081   "!TARGET_64BIT && ANY_FP_REGNO_P (REGNO (operands[1]))"
2082   [(set (reg:SI 7) (plus:SI (reg:SI 7) (const_int -4)))
2083    (set (mem:SF (reg:SI 7)) (match_dup 1))])
2085 (define_split
2086   [(set (match_operand:SF 0 "push_operand" "")
2087         (match_operand:SF 1 "register_operand" ""))]
2088   "TARGET_64BIT && ANY_FP_REGNO_P (REGNO (operands[1]))"
2089   [(set (reg:DI 7) (plus:DI (reg:DI 7) (const_int -8)))
2090    (set (mem:SF (reg:DI 7)) (match_dup 1))])
2092 (define_insn "*movsf_1"
2093   [(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")
2094         (match_operand:SF 1 "general_operand" "fm#rx,f#rx,G,rmF#fx,Fr#fx,H,x,xm#rf,x#rf,rm,*y,*y"))]
2095   "(GET_CODE (operands[0]) != MEM || GET_CODE (operands[1]) != MEM)
2096    && (reload_in_progress || reload_completed
2097        || (ix86_cmodel == CM_MEDIUM || ix86_cmodel == CM_LARGE)
2098        || GET_CODE (operands[1]) != CONST_DOUBLE
2099        || memory_operand (operands[0], SFmode))" 
2101   switch (which_alternative)
2102     {
2103     case 0:
2104       if (REG_P (operands[1])
2105           && find_regno_note (insn, REG_DEAD, REGNO (operands[1])))
2106         return "fstp\t%y0";
2107       else if (STACK_TOP_P (operands[0]))
2108         return "fld%z1\t%y1";
2109       else
2110         return "fst\t%y0";
2112     case 1:
2113       if (find_regno_note (insn, REG_DEAD, REGNO (operands[1])))
2114         return "fstp%z0\t%y0";
2115       else
2116         return "fst%z0\t%y0";
2118     case 2:
2119       switch (standard_80387_constant_p (operands[1]))
2120         {
2121         case 1:
2122           return "fldz";
2123         case 2:
2124           return "fld1";
2125         }
2126       abort();
2128     case 3:
2129     case 4:
2130       return "mov{l}\t{%1, %0|%0, %1}";
2131     case 5:
2132       if (TARGET_SSE2 && !TARGET_ATHLON)
2133         return "pxor\t%0, %0";
2134       else
2135         return "xorps\t%0, %0";
2136     case 6:
2137       if (TARGET_PARTIAL_REG_DEPENDENCY)
2138         return "movaps\t{%1, %0|%0, %1}";
2139       else
2140         return "movss\t{%1, %0|%0, %1}";
2141     case 7:
2142     case 8:
2143       return "movss\t{%1, %0|%0, %1}";
2145     case 9:
2146     case 10:
2147       return "movd\t{%1, %0|%0, %1}";
2149     case 11:
2150       return "movq\t{%1, %0|%0, %1}";
2152     default:
2153       abort();
2154     }
2156   [(set_attr "type" "fmov,fmov,fmov,imov,imov,ssemov,ssemov,ssemov,ssemov,mmxmov,mmxmov,mmxmov")
2157    (set_attr "mode" "SF,SF,SF,SI,SI,TI,SF,SF,SF,SI,SI,DI")])
2159 (define_insn "*swapsf"
2160   [(set (match_operand:SF 0 "register_operand" "+f")
2161         (match_operand:SF 1 "register_operand" "+f"))
2162    (set (match_dup 1)
2163         (match_dup 0))]
2164   "reload_completed || !TARGET_SSE"
2166   if (STACK_TOP_P (operands[0]))
2167     return "fxch\t%1";
2168   else
2169     return "fxch\t%0";
2171   [(set_attr "type" "fxch")
2172    (set_attr "mode" "SF")])
2174 (define_expand "movdf"
2175   [(set (match_operand:DF 0 "nonimmediate_operand" "")
2176         (match_operand:DF 1 "general_operand" ""))]
2177   ""
2178   "ix86_expand_move (DFmode, operands); DONE;")
2180 ;; Size of pushdf is 3 (for sub) + 2 (for fstp) + memory operand size.
2181 ;; Size of pushdf using integer insturctions is 2+2*memory operand size
2182 ;; On the average, pushdf using integers can be still shorter.  Allow this
2183 ;; pattern for optimize_size too.
2185 (define_insn "*pushdf_nointeger"
2186   [(set (match_operand:DF 0 "push_operand" "=<,<,<,<")
2187         (match_operand:DF 1 "general_no_elim_operand" "f#Y,Fo#fY,*r#fY,Y#f"))]
2188   "!TARGET_64BIT && !TARGET_INTEGER_DFMODE_MOVES"
2190   switch (which_alternative)
2191     {
2192     case 0:
2193       /* %%% We loose REG_DEAD notes for controling pops if we split late.  */
2194       operands[0] = gen_rtx_MEM (DFmode, stack_pointer_rtx);
2195       operands[2] = stack_pointer_rtx;
2196       operands[3] = GEN_INT (8);
2197       if (find_regno_note (insn, REG_DEAD, REGNO (operands[1])))
2198         return "sub{l}\t{%3, %2|%2, %3}\;fstp%z0\t%y0";
2199       else
2200         return "sub{l}\t{%3, %2|%2, %3}\;fst%z0\t%y0";
2202     case 1:
2203     case 2:
2204     case 3:
2205       return "#";
2207     default:
2208       abort ();
2209     }
2211   [(set_attr "type" "multi")
2212    (set_attr "mode" "DF,SI,SI,DF")])
2214 (define_insn "*pushdf_integer"
2215   [(set (match_operand:DF 0 "push_operand" "=<,<,<")
2216         (match_operand:DF 1 "general_no_elim_operand" "f#rY,rFo#fY,Y#rf"))]
2217   "TARGET_64BIT || TARGET_INTEGER_DFMODE_MOVES"
2219   switch (which_alternative)
2220     {
2221     case 0:
2222       /* %%% We loose REG_DEAD notes for controling pops if we split late.  */
2223       operands[0] = gen_rtx_MEM (DFmode, stack_pointer_rtx);
2224       operands[2] = stack_pointer_rtx;
2225       operands[3] = GEN_INT (8);
2226       if (TARGET_64BIT)
2227         if (find_regno_note (insn, REG_DEAD, REGNO (operands[1])))
2228           return "sub{q}\t{%3, %2|%2, %3}\;fstp%z0\t%y0";
2229         else
2230           return "sub{q}\t{%3, %2|%2, %3}\;fst%z0\t%y0";
2231       else
2232         if (find_regno_note (insn, REG_DEAD, REGNO (operands[1])))
2233           return "sub{l}\t{%3, %2|%2, %3}\;fstp%z0\t%y0";
2234         else
2235           return "sub{l}\t{%3, %2|%2, %3}\;fst%z0\t%y0";
2238     case 1:
2239     case 2:
2240       return "#";
2242     default:
2243       abort ();
2244     }
2246   [(set_attr "type" "multi")
2247    (set_attr "mode" "DF,SI,DF")])
2249 ;; %%% Kill this when call knows how to work this out.
2250 (define_split
2251   [(set (match_operand:DF 0 "push_operand" "")
2252         (match_operand:DF 1 "register_operand" ""))]
2253   "!TARGET_64BIT && reload_completed && ANY_FP_REGNO_P (REGNO (operands[1]))"
2254   [(set (reg:SI 7) (plus:SI (reg:SI 7) (const_int -8)))
2255    (set (mem:DF (reg:SI 7)) (match_dup 1))]
2256   "")
2258 (define_split
2259   [(set (match_operand:DF 0 "push_operand" "")
2260         (match_operand:DF 1 "register_operand" ""))]
2261   "TARGET_64BIT && reload_completed && ANY_FP_REGNO_P (REGNO (operands[1]))"
2262   [(set (reg:DI 7) (plus:DI (reg:DI 7) (const_int -8)))
2263    (set (mem:DF (reg:DI 7)) (match_dup 1))]
2264   "")
2266 (define_split
2267   [(set (match_operand:DF 0 "push_operand" "")
2268         (match_operand:DF 1 "general_operand" ""))]
2269   "reload_completed"
2270   [(const_int 0)]
2271   "ix86_split_long_move (operands); DONE;")
2273 ;; Moving is usually shorter when only FP registers are used. This separate
2274 ;; movdf pattern avoids the use of integer registers for FP operations
2275 ;; when optimizing for size.
2277 (define_insn "*movdf_nointeger"
2278   [(set (match_operand:DF 0 "nonimmediate_operand" "=f#Y,m,f#Y,*r,o,Y#f,Y#f,Y#f,m")
2279         (match_operand:DF 1 "general_operand" "fm#Y,f#Y,G,*roF,F*r,H,Y#f,YHm#f,Y#f"))]
2280   "(GET_CODE (operands[0]) != MEM || GET_CODE (operands[1]) != MEM)
2281    && (optimize_size || !TARGET_INTEGER_DFMODE_MOVES)
2282    && (reload_in_progress || reload_completed
2283        || (ix86_cmodel == CM_MEDIUM || ix86_cmodel == CM_LARGE)
2284        || GET_CODE (operands[1]) != CONST_DOUBLE
2285        || memory_operand (operands[0], DFmode))" 
2287   switch (which_alternative)
2288     {
2289     case 0:
2290       if (REG_P (operands[1])
2291           && find_regno_note (insn, REG_DEAD, REGNO (operands[1])))
2292         return "fstp\t%y0";
2293       else if (STACK_TOP_P (operands[0]))
2294         return "fld%z1\t%y1";
2295       else
2296         return "fst\t%y0";
2298     case 1:
2299       if (find_regno_note (insn, REG_DEAD, REGNO (operands[1])))
2300         return "fstp%z0\t%y0";
2301       else
2302         return "fst%z0\t%y0";
2304     case 2:
2305       switch (standard_80387_constant_p (operands[1]))
2306         {
2307         case 1:
2308           return "fldz";
2309         case 2:
2310           return "fld1";
2311         }
2312       abort();
2314     case 3:
2315     case 4:
2316       return "#";
2317     case 5:
2318       if (TARGET_ATHLON)
2319         return "xorpd\t%0, %0";
2320       else
2321         return "pxor\t%0, %0";
2322     case 6:
2323       if (TARGET_PARTIAL_REG_DEPENDENCY)
2324         return "movapd\t{%1, %0|%0, %1}";
2325       else
2326         return "movsd\t{%1, %0|%0, %1}";
2327     case 7:
2328     case 8:
2329         return "movsd\t{%1, %0|%0, %1}";
2331     default:
2332       abort();
2333     }
2335   [(set_attr "type" "fmov,fmov,fmov,multi,multi,ssemov,ssemov,ssemov,ssemov")
2336    (set_attr "mode" "DF,DF,DF,SI,SI,TI,DF,DF,DF")])
2338 (define_insn "*movdf_integer"
2339   [(set (match_operand:DF 0 "nonimmediate_operand" "=f#Yr,m,f#Yr,r#Yf,o,Y#rf,Y#rf,Y#rf,m")
2340         (match_operand:DF 1 "general_operand" "fm#Yr,f#Yr,G,roF#Yf,Fr#Yf,H,Y#rf,Ym#rf,Y#rf"))]
2341   "(GET_CODE (operands[0]) != MEM || GET_CODE (operands[1]) != MEM)
2342    && !optimize_size && TARGET_INTEGER_DFMODE_MOVES
2343    && (reload_in_progress || reload_completed
2344        || (ix86_cmodel == CM_MEDIUM || ix86_cmodel == CM_LARGE)
2345        || GET_CODE (operands[1]) != CONST_DOUBLE
2346        || memory_operand (operands[0], DFmode))" 
2348   switch (which_alternative)
2349     {
2350     case 0:
2351       if (REG_P (operands[1])
2352           && find_regno_note (insn, REG_DEAD, REGNO (operands[1])))
2353         return "fstp\t%y0";
2354       else if (STACK_TOP_P (operands[0]))
2355         return "fld%z1\t%y1";
2356       else
2357         return "fst\t%y0";
2359     case 1:
2360       if (find_regno_note (insn, REG_DEAD, REGNO (operands[1])))
2361         return "fstp%z0\t%y0";
2362       else
2363         return "fst%z0\t%y0";
2365     case 2:
2366       switch (standard_80387_constant_p (operands[1]))
2367         {
2368         case 1:
2369           return "fldz";
2370         case 2:
2371           return "fld1";
2372         }
2373       abort();
2375     case 3:
2376     case 4:
2377       return "#";
2379     case 5:
2380       if (TARGET_ATHLON)
2381         return "xorpd\t%0, %0";
2382       else
2383         return "pxor\t%0, %0";
2384     case 6:
2385       if (TARGET_PARTIAL_REG_DEPENDENCY)
2386         return "movapd\t{%1, %0|%0, %1}";
2387       else
2388         return "movsd\t{%1, %0|%0, %1}";
2389     case 7:
2390     case 8:
2391       return "movsd\t{%1, %0|%0, %1}";
2393     default:
2394       abort();
2395     }
2397   [(set_attr "type" "fmov,fmov,fmov,multi,multi,ssemov,ssemov,ssemov,ssemov")
2398    (set_attr "mode" "DF,DF,DF,SI,SI,TI,DF,DF,DF")])
2400 (define_split
2401   [(set (match_operand:DF 0 "nonimmediate_operand" "")
2402         (match_operand:DF 1 "general_operand" ""))]
2403   "reload_completed
2404    && (GET_CODE (operands[0]) != MEM || GET_CODE (operands[1]) != MEM)
2405    && ! (ANY_FP_REG_P (operands[0]) || 
2406          (GET_CODE (operands[0]) == SUBREG
2407           && ANY_FP_REG_P (SUBREG_REG (operands[0]))))
2408    && ! (ANY_FP_REG_P (operands[1]) || 
2409          (GET_CODE (operands[1]) == SUBREG
2410           && ANY_FP_REG_P (SUBREG_REG (operands[1]))))"
2411   [(const_int 0)]
2412   "ix86_split_long_move (operands); DONE;")
2414 (define_insn "*swapdf"
2415   [(set (match_operand:DF 0 "register_operand" "+f")
2416         (match_operand:DF 1 "register_operand" "+f"))
2417    (set (match_dup 1)
2418         (match_dup 0))]
2419   "reload_completed || !TARGET_SSE2"
2421   if (STACK_TOP_P (operands[0]))
2422     return "fxch\t%1";
2423   else
2424     return "fxch\t%0";
2426   [(set_attr "type" "fxch")
2427    (set_attr "mode" "DF")])
2429 (define_expand "movxf"
2430   [(set (match_operand:XF 0 "nonimmediate_operand" "")
2431         (match_operand:XF 1 "general_operand" ""))]
2432   "!TARGET_64BIT"
2433   "ix86_expand_move (XFmode, operands); DONE;")
2435 (define_expand "movtf"
2436   [(set (match_operand:TF 0 "nonimmediate_operand" "")
2437         (match_operand:TF 1 "general_operand" ""))]
2438   ""
2439   "ix86_expand_move (TFmode, operands); DONE;")
2441 ;; Size of pushdf is 3 (for sub) + 2 (for fstp) + memory operand size.
2442 ;; Size of pushdf using integer insturctions is 3+3*memory operand size
2443 ;; Pushing using integer instructions is longer except for constants
2444 ;; and direct memory references.
2445 ;; (assuming that any given constant is pushed only once, but this ought to be
2446 ;;  handled elsewhere).
2448 (define_insn "*pushxf_nointeger"
2449   [(set (match_operand:XF 0 "push_operand" "=X,X,X")
2450         (match_operand:XF 1 "general_no_elim_operand" "f,Fo,*r"))]
2451   "!TARGET_64BIT && optimize_size"
2453   switch (which_alternative)
2454     {
2455     case 0:
2456       /* %%% We loose REG_DEAD notes for controling pops if we split late.  */
2457       operands[0] = gen_rtx_MEM (XFmode, stack_pointer_rtx);
2458       operands[2] = stack_pointer_rtx;
2459       operands[3] = GEN_INT (12);
2460       if (find_regno_note (insn, REG_DEAD, REGNO (operands[1])))
2461         return "sub{l}\t{%3, %2|%2, %3}\;fstp%z0\t%y0";
2462       else
2463         return "sub{l}\t{%3, %2|%2, %3}\;fst%z0\t%y0";
2465     case 1:
2466     case 2:
2467       return "#";
2469     default:
2470       abort ();
2471     }
2473   [(set_attr "type" "multi")
2474    (set_attr "mode" "XF,SI,SI")])
2476 (define_insn "*pushtf_nointeger"
2477   [(set (match_operand:TF 0 "push_operand" "=<,<,<")
2478         (match_operand:TF 1 "general_no_elim_operand" "f,Fo,*r"))]
2479   "optimize_size"
2481   switch (which_alternative)
2482     {
2483     case 0:
2484       /* %%% We loose REG_DEAD notes for controling pops if we split late.  */
2485       operands[0] = gen_rtx_MEM (XFmode, stack_pointer_rtx);
2486       operands[2] = stack_pointer_rtx;
2487       operands[3] = GEN_INT (16);
2488       if (find_regno_note (insn, REG_DEAD, REGNO (operands[1])))
2489         return "sub{l}\t{%3, %2|%2, %3}\;fstp%z0\t%y0";
2490       else
2491         return "sub{l}\t{%3, %2|%2, %3}\;fst%z0\t%y0";
2493     case 1:
2494     case 2:
2495       return "#";
2497     default:
2498       abort ();
2499     }
2501   [(set_attr "type" "multi")
2502    (set_attr "mode" "XF,SI,SI")])
2504 (define_insn "*pushxf_integer"
2505   [(set (match_operand:XF 0 "push_operand" "=<,<")
2506         (match_operand:XF 1 "general_no_elim_operand" "f#r,ro#f"))]
2507   "!TARGET_64BIT && !optimize_size"
2509   switch (which_alternative)
2510     {
2511     case 0:
2512       /* %%% We loose REG_DEAD notes for controling pops if we split late.  */
2513       operands[0] = gen_rtx_MEM (XFmode, stack_pointer_rtx);
2514       operands[2] = stack_pointer_rtx;
2515       operands[3] = GEN_INT (12);
2516       if (find_regno_note (insn, REG_DEAD, REGNO (operands[1])))
2517         return "sub{l}\t{%3, %2|%2, %3}\;fstp%z0\t%y0";
2518       else
2519         return "sub{l}\t{%3, %2|%2, %3}\;fst%z0\t%y0";
2521     case 1:
2522       return "#";
2524     default:
2525       abort ();
2526     }
2528   [(set_attr "type" "multi")
2529    (set_attr "mode" "XF,SI")])
2531 (define_insn "*pushtf_integer"
2532   [(set (match_operand:TF 0 "push_operand" "=<,<")
2533         (match_operand:TF 1 "general_no_elim_operand" "f#r,rFo#f"))]
2534   "!optimize_size"
2536   switch (which_alternative)
2537     {
2538     case 0:
2539       /* %%% We loose REG_DEAD notes for controling pops if we split late.  */
2540       operands[0] = gen_rtx_MEM (XFmode, stack_pointer_rtx);
2541       operands[2] = stack_pointer_rtx;
2542       operands[3] = GEN_INT (16);
2543       if (TARGET_64BIT)
2544         if (find_regno_note (insn, REG_DEAD, REGNO (operands[1])))
2545           return "sub{q}\t{%3, %2|%2, %3}\;fstp%z0\t%y0";
2546         else
2547           return "sub{q}\t{%3, %2|%2, %3}\;fst%z0\t%y0";
2548       else
2549         if (find_regno_note (insn, REG_DEAD, REGNO (operands[1])))
2550           return "sub{l}\t{%3, %2|%2, %3}\;fstp%z0\t%y0";
2551         else
2552           return "sub{l}\t{%3, %2|%2, %3}\;fst%z0\t%y0";
2554     case 1:
2555       return "#";
2557     default:
2558       abort ();
2559     }
2561   [(set_attr "type" "multi")
2562    (set_attr "mode" "XF,SI")])
2564 (define_split
2565   [(set (match_operand 0 "push_operand" "")
2566         (match_operand 1 "general_operand" ""))]
2567   "reload_completed
2568    && (GET_MODE (operands[0]) == XFmode
2569        || GET_MODE (operands[0]) == TFmode
2570        || GET_MODE (operands[0]) == DFmode)
2571    && (!REG_P (operands[1]) || !ANY_FP_REGNO_P (REGNO (operands[1])))"
2572   [(const_int 0)]
2573   "ix86_split_long_move (operands); DONE;")
2575 (define_split
2576   [(set (match_operand:XF 0 "push_operand" "")
2577         (match_operand:XF 1 "register_operand" ""))]
2578   "!TARGET_64BIT && ANY_FP_REGNO_P (REGNO (operands[1]))"
2579   [(set (reg:SI 7) (plus:SI (reg:SI 7) (const_int -12)))
2580    (set (mem:XF (reg:SI 7)) (match_dup 1))])
2582 (define_split
2583   [(set (match_operand:TF 0 "push_operand" "")
2584         (match_operand:TF 1 "register_operand" ""))]
2585   "!TARGET_64BIT && ANY_FP_REGNO_P (REGNO (operands[1]))"
2586   [(set (reg:SI 7) (plus:SI (reg:SI 7) (const_int -16)))
2587    (set (mem:TF (reg:SI 7)) (match_dup 1))])
2589 (define_split
2590   [(set (match_operand:TF 0 "push_operand" "")
2591         (match_operand:TF 1 "register_operand" ""))]
2592   "TARGET_64BIT && ANY_FP_REGNO_P (REGNO (operands[1]))"
2593   [(set (reg:DI 7) (plus:DI (reg:DI 7) (const_int -16)))
2594    (set (mem:TF (reg:DI 7)) (match_dup 1))])
2596 ;; Do not use integer registers when optimizing for size
2597 (define_insn "*movxf_nointeger"
2598   [(set (match_operand:XF 0 "nonimmediate_operand" "=f,m,f,*r,o")
2599         (match_operand:XF 1 "general_operand" "fm,f,G,*roF,F*r"))]
2600   "!TARGET_64BIT
2601    && optimize_size
2602    && (GET_CODE (operands[0]) != MEM || GET_CODE (operands[1]) != MEM)
2603    && (reload_in_progress || reload_completed
2604        || GET_CODE (operands[1]) != CONST_DOUBLE
2605        || memory_operand (operands[0], XFmode))" 
2607   switch (which_alternative)
2608     {
2609     case 0:
2610       if (REG_P (operands[1])
2611           && find_regno_note (insn, REG_DEAD, REGNO (operands[1])))
2612         return "fstp\t%y0";
2613       else if (STACK_TOP_P (operands[0]))
2614         return "fld%z1\t%y1";
2615       else
2616         return "fst\t%y0";
2618     case 1:
2619       /* There is no non-popping store to memory for XFmode.  So if
2620          we need one, follow the store with a load.  */
2621       if (! find_regno_note (insn, REG_DEAD, REGNO (operands[1])))
2622         return "fstp%z0\t%y0\;fld%z0\t%y0";
2623       else
2624         return "fstp%z0\t%y0";
2626     case 2:
2627       switch (standard_80387_constant_p (operands[1]))
2628         {
2629         case 1:
2630           return "fldz";
2631         case 2:
2632           return "fld1";
2633         }
2634       break;
2636     case 3: case 4:
2637       return "#";
2638     }
2639   abort();
2641   [(set_attr "type" "fmov,fmov,fmov,multi,multi")
2642    (set_attr "mode" "XF,XF,XF,SI,SI")])
2644 (define_insn "*movtf_nointeger"
2645   [(set (match_operand:TF 0 "nonimmediate_operand" "=f,m,f,*r,o")
2646         (match_operand:TF 1 "general_operand" "fm,f,G,*roF,F*r"))]
2647   "(GET_CODE (operands[0]) != MEM || GET_CODE (operands[1]) != MEM)
2648    && optimize_size
2649    && (reload_in_progress || reload_completed
2650        || GET_CODE (operands[1]) != CONST_DOUBLE
2651        || (ix86_cmodel == CM_MEDIUM || ix86_cmodel == CM_LARGE)
2652        || memory_operand (operands[0], TFmode))" 
2654   switch (which_alternative)
2655     {
2656     case 0:
2657       if (REG_P (operands[1])
2658           && find_regno_note (insn, REG_DEAD, REGNO (operands[1])))
2659         return "fstp\t%y0";
2660       else if (STACK_TOP_P (operands[0]))
2661         return "fld%z1\t%y1";
2662       else
2663         return "fst\t%y0";
2665     case 1:
2666       /* There is no non-popping store to memory for XFmode.  So if
2667          we need one, follow the store with a load.  */
2668       if (! find_regno_note (insn, REG_DEAD, REGNO (operands[1])))
2669         return "fstp%z0\t%y0\;fld%z0\t%y0";
2670       else
2671         return "fstp%z0\t%y0";
2673     case 2:
2674       switch (standard_80387_constant_p (operands[1]))
2675         {
2676         case 1:
2677           return "fldz";
2678         case 2:
2679           return "fld1";
2680         }
2681       break;
2683     case 3: case 4:
2684       return "#";
2685     }
2686   abort();
2688   [(set_attr "type" "fmov,fmov,fmov,multi,multi")
2689    (set_attr "mode" "XF,XF,XF,SI,SI")])
2691 (define_insn "*movxf_integer"
2692   [(set (match_operand:XF 0 "nonimmediate_operand" "=f#r,m,f#r,r#f,o")
2693         (match_operand:XF 1 "general_operand" "fm#r,f#r,G,roF#f,Fr#f"))]
2694   "!TARGET_64BIT
2695    && !optimize_size
2696    && (GET_CODE (operands[0]) != MEM || GET_CODE (operands[1]) != MEM)
2697    && (reload_in_progress || reload_completed
2698        || GET_CODE (operands[1]) != CONST_DOUBLE
2699        || memory_operand (operands[0], XFmode))" 
2701   switch (which_alternative)
2702     {
2703     case 0:
2704       if (REG_P (operands[1])
2705           && find_regno_note (insn, REG_DEAD, REGNO (operands[1])))
2706         return "fstp\t%y0";
2707       else if (STACK_TOP_P (operands[0]))
2708         return "fld%z1\t%y1";
2709       else
2710         return "fst\t%y0";
2712     case 1:
2713       /* There is no non-popping store to memory for XFmode.  So if
2714          we need one, follow the store with a load.  */
2715       if (! find_regno_note (insn, REG_DEAD, REGNO (operands[1])))
2716         return "fstp%z0\t%y0\;fld%z0\t%y0";
2717       else
2718         return "fstp%z0\t%y0";
2720     case 2:
2721       switch (standard_80387_constant_p (operands[1]))
2722         {
2723         case 1:
2724           return "fldz";
2725         case 2:
2726           return "fld1";
2727         }
2728       break;
2730     case 3: case 4:
2731       return "#";
2732     }
2733   abort();
2735   [(set_attr "type" "fmov,fmov,fmov,multi,multi")
2736    (set_attr "mode" "XF,XF,XF,SI,SI")])
2738 (define_insn "*movtf_integer"
2739   [(set (match_operand:TF 0 "nonimmediate_operand" "=f#r,m,f#r,r#f,o")
2740         (match_operand:TF 1 "general_operand" "fm#r,f#r,G,roF#f,Fr#f"))]
2741   "(GET_CODE (operands[0]) != MEM || GET_CODE (operands[1]) != MEM)
2742    && !optimize_size
2743    && (reload_in_progress || reload_completed
2744        || GET_CODE (operands[1]) != CONST_DOUBLE
2745        || (ix86_cmodel == CM_MEDIUM || ix86_cmodel == CM_LARGE)
2746        || memory_operand (operands[0], TFmode))" 
2748   switch (which_alternative)
2749     {
2750     case 0:
2751       if (REG_P (operands[1])
2752           && find_regno_note (insn, REG_DEAD, REGNO (operands[1])))
2753         return "fstp\t%y0";
2754       else if (STACK_TOP_P (operands[0]))
2755         return "fld%z1\t%y1";
2756       else
2757         return "fst\t%y0";
2759     case 1:
2760       /* There is no non-popping store to memory for XFmode.  So if
2761          we need one, follow the store with a load.  */
2762       if (! find_regno_note (insn, REG_DEAD, REGNO (operands[1])))
2763         return "fstp%z0\t%y0\;fld%z0\t%y0";
2764       else
2765         return "fstp%z0\t%y0";
2767     case 2:
2768       switch (standard_80387_constant_p (operands[1]))
2769         {
2770         case 1:
2771           return "fldz";
2772         case 2:
2773           return "fld1";
2774         }
2775       break;
2777     case 3: case 4:
2778       return "#";
2779     }
2780   abort();
2782   [(set_attr "type" "fmov,fmov,fmov,multi,multi")
2783    (set_attr "mode" "XF,XF,XF,SI,SI")])
2785 (define_split
2786   [(set (match_operand 0 "nonimmediate_operand" "")
2787         (match_operand 1 "general_operand" ""))]
2788   "reload_completed
2789    && (GET_CODE (operands[0]) != MEM || GET_CODE (operands[1]) != MEM)
2790    && (GET_MODE (operands[0]) == XFmode || GET_MODE (operands[0]) == TFmode)
2791    && ! (ANY_FP_REG_P (operands[0]) || 
2792          (GET_CODE (operands[0]) == SUBREG
2793           && ANY_FP_REG_P (SUBREG_REG (operands[0]))))
2794    && ! (ANY_FP_REG_P (operands[1]) || 
2795          (GET_CODE (operands[1]) == SUBREG
2796           && ANY_FP_REG_P (SUBREG_REG (operands[1]))))"
2797   [(const_int 0)]
2798   "ix86_split_long_move (operands); DONE;")
2800 (define_split
2801   [(set (match_operand 0 "register_operand" "")
2802         (match_operand 1 "memory_operand" ""))]
2803   "reload_completed
2804    && GET_CODE (operands[1]) == MEM
2805    && (GET_MODE (operands[0]) == XFmode || GET_MODE (operands[0]) == TFmode
2806        || GET_MODE (operands[0]) == SFmode || GET_MODE (operands[0]) == DFmode)
2807    && GET_CODE (XEXP (operands[1], 0)) == SYMBOL_REF
2808    && CONSTANT_POOL_ADDRESS_P (XEXP (operands[1], 0))
2809    && (!(SSE_REG_P (operands[0]) || 
2810          (GET_CODE (operands[0]) == SUBREG
2811           && SSE_REG_P (SUBREG_REG (operands[0]))))
2812        || standard_sse_constant_p (get_pool_constant (XEXP (operands[1], 0))))
2813    && (!(FP_REG_P (operands[0]) || 
2814          (GET_CODE (operands[0]) == SUBREG
2815           && FP_REG_P (SUBREG_REG (operands[0]))))
2816        || standard_80387_constant_p (get_pool_constant (XEXP (operands[1], 0))))"
2817   [(set (match_dup 0)
2818         (match_dup 1))]
2819   "operands[1] = get_pool_constant (XEXP (operands[1], 0));")
2821 (define_insn "swapxf"
2822   [(set (match_operand:XF 0 "register_operand" "+f")
2823         (match_operand:XF 1 "register_operand" "+f"))
2824    (set (match_dup 1)
2825         (match_dup 0))]
2826   ""
2828   if (STACK_TOP_P (operands[0]))
2829     return "fxch\t%1";
2830   else
2831     return "fxch\t%0";
2833   [(set_attr "type" "fxch")
2834    (set_attr "mode" "XF")])
2836 (define_insn "swaptf"
2837   [(set (match_operand:TF 0 "register_operand" "+f")
2838         (match_operand:TF 1 "register_operand" "+f"))
2839    (set (match_dup 1)
2840         (match_dup 0))]
2841   ""
2843   if (STACK_TOP_P (operands[0]))
2844     return "fxch\t%1";
2845   else
2846     return "fxch\t%0";
2848   [(set_attr "type" "fxch")
2849    (set_attr "mode" "XF")])
2851 ;; Zero extension instructions
2853 (define_expand "zero_extendhisi2"
2854   [(set (match_operand:SI 0 "register_operand" "")
2855      (zero_extend:SI (match_operand:HI 1 "nonimmediate_operand" "")))]
2856   ""
2858   if (TARGET_ZERO_EXTEND_WITH_AND && !optimize_size)
2859     {
2860       operands[1] = force_reg (HImode, operands[1]);
2861       emit_insn (gen_zero_extendhisi2_and (operands[0], operands[1]));
2862       DONE;
2863     }
2866 (define_insn "zero_extendhisi2_and"
2867   [(set (match_operand:SI 0 "register_operand" "=r")
2868      (zero_extend:SI (match_operand:HI 1 "register_operand" "0")))
2869    (clobber (reg:CC 17))]
2870   "TARGET_ZERO_EXTEND_WITH_AND && !optimize_size"
2871   "#"
2872   [(set_attr "type" "alu1")
2873    (set_attr "mode" "SI")])
2875 (define_split
2876   [(set (match_operand:SI 0 "register_operand" "")
2877         (zero_extend:SI (match_operand:HI 1 "register_operand" "")))
2878    (clobber (reg:CC 17))]
2879   "reload_completed && TARGET_ZERO_EXTEND_WITH_AND && !optimize_size"
2880   [(parallel [(set (match_dup 0) (and:SI (match_dup 0) (const_int 65535)))
2881               (clobber (reg:CC 17))])]
2882   "")
2884 (define_insn "*zero_extendhisi2_movzwl"
2885   [(set (match_operand:SI 0 "register_operand" "=r")
2886      (zero_extend:SI (match_operand:HI 1 "nonimmediate_operand" "rm")))]
2887   "!TARGET_ZERO_EXTEND_WITH_AND || optimize_size"
2888   "movz{wl|x}\t{%1, %0|%0, %1}"
2889   [(set_attr "type" "imovx")
2890    (set_attr "mode" "SI")])
2892 (define_expand "zero_extendqihi2"
2893   [(parallel
2894     [(set (match_operand:HI 0 "register_operand" "")
2895        (zero_extend:HI (match_operand:QI 1 "nonimmediate_operand" "")))
2896      (clobber (reg:CC 17))])]
2897   ""
2898   "")
2900 (define_insn "*zero_extendqihi2_and"
2901   [(set (match_operand:HI 0 "register_operand" "=r,?&q")
2902      (zero_extend:HI (match_operand:QI 1 "nonimmediate_operand" "0,qm")))
2903    (clobber (reg:CC 17))]
2904   "TARGET_ZERO_EXTEND_WITH_AND && !optimize_size"
2905   "#"
2906   [(set_attr "type" "alu1")
2907    (set_attr "mode" "HI")])
2909 (define_insn "*zero_extendqihi2_movzbw_and"
2910   [(set (match_operand:HI 0 "register_operand" "=r,r")
2911      (zero_extend:HI (match_operand:QI 1 "nonimmediate_operand" "qm,0")))
2912    (clobber (reg:CC 17))]
2913   "!TARGET_ZERO_EXTEND_WITH_AND || optimize_size"
2914   "#"
2915   [(set_attr "type" "imovx,alu1")
2916    (set_attr "mode" "HI")])
2918 (define_insn "*zero_extendqihi2_movzbw"
2919   [(set (match_operand:HI 0 "register_operand" "=r")
2920      (zero_extend:HI (match_operand:QI 1 "nonimmediate_operand" "qm")))]
2921   "(!TARGET_ZERO_EXTEND_WITH_AND || optimize_size) && reload_completed"
2922   "movz{bw|x}\t{%1, %0|%0, %1}"
2923   [(set_attr "type" "imovx")
2924    (set_attr "mode" "HI")])
2926 ;; For the movzbw case strip only the clobber
2927 (define_split
2928   [(set (match_operand:HI 0 "register_operand" "")
2929         (zero_extend:HI (match_operand:QI 1 "nonimmediate_operand" "")))
2930    (clobber (reg:CC 17))]
2931   "reload_completed 
2932    && (!TARGET_ZERO_EXTEND_WITH_AND || optimize_size)
2933    && (!REG_P (operands[1]) || ANY_QI_REG_P (operands[1]))"
2934   [(set (match_operand:HI 0 "register_operand" "")
2935         (zero_extend:HI (match_operand:QI 1 "nonimmediate_operand" "")))])
2937 ;; When source and destination does not overlap, clear destination
2938 ;; first and then do the movb
2939 (define_split
2940   [(set (match_operand:HI 0 "register_operand" "")
2941         (zero_extend:HI (match_operand:QI 1 "nonimmediate_operand" "")))
2942    (clobber (reg:CC 17))]
2943   "reload_completed
2944    && ANY_QI_REG_P (operands[0])
2945    && (TARGET_ZERO_EXTEND_WITH_AND && !optimize_size)
2946    && !reg_overlap_mentioned_p (operands[0], operands[1])"
2947   [(set (match_dup 0) (const_int 0))
2948    (set (strict_low_part (match_dup 2)) (match_dup 1))]
2949   "operands[2] = gen_lowpart (QImode, operands[0]);")
2951 ;; Rest is handled by single and.
2952 (define_split
2953   [(set (match_operand:HI 0 "register_operand" "")
2954         (zero_extend:HI (match_operand:QI 1 "register_operand" "")))
2955    (clobber (reg:CC 17))]
2956   "reload_completed
2957    && true_regnum (operands[0]) == true_regnum (operands[1])"
2958   [(parallel [(set (match_dup 0) (and:HI (match_dup 0) (const_int 255)))
2959               (clobber (reg:CC 17))])]
2960   "")
2962 (define_expand "zero_extendqisi2"
2963   [(parallel
2964     [(set (match_operand:SI 0 "register_operand" "")
2965        (zero_extend:SI (match_operand:QI 1 "nonimmediate_operand" "")))
2966      (clobber (reg:CC 17))])]
2967   ""
2968   "")
2970 (define_insn "*zero_extendqisi2_and"
2971   [(set (match_operand:SI 0 "register_operand" "=r,?&q")
2972      (zero_extend:SI (match_operand:QI 1 "nonimmediate_operand" "0,qm")))
2973    (clobber (reg:CC 17))]
2974   "TARGET_ZERO_EXTEND_WITH_AND && !optimize_size"
2975   "#"
2976   [(set_attr "type" "alu1")
2977    (set_attr "mode" "SI")])
2979 (define_insn "*zero_extendqisi2_movzbw_and"
2980   [(set (match_operand:SI 0 "register_operand" "=r,r")
2981      (zero_extend:SI (match_operand:QI 1 "nonimmediate_operand" "qm,0")))
2982    (clobber (reg:CC 17))]
2983   "!TARGET_ZERO_EXTEND_WITH_AND || optimize_size"
2984   "#"
2985   [(set_attr "type" "imovx,alu1")
2986    (set_attr "mode" "SI")])
2988 (define_insn "*zero_extendqisi2_movzbw"
2989   [(set (match_operand:SI 0 "register_operand" "=r")
2990      (zero_extend:SI (match_operand:QI 1 "nonimmediate_operand" "qm")))]
2991   "(!TARGET_ZERO_EXTEND_WITH_AND || optimize_size) && reload_completed"
2992   "movz{bl|x}\t{%1, %0|%0, %1}"
2993   [(set_attr "type" "imovx")
2994    (set_attr "mode" "SI")])
2996 ;; For the movzbl case strip only the clobber
2997 (define_split
2998   [(set (match_operand:SI 0 "register_operand" "")
2999         (zero_extend:SI (match_operand:QI 1 "nonimmediate_operand" "")))
3000    (clobber (reg:CC 17))]
3001   "reload_completed 
3002    && (!TARGET_ZERO_EXTEND_WITH_AND || optimize_size)
3003    && (!REG_P (operands[1]) || ANY_QI_REG_P (operands[1]))"
3004   [(set (match_dup 0)
3005         (zero_extend:SI (match_dup 1)))])
3007 ;; When source and destination does not overlap, clear destination
3008 ;; first and then do the movb
3009 (define_split
3010   [(set (match_operand:SI 0 "register_operand" "")
3011         (zero_extend:SI (match_operand:QI 1 "nonimmediate_operand" "")))
3012    (clobber (reg:CC 17))]
3013   "reload_completed
3014    && ANY_QI_REG_P (operands[0])
3015    && (ANY_QI_REG_P (operands[1]) || GET_CODE (operands[1]) == MEM)
3016    && (TARGET_ZERO_EXTEND_WITH_AND && !optimize_size)
3017    && !reg_overlap_mentioned_p (operands[0], operands[1])"
3018   [(set (match_dup 0) (const_int 0))
3019    (set (strict_low_part (match_dup 2)) (match_dup 1))]
3020   "operands[2] = gen_lowpart (QImode, operands[0]);")
3022 ;; Rest is handled by single and.
3023 (define_split
3024   [(set (match_operand:SI 0 "register_operand" "")
3025         (zero_extend:SI (match_operand:QI 1 "register_operand" "")))
3026    (clobber (reg:CC 17))]
3027   "reload_completed
3028    && true_regnum (operands[0]) == true_regnum (operands[1])"
3029   [(parallel [(set (match_dup 0) (and:SI (match_dup 0) (const_int 255)))
3030               (clobber (reg:CC 17))])]
3031   "")
3033 ;; %%% Kill me once multi-word ops are sane.
3034 (define_expand "zero_extendsidi2"
3035   [(set (match_operand:DI 0 "register_operand" "=r")
3036      (zero_extend:DI (match_operand:SI 1 "nonimmediate_operand" "rm")))]
3037   ""
3038   "if (!TARGET_64BIT)
3039      {
3040        emit_insn (gen_zero_extendsidi2_32 (operands[0], operands[1]));
3041        DONE;
3042      }
3043   ")
3045 (define_insn "zero_extendsidi2_32"
3046   [(set (match_operand:DI 0 "nonimmediate_operand" "=r,?r,?*o")
3047         (zero_extend:DI (match_operand:SI 1 "nonimmediate_operand" "0,rm,r")))
3048    (clobber (reg:CC 17))]
3049   "!TARGET_64BIT"
3050   "#"
3051   [(set_attr "mode" "SI")])
3053 (define_insn "zero_extendsidi2_rex64"
3054   [(set (match_operand:DI 0 "nonimmediate_operand" "=r,o")
3055      (zero_extend:DI (match_operand:SI 1 "nonimmediate_operand" "rm,0")))]
3056   "TARGET_64BIT"
3057   "@
3058    mov\t{%k1, %k0|%k0, %k1}
3059    #"
3060   [(set_attr "type" "imovx,imov")
3061    (set_attr "mode" "SI,DI")])
3063 (define_split
3064   [(set (match_operand:DI 0 "memory_operand" "")
3065      (zero_extend:DI (match_dup 0)))]
3066   "TARGET_64BIT"
3067   [(set (match_dup 4) (const_int 0))]
3068   "split_di (&operands[0], 1, &operands[3], &operands[4]);")
3070 (define_split 
3071   [(set (match_operand:DI 0 "register_operand" "")
3072         (zero_extend:DI (match_operand:SI 1 "register_operand" "")))
3073    (clobber (reg:CC 17))]
3074   "!TARGET_64BIT && reload_completed
3075    && true_regnum (operands[0]) == true_regnum (operands[1])"
3076   [(set (match_dup 4) (const_int 0))]
3077   "split_di (&operands[0], 1, &operands[3], &operands[4]);")
3079 (define_split 
3080   [(set (match_operand:DI 0 "nonimmediate_operand" "")
3081         (zero_extend:DI (match_operand:SI 1 "general_operand" "")))
3082    (clobber (reg:CC 17))]
3083   "!TARGET_64BIT && reload_completed"
3084   [(set (match_dup 3) (match_dup 1))
3085    (set (match_dup 4) (const_int 0))]
3086   "split_di (&operands[0], 1, &operands[3], &operands[4]);")
3088 (define_insn "zero_extendhidi2"
3089   [(set (match_operand:DI 0 "register_operand" "=r,r")
3090      (zero_extend:DI (match_operand:HI 1 "nonimmediate_operand" "r,m")))]
3091   "TARGET_64BIT"
3092   "@
3093    movz{wl|x}\t{%1, %k0|%k0, %1} 
3094    movz{wq|x}\t{%1, %0|%0, %1}"
3095   [(set_attr "type" "imovx")
3096    (set_attr "mode" "SI,DI")])
3098 (define_insn "zero_extendqidi2"
3099   [(set (match_operand:DI 0 "register_operand" "=r,r")
3100      (zero_extend:DI (match_operand:QI 1 "nonimmediate_operand" "Q,m")))]
3101   "TARGET_64BIT"
3102   "@
3103    movz{bl|x}\t{%1, %k0|%k0, %1} 
3104    movz{bq|x}\t{%1, %0|%0, %1}"
3105   [(set_attr "type" "imovx")
3106    (set_attr "mode" "SI,DI")])
3108 ;; Sign extension instructions
3110 (define_expand "extendsidi2"
3111   [(parallel [(set (match_operand:DI 0 "register_operand" "")
3112                    (sign_extend:DI (match_operand:SI 1 "register_operand" "")))
3113               (clobber (reg:CC 17))
3114               (clobber (match_scratch:SI 2 ""))])]
3115   ""
3117   if (TARGET_64BIT)
3118     {
3119       emit_insn (gen_extendsidi2_rex64 (operands[0], operands[1]));
3120       DONE;
3121     }
3124 (define_insn "*extendsidi2_1"
3125   [(set (match_operand:DI 0 "nonimmediate_operand" "=*A,r,?r,?*o")
3126         (sign_extend:DI (match_operand:SI 1 "register_operand" "0,0,r,r")))
3127    (clobber (reg:CC 17))
3128    (clobber (match_scratch:SI 2 "=X,X,X,&r"))]
3129   "!TARGET_64BIT"
3130   "#")
3132 (define_insn "extendsidi2_rex64"
3133   [(set (match_operand:DI 0 "register_operand" "=*a,r")
3134         (sign_extend:DI (match_operand:SI 1 "nonimmediate_operand" "*0,rm")))]
3135   "TARGET_64BIT"
3136   "@
3137    {cltq|cdqe}
3138    movs{lq|x}\t{%1,%0|%0, %1}"
3139   [(set_attr "type" "imovx")
3140    (set_attr "mode" "DI")
3141    (set_attr "prefix_0f" "0")
3142    (set_attr "modrm" "0,1")])
3144 (define_insn "extendhidi2"
3145   [(set (match_operand:DI 0 "register_operand" "=r")
3146         (sign_extend:DI (match_operand:HI 1 "nonimmediate_operand" "rm")))]
3147   "TARGET_64BIT"
3148   "movs{wq|x}\t{%1,%0|%0, %1}"
3149   [(set_attr "type" "imovx")
3150    (set_attr "mode" "DI")])
3152 (define_insn "extendqidi2"
3153   [(set (match_operand:DI 0 "register_operand" "=r")
3154         (sign_extend:DI (match_operand:QI 1 "nonimmediate_operand" "qm")))]
3155   "TARGET_64BIT"
3156   "movs{bq|x}\t{%1,%0|%0, %1}"
3157    [(set_attr "type" "imovx")
3158     (set_attr "mode" "DI")])
3160 ;; Extend to memory case when source register does die.
3161 (define_split 
3162   [(set (match_operand:DI 0 "memory_operand" "")
3163         (sign_extend:DI (match_operand:SI 1 "register_operand" "")))
3164    (clobber (reg:CC 17))
3165    (clobber (match_operand:SI 2 "register_operand" ""))]
3166   "(reload_completed
3167     && dead_or_set_p (insn, operands[1])
3168     && !reg_mentioned_p (operands[1], operands[0]))"
3169   [(set (match_dup 3) (match_dup 1))
3170    (parallel [(set (match_dup 1) (ashiftrt:SI (match_dup 1) (const_int 31)))
3171               (clobber (reg:CC 17))])
3172    (set (match_dup 4) (match_dup 1))]
3173   "split_di (&operands[0], 1, &operands[3], &operands[4]);")
3175 ;; Extend to memory case when source register does not die.
3176 (define_split 
3177   [(set (match_operand:DI 0 "memory_operand" "")
3178         (sign_extend:DI (match_operand:SI 1 "register_operand" "")))
3179    (clobber (reg:CC 17))
3180    (clobber (match_operand:SI 2 "register_operand" ""))]
3181   "reload_completed"
3182   [(const_int 0)]
3184   split_di (&operands[0], 1, &operands[3], &operands[4]);
3186   emit_move_insn (operands[3], operands[1]);
3188   /* Generate a cltd if possible and doing so it profitable.  */
3189   if (true_regnum (operands[1]) == 0
3190       && true_regnum (operands[2]) == 1
3191       && (optimize_size || TARGET_USE_CLTD))
3192     {
3193       emit_insn (gen_ashrsi3_31 (operands[2], operands[1], GEN_INT (31)));
3194     }
3195   else
3196     {
3197       emit_move_insn (operands[2], operands[1]);
3198       emit_insn (gen_ashrsi3_31 (operands[2], operands[2], GEN_INT (31)));
3199     }
3200   emit_move_insn (operands[4], operands[2]);
3201   DONE;
3204 ;; Extend to register case.  Optimize case where source and destination
3205 ;; registers match and cases where we can use cltd.
3206 (define_split 
3207   [(set (match_operand:DI 0 "register_operand" "")
3208         (sign_extend:DI (match_operand:SI 1 "register_operand" "")))
3209    (clobber (reg:CC 17))
3210    (clobber (match_scratch:SI 2 ""))]
3211   "reload_completed"
3212   [(const_int 0)]
3214   split_di (&operands[0], 1, &operands[3], &operands[4]);
3216   if (true_regnum (operands[3]) != true_regnum (operands[1]))
3217     emit_move_insn (operands[3], operands[1]);
3219   /* Generate a cltd if possible and doing so it profitable.  */
3220   if (true_regnum (operands[3]) == 0
3221       && (optimize_size || TARGET_USE_CLTD))
3222     {
3223       emit_insn (gen_ashrsi3_31 (operands[4], operands[3], GEN_INT (31)));
3224       DONE;
3225     }
3227   if (true_regnum (operands[4]) != true_regnum (operands[1]))
3228     emit_move_insn (operands[4], operands[1]);
3230   emit_insn (gen_ashrsi3_31 (operands[4], operands[4], GEN_INT (31)));
3231   DONE;
3234 (define_insn "extendhisi2"
3235   [(set (match_operand:SI 0 "register_operand" "=*a,r")
3236         (sign_extend:SI (match_operand:HI 1 "nonimmediate_operand" "*0,rm")))]
3237   ""
3239   switch (get_attr_prefix_0f (insn))
3240     {
3241     case 0:
3242       return "{cwtl|cwde}";
3243     default:
3244       return "movs{wl|x}\t{%1,%0|%0, %1}";
3245     }
3247   [(set_attr "type" "imovx")
3248    (set_attr "mode" "SI")
3249    (set (attr "prefix_0f")
3250      ;; movsx is short decodable while cwtl is vector decoded.
3251      (if_then_else (and (eq_attr "cpu" "!k6")
3252                         (eq_attr "alternative" "0"))
3253         (const_string "0")
3254         (const_string "1")))
3255    (set (attr "modrm")
3256      (if_then_else (eq_attr "prefix_0f" "0")
3257         (const_string "0")
3258         (const_string "1")))])
3260 (define_insn "*extendhisi2_zext"
3261   [(set (match_operand:DI 0 "register_operand" "=*a,r")
3262         (zero_extend:DI
3263           (sign_extend:SI (match_operand:HI 1 "nonimmediate_operand" "*0,rm"))))]
3264   "TARGET_64BIT"
3266   switch (get_attr_prefix_0f (insn))
3267     {
3268     case 0:
3269       return "{cwtl|cwde}";
3270     default:
3271       return "movs{wl|x}\t{%1,%k0|%k0, %1}";
3272     }
3274   [(set_attr "type" "imovx")
3275    (set_attr "mode" "SI")
3276    (set (attr "prefix_0f")
3277      ;; movsx is short decodable while cwtl is vector decoded.
3278      (if_then_else (and (eq_attr "cpu" "!k6")
3279                         (eq_attr "alternative" "0"))
3280         (const_string "0")
3281         (const_string "1")))
3282    (set (attr "modrm")
3283      (if_then_else (eq_attr "prefix_0f" "0")
3284         (const_string "0")
3285         (const_string "1")))])
3287 (define_insn "extendqihi2"
3288   [(set (match_operand:HI 0 "register_operand" "=*a,r")
3289         (sign_extend:HI (match_operand:QI 1 "nonimmediate_operand" "*0,qm")))]
3290   ""
3292   switch (get_attr_prefix_0f (insn))
3293     {
3294     case 0:
3295       return "{cbtw|cbw}";
3296     default:
3297       return "movs{bw|x}\t{%1,%0|%0, %1}";
3298     }
3300   [(set_attr "type" "imovx")
3301    (set_attr "mode" "HI")
3302    (set (attr "prefix_0f")
3303      ;; movsx is short decodable while cwtl is vector decoded.
3304      (if_then_else (and (eq_attr "cpu" "!k6")
3305                         (eq_attr "alternative" "0"))
3306         (const_string "0")
3307         (const_string "1")))
3308    (set (attr "modrm")
3309      (if_then_else (eq_attr "prefix_0f" "0")
3310         (const_string "0")
3311         (const_string "1")))])
3313 (define_insn "extendqisi2"
3314   [(set (match_operand:SI 0 "register_operand" "=r")
3315         (sign_extend:SI (match_operand:QI 1 "nonimmediate_operand" "qm")))]
3316   ""
3317   "movs{bl|x}\t{%1,%0|%0, %1}"
3318    [(set_attr "type" "imovx")
3319     (set_attr "mode" "SI")])
3321 (define_insn "*extendqisi2_zext"
3322   [(set (match_operand:DI 0 "register_operand" "=r")
3323         (zero_extend:DI
3324           (sign_extend:SI (match_operand:QI 1 "nonimmediate_operand" "qm"))))]
3325   "TARGET_64BIT"
3326   "movs{bl|x}\t{%1,%k0|%k0, %1}"
3327    [(set_attr "type" "imovx")
3328     (set_attr "mode" "SI")])
3330 ;; Conversions between float and double.
3332 ;; These are all no-ops in the model used for the 80387.  So just
3333 ;; emit moves.
3335 ;; %%% Kill these when call knows how to work out a DFmode push earlier. 
3336 (define_insn "*dummy_extendsfdf2"
3337   [(set (match_operand:DF 0 "push_operand" "=<")
3338         (float_extend:DF (match_operand:SF 1 "nonimmediate_operand" "fY")))]
3339   "0"
3340   "#")
3342 (define_split
3343   [(set (match_operand:DF 0 "push_operand" "")
3344         (float_extend:DF (match_operand:SF 1 "register_operand" "")))]
3345   "!TARGET_64BIT && FP_REGNO_P (REGNO (operands[1]))"
3346   [(set (reg:SI 7) (plus:SI (reg:SI 7) (const_int -8)))
3347    (set (mem:DF (reg:SI 7)) (float_extend:DF (match_dup 1)))])
3349 (define_split
3350   [(set (match_operand:DF 0 "push_operand" "")
3351         (float_extend:DF (match_operand:SF 1 "register_operand" "")))]
3352   "TARGET_64BIT && FP_REGNO_P (REGNO (operands[1]))"
3353   [(set (reg:DI 7) (plus:DI (reg:DI 7) (const_int -8)))
3354    (set (mem:DF (reg:DI 7)) (float_extend:DF (match_dup 1)))])
3356 (define_insn "*dummy_extendsfxf2"
3357   [(set (match_operand:XF 0 "push_operand" "=<")
3358         (float_extend:XF (match_operand:SF 1 "nonimmediate_operand" "f")))]
3359   "0"
3360   "#")
3362 (define_split
3363   [(set (match_operand:XF 0 "push_operand" "")
3364         (float_extend:XF (match_operand:SF 1 "register_operand" "")))]
3365   "!TARGET_64BIT && FP_REGNO_P (REGNO (operands[1]))"
3366   [(set (reg:SI 7) (plus:SI (reg:SI 7) (const_int -12)))
3367    (set (mem:XF (reg:SI 7)) (float_extend:XF (match_dup 1)))])
3369 (define_insn "*dummy_extendsftf2"
3370   [(set (match_operand:TF 0 "push_operand" "=<")
3371         (float_extend:TF (match_operand:SF 1 "nonimmediate_operand" "f")))]
3372   "0"
3373   "#")
3375 (define_split
3376   [(set (match_operand:TF 0 "push_operand" "")
3377         (float_extend:TF (match_operand:SF 1 "register_operand" "")))]
3378   "!TARGET_64BIT && FP_REGNO_P (REGNO (operands[1]))"
3379   [(set (reg:SI 7) (plus:SI (reg:SI 7) (const_int -16)))
3380    (set (mem:TF (reg:SI 7)) (float_extend:TF (match_dup 1)))])
3382 (define_split
3383   [(set (match_operand:TF 0 "push_operand" "")
3384         (float_extend:TF (match_operand:SF 1 "register_operand" "")))]
3385   "TARGET_64BIT && FP_REGNO_P (REGNO (operands[1]))"
3386   [(set (reg:DI 7) (plus:DI (reg:DI 7) (const_int -16)))
3387    (set (mem:DF (reg:DI 7)) (float_extend:TF (match_dup 1)))])
3389 (define_insn "*dummy_extenddfxf2"
3390   [(set (match_operand:XF 0 "push_operand" "=<")
3391         (float_extend:XF (match_operand:DF 1 "nonimmediate_operand" "f")))]
3392   "0"
3393   "#")
3395 (define_split
3396   [(set (match_operand:XF 0 "push_operand" "")
3397         (float_extend:XF (match_operand:DF 1 "register_operand" "")))]
3398   "!TARGET_64BIT && FP_REGNO_P (REGNO (operands[1]))"
3399   [(set (reg:SI 7) (plus:SI (reg:SI 7) (const_int -12)))
3400    (set (mem:DF (reg:SI 7)) (float_extend:XF (match_dup 1)))])
3402 (define_insn "*dummy_extenddftf2"
3403   [(set (match_operand:TF 0 "push_operand" "=<")
3404         (float_extend:TF (match_operand:DF 1 "nonimmediate_operand" "f")))]
3405   "0"
3406   "#")
3408 (define_split
3409   [(set (match_operand:TF 0 "push_operand" "")
3410         (float_extend:TF (match_operand:DF 1 "register_operand" "")))]
3411   "!TARGET_64BIT && FP_REGNO_P (REGNO (operands[1]))"
3412   [(set (reg:SI 7) (plus:SI (reg:SI 7) (const_int -16)))
3413    (set (mem:TF (reg:SI 7)) (float_extend:XF (match_dup 1)))])
3415 (define_split
3416   [(set (match_operand:TF 0 "push_operand" "")
3417         (float_extend:TF (match_operand:DF 1 "register_operand" "")))]
3418   "TARGET_64BIT && FP_REGNO_P (REGNO (operands[1]))"
3419   [(set (reg:DI 7) (plus:DI (reg:DI 7) (const_int -16)))
3420    (set (mem:TF (reg:DI 7)) (float_extend:TF (match_dup 1)))])
3422 (define_expand "extendsfdf2"
3423   [(set (match_operand:DF 0 "nonimmediate_operand" "")
3424         (float_extend:DF (match_operand:SF 1 "general_operand" "")))]
3425   "TARGET_80387 || TARGET_SSE2"
3427   /* ??? Needed for compress_float_constant since all fp constants
3428      are LEGITIMATE_CONSTANT_P.  */
3429   if (GET_CODE (operands[1]) == CONST_DOUBLE)
3430     operands[1] = validize_mem (force_const_mem (SFmode, operands[1]));
3431   if (GET_CODE (operands[0]) == MEM && GET_CODE (operands[1]) == MEM)
3432     operands[1] = force_reg (SFmode, operands[1]);
3435 (define_insn "*extendsfdf2_1"
3436   [(set (match_operand:DF 0 "nonimmediate_operand" "=f#Y,mf#Y,Y#f")
3437         (float_extend:DF (match_operand:SF 1 "nonimmediate_operand" "fm#Y,f#Y,mY#f")))]
3438   "(TARGET_80387 || TARGET_SSE2)
3439    && (GET_CODE (operands[0]) != MEM || GET_CODE (operands[1]) != MEM)"
3441   switch (which_alternative)
3442     {
3443     case 0:
3444       if (REG_P (operands[1])
3445           && find_regno_note (insn, REG_DEAD, REGNO (operands[1])))
3446         return "fstp\t%y0";
3447       else if (STACK_TOP_P (operands[0]))
3448         return "fld%z1\t%y1";
3449       else
3450         return "fst\t%y0";
3452     case 1:
3453       if (find_regno_note (insn, REG_DEAD, REGNO (operands[1])))
3454         return "fstp%z0\t%y0";
3456       else
3457         return "fst%z0\t%y0";
3458     case 2:
3459       return "cvtss2sd\t{%1, %0|%0, %1}";
3461     default:
3462       abort ();
3463     }
3465   [(set_attr "type" "fmov,fmov,ssecvt")
3466    (set_attr "mode" "SF,XF,DF")])
3468 (define_insn "*extendsfdf2_1_sse_only"
3469   [(set (match_operand:DF 0 "register_operand" "=Y")
3470         (float_extend:DF (match_operand:SF 1 "nonimmediate_operand" "mY")))]
3471   "!TARGET_80387 && TARGET_SSE2
3472    && (GET_CODE (operands[0]) != MEM || GET_CODE (operands[1]) != MEM)"
3473   "cvtss2sd\t{%1, %0|%0, %1}"
3474   [(set_attr "type" "ssecvt")
3475    (set_attr "mode" "DF")])
3477 (define_expand "extendsfxf2"
3478   [(set (match_operand:XF 0 "nonimmediate_operand" "")
3479         (float_extend:XF (match_operand:SF 1 "general_operand" "")))]
3480   "!TARGET_64BIT && TARGET_80387"
3482   /* ??? Needed for compress_float_constant since all fp constants
3483      are LEGITIMATE_CONSTANT_P.  */
3484   if (GET_CODE (operands[1]) == CONST_DOUBLE)
3485     operands[1] = validize_mem (force_const_mem (SFmode, operands[1]));
3486   if (GET_CODE (operands[0]) == MEM && GET_CODE (operands[1]) == MEM)
3487     operands[1] = force_reg (SFmode, operands[1]);
3490 (define_insn "*extendsfxf2_1"
3491   [(set (match_operand:XF 0 "nonimmediate_operand" "=f,m")
3492         (float_extend:XF (match_operand:SF 1 "nonimmediate_operand" "fm,f")))]
3493   "!TARGET_64BIT && TARGET_80387
3494    && (GET_CODE (operands[0]) != MEM || GET_CODE (operands[1]) != MEM)"
3496   switch (which_alternative)
3497     {
3498     case 0:
3499       if (REG_P (operands[1])
3500           && find_regno_note (insn, REG_DEAD, REGNO (operands[1])))
3501         return "fstp\t%y0";
3502       else if (STACK_TOP_P (operands[0]))
3503         return "fld%z1\t%y1";
3504       else
3505         return "fst\t%y0";
3507     case 1:
3508       /* There is no non-popping store to memory for XFmode.  So if
3509          we need one, follow the store with a load.  */
3510       if (! find_regno_note (insn, REG_DEAD, REGNO (operands[1])))
3511         return "fstp%z0\t%y0\n\tfld%z0\t%y0";
3512       else
3513         return "fstp%z0\t%y0";
3515     default:
3516       abort ();
3517     }
3519   [(set_attr "type" "fmov")
3520    (set_attr "mode" "SF,XF")])
3522 (define_expand "extendsftf2"
3523   [(set (match_operand:TF 0 "nonimmediate_operand" "")
3524         (float_extend:TF (match_operand:SF 1 "general_operand" "")))]
3525   "TARGET_80387"
3527   /* ??? Needed for compress_float_constant since all fp constants
3528      are LEGITIMATE_CONSTANT_P.  */
3529   if (GET_CODE (operands[1]) == CONST_DOUBLE)
3530     operands[1] = validize_mem (force_const_mem (SFmode, operands[1]));
3531   if (GET_CODE (operands[0]) == MEM && GET_CODE (operands[1]) == MEM)
3532     operands[1] = force_reg (SFmode, operands[1]);
3535 (define_insn "*extendsftf2_1"
3536   [(set (match_operand:TF 0 "nonimmediate_operand" "=f,m")
3537         (float_extend:TF (match_operand:SF 1 "nonimmediate_operand" "fm,f")))]
3538   "TARGET_80387
3539    && (GET_CODE (operands[0]) != MEM || GET_CODE (operands[1]) != MEM)"
3541   switch (which_alternative)
3542     {
3543     case 0:
3544       if (REG_P (operands[1])
3545           && find_regno_note (insn, REG_DEAD, REGNO (operands[1])))
3546         return "fstp\t%y0";
3547       else if (STACK_TOP_P (operands[0]))
3548         return "fld%z1\t%y1";
3549       else
3550         return "fst\t%y0";
3552     case 1:
3553       /* There is no non-popping store to memory for XFmode.  So if
3554          we need one, follow the store with a load.  */
3555       if (! find_regno_note (insn, REG_DEAD, REGNO (operands[1])))
3556         return "fstp%z0\t%y0\n\tfld%z0\t%y0";
3557       else
3558         return "fstp%z0\t%y0";
3560     default:
3561       abort ();
3562     }
3564   [(set_attr "type" "fmov")
3565    (set_attr "mode" "SF,XF")])
3567 (define_expand "extenddfxf2"
3568   [(set (match_operand:XF 0 "nonimmediate_operand" "")
3569         (float_extend:XF (match_operand:DF 1 "general_operand" "")))]
3570   "!TARGET_64BIT && TARGET_80387"
3572   /* ??? Needed for compress_float_constant since all fp constants
3573      are LEGITIMATE_CONSTANT_P.  */
3574   if (GET_CODE (operands[1]) == CONST_DOUBLE)
3575     operands[1] = validize_mem (force_const_mem (DFmode, operands[1]));
3576   if (GET_CODE (operands[0]) == MEM && GET_CODE (operands[1]) == MEM)
3577     operands[1] = force_reg (DFmode, operands[1]);
3580 (define_insn "*extenddfxf2_1"
3581   [(set (match_operand:XF 0 "nonimmediate_operand" "=f,m")
3582         (float_extend:XF (match_operand:DF 1 "nonimmediate_operand" "fm,f")))]
3583   "!TARGET_64BIT && TARGET_80387
3584    && (GET_CODE (operands[0]) != MEM || GET_CODE (operands[1]) != MEM)"
3586   switch (which_alternative)
3587     {
3588     case 0:
3589       if (REG_P (operands[1])
3590           && find_regno_note (insn, REG_DEAD, REGNO (operands[1])))
3591         return "fstp\t%y0";
3592       else if (STACK_TOP_P (operands[0]))
3593         return "fld%z1\t%y1";
3594       else
3595         return "fst\t%y0";
3597     case 1:
3598       /* There is no non-popping store to memory for XFmode.  So if
3599          we need one, follow the store with a load.  */
3600       if (! find_regno_note (insn, REG_DEAD, REGNO (operands[1])))
3601         return "fstp%z0\t%y0\n\tfld%z0\t%y0";
3602       else
3603         return "fstp%z0\t%y0";
3605     default:
3606       abort ();
3607     }
3609   [(set_attr "type" "fmov")
3610    (set_attr "mode" "DF,XF")])
3612 (define_expand "extenddftf2"
3613   [(set (match_operand:TF 0 "nonimmediate_operand" "")
3614         (float_extend:TF (match_operand:DF 1 "general_operand" "")))]
3615   "TARGET_80387"
3617   /* ??? Needed for compress_float_constant since all fp constants
3618      are LEGITIMATE_CONSTANT_P.  */
3619   if (GET_CODE (operands[1]) == CONST_DOUBLE)
3620     operands[1] = validize_mem (force_const_mem (DFmode, operands[1]));
3621   if (GET_CODE (operands[0]) == MEM && GET_CODE (operands[1]) == MEM)
3622     operands[1] = force_reg (DFmode, operands[1]);
3625 (define_insn "*extenddftf2_1"
3626   [(set (match_operand:TF 0 "nonimmediate_operand" "=f,m")
3627         (float_extend:TF (match_operand:DF 1 "nonimmediate_operand" "fm,f")))]
3628   "TARGET_80387
3629    && (GET_CODE (operands[0]) != MEM || GET_CODE (operands[1]) != MEM)"
3631   switch (which_alternative)
3632     {
3633     case 0:
3634       if (REG_P (operands[1])
3635           && find_regno_note (insn, REG_DEAD, REGNO (operands[1])))
3636         return "fstp\t%y0";
3637       else if (STACK_TOP_P (operands[0]))
3638         return "fld%z1\t%y1";
3639       else
3640         return "fst\t%y0";
3642     case 1:
3643       /* There is no non-popping store to memory for XFmode.  So if
3644          we need one, follow the store with a load.  */
3645       if (! find_regno_note (insn, REG_DEAD, REGNO (operands[1])))
3646         return "fstp%z0\t%y0\n\tfld%z0\t%y0";
3647       else
3648         return "fstp%z0\t%y0";
3650     default:
3651       abort ();
3652     }
3654   [(set_attr "type" "fmov")
3655    (set_attr "mode" "DF,XF")])
3657 ;; %%% This seems bad bad news.
3658 ;; This cannot output into an f-reg because there is no way to be sure
3659 ;; of truncating in that case.  Otherwise this is just like a simple move
3660 ;; insn.  So we pretend we can output to a reg in order to get better
3661 ;; register preferencing, but we really use a stack slot.
3663 (define_expand "truncdfsf2"
3664   [(parallel [(set (match_operand:SF 0 "nonimmediate_operand" "")
3665                    (float_truncate:SF
3666                     (match_operand:DF 1 "register_operand" "")))
3667               (clobber (match_dup 2))])]
3668   "TARGET_80387 || TARGET_SSE2"
3669   "
3670    if (TARGET_80387)
3671      operands[2] = assign_386_stack_local (SFmode, 0);
3672    else
3673      {
3674         emit_insn (gen_truncdfsf2_sse_only (operands[0], operands[1]));
3675         DONE;
3676      }
3679 (define_insn "*truncdfsf2_1"
3680   [(set (match_operand:SF 0 "nonimmediate_operand" "=m,?f#rx,?r#fx,?x#rf")
3681         (float_truncate:SF
3682          (match_operand:DF 1 "register_operand" "f,f,f,f")))
3683    (clobber (match_operand:SF 2 "memory_operand" "=X,m,m,m"))]
3684   "TARGET_80387 && !TARGET_SSE2"
3686   switch (which_alternative)
3687     {
3688     case 0:
3689       if (find_regno_note (insn, REG_DEAD, REGNO (operands[1])))
3690         return "fstp%z0\t%y0";
3691       else
3692         return "fst%z0\t%y0";
3693     default:
3694       abort ();
3695     }
3697   [(set_attr "type" "fmov,multi,multi,multi")
3698    (set_attr "mode" "SF,SF,SF,SF")])
3700 (define_insn "*truncdfsf2_1_sse"
3701   [(set (match_operand:SF 0 "nonimmediate_operand" "=*!m,?f#rx,?r#fx,?x#rf,Y")
3702         (float_truncate:SF
3703          (match_operand:DF 1 "nonimmediate_operand" "f,f,f,f,mY")))
3704    (clobber (match_operand:SF 2 "memory_operand" "=X,m,m,m,X"))]
3705   "TARGET_80387 && TARGET_SSE2"
3707   switch (which_alternative)
3708     {
3709     case 0:
3710       if (find_regno_note (insn, REG_DEAD, REGNO (operands[1])))
3711         return "fstp%z0\t%y0";
3712       else
3713         return "fst%z0\t%y0";
3714     case 4:
3715       return "cvtsd2ss\t{%1, %0|%0, %1}";
3716     default:
3717       abort ();
3718     }
3720   [(set_attr "type" "fmov,multi,multi,multi,ssecvt")
3721    (set_attr "mode" "SF,SF,SF,SF,DF")])
3723 (define_insn "*truncdfsf2_2"
3724   [(set (match_operand:SF 0 "nonimmediate_operand" "=Y,!m")
3725         (float_truncate:SF
3726          (match_operand:DF 1 "nonimmediate_operand" "mY,f")))]
3727   "TARGET_80387 && TARGET_SSE2
3728    && (GET_CODE (operands[0]) != MEM || GET_CODE (operands[1]) != MEM)"
3730   switch (which_alternative)
3731     {
3732     case 0:
3733       return "cvtsd2ss\t{%1, %0|%0, %1}";
3734     case 1:
3735       if (find_regno_note (insn, REG_DEAD, REGNO (operands[1])))
3736         return "fstp%z0\t%y0";
3737       else
3738         return "fst%z0\t%y0";
3739     default:
3740       abort ();
3741     }
3743   [(set_attr "type" "ssecvt,fmov")
3744    (set_attr "mode" "DF,SF")])
3746 (define_insn "truncdfsf2_3"
3747   [(set (match_operand:SF 0 "memory_operand" "=m")
3748         (float_truncate:SF
3749          (match_operand:DF 1 "register_operand" "f")))]
3750   "TARGET_80387"
3752   if (find_regno_note (insn, REG_DEAD, REGNO (operands[1])))
3753     return "fstp%z0\t%y0";
3754   else
3755     return "fst%z0\t%y0";
3757   [(set_attr "type" "fmov")
3758    (set_attr "mode" "SF")])
3760 (define_insn "truncdfsf2_sse_only"
3761   [(set (match_operand:SF 0 "register_operand" "=Y")
3762         (float_truncate:SF
3763          (match_operand:DF 1 "nonimmediate_operand" "mY")))]
3764   "!TARGET_80387 && TARGET_SSE2"
3765   "cvtsd2ss\t{%1, %0|%0, %1}"
3766   [(set_attr "type" "ssecvt")
3767    (set_attr "mode" "DF")])
3769 (define_split
3770   [(set (match_operand:SF 0 "memory_operand" "")
3771         (float_truncate:SF
3772          (match_operand:DF 1 "register_operand" "")))
3773    (clobber (match_operand:SF 2 "memory_operand" ""))]
3774   "TARGET_80387"
3775   [(set (match_dup 0) (float_truncate:SF (match_dup 1)))]
3776   "")
3778 (define_split
3779   [(set (match_operand:SF 0 "nonimmediate_operand" "")
3780         (float_truncate:SF
3781          (match_operand:DF 1 "nonimmediate_operand" "")))
3782    (clobber (match_operand 2 "" ""))]
3783   "TARGET_80387 && reload_completed
3784    && !FP_REG_P (operands[0]) && !FP_REG_P (operands[1])"
3785   [(set (match_dup 0) (float_truncate:SF (match_dup 1)))]
3786   "")
3788 (define_split
3789   [(set (match_operand:SF 0 "register_operand" "")
3790         (float_truncate:SF
3791          (match_operand:DF 1 "register_operand" "")))
3792    (clobber (match_operand:SF 2 "memory_operand" ""))]
3793   "TARGET_80387 && reload_completed
3794    && FP_REG_P (operands[1])"
3795   [(set (match_dup 2) (float_truncate:SF (match_dup 1)))
3796    (set (match_dup 0) (match_dup 2))]
3797   "")
3799 (define_expand "truncxfsf2"
3800   [(parallel [(set (match_operand:SF 0 "nonimmediate_operand" "")
3801                    (float_truncate:SF
3802                     (match_operand:XF 1 "register_operand" "")))
3803               (clobber (match_dup 2))])]
3804   "!TARGET_64BIT && TARGET_80387"
3805   "operands[2] = assign_386_stack_local (SFmode, 0);")
3807 (define_insn "*truncxfsf2_1"
3808   [(set (match_operand:SF 0 "nonimmediate_operand" "=m,?f#rx,?r#fx,?x#rf")
3809         (float_truncate:SF
3810          (match_operand:XF 1 "register_operand" "f,f,f,f")))
3811    (clobber (match_operand:SF 2 "memory_operand" "=X,m,m,m"))]
3812   "!TARGET_64BIT && TARGET_80387"
3814   switch (which_alternative)
3815     {
3816     case 0:
3817       if (find_regno_note (insn, REG_DEAD, REGNO (operands[1])))
3818         return "fstp%z0\t%y0";
3819       else
3820         return "fst%z0\t%y0";
3821     default:
3822       abort();
3823     }
3825   [(set_attr "type" "fmov,multi,multi,multi")
3826    (set_attr "mode" "SF")])
3828 (define_insn "*truncxfsf2_2"
3829   [(set (match_operand:SF 0 "memory_operand" "=m")
3830         (float_truncate:SF
3831          (match_operand:XF 1 "register_operand" "f")))]
3832   "!TARGET_64BIT && TARGET_80387"
3834   if (find_regno_note (insn, REG_DEAD, REGNO (operands[1])))
3835     return "fstp%z0\t%y0";
3836   else
3837     return "fst%z0\t%y0";
3839   [(set_attr "type" "fmov")
3840    (set_attr "mode" "SF")])
3842 (define_split
3843   [(set (match_operand:SF 0 "memory_operand" "")
3844         (float_truncate:SF
3845          (match_operand:XF 1 "register_operand" "")))
3846    (clobber (match_operand:SF 2 "memory_operand" ""))]
3847   "TARGET_80387"
3848   [(set (match_dup 0) (float_truncate:SF (match_dup 1)))]
3849   "")
3851 (define_split
3852   [(set (match_operand:SF 0 "register_operand" "")
3853         (float_truncate:SF
3854          (match_operand:XF 1 "register_operand" "")))
3855    (clobber (match_operand:SF 2 "memory_operand" ""))]
3856   "TARGET_80387 && reload_completed"
3857   [(set (match_dup 2) (float_truncate:SF (match_dup 1)))
3858    (set (match_dup 0) (match_dup 2))]
3859   "")
3861 (define_expand "trunctfsf2"
3862   [(parallel [(set (match_operand:SF 0 "nonimmediate_operand" "")
3863                    (float_truncate:SF
3864                     (match_operand:TF 1 "register_operand" "")))
3865               (clobber (match_dup 2))])]
3866   "TARGET_80387"
3867   "operands[2] = assign_386_stack_local (SFmode, 0);")
3869 (define_insn "*trunctfsf2_1"
3870   [(set (match_operand:SF 0 "nonimmediate_operand" "=m,?f#rx,?r#fx,?x#rf")
3871         (float_truncate:SF
3872          (match_operand:TF 1 "register_operand" "f,f,f,f")))
3873    (clobber (match_operand:SF 2 "memory_operand" "=X,m,m,m"))]
3874   "TARGET_80387"
3876   switch (which_alternative)
3877     {
3878     case 0:
3879       if (find_regno_note (insn, REG_DEAD, REGNO (operands[1])))
3880         return "fstp%z0\t%y0";
3881       else
3882         return "fst%z0\t%y0";
3883     default:
3884       abort();
3885     }
3887   [(set_attr "type" "fmov,multi,multi,multi")
3888    (set_attr "mode" "SF")])
3890 (define_insn "*trunctfsf2_2"
3891   [(set (match_operand:SF 0 "memory_operand" "=m")
3892         (float_truncate:SF
3893          (match_operand:TF 1 "register_operand" "f")))]
3894   "TARGET_80387"
3896   if (find_regno_note (insn, REG_DEAD, REGNO (operands[1])))
3897     return "fstp%z0\t%y0";
3898   else
3899     return "fst%z0\t%y0";
3901   [(set_attr "type" "fmov")
3902    (set_attr "mode" "SF")])
3904 (define_split
3905   [(set (match_operand:SF 0 "memory_operand" "")
3906         (float_truncate:SF
3907          (match_operand:TF 1 "register_operand" "")))
3908    (clobber (match_operand:SF 2 "memory_operand" ""))]
3909   "TARGET_80387"
3910   [(set (match_dup 0) (float_truncate:SF (match_dup 1)))]
3911   "")
3913 (define_split
3914   [(set (match_operand:SF 0 "register_operand" "")
3915         (float_truncate:SF
3916          (match_operand:TF 1 "register_operand" "")))
3917    (clobber (match_operand:SF 2 "memory_operand" ""))]
3918   "TARGET_80387 && reload_completed"
3919   [(set (match_dup 2) (float_truncate:SF (match_dup 1)))
3920    (set (match_dup 0) (match_dup 2))]
3921   "")
3924 (define_expand "truncxfdf2"
3925   [(parallel [(set (match_operand:DF 0 "nonimmediate_operand" "")
3926                    (float_truncate:DF
3927                     (match_operand:XF 1 "register_operand" "")))
3928               (clobber (match_dup 2))])]
3929   "!TARGET_64BIT && TARGET_80387"
3930   "operands[2] = assign_386_stack_local (DFmode, 0);")
3932 (define_insn "*truncxfdf2_1"
3933   [(set (match_operand:DF 0 "nonimmediate_operand" "=m,?f#rY,?r#fY,?Y#rf")
3934         (float_truncate:DF
3935          (match_operand:XF 1 "register_operand" "f,f,f,f")))
3936    (clobber (match_operand:DF 2 "memory_operand" "=X,m,m,m"))]
3937   "!TARGET_64BIT && TARGET_80387"
3939   switch (which_alternative)
3940     {
3941     case 0:
3942       if (find_regno_note (insn, REG_DEAD, REGNO (operands[1])))
3943         return "fstp%z0\t%y0";
3944       else
3945         return "fst%z0\t%y0";
3946     default:
3947       abort();
3948     }
3949   abort ();
3951   [(set_attr "type" "fmov,multi,multi,multi")
3952    (set_attr "mode" "DF")])
3954 (define_insn "*truncxfdf2_2"
3955   [(set (match_operand:DF 0 "memory_operand" "=m")
3956         (float_truncate:DF
3957           (match_operand:XF 1 "register_operand" "f")))]
3958   "!TARGET_64BIT && TARGET_80387"
3960   if (find_regno_note (insn, REG_DEAD, REGNO (operands[1])))
3961     return "fstp%z0\t%y0";
3962   else
3963     return "fst%z0\t%y0";
3965   [(set_attr "type" "fmov")
3966    (set_attr "mode" "DF")])
3968 (define_split
3969   [(set (match_operand:DF 0 "memory_operand" "")
3970         (float_truncate:DF
3971          (match_operand:XF 1 "register_operand" "")))
3972    (clobber (match_operand:DF 2 "memory_operand" ""))]
3973   "TARGET_80387"
3974   [(set (match_dup 0) (float_truncate:DF (match_dup 1)))]
3975   "")
3977 (define_split
3978   [(set (match_operand:DF 0 "register_operand" "")
3979         (float_truncate:DF
3980          (match_operand:XF 1 "register_operand" "")))
3981    (clobber (match_operand:DF 2 "memory_operand" ""))]
3982   "TARGET_80387 && reload_completed"
3983   [(set (match_dup 2) (float_truncate:DF (match_dup 1)))
3984    (set (match_dup 0) (match_dup 2))]
3985   "")
3987 (define_expand "trunctfdf2"
3988   [(parallel [(set (match_operand:DF 0 "nonimmediate_operand" "")
3989                    (float_truncate:DF
3990                     (match_operand:TF 1 "register_operand" "")))
3991               (clobber (match_dup 2))])]
3992   "TARGET_80387"
3993   "operands[2] = assign_386_stack_local (DFmode, 0);")
3995 (define_insn "*trunctfdf2_1"
3996   [(set (match_operand:DF 0 "nonimmediate_operand" "=m,?f#rY,?r#fY,?Y#rf")
3997         (float_truncate:DF
3998          (match_operand:TF 1 "register_operand" "f,f,f,f")))
3999    (clobber (match_operand:DF 2 "memory_operand" "=X,m,m,m"))]
4000   "TARGET_80387"
4002   switch (which_alternative)
4003     {
4004     case 0:
4005       if (find_regno_note (insn, REG_DEAD, REGNO (operands[1])))
4006         return "fstp%z0\t%y0";
4007       else
4008         return "fst%z0\t%y0";
4009     default:
4010       abort();
4011     }
4012   abort ();
4014   [(set_attr "type" "fmov,multi,multi,multi")
4015    (set_attr "mode" "DF")])
4017         (define_insn "*trunctfdf2_2"
4018   [(set (match_operand:DF 0 "memory_operand" "=m")
4019         (float_truncate:DF
4020           (match_operand:TF 1 "register_operand" "f")))]
4021   "TARGET_80387"
4023   if (find_regno_note (insn, REG_DEAD, REGNO (operands[1])))
4024     return "fstp%z0\t%y0";
4025   else
4026     return "fst%z0\t%y0";
4028   [(set_attr "type" "fmov")
4029    (set_attr "mode" "DF")])
4031 (define_split
4032   [(set (match_operand:DF 0 "memory_operand" "")
4033         (float_truncate:DF
4034          (match_operand:TF 1 "register_operand" "")))
4035    (clobber (match_operand:DF 2 "memory_operand" ""))]
4036   "TARGET_80387"
4037   [(set (match_dup 0) (float_truncate:DF (match_dup 1)))]
4038   "")
4040 (define_split
4041   [(set (match_operand:DF 0 "register_operand" "")
4042         (float_truncate:DF
4043          (match_operand:TF 1 "register_operand" "")))
4044    (clobber (match_operand:DF 2 "memory_operand" ""))]
4045   "TARGET_80387 && reload_completed"
4046   [(set (match_dup 2) (float_truncate:DF (match_dup 1)))
4047    (set (match_dup 0) (match_dup 2))]
4048   "")
4051 ;; %%% Break up all these bad boys.
4053 ;; Signed conversion to DImode.
4055 (define_expand "fix_truncxfdi2"
4056   [(set (match_operand:DI 0 "nonimmediate_operand" "")
4057         (fix:DI (match_operand:XF 1 "register_operand" "")))]
4058   "!TARGET_64BIT && TARGET_80387"
4059   "")
4061 (define_expand "fix_trunctfdi2"
4062   [(set (match_operand:DI 0 "nonimmediate_operand" "")
4063         (fix:DI (match_operand:TF 1 "register_operand" "")))]
4064   "TARGET_80387"
4065   "")
4067 (define_expand "fix_truncdfdi2"
4068   [(set (match_operand:DI 0 "nonimmediate_operand" "")
4069         (fix:DI (match_operand:DF 1 "register_operand" "")))]
4070   "TARGET_80387 || (TARGET_SSE2 && TARGET_64BIT)"
4072   if (TARGET_64BIT && TARGET_SSE2)
4073    {
4074      rtx out = REG_P (operands[0]) ? operands[0] : gen_reg_rtx (DImode);
4075      emit_insn (gen_fix_truncdfdi_sse (out, operands[1]));
4076      if (out != operands[0])
4077         emit_move_insn (operands[0], out);
4078      DONE;
4079    }
4082 (define_expand "fix_truncsfdi2"
4083   [(set (match_operand:DI 0 "nonimmediate_operand" "")
4084         (fix:DI (match_operand:SF 1 "register_operand" "")))]
4085   "TARGET_80387 || (TARGET_SSE && TARGET_64BIT)"
4087   if (TARGET_SSE && TARGET_64BIT)
4088    {
4089      rtx out = REG_P (operands[0]) ? operands[0] : gen_reg_rtx (DImode);
4090      emit_insn (gen_fix_truncsfdi_sse (out, operands[1]));
4091      if (out != operands[0])
4092         emit_move_insn (operands[0], out);
4093      DONE;
4094    }
4097 ;; See the comments in i386.h near OPTIMIZE_MODE_SWITCHING for the description
4098 ;; of the machinery.
4099 (define_insn_and_split "*fix_truncdi_1"
4100   [(set (match_operand:DI 0 "nonimmediate_operand" "=m,?r")
4101         (fix:DI (match_operand 1 "register_operand" "f,f")))]
4102   "TARGET_80387 && FLOAT_MODE_P (GET_MODE (operands[1]))
4103    && !reload_completed && !reload_in_progress
4104    && (!SSE_FLOAT_MODE_P (GET_MODE (operands[1])) || !TARGET_64BIT)"
4105   "#"
4106   "&& 1"
4107   [(const_int 0)]
4109   operands[2] = assign_386_stack_local (HImode, 1);
4110   operands[3] = assign_386_stack_local (HImode, 2);
4111   if (memory_operand (operands[0], VOIDmode))
4112     emit_insn (gen_fix_truncdi_memory (operands[0], operands[1],
4113                                        operands[2], operands[3]));
4114   else
4115     {
4116       operands[4] = assign_386_stack_local (DImode, 0);
4117       emit_insn (gen_fix_truncdi_nomemory (operands[0], operands[1],
4118                                            operands[2], operands[3],
4119                                            operands[4]));
4120     }
4121   DONE;
4123   [(set_attr "type" "fistp")])
4125 (define_insn "fix_truncdi_nomemory"
4126   [(set (match_operand:DI 0 "nonimmediate_operand" "=m,?r")
4127         (fix:DI (match_operand 1 "register_operand" "f,f")))
4128    (use (match_operand:HI 2 "memory_operand" "m,m"))
4129    (use (match_operand:HI 3 "memory_operand" "m,m"))
4130    (clobber (match_operand:DI 4 "memory_operand" "=m,m"))
4131    (clobber (match_scratch:DF 5 "=&1f,&1f"))]
4132   "TARGET_80387 && FLOAT_MODE_P (GET_MODE (operands[1]))
4133    && (!SSE_FLOAT_MODE_P (GET_MODE (operands[1])) || !TARGET_64BIT)"
4134   "#"
4135   [(set_attr "type" "fistp")])
4137 (define_insn "fix_truncdi_memory"
4138   [(set (match_operand:DI 0 "memory_operand" "=m")
4139         (fix:DI (match_operand 1 "register_operand" "f")))
4140    (use (match_operand:HI 2 "memory_operand" "m"))
4141    (use (match_operand:HI 3 "memory_operand" "m"))
4142    (clobber (match_scratch:DF 4 "=&1f"))]
4143   "TARGET_80387 && FLOAT_MODE_P (GET_MODE (operands[1]))
4144    && (!SSE_FLOAT_MODE_P (GET_MODE (operands[1])) || !TARGET_64BIT)"
4145   "* operands[5] = operands[4]; return output_fix_trunc (insn, operands);"
4146   [(set_attr "type" "fistp")])
4148 (define_split 
4149   [(set (match_operand:DI 0 "register_operand" "")
4150         (fix:DI (match_operand 1 "register_operand" "")))
4151    (use (match_operand:HI 2 "memory_operand" ""))
4152    (use (match_operand:HI 3 "memory_operand" ""))
4153    (clobber (match_operand:DI 4 "memory_operand" ""))
4154    (clobber (match_scratch 5 ""))]
4155   "reload_completed"
4156   [(parallel [(set (match_dup 4) (fix:DI (match_dup 1)))
4157               (use (match_dup 2))
4158               (use (match_dup 3))
4159               (clobber (match_dup 5))])
4160    (set (match_dup 0) (match_dup 4))]
4161   "")
4163 (define_split 
4164   [(set (match_operand:DI 0 "memory_operand" "")
4165         (fix:DI (match_operand 1 "register_operand" "")))
4166    (use (match_operand:HI 2 "memory_operand" ""))
4167    (use (match_operand:HI 3 "memory_operand" ""))
4168    (clobber (match_operand:DI 4 "memory_operand" ""))
4169    (clobber (match_scratch 5 ""))]
4170   "reload_completed"
4171   [(parallel [(set (match_dup 0) (fix:DI (match_dup 1)))
4172               (use (match_dup 2))
4173               (use (match_dup 3))
4174               (clobber (match_dup 5))])]
4175   "")
4177 ;; When SSE available, it is always faster to use it!
4178 (define_insn "fix_truncsfdi_sse"
4179   [(set (match_operand:DI 0 "register_operand" "=r")
4180         (fix:DI (match_operand:SF 1 "nonimmediate_operand" "xm")))]
4181   "TARGET_64BIT && TARGET_SSE"
4182   "cvttss2si{q}\t{%1, %0|%0, %1}"
4183   [(set_attr "type" "ssecvt")])
4185 (define_insn "fix_truncdfdi_sse"
4186   [(set (match_operand:DI 0 "register_operand" "=r")
4187         (fix:DI (match_operand:DF 1 "nonimmediate_operand" "Ym")))]
4188   "TARGET_64BIT && TARGET_SSE2"
4189   "cvttsd2si{q}\t{%1, %0|%0, %1}"
4190   [(set_attr "type" "ssecvt")])
4192 ;; Signed conversion to SImode.
4194 (define_expand "fix_truncxfsi2"
4195   [(set (match_operand:SI 0 "nonimmediate_operand" "")
4196         (fix:SI (match_operand:XF 1 "register_operand" "")))]
4197   "!TARGET_64BIT && TARGET_80387"
4198   "")
4200 (define_expand "fix_trunctfsi2"
4201   [(set (match_operand:SI 0 "nonimmediate_operand" "")
4202         (fix:SI (match_operand:TF 1 "register_operand" "")))]
4203   "TARGET_80387"
4204   "")
4206 (define_expand "fix_truncdfsi2"
4207   [(set (match_operand:SI 0 "nonimmediate_operand" "")
4208         (fix:SI (match_operand:DF 1 "register_operand" "")))]
4209   "TARGET_80387 || TARGET_SSE2"
4211   if (TARGET_SSE2)
4212    {
4213      rtx out = REG_P (operands[0]) ? operands[0] : gen_reg_rtx (SImode);
4214      emit_insn (gen_fix_truncdfsi_sse (out, operands[1]));
4215      if (out != operands[0])
4216         emit_move_insn (operands[0], out);
4217      DONE;
4218    }
4221 (define_expand "fix_truncsfsi2"
4222   [(set (match_operand:SI 0 "nonimmediate_operand" "")
4223         (fix:SI (match_operand:SF 1 "register_operand" "")))]
4224   "TARGET_80387 || TARGET_SSE"
4226   if (TARGET_SSE)
4227    {
4228      rtx out = REG_P (operands[0]) ? operands[0] : gen_reg_rtx (SImode);
4229      emit_insn (gen_fix_truncsfsi_sse (out, operands[1]));
4230      if (out != operands[0])
4231         emit_move_insn (operands[0], out);
4232      DONE;
4233    }
4236 ;; See the comments in i386.h near OPTIMIZE_MODE_SWITCHING for the description
4237 ;; of the machinery.
4238 (define_insn_and_split "*fix_truncsi_1"
4239   [(set (match_operand:SI 0 "nonimmediate_operand" "=m,?r")
4240         (fix:SI (match_operand 1 "register_operand" "f,f")))]
4241   "TARGET_80387 && FLOAT_MODE_P (GET_MODE (operands[1]))
4242    && !reload_completed && !reload_in_progress
4243    && !SSE_FLOAT_MODE_P (GET_MODE (operands[1]))"
4244   "#"
4245   "&& 1"
4246   [(const_int 0)]
4248   operands[2] = assign_386_stack_local (HImode, 1);
4249   operands[3] = assign_386_stack_local (HImode, 2);
4250   if (memory_operand (operands[0], VOIDmode))
4251     emit_insn (gen_fix_truncsi_memory (operands[0], operands[1],
4252                                        operands[2], operands[3]));
4253   else
4254     {
4255       operands[4] = assign_386_stack_local (SImode, 0);
4256       emit_insn (gen_fix_truncsi_nomemory (operands[0], operands[1],
4257                                            operands[2], operands[3],
4258                                            operands[4]));
4259     }
4260   DONE;
4262   [(set_attr "type" "fistp")])
4264 (define_insn "fix_truncsi_nomemory"
4265   [(set (match_operand:SI 0 "nonimmediate_operand" "=m,?r")
4266         (fix:SI (match_operand 1 "register_operand" "f,f")))
4267    (use (match_operand:HI 2 "memory_operand" "m,m"))
4268    (use (match_operand:HI 3 "memory_operand" "m,m"))
4269    (clobber (match_operand:SI 4 "memory_operand" "=m,m"))]
4270   "TARGET_80387 && FLOAT_MODE_P (GET_MODE (operands[1]))
4271    && !SSE_FLOAT_MODE_P (GET_MODE (operands[1]))"
4272   "#"
4273   [(set_attr "type" "fistp")])
4275 (define_insn "fix_truncsi_memory"
4276   [(set (match_operand:SI 0 "memory_operand" "=m")
4277         (fix:SI (match_operand 1 "register_operand" "f")))
4278    (use (match_operand:HI 2 "memory_operand" "m"))
4279    (use (match_operand:HI 3 "memory_operand" "m"))]
4280   "TARGET_80387 && FLOAT_MODE_P (GET_MODE (operands[1]))
4281    && !SSE_FLOAT_MODE_P (GET_MODE (operands[1]))"
4282   "* return output_fix_trunc (insn, operands);"
4283   [(set_attr "type" "fistp")])
4285 ;; When SSE available, it is always faster to use it!
4286 (define_insn "fix_truncsfsi_sse"
4287   [(set (match_operand:SI 0 "register_operand" "=r")
4288         (fix:SI (match_operand:SF 1 "nonimmediate_operand" "xm")))]
4289   "TARGET_SSE"
4290   "cvttss2si\t{%1, %0|%0, %1}"
4291   [(set_attr "type" "ssecvt")])
4293 (define_insn "fix_truncdfsi_sse"
4294   [(set (match_operand:SI 0 "register_operand" "=r")
4295         (fix:SI (match_operand:DF 1 "nonimmediate_operand" "Ym")))]
4296   "TARGET_SSE2"
4297   "cvttsd2si\t{%1, %0|%0, %1}"
4298   [(set_attr "type" "ssecvt")])
4300 (define_split 
4301   [(set (match_operand:SI 0 "register_operand" "")
4302         (fix:SI (match_operand 1 "register_operand" "")))
4303    (use (match_operand:HI 2 "memory_operand" ""))
4304    (use (match_operand:HI 3 "memory_operand" ""))
4305    (clobber (match_operand:SI 4 "memory_operand" ""))]
4306   "reload_completed"
4307   [(parallel [(set (match_dup 4) (fix:SI (match_dup 1)))
4308               (use (match_dup 2))
4309               (use (match_dup 3))])
4310    (set (match_dup 0) (match_dup 4))]
4311   "")
4313 (define_split 
4314   [(set (match_operand:SI 0 "memory_operand" "")
4315         (fix:SI (match_operand 1 "register_operand" "")))
4316    (use (match_operand:HI 2 "memory_operand" ""))
4317    (use (match_operand:HI 3 "memory_operand" ""))
4318    (clobber (match_operand:SI 4 "memory_operand" ""))]
4319   "reload_completed"
4320   [(parallel [(set (match_dup 0) (fix:SI (match_dup 1)))
4321               (use (match_dup 2))
4322               (use (match_dup 3))])]
4323   "")
4325 ;; Signed conversion to HImode.
4327 (define_expand "fix_truncxfhi2"
4328   [(set (match_operand:HI 0 "nonimmediate_operand" "")
4329         (fix:HI (match_operand:XF 1 "register_operand" "")))]
4330   "!TARGET_64BIT && TARGET_80387"
4331   "")
4333 (define_expand "fix_trunctfhi2"
4334   [(set (match_operand:HI 0 "nonimmediate_operand" "")
4335         (fix:HI (match_operand:TF 1 "register_operand" "")))]
4336   "TARGET_80387"
4337   "")
4339 (define_expand "fix_truncdfhi2"
4340   [(set (match_operand:HI 0 "nonimmediate_operand" "")
4341         (fix:HI (match_operand:DF 1 "register_operand" "")))]
4342   "TARGET_80387 && !TARGET_SSE2"
4343   "")
4345 (define_expand "fix_truncsfhi2"
4346   [(set (match_operand:HI 0 "nonimmediate_operand" "")
4347         (fix:HI (match_operand:SF 1 "register_operand" "")))]
4348   "TARGET_80387 && !TARGET_SSE"
4349   "")
4351 ;; See the comments in i386.h near OPTIMIZE_MODE_SWITCHING for the description
4352 ;; of the machinery.
4353 (define_insn_and_split "*fix_trunchi_1"
4354   [(set (match_operand:HI 0 "nonimmediate_operand" "=m,?r")
4355         (fix:HI (match_operand 1 "register_operand" "f,f")))]
4356   "TARGET_80387 && FLOAT_MODE_P (GET_MODE (operands[1]))
4357    && !reload_completed && !reload_in_progress
4358    && !SSE_FLOAT_MODE_P (GET_MODE (operands[1]))"
4359   "#"
4360   ""
4361   [(const_int 0)]
4363   operands[2] = assign_386_stack_local (HImode, 1);
4364   operands[3] = assign_386_stack_local (HImode, 2);
4365   if (memory_operand (operands[0], VOIDmode))
4366     emit_insn (gen_fix_trunchi_memory (operands[0], operands[1],
4367                                        operands[2], operands[3]));
4368   else
4369     {
4370       operands[4] = assign_386_stack_local (HImode, 0);
4371       emit_insn (gen_fix_trunchi_nomemory (operands[0], operands[1],
4372                                            operands[2], operands[3],
4373                                            operands[4]));
4374     }
4375   DONE;
4377   [(set_attr "type" "fistp")])
4379 (define_insn "fix_trunchi_nomemory"
4380   [(set (match_operand:HI 0 "nonimmediate_operand" "=m,?r")
4381         (fix:HI (match_operand 1 "register_operand" "f,f")))
4382    (use (match_operand:HI 2 "memory_operand" "m,m"))
4383    (use (match_operand:HI 3 "memory_operand" "m,m"))
4384    (clobber (match_operand:HI 4 "memory_operand" "=m,m"))]
4385   "TARGET_80387 && FLOAT_MODE_P (GET_MODE (operands[1]))
4386    && !SSE_FLOAT_MODE_P (GET_MODE (operands[1]))"
4387   "#"
4388   [(set_attr "type" "fistp")])
4390 (define_insn "fix_trunchi_memory"
4391   [(set (match_operand:HI 0 "memory_operand" "=m")
4392         (fix:HI (match_operand 1 "register_operand" "f")))
4393    (use (match_operand:HI 2 "memory_operand" "m"))
4394    (use (match_operand:HI 3 "memory_operand" "m"))]
4395   "TARGET_80387 && FLOAT_MODE_P (GET_MODE (operands[1]))
4396    && !SSE_FLOAT_MODE_P (GET_MODE (operands[1]))"
4397   "* return output_fix_trunc (insn, operands);"
4398   [(set_attr "type" "fistp")])
4400 (define_split 
4401   [(set (match_operand:HI 0 "memory_operand" "")
4402         (fix:HI (match_operand 1 "register_operand" "")))
4403    (use (match_operand:HI 2 "memory_operand" ""))
4404    (use (match_operand:HI 3 "memory_operand" ""))
4405    (clobber (match_operand:HI 4 "memory_operand" ""))]
4406   "reload_completed"
4407   [(parallel [(set (match_dup 0) (fix:HI (match_dup 1)))
4408               (use (match_dup 2))
4409               (use (match_dup 3))])]
4410   "")
4412 (define_split 
4413   [(set (match_operand:HI 0 "register_operand" "")
4414         (fix:HI (match_operand 1 "register_operand" "")))
4415    (use (match_operand:HI 2 "memory_operand" ""))
4416    (use (match_operand:HI 3 "memory_operand" ""))
4417    (clobber (match_operand:HI 4 "memory_operand" ""))]
4418   "reload_completed"
4419   [(parallel [(set (match_dup 4) (fix:HI (match_dup 1)))
4420               (use (match_dup 2))
4421               (use (match_dup 3))
4422               (clobber (match_dup 4))])
4423    (set (match_dup 0) (match_dup 4))]
4424   "")
4426 ;; %% Not used yet.
4427 (define_insn "x86_fnstcw_1"
4428   [(set (match_operand:HI 0 "memory_operand" "=m")
4429         (unspec:HI [(reg:HI 18)] UNSPEC_FSTCW))]
4430   "TARGET_80387"
4431   "fnstcw\t%0"
4432   [(set_attr "length" "2")
4433    (set_attr "mode" "HI")
4434    (set_attr "unit" "i387")
4435    (set_attr "ppro_uops" "few")])
4437 (define_insn "x86_fldcw_1"
4438   [(set (reg:HI 18)
4439         (unspec:HI [(match_operand:HI 0 "memory_operand" "m")] UNSPEC_FLDCW))]
4440   "TARGET_80387"
4441   "fldcw\t%0"
4442   [(set_attr "length" "2")
4443    (set_attr "mode" "HI")
4444    (set_attr "unit" "i387")
4445    (set_attr "athlon_decode" "vector")
4446    (set_attr "ppro_uops" "few")])
4448 ;; Conversion between fixed point and floating point.
4450 ;; Even though we only accept memory inputs, the backend _really_
4451 ;; wants to be able to do this between registers.
4453 (define_insn "floathisf2"
4454   [(set (match_operand:SF 0 "register_operand" "=f,f")
4455         (float:SF (match_operand:HI 1 "nonimmediate_operand" "m,r")))]
4456   "TARGET_80387 && !TARGET_SSE"
4457   "@
4458    fild%z1\t%1
4459    #"
4460   [(set_attr "type" "fmov,multi")
4461    (set_attr "mode" "SF")
4462    (set_attr "fp_int_src" "true")])
4464 (define_expand "floatsisf2"
4465   [(set (match_operand:SF 0 "register_operand" "")
4466         (float:SF (match_operand:SI 1 "nonimmediate_operand" "")))]
4467   "TARGET_SSE || TARGET_80387"
4468   "")
4470 (define_insn "*floatsisf2_i387"
4471   [(set (match_operand:SF 0 "register_operand" "=f,?f,x")
4472         (float:SF (match_operand:SI 1 "nonimmediate_operand" "m,r,mr")))]
4473   "TARGET_80387 && (!TARGET_SSE || TARGET_MIX_SSE_I387)"
4474   "@
4475    fild%z1\t%1
4476    #
4477    cvtsi2ss\t{%1, %0|%0, %1}"
4478   [(set_attr "type" "fmov,multi,ssecvt")
4479    (set_attr "mode" "SF")
4480    (set_attr "fp_int_src" "true")])
4482 (define_insn "*floatsisf2_sse"
4483   [(set (match_operand:SF 0 "register_operand" "=x")
4484         (float:SF (match_operand:SI 1 "nonimmediate_operand" "mr")))]
4485   "TARGET_SSE"
4486   "cvtsi2ss\t{%1, %0|%0, %1}"
4487   [(set_attr "type" "ssecvt")
4488    (set_attr "mode" "SF")
4489    (set_attr "fp_int_src" "true")])
4491 (define_expand "floatdisf2"
4492   [(set (match_operand:SF 0 "register_operand" "")
4493         (float:SF (match_operand:DI 1 "nonimmediate_operand" "")))]
4494   "(TARGET_64BIT && TARGET_SSE) || TARGET_80387"
4495   "")
4497 (define_insn "*floatdisf2_i387_only"
4498   [(set (match_operand:SF 0 "register_operand" "=f,?f")
4499         (float:SF (match_operand:DI 1 "nonimmediate_operand" "m,r")))]
4500   "TARGET_80387 && (!TARGET_SSE || !TARGET_64BIT || TARGET_MIX_SSE_I387)"
4501   "@
4502    fild%z1\t%1
4503    #"
4504   [(set_attr "type" "fmov,multi")
4505    (set_attr "mode" "SF")
4506    (set_attr "fp_int_src" "true")])
4508 (define_insn "*floatdisf2_i387"
4509   [(set (match_operand:SF 0 "register_operand" "=f,?f,x")
4510         (float:SF (match_operand:DI 1 "nonimmediate_operand" "m,r,mr")))]
4511   "TARGET_64BIT && TARGET_80387 && (!TARGET_SSE || TARGET_MIX_SSE_I387)"
4512   "@
4513    fild%z1\t%1
4514    #
4515    cvtsi2ss{q}\t{%1, %0|%0, %1}"
4516   [(set_attr "type" "fmov,multi,ssecvt")
4517    (set_attr "mode" "SF")
4518    (set_attr "fp_int_src" "true")])
4520 (define_insn "*floatdisf2_sse"
4521   [(set (match_operand:SF 0 "register_operand" "=x")
4522         (float:SF (match_operand:DI 1 "nonimmediate_operand" "mr")))]
4523   "TARGET_64BIT && TARGET_SSE"
4524   "cvtsi2ss{q}\t{%1, %0|%0, %1}"
4525   [(set_attr "type" "ssecvt")
4526    (set_attr "mode" "SF")
4527    (set_attr "fp_int_src" "true")])
4529 (define_insn "floathidf2"
4530   [(set (match_operand:DF 0 "register_operand" "=f,f")
4531         (float:DF (match_operand:HI 1 "nonimmediate_operand" "m,r")))]
4532   "TARGET_80387 && !TARGET_SSE2"
4533   "@
4534    fild%z1\t%1
4535    #"
4536   [(set_attr "type" "fmov,multi")
4537    (set_attr "mode" "DF")
4538    (set_attr "fp_int_src" "true")])
4540 (define_expand "floatsidf2"
4541   [(set (match_operand:DF 0 "register_operand" "")
4542         (float:DF (match_operand:SI 1 "nonimmediate_operand" "")))]
4543   "TARGET_80387 || TARGET_SSE2"
4544   "")
4546 (define_insn "*floatsidf2_i387"
4547   [(set (match_operand:DF 0 "register_operand" "=f,?f,Y")
4548         (float:DF (match_operand:SI 1 "nonimmediate_operand" "m,r,mr")))]
4549   "TARGET_80387 && (!TARGET_SSE2 || TARGET_MIX_SSE_I387)"
4550   "@
4551    fild%z1\t%1
4552    #
4553    cvtsi2sd\t{%1, %0|%0, %1}"
4554   [(set_attr "type" "fmov,multi,ssecvt")
4555    (set_attr "mode" "DF")
4556    (set_attr "fp_int_src" "true")])
4558 (define_insn "*floatsidf2_sse"
4559   [(set (match_operand:DF 0 "register_operand" "=Y")
4560         (float:DF (match_operand:SI 1 "nonimmediate_operand" "mr")))]
4561   "TARGET_SSE2"
4562   "cvtsi2sd\t{%1, %0|%0, %1}"
4563   [(set_attr "type" "ssecvt")
4564    (set_attr "mode" "DF")
4565    (set_attr "fp_int_src" "true")])
4567 (define_expand "floatdidf2"
4568   [(set (match_operand:DF 0 "register_operand" "")
4569         (float:DF (match_operand:DI 1 "nonimmediate_operand" "")))]
4570   "(TARGET_64BIT && TARGET_SSE2) || TARGET_80387"
4571   "")
4573 (define_insn "*floatdidf2_i387_only"
4574   [(set (match_operand:DF 0 "register_operand" "=f,?f")
4575         (float:DF (match_operand:DI 1 "nonimmediate_operand" "m,r")))]
4576   "TARGET_80387 && (!TARGET_SSE2 || !TARGET_64BIT)"
4577   "@
4578    fild%z1\t%1
4579    #"
4580   [(set_attr "type" "fmov,multi")
4581    (set_attr "mode" "DF")
4582    (set_attr "fp_int_src" "true")])
4584 (define_insn "*floatdidf2_i387"
4585   [(set (match_operand:DF 0 "register_operand" "=f,?f,Y")
4586         (float:DF (match_operand:DI 1 "nonimmediate_operand" "m,r,mr")))]
4587   "TARGET_64BIT && TARGET_80387 && (!TARGET_SSE2 || TARGET_MIX_SSE_I387)"
4588   "@
4589    fild%z1\t%1
4590    #
4591    cvtsi2sd{q}\t{%1, %0|%0, %1}"
4592   [(set_attr "type" "fmov,multi,ssecvt")
4593    (set_attr "mode" "DF")
4594    (set_attr "fp_int_src" "true")])
4596 (define_insn "*floatdidf2_sse"
4597   [(set (match_operand:DF 0 "register_operand" "=Y")
4598         (float:DF (match_operand:DI 1 "nonimmediate_operand" "mr")))]
4599   "TARGET_SSE2"
4600   "cvtsi2sd{q}\t{%1, %0|%0, %1}"
4601   [(set_attr "type" "ssecvt")
4602    (set_attr "mode" "DF")
4603    (set_attr "fp_int_src" "true")])
4605 (define_insn "floathixf2"
4606   [(set (match_operand:XF 0 "register_operand" "=f,f")
4607         (float:XF (match_operand:HI 1 "nonimmediate_operand" "m,r")))]
4608   "!TARGET_64BIT && TARGET_80387"
4609   "@
4610    fild%z1\t%1
4611    #"
4612   [(set_attr "type" "fmov,multi")
4613    (set_attr "mode" "XF")
4614    (set_attr "fp_int_src" "true")])
4616 (define_insn "floathitf2"
4617   [(set (match_operand:TF 0 "register_operand" "=f,f")
4618         (float:TF (match_operand:HI 1 "nonimmediate_operand" "m,r")))]
4619   "TARGET_80387"
4620   "@
4621    fild%z1\t%1
4622    #"
4623   [(set_attr "type" "fmov,multi")
4624    (set_attr "mode" "XF")
4625    (set_attr "fp_int_src" "true")])
4627 (define_insn "floatsixf2"
4628   [(set (match_operand:XF 0 "register_operand" "=f,f")
4629         (float:XF (match_operand:SI 1 "nonimmediate_operand" "m,r")))]
4630   "!TARGET_64BIT && TARGET_80387"
4631   "@
4632    fild%z1\t%1
4633    #"
4634   [(set_attr "type" "fmov,multi")
4635    (set_attr "mode" "XF")
4636    (set_attr "fp_int_src" "true")])
4638 (define_insn "floatsitf2"
4639   [(set (match_operand:TF 0 "register_operand" "=f,f")
4640         (float:TF (match_operand:SI 1 "nonimmediate_operand" "m,r")))]
4641   "TARGET_80387"
4642   "@
4643    fild%z1\t%1
4644    #"
4645   [(set_attr "type" "fmov,multi")
4646    (set_attr "mode" "XF")
4647    (set_attr "fp_int_src" "true")])
4649 (define_insn "floatdixf2"
4650   [(set (match_operand:XF 0 "register_operand" "=f,f")
4651         (float:XF (match_operand:DI 1 "nonimmediate_operand" "m,r")))]
4652   "!TARGET_64BIT && TARGET_80387"
4653   "@
4654    fild%z1\t%1
4655    #"
4656   [(set_attr "type" "fmov,multi")
4657    (set_attr "mode" "XF")
4658    (set_attr "fp_int_src" "true")])
4660 (define_insn "floatditf2"
4661   [(set (match_operand:TF 0 "register_operand" "=f,f")
4662         (float:TF (match_operand:DI 1 "nonimmediate_operand" "m,r")))]
4663   "TARGET_80387"
4664   "@
4665    fild%z1\t%1
4666    #"
4667   [(set_attr "type" "fmov,multi")
4668    (set_attr "mode" "XF")
4669    (set_attr "fp_int_src" "true")])
4671 ;; %%% Kill these when reload knows how to do it.
4672 (define_split
4673   [(set (match_operand 0 "register_operand" "")
4674         (float (match_operand 1 "register_operand" "")))]
4675   "reload_completed && FLOAT_MODE_P (GET_MODE (operands[0]))
4676    && FP_REG_P (operands[0])"
4677   [(const_int 0)]
4679   operands[2] = ix86_force_to_memory (GET_MODE (operands[1]), operands[1]);
4680   operands[2] = gen_rtx_FLOAT (GET_MODE (operands[0]), operands[2]);
4681   emit_insn (gen_rtx_SET (VOIDmode, operands[0], operands[2]));
4682   ix86_free_from_memory (GET_MODE (operands[1]));
4683   DONE;
4686 ;; Add instructions
4688 ;; %%% splits for addsidi3
4689 ;  [(set (match_operand:DI 0 "nonimmediate_operand" "")
4690 ;       (plus:DI (match_operand:DI 1 "general_operand" "")
4691 ;                (zero_extend:DI (match_operand:SI 2 "general_operand" ""))))]
4693 (define_expand "adddi3"
4694   [(set (match_operand:DI 0 "nonimmediate_operand" "")
4695         (plus:DI (match_operand:DI 1 "nonimmediate_operand" "")
4696                  (match_operand:DI 2 "x86_64_general_operand" "")))
4697    (clobber (reg:CC 17))]
4698   ""
4699   "ix86_expand_binary_operator (PLUS, DImode, operands); DONE;")
4701 (define_insn "*adddi3_1"
4702   [(set (match_operand:DI 0 "nonimmediate_operand" "=r,o")
4703         (plus:DI (match_operand:DI 1 "nonimmediate_operand" "%0,0")
4704                  (match_operand:DI 2 "general_operand" "roiF,riF")))
4705    (clobber (reg:CC 17))]
4706   "!TARGET_64BIT"
4707   "#")
4709 (define_split
4710   [(set (match_operand:DI 0 "nonimmediate_operand" "")
4711         (plus:DI (match_operand:DI 1 "nonimmediate_operand" "")
4712                  (match_operand:DI 2 "general_operand" "")))
4713    (clobber (reg:CC 17))]
4714   "!TARGET_64BIT && reload_completed"
4715   [(parallel [(set (reg:CC 17) (unspec:CC [(match_dup 1) (match_dup 2)]
4716                                           UNSPEC_ADD_CARRY))
4717               (set (match_dup 0) (plus:SI (match_dup 1) (match_dup 2)))])
4718    (parallel [(set (match_dup 3)
4719                    (plus:SI (plus:SI (ltu:SI (reg:CC 17) (const_int 0))
4720                                      (match_dup 4))
4721                             (match_dup 5)))
4722               (clobber (reg:CC 17))])]
4723   "split_di (operands+0, 1, operands+0, operands+3);
4724    split_di (operands+1, 1, operands+1, operands+4);
4725    split_di (operands+2, 1, operands+2, operands+5);")
4727 (define_insn "*adddi3_carry_rex64"
4728   [(set (match_operand:DI 0 "nonimmediate_operand" "=rm,r")
4729           (plus:DI (plus:DI (ltu:DI (reg:CC 17) (const_int 0))
4730                             (match_operand:DI 1 "nonimmediate_operand" "%0,0"))
4731                    (match_operand:DI 2 "x86_64_general_operand" "re,rm")))
4732    (clobber (reg:CC 17))]
4733   "TARGET_64BIT && ix86_binary_operator_ok (PLUS, DImode, operands)"
4734   "adc{q}\t{%2, %0|%0, %2}"
4735   [(set_attr "type" "alu")
4736    (set_attr "pent_pair" "pu")
4737    (set_attr "mode" "DI")
4738    (set_attr "ppro_uops" "few")])
4740 (define_insn "*adddi3_cc_rex64"
4741   [(set (reg:CC 17)
4742         (unspec:CC [(match_operand:DI 1 "nonimmediate_operand" "%0,0")
4743                     (match_operand:DI 2 "x86_64_general_operand" "re,rm")]
4744                    UNSPEC_ADD_CARRY))
4745    (set (match_operand:DI 0 "nonimmediate_operand" "=rm,r")
4746         (plus:DI (match_dup 1) (match_dup 2)))]
4747   "TARGET_64BIT && ix86_binary_operator_ok (PLUS, DImode, operands)"
4748   "add{q}\t{%2, %0|%0, %2}"
4749   [(set_attr "type" "alu")
4750    (set_attr "mode" "DI")])
4752 (define_insn "*addsi3_carry"
4753   [(set (match_operand:SI 0 "nonimmediate_operand" "=rm,r")
4754           (plus:SI (plus:SI (ltu:SI (reg:CC 17) (const_int 0))
4755                             (match_operand:SI 1 "nonimmediate_operand" "%0,0"))
4756                    (match_operand:SI 2 "general_operand" "ri,rm")))
4757    (clobber (reg:CC 17))]
4758   "ix86_binary_operator_ok (PLUS, SImode, operands)"
4759   "adc{l}\t{%2, %0|%0, %2}"
4760   [(set_attr "type" "alu")
4761    (set_attr "pent_pair" "pu")
4762    (set_attr "mode" "SI")
4763    (set_attr "ppro_uops" "few")])
4765 (define_insn "*addsi3_carry_zext"
4766   [(set (match_operand:DI 0 "register_operand" "=r")
4767           (zero_extend:DI 
4768             (plus:SI (plus:SI (ltu:SI (reg:CC 17) (const_int 0))
4769                               (match_operand:SI 1 "nonimmediate_operand" "%0"))
4770                      (match_operand:SI 2 "general_operand" "rim"))))
4771    (clobber (reg:CC 17))]
4772   "TARGET_64BIT && ix86_binary_operator_ok (PLUS, SImode, operands)"
4773   "adc{l}\t{%2, %k0|%k0, %2}"
4774   [(set_attr "type" "alu")
4775    (set_attr "pent_pair" "pu")
4776    (set_attr "mode" "SI")
4777    (set_attr "ppro_uops" "few")])
4779 (define_insn "*addsi3_cc"
4780   [(set (reg:CC 17)
4781         (unspec:CC [(match_operand:SI 1 "nonimmediate_operand" "%0,0")
4782                     (match_operand:SI 2 "general_operand" "ri,rm")]
4783                    UNSPEC_ADD_CARRY))
4784    (set (match_operand:SI 0 "nonimmediate_operand" "=rm,r")
4785         (plus:SI (match_dup 1) (match_dup 2)))]
4786   "ix86_binary_operator_ok (PLUS, SImode, operands)"
4787   "add{l}\t{%2, %0|%0, %2}"
4788   [(set_attr "type" "alu")
4789    (set_attr "mode" "SI")])
4791 (define_insn "addqi3_cc"
4792   [(set (reg:CC 17)
4793         (unspec:CC [(match_operand:QI 1 "nonimmediate_operand" "%0,0")
4794                     (match_operand:QI 2 "general_operand" "qi,qm")]
4795                    UNSPEC_ADD_CARRY))
4796    (set (match_operand:QI 0 "nonimmediate_operand" "=qm,q")
4797         (plus:QI (match_dup 1) (match_dup 2)))]
4798   "ix86_binary_operator_ok (PLUS, QImode, operands)"
4799   "add{b}\t{%2, %0|%0, %2}"
4800   [(set_attr "type" "alu")
4801    (set_attr "mode" "QI")])
4803 (define_expand "addsi3"
4804   [(parallel [(set (match_operand:SI 0 "nonimmediate_operand" "")
4805                    (plus:SI (match_operand:SI 1 "nonimmediate_operand" "")
4806                             (match_operand:SI 2 "general_operand" "")))
4807               (clobber (reg:CC 17))])]
4808   ""
4809   "ix86_expand_binary_operator (PLUS, SImode, operands); DONE;")
4811 (define_insn "*lea_1"
4812   [(set (match_operand:SI 0 "register_operand" "=r")
4813         (match_operand:SI 1 "address_operand" "p"))]
4814   "!TARGET_64BIT"
4815   "lea{l}\t{%a1, %0|%0, %a1}"
4816   [(set_attr "type" "lea")
4817    (set_attr "mode" "SI")])
4819 (define_insn "*lea_1_rex64"
4820   [(set (match_operand:SI 0 "register_operand" "=r")
4821         (subreg:SI (match_operand:DI 1 "address_operand" "p") 0))]
4822   "TARGET_64BIT"
4823   "lea{l}\t{%a1, %0|%0, %a1}"
4824   [(set_attr "type" "lea")
4825    (set_attr "mode" "SI")])
4827 (define_insn "*lea_1_zext"
4828   [(set (match_operand:DI 0 "register_operand" "=r")
4829         (zero_extend:DI (subreg:SI (match_operand:DI 1 "address_operand" "p") 0)))]
4830   "TARGET_64BIT"
4831   "lea{l}\t{%a1, %k0|%k0, %a1}"
4832   [(set_attr "type" "lea")
4833    (set_attr "mode" "SI")])
4835 (define_insn "*lea_2_rex64"
4836   [(set (match_operand:DI 0 "register_operand" "=r")
4837         (match_operand:DI 1 "address_operand" "p"))]
4838   "TARGET_64BIT"
4839   "lea{q}\t{%a1, %0|%0, %a1}"
4840   [(set_attr "type" "lea")
4841    (set_attr "mode" "DI")])
4843 ;; The lea patterns for non-Pmodes needs to be matched by several
4844 ;; insns converted to real lea by splitters.
4846 (define_insn_and_split "*lea_general_1"
4847   [(set (match_operand 0 "register_operand" "=r")
4848         (plus (plus (match_operand 1 "index_register_operand" "r")
4849                     (match_operand 2 "register_operand" "r"))
4850               (match_operand 3 "immediate_operand" "i")))]
4851   "(GET_MODE (operands[0]) == QImode || GET_MODE (operands[0]) == HImode
4852     || (TARGET_64BIT && GET_MODE (operands[0]) == SImode))
4853    && (!TARGET_PARTIAL_REG_STALL || optimize_size)
4854    && GET_MODE (operands[0]) == GET_MODE (operands[1])
4855    && GET_MODE (operands[0]) == GET_MODE (operands[2])
4856    && (GET_MODE (operands[0]) == GET_MODE (operands[3])
4857        || GET_MODE (operands[3]) == VOIDmode)"
4858   "#"
4859   "&& reload_completed"
4860   [(const_int 0)]
4862   rtx pat;
4863   operands[0] = gen_lowpart (SImode, operands[0]);
4864   operands[1] = gen_lowpart (Pmode, operands[1]);
4865   operands[2] = gen_lowpart (Pmode, operands[2]);
4866   operands[3] = gen_lowpart (Pmode, operands[3]);
4867   pat = gen_rtx_PLUS (Pmode, gen_rtx_PLUS (Pmode, operands[1], operands[2]),
4868                       operands[3]);
4869   if (Pmode != SImode)
4870     pat = gen_rtx_SUBREG (SImode, pat, 0);
4871   emit_insn (gen_rtx_SET (VOIDmode, operands[0], pat));
4872   DONE;
4874   [(set_attr "type" "lea")
4875    (set_attr "mode" "SI")])
4877 (define_insn_and_split "*lea_general_1_zext"
4878   [(set (match_operand:DI 0 "register_operand" "=r")
4879         (zero_extend:DI
4880           (plus:SI (plus:SI (match_operand:SI 1 "index_register_operand" "r")
4881                             (match_operand:SI 2 "register_operand" "r"))
4882                    (match_operand:SI 3 "immediate_operand" "i"))))]
4883   "TARGET_64BIT"
4884   "#"
4885   "&& reload_completed"
4886   [(set (match_dup 0)
4887         (zero_extend:DI (subreg:SI (plus:DI (plus:DI (match_dup 1)
4888                                                      (match_dup 2))
4889                                             (match_dup 3)) 0)))]
4891   operands[1] = gen_lowpart (Pmode, operands[1]);
4892   operands[2] = gen_lowpart (Pmode, operands[2]);
4893   operands[3] = gen_lowpart (Pmode, operands[3]);
4895   [(set_attr "type" "lea")
4896    (set_attr "mode" "SI")])
4898 (define_insn_and_split "*lea_general_2"
4899   [(set (match_operand 0 "register_operand" "=r")
4900         (plus (mult (match_operand 1 "index_register_operand" "r")
4901                     (match_operand 2 "const248_operand" "i"))
4902               (match_operand 3 "nonmemory_operand" "ri")))]
4903   "(GET_MODE (operands[0]) == QImode || GET_MODE (operands[0]) == HImode
4904     || (TARGET_64BIT && GET_MODE (operands[0]) == SImode))
4905    && (!TARGET_PARTIAL_REG_STALL || optimize_size)
4906    && GET_MODE (operands[0]) == GET_MODE (operands[1])
4907    && (GET_MODE (operands[0]) == GET_MODE (operands[3])
4908        || GET_MODE (operands[3]) == VOIDmode)"
4909   "#"
4910   "&& reload_completed"
4911   [(const_int 0)]
4913   rtx pat;
4914   operands[0] = gen_lowpart (SImode, operands[0]);
4915   operands[1] = gen_lowpart (Pmode, operands[1]);
4916   operands[3] = gen_lowpart (Pmode, operands[3]);
4917   pat = gen_rtx_PLUS (Pmode, gen_rtx_MULT (Pmode, operands[1], operands[2]),
4918                       operands[3]);
4919   if (Pmode != SImode)
4920     pat = gen_rtx_SUBREG (SImode, pat, 0);
4921   emit_insn (gen_rtx_SET (VOIDmode, operands[0], pat));
4922   DONE;
4924   [(set_attr "type" "lea")
4925    (set_attr "mode" "SI")])
4927 (define_insn_and_split "*lea_general_2_zext"
4928   [(set (match_operand:DI 0 "register_operand" "=r")
4929         (zero_extend:DI
4930           (plus:SI (mult:SI (match_operand:SI 1 "index_register_operand" "r")
4931                             (match_operand:SI 2 "const248_operand" "n"))
4932                    (match_operand:SI 3 "nonmemory_operand" "ri"))))]
4933   "TARGET_64BIT"
4934   "#"
4935   "&& reload_completed"
4936   [(set (match_dup 0)
4937         (zero_extend:DI (subreg:SI (plus:DI (mult:DI (match_dup 1)
4938                                                      (match_dup 2))
4939                                             (match_dup 3)) 0)))]
4941   operands[1] = gen_lowpart (Pmode, operands[1]);
4942   operands[3] = gen_lowpart (Pmode, operands[3]);
4944   [(set_attr "type" "lea")
4945    (set_attr "mode" "SI")])
4947 (define_insn_and_split "*lea_general_3"
4948   [(set (match_operand 0 "register_operand" "=r")
4949         (plus (plus (mult (match_operand 1 "index_register_operand" "r")
4950                           (match_operand 2 "const248_operand" "i"))
4951                     (match_operand 3 "register_operand" "r"))
4952               (match_operand 4 "immediate_operand" "i")))]
4953   "(GET_MODE (operands[0]) == QImode || GET_MODE (operands[0]) == HImode
4954     || (TARGET_64BIT && GET_MODE (operands[0]) == SImode))
4955    && (!TARGET_PARTIAL_REG_STALL || optimize_size)
4956    && GET_MODE (operands[0]) == GET_MODE (operands[1])
4957    && GET_MODE (operands[0]) == GET_MODE (operands[3])"
4958   "#"
4959   "&& reload_completed"
4960   [(const_int 0)]
4962   rtx pat;
4963   operands[0] = gen_lowpart (SImode, operands[0]);
4964   operands[1] = gen_lowpart (Pmode, operands[1]);
4965   operands[3] = gen_lowpart (Pmode, operands[3]);
4966   operands[4] = gen_lowpart (Pmode, operands[4]);
4967   pat = gen_rtx_PLUS (Pmode,
4968                       gen_rtx_PLUS (Pmode, gen_rtx_MULT (Pmode, operands[1],
4969                                                          operands[2]),
4970                                     operands[3]),
4971                       operands[4]);
4972   if (Pmode != SImode)
4973     pat = gen_rtx_SUBREG (SImode, pat, 0);
4974   emit_insn (gen_rtx_SET (VOIDmode, operands[0], pat));
4975   DONE;
4977   [(set_attr "type" "lea")
4978    (set_attr "mode" "SI")])
4980 (define_insn_and_split "*lea_general_3_zext"
4981   [(set (match_operand:DI 0 "register_operand" "=r")
4982         (zero_extend:DI
4983           (plus:SI (plus:SI (mult:SI (match_operand:SI 1 "index_register_operand" "r")
4984                                      (match_operand:SI 2 "const248_operand" "n"))
4985                             (match_operand:SI 3 "register_operand" "r"))
4986                    (match_operand:SI 4 "immediate_operand" "i"))))]
4987   "TARGET_64BIT"
4988   "#"
4989   "&& reload_completed"
4990   [(set (match_dup 0)
4991         (zero_extend:DI (subreg:SI (plus:DI (plus:DI (mult:DI (match_dup 1)
4992                                                               (match_dup 2))
4993                                                      (match_dup 3))
4994                                             (match_dup 4)) 0)))]
4996   operands[1] = gen_lowpart (Pmode, operands[1]);
4997   operands[3] = gen_lowpart (Pmode, operands[3]);
4998   operands[4] = gen_lowpart (Pmode, operands[4]);
5000   [(set_attr "type" "lea")
5001    (set_attr "mode" "SI")])
5003 (define_insn "*adddi_1_rex64"
5004   [(set (match_operand:DI 0 "nonimmediate_operand" "=r,rm,r")
5005         (plus:DI (match_operand:DI 1 "nonimmediate_operand" "%0,0,r")
5006                  (match_operand:DI 2 "x86_64_general_operand" "rme,re,re")))
5007    (clobber (reg:CC 17))]
5008   "TARGET_64BIT && ix86_binary_operator_ok (PLUS, DImode, operands)"
5010   switch (get_attr_type (insn))
5011     {
5012     case TYPE_LEA:
5013       operands[2] = SET_SRC (XVECEXP (PATTERN (insn), 0, 0));
5014       return "lea{q}\t{%a2, %0|%0, %a2}";
5016     case TYPE_INCDEC:
5017       if (! rtx_equal_p (operands[0], operands[1]))
5018         abort ();
5019       if (operands[2] == const1_rtx)
5020         return "inc{q}\t%0";
5021       else if (operands[2] == constm1_rtx)
5022         return "dec{q}\t%0";
5023       else
5024         abort ();
5026     default:
5027       if (! rtx_equal_p (operands[0], operands[1]))
5028         abort ();
5030       /* Make things pretty and `subl $4,%eax' rather than `addl $-4, %eax'.
5031          Exceptions: -128 encodes smaller than 128, so swap sign and op.  */
5032       if (GET_CODE (operands[2]) == CONST_INT
5033           /* Avoid overflows.  */
5034           && ((INTVAL (operands[2]) & ((((unsigned int) 1) << 31) - 1)))
5035           && (INTVAL (operands[2]) == 128
5036               || (INTVAL (operands[2]) < 0
5037                   && INTVAL (operands[2]) != -128)))
5038         {
5039           operands[2] = GEN_INT (-INTVAL (operands[2]));
5040           return "sub{q}\t{%2, %0|%0, %2}";
5041         }
5042       return "add{q}\t{%2, %0|%0, %2}";
5043     }
5045   [(set (attr "type")
5046      (cond [(eq_attr "alternative" "2")
5047               (const_string "lea")
5048             ; Current assemblers are broken and do not allow @GOTOFF in
5049             ; ought but a memory context.
5050             (match_operand:DI 2 "pic_symbolic_operand" "")
5051               (const_string "lea")
5052             (match_operand:DI 2 "incdec_operand" "")
5053               (const_string "incdec")
5054            ]
5055            (const_string "alu")))
5056    (set_attr "mode" "DI")])
5058 ;; Convert lea to the lea pattern to avoid flags dependency.
5059 (define_split
5060   [(set (match_operand:DI 0 "register_operand" "")
5061         (plus:DI (match_operand:DI 1 "register_operand" "")
5062                  (match_operand:DI 2 "x86_64_nonmemory_operand" "")))
5063    (clobber (reg:CC 17))]
5064   "TARGET_64BIT && reload_completed
5065    && true_regnum (operands[0]) != true_regnum (operands[1])"
5066   [(set (match_dup 0)
5067         (plus:DI (match_dup 1)
5068                  (match_dup 2)))]
5069   "")
5071 (define_insn "*adddi_2_rex64"
5072   [(set (reg 17)
5073         (compare
5074           (plus:DI (match_operand:DI 1 "nonimmediate_operand" "%0,0")
5075                    (match_operand:DI 2 "x86_64_general_operand" "rme,re"))
5076           (const_int 0)))                       
5077    (set (match_operand:DI 0 "nonimmediate_operand" "=r,rm")
5078         (plus:DI (match_dup 1) (match_dup 2)))]
5079   "TARGET_64BIT && ix86_match_ccmode (insn, CCGOCmode)
5080    && ix86_binary_operator_ok (PLUS, DImode, operands)
5081    /* Current assemblers are broken and do not allow @GOTOFF in
5082       ought but a memory context.  */
5083    && ! pic_symbolic_operand (operands[2], VOIDmode)"
5085   switch (get_attr_type (insn))
5086     {
5087     case TYPE_INCDEC:
5088       if (! rtx_equal_p (operands[0], operands[1]))
5089         abort ();
5090       if (operands[2] == const1_rtx)
5091         return "inc{q}\t%0";
5092       else if (operands[2] == constm1_rtx)
5093         return "dec{q}\t%0";
5094       else
5095         abort ();
5097     default:
5098       if (! rtx_equal_p (operands[0], operands[1]))
5099         abort ();
5100       /* ???? We ought to handle there the 32bit case too
5101          - do we need new constrant?  */
5102       /* Make things pretty and `subl $4,%eax' rather than `addl $-4, %eax'.
5103          Exceptions: -128 encodes smaller than 128, so swap sign and op.  */
5104       if (GET_CODE (operands[2]) == CONST_INT
5105           /* Avoid overflows.  */
5106           && ((INTVAL (operands[2]) & ((((unsigned int) 1) << 31) - 1)))
5107           && (INTVAL (operands[2]) == 128
5108               || (INTVAL (operands[2]) < 0
5109                   && INTVAL (operands[2]) != -128)))
5110         {
5111           operands[2] = GEN_INT (-INTVAL (operands[2]));
5112           return "sub{q}\t{%2, %0|%0, %2}";
5113         }
5114       return "add{q}\t{%2, %0|%0, %2}";
5115     }
5117   [(set (attr "type")
5118      (if_then_else (match_operand:DI 2 "incdec_operand" "")
5119         (const_string "incdec")
5120         (const_string "alu")))
5121    (set_attr "mode" "DI")])
5123 (define_insn "*adddi_3_rex64"
5124   [(set (reg 17)
5125         (compare (neg:DI (match_operand:DI 2 "x86_64_general_operand" "rme"))
5126                  (match_operand:DI 1 "x86_64_general_operand" "%0")))
5127    (clobber (match_scratch:DI 0 "=r"))]
5128   "TARGET_64BIT
5129    && ix86_match_ccmode (insn, CCZmode)
5130    && (GET_CODE (operands[1]) != MEM || GET_CODE (operands[2]) != MEM)
5131    /* Current assemblers are broken and do not allow @GOTOFF in
5132       ought but a memory context.  */
5133    && ! pic_symbolic_operand (operands[2], VOIDmode)"
5135   switch (get_attr_type (insn))
5136     {
5137     case TYPE_INCDEC:
5138       if (! rtx_equal_p (operands[0], operands[1]))
5139         abort ();
5140       if (operands[2] == const1_rtx)
5141         return "inc{q}\t%0";
5142       else if (operands[2] == constm1_rtx)
5143         return "dec{q}\t%0";
5144       else
5145         abort ();
5147     default:
5148       if (! rtx_equal_p (operands[0], operands[1]))
5149         abort ();
5150       /* ???? We ought to handle there the 32bit case too
5151          - do we need new constrant?  */
5152       /* Make things pretty and `subl $4,%eax' rather than `addl $-4, %eax'.
5153          Exceptions: -128 encodes smaller than 128, so swap sign and op.  */
5154       if (GET_CODE (operands[2]) == CONST_INT
5155           /* Avoid overflows.  */
5156           && ((INTVAL (operands[2]) & ((((unsigned int) 1) << 31) - 1)))
5157           && (INTVAL (operands[2]) == 128
5158               || (INTVAL (operands[2]) < 0
5159                   && INTVAL (operands[2]) != -128)))
5160         {
5161           operands[2] = GEN_INT (-INTVAL (operands[2]));
5162           return "sub{q}\t{%2, %0|%0, %2}";
5163         }
5164       return "add{q}\t{%2, %0|%0, %2}";
5165     }
5167   [(set (attr "type")
5168      (if_then_else (match_operand:DI 2 "incdec_operand" "")
5169         (const_string "incdec")
5170         (const_string "alu")))
5171    (set_attr "mode" "DI")])
5173 ; For comparisons against 1, -1 and 128, we may generate better code
5174 ; by converting cmp to add, inc or dec as done by peephole2.  This pattern
5175 ; is matched then.  We can't accept general immediate, because for
5176 ; case of overflows,  the result is messed up.
5177 ; This pattern also don't hold of 0x8000000000000000, since the value overflows
5178 ; when negated.
5179 ; Also carry flag is reversed compared to cmp, so this conversion is valid
5180 ; only for comparisons not depending on it.
5181 (define_insn "*adddi_4_rex64"
5182   [(set (reg 17)
5183         (compare (match_operand:DI 1 "nonimmediate_operand" "0")
5184                  (match_operand:DI 2 "x86_64_immediate_operand" "e")))
5185    (clobber (match_scratch:DI 0 "=rm"))]
5186   "TARGET_64BIT
5187    &&  ix86_match_ccmode (insn, CCGCmode)"
5189   switch (get_attr_type (insn))
5190     {
5191     case TYPE_INCDEC:
5192       if (operands[2] == constm1_rtx)
5193         return "inc{q}\t%0";
5194       else if (operands[2] == const1_rtx)
5195         return "dec{q}\t%0";
5196       else
5197         abort();
5199     default:
5200       if (! rtx_equal_p (operands[0], operands[1]))
5201         abort ();
5202       /* Make things pretty and `subl $4,%eax' rather than `addl $-4, %eax'.
5203          Exceptions: -128 encodes smaller than 128, so swap sign and op.  */
5204       if ((INTVAL (operands[2]) == -128
5205            || (INTVAL (operands[2]) > 0
5206                && INTVAL (operands[2]) != 128))
5207           /* Avoid overflows.  */
5208           && ((INTVAL (operands[2]) & ((((unsigned int) 1) << 31) - 1))))
5209         return "sub{q}\t{%2, %0|%0, %2}";
5210       operands[2] = GEN_INT (-INTVAL (operands[2]));
5211       return "add{q}\t{%2, %0|%0, %2}";
5212     }
5214   [(set (attr "type")
5215      (if_then_else (match_operand:DI 2 "incdec_operand" "")
5216         (const_string "incdec")
5217         (const_string "alu")))
5218    (set_attr "mode" "DI")])
5220 (define_insn "*adddi_5_rex64"
5221   [(set (reg 17)
5222         (compare
5223           (plus:DI (match_operand:DI 1 "nonimmediate_operand" "%0")
5224                    (match_operand:DI 2 "x86_64_general_operand" "rme"))
5225           (const_int 0)))                       
5226    (clobber (match_scratch:DI 0 "=r"))]
5227   "TARGET_64BIT
5228    && ix86_match_ccmode (insn, CCGOCmode)
5229    && (GET_CODE (operands[1]) != MEM || GET_CODE (operands[2]) != MEM)
5230    /* Current assemblers are broken and do not allow @GOTOFF in
5231       ought but a memory context.  */
5232    && ! pic_symbolic_operand (operands[2], VOIDmode)"
5234   switch (get_attr_type (insn))
5235     {
5236     case TYPE_INCDEC:
5237       if (! rtx_equal_p (operands[0], operands[1]))
5238         abort ();
5239       if (operands[2] == const1_rtx)
5240         return "inc{q}\t%0";
5241       else if (operands[2] == constm1_rtx)
5242         return "dec{q}\t%0";
5243       else
5244         abort();
5246     default:
5247       if (! rtx_equal_p (operands[0], operands[1]))
5248         abort ();
5249       /* Make things pretty and `subl $4,%eax' rather than `addl $-4, %eax'.
5250          Exceptions: -128 encodes smaller than 128, so swap sign and op.  */
5251       if (GET_CODE (operands[2]) == CONST_INT
5252           /* Avoid overflows.  */
5253           && ((INTVAL (operands[2]) & ((((unsigned int) 1) << 31) - 1)))
5254           && (INTVAL (operands[2]) == 128
5255               || (INTVAL (operands[2]) < 0
5256                   && INTVAL (operands[2]) != -128)))
5257         {
5258           operands[2] = GEN_INT (-INTVAL (operands[2]));
5259           return "sub{q}\t{%2, %0|%0, %2}";
5260         }
5261       return "add{q}\t{%2, %0|%0, %2}";
5262     }
5264   [(set (attr "type")
5265      (if_then_else (match_operand:DI 2 "incdec_operand" "")
5266         (const_string "incdec")
5267         (const_string "alu")))
5268    (set_attr "mode" "DI")])
5271 (define_insn "*addsi_1"
5272   [(set (match_operand:SI 0 "nonimmediate_operand" "=r,rm,r")
5273         (plus:SI (match_operand:SI 1 "nonimmediate_operand" "%0,0,r")
5274                  (match_operand:SI 2 "general_operand" "rmni,rni,rni")))
5275    (clobber (reg:CC 17))]
5276   "ix86_binary_operator_ok (PLUS, SImode, operands)"
5278   switch (get_attr_type (insn))
5279     {
5280     case TYPE_LEA:
5281       operands[2] = SET_SRC (XVECEXP (PATTERN (insn), 0, 0));
5282       return "lea{l}\t{%a2, %0|%0, %a2}";
5284     case TYPE_INCDEC:
5285       if (! rtx_equal_p (operands[0], operands[1]))
5286         abort ();
5287       if (operands[2] == const1_rtx)
5288         return "inc{l}\t%0";
5289       else if (operands[2] == constm1_rtx)
5290         return "dec{l}\t%0";
5291       else
5292         abort();
5294     default:
5295       if (! rtx_equal_p (operands[0], operands[1]))
5296         abort ();
5298       /* Make things pretty and `subl $4,%eax' rather than `addl $-4, %eax'.
5299          Exceptions: -128 encodes smaller than 128, so swap sign and op.  */
5300       if (GET_CODE (operands[2]) == CONST_INT
5301           && (INTVAL (operands[2]) == 128
5302               || (INTVAL (operands[2]) < 0
5303                   && INTVAL (operands[2]) != -128)))
5304         {
5305           operands[2] = GEN_INT (-INTVAL (operands[2]));
5306           return "sub{l}\t{%2, %0|%0, %2}";
5307         }
5308       return "add{l}\t{%2, %0|%0, %2}";
5309     }
5311   [(set (attr "type")
5312      (cond [(eq_attr "alternative" "2")
5313               (const_string "lea")
5314             ; Current assemblers are broken and do not allow @GOTOFF in
5315             ; ought but a memory context.
5316             (match_operand:SI 2 "pic_symbolic_operand" "")
5317               (const_string "lea")
5318             (match_operand:SI 2 "incdec_operand" "")
5319               (const_string "incdec")
5320            ]
5321            (const_string "alu")))
5322    (set_attr "mode" "SI")])
5324 ;; Convert lea to the lea pattern to avoid flags dependency.
5325 (define_split
5326   [(set (match_operand 0 "register_operand" "")
5327         (plus (match_operand 1 "register_operand" "")
5328               (match_operand 2 "nonmemory_operand" "")))
5329    (clobber (reg:CC 17))]
5330   "reload_completed
5331    && true_regnum (operands[0]) != true_regnum (operands[1])"
5332   [(const_int 0)]
5334   rtx pat;
5335   /* In -fPIC mode the constructs like (const (unspec [symbol_ref]))
5336      may confuse gen_lowpart.  */
5337   if (GET_MODE (operands[0]) != Pmode)
5338     {
5339       operands[1] = gen_lowpart (Pmode, operands[1]);
5340       operands[2] = gen_lowpart (Pmode, operands[2]);
5341     }
5342   operands[0] = gen_lowpart (SImode, operands[0]);
5343   pat = gen_rtx_PLUS (Pmode, operands[1], operands[2]);
5344   if (Pmode != SImode)
5345     pat = gen_rtx_SUBREG (SImode, pat, 0);
5346   emit_insn (gen_rtx_SET (VOIDmode, operands[0], pat));
5347   DONE;
5350 ;; It may seem that nonimmediate operand is proper one for operand 1.
5351 ;; The addsi_1 pattern allows nonimmediate operand at that place and
5352 ;; we take care in ix86_binary_operator_ok to not allow two memory
5353 ;; operands so proper swapping will be done in reload.  This allow
5354 ;; patterns constructed from addsi_1 to match.
5355 (define_insn "addsi_1_zext"
5356   [(set (match_operand:DI 0 "register_operand" "=r,r")
5357         (zero_extend:DI
5358           (plus:SI (match_operand:SI 1 "nonimmediate_operand" "%0,r")
5359                    (match_operand:SI 2 "general_operand" "rmni,rni"))))
5360    (clobber (reg:CC 17))]
5361   "TARGET_64BIT && ix86_binary_operator_ok (PLUS, SImode, operands)"
5363   switch (get_attr_type (insn))
5364     {
5365     case TYPE_LEA:
5366       operands[2] = SET_SRC (XVECEXP (PATTERN (insn), 0, 0));
5367       return "lea{l}\t{%a2, %k0|%k0, %a2}";
5369     case TYPE_INCDEC:
5370       if (operands[2] == const1_rtx)
5371         return "inc{l}\t%k0";
5372       else if (operands[2] == constm1_rtx)
5373         return "dec{l}\t%k0";
5374       else
5375         abort();
5377     default:
5378       /* Make things pretty and `subl $4,%eax' rather than `addl $-4, %eax'.
5379          Exceptions: -128 encodes smaller than 128, so swap sign and op.  */
5380       if (GET_CODE (operands[2]) == CONST_INT
5381           && (INTVAL (operands[2]) == 128
5382               || (INTVAL (operands[2]) < 0
5383                   && INTVAL (operands[2]) != -128)))
5384         {
5385           operands[2] = GEN_INT (-INTVAL (operands[2]));
5386           return "sub{l}\t{%2, %k0|%k0, %2}";
5387         }
5388       return "add{l}\t{%2, %k0|%k0, %2}";
5389     }
5391   [(set (attr "type")
5392      (cond [(eq_attr "alternative" "1")
5393               (const_string "lea")
5394             ; Current assemblers are broken and do not allow @GOTOFF in
5395             ; ought but a memory context.
5396             (match_operand:SI 2 "pic_symbolic_operand" "")
5397               (const_string "lea")
5398             (match_operand:SI 2 "incdec_operand" "")
5399               (const_string "incdec")
5400            ]
5401            (const_string "alu")))
5402    (set_attr "mode" "SI")])
5404 ;; Convert lea to the lea pattern to avoid flags dependency.
5405 (define_split
5406   [(set (match_operand:DI 0 "register_operand" "")
5407         (zero_extend:DI
5408           (plus:SI (match_operand:SI 1 "register_operand" "")
5409                    (match_operand:SI 2 "nonmemory_operand" ""))))
5410    (clobber (reg:CC 17))]
5411   "reload_completed
5412    && true_regnum (operands[0]) != true_regnum (operands[1])"
5413   [(set (match_dup 0)
5414         (zero_extend:DI (subreg:SI (plus:DI (match_dup 1) (match_dup 2)) 0)))]
5416   operands[1] = gen_lowpart (Pmode, operands[1]);
5417   operands[2] = gen_lowpart (Pmode, operands[2]);
5420 (define_insn "*addsi_2"
5421   [(set (reg 17)
5422         (compare
5423           (plus:SI (match_operand:SI 1 "nonimmediate_operand" "%0,0")
5424                    (match_operand:SI 2 "general_operand" "rmni,rni"))
5425           (const_int 0)))                       
5426    (set (match_operand:SI 0 "nonimmediate_operand" "=r,rm")
5427         (plus:SI (match_dup 1) (match_dup 2)))]
5428   "ix86_match_ccmode (insn, CCGOCmode)
5429    && ix86_binary_operator_ok (PLUS, SImode, operands)
5430    /* Current assemblers are broken and do not allow @GOTOFF in
5431       ought but a memory context.  */
5432    && ! pic_symbolic_operand (operands[2], VOIDmode)"
5434   switch (get_attr_type (insn))
5435     {
5436     case TYPE_INCDEC:
5437       if (! rtx_equal_p (operands[0], operands[1]))
5438         abort ();
5439       if (operands[2] == const1_rtx)
5440         return "inc{l}\t%0";
5441       else if (operands[2] == constm1_rtx)
5442         return "dec{l}\t%0";
5443       else
5444         abort();
5446     default:
5447       if (! rtx_equal_p (operands[0], operands[1]))
5448         abort ();
5449       /* Make things pretty and `subl $4,%eax' rather than `addl $-4, %eax'.
5450          Exceptions: -128 encodes smaller than 128, so swap sign and op.  */
5451       if (GET_CODE (operands[2]) == CONST_INT
5452           && (INTVAL (operands[2]) == 128
5453               || (INTVAL (operands[2]) < 0
5454                   && INTVAL (operands[2]) != -128)))
5455         {
5456           operands[2] = GEN_INT (-INTVAL (operands[2]));
5457           return "sub{l}\t{%2, %0|%0, %2}";
5458         }
5459       return "add{l}\t{%2, %0|%0, %2}";
5460     }
5462   [(set (attr "type")
5463      (if_then_else (match_operand:SI 2 "incdec_operand" "")
5464         (const_string "incdec")
5465         (const_string "alu")))
5466    (set_attr "mode" "SI")])
5468 ;; See comment for addsi_1_zext why we do use nonimmediate_operand
5469 (define_insn "*addsi_2_zext"
5470   [(set (reg 17)
5471         (compare
5472           (plus:SI (match_operand:SI 1 "nonimmediate_operand" "%0")
5473                    (match_operand:SI 2 "general_operand" "rmni"))
5474           (const_int 0)))                       
5475    (set (match_operand:DI 0 "register_operand" "=r")
5476         (zero_extend:DI (plus:SI (match_dup 1) (match_dup 2))))]
5477   "TARGET_64BIT && ix86_match_ccmode (insn, CCGOCmode)
5478    && ix86_binary_operator_ok (PLUS, SImode, operands)
5479    /* Current assemblers are broken and do not allow @GOTOFF in
5480       ought but a memory context.  */
5481    && ! pic_symbolic_operand (operands[2], VOIDmode)"
5483   switch (get_attr_type (insn))
5484     {
5485     case TYPE_INCDEC:
5486       if (operands[2] == const1_rtx)
5487         return "inc{l}\t%k0";
5488       else if (operands[2] == constm1_rtx)
5489         return "dec{l}\t%k0";
5490       else
5491         abort();
5493     default:
5494       /* Make things pretty and `subl $4,%eax' rather than `addl $-4, %eax'.
5495          Exceptions: -128 encodes smaller than 128, so swap sign and op.  */
5496       if (GET_CODE (operands[2]) == CONST_INT
5497           && (INTVAL (operands[2]) == 128
5498               || (INTVAL (operands[2]) < 0
5499                   && INTVAL (operands[2]) != -128)))
5500         {
5501           operands[2] = GEN_INT (-INTVAL (operands[2]));
5502           return "sub{l}\t{%2, %k0|%k0, %2}";
5503         }
5504       return "add{l}\t{%2, %k0|%k0, %2}";
5505     }
5507   [(set (attr "type")
5508      (if_then_else (match_operand:SI 2 "incdec_operand" "")
5509         (const_string "incdec")
5510         (const_string "alu")))
5511    (set_attr "mode" "SI")])
5513 (define_insn "*addsi_3"
5514   [(set (reg 17)
5515         (compare (neg:SI (match_operand:SI 2 "general_operand" "rmni"))
5516                  (match_operand:SI 1 "nonimmediate_operand" "%0")))
5517    (clobber (match_scratch:SI 0 "=r"))]
5518   "ix86_match_ccmode (insn, CCZmode)
5519    && (GET_CODE (operands[1]) != MEM || GET_CODE (operands[2]) != MEM)
5520    /* Current assemblers are broken and do not allow @GOTOFF in
5521       ought but a memory context.  */
5522    && ! pic_symbolic_operand (operands[2], VOIDmode)"
5524   switch (get_attr_type (insn))
5525     {
5526     case TYPE_INCDEC:
5527       if (! rtx_equal_p (operands[0], operands[1]))
5528         abort ();
5529       if (operands[2] == const1_rtx)
5530         return "inc{l}\t%0";
5531       else if (operands[2] == constm1_rtx)
5532         return "dec{l}\t%0";
5533       else
5534         abort();
5536     default:
5537       if (! rtx_equal_p (operands[0], operands[1]))
5538         abort ();
5539       /* Make things pretty and `subl $4,%eax' rather than `addl $-4, %eax'.
5540          Exceptions: -128 encodes smaller than 128, so swap sign and op.  */
5541       if (GET_CODE (operands[2]) == CONST_INT
5542           && (INTVAL (operands[2]) == 128
5543               || (INTVAL (operands[2]) < 0
5544                   && INTVAL (operands[2]) != -128)))
5545         {
5546           operands[2] = GEN_INT (-INTVAL (operands[2]));
5547           return "sub{l}\t{%2, %0|%0, %2}";
5548         }
5549       return "add{l}\t{%2, %0|%0, %2}";
5550     }
5552   [(set (attr "type")
5553      (if_then_else (match_operand:SI 2 "incdec_operand" "")
5554         (const_string "incdec")
5555         (const_string "alu")))
5556    (set_attr "mode" "SI")])
5558 ;; See comment for addsi_1_zext why we do use nonimmediate_operand
5559 (define_insn "*addsi_3_zext"
5560   [(set (reg 17)
5561         (compare (neg:SI (match_operand:SI 2 "general_operand" "rmni"))
5562                  (match_operand:SI 1 "nonimmediate_operand" "%0")))
5563    (set (match_operand:DI 0 "register_operand" "=r")
5564         (zero_extend:DI (plus:SI (match_dup 1) (match_dup 2))))]
5565   "TARGET_64BIT && ix86_match_ccmode (insn, CCZmode)
5566    && ix86_binary_operator_ok (PLUS, SImode, operands)
5567    /* Current assemblers are broken and do not allow @GOTOFF in
5568       ought but a memory context.  */
5569    && ! pic_symbolic_operand (operands[2], VOIDmode)"
5571   switch (get_attr_type (insn))
5572     {
5573     case TYPE_INCDEC:
5574       if (operands[2] == const1_rtx)
5575         return "inc{l}\t%k0";
5576       else if (operands[2] == constm1_rtx)
5577         return "dec{l}\t%k0";
5578       else
5579         abort();
5581     default:
5582       /* Make things pretty and `subl $4,%eax' rather than `addl $-4, %eax'.
5583          Exceptions: -128 encodes smaller than 128, so swap sign and op.  */
5584       if (GET_CODE (operands[2]) == CONST_INT
5585           && (INTVAL (operands[2]) == 128
5586               || (INTVAL (operands[2]) < 0
5587                   && INTVAL (operands[2]) != -128)))
5588         {
5589           operands[2] = GEN_INT (-INTVAL (operands[2]));
5590           return "sub{l}\t{%2, %k0|%k0, %2}";
5591         }
5592       return "add{l}\t{%2, %k0|%k0, %2}";
5593     }
5595   [(set (attr "type")
5596      (if_then_else (match_operand:SI 2 "incdec_operand" "")
5597         (const_string "incdec")
5598         (const_string "alu")))
5599    (set_attr "mode" "SI")])
5601 ; For comparisons agains 1, -1 and 128, we may generate better code
5602 ; by converting cmp to add, inc or dec as done by peephole2.  This pattern
5603 ; is matched then.  We can't accept general immediate, because for
5604 ; case of overflows,  the result is messed up.
5605 ; This pattern also don't hold of 0x80000000, since the value overflows
5606 ; when negated.
5607 ; Also carry flag is reversed compared to cmp, so this conversion is valid
5608 ; only for comparisons not depending on it.
5609 (define_insn "*addsi_4"
5610   [(set (reg 17)
5611         (compare (match_operand:SI 1 "nonimmediate_operand" "0")
5612                  (match_operand:SI 2 "const_int_operand" "n")))
5613    (clobber (match_scratch:SI 0 "=rm"))]
5614   "ix86_match_ccmode (insn, CCGCmode)
5615    && (INTVAL (operands[2]) & 0xffffffff) != 0x80000000"
5617   switch (get_attr_type (insn))
5618     {
5619     case TYPE_INCDEC:
5620       if (operands[2] == constm1_rtx)
5621         return "inc{l}\t%0";
5622       else if (operands[2] == const1_rtx)
5623         return "dec{l}\t%0";
5624       else
5625         abort();
5627     default:
5628       if (! rtx_equal_p (operands[0], operands[1]))
5629         abort ();
5630       /* Make things pretty and `subl $4,%eax' rather than `addl $-4, %eax'.
5631          Exceptions: -128 encodes smaller than 128, so swap sign and op.  */
5632       if ((INTVAL (operands[2]) == -128
5633            || (INTVAL (operands[2]) > 0
5634                && INTVAL (operands[2]) != 128)))
5635         return "sub{l}\t{%2, %0|%0, %2}";
5636       operands[2] = GEN_INT (-INTVAL (operands[2]));
5637       return "add{l}\t{%2, %0|%0, %2}";
5638     }
5640   [(set (attr "type")
5641      (if_then_else (match_operand:SI 2 "incdec_operand" "")
5642         (const_string "incdec")
5643         (const_string "alu")))
5644    (set_attr "mode" "SI")])
5646 (define_insn "*addsi_5"
5647   [(set (reg 17)
5648         (compare
5649           (plus:SI (match_operand:SI 1 "nonimmediate_operand" "%0")
5650                    (match_operand:SI 2 "general_operand" "rmni"))
5651           (const_int 0)))                       
5652    (clobber (match_scratch:SI 0 "=r"))]
5653   "ix86_match_ccmode (insn, CCGOCmode)
5654    && (GET_CODE (operands[1]) != MEM || GET_CODE (operands[2]) != MEM)
5655    /* Current assemblers are broken and do not allow @GOTOFF in
5656       ought but a memory context.  */
5657    && ! pic_symbolic_operand (operands[2], VOIDmode)"
5659   switch (get_attr_type (insn))
5660     {
5661     case TYPE_INCDEC:
5662       if (! rtx_equal_p (operands[0], operands[1]))
5663         abort ();
5664       if (operands[2] == const1_rtx)
5665         return "inc{l}\t%0";
5666       else if (operands[2] == constm1_rtx)
5667         return "dec{l}\t%0";
5668       else
5669         abort();
5671     default:
5672       if (! rtx_equal_p (operands[0], operands[1]))
5673         abort ();
5674       /* Make things pretty and `subl $4,%eax' rather than `addl $-4, %eax'.
5675          Exceptions: -128 encodes smaller than 128, so swap sign and op.  */
5676       if (GET_CODE (operands[2]) == CONST_INT
5677           && (INTVAL (operands[2]) == 128
5678               || (INTVAL (operands[2]) < 0
5679                   && INTVAL (operands[2]) != -128)))
5680         {
5681           operands[2] = GEN_INT (-INTVAL (operands[2]));
5682           return "sub{l}\t{%2, %0|%0, %2}";
5683         }
5684       return "add{l}\t{%2, %0|%0, %2}";
5685     }
5687   [(set (attr "type")
5688      (if_then_else (match_operand:SI 2 "incdec_operand" "")
5689         (const_string "incdec")
5690         (const_string "alu")))
5691    (set_attr "mode" "SI")])
5693 (define_expand "addhi3"
5694   [(parallel [(set (match_operand:HI 0 "nonimmediate_operand" "")
5695                    (plus:HI (match_operand:HI 1 "nonimmediate_operand" "")
5696                             (match_operand:HI 2 "general_operand" "")))
5697               (clobber (reg:CC 17))])]
5698   "TARGET_HIMODE_MATH"
5699   "ix86_expand_binary_operator (PLUS, HImode, operands); DONE;")
5701 ;; %%% After Dave's SUBREG_BYTE stuff goes in, re-enable incb %ah
5702 ;; type optimizations enabled by define-splits.  This is not important
5703 ;; for PII, and in fact harmful because of partial register stalls.
5705 (define_insn "*addhi_1_lea"
5706   [(set (match_operand:HI 0 "nonimmediate_operand" "=rm,r,r")
5707         (plus:HI (match_operand:HI 1 "nonimmediate_operand" "%0,0,r")
5708                  (match_operand:HI 2 "general_operand" "ri,rm,rni")))
5709    (clobber (reg:CC 17))]
5710   "!TARGET_PARTIAL_REG_STALL
5711    && ix86_binary_operator_ok (PLUS, HImode, operands)"
5713   switch (get_attr_type (insn))
5714     {
5715     case TYPE_LEA:
5716       return "#";
5717     case TYPE_INCDEC:
5718       if (operands[2] == const1_rtx)
5719         return "inc{w}\t%0";
5720       else if (operands[2] == constm1_rtx)
5721         return "dec{w}\t%0";
5722       abort();
5724     default:
5725       /* Make things pretty and `subl $4,%eax' rather than `addl $-4, %eax'.
5726          Exceptions: -128 encodes smaller than 128, so swap sign and op.  */
5727       if (GET_CODE (operands[2]) == CONST_INT
5728           && (INTVAL (operands[2]) == 128
5729               || (INTVAL (operands[2]) < 0
5730                   && INTVAL (operands[2]) != -128)))
5731         {
5732           operands[2] = GEN_INT (-INTVAL (operands[2]));
5733           return "sub{w}\t{%2, %0|%0, %2}";
5734         }
5735       return "add{w}\t{%2, %0|%0, %2}";
5736     }
5738   [(set (attr "type")
5739      (if_then_else (eq_attr "alternative" "2")
5740         (const_string "lea")
5741         (if_then_else (match_operand:HI 2 "incdec_operand" "")
5742            (const_string "incdec")
5743            (const_string "alu"))))
5744    (set_attr "mode" "HI,HI,SI")])
5746 (define_insn "*addhi_1"
5747   [(set (match_operand:HI 0 "nonimmediate_operand" "=rm,r")
5748         (plus:HI (match_operand:HI 1 "nonimmediate_operand" "%0,0")
5749                  (match_operand:HI 2 "general_operand" "ri,rm")))
5750    (clobber (reg:CC 17))]
5751   "TARGET_PARTIAL_REG_STALL
5752    && ix86_binary_operator_ok (PLUS, HImode, operands)"
5754   switch (get_attr_type (insn))
5755     {
5756     case TYPE_INCDEC:
5757       if (operands[2] == const1_rtx)
5758         return "inc{w}\t%0";
5759       else if (operands[2] == constm1_rtx)
5760         return "dec{w}\t%0";
5761       abort();
5763     default:
5764       /* Make things pretty and `subl $4,%eax' rather than `addl $-4, %eax'.
5765          Exceptions: -128 encodes smaller than 128, so swap sign and op.  */
5766       if (GET_CODE (operands[2]) == CONST_INT
5767           && (INTVAL (operands[2]) == 128
5768               || (INTVAL (operands[2]) < 0
5769                   && INTVAL (operands[2]) != -128)))
5770         {
5771           operands[2] = GEN_INT (-INTVAL (operands[2]));
5772           return "sub{w}\t{%2, %0|%0, %2}";
5773         }
5774       return "add{w}\t{%2, %0|%0, %2}";
5775     }
5777   [(set (attr "type")
5778      (if_then_else (match_operand:HI 2 "incdec_operand" "")
5779         (const_string "incdec")
5780         (const_string "alu")))
5781    (set_attr "mode" "HI")])
5783 (define_insn "*addhi_2"
5784   [(set (reg 17)
5785         (compare
5786           (plus:HI (match_operand:HI 1 "nonimmediate_operand" "%0,0")
5787                    (match_operand:HI 2 "general_operand" "rmni,rni"))
5788           (const_int 0)))                       
5789    (set (match_operand:HI 0 "nonimmediate_operand" "=r,rm")
5790         (plus:HI (match_dup 1) (match_dup 2)))]
5791   "ix86_match_ccmode (insn, CCGOCmode)
5792    && ix86_binary_operator_ok (PLUS, HImode, operands)"
5794   switch (get_attr_type (insn))
5795     {
5796     case TYPE_INCDEC:
5797       if (operands[2] == const1_rtx)
5798         return "inc{w}\t%0";
5799       else if (operands[2] == constm1_rtx)
5800         return "dec{w}\t%0";
5801       abort();
5803     default:
5804       /* Make things pretty and `subl $4,%eax' rather than `addl $-4, %eax'.
5805          Exceptions: -128 encodes smaller than 128, so swap sign and op.  */
5806       if (GET_CODE (operands[2]) == CONST_INT
5807           && (INTVAL (operands[2]) == 128
5808               || (INTVAL (operands[2]) < 0
5809                   && INTVAL (operands[2]) != -128)))
5810         {
5811           operands[2] = GEN_INT (-INTVAL (operands[2]));
5812           return "sub{w}\t{%2, %0|%0, %2}";
5813         }
5814       return "add{w}\t{%2, %0|%0, %2}";
5815     }
5817   [(set (attr "type")
5818      (if_then_else (match_operand:HI 2 "incdec_operand" "")
5819         (const_string "incdec")
5820         (const_string "alu")))
5821    (set_attr "mode" "HI")])
5823 (define_insn "*addhi_3"
5824   [(set (reg 17)
5825         (compare (neg:HI (match_operand:HI 2 "general_operand" "rmni"))
5826                  (match_operand:HI 1 "nonimmediate_operand" "%0")))
5827    (clobber (match_scratch:HI 0 "=r"))]
5828   "ix86_match_ccmode (insn, CCZmode)
5829    && (GET_CODE (operands[1]) != MEM || GET_CODE (operands[2]) != MEM)"
5831   switch (get_attr_type (insn))
5832     {
5833     case TYPE_INCDEC:
5834       if (operands[2] == const1_rtx)
5835         return "inc{w}\t%0";
5836       else if (operands[2] == constm1_rtx)
5837         return "dec{w}\t%0";
5838       abort();
5840     default:
5841       /* Make things pretty and `subl $4,%eax' rather than `addl $-4, %eax'.
5842          Exceptions: -128 encodes smaller than 128, so swap sign and op.  */
5843       if (GET_CODE (operands[2]) == CONST_INT
5844           && (INTVAL (operands[2]) == 128
5845               || (INTVAL (operands[2]) < 0
5846                   && INTVAL (operands[2]) != -128)))
5847         {
5848           operands[2] = GEN_INT (-INTVAL (operands[2]));
5849           return "sub{w}\t{%2, %0|%0, %2}";
5850         }
5851       return "add{w}\t{%2, %0|%0, %2}";
5852     }
5854   [(set (attr "type")
5855      (if_then_else (match_operand:HI 2 "incdec_operand" "")
5856         (const_string "incdec")
5857         (const_string "alu")))
5858    (set_attr "mode" "HI")])
5860 ; See comments above addsi_3_imm for details.
5861 (define_insn "*addhi_4"
5862   [(set (reg 17)
5863         (compare (match_operand:HI 1 "nonimmediate_operand" "0")
5864                  (match_operand:HI 2 "const_int_operand" "n")))
5865    (clobber (match_scratch:HI 0 "=rm"))]
5866   "ix86_match_ccmode (insn, CCGCmode)
5867    && (INTVAL (operands[2]) & 0xffff) != 0x8000"
5869   switch (get_attr_type (insn))
5870     {
5871     case TYPE_INCDEC:
5872       if (operands[2] == constm1_rtx)
5873         return "inc{w}\t%0";
5874       else if (operands[2] == const1_rtx)
5875         return "dec{w}\t%0";
5876       else
5877         abort();
5879     default:
5880       if (! rtx_equal_p (operands[0], operands[1]))
5881         abort ();
5882       /* Make things pretty and `subl $4,%eax' rather than `addl $-4, %eax'.
5883          Exceptions: -128 encodes smaller than 128, so swap sign and op.  */
5884       if ((INTVAL (operands[2]) == -128
5885            || (INTVAL (operands[2]) > 0
5886                && INTVAL (operands[2]) != 128)))
5887         return "sub{w}\t{%2, %0|%0, %2}";
5888       operands[2] = GEN_INT (-INTVAL (operands[2]));
5889       return "add{w}\t{%2, %0|%0, %2}";
5890     }
5892   [(set (attr "type")
5893      (if_then_else (match_operand:HI 2 "incdec_operand" "")
5894         (const_string "incdec")
5895         (const_string "alu")))
5896    (set_attr "mode" "SI")])
5899 (define_insn "*addhi_5"
5900   [(set (reg 17)
5901         (compare
5902           (plus:HI (match_operand:HI 1 "nonimmediate_operand" "%0")
5903                    (match_operand:HI 2 "general_operand" "rmni"))
5904           (const_int 0)))                       
5905    (clobber (match_scratch:HI 0 "=r"))]
5906   "ix86_match_ccmode (insn, CCGOCmode)
5907    && (GET_CODE (operands[1]) != MEM || GET_CODE (operands[2]) != MEM)"
5909   switch (get_attr_type (insn))
5910     {
5911     case TYPE_INCDEC:
5912       if (operands[2] == const1_rtx)
5913         return "inc{w}\t%0";
5914       else if (operands[2] == constm1_rtx)
5915         return "dec{w}\t%0";
5916       abort();
5918     default:
5919       /* Make things pretty and `subl $4,%eax' rather than `addl $-4, %eax'.
5920          Exceptions: -128 encodes smaller than 128, so swap sign and op.  */
5921       if (GET_CODE (operands[2]) == CONST_INT
5922           && (INTVAL (operands[2]) == 128
5923               || (INTVAL (operands[2]) < 0
5924                   && INTVAL (operands[2]) != -128)))
5925         {
5926           operands[2] = GEN_INT (-INTVAL (operands[2]));
5927           return "sub{w}\t{%2, %0|%0, %2}";
5928         }
5929       return "add{w}\t{%2, %0|%0, %2}";
5930     }
5932   [(set (attr "type")
5933      (if_then_else (match_operand:HI 2 "incdec_operand" "")
5934         (const_string "incdec")
5935         (const_string "alu")))
5936    (set_attr "mode" "HI")])
5938 (define_expand "addqi3"
5939   [(parallel [(set (match_operand:QI 0 "nonimmediate_operand" "")
5940                    (plus:QI (match_operand:QI 1 "nonimmediate_operand" "")
5941                             (match_operand:QI 2 "general_operand" "")))
5942               (clobber (reg:CC 17))])]
5943   "TARGET_QIMODE_MATH"
5944   "ix86_expand_binary_operator (PLUS, QImode, operands); DONE;")
5946 ;; %%% Potential partial reg stall on alternative 2.  What to do?
5947 (define_insn "*addqi_1_lea"
5948   [(set (match_operand:QI 0 "nonimmediate_operand" "=qm,q,r,r")
5949         (plus:QI (match_operand:QI 1 "nonimmediate_operand" "%0,0,0,r")
5950                  (match_operand:QI 2 "general_operand" "qn,qmn,rn,rn")))
5951    (clobber (reg:CC 17))]
5952   "!TARGET_PARTIAL_REG_STALL
5953    && ix86_binary_operator_ok (PLUS, QImode, operands)"
5955   int widen = (which_alternative == 2);
5956   switch (get_attr_type (insn))
5957     {
5958     case TYPE_LEA:
5959       return "#";
5960     case TYPE_INCDEC:
5961       if (operands[2] == const1_rtx)
5962         return widen ? "inc{l}\t%k0" : "inc{b}\t%0";
5963       else if (operands[2] == constm1_rtx)
5964         return widen ? "dec{l}\t%k0" : "dec{b}\t%0";
5965       abort();
5967     default:
5968       /* Make things pretty and `subl $4,%eax' rather than `addl $-4, %eax'.
5969          Exceptions: -128 encodes smaller than 128, so swap sign and op.  */
5970       if (GET_CODE (operands[2]) == CONST_INT
5971           && (INTVAL (operands[2]) == 128
5972               || (INTVAL (operands[2]) < 0
5973                   && INTVAL (operands[2]) != -128)))
5974         {
5975           operands[2] = GEN_INT (-INTVAL (operands[2]));
5976           if (widen)
5977             return "sub{l}\t{%2, %k0|%k0, %2}";
5978           else
5979             return "sub{b}\t{%2, %0|%0, %2}";
5980         }
5981       if (widen)
5982         return "add{l}\t{%k2, %k0|%k0, %k2}";
5983       else
5984         return "add{b}\t{%2, %0|%0, %2}";
5985     }
5987   [(set (attr "type")
5988      (if_then_else (eq_attr "alternative" "3")
5989         (const_string "lea")
5990         (if_then_else (match_operand:QI 2 "incdec_operand" "")
5991            (const_string "incdec")
5992            (const_string "alu"))))
5993    (set_attr "mode" "QI,QI,SI,SI")])
5995 (define_insn "*addqi_1"
5996   [(set (match_operand:QI 0 "nonimmediate_operand" "=qm,q,r")
5997         (plus:QI (match_operand:QI 1 "nonimmediate_operand" "%0,0,0")
5998                  (match_operand:QI 2 "general_operand" "qn,qmn,rn")))
5999    (clobber (reg:CC 17))]
6000   "TARGET_PARTIAL_REG_STALL
6001    && ix86_binary_operator_ok (PLUS, QImode, operands)"
6003   int widen = (which_alternative == 2);
6004   switch (get_attr_type (insn))
6005     {
6006     case TYPE_INCDEC:
6007       if (operands[2] == const1_rtx)
6008         return widen ? "inc{l}\t%k0" : "inc{b}\t%0";
6009       else if (operands[2] == constm1_rtx)
6010         return widen ? "dec{l}\t%k0" : "dec{b}\t%0";
6011       abort();
6013     default:
6014       /* Make things pretty and `subl $4,%eax' rather than `addl $-4, %eax'.
6015          Exceptions: -128 encodes smaller than 128, so swap sign and op.  */
6016       if (GET_CODE (operands[2]) == CONST_INT
6017           && (INTVAL (operands[2]) == 128
6018               || (INTVAL (operands[2]) < 0
6019                   && INTVAL (operands[2]) != -128)))
6020         {
6021           operands[2] = GEN_INT (-INTVAL (operands[2]));
6022           if (widen)
6023             return "sub{l}\t{%2, %k0|%k0, %2}";
6024           else
6025             return "sub{b}\t{%2, %0|%0, %2}";
6026         }
6027       if (widen)
6028         return "add{l}\t{%k2, %k0|%k0, %k2}";
6029       else
6030         return "add{b}\t{%2, %0|%0, %2}";
6031     }
6033   [(set (attr "type")
6034      (if_then_else (match_operand:QI 2 "incdec_operand" "")
6035         (const_string "incdec")
6036         (const_string "alu")))
6037    (set_attr "mode" "QI,QI,SI")])
6039 (define_insn "*addqi_1_slp"
6040   [(set (strict_low_part (match_operand:QI 0 "nonimmediate_operand" "+qm,q"))
6041         (plus:QI (match_operand:QI 1 "nonimmediate_operand" "%0,0")
6042                  (match_operand:QI 2 "general_operand" "qn,qnm")))
6043    (clobber (reg:CC 17))]
6044   "(! TARGET_PARTIAL_REG_STALL || optimize_size)
6045    && ix86_binary_operator_ok (PLUS, QImode, operands)"
6047   switch (get_attr_type (insn))
6048     {
6049     case TYPE_INCDEC:
6050       if (operands[2] == const1_rtx)
6051         return "inc{b}\t%0";
6052       else if (operands[2] == constm1_rtx)
6053         return "dec{b}\t%0";
6054       abort();
6056     default:
6057       /* Make things pretty and `subl $4,%eax' rather than `addl $-4, %eax'.  */
6058       if (GET_CODE (operands[2]) == CONST_INT
6059           && INTVAL (operands[2]) < 0)
6060         {
6061           operands[2] = GEN_INT (-INTVAL (operands[2]));
6062           return "sub{b}\t{%2, %0|%0, %2}";
6063         }
6064       return "add{b}\t{%2, %0|%0, %2}";
6065     }
6067   [(set (attr "type")
6068      (if_then_else (match_operand:QI 2 "incdec_operand" "")
6069         (const_string "incdec")
6070         (const_string "alu")))
6071    (set_attr "mode" "QI")])
6073 (define_insn "*addqi_2"
6074   [(set (reg 17)
6075         (compare
6076           (plus:QI (match_operand:QI 1 "nonimmediate_operand" "%0,0")
6077                    (match_operand:QI 2 "general_operand" "qmni,qni"))
6078           (const_int 0)))
6079    (set (match_operand:QI 0 "nonimmediate_operand" "=q,qm")
6080         (plus:QI (match_dup 1) (match_dup 2)))]
6081   "ix86_match_ccmode (insn, CCGOCmode)
6082    && ix86_binary_operator_ok (PLUS, QImode, operands)"
6084   switch (get_attr_type (insn))
6085     {
6086     case TYPE_INCDEC:
6087       if (operands[2] == const1_rtx)
6088         return "inc{b}\t%0";
6089       else if (operands[2] == constm1_rtx
6090                || (GET_CODE (operands[2]) == CONST_INT
6091                    && INTVAL (operands[2]) == 255))
6092         return "dec{b}\t%0";
6093       abort();
6095     default:
6096       /* Make things pretty and `subb $4,%al' rather than `addb $-4, %al'.  */
6097       if (GET_CODE (operands[2]) == CONST_INT
6098           && INTVAL (operands[2]) < 0)
6099         {
6100           operands[2] = GEN_INT (-INTVAL (operands[2]));
6101           return "sub{b}\t{%2, %0|%0, %2}";
6102         }
6103       return "add{b}\t{%2, %0|%0, %2}";
6104     }
6106   [(set (attr "type")
6107      (if_then_else (match_operand:QI 2 "incdec_operand" "")
6108         (const_string "incdec")
6109         (const_string "alu")))
6110    (set_attr "mode" "QI")])
6112 (define_insn "*addqi_3"
6113   [(set (reg 17)
6114         (compare (neg:QI (match_operand:QI 2 "general_operand" "qmni"))
6115                  (match_operand:QI 1 "nonimmediate_operand" "%0")))
6116    (clobber (match_scratch:QI 0 "=q"))]
6117   "ix86_match_ccmode (insn, CCZmode)
6118    && (GET_CODE (operands[1]) != MEM || GET_CODE (operands[2]) != MEM)"
6120   switch (get_attr_type (insn))
6121     {
6122     case TYPE_INCDEC:
6123       if (operands[2] == const1_rtx)
6124         return "inc{b}\t%0";
6125       else if (operands[2] == constm1_rtx
6126                || (GET_CODE (operands[2]) == CONST_INT
6127                    && INTVAL (operands[2]) == 255))
6128         return "dec{b}\t%0";
6129       abort();
6131     default:
6132       /* Make things pretty and `subb $4,%al' rather than `addb $-4, %al'.  */
6133       if (GET_CODE (operands[2]) == CONST_INT
6134           && INTVAL (operands[2]) < 0)
6135         {
6136           operands[2] = GEN_INT (-INTVAL (operands[2]));
6137           return "sub{b}\t{%2, %0|%0, %2}";
6138         }
6139       return "add{b}\t{%2, %0|%0, %2}";
6140     }
6142   [(set (attr "type")
6143      (if_then_else (match_operand:QI 2 "incdec_operand" "")
6144         (const_string "incdec")
6145         (const_string "alu")))
6146    (set_attr "mode" "QI")])
6148 ; See comments above addsi_3_imm for details.
6149 (define_insn "*addqi_4"
6150   [(set (reg 17)
6151         (compare (match_operand:QI 1 "nonimmediate_operand" "0")
6152                  (match_operand:QI 2 "const_int_operand" "n")))
6153    (clobber (match_scratch:QI 0 "=qm"))]
6154   "ix86_match_ccmode (insn, CCGCmode)
6155    && (INTVAL (operands[2]) & 0xff) != 0x80"
6157   switch (get_attr_type (insn))
6158     {
6159     case TYPE_INCDEC:
6160       if (operands[2] == constm1_rtx
6161           || (GET_CODE (operands[2]) == CONST_INT
6162               && INTVAL (operands[2]) == 255))
6163         return "inc{b}\t%0";
6164       else if (operands[2] == const1_rtx)
6165         return "dec{b}\t%0";
6166       else
6167         abort();
6169     default:
6170       if (! rtx_equal_p (operands[0], operands[1]))
6171         abort ();
6172       if (INTVAL (operands[2]) < 0)
6173         {
6174           operands[2] = GEN_INT (-INTVAL (operands[2]));
6175           return "add{b}\t{%2, %0|%0, %2}";
6176         }
6177       return "sub{b}\t{%2, %0|%0, %2}";
6178     }
6180   [(set (attr "type")
6181      (if_then_else (match_operand:HI 2 "incdec_operand" "")
6182         (const_string "incdec")
6183         (const_string "alu")))
6184    (set_attr "mode" "QI")])
6187 (define_insn "*addqi_5"
6188   [(set (reg 17)
6189         (compare
6190           (plus:QI (match_operand:QI 1 "nonimmediate_operand" "%0")
6191                    (match_operand:QI 2 "general_operand" "qmni"))
6192           (const_int 0)))
6193    (clobber (match_scratch:QI 0 "=q"))]
6194   "ix86_match_ccmode (insn, CCGOCmode)
6195    && (GET_CODE (operands[1]) != MEM || GET_CODE (operands[2]) != MEM)"
6197   switch (get_attr_type (insn))
6198     {
6199     case TYPE_INCDEC:
6200       if (operands[2] == const1_rtx)
6201         return "inc{b}\t%0";
6202       else if (operands[2] == constm1_rtx
6203                || (GET_CODE (operands[2]) == CONST_INT
6204                    && INTVAL (operands[2]) == 255))
6205         return "dec{b}\t%0";
6206       abort();
6208     default:
6209       /* Make things pretty and `subb $4,%al' rather than `addb $-4, %al'.  */
6210       if (GET_CODE (operands[2]) == CONST_INT
6211           && INTVAL (operands[2]) < 0)
6212         {
6213           operands[2] = GEN_INT (-INTVAL (operands[2]));
6214           return "sub{b}\t{%2, %0|%0, %2}";
6215         }
6216       return "add{b}\t{%2, %0|%0, %2}";
6217     }
6219   [(set (attr "type")
6220      (if_then_else (match_operand:QI 2 "incdec_operand" "")
6221         (const_string "incdec")
6222         (const_string "alu")))
6223    (set_attr "mode" "QI")])
6226 (define_insn "addqi_ext_1"
6227   [(set (zero_extract:SI (match_operand 0 "ext_register_operand" "=Q")
6228                          (const_int 8)
6229                          (const_int 8))
6230         (plus:SI
6231           (zero_extract:SI
6232             (match_operand 1 "ext_register_operand" "0")
6233             (const_int 8)
6234             (const_int 8))
6235           (match_operand:QI 2 "general_operand" "Qmn")))
6236    (clobber (reg:CC 17))]
6237   "!TARGET_64BIT"
6239   switch (get_attr_type (insn))
6240     {
6241     case TYPE_INCDEC:
6242       if (operands[2] == const1_rtx)
6243         return "inc{b}\t%h0";
6244       else if (operands[2] == constm1_rtx
6245                || (GET_CODE (operands[2]) == CONST_INT
6246                    && INTVAL (operands[2]) == 255))
6247         return "dec{b}\t%h0";
6248       abort();
6250     default:
6251       return "add{b}\t{%2, %h0|%h0, %2}";
6252     }
6254   [(set (attr "type")
6255      (if_then_else (match_operand:QI 2 "incdec_operand" "")
6256         (const_string "incdec")
6257         (const_string "alu")))
6258    (set_attr "mode" "QI")])
6260 (define_insn "*addqi_ext_1_rex64"
6261   [(set (zero_extract:SI (match_operand 0 "ext_register_operand" "=Q")
6262                          (const_int 8)
6263                          (const_int 8))
6264         (plus:SI
6265           (zero_extract:SI
6266             (match_operand 1 "ext_register_operand" "0")
6267             (const_int 8)
6268             (const_int 8))
6269           (match_operand:QI 2 "nonmemory_operand" "Qn")))
6270    (clobber (reg:CC 17))]
6271   "TARGET_64BIT"
6273   switch (get_attr_type (insn))
6274     {
6275     case TYPE_INCDEC:
6276       if (operands[2] == const1_rtx)
6277         return "inc{b}\t%h0";
6278       else if (operands[2] == constm1_rtx
6279                || (GET_CODE (operands[2]) == CONST_INT
6280                    && INTVAL (operands[2]) == 255))
6281         return "dec{b}\t%h0";
6282       abort();
6284     default:
6285       return "add{b}\t{%2, %h0|%h0, %2}";
6286     }
6288   [(set (attr "type")
6289      (if_then_else (match_operand:QI 2 "incdec_operand" "")
6290         (const_string "incdec")
6291         (const_string "alu")))
6292    (set_attr "mode" "QI")])
6294 (define_insn "*addqi_ext_2"
6295   [(set (zero_extract:SI (match_operand 0 "ext_register_operand" "=Q")
6296                          (const_int 8)
6297                          (const_int 8))
6298         (plus:SI
6299           (zero_extract:SI
6300             (match_operand 1 "ext_register_operand" "%0")
6301             (const_int 8)
6302             (const_int 8))
6303           (zero_extract:SI
6304             (match_operand 2 "ext_register_operand" "Q")
6305             (const_int 8)
6306             (const_int 8))))
6307    (clobber (reg:CC 17))]
6308   ""
6309   "add{b}\t{%h2, %h0|%h0, %h2}"
6310   [(set_attr "type" "alu")
6311    (set_attr "mode" "QI")])
6313 ;; The patterns that match these are at the end of this file.
6315 (define_expand "addxf3"
6316   [(set (match_operand:XF 0 "register_operand" "")
6317         (plus:XF (match_operand:XF 1 "register_operand" "")
6318                  (match_operand:XF 2 "register_operand" "")))]
6319   "!TARGET_64BIT && TARGET_80387"
6320   "")
6322 (define_expand "addtf3"
6323   [(set (match_operand:TF 0 "register_operand" "")
6324         (plus:TF (match_operand:TF 1 "register_operand" "")
6325                  (match_operand:TF 2 "register_operand" "")))]
6326   "TARGET_80387"
6327   "")
6329 (define_expand "adddf3"
6330   [(set (match_operand:DF 0 "register_operand" "")
6331         (plus:DF (match_operand:DF 1 "register_operand" "")
6332                  (match_operand:DF 2 "nonimmediate_operand" "")))]
6333   "TARGET_80387 || (TARGET_SSE2 && TARGET_SSE_MATH)"
6334   "")
6336 (define_expand "addsf3"
6337   [(set (match_operand:SF 0 "register_operand" "")
6338         (plus:SF (match_operand:SF 1 "register_operand" "")
6339                  (match_operand:SF 2 "nonimmediate_operand" "")))]
6340   "TARGET_80387 || TARGET_SSE_MATH"
6341   "")
6343 ;; Subtract instructions
6345 ;; %%% splits for subsidi3
6347 (define_expand "subdi3"
6348   [(parallel [(set (match_operand:DI 0 "nonimmediate_operand" "")
6349                    (minus:DI (match_operand:DI 1 "nonimmediate_operand" "")
6350                              (match_operand:DI 2 "x86_64_general_operand" "")))
6351               (clobber (reg:CC 17))])]
6352   ""
6353   "ix86_expand_binary_operator (MINUS, DImode, operands); DONE;")
6355 (define_insn "*subdi3_1"
6356   [(set (match_operand:DI 0 "nonimmediate_operand" "=r,o")
6357         (minus:DI (match_operand:DI 1 "nonimmediate_operand" "0,0")
6358                   (match_operand:DI 2 "general_operand" "roiF,riF")))
6359    (clobber (reg:CC 17))]
6360   "!TARGET_64BIT"
6361   "#")
6363 (define_split
6364   [(set (match_operand:DI 0 "nonimmediate_operand" "")
6365         (minus:DI (match_operand:DI 1 "nonimmediate_operand" "")
6366                   (match_operand:DI 2 "general_operand" "")))
6367    (clobber (reg:CC 17))]
6368   "!TARGET_64BIT && reload_completed"
6369   [(parallel [(set (reg:CC 17) (compare:CC (match_dup 1) (match_dup 2)))
6370               (set (match_dup 0) (minus:SI (match_dup 1) (match_dup 2)))])
6371    (parallel [(set (match_dup 3)
6372                    (minus:SI (match_dup 4)
6373                              (plus:SI (ltu:SI (reg:CC 17) (const_int 0))
6374                                       (match_dup 5))))
6375               (clobber (reg:CC 17))])]
6376   "split_di (operands+0, 1, operands+0, operands+3);
6377    split_di (operands+1, 1, operands+1, operands+4);
6378    split_di (operands+2, 1, operands+2, operands+5);")
6380 (define_insn "subdi3_carry_rex64"
6381   [(set (match_operand:DI 0 "nonimmediate_operand" "=rm,r")
6382           (minus:DI (match_operand:DI 1 "nonimmediate_operand" "0,0")
6383             (plus:DI (ltu:DI (reg:CC 17) (const_int 0))
6384                (match_operand:DI 2 "x86_64_general_operand" "re,rm"))))
6385    (clobber (reg:CC 17))]
6386   "TARGET_64BIT && ix86_binary_operator_ok (MINUS, DImode, operands)"
6387   "sbb{q}\t{%2, %0|%0, %2}"
6388   [(set_attr "type" "alu")
6389    (set_attr "pent_pair" "pu")
6390    (set_attr "ppro_uops" "few")
6391    (set_attr "mode" "DI")])
6393 (define_insn "*subdi_1_rex64"
6394   [(set (match_operand:DI 0 "nonimmediate_operand" "=rm,r")
6395         (minus:DI (match_operand:DI 1 "nonimmediate_operand" "0,0")
6396                   (match_operand:DI 2 "x86_64_general_operand" "re,rm")))
6397    (clobber (reg:CC 17))]
6398   "TARGET_64BIT && ix86_binary_operator_ok (MINUS, DImode, operands)"
6399   "sub{q}\t{%2, %0|%0, %2}"
6400   [(set_attr "type" "alu")
6401    (set_attr "mode" "DI")])
6403 (define_insn "*subdi_2_rex64"
6404   [(set (reg 17)
6405         (compare
6406           (minus:DI (match_operand:DI 1 "nonimmediate_operand" "0,0")
6407                     (match_operand:DI 2 "x86_64_general_operand" "re,rm"))
6408           (const_int 0)))
6409    (set (match_operand:DI 0 "nonimmediate_operand" "=rm,r")
6410         (minus:DI (match_dup 1) (match_dup 2)))]
6411   "TARGET_64BIT && ix86_match_ccmode (insn, CCGOCmode)
6412    && ix86_binary_operator_ok (MINUS, DImode, operands)"
6413   "sub{q}\t{%2, %0|%0, %2}"
6414   [(set_attr "type" "alu")
6415    (set_attr "mode" "DI")])
6417 (define_insn "*subdi_3_rex63"
6418   [(set (reg 17)
6419         (compare (match_operand:DI 1 "nonimmediate_operand" "0,0")
6420                  (match_operand:DI 2 "x86_64_general_operand" "re,rm")))
6421    (set (match_operand:DI 0 "nonimmediate_operand" "=rm,r")
6422         (minus:DI (match_dup 1) (match_dup 2)))]
6423   "TARGET_64BIT && ix86_match_ccmode (insn, CCmode)
6424    && ix86_binary_operator_ok (MINUS, SImode, operands)"
6425   "sub{q}\t{%2, %0|%0, %2}"
6426   [(set_attr "type" "alu")
6427    (set_attr "mode" "DI")])
6430 (define_insn "subsi3_carry"
6431   [(set (match_operand:SI 0 "nonimmediate_operand" "=rm,r")
6432           (minus:SI (match_operand:SI 1 "nonimmediate_operand" "0,0")
6433             (plus:SI (ltu:SI (reg:CC 17) (const_int 0))
6434                (match_operand:SI 2 "general_operand" "ri,rm"))))
6435    (clobber (reg:CC 17))]
6436   "ix86_binary_operator_ok (MINUS, SImode, operands)"
6437   "sbb{l}\t{%2, %0|%0, %2}"
6438   [(set_attr "type" "alu")
6439    (set_attr "pent_pair" "pu")
6440    (set_attr "ppro_uops" "few")
6441    (set_attr "mode" "SI")])
6443 (define_insn "subsi3_carry_zext"
6444   [(set (match_operand:DI 0 "register_operand" "=rm,r")
6445           (zero_extend:DI
6446             (minus:SI (match_operand:SI 1 "register_operand" "0,0")
6447               (plus:SI (ltu:SI (reg:CC 17) (const_int 0))
6448                  (match_operand:SI 2 "general_operand" "ri,rm")))))
6449    (clobber (reg:CC 17))]
6450   "TARGET_64BIT && ix86_binary_operator_ok (MINUS, SImode, operands)"
6451   "sbb{l}\t{%2, %k0|%k0, %2}"
6452   [(set_attr "type" "alu")
6453    (set_attr "pent_pair" "pu")
6454    (set_attr "ppro_uops" "few")
6455    (set_attr "mode" "SI")])
6457 (define_expand "subsi3"
6458   [(parallel [(set (match_operand:SI 0 "nonimmediate_operand" "")
6459                    (minus:SI (match_operand:SI 1 "nonimmediate_operand" "")
6460                              (match_operand:SI 2 "general_operand" "")))
6461               (clobber (reg:CC 17))])]
6462   ""
6463   "ix86_expand_binary_operator (MINUS, SImode, operands); DONE;")
6465 (define_insn "*subsi_1"
6466   [(set (match_operand:SI 0 "nonimmediate_operand" "=rm,r")
6467         (minus:SI (match_operand:SI 1 "nonimmediate_operand" "0,0")
6468                   (match_operand:SI 2 "general_operand" "ri,rm")))
6469    (clobber (reg:CC 17))]
6470   "ix86_binary_operator_ok (MINUS, SImode, operands)"
6471   "sub{l}\t{%2, %0|%0, %2}"
6472   [(set_attr "type" "alu")
6473    (set_attr "mode" "SI")])
6475 (define_insn "*subsi_1_zext"
6476   [(set (match_operand:DI 0 "register_operand" "=r")
6477         (zero_extend:DI
6478           (minus:SI (match_operand:SI 1 "register_operand" "0")
6479                     (match_operand:SI 2 "general_operand" "rim"))))
6480    (clobber (reg:CC 17))]
6481   "TARGET_64BIT && ix86_binary_operator_ok (MINUS, SImode, operands)"
6482   "sub{l}\t{%2, %k0|%k0, %2}"
6483   [(set_attr "type" "alu")
6484    (set_attr "mode" "SI")])
6486 (define_insn "*subsi_2"
6487   [(set (reg 17)
6488         (compare
6489           (minus:SI (match_operand:SI 1 "nonimmediate_operand" "0,0")
6490                     (match_operand:SI 2 "general_operand" "ri,rm"))
6491           (const_int 0)))
6492    (set (match_operand:SI 0 "nonimmediate_operand" "=rm,r")
6493         (minus:SI (match_dup 1) (match_dup 2)))]
6494   "ix86_match_ccmode (insn, CCGOCmode)
6495    && ix86_binary_operator_ok (MINUS, SImode, operands)"
6496   "sub{l}\t{%2, %0|%0, %2}"
6497   [(set_attr "type" "alu")
6498    (set_attr "mode" "SI")])
6500 (define_insn "*subsi_2_zext"
6501   [(set (reg 17)
6502         (compare
6503           (minus:SI (match_operand:SI 1 "register_operand" "0")
6504                     (match_operand:SI 2 "general_operand" "rim"))
6505           (const_int 0)))
6506    (set (match_operand:DI 0 "register_operand" "=r")
6507         (zero_extend:DI
6508           (minus:SI (match_dup 1)
6509                     (match_dup 2))))]
6510   "TARGET_64BIT && ix86_match_ccmode (insn, CCGOCmode)
6511    && ix86_binary_operator_ok (MINUS, SImode, operands)"
6512   "sub{l}\t{%2, %k0|%k0, %2}"
6513   [(set_attr "type" "alu")
6514    (set_attr "mode" "SI")])
6516 (define_insn "*subsi_3"
6517   [(set (reg 17)
6518         (compare (match_operand:SI 1 "nonimmediate_operand" "0,0")
6519                  (match_operand:SI 2 "general_operand" "ri,rm")))
6520    (set (match_operand:SI 0 "nonimmediate_operand" "=rm,r")
6521         (minus:SI (match_dup 1) (match_dup 2)))]
6522   "ix86_match_ccmode (insn, CCmode)
6523    && ix86_binary_operator_ok (MINUS, SImode, operands)"
6524   "sub{l}\t{%2, %0|%0, %2}"
6525   [(set_attr "type" "alu")
6526    (set_attr "mode" "SI")])
6528 (define_insn "*subsi_3_zext"
6529   [(set (reg 17)
6530         (compare (match_operand:SI 1 "nonimmediate_operand" "0")
6531                  (match_operand:SI 2 "general_operand" "rim")))
6532    (set (match_operand:DI 0 "register_operand" "=r")
6533         (zero_extend:DI
6534           (minus:SI (match_dup 1)
6535                     (match_dup 2))))]
6536   "TARGET_64BIT && ix86_match_ccmode (insn, CCmode)
6537    && ix86_binary_operator_ok (MINUS, SImode, operands)"
6538   "sub{q}\t{%2, %0|%0, %2}"
6539   [(set_attr "type" "alu")
6540    (set_attr "mode" "DI")])
6542 (define_expand "subhi3"
6543   [(parallel [(set (match_operand:HI 0 "nonimmediate_operand" "")
6544                    (minus:HI (match_operand:HI 1 "nonimmediate_operand" "")
6545                              (match_operand:HI 2 "general_operand" "")))
6546               (clobber (reg:CC 17))])]
6547   "TARGET_HIMODE_MATH"
6548   "ix86_expand_binary_operator (MINUS, HImode, operands); DONE;")
6550 (define_insn "*subhi_1"
6551   [(set (match_operand:HI 0 "nonimmediate_operand" "=rm,r")
6552         (minus:HI (match_operand:HI 1 "nonimmediate_operand" "0,0")
6553                   (match_operand:HI 2 "general_operand" "ri,rm")))
6554    (clobber (reg:CC 17))]
6555   "ix86_binary_operator_ok (MINUS, HImode, operands)"
6556   "sub{w}\t{%2, %0|%0, %2}"
6557   [(set_attr "type" "alu")
6558    (set_attr "mode" "HI")])
6560 (define_insn "*subhi_2"
6561   [(set (reg 17)
6562         (compare
6563           (minus:HI (match_operand:HI 1 "nonimmediate_operand" "0,0")
6564                     (match_operand:HI 2 "general_operand" "ri,rm"))
6565           (const_int 0)))
6566    (set (match_operand:HI 0 "nonimmediate_operand" "=rm,r")
6567         (minus:HI (match_dup 1) (match_dup 2)))]
6568   "ix86_match_ccmode (insn, CCGOCmode)
6569    && ix86_binary_operator_ok (MINUS, HImode, operands)"
6570   "sub{w}\t{%2, %0|%0, %2}"
6571   [(set_attr "type" "alu")
6572    (set_attr "mode" "HI")])
6574 (define_insn "*subhi_3"
6575   [(set (reg 17)
6576         (compare (match_operand:HI 1 "nonimmediate_operand" "0,0")
6577                  (match_operand:HI 2 "general_operand" "ri,rm")))
6578    (set (match_operand:HI 0 "nonimmediate_operand" "=rm,r")
6579         (minus:HI (match_dup 1) (match_dup 2)))]
6580   "ix86_match_ccmode (insn, CCmode)
6581    && ix86_binary_operator_ok (MINUS, HImode, operands)"
6582   "sub{w}\t{%2, %0|%0, %2}"
6583   [(set_attr "type" "alu")
6584    (set_attr "mode" "HI")])
6586 (define_expand "subqi3"
6587   [(parallel [(set (match_operand:QI 0 "nonimmediate_operand" "")
6588                    (minus:QI (match_operand:QI 1 "nonimmediate_operand" "")
6589                              (match_operand:QI 2 "general_operand" "")))
6590               (clobber (reg:CC 17))])]
6591   "TARGET_QIMODE_MATH"
6592   "ix86_expand_binary_operator (MINUS, QImode, operands); DONE;")
6594 (define_insn "*subqi_1"
6595   [(set (match_operand:QI 0 "nonimmediate_operand" "=qm,q")
6596         (minus:QI (match_operand:QI 1 "nonimmediate_operand" "0,0")
6597                   (match_operand:QI 2 "general_operand" "qn,qmn")))
6598    (clobber (reg:CC 17))]
6599   "ix86_binary_operator_ok (MINUS, QImode, operands)"
6600   "sub{b}\t{%2, %0|%0, %2}"
6601   [(set_attr "type" "alu")
6602    (set_attr "mode" "QI")])
6604 (define_insn "*subqi_1_slp"
6605   [(set (strict_low_part (match_operand:QI 0 "nonimmediate_operand" "+qm,q"))
6606         (minus:QI (match_operand:QI 1 "nonimmediate_operand" "0,0")
6607                   (match_operand:QI 2 "general_operand" "qn,qmn")))
6608    (clobber (reg:CC 17))]
6609   "(! TARGET_PARTIAL_REG_STALL || optimize_size)
6610    && ix86_binary_operator_ok (MINUS, QImode, operands)"
6611   "sub{b}\t{%2, %0|%0, %2}"
6612   [(set_attr "type" "alu")
6613    (set_attr "mode" "QI")])
6615 (define_insn "*subqi_2"
6616   [(set (reg 17)
6617         (compare
6618           (minus:QI (match_operand:QI 1 "nonimmediate_operand" "0,0")
6619                     (match_operand:QI 2 "general_operand" "qi,qm"))
6620           (const_int 0)))
6621    (set (match_operand:HI 0 "nonimmediate_operand" "=qm,q")
6622         (minus:HI (match_dup 1) (match_dup 2)))]
6623   "ix86_match_ccmode (insn, CCGOCmode)
6624    && ix86_binary_operator_ok (MINUS, QImode, operands)"
6625   "sub{b}\t{%2, %0|%0, %2}"
6626   [(set_attr "type" "alu")
6627    (set_attr "mode" "QI")])
6629 (define_insn "*subqi_3"
6630   [(set (reg 17)
6631         (compare (match_operand:QI 1 "nonimmediate_operand" "0,0")
6632                  (match_operand:QI 2 "general_operand" "qi,qm")))
6633    (set (match_operand:HI 0 "nonimmediate_operand" "=qm,q")
6634         (minus:HI (match_dup 1) (match_dup 2)))]
6635   "ix86_match_ccmode (insn, CCmode)
6636    && ix86_binary_operator_ok (MINUS, QImode, operands)"
6637   "sub{b}\t{%2, %0|%0, %2}"
6638   [(set_attr "type" "alu")
6639    (set_attr "mode" "QI")])
6641 ;; The patterns that match these are at the end of this file.
6643 (define_expand "subxf3"
6644   [(set (match_operand:XF 0 "register_operand" "")
6645         (minus:XF (match_operand:XF 1 "register_operand" "")
6646                   (match_operand:XF 2 "register_operand" "")))]
6647   "!TARGET_64BIT && TARGET_80387"
6648   "")
6650 (define_expand "subtf3"
6651   [(set (match_operand:TF 0 "register_operand" "")
6652         (minus:TF (match_operand:TF 1 "register_operand" "")
6653                   (match_operand:TF 2 "register_operand" "")))]
6654   "TARGET_80387"
6655   "")
6657 (define_expand "subdf3"
6658   [(set (match_operand:DF 0 "register_operand" "")
6659         (minus:DF (match_operand:DF 1 "register_operand" "")
6660                   (match_operand:DF 2 "nonimmediate_operand" "")))]
6661   "TARGET_80387 || (TARGET_SSE2 && TARGET_SSE_MATH)"
6662   "")
6664 (define_expand "subsf3"
6665   [(set (match_operand:SF 0 "register_operand" "")
6666         (minus:SF (match_operand:SF 1 "register_operand" "")
6667                   (match_operand:SF 2 "nonimmediate_operand" "")))]
6668   "TARGET_80387 || TARGET_SSE_MATH"
6669   "")
6671 ;; Multiply instructions
6673 (define_expand "muldi3"
6674   [(parallel [(set (match_operand:DI 0 "register_operand" "")
6675                    (mult:DI (match_operand:DI 1 "register_operand" "")
6676                             (match_operand:DI 2 "x86_64_general_operand" "")))
6677               (clobber (reg:CC 17))])]
6678   "TARGET_64BIT"
6679   "")
6681 (define_insn "*muldi3_1_rex64"
6682   [(set (match_operand:DI 0 "register_operand" "=r,r,r")
6683         (mult:DI (match_operand:DI 1 "nonimmediate_operand" "%rm,0,0")
6684                  (match_operand:DI 2 "x86_64_general_operand" "K,e,mr")))
6685    (clobber (reg:CC 17))]
6686   "TARGET_64BIT
6687    && (GET_CODE (operands[1]) != MEM || GET_CODE (operands[2]) != MEM)"
6688   "@
6689    imul{q}\t{%2, %1, %0|%0, %1, %2}
6690    imul{q}\t{%2, %1, %0|%0, %1, %2}
6691    imul{q}\t{%2, %0|%0, %2}"
6692   [(set_attr "type" "imul")
6693    (set_attr "prefix_0f" "0,0,1")
6694    (set_attr "mode" "DI")])
6696 (define_expand "mulsi3"
6697   [(parallel [(set (match_operand:SI 0 "register_operand" "")
6698                    (mult:SI (match_operand:SI 1 "register_operand" "")
6699                             (match_operand:SI 2 "general_operand" "")))
6700               (clobber (reg:CC 17))])]
6701   ""
6702   "")
6704 (define_insn "*mulsi3_1"
6705   [(set (match_operand:SI 0 "register_operand" "=r,r,r")
6706         (mult:SI (match_operand:SI 1 "nonimmediate_operand" "%rm,0,0")
6707                  (match_operand:SI 2 "general_operand" "K,i,mr")))
6708    (clobber (reg:CC 17))]
6709   "GET_CODE (operands[1]) != MEM || GET_CODE (operands[2]) != MEM"
6710   ; For the {r,0,i} alternative (i.e., register <- register * immediate),
6711   ; there are two ways of writing the exact same machine instruction
6712   ; in assembly language.  One, for example, is:
6713   ;
6714   ;   imul $12, %eax
6715   ;
6716   ; while the other is:
6717   ;
6718   ;   imul $12, %eax, %eax
6719   ;
6720   ; The first is simply short-hand for the latter.  But, some assemblers,
6721   ; like the SCO OSR5 COFF assembler, don't handle the first form.
6722   "@
6723    imul{l}\t{%2, %1, %0|%0, %1, %2}
6724    imul{l}\t{%2, %1, %0|%0, %1, %2}
6725    imul{l}\t{%2, %0|%0, %2}"
6726   [(set_attr "type" "imul")
6727    (set_attr "prefix_0f" "0,0,1")
6728    (set_attr "mode" "SI")])
6730 (define_insn "*mulsi3_1_zext"
6731   [(set (match_operand:DI 0 "register_operand" "=r,r,r")
6732         (zero_extend:DI
6733           (mult:SI (match_operand:SI 1 "nonimmediate_operand" "%rm,0,0")
6734                    (match_operand:SI 2 "general_operand" "K,i,mr"))))
6735    (clobber (reg:CC 17))]
6736   "TARGET_64BIT
6737    && (GET_CODE (operands[1]) != MEM || GET_CODE (operands[2]) != MEM)"
6738   ; For the {r,0,i} alternative (i.e., register <- register * immediate),
6739   ; there are two ways of writing the exact same machine instruction
6740   ; in assembly language.  One, for example, is:
6741   ;
6742   ;   imul $12, %eax
6743   ;
6744   ; while the other is:
6745   ;
6746   ;   imul $12, %eax, %eax
6747   ;
6748   ; The first is simply short-hand for the latter.  But, some assemblers,
6749   ; like the SCO OSR5 COFF assembler, don't handle the first form.
6750   "@
6751    imul{l}\t{%2, %1, %k0|%k0, %1, %2}
6752    imul{l}\t{%2, %1, %k0|%k0, %1, %2}
6753    imul{l}\t{%2, %k0|%k0, %2}"
6754   [(set_attr "type" "imul")
6755    (set_attr "prefix_0f" "0,0,1")
6756    (set_attr "mode" "SI")])
6758 (define_expand "mulhi3"
6759   [(parallel [(set (match_operand:HI 0 "register_operand" "")
6760                    (mult:HI (match_operand:HI 1 "register_operand" "")
6761                             (match_operand:HI 2 "general_operand" "")))
6762               (clobber (reg:CC 17))])]
6763   "TARGET_HIMODE_MATH"
6764   "")
6766 (define_insn "*mulhi3_1"
6767   [(set (match_operand:HI 0 "register_operand" "=r,r,r")
6768         (mult:HI (match_operand:HI 1 "nonimmediate_operand" "%rm,0,0")
6769                  (match_operand:HI 2 "general_operand" "K,i,mr")))
6770    (clobber (reg:CC 17))]
6771   "GET_CODE (operands[1]) != MEM || GET_CODE (operands[2]) != MEM"
6772   ; %%% There was a note about "Assembler has weird restrictions",
6773   ; concerning alternative 1 when op1 == op0.  True?
6774   "@
6775    imul{w}\t{%2, %1, %0|%0, %1, %2}
6776    imul{w}\t{%2, %1, %0|%0, %1, %2}
6777    imul{w}\t{%2, %0|%0, %2}"
6778   [(set_attr "type" "imul")
6779    (set_attr "prefix_0f" "0,0,1")
6780    (set_attr "mode" "HI")])
6782 (define_expand "mulqi3"
6783   [(parallel [(set (match_operand:QI 0 "register_operand" "")
6784                    (mult:QI (match_operand:QI 1 "nonimmediate_operand" "")
6785                             (match_operand:QI 2 "register_operand" "")))
6786               (clobber (reg:CC 17))])]
6787   "TARGET_QIMODE_MATH"
6788   "")
6790 (define_insn "*mulqi3_1"
6791   [(set (match_operand:QI 0 "register_operand" "=a")
6792         (mult:QI (match_operand:QI 1 "nonimmediate_operand" "%0")
6793                  (match_operand:QI 2 "nonimmediate_operand" "qm")))
6794    (clobber (reg:CC 17))]
6795   "TARGET_QIMODE_MATH
6796    && (GET_CODE (operands[1]) != MEM || GET_CODE (operands[2]) != MEM)"
6797   "mul{b}\t%2"
6798   [(set_attr "type" "imul")
6799    (set_attr "length_immediate" "0")
6800    (set_attr "mode" "QI")])
6802 (define_expand "umulqihi3"
6803   [(parallel [(set (match_operand:HI 0 "register_operand" "")
6804                    (mult:HI (zero_extend:HI
6805                               (match_operand:QI 1 "nonimmediate_operand" ""))
6806                             (zero_extend:HI
6807                               (match_operand:QI 2 "register_operand" ""))))
6808               (clobber (reg:CC 17))])]
6809   "TARGET_QIMODE_MATH"
6810   "")
6812 (define_insn "*umulqihi3_1"
6813   [(set (match_operand:HI 0 "register_operand" "=a")
6814         (mult:HI (zero_extend:HI (match_operand:QI 1 "nonimmediate_operand" "%0"))
6815                  (zero_extend:HI (match_operand:QI 2 "nonimmediate_operand" "qm"))))
6816    (clobber (reg:CC 17))]
6817   "TARGET_QIMODE_MATH
6818    && (GET_CODE (operands[1]) != MEM || GET_CODE (operands[2]) != MEM)"
6819   "mul{b}\t%2"
6820   [(set_attr "type" "imul")
6821    (set_attr "length_immediate" "0")
6822    (set_attr "mode" "QI")])
6824 (define_expand "mulqihi3"
6825   [(parallel [(set (match_operand:HI 0 "register_operand" "")
6826                    (mult:HI (sign_extend:HI (match_operand:QI 1 "nonimmediate_operand" ""))
6827                             (sign_extend:HI (match_operand:QI 2 "register_operand" ""))))
6828               (clobber (reg:CC 17))])]
6829   "TARGET_QIMODE_MATH"
6830   "")
6832 (define_insn "*mulqihi3_insn"
6833   [(set (match_operand:HI 0 "register_operand" "=a")
6834         (mult:HI (sign_extend:HI (match_operand:QI 1 "nonimmediate_operand" "%0"))
6835                  (sign_extend:HI (match_operand:QI 2 "nonimmediate_operand" "qm"))))
6836    (clobber (reg:CC 17))]
6837   "TARGET_QIMODE_MATH
6838    && (GET_CODE (operands[1]) != MEM || GET_CODE (operands[2]) != MEM)"
6839   "imul{b}\t%2"
6840   [(set_attr "type" "imul")
6841    (set_attr "length_immediate" "0")
6842    (set_attr "mode" "QI")])
6844 (define_expand "umulditi3"
6845   [(parallel [(set (match_operand:TI 0 "register_operand" "")
6846                    (mult:TI (zero_extend:TI
6847                               (match_operand:DI 1 "nonimmediate_operand" ""))
6848                             (zero_extend:TI
6849                               (match_operand:DI 2 "register_operand" ""))))
6850               (clobber (reg:CC 17))])]
6851   "TARGET_64BIT"
6852   "")
6854 (define_insn "*umulditi3_insn"
6855   [(set (match_operand:TI 0 "register_operand" "=A")
6856         (mult:TI (zero_extend:TI (match_operand:DI 1 "nonimmediate_operand" "%0"))
6857                  (zero_extend:TI (match_operand:DI 2 "nonimmediate_operand" "rm"))))
6858    (clobber (reg:CC 17))]
6859   "TARGET_64BIT
6860    && (GET_CODE (operands[1]) != MEM || GET_CODE (operands[2]) != MEM)"
6861   "mul{q}\t%2"
6862   [(set_attr "type" "imul")
6863    (set_attr "ppro_uops" "few")
6864    (set_attr "length_immediate" "0")
6865    (set_attr "mode" "DI")])
6867 ;; We can't use this pattern in 64bit mode, since it results in two separate 32bit registers
6868 (define_expand "umulsidi3"
6869   [(parallel [(set (match_operand:DI 0 "register_operand" "")
6870                    (mult:DI (zero_extend:DI
6871                               (match_operand:SI 1 "nonimmediate_operand" ""))
6872                             (zero_extend:DI
6873                               (match_operand:SI 2 "register_operand" ""))))
6874               (clobber (reg:CC 17))])]
6875   "!TARGET_64BIT"
6876   "")
6878 (define_insn "*umulsidi3_insn"
6879   [(set (match_operand:DI 0 "register_operand" "=A")
6880         (mult:DI (zero_extend:DI (match_operand:SI 1 "nonimmediate_operand" "%0"))
6881                  (zero_extend:DI (match_operand:SI 2 "nonimmediate_operand" "rm"))))
6882    (clobber (reg:CC 17))]
6883   "!TARGET_64BIT
6884    && (GET_CODE (operands[1]) != MEM || GET_CODE (operands[2]) != MEM)"
6885   "mul{l}\t%2"
6886   [(set_attr "type" "imul")
6887    (set_attr "ppro_uops" "few")
6888    (set_attr "length_immediate" "0")
6889    (set_attr "mode" "SI")])
6891 (define_expand "mulditi3"
6892   [(parallel [(set (match_operand:TI 0 "register_operand" "")
6893                    (mult:TI (sign_extend:TI
6894                               (match_operand:DI 1 "nonimmediate_operand" ""))
6895                             (sign_extend:TI
6896                               (match_operand:DI 2 "register_operand" ""))))
6897               (clobber (reg:CC 17))])]
6898   "TARGET_64BIT"
6899   "")
6901 (define_insn "*mulditi3_insn"
6902   [(set (match_operand:TI 0 "register_operand" "=A")
6903         (mult:TI (sign_extend:TI (match_operand:DI 1 "nonimmediate_operand" "%0"))
6904                  (sign_extend:TI (match_operand:DI 2 "nonimmediate_operand" "rm"))))
6905    (clobber (reg:CC 17))]
6906   "TARGET_64BIT
6907    && (GET_CODE (operands[1]) != MEM || GET_CODE (operands[2]) != MEM)"
6908   "imul{q}\t%2"
6909   [(set_attr "type" "imul")
6910    (set_attr "length_immediate" "0")
6911    (set_attr "mode" "DI")])
6913 (define_expand "mulsidi3"
6914   [(parallel [(set (match_operand:DI 0 "register_operand" "")
6915                    (mult:DI (sign_extend:DI
6916                               (match_operand:SI 1 "nonimmediate_operand" ""))
6917                             (sign_extend:DI
6918                               (match_operand:SI 2 "register_operand" ""))))
6919               (clobber (reg:CC 17))])]
6920   "!TARGET_64BIT"
6921   "")
6923 (define_insn "*mulsidi3_insn"
6924   [(set (match_operand:DI 0 "register_operand" "=A")
6925         (mult:DI (sign_extend:DI (match_operand:SI 1 "nonimmediate_operand" "%0"))
6926                  (sign_extend:DI (match_operand:SI 2 "nonimmediate_operand" "rm"))))
6927    (clobber (reg:CC 17))]
6928   "!TARGET_64BIT
6929    && (GET_CODE (operands[1]) != MEM || GET_CODE (operands[2]) != MEM)"
6930   "imul{l}\t%2"
6931   [(set_attr "type" "imul")
6932    (set_attr "length_immediate" "0")
6933    (set_attr "mode" "SI")])
6935 (define_expand "umuldi3_highpart"
6936   [(parallel [(set (match_operand:DI 0 "register_operand" "")
6937                    (truncate:DI
6938                      (lshiftrt:TI
6939                        (mult:TI (zero_extend:TI
6940                                   (match_operand:DI 1 "nonimmediate_operand" ""))
6941                                 (zero_extend:TI
6942                                   (match_operand:DI 2 "register_operand" "")))
6943                        (const_int 64))))
6944               (clobber (match_scratch:DI 3 ""))
6945               (clobber (reg:CC 17))])]
6946   "TARGET_64BIT"
6947   "")
6949 (define_insn "*umuldi3_highpart_rex64"
6950   [(set (match_operand:DI 0 "register_operand" "=d")
6951         (truncate:DI
6952           (lshiftrt:TI
6953             (mult:TI (zero_extend:TI
6954                        (match_operand:DI 1 "nonimmediate_operand" "%a"))
6955                      (zero_extend:TI
6956                        (match_operand:DI 2 "nonimmediate_operand" "rm")))
6957             (const_int 64))))
6958    (clobber (match_scratch:DI 3 "=1"))
6959    (clobber (reg:CC 17))]
6960   "TARGET_64BIT
6961    && (GET_CODE (operands[1]) != MEM || GET_CODE (operands[2]) != MEM)"
6962   "mul{q}\t%2"
6963   [(set_attr "type" "imul")
6964    (set_attr "ppro_uops" "few")
6965    (set_attr "length_immediate" "0")
6966    (set_attr "mode" "DI")])
6968 (define_expand "umulsi3_highpart"
6969   [(parallel [(set (match_operand:SI 0 "register_operand" "")
6970                    (truncate:SI
6971                      (lshiftrt:DI
6972                        (mult:DI (zero_extend:DI
6973                                   (match_operand:SI 1 "nonimmediate_operand" ""))
6974                                 (zero_extend:DI
6975                                   (match_operand:SI 2 "register_operand" "")))
6976                        (const_int 32))))
6977               (clobber (match_scratch:SI 3 ""))
6978               (clobber (reg:CC 17))])]
6979   ""
6980   "")
6982 (define_insn "*umulsi3_highpart_insn"
6983   [(set (match_operand:SI 0 "register_operand" "=d")
6984         (truncate:SI
6985           (lshiftrt:DI
6986             (mult:DI (zero_extend:DI
6987                        (match_operand:SI 1 "nonimmediate_operand" "%a"))
6988                      (zero_extend:DI
6989                        (match_operand:SI 2 "nonimmediate_operand" "rm")))
6990             (const_int 32))))
6991    (clobber (match_scratch:SI 3 "=1"))
6992    (clobber (reg:CC 17))]
6993   "GET_CODE (operands[1]) != MEM || GET_CODE (operands[2]) != MEM"
6994   "mul{l}\t%2"
6995   [(set_attr "type" "imul")
6996    (set_attr "ppro_uops" "few")
6997    (set_attr "length_immediate" "0")
6998    (set_attr "mode" "SI")])
7000 (define_insn "*umulsi3_highpart_zext"
7001   [(set (match_operand:DI 0 "register_operand" "=d")
7002         (zero_extend:DI (truncate:SI
7003           (lshiftrt:DI
7004             (mult:DI (zero_extend:DI
7005                        (match_operand:SI 1 "nonimmediate_operand" "%a"))
7006                      (zero_extend:DI
7007                        (match_operand:SI 2 "nonimmediate_operand" "rm")))
7008             (const_int 32)))))
7009    (clobber (match_scratch:SI 3 "=1"))
7010    (clobber (reg:CC 17))]
7011   "TARGET_64BIT
7012    && (GET_CODE (operands[1]) != MEM || GET_CODE (operands[2]) != MEM)"
7013   "mul{l}\t%2"
7014   [(set_attr "type" "imul")
7015    (set_attr "ppro_uops" "few")
7016    (set_attr "length_immediate" "0")
7017    (set_attr "mode" "SI")])
7019 (define_expand "smuldi3_highpart"
7020   [(parallel [(set (match_operand:DI 0 "register_operand" "=d")
7021                    (truncate:DI
7022                      (lshiftrt:TI
7023                        (mult:TI (sign_extend:TI
7024                                   (match_operand:DI 1 "nonimmediate_operand" ""))
7025                                 (sign_extend:TI
7026                                   (match_operand:DI 2 "register_operand" "")))
7027                        (const_int 64))))
7028               (clobber (match_scratch:DI 3 ""))
7029               (clobber (reg:CC 17))])]
7030   "TARGET_64BIT"
7031   "")
7033 (define_insn "*smuldi3_highpart_rex64"
7034   [(set (match_operand:DI 0 "register_operand" "=d")
7035         (truncate:DI
7036           (lshiftrt:TI
7037             (mult:TI (sign_extend:TI
7038                        (match_operand:DI 1 "nonimmediate_operand" "%a"))
7039                      (sign_extend:TI
7040                        (match_operand:DI 2 "nonimmediate_operand" "rm")))
7041             (const_int 64))))
7042    (clobber (match_scratch:DI 3 "=1"))
7043    (clobber (reg:CC 17))]
7044   "TARGET_64BIT
7045    && (GET_CODE (operands[1]) != MEM || GET_CODE (operands[2]) != MEM)"
7046   "imul{q}\t%2"
7047   [(set_attr "type" "imul")
7048    (set_attr "ppro_uops" "few")
7049    (set_attr "mode" "DI")])
7051 (define_expand "smulsi3_highpart"
7052   [(parallel [(set (match_operand:SI 0 "register_operand" "")
7053                    (truncate:SI
7054                      (lshiftrt:DI
7055                        (mult:DI (sign_extend:DI
7056                                   (match_operand:SI 1 "nonimmediate_operand" ""))
7057                                 (sign_extend:DI
7058                                   (match_operand:SI 2 "register_operand" "")))
7059                        (const_int 32))))
7060               (clobber (match_scratch:SI 3 ""))
7061               (clobber (reg:CC 17))])]
7062   ""
7063   "")
7065 (define_insn "*smulsi3_highpart_insn"
7066   [(set (match_operand:SI 0 "register_operand" "=d")
7067         (truncate:SI
7068           (lshiftrt:DI
7069             (mult:DI (sign_extend:DI
7070                        (match_operand:SI 1 "nonimmediate_operand" "%a"))
7071                      (sign_extend:DI
7072                        (match_operand:SI 2 "nonimmediate_operand" "rm")))
7073             (const_int 32))))
7074    (clobber (match_scratch:SI 3 "=1"))
7075    (clobber (reg:CC 17))]
7076   "GET_CODE (operands[1]) != MEM || GET_CODE (operands[2]) != MEM"
7077   "imul{l}\t%2"
7078   [(set_attr "type" "imul")
7079    (set_attr "ppro_uops" "few")
7080    (set_attr "mode" "SI")])
7082 (define_insn "*smulsi3_highpart_zext"
7083   [(set (match_operand:DI 0 "register_operand" "=d")
7084         (zero_extend:DI (truncate:SI
7085           (lshiftrt:DI
7086             (mult:DI (sign_extend:DI
7087                        (match_operand:SI 1 "nonimmediate_operand" "%a"))
7088                      (sign_extend:DI
7089                        (match_operand:SI 2 "nonimmediate_operand" "rm")))
7090             (const_int 32)))))
7091    (clobber (match_scratch:SI 3 "=1"))
7092    (clobber (reg:CC 17))]
7093   "TARGET_64BIT
7094    && (GET_CODE (operands[1]) != MEM || GET_CODE (operands[2]) != MEM)"
7095   "imul{l}\t%2"
7096   [(set_attr "type" "imul")
7097    (set_attr "ppro_uops" "few")
7098    (set_attr "mode" "SI")])
7100 ;; The patterns that match these are at the end of this file.
7102 (define_expand "mulxf3"
7103   [(set (match_operand:XF 0 "register_operand" "")
7104         (mult:XF (match_operand:XF 1 "register_operand" "")
7105                  (match_operand:XF 2 "register_operand" "")))]
7106   "!TARGET_64BIT && TARGET_80387"
7107   "")
7109 (define_expand "multf3"
7110   [(set (match_operand:TF 0 "register_operand" "")
7111         (mult:TF (match_operand:TF 1 "register_operand" "")
7112                  (match_operand:TF 2 "register_operand" "")))]
7113   "TARGET_80387"
7114   "")
7116 (define_expand "muldf3"
7117   [(set (match_operand:DF 0 "register_operand" "")
7118         (mult:DF (match_operand:DF 1 "register_operand" "")
7119                  (match_operand:DF 2 "nonimmediate_operand" "")))]
7120   "TARGET_80387 || (TARGET_SSE2 && TARGET_SSE_MATH)"
7121   "")
7123 (define_expand "mulsf3"
7124   [(set (match_operand:SF 0 "register_operand" "")
7125         (mult:SF (match_operand:SF 1 "register_operand" "")
7126                  (match_operand:SF 2 "nonimmediate_operand" "")))]
7127   "TARGET_80387 || TARGET_SSE_MATH"
7128   "")
7130 ;; Divide instructions
7132 (define_insn "divqi3"
7133   [(set (match_operand:QI 0 "register_operand" "=a")
7134         (div:QI (match_operand:HI 1 "register_operand" "0")
7135                 (match_operand:QI 2 "nonimmediate_operand" "qm")))
7136    (clobber (reg:CC 17))]
7137   "TARGET_QIMODE_MATH"
7138   "idiv{b}\t%2"
7139   [(set_attr "type" "idiv")
7140    (set_attr "mode" "QI")
7141    (set_attr "ppro_uops" "few")])
7143 (define_insn "udivqi3"
7144   [(set (match_operand:QI 0 "register_operand" "=a")
7145         (udiv:QI (match_operand:HI 1 "register_operand" "0")
7146                  (match_operand:QI 2 "nonimmediate_operand" "qm")))
7147    (clobber (reg:CC 17))]
7148   "TARGET_QIMODE_MATH"
7149   "div{b}\t%2"
7150   [(set_attr "type" "idiv")
7151    (set_attr "mode" "QI")
7152    (set_attr "ppro_uops" "few")])
7154 ;; The patterns that match these are at the end of this file.
7156 (define_expand "divxf3"
7157   [(set (match_operand:XF 0 "register_operand" "")
7158         (div:XF (match_operand:XF 1 "register_operand" "")
7159                 (match_operand:XF 2 "register_operand" "")))]
7160   "!TARGET_64BIT && TARGET_80387"
7161   "")
7163 (define_expand "divtf3"
7164   [(set (match_operand:TF 0 "register_operand" "")
7165         (div:TF (match_operand:TF 1 "register_operand" "")
7166                 (match_operand:TF 2 "register_operand" "")))]
7167   "TARGET_80387"
7168   "")
7170 (define_expand "divdf3"
7171   [(set (match_operand:DF 0 "register_operand" "")
7172         (div:DF (match_operand:DF 1 "register_operand" "")
7173                 (match_operand:DF 2 "nonimmediate_operand" "")))]
7174    "TARGET_80387 || (TARGET_SSE2 && TARGET_SSE_MATH)"
7175    "")
7177 (define_expand "divsf3"
7178   [(set (match_operand:SF 0 "register_operand" "")
7179         (div:SF (match_operand:SF 1 "register_operand" "")
7180                 (match_operand:SF 2 "nonimmediate_operand" "")))]
7181   "TARGET_80387 || TARGET_SSE_MATH"
7182   "")
7184 ;; Remainder instructions.
7186 (define_expand "divmoddi4"
7187   [(parallel [(set (match_operand:DI 0 "register_operand" "")
7188                    (div:DI (match_operand:DI 1 "register_operand" "")
7189                            (match_operand:DI 2 "nonimmediate_operand" "")))
7190               (set (match_operand:DI 3 "register_operand" "")
7191                    (mod:DI (match_dup 1) (match_dup 2)))
7192               (clobber (reg:CC 17))])]
7193   "TARGET_64BIT"
7194   "")
7196 ;; Allow to come the parameter in eax or edx to avoid extra moves.
7197 ;; Penalize eax case sligthly because it results in worse scheduling
7198 ;; of code.
7199 (define_insn "*divmoddi4_nocltd_rex64"
7200   [(set (match_operand:DI 0 "register_operand" "=&a,?a")
7201         (div:DI (match_operand:DI 2 "register_operand" "1,0")
7202                 (match_operand:DI 3 "nonimmediate_operand" "rm,rm")))
7203    (set (match_operand:DI 1 "register_operand" "=&d,&d")
7204         (mod:DI (match_dup 2) (match_dup 3)))
7205    (clobber (reg:CC 17))]
7206   "TARGET_64BIT && !optimize_size && !TARGET_USE_CLTD"
7207   "#"
7208   [(set_attr "type" "multi")])
7210 (define_insn "*divmoddi4_cltd_rex64"
7211   [(set (match_operand:DI 0 "register_operand" "=a")
7212         (div:DI (match_operand:DI 2 "register_operand" "a")
7213                 (match_operand:DI 3 "nonimmediate_operand" "rm")))
7214    (set (match_operand:DI 1 "register_operand" "=&d")
7215         (mod:DI (match_dup 2) (match_dup 3)))
7216    (clobber (reg:CC 17))]
7217   "TARGET_64BIT && (optimize_size || TARGET_USE_CLTD)"
7218   "#"
7219   [(set_attr "type" "multi")])
7221 (define_insn "*divmoddi_noext_rex64"
7222   [(set (match_operand:DI 0 "register_operand" "=a")
7223         (div:DI (match_operand:DI 1 "register_operand" "0")
7224                 (match_operand:DI 2 "nonimmediate_operand" "rm")))
7225    (set (match_operand:DI 3 "register_operand" "=d")
7226         (mod:DI (match_dup 1) (match_dup 2)))
7227    (use (match_operand:DI 4 "register_operand" "3"))
7228    (clobber (reg:CC 17))]
7229   "TARGET_64BIT"
7230   "idiv{q}\t%2"
7231   [(set_attr "type" "idiv")
7232    (set_attr "mode" "DI")
7233    (set_attr "ppro_uops" "few")])
7235 (define_split
7236   [(set (match_operand:DI 0 "register_operand" "")
7237         (div:DI (match_operand:DI 1 "register_operand" "")
7238                 (match_operand:DI 2 "nonimmediate_operand" "")))
7239    (set (match_operand:DI 3 "register_operand" "")
7240         (mod:DI (match_dup 1) (match_dup 2)))
7241    (clobber (reg:CC 17))]
7242   "TARGET_64BIT && reload_completed"
7243   [(parallel [(set (match_dup 3)
7244                    (ashiftrt:DI (match_dup 4) (const_int 63)))
7245               (clobber (reg:CC 17))])
7246    (parallel [(set (match_dup 0)
7247                    (div:DI (reg:DI 0) (match_dup 2)))
7248               (set (match_dup 3)
7249                    (mod:DI (reg:DI 0) (match_dup 2)))
7250               (use (match_dup 3))
7251               (clobber (reg:CC 17))])]
7253   /* Avoid use of cltd in favour of a mov+shift.  */
7254   if (!TARGET_USE_CLTD && !optimize_size)
7255     {
7256       if (true_regnum (operands[1]))
7257         emit_move_insn (operands[0], operands[1]);
7258       else
7259         emit_move_insn (operands[3], operands[1]);
7260       operands[4] = operands[3];
7261     }
7262   else
7263     {
7264       if (true_regnum (operands[1]))
7265         abort();
7266       operands[4] = operands[1];
7267     }
7271 (define_expand "divmodsi4"
7272   [(parallel [(set (match_operand:SI 0 "register_operand" "")
7273                    (div:SI (match_operand:SI 1 "register_operand" "")
7274                            (match_operand:SI 2 "nonimmediate_operand" "")))
7275               (set (match_operand:SI 3 "register_operand" "")
7276                    (mod:SI (match_dup 1) (match_dup 2)))
7277               (clobber (reg:CC 17))])]
7278   ""
7279   "")
7281 ;; Allow to come the parameter in eax or edx to avoid extra moves.
7282 ;; Penalize eax case sligthly because it results in worse scheduling
7283 ;; of code.
7284 (define_insn "*divmodsi4_nocltd"
7285   [(set (match_operand:SI 0 "register_operand" "=&a,?a")
7286         (div:SI (match_operand:SI 2 "register_operand" "1,0")
7287                 (match_operand:SI 3 "nonimmediate_operand" "rm,rm")))
7288    (set (match_operand:SI 1 "register_operand" "=&d,&d")
7289         (mod:SI (match_dup 2) (match_dup 3)))
7290    (clobber (reg:CC 17))]
7291   "!optimize_size && !TARGET_USE_CLTD"
7292   "#"
7293   [(set_attr "type" "multi")])
7295 (define_insn "*divmodsi4_cltd"
7296   [(set (match_operand:SI 0 "register_operand" "=a")
7297         (div:SI (match_operand:SI 2 "register_operand" "a")
7298                 (match_operand:SI 3 "nonimmediate_operand" "rm")))
7299    (set (match_operand:SI 1 "register_operand" "=&d")
7300         (mod:SI (match_dup 2) (match_dup 3)))
7301    (clobber (reg:CC 17))]
7302   "optimize_size || TARGET_USE_CLTD"
7303   "#"
7304   [(set_attr "type" "multi")])
7306 (define_insn "*divmodsi_noext"
7307   [(set (match_operand:SI 0 "register_operand" "=a")
7308         (div:SI (match_operand:SI 1 "register_operand" "0")
7309                 (match_operand:SI 2 "nonimmediate_operand" "rm")))
7310    (set (match_operand:SI 3 "register_operand" "=d")
7311         (mod:SI (match_dup 1) (match_dup 2)))
7312    (use (match_operand:SI 4 "register_operand" "3"))
7313    (clobber (reg:CC 17))]
7314   ""
7315   "idiv{l}\t%2"
7316   [(set_attr "type" "idiv")
7317    (set_attr "mode" "SI")
7318    (set_attr "ppro_uops" "few")])
7320 (define_split
7321   [(set (match_operand:SI 0 "register_operand" "")
7322         (div:SI (match_operand:SI 1 "register_operand" "")
7323                 (match_operand:SI 2 "nonimmediate_operand" "")))
7324    (set (match_operand:SI 3 "register_operand" "")
7325         (mod:SI (match_dup 1) (match_dup 2)))
7326    (clobber (reg:CC 17))]
7327   "reload_completed"
7328   [(parallel [(set (match_dup 3)
7329                    (ashiftrt:SI (match_dup 4) (const_int 31)))
7330               (clobber (reg:CC 17))])
7331    (parallel [(set (match_dup 0)
7332                    (div:SI (reg:SI 0) (match_dup 2)))
7333               (set (match_dup 3)
7334                    (mod:SI (reg:SI 0) (match_dup 2)))
7335               (use (match_dup 3))
7336               (clobber (reg:CC 17))])]
7338   /* Avoid use of cltd in favour of a mov+shift.  */
7339   if (!TARGET_USE_CLTD && !optimize_size)
7340     {
7341       if (true_regnum (operands[1]))
7342         emit_move_insn (operands[0], operands[1]);
7343       else
7344         emit_move_insn (operands[3], operands[1]);
7345       operands[4] = operands[3];
7346     }
7347   else
7348     {
7349       if (true_regnum (operands[1]))
7350         abort();
7351       operands[4] = operands[1];
7352     }
7354 ;; %%% Split me.
7355 (define_insn "divmodhi4"
7356   [(set (match_operand:HI 0 "register_operand" "=a")
7357         (div:HI (match_operand:HI 1 "register_operand" "0")
7358                 (match_operand:HI 2 "nonimmediate_operand" "rm")))
7359    (set (match_operand:HI 3 "register_operand" "=&d")
7360         (mod:HI (match_dup 1) (match_dup 2)))
7361    (clobber (reg:CC 17))]
7362   "TARGET_HIMODE_MATH"
7363   "cwtd\;idiv{w}\t%2"
7364   [(set_attr "type" "multi")
7365    (set_attr "length_immediate" "0")
7366    (set_attr "mode" "SI")])
7368 (define_insn "udivmoddi4"
7369   [(set (match_operand:DI 0 "register_operand" "=a")
7370         (udiv:DI (match_operand:DI 1 "register_operand" "0")
7371                  (match_operand:DI 2 "nonimmediate_operand" "rm")))
7372    (set (match_operand:DI 3 "register_operand" "=&d")
7373         (umod:DI (match_dup 1) (match_dup 2)))
7374    (clobber (reg:CC 17))]
7375   "TARGET_64BIT"
7376   "xor{q}\t%3, %3\;div{q}\t%2"
7377   [(set_attr "type" "multi")
7378    (set_attr "length_immediate" "0")
7379    (set_attr "mode" "DI")])
7381 (define_insn "*udivmoddi4_noext"
7382   [(set (match_operand:DI 0 "register_operand" "=a")
7383         (udiv:DI (match_operand:DI 1 "register_operand" "0")
7384                  (match_operand:DI 2 "nonimmediate_operand" "rm")))
7385    (set (match_operand:DI 3 "register_operand" "=d")
7386         (umod:DI (match_dup 1) (match_dup 2)))
7387    (use (match_dup 3))
7388    (clobber (reg:CC 17))]
7389   "TARGET_64BIT"
7390   "div{q}\t%2"
7391   [(set_attr "type" "idiv")
7392    (set_attr "ppro_uops" "few")
7393    (set_attr "mode" "DI")])
7395 (define_split
7396   [(set (match_operand:DI 0 "register_operand" "")
7397         (udiv:DI (match_operand:DI 1 "register_operand" "")
7398                  (match_operand:DI 2 "nonimmediate_operand" "")))
7399    (set (match_operand:DI 3 "register_operand" "")
7400         (umod:DI (match_dup 1) (match_dup 2)))
7401    (clobber (reg:CC 17))]
7402   "TARGET_64BIT && reload_completed"
7403   [(set (match_dup 3) (const_int 0))
7404    (parallel [(set (match_dup 0)
7405                    (udiv:DI (match_dup 1) (match_dup 2)))
7406               (set (match_dup 3)
7407                    (umod:DI (match_dup 1) (match_dup 2)))
7408               (use (match_dup 3))
7409               (clobber (reg:CC 17))])]
7410   "")
7412 (define_insn "udivmodsi4"
7413   [(set (match_operand:SI 0 "register_operand" "=a")
7414         (udiv:SI (match_operand:SI 1 "register_operand" "0")
7415                  (match_operand:SI 2 "nonimmediate_operand" "rm")))
7416    (set (match_operand:SI 3 "register_operand" "=&d")
7417         (umod:SI (match_dup 1) (match_dup 2)))
7418    (clobber (reg:CC 17))]
7419   ""
7420   "xor{l}\t%3, %3\;div{l}\t%2"
7421   [(set_attr "type" "multi")
7422    (set_attr "length_immediate" "0")
7423    (set_attr "mode" "SI")])
7425 (define_insn "*udivmodsi4_noext"
7426   [(set (match_operand:SI 0 "register_operand" "=a")
7427         (udiv:SI (match_operand:SI 1 "register_operand" "0")
7428                  (match_operand:SI 2 "nonimmediate_operand" "rm")))
7429    (set (match_operand:SI 3 "register_operand" "=d")
7430         (umod:SI (match_dup 1) (match_dup 2)))
7431    (use (match_dup 3))
7432    (clobber (reg:CC 17))]
7433   ""
7434   "div{l}\t%2"
7435   [(set_attr "type" "idiv")
7436    (set_attr "ppro_uops" "few")
7437    (set_attr "mode" "SI")])
7439 (define_split
7440   [(set (match_operand:SI 0 "register_operand" "")
7441         (udiv:SI (match_operand:SI 1 "register_operand" "")
7442                  (match_operand:SI 2 "nonimmediate_operand" "")))
7443    (set (match_operand:SI 3 "register_operand" "")
7444         (umod:SI (match_dup 1) (match_dup 2)))
7445    (clobber (reg:CC 17))]
7446   "reload_completed"
7447   [(set (match_dup 3) (const_int 0))
7448    (parallel [(set (match_dup 0)
7449                    (udiv:SI (match_dup 1) (match_dup 2)))
7450               (set (match_dup 3)
7451                    (umod:SI (match_dup 1) (match_dup 2)))
7452               (use (match_dup 3))
7453               (clobber (reg:CC 17))])]
7454   "")
7456 (define_expand "udivmodhi4"
7457   [(set (match_dup 4) (const_int 0))
7458    (parallel [(set (match_operand:HI 0 "register_operand" "")
7459                    (udiv:HI (match_operand:HI 1 "register_operand" "")
7460                             (match_operand:HI 2 "nonimmediate_operand" "")))
7461               (set (match_operand:HI 3 "register_operand" "")
7462                    (umod:HI (match_dup 1) (match_dup 2)))
7463               (use (match_dup 4))
7464               (clobber (reg:CC 17))])]
7465   "TARGET_HIMODE_MATH"
7466   "operands[4] = gen_reg_rtx (HImode);")
7468 (define_insn "*udivmodhi_noext"
7469   [(set (match_operand:HI 0 "register_operand" "=a")
7470         (udiv:HI (match_operand:HI 1 "register_operand" "0")
7471                  (match_operand:HI 2 "nonimmediate_operand" "rm")))
7472    (set (match_operand:HI 3 "register_operand" "=d")
7473         (umod:HI (match_dup 1) (match_dup 2)))
7474    (use (match_operand:HI 4 "register_operand" "3"))
7475    (clobber (reg:CC 17))]
7476   ""
7477   "div{w}\t%2"
7478   [(set_attr "type" "idiv")
7479    (set_attr "mode" "HI")
7480    (set_attr "ppro_uops" "few")])
7482 ;; We can not use div/idiv for double division, because it causes
7483 ;; "division by zero" on the overflow and that's not what we expect
7484 ;; from truncate.  Because true (non truncating) double division is
7485 ;; never generated, we can't create this insn anyway.
7487 ;(define_insn ""
7488 ;  [(set (match_operand:SI 0 "register_operand" "=a")
7489 ;       (truncate:SI
7490 ;         (udiv:DI (match_operand:DI 1 "register_operand" "A")
7491 ;                  (zero_extend:DI
7492 ;                    (match_operand:SI 2 "nonimmediate_operand" "rm")))))
7493 ;   (set (match_operand:SI 3 "register_operand" "=d")
7494 ;       (truncate:SI
7495 ;         (umod:DI (match_dup 1) (zero_extend:DI (match_dup 2)))))
7496 ;   (clobber (reg:CC 17))]
7497 ;  ""
7498 ;  "div{l}\t{%2, %0|%0, %2}"
7499 ;  [(set_attr "type" "idiv")
7500 ;   (set_attr "ppro_uops" "few")])
7502 ;;- Logical AND instructions
7504 ;; On Pentium, "test imm, reg" is pairable only with eax, ax, and al.
7505 ;; Note that this excludes ah.
7507 (define_insn "*testdi_1_rex64"
7508   [(set (reg 17)
7509         (compare
7510           (and:DI (match_operand:DI 0 "nonimmediate_operand" "%*a,r,*a,r,rm")
7511                   (match_operand:DI 1 "x86_64_szext_nonmemory_operand" "Z,Z,e,e,re"))
7512           (const_int 0)))]
7513   "TARGET_64BIT && ix86_match_ccmode (insn, CCNOmode)"
7514   "@
7515    test{l}\t{%k1, %k0|%k0, %k1} 
7516    test{l}\t{%k1, %k0|%k0, %k1} 
7517    test{q}\t{%1, %0|%0, %1} 
7518    test{q}\t{%1, %0|%0, %1} 
7519    test{q}\t{%1, %0|%0, %1}"
7520   [(set_attr "type" "test")
7521    (set_attr "modrm" "0,1,0,1,1")
7522    (set_attr "mode" "SI,SI,DI,DI,DI")
7523    (set_attr "pent_pair" "uv,np,uv,np,uv")])
7525 (define_insn "testsi_1"
7526   [(set (reg 17)
7527         (compare
7528           (and:SI (match_operand:SI 0 "nonimmediate_operand" "%*a,r,rm")
7529                   (match_operand:SI 1 "nonmemory_operand" "in,in,rin"))
7530           (const_int 0)))]
7531   "ix86_match_ccmode (insn, CCNOmode)"
7532   "test{l}\t{%1, %0|%0, %1}"
7533   [(set_attr "type" "test")
7534    (set_attr "modrm" "0,1,1")
7535    (set_attr "mode" "SI")
7536    (set_attr "pent_pair" "uv,np,uv")])
7538 (define_expand "testsi_ccno_1"
7539   [(set (reg:CCNO 17)
7540         (compare:CCNO
7541           (and:SI (match_operand:SI 0 "nonimmediate_operand" "")
7542                   (match_operand:SI 1 "nonmemory_operand" ""))
7543           (const_int 0)))]
7544   ""
7545   "")
7547 (define_insn "*testhi_1"
7548   [(set (reg 17)
7549         (compare (and:HI (match_operand:HI 0 "nonimmediate_operand" "%*a,r,rm")
7550                          (match_operand:HI 1 "nonmemory_operand" "n,n,rn"))
7551                  (const_int 0)))]
7552   "ix86_match_ccmode (insn, CCNOmode)"
7553   "test{w}\t{%1, %0|%0, %1}"
7554   [(set_attr "type" "test")
7555    (set_attr "modrm" "0,1,1")
7556    (set_attr "mode" "HI")
7557    (set_attr "pent_pair" "uv,np,uv")])
7559 (define_expand "testqi_ccz_1"
7560   [(set (reg:CCZ 17)
7561         (compare:CCZ (and:QI (match_operand:QI 0 "nonimmediate_operand" "")
7562                              (match_operand:QI 1 "nonmemory_operand" ""))
7563                  (const_int 0)))]
7564   ""
7565   "")
7567 (define_insn "*testqi_1"
7568   [(set (reg 17)
7569         (compare (and:QI (match_operand:QI 0 "nonimmediate_operand" "%*a,q,qm,r")
7570                          (match_operand:QI 1 "nonmemory_operand" "n,n,qn,n"))
7571                  (const_int 0)))]
7572   "ix86_match_ccmode (insn, CCNOmode)"
7574   if (which_alternative == 3)
7575     {
7576       if (GET_CODE (operands[1]) == CONST_INT
7577           && (INTVAL (operands[1]) & 0xffffff00))
7578         operands[1] = GEN_INT (INTVAL (operands[1]) & 0xff);
7579       return "test{l}\t{%1, %k0|%k0, %1}";
7580     }
7581   return "test{b}\t{%1, %0|%0, %1}";
7583   [(set_attr "type" "test")
7584    (set_attr "modrm" "0,1,1,1")
7585    (set_attr "mode" "QI,QI,QI,SI")
7586    (set_attr "pent_pair" "uv,np,uv,np")])
7588 (define_expand "testqi_ext_ccno_0"
7589   [(set (reg:CCNO 17)
7590         (compare:CCNO
7591           (and:SI
7592             (zero_extract:SI
7593               (match_operand 0 "ext_register_operand" "")
7594               (const_int 8)
7595               (const_int 8))
7596             (match_operand 1 "const_int_operand" ""))
7597           (const_int 0)))]
7598   ""
7599   "")
7601 (define_insn "*testqi_ext_0"
7602   [(set (reg 17)
7603         (compare
7604           (and:SI
7605             (zero_extract:SI
7606               (match_operand 0 "ext_register_operand" "Q")
7607               (const_int 8)
7608               (const_int 8))
7609             (match_operand 1 "const_int_operand" "n"))
7610           (const_int 0)))]
7611   "ix86_match_ccmode (insn, CCNOmode)"
7612   "test{b}\t{%1, %h0|%h0, %1}"
7613   [(set_attr "type" "test")
7614    (set_attr "mode" "QI")
7615    (set_attr "length_immediate" "1")
7616    (set_attr "pent_pair" "np")])
7618 (define_insn "*testqi_ext_1"
7619   [(set (reg 17)
7620         (compare
7621           (and:SI
7622             (zero_extract:SI
7623               (match_operand 0 "ext_register_operand" "Q")
7624               (const_int 8)
7625               (const_int 8))
7626             (zero_extend:SI
7627               (match_operand:QI 1 "nonimmediate_operand" "Qm")))
7628           (const_int 0)))]
7629   "!TARGET_64BIT && ix86_match_ccmode (insn, CCNOmode)"
7630   "test{b}\t{%1, %h0|%h0, %1}"
7631   [(set_attr "type" "test")
7632    (set_attr "mode" "QI")])
7634 (define_insn "*testqi_ext_1_rex64"
7635   [(set (reg 17)
7636         (compare
7637           (and:SI
7638             (zero_extract:SI
7639               (match_operand 0 "ext_register_operand" "Q")
7640               (const_int 8)
7641               (const_int 8))
7642             (zero_extend:SI
7643               (match_operand:QI 1 "register_operand" "Q")))
7644           (const_int 0)))]
7645   "TARGET_64BIT && ix86_match_ccmode (insn, CCNOmode)"
7646   "test{b}\t{%1, %h0|%h0, %1}"
7647   [(set_attr "type" "test")
7648    (set_attr "mode" "QI")])
7650 (define_insn "*testqi_ext_2"
7651   [(set (reg 17)
7652         (compare
7653           (and:SI
7654             (zero_extract:SI
7655               (match_operand 0 "ext_register_operand" "Q")
7656               (const_int 8)
7657               (const_int 8))
7658             (zero_extract:SI
7659               (match_operand 1 "ext_register_operand" "Q")
7660               (const_int 8)
7661               (const_int 8)))
7662           (const_int 0)))]
7663   "ix86_match_ccmode (insn, CCNOmode)"
7664   "test{b}\t{%h1, %h0|%h0, %h1}"
7665   [(set_attr "type" "test")
7666    (set_attr "mode" "QI")])
7668 ;; Combine likes to form bit extractions for some tests.  Humor it.
7669 (define_insn "*testqi_ext_3"
7670   [(set (reg 17)
7671         (compare (zero_extract:SI
7672                    (match_operand 0 "nonimmediate_operand" "rm")
7673                    (match_operand:SI 1 "const_int_operand" "")
7674                    (match_operand:SI 2 "const_int_operand" ""))
7675                  (const_int 0)))]
7676   "ix86_match_ccmode (insn, CCNOmode)
7677    && (GET_MODE (operands[0]) == SImode
7678        || (TARGET_64BIT && GET_MODE (operands[0]) == DImode)
7679        || GET_MODE (operands[0]) == HImode
7680        || GET_MODE (operands[0]) == QImode)"
7681   "#")
7683 (define_insn "*testqi_ext_3_rex64"
7684   [(set (reg 17)
7685         (compare (zero_extract:DI
7686                    (match_operand 0 "nonimmediate_operand" "rm")
7687                    (match_operand:DI 1 "const_int_operand" "")
7688                    (match_operand:DI 2 "const_int_operand" ""))
7689                  (const_int 0)))]
7690   "TARGET_64BIT
7691    && ix86_match_ccmode (insn, CCNOmode)
7692    /* The code below cannot deal with constants outside HOST_WIDE_INT.  */
7693    && INTVAL (operands[1]) + INTVAL (operands[2]) < HOST_BITS_PER_WIDE_INT
7694    /* Ensure that resulting mask is zero or sign extended operand.  */
7695    && (INTVAL (operands[1]) + INTVAL (operands[2]) <= 32
7696        || (INTVAL (operands[1]) + INTVAL (operands[2]) == 64
7697            && INTVAL (operands[1]) > 32))
7698    && (GET_MODE (operands[0]) == SImode
7699        || GET_MODE (operands[0]) == DImode
7700        || GET_MODE (operands[0]) == HImode
7701        || GET_MODE (operands[0]) == QImode)"
7702   "#")
7704 (define_split
7705   [(set (reg 17)
7706         (compare (zero_extract
7707                    (match_operand 0 "nonimmediate_operand" "")
7708                    (match_operand 1 "const_int_operand" "")
7709                    (match_operand 2 "const_int_operand" ""))
7710                  (const_int 0)))]
7711   "ix86_match_ccmode (insn, CCNOmode)"
7712   [(set (reg:CCNO 17) (compare:CCNO (match_dup 3) (const_int 0)))]
7714   HOST_WIDE_INT len = INTVAL (operands[1]);
7715   HOST_WIDE_INT pos = INTVAL (operands[2]);
7716   HOST_WIDE_INT mask;
7717   enum machine_mode mode, submode;
7719   mode = GET_MODE (operands[0]);
7720   if (GET_CODE (operands[0]) == MEM)
7721     {
7722       /* ??? Combine likes to put non-volatile mem extractions in QImode
7723          no matter the size of the test.  So find a mode that works.  */
7724       if (! MEM_VOLATILE_P (operands[0]))
7725         {
7726           mode = smallest_mode_for_size (pos + len, MODE_INT);
7727           operands[0] = adjust_address (operands[0], mode, 0);
7728         }
7729     }
7730   else if (GET_CODE (operands[0]) == SUBREG
7731            && (submode = GET_MODE (SUBREG_REG (operands[0])),
7732                GET_MODE_BITSIZE (mode) > GET_MODE_BITSIZE (submode))
7733            && pos + len <= GET_MODE_BITSIZE (submode))
7734     {
7735       /* Narrow a paradoxical subreg to prevent partial register stalls.  */
7736       mode = submode;
7737       operands[0] = SUBREG_REG (operands[0]);
7738     }
7739   else if (mode == HImode && pos + len <= 8)
7740     {
7741       /* Small HImode tests can be converted to QImode.  */
7742       mode = QImode;
7743       operands[0] = gen_lowpart (QImode, operands[0]);
7744     }
7746   mask  = ((HOST_WIDE_INT)1 << (pos + len)) - 1;
7747   mask &= ~(((HOST_WIDE_INT)1 << pos) - 1);
7749   operands[3] = gen_rtx_AND (mode, operands[0], gen_int_mode (mask, mode));
7752 ;; Convert HImode/SImode test instructions with immediate to QImode ones.
7753 ;; i386 does not allow to encode test with 8bit sign extended immediate, so
7754 ;; this is relatively important trick.
7755 ;; Do the converison only post-reload to avoid limiting of the register class
7756 ;; to QI regs.
7757 (define_split
7758   [(set (reg 17)
7759         (compare
7760           (and (match_operand 0 "register_operand" "")
7761                (match_operand 1 "const_int_operand" ""))
7762           (const_int 0)))]
7763    "reload_completed
7764     && QI_REG_P (operands[0])
7765     && ((ix86_match_ccmode (insn, CCZmode)
7766          && !(INTVAL (operands[1]) & ~(255 << 8)))
7767         || (ix86_match_ccmode (insn, CCNOmode)
7768             && !(INTVAL (operands[1]) & ~(127 << 8))))
7769     && GET_MODE (operands[0]) != QImode"
7770   [(set (reg:CCNO 17)
7771         (compare:CCNO
7772           (and:SI (zero_extract:SI (match_dup 0) (const_int 8) (const_int 8))
7773                   (match_dup 1))
7774           (const_int 0)))]
7775   "operands[0] = gen_lowpart (SImode, operands[0]);
7776    operands[1] = gen_int_mode (INTVAL (operands[1]) >> 8, SImode);")
7778 (define_split
7779   [(set (reg 17)
7780         (compare
7781           (and (match_operand 0 "nonimmediate_operand" "")
7782                (match_operand 1 "const_int_operand" ""))
7783           (const_int 0)))]
7784    "reload_completed
7785     && (!REG_P (operands[0]) || ANY_QI_REG_P (operands[0]))
7786     && ((ix86_match_ccmode (insn, CCZmode)
7787          && !(INTVAL (operands[1]) & ~255))
7788         || (ix86_match_ccmode (insn, CCNOmode)
7789             && !(INTVAL (operands[1]) & ~127)))
7790     && GET_MODE (operands[0]) != QImode"
7791   [(set (reg:CCNO 17)
7792         (compare:CCNO
7793           (and:QI (match_dup 0)
7794                   (match_dup 1))
7795           (const_int 0)))]
7796   "operands[0] = gen_lowpart (QImode, operands[0]);
7797    operands[1] = gen_lowpart (QImode, operands[1]);")
7800 ;; %%% This used to optimize known byte-wide and operations to memory,
7801 ;; and sometimes to QImode registers.  If this is considered useful,
7802 ;; it should be done with splitters.
7804 (define_expand "anddi3"
7805   [(set (match_operand:DI 0 "nonimmediate_operand" "")
7806         (and:DI (match_operand:DI 1 "nonimmediate_operand" "")
7807                 (match_operand:DI 2 "x86_64_szext_general_operand" "")))
7808    (clobber (reg:CC 17))]
7809   "TARGET_64BIT"
7810   "ix86_expand_binary_operator (AND, DImode, operands); DONE;")
7812 (define_insn "*anddi_1_rex64"
7813   [(set (match_operand:DI 0 "nonimmediate_operand" "=r,rm,r,r")
7814         (and:DI (match_operand:DI 1 "nonimmediate_operand" "%0,0,0,qm")
7815                 (match_operand:DI 2 "x86_64_szext_general_operand" "Z,re,rm,L")))
7816    (clobber (reg:CC 17))]
7817   "TARGET_64BIT && ix86_binary_operator_ok (AND, DImode, operands)"
7819   switch (get_attr_type (insn))
7820     {
7821     case TYPE_IMOVX:
7822       {
7823         enum machine_mode mode;
7825         if (GET_CODE (operands[2]) != CONST_INT)
7826           abort ();
7827         if (INTVAL (operands[2]) == 0xff)
7828           mode = QImode;
7829         else if (INTVAL (operands[2]) == 0xffff)
7830           mode = HImode;
7831         else
7832           abort ();
7833         
7834         operands[1] = gen_lowpart (mode, operands[1]);
7835         if (mode == QImode)
7836           return "movz{bq|x}\t{%1,%0|%0, %1}";
7837         else
7838           return "movz{wq|x}\t{%1,%0|%0, %1}";
7839       }
7841     default:
7842       if (! rtx_equal_p (operands[0], operands[1]))
7843         abort ();
7844       if (get_attr_mode (insn) == MODE_SI)
7845         return "and{l}\t{%k2, %k0|%k0, %k2}";
7846       else
7847         return "and{q}\t{%2, %0|%0, %2}";
7848     }
7850   [(set_attr "type" "alu,alu,alu,imovx")
7851    (set_attr "length_immediate" "*,*,*,0")
7852    (set_attr "mode" "SI,DI,DI,DI")])
7854 (define_insn "*anddi_2"
7855   [(set (reg 17)
7856         (compare (and:DI (match_operand:DI 1 "nonimmediate_operand" "%0,0,0")
7857                          (match_operand:DI 2 "x86_64_szext_general_operand" "Z,rem,re"))
7858                  (const_int 0)))
7859    (set (match_operand:DI 0 "nonimmediate_operand" "=r,r,rm")
7860         (and:DI (match_dup 1) (match_dup 2)))]
7861   "TARGET_64BIT && ix86_match_ccmode (insn, CCNOmode)
7862    && ix86_binary_operator_ok (AND, DImode, operands)"
7863   "@
7864    and{l}\t{%k2, %k0|%k0, %k2} 
7865    and{q}\t{%2, %0|%0, %2} 
7866    and{q}\t{%2, %0|%0, %2}"
7867   [(set_attr "type" "alu")
7868    (set_attr "mode" "SI,DI,DI")])
7870 (define_expand "andsi3"
7871   [(set (match_operand:SI 0 "nonimmediate_operand" "")
7872         (and:SI (match_operand:SI 1 "nonimmediate_operand" "")
7873                 (match_operand:SI 2 "general_operand" "")))
7874    (clobber (reg:CC 17))]
7875   ""
7876   "ix86_expand_binary_operator (AND, SImode, operands); DONE;")
7878 (define_insn "*andsi_1"
7879   [(set (match_operand:SI 0 "nonimmediate_operand" "=rm,r,r")
7880         (and:SI (match_operand:SI 1 "nonimmediate_operand" "%0,0,qm")
7881                 (match_operand:SI 2 "general_operand" "ri,rm,L")))
7882    (clobber (reg:CC 17))]
7883   "ix86_binary_operator_ok (AND, SImode, operands)"
7885   switch (get_attr_type (insn))
7886     {
7887     case TYPE_IMOVX:
7888       {
7889         enum machine_mode mode;
7891         if (GET_CODE (operands[2]) != CONST_INT)
7892           abort ();
7893         if (INTVAL (operands[2]) == 0xff)
7894           mode = QImode;
7895         else if (INTVAL (operands[2]) == 0xffff)
7896           mode = HImode;
7897         else
7898           abort ();
7899         
7900         operands[1] = gen_lowpart (mode, operands[1]);
7901         if (mode == QImode)
7902           return "movz{bl|x}\t{%1,%0|%0, %1}";
7903         else
7904           return "movz{wl|x}\t{%1,%0|%0, %1}";
7905       }
7907     default:
7908       if (! rtx_equal_p (operands[0], operands[1]))
7909         abort ();
7910       return "and{l}\t{%2, %0|%0, %2}";
7911     }
7913   [(set_attr "type" "alu,alu,imovx")
7914    (set_attr "length_immediate" "*,*,0")
7915    (set_attr "mode" "SI")])
7917 (define_split
7918   [(set (match_operand 0 "register_operand" "")
7919         (and (match_dup 0)
7920              (const_int -65536)))
7921    (clobber (reg:CC 17))]
7922   "optimize_size || (TARGET_FAST_PREFIX && !TARGET_PARTIAL_REG_STALL)"
7923   [(set (strict_low_part (match_dup 1)) (const_int 0))]
7924   "operands[1] = gen_lowpart (HImode, operands[0]);")
7926 (define_split
7927   [(set (match_operand 0 "ext_register_operand" "")
7928         (and (match_dup 0)
7929              (const_int -256)))
7930    (clobber (reg:CC 17))]
7931   "(optimize_size || !TARGET_PARTIAL_REG_STALL) && reload_completed"
7932   [(set (strict_low_part (match_dup 1)) (const_int 0))]
7933   "operands[1] = gen_lowpart (QImode, operands[0]);")
7935 (define_split
7936   [(set (match_operand 0 "ext_register_operand" "")
7937         (and (match_dup 0)
7938              (const_int -65281)))
7939    (clobber (reg:CC 17))]
7940   "(optimize_size || !TARGET_PARTIAL_REG_STALL) && reload_completed"
7941   [(parallel [(set (zero_extract:SI (match_dup 0)
7942                                     (const_int 8)
7943                                     (const_int 8))
7944                    (xor:SI 
7945                      (zero_extract:SI (match_dup 0)
7946                                       (const_int 8)
7947                                       (const_int 8))
7948                      (zero_extract:SI (match_dup 0)
7949                                       (const_int 8)
7950                                       (const_int 8))))
7951               (clobber (reg:CC 17))])]
7952   "operands[0] = gen_lowpart (SImode, operands[0]);")
7954 ;; See comment for addsi_1_zext why we do use nonimmediate_operand
7955 (define_insn "*andsi_1_zext"
7956   [(set (match_operand:DI 0 "register_operand" "=r")
7957         (zero_extend:DI
7958           (and:SI (match_operand:SI 1 "nonimmediate_operand" "%0")
7959                   (match_operand:SI 2 "general_operand" "rim"))))
7960    (clobber (reg:CC 17))]
7961   "TARGET_64BIT && ix86_binary_operator_ok (AND, SImode, operands)"
7962   "and{l}\t{%2, %k0|%k0, %2}"
7963   [(set_attr "type" "alu")
7964    (set_attr "mode" "SI")])
7966 (define_insn "*andsi_2"
7967   [(set (reg 17)
7968         (compare (and:SI (match_operand:SI 1 "nonimmediate_operand" "%0,0")
7969                          (match_operand:SI 2 "general_operand" "rim,ri"))
7970                  (const_int 0)))
7971    (set (match_operand:SI 0 "nonimmediate_operand" "=r,rm")
7972         (and:SI (match_dup 1) (match_dup 2)))]
7973   "ix86_match_ccmode (insn, CCNOmode)
7974    && ix86_binary_operator_ok (AND, SImode, operands)"
7975   "and{l}\t{%2, %0|%0, %2}"
7976   [(set_attr "type" "alu")
7977    (set_attr "mode" "SI")])
7979 ;; See comment for addsi_1_zext why we do use nonimmediate_operand
7980 (define_insn "*andsi_2_zext"
7981   [(set (reg 17)
7982         (compare (and:SI (match_operand:SI 1 "nonimmediate_operand" "%0")
7983                          (match_operand:SI 2 "general_operand" "rim"))
7984                  (const_int 0)))
7985    (set (match_operand:DI 0 "register_operand" "=r")
7986         (zero_extend:DI (and:SI (match_dup 1) (match_dup 2))))]
7987   "TARGET_64BIT && ix86_match_ccmode (insn, CCNOmode)
7988    && ix86_binary_operator_ok (AND, SImode, operands)"
7989   "and{l}\t{%2, %k0|%k0, %2}"
7990   [(set_attr "type" "alu")
7991    (set_attr "mode" "SI")])
7993 (define_expand "andhi3"
7994   [(set (match_operand:HI 0 "nonimmediate_operand" "")
7995         (and:HI (match_operand:HI 1 "nonimmediate_operand" "")
7996                 (match_operand:HI 2 "general_operand" "")))
7997    (clobber (reg:CC 17))]
7998   "TARGET_HIMODE_MATH"
7999   "ix86_expand_binary_operator (AND, HImode, operands); DONE;")
8001 (define_insn "*andhi_1"
8002   [(set (match_operand:HI 0 "nonimmediate_operand" "=rm,r,r")
8003         (and:HI (match_operand:HI 1 "nonimmediate_operand" "%0,0,qm")
8004                 (match_operand:HI 2 "general_operand" "ri,rm,L")))
8005    (clobber (reg:CC 17))]
8006   "ix86_binary_operator_ok (AND, HImode, operands)"
8008   switch (get_attr_type (insn))
8009     {
8010     case TYPE_IMOVX:
8011       if (GET_CODE (operands[2]) != CONST_INT)
8012         abort ();
8013       if (INTVAL (operands[2]) == 0xff)
8014         return "movz{bl|x}\t{%b1, %k0|%k0, %b1}";
8015       abort ();
8017     default:
8018       if (! rtx_equal_p (operands[0], operands[1]))
8019         abort ();
8021       return "and{w}\t{%2, %0|%0, %2}";
8022     }
8024   [(set_attr "type" "alu,alu,imovx")
8025    (set_attr "length_immediate" "*,*,0")
8026    (set_attr "mode" "HI,HI,SI")])
8028 (define_insn "*andhi_2"
8029   [(set (reg 17)
8030         (compare (and:HI (match_operand:HI 1 "nonimmediate_operand" "%0,0")
8031                          (match_operand:HI 2 "general_operand" "rim,ri"))
8032                  (const_int 0)))
8033    (set (match_operand:HI 0 "nonimmediate_operand" "=r,rm")
8034         (and:HI (match_dup 1) (match_dup 2)))]
8035   "ix86_match_ccmode (insn, CCNOmode)
8036    && ix86_binary_operator_ok (AND, HImode, operands)"
8037   "and{w}\t{%2, %0|%0, %2}"
8038   [(set_attr "type" "alu")
8039    (set_attr "mode" "HI")])
8041 (define_expand "andqi3"
8042   [(set (match_operand:QI 0 "nonimmediate_operand" "")
8043         (and:QI (match_operand:QI 1 "nonimmediate_operand" "")
8044                 (match_operand:QI 2 "general_operand" "")))
8045    (clobber (reg:CC 17))]
8046   "TARGET_QIMODE_MATH"
8047   "ix86_expand_binary_operator (AND, QImode, operands); DONE;")
8049 ;; %%% Potential partial reg stall on alternative 2.  What to do?
8050 (define_insn "*andqi_1"
8051   [(set (match_operand:QI 0 "nonimmediate_operand" "=qm,q,r")
8052         (and:QI (match_operand:QI 1 "nonimmediate_operand" "%0,0,0")
8053                 (match_operand:QI 2 "general_operand" "qi,qmi,ri")))
8054    (clobber (reg:CC 17))]
8055   "ix86_binary_operator_ok (AND, QImode, operands)"
8056   "@
8057    and{b}\t{%2, %0|%0, %2}
8058    and{b}\t{%2, %0|%0, %2}
8059    and{l}\t{%k2, %k0|%k0, %k2}"
8060   [(set_attr "type" "alu")
8061    (set_attr "mode" "QI,QI,SI")])
8063 (define_insn "*andqi_1_slp"
8064   [(set (strict_low_part (match_operand:QI 0 "nonimmediate_operand" "+qm,q"))
8065         (and:QI (match_dup 0)
8066                 (match_operand:QI 1 "general_operand" "qi,qmi")))
8067    (clobber (reg:CC 17))]
8068   "! TARGET_PARTIAL_REG_STALL || optimize_size"
8069   "and{b}\t{%1, %0|%0, %1}"
8070   [(set_attr "type" "alu1")
8071    (set_attr "mode" "QI")])
8073 (define_insn "*andqi_2"
8074   [(set (reg 17)
8075         (compare (and:QI
8076                    (match_operand:QI 1 "nonimmediate_operand" "%0,0,0")
8077                    (match_operand:QI 2 "general_operand" "qim,qi,i"))
8078                  (const_int 0)))
8079    (set (match_operand:QI 0 "nonimmediate_operand" "=q,qm,*r")
8080         (and:QI (match_dup 1) (match_dup 2)))]
8081   "ix86_match_ccmode (insn, CCNOmode)
8082    && ix86_binary_operator_ok (AND, QImode, operands)"
8084   if (which_alternative == 2)
8085     {
8086       if (GET_CODE (operands[2]) == CONST_INT
8087           && (INTVAL (operands[2]) & 0xffffff00))
8088         operands[2] = GEN_INT (INTVAL (operands[2]) & 0xff);
8089       return "and{l}\t{%2, %k0|%k0, %2}";
8090     }
8091   return "and{b}\t{%2, %0|%0, %2}";
8093   [(set_attr "type" "alu")
8094    (set_attr "mode" "QI,QI,SI")])
8096 (define_insn "*andqi_2_slp"
8097   [(set (reg 17)
8098         (compare (and:QI
8099                    (match_operand:QI 0 "nonimmediate_operand" "+q,qm")
8100                    (match_operand:QI 1 "nonimmediate_operand" "qmi,qi"))
8101                  (const_int 0)))
8102    (set (strict_low_part (match_dup 0))
8103         (and:QI (match_dup 0) (match_dup 1)))]
8104   "(! TARGET_PARTIAL_REG_STALL || optimize_size)
8105    && ix86_match_ccmode (insn, CCNOmode)"
8106   "and{b}\t{%1, %0|%0, %1}"
8107   [(set_attr "type" "alu1")
8108    (set_attr "mode" "QI")])
8110 ;; ??? A bug in recog prevents it from recognizing a const_int as an
8111 ;; operand to zero_extend in andqi_ext_1.  It was checking explicitly
8112 ;; for a QImode operand, which of course failed.
8114 (define_insn "andqi_ext_0"
8115   [(set (zero_extract:SI (match_operand 0 "ext_register_operand" "=Q")
8116                          (const_int 8)
8117                          (const_int 8))
8118         (and:SI 
8119           (zero_extract:SI
8120             (match_operand 1 "ext_register_operand" "0")
8121             (const_int 8)
8122             (const_int 8))
8123           (match_operand 2 "const_int_operand" "n")))
8124    (clobber (reg:CC 17))]
8125   ""
8126   "and{b}\t{%2, %h0|%h0, %2}"
8127   [(set_attr "type" "alu")
8128    (set_attr "length_immediate" "1")
8129    (set_attr "mode" "QI")])
8131 ;; Generated by peephole translating test to and.  This shows up
8132 ;; often in fp comparisons.
8134 (define_insn "*andqi_ext_0_cc"
8135   [(set (reg 17)
8136         (compare
8137           (and:SI
8138             (zero_extract:SI
8139               (match_operand 1 "ext_register_operand" "0")
8140               (const_int 8)
8141               (const_int 8))
8142             (match_operand 2 "const_int_operand" "n"))
8143           (const_int 0)))
8144    (set (zero_extract:SI (match_operand 0 "ext_register_operand" "=Q")
8145                          (const_int 8)
8146                          (const_int 8))
8147         (and:SI 
8148           (zero_extract:SI
8149             (match_dup 1)
8150             (const_int 8)
8151             (const_int 8))
8152           (match_dup 2)))]
8153   "ix86_match_ccmode (insn, CCNOmode)"
8154   "and{b}\t{%2, %h0|%h0, %2}"
8155   [(set_attr "type" "alu")
8156    (set_attr "length_immediate" "1")
8157    (set_attr "mode" "QI")])
8159 (define_insn "*andqi_ext_1"
8160   [(set (zero_extract:SI (match_operand 0 "ext_register_operand" "=Q")
8161                          (const_int 8)
8162                          (const_int 8))
8163         (and:SI 
8164           (zero_extract:SI
8165             (match_operand 1 "ext_register_operand" "0")
8166             (const_int 8)
8167             (const_int 8))
8168           (zero_extend:SI
8169             (match_operand:QI 2 "general_operand" "Qm"))))
8170    (clobber (reg:CC 17))]
8171   "!TARGET_64BIT"
8172   "and{b}\t{%2, %h0|%h0, %2}"
8173   [(set_attr "type" "alu")
8174    (set_attr "length_immediate" "0")
8175    (set_attr "mode" "QI")])
8177 (define_insn "*andqi_ext_1_rex64"
8178   [(set (zero_extract:SI (match_operand 0 "ext_register_operand" "=Q")
8179                          (const_int 8)
8180                          (const_int 8))
8181         (and:SI 
8182           (zero_extract:SI
8183             (match_operand 1 "ext_register_operand" "0")
8184             (const_int 8)
8185             (const_int 8))
8186           (zero_extend:SI
8187             (match_operand 2 "ext_register_operand" "Q"))))
8188    (clobber (reg:CC 17))]
8189   "TARGET_64BIT"
8190   "and{b}\t{%2, %h0|%h0, %2}"
8191   [(set_attr "type" "alu")
8192    (set_attr "length_immediate" "0")
8193    (set_attr "mode" "QI")])
8195 (define_insn "*andqi_ext_2"
8196   [(set (zero_extract:SI (match_operand 0 "ext_register_operand" "=Q")
8197                          (const_int 8)
8198                          (const_int 8))
8199         (and:SI
8200           (zero_extract:SI
8201             (match_operand 1 "ext_register_operand" "%0")
8202             (const_int 8)
8203             (const_int 8))
8204           (zero_extract:SI
8205             (match_operand 2 "ext_register_operand" "Q")
8206             (const_int 8)
8207             (const_int 8))))
8208    (clobber (reg:CC 17))]
8209   ""
8210   "and{b}\t{%h2, %h0|%h0, %h2}"
8211   [(set_attr "type" "alu")
8212    (set_attr "length_immediate" "0")
8213    (set_attr "mode" "QI")])
8215 ;; Convert wide AND instructions with immediate operand to shorter QImode
8216 ;; equivalents when possible.
8217 ;; Don't do the splitting with memory operands, since it intoduces risc
8218 ;; of memory mismatch stalls.  We may want to do the splitting for optimizing
8219 ;; for size, but that can (should?) be handled by generic code instead.
8220 (define_split
8221   [(set (match_operand 0 "register_operand" "")
8222         (and (match_operand 1 "register_operand" "")
8223              (match_operand 2 "const_int_operand" "")))
8224    (clobber (reg:CC 17))]
8225    "reload_completed
8226     && QI_REG_P (operands[0])
8227     && (!TARGET_PARTIAL_REG_STALL || optimize_size)
8228     && !(~INTVAL (operands[2]) & ~(255 << 8))
8229     && GET_MODE (operands[0]) != QImode"
8230   [(parallel [(set (zero_extract:SI (match_dup 0) (const_int 8) (const_int 8))
8231                    (and:SI (zero_extract:SI (match_dup 1)
8232                                             (const_int 8) (const_int 8))
8233                            (match_dup 2)))
8234               (clobber (reg:CC 17))])]
8235   "operands[0] = gen_lowpart (SImode, operands[0]);
8236    operands[1] = gen_lowpart (SImode, operands[1]);
8237    operands[2] = gen_int_mode ((INTVAL (operands[2]) >> 8) & 0xff, SImode);")
8239 ;; Since AND can be encoded with sign extended immediate, this is only
8240 ;; profitable when 7th bit is not set.
8241 (define_split
8242   [(set (match_operand 0 "register_operand" "")
8243         (and (match_operand 1 "general_operand" "")
8244              (match_operand 2 "const_int_operand" "")))
8245    (clobber (reg:CC 17))]
8246    "reload_completed
8247     && ANY_QI_REG_P (operands[0])
8248     && (!TARGET_PARTIAL_REG_STALL || optimize_size)
8249     && !(~INTVAL (operands[2]) & ~255)
8250     && !(INTVAL (operands[2]) & 128)
8251     && GET_MODE (operands[0]) != QImode"
8252   [(parallel [(set (strict_low_part (match_dup 0))
8253                    (and:QI (match_dup 1)
8254                            (match_dup 2)))
8255               (clobber (reg:CC 17))])]
8256   "operands[0] = gen_lowpart (QImode, operands[0]);
8257    operands[1] = gen_lowpart (QImode, operands[1]);
8258    operands[2] = gen_lowpart (QImode, operands[2]);")
8260 ;; Logical inclusive OR instructions
8262 ;; %%% This used to optimize known byte-wide and operations to memory.
8263 ;; If this is considered useful, it should be done with splitters.
8265 (define_expand "iordi3"
8266   [(set (match_operand:DI 0 "nonimmediate_operand" "")
8267         (ior:DI (match_operand:DI 1 "nonimmediate_operand" "")
8268                 (match_operand:DI 2 "x86_64_general_operand" "")))
8269    (clobber (reg:CC 17))]
8270   "TARGET_64BIT"
8271   "ix86_expand_binary_operator (IOR, DImode, operands); DONE;")
8273 (define_insn "*iordi_1_rex64"
8274   [(set (match_operand:DI 0 "nonimmediate_operand" "=rm,r")
8275         (ior:DI (match_operand:DI 1 "nonimmediate_operand" "%0,0")
8276                 (match_operand:DI 2 "x86_64_general_operand" "re,rme")))
8277    (clobber (reg:CC 17))]
8278   "TARGET_64BIT
8279    && ix86_binary_operator_ok (IOR, DImode, operands)"
8280   "or{q}\t{%2, %0|%0, %2}"
8281   [(set_attr "type" "alu")
8282    (set_attr "mode" "DI")])
8284 (define_insn "*iordi_2_rex64"
8285   [(set (reg 17)
8286         (compare (ior:DI (match_operand:DI 1 "nonimmediate_operand" "%0,0")
8287                          (match_operand:DI 2 "x86_64_general_operand" "rem,re"))
8288                  (const_int 0)))
8289    (set (match_operand:DI 0 "nonimmediate_operand" "=r,rm")
8290         (ior:DI (match_dup 1) (match_dup 2)))]
8291   "TARGET_64BIT
8292    && ix86_match_ccmode (insn, CCNOmode)
8293    && ix86_binary_operator_ok (IOR, DImode, operands)"
8294   "or{q}\t{%2, %0|%0, %2}"
8295   [(set_attr "type" "alu")
8296    (set_attr "mode" "DI")])
8298 (define_insn "*iordi_3_rex64"
8299   [(set (reg 17)
8300         (compare (ior:DI (match_operand:DI 1 "nonimmediate_operand" "%0")
8301                          (match_operand:DI 2 "x86_64_general_operand" "rem"))
8302                  (const_int 0)))
8303    (clobber (match_scratch:DI 0 "=r"))]
8304   "TARGET_64BIT
8305    && ix86_match_ccmode (insn, CCNOmode)
8306    && ix86_binary_operator_ok (IOR, DImode, operands)"
8307   "or{q}\t{%2, %0|%0, %2}"
8308   [(set_attr "type" "alu")
8309    (set_attr "mode" "DI")])
8312 (define_expand "iorsi3"
8313   [(set (match_operand:SI 0 "nonimmediate_operand" "")
8314         (ior:SI (match_operand:SI 1 "nonimmediate_operand" "")
8315                 (match_operand:SI 2 "general_operand" "")))
8316    (clobber (reg:CC 17))]
8317   ""
8318   "ix86_expand_binary_operator (IOR, SImode, operands); DONE;")
8320 (define_insn "*iorsi_1"
8321   [(set (match_operand:SI 0 "nonimmediate_operand" "=rm,r")
8322         (ior:SI (match_operand:SI 1 "nonimmediate_operand" "%0,0")
8323                 (match_operand:SI 2 "general_operand" "ri,rmi")))
8324    (clobber (reg:CC 17))]
8325   "ix86_binary_operator_ok (IOR, SImode, operands)"
8326   "or{l}\t{%2, %0|%0, %2}"
8327   [(set_attr "type" "alu")
8328    (set_attr "mode" "SI")])
8330 ;; See comment for addsi_1_zext why we do use nonimmediate_operand
8331 (define_insn "*iorsi_1_zext"
8332   [(set (match_operand:DI 0 "register_operand" "=rm")
8333         (zero_extend:DI
8334           (ior:SI (match_operand:SI 1 "nonimmediate_operand" "%0")
8335                   (match_operand:SI 2 "general_operand" "rim"))))
8336    (clobber (reg:CC 17))]
8337   "TARGET_64BIT && ix86_binary_operator_ok (IOR, SImode, operands)"
8338   "or{l}\t{%2, %k0|%k0, %2}"
8339   [(set_attr "type" "alu")
8340    (set_attr "mode" "SI")])
8342 (define_insn "*iorsi_1_zext_imm"
8343   [(set (match_operand:DI 0 "register_operand" "=rm")
8344         (ior:DI (zero_extend:DI (match_operand:SI 1 "register_operand" "%0"))
8345                 (match_operand:DI 2 "x86_64_zext_immediate_operand" "Z")))
8346    (clobber (reg:CC 17))]
8347   "TARGET_64BIT"
8348   "or{l}\t{%2, %k0|%k0, %2}"
8349   [(set_attr "type" "alu")
8350    (set_attr "mode" "SI")])
8352 (define_insn "*iorsi_2"
8353   [(set (reg 17)
8354         (compare (ior:SI (match_operand:SI 1 "nonimmediate_operand" "%0,0")
8355                          (match_operand:SI 2 "general_operand" "rim,ri"))
8356                  (const_int 0)))
8357    (set (match_operand:SI 0 "nonimmediate_operand" "=r,rm")
8358         (ior:SI (match_dup 1) (match_dup 2)))]
8359   "ix86_match_ccmode (insn, CCNOmode)
8360    && ix86_binary_operator_ok (IOR, SImode, operands)"
8361   "or{l}\t{%2, %0|%0, %2}"
8362   [(set_attr "type" "alu")
8363    (set_attr "mode" "SI")])
8365 ;; See comment for addsi_1_zext why we do use nonimmediate_operand
8366 ;; ??? Special case for immediate operand is missing - it is tricky.
8367 (define_insn "*iorsi_2_zext"
8368   [(set (reg 17)
8369         (compare (ior:SI (match_operand:SI 1 "nonimmediate_operand" "%0")
8370                          (match_operand:SI 2 "general_operand" "rim"))
8371                  (const_int 0)))
8372    (set (match_operand:DI 0 "register_operand" "=r")
8373         (zero_extend:DI (ior:SI (match_dup 1) (match_dup 2))))]
8374   "TARGET_64BIT && ix86_match_ccmode (insn, CCNOmode)
8375    && ix86_binary_operator_ok (IOR, SImode, operands)"
8376   "or{l}\t{%2, %k0|%k0, %2}"
8377   [(set_attr "type" "alu")
8378    (set_attr "mode" "SI")])
8380 (define_insn "*iorsi_2_zext_imm"
8381   [(set (reg 17)
8382         (compare (ior:SI (match_operand:SI 1 "nonimmediate_operand" "%0")
8383                          (match_operand 2 "x86_64_zext_immediate_operand" "Z"))
8384                  (const_int 0)))
8385    (set (match_operand:DI 0 "register_operand" "=r")
8386         (ior:DI (zero_extend:DI (match_dup 1)) (match_dup 2)))]
8387   "TARGET_64BIT && ix86_match_ccmode (insn, CCNOmode)
8388    && ix86_binary_operator_ok (IOR, SImode, operands)"
8389   "or{l}\t{%2, %k0|%k0, %2}"
8390   [(set_attr "type" "alu")
8391    (set_attr "mode" "SI")])
8393 (define_insn "*iorsi_3"
8394   [(set (reg 17)
8395         (compare (ior:SI (match_operand:SI 1 "nonimmediate_operand" "%0")
8396                          (match_operand:SI 2 "general_operand" "rim"))
8397                  (const_int 0)))
8398    (clobber (match_scratch:SI 0 "=r"))]
8399   "ix86_match_ccmode (insn, CCNOmode)
8400    && (GET_CODE (operands[1]) != MEM || GET_CODE (operands[2]) != MEM)"
8401   "or{l}\t{%2, %0|%0, %2}"
8402   [(set_attr "type" "alu")
8403    (set_attr "mode" "SI")])
8405 (define_expand "iorhi3"
8406   [(set (match_operand:HI 0 "nonimmediate_operand" "")
8407         (ior:HI (match_operand:HI 1 "nonimmediate_operand" "")
8408                 (match_operand:HI 2 "general_operand" "")))
8409    (clobber (reg:CC 17))]
8410   "TARGET_HIMODE_MATH"
8411   "ix86_expand_binary_operator (IOR, HImode, operands); DONE;")
8413 (define_insn "*iorhi_1"
8414   [(set (match_operand:HI 0 "nonimmediate_operand" "=r,m")
8415         (ior:HI (match_operand:HI 1 "nonimmediate_operand" "%0,0")
8416                 (match_operand:HI 2 "general_operand" "rmi,ri")))
8417    (clobber (reg:CC 17))]
8418   "ix86_binary_operator_ok (IOR, HImode, operands)"
8419   "or{w}\t{%2, %0|%0, %2}"
8420   [(set_attr "type" "alu")
8421    (set_attr "mode" "HI")])
8423 (define_insn "*iorhi_2"
8424   [(set (reg 17)
8425         (compare (ior:HI (match_operand:HI 1 "nonimmediate_operand" "%0,0")
8426                          (match_operand:HI 2 "general_operand" "rim,ri"))
8427                  (const_int 0)))
8428    (set (match_operand:HI 0 "nonimmediate_operand" "=r,rm")
8429         (ior:HI (match_dup 1) (match_dup 2)))]
8430   "ix86_match_ccmode (insn, CCNOmode)
8431    && ix86_binary_operator_ok (IOR, HImode, operands)"
8432   "or{w}\t{%2, %0|%0, %2}"
8433   [(set_attr "type" "alu")
8434    (set_attr "mode" "HI")])
8436 (define_insn "*iorhi_3"
8437   [(set (reg 17)
8438         (compare (ior:HI (match_operand:HI 1 "nonimmediate_operand" "%0")
8439                          (match_operand:HI 2 "general_operand" "rim"))
8440                  (const_int 0)))
8441    (clobber (match_scratch:HI 0 "=r"))]
8442   "ix86_match_ccmode (insn, CCNOmode)
8443    && (GET_CODE (operands[1]) != MEM || GET_CODE (operands[2]) != MEM)"
8444   "or{w}\t{%2, %0|%0, %2}"
8445   [(set_attr "type" "alu")
8446    (set_attr "mode" "HI")])
8448 (define_expand "iorqi3"
8449   [(set (match_operand:QI 0 "nonimmediate_operand" "")
8450         (ior:QI (match_operand:QI 1 "nonimmediate_operand" "")
8451                 (match_operand:QI 2 "general_operand" "")))
8452    (clobber (reg:CC 17))]
8453   "TARGET_QIMODE_MATH"
8454   "ix86_expand_binary_operator (IOR, QImode, operands); DONE;")
8456 ;; %%% Potential partial reg stall on alternative 2.  What to do?
8457 (define_insn "*iorqi_1"
8458   [(set (match_operand:QI 0 "nonimmediate_operand" "=q,m,r")
8459         (ior:QI (match_operand:QI 1 "nonimmediate_operand" "%0,0,0")
8460                 (match_operand:QI 2 "general_operand" "qmi,qi,ri")))
8461    (clobber (reg:CC 17))]
8462   "ix86_binary_operator_ok (IOR, QImode, operands)"
8463   "@
8464    or{b}\t{%2, %0|%0, %2}
8465    or{b}\t{%2, %0|%0, %2}
8466    or{l}\t{%k2, %k0|%k0, %k2}"
8467   [(set_attr "type" "alu")
8468    (set_attr "mode" "QI,QI,SI")])
8470 (define_insn "*iorqi_1_slp"
8471   [(set (strict_low_part (match_operand:QI 0 "nonimmediate_operand" "+q,m"))
8472         (ior:QI (match_dup 0)
8473                 (match_operand:QI 1 "general_operand" "qmi,qi")))
8474    (clobber (reg:CC 17))]
8475   "! TARGET_PARTIAL_REG_STALL || optimize_size"
8476   "or{b}\t{%1, %0|%0, %1}"
8477   [(set_attr "type" "alu1")
8478    (set_attr "mode" "QI")])
8480 (define_insn "*iorqi_2"
8481   [(set (reg 17)
8482         (compare (ior:QI (match_operand:QI 1 "nonimmediate_operand" "%0,0")
8483                          (match_operand:QI 2 "general_operand" "qim,qi"))
8484                  (const_int 0)))
8485    (set (match_operand:QI 0 "nonimmediate_operand" "=q,qm")
8486         (ior:QI (match_dup 1) (match_dup 2)))]
8487   "ix86_match_ccmode (insn, CCNOmode)
8488    && ix86_binary_operator_ok (IOR, QImode, operands)"
8489   "or{b}\t{%2, %0|%0, %2}"
8490   [(set_attr "type" "alu")
8491    (set_attr "mode" "QI")])
8493 (define_insn "*iorqi_2_slp"
8494   [(set (reg 17)
8495         (compare (ior:QI (match_operand:QI 0 "nonimmediate_operand" "+q,qm")
8496                          (match_operand:QI 1 "general_operand" "qim,qi"))
8497                  (const_int 0)))
8498    (set (strict_low_part (match_dup 0))
8499         (ior:QI (match_dup 0) (match_dup 1)))]
8500   "(! TARGET_PARTIAL_REG_STALL || optimize_size)
8501    && ix86_match_ccmode (insn, CCNOmode)"
8502   "or{b}\t{%1, %0|%0, %1}"
8503   [(set_attr "type" "alu1")
8504    (set_attr "mode" "QI")])
8506 (define_insn "*iorqi_3"
8507   [(set (reg 17)
8508         (compare (ior:QI (match_operand:QI 1 "nonimmediate_operand" "%0")
8509                          (match_operand:QI 2 "general_operand" "qim"))
8510                  (const_int 0)))
8511    (clobber (match_scratch:QI 0 "=q"))]
8512   "ix86_match_ccmode (insn, CCNOmode)
8513    && (GET_CODE (operands[1]) != MEM || GET_CODE (operands[2]) != MEM)"
8514   "or{b}\t{%2, %0|%0, %2}"
8515   [(set_attr "type" "alu")
8516    (set_attr "mode" "QI")])
8518 (define_insn "iorqi_ext_0"
8519   [(set (zero_extract:SI (match_operand 0 "ext_register_operand" "=Q")
8520                          (const_int 8)
8521                          (const_int 8))
8522         (ior:SI 
8523           (zero_extract:SI
8524             (match_operand 1 "ext_register_operand" "0")
8525             (const_int 8)
8526             (const_int 8))
8527           (match_operand 2 "const_int_operand" "n")))
8528    (clobber (reg:CC 17))]
8529   "(!TARGET_PARTIAL_REG_STALL || optimize_size)"
8530   "or{b}\t{%2, %h0|%h0, %2}"
8531   [(set_attr "type" "alu")
8532    (set_attr "length_immediate" "1")
8533    (set_attr "mode" "QI")])
8535 (define_insn "*iorqi_ext_1"
8536   [(set (zero_extract:SI (match_operand 0 "ext_register_operand" "=Q")
8537                          (const_int 8)
8538                          (const_int 8))
8539         (ior:SI 
8540           (zero_extract:SI
8541             (match_operand 1 "ext_register_operand" "0")
8542             (const_int 8)
8543             (const_int 8))
8544           (zero_extend:SI
8545             (match_operand:QI 2 "general_operand" "Qm"))))
8546    (clobber (reg:CC 17))]
8547   "!TARGET_64BIT
8548    && (!TARGET_PARTIAL_REG_STALL || optimize_size)"
8549   "or{b}\t{%2, %h0|%h0, %2}"
8550   [(set_attr "type" "alu")
8551    (set_attr "length_immediate" "0")
8552    (set_attr "mode" "QI")])
8554 (define_insn "*iorqi_ext_1_rex64"
8555   [(set (zero_extract:SI (match_operand 0 "ext_register_operand" "=Q")
8556                          (const_int 8)
8557                          (const_int 8))
8558         (ior:SI 
8559           (zero_extract:SI
8560             (match_operand 1 "ext_register_operand" "0")
8561             (const_int 8)
8562             (const_int 8))
8563           (zero_extend:SI
8564             (match_operand 2 "ext_register_operand" "Q"))))
8565    (clobber (reg:CC 17))]
8566   "TARGET_64BIT
8567    && (!TARGET_PARTIAL_REG_STALL || optimize_size)"
8568   "or{b}\t{%2, %h0|%h0, %2}"
8569   [(set_attr "type" "alu")
8570    (set_attr "length_immediate" "0")
8571    (set_attr "mode" "QI")])
8573 (define_insn "*iorqi_ext_2"
8574   [(set (zero_extract:SI (match_operand 0 "ext_register_operand" "=Q")
8575                          (const_int 8)
8576                          (const_int 8))
8577         (ior:SI 
8578           (zero_extract:SI (match_operand 1 "ext_register_operand" "0")
8579                            (const_int 8)
8580                            (const_int 8))
8581           (zero_extract:SI (match_operand 2 "ext_register_operand" "Q")
8582                            (const_int 8)
8583                            (const_int 8))))
8584    (clobber (reg:CC 17))]
8585   "(!TARGET_PARTIAL_REG_STALL || optimize_size)"
8586   "ior{b}\t{%h2, %h0|%h0, %h2}"
8587   [(set_attr "type" "alu")
8588    (set_attr "length_immediate" "0")
8589    (set_attr "mode" "QI")])
8591 (define_split
8592   [(set (match_operand 0 "register_operand" "")
8593         (ior (match_operand 1 "register_operand" "")
8594              (match_operand 2 "const_int_operand" "")))
8595    (clobber (reg:CC 17))]
8596    "reload_completed
8597     && QI_REG_P (operands[0])
8598     && (!TARGET_PARTIAL_REG_STALL || optimize_size)
8599     && !(INTVAL (operands[2]) & ~(255 << 8))
8600     && GET_MODE (operands[0]) != QImode"
8601   [(parallel [(set (zero_extract:SI (match_dup 0) (const_int 8) (const_int 8))
8602                    (ior:SI (zero_extract:SI (match_dup 1)
8603                                             (const_int 8) (const_int 8))
8604                            (match_dup 2)))
8605               (clobber (reg:CC 17))])]
8606   "operands[0] = gen_lowpart (SImode, operands[0]);
8607    operands[1] = gen_lowpart (SImode, operands[1]);
8608    operands[2] = gen_int_mode ((INTVAL (operands[2]) >> 8) & 0xff, SImode);")
8610 ;; Since OR can be encoded with sign extended immediate, this is only
8611 ;; profitable when 7th bit is set.
8612 (define_split
8613   [(set (match_operand 0 "register_operand" "")
8614         (ior (match_operand 1 "general_operand" "")
8615              (match_operand 2 "const_int_operand" "")))
8616    (clobber (reg:CC 17))]
8617    "reload_completed
8618     && ANY_QI_REG_P (operands[0])
8619     && (!TARGET_PARTIAL_REG_STALL || optimize_size)
8620     && !(INTVAL (operands[2]) & ~255)
8621     && (INTVAL (operands[2]) & 128)
8622     && GET_MODE (operands[0]) != QImode"
8623   [(parallel [(set (strict_low_part (match_dup 0))
8624                    (ior:QI (match_dup 1)
8625                            (match_dup 2)))
8626               (clobber (reg:CC 17))])]
8627   "operands[0] = gen_lowpart (QImode, operands[0]);
8628    operands[1] = gen_lowpart (QImode, operands[1]);
8629    operands[2] = gen_lowpart (QImode, operands[2]);")
8631 ;; Logical XOR instructions
8633 ;; %%% This used to optimize known byte-wide and operations to memory.
8634 ;; If this is considered useful, it should be done with splitters.
8636 (define_expand "xordi3"
8637   [(set (match_operand:DI 0 "nonimmediate_operand" "")
8638         (xor:DI (match_operand:DI 1 "nonimmediate_operand" "")
8639                 (match_operand:DI 2 "x86_64_general_operand" "")))
8640    (clobber (reg:CC 17))]
8641   "TARGET_64BIT"
8642   "ix86_expand_binary_operator (XOR, DImode, operands); DONE;")
8644 (define_insn "*xordi_1_rex64"
8645   [(set (match_operand:DI 0 "nonimmediate_operand" "=rm,r")
8646         (xor:DI (match_operand:DI 1 "nonimmediate_operand" "%0,0")
8647                 (match_operand:DI 2 "x86_64_general_operand" "re,rm")))
8648    (clobber (reg:CC 17))]
8649   "TARGET_64BIT
8650    && ix86_binary_operator_ok (XOR, DImode, operands)"
8651   "@
8652    xor{q}\t{%2, %0|%0, %2} 
8653    xor{q}\t{%2, %0|%0, %2}"
8654   [(set_attr "type" "alu")
8655    (set_attr "mode" "DI,DI")])
8657 (define_insn "*xordi_2_rex64"
8658   [(set (reg 17)
8659         (compare (xor:DI (match_operand:DI 1 "nonimmediate_operand" "%0,0")
8660                          (match_operand:DI 2 "x86_64_general_operand" "rem,re"))
8661                  (const_int 0)))
8662    (set (match_operand:DI 0 "nonimmediate_operand" "=r,rm")
8663         (xor:DI (match_dup 1) (match_dup 2)))]
8664   "TARGET_64BIT
8665    && ix86_match_ccmode (insn, CCNOmode)
8666    && ix86_binary_operator_ok (XOR, DImode, operands)"
8667   "@
8668    xor{q}\t{%2, %0|%0, %2} 
8669    xor{q}\t{%2, %0|%0, %2}"
8670   [(set_attr "type" "alu")
8671    (set_attr "mode" "DI,DI")])
8673 (define_insn "*xordi_3_rex64"
8674   [(set (reg 17)
8675         (compare (xor:DI (match_operand:DI 1 "nonimmediate_operand" "%0")
8676                          (match_operand:DI 2 "x86_64_general_operand" "rem"))
8677                  (const_int 0)))
8678    (clobber (match_scratch:DI 0 "=r"))]
8679   "TARGET_64BIT
8680    && ix86_match_ccmode (insn, CCNOmode)
8681    && ix86_binary_operator_ok (XOR, DImode, operands)"
8682   "xor{q}\t{%2, %0|%0, %2}"
8683   [(set_attr "type" "alu")
8684    (set_attr "mode" "DI")])
8686 (define_expand "xorsi3"
8687   [(set (match_operand:SI 0 "nonimmediate_operand" "")
8688         (xor:SI (match_operand:SI 1 "nonimmediate_operand" "")
8689                 (match_operand:SI 2 "general_operand" "")))
8690    (clobber (reg:CC 17))]
8691   ""
8692   "ix86_expand_binary_operator (XOR, SImode, operands); DONE;")
8694 (define_insn "*xorsi_1"
8695   [(set (match_operand:SI 0 "nonimmediate_operand" "=rm,r")
8696         (xor:SI (match_operand:SI 1 "nonimmediate_operand" "%0,0")
8697                 (match_operand:SI 2 "general_operand" "ri,rm")))
8698    (clobber (reg:CC 17))]
8699   "ix86_binary_operator_ok (XOR, SImode, operands)"
8700   "xor{l}\t{%2, %0|%0, %2}"
8701   [(set_attr "type" "alu")
8702    (set_attr "mode" "SI")])
8704 ;; See comment for addsi_1_zext why we do use nonimmediate_operand
8705 ;; Add speccase for immediates
8706 (define_insn "*xorsi_1_zext"
8707   [(set (match_operand:DI 0 "register_operand" "=r")
8708         (zero_extend:DI
8709           (xor:SI (match_operand:SI 1 "nonimmediate_operand" "%0")
8710                   (match_operand:SI 2 "general_operand" "rim"))))
8711    (clobber (reg:CC 17))]
8712   "TARGET_64BIT && ix86_binary_operator_ok (XOR, SImode, operands)"
8713   "xor{l}\t{%2, %k0|%k0, %2}"
8714   [(set_attr "type" "alu")
8715    (set_attr "mode" "SI")])
8717 (define_insn "*xorsi_1_zext_imm"
8718   [(set (match_operand:DI 0 "register_operand" "=r")
8719         (xor:DI (zero_extend:DI (match_operand:SI 1 "register_operand" "%0"))
8720                 (match_operand:DI 2 "x86_64_zext_immediate_operand" "Z")))
8721    (clobber (reg:CC 17))]
8722   "TARGET_64BIT && ix86_binary_operator_ok (XOR, SImode, operands)"
8723   "xor{l}\t{%2, %k0|%k0, %2}"
8724   [(set_attr "type" "alu")
8725    (set_attr "mode" "SI")])
8727 (define_insn "*xorsi_2"
8728   [(set (reg 17)
8729         (compare (xor:SI (match_operand:SI 1 "nonimmediate_operand" "%0,0")
8730                          (match_operand:SI 2 "general_operand" "rim,ri"))
8731                  (const_int 0)))
8732    (set (match_operand:SI 0 "nonimmediate_operand" "=r,rm")
8733         (xor:SI (match_dup 1) (match_dup 2)))]
8734   "ix86_match_ccmode (insn, CCNOmode)
8735    && ix86_binary_operator_ok (XOR, SImode, operands)"
8736   "xor{l}\t{%2, %0|%0, %2}"
8737   [(set_attr "type" "alu")
8738    (set_attr "mode" "SI")])
8740 ;; See comment for addsi_1_zext why we do use nonimmediate_operand
8741 ;; ??? Special case for immediate operand is missing - it is tricky.
8742 (define_insn "*xorsi_2_zext"
8743   [(set (reg 17)
8744         (compare (xor:SI (match_operand:SI 1 "nonimmediate_operand" "%0")
8745                          (match_operand:SI 2 "general_operand" "rim"))
8746                  (const_int 0)))
8747    (set (match_operand:DI 0 "register_operand" "=r")
8748         (zero_extend:DI (xor:SI (match_dup 1) (match_dup 2))))]
8749   "TARGET_64BIT && ix86_match_ccmode (insn, CCNOmode)
8750    && ix86_binary_operator_ok (XOR, SImode, operands)"
8751   "xor{l}\t{%2, %k0|%k0, %2}"
8752   [(set_attr "type" "alu")
8753    (set_attr "mode" "SI")])
8755 (define_insn "*xorsi_2_zext_imm"
8756   [(set (reg 17)
8757         (compare (xor:SI (match_operand:SI 1 "nonimmediate_operand" "%0")
8758                          (match_operand 2 "x86_64_zext_immediate_operand" "Z"))
8759                  (const_int 0)))
8760    (set (match_operand:DI 0 "register_operand" "=r")
8761         (xor:DI (zero_extend:DI (match_dup 1)) (match_dup 2)))]
8762   "TARGET_64BIT && ix86_match_ccmode (insn, CCNOmode)
8763    && ix86_binary_operator_ok (XOR, SImode, operands)"
8764   "xor{l}\t{%2, %k0|%k0, %2}"
8765   [(set_attr "type" "alu")
8766    (set_attr "mode" "SI")])
8768 (define_insn "*xorsi_3"
8769   [(set (reg 17)
8770         (compare (xor:SI (match_operand:SI 1 "nonimmediate_operand" "%0")
8771                          (match_operand:SI 2 "general_operand" "rim"))
8772                  (const_int 0)))
8773    (clobber (match_scratch:SI 0 "=r"))]
8774   "ix86_match_ccmode (insn, CCNOmode)
8775    && (GET_CODE (operands[1]) != MEM || GET_CODE (operands[2]) != MEM)"
8776   "xor{l}\t{%2, %0|%0, %2}"
8777   [(set_attr "type" "alu")
8778    (set_attr "mode" "SI")])
8780 (define_expand "xorhi3"
8781   [(set (match_operand:HI 0 "nonimmediate_operand" "")
8782         (xor:HI (match_operand:HI 1 "nonimmediate_operand" "")
8783                 (match_operand:HI 2 "general_operand" "")))
8784    (clobber (reg:CC 17))]
8785   "TARGET_HIMODE_MATH"
8786   "ix86_expand_binary_operator (XOR, HImode, operands); DONE;")
8788 (define_insn "*xorhi_1"
8789   [(set (match_operand:HI 0 "nonimmediate_operand" "=r,m")
8790         (xor:HI (match_operand:HI 1 "nonimmediate_operand" "%0,0")
8791                 (match_operand:HI 2 "general_operand" "rmi,ri")))
8792    (clobber (reg:CC 17))]
8793   "ix86_binary_operator_ok (XOR, HImode, operands)"
8794   "xor{w}\t{%2, %0|%0, %2}"
8795   [(set_attr "type" "alu")
8796    (set_attr "mode" "HI")])
8798 (define_insn "*xorhi_2"
8799   [(set (reg 17)
8800         (compare (xor:HI (match_operand:HI 1 "nonimmediate_operand" "%0,0")
8801                          (match_operand:HI 2 "general_operand" "rim,ri"))
8802                  (const_int 0)))
8803    (set (match_operand:HI 0 "nonimmediate_operand" "=r,rm")
8804         (xor:HI (match_dup 1) (match_dup 2)))]
8805   "ix86_match_ccmode (insn, CCNOmode)
8806    && ix86_binary_operator_ok (XOR, HImode, operands)"
8807   "xor{w}\t{%2, %0|%0, %2}"
8808   [(set_attr "type" "alu")
8809    (set_attr "mode" "HI")])
8811 (define_insn "*xorhi_3"
8812   [(set (reg 17)
8813         (compare (xor:HI (match_operand:HI 1 "nonimmediate_operand" "%0")
8814                          (match_operand:HI 2 "general_operand" "rim"))
8815                  (const_int 0)))
8816    (clobber (match_scratch:HI 0 "=r"))]
8817   "ix86_match_ccmode (insn, CCNOmode)
8818    && (GET_CODE (operands[1]) != MEM || GET_CODE (operands[2]) != MEM)"
8819   "xor{w}\t{%2, %0|%0, %2}"
8820   [(set_attr "type" "alu")
8821    (set_attr "mode" "HI")])
8823 (define_expand "xorqi3"
8824   [(set (match_operand:QI 0 "nonimmediate_operand" "")
8825         (xor:QI (match_operand:QI 1 "nonimmediate_operand" "")
8826                 (match_operand:QI 2 "general_operand" "")))
8827    (clobber (reg:CC 17))]
8828   "TARGET_QIMODE_MATH"
8829   "ix86_expand_binary_operator (XOR, QImode, operands); DONE;")
8831 ;; %%% Potential partial reg stall on alternative 2.  What to do?
8832 (define_insn "*xorqi_1"
8833   [(set (match_operand:QI 0 "nonimmediate_operand" "=q,m,r")
8834         (xor:QI (match_operand:QI 1 "nonimmediate_operand" "%0,0,0")
8835                 (match_operand:QI 2 "general_operand" "qmi,qi,ri")))
8836    (clobber (reg:CC 17))]
8837   "ix86_binary_operator_ok (XOR, QImode, operands)"
8838   "@
8839    xor{b}\t{%2, %0|%0, %2}
8840    xor{b}\t{%2, %0|%0, %2}
8841    xor{l}\t{%k2, %k0|%k0, %k2}"
8842   [(set_attr "type" "alu")
8843    (set_attr "mode" "QI,QI,SI")])
8845 (define_insn "*xorqi_1_slp"
8846   [(set (strict_low_part (match_operand:QI 0 "nonimmediate_operand" "+qm,q"))
8847         (xor:QI (match_dup 0)
8848                 (match_operand:QI 1 "general_operand" "qi,qmi")))
8849    (clobber (reg:CC 17))]
8850   "! TARGET_PARTIAL_REG_STALL || optimize_size"
8851   "xor{b}\t{%1, %0|%0, %1}"
8852   [(set_attr "type" "alu1")
8853    (set_attr "mode" "QI")])
8855 (define_insn "xorqi_ext_0"
8856   [(set (zero_extract:SI (match_operand 0 "ext_register_operand" "=Q")
8857                          (const_int 8)
8858                          (const_int 8))
8859         (xor:SI 
8860           (zero_extract:SI
8861             (match_operand 1 "ext_register_operand" "0")
8862             (const_int 8)
8863             (const_int 8))
8864           (match_operand 2 "const_int_operand" "n")))
8865    (clobber (reg:CC 17))]
8866   "(!TARGET_PARTIAL_REG_STALL || optimize_size)"
8867   "xor{b}\t{%2, %h0|%h0, %2}"
8868   [(set_attr "type" "alu")
8869    (set_attr "length_immediate" "1")
8870    (set_attr "mode" "QI")])
8872 (define_insn "*xorqi_ext_1"
8873   [(set (zero_extract:SI (match_operand 0 "ext_register_operand" "=Q")
8874                          (const_int 8)
8875                          (const_int 8))
8876         (xor:SI 
8877           (zero_extract:SI
8878             (match_operand 1 "ext_register_operand" "0")
8879             (const_int 8)
8880             (const_int 8))
8881           (zero_extend:SI
8882             (match_operand:QI 2 "general_operand" "Qm"))))
8883    (clobber (reg:CC 17))]
8884   "!TARGET_64BIT
8885    && (!TARGET_PARTIAL_REG_STALL || optimize_size)"
8886   "xor{b}\t{%2, %h0|%h0, %2}"
8887   [(set_attr "type" "alu")
8888    (set_attr "length_immediate" "0")
8889    (set_attr "mode" "QI")])
8891 (define_insn "*xorqi_ext_1_rex64"
8892   [(set (zero_extract:SI (match_operand 0 "ext_register_operand" "=Q")
8893                          (const_int 8)
8894                          (const_int 8))
8895         (xor:SI 
8896           (zero_extract:SI
8897             (match_operand 1 "ext_register_operand" "0")
8898             (const_int 8)
8899             (const_int 8))
8900           (zero_extend:SI
8901             (match_operand 2 "ext_register_operand" "Q"))))
8902    (clobber (reg:CC 17))]
8903   "TARGET_64BIT
8904    && (!TARGET_PARTIAL_REG_STALL || optimize_size)"
8905   "xor{b}\t{%2, %h0|%h0, %2}"
8906   [(set_attr "type" "alu")
8907    (set_attr "length_immediate" "0")
8908    (set_attr "mode" "QI")])
8910 (define_insn "*xorqi_ext_2"
8911   [(set (zero_extract:SI (match_operand 0 "ext_register_operand" "=Q")
8912                          (const_int 8)
8913                          (const_int 8))
8914         (xor:SI 
8915           (zero_extract:SI (match_operand 1 "ext_register_operand" "0")
8916                            (const_int 8)
8917                            (const_int 8))
8918           (zero_extract:SI (match_operand 2 "ext_register_operand" "Q")
8919                            (const_int 8)
8920                            (const_int 8))))
8921    (clobber (reg:CC 17))]
8922   "(!TARGET_PARTIAL_REG_STALL || optimize_size)"
8923   "xor{b}\t{%h2, %h0|%h0, %h2}"
8924   [(set_attr "type" "alu")
8925    (set_attr "length_immediate" "0")
8926    (set_attr "mode" "QI")])
8928 (define_insn "*xorqi_cc_1"
8929   [(set (reg 17)
8930         (compare
8931           (xor:QI (match_operand:QI 1 "nonimmediate_operand" "%0,0")
8932                   (match_operand:QI 2 "general_operand" "qim,qi"))
8933           (const_int 0)))
8934    (set (match_operand:QI 0 "nonimmediate_operand" "=q,qm")
8935         (xor:QI (match_dup 1) (match_dup 2)))]
8936   "ix86_match_ccmode (insn, CCNOmode)
8937    && ix86_binary_operator_ok (XOR, QImode, operands)"
8938   "xor{b}\t{%2, %0|%0, %2}"
8939   [(set_attr "type" "alu")
8940    (set_attr "mode" "QI")])
8942 (define_insn "*xorqi_2_slp"
8943   [(set (reg 17)
8944         (compare (xor:QI (match_operand:QI 0 "nonimmediate_operand" "+q,qm")
8945                          (match_operand:QI 1 "general_operand" "qim,qi"))
8946                  (const_int 0)))
8947    (set (strict_low_part (match_dup 0))
8948         (xor:QI (match_dup 0) (match_dup 1)))]
8949   "(! TARGET_PARTIAL_REG_STALL || optimize_size)
8950    && ix86_match_ccmode (insn, CCNOmode)"
8951   "xor{b}\t{%1, %0|%0, %1}"
8952   [(set_attr "type" "alu1")
8953    (set_attr "mode" "QI")])
8955 (define_insn "*xorqi_cc_2"
8956   [(set (reg 17)
8957         (compare
8958           (xor:QI (match_operand:QI 1 "nonimmediate_operand" "%0")
8959                   (match_operand:QI 2 "general_operand" "qim"))
8960           (const_int 0)))
8961    (clobber (match_scratch:QI 0 "=q"))]
8962   "ix86_match_ccmode (insn, CCNOmode)
8963    && (GET_CODE (operands[1]) != MEM || GET_CODE (operands[2]) != MEM)"
8964   "xor{b}\t{%2, %0|%0, %2}"
8965   [(set_attr "type" "alu")
8966    (set_attr "mode" "QI")])
8968 (define_insn "*xorqi_cc_ext_1"
8969   [(set (reg 17)
8970         (compare
8971           (xor:SI
8972             (zero_extract:SI
8973               (match_operand 1 "ext_register_operand" "0")
8974               (const_int 8)
8975               (const_int 8))
8976             (match_operand:QI 2 "general_operand" "qmn"))
8977           (const_int 0)))
8978    (set (zero_extract:SI (match_operand 0 "ext_register_operand" "=q")
8979                          (const_int 8)
8980                          (const_int 8))
8981         (xor:SI 
8982           (zero_extract:SI (match_dup 1) (const_int 8) (const_int 8))
8983           (match_dup 2)))]
8984   "!TARGET_64BIT && ix86_match_ccmode (insn, CCNOmode)"
8985   "xor{b}\t{%2, %h0|%h0, %2}"
8986   [(set_attr "type" "alu")
8987    (set_attr "mode" "QI")])
8989 (define_insn "*xorqi_cc_ext_1_rex64"
8990   [(set (reg 17)
8991         (compare
8992           (xor:SI
8993             (zero_extract:SI
8994               (match_operand 1 "ext_register_operand" "0")
8995               (const_int 8)
8996               (const_int 8))
8997             (match_operand:QI 2 "nonmemory_operand" "Qn"))
8998           (const_int 0)))
8999    (set (zero_extract:SI (match_operand 0 "ext_register_operand" "=Q")
9000                          (const_int 8)
9001                          (const_int 8))
9002         (xor:SI 
9003           (zero_extract:SI (match_dup 1) (const_int 8) (const_int 8))
9004           (match_dup 2)))]
9005   "TARGET_64BIT && ix86_match_ccmode (insn, CCNOmode)"
9006   "xor{b}\t{%2, %h0|%h0, %2}"
9007   [(set_attr "type" "alu")
9008    (set_attr "mode" "QI")])
9010 (define_expand "xorqi_cc_ext_1"
9011   [(parallel [
9012      (set (reg:CCNO 17)
9013           (compare:CCNO
9014             (xor:SI
9015               (zero_extract:SI
9016                 (match_operand 1 "ext_register_operand" "")
9017                 (const_int 8)
9018                 (const_int 8))
9019               (match_operand:QI 2 "general_operand" ""))
9020             (const_int 0)))
9021      (set (zero_extract:SI (match_operand 0 "ext_register_operand" "")
9022                            (const_int 8)
9023                            (const_int 8))
9024           (xor:SI 
9025             (zero_extract:SI (match_dup 1) (const_int 8) (const_int 8))
9026             (match_dup 2)))])]
9027   ""
9028   "")
9030 (define_split
9031   [(set (match_operand 0 "register_operand" "")
9032         (xor (match_operand 1 "register_operand" "")
9033              (match_operand 2 "const_int_operand" "")))
9034    (clobber (reg:CC 17))]
9035    "reload_completed
9036     && QI_REG_P (operands[0])
9037     && (!TARGET_PARTIAL_REG_STALL || optimize_size)
9038     && !(INTVAL (operands[2]) & ~(255 << 8))
9039     && GET_MODE (operands[0]) != QImode"
9040   [(parallel [(set (zero_extract:SI (match_dup 0) (const_int 8) (const_int 8))
9041                    (xor:SI (zero_extract:SI (match_dup 1)
9042                                             (const_int 8) (const_int 8))
9043                            (match_dup 2)))
9044               (clobber (reg:CC 17))])]
9045   "operands[0] = gen_lowpart (SImode, operands[0]);
9046    operands[1] = gen_lowpart (SImode, operands[1]);
9047    operands[2] = gen_int_mode ((INTVAL (operands[2]) >> 8) & 0xff, SImode);")
9049 ;; Since XOR can be encoded with sign extended immediate, this is only
9050 ;; profitable when 7th bit is set.
9051 (define_split
9052   [(set (match_operand 0 "register_operand" "")
9053         (xor (match_operand 1 "general_operand" "")
9054              (match_operand 2 "const_int_operand" "")))
9055    (clobber (reg:CC 17))]
9056    "reload_completed
9057     && ANY_QI_REG_P (operands[0])
9058     && (!TARGET_PARTIAL_REG_STALL || optimize_size)
9059     && !(INTVAL (operands[2]) & ~255)
9060     && (INTVAL (operands[2]) & 128)
9061     && GET_MODE (operands[0]) != QImode"
9062   [(parallel [(set (strict_low_part (match_dup 0))
9063                    (xor:QI (match_dup 1)
9064                            (match_dup 2)))
9065               (clobber (reg:CC 17))])]
9066   "operands[0] = gen_lowpart (QImode, operands[0]);
9067    operands[1] = gen_lowpart (QImode, operands[1]);
9068    operands[2] = gen_lowpart (QImode, operands[2]);")
9070 ;; Negation instructions
9072 (define_expand "negdi2"
9073   [(parallel [(set (match_operand:DI 0 "nonimmediate_operand" "")
9074                    (neg:DI (match_operand:DI 1 "nonimmediate_operand" "")))
9075               (clobber (reg:CC 17))])]
9076   ""
9077   "ix86_expand_unary_operator (NEG, DImode, operands); DONE;")
9079 (define_insn "*negdi2_1"
9080   [(set (match_operand:DI 0 "nonimmediate_operand" "=ro")
9081         (neg:DI (match_operand:DI 1 "general_operand" "0")))
9082    (clobber (reg:CC 17))]
9083   "!TARGET_64BIT
9084    && ix86_unary_operator_ok (NEG, DImode, operands)"
9085   "#")
9087 (define_split
9088   [(set (match_operand:DI 0 "nonimmediate_operand" "")
9089         (neg:DI (match_operand:DI 1 "general_operand" "")))
9090    (clobber (reg:CC 17))]
9091   "!TARGET_64BIT && reload_completed"
9092   [(parallel
9093     [(set (reg:CCZ 17)
9094           (compare:CCZ (neg:SI (match_dup 2)) (const_int 0)))
9095      (set (match_dup 0) (neg:SI (match_dup 2)))])
9096    (parallel
9097     [(set (match_dup 1)
9098           (plus:SI (plus:SI (ltu:SI (reg:CC 17) (const_int 0))
9099                             (match_dup 3))
9100                    (const_int 0)))
9101      (clobber (reg:CC 17))])
9102    (parallel
9103     [(set (match_dup 1)
9104           (neg:SI (match_dup 1)))
9105      (clobber (reg:CC 17))])]
9106   "split_di (operands+1, 1, operands+2, operands+3);
9107    split_di (operands+0, 1, operands+0, operands+1);")
9109 (define_insn "*negdi2_1_rex64"
9110   [(set (match_operand:DI 0 "nonimmediate_operand" "=rm")
9111         (neg:DI (match_operand:DI 1 "nonimmediate_operand" "0")))
9112    (clobber (reg:CC 17))]
9113   "TARGET_64BIT && ix86_unary_operator_ok (NEG, DImode, operands)"
9114   "neg{q}\t%0"
9115   [(set_attr "type" "negnot")
9116    (set_attr "mode" "DI")])
9118 ;; The problem with neg is that it does not perform (compare x 0),
9119 ;; it really performs (compare 0 x), which leaves us with the zero
9120 ;; flag being the only useful item.
9122 (define_insn "*negdi2_cmpz_rex64"
9123   [(set (reg:CCZ 17)
9124         (compare:CCZ (neg:DI (match_operand:DI 1 "nonimmediate_operand" "0"))
9125                      (const_int 0)))
9126    (set (match_operand:DI 0 "nonimmediate_operand" "=rm")
9127         (neg:DI (match_dup 1)))]
9128   "TARGET_64BIT && ix86_unary_operator_ok (NEG, DImode, operands)"
9129   "neg{q}\t%0"
9130   [(set_attr "type" "negnot")
9131    (set_attr "mode" "DI")])
9134 (define_expand "negsi2"
9135   [(parallel [(set (match_operand:SI 0 "nonimmediate_operand" "")
9136                    (neg:SI (match_operand:SI 1 "nonimmediate_operand" "")))
9137               (clobber (reg:CC 17))])]
9138   ""
9139   "ix86_expand_unary_operator (NEG, SImode, operands); DONE;")
9141 (define_insn "*negsi2_1"
9142   [(set (match_operand:SI 0 "nonimmediate_operand" "=rm")
9143         (neg:SI (match_operand:SI 1 "nonimmediate_operand" "0")))
9144    (clobber (reg:CC 17))]
9145   "ix86_unary_operator_ok (NEG, SImode, operands)"
9146   "neg{l}\t%0"
9147   [(set_attr "type" "negnot")
9148    (set_attr "mode" "SI")])
9150 ;; Combine is quite creative about this pattern.
9151 (define_insn "*negsi2_1_zext"
9152   [(set (match_operand:DI 0 "register_operand" "=r")
9153         (lshiftrt:DI (neg:DI (ashift:DI (match_operand:DI 1 "register_operand" "0")
9154                                         (const_int 32)))
9155                      (const_int 32)))
9156    (clobber (reg:CC 17))]
9157   "TARGET_64BIT && ix86_unary_operator_ok (NEG, SImode, operands)"
9158   "neg{l}\t%k0"
9159   [(set_attr "type" "negnot")
9160    (set_attr "mode" "SI")])
9162 ;; The problem with neg is that it does not perform (compare x 0),
9163 ;; it really performs (compare 0 x), which leaves us with the zero
9164 ;; flag being the only useful item.
9166 (define_insn "*negsi2_cmpz"
9167   [(set (reg:CCZ 17)
9168         (compare:CCZ (neg:SI (match_operand:SI 1 "nonimmediate_operand" "0"))
9169                      (const_int 0)))
9170    (set (match_operand:SI 0 "nonimmediate_operand" "=rm")
9171         (neg:SI (match_dup 1)))]
9172   "ix86_unary_operator_ok (NEG, SImode, operands)"
9173   "neg{l}\t%0"
9174   [(set_attr "type" "negnot")
9175    (set_attr "mode" "SI")])
9177 (define_insn "*negsi2_cmpz_zext"
9178   [(set (reg:CCZ 17)
9179         (compare:CCZ (lshiftrt:DI
9180                        (neg:DI (ashift:DI
9181                                  (match_operand:DI 1 "register_operand" "0")
9182                                  (const_int 32)))
9183                        (const_int 32))
9184                      (const_int 0)))
9185    (set (match_operand:DI 0 "register_operand" "=r")
9186         (lshiftrt:DI (neg:DI (ashift:DI (match_dup 1)
9187                                         (const_int 32)))
9188                      (const_int 32)))]
9189   "TARGET_64BIT && ix86_unary_operator_ok (NEG, SImode, operands)"
9190   "neg{l}\t%k0"
9191   [(set_attr "type" "negnot")
9192    (set_attr "mode" "SI")])
9194 (define_expand "neghi2"
9195   [(parallel [(set (match_operand:HI 0 "nonimmediate_operand" "")
9196                    (neg:HI (match_operand:HI 1 "nonimmediate_operand" "")))
9197               (clobber (reg:CC 17))])]
9198   "TARGET_HIMODE_MATH"
9199   "ix86_expand_unary_operator (NEG, HImode, operands); DONE;")
9201 (define_insn "*neghi2_1"
9202   [(set (match_operand:HI 0 "nonimmediate_operand" "=rm")
9203         (neg:HI (match_operand:HI 1 "nonimmediate_operand" "0")))
9204    (clobber (reg:CC 17))]
9205   "ix86_unary_operator_ok (NEG, HImode, operands)"
9206   "neg{w}\t%0"
9207   [(set_attr "type" "negnot")
9208    (set_attr "mode" "HI")])
9210 (define_insn "*neghi2_cmpz"
9211   [(set (reg:CCZ 17)
9212         (compare:CCZ (neg:HI (match_operand:HI 1 "nonimmediate_operand" "0"))
9213                      (const_int 0)))
9214    (set (match_operand:HI 0 "nonimmediate_operand" "=rm")
9215         (neg:HI (match_dup 1)))]
9216   "ix86_unary_operator_ok (NEG, HImode, operands)"
9217   "neg{w}\t%0"
9218   [(set_attr "type" "negnot")
9219    (set_attr "mode" "HI")])
9221 (define_expand "negqi2"
9222   [(parallel [(set (match_operand:QI 0 "nonimmediate_operand" "")
9223                    (neg:QI (match_operand:QI 1 "nonimmediate_operand" "")))
9224               (clobber (reg:CC 17))])]
9225   "TARGET_QIMODE_MATH"
9226   "ix86_expand_unary_operator (NEG, QImode, operands); DONE;")
9228 (define_insn "*negqi2_1"
9229   [(set (match_operand:QI 0 "nonimmediate_operand" "=qm")
9230         (neg:QI (match_operand:QI 1 "nonimmediate_operand" "0")))
9231    (clobber (reg:CC 17))]
9232   "ix86_unary_operator_ok (NEG, QImode, operands)"
9233   "neg{b}\t%0"
9234   [(set_attr "type" "negnot")
9235    (set_attr "mode" "QI")])
9237 (define_insn "*negqi2_cmpz"
9238   [(set (reg:CCZ 17)
9239         (compare:CCZ (neg:QI (match_operand:QI 1 "nonimmediate_operand" "0"))
9240                      (const_int 0)))
9241    (set (match_operand:QI 0 "nonimmediate_operand" "=qm")
9242         (neg:QI (match_dup 1)))]
9243   "ix86_unary_operator_ok (NEG, QImode, operands)"
9244   "neg{b}\t%0"
9245   [(set_attr "type" "negnot")
9246    (set_attr "mode" "QI")])
9248 ;; Changing of sign for FP values is doable using integer unit too.
9250 (define_expand "negsf2"
9251   [(parallel [(set (match_operand:SF 0 "nonimmediate_operand" "")
9252                    (neg:SF (match_operand:SF 1 "nonimmediate_operand" "")))
9253               (clobber (reg:CC 17))])]
9254   "TARGET_80387"
9255   "if (TARGET_SSE)
9256      {
9257        /* In case operand is in memory,  we will not use SSE.  */
9258        if (memory_operand (operands[0], VOIDmode)
9259            && rtx_equal_p (operands[0], operands[1]))
9260          emit_insn (gen_negsf2_memory (operands[0], operands[1]));
9261        else
9262         {
9263           /* Using SSE is tricky, since we need bitwise negation of -0
9264              in register.  */
9265           rtx reg = gen_reg_rtx (SFmode);
9266           rtx dest = operands[0];
9268           operands[1] = force_reg (SFmode, operands[1]);
9269           operands[0] = force_reg (SFmode, operands[0]);
9270           emit_move_insn (reg,
9271                           gen_lowpart (SFmode,
9272                                        gen_int_mode (0x80000000, SImode)));
9273           emit_insn (gen_negsf2_ifs (operands[0], operands[1], reg));
9274           if (dest != operands[0])
9275             emit_move_insn (dest, operands[0]);
9276         }
9277        DONE;
9278      }
9279    ix86_expand_unary_operator (NEG, SFmode, operands); DONE;")
9281 (define_insn "negsf2_memory"
9282   [(set (match_operand:SF 0 "memory_operand" "=m")
9283         (neg:SF (match_operand:SF 1 "memory_operand" "0")))
9284    (clobber (reg:CC 17))]
9285   "ix86_unary_operator_ok (NEG, SFmode, operands)"
9286   "#")
9288 (define_insn "negsf2_ifs"
9289   [(set (match_operand:SF 0 "nonimmediate_operand" "=x#fr,x#fr,f#xr,rm#xf")
9290         (neg:SF (match_operand:SF 1 "nonimmediate_operand" "0,x#fr,0,0")))
9291    (use (match_operand:SF 2 "nonmemory_operand" "x,0#x,*g#x,*g#x"))
9292    (clobber (reg:CC 17))]
9293   "TARGET_SSE
9294    && (reload_in_progress || reload_completed
9295        || (register_operand (operands[0], VOIDmode)
9296            && register_operand (operands[1], VOIDmode)))"
9297   "#")
9299 (define_split
9300   [(set (match_operand:SF 0 "memory_operand" "")
9301         (neg:SF (match_operand:SF 1 "memory_operand" "")))
9302    (use (match_operand:SF 2 "" ""))
9303    (clobber (reg:CC 17))]
9304   ""
9305   [(parallel [(set (match_dup 0)
9306                    (neg:SF (match_dup 1)))
9307               (clobber (reg:CC 17))])])
9309 (define_split
9310   [(set (match_operand:SF 0 "register_operand" "")
9311         (neg:SF (match_operand:SF 1 "register_operand" "")))
9312    (use (match_operand:SF 2 "" ""))
9313    (clobber (reg:CC 17))]
9314   "reload_completed && !SSE_REG_P (operands[0])"
9315   [(parallel [(set (match_dup 0)
9316                    (neg:SF (match_dup 1)))
9317               (clobber (reg:CC 17))])])
9319 (define_split
9320   [(set (match_operand:SF 0 "register_operand" "")
9321         (neg:SF (match_operand:SF 1 "register_operand" "")))
9322    (use (match_operand:SF 2 "register_operand" ""))
9323    (clobber (reg:CC 17))]
9324   "reload_completed && SSE_REG_P (operands[0])"
9325   [(set (subreg:TI (match_dup 0) 0)
9326         (xor:TI (subreg:TI (match_dup 1) 0)
9327                 (subreg:TI (match_dup 2) 0)))]
9329   if (operands_match_p (operands[0], operands[2]))
9330     {
9331       rtx tmp;
9332       tmp = operands[1];
9333       operands[1] = operands[2];
9334       operands[2] = tmp;
9335     }
9339 ;; Keep 'f' and 'r' in separate alternatives to avoid reload problems
9340 ;; because of secondary memory needed to reload from class FLOAT_INT_REGS
9341 ;; to itself.
9342 (define_insn "*negsf2_if"
9343   [(set (match_operand:SF 0 "nonimmediate_operand" "=f#r,rm#f")
9344         (neg:SF (match_operand:SF 1 "nonimmediate_operand" "0,0")))
9345    (clobber (reg:CC 17))]
9346   "TARGET_80387 && !TARGET_SSE
9347    && ix86_unary_operator_ok (NEG, SFmode, operands)"
9348   "#")
9350 (define_split
9351   [(set (match_operand:SF 0 "register_operand" "")
9352         (neg:SF (match_operand:SF 1 "register_operand" "")))
9353    (clobber (reg:CC 17))]
9354   "TARGET_80387 && FP_REGNO_P (REGNO (operands[0])) && reload_completed"
9355   [(set (match_dup 0)
9356         (neg:SF (match_dup 1)))]
9357   "")
9359 (define_split
9360   [(set (match_operand:SF 0 "register_operand" "")
9361         (neg:SF (match_operand:SF 1 "register_operand" "")))
9362    (clobber (reg:CC 17))]
9363   "TARGET_80387 && reload_completed && !FP_REGNO_P (REGNO (operands[0]))"
9364   [(parallel [(set (match_dup 0) (xor:SI (match_dup 0) (match_dup 1)))
9365               (clobber (reg:CC 17))])]
9366   "operands[1] = gen_int_mode (0x80000000, SImode);
9367    operands[0] = gen_rtx_REG (SImode, REGNO (operands[0]));")
9369 (define_split
9370   [(set (match_operand 0 "memory_operand" "")
9371         (neg (match_operand 1 "memory_operand" "")))
9372    (clobber (reg:CC 17))]
9373   "TARGET_80387 && reload_completed && FLOAT_MODE_P (GET_MODE (operands[0]))"
9374   [(parallel [(set (match_dup 0) (xor:QI (match_dup 0) (match_dup 1)))
9375               (clobber (reg:CC 17))])]
9377   int size = GET_MODE_SIZE (GET_MODE (operands[1]));
9379   /* XFmode's size is 12, TFmode 16, but only 10 bytes are used.  */
9380   if (size >= 12)
9381     size = 10;
9382   operands[0] = adjust_address (operands[0], QImode, size - 1);
9383   operands[1] = gen_int_mode (0x80, QImode);
9386 (define_expand "negdf2"
9387   [(parallel [(set (match_operand:DF 0 "nonimmediate_operand" "")
9388                    (neg:DF (match_operand:DF 1 "nonimmediate_operand" "")))
9389               (clobber (reg:CC 17))])]
9390   "TARGET_80387"
9391   "if (TARGET_SSE2)
9392      {
9393        /* In case operand is in memory,  we will not use SSE.  */
9394        if (memory_operand (operands[0], VOIDmode)
9395            && rtx_equal_p (operands[0], operands[1]))
9396          emit_insn (gen_negdf2_memory (operands[0], operands[1]));
9397        else
9398         {
9399           /* Using SSE is tricky, since we need bitwise negation of -0
9400              in register.  */
9401           rtx reg = gen_reg_rtx (DFmode);
9402 #if HOST_BITS_PER_WIDE_INT >= 64
9403           rtx imm = gen_int_mode (((HOST_WIDE_INT)1) << 63, DImode);
9404 #else
9405           rtx imm = immed_double_const (0, 0x80000000, DImode);
9406 #endif
9407           rtx dest = operands[0];
9409           operands[1] = force_reg (DFmode, operands[1]);
9410           operands[0] = force_reg (DFmode, operands[0]);
9411           emit_move_insn (reg, gen_lowpart (DFmode, imm));
9412           emit_insn (gen_negdf2_ifs (operands[0], operands[1], reg));
9413           if (dest != operands[0])
9414             emit_move_insn (dest, operands[0]);
9415         }
9416        DONE;
9417      }
9418    ix86_expand_unary_operator (NEG, DFmode, operands); DONE;")
9420 (define_insn "negdf2_memory"
9421   [(set (match_operand:DF 0 "memory_operand" "=m")
9422         (neg:DF (match_operand:DF 1 "memory_operand" "0")))
9423    (clobber (reg:CC 17))]
9424   "ix86_unary_operator_ok (NEG, DFmode, operands)"
9425   "#")
9427 (define_insn "negdf2_ifs"
9428   [(set (match_operand:DF 0 "nonimmediate_operand" "=Y#fr,Y#fr,f#Yr,rm#Yf")
9429         (neg:DF (match_operand:DF 1 "nonimmediate_operand" "0,Y#fr,0,0")))
9430    (use (match_operand:DF 2 "nonmemory_operand" "Y,0,*g#Y,*g#Y"))
9431    (clobber (reg:CC 17))]
9432   "!TARGET_64BIT && TARGET_SSE2
9433    && (reload_in_progress || reload_completed
9434        || (register_operand (operands[0], VOIDmode)
9435            && register_operand (operands[1], VOIDmode)))"
9436   "#")
9438 (define_insn "*negdf2_ifs_rex64"
9439   [(set (match_operand:DF 0 "nonimmediate_operand" "=Y#fr,Y#fr,fm#Yr,r#Yf")
9440         (neg:DF (match_operand:DF 1 "nonimmediate_operand" "0,Y#fr,0,0")))
9441    (use (match_operand:DF 2 "general_operand" "Y,0,*g#Yr,*rm"))
9442    (clobber (reg:CC 17))]
9443   "TARGET_64BIT && TARGET_SSE2
9444    && (reload_in_progress || reload_completed
9445        || (register_operand (operands[0], VOIDmode)
9446            && register_operand (operands[1], VOIDmode)))"
9447   "#")
9449 (define_split
9450   [(set (match_operand:DF 0 "memory_operand" "")
9451         (neg:DF (match_operand:DF 1 "memory_operand" "")))
9452    (use (match_operand:DF 2 "" ""))
9453    (clobber (reg:CC 17))]
9454   ""
9455   [(parallel [(set (match_dup 0)
9456                    (neg:DF (match_dup 1)))
9457               (clobber (reg:CC 17))])])
9459 (define_split
9460   [(set (match_operand:DF 0 "register_operand" "")
9461         (neg:DF (match_operand:DF 1 "register_operand" "")))
9462    (use (match_operand:DF 2 "" ""))
9463    (clobber (reg:CC 17))]
9464   "reload_completed && !SSE_REG_P (operands[0])
9465    && (!TARGET_64BIT || FP_REG_P (operands[0]))"
9466   [(parallel [(set (match_dup 0)
9467                    (neg:DF (match_dup 1)))
9468               (clobber (reg:CC 17))])])
9470 (define_split
9471   [(set (match_operand:DF 0 "register_operand" "")
9472         (neg:DF (match_operand:DF 1 "register_operand" "")))
9473    (use (match_operand:DF 2 "" ""))
9474    (clobber (reg:CC 17))]
9475   "TARGET_64BIT && reload_completed && GENERAL_REG_P (operands[0])"
9476   [(parallel [(set (match_dup 0)
9477                    (xor:DI (match_dup 1) (match_dup 2)))
9478               (clobber (reg:CC 17))])]
9479    "operands[0] = gen_lowpart (DImode, operands[0]);
9480     operands[1] = gen_lowpart (DImode, operands[1]);
9481     operands[2] = gen_lowpart (DImode, operands[2]);")
9483 (define_split
9484   [(set (match_operand:DF 0 "register_operand" "")
9485         (neg:DF (match_operand:DF 1 "register_operand" "")))
9486    (use (match_operand:DF 2 "register_operand" ""))
9487    (clobber (reg:CC 17))]
9488   "reload_completed && SSE_REG_P (operands[0])"
9489   [(set (subreg:TI (match_dup 0) 0)
9490         (xor:TI (subreg:TI (match_dup 1) 0)
9491                 (subreg:TI (match_dup 2) 0)))]
9493   if (operands_match_p (operands[0], operands[2]))
9494     {
9495       rtx tmp;
9496       tmp = operands[1];
9497       operands[1] = operands[2];
9498       operands[2] = tmp;
9499     }
9502 ;; Keep 'f' and 'r' in separate alternatives to avoid reload problems
9503 ;; because of secondary memory needed to reload from class FLOAT_INT_REGS
9504 ;; to itself.
9505 (define_insn "*negdf2_if"
9506   [(set (match_operand:DF 0 "nonimmediate_operand" "=f#r,rm#f")
9507         (neg:DF (match_operand:DF 1 "nonimmediate_operand" "0,0")))
9508    (clobber (reg:CC 17))]
9509   "!TARGET_64BIT && TARGET_80387
9510    && ix86_unary_operator_ok (NEG, DFmode, operands)"
9511   "#")
9513 ;; FIXME: We should to allow integer registers here.  Problem is that
9514 ;; we need another scratch register to get constant from.
9515 ;; Forcing constant to mem if no register available in peep2 should be
9516 ;; safe even for PIC mode, because of RIP relative addressing.
9517 (define_insn "*negdf2_if_rex64"
9518   [(set (match_operand:DF 0 "nonimmediate_operand" "=f,mf")
9519         (neg:DF (match_operand:DF 1 "nonimmediate_operand" "0,0")))
9520    (clobber (reg:CC 17))]
9521   "TARGET_64BIT && TARGET_80387
9522    && ix86_unary_operator_ok (NEG, DFmode, operands)"
9523   "#")
9525 (define_split
9526   [(set (match_operand:DF 0 "register_operand" "")
9527         (neg:DF (match_operand:DF 1 "register_operand" "")))
9528    (clobber (reg:CC 17))]
9529   "TARGET_80387 && FP_REGNO_P (REGNO (operands[0])) && reload_completed"
9530   [(set (match_dup 0)
9531         (neg:DF (match_dup 1)))]
9532   "")
9534 (define_split
9535   [(set (match_operand:DF 0 "register_operand" "")
9536         (neg:DF (match_operand:DF 1 "register_operand" "")))
9537    (clobber (reg:CC 17))]
9538   "!TARGET_64BIT && TARGET_80387 && reload_completed
9539    && !FP_REGNO_P (REGNO (operands[0]))"
9540   [(parallel [(set (match_dup 3) (xor:SI (match_dup 3) (match_dup 4)))
9541               (clobber (reg:CC 17))])]
9542   "operands[4] = gen_int_mode (0x80000000, SImode);
9543    split_di (operands+0, 1, operands+2, operands+3);")
9545 (define_expand "negxf2"
9546   [(parallel [(set (match_operand:XF 0 "nonimmediate_operand" "")
9547                    (neg:XF (match_operand:XF 1 "nonimmediate_operand" "")))
9548               (clobber (reg:CC 17))])]
9549   "!TARGET_64BIT && TARGET_80387"
9550   "ix86_expand_unary_operator (NEG, XFmode, operands); DONE;")
9552 (define_expand "negtf2"
9553   [(parallel [(set (match_operand:TF 0 "nonimmediate_operand" "")
9554                    (neg:TF (match_operand:TF 1 "nonimmediate_operand" "")))
9555               (clobber (reg:CC 17))])]
9556   "TARGET_80387"
9557   "ix86_expand_unary_operator (NEG, TFmode, operands); DONE;")
9559 ;; Keep 'f' and 'r' in separate alternatives to avoid reload problems
9560 ;; because of secondary memory needed to reload from class FLOAT_INT_REGS
9561 ;; to itself.
9562 (define_insn "*negxf2_if"
9563   [(set (match_operand:XF 0 "nonimmediate_operand" "=f#r,rm#f")
9564         (neg:XF (match_operand:XF 1 "nonimmediate_operand" "0,0")))
9565    (clobber (reg:CC 17))]
9566   "!TARGET_64BIT && TARGET_80387
9567    && ix86_unary_operator_ok (NEG, XFmode, operands)"
9568   "#")
9570 (define_split
9571   [(set (match_operand:XF 0 "register_operand" "")
9572         (neg:XF (match_operand:XF 1 "register_operand" "")))
9573    (clobber (reg:CC 17))]
9574   "TARGET_80387 && FP_REGNO_P (REGNO (operands[0])) && reload_completed"
9575   [(set (match_dup 0)
9576         (neg:XF (match_dup 1)))]
9577   "")
9579 (define_split
9580   [(set (match_operand:XF 0 "register_operand" "")
9581         (neg:XF (match_operand:XF 1 "register_operand" "")))
9582    (clobber (reg:CC 17))]
9583   "TARGET_80387 && reload_completed && !FP_REGNO_P (REGNO (operands[0]))"
9584   [(parallel [(set (match_dup 0) (xor:SI (match_dup 0) (match_dup 1)))
9585               (clobber (reg:CC 17))])]
9586   "operands[1] = GEN_INT (0x8000);
9587    operands[0] = gen_rtx_REG (SImode,
9588                               true_regnum (operands[0]) + (TARGET_64BIT ? 1 : 2));")
9590 ;; Keep 'f' and 'r' in separate alternatives to avoid reload problems
9591 ;; because of secondary memory needed to reload from class FLOAT_INT_REGS
9592 ;; to itself.
9593 (define_insn "*negtf2_if"
9594   [(set (match_operand:TF 0 "nonimmediate_operand" "=f#r,rm#f")
9595         (neg:TF (match_operand:TF 1 "nonimmediate_operand" "0,0")))
9596    (clobber (reg:CC 17))]
9597   "TARGET_80387 && ix86_unary_operator_ok (NEG, TFmode, operands)"
9598   "#")
9600 (define_split
9601   [(set (match_operand:TF 0 "register_operand" "")
9602         (neg:TF (match_operand:TF 1 "register_operand" "")))
9603    (clobber (reg:CC 17))]
9604   "TARGET_80387 && FP_REGNO_P (REGNO (operands[0])) && reload_completed"
9605   [(set (match_dup 0)
9606         (neg:TF (match_dup 1)))]
9607   "")
9609 (define_split
9610   [(set (match_operand:TF 0 "register_operand" "")
9611         (neg:TF (match_operand:TF 1 "register_operand" "")))
9612    (clobber (reg:CC 17))]
9613   "TARGET_80387 && reload_completed && !FP_REGNO_P (REGNO (operands[0]))"
9614   [(parallel [(set (match_dup 0) (xor:SI (match_dup 0) (match_dup 1)))
9615               (clobber (reg:CC 17))])]
9616   "operands[1] = GEN_INT (0x8000);
9617    operands[0] = gen_rtx_REG (SImode,
9618                               true_regnum (operands[0]) + (TARGET_64BIT ? 1 : 2));")
9620 ;; Conditionize these after reload. If they matches before reload, we 
9621 ;; lose the clobber and ability to use integer instructions.
9623 (define_insn "*negsf2_1"
9624   [(set (match_operand:SF 0 "register_operand" "=f")
9625         (neg:SF (match_operand:SF 1 "register_operand" "0")))]
9626   "TARGET_80387 && reload_completed"
9627   "fchs"
9628   [(set_attr "type" "fsgn")
9629    (set_attr "mode" "SF")
9630    (set_attr "ppro_uops" "few")])
9632 (define_insn "*negdf2_1"
9633   [(set (match_operand:DF 0 "register_operand" "=f")
9634         (neg:DF (match_operand:DF 1 "register_operand" "0")))]
9635   "TARGET_80387 && reload_completed"
9636   "fchs"
9637   [(set_attr "type" "fsgn")
9638    (set_attr "mode" "DF")
9639    (set_attr "ppro_uops" "few")])
9641 (define_insn "*negextendsfdf2"
9642   [(set (match_operand:DF 0 "register_operand" "=f")
9643         (neg:DF (float_extend:DF
9644                   (match_operand:SF 1 "register_operand" "0"))))]
9645   "TARGET_80387"
9646   "fchs"
9647   [(set_attr "type" "fsgn")
9648    (set_attr "mode" "DF")
9649    (set_attr "ppro_uops" "few")])
9651 (define_insn "*negxf2_1"
9652   [(set (match_operand:XF 0 "register_operand" "=f")
9653         (neg:XF (match_operand:XF 1 "register_operand" "0")))]
9654   "!TARGET_64BIT && TARGET_80387 && reload_completed"
9655   "fchs"
9656   [(set_attr "type" "fsgn")
9657    (set_attr "mode" "XF")
9658    (set_attr "ppro_uops" "few")])
9660 (define_insn "*negextenddfxf2"
9661   [(set (match_operand:XF 0 "register_operand" "=f")
9662         (neg:XF (float_extend:XF
9663                   (match_operand:DF 1 "register_operand" "0"))))]
9664   "!TARGET_64BIT && TARGET_80387"
9665   "fchs"
9666   [(set_attr "type" "fsgn")
9667    (set_attr "mode" "XF")
9668    (set_attr "ppro_uops" "few")])
9670 (define_insn "*negextendsfxf2"
9671   [(set (match_operand:XF 0 "register_operand" "=f")
9672         (neg:XF (float_extend:XF
9673                   (match_operand:SF 1 "register_operand" "0"))))]
9674   "!TARGET_64BIT && TARGET_80387"
9675   "fchs"
9676   [(set_attr "type" "fsgn")
9677    (set_attr "mode" "XF")
9678    (set_attr "ppro_uops" "few")])
9680 (define_insn "*negtf2_1"
9681   [(set (match_operand:TF 0 "register_operand" "=f")
9682         (neg:TF (match_operand:TF 1 "register_operand" "0")))]
9683   "TARGET_80387 && reload_completed"
9684   "fchs"
9685   [(set_attr "type" "fsgn")
9686    (set_attr "mode" "XF")
9687    (set_attr "ppro_uops" "few")])
9689 (define_insn "*negextenddftf2"
9690   [(set (match_operand:TF 0 "register_operand" "=f")
9691         (neg:TF (float_extend:TF
9692                   (match_operand:DF 1 "register_operand" "0"))))]
9693   "TARGET_80387"
9694   "fchs"
9695   [(set_attr "type" "fsgn")
9696    (set_attr "mode" "XF")
9697    (set_attr "ppro_uops" "few")])
9699 (define_insn "*negextendsftf2"
9700   [(set (match_operand:TF 0 "register_operand" "=f")
9701         (neg:TF (float_extend:TF
9702                   (match_operand:SF 1 "register_operand" "0"))))]
9703   "TARGET_80387"
9704   "fchs"
9705   [(set_attr "type" "fsgn")
9706    (set_attr "mode" "XF")
9707    (set_attr "ppro_uops" "few")])
9709 ;; Absolute value instructions
9711 (define_expand "abssf2"
9712   [(parallel [(set (match_operand:SF 0 "nonimmediate_operand" "")
9713                    (neg:SF (match_operand:SF 1 "nonimmediate_operand" "")))
9714               (clobber (reg:CC 17))])]
9715   "TARGET_80387"
9716   "if (TARGET_SSE)
9717      {
9718        /* In case operand is in memory,  we will not use SSE.  */
9719        if (memory_operand (operands[0], VOIDmode)
9720            && rtx_equal_p (operands[0], operands[1]))
9721          emit_insn (gen_abssf2_memory (operands[0], operands[1]));
9722        else
9723         {
9724           /* Using SSE is tricky, since we need bitwise negation of -0
9725              in register.  */
9726           rtx reg = gen_reg_rtx (SFmode);
9727           rtx dest = operands[0];
9729           operands[1] = force_reg (SFmode, operands[1]);
9730           operands[0] = force_reg (SFmode, operands[0]);
9731           emit_move_insn (reg,
9732                           gen_lowpart (SFmode,
9733                                        gen_int_mode (0x80000000, SImode)));
9734           emit_insn (gen_abssf2_ifs (operands[0], operands[1], reg));
9735           if (dest != operands[0])
9736             emit_move_insn (dest, operands[0]);
9737         }
9738        DONE;
9739      }
9740    ix86_expand_unary_operator (ABS, SFmode, operands); DONE;")
9742 (define_insn "abssf2_memory"
9743   [(set (match_operand:SF 0 "memory_operand" "=m")
9744         (abs:SF (match_operand:SF 1 "memory_operand" "0")))
9745    (clobber (reg:CC 17))]
9746   "ix86_unary_operator_ok (ABS, SFmode, operands)"
9747   "#")
9749 (define_insn "abssf2_ifs"
9750   [(set (match_operand:SF 0 "nonimmediate_operand" "=x#fr,f#xr,rm#xf")
9751         (abs:SF (match_operand:SF 1 "nonimmediate_operand" "x,0,0")))
9752    (use (match_operand:SF 2 "nonmemory_operand" "*0#x,*g#x,*g#x"))
9753    (clobber (reg:CC 17))]
9754   "TARGET_SSE
9755    && (reload_in_progress || reload_completed
9756        || (register_operand (operands[0], VOIDmode)
9757            && register_operand (operands[1], VOIDmode)))"
9758   "#")
9760 (define_split
9761   [(set (match_operand:SF 0 "memory_operand" "")
9762         (abs:SF (match_operand:SF 1 "memory_operand" "")))
9763    (use (match_operand:SF 2 "" ""))
9764    (clobber (reg:CC 17))]
9765   ""
9766   [(parallel [(set (match_dup 0)
9767                    (abs:SF (match_dup 1)))
9768               (clobber (reg:CC 17))])])
9770 (define_split
9771   [(set (match_operand:SF 0 "register_operand" "")
9772         (abs:SF (match_operand:SF 1 "register_operand" "")))
9773    (use (match_operand:SF 2 "" ""))
9774    (clobber (reg:CC 17))]
9775   "reload_completed && !SSE_REG_P (operands[0])"
9776   [(parallel [(set (match_dup 0)
9777                    (abs:SF (match_dup 1)))
9778               (clobber (reg:CC 17))])])
9780 (define_split
9781   [(set (match_operand:SF 0 "register_operand" "")
9782         (abs:SF (match_operand:SF 1 "register_operand" "")))
9783    (use (match_operand:SF 2 "register_operand" ""))
9784    (clobber (reg:CC 17))]
9785   "reload_completed && SSE_REG_P (operands[0])"
9786   [(set (subreg:TI (match_dup 0) 0)
9787         (and:TI (not:TI (subreg:TI (match_dup 2) 0))
9788                 (subreg:TI (match_dup 1) 0)))])
9790 ;; Keep 'f' and 'r' in separate alternatives to avoid reload problems
9791 ;; because of secondary memory needed to reload from class FLOAT_INT_REGS
9792 ;; to itself.
9793 (define_insn "*abssf2_if"
9794   [(set (match_operand:SF 0 "nonimmediate_operand" "=f#r,rm#f")
9795         (abs:SF (match_operand:SF 1 "nonimmediate_operand" "0,0")))
9796    (clobber (reg:CC 17))]
9797   "TARGET_80387 && ix86_unary_operator_ok (ABS, SFmode, operands) && !TARGET_SSE"
9798   "#")
9800 (define_split
9801   [(set (match_operand:SF 0 "register_operand" "")
9802         (abs:SF (match_operand:SF 1 "register_operand" "")))
9803    (clobber (reg:CC 17))]
9804   "TARGET_80387 && FP_REGNO_P (REGNO (operands[0]))"
9805   [(set (match_dup 0)
9806         (abs:SF (match_dup 1)))]
9807   "")
9809 (define_split
9810   [(set (match_operand:SF 0 "register_operand" "")
9811         (abs:SF (match_operand:SF 1 "register_operand" "")))
9812    (clobber (reg:CC 17))]
9813   "TARGET_80387 && reload_completed && !FP_REGNO_P (REGNO (operands[0]))"
9814   [(parallel [(set (match_dup 0) (and:SI (match_dup 0) (match_dup 1)))
9815               (clobber (reg:CC 17))])]
9816   "operands[1] = gen_int_mode (~0x80000000, SImode);
9817    operands[0] = gen_rtx_REG (SImode, REGNO (operands[0]));")
9819 (define_split
9820   [(set (match_operand 0 "memory_operand" "")
9821         (abs (match_operand 1 "memory_operand" "")))
9822    (clobber (reg:CC 17))]
9823   "TARGET_80387 && reload_completed && FLOAT_MODE_P (GET_MODE (operands[0]))"
9824   [(parallel [(set (match_dup 0) (and:QI (match_dup 0) (match_dup 1)))
9825               (clobber (reg:CC 17))])]
9827   int size = GET_MODE_SIZE (GET_MODE (operands[1]));
9829   /* XFmode's size is 12, TFmode 16, but only 10 bytes are used.  */
9830   if (size >= 12)
9831     size = 10;
9832   operands[0] = adjust_address (operands[0], QImode, size - 1);
9833   operands[1] = gen_int_mode (~0x80, QImode);
9836 (define_expand "absdf2"
9837   [(parallel [(set (match_operand:DF 0 "nonimmediate_operand" "")
9838                    (neg:DF (match_operand:DF 1 "nonimmediate_operand" "")))
9839               (clobber (reg:CC 17))])]
9840   "TARGET_80387"
9841   "if (TARGET_SSE2)
9842      {
9843        /* In case operand is in memory,  we will not use SSE.  */
9844        if (memory_operand (operands[0], VOIDmode)
9845            && rtx_equal_p (operands[0], operands[1]))
9846          emit_insn (gen_absdf2_memory (operands[0], operands[1]));
9847        else
9848         {
9849           /* Using SSE is tricky, since we need bitwise negation of -0
9850              in register.  */
9851           rtx reg = gen_reg_rtx (DFmode);
9852 #if HOST_BITS_PER_WIDE_INT >= 64
9853           rtx imm = gen_int_mode (((HOST_WIDE_INT)1) << 63, DImode);
9854 #else
9855           rtx imm = immed_double_const (0, 0x80000000, DImode);
9856 #endif
9857           rtx dest = operands[0];
9859           operands[1] = force_reg (DFmode, operands[1]);
9860           operands[0] = force_reg (DFmode, operands[0]);
9861           emit_move_insn (reg, gen_lowpart (DFmode, imm));
9862           emit_insn (gen_absdf2_ifs (operands[0], operands[1], reg));
9863           if (dest != operands[0])
9864             emit_move_insn (dest, operands[0]);
9865         }
9866        DONE;
9867      }
9868    ix86_expand_unary_operator (ABS, DFmode, operands); DONE;")
9870 (define_insn "absdf2_memory"
9871   [(set (match_operand:DF 0 "memory_operand" "=m")
9872         (abs:DF (match_operand:DF 1 "memory_operand" "0")))
9873    (clobber (reg:CC 17))]
9874   "ix86_unary_operator_ok (ABS, DFmode, operands)"
9875   "#")
9877 (define_insn "absdf2_ifs"
9878   [(set (match_operand:DF 0 "nonimmediate_operand" "=Y#fr,mf#Yr,mr#Yf")
9879         (abs:DF (match_operand:DF 1 "nonimmediate_operand" "Y,0,0")))
9880    (use (match_operand:DF 2 "nonmemory_operand" "*0#Y,*g#Y,*g#Y"))
9881    (clobber (reg:CC 17))]
9882   "!TARGET_64BIT && TARGET_SSE2
9883    && (reload_in_progress || reload_completed
9884        || (register_operand (operands[0], VOIDmode)
9885            && register_operand (operands[1], VOIDmode)))"
9886   "#")
9888 (define_insn "*absdf2_ifs_rex64"
9889   [(set (match_operand:DF 0 "nonimmediate_operand" "=Y#fr,mf#Yr")
9890         (abs:DF (match_operand:DF 1 "nonimmediate_operand" "Y,0")))
9891    (use (match_operand:DF 2 "nonmemory_operand" "*0#Y,*g#Y"))
9892    (clobber (reg:CC 17))]
9893   "TARGET_64BIT && TARGET_SSE2
9894    && (reload_in_progress || reload_completed
9895        || (register_operand (operands[0], VOIDmode)
9896            && register_operand (operands[1], VOIDmode)))"
9897   "#")
9899 (define_split
9900   [(set (match_operand:DF 0 "memory_operand" "")
9901         (abs:DF (match_operand:DF 1 "memory_operand" "")))
9902    (use (match_operand:DF 2 "" ""))
9903    (clobber (reg:CC 17))]
9904   ""
9905   [(parallel [(set (match_dup 0)
9906                    (abs:DF (match_dup 1)))
9907               (clobber (reg:CC 17))])])
9909 (define_split
9910   [(set (match_operand:DF 0 "register_operand" "")
9911         (abs:DF (match_operand:DF 1 "register_operand" "")))
9912    (use (match_operand:DF 2 "" ""))
9913    (clobber (reg:CC 17))]
9914   "reload_completed && !SSE_REG_P (operands[0])"
9915   [(parallel [(set (match_dup 0)
9916                    (abs:DF (match_dup 1)))
9917               (clobber (reg:CC 17))])])
9919 (define_split
9920   [(set (match_operand:DF 0 "register_operand" "")
9921         (abs:DF (match_operand:DF 1 "register_operand" "")))
9922    (use (match_operand:DF 2 "register_operand" ""))
9923    (clobber (reg:CC 17))]
9924   "reload_completed && SSE_REG_P (operands[0])"
9925   [(set (subreg:TI (match_dup 0) 0)
9926         (and:TI (not:TI (subreg:TI (match_dup 2) 0))
9927                 (subreg:TI (match_dup 1) 0)))])
9930 ;; Keep 'f' and 'r' in separate alternatives to avoid reload problems
9931 ;; because of secondary memory needed to reload from class FLOAT_INT_REGS
9932 ;; to itself.
9933 (define_insn "*absdf2_if"
9934   [(set (match_operand:DF 0 "nonimmediate_operand" "=f#r,rm#f")
9935         (abs:DF (match_operand:DF 1 "nonimmediate_operand" "0,0")))
9936    (clobber (reg:CC 17))]
9937   "!TARGET_64BIT && TARGET_80387
9938    && ix86_unary_operator_ok (ABS, DFmode, operands)"
9939   "#")
9941 ;; FIXME: We should to allow integer registers here.  Problem is that
9942 ;; we need another scratch register to get constant from.
9943 ;; Forcing constant to mem if no register available in peep2 should be
9944 ;; safe even for PIC mode, because of RIP relative addressing.
9945 (define_insn "*absdf2_if_rex64"
9946   [(set (match_operand:DF 0 "nonimmediate_operand" "=f,mf")
9947         (abs:DF (match_operand:DF 1 "nonimmediate_operand" "0,0")))
9948    (clobber (reg:CC 17))]
9949   "TARGET_64BIT && TARGET_80387
9950    && ix86_unary_operator_ok (ABS, DFmode, operands)"
9951   "#")
9953 (define_split
9954   [(set (match_operand:DF 0 "register_operand" "")
9955         (abs:DF (match_operand:DF 1 "register_operand" "")))
9956    (clobber (reg:CC 17))]
9957   "TARGET_80387 && FP_REGNO_P (REGNO (operands[0])) && reload_completed"
9958   [(set (match_dup 0)
9959         (abs:DF (match_dup 1)))]
9960   "")
9962 (define_split
9963   [(set (match_operand:DF 0 "register_operand" "")
9964         (abs:DF (match_operand:DF 1 "register_operand" "")))
9965    (clobber (reg:CC 17))]
9966   "!TARGET_64BIT && TARGET_80387 && reload_completed &&
9967    !FP_REGNO_P (REGNO (operands[0]))"
9968   [(parallel [(set (match_dup 3) (and:SI (match_dup 3) (match_dup 4)))
9969               (clobber (reg:CC 17))])]
9970   "operands[4] = gen_int_mode (~0x80000000, SImode);
9971    split_di (operands+0, 1, operands+2, operands+3);")
9973 (define_expand "absxf2"
9974   [(parallel [(set (match_operand:XF 0 "nonimmediate_operand" "")
9975                    (neg:XF (match_operand:XF 1 "nonimmediate_operand" "")))
9976               (clobber (reg:CC 17))])]
9977   "!TARGET_64BIT && TARGET_80387"
9978   "ix86_expand_unary_operator (ABS, XFmode, operands); DONE;")
9980 (define_expand "abstf2"
9981   [(parallel [(set (match_operand:TF 0 "nonimmediate_operand" "")
9982                    (neg:TF (match_operand:TF 1 "nonimmediate_operand" "")))
9983               (clobber (reg:CC 17))])]
9984   "TARGET_80387"
9985   "ix86_expand_unary_operator (ABS, TFmode, operands); DONE;")
9987 ;; Keep 'f' and 'r' in separate alternatives to avoid reload problems
9988 ;; because of secondary memory needed to reload from class FLOAT_INT_REGS
9989 ;; to itself.
9990 (define_insn "*absxf2_if"
9991   [(set (match_operand:XF 0 "nonimmediate_operand" "=f#r,rm#f")
9992         (abs:XF (match_operand:XF 1 "nonimmediate_operand" "0,0")))
9993    (clobber (reg:CC 17))]
9994   "!TARGET_64BIT && TARGET_80387
9995    && ix86_unary_operator_ok (ABS, XFmode, operands)"
9996   "#")
9998 (define_split
9999   [(set (match_operand:XF 0 "register_operand" "")
10000         (abs:XF (match_operand:XF 1 "register_operand" "")))
10001    (clobber (reg:CC 17))]
10002   "TARGET_80387 && FP_REGNO_P (REGNO (operands[0])) && reload_completed"
10003   [(set (match_dup 0)
10004         (abs:XF (match_dup 1)))]
10005   "")
10007 (define_split
10008   [(set (match_operand:XF 0 "register_operand" "")
10009         (abs:XF (match_operand:XF 1 "register_operand" "")))
10010    (clobber (reg:CC 17))]
10011   "TARGET_80387 && reload_completed && !FP_REGNO_P (REGNO (operands[0]))"
10012   [(parallel [(set (match_dup 0) (and:SI (match_dup 0) (match_dup 1)))
10013               (clobber (reg:CC 17))])]
10014   "operands[1] = GEN_INT (~0x8000);
10015    operands[0] = gen_rtx_REG (SImode,
10016                               true_regnum (operands[0]) + (TARGET_64BIT ? 1 : 2));")
10018 (define_insn "*abstf2_if"
10019   [(set (match_operand:TF 0 "nonimmediate_operand" "=f#r,rm#f")
10020         (abs:TF (match_operand:TF 1 "nonimmediate_operand" "0,0")))
10021    (clobber (reg:CC 17))]
10022   "TARGET_80387 && ix86_unary_operator_ok (ABS, TFmode, operands)"
10023   "#")
10025 (define_split
10026   [(set (match_operand:TF 0 "register_operand" "")
10027         (abs:TF (match_operand:TF 1 "register_operand" "")))
10028    (clobber (reg:CC 17))]
10029   "TARGET_80387 && FP_REGNO_P (REGNO (operands[0])) && reload_completed"
10030   [(set (match_dup 0)
10031         (abs:TF (match_dup 1)))]
10032   "")
10034 (define_split
10035   [(set (match_operand:TF 0 "register_operand" "")
10036         (abs:TF (match_operand:TF 1 "register_operand" "")))
10037    (clobber (reg:CC 17))]
10038   "TARGET_80387 && reload_completed && !FP_REGNO_P (REGNO (operands[0]))"
10039   [(parallel [(set (match_dup 0) (and:SI (match_dup 0) (match_dup 1)))
10040               (clobber (reg:CC 17))])]
10041   "operands[1] = GEN_INT (~0x8000);
10042    operands[0] = gen_rtx_REG (SImode,
10043                               true_regnum (operands[0]) + (TARGET_64BIT ? 1 : 2));")
10045 (define_insn "*abssf2_1"
10046   [(set (match_operand:SF 0 "register_operand" "=f")
10047         (abs:SF (match_operand:SF 1 "register_operand" "0")))]
10048   "TARGET_80387 && reload_completed"
10049   "fabs"
10050   [(set_attr "type" "fsgn")
10051    (set_attr "mode" "SF")])
10053 (define_insn "*absdf2_1"
10054   [(set (match_operand:DF 0 "register_operand" "=f")
10055         (abs:DF (match_operand:DF 1 "register_operand" "0")))]
10056   "TARGET_80387 && reload_completed"
10057   "fabs"
10058   [(set_attr "type" "fsgn")
10059    (set_attr "mode" "DF")])
10061 (define_insn "*absextendsfdf2"
10062   [(set (match_operand:DF 0 "register_operand" "=f")
10063         (abs:DF (float_extend:DF
10064                   (match_operand:SF 1 "register_operand" "0"))))]
10065   "TARGET_80387"
10066   "fabs"
10067   [(set_attr "type" "fsgn")
10068    (set_attr "mode" "DF")])
10070 (define_insn "*absxf2_1"
10071   [(set (match_operand:XF 0 "register_operand" "=f")
10072         (abs:XF (match_operand:XF 1 "register_operand" "0")))]
10073   "!TARGET_64BIT && TARGET_80387 && reload_completed"
10074   "fabs"
10075   [(set_attr "type" "fsgn")
10076    (set_attr "mode" "DF")])
10078 (define_insn "*absextenddfxf2"
10079   [(set (match_operand:XF 0 "register_operand" "=f")
10080         (abs:XF (float_extend:XF
10081           (match_operand:DF 1 "register_operand" "0"))))]
10082   "!TARGET_64BIT && TARGET_80387"
10083   "fabs"
10084   [(set_attr "type" "fsgn")
10085    (set_attr "mode" "XF")])
10087 (define_insn "*absextendsfxf2"
10088   [(set (match_operand:XF 0 "register_operand" "=f")
10089         (abs:XF (float_extend:XF
10090           (match_operand:SF 1 "register_operand" "0"))))]
10091   "!TARGET_64BIT && TARGET_80387"
10092   "fabs"
10093   [(set_attr "type" "fsgn")
10094    (set_attr "mode" "XF")])
10096 (define_insn "*abstf2_1"
10097   [(set (match_operand:TF 0 "register_operand" "=f")
10098         (abs:TF (match_operand:TF 1 "register_operand" "0")))]
10099   "TARGET_80387 && reload_completed"
10100   "fabs"
10101   [(set_attr "type" "fsgn")
10102    (set_attr "mode" "DF")])
10104 (define_insn "*absextenddftf2"
10105   [(set (match_operand:TF 0 "register_operand" "=f")
10106         (abs:TF (float_extend:TF
10107           (match_operand:DF 1 "register_operand" "0"))))]
10108   "TARGET_80387"
10109   "fabs"
10110   [(set_attr "type" "fsgn")
10111    (set_attr "mode" "XF")])
10113 (define_insn "*absextendsftf2"
10114   [(set (match_operand:TF 0 "register_operand" "=f")
10115         (abs:TF (float_extend:TF
10116           (match_operand:SF 1 "register_operand" "0"))))]
10117   "TARGET_80387"
10118   "fabs"
10119   [(set_attr "type" "fsgn")
10120    (set_attr "mode" "XF")])
10122 ;; One complement instructions
10124 (define_expand "one_cmpldi2"
10125   [(set (match_operand:DI 0 "nonimmediate_operand" "")
10126         (not:DI (match_operand:DI 1 "nonimmediate_operand" "")))]
10127   "TARGET_64BIT"
10128   "ix86_expand_unary_operator (NOT, DImode, operands); DONE;")
10130 (define_insn "*one_cmpldi2_1_rex64"
10131   [(set (match_operand:DI 0 "nonimmediate_operand" "=rm")
10132         (not:DI (match_operand:DI 1 "nonimmediate_operand" "0")))]
10133   "TARGET_64BIT && ix86_unary_operator_ok (NOT, DImode, operands)"
10134   "not{q}\t%0"
10135   [(set_attr "type" "negnot")
10136    (set_attr "mode" "DI")])
10138 (define_insn "*one_cmpldi2_2_rex64"
10139   [(set (reg 17)
10140         (compare (not:DI (match_operand:DI 1 "nonimmediate_operand" "0"))
10141                  (const_int 0)))
10142    (set (match_operand:DI 0 "nonimmediate_operand" "=rm")
10143         (not:DI (match_dup 1)))]
10144   "TARGET_64BIT && ix86_match_ccmode (insn, CCNOmode)
10145    && ix86_unary_operator_ok (NOT, DImode, operands)"
10146   "#"
10147   [(set_attr "type" "alu1")
10148    (set_attr "mode" "DI")])
10150 (define_split
10151   [(set (reg 17)
10152         (compare (not:DI (match_operand:DI 1 "nonimmediate_operand" ""))
10153                  (const_int 0)))
10154    (set (match_operand:DI 0 "nonimmediate_operand" "")
10155         (not:DI (match_dup 1)))]
10156   "TARGET_64BIT && ix86_match_ccmode (insn, CCNOmode)"
10157   [(parallel [(set (reg:CCNO 17)
10158                    (compare:CCNO (xor:DI (match_dup 1) (const_int -1))
10159                                  (const_int 0)))
10160               (set (match_dup 0)
10161                    (xor:DI (match_dup 1) (const_int -1)))])]
10162   "")
10164 (define_expand "one_cmplsi2"
10165   [(set (match_operand:SI 0 "nonimmediate_operand" "")
10166         (not:SI (match_operand:SI 1 "nonimmediate_operand" "")))]
10167   ""
10168   "ix86_expand_unary_operator (NOT, SImode, operands); DONE;")
10170 (define_insn "*one_cmplsi2_1"
10171   [(set (match_operand:SI 0 "nonimmediate_operand" "=rm")
10172         (not:SI (match_operand:SI 1 "nonimmediate_operand" "0")))]
10173   "ix86_unary_operator_ok (NOT, SImode, operands)"
10174   "not{l}\t%0"
10175   [(set_attr "type" "negnot")
10176    (set_attr "mode" "SI")])
10178 ;; ??? Currently never generated - xor is used instead.
10179 (define_insn "*one_cmplsi2_1_zext"
10180   [(set (match_operand:DI 0 "register_operand" "=r")
10181         (zero_extend:DI (not:SI (match_operand:SI 1 "register_operand" "0"))))]
10182   "TARGET_64BIT && ix86_unary_operator_ok (NOT, SImode, operands)"
10183   "not{l}\t%k0"
10184   [(set_attr "type" "negnot")
10185    (set_attr "mode" "SI")])
10187 (define_insn "*one_cmplsi2_2"
10188   [(set (reg 17)
10189         (compare (not:SI (match_operand:SI 1 "nonimmediate_operand" "0"))
10190                  (const_int 0)))
10191    (set (match_operand:SI 0 "nonimmediate_operand" "=rm")
10192         (not:SI (match_dup 1)))]
10193   "ix86_match_ccmode (insn, CCNOmode)
10194    && ix86_unary_operator_ok (NOT, SImode, operands)"
10195   "#"
10196   [(set_attr "type" "alu1")
10197    (set_attr "mode" "SI")])
10199 (define_split
10200   [(set (reg 17)
10201         (compare (not:SI (match_operand:SI 1 "nonimmediate_operand" ""))
10202                  (const_int 0)))
10203    (set (match_operand:SI 0 "nonimmediate_operand" "")
10204         (not:SI (match_dup 1)))]
10205   "ix86_match_ccmode (insn, CCNOmode)"
10206   [(parallel [(set (reg:CCNO 17)
10207                    (compare:CCNO (xor:SI (match_dup 1) (const_int -1))
10208                                  (const_int 0)))
10209               (set (match_dup 0)
10210                    (xor:SI (match_dup 1) (const_int -1)))])]
10211   "")
10213 ;; ??? Currently never generated - xor is used instead.
10214 (define_insn "*one_cmplsi2_2_zext"
10215   [(set (reg 17)
10216         (compare (not:SI (match_operand:SI 1 "register_operand" "0"))
10217                  (const_int 0)))
10218    (set (match_operand:DI 0 "register_operand" "=r")
10219         (zero_extend:DI (not:SI (match_dup 1))))]
10220   "TARGET_64BIT && ix86_match_ccmode (insn, CCNOmode)
10221    && ix86_unary_operator_ok (NOT, SImode, operands)"
10222   "#"
10223   [(set_attr "type" "alu1")
10224    (set_attr "mode" "SI")])
10226 (define_split
10227   [(set (reg 17)
10228         (compare (not:SI (match_operand:SI 1 "register_operand" ""))
10229                  (const_int 0)))
10230    (set (match_operand:DI 0 "register_operand" "")
10231         (zero_extend:DI (not:SI (match_dup 1))))]
10232   "ix86_match_ccmode (insn, CCNOmode)"
10233   [(parallel [(set (reg:CCNO 17)
10234                    (compare:CCNO (xor:SI (match_dup 1) (const_int -1))
10235                                  (const_int 0)))
10236               (set (match_dup 0)
10237                    (zero_extend:DI (xor:SI (match_dup 1) (const_int -1))))])]
10238   "")
10240 (define_expand "one_cmplhi2"
10241   [(set (match_operand:HI 0 "nonimmediate_operand" "")
10242         (not:HI (match_operand:HI 1 "nonimmediate_operand" "")))]
10243   "TARGET_HIMODE_MATH"
10244   "ix86_expand_unary_operator (NOT, HImode, operands); DONE;")
10246 (define_insn "*one_cmplhi2_1"
10247   [(set (match_operand:HI 0 "nonimmediate_operand" "=rm")
10248         (not:HI (match_operand:HI 1 "nonimmediate_operand" "0")))]
10249   "ix86_unary_operator_ok (NOT, HImode, operands)"
10250   "not{w}\t%0"
10251   [(set_attr "type" "negnot")
10252    (set_attr "mode" "HI")])
10254 (define_insn "*one_cmplhi2_2"
10255   [(set (reg 17)
10256         (compare (not:HI (match_operand:HI 1 "nonimmediate_operand" "0"))
10257                  (const_int 0)))
10258    (set (match_operand:HI 0 "nonimmediate_operand" "=rm")
10259         (not:HI (match_dup 1)))]
10260   "ix86_match_ccmode (insn, CCNOmode)
10261    && ix86_unary_operator_ok (NEG, HImode, operands)"
10262   "#"
10263   [(set_attr "type" "alu1")
10264    (set_attr "mode" "HI")])
10266 (define_split
10267   [(set (reg 17)
10268         (compare (not:HI (match_operand:HI 1 "nonimmediate_operand" ""))
10269                  (const_int 0)))
10270    (set (match_operand:HI 0 "nonimmediate_operand" "")
10271         (not:HI (match_dup 1)))]
10272   "ix86_match_ccmode (insn, CCNOmode)"
10273   [(parallel [(set (reg:CCNO 17)
10274                    (compare:CCNO (xor:HI (match_dup 1) (const_int -1))
10275                                  (const_int 0)))
10276               (set (match_dup 0)
10277                    (xor:HI (match_dup 1) (const_int -1)))])]
10278   "")
10280 ;; %%% Potential partial reg stall on alternative 1.  What to do?
10281 (define_expand "one_cmplqi2"
10282   [(set (match_operand:QI 0 "nonimmediate_operand" "")
10283         (not:QI (match_operand:QI 1 "nonimmediate_operand" "")))]
10284   "TARGET_QIMODE_MATH"
10285   "ix86_expand_unary_operator (NOT, QImode, operands); DONE;")
10287 (define_insn "*one_cmplqi2_1"
10288   [(set (match_operand:QI 0 "nonimmediate_operand" "=qm,r")
10289         (not:QI (match_operand:QI 1 "nonimmediate_operand" "0,0")))]
10290   "ix86_unary_operator_ok (NOT, QImode, operands)"
10291   "@
10292    not{b}\t%0
10293    not{l}\t%k0"
10294   [(set_attr "type" "negnot")
10295    (set_attr "mode" "QI,SI")])
10297 (define_insn "*one_cmplqi2_2"
10298   [(set (reg 17)
10299         (compare (not:QI (match_operand:QI 1 "nonimmediate_operand" "0"))
10300                  (const_int 0)))
10301    (set (match_operand:QI 0 "nonimmediate_operand" "=qm")
10302         (not:QI (match_dup 1)))]
10303   "ix86_match_ccmode (insn, CCNOmode)
10304    && ix86_unary_operator_ok (NOT, QImode, operands)"
10305   "#"
10306   [(set_attr "type" "alu1")
10307    (set_attr "mode" "QI")])
10309 (define_split
10310   [(set (reg 17)
10311         (compare (not:QI (match_operand:QI 1 "nonimmediate_operand" ""))
10312                  (const_int 0)))
10313    (set (match_operand:QI 0 "nonimmediate_operand" "")
10314         (not:QI (match_dup 1)))]
10315   "ix86_match_ccmode (insn, CCNOmode)"
10316   [(parallel [(set (reg:CCNO 17)
10317                    (compare:CCNO (xor:QI (match_dup 1) (const_int -1))
10318                                  (const_int 0)))
10319               (set (match_dup 0)
10320                    (xor:QI (match_dup 1) (const_int -1)))])]
10321   "")
10323 ;; Arithmetic shift instructions
10325 ;; DImode shifts are implemented using the i386 "shift double" opcode,
10326 ;; which is written as "sh[lr]d[lw] imm,reg,reg/mem".  If the shift count
10327 ;; is variable, then the count is in %cl and the "imm" operand is dropped
10328 ;; from the assembler input.
10330 ;; This instruction shifts the target reg/mem as usual, but instead of
10331 ;; shifting in zeros, bits are shifted in from reg operand.  If the insn
10332 ;; is a left shift double, bits are taken from the high order bits of
10333 ;; reg, else if the insn is a shift right double, bits are taken from the
10334 ;; low order bits of reg.  So if %eax is "1234" and %edx is "5678",
10335 ;; "shldl $8,%edx,%eax" leaves %edx unchanged and sets %eax to "2345".
10337 ;; Since sh[lr]d does not change the `reg' operand, that is done
10338 ;; separately, making all shifts emit pairs of shift double and normal
10339 ;; shift.  Since sh[lr]d does not shift more than 31 bits, and we wish to
10340 ;; support a 63 bit shift, each shift where the count is in a reg expands
10341 ;; to a pair of shifts, a branch, a shift by 32 and a label.
10343 ;; If the shift count is a constant, we need never emit more than one
10344 ;; shift pair, instead using moves and sign extension for counts greater
10345 ;; than 31.
10347 (define_expand "ashldi3"
10348   [(parallel [(set (match_operand:DI 0 "shiftdi_operand" "")
10349                    (ashift:DI (match_operand:DI 1 "shiftdi_operand" "")
10350                               (match_operand:QI 2 "nonmemory_operand" "")))
10351               (clobber (reg:CC 17))])]
10352   ""
10354   if (!TARGET_64BIT && TARGET_CMOVE && ! immediate_operand (operands[2], QImode))
10355     {
10356       emit_insn (gen_ashldi3_1 (operands[0], operands[1], operands[2]));
10357       DONE;
10358     }
10359   ix86_expand_binary_operator (ASHIFT, DImode, operands);
10360   DONE;
10363 (define_insn "*ashldi3_1_rex64"
10364   [(set (match_operand:DI 0 "nonimmediate_operand" "=rm,r")
10365         (ashift:DI (match_operand:DI 1 "nonimmediate_operand" "0,r")
10366                    (match_operand:QI 2 "nonmemory_operand" "cJ,M")))
10367    (clobber (reg:CC 17))]
10368   "TARGET_64BIT && ix86_binary_operator_ok (ASHIFT, DImode, operands)"
10370   switch (get_attr_type (insn))
10371     {
10372     case TYPE_ALU:
10373       if (operands[2] != const1_rtx)
10374         abort ();
10375       if (!rtx_equal_p (operands[0], operands[1]))
10376         abort ();
10377       return "add{q}\t{%0, %0|%0, %0}";
10379     case TYPE_LEA:
10380       if (GET_CODE (operands[2]) != CONST_INT
10381           || (unsigned HOST_WIDE_INT) INTVAL (operands[2]) > 3)
10382         abort ();
10383       operands[1] = gen_rtx_MULT (DImode, operands[1],
10384                                   GEN_INT (1 << INTVAL (operands[2])));
10385       return "lea{q}\t{%a1, %0|%0, %a1}";
10387     default:
10388       if (REG_P (operands[2]))
10389         return "sal{q}\t{%b2, %0|%0, %b2}";
10390       else if (GET_CODE (operands[2]) == CONST_INT
10391                && INTVAL (operands[2]) == 1
10392                && (TARGET_SHIFT1 || optimize_size))
10393         return "sal{q}\t%0";
10394       else
10395         return "sal{q}\t{%2, %0|%0, %2}";
10396     }
10398   [(set (attr "type")
10399      (cond [(eq_attr "alternative" "1")
10400               (const_string "lea")
10401             (and (and (ne (symbol_ref "TARGET_DOUBLE_WITH_ADD")
10402                           (const_int 0))
10403                       (match_operand 0 "register_operand" ""))
10404                  (match_operand 2 "const1_operand" ""))
10405               (const_string "alu")
10406            ]
10407            (const_string "ishift")))
10408    (set_attr "mode" "DI")])
10410 ;; Convert lea to the lea pattern to avoid flags dependency.
10411 (define_split
10412   [(set (match_operand:DI 0 "register_operand" "")
10413         (ashift:DI (match_operand:DI 1 "register_operand" "")
10414                    (match_operand:QI 2 "immediate_operand" "")))
10415    (clobber (reg:CC 17))]
10416   "TARGET_64BIT && reload_completed
10417    && true_regnum (operands[0]) != true_regnum (operands[1])"
10418   [(set (match_dup 0)
10419         (mult:DI (match_dup 1)
10420                  (match_dup 2)))]
10421   "operands[2] = gen_int_mode (1 << INTVAL (operands[2]), DImode);")
10423 ;; This pattern can't accept a variable shift count, since shifts by
10424 ;; zero don't affect the flags.  We assume that shifts by constant
10425 ;; zero are optimized away.
10426 (define_insn "*ashldi3_cmp_rex64"
10427   [(set (reg 17)
10428         (compare
10429           (ashift:DI (match_operand:DI 1 "nonimmediate_operand" "0")
10430                      (match_operand:QI 2 "immediate_operand" "e"))
10431           (const_int 0)))
10432    (set (match_operand:DI 0 "nonimmediate_operand" "=rm")
10433         (ashift:DI (match_dup 1) (match_dup 2)))]
10434   "TARGET_64BIT && ix86_match_ccmode (insn, CCGOCmode)
10435    && ix86_binary_operator_ok (ASHIFT, DImode, operands)"
10437   switch (get_attr_type (insn))
10438     {
10439     case TYPE_ALU:
10440       if (operands[2] != const1_rtx)
10441         abort ();
10442       return "add{q}\t{%0, %0|%0, %0}";
10444     default:
10445       if (REG_P (operands[2]))
10446         return "sal{q}\t{%b2, %0|%0, %b2}";
10447       else if (GET_CODE (operands[2]) == CONST_INT
10448                && INTVAL (operands[2]) == 1
10449                && (TARGET_SHIFT1 || optimize_size))
10450         return "sal{q}\t%0";
10451       else
10452         return "sal{q}\t{%2, %0|%0, %2}";
10453     }
10455   [(set (attr "type")
10456      (cond [(and (and (ne (symbol_ref "TARGET_DOUBLE_WITH_ADD")
10457                           (const_int 0))
10458                       (match_operand 0 "register_operand" ""))
10459                  (match_operand 2 "const1_operand" ""))
10460               (const_string "alu")
10461            ]
10462            (const_string "ishift")))
10463    (set_attr "mode" "DI")])
10465 (define_insn "ashldi3_1"
10466   [(set (match_operand:DI 0 "register_operand" "=r")
10467         (ashift:DI (match_operand:DI 1 "register_operand" "0")
10468                    (match_operand:QI 2 "nonmemory_operand" "Jc")))
10469    (clobber (match_scratch:SI 3 "=&r"))
10470    (clobber (reg:CC 17))]
10471   "!TARGET_64BIT && TARGET_CMOVE"
10472   "#"
10473   [(set_attr "type" "multi")])
10475 (define_insn "*ashldi3_2"
10476   [(set (match_operand:DI 0 "register_operand" "=r")
10477         (ashift:DI (match_operand:DI 1 "register_operand" "0")
10478                    (match_operand:QI 2 "nonmemory_operand" "Jc")))
10479    (clobber (reg:CC 17))]
10480   "!TARGET_64BIT"
10481   "#"
10482   [(set_attr "type" "multi")])
10484 (define_split
10485   [(set (match_operand:DI 0 "register_operand" "")
10486         (ashift:DI (match_operand:DI 1 "register_operand" "")
10487                    (match_operand:QI 2 "nonmemory_operand" "")))
10488    (clobber (match_scratch:SI 3 ""))
10489    (clobber (reg:CC 17))]
10490   "!TARGET_64BIT && TARGET_CMOVE && reload_completed"
10491   [(const_int 0)]
10492   "ix86_split_ashldi (operands, operands[3]); DONE;")
10494 (define_split
10495   [(set (match_operand:DI 0 "register_operand" "")
10496         (ashift:DI (match_operand:DI 1 "register_operand" "")
10497                    (match_operand:QI 2 "nonmemory_operand" "")))
10498    (clobber (reg:CC 17))]
10499   "!TARGET_64BIT && reload_completed"
10500   [(const_int 0)]
10501   "ix86_split_ashldi (operands, NULL_RTX); DONE;")
10503 (define_insn "x86_shld_1"
10504   [(set (match_operand:SI 0 "nonimmediate_operand" "+r*m,r*m")
10505         (ior:SI (ashift:SI (match_dup 0)
10506                   (match_operand:QI 2 "nonmemory_operand" "I,c"))
10507                 (lshiftrt:SI (match_operand:SI 1 "register_operand" "r,r")
10508                   (minus:QI (const_int 32) (match_dup 2)))))
10509    (clobber (reg:CC 17))]
10510   ""
10511   "@
10512    shld{l}\t{%2, %1, %0|%0, %1, %2}
10513    shld{l}\t{%s2%1, %0|%0, %1, %2}"
10514   [(set_attr "type" "ishift")
10515    (set_attr "prefix_0f" "1")
10516    (set_attr "mode" "SI")
10517    (set_attr "pent_pair" "np")
10518    (set_attr "athlon_decode" "vector")
10519    (set_attr "ppro_uops" "few")])
10521 (define_expand "x86_shift_adj_1"
10522   [(set (reg:CCZ 17)
10523         (compare:CCZ (and:QI (match_operand:QI 2 "register_operand" "")
10524                              (const_int 32))
10525                      (const_int 0)))
10526    (set (match_operand:SI 0 "register_operand" "")
10527         (if_then_else:SI (ne (reg:CCZ 17) (const_int 0))
10528                          (match_operand:SI 1 "register_operand" "")
10529                          (match_dup 0)))
10530    (set (match_dup 1)
10531         (if_then_else:SI (ne (reg:CCZ 17) (const_int 0))
10532                          (match_operand:SI 3 "register_operand" "r")
10533                          (match_dup 1)))]
10534   "TARGET_CMOVE"
10535   "")
10537 (define_expand "x86_shift_adj_2"
10538   [(use (match_operand:SI 0 "register_operand" ""))
10539    (use (match_operand:SI 1 "register_operand" ""))
10540    (use (match_operand:QI 2 "register_operand" ""))]
10541   ""
10543   rtx label = gen_label_rtx ();
10544   rtx tmp;
10546   emit_insn (gen_testqi_ccz_1 (operands[2], GEN_INT (32)));
10548   tmp = gen_rtx_REG (CCZmode, FLAGS_REG);
10549   tmp = gen_rtx_EQ (VOIDmode, tmp, const0_rtx);
10550   tmp = gen_rtx_IF_THEN_ELSE (VOIDmode, tmp,
10551                               gen_rtx_LABEL_REF (VOIDmode, label),
10552                               pc_rtx);
10553   tmp = emit_jump_insn (gen_rtx_SET (VOIDmode, pc_rtx, tmp));
10554   JUMP_LABEL (tmp) = label;
10556   emit_move_insn (operands[0], operands[1]);
10557   emit_move_insn (operands[1], const0_rtx);
10559   emit_label (label);
10560   LABEL_NUSES (label) = 1;
10562   DONE;
10565 (define_expand "ashlsi3"
10566   [(set (match_operand:SI 0 "nonimmediate_operand" "")
10567         (ashift:SI (match_operand:SI 1 "nonimmediate_operand" "")
10568                    (match_operand:QI 2 "nonmemory_operand" "")))
10569    (clobber (reg:CC 17))]
10570   ""
10571   "ix86_expand_binary_operator (ASHIFT, SImode, operands); DONE;")
10573 (define_insn "*ashlsi3_1"
10574   [(set (match_operand:SI 0 "nonimmediate_operand" "=rm,r")
10575         (ashift:SI (match_operand:SI 1 "nonimmediate_operand" "0,r")
10576                    (match_operand:QI 2 "nonmemory_operand" "cI,M")))
10577    (clobber (reg:CC 17))]
10578   "ix86_binary_operator_ok (ASHIFT, SImode, operands)"
10580   switch (get_attr_type (insn))
10581     {
10582     case TYPE_ALU:
10583       if (operands[2] != const1_rtx)
10584         abort ();
10585       if (!rtx_equal_p (operands[0], operands[1]))
10586         abort ();
10587       return "add{l}\t{%0, %0|%0, %0}";
10589     case TYPE_LEA:
10590       return "#";
10592     default:
10593       if (REG_P (operands[2]))
10594         return "sal{l}\t{%b2, %0|%0, %b2}";
10595       else if (GET_CODE (operands[2]) == CONST_INT
10596                && INTVAL (operands[2]) == 1
10597                && (TARGET_SHIFT1 || optimize_size))
10598         return "sal{l}\t%0";
10599       else
10600         return "sal{l}\t{%2, %0|%0, %2}";
10601     }
10603   [(set (attr "type")
10604      (cond [(eq_attr "alternative" "1")
10605               (const_string "lea")
10606             (and (and (ne (symbol_ref "TARGET_DOUBLE_WITH_ADD")
10607                           (const_int 0))
10608                       (match_operand 0 "register_operand" ""))
10609                  (match_operand 2 "const1_operand" ""))
10610               (const_string "alu")
10611            ]
10612            (const_string "ishift")))
10613    (set_attr "mode" "SI")])
10615 ;; Convert lea to the lea pattern to avoid flags dependency.
10616 (define_split
10617   [(set (match_operand 0 "register_operand" "")
10618         (ashift (match_operand 1 "index_register_operand" "")
10619                 (match_operand:QI 2 "const_int_operand" "")))
10620    (clobber (reg:CC 17))]
10621   "reload_completed
10622    && true_regnum (operands[0]) != true_regnum (operands[1])"
10623   [(const_int 0)]
10625   rtx pat;
10626   operands[0] = gen_lowpart (SImode, operands[0]);
10627   operands[1] = gen_lowpart (Pmode, operands[1]);
10628   operands[2] = gen_int_mode (1 << INTVAL (operands[2]), Pmode);
10629   pat = gen_rtx_MULT (Pmode, operands[1], operands[2]);
10630   if (Pmode != SImode)
10631     pat = gen_rtx_SUBREG (SImode, pat, 0);
10632   emit_insn (gen_rtx_SET (VOIDmode, operands[0], pat));
10633   DONE;
10636 ;; Rare case of shifting RSP is handled by generating move and shift
10637 (define_split
10638   [(set (match_operand 0 "register_operand" "")
10639         (ashift (match_operand 1 "register_operand" "")
10640                 (match_operand:QI 2 "const_int_operand" "")))
10641    (clobber (reg:CC 17))]
10642   "reload_completed
10643    && true_regnum (operands[0]) != true_regnum (operands[1])"
10644   [(const_int 0)]
10646   rtx pat, clob;
10647   emit_move_insn (operands[1], operands[0]);
10648   pat = gen_rtx_SET (VOIDmode, operands[0],
10649                      gen_rtx_ASHIFT (GET_MODE (operands[0]),
10650                                      operands[0], operands[2]));
10651   clob = gen_rtx_CLOBBER (VOIDmode, gen_rtx_REG (CCmode, FLAGS_REG));
10652   emit_insn (gen_rtx_PARALLEL (VOIDmode, gen_rtvec (2, pat, clob)));
10653   DONE;
10656 (define_insn "*ashlsi3_1_zext"
10657   [(set (match_operand:DI 0 "register_operand" "=r,r")
10658         (zero_extend:DI (ashift:SI (match_operand:SI 1 "register_operand" "0,r")
10659                         (match_operand:QI 2 "nonmemory_operand" "cI,M"))))
10660    (clobber (reg:CC 17))]
10661   "TARGET_64BIT && ix86_binary_operator_ok (ASHIFT, SImode, operands)"
10663   switch (get_attr_type (insn))
10664     {
10665     case TYPE_ALU:
10666       if (operands[2] != const1_rtx)
10667         abort ();
10668       return "add{l}\t{%k0, %k0|%k0, %k0}";
10670     case TYPE_LEA:
10671       return "#";
10673     default:
10674       if (REG_P (operands[2]))
10675         return "sal{l}\t{%b2, %k0|%k0, %b2}";
10676       else if (GET_CODE (operands[2]) == CONST_INT
10677                && INTVAL (operands[2]) == 1
10678                && (TARGET_SHIFT1 || optimize_size))
10679         return "sal{l}\t%k0";
10680       else
10681         return "sal{l}\t{%2, %k0|%k0, %2}";
10682     }
10684   [(set (attr "type")
10685      (cond [(eq_attr "alternative" "1")
10686               (const_string "lea")
10687             (and (ne (symbol_ref "TARGET_DOUBLE_WITH_ADD")
10688                      (const_int 0))
10689                  (match_operand 2 "const1_operand" ""))
10690               (const_string "alu")
10691            ]
10692            (const_string "ishift")))
10693    (set_attr "mode" "SI")])
10695 ;; Convert lea to the lea pattern to avoid flags dependency.
10696 (define_split
10697   [(set (match_operand:DI 0 "register_operand" "")
10698         (zero_extend:DI (ashift (match_operand 1 "register_operand" "")
10699                                 (match_operand:QI 2 "const_int_operand" ""))))
10700    (clobber (reg:CC 17))]
10701   "reload_completed
10702    && true_regnum (operands[0]) != true_regnum (operands[1])"
10703   [(set (match_dup 0) (zero_extend:DI (subreg:SI (mult:SI (match_dup 1) (match_dup 2)) 0)))]
10705   operands[1] = gen_lowpart (Pmode, operands[1]);
10706   operands[2] = gen_int_mode (1 << INTVAL (operands[2]), Pmode);
10709 ;; This pattern can't accept a variable shift count, since shifts by
10710 ;; zero don't affect the flags.  We assume that shifts by constant
10711 ;; zero are optimized away.
10712 (define_insn "*ashlsi3_cmp"
10713   [(set (reg 17)
10714         (compare
10715           (ashift:SI (match_operand:SI 1 "nonimmediate_operand" "0")
10716                      (match_operand:QI 2 "const_int_1_31_operand" "I"))
10717           (const_int 0)))
10718    (set (match_operand:SI 0 "nonimmediate_operand" "=rm")
10719         (ashift:SI (match_dup 1) (match_dup 2)))]
10720   "ix86_match_ccmode (insn, CCGOCmode)
10721    && ix86_binary_operator_ok (ASHIFT, SImode, operands)"
10723   switch (get_attr_type (insn))
10724     {
10725     case TYPE_ALU:
10726       if (operands[2] != const1_rtx)
10727         abort ();
10728       return "add{l}\t{%0, %0|%0, %0}";
10730     default:
10731       if (REG_P (operands[2]))
10732         return "sal{l}\t{%b2, %0|%0, %b2}";
10733       else if (GET_CODE (operands[2]) == CONST_INT
10734                && INTVAL (operands[2]) == 1
10735                && (TARGET_SHIFT1 || optimize_size))
10736         return "sal{l}\t%0";
10737       else
10738         return "sal{l}\t{%2, %0|%0, %2}";
10739     }
10741   [(set (attr "type")
10742      (cond [(and (and (ne (symbol_ref "TARGET_DOUBLE_WITH_ADD")
10743                           (const_int 0))
10744                       (match_operand 0 "register_operand" ""))
10745                  (match_operand 2 "const1_operand" ""))
10746               (const_string "alu")
10747            ]
10748            (const_string "ishift")))
10749    (set_attr "mode" "SI")])
10751 (define_insn "*ashlsi3_cmp_zext"
10752   [(set (reg 17)
10753         (compare
10754           (ashift:SI (match_operand:SI 1 "register_operand" "0")
10755                      (match_operand:QI 2 "const_int_1_31_operand" "I"))
10756           (const_int 0)))
10757    (set (match_operand:DI 0 "register_operand" "=r")
10758         (zero_extend:DI (ashift:SI (match_dup 1) (match_dup 2))))]
10759   "TARGET_64BIT && ix86_match_ccmode (insn, CCGOCmode)
10760    && ix86_binary_operator_ok (ASHIFT, SImode, operands)"
10762   switch (get_attr_type (insn))
10763     {
10764     case TYPE_ALU:
10765       if (operands[2] != const1_rtx)
10766         abort ();
10767       return "add{l}\t{%k0, %k0|%k0, %k0}";
10769     default:
10770       if (REG_P (operands[2]))
10771         return "sal{l}\t{%b2, %k0|%k0, %b2}";
10772       else if (GET_CODE (operands[2]) == CONST_INT
10773                && INTVAL (operands[2]) == 1
10774                && (TARGET_SHIFT1 || optimize_size))
10775         return "sal{l}\t%k0";
10776       else
10777         return "sal{l}\t{%2, %k0|%k0, %2}";
10778     }
10780   [(set (attr "type")
10781      (cond [(and (ne (symbol_ref "TARGET_DOUBLE_WITH_ADD")
10782                      (const_int 0))
10783                  (match_operand 2 "const1_operand" ""))
10784               (const_string "alu")
10785            ]
10786            (const_string "ishift")))
10787    (set_attr "mode" "SI")])
10789 (define_expand "ashlhi3"
10790   [(set (match_operand:HI 0 "nonimmediate_operand" "")
10791         (ashift:HI (match_operand:HI 1 "nonimmediate_operand" "")
10792                    (match_operand:QI 2 "nonmemory_operand" "")))
10793    (clobber (reg:CC 17))]
10794   "TARGET_HIMODE_MATH"
10795   "ix86_expand_binary_operator (ASHIFT, HImode, operands); DONE;")
10797 (define_insn "*ashlhi3_1_lea"
10798   [(set (match_operand:HI 0 "nonimmediate_operand" "=rm,r")
10799         (ashift:HI (match_operand:HI 1 "nonimmediate_operand" "0,r")
10800                    (match_operand:QI 2 "nonmemory_operand" "cI,M")))
10801    (clobber (reg:CC 17))]
10802   "!TARGET_PARTIAL_REG_STALL
10803    && ix86_binary_operator_ok (ASHIFT, HImode, operands)"
10805   switch (get_attr_type (insn))
10806     {
10807     case TYPE_LEA:
10808       return "#";
10809     case TYPE_ALU:
10810       if (operands[2] != const1_rtx)
10811         abort ();
10812       return "add{w}\t{%0, %0|%0, %0}";
10814     default:
10815       if (REG_P (operands[2]))
10816         return "sal{w}\t{%b2, %0|%0, %b2}";
10817       else if (GET_CODE (operands[2]) == CONST_INT
10818                && INTVAL (operands[2]) == 1
10819                && (TARGET_SHIFT1 || optimize_size))
10820         return "sal{w}\t%0";
10821       else
10822         return "sal{w}\t{%2, %0|%0, %2}";
10823     }
10825   [(set (attr "type")
10826      (cond [(eq_attr "alternative" "1")
10827               (const_string "lea")
10828             (and (and (ne (symbol_ref "TARGET_DOUBLE_WITH_ADD")
10829                           (const_int 0))
10830                       (match_operand 0 "register_operand" ""))
10831                  (match_operand 2 "const1_operand" ""))
10832               (const_string "alu")
10833            ]
10834            (const_string "ishift")))
10835    (set_attr "mode" "HI,SI")])
10837 (define_insn "*ashlhi3_1"
10838   [(set (match_operand:HI 0 "nonimmediate_operand" "=rm")
10839         (ashift:HI (match_operand:HI 1 "nonimmediate_operand" "0")
10840                    (match_operand:QI 2 "nonmemory_operand" "cI")))
10841    (clobber (reg:CC 17))]
10842   "TARGET_PARTIAL_REG_STALL
10843    && ix86_binary_operator_ok (ASHIFT, HImode, operands)"
10845   switch (get_attr_type (insn))
10846     {
10847     case TYPE_ALU:
10848       if (operands[2] != const1_rtx)
10849         abort ();
10850       return "add{w}\t{%0, %0|%0, %0}";
10852     default:
10853       if (REG_P (operands[2]))
10854         return "sal{w}\t{%b2, %0|%0, %b2}";
10855       else if (GET_CODE (operands[2]) == CONST_INT
10856                && INTVAL (operands[2]) == 1
10857                && (TARGET_SHIFT1 || optimize_size))
10858         return "sal{w}\t%0";
10859       else
10860         return "sal{w}\t{%2, %0|%0, %2}";
10861     }
10863   [(set (attr "type")
10864      (cond [(and (and (ne (symbol_ref "TARGET_DOUBLE_WITH_ADD")
10865                           (const_int 0))
10866                       (match_operand 0 "register_operand" ""))
10867                  (match_operand 2 "const1_operand" ""))
10868               (const_string "alu")
10869            ]
10870            (const_string "ishift")))
10871    (set_attr "mode" "HI")])
10873 ;; This pattern can't accept a variable shift count, since shifts by
10874 ;; zero don't affect the flags.  We assume that shifts by constant
10875 ;; zero are optimized away.
10876 (define_insn "*ashlhi3_cmp"
10877   [(set (reg 17)
10878         (compare
10879           (ashift:HI (match_operand:HI 1 "nonimmediate_operand" "0")
10880                      (match_operand:QI 2 "const_int_1_31_operand" "I"))
10881           (const_int 0)))
10882    (set (match_operand:HI 0 "nonimmediate_operand" "=rm")
10883         (ashift:HI (match_dup 1) (match_dup 2)))]
10884   "ix86_match_ccmode (insn, CCGOCmode)
10885    && ix86_binary_operator_ok (ASHIFT, HImode, operands)"
10887   switch (get_attr_type (insn))
10888     {
10889     case TYPE_ALU:
10890       if (operands[2] != const1_rtx)
10891         abort ();
10892       return "add{w}\t{%0, %0|%0, %0}";
10894     default:
10895       if (REG_P (operands[2]))
10896         return "sal{w}\t{%b2, %0|%0, %b2}";
10897       else if (GET_CODE (operands[2]) == CONST_INT
10898                && INTVAL (operands[2]) == 1
10899                && (TARGET_SHIFT1 || optimize_size))
10900         return "sal{w}\t%0";
10901       else
10902         return "sal{w}\t{%2, %0|%0, %2}";
10903     }
10905   [(set (attr "type")
10906      (cond [(and (and (ne (symbol_ref "TARGET_DOUBLE_WITH_ADD")
10907                           (const_int 0))
10908                       (match_operand 0 "register_operand" ""))
10909                  (match_operand 2 "const1_operand" ""))
10910               (const_string "alu")
10911            ]
10912            (const_string "ishift")))
10913    (set_attr "mode" "HI")])
10915 (define_expand "ashlqi3"
10916   [(set (match_operand:QI 0 "nonimmediate_operand" "")
10917         (ashift:QI (match_operand:QI 1 "nonimmediate_operand" "")
10918                    (match_operand:QI 2 "nonmemory_operand" "")))
10919    (clobber (reg:CC 17))]
10920   "TARGET_QIMODE_MATH"
10921   "ix86_expand_binary_operator (ASHIFT, QImode, operands); DONE;")
10923 ;; %%% Potential partial reg stall on alternative 2.  What to do?
10925 (define_insn "*ashlqi3_1_lea"
10926   [(set (match_operand:QI 0 "nonimmediate_operand" "=qm,r,r")
10927         (ashift:QI (match_operand:QI 1 "nonimmediate_operand" "0,0,r")
10928                    (match_operand:QI 2 "nonmemory_operand" "cI,cI,M")))
10929    (clobber (reg:CC 17))]
10930   "!TARGET_PARTIAL_REG_STALL
10931    && ix86_binary_operator_ok (ASHIFT, QImode, operands)"
10933   switch (get_attr_type (insn))
10934     {
10935     case TYPE_LEA:
10936       return "#";
10937     case TYPE_ALU:
10938       if (operands[2] != const1_rtx)
10939         abort ();
10940       if (REG_P (operands[1]) && !ANY_QI_REG_P (operands[1]))
10941         return "add{l}\t{%k0, %k0|%k0, %k0}";
10942       else
10943         return "add{b}\t{%0, %0|%0, %0}";
10945     default:
10946       if (REG_P (operands[2]))
10947         {
10948           if (get_attr_mode (insn) == MODE_SI)
10949             return "sal{l}\t{%b2, %k0|%k0, %b2}";
10950           else
10951             return "sal{b}\t{%b2, %0|%0, %b2}";
10952         }
10953       else if (GET_CODE (operands[2]) == CONST_INT
10954                && INTVAL (operands[2]) == 1
10955                && (TARGET_SHIFT1 || optimize_size))
10956         {
10957           if (get_attr_mode (insn) == MODE_SI)
10958             return "sal{l}\t%0";
10959           else
10960             return "sal{b}\t%0";
10961         }
10962       else
10963         {
10964           if (get_attr_mode (insn) == MODE_SI)
10965             return "sal{l}\t{%2, %k0|%k0, %2}";
10966           else
10967             return "sal{b}\t{%2, %0|%0, %2}";
10968         }
10969     }
10971   [(set (attr "type")
10972      (cond [(eq_attr "alternative" "2")
10973               (const_string "lea")
10974             (and (and (ne (symbol_ref "TARGET_DOUBLE_WITH_ADD")
10975                           (const_int 0))
10976                       (match_operand 0 "register_operand" ""))
10977                  (match_operand 2 "const1_operand" ""))
10978               (const_string "alu")
10979            ]
10980            (const_string "ishift")))
10981    (set_attr "mode" "QI,SI,SI")])
10983 (define_insn "*ashlqi3_1"
10984   [(set (match_operand:QI 0 "nonimmediate_operand" "=qm,r")
10985         (ashift:QI (match_operand:QI 1 "nonimmediate_operand" "0,0")
10986                    (match_operand:QI 2 "nonmemory_operand" "cI,cI")))
10987    (clobber (reg:CC 17))]
10988   "TARGET_PARTIAL_REG_STALL
10989    && ix86_binary_operator_ok (ASHIFT, QImode, operands)"
10991   switch (get_attr_type (insn))
10992     {
10993     case TYPE_ALU:
10994       if (operands[2] != const1_rtx)
10995         abort ();
10996       if (REG_P (operands[1]) && !ANY_QI_REG_P (operands[1]))
10997         return "add{l}\t{%k0, %k0|%k0, %k0}";
10998       else
10999         return "add{b}\t{%0, %0|%0, %0}";
11001     default:
11002       if (REG_P (operands[2]))
11003         {
11004           if (get_attr_mode (insn) == MODE_SI)
11005             return "sal{l}\t{%b2, %k0|%k0, %b2}";
11006           else
11007             return "sal{b}\t{%b2, %0|%0, %b2}";
11008         }
11009       else if (GET_CODE (operands[2]) == CONST_INT
11010                && INTVAL (operands[2]) == 1
11011                && (TARGET_SHIFT1 || optimize_size))
11012         {
11013           if (get_attr_mode (insn) == MODE_SI)
11014             return "sal{l}\t%0";
11015           else
11016             return "sal{b}\t%0";
11017         }
11018       else
11019         {
11020           if (get_attr_mode (insn) == MODE_SI)
11021             return "sal{l}\t{%2, %k0|%k0, %2}";
11022           else
11023             return "sal{b}\t{%2, %0|%0, %2}";
11024         }
11025     }
11027   [(set (attr "type")
11028      (cond [(and (and (ne (symbol_ref "TARGET_DOUBLE_WITH_ADD")
11029                           (const_int 0))
11030                       (match_operand 0 "register_operand" ""))
11031                  (match_operand 2 "const1_operand" ""))
11032               (const_string "alu")
11033            ]
11034            (const_string "ishift")))
11035    (set_attr "mode" "QI,SI")])
11037 ;; This pattern can't accept a variable shift count, since shifts by
11038 ;; zero don't affect the flags.  We assume that shifts by constant
11039 ;; zero are optimized away.
11040 (define_insn "*ashlqi3_cmp"
11041   [(set (reg 17)
11042         (compare
11043           (ashift:QI (match_operand:QI 1 "nonimmediate_operand" "0")
11044                      (match_operand:QI 2 "const_int_1_31_operand" "I"))
11045           (const_int 0)))
11046    (set (match_operand:QI 0 "nonimmediate_operand" "=qm")
11047         (ashift:QI (match_dup 1) (match_dup 2)))]
11048   "ix86_match_ccmode (insn, CCGOCmode)
11049    && ix86_binary_operator_ok (ASHIFT, QImode, operands)"
11051   switch (get_attr_type (insn))
11052     {
11053     case TYPE_ALU:
11054       if (operands[2] != const1_rtx)
11055         abort ();
11056       return "add{b}\t{%0, %0|%0, %0}";
11058     default:
11059       if (REG_P (operands[2]))
11060         return "sal{b}\t{%b2, %0|%0, %b2}";
11061       else if (GET_CODE (operands[2]) == CONST_INT
11062                && INTVAL (operands[2]) == 1
11063                && (TARGET_SHIFT1 || optimize_size))
11064         return "sal{b}\t%0";
11065       else
11066         return "sal{b}\t{%2, %0|%0, %2}";
11067     }
11069   [(set (attr "type")
11070      (cond [(and (and (ne (symbol_ref "TARGET_DOUBLE_WITH_ADD")
11071                           (const_int 0))
11072                       (match_operand 0 "register_operand" ""))
11073                  (match_operand 2 "const1_operand" ""))
11074               (const_string "alu")
11075            ]
11076            (const_string "ishift")))
11077    (set_attr "mode" "QI")])
11079 ;; See comment above `ashldi3' about how this works.
11081 (define_expand "ashrdi3"
11082   [(parallel [(set (match_operand:DI 0 "shiftdi_operand" "")
11083                    (ashiftrt:DI (match_operand:DI 1 "shiftdi_operand" "")
11084                                 (match_operand:QI 2 "nonmemory_operand" "")))
11085               (clobber (reg:CC 17))])]
11086   ""
11088   if (!TARGET_64BIT && TARGET_CMOVE && ! immediate_operand (operands[2], QImode))
11089     {
11090       emit_insn (gen_ashrdi3_1 (operands[0], operands[1], operands[2]));
11091       DONE;
11092     }
11093   ix86_expand_binary_operator (ASHIFTRT, DImode, operands);
11094   DONE;
11097 (define_insn "ashrdi3_63_rex64"
11098   [(set (match_operand:DI 0 "nonimmediate_operand" "=*d,rm")
11099         (ashiftrt:DI (match_operand:DI 1 "nonimmediate_operand" "*a,0")
11100                      (match_operand:DI 2 "const_int_operand" "i,i")))
11101    (clobber (reg:CC 17))]
11102   "TARGET_64BIT && INTVAL (operands[2]) == 63 && (TARGET_USE_CLTD || optimize_size)
11103    && ix86_binary_operator_ok (ASHIFTRT, DImode, operands)"
11104   "@
11105    {cqto|cqo}
11106    sar{q}\t{%2, %0|%0, %2}"
11107   [(set_attr "type" "imovx,ishift")
11108    (set_attr "prefix_0f" "0,*")
11109    (set_attr "length_immediate" "0,*")
11110    (set_attr "modrm" "0,1")
11111    (set_attr "mode" "DI")])
11113 (define_insn "*ashrdi3_1_one_bit_rex64"
11114   [(set (match_operand:DI 0 "nonimmediate_operand" "=rm")
11115         (ashiftrt:DI (match_operand:DI 1 "nonimmediate_operand" "0")
11116                      (match_operand:QI 2 "const_int_1_operand" "")))
11117    (clobber (reg:CC 17))]
11118   "TARGET_64BIT && ix86_binary_operator_ok (ASHIFTRT, DImode, operands)
11119    && (TARGET_SHIFT1 || optimize_size)"
11120   "sar{q}\t%0"
11121   [(set_attr "type" "ishift")
11122    (set (attr "length") 
11123      (if_then_else (match_operand:DI 0 "register_operand" "") 
11124         (const_string "2")
11125         (const_string "*")))])
11127 (define_insn "*ashrdi3_1_rex64"
11128   [(set (match_operand:DI 0 "nonimmediate_operand" "=rm,rm")
11129         (ashiftrt:DI (match_operand:DI 1 "nonimmediate_operand" "0,0")
11130                      (match_operand:QI 2 "nonmemory_operand" "J,c")))
11131    (clobber (reg:CC 17))]
11132   "TARGET_64BIT && ix86_binary_operator_ok (ASHIFTRT, DImode, operands)"
11133   "@
11134    sar{q}\t{%2, %0|%0, %2}
11135    sar{q}\t{%b2, %0|%0, %b2}"
11136   [(set_attr "type" "ishift")
11137    (set_attr "mode" "DI")])
11139 ;; This pattern can't accept a variable shift count, since shifts by
11140 ;; zero don't affect the flags.  We assume that shifts by constant
11141 ;; zero are optimized away.
11142 (define_insn "*ashrdi3_one_bit_cmp_rex64"
11143   [(set (reg 17)
11144         (compare
11145           (ashiftrt:DI (match_operand:DI 1 "nonimmediate_operand" "0")
11146                        (match_operand:QI 2 "const_int_1_operand" ""))
11147           (const_int 0)))
11148    (set (match_operand:DI 0 "nonimmediate_operand" "=rm")
11149         (ashiftrt:DI (match_dup 1) (match_dup 2)))]
11150   "TARGET_64BIT && ix86_match_ccmode (insn, CCGOCmode)
11151    && (TARGET_SHIFT1 || optimize_size)
11152    && ix86_binary_operator_ok (ASHIFTRT, DImode, operands)"
11153   "sar{q}\t%0"
11154   [(set_attr "type" "ishift")
11155    (set (attr "length") 
11156      (if_then_else (match_operand:DI 0 "register_operand" "") 
11157         (const_string "2")
11158         (const_string "*")))])
11160 ;; This pattern can't accept a variable shift count, since shifts by
11161 ;; zero don't affect the flags.  We assume that shifts by constant
11162 ;; zero are optimized away.
11163 (define_insn "*ashrdi3_cmp_rex64"
11164   [(set (reg 17)
11165         (compare
11166           (ashiftrt:DI (match_operand:DI 1 "nonimmediate_operand" "0")
11167                        (match_operand:QI 2 "const_int_operand" "n"))
11168           (const_int 0)))
11169    (set (match_operand:DI 0 "nonimmediate_operand" "=rm")
11170         (ashiftrt:DI (match_dup 1) (match_dup 2)))]
11171   "TARGET_64BIT && ix86_match_ccmode (insn, CCGOCmode)
11172    && ix86_binary_operator_ok (ASHIFTRT, DImode, operands)"
11173   "sar{q}\t{%2, %0|%0, %2}"
11174   [(set_attr "type" "ishift")
11175    (set_attr "mode" "DI")])
11178 (define_insn "ashrdi3_1"
11179   [(set (match_operand:DI 0 "register_operand" "=r")
11180         (ashiftrt:DI (match_operand:DI 1 "register_operand" "0")
11181                      (match_operand:QI 2 "nonmemory_operand" "Jc")))
11182    (clobber (match_scratch:SI 3 "=&r"))
11183    (clobber (reg:CC 17))]
11184   "!TARGET_64BIT && TARGET_CMOVE"
11185   "#"
11186   [(set_attr "type" "multi")])
11188 (define_insn "*ashrdi3_2"
11189   [(set (match_operand:DI 0 "register_operand" "=r")
11190         (ashiftrt:DI (match_operand:DI 1 "register_operand" "0")
11191                      (match_operand:QI 2 "nonmemory_operand" "Jc")))
11192    (clobber (reg:CC 17))]
11193   "!TARGET_64BIT"
11194   "#"
11195   [(set_attr "type" "multi")])
11197 (define_split
11198   [(set (match_operand:DI 0 "register_operand" "")
11199         (ashiftrt:DI (match_operand:DI 1 "register_operand" "")
11200                      (match_operand:QI 2 "nonmemory_operand" "")))
11201    (clobber (match_scratch:SI 3 ""))
11202    (clobber (reg:CC 17))]
11203   "!TARGET_64BIT && TARGET_CMOVE && reload_completed"
11204   [(const_int 0)]
11205   "ix86_split_ashrdi (operands, operands[3]); DONE;")
11207 (define_split
11208   [(set (match_operand:DI 0 "register_operand" "")
11209         (ashiftrt:DI (match_operand:DI 1 "register_operand" "")
11210                      (match_operand:QI 2 "nonmemory_operand" "")))
11211    (clobber (reg:CC 17))]
11212   "!TARGET_64BIT && reload_completed"
11213   [(const_int 0)]
11214   "ix86_split_ashrdi (operands, NULL_RTX); DONE;")
11216 (define_insn "x86_shrd_1"
11217   [(set (match_operand:SI 0 "nonimmediate_operand" "+r*m,r*m")
11218         (ior:SI (ashiftrt:SI (match_dup 0)
11219                   (match_operand:QI 2 "nonmemory_operand" "I,c"))
11220                 (ashift:SI (match_operand:SI 1 "register_operand" "r,r")
11221                   (minus:QI (const_int 32) (match_dup 2)))))
11222    (clobber (reg:CC 17))]
11223   ""
11224   "@
11225    shrd{l}\t{%2, %1, %0|%0, %1, %2}
11226    shrd{l}\t{%s2%1, %0|%0, %1, %2}"
11227   [(set_attr "type" "ishift")
11228    (set_attr "prefix_0f" "1")
11229    (set_attr "pent_pair" "np")
11230    (set_attr "ppro_uops" "few")
11231    (set_attr "mode" "SI")])
11233 (define_expand "x86_shift_adj_3"
11234   [(use (match_operand:SI 0 "register_operand" ""))
11235    (use (match_operand:SI 1 "register_operand" ""))
11236    (use (match_operand:QI 2 "register_operand" ""))]
11237   ""
11239   rtx label = gen_label_rtx ();
11240   rtx tmp;
11242   emit_insn (gen_testqi_ccz_1 (operands[2], GEN_INT (32)));
11244   tmp = gen_rtx_REG (CCZmode, FLAGS_REG);
11245   tmp = gen_rtx_EQ (VOIDmode, tmp, const0_rtx);
11246   tmp = gen_rtx_IF_THEN_ELSE (VOIDmode, tmp,
11247                               gen_rtx_LABEL_REF (VOIDmode, label),
11248                               pc_rtx);
11249   tmp = emit_jump_insn (gen_rtx_SET (VOIDmode, pc_rtx, tmp));
11250   JUMP_LABEL (tmp) = label;
11252   emit_move_insn (operands[0], operands[1]);
11253   emit_insn (gen_ashrsi3_31 (operands[1], operands[1], GEN_INT (31)));
11255   emit_label (label);
11256   LABEL_NUSES (label) = 1;
11258   DONE;
11261 (define_insn "ashrsi3_31"
11262   [(set (match_operand:SI 0 "nonimmediate_operand" "=*d,rm")
11263         (ashiftrt:SI (match_operand:SI 1 "nonimmediate_operand" "*a,0")
11264                      (match_operand:SI 2 "const_int_operand" "i,i")))
11265    (clobber (reg:CC 17))]
11266   "INTVAL (operands[2]) == 31 && (TARGET_USE_CLTD || optimize_size)
11267    && ix86_binary_operator_ok (ASHIFTRT, SImode, operands)"
11268   "@
11269    {cltd|cdq}
11270    sar{l}\t{%2, %0|%0, %2}"
11271   [(set_attr "type" "imovx,ishift")
11272    (set_attr "prefix_0f" "0,*")
11273    (set_attr "length_immediate" "0,*")
11274    (set_attr "modrm" "0,1")
11275    (set_attr "mode" "SI")])
11277 (define_insn "*ashrsi3_31_zext"
11278   [(set (match_operand:DI 0 "register_operand" "=*d,r")
11279         (zero_extend:DI (ashiftrt:SI (match_operand:SI 1 "register_operand" "*a,0")
11280                                      (match_operand:SI 2 "const_int_operand" "i,i"))))
11281    (clobber (reg:CC 17))]
11282   "TARGET_64BIT && (TARGET_USE_CLTD || optimize_size)
11283    && INTVAL (operands[2]) == 31
11284    && ix86_binary_operator_ok (ASHIFTRT, SImode, operands)"
11285   "@
11286    {cltd|cdq}
11287    sar{l}\t{%2, %k0|%k0, %2}"
11288   [(set_attr "type" "imovx,ishift")
11289    (set_attr "prefix_0f" "0,*")
11290    (set_attr "length_immediate" "0,*")
11291    (set_attr "modrm" "0,1")
11292    (set_attr "mode" "SI")])
11294 (define_expand "ashrsi3"
11295   [(set (match_operand:SI 0 "nonimmediate_operand" "")
11296         (ashiftrt:SI (match_operand:SI 1 "nonimmediate_operand" "")
11297                      (match_operand:QI 2 "nonmemory_operand" "")))
11298    (clobber (reg:CC 17))]
11299   ""
11300   "ix86_expand_binary_operator (ASHIFTRT, SImode, operands); DONE;")
11302 (define_insn "*ashrsi3_1_one_bit"
11303   [(set (match_operand:SI 0 "nonimmediate_operand" "=rm")
11304         (ashiftrt:SI (match_operand:SI 1 "nonimmediate_operand" "0")
11305                      (match_operand:QI 2 "const_int_1_operand" "")))
11306    (clobber (reg:CC 17))]
11307   "ix86_binary_operator_ok (ASHIFTRT, SImode, operands)
11308    && (TARGET_SHIFT1 || optimize_size)"
11309   "sar{l}\t%0"
11310   [(set_attr "type" "ishift")
11311    (set (attr "length") 
11312      (if_then_else (match_operand:SI 0 "register_operand" "") 
11313         (const_string "2")
11314         (const_string "*")))])
11316 (define_insn "*ashrsi3_1_one_bit_zext"
11317   [(set (match_operand:DI 0 "register_operand" "=r")
11318         (zero_extend:DI (ashiftrt:SI (match_operand:SI 1 "register_operand" "0")
11319                                      (match_operand:QI 2 "const_int_1_operand" ""))))
11320    (clobber (reg:CC 17))]
11321   "TARGET_64BIT && ix86_binary_operator_ok (ASHIFTRT, SImode, operands)
11322    && (TARGET_SHIFT1 || optimize_size)"
11323   "sar{l}\t%k0"
11324   [(set_attr "type" "ishift")
11325    (set_attr "length" "2")])
11327 (define_insn "*ashrsi3_1"
11328   [(set (match_operand:SI 0 "nonimmediate_operand" "=rm,rm")
11329         (ashiftrt:SI (match_operand:SI 1 "nonimmediate_operand" "0,0")
11330                      (match_operand:QI 2 "nonmemory_operand" "I,c")))
11331    (clobber (reg:CC 17))]
11332   "ix86_binary_operator_ok (ASHIFTRT, SImode, operands)"
11333   "@
11334    sar{l}\t{%2, %0|%0, %2}
11335    sar{l}\t{%b2, %0|%0, %b2}"
11336   [(set_attr "type" "ishift")
11337    (set_attr "mode" "SI")])
11339 (define_insn "*ashrsi3_1_zext"
11340   [(set (match_operand:DI 0 "register_operand" "=r,r")
11341         (zero_extend:DI (ashiftrt:SI (match_operand:SI 1 "register_operand" "0,0")
11342                                      (match_operand:QI 2 "nonmemory_operand" "I,c"))))
11343    (clobber (reg:CC 17))]
11344   "TARGET_64BIT && ix86_binary_operator_ok (ASHIFTRT, SImode, operands)"
11345   "@
11346    sar{l}\t{%2, %k0|%k0, %2}
11347    sar{l}\t{%b2, %k0|%k0, %b2}"
11348   [(set_attr "type" "ishift")
11349    (set_attr "mode" "SI")])
11351 ;; This pattern can't accept a variable shift count, since shifts by
11352 ;; zero don't affect the flags.  We assume that shifts by constant
11353 ;; zero are optimized away.
11354 (define_insn "*ashrsi3_one_bit_cmp"
11355   [(set (reg 17)
11356         (compare
11357           (ashiftrt:SI (match_operand:SI 1 "nonimmediate_operand" "0")
11358                        (match_operand:QI 2 "const_int_1_operand" ""))
11359           (const_int 0)))
11360    (set (match_operand:SI 0 "nonimmediate_operand" "=rm")
11361         (ashiftrt:SI (match_dup 1) (match_dup 2)))]
11362   "ix86_match_ccmode (insn, CCGOCmode)
11363    && (TARGET_SHIFT1 || optimize_size)
11364    && ix86_binary_operator_ok (ASHIFTRT, SImode, operands)"
11365   "sar{l}\t%0"
11366   [(set_attr "type" "ishift")
11367    (set (attr "length") 
11368      (if_then_else (match_operand:SI 0 "register_operand" "") 
11369         (const_string "2")
11370         (const_string "*")))])
11372 (define_insn "*ashrsi3_one_bit_cmp_zext"
11373   [(set (reg 17)
11374         (compare
11375           (ashiftrt:SI (match_operand:SI 1 "register_operand" "0")
11376                        (match_operand:QI 2 "const_int_1_operand" ""))
11377           (const_int 0)))
11378    (set (match_operand:DI 0 "register_operand" "=r")
11379         (zero_extend:DI (ashiftrt:SI (match_dup 1) (match_dup 2))))]
11380   "TARGET_64BIT && ix86_match_ccmode (insn, CCmode)
11381    && (TARGET_SHIFT1 || optimize_size)
11382    && ix86_binary_operator_ok (ASHIFTRT, SImode, operands)"
11383   "sar{l}\t%k0"
11384   [(set_attr "type" "ishift")
11385    (set_attr "length" "2")])
11387 ;; This pattern can't accept a variable shift count, since shifts by
11388 ;; zero don't affect the flags.  We assume that shifts by constant
11389 ;; zero are optimized away.
11390 (define_insn "*ashrsi3_cmp"
11391   [(set (reg 17)
11392         (compare
11393           (ashiftrt:SI (match_operand:SI 1 "nonimmediate_operand" "0")
11394                        (match_operand:QI 2 "const_int_1_31_operand" "I"))
11395           (const_int 0)))
11396    (set (match_operand:SI 0 "nonimmediate_operand" "=rm")
11397         (ashiftrt:SI (match_dup 1) (match_dup 2)))]
11398   "ix86_match_ccmode (insn, CCGOCmode)
11399    && ix86_binary_operator_ok (ASHIFTRT, SImode, operands)"
11400   "sar{l}\t{%2, %0|%0, %2}"
11401   [(set_attr "type" "ishift")
11402    (set_attr "mode" "SI")])
11404 (define_insn "*ashrsi3_cmp_zext"
11405   [(set (reg 17)
11406         (compare
11407           (ashiftrt:SI (match_operand:SI 1 "register_operand" "0")
11408                        (match_operand:QI 2 "const_int_1_31_operand" "I"))
11409           (const_int 0)))
11410    (set (match_operand:DI 0 "register_operand" "=r")
11411         (zero_extend:DI (ashiftrt:SI (match_dup 1) (match_dup 2))))]
11412   "TARGET_64BIT && ix86_match_ccmode (insn, CCGOCmode)
11413    && ix86_binary_operator_ok (ASHIFTRT, SImode, operands)"
11414   "sar{l}\t{%2, %k0|%k0, %2}"
11415   [(set_attr "type" "ishift")
11416    (set_attr "mode" "SI")])
11418 (define_expand "ashrhi3"
11419   [(set (match_operand:HI 0 "nonimmediate_operand" "")
11420         (ashiftrt:HI (match_operand:HI 1 "nonimmediate_operand" "")
11421                      (match_operand:QI 2 "nonmemory_operand" "")))
11422    (clobber (reg:CC 17))]
11423   "TARGET_HIMODE_MATH"
11424   "ix86_expand_binary_operator (ASHIFTRT, HImode, operands); DONE;")
11426 (define_insn "*ashrhi3_1_one_bit"
11427   [(set (match_operand:HI 0 "nonimmediate_operand" "=rm")
11428         (ashiftrt:HI (match_operand:HI 1 "nonimmediate_operand" "0")
11429                      (match_operand:QI 2 "const_int_1_operand" "")))
11430    (clobber (reg:CC 17))]
11431   "ix86_binary_operator_ok (ASHIFTRT, HImode, operands)
11432    && (TARGET_SHIFT1 || optimize_size)"
11433   "sar{w}\t%0"
11434   [(set_attr "type" "ishift")
11435    (set (attr "length") 
11436      (if_then_else (match_operand 0 "register_operand" "") 
11437         (const_string "2")
11438         (const_string "*")))])
11440 (define_insn "*ashrhi3_1"
11441   [(set (match_operand:HI 0 "nonimmediate_operand" "=rm,rm")
11442         (ashiftrt:HI (match_operand:HI 1 "nonimmediate_operand" "0,0")
11443                      (match_operand:QI 2 "nonmemory_operand" "I,c")))
11444    (clobber (reg:CC 17))]
11445   "ix86_binary_operator_ok (ASHIFTRT, HImode, operands)"
11446   "@
11447    sar{w}\t{%2, %0|%0, %2}
11448    sar{w}\t{%b2, %0|%0, %b2}"
11449   [(set_attr "type" "ishift")
11450    (set_attr "mode" "HI")])
11452 ;; This pattern can't accept a variable shift count, since shifts by
11453 ;; zero don't affect the flags.  We assume that shifts by constant
11454 ;; zero are optimized away.
11455 (define_insn "*ashrhi3_one_bit_cmp"
11456   [(set (reg 17)
11457         (compare
11458           (ashiftrt:HI (match_operand:HI 1 "nonimmediate_operand" "0")
11459                        (match_operand:QI 2 "const_int_1_operand" ""))
11460           (const_int 0)))
11461    (set (match_operand:HI 0 "nonimmediate_operand" "=rm")
11462         (ashiftrt:HI (match_dup 1) (match_dup 2)))]
11463   "ix86_match_ccmode (insn, CCGOCmode)
11464    && (TARGET_SHIFT1 || optimize_size)
11465    && ix86_binary_operator_ok (ASHIFTRT, HImode, operands)"
11466   "sar{w}\t%0"
11467   [(set_attr "type" "ishift")
11468    (set (attr "length") 
11469      (if_then_else (match_operand 0 "register_operand" "") 
11470         (const_string "2")
11471         (const_string "*")))])
11473 ;; This pattern can't accept a variable shift count, since shifts by
11474 ;; zero don't affect the flags.  We assume that shifts by constant
11475 ;; zero are optimized away.
11476 (define_insn "*ashrhi3_cmp"
11477   [(set (reg 17)
11478         (compare
11479           (ashiftrt:HI (match_operand:HI 1 "nonimmediate_operand" "0")
11480                        (match_operand:QI 2 "const_int_1_31_operand" "I"))
11481           (const_int 0)))
11482    (set (match_operand:HI 0 "nonimmediate_operand" "=rm")
11483         (ashiftrt:HI (match_dup 1) (match_dup 2)))]
11484   "ix86_match_ccmode (insn, CCGOCmode)
11485    && ix86_binary_operator_ok (ASHIFTRT, HImode, operands)"
11486   "sar{w}\t{%2, %0|%0, %2}"
11487   [(set_attr "type" "ishift")
11488    (set_attr "mode" "HI")])
11490 (define_expand "ashrqi3"
11491   [(set (match_operand:QI 0 "nonimmediate_operand" "")
11492         (ashiftrt:QI (match_operand:QI 1 "nonimmediate_operand" "")
11493                      (match_operand:QI 2 "nonmemory_operand" "")))
11494    (clobber (reg:CC 17))]
11495   "TARGET_QIMODE_MATH"
11496   "ix86_expand_binary_operator (ASHIFTRT, QImode, operands); DONE;")
11498 (define_insn "*ashrqi3_1_one_bit"
11499   [(set (match_operand:QI 0 "nonimmediate_operand" "=qm")
11500         (ashiftrt:QI (match_operand:QI 1 "nonimmediate_operand" "0")
11501                      (match_operand:QI 2 "const_int_1_operand" "")))
11502    (clobber (reg:CC 17))]
11503   "ix86_binary_operator_ok (ASHIFTRT, QImode, operands)
11504    && (TARGET_SHIFT1 || optimize_size)"
11505   "sar{b}\t%0"
11506   [(set_attr "type" "ishift")
11507    (set (attr "length") 
11508      (if_then_else (match_operand 0 "register_operand" "") 
11509         (const_string "2")
11510         (const_string "*")))])
11512 (define_insn "*ashrqi3_1_one_bit_slp"
11513   [(set (strict_low_part (match_operand:QI 0 "nonimmediate_operand" "+qm"))
11514         (ashiftrt:QI (match_operand:QI 1 "nonimmediate_operand" "0")
11515                      (match_operand:QI 2 "const_int_1_operand" "")))
11516    (clobber (reg:CC 17))]
11517   "ix86_binary_operator_ok (ASHIFTRT, QImode, operands)
11518    && (! TARGET_PARTIAL_REG_STALL || optimize_size)
11519    && (TARGET_SHIFT1 || optimize_size)"
11520   "sar{b}\t%0"
11521   [(set_attr "type" "ishift")
11522    (set (attr "length") 
11523      (if_then_else (match_operand 0 "register_operand" "") 
11524         (const_string "2")
11525         (const_string "*")))])
11527 (define_insn "*ashrqi3_1"
11528   [(set (match_operand:QI 0 "nonimmediate_operand" "=qm,qm")
11529         (ashiftrt:QI (match_operand:QI 1 "nonimmediate_operand" "0,0")
11530                      (match_operand:QI 2 "nonmemory_operand" "I,c")))
11531    (clobber (reg:CC 17))]
11532   "ix86_binary_operator_ok (ASHIFTRT, QImode, operands)"
11533   "@
11534    sar{b}\t{%2, %0|%0, %2}
11535    sar{b}\t{%b2, %0|%0, %b2}"
11536   [(set_attr "type" "ishift")
11537    (set_attr "mode" "QI")])
11539 (define_insn "*ashrqi3_1_slp"
11540   [(set (strict_low_part (match_operand:QI 0 "nonimmediate_operand" "+qm,qm"))
11541         (ashiftrt:QI (match_operand:QI 1 "nonimmediate_operand" "0,0")
11542                      (match_operand:QI 2 "nonmemory_operand" "I,c")))
11543    (clobber (reg:CC 17))]
11544   "(! TARGET_PARTIAL_REG_STALL || optimize_size)
11545    && ix86_binary_operator_ok (ASHIFTRT, QImode, operands)"
11546   "@
11547    sar{b}\t{%2, %0|%0, %2}
11548    sar{b}\t{%b2, %0|%0, %b2}"
11549   [(set_attr "type" "ishift")
11550    (set_attr "mode" "QI")])
11552 ;; This pattern can't accept a variable shift count, since shifts by
11553 ;; zero don't affect the flags.  We assume that shifts by constant
11554 ;; zero are optimized away.
11555 (define_insn "*ashrqi3_one_bit_cmp"
11556   [(set (reg 17)
11557         (compare
11558           (ashiftrt:QI (match_operand:QI 1 "nonimmediate_operand" "0")
11559                        (match_operand:QI 2 "const_int_1_operand" "I"))
11560           (const_int 0)))
11561    (set (match_operand:QI 0 "nonimmediate_operand" "=qm")
11562         (ashiftrt:QI (match_dup 1) (match_dup 2)))]
11563   "ix86_match_ccmode (insn, CCGOCmode)
11564    && (TARGET_SHIFT1 || optimize_size)
11565    && ix86_binary_operator_ok (ASHIFTRT, QImode, operands)"
11566   "sar{b}\t%0"
11567   [(set_attr "type" "ishift")
11568    (set (attr "length") 
11569      (if_then_else (match_operand 0 "register_operand" "") 
11570         (const_string "2")
11571         (const_string "*")))])
11573 ;; This pattern can't accept a variable shift count, since shifts by
11574 ;; zero don't affect the flags.  We assume that shifts by constant
11575 ;; zero are optimized away.
11576 (define_insn "*ashrqi3_cmp"
11577   [(set (reg 17)
11578         (compare
11579           (ashiftrt:QI (match_operand:QI 1 "nonimmediate_operand" "0")
11580                        (match_operand:QI 2 "const_int_1_31_operand" "I"))
11581           (const_int 0)))
11582    (set (match_operand:QI 0 "nonimmediate_operand" "=qm")
11583         (ashiftrt:QI (match_dup 1) (match_dup 2)))]
11584   "ix86_match_ccmode (insn, CCGOCmode)
11585    && ix86_binary_operator_ok (ASHIFTRT, QImode, operands)"
11586   "sar{b}\t{%2, %0|%0, %2}"
11587   [(set_attr "type" "ishift")
11588    (set_attr "mode" "QI")])
11590 ;; Logical shift instructions
11592 ;; See comment above `ashldi3' about how this works.
11594 (define_expand "lshrdi3"
11595   [(parallel [(set (match_operand:DI 0 "shiftdi_operand" "")
11596                    (lshiftrt:DI (match_operand:DI 1 "shiftdi_operand" "")
11597                                 (match_operand:QI 2 "nonmemory_operand" "")))
11598               (clobber (reg:CC 17))])]
11599   ""
11601   if (!TARGET_64BIT && TARGET_CMOVE && ! immediate_operand (operands[2], QImode))
11602     {
11603       emit_insn (gen_lshrdi3_1 (operands[0], operands[1], operands[2]));
11604       DONE;
11605     }
11606   ix86_expand_binary_operator (LSHIFTRT, DImode, operands);
11607   DONE;
11610 (define_insn "*lshrdi3_1_one_bit_rex64"
11611   [(set (match_operand:DI 0 "nonimmediate_operand" "=rm")
11612         (lshiftrt:DI (match_operand:DI 1 "nonimmediate_operand" "0")
11613                      (match_operand:QI 2 "const_int_1_operand" "")))
11614    (clobber (reg:CC 17))]
11615   "TARGET_64BIT && ix86_binary_operator_ok (LSHIFTRT, HImode, operands)
11616    && (TARGET_SHIFT1 || optimize_size)"
11617   "shr{q}\t%0"
11618   [(set_attr "type" "ishift")
11619    (set (attr "length") 
11620      (if_then_else (match_operand:DI 0 "register_operand" "") 
11621         (const_string "2")
11622         (const_string "*")))])
11624 (define_insn "*lshrdi3_1_rex64"
11625   [(set (match_operand:DI 0 "nonimmediate_operand" "=rm,rm")
11626         (lshiftrt:DI (match_operand:DI 1 "nonimmediate_operand" "0,0")
11627                      (match_operand:QI 2 "nonmemory_operand" "J,c")))
11628    (clobber (reg:CC 17))]
11629   "TARGET_64BIT && ix86_binary_operator_ok (LSHIFTRT, HImode, operands)"
11630   "@
11631    shr{q}\t{%2, %0|%0, %2}
11632    shr{q}\t{%b2, %0|%0, %b2}"
11633   [(set_attr "type" "ishift")
11634    (set_attr "mode" "DI")])
11636 ;; This pattern can't accept a variable shift count, since shifts by
11637 ;; zero don't affect the flags.  We assume that shifts by constant
11638 ;; zero are optimized away.
11639 (define_insn "*lshrdi3_cmp_one_bit_rex64"
11640   [(set (reg 17)
11641         (compare
11642           (lshiftrt:DI (match_operand:DI 1 "nonimmediate_operand" "0")
11643                        (match_operand:QI 2 "const_int_1_operand" ""))
11644           (const_int 0)))
11645    (set (match_operand:DI 0 "nonimmediate_operand" "=rm")
11646         (lshiftrt:DI (match_dup 1) (match_dup 2)))]
11647   "TARGET_64BIT && ix86_match_ccmode (insn, CCGOCmode)
11648    && (TARGET_SHIFT1 || optimize_size)
11649    && ix86_binary_operator_ok (LSHIFTRT, HImode, operands)"
11650   "shr{q}\t%0"
11651   [(set_attr "type" "ishift")
11652    (set (attr "length") 
11653      (if_then_else (match_operand:DI 0 "register_operand" "") 
11654         (const_string "2")
11655         (const_string "*")))])
11657 ;; This pattern can't accept a variable shift count, since shifts by
11658 ;; zero don't affect the flags.  We assume that shifts by constant
11659 ;; zero are optimized away.
11660 (define_insn "*lshrdi3_cmp_rex64"
11661   [(set (reg 17)
11662         (compare
11663           (lshiftrt:DI (match_operand:DI 1 "nonimmediate_operand" "0")
11664                        (match_operand:QI 2 "const_int_operand" "e"))
11665           (const_int 0)))
11666    (set (match_operand:DI 0 "nonimmediate_operand" "=rm")
11667         (lshiftrt:DI (match_dup 1) (match_dup 2)))]
11668   "TARGET_64BIT && ix86_match_ccmode (insn, CCGOCmode)
11669    && ix86_binary_operator_ok (LSHIFTRT, HImode, operands)"
11670   "shr{q}\t{%2, %0|%0, %2}"
11671   [(set_attr "type" "ishift")
11672    (set_attr "mode" "DI")])
11674 (define_insn "lshrdi3_1"
11675   [(set (match_operand:DI 0 "register_operand" "=r")
11676         (lshiftrt:DI (match_operand:DI 1 "register_operand" "0")
11677                      (match_operand:QI 2 "nonmemory_operand" "Jc")))
11678    (clobber (match_scratch:SI 3 "=&r"))
11679    (clobber (reg:CC 17))]
11680   "!TARGET_64BIT && TARGET_CMOVE"
11681   "#"
11682   [(set_attr "type" "multi")])
11684 (define_insn "*lshrdi3_2"
11685   [(set (match_operand:DI 0 "register_operand" "=r")
11686         (lshiftrt:DI (match_operand:DI 1 "register_operand" "0")
11687                      (match_operand:QI 2 "nonmemory_operand" "Jc")))
11688    (clobber (reg:CC 17))]
11689   "!TARGET_64BIT"
11690   "#"
11691   [(set_attr "type" "multi")])
11693 (define_split 
11694   [(set (match_operand:DI 0 "register_operand" "")
11695         (lshiftrt:DI (match_operand:DI 1 "register_operand" "")
11696                      (match_operand:QI 2 "nonmemory_operand" "")))
11697    (clobber (match_scratch:SI 3 ""))
11698    (clobber (reg:CC 17))]
11699   "!TARGET_64BIT && TARGET_CMOVE && reload_completed"
11700   [(const_int 0)]
11701   "ix86_split_lshrdi (operands, operands[3]); DONE;")
11703 (define_split 
11704   [(set (match_operand:DI 0 "register_operand" "")
11705         (lshiftrt:DI (match_operand:DI 1 "register_operand" "")
11706                      (match_operand:QI 2 "nonmemory_operand" "")))
11707    (clobber (reg:CC 17))]
11708   "!TARGET_64BIT && reload_completed"
11709   [(const_int 0)]
11710   "ix86_split_lshrdi (operands, NULL_RTX); DONE;")
11712 (define_expand "lshrsi3"
11713   [(set (match_operand:SI 0 "nonimmediate_operand" "")
11714         (lshiftrt:SI (match_operand:SI 1 "nonimmediate_operand" "")
11715                      (match_operand:QI 2 "nonmemory_operand" "")))
11716    (clobber (reg:CC 17))]
11717   ""
11718   "ix86_expand_binary_operator (LSHIFTRT, SImode, operands); DONE;")
11720 (define_insn "*lshrsi3_1_one_bit"
11721   [(set (match_operand:SI 0 "nonimmediate_operand" "=rm")
11722         (lshiftrt:SI (match_operand:SI 1 "nonimmediate_operand" "0")
11723                      (match_operand:QI 2 "const_int_1_operand" "")))
11724    (clobber (reg:CC 17))]
11725   "ix86_binary_operator_ok (LSHIFTRT, HImode, operands)
11726    && (TARGET_SHIFT1 || optimize_size)"
11727   "shr{l}\t%0"
11728   [(set_attr "type" "ishift")
11729    (set (attr "length") 
11730      (if_then_else (match_operand:SI 0 "register_operand" "") 
11731         (const_string "2")
11732         (const_string "*")))])
11734 (define_insn "*lshrsi3_1_one_bit_zext"
11735   [(set (match_operand:DI 0 "register_operand" "=r")
11736         (lshiftrt:DI (zero_extend:DI (match_operand:SI 1 "register_operand" "0"))
11737                      (match_operand:QI 2 "const_int_1_operand" "")))
11738    (clobber (reg:CC 17))]
11739   "TARGET_64BIT && ix86_binary_operator_ok (LSHIFTRT, HImode, operands)
11740    && (TARGET_SHIFT1 || optimize_size)"
11741   "shr{l}\t%k0"
11742   [(set_attr "type" "ishift")
11743    (set_attr "length" "2")])
11745 (define_insn "*lshrsi3_1"
11746   [(set (match_operand:SI 0 "nonimmediate_operand" "=rm,rm")
11747         (lshiftrt:SI (match_operand:SI 1 "nonimmediate_operand" "0,0")
11748                      (match_operand:QI 2 "nonmemory_operand" "I,c")))
11749    (clobber (reg:CC 17))]
11750   "ix86_binary_operator_ok (LSHIFTRT, HImode, operands)"
11751   "@
11752    shr{l}\t{%2, %0|%0, %2}
11753    shr{l}\t{%b2, %0|%0, %b2}"
11754   [(set_attr "type" "ishift")
11755    (set_attr "mode" "SI")])
11757 (define_insn "*lshrsi3_1_zext"
11758   [(set (match_operand:DI 0 "register_operand" "=r,r")
11759         (zero_extend:DI
11760           (lshiftrt:SI (match_operand:SI 1 "nonimmediate_operand" "0,0")
11761                        (match_operand:QI 2 "nonmemory_operand" "I,c"))))
11762    (clobber (reg:CC 17))]
11763   "TARGET_64BIT && ix86_binary_operator_ok (LSHIFTRT, HImode, operands)"
11764   "@
11765    shr{l}\t{%2, %k0|%k0, %2}
11766    shr{l}\t{%b2, %k0|%k0, %b2}"
11767   [(set_attr "type" "ishift")
11768    (set_attr "mode" "SI")])
11770 ;; This pattern can't accept a variable shift count, since shifts by
11771 ;; zero don't affect the flags.  We assume that shifts by constant
11772 ;; zero are optimized away.
11773 (define_insn "*lshrsi3_one_bit_cmp"
11774   [(set (reg 17)
11775         (compare
11776           (lshiftrt:SI (match_operand:SI 1 "nonimmediate_operand" "0")
11777                        (match_operand:QI 2 "const_int_1_operand" ""))
11778           (const_int 0)))
11779    (set (match_operand:SI 0 "nonimmediate_operand" "=rm")
11780         (lshiftrt:SI (match_dup 1) (match_dup 2)))]
11781   "ix86_match_ccmode (insn, CCGOCmode)
11782    && (TARGET_SHIFT1 || optimize_size)
11783    && ix86_binary_operator_ok (LSHIFTRT, HImode, operands)"
11784   "shr{l}\t%0"
11785   [(set_attr "type" "ishift")
11786    (set (attr "length") 
11787      (if_then_else (match_operand:SI 0 "register_operand" "") 
11788         (const_string "2")
11789         (const_string "*")))])
11791 (define_insn "*lshrsi3_cmp_one_bit_zext"
11792   [(set (reg 17)
11793         (compare
11794           (lshiftrt:SI (match_operand:SI 1 "register_operand" "0")
11795                        (match_operand:QI 2 "const_int_1_operand" ""))
11796           (const_int 0)))
11797    (set (match_operand:DI 0 "register_operand" "=r")
11798         (lshiftrt:DI (zero_extend:DI (match_dup 1)) (match_dup 2)))]
11799   "TARGET_64BIT && ix86_match_ccmode (insn, CCGOCmode)
11800    && (TARGET_SHIFT1 || optimize_size)
11801    && ix86_binary_operator_ok (LSHIFTRT, HImode, operands)"
11802   "shr{l}\t%k0"
11803   [(set_attr "type" "ishift")
11804    (set_attr "length" "2")])
11806 ;; This pattern can't accept a variable shift count, since shifts by
11807 ;; zero don't affect the flags.  We assume that shifts by constant
11808 ;; zero are optimized away.
11809 (define_insn "*lshrsi3_cmp"
11810   [(set (reg 17)
11811         (compare
11812           (lshiftrt:SI (match_operand:SI 1 "nonimmediate_operand" "0")
11813                        (match_operand:QI 2 "const_int_1_31_operand" "I"))
11814           (const_int 0)))
11815    (set (match_operand:SI 0 "nonimmediate_operand" "=rm")
11816         (lshiftrt:SI (match_dup 1) (match_dup 2)))]
11817   "ix86_match_ccmode (insn, CCGOCmode)
11818    && ix86_binary_operator_ok (LSHIFTRT, HImode, operands)"
11819   "shr{l}\t{%2, %0|%0, %2}"
11820   [(set_attr "type" "ishift")
11821    (set_attr "mode" "SI")])
11823 (define_insn "*lshrsi3_cmp_zext"
11824   [(set (reg 17)
11825         (compare
11826           (lshiftrt:SI (match_operand:SI 1 "register_operand" "0")
11827                        (match_operand:QI 2 "const_int_1_31_operand" "I"))
11828           (const_int 0)))
11829    (set (match_operand:DI 0 "register_operand" "=r")
11830         (lshiftrt:DI (zero_extend:DI (match_dup 1)) (match_dup 2)))]
11831   "TARGET_64BIT && ix86_match_ccmode (insn, CCGOCmode)
11832    && ix86_binary_operator_ok (LSHIFTRT, HImode, operands)"
11833   "shr{l}\t{%2, %k0|%k0, %2}"
11834   [(set_attr "type" "ishift")
11835    (set_attr "mode" "SI")])
11837 (define_expand "lshrhi3"
11838   [(set (match_operand:HI 0 "nonimmediate_operand" "")
11839         (lshiftrt:HI (match_operand:HI 1 "nonimmediate_operand" "")
11840                      (match_operand:QI 2 "nonmemory_operand" "")))
11841    (clobber (reg:CC 17))]
11842   "TARGET_HIMODE_MATH"
11843   "ix86_expand_binary_operator (LSHIFTRT, HImode, operands); DONE;")
11845 (define_insn "*lshrhi3_1_one_bit"
11846   [(set (match_operand:HI 0 "nonimmediate_operand" "=rm")
11847         (lshiftrt:HI (match_operand:HI 1 "nonimmediate_operand" "0")
11848                      (match_operand:QI 2 "const_int_1_operand" "")))
11849    (clobber (reg:CC 17))]
11850   "ix86_binary_operator_ok (LSHIFTRT, HImode, operands)
11851    && (TARGET_SHIFT1 || optimize_size)"
11852   "shr{w}\t%0"
11853   [(set_attr "type" "ishift")
11854    (set (attr "length") 
11855      (if_then_else (match_operand 0 "register_operand" "") 
11856         (const_string "2")
11857         (const_string "*")))])
11859 (define_insn "*lshrhi3_1"
11860   [(set (match_operand:HI 0 "nonimmediate_operand" "=rm,rm")
11861         (lshiftrt:HI (match_operand:HI 1 "nonimmediate_operand" "0,0")
11862                      (match_operand:QI 2 "nonmemory_operand" "I,c")))
11863    (clobber (reg:CC 17))]
11864   "ix86_binary_operator_ok (LSHIFTRT, HImode, operands)"
11865   "@
11866    shr{w}\t{%2, %0|%0, %2}
11867    shr{w}\t{%b2, %0|%0, %b2}"
11868   [(set_attr "type" "ishift")
11869    (set_attr "mode" "HI")])
11871 ;; This pattern can't accept a variable shift count, since shifts by
11872 ;; zero don't affect the flags.  We assume that shifts by constant
11873 ;; zero are optimized away.
11874 (define_insn "*lshrhi3_one_bit_cmp"
11875   [(set (reg 17)
11876         (compare
11877           (lshiftrt:HI (match_operand:HI 1 "nonimmediate_operand" "0")
11878                        (match_operand:QI 2 "const_int_1_operand" ""))
11879           (const_int 0)))
11880    (set (match_operand:HI 0 "nonimmediate_operand" "=rm")
11881         (lshiftrt:HI (match_dup 1) (match_dup 2)))]
11882   "ix86_match_ccmode (insn, CCGOCmode)
11883    && (TARGET_SHIFT1 || optimize_size)
11884    && ix86_binary_operator_ok (LSHIFTRT, HImode, operands)"
11885   "shr{w}\t%0"
11886   [(set_attr "type" "ishift")
11887    (set (attr "length") 
11888      (if_then_else (match_operand:SI 0 "register_operand" "") 
11889         (const_string "2")
11890         (const_string "*")))])
11892 ;; This pattern can't accept a variable shift count, since shifts by
11893 ;; zero don't affect the flags.  We assume that shifts by constant
11894 ;; zero are optimized away.
11895 (define_insn "*lshrhi3_cmp"
11896   [(set (reg 17)
11897         (compare
11898           (lshiftrt:HI (match_operand:HI 1 "nonimmediate_operand" "0")
11899                        (match_operand:QI 2 "const_int_1_31_operand" "I"))
11900           (const_int 0)))
11901    (set (match_operand:HI 0 "nonimmediate_operand" "=rm")
11902         (lshiftrt:HI (match_dup 1) (match_dup 2)))]
11903   "ix86_match_ccmode (insn, CCGOCmode)
11904    && ix86_binary_operator_ok (LSHIFTRT, HImode, operands)"
11905   "shr{w}\t{%2, %0|%0, %2}"
11906   [(set_attr "type" "ishift")
11907    (set_attr "mode" "HI")])
11909 (define_expand "lshrqi3"
11910   [(set (match_operand:QI 0 "nonimmediate_operand" "")
11911         (lshiftrt:QI (match_operand:QI 1 "nonimmediate_operand" "")
11912                      (match_operand:QI 2 "nonmemory_operand" "")))
11913    (clobber (reg:CC 17))]
11914   "TARGET_QIMODE_MATH"
11915   "ix86_expand_binary_operator (LSHIFTRT, QImode, operands); DONE;")
11917 (define_insn "*lshrqi3_1_one_bit"
11918   [(set (match_operand:QI 0 "nonimmediate_operand" "=qm")
11919         (lshiftrt:QI (match_operand:QI 1 "nonimmediate_operand" "0")
11920                      (match_operand:QI 2 "const_int_1_operand" "")))
11921    (clobber (reg:CC 17))]
11922   "ix86_binary_operator_ok (LSHIFTRT, QImode, operands)
11923    && (TARGET_SHIFT1 || optimize_size)"
11924   "shr{b}\t%0"
11925   [(set_attr "type" "ishift")
11926    (set (attr "length") 
11927      (if_then_else (match_operand 0 "register_operand" "") 
11928         (const_string "2")
11929         (const_string "*")))])
11931 (define_insn "*lshrqi3_1_one_bit_slp"
11932   [(set (strict_low_part (match_operand:QI 0 "nonimmediate_operand" "+qm"))
11933         (lshiftrt:QI (match_operand:QI 1 "nonimmediate_operand" "0")
11934                      (match_operand:QI 2 "const_int_1_operand" "")))
11935    (clobber (reg:CC 17))]
11936   "(! TARGET_PARTIAL_REG_STALL || optimize_size)
11937    && ix86_binary_operator_ok (LSHIFTRT, QImode, operands)
11938    && (TARGET_SHIFT1 || optimize_size)"
11939   "shr{b}\t%0"
11940   [(set_attr "type" "ishift")
11941    (set (attr "length") 
11942      (if_then_else (match_operand 0 "register_operand" "") 
11943         (const_string "2")
11944         (const_string "*")))])
11946 (define_insn "*lshrqi3_1"
11947   [(set (match_operand:QI 0 "nonimmediate_operand" "=qm,qm")
11948         (lshiftrt:QI (match_operand:QI 1 "nonimmediate_operand" "0,0")
11949                      (match_operand:QI 2 "nonmemory_operand" "I,c")))
11950    (clobber (reg:CC 17))]
11951   "ix86_binary_operator_ok (LSHIFTRT, QImode, operands)"
11952   "@
11953    shr{b}\t{%2, %0|%0, %2}
11954    shr{b}\t{%b2, %0|%0, %b2}"
11955   [(set_attr "type" "ishift")
11956    (set_attr "mode" "QI")])
11958 (define_insn "*lshrqi3_1_slp"
11959   [(set (strict_low_part (match_operand:QI 0 "nonimmediate_operand" "+qm,qm"))
11960         (lshiftrt:QI (match_operand:QI 1 "nonimmediate_operand" "0,0")
11961                      (match_operand:QI 2 "nonmemory_operand" "I,c")))
11962    (clobber (reg:CC 17))]
11963   "(! TARGET_PARTIAL_REG_STALL || optimize_size)
11964    && ix86_binary_operator_ok (LSHIFTRT, QImode, operands)"
11965   "@
11966    shr{b}\t{%2, %0|%0, %2}
11967    shr{b}\t{%b2, %0|%0, %b2}"
11968   [(set_attr "type" "ishift")
11969    (set_attr "mode" "QI")])
11971 ;; This pattern can't accept a variable shift count, since shifts by
11972 ;; zero don't affect the flags.  We assume that shifts by constant
11973 ;; zero are optimized away.
11974 (define_insn "*lshrqi2_one_bit_cmp"
11975   [(set (reg 17)
11976         (compare
11977           (lshiftrt:QI (match_operand:QI 1 "nonimmediate_operand" "0")
11978                        (match_operand:QI 2 "const_int_1_operand" ""))
11979           (const_int 0)))
11980    (set (match_operand:QI 0 "nonimmediate_operand" "=qm")
11981         (lshiftrt:QI (match_dup 1) (match_dup 2)))]
11982   "ix86_match_ccmode (insn, CCGOCmode)
11983    && (TARGET_SHIFT1 || optimize_size)
11984    && ix86_binary_operator_ok (LSHIFTRT, QImode, operands)"
11985   "shr{b}\t%0"
11986   [(set_attr "type" "ishift")
11987    (set (attr "length") 
11988      (if_then_else (match_operand:SI 0 "register_operand" "") 
11989         (const_string "2")
11990         (const_string "*")))])
11992 ;; This pattern can't accept a variable shift count, since shifts by
11993 ;; zero don't affect the flags.  We assume that shifts by constant
11994 ;; zero are optimized away.
11995 (define_insn "*lshrqi2_cmp"
11996   [(set (reg 17)
11997         (compare
11998           (lshiftrt:QI (match_operand:QI 1 "nonimmediate_operand" "0")
11999                        (match_operand:QI 2 "const_int_1_31_operand" "I"))
12000           (const_int 0)))
12001    (set (match_operand:QI 0 "nonimmediate_operand" "=qm")
12002         (lshiftrt:QI (match_dup 1) (match_dup 2)))]
12003   "ix86_match_ccmode (insn, CCGOCmode)
12004    && ix86_binary_operator_ok (LSHIFTRT, QImode, operands)"
12005   "shr{b}\t{%2, %0|%0, %2}"
12006   [(set_attr "type" "ishift")
12007    (set_attr "mode" "QI")])
12009 ;; Rotate instructions
12011 (define_expand "rotldi3"
12012   [(set (match_operand:DI 0 "nonimmediate_operand" "")
12013         (rotate:DI (match_operand:DI 1 "nonimmediate_operand" "")
12014                    (match_operand:QI 2 "nonmemory_operand" "")))
12015    (clobber (reg:CC 17))]
12016   "TARGET_64BIT"
12017   "ix86_expand_binary_operator (ROTATE, DImode, operands); DONE;")
12019 (define_insn "*rotlsi3_1_one_bit_rex64"
12020   [(set (match_operand:DI 0 "nonimmediate_operand" "=rm")
12021         (rotate:DI (match_operand:DI 1 "nonimmediate_operand" "0")
12022                    (match_operand:QI 2 "const_int_1_operand" "")))
12023    (clobber (reg:CC 17))]
12024   "TARGET_64BIT && ix86_binary_operator_ok (ROTATE, DImode, operands)
12025    && (TARGET_SHIFT1 || optimize_size)"
12026   "rol{q}\t%0"
12027   [(set_attr "type" "rotate")
12028    (set (attr "length") 
12029      (if_then_else (match_operand:DI 0 "register_operand" "") 
12030         (const_string "2")
12031         (const_string "*")))])
12033 (define_insn "*rotldi3_1_rex64"
12034   [(set (match_operand:DI 0 "nonimmediate_operand" "=rm,rm")
12035         (rotate:DI (match_operand:DI 1 "nonimmediate_operand" "0,0")
12036                    (match_operand:QI 2 "nonmemory_operand" "e,c")))
12037    (clobber (reg:CC 17))]
12038   "TARGET_64BIT && ix86_binary_operator_ok (ROTATE, DImode, operands)"
12039   "@
12040    rol{q}\t{%2, %0|%0, %2}
12041    rol{q}\t{%b2, %0|%0, %b2}"
12042   [(set_attr "type" "rotate")
12043    (set_attr "mode" "DI")])
12045 (define_expand "rotlsi3"
12046   [(set (match_operand:SI 0 "nonimmediate_operand" "")
12047         (rotate:SI (match_operand:SI 1 "nonimmediate_operand" "")
12048                    (match_operand:QI 2 "nonmemory_operand" "")))
12049    (clobber (reg:CC 17))]
12050   ""
12051   "ix86_expand_binary_operator (ROTATE, SImode, operands); DONE;")
12053 (define_insn "*rotlsi3_1_one_bit"
12054   [(set (match_operand:SI 0 "nonimmediate_operand" "=rm")
12055         (rotate:SI (match_operand:SI 1 "nonimmediate_operand" "0")
12056                    (match_operand:QI 2 "const_int_1_operand" "")))
12057    (clobber (reg:CC 17))]
12058   "ix86_binary_operator_ok (ROTATE, SImode, operands)
12059    && (TARGET_SHIFT1 || optimize_size)"
12060   "rol{l}\t%0"
12061   [(set_attr "type" "rotate")
12062    (set (attr "length") 
12063      (if_then_else (match_operand:SI 0 "register_operand" "") 
12064         (const_string "2")
12065         (const_string "*")))])
12067 (define_insn "*rotlsi3_1_one_bit_zext"
12068   [(set (match_operand:DI 0 "register_operand" "=r")
12069         (zero_extend:DI
12070           (rotate:SI (match_operand:SI 1 "register_operand" "0")
12071                      (match_operand:QI 2 "const_int_1_operand" ""))))
12072    (clobber (reg:CC 17))]
12073   "TARGET_64BIT && ix86_binary_operator_ok (ROTATE, SImode, operands)
12074    && (TARGET_SHIFT1 || optimize_size)"
12075   "rol{l}\t%k0"
12076   [(set_attr "type" "rotate")
12077    (set_attr "length" "2")])
12079 (define_insn "*rotlsi3_1"
12080   [(set (match_operand:SI 0 "nonimmediate_operand" "=rm,rm")
12081         (rotate:SI (match_operand:SI 1 "nonimmediate_operand" "0,0")
12082                    (match_operand:QI 2 "nonmemory_operand" "I,c")))
12083    (clobber (reg:CC 17))]
12084   "ix86_binary_operator_ok (ROTATE, SImode, operands)"
12085   "@
12086    rol{l}\t{%2, %0|%0, %2}
12087    rol{l}\t{%b2, %0|%0, %b2}"
12088   [(set_attr "type" "rotate")
12089    (set_attr "mode" "SI")])
12091 (define_insn "*rotlsi3_1_zext"
12092   [(set (match_operand:DI 0 "register_operand" "=r,r")
12093         (zero_extend:DI
12094           (rotate:SI (match_operand:SI 1 "register_operand" "0,0")
12095                      (match_operand:QI 2 "nonmemory_operand" "I,c"))))
12096    (clobber (reg:CC 17))]
12097   "TARGET_64BIT && ix86_binary_operator_ok (ROTATE, SImode, operands)"
12098   "@
12099    rol{l}\t{%2, %k0|%k0, %2}
12100    rol{l}\t{%b2, %k0|%k0, %b2}"
12101   [(set_attr "type" "rotate")
12102    (set_attr "mode" "SI")])
12104 (define_expand "rotlhi3"
12105   [(set (match_operand:HI 0 "nonimmediate_operand" "")
12106         (rotate:HI (match_operand:HI 1 "nonimmediate_operand" "")
12107                    (match_operand:QI 2 "nonmemory_operand" "")))
12108    (clobber (reg:CC 17))]
12109   "TARGET_HIMODE_MATH"
12110   "ix86_expand_binary_operator (ROTATE, HImode, operands); DONE;")
12112 (define_insn "*rotlhi3_1_one_bit"
12113   [(set (match_operand:HI 0 "nonimmediate_operand" "=rm")
12114         (rotate:HI (match_operand:HI 1 "nonimmediate_operand" "0")
12115                    (match_operand:QI 2 "const_int_1_operand" "")))
12116    (clobber (reg:CC 17))]
12117   "ix86_binary_operator_ok (ROTATE, HImode, operands)
12118    && (TARGET_SHIFT1 || optimize_size)"
12119   "rol{w}\t%0"
12120   [(set_attr "type" "rotate")
12121    (set (attr "length") 
12122      (if_then_else (match_operand 0 "register_operand" "") 
12123         (const_string "2")
12124         (const_string "*")))])
12126 (define_insn "*rotlhi3_1"
12127   [(set (match_operand:HI 0 "nonimmediate_operand" "=rm,rm")
12128         (rotate:HI (match_operand:HI 1 "nonimmediate_operand" "0,0")
12129                    (match_operand:QI 2 "nonmemory_operand" "I,c")))
12130    (clobber (reg:CC 17))]
12131   "ix86_binary_operator_ok (ROTATE, HImode, operands)"
12132   "@
12133    rol{w}\t{%2, %0|%0, %2}
12134    rol{w}\t{%b2, %0|%0, %b2}"
12135   [(set_attr "type" "rotate")
12136    (set_attr "mode" "HI")])
12138 (define_expand "rotlqi3"
12139   [(set (match_operand:QI 0 "nonimmediate_operand" "")
12140         (rotate:QI (match_operand:QI 1 "nonimmediate_operand" "")
12141                    (match_operand:QI 2 "nonmemory_operand" "")))
12142    (clobber (reg:CC 17))]
12143   "TARGET_QIMODE_MATH"
12144   "ix86_expand_binary_operator (ROTATE, QImode, operands); DONE;")
12146 (define_insn "*rotlqi3_1_one_bit_slp"
12147   [(set (strict_low_part (match_operand:QI 0 "nonimmediate_operand" "+qm"))
12148         (rotate:QI (match_operand:QI 1 "nonimmediate_operand" "0")
12149                    (match_operand:QI 2 "const_int_1_operand" "")))
12150    (clobber (reg:CC 17))]
12151   "(! TARGET_PARTIAL_REG_STALL || optimize_size)
12152    && ix86_binary_operator_ok (ROTATE, QImode, operands)
12153    && (TARGET_SHIFT1 || optimize_size)"
12154   "rol{b}\t%0"
12155   [(set_attr "type" "rotate")
12156    (set (attr "length") 
12157      (if_then_else (match_operand 0 "register_operand" "") 
12158         (const_string "2")
12159         (const_string "*")))])
12161 (define_insn "*rotlqi3_1_one_bit"
12162   [(set (match_operand:QI 0 "nonimmediate_operand" "=qm")
12163         (rotate:QI (match_operand:QI 1 "nonimmediate_operand" "0")
12164                    (match_operand:QI 2 "const_int_1_operand" "")))
12165    (clobber (reg:CC 17))]
12166   "ix86_binary_operator_ok (ROTATE, QImode, operands)
12167    && (TARGET_SHIFT1 || optimize_size)"
12168   "rol{b}\t%0"
12169   [(set_attr "type" "rotate")
12170    (set (attr "length") 
12171      (if_then_else (match_operand 0 "register_operand" "") 
12172         (const_string "2")
12173         (const_string "*")))])
12175 (define_insn "*rotlqi3_1_slp"
12176   [(set (strict_low_part (match_operand:QI 0 "nonimmediate_operand" "+qm,qm"))
12177         (rotate:QI (match_operand:QI 1 "nonimmediate_operand" "0,0")
12178                    (match_operand:QI 2 "nonmemory_operand" "I,c")))
12179    (clobber (reg:CC 17))]
12180   "(! TARGET_PARTIAL_REG_STALL || optimize_size)
12181    && ix86_binary_operator_ok (ROTATE, QImode, operands)"
12182   "@
12183    rol{b}\t{%2, %0|%0, %2}
12184    rol{b}\t{%b2, %0|%0, %b2}"
12185   [(set_attr "type" "rotate")
12186    (set_attr "mode" "QI")])
12188 (define_insn "*rotlqi3_1"
12189   [(set (match_operand:QI 0 "nonimmediate_operand" "=qm,qm")
12190         (rotate:QI (match_operand:QI 1 "nonimmediate_operand" "0,0")
12191                    (match_operand:QI 2 "nonmemory_operand" "I,c")))
12192    (clobber (reg:CC 17))]
12193   "ix86_binary_operator_ok (ROTATE, QImode, operands)"
12194   "@
12195    rol{b}\t{%2, %0|%0, %2}
12196    rol{b}\t{%b2, %0|%0, %b2}"
12197   [(set_attr "type" "rotate")
12198    (set_attr "mode" "QI")])
12200 (define_expand "rotrdi3"
12201   [(set (match_operand:DI 0 "nonimmediate_operand" "")
12202         (rotatert:DI (match_operand:DI 1 "nonimmediate_operand" "")
12203                      (match_operand:QI 2 "nonmemory_operand" "")))
12204    (clobber (reg:CC 17))]
12205   "TARGET_64BIT"
12206   "ix86_expand_binary_operator (ROTATERT, DImode, operands); DONE;")
12208 (define_insn "*rotrdi3_1_one_bit_rex64"
12209   [(set (match_operand:DI 0 "nonimmediate_operand" "=rm")
12210         (rotatert:DI (match_operand:DI 1 "nonimmediate_operand" "0")
12211                      (match_operand:QI 2 "const_int_1_operand" "")))
12212    (clobber (reg:CC 17))]
12213   "TARGET_64BIT && ix86_binary_operator_ok (ROTATERT, DImode, operands)
12214    && (TARGET_SHIFT1 || optimize_size)"
12215   "ror{q}\t%0"
12216   [(set_attr "type" "rotate")
12217    (set (attr "length") 
12218      (if_then_else (match_operand:DI 0 "register_operand" "") 
12219         (const_string "2")
12220         (const_string "*")))])
12222 (define_insn "*rotrdi3_1_rex64"
12223   [(set (match_operand:DI 0 "nonimmediate_operand" "=rm,rm")
12224         (rotatert:DI (match_operand:DI 1 "nonimmediate_operand" "0,0")
12225                      (match_operand:QI 2 "nonmemory_operand" "J,c")))
12226    (clobber (reg:CC 17))]
12227   "TARGET_64BIT && ix86_binary_operator_ok (ROTATERT, DImode, operands)"
12228   "@
12229    ror{q}\t{%2, %0|%0, %2}
12230    ror{q}\t{%b2, %0|%0, %b2}"
12231   [(set_attr "type" "rotate")
12232    (set_attr "mode" "DI")])
12234 (define_expand "rotrsi3"
12235   [(set (match_operand:SI 0 "nonimmediate_operand" "")
12236         (rotatert:SI (match_operand:SI 1 "nonimmediate_operand" "")
12237                      (match_operand:QI 2 "nonmemory_operand" "")))
12238    (clobber (reg:CC 17))]
12239   ""
12240   "ix86_expand_binary_operator (ROTATERT, SImode, operands); DONE;")
12242 (define_insn "*rotrsi3_1_one_bit"
12243   [(set (match_operand:SI 0 "nonimmediate_operand" "=rm")
12244         (rotatert:SI (match_operand:SI 1 "nonimmediate_operand" "0")
12245                      (match_operand:QI 2 "const_int_1_operand" "")))
12246    (clobber (reg:CC 17))]
12247   "ix86_binary_operator_ok (ROTATERT, SImode, operands)
12248    && (TARGET_SHIFT1 || optimize_size)"
12249   "ror{l}\t%0"
12250   [(set_attr "type" "rotate")
12251    (set (attr "length") 
12252      (if_then_else (match_operand:SI 0 "register_operand" "") 
12253         (const_string "2")
12254         (const_string "*")))])
12256 (define_insn "*rotrsi3_1_one_bit_zext"
12257   [(set (match_operand:DI 0 "register_operand" "=r")
12258         (zero_extend:DI
12259           (rotatert:SI (match_operand:SI 1 "register_operand" "0")
12260                        (match_operand:QI 2 "const_int_1_operand" ""))))
12261    (clobber (reg:CC 17))]
12262   "TARGET_64BIT && ix86_binary_operator_ok (ROTATERT, SImode, operands)
12263    && (TARGET_SHIFT1 || optimize_size)"
12264   "ror{l}\t%k0"
12265   [(set_attr "type" "rotate")
12266    (set (attr "length") 
12267      (if_then_else (match_operand:SI 0 "register_operand" "") 
12268         (const_string "2")
12269         (const_string "*")))])
12271 (define_insn "*rotrsi3_1"
12272   [(set (match_operand:SI 0 "nonimmediate_operand" "=rm,rm")
12273         (rotatert:SI (match_operand:SI 1 "nonimmediate_operand" "0,0")
12274                      (match_operand:QI 2 "nonmemory_operand" "I,c")))
12275    (clobber (reg:CC 17))]
12276   "ix86_binary_operator_ok (ROTATERT, SImode, operands)"
12277   "@
12278    ror{l}\t{%2, %0|%0, %2}
12279    ror{l}\t{%b2, %0|%0, %b2}"
12280   [(set_attr "type" "rotate")
12281    (set_attr "mode" "SI")])
12283 (define_insn "*rotrsi3_1_zext"
12284   [(set (match_operand:DI 0 "register_operand" "=r,r")
12285         (zero_extend:DI
12286           (rotatert:SI (match_operand:SI 1 "register_operand" "0,0")
12287                        (match_operand:QI 2 "nonmemory_operand" "I,c"))))
12288    (clobber (reg:CC 17))]
12289   "TARGET_64BIT && ix86_binary_operator_ok (ROTATERT, SImode, operands)"
12290   "@
12291    ror{l}\t{%2, %k0|%k0, %2}
12292    ror{l}\t{%b2, %k0|%k0, %b2}"
12293   [(set_attr "type" "rotate")
12294    (set_attr "mode" "SI")])
12296 (define_expand "rotrhi3"
12297   [(set (match_operand:HI 0 "nonimmediate_operand" "")
12298         (rotatert:HI (match_operand:HI 1 "nonimmediate_operand" "")
12299                      (match_operand:QI 2 "nonmemory_operand" "")))
12300    (clobber (reg:CC 17))]
12301   "TARGET_HIMODE_MATH"
12302   "ix86_expand_binary_operator (ROTATERT, HImode, operands); DONE;")
12304 (define_insn "*rotrhi3_one_bit"
12305   [(set (match_operand:HI 0 "nonimmediate_operand" "=rm")
12306         (rotatert:HI (match_operand:HI 1 "nonimmediate_operand" "0")
12307                      (match_operand:QI 2 "const_int_1_operand" "")))
12308    (clobber (reg:CC 17))]
12309   "ix86_binary_operator_ok (ROTATERT, HImode, operands)
12310    && (TARGET_SHIFT1 || optimize_size)"
12311   "ror{w}\t%0"
12312   [(set_attr "type" "rotate")
12313    (set (attr "length") 
12314      (if_then_else (match_operand 0 "register_operand" "") 
12315         (const_string "2")
12316         (const_string "*")))])
12318 (define_insn "*rotrhi3"
12319   [(set (match_operand:HI 0 "nonimmediate_operand" "=rm,rm")
12320         (rotatert:HI (match_operand:HI 1 "nonimmediate_operand" "0,0")
12321                      (match_operand:QI 2 "nonmemory_operand" "I,c")))
12322    (clobber (reg:CC 17))]
12323   "ix86_binary_operator_ok (ROTATERT, HImode, operands)"
12324   "@
12325    ror{w}\t{%2, %0|%0, %2}
12326    ror{w}\t{%b2, %0|%0, %b2}"
12327   [(set_attr "type" "rotate")
12328    (set_attr "mode" "HI")])
12330 (define_expand "rotrqi3"
12331   [(set (match_operand:QI 0 "nonimmediate_operand" "")
12332         (rotatert:QI (match_operand:QI 1 "nonimmediate_operand" "")
12333                      (match_operand:QI 2 "nonmemory_operand" "")))
12334    (clobber (reg:CC 17))]
12335   "TARGET_QIMODE_MATH"
12336   "ix86_expand_binary_operator (ROTATERT, QImode, operands); DONE;")
12338 (define_insn "*rotrqi3_1_one_bit"
12339   [(set (match_operand:QI 0 "nonimmediate_operand" "=qm")
12340         (rotatert:QI (match_operand:QI 1 "nonimmediate_operand" "0")
12341                      (match_operand:QI 2 "const_int_1_operand" "")))
12342    (clobber (reg:CC 17))]
12343   "ix86_binary_operator_ok (ROTATERT, QImode, operands)
12344    && (TARGET_SHIFT1 || optimize_size)"
12345   "ror{b}\t%0"
12346   [(set_attr "type" "rotate")
12347    (set (attr "length") 
12348      (if_then_else (match_operand 0 "register_operand" "") 
12349         (const_string "2")
12350         (const_string "*")))])
12352 (define_insn "*rotrqi3_1_one_bit_slp"
12353   [(set (strict_low_part (match_operand:QI 0 "nonimmediate_operand" "+qm"))
12354         (rotatert:QI (match_operand:QI 1 "nonimmediate_operand" "0")
12355                      (match_operand:QI 2 "const_int_1_operand" "")))
12356    (clobber (reg:CC 17))]
12357   "(! TARGET_PARTIAL_REG_STALL || optimize_size)
12358    && ix86_binary_operator_ok (ROTATERT, QImode, operands)
12359    && (TARGET_SHIFT1 || optimize_size)"
12360   "ror{b}\t%0"
12361   [(set_attr "type" "rotate")
12362    (set (attr "length") 
12363      (if_then_else (match_operand 0 "register_operand" "") 
12364         (const_string "2")
12365         (const_string "*")))])
12367 (define_insn "*rotrqi3_1"
12368   [(set (match_operand:QI 0 "nonimmediate_operand" "=qm,qm")
12369         (rotatert:QI (match_operand:QI 1 "nonimmediate_operand" "0,0")
12370                      (match_operand:QI 2 "nonmemory_operand" "I,c")))
12371    (clobber (reg:CC 17))]
12372   "ix86_binary_operator_ok (ROTATERT, QImode, operands)"
12373   "@
12374    ror{b}\t{%2, %0|%0, %2}
12375    ror{b}\t{%b2, %0|%0, %b2}"
12376   [(set_attr "type" "rotate")
12377    (set_attr "mode" "QI")])
12379 (define_insn "*rotrqi3_1_slp"
12380   [(set (strict_low_part (match_operand:QI 0 "nonimmediate_operand" "+qm,qm"))
12381         (rotatert:QI (match_operand:QI 1 "nonimmediate_operand" "0,0")
12382                      (match_operand:QI 2 "nonmemory_operand" "I,c")))
12383    (clobber (reg:CC 17))]
12384   "(! TARGET_PARTIAL_REG_STALL || optimize_size)
12385    && ix86_binary_operator_ok (ROTATERT, QImode, operands)"
12386   "@
12387    ror{b}\t{%2, %0|%0, %2}
12388    ror{b}\t{%b2, %0|%0, %b2}"
12389   [(set_attr "type" "rotate")
12390    (set_attr "mode" "QI")])
12392 ;; Bit set / bit test instructions
12394 (define_expand "extv"
12395   [(set (match_operand:SI 0 "register_operand" "")
12396         (sign_extract:SI (match_operand:SI 1 "register_operand" "")
12397                          (match_operand:SI 2 "immediate_operand" "")
12398                          (match_operand:SI 3 "immediate_operand" "")))]
12399   ""
12401   /* Handle extractions from %ah et al.  */
12402   if (INTVAL (operands[2]) != 8 || INTVAL (operands[3]) != 8)
12403     FAIL;
12405   /* From mips.md: extract_bit_field doesn't verify that our source
12406      matches the predicate, so check it again here.  */
12407   if (! register_operand (operands[1], VOIDmode))
12408     FAIL;
12411 (define_expand "extzv"
12412   [(set (match_operand:SI 0 "register_operand" "")
12413         (zero_extract:SI (match_operand 1 "ext_register_operand" "")
12414                          (match_operand:SI 2 "immediate_operand" "")
12415                          (match_operand:SI 3 "immediate_operand" "")))]
12416   ""
12418   /* Handle extractions from %ah et al.  */
12419   if (INTVAL (operands[2]) != 8 || INTVAL (operands[3]) != 8)
12420     FAIL;
12422   /* From mips.md: extract_bit_field doesn't verify that our source
12423      matches the predicate, so check it again here.  */
12424   if (! register_operand (operands[1], VOIDmode))
12425     FAIL;
12428 (define_expand "insv"
12429   [(set (zero_extract:SI (match_operand 0 "ext_register_operand" "")
12430                          (match_operand:SI 1 "immediate_operand" "")
12431                          (match_operand:SI 2 "immediate_operand" ""))
12432         (match_operand:SI 3 "register_operand" ""))]
12433   ""
12435   /* Handle extractions from %ah et al.  */
12436   if (INTVAL (operands[1]) != 8 || INTVAL (operands[2]) != 8)
12437     FAIL;
12439   /* From mips.md: insert_bit_field doesn't verify that our source
12440      matches the predicate, so check it again here.  */
12441   if (! register_operand (operands[0], VOIDmode))
12442     FAIL;
12445 ;; %%% bts, btr, btc, bt.
12447 ;; Store-flag instructions.
12449 ;; For all sCOND expanders, also expand the compare or test insn that
12450 ;; generates cc0.  Generate an equality comparison if `seq' or `sne'.
12452 ;; %%% Do the expansion to SImode.  If PII, do things the xor+setcc way
12453 ;; to avoid partial register stalls.  Otherwise do things the setcc+movzx
12454 ;; way, which can later delete the movzx if only QImode is needed.
12456 (define_expand "seq"
12457   [(set (match_operand:QI 0 "register_operand" "")
12458         (eq:QI (reg:CC 17) (const_int 0)))]
12459   ""
12460   "if (ix86_expand_setcc (EQ, operands[0])) DONE; else FAIL;")
12462 (define_expand "sne"
12463   [(set (match_operand:QI 0 "register_operand" "")
12464         (ne:QI (reg:CC 17) (const_int 0)))]
12465   ""
12466   "if (ix86_expand_setcc (NE, operands[0])) DONE; else FAIL;")
12468 (define_expand "sgt"
12469   [(set (match_operand:QI 0 "register_operand" "")
12470         (gt:QI (reg:CC 17) (const_int 0)))]
12471   ""
12472   "if (ix86_expand_setcc (GT, operands[0])) DONE; else FAIL;")
12474 (define_expand "sgtu"
12475   [(set (match_operand:QI 0 "register_operand" "")
12476         (gtu:QI (reg:CC 17) (const_int 0)))]
12477   ""
12478   "if (ix86_expand_setcc (GTU, operands[0])) DONE; else FAIL;")
12480 (define_expand "slt"
12481   [(set (match_operand:QI 0 "register_operand" "")
12482         (lt:QI (reg:CC 17) (const_int 0)))]
12483   ""
12484   "if (ix86_expand_setcc (LT, operands[0])) DONE; else FAIL;")
12486 (define_expand "sltu"
12487   [(set (match_operand:QI 0 "register_operand" "")
12488         (ltu:QI (reg:CC 17) (const_int 0)))]
12489   ""
12490   "if (ix86_expand_setcc (LTU, operands[0])) DONE; else FAIL;")
12492 (define_expand "sge"
12493   [(set (match_operand:QI 0 "register_operand" "")
12494         (ge:QI (reg:CC 17) (const_int 0)))]
12495   ""
12496   "if (ix86_expand_setcc (GE, operands[0])) DONE; else FAIL;")
12498 (define_expand "sgeu"
12499   [(set (match_operand:QI 0 "register_operand" "")
12500         (geu:QI (reg:CC 17) (const_int 0)))]
12501   ""
12502   "if (ix86_expand_setcc (GEU, operands[0])) DONE; else FAIL;")
12504 (define_expand "sle"
12505   [(set (match_operand:QI 0 "register_operand" "")
12506         (le:QI (reg:CC 17) (const_int 0)))]
12507   ""
12508   "if (ix86_expand_setcc (LE, operands[0])) DONE; else FAIL;")
12510 (define_expand "sleu"
12511   [(set (match_operand:QI 0 "register_operand" "")
12512         (leu:QI (reg:CC 17) (const_int 0)))]
12513   ""
12514   "if (ix86_expand_setcc (LEU, operands[0])) DONE; else FAIL;")
12516 (define_expand "sunordered"
12517   [(set (match_operand:QI 0 "register_operand" "")
12518         (unordered:QI (reg:CC 17) (const_int 0)))]
12519   "TARGET_80387 || TARGET_SSE"
12520   "if (ix86_expand_setcc (UNORDERED, operands[0])) DONE; else FAIL;")
12522 (define_expand "sordered"
12523   [(set (match_operand:QI 0 "register_operand" "")
12524         (ordered:QI (reg:CC 17) (const_int 0)))]
12525   "TARGET_80387"
12526   "if (ix86_expand_setcc (ORDERED, operands[0])) DONE; else FAIL;")
12528 (define_expand "suneq"
12529   [(set (match_operand:QI 0 "register_operand" "")
12530         (uneq:QI (reg:CC 17) (const_int 0)))]
12531   "TARGET_80387 || TARGET_SSE"
12532   "if (ix86_expand_setcc (UNEQ, operands[0])) DONE; else FAIL;")
12534 (define_expand "sunge"
12535   [(set (match_operand:QI 0 "register_operand" "")
12536         (unge:QI (reg:CC 17) (const_int 0)))]
12537   "TARGET_80387 || TARGET_SSE"
12538   "if (ix86_expand_setcc (UNGE, operands[0])) DONE; else FAIL;")
12540 (define_expand "sungt"
12541   [(set (match_operand:QI 0 "register_operand" "")
12542         (ungt:QI (reg:CC 17) (const_int 0)))]
12543   "TARGET_80387 || TARGET_SSE"
12544   "if (ix86_expand_setcc (UNGT, operands[0])) DONE; else FAIL;")
12546 (define_expand "sunle"
12547   [(set (match_operand:QI 0 "register_operand" "")
12548         (unle:QI (reg:CC 17) (const_int 0)))]
12549   "TARGET_80387 || TARGET_SSE"
12550   "if (ix86_expand_setcc (UNLE, operands[0])) DONE; else FAIL;")
12552 (define_expand "sunlt"
12553   [(set (match_operand:QI 0 "register_operand" "")
12554         (unlt:QI (reg:CC 17) (const_int 0)))]
12555   "TARGET_80387 || TARGET_SSE"
12556   "if (ix86_expand_setcc (UNLT, operands[0])) DONE; else FAIL;")
12558 (define_expand "sltgt"
12559   [(set (match_operand:QI 0 "register_operand" "")
12560         (ltgt:QI (reg:CC 17) (const_int 0)))]
12561   "TARGET_80387 || TARGET_SSE"
12562   "if (ix86_expand_setcc (LTGT, operands[0])) DONE; else FAIL;")
12564 (define_insn "*setcc_1"
12565   [(set (match_operand:QI 0 "nonimmediate_operand" "=qm")
12566         (match_operator:QI 1 "ix86_comparison_operator"
12567           [(reg 17) (const_int 0)]))]
12568   ""
12569   "set%C1\t%0"
12570   [(set_attr "type" "setcc")
12571    (set_attr "mode" "QI")])
12573 (define_insn "setcc_2"
12574   [(set (strict_low_part (match_operand:QI 0 "nonimmediate_operand" "+qm"))
12575         (match_operator:QI 1 "ix86_comparison_operator"
12576           [(reg 17) (const_int 0)]))]
12577   ""
12578   "set%C1\t%0"
12579   [(set_attr "type" "setcc")
12580    (set_attr "mode" "QI")])
12582 ;; In general it is not safe to assume too much about CCmode registers,
12583 ;; so simplify-rtx stops when it sees a second one.  Under certain 
12584 ;; conditions this is safe on x86, so help combine not create
12586 ;;      seta    %al
12587 ;;      testb   %al, %al
12588 ;;      sete    %al
12590 (define_split 
12591   [(set (match_operand:QI 0 "nonimmediate_operand" "")
12592         (ne:QI (match_operator 1 "ix86_comparison_operator"
12593                  [(reg 17) (const_int 0)])
12594             (const_int 0)))]
12595   ""
12596   [(set (match_dup 0) (match_dup 1))]
12598   PUT_MODE (operands[1], QImode);
12601 (define_split 
12602   [(set (strict_low_part (match_operand:QI 0 "nonimmediate_operand" ""))
12603         (ne:QI (match_operator 1 "ix86_comparison_operator"
12604                  [(reg 17) (const_int 0)])
12605             (const_int 0)))]
12606   ""
12607   [(set (match_dup 0) (match_dup 1))]
12609   PUT_MODE (operands[1], QImode);
12612 (define_split 
12613   [(set (match_operand:QI 0 "nonimmediate_operand" "")
12614         (eq:QI (match_operator 1 "ix86_comparison_operator"
12615                  [(reg 17) (const_int 0)])
12616             (const_int 0)))]
12617   ""
12618   [(set (match_dup 0) (match_dup 1))]
12620   rtx new_op1 = copy_rtx (operands[1]);
12621   operands[1] = new_op1;
12622   PUT_MODE (new_op1, QImode);
12623   PUT_CODE (new_op1, REVERSE_CONDITION (GET_CODE (new_op1),
12624                                         GET_MODE (XEXP (new_op1, 0))));
12626   /* Make sure that (a) the CCmode we have for the flags is strong
12627      enough for the reversed compare or (b) we have a valid FP compare.  */
12628   if (! ix86_comparison_operator (new_op1, VOIDmode))
12629     FAIL;
12632 (define_split 
12633   [(set (strict_low_part (match_operand:QI 0 "nonimmediate_operand" ""))
12634         (eq:QI (match_operator 1 "ix86_comparison_operator"
12635                  [(reg 17) (const_int 0)])
12636             (const_int 0)))]
12637   ""
12638   [(set (match_dup 0) (match_dup 1))]
12640   rtx new_op1 = copy_rtx (operands[1]);
12641   operands[1] = new_op1;
12642   PUT_MODE (new_op1, QImode);
12643   PUT_CODE (new_op1, REVERSE_CONDITION (GET_CODE (new_op1),
12644                                         GET_MODE (XEXP (new_op1, 0))));
12646   /* Make sure that (a) the CCmode we have for the flags is strong
12647      enough for the reversed compare or (b) we have a valid FP compare.  */
12648   if (! ix86_comparison_operator (new_op1, VOIDmode))
12649     FAIL;
12652 ;; The SSE store flag instructions saves 0 or 0xffffffff to the result.
12653 ;; subsequent logical operations are used to imitate conditional moves.
12654 ;; 0xffffffff is NaN, but not in normalized form, so we can't represent
12655 ;; it directly.  Futher holding this value in pseudo register might bring
12656 ;; problem in implicit normalization in spill code.
12657 ;; So we don't define FLOAT_STORE_FLAG_VALUE and create these
12658 ;; instructions after reload by splitting the conditional move patterns.
12660 (define_insn "*sse_setccsf"
12661   [(set (match_operand:SF 0 "register_operand" "=x")
12662         (match_operator:SF 1 "sse_comparison_operator"
12663           [(match_operand:SF 2 "register_operand" "0")
12664            (match_operand:SF 3 "nonimmediate_operand" "xm")]))]
12665   "TARGET_SSE && reload_completed"
12666   "cmp%D1ss\t{%3, %0|%0, %3}"
12667   [(set_attr "type" "ssecmp")
12668    (set_attr "mode" "SF")])
12670 (define_insn "*sse_setccdf"
12671   [(set (match_operand:DF 0 "register_operand" "=Y")
12672         (match_operator:DF 1 "sse_comparison_operator"
12673           [(match_operand:DF 2 "register_operand" "0")
12674            (match_operand:DF 3 "nonimmediate_operand" "Ym")]))]
12675   "TARGET_SSE2 && reload_completed"
12676   "cmp%D1sd\t{%3, %0|%0, %3}"
12677   [(set_attr "type" "ssecmp")
12678    (set_attr "mode" "DF")])
12680 ;; Basic conditional jump instructions.
12681 ;; We ignore the overflow flag for signed branch instructions.
12683 ;; For all bCOND expanders, also expand the compare or test insn that
12684 ;; generates reg 17.  Generate an equality comparison if `beq' or `bne'.
12686 (define_expand "beq"
12687   [(set (pc)
12688         (if_then_else (match_dup 1)
12689                       (label_ref (match_operand 0 "" ""))
12690                       (pc)))]
12691   ""
12692   "ix86_expand_branch (EQ, operands[0]); DONE;")
12694 (define_expand "bne"
12695   [(set (pc)
12696         (if_then_else (match_dup 1)
12697                       (label_ref (match_operand 0 "" ""))
12698                       (pc)))]
12699   ""
12700   "ix86_expand_branch (NE, operands[0]); DONE;")
12702 (define_expand "bgt"
12703   [(set (pc)
12704         (if_then_else (match_dup 1)
12705                       (label_ref (match_operand 0 "" ""))
12706                       (pc)))]
12707   ""
12708   "ix86_expand_branch (GT, operands[0]); DONE;")
12710 (define_expand "bgtu"
12711   [(set (pc)
12712         (if_then_else (match_dup 1)
12713                       (label_ref (match_operand 0 "" ""))
12714                       (pc)))]
12715   ""
12716   "ix86_expand_branch (GTU, operands[0]); DONE;")
12718 (define_expand "blt"
12719   [(set (pc)
12720         (if_then_else (match_dup 1)
12721                       (label_ref (match_operand 0 "" ""))
12722                       (pc)))]
12723   ""
12724   "ix86_expand_branch (LT, operands[0]); DONE;")
12726 (define_expand "bltu"
12727   [(set (pc)
12728         (if_then_else (match_dup 1)
12729                       (label_ref (match_operand 0 "" ""))
12730                       (pc)))]
12731   ""
12732   "ix86_expand_branch (LTU, operands[0]); DONE;")
12734 (define_expand "bge"
12735   [(set (pc)
12736         (if_then_else (match_dup 1)
12737                       (label_ref (match_operand 0 "" ""))
12738                       (pc)))]
12739   ""
12740   "ix86_expand_branch (GE, operands[0]); DONE;")
12742 (define_expand "bgeu"
12743   [(set (pc)
12744         (if_then_else (match_dup 1)
12745                       (label_ref (match_operand 0 "" ""))
12746                       (pc)))]
12747   ""
12748   "ix86_expand_branch (GEU, operands[0]); DONE;")
12750 (define_expand "ble"
12751   [(set (pc)
12752         (if_then_else (match_dup 1)
12753                       (label_ref (match_operand 0 "" ""))
12754                       (pc)))]
12755   ""
12756   "ix86_expand_branch (LE, operands[0]); DONE;")
12758 (define_expand "bleu"
12759   [(set (pc)
12760         (if_then_else (match_dup 1)
12761                       (label_ref (match_operand 0 "" ""))
12762                       (pc)))]
12763   ""
12764   "ix86_expand_branch (LEU, operands[0]); DONE;")
12766 (define_expand "bunordered"
12767   [(set (pc)
12768         (if_then_else (match_dup 1)
12769                       (label_ref (match_operand 0 "" ""))
12770                       (pc)))]
12771   "TARGET_80387 || TARGET_SSE"
12772   "ix86_expand_branch (UNORDERED, operands[0]); DONE;")
12774 (define_expand "bordered"
12775   [(set (pc)
12776         (if_then_else (match_dup 1)
12777                       (label_ref (match_operand 0 "" ""))
12778                       (pc)))]
12779   "TARGET_80387 || TARGET_SSE"
12780   "ix86_expand_branch (ORDERED, operands[0]); DONE;")
12782 (define_expand "buneq"
12783   [(set (pc)
12784         (if_then_else (match_dup 1)
12785                       (label_ref (match_operand 0 "" ""))
12786                       (pc)))]
12787   "TARGET_80387 || TARGET_SSE"
12788   "ix86_expand_branch (UNEQ, operands[0]); DONE;")
12790 (define_expand "bunge"
12791   [(set (pc)
12792         (if_then_else (match_dup 1)
12793                       (label_ref (match_operand 0 "" ""))
12794                       (pc)))]
12795   "TARGET_80387 || TARGET_SSE"
12796   "ix86_expand_branch (UNGE, operands[0]); DONE;")
12798 (define_expand "bungt"
12799   [(set (pc)
12800         (if_then_else (match_dup 1)
12801                       (label_ref (match_operand 0 "" ""))
12802                       (pc)))]
12803   "TARGET_80387 || TARGET_SSE"
12804   "ix86_expand_branch (UNGT, operands[0]); DONE;")
12806 (define_expand "bunle"
12807   [(set (pc)
12808         (if_then_else (match_dup 1)
12809                       (label_ref (match_operand 0 "" ""))
12810                       (pc)))]
12811   "TARGET_80387 || TARGET_SSE"
12812   "ix86_expand_branch (UNLE, operands[0]); DONE;")
12814 (define_expand "bunlt"
12815   [(set (pc)
12816         (if_then_else (match_dup 1)
12817                       (label_ref (match_operand 0 "" ""))
12818                       (pc)))]
12819   "TARGET_80387 || TARGET_SSE"
12820   "ix86_expand_branch (UNLT, operands[0]); DONE;")
12822 (define_expand "bltgt"
12823   [(set (pc)
12824         (if_then_else (match_dup 1)
12825                       (label_ref (match_operand 0 "" ""))
12826                       (pc)))]
12827   "TARGET_80387 || TARGET_SSE"
12828   "ix86_expand_branch (LTGT, operands[0]); DONE;")
12830 (define_insn "*jcc_1"
12831   [(set (pc)
12832         (if_then_else (match_operator 1 "ix86_comparison_operator"
12833                                       [(reg 17) (const_int 0)])
12834                       (label_ref (match_operand 0 "" ""))
12835                       (pc)))]
12836   ""
12837   "%+j%C1\t%l0"
12838   [(set_attr "type" "ibr")
12839    (set_attr "modrm" "0")
12840    (set (attr "prefix_0f")
12841            (if_then_else (and (ge (minus (match_dup 0) (pc))
12842                                   (const_int -128))
12843                               (lt (minus (match_dup 0) (pc))
12844                                   (const_int 124)))
12845              (const_int 0)
12846              (const_int 1)))])
12848 (define_insn "*jcc_2"
12849   [(set (pc)
12850         (if_then_else (match_operator 1 "ix86_comparison_operator"
12851                                       [(reg 17) (const_int 0)])
12852                       (pc)
12853                       (label_ref (match_operand 0 "" ""))))]
12854   ""
12855   "%+j%c1\t%l0"
12856   [(set_attr "type" "ibr")
12857    (set_attr "modrm" "0")
12858    (set (attr "prefix_0f")
12859            (if_then_else (and (ge (minus (match_dup 0) (pc))
12860                                   (const_int -128))
12861                               (lt (minus (match_dup 0) (pc))
12862                                   (const_int 124)))
12863              (const_int 0)
12864              (const_int 1)))])
12866 ;; In general it is not safe to assume too much about CCmode registers,
12867 ;; so simplify-rtx stops when it sees a second one.  Under certain 
12868 ;; conditions this is safe on x86, so help combine not create
12870 ;;      seta    %al
12871 ;;      testb   %al, %al
12872 ;;      je      Lfoo
12874 (define_split 
12875   [(set (pc)
12876         (if_then_else (ne (match_operator 0 "ix86_comparison_operator"
12877                                       [(reg 17) (const_int 0)])
12878                           (const_int 0))
12879                       (label_ref (match_operand 1 "" ""))
12880                       (pc)))]
12881   ""
12882   [(set (pc)
12883         (if_then_else (match_dup 0)
12884                       (label_ref (match_dup 1))
12885                       (pc)))]
12887   PUT_MODE (operands[0], VOIDmode);
12889   
12890 (define_split 
12891   [(set (pc)
12892         (if_then_else (eq (match_operator 0 "ix86_comparison_operator"
12893                                       [(reg 17) (const_int 0)])
12894                           (const_int 0))
12895                       (label_ref (match_operand 1 "" ""))
12896                       (pc)))]
12897   ""
12898   [(set (pc)
12899         (if_then_else (match_dup 0)
12900                       (label_ref (match_dup 1))
12901                       (pc)))]
12903   rtx new_op0 = copy_rtx (operands[0]);
12904   operands[0] = new_op0;
12905   PUT_MODE (new_op0, VOIDmode);
12906   PUT_CODE (new_op0, REVERSE_CONDITION (GET_CODE (new_op0),
12907                                         GET_MODE (XEXP (new_op0, 0))));
12909   /* Make sure that (a) the CCmode we have for the flags is strong
12910      enough for the reversed compare or (b) we have a valid FP compare.  */
12911   if (! ix86_comparison_operator (new_op0, VOIDmode))
12912     FAIL;
12915 ;; Define combination compare-and-branch fp compare instructions to use
12916 ;; during early optimization.  Splitting the operation apart early makes
12917 ;; for bad code when we want to reverse the operation.
12919 (define_insn "*fp_jcc_1"
12920   [(set (pc)
12921         (if_then_else (match_operator 0 "comparison_operator"
12922                         [(match_operand 1 "register_operand" "f")
12923                          (match_operand 2 "register_operand" "f")])
12924           (label_ref (match_operand 3 "" ""))
12925           (pc)))
12926    (clobber (reg:CCFP 18))
12927    (clobber (reg:CCFP 17))]
12928   "TARGET_CMOVE && TARGET_80387
12929    && !SSE_FLOAT_MODE_P (GET_MODE (operands[1]))
12930    && FLOAT_MODE_P (GET_MODE (operands[1]))
12931    && GET_MODE (operands[1]) == GET_MODE (operands[2])
12932    && ix86_fp_jump_nontrivial_p (GET_CODE (operands[0]))"
12933   "#")
12935 (define_insn "*fp_jcc_1_sse"
12936   [(set (pc)
12937         (if_then_else (match_operator 0 "comparison_operator"
12938                         [(match_operand 1 "register_operand" "f#x,x#f")
12939                          (match_operand 2 "nonimmediate_operand" "f#x,xm#f")])
12940           (label_ref (match_operand 3 "" ""))
12941           (pc)))
12942    (clobber (reg:CCFP 18))
12943    (clobber (reg:CCFP 17))]
12944   "TARGET_80387
12945    && SSE_FLOAT_MODE_P (GET_MODE (operands[1]))
12946    && GET_MODE (operands[1]) == GET_MODE (operands[2])
12947    && ix86_fp_jump_nontrivial_p (GET_CODE (operands[0]))"
12948   "#")
12950 (define_insn "*fp_jcc_1_sse_only"
12951   [(set (pc)
12952         (if_then_else (match_operator 0 "comparison_operator"
12953                         [(match_operand 1 "register_operand" "x")
12954                          (match_operand 2 "nonimmediate_operand" "xm")])
12955           (label_ref (match_operand 3 "" ""))
12956           (pc)))
12957    (clobber (reg:CCFP 18))
12958    (clobber (reg:CCFP 17))]
12959   "SSE_FLOAT_MODE_P (GET_MODE (operands[1]))
12960    && GET_MODE (operands[1]) == GET_MODE (operands[2])
12961    && ix86_fp_jump_nontrivial_p (GET_CODE (operands[0]))"
12962   "#")
12964 (define_insn "*fp_jcc_2"
12965   [(set (pc)
12966         (if_then_else (match_operator 0 "comparison_operator"
12967                         [(match_operand 1 "register_operand" "f")
12968                          (match_operand 2 "register_operand" "f")])
12969           (pc)
12970           (label_ref (match_operand 3 "" ""))))
12971    (clobber (reg:CCFP 18))
12972    (clobber (reg:CCFP 17))]
12973   "TARGET_CMOVE && TARGET_80387
12974    && !SSE_FLOAT_MODE_P (GET_MODE (operands[1]))
12975    && FLOAT_MODE_P (GET_MODE (operands[1]))
12976    && GET_MODE (operands[1]) == GET_MODE (operands[2])
12977    && ix86_fp_jump_nontrivial_p (GET_CODE (operands[0]))"
12978   "#")
12980 (define_insn "*fp_jcc_2_sse"
12981   [(set (pc)
12982         (if_then_else (match_operator 0 "comparison_operator"
12983                         [(match_operand 1 "register_operand" "f#x,x#f")
12984                          (match_operand 2 "nonimmediate_operand" "f#x,xm#f")])
12985           (pc)
12986           (label_ref (match_operand 3 "" ""))))
12987    (clobber (reg:CCFP 18))
12988    (clobber (reg:CCFP 17))]
12989   "TARGET_80387
12990    && SSE_FLOAT_MODE_P (GET_MODE (operands[1]))
12991    && GET_MODE (operands[1]) == GET_MODE (operands[2])
12992    && ix86_fp_jump_nontrivial_p (GET_CODE (operands[0]))"
12993   "#")
12995 (define_insn "*fp_jcc_2_sse_only"
12996   [(set (pc)
12997         (if_then_else (match_operator 0 "comparison_operator"
12998                         [(match_operand 1 "register_operand" "x")
12999                          (match_operand 2 "nonimmediate_operand" "xm")])
13000           (pc)
13001           (label_ref (match_operand 3 "" ""))))
13002    (clobber (reg:CCFP 18))
13003    (clobber (reg:CCFP 17))]
13004   "SSE_FLOAT_MODE_P (GET_MODE (operands[1]))
13005    && GET_MODE (operands[1]) == GET_MODE (operands[2])
13006    && ix86_fp_jump_nontrivial_p (GET_CODE (operands[0]))"
13007   "#")
13009 (define_insn "*fp_jcc_3"
13010   [(set (pc)
13011         (if_then_else (match_operator 0 "comparison_operator"
13012                         [(match_operand 1 "register_operand" "f")
13013                          (match_operand 2 "nonimmediate_operand" "fm")])
13014           (label_ref (match_operand 3 "" ""))
13015           (pc)))
13016    (clobber (reg:CCFP 18))
13017    (clobber (reg:CCFP 17))
13018    (clobber (match_scratch:HI 4 "=a"))]
13019   "TARGET_80387
13020    && (GET_MODE (operands[1]) == SFmode || GET_MODE (operands[1]) == DFmode)
13021    && GET_MODE (operands[1]) == GET_MODE (operands[2])
13022    && !ix86_use_fcomi_compare (GET_CODE (operands[0]))
13023    && SELECT_CC_MODE (GET_CODE (operands[0]),
13024                       operands[1], operands[2]) == CCFPmode
13025    && ix86_fp_jump_nontrivial_p (GET_CODE (operands[0]))"
13026   "#")
13028 (define_insn "*fp_jcc_4"
13029   [(set (pc)
13030         (if_then_else (match_operator 0 "comparison_operator"
13031                         [(match_operand 1 "register_operand" "f")
13032                          (match_operand 2 "nonimmediate_operand" "fm")])
13033           (pc)
13034           (label_ref (match_operand 3 "" ""))))
13035    (clobber (reg:CCFP 18))
13036    (clobber (reg:CCFP 17))
13037    (clobber (match_scratch:HI 4 "=a"))]
13038   "TARGET_80387
13039    && (GET_MODE (operands[1]) == SFmode || GET_MODE (operands[1]) == DFmode)
13040    && GET_MODE (operands[1]) == GET_MODE (operands[2])
13041    && !ix86_use_fcomi_compare (GET_CODE (operands[0]))
13042    && SELECT_CC_MODE (GET_CODE (operands[0]),
13043                       operands[1], operands[2]) == CCFPmode
13044    && ix86_fp_jump_nontrivial_p (GET_CODE (operands[0]))"
13045   "#")
13047 (define_insn "*fp_jcc_5"
13048   [(set (pc)
13049         (if_then_else (match_operator 0 "comparison_operator"
13050                         [(match_operand 1 "register_operand" "f")
13051                          (match_operand 2 "register_operand" "f")])
13052           (label_ref (match_operand 3 "" ""))
13053           (pc)))
13054    (clobber (reg:CCFP 18))
13055    (clobber (reg:CCFP 17))
13056    (clobber (match_scratch:HI 4 "=a"))]
13057   "TARGET_80387
13058    && FLOAT_MODE_P (GET_MODE (operands[1]))
13059    && GET_MODE (operands[1]) == GET_MODE (operands[2])
13060    && ix86_fp_jump_nontrivial_p (GET_CODE (operands[0]))"
13061   "#")
13063 (define_insn "*fp_jcc_6"
13064   [(set (pc)
13065         (if_then_else (match_operator 0 "comparison_operator"
13066                         [(match_operand 1 "register_operand" "f")
13067                          (match_operand 2 "register_operand" "f")])
13068           (pc)
13069           (label_ref (match_operand 3 "" ""))))
13070    (clobber (reg:CCFP 18))
13071    (clobber (reg:CCFP 17))
13072    (clobber (match_scratch:HI 4 "=a"))]
13073   "TARGET_80387
13074    && FLOAT_MODE_P (GET_MODE (operands[1]))
13075    && GET_MODE (operands[1]) == GET_MODE (operands[2])
13076    && ix86_fp_jump_nontrivial_p (GET_CODE (operands[0]))"
13077   "#")
13079 (define_split
13080   [(set (pc)
13081         (if_then_else (match_operator 0 "comparison_operator"
13082                         [(match_operand 1 "register_operand" "")
13083                          (match_operand 2 "nonimmediate_operand" "")])
13084           (match_operand 3 "" "")
13085           (match_operand 4 "" "")))
13086    (clobber (reg:CCFP 18))
13087    (clobber (reg:CCFP 17))]
13088   "reload_completed"
13089   [(const_int 0)]
13091   ix86_split_fp_branch (GET_CODE (operands[0]), operands[1], operands[2],
13092                         operands[3], operands[4], NULL_RTX);
13093   DONE;
13096 (define_split
13097   [(set (pc)
13098         (if_then_else (match_operator 0 "comparison_operator"
13099                         [(match_operand 1 "register_operand" "")
13100                          (match_operand 2 "nonimmediate_operand" "")])
13101           (match_operand 3 "" "")
13102           (match_operand 4 "" "")))
13103    (clobber (reg:CCFP 18))
13104    (clobber (reg:CCFP 17))
13105    (clobber (match_scratch:HI 5 "=a"))]
13106   "reload_completed"
13107   [(set (pc)
13108         (if_then_else (match_dup 6)
13109           (match_dup 3)
13110           (match_dup 4)))]
13112   ix86_split_fp_branch (GET_CODE (operands[0]), operands[1], operands[2],
13113                         operands[3], operands[4], operands[5]);
13114   DONE;
13117 ;; Unconditional and other jump instructions
13119 (define_insn "jump"
13120   [(set (pc)
13121         (label_ref (match_operand 0 "" "")))]
13122   ""
13123   "jmp\t%l0"
13124   [(set_attr "type" "ibr")
13125    (set_attr "modrm" "0")])
13127 (define_expand "indirect_jump"
13128   [(set (pc) (match_operand 0 "nonimmediate_operand" "rm"))]
13129   ""
13130   "")
13132 (define_insn "*indirect_jump"
13133   [(set (pc) (match_operand:SI 0 "nonimmediate_operand" "rm"))]
13134   "!TARGET_64BIT"
13135   "jmp\t%A0"
13136   [(set_attr "type" "ibr")
13137    (set_attr "length_immediate" "0")])
13139 (define_insn "*indirect_jump_rtx64"
13140   [(set (pc) (match_operand:DI 0 "nonimmediate_operand" "rm"))]
13141   "TARGET_64BIT"
13142   "jmp\t%A0"
13143   [(set_attr "type" "ibr")
13144    (set_attr "length_immediate" "0")])
13146 (define_expand "tablejump"
13147   [(parallel [(set (pc) (match_operand 0 "nonimmediate_operand" "rm"))
13148               (use (label_ref (match_operand 1 "" "")))])]
13149   ""
13151   /* In PIC mode, the table entries are stored GOT (32-bit) or PC (64-bit)
13152      relative.  Convert the relative address to an absolute address.  */
13153   if (flag_pic)
13154     {
13155       rtx op0, op1;
13156       enum rtx_code code;
13158       if (TARGET_64BIT)
13159         {
13160           code = PLUS;
13161           op0 = operands[0];
13162           op1 = gen_rtx_LABEL_REF (Pmode, operands[1]);
13163         }
13164       else if (TARGET_MACHO || HAVE_AS_GOTOFF_IN_DATA)
13165         {
13166           code = PLUS;
13167           op0 = operands[0];
13168           op1 = pic_offset_table_rtx;
13169         }
13170       else
13171         {
13172           code = MINUS;
13173           op0 = pic_offset_table_rtx;
13174           op1 = operands[0];
13175         }
13177       operands[0] = expand_simple_binop (Pmode, code, op0, op1, NULL_RTX, 0,
13178                                          OPTAB_DIRECT);
13179     }
13182 (define_insn "*tablejump_1"
13183   [(set (pc) (match_operand:SI 0 "nonimmediate_operand" "rm"))
13184    (use (label_ref (match_operand 1 "" "")))]
13185   "!TARGET_64BIT"
13186   "jmp\t%A0"
13187   [(set_attr "type" "ibr")
13188    (set_attr "length_immediate" "0")])
13190 (define_insn "*tablejump_1_rtx64"
13191   [(set (pc) (match_operand:DI 0 "nonimmediate_operand" "rm"))
13192    (use (label_ref (match_operand 1 "" "")))]
13193   "TARGET_64BIT"
13194   "jmp\t%A0"
13195   [(set_attr "type" "ibr")
13196    (set_attr "length_immediate" "0")])
13198 ;; Loop instruction
13200 ;; This is all complicated by the fact that since this is a jump insn
13201 ;; we must handle our own reloads.
13203 (define_expand "doloop_end"
13204   [(use (match_operand 0 "" ""))        ; loop pseudo
13205    (use (match_operand 1 "" ""))        ; iterations; zero if unknown
13206    (use (match_operand 2 "" ""))        ; max iterations
13207    (use (match_operand 3 "" ""))        ; loop level 
13208    (use (match_operand 4 "" ""))]       ; label
13209   "!TARGET_64BIT && TARGET_USE_LOOP"
13210   "                                 
13212   /* Only use cloop on innermost loops.  */
13213   if (INTVAL (operands[3]) > 1)
13214     FAIL;
13215   if (GET_MODE (operands[0]) != SImode)
13216     FAIL;
13217   emit_jump_insn (gen_doloop_end_internal (operands[4], operands[0],
13218                                            operands[0]));
13219   DONE;
13222 (define_insn "doloop_end_internal"
13223   [(set (pc)
13224         (if_then_else (ne (match_operand:SI 1 "register_operand" "c,?*r,?*r")
13225                           (const_int 1))
13226                       (label_ref (match_operand 0 "" ""))
13227                       (pc)))
13228    (set (match_operand:SI 2 "register_operand" "=1,1,*m*r")
13229         (plus:SI (match_dup 1)
13230                  (const_int -1)))
13231    (clobber (match_scratch:SI 3 "=X,X,r"))
13232    (clobber (reg:CC 17))]
13233   "!TARGET_64BIT && TARGET_USE_LOOP"
13235   if (which_alternative != 0)
13236     return "#";
13237   if (get_attr_length (insn) == 2)
13238     return "%+loop\t%l0";
13239   else
13240     return "dec{l}\t%1\;%+jne\t%l0";
13242   [(set_attr "ppro_uops" "many")
13243    (set (attr "length")
13244         (if_then_else (and (eq_attr "alternative" "0")
13245                            (and (ge (minus (match_dup 0) (pc))
13246                                     (const_int -128))
13247                                 (lt (minus (match_dup 0) (pc))
13248                                     (const_int 124))))
13249                       (const_int 2)
13250                       (const_int 16)))
13251    (set (attr "type")
13252         (if_then_else (and (eq_attr "alternative" "0")
13253                            (and (ge (minus (match_dup 0) (pc))
13254                                     (const_int -128))
13255                                 (lt (minus (match_dup 0) (pc))
13256                                     (const_int 124))))
13257                       (const_string "ibr")
13258                       (const_string "multi")))])
13260 (define_split
13261   [(set (pc)
13262         (if_then_else (ne (match_operand:SI 1 "register_operand" "")
13263                           (const_int 1))
13264                       (match_operand 0 "" "")
13265                       (pc)))
13266    (set (match_dup 1)
13267         (plus:SI (match_dup 1)
13268                  (const_int -1)))
13269    (clobber (match_scratch:SI 2 ""))
13270    (clobber (reg:CC 17))]
13271   "!TARGET_64BIT && TARGET_USE_LOOP
13272    && reload_completed
13273    && REGNO (operands[1]) != 2"
13274   [(parallel [(set (reg:CCZ 17)
13275                    (compare:CCZ (plus:SI (match_dup 1) (const_int -1))
13276                                  (const_int 0)))
13277               (set (match_dup 1) (plus:SI (match_dup 1) (const_int -1)))])
13278    (set (pc) (if_then_else (ne (reg:CCZ 17) (const_int 0))
13279                            (match_dup 0)
13280                            (pc)))]
13281   "")
13282   
13283 (define_split
13284   [(set (pc)
13285         (if_then_else (ne (match_operand:SI 1 "register_operand" "")
13286                           (const_int 1))
13287                       (match_operand 0 "" "")
13288                       (pc)))
13289    (set (match_operand:SI 2 "nonimmediate_operand" "")
13290         (plus:SI (match_dup 1)
13291                  (const_int -1)))
13292    (clobber (match_scratch:SI 3 ""))
13293    (clobber (reg:CC 17))]
13294   "!TARGET_64BIT && TARGET_USE_LOOP
13295    && reload_completed
13296    && (! REG_P (operands[2])
13297        || ! rtx_equal_p (operands[1], operands[2]))"
13298   [(set (match_dup 3) (match_dup 1))
13299    (parallel [(set (reg:CCZ 17)
13300                    (compare:CCZ (plus:SI (match_dup 3) (const_int -1))
13301                                 (const_int 0)))
13302               (set (match_dup 3) (plus:SI (match_dup 3) (const_int -1)))])
13303    (set (match_dup 2) (match_dup 3))
13304    (set (pc) (if_then_else (ne (reg:CCZ 17) (const_int 0))
13305                            (match_dup 0)
13306                            (pc)))]
13307   "")
13309 ;; Convert setcc + movzbl to xor + setcc if operands don't overlap.
13311 (define_peephole2
13312   [(set (reg 17) (match_operand 0 "" ""))
13313    (set (match_operand:QI 1 "register_operand" "")
13314         (match_operator:QI 2 "ix86_comparison_operator"
13315           [(reg 17) (const_int 0)]))
13316    (set (match_operand 3 "q_regs_operand" "")
13317         (zero_extend (match_dup 1)))]
13318   "(peep2_reg_dead_p (3, operands[1])
13319     || operands_match_p (operands[1], operands[3]))
13320    && ! reg_overlap_mentioned_p (operands[3], operands[0])"
13321   [(set (match_dup 4) (match_dup 0))
13322    (set (strict_low_part (match_dup 5))
13323         (match_dup 2))]
13325   operands[4] = gen_rtx_REG (GET_MODE (operands[0]), 17);
13326   operands[5] = gen_rtx_REG (QImode, REGNO (operands[3]));
13327   ix86_expand_clear (operands[3]);
13330 ;; Similar, but match zero_extendhisi2_and, which adds a clobber.
13332 (define_peephole2
13333   [(set (reg 17) (match_operand 0 "" ""))
13334    (set (match_operand:QI 1 "register_operand" "")
13335         (match_operator:QI 2 "ix86_comparison_operator"
13336           [(reg 17) (const_int 0)]))
13337    (parallel [(set (match_operand 3 "q_regs_operand" "")
13338                    (zero_extend (match_dup 1)))
13339               (clobber (reg:CC 17))])]
13340   "(peep2_reg_dead_p (3, operands[1])
13341     || operands_match_p (operands[1], operands[3]))
13342    && ! reg_overlap_mentioned_p (operands[3], operands[0])"
13343   [(set (match_dup 4) (match_dup 0))
13344    (set (strict_low_part (match_dup 5))
13345         (match_dup 2))]
13347   operands[4] = gen_rtx_REG (GET_MODE (operands[0]), 17);
13348   operands[5] = gen_rtx_REG (QImode, REGNO (operands[3]));
13349   ix86_expand_clear (operands[3]);
13352 ;; Call instructions.
13354 ;; The predicates normally associated with named expanders are not properly
13355 ;; checked for calls.  This is a bug in the generic code, but it isn't that
13356 ;; easy to fix.  Ignore it for now and be prepared to fix things up.
13358 ;; Call subroutine returning no value.
13360 (define_expand "call_pop"
13361   [(parallel [(call (match_operand:QI 0 "" "")
13362                     (match_operand:SI 1 "" ""))
13363               (set (reg:SI 7)
13364                    (plus:SI (reg:SI 7)
13365                             (match_operand:SI 3 "" "")))])]
13366   "!TARGET_64BIT"
13368   ix86_expand_call (NULL, operands[0], operands[1], operands[2], operands[3]);
13369   DONE;
13372 (define_insn "*call_pop_0"
13373   [(call (mem:QI (match_operand:SI 0 "constant_call_address_operand" ""))
13374          (match_operand:SI 1 "" ""))
13375    (set (reg:SI 7) (plus:SI (reg:SI 7)
13376                             (match_operand:SI 2 "immediate_operand" "")))]
13377   "!TARGET_64BIT"
13379   if (SIBLING_CALL_P (insn))
13380     return "jmp\t%P0";
13381   else
13382     return "call\t%P0";
13384   [(set_attr "type" "call")])
13385   
13386 (define_insn "*call_pop_1"
13387   [(call (mem:QI (match_operand:SI 0 "call_insn_operand" "rsm"))
13388          (match_operand:SI 1 "" ""))
13389    (set (reg:SI 7) (plus:SI (reg:SI 7)
13390                             (match_operand:SI 2 "immediate_operand" "i")))]
13391   "!TARGET_64BIT"
13393   if (constant_call_address_operand (operands[0], Pmode))
13394     {
13395       if (SIBLING_CALL_P (insn))
13396         return "jmp\t%P0";
13397       else
13398         return "call\t%P0";
13399     }
13400   if (SIBLING_CALL_P (insn))
13401     return "jmp\t%A0";
13402   else
13403     return "call\t%A0";
13405   [(set_attr "type" "call")])
13407 (define_expand "call"
13408   [(call (match_operand:QI 0 "" "")
13409          (match_operand 1 "" ""))
13410    (use (match_operand 2 "" ""))]
13411   ""
13413   ix86_expand_call (NULL, operands[0], operands[1], operands[2], NULL);
13414   DONE;
13417 (define_insn "*call_0"
13418   [(call (mem:QI (match_operand 0 "constant_call_address_operand" ""))
13419          (match_operand 1 "" ""))]
13420   ""
13422   if (SIBLING_CALL_P (insn))
13423     return "jmp\t%P0";
13424   else
13425     return "call\t%P0";
13427   [(set_attr "type" "call")])
13429 (define_insn "*call_1"
13430   [(call (mem:QI (match_operand:SI 0 "call_insn_operand" "rsm"))
13431          (match_operand 1 "" ""))]
13432   "!TARGET_64BIT"
13434   if (constant_call_address_operand (operands[0], QImode))
13435     {
13436       if (SIBLING_CALL_P (insn))
13437         return "jmp\t%P0";
13438       else
13439         return "call\t%P0";
13440     }
13441   if (SIBLING_CALL_P (insn))
13442     return "jmp\t%A0";
13443   else
13444     return "call\t%A0";
13446   [(set_attr "type" "call")])
13448 (define_insn "*call_1_rex64"
13449   [(call (mem:QI (match_operand:DI 0 "call_insn_operand" "rsm"))
13450          (match_operand 1 "" ""))]
13451   "TARGET_64BIT"
13453   if (constant_call_address_operand (operands[0], QImode))
13454     {
13455       if (SIBLING_CALL_P (insn))
13456         return "jmp\t%P0";
13457       else
13458         return "call\t%P0";
13459     }
13460   if (SIBLING_CALL_P (insn))
13461     return "jmp\t%A0";
13462   else
13463     return "call\t%A0";
13465   [(set_attr "type" "call")])
13467 ;; Call subroutine, returning value in operand 0
13469 (define_expand "call_value_pop"
13470   [(parallel [(set (match_operand 0 "" "")
13471                    (call (match_operand:QI 1 "" "")
13472                          (match_operand:SI 2 "" "")))
13473               (set (reg:SI 7)
13474                    (plus:SI (reg:SI 7)
13475                             (match_operand:SI 4 "" "")))])]
13476   "!TARGET_64BIT"
13478   ix86_expand_call (operands[0], operands[1], operands[2],
13479                     operands[3], operands[4]);
13480   DONE;
13483 (define_expand "call_value"
13484   [(set (match_operand 0 "" "")
13485         (call (match_operand:QI 1 "" "")
13486               (match_operand:SI 2 "" "")))
13487    (use (match_operand:SI 3 "" ""))]
13488   ;; Operand 2 not used on the i386.
13489   ""
13491   ix86_expand_call (operands[0], operands[1], operands[2], operands[3], NULL);
13492   DONE;
13495 ;; Call subroutine returning any type.
13497 (define_expand "untyped_call"
13498   [(parallel [(call (match_operand 0 "" "")
13499                     (const_int 0))
13500               (match_operand 1 "" "")
13501               (match_operand 2 "" "")])]
13502   ""
13504   int i;
13506   /* In order to give reg-stack an easier job in validating two
13507      coprocessor registers as containing a possible return value,
13508      simply pretend the untyped call returns a complex long double
13509      value.  */
13511   ix86_expand_call ((TARGET_FLOAT_RETURNS_IN_80387
13512                      ? gen_rtx_REG (XCmode, FIRST_FLOAT_REG) : NULL),
13513                     operands[0], const0_rtx, GEN_INT (SSE_REGPARM_MAX - 1),
13514                     NULL);
13516   for (i = 0; i < XVECLEN (operands[2], 0); i++)
13517     {
13518       rtx set = XVECEXP (operands[2], 0, i);
13519       emit_move_insn (SET_DEST (set), SET_SRC (set));
13520     }
13522   /* The optimizer does not know that the call sets the function value
13523      registers we stored in the result block.  We avoid problems by
13524      claiming that all hard registers are used and clobbered at this
13525      point.  */
13526   emit_insn (gen_blockage (const0_rtx));
13528   DONE;
13531 ;; Prologue and epilogue instructions
13533 ;; UNSPEC_VOLATILE is considered to use and clobber all hard registers and
13534 ;; all of memory.  This blocks insns from being moved across this point.
13536 (define_insn "blockage"
13537   [(unspec_volatile [(match_operand 0 "" "")] UNSPECV_BLOCKAGE)]
13538   ""
13539   ""
13540   [(set_attr "length" "0")])
13542 ;; Insn emitted into the body of a function to return from a function.
13543 ;; This is only done if the function's epilogue is known to be simple.
13544 ;; See comments for ix86_can_use_return_insn_p in i386.c.
13546 (define_expand "return"
13547   [(return)]
13548   "ix86_can_use_return_insn_p ()"
13550   if (current_function_pops_args)
13551     {
13552       rtx popc = GEN_INT (current_function_pops_args);
13553       emit_jump_insn (gen_return_pop_internal (popc));
13554       DONE;
13555     }
13558 (define_insn "return_internal"
13559   [(return)]
13560   "reload_completed"
13561   "ret"
13562   [(set_attr "length" "1")
13563    (set_attr "length_immediate" "0")
13564    (set_attr "modrm" "0")])
13566 (define_insn "return_pop_internal"
13567   [(return)
13568    (use (match_operand:SI 0 "const_int_operand" ""))]
13569   "reload_completed"
13570   "ret\t%0"
13571   [(set_attr "length" "3")
13572    (set_attr "length_immediate" "2")
13573    (set_attr "modrm" "0")])
13575 (define_insn "return_indirect_internal"
13576   [(return)
13577    (use (match_operand:SI 0 "register_operand" "r"))]
13578   "reload_completed"
13579   "jmp\t%A0"
13580   [(set_attr "type" "ibr")
13581    (set_attr "length_immediate" "0")])
13583 (define_insn "nop"
13584   [(const_int 0)]
13585   ""
13586   "nop"
13587   [(set_attr "length" "1")
13588    (set_attr "length_immediate" "0")
13589    (set_attr "modrm" "0")
13590    (set_attr "ppro_uops" "one")])
13592 (define_expand "prologue"
13593   [(const_int 1)]
13594   ""
13595   "ix86_expand_prologue (); DONE;")
13597 (define_insn "set_got"
13598   [(set (match_operand:SI 0 "register_operand" "=r")
13599         (unspec:SI [(const_int 0)] UNSPEC_SET_GOT))
13600    (clobber (reg:CC 17))]
13601   "!TARGET_64BIT"
13602   { return output_set_got (operands[0]); }
13603   [(set_attr "type" "multi")
13604    (set_attr "length" "12")])
13606 (define_expand "epilogue"
13607   [(const_int 1)]
13608   ""
13609   "ix86_expand_epilogue (1); DONE;")
13611 (define_expand "sibcall_epilogue"
13612   [(const_int 1)]
13613   ""
13614   "ix86_expand_epilogue (0); DONE;")
13616 (define_expand "eh_return"
13617   [(use (match_operand 0 "register_operand" ""))
13618    (use (match_operand 1 "register_operand" ""))]
13619   ""
13621   rtx tmp, sa = operands[0], ra = operands[1];
13623   /* Tricky bit: we write the address of the handler to which we will
13624      be returning into someone else's stack frame, one word below the
13625      stack address we wish to restore.  */
13626   tmp = gen_rtx_PLUS (Pmode, arg_pointer_rtx, sa);
13627   tmp = plus_constant (tmp, -UNITS_PER_WORD);
13628   tmp = gen_rtx_MEM (Pmode, tmp);
13629   emit_move_insn (tmp, ra);
13631   if (Pmode == SImode)
13632     emit_insn (gen_eh_return_si (sa));
13633   else
13634     emit_insn (gen_eh_return_di (sa));
13635   emit_barrier ();
13636   DONE;
13639 (define_insn_and_split "eh_return_si"
13640   [(unspec_volatile [(match_operand:SI 0 "register_operand" "c")]
13641                     UNSPECV_EH_RETURN)]
13642   "!TARGET_64BIT"
13643   "#"
13644   "reload_completed"
13645   [(const_int 1)]
13646   "ix86_expand_epilogue (2); DONE;")
13648 (define_insn_and_split "eh_return_di"
13649   [(unspec_volatile [(match_operand:DI 0 "register_operand" "c")]
13650                     UNSPECV_EH_RETURN)]
13651   "TARGET_64BIT"
13652   "#"
13653   "reload_completed"
13654   [(const_int 1)]
13655   "ix86_expand_epilogue (2); DONE;")
13657 (define_insn "leave"
13658   [(set (reg:SI 7) (plus:SI (reg:SI 6) (const_int 4)))
13659    (set (reg:SI 6) (mem:SI (reg:SI 6)))
13660    (clobber (mem:BLK (scratch)))]
13661   "!TARGET_64BIT"
13662   "leave"
13663   [(set_attr "length_immediate" "0")
13664    (set_attr "length" "1")
13665    (set_attr "modrm" "0")
13666    (set_attr "athlon_decode" "vector")
13667    (set_attr "ppro_uops" "few")])
13669 (define_insn "leave_rex64"
13670   [(set (reg:DI 7) (plus:DI (reg:DI 6) (const_int 8)))
13671    (set (reg:DI 6) (mem:DI (reg:DI 6)))
13672    (clobber (mem:BLK (scratch)))]
13673   "TARGET_64BIT"
13674   "leave"
13675   [(set_attr "length_immediate" "0")
13676    (set_attr "length" "1")
13677    (set_attr "modrm" "0")
13678    (set_attr "athlon_decode" "vector")
13679    (set_attr "ppro_uops" "few")])
13681 (define_expand "ffssi2"
13682   [(set (match_operand:SI 0 "nonimmediate_operand" "") 
13683         (ffs:SI (match_operand:SI 1 "general_operand" "")))]
13684   ""
13686   rtx out = gen_reg_rtx (SImode), tmp = gen_reg_rtx (SImode);
13687   rtx in = operands[1];
13689   if (TARGET_CMOVE)
13690     {
13691       emit_move_insn (tmp, constm1_rtx);
13692       emit_insn (gen_ffssi_1 (out, in));
13693       emit_insn (gen_rtx_SET (VOIDmode, out,
13694                   gen_rtx_IF_THEN_ELSE (SImode, 
13695                     gen_rtx_EQ (VOIDmode, gen_rtx_REG (CCZmode, FLAGS_REG),
13696                                 const0_rtx),
13697                     tmp,
13698                     out)));
13699       emit_insn (gen_addsi3 (out, out, const1_rtx));
13700       emit_move_insn (operands[0], out);
13701     }
13703   /* Pentium bsf instruction is extremly slow.  The following code is
13704      recommended by the Intel Optimizing Manual as a reasonable replacement:
13705            TEST    EAX,EAX
13706            JZ      SHORT BS2
13707            XOR     ECX,ECX
13708            MOV     DWORD PTR [TEMP+4],ECX
13709            SUB     ECX,EAX
13710            AND     EAX,ECX
13711            MOV     DWORD PTR [TEMP],EAX
13712            FILD    QWORD PTR [TEMP]
13713            FSTP    QWORD PTR [TEMP]
13714            WAIT    ; WAIT only needed for compatibility with
13715                    ; earlier processors
13716            MOV     ECX, DWORD PTR [TEMP+4]
13717            SHR     ECX,20
13718            SUB     ECX,3FFH
13719            TEST    EAX,EAX       ; clear zero flag
13720        BS2:
13721      Following piece of code expand ffs to similar beast.
13722        */
13724   else if (TARGET_PENTIUM && !optimize_size && TARGET_80387)
13725     {
13726       rtx label = gen_label_rtx ();
13727       rtx lo, hi;
13728       rtx mem = assign_386_stack_local (DImode, 0);
13729       rtx fptmp = gen_reg_rtx (DFmode);
13730       split_di (&mem, 1, &lo, &hi);
13732       emit_move_insn (out, const0_rtx);
13734       emit_cmp_and_jump_insns (in, const0_rtx, EQ, 0, SImode, 1, label);
13736       emit_move_insn (hi, out);
13737       emit_insn (gen_subsi3 (out, out, in));
13738       emit_insn (gen_andsi3 (out, out, in));
13739       emit_move_insn (lo, out);
13740       emit_insn (gen_floatdidf2 (fptmp,mem));
13741       emit_move_insn (gen_rtx_MEM (DFmode, XEXP (mem, 0)), fptmp);
13742       emit_move_insn (out, hi);
13743       emit_insn (gen_lshrsi3 (out, out, GEN_INT (20)));
13744       emit_insn (gen_subsi3 (out, out, GEN_INT (0x3ff - 1)));
13746       emit_label (label);
13747       LABEL_NUSES (label) = 1;
13749       emit_move_insn (operands[0], out);
13750     }
13751   else
13752     {
13753       emit_move_insn (tmp, const0_rtx);
13754       emit_insn (gen_ffssi_1 (out, in));
13755       emit_insn (gen_rtx_SET (VOIDmode, 
13756                   gen_rtx_STRICT_LOW_PART (VOIDmode, gen_lowpart (QImode, tmp)),
13757                   gen_rtx_EQ (QImode, gen_rtx_REG (CCZmode, FLAGS_REG),
13758                               const0_rtx)));
13759       emit_insn (gen_negsi2 (tmp, tmp));
13760       emit_insn (gen_iorsi3 (out, out, tmp));
13761       emit_insn (gen_addsi3 (out, out, const1_rtx));
13762       emit_move_insn (operands[0], out);
13763     }
13764   DONE;  
13767 (define_insn "ffssi_1"
13768   [(set (reg:CCZ 17)
13769         (compare:CCZ (match_operand:SI 1 "nonimmediate_operand" "rm")
13770                      (const_int 0)))
13771    (set (match_operand:SI 0 "register_operand" "=r")
13772         (unspec:SI [(match_dup 1)] UNSPEC_BSF))]
13773   ""
13774   "bsf{l}\t{%1, %0|%0, %1}"
13775   [(set_attr "prefix_0f" "1")
13776    (set_attr "ppro_uops" "few")])
13778 ;; ffshi2 is not useful -- 4 word prefix ops are needed, which is larger
13779 ;; and slower than the two-byte movzx insn needed to do the work in SImode.
13781 ;; Thread-local storage patterns for ELF.
13783 ;; Note that these code sequences must appear exactly as shown
13784 ;; in order to allow linker relaxation.
13786 (define_insn "*tls_global_dynamic_gnu"
13787   [(set (match_operand:SI 0 "register_operand" "=a")
13788         (unspec:SI [(match_operand:SI 1 "register_operand" "b")
13789                     (match_operand:SI 2 "tls_symbolic_operand" "")
13790                     (match_operand:SI 3 "call_insn_operand" "")]
13791                     UNSPEC_TLS_GD))
13792    (clobber (match_scratch:SI 4 "=d"))
13793    (clobber (match_scratch:SI 5 "=c"))
13794    (clobber (reg:CC 17))]
13795   "TARGET_GNU_TLS"
13796   "lea{l}\t{%a2@TLSGD(,%1,1), %0|%0, %a2@TLSGD[%1*1]}\;call\t%P3"
13797   [(set_attr "type" "multi")
13798    (set_attr "length" "12")])
13800 (define_insn "*tls_global_dynamic_sun"
13801   [(set (match_operand:SI 0 "register_operand" "=a")
13802         (unspec:SI [(match_operand:SI 1 "register_operand" "b")
13803                     (match_operand:SI 2 "tls_symbolic_operand" "")
13804                     (match_operand:SI 3 "call_insn_operand" "")]
13805                     UNSPEC_TLS_GD))
13806    (clobber (match_scratch:SI 4 "=d"))
13807    (clobber (match_scratch:SI 5 "=c"))
13808    (clobber (reg:CC 17))]
13809   "TARGET_SUN_TLS"
13810   "lea{l}\t{%a2@DTLNDX(%1), %4|%4, %a2@DTLNDX[%1]}
13811         push{l}\t%4\;call\t%a2@TLSPLT\;pop{l}\t%4\;nop"
13812   [(set_attr "type" "multi")
13813    (set_attr "length" "14")])
13815 (define_expand "tls_global_dynamic"
13816   [(parallel [(set (match_operand:SI 0 "register_operand" "")
13817                    (unspec:SI
13818                     [(match_dup 2)
13819                      (match_operand:SI 1 "tls_symbolic_operand" "")
13820                      (match_dup 3)]
13821                     UNSPEC_TLS_GD))
13822               (clobber (match_scratch:SI 4 ""))
13823               (clobber (match_scratch:SI 5 ""))
13824               (clobber (reg:CC 17))])]
13825   ""
13827   if (!flag_pic)
13828     abort ();
13829   operands[2] = pic_offset_table_rtx;
13830   operands[3] = ix86_tls_get_addr ();
13833 (define_insn "*tls_local_dynamic_base_gnu"
13834   [(set (match_operand:SI 0 "register_operand" "=a")
13835         (unspec:SI [(match_operand:SI 1 "register_operand" "b")
13836                     (match_operand:SI 2 "call_insn_operand" "")]
13837                    UNSPEC_TLS_LD_BASE))
13838    (clobber (match_scratch:SI 3 "=d"))
13839    (clobber (match_scratch:SI 4 "=c"))
13840    (clobber (reg:CC 17))]
13841   "TARGET_GNU_TLS"
13842   "lea{l}\t{%&@TLSLDM(%1), %0|%0, %&@TLSLDM[%1]}\;call\t%P2"
13843   [(set_attr "type" "multi")
13844    (set_attr "length" "11")])
13846 (define_insn "*tls_local_dynamic_base_sun"
13847   [(set (match_operand:SI 0 "register_operand" "=a")
13848         (unspec:SI [(match_operand:SI 1 "register_operand" "b")
13849                     (match_operand:SI 2 "call_insn_operand" "")]
13850                    UNSPEC_TLS_LD_BASE))
13851    (clobber (match_scratch:SI 3 "=d"))
13852    (clobber (match_scratch:SI 4 "=c"))
13853    (clobber (reg:CC 17))]
13854   "TARGET_SUN_TLS"
13855   "lea{l}\t{%&@TMDNX(%1), %3|%3, %&@TMDNX[%1]}
13856         push{l}\t%3\;call\t%&@TLSPLT\;pop{l}\t%3"
13857   [(set_attr "type" "multi")
13858    (set_attr "length" "13")])
13860 (define_expand "tls_local_dynamic_base"
13861   [(parallel [(set (match_operand:SI 0 "register_operand" "")
13862                    (unspec:SI [(match_dup 1) (match_dup 2)]
13863                               UNSPEC_TLS_LD_BASE))
13864               (clobber (match_scratch:SI 3 ""))
13865               (clobber (match_scratch:SI 4 ""))
13866               (clobber (reg:CC 17))])]
13867   ""
13869   if (!flag_pic)
13870     abort ();
13871   operands[1] = pic_offset_table_rtx;
13872   operands[2] = ix86_tls_get_addr ();
13875 ;; Local dynamic of a single variable is a lose.  Show combine how
13876 ;; to convert that back to global dynamic.
13878 (define_insn_and_split "*tls_local_dynamic_once"
13879   [(set (match_operand:SI 0 "register_operand" "=a")
13880         (plus:SI (unspec:SI [(match_operand:SI 1 "register_operand" "b")
13881                              (match_operand:SI 2 "call_insn_operand" "")]
13882                             UNSPEC_TLS_LD_BASE)
13883                  (const:SI (unspec:SI
13884                             [(match_operand:SI 3 "tls_symbolic_operand" "")]
13885                             UNSPEC_DTPOFF))))
13886    (clobber (match_scratch:SI 4 "=d"))
13887    (clobber (match_scratch:SI 5 "=c"))
13888    (clobber (reg:CC 17))]
13889   ""
13890   "#"
13891   ""
13892   [(parallel [(set (match_dup 0)
13893                    (unspec:SI [(match_dup 1) (match_dup 3) (match_dup 2)]
13894                               UNSPEC_TLS_GD))
13895               (clobber (match_dup 4))
13896               (clobber (match_dup 5))
13897               (clobber (reg:CC 17))])]
13898   "")
13900 ;; These patterns match the binary 387 instructions for addM3, subM3,
13901 ;; mulM3 and divM3.  There are three patterns for each of DFmode and
13902 ;; SFmode.  The first is the normal insn, the second the same insn but
13903 ;; with one operand a conversion, and the third the same insn but with
13904 ;; the other operand a conversion.  The conversion may be SFmode or
13905 ;; SImode if the target mode DFmode, but only SImode if the target mode
13906 ;; is SFmode.
13908 ;; Gcc is slightly more smart about handling normal two address instructions
13909 ;; so use special patterns for add and mull.
13910 (define_insn "*fop_sf_comm_nosse"
13911   [(set (match_operand:SF 0 "register_operand" "=f")
13912         (match_operator:SF 3 "binary_fp_operator"
13913                         [(match_operand:SF 1 "nonimmediate_operand" "%0")
13914                          (match_operand:SF 2 "nonimmediate_operand" "fm")]))]
13915   "TARGET_80387 && !TARGET_SSE_MATH
13916    && GET_RTX_CLASS (GET_CODE (operands[3])) == 'c'
13917    && (GET_CODE (operands[1]) != MEM || GET_CODE (operands[2]) != MEM)"
13918   "* return output_387_binary_op (insn, operands);"
13919   [(set (attr "type") 
13920         (if_then_else (match_operand:SF 3 "mult_operator" "") 
13921            (const_string "fmul")
13922            (const_string "fop")))
13923    (set_attr "mode" "SF")])
13925 (define_insn "*fop_sf_comm"
13926   [(set (match_operand:SF 0 "register_operand" "=f#x,x#f")
13927         (match_operator:SF 3 "binary_fp_operator"
13928                         [(match_operand:SF 1 "nonimmediate_operand" "%0,0")
13929                          (match_operand:SF 2 "nonimmediate_operand" "fm#x,xm#f")]))]
13930   "TARGET_80387 && TARGET_SSE_MATH && TARGET_MIX_SSE_I387
13931    && GET_RTX_CLASS (GET_CODE (operands[3])) == 'c'
13932    && (GET_CODE (operands[1]) != MEM || GET_CODE (operands[2]) != MEM)"
13933   "* return output_387_binary_op (insn, operands);"
13934   [(set (attr "type") 
13935         (if_then_else (eq_attr "alternative" "1")
13936            (if_then_else (match_operand:SF 3 "mult_operator" "") 
13937               (const_string "ssemul")
13938               (const_string "sseadd"))
13939            (if_then_else (match_operand:SF 3 "mult_operator" "") 
13940               (const_string "fmul")
13941               (const_string "fop"))))
13942    (set_attr "mode" "SF")])
13944 (define_insn "*fop_sf_comm_sse"
13945   [(set (match_operand:SF 0 "register_operand" "=x")
13946         (match_operator:SF 3 "binary_fp_operator"
13947                         [(match_operand:SF 1 "nonimmediate_operand" "%0")
13948                          (match_operand:SF 2 "nonimmediate_operand" "xm")]))]
13949   "TARGET_SSE_MATH && GET_RTX_CLASS (GET_CODE (operands[3])) == 'c'
13950    && (GET_CODE (operands[1]) != MEM || GET_CODE (operands[2]) != MEM)"
13951   "* return output_387_binary_op (insn, operands);"
13952   [(set (attr "type") 
13953         (if_then_else (match_operand:SF 3 "mult_operator" "") 
13954            (const_string "ssemul")
13955            (const_string "sseadd")))
13956    (set_attr "mode" "SF")])
13958 (define_insn "*fop_df_comm_nosse"
13959   [(set (match_operand:DF 0 "register_operand" "=f")
13960         (match_operator:DF 3 "binary_fp_operator"
13961                         [(match_operand:DF 1 "nonimmediate_operand" "%0")
13962                          (match_operand:DF 2 "nonimmediate_operand" "fm")]))]
13963   "TARGET_80387 && (!TARGET_SSE2 || !TARGET_SSE_MATH)
13964    && GET_RTX_CLASS (GET_CODE (operands[3])) == 'c'
13965    && (GET_CODE (operands[1]) != MEM || GET_CODE (operands[2]) != MEM)"
13966   "* return output_387_binary_op (insn, operands);"
13967   [(set (attr "type") 
13968         (if_then_else (match_operand:SF 3 "mult_operator" "") 
13969            (const_string "fmul")
13970            (const_string "fop")))
13971    (set_attr "mode" "DF")])
13973 (define_insn "*fop_df_comm"
13974   [(set (match_operand:DF 0 "register_operand" "=f#Y,Y#f")
13975         (match_operator:DF 3 "binary_fp_operator"
13976                         [(match_operand:DF 1 "nonimmediate_operand" "%0,0")
13977                          (match_operand:DF 2 "nonimmediate_operand" "fm#Y,Ym#f")]))]
13978   "TARGET_80387 && TARGET_SSE_MATH && TARGET_SSE2 && TARGET_MIX_SSE_I387
13979    && GET_RTX_CLASS (GET_CODE (operands[3])) == 'c'
13980    && (GET_CODE (operands[1]) != MEM || GET_CODE (operands[2]) != MEM)"
13981   "* return output_387_binary_op (insn, operands);"
13982   [(set (attr "type") 
13983         (if_then_else (eq_attr "alternative" "1")
13984            (if_then_else (match_operand:SF 3 "mult_operator" "") 
13985               (const_string "ssemul")
13986               (const_string "sseadd"))
13987            (if_then_else (match_operand:SF 3 "mult_operator" "") 
13988               (const_string "fmul")
13989               (const_string "fop"))))
13990    (set_attr "mode" "DF")])
13992 (define_insn "*fop_df_comm_sse"
13993   [(set (match_operand:DF 0 "register_operand" "=Y")
13994         (match_operator:DF 3 "binary_fp_operator"
13995                         [(match_operand:DF 1 "nonimmediate_operand" "%0")
13996                          (match_operand:DF 2 "nonimmediate_operand" "Ym")]))]
13997   "TARGET_SSE2 && TARGET_SSE_MATH
13998    && GET_RTX_CLASS (GET_CODE (operands[3])) == 'c'
13999    && (GET_CODE (operands[1]) != MEM || GET_CODE (operands[2]) != MEM)"
14000   "* return output_387_binary_op (insn, operands);"
14001   [(set (attr "type") 
14002         (if_then_else (match_operand:SF 3 "mult_operator" "") 
14003            (const_string "ssemul")
14004            (const_string "sseadd")))
14005    (set_attr "mode" "DF")])
14007 (define_insn "*fop_xf_comm"
14008   [(set (match_operand:XF 0 "register_operand" "=f")
14009         (match_operator:XF 3 "binary_fp_operator"
14010                         [(match_operand:XF 1 "register_operand" "%0")
14011                          (match_operand:XF 2 "register_operand" "f")]))]
14012   "!TARGET_64BIT && TARGET_80387
14013    && GET_RTX_CLASS (GET_CODE (operands[3])) == 'c'"
14014   "* return output_387_binary_op (insn, operands);"
14015   [(set (attr "type") 
14016         (if_then_else (match_operand:XF 3 "mult_operator" "") 
14017            (const_string "fmul")
14018            (const_string "fop")))
14019    (set_attr "mode" "XF")])
14021 (define_insn "*fop_tf_comm"
14022   [(set (match_operand:TF 0 "register_operand" "=f")
14023         (match_operator:TF 3 "binary_fp_operator"
14024                         [(match_operand:TF 1 "register_operand" "%0")
14025                          (match_operand:TF 2 "register_operand" "f")]))]
14026   "TARGET_80387 && GET_RTX_CLASS (GET_CODE (operands[3])) == 'c'"
14027   "* return output_387_binary_op (insn, operands);"
14028   [(set (attr "type") 
14029         (if_then_else (match_operand:TF 3 "mult_operator" "") 
14030            (const_string "fmul")
14031            (const_string "fop")))
14032    (set_attr "mode" "XF")])
14034 (define_insn "*fop_sf_1_nosse"
14035   [(set (match_operand:SF 0 "register_operand" "=f,f")
14036         (match_operator:SF 3 "binary_fp_operator"
14037                         [(match_operand:SF 1 "nonimmediate_operand" "0,fm")
14038                          (match_operand:SF 2 "nonimmediate_operand" "fm,0")]))]
14039   "TARGET_80387 && !TARGET_SSE_MATH
14040    && GET_RTX_CLASS (GET_CODE (operands[3])) != 'c'
14041    && (GET_CODE (operands[1]) != MEM || GET_CODE (operands[2]) != MEM)"
14042   "* return output_387_binary_op (insn, operands);"
14043   [(set (attr "type") 
14044         (cond [(match_operand:SF 3 "mult_operator" "") 
14045                  (const_string "fmul")
14046                (match_operand:SF 3 "div_operator" "") 
14047                  (const_string "fdiv")
14048               ]
14049               (const_string "fop")))
14050    (set_attr "mode" "SF")])
14052 (define_insn "*fop_sf_1"
14053   [(set (match_operand:SF 0 "register_operand" "=f,f,x")
14054         (match_operator:SF 3 "binary_fp_operator"
14055                         [(match_operand:SF 1 "nonimmediate_operand" "0,fm,0")
14056                          (match_operand:SF 2 "nonimmediate_operand" "fm,0,xm#f")]))]
14057   "TARGET_80387 && TARGET_SSE_MATH && TARGET_MIX_SSE_I387
14058    && GET_RTX_CLASS (GET_CODE (operands[3])) != 'c'
14059    && (GET_CODE (operands[1]) != MEM || GET_CODE (operands[2]) != MEM)"
14060   "* return output_387_binary_op (insn, operands);"
14061   [(set (attr "type") 
14062         (cond [(and (eq_attr "alternative" "2")
14063                     (match_operand:SF 3 "mult_operator" ""))
14064                  (const_string "ssemul")
14065                (and (eq_attr "alternative" "2")
14066                     (match_operand:SF 3 "div_operator" ""))
14067                  (const_string "ssediv")
14068                (eq_attr "alternative" "2")
14069                  (const_string "sseadd")
14070                (match_operand:SF 3 "mult_operator" "") 
14071                  (const_string "fmul")
14072                (match_operand:SF 3 "div_operator" "") 
14073                  (const_string "fdiv")
14074               ]
14075               (const_string "fop")))
14076    (set_attr "mode" "SF")])
14078 (define_insn "*fop_sf_1_sse"
14079   [(set (match_operand:SF 0 "register_operand" "=x")
14080         (match_operator:SF 3 "binary_fp_operator"
14081                         [(match_operand:SF 1 "register_operand" "0")
14082                          (match_operand:SF 2 "nonimmediate_operand" "xm")]))]
14083   "TARGET_SSE_MATH
14084    && GET_RTX_CLASS (GET_CODE (operands[3])) != 'c'"
14085   "* return output_387_binary_op (insn, operands);"
14086   [(set (attr "type") 
14087         (cond [(match_operand:SF 3 "mult_operator" "")
14088                  (const_string "ssemul")
14089                (match_operand:SF 3 "div_operator" "")
14090                  (const_string "ssediv")
14091               ]
14092               (const_string "sseadd")))
14093    (set_attr "mode" "SF")])
14095 ;; ??? Add SSE splitters for these!
14096 (define_insn "*fop_sf_2"
14097   [(set (match_operand:SF 0 "register_operand" "=f,f")
14098         (match_operator:SF 3 "binary_fp_operator"
14099           [(float:SF (match_operand:SI 1 "nonimmediate_operand" "m,?r"))
14100            (match_operand:SF 2 "register_operand" "0,0")]))]
14101   "TARGET_80387 && TARGET_USE_FIOP && !TARGET_SSE_MATH"
14102   "* return which_alternative ? \"#\" : output_387_binary_op (insn, operands);"
14103   [(set (attr "type") 
14104         (cond [(match_operand:SF 3 "mult_operator" "") 
14105                  (const_string "fmul")
14106                (match_operand:SF 3 "div_operator" "") 
14107                  (const_string "fdiv")
14108               ]
14109               (const_string "fop")))
14110    (set_attr "fp_int_src" "true")
14111    (set_attr "ppro_uops" "many")
14112    (set_attr "mode" "SI")])
14114 (define_insn "*fop_sf_3"
14115   [(set (match_operand:SF 0 "register_operand" "=f,f")
14116         (match_operator:SF 3 "binary_fp_operator"
14117           [(match_operand:SF 1 "register_operand" "0,0")
14118            (float:SF (match_operand:SI 2 "nonimmediate_operand" "m,?r"))]))]
14119   "TARGET_80387 && TARGET_USE_FIOP && !TARGET_SSE_MATH"
14120   "* return which_alternative ? \"#\" : output_387_binary_op (insn, operands);"
14121   [(set (attr "type") 
14122         (cond [(match_operand:SF 3 "mult_operator" "") 
14123                  (const_string "fmul")
14124                (match_operand:SF 3 "div_operator" "") 
14125                  (const_string "fdiv")
14126               ]
14127               (const_string "fop")))
14128    (set_attr "fp_int_src" "true")
14129    (set_attr "ppro_uops" "many")
14130    (set_attr "mode" "SI")])
14132 (define_insn "*fop_df_1_nosse"
14133   [(set (match_operand:DF 0 "register_operand" "=f,f")
14134         (match_operator:DF 3 "binary_fp_operator"
14135                         [(match_operand:DF 1 "nonimmediate_operand" "0,fm")
14136                          (match_operand:DF 2 "nonimmediate_operand" "fm,0")]))]
14137   "TARGET_80387 && (!TARGET_SSE2 || !TARGET_SSE_MATH)
14138    && GET_RTX_CLASS (GET_CODE (operands[3])) != 'c'
14139    && (GET_CODE (operands[1]) != MEM || GET_CODE (operands[2]) != MEM)"
14140   "* return output_387_binary_op (insn, operands);"
14141   [(set (attr "type") 
14142         (cond [(match_operand:DF 3 "mult_operator" "") 
14143                  (const_string "fmul")
14144                (match_operand:DF 3 "div_operator" "")
14145                  (const_string "fdiv")
14146               ]
14147               (const_string "fop")))
14148    (set_attr "mode" "DF")])
14151 (define_insn "*fop_df_1"
14152   [(set (match_operand:DF 0 "register_operand" "=f#Y,f#Y,Y#f")
14153         (match_operator:DF 3 "binary_fp_operator"
14154                         [(match_operand:DF 1 "nonimmediate_operand" "0,fm,0")
14155                          (match_operand:DF 2 "nonimmediate_operand" "fm,0,Ym#f")]))]
14156   "TARGET_80387 && TARGET_SSE2 && TARGET_SSE_MATH && TARGET_MIX_SSE_I387
14157    && GET_RTX_CLASS (GET_CODE (operands[3])) != 'c'
14158    && (GET_CODE (operands[1]) != MEM || GET_CODE (operands[2]) != MEM)"
14159   "* return output_387_binary_op (insn, operands);"
14160   [(set (attr "type") 
14161         (cond [(and (eq_attr "alternative" "2")
14162                     (match_operand:SF 3 "mult_operator" ""))
14163                  (const_string "ssemul")
14164                (and (eq_attr "alternative" "2")
14165                     (match_operand:SF 3 "div_operator" ""))
14166                  (const_string "ssediv")
14167                (eq_attr "alternative" "2")
14168                  (const_string "sseadd")
14169                (match_operand:DF 3 "mult_operator" "") 
14170                  (const_string "fmul")
14171                (match_operand:DF 3 "div_operator" "") 
14172                  (const_string "fdiv")
14173               ]
14174               (const_string "fop")))
14175    (set_attr "mode" "DF")])
14177 (define_insn "*fop_df_1_sse"
14178   [(set (match_operand:DF 0 "register_operand" "=Y")
14179         (match_operator:DF 3 "binary_fp_operator"
14180                         [(match_operand:DF 1 "register_operand" "0")
14181                          (match_operand:DF 2 "nonimmediate_operand" "Ym")]))]
14182   "TARGET_SSE2 && TARGET_SSE_MATH
14183    && GET_RTX_CLASS (GET_CODE (operands[3])) != 'c'"
14184   "* return output_387_binary_op (insn, operands);"
14185   [(set_attr "mode" "DF")
14186    (set (attr "type") 
14187         (cond [(match_operand:SF 3 "mult_operator" "")
14188                  (const_string "ssemul")
14189                (match_operand:SF 3 "div_operator" "")
14190                  (const_string "ssediv")
14191               ]
14192               (const_string "sseadd")))])
14194 ;; ??? Add SSE splitters for these!
14195 (define_insn "*fop_df_2"
14196   [(set (match_operand:DF 0 "register_operand" "=f,f")
14197         (match_operator:DF 3 "binary_fp_operator"
14198            [(float:DF (match_operand:SI 1 "nonimmediate_operand" "m,?r"))
14199             (match_operand:DF 2 "register_operand" "0,0")]))]
14200   "TARGET_80387 && TARGET_USE_FIOP && !(TARGET_SSE2 && TARGET_SSE_MATH)"
14201   "* return which_alternative ? \"#\" : output_387_binary_op (insn, operands);"
14202   [(set (attr "type") 
14203         (cond [(match_operand:DF 3 "mult_operator" "") 
14204                  (const_string "fmul")
14205                (match_operand:DF 3 "div_operator" "") 
14206                  (const_string "fdiv")
14207               ]
14208               (const_string "fop")))
14209    (set_attr "fp_int_src" "true")
14210    (set_attr "ppro_uops" "many")
14211    (set_attr "mode" "SI")])
14213 (define_insn "*fop_df_3"
14214   [(set (match_operand:DF 0 "register_operand" "=f,f")
14215         (match_operator:DF 3 "binary_fp_operator"
14216            [(match_operand:DF 1 "register_operand" "0,0")
14217             (float:DF (match_operand:SI 2 "nonimmediate_operand" "m,?r"))]))]
14218   "TARGET_80387 && TARGET_USE_FIOP && !(TARGET_SSE2 && TARGET_SSE_MATH)"
14219   "* return which_alternative ? \"#\" : output_387_binary_op (insn, operands);"
14220   [(set (attr "type") 
14221         (cond [(match_operand:DF 3 "mult_operator" "") 
14222                  (const_string "fmul")
14223                (match_operand:DF 3 "div_operator" "") 
14224                  (const_string "fdiv")
14225               ]
14226               (const_string "fop")))
14227    (set_attr "fp_int_src" "true")
14228    (set_attr "ppro_uops" "many")
14229    (set_attr "mode" "SI")])
14231 (define_insn "*fop_df_4"
14232   [(set (match_operand:DF 0 "register_operand" "=f,f")
14233         (match_operator:DF 3 "binary_fp_operator"
14234            [(float_extend:DF (match_operand:SF 1 "nonimmediate_operand" "fm,0"))
14235             (match_operand:DF 2 "register_operand" "0,f")]))]
14236   "TARGET_80387 && (!TARGET_SSE2 || !TARGET_SSE_MATH)
14237    && (GET_CODE (operands[1]) != MEM || GET_CODE (operands[2]) != MEM)"
14238   "* return output_387_binary_op (insn, operands);"
14239   [(set (attr "type") 
14240         (cond [(match_operand:DF 3 "mult_operator" "") 
14241                  (const_string "fmul")
14242                (match_operand:DF 3 "div_operator" "") 
14243                  (const_string "fdiv")
14244               ]
14245               (const_string "fop")))
14246    (set_attr "mode" "SF")])
14248 (define_insn "*fop_df_5"
14249   [(set (match_operand:DF 0 "register_operand" "=f,f")
14250         (match_operator:DF 3 "binary_fp_operator"
14251           [(match_operand:DF 1 "register_operand" "0,f")
14252            (float_extend:DF
14253             (match_operand:SF 2 "nonimmediate_operand" "fm,0"))]))]
14254   "TARGET_80387 && !(TARGET_SSE2 && TARGET_SSE_MATH)"
14255   "* return output_387_binary_op (insn, operands);"
14256   [(set (attr "type") 
14257         (cond [(match_operand:DF 3 "mult_operator" "") 
14258                  (const_string "fmul")
14259                (match_operand:DF 3 "div_operator" "") 
14260                  (const_string "fdiv")
14261               ]
14262               (const_string "fop")))
14263    (set_attr "mode" "SF")])
14265 (define_insn "*fop_xf_1"
14266   [(set (match_operand:XF 0 "register_operand" "=f,f")
14267         (match_operator:XF 3 "binary_fp_operator"
14268                         [(match_operand:XF 1 "register_operand" "0,f")
14269                          (match_operand:XF 2 "register_operand" "f,0")]))]
14270   "!TARGET_64BIT && TARGET_80387
14271    && GET_RTX_CLASS (GET_CODE (operands[3])) != 'c'"
14272   "* return output_387_binary_op (insn, operands);"
14273   [(set (attr "type") 
14274         (cond [(match_operand:XF 3 "mult_operator" "") 
14275                  (const_string "fmul")
14276                (match_operand:XF 3 "div_operator" "") 
14277                  (const_string "fdiv")
14278               ]
14279               (const_string "fop")))
14280    (set_attr "mode" "XF")])
14282 (define_insn "*fop_tf_1"
14283   [(set (match_operand:TF 0 "register_operand" "=f,f")
14284         (match_operator:TF 3 "binary_fp_operator"
14285                         [(match_operand:TF 1 "register_operand" "0,f")
14286                          (match_operand:TF 2 "register_operand" "f,0")]))]
14287   "TARGET_80387
14288    && GET_RTX_CLASS (GET_CODE (operands[3])) != 'c'"
14289   "* return output_387_binary_op (insn, operands);"
14290   [(set (attr "type") 
14291         (cond [(match_operand:TF 3 "mult_operator" "") 
14292                  (const_string "fmul")
14293                (match_operand:TF 3 "div_operator" "") 
14294                  (const_string "fdiv")
14295               ]
14296               (const_string "fop")))
14297    (set_attr "mode" "XF")])
14299 (define_insn "*fop_xf_2"
14300   [(set (match_operand:XF 0 "register_operand" "=f,f")
14301         (match_operator:XF 3 "binary_fp_operator"
14302            [(float:XF (match_operand:SI 1 "nonimmediate_operand" "m,?r"))
14303             (match_operand:XF 2 "register_operand" "0,0")]))]
14304   "!TARGET_64BIT && TARGET_80387 && TARGET_USE_FIOP"
14305   "* return which_alternative ? \"#\" : output_387_binary_op (insn, operands);"
14306   [(set (attr "type") 
14307         (cond [(match_operand:XF 3 "mult_operator" "") 
14308                  (const_string "fmul")
14309                (match_operand:XF 3 "div_operator" "") 
14310                  (const_string "fdiv")
14311               ]
14312               (const_string "fop")))
14313    (set_attr "fp_int_src" "true")
14314    (set_attr "mode" "SI")
14315    (set_attr "ppro_uops" "many")])
14317 (define_insn "*fop_tf_2"
14318   [(set (match_operand:TF 0 "register_operand" "=f,f")
14319         (match_operator:TF 3 "binary_fp_operator"
14320            [(float:TF (match_operand:SI 1 "nonimmediate_operand" "m,?r"))
14321             (match_operand:TF 2 "register_operand" "0,0")]))]
14322   "TARGET_80387 && TARGET_USE_FIOP"
14323   "* return which_alternative ? \"#\" : output_387_binary_op (insn, operands);"
14324   [(set (attr "type") 
14325         (cond [(match_operand:TF 3 "mult_operator" "") 
14326                  (const_string "fmul")
14327                (match_operand:TF 3 "div_operator" "") 
14328                  (const_string "fdiv")
14329               ]
14330               (const_string "fop")))
14331    (set_attr "fp_int_src" "true")
14332    (set_attr "mode" "SI")
14333    (set_attr "ppro_uops" "many")])
14335 (define_insn "*fop_xf_3"
14336   [(set (match_operand:XF 0 "register_operand" "=f,f")
14337         (match_operator:XF 3 "binary_fp_operator"
14338           [(match_operand:XF 1 "register_operand" "0,0")
14339            (float:XF (match_operand:SI 2 "nonimmediate_operand" "m,?r"))]))]
14340   "!TARGET_64BIT && TARGET_80387 && TARGET_USE_FIOP"
14341   "* return which_alternative ? \"#\" : output_387_binary_op (insn, operands);"
14342   [(set (attr "type") 
14343         (cond [(match_operand:XF 3 "mult_operator" "") 
14344                  (const_string "fmul")
14345                (match_operand:XF 3 "div_operator" "") 
14346                  (const_string "fdiv")
14347               ]
14348               (const_string "fop")))
14349    (set_attr "fp_int_src" "true")
14350    (set_attr "mode" "SI")
14351    (set_attr "ppro_uops" "many")])
14353 (define_insn "*fop_tf_3"
14354   [(set (match_operand:TF 0 "register_operand" "=f,f")
14355         (match_operator:TF 3 "binary_fp_operator"
14356           [(match_operand:TF 1 "register_operand" "0,0")
14357            (float:TF (match_operand:SI 2 "nonimmediate_operand" "m,?r"))]))]
14358   "TARGET_80387 && TARGET_USE_FIOP"
14359   "* return which_alternative ? \"#\" : output_387_binary_op (insn, operands);"
14360   [(set (attr "type") 
14361         (cond [(match_operand:TF 3 "mult_operator" "") 
14362                  (const_string "fmul")
14363                (match_operand:TF 3 "div_operator" "") 
14364                  (const_string "fdiv")
14365               ]
14366               (const_string "fop")))
14367    (set_attr "fp_int_src" "true")
14368    (set_attr "mode" "SI")
14369    (set_attr "ppro_uops" "many")])
14371 (define_insn "*fop_xf_4"
14372   [(set (match_operand:XF 0 "register_operand" "=f,f")
14373         (match_operator:XF 3 "binary_fp_operator"
14374            [(float_extend:XF (match_operand:SF 1 "nonimmediate_operand" "fm,0"))
14375             (match_operand:XF 2 "register_operand" "0,f")]))]
14376   "!TARGET_64BIT && TARGET_80387"
14377   "* return output_387_binary_op (insn, operands);"
14378   [(set (attr "type") 
14379         (cond [(match_operand:XF 3 "mult_operator" "") 
14380                  (const_string "fmul")
14381                (match_operand:XF 3 "div_operator" "") 
14382                  (const_string "fdiv")
14383               ]
14384               (const_string "fop")))
14385    (set_attr "mode" "SF")])
14387 (define_insn "*fop_tf_4"
14388   [(set (match_operand:TF 0 "register_operand" "=f,f")
14389         (match_operator:TF 3 "binary_fp_operator"
14390            [(float_extend:TF (match_operand:SF 1 "nonimmediate_operand" "fm,0"))
14391             (match_operand:TF 2 "register_operand" "0,f")]))]
14392   "TARGET_80387"
14393   "* return output_387_binary_op (insn, operands);"
14394   [(set (attr "type") 
14395         (cond [(match_operand:TF 3 "mult_operator" "") 
14396                  (const_string "fmul")
14397                (match_operand:TF 3 "div_operator" "") 
14398                  (const_string "fdiv")
14399               ]
14400               (const_string "fop")))
14401    (set_attr "mode" "SF")])
14403 (define_insn "*fop_xf_5"
14404   [(set (match_operand:XF 0 "register_operand" "=f,f")
14405         (match_operator:XF 3 "binary_fp_operator"
14406           [(match_operand:XF 1 "register_operand" "0,f")
14407            (float_extend:XF
14408             (match_operand:SF 2 "nonimmediate_operand" "fm,0"))]))]
14409   "!TARGET_64BIT && TARGET_80387"
14410   "* return output_387_binary_op (insn, operands);"
14411   [(set (attr "type") 
14412         (cond [(match_operand:XF 3 "mult_operator" "") 
14413                  (const_string "fmul")
14414                (match_operand:XF 3 "div_operator" "") 
14415                  (const_string "fdiv")
14416               ]
14417               (const_string "fop")))
14418    (set_attr "mode" "SF")])
14420 (define_insn "*fop_tf_5"
14421   [(set (match_operand:TF 0 "register_operand" "=f,f")
14422         (match_operator:TF 3 "binary_fp_operator"
14423           [(match_operand:TF 1 "register_operand" "0,f")
14424            (float_extend:TF
14425             (match_operand:SF 2 "nonimmediate_operand" "fm,0"))]))]
14426   "TARGET_80387"
14427   "* return output_387_binary_op (insn, operands);"
14428   [(set (attr "type") 
14429         (cond [(match_operand:TF 3 "mult_operator" "") 
14430                  (const_string "fmul")
14431                (match_operand:TF 3 "div_operator" "") 
14432                  (const_string "fdiv")
14433               ]
14434               (const_string "fop")))
14435    (set_attr "mode" "SF")])
14437 (define_insn "*fop_xf_6"
14438   [(set (match_operand:XF 0 "register_operand" "=f,f")
14439         (match_operator:XF 3 "binary_fp_operator"
14440            [(float_extend:XF (match_operand:DF 1 "nonimmediate_operand" "fm,0"))
14441             (match_operand:XF 2 "register_operand" "0,f")]))]
14442   "!TARGET_64BIT && TARGET_80387"
14443   "* return output_387_binary_op (insn, operands);"
14444   [(set (attr "type") 
14445         (cond [(match_operand:XF 3 "mult_operator" "") 
14446                  (const_string "fmul")
14447                (match_operand:XF 3 "div_operator" "") 
14448                  (const_string "fdiv")
14449               ]
14450               (const_string "fop")))
14451    (set_attr "mode" "DF")])
14453 (define_insn "*fop_tf_6"
14454   [(set (match_operand:TF 0 "register_operand" "=f,f")
14455         (match_operator:TF 3 "binary_fp_operator"
14456            [(float_extend:TF (match_operand:DF 1 "nonimmediate_operand" "fm,0"))
14457             (match_operand:TF 2 "register_operand" "0,f")]))]
14458   "TARGET_80387"
14459   "* return output_387_binary_op (insn, operands);"
14460   [(set (attr "type") 
14461         (cond [(match_operand:TF 3 "mult_operator" "") 
14462                  (const_string "fmul")
14463                (match_operand:TF 3 "div_operator" "") 
14464                  (const_string "fdiv")
14465               ]
14466               (const_string "fop")))
14467    (set_attr "mode" "DF")])
14469 (define_insn "*fop_xf_7"
14470   [(set (match_operand:XF 0 "register_operand" "=f,f")
14471         (match_operator:XF 3 "binary_fp_operator"
14472           [(match_operand:XF 1 "register_operand" "0,f")
14473            (float_extend:XF
14474             (match_operand:DF 2 "nonimmediate_operand" "fm,0"))]))]
14475   "!TARGET_64BIT && TARGET_80387"
14476   "* return output_387_binary_op (insn, operands);"
14477   [(set (attr "type") 
14478         (cond [(match_operand:XF 3 "mult_operator" "") 
14479                  (const_string "fmul")
14480                (match_operand:XF 3 "div_operator" "") 
14481                  (const_string "fdiv")
14482               ]
14483               (const_string "fop")))
14484    (set_attr "mode" "DF")])
14486 (define_insn "*fop_tf_7"
14487   [(set (match_operand:TF 0 "register_operand" "=f,f")
14488         (match_operator:TF 3 "binary_fp_operator"
14489           [(match_operand:TF 1 "register_operand" "0,f")
14490            (float_extend:TF
14491             (match_operand:DF 2 "nonimmediate_operand" "fm,0"))]))]
14492   "TARGET_80387"
14493   "* return output_387_binary_op (insn, operands);"
14494   [(set (attr "type") 
14495         (cond [(match_operand:TF 3 "mult_operator" "") 
14496                  (const_string "fmul")
14497                (match_operand:TF 3 "div_operator" "") 
14498                  (const_string "fdiv")
14499               ]
14500               (const_string "fop")))
14501    (set_attr "mode" "DF")])
14503 (define_split
14504   [(set (match_operand 0 "register_operand" "")
14505         (match_operator 3 "binary_fp_operator"
14506            [(float (match_operand:SI 1 "register_operand" ""))
14507             (match_operand 2 "register_operand" "")]))]
14508   "TARGET_80387 && reload_completed
14509    && FLOAT_MODE_P (GET_MODE (operands[0]))"
14510   [(const_int 0)]
14512   operands[4] = ix86_force_to_memory (GET_MODE (operands[1]), operands[1]);
14513   operands[4] = gen_rtx_FLOAT (GET_MODE (operands[0]), operands[4]);
14514   emit_insn (gen_rtx_SET (VOIDmode, operands[0],
14515                           gen_rtx_fmt_ee (GET_CODE (operands[3]),
14516                                           GET_MODE (operands[3]),
14517                                           operands[4],
14518                                           operands[2])));
14519   ix86_free_from_memory (GET_MODE (operands[1]));
14520   DONE;
14523 (define_split
14524   [(set (match_operand 0 "register_operand" "")
14525         (match_operator 3 "binary_fp_operator"
14526            [(match_operand 1 "register_operand" "")
14527             (float (match_operand:SI 2 "register_operand" ""))]))]
14528   "TARGET_80387 && reload_completed
14529    && FLOAT_MODE_P (GET_MODE (operands[0]))"
14530   [(const_int 0)]
14532   operands[4] = ix86_force_to_memory (GET_MODE (operands[2]), operands[2]);
14533   operands[4] = gen_rtx_FLOAT (GET_MODE (operands[0]), operands[4]);
14534   emit_insn (gen_rtx_SET (VOIDmode, operands[0],
14535                           gen_rtx_fmt_ee (GET_CODE (operands[3]),
14536                                           GET_MODE (operands[3]),
14537                                           operands[1],
14538                                           operands[4])));
14539   ix86_free_from_memory (GET_MODE (operands[2]));
14540   DONE;
14543 ;; FPU special functions.
14545 (define_expand "sqrtsf2"
14546   [(set (match_operand:SF 0 "register_operand" "")
14547         (sqrt:SF (match_operand:SF 1 "nonimmediate_operand" "")))]
14548   "(! TARGET_NO_FANCY_MATH_387 && TARGET_80387) || TARGET_SSE_MATH"
14550   if (!TARGET_SSE_MATH)
14551     operands[1] = force_reg (SFmode, operands[1]);
14554 (define_insn "sqrtsf2_1"
14555   [(set (match_operand:SF 0 "register_operand" "=f#x,x#f")
14556         (sqrt:SF (match_operand:SF 1 "nonimmediate_operand" "0#x,xm#f")))]
14557   "! TARGET_NO_FANCY_MATH_387 && TARGET_80387
14558    && (TARGET_SSE_MATH && TARGET_MIX_SSE_I387)"
14559   "@
14560    fsqrt
14561    sqrtss\t{%1, %0|%0, %1}"
14562   [(set_attr "type" "fpspc,sse")
14563    (set_attr "mode" "SF,SF")
14564    (set_attr "athlon_decode" "direct,*")])
14566 (define_insn "sqrtsf2_1_sse_only"
14567   [(set (match_operand:SF 0 "register_operand" "=x")
14568         (sqrt:SF (match_operand:SF 1 "nonimmediate_operand" "xm")))]
14569   "TARGET_SSE_MATH && (!TARGET_80387 || !TARGET_MIX_SSE_I387)"
14570   "sqrtss\t{%1, %0|%0, %1}"
14571   [(set_attr "type" "sse")
14572    (set_attr "mode" "SF")
14573    (set_attr "athlon_decode" "*")])
14575 (define_insn "sqrtsf2_i387"
14576   [(set (match_operand:SF 0 "register_operand" "=f")
14577         (sqrt:SF (match_operand:SF 1 "register_operand" "0")))]
14578   "! TARGET_NO_FANCY_MATH_387 && TARGET_80387
14579    && !TARGET_SSE_MATH"
14580   "fsqrt"
14581   [(set_attr "type" "fpspc")
14582    (set_attr "mode" "SF")
14583    (set_attr "athlon_decode" "direct")])
14585 (define_expand "sqrtdf2"
14586   [(set (match_operand:DF 0 "register_operand" "")
14587         (sqrt:DF (match_operand:DF 1 "nonimmediate_operand" "")))]
14588   "(! TARGET_NO_FANCY_MATH_387 && TARGET_80387)
14589    || (TARGET_SSE2 && TARGET_SSE_MATH)"
14591   if (!TARGET_SSE2 || !TARGET_SSE_MATH)
14592     operands[1] = force_reg (DFmode, operands[1]);
14595 (define_insn "sqrtdf2_1"
14596   [(set (match_operand:DF 0 "register_operand" "=f#Y,Y#f")
14597         (sqrt:DF (match_operand:DF 1 "nonimmediate_operand" "0#Y,Ym#f")))]
14598   "! TARGET_NO_FANCY_MATH_387 && TARGET_80387
14599    && (TARGET_SSE2 && TARGET_SSE_MATH && TARGET_MIX_SSE_I387)"
14600   "@
14601    fsqrt
14602    sqrtsd\t{%1, %0|%0, %1}"
14603   [(set_attr "type" "fpspc,sse")
14604    (set_attr "mode" "DF,DF")
14605    (set_attr "athlon_decode" "direct,*")])
14607 (define_insn "sqrtdf2_1_sse_only"
14608   [(set (match_operand:DF 0 "register_operand" "=Y")
14609         (sqrt:DF (match_operand:DF 1 "nonimmediate_operand" "Ym")))]
14610   "TARGET_SSE2 && TARGET_SSE_MATH && (!TARGET_80387 || !TARGET_MIX_SSE_I387)"
14611   "sqrtsd\t{%1, %0|%0, %1}"
14612   [(set_attr "type" "sse")
14613    (set_attr "mode" "DF")
14614    (set_attr "athlon_decode" "*")])
14616 (define_insn "sqrtdf2_i387"
14617   [(set (match_operand:DF 0 "register_operand" "=f")
14618         (sqrt:DF (match_operand:DF 1 "register_operand" "0")))]
14619   "! TARGET_NO_FANCY_MATH_387 && TARGET_80387
14620    && (!TARGET_SSE2 || !TARGET_SSE_MATH)"
14621   "fsqrt"
14622   [(set_attr "type" "fpspc")
14623    (set_attr "mode" "DF")
14624    (set_attr "athlon_decode" "direct")])
14626 (define_insn "*sqrtextendsfdf2"
14627   [(set (match_operand:DF 0 "register_operand" "=f")
14628         (sqrt:DF (float_extend:DF
14629                   (match_operand:SF 1 "register_operand" "0"))))]
14630   "! TARGET_NO_FANCY_MATH_387 && TARGET_80387
14631    && !(TARGET_SSE2 && TARGET_SSE_MATH)"
14632   "fsqrt"
14633   [(set_attr "type" "fpspc")
14634    (set_attr "mode" "DF")
14635    (set_attr "athlon_decode" "direct")])
14637 (define_insn "sqrtxf2"
14638   [(set (match_operand:XF 0 "register_operand" "=f")
14639         (sqrt:XF (match_operand:XF 1 "register_operand" "0")))]
14640   "!TARGET_64BIT && TARGET_80387 && !TARGET_NO_FANCY_MATH_387 
14641    && (TARGET_IEEE_FP || flag_unsafe_math_optimizations) "
14642   "fsqrt"
14643   [(set_attr "type" "fpspc")
14644    (set_attr "mode" "XF")
14645    (set_attr "athlon_decode" "direct")])
14647 (define_insn "sqrttf2"
14648   [(set (match_operand:TF 0 "register_operand" "=f")
14649         (sqrt:TF (match_operand:TF 1 "register_operand" "0")))]
14650   "! TARGET_NO_FANCY_MATH_387 && TARGET_80387 
14651    && (TARGET_IEEE_FP || flag_unsafe_math_optimizations) "
14652   "fsqrt"
14653   [(set_attr "type" "fpspc")
14654    (set_attr "mode" "XF")
14655    (set_attr "athlon_decode" "direct")])
14657 (define_insn "*sqrtextenddfxf2"
14658   [(set (match_operand:XF 0 "register_operand" "=f")
14659         (sqrt:XF (float_extend:XF
14660                   (match_operand:DF 1 "register_operand" "0"))))]
14661   "!TARGET_64BIT && TARGET_80387 && !TARGET_NO_FANCY_MATH_387"
14662   "fsqrt"
14663   [(set_attr "type" "fpspc")
14664    (set_attr "mode" "XF")
14665    (set_attr "athlon_decode" "direct")])
14667 (define_insn "*sqrtextenddftf2"
14668   [(set (match_operand:TF 0 "register_operand" "=f")
14669         (sqrt:TF (float_extend:TF
14670                   (match_operand:DF 1 "register_operand" "0"))))]
14671   "! TARGET_NO_FANCY_MATH_387 && TARGET_80387"
14672   "fsqrt"
14673   [(set_attr "type" "fpspc")
14674    (set_attr "mode" "XF")
14675    (set_attr "athlon_decode" "direct")])
14677 (define_insn "*sqrtextendsfxf2"
14678   [(set (match_operand:XF 0 "register_operand" "=f")
14679         (sqrt:XF (float_extend:XF
14680                   (match_operand:SF 1 "register_operand" "0"))))]
14681   "!TARGET_64BIT && TARGET_80387 && !TARGET_NO_FANCY_MATH_387"
14682   "fsqrt"
14683   [(set_attr "type" "fpspc")
14684    (set_attr "mode" "XF")
14685    (set_attr "athlon_decode" "direct")])
14687 (define_insn "*sqrtextendsftf2"
14688   [(set (match_operand:TF 0 "register_operand" "=f")
14689         (sqrt:TF (float_extend:TF
14690                   (match_operand:SF 1 "register_operand" "0"))))]
14691   "! TARGET_NO_FANCY_MATH_387 && TARGET_80387"
14692   "fsqrt"
14693   [(set_attr "type" "fpspc")
14694    (set_attr "mode" "XF")
14695    (set_attr "athlon_decode" "direct")])
14697 (define_insn "sindf2"
14698   [(set (match_operand:DF 0 "register_operand" "=f")
14699         (unspec:DF [(match_operand:DF 1 "register_operand" "0")] UNSPEC_SIN))]
14700   "! TARGET_NO_FANCY_MATH_387 && TARGET_80387 
14701    && flag_unsafe_math_optimizations"
14702   "fsin"
14703   [(set_attr "type" "fpspc")
14704    (set_attr "mode" "DF")])
14706 (define_insn "sinsf2"
14707   [(set (match_operand:SF 0 "register_operand" "=f")
14708         (unspec:SF [(match_operand:SF 1 "register_operand" "0")] UNSPEC_SIN))]
14709   "! TARGET_NO_FANCY_MATH_387 && TARGET_80387 
14710    && flag_unsafe_math_optimizations"
14711   "fsin"
14712   [(set_attr "type" "fpspc")
14713    (set_attr "mode" "SF")])
14715 (define_insn "*sinextendsfdf2"
14716   [(set (match_operand:DF 0 "register_operand" "=f")
14717         (unspec:DF [(float_extend:DF
14718                      (match_operand:SF 1 "register_operand" "0"))]
14719                    UNSPEC_SIN))]
14720   "! TARGET_NO_FANCY_MATH_387 && TARGET_80387 
14721    && flag_unsafe_math_optimizations"
14722   "fsin"
14723   [(set_attr "type" "fpspc")
14724    (set_attr "mode" "DF")])
14726 (define_insn "sinxf2"
14727   [(set (match_operand:XF 0 "register_operand" "=f")
14728         (unspec:XF [(match_operand:XF 1 "register_operand" "0")] UNSPEC_SIN))]
14729   "!TARGET_64BIT && TARGET_80387 && !TARGET_NO_FANCY_MATH_387
14730    && flag_unsafe_math_optimizations"
14731   "fsin"
14732   [(set_attr "type" "fpspc")
14733    (set_attr "mode" "XF")])
14735 (define_insn "sintf2"
14736   [(set (match_operand:TF 0 "register_operand" "=f")
14737         (unspec:TF [(match_operand:TF 1 "register_operand" "0")] UNSPEC_SIN))]
14738   "! TARGET_NO_FANCY_MATH_387 && TARGET_80387 
14739    && flag_unsafe_math_optimizations"
14740   "fsin"
14741   [(set_attr "type" "fpspc")
14742    (set_attr "mode" "XF")])
14744 (define_insn "cosdf2"
14745   [(set (match_operand:DF 0 "register_operand" "=f")
14746         (unspec:DF [(match_operand:DF 1 "register_operand" "0")] UNSPEC_COS))]
14747   "! TARGET_NO_FANCY_MATH_387 && TARGET_80387 
14748    && flag_unsafe_math_optimizations"
14749   "fcos"
14750   [(set_attr "type" "fpspc")
14751    (set_attr "mode" "DF")])
14753 (define_insn "cossf2"
14754   [(set (match_operand:SF 0 "register_operand" "=f")
14755         (unspec:SF [(match_operand:SF 1 "register_operand" "0")] UNSPEC_COS))]
14756   "! TARGET_NO_FANCY_MATH_387 && TARGET_80387 
14757    && flag_unsafe_math_optimizations"
14758   "fcos"
14759   [(set_attr "type" "fpspc")
14760    (set_attr "mode" "SF")])
14762 (define_insn "*cosextendsfdf2"
14763   [(set (match_operand:DF 0 "register_operand" "=f")
14764         (unspec:DF [(float_extend:DF
14765                      (match_operand:SF 1 "register_operand" "0"))]
14766                    UNSPEC_COS))]
14767   "! TARGET_NO_FANCY_MATH_387 && TARGET_80387 
14768    && flag_unsafe_math_optimizations"
14769   "fcos"
14770   [(set_attr "type" "fpspc")
14771    (set_attr "mode" "DF")])
14773 (define_insn "cosxf2"
14774   [(set (match_operand:XF 0 "register_operand" "=f")
14775         (unspec:XF [(match_operand:XF 1 "register_operand" "0")] UNSPEC_COS))]
14776   "! TARGET_NO_FANCY_MATH_387 && TARGET_80387
14777    && flag_unsafe_math_optimizations"
14778   "fcos"
14779   [(set_attr "type" "fpspc")
14780    (set_attr "mode" "XF")])
14782 (define_insn "costf2"
14783   [(set (match_operand:TF 0 "register_operand" "=f")
14784         (unspec:TF [(match_operand:TF 1 "register_operand" "0")] UNSPEC_COS))]
14785   "! TARGET_NO_FANCY_MATH_387 && TARGET_80387 
14786    && flag_unsafe_math_optimizations"
14787   "fcos"
14788   [(set_attr "type" "fpspc")
14789    (set_attr "mode" "XF")])
14791 ;; Block operation instructions
14793 (define_insn "cld"
14794  [(set (reg:SI 19) (const_int 0))]
14795  ""
14796  "cld"
14797   [(set_attr "type" "cld")])
14799 (define_expand "movstrsi"
14800   [(use (match_operand:BLK 0 "memory_operand" ""))
14801    (use (match_operand:BLK 1 "memory_operand" ""))
14802    (use (match_operand:SI 2 "nonmemory_operand" ""))
14803    (use (match_operand:SI 3 "const_int_operand" ""))]
14804   ""
14806  if (ix86_expand_movstr (operands[0], operands[1], operands[2], operands[3]))
14807    DONE;
14808  else
14809    FAIL;
14812 (define_expand "movstrdi"
14813   [(use (match_operand:BLK 0 "memory_operand" ""))
14814    (use (match_operand:BLK 1 "memory_operand" ""))
14815    (use (match_operand:DI 2 "nonmemory_operand" ""))
14816    (use (match_operand:DI 3 "const_int_operand" ""))]
14817   "TARGET_64BIT"
14819  if (ix86_expand_movstr (operands[0], operands[1], operands[2], operands[3]))
14820    DONE;
14821  else
14822    FAIL;
14825 ;; Most CPUs don't like single string operations
14826 ;; Handle this case here to simplify previous expander.
14828 (define_expand "strmovdi_rex64"
14829   [(set (match_dup 2)
14830         (mem:DI (match_operand:DI 1 "register_operand" "")))
14831    (set (mem:DI (match_operand:DI 0 "register_operand" ""))
14832         (match_dup 2))
14833    (parallel [(set (match_dup 0) (plus:DI (match_dup 0) (const_int 8)))
14834               (clobber (reg:CC 17))])
14835    (parallel [(set (match_dup 1) (plus:DI (match_dup 1) (const_int 8)))
14836               (clobber (reg:CC 17))])]
14837   "TARGET_64BIT"
14839   if (TARGET_SINGLE_STRINGOP || optimize_size)
14840     {
14841       emit_insn (gen_strmovdi_rex_1 (operands[0], operands[1], operands[0],
14842                                      operands[1]));
14843       DONE;
14844     }
14845   else 
14846     operands[2] = gen_reg_rtx (DImode);
14850 (define_expand "strmovsi"
14851   [(set (match_dup 2)
14852         (mem:SI (match_operand:SI 1 "register_operand" "")))
14853    (set (mem:SI (match_operand:SI 0 "register_operand" ""))
14854         (match_dup 2))
14855    (parallel [(set (match_dup 0) (plus:SI (match_dup 0) (const_int 4)))
14856               (clobber (reg:CC 17))])
14857    (parallel [(set (match_dup 1) (plus:SI (match_dup 1) (const_int 4)))
14858               (clobber (reg:CC 17))])]
14859   ""
14861   if (TARGET_64BIT)
14862     {
14863       emit_insn (gen_strmovsi_rex64 (operands[0], operands[1]));
14864       DONE;
14865     }
14866   if (TARGET_SINGLE_STRINGOP || optimize_size)
14867     {
14868       emit_insn (gen_strmovsi_1 (operands[0], operands[1], operands[0],
14869                                 operands[1]));
14870       DONE;
14871     }
14872   else 
14873     operands[2] = gen_reg_rtx (SImode);
14876 (define_expand "strmovsi_rex64"
14877   [(set (match_dup 2)
14878         (mem:SI (match_operand:DI 1 "register_operand" "")))
14879    (set (mem:SI (match_operand:DI 0 "register_operand" ""))
14880         (match_dup 2))
14881    (parallel [(set (match_dup 0) (plus:DI (match_dup 0) (const_int 4)))
14882               (clobber (reg:CC 17))])
14883    (parallel [(set (match_dup 1) (plus:DI (match_dup 1) (const_int 4)))
14884               (clobber (reg:CC 17))])]
14885   "TARGET_64BIT"
14887   if (TARGET_SINGLE_STRINGOP || optimize_size)
14888     {
14889       emit_insn (gen_strmovsi_rex_1 (operands[0], operands[1], operands[0],
14890                                      operands[1]));
14891       DONE;
14892     }
14893   else 
14894     operands[2] = gen_reg_rtx (SImode);
14897 (define_expand "strmovhi"
14898   [(set (match_dup 2)
14899         (mem:HI (match_operand:SI 1 "register_operand" "")))
14900    (set (mem:HI (match_operand:SI 0 "register_operand" ""))
14901         (match_dup 2))
14902    (parallel [(set (match_dup 0) (plus:SI (match_dup 0) (const_int 2)))
14903               (clobber (reg:CC 17))])
14904    (parallel [(set (match_dup 1) (plus:SI (match_dup 1) (const_int 2)))
14905               (clobber (reg:CC 17))])]
14906   ""
14908   if (TARGET_64BIT)
14909     {
14910       emit_insn (gen_strmovhi_rex64 (operands[0], operands[1]));
14911       DONE;
14912     }
14913   if (TARGET_SINGLE_STRINGOP || optimize_size)
14914     {
14915       emit_insn (gen_strmovhi_1 (operands[0], operands[1], operands[0],
14916                                 operands[1]));
14917       DONE;
14918     }
14919   else 
14920     operands[2] = gen_reg_rtx (HImode);
14923 (define_expand "strmovhi_rex64"
14924   [(set (match_dup 2)
14925         (mem:HI (match_operand:DI 1 "register_operand" "")))
14926    (set (mem:HI (match_operand:DI 0 "register_operand" ""))
14927         (match_dup 2))
14928    (parallel [(set (match_dup 0) (plus:DI (match_dup 0) (const_int 2)))
14929               (clobber (reg:CC 17))])
14930    (parallel [(set (match_dup 1) (plus:DI (match_dup 1) (const_int 2)))
14931               (clobber (reg:CC 17))])]
14932   "TARGET_64BIT"
14934   if (TARGET_SINGLE_STRINGOP || optimize_size)
14935     {
14936       emit_insn (gen_strmovhi_rex_1 (operands[0], operands[1], operands[0],
14937                                      operands[1]));
14938       DONE;
14939     }
14940   else 
14941     operands[2] = gen_reg_rtx (HImode);
14944 (define_expand "strmovqi"
14945   [(set (match_dup 2)
14946         (mem:QI (match_operand:SI 1 "register_operand" "")))
14947    (set (mem:QI (match_operand:SI 0 "register_operand" ""))
14948         (match_dup 2))
14949    (parallel [(set (match_dup 0) (plus:SI (match_dup 0) (const_int 1)))
14950               (clobber (reg:CC 17))])
14951    (parallel [(set (match_dup 1) (plus:SI (match_dup 1) (const_int 1)))
14952               (clobber (reg:CC 17))])]
14953   ""
14955   if (TARGET_64BIT)
14956     {
14957       emit_insn (gen_strmovqi_rex64 (operands[0], operands[1]));
14958       DONE;
14959     }
14960   if (TARGET_SINGLE_STRINGOP || optimize_size)
14961     {
14962       emit_insn (gen_strmovqi_1 (operands[0], operands[1], operands[0],
14963                                 operands[1]));
14964       DONE;
14965     }
14966   else 
14967     operands[2] = gen_reg_rtx (QImode);
14970 (define_expand "strmovqi_rex64"
14971   [(set (match_dup 2)
14972         (mem:QI (match_operand:DI 1 "register_operand" "")))
14973    (set (mem:QI (match_operand:DI 0 "register_operand" ""))
14974         (match_dup 2))
14975    (parallel [(set (match_dup 0) (plus:DI (match_dup 0) (const_int 1)))
14976               (clobber (reg:CC 17))])
14977    (parallel [(set (match_dup 1) (plus:DI (match_dup 1) (const_int 1)))
14978               (clobber (reg:CC 17))])]
14979   "TARGET_64BIT"
14981   if (TARGET_SINGLE_STRINGOP || optimize_size)
14982     {
14983       emit_insn (gen_strmovqi_rex_1 (operands[0], operands[1], operands[0],
14984                                      operands[1]));
14985       DONE;
14986     }
14987   else 
14988     operands[2] = gen_reg_rtx (QImode);
14991 (define_insn "strmovdi_rex_1"
14992   [(set (mem:DI (match_operand:DI 2 "register_operand" "0"))
14993         (mem:DI (match_operand:DI 3 "register_operand" "1")))
14994    (set (match_operand:DI 0 "register_operand" "=D")
14995         (plus:DI (match_dup 2)
14996                  (const_int 8)))
14997    (set (match_operand:DI 1 "register_operand" "=S")
14998         (plus:DI (match_dup 3)
14999                  (const_int 8)))
15000    (use (reg:SI 19))]
15001   "TARGET_64BIT && (TARGET_SINGLE_STRINGOP || optimize_size)"
15002   "movsq"
15003   [(set_attr "type" "str")
15004    (set_attr "mode" "DI")
15005    (set_attr "memory" "both")])
15007 (define_insn "strmovsi_1"
15008   [(set (mem:SI (match_operand:SI 2 "register_operand" "0"))
15009         (mem:SI (match_operand:SI 3 "register_operand" "1")))
15010    (set (match_operand:SI 0 "register_operand" "=D")
15011         (plus:SI (match_dup 2)
15012                  (const_int 4)))
15013    (set (match_operand:SI 1 "register_operand" "=S")
15014         (plus:SI (match_dup 3)
15015                  (const_int 4)))
15016    (use (reg:SI 19))]
15017   "!TARGET_64BIT && (TARGET_SINGLE_STRINGOP || optimize_size)"
15018   "{movsl|movsd}"
15019   [(set_attr "type" "str")
15020    (set_attr "mode" "SI")
15021    (set_attr "memory" "both")])
15023 (define_insn "strmovsi_rex_1"
15024   [(set (mem:SI (match_operand:DI 2 "register_operand" "0"))
15025         (mem:SI (match_operand:DI 3 "register_operand" "1")))
15026    (set (match_operand:DI 0 "register_operand" "=D")
15027         (plus:DI (match_dup 2)
15028                  (const_int 4)))
15029    (set (match_operand:DI 1 "register_operand" "=S")
15030         (plus:DI (match_dup 3)
15031                  (const_int 4)))
15032    (use (reg:SI 19))]
15033   "TARGET_64BIT && (TARGET_SINGLE_STRINGOP || optimize_size)"
15034   "{movsl|movsd}"
15035   [(set_attr "type" "str")
15036    (set_attr "mode" "SI")
15037    (set_attr "memory" "both")])
15039 (define_insn "strmovhi_1"
15040   [(set (mem:HI (match_operand:SI 2 "register_operand" "0"))
15041         (mem:HI (match_operand:SI 3 "register_operand" "1")))
15042    (set (match_operand:SI 0 "register_operand" "=D")
15043         (plus:SI (match_dup 2)
15044                  (const_int 2)))
15045    (set (match_operand:SI 1 "register_operand" "=S")
15046         (plus:SI (match_dup 3)
15047                  (const_int 2)))
15048    (use (reg:SI 19))]
15049   "!TARGET_64BIT && (TARGET_SINGLE_STRINGOP || optimize_size)"
15050   "movsw"
15051   [(set_attr "type" "str")
15052    (set_attr "memory" "both")
15053    (set_attr "mode" "HI")])
15055 (define_insn "strmovhi_rex_1"
15056   [(set (mem:HI (match_operand:DI 2 "register_operand" "0"))
15057         (mem:HI (match_operand:DI 3 "register_operand" "1")))
15058    (set (match_operand:DI 0 "register_operand" "=D")
15059         (plus:DI (match_dup 2)
15060                  (const_int 2)))
15061    (set (match_operand:DI 1 "register_operand" "=S")
15062         (plus:DI (match_dup 3)
15063                  (const_int 2)))
15064    (use (reg:SI 19))]
15065   "TARGET_64BIT && (TARGET_SINGLE_STRINGOP || optimize_size)"
15066   "movsw"
15067   [(set_attr "type" "str")
15068    (set_attr "memory" "both")
15069    (set_attr "mode" "HI")])
15071 (define_insn "strmovqi_1"
15072   [(set (mem:QI (match_operand:SI 2 "register_operand" "0"))
15073         (mem:QI (match_operand:SI 3 "register_operand" "1")))
15074    (set (match_operand:SI 0 "register_operand" "=D")
15075         (plus:SI (match_dup 2)
15076                  (const_int 1)))
15077    (set (match_operand:SI 1 "register_operand" "=S")
15078         (plus:SI (match_dup 3)
15079                  (const_int 1)))
15080    (use (reg:SI 19))]
15081   "!TARGET_64BIT && (TARGET_SINGLE_STRINGOP || optimize_size)"
15082   "movsb"
15083   [(set_attr "type" "str")
15084    (set_attr "memory" "both")
15085    (set_attr "mode" "QI")])
15087 (define_insn "strmovqi_rex_1"
15088   [(set (mem:QI (match_operand:DI 2 "register_operand" "0"))
15089         (mem:QI (match_operand:DI 3 "register_operand" "1")))
15090    (set (match_operand:DI 0 "register_operand" "=D")
15091         (plus:DI (match_dup 2)
15092                  (const_int 1)))
15093    (set (match_operand:DI 1 "register_operand" "=S")
15094         (plus:DI (match_dup 3)
15095                  (const_int 1)))
15096    (use (reg:SI 19))]
15097   "TARGET_64BIT && (TARGET_SINGLE_STRINGOP || optimize_size)"
15098   "movsb"
15099   [(set_attr "type" "str")
15100    (set_attr "memory" "both")
15101    (set_attr "mode" "QI")])
15103 (define_insn "rep_movdi_rex64"
15104   [(set (match_operand:DI 2 "register_operand" "=c") (const_int 0))
15105    (set (match_operand:DI 0 "register_operand" "=D") 
15106         (plus:DI (ashift:DI (match_operand:DI 5 "register_operand" "2")
15107                             (const_int 3))
15108                  (match_operand:DI 3 "register_operand" "0")))
15109    (set (match_operand:DI 1 "register_operand" "=S") 
15110         (plus:DI (ashift:DI (match_dup 5) (const_int 3))
15111                  (match_operand:DI 4 "register_operand" "1")))
15112    (set (mem:BLK (match_dup 3))
15113         (mem:BLK (match_dup 4)))
15114    (use (match_dup 5))
15115    (use (reg:SI 19))]
15116   "TARGET_64BIT"
15117   "{rep\;movsq|rep movsq}"
15118   [(set_attr "type" "str")
15119    (set_attr "prefix_rep" "1")
15120    (set_attr "memory" "both")
15121    (set_attr "mode" "DI")])
15123 (define_insn "rep_movsi"
15124   [(set (match_operand:SI 2 "register_operand" "=c") (const_int 0))
15125    (set (match_operand:SI 0 "register_operand" "=D") 
15126         (plus:SI (ashift:SI (match_operand:SI 5 "register_operand" "2")
15127                             (const_int 2))
15128                  (match_operand:SI 3 "register_operand" "0")))
15129    (set (match_operand:SI 1 "register_operand" "=S") 
15130         (plus:SI (ashift:SI (match_dup 5) (const_int 2))
15131                  (match_operand:SI 4 "register_operand" "1")))
15132    (set (mem:BLK (match_dup 3))
15133         (mem:BLK (match_dup 4)))
15134    (use (match_dup 5))
15135    (use (reg:SI 19))]
15136   "!TARGET_64BIT"
15137   "{rep\;movsl|rep movsd}"
15138   [(set_attr "type" "str")
15139    (set_attr "prefix_rep" "1")
15140    (set_attr "memory" "both")
15141    (set_attr "mode" "SI")])
15143 (define_insn "rep_movsi_rex64"
15144   [(set (match_operand:DI 2 "register_operand" "=c") (const_int 0))
15145    (set (match_operand:DI 0 "register_operand" "=D") 
15146         (plus:DI (ashift:DI (match_operand:DI 5 "register_operand" "2")
15147                             (const_int 2))
15148                  (match_operand:DI 3 "register_operand" "0")))
15149    (set (match_operand:DI 1 "register_operand" "=S") 
15150         (plus:DI (ashift:DI (match_dup 5) (const_int 2))
15151                  (match_operand:DI 4 "register_operand" "1")))
15152    (set (mem:BLK (match_dup 3))
15153         (mem:BLK (match_dup 4)))
15154    (use (match_dup 5))
15155    (use (reg:SI 19))]
15156   "TARGET_64BIT"
15157   "{rep\;movsl|rep movsd}"
15158   [(set_attr "type" "str")
15159    (set_attr "prefix_rep" "1")
15160    (set_attr "memory" "both")
15161    (set_attr "mode" "SI")])
15163 (define_insn "rep_movqi"
15164   [(set (match_operand:SI 2 "register_operand" "=c") (const_int 0))
15165    (set (match_operand:SI 0 "register_operand" "=D") 
15166         (plus:SI (match_operand:SI 3 "register_operand" "0")
15167                  (match_operand:SI 5 "register_operand" "2")))
15168    (set (match_operand:SI 1 "register_operand" "=S") 
15169         (plus:SI (match_operand:SI 4 "register_operand" "1") (match_dup 5)))
15170    (set (mem:BLK (match_dup 3))
15171         (mem:BLK (match_dup 4)))
15172    (use (match_dup 5))
15173    (use (reg:SI 19))]
15174   "!TARGET_64BIT"
15175   "{rep\;movsb|rep movsb}"
15176   [(set_attr "type" "str")
15177    (set_attr "prefix_rep" "1")
15178    (set_attr "memory" "both")
15179    (set_attr "mode" "SI")])
15181 (define_insn "rep_movqi_rex64"
15182   [(set (match_operand:DI 2 "register_operand" "=c") (const_int 0))
15183    (set (match_operand:DI 0 "register_operand" "=D") 
15184         (plus:DI (match_operand:DI 3 "register_operand" "0")
15185                  (match_operand:DI 5 "register_operand" "2")))
15186    (set (match_operand:DI 1 "register_operand" "=S") 
15187         (plus:DI (match_operand:DI 4 "register_operand" "1") (match_dup 5)))
15188    (set (mem:BLK (match_dup 3))
15189         (mem:BLK (match_dup 4)))
15190    (use (match_dup 5))
15191    (use (reg:SI 19))]
15192   "TARGET_64BIT"
15193   "{rep\;movsb|rep movsb}"
15194   [(set_attr "type" "str")
15195    (set_attr "prefix_rep" "1")
15196    (set_attr "memory" "both")
15197    (set_attr "mode" "SI")])
15199 (define_expand "clrstrsi"
15200    [(use (match_operand:BLK 0 "memory_operand" ""))
15201     (use (match_operand:SI 1 "nonmemory_operand" ""))
15202     (use (match_operand 2 "const_int_operand" ""))]
15203   ""
15205  if (ix86_expand_clrstr (operands[0], operands[1], operands[2]))
15206    DONE;
15207  else
15208    FAIL;
15211 (define_expand "clrstrdi"
15212    [(use (match_operand:BLK 0 "memory_operand" ""))
15213     (use (match_operand:DI 1 "nonmemory_operand" ""))
15214     (use (match_operand 2 "const_int_operand" ""))]
15215   "TARGET_64BIT"
15217  if (ix86_expand_clrstr (operands[0], operands[1], operands[2]))
15218    DONE;
15219  else
15220    FAIL;
15223 ;; Most CPUs don't like single string operations
15224 ;; Handle this case here to simplify previous expander.
15226 (define_expand "strsetdi_rex64"
15227   [(set (mem:DI (match_operand:DI 0 "register_operand" ""))
15228         (match_operand:DI 1 "register_operand" ""))
15229    (parallel [(set (match_dup 0) (plus:DI (match_dup 0) (const_int 8)))
15230               (clobber (reg:CC 17))])]
15231   "TARGET_64BIT"
15233   if (TARGET_SINGLE_STRINGOP || optimize_size)
15234     {
15235       emit_insn (gen_strsetdi_rex_1 (operands[0], operands[0], operands[1]));
15236       DONE;
15237     }
15240 (define_expand "strsetsi"
15241   [(set (mem:SI (match_operand:SI 0 "register_operand" ""))
15242         (match_operand:SI 1 "register_operand" ""))
15243    (parallel [(set (match_dup 0) (plus:SI (match_dup 0) (const_int 4)))
15244               (clobber (reg:CC 17))])]
15245   ""
15247   if (TARGET_64BIT)
15248     {
15249       emit_insn (gen_strsetsi_rex64 (operands[0], operands[1]));
15250       DONE;
15251     }
15252   else if (TARGET_SINGLE_STRINGOP || optimize_size)
15253     {
15254       emit_insn (gen_strsetsi_1 (operands[0], operands[0], operands[1]));
15255       DONE;
15256     }
15259 (define_expand "strsetsi_rex64"
15260   [(set (mem:SI (match_operand:DI 0 "register_operand" ""))
15261         (match_operand:SI 1 "register_operand" ""))
15262    (parallel [(set (match_dup 0) (plus:DI (match_dup 0) (const_int 4)))
15263               (clobber (reg:CC 17))])]
15264   "TARGET_64BIT"
15266   if (TARGET_SINGLE_STRINGOP || optimize_size)
15267     {
15268       emit_insn (gen_strsetsi_rex_1 (operands[0], operands[0], operands[1]));
15269       DONE;
15270     }
15273 (define_expand "strsethi"
15274   [(set (mem:HI (match_operand:SI 0 "register_operand" ""))
15275         (match_operand:HI 1 "register_operand" ""))
15276    (parallel [(set (match_dup 0) (plus:SI (match_dup 0) (const_int 2)))
15277               (clobber (reg:CC 17))])]
15278   ""
15280   if (TARGET_64BIT)
15281     {
15282       emit_insn (gen_strsethi_rex64 (operands[0], operands[1]));
15283       DONE;
15284     }
15285   else if (TARGET_SINGLE_STRINGOP || optimize_size)
15286     {
15287       emit_insn (gen_strsethi_1 (operands[0], operands[0], operands[1]));
15288       DONE;
15289     }
15292 (define_expand "strsethi_rex64"
15293   [(set (mem:HI (match_operand:DI 0 "register_operand" ""))
15294         (match_operand:HI 1 "register_operand" ""))
15295    (parallel [(set (match_dup 0) (plus:DI (match_dup 0) (const_int 2)))
15296               (clobber (reg:CC 17))])]
15297   "TARGET_64BIT"
15299   if (TARGET_SINGLE_STRINGOP || optimize_size)
15300     {
15301       emit_insn (gen_strsethi_rex_1 (operands[0], operands[0], operands[1]));
15302       DONE;
15303     }
15306 (define_expand "strsetqi"
15307   [(set (mem:QI (match_operand:SI 0 "register_operand" ""))
15308         (match_operand:QI 1 "register_operand" ""))
15309    (parallel [(set (match_dup 0) (plus:SI (match_dup 0) (const_int 1)))
15310               (clobber (reg:CC 17))])]
15311   ""
15313   if (TARGET_64BIT)
15314     {
15315       emit_insn (gen_strsetqi_rex64 (operands[0], operands[1]));
15316       DONE;
15317     }
15318   else if (TARGET_SINGLE_STRINGOP || optimize_size)
15319     {
15320       emit_insn (gen_strsetqi_1 (operands[0], operands[0], operands[1]));
15321       DONE;
15322     }
15325 (define_expand "strsetqi_rex64"
15326   [(set (mem:QI (match_operand:DI 0 "register_operand" ""))
15327         (match_operand:QI 1 "register_operand" ""))
15328    (parallel [(set (match_dup 0) (plus:DI (match_dup 0) (const_int 1)))
15329               (clobber (reg:CC 17))])]
15330   "TARGET_64BIT"
15332   if (TARGET_SINGLE_STRINGOP || optimize_size)
15333     {
15334       emit_insn (gen_strsetqi_rex_1 (operands[0], operands[0], operands[1]));
15335       DONE;
15336     }
15339 (define_insn "strsetdi_rex_1"
15340   [(set (mem:SI (match_operand:DI 1 "register_operand" "0"))
15341         (match_operand:SI 2 "register_operand" "a"))
15342    (set (match_operand:DI 0 "register_operand" "=D")
15343         (plus:DI (match_dup 1)
15344                  (const_int 8)))
15345    (use (reg:SI 19))]
15346   "TARGET_64BIT && (TARGET_SINGLE_STRINGOP || optimize_size)"
15347   "stosq"
15348   [(set_attr "type" "str")
15349    (set_attr "memory" "store")
15350    (set_attr "mode" "DI")])
15352 (define_insn "strsetsi_1"
15353   [(set (mem:SI (match_operand:SI 1 "register_operand" "0"))
15354         (match_operand:SI 2 "register_operand" "a"))
15355    (set (match_operand:SI 0 "register_operand" "=D")
15356         (plus:SI (match_dup 1)
15357                  (const_int 4)))
15358    (use (reg:SI 19))]
15359   "!TARGET_64BIT && (TARGET_SINGLE_STRINGOP || optimize_size)"
15360   "{stosl|stosd}"
15361   [(set_attr "type" "str")
15362    (set_attr "memory" "store")
15363    (set_attr "mode" "SI")])
15365 (define_insn "strsetsi_rex_1"
15366   [(set (mem:SI (match_operand:DI 1 "register_operand" "0"))
15367         (match_operand:SI 2 "register_operand" "a"))
15368    (set (match_operand:DI 0 "register_operand" "=D")
15369         (plus:DI (match_dup 1)
15370                  (const_int 4)))
15371    (use (reg:SI 19))]
15372   "TARGET_64BIT && (TARGET_SINGLE_STRINGOP || optimize_size)"
15373   "{stosl|stosd}"
15374   [(set_attr "type" "str")
15375    (set_attr "memory" "store")
15376    (set_attr "mode" "SI")])
15378 (define_insn "strsethi_1"
15379   [(set (mem:HI (match_operand:SI 1 "register_operand" "0"))
15380         (match_operand:HI 2 "register_operand" "a"))
15381    (set (match_operand:SI 0 "register_operand" "=D")
15382         (plus:SI (match_dup 1)
15383                  (const_int 2)))
15384    (use (reg:SI 19))]
15385   "!TARGET_64BIT && (TARGET_SINGLE_STRINGOP || optimize_size)"
15386   "stosw"
15387   [(set_attr "type" "str")
15388    (set_attr "memory" "store")
15389    (set_attr "mode" "HI")])
15391 (define_insn "strsethi_rex_1"
15392   [(set (mem:HI (match_operand:DI 1 "register_operand" "0"))
15393         (match_operand:HI 2 "register_operand" "a"))
15394    (set (match_operand:DI 0 "register_operand" "=D")
15395         (plus:DI (match_dup 1)
15396                  (const_int 2)))
15397    (use (reg:SI 19))]
15398   "TARGET_64BIT && (TARGET_SINGLE_STRINGOP || optimize_size)"
15399   "stosw"
15400   [(set_attr "type" "str")
15401    (set_attr "memory" "store")
15402    (set_attr "mode" "HI")])
15404 (define_insn "strsetqi_1"
15405   [(set (mem:QI (match_operand:SI 1 "register_operand" "0"))
15406         (match_operand:QI 2 "register_operand" "a"))
15407    (set (match_operand:SI 0 "register_operand" "=D")
15408         (plus:SI (match_dup 1)
15409                  (const_int 1)))
15410    (use (reg:SI 19))]
15411   "!TARGET_64BIT && (TARGET_SINGLE_STRINGOP || optimize_size)"
15412   "stosb"
15413   [(set_attr "type" "str")
15414    (set_attr "memory" "store")
15415    (set_attr "mode" "QI")])
15417 (define_insn "strsetqi_rex_1"
15418   [(set (mem:QI (match_operand:DI 1 "register_operand" "0"))
15419         (match_operand:QI 2 "register_operand" "a"))
15420    (set (match_operand:DI 0 "register_operand" "=D")
15421         (plus:DI (match_dup 1)
15422                  (const_int 1)))
15423    (use (reg:SI 19))]
15424   "TARGET_64BIT && (TARGET_SINGLE_STRINGOP || optimize_size)"
15425   "stosb"
15426   [(set_attr "type" "str")
15427    (set_attr "memory" "store")
15428    (set_attr "mode" "QI")])
15430 (define_insn "rep_stosdi_rex64"
15431   [(set (match_operand:DI 1 "register_operand" "=c") (const_int 0))
15432    (set (match_operand:DI 0 "register_operand" "=D") 
15433         (plus:DI (ashift:DI (match_operand:DI 4 "register_operand" "1")
15434                             (const_int 3))
15435                  (match_operand:DI 3 "register_operand" "0")))
15436    (set (mem:BLK (match_dup 3))
15437         (const_int 0))
15438    (use (match_operand:DI 2 "register_operand" "a"))
15439    (use (match_dup 4))
15440    (use (reg:SI 19))]
15441   "TARGET_64BIT"
15442   "{rep\;stosq|rep stosq}"
15443   [(set_attr "type" "str")
15444    (set_attr "prefix_rep" "1")
15445    (set_attr "memory" "store")
15446    (set_attr "mode" "DI")])
15448 (define_insn "rep_stossi"
15449   [(set (match_operand:SI 1 "register_operand" "=c") (const_int 0))
15450    (set (match_operand:SI 0 "register_operand" "=D") 
15451         (plus:SI (ashift:SI (match_operand:SI 4 "register_operand" "1")
15452                             (const_int 2))
15453                  (match_operand:SI 3 "register_operand" "0")))
15454    (set (mem:BLK (match_dup 3))
15455         (const_int 0))
15456    (use (match_operand:SI 2 "register_operand" "a"))
15457    (use (match_dup 4))
15458    (use (reg:SI 19))]
15459   "!TARGET_64BIT"
15460   "{rep\;stosl|rep stosd}"
15461   [(set_attr "type" "str")
15462    (set_attr "prefix_rep" "1")
15463    (set_attr "memory" "store")
15464    (set_attr "mode" "SI")])
15466 (define_insn "rep_stossi_rex64"
15467   [(set (match_operand:DI 1 "register_operand" "=c") (const_int 0))
15468    (set (match_operand:DI 0 "register_operand" "=D") 
15469         (plus:DI (ashift:DI (match_operand:DI 4 "register_operand" "1")
15470                             (const_int 2))
15471                  (match_operand:DI 3 "register_operand" "0")))
15472    (set (mem:BLK (match_dup 3))
15473         (const_int 0))
15474    (use (match_operand:SI 2 "register_operand" "a"))
15475    (use (match_dup 4))
15476    (use (reg:SI 19))]
15477   "TARGET_64BIT"
15478   "{rep\;stosl|rep stosd}"
15479   [(set_attr "type" "str")
15480    (set_attr "prefix_rep" "1")
15481    (set_attr "memory" "store")
15482    (set_attr "mode" "SI")])
15484 (define_insn "rep_stosqi"
15485   [(set (match_operand:SI 1 "register_operand" "=c") (const_int 0))
15486    (set (match_operand:SI 0 "register_operand" "=D") 
15487         (plus:SI (match_operand:SI 3 "register_operand" "0")
15488                  (match_operand:SI 4 "register_operand" "1")))
15489    (set (mem:BLK (match_dup 3))
15490         (const_int 0))
15491    (use (match_operand:QI 2 "register_operand" "a"))
15492    (use (match_dup 4))
15493    (use (reg:SI 19))]
15494   "!TARGET_64BIT"
15495   "{rep\;stosb|rep stosb}"
15496   [(set_attr "type" "str")
15497    (set_attr "prefix_rep" "1")
15498    (set_attr "memory" "store")
15499    (set_attr "mode" "QI")])
15501 (define_insn "rep_stosqi_rex64"
15502   [(set (match_operand:DI 1 "register_operand" "=c") (const_int 0))
15503    (set (match_operand:DI 0 "register_operand" "=D") 
15504         (plus:DI (match_operand:DI 3 "register_operand" "0")
15505                  (match_operand:DI 4 "register_operand" "1")))
15506    (set (mem:BLK (match_dup 3))
15507         (const_int 0))
15508    (use (match_operand:QI 2 "register_operand" "a"))
15509    (use (match_dup 4))
15510    (use (reg:DI 19))]
15511   "TARGET_64BIT"
15512   "{rep\;stosb|rep stosb}"
15513   [(set_attr "type" "str")
15514    (set_attr "prefix_rep" "1")
15515    (set_attr "memory" "store")
15516    (set_attr "mode" "QI")])
15518 (define_expand "cmpstrsi"
15519   [(set (match_operand:SI 0 "register_operand" "")
15520         (compare:SI (match_operand:BLK 1 "general_operand" "")
15521                     (match_operand:BLK 2 "general_operand" "")))
15522    (use (match_operand 3 "general_operand" ""))
15523    (use (match_operand 4 "immediate_operand" ""))]
15524   ""
15526   rtx addr1, addr2, out, outlow, count, countreg, align;
15528   out = operands[0];
15529   if (GET_CODE (out) != REG)
15530     out = gen_reg_rtx (SImode);
15532   addr1 = copy_to_mode_reg (Pmode, XEXP (operands[1], 0));
15533   addr2 = copy_to_mode_reg (Pmode, XEXP (operands[2], 0));
15534   
15535   count = operands[3];
15536   countreg = ix86_zero_extend_to_Pmode (count);
15538   /* %%% Iff we are testing strict equality, we can use known alignment
15539      to good advantage.  This may be possible with combine, particularly
15540      once cc0 is dead.  */
15541   align = operands[4];
15543   emit_insn (gen_cld ());
15544   if (GET_CODE (count) == CONST_INT)
15545     {
15546       if (INTVAL (count) == 0)
15547         {
15548           emit_move_insn (operands[0], const0_rtx);
15549           DONE;
15550         }
15551       if (TARGET_64BIT)
15552         emit_insn (gen_cmpstrqi_nz_rex_1 (addr1, addr2, countreg, align,
15553                                           addr1, addr2, countreg));
15554       else
15555         emit_insn (gen_cmpstrqi_nz_1 (addr1, addr2, countreg, align,
15556                                       addr1, addr2, countreg));
15557     }
15558   else
15559     {
15560       if (TARGET_64BIT)
15561         {
15562           emit_insn (gen_cmpdi_1_rex64 (countreg, countreg));
15563           emit_insn (gen_cmpstrqi_rex_1 (addr1, addr2, countreg, align,
15564                                          addr1, addr2, countreg));
15565         }
15566       else
15567         {
15568           emit_insn (gen_cmpsi_1 (countreg, countreg));
15569           emit_insn (gen_cmpstrqi_1 (addr1, addr2, countreg, align,
15570                                      addr1, addr2, countreg));
15571         }
15572     }
15574   outlow = gen_lowpart (QImode, out);
15575   emit_insn (gen_cmpintqi (outlow));
15576   emit_move_insn (out, gen_rtx_SIGN_EXTEND (SImode, outlow));
15578   if (operands[0] != out)
15579     emit_move_insn (operands[0], out);
15581   DONE;
15584 ;; Produce a tri-state integer (-1, 0, 1) from condition codes.
15586 (define_expand "cmpintqi"
15587   [(set (match_dup 1)
15588         (gtu:QI (reg:CC 17) (const_int 0)))
15589    (set (match_dup 2)
15590         (ltu:QI (reg:CC 17) (const_int 0)))
15591    (parallel [(set (match_operand:QI 0 "register_operand" "")
15592                    (minus:QI (match_dup 1)
15593                              (match_dup 2)))
15594               (clobber (reg:CC 17))])]
15595   ""
15596   "operands[1] = gen_reg_rtx (QImode);
15597    operands[2] = gen_reg_rtx (QImode);")
15599 ;; memcmp recognizers.  The `cmpsb' opcode does nothing if the count is
15600 ;; zero.  Emit extra code to make sure that a zero-length compare is EQ.
15602 (define_insn "cmpstrqi_nz_1"
15603   [(set (reg:CC 17)
15604         (compare:CC (mem:BLK (match_operand:SI 4 "register_operand" "0"))
15605                     (mem:BLK (match_operand:SI 5 "register_operand" "1"))))
15606    (use (match_operand:SI 6 "register_operand" "2"))
15607    (use (match_operand:SI 3 "immediate_operand" "i"))
15608    (use (reg:SI 19))
15609    (clobber (match_operand:SI 0 "register_operand" "=S"))
15610    (clobber (match_operand:SI 1 "register_operand" "=D"))
15611    (clobber (match_operand:SI 2 "register_operand" "=c"))]
15612   "!TARGET_64BIT"
15613   "repz{\;| }cmpsb"
15614   [(set_attr "type" "str")
15615    (set_attr "mode" "QI")
15616    (set_attr "prefix_rep" "1")])
15618 (define_insn "cmpstrqi_nz_rex_1"
15619   [(set (reg:CC 17)
15620         (compare:CC (mem:BLK (match_operand:DI 4 "register_operand" "0"))
15621                     (mem:BLK (match_operand:DI 5 "register_operand" "1"))))
15622    (use (match_operand:DI 6 "register_operand" "2"))
15623    (use (match_operand:SI 3 "immediate_operand" "i"))
15624    (use (reg:SI 19))
15625    (clobber (match_operand:DI 0 "register_operand" "=S"))
15626    (clobber (match_operand:DI 1 "register_operand" "=D"))
15627    (clobber (match_operand:DI 2 "register_operand" "=c"))]
15628   "TARGET_64BIT"
15629   "repz{\;| }cmpsb"
15630   [(set_attr "type" "str")
15631    (set_attr "mode" "QI")
15632    (set_attr "prefix_rep" "1")])
15634 ;; The same, but the count is not known to not be zero.
15636 (define_insn "cmpstrqi_1"
15637   [(set (reg:CC 17)
15638         (if_then_else:CC (ne (match_operand:SI 6 "register_operand" "2")
15639                              (const_int 0))
15640           (compare:CC (mem:BLK (match_operand:SI 4 "register_operand" "0"))
15641                       (mem:BLK (match_operand:SI 5 "register_operand" "1")))
15642           (const_int 0)))
15643    (use (match_operand:SI 3 "immediate_operand" "i"))
15644    (use (reg:CC 17))
15645    (use (reg:SI 19))
15646    (clobber (match_operand:SI 0 "register_operand" "=S"))
15647    (clobber (match_operand:SI 1 "register_operand" "=D"))
15648    (clobber (match_operand:SI 2 "register_operand" "=c"))]
15649   "!TARGET_64BIT"
15650   "repz{\;| }cmpsb"
15651   [(set_attr "type" "str")
15652    (set_attr "mode" "QI")
15653    (set_attr "prefix_rep" "1")])
15655 (define_insn "cmpstrqi_rex_1"
15656   [(set (reg:CC 17)
15657         (if_then_else:CC (ne (match_operand:DI 6 "register_operand" "2")
15658                              (const_int 0))
15659           (compare:CC (mem:BLK (match_operand:DI 4 "register_operand" "0"))
15660                       (mem:BLK (match_operand:DI 5 "register_operand" "1")))
15661           (const_int 0)))
15662    (use (match_operand:SI 3 "immediate_operand" "i"))
15663    (use (reg:CC 17))
15664    (use (reg:SI 19))
15665    (clobber (match_operand:DI 0 "register_operand" "=S"))
15666    (clobber (match_operand:DI 1 "register_operand" "=D"))
15667    (clobber (match_operand:DI 2 "register_operand" "=c"))]
15668   "TARGET_64BIT"
15669   "repz{\;| }cmpsb"
15670   [(set_attr "type" "str")
15671    (set_attr "mode" "QI")
15672    (set_attr "prefix_rep" "1")])
15674 (define_expand "strlensi"
15675   [(set (match_operand:SI 0 "register_operand" "")
15676         (unspec:SI [(match_operand:BLK 1 "general_operand" "")
15677                     (match_operand:QI 2 "immediate_operand" "")
15678                     (match_operand 3 "immediate_operand" "")] UNSPEC_SCAS))]
15679   ""
15681  if (ix86_expand_strlen (operands[0], operands[1], operands[2], operands[3]))
15682    DONE;
15683  else
15684    FAIL;
15687 (define_expand "strlendi"
15688   [(set (match_operand:DI 0 "register_operand" "")
15689         (unspec:DI [(match_operand:BLK 1 "general_operand" "")
15690                     (match_operand:QI 2 "immediate_operand" "")
15691                     (match_operand 3 "immediate_operand" "")] UNSPEC_SCAS))]
15692   ""
15694  if (ix86_expand_strlen (operands[0], operands[1], operands[2], operands[3]))
15695    DONE;
15696  else
15697    FAIL;
15700 (define_insn "strlenqi_1"
15701   [(set (match_operand:SI 0 "register_operand" "=&c")
15702         (unspec:SI [(mem:BLK (match_operand:SI 5 "register_operand" "1"))
15703                     (match_operand:QI 2 "register_operand" "a")
15704                     (match_operand:SI 3 "immediate_operand" "i")
15705                     (match_operand:SI 4 "register_operand" "0")] UNSPEC_SCAS))
15706    (use (reg:SI 19))
15707    (clobber (match_operand:SI 1 "register_operand" "=D"))
15708    (clobber (reg:CC 17))]
15709   "!TARGET_64BIT"
15710   "repnz{\;| }scasb"
15711   [(set_attr "type" "str")
15712    (set_attr "mode" "QI")
15713    (set_attr "prefix_rep" "1")])
15715 (define_insn "strlenqi_rex_1"
15716   [(set (match_operand:DI 0 "register_operand" "=&c")
15717         (unspec:DI [(mem:BLK (match_operand:DI 5 "register_operand" "1"))
15718                     (match_operand:QI 2 "register_operand" "a")
15719                     (match_operand:DI 3 "immediate_operand" "i")
15720                     (match_operand:DI 4 "register_operand" "0")] UNSPEC_SCAS))
15721    (use (reg:SI 19))
15722    (clobber (match_operand:DI 1 "register_operand" "=D"))
15723    (clobber (reg:CC 17))]
15724   "TARGET_64BIT"
15725   "repnz{\;| }scasb"
15726   [(set_attr "type" "str")
15727    (set_attr "mode" "QI")
15728    (set_attr "prefix_rep" "1")])
15730 ;; Peephole optimizations to clean up after cmpstr*.  This should be
15731 ;; handled in combine, but it is not currently up to the task.
15732 ;; When used for their truth value, the cmpstr* expanders generate
15733 ;; code like this:
15735 ;;   repz cmpsb
15736 ;;   seta       %al
15737 ;;   setb       %dl
15738 ;;   cmpb       %al, %dl
15739 ;;   jcc        label
15741 ;; The intermediate three instructions are unnecessary.
15743 ;; This one handles cmpstr*_nz_1...
15744 (define_peephole2
15745   [(parallel[
15746      (set (reg:CC 17)
15747           (compare:CC (mem:BLK (match_operand 4 "register_operand" ""))
15748                       (mem:BLK (match_operand 5 "register_operand" ""))))
15749      (use (match_operand 6 "register_operand" ""))
15750      (use (match_operand:SI 3 "immediate_operand" ""))
15751      (use (reg:SI 19))
15752      (clobber (match_operand 0 "register_operand" ""))
15753      (clobber (match_operand 1 "register_operand" ""))
15754      (clobber (match_operand 2 "register_operand" ""))])
15755    (set (match_operand:QI 7 "register_operand" "")
15756         (gtu:QI (reg:CC 17) (const_int 0)))
15757    (set (match_operand:QI 8 "register_operand" "")
15758         (ltu:QI (reg:CC 17) (const_int 0)))
15759    (set (reg 17)
15760         (compare (match_dup 7) (match_dup 8)))
15761   ]
15762   "peep2_reg_dead_p (4, operands[7]) && peep2_reg_dead_p (4, operands[8])"
15763   [(parallel[
15764      (set (reg:CC 17)
15765           (compare:CC (mem:BLK (match_dup 4))
15766                       (mem:BLK (match_dup 5))))
15767      (use (match_dup 6))
15768      (use (match_dup 3))
15769      (use (reg:SI 19))
15770      (clobber (match_dup 0))
15771      (clobber (match_dup 1))
15772      (clobber (match_dup 2))])]
15773   "")
15775 ;; ...and this one handles cmpstr*_1.
15776 (define_peephole2
15777   [(parallel[
15778      (set (reg:CC 17)
15779           (if_then_else:CC (ne (match_operand 6 "register_operand" "")
15780                                (const_int 0))
15781             (compare:CC (mem:BLK (match_operand 4 "register_operand" ""))
15782                         (mem:BLK (match_operand 5 "register_operand" "")))
15783             (const_int 0)))
15784      (use (match_operand:SI 3 "immediate_operand" ""))
15785      (use (reg:CC 17))
15786      (use (reg:SI 19))
15787      (clobber (match_operand 0 "register_operand" ""))
15788      (clobber (match_operand 1 "register_operand" ""))
15789      (clobber (match_operand 2 "register_operand" ""))])
15790    (set (match_operand:QI 7 "register_operand" "")
15791         (gtu:QI (reg:CC 17) (const_int 0)))
15792    (set (match_operand:QI 8 "register_operand" "")
15793         (ltu:QI (reg:CC 17) (const_int 0)))
15794    (set (reg 17)
15795         (compare (match_dup 7) (match_dup 8)))
15796   ]
15797   "peep2_reg_dead_p (4, operands[7]) && peep2_reg_dead_p (4, operands[8])"
15798   [(parallel[
15799      (set (reg:CC 17)
15800           (if_then_else:CC (ne (match_dup 6)
15801                                (const_int 0))
15802             (compare:CC (mem:BLK (match_dup 4))
15803                         (mem:BLK (match_dup 5)))
15804             (const_int 0)))
15805      (use (match_dup 3))
15806      (use (reg:CC 17))
15807      (use (reg:SI 19))
15808      (clobber (match_dup 0))
15809      (clobber (match_dup 1))
15810      (clobber (match_dup 2))])]
15811   "")
15815 ;; Conditional move instructions.
15817 (define_expand "movdicc"
15818   [(set (match_operand:DI 0 "register_operand" "")
15819         (if_then_else:DI (match_operand 1 "comparison_operator" "")
15820                          (match_operand:DI 2 "general_operand" "")
15821                          (match_operand:DI 3 "general_operand" "")))]
15822   "TARGET_64BIT"
15823   "if (!ix86_expand_int_movcc (operands)) FAIL; DONE;")
15825 (define_insn "x86_movdicc_0_m1_rex64"
15826   [(set (match_operand:DI 0 "register_operand" "=r")
15827         (if_then_else:DI (ltu (reg:CC 17) (const_int 0))
15828           (const_int -1)
15829           (const_int 0)))
15830    (clobber (reg:CC 17))]
15831   "TARGET_64BIT"
15832   "sbb{q}\t%0, %0"
15833   ; Since we don't have the proper number of operands for an alu insn,
15834   ; fill in all the blanks.
15835   [(set_attr "type" "alu")
15836    (set_attr "pent_pair" "pu")
15837    (set_attr "memory" "none")
15838    (set_attr "imm_disp" "false")
15839    (set_attr "mode" "DI")
15840    (set_attr "length_immediate" "0")])
15842 (define_insn "*movdicc_c_rex64"
15843   [(set (match_operand:DI 0 "register_operand" "=r,r")
15844         (if_then_else:DI (match_operator 1 "ix86_comparison_operator" 
15845                                 [(reg 17) (const_int 0)])
15846                       (match_operand:DI 2 "nonimmediate_operand" "rm,0")
15847                       (match_operand:DI 3 "nonimmediate_operand" "0,rm")))]
15848   "TARGET_64BIT && TARGET_CMOVE
15849    && (GET_CODE (operands[2]) != MEM || GET_CODE (operands[3]) != MEM)"
15850   "@
15851    cmov%O2%C1\t{%2, %0|%0, %2}
15852    cmov%O2%c1\t{%3, %0|%0, %3}"
15853   [(set_attr "type" "icmov")
15854    (set_attr "mode" "DI")])
15856 (define_expand "movsicc"
15857   [(set (match_operand:SI 0 "register_operand" "")
15858         (if_then_else:SI (match_operand 1 "comparison_operator" "")
15859                          (match_operand:SI 2 "general_operand" "")
15860                          (match_operand:SI 3 "general_operand" "")))]
15861   ""
15862   "if (!ix86_expand_int_movcc (operands)) FAIL; DONE;")
15864 ;; Data flow gets confused by our desire for `sbbl reg,reg', and clearing
15865 ;; the register first winds up with `sbbl $0,reg', which is also weird.
15866 ;; So just document what we're doing explicitly.
15868 (define_insn "x86_movsicc_0_m1"
15869   [(set (match_operand:SI 0 "register_operand" "=r")
15870         (if_then_else:SI (ltu (reg:CC 17) (const_int 0))
15871           (const_int -1)
15872           (const_int 0)))
15873    (clobber (reg:CC 17))]
15874   ""
15875   "sbb{l}\t%0, %0"
15876   ; Since we don't have the proper number of operands for an alu insn,
15877   ; fill in all the blanks.
15878   [(set_attr "type" "alu")
15879    (set_attr "pent_pair" "pu")
15880    (set_attr "memory" "none")
15881    (set_attr "imm_disp" "false")
15882    (set_attr "mode" "SI")
15883    (set_attr "length_immediate" "0")])
15885 (define_insn "*movsicc_noc"
15886   [(set (match_operand:SI 0 "register_operand" "=r,r")
15887         (if_then_else:SI (match_operator 1 "ix86_comparison_operator" 
15888                                 [(reg 17) (const_int 0)])
15889                       (match_operand:SI 2 "nonimmediate_operand" "rm,0")
15890                       (match_operand:SI 3 "nonimmediate_operand" "0,rm")))]
15891   "TARGET_CMOVE
15892    && (GET_CODE (operands[2]) != MEM || GET_CODE (operands[3]) != MEM)"
15893   "@
15894    cmov%O2%C1\t{%2, %0|%0, %2}
15895    cmov%O2%c1\t{%3, %0|%0, %3}"
15896   [(set_attr "type" "icmov")
15897    (set_attr "mode" "SI")])
15899 (define_expand "movhicc"
15900   [(set (match_operand:HI 0 "register_operand" "")
15901         (if_then_else:HI (match_operand 1 "comparison_operator" "")
15902                          (match_operand:HI 2 "nonimmediate_operand" "")
15903                          (match_operand:HI 3 "nonimmediate_operand" "")))]
15904   "TARGET_CMOVE && TARGET_HIMODE_MATH"
15905   "if (!ix86_expand_int_movcc (operands)) FAIL; DONE;")
15907 (define_insn "*movhicc_noc"
15908   [(set (match_operand:HI 0 "register_operand" "=r,r")
15909         (if_then_else:HI (match_operator 1 "ix86_comparison_operator" 
15910                                 [(reg 17) (const_int 0)])
15911                       (match_operand:HI 2 "nonimmediate_operand" "rm,0")
15912                       (match_operand:HI 3 "nonimmediate_operand" "0,rm")))]
15913   "TARGET_CMOVE
15914    && (GET_CODE (operands[2]) != MEM || GET_CODE (operands[3]) != MEM)"
15915   "@
15916    cmov%O2%C1\t{%2, %0|%0, %2}
15917    cmov%O2%c1\t{%3, %0|%0, %3}"
15918   [(set_attr "type" "icmov")
15919    (set_attr "mode" "HI")])
15921 (define_expand "movsfcc"
15922   [(set (match_operand:SF 0 "register_operand" "")
15923         (if_then_else:SF (match_operand 1 "comparison_operator" "")
15924                          (match_operand:SF 2 "register_operand" "")
15925                          (match_operand:SF 3 "register_operand" "")))]
15926   "TARGET_CMOVE"
15927   "if (! ix86_expand_fp_movcc (operands)) FAIL; DONE;")
15929 (define_insn "*movsfcc_1"
15930   [(set (match_operand:SF 0 "register_operand" "=f,f,r,r")
15931         (if_then_else:SF (match_operator 1 "fcmov_comparison_operator" 
15932                                 [(reg 17) (const_int 0)])
15933                       (match_operand:SF 2 "nonimmediate_operand" "f,0,rm,0")
15934                       (match_operand:SF 3 "nonimmediate_operand" "0,f,0,rm")))]
15935   "TARGET_CMOVE
15936    && (GET_CODE (operands[2]) != MEM || GET_CODE (operands[3]) != MEM)"
15937   "@
15938    fcmov%F1\t{%2, %0|%0, %2}
15939    fcmov%f1\t{%3, %0|%0, %3}
15940    cmov%O2%C1\t{%2, %0|%0, %2}
15941    cmov%O2%c1\t{%3, %0|%0, %3}"
15942   [(set_attr "type" "fcmov,fcmov,icmov,icmov")
15943    (set_attr "mode" "SF,SF,SI,SI")])
15945 (define_expand "movdfcc"
15946   [(set (match_operand:DF 0 "register_operand" "")
15947         (if_then_else:DF (match_operand 1 "comparison_operator" "")
15948                          (match_operand:DF 2 "register_operand" "")
15949                          (match_operand:DF 3 "register_operand" "")))]
15950   "TARGET_CMOVE"
15951   "if (! ix86_expand_fp_movcc (operands)) FAIL; DONE;")
15953 (define_insn "*movdfcc_1"
15954   [(set (match_operand:DF 0 "register_operand" "=f,f,&r,&r")
15955         (if_then_else:DF (match_operator 1 "fcmov_comparison_operator" 
15956                                 [(reg 17) (const_int 0)])
15957                       (match_operand:DF 2 "nonimmediate_operand" "f,0,rm,0")
15958                       (match_operand:DF 3 "nonimmediate_operand" "0,f,0,rm")))]
15959   "!TARGET_64BIT && TARGET_CMOVE
15960    && (GET_CODE (operands[2]) != MEM || GET_CODE (operands[3]) != MEM)"
15961   "@
15962    fcmov%F1\t{%2, %0|%0, %2}
15963    fcmov%f1\t{%3, %0|%0, %3}
15964    #
15965    #"
15966   [(set_attr "type" "fcmov,fcmov,multi,multi")
15967    (set_attr "mode" "DF")])
15969 (define_insn "*movdfcc_1_rex64"
15970   [(set (match_operand:DF 0 "register_operand" "=f,f,&r,&r")
15971         (if_then_else:DF (match_operator 1 "fcmov_comparison_operator" 
15972                                 [(reg 17) (const_int 0)])
15973                       (match_operand:DF 2 "nonimmediate_operand" "f,0,rm,0")
15974                       (match_operand:DF 3 "nonimmediate_operand" "0,f,0,rm")))]
15975   "TARGET_64BIT && TARGET_CMOVE
15976    && (GET_CODE (operands[2]) != MEM || GET_CODE (operands[3]) != MEM)"
15977   "@
15978    fcmov%F1\t{%2, %0|%0, %2}
15979    fcmov%f1\t{%3, %0|%0, %3}
15980    cmov%O2%C1\t{%2, %0|%0, %2}
15981    cmov%O2%c1\t{%3, %0|%0, %3}"
15982   [(set_attr "type" "fcmov,fcmov,icmov,icmov")
15983    (set_attr "mode" "DF")])
15985 (define_split
15986   [(set (match_operand:DF 0 "register_operand" "")
15987         (if_then_else:DF (match_operator 1 "fcmov_comparison_operator" 
15988                                 [(match_operand 4 "" "") (const_int 0)])
15989                       (match_operand:DF 2 "nonimmediate_operand" "")
15990                       (match_operand:DF 3 "nonimmediate_operand" "")))]
15991   "!TARGET_64BIT && !ANY_FP_REG_P (operands[0]) && reload_completed"
15992   [(set (match_dup 2)
15993         (if_then_else:SI (match_op_dup 1 [(match_dup 4) (const_int 0)])
15994                       (match_dup 5)
15995                       (match_dup 7)))
15996    (set (match_dup 3)
15997         (if_then_else:SI (match_op_dup 1 [(match_dup 4) (const_int 0)])
15998                       (match_dup 6)
15999                       (match_dup 8)))]
16000   "split_di (operands+2, 1, operands+5, operands+6);
16001    split_di (operands+3, 1, operands+7, operands+8);
16002    split_di (operands, 1, operands+2, operands+3);")
16004 (define_expand "movxfcc"
16005   [(set (match_operand:XF 0 "register_operand" "")
16006         (if_then_else:XF (match_operand 1 "comparison_operator" "")
16007                          (match_operand:XF 2 "register_operand" "")
16008                          (match_operand:XF 3 "register_operand" "")))]
16009   "!TARGET_64BIT && TARGET_CMOVE"
16010   "if (! ix86_expand_fp_movcc (operands)) FAIL; DONE;")
16012 (define_expand "movtfcc"
16013   [(set (match_operand:TF 0 "register_operand" "")
16014         (if_then_else:TF (match_operand 1 "comparison_operator" "")
16015                          (match_operand:TF 2 "register_operand" "")
16016                          (match_operand:TF 3 "register_operand" "")))]
16017   "TARGET_CMOVE"
16018   "if (! ix86_expand_fp_movcc (operands)) FAIL; DONE;")
16020 (define_insn "*movxfcc_1"
16021   [(set (match_operand:XF 0 "register_operand" "=f,f")
16022         (if_then_else:XF (match_operator 1 "fcmov_comparison_operator" 
16023                                 [(reg 17) (const_int 0)])
16024                       (match_operand:XF 2 "register_operand" "f,0")
16025                       (match_operand:XF 3 "register_operand" "0,f")))]
16026   "!TARGET_64BIT && TARGET_CMOVE"
16027   "@
16028    fcmov%F1\t{%2, %0|%0, %2}
16029    fcmov%f1\t{%3, %0|%0, %3}"
16030   [(set_attr "type" "fcmov")
16031    (set_attr "mode" "XF")])
16033 (define_insn "*movtfcc_1"
16034   [(set (match_operand:TF 0 "register_operand" "=f,f")
16035         (if_then_else:TF (match_operator 1 "fcmov_comparison_operator" 
16036                                 [(reg 17) (const_int 0)])
16037                       (match_operand:TF 2 "register_operand" "f,0")
16038                       (match_operand:TF 3 "register_operand" "0,f")))]
16039   "TARGET_CMOVE"
16040   "@
16041    fcmov%F1\t{%2, %0|%0, %2}
16042    fcmov%f1\t{%3, %0|%0, %3}"
16043   [(set_attr "type" "fcmov")
16044    (set_attr "mode" "XF")])
16046 (define_expand "minsf3"
16047   [(parallel [
16048      (set (match_operand:SF 0 "register_operand" "")
16049           (if_then_else:SF (lt (match_operand:SF 1 "register_operand" "")
16050                                (match_operand:SF 2 "nonimmediate_operand" ""))
16051                            (match_dup 1)
16052                            (match_dup 2)))
16053      (clobber (reg:CC 17))])]
16054   "TARGET_SSE"
16055   "")
16057 (define_insn "*minsf"
16058   [(set (match_operand:SF 0 "register_operand" "=x#f,f#x,f#x")
16059         (if_then_else:SF (lt (match_operand:SF 1 "register_operand" "0,0,f#x")
16060                              (match_operand:SF 2 "nonimmediate_operand" "xm#f,f#x,0"))
16061                          (match_dup 1)
16062                          (match_dup 2)))
16063    (clobber (reg:CC 17))]
16064   "TARGET_SSE && TARGET_IEEE_FP"
16065   "#")
16067 (define_insn "*minsf_nonieee"
16068   [(set (match_operand:SF 0 "register_operand" "=x#f,f#x")
16069         (if_then_else:SF (lt (match_operand:SF 1 "nonimmediate_operand" "%0,0")
16070                              (match_operand:SF 2 "nonimmediate_operand" "xm#f,f#x"))
16071                          (match_dup 1)
16072                          (match_dup 2)))
16073    (clobber (reg:CC 17))]
16074   "TARGET_SSE && !TARGET_IEEE_FP
16075    && (GET_CODE (operands[1]) != MEM || GET_CODE (operands[2]) != MEM)"
16076   "#")
16078 (define_split
16079   [(set (match_operand:SF 0 "register_operand" "")
16080         (if_then_else:SF (lt (match_operand:SF 1 "register_operand" "")
16081                              (match_operand:SF 2 "nonimmediate_operand" ""))
16082                          (match_operand:SF 3 "register_operand" "")
16083                          (match_operand:SF 4 "nonimmediate_operand" "")))
16084    (clobber (reg:CC 17))]
16085   "SSE_REG_P (operands[0]) && reload_completed
16086    && ((operands_match_p (operands[1], operands[3])
16087         && operands_match_p (operands[2], operands[4]))
16088        || (operands_match_p (operands[1], operands[4])
16089            && operands_match_p (operands[2], operands[3])))"
16090   [(set (match_dup 0)
16091         (if_then_else:SF (lt (match_dup 1)
16092                              (match_dup 2))
16093                          (match_dup 1)
16094                          (match_dup 2)))])
16096 ;; We can't represent the LT test directly.  Do this by swapping the operands.
16098 (define_split
16099   [(set (match_operand:SF 0 "register_operand" "")
16100         (if_then_else:SF (lt (match_operand:SF 1 "register_operand" "")
16101                              (match_operand:SF 2 "register_operand" ""))
16102                          (match_operand:SF 3 "register_operand" "")
16103                          (match_operand:SF 4 "register_operand" "")))
16104    (clobber (reg:CC 17))]
16105   "FP_REG_P (operands[0]) && reload_completed
16106    && ((operands_match_p (operands[1], operands[3])
16107         && operands_match_p (operands[2], operands[4]))
16108        || (operands_match_p (operands[1], operands[4])
16109            && operands_match_p (operands[2], operands[3])))"
16110   [(set (reg:CCFP 17)
16111         (compare:CCFP (match_dup 2)
16112                       (match_dup 1)))
16113    (set (match_dup 0)
16114         (if_then_else:SF (ge (reg:CCFP 17) (const_int 0))
16115                          (match_dup 1)
16116                          (match_dup 2)))])
16118 (define_insn "*minsf_sse"
16119   [(set (match_operand:SF 0 "register_operand" "=x")
16120         (if_then_else:SF (lt (match_operand:SF 1 "register_operand" "0")
16121                              (match_operand:SF 2 "nonimmediate_operand" "xm"))
16122                          (match_dup 1)
16123                          (match_dup 2)))]
16124   "TARGET_SSE && reload_completed"
16125   "minss\t{%2, %0|%0, %2}"
16126   [(set_attr "type" "sse")
16127    (set_attr "mode" "SF")])
16129 (define_expand "mindf3"
16130   [(parallel [
16131      (set (match_operand:DF 0 "register_operand" "")
16132           (if_then_else:DF (lt (match_operand:DF 1 "register_operand" "")
16133                                (match_operand:DF 2 "nonimmediate_operand" ""))
16134                            (match_dup 1)
16135                            (match_dup 2)))
16136      (clobber (reg:CC 17))])]
16137   "TARGET_SSE2 && TARGET_SSE_MATH"
16138   "#")
16140 (define_insn "*mindf"
16141   [(set (match_operand:DF 0 "register_operand" "=Y#f,f#Y,f#Y")
16142         (if_then_else:DF (lt (match_operand:DF 1 "register_operand" "0,0,f#Y")
16143                              (match_operand:DF 2 "nonimmediate_operand" "Ym#f,f#Y,0"))
16144                          (match_dup 1)
16145                          (match_dup 2)))
16146    (clobber (reg:CC 17))]
16147   "TARGET_SSE2 && TARGET_IEEE_FP && TARGET_SSE_MATH"
16148   "#")
16150 (define_insn "*mindf_nonieee"
16151   [(set (match_operand:DF 0 "register_operand" "=Y#f,f#Y")
16152         (if_then_else:DF (lt (match_operand:DF 1 "nonimmediate_operand" "%0,0")
16153                              (match_operand:DF 2 "nonimmediate_operand" "Ym#f,f#Y"))
16154                          (match_dup 1)
16155                          (match_dup 2)))
16156    (clobber (reg:CC 17))]
16157   "TARGET_SSE2 && TARGET_SSE_MATH && !TARGET_IEEE_FP
16158    && (GET_CODE (operands[1]) != MEM || GET_CODE (operands[2]) != MEM)"
16159   "#")
16161 (define_split
16162   [(set (match_operand:DF 0 "register_operand" "")
16163         (if_then_else:DF (lt (match_operand:DF 1 "register_operand" "")
16164                              (match_operand:DF 2 "nonimmediate_operand" ""))
16165                          (match_operand:DF 3 "register_operand" "")
16166                          (match_operand:DF 4 "nonimmediate_operand" "")))
16167    (clobber (reg:CC 17))]
16168   "SSE_REG_P (operands[0]) && reload_completed
16169    && ((operands_match_p (operands[1], operands[3])
16170         && operands_match_p (operands[2], operands[4]))
16171        || (operands_match_p (operands[1], operands[4])
16172            && operands_match_p (operands[2], operands[3])))"
16173   [(set (match_dup 0)
16174         (if_then_else:DF (lt (match_dup 1)
16175                              (match_dup 2))
16176                          (match_dup 1)
16177                          (match_dup 2)))])
16179 ;; We can't represent the LT test directly.  Do this by swapping the operands.
16180 (define_split
16181   [(set (match_operand:DF 0 "register_operand" "")
16182         (if_then_else:DF (lt (match_operand:DF 1 "register_operand" "")
16183                              (match_operand:DF 2 "register_operand" ""))
16184                          (match_operand:DF 3 "register_operand" "")
16185                          (match_operand:DF 4 "register_operand" "")))
16186    (clobber (reg:CC 17))]
16187   "FP_REG_P (operands[0]) && reload_completed
16188    && ((operands_match_p (operands[1], operands[3])
16189         && operands_match_p (operands[2], operands[4]))
16190        || (operands_match_p (operands[1], operands[4])
16191            && operands_match_p (operands[2], operands[3])))"
16192   [(set (reg:CCFP 17)
16193         (compare:CCFP (match_dup 2)
16194                       (match_dup 2)))
16195    (set (match_dup 0)
16196         (if_then_else:DF (ge (reg:CCFP 17) (const_int 0))
16197                          (match_dup 1)
16198                          (match_dup 2)))])
16200 (define_insn "*mindf_sse"
16201   [(set (match_operand:DF 0 "register_operand" "=Y")
16202         (if_then_else:DF (lt (match_operand:DF 1 "register_operand" "0")
16203                              (match_operand:DF 2 "nonimmediate_operand" "Ym"))
16204                          (match_dup 1)
16205                          (match_dup 2)))]
16206   "TARGET_SSE2 && TARGET_SSE_MATH && reload_completed"
16207   "minsd\t{%2, %0|%0, %2}"
16208   [(set_attr "type" "sse")
16209    (set_attr "mode" "DF")])
16211 (define_expand "maxsf3"
16212   [(parallel [
16213      (set (match_operand:SF 0 "register_operand" "")
16214           (if_then_else:SF (gt (match_operand:SF 1 "register_operand" "")
16215                                (match_operand:SF 2 "nonimmediate_operand" ""))
16216                            (match_dup 1)
16217                            (match_dup 2)))
16218      (clobber (reg:CC 17))])]
16219   "TARGET_SSE"
16220   "#")
16222 (define_insn "*maxsf"
16223   [(set (match_operand:SF 0 "register_operand" "=x#f,f#x,f#x")
16224         (if_then_else:SF (gt (match_operand:SF 1 "register_operand" "0,0,f#x")
16225                              (match_operand:SF 2 "nonimmediate_operand" "xm#f,f#x,0"))
16226                          (match_dup 1)
16227                          (match_dup 2)))
16228    (clobber (reg:CC 17))]
16229   "TARGET_SSE && TARGET_IEEE_FP"
16230   "#")
16232 (define_insn "*maxsf_nonieee"
16233   [(set (match_operand:SF 0 "register_operand" "=x#f,f#x")
16234         (if_then_else:SF (gt (match_operand:SF 1 "nonimmediate_operand" "%0,0")
16235                              (match_operand:SF 2 "nonimmediate_operand" "xm#f,f#x"))
16236                          (match_dup 1)
16237                          (match_dup 2)))
16238    (clobber (reg:CC 17))]
16239   "TARGET_SSE && !TARGET_IEEE_FP
16240    && (GET_CODE (operands[1]) != MEM || GET_CODE (operands[2]) != MEM)"
16241   "#")
16243 (define_split
16244   [(set (match_operand:SF 0 "register_operand" "")
16245         (if_then_else:SF (gt (match_operand:SF 1 "register_operand" "")
16246                              (match_operand:SF 2 "nonimmediate_operand" ""))
16247                          (match_operand:SF 3 "register_operand" "")
16248                          (match_operand:SF 4 "nonimmediate_operand" "")))
16249    (clobber (reg:CC 17))]
16250   "SSE_REG_P (operands[0]) && reload_completed
16251    && ((operands_match_p (operands[1], operands[3])
16252         && operands_match_p (operands[2], operands[4]))
16253        || (operands_match_p (operands[1], operands[4])
16254            && operands_match_p (operands[2], operands[3])))"
16255   [(set (match_dup 0)
16256         (if_then_else:SF (gt (match_dup 1)
16257                              (match_dup 2))
16258                          (match_dup 1)
16259                          (match_dup 2)))])
16261 (define_split
16262   [(set (match_operand:SF 0 "register_operand" "")
16263         (if_then_else:SF (gt (match_operand:SF 1 "register_operand" "")
16264                              (match_operand:SF 2 "register_operand" ""))
16265                          (match_operand:SF 3 "register_operand" "")
16266                          (match_operand:SF 4 "register_operand" "")))
16267    (clobber (reg:CC 17))]
16268   "FP_REG_P (operands[0]) && reload_completed
16269    && ((operands_match_p (operands[1], operands[3])
16270         && operands_match_p (operands[2], operands[4]))
16271        || (operands_match_p (operands[1], operands[4])
16272            && operands_match_p (operands[2], operands[3])))"
16273   [(set (reg:CCFP 17)
16274         (compare:CCFP (match_dup 1)
16275                       (match_dup 2)))
16276    (set (match_dup 0)
16277         (if_then_else:SF (gt (reg:CCFP 17) (const_int 0))
16278                          (match_dup 1)
16279                          (match_dup 2)))])
16281 (define_insn "*maxsf_sse"
16282   [(set (match_operand:SF 0 "register_operand" "=x")
16283         (if_then_else:SF (gt (match_operand:SF 1 "register_operand" "0")
16284                              (match_operand:SF 2 "nonimmediate_operand" "xm"))
16285                          (match_dup 1)
16286                          (match_dup 2)))]
16287   "TARGET_SSE && reload_completed"
16288   "maxss\t{%2, %0|%0, %2}"
16289   [(set_attr "type" "sse")
16290    (set_attr "mode" "SF")])
16292 (define_expand "maxdf3"
16293   [(parallel [
16294      (set (match_operand:DF 0 "register_operand" "")
16295           (if_then_else:DF (gt (match_operand:DF 1 "register_operand" "")
16296                                (match_operand:DF 2 "nonimmediate_operand" ""))
16297                            (match_dup 1)
16298                            (match_dup 2)))
16299      (clobber (reg:CC 17))])]
16300   "TARGET_SSE2 && TARGET_SSE_MATH"
16301   "#")
16303 (define_insn "*maxdf"
16304   [(set (match_operand:DF 0 "register_operand" "=Y#f,f#Y,f#Y")
16305         (if_then_else:DF (gt (match_operand:DF 1 "register_operand" "0,0,f#Y")
16306                              (match_operand:DF 2 "nonimmediate_operand" "Ym#f,f#Y,0"))
16307                          (match_dup 1)
16308                          (match_dup 2)))
16309    (clobber (reg:CC 17))]
16310   "TARGET_SSE2 && TARGET_SSE_MATH && TARGET_IEEE_FP"
16311   "#")
16313 (define_insn "*maxdf_nonieee"
16314   [(set (match_operand:DF 0 "register_operand" "=Y#f,f#Y")
16315         (if_then_else:DF (gt (match_operand:DF 1 "nonimmediate_operand" "%0,0")
16316                              (match_operand:DF 2 "nonimmediate_operand" "Ym#f,f#Y"))
16317                          (match_dup 1)
16318                          (match_dup 2)))
16319    (clobber (reg:CC 17))]
16320   "TARGET_SSE2 && TARGET_SSE_MATH && !TARGET_IEEE_FP
16321    && (GET_CODE (operands[1]) != MEM || GET_CODE (operands[2]) != MEM)"
16322   "#")
16324 (define_split
16325   [(set (match_operand:DF 0 "register_operand" "")
16326         (if_then_else:DF (gt (match_operand:DF 1 "register_operand" "")
16327                              (match_operand:DF 2 "nonimmediate_operand" ""))
16328                          (match_operand:DF 3 "register_operand" "")
16329                          (match_operand:DF 4 "nonimmediate_operand" "")))
16330    (clobber (reg:CC 17))]
16331   "SSE_REG_P (operands[0]) && reload_completed
16332    && ((operands_match_p (operands[1], operands[3])
16333         && operands_match_p (operands[2], operands[4]))
16334        || (operands_match_p (operands[1], operands[4])
16335            && operands_match_p (operands[2], operands[3])))"
16336   [(set (match_dup 0)
16337         (if_then_else:DF (gt (match_dup 1)
16338                              (match_dup 2))
16339                          (match_dup 1)
16340                          (match_dup 2)))])
16342 (define_split
16343   [(set (match_operand:DF 0 "register_operand" "")
16344         (if_then_else:DF (gt (match_operand:DF 1 "register_operand" "")
16345                              (match_operand:DF 2 "register_operand" ""))
16346                          (match_operand:DF 3 "register_operand" "")
16347                          (match_operand:DF 4 "register_operand" "")))
16348    (clobber (reg:CC 17))]
16349   "FP_REG_P (operands[0]) && reload_completed
16350    && ((operands_match_p (operands[1], operands[3])
16351         && operands_match_p (operands[2], operands[4]))
16352        || (operands_match_p (operands[1], operands[4])
16353            && operands_match_p (operands[2], operands[3])))"
16354   [(set (reg:CCFP 17)
16355         (compare:CCFP (match_dup 1)
16356                       (match_dup 2)))
16357    (set (match_dup 0)
16358         (if_then_else:DF (gt (reg:CCFP 17) (const_int 0))
16359                          (match_dup 1)
16360                          (match_dup 2)))])
16362 (define_insn "*maxdf_sse"
16363   [(set (match_operand:DF 0 "register_operand" "=Y")
16364         (if_then_else:DF (gt (match_operand:DF 1 "register_operand" "0")
16365                              (match_operand:DF 2 "nonimmediate_operand" "Ym"))
16366                          (match_dup 1)
16367                          (match_dup 2)))]
16368   "TARGET_SSE2 && TARGET_SSE_MATH && reload_completed"
16369   "maxsd\t{%2, %0|%0, %2}"
16370   [(set_attr "type" "sse")
16371    (set_attr "mode" "DF")])
16373 ;; Misc patterns (?)
16375 ;; This pattern exists to put a dependency on all ebp-based memory accesses.
16376 ;; Otherwise there will be nothing to keep
16377 ;; 
16378 ;; [(set (reg ebp) (reg esp))]
16379 ;; [(set (reg esp) (plus (reg esp) (const_int -160000)))
16380 ;;  (clobber (eflags)]
16381 ;; [(set (mem (plus (reg ebp) (const_int -160000))) (const_int 0))]
16383 ;; in proper program order.
16384 (define_expand "pro_epilogue_adjust_stack"
16385   [(parallel [(set (match_operand:SI 0 "register_operand" "=r,r")
16386                    (plus:SI (match_operand:SI 1 "register_operand" "0,r")
16387                             (match_operand:SI 2 "immediate_operand" "i,i")))
16388               (clobber (reg:CC 17))
16389               (clobber (mem:BLK (scratch)))])]
16390  ""
16392   if (TARGET_64BIT)
16393     {
16394       emit_insn (gen_pro_epilogue_adjust_stack_rex64
16395                  (operands[0], operands[1], operands[2]));
16396       DONE;
16397     }
16400 (define_insn "*pro_epilogue_adjust_stack_1"
16401   [(set (match_operand:SI 0 "register_operand" "=r,r")
16402         (plus:SI (match_operand:SI 1 "register_operand" "0,r")
16403                  (match_operand:SI 2 "immediate_operand" "i,i")))
16404    (clobber (reg:CC 17))
16405    (clobber (mem:BLK (scratch)))]
16406   "!TARGET_64BIT"
16408   switch (get_attr_type (insn))
16409     {
16410     case TYPE_IMOV:
16411       return "mov{l}\t{%1, %0|%0, %1}";
16413     case TYPE_ALU:
16414       if (GET_CODE (operands[2]) == CONST_INT
16415           && (INTVAL (operands[2]) == 128
16416               || (INTVAL (operands[2]) < 0
16417                   && INTVAL (operands[2]) != -128)))
16418         {
16419           operands[2] = GEN_INT (-INTVAL (operands[2]));
16420           return "sub{l}\t{%2, %0|%0, %2}";
16421         }
16422       return "add{l}\t{%2, %0|%0, %2}";
16424     case TYPE_LEA:
16425       operands[2] = SET_SRC (XVECEXP (PATTERN (insn), 0, 0));
16426       return "lea{l}\t{%a2, %0|%0, %a2}";
16428     default:
16429       abort ();
16430     }
16432   [(set (attr "type")
16433         (cond [(eq_attr "alternative" "0")
16434                  (const_string "alu")
16435                (match_operand:SI 2 "const0_operand" "")
16436                  (const_string "imov")
16437               ]
16438               (const_string "lea")))
16439    (set_attr "mode" "SI")])
16441 (define_insn "pro_epilogue_adjust_stack_rex64"
16442   [(set (match_operand:DI 0 "register_operand" "=r,r")
16443         (plus:DI (match_operand:DI 1 "register_operand" "0,r")
16444                  (match_operand:DI 2 "x86_64_immediate_operand" "e,e")))
16445    (clobber (reg:CC 17))
16446    (clobber (mem:BLK (scratch)))]
16447   "TARGET_64BIT"
16449   switch (get_attr_type (insn))
16450     {
16451     case TYPE_IMOV:
16452       return "mov{q}\t{%1, %0|%0, %1}";
16454     case TYPE_ALU:
16455       if (GET_CODE (operands[2]) == CONST_INT
16456           && (INTVAL (operands[2]) == 128
16457               || (INTVAL (operands[2]) < 0
16458                   && INTVAL (operands[2]) != -128)))
16459         {
16460           operands[2] = GEN_INT (-INTVAL (operands[2]));
16461           return "sub{q}\t{%2, %0|%0, %2}";
16462         }
16463       return "add{q}\t{%2, %0|%0, %2}";
16465     case TYPE_LEA:
16466       operands[2] = SET_SRC (XVECEXP (PATTERN (insn), 0, 0));
16467       return "lea{q}\t{%a2, %0|%0, %a2}";
16469     default:
16470       abort ();
16471     }
16473   [(set (attr "type")
16474         (cond [(eq_attr "alternative" "0")
16475                  (const_string "alu")
16476                (match_operand:DI 2 "const0_operand" "")
16477                  (const_string "imov")
16478               ]
16479               (const_string "lea")))
16480    (set_attr "mode" "DI")])
16483 ;; Placeholder for the conditional moves.  This one is split either to SSE
16484 ;; based moves emulation or to usual cmove sequence.  Little bit unfortunate
16485 ;; fact is that compares supported by the cmp??ss instructions are exactly
16486 ;; swapped of those supported by cmove sequence.
16487 ;; The EQ/NE comparisons also needs bit care, since they are not directly
16488 ;; supported by i387 comparisons and we do need to emit two conditional moves
16489 ;; in tandem.
16491 (define_insn "sse_movsfcc"
16492   [(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")
16493         (if_then_else:SF (match_operator 1 "sse_comparison_operator"
16494                         [(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")
16495                          (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")])
16496                       (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")
16497                       (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")))
16498    (clobber (match_scratch:SF 6 "=2,&4,X,X,X,X,X,X,X,X"))
16499    (clobber (reg:CC 17))]
16500   "TARGET_SSE
16501    && (GET_CODE (operands[2]) != MEM || GET_CODE (operands[3]) != MEM)
16502    && (!TARGET_IEEE_FP
16503        || (GET_CODE (operands[1]) != EQ && GET_CODE (operands[1]) != NE))"
16504   "#")
16506 (define_insn "sse_movsfcc_eq"
16507   [(set (match_operand:SF 0 "register_operand" "=&x#rf,x#rf,?f#xr,?f#xr,?r#xf,?r#xf")
16508         (if_then_else:SF (eq (match_operand:SF 3 "nonimmediate_operand" "%0#fx,x#fx,f#x,xm#f,f#x,xm#f")
16509                              (match_operand:SF 4 "nonimmediate_operand" "xm#f,xm#f,f#x,x#f,f#x,x#f"))
16510                       (match_operand:SF 1 "nonimmediate_operand" "x#fr,0#fr,0#fx,0#fx,0#rx,0#rx")
16511                       (match_operand:SF 2 "nonimmediate_operand" "x#fr,x#fr,f#fx,f#fx,rm#rx,rm#rx")))
16512    (clobber (match_scratch:SF 5 "=1,&3,X,X,X,X"))
16513    (clobber (reg:CC 17))]
16514   "TARGET_SSE
16515    && (GET_CODE (operands[2]) != MEM || GET_CODE (operands[3]) != MEM)"
16516   "#")
16518 (define_insn "sse_movdfcc"
16519   [(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")
16520         (if_then_else:DF (match_operator 1 "sse_comparison_operator"
16521                         [(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")
16522                          (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")])
16523                       (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")
16524                       (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")))
16525    (clobber (match_scratch:DF 6 "=2,&4,X,X,X,X,X,X,X,X"))
16526    (clobber (reg:CC 17))]
16527   "TARGET_SSE2
16528    && (GET_CODE (operands[2]) != MEM || GET_CODE (operands[3]) != MEM)
16529    && (!TARGET_IEEE_FP
16530        || (GET_CODE (operands[1]) != EQ && GET_CODE (operands[1]) != NE))"
16531   "#")
16533 (define_insn "sse_movdfcc_eq"
16534   [(set (match_operand:DF 0 "register_operand" "=&Y#rf,Y#rf,?f#Yr,?f#Yr,?r#Yf,?r#Yf")
16535         (if_then_else:DF (eq (match_operand:DF 3 "nonimmediate_operand" "%0#fY,Y#fY,f#Y,Ym#f,f#Y,Ym#f")
16536                              (match_operand:DF 4 "nonimmediate_operand" "Ym#f,Ym#f,f#Y,Y#f,f#Y,Y#f"))
16537                       (match_operand:DF 1 "nonimmediate_operand" "Y#fr,0#fr,0#fY,0#fY,0#rY,0#rY")
16538                       (match_operand:DF 2 "nonimmediate_operand" "Y#fr,Y#fr,f#fY,f#fY,rm#rY,rm#rY")))
16539    (clobber (match_scratch:DF 5 "=1,&3,X,X,X,X"))
16540    (clobber (reg:CC 17))]
16541   "TARGET_SSE
16542    && (GET_CODE (operands[2]) != MEM || GET_CODE (operands[3]) != MEM)"
16543   "#")
16545 ;; For non-sse moves just expand the usual cmove sequence.
16546 (define_split
16547   [(set (match_operand 0 "register_operand" "")
16548         (if_then_else (match_operator 1 "comparison_operator"
16549                         [(match_operand 4 "nonimmediate_operand" "")
16550                          (match_operand 5 "register_operand" "")])
16551                       (match_operand 2 "nonimmediate_operand" "")
16552                       (match_operand 3 "nonimmediate_operand" "")))
16553    (clobber (match_operand 6 "" ""))
16554    (clobber (reg:CC 17))]
16555   "!SSE_REG_P (operands[0]) && reload_completed
16556    && VALID_SSE_REG_MODE (GET_MODE (operands[0]))"
16557   [(const_int 0)]
16559    ix86_compare_op0 = operands[5];
16560    ix86_compare_op1 = operands[4];
16561    operands[1] = gen_rtx_fmt_ee (swap_condition (GET_CODE (operands[1])),
16562                                  VOIDmode, operands[5], operands[4]);
16563    ix86_expand_fp_movcc (operands);
16564    DONE;
16567 ;; Split SSE based conditional move into seqence:
16568 ;; cmpCC op0, op4   -  set op0 to 0 or ffffffff depending on the comparison
16569 ;; and   op2, op0   -  zero op2 if comparison was false
16570 ;; nand  op0, op3   -  load op3 to op0 if comparison was false
16571 ;; or    op2, op0   -  get the non-zero one into the result.
16572 (define_split
16573   [(set (match_operand 0 "register_operand" "")
16574         (if_then_else (match_operator 1 "sse_comparison_operator"
16575                         [(match_operand 4 "register_operand" "")
16576                          (match_operand 5 "nonimmediate_operand" "")])
16577                       (match_operand 2 "register_operand" "")
16578                       (match_operand 3 "register_operand" "")))
16579    (clobber (match_operand 6 "" ""))
16580    (clobber (reg:CC 17))]
16581   "SSE_REG_P (operands[0]) && reload_completed"
16582   [(set (match_dup 4) (match_op_dup 1 [(match_dup 4) (match_dup 5)]))
16583    (set (subreg:TI (match_dup 2) 0) (and:TI (subreg:TI (match_dup 2) 0)
16584                                             (subreg:TI (match_dup 4) 0)))
16585    (set (subreg:TI (match_dup 4) 0) (and:TI (not:TI (subreg:TI (match_dup 4) 0))
16586                                             (subreg:TI (match_dup 3) 0)))
16587    (set (subreg:TI (match_dup 0) 0) (ior:TI (subreg:TI (match_dup 6) 0)
16588                                             (subreg:TI (match_dup 7) 0)))]
16590   /* If op2 == op3, op3 will be clobbered before it is used.
16591      This should be optimized out though.  */
16592   if (operands_match_p (operands[2], operands[3]))
16593     abort ();
16594   PUT_MODE (operands[1], GET_MODE (operands[0]));
16595   if (operands_match_p (operands[0], operands[4]))
16596     operands[6] = operands[4], operands[7] = operands[2];
16597   else
16598     operands[6] = operands[2], operands[7] = operands[4];
16601 ;; Special case of conditional move we can handle effectivly.
16602 ;; Do not brother with the integer/floating point case, since these are
16603 ;; bot considerably slower, unlike in the generic case.
16604 (define_insn "*sse_movsfcc_const0_1"
16605   [(set (match_operand:SF 0 "register_operand" "=&x")
16606         (if_then_else:SF (match_operator 1 "sse_comparison_operator"
16607                         [(match_operand:SF 4 "register_operand" "0")
16608                          (match_operand:SF 5 "nonimmediate_operand" "xm")])
16609                       (match_operand:SF 2 "register_operand" "x")
16610                       (match_operand:SF 3 "const0_operand" "X")))]
16611   "TARGET_SSE"
16612   "#")
16614 (define_insn "*sse_movsfcc_const0_2"
16615   [(set (match_operand:SF 0 "register_operand" "=&x")
16616         (if_then_else:SF (match_operator 1 "sse_comparison_operator"
16617                         [(match_operand:SF 4 "register_operand" "0")
16618                          (match_operand:SF 5 "nonimmediate_operand" "xm")])
16619                       (match_operand:SF 2 "const0_operand" "X")
16620                       (match_operand:SF 3 "register_operand" "x")))]
16621   "TARGET_SSE"
16622   "#")
16624 (define_insn "*sse_movsfcc_const0_3"
16625   [(set (match_operand:SF 0 "register_operand" "=&x")
16626         (if_then_else:SF (match_operator 1 "fcmov_comparison_operator"
16627                         [(match_operand:SF 4 "nonimmediate_operand" "xm")
16628                          (match_operand:SF 5 "register_operand" "0")])
16629                       (match_operand:SF 2 "register_operand" "x")
16630                       (match_operand:SF 3 "const0_operand" "X")))]
16631   "TARGET_SSE"
16632   "#")
16634 (define_insn "*sse_movsfcc_const0_4"
16635   [(set (match_operand:SF 0 "register_operand" "=&x")
16636         (if_then_else:SF (match_operator 1 "fcmov_comparison_operator"
16637                         [(match_operand:SF 4 "nonimmediate_operand" "xm")
16638                          (match_operand:SF 5 "register_operand" "0")])
16639                       (match_operand:SF 2 "const0_operand" "X")
16640                       (match_operand:SF 3 "register_operand" "x")))]
16641   "TARGET_SSE"
16642   "#")
16644 (define_insn "*sse_movdfcc_const0_1"
16645   [(set (match_operand:DF 0 "register_operand" "=&Y")
16646         (if_then_else:DF (match_operator 1 "sse_comparison_operator"
16647                         [(match_operand:DF 4 "register_operand" "0")
16648                          (match_operand:DF 5 "nonimmediate_operand" "Ym")])
16649                       (match_operand:DF 2 "register_operand" "Y")
16650                       (match_operand:DF 3 "const0_operand" "X")))]
16651   "TARGET_SSE2"
16652   "#")
16654 (define_insn "*sse_movdfcc_const0_2"
16655   [(set (match_operand:DF 0 "register_operand" "=&Y")
16656         (if_then_else:DF (match_operator 1 "sse_comparison_operator"
16657                         [(match_operand:DF 4 "register_operand" "0")
16658                          (match_operand:DF 5 "nonimmediate_operand" "Ym")])
16659                       (match_operand:DF 2 "const0_operand" "X")
16660                       (match_operand:DF 3 "register_operand" "Y")))]
16661   "TARGET_SSE2"
16662   "#")
16664 (define_insn "*sse_movdfcc_const0_3"
16665   [(set (match_operand:DF 0 "register_operand" "=&Y")
16666         (if_then_else:DF (match_operator 1 "fcmov_comparison_operator"
16667                         [(match_operand:DF 4 "nonimmediate_operand" "Ym")
16668                          (match_operand:DF 5 "register_operand" "0")])
16669                       (match_operand:DF 2 "register_operand" "Y")
16670                       (match_operand:DF 3 "const0_operand" "X")))]
16671   "TARGET_SSE2"
16672   "#")
16674 (define_insn "*sse_movdfcc_const0_4"
16675   [(set (match_operand:DF 0 "register_operand" "=&Y")
16676         (if_then_else:DF (match_operator 1 "fcmov_comparison_operator"
16677                         [(match_operand:DF 4 "nonimmediate_operand" "Ym")
16678                          (match_operand:DF 5 "register_operand" "0")])
16679                       (match_operand:DF 2 "const0_operand" "X")
16680                       (match_operand:DF 3 "register_operand" "Y")))]
16681   "TARGET_SSE2"
16682   "#")
16684 (define_split
16685   [(set (match_operand 0 "register_operand" "")
16686         (if_then_else (match_operator 1 "comparison_operator"
16687                         [(match_operand 4 "register_operand" "")
16688                          (match_operand 5 "nonimmediate_operand" "")])
16689                       (match_operand 2 "nonmemory_operand" "")
16690                       (match_operand 3 "nonmemory_operand" "")))]
16691   "SSE_REG_P (operands[0]) && reload_completed
16692    && (const0_operand (operands[2], GET_MODE (operands[0]))
16693        || const0_operand (operands[3], GET_MODE (operands[0])))"
16694   [(set (match_dup 0) (match_op_dup 1 [(match_dup 0) (match_dup 5)]))
16695    (set (subreg:TI (match_dup 0) 0) (and:TI (match_dup 6)
16696                                             (subreg:TI (match_dup 7) 0)))]
16698   PUT_MODE (operands[1], GET_MODE (operands[0]));
16699   if (!sse_comparison_operator (operands[1], VOIDmode))
16700     {
16701       rtx tmp = operands[5];
16702       operands[5] = operands[4];
16703       operands[4] = tmp;
16704       PUT_CODE (operands[1], swap_condition (GET_CODE (operands[1])));
16705     }
16706   if (const0_operand (operands[2], GET_MODE (operands[0])))
16707     {
16708       operands[7] = operands[3];
16709       operands[6] = gen_rtx_NOT (TImode, gen_rtx_SUBREG (TImode, operands[0],
16710                                                          0));
16711     }
16712   else
16713     {
16714       operands[7] = operands[2];
16715       operands[6] = gen_rtx_SUBREG (TImode, operands[0], 0);
16716     }
16719 (define_expand "allocate_stack_worker"
16720   [(match_operand:SI 0 "register_operand" "")]
16721   "TARGET_STACK_PROBE"
16723   if (TARGET_64BIT)
16724     emit_insn (gen_allocate_stack_worker_rex64 (operands[0]));
16725   else
16726     emit_insn (gen_allocate_stack_worker_1 (operands[0]));
16727   DONE;
16730 (define_insn "allocate_stack_worker_1"
16731   [(unspec:SI [(match_operand:SI 0 "register_operand" "a")] UNSPEC_STACK_PROBE)
16732    (set (reg:SI 7) (minus:SI (reg:SI 7) (match_dup 0)))
16733    (clobber (match_dup 0))
16734    (clobber (reg:CC 17))]
16735   "!TARGET_64BIT && TARGET_STACK_PROBE"
16736   "call\t__alloca"
16737   [(set_attr "type" "multi")
16738    (set_attr "length" "5")])
16740 (define_insn "allocate_stack_worker_rex64"
16741   [(unspec:DI [(match_operand:DI 0 "register_operand" "a")] UNSPEC_STACK_PROBE)
16742    (set (reg:DI 7) (minus:DI (reg:DI 7) (match_dup 0)))
16743    (clobber (match_dup 0))
16744    (clobber (reg:CC 17))]
16745   "TARGET_64BIT && TARGET_STACK_PROBE"
16746   "call\t__alloca"
16747   [(set_attr "type" "multi")
16748    (set_attr "length" "5")])
16750 (define_expand "allocate_stack"
16751   [(parallel [(set (match_operand:SI 0 "register_operand" "=r")
16752                    (minus:SI (reg:SI 7)
16753                              (match_operand:SI 1 "general_operand" "")))
16754               (clobber (reg:CC 17))])
16755    (parallel [(set (reg:SI 7)
16756                    (minus:SI (reg:SI 7) (match_dup 1)))
16757               (clobber (reg:CC 17))])]
16758   "TARGET_STACK_PROBE"
16760 #ifdef CHECK_STACK_LIMIT
16761   if (GET_CODE (operands[1]) == CONST_INT
16762       && INTVAL (operands[1]) < CHECK_STACK_LIMIT)
16763     emit_insn (gen_subsi3 (stack_pointer_rtx, stack_pointer_rtx,
16764                            operands[1]));
16765   else 
16766 #endif
16767     emit_insn (gen_allocate_stack_worker (copy_to_mode_reg (SImode,
16768                                                             operands[1])));
16770   emit_move_insn (operands[0], virtual_stack_dynamic_rtx);
16771   DONE;
16774 (define_expand "builtin_setjmp_receiver"
16775   [(label_ref (match_operand 0 "" ""))]
16776   "!TARGET_64BIT && flag_pic"
16778   emit_insn (gen_set_got (pic_offset_table_rtx));
16779   DONE;
16782 ;; Avoid redundant prefixes by splitting HImode arithmetic to SImode.
16784 (define_split
16785   [(set (match_operand 0 "register_operand" "")
16786         (match_operator 3 "promotable_binary_operator"
16787            [(match_operand 1 "register_operand" "")
16788             (match_operand 2 "aligned_operand" "")]))
16789    (clobber (reg:CC 17))]
16790   "! TARGET_PARTIAL_REG_STALL && reload_completed
16791    && ((GET_MODE (operands[0]) == HImode 
16792         && ((!optimize_size && !TARGET_FAST_PREFIX)
16793             || GET_CODE (operands[2]) != CONST_INT
16794             || CONST_OK_FOR_LETTER_P (INTVAL (operands[2]), 'K')))
16795        || (GET_MODE (operands[0]) == QImode 
16796            && (TARGET_PROMOTE_QImode || optimize_size)))"
16797   [(parallel [(set (match_dup 0)
16798                    (match_op_dup 3 [(match_dup 1) (match_dup 2)]))
16799               (clobber (reg:CC 17))])]
16800   "operands[0] = gen_lowpart (SImode, operands[0]);
16801    operands[1] = gen_lowpart (SImode, operands[1]);
16802    if (GET_CODE (operands[3]) != ASHIFT)
16803      operands[2] = gen_lowpart (SImode, operands[2]);
16804    PUT_MODE (operands[3], SImode);")
16806 (define_split
16807   [(set (reg 17)
16808         (compare (and (match_operand 1 "aligned_operand" "")
16809                       (match_operand 2 "const_int_operand" ""))
16810                  (const_int 0)))
16811    (set (match_operand 0 "register_operand" "")
16812         (and (match_dup 1) (match_dup 2)))]
16813   "! TARGET_PARTIAL_REG_STALL && reload_completed
16814    && ix86_match_ccmode (insn, CCNOmode)
16815    && (GET_MODE (operands[0]) == HImode
16816        || (GET_MODE (operands[0]) == QImode 
16817            /* Ensure that the operand will remain sign extended immedaite.  */
16818            && INTVAL (operands[2]) >= 0
16819            && (TARGET_PROMOTE_QImode || optimize_size)))"
16820   [(parallel [(set (reg:CCNO 17)
16821                    (compare:CCNO (and:SI (match_dup 1) (match_dup 2))
16822                                  (const_int 0)))
16823               (set (match_dup 0)
16824                    (and:SI (match_dup 1) (match_dup 2)))])]
16825   "operands[2]
16826      = gen_int_mode (INTVAL (operands[2])
16827                      & GET_MODE_MASK (GET_MODE (operands[0])),
16828                      SImode);
16829    operands[0] = gen_lowpart (SImode, operands[0]);
16830    operands[1] = gen_lowpart (SImode, operands[1]);")
16832 ; Don't promote the QImode tests, as i386 don't have encoding of
16833 ; the test instruction with 32bit sign extended immediate and thus
16834 ; the code grows.
16835 (define_split
16836   [(set (reg 17)
16837         (compare (and (match_operand:HI 0 "aligned_operand" "")
16838                       (match_operand:HI 1 "const_int_operand" ""))
16839                  (const_int 0)))]
16840   "! TARGET_PARTIAL_REG_STALL && reload_completed
16841    && ix86_match_ccmode (insn, CCNOmode)
16842    && GET_MODE (operands[0]) == HImode"
16843   [(set (reg:CCNO 17)
16844         (compare:CCNO (and:SI (match_dup 0) (match_dup 1))
16845                       (const_int 0)))]
16846   "operands[1]
16847      = gen_int_mode (INTVAL (operands[1])
16848                      & GET_MODE_MASK (GET_MODE (operands[0])),
16849                      SImode);
16850    operands[0] = gen_lowpart (SImode, operands[0]);")
16852 (define_split
16853   [(set (match_operand 0 "register_operand" "")
16854         (neg (match_operand 1 "register_operand" "")))
16855    (clobber (reg:CC 17))]
16856   "! TARGET_PARTIAL_REG_STALL && reload_completed
16857    && (GET_MODE (operands[0]) == HImode
16858        || (GET_MODE (operands[0]) == QImode 
16859            && (TARGET_PROMOTE_QImode || optimize_size)))"
16860   [(parallel [(set (match_dup 0)
16861                    (neg:SI (match_dup 1)))
16862               (clobber (reg:CC 17))])]
16863   "operands[0] = gen_lowpart (SImode, operands[0]);
16864    operands[1] = gen_lowpart (SImode, operands[1]);")
16866 (define_split
16867   [(set (match_operand 0 "register_operand" "")
16868         (not (match_operand 1 "register_operand" "")))]
16869   "! TARGET_PARTIAL_REG_STALL && reload_completed
16870    && (GET_MODE (operands[0]) == HImode
16871        || (GET_MODE (operands[0]) == QImode 
16872            && (TARGET_PROMOTE_QImode || optimize_size)))"
16873   [(set (match_dup 0)
16874         (not:SI (match_dup 1)))]
16875   "operands[0] = gen_lowpart (SImode, operands[0]);
16876    operands[1] = gen_lowpart (SImode, operands[1]);")
16878 (define_split 
16879   [(set (match_operand 0 "register_operand" "")
16880         (if_then_else (match_operator 1 "comparison_operator" 
16881                                 [(reg 17) (const_int 0)])
16882                       (match_operand 2 "register_operand" "")
16883                       (match_operand 3 "register_operand" "")))]
16884   "! TARGET_PARTIAL_REG_STALL && TARGET_CMOVE
16885    && (GET_MODE (operands[0]) == HImode
16886        || (GET_MODE (operands[0]) == QImode 
16887            && (TARGET_PROMOTE_QImode || optimize_size)))"
16888   [(set (match_dup 0)
16889         (if_then_else:SI (match_dup 1) (match_dup 2) (match_dup 3)))]
16890   "operands[0] = gen_lowpart (SImode, operands[0]);
16891    operands[2] = gen_lowpart (SImode, operands[2]);
16892    operands[3] = gen_lowpart (SImode, operands[3]);")
16893                         
16895 ;; RTL Peephole optimizations, run before sched2.  These primarily look to
16896 ;; transform a complex memory operation into two memory to register operations.
16898 ;; Don't push memory operands
16899 (define_peephole2
16900   [(set (match_operand:SI 0 "push_operand" "")
16901         (match_operand:SI 1 "memory_operand" ""))
16902    (match_scratch:SI 2 "r")]
16903   "! optimize_size && ! TARGET_PUSH_MEMORY"
16904   [(set (match_dup 2) (match_dup 1))
16905    (set (match_dup 0) (match_dup 2))]
16906   "")
16908 (define_peephole2
16909   [(set (match_operand:DI 0 "push_operand" "")
16910         (match_operand:DI 1 "memory_operand" ""))
16911    (match_scratch:DI 2 "r")]
16912   "! optimize_size && ! TARGET_PUSH_MEMORY"
16913   [(set (match_dup 2) (match_dup 1))
16914    (set (match_dup 0) (match_dup 2))]
16915   "")
16917 ;; We need to handle SFmode only, because DFmode and XFmode is split to
16918 ;; SImode pushes.
16919 (define_peephole2
16920   [(set (match_operand:SF 0 "push_operand" "")
16921         (match_operand:SF 1 "memory_operand" ""))
16922    (match_scratch:SF 2 "r")]
16923   "! optimize_size && ! TARGET_PUSH_MEMORY"
16924   [(set (match_dup 2) (match_dup 1))
16925    (set (match_dup 0) (match_dup 2))]
16926   "")
16928 (define_peephole2
16929   [(set (match_operand:HI 0 "push_operand" "")
16930         (match_operand:HI 1 "memory_operand" ""))
16931    (match_scratch:HI 2 "r")]
16932   "! optimize_size && ! TARGET_PUSH_MEMORY"
16933   [(set (match_dup 2) (match_dup 1))
16934    (set (match_dup 0) (match_dup 2))]
16935   "")
16937 (define_peephole2
16938   [(set (match_operand:QI 0 "push_operand" "")
16939         (match_operand:QI 1 "memory_operand" ""))
16940    (match_scratch:QI 2 "q")]
16941   "! optimize_size && ! TARGET_PUSH_MEMORY"
16942   [(set (match_dup 2) (match_dup 1))
16943    (set (match_dup 0) (match_dup 2))]
16944   "")
16946 ;; Don't move an immediate directly to memory when the instruction
16947 ;; gets too big.
16948 (define_peephole2
16949   [(match_scratch:SI 1 "r")
16950    (set (match_operand:SI 0 "memory_operand" "")
16951         (const_int 0))]
16952   "! optimize_size
16953    && ! TARGET_USE_MOV0
16954    && TARGET_SPLIT_LONG_MOVES
16955    && get_attr_length (insn) >= ix86_cost->large_insn
16956    && peep2_regno_dead_p (0, FLAGS_REG)"
16957   [(parallel [(set (match_dup 1) (const_int 0))
16958               (clobber (reg:CC 17))])
16959    (set (match_dup 0) (match_dup 1))]
16960   "")
16962 (define_peephole2
16963   [(match_scratch:HI 1 "r")
16964    (set (match_operand:HI 0 "memory_operand" "")
16965         (const_int 0))]
16966   "! optimize_size
16967    && ! TARGET_USE_MOV0
16968    && TARGET_SPLIT_LONG_MOVES
16969    && get_attr_length (insn) >= ix86_cost->large_insn
16970    && peep2_regno_dead_p (0, FLAGS_REG)"
16971   [(parallel [(set (match_dup 2) (const_int 0))
16972               (clobber (reg:CC 17))])
16973    (set (match_dup 0) (match_dup 1))]
16974   "operands[2] = gen_rtx_REG (SImode, true_regnum (operands[1]));")
16976 (define_peephole2
16977   [(match_scratch:QI 1 "q")
16978    (set (match_operand:QI 0 "memory_operand" "")
16979         (const_int 0))]
16980   "! optimize_size
16981    && ! TARGET_USE_MOV0
16982    && TARGET_SPLIT_LONG_MOVES
16983    && get_attr_length (insn) >= ix86_cost->large_insn
16984    && peep2_regno_dead_p (0, FLAGS_REG)"
16985   [(parallel [(set (match_dup 2) (const_int 0))
16986               (clobber (reg:CC 17))])
16987    (set (match_dup 0) (match_dup 1))]
16988   "operands[2] = gen_rtx_REG (SImode, true_regnum (operands[1]));")
16990 (define_peephole2
16991   [(match_scratch:SI 2 "r")
16992    (set (match_operand:SI 0 "memory_operand" "")
16993         (match_operand:SI 1 "immediate_operand" ""))]
16994   "! optimize_size
16995    && get_attr_length (insn) >= ix86_cost->large_insn
16996    && TARGET_SPLIT_LONG_MOVES"
16997   [(set (match_dup 2) (match_dup 1))
16998    (set (match_dup 0) (match_dup 2))]
16999   "")
17001 (define_peephole2
17002   [(match_scratch:HI 2 "r")
17003    (set (match_operand:HI 0 "memory_operand" "")
17004         (match_operand:HI 1 "immediate_operand" ""))]
17005   "! optimize_size && get_attr_length (insn) >= ix86_cost->large_insn
17006   && TARGET_SPLIT_LONG_MOVES"
17007   [(set (match_dup 2) (match_dup 1))
17008    (set (match_dup 0) (match_dup 2))]
17009   "")
17011 (define_peephole2
17012   [(match_scratch:QI 2 "q")
17013    (set (match_operand:QI 0 "memory_operand" "")
17014         (match_operand:QI 1 "immediate_operand" ""))]
17015   "! optimize_size && get_attr_length (insn) >= ix86_cost->large_insn
17016   && TARGET_SPLIT_LONG_MOVES"
17017   [(set (match_dup 2) (match_dup 1))
17018    (set (match_dup 0) (match_dup 2))]
17019   "")
17021 ;; Don't compare memory with zero, load and use a test instead.
17022 (define_peephole2
17023   [(set (reg 17)
17024         (compare (match_operand:SI 0 "memory_operand" "")
17025                  (const_int 0)))
17026    (match_scratch:SI 3 "r")]
17027   "ix86_match_ccmode (insn, CCNOmode) && ! optimize_size"
17028   [(set (match_dup 3) (match_dup 0))
17029    (set (reg:CCNO 17) (compare:CCNO (match_dup 3) (const_int 0)))]
17030   "")
17032 ;; NOT is not pairable on Pentium, while XOR is, but one byte longer. 
17033 ;; Don't split NOTs with a displacement operand, because resulting XOR
17034 ;; will not be pariable anyway.
17036 ;; On AMD K6, NOT is vector decoded with memory operand that can not be
17037 ;; represented using a modRM byte.  The XOR replacement is long decoded,
17038 ;; so this split helps here as well.
17040 ;; Note: Can't do this as a regular split because we can't get proper
17041 ;; lifetime information then.
17043 (define_peephole2
17044   [(set (match_operand:SI 0 "nonimmediate_operand" "")
17045         (not:SI (match_operand:SI 1 "nonimmediate_operand" "")))]
17046   "!optimize_size
17047    && peep2_regno_dead_p (0, FLAGS_REG)
17048    && ((TARGET_PENTIUM 
17049         && (GET_CODE (operands[0]) != MEM
17050             || !memory_displacement_operand (operands[0], SImode)))
17051        || (TARGET_K6 && long_memory_operand (operands[0], SImode)))"
17052   [(parallel [(set (match_dup 0)
17053                    (xor:SI (match_dup 1) (const_int -1)))
17054               (clobber (reg:CC 17))])]
17055   "")
17057 (define_peephole2
17058   [(set (match_operand:HI 0 "nonimmediate_operand" "")
17059         (not:HI (match_operand:HI 1 "nonimmediate_operand" "")))]
17060   "!optimize_size
17061    && peep2_regno_dead_p (0, FLAGS_REG)
17062    && ((TARGET_PENTIUM 
17063         && (GET_CODE (operands[0]) != MEM
17064             || !memory_displacement_operand (operands[0], HImode)))
17065        || (TARGET_K6 && long_memory_operand (operands[0], HImode)))"
17066   [(parallel [(set (match_dup 0)
17067                    (xor:HI (match_dup 1) (const_int -1)))
17068               (clobber (reg:CC 17))])]
17069   "")
17071 (define_peephole2
17072   [(set (match_operand:QI 0 "nonimmediate_operand" "")
17073         (not:QI (match_operand:QI 1 "nonimmediate_operand" "")))]
17074   "!optimize_size
17075    && peep2_regno_dead_p (0, FLAGS_REG)
17076    && ((TARGET_PENTIUM 
17077         && (GET_CODE (operands[0]) != MEM
17078             || !memory_displacement_operand (operands[0], QImode)))
17079        || (TARGET_K6 && long_memory_operand (operands[0], QImode)))"
17080   [(parallel [(set (match_dup 0)
17081                    (xor:QI (match_dup 1) (const_int -1)))
17082               (clobber (reg:CC 17))])]
17083   "")
17085 ;; Non pairable "test imm, reg" instructions can be translated to
17086 ;; "and imm, reg" if reg dies.  The "and" form is also shorter (one
17087 ;; byte opcode instead of two, have a short form for byte operands),
17088 ;; so do it for other CPUs as well.  Given that the value was dead,
17089 ;; this should not create any new dependencies.  Pass on the sub-word
17090 ;; versions if we're concerned about partial register stalls.
17092 (define_peephole2
17093   [(set (reg 17)
17094         (compare (and:SI (match_operand:SI 0 "register_operand" "")
17095                          (match_operand:SI 1 "immediate_operand" ""))
17096                  (const_int 0)))]
17097   "ix86_match_ccmode (insn, CCNOmode)
17098    && (true_regnum (operands[0]) != 0
17099        || (GET_CODE (operands[1]) == CONST_INT
17100            && CONST_OK_FOR_LETTER_P (INTVAL (operands[1]), 'K')))
17101    && find_regno_note (insn, REG_DEAD, true_regnum (operands[0]))"
17102   [(parallel
17103      [(set (reg:CCNO 17)
17104            (compare:CCNO (and:SI (match_dup 0)
17105                                  (match_dup 1))
17106                          (const_int 0)))
17107       (set (match_dup 0)
17108            (and:SI (match_dup 0) (match_dup 1)))])]
17109   "")
17111 ;; We don't need to handle HImode case, because it will be promoted to SImode
17112 ;; on ! TARGET_PARTIAL_REG_STALL
17114 (define_peephole2
17115   [(set (reg 17)
17116         (compare (and:QI (match_operand:QI 0 "register_operand" "")
17117                          (match_operand:QI 1 "immediate_operand" ""))
17118                  (const_int 0)))]
17119   "! TARGET_PARTIAL_REG_STALL
17120    && ix86_match_ccmode (insn, CCNOmode)
17121    && true_regnum (operands[0]) != 0
17122    && find_regno_note (insn, REG_DEAD, true_regnum (operands[0]))"
17123   [(parallel
17124      [(set (reg:CCNO 17)
17125            (compare:CCNO (and:QI (match_dup 0)
17126                                  (match_dup 1))
17127                          (const_int 0)))
17128       (set (match_dup 0)
17129            (and:QI (match_dup 0) (match_dup 1)))])]
17130   "")
17132 (define_peephole2
17133   [(set (reg 17)
17134         (compare
17135           (and:SI
17136             (zero_extract:SI
17137               (match_operand 0 "ext_register_operand" "")
17138               (const_int 8)
17139               (const_int 8))
17140             (match_operand 1 "const_int_operand" ""))
17141           (const_int 0)))]
17142   "! TARGET_PARTIAL_REG_STALL
17143    && ix86_match_ccmode (insn, CCNOmode)
17144    && true_regnum (operands[0]) != 0
17145    && find_regno_note (insn, REG_DEAD, true_regnum (operands[0]))"
17146   [(parallel [(set (reg:CCNO 17)
17147                    (compare:CCNO
17148                        (and:SI
17149                          (zero_extract:SI
17150                          (match_dup 0)
17151                          (const_int 8)
17152                          (const_int 8))
17153                         (match_dup 1))
17154                    (const_int 0)))
17155               (set (zero_extract:SI (match_dup 0)
17156                                     (const_int 8)
17157                                     (const_int 8))
17158                    (and:SI 
17159                      (zero_extract:SI
17160                        (match_dup 0)
17161                        (const_int 8)
17162                        (const_int 8))
17163                      (match_dup 1)))])]
17164   "")
17166 ;; Don't do logical operations with memory inputs.
17167 (define_peephole2
17168   [(match_scratch:SI 2 "r")
17169    (parallel [(set (match_operand:SI 0 "register_operand" "")
17170                    (match_operator:SI 3 "arith_or_logical_operator"
17171                      [(match_dup 0)
17172                       (match_operand:SI 1 "memory_operand" "")]))
17173               (clobber (reg:CC 17))])]
17174   "! optimize_size && ! TARGET_READ_MODIFY"
17175   [(set (match_dup 2) (match_dup 1))
17176    (parallel [(set (match_dup 0)
17177                    (match_op_dup 3 [(match_dup 0) (match_dup 2)]))
17178               (clobber (reg:CC 17))])]
17179   "")
17181 (define_peephole2
17182   [(match_scratch:SI 2 "r")
17183    (parallel [(set (match_operand:SI 0 "register_operand" "")
17184                    (match_operator:SI 3 "arith_or_logical_operator"
17185                      [(match_operand:SI 1 "memory_operand" "")
17186                       (match_dup 0)]))
17187               (clobber (reg:CC 17))])]
17188   "! optimize_size && ! TARGET_READ_MODIFY"
17189   [(set (match_dup 2) (match_dup 1))
17190    (parallel [(set (match_dup 0)
17191                    (match_op_dup 3 [(match_dup 2) (match_dup 0)]))
17192               (clobber (reg:CC 17))])]
17193   "")
17195 ; Don't do logical operations with memory outputs
17197 ; These two don't make sense for PPro/PII -- we're expanding a 4-uop
17198 ; instruction into two 1-uop insns plus a 2-uop insn.  That last has
17199 ; the same decoder scheduling characteristics as the original.
17201 (define_peephole2
17202   [(match_scratch:SI 2 "r")
17203    (parallel [(set (match_operand:SI 0 "memory_operand" "")
17204                    (match_operator:SI 3 "arith_or_logical_operator"
17205                      [(match_dup 0)
17206                       (match_operand:SI 1 "nonmemory_operand" "")]))
17207               (clobber (reg:CC 17))])]
17208   "! optimize_size && ! TARGET_READ_MODIFY_WRITE"
17209   [(set (match_dup 2) (match_dup 0))
17210    (parallel [(set (match_dup 2)
17211                    (match_op_dup 3 [(match_dup 2) (match_dup 1)]))
17212               (clobber (reg:CC 17))])
17213    (set (match_dup 0) (match_dup 2))]
17214   "")
17216 (define_peephole2
17217   [(match_scratch:SI 2 "r")
17218    (parallel [(set (match_operand:SI 0 "memory_operand" "")
17219                    (match_operator:SI 3 "arith_or_logical_operator"
17220                      [(match_operand:SI 1 "nonmemory_operand" "")
17221                       (match_dup 0)]))
17222               (clobber (reg:CC 17))])]
17223   "! optimize_size && ! TARGET_READ_MODIFY_WRITE"
17224   [(set (match_dup 2) (match_dup 0))
17225    (parallel [(set (match_dup 2)
17226                    (match_op_dup 3 [(match_dup 1) (match_dup 2)]))
17227               (clobber (reg:CC 17))])
17228    (set (match_dup 0) (match_dup 2))]
17229   "")
17231 ;; Attempt to always use XOR for zeroing registers.
17232 (define_peephole2
17233   [(set (match_operand 0 "register_operand" "")
17234         (const_int 0))]
17235   "(GET_MODE (operands[0]) == QImode
17236     || GET_MODE (operands[0]) == HImode
17237     || GET_MODE (operands[0]) == SImode
17238     || (GET_MODE (operands[0]) == DImode && TARGET_64BIT))
17239    && (! TARGET_USE_MOV0 || optimize_size)
17240    && peep2_regno_dead_p (0, FLAGS_REG)"
17241   [(parallel [(set (match_dup 0) (const_int 0))
17242               (clobber (reg:CC 17))])]
17243   "operands[0] = gen_rtx_REG (GET_MODE (operands[0]) == DImode ? DImode : SImode,
17244                               true_regnum (operands[0]));")
17246 (define_peephole2
17247   [(set (strict_low_part (match_operand 0 "register_operand" ""))
17248         (const_int 0))]
17249   "(GET_MODE (operands[0]) == QImode
17250     || GET_MODE (operands[0]) == HImode)
17251    && (! TARGET_USE_MOV0 || optimize_size)
17252    && peep2_regno_dead_p (0, FLAGS_REG)"
17253   [(parallel [(set (strict_low_part (match_dup 0)) (const_int 0))
17254               (clobber (reg:CC 17))])])
17256 ;; For HI and SI modes, or $-1,reg is smaller than mov $-1,reg.
17257 (define_peephole2
17258   [(set (match_operand 0 "register_operand" "")
17259         (const_int -1))]
17260   "(GET_MODE (operands[0]) == HImode
17261     || GET_MODE (operands[0]) == SImode 
17262     || (GET_MODE (operands[0]) == DImode && TARGET_64BIT))
17263    && (optimize_size || TARGET_PENTIUM)
17264    && peep2_regno_dead_p (0, FLAGS_REG)"
17265   [(parallel [(set (match_dup 0) (const_int -1))
17266               (clobber (reg:CC 17))])]
17267   "operands[0] = gen_rtx_REG (GET_MODE (operands[0]) == DImode ? DImode : SImode,
17268                               true_regnum (operands[0]));")
17270 ;; Attempt to convert simple leas to adds. These can be created by
17271 ;; move expanders.
17272 (define_peephole2
17273   [(set (match_operand:SI 0 "register_operand" "")
17274         (plus:SI (match_dup 0)
17275                  (match_operand:SI 1 "nonmemory_operand" "")))]
17276   "peep2_regno_dead_p (0, FLAGS_REG)"
17277   [(parallel [(set (match_dup 0) (plus:SI (match_dup 0) (match_dup 1)))
17278               (clobber (reg:CC 17))])]
17279   "")
17281 (define_peephole2
17282   [(set (match_operand:SI 0 "register_operand" "")
17283         (subreg:SI (plus:DI (match_operand:DI 1 "register_operand" "")
17284                             (match_operand:DI 2 "nonmemory_operand" "")) 0))]
17285   "peep2_regno_dead_p (0, FLAGS_REG) && REGNO (operands[0]) == REGNO (operands[1])"
17286   [(parallel [(set (match_dup 0) (plus:SI (match_dup 0) (match_dup 2)))
17287               (clobber (reg:CC 17))])]
17288   "operands[2] = gen_lowpart (SImode, operands[2]);")
17290 (define_peephole2
17291   [(set (match_operand:DI 0 "register_operand" "")
17292         (plus:DI (match_dup 0)
17293                  (match_operand:DI 1 "x86_64_general_operand" "")))]
17294   "peep2_regno_dead_p (0, FLAGS_REG)"
17295   [(parallel [(set (match_dup 0) (plus:DI (match_dup 0) (match_dup 1)))
17296               (clobber (reg:CC 17))])]
17297   "")
17299 (define_peephole2
17300   [(set (match_operand:SI 0 "register_operand" "")
17301         (mult:SI (match_dup 0)
17302                  (match_operand:SI 1 "const_int_operand" "")))]
17303   "exact_log2 (INTVAL (operands[1])) >= 0
17304    && peep2_regno_dead_p (0, FLAGS_REG)"
17305   [(parallel [(set (match_dup 0) (ashift:SI (match_dup 0) (match_dup 2)))
17306               (clobber (reg:CC 17))])]
17307   "operands[2] = GEN_INT (exact_log2 (INTVAL (operands[1])));")
17309 (define_peephole2
17310   [(set (match_operand:DI 0 "register_operand" "")
17311         (mult:DI (match_dup 0)
17312                  (match_operand:DI 1 "const_int_operand" "")))]
17313   "exact_log2 (INTVAL (operands[1])) >= 0
17314    && peep2_regno_dead_p (0, FLAGS_REG)"
17315   [(parallel [(set (match_dup 0) (ashift:DI (match_dup 0) (match_dup 2)))
17316               (clobber (reg:CC 17))])]
17317   "operands[2] = GEN_INT (exact_log2 (INTVAL (operands[1])));")
17319 (define_peephole2
17320   [(set (match_operand:SI 0 "register_operand" "")
17321         (subreg:SI (mult:DI (match_operand:DI 1 "register_operand" "")
17322                    (match_operand:DI 2 "const_int_operand" "")) 0))]
17323   "exact_log2 (INTVAL (operands[1])) >= 0
17324    && REGNO (operands[0]) == REGNO (operands[1])
17325    && peep2_regno_dead_p (0, FLAGS_REG)"
17326   [(parallel [(set (match_dup 0) (ashift:SI (match_dup 0) (match_dup 2)))
17327               (clobber (reg:CC 17))])]
17328   "operands[2] = GEN_INT (exact_log2 (INTVAL (operands[2])));")
17330 ;; The ESP adjustments can be done by the push and pop instructions.  Resulting
17331 ;; code is shorter, since push is only 1 byte, while add imm, %esp 3 bytes.  On
17332 ;; many CPUs it is also faster, since special hardware to avoid esp
17333 ;; dependencies is present.
17335 ;; While some of these conversions may be done using splitters, we use peepholes
17336 ;; in order to allow combine_stack_adjustments pass to see nonobfuscated RTL.
17338 ;; Convert prologue esp subtractions to push.
17339 ;; We need register to push.  In order to keep verify_flow_info happy we have
17340 ;; two choices
17341 ;; - use scratch and clobber it in order to avoid dependencies
17342 ;; - use already live register
17343 ;; We can't use the second way right now, since there is no reliable way how to
17344 ;; verify that given register is live.  First choice will also most likely in
17345 ;; fewer dependencies.  On the place of esp adjustments it is very likely that
17346 ;; call clobbered registers are dead.  We may want to use base pointer as an
17347 ;; alternative when no register is available later.
17349 (define_peephole2
17350   [(match_scratch:SI 0 "r")
17351    (parallel [(set (reg:SI 7) (plus:SI (reg:SI 7) (const_int -4)))
17352               (clobber (reg:CC 17))
17353               (clobber (mem:BLK (scratch)))])]
17354   "optimize_size || !TARGET_SUB_ESP_4"
17355   [(clobber (match_dup 0))
17356    (parallel [(set (mem:SI (pre_dec:SI (reg:SI 7))) (match_dup 0))
17357               (clobber (mem:BLK (scratch)))])])
17359 (define_peephole2
17360   [(match_scratch:SI 0 "r")
17361    (parallel [(set (reg:SI 7) (plus:SI (reg:SI 7) (const_int -8)))
17362               (clobber (reg:CC 17))
17363               (clobber (mem:BLK (scratch)))])]
17364   "optimize_size || !TARGET_SUB_ESP_8"
17365   [(clobber (match_dup 0))
17366    (set (mem:SI (pre_dec:SI (reg:SI 7))) (match_dup 0))
17367    (parallel [(set (mem:SI (pre_dec:SI (reg:SI 7))) (match_dup 0))
17368               (clobber (mem:BLK (scratch)))])])
17370 ;; Convert esp subtractions to push.
17371 (define_peephole2
17372   [(match_scratch:SI 0 "r")
17373    (parallel [(set (reg:SI 7) (plus:SI (reg:SI 7) (const_int -4)))
17374               (clobber (reg:CC 17))])]
17375   "optimize_size || !TARGET_SUB_ESP_4"
17376   [(clobber (match_dup 0))
17377    (set (mem:SI (pre_dec:SI (reg:SI 7))) (match_dup 0))])
17379 (define_peephole2
17380   [(match_scratch:SI 0 "r")
17381    (parallel [(set (reg:SI 7) (plus:SI (reg:SI 7) (const_int -8)))
17382               (clobber (reg:CC 17))])]
17383   "optimize_size || !TARGET_SUB_ESP_8"
17384   [(clobber (match_dup 0))
17385    (set (mem:SI (pre_dec:SI (reg:SI 7))) (match_dup 0))
17386    (set (mem:SI (pre_dec:SI (reg:SI 7))) (match_dup 0))])
17388 ;; Convert epilogue deallocator to pop.
17389 (define_peephole2
17390   [(match_scratch:SI 0 "r")
17391    (parallel [(set (reg:SI 7) (plus:SI (reg:SI 7) (const_int 4)))
17392               (clobber (reg:CC 17))
17393               (clobber (mem:BLK (scratch)))])]
17394   "optimize_size || !TARGET_ADD_ESP_4"
17395   [(parallel [(set (match_dup 0) (mem:SI (reg:SI 7)))
17396               (set (reg:SI 7) (plus:SI (reg:SI 7) (const_int 4)))
17397               (clobber (mem:BLK (scratch)))])]
17398   "")
17400 ;; Two pops case is tricky, since pop causes dependency on destination register.
17401 ;; We use two registers if available.
17402 (define_peephole2
17403   [(match_scratch:SI 0 "r")
17404    (match_scratch:SI 1 "r")
17405    (parallel [(set (reg:SI 7) (plus:SI (reg:SI 7) (const_int 8)))
17406               (clobber (reg:CC 17))
17407               (clobber (mem:BLK (scratch)))])]
17408   "optimize_size || !TARGET_ADD_ESP_8"
17409   [(parallel [(set (match_dup 0) (mem:SI (reg:SI 7)))
17410               (set (reg:SI 7) (plus:SI (reg:SI 7) (const_int 4)))
17411               (clobber (mem:BLK (scratch)))])
17412    (parallel [(set (match_dup 1) (mem:SI (reg:SI 7)))
17413               (set (reg:SI 7) (plus:SI (reg:SI 7) (const_int 4)))])]
17414   "")
17416 (define_peephole2
17417   [(match_scratch:SI 0 "r")
17418    (parallel [(set (reg:SI 7) (plus:SI (reg:SI 7) (const_int 8)))
17419               (clobber (reg:CC 17))
17420               (clobber (mem:BLK (scratch)))])]
17421   "optimize_size"
17422   [(parallel [(set (match_dup 0) (mem:SI (reg:SI 7)))
17423               (set (reg:SI 7) (plus:SI (reg:SI 7) (const_int 4)))
17424               (clobber (mem:BLK (scratch)))])
17425    (parallel [(set (match_dup 0) (mem:SI (reg:SI 7)))
17426               (set (reg:SI 7) (plus:SI (reg:SI 7) (const_int 4)))])]
17427   "")
17429 ;; Convert esp additions to pop.
17430 (define_peephole2
17431   [(match_scratch:SI 0 "r")
17432    (parallel [(set (reg:SI 7) (plus:SI (reg:SI 7) (const_int 4)))
17433               (clobber (reg:CC 17))])]
17434   ""
17435   [(parallel [(set (match_dup 0) (mem:SI (reg:SI 7)))
17436               (set (reg:SI 7) (plus:SI (reg:SI 7) (const_int 4)))])]
17437   "")
17439 ;; Two pops case is tricky, since pop causes dependency on destination register.
17440 ;; We use two registers if available.
17441 (define_peephole2
17442   [(match_scratch:SI 0 "r")
17443    (match_scratch:SI 1 "r")
17444    (parallel [(set (reg:SI 7) (plus:SI (reg:SI 7) (const_int 8)))
17445               (clobber (reg:CC 17))])]
17446   ""
17447   [(parallel [(set (match_dup 0) (mem:SI (reg:SI 7)))
17448               (set (reg:SI 7) (plus:SI (reg:SI 7) (const_int 4)))])
17449    (parallel [(set (match_dup 1) (mem:SI (reg:SI 7)))
17450               (set (reg:SI 7) (plus:SI (reg:SI 7) (const_int 4)))])]
17451   "")
17453 (define_peephole2
17454   [(match_scratch:SI 0 "r")
17455    (parallel [(set (reg:SI 7) (plus:SI (reg:SI 7) (const_int 8)))
17456               (clobber (reg:CC 17))])]
17457   "optimize_size"
17458   [(parallel [(set (match_dup 0) (mem:SI (reg:SI 7)))
17459               (set (reg:SI 7) (plus:SI (reg:SI 7) (const_int 4)))])
17460    (parallel [(set (match_dup 0) (mem:SI (reg:SI 7)))
17461               (set (reg:SI 7) (plus:SI (reg:SI 7) (const_int 4)))])]
17462   "")
17464 ;; Convert compares with 1 to shorter inc/dec operations when CF is not
17465 ;; required and register dies.
17466 (define_peephole2
17467   [(set (reg 17)
17468         (compare (match_operand:SI 0 "register_operand" "")
17469                  (match_operand:SI 1 "incdec_operand" "")))]
17470   "ix86_match_ccmode (insn, CCGCmode)
17471    && find_regno_note (insn, REG_DEAD, true_regnum (operands[0]))"
17472   [(parallel [(set (reg:CCGC 17)
17473                    (compare:CCGC (match_dup 0)
17474                                  (match_dup 1)))
17475               (clobber (match_dup 0))])]
17476   "")
17478 (define_peephole2
17479   [(set (reg 17)
17480         (compare (match_operand:HI 0 "register_operand" "")
17481                  (match_operand:HI 1 "incdec_operand" "")))]
17482   "ix86_match_ccmode (insn, CCGCmode)
17483    && find_regno_note (insn, REG_DEAD, true_regnum (operands[0]))"
17484   [(parallel [(set (reg:CCGC 17)
17485                    (compare:CCGC (match_dup 0)
17486                                  (match_dup 1)))
17487               (clobber (match_dup 0))])]
17488   "")
17490 (define_peephole2
17491   [(set (reg 17)
17492         (compare (match_operand:QI 0 "register_operand" "")
17493                  (match_operand:QI 1 "incdec_operand" "")))]
17494   "ix86_match_ccmode (insn, CCGCmode)
17495    && find_regno_note (insn, REG_DEAD, true_regnum (operands[0]))"
17496   [(parallel [(set (reg:CCGC 17)
17497                    (compare:CCGC (match_dup 0)
17498                                  (match_dup 1)))
17499               (clobber (match_dup 0))])]
17500   "")
17502 ;; Convert compares with 128 to shorter add -128
17503 (define_peephole2
17504   [(set (reg 17)
17505         (compare (match_operand:SI 0 "register_operand" "")
17506                  (const_int 128)))]
17507   "ix86_match_ccmode (insn, CCGCmode)
17508    && find_regno_note (insn, REG_DEAD, true_regnum (operands[0]))"
17509   [(parallel [(set (reg:CCGC 17)
17510                    (compare:CCGC (match_dup 0)
17511                                  (const_int 128)))
17512               (clobber (match_dup 0))])]
17513   "")
17515 (define_peephole2
17516   [(set (reg 17)
17517         (compare (match_operand:HI 0 "register_operand" "")
17518                  (const_int 128)))]
17519   "ix86_match_ccmode (insn, CCGCmode)
17520    && find_regno_note (insn, REG_DEAD, true_regnum (operands[0]))"
17521   [(parallel [(set (reg:CCGC 17)
17522                    (compare:CCGC (match_dup 0)
17523                                  (const_int 128)))
17524               (clobber (match_dup 0))])]
17525   "")
17527 (define_peephole2
17528   [(match_scratch:DI 0 "r")
17529    (parallel [(set (reg:DI 7) (plus:DI (reg:DI 7) (const_int -8)))
17530               (clobber (reg:CC 17))
17531               (clobber (mem:BLK (scratch)))])]
17532   "optimize_size || !TARGET_SUB_ESP_4"
17533   [(clobber (match_dup 0))
17534    (parallel [(set (mem:DI (pre_dec:DI (reg:DI 7))) (match_dup 0))
17535               (clobber (mem:BLK (scratch)))])])
17537 (define_peephole2
17538   [(match_scratch:DI 0 "r")
17539    (parallel [(set (reg:DI 7) (plus:DI (reg:DI 7) (const_int -16)))
17540               (clobber (reg:CC 17))
17541               (clobber (mem:BLK (scratch)))])]
17542   "optimize_size || !TARGET_SUB_ESP_8"
17543   [(clobber (match_dup 0))
17544    (set (mem:DI (pre_dec:DI (reg:DI 7))) (match_dup 0))
17545    (parallel [(set (mem:DI (pre_dec:DI (reg:DI 7))) (match_dup 0))
17546               (clobber (mem:BLK (scratch)))])])
17548 ;; Convert esp subtractions to push.
17549 (define_peephole2
17550   [(match_scratch:DI 0 "r")
17551    (parallel [(set (reg:DI 7) (plus:DI (reg:DI 7) (const_int -8)))
17552               (clobber (reg:CC 17))])]
17553   "optimize_size || !TARGET_SUB_ESP_4"
17554   [(clobber (match_dup 0))
17555    (set (mem:DI (pre_dec:DI (reg:DI 7))) (match_dup 0))])
17557 (define_peephole2
17558   [(match_scratch:DI 0 "r")
17559    (parallel [(set (reg:DI 7) (plus:DI (reg:DI 7) (const_int -16)))
17560               (clobber (reg:CC 17))])]
17561   "optimize_size || !TARGET_SUB_ESP_8"
17562   [(clobber (match_dup 0))
17563    (set (mem:DI (pre_dec:DI (reg:DI 7))) (match_dup 0))
17564    (set (mem:DI (pre_dec:DI (reg:DI 7))) (match_dup 0))])
17566 ;; Convert epilogue deallocator to pop.
17567 (define_peephole2
17568   [(match_scratch:DI 0 "r")
17569    (parallel [(set (reg:DI 7) (plus:DI (reg:DI 7) (const_int 8)))
17570               (clobber (reg:CC 17))
17571               (clobber (mem:BLK (scratch)))])]
17572   "optimize_size || !TARGET_ADD_ESP_4"
17573   [(parallel [(set (match_dup 0) (mem:DI (reg:DI 7)))
17574               (set (reg:DI 7) (plus:DI (reg:DI 7) (const_int 8)))
17575               (clobber (mem:BLK (scratch)))])]
17576   "")
17578 ;; Two pops case is tricky, since pop causes dependency on destination register.
17579 ;; We use two registers if available.
17580 (define_peephole2
17581   [(match_scratch:DI 0 "r")
17582    (match_scratch:DI 1 "r")
17583    (parallel [(set (reg:DI 7) (plus:DI (reg:DI 7) (const_int 16)))
17584               (clobber (reg:CC 17))
17585               (clobber (mem:BLK (scratch)))])]
17586   "optimize_size || !TARGET_ADD_ESP_8"
17587   [(parallel [(set (match_dup 0) (mem:DI (reg:DI 7)))
17588               (set (reg:DI 7) (plus:DI (reg:DI 7) (const_int 8)))
17589               (clobber (mem:BLK (scratch)))])
17590    (parallel [(set (match_dup 1) (mem:DI (reg:DI 7)))
17591               (set (reg:DI 7) (plus:DI (reg:DI 7) (const_int 8)))])]
17592   "")
17594 (define_peephole2
17595   [(match_scratch:DI 0 "r")
17596    (parallel [(set (reg:DI 7) (plus:DI (reg:DI 7) (const_int 16)))
17597               (clobber (reg:CC 17))
17598               (clobber (mem:BLK (scratch)))])]
17599   "optimize_size"
17600   [(parallel [(set (match_dup 0) (mem:DI (reg:DI 7)))
17601               (set (reg:DI 7) (plus:DI (reg:DI 7) (const_int 8)))
17602               (clobber (mem:BLK (scratch)))])
17603    (parallel [(set (match_dup 0) (mem:DI (reg:DI 7)))
17604               (set (reg:DI 7) (plus:DI (reg:DI 7) (const_int 8)))])]
17605   "")
17607 ;; Convert esp additions to pop.
17608 (define_peephole2
17609   [(match_scratch:DI 0 "r")
17610    (parallel [(set (reg:DI 7) (plus:DI (reg:DI 7) (const_int 8)))
17611               (clobber (reg:CC 17))])]
17612   ""
17613   [(parallel [(set (match_dup 0) (mem:DI (reg:DI 7)))
17614               (set (reg:DI 7) (plus:DI (reg:DI 7) (const_int 8)))])]
17615   "")
17617 ;; Two pops case is tricky, since pop causes dependency on destination register.
17618 ;; We use two registers if available.
17619 (define_peephole2
17620   [(match_scratch:DI 0 "r")
17621    (match_scratch:DI 1 "r")
17622    (parallel [(set (reg:DI 7) (plus:DI (reg:DI 7) (const_int 16)))
17623               (clobber (reg:CC 17))])]
17624   ""
17625   [(parallel [(set (match_dup 0) (mem:DI (reg:DI 7)))
17626               (set (reg:DI 7) (plus:DI (reg:DI 7) (const_int 8)))])
17627    (parallel [(set (match_dup 1) (mem:DI (reg:DI 7)))
17628               (set (reg:DI 7) (plus:DI (reg:DI 7) (const_int 8)))])]
17629   "")
17631 (define_peephole2
17632   [(match_scratch:DI 0 "r")
17633    (parallel [(set (reg:DI 7) (plus:DI (reg:DI 7) (const_int 16)))
17634               (clobber (reg:CC 17))])]
17635   "optimize_size"
17636   [(parallel [(set (match_dup 0) (mem:DI (reg:DI 7)))
17637               (set (reg:DI 7) (plus:DI (reg:DI 7) (const_int 8)))])
17638    (parallel [(set (match_dup 0) (mem:DI (reg:DI 7)))
17639               (set (reg:DI 7) (plus:DI (reg:DI 7) (const_int 8)))])]
17640   "")
17642 ;; Call-value patterns last so that the wildcard operand does not
17643 ;; disrupt insn-recog's switch tables.
17645 (define_insn "*call_value_pop_0"
17646   [(set (match_operand 0 "" "")
17647         (call (mem:QI (match_operand:SI 1 "constant_call_address_operand" ""))
17648               (match_operand:SI 2 "" "")))
17649    (set (reg:SI 7) (plus:SI (reg:SI 7)
17650                             (match_operand:SI 3 "immediate_operand" "")))]
17651   "!TARGET_64BIT"
17653   if (SIBLING_CALL_P (insn))
17654     return "jmp\t%P1";
17655   else
17656     return "call\t%P1";
17658   [(set_attr "type" "callv")])
17660 (define_insn "*call_value_pop_1"
17661   [(set (match_operand 0 "" "")
17662         (call (mem:QI (match_operand:SI 1 "call_insn_operand" "rsm"))
17663               (match_operand:SI 2 "" "")))
17664    (set (reg:SI 7) (plus:SI (reg:SI 7)
17665                             (match_operand:SI 3 "immediate_operand" "i")))]
17666   "!TARGET_64BIT"
17668   if (constant_call_address_operand (operands[1], QImode))
17669     {
17670       if (SIBLING_CALL_P (insn))
17671         return "jmp\t%P1";
17672       else
17673         return "call\t%P1";
17674     }
17675   if (SIBLING_CALL_P (insn))
17676     return "jmp\t%A1";
17677   else
17678     return "call\t%A1";
17680   [(set_attr "type" "callv")])
17682 (define_insn "*call_value_0"
17683   [(set (match_operand 0 "" "")
17684         (call (mem:QI (match_operand:SI 1 "constant_call_address_operand" ""))
17685               (match_operand:SI 2 "" "")))]
17686   "!TARGET_64BIT"
17688   if (SIBLING_CALL_P (insn))
17689     return "jmp\t%P1";
17690   else
17691     return "call\t%P1";
17693   [(set_attr "type" "callv")])
17695 (define_insn "*call_value_0_rex64"
17696   [(set (match_operand 0 "" "")
17697         (call (mem:QI (match_operand:DI 1 "constant_call_address_operand" ""))
17698               (match_operand:DI 2 "const_int_operand" "")))]
17699   "TARGET_64BIT"
17701   if (SIBLING_CALL_P (insn))
17702     return "jmp\t%P1";
17703   else
17704     return "call\t%P1";
17706   [(set_attr "type" "callv")])
17708 (define_insn "*call_value_1"
17709   [(set (match_operand 0 "" "")
17710         (call (mem:QI (match_operand:SI 1 "call_insn_operand" "rsm"))
17711               (match_operand:SI 2 "" "")))]
17712   "!TARGET_64BIT"
17714   if (constant_call_address_operand (operands[1], QImode))
17715     {
17716       if (SIBLING_CALL_P (insn))
17717         return "jmp\t%P1";
17718       else
17719         return "call\t%P1";
17720     }
17721   if (SIBLING_CALL_P (insn))
17722     return "jmp\t%*%1";
17723   else
17724     return "call\t%*%1";
17726   [(set_attr "type" "callv")])
17728 (define_insn "*call_value_1_rex64"
17729   [(set (match_operand 0 "" "")
17730         (call (mem:QI (match_operand:DI 1 "call_insn_operand" "rsm"))
17731               (match_operand:DI 2 "" "")))]
17732   "TARGET_64BIT"
17734   if (constant_call_address_operand (operands[1], QImode))
17735     {
17736       if (SIBLING_CALL_P (insn))
17737         return "jmp\t%P1";
17738       else
17739         return "call\t%P1";
17740     }
17741   if (SIBLING_CALL_P (insn))
17742     return "jmp\t%A1";
17743   else
17744     return "call\t%A1";
17746   [(set_attr "type" "callv")])
17748 (define_insn "trap"
17749   [(trap_if (const_int 1) (const_int 5))]
17750   ""
17751   "int\t$5")
17753 ;;; ix86 doesn't have conditional trap instructions, but we fake them
17754 ;;; for the sake of bounds checking.  By emitting bounds checks as
17755 ;;; conditional traps rather than as conditional jumps around
17756 ;;; unconditional traps we avoid introducing spurious basic-block
17757 ;;; boundaries and facilitate elimination of redundant checks.  In
17758 ;;; honor of the too-inflexible-for-BPs `bound' instruction, we use
17759 ;;; interrupt 5.
17760 ;;; 
17761 ;;; FIXME: Static branch prediction rules for ix86 are such that
17762 ;;; forward conditional branches predict as untaken.  As implemented
17763 ;;; below, pseudo conditional traps violate that rule.  We should use
17764 ;;; .pushsection/.popsection to place all of the `int 5's in a special
17765 ;;; section loaded at the end of the text segment and branch forward
17766 ;;; there on bounds-failure, and then jump back immediately (in case
17767 ;;; the system chooses to ignore bounds violations, or to report
17768 ;;; violations and continue execution).
17770 (define_expand "conditional_trap"
17771   [(trap_if (match_operator 0 "comparison_operator"
17772              [(match_dup 2) (const_int 0)])
17773             (match_operand 1 "const_int_operand" ""))]
17774   ""
17776   emit_insn (gen_rtx_TRAP_IF (VOIDmode,
17777                               ix86_expand_compare (GET_CODE (operands[0]),
17778                                                    NULL, NULL),
17779                               operands[1]));
17780   DONE;
17783 (define_insn "*conditional_trap_1"
17784   [(trap_if (match_operator 0 "comparison_operator"
17785              [(reg 17) (const_int 0)])
17786             (match_operand 1 "const_int_operand" ""))]
17787   ""
17789   operands[2] = gen_label_rtx ();
17790   output_asm_insn ("j%c0\t%l2\; int\t%1", operands);
17791   ASM_OUTPUT_INTERNAL_LABEL (asm_out_file, "L",
17792                              CODE_LABEL_NUMBER (operands[2]));
17793   RET;
17796         ;; Pentium III SIMD instructions.
17798 ;; Moves for SSE/MMX regs.
17800 (define_insn "movv4sf_internal"
17801   [(set (match_operand:V4SF 0 "nonimmediate_operand" "=x,m")
17802         (match_operand:V4SF 1 "nonimmediate_operand" "xm,x"))]
17803   "TARGET_SSE"
17804   ;; @@@ let's try to use movaps here.
17805   "movaps\t{%1, %0|%0, %1}"
17806   [(set_attr "type" "ssemov")
17807    (set_attr "mode" "V4SF")])
17809 (define_insn "movv4si_internal"
17810   [(set (match_operand:V4SI 0 "nonimmediate_operand" "=x,m")
17811         (match_operand:V4SI 1 "nonimmediate_operand" "xm,x"))]
17812   "TARGET_SSE"
17813   ;; @@@ let's try to use movaps here.
17814   "movaps\t{%1, %0|%0, %1}"
17815   [(set_attr "type" "ssemov")
17816    (set_attr "mode" "V4SF")])
17818 (define_insn "movv8qi_internal"
17819   [(set (match_operand:V8QI 0 "nonimmediate_operand" "=y,m")
17820         (match_operand:V8QI 1 "nonimmediate_operand" "ym,y"))]
17821   "TARGET_MMX"
17822   "movq\t{%1, %0|%0, %1}"
17823   [(set_attr "type" "mmxmov")
17824    (set_attr "mode" "DI")])
17826 (define_insn "movv4hi_internal"
17827   [(set (match_operand:V4HI 0 "nonimmediate_operand" "=y,m")
17828         (match_operand:V4HI 1 "nonimmediate_operand" "ym,y"))]
17829   "TARGET_MMX"
17830   "movq\t{%1, %0|%0, %1}"
17831   [(set_attr "type" "mmxmov")
17832    (set_attr "mode" "DI")])
17834 (define_insn "movv2si_internal"
17835   [(set (match_operand:V2SI 0 "nonimmediate_operand" "=y,m")
17836         (match_operand:V2SI 1 "nonimmediate_operand" "ym,y"))]
17837   "TARGET_MMX"
17838   "movq\t{%1, %0|%0, %1}"
17839   [(set_attr "type" "mmxcvt")
17840    (set_attr "mode" "DI")])
17842 (define_insn "movv2sf_internal"
17843   [(set (match_operand:V2SF 0 "nonimmediate_operand" "=y,m")
17844         (match_operand:V2SF 1 "nonimmediate_operand" "ym,y"))]
17845   "TARGET_3DNOW"
17846   "movq\\t{%1, %0|%0, %1}"
17847   [(set_attr "type" "mmxcvt")
17848    (set_attr "mode" "DI")])
17850 (define_expand "movti"
17851   [(set (match_operand:TI 0 "general_operand" "")
17852         (match_operand:TI 1 "general_operand" ""))]
17853   "TARGET_SSE || TARGET_64BIT"
17855   if (TARGET_64BIT)
17856     ix86_expand_move (TImode, operands);
17857   else
17858     ix86_expand_vector_move (TImode, operands);
17859   DONE;
17862 (define_insn "movv2df_internal"
17863   [(set (match_operand:V2DF 0 "nonimmediate_operand" "=x,m")
17864         (match_operand:V2DF 1 "general_operand" "xm,x"))]
17865   "TARGET_SSE2"
17866   ;; @@@ let's try to use movaps here.
17867   "movapd\t{%1, %0|%0, %1}"
17868   [(set_attr "type" "ssemov")
17869    (set_attr "mode" "V2DF")])
17871 (define_insn "movv8hi_internal"
17872   [(set (match_operand:V8HI 0 "nonimmediate_operand" "=x,m")
17873         (match_operand:V8HI 1 "general_operand" "xm,x"))]
17874   "TARGET_SSE2"
17875   ;; @@@ let's try to use movaps here.
17876   "movaps\t{%1, %0|%0, %1}"
17877   [(set_attr "type" "ssemov")
17878    (set_attr "mode" "V4SF")])
17880 (define_insn "movv16qi_internal"
17881   [(set (match_operand:V16QI 0 "nonimmediate_operand" "=x,m")
17882         (match_operand:V16QI 1 "general_operand" "xm,x"))]
17883   "TARGET_SSE2"
17884   ;; @@@ let's try to use movaps here.
17885   "movaps\t{%1, %0|%0, %1}"
17886   [(set_attr "type" "ssemov")
17887    (set_attr "mode" "V4SF")])
17889 (define_expand "movv2df"
17890   [(set (match_operand:V2DF 0 "general_operand" "")
17891         (match_operand:V2DF 1 "general_operand" ""))]
17892   "TARGET_SSE2"
17894   ix86_expand_vector_move (V2DFmode, operands);
17895   DONE;
17898 (define_expand "movv8hi"
17899   [(set (match_operand:V8HI 0 "general_operand" "")
17900         (match_operand:V8HI 1 "general_operand" ""))]
17901   "TARGET_SSE2"
17903   ix86_expand_vector_move (V8HImode, operands);
17904   DONE;
17907 (define_expand "movv16qi"
17908   [(set (match_operand:V16QI 0 "general_operand" "")
17909         (match_operand:V16QI 1 "general_operand" ""))]
17910   "TARGET_SSE2"
17912   ix86_expand_vector_move (V16QImode, operands);
17913   DONE;
17916 (define_expand "movv4sf"
17917   [(set (match_operand:V4SF 0 "general_operand" "")
17918         (match_operand:V4SF 1 "general_operand" ""))]
17919   "TARGET_SSE"
17921   ix86_expand_vector_move (V4SFmode, operands);
17922   DONE;
17925 (define_expand "movv4si"
17926   [(set (match_operand:V4SI 0 "general_operand" "")
17927         (match_operand:V4SI 1 "general_operand" ""))]
17928   "TARGET_MMX"
17930   ix86_expand_vector_move (V4SImode, operands);
17931   DONE;
17934 (define_expand "movv2si"
17935   [(set (match_operand:V2SI 0 "general_operand" "")
17936         (match_operand:V2SI 1 "general_operand" ""))]
17937   "TARGET_MMX"
17939   ix86_expand_vector_move (V2SImode, operands);
17940   DONE;
17943 (define_expand "movv4hi"
17944   [(set (match_operand:V4HI 0 "general_operand" "")
17945         (match_operand:V4HI 1 "general_operand" ""))]
17946   "TARGET_MMX"
17948   ix86_expand_vector_move (V4HImode, operands);
17949   DONE;
17952 (define_expand "movv8qi"
17953   [(set (match_operand:V8QI 0 "general_operand" "")
17954         (match_operand:V8QI 1 "general_operand" ""))]
17955   "TARGET_MMX"
17957   ix86_expand_vector_move (V8QImode, operands);
17958   DONE;
17961 (define_expand "movv2sf"
17962   [(set (match_operand:V2SF 0 "general_operand" "")
17963         (match_operand:V2SF 1 "general_operand" ""))]
17964    "TARGET_3DNOW"
17966   ix86_expand_vector_move (V2SFmode, operands);
17967   DONE;
17970 (define_insn_and_split "*pushti"
17971   [(set (match_operand:TI 0 "push_operand" "=<")
17972         (match_operand:TI 1 "nonmemory_operand" "x"))]
17973   "TARGET_SSE"
17974   "#"
17975   ""
17976   [(set (reg:SI 7) (plus:SI (reg:SI 7) (const_int -16)))
17977    (set (mem:TI (reg:SI 7)) (match_dup 1))]
17978   ""
17979   [(set_attr "type" "multi")])
17981 (define_insn_and_split "*pushv2df"
17982   [(set (match_operand:V2DF 0 "push_operand" "=<")
17983         (match_operand:V2DF 1 "nonmemory_operand" "x"))]
17984   "TARGET_SSE2"
17985   "#"
17986   ""
17987   [(set (reg:SI 7) (plus:SI (reg:SI 7) (const_int -16)))
17988    (set (mem:V2DF (reg:SI 7)) (match_dup 1))]
17989   ""
17990   [(set_attr "type" "multi")])
17992 (define_insn_and_split "*pushv8hi"
17993   [(set (match_operand:V8HI 0 "push_operand" "=<")
17994         (match_operand:V8HI 1 "nonmemory_operand" "x"))]
17995   "TARGET_SSE2"
17996   "#"
17997   ""
17998   [(set (reg:SI 7) (plus:SI (reg:SI 7) (const_int -16)))
17999    (set (mem:V8HI (reg:SI 7)) (match_dup 1))]
18000   ""
18001   [(set_attr "type" "multi")])
18003 (define_insn_and_split "*pushv16qi"
18004   [(set (match_operand:V16QI 0 "push_operand" "=<")
18005         (match_operand:V16QI 1 "nonmemory_operand" "x"))]
18006   "TARGET_SSE2"
18007   "#"
18008   ""
18009   [(set (reg:SI 7) (plus:SI (reg:SI 7) (const_int -16)))
18010    (set (mem:V16QI (reg:SI 7)) (match_dup 1))]
18011   ""
18012   [(set_attr "type" "multi")])
18014 (define_insn_and_split "*pushv4sf"
18015   [(set (match_operand:V4SF 0 "push_operand" "=<")
18016         (match_operand:V4SF 1 "nonmemory_operand" "x"))]
18017   "TARGET_SSE"
18018   "#"
18019   ""
18020   [(set (reg:SI 7) (plus:SI (reg:SI 7) (const_int -16)))
18021    (set (mem:V4SF (reg:SI 7)) (match_dup 1))]
18022   ""
18023   [(set_attr "type" "multi")])
18025 (define_insn_and_split "*pushv4si"
18026   [(set (match_operand:V4SI 0 "push_operand" "=<")
18027         (match_operand:V4SI 1 "nonmemory_operand" "x"))]
18028   "TARGET_SSE"
18029   "#"
18030   ""
18031   [(set (reg:SI 7) (plus:SI (reg:SI 7) (const_int -16)))
18032    (set (mem:V4SI (reg:SI 7)) (match_dup 1))]
18033   ""
18034   [(set_attr "type" "multi")])
18036 (define_insn_and_split "*pushv2si"
18037   [(set (match_operand:V2SI 0 "push_operand" "=<")
18038         (match_operand:V2SI 1 "nonmemory_operand" "y"))]
18039   "TARGET_MMX"
18040   "#"
18041   ""
18042   [(set (reg:SI 7) (plus:SI (reg:SI 7) (const_int -8)))
18043    (set (mem:V2SI (reg:SI 7)) (match_dup 1))]
18044   ""
18045   [(set_attr "type" "mmx")])
18047 (define_insn_and_split "*pushv4hi"
18048   [(set (match_operand:V4HI 0 "push_operand" "=<")
18049         (match_operand:V4HI 1 "nonmemory_operand" "y"))]
18050   "TARGET_MMX"
18051   "#"
18052   ""
18053   [(set (reg:SI 7) (plus:SI (reg:SI 7) (const_int -8)))
18054    (set (mem:V4HI (reg:SI 7)) (match_dup 1))]
18055   ""
18056   [(set_attr "type" "mmx")])
18058 (define_insn_and_split "*pushv8qi"
18059   [(set (match_operand:V8QI 0 "push_operand" "=<")
18060         (match_operand:V8QI 1 "nonmemory_operand" "y"))]
18061   "TARGET_MMX"
18062   "#"
18063   ""
18064   [(set (reg:SI 7) (plus:SI (reg:SI 7) (const_int -8)))
18065    (set (mem:V8QI (reg:SI 7)) (match_dup 1))]
18066   ""
18067   [(set_attr "type" "mmx")])
18069 (define_insn_and_split "*pushv2sf"
18070   [(set (match_operand:V2SF 0 "push_operand" "=<")
18071         (match_operand:V2SF 1 "nonmemory_operand" "y"))]
18072   "TARGET_3DNOW"
18073   "#"
18074   ""
18075   [(set (reg:SI 7) (plus:SI (reg:SI 7) (const_int -8)))
18076    (set (mem:V2SF (reg:SI 7)) (match_dup 1))]
18077   ""
18078   [(set_attr "type" "mmx")])
18080 (define_insn "movti_internal"
18081   [(set (match_operand:TI 0 "nonimmediate_operand" "=x,x,m")
18082         (match_operand:TI 1 "general_operand" "O,xm,x"))]
18083   "TARGET_SSE && !TARGET_64BIT"
18084   "@
18085    xorps\t%0, %0
18086    movaps\t{%1, %0|%0, %1}
18087    movaps\t{%1, %0|%0, %1}"
18088   [(set_attr "type" "ssemov,ssemov,ssemov")
18089    (set_attr "mode" "V4SF")])
18091 (define_insn "*movti_rex64"
18092   [(set (match_operand:TI 0 "nonimmediate_operand" "=r,o,x,mx,x")
18093         (match_operand:TI 1 "general_operand" "riFo,riF,O,x,m"))]
18094   "TARGET_64BIT
18095    && (GET_CODE (operands[0]) != MEM || GET_CODE (operands[1]) != MEM)"
18096   "@
18097    #
18098    #
18099    xorps\t%0, %0
18100    movaps\\t{%1, %0|%0, %1}
18101    movaps\\t{%1, %0|%0, %1}"
18102   [(set_attr "type" "*,*,ssemov,ssemov,ssemov")
18103    (set_attr "mode" "V4SF")])
18105 (define_split
18106   [(set (match_operand:TI 0 "nonimmediate_operand" "")
18107         (match_operand:TI 1 "general_operand" ""))]
18108   "reload_completed && !SSE_REG_P (operands[0])
18109    && !SSE_REG_P (operands[1])"
18110   [(const_int 0)]
18111   "ix86_split_long_move (operands); DONE;")
18113 ;; These two patterns are useful for specifying exactly whether to use
18114 ;; movaps or movups
18115 (define_insn "sse_movaps"
18116   [(set (match_operand:V4SF 0 "nonimmediate_operand" "=x,m")
18117         (unspec:V4SF [(match_operand:V4SF 1 "nonimmediate_operand" "xm,x")]
18118                      UNSPEC_MOVA))]
18119   "TARGET_SSE"
18120   "@
18121    movaps\t{%1, %0|%0, %1}
18122    movaps\t{%1, %0|%0, %1}"
18123   [(set_attr "type" "ssemov,ssemov")
18124    (set_attr "mode" "V4SF")])
18126 (define_insn "sse_movups"
18127   [(set (match_operand:V4SF 0 "nonimmediate_operand" "=x,m")
18128         (unspec:V4SF [(match_operand:V4SF 1 "nonimmediate_operand" "xm,x")]
18129                      UNSPEC_MOVU))]
18130   "TARGET_SSE"
18131   "@
18132    movups\t{%1, %0|%0, %1}
18133    movups\t{%1, %0|%0, %1}"
18134   [(set_attr "type" "ssecvt,ssecvt")
18135    (set_attr "mode" "V4SF")])
18138 ;; SSE Strange Moves.
18140 (define_insn "sse_movmskps"
18141   [(set (match_operand:SI 0 "register_operand" "=r")
18142         (unspec:SI [(match_operand:V4SF 1 "register_operand" "x")]
18143                    UNSPEC_MOVMSK))]
18144   "TARGET_SSE"
18145   "movmskps\t{%1, %0|%0, %1}"
18146   [(set_attr "type" "ssecvt")
18147    (set_attr "mode" "V4SF")])
18149 (define_insn "mmx_pmovmskb"
18150   [(set (match_operand:SI 0 "register_operand" "=r")
18151         (unspec:SI [(match_operand:V8QI 1 "register_operand" "y")]
18152                    UNSPEC_MOVMSK))]
18153   "TARGET_SSE || TARGET_3DNOW_A"
18154   "pmovmskb\t{%1, %0|%0, %1}"
18155   [(set_attr "type" "ssecvt")
18156    (set_attr "mode" "V4SF")])
18159 (define_insn "mmx_maskmovq"
18160   [(set (mem:V8QI (match_operand:SI 0 "register_operand" "D"))
18161         (unspec:V8QI [(match_operand:V8QI 1 "register_operand" "y")
18162                       (match_operand:V8QI 2 "register_operand" "y")]
18163                      UNSPEC_MASKMOV))]
18164   "(TARGET_SSE || TARGET_3DNOW_A) && !TARGET_64BIT"
18165   ;; @@@ check ordering of operands in intel/nonintel syntax
18166   "maskmovq\t{%2, %1|%1, %2}"
18167   [(set_attr "type" "mmxcvt")
18168    (set_attr "mode" "DI")])
18170 (define_insn "mmx_maskmovq_rex"
18171   [(set (mem:V8QI (match_operand:DI 0 "register_operand" "D"))
18172         (unspec:V8QI [(match_operand:V8QI 1 "register_operand" "y")
18173                       (match_operand:V8QI 2 "register_operand" "y")]
18174                      UNSPEC_MASKMOV))]
18175   "(TARGET_SSE || TARGET_3DNOW_A) && TARGET_64BIT"
18176   ;; @@@ check ordering of operands in intel/nonintel syntax
18177   "maskmovq\t{%2, %1|%1, %2}"
18178   [(set_attr "type" "mmxcvt")
18179    (set_attr "mode" "DI")])
18181 (define_insn "sse_movntv4sf"
18182   [(set (match_operand:V4SF 0 "memory_operand" "=m")
18183         (unspec:V4SF [(match_operand:V4SF 1 "register_operand" "x")]
18184                      UNSPEC_MOVNT))]
18185   "TARGET_SSE"
18186   "movntps\t{%1, %0|%0, %1}"
18187   [(set_attr "type" "ssemov")
18188    (set_attr "mode" "V4SF")])
18190 (define_insn "sse_movntdi"
18191   [(set (match_operand:DI 0 "memory_operand" "=m")
18192         (unspec:DI [(match_operand:DI 1 "register_operand" "y")]
18193                    UNSPEC_MOVNT))]
18194   "TARGET_SSE || TARGET_3DNOW_A"
18195   "movntq\t{%1, %0|%0, %1}"
18196   [(set_attr "type" "mmxmov")
18197    (set_attr "mode" "DI")])
18199 (define_insn "sse_movhlps"
18200   [(set (match_operand:V4SF 0 "register_operand" "=x")
18201         (vec_merge:V4SF
18202          (match_operand:V4SF 1 "register_operand" "0")
18203          (vec_select:V4SF (match_operand:V4SF 2 "register_operand" "x")
18204                           (parallel [(const_int 2)
18205                                      (const_int 3)
18206                                      (const_int 0)
18207                                      (const_int 1)]))
18208          (const_int 3)))]
18209   "TARGET_SSE"
18210   "movhlps\t{%2, %0|%0, %2}"
18211   [(set_attr "type" "ssecvt")
18212    (set_attr "mode" "V4SF")])
18214 (define_insn "sse_movlhps"
18215   [(set (match_operand:V4SF 0 "register_operand" "=x")
18216         (vec_merge:V4SF
18217          (match_operand:V4SF 1 "register_operand" "0")
18218          (vec_select:V4SF (match_operand:V4SF 2 "register_operand" "x")
18219                           (parallel [(const_int 2)
18220                                      (const_int 3)
18221                                      (const_int 0)
18222                                      (const_int 1)]))
18223          (const_int 12)))]
18224   "TARGET_SSE"
18225   "movlhps\t{%2, %0|%0, %2}"
18226   [(set_attr "type" "ssecvt")
18227    (set_attr "mode" "V4SF")])
18229 (define_insn "sse_movhps"
18230   [(set (match_operand:V4SF 0 "nonimmediate_operand" "=x,m")
18231         (vec_merge:V4SF
18232          (match_operand:V4SF 1 "nonimmediate_operand" "0,0")
18233          (match_operand:V4SF 2 "nonimmediate_operand" "m,x")
18234          (const_int 12)))]
18235   "TARGET_SSE
18236    && (GET_CODE (operands[1]) == MEM || GET_CODE (operands[2]) == MEM)"
18237   "movhps\t{%2, %0|%0, %2}"
18238   [(set_attr "type" "ssecvt")
18239    (set_attr "mode" "V4SF")])
18241 (define_insn "sse_movlps"
18242   [(set (match_operand:V4SF 0 "nonimmediate_operand" "=x,m")
18243         (vec_merge:V4SF
18244          (match_operand:V4SF 1 "nonimmediate_operand" "0,0")
18245          (match_operand:V4SF 2 "nonimmediate_operand" "m,x")
18246          (const_int 3)))]
18247   "TARGET_SSE
18248    && (GET_CODE (operands[1]) == MEM || GET_CODE (operands[2]) == MEM)"
18249   "movlps\t{%2, %0|%0, %2}"
18250   [(set_attr "type" "ssecvt")
18251    (set_attr "mode" "V4SF")])
18253 (define_insn "sse_loadss"
18254   [(set (match_operand:V4SF 0 "register_operand" "=x")
18255         (vec_merge:V4SF
18256          (match_operand:V4SF 1 "memory_operand" "m")
18257          (vec_duplicate:V4SF (float:SF (const_int 0)))
18258          (const_int 1)))]
18259   "TARGET_SSE"
18260   "movss\t{%1, %0|%0, %1}"
18261   [(set_attr "type" "ssemov")
18262    (set_attr "mode" "SF")])
18264 (define_insn "sse_movss"
18265   [(set (match_operand:V4SF 0 "register_operand" "=x")
18266         (vec_merge:V4SF
18267          (match_operand:V4SF 1 "register_operand" "0")
18268          (match_operand:V4SF 2 "register_operand" "x")
18269          (const_int 1)))]
18270   "TARGET_SSE"
18271   "movss\t{%2, %0|%0, %2}"
18272   [(set_attr "type" "ssemov")
18273    (set_attr "mode" "SF")])
18275 (define_insn "sse_storess"
18276   [(set (match_operand:SF 0 "memory_operand" "=m")
18277         (vec_select:SF
18278          (match_operand:V4SF 1 "register_operand" "x")
18279          (parallel [(const_int 0)])))]
18280   "TARGET_SSE"
18281   "movss\t{%1, %0|%0, %1}"
18282   [(set_attr "type" "ssemov")
18283    (set_attr "mode" "SF")])
18285 (define_insn "sse_shufps"
18286   [(set (match_operand:V4SF 0 "register_operand" "=x")
18287         (unspec:V4SF [(match_operand:V4SF 1 "register_operand" "0")
18288                       (match_operand:V4SF 2 "nonimmediate_operand" "xm")
18289                       (match_operand:SI 3 "immediate_operand" "i")]
18290                      UNSPEC_SHUFFLE))]
18291   "TARGET_SSE"
18292   ;; @@@ check operand order for intel/nonintel syntax
18293   "shufps\t{%3, %2, %0|%0, %2, %3}"
18294   [(set_attr "type" "ssecvt")
18295    (set_attr "mode" "V4SF")])
18298 ;; SSE arithmetic
18300 (define_insn "addv4sf3"
18301   [(set (match_operand:V4SF 0 "register_operand" "=x")
18302         (plus:V4SF (match_operand:V4SF 1 "register_operand" "0")
18303                    (match_operand:V4SF 2 "nonimmediate_operand" "xm")))]
18304   "TARGET_SSE"
18305   "addps\t{%2, %0|%0, %2}"
18306   [(set_attr "type" "sseadd")
18307    (set_attr "mode" "V4SF")])
18309 (define_insn "vmaddv4sf3"
18310   [(set (match_operand:V4SF 0 "register_operand" "=x")
18311         (vec_merge:V4SF
18312          (plus:V4SF (match_operand:V4SF 1 "register_operand" "0")
18313                     (match_operand:V4SF 2 "nonimmediate_operand" "xm"))
18314          (match_dup 1)
18315          (const_int 1)))]
18316   "TARGET_SSE"
18317   "addss\t{%2, %0|%0, %2}"
18318   [(set_attr "type" "sseadd")
18319    (set_attr "mode" "SF")])
18321 (define_insn "subv4sf3"
18322   [(set (match_operand:V4SF 0 "register_operand" "=x")
18323         (minus:V4SF (match_operand:V4SF 1 "register_operand" "0")
18324                     (match_operand:V4SF 2 "nonimmediate_operand" "xm")))]
18325   "TARGET_SSE"
18326   "subps\t{%2, %0|%0, %2}"
18327   [(set_attr "type" "sseadd")
18328    (set_attr "mode" "V4SF")])
18330 (define_insn "vmsubv4sf3"
18331   [(set (match_operand:V4SF 0 "register_operand" "=x")
18332         (vec_merge:V4SF
18333          (minus:V4SF (match_operand:V4SF 1 "register_operand" "0")
18334                      (match_operand:V4SF 2 "nonimmediate_operand" "xm"))
18335          (match_dup 1)
18336          (const_int 1)))]
18337   "TARGET_SSE"
18338   "subss\t{%2, %0|%0, %2}"
18339   [(set_attr "type" "sseadd")
18340    (set_attr "mode" "SF")])
18342 (define_insn "mulv4sf3"
18343   [(set (match_operand:V4SF 0 "register_operand" "=x")
18344         (mult:V4SF (match_operand:V4SF 1 "register_operand" "0")
18345                    (match_operand:V4SF 2 "nonimmediate_operand" "xm")))]
18346   "TARGET_SSE"
18347   "mulps\t{%2, %0|%0, %2}"
18348   [(set_attr "type" "ssemul")
18349    (set_attr "mode" "V4SF")])
18351 (define_insn "vmmulv4sf3"
18352   [(set (match_operand:V4SF 0 "register_operand" "=x")
18353         (vec_merge:V4SF
18354          (mult:V4SF (match_operand:V4SF 1 "register_operand" "0")
18355                     (match_operand:V4SF 2 "nonimmediate_operand" "xm"))
18356          (match_dup 1)
18357          (const_int 1)))]
18358   "TARGET_SSE"
18359   "mulss\t{%2, %0|%0, %2}"
18360   [(set_attr "type" "ssemul")
18361    (set_attr "mode" "SF")])
18363 (define_insn "divv4sf3"
18364   [(set (match_operand:V4SF 0 "register_operand" "=x")
18365         (div:V4SF (match_operand:V4SF 1 "register_operand" "0")
18366                   (match_operand:V4SF 2 "nonimmediate_operand" "xm")))]
18367   "TARGET_SSE"
18368   "divps\t{%2, %0|%0, %2}"
18369   [(set_attr "type" "ssediv")
18370    (set_attr "mode" "V4SF")])
18372 (define_insn "vmdivv4sf3"
18373   [(set (match_operand:V4SF 0 "register_operand" "=x")
18374         (vec_merge:V4SF
18375          (div:V4SF (match_operand:V4SF 1 "register_operand" "0")
18376                    (match_operand:V4SF 2 "nonimmediate_operand" "xm"))
18377          (match_dup 1)
18378          (const_int 1)))]
18379   "TARGET_SSE"
18380   "divss\t{%2, %0|%0, %2}"
18381   [(set_attr "type" "ssediv")
18382    (set_attr "mode" "SF")])
18385 ;; SSE square root/reciprocal
18387 (define_insn "rcpv4sf2"
18388   [(set (match_operand:V4SF 0 "register_operand" "=x")
18389         (unspec:V4SF
18390          [(match_operand:V4SF 1 "nonimmediate_operand" "xm")] UNSPEC_RCP))]
18391   "TARGET_SSE"
18392   "rcpps\t{%1, %0|%0, %1}"
18393   [(set_attr "type" "sse")
18394    (set_attr "mode" "V4SF")])
18396 (define_insn "vmrcpv4sf2"
18397   [(set (match_operand:V4SF 0 "register_operand" "=x")
18398         (vec_merge:V4SF
18399          (unspec:V4SF [(match_operand:V4SF 1 "nonimmediate_operand" "xm")]
18400                       UNSPEC_RCP)
18401          (match_operand:V4SF 2 "register_operand" "0")
18402          (const_int 1)))]
18403   "TARGET_SSE"
18404   "rcpss\t{%1, %0|%0, %1}"
18405   [(set_attr "type" "sse")
18406    (set_attr "mode" "SF")])
18408 (define_insn "rsqrtv4sf2"
18409   [(set (match_operand:V4SF 0 "register_operand" "=x")
18410         (unspec:V4SF
18411          [(match_operand:V4SF 1 "nonimmediate_operand" "xm")] UNSPEC_RSQRT))]
18412   "TARGET_SSE"
18413   "rsqrtps\t{%1, %0|%0, %1}"
18414   [(set_attr "type" "sse")
18415    (set_attr "mode" "V4SF")])
18417 (define_insn "vmrsqrtv4sf2"
18418   [(set (match_operand:V4SF 0 "register_operand" "=x")
18419         (vec_merge:V4SF
18420          (unspec:V4SF [(match_operand:V4SF 1 "nonimmediate_operand" "xm")]
18421                       UNSPEC_RSQRT)
18422          (match_operand:V4SF 2 "register_operand" "0")
18423          (const_int 1)))]
18424   "TARGET_SSE"
18425   "rsqrtss\t{%1, %0|%0, %1}"
18426   [(set_attr "type" "sse")
18427    (set_attr "mode" "SF")])
18429 (define_insn "sqrtv4sf2"
18430   [(set (match_operand:V4SF 0 "register_operand" "=x")
18431         (sqrt:V4SF (match_operand:V4SF 1 "nonimmediate_operand" "xm")))]
18432   "TARGET_SSE"
18433   "sqrtps\t{%1, %0|%0, %1}"
18434   [(set_attr "type" "sse")
18435    (set_attr "mode" "V4SF")])
18437 (define_insn "vmsqrtv4sf2"
18438   [(set (match_operand:V4SF 0 "register_operand" "=x")
18439         (vec_merge:V4SF
18440          (sqrt:V4SF (match_operand:V4SF 1 "nonimmediate_operand" "xm"))
18441          (match_operand:V4SF 2 "register_operand" "0")
18442          (const_int 1)))]
18443   "TARGET_SSE"
18444   "sqrtss\t{%1, %0|%0, %1}"
18445   [(set_attr "type" "sse")
18446    (set_attr "mode" "SF")])
18448 ;; SSE logical operations.
18450 ;; These are not called andti3 etc. because we really really don't want
18451 ;; the compiler to widen DImode ands to TImode ands and then try to move
18452 ;; into DImode subregs of SSE registers, and them together, and move out
18453 ;; of DImode subregs again!
18455 (define_insn "*sse_andti3_df_1"
18456   [(set (subreg:TI (match_operand:DF 0 "register_operand" "=Y") 0)
18457         (and:TI (subreg:TI (match_operand:DF 1 "register_operand" "%0") 0)
18458                 (subreg:TI (match_operand:DF 2 "register_operand" "Y") 0)))]
18459   "TARGET_SSE2"
18460   "andpd\t{%2, %0|%0, %2}"
18461   [(set_attr "type" "sselog")
18462    (set_attr "mode" "V2DF")])
18464 (define_insn "*sse_andti3_df_2"
18465   [(set (subreg:TI (match_operand:DF 0 "register_operand" "=Y") 0)
18466         (and:TI (subreg:TI (match_operand:DF 1 "register_operand" "0") 0)
18467                 (match_operand:TI 2 "nonimmediate_operand" "Ym")))]
18468   "TARGET_SSE2"
18469   "andpd\t{%2, %0|%0, %2}"
18470   [(set_attr "type" "sselog")
18471    (set_attr "mode" "V2DF")])
18473 (define_insn "*sse_andti3_sf_1"
18474   [(set (subreg:TI (match_operand:SF 0 "register_operand" "=x") 0)
18475         (and:TI (subreg:TI (match_operand:SF 1 "register_operand" "%0") 0)
18476                 (subreg:TI (match_operand:SF 2 "register_operand" "x") 0)))]
18477   "TARGET_SSE"
18478   "andps\t{%2, %0|%0, %2}"
18479   [(set_attr "type" "sselog")
18480    (set_attr "mode" "V4SF")])
18482 (define_insn "*sse_andti3_sf_2"
18483   [(set (subreg:TI (match_operand:SF 0 "register_operand" "=x") 0)
18484         (and:TI (subreg:TI (match_operand:SF 1 "register_operand" "0") 0)
18485                 (match_operand:TI 2 "nonimmediate_operand" "xm")))]
18486   "TARGET_SSE"
18487   "andps\t{%2, %0|%0, %2}"
18488   [(set_attr "type" "sselog")
18489    (set_attr "mode" "V4SF")])
18491 (define_insn "sse_andti3"
18492   [(set (match_operand:TI 0 "register_operand" "=x")
18493         (and:TI (match_operand:TI 1 "nonimmediate_operand" "%0")
18494                 (match_operand:TI 2 "nonimmediate_operand" "xm")))]
18495   "TARGET_SSE && !TARGET_SSE2
18496    && (GET_CODE (operands[1]) != MEM || GET_CODE (operands[2]) != MEM)"
18497   "andps\t{%2, %0|%0, %2}"
18498   [(set_attr "type" "sselog")
18499    (set_attr "mode" "V4SF")])
18501 (define_insn "sse2_andti3"
18502   [(set (match_operand:TI 0 "register_operand" "=x")
18503         (and:TI (match_operand:TI 1 "nonimmediate_operand" "%0")
18504                 (match_operand:TI 2 "nonimmediate_operand" "xm")))]
18505   "TARGET_SSE2
18506    && (GET_CODE (operands[1]) != MEM || GET_CODE (operands[2]) != MEM)"
18507   "pand\t{%2, %0|%0, %2}"
18508   [(set_attr "type" "sselog")
18509    (set_attr "mode" "TI")])
18511 (define_insn "sse2_andv2di3"
18512   [(set (match_operand:V2DI 0 "register_operand" "=x")
18513         (and:V2DI (match_operand:V2DI 1 "nonimmediate_operand" "%0")
18514                   (match_operand:V2DI 2 "nonimmediate_operand" "xm")))]
18515   "TARGET_SSE2
18516    && (GET_CODE (operands[1]) != MEM || GET_CODE (operands[2]) != MEM)"
18517   "pand\t{%2, %0|%0, %2}"
18518   [(set_attr "type" "sselog")
18519    (set_attr "mode" "TI")])
18521 (define_insn "*sse_nandti3_df"
18522   [(set (subreg:TI (match_operand:DF 0 "register_operand" "=Y") 0)
18523         (and:TI (not:TI (subreg:TI (match_operand:DF 1 "register_operand" "0") 0))
18524                 (match_operand:TI 2 "nonimmediate_operand" "Ym")))]
18525   "TARGET_SSE2"
18526   "andnpd\t{%2, %0|%0, %2}"
18527   [(set_attr "type" "sselog")
18528    (set_attr "mode" "V2DF")])
18530 (define_insn "*sse_nandti3_sf"
18531   [(set (subreg:TI (match_operand:SF 0 "register_operand" "=x") 0)
18532         (and:TI (not:TI (subreg:TI (match_operand:SF 1 "register_operand" "0") 0))
18533                 (match_operand:TI 2 "nonimmediate_operand" "xm")))]
18534   "TARGET_SSE"
18535   "andnps\t{%2, %0|%0, %2}"
18536   [(set_attr "type" "sselog")
18537    (set_attr "mode" "V4SF")])
18539 (define_insn "sse_nandti3"
18540   [(set (match_operand:TI 0 "register_operand" "=x")
18541         (and:TI (not:TI (match_operand:TI 1 "register_operand" "0"))
18542                 (match_operand:TI 2 "nonimmediate_operand" "xm")))]
18543   "TARGET_SSE && !TARGET_SSE2"
18544   "andnps\t{%2, %0|%0, %2}"
18545   [(set_attr "type" "sselog")
18546    (set_attr "mode" "V4SF")])
18548 (define_insn "sse2_nandti3"
18549   [(set (match_operand:TI 0 "register_operand" "=x")
18550         (and:TI (not:TI (match_operand:TI 1 "register_operand" "0"))
18551                 (match_operand:TI 2 "nonimmediate_operand" "xm")))]
18552   "TARGET_SSE2"
18553   "pandn\t{%2, %0|%0, %2}"
18554   [(set_attr "type" "sselog")
18555    (set_attr "mode" "TI")])
18557 (define_insn "sse2_nandv2di3"
18558   [(set (match_operand:V2DI 0 "register_operand" "=x")
18559         (and:V2DI (not:V2DI (match_operand:V2DI 1 "nonimmediate_operand" "%0"))
18560                   (match_operand:V2DI 2 "nonimmediate_operand" "xm")))]
18561   "TARGET_SSE2
18562    && (GET_CODE (operands[1]) != MEM || GET_CODE (operands[2]) != MEM)"
18563   "pandn\t{%2, %0|%0, %2}"
18564   [(set_attr "type" "sselog")
18565    (set_attr "mode" "TI")])
18567 (define_insn "*sse_iorti3_df_1"
18568   [(set (subreg:TI (match_operand:DF 0 "register_operand" "=Y") 0)
18569         (ior:TI (subreg:TI (match_operand:DF 1 "register_operand" "%0") 0)
18570                 (subreg:TI (match_operand:DF 2 "register_operand" "Y") 0)))]
18571   "TARGET_SSE2"
18572   "orpd\t{%2, %0|%0, %2}"
18573   [(set_attr "type" "sselog")
18574    (set_attr "mode" "V2DF")])
18576 (define_insn "*sse_iorti3_df_2"
18577   [(set (subreg:TI (match_operand:DF 0 "register_operand" "=Y") 0)
18578         (ior:TI (subreg:TI (match_operand:DF 1 "register_operand" "0") 0)
18579                 (match_operand:TI 2 "nonimmediate_operand" "Ym")))]
18580   "TARGET_SSE2"
18581   "orpd\t{%2, %0|%0, %2}"
18582   [(set_attr "type" "sselog")
18583    (set_attr "mode" "V2DF")])
18585 (define_insn "*sse_iorti3_sf_1"
18586   [(set (subreg:TI (match_operand:SF 0 "register_operand" "=x") 0)
18587         (ior:TI (subreg:TI (match_operand:SF 1 "register_operand" "%0") 0)
18588                 (subreg:TI (match_operand:SF 2 "register_operand" "x") 0)))]
18589   "TARGET_SSE"
18590   "orps\t{%2, %0|%0, %2}"
18591   [(set_attr "type" "sselog")
18592    (set_attr "mode" "V4SF")])
18594 (define_insn "*sse_iorti3_sf_2"
18595   [(set (subreg:TI (match_operand:SF 0 "register_operand" "=x") 0)
18596         (ior:TI (subreg:TI (match_operand:SF 1 "register_operand" "0") 0)
18597                 (match_operand:TI 2 "nonimmediate_operand" "xm")))]
18598   "TARGET_SSE"
18599   "orps\t{%2, %0|%0, %2}"
18600   [(set_attr "type" "sselog")
18601    (set_attr "mode" "V4SF")])
18603 (define_insn "sse_iorti3"
18604   [(set (match_operand:TI 0 "register_operand" "=x")
18605         (ior:TI (match_operand:TI 1 "nonimmediate_operand" "%0")
18606                 (match_operand:TI 2 "nonimmediate_operand" "xm")))]
18607   "TARGET_SSE && !TARGET_SSE2
18608    && (GET_CODE (operands[1]) != MEM || GET_CODE (operands[2]) != MEM)"
18609   "orps\t{%2, %0|%0, %2}"
18610   [(set_attr "type" "sselog")
18611    (set_attr "mode" "V4SF")])
18613 (define_insn "sse2_iorti3"
18614   [(set (match_operand:TI 0 "register_operand" "=x")
18615         (ior:TI (match_operand:TI 1 "nonimmediate_operand" "%0")
18616                 (match_operand:TI 2 "nonimmediate_operand" "xm")))]
18617   "TARGET_SSE2
18618    && (GET_CODE (operands[1]) != MEM || GET_CODE (operands[2]) != MEM)"
18619   "por\t{%2, %0|%0, %2}"
18620   [(set_attr "type" "sselog")
18621    (set_attr "mode" "TI")])
18623 (define_insn "sse2_iorv2di3"
18624   [(set (match_operand:V2DI 0 "register_operand" "=x")
18625         (ior:V2DI (match_operand:V2DI 1 "nonimmediate_operand" "%0")
18626                   (match_operand:V2DI 2 "nonimmediate_operand" "xm")))]
18627   "TARGET_SSE2
18628    && (GET_CODE (operands[1]) != MEM || GET_CODE (operands[2]) != MEM)"
18629   "por\t{%2, %0|%0, %2}"
18630   [(set_attr "type" "sselog")
18631    (set_attr "mode" "TI")])
18633 (define_insn "*sse_xorti3_df_1"
18634   [(set (subreg:TI (match_operand:DF 0 "register_operand" "=Y") 0)
18635         (xor:TI (subreg:TI (match_operand:DF 1 "register_operand" "%0") 0)
18636                 (subreg:TI (match_operand:DF 2 "register_operand" "Y") 0)))]
18637   "TARGET_SSE2"
18638   "xorpd\t{%2, %0|%0, %2}"
18639   [(set_attr "type" "sselog")
18640    (set_attr "mode" "V2DF")])
18642 (define_insn "*sse_xorti3_df_2"
18643   [(set (subreg:TI (match_operand:DF 0 "register_operand" "=Y") 0)
18644         (xor:TI (subreg:TI (match_operand:DF 1 "register_operand" "0") 0)
18645                 (match_operand:TI 2 "nonimmediate_operand" "Ym")))]
18646   "TARGET_SSE2"
18647   "xorpd\t{%2, %0|%0, %2}"
18648   [(set_attr "type" "sselog")
18649    (set_attr "mode" "V2DF")])
18651 (define_insn "*sse_xorti3_sf_1"
18652   [(set (subreg:TI (match_operand:SF 0 "register_operand" "=x") 0)
18653         (xor:TI (subreg:TI (match_operand:SF 1 "register_operand" "%0") 0)
18654                 (subreg:TI (match_operand:SF 2 "register_operand" "x") 0)))]
18655   "TARGET_SSE"
18656   "xorps\t{%2, %0|%0, %2}"
18657   [(set_attr "type" "sselog")
18658    (set_attr "mode" "V4SF")])
18660 (define_insn "*sse_xorti3_sf_2"
18661   [(set (subreg:TI (match_operand:SF 0 "register_operand" "=x") 0)
18662         (xor:TI (subreg:TI (match_operand:SF 1 "register_operand" "0") 0)
18663                 (match_operand:TI 2 "nonimmediate_operand" "xm")))]
18664   "TARGET_SSE"
18665   "xorps\t{%2, %0|%0, %2}"
18666   [(set_attr "type" "sselog")
18667    (set_attr "mode" "V4SF")])
18669 (define_insn "sse_xorti3"
18670   [(set (match_operand:TI 0 "register_operand" "=x")
18671         (xor:TI (match_operand:TI 1 "nonimmediate_operand" "%0")
18672                 (match_operand:TI 2 "nonimmediate_operand" "xm")))]
18673   "TARGET_SSE && !TARGET_SSE2
18674    && (GET_CODE (operands[1]) != MEM || GET_CODE (operands[2]) != MEM)"
18675   "xorps\t{%2, %0|%0, %2}"
18676   [(set_attr "type" "sselog")
18677    (set_attr "mode" "V4SF")])
18679 (define_insn "sse2_xorti3"
18680   [(set (match_operand:TI 0 "register_operand" "=x")
18681         (xor:TI (match_operand:TI 1 "nonimmediate_operand" "%0")
18682                 (match_operand:TI 2 "nonimmediate_operand" "xm")))]
18683   "TARGET_SSE2
18684    && (GET_CODE (operands[1]) != MEM || GET_CODE (operands[2]) != MEM)"
18685   "pxor\t{%2, %0|%0, %2}"
18686   [(set_attr "type" "sselog")
18687    (set_attr "mode" "TI")])
18689 (define_insn "sse2_xorv2di3"
18690   [(set (match_operand:V2DI 0 "register_operand" "=x")
18691         (xor:V2DI (match_operand:V2DI 1 "nonimmediate_operand" "%0")
18692                   (match_operand:V2DI 2 "nonimmediate_operand" "xm")))]
18693   "TARGET_SSE2
18694    && (GET_CODE (operands[1]) != MEM || GET_CODE (operands[2]) != MEM)"
18695   "pxor\t{%2, %0|%0, %2}"
18696   [(set_attr "type" "sselog")
18697    (set_attr "mode" "TI")])
18699 ;; Use xor, but don't show input operands so they aren't live before
18700 ;; this insn.
18701 (define_insn "sse_clrv4sf"
18702   [(set (match_operand:V4SF 0 "register_operand" "=x")
18703         (unspec:V4SF [(const_int 0)] UNSPEC_NOP))]
18704   "TARGET_SSE"
18705   "xorps\t{%0, %0|%0, %0}"
18706   [(set_attr "type" "sselog")
18707    (set_attr "memory" "none")
18708    (set_attr "mode" "V4SF")])
18710 ;; SSE mask-generating compares
18712 (define_insn "maskcmpv4sf3"
18713   [(set (match_operand:V4SI 0 "register_operand" "=x")
18714         (match_operator:V4SI 3 "sse_comparison_operator"
18715                 [(match_operand:V4SF 1 "register_operand" "0")
18716                  (match_operand:V4SF 2 "register_operand" "x")]))]
18717   "TARGET_SSE"
18718   "cmp%D3ps\t{%2, %0|%0, %2}"
18719   [(set_attr "type" "ssecmp")
18720    (set_attr "mode" "V4SF")])
18722 (define_insn "maskncmpv4sf3"
18723   [(set (match_operand:V4SI 0 "register_operand" "=x")
18724         (not:V4SI
18725          (match_operator:V4SI 3 "sse_comparison_operator"
18726                 [(match_operand:V4SF 1 "register_operand" "0")
18727                  (match_operand:V4SF 2 "register_operand" "x")])))]
18728   "TARGET_SSE"
18730   if (GET_CODE (operands[3]) == UNORDERED)
18731     return "cmpordps\t{%2, %0|%0, %2}";
18732   else
18733     return "cmpn%D3ps\t{%2, %0|%0, %2}";
18735   [(set_attr "type" "ssecmp")
18736    (set_attr "mode" "V4SF")])
18738 (define_insn "vmmaskcmpv4sf3"
18739   [(set (match_operand:V4SI 0 "register_operand" "=x")
18740         (vec_merge:V4SI
18741          (match_operator:V4SI 3 "sse_comparison_operator"
18742                 [(match_operand:V4SF 1 "register_operand" "0")
18743                  (match_operand:V4SF 2 "register_operand" "x")])
18744          (match_dup 1)
18745          (const_int 1)))]
18746   "TARGET_SSE"
18747   "cmp%D3ss\t{%2, %0|%0, %2}"
18748   [(set_attr "type" "ssecmp")
18749    (set_attr "mode" "SF")])
18751 (define_insn "vmmaskncmpv4sf3"
18752   [(set (match_operand:V4SI 0 "register_operand" "=x")
18753         (vec_merge:V4SI
18754          (not:V4SI
18755           (match_operator:V4SI 3 "sse_comparison_operator"
18756                 [(match_operand:V4SF 1 "register_operand" "0")
18757                  (match_operand:V4SF 2 "register_operand" "x")]))
18758          (subreg:V4SI (match_dup 1) 0)
18759          (const_int 1)))]
18760   "TARGET_SSE"
18762   if (GET_CODE (operands[3]) == UNORDERED)
18763     return "cmpordss\t{%2, %0|%0, %2}";
18764   else
18765     return "cmpn%D3ss\t{%2, %0|%0, %2}";
18767   [(set_attr "type" "ssecmp")
18768    (set_attr "mode" "SF")])
18770 (define_insn "sse_comi"
18771   [(set (reg:CCFP 17)
18772         (match_operator:CCFP 2 "sse_comparison_operator"
18773                         [(vec_select:SF
18774                           (match_operand:V4SF 0 "register_operand" "x")
18775                           (parallel [(const_int 0)]))
18776                          (vec_select:SF
18777                           (match_operand:V4SF 1 "register_operand" "x")
18778                           (parallel [(const_int 0)]))]))]
18779   "TARGET_SSE"
18780   "comiss\t{%1, %0|%0, %1}"
18781   [(set_attr "type" "ssecmp")
18782    (set_attr "mode" "SF")])
18784 (define_insn "sse_ucomi"
18785   [(set (reg:CCFPU 17)
18786         (match_operator:CCFPU 2 "sse_comparison_operator"
18787                         [(vec_select:SF
18788                           (match_operand:V4SF 0 "register_operand" "x")
18789                           (parallel [(const_int 0)]))
18790                          (vec_select:SF
18791                           (match_operand:V4SF 1 "register_operand" "x")
18792                           (parallel [(const_int 0)]))]))]
18793   "TARGET_SSE"
18794   "ucomiss\t{%1, %0|%0, %1}"
18795   [(set_attr "type" "ssecmp")
18796    (set_attr "mode" "SF")])
18799 ;; SSE unpack
18801 (define_insn "sse_unpckhps"
18802   [(set (match_operand:V4SF 0 "register_operand" "=x")
18803         (vec_merge:V4SF
18804          (vec_select:V4SF (match_operand:V4SF 1 "register_operand" "0")
18805                           (parallel [(const_int 2)
18806                                      (const_int 0)
18807                                      (const_int 3)
18808                                      (const_int 1)]))
18809          (vec_select:V4SF (match_operand:V4SF 2 "register_operand" "x")
18810                           (parallel [(const_int 0)
18811                                      (const_int 2)
18812                                      (const_int 1)
18813                                      (const_int 3)]))
18814          (const_int 5)))]
18815   "TARGET_SSE"
18816   "unpckhps\t{%2, %0|%0, %2}"
18817   [(set_attr "type" "ssecvt")
18818    (set_attr "mode" "V4SF")])
18820 (define_insn "sse_unpcklps"
18821   [(set (match_operand:V4SF 0 "register_operand" "=x")
18822         (vec_merge:V4SF
18823          (vec_select:V4SF (match_operand:V4SF 1 "register_operand" "0")
18824                           (parallel [(const_int 0)
18825                                      (const_int 2)
18826                                      (const_int 1)
18827                                      (const_int 3)]))
18828          (vec_select:V4SF (match_operand:V4SF 2 "register_operand" "x")
18829                           (parallel [(const_int 2)
18830                                      (const_int 0)
18831                                      (const_int 3)
18832                                      (const_int 1)]))
18833          (const_int 5)))]
18834   "TARGET_SSE"
18835   "unpcklps\t{%2, %0|%0, %2}"
18836   [(set_attr "type" "ssecvt")
18837    (set_attr "mode" "V4SF")])
18840 ;; SSE min/max
18842 (define_insn "smaxv4sf3"
18843   [(set (match_operand:V4SF 0 "register_operand" "=x")
18844         (smax:V4SF (match_operand:V4SF 1 "register_operand" "0")
18845                    (match_operand:V4SF 2 "nonimmediate_operand" "xm")))]
18846   "TARGET_SSE"
18847   "maxps\t{%2, %0|%0, %2}"
18848   [(set_attr "type" "sse")
18849    (set_attr "mode" "V4SF")])
18851 (define_insn "vmsmaxv4sf3"
18852   [(set (match_operand:V4SF 0 "register_operand" "=x")
18853         (vec_merge:V4SF
18854          (smax:V4SF (match_operand:V4SF 1 "register_operand" "0")
18855                     (match_operand:V4SF 2 "nonimmediate_operand" "xm"))
18856          (match_dup 1)
18857          (const_int 1)))]
18858   "TARGET_SSE"
18859   "maxss\t{%2, %0|%0, %2}"
18860   [(set_attr "type" "sse")
18861    (set_attr "mode" "SF")])
18863 (define_insn "sminv4sf3"
18864   [(set (match_operand:V4SF 0 "register_operand" "=x")
18865         (smin:V4SF (match_operand:V4SF 1 "register_operand" "0")
18866                    (match_operand:V4SF 2 "nonimmediate_operand" "xm")))]
18867   "TARGET_SSE"
18868   "minps\t{%2, %0|%0, %2}"
18869   [(set_attr "type" "sse")
18870    (set_attr "mode" "V4SF")])
18872 (define_insn "vmsminv4sf3"
18873   [(set (match_operand:V4SF 0 "register_operand" "=x")
18874         (vec_merge:V4SF
18875          (smin:V4SF (match_operand:V4SF 1 "register_operand" "0")
18876                     (match_operand:V4SF 2 "nonimmediate_operand" "xm"))
18877          (match_dup 1)
18878          (const_int 1)))]
18879   "TARGET_SSE"
18880   "minss\t{%2, %0|%0, %2}"
18881   [(set_attr "type" "sse")
18882    (set_attr "mode" "SF")])
18885 ;; SSE <-> integer/MMX conversions
18887 (define_insn "cvtpi2ps"
18888   [(set (match_operand:V4SF 0 "register_operand" "=x")
18889         (vec_merge:V4SF
18890          (match_operand:V4SF 1 "register_operand" "0")
18891          (vec_duplicate:V4SF
18892           (float:V2SF (match_operand:V2SI 2 "nonimmediate_operand" "ym")))
18893          (const_int 12)))]
18894   "TARGET_SSE"
18895   "cvtpi2ps\t{%2, %0|%0, %2}"
18896   [(set_attr "type" "ssecvt")
18897    (set_attr "mode" "V4SF")])
18899 (define_insn "cvtps2pi"
18900   [(set (match_operand:V2SI 0 "register_operand" "=y")
18901         (vec_select:V2SI
18902          (fix:V4SI (match_operand:V4SF 1 "nonimmediate_operand" "xm"))
18903          (parallel [(const_int 0) (const_int 1)])))]
18904   "TARGET_SSE"
18905   "cvtps2pi\t{%1, %0|%0, %1}"
18906   [(set_attr "type" "ssecvt")
18907    (set_attr "mode" "V4SF")])
18909 (define_insn "cvttps2pi"
18910   [(set (match_operand:V2SI 0 "register_operand" "=y")
18911         (vec_select:V2SI
18912          (unspec:V4SI [(match_operand:V4SF 1 "nonimmediate_operand" "xm")]
18913                       UNSPEC_FIX)
18914          (parallel [(const_int 0) (const_int 1)])))]
18915   "TARGET_SSE"
18916   "cvttps2pi\t{%1, %0|%0, %1}"
18917   [(set_attr "type" "ssecvt")
18918    (set_attr "mode" "SF")])
18920 (define_insn "cvtsi2ss"
18921   [(set (match_operand:V4SF 0 "register_operand" "=x")
18922         (vec_merge:V4SF
18923          (match_operand:V4SF 1 "register_operand" "0")
18924          (vec_duplicate:V4SF
18925           (float:SF (match_operand:SI 2 "nonimmediate_operand" "rm")))
18926          (const_int 14)))]
18927   "TARGET_SSE"
18928   "cvtsi2ss\t{%2, %0|%0, %2}"
18929   [(set_attr "type" "ssecvt")
18930    (set_attr "mode" "SF")])
18932 (define_insn "cvtss2si"
18933   [(set (match_operand:SI 0 "register_operand" "=r")
18934         (vec_select:SI
18935          (fix:V4SI (match_operand:V4SF 1 "nonimmediate_operand" "xm"))
18936          (parallel [(const_int 0)])))]
18937   "TARGET_SSE"
18938   "cvtss2si\t{%1, %0|%0, %1}"
18939   [(set_attr "type" "ssecvt")
18940    (set_attr "mode" "SF")])
18942 (define_insn "cvttss2si"
18943   [(set (match_operand:SI 0 "register_operand" "=r")
18944         (vec_select:SI
18945          (unspec:V4SI [(match_operand:V4SF 1 "nonimmediate_operand" "xm")]
18946                       UNSPEC_FIX)
18947          (parallel [(const_int 0)])))]
18948   "TARGET_SSE"
18949   "cvttss2si\t{%1, %0|%0, %1}"
18950   [(set_attr "type" "ssecvt")
18951    (set_attr "mode" "SF")])
18954 ;; MMX insns
18956 ;; MMX arithmetic
18958 (define_insn "addv8qi3"
18959   [(set (match_operand:V8QI 0 "register_operand" "=y")
18960         (plus:V8QI (match_operand:V8QI 1 "register_operand" "0")
18961                    (match_operand:V8QI 2 "nonimmediate_operand" "ym")))]
18962   "TARGET_MMX"
18963   "paddb\t{%2, %0|%0, %2}"
18964   [(set_attr "type" "mmxadd")
18965    (set_attr "mode" "DI")])
18967 (define_insn "addv4hi3"
18968   [(set (match_operand:V4HI 0 "register_operand" "=y")
18969         (plus:V4HI (match_operand:V4HI 1 "register_operand" "0")
18970                    (match_operand:V4HI 2 "nonimmediate_operand" "ym")))]
18971   "TARGET_MMX"
18972   "paddw\t{%2, %0|%0, %2}"
18973   [(set_attr "type" "mmxadd")
18974    (set_attr "mode" "DI")])
18976 (define_insn "addv2si3"
18977   [(set (match_operand:V2SI 0 "register_operand" "=y")
18978         (plus:V2SI (match_operand:V2SI 1 "register_operand" "0")
18979                    (match_operand:V2SI 2 "nonimmediate_operand" "ym")))]
18980   "TARGET_MMX"
18981   "paddd\t{%2, %0|%0, %2}"
18982   [(set_attr "type" "mmxadd")
18983    (set_attr "mode" "DI")])
18985 (define_insn "ssaddv8qi3"
18986   [(set (match_operand:V8QI 0 "register_operand" "=y")
18987         (ss_plus:V8QI (match_operand:V8QI 1 "register_operand" "0")
18988                       (match_operand:V8QI 2 "nonimmediate_operand" "ym")))]
18989   "TARGET_MMX"
18990   "paddsb\t{%2, %0|%0, %2}"
18991   [(set_attr "type" "mmxadd")
18992    (set_attr "mode" "DI")])
18994 (define_insn "ssaddv4hi3"
18995   [(set (match_operand:V4HI 0 "register_operand" "=y")
18996         (ss_plus:V4HI (match_operand:V4HI 1 "register_operand" "0")
18997                       (match_operand:V4HI 2 "nonimmediate_operand" "ym")))]
18998   "TARGET_MMX"
18999   "paddsw\t{%2, %0|%0, %2}"
19000   [(set_attr "type" "mmxadd")
19001    (set_attr "mode" "DI")])
19003 (define_insn "usaddv8qi3"
19004   [(set (match_operand:V8QI 0 "register_operand" "=y")
19005         (us_plus:V8QI (match_operand:V8QI 1 "register_operand" "0")
19006                       (match_operand:V8QI 2 "nonimmediate_operand" "ym")))]
19007   "TARGET_MMX"
19008   "paddusb\t{%2, %0|%0, %2}"
19009   [(set_attr "type" "mmxadd")
19010    (set_attr "mode" "DI")])
19012 (define_insn "usaddv4hi3"
19013   [(set (match_operand:V4HI 0 "register_operand" "=y")
19014         (us_plus:V4HI (match_operand:V4HI 1 "register_operand" "0")
19015                       (match_operand:V4HI 2 "nonimmediate_operand" "ym")))]
19016   "TARGET_MMX"
19017   "paddusw\t{%2, %0|%0, %2}"
19018   [(set_attr "type" "mmxadd")
19019    (set_attr "mode" "DI")])
19021 (define_insn "subv8qi3"
19022   [(set (match_operand:V8QI 0 "register_operand" "=y")
19023         (minus:V8QI (match_operand:V8QI 1 "register_operand" "0")
19024                     (match_operand:V8QI 2 "nonimmediate_operand" "ym")))]
19025   "TARGET_MMX"
19026   "psubb\t{%2, %0|%0, %2}"
19027   [(set_attr "type" "mmxadd")
19028    (set_attr "mode" "DI")])
19030 (define_insn "subv4hi3"
19031   [(set (match_operand:V4HI 0 "register_operand" "=y")
19032         (minus:V4HI (match_operand:V4HI 1 "register_operand" "0")
19033                     (match_operand:V4HI 2 "nonimmediate_operand" "ym")))]
19034   "TARGET_MMX"
19035   "psubw\t{%2, %0|%0, %2}"
19036   [(set_attr "type" "mmxadd")
19037    (set_attr "mode" "DI")])
19039 (define_insn "subv2si3"
19040   [(set (match_operand:V2SI 0 "register_operand" "=y")
19041         (minus:V2SI (match_operand:V2SI 1 "register_operand" "0")
19042                     (match_operand:V2SI 2 "nonimmediate_operand" "ym")))]
19043   "TARGET_MMX"
19044   "psubd\t{%2, %0|%0, %2}"
19045   [(set_attr "type" "mmxadd")
19046    (set_attr "mode" "DI")])
19048 (define_insn "sssubv8qi3"
19049   [(set (match_operand:V8QI 0 "register_operand" "=y")
19050         (ss_minus:V8QI (match_operand:V8QI 1 "register_operand" "0")
19051                        (match_operand:V8QI 2 "nonimmediate_operand" "ym")))]
19052   "TARGET_MMX"
19053   "psubsb\t{%2, %0|%0, %2}"
19054   [(set_attr "type" "mmxadd")
19055    (set_attr "mode" "DI")])
19057 (define_insn "sssubv4hi3"
19058   [(set (match_operand:V4HI 0 "register_operand" "=y")
19059         (ss_minus:V4HI (match_operand:V4HI 1 "register_operand" "0")
19060                        (match_operand:V4HI 2 "nonimmediate_operand" "ym")))]
19061   "TARGET_MMX"
19062   "psubsw\t{%2, %0|%0, %2}"
19063   [(set_attr "type" "mmxadd")
19064    (set_attr "mode" "DI")])
19066 (define_insn "ussubv8qi3"
19067   [(set (match_operand:V8QI 0 "register_operand" "=y")
19068         (us_minus:V8QI (match_operand:V8QI 1 "register_operand" "0")
19069                        (match_operand:V8QI 2 "nonimmediate_operand" "ym")))]
19070   "TARGET_MMX"
19071   "psubusb\t{%2, %0|%0, %2}"
19072   [(set_attr "type" "mmxadd")
19073    (set_attr "mode" "DI")])
19075 (define_insn "ussubv4hi3"
19076   [(set (match_operand:V4HI 0 "register_operand" "=y")
19077         (us_minus:V4HI (match_operand:V4HI 1 "register_operand" "0")
19078                        (match_operand:V4HI 2 "nonimmediate_operand" "ym")))]
19079   "TARGET_MMX"
19080   "psubusw\t{%2, %0|%0, %2}"
19081   [(set_attr "type" "mmxadd")
19082    (set_attr "mode" "DI")])
19084 (define_insn "mulv4hi3"
19085   [(set (match_operand:V4HI 0 "register_operand" "=y")
19086         (mult:V4HI (match_operand:V4HI 1 "register_operand" "0")
19087                    (match_operand:V4HI 2 "nonimmediate_operand" "ym")))]
19088   "TARGET_MMX"
19089   "pmullw\t{%2, %0|%0, %2}"
19090   [(set_attr "type" "mmxmul")
19091    (set_attr "mode" "DI")])
19093 (define_insn "smulv4hi3_highpart"
19094   [(set (match_operand:V4HI 0 "register_operand" "=y")
19095         (truncate:V4HI
19096          (lshiftrt:V4SI
19097           (mult:V4SI (sign_extend:V4SI
19098                       (match_operand:V4HI 1 "register_operand" "0"))
19099                      (sign_extend:V4SI
19100                       (match_operand:V4HI 2 "nonimmediate_operand" "ym")))
19101           (const_int 16))))]
19102   "TARGET_MMX"
19103   "pmulhw\t{%2, %0|%0, %2}"
19104   [(set_attr "type" "mmxmul")
19105    (set_attr "mode" "DI")])
19107 (define_insn "umulv4hi3_highpart"
19108   [(set (match_operand:V4HI 0 "register_operand" "=y")
19109         (truncate:V4HI
19110          (lshiftrt:V4SI
19111           (mult:V4SI (zero_extend:V4SI
19112                       (match_operand:V4HI 1 "register_operand" "0"))
19113                      (zero_extend:V4SI
19114                       (match_operand:V4HI 2 "nonimmediate_operand" "ym")))
19115           (const_int 16))))]
19116   "TARGET_SSE || TARGET_3DNOW_A"
19117   "pmulhuw\t{%2, %0|%0, %2}"
19118   [(set_attr "type" "mmxmul")
19119    (set_attr "mode" "DI")])
19121 (define_insn "mmx_pmaddwd"
19122   [(set (match_operand:V2SI 0 "register_operand" "=y")
19123         (plus:V2SI
19124          (mult:V2SI
19125           (sign_extend:V2SI
19126            (vec_select:V2HI (match_operand:V4HI 1 "register_operand" "0")
19127                             (parallel [(const_int 0) (const_int 2)])))
19128           (sign_extend:V2SI
19129            (vec_select:V2HI (match_operand:V4HI 2 "nonimmediate_operand" "ym")
19130                             (parallel [(const_int 0) (const_int 2)]))))
19131          (mult:V2SI
19132           (sign_extend:V2SI (vec_select:V2HI (match_dup 1)
19133                                              (parallel [(const_int 1)
19134                                                         (const_int 3)])))
19135           (sign_extend:V2SI (vec_select:V2HI (match_dup 2)
19136                                              (parallel [(const_int 1)
19137                                                         (const_int 3)]))))))]
19138   "TARGET_MMX"
19139   "pmaddwd\t{%2, %0|%0, %2}"
19140   [(set_attr "type" "mmxmul")
19141    (set_attr "mode" "DI")])
19144 ;; MMX logical operations
19145 ;; Note we don't want to declare these as regular iordi3 insns to prevent
19146 ;; normal code that also wants to use the FPU from getting broken.
19147 ;; The UNSPECs are there to prevent the combiner from getting overly clever.
19148 (define_insn "mmx_iordi3"
19149   [(set (match_operand:DI 0 "register_operand" "=y")
19150         (unspec:DI
19151          [(ior:DI (match_operand:DI 1 "register_operand" "0")
19152                   (match_operand:DI 2 "nonimmediate_operand" "ym"))]
19153          UNSPEC_NOP))]
19154   "TARGET_MMX"
19155   "por\t{%2, %0|%0, %2}"
19156   [(set_attr "type" "mmxadd")
19157    (set_attr "mode" "DI")])
19159 (define_insn "mmx_xordi3"
19160   [(set (match_operand:DI 0 "register_operand" "=y")
19161         (unspec:DI
19162          [(xor:DI (match_operand:DI 1 "register_operand" "0")
19163                   (match_operand:DI 2 "nonimmediate_operand" "ym"))]
19164          UNSPEC_NOP))]
19165   "TARGET_MMX"
19166   "pxor\t{%2, %0|%0, %2}"
19167   [(set_attr "type" "mmxadd")
19168    (set_attr "mode" "DI")
19169    (set_attr "memory" "none")])
19171 ;; Same as pxor, but don't show input operands so that we don't think
19172 ;; they are live.
19173 (define_insn "mmx_clrdi"
19174   [(set (match_operand:DI 0 "register_operand" "=y")
19175         (unspec:DI [(const_int 0)] UNSPEC_NOP))]
19176   "TARGET_MMX"
19177   "pxor\t{%0, %0|%0, %0}"
19178   [(set_attr "type" "mmxadd")
19179    (set_attr "mode" "DI")
19180    (set_attr "memory" "none")])
19182 (define_insn "mmx_anddi3"
19183   [(set (match_operand:DI 0 "register_operand" "=y")
19184         (unspec:DI
19185          [(and:DI (match_operand:DI 1 "register_operand" "0")
19186                   (match_operand:DI 2 "nonimmediate_operand" "ym"))]
19187          UNSPEC_NOP))]
19188   "TARGET_MMX"
19189   "pand\t{%2, %0|%0, %2}"
19190   [(set_attr "type" "mmxadd")
19191    (set_attr "mode" "DI")])
19193 (define_insn "mmx_nanddi3"
19194   [(set (match_operand:DI 0 "register_operand" "=y")
19195         (unspec:DI
19196          [(and:DI (not:DI (match_operand:DI 1 "register_operand" "0"))
19197                           (match_operand:DI 2 "nonimmediate_operand" "ym"))]
19198          UNSPEC_NOP))]
19199   "TARGET_MMX"
19200   "pandn\t{%2, %0|%0, %2}"
19201   [(set_attr "type" "mmxadd")
19202    (set_attr "mode" "DI")])
19205 ;; MMX unsigned averages/sum of absolute differences
19207 (define_insn "mmx_uavgv8qi3"
19208   [(set (match_operand:V8QI 0 "register_operand" "=y")
19209         (ashiftrt:V8QI
19210          (plus:V8QI (plus:V8QI
19211                      (match_operand:V8QI 1 "register_operand" "0")
19212                      (match_operand:V8QI 2 "nonimmediate_operand" "ym"))
19213                     (const_vector:V8QI [(const_int 1)
19214                                         (const_int 1)
19215                                         (const_int 1)
19216                                         (const_int 1)
19217                                         (const_int 1)
19218                                         (const_int 1)
19219                                         (const_int 1)
19220                                         (const_int 1)]))
19221          (const_int 1)))]
19222   "TARGET_SSE || TARGET_3DNOW_A"
19223   "pavgb\t{%2, %0|%0, %2}"
19224   [(set_attr "type" "mmxshft")
19225    (set_attr "mode" "DI")])
19227 (define_insn "mmx_uavgv4hi3"
19228   [(set (match_operand:V4HI 0 "register_operand" "=y")
19229         (ashiftrt:V4HI
19230          (plus:V4HI (plus:V4HI
19231                      (match_operand:V4HI 1 "register_operand" "0")
19232                      (match_operand:V4HI 2 "nonimmediate_operand" "ym"))
19233                     (const_vector:V4HI [(const_int 1)
19234                                         (const_int 1)
19235                                         (const_int 1)
19236                                         (const_int 1)]))
19237          (const_int 1)))]
19238   "TARGET_SSE || TARGET_3DNOW_A"
19239   "pavgw\t{%2, %0|%0, %2}"
19240   [(set_attr "type" "mmxshft")
19241    (set_attr "mode" "DI")])
19243 (define_insn "mmx_psadbw"
19244   [(set (match_operand:DI 0 "register_operand" "=y")
19245         (unspec:DI [(match_operand:V8QI 1 "register_operand" "0")
19246                     (match_operand:V8QI 2 "nonimmediate_operand" "ym")]
19247                    UNSPEC_PSADBW))]
19248   "TARGET_SSE || TARGET_3DNOW_A"
19249   "psadbw\t{%2, %0|%0, %2}"
19250   [(set_attr "type" "mmxshft")
19251    (set_attr "mode" "DI")])
19254 ;; MMX insert/extract/shuffle
19256 (define_insn "mmx_pinsrw"
19257   [(set (match_operand:V4HI 0 "register_operand" "=y")
19258         (vec_merge:V4HI (match_operand:V4HI 1 "register_operand" "0")
19259                         (vec_duplicate:V4HI
19260                          (truncate:HI (match_operand:SI 2 "nonimmediate_operand" "rm")))
19261                         (match_operand:SI 3 "immediate_operand" "i")))]
19262   "TARGET_SSE || TARGET_3DNOW_A"
19263   "pinsrw\t{%3, %2, %0|%0, %2, %3}"
19264   [(set_attr "type" "mmxcvt")
19265    (set_attr "mode" "DI")])
19267 (define_insn "mmx_pextrw"
19268   [(set (match_operand:SI 0 "register_operand" "=r")
19269         (zero_extend:SI (vec_select:HI (match_operand:V4HI 1 "register_operand" "y")
19270                                        (parallel
19271                                         [(match_operand:SI 2 "immediate_operand" "i")]))))]
19272   "TARGET_SSE || TARGET_3DNOW_A"
19273   "pextrw\t{%2, %1, %0|%0, %1, %2}"
19274   [(set_attr "type" "mmxcvt")
19275    (set_attr "mode" "DI")])
19277 (define_insn "mmx_pshufw"
19278   [(set (match_operand:V4HI 0 "register_operand" "=y")
19279         (unspec:V4HI [(match_operand:V4HI 1 "register_operand" "0")
19280                       (match_operand:SI 2 "immediate_operand" "i")]
19281                      UNSPEC_SHUFFLE))]
19282   "TARGET_SSE || TARGET_3DNOW_A"
19283   "pshufw\t{%2, %1, %0|%0, %1, %2}"
19284   [(set_attr "type" "mmxcvt")
19285    (set_attr "mode" "DI")])
19288 ;; MMX mask-generating comparisons
19290 (define_insn "eqv8qi3"
19291   [(set (match_operand:V8QI 0 "register_operand" "=y")
19292         (eq:V8QI (match_operand:V8QI 1 "register_operand" "0")
19293                  (match_operand:V8QI 2 "nonimmediate_operand" "ym")))]
19294   "TARGET_MMX"
19295   "pcmpeqb\t{%2, %0|%0, %2}"
19296   [(set_attr "type" "mmxcmp")
19297    (set_attr "mode" "DI")])
19299 (define_insn "eqv4hi3"
19300   [(set (match_operand:V4HI 0 "register_operand" "=y")
19301         (eq:V4HI (match_operand:V4HI 1 "register_operand" "0")
19302                  (match_operand:V4HI 2 "nonimmediate_operand" "ym")))]
19303   "TARGET_MMX"
19304   "pcmpeqw\t{%2, %0|%0, %2}"
19305   [(set_attr "type" "mmxcmp")
19306    (set_attr "mode" "DI")])
19308 (define_insn "eqv2si3"
19309   [(set (match_operand:V2SI 0 "register_operand" "=y")
19310         (eq:V2SI (match_operand:V2SI 1 "register_operand" "0")
19311                  (match_operand:V2SI 2 "nonimmediate_operand" "ym")))]
19312   "TARGET_MMX"
19313   "pcmpeqd\t{%2, %0|%0, %2}"
19314   [(set_attr "type" "mmxcmp")
19315    (set_attr "mode" "DI")])
19317 (define_insn "gtv8qi3"
19318   [(set (match_operand:V8QI 0 "register_operand" "=y")
19319         (gt:V8QI (match_operand:V8QI 1 "register_operand" "0")
19320                  (match_operand:V8QI 2 "nonimmediate_operand" "ym")))]
19321   "TARGET_MMX"
19322   "pcmpgtb\t{%2, %0|%0, %2}"
19323   [(set_attr "type" "mmxcmp")
19324    (set_attr "mode" "DI")])
19326 (define_insn "gtv4hi3"
19327   [(set (match_operand:V4HI 0 "register_operand" "=y")
19328         (gt:V4HI (match_operand:V4HI 1 "register_operand" "0")
19329                  (match_operand:V4HI 2 "nonimmediate_operand" "ym")))]
19330   "TARGET_MMX"
19331   "pcmpgtw\t{%2, %0|%0, %2}"
19332   [(set_attr "type" "mmxcmp")
19333    (set_attr "mode" "DI")])
19335 (define_insn "gtv2si3"
19336   [(set (match_operand:V2SI 0 "register_operand" "=y")
19337         (gt:V2SI (match_operand:V2SI 1 "register_operand" "0")
19338                  (match_operand:V2SI 2 "nonimmediate_operand" "ym")))]
19339   "TARGET_MMX"
19340   "pcmpgtd\t{%2, %0|%0, %2}"
19341   [(set_attr "type" "mmxcmp")
19342    (set_attr "mode" "DI")])
19345 ;; MMX max/min insns
19347 (define_insn "umaxv8qi3"
19348   [(set (match_operand:V8QI 0 "register_operand" "=y")
19349         (umax:V8QI (match_operand:V8QI 1 "register_operand" "0")
19350                    (match_operand:V8QI 2 "nonimmediate_operand" "ym")))]
19351   "TARGET_SSE || TARGET_3DNOW_A"
19352   "pmaxub\t{%2, %0|%0, %2}"
19353   [(set_attr "type" "mmxadd")
19354    (set_attr "mode" "DI")])
19356 (define_insn "smaxv4hi3"
19357   [(set (match_operand:V4HI 0 "register_operand" "=y")
19358         (smax:V4HI (match_operand:V4HI 1 "register_operand" "0")
19359                    (match_operand:V4HI 2 "nonimmediate_operand" "ym")))]
19360   "TARGET_SSE || TARGET_3DNOW_A"
19361   "pmaxsw\t{%2, %0|%0, %2}"
19362   [(set_attr "type" "mmxadd")
19363    (set_attr "mode" "DI")])
19365 (define_insn "uminv8qi3"
19366   [(set (match_operand:V8QI 0 "register_operand" "=y")
19367         (umin:V8QI (match_operand:V8QI 1 "register_operand" "0")
19368                    (match_operand:V8QI 2 "nonimmediate_operand" "ym")))]
19369   "TARGET_SSE || TARGET_3DNOW_A"
19370   "pminub\t{%2, %0|%0, %2}"
19371   [(set_attr "type" "mmxadd")
19372    (set_attr "mode" "DI")])
19374 (define_insn "sminv4hi3"
19375   [(set (match_operand:V4HI 0 "register_operand" "=y")
19376         (smin:V4HI (match_operand:V4HI 1 "register_operand" "0")
19377                    (match_operand:V4HI 2 "nonimmediate_operand" "ym")))]
19378   "TARGET_SSE || TARGET_3DNOW_A"
19379   "pminsw\t{%2, %0|%0, %2}"
19380   [(set_attr "type" "mmxadd")
19381    (set_attr "mode" "DI")])
19384 ;; MMX shifts
19386 (define_insn "ashrv4hi3"
19387   [(set (match_operand:V4HI 0 "register_operand" "=y")
19388         (ashiftrt:V4HI (match_operand:V4HI 1 "register_operand" "0")
19389                        (match_operand:DI 2 "nonmemory_operand" "yi")))]
19390   "TARGET_MMX"
19391   "psraw\t{%2, %0|%0, %2}"
19392   [(set_attr "type" "mmxshft")
19393    (set_attr "mode" "DI")])
19395 (define_insn "ashrv2si3"
19396   [(set (match_operand:V2SI 0 "register_operand" "=y")
19397         (ashiftrt:V2SI (match_operand:V2SI 1 "register_operand" "0")
19398                        (match_operand:DI 2 "nonmemory_operand" "yi")))]
19399   "TARGET_MMX"
19400   "psrad\t{%2, %0|%0, %2}"
19401   [(set_attr "type" "mmxshft")
19402    (set_attr "mode" "DI")])
19404 (define_insn "lshrv4hi3"
19405   [(set (match_operand:V4HI 0 "register_operand" "=y")
19406         (lshiftrt:V4HI (match_operand:V4HI 1 "register_operand" "0")
19407                        (match_operand:DI 2 "nonmemory_operand" "yi")))]
19408   "TARGET_MMX"
19409   "psrlw\t{%2, %0|%0, %2}"
19410   [(set_attr "type" "mmxshft")
19411    (set_attr "mode" "DI")])
19413 (define_insn "lshrv2si3"
19414   [(set (match_operand:V2SI 0 "register_operand" "=y")
19415         (lshiftrt:V2SI (match_operand:V2SI 1 "register_operand" "0")
19416                        (match_operand:DI 2 "nonmemory_operand" "yi")))]
19417   "TARGET_MMX"
19418   "psrld\t{%2, %0|%0, %2}"
19419   [(set_attr "type" "mmxshft")
19420    (set_attr "mode" "DI")])
19422 ;; See logical MMX insns.
19423 (define_insn "mmx_lshrdi3"
19424   [(set (match_operand:DI 0 "register_operand" "=y")
19425         (unspec:DI
19426           [(lshiftrt:DI (match_operand:DI 1 "register_operand" "0")
19427                        (match_operand:DI 2 "nonmemory_operand" "yi"))]
19428           UNSPEC_NOP))]
19429   "TARGET_MMX"
19430   "psrlq\t{%2, %0|%0, %2}"
19431   [(set_attr "type" "mmxshft")
19432    (set_attr "mode" "DI")])
19434 (define_insn "ashlv4hi3"
19435   [(set (match_operand:V4HI 0 "register_operand" "=y")
19436         (ashift:V4HI (match_operand:V4HI 1 "register_operand" "0")
19437                        (match_operand:DI 2 "nonmemory_operand" "yi")))]
19438   "TARGET_MMX"
19439   "psllw\t{%2, %0|%0, %2}"
19440   [(set_attr "type" "mmxshft")
19441    (set_attr "mode" "DI")])
19443 (define_insn "ashlv2si3"
19444   [(set (match_operand:V2SI 0 "register_operand" "=y")
19445         (ashift:V2SI (match_operand:V2SI 1 "register_operand" "0")
19446                        (match_operand:DI 2 "nonmemory_operand" "yi")))]
19447   "TARGET_MMX"
19448   "pslld\t{%2, %0|%0, %2}"
19449   [(set_attr "type" "mmxshft")
19450    (set_attr "mode" "DI")])
19452 ;; See logical MMX insns.
19453 (define_insn "mmx_ashldi3"
19454   [(set (match_operand:DI 0 "register_operand" "=y")
19455         (unspec:DI
19456          [(ashift:DI (match_operand:DI 1 "register_operand" "0")
19457                      (match_operand:DI 2 "nonmemory_operand" "yi"))]
19458          UNSPEC_NOP))]
19459   "TARGET_MMX"
19460   "psllq\t{%2, %0|%0, %2}"
19461   [(set_attr "type" "mmxshft")
19462    (set_attr "mode" "DI")])
19465 ;; MMX pack/unpack insns.
19467 (define_insn "mmx_packsswb"
19468   [(set (match_operand:V8QI 0 "register_operand" "=y")
19469         (vec_concat:V8QI
19470          (ss_truncate:V4QI (match_operand:V4HI 1 "register_operand" "0"))
19471          (ss_truncate:V4QI (match_operand:V4HI 2 "register_operand" "y"))))]
19472   "TARGET_MMX"
19473   "packsswb\t{%2, %0|%0, %2}"
19474   [(set_attr "type" "mmxshft")
19475    (set_attr "mode" "DI")])
19477 (define_insn "mmx_packssdw"
19478   [(set (match_operand:V4HI 0 "register_operand" "=y")
19479         (vec_concat:V4HI
19480          (ss_truncate:V2HI (match_operand:V2SI 1 "register_operand" "0"))
19481          (ss_truncate:V2HI (match_operand:V2SI 2 "register_operand" "y"))))]
19482   "TARGET_MMX"
19483   "packssdw\t{%2, %0|%0, %2}"
19484   [(set_attr "type" "mmxshft")
19485    (set_attr "mode" "DI")])
19487 (define_insn "mmx_packuswb"
19488   [(set (match_operand:V8QI 0 "register_operand" "=y")
19489         (vec_concat:V8QI
19490          (us_truncate:V4QI (match_operand:V4HI 1 "register_operand" "0"))
19491          (us_truncate:V4QI (match_operand:V4HI 2 "register_operand" "y"))))]
19492   "TARGET_MMX"
19493   "packuswb\t{%2, %0|%0, %2}"
19494   [(set_attr "type" "mmxshft")
19495    (set_attr "mode" "DI")])
19497 (define_insn "mmx_punpckhbw"
19498   [(set (match_operand:V8QI 0 "register_operand" "=y")
19499         (vec_merge:V8QI
19500          (vec_select:V8QI (match_operand:V8QI 1 "register_operand" "0")
19501                           (parallel [(const_int 4)
19502                                      (const_int 0)
19503                                      (const_int 5)
19504                                      (const_int 1)
19505                                      (const_int 6)
19506                                      (const_int 2)
19507                                      (const_int 7)
19508                                      (const_int 3)]))
19509          (vec_select:V8QI (match_operand:V8QI 2 "register_operand" "y")
19510                           (parallel [(const_int 0)
19511                                      (const_int 4)
19512                                      (const_int 1)
19513                                      (const_int 5)
19514                                      (const_int 2)
19515                                      (const_int 6)
19516                                      (const_int 3)
19517                                      (const_int 7)]))
19518          (const_int 85)))]
19519   "TARGET_MMX"
19520   "punpckhbw\t{%2, %0|%0, %2}"
19521   [(set_attr "type" "mmxcvt")
19522    (set_attr "mode" "DI")])
19524 (define_insn "mmx_punpckhwd"
19525   [(set (match_operand:V4HI 0 "register_operand" "=y")
19526         (vec_merge:V4HI
19527          (vec_select:V4HI (match_operand:V4HI 1 "register_operand" "0")
19528                           (parallel [(const_int 0)
19529                                      (const_int 2)
19530                                      (const_int 1)
19531                                      (const_int 3)]))
19532          (vec_select:V4HI (match_operand:V4HI 2 "register_operand" "y")
19533                           (parallel [(const_int 2)
19534                                      (const_int 0)
19535                                      (const_int 3)
19536                                      (const_int 1)]))
19537          (const_int 5)))]
19538   "TARGET_MMX"
19539   "punpckhwd\t{%2, %0|%0, %2}"
19540   [(set_attr "type" "mmxcvt")
19541    (set_attr "mode" "DI")])
19543 (define_insn "mmx_punpckhdq"
19544   [(set (match_operand:V2SI 0 "register_operand" "=y")
19545         (vec_merge:V2SI
19546          (vec_select:V2SI (match_operand:V2SI 1 "register_operand" "0")
19547                           (parallel [(const_int 0)
19548                                      (const_int 1)]))
19549          (vec_select:V2SI (match_operand:V2SI 2 "register_operand" "y")
19550                           (parallel [(const_int 1)
19551                                      (const_int 0)]))
19552          (const_int 1)))]
19553   "TARGET_MMX"
19554   "punpckhdq\t{%2, %0|%0, %2}"
19555   [(set_attr "type" "mmxcvt")
19556    (set_attr "mode" "DI")])
19558 (define_insn "mmx_punpcklbw"
19559   [(set (match_operand:V8QI 0 "register_operand" "=y")
19560         (vec_merge:V8QI
19561          (vec_select:V8QI (match_operand:V8QI 1 "register_operand" "0")
19562                           (parallel [(const_int 0)
19563                                      (const_int 4)
19564                                      (const_int 1)
19565                                      (const_int 5)
19566                                      (const_int 2)
19567                                      (const_int 6)
19568                                      (const_int 3)
19569                                      (const_int 7)]))
19570          (vec_select:V8QI (match_operand:V8QI 2 "register_operand" "y")
19571                           (parallel [(const_int 4)
19572                                      (const_int 0)
19573                                      (const_int 5)
19574                                      (const_int 1)
19575                                      (const_int 6)
19576                                      (const_int 2)
19577                                      (const_int 7)
19578                                      (const_int 3)]))
19579          (const_int 85)))]
19580   "TARGET_MMX"
19581   "punpcklbw\t{%2, %0|%0, %2}"
19582   [(set_attr "type" "mmxcvt")
19583    (set_attr "mode" "DI")])
19585 (define_insn "mmx_punpcklwd"
19586   [(set (match_operand:V4HI 0 "register_operand" "=y")
19587         (vec_merge:V4HI
19588          (vec_select:V4HI (match_operand:V4HI 1 "register_operand" "0")
19589                           (parallel [(const_int 2)
19590                                      (const_int 0)
19591                                      (const_int 3)
19592                                      (const_int 1)]))
19593          (vec_select:V4HI (match_operand:V4HI 2 "register_operand" "y")
19594                           (parallel [(const_int 0)
19595                                      (const_int 2)
19596                                      (const_int 1)
19597                                      (const_int 3)]))
19598          (const_int 5)))]
19599   "TARGET_MMX"
19600   "punpcklwd\t{%2, %0|%0, %2}"
19601   [(set_attr "type" "mmxcvt")
19602    (set_attr "mode" "DI")])
19604 (define_insn "mmx_punpckldq"
19605   [(set (match_operand:V2SI 0 "register_operand" "=y")
19606         (vec_merge:V2SI
19607          (vec_select:V2SI (match_operand:V2SI 1 "register_operand" "0")
19608                            (parallel [(const_int 1)
19609                                       (const_int 0)]))
19610          (vec_select:V2SI (match_operand:V2SI 2 "register_operand" "y")
19611                           (parallel [(const_int 0)
19612                                      (const_int 1)]))
19613          (const_int 1)))]
19614   "TARGET_MMX"
19615   "punpckldq\t{%2, %0|%0, %2}"
19616   [(set_attr "type" "mmxcvt")
19617    (set_attr "mode" "DI")])
19620 ;; Miscellaneous stuff
19622 (define_insn "emms"
19623   [(unspec_volatile [(const_int 0)] UNSPECV_EMMS)
19624    (clobber (reg:XF 8))
19625    (clobber (reg:XF 9))
19626    (clobber (reg:XF 10))
19627    (clobber (reg:XF 11))
19628    (clobber (reg:XF 12))
19629    (clobber (reg:XF 13))
19630    (clobber (reg:XF 14))
19631    (clobber (reg:XF 15))
19632    (clobber (reg:DI 29))
19633    (clobber (reg:DI 30))
19634    (clobber (reg:DI 31))
19635    (clobber (reg:DI 32))
19636    (clobber (reg:DI 33))
19637    (clobber (reg:DI 34))
19638    (clobber (reg:DI 35))
19639    (clobber (reg:DI 36))]
19640   "TARGET_MMX"
19641   "emms"
19642   [(set_attr "type" "mmx")
19643    (set_attr "memory" "unknown")])
19645 (define_insn "ldmxcsr"
19646   [(unspec_volatile [(match_operand:SI 0 "memory_operand" "m")]
19647                     UNSPECV_LDMXCSR)]
19648   "TARGET_MMX"
19649   "ldmxcsr\t%0"
19650   [(set_attr "type" "mmx")
19651    (set_attr "memory" "load")])
19653 (define_insn "stmxcsr"
19654   [(set (match_operand:SI 0 "memory_operand" "=m")
19655         (unspec_volatile:SI [(const_int 0)] UNSPECV_STMXCSR))]
19656   "TARGET_MMX"
19657   "stmxcsr\t%0"
19658   [(set_attr "type" "mmx")
19659    (set_attr "memory" "store")])
19661 (define_expand "sfence"
19662   [(set (match_dup 0)
19663         (unspec:BLK [(match_dup 0)] UNSPEC_SFENCE))]
19664   "TARGET_SSE || TARGET_3DNOW_A"
19666   operands[0] = gen_rtx_MEM (BLKmode, gen_rtx_SCRATCH (Pmode));
19667   MEM_VOLATILE_P (operands[0]) = 1;
19670 (define_insn "*sfence_insn"
19671   [(set (match_operand:BLK 0 "" "")
19672         (unspec:BLK [(match_dup 0)] UNSPEC_SFENCE))]
19673   "TARGET_SSE || TARGET_3DNOW_A"
19674   "sfence"
19675   [(set_attr "type" "sse")
19676    (set_attr "memory" "unknown")])
19678 (define_expand "sse_prologue_save"
19679   [(parallel [(set (match_operand:BLK 0 "" "")
19680                    (unspec:BLK [(reg:DI 21)
19681                                 (reg:DI 22)
19682                                 (reg:DI 23)
19683                                 (reg:DI 24)
19684                                 (reg:DI 25)
19685                                 (reg:DI 26)
19686                                 (reg:DI 27)
19687                                 (reg:DI 28)] UNSPEC_SSE_PROLOGUE_SAVE))
19688               (use (match_operand:DI 1 "register_operand" ""))
19689               (use (match_operand:DI 2 "immediate_operand" ""))
19690               (use (label_ref:DI (match_operand 3 "" "")))])]
19691   "TARGET_64BIT"
19692   "")
19694 (define_insn "*sse_prologue_save_insn"
19695   [(set (mem:BLK (plus:DI (match_operand:DI 0 "register_operand" "R")
19696                           (match_operand:DI 4 "const_int_operand" "n")))
19697         (unspec:BLK [(reg:DI 21)
19698                      (reg:DI 22)
19699                      (reg:DI 23)
19700                      (reg:DI 24)
19701                      (reg:DI 25)
19702                      (reg:DI 26)
19703                      (reg:DI 27)
19704                      (reg:DI 28)] UNSPEC_SSE_PROLOGUE_SAVE))
19705    (use (match_operand:DI 1 "register_operand" "r"))
19706    (use (match_operand:DI 2 "const_int_operand" "i"))
19707    (use (label_ref:DI (match_operand 3 "" "X")))]
19708   "TARGET_64BIT
19709    && INTVAL (operands[4]) + SSE_REGPARM_MAX * 16 - 16 < 128
19710    && INTVAL (operands[4]) + INTVAL (operands[2]) * 16 >= -128"
19711   "*
19713   int i;
19714   operands[0] = gen_rtx_MEM (Pmode,
19715                              gen_rtx_PLUS (Pmode, operands[0], operands[4]));
19716   output_asm_insn (\"jmp\\t%A1\", operands);
19717   for (i = SSE_REGPARM_MAX - 1; i >= INTVAL (operands[2]); i--)
19718     {
19719       operands[4] = adjust_address (operands[0], DImode, i*16);
19720       operands[5] = gen_rtx_REG (TImode, SSE_REGNO (i));
19721       PUT_MODE (operands[4], TImode);
19722       if (GET_CODE (XEXP (operands[0], 0)) != PLUS)
19723         output_asm_insn (\"rex\", operands);
19724       output_asm_insn (\"movaps\\t{%5, %4|%4, %5}\", operands);
19725     }
19726   ASM_OUTPUT_INTERNAL_LABEL (asm_out_file, \"L\",
19727                              CODE_LABEL_NUMBER (operands[3]));
19728   RET;
19730   "
19731   [(set_attr "type" "other")
19732    (set_attr "length_immediate" "0")
19733    (set_attr "length_address" "0")
19734    (set_attr "length" "135")
19735    (set_attr "memory" "store")
19736    (set_attr "modrm" "0")
19737    (set_attr "mode" "DI")])
19739 ;; 3Dnow! instructions
19741 (define_insn "addv2sf3"
19742   [(set (match_operand:V2SF 0 "register_operand" "=y")
19743         (plus:V2SF (match_operand:V2SF 1 "register_operand" "0")
19744                    (match_operand:V2SF 2 "nonimmediate_operand" "ym")))]
19745   "TARGET_3DNOW"
19746   "pfadd\\t{%2, %0|%0, %2}"
19747   [(set_attr "type" "mmxadd")
19748    (set_attr "mode" "V2SF")])
19750 (define_insn "subv2sf3"
19751   [(set (match_operand:V2SF 0 "register_operand" "=y")
19752         (minus:V2SF (match_operand:V2SF 1 "register_operand" "0")
19753                     (match_operand:V2SF 2 "nonimmediate_operand" "ym")))]
19754   "TARGET_3DNOW"
19755   "pfsub\\t{%2, %0|%0, %2}"
19756   [(set_attr "type" "mmxadd")
19757    (set_attr "mode" "V2SF")])
19759 (define_insn "subrv2sf3"
19760   [(set (match_operand:V2SF 0 "register_operand" "=y")
19761         (minus:V2SF (match_operand:V2SF 2 "nonimmediate_operand" "ym")
19762                     (match_operand:V2SF 1 "register_operand" "0")))]
19763   "TARGET_3DNOW"
19764   "pfsubr\\t{%2, %0|%0, %2}"
19765   [(set_attr "type" "mmxadd")
19766    (set_attr "mode" "V2SF")])
19768 (define_insn "gtv2sf3"
19769   [(set (match_operand:V2SI 0 "register_operand" "=y")
19770         (gt:V2SI (match_operand:V2SF 1 "register_operand" "0")
19771                  (match_operand:V2SF 2 "nonimmediate_operand" "ym")))]
19772  "TARGET_3DNOW"
19773   "pfcmpgt\\t{%2, %0|%0, %2}"
19774   [(set_attr "type" "mmxcmp")
19775    (set_attr "mode" "V2SF")])
19777 (define_insn "gev2sf3"
19778   [(set (match_operand:V2SI 0 "register_operand" "=y")
19779         (ge:V2SI (match_operand:V2SF 1 "register_operand" "0")
19780                  (match_operand:V2SF 2 "nonimmediate_operand" "ym")))]
19781   "TARGET_3DNOW"
19782   "pfcmpge\\t{%2, %0|%0, %2}"
19783   [(set_attr "type" "mmxcmp")
19784    (set_attr "mode" "V2SF")])
19786 (define_insn "eqv2sf3"
19787   [(set (match_operand:V2SI 0 "register_operand" "=y")
19788         (eq:V2SI (match_operand:V2SF 1 "register_operand" "0")
19789                  (match_operand:V2SF 2 "nonimmediate_operand" "ym")))]
19790   "TARGET_3DNOW"
19791   "pfcmpeq\\t{%2, %0|%0, %2}"
19792   [(set_attr "type" "mmxcmp")
19793    (set_attr "mode" "V2SF")])
19795 (define_insn "pfmaxv2sf3"
19796   [(set (match_operand:V2SF 0 "register_operand" "=y")
19797         (smax:V2SF (match_operand:V2SF 1 "register_operand" "0")
19798                    (match_operand:V2SF 2 "nonimmediate_operand" "ym")))]
19799   "TARGET_3DNOW"
19800   "pfmax\\t{%2, %0|%0, %2}"
19801   [(set_attr "type" "mmxadd")
19802    (set_attr "mode" "V2SF")])
19804 (define_insn "pfminv2sf3"
19805   [(set (match_operand:V2SF 0 "register_operand" "=y")
19806         (smin:V2SF (match_operand:V2SF 1 "register_operand" "0")
19807                    (match_operand:V2SF 2 "nonimmediate_operand" "ym")))]
19808   "TARGET_3DNOW"
19809   "pfmin\\t{%2, %0|%0, %2}"
19810   [(set_attr "type" "mmxadd")
19811    (set_attr "mode" "V2SF")])
19813 (define_insn "mulv2sf3"
19814   [(set (match_operand:V2SF 0 "register_operand" "=y")
19815         (mult:V2SF (match_operand:V2SF 1 "register_operand" "0")
19816                    (match_operand:V2SF 2 "nonimmediate_operand" "ym")))]
19817   "TARGET_3DNOW"
19818   "pfmul\\t{%2, %0|%0, %2}"
19819   [(set_attr "type" "mmxmul")
19820    (set_attr "mode" "V2SF")])
19822 (define_insn "femms"
19823   [(unspec_volatile [(const_int 0)] UNSPECV_FEMMS)
19824    (clobber (reg:XF 8))
19825    (clobber (reg:XF 9))
19826    (clobber (reg:XF 10))
19827    (clobber (reg:XF 11))
19828    (clobber (reg:XF 12))
19829    (clobber (reg:XF 13))
19830    (clobber (reg:XF 14))
19831    (clobber (reg:XF 15))
19832    (clobber (reg:DI 29))
19833    (clobber (reg:DI 30))
19834    (clobber (reg:DI 31))
19835    (clobber (reg:DI 32))
19836    (clobber (reg:DI 33))
19837    (clobber (reg:DI 34))
19838    (clobber (reg:DI 35))
19839    (clobber (reg:DI 36))]
19840   "TARGET_3DNOW"
19841   "femms"
19842   [(set_attr "type" "mmx")
19843    (set_attr "memory" "none")]) 
19845 (define_insn "pf2id"
19846   [(set (match_operand:V2SI 0 "register_operand" "=y")
19847         (fix:V2SI (match_operand:V2SF 1 "nonimmediate_operand" "ym")))]
19848   "TARGET_3DNOW"
19849   "pf2id\\t{%1, %0|%0, %1}"
19850   [(set_attr "type" "mmxcvt")
19851    (set_attr "mode" "V2SF")])
19853 (define_insn "pf2iw"
19854   [(set (match_operand:V2SI 0 "register_operand" "=y")
19855         (sign_extend:V2SI
19856            (ss_truncate:V2HI
19857               (fix:V2SI (match_operand:V2SF 1 "nonimmediate_operand" "ym")))))]
19858   "TARGET_3DNOW_A"
19859   "pf2iw\\t{%1, %0|%0, %1}"
19860   [(set_attr "type" "mmxcvt")
19861    (set_attr "mode" "V2SF")])
19863 (define_insn "pfacc"
19864   [(set (match_operand:V2SF 0 "register_operand" "=y")
19865         (vec_concat:V2SF
19866            (plus:SF
19867               (vec_select:SF (match_operand:V2SF 1 "register_operand" "0")
19868                              (parallel [(const_int  0)]))
19869               (vec_select:SF (match_dup 1)
19870                              (parallel [(const_int 1)])))
19871            (plus:SF
19872               (vec_select:SF (match_operand:V2SF 2 "nonimmediate_operand" "y")
19873                              (parallel [(const_int  0)]))
19874               (vec_select:SF (match_dup 2)
19875                              (parallel [(const_int 1)])))))]
19876   "TARGET_3DNOW"
19877   "pfacc\\t{%2, %0|%0, %2}"
19878   [(set_attr "type" "mmxadd")
19879    (set_attr "mode" "V2SF")])
19881 (define_insn "pfnacc"
19882   [(set (match_operand:V2SF 0 "register_operand" "=y")
19883         (vec_concat:V2SF
19884            (minus:SF
19885               (vec_select:SF (match_operand:V2SF 1 "register_operand" "0")
19886                              (parallel [(const_int 0)]))
19887               (vec_select:SF (match_dup 1)
19888                              (parallel [(const_int 1)])))
19889            (minus:SF
19890               (vec_select:SF (match_operand:V2SF 2 "nonimmediate_operand" "y")
19891                              (parallel [(const_int  0)]))
19892               (vec_select:SF (match_dup 2)
19893                              (parallel [(const_int 1)])))))]
19894   "TARGET_3DNOW_A"
19895   "pfnacc\\t{%2, %0|%0, %2}"
19896   [(set_attr "type" "mmxadd")
19897    (set_attr "mode" "V2SF")])
19899 (define_insn "pfpnacc"
19900   [(set (match_operand:V2SF 0 "register_operand" "=y")
19901         (vec_concat:V2SF
19902            (minus:SF
19903               (vec_select:SF (match_operand:V2SF 1 "register_operand" "0")
19904                              (parallel [(const_int 0)]))
19905               (vec_select:SF (match_dup 1)
19906                              (parallel [(const_int 1)])))
19907            (plus:SF
19908               (vec_select:SF (match_operand:V2SF 2 "nonimmediate_operand" "y")
19909                              (parallel [(const_int 0)]))
19910               (vec_select:SF (match_dup 2)
19911                              (parallel [(const_int 1)])))))]
19912   "TARGET_3DNOW_A"
19913   "pfpnacc\\t{%2, %0|%0, %2}"
19914   [(set_attr "type" "mmxadd")
19915    (set_attr "mode" "V2SF")])
19917 (define_insn "pi2fw"
19918   [(set (match_operand:V2SF 0 "register_operand" "=y")
19919         (float:V2SF
19920            (vec_concat:V2SI
19921               (sign_extend:SI
19922                  (truncate:HI
19923                     (vec_select:SI (match_operand:V2SI 1 "nonimmediate_operand" "ym")
19924                                    (parallel [(const_int 0)]))))
19925               (sign_extend:SI
19926                  (truncate:HI
19927                     (vec_select:SI (match_dup 1)
19928                                    (parallel [(const_int  1)])))))))]
19929   "TARGET_3DNOW_A"
19930   "pi2fw\\t{%1, %0|%0, %1}"
19931   [(set_attr "type" "mmxcvt")
19932    (set_attr "mode" "V2SF")])
19934 (define_insn "floatv2si2"
19935   [(set (match_operand:V2SF 0 "register_operand" "=y")
19936         (float:V2SF (match_operand:V2SI 1 "nonimmediate_operand" "ym")))]
19937   "TARGET_3DNOW"
19938   "pi2fd\\t{%1, %0|%0, %1}"
19939   [(set_attr "type" "mmxcvt")
19940    (set_attr "mode" "V2SF")])
19942 ;; This insn is identical to pavgb in operation, but the opcode is
19943 ;; different.  To avoid accidentally matching pavgb, use an unspec.
19945 (define_insn "pavgusb"
19946  [(set (match_operand:V8QI 0 "register_operand" "=y")
19947        (unspec:V8QI
19948           [(match_operand:V8QI 1 "register_operand" "0")
19949            (match_operand:V8QI 2 "nonimmediate_operand" "ym")]
19950           UNSPEC_PAVGUSB))]
19951   "TARGET_3DNOW"
19952   "pavgusb\\t{%2, %0|%0, %2}"
19953   [(set_attr "type" "mmxshft")
19954    (set_attr "mode" "TI")])
19956 ;; 3DNow reciprical and sqrt
19958 (define_insn "pfrcpv2sf2"
19959   [(set (match_operand:V2SF 0 "register_operand" "=y")
19960         (unspec:V2SF [(match_operand:V2SF 1 "nonimmediate_operand" "ym")]
19961         UNSPEC_PFRCP))]
19962   "TARGET_3DNOW"
19963   "pfrcp\\t{%1, %0|%0, %1}"
19964   [(set_attr "type" "mmx")
19965    (set_attr "mode" "TI")])
19967 (define_insn "pfrcpit1v2sf3"
19968   [(set (match_operand:V2SF 0 "register_operand" "=y")
19969         (unspec:V2SF [(match_operand:V2SF 1 "register_operand" "0")
19970                       (match_operand:V2SF 2 "nonimmediate_operand" "ym")]
19971                      UNSPEC_PFRCPIT1))]
19972   "TARGET_3DNOW"
19973   "pfrcpit1\\t{%2, %0|%0, %2}"
19974   [(set_attr "type" "mmx")
19975    (set_attr "mode" "TI")])
19977 (define_insn "pfrcpit2v2sf3"
19978   [(set (match_operand:V2SF 0 "register_operand" "=y")
19979         (unspec:V2SF [(match_operand:V2SF 1 "register_operand" "0")
19980                       (match_operand:V2SF 2 "nonimmediate_operand" "ym")]
19981                      UNSPEC_PFRCPIT2))]
19982   "TARGET_3DNOW"
19983   "pfrcpit2\\t{%2, %0|%0, %2}"
19984   [(set_attr "type" "mmx")
19985    (set_attr "mode" "TI")])
19987 (define_insn "pfrsqrtv2sf2"
19988   [(set (match_operand:V2SF 0 "register_operand" "=y")
19989         (unspec:V2SF [(match_operand:V2SF 1 "nonimmediate_operand" "ym")]
19990                      UNSPEC_PFRSQRT))]
19991   "TARGET_3DNOW"
19992   "pfrsqrt\\t{%1, %0|%0, %1}"
19993   [(set_attr "type" "mmx")
19994    (set_attr "mode" "TI")])
19995                 
19996 (define_insn "pfrsqit1v2sf3"
19997   [(set (match_operand:V2SF 0 "register_operand" "=y")
19998         (unspec:V2SF [(match_operand:V2SF 1 "register_operand" "0")
19999                       (match_operand:V2SF 2 "nonimmediate_operand" "ym")]
20000                      UNSPEC_PFRSQIT1))]
20001   "TARGET_3DNOW"
20002   "pfrsqit1\\t{%2, %0|%0, %2}"
20003   [(set_attr "type" "mmx")
20004    (set_attr "mode" "TI")])
20006 (define_insn "pmulhrwv4hi3"
20007   [(set (match_operand:V4HI 0 "register_operand" "=y")
20008         (truncate:V4HI
20009            (lshiftrt:V4SI
20010               (plus:V4SI
20011                  (mult:V4SI
20012                     (sign_extend:V4SI
20013                        (match_operand:V4HI 1 "register_operand" "0"))
20014                     (sign_extend:V4SI
20015                        (match_operand:V4HI 2 "nonimmediate_operand" "ym")))
20016                  (const_vector:V4SI [(const_int 32768)
20017                                      (const_int 32768)
20018                                      (const_int 32768)
20019                                      (const_int 32768)]))
20020               (const_int 16))))]
20021   "TARGET_3DNOW"
20022   "pmulhrw\\t{%2, %0|%0, %2}"
20023   [(set_attr "type" "mmxmul")
20024    (set_attr "mode" "TI")])
20026 (define_insn "pswapdv2si2"
20027   [(set (match_operand:V2SI 0 "register_operand" "=y")
20028         (vec_select:V2SI (match_operand:V2SI 1 "nonimmediate_operand" "ym")
20029                          (parallel [(const_int 1) (const_int 0)])))]
20030   "TARGET_3DNOW_A"
20031   "pswapd\\t{%1, %0|%0, %1}"
20032   [(set_attr "type" "mmxcvt")
20033    (set_attr "mode" "TI")])
20035 (define_insn "pswapdv2sf2"
20036   [(set (match_operand:V2SF 0 "register_operand" "=y")
20037         (vec_select:V2SF (match_operand:V2SF 1 "nonimmediate_operand" "ym")
20038                          (parallel [(const_int 1) (const_int 0)])))]
20039   "TARGET_3DNOW_A"
20040   "pswapd\\t{%1, %0|%0, %1}"
20041   [(set_attr "type" "mmxcvt")
20042    (set_attr "mode" "TI")])
20044 (define_expand "prefetch"
20045   [(prefetch (match_operand 0 "address_operand" "")
20046              (match_operand:SI 1 "const_int_operand" "")
20047              (match_operand:SI 2 "const_int_operand" ""))]
20048   "TARGET_PREFETCH_SSE || TARGET_3DNOW"
20050   int rw = INTVAL (operands[1]);
20051   int locality = INTVAL (operands[2]);
20053   if (rw != 0 && rw != 1)
20054     abort ();
20055   if (locality < 0 || locality > 3)
20056     abort ();
20057   if (GET_MODE (operands[0]) != Pmode && GET_MODE (operands[0]) != VOIDmode)
20058     abort ();
20060   /* Use 3dNOW prefetch in case we are asking for write prefetch not
20061      suported by SSE counterpart or the SSE prefetch is not available
20062      (K6 machines).  Otherwise use SSE prefetch as it allows specifying
20063      of locality.  */
20064   if (TARGET_3DNOW && (!TARGET_PREFETCH_SSE || rw))
20065     operands[2] = GEN_INT (3);
20066   else
20067     operands[1] = const0_rtx;
20070 (define_insn "*prefetch_sse"
20071   [(prefetch (match_operand:SI 0 "address_operand" "p")
20072              (const_int 0)
20073              (match_operand:SI 1 "const_int_operand" ""))]
20074   "TARGET_PREFETCH_SSE && !TARGET_64BIT"
20076   static const char * const patterns[4] = {
20077    "prefetchnta\t%a0", "prefetcht2\t%a0", "prefetcht1\t%a0", "prefetcht0\t%a0"
20078   };
20080   int locality = INTVAL (operands[1]);
20081   if (locality < 0 || locality > 3)
20082     abort ();
20084   return patterns[locality];  
20086   [(set_attr "type" "sse")
20087    (set_attr "memory" "none")])
20089 (define_insn "*prefetch_sse_rex"
20090   [(prefetch (match_operand:DI 0 "address_operand" "p")
20091              (const_int 0)
20092              (match_operand:SI 1 "const_int_operand" ""))]
20093   "TARGET_PREFETCH_SSE && TARGET_64BIT"
20095   static const char * const patterns[4] = {
20096    "prefetchnta\t%a0", "prefetcht2\t%a0", "prefetcht1\t%a0", "prefetcht0\t%a0"
20097   };
20099   int locality = INTVAL (operands[1]);
20100   if (locality < 0 || locality > 3)
20101     abort ();
20103   return patterns[locality];  
20105   [(set_attr "type" "sse")
20106    (set_attr "memory" "none")])
20108 (define_insn "*prefetch_3dnow"
20109   [(prefetch (match_operand:SI 0 "address_operand" "p")
20110              (match_operand:SI 1 "const_int_operand" "n")
20111              (const_int 3))]
20112   "TARGET_3DNOW && !TARGET_64BIT"
20114   if (INTVAL (operands[1]) == 0)
20115     return "prefetch\t%a0";
20116   else
20117     return "prefetchw\t%a0";
20119   [(set_attr "type" "mmx")
20120    (set_attr "memory" "none")])
20122 (define_insn "*prefetch_3dnow_rex"
20123   [(prefetch (match_operand:DI 0 "address_operand" "p")
20124              (match_operand:SI 1 "const_int_operand" "n")
20125              (const_int 3))]
20126   "TARGET_3DNOW && TARGET_64BIT"
20128   if (INTVAL (operands[1]) == 0)
20129     return "prefetch\t%a0";
20130   else
20131     return "prefetchw\t%a0";
20133   [(set_attr "type" "mmx")
20134    (set_attr "memory" "none")])
20136 ;; SSE2 support
20138 (define_insn "addv2df3"
20139   [(set (match_operand:V2DF 0 "register_operand" "=x")
20140         (plus:V2DF (match_operand:V2DF 1 "register_operand" "0")
20141                    (match_operand:V2DF 2 "nonimmediate_operand" "xm")))]
20142   "TARGET_SSE2"
20143   "addpd\t{%2, %0|%0, %2}"
20144   [(set_attr "type" "sseadd")
20145    (set_attr "mode" "V2DF")])
20147 (define_insn "vmaddv2df3"
20148   [(set (match_operand:V2DF 0 "register_operand" "=x")
20149         (vec_merge:V2DF (plus:V2DF (match_operand:V2DF 1 "register_operand" "0")
20150                                    (match_operand:V2DF 2 "nonimmediate_operand" "xm"))
20151                         (match_dup 1)
20152                         (const_int 1)))]
20153   "TARGET_SSE2"
20154   "addsd\t{%2, %0|%0, %2}"
20155   [(set_attr "type" "sseadd")
20156    (set_attr "mode" "DF")])
20158 (define_insn "subv2df3"
20159   [(set (match_operand:V2DF 0 "register_operand" "=x")
20160         (minus:V2DF (match_operand:V2DF 1 "register_operand" "0")
20161                    (match_operand:V2DF 2 "nonimmediate_operand" "xm")))]
20162   "TARGET_SSE2"
20163   "subpd\t{%2, %0|%0, %2}"
20164   [(set_attr "type" "sseadd")
20165    (set_attr "mode" "V2DF")])
20167 (define_insn "vmsubv2df3"
20168   [(set (match_operand:V2DF 0 "register_operand" "=x")
20169         (vec_merge:V2DF (minus:V2DF (match_operand:V2DF 1 "register_operand" "0")
20170                                    (match_operand:V2DF 2 "nonimmediate_operand" "xm"))
20171                         (match_dup 1)
20172                         (const_int 1)))]
20173   "TARGET_SSE2"
20174   "subsd\t{%2, %0|%0, %2}"
20175   [(set_attr "type" "sseadd")
20176    (set_attr "mode" "DF")])
20178 (define_insn "mulv2df3"
20179   [(set (match_operand:V2DF 0 "register_operand" "=x")
20180         (mult:V2DF (match_operand:V2DF 1 "register_operand" "0")
20181                    (match_operand:V2DF 2 "nonimmediate_operand" "xm")))]
20182   "TARGET_SSE2"
20183   "mulpd\t{%2, %0|%0, %2}"
20184   [(set_attr "type" "ssemul")
20185    (set_attr "mode" "V2DF")])
20187 (define_insn "vmmulv2df3"
20188   [(set (match_operand:V2DF 0 "register_operand" "=x")
20189         (vec_merge:V2DF (mult:V2DF (match_operand:V2DF 1 "register_operand" "0")
20190                                    (match_operand:V2DF 2 "nonimmediate_operand" "xm"))
20191                         (match_dup 1)
20192                         (const_int 1)))]
20193   "TARGET_SSE2"
20194   "mulsd\t{%2, %0|%0, %2}"
20195   [(set_attr "type" "ssemul")
20196    (set_attr "mode" "DF")])
20198 (define_insn "divv2df3"
20199   [(set (match_operand:V2DF 0 "register_operand" "=x")
20200         (div:V2DF (match_operand:V2DF 1 "register_operand" "0")
20201                   (match_operand:V2DF 2 "nonimmediate_operand" "xm")))]
20202   "TARGET_SSE2"
20203   "divpd\t{%2, %0|%0, %2}"
20204   [(set_attr "type" "ssediv")
20205    (set_attr "mode" "V2DF")])
20207 (define_insn "vmdivv2df3"
20208   [(set (match_operand:V2DF 0 "register_operand" "=x")
20209         (vec_merge:V2DF (div:V2DF (match_operand:V2DF 1 "register_operand" "0")
20210                                   (match_operand:V2DF 2 "nonimmediate_operand" "xm"))
20211                         (match_dup 1)
20212                         (const_int 1)))]
20213   "TARGET_SSE2"
20214   "divsd\t{%2, %0|%0, %2}"
20215   [(set_attr "type" "ssediv")
20216    (set_attr "mode" "DF")])
20218 ;; SSE min/max
20220 (define_insn "smaxv2df3"
20221   [(set (match_operand:V2DF 0 "register_operand" "=x")
20222         (smax:V2DF (match_operand:V2DF 1 "register_operand" "0")
20223                    (match_operand:V2DF 2 "nonimmediate_operand" "xm")))]
20224   "TARGET_SSE2"
20225   "maxpd\t{%2, %0|%0, %2}"
20226   [(set_attr "type" "sseadd")
20227    (set_attr "mode" "V2DF")])
20229 (define_insn "vmsmaxv2df3"
20230   [(set (match_operand:V2DF 0 "register_operand" "=x")
20231         (vec_merge:V2DF (smax:V2DF (match_operand:V2DF 1 "register_operand" "0")
20232                                    (match_operand:V2DF 2 "nonimmediate_operand" "xm"))
20233                         (match_dup 1)
20234                         (const_int 1)))]
20235   "TARGET_SSE2"
20236   "maxsd\t{%2, %0|%0, %2}"
20237   [(set_attr "type" "sseadd")
20238    (set_attr "mode" "DF")])
20240 (define_insn "sminv2df3"
20241   [(set (match_operand:V2DF 0 "register_operand" "=x")
20242         (smin:V2DF (match_operand:V2DF 1 "register_operand" "0")
20243                    (match_operand:V2DF 2 "nonimmediate_operand" "xm")))]
20244   "TARGET_SSE2"
20245   "minpd\t{%2, %0|%0, %2}"
20246   [(set_attr "type" "sseadd")
20247    (set_attr "mode" "V2DF")])
20249 (define_insn "vmsminv2df3"
20250   [(set (match_operand:V2DF 0 "register_operand" "=x")
20251         (vec_merge:V2DF (smin:V2DF (match_operand:V2DF 1 "register_operand" "0")
20252                                    (match_operand:V2DF 2 "nonimmediate_operand" "xm"))
20253                         (match_dup 1)
20254                         (const_int 1)))]
20255   "TARGET_SSE2"
20256   "minsd\t{%2, %0|%0, %2}"
20257   [(set_attr "type" "sseadd")
20258    (set_attr "mode" "DF")])
20260 (define_insn "sse2_anddf3"
20261   [(set (match_operand:V2DF 0 "register_operand" "=x")
20262         (subreg:V2DF (and:TI (subreg:TI (match_operand:V2DF 1 "register_operand" "%0") 0)
20263                              (subreg:TI (match_operand:V2DF 2 "nonimmediate_operand" "xm") 0)) 0))]
20264   "TARGET_SSE2"
20265   "andpd\t{%2, %0|%0, %2}"
20266   [(set_attr "type" "sselog")
20267    (set_attr "mode" "V2DF")])
20269 (define_insn "sse2_nanddf3"
20270   [(set (match_operand:V2DF 0 "register_operand" "=x")
20271         (subreg:V2DF (and:TI (not:TI (subreg:TI (match_operand:V2DF 1 "register_operand" "0") 0))
20272                              (subreg:TI (match_operand:V2DF 2 "nonimmediate_operand" "xm") 0)) 0))]
20273   "TARGET_SSE2"
20274   "andnpd\t{%2, %0|%0, %2}"
20275   [(set_attr "type" "sselog")
20276    (set_attr "mode" "V2DF")])
20278 (define_insn "sse2_iordf3"
20279   [(set (match_operand:V2DF 0 "register_operand" "=x")
20280         (subreg:V2DF (ior:TI (subreg:TI (match_operand:V2DF 1 "register_operand" "%0") 0)
20281                              (subreg:TI (match_operand:V2DF 2 "nonimmediate_operand" "xm") 0)) 0))]
20282   "TARGET_SSE2"
20283   "orpd\t{%2, %0|%0, %2}"
20284   [(set_attr "type" "sselog")
20285    (set_attr "mode" "V2DF")])
20287 (define_insn "sse2_xordf3"
20288   [(set (match_operand:V2DF 0 "register_operand" "=x")
20289         (subreg:V2DF (xor:TI (subreg:TI (match_operand:V2DF 1 "register_operand" "%0") 0)
20290                              (subreg:TI (match_operand:V2DF 2 "nonimmediate_operand" "xm") 0)) 0))]
20291   "TARGET_SSE2"
20292   "xorpd\t{%2, %0|%0, %2}"
20293   [(set_attr "type" "sselog")
20294    (set_attr "mode" "V2DF")])
20295 ;; SSE2 square root.  There doesn't appear to be an extension for the
20296 ;; reciprocal/rsqrt instructions if the Intel manual is to be believed.
20298 (define_insn "sqrtv2df2"
20299   [(set (match_operand:V2DF 0 "register_operand" "=x")
20300         (sqrt:V2DF (match_operand:V2DF 1 "register_operand" "xm")))]
20301   "TARGET_SSE2"
20302   "sqrtpd\t{%1, %0|%0, %1}"
20303   [(set_attr "type" "sse")
20304    (set_attr "mode" "V2DF")])
20306 (define_insn "vmsqrtv2df2"
20307   [(set (match_operand:V2DF 0 "register_operand" "=x")
20308         (vec_merge:V2DF (sqrt:V2DF (match_operand:V2DF 1 "register_operand" "xm"))
20309                         (match_operand:V2DF 2 "register_operand" "0")
20310                         (const_int 1)))]
20311   "TARGET_SSE2"
20312   "sqrtsd\t{%1, %0|%0, %1}"
20313   [(set_attr "type" "sse")
20314    (set_attr "mode" "SF")])
20316 ;; SSE mask-generating compares
20318 (define_insn "maskcmpv2df3"
20319   [(set (match_operand:V2DI 0 "register_operand" "=x")
20320         (match_operator:V2DI 3 "sse_comparison_operator"
20321                              [(match_operand:V2DF 1 "register_operand" "0")
20322                               (match_operand:V2DF 2 "nonimmediate_operand" "x")]))]
20323   "TARGET_SSE2"
20324   "cmp%D3pd\t{%2, %0|%0, %2}"
20325   [(set_attr "type" "ssecmp")
20326    (set_attr "mode" "V2DF")])
20328 (define_insn "maskncmpv2df3"
20329   [(set (match_operand:V2DI 0 "register_operand" "=x")
20330         (not:V2DI
20331          (match_operator:V2DI 3 "sse_comparison_operator"
20332                               [(match_operand:V2DF 1 "register_operand" "0")
20333                                (match_operand:V2DF 2 "nonimmediate_operand" "x")])))]
20334   "TARGET_SSE2"
20335   "cmpn%D3pd\t{%2, %0|%0, %2}"
20336   [(set_attr "type" "ssecmp")
20337    (set_attr "mode" "V2DF")])
20339 (define_insn "vmmaskcmpv2df3"
20340   [(set (match_operand:V2DI 0 "register_operand" "=x")
20341         (vec_merge:V2DI
20342          (match_operator:V2DI 3 "sse_comparison_operator"
20343                               [(match_operand:V2DF 1 "register_operand" "0")
20344                                (match_operand:V2DF 2 "nonimmediate_operand" "x")])
20345          (match_dup 1)
20346          (const_int 1)))]
20347   "TARGET_SSE2"
20348   "cmp%D3sd\t{%2, %0|%0, %2}"
20349   [(set_attr "type" "ssecmp")
20350    (set_attr "mode" "DF")])
20352 (define_insn "vmmaskncmpv2df3"
20353   [(set (match_operand:V2DI 0 "register_operand" "=x")
20354         (vec_merge:V2DI
20355          (not:V2DI
20356           (match_operator:V2DI 3 "sse_comparison_operator"
20357                                [(match_operand:V2DF 1 "register_operand" "0")
20358                                 (match_operand:V2DF 2 "nonimmediate_operand" "x")]))
20359          (subreg:V2DI (match_dup 1) 0)
20360          (const_int 1)))]
20361   "TARGET_SSE2"
20362   "cmp%D3sd\t{%2, %0|%0, %2}"
20363   [(set_attr "type" "ssecmp")
20364    (set_attr "mode" "DF")])
20366 (define_insn "sse2_comi"
20367   [(set (reg:CCFP 17)
20368         (match_operator:CCFP 2 "sse_comparison_operator"
20369                         [(vec_select:DF
20370                           (match_operand:V2DF 0 "register_operand" "x")
20371                           (parallel [(const_int 0)]))
20372                          (vec_select:DF
20373                           (match_operand:V2DF 1 "register_operand" "x")
20374                           (parallel [(const_int 0)]))]))]
20375   "TARGET_SSE2"
20376   "comisd\t{%1, %0|%0, %1}"
20377   [(set_attr "type" "ssecmp")
20378    (set_attr "mode" "DF")])
20380 (define_insn "sse2_ucomi"
20381   [(set (reg:CCFPU 17)
20382         (match_operator:CCFPU 2 "sse_comparison_operator"
20383                         [(vec_select:DF
20384                           (match_operand:V2DF 0 "register_operand" "x")
20385                           (parallel [(const_int 0)]))
20386                          (vec_select:DF
20387                           (match_operand:V2DF 1 "register_operand" "x")
20388                           (parallel [(const_int 0)]))]))]
20389   "TARGET_SSE2"
20390   "ucomisd\t{%1, %0|%0, %1}"
20391   [(set_attr "type" "ssecmp")
20392    (set_attr "mode" "DF")])
20394 ;; SSE Strange Moves.
20396 (define_insn "sse2_movmskpd"
20397   [(set (match_operand:SI 0 "register_operand" "=r")
20398         (unspec:SI [(match_operand:V2DF 1 "register_operand" "x")]
20399                    UNSPEC_MOVMSK))]
20400   "TARGET_SSE2"
20401   "movmskpd\t{%1, %0|%0, %1}"
20402   [(set_attr "type" "ssecvt")
20403    (set_attr "mode" "V2DF")])
20405 (define_insn "sse2_pmovmskb"
20406   [(set (match_operand:SI 0 "register_operand" "=r")
20407         (unspec:SI [(match_operand:V16QI 1 "register_operand" "x")]
20408                    UNSPEC_MOVMSK))]
20409   "TARGET_SSE2"
20410   "pmovmskb\t{%1, %0|%0, %1}"
20411   [(set_attr "type" "ssecvt")
20412    (set_attr "mode" "V2DF")])
20414 (define_insn "sse2_maskmovdqu"
20415   [(set (mem:V16QI (match_operand:SI 0 "register_operand" "D"))
20416         (unspec:V16QI [(match_operand:V16QI 1 "register_operand" "x")
20417                        (match_operand:V16QI 2 "register_operand" "x")]
20418                       UNSPEC_MASKMOV))]
20419   "TARGET_SSE2"
20420   ;; @@@ check ordering of operands in intel/nonintel syntax
20421   "maskmovdqu\t{%2, %1|%1, %2}"
20422   [(set_attr "type" "ssecvt")
20423    (set_attr "mode" "TI")])
20425 (define_insn "sse2_movntv2df"
20426   [(set (match_operand:V2DF 0 "memory_operand" "=m")
20427         (unspec:V2DF [(match_operand:V2DF 1 "register_operand" "x")]
20428                      UNSPEC_MOVNT))]
20429   "TARGET_SSE2"
20430   "movntpd\t{%1, %0|%0, %1}"
20431   [(set_attr "type" "ssecvt")
20432    (set_attr "mode" "V2DF")])
20434 (define_insn "sse2_movntv2di"
20435   [(set (match_operand:V2DI 0 "memory_operand" "=m")
20436         (unspec:V2DI [(match_operand:V2DI 1 "register_operand" "x")]
20437                      UNSPEC_MOVNT))]
20438   "TARGET_SSE2"
20439   "movntdq\t{%1, %0|%0, %1}"
20440   [(set_attr "type" "ssecvt")
20441    (set_attr "mode" "TI")])
20443 (define_insn "sse2_movntsi"
20444   [(set (match_operand:SI 0 "memory_operand" "=m")
20445         (unspec:SI [(match_operand:SI 1 "register_operand" "r")]
20446                    UNSPEC_MOVNT))]
20447   "TARGET_SSE2"
20448   "movnti\t{%1, %0|%0, %1}"
20449   [(set_attr "type" "ssecvt")
20450    (set_attr "mode" "V2DF")])
20452 ;; SSE <-> integer/MMX conversions
20454 ;; Conversions between SI and SF
20456 (define_insn "cvtdq2ps"
20457   [(set (match_operand:V4SF 0 "register_operand" "=x")
20458         (float:V4SF (match_operand:V4SI 1 "nonimmediate_operand" "xm")))]
20459   "TARGET_SSE2"
20460   "cvtdq2ps\t{%1, %0|%0, %1}"
20461   [(set_attr "type" "ssecvt")
20462    (set_attr "mode" "V2DF")])
20464 (define_insn "cvtps2dq"
20465   [(set (match_operand:V4SI 0 "register_operand" "=x")
20466         (fix:V4SI (match_operand:V4SF 1 "nonimmediate_operand" "xm")))]
20467   "TARGET_SSE2"
20468   "cvtps2dq\t{%1, %0|%0, %1}"
20469   [(set_attr "type" "ssecvt")
20470    (set_attr "mode" "TI")])
20472 (define_insn "cvttps2dq"
20473   [(set (match_operand:V4SI 0 "register_operand" "=x")
20474         (unspec:V4SI [(match_operand:V4SF 1 "nonimmediate_operand" "xm")]
20475                      UNSPEC_FIX))]
20476   "TARGET_SSE2"
20477   "cvttps2dq\t{%1, %0|%0, %1}"
20478   [(set_attr "type" "ssecvt")
20479    (set_attr "mode" "TI")])
20481 ;; Conversions between SI and DF
20483 (define_insn "cvtdq2pd"
20484   [(set (match_operand:V2DF 0 "register_operand" "=x")
20485         (float:V2DF (vec_select:V2SI
20486                      (match_operand:V4SI 1 "nonimmediate_operand" "xm")
20487                      (parallel
20488                       [(const_int 0)
20489                        (const_int 1)]))))]
20490   "TARGET_SSE2"
20491   "cvtdq2pd\t{%1, %0|%0, %1}"
20492   [(set_attr "type" "ssecvt")
20493    (set_attr "mode" "V2DF")])
20495 (define_insn "cvtpd2dq"
20496   [(set (match_operand:V4SI 0 "register_operand" "=x")
20497         (vec_concat:V4SI
20498          (fix:V2SI (match_operand:V2DF 1 "nonimmediate_operand" "xm"))
20499          (const_vector:V2SI [(const_int 0) (const_int 0)])))]
20500   "TARGET_SSE2"
20501   "cvtpd2dq\t{%1, %0|%0, %1}"
20502   [(set_attr "type" "ssecvt")
20503    (set_attr "mode" "TI")])
20505 (define_insn "cvttpd2dq"
20506   [(set (match_operand:V4SI 0 "register_operand" "=x")
20507         (vec_concat:V4SI
20508          (unspec:V2SI [(match_operand:V2DF 1 "nonimmediate_operand" "xm")]
20509                       UNSPEC_FIX)
20510          (const_vector:V2SI [(const_int 0) (const_int 0)])))]
20511   "TARGET_SSE2"
20512   "cvttpd2dq\t{%1, %0|%0, %1}"
20513   [(set_attr "type" "ssecvt")
20514    (set_attr "mode" "TI")])
20516 (define_insn "cvtpd2pi"
20517   [(set (match_operand:V2SI 0 "register_operand" "=y")
20518         (fix:V2SI (match_operand:V2DF 1 "nonimmediate_operand" "xm")))]
20519   "TARGET_SSE2"
20520   "cvtpd2pi\t{%1, %0|%0, %1}"
20521   [(set_attr "type" "ssecvt")
20522    (set_attr "mode" "TI")])
20524 (define_insn "cvttpd2pi"
20525   [(set (match_operand:V2SI 0 "register_operand" "=y")
20526         (unspec:V2SI [(match_operand:V2DF 1 "nonimmediate_operand" "xm")]
20527                      UNSPEC_FIX))]
20528   "TARGET_SSE2"
20529   "cvttpd2pi\t{%1, %0|%0, %1}"
20530   [(set_attr "type" "ssecvt")
20531    (set_attr "mode" "TI")])
20533 (define_insn "cvtpi2pd"
20534   [(set (match_operand:V2DF 0 "register_operand" "=x")
20535         (float:V2DF (match_operand:V2SI 1 "nonimmediate_operand" "ym")))]
20536   "TARGET_SSE2"
20537   "cvtpi2pd\t{%1, %0|%0, %1}"
20538   [(set_attr "type" "ssecvt")
20539    (set_attr "mode" "TI")])
20541 ;; Conversions between SI and DF
20543 (define_insn "cvtsd2si"
20544   [(set (match_operand:SI 0 "register_operand" "=r")
20545         (fix:SI (vec_select:DF (match_operand:V2DF 1 "register_operand" "xm")
20546                                (parallel [(const_int 0)]))))]
20547   "TARGET_SSE2"
20548   "cvtsd2si\t{%1, %0|%0, %1}"
20549   [(set_attr "type" "ssecvt")
20550    (set_attr "mode" "SI")])
20552 (define_insn "cvttsd2si"
20553   [(set (match_operand:SI 0 "register_operand" "=r")
20554         (unspec:SI [(vec_select:DF (match_operand:V2DF 1 "register_operand" "xm")
20555                                    (parallel [(const_int 0)]))] UNSPEC_FIX))]
20556   "TARGET_SSE2"
20557   "cvttsd2si\t{%1, %0|%0, %1}"
20558   [(set_attr "type" "ssecvt")
20559    (set_attr "mode" "SI")])
20561 (define_insn "cvtsi2sd"
20562   [(set (match_operand:V2DF 0 "register_operand" "=x")
20563         (vec_merge:V2DF (match_operand:V2DF 1 "register_operand" "0")
20564                         (vec_duplicate:V2DF
20565                           (float:DF
20566                             (match_operand:SI 2 "nonimmediate_operand" "rm")))
20567                         (const_int 2)))]
20568   "TARGET_SSE2"
20569   "cvtsd2si\t{%2, %0|%0, %2}"
20570   [(set_attr "type" "ssecvt")
20571    (set_attr "mode" "DF")])
20573 ;; Conversions between SF and DF
20575 (define_insn "cvtsd2ss"
20576   [(set (match_operand:V4SF 0 "register_operand" "=x")
20577         (vec_merge:V4SF (match_operand:V4SF 1 "register_operand" "0")
20578                         (vec_duplicate:V4SF
20579                           (float_truncate:V2SF
20580                             (match_operand:V2DF 2 "register_operand" "xm")))
20581                         (const_int 14)))]
20582   "TARGET_SSE2"
20583   "cvtsd2ss\t{%2, %0|%0, %2}"
20584   [(set_attr "type" "ssecvt")
20585    (set_attr "mode" "SF")])
20587 (define_insn "cvtss2sd"
20588   [(set (match_operand:V2DF 0 "register_operand" "=x")
20589         (vec_merge:V2DF (match_operand:V2DF 1 "register_operand" "0")
20590                         (float_extend:V2DF
20591                           (vec_select:V2SF
20592                             (match_operand:V4SF 2 "register_operand" "xm")
20593                             (parallel [(const_int 0)
20594                                        (const_int 1)])))
20595                         (const_int 2)))]
20596   "TARGET_SSE2"
20597   "cvtss2sd\t{%2, %0|%0, %2}"
20598   [(set_attr "type" "ssecvt")
20599    (set_attr "mode" "DF")])
20601 (define_insn "cvtpd2ps"
20602   [(set (match_operand:V4SF 0 "register_operand" "=x")
20603         (subreg:V4SF
20604           (vec_concat:V4SI
20605             (subreg:V2SI (float_truncate:V2SF
20606                            (match_operand:V2DF 1 "nonimmediate_operand" "xm")) 0)
20607             (const_vector:V2SI [(const_int 0) (const_int 0)])) 0))]
20608   "TARGET_SSE2"
20609   "cvtpd2ps\t{%1, %0|%0, %1}"
20610   [(set_attr "type" "ssecvt")
20611    (set_attr "mode" "V4SF")])
20613 (define_insn "cvtps2pd"
20614   [(set (match_operand:V2DF 0 "register_operand" "=x")
20615         (float_extend:V2DF
20616           (vec_select:V2SF (match_operand:V4SF 1 "nonimmediate_operand" "xm")
20617                            (parallel [(const_int 0)
20618                                       (const_int 1)]))))]
20619   "TARGET_SSE2"
20620   "cvtps2pd\t{%1, %0|%0, %1}"
20621   [(set_attr "type" "ssecvt")
20622    (set_attr "mode" "V2DF")])
20624 ;; SSE2 variants of MMX insns
20626 ;; MMX arithmetic
20628 (define_insn "addv16qi3"
20629   [(set (match_operand:V16QI 0 "register_operand" "=x")
20630         (plus:V16QI (match_operand:V16QI 1 "register_operand" "0")
20631                     (match_operand:V16QI 2 "nonimmediate_operand" "xm")))]
20632   "TARGET_SSE2"
20633   "paddb\t{%2, %0|%0, %2}"
20634   [(set_attr "type" "sseiadd")
20635    (set_attr "mode" "TI")])
20637 (define_insn "addv8hi3"
20638   [(set (match_operand:V8HI 0 "register_operand" "=x")
20639         (plus:V8HI (match_operand:V8HI 1 "register_operand" "0")
20640                    (match_operand:V8HI 2 "nonimmediate_operand" "xm")))]
20641   "TARGET_SSE2"
20642   "paddw\t{%2, %0|%0, %2}"
20643   [(set_attr "type" "sseiadd")
20644    (set_attr "mode" "TI")])
20646 (define_insn "addv4si3"
20647   [(set (match_operand:V4SI 0 "register_operand" "=x")
20648         (plus:V4SI (match_operand:V4SI 1 "register_operand" "0")
20649                    (match_operand:V4SI 2 "nonimmediate_operand" "xm")))]
20650   "TARGET_SSE2"
20651   "paddd\t{%2, %0|%0, %2}"
20652   [(set_attr "type" "sseiadd")
20653    (set_attr "mode" "TI")])
20655 (define_insn "addv2di3"
20656   [(set (match_operand:V2DI 0 "register_operand" "=x")
20657         (plus:V2DI (match_operand:V2DI 1 "register_operand" "0")
20658                    (match_operand:V2DI 2 "nonimmediate_operand" "xm")))]
20659   "TARGET_SSE2"
20660   "paddq\t{%2, %0|%0, %2}"
20661   [(set_attr "type" "sseiadd")
20662    (set_attr "mode" "TI")])
20664 (define_insn "ssaddv16qi3"
20665   [(set (match_operand:V16QI 0 "register_operand" "=x")
20666         (ss_plus:V16QI (match_operand:V16QI 1 "register_operand" "0")
20667                        (match_operand:V16QI 2 "nonimmediate_operand" "xm")))]
20668   "TARGET_SSE2"
20669   "paddsb\t{%2, %0|%0, %2}"
20670   [(set_attr "type" "sseiadd")
20671    (set_attr "mode" "TI")])
20673 (define_insn "ssaddv8hi3"
20674   [(set (match_operand:V8HI 0 "register_operand" "=x")
20675         (ss_plus:V8HI (match_operand:V8HI 1 "register_operand" "0")
20676                       (match_operand:V8HI 2 "nonimmediate_operand" "xm")))]
20677   "TARGET_SSE2"
20678   "paddsw\t{%2, %0|%0, %2}"
20679   [(set_attr "type" "sseiadd")
20680    (set_attr "mode" "TI")])
20682 (define_insn "usaddv16qi3"
20683   [(set (match_operand:V16QI 0 "register_operand" "=x")
20684         (us_plus:V16QI (match_operand:V16QI 1 "register_operand" "0")
20685                        (match_operand:V16QI 2 "nonimmediate_operand" "xm")))]
20686   "TARGET_SSE2"
20687   "paddusb\t{%2, %0|%0, %2}"
20688   [(set_attr "type" "sseiadd")
20689    (set_attr "mode" "TI")])
20691 (define_insn "usaddv8hi3"
20692   [(set (match_operand:V8HI 0 "register_operand" "=x")
20693         (us_plus:V8HI (match_operand:V8HI 1 "register_operand" "0")
20694                       (match_operand:V8HI 2 "nonimmediate_operand" "xm")))]
20695   "TARGET_SSE2"
20696   "paddusw\t{%2, %0|%0, %2}"
20697   [(set_attr "type" "sseiadd")
20698    (set_attr "mode" "TI")])
20700 (define_insn "subv16qi3"
20701   [(set (match_operand:V16QI 0 "register_operand" "=x")
20702         (minus:V16QI (match_operand:V16QI 1 "register_operand" "0")
20703                      (match_operand:V16QI 2 "nonimmediate_operand" "xm")))]
20704   "TARGET_SSE2"
20705   "psubb\t{%2, %0|%0, %2}"
20706   [(set_attr "type" "sseiadd")
20707    (set_attr "mode" "TI")])
20709 (define_insn "subv8hi3"
20710   [(set (match_operand:V8HI 0 "register_operand" "=x")
20711         (minus:V8HI (match_operand:V8HI 1 "register_operand" "0")
20712                     (match_operand:V8HI 2 "nonimmediate_operand" "xm")))]
20713   "TARGET_SSE2"
20714   "psubw\t{%2, %0|%0, %2}"
20715   [(set_attr "type" "sseiadd")
20716    (set_attr "mode" "TI")])
20718 (define_insn "subv4si3"
20719   [(set (match_operand:V4SI 0 "register_operand" "=x")
20720         (minus:V4SI (match_operand:V4SI 1 "register_operand" "0")
20721                     (match_operand:V4SI 2 "nonimmediate_operand" "xm")))]
20722   "TARGET_SSE2"
20723   "psubd\t{%2, %0|%0, %2}"
20724   [(set_attr "type" "sseiadd")
20725    (set_attr "mode" "TI")])
20727 (define_insn "subv2di3"
20728   [(set (match_operand:V2DI 0 "register_operand" "=x")
20729         (minus:V2DI (match_operand:V2DI 1 "register_operand" "0")
20730                     (match_operand:V2DI 2 "nonimmediate_operand" "xm")))]
20731   "TARGET_SSE2"
20732   "psubq\t{%2, %0|%0, %2}"
20733   [(set_attr "type" "sseiadd")
20734    (set_attr "mode" "TI")])
20736 (define_insn "sssubv16qi3"
20737   [(set (match_operand:V16QI 0 "register_operand" "=x")
20738         (ss_minus:V16QI (match_operand:V16QI 1 "register_operand" "0")
20739                         (match_operand:V16QI 2 "nonimmediate_operand" "xm")))]
20740   "TARGET_SSE2"
20741   "psubsb\t{%2, %0|%0, %2}"
20742   [(set_attr "type" "sseiadd")
20743    (set_attr "mode" "TI")])
20745 (define_insn "sssubv8hi3"
20746   [(set (match_operand:V8HI 0 "register_operand" "=x")
20747         (ss_minus:V8HI (match_operand:V8HI 1 "register_operand" "0")
20748                        (match_operand:V8HI 2 "nonimmediate_operand" "xm")))]
20749   "TARGET_SSE2"
20750   "psubsw\t{%2, %0|%0, %2}"
20751   [(set_attr "type" "sseiadd")
20752    (set_attr "mode" "TI")])
20754 (define_insn "ussubv16qi3"
20755   [(set (match_operand:V16QI 0 "register_operand" "=x")
20756         (us_minus:V16QI (match_operand:V16QI 1 "register_operand" "0")
20757                         (match_operand:V16QI 2 "nonimmediate_operand" "xm")))]
20758   "TARGET_SSE2"
20759   "psubusb\t{%2, %0|%0, %2}"
20760   [(set_attr "type" "sseiadd")
20761    (set_attr "mode" "TI")])
20763 (define_insn "ussubv8hi3"
20764   [(set (match_operand:V8HI 0 "register_operand" "=x")
20765         (us_minus:V8HI (match_operand:V8HI 1 "register_operand" "0")
20766                        (match_operand:V8HI 2 "nonimmediate_operand" "xm")))]
20767   "TARGET_SSE2"
20768   "psubusw\t{%2, %0|%0, %2}"
20769   [(set_attr "type" "sseiadd")
20770    (set_attr "mode" "TI")])
20772 (define_insn "mulv8hi3"
20773   [(set (match_operand:V8HI 0 "register_operand" "=x")
20774         (mult:V8HI (match_operand:V8HI 1 "register_operand" "0")
20775                    (match_operand:V8HI 2 "nonimmediate_operand" "xm")))]
20776   "TARGET_SSE2"
20777   "pmullw\t{%2, %0|%0, %2}"
20778   [(set_attr "type" "sseimul")
20779    (set_attr "mode" "TI")])
20781 (define_insn "smulv8hi3_highpart"
20782   [(set (match_operand:V8HI 0 "register_operand" "=x")
20783         (truncate:V8HI
20784          (lshiftrt:V8SI
20785           (mult:V8SI (sign_extend:V8SI (match_operand:V8HI 1 "register_operand" "0"))
20786                      (sign_extend:V8SI (match_operand:V8HI 2 "nonimmediate_operand" "xm")))
20787           (const_int 16))))]
20788   "TARGET_SSE2"
20789   "pmulhw\t{%2, %0|%0, %2}"
20790   [(set_attr "type" "sseimul")
20791    (set_attr "mode" "TI")])
20793 (define_insn "umulv8hi3_highpart"
20794   [(set (match_operand:V8HI 0 "register_operand" "=x")
20795         (truncate:V8HI
20796          (lshiftrt:V8SI
20797           (mult:V8SI (zero_extend:V8SI (match_operand:V8HI 1 "register_operand" "0"))
20798                      (zero_extend:V8SI (match_operand:V8HI 2 "nonimmediate_operand" "xm")))
20799           (const_int 16))))]
20800   "TARGET_SSE2"
20801   "pmulhuw\t{%2, %0|%0, %2}"
20802   [(set_attr "type" "sseimul")
20803    (set_attr "mode" "TI")])
20805 (define_insn "sse2_umulsidi3"
20806   [(set (match_operand:DI 0 "register_operand" "=y")
20807         (mult:DI (zero_extend:DI (vec_select:SI
20808                                   (match_operand:V2SI 1 "register_operand" "0")
20809                                   (parallel [(const_int 0)])))
20810                  (zero_extend:DI (vec_select:SI
20811                                   (match_operand:V2SI 2 "nonimmediate_operand" "ym")
20812                                   (parallel [(const_int 0)])))))]
20813   "TARGET_SSE2"
20814   "pmuludq\t{%2, %0|%0, %2}"
20815   [(set_attr "type" "sseimul")
20816    (set_attr "mode" "TI")])
20818 (define_insn "sse2_umulv2siv2di3"
20819   [(set (match_operand:V2DI 0 "register_operand" "=y")
20820         (mult:V2DI (zero_extend:V2DI
20821                      (vec_select:V2SI
20822                        (match_operand:V4SI 1 "register_operand" "0")
20823                        (parallel [(const_int 0) (const_int 2)])))
20824                    (zero_extend:V2DI
20825                      (vec_select:V2SI
20826                        (match_operand:V4SI 2 "nonimmediate_operand" "ym")
20827                        (parallel [(const_int 0) (const_int 2)])))))]
20828   "TARGET_SSE2"
20829   "pmuludq\t{%2, %0|%0, %2}"
20830   [(set_attr "type" "sseimul")
20831    (set_attr "mode" "TI")])
20833 (define_insn "sse2_pmaddwd"
20834   [(set (match_operand:V4SI 0 "register_operand" "=x")
20835         (plus:V4SI
20836          (mult:V4SI
20837           (sign_extend:V4SI (vec_select:V4HI (match_operand:V8HI 1 "register_operand" "0")
20838                                              (parallel [(const_int 0)
20839                                                         (const_int 2)
20840                                                         (const_int 4)
20841                                                         (const_int 6)])))
20842           (sign_extend:V4SI (vec_select:V4HI (match_operand:V8HI 2 "nonimmediate_operand" "xm")
20843                                              (parallel [(const_int 0)
20844                                                         (const_int 2)
20845                                                         (const_int 4)
20846                                                         (const_int 6)]))))
20847          (mult:V4SI
20848           (sign_extend:V4SI (vec_select:V4HI (match_dup 1)
20849                                              (parallel [(const_int 1)
20850                                                         (const_int 3)
20851                                                         (const_int 5)
20852                                                         (const_int 7)])))
20853           (sign_extend:V4SI (vec_select:V4HI (match_dup 2)
20854                                              (parallel [(const_int 1)
20855                                                         (const_int 3)
20856                                                         (const_int 5)
20857                                                         (const_int 7)]))))))]
20858   "TARGET_SSE2"
20859   "pmaddwd\t{%2, %0|%0, %2}"
20860   [(set_attr "type" "sseiadd")
20861    (set_attr "mode" "TI")])
20863 ;; Same as pxor, but don't show input operands so that we don't think
20864 ;; they are live.
20865 (define_insn "sse2_clrti"
20866   [(set (match_operand:TI 0 "register_operand" "=x") (const_int 0))]
20867   "TARGET_SSE2"
20868   "pxor\t{%0, %0|%0, %0}"
20869   [(set_attr "type" "sseiadd")
20870    (set_attr "memory" "none")
20871    (set_attr "mode" "TI")])
20873 ;; MMX unsigned averages/sum of absolute differences
20875 (define_insn "sse2_uavgv16qi3"
20876   [(set (match_operand:V16QI 0 "register_operand" "=x")
20877         (ashiftrt:V16QI
20878          (plus:V16QI (plus:V16QI
20879                      (match_operand:V16QI 1 "register_operand" "0")
20880                      (match_operand:V16QI 2 "nonimmediate_operand" "ym"))
20881                      (const_vector:V16QI [(const_int 1) (const_int 1)
20882                                           (const_int 1) (const_int 1)
20883                                           (const_int 1) (const_int 1)
20884                                           (const_int 1) (const_int 1)
20885                                           (const_int 1) (const_int 1)
20886                                           (const_int 1) (const_int 1)
20887                                           (const_int 1) (const_int 1)
20888                                           (const_int 1) (const_int 1)]))
20889          (const_int 1)))]
20890   "TARGET_SSE2"
20891   "pavgb\t{%2, %0|%0, %2}"
20892   [(set_attr "type" "sseiadd")
20893    (set_attr "mode" "TI")])
20895 (define_insn "sse2_uavgv8hi3"
20896   [(set (match_operand:V8HI 0 "register_operand" "=x")
20897         (ashiftrt:V8HI
20898          (plus:V8HI (plus:V8HI
20899                      (match_operand:V8HI 1 "register_operand" "0")
20900                      (match_operand:V8HI 2 "nonimmediate_operand" "ym"))
20901                     (const_vector:V8HI [(const_int 1) (const_int 1)
20902                                         (const_int 1) (const_int 1)
20903                                         (const_int 1) (const_int 1)
20904                                         (const_int 1) (const_int 1)]))
20905          (const_int 1)))]
20906   "TARGET_SSE2"
20907   "pavgw\t{%2, %0|%0, %2}"
20908   [(set_attr "type" "sseiadd")
20909    (set_attr "mode" "TI")])
20911 ;; @@@ this isn't the right representation.
20912 (define_insn "sse2_psadbw"
20913   [(set (match_operand:V2DI 0 "register_operand" "=x")
20914         (unspec:V2DI [(match_operand:V16QI 1 "register_operand" "0")
20915                       (match_operand:V16QI 2 "nonimmediate_operand" "ym")]
20916                      UNSPEC_PSADBW))]
20917   "TARGET_SSE2"
20918   "psadbw\t{%2, %0|%0, %2}"
20919   [(set_attr "type" "sseiadd")
20920    (set_attr "mode" "TI")])
20923 ;; MMX insert/extract/shuffle
20925 (define_insn "sse2_pinsrw"
20926   [(set (match_operand:V8HI 0 "register_operand" "=x")
20927         (vec_merge:V8HI (match_operand:V8HI 1 "register_operand" "0")
20928                         (vec_duplicate:V8HI
20929                          (match_operand:SI 2 "nonimmediate_operand" "rm"))
20930                         (match_operand:SI 3 "immediate_operand" "i")))]
20931   "TARGET_SSE2"
20932   "pinsrw\t{%3, %2, %0|%0, %2, %3}"
20933   [(set_attr "type" "ssecvt")
20934    (set_attr "mode" "TI")])
20936 (define_insn "sse2_pextrw"
20937   [(set (match_operand:SI 0 "register_operand" "=r")
20938         (zero_extend:SI
20939           (vec_select:HI (match_operand:V8HI 1 "register_operand" "x")
20940                          (parallel
20941                           [(match_operand:SI 2 "immediate_operand" "i")]))))]
20942   "TARGET_SSE2"
20943   "pextrw\t{%2, %1, %0|%0, %1, %2}"
20944   [(set_attr "type" "ssecvt")
20945    (set_attr "mode" "TI")])
20947 (define_insn "sse2_pshufd"
20948   [(set (match_operand:V4SI 0 "register_operand" "=x")
20949         (unspec:V4SI [(match_operand:V4SI 1 "register_operand" "0")
20950                       (match_operand:SI 2 "immediate_operand" "i")]
20951                      UNSPEC_SHUFFLE))]
20952   "TARGET_SSE2"
20953   "pshufd\t{%2, %1, %0|%0, %1, %2}"
20954   [(set_attr "type" "ssecvt")
20955    (set_attr "mode" "TI")])
20957 (define_insn "sse2_pshuflw"
20958   [(set (match_operand:V8HI 0 "register_operand" "=x")
20959         (unspec:V8HI [(match_operand:V8HI 1 "register_operand" "0")
20960                       (match_operand:SI 2 "immediate_operand" "i")]
20961                      UNSPEC_PSHUFLW))]
20962   "TARGET_SSE2"
20963   "pshuflw\t{%2, %1, %0|%0, %1, %2}"
20964   [(set_attr "type" "ssecvt")
20965    (set_attr "mode" "TI")])
20967 (define_insn "sse2_pshufhw"
20968   [(set (match_operand:V8HI 0 "register_operand" "=x")
20969         (unspec:V8HI [(match_operand:V8HI 1 "register_operand" "0")
20970                       (match_operand:SI 2 "immediate_operand" "i")]
20971                      UNSPEC_PSHUFHW))]
20972   "TARGET_SSE2"
20973   "pshufhw\t{%2, %1, %0|%0, %1, %2}"
20974   [(set_attr "type" "ssecvt")
20975    (set_attr "mode" "TI")])
20977 ;; MMX mask-generating comparisons
20979 (define_insn "eqv16qi3"
20980   [(set (match_operand:V16QI 0 "register_operand" "=x")
20981         (eq:V16QI (match_operand:V16QI 1 "register_operand" "0")
20982                  (match_operand:V16QI 2 "nonimmediate_operand" "xm")))]
20983   "TARGET_SSE2"
20984   "pcmpeqb\t{%2, %0|%0, %2}"
20985   [(set_attr "type" "ssecmp")
20986    (set_attr "mode" "TI")])
20988 (define_insn "eqv8hi3"
20989   [(set (match_operand:V8HI 0 "register_operand" "=x")
20990         (eq:V8HI (match_operand:V8HI 1 "register_operand" "0")
20991                  (match_operand:V8HI 2 "nonimmediate_operand" "xm")))]
20992   "TARGET_SSE2"
20993   "pcmpeqw\t{%2, %0|%0, %2}"
20994   [(set_attr "type" "ssecmp")
20995    (set_attr "mode" "TI")])
20997 (define_insn "eqv4si3"
20998   [(set (match_operand:V4SI 0 "register_operand" "=x")
20999         (eq:V4SI (match_operand:V4SI 1 "register_operand" "0")
21000                  (match_operand:V4SI 2 "nonimmediate_operand" "xm")))]
21001   "TARGET_SSE2"
21002   "pcmpeqd\t{%2, %0|%0, %2}"
21003   [(set_attr "type" "ssecmp")
21004    (set_attr "mode" "TI")])
21006 (define_insn "gtv16qi3"
21007   [(set (match_operand:V16QI 0 "register_operand" "=x")
21008         (gt:V16QI (match_operand:V16QI 1 "register_operand" "0")
21009                  (match_operand:V16QI 2 "nonimmediate_operand" "xm")))]
21010   "TARGET_SSE2"
21011   "pcmpgtb\t{%2, %0|%0, %2}"
21012   [(set_attr "type" "ssecmp")
21013    (set_attr "mode" "TI")])
21015 (define_insn "gtv8hi3"
21016   [(set (match_operand:V8HI 0 "register_operand" "=x")
21017         (gt:V8HI (match_operand:V8HI 1 "register_operand" "0")
21018                  (match_operand:V8HI 2 "nonimmediate_operand" "xm")))]
21019   "TARGET_SSE2"
21020   "pcmpgtw\t{%2, %0|%0, %2}"
21021   [(set_attr "type" "ssecmp")
21022    (set_attr "mode" "TI")])
21024 (define_insn "gtv4si3"
21025   [(set (match_operand:V4SI 0 "register_operand" "=x")
21026         (gt:V4SI (match_operand:V4SI 1 "register_operand" "0")
21027                  (match_operand:V4SI 2 "nonimmediate_operand" "xm")))]
21028   "TARGET_SSE2"
21029   "pcmpgtd\t{%2, %0|%0, %2}"
21030   [(set_attr "type" "ssecmp")
21031    (set_attr "mode" "TI")])
21034 ;; MMX max/min insns
21036 (define_insn "umaxv16qi3"
21037   [(set (match_operand:V16QI 0 "register_operand" "=x")
21038         (umax:V16QI (match_operand:V16QI 1 "register_operand" "0")
21039                    (match_operand:V16QI 2 "nonimmediate_operand" "xm")))]
21040   "TARGET_SSE2"
21041   "pmaxub\t{%2, %0|%0, %2}"
21042   [(set_attr "type" "sseiadd")
21043    (set_attr "mode" "TI")])
21045 (define_insn "smaxv8hi3"
21046   [(set (match_operand:V8HI 0 "register_operand" "=x")
21047         (smax:V8HI (match_operand:V8HI 1 "register_operand" "0")
21048                    (match_operand:V8HI 2 "nonimmediate_operand" "xm")))]
21049   "TARGET_SSE2"
21050   "pmaxsw\t{%2, %0|%0, %2}"
21051   [(set_attr "type" "sseiadd")
21052    (set_attr "mode" "TI")])
21054 (define_insn "uminv16qi3"
21055   [(set (match_operand:V16QI 0 "register_operand" "=x")
21056         (umin:V16QI (match_operand:V16QI 1 "register_operand" "0")
21057                    (match_operand:V16QI 2 "nonimmediate_operand" "xm")))]
21058   "TARGET_SSE2"
21059   "pminub\t{%2, %0|%0, %2}"
21060   [(set_attr "type" "sseiadd")
21061    (set_attr "mode" "TI")])
21063 (define_insn "sminv8hi3"
21064   [(set (match_operand:V8HI 0 "register_operand" "=x")
21065         (smin:V8HI (match_operand:V8HI 1 "register_operand" "0")
21066                    (match_operand:V8HI 2 "nonimmediate_operand" "xm")))]
21067   "TARGET_SSE2"
21068   "pminsw\t{%2, %0|%0, %2}"
21069   [(set_attr "type" "sseiadd")
21070    (set_attr "mode" "TI")])
21073 ;; MMX shifts
21075 (define_insn "ashrv8hi3"
21076   [(set (match_operand:V8HI 0 "register_operand" "=x")
21077         (ashiftrt:V8HI (match_operand:V8HI 1 "register_operand" "0")
21078                        (match_operand:SI 2 "nonmemory_operand" "ri")))]
21079   "TARGET_SSE2"
21080   "psraw\t{%2, %0|%0, %2}"
21081   [(set_attr "type" "sseishft")
21082    (set_attr "mode" "TI")])
21084 (define_insn "ashrv4si3"
21085   [(set (match_operand:V4SI 0 "register_operand" "=x")
21086         (ashiftrt:V4SI (match_operand:V4SI 1 "register_operand" "0")
21087                        (match_operand:SI 2 "nonmemory_operand" "ri")))]
21088   "TARGET_SSE2"
21089   "psrad\t{%2, %0|%0, %2}"
21090   [(set_attr "type" "sseishft")
21091    (set_attr "mode" "TI")])
21093 (define_insn "lshrv8hi3"
21094   [(set (match_operand:V8HI 0 "register_operand" "=x")
21095         (lshiftrt:V8HI (match_operand:V8HI 1 "register_operand" "0")
21096                        (match_operand:SI 2 "nonmemory_operand" "ri")))]
21097   "TARGET_SSE2"
21098   "psrlw\t{%2, %0|%0, %2}"
21099   [(set_attr "type" "sseishft")
21100    (set_attr "mode" "TI")])
21102 (define_insn "lshrv4si3"
21103   [(set (match_operand:V4SI 0 "register_operand" "=x")
21104         (lshiftrt:V4SI (match_operand:V4SI 1 "register_operand" "0")
21105                        (match_operand:SI 2 "nonmemory_operand" "ri")))]
21106   "TARGET_SSE2"
21107   "psrld\t{%2, %0|%0, %2}"
21108   [(set_attr "type" "sseishft")
21109    (set_attr "mode" "TI")])
21111 (define_insn "lshrv2di3"
21112   [(set (match_operand:V2DI 0 "register_operand" "=x")
21113         (lshiftrt:V2DI (match_operand:V2DI 1 "register_operand" "0")
21114                        (match_operand:SI 2 "nonmemory_operand" "ri")))]
21115   "TARGET_SSE2"
21116   "psrlq\t{%2, %0|%0, %2}"
21117   [(set_attr "type" "sseishft")
21118    (set_attr "mode" "TI")])
21120 (define_insn "ashlv8hi3"
21121   [(set (match_operand:V8HI 0 "register_operand" "=x")
21122         (ashift:V8HI (match_operand:V8HI 1 "register_operand" "0")
21123                      (match_operand:SI 2 "nonmemory_operand" "ri")))]
21124   "TARGET_SSE2"
21125   "psllw\t{%2, %0|%0, %2}"
21126   [(set_attr "type" "sseishft")
21127    (set_attr "mode" "TI")])
21129 (define_insn "ashlv4si3"
21130   [(set (match_operand:V4SI 0 "register_operand" "=x")
21131         (ashift:V4SI (match_operand:V4SI 1 "register_operand" "0")
21132                      (match_operand:SI 2 "nonmemory_operand" "ri")))]
21133   "TARGET_SSE2"
21134   "pslld\t{%2, %0|%0, %2}"
21135   [(set_attr "type" "sseishft")
21136    (set_attr "mode" "TI")])
21138 (define_insn "ashlv2di3"
21139   [(set (match_operand:V2DI 0 "register_operand" "=x")
21140         (ashift:V2DI (match_operand:V2DI 1 "register_operand" "0")
21141                      (match_operand:SI 2 "nonmemory_operand" "ri")))]
21142   "TARGET_SSE2"
21143   "psllq\t{%2, %0|%0, %2}"
21144   [(set_attr "type" "sseishft")
21145    (set_attr "mode" "TI")])
21147 (define_insn "ashrv8hi3_ti"
21148   [(set (match_operand:V8HI 0 "register_operand" "=x")
21149         (ashiftrt:V8HI (match_operand:V8HI 1 "register_operand" "0")
21150                        (subreg:TI (match_operand:V2DI 2 "nonmemory_operand" "xi") 0)))]
21151   "TARGET_SSE2"
21152   "psraw\t{%2, %0|%0, %2}"
21153   [(set_attr "type" "sseishft")
21154    (set_attr "mode" "TI")])
21156 (define_insn "ashrv4si3_ti"
21157   [(set (match_operand:V4SI 0 "register_operand" "=x")
21158         (ashiftrt:V4SI (match_operand:V4SI 1 "register_operand" "0")
21159                        (subreg:TI (match_operand:V2DI 2 "nonmemory_operand" "xi") 0)))]
21160   "TARGET_SSE2"
21161   "psrad\t{%2, %0|%0, %2}"
21162   [(set_attr "type" "sseishft")
21163    (set_attr "mode" "TI")])
21165 (define_insn "lshrv8hi3_ti"
21166   [(set (match_operand:V8HI 0 "register_operand" "=x")
21167         (lshiftrt:V8HI (match_operand:V8HI 1 "register_operand" "0")
21168                        (subreg:TI (match_operand:V2DI 2 "nonmemory_operand" "xi") 0)))]
21169   "TARGET_SSE2"
21170   "psrlw\t{%2, %0|%0, %2}"
21171   [(set_attr "type" "sseishft")
21172    (set_attr "mode" "TI")])
21174 (define_insn "lshrv4si3_ti"
21175   [(set (match_operand:V4SI 0 "register_operand" "=x")
21176         (lshiftrt:V4SI (match_operand:V4SI 1 "register_operand" "0")
21177                        (subreg:TI (match_operand:V2DI 2 "nonmemory_operand" "xi") 0)))]
21178   "TARGET_SSE2"
21179   "psrld\t{%2, %0|%0, %2}"
21180   [(set_attr "type" "sseishft")
21181    (set_attr "mode" "TI")])
21183 (define_insn "lshrv2di3_ti"
21184   [(set (match_operand:V2DI 0 "register_operand" "=x")
21185         (lshiftrt:V2DI (match_operand:V2DI 1 "register_operand" "0")
21186                        (subreg:TI (match_operand:V2DI 2 "nonmemory_operand" "xi") 0)))]
21187   "TARGET_SSE2"
21188   "psrlq\t{%2, %0|%0, %2}"
21189   [(set_attr "type" "sseishft")
21190    (set_attr "mode" "TI")])
21192 (define_insn "ashlv8hi3_ti"
21193   [(set (match_operand:V8HI 0 "register_operand" "=x")
21194         (ashift:V8HI (match_operand:V8HI 1 "register_operand" "0")
21195                      (subreg:TI (match_operand:V2DI 2 "nonmemory_operand" "xi") 0)))]
21196   "TARGET_SSE2"
21197   "psllw\t{%2, %0|%0, %2}"
21198   [(set_attr "type" "sseishft")
21199    (set_attr "mode" "TI")])
21201 (define_insn "ashlv4si3_ti"
21202   [(set (match_operand:V4SI 0 "register_operand" "=x")
21203         (ashift:V4SI (match_operand:V4SI 1 "register_operand" "0")
21204                      (subreg:TI (match_operand:V2DI 2 "nonmemory_operand" "xi") 0)))]
21205   "TARGET_SSE2"
21206   "pslld\t{%2, %0|%0, %2}"
21207   [(set_attr "type" "sseishft")
21208    (set_attr "mode" "TI")])
21210 (define_insn "ashlv2di3_ti"
21211   [(set (match_operand:V2DI 0 "register_operand" "=x")
21212         (ashift:V2DI (match_operand:V2DI 1 "register_operand" "0")
21213                      (subreg:TI (match_operand:V2DI 2 "nonmemory_operand" "xi") 0)))]
21214   "TARGET_SSE2"
21215   "psllq\t{%2, %0|%0, %2}"
21216   [(set_attr "type" "sseishft")
21217    (set_attr "mode" "TI")])
21219 ;; See logical MMX insns for the reason for the unspec.  Strictly speaking
21220 ;; we wouldn't need here it since we never generate TImode arithmetic.
21222 ;; There has to be some kind of prize for the weirdest new instruction...
21223 (define_insn "sse2_ashlti3"
21224   [(set (match_operand:TI 0 "register_operand" "=x")
21225         (unspec:TI
21226          [(ashift:TI (match_operand:TI 1 "register_operand" "0")
21227                      (mult:SI (match_operand:SI 2 "immediate_operand" "i")
21228                                (const_int 8)))] UNSPEC_NOP))]
21229   "TARGET_SSE2"
21230   "pslldq\t{%2, %0|%0, %2}"
21231   [(set_attr "type" "sseishft")
21232    (set_attr "mode" "TI")])
21234 (define_insn "sse2_lshrti3"
21235   [(set (match_operand:TI 0 "register_operand" "=x")
21236         (unspec:TI
21237          [(lshiftrt:TI (match_operand:TI 1 "register_operand" "0")
21238                        (mult:SI (match_operand:SI 2 "immediate_operand" "i")
21239                                 (const_int 8)))] UNSPEC_NOP))]
21240   "TARGET_SSE2"
21241   "pslrdq\t{%2, %0|%0, %2}"
21242   [(set_attr "type" "sseishft")
21243    (set_attr "mode" "TI")])
21245 ;; SSE unpack
21247 (define_insn "sse2_unpckhpd"
21248   [(set (match_operand:V2DF 0 "register_operand" "=x")
21249         (vec_concat:V2DF
21250          (vec_select:V2DF (match_operand:V2DF 1 "register_operand" "0")
21251                           (parallel [(const_int 1)]))
21252          (vec_select:V2DF (match_operand:V2DF 2 "register_operand" "x")
21253                           (parallel [(const_int 0)]))))]
21254   "TARGET_SSE2"
21255   "unpckhpd\t{%2, %0|%0, %2}"
21256   [(set_attr "type" "ssecvt")
21257    (set_attr "mode" "TI")])
21259 (define_insn "sse2_unpcklpd"
21260   [(set (match_operand:V2DF 0 "register_operand" "=x")
21261         (vec_concat:V2DF
21262          (vec_select:V2DF (match_operand:V2DF 1 "register_operand" "0")
21263                           (parallel [(const_int 0)]))
21264          (vec_select:V2DF (match_operand:V2DF 2 "register_operand" "x")
21265                           (parallel [(const_int 1)]))))]
21266   "TARGET_SSE2"
21267   "unpcklpd\t{%2, %0|%0, %2}"
21268   [(set_attr "type" "ssecvt")
21269    (set_attr "mode" "TI")])
21271 ;; MMX pack/unpack insns.
21273 (define_insn "sse2_packsswb"
21274   [(set (match_operand:V16QI 0 "register_operand" "=x")
21275         (vec_concat:V16QI
21276          (ss_truncate:V8QI (match_operand:V8HI 1 "register_operand" "0"))
21277          (ss_truncate:V8QI (match_operand:V8HI 2 "register_operand" "x"))))]
21278   "TARGET_SSE2"
21279   "packsswb\t{%2, %0|%0, %2}"
21280   [(set_attr "type" "ssecvt")
21281    (set_attr "mode" "TI")])
21283 (define_insn "sse2_packssdw"
21284   [(set (match_operand:V8HI 0 "register_operand" "=x")
21285         (vec_concat:V8HI
21286          (ss_truncate:V4HI (match_operand:V4SI 1 "register_operand" "0"))
21287          (ss_truncate:V4HI (match_operand:V4SI 2 "register_operand" "x"))))]
21288   "TARGET_SSE2"
21289   "packssdw\t{%2, %0|%0, %2}"
21290   [(set_attr "type" "ssecvt")
21291    (set_attr "mode" "TI")])
21293 (define_insn "sse2_packuswb"
21294   [(set (match_operand:V16QI 0 "register_operand" "=x")
21295         (vec_concat:V16QI
21296          (us_truncate:V8QI (match_operand:V8HI 1 "register_operand" "0"))
21297          (us_truncate:V8QI (match_operand:V8HI 2 "register_operand" "x"))))]
21298   "TARGET_SSE2"
21299   "packuswb\t{%2, %0|%0, %2}"
21300   [(set_attr "type" "ssecvt")
21301    (set_attr "mode" "TI")])
21303 (define_insn "sse2_punpckhbw"
21304   [(set (match_operand:V16QI 0 "register_operand" "=x")
21305         (vec_merge:V16QI
21306          (vec_select:V16QI (match_operand:V16QI 1 "register_operand" "0")
21307                            (parallel [(const_int 8) (const_int 0)
21308                                       (const_int 9) (const_int 1)
21309                                       (const_int 10) (const_int 2)
21310                                       (const_int 11) (const_int 3)
21311                                       (const_int 12) (const_int 4)
21312                                       (const_int 13) (const_int 5)
21313                                       (const_int 14) (const_int 6)
21314                                       (const_int 15) (const_int 7)]))
21315          (vec_select:V16QI (match_operand:V16QI 2 "register_operand" "x")
21316                            (parallel [(const_int 0) (const_int 8)
21317                                       (const_int 1) (const_int 9)
21318                                       (const_int 2) (const_int 10)
21319                                       (const_int 3) (const_int 11)
21320                                       (const_int 4) (const_int 12)
21321                                       (const_int 5) (const_int 13)
21322                                       (const_int 6) (const_int 14)
21323                                       (const_int 7) (const_int 15)]))
21324          (const_int 21845)))]
21325   "TARGET_SSE2"
21326   "punpckhbw\t{%2, %0|%0, %2}"
21327   [(set_attr "type" "ssecvt")
21328    (set_attr "mode" "TI")])
21330 (define_insn "sse2_punpckhwd"
21331   [(set (match_operand:V8HI 0 "register_operand" "=x")
21332         (vec_merge:V8HI
21333          (vec_select:V8HI (match_operand:V8HI 1 "register_operand" "0")
21334                           (parallel [(const_int 4) (const_int 0)
21335                                      (const_int 5) (const_int 1)
21336                                      (const_int 6) (const_int 2)
21337                                      (const_int 7) (const_int 3)]))
21338          (vec_select:V8HI (match_operand:V8HI 2 "register_operand" "x")
21339                           (parallel [(const_int 0) (const_int 4)
21340                                      (const_int 1) (const_int 5)
21341                                      (const_int 2) (const_int 6)
21342                                      (const_int 3) (const_int 7)]))
21343          (const_int 85)))]
21344   "TARGET_SSE2"
21345   "punpckhwd\t{%2, %0|%0, %2}"
21346   [(set_attr "type" "ssecvt")
21347    (set_attr "mode" "TI")])
21349 (define_insn "sse2_punpckhdq"
21350   [(set (match_operand:V4SI 0 "register_operand" "=x")
21351         (vec_merge:V4SI
21352          (vec_select:V4SI (match_operand:V4SI 1 "register_operand" "0")
21353                           (parallel [(const_int 2) (const_int 0)
21354                                      (const_int 3) (const_int 1)]))
21355          (vec_select:V4SI (match_operand:V4SI 2 "register_operand" "x")
21356                           (parallel [(const_int 0) (const_int 2)
21357                                      (const_int 1) (const_int 3)]))
21358          (const_int 5)))]
21359   "TARGET_SSE2"
21360   "punpckhdq\t{%2, %0|%0, %2}"
21361   [(set_attr "type" "ssecvt")
21362    (set_attr "mode" "TI")])
21364 (define_insn "sse2_punpcklbw"
21365   [(set (match_operand:V16QI 0 "register_operand" "=x")
21366         (vec_merge:V16QI
21367          (vec_select:V16QI (match_operand:V16QI 1 "register_operand" "0")
21368                            (parallel [(const_int 0) (const_int 8)
21369                                       (const_int 1) (const_int 9)
21370                                       (const_int 2) (const_int 10)
21371                                       (const_int 3) (const_int 11)
21372                                       (const_int 4) (const_int 12)
21373                                       (const_int 5) (const_int 13)
21374                                       (const_int 6) (const_int 14)
21375                                       (const_int 7) (const_int 15)]))
21376          (vec_select:V16QI (match_operand:V16QI 2 "register_operand" "x")
21377                            (parallel [(const_int 8) (const_int 0)
21378                                       (const_int 9) (const_int 1)
21379                                       (const_int 10) (const_int 2)
21380                                       (const_int 11) (const_int 3)
21381                                       (const_int 12) (const_int 4)
21382                                       (const_int 13) (const_int 5)
21383                                       (const_int 14) (const_int 6)
21384                                       (const_int 15) (const_int 7)]))
21385          (const_int 21845)))]
21386   "TARGET_SSE2"
21387   "punpcklbw\t{%2, %0|%0, %2}"
21388   [(set_attr "type" "ssecvt")
21389    (set_attr "mode" "TI")])
21391 (define_insn "sse2_punpcklwd"
21392   [(set (match_operand:V8HI 0 "register_operand" "=x")
21393         (vec_merge:V8HI
21394          (vec_select:V8HI (match_operand:V8HI 1 "register_operand" "0")
21395                           (parallel [(const_int 0) (const_int 4)
21396                                      (const_int 1) (const_int 5)
21397                                      (const_int 2) (const_int 6)
21398                                      (const_int 3) (const_int 7)]))
21399          (vec_select:V8HI (match_operand:V8HI 2 "register_operand" "x")
21400                           (parallel [(const_int 4) (const_int 0)
21401                                      (const_int 5) (const_int 1)
21402                                      (const_int 6) (const_int 2)
21403                                      (const_int 7) (const_int 3)]))
21404          (const_int 85)))]
21405   "TARGET_SSE2"
21406   "punpcklwd\t{%2, %0|%0, %2}"
21407   [(set_attr "type" "ssecvt")
21408    (set_attr "mode" "TI")])
21410 (define_insn "sse2_punpckldq"
21411   [(set (match_operand:V4SI 0 "register_operand" "=x")
21412         (vec_merge:V4SI
21413          (vec_select:V4SI (match_operand:V4SI 1 "register_operand" "0")
21414                           (parallel [(const_int 0) (const_int 2)
21415                                      (const_int 1) (const_int 3)]))
21416          (vec_select:V4SI (match_operand:V4SI 2 "register_operand" "x")
21417                           (parallel [(const_int 2) (const_int 0)
21418                                      (const_int 3) (const_int 1)]))
21419          (const_int 5)))]
21420   "TARGET_SSE2"
21421   "punpckldq\t{%2, %0|%0, %2}"
21422   [(set_attr "type" "ssecvt")
21423    (set_attr "mode" "TI")])
21425 ;; SSE2 moves
21427 (define_insn "sse2_movapd"
21428   [(set (match_operand:V2DF 0 "nonimmediate_operand" "=x,m")
21429         (unspec:V2DF [(match_operand:V2DF 1 "general_operand" "xm,x")]
21430                      UNSPEC_MOVA))]
21431   "TARGET_SSE2"
21432   "@
21433    movapd\t{%1, %0|%0, %1}
21434    movapd\t{%1, %0|%0, %1}"
21435   [(set_attr "type" "ssemov")
21436    (set_attr "mode" "V2DF")])
21438 (define_insn "sse2_movupd"
21439   [(set (match_operand:V2DF 0 "nonimmediate_operand" "=x,m")
21440         (unspec:V2DF [(match_operand:V2DF 1 "general_operand" "xm,x")]
21441                      UNSPEC_MOVU))]
21442   "TARGET_SSE2"
21443   "@
21444    movupd\t{%1, %0|%0, %1}
21445    movupd\t{%1, %0|%0, %1}"
21446   [(set_attr "type" "ssecvt")
21447    (set_attr "mode" "V2DF")])
21449 (define_insn "sse2_movdqa"
21450   [(set (match_operand:TI 0 "nonimmediate_operand" "=x,m")
21451         (unspec:TI [(match_operand:TI 1 "general_operand" "xm,x")]
21452                    UNSPEC_MOVA))]
21453   "TARGET_SSE2"
21454   "@
21455    movdqa\t{%1, %0|%0, %1}
21456    movdqa\t{%1, %0|%0, %1}"
21457   [(set_attr "type" "ssemov")
21458    (set_attr "mode" "TI")])
21460 (define_insn "sse2_movdqu"
21461   [(set (match_operand:TI 0 "nonimmediate_operand" "=x,m")
21462         (unspec:TI [(match_operand:TI 1 "general_operand" "xm,x")]
21463                    UNSPEC_MOVU))]
21464   "TARGET_SSE2"
21465   "@
21466    movdqu\t{%1, %0|%0, %1}
21467    movdqu\t{%1, %0|%0, %1}"
21468   [(set_attr "type" "ssecvt")
21469    (set_attr "mode" "TI")])
21471 (define_insn "sse2_movdq2q"
21472   [(set (match_operand:DI 0 "nonimmediate_operand" "=y")
21473         (vec_select:DI (match_operand:V2DI 1 "general_operand" "x")
21474                        (parallel [(const_int 0)])))]
21475   "TARGET_SSE2"
21476   "movdq2q\t{%1, %0|%0, %1}"
21477   [(set_attr "type" "ssecvt")
21478    (set_attr "mode" "TI")])
21480 (define_insn "sse2_movq2dq"
21481   [(set (match_operand:V2DI 0 "nonimmediate_operand" "=x")
21482         (vec_concat:V2DI (match_operand:DI 1 "general_operand" "y")
21483                          (const_vector:DI [(const_int 0)])))]
21484   "TARGET_SSE2"
21485   "movq2dq\t{%1, %0|%0, %1}"
21486   [(set_attr "type" "ssecvt")
21487    (set_attr "mode" "TI")])
21489 (define_insn "sse2_movhpd"
21490   [(set (match_operand:V2DF 0 "nonimmediate_operand" "=x,m")
21491         (vec_merge:V2DF
21492          (match_operand:V2DF 1 "nonimmediate_operand" "0,0")
21493          (match_operand:V2DF 2 "nonimmediate_operand" "m,x")
21494          (const_int 2)))]
21495   "TARGET_SSE2 && (GET_CODE (operands[1]) == MEM || GET_CODE (operands[2]) == MEM)"
21496   "movhpd\t{%2, %0|%0, %2}"
21497   [(set_attr "type" "ssecvt")
21498    (set_attr "mode" "V2DF")])
21500 (define_insn "sse2_movlpd"
21501   [(set (match_operand:V2DF 0 "nonimmediate_operand" "=x,m")
21502         (vec_merge:V2DF
21503          (match_operand:V2DF 1 "nonimmediate_operand" "0,0")
21504          (match_operand:V2DF 2 "nonimmediate_operand" "m,x")
21505          (const_int 1)))]
21506   "TARGET_SSE2 && (GET_CODE (operands[1]) == MEM || GET_CODE (operands[2]) == MEM)"
21507   "movlpd\t{%2, %0|%0, %2}"
21508   [(set_attr "type" "ssecvt")
21509    (set_attr "mode" "V2DF")])
21511 (define_insn "sse2_loadsd"
21512   [(set (match_operand:V2DF 0 "register_operand" "=x")
21513         (vec_merge:V2DF
21514          (match_operand:DF 1 "memory_operand" "m")
21515          (vec_duplicate:DF (float:DF (const_int 0)))
21516          (const_int 1)))]
21517   "TARGET_SSE2"
21518   "movsd\t{%1, %0|%0, %1}"
21519   [(set_attr "type" "ssecvt")
21520    (set_attr "mode" "DF")])
21522 (define_insn "sse2_movsd"
21523   [(set (match_operand:V2DF 0 "register_operand" "=x")
21524         (vec_merge:V2DF
21525          (match_operand:V2DF 1 "register_operand" "0")
21526          (match_operand:V2DF 2 "register_operand" "x")
21527          (const_int 1)))]
21528   "TARGET_SSE2"
21529   "movsd\t{%2, %0|%0, %2}"
21530   [(set_attr "type" "ssecvt")
21531    (set_attr "mode" "DF")])
21533 (define_insn "sse2_storesd"
21534   [(set (match_operand:DF 0 "memory_operand" "=m")
21535         (vec_select:DF
21536          (match_operand:V2DF 1 "register_operand" "x")
21537          (parallel [(const_int 0)])))]
21538   "TARGET_SSE2"
21539   "movsd\t{%1, %0|%0, %1}"
21540   [(set_attr "type" "ssecvt")
21541    (set_attr "mode" "DF")])
21543 (define_insn "sse2_shufpd"
21544   [(set (match_operand:V2DF 0 "register_operand" "=x")
21545         (unspec:V2DF [(match_operand:V2DF 1 "register_operand" "0")
21546                       (match_operand:V2DF 2 "nonimmediate_operand" "xm")
21547                       (match_operand:SI 3 "immediate_operand" "i")]
21548                      UNSPEC_SHUFFLE))]
21549   "TARGET_SSE2"
21550   ;; @@@ check operand order for intel/nonintel syntax
21551   "shufpd\t{%3, %2, %0|%0, %2, %3}"
21552   [(set_attr "type" "ssecvt")
21553    (set_attr "mode" "V2DF")])
21555 (define_insn "sse2_clflush"
21556   [(unspec_volatile [(match_operand:SI 0 "address_operand" "p")]
21557                     UNSPECV_CLFLUSH)]
21558   "TARGET_SSE2"
21559   "clflush %0"
21560   [(set_attr "type" "sse")
21561    (set_attr "memory" "unknown")])
21563 (define_expand "sse2_mfence"
21564   [(set (match_dup 0)
21565         (unspec:BLK [(match_dup 0)] UNSPEC_MFENCE))]
21566   "TARGET_SSE2"
21568   operands[0] = gen_rtx_MEM (BLKmode, gen_rtx_SCRATCH (Pmode));
21569   MEM_VOLATILE_P (operands[0]) = 1;
21572 (define_insn "*mfence_insn"
21573   [(set (match_operand:BLK 0 "" "")
21574         (unspec:BLK [(match_dup 0)] UNSPEC_MFENCE))]
21575   "TARGET_SSE2"
21576   "mfence"
21577   [(set_attr "type" "sse")
21578    (set_attr "memory" "unknown")])
21580 (define_expand "sse2_lfence"
21581   [(set (match_dup 0)
21582         (unspec:BLK [(match_dup 0)] UNSPEC_LFENCE))]
21583   "TARGET_SSE2"
21585   operands[0] = gen_rtx_MEM (BLKmode, gen_rtx_SCRATCH (Pmode));
21586   MEM_VOLATILE_P (operands[0]) = 1;
21589 (define_insn "*lfence_insn"
21590   [(set (match_operand:BLK 0 "" "")
21591         (unspec:BLK [(match_dup 0)] UNSPEC_LFENCE))]
21592   "TARGET_SSE2"
21593   "lfence"
21594   [(set_attr "type" "sse")
21595    (set_attr "memory" "unknown")])