OSDN Git Service

d7ab20f26b7d58c9ad482ef2cbd7a3f7328c1e43
[pf3gnuchains/gcc-fork.git] / gcc / config / i386 / i386.md
1 ;; GCC machine description for IA-32 and x86-64.
2 ;; Copyright (C) 1988, 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001
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.
13 ;;
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.
18 ;;
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.  */
23 ;;
24 ;; The original PO technology requires these to be ordered by speed,
25 ;; so that assigner will pick the fastest.
26 ;;
27 ;; See file "rtl.def" for documentation on define_insn, match_*, et. al.
28 ;;
29 ;; Macro #define NOTICE_UPDATE_CC in file i386.h handles condition code
30 ;; updates for most instructions.
31 ;;
32 ;; Macro REG_CLASS_FROM_LETTER in file i386.h defines the register
33 ;; constraint letters.
34 ;;
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.
45 ;;
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.
52 ;;
53 ;; UNSPEC usage:
54 ;; 0  This is a `scas' operation.  The mode of the UNSPEC is always SImode.
55 ;;    operand 0 is the memory address to scan.
56 ;;    operand 1 is a register containing the value to scan for.  The mode
57 ;;       of the scas opcode will be the same as the mode of this operand.
58 ;;    operand 2 is the known alignment of operand 0.
59 ;; 1  This is a `sin' operation.  The mode of the UNSPEC is MODE_FLOAT.
60 ;;    operand 0 is the argument for `sin'.
61 ;; 2  This is a `cos' operation.  The mode of the UNSPEC is MODE_FLOAT.
62 ;;    operand 0 is the argument for `cos'.
63 ;; 3  This is part of a `stack probe' operation.  The mode of the UNSPEC is 
64 ;;    always SImode.  operand 0 is the size of the stack allocation.
65 ;; 4  This is the source of a fake SET of the frame pointer which is used to
66 ;;    prevent insns referencing it being scheduled across the initial
67 ;;    decrement of the stack pointer.
68 ;; 5  This is a `bsf' operation.
69 ;; 6  This is the @GOT offset of a PIC address.
70 ;; 7  This is the @GOTOFF offset of a PIC address.
71 ;; 8  This is a reference to a symbol's @PLT address.
72 ;; 9  This is an `fnstsw' operation.
73 ;; 10 This is a `sahf' operation.
74 ;; 11 This is a `fstcw' operation
75 ;; 12 This is behaviour of add when setting carry flag.
76 ;; 13 This is a `eh_return' placeholder.
77
78 ;; For SSE/MMX support:
79 ;; 30 This is `fix', guaranteed to be truncating.
80 ;; 31 This is a `emms' operation.
81 ;; 32 This is a `maskmov' operation.
82 ;; 33 This is a `movmsk' operation.
83 ;; 34 This is a `non-temporal' move.
84 ;; 35 This is a `prefetch' operation.
85 ;; 36 This is used to distinguish COMISS from UCOMISS.
86 ;; 37 This is a `ldmxcsr' operation.
87 ;; 38 This is a forced `movaps' instruction (rather than whatever movti does)
88 ;; 39 This is a forced `movups' instruction (rather than whatever movti does)
89 ;; 40 This is a `stmxcsr' operation.
90 ;; 41 This is a `shuffle' operation.
91 ;; 42 This is a `rcp' operation.
92 ;; 43 This is a `rsqsrt' operation.
93 ;; 44 This is a `sfence' operation.
94 ;; 45 This is a noop to prevent excessive combiner cleverness.
95 ;; 46 This is a `femms' operation.
96 ;; 47 This is a `prefetch' (3DNow) operation.
97 ;; 48 This is a `prefetchw' operation.
98 ;; 49 This is a 'pavgusb' operation.
99 ;; 50 This is a `pfrcp' operation.
100 ;; 51 This is a `pfrcpit1' operation.
101 ;; 52 This is a `pfrcpit2' operation.
102 ;; 53 This is a `pfrsqrt' operation.
103 ;; 54 This is a `pfrsqrit1' operation.
104
105 ;; Insns whose names begin with "x86_" are emitted by gen_FOO calls
106 ;; from i386.c.
107
108 ;; In C guard expressions, put expressions which may be compile-time
109 ;; constants first.  This allows for better optimization.  For
110 ;; example, write "TARGET_64BIT && reload_completed", not
111 ;; "reload_completed && TARGET_64BIT".
112
113 \f
114 ;; Processor type.  This attribute must exactly match the processor_type
115 ;; enumeration in i386.h.
116 (define_attr "cpu" "i386,i486,pentium,pentiumpro,k6,athlon,pentium4"
117   (const (symbol_ref "ix86_cpu")))
118
119 ;; A basic instruction type.  Refinements due to arguments to be
120 ;; provided in other attributes.
121 (define_attr "type"
122   "other,multi,alu1,negnot,alu,icmp,test,imov,imovx,lea,incdec,ishift,imul,idiv,ibr,setcc,push,pop,call,callv,icmov,fmov,fop,fop1,fsgn,fmul,fdiv,fpspc,fcmov,fcmp,fxch,str,cld,sse,mmx,fistp"
123   (const_string "other"))
124
125 ;; Main data type used by the insn
126 (define_attr "mode" "unknown,none,QI,HI,SI,DI,unknownfp,SF,DF,XF,TI"
127   (const_string "unknown"))
128
129 ;; Set for i387 operations.
130 (define_attr "i387" ""
131   (if_then_else (eq_attr "type" "fmov,fop,fop1,fsgn,fmul,fdiv,fpspc,fcmov,fcmp,fxch,fistp")
132     (const_int 1)
133     (const_int 0)))
134
135 ;; The (bounding maximum) length of an instruction immediate.
136 (define_attr "length_immediate" ""
137   (cond [(eq_attr "type" "incdec,setcc,icmov,ibr,str,cld,lea,other,multi,idiv,sse,mmx")
138            (const_int 0)
139          (eq_attr "i387" "1")
140            (const_int 0)
141          (eq_attr "type" "alu1,negnot,alu,icmp,imovx,ishift,imul,push,pop")
142            (symbol_ref "ix86_attr_length_immediate_default(insn,1)")
143          (eq_attr "type" "imov,test")
144            (symbol_ref "ix86_attr_length_immediate_default(insn,0)")
145          (eq_attr "type" "call")
146            (if_then_else (match_operand 0 "constant_call_address_operand" "")
147              (const_int 4)
148              (const_int 0))
149          (eq_attr "type" "callv")
150            (if_then_else (match_operand 1 "constant_call_address_operand" "")
151              (const_int 4)
152              (const_int 0))
153          (eq_attr "type" "ibr")
154            (if_then_else (and (ge (minus (match_dup 0) (pc))
155                                   (const_int -128))
156                               (lt (minus (match_dup 0) (pc))
157                                   (const_int 124)))
158              (const_int 1)
159              (const_int 4))
160          ]
161          (symbol_ref "/* Update immediate_length and other attributes! */ abort(),1")))
162
163 ;; The (bounding maximum) length of an instruction address.
164 (define_attr "length_address" ""
165   (cond [(eq_attr "type" "str,cld,other,multi,fxch")
166            (const_int 0)
167          (and (eq_attr "type" "call")
168               (match_operand 1 "constant_call_address_operand" ""))
169              (const_int 0)
170          (and (eq_attr "type" "callv")
171               (match_operand 1 "constant_call_address_operand" ""))
172              (const_int 0)
173          ]
174          (symbol_ref "ix86_attr_length_address_default (insn)")))
175
176 ;; Set when length prefix is used.
177 (define_attr "prefix_data16" ""
178   (if_then_else (eq_attr "mode" "HI")
179     (const_int 1)
180     (const_int 0)))
181
182 ;; Set when string REP prefix is used.
183 (define_attr "prefix_rep" "" (const_int 0))
184
185 ;; Set when 0f opcode prefix is used.
186 (define_attr "prefix_0f" ""
187   (if_then_else (eq_attr "type" "imovx,setcc,icmov,sse,mmx")
188     (const_int 1)
189     (const_int 0)))
190
191 ;; Set when modrm byte is used.
192 (define_attr "modrm" ""
193   (cond [(eq_attr "type" "str,cld")
194            (const_int 0)
195          (eq_attr "i387" "1")
196            (const_int 0)
197          (and (eq_attr "type" "incdec")
198               (ior (match_operand:SI 1 "register_operand" "")
199                    (match_operand:HI 1 "register_operand" "")))
200            (const_int 0)
201          (and (eq_attr "type" "push")
202               (not (match_operand 1 "memory_operand" "")))
203            (const_int 0)
204          (and (eq_attr "type" "pop")
205               (not (match_operand 0 "memory_operand" "")))
206            (const_int 0)
207          (and (eq_attr "type" "imov")
208               (and (match_operand 0 "register_operand" "")
209                    (match_operand 1 "immediate_operand" "")))
210            (const_int 0)
211          ]
212          (const_int 1)))
213
214 ;; The (bounding maximum) length of an instruction in bytes.
215 ;; ??? fistp is in fact fldcw/fistp/fldcw sequence.  Later we may want
216 ;; to split it and compute proper length as for other insns.
217 (define_attr "length" ""
218   (cond [(eq_attr "type" "other,multi,fistp")
219            (const_int 16)
220          ]
221          (plus (plus (attr "modrm")
222                      (plus (attr "prefix_0f")
223                            (plus (attr "i387")
224                                  (const_int 1))))
225                (plus (attr "prefix_rep")
226                      (plus (attr "prefix_data16")
227                            (plus (attr "length_immediate")
228                                  (attr "length_address")))))))
229
230 ;; The `memory' attribute is `none' if no memory is referenced, `load' or
231 ;; `store' if there is a simple memory reference therein, or `unknown'
232 ;; if the instruction is complex.
233
234 (define_attr "memory" "none,load,store,both,unknown"
235   (cond [(eq_attr "type" "other,multi,str")
236            (const_string "unknown")
237          (eq_attr "type" "lea,fcmov,fpspc,cld")
238            (const_string "none")
239          (eq_attr "type" "fistp")
240            (const_string "both")
241          (eq_attr "type" "push")
242            (if_then_else (match_operand 1 "memory_operand" "")
243              (const_string "both")
244              (const_string "store"))
245          (eq_attr "type" "pop,setcc")
246            (if_then_else (match_operand 0 "memory_operand" "")
247              (const_string "both")
248              (const_string "load"))
249          (eq_attr "type" "icmp,test")
250            (if_then_else (ior (match_operand 0 "memory_operand" "")
251                               (match_operand 1 "memory_operand" ""))
252              (const_string "load")
253              (const_string "none"))
254          (eq_attr "type" "ibr")
255            (if_then_else (match_operand 0 "memory_operand" "")
256              (const_string "load")
257              (const_string "none"))
258          (eq_attr "type" "call")
259            (if_then_else (match_operand 0 "constant_call_address_operand" "")
260              (const_string "none")
261              (const_string "load"))
262          (eq_attr "type" "callv")
263            (if_then_else (match_operand 1 "constant_call_address_operand" "")
264              (const_string "none")
265              (const_string "load"))
266          (and (eq_attr "type" "alu1,negnot")
267               (match_operand 1 "memory_operand" ""))
268            (const_string "both")
269          (and (match_operand 0 "memory_operand" "")
270               (match_operand 1 "memory_operand" ""))
271            (const_string "both")
272          (match_operand 0 "memory_operand" "")
273            (const_string "store")
274          (match_operand 1 "memory_operand" "")
275            (const_string "load")
276          (and (eq_attr "type" "!icmp,test,alu1,negnot,fop1,fsgn,imov,imovx,fmov,fcmp,sse,mmx")
277               (match_operand 2 "memory_operand" ""))
278            (const_string "load")
279          (and (eq_attr "type" "icmov")
280               (match_operand 3 "memory_operand" ""))
281            (const_string "load")
282         ]
283         (const_string "none")))
284
285 ;; Indicates if an instruction has both an immediate and a displacement.
286
287 (define_attr "imm_disp" "false,true,unknown"
288   (cond [(eq_attr "type" "other,multi")
289            (const_string "unknown")
290          (and (eq_attr "type" "icmp,test,imov")
291               (and (match_operand 0 "memory_displacement_operand" "")
292                    (match_operand 1 "immediate_operand" "")))
293            (const_string "true")
294          (and (eq_attr "type" "alu,ishift,imul,idiv")
295               (and (match_operand 0 "memory_displacement_operand" "")
296                    (match_operand 2 "immediate_operand" "")))
297            (const_string "true")
298         ]
299         (const_string "false")))
300
301 ;; Indicates if an FP operation has an integer source.
302
303 (define_attr "fp_int_src" "false,true"
304   (const_string "false"))
305
306 ;; Describe a user's asm statement.
307 (define_asm_attributes
308   [(set_attr "length" "128")
309    (set_attr "type" "multi")])
310 \f
311 ;; Pentium Scheduling
312 ;;
313 ;; The Pentium is an in-order core with two integer pipelines.
314
315 ;; True for insns that behave like prefixed insns on the Pentium.
316 (define_attr "pent_prefix" "false,true"
317   (if_then_else (ior (eq_attr "prefix_0f" "1")
318                      (ior (eq_attr "prefix_data16" "1")
319                           (eq_attr "prefix_rep" "1")))
320     (const_string "true")
321     (const_string "false")))
322
323 ;; Categorize how an instruction slots.
324
325 ;; The non-MMX Pentium slots an instruction with prefixes on U pipe only,
326 ;; while MMX Pentium can slot it on either U or V.  Model non-MMX Pentium
327 ;; rules, because it results in noticeably better code on non-MMX Pentium
328 ;; and doesn't hurt much on MMX.  (Prefixed instructions are not very
329 ;; common, so the scheduler usualy has a non-prefixed insn to pair).
330
331 (define_attr "pent_pair" "uv,pu,pv,np"
332   (cond [(eq_attr "imm_disp" "true")
333            (const_string "np")
334          (ior (eq_attr "type" "alu1,alu,imov,icmp,test,lea,incdec")
335               (and (eq_attr "type" "pop,push")
336                    (eq_attr "memory" "!both")))
337            (if_then_else (eq_attr "pent_prefix" "true")
338              (const_string "pu")
339              (const_string "uv"))
340          (eq_attr "type" "ibr")
341            (const_string "pv")
342          (and (eq_attr "type" "ishift")
343               (match_operand 2 "const_int_operand" ""))
344            (const_string "pu")
345          (and (eq_attr "type" "call")
346               (match_operand 0 "constant_call_address_operand" ""))
347            (const_string "pv")
348          (and (eq_attr "type" "callv")
349               (match_operand 1 "constant_call_address_operand" ""))
350            (const_string "pv")
351         ]
352         (const_string "np")))
353
354 ;; Rough readiness numbers.  Fine tuning happens in i386.c.
355 ;;
356 ;; u    describes pipe U
357 ;; v    describes pipe V
358 ;; uv   describes either pipe U or V for those that can issue to either
359 ;; np   describes not paring
360 ;; fpu  describes fpu
361 ;; fpm  describes fp insns of different types are not pipelined.
362 ;;
363 ;; ??? fxch isn't handled; not an issue until sched3 after reg-stack is real.
364
365 (define_function_unit "pent_np" 1 0
366   (and (eq_attr "cpu" "pentium")
367        (eq_attr "type" "imul"))
368   11 11)
369
370 (define_function_unit "pent_mul" 1 1
371   (and (eq_attr "cpu" "pentium")
372        (eq_attr "type" "imul"))
373   11 11)
374
375 ;; Rep movs takes minimally 12 cycles.
376 (define_function_unit "pent_np" 1 0
377   (and (eq_attr "cpu" "pentium")
378        (eq_attr "type" "str"))
379   12 12)
380
381 ; ??? IDIV for SI takes 46 cycles, for HI 30, for QI 22
382 (define_function_unit "pent_np" 1 0
383   (and (eq_attr "cpu" "pentium")
384        (eq_attr "type" "idiv"))
385   46 46)
386
387 ; Fp reg-reg moves takes 1 cycle. Loads takes 1 cycle for SF/DF mode,
388 ; 3 cycles for XFmode.  Stores takes 2 cycles for SF/DF and 3 for XF.
389 ; fldz and fld1 takes 2 cycles.  Only reg-reg moves are pairable.
390 ; The integer <-> fp conversion is not modeled correctly. Fild behaves
391 ; like normal fp operation and fist takes 6 cycles.
392
393 (define_function_unit "fpu" 1 0
394   (and (eq_attr "cpu" "pentium")
395        (and (eq_attr "type" "fmov")
396             (and (eq_attr "memory" "load,store")
397                  (eq_attr "mode" "XF"))))
398   3 3)
399
400 (define_function_unit "pent_np" 1 0
401   (and (eq_attr "cpu" "pentium")
402        (and (eq_attr "type" "fmov")
403             (and (eq_attr "memory" "load,store")
404                  (eq_attr "mode" "XF"))))
405   3 3)
406
407 (define_function_unit "fpu" 1 0
408   (and (eq_attr "cpu" "pentium")
409        (and (eq_attr "type" "fmov")
410             (ior (match_operand 1 "immediate_operand" "")
411                  (eq_attr "memory" "store"))))
412   2 2)
413
414 (define_function_unit "pent_np" 1 0
415   (and (eq_attr "cpu" "pentium")
416        (and (eq_attr "type" "fmov")
417             (ior (match_operand 1 "immediate_operand" "")
418                  (eq_attr "memory" "store"))))
419   2 2)
420
421 (define_function_unit "pent_np" 1 0
422   (and (eq_attr "cpu" "pentium")
423        (eq_attr "type" "cld"))
424   2 2)
425
426 (define_function_unit "fpu" 1 0
427   (and (eq_attr "cpu" "pentium")
428        (and (eq_attr "type" "fmov")
429             (eq_attr "memory" "none,load")))
430   1 1)
431
432 ; Read/Modify/Write instructions usually take 3 cycles.
433 (define_function_unit "pent_u" 1 0
434   (and (eq_attr "cpu" "pentium")
435        (and (eq_attr "type" "alu,alu1,ishift")
436             (and (eq_attr "pent_pair" "pu")
437                  (eq_attr "memory" "both"))))
438   3 3)
439
440 (define_function_unit "pent_uv" 2 0
441   (and (eq_attr "cpu" "pentium")
442        (and (eq_attr "type" "alu,alu1,ishift")
443             (and (eq_attr "pent_pair" "!np")
444                  (eq_attr "memory" "both"))))
445   3 3)
446
447 (define_function_unit "pent_np" 1 0
448   (and (eq_attr "cpu" "pentium")
449        (and (eq_attr "type" "alu,alu1,negnot,ishift")
450             (and (eq_attr "pent_pair" "np")
451                  (eq_attr "memory" "both"))))
452   3 3)
453
454 ; Read/Modify or Modify/Write instructions usually take 2 cycles.
455 (define_function_unit "pent_u" 1 0
456   (and (eq_attr "cpu" "pentium")
457        (and (eq_attr "type" "alu,ishift")
458             (and (eq_attr "pent_pair" "pu")
459                  (eq_attr "memory" "load,store"))))
460   2 2)
461
462 (define_function_unit "pent_uv" 2 0
463   (and (eq_attr "cpu" "pentium")
464        (and (eq_attr "type" "alu,ishift")
465             (and (eq_attr "pent_pair" "!np")
466                  (eq_attr "memory" "load,store"))))
467   2 2)
468
469 (define_function_unit "pent_np" 1 0
470   (and (eq_attr "cpu" "pentium")
471        (and (eq_attr "type" "alu,ishift")
472             (and (eq_attr "pent_pair" "np")
473                  (eq_attr "memory" "load,store"))))
474   2 2)
475
476 ; Insns w/o memory operands and move instructions usually take one cycle.
477 (define_function_unit "pent_u" 1 0
478   (and (eq_attr "cpu" "pentium")
479        (eq_attr "pent_pair" "pu"))
480   1 1)
481
482 (define_function_unit "pent_v" 1 0
483   (and (eq_attr "cpu" "pentium")
484        (eq_attr "pent_pair" "pv"))
485   1 1)
486
487 (define_function_unit "pent_uv" 2 0
488   (and (eq_attr "cpu" "pentium")
489        (eq_attr "pent_pair" "!np"))
490   1 1)
491
492 (define_function_unit "pent_np" 1 0
493   (and (eq_attr "cpu" "pentium")
494        (eq_attr "pent_pair" "np"))
495   1 1)
496
497 ; Pairable insns only conflict with other non-pairable insns.
498 (define_function_unit "pent_np" 1 0
499   (and (eq_attr "cpu" "pentium")
500        (and (eq_attr "type" "alu,alu1,ishift")
501             (and (eq_attr "pent_pair" "!np")
502                  (eq_attr "memory" "both"))))
503   3 3
504   [(eq_attr "pent_pair" "np")])
505
506 (define_function_unit "pent_np" 1 0
507   (and (eq_attr "cpu" "pentium")
508        (and (eq_attr "type" "alu,alu1,ishift")
509             (and (eq_attr "pent_pair" "!np")
510                  (eq_attr "memory" "load,store"))))
511   2 2
512   [(eq_attr "pent_pair" "np")])
513
514 (define_function_unit "pent_np" 1 0
515   (and (eq_attr "cpu" "pentium")
516        (eq_attr "pent_pair" "!np"))
517   1 1
518   [(eq_attr "pent_pair" "np")])
519
520 ; Floating point instructions usually blocks cycle longer when combined with
521 ; integer instructions, because of the inpaired fxch instruction.
522 (define_function_unit "pent_np" 1 0
523   (and (eq_attr "cpu" "pentium")
524        (eq_attr "type" "fmov,fop,fop1,fsgn,fmul,fpspc,fcmov,fcmp,fistp"))
525   2 2
526   [(eq_attr "type" "!fmov,fop,fop1,fsgn,fmul,fpspc,fcmov,fcmp,fistp")])
527
528 (define_function_unit "fpu" 1 0
529   (and (eq_attr "cpu" "pentium")
530        (eq_attr "type" "fcmp,fxch,fsgn"))
531   1 1)
532
533 ; Addition takes 3 cycles; assume other random cruft does as well.
534 ; ??? Trivial fp operations such as fabs or fchs takes only one cycle.
535 (define_function_unit "fpu" 1 0
536   (and (eq_attr "cpu" "pentium")
537        (eq_attr "type" "fop,fop1,fistp"))
538   3 1)
539
540 ; Multiplication takes 3 cycles and is only half pipelined.
541 (define_function_unit "fpu" 1 0
542   (and (eq_attr "cpu" "pentium")
543        (eq_attr "type" "fmul"))
544   3 1)
545
546 (define_function_unit "pent_mul" 1 1
547   (and (eq_attr "cpu" "pentium")
548        (eq_attr "type" "fmul"))
549   2 2)
550
551 ; ??? This is correct only for fdiv and sqrt -- sin/cos take 65-100 cycles. 
552 ; They can overlap with integer insns.  Only the last two cycles can overlap
553 ; with other fp insns.  Only fsin/fcos can overlap with multiplies.
554 ; Only last two cycles of fsin/fcos can overlap with other instructions.
555 (define_function_unit "fpu" 1 0
556   (and (eq_attr "cpu" "pentium")
557        (eq_attr "type" "fdiv"))
558   39 37)
559
560 (define_function_unit "pent_mul" 1 1
561   (and (eq_attr "cpu" "pentium")
562        (eq_attr "type" "fdiv"))
563   39 39)
564
565 (define_function_unit "fpu" 1 0
566   (and (eq_attr "cpu" "pentium")
567        (eq_attr "type" "fpspc"))
568   70 68)
569
570 (define_function_unit "pent_mul" 1 1
571   (and (eq_attr "cpu" "pentium")
572        (eq_attr "type" "fpspc"))
573   70 70)
574 \f
575 ;; Pentium Pro/PII Scheduling
576 ;;
577 ;; The PPro has an out-of-order core, but the instruction decoders are
578 ;; naturally in-order and asymmetric.  We get best performance by scheduling
579 ;; for the decoders, for in doing so we give the oo execution unit the 
580 ;; most choices.
581
582 ;; Categorize how many uops an ia32 instruction evaluates to:
583 ;;   one --  an instruction with 1 uop can be decoded by any of the
584 ;;           three decoders.
585 ;;   few --  an instruction with 1 to 4 uops can be decoded only by 
586 ;;           decoder 0.
587 ;;   many -- a complex instruction may take an unspecified number of
588 ;;           cycles to decode in decoder 0.
589
590 (define_attr "ppro_uops" "one,few,many"
591   (cond [(eq_attr "type" "other,multi,call,callv,fpspc,str")
592            (const_string "many")
593          (eq_attr "type" "icmov,fcmov,str,cld")
594            (const_string "few")
595          (eq_attr "type" "imov")
596            (if_then_else (eq_attr "memory" "store,both")
597              (const_string "few")
598              (const_string "one"))
599          (eq_attr "memory" "!none")
600            (const_string "few")
601         ]
602         (const_string "one")))
603
604 ;; Rough readiness numbers.  Fine tuning happens in i386.c.
605 ;;
606 ;; p0   describes port 0.
607 ;; p01  describes ports 0 and 1 as a pair; alu insns can issue to either.
608 ;; p2   describes port 2 for loads.
609 ;; p34  describes ports 3 and 4 for stores.
610 ;; fpu  describes the fpu accessed via port 0. 
611 ;;      ??? It is less than clear if there are separate fadd and fmul units
612 ;;      that could operate in parallel.
613 ;;
614 ;; ??? fxch isn't handled; not an issue until sched3 after reg-stack is real.
615
616 (define_function_unit "ppro_p0" 1 0
617   (and (eq_attr "cpu" "pentiumpro")
618        (eq_attr "type" "ishift,lea,ibr,cld"))
619   1 1)
620
621 (define_function_unit "ppro_p0" 1 0
622   (and (eq_attr "cpu" "pentiumpro")
623        (eq_attr "type" "imul"))
624   4 1)
625
626 ;; ??? Does the divider lock out the pipe while it works,
627 ;; or is there a disconnected unit?
628 (define_function_unit "ppro_p0" 1 0
629   (and (eq_attr "cpu" "pentiumpro")
630        (eq_attr "type" "idiv"))
631   17 17)
632
633 (define_function_unit "ppro_p0" 1 0
634   (and (eq_attr "cpu" "pentiumpro")
635        (eq_attr "type" "fop,fop1,fsgn,fistp"))
636   3 1)
637
638 (define_function_unit "ppro_p0" 1 0
639   (and (eq_attr "cpu" "pentiumpro")
640        (eq_attr "type" "fcmov"))
641   2 1)
642
643 (define_function_unit "ppro_p0" 1 0
644   (and (eq_attr "cpu" "pentiumpro")
645        (eq_attr "type" "fcmp"))
646   1 1)
647
648 (define_function_unit "ppro_p0" 1 0
649   (and (eq_attr "cpu" "pentiumpro")
650        (eq_attr "type" "fmov"))
651   1 1)
652
653 (define_function_unit "ppro_p0" 1 0
654   (and (eq_attr "cpu" "pentiumpro")
655        (eq_attr "type" "fmul"))
656   5 1)
657
658 (define_function_unit "ppro_p0" 1 0
659   (and (eq_attr "cpu" "pentiumpro")
660        (eq_attr "type" "fdiv,fpspc"))
661   56 1)
662
663 (define_function_unit "ppro_p01" 2 0
664   (and (eq_attr "cpu" "pentiumpro")
665        (eq_attr "type" "!imov,fmov"))
666   1 1)
667
668 (define_function_unit "ppro_p01" 2 0
669   (and (and (eq_attr "cpu" "pentiumpro")
670             (eq_attr "type" "imov,fmov"))
671        (eq_attr "memory" "none"))
672   1 1)
673
674 (define_function_unit "ppro_p2" 1 0
675   (and (eq_attr "cpu" "pentiumpro")
676        (ior (eq_attr "type" "pop")
677             (eq_attr "memory" "load,both")))
678   3 1)
679
680 (define_function_unit "ppro_p34" 1 0
681   (and (eq_attr "cpu" "pentiumpro")
682        (ior (eq_attr "type" "push")
683             (eq_attr "memory" "store,both")))
684   1 1)
685
686 (define_function_unit "fpu" 1 0
687   (and (eq_attr "cpu" "pentiumpro")
688        (eq_attr "type" "fop,fop1,fsgn,fmov,fcmp,fcmov,fistp"))
689   1 1)
690
691 (define_function_unit "fpu" 1 0
692   (and (eq_attr "cpu" "pentiumpro")
693        (eq_attr "type" "fmul"))
694   5 2)
695
696 (define_function_unit "fpu" 1 0
697   (and (eq_attr "cpu" "pentiumpro")
698        (eq_attr "type" "fdiv,fpspc"))
699   56 56)
700
701 ;; imul uses the fpu.  ??? does it have the same throughput as fmul?
702 (define_function_unit "fpu" 1 0
703   (and (eq_attr "cpu" "pentiumpro")
704        (eq_attr "type" "imul"))
705   4 1)
706 \f
707 ;; AMD K6/K6-2 Scheduling
708 ;;
709 ;; The K6 has similar architecture to PPro.  Important difference is, that
710 ;; there are only two decoders and they seems to be much slower than execution
711 ;; units.  So we have to pay much more attention to proper decoding for
712 ;; schedulers.  We share most of scheduler code for PPro in i386.c
713 ;;
714 ;; The fp unit is not pipelined and do one operation per two cycles including
715 ;; the FXCH.
716 ;;
717 ;; alu    describes both ALU units (ALU-X and ALU-Y).
718 ;; alux   describes X alu unit
719 ;; fpu    describes FPU unit
720 ;; load   describes load unit.
721 ;; branch describes branch unit.
722 ;; store  decsribes store unit.  This unit is not modelled completely and only
723 ;;        used to model lea operation.  Otherwise it lie outside of the critical
724 ;;        path.
725 ;;
726 ;; ??? fxch isn't handled; not an issue until sched3 after reg-stack is real.
727
728 ;; The decoder specification is in the PPro section above!
729
730 ;; Shift instructions and certain arithmetic are issued only to X pipe.
731 (define_function_unit "k6_alux" 1 0
732   (and (eq_attr "cpu" "k6")
733        (eq_attr "type" "ishift,alu1,negnot,cld"))
734   1 1)
735
736 ;; The QI mode arithmetic is issued to X pipe only.
737 (define_function_unit "k6_alux" 1 0
738   (and (eq_attr "cpu" "k6")
739        (and (eq_attr "type" "alu,alu1,negnot,icmp,test,imovx,incdec")
740             (match_operand:QI 0 "general_operand" "")))
741   1 1)
742
743 (define_function_unit "k6_alu" 2 0
744   (and (eq_attr "cpu" "k6")
745        (eq_attr "type" "ishift,alu1,negnot,alu,icmp,test,imovx,incdec,setcc,lea"))
746   1 1)
747
748 (define_function_unit "k6_alu" 2 0
749   (and (eq_attr "cpu" "k6")
750        (and (eq_attr "type" "imov")
751             (eq_attr "memory" "none")))
752   1 1)
753
754 (define_function_unit "k6_branch" 1 0
755   (and (eq_attr "cpu" "k6")
756        (eq_attr "type" "call,callv,ibr"))
757   1 1)
758
759 ;; Load unit have two cycle latency, but we take care for it in adjust_cost
760 (define_function_unit "k6_load" 1 0
761   (and (eq_attr "cpu" "k6")
762        (ior (eq_attr "type" "pop")
763             (eq_attr "memory" "load,both")))
764   1 1)
765
766 (define_function_unit "k6_load" 1 0
767   (and (eq_attr "cpu" "k6")
768        (and (eq_attr "type" "str")
769             (eq_attr "memory" "load,both")))
770   10 10)
771
772 ;; Lea have two instructions, so latency is probably 2
773 (define_function_unit "k6_store" 1 0
774   (and (eq_attr "cpu" "k6")
775        (eq_attr "type" "lea"))
776   2 1)
777
778 (define_function_unit "k6_store" 1 0
779   (and (eq_attr "cpu" "k6")
780        (eq_attr "type" "str"))
781   10 10)
782
783 (define_function_unit "k6_store" 1 0
784   (and (eq_attr "cpu" "k6")
785        (ior (eq_attr "type" "push")
786             (eq_attr "memory" "store,both")))
787   1 1)
788
789 (define_function_unit "k6_fpu" 1 1
790   (and (eq_attr "cpu" "k6")
791        (eq_attr "type" "fop,fop1,fmov,fcmp,fistp"))
792   2 2)
793
794 (define_function_unit "k6_fpu" 1 1
795   (and (eq_attr "cpu" "k6")
796        (eq_attr "type" "fmul"))
797   2 2)
798
799 ;; ??? Guess
800 (define_function_unit "k6_fpu" 1 1
801   (and (eq_attr "cpu" "k6")
802        (eq_attr "type" "fdiv,fpspc"))
803   56 56)
804
805 (define_function_unit "k6_alu" 2 0
806   (and (eq_attr "cpu" "k6")
807        (eq_attr "type" "imul"))
808   2 2)
809
810 (define_function_unit "k6_alux" 1 0
811   (and (eq_attr "cpu" "k6")
812        (eq_attr "type" "imul"))
813   2 2)
814
815 ;; ??? Guess
816 (define_function_unit "k6_alu" 2 0
817   (and (eq_attr "cpu" "k6")
818        (eq_attr "type" "idiv"))
819   17 17)
820
821 (define_function_unit "k6_alux" 1 0
822   (and (eq_attr "cpu" "k6")
823        (eq_attr "type" "idiv"))
824   17 17)
825 \f
826 ;; AMD Athlon Scheduling
827 ;;
828 ;; The Athlon does contain three pipelined FP units, three integer units and
829 ;; three address generation units. 
830 ;;
831 ;; The predecode logic is determining boundaries of instructions in the 64
832 ;; byte cache line. So the cache line straddling problem of K6 might be issue
833 ;; here as well, but it is not noted in the documentation.
834 ;;
835 ;; Three DirectPath instructions decoders and only one VectorPath decoder
836 ;; is available. They can decode three DirectPath instructions or one VectorPath
837 ;; instruction per cycle.
838 ;; Decoded macro instructions are then passed to 72 entry instruction control
839 ;; unit, that passes
840 ;; it to the specialized integer (18 entry) and fp (36 entry) schedulers.
841 ;;
842 ;; The load/store queue unit is not attached to the schedulers but
843 ;; communicates with all the execution units separately instead.
844
845 (define_attr "athlon_decode" "direct,vector"
846   (cond [(eq_attr "type" "call,imul,idiv,other,multi,fcmov,fpspc,str,pop,cld,fcmov")
847            (const_string "vector")
848          (and (eq_attr "type" "push")
849               (match_operand 1 "memory_operand" ""))
850            (const_string "vector")
851          (and (eq_attr "type" "fmov")
852               (and (eq_attr "memory" "load,store")
853                    (eq_attr "mode" "XF")))
854            (const_string "vector")]
855         (const_string "direct")))
856
857 (define_function_unit "athlon_vectordec" 1 0
858   (and (eq_attr "cpu" "athlon")
859        (eq_attr "athlon_decode" "vector"))
860   1 1)
861
862 (define_function_unit "athlon_directdec" 3 0
863   (and (eq_attr "cpu" "athlon")
864        (eq_attr "athlon_decode" "direct"))
865   1 1)
866
867 (define_function_unit "athlon_vectordec" 1 0
868   (and (eq_attr "cpu" "athlon")
869        (eq_attr "athlon_decode" "direct"))
870   1 1 [(eq_attr "athlon_decode" "vector")])
871
872 (define_function_unit "athlon_ieu" 3 0
873   (and (eq_attr "cpu" "athlon")
874        (eq_attr "type" "alu1,negnot,alu,icmp,test,imov,imovx,lea,incdec,ishift,ibr,call,callv,icmov,cld,pop,setcc,push,pop"))
875   1 1)
876
877 (define_function_unit "athlon_ieu" 3 0
878   (and (eq_attr "cpu" "athlon")
879        (eq_attr "type" "str"))
880   15 15)
881
882 (define_function_unit "athlon_ieu" 3 0
883   (and (eq_attr "cpu" "athlon")
884        (eq_attr "type" "imul"))
885   5 0)
886
887 (define_function_unit "athlon_ieu" 3 0
888   (and (eq_attr "cpu" "athlon")
889        (eq_attr "type" "idiv"))
890   42 0)
891
892 (define_function_unit "athlon_muldiv" 1 0
893   (and (eq_attr "cpu" "athlon")
894        (eq_attr "type" "imul"))
895   5 0)
896
897 (define_function_unit "athlon_muldiv" 1 0
898   (and (eq_attr "cpu" "athlon")
899        (eq_attr "type" "idiv"))
900   42 42)
901
902 (define_attr "athlon_fpunits" "none,store,mul,add,muladd,any"
903   (cond [(eq_attr "type" "fop,fop1,fcmp,fistp")
904            (const_string "add")
905          (eq_attr "type" "fmul,fdiv,fpspc,fsgn,fcmov")
906            (const_string "mul")
907          (and (eq_attr "type" "fmov") (eq_attr "memory" "store,both"))
908            (const_string "store")
909          (and (eq_attr "type" "fmov") (eq_attr "memory" "load"))
910            (const_string "any")
911          (and (eq_attr "type" "fmov")
912               (ior (match_operand:SI 1 "register_operand" "")
913                    (match_operand 1 "immediate_operand" "")))
914            (const_string "store")
915          (eq_attr "type" "fmov")
916            (const_string "muladd")]
917         (const_string "none")))
918
919 ;; We use latencies 1 for definitions.  This is OK to model colisions
920 ;; in execution units.  The real latencies are modeled in the "fp" pipeline.
921
922 ;; fsin, fcos: 96-192
923 ;; fsincos: 107-211
924 ;; fsqrt: 19 for SFmode, 27 for DFmode, 35 for XFmode.
925 (define_function_unit "athlon_fp" 3 0
926   (and (eq_attr "cpu" "athlon")
927        (eq_attr "type" "fpspc"))
928   100 1)
929
930 ;; 16 cycles for SFmode, 20 for DFmode and 24 for XFmode.
931 (define_function_unit "athlon_fp" 3 0
932   (and (eq_attr "cpu" "athlon")
933        (eq_attr "type" "fdiv"))
934   24 1)
935
936 (define_function_unit "athlon_fp" 3 0
937   (and (eq_attr "cpu" "athlon")
938        (eq_attr "type" "fop,fop1,fmul,fistp"))
939   4 1)
940
941 ;; XFmode loads are slow.
942 ;; XFmode store is slow too (8 cycles), but we don't need to model it, because
943 ;; there are no dependent instructions.
944
945 (define_function_unit "athlon_fp" 3 0
946   (and (eq_attr "cpu" "athlon")
947        (and (eq_attr "type" "fmov")
948             (and (eq_attr "memory" "load")
949                  (eq_attr "mode" "XF"))))
950   10 1)
951
952 (define_function_unit "athlon_fp" 3 0
953   (and (eq_attr "cpu" "athlon")
954        (eq_attr "type" "fmov,fsgn"))
955   2 1)
956
957 ;; fcmp and ftst instructions
958 (define_function_unit "athlon_fp" 3 0
959   (and (eq_attr "cpu" "athlon")
960        (and (eq_attr "type" "fcmp")
961             (eq_attr "athlon_decode" "direct")))
962   3 1)
963
964 ;; fcmpi instructions.
965 (define_function_unit "athlon_fp" 3 0
966   (and (eq_attr "cpu" "athlon")
967        (and (eq_attr "type" "fcmp")
968             (eq_attr "athlon_decode" "vector")))
969   3 1)
970
971 (define_function_unit "athlon_fp" 3 0
972   (and (eq_attr "cpu" "athlon")
973        (eq_attr "type" "fcmov"))
974   7 1)
975
976 (define_function_unit "athlon_fp_mul" 1 0
977   (and (eq_attr "cpu" "athlon")
978        (eq_attr "athlon_fpunits" "mul"))
979   1 1)
980
981 (define_function_unit "athlon_fp_add" 1 0
982   (and (eq_attr "cpu" "athlon")
983        (eq_attr "athlon_fpunits" "add"))
984   1 1)
985
986 (define_function_unit "athlon_fp_muladd" 2 0
987   (and (eq_attr "cpu" "athlon")
988        (eq_attr "athlon_fpunits" "muladd,mul,add"))
989   1 1)
990
991 (define_function_unit "athlon_fp_store" 1 0
992   (and (eq_attr "cpu" "athlon")
993        (eq_attr "athlon_fpunits" "store"))
994   1 1)
995
996 ;; We don't need to model the Address Generation Unit, since we don't model
997 ;; the re-order buffer yet and thus we never schedule more than three operations
998 ;; at time.  Later we may want to experiment with MD_SCHED macros modeling the
999 ;; decoders independently on the functional units.
1000
1001 ;(define_function_unit "athlon_agu" 3 0
1002 ;  (and (eq_attr "cpu" "athlon")
1003 ;       (and (eq_attr "memory" "!none")
1004 ;            (eq_attr "athlon_fpunits" "none")))
1005 ;  1 1)
1006
1007 ;; Model load unit to avoid too long sequences of loads.  We don't need to
1008 ;; model store queue, since it is hardly going to be bottleneck.
1009
1010 (define_function_unit "athlon_load" 2 0
1011   (and (eq_attr "cpu" "athlon")
1012        (eq_attr "memory" "load,both"))
1013   1 1)
1014
1015 \f
1016 ;; Compare instructions.
1017
1018 ;; All compare insns have expanders that save the operands away without
1019 ;; actually generating RTL.  The bCOND or sCOND (emitted immediately
1020 ;; after the cmp) will actually emit the cmpM.
1021
1022 (define_expand "cmpdi"
1023   [(set (reg:CC 17)
1024         (compare:CC (match_operand:DI 0 "nonimmediate_operand" "")
1025                     (match_operand:DI 1 "x86_64_general_operand" "")))]
1026   ""
1027 {
1028   if (GET_CODE (operands[0]) == MEM && GET_CODE (operands[1]) == MEM)
1029     operands[0] = force_reg (DImode, operands[0]);
1030   ix86_compare_op0 = operands[0];
1031   ix86_compare_op1 = operands[1];
1032   DONE;
1033 })
1034
1035 (define_expand "cmpsi"
1036   [(set (reg:CC 17)
1037         (compare:CC (match_operand:SI 0 "cmpsi_operand" "")
1038                     (match_operand:SI 1 "general_operand" "")))]
1039   ""
1040 {
1041   if (GET_CODE (operands[0]) == MEM && GET_CODE (operands[1]) == MEM)
1042     operands[0] = force_reg (SImode, operands[0]);
1043   ix86_compare_op0 = operands[0];
1044   ix86_compare_op1 = operands[1];
1045   DONE;
1046 })
1047
1048 (define_expand "cmphi"
1049   [(set (reg:CC 17)
1050         (compare:CC (match_operand:HI 0 "nonimmediate_operand" "")
1051                     (match_operand:HI 1 "general_operand" "")))]
1052   ""
1053 {
1054   if (GET_CODE (operands[0]) == MEM && GET_CODE (operands[1]) == MEM)
1055     operands[0] = force_reg (HImode, operands[0]);
1056   ix86_compare_op0 = operands[0];
1057   ix86_compare_op1 = operands[1];
1058   DONE;
1059 })
1060
1061 (define_expand "cmpqi"
1062   [(set (reg:CC 17)
1063         (compare:CC (match_operand:QI 0 "nonimmediate_operand" "")
1064                     (match_operand:QI 1 "general_operand" "")))]
1065   "TARGET_QIMODE_MATH"
1066 {
1067   if (GET_CODE (operands[0]) == MEM && GET_CODE (operands[1]) == MEM)
1068     operands[0] = force_reg (QImode, operands[0]);
1069   ix86_compare_op0 = operands[0];
1070   ix86_compare_op1 = operands[1];
1071   DONE;
1072 })
1073
1074 (define_insn "cmpdi_ccno_1_rex64"
1075   [(set (reg 17)
1076         (compare (match_operand:DI 0 "nonimmediate_operand" "r,?mr")
1077                  (match_operand:DI 1 "const0_operand" "n,n")))]
1078   "TARGET_64BIT && ix86_match_ccmode (insn, CCNOmode)"
1079   "@
1080    test{q}\t{%0, %0|%0, %0}
1081    cmp{q}\t{%1, %0|%0, %1}"
1082   [(set_attr "type" "test,icmp")
1083    (set_attr "length_immediate" "0,1")
1084    (set_attr "mode" "DI")])
1085
1086 (define_insn "*cmpdi_minus_1_rex64"
1087   [(set (reg 17)
1088         (compare (minus:DI (match_operand:DI 0 "nonimmediate_operand" "rm,r")
1089                            (match_operand:DI 1 "x86_64_general_operand" "re,mr"))
1090                  (const_int 0)))]
1091   "TARGET_64BIT && ix86_match_ccmode (insn, CCGOCmode)"
1092   "cmp{q}\t{%1, %0|%0, %1}"
1093   [(set_attr "type" "icmp")
1094    (set_attr "mode" "DI")])
1095
1096 (define_expand "cmpdi_1_rex64"
1097   [(set (reg:CC 17)
1098         (compare:CC (match_operand:DI 0 "nonimmediate_operand" "")
1099                     (match_operand:DI 1 "general_operand" "")))]
1100   "TARGET_64BIT"
1101   "")
1102
1103 (define_insn "cmpdi_1_insn_rex64"
1104   [(set (reg 17)
1105         (compare (match_operand:DI 0 "nonimmediate_operand" "mr,r")
1106                  (match_operand:DI 1 "x86_64_general_operand" "re,mr")))]
1107   "TARGET_64BIT && ix86_match_ccmode (insn, CCmode)"
1108   "cmp{q}\t{%1, %0|%0, %1}"
1109   [(set_attr "type" "icmp")
1110    (set_attr "mode" "DI")])
1111
1112
1113 (define_insn "*cmpsi_ccno_1"
1114   [(set (reg 17)
1115         (compare (match_operand:SI 0 "nonimmediate_operand" "r,?mr")
1116                  (match_operand:SI 1 "const0_operand" "n,n")))]
1117   "ix86_match_ccmode (insn, CCNOmode)"
1118   "@
1119    test{l}\t{%0, %0|%0, %0}
1120    cmp{l}\t{%1, %0|%0, %1}"
1121   [(set_attr "type" "test,icmp")
1122    (set_attr "length_immediate" "0,1")
1123    (set_attr "mode" "SI")])
1124
1125 (define_insn "*cmpsi_minus_1"
1126   [(set (reg 17)
1127         (compare (minus:SI (match_operand:SI 0 "nonimmediate_operand" "rm,r")
1128                            (match_operand:SI 1 "general_operand" "ri,mr"))
1129                  (const_int 0)))]
1130   "ix86_match_ccmode (insn, CCGOCmode)"
1131   "cmp{l}\t{%1, %0|%0, %1}"
1132   [(set_attr "type" "icmp")
1133    (set_attr "mode" "SI")])
1134
1135 (define_expand "cmpsi_1"
1136   [(set (reg:CC 17)
1137         (compare:CC (match_operand:SI 0 "nonimmediate_operand" "rm,r")
1138                     (match_operand:SI 1 "general_operand" "ri,mr")))]
1139   ""
1140   "")
1141
1142 (define_insn "*cmpsi_1_insn"
1143   [(set (reg 17)
1144         (compare (match_operand:SI 0 "nonimmediate_operand" "rm,r")
1145                  (match_operand:SI 1 "general_operand" "ri,mr")))]
1146   "(GET_CODE (operands[0]) != MEM || GET_CODE (operands[1]) != MEM)
1147     && ix86_match_ccmode (insn, CCmode)"
1148   "cmp{l}\t{%1, %0|%0, %1}"
1149   [(set_attr "type" "icmp")
1150    (set_attr "mode" "SI")])
1151
1152 (define_insn "*cmphi_ccno_1"
1153   [(set (reg 17)
1154         (compare (match_operand:HI 0 "nonimmediate_operand" "r,?mr")
1155                  (match_operand:HI 1 "const0_operand" "n,n")))]
1156   "ix86_match_ccmode (insn, CCNOmode)"
1157   "@
1158    test{w}\t{%0, %0|%0, %0}
1159    cmp{w}\t{%1, %0|%0, %1}"
1160   [(set_attr "type" "test,icmp")
1161    (set_attr "length_immediate" "0,1")
1162    (set_attr "mode" "HI")])
1163
1164 (define_insn "*cmphi_minus_1"
1165   [(set (reg 17)
1166         (compare (minus:HI (match_operand:HI 0 "nonimmediate_operand" "rm,r")
1167                            (match_operand:HI 1 "general_operand" "ri,mr"))
1168                  (const_int 0)))]
1169   "ix86_match_ccmode (insn, CCGOCmode)"
1170   "cmp{w}\t{%1, %0|%0, %1}"
1171   [(set_attr "type" "icmp")
1172    (set_attr "mode" "HI")])
1173
1174 (define_insn "*cmphi_1"
1175   [(set (reg 17)
1176         (compare (match_operand:HI 0 "nonimmediate_operand" "rm,r")
1177                  (match_operand:HI 1 "general_operand" "ri,mr")))]
1178   "(GET_CODE (operands[0]) != MEM || GET_CODE (operands[1]) != MEM)
1179    && ix86_match_ccmode (insn, CCmode)"
1180   "cmp{w}\t{%1, %0|%0, %1}"
1181   [(set_attr "type" "icmp")
1182    (set_attr "mode" "HI")])
1183
1184 (define_insn "*cmpqi_ccno_1"
1185   [(set (reg 17)
1186         (compare (match_operand:QI 0 "nonimmediate_operand" "q,?mq")
1187                  (match_operand:QI 1 "const0_operand" "n,n")))]
1188   "ix86_match_ccmode (insn, CCNOmode)"
1189   "@
1190    test{b}\t{%0, %0|%0, %0}
1191    cmp{b}\t{$0, %0|%0, 0}"
1192   [(set_attr "type" "test,icmp")
1193    (set_attr "length_immediate" "0,1")
1194    (set_attr "mode" "QI")])
1195
1196 (define_insn "*cmpqi_1"
1197   [(set (reg 17)
1198         (compare (match_operand:QI 0 "nonimmediate_operand" "qm,q")
1199                  (match_operand:QI 1 "general_operand" "qi,mq")))]
1200   "(GET_CODE (operands[0]) != MEM || GET_CODE (operands[1]) != MEM)
1201     && ix86_match_ccmode (insn, CCmode)"
1202   "cmp{b}\t{%1, %0|%0, %1}"
1203   [(set_attr "type" "icmp")
1204    (set_attr "mode" "QI")])
1205
1206 (define_insn "*cmpqi_minus_1"
1207   [(set (reg 17)
1208         (compare (minus:QI (match_operand:QI 0 "nonimmediate_operand" "qm,q")
1209                            (match_operand:QI 1 "general_operand" "qi,mq"))
1210                  (const_int 0)))]
1211   "ix86_match_ccmode (insn, CCGOCmode)"
1212   "cmp{b}\t{%1, %0|%0, %1}"
1213   [(set_attr "type" "icmp")
1214    (set_attr "mode" "QI")])
1215
1216 (define_insn "*cmpqi_ext_1"
1217   [(set (reg 17)
1218         (compare
1219           (match_operand:QI 0 "general_operand" "Qm")
1220           (subreg:QI
1221             (zero_extract:SI
1222               (match_operand 1 "ext_register_operand" "Q")
1223               (const_int 8)
1224               (const_int 8)) 0)))]
1225   "!TARGET_64BIT && ix86_match_ccmode (insn, CCmode)"
1226   "cmp{b}\t{%h1, %0|%0, %h1}"
1227   [(set_attr "type" "icmp")
1228    (set_attr "mode" "QI")])
1229
1230 (define_insn "*cmpqi_ext_1_rex64"
1231   [(set (reg 17)
1232         (compare
1233           (match_operand:QI 0 "register_operand" "Q")
1234           (subreg:QI
1235             (zero_extract:SI
1236               (match_operand 1 "ext_register_operand" "Q")
1237               (const_int 8)
1238               (const_int 8)) 0)))]
1239   "TARGET_64BIT && ix86_match_ccmode (insn, CCmode)"
1240   "cmp{b}\t{%h1, %0|%0, %h1}"
1241   [(set_attr "type" "icmp")
1242    (set_attr "mode" "QI")])
1243
1244 (define_insn "*cmpqi_ext_2"
1245   [(set (reg 17)
1246         (compare
1247           (subreg:QI
1248             (zero_extract:SI
1249               (match_operand 0 "ext_register_operand" "Q")
1250               (const_int 8)
1251               (const_int 8)) 0)
1252           (match_operand:QI 1 "const0_operand" "n")))]
1253   "ix86_match_ccmode (insn, CCNOmode)"
1254   "test{b}\t%h0, %h0"
1255   [(set_attr "type" "test")
1256    (set_attr "length_immediate" "0")
1257    (set_attr "mode" "QI")])
1258
1259 (define_expand "cmpqi_ext_3"
1260   [(set (reg:CC 17)
1261         (compare:CC
1262           (subreg:QI
1263             (zero_extract:SI
1264               (match_operand 0 "ext_register_operand" "")
1265               (const_int 8)
1266               (const_int 8)) 0)
1267           (match_operand:QI 1 "general_operand" "")))]
1268   ""
1269   "")
1270
1271 (define_insn "cmpqi_ext_3_insn"
1272   [(set (reg 17)
1273         (compare
1274           (subreg:QI
1275             (zero_extract:SI
1276               (match_operand 0 "ext_register_operand" "Q")
1277               (const_int 8)
1278               (const_int 8)) 0)
1279           (match_operand:QI 1 "general_operand" "Qmn")))]
1280   "!TARGET_64BIT && ix86_match_ccmode (insn, CCmode)"
1281   "cmp{b}\t{%1, %h0|%h0, %1}"
1282   [(set_attr "type" "icmp")
1283    (set_attr "mode" "QI")])
1284
1285 (define_insn "cmpqi_ext_3_insn_rex64"
1286   [(set (reg 17)
1287         (compare
1288           (subreg:QI
1289             (zero_extract:SI
1290               (match_operand 0 "ext_register_operand" "Q")
1291               (const_int 8)
1292               (const_int 8)) 0)
1293           (match_operand:QI 1 "nonmemory_operand" "Qn")))]
1294   "TARGET_64BIT && ix86_match_ccmode (insn, CCmode)"
1295   "cmp{b}\t{%1, %h0|%h0, %1}"
1296   [(set_attr "type" "icmp")
1297    (set_attr "mode" "QI")])
1298
1299 (define_insn "*cmpqi_ext_4"
1300   [(set (reg 17)
1301         (compare
1302           (subreg:QI
1303             (zero_extract:SI
1304               (match_operand 0 "ext_register_operand" "Q")
1305               (const_int 8)
1306               (const_int 8)) 0)
1307           (subreg:QI
1308             (zero_extract:SI
1309               (match_operand 1 "ext_register_operand" "Q")
1310               (const_int 8)
1311               (const_int 8)) 0)))]
1312   "ix86_match_ccmode (insn, CCmode)"
1313   "cmp{b}\t{%h1, %h0|%h0, %h1}"
1314   [(set_attr "type" "icmp")
1315    (set_attr "mode" "QI")])
1316
1317 ;; These implement float point compares.
1318 ;; %%% See if we can get away with VOIDmode operands on the actual insns,
1319 ;; which would allow mix and match FP modes on the compares.  Which is what
1320 ;; the old patterns did, but with many more of them.
1321
1322 (define_expand "cmpxf"
1323   [(set (reg:CC 17)
1324         (compare:CC (match_operand:XF 0 "cmp_fp_expander_operand" "")
1325                     (match_operand:XF 1 "cmp_fp_expander_operand" "")))]
1326   "!TARGET_64BIT && TARGET_80387"
1327 {
1328   ix86_compare_op0 = operands[0];
1329   ix86_compare_op1 = operands[1];
1330   DONE;
1331 })
1332
1333 (define_expand "cmptf"
1334   [(set (reg:CC 17)
1335         (compare:CC (match_operand:TF 0 "cmp_fp_expander_operand" "")
1336                     (match_operand:TF 1 "cmp_fp_expander_operand" "")))]
1337   "TARGET_80387"
1338 {
1339   ix86_compare_op0 = operands[0];
1340   ix86_compare_op1 = operands[1];
1341   DONE;
1342 })
1343
1344 (define_expand "cmpdf"
1345   [(set (reg:CC 17)
1346         (compare:CC (match_operand:DF 0 "cmp_fp_expander_operand" "")
1347                     (match_operand:DF 1 "cmp_fp_expander_operand" "")))]
1348   "TARGET_80387 || TARGET_SSE2"
1349 {
1350   ix86_compare_op0 = operands[0];
1351   ix86_compare_op1 = operands[1];
1352   DONE;
1353 })
1354
1355 (define_expand "cmpsf"
1356   [(set (reg:CC 17)
1357         (compare:CC (match_operand:SF 0 "cmp_fp_expander_operand" "")
1358                     (match_operand:SF 1 "cmp_fp_expander_operand" "")))]
1359   "TARGET_80387 || TARGET_SSE"
1360 {
1361   ix86_compare_op0 = operands[0];
1362   ix86_compare_op1 = operands[1];
1363   DONE;
1364 })
1365
1366 ;; FP compares, step 1:
1367 ;; Set the FP condition codes.
1368 ;;
1369 ;; CCFPmode     compare with exceptions
1370 ;; CCFPUmode    compare with no exceptions
1371
1372 ;; %%% It is an unfortunate fact that ftst has no non-popping variant,
1373 ;; and that fp moves clobber the condition codes, and that there is
1374 ;; currently no way to describe this fact to reg-stack.  So there are
1375 ;; no splitters yet for this.
1376
1377 ;; %%% YIKES!  This scheme does not retain a strong connection between 
1378 ;; the real compare and the ultimate cc0 user, so CC_REVERSE does not
1379 ;; work!  Only allow tos/mem with tos in op 0.
1380 ;;
1381 ;; Hmm, of course, this is what the actual _hardware_ does.  Perhaps
1382 ;; things aren't as bad as they sound...
1383
1384 (define_insn "*cmpfp_0"
1385   [(set (match_operand:HI 0 "register_operand" "=a")
1386         (unspec:HI
1387           [(compare:CCFP (match_operand 1 "register_operand" "f")
1388                          (match_operand 2 "const0_operand" "X"))] 9))]
1389   "TARGET_80387
1390    && FLOAT_MODE_P (GET_MODE (operands[1]))
1391    && GET_MODE (operands[1]) == GET_MODE (operands[2])"
1392 {
1393   if (find_regno_note (insn, REG_DEAD, REGNO (operands[1])))
1394     return "ftst\;fnstsw\t%0\;fstp\t%y0";
1395   else
1396     return "ftst\;fnstsw\t%0";
1397 }
1398   [(set_attr "type" "multi")
1399    (set_attr "mode" "unknownfp")])
1400
1401 ;; We may not use "#" to split and emit these, since the REG_DEAD notes
1402 ;; used to manage the reg stack popping would not be preserved.
1403
1404 (define_insn "*cmpfp_2_sf"
1405   [(set (reg:CCFP 18)
1406         (compare:CCFP
1407           (match_operand:SF 0 "register_operand" "f")
1408           (match_operand:SF 1 "nonimmediate_operand" "fm")))]
1409   "TARGET_80387"
1410   "* return output_fp_compare (insn, operands, 0, 0);"
1411   [(set_attr "type" "fcmp")
1412    (set_attr "mode" "SF")])
1413
1414 (define_insn "*cmpfp_2_sf_1"
1415   [(set (match_operand:HI 0 "register_operand" "=a")
1416         (unspec:HI
1417           [(compare:CCFP
1418              (match_operand:SF 1 "register_operand" "f")
1419              (match_operand:SF 2 "nonimmediate_operand" "fm"))] 9))]
1420   "TARGET_80387"
1421   "* return output_fp_compare (insn, operands, 2, 0);"
1422   [(set_attr "type" "fcmp")
1423    (set_attr "mode" "SF")])
1424
1425 (define_insn "*cmpfp_2_df"
1426   [(set (reg:CCFP 18)
1427         (compare:CCFP
1428           (match_operand:DF 0 "register_operand" "f")
1429           (match_operand:DF 1 "nonimmediate_operand" "fm")))]
1430   "TARGET_80387"
1431   "* return output_fp_compare (insn, operands, 0, 0);"
1432   [(set_attr "type" "fcmp")
1433    (set_attr "mode" "DF")])
1434
1435 (define_insn "*cmpfp_2_df_1"
1436   [(set (match_operand:HI 0 "register_operand" "=a")
1437         (unspec:HI
1438           [(compare:CCFP
1439              (match_operand:DF 1 "register_operand" "f")
1440              (match_operand:DF 2 "nonimmediate_operand" "fm"))] 9))]
1441   "TARGET_80387"
1442   "* return output_fp_compare (insn, operands, 2, 0);"
1443   [(set_attr "type" "multi")
1444    (set_attr "mode" "DF")])
1445
1446 (define_insn "*cmpfp_2_xf"
1447   [(set (reg:CCFP 18)
1448         (compare:CCFP
1449           (match_operand:XF 0 "register_operand" "f")
1450           (match_operand:XF 1 "register_operand" "f")))]
1451   "!TARGET_64BIT && TARGET_80387"
1452   "* return output_fp_compare (insn, operands, 0, 0);"
1453   [(set_attr "type" "fcmp")
1454    (set_attr "mode" "XF")])
1455
1456 (define_insn "*cmpfp_2_tf"
1457   [(set (reg:CCFP 18)
1458         (compare:CCFP
1459           (match_operand:TF 0 "register_operand" "f")
1460           (match_operand:TF 1 "register_operand" "f")))]
1461   "TARGET_80387"
1462   "* return output_fp_compare (insn, operands, 0, 0);"
1463   [(set_attr "type" "fcmp")
1464    (set_attr "mode" "XF")])
1465
1466 (define_insn "*cmpfp_2_xf_1"
1467   [(set (match_operand:HI 0 "register_operand" "=a")
1468         (unspec:HI
1469           [(compare:CCFP
1470              (match_operand:XF 1 "register_operand" "f")
1471              (match_operand:XF 2 "register_operand" "f"))] 9))]
1472   "!TARGET_64BIT && TARGET_80387"
1473   "* return output_fp_compare (insn, operands, 2, 0);"
1474   [(set_attr "type" "multi")
1475    (set_attr "mode" "XF")])
1476
1477 (define_insn "*cmpfp_2_tf_1"
1478   [(set (match_operand:HI 0 "register_operand" "=a")
1479         (unspec:HI
1480           [(compare:CCFP
1481              (match_operand:TF 1 "register_operand" "f")
1482              (match_operand:TF 2 "register_operand" "f"))] 9))]
1483   "TARGET_80387"
1484   "* return output_fp_compare (insn, operands, 2, 0);"
1485   [(set_attr "type" "multi")
1486    (set_attr "mode" "XF")])
1487
1488 (define_insn "*cmpfp_2u"
1489   [(set (reg:CCFPU 18)
1490         (compare:CCFPU
1491           (match_operand 0 "register_operand" "f")
1492           (match_operand 1 "register_operand" "f")))]
1493   "TARGET_80387
1494    && FLOAT_MODE_P (GET_MODE (operands[0]))
1495    && GET_MODE (operands[0]) == GET_MODE (operands[1])"
1496   "* return output_fp_compare (insn, operands, 0, 1);"
1497   [(set_attr "type" "fcmp")
1498    (set_attr "mode" "unknownfp")])
1499
1500 (define_insn "*cmpfp_2u_1"
1501   [(set (match_operand:HI 0 "register_operand" "=a")
1502         (unspec:HI
1503           [(compare:CCFPU
1504              (match_operand 1 "register_operand" "f")
1505              (match_operand 2 "register_operand" "f"))] 9))]
1506   "TARGET_80387
1507    && FLOAT_MODE_P (GET_MODE (operands[1]))
1508    && GET_MODE (operands[1]) == GET_MODE (operands[2])"
1509   "* return output_fp_compare (insn, operands, 2, 1);"
1510   [(set_attr "type" "multi")
1511    (set_attr "mode" "unknownfp")])
1512
1513 ;; Patterns to match the SImode-in-memory ficom instructions.
1514 ;;
1515 ;; %%% Play games with accepting gp registers, as otherwise we have to
1516 ;; force them to memory during rtl generation, which is no good.  We
1517 ;; can get rid of this once we teach reload to do memory input reloads 
1518 ;; via pushes.
1519
1520 (define_insn "*ficom_1"
1521   [(set (reg:CCFP 18)
1522         (compare:CCFP
1523           (match_operand 0 "register_operand" "f,f")
1524           (float (match_operand:SI 1 "nonimmediate_operand" "m,?r"))))]
1525   "0 && TARGET_80387 && FLOAT_MODE_P (GET_MODE (operands[0]))
1526    && GET_MODE (XEXP (SET_SRC (PATTERN (insn)), 1)) == GET_MODE (operands[0])"
1527   "#")
1528
1529 ;; Split the not-really-implemented gp register case into a
1530 ;; push-op-pop sequence.
1531 ;;
1532 ;; %%% This is most efficient, but am I gonna get in trouble
1533 ;; for separating cc0_setter and cc0_user?
1534
1535 (define_split
1536   [(set (reg:CCFP 18)
1537         (compare:CCFP
1538           (match_operand:SF 0 "register_operand" "")
1539           (float (match_operand:SI 1 "register_operand" ""))))]
1540   "0 && TARGET_80387 && reload_completed"
1541   [(set (mem:SI (pre_dec:SI (reg:SI 7))) (match_dup 1))
1542    (set (reg:CCFP 18) (compare:CCFP (match_dup 0) (match_dup 2)))
1543    (parallel [(set (match_dup 1) (mem:SI (reg:SI 7)))
1544               (set (reg:SI 7) (plus:SI (reg:SI 7) (const_int 4)))])]
1545   "operands[2] = gen_rtx_MEM (Pmode, stack_pointer_rtx);
1546    operands[2] = gen_rtx_FLOAT (GET_MODE (operands[0]), operands[2]);")
1547
1548 ;; FP compares, step 2
1549 ;; Move the fpsw to ax.
1550
1551 (define_insn "x86_fnstsw_1"
1552   [(set (match_operand:HI 0 "register_operand" "=a")
1553         (unspec:HI [(reg 18)] 9))]
1554   "TARGET_80387"
1555   "fnstsw\t%0"
1556   [(set_attr "length" "2")
1557    (set_attr "mode" "SI")
1558    (set_attr "i387" "1")
1559    (set_attr "ppro_uops" "few")])
1560
1561 ;; FP compares, step 3
1562 ;; Get ax into flags, general case.
1563
1564 (define_insn "x86_sahf_1"
1565   [(set (reg:CC 17)
1566         (unspec:CC [(match_operand:HI 0 "register_operand" "a")] 10))]
1567   "!TARGET_64BIT"
1568   "sahf"
1569   [(set_attr "length" "1")
1570    (set_attr "athlon_decode" "vector")
1571    (set_attr "mode" "SI")
1572    (set_attr "ppro_uops" "one")])
1573
1574 ;; Pentium Pro can do steps 1 through 3 in one go.
1575
1576 (define_insn "*cmpfp_i"
1577   [(set (reg:CCFP 17)
1578         (compare:CCFP (match_operand 0 "register_operand" "f")
1579                       (match_operand 1 "register_operand" "f")))]
1580   "TARGET_80387 && TARGET_CMOVE
1581    && !SSE_FLOAT_MODE_P (GET_MODE (operands[0]))
1582    && FLOAT_MODE_P (GET_MODE (operands[0]))
1583    && GET_MODE (operands[0]) == GET_MODE (operands[0])"
1584   "* return output_fp_compare (insn, operands, 1, 0);"
1585   [(set_attr "type" "fcmp")
1586    (set_attr "mode" "unknownfp")
1587    (set_attr "athlon_decode" "vector")])
1588
1589 (define_insn "*cmpfp_i_sse"
1590   [(set (reg:CCFP 17)
1591         (compare:CCFP (match_operand 0 "register_operand" "f#x,x#f")
1592                       (match_operand 1 "nonimmediate_operand" "f#x,xm#f")))]
1593   "TARGET_80387
1594    && SSE_FLOAT_MODE_P (GET_MODE (operands[0]))
1595    && GET_MODE (operands[0]) == GET_MODE (operands[0])"
1596   "* return output_fp_compare (insn, operands, 1, 0);"
1597   [(set_attr "type" "fcmp,sse")
1598    (set_attr "mode" "unknownfp")
1599    (set_attr "athlon_decode" "vector")])
1600
1601 (define_insn "*cmpfp_i_sse_only"
1602   [(set (reg:CCFP 17)
1603         (compare:CCFP (match_operand 0 "register_operand" "x")
1604                       (match_operand 1 "nonimmediate_operand" "xm")))]
1605   "SSE_FLOAT_MODE_P (GET_MODE (operands[0]))
1606    && GET_MODE (operands[0]) == GET_MODE (operands[0])"
1607   "* return output_fp_compare (insn, operands, 1, 0);"
1608   [(set_attr "type" "sse")
1609    (set_attr "mode" "unknownfp")
1610    (set_attr "athlon_decode" "vector")])
1611
1612 (define_insn "*cmpfp_iu"
1613   [(set (reg:CCFPU 17)
1614         (compare:CCFPU (match_operand 0 "register_operand" "f")
1615                        (match_operand 1 "register_operand" "f")))]
1616   "TARGET_80387 && TARGET_CMOVE
1617    && !SSE_FLOAT_MODE_P (GET_MODE (operands[0]))
1618    && FLOAT_MODE_P (GET_MODE (operands[0]))
1619    && GET_MODE (operands[0]) == GET_MODE (operands[1])"
1620   "* return output_fp_compare (insn, operands, 1, 1);"
1621   [(set_attr "type" "fcmp")
1622    (set_attr "mode" "unknownfp")
1623    (set_attr "athlon_decode" "vector")])
1624
1625 (define_insn "*cmpfp_iu_sse"
1626   [(set (reg:CCFPU 17)
1627         (compare:CCFPU (match_operand 0 "register_operand" "f#x,x#f")
1628                        (match_operand 1 "nonimmediate_operand" "f#x,xm#f")))]
1629   "TARGET_80387
1630    && SSE_FLOAT_MODE_P (GET_MODE (operands[0]))
1631    && GET_MODE (operands[0]) == GET_MODE (operands[1])"
1632   "* return output_fp_compare (insn, operands, 1, 1);"
1633   [(set_attr "type" "fcmp,sse")
1634    (set_attr "mode" "unknownfp")
1635    (set_attr "athlon_decode" "vector")])
1636
1637 (define_insn "*cmpfp_iu_sse_only"
1638   [(set (reg:CCFPU 17)
1639         (compare:CCFPU (match_operand 0 "register_operand" "x")
1640                        (match_operand 1 "nonimmediate_operand" "xm")))]
1641   "SSE_FLOAT_MODE_P (GET_MODE (operands[0]))
1642    && GET_MODE (operands[0]) == GET_MODE (operands[1])"
1643   "* return output_fp_compare (insn, operands, 1, 1);"
1644   [(set_attr "type" "sse")
1645    (set_attr "mode" "unknownfp")
1646    (set_attr "athlon_decode" "vector")])
1647 \f
1648 ;; Move instructions.
1649
1650 ;; General case of fullword move.
1651
1652 (define_expand "movsi"
1653   [(set (match_operand:SI 0 "nonimmediate_operand" "")
1654         (match_operand:SI 1 "general_operand" ""))]
1655   ""
1656   "ix86_expand_move (SImode, operands); DONE;")
1657
1658 ;; Push/pop instructions.  They are separate since autoinc/dec is not a
1659 ;; general_operand.
1660 ;;
1661 ;; %%% We don't use a post-inc memory reference because x86 is not a 
1662 ;; general AUTO_INC_DEC host, which impacts how it is treated in flow.
1663 ;; Changing this impacts compiler performance on other non-AUTO_INC_DEC
1664 ;; targets without our curiosities, and it is just as easy to represent
1665 ;; this differently.
1666
1667 (define_insn "*pushsi2"
1668   [(set (match_operand:SI 0 "push_operand" "=<")
1669         (match_operand:SI 1 "general_no_elim_operand" "ri*m"))]
1670   "!TARGET_64BIT"
1671   "push{l}\t%1"
1672   [(set_attr "type" "push")
1673    (set_attr "mode" "SI")])
1674
1675 ;; For 64BIT abi we always round up to 8 bytes.
1676 (define_insn "*pushsi2_rex64"
1677   [(set (match_operand:SI 0 "push_operand" "=X")
1678         (match_operand:SI 1 "nonmemory_no_elim_operand" "ri"))]
1679   "TARGET_64BIT"
1680   "push{q}\t%q1"
1681   [(set_attr "type" "push")
1682    (set_attr "mode" "SI")])
1683
1684 (define_insn "*pushsi2_prologue"
1685   [(set (match_operand:SI 0 "push_operand" "=<")
1686         (match_operand:SI 1 "general_no_elim_operand" "ri*m"))
1687    (clobber (mem:BLK (scratch)))]
1688   "!TARGET_64BIT"
1689   "push{l}\t%1"
1690   [(set_attr "type" "push")
1691    (set_attr "mode" "SI")])
1692
1693 (define_insn "*popsi1_epilogue"
1694   [(set (match_operand:SI 0 "nonimmediate_operand" "=r*m")
1695         (mem:SI (reg:SI 7)))
1696    (set (reg:SI 7)
1697         (plus:SI (reg:SI 7) (const_int 4)))
1698    (clobber (mem:BLK (scratch)))]
1699   "!TARGET_64BIT"
1700   "pop{l}\t%0"
1701   [(set_attr "type" "pop")
1702    (set_attr "mode" "SI")])
1703
1704 (define_insn "popsi1"
1705   [(set (match_operand:SI 0 "nonimmediate_operand" "=r*m")
1706         (mem:SI (reg:SI 7)))
1707    (set (reg:SI 7)
1708         (plus:SI (reg:SI 7) (const_int 4)))]
1709   "!TARGET_64BIT"
1710   "pop{l}\t%0"
1711   [(set_attr "type" "pop")
1712    (set_attr "mode" "SI")])
1713
1714 (define_insn "*movsi_xor"
1715   [(set (match_operand:SI 0 "register_operand" "=r")
1716         (match_operand:SI 1 "const0_operand" "i"))
1717    (clobber (reg:CC 17))]
1718   "reload_completed && (!TARGET_USE_MOV0 || optimize_size)"
1719   "xor{l}\t{%0, %0|%0, %0}"
1720   [(set_attr "type" "alu1")
1721    (set_attr "mode" "SI")
1722    (set_attr "length_immediate" "0")])
1723
1724 (define_insn "*movsi_or"
1725   [(set (match_operand:SI 0 "register_operand" "=r")
1726         (match_operand:SI 1 "immediate_operand" "i"))
1727    (clobber (reg:CC 17))]
1728   "reload_completed && GET_CODE (operands[1]) == CONST_INT
1729    && INTVAL (operands[1]) == -1
1730    && (TARGET_PENTIUM || optimize_size)"
1731 {
1732   operands[1] = constm1_rtx;
1733   return "or{l}\t{%1, %0|%0, %1}";
1734 }
1735   [(set_attr "type" "alu1")
1736    (set_attr "mode" "SI")
1737    (set_attr "length_immediate" "1")])
1738
1739 (define_insn "*movsi_1"
1740   [(set (match_operand:SI 0 "nonimmediate_operand" "=*a,r,*a,m,!*y,!rm,!*Y,!rm,!*Y")
1741         (match_operand:SI 1 "general_operand" "im,rinm,rinm,rin,rm,*y,rm,*Y,*Y"))]
1742   "GET_CODE (operands[0]) != MEM || GET_CODE (operands[1]) != MEM"
1743 {
1744   switch (get_attr_type (insn))
1745     {
1746     case TYPE_SSE:
1747       if (get_attr_mode (insn) == TImode)
1748         return "movdqa\t{%1, %0|%0, %1}";
1749       return "movd\t{%1, %0|%0, %1}";
1750
1751     case TYPE_MMX:
1752       return "movd\t{%1, %0|%0, %1}";
1753
1754     case TYPE_LEA:
1755       return "lea{l}\t{%1, %0|%0, %1}";
1756
1757     default:
1758       if (flag_pic && SYMBOLIC_CONST (operands[1]))
1759         abort();
1760       return "mov{l}\t{%1, %0|%0, %1}";
1761     }
1762 }
1763   [(set (attr "type")
1764      (cond [(eq_attr "alternative" "4,5")
1765               (const_string "mmx")
1766             (eq_attr "alternative" "6,7,8")
1767               (const_string "sse")
1768             (and (ne (symbol_ref "flag_pic") (const_int 0))
1769                  (match_operand:SI 1 "symbolic_operand" ""))
1770               (const_string "lea")
1771            ]
1772            (const_string "imov")))
1773    (set_attr "modrm" "0,*,0,*,*,*,*,*,*")
1774    (set_attr "mode" "SI,SI,SI,SI,SI,SI,TI,SI,SI")])
1775
1776 ;; Stores and loads of ax to arbitary constant address.
1777 ;; We fake an second form of instruction to force reload to load address
1778 ;; into register when rax is not available
1779 (define_insn "*movabssi_1_rex64"
1780   [(set (mem:SI (match_operand:DI 0 "x86_64_movabs_operand" "i,r,r"))
1781         (match_operand:SI 1 "nonmemory_operand" "a,er,i"))]
1782   "TARGET_64BIT"
1783   "@
1784    movabs{l}\t{%1, %P0|%P0, %1}
1785    mov{l}\t{%1, %a0|%a0, %1}
1786    movabs{l}\t{%1, %a0|%a0, %1}"
1787   [(set_attr "type" "imov")
1788    (set_attr "modrm" "0,*,*")
1789    (set_attr "length_address" "8,0,0")
1790    (set_attr "length_immediate" "0,*,*")
1791    (set_attr "memory" "store")
1792    (set_attr "mode" "SI")])
1793
1794 (define_insn "*movabssi_2_rex64"
1795   [(set (match_operand:SI 0 "register_operand" "=a,r")
1796         (mem:SI (match_operand:DI 1 "x86_64_movabs_operand" "i,r")))]
1797   "TARGET_64BIT"
1798   "@
1799    movabs{l}\t{%P1, %0|%0, %P1}
1800    mov{l}\t{%a1, %0|%0, %a1}"
1801   [(set_attr "type" "imov")
1802    (set_attr "modrm" "0,*")
1803    (set_attr "length_address" "8,0")
1804    (set_attr "length_immediate" "0")
1805    (set_attr "memory" "load")
1806    (set_attr "mode" "SI")])
1807
1808 (define_insn "*swapsi"
1809   [(set (match_operand:SI 0 "register_operand" "+r")
1810         (match_operand:SI 1 "register_operand" "+r"))
1811    (set (match_dup 1)
1812         (match_dup 0))]
1813   ""
1814   "xchg{l}\t%1, %0"
1815   [(set_attr "type" "imov")
1816    (set_attr "pent_pair" "np")
1817    (set_attr "athlon_decode" "vector")
1818    (set_attr "mode" "SI")
1819    (set_attr "modrm" "0")
1820    (set_attr "ppro_uops" "few")])
1821
1822 (define_expand "movhi"
1823   [(set (match_operand:HI 0 "nonimmediate_operand" "")
1824         (match_operand:HI 1 "general_operand" ""))]
1825   ""
1826   "ix86_expand_move (HImode, operands); DONE;")
1827
1828 (define_insn "*pushhi2"
1829   [(set (match_operand:HI 0 "push_operand" "=<,<")
1830         (match_operand:HI 1 "general_no_elim_operand" "n,r*m"))]
1831   "!TARGET_64BIT"
1832   "@
1833    push{w}\t{|WORD PTR }%1
1834    push{w}\t%1"
1835   [(set_attr "type" "push")
1836    (set_attr "mode" "HI")])
1837
1838 ;; For 64BIT abi we always round up to 8 bytes.
1839 (define_insn "*pushhi2_rex64"
1840   [(set (match_operand:HI 0 "push_operand" "=X")
1841         (match_operand:HI 1 "nonmemory_no_elim_operand" "ri"))]
1842   "TARGET_64BIT"
1843   "push{q}\t%q1"
1844   [(set_attr "type" "push")
1845    (set_attr "mode" "QI")])
1846
1847 (define_insn "*movhi_1"
1848   [(set (match_operand:HI 0 "nonimmediate_operand" "=*a,r,r,*a,r,m")
1849         (match_operand:HI 1 "general_operand" "i,r,rn,rm,rm,rn"))]
1850   "GET_CODE (operands[0]) != MEM || GET_CODE (operands[1]) != MEM"
1851 {
1852   switch (get_attr_type (insn))
1853     {
1854     case TYPE_IMOVX:
1855       /* movzwl is faster than movw on p2 due to partial word stalls,
1856          though not as fast as an aligned movl.  */
1857       return "movz{wl|x}\t{%1, %k0|%k0, %1}";
1858     default:
1859       if (get_attr_mode (insn) == MODE_SI)
1860         return "mov{l}\t{%k1, %k0|%k0, %k1}";
1861       else
1862         return "mov{w}\t{%1, %0|%0, %1}";
1863     }
1864 }
1865   [(set (attr "type")
1866      (cond [(and (eq_attr "alternative" "0,1")
1867                  (ior (eq (symbol_ref "TARGET_PARTIAL_REG_STALL")
1868                           (const_int 0))
1869                       (eq (symbol_ref "TARGET_HIMODE_MATH")
1870                           (const_int 0))))
1871               (const_string "imov")
1872             (and (eq_attr "alternative" "2,3,4")
1873                  (match_operand:HI 1 "aligned_operand" ""))
1874               (const_string "imov")
1875             (and (ne (symbol_ref "TARGET_MOVX")
1876                      (const_int 0))
1877                  (eq_attr "alternative" "0,1,3,4"))
1878               (const_string "imovx")
1879            ]
1880            (const_string "imov")))
1881     (set (attr "mode")
1882       (cond [(eq_attr "type" "imovx")
1883                (const_string "SI")
1884              (and (eq_attr "alternative" "2,3,4")
1885                   (match_operand:HI 1 "aligned_operand" ""))
1886                (const_string "SI")
1887              (and (eq_attr "alternative" "0,1")
1888                   (ior (eq (symbol_ref "TARGET_PARTIAL_REG_STALL")
1889                            (const_int 0))
1890                        (eq (symbol_ref "TARGET_HIMODE_MATH")
1891                            (const_int 0))))
1892                (const_string "SI")
1893             ]
1894             (const_string "HI")))
1895    (set_attr "modrm" "0,*,*,0,*,*")])
1896
1897 ;; Stores and loads of ax to arbitary constant address.
1898 ;; We fake an second form of instruction to force reload to load address
1899 ;; into register when rax is not available
1900 (define_insn "*movabshi_1_rex64"
1901   [(set (mem:HI (match_operand:DI 0 "x86_64_movabs_operand" "i,r,r"))
1902         (match_operand:HI 1 "nonmemory_operand" "a,er,i"))]
1903   "TARGET_64BIT"
1904   "@
1905    movabs{w}\t{%1, %P0|%P0, %1}
1906    mov{w}\t{%1, %a0|%a0, %1}
1907    movabs{w}\t{%1, %a0|%a0, %1}"
1908   [(set_attr "type" "imov")
1909    (set_attr "modrm" "0,*,*")
1910    (set_attr "length_address" "8,0,0")
1911    (set_attr "length_immediate" "0,*,*")
1912    (set_attr "memory" "store")
1913    (set_attr "mode" "HI")])
1914
1915 (define_insn "*movabshi_2_rex64"
1916   [(set (match_operand:HI 0 "register_operand" "=a,r")
1917         (mem:HI (match_operand:DI 1 "x86_64_movabs_operand" "i,r")))]
1918   "TARGET_64BIT"
1919   "@
1920    movabs{w}\t{%P1, %0|%0, %P1}
1921    mov{w}\t{%a1, %0|%0, %a1}"
1922   [(set_attr "type" "imov")
1923    (set_attr "modrm" "0,*")
1924    (set_attr "length_address" "8,0")
1925    (set_attr "length_immediate" "0")
1926    (set_attr "memory" "load")
1927    (set_attr "mode" "HI")])
1928
1929 (define_insn "*swaphi_1"
1930   [(set (match_operand:HI 0 "register_operand" "+r")
1931         (match_operand:HI 1 "register_operand" "+r"))
1932    (set (match_dup 1)
1933         (match_dup 0))]
1934   "TARGET_PARTIAL_REG_STALL"
1935   "xchg{w}\t%1, %0"
1936   [(set_attr "type" "imov")
1937    (set_attr "pent_pair" "np")
1938    (set_attr "mode" "HI")
1939    (set_attr "modrm" "0")
1940    (set_attr "ppro_uops" "few")])
1941
1942 (define_insn "*swaphi_2"
1943   [(set (match_operand:HI 0 "register_operand" "+r")
1944         (match_operand:HI 1 "register_operand" "+r"))
1945    (set (match_dup 1)
1946         (match_dup 0))]
1947   "! TARGET_PARTIAL_REG_STALL"
1948   "xchg{l}\t%k1, %k0"
1949   [(set_attr "type" "imov")
1950    (set_attr "pent_pair" "np")
1951    (set_attr "mode" "SI")
1952    (set_attr "modrm" "0")
1953    (set_attr "ppro_uops" "few")])
1954
1955 (define_expand "movstricthi"
1956   [(set (strict_low_part (match_operand:HI 0 "nonimmediate_operand" ""))
1957         (match_operand:HI 1 "general_operand" ""))]
1958   "! TARGET_PARTIAL_REG_STALL || optimize_size"
1959 {
1960   /* Don't generate memory->memory moves, go through a register */
1961   if (GET_CODE (operands[0]) == MEM && GET_CODE (operands[1]) == MEM)
1962     operands[1] = force_reg (HImode, operands[1]);
1963 })
1964
1965 (define_insn "*movstricthi_1"
1966   [(set (strict_low_part (match_operand:HI 0 "nonimmediate_operand" "+rm,r"))
1967         (match_operand:HI 1 "general_operand" "rn,m"))]
1968   "(! TARGET_PARTIAL_REG_STALL || optimize_size)
1969    && (GET_CODE (operands[0]) != MEM || GET_CODE (operands[1]) != MEM)"
1970   "mov{w}\t{%1, %0|%0, %1}"
1971   [(set_attr "type" "imov")
1972    (set_attr "mode" "HI")])
1973
1974 (define_insn "*movstricthi_xor"
1975   [(set (strict_low_part (match_operand:HI 0 "register_operand" "+r"))
1976         (match_operand:HI 1 "const0_operand" "i"))
1977    (clobber (reg:CC 17))]
1978   "reload_completed
1979    && ((!TARGET_USE_MOV0 && !TARGET_PARTIAL_REG_STALL) || optimize_size)"
1980   "xor{w}\t{%0, %0|%0, %0}"
1981   [(set_attr "type" "alu1")
1982    (set_attr "mode" "HI")
1983    (set_attr "length_immediate" "0")])
1984
1985 (define_expand "movqi"
1986   [(set (match_operand:QI 0 "nonimmediate_operand" "")
1987         (match_operand:QI 1 "general_operand" ""))]
1988   ""
1989   "ix86_expand_move (QImode, operands); DONE;")
1990
1991 ;; emit_push_insn when it calls move_by_pieces requires an insn to
1992 ;; "push a byte".  But actually we use pushw, which has the effect
1993 ;; of rounding the amount pushed up to a halfword.
1994
1995 (define_insn "*pushqi2"
1996   [(set (match_operand:QI 0 "push_operand" "=X,X")
1997         (match_operand:QI 1 "nonmemory_no_elim_operand" "n,r"))]
1998   "!TARGET_64BIT"
1999   "@
2000    push{w}\t{|word ptr }%1
2001    push{w}\t%w1"
2002   [(set_attr "type" "push")
2003    (set_attr "mode" "HI")])
2004
2005 ;; For 64BIT abi we always round up to 8 bytes.
2006 (define_insn "*pushqi2_rex64"
2007   [(set (match_operand:QI 0 "push_operand" "=X")
2008         (match_operand:QI 1 "nonmemory_no_elim_operand" "ri"))]
2009   "TARGET_64BIT"
2010   "push{q}\t%q1"
2011   [(set_attr "type" "push")
2012    (set_attr "mode" "QI")])
2013
2014 ;; Situation is quite tricky about when to choose full sized (SImode) move
2015 ;; over QImode moves.  For Q_REG -> Q_REG move we use full size only for
2016 ;; partial register dependency machines (such as AMD Athlon), where QImode
2017 ;; moves issue extra dependency and for partial register stalls machines
2018 ;; that don't use QImode patterns (and QImode move cause stall on the next
2019 ;; instruction).
2020 ;;
2021 ;; For loads of Q_REG to NONQ_REG we use full sized moves except for partial
2022 ;; register stall machines with, where we use QImode instructions, since
2023 ;; partial register stall can be caused there.  Then we use movzx.
2024 (define_insn "*movqi_1"
2025   [(set (match_operand:QI 0 "nonimmediate_operand" "=q,q ,q ,r,r ,?r,m")
2026         (match_operand:QI 1 "general_operand"      " q,qn,qm,q,rn,qm,qn"))]
2027   "GET_CODE (operands[0]) != MEM || GET_CODE (operands[1]) != MEM"
2028 {
2029   switch (get_attr_type (insn))
2030     {
2031     case TYPE_IMOVX:
2032       if (!ANY_QI_REG_P (operands[1]) && GET_CODE (operands[1]) != MEM)
2033         abort ();
2034       return "movz{bl|x}\t{%1, %k0|%k0, %1}";
2035     default:
2036       if (get_attr_mode (insn) == MODE_SI)
2037         return "mov{l}\t{%k1, %k0|%k0, %k1}";
2038       else
2039         return "mov{b}\t{%1, %0|%0, %1}";
2040     }
2041 }
2042   [(set (attr "type")
2043      (cond [(and (eq_attr "alternative" "3")
2044                  (ior (eq (symbol_ref "TARGET_PARTIAL_REG_STALL")
2045                           (const_int 0))
2046                       (eq (symbol_ref "TARGET_QIMODE_MATH")
2047                           (const_int 0))))
2048               (const_string "imov")
2049             (eq_attr "alternative" "3,5")
2050               (const_string "imovx")
2051             (and (ne (symbol_ref "TARGET_MOVX")
2052                      (const_int 0))
2053                  (eq_attr "alternative" "2"))
2054               (const_string "imovx")
2055            ]
2056            (const_string "imov")))
2057    (set (attr "mode")
2058       (cond [(eq_attr "alternative" "3,4,5")
2059                (const_string "SI")
2060              (eq_attr "alternative" "6")
2061                (const_string "QI")
2062              (eq_attr "type" "imovx")
2063                (const_string "SI")
2064              (and (eq_attr "type" "imov")
2065                   (and (eq_attr "alternative" "0,1,2")
2066                        (ne (symbol_ref "TARGET_PARTIAL_REG_DEPENDENCY")
2067                            (const_int 0))))
2068                (const_string "SI")
2069              ;; Avoid partial register stalls when not using QImode arithmetic
2070              (and (eq_attr "type" "imov")
2071                   (and (eq_attr "alternative" "0,1,2")
2072                        (and (ne (symbol_ref "TARGET_PARTIAL_REG_STALL")
2073                                 (const_int 0))
2074                             (eq (symbol_ref "TARGET_QIMODE_MATH")
2075                                 (const_int 0)))))
2076                (const_string "SI")
2077            ]
2078            (const_string "QI")))])
2079
2080 (define_expand "reload_outqi"
2081   [(parallel [(match_operand:QI 0 "" "=m")
2082               (match_operand:QI 1 "register_operand" "r")
2083               (match_operand:QI 2 "register_operand" "=&q")])]
2084   ""
2085 {
2086   rtx op0, op1, op2;
2087   op0 = operands[0]; op1 = operands[1]; op2 = operands[2];
2088
2089   if (reg_overlap_mentioned_p (op2, op0))
2090     abort ();
2091   if (! q_regs_operand (op1, QImode))
2092     {
2093       emit_insn (gen_movqi (op2, op1));
2094       op1 = op2;
2095     }
2096   emit_insn (gen_movqi (op0, op1));
2097   DONE;
2098 })
2099
2100 (define_insn "*swapqi"
2101   [(set (match_operand:QI 0 "register_operand" "+r")
2102         (match_operand:QI 1 "register_operand" "+r"))
2103    (set (match_dup 1)
2104         (match_dup 0))]
2105   ""
2106   "xchg{b}\t%1, %0"
2107   [(set_attr "type" "imov")
2108    (set_attr "pent_pair" "np")
2109    (set_attr "mode" "QI")
2110    (set_attr "modrm" "0")
2111    (set_attr "ppro_uops" "few")])
2112
2113 (define_expand "movstrictqi"
2114   [(set (strict_low_part (match_operand:QI 0 "nonimmediate_operand" ""))
2115         (match_operand:QI 1 "general_operand" ""))]
2116   "! TARGET_PARTIAL_REG_STALL"
2117 {
2118   /* Don't generate memory->memory moves, go through a register */
2119   if (GET_CODE (operands[0]) == MEM && GET_CODE (operands[1]) == MEM)
2120     operands[1] = force_reg (QImode, operands[1]);
2121 })
2122
2123 (define_insn "*movstrictqi_1"
2124   [(set (strict_low_part (match_operand:QI 0 "nonimmediate_operand" "+qm,q"))
2125         (match_operand:QI 1 "general_operand" "*qn,m"))]
2126   "! TARGET_PARTIAL_REG_STALL
2127    && (GET_CODE (operands[0]) != MEM || GET_CODE (operands[1]) != MEM)"
2128   "mov{b}\t{%1, %0|%0, %1}"
2129   [(set_attr "type" "imov")
2130    (set_attr "mode" "QI")])
2131
2132 (define_insn "*movstrictqi_xor"
2133   [(set (strict_low_part (match_operand:QI 0 "q_regs_operand" "+q"))
2134         (match_operand:QI 1 "const0_operand" "i"))
2135    (clobber (reg:CC 17))]
2136   "reload_completed && (!TARGET_USE_MOV0 || optimize_size)"
2137   "xor{b}\t{%0, %0|%0, %0}"
2138   [(set_attr "type" "alu1")
2139    (set_attr "mode" "QI")
2140    (set_attr "length_immediate" "0")])
2141
2142 (define_insn "*movsi_extv_1"
2143   [(set (match_operand:SI 0 "register_operand" "=R")
2144         (sign_extract:SI (match_operand 1 "ext_register_operand" "Q")
2145                          (const_int 8)
2146                          (const_int 8)))]
2147   ""
2148   "movs{bl|x}\t{%h1, %0|%0, %h1}"
2149   [(set_attr "type" "imovx")
2150    (set_attr "mode" "SI")])
2151
2152 (define_insn "*movhi_extv_1"
2153   [(set (match_operand:HI 0 "register_operand" "=R")
2154         (sign_extract:HI (match_operand 1 "ext_register_operand" "Q")
2155                          (const_int 8)
2156                          (const_int 8)))]
2157   ""
2158   "movs{bl|x}\t{%h1, %k0|%k0, %h1}"
2159   [(set_attr "type" "imovx")
2160    (set_attr "mode" "SI")])
2161
2162 (define_insn "*movqi_extv_1"
2163   [(set (match_operand:QI 0 "nonimmediate_operand" "=Qm,?r")
2164         (sign_extract:QI (match_operand 1 "ext_register_operand" "Q,Q")
2165                          (const_int 8)
2166                          (const_int 8)))]
2167   "!TARGET_64BIT"
2168 {
2169   switch (get_attr_type (insn))
2170     {
2171     case TYPE_IMOVX:
2172       return "movs{bl|x}\t{%h1, %k0|%k0, %h1}";
2173     default:
2174       return "mov{b}\t{%h1, %0|%0, %h1}";
2175     }
2176 }
2177   [(set (attr "type")
2178      (if_then_else (and (match_operand:QI 0 "register_operand" "")
2179                         (ior (not (match_operand:QI 0 "q_regs_operand" ""))
2180                              (ne (symbol_ref "TARGET_MOVX")
2181                                  (const_int 0))))
2182         (const_string "imovx")
2183         (const_string "imov")))
2184    (set (attr "mode")
2185      (if_then_else (eq_attr "type" "imovx")
2186         (const_string "SI")
2187         (const_string "QI")))])
2188
2189 (define_insn "*movqi_extv_1_rex64"
2190   [(set (match_operand:QI 0 "register_operand" "=Q,?R")
2191         (sign_extract:QI (match_operand 1 "ext_register_operand" "Q,Q")
2192                          (const_int 8)
2193                          (const_int 8)))]
2194   "TARGET_64BIT"
2195 {
2196   switch (get_attr_type (insn))
2197     {
2198     case TYPE_IMOVX:
2199       return "movs{bl|x}\t{%h1, %k0|%k0, %h1}";
2200     default:
2201       return "mov{b}\t{%h1, %0|%0, %h1}";
2202     }
2203 }
2204   [(set (attr "type")
2205      (if_then_else (and (match_operand:QI 0 "register_operand" "")
2206                         (ior (not (match_operand:QI 0 "q_regs_operand" ""))
2207                              (ne (symbol_ref "TARGET_MOVX")
2208                                  (const_int 0))))
2209         (const_string "imovx")
2210         (const_string "imov")))
2211    (set (attr "mode")
2212      (if_then_else (eq_attr "type" "imovx")
2213         (const_string "SI")
2214         (const_string "QI")))])
2215
2216 ;; Stores and loads of ax to arbitary constant address.
2217 ;; We fake an second form of instruction to force reload to load address
2218 ;; into register when rax is not available
2219 (define_insn "*movabsqi_1_rex64"
2220   [(set (mem:QI (match_operand:DI 0 "x86_64_movabs_operand" "i,r,r"))
2221         (match_operand:QI 1 "nonmemory_operand" "a,er,i"))]
2222   "TARGET_64BIT"
2223   "@
2224    movabs{q}\t{%1, %P0|%P0, %1}
2225    mov{q}\t{%1, %a0|%a0, %1}
2226    movabs{q}\t{%1, %a0|%a0, %1}"
2227   [(set_attr "type" "imov")
2228    (set_attr "modrm" "0,*,*")
2229    (set_attr "length_address" "8,0,0")
2230    (set_attr "length_immediate" "0,*,*")
2231    (set_attr "memory" "store")
2232    (set_attr "mode" "QI")])
2233
2234 (define_insn "*movabsqi_2_rex64"
2235   [(set (match_operand:QI 0 "register_operand" "=a,r")
2236         (mem:QI (match_operand:DI 1 "x86_64_movabs_operand" "i,r")))]
2237   "TARGET_64BIT"
2238   "@
2239    movabs{q}\t{%P1, %0|%0, %P1}
2240    mov{q}\t{%a1, %0|%0, %a1}"
2241   [(set_attr "type" "imov")
2242    (set_attr "modrm" "0,*")
2243    (set_attr "length_address" "8,0")
2244    (set_attr "length_immediate" "0")
2245    (set_attr "memory" "load")
2246    (set_attr "mode" "QI")])
2247
2248 (define_insn "*movsi_extzv_1"
2249   [(set (match_operand:SI 0 "register_operand" "=R")
2250         (zero_extract:SI (match_operand 1 "ext_register_operand" "Q")
2251                          (const_int 8)
2252                          (const_int 8)))]
2253   ""
2254   "movz{bl|x}\t{%h1, %0|%0, %h1}"
2255   [(set_attr "type" "imovx")
2256    (set_attr "mode" "SI")])
2257
2258 (define_insn "*movqi_extzv_2"
2259   [(set (match_operand:QI 0 "nonimmediate_operand" "=Qm,?R")
2260         (subreg:QI (zero_extract:SI (match_operand 1 "ext_register_operand" "Q,Q")
2261                                     (const_int 8)
2262                                     (const_int 8)) 0))]
2263   "!TARGET_64BIT"
2264 {
2265   switch (get_attr_type (insn))
2266     {
2267     case TYPE_IMOVX:
2268       return "movz{bl|x}\t{%h1, %k0|%k0, %h1}";
2269     default:
2270       return "mov{b}\t{%h1, %0|%0, %h1}";
2271     }
2272 }
2273   [(set (attr "type")
2274      (if_then_else (and (match_operand:QI 0 "register_operand" "")
2275                         (ior (not (match_operand:QI 0 "q_regs_operand" ""))
2276                              (ne (symbol_ref "TARGET_MOVX")
2277                                  (const_int 0))))
2278         (const_string "imovx")
2279         (const_string "imov")))
2280    (set (attr "mode")
2281      (if_then_else (eq_attr "type" "imovx")
2282         (const_string "SI")
2283         (const_string "QI")))])
2284
2285 (define_insn "*movqi_extzv_2_rex64"
2286   [(set (match_operand:QI 0 "register_operand" "=Q,?R")
2287         (subreg:QI (zero_extract:SI (match_operand 1 "ext_register_operand" "Q,Q")
2288                                     (const_int 8)
2289                                     (const_int 8)) 0))]
2290   "TARGET_64BIT"
2291 {
2292   switch (get_attr_type (insn))
2293     {
2294     case TYPE_IMOVX:
2295       return "movz{bl|x}\t{%h1, %k0|%k0, %h1}";
2296     default:
2297       return "mov{b}\t{%h1, %0|%0, %h1}";
2298     }
2299 }
2300   [(set (attr "type")
2301      (if_then_else (ior (not (match_operand:QI 0 "q_regs_operand" ""))
2302                         (ne (symbol_ref "TARGET_MOVX")
2303                             (const_int 0)))
2304         (const_string "imovx")
2305         (const_string "imov")))
2306    (set (attr "mode")
2307      (if_then_else (eq_attr "type" "imovx")
2308         (const_string "SI")
2309         (const_string "QI")))])
2310
2311 (define_insn "movsi_insv_1"
2312   [(set (zero_extract:SI (match_operand 0 "ext_register_operand" "+Q")
2313                          (const_int 8)
2314                          (const_int 8))
2315         (match_operand:SI 1 "general_operand" "Qmn"))]
2316   "!TARGET_64BIT"
2317   "mov{b}\t{%b1, %h0|%h0, %b1}"
2318   [(set_attr "type" "imov")
2319    (set_attr "mode" "QI")])
2320
2321 (define_insn "*movsi_insv_1_rex64"
2322   [(set (zero_extract:SI (match_operand 0 "ext_register_operand" "+Q")
2323                          (const_int 8)
2324                          (const_int 8))
2325         (match_operand:SI 1 "nonmemory_operand" "Qn"))]
2326   "TARGET_64BIT"
2327   "mov{b}\t{%b1, %h0|%h0, %b1}"
2328   [(set_attr "type" "imov")
2329    (set_attr "mode" "QI")])
2330
2331 (define_insn "*movqi_insv_2"
2332   [(set (zero_extract:SI (match_operand 0 "ext_register_operand" "+Q")
2333                          (const_int 8)
2334                          (const_int 8))
2335         (and:SI (lshiftrt:SI (match_operand:SI 1 "register_operand" "Q")
2336                              (const_int 8))
2337                 (const_int 255)))]
2338   ""
2339   "mov{b}\t{%h1, %h0|%h0, %h1}"
2340   [(set_attr "type" "imov")
2341    (set_attr "mode" "QI")])
2342
2343 (define_expand "movdi"
2344   [(set (match_operand:DI 0 "nonimmediate_operand" "")
2345         (match_operand:DI 1 "general_operand" ""))]
2346   ""
2347   "ix86_expand_move (DImode, operands); DONE;")
2348
2349 (define_insn "*pushdi"
2350   [(set (match_operand:DI 0 "push_operand" "=<")
2351         (match_operand:DI 1 "general_no_elim_operand" "riF*m"))]
2352   "!TARGET_64BIT"
2353   "#")
2354
2355 (define_insn "pushdi2_rex64"
2356   [(set (match_operand:DI 0 "push_operand" "=<,!<")
2357         (match_operand:DI 1 "general_no_elim_operand" "re*m,n"))]
2358   "TARGET_64BIT"
2359   "@
2360    push{q}\t%1
2361    #"
2362   [(set_attr "type" "push,multi")
2363    (set_attr "mode" "DI")])
2364
2365 ;; Convert impossible pushes of immediate to existing instructions.
2366 ;; First try to get scratch register and go through it.  In case this
2367 ;; fails, push sign extended lower part first and then overwrite
2368 ;; upper part by 32bit move.
2369 (define_peephole2
2370   [(match_scratch:DI 2 "r")
2371    (set (match_operand:DI 0 "push_operand" "")
2372         (match_operand:DI 1 "immediate_operand" ""))]
2373   "TARGET_64BIT && !symbolic_operand (operands[1], DImode)
2374    && !x86_64_immediate_operand (operands[1], DImode)"
2375   [(set (match_dup 2) (match_dup 1))
2376    (set (match_dup 0) (match_dup 2))]
2377   "")
2378
2379 ;; We need to define this as both peepholer and splitter for case
2380 ;; peephole2 pass is not run.
2381 (define_peephole2
2382   [(set (match_operand:DI 0 "push_operand" "")
2383         (match_operand:DI 1 "immediate_operand" ""))]
2384   "TARGET_64BIT && !symbolic_operand (operands[1], DImode)
2385    && !x86_64_immediate_operand (operands[1], DImode) && 1"
2386   [(set (match_dup 0) (match_dup 1))
2387    (set (match_dup 2) (match_dup 3))]
2388   "split_di (operands + 1, 1, operands + 2, operands + 3);
2389    operands[1] = gen_lowpart (DImode, operands[2]);
2390    operands[2] = gen_rtx_MEM (SImode, gen_rtx_PLUS (DImode, stack_pointer_rtx,
2391                                                     GEN_INT (4)));
2392   ")
2393
2394 (define_split
2395   [(set (match_operand:DI 0 "push_operand" "")
2396         (match_operand:DI 1 "immediate_operand" ""))]
2397   "TARGET_64BIT && (flow2_completed || (reload_completed && !flag_peephole2))
2398    && !symbolic_operand (operands[1], DImode)
2399    && !x86_64_immediate_operand (operands[1], DImode)"
2400   [(set (match_dup 0) (match_dup 1))
2401    (set (match_dup 2) (match_dup 3))]
2402   "split_di (operands + 1, 1, operands + 2, operands + 3);
2403    operands[1] = gen_lowpart (DImode, operands[2]);
2404    operands[2] = gen_rtx_MEM (SImode, gen_rtx_PLUS (DImode, stack_pointer_rtx,
2405                                                     GEN_INT (4)));
2406   ")
2407
2408 (define_insn "*pushdi2_prologue_rex64"
2409   [(set (match_operand:DI 0 "push_operand" "=<")
2410         (match_operand:DI 1 "general_no_elim_operand" "re*m"))
2411    (clobber (mem:BLK (scratch)))]
2412   "TARGET_64BIT"
2413   "push{q}\t%1"
2414   [(set_attr "type" "push")
2415    (set_attr "mode" "DI")])
2416
2417 (define_insn "*popdi1_epilogue_rex64"
2418   [(set (match_operand:DI 0 "nonimmediate_operand" "=r*m")
2419         (mem:DI (reg:DI 7)))
2420    (set (reg:DI 7)
2421         (plus:DI (reg:DI 7) (const_int 8)))
2422    (clobber (mem:BLK (scratch)))]
2423   "TARGET_64BIT"
2424   "pop{q}\t%0"
2425   [(set_attr "type" "pop")
2426    (set_attr "mode" "DI")])
2427
2428 (define_insn "popdi1"
2429   [(set (match_operand:DI 0 "nonimmediate_operand" "=r*m")
2430         (mem:DI (reg:DI 7)))
2431    (set (reg:DI 7)
2432         (plus:DI (reg:DI 7) (const_int 8)))]
2433   "TARGET_64BIT"
2434   "pop{q}\t%0"
2435   [(set_attr "type" "pop")
2436    (set_attr "mode" "DI")])
2437
2438 (define_insn "*movdi_xor_rex64"
2439   [(set (match_operand:DI 0 "register_operand" "=r")
2440         (match_operand:DI 1 "const0_operand" "i"))
2441    (clobber (reg:CC 17))]
2442   "TARGET_64BIT && (!TARGET_USE_MOV0 || optimize_size)
2443    && reload_completed"
2444   "xor{l}\t{%k0, %k0|%k0, %k0}"
2445   [(set_attr "type" "alu1")
2446    (set_attr "mode" "SI")
2447    (set_attr "length_immediate" "0")])
2448
2449 (define_insn "*movdi_or_rex64"
2450   [(set (match_operand:DI 0 "register_operand" "=r")
2451         (match_operand:DI 1 "const_int_operand" "i"))
2452    (clobber (reg:CC 17))]
2453   "TARGET_64BIT && (TARGET_PENTIUM || optimize_size)
2454    && reload_completed
2455    && GET_CODE (operands[1]) == CONST_INT
2456    && INTVAL (operands[1]) == -1"
2457 {
2458   operands[1] = constm1_rtx;
2459   return "or{q}\t{%1, %0|%0, %1}";
2460 }
2461   [(set_attr "type" "alu1")
2462    (set_attr "mode" "DI")
2463    (set_attr "length_immediate" "1")])
2464
2465 (define_insn "*movdi_2"
2466   [(set (match_operand:DI 0 "nonimmediate_operand" "=r,o,!m*y,!*y,!m,*Y,!*Y")
2467         (match_operand:DI 1 "general_operand" "riFo,riF,*y,m,*Y,*Y,m"))]
2468   "!TARGET_64BIT
2469    && (GET_CODE (operands[0]) != MEM || GET_CODE (operands[1]) != MEM)"
2470   "@
2471    #
2472    #
2473    movq\t{%1, %0|%0, %1}
2474    movq\t{%1, %0|%0, %1}
2475    movq\t{%1, %0|%0, %1}
2476    movdqa\t{%1, %0|%0, %1}
2477    movq\t{%1, %0|%0, %1}"
2478   [(set_attr "type" "*,*,mmx,mmx,sse,sse,sse")
2479    (set_attr "mode" "DI,DI,DI,DI,DI,TI,DI")])
2480
2481 (define_split
2482   [(set (match_operand:DI 0 "push_operand" "")
2483         (match_operand:DI 1 "general_operand" ""))]
2484   "!TARGET_64BIT && reload_completed
2485    && (! MMX_REG_P (operands[1]) && !SSE_REG_P (operands[1]))"
2486   [(const_int 0)]
2487   "ix86_split_long_move (operands); DONE;")
2488
2489 ;; %%% This multiword shite has got to go.
2490 (define_split
2491   [(set (match_operand:DI 0 "nonimmediate_operand" "")
2492         (match_operand:DI 1 "general_operand" ""))]
2493   "!TARGET_64BIT && reload_completed
2494    && (!MMX_REG_P (operands[0]) && !SSE_REG_P (operands[0]))
2495    && (!MMX_REG_P (operands[1]) && !SSE_REG_P (operands[1]))"
2496   [(const_int 0)]
2497   "ix86_split_long_move (operands); DONE;")
2498
2499 (define_insn "*movdi_1_rex64"
2500   [(set (match_operand:DI 0 "nonimmediate_operand" "=r,r,r,mr,!mr,!m*y,!*y,!*Y,!m,!*Y")
2501         (match_operand:DI 1 "general_operand" "Z,rem,i,re,n,*y,m,*Y,*Y,*m"))]
2502   "TARGET_64BIT
2503    && (GET_CODE (operands[0]) != MEM || GET_CODE (operands[1]) != MEM)"
2504 {
2505   switch (get_attr_type (insn))
2506     {
2507     case TYPE_SSE:
2508       if (register_operand (operands[0], DImode)
2509           && register_operand (operands[1], DImode))
2510           return "movdqa\t{%1, %0|%0, %1}";
2511       /* FALLTHRU */
2512     case TYPE_MMX:
2513       return "movq\t{%1, %0|%0, %1}";
2514     case TYPE_MULTI:
2515       return "#";
2516     case TYPE_LEA:
2517       return "lea{q}\t{%a1, %0|%0, %a1}";
2518     default:
2519       if (flag_pic && SYMBOLIC_CONST (operands[1]))
2520         abort ();
2521       if (get_attr_mode (insn) == MODE_SI)
2522         return "mov{l}\t{%k1, %k0|%k0, %k1}";
2523       else if (which_alternative == 2)
2524         return "movabs{q}\t{%1, %0|%0, %1}";
2525       else
2526         return "mov{q}\t{%1, %0|%0, %1}";
2527     }
2528 }
2529   [(set (attr "type")
2530      (cond [(eq_attr "alternative" "5,6")
2531               (const_string "mmx")
2532             (eq_attr "alternative" "7,8")
2533               (const_string "sse")
2534             (eq_attr "alternative" "4")
2535               (const_string "multi")
2536             (and (ne (symbol_ref "flag_pic") (const_int 0))
2537                  (match_operand:DI 1 "symbolic_operand" ""))
2538               (const_string "lea")
2539            ]
2540            (const_string "imov")))
2541    (set_attr "modrm" "*,0,0,*,*,*,*,*,*,*")
2542    (set_attr "length_immediate" "*,4,8,*,*,*,*,*,*,*")
2543    (set_attr "mode" "SI,DI,DI,DI,SI,DI,DI,DI,TI,DI")])
2544
2545 ;; Stores and loads of ax to arbitary constant address.
2546 ;; We fake an second form of instruction to force reload to load address
2547 ;; into register when rax is not available
2548 (define_insn "*movabsdi_1_rex64"
2549   [(set (mem:DI (match_operand:DI 0 "x86_64_movabs_operand" "i,r,r"))
2550         (match_operand:DI 1 "nonmemory_operand" "a,er,i"))]
2551   "TARGET_64BIT"
2552   "@
2553    movabs{q}\t{%1, %P0|%P0, %1}
2554    mov{q}\t{%1, %a0|%a0, %1}
2555    movabs{q}\t{%1, %a0|%a0, %1}"
2556   [(set_attr "type" "imov")
2557    (set_attr "modrm" "0,*,*")
2558    (set_attr "length_address" "8,0,0")
2559    (set_attr "length_immediate" "0,*,*")
2560    (set_attr "memory" "store")
2561    (set_attr "mode" "DI")])
2562
2563 (define_insn "*movabsdi_2_rex64"
2564   [(set (match_operand:DI 0 "register_operand" "=a,r")
2565         (mem:DI (match_operand:DI 1 "x86_64_movabs_operand" "i,r")))]
2566   "TARGET_64BIT"
2567   "@
2568    movabs{q}\t{%P1, %0|%0, %P1}
2569    mov{q}\t{%a1, %0|%0, %a1}"
2570   [(set_attr "type" "imov")
2571    (set_attr "modrm" "0,*")
2572    (set_attr "length_address" "8,0")
2573    (set_attr "length_immediate" "0")
2574    (set_attr "memory" "load")
2575    (set_attr "mode" "DI")])
2576
2577 ;; Convert impossible stores of immediate to existing instructions.
2578 ;; First try to get scratch register and go through it.  In case this
2579 ;; fails, move by 32bit parts.
2580 (define_peephole2
2581   [(match_scratch:DI 2 "r")
2582    (set (match_operand:DI 0 "memory_operand" "")
2583         (match_operand:DI 1 "immediate_operand" ""))]
2584   "TARGET_64BIT && !symbolic_operand (operands[1], DImode)
2585    && !x86_64_immediate_operand (operands[1], DImode)"
2586   [(set (match_dup 2) (match_dup 1))
2587    (set (match_dup 0) (match_dup 2))]
2588   "")
2589
2590 ;; We need to define this as both peepholer and splitter for case
2591 ;; peephole2 pass is not run.
2592 (define_peephole2
2593   [(set (match_operand:DI 0 "memory_operand" "")
2594         (match_operand:DI 1 "immediate_operand" ""))]
2595   "TARGET_64BIT && !symbolic_operand (operands[1], DImode)
2596    && !x86_64_immediate_operand (operands[1], DImode) && 1"
2597   [(set (match_dup 2) (match_dup 3))
2598    (set (match_dup 4) (match_dup 5))]
2599   "split_di (operands, 2, operands + 2, operands + 4);")
2600
2601 (define_split
2602   [(set (match_operand:DI 0 "memory_operand" "")
2603         (match_operand:DI 1 "immediate_operand" ""))]
2604   "TARGET_64BIT && (flow2_completed || (reload_completed && !flag_peephole2))
2605    && !symbolic_operand (operands[1], DImode)
2606    && !x86_64_immediate_operand (operands[1], DImode)"
2607   [(set (match_dup 2) (match_dup 3))
2608    (set (match_dup 4) (match_dup 5))]
2609   "split_di (operands, 2, operands + 2, operands + 4);")
2610
2611 (define_insn "*swapdi_rex64"
2612   [(set (match_operand:DI 0 "register_operand" "+r")
2613         (match_operand:DI 1 "register_operand" "+r"))
2614    (set (match_dup 1)
2615         (match_dup 0))]
2616   "TARGET_64BIT"
2617   "xchg{q}\t%1, %0"
2618   [(set_attr "type" "imov")
2619    (set_attr "pent_pair" "np")
2620    (set_attr "athlon_decode" "vector")
2621    (set_attr "mode" "DI")
2622    (set_attr "modrm" "0")
2623    (set_attr "ppro_uops" "few")])
2624
2625   
2626 (define_expand "movsf"
2627   [(set (match_operand:SF 0 "nonimmediate_operand" "")
2628         (match_operand:SF 1 "general_operand" ""))]
2629   ""
2630   "ix86_expand_move (SFmode, operands); DONE;")
2631
2632 (define_insn "*pushsf"
2633   [(set (match_operand:SF 0 "push_operand" "=<,<,<")
2634         (match_operand:SF 1 "general_no_elim_operand" "f#rx,rFm#fx,x#rf"))]
2635   "!TARGET_64BIT"
2636 {
2637   switch (which_alternative)
2638     {
2639     case 0:
2640       /* %%% We loose REG_DEAD notes for controling pops if we split late.  */
2641       operands[0] = gen_rtx_MEM (SFmode, stack_pointer_rtx);
2642       operands[2] = stack_pointer_rtx;
2643       operands[3] = GEN_INT (4);
2644       if (find_regno_note (insn, REG_DEAD, REGNO (operands[1])))
2645         return "sub{l}\t{%3, %2|%2, %3}\;fstp%z0\t%y0";
2646       else
2647         return "sub{l}\t{%3, %2|%2, %3}\;fst%z0\t%y0";
2648
2649     case 1:
2650       return "push{l}\t%1";
2651     case 2:
2652       return "#";
2653
2654     default:
2655       abort ();
2656     }
2657 }
2658   [(set_attr "type" "multi,push,multi")
2659    (set_attr "mode" "SF,SI,SF")])
2660
2661 (define_insn "*pushsf_rex64"
2662   [(set (match_operand:SF 0 "push_operand" "=X,X,X")
2663         (match_operand:SF 1 "nonmemory_no_elim_operand" "f#rx,rF#fx,x#rf"))]
2664   "TARGET_64BIT"
2665 {
2666   switch (which_alternative)
2667     {
2668     case 0:
2669       /* %%% We loose REG_DEAD notes for controling pops if we split late.  */
2670       operands[0] = gen_rtx_MEM (SFmode, stack_pointer_rtx);
2671       operands[2] = stack_pointer_rtx;
2672       operands[3] = GEN_INT (8);
2673       if (find_regno_note (insn, REG_DEAD, REGNO (operands[1])))
2674         return "sub{q}\t{%3, %2|%2, %3}\;fstp%z0\t%y0";
2675       else
2676         return "sub{q}\t{%3, %2|%2, %3}\;fst%z0\t%y0";
2677
2678     case 1:
2679       return "push{q}\t%q1";
2680
2681     case 2:
2682       return "#";
2683
2684     default:
2685       abort ();
2686     }
2687 }
2688   [(set_attr "type" "multi,push,multi")
2689    (set_attr "mode" "SF,DI,SF")])
2690
2691 (define_split
2692   [(set (match_operand:SF 0 "push_operand" "")
2693         (match_operand:SF 1 "memory_operand" ""))]
2694   "reload_completed
2695    && GET_CODE (operands[1]) == MEM
2696    && GET_CODE (XEXP (operands[1], 0)) == SYMBOL_REF
2697    && CONSTANT_POOL_ADDRESS_P (XEXP (operands[1], 0))"
2698   [(set (match_dup 0)
2699         (match_dup 1))]
2700   "operands[1] = get_pool_constant (XEXP (operands[1], 0));")
2701
2702
2703 ;; %%% Kill this when call knows how to work this out.
2704 (define_split
2705   [(set (match_operand:SF 0 "push_operand" "")
2706         (match_operand:SF 1 "register_operand" ""))]
2707   "!TARGET_64BIT && ANY_FP_REGNO_P (REGNO (operands[1]))"
2708   [(set (reg:SI 7) (plus:SI (reg:SI 7) (const_int -4)))
2709    (set (mem:SF (reg:SI 7)) (match_dup 1))])
2710
2711 (define_split
2712   [(set (match_operand:SF 0 "push_operand" "")
2713         (match_operand:SF 1 "register_operand" ""))]
2714   "TARGET_64BIT && ANY_FP_REGNO_P (REGNO (operands[1]))"
2715   [(set (reg:DI 7) (plus:DI (reg:DI 7) (const_int -8)))
2716    (set (mem:SF (reg:DI 7)) (match_dup 1))])
2717
2718 (define_insn "*movsf_1"
2719   [(set (match_operand:SF 0 "nonimmediate_operand" "=f#xr,m,f#xr,r#xf,m,x#rf,x#rf,x#rf,m")
2720         (match_operand:SF 1 "general_operand" "fm#rx,f#rx,G,rmF#fx,Fr#fx,H,x,xm#rf,x#rf"))]
2721   "(GET_CODE (operands[0]) != MEM || GET_CODE (operands[1]) != MEM)
2722    && (reload_in_progress || reload_completed
2723        || GET_CODE (operands[1]) != CONST_DOUBLE
2724        || memory_operand (operands[0], SFmode))" 
2725 {
2726   switch (which_alternative)
2727     {
2728     case 0:
2729       if (REG_P (operands[1])
2730           && find_regno_note (insn, REG_DEAD, REGNO (operands[1])))
2731         return "fstp\t%y0";
2732       else if (STACK_TOP_P (operands[0]))
2733         return "fld%z1\t%y1";
2734       else
2735         return "fst\t%y0";
2736
2737     case 1:
2738       if (find_regno_note (insn, REG_DEAD, REGNO (operands[1])))
2739         return "fstp%z0\t%y0";
2740       else
2741         return "fst%z0\t%y0";
2742
2743     case 2:
2744       switch (standard_80387_constant_p (operands[1]))
2745         {
2746         case 1:
2747           return "fldz";
2748         case 2:
2749           return "fld1";
2750         }
2751       abort();
2752
2753     case 3:
2754     case 4:
2755       return "mov{l}\t{%1, %0|%0, %1}";
2756     case 5:
2757       return "pxor\t%0, %0";
2758     case 6:
2759       if (TARGET_PARTIAL_REG_DEPENDENCY)
2760         return "movaps\t{%1, %0|%0, %1}";
2761       else
2762         return "movss\t{%1, %0|%0, %1}";
2763     case 7:
2764     case 8:
2765       return "movss\t{%1, %0|%0, %1}";
2766
2767     default:
2768       abort();
2769     }
2770 }
2771   [(set_attr "type" "fmov,fmov,fmov,imov,imov,sse,sse,sse,sse")
2772    (set_attr "mode" "SF,SF,SF,SI,SI,TI,SF,SF,SF")])
2773
2774 (define_insn "*swapsf"
2775   [(set (match_operand:SF 0 "register_operand" "+f")
2776         (match_operand:SF 1 "register_operand" "+f"))
2777    (set (match_dup 1)
2778         (match_dup 0))]
2779   "reload_completed || !TARGET_SSE2"
2780 {
2781   if (STACK_TOP_P (operands[0]))
2782     return "fxch\t%1";
2783   else
2784     return "fxch\t%0";
2785 }
2786   [(set_attr "type" "fxch")
2787    (set_attr "mode" "SF")])
2788
2789 (define_expand "movdf"
2790   [(set (match_operand:DF 0 "nonimmediate_operand" "")
2791         (match_operand:DF 1 "general_operand" ""))]
2792   ""
2793   "ix86_expand_move (DFmode, operands); DONE;")
2794
2795 ;; Size of pushdf is 3 (for sub) + 2 (for fstp) + memory operand size.
2796 ;; Size of pushdf using integer insturctions is 2+2*memory operand size
2797 ;; On the average, pushdf using integers can be still shorter.  Allow this
2798 ;; pattern for optimize_size too.
2799
2800 (define_insn "*pushdf_nointeger"
2801   [(set (match_operand:DF 0 "push_operand" "=<,<,<,<")
2802         (match_operand:DF 1 "general_no_elim_operand" "f#Y,Fo#fY,*r#fY,Y#f"))]
2803   "!TARGET_64BIT && !TARGET_INTEGER_DFMODE_MOVES"
2804 {
2805   switch (which_alternative)
2806     {
2807     case 0:
2808       /* %%% We loose REG_DEAD notes for controling pops if we split late.  */
2809       operands[0] = gen_rtx_MEM (DFmode, stack_pointer_rtx);
2810       operands[2] = stack_pointer_rtx;
2811       operands[3] = GEN_INT (8);
2812       if (find_regno_note (insn, REG_DEAD, REGNO (operands[1])))
2813         return "sub{l}\t{%3, %2|%2, %3}\;fstp%z0\t%y0";
2814       else
2815         return "sub{l}\t{%3, %2|%2, %3}\;fst%z0\t%y0";
2816
2817     case 1:
2818     case 2:
2819     case 3:
2820       return "#";
2821
2822     default:
2823       abort ();
2824     }
2825 }
2826   [(set_attr "type" "multi")
2827    (set_attr "mode" "DF,SI,SI,DF")])
2828
2829 (define_insn "*pushdf_integer"
2830   [(set (match_operand:DF 0 "push_operand" "=<,<,<")
2831         (match_operand:DF 1 "general_no_elim_operand" "f#rY,rFo#fY,Y#rf"))]
2832   "TARGET_64BIT || TARGET_INTEGER_DFMODE_MOVES"
2833 {
2834   switch (which_alternative)
2835     {
2836     case 0:
2837       /* %%% We loose REG_DEAD notes for controling pops if we split late.  */
2838       operands[0] = gen_rtx_MEM (DFmode, stack_pointer_rtx);
2839       operands[2] = stack_pointer_rtx;
2840       operands[3] = GEN_INT (8);
2841       if (TARGET_64BIT)
2842         if (find_regno_note (insn, REG_DEAD, REGNO (operands[1])))
2843           return "sub{q}\t{%3, %2|%2, %3}\;fstp%z0\t%y0";
2844         else
2845           return "sub{q}\t{%3, %2|%2, %3}\;fst%z0\t%y0";
2846       else
2847         if (find_regno_note (insn, REG_DEAD, REGNO (operands[1])))
2848           return "sub{l}\t{%3, %2|%2, %3}\;fstp%z0\t%y0";
2849         else
2850           return "sub{l}\t{%3, %2|%2, %3}\;fst%z0\t%y0";
2851
2852
2853     case 1:
2854     case 2:
2855       return "#";
2856
2857     default:
2858       abort ();
2859     }
2860 }
2861   [(set_attr "type" "multi")
2862    (set_attr "mode" "DF,SI,DF")])
2863
2864 ;; %%% Kill this when call knows how to work this out.
2865 (define_split
2866   [(set (match_operand:DF 0 "push_operand" "")
2867         (match_operand:DF 1 "register_operand" ""))]
2868   "!TARGET_64BIT && reload_completed && ANY_FP_REGNO_P (REGNO (operands[1]))"
2869   [(set (reg:SI 7) (plus:SI (reg:SI 7) (const_int -8)))
2870    (set (mem:DF (reg:SI 7)) (match_dup 1))]
2871   "")
2872
2873 (define_split
2874   [(set (match_operand:DF 0 "push_operand" "")
2875         (match_operand:DF 1 "register_operand" ""))]
2876   "TARGET_64BIT && reload_completed && ANY_FP_REGNO_P (REGNO (operands[1]))"
2877   [(set (reg:DI 7) (plus:DI (reg:DI 7) (const_int -8)))
2878    (set (mem:DF (reg:DI 7)) (match_dup 1))]
2879   "")
2880
2881 (define_split
2882   [(set (match_operand:DF 0 "push_operand" "")
2883         (match_operand:DF 1 "general_operand" ""))]
2884   "reload_completed"
2885   [(const_int 0)]
2886   "ix86_split_long_move (operands); DONE;")
2887
2888 ;; Moving is usually shorter when only FP registers are used. This separate
2889 ;; movdf pattern avoids the use of integer registers for FP operations
2890 ;; when optimizing for size.
2891
2892 (define_insn "*movdf_nointeger"
2893   [(set (match_operand:DF 0 "nonimmediate_operand" "=f#Y,m,f#Y,*r,o,Y#f,Y#f,Y#f,m")
2894         (match_operand:DF 1 "general_operand" "fm#Y,f#Y,G,*roF,F*r,H,Y#f,YHm#f,Y#f"))]
2895   "(GET_CODE (operands[0]) != MEM || GET_CODE (operands[1]) != MEM)
2896    && (optimize_size || !TARGET_INTEGER_DFMODE_MOVES)
2897    && (reload_in_progress || reload_completed
2898        || GET_CODE (operands[1]) != CONST_DOUBLE
2899        || memory_operand (operands[0], DFmode))" 
2900 {
2901   switch (which_alternative)
2902     {
2903     case 0:
2904       if (REG_P (operands[1])
2905           && find_regno_note (insn, REG_DEAD, REGNO (operands[1])))
2906         return "fstp\t%y0";
2907       else if (STACK_TOP_P (operands[0]))
2908         return "fld%z1\t%y1";
2909       else
2910         return "fst\t%y0";
2911
2912     case 1:
2913       if (find_regno_note (insn, REG_DEAD, REGNO (operands[1])))
2914         return "fstp%z0\t%y0";
2915       else
2916         return "fst%z0\t%y0";
2917
2918     case 2:
2919       switch (standard_80387_constant_p (operands[1]))
2920         {
2921         case 1:
2922           return "fldz";
2923         case 2:
2924           return "fld1";
2925         }
2926       abort();
2927
2928     case 3:
2929     case 4:
2930       return "#";
2931     case 5:
2932       return "pxor\t%0, %0";
2933     case 6:
2934       if (TARGET_PARTIAL_REG_DEPENDENCY)
2935         return "movapd\t{%1, %0|%0, %1}";
2936       else
2937         return "movsd\t{%1, %0|%0, %1}";
2938     case 7:
2939     case 8:
2940         return "movsd\t{%1, %0|%0, %1}";
2941
2942     default:
2943       abort();
2944     }
2945 }
2946   [(set_attr "type" "fmov,fmov,fmov,multi,multi,sse,sse,sse,sse")
2947    (set_attr "mode" "DF,DF,DF,SI,SI,TI,DF,DF,DF")])
2948
2949 (define_insn "*movdf_integer"
2950   [(set (match_operand:DF 0 "nonimmediate_operand" "=f#Yr,m,f#Yr,r#Yf,o,Y#rf,Y#rf,Y#rf,m")
2951         (match_operand:DF 1 "general_operand" "fm#Yr,f#Yr,G,roF#Yf,Fr#Yf,H,Y#rf,Ym#rf,Y#rf"))]
2952   "(GET_CODE (operands[0]) != MEM || GET_CODE (operands[1]) != MEM)
2953    && !optimize_size && TARGET_INTEGER_DFMODE_MOVES
2954    && (reload_in_progress || reload_completed
2955        || GET_CODE (operands[1]) != CONST_DOUBLE
2956        || memory_operand (operands[0], DFmode))" 
2957 {
2958   switch (which_alternative)
2959     {
2960     case 0:
2961       if (REG_P (operands[1])
2962           && find_regno_note (insn, REG_DEAD, REGNO (operands[1])))
2963         return "fstp\t%y0";
2964       else if (STACK_TOP_P (operands[0]))
2965         return "fld%z1\t%y1";
2966       else
2967         return "fst\t%y0";
2968
2969     case 1:
2970       if (find_regno_note (insn, REG_DEAD, REGNO (operands[1])))
2971         return "fstp%z0\t%y0";
2972       else
2973         return "fst%z0\t%y0";
2974
2975     case 2:
2976       switch (standard_80387_constant_p (operands[1]))
2977         {
2978         case 1:
2979           return "fldz";
2980         case 2:
2981           return "fld1";
2982         }
2983       abort();
2984
2985     case 3:
2986     case 4:
2987       return "#";
2988
2989     case 5:
2990       return "pxor\t%0, %0";
2991     case 6:
2992       if (TARGET_PARTIAL_REG_DEPENDENCY)
2993         return "movapd\t{%1, %0|%0, %1}";
2994       else
2995         return "movsd\t{%1, %0|%0, %1}";
2996     case 7:
2997     case 8:
2998       return "movsd\t{%1, %0|%0, %1}";
2999
3000     default:
3001       abort();
3002     }
3003 }
3004   [(set_attr "type" "fmov,fmov,fmov,multi,multi,sse,sse,sse,sse")
3005    (set_attr "mode" "DF,DF,DF,SI,SI,TI,DF,DF,DF")])
3006
3007 (define_split
3008   [(set (match_operand:DF 0 "nonimmediate_operand" "")
3009         (match_operand:DF 1 "general_operand" ""))]
3010   "reload_completed
3011    && (GET_CODE (operands[0]) != MEM || GET_CODE (operands[1]) != MEM)
3012    && ! (ANY_FP_REG_P (operands[0]) || 
3013          (GET_CODE (operands[0]) == SUBREG
3014           && ANY_FP_REG_P (SUBREG_REG (operands[0]))))
3015    && ! (ANY_FP_REG_P (operands[1]) || 
3016          (GET_CODE (operands[1]) == SUBREG
3017           && ANY_FP_REG_P (SUBREG_REG (operands[1]))))"
3018   [(const_int 0)]
3019   "ix86_split_long_move (operands); DONE;")
3020
3021 (define_insn "*swapdf"
3022   [(set (match_operand:DF 0 "register_operand" "+f")
3023         (match_operand:DF 1 "register_operand" "+f"))
3024    (set (match_dup 1)
3025         (match_dup 0))]
3026   "reload_completed || !TARGET_SSE2"
3027 {
3028   if (STACK_TOP_P (operands[0]))
3029     return "fxch\t%1";
3030   else
3031     return "fxch\t%0";
3032 }
3033   [(set_attr "type" "fxch")
3034    (set_attr "mode" "DF")])
3035
3036 (define_expand "movxf"
3037   [(set (match_operand:XF 0 "nonimmediate_operand" "")
3038         (match_operand:XF 1 "general_operand" ""))]
3039   "!TARGET_64BIT"
3040   "ix86_expand_move (XFmode, operands); DONE;")
3041
3042 (define_expand "movtf"
3043   [(set (match_operand:TF 0 "nonimmediate_operand" "")
3044         (match_operand:TF 1 "general_operand" ""))]
3045   ""
3046   "ix86_expand_move (TFmode, operands); DONE;")
3047
3048 ;; Size of pushdf is 3 (for sub) + 2 (for fstp) + memory operand size.
3049 ;; Size of pushdf using integer insturctions is 3+3*memory operand size
3050 ;; Pushing using integer instructions is longer except for constants
3051 ;; and direct memory references.
3052 ;; (assuming that any given constant is pushed only once, but this ought to be
3053 ;;  handled elsewhere).
3054
3055 (define_insn "*pushxf_nointeger"
3056   [(set (match_operand:XF 0 "push_operand" "=X,X,X")
3057         (match_operand:XF 1 "general_no_elim_operand" "f,Fo,*r"))]
3058   "!TARGET_64BIT && optimize_size"
3059 {
3060   switch (which_alternative)
3061     {
3062     case 0:
3063       /* %%% We loose REG_DEAD notes for controling pops if we split late.  */
3064       operands[0] = gen_rtx_MEM (XFmode, stack_pointer_rtx);
3065       operands[2] = stack_pointer_rtx;
3066       operands[3] = GEN_INT (12);
3067       if (find_regno_note (insn, REG_DEAD, REGNO (operands[1])))
3068         return "sub{l}\t{%3, %2|%2, %3}\;fstp%z0\t%y0";
3069       else
3070         return "sub{l}\t{%3, %2|%2, %3}\;fst%z0\t%y0";
3071
3072     case 1:
3073     case 2:
3074       return "#";
3075
3076     default:
3077       abort ();
3078     }
3079 }
3080   [(set_attr "type" "multi")
3081    (set_attr "mode" "XF,SI,SI")])
3082
3083 (define_insn "*pushtf_nointeger"
3084   [(set (match_operand:TF 0 "push_operand" "=<,<,<")
3085         (match_operand:TF 1 "general_no_elim_operand" "f,Fo,*r"))]
3086   "optimize_size"
3087 {
3088   switch (which_alternative)
3089     {
3090     case 0:
3091       /* %%% We loose REG_DEAD notes for controling pops if we split late.  */
3092       operands[0] = gen_rtx_MEM (XFmode, stack_pointer_rtx);
3093       operands[2] = stack_pointer_rtx;
3094       operands[3] = GEN_INT (16);
3095       if (find_regno_note (insn, REG_DEAD, REGNO (operands[1])))
3096         return "sub{l}\t{%3, %2|%2, %3}\;fstp%z0\t%y0";
3097       else
3098         return "sub{l}\t{%3, %2|%2, %3}\;fst%z0\t%y0";
3099
3100     case 1:
3101     case 2:
3102       return "#";
3103
3104     default:
3105       abort ();
3106     }
3107 }
3108   [(set_attr "type" "multi")
3109    (set_attr "mode" "XF,SI,SI")])
3110
3111 (define_insn "*pushxf_integer"
3112   [(set (match_operand:XF 0 "push_operand" "=<,<")
3113         (match_operand:XF 1 "general_no_elim_operand" "f#r,ro#f"))]
3114   "!TARGET_64BIT && !optimize_size"
3115 {
3116   switch (which_alternative)
3117     {
3118     case 0:
3119       /* %%% We loose REG_DEAD notes for controling pops if we split late.  */
3120       operands[0] = gen_rtx_MEM (XFmode, stack_pointer_rtx);
3121       operands[2] = stack_pointer_rtx;
3122       operands[3] = GEN_INT (12);
3123       if (find_regno_note (insn, REG_DEAD, REGNO (operands[1])))
3124         return "sub{l}\t{%3, %2|%2, %3}\;fstp%z0\t%y0";
3125       else
3126         return "sub{l}\t{%3, %2|%2, %3}\;fst%z0\t%y0";
3127
3128     case 1:
3129       return "#";
3130
3131     default:
3132       abort ();
3133     }
3134 }
3135   [(set_attr "type" "multi")
3136    (set_attr "mode" "XF,SI")])
3137
3138 (define_insn "*pushtf_integer"
3139   [(set (match_operand:TF 0 "push_operand" "=<,<")
3140         (match_operand:TF 1 "general_no_elim_operand" "f#r,rFo#f"))]
3141   "!optimize_size"
3142 {
3143   switch (which_alternative)
3144     {
3145     case 0:
3146       /* %%% We loose REG_DEAD notes for controling pops if we split late.  */
3147       operands[0] = gen_rtx_MEM (XFmode, stack_pointer_rtx);
3148       operands[2] = stack_pointer_rtx;
3149       operands[3] = GEN_INT (16);
3150       if (TARGET_64BIT)
3151         if (find_regno_note (insn, REG_DEAD, REGNO (operands[1])))
3152           return "sub{q}\t{%3, %2|%2, %3}\;fstp%z0\t%y0";
3153         else
3154           return "sub{q}\t{%3, %2|%2, %3}\;fst%z0\t%y0";
3155       else
3156         if (find_regno_note (insn, REG_DEAD, REGNO (operands[1])))
3157           return "sub{l}\t{%3, %2|%2, %3}\;fstp%z0\t%y0";
3158         else
3159           return "sub{l}\t{%3, %2|%2, %3}\;fst%z0\t%y0";
3160
3161     case 1:
3162       return "#";
3163
3164     default:
3165       abort ();
3166     }
3167 }
3168   [(set_attr "type" "multi")
3169    (set_attr "mode" "XF,SI")])
3170
3171 (define_split
3172   [(set (match_operand 0 "push_operand" "")
3173         (match_operand 1 "general_operand" ""))]
3174   "reload_completed
3175    && (GET_MODE (operands[0]) == XFmode
3176        || GET_MODE (operands[0]) == TFmode
3177        || GET_MODE (operands[0]) == DFmode)
3178    && (!REG_P (operands[1]) || !ANY_FP_REGNO_P (REGNO (operands[1])))"
3179   [(const_int 0)]
3180   "ix86_split_long_move (operands); DONE;")
3181
3182 (define_split
3183   [(set (match_operand:XF 0 "push_operand" "")
3184         (match_operand:XF 1 "register_operand" ""))]
3185   "!TARGET_64BIT && ANY_FP_REGNO_P (REGNO (operands[1]))"
3186   [(set (reg:SI 7) (plus:SI (reg:SI 7) (const_int -12)))
3187    (set (mem:XF (reg:SI 7)) (match_dup 1))])
3188
3189 (define_split
3190   [(set (match_operand:TF 0 "push_operand" "")
3191         (match_operand:TF 1 "register_operand" ""))]
3192   "!TARGET_64BIT && ANY_FP_REGNO_P (REGNO (operands[1]))"
3193   [(set (reg:SI 7) (plus:SI (reg:SI 7) (const_int -16)))
3194    (set (mem:TF (reg:SI 7)) (match_dup 1))])
3195
3196 (define_split
3197   [(set (match_operand:TF 0 "push_operand" "")
3198         (match_operand:TF 1 "register_operand" ""))]
3199   "TARGET_64BIT && ANY_FP_REGNO_P (REGNO (operands[1]))"
3200   [(set (reg:DI 7) (plus:DI (reg:DI 7) (const_int -16)))
3201    (set (mem:TF (reg:DI 7)) (match_dup 1))])
3202
3203 ;; Do not use integer registers when optimizing for size
3204 (define_insn "*movxf_nointeger"
3205   [(set (match_operand:XF 0 "nonimmediate_operand" "=f,m,f,*r,o")
3206         (match_operand:XF 1 "general_operand" "fm,f,G,*roF,F*r"))]
3207   "!TARGET_64BIT
3208    && optimize_size
3209    && (GET_CODE (operands[0]) != MEM || GET_CODE (operands[1]) != MEM)
3210    && (reload_in_progress || reload_completed
3211        || GET_CODE (operands[1]) != CONST_DOUBLE
3212        || memory_operand (operands[0], XFmode))" 
3213 {
3214   switch (which_alternative)
3215     {
3216     case 0:
3217       if (REG_P (operands[1])
3218           && find_regno_note (insn, REG_DEAD, REGNO (operands[1])))
3219         return "fstp\t%y0";
3220       else if (STACK_TOP_P (operands[0]))
3221         return "fld%z1\t%y1";
3222       else
3223         return "fst\t%y0";
3224
3225     case 1:
3226       /* There is no non-popping store to memory for XFmode.  So if
3227          we need one, follow the store with a load.  */
3228       if (! find_regno_note (insn, REG_DEAD, REGNO (operands[1])))
3229         return "fstp%z0\t%y0\;fld%z0\t%y0";
3230       else
3231         return "fstp%z0\t%y0";
3232
3233     case 2:
3234       switch (standard_80387_constant_p (operands[1]))
3235         {
3236         case 1:
3237           return "fldz";
3238         case 2:
3239           return "fld1";
3240         }
3241       break;
3242
3243     case 3: case 4:
3244       return "#";
3245     }
3246   abort();
3247 }
3248   [(set_attr "type" "fmov,fmov,fmov,multi,multi")
3249    (set_attr "mode" "XF,XF,XF,SI,SI")])
3250
3251 (define_insn "*movtf_nointeger"
3252   [(set (match_operand:TF 0 "nonimmediate_operand" "=f,m,f,*r,o")
3253         (match_operand:TF 1 "general_operand" "fm,f,G,*roF,F*r"))]
3254   "(GET_CODE (operands[0]) != MEM || GET_CODE (operands[1]) != MEM)
3255    && optimize_size
3256    && (reload_in_progress || reload_completed
3257        || GET_CODE (operands[1]) != CONST_DOUBLE
3258        || memory_operand (operands[0], TFmode))" 
3259 {
3260   switch (which_alternative)
3261     {
3262     case 0:
3263       if (REG_P (operands[1])
3264           && find_regno_note (insn, REG_DEAD, REGNO (operands[1])))
3265         return "fstp\t%y0";
3266       else if (STACK_TOP_P (operands[0]))
3267         return "fld%z1\t%y1";
3268       else
3269         return "fst\t%y0";
3270
3271     case 1:
3272       /* There is no non-popping store to memory for XFmode.  So if
3273          we need one, follow the store with a load.  */
3274       if (! find_regno_note (insn, REG_DEAD, REGNO (operands[1])))
3275         return "fstp%z0\t%y0\;fld%z0\t%y0";
3276       else
3277         return "fstp%z0\t%y0";
3278
3279     case 2:
3280       switch (standard_80387_constant_p (operands[1]))
3281         {
3282         case 1:
3283           return "fldz";
3284         case 2:
3285           return "fld1";
3286         }
3287       break;
3288
3289     case 3: case 4:
3290       return "#";
3291     }
3292   abort();
3293 }
3294   [(set_attr "type" "fmov,fmov,fmov,multi,multi")
3295    (set_attr "mode" "XF,XF,XF,SI,SI")])
3296
3297 (define_insn "*movxf_integer"
3298   [(set (match_operand:XF 0 "nonimmediate_operand" "=f#r,m,f#r,r#f,o")
3299         (match_operand:XF 1 "general_operand" "fm#r,f#r,G,roF#f,Fr#f"))]
3300   "!TARGET_64BIT
3301    && !optimize_size
3302    && (GET_CODE (operands[0]) != MEM || GET_CODE (operands[1]) != MEM)
3303    && (reload_in_progress || reload_completed
3304        || GET_CODE (operands[1]) != CONST_DOUBLE
3305        || memory_operand (operands[0], XFmode))" 
3306 {
3307   switch (which_alternative)
3308     {
3309     case 0:
3310       if (REG_P (operands[1])
3311           && find_regno_note (insn, REG_DEAD, REGNO (operands[1])))
3312         return "fstp\t%y0";
3313       else if (STACK_TOP_P (operands[0]))
3314         return "fld%z1\t%y1";
3315       else
3316         return "fst\t%y0";
3317
3318     case 1:
3319       /* There is no non-popping store to memory for XFmode.  So if
3320          we need one, follow the store with a load.  */
3321       if (! find_regno_note (insn, REG_DEAD, REGNO (operands[1])))
3322         return "fstp%z0\t%y0\;fld%z0\t%y0";
3323       else
3324         return "fstp%z0\t%y0";
3325
3326     case 2:
3327       switch (standard_80387_constant_p (operands[1]))
3328         {
3329         case 1:
3330           return "fldz";
3331         case 2:
3332           return "fld1";
3333         }
3334       break;
3335
3336     case 3: case 4:
3337       return "#";
3338     }
3339   abort();
3340 }
3341   [(set_attr "type" "fmov,fmov,fmov,multi,multi")
3342    (set_attr "mode" "XF,XF,XF,SI,SI")])
3343
3344 (define_insn "*movtf_integer"
3345   [(set (match_operand:TF 0 "nonimmediate_operand" "=f#r,m,f#r,r#f,o")
3346         (match_operand:TF 1 "general_operand" "fm#r,f#r,G,roF#f,Fr#f"))]
3347   "(GET_CODE (operands[0]) != MEM || GET_CODE (operands[1]) != MEM)
3348    && !optimize_size
3349    && (reload_in_progress || reload_completed
3350        || GET_CODE (operands[1]) != CONST_DOUBLE
3351        || memory_operand (operands[0], TFmode))" 
3352 {
3353   switch (which_alternative)
3354     {
3355     case 0:
3356       if (REG_P (operands[1])
3357           && find_regno_note (insn, REG_DEAD, REGNO (operands[1])))
3358         return "fstp\t%y0";
3359       else if (STACK_TOP_P (operands[0]))
3360         return "fld%z1\t%y1";
3361       else
3362         return "fst\t%y0";
3363
3364     case 1:
3365       /* There is no non-popping store to memory for XFmode.  So if
3366          we need one, follow the store with a load.  */
3367       if (! find_regno_note (insn, REG_DEAD, REGNO (operands[1])))
3368         return "fstp%z0\t%y0\;fld%z0\t%y0";
3369       else
3370         return "fstp%z0\t%y0";
3371
3372     case 2:
3373       switch (standard_80387_constant_p (operands[1]))
3374         {
3375         case 1:
3376           return "fldz";
3377         case 2:
3378           return "fld1";
3379         }
3380       break;
3381
3382     case 3: case 4:
3383       return "#";
3384     }
3385   abort();
3386 }
3387   [(set_attr "type" "fmov,fmov,fmov,multi,multi")
3388    (set_attr "mode" "XF,XF,XF,SI,SI")])
3389
3390 (define_split
3391   [(set (match_operand 0 "nonimmediate_operand" "")
3392         (match_operand 1 "general_operand" ""))]
3393   "reload_completed
3394    && (GET_CODE (operands[0]) != MEM || GET_CODE (operands[1]) != MEM)
3395    && (GET_MODE (operands[0]) == XFmode || GET_MODE (operands[0]) == TFmode)
3396    && ! (ANY_FP_REG_P (operands[0]) || 
3397          (GET_CODE (operands[0]) == SUBREG
3398           && ANY_FP_REG_P (SUBREG_REG (operands[0]))))
3399    && ! (ANY_FP_REG_P (operands[1]) || 
3400          (GET_CODE (operands[1]) == SUBREG
3401           && ANY_FP_REG_P (SUBREG_REG (operands[1]))))"
3402   [(const_int 0)]
3403   "ix86_split_long_move (operands); DONE;")
3404
3405 (define_split
3406   [(set (match_operand 0 "register_operand" "")
3407         (match_operand 1 "memory_operand" ""))]
3408   "reload_completed
3409    && GET_CODE (operands[1]) == MEM
3410    && (GET_MODE (operands[0]) == XFmode || GET_MODE (operands[0]) == TFmode
3411        || GET_MODE (operands[0]) == SFmode || GET_MODE (operands[0]) == DFmode)
3412    && GET_CODE (XEXP (operands[1], 0)) == SYMBOL_REF
3413    && CONSTANT_POOL_ADDRESS_P (XEXP (operands[1], 0))
3414    && (!(SSE_REG_P (operands[0]) || 
3415          (GET_CODE (operands[0]) == SUBREG
3416           && SSE_REG_P (SUBREG_REG (operands[0]))))
3417        || standard_sse_constant_p (get_pool_constant (XEXP (operands[1], 0))))
3418    && (!(FP_REG_P (operands[0]) || 
3419          (GET_CODE (operands[0]) == SUBREG
3420           && FP_REG_P (SUBREG_REG (operands[0]))))
3421        || standard_80387_constant_p (get_pool_constant (XEXP (operands[1], 0))))"
3422   [(set (match_dup 0)
3423         (match_dup 1))]
3424   "operands[1] = get_pool_constant (XEXP (operands[1], 0));")
3425
3426 (define_insn "swapxf"
3427   [(set (match_operand:XF 0 "register_operand" "+f")
3428         (match_operand:XF 1 "register_operand" "+f"))
3429    (set (match_dup 1)
3430         (match_dup 0))]
3431   ""
3432 {
3433   if (STACK_TOP_P (operands[0]))
3434     return "fxch\t%1";
3435   else
3436     return "fxch\t%0";
3437 }
3438   [(set_attr "type" "fxch")
3439    (set_attr "mode" "XF")])
3440
3441 (define_insn "swaptf"
3442   [(set (match_operand:TF 0 "register_operand" "+f")
3443         (match_operand:TF 1 "register_operand" "+f"))
3444    (set (match_dup 1)
3445         (match_dup 0))]
3446   ""
3447 {
3448   if (STACK_TOP_P (operands[0]))
3449     return "fxch\t%1";
3450   else
3451     return "fxch\t%0";
3452 }
3453   [(set_attr "type" "fxch")
3454    (set_attr "mode" "XF")])
3455 \f
3456 ;; Zero extension instructions
3457
3458 (define_expand "zero_extendhisi2"
3459   [(set (match_operand:SI 0 "register_operand" "")
3460      (zero_extend:SI (match_operand:HI 1 "nonimmediate_operand" "")))]
3461   ""
3462 {
3463   if (TARGET_ZERO_EXTEND_WITH_AND && !optimize_size)
3464     {
3465       operands[1] = force_reg (HImode, operands[1]);
3466       emit_insn (gen_zero_extendhisi2_and (operands[0], operands[1]));
3467       DONE;
3468     }
3469 })
3470
3471 (define_insn "zero_extendhisi2_and"
3472   [(set (match_operand:SI 0 "register_operand" "=r")
3473      (zero_extend:SI (match_operand:HI 1 "register_operand" "0")))
3474    (clobber (reg:CC 17))]
3475   "TARGET_ZERO_EXTEND_WITH_AND && !optimize_size"
3476   "#"
3477   [(set_attr "type" "alu1")
3478    (set_attr "mode" "SI")])
3479
3480 (define_split
3481   [(set (match_operand:SI 0 "register_operand" "")
3482         (zero_extend:SI (match_operand:HI 1 "register_operand" "")))
3483    (clobber (reg:CC 17))]
3484   "reload_completed && TARGET_ZERO_EXTEND_WITH_AND && !optimize_size"
3485   [(parallel [(set (match_dup 0) (and:SI (match_dup 0) (const_int 65535)))
3486               (clobber (reg:CC 17))])]
3487   "")
3488
3489 (define_insn "*zero_extendhisi2_movzwl"
3490   [(set (match_operand:SI 0 "register_operand" "=r")
3491      (zero_extend:SI (match_operand:HI 1 "nonimmediate_operand" "rm")))]
3492   "!TARGET_ZERO_EXTEND_WITH_AND || optimize_size"
3493   "movz{wl|x}\t{%1, %0|%0, %1}"
3494   [(set_attr "type" "imovx")
3495    (set_attr "mode" "SI")])
3496
3497 (define_expand "zero_extendqihi2"
3498   [(parallel
3499     [(set (match_operand:HI 0 "register_operand" "")
3500        (zero_extend:HI (match_operand:QI 1 "nonimmediate_operand" "")))
3501      (clobber (reg:CC 17))])]
3502   ""
3503   "")
3504
3505 (define_insn "*zero_extendqihi2_and"
3506   [(set (match_operand:HI 0 "register_operand" "=r,?&q")
3507      (zero_extend:HI (match_operand:QI 1 "nonimmediate_operand" "0,qm")))
3508    (clobber (reg:CC 17))]
3509   "TARGET_ZERO_EXTEND_WITH_AND && !optimize_size"
3510   "#"
3511   [(set_attr "type" "alu1")
3512    (set_attr "mode" "HI")])
3513
3514 (define_insn "*zero_extendqihi2_movzbw_and"
3515   [(set (match_operand:HI 0 "register_operand" "=r,r")
3516      (zero_extend:HI (match_operand:QI 1 "nonimmediate_operand" "qm,0")))
3517    (clobber (reg:CC 17))]
3518   "!TARGET_ZERO_EXTEND_WITH_AND || optimize_size"
3519   "#"
3520   [(set_attr "type" "imovx,alu1")
3521    (set_attr "mode" "HI")])
3522
3523 (define_insn "*zero_extendqihi2_movzbw"
3524   [(set (match_operand:HI 0 "register_operand" "=r")
3525      (zero_extend:HI (match_operand:QI 1 "nonimmediate_operand" "qm")))]
3526   "(!TARGET_ZERO_EXTEND_WITH_AND || optimize_size) && reload_completed"
3527   "movz{bw|x}\t{%1, %0|%0, %1}"
3528   [(set_attr "type" "imovx")
3529    (set_attr "mode" "HI")])
3530
3531 ;; For the movzbw case strip only the clobber
3532 (define_split
3533   [(set (match_operand:HI 0 "register_operand" "")
3534         (zero_extend:HI (match_operand:QI 1 "nonimmediate_operand" "")))
3535    (clobber (reg:CC 17))]
3536   "reload_completed 
3537    && (!TARGET_ZERO_EXTEND_WITH_AND || optimize_size)
3538    && (!REG_P (operands[1]) || ANY_QI_REG_P (operands[1]))"
3539   [(set (match_operand:HI 0 "register_operand" "")
3540         (zero_extend:HI (match_operand:QI 1 "nonimmediate_operand" "")))])
3541
3542 ;; When source and destination does not overlap, clear destination
3543 ;; first and then do the movb
3544 (define_split
3545   [(set (match_operand:HI 0 "register_operand" "")
3546         (zero_extend:HI (match_operand:QI 1 "nonimmediate_operand" "")))
3547    (clobber (reg:CC 17))]
3548   "reload_completed
3549    && ANY_QI_REG_P (operands[0])
3550    && (TARGET_ZERO_EXTEND_WITH_AND && !optimize_size)
3551    && !reg_overlap_mentioned_p (operands[0], operands[1])"
3552   [(set (match_dup 0) (const_int 0))
3553    (set (strict_low_part (match_dup 2)) (match_dup 1))]
3554   "operands[2] = gen_lowpart (QImode, operands[0]);")
3555
3556 ;; Rest is handled by single and.
3557 (define_split
3558   [(set (match_operand:HI 0 "register_operand" "")
3559         (zero_extend:HI (match_operand:QI 1 "register_operand" "")))
3560    (clobber (reg:CC 17))]
3561   "reload_completed
3562    && true_regnum (operands[0]) == true_regnum (operands[1])"
3563   [(parallel [(set (match_dup 0) (and:HI (match_dup 0) (const_int 255)))
3564               (clobber (reg:CC 17))])]
3565   "")
3566
3567 (define_expand "zero_extendqisi2"
3568   [(parallel
3569     [(set (match_operand:SI 0 "register_operand" "")
3570        (zero_extend:SI (match_operand:QI 1 "nonimmediate_operand" "")))
3571      (clobber (reg:CC 17))])]
3572   ""
3573   "")
3574
3575 (define_insn "*zero_extendqisi2_and"
3576   [(set (match_operand:SI 0 "register_operand" "=r,?&q")
3577      (zero_extend:SI (match_operand:QI 1 "nonimmediate_operand" "0,qm")))
3578    (clobber (reg:CC 17))]
3579   "TARGET_ZERO_EXTEND_WITH_AND && !optimize_size"
3580   "#"
3581   [(set_attr "type" "alu1")
3582    (set_attr "mode" "SI")])
3583
3584 (define_insn "*zero_extendqisi2_movzbw_and"
3585   [(set (match_operand:SI 0 "register_operand" "=r,r")
3586      (zero_extend:SI (match_operand:QI 1 "nonimmediate_operand" "qm,0")))
3587    (clobber (reg:CC 17))]
3588   "!TARGET_ZERO_EXTEND_WITH_AND || optimize_size"
3589   "#"
3590   [(set_attr "type" "imovx,alu1")
3591    (set_attr "mode" "SI")])
3592
3593 (define_insn "*zero_extendqisi2_movzbw"
3594   [(set (match_operand:SI 0 "register_operand" "=r")
3595      (zero_extend:SI (match_operand:QI 1 "nonimmediate_operand" "qm")))]
3596   "(!TARGET_ZERO_EXTEND_WITH_AND || optimize_size) && reload_completed"
3597   "movz{bl|x}\t{%1, %0|%0, %1}"
3598   [(set_attr "type" "imovx")
3599    (set_attr "mode" "SI")])
3600
3601 ;; For the movzbl case strip only the clobber
3602 (define_split
3603   [(set (match_operand:SI 0 "register_operand" "")
3604         (zero_extend:SI (match_operand:QI 1 "nonimmediate_operand" "")))
3605    (clobber (reg:CC 17))]
3606   "reload_completed 
3607    && (!TARGET_ZERO_EXTEND_WITH_AND || optimize_size)
3608    && (!REG_P (operands[1]) || ANY_QI_REG_P (operands[1]))"
3609   [(set (match_dup 0)
3610         (zero_extend:SI (match_dup 1)))])
3611
3612 ;; When source and destination does not overlap, clear destination
3613 ;; first and then do the movb
3614 (define_split
3615   [(set (match_operand:SI 0 "register_operand" "")
3616         (zero_extend:SI (match_operand:QI 1 "nonimmediate_operand" "")))
3617    (clobber (reg:CC 17))]
3618   "reload_completed
3619    && ANY_QI_REG_P (operands[0])
3620    && (ANY_QI_REG_P (operands[1]) || GET_CODE (operands[1]) == MEM)
3621    && (TARGET_ZERO_EXTEND_WITH_AND && !optimize_size)
3622    && !reg_overlap_mentioned_p (operands[0], operands[1])"
3623   [(set (match_dup 0) (const_int 0))
3624    (set (strict_low_part (match_dup 2)) (match_dup 1))]
3625   "operands[2] = gen_lowpart (QImode, operands[0]);")
3626
3627 ;; Rest is handled by single and.
3628 (define_split
3629   [(set (match_operand:SI 0 "register_operand" "")
3630         (zero_extend:SI (match_operand:QI 1 "register_operand" "")))
3631    (clobber (reg:CC 17))]
3632   "reload_completed
3633    && true_regnum (operands[0]) == true_regnum (operands[1])"
3634   [(parallel [(set (match_dup 0) (and:SI (match_dup 0) (const_int 255)))
3635               (clobber (reg:CC 17))])]
3636   "")
3637
3638 ;; %%% Kill me once multi-word ops are sane.
3639 (define_expand "zero_extendsidi2"
3640   [(set (match_operand:DI 0 "register_operand" "=r")
3641      (zero_extend:DI (match_operand:SI 1 "nonimmediate_operand" "rm")))]
3642   ""
3643   "if (!TARGET_64BIT)
3644      {
3645        emit_insn (gen_zero_extendsidi2_32 (operands[0], operands[1]));
3646        DONE;
3647      }
3648   ")
3649
3650 (define_insn "zero_extendsidi2_32"
3651   [(set (match_operand:DI 0 "nonimmediate_operand" "=r,?r,?*o")
3652         (zero_extend:DI (match_operand:SI 1 "nonimmediate_operand" "0,rm,r")))
3653    (clobber (reg:CC 17))]
3654   "!TARGET_64BIT"
3655   "#"
3656   [(set_attr "mode" "SI")])
3657
3658 (define_insn "zero_extendsidi2_rex64"
3659   [(set (match_operand:DI 0 "nonimmediate_operand" "=r,o")
3660      (zero_extend:DI (match_operand:SI 1 "nonimmediate_operand" "rm,0")))]
3661   "TARGET_64BIT"
3662   "@
3663    mov\t{%k1, %k0|%k0, %k1}
3664    #"
3665   [(set_attr "type" "imovx,imov")
3666    (set_attr "mode" "SI,DI")])
3667
3668 (define_split
3669   [(set (match_operand:DI 0 "memory_operand" "")
3670      (zero_extend:DI (match_dup 0)))]
3671   "TARGET_64BIT"
3672   [(set (match_dup 4) (const_int 0))]
3673   "split_di (&operands[0], 1, &operands[3], &operands[4]);")
3674
3675 (define_split 
3676   [(set (match_operand:DI 0 "register_operand" "")
3677         (zero_extend:DI (match_operand:SI 1 "register_operand" "")))
3678    (clobber (reg:CC 17))]
3679   "!TARGET_64BIT && reload_completed
3680    && true_regnum (operands[0]) == true_regnum (operands[1])"
3681   [(set (match_dup 4) (const_int 0))]
3682   "split_di (&operands[0], 1, &operands[3], &operands[4]);")
3683
3684 (define_split 
3685   [(set (match_operand:DI 0 "nonimmediate_operand" "")
3686         (zero_extend:DI (match_operand:SI 1 "general_operand" "")))
3687    (clobber (reg:CC 17))]
3688   "!TARGET_64BIT && reload_completed"
3689   [(set (match_dup 3) (match_dup 1))
3690    (set (match_dup 4) (const_int 0))]
3691   "split_di (&operands[0], 1, &operands[3], &operands[4]);")
3692
3693 (define_insn "zero_extendhidi2"
3694   [(set (match_operand:DI 0 "register_operand" "=r,r")
3695      (zero_extend:DI (match_operand:HI 1 "nonimmediate_operand" "r,m")))]
3696   "TARGET_64BIT"
3697   "@
3698    movz{wl|x}\t{%1, %k0|%k0, %1} 
3699    movz{wq|x}\t{%1, %0|%0, %1}"
3700   [(set_attr "type" "imovx")
3701    (set_attr "mode" "SI,DI")])
3702
3703 (define_insn "zero_extendqidi2"
3704   [(set (match_operand:DI 0 "register_operand" "=r,r")
3705      (zero_extend:DI (match_operand:QI 1 "nonimmediate_operand" "Q,m")))]
3706   "TARGET_64BIT"
3707   "@
3708    movz{bl|x}\t{%1, %k0|%k0, %1} 
3709    movz{bq|x}\t{%1, %0|%0, %1}"
3710   [(set_attr "type" "imovx")
3711    (set_attr "mode" "SI,DI")])
3712 \f
3713 ;; Sign extension instructions
3714
3715 (define_expand "extendsidi2"
3716   [(parallel [(set (match_operand:DI 0 "register_operand" "")
3717                    (sign_extend:DI (match_operand:SI 1 "register_operand" "")))
3718               (clobber (reg:CC 17))
3719               (clobber (match_scratch:SI 2 ""))])]
3720   ""
3721 {
3722   if (TARGET_64BIT)
3723     {
3724       emit_insn (gen_extendsidi2_rex64 (operands[0], operands[1]));
3725       DONE;
3726     }
3727 })
3728
3729 (define_insn "*extendsidi2_1"
3730   [(set (match_operand:DI 0 "nonimmediate_operand" "=*A,r,?r,?*o")
3731         (sign_extend:DI (match_operand:SI 1 "register_operand" "0,0,r,r")))
3732    (clobber (reg:CC 17))
3733    (clobber (match_scratch:SI 2 "=X,X,X,&r"))]
3734   "!TARGET_64BIT"
3735   "#")
3736
3737 (define_insn "extendsidi2_rex64"
3738   [(set (match_operand:DI 0 "register_operand" "=*a,r")
3739         (sign_extend:DI (match_operand:SI 1 "nonimmediate_operand" "*0,rm")))]
3740   "TARGET_64BIT"
3741   "@
3742    {cltq|cdqe}
3743    movs{lq|x}\t{%1,%0|%0, %1}"
3744   [(set_attr "type" "imovx")
3745    (set_attr "mode" "DI")
3746    (set_attr "prefix_0f" "0")
3747    (set_attr "modrm" "0,1")])
3748
3749 (define_insn "extendhidi2"
3750   [(set (match_operand:DI 0 "register_operand" "=r")
3751         (sign_extend:DI (match_operand:HI 1 "nonimmediate_operand" "rm")))]
3752   "TARGET_64BIT"
3753   "movs{wq|x}\t{%1,%0|%0, %1}"
3754   [(set_attr "type" "imovx")
3755    (set_attr "mode" "DI")])
3756
3757 (define_insn "extendqidi2"
3758   [(set (match_operand:DI 0 "register_operand" "=r")
3759         (sign_extend:DI (match_operand:QI 1 "nonimmediate_operand" "qm")))]
3760   "TARGET_64BIT"
3761   "movs{bq|x}\t{%1,%0|%0, %1}"
3762    [(set_attr "type" "imovx")
3763     (set_attr "mode" "DI")])
3764
3765 ;; Extend to memory case when source register does die.
3766 (define_split 
3767   [(set (match_operand:DI 0 "memory_operand" "")
3768         (sign_extend:DI (match_operand:SI 1 "register_operand" "")))
3769    (clobber (reg:CC 17))
3770    (clobber (match_operand:SI 2 "register_operand" ""))]
3771   "(reload_completed
3772     && dead_or_set_p (insn, operands[1])
3773     && !reg_mentioned_p (operands[1], operands[0]))"
3774   [(set (match_dup 3) (match_dup 1))
3775    (parallel [(set (match_dup 1) (ashiftrt:SI (match_dup 1) (const_int 31)))
3776               (clobber (reg:CC 17))])
3777    (set (match_dup 4) (match_dup 1))]
3778   "split_di (&operands[0], 1, &operands[3], &operands[4]);")
3779
3780 ;; Extend to memory case when source register does not die.
3781 (define_split 
3782   [(set (match_operand:DI 0 "memory_operand" "")
3783         (sign_extend:DI (match_operand:SI 1 "register_operand" "")))
3784    (clobber (reg:CC 17))
3785    (clobber (match_operand:SI 2 "register_operand" ""))]
3786   "reload_completed"
3787   [(const_int 0)]
3788 {
3789   split_di (&operands[0], 1, &operands[3], &operands[4]);
3790
3791   emit_move_insn (operands[3], operands[1]);
3792
3793   /* Generate a cltd if possible and doing so it profitable.  */
3794   if (true_regnum (operands[1]) == 0
3795       && true_regnum (operands[2]) == 1
3796       && (optimize_size || TARGET_USE_CLTD))
3797     {
3798       emit_insn (gen_ashrsi3_31 (operands[2], operands[1], GEN_INT (31)));
3799     }
3800   else
3801     {
3802       emit_move_insn (operands[2], operands[1]);
3803       emit_insn (gen_ashrsi3_31 (operands[2], operands[2], GEN_INT (31)));
3804     }
3805   emit_move_insn (operands[4], operands[2]);
3806   DONE;
3807 })
3808
3809 ;; Extend to register case.  Optimize case where source and destination
3810 ;; registers match and cases where we can use cltd.
3811 (define_split 
3812   [(set (match_operand:DI 0 "register_operand" "")
3813         (sign_extend:DI (match_operand:SI 1 "register_operand" "")))
3814    (clobber (reg:CC 17))
3815    (clobber (match_scratch:SI 2 ""))]
3816   "reload_completed"
3817   [(const_int 0)]
3818 {
3819   split_di (&operands[0], 1, &operands[3], &operands[4]);
3820
3821   if (true_regnum (operands[3]) != true_regnum (operands[1]))
3822     emit_move_insn (operands[3], operands[1]);
3823
3824   /* Generate a cltd if possible and doing so it profitable.  */
3825   if (true_regnum (operands[3]) == 0
3826       && (optimize_size || TARGET_USE_CLTD))
3827     {
3828       emit_insn (gen_ashrsi3_31 (operands[4], operands[3], GEN_INT (31)));
3829       DONE;
3830     }
3831
3832   if (true_regnum (operands[4]) != true_regnum (operands[1]))
3833     emit_move_insn (operands[4], operands[1]);
3834
3835   emit_insn (gen_ashrsi3_31 (operands[4], operands[4], GEN_INT (31)));
3836   DONE;
3837 })
3838
3839 (define_insn "extendhisi2"
3840   [(set (match_operand:SI 0 "register_operand" "=*a,r")
3841         (sign_extend:SI (match_operand:HI 1 "nonimmediate_operand" "*0,rm")))]
3842   ""
3843 {
3844   switch (get_attr_prefix_0f (insn))
3845     {
3846     case 0:
3847       return "{cwtl|cwde}";
3848     default:
3849       return "movs{wl|x}\t{%1,%0|%0, %1}";
3850     }
3851 }
3852   [(set_attr "type" "imovx")
3853    (set_attr "mode" "SI")
3854    (set (attr "prefix_0f")
3855      ;; movsx is short decodable while cwtl is vector decoded.
3856      (if_then_else (and (eq_attr "cpu" "!k6")
3857                         (eq_attr "alternative" "0"))
3858         (const_string "0")
3859         (const_string "1")))
3860    (set (attr "modrm")
3861      (if_then_else (eq_attr "prefix_0f" "0")
3862         (const_string "0")
3863         (const_string "1")))])
3864
3865 (define_insn "*extendhisi2_zext"
3866   [(set (match_operand:DI 0 "register_operand" "=*a,r")
3867         (zero_extend:DI
3868           (sign_extend:SI (match_operand:HI 1 "nonimmediate_operand" "*0,rm"))))]
3869   "TARGET_64BIT"
3870 {
3871   switch (get_attr_prefix_0f (insn))
3872     {
3873     case 0:
3874       return "{cwtl|cwde}";
3875     default:
3876       return "movs{wl|x}\t{%1,%k0|%k0, %1}";
3877     }
3878 }
3879   [(set_attr "type" "imovx")
3880    (set_attr "mode" "SI")
3881    (set (attr "prefix_0f")
3882      ;; movsx is short decodable while cwtl is vector decoded.
3883      (if_then_else (and (eq_attr "cpu" "!k6")
3884                         (eq_attr "alternative" "0"))
3885         (const_string "0")
3886         (const_string "1")))
3887    (set (attr "modrm")
3888      (if_then_else (eq_attr "prefix_0f" "0")
3889         (const_string "0")
3890         (const_string "1")))])
3891
3892 (define_insn "extendqihi2"
3893   [(set (match_operand:HI 0 "register_operand" "=*a,r")
3894         (sign_extend:HI (match_operand:QI 1 "nonimmediate_operand" "*0,qm")))]
3895   ""
3896 {
3897   switch (get_attr_prefix_0f (insn))
3898     {
3899     case 0:
3900       return "{cbtw|cbw}";
3901     default:
3902       return "movs{bw|x}\t{%1,%0|%0, %1}";
3903     }
3904 }
3905   [(set_attr "type" "imovx")
3906    (set_attr "mode" "HI")
3907    (set (attr "prefix_0f")
3908      ;; movsx is short decodable while cwtl is vector decoded.
3909      (if_then_else (and (eq_attr "cpu" "!k6")
3910                         (eq_attr "alternative" "0"))
3911         (const_string "0")
3912         (const_string "1")))
3913    (set (attr "modrm")
3914      (if_then_else (eq_attr "prefix_0f" "0")
3915         (const_string "0")
3916         (const_string "1")))])
3917
3918 (define_insn "extendqisi2"
3919   [(set (match_operand:SI 0 "register_operand" "=r")
3920         (sign_extend:SI (match_operand:QI 1 "nonimmediate_operand" "qm")))]
3921   ""
3922   "movs{bl|x}\t{%1,%0|%0, %1}"
3923    [(set_attr "type" "imovx")
3924     (set_attr "mode" "SI")])
3925
3926 (define_insn "*extendqisi2_zext"
3927   [(set (match_operand:DI 0 "register_operand" "=r")
3928         (zero_extend:DI
3929           (sign_extend:SI (match_operand:QI 1 "nonimmediate_operand" "qm"))))]
3930   "TARGET_64BIT"
3931   "movs{bl|x}\t{%1,%k0|%k0, %1}"
3932    [(set_attr "type" "imovx")
3933     (set_attr "mode" "SI")])
3934 \f
3935 ;; Conversions between float and double.
3936
3937 ;; These are all no-ops in the model used for the 80387.  So just
3938 ;; emit moves.
3939
3940 ;; %%% Kill these when call knows how to work out a DFmode push earlier. 
3941 (define_insn "*dummy_extendsfdf2"
3942   [(set (match_operand:DF 0 "push_operand" "=<")
3943         (float_extend:DF (match_operand:SF 1 "nonimmediate_operand" "fY")))]
3944   "0"
3945   "#")
3946
3947 (define_split
3948   [(set (match_operand:DF 0 "push_operand" "")
3949         (float_extend:DF (match_operand:SF 1 "register_operand" "")))]
3950   "!TARGET_64BIT && FP_REGNO_P (REGNO (operands[1]))"
3951   [(set (reg:SI 7) (plus:SI (reg:SI 7) (const_int -8)))
3952    (set (mem:DF (reg:SI 7)) (float_extend:DF (match_dup 1)))])
3953
3954 (define_split
3955   [(set (match_operand:DF 0 "push_operand" "")
3956         (float_extend:DF (match_operand:SF 1 "register_operand" "")))]
3957   "TARGET_64BIT && FP_REGNO_P (REGNO (operands[1]))"
3958   [(set (reg:DI 7) (plus:DI (reg:DI 7) (const_int -8)))
3959    (set (mem:DF (reg:DI 7)) (float_extend:DF (match_dup 1)))])
3960
3961 (define_insn "*dummy_extendsfxf2"
3962   [(set (match_operand:XF 0 "push_operand" "=<")
3963         (float_extend:XF (match_operand:SF 1 "nonimmediate_operand" "f")))]
3964   "0"
3965   "#")
3966
3967 (define_split
3968   [(set (match_operand:XF 0 "push_operand" "")
3969         (float_extend:XF (match_operand:SF 1 "register_operand" "")))]
3970   "!TARGET_64BIT && FP_REGNO_P (REGNO (operands[1]))"
3971   [(set (reg:SI 7) (plus:SI (reg:SI 7) (const_int -12)))
3972    (set (mem:XF (reg:SI 7)) (float_extend:XF (match_dup 1)))])
3973
3974 (define_insn "*dummy_extendsftf2"
3975   [(set (match_operand:TF 0 "push_operand" "=<")
3976         (float_extend:TF (match_operand:SF 1 "nonimmediate_operand" "f")))]
3977   "0"
3978   "#")
3979
3980 (define_split
3981   [(set (match_operand:TF 0 "push_operand" "")
3982         (float_extend:TF (match_operand:SF 1 "register_operand" "")))]
3983   "!TARGET_64BIT && FP_REGNO_P (REGNO (operands[1]))"
3984   [(set (reg:SI 7) (plus:SI (reg:SI 7) (const_int -16)))
3985    (set (mem:TF (reg:SI 7)) (float_extend:TF (match_dup 1)))])
3986
3987 (define_split
3988   [(set (match_operand:TF 0 "push_operand" "")
3989         (float_extend:TF (match_operand:SF 1 "register_operand" "")))]
3990   "TARGET_64BIT && FP_REGNO_P (REGNO (operands[1]))"
3991   [(set (reg:DI 7) (plus:DI (reg:DI 7) (const_int -16)))
3992    (set (mem:DF (reg:DI 7)) (float_extend:TF (match_dup 1)))])
3993
3994 (define_insn "*dummy_extenddfxf2"
3995   [(set (match_operand:XF 0 "push_operand" "=<")
3996         (float_extend:XF (match_operand:DF 1 "nonimmediate_operand" "f")))]
3997   "0"
3998   "#")
3999
4000 (define_split
4001   [(set (match_operand:XF 0 "push_operand" "")
4002         (float_extend:XF (match_operand:DF 1 "register_operand" "")))]
4003   "!TARGET_64BIT && FP_REGNO_P (REGNO (operands[1]))"
4004   [(set (reg:SI 7) (plus:SI (reg:SI 7) (const_int -12)))
4005    (set (mem:DF (reg:SI 7)) (float_extend:XF (match_dup 1)))])
4006
4007 (define_insn "*dummy_extenddftf2"
4008   [(set (match_operand:TF 0 "push_operand" "=<")
4009         (float_extend:TF (match_operand:DF 1 "nonimmediate_operand" "f")))]
4010   "0"
4011   "#")
4012
4013 (define_split
4014   [(set (match_operand:TF 0 "push_operand" "")
4015         (float_extend:TF (match_operand:DF 1 "register_operand" "")))]
4016   "!TARGET_64BIT && FP_REGNO_P (REGNO (operands[1]))"
4017   [(set (reg:SI 7) (plus:SI (reg:SI 7) (const_int -16)))
4018    (set (mem:TF (reg:SI 7)) (float_extend:XF (match_dup 1)))])
4019
4020 (define_split
4021   [(set (match_operand:TF 0 "push_operand" "")
4022         (float_extend:TF (match_operand:DF 1 "register_operand" "")))]
4023   "TARGET_64BIT && FP_REGNO_P (REGNO (operands[1]))"
4024   [(set (reg:DI 7) (plus:DI (reg:DI 7) (const_int -16)))
4025    (set (mem:TF (reg:DI 7)) (float_extend:TF (match_dup 1)))])
4026
4027 (define_expand "extendsfdf2"
4028   [(set (match_operand:DF 0 "nonimmediate_operand" "")
4029         (float_extend:DF (match_operand:SF 1 "nonimmediate_operand" "")))]
4030   "TARGET_80387 || TARGET_SSE2"
4031 {
4032   if (GET_CODE (operands[0]) == MEM && GET_CODE (operands[1]) == MEM)
4033     operands[1] = force_reg (SFmode, operands[1]);
4034 })
4035
4036 (define_insn "*extendsfdf2_1"
4037   [(set (match_operand:DF 0 "nonimmediate_operand" "=f#Y,mf#Y,Y#f")
4038         (float_extend:DF (match_operand:SF 1 "nonimmediate_operand" "fm#Y,f#Y,mY#f")))]
4039   "(TARGET_80387 || TARGET_SSE2)
4040    && (GET_CODE (operands[0]) != MEM || GET_CODE (operands[1]) != MEM)"
4041 {
4042   switch (which_alternative)
4043     {
4044     case 0:
4045       if (REG_P (operands[1])
4046           && find_regno_note (insn, REG_DEAD, REGNO (operands[1])))
4047         return "fstp\t%y0";
4048       else if (STACK_TOP_P (operands[0]))
4049         return "fld%z1\t%y1";
4050       else
4051         return "fst\t%y0";
4052
4053     case 1:
4054       if (find_regno_note (insn, REG_DEAD, REGNO (operands[1])))
4055         return "fstp%z0\t%y0";
4056
4057       else
4058         return "fst%z0\t%y0";
4059     case 2:
4060       return "cvtss2sd\t{%1, %0|%0, %1}";
4061
4062     default:
4063       abort ();
4064     }
4065 }
4066   [(set_attr "type" "fmov,fmov,sse")
4067    (set_attr "mode" "SF,XF,DF")])
4068
4069 (define_insn "*extendsfdf2_1_sse_only"
4070   [(set (match_operand:DF 0 "register_operand" "=Y")
4071         (float_extend:DF (match_operand:SF 1 "nonimmediate_operand" "mY")))]
4072   "!TARGET_80387 && TARGET_SSE2
4073    && (GET_CODE (operands[0]) != MEM || GET_CODE (operands[1]) != MEM)"
4074   "cvtss2sd\t{%1, %0|%0, %1}"
4075   [(set_attr "type" "sse")
4076    (set_attr "mode" "DF")])
4077
4078 (define_expand "extendsfxf2"
4079   [(set (match_operand:XF 0 "nonimmediate_operand" "")
4080         (float_extend:XF (match_operand:SF 1 "nonimmediate_operand" "")))]
4081   "!TARGET_64BIT && TARGET_80387"
4082 {
4083   if (GET_CODE (operands[0]) == MEM && GET_CODE (operands[1]) == MEM)
4084     operands[1] = force_reg (SFmode, operands[1]);
4085 })
4086
4087 (define_insn "*extendsfxf2_1"
4088   [(set (match_operand:XF 0 "nonimmediate_operand" "=f,m")
4089         (float_extend:XF (match_operand:SF 1 "nonimmediate_operand" "fm,f")))]
4090   "!TARGET_64BIT && TARGET_80387
4091    && (GET_CODE (operands[0]) != MEM || GET_CODE (operands[1]) != MEM)"
4092 {
4093   switch (which_alternative)
4094     {
4095     case 0:
4096       if (REG_P (operands[1])
4097           && find_regno_note (insn, REG_DEAD, REGNO (operands[1])))
4098         return "fstp\t%y0";
4099       else if (STACK_TOP_P (operands[0]))
4100         return "fld%z1\t%y1";
4101       else
4102         return "fst\t%y0";
4103
4104     case 1:
4105       /* There is no non-popping store to memory for XFmode.  So if
4106          we need one, follow the store with a load.  */
4107       if (! find_regno_note (insn, REG_DEAD, REGNO (operands[1])))
4108         return "fstp%z0\t%y0\n\tfld%z0\t%y0";
4109       else
4110         return "fstp%z0\t%y0";
4111
4112     default:
4113       abort ();
4114     }
4115 }
4116   [(set_attr "type" "fmov")
4117    (set_attr "mode" "SF,XF")])
4118
4119 (define_expand "extendsftf2"
4120   [(set (match_operand:TF 0 "nonimmediate_operand" "")
4121         (float_extend:TF (match_operand:SF 1 "nonimmediate_operand" "")))]
4122   "TARGET_80387"
4123 {
4124   if (GET_CODE (operands[0]) == MEM && GET_CODE (operands[1]) == MEM)
4125     operands[1] = force_reg (SFmode, operands[1]);
4126 })
4127
4128 (define_insn "*extendsftf2_1"
4129   [(set (match_operand:TF 0 "nonimmediate_operand" "=f,m")
4130         (float_extend:TF (match_operand:SF 1 "nonimmediate_operand" "fm,f")))]
4131   "TARGET_80387
4132    && (GET_CODE (operands[0]) != MEM || GET_CODE (operands[1]) != MEM)"
4133 {
4134   switch (which_alternative)
4135     {
4136     case 0:
4137       if (REG_P (operands[1])
4138           && find_regno_note (insn, REG_DEAD, REGNO (operands[1])))
4139         return "fstp\t%y0";
4140       else if (STACK_TOP_P (operands[0]))
4141         return "fld%z1\t%y1";
4142       else
4143         return "fst\t%y0";
4144
4145     case 1:
4146       /* There is no non-popping store to memory for XFmode.  So if
4147          we need one, follow the store with a load.  */
4148       if (! find_regno_note (insn, REG_DEAD, REGNO (operands[1])))
4149         return "fstp%z0\t%y0\n\tfld%z0\t%y0";
4150       else
4151         return "fstp%z0\t%y0";
4152
4153     default:
4154       abort ();
4155     }
4156 }
4157   [(set_attr "type" "fmov")
4158    (set_attr "mode" "SF,XF")])
4159
4160 (define_expand "extenddfxf2"
4161   [(set (match_operand:XF 0 "nonimmediate_operand" "")
4162         (float_extend:XF (match_operand:DF 1 "nonimmediate_operand" "")))]
4163   "!TARGET_64BIT && TARGET_80387"
4164 {
4165   if (GET_CODE (operands[0]) == MEM && GET_CODE (operands[1]) == MEM)
4166     operands[1] = force_reg (DFmode, operands[1]);
4167 })
4168
4169 (define_insn "*extenddfxf2_1"
4170   [(set (match_operand:XF 0 "nonimmediate_operand" "=f,m")
4171         (float_extend:XF (match_operand:DF 1 "nonimmediate_operand" "fm,f")))]
4172   "!TARGET_64BIT && TARGET_80387
4173    && (GET_CODE (operands[0]) != MEM || GET_CODE (operands[1]) != MEM)"
4174 {
4175   switch (which_alternative)
4176     {
4177     case 0:
4178       if (REG_P (operands[1])
4179           && find_regno_note (insn, REG_DEAD, REGNO (operands[1])))
4180         return "fstp\t%y0";
4181       else if (STACK_TOP_P (operands[0]))
4182         return "fld%z1\t%y1";
4183       else
4184         return "fst\t%y0";
4185
4186     case 1:
4187       /* There is no non-popping store to memory for XFmode.  So if
4188          we need one, follow the store with a load.  */
4189       if (! find_regno_note (insn, REG_DEAD, REGNO (operands[1])))
4190         return "fstp%z0\t%y0\n\tfld%z0\t%y0";
4191       else
4192         return "fstp%z0\t%y0";
4193
4194     default:
4195       abort ();
4196     }
4197 }
4198   [(set_attr "type" "fmov")
4199    (set_attr "mode" "DF,XF")])
4200
4201 (define_expand "extenddftf2"
4202   [(set (match_operand:TF 0 "nonimmediate_operand" "")
4203         (float_extend:TF (match_operand:DF 1 "nonimmediate_operand" "")))]
4204   "TARGET_80387"
4205 {
4206   if (GET_CODE (operands[0]) == MEM && GET_CODE (operands[1]) == MEM)
4207     operands[1] = force_reg (DFmode, operands[1]);
4208 })
4209
4210 (define_insn "*extenddftf2_1"
4211   [(set (match_operand:TF 0 "nonimmediate_operand" "=f,m")
4212         (float_extend:TF (match_operand:DF 1 "nonimmediate_operand" "fm,f")))]
4213   "TARGET_80387
4214    && (GET_CODE (operands[0]) != MEM || GET_CODE (operands[1]) != MEM)"
4215 {
4216   switch (which_alternative)
4217     {
4218     case 0:
4219       if (REG_P (operands[1])
4220           && find_regno_note (insn, REG_DEAD, REGNO (operands[1])))
4221         return "fstp\t%y0";
4222       else if (STACK_TOP_P (operands[0]))
4223         return "fld%z1\t%y1";
4224       else
4225         return "fst\t%y0";
4226
4227     case 1:
4228       /* There is no non-popping store to memory for XFmode.  So if
4229          we need one, follow the store with a load.  */
4230       if (! find_regno_note (insn, REG_DEAD, REGNO (operands[1])))
4231         return "fstp%z0\t%y0\n\tfld%z0\t%y0";
4232       else
4233         return "fstp%z0\t%y0";
4234
4235     default:
4236       abort ();
4237     }
4238 }
4239   [(set_attr "type" "fmov")
4240    (set_attr "mode" "DF,XF")])
4241
4242 ;; %%% This seems bad bad news.
4243 ;; This cannot output into an f-reg because there is no way to be sure
4244 ;; of truncating in that case.  Otherwise this is just like a simple move
4245 ;; insn.  So we pretend we can output to a reg in order to get better
4246 ;; register preferencing, but we really use a stack slot.
4247
4248 (define_expand "truncdfsf2"
4249   [(parallel [(set (match_operand:SF 0 "nonimmediate_operand" "")
4250                    (float_truncate:SF
4251                     (match_operand:DF 1 "register_operand" "")))
4252               (clobber (match_dup 2))])]
4253   "TARGET_80387 || TARGET_SSE2"
4254   "
4255    if (TARGET_80387)
4256      operands[2] = assign_386_stack_local (SFmode, 0);
4257    else
4258      {
4259         emit_insn (gen_truncdfsf2_sse_only (operands[0], operands[1]));
4260         DONE;
4261      }
4262 ")
4263
4264 (define_insn "*truncdfsf2_1"
4265   [(set (match_operand:SF 0 "nonimmediate_operand" "=m,?f#rx,?r#fx,?x#rf")
4266         (float_truncate:SF
4267          (match_operand:DF 1 "register_operand" "f,f,f,f")))
4268    (clobber (match_operand:SF 2 "memory_operand" "=X,m,m,m"))]
4269   "TARGET_80387 && !TARGET_SSE2"
4270 {
4271   switch (which_alternative)
4272     {
4273     case 0:
4274       if (find_regno_note (insn, REG_DEAD, REGNO (operands[1])))
4275         return "fstp%z0\t%y0";
4276       else
4277         return "fst%z0\t%y0";
4278     default:
4279       abort ();
4280     }
4281 }
4282   [(set_attr "type" "fmov,multi,multi,multi")
4283    (set_attr "mode" "SF,SF,SF,SF")])
4284
4285 (define_insn "*truncdfsf2_1_sse"
4286   [(set (match_operand:SF 0 "nonimmediate_operand" "=*!m,?f#rx,?r#fx,?x#rf,Y")
4287         (float_truncate:SF
4288          (match_operand:DF 1 "nonimmediate_operand" "f,f,f,f,mY")))
4289    (clobber (match_operand:SF 2 "memory_operand" "=X,m,m,m,X"))]
4290   "TARGET_80387 && TARGET_SSE2"
4291 {
4292   switch (which_alternative)
4293     {
4294     case 0:
4295       if (find_regno_note (insn, REG_DEAD, REGNO (operands[1])))
4296         return "fstp%z0\t%y0";
4297       else
4298         return "fst%z0\t%y0";
4299     case 4:
4300       return "cvtsd2ss\t{%1, %0|%0, %1}";
4301     default:
4302       abort ();
4303     }
4304 }
4305   [(set_attr "type" "fmov,multi,multi,multi,sse")
4306    (set_attr "mode" "SF,SF,SF,SF,DF")])
4307
4308 (define_insn "*truncdfsf2_2"
4309   [(set (match_operand:SF 0 "nonimmediate_operand" "=Y,!m")
4310         (float_truncate:SF
4311          (match_operand:DF 1 "nonimmediate_operand" "mY,f")))]
4312   "TARGET_80387 && TARGET_SSE2
4313    && (GET_CODE (operands[0]) != MEM || GET_CODE (operands[1]) != MEM)"
4314 {
4315   switch (which_alternative)
4316     {
4317     case 0:
4318       return "cvtsd2ss\t{%1, %0|%0, %1}";
4319     case 1:
4320       if (find_regno_note (insn, REG_DEAD, REGNO (operands[1])))
4321         return "fstp%z0\t%y0";
4322       else
4323         return "fst%z0\t%y0";
4324     default:
4325       abort ();
4326     }
4327 }
4328   [(set_attr "type" "sse,fmov")
4329    (set_attr "mode" "DF,SF")])
4330
4331 (define_insn "truncdfsf2_3"
4332   [(set (match_operand:SF 0 "memory_operand" "=m")
4333         (float_truncate:SF
4334          (match_operand:DF 1 "register_operand" "f")))]
4335   "TARGET_80387"
4336 {
4337   if (find_regno_note (insn, REG_DEAD, REGNO (operands[1])))
4338     return "fstp%z0\t%y0";
4339   else
4340     return "fst%z0\t%y0";
4341 }
4342   [(set_attr "type" "fmov")
4343    (set_attr "mode" "SF")])
4344
4345 (define_insn "truncdfsf2_sse_only"
4346   [(set (match_operand:SF 0 "register_operand" "=Y")
4347         (float_truncate:SF
4348          (match_operand:DF 1 "nonimmediate_operand" "mY")))]
4349   "!TARGET_80387 && TARGET_SSE2"
4350   "cvtsd2ss\t{%1, %0|%0, %1}"
4351   [(set_attr "type" "sse")
4352    (set_attr "mode" "DF")])
4353
4354 (define_split
4355   [(set (match_operand:SF 0 "memory_operand" "")
4356         (float_truncate:SF
4357          (match_operand:DF 1 "register_operand" "")))
4358    (clobber (match_operand:SF 2 "memory_operand" ""))]
4359   "TARGET_80387"
4360   [(set (match_dup 0) (float_truncate:SF (match_dup 1)))]
4361   "")
4362
4363 (define_split
4364   [(set (match_operand:SF 0 "nonimmediate_operand" "")
4365         (float_truncate:SF
4366          (match_operand:DF 1 "nonimmediate_operand" "")))
4367    (clobber (match_operand 2 "" ""))]
4368   "TARGET_80387 && reload_completed
4369    && !FP_REG_P (operands[0]) && !FP_REG_P (operands[1])"
4370   [(set (match_dup 0) (float_truncate:SF (match_dup 1)))]
4371   "")
4372
4373 (define_split
4374   [(set (match_operand:SF 0 "register_operand" "")
4375         (float_truncate:SF
4376          (match_operand:DF 1 "register_operand" "")))
4377    (clobber (match_operand:SF 2 "memory_operand" ""))]
4378   "TARGET_80387 && reload_completed
4379    && FP_REG_P (operands[1])"
4380   [(set (match_dup 2) (float_truncate:SF (match_dup 1)))
4381    (set (match_dup 0) (match_dup 2))]
4382   "")
4383
4384 (define_expand "truncxfsf2"
4385   [(parallel [(set (match_operand:SF 0 "nonimmediate_operand" "")
4386                    (float_truncate:SF
4387                     (match_operand:XF 1 "register_operand" "")))
4388               (clobber (match_dup 2))])]
4389   "!TARGET_64BIT && TARGET_80387"
4390   "operands[2] = assign_386_stack_local (SFmode, 0);")
4391
4392 (define_insn "*truncxfsf2_1"
4393   [(set (match_operand:SF 0 "nonimmediate_operand" "=m,?f#rx,?r#fx,?x#rf")
4394         (float_truncate:SF
4395          (match_operand:XF 1 "register_operand" "f,f,f,f")))
4396    (clobber (match_operand:SF 2 "memory_operand" "=X,m,m,m"))]
4397   "!TARGET_64BIT && TARGET_80387"
4398 {
4399   switch (which_alternative)
4400     {
4401     case 0:
4402       if (find_regno_note (insn, REG_DEAD, REGNO (operands[1])))
4403         return "fstp%z0\t%y0";
4404       else
4405         return "fst%z0\t%y0";
4406     default:
4407       abort();
4408     }
4409 }
4410   [(set_attr "type" "fmov,multi,multi,multi")
4411    (set_attr "mode" "SF")])
4412
4413 (define_insn "*truncxfsf2_2"
4414   [(set (match_operand:SF 0 "memory_operand" "=m")
4415         (float_truncate:SF
4416          (match_operand:XF 1 "register_operand" "f")))]
4417   "!TARGET_64BIT && TARGET_80387"
4418 {
4419   if (find_regno_note (insn, REG_DEAD, REGNO (operands[1])))
4420     return "fstp%z0\t%y0";
4421   else
4422     return "fst%z0\t%y0";
4423 }
4424   [(set_attr "type" "fmov")
4425    (set_attr "mode" "SF")])
4426
4427 (define_split
4428   [(set (match_operand:SF 0 "memory_operand" "")
4429         (float_truncate:SF
4430          (match_operand:XF 1 "register_operand" "")))
4431    (clobber (match_operand:SF 2 "memory_operand" ""))]
4432   "TARGET_80387"
4433   [(set (match_dup 0) (float_truncate:SF (match_dup 1)))]
4434   "")
4435
4436 (define_split
4437   [(set (match_operand:SF 0 "register_operand" "")
4438         (float_truncate:SF
4439          (match_operand:XF 1 "register_operand" "")))
4440    (clobber (match_operand:SF 2 "memory_operand" ""))]
4441   "TARGET_80387 && reload_completed"
4442   [(set (match_dup 2) (float_truncate:SF (match_dup 1)))
4443    (set (match_dup 0) (match_dup 2))]
4444   "")
4445
4446 (define_expand "trunctfsf2"
4447   [(parallel [(set (match_operand:SF 0 "nonimmediate_operand" "")
4448                    (float_truncate:SF
4449                     (match_operand:TF 1 "register_operand" "")))
4450               (clobber (match_dup 2))])]
4451   "TARGET_80387"
4452   "operands[2] = assign_386_stack_local (SFmode, 0);")
4453
4454 (define_insn "*trunctfsf2_1"
4455   [(set (match_operand:SF 0 "nonimmediate_operand" "=m,?f#rx,?r#fx,?x#rf")
4456         (float_truncate:SF
4457          (match_operand:TF 1 "register_operand" "f,f,f,f")))
4458    (clobber (match_operand:SF 2 "memory_operand" "=X,m,m,m"))]
4459   "TARGET_80387"
4460 {
4461   switch (which_alternative)
4462     {
4463     case 0:
4464       if (find_regno_note (insn, REG_DEAD, REGNO (operands[1])))
4465         return "fstp%z0\t%y0";
4466       else
4467         return "fst%z0\t%y0";
4468     default:
4469       abort();
4470     }
4471 }
4472   [(set_attr "type" "fmov,multi,multi,multi")
4473    (set_attr "mode" "SF")])
4474
4475 (define_insn "*trunctfsf2_2"
4476   [(set (match_operand:SF 0 "memory_operand" "=m")
4477         (float_truncate:SF
4478          (match_operand:TF 1 "register_operand" "f")))]
4479   "TARGET_80387"
4480 {
4481   if (find_regno_note (insn, REG_DEAD, REGNO (operands[1])))
4482     return "fstp%z0\t%y0";
4483   else
4484     return "fst%z0\t%y0";
4485 }
4486   [(set_attr "type" "fmov")
4487    (set_attr "mode" "SF")])
4488
4489 (define_split
4490   [(set (match_operand:SF 0 "memory_operand" "")
4491         (float_truncate:SF
4492          (match_operand:TF 1 "register_operand" "")))
4493    (clobber (match_operand:SF 2 "memory_operand" ""))]
4494   "TARGET_80387"
4495   [(set (match_dup 0) (float_truncate:SF (match_dup 1)))]
4496   "")
4497
4498 (define_split
4499   [(set (match_operand:SF 0 "register_operand" "")
4500         (float_truncate:SF
4501          (match_operand:TF 1 "register_operand" "")))
4502    (clobber (match_operand:SF 2 "memory_operand" ""))]
4503   "TARGET_80387 && reload_completed"
4504   [(set (match_dup 2) (float_truncate:SF (match_dup 1)))
4505    (set (match_dup 0) (match_dup 2))]
4506   "")
4507
4508
4509 (define_expand "truncxfdf2"
4510   [(parallel [(set (match_operand:DF 0 "nonimmediate_operand" "")
4511                    (float_truncate:DF
4512                     (match_operand:XF 1 "register_operand" "")))
4513               (clobber (match_dup 2))])]
4514   "!TARGET_64BIT && TARGET_80387"
4515   "operands[2] = assign_386_stack_local (DFmode, 0);")
4516
4517 (define_insn "*truncxfdf2_1"
4518   [(set (match_operand:DF 0 "nonimmediate_operand" "=m,?f#rY,?r#fY,?Y#rf")
4519         (float_truncate:DF
4520          (match_operand:XF 1 "register_operand" "f,f,f,f")))
4521    (clobber (match_operand:DF 2 "memory_operand" "=X,m,m,m"))]
4522   "!TARGET_64BIT && TARGET_80387"
4523 {
4524   switch (which_alternative)
4525     {
4526     case 0:
4527       if (find_regno_note (insn, REG_DEAD, REGNO (operands[1])))
4528         return "fstp%z0\t%y0";
4529       else
4530         return "fst%z0\t%y0";
4531     default:
4532       abort();
4533     }
4534   abort ();
4535 }
4536   [(set_attr "type" "fmov,multi,multi,multi")
4537    (set_attr "mode" "DF")])
4538
4539 (define_insn "*truncxfdf2_2"
4540   [(set (match_operand:DF 0 "memory_operand" "=m")
4541         (float_truncate:DF
4542           (match_operand:XF 1 "register_operand" "f")))]
4543   "!TARGET_64BIT && TARGET_80387"
4544 {
4545   if (find_regno_note (insn, REG_DEAD, REGNO (operands[1])))
4546     return "fstp%z0\t%y0";
4547   else
4548     return "fst%z0\t%y0";
4549 }
4550   [(set_attr "type" "fmov")
4551    (set_attr "mode" "DF")])
4552
4553 (define_split
4554   [(set (match_operand:DF 0 "memory_operand" "")
4555         (float_truncate:DF
4556          (match_operand:XF 1 "register_operand" "")))
4557    (clobber (match_operand:DF 2 "memory_operand" ""))]
4558   "TARGET_80387"
4559   [(set (match_dup 0) (float_truncate:DF (match_dup 1)))]
4560   "")
4561
4562 (define_split
4563   [(set (match_operand:DF 0 "register_operand" "")
4564         (float_truncate:DF
4565          (match_operand:XF 1 "register_operand" "")))
4566    (clobber (match_operand:DF 2 "memory_operand" ""))]
4567   "TARGET_80387 && reload_completed"
4568   [(set (match_dup 2) (float_truncate:DF (match_dup 1)))
4569    (set (match_dup 0) (match_dup 2))]
4570   "")
4571
4572 (define_expand "trunctfdf2"
4573   [(parallel [(set (match_operand:DF 0 "nonimmediate_operand" "")
4574                    (float_truncate:DF
4575                     (match_operand:TF 1 "register_operand" "")))
4576               (clobber (match_dup 2))])]
4577   "TARGET_80387"
4578   "operands[2] = assign_386_stack_local (DFmode, 0);")
4579
4580 (define_insn "*trunctfdf2_1"
4581   [(set (match_operand:DF 0 "nonimmediate_operand" "=m,?f#rY,?r#fY,?Y#rf")
4582         (float_truncate:DF
4583          (match_operand:TF 1 "register_operand" "f,f,f,f")))
4584    (clobber (match_operand:DF 2 "memory_operand" "=X,m,m,m"))]
4585   "TARGET_80387"
4586 {
4587   switch (which_alternative)
4588     {
4589     case 0:
4590       if (find_regno_note (insn, REG_DEAD, REGNO (operands[1])))
4591         return "fstp%z0\t%y0";
4592       else
4593         return "fst%z0\t%y0";
4594     default:
4595       abort();
4596     }
4597   abort ();
4598 }
4599   [(set_attr "type" "fmov,multi,multi,multi")
4600    (set_attr "mode" "DF")])
4601
4602         (define_insn "*trunctfdf2_2"
4603   [(set (match_operand:DF 0 "memory_operand" "=m")
4604         (float_truncate:DF
4605           (match_operand:TF 1 "register_operand" "f")))]
4606   "TARGET_80387"
4607 {
4608   if (find_regno_note (insn, REG_DEAD, REGNO (operands[1])))
4609     return "fstp%z0\t%y0";
4610   else
4611     return "fst%z0\t%y0";
4612 }
4613   [(set_attr "type" "fmov")
4614    (set_attr "mode" "DF")])
4615
4616 (define_split
4617   [(set (match_operand:DF 0 "memory_operand" "")
4618         (float_truncate:DF
4619          (match_operand:TF 1 "register_operand" "")))
4620    (clobber (match_operand:DF 2 "memory_operand" ""))]
4621   "TARGET_80387"
4622   [(set (match_dup 0) (float_truncate:DF (match_dup 1)))]
4623   "")
4624
4625 (define_split
4626   [(set (match_operand:DF 0 "register_operand" "")
4627         (float_truncate:DF
4628          (match_operand:TF 1 "register_operand" "")))
4629    (clobber (match_operand:DF 2 "memory_operand" ""))]
4630   "TARGET_80387 && reload_completed"
4631   [(set (match_dup 2) (float_truncate:DF (match_dup 1)))
4632    (set (match_dup 0) (match_dup 2))]
4633   "")
4634
4635 \f
4636 ;; %%% Break up all these bad boys.
4637
4638 ;; Signed conversion to DImode.
4639
4640 (define_expand "fix_truncxfdi2"
4641   [(set (match_operand:DI 0 "nonimmediate_operand" "")
4642         (fix:DI (match_operand:XF 1 "register_operand" "")))]
4643   "!TARGET_64BIT && TARGET_80387"
4644   "")
4645
4646 (define_expand "fix_trunctfdi2"
4647   [(set (match_operand:DI 0 "nonimmediate_operand" "")
4648         (fix:DI (match_operand:TF 1 "register_operand" "")))]
4649   "TARGET_80387"
4650   "")
4651
4652 (define_expand "fix_truncdfdi2"
4653   [(set (match_operand:DI 0 "nonimmediate_operand" "")
4654         (fix:DI (match_operand:DF 1 "register_operand" "")))]
4655   "TARGET_80387 || (TARGET_SSE2 && TARGET_64BIT)"
4656 {
4657   if (TARGET_64BIT && TARGET_SSE2)
4658    {
4659      rtx out = REG_P (operands[0]) ? operands[0] : gen_reg_rtx (DImode);
4660      emit_insn (gen_fix_truncdfdi_sse (out, operands[1]));
4661      if (out != operands[0])
4662         emit_move_insn (operands[0], out);
4663      DONE;
4664    }
4665 })
4666
4667 (define_expand "fix_truncsfdi2"
4668   [(set (match_operand:DI 0 "nonimmediate_operand" "")
4669         (fix:DI (match_operand:SF 1 "register_operand" "")))]
4670   "TARGET_80387 || (TARGET_SSE && TARGET_64BIT)"
4671 {
4672   if (TARGET_SSE && TARGET_64BIT)
4673    {
4674      rtx out = REG_P (operands[0]) ? operands[0] : gen_reg_rtx (DImode);
4675      emit_insn (gen_fix_truncsfdi_sse (out, operands[1]));
4676      if (out != operands[0])
4677         emit_move_insn (operands[0], out);
4678      DONE;
4679    }
4680 })
4681
4682 ;; See the comments in i386.h near OPTIMIZE_MODE_SWITCHING for the description
4683 ;; of the machinery.
4684 (define_insn_and_split "*fix_truncdi_1"
4685   [(set (match_operand:DI 0 "nonimmediate_operand" "=m,?r")
4686         (fix:DI (match_operand 1 "register_operand" "f,f")))]
4687   "TARGET_80387 && FLOAT_MODE_P (GET_MODE (operands[1]))
4688    && !reload_completed && !reload_in_progress
4689    && (!SSE_FLOAT_MODE_P (GET_MODE (operands[1])) || !TARGET_64BIT)"
4690   "#"
4691   "&& 1"
4692   [(const_int 0)]
4693 {
4694   operands[2] = assign_386_stack_local (HImode, 1);
4695   operands[3] = assign_386_stack_local (HImode, 2);
4696   if (memory_operand (operands[0], VOIDmode))
4697     emit_insn (gen_fix_truncdi_memory (operands[0], operands[1],
4698                                        operands[2], operands[3]));
4699   else
4700     {
4701       operands[4] = assign_386_stack_local (DImode, 0);
4702       emit_insn (gen_fix_truncdi_nomemory (operands[0], operands[1],
4703                                            operands[2], operands[3],
4704                                            operands[4]));
4705     }
4706   DONE;
4707 }
4708   [(set_attr "type" "fistp")])
4709
4710 (define_insn "fix_truncdi_nomemory"
4711   [(set (match_operand:DI 0 "nonimmediate_operand" "=m,?r")
4712         (fix:DI (match_operand 1 "register_operand" "f,f")))
4713    (use (match_operand:HI 2 "memory_operand" "m,m"))
4714    (use (match_operand:HI 3 "memory_operand" "m,m"))
4715    (clobber (match_operand:DI 4 "memory_operand" "=m,m"))
4716    (clobber (match_scratch:DF 5 "=&1f,&1f"))]
4717   "TARGET_80387 && FLOAT_MODE_P (GET_MODE (operands[1]))
4718    && (!SSE_FLOAT_MODE_P (GET_MODE (operands[1])) || !TARGET_64BIT)"
4719   "#"
4720   [(set_attr "type" "fistp")])
4721
4722 (define_insn "fix_truncdi_memory"
4723   [(set (match_operand:DI 0 "memory_operand" "=m")
4724         (fix:DI (match_operand 1 "register_operand" "f")))
4725    (use (match_operand:HI 2 "memory_operand" "m"))
4726    (use (match_operand:HI 3 "memory_operand" "m"))
4727    (clobber (match_scratch:DF 4 "=&1f"))]
4728   "TARGET_80387 && FLOAT_MODE_P (GET_MODE (operands[1]))
4729    && (!SSE_FLOAT_MODE_P (GET_MODE (operands[1])) || !TARGET_64BIT)"
4730   "* operands[5] = operands[4]; return output_fix_trunc (insn, operands);"
4731   [(set_attr "type" "fistp")])
4732
4733 (define_split 
4734   [(set (match_operand:DI 0 "register_operand" "")
4735         (fix:DI (match_operand 1 "register_operand" "")))
4736    (use (match_operand:HI 2 "memory_operand" ""))
4737    (use (match_operand:HI 3 "memory_operand" ""))
4738    (clobber (match_operand:DI 4 "memory_operand" ""))
4739    (clobber (match_scratch 5 ""))]
4740   "reload_completed"
4741   [(parallel [(set (match_dup 4) (fix:DI (match_dup 1)))
4742               (use (match_dup 2))
4743               (use (match_dup 3))
4744               (clobber (match_dup 5))])
4745    (set (match_dup 0) (match_dup 4))]
4746   "")
4747
4748 (define_split 
4749   [(set (match_operand:DI 0 "memory_operand" "")
4750         (fix:DI (match_operand 1 "register_operand" "")))
4751    (use (match_operand:HI 2 "memory_operand" ""))
4752    (use (match_operand:HI 3 "memory_operand" ""))
4753    (clobber (match_operand:DI 4 "memory_operand" ""))
4754    (clobber (match_scratch 5 ""))]
4755   "reload_completed"
4756   [(parallel [(set (match_dup 0) (fix:DI (match_dup 1)))
4757               (use (match_dup 2))
4758               (use (match_dup 3))
4759               (clobber (match_dup 5))])]
4760   "")
4761
4762 ;; When SSE available, it is always faster to use it!
4763 (define_insn "fix_truncsfdi_sse"
4764   [(set (match_operand:DI 0 "register_operand" "=r")
4765         (fix:DI (match_operand:SF 1 "nonimmediate_operand" "xm")))]
4766   "TARGET_64BIT && TARGET_SSE"
4767   "cvttss2si{q}\t{%1, %0|%0, %1}"
4768   [(set_attr "type" "sse")])
4769
4770 (define_insn "fix_truncdfdi_sse"
4771   [(set (match_operand:DI 0 "register_operand" "=r")
4772         (fix:DI (match_operand:DF 1 "nonimmediate_operand" "Ym")))]
4773   "TARGET_64BIT && TARGET_SSE2"
4774   "cvttsd2si{q}\t{%1, %0|%0, %1}"
4775   [(set_attr "type" "sse")])
4776
4777 ;; Signed conversion to SImode.
4778
4779 (define_expand "fix_truncxfsi2"
4780   [(set (match_operand:SI 0 "nonimmediate_operand" "")
4781         (fix:SI (match_operand:XF 1 "register_operand" "")))]
4782   "!TARGET_64BIT && TARGET_80387"
4783   "")
4784
4785 (define_expand "fix_trunctfsi2"
4786   [(set (match_operand:SI 0 "nonimmediate_operand" "")
4787         (fix:SI (match_operand:TF 1 "register_operand" "")))]
4788   "TARGET_80387"
4789   "")
4790
4791 (define_expand "fix_truncdfsi2"
4792   [(set (match_operand:SI 0 "nonimmediate_operand" "")
4793         (fix:SI (match_operand:DF 1 "register_operand" "")))]
4794   "TARGET_80387 || TARGET_SSE2"
4795 {
4796   if (TARGET_SSE2)
4797    {
4798      rtx out = REG_P (operands[0]) ? operands[0] : gen_reg_rtx (SImode);
4799      emit_insn (gen_fix_truncdfsi_sse (out, operands[1]));
4800      if (out != operands[0])
4801         emit_move_insn (operands[0], out);
4802      DONE;
4803    }
4804 })
4805
4806 (define_expand "fix_truncsfsi2"
4807   [(set (match_operand:SI 0 "nonimmediate_operand" "")
4808         (fix:SI (match_operand:SF 1 "register_operand" "")))]
4809   "TARGET_80387 || TARGET_SSE"
4810 {
4811   if (TARGET_SSE)
4812    {
4813      rtx out = REG_P (operands[0]) ? operands[0] : gen_reg_rtx (SImode);
4814      emit_insn (gen_fix_truncsfsi_sse (out, operands[1]));
4815      if (out != operands[0])
4816         emit_move_insn (operands[0], out);
4817      DONE;
4818    }
4819 })
4820
4821 ;; See the comments in i386.h near OPTIMIZE_MODE_SWITCHING for the description
4822 ;; of the machinery.
4823 (define_insn_and_split "*fix_truncsi_1"
4824   [(set (match_operand:SI 0 "nonimmediate_operand" "=m,?r")
4825         (fix:SI (match_operand 1 "register_operand" "f,f")))]
4826   "TARGET_80387 && FLOAT_MODE_P (GET_MODE (operands[1]))
4827    && !reload_completed && !reload_in_progress
4828    && !SSE_FLOAT_MODE_P (GET_MODE (operands[1]))"
4829   "#"
4830   "&& 1"
4831   [(const_int 0)]
4832 {
4833   operands[2] = assign_386_stack_local (HImode, 1);
4834   operands[3] = assign_386_stack_local (HImode, 2);
4835   if (memory_operand (operands[0], VOIDmode))
4836     emit_insn (gen_fix_truncsi_memory (operands[0], operands[1],
4837                                        operands[2], operands[3]));
4838   else
4839     {
4840       operands[4] = assign_386_stack_local (SImode, 0);
4841       emit_insn (gen_fix_truncsi_nomemory (operands[0], operands[1],
4842                                            operands[2], operands[3],
4843                                            operands[4]));
4844     }
4845   DONE;
4846 }
4847   [(set_attr "type" "fistp")])
4848
4849 (define_insn "fix_truncsi_nomemory"
4850   [(set (match_operand:SI 0 "nonimmediate_operand" "=m,?r")
4851         (fix:SI (match_operand 1 "register_operand" "f,f")))
4852    (use (match_operand:HI 2 "memory_operand" "m,m"))
4853    (use (match_operand:HI 3 "memory_operand" "m,m"))
4854    (clobber (match_operand:SI 4 "memory_operand" "=m,m"))]
4855   "TARGET_80387 && FLOAT_MODE_P (GET_MODE (operands[1]))
4856    && !SSE_FLOAT_MODE_P (GET_MODE (operands[1]))"
4857   "#"
4858   [(set_attr "type" "fistp")])
4859
4860 (define_insn "fix_truncsi_memory"
4861   [(set (match_operand:SI 0 "memory_operand" "=m")
4862         (fix:SI (match_operand 1 "register_operand" "f")))
4863    (use (match_operand:HI 2 "memory_operand" "m"))
4864    (use (match_operand:HI 3 "memory_operand" "m"))]
4865   "TARGET_80387 && FLOAT_MODE_P (GET_MODE (operands[1]))
4866    && !SSE_FLOAT_MODE_P (GET_MODE (operands[1]))"
4867   "* return output_fix_trunc (insn, operands);"
4868   [(set_attr "type" "fistp")])
4869
4870 ;; When SSE available, it is always faster to use it!
4871 (define_insn "fix_truncsfsi_sse"
4872   [(set (match_operand:SI 0 "register_operand" "=r")
4873         (fix:SI (match_operand:SF 1 "nonimmediate_operand" "xm")))]
4874   "TARGET_SSE"
4875   "cvttss2si\t{%1, %0|%0, %1}"
4876   [(set_attr "type" "sse")])
4877
4878 (define_insn "fix_truncdfsi_sse"
4879   [(set (match_operand:SI 0 "register_operand" "=r")
4880         (fix:SI (match_operand:DF 1 "nonimmediate_operand" "Ym")))]
4881   "TARGET_SSE2"
4882   "cvttsd2si\t{%1, %0|%0, %1}"
4883   [(set_attr "type" "sse")])
4884
4885 (define_split 
4886   [(set (match_operand:SI 0 "register_operand" "")
4887         (fix:SI (match_operand 1 "register_operand" "")))
4888    (use (match_operand:HI 2 "memory_operand" ""))
4889    (use (match_operand:HI 3 "memory_operand" ""))
4890    (clobber (match_operand:SI 4 "memory_operand" ""))]
4891   "reload_completed"
4892   [(parallel [(set (match_dup 4) (fix:SI (match_dup 1)))
4893               (use (match_dup 2))
4894               (use (match_dup 3))])
4895    (set (match_dup 0) (match_dup 4))]
4896   "")
4897
4898 (define_split 
4899   [(set (match_operand:SI 0 "memory_operand" "")
4900         (fix:SI (match_operand 1 "register_operand" "")))
4901    (use (match_operand:HI 2 "memory_operand" ""))
4902    (use (match_operand:HI 3 "memory_operand" ""))
4903    (clobber (match_operand:SI 4 "memory_operand" ""))]
4904   "reload_completed"
4905   [(parallel [(set (match_dup 0) (fix:SI (match_dup 1)))
4906               (use (match_dup 2))
4907               (use (match_dup 3))])]
4908   "")
4909
4910 ;; Signed conversion to HImode.
4911
4912 (define_expand "fix_truncxfhi2"
4913   [(set (match_operand:HI 0 "nonimmediate_operand" "")
4914         (fix:HI (match_operand:XF 1 "register_operand" "")))]
4915   "!TARGET_64BIT && TARGET_80387"
4916   "")
4917
4918 (define_expand "fix_trunctfhi2"
4919   [(set (match_operand:HI 0 "nonimmediate_operand" "")
4920         (fix:HI (match_operand:TF 1 "register_operand" "")))]
4921   "TARGET_80387"
4922   "")
4923
4924 (define_expand "fix_truncdfhi2"
4925   [(set (match_operand:HI 0 "nonimmediate_operand" "")
4926         (fix:HI (match_operand:DF 1 "register_operand" "")))]
4927   "TARGET_80387 && !TARGET_SSE2"
4928   "")
4929
4930 (define_expand "fix_truncsfhi2"
4931   [(set (match_operand:HI 0 "nonimmediate_operand" "")
4932         (fix:HI (match_operand:SF 1 "register_operand" "")))]
4933   "TARGET_80387 && !TARGET_SSE"
4934   "")
4935
4936 ;; See the comments in i386.h near OPTIMIZE_MODE_SWITCHING for the description
4937 ;; of the machinery.
4938 (define_insn_and_split "*fix_trunchi_1"
4939   [(set (match_operand:HI 0 "nonimmediate_operand" "=m,?r")
4940         (fix:HI (match_operand 1 "register_operand" "f,f")))]
4941   "TARGET_80387 && FLOAT_MODE_P (GET_MODE (operands[1]))
4942    && !reload_completed && !reload_in_progress
4943    && !SSE_FLOAT_MODE_P (GET_MODE (operands[1]))"
4944   "#"
4945   ""
4946   [(const_int 0)]
4947 {
4948   operands[2] = assign_386_stack_local (HImode, 1);
4949   operands[3] = assign_386_stack_local (HImode, 2);
4950   if (memory_operand (operands[0], VOIDmode))
4951     emit_insn (gen_fix_trunchi_memory (operands[0], operands[1],
4952                                        operands[2], operands[3]));
4953   else
4954     {
4955       operands[4] = assign_386_stack_local (HImode, 0);
4956       emit_insn (gen_fix_trunchi_nomemory (operands[0], operands[1],
4957                                            operands[2], operands[3],
4958                                            operands[4]));
4959     }
4960   DONE;
4961 }
4962   [(set_attr "type" "fistp")])
4963
4964 (define_insn "fix_trunchi_nomemory"
4965   [(set (match_operand:HI 0 "nonimmediate_operand" "=m,?r")
4966         (fix:HI (match_operand 1 "register_operand" "f,f")))
4967    (use (match_operand:HI 2 "memory_operand" "m,m"))
4968    (use (match_operand:HI 3 "memory_operand" "m,m"))
4969    (clobber (match_operand:HI 4 "memory_operand" "=m,m"))]
4970   "TARGET_80387 && FLOAT_MODE_P (GET_MODE (operands[1]))
4971    && !SSE_FLOAT_MODE_P (GET_MODE (operands[1]))"
4972   "#"
4973   [(set_attr "type" "fistp")])
4974
4975 (define_insn "fix_trunchi_memory"
4976   [(set (match_operand:HI 0 "memory_operand" "=m")
4977         (fix:HI (match_operand 1 "register_operand" "f")))
4978    (use (match_operand:HI 2 "memory_operand" "m"))
4979    (use (match_operand:HI 3 "memory_operand" "m"))]
4980   "TARGET_80387 && FLOAT_MODE_P (GET_MODE (operands[1]))
4981    && !SSE_FLOAT_MODE_P (GET_MODE (operands[1]))"
4982   "* return output_fix_trunc (insn, operands);"
4983   [(set_attr "type" "fistp")])
4984
4985 (define_split 
4986   [(set (match_operand:HI 0 "memory_operand" "")
4987         (fix:HI (match_operand 1 "register_operand" "")))
4988    (use (match_operand:HI 2 "memory_operand" ""))
4989    (use (match_operand:HI 3 "memory_operand" ""))
4990    (clobber (match_operand:HI 4 "memory_operand" ""))]
4991   "reload_completed"
4992   [(parallel [(set (match_dup 0) (fix:HI (match_dup 1)))
4993               (use (match_dup 2))
4994               (use (match_dup 3))])]
4995   "")
4996
4997 (define_split 
4998   [(set (match_operand:HI 0 "register_operand" "")
4999         (fix:HI (match_operand 1 "register_operand" "")))
5000    (use (match_operand:HI 2 "memory_operand" ""))
5001    (use (match_operand:HI 3 "memory_operand" ""))
5002    (clobber (match_operand:HI 4 "memory_operand" ""))]
5003   "reload_completed"
5004   [(parallel [(set (match_dup 4) (fix:HI (match_dup 1)))
5005               (use (match_dup 2))
5006               (use (match_dup 3))
5007               (clobber (match_dup 4))])
5008    (set (match_dup 0) (match_dup 4))]
5009   "")
5010
5011 ;; %% Not used yet.
5012 (define_insn "x86_fnstcw_1"
5013   [(set (match_operand:HI 0 "memory_operand" "=m")
5014         (unspec:HI [(reg:HI 18)] 11))]
5015   "TARGET_80387"
5016   "fnstcw\t%0"
5017   [(set_attr "length" "2")
5018    (set_attr "mode" "HI")
5019    (set_attr "i387" "1")
5020    (set_attr "ppro_uops" "few")])
5021
5022 (define_insn "x86_fldcw_1"
5023   [(set (reg:HI 18)
5024         (unspec:HI [(match_operand:HI 0 "memory_operand" "m")] 12))]
5025   "TARGET_80387"
5026   "fldcw\t%0"
5027   [(set_attr "length" "2")
5028    (set_attr "mode" "HI")
5029    (set_attr "i387" "1")
5030    (set_attr "athlon_decode" "vector")
5031    (set_attr "ppro_uops" "few")])
5032 \f
5033 ;; Conversion between fixed point and floating point.
5034
5035 ;; Even though we only accept memory inputs, the backend _really_
5036 ;; wants to be able to do this between registers.
5037
5038 (define_insn "floathisf2"
5039   [(set (match_operand:SF 0 "register_operand" "=f,f")
5040         (float:SF (match_operand:HI 1 "nonimmediate_operand" "m,r")))]
5041   "TARGET_80387 && !TARGET_SSE"
5042   "@
5043    fild%z1\t%1
5044    #"
5045   [(set_attr "type" "fmov,multi")
5046    (set_attr "mode" "SF")
5047    (set_attr "fp_int_src" "true")])
5048
5049 (define_expand "floatsisf2"
5050   [(set (match_operand:SF 0 "register_operand" "")
5051         (float:SF (match_operand:SI 1 "nonimmediate_operand" "")))]
5052   "TARGET_SSE || TARGET_80387"
5053   "")
5054
5055 (define_insn "*floatsisf2_i387"
5056   [(set (match_operand:SF 0 "register_operand" "=f,?f,x")
5057         (float:SF (match_operand:SI 1 "nonimmediate_operand" "m,r,mr")))]
5058   "TARGET_80387 && (!TARGET_SSE || TARGET_MIX_SSE_I387)"
5059   "@
5060    fild%z1\t%1
5061    #
5062    cvtsi2ss\t{%1, %0|%0, %1}"
5063   [(set_attr "type" "fmov,multi,sse")
5064    (set_attr "mode" "SF")
5065    (set_attr "fp_int_src" "true")])
5066
5067 (define_insn "*floatsisf2_sse"
5068   [(set (match_operand:SF 0 "register_operand" "=x")
5069         (float:SF (match_operand:SI 1 "nonimmediate_operand" "mr")))]
5070   "TARGET_SSE"
5071   "cvtsi2ss\t{%1, %0|%0, %1}"
5072   [(set_attr "type" "sse")
5073    (set_attr "mode" "SF")
5074    (set_attr "fp_int_src" "true")])
5075
5076 (define_expand "floatdisf2"
5077   [(set (match_operand:SF 0 "register_operand" "")
5078         (float:SF (match_operand:DI 1 "nonimmediate_operand" "")))]
5079   "(TARGET_64BIT && TARGET_SSE) || TARGET_80387"
5080   "")
5081
5082 (define_insn "*floatdisf2_i387_only"
5083   [(set (match_operand:SF 0 "register_operand" "=f,?f")
5084         (float:SF (match_operand:DI 1 "nonimmediate_operand" "m,r")))]
5085   "TARGET_80387 && (!TARGET_SSE || !TARGET_64BIT || TARGET_MIX_SSE_I387)"
5086   "@
5087    fild%z1\t%1
5088    #"
5089   [(set_attr "type" "fmov,multi")
5090    (set_attr "mode" "SF")
5091    (set_attr "fp_int_src" "true")])
5092
5093 (define_insn "*floatdisf2_i387"
5094   [(set (match_operand:SF 0 "register_operand" "=f,?f,x")
5095         (float:SF (match_operand:DI 1 "nonimmediate_operand" "m,r,mr")))]
5096   "TARGET_64BIT && TARGET_80387 && (!TARGET_SSE || TARGET_MIX_SSE_I387)"
5097   "@
5098    fild%z1\t%1
5099    #
5100    cvtsi2ss{q}\t{%1, %0|%0, %1}"
5101   [(set_attr "type" "fmov,multi,sse")
5102    (set_attr "mode" "SF")
5103    (set_attr "fp_int_src" "true")])
5104
5105 (define_insn "*floatdisf2_sse"
5106   [(set (match_operand:SF 0 "register_operand" "=x")
5107         (float:SF (match_operand:DI 1 "nonimmediate_operand" "mr")))]
5108   "TARGET_64BIT && TARGET_SSE"
5109   "cvtsi2ss{q}\t{%1, %0|%0, %1}"
5110   [(set_attr "type" "sse")
5111    (set_attr "mode" "SF")
5112    (set_attr "fp_int_src" "true")])
5113
5114 (define_insn "floathidf2"
5115   [(set (match_operand:DF 0 "register_operand" "=f,f")
5116         (float:DF (match_operand:HI 1 "nonimmediate_operand" "m,r")))]
5117   "TARGET_80387 && !TARGET_SSE2"
5118   "@
5119    fild%z1\t%1
5120    #"
5121   [(set_attr "type" "fmov,multi")
5122    (set_attr "mode" "DF")
5123    (set_attr "fp_int_src" "true")])
5124
5125 (define_expand "floatsidf2"
5126   [(set (match_operand:DF 0 "register_operand" "")
5127         (float:DF (match_operand:SI 1 "nonimmediate_operand" "")))]
5128   ""
5129   "")
5130
5131 (define_insn "*floatsidf2_i387"
5132   [(set (match_operand:DF 0 "register_operand" "=f,?f,Y")
5133         (float:DF (match_operand:SI 1 "nonimmediate_operand" "m,r,mr")))]
5134   "TARGET_80387 && (!TARGET_SSE2 || TARGET_MIX_SSE_I387)"
5135   "@
5136    fild%z1\t%1
5137    #
5138    cvtsi2sd\t{%1, %0|%0, %1}"
5139   [(set_attr "type" "fmov,multi,sse")
5140    (set_attr "mode" "DF")
5141    (set_attr "fp_int_src" "true")])
5142
5143 (define_insn "*floatsidf2_sse"
5144   [(set (match_operand:DF 0 "register_operand" "=Y")
5145         (float:DF (match_operand:SI 1 "nonimmediate_operand" "mr")))]
5146   "TARGET_SSE2"
5147   "cvtsi2sd\t{%1, %0|%0, %1}"
5148   [(set_attr "type" "sse")
5149    (set_attr "mode" "DF")
5150    (set_attr "fp_int_src" "true")])
5151
5152 (define_expand "floatdidf2"
5153   [(set (match_operand:DF 0 "register_operand" "")
5154         (float:DF (match_operand:DI 1 "nonimmediate_operand" "")))]
5155   "(TARGET_64BIT && TARGET_SSE2) || TARGET_80387"
5156   "")
5157
5158 (define_insn "*floatdidf2_i387_only"
5159   [(set (match_operand:DF 0 "register_operand" "=f,?f")
5160         (float:DF (match_operand:DI 1 "nonimmediate_operand" "m,r")))]
5161   "TARGET_80387 && (!TARGET_SSE2 || !TARGET_64BIT)"
5162   "@
5163    fild%z1\t%1
5164    #"
5165   [(set_attr "type" "fmov,multi")
5166    (set_attr "mode" "DF")
5167    (set_attr "fp_int_src" "true")])
5168
5169 (define_insn "*floatdidf2_i387"
5170   [(set (match_operand:DF 0 "register_operand" "=f,?f,Y")
5171         (float:DF (match_operand:DI 1 "nonimmediate_operand" "m,r,mr")))]
5172   "TARGET_64BIT && TARGET_80387 && (!TARGET_SSE2 || TARGET_MIX_SSE_I387)"
5173   "@
5174    fild%z1\t%1
5175    #
5176    cvtsi2sd{q}\t{%1, %0|%0, %1}"
5177   [(set_attr "type" "fmov,multi,sse")
5178    (set_attr "mode" "DF")
5179    (set_attr "fp_int_src" "true")])
5180
5181 (define_insn "*floatdidf2_sse"
5182   [(set (match_operand:DF 0 "register_operand" "=Y")
5183         (float:DF (match_operand:DI 1 "nonimmediate_operand" "mr")))]
5184   "TARGET_SSE2"
5185   "cvtsi2sd{q}\t{%1, %0|%0, %1}"
5186   [(set_attr "type" "sse")
5187    (set_attr "mode" "DF")
5188    (set_attr "fp_int_src" "true")])
5189
5190 (define_insn "floathixf2"
5191   [(set (match_operand:XF 0 "register_operand" "=f,f")
5192         (float:XF (match_operand:HI 1 "nonimmediate_operand" "m,r")))]
5193   "!TARGET_64BIT && TARGET_80387"
5194   "@
5195    fild%z1\t%1
5196    #"
5197   [(set_attr "type" "fmov,multi")
5198    (set_attr "mode" "XF")
5199    (set_attr "fp_int_src" "true")])
5200
5201 (define_insn "floathitf2"
5202   [(set (match_operand:TF 0 "register_operand" "=f,f")
5203         (float:TF (match_operand:HI 1 "nonimmediate_operand" "m,r")))]
5204   "TARGET_80387"
5205   "@
5206    fild%z1\t%1
5207    #"
5208   [(set_attr "type" "fmov,multi")
5209    (set_attr "mode" "XF")
5210    (set_attr "fp_int_src" "true")])
5211
5212 (define_insn "floatsixf2"
5213   [(set (match_operand:XF 0 "register_operand" "=f,f")
5214         (float:XF (match_operand:SI 1 "nonimmediate_operand" "m,r")))]
5215   "!TARGET_64BIT && TARGET_80387"
5216   "@
5217    fild%z1\t%1
5218    #"
5219   [(set_attr "type" "fmov,multi")
5220    (set_attr "mode" "XF")
5221    (set_attr "fp_int_src" "true")])
5222
5223 (define_insn "floatsitf2"
5224   [(set (match_operand:TF 0 "register_operand" "=f,f")
5225         (float:TF (match_operand:SI 1 "nonimmediate_operand" "m,r")))]
5226   "TARGET_80387"
5227   "@
5228    fild%z1\t%1
5229    #"
5230   [(set_attr "type" "fmov,multi")
5231    (set_attr "mode" "XF")
5232    (set_attr "fp_int_src" "true")])
5233
5234 (define_insn "floatdixf2"
5235   [(set (match_operand:XF 0 "register_operand" "=f,f")
5236         (float:XF (match_operand:DI 1 "nonimmediate_operand" "m,r")))]
5237   "!TARGET_64BIT && TARGET_80387"
5238   "@
5239    fild%z1\t%1
5240    #"
5241   [(set_attr "type" "fmov,multi")
5242    (set_attr "mode" "XF")
5243    (set_attr "fp_int_src" "true")])
5244
5245 (define_insn "floatditf2"
5246   [(set (match_operand:TF 0 "register_operand" "=f,f")
5247         (float:TF (match_operand:DI 1 "nonimmediate_operand" "m,r")))]
5248   "TARGET_80387"
5249   "@
5250    fild%z1\t%1
5251    #"
5252   [(set_attr "type" "fmov,multi")
5253    (set_attr "mode" "XF")
5254    (set_attr "fp_int_src" "true")])
5255
5256 ;; %%% Kill these when reload knows how to do it.
5257 (define_split
5258   [(set (match_operand 0 "register_operand" "")
5259         (float (match_operand 1 "register_operand" "")))]
5260   "reload_completed && FLOAT_MODE_P (GET_MODE (operands[0]))
5261    && FP_REG_P (operands[0])"
5262   [(const_int 0)]
5263 {
5264   operands[2] = ix86_force_to_memory (GET_MODE (operands[1]), operands[1]);
5265   operands[2] = gen_rtx_FLOAT (GET_MODE (operands[0]), operands[2]);
5266   emit_insn (gen_rtx_SET (VOIDmode, operands[0], operands[2]));
5267   ix86_free_from_memory (GET_MODE (operands[1]));
5268   DONE;
5269 })
5270 \f
5271 ;; Add instructions
5272
5273 ;; %%% splits for addsidi3
5274 ;  [(set (match_operand:DI 0 "nonimmediate_operand" "")
5275 ;       (plus:DI (match_operand:DI 1 "general_operand" "")
5276 ;                (zero_extend:DI (match_operand:SI 2 "general_operand" ""))))]
5277
5278 (define_expand "adddi3"
5279   [(set (match_operand:DI 0 "nonimmediate_operand" "")
5280         (plus:DI (match_operand:DI 1 "nonimmediate_operand" "")
5281                  (match_operand:DI 2 "x86_64_general_operand" "")))
5282    (clobber (reg:CC 17))]
5283   ""
5284   "ix86_expand_binary_operator (PLUS, DImode, operands); DONE;")
5285
5286 (define_insn "*adddi3_1"
5287   [(set (match_operand:DI 0 "nonimmediate_operand" "=r,o")
5288         (plus:DI (match_operand:DI 1 "nonimmediate_operand" "%0,0")
5289                  (match_operand:DI 2 "general_operand" "roiF,riF")))
5290    (clobber (reg:CC 17))]
5291   "!TARGET_64BIT"
5292   "#")
5293
5294 (define_split
5295   [(set (match_operand:DI 0 "nonimmediate_operand" "")
5296         (plus:DI (match_operand:DI 1 "nonimmediate_operand" "")
5297                  (match_operand:DI 2 "general_operand" "")))
5298    (clobber (reg:CC 17))]
5299   "!TARGET_64BIT && reload_completed"
5300   [(parallel [(set (reg:CC 17) (unspec:CC [(match_dup 1) (match_dup 2)] 12))
5301               (set (match_dup 0) (plus:SI (match_dup 1) (match_dup 2)))])
5302    (parallel [(set (match_dup 3)
5303                    (plus:SI (plus:SI (ltu:SI (reg:CC 17) (const_int 0))
5304                                      (match_dup 4))
5305                             (match_dup 5)))
5306               (clobber (reg:CC 17))])]
5307   "split_di (operands+0, 1, operands+0, operands+3);
5308    split_di (operands+1, 1, operands+1, operands+4);
5309    split_di (operands+2, 1, operands+2, operands+5);")
5310
5311 (define_insn "*adddi3_carry_rex64"
5312   [(set (match_operand:DI 0 "nonimmediate_operand" "=rm,r")
5313           (plus:DI (plus:DI (ltu:DI (reg:CC 17) (const_int 0))
5314                             (match_operand:DI 1 "nonimmediate_operand" "%0,0"))
5315                    (match_operand:DI 2 "x86_64_general_operand" "re,rm")))
5316    (clobber (reg:CC 17))]
5317   "TARGET_64BIT && ix86_binary_operator_ok (PLUS, DImode, operands)"
5318   "adc{q}\t{%2, %0|%0, %2}"
5319   [(set_attr "type" "alu")
5320    (set_attr "pent_pair" "pu")
5321    (set_attr "mode" "DI")
5322    (set_attr "ppro_uops" "few")])
5323
5324 (define_insn "*adddi3_cc_rex64"
5325   [(set (reg:CC 17) (unspec:CC [(match_operand:DI 1 "nonimmediate_operand" "%0,0")
5326                                 (match_operand:DI 2 "x86_64_general_operand" "re,rm")] 12))
5327    (set (match_operand:DI 0 "nonimmediate_operand" "=rm,r")
5328         (plus:DI (match_dup 1) (match_dup 2)))]
5329   "TARGET_64BIT && ix86_binary_operator_ok (PLUS, DImode, operands)"
5330   "add{q}\t{%2, %0|%0, %2}"
5331   [(set_attr "type" "alu")
5332    (set_attr "mode" "DI")])
5333
5334 (define_insn "*addsi3_carry"
5335   [(set (match_operand:SI 0 "nonimmediate_operand" "=rm,r")
5336           (plus:SI (plus:SI (ltu:SI (reg:CC 17) (const_int 0))
5337                             (match_operand:SI 1 "nonimmediate_operand" "%0,0"))
5338                    (match_operand:SI 2 "general_operand" "ri,rm")))
5339    (clobber (reg:CC 17))]
5340   "ix86_binary_operator_ok (PLUS, SImode, operands)"
5341   "adc{l}\t{%2, %0|%0, %2}"
5342   [(set_attr "type" "alu")
5343    (set_attr "pent_pair" "pu")
5344    (set_attr "mode" "SI")
5345    (set_attr "ppro_uops" "few")])
5346
5347 (define_insn "*addsi3_carry_zext"
5348   [(set (match_operand:DI 0 "register_operand" "=r")
5349           (zero_extend:DI 
5350             (plus:SI (plus:SI (ltu:SI (reg:CC 17) (const_int 0))
5351                               (match_operand:SI 1 "nonimmediate_operand" "%0"))
5352                      (match_operand:SI 2 "general_operand" "rim"))))
5353    (clobber (reg:CC 17))]
5354   "TARGET_64BIT && ix86_binary_operator_ok (PLUS, SImode, operands)"
5355   "adc{l}\t{%2, %k0|%k0, %2}"
5356   [(set_attr "type" "alu")
5357    (set_attr "pent_pair" "pu")
5358    (set_attr "mode" "SI")
5359    (set_attr "ppro_uops" "few")])
5360
5361 (define_insn "*addsi3_cc"
5362   [(set (reg:CC 17) (unspec:CC [(match_operand:SI 1 "nonimmediate_operand" "%0,0")
5363                                 (match_operand:SI 2 "general_operand" "ri,rm")] 12))
5364    (set (match_operand:SI 0 "nonimmediate_operand" "=rm,r")
5365         (plus:SI (match_dup 1) (match_dup 2)))]
5366   "ix86_binary_operator_ok (PLUS, SImode, operands)"
5367   "add{l}\t{%2, %0|%0, %2}"
5368   [(set_attr "type" "alu")
5369    (set_attr "mode" "SI")])
5370
5371 (define_insn "addqi3_cc"
5372   [(set (reg:CC 17) (unspec:CC [(match_operand:QI 1 "nonimmediate_operand" "%0,0")
5373                                 (match_operand:QI 2 "general_operand" "qi,qm")] 12))
5374    (set (match_operand:QI 0 "nonimmediate_operand" "=qm,q")
5375         (plus:QI (match_dup 1) (match_dup 2)))]
5376   "ix86_binary_operator_ok (PLUS, QImode, operands)"
5377   "add{b}\t{%2, %0|%0, %2}"
5378   [(set_attr "type" "alu")
5379    (set_attr "mode" "QI")])
5380
5381 (define_expand "addsi3"
5382   [(parallel [(set (match_operand:SI 0 "nonimmediate_operand" "")
5383                    (plus:SI (match_operand:SI 1 "nonimmediate_operand" "")
5384                             (match_operand:SI 2 "general_operand" "")))
5385               (clobber (reg:CC 17))])]
5386   ""
5387   "ix86_expand_binary_operator (PLUS, SImode, operands); DONE;")
5388
5389 (define_insn "*lea_1"
5390   [(set (match_operand:SI 0 "register_operand" "=r")
5391         (match_operand:SI 1 "address_operand" "p"))]
5392   "!TARGET_64BIT"
5393   "lea{l}\t{%a1, %0|%0, %a1}"
5394   [(set_attr "type" "lea")
5395    (set_attr "mode" "SI")])
5396
5397 (define_insn "*lea_1_rex64"
5398   [(set (match_operand:SI 0 "register_operand" "=r")
5399         (subreg:SI (match_operand:DI 1 "address_operand" "p") 0))]
5400   "TARGET_64BIT"
5401   "lea{l}\t{%a1, %0|%0, %a1}"
5402   [(set_attr "type" "lea")
5403    (set_attr "mode" "SI")])
5404
5405 (define_insn "*lea_1_zext"
5406   [(set (match_operand:DI 0 "register_operand" "=r")
5407         (zero_extend:DI (subreg:SI (match_operand:DI 1 "address_operand" "p") 0)))]
5408   "TARGET_64BIT"
5409   "lea{l}\t{%a1, %k0|%k0, %a1}"
5410   [(set_attr "type" "lea")
5411    (set_attr "mode" "SI")])
5412
5413 (define_insn "*lea_2_rex64"
5414   [(set (match_operand:DI 0 "register_operand" "=r")
5415         (match_operand:DI 1 "address_operand" "p"))]
5416   "TARGET_64BIT"
5417   "lea{q}\t{%a1, %0|%0, %a1}"
5418   [(set_attr "type" "lea")
5419    (set_attr "mode" "DI")])
5420
5421 ;; The lea patterns for non-Pmodes needs to be matched by several
5422 ;; insns converted to real lea by splitters.
5423
5424 (define_insn_and_split "*lea_general_1"
5425   [(set (match_operand 0 "register_operand" "=r")
5426         (plus (plus (match_operand 1 "register_operand" "r")
5427                     (match_operand 2 "register_operand" "r"))
5428               (match_operand 3 "immediate_operand" "i")))]
5429   "(GET_MODE (operands[0]) == QImode || GET_MODE (operands[0]) == HImode
5430     || (TARGET_64BIT && GET_MODE (operands[0]) == SImode))
5431    && (!TARGET_PARTIAL_REG_STALL || optimize_size)
5432    && GET_MODE (operands[0]) == GET_MODE (operands[1])
5433    && GET_MODE (operands[0]) == GET_MODE (operands[2])
5434    && (GET_MODE (operands[0]) == GET_MODE (operands[3])
5435        || GET_MODE (operands[3]) == VOIDmode)"
5436   "#"
5437   "&& reload_completed"
5438   [(const_int 0)]
5439 {
5440   rtx pat;
5441   operands[0] = gen_lowpart (SImode, operands[0]);
5442   operands[1] = gen_lowpart (Pmode, operands[1]);
5443   operands[2] = gen_lowpart (Pmode, operands[2]);
5444   operands[3] = gen_lowpart (Pmode, operands[3]);
5445   pat = gen_rtx_PLUS (Pmode, gen_rtx_PLUS (Pmode, operands[1], operands[2]),
5446                       operands[3]);
5447   if (Pmode != SImode)
5448     pat = gen_rtx_SUBREG (SImode, pat, 0);
5449   emit_insn (gen_rtx_SET (VOIDmode, operands[0], pat));
5450   DONE;
5451 }
5452   [(set_attr "type" "lea")
5453    (set_attr "mode" "SI")])
5454
5455 (define_insn_and_split "*lea_general_1_zext"
5456   [(set (match_operand:DI 0 "register_operand" "=r")
5457         (zero_extend:DI
5458           (plus:SI (plus:SI (match_operand:SI 1 "register_operand" "r")
5459                             (match_operand:SI 2 "register_operand" "r"))
5460                    (match_operand:SI 3 "immediate_operand" "i"))))]
5461   "TARGET_64BIT"
5462   "#"
5463   "&& reload_completed"
5464   [(set (match_dup 0)
5465         (zero_extend:DI (subreg:SI (plus:DI (plus:DI (match_dup 1)
5466                                                      (match_dup 2))
5467                                             (match_dup 3)) 0)))]
5468 {
5469   operands[1] = gen_lowpart (Pmode, operands[1]);
5470   operands[2] = gen_lowpart (Pmode, operands[2]);
5471   operands[3] = gen_lowpart (Pmode, operands[3]);
5472 }
5473   [(set_attr "type" "lea")
5474    (set_attr "mode" "SI")])
5475
5476 (define_insn_and_split "*lea_general_2"
5477   [(set (match_operand 0 "register_operand" "=r")
5478         (plus (mult (match_operand 1 "register_operand" "r")
5479                     (match_operand 2 "const248_operand" "i"))
5480               (match_operand 3 "nonmemory_operand" "ri")))]
5481   "(GET_MODE (operands[0]) == QImode || GET_MODE (operands[0]) == HImode
5482     || (TARGET_64BIT && GET_MODE (operands[0]) == SImode))
5483    && (!TARGET_PARTIAL_REG_STALL || optimize_size)
5484    && GET_MODE (operands[0]) == GET_MODE (operands[1])
5485    && (GET_MODE (operands[0]) == GET_MODE (operands[3])
5486        || GET_MODE (operands[3]) == VOIDmode)"
5487   "#"
5488   "&& reload_completed"
5489   [(const_int 0)]
5490 {
5491   rtx pat;
5492   operands[0] = gen_lowpart (SImode, operands[0]);
5493   operands[1] = gen_lowpart (Pmode, operands[1]);
5494   operands[3] = gen_lowpart (Pmode, operands[3]);
5495   pat = gen_rtx_PLUS (Pmode, gen_rtx_MULT (Pmode, operands[1], operands[2]),
5496                       operands[3]);
5497   if (Pmode != SImode)
5498     pat = gen_rtx_SUBREG (SImode, pat, 0);
5499   emit_insn (gen_rtx_SET (VOIDmode, operands[0], pat));
5500   DONE;
5501 }
5502   [(set_attr "type" "lea")
5503    (set_attr "mode" "SI")])
5504
5505 (define_insn_and_split "*lea_general_2_zext"
5506   [(set (match_operand:DI 0 "register_operand" "=r")
5507         (zero_extend:DI
5508           (plus:SI (mult:SI (match_operand:SI 1 "register_operand" "r")
5509                             (match_operand:SI 2 "const248_operand" "n"))
5510                    (match_operand:SI 3 "nonmemory_operand" "ri"))))]
5511   "TARGET_64BIT"
5512   "#"
5513   "&& reload_completed"
5514   [(set (match_dup 0)
5515         (zero_extend:DI (subreg:SI (plus:DI (mult:DI (match_dup 1)
5516                                                      (match_dup 2))
5517                                             (match_dup 3)) 0)))]
5518 {
5519   operands[1] = gen_lowpart (Pmode, operands[1]);
5520   operands[3] = gen_lowpart (Pmode, operands[3]);
5521 }
5522   [(set_attr "type" "lea")
5523    (set_attr "mode" "SI")])
5524
5525 (define_insn_and_split "*lea_general_3"
5526   [(set (match_operand 0 "register_operand" "=r")
5527         (plus (plus (mult (match_operand 1 "register_operand" "r")
5528                           (match_operand 2 "const248_operand" "i"))
5529                     (match_operand 3 "register_operand" "r"))
5530               (match_operand 4 "immediate_operand" "i")))]
5531   "(GET_MODE (operands[0]) == QImode || GET_MODE (operands[0]) == HImode
5532     || (TARGET_64BIT && GET_MODE (operands[0]) == SImode))
5533    && (!TARGET_PARTIAL_REG_STALL || optimize_size)
5534    && GET_MODE (operands[0]) == GET_MODE (operands[1])
5535    && GET_MODE (operands[0]) == GET_MODE (operands[3])"
5536   "#"
5537   "&& reload_completed"
5538   [(const_int 0)]
5539 {
5540   rtx pat;
5541   operands[0] = gen_lowpart (SImode, operands[0]);
5542   operands[1] = gen_lowpart (Pmode, operands[1]);
5543   operands[3] = gen_lowpart (Pmode, operands[3]);
5544   operands[4] = gen_lowpart (Pmode, operands[4]);
5545   pat = gen_rtx_PLUS (Pmode,
5546                       gen_rtx_PLUS (Pmode, gen_rtx_MULT (Pmode, operands[1],
5547                                                          operands[2]),
5548                                     operands[3]),
5549                       operands[4]);
5550   if (Pmode != SImode)
5551     pat = gen_rtx_SUBREG (SImode, pat, 0);
5552   emit_insn (gen_rtx_SET (VOIDmode, operands[0], pat));
5553   DONE;
5554 }
5555   [(set_attr "type" "lea")
5556    (set_attr "mode" "SI")])
5557
5558 (define_insn_and_split "*lea_general_3_zext"
5559   [(set (match_operand:DI 0 "register_operand" "=r")
5560         (zero_extend:DI
5561           (plus:SI (plus:SI (mult:SI (match_operand:SI 1 "register_operand" "r")
5562                                      (match_operand:SI 2 "const248_operand" "n"))
5563                             (match_operand:SI 3 "register_operand" "r"))
5564                    (match_operand:SI 4 "immediate_operand" "i"))))]
5565   "TARGET_64BIT"
5566   "#"
5567   "&& reload_completed"
5568   [(set (match_dup 0)
5569         (zero_extend:DI (subreg:SI (plus:DI (plus:DI (mult:DI (match_dup 1)
5570                                                               (match_dup 2))
5571                                                      (match_dup 3))
5572                                             (match_dup 4)) 0)))]
5573 {
5574   operands[1] = gen_lowpart (Pmode, operands[1]);
5575   operands[3] = gen_lowpart (Pmode, operands[3]);
5576   operands[4] = gen_lowpart (Pmode, operands[4]);
5577 }
5578   [(set_attr "type" "lea")
5579    (set_attr "mode" "SI")])
5580
5581 (define_insn "*adddi_1_rex64"
5582   [(set (match_operand:DI 0 "nonimmediate_operand" "=r,rm,r")
5583         (plus:DI (match_operand:DI 1 "nonimmediate_operand" "%0,0,r")
5584                  (match_operand:DI 2 "x86_64_general_operand" "rme,re,re")))
5585    (clobber (reg:CC 17))]
5586   "TARGET_64BIT && ix86_binary_operator_ok (PLUS, DImode, operands)"
5587 {
5588   switch (get_attr_type (insn))
5589     {
5590     case TYPE_LEA:
5591       operands[2] = SET_SRC (XVECEXP (PATTERN (insn), 0, 0));
5592       return "lea{q}\t{%a2, %0|%0, %a2}";
5593
5594     case TYPE_INCDEC:
5595       if (! rtx_equal_p (operands[0], operands[1]))
5596         abort ();
5597       if (operands[2] == const1_rtx)
5598         return "inc{q}\t%0";
5599       else if (operands[2] == constm1_rtx)
5600         return "dec{q}\t%0";
5601       else
5602         abort ();
5603
5604     default:
5605       if (! rtx_equal_p (operands[0], operands[1]))
5606         abort ();
5607
5608       /* Make things pretty and `subl $4,%eax' rather than `addl $-4, %eax'.
5609          Exceptions: -128 encodes smaller than 128, so swap sign and op.  */
5610       if (GET_CODE (operands[2]) == CONST_INT
5611           /* Avoid overflows.  */
5612           && ((INTVAL (operands[2]) & ((((unsigned int) 1) << 31) - 1)))
5613           && (INTVAL (operands[2]) == 128
5614               || (INTVAL (operands[2]) < 0
5615                   && INTVAL (operands[2]) != -128)))
5616         {
5617           operands[2] = GEN_INT (-INTVAL (operands[2]));
5618           return "sub{q}\t{%2, %0|%0, %2}";
5619         }
5620       return "add{q}\t{%2, %0|%0, %2}";
5621     }
5622 }
5623   [(set (attr "type")
5624      (cond [(eq_attr "alternative" "2")
5625               (const_string "lea")
5626             ; Current assemblers are broken and do not allow @GOTOFF in
5627             ; ought but a memory context.
5628             (match_operand:DI 2 "pic_symbolic_operand" "")
5629               (const_string "lea")
5630             (match_operand:DI 2 "incdec_operand" "")
5631               (const_string "incdec")
5632            ]
5633            (const_string "alu")))
5634    (set_attr "mode" "DI")])
5635
5636 ;; Convert lea to the lea pattern to avoid flags dependency.
5637 (define_split
5638   [(set (match_operand:DI 0 "register_operand" "")
5639         (plus:DI (match_operand:DI 1 "register_operand" "")
5640                  (match_operand:DI 2 "x86_64_nonmemory_operand" "")))
5641    (clobber (reg:CC 17))]
5642   "TARGET_64BIT && reload_completed
5643    && true_regnum (operands[0]) != true_regnum (operands[1])"
5644   [(set (match_dup 0)
5645         (plus:DI (match_dup 1)
5646                  (match_dup 2)))]
5647   "")
5648
5649 (define_insn "*adddi_2_rex64"
5650   [(set (reg 17)
5651         (compare
5652           (plus:DI (match_operand:DI 1 "nonimmediate_operand" "%0,0")
5653                    (match_operand:DI 2 "x86_64_general_operand" "rme,re"))
5654           (const_int 0)))                       
5655    (set (match_operand:DI 0 "nonimmediate_operand" "=r,rm")
5656         (plus:DI (match_dup 1) (match_dup 2)))]
5657   "TARGET_64BIT && ix86_match_ccmode (insn, CCGOCmode)
5658    && ix86_binary_operator_ok (PLUS, DImode, operands)
5659    /* Current assemblers are broken and do not allow @GOTOFF in
5660       ought but a memory context.  */
5661    && ! pic_symbolic_operand (operands[2], VOIDmode)"
5662 {
5663   switch (get_attr_type (insn))
5664     {
5665     case TYPE_INCDEC:
5666       if (! rtx_equal_p (operands[0], operands[1]))
5667         abort ();
5668       if (operands[2] == const1_rtx)
5669         return "inc{q}\t%0";
5670       else if (operands[2] == constm1_rtx)
5671         return "dec{q}\t%0";
5672       else
5673         abort ();
5674
5675     default:
5676       if (! rtx_equal_p (operands[0], operands[1]))
5677         abort ();
5678       /* ???? We ought to handle there the 32bit case too
5679          - do we need new constrant?  */
5680       /* Make things pretty and `subl $4,%eax' rather than `addl $-4, %eax'.
5681          Exceptions: -128 encodes smaller than 128, so swap sign and op.  */
5682       if (GET_CODE (operands[2]) == CONST_INT
5683           /* Avoid overflows.  */
5684           && ((INTVAL (operands[2]) & ((((unsigned int) 1) << 31) - 1)))
5685           && (INTVAL (operands[2]) == 128
5686               || (INTVAL (operands[2]) < 0
5687                   && INTVAL (operands[2]) != -128)))
5688         {
5689           operands[2] = GEN_INT (-INTVAL (operands[2]));
5690           return "sub{q}\t{%2, %0|%0, %2}";
5691         }
5692       return "add{q}\t{%2, %0|%0, %2}";
5693     }
5694 }
5695   [(set (attr "type")
5696      (if_then_else (match_operand:DI 2 "incdec_operand" "")
5697         (const_string "incdec")
5698         (const_string "alu")))
5699    (set_attr "mode" "DI")])
5700
5701 (define_insn "*adddi_3_rex64"
5702   [(set (reg 17)
5703         (compare (neg:DI (match_operand:DI 2 "x86_64_general_operand" "rme"))
5704                  (match_operand:DI 1 "x86_64_general_operand" "%0")))
5705    (clobber (match_scratch:DI 0 "=r"))]
5706   "TARGET_64BIT
5707    && ix86_match_ccmode (insn, CCZmode)
5708    && (GET_CODE (operands[1]) != MEM || GET_CODE (operands[2]) != MEM)
5709    /* Current assemblers are broken and do not allow @GOTOFF in
5710       ought but a memory context.  */
5711    && ! pic_symbolic_operand (operands[2], VOIDmode)"
5712 {
5713   switch (get_attr_type (insn))
5714     {
5715     case TYPE_INCDEC:
5716       if (! rtx_equal_p (operands[0], operands[1]))
5717         abort ();
5718       if (operands[2] == const1_rtx)
5719         return "inc{q}\t%0";
5720       else if (operands[2] == constm1_rtx)
5721         return "dec{q}\t%0";
5722       else
5723         abort ();
5724
5725     default:
5726       if (! rtx_equal_p (operands[0], operands[1]))
5727         abort ();
5728       /* ???? We ought to handle there the 32bit case too
5729          - do we need new constrant?  */
5730       /* Make things pretty and `subl $4,%eax' rather than `addl $-4, %eax'.
5731          Exceptions: -128 encodes smaller than 128, so swap sign and op.  */
5732       if (GET_CODE (operands[2]) == CONST_INT
5733           /* Avoid overflows.  */
5734           && ((INTVAL (operands[2]) & ((((unsigned int) 1) << 31) - 1)))
5735           && (INTVAL (operands[2]) == 128
5736               || (INTVAL (operands[2]) < 0
5737                   && INTVAL (operands[2]) != -128)))
5738         {
5739           operands[2] = GEN_INT (-INTVAL (operands[2]));
5740           return "sub{q}\t{%2, %0|%0, %2}";
5741         }
5742       return "add{q}\t{%2, %0|%0, %2}";
5743     }
5744 }
5745   [(set (attr "type")
5746      (if_then_else (match_operand:DI 2 "incdec_operand" "")
5747         (const_string "incdec")
5748         (const_string "alu")))
5749    (set_attr "mode" "DI")])
5750
5751 ; For comparisons against 1, -1 and 128, we may generate better code
5752 ; by converting cmp to add, inc or dec as done by peephole2.  This pattern
5753 ; is matched then.  We can't accept general immediate, because for
5754 ; case of overflows,  the result is messed up.
5755 ; This pattern also don't hold of 0x8000000000000000, since the value overflows
5756 ; when negated.
5757 ; Also carry flag is reversed compared to cmp, so this converison is valid
5758 ; only for comparisons not depending on it.
5759 (define_insn "*adddi_4_rex64"
5760   [(set (reg 17)
5761         (compare (match_operand:DI 1 "nonimmediate_operand" "0")
5762                  (match_operand:DI 2 "x86_64_immediate_operand" "e")))
5763    (clobber (match_scratch:DI 0 "=rm"))]
5764   "TARGET_64BIT
5765    &&  ix86_match_ccmode (insn, CCGCmode)"
5766 {
5767   switch (get_attr_type (insn))
5768     {
5769     case TYPE_INCDEC:
5770       if (operands[2] == constm1_rtx)
5771         return "inc{q}\t%0";
5772       else if (operands[2] == const1_rtx)
5773         return "dec{q}\t%0";
5774       else
5775         abort();
5776
5777     default:
5778       if (! rtx_equal_p (operands[0], operands[1]))
5779         abort ();
5780       /* Make things pretty and `subl $4,%eax' rather than `addl $-4, %eax'.
5781          Exceptions: -128 encodes smaller than 128, so swap sign and op.  */
5782       if ((INTVAL (operands[2]) == -128
5783            || (INTVAL (operands[2]) > 0
5784                && INTVAL (operands[2]) != 128))
5785           /* Avoid overflows.  */
5786           && ((INTVAL (operands[2]) & ((((unsigned int) 1) << 31) - 1))))
5787         return "sub{q}\t{%2, %0|%0, %2}";
5788       operands[2] = GEN_INT (-INTVAL (operands[2]));
5789       return "add{q}\t{%2, %0|%0, %2}";
5790     }
5791 }
5792   [(set (attr "type")
5793      (if_then_else (match_operand:DI 2 "incdec_operand" "")
5794         (const_string "incdec")
5795         (const_string "alu")))
5796    (set_attr "mode" "DI")])
5797
5798 (define_insn "*adddi_5_rex64"
5799   [(set (reg 17)
5800         (compare
5801           (plus:DI (match_operand:DI 1 "nonimmediate_operand" "%0")
5802                    (match_operand:DI 2 "x86_64_general_operand" "rme"))
5803           (const_int 0)))                       
5804    (clobber (match_scratch:DI 0 "=r"))]
5805   "TARGET_64BIT
5806    && ix86_match_ccmode (insn, CCGOCmode)
5807    && (GET_CODE (operands[1]) != MEM || GET_CODE (operands[2]) != MEM)
5808    /* Current assemblers are broken and do not allow @GOTOFF in
5809       ought but a memory context.  */
5810    && ! pic_symbolic_operand (operands[2], VOIDmode)"
5811 {
5812   switch (get_attr_type (insn))
5813     {
5814     case TYPE_INCDEC:
5815       if (! rtx_equal_p (operands[0], operands[1]))
5816         abort ();
5817       if (operands[2] == const1_rtx)
5818         return "inc{q}\t%0";
5819       else if (operands[2] == constm1_rtx)
5820         return "dec{q}\t%0";
5821       else
5822         abort();
5823
5824     default:
5825       if (! rtx_equal_p (operands[0], operands[1]))
5826         abort ();
5827       /* Make things pretty and `subl $4,%eax' rather than `addl $-4, %eax'.
5828          Exceptions: -128 encodes smaller than 128, so swap sign and op.  */
5829       if (GET_CODE (operands[2]) == CONST_INT
5830           /* Avoid overflows.  */
5831           && ((INTVAL (operands[2]) & ((((unsigned int) 1) << 31) - 1)))
5832           && (INTVAL (operands[2]) == 128
5833               || (INTVAL (operands[2]) < 0
5834                   && INTVAL (operands[2]) != -128)))
5835         {
5836           operands[2] = GEN_INT (-INTVAL (operands[2]));
5837           return "sub{q}\t{%2, %0|%0, %2}";
5838         }
5839       return "add{q}\t{%2, %0|%0, %2}";
5840     }
5841 }
5842   [(set (attr "type")
5843      (if_then_else (match_operand:DI 2 "incdec_operand" "")
5844         (const_string "incdec")
5845         (const_string "alu")))
5846    (set_attr "mode" "DI")])
5847
5848
5849 (define_insn "*addsi_1"
5850   [(set (match_operand:SI 0 "nonimmediate_operand" "=r,rm,r")
5851         (plus:SI (match_operand:SI 1 "nonimmediate_operand" "%0,0,r")
5852                  (match_operand:SI 2 "general_operand" "rmni,rni,rni")))
5853    (clobber (reg:CC 17))]
5854   "ix86_binary_operator_ok (PLUS, SImode, operands)"
5855 {
5856   switch (get_attr_type (insn))
5857     {
5858     case TYPE_LEA:
5859       operands[2] = SET_SRC (XVECEXP (PATTERN (insn), 0, 0));
5860       return "lea{l}\t{%a2, %0|%0, %a2}";
5861
5862     case TYPE_INCDEC:
5863       if (! rtx_equal_p (operands[0], operands[1]))
5864         abort ();
5865       if (operands[2] == const1_rtx)
5866         return "inc{l}\t%0";
5867       else if (operands[2] == constm1_rtx)
5868         return "dec{l}\t%0";
5869       else
5870         abort();
5871
5872     default:
5873       if (! rtx_equal_p (operands[0], operands[1]))
5874         abort ();
5875
5876       /* Make things pretty and `subl $4,%eax' rather than `addl $-4, %eax'.
5877          Exceptions: -128 encodes smaller than 128, so swap sign and op.  */
5878       if (GET_CODE (operands[2]) == CONST_INT
5879           && (INTVAL (operands[2]) == 128
5880               || (INTVAL (operands[2]) < 0
5881                   && INTVAL (operands[2]) != -128)))
5882         {
5883           operands[2] = GEN_INT (-INTVAL (operands[2]));
5884           return "sub{l}\t{%2, %0|%0, %2}";
5885         }
5886       return "add{l}\t{%2, %0|%0, %2}";
5887     }
5888 }
5889   [(set (attr "type")
5890      (cond [(eq_attr "alternative" "2")
5891               (const_string "lea")
5892             ; Current assemblers are broken and do not allow @GOTOFF in
5893             ; ought but a memory context.
5894             (match_operand:SI 2 "pic_symbolic_operand" "")
5895               (const_string "lea")
5896             (match_operand:SI 2 "incdec_operand" "")
5897               (const_string "incdec")
5898            ]
5899            (const_string "alu")))
5900    (set_attr "mode" "SI")])
5901
5902 ;; Convert lea to the lea pattern to avoid flags dependency.
5903 (define_split
5904   [(set (match_operand 0 "register_operand" "")
5905         (plus (match_operand 1 "register_operand" "")
5906               (match_operand 2 "nonmemory_operand" "")))
5907    (clobber (reg:CC 17))]
5908   "reload_completed
5909    && true_regnum (operands[0]) != true_regnum (operands[1])"
5910   [(const_int 0)]
5911 {
5912   rtx pat;
5913   /* In -fPIC mode the constructs like (const (unspec [symbol_ref]))
5914      may confuse gen_lowpart.  */
5915   if (GET_MODE (operands[0]) != Pmode)
5916     {
5917       operands[1] = gen_lowpart (Pmode, operands[1]);
5918       operands[2] = gen_lowpart (Pmode, operands[2]);
5919     }
5920   operands[0] = gen_lowpart (SImode, operands[0]);
5921   pat = gen_rtx_PLUS (Pmode, operands[1], operands[2]);
5922   if (Pmode != SImode)
5923     pat = gen_rtx_SUBREG (SImode, pat, 0);
5924   emit_insn (gen_rtx_SET (VOIDmode, operands[0], pat));
5925   DONE;
5926 })
5927
5928 ;; It may seem that nonimmediate operand is proper one for operand 1.
5929 ;; The addsi_1 pattern allows nonimmediate operand at that place and
5930 ;; we take care in ix86_binary_operator_ok to not allow two memory
5931 ;; operands so proper swapping will be done in reload.  This allow
5932 ;; patterns constructed from addsi_1 to match.
5933 (define_insn "addsi_1_zext"
5934   [(set (match_operand:DI 0 "register_operand" "=r,r")
5935         (zero_extend:DI
5936           (plus:SI (match_operand:SI 1 "nonimmediate_operand" "%0,r")
5937                    (match_operand:SI 2 "general_operand" "rmni,rni"))))
5938    (clobber (reg:CC 17))]
5939   "TARGET_64BIT && ix86_binary_operator_ok (PLUS, SImode, operands)"
5940 {
5941   switch (get_attr_type (insn))
5942     {
5943     case TYPE_LEA:
5944       operands[2] = SET_SRC (XVECEXP (PATTERN (insn), 0, 0));
5945       return "lea{l}\t{%a2, %k0|%k0, %a2}";
5946
5947     case TYPE_INCDEC:
5948       if (operands[2] == const1_rtx)
5949         return "inc{l}\t%k0";
5950       else if (operands[2] == constm1_rtx)
5951         return "dec{l}\t%k0";
5952       else
5953         abort();
5954
5955     default:
5956       /* Make things pretty and `subl $4,%eax' rather than `addl $-4, %eax'.
5957          Exceptions: -128 encodes smaller than 128, so swap sign and op.  */
5958       if (GET_CODE (operands[2]) == CONST_INT
5959           && (INTVAL (operands[2]) == 128
5960               || (INTVAL (operands[2]) < 0
5961                   && INTVAL (operands[2]) != -128)))
5962         {
5963           operands[2] = GEN_INT (-INTVAL (operands[2]));
5964           return "sub{l}\t{%2, %k0|%k0, %2}";
5965         }
5966       return "add{l}\t{%2, %k0|%k0, %2}";
5967     }
5968 }
5969   [(set (attr "type")
5970      (cond [(eq_attr "alternative" "1")
5971               (const_string "lea")
5972             ; Current assemblers are broken and do not allow @GOTOFF in
5973             ; ought but a memory context.
5974             (match_operand:SI 2 "pic_symbolic_operand" "")
5975               (const_string "lea")
5976             (match_operand:SI 2 "incdec_operand" "")
5977               (const_string "incdec")
5978            ]
5979            (const_string "alu")))
5980    (set_attr "mode" "SI")])
5981
5982 ;; Convert lea to the lea pattern to avoid flags dependency.
5983 (define_split
5984   [(set (match_operand:DI 0 "register_operand" "")
5985         (zero_extend:DI
5986           (plus:SI (match_operand:SI 1 "register_operand" "")
5987                    (match_operand:SI 2 "nonmemory_operand" ""))))
5988    (clobber (reg:CC 17))]
5989   "reload_completed
5990    && true_regnum (operands[0]) != true_regnum (operands[1])"
5991   [(set (match_dup 0)
5992         (zero_extend:DI (subreg:SI (plus:DI (match_dup 1) (match_dup 2)) 0)))]
5993 {
5994   operands[1] = gen_lowpart (Pmode, operands[1]);
5995   operands[2] = gen_lowpart (Pmode, operands[2]);
5996 })
5997
5998 (define_insn "*addsi_2"
5999   [(set (reg 17)
6000         (compare
6001           (plus:SI (match_operand:SI 1 "nonimmediate_operand" "%0,0")
6002                    (match_operand:SI 2 "general_operand" "rmni,rni"))
6003           (const_int 0)))                       
6004    (set (match_operand:SI 0 "nonimmediate_operand" "=r,rm")
6005         (plus:SI (match_dup 1) (match_dup 2)))]
6006   "ix86_match_ccmode (insn, CCGOCmode)
6007    && ix86_binary_operator_ok (PLUS, SImode, operands)
6008    /* Current assemblers are broken and do not allow @GOTOFF in
6009       ought but a memory context.  */
6010    && ! pic_symbolic_operand (operands[2], VOIDmode)"
6011 {
6012   switch (get_attr_type (insn))
6013     {
6014     case TYPE_INCDEC:
6015       if (! rtx_equal_p (operands[0], operands[1]))
6016         abort ();
6017       if (operands[2] == const1_rtx)
6018         return "inc{l}\t%0";
6019       else if (operands[2] == constm1_rtx)
6020         return "dec{l}\t%0";
6021       else
6022         abort();
6023
6024     default:
6025       if (! rtx_equal_p (operands[0], operands[1]))
6026         abort ();
6027       /* Make things pretty and `subl $4,%eax' rather than `addl $-4, %eax'.
6028          Exceptions: -128 encodes smaller than 128, so swap sign and op.  */
6029       if (GET_CODE (operands[2]) == CONST_INT
6030           && (INTVAL (operands[2]) == 128
6031               || (INTVAL (operands[2]) < 0
6032                   && INTVAL (operands[2]) != -128)))
6033         {
6034           operands[2] = GEN_INT (-INTVAL (operands[2]));
6035           return "sub{l}\t{%2, %0|%0, %2}";
6036         }
6037       return "add{l}\t{%2, %0|%0, %2}";
6038     }
6039 }
6040   [(set (attr "type")
6041      (if_then_else (match_operand:SI 2 "incdec_operand" "")
6042         (const_string "incdec")
6043         (const_string "alu")))
6044    (set_attr "mode" "SI")])
6045
6046 ;; See comment for addsi_1_zext why we do use nonimmediate_operand
6047 (define_insn "*addsi_2_zext"
6048   [(set (reg 17)
6049         (compare
6050           (plus:SI (match_operand:SI 1 "nonimmediate_operand" "%0")
6051                    (match_operand:SI 2 "general_operand" "rmni"))
6052           (const_int 0)))                       
6053    (set (match_operand:DI 0 "register_operand" "=r")
6054         (zero_extend:DI (plus:SI (match_dup 1) (match_dup 2))))]
6055   "TARGET_64BIT && ix86_match_ccmode (insn, CCGOCmode)
6056    && ix86_binary_operator_ok (PLUS, SImode, operands)
6057    /* Current assemblers are broken and do not allow @GOTOFF in
6058       ought but a memory context.  */
6059    && ! pic_symbolic_operand (operands[2], VOIDmode)"
6060 {
6061   switch (get_attr_type (insn))
6062     {
6063     case TYPE_INCDEC:
6064       if (operands[2] == const1_rtx)
6065         return "inc{l}\t%k0";
6066       else if (operands[2] == constm1_rtx)
6067         return "dec{l}\t%k0";
6068       else
6069         abort();
6070
6071     default:
6072       /* Make things pretty and `subl $4,%eax' rather than `addl $-4, %eax'.
6073          Exceptions: -128 encodes smaller than 128, so swap sign and op.  */
6074       if (GET_CODE (operands[2]) == CONST_INT
6075           && (INTVAL (operands[2]) == 128
6076               || (INTVAL (operands[2]) < 0
6077                   && INTVAL (operands[2]) != -128)))
6078         {
6079           operands[2] = GEN_INT (-INTVAL (operands[2]));
6080           return "sub{l}\t{%2, %k0|%k0, %2}";
6081         }
6082       return "add{l}\t{%2, %k0|%k0, %2}";
6083     }
6084 }
6085   [(set (attr "type")
6086      (if_then_else (match_operand:SI 2 "incdec_operand" "")
6087         (const_string "incdec")
6088         (const_string "alu")))
6089    (set_attr "mode" "SI")])
6090
6091 (define_insn "*addsi_3"
6092   [(set (reg 17)
6093         (compare (neg:SI (match_operand:SI 2 "general_operand" "rmni"))
6094                  (match_operand:SI 1 "nonimmediate_operand" "%0")))
6095    (clobber (match_scratch:SI 0 "=r"))]
6096   "ix86_match_ccmode (insn, CCZmode)
6097    && (GET_CODE (operands[1]) != MEM || GET_CODE (operands[2]) != MEM)
6098    /* Current assemblers are broken and do not allow @GOTOFF in
6099       ought but a memory context.  */
6100    && ! pic_symbolic_operand (operands[2], VOIDmode)"
6101 {
6102   switch (get_attr_type (insn))
6103     {
6104     case TYPE_INCDEC:
6105       if (! rtx_equal_p (operands[0], operands[1]))
6106         abort ();
6107       if (operands[2] == const1_rtx)
6108         return "inc{l}\t%0";
6109       else if (operands[2] == constm1_rtx)
6110         return "dec{l}\t%0";
6111       else
6112         abort();
6113
6114     default:
6115       if (! rtx_equal_p (operands[0], operands[1]))
6116         abort ();
6117       /* Make things pretty and `subl $4,%eax' rather than `addl $-4, %eax'.
6118          Exceptions: -128 encodes smaller than 128, so swap sign and op.  */
6119       if (GET_CODE (operands[2]) == CONST_INT
6120           && (INTVAL (operands[2]) == 128
6121               || (INTVAL (operands[2]) < 0
6122                   && INTVAL (operands[2]) != -128)))
6123         {
6124           operands[2] = GEN_INT (-INTVAL (operands[2]));
6125           return "sub{l}\t{%2, %0|%0, %2}";
6126         }
6127       return "add{l}\t{%2, %0|%0, %2}";
6128     }
6129 }
6130   [(set (attr "type")
6131      (if_then_else (match_operand:SI 2 "incdec_operand" "")
6132         (const_string "incdec")
6133         (const_string "alu")))
6134    (set_attr "mode" "SI")])
6135
6136 ;; See comment for addsi_1_zext why we do use nonimmediate_operand
6137 (define_insn "*addsi_3_zext"
6138   [(set (reg 17)
6139         (compare (neg:SI (match_operand:SI 2 "general_operand" "rmni"))
6140                  (match_operand:SI 1 "nonimmediate_operand" "%0")))
6141    (set (match_operand:DI 0 "register_operand" "=r")
6142         (zero_extend:DI (plus:SI (match_dup 1) (match_dup 2))))]
6143   "TARGET_64BIT && ix86_match_ccmode (insn, CCZmode)
6144    && ix86_binary_operator_ok (PLUS, SImode, operands)
6145    /* Current assemblers are broken and do not allow @GOTOFF in
6146       ought but a memory context.  */
6147    && ! pic_symbolic_operand (operands[2], VOIDmode)"
6148 {
6149   switch (get_attr_type (insn))
6150     {
6151     case TYPE_INCDEC:
6152       if (operands[2] == const1_rtx)
6153         return "inc{l}\t%k0";
6154       else if (operands[2] == constm1_rtx)
6155         return "dec{l}\t%k0";
6156       else
6157         abort();
6158
6159     default:
6160       /* Make things pretty and `subl $4,%eax' rather than `addl $-4, %eax'.
6161          Exceptions: -128 encodes smaller than 128, so swap sign and op.  */
6162       if (GET_CODE (operands[2]) == CONST_INT
6163           && (INTVAL (operands[2]) == 128
6164               || (INTVAL (operands[2]) < 0
6165                   && INTVAL (operands[2]) != -128)))
6166         {
6167           operands[2] = GEN_INT (-INTVAL (operands[2]));
6168           return "sub{l}\t{%2, %k0|%k0, %2}";
6169         }
6170       return "add{l}\t{%2, %k0|%k0, %2}";
6171     }
6172 }
6173   [(set (attr "type")
6174      (if_then_else (match_operand:SI 2 "incdec_operand" "")
6175         (const_string "incdec")
6176         (const_string "alu")))
6177    (set_attr "mode" "SI")])
6178
6179 ; For comparisons agains 1, -1 and 128, we may generate better code
6180 ; by converting cmp to add, inc or dec as done by peephole2.  This pattern
6181 ; is matched then.  We can't accept general immediate, because for
6182 ; case of overflows,  the result is messed up.
6183 ; This pattern also don't hold of 0x80000000, since the value overflows
6184 ; when negated.
6185 ; Also carry flag is reversed compared to cmp, so this converison is valid
6186 ; only for comparisons not depending on it.
6187 (define_insn "*addsi_4"
6188   [(set (reg 17)
6189         (compare (match_operand:SI 1 "nonimmediate_operand" "0")
6190                  (match_operand:SI 2 "const_int_operand" "n")))
6191    (clobber (match_scratch:SI 0 "=rm"))]
6192   "ix86_match_ccmode (insn, CCGCmode)
6193    && (INTVAL (operands[2]) & 0xffffffff) != 0x80000000"
6194 {
6195   switch (get_attr_type (insn))
6196     {
6197     case TYPE_INCDEC:
6198       if (operands[2] == constm1_rtx)
6199         return "inc{l}\t%0";
6200       else if (operands[2] == const1_rtx)
6201         return "dec{l}\t%0";
6202       else
6203         abort();
6204
6205     default:
6206       if (! rtx_equal_p (operands[0], operands[1]))
6207         abort ();
6208       /* Make things pretty and `subl $4,%eax' rather than `addl $-4, %eax'.
6209          Exceptions: -128 encodes smaller than 128, so swap sign and op.  */
6210       if ((INTVAL (operands[2]) == -128
6211            || (INTVAL (operands[2]) > 0
6212                && INTVAL (operands[2]) != 128)))
6213         return "sub{l}\t{%2, %0|%0, %2}";
6214       operands[2] = GEN_INT (-INTVAL (operands[2]));
6215       return "add{l}\t{%2, %0|%0, %2}";
6216     }
6217 }
6218   [(set (attr "type")
6219      (if_then_else (match_operand:SI 2 "incdec_operand" "")
6220         (const_string "incdec")
6221         (const_string "alu")))
6222    (set_attr "mode" "SI")])
6223
6224 (define_insn "*addsi_5"
6225   [(set (reg 17)
6226         (compare
6227           (plus:SI (match_operand:SI 1 "nonimmediate_operand" "%0")
6228                    (match_operand:SI 2 "general_operand" "rmni"))
6229           (const_int 0)))                       
6230    (clobber (match_scratch:SI 0 "=r"))]
6231   "ix86_match_ccmode (insn, CCGOCmode)
6232    && (GET_CODE (operands[1]) != MEM || GET_CODE (operands[2]) != MEM)
6233    /* Current assemblers are broken and do not allow @GOTOFF in
6234       ought but a memory context.  */
6235    && ! pic_symbolic_operand (operands[2], VOIDmode)"
6236 {
6237   switch (get_attr_type (insn))
6238     {
6239     case TYPE_INCDEC:
6240       if (! rtx_equal_p (operands[0], operands[1]))
6241         abort ();
6242       if (operands[2] == const1_rtx)
6243         return "inc{l}\t%0";
6244       else if (operands[2] == constm1_rtx)
6245         return "dec{l}\t%0";
6246       else
6247         abort();
6248
6249     default:
6250       if (! rtx_equal_p (operands[0], operands[1]))
6251         abort ();
6252       /* Make things pretty and `subl $4,%eax' rather than `addl $-4, %eax'.
6253          Exceptions: -128 encodes smaller than 128, so swap sign and op.  */
6254       if (GET_CODE (operands[2]) == CONST_INT
6255           && (INTVAL (operands[2]) == 128
6256               || (INTVAL (operands[2]) < 0
6257                   && INTVAL (operands[2]) != -128)))
6258         {
6259           operands[2] = GEN_INT (-INTVAL (operands[2]));
6260           return "sub{l}\t{%2, %0|%0, %2}";
6261         }
6262       return "add{l}\t{%2, %0|%0, %2}";
6263     }
6264 }
6265   [(set (attr "type")
6266      (if_then_else (match_operand:SI 2 "incdec_operand" "")
6267         (const_string "incdec")
6268         (const_string "alu")))
6269    (set_attr "mode" "SI")])
6270
6271 (define_expand "addhi3"
6272   [(parallel [(set (match_operand:HI 0 "nonimmediate_operand" "")
6273                    (plus:HI (match_operand:HI 1 "nonimmediate_operand" "")
6274                             (match_operand:HI 2 "general_operand" "")))
6275               (clobber (reg:CC 17))])]
6276   "TARGET_HIMODE_MATH"
6277   "ix86_expand_binary_operator (PLUS, HImode, operands); DONE;")
6278
6279 ;; %%% After Dave's SUBREG_BYTE stuff goes in, re-enable incb %ah
6280 ;; type optimizations enabled by define-splits.  This is not important
6281 ;; for PII, and in fact harmful because of partial register stalls.
6282
6283 (define_insn "*addhi_1_lea"
6284   [(set (match_operand:HI 0 "nonimmediate_operand" "=rm,r,r")
6285         (plus:HI (match_operand:HI 1 "nonimmediate_operand" "%0,0,r")
6286                  (match_operand:HI 2 "general_operand" "ri,rm,rni")))
6287    (clobber (reg:CC 17))]
6288   "!TARGET_PARTIAL_REG_STALL
6289    && ix86_binary_operator_ok (PLUS, HImode, operands)"
6290 {
6291   switch (get_attr_type (insn))
6292     {
6293     case TYPE_LEA:
6294       return "#";
6295     case TYPE_INCDEC:
6296       if (operands[2] == const1_rtx)
6297         return "inc{w}\t%0";
6298       else if (operands[2] == constm1_rtx
6299                || (GET_CODE (operands[2]) == CONST_INT
6300                    && INTVAL (operands[2]) == 65535))
6301         return "dec{w}\t%0";
6302       abort();
6303
6304     default:
6305       /* Make things pretty and `subl $4,%eax' rather than `addl $-4, %eax'.
6306          Exceptions: -128 encodes smaller than 128, so swap sign and op.  */
6307       if (GET_CODE (operands[2]) == CONST_INT
6308           && (INTVAL (operands[2]) == 128
6309               || (INTVAL (operands[2]) < 0
6310                   && INTVAL (operands[2]) != -128)))
6311         {
6312           operands[2] = GEN_INT (-INTVAL (operands[2]));
6313           return "sub{w}\t{%2, %0|%0, %2}";
6314         }
6315       return "add{w}\t{%2, %0|%0, %2}";
6316     }
6317 }
6318   [(set (attr "type")
6319      (if_then_else (eq_attr "alternative" "2")
6320         (const_string "lea")
6321         (if_then_else (match_operand:HI 2 "incdec_operand" "")
6322            (const_string "incdec")
6323            (const_string "alu"))))
6324    (set_attr "mode" "HI,HI,SI")])
6325
6326 (define_insn "*addhi_1"
6327   [(set (match_operand:HI 0 "nonimmediate_operand" "=rm,r")
6328         (plus:HI (match_operand:HI 1 "nonimmediate_operand" "%0,0")
6329                  (match_operand:HI 2 "general_operand" "ri,rm")))
6330    (clobber (reg:CC 17))]
6331   "TARGET_PARTIAL_REG_STALL
6332    && ix86_binary_operator_ok (PLUS, HImode, operands)"
6333 {
6334   switch (get_attr_type (insn))
6335     {
6336     case TYPE_INCDEC:
6337       if (operands[2] == const1_rtx)
6338         return "inc{w}\t%0";
6339       else if (operands[2] == constm1_rtx
6340                || (GET_CODE (operands[2]) == CONST_INT
6341                    && INTVAL (operands[2]) == 65535))
6342         return "dec{w}\t%0";
6343       abort();
6344
6345     default:
6346       /* Make things pretty and `subl $4,%eax' rather than `addl $-4, %eax'.
6347          Exceptions: -128 encodes smaller than 128, so swap sign and op.  */
6348       if (GET_CODE (operands[2]) == CONST_INT
6349           && (INTVAL (operands[2]) == 128
6350               || (INTVAL (operands[2]) < 0
6351                   && INTVAL (operands[2]) != -128)))
6352         {
6353           operands[2] = GEN_INT (-INTVAL (operands[2]));
6354           return "sub{w}\t{%2, %0|%0, %2}";
6355         }
6356       return "add{w}\t{%2, %0|%0, %2}";
6357     }
6358 }
6359   [(set (attr "type")
6360      (if_then_else (match_operand:HI 2 "incdec_operand" "")
6361         (const_string "incdec")
6362         (const_string "alu")))
6363    (set_attr "mode" "HI")])
6364
6365 (define_insn "*addhi_2"
6366   [(set (reg 17)
6367         (compare
6368           (plus:HI (match_operand:HI 1 "nonimmediate_operand" "%0,0")
6369                    (match_operand:HI 2 "general_operand" "rmni,rni"))
6370           (const_int 0)))                       
6371    (set (match_operand:HI 0 "nonimmediate_operand" "=r,rm")
6372         (plus:HI (match_dup 1) (match_dup 2)))]
6373   "ix86_match_ccmode (insn, CCGOCmode)
6374    && ix86_binary_operator_ok (PLUS, HImode, operands)"
6375 {
6376   switch (get_attr_type (insn))
6377     {
6378     case TYPE_INCDEC:
6379       if (operands[2] == const1_rtx)
6380         return "inc{w}\t%0";
6381       else if (operands[2] == constm1_rtx
6382                || (GET_CODE (operands[2]) == CONST_INT
6383                    && INTVAL (operands[2]) == 65535))
6384         return "dec{w}\t%0";
6385       abort();
6386
6387     default:
6388       /* Make things pretty and `subl $4,%eax' rather than `addl $-4, %eax'.
6389          Exceptions: -128 encodes smaller than 128, so swap sign and op.  */
6390       if (GET_CODE (operands[2]) == CONST_INT
6391           && (INTVAL (operands[2]) == 128
6392               || (INTVAL (operands[2]) < 0
6393                   && INTVAL (operands[2]) != -128)))
6394         {
6395           operands[2] = GEN_INT (-INTVAL (operands[2]));
6396           return "sub{w}\t{%2, %0|%0, %2}";
6397         }
6398       return "add{w}\t{%2, %0|%0, %2}";
6399     }
6400 }
6401   [(set (attr "type")
6402      (if_then_else (match_operand:HI 2 "incdec_operand" "")
6403         (const_string "incdec")
6404         (const_string "alu")))
6405    (set_attr "mode" "HI")])
6406
6407 (define_insn "*addhi_3"
6408   [(set (reg 17)
6409         (compare (neg:HI (match_operand:HI 2 "general_operand" "rmni"))
6410                  (match_operand:HI 1 "nonimmediate_operand" "%0")))
6411    (clobber (match_scratch:HI 0 "=r"))]
6412   "ix86_match_ccmode (insn, CCZmode)
6413    && (GET_CODE (operands[1]) != MEM || GET_CODE (operands[2]) != MEM)"
6414 {
6415   switch (get_attr_type (insn))
6416     {
6417     case TYPE_INCDEC:
6418       if (operands[2] == const1_rtx)
6419         return "inc{w}\t%0";
6420       else if (operands[2] == constm1_rtx
6421                || (GET_CODE (operands[2]) == CONST_INT
6422                    && INTVAL (operands[2]) == 65535))
6423         return "dec{w}\t%0";
6424       abort();
6425
6426     default:
6427       /* Make things pretty and `subl $4,%eax' rather than `addl $-4, %eax'.
6428          Exceptions: -128 encodes smaller than 128, so swap sign and op.  */
6429       if (GET_CODE (operands[2]) == CONST_INT
6430           && (INTVAL (operands[2]) == 128
6431               || (INTVAL (operands[2]) < 0
6432                   && INTVAL (operands[2]) != -128)))
6433         {
6434           operands[2] = GEN_INT (-INTVAL (operands[2]));
6435           return "sub{w}\t{%2, %0|%0, %2}";
6436         }
6437       return "add{w}\t{%2, %0|%0, %2}";
6438     }
6439 }
6440   [(set (attr "type")
6441      (if_then_else (match_operand:HI 2 "incdec_operand" "")
6442         (const_string "incdec")
6443         (const_string "alu")))
6444    (set_attr "mode" "HI")])
6445
6446 ; See comments above addsi_3_imm for details.
6447 (define_insn "*addhi_4"
6448   [(set (reg 17)
6449         (compare (match_operand:HI 1 "nonimmediate_operand" "0")
6450                  (match_operand:HI 2 "const_int_operand" "n")))
6451    (clobber (match_scratch:HI 0 "=rm"))]
6452   "ix86_match_ccmode (insn, CCGCmode)
6453    && (INTVAL (operands[2]) & 0xffff) != 0x8000"
6454 {
6455   switch (get_attr_type (insn))
6456     {
6457     case TYPE_INCDEC:
6458       if (operands[2] == constm1_rtx
6459           || (GET_CODE (operands[2]) == CONST_INT
6460               && INTVAL (operands[2]) == 65535))
6461         return "inc{w}\t%0";
6462       else if (operands[2] == const1_rtx)
6463         return "dec{w}\t%0";
6464       else
6465         abort();
6466
6467     default:
6468       if (! rtx_equal_p (operands[0], operands[1]))
6469         abort ();
6470       /* Make things pretty and `subl $4,%eax' rather than `addl $-4, %eax'.
6471          Exceptions: -128 encodes smaller than 128, so swap sign and op.  */
6472       if ((INTVAL (operands[2]) == -128
6473            || (INTVAL (operands[2]) > 0
6474                && INTVAL (operands[2]) != 128)))
6475         return "sub{w}\t{%2, %0|%0, %2}";
6476       operands[2] = GEN_INT (-INTVAL (operands[2]));
6477       return "add{w}\t{%2, %0|%0, %2}";
6478     }
6479 }
6480   [(set (attr "type")
6481      (if_then_else (match_operand:HI 2 "incdec_operand" "")
6482         (const_string "incdec")
6483         (const_string "alu")))
6484    (set_attr "mode" "SI")])
6485
6486
6487 (define_insn "*addhi_5"
6488   [(set (reg 17)
6489         (compare
6490           (plus:HI (match_operand:HI 1 "nonimmediate_operand" "%0")
6491                    (match_operand:HI 2 "general_operand" "rmni"))
6492           (const_int 0)))                       
6493    (clobber (match_scratch:HI 0 "=r"))]
6494   "ix86_match_ccmode (insn, CCGOCmode)
6495    && (GET_CODE (operands[1]) != MEM || GET_CODE (operands[2]) != MEM)"
6496 {
6497   switch (get_attr_type (insn))
6498     {
6499     case TYPE_INCDEC:
6500       if (operands[2] == const1_rtx)
6501         return "inc{w}\t%0";
6502       else if (operands[2] == constm1_rtx
6503                || (GET_CODE (operands[2]) == CONST_INT
6504                    && INTVAL (operands[2]) == 65535))
6505         return "dec{w}\t%0";
6506       abort();
6507
6508     default:
6509       /* Make things pretty and `subl $4,%eax' rather than `addl $-4, %eax'.
6510          Exceptions: -128 encodes smaller than 128, so swap sign and op.  */
6511       if (GET_CODE (operands[2]) == CONST_INT
6512           && (INTVAL (operands[2]) == 128
6513               || (INTVAL (operands[2]) < 0
6514                   && INTVAL (operands[2]) != -128)))
6515         {
6516           operands[2] = GEN_INT (-INTVAL (operands[2]));
6517           return "sub{w}\t{%2, %0|%0, %2}";
6518         }
6519       return "add{w}\t{%2, %0|%0, %2}";
6520     }
6521 }
6522   [(set (attr "type")
6523      (if_then_else (match_operand:HI 2 "incdec_operand" "")
6524         (const_string "incdec")
6525         (const_string "alu")))
6526    (set_attr "mode" "HI")])
6527
6528 (define_expand "addqi3"
6529   [(parallel [(set (match_operand:QI 0 "nonimmediate_operand" "")
6530                    (plus:QI (match_operand:QI 1 "nonimmediate_operand" "")
6531                             (match_operand:QI 2 "general_operand" "")))
6532               (clobber (reg:CC 17))])]
6533   "TARGET_QIMODE_MATH"
6534   "ix86_expand_binary_operator (PLUS, QImode, operands); DONE;")
6535
6536 ;; %%% Potential partial reg stall on alternative 2.  What to do?
6537 (define_insn "*addqi_1_lea"
6538   [(set (match_operand:QI 0 "nonimmediate_operand" "=qm,q,r,r")
6539         (plus:QI (match_operand:QI 1 "nonimmediate_operand" "%0,0,0,r")
6540                  (match_operand:QI 2 "general_operand" "qn,qmn,rn,rn")))
6541    (clobber (reg:CC 17))]
6542   "!TARGET_PARTIAL_REG_STALL
6543    && ix86_binary_operator_ok (PLUS, QImode, operands)"
6544 {
6545   int widen = (which_alternative == 2);
6546   switch (get_attr_type (insn))
6547     {
6548     case TYPE_LEA:
6549       return "#";
6550     case TYPE_INCDEC:
6551       if (operands[2] == const1_rtx)
6552         return widen ? "inc{l}\t%k0" : "inc{b}\t%0";
6553       else if (operands[2] == constm1_rtx
6554                || (GET_CODE (operands[2]) == CONST_INT
6555                    && INTVAL (operands[2]) == 255))
6556         return widen ? "dec{l}\t%k0" : "dec{b}\t%0";
6557       abort();
6558
6559     default:
6560       /* Make things pretty and `subl $4,%eax' rather than `addl $-4, %eax'.
6561          Exceptions: -128 encodes smaller than 128, so swap sign and op.  */
6562       if (GET_CODE (operands[2]) == CONST_INT
6563           && (INTVAL (operands[2]) == 128
6564               || (INTVAL (operands[2]) < 0
6565                   && INTVAL (operands[2]) != -128)))
6566         {
6567           operands[2] = GEN_INT (-INTVAL (operands[2]));
6568           if (widen)
6569             return "sub{l}\t{%2, %k0|%k0, %2}";
6570           else
6571             return "sub{b}\t{%2, %0|%0, %2}";
6572         }
6573       if (widen)
6574         return "add{l}\t{%k2, %k0|%k0, %k2}";
6575       else
6576         return "add{b}\t{%2, %0|%0, %2}";
6577     }
6578 }
6579   [(set (attr "type")
6580      (if_then_else (eq_attr "alternative" "3")
6581         (const_string "lea")
6582         (if_then_else (match_operand:QI 2 "incdec_operand" "")
6583            (const_string "incdec")
6584            (const_string "alu"))))
6585    (set_attr "mode" "QI,QI,SI,SI")])
6586
6587 (define_insn "*addqi_1"
6588   [(set (match_operand:QI 0 "nonimmediate_operand" "=qm,q,r")
6589         (plus:QI (match_operand:QI 1 "nonimmediate_operand" "%0,0,0")
6590                  (match_operand:QI 2 "general_operand" "qn,qmn,rn")))
6591    (clobber (reg:CC 17))]
6592   "TARGET_PARTIAL_REG_STALL
6593    && ix86_binary_operator_ok (PLUS, QImode, operands)"
6594 {
6595   int widen = (which_alternative == 2);
6596   switch (get_attr_type (insn))
6597     {
6598     case TYPE_INCDEC:
6599       if (operands[2] == const1_rtx)
6600         return widen ? "inc{l}\t%k0" : "inc{b}\t%0";
6601       else if (operands[2] == constm1_rtx
6602                || (GET_CODE (operands[2]) == CONST_INT
6603                    && INTVAL (operands[2]) == 255))
6604         return widen ? "dec{l}\t%k0" : "dec{b}\t%0";
6605       abort();
6606
6607     default:
6608       /* Make things pretty and `subl $4,%eax' rather than `addl $-4, %eax'.
6609          Exceptions: -128 encodes smaller than 128, so swap sign and op.  */
6610       if (GET_CODE (operands[2]) == CONST_INT
6611           && (INTVAL (operands[2]) == 128
6612               || (INTVAL (operands[2]) < 0
6613                   && INTVAL (operands[2]) != -128)))
6614         {
6615           operands[2] = GEN_INT (-INTVAL (operands[2]));
6616           if (widen)
6617             return "sub{l}\t{%2, %k0|%k0, %2}";
6618           else
6619             return "sub{b}\t{%2, %0|%0, %2}";
6620         }
6621       if (widen)
6622         return "add{l}\t{%k2, %k0|%k0, %k2}";
6623       else
6624         return "add{b}\t{%2, %0|%0, %2}";
6625     }
6626 }
6627   [(set (attr "type")
6628      (if_then_else (match_operand:QI 2 "incdec_operand" "")
6629         (const_string "incdec")
6630         (const_string "alu")))
6631    (set_attr "mode" "QI,QI,SI")])
6632
6633 (define_insn "*addqi_2"
6634   [(set (reg 17)
6635         (compare
6636           (plus:QI (match_operand:QI 1 "nonimmediate_operand" "%0,0")
6637                    (match_operand:QI 2 "general_operand" "qmni,qni"))
6638           (const_int 0)))
6639    (set (match_operand:QI 0 "nonimmediate_operand" "=q,qm")
6640         (plus:QI (match_dup 1) (match_dup 2)))]
6641   "ix86_match_ccmode (insn, CCGOCmode)
6642    && ix86_binary_operator_ok (PLUS, QImode, operands)"
6643 {
6644   switch (get_attr_type (insn))
6645     {
6646     case TYPE_INCDEC:
6647       if (operands[2] == const1_rtx)
6648         return "inc{b}\t%0";
6649       else if (operands[2] == constm1_rtx
6650                || (GET_CODE (operands[2]) == CONST_INT
6651                    && INTVAL (operands[2]) == 255))
6652         return "dec{b}\t%0";
6653       abort();
6654
6655     default:
6656       /* Make things pretty and `subb $4,%al' rather than `addb $-4, %al'.  */
6657       if (GET_CODE (operands[2]) == CONST_INT
6658           && INTVAL (operands[2]) < 0)
6659         {
6660           operands[2] = GEN_INT (-INTVAL (operands[2]));
6661           return "sub{b}\t{%2, %0|%0, %2}";
6662         }
6663       return "add{b}\t{%2, %0|%0, %2}";
6664     }
6665 }
6666   [(set (attr "type")
6667      (if_then_else (match_operand:QI 2 "incdec_operand" "")
6668         (const_string "incdec")
6669         (const_string "alu")))
6670    (set_attr "mode" "QI")])
6671
6672 (define_insn "*addqi_3"
6673   [(set (reg 17)
6674         (compare (neg:QI (match_operand:QI 2 "general_operand" "qmni"))
6675                  (match_operand:QI 1 "nonimmediate_operand" "%0")))
6676    (clobber (match_scratch:QI 0 "=q"))]
6677   "ix86_match_ccmode (insn, CCZmode)
6678    && (GET_CODE (operands[1]) != MEM || GET_CODE (operands[2]) != MEM)"
6679 {
6680   switch (get_attr_type (insn))
6681     {
6682     case TYPE_INCDEC:
6683       if (operands[2] == const1_rtx)
6684         return "inc{b}\t%0";
6685       else if (operands[2] == constm1_rtx
6686                || (GET_CODE (operands[2]) == CONST_INT
6687                    && INTVAL (operands[2]) == 255))
6688         return "dec{b}\t%0";
6689       abort();
6690
6691     default:
6692       /* Make things pretty and `subb $4,%al' rather than `addb $-4, %al'.  */
6693       if (GET_CODE (operands[2]) == CONST_INT
6694           && INTVAL (operands[2]) < 0)
6695         {
6696           operands[2] = GEN_INT (-INTVAL (operands[2]));
6697           return "sub{b}\t{%2, %0|%0, %2}";
6698         }
6699       return "add{b}\t{%2, %0|%0, %2}";
6700     }
6701 }
6702   [(set (attr "type")
6703      (if_then_else (match_operand:QI 2 "incdec_operand" "")
6704         (const_string "incdec")
6705         (const_string "alu")))
6706    (set_attr "mode" "QI")])
6707
6708 ; See comments above addsi_3_imm for details.
6709 (define_insn "*addqi_4"
6710   [(set (reg 17)
6711         (compare (match_operand:QI 1 "nonimmediate_operand" "0")
6712                  (match_operand:QI 2 "const_int_operand" "n")))
6713    (clobber (match_scratch:QI 0 "=qm"))]
6714   "ix86_match_ccmode (insn, CCGCmode)
6715    && (INTVAL (operands[2]) & 0xff) != 0x80"
6716 {
6717   switch (get_attr_type (insn))
6718     {
6719     case TYPE_INCDEC:
6720       if (operands[2] == constm1_rtx
6721           || (GET_CODE (operands[2]) == CONST_INT
6722               && INTVAL (operands[2]) == 255))
6723         return "inc{b}\t%0";
6724       else if (operands[2] == const1_rtx)
6725         return "dec{b}\t%0";
6726       else
6727         abort();
6728
6729     default:
6730       if (! rtx_equal_p (operands[0], operands[1]))
6731         abort ();
6732       if (INTVAL (operands[2]) < 0)
6733         {
6734           operands[2] = GEN_INT (-INTVAL (operands[2]));
6735           return "add{b}\t{%2, %0|%0, %2}";
6736         }
6737       return "sub{b}\t{%2, %0|%0, %2}";
6738     }
6739 }
6740   [(set (attr "type")
6741      (if_then_else (match_operand:HI 2 "incdec_operand" "")
6742         (const_string "incdec")
6743         (const_string "alu")))
6744    (set_attr "mode" "QI")])
6745
6746
6747 (define_insn "*addqi_5"
6748   [(set (reg 17)
6749         (compare
6750           (plus:QI (match_operand:QI 1 "nonimmediate_operand" "%0")
6751                    (match_operand:QI 2 "general_operand" "qmni"))
6752           (const_int 0)))
6753    (clobber (match_scratch:QI 0 "=q"))]
6754   "ix86_match_ccmode (insn, CCGOCmode)
6755    && (GET_CODE (operands[1]) != MEM || GET_CODE (operands[2]) != MEM)"
6756 {
6757   switch (get_attr_type (insn))
6758     {
6759     case TYPE_INCDEC:
6760       if (operands[2] == const1_rtx)
6761         return "inc{b}\t%0";
6762       else if (operands[2] == constm1_rtx
6763                || (GET_CODE (operands[2]) == CONST_INT
6764                    && INTVAL (operands[2]) == 255))
6765         return "dec{b}\t%0";
6766       abort();
6767
6768     default:
6769       /* Make things pretty and `subb $4,%al' rather than `addb $-4, %al'.  */
6770       if (GET_CODE (operands[2]) == CONST_INT
6771           && INTVAL (operands[2]) < 0)
6772         {
6773           operands[2] = GEN_INT (-INTVAL (operands[2]));
6774           return "sub{b}\t{%2, %0|%0, %2}";
6775         }
6776       return "add{b}\t{%2, %0|%0, %2}";
6777     }
6778 }
6779   [(set (attr "type")
6780      (if_then_else (match_operand:QI 2 "incdec_operand" "")
6781         (const_string "incdec")
6782         (const_string "alu")))
6783    (set_attr "mode" "QI")])
6784
6785
6786 (define_insn "addqi_ext_1"
6787   [(set (zero_extract:SI (match_operand 0 "ext_register_operand" "=Q")
6788                          (const_int 8)
6789                          (const_int 8))
6790         (plus:SI
6791           (zero_extract:SI
6792             (match_operand 1 "ext_register_operand" "0")
6793             (const_int 8)
6794             (const_int 8))
6795           (match_operand:QI 2 "general_operand" "Qmn")))
6796    (clobber (reg:CC 17))]
6797   "!TARGET_64BIT"
6798 {
6799   switch (get_attr_type (insn))
6800     {
6801     case TYPE_INCDEC:
6802       if (operands[2] == const1_rtx)
6803         return "inc{b}\t%h0";
6804       else if (operands[2] == constm1_rtx
6805                || (GET_CODE (operands[2]) == CONST_INT
6806                    && INTVAL (operands[2]) == 255))
6807         return "dec{b}\t%h0";
6808       abort();
6809
6810     default:
6811       return "add{b}\t{%2, %h0|%h0, %2}";
6812     }
6813 }
6814   [(set (attr "type")
6815      (if_then_else (match_operand:QI 2 "incdec_operand" "")
6816         (const_string "incdec")
6817         (const_string "alu")))
6818    (set_attr "mode" "QI")])
6819
6820 (define_insn "*addqi_ext_1_rex64"
6821   [(set (zero_extract:SI (match_operand 0 "ext_register_operand" "=Q")
6822                          (const_int 8)
6823                          (const_int 8))
6824         (plus:SI
6825           (zero_extract:SI
6826             (match_operand 1 "ext_register_operand" "0")
6827             (const_int 8)
6828             (const_int 8))
6829           (match_operand:QI 2 "nonmemory_operand" "Qn")))
6830    (clobber (reg:CC 17))]
6831   "TARGET_64BIT"
6832 {
6833   switch (get_attr_type (insn))
6834     {
6835     case TYPE_INCDEC:
6836       if (operands[2] == const1_rtx)
6837         return "inc{b}\t%h0";
6838       else if (operands[2] == constm1_rtx
6839                || (GET_CODE (operands[2]) == CONST_INT
6840                    && INTVAL (operands[2]) == 255))
6841         return "dec{b}\t%h0";
6842       abort();
6843
6844     default:
6845       return "add{b}\t{%2, %h0|%h0, %2}";
6846     }
6847 }
6848   [(set (attr "type")
6849      (if_then_else (match_operand:QI 2 "incdec_operand" "")
6850         (const_string "incdec")
6851         (const_string "alu")))
6852    (set_attr "mode" "QI")])
6853
6854 (define_insn "*addqi_ext_2"
6855   [(set (zero_extract:SI (match_operand 0 "ext_register_operand" "=Q")
6856                          (const_int 8)
6857                          (const_int 8))
6858         (plus:SI
6859           (zero_extract:SI
6860             (match_operand 1 "ext_register_operand" "%0")
6861             (const_int 8)
6862             (const_int 8))
6863           (zero_extract:SI
6864             (match_operand 2 "ext_register_operand" "Q")
6865             (const_int 8)
6866             (const_int 8))))
6867    (clobber (reg:CC 17))]
6868   ""
6869   "add{b}\t{%h2, %h0|%h0, %h2}"
6870   [(set_attr "type" "alu")
6871    (set_attr "mode" "QI")])
6872
6873 ;; The patterns that match these are at the end of this file.
6874
6875 (define_expand "addxf3"
6876   [(set (match_operand:XF 0 "register_operand" "")
6877         (plus:XF (match_operand:XF 1 "register_operand" "")
6878                  (match_operand:XF 2 "register_operand" "")))]
6879   "!TARGET_64BIT && TARGET_80387"
6880   "")
6881
6882 (define_expand "addtf3"
6883   [(set (match_operand:TF 0 "register_operand" "")
6884         (plus:TF (match_operand:TF 1 "register_operand" "")
6885                  (match_operand:TF 2 "register_operand" "")))]
6886   "TARGET_80387"
6887   "")
6888
6889 (define_expand "adddf3"
6890   [(set (match_operand:DF 0 "register_operand" "")
6891         (plus:DF (match_operand:DF 1 "register_operand" "")
6892                  (match_operand:DF 2 "nonimmediate_operand" "")))]
6893   "TARGET_80387 || TARGET_SSE2"
6894   "")
6895
6896 (define_expand "addsf3"
6897   [(set (match_operand:SF 0 "register_operand" "")
6898         (plus:SF (match_operand:SF 1 "register_operand" "")
6899                  (match_operand:SF 2 "nonimmediate_operand" "")))]
6900   "TARGET_80387 || TARGET_SSE"
6901   "")
6902 \f
6903 ;; Subtract instructions
6904
6905 ;; %%% splits for subsidi3
6906
6907 (define_expand "subdi3"
6908   [(parallel [(set (match_operand:DI 0 "nonimmediate_operand" "")
6909                    (minus:DI (match_operand:DI 1 "nonimmediate_operand" "")
6910                              (match_operand:DI 2 "x86_64_general_operand" "")))
6911               (clobber (reg:CC 17))])]
6912   ""
6913   "ix86_expand_binary_operator (MINUS, DImode, operands); DONE;")
6914
6915 (define_insn "*subdi3_1"
6916   [(set (match_operand:DI 0 "nonimmediate_operand" "=r,o")
6917         (minus:DI (match_operand:DI 1 "nonimmediate_operand" "0,0")
6918                   (match_operand:DI 2 "general_operand" "roiF,riF")))
6919    (clobber (reg:CC 17))]
6920   "!TARGET_64BIT"
6921   "#")
6922
6923 (define_split
6924   [(set (match_operand:DI 0 "nonimmediate_operand" "")
6925         (minus:DI (match_operand:DI 1 "nonimmediate_operand" "")
6926                   (match_operand:DI 2 "general_operand" "")))
6927    (clobber (reg:CC 17))]
6928   "!TARGET_64BIT && reload_completed"
6929   [(parallel [(set (reg:CC 17) (compare:CC (match_dup 1) (match_dup 2)))
6930               (set (match_dup 0) (minus:SI (match_dup 1) (match_dup 2)))])
6931    (parallel [(set (match_dup 3)
6932                    (minus:SI (match_dup 4)
6933                              (plus:SI (ltu:SI (reg:CC 17) (const_int 0))
6934                                       (match_dup 5))))
6935               (clobber (reg:CC 17))])]
6936   "split_di (operands+0, 1, operands+0, operands+3);
6937    split_di (operands+1, 1, operands+1, operands+4);
6938    split_di (operands+2, 1, operands+2, operands+5);")
6939
6940 (define_insn "subdi3_carry_rex64"
6941   [(set (match_operand:DI 0 "nonimmediate_operand" "=rm,r")
6942           (minus:DI (match_operand:DI 1 "nonimmediate_operand" "0,0")
6943             (plus:DI (ltu:DI (reg:CC 17) (const_int 0))
6944                (match_operand:DI 2 "x86_64_general_operand" "re,rm"))))
6945    (clobber (reg:CC 17))]
6946   "TARGET_64BIT && ix86_binary_operator_ok (MINUS, DImode, operands)"
6947   "sbb{q}\t{%2, %0|%0, %2}"
6948   [(set_attr "type" "alu")
6949    (set_attr "pent_pair" "pu")
6950    (set_attr "ppro_uops" "few")
6951    (set_attr "mode" "DI")])
6952
6953 (define_insn "*subdi_1_rex64"
6954   [(set (match_operand:DI 0 "nonimmediate_operand" "=rm,r")
6955         (minus:DI (match_operand:DI 1 "nonimmediate_operand" "0,0")
6956                   (match_operand:DI 2 "x86_64_general_operand" "re,rm")))
6957    (clobber (reg:CC 17))]
6958   "TARGET_64BIT && ix86_binary_operator_ok (MINUS, DImode, operands)"
6959   "sub{q}\t{%2, %0|%0, %2}"
6960   [(set_attr "type" "alu")
6961    (set_attr "mode" "DI")])
6962
6963 (define_insn "*subdi_2_rex64"
6964   [(set (reg 17)
6965         (compare
6966           (minus:DI (match_operand:DI 1 "nonimmediate_operand" "0,0")
6967                     (match_operand:DI 2 "x86_64_general_operand" "re,rm"))
6968           (const_int 0)))
6969    (set (match_operand:DI 0 "nonimmediate_operand" "=rm,r")
6970         (minus:DI (match_dup 1) (match_dup 2)))]
6971   "TARGET_64BIT && ix86_match_ccmode (insn, CCGOCmode)
6972    && ix86_binary_operator_ok (MINUS, DImode, operands)"
6973   "sub{q}\t{%2, %0|%0, %2}"
6974   [(set_attr "type" "alu")
6975    (set_attr "mode" "DI")])
6976
6977 (define_insn "*subdi_3_rex63"
6978   [(set (reg 17)
6979         (compare (match_operand:DI 1 "nonimmediate_operand" "0,0")
6980                  (match_operand:DI 2 "x86_64_general_operand" "re,rm")))
6981    (set (match_operand:DI 0 "nonimmediate_operand" "=rm,r")
6982         (minus:DI (match_dup 1) (match_dup 2)))]
6983   "TARGET_64BIT && ix86_match_ccmode (insn, CCmode)
6984    && ix86_binary_operator_ok (MINUS, SImode, operands)"
6985   "sub{q}\t{%2, %0|%0, %2}"
6986   [(set_attr "type" "alu")
6987    (set_attr "mode" "DI")])
6988
6989
6990 (define_insn "subsi3_carry"
6991   [(set (match_operand:SI 0 "nonimmediate_operand" "=rm,r")
6992           (minus:SI (match_operand:SI 1 "nonimmediate_operand" "0,0")
6993             (plus:SI (ltu:SI (reg:CC 17) (const_int 0))
6994                (match_operand:SI 2 "general_operand" "ri,rm"))))
6995    (clobber (reg:CC 17))]
6996   "ix86_binary_operator_ok (MINUS, SImode, operands)"
6997   "sbb{l}\t{%2, %0|%0, %2}"
6998   [(set_attr "type" "alu")
6999    (set_attr "pent_pair" "pu")
7000    (set_attr "ppro_uops" "few")
7001    (set_attr "mode" "SI")])
7002
7003 (define_insn "subsi3_carry_zext"
7004   [(set (match_operand:DI 0 "register_operand" "=rm,r")
7005           (zero_extend:DI
7006             (minus:SI (match_operand:SI 1 "register_operand" "0,0")
7007               (plus:SI (ltu:SI (reg:CC 17) (const_int 0))
7008                  (match_operand:SI 2 "general_operand" "ri,rm")))))
7009    (clobber (reg:CC 17))]
7010   "TARGET_64BIT && ix86_binary_operator_ok (MINUS, SImode, operands)"
7011   "sbb{l}\t{%2, %k0|%k0, %2}"
7012   [(set_attr "type" "alu")
7013    (set_attr "pent_pair" "pu")
7014    (set_attr "ppro_uops" "few")
7015    (set_attr "mode" "SI")])
7016
7017 (define_expand "subsi3"
7018   [(parallel [(set (match_operand:SI 0 "nonimmediate_operand" "")
7019                    (minus:SI (match_operand:SI 1 "nonimmediate_operand" "")
7020                              (match_operand:SI 2 "general_operand" "")))
7021               (clobber (reg:CC 17))])]
7022   ""
7023   "ix86_expand_binary_operator (MINUS, SImode, operands); DONE;")
7024
7025 (define_insn "*subsi_1"
7026   [(set (match_operand:SI 0 "nonimmediate_operand" "=rm,r")
7027         (minus:SI (match_operand:SI 1 "nonimmediate_operand" "0,0")
7028                   (match_operand:SI 2 "general_operand" "ri,rm")))
7029    (clobber (reg:CC 17))]
7030   "ix86_binary_operator_ok (MINUS, SImode, operands)"
7031   "sub{l}\t{%2, %0|%0, %2}"
7032   [(set_attr "type" "alu")
7033    (set_attr "mode" "SI")])
7034
7035 (define_insn "*subsi_1_zext"
7036   [(set (match_operand:DI 0 "register_operand" "=r")
7037         (zero_extend:DI
7038           (minus:SI (match_operand:SI 1 "register_operand" "0")
7039                     (match_operand:SI 2 "general_operand" "rim"))))
7040    (clobber (reg:CC 17))]
7041   "TARGET_64BIT && ix86_binary_operator_ok (MINUS, SImode, operands)"
7042   "sub{l}\t{%2, %k0|%k0, %2}"
7043   [(set_attr "type" "alu")
7044    (set_attr "mode" "SI")])
7045
7046 (define_insn "*subsi_2"
7047   [(set (reg 17)
7048         (compare
7049           (minus:SI (match_operand:SI 1 "nonimmediate_operand" "0,0")
7050                     (match_operand:SI 2 "general_operand" "ri,rm"))
7051           (const_int 0)))
7052    (set (match_operand:SI 0 "nonimmediate_operand" "=rm,r")
7053         (minus:SI (match_dup 1) (match_dup 2)))]
7054   "ix86_match_ccmode (insn, CCGOCmode)
7055    && ix86_binary_operator_ok (MINUS, SImode, operands)"
7056   "sub{l}\t{%2, %0|%0, %2}"
7057   [(set_attr "type" "alu")
7058    (set_attr "mode" "SI")])
7059
7060 (define_insn "*subsi_2_zext"
7061   [(set (reg 17)
7062         (compare
7063           (minus:SI (match_operand:SI 1 "register_operand" "0")
7064                     (match_operand:SI 2 "general_operand" "rim"))
7065           (const_int 0)))
7066    (set (match_operand:DI 0 "register_operand" "=r")
7067         (zero_extend:DI
7068           (minus:SI (match_dup 1)
7069                     (match_dup 2))))]
7070   "TARGET_64BIT && ix86_match_ccmode (insn, CCGOCmode)
7071    && ix86_binary_operator_ok (MINUS, SImode, operands)"
7072   "sub{l}\t{%2, %k0|%k0, %2}"
7073   [(set_attr "type" "alu")
7074    (set_attr "mode" "SI")])
7075
7076 (define_insn "*subsi_3"
7077   [(set (reg 17)
7078         (compare (match_operand:SI 1 "nonimmediate_operand" "0,0")
7079                  (match_operand:SI 2 "general_operand" "ri,rm")))
7080    (set (match_operand:SI 0 "nonimmediate_operand" "=rm,r")
7081         (minus:SI (match_dup 1) (match_dup 2)))]
7082   "ix86_match_ccmode (insn, CCmode)
7083    && ix86_binary_operator_ok (MINUS, SImode, operands)"
7084   "sub{l}\t{%2, %0|%0, %2}"
7085   [(set_attr "type" "alu")
7086    (set_attr "mode" "SI")])
7087
7088 (define_insn "*subsi_3_zext"
7089   [(set (reg 17)
7090         (compare (match_operand:SI 1 "nonimmediate_operand" "0")
7091                  (match_operand:SI 2 "general_operand" "rim")))
7092    (set (match_operand:DI 0 "register_operand" "=r")
7093         (zero_extend:DI
7094           (minus:SI (match_dup 1)
7095                     (match_dup 2))))]
7096   "TARGET_64BIT && ix86_match_ccmode (insn, CCmode)
7097    && ix86_binary_operator_ok (MINUS, SImode, operands)"
7098   "sub{q}\t{%2, %0|%0, %2}"
7099   [(set_attr "type" "alu")
7100    (set_attr "mode" "DI")])
7101
7102 (define_expand "subhi3"
7103   [(parallel [(set (match_operand:HI 0 "nonimmediate_operand" "")
7104                    (minus:HI (match_operand:HI 1 "nonimmediate_operand" "")
7105                              (match_operand:HI 2 "general_operand" "")))
7106               (clobber (reg:CC 17))])]
7107   "TARGET_HIMODE_MATH"
7108   "ix86_expand_binary_operator (MINUS, HImode, operands); DONE;")
7109
7110 (define_insn "*subhi_1"
7111   [(set (match_operand:HI 0 "nonimmediate_operand" "=rm,r")
7112         (minus:HI (match_operand:HI 1 "nonimmediate_operand" "0,0")
7113                   (match_operand:HI 2 "general_operand" "ri,rm")))
7114    (clobber (reg:CC 17))]
7115   "ix86_binary_operator_ok (MINUS, HImode, operands)"
7116   "sub{w}\t{%2, %0|%0, %2}"
7117   [(set_attr "type" "alu")
7118    (set_attr "mode" "HI")])
7119
7120 (define_insn "*subhi_2"
7121   [(set (reg 17)
7122         (compare
7123           (minus:HI (match_operand:HI 1 "nonimmediate_operand" "0,0")
7124                     (match_operand:HI 2 "general_operand" "ri,rm"))
7125           (const_int 0)))
7126    (set (match_operand:HI 0 "nonimmediate_operand" "=rm,r")
7127         (minus:HI (match_dup 1) (match_dup 2)))]
7128   "ix86_match_ccmode (insn, CCGOCmode)
7129    && ix86_binary_operator_ok (MINUS, HImode, operands)"
7130   "sub{w}\t{%2, %0|%0, %2}"
7131   [(set_attr "type" "alu")
7132    (set_attr "mode" "HI")])
7133
7134 (define_insn "*subhi_3"
7135   [(set (reg 17)
7136         (compare (match_operand:HI 1 "nonimmediate_operand" "0,0")
7137                  (match_operand:HI 2 "general_operand" "ri,rm")))
7138    (set (match_operand:HI 0 "nonimmediate_operand" "=rm,r")
7139         (minus:HI (match_dup 1) (match_dup 2)))]
7140   "ix86_match_ccmode (insn, CCmode)
7141    && ix86_binary_operator_ok (MINUS, HImode, operands)"
7142   "sub{w}\t{%2, %0|%0, %2}"
7143   [(set_attr "type" "alu")
7144    (set_attr "mode" "HI")])
7145
7146 (define_expand "subqi3"
7147   [(parallel [(set (match_operand:QI 0 "nonimmediate_operand" "")
7148                    (minus:QI (match_operand:QI 1 "nonimmediate_operand" "")
7149                              (match_operand:QI 2 "general_operand" "")))
7150               (clobber (reg:CC 17))])]
7151   "TARGET_QIMODE_MATH"
7152   "ix86_expand_binary_operator (MINUS, QImode, operands); DONE;")
7153
7154 (define_insn "*subqi_1"
7155   [(set (match_operand:QI 0 "nonimmediate_operand" "=qm,q")
7156         (minus:QI (match_operand:QI 1 "nonimmediate_operand" "0,0")
7157                   (match_operand:QI 2 "general_operand" "qn,qmn")))
7158    (clobber (reg:CC 17))]
7159   "ix86_binary_operator_ok (MINUS, QImode, operands)"
7160   "sub{b}\t{%2, %0|%0, %2}"
7161   [(set_attr "type" "alu")
7162    (set_attr "mode" "QI")])
7163
7164 (define_insn "*subqi_2"
7165   [(set (reg 17)
7166         (compare
7167           (minus:QI (match_operand:QI 1 "nonimmediate_operand" "0,0")
7168                     (match_operand:QI 2 "general_operand" "qi,qm"))
7169           (const_int 0)))
7170    (set (match_operand:HI 0 "nonimmediate_operand" "=qm,q")
7171         (minus:HI (match_dup 1) (match_dup 2)))]
7172   "ix86_match_ccmode (insn, CCGOCmode)
7173    && ix86_binary_operator_ok (MINUS, QImode, operands)"
7174   "sub{b}\t{%2, %0|%0, %2}"
7175   [(set_attr "type" "alu")
7176    (set_attr "mode" "QI")])
7177
7178 (define_insn "*subqi_3"
7179   [(set (reg 17)
7180         (compare (match_operand:QI 1 "nonimmediate_operand" "0,0")
7181                  (match_operand:QI 2 "general_operand" "qi,qm")))
7182    (set (match_operand:HI 0 "nonimmediate_operand" "=qm,q")
7183         (minus:HI (match_dup 1) (match_dup 2)))]
7184   "ix86_match_ccmode (insn, CCmode)
7185    && ix86_binary_operator_ok (MINUS, QImode, operands)"
7186   "sub{b}\t{%2, %0|%0, %2}"
7187   [(set_attr "type" "alu")
7188    (set_attr "mode" "QI")])
7189
7190 ;; The patterns that match these are at the end of this file.
7191
7192 (define_expand "subxf3"
7193   [(set (match_operand:XF 0 "register_operand" "")
7194         (minus:XF (match_operand:XF 1 "register_operand" "")
7195                   (match_operand:XF 2 "register_operand" "")))]
7196   "!TARGET_64BIT && TARGET_80387"
7197   "")
7198
7199 (define_expand "subtf3"
7200   [(set (match_operand:TF 0 "register_operand" "")
7201         (minus:TF (match_operand:TF 1 "register_operand" "")
7202                   (match_operand:TF 2 "register_operand" "")))]
7203   "TARGET_80387"
7204   "")
7205
7206 (define_expand "subdf3"
7207   [(set (match_operand:DF 0 "register_operand" "")
7208         (minus:DF (match_operand:DF 1 "register_operand" "")
7209                   (match_operand:DF 2 "nonimmediate_operand" "")))]
7210   "TARGET_80387 || TARGET_SSE2"
7211   "")
7212
7213 (define_expand "subsf3"
7214   [(set (match_operand:SF 0 "register_operand" "")
7215         (minus:SF (match_operand:SF 1 "register_operand" "")
7216                   (match_operand:SF 2 "nonimmediate_operand" "")))]
7217   "TARGET_80387 || TARGET_SSE"
7218   "")
7219 \f
7220 ;; Multiply instructions
7221
7222 (define_expand "muldi3"
7223   [(parallel [(set (match_operand:DI 0 "register_operand" "")
7224                    (mult:DI (match_operand:DI 1 "register_operand" "")
7225                             (match_operand:DI 2 "x86_64_general_operand" "")))
7226               (clobber (reg:CC 17))])]
7227   "TARGET_64BIT"
7228   "")
7229
7230 (define_insn "*muldi3_1_rex64"
7231   [(set (match_operand:DI 0 "register_operand" "=r,r,r")
7232         (mult:DI (match_operand:DI 1 "nonimmediate_operand" "%rm,0,0")
7233                  (match_operand:DI 2 "x86_64_general_operand" "K,e,mr")))
7234    (clobber (reg:CC 17))]
7235   "TARGET_64BIT
7236    && (GET_CODE (operands[1]) != MEM || GET_CODE (operands[2]) != MEM)"
7237   "@
7238    imul{q}\t{%2, %1, %0|%0, %1, %2}
7239    imul{q}\t{%2, %1, %0|%0, %1, %2}
7240    imul{q}\t{%2, %0|%0, %2}"
7241   [(set_attr "type" "imul")
7242    (set_attr "prefix_0f" "0,0,1")
7243    (set_attr "mode" "DI")])
7244
7245 (define_expand "mulsi3"
7246   [(parallel [(set (match_operand:SI 0 "register_operand" "")
7247                    (mult:SI (match_operand:SI 1 "register_operand" "")
7248                             (match_operand:SI 2 "general_operand" "")))
7249               (clobber (reg:CC 17))])]
7250   ""
7251   "")
7252
7253 (define_insn "*mulsi3_1"
7254   [(set (match_operand:SI 0 "register_operand" "=r,r,r")
7255         (mult:SI (match_operand:SI 1 "nonimmediate_operand" "%rm,0,0")
7256                  (match_operand:SI 2 "general_operand" "K,i,mr")))
7257    (clobber (reg:CC 17))]
7258   "GET_CODE (operands[1]) != MEM || GET_CODE (operands[2]) != MEM"
7259   ; For the {r,0,i} alternative (i.e., register <- register * immediate),
7260   ; there are two ways of writing the exact same machine instruction
7261   ; in assembly language.  One, for example, is:
7262   ;
7263   ;   imul $12, %eax
7264   ;
7265   ; while the other is:
7266   ;
7267   ;   imul $12, %eax, %eax
7268   ;
7269   ; The first is simply short-hand for the latter.  But, some assemblers,
7270   ; like the SCO OSR5 COFF assembler, don't handle the first form.
7271   "@
7272    imul{l}\t{%2, %1, %0|%0, %1, %2}
7273    imul{l}\t{%2, %1, %0|%0, %1, %2}
7274    imul{l}\t{%2, %0|%0, %2}"
7275   [(set_attr "type" "imul")
7276    (set_attr "prefix_0f" "0,0,1")
7277    (set_attr "mode" "SI")])
7278
7279 (define_insn "*mulsi3_1_zext"
7280   [(set (match_operand:DI 0 "register_operand" "=r,r,r")
7281         (zero_extend:DI
7282           (mult:SI (match_operand:SI 1 "nonimmediate_operand" "%rm,0,0")
7283                    (match_operand:SI 2 "general_operand" "K,i,mr"))))
7284    (clobber (reg:CC 17))]
7285   "TARGET_64BIT
7286    && (GET_CODE (operands[1]) != MEM || GET_CODE (operands[2]) != MEM)"
7287   ; For the {r,0,i} alternative (i.e., register <- register * immediate),
7288   ; there are two ways of writing the exact same machine instruction
7289   ; in assembly language.  One, for example, is:
7290   ;
7291   ;   imul $12, %eax
7292   ;
7293   ; while the other is:
7294   ;
7295   ;   imul $12, %eax, %eax
7296   ;
7297   ; The first is simply short-hand for the latter.  But, some assemblers,
7298   ; like the SCO OSR5 COFF assembler, don't handle the first form.
7299   "@
7300    imul{l}\t{%2, %1, %k0|%k0, %1, %2}
7301    imul{l}\t{%2, %1, %k0|%k0, %1, %2}
7302    imul{l}\t{%2, %k0|%k0, %2}"
7303   [(set_attr "type" "imul")
7304    (set_attr "prefix_0f" "0,0,1")
7305    (set_attr "mode" "SI")])
7306
7307 (define_expand "mulhi3"
7308   [(parallel [(set (match_operand:HI 0 "register_operand" "")
7309                    (mult:HI (match_operand:HI 1 "register_operand" "")
7310                             (match_operand:HI 2 "general_operand" "")))
7311               (clobber (reg:CC 17))])]
7312   "TARGET_HIMODE_MATH"
7313   "")
7314
7315 (define_insn "*mulhi3_1"
7316   [(set (match_operand:HI 0 "register_operand" "=r,r,r")
7317         (mult:HI (match_operand:HI 1 "nonimmediate_operand" "%rm,0,0")
7318                  (match_operand:HI 2 "general_operand" "K,i,mr")))
7319    (clobber (reg:CC 17))]
7320   "GET_CODE (operands[1]) != MEM || GET_CODE (operands[2]) != MEM"
7321   ; %%% There was a note about "Assembler has weird restrictions",
7322   ; concerning alternative 1 when op1 == op0.  True?
7323   "@
7324    imul{w}\t{%2, %1, %0|%0, %1, %2}
7325    imul{w}\t{%2, %1, %0|%0, %1, %2}
7326    imul{w}\t{%2, %0|%0, %2}"
7327   [(set_attr "type" "imul")
7328    (set_attr "prefix_0f" "0,0,1")
7329    (set_attr "mode" "HI")])
7330
7331 (define_insn "mulqi3"
7332   [(set (match_operand:QI 0 "register_operand" "=a")
7333         (mult:QI (match_operand:QI 1 "register_operand" "%0")
7334                  (match_operand:QI 2 "nonimmediate_operand" "qm")))
7335    (clobber (reg:CC 17))]
7336   "TARGET_QIMODE_MATH"
7337   "mul{b}\t%2"
7338   [(set_attr "type" "imul")
7339    (set_attr "length_immediate" "0")
7340    (set_attr "mode" "QI")])
7341
7342 (define_insn "umulqihi3"
7343   [(set (match_operand:HI 0 "register_operand" "=a")
7344         (mult:HI (zero_extend:HI (match_operand:QI 1 "register_operand" "%0"))
7345                  (zero_extend:HI (match_operand:QI 2 "nonimmediate_operand" "qm"))))
7346    (clobber (reg:CC 17))]
7347   "TARGET_QIMODE_MATH"
7348   "mul{b}\t%2"
7349   [(set_attr "type" "imul")
7350    (set_attr "length_immediate" "0")
7351    (set_attr "mode" "QI")])
7352
7353 (define_insn "mulqihi3"
7354   [(set (match_operand:HI 0 "register_operand" "=a")
7355         (mult:HI (sign_extend:HI (match_operand:QI 1 "register_operand" "%0"))
7356                  (sign_extend:HI (match_operand:QI 2 "nonimmediate_operand" "qm"))))
7357    (clobber (reg:CC 17))]
7358   "TARGET_QIMODE_MATH"
7359   "imul{b}\t%2"
7360   [(set_attr "type" "imul")
7361    (set_attr "length_immediate" "0")
7362    (set_attr "mode" "QI")])
7363
7364 (define_insn "umulditi3"
7365   [(set (match_operand:TI 0 "register_operand" "=A")
7366         (mult:TI (zero_extend:TI (match_operand:DI 1 "register_operand" "%0"))
7367                  (zero_extend:TI (match_operand:DI 2 "nonimmediate_operand" "rm"))))
7368    (clobber (reg:CC 17))]
7369   "TARGET_64BIT"
7370   "mul{q}\t%2"
7371   [(set_attr "type" "imul")
7372    (set_attr "ppro_uops" "few")
7373    (set_attr "length_immediate" "0")
7374    (set_attr "mode" "DI")])
7375
7376 ;; We can't use this pattern in 64bit mode, since it results in two separate 32bit registers
7377 (define_insn "umulsidi3"
7378   [(set (match_operand:DI 0 "register_operand" "=A")
7379         (mult:DI (zero_extend:DI (match_operand:SI 1 "register_operand" "%0"))
7380                  (zero_extend:DI (match_operand:SI 2 "nonimmediate_operand" "rm"))))
7381    (clobber (reg:CC 17))]
7382   "!TARGET_64BIT"
7383   "mul{l}\t%2"
7384   [(set_attr "type" "imul")
7385    (set_attr "ppro_uops" "few")
7386    (set_attr "length_immediate" "0")
7387    (set_attr "mode" "SI")])
7388
7389 (define_insn "mulditi3"
7390   [(set (match_operand:TI 0 "register_operand" "=A")
7391         (mult:TI (sign_extend:TI (match_operand:DI 1 "register_operand" "%0"))
7392                  (sign_extend:TI (match_operand:DI 2 "nonimmediate_operand" "rm"))))
7393    (clobber (reg:CC 17))]
7394   "TARGET_64BIT"
7395   "imul{q}\t%2"
7396   [(set_attr "type" "imul")
7397    (set_attr "length_immediate" "0")
7398    (set_attr "mode" "DI")])
7399
7400 (define_insn "mulsidi3"
7401   [(set (match_operand:DI 0 "register_operand" "=A")
7402         (mult:DI (sign_extend:DI (match_operand:SI 1 "register_operand" "%0"))
7403                  (sign_extend:DI (match_operand:SI 2 "nonimmediate_operand" "rm"))))
7404    (clobber (reg:CC 17))]
7405   "!TARGET_64BIT"
7406   "imul{l}\t%2"
7407   [(set_attr "type" "imul")
7408    (set_attr "length_immediate" "0")
7409    (set_attr "mode" "SI")])
7410
7411 (define_insn "*umuldi3_highpart_rex64"
7412   [(set (match_operand:DI 0 "register_operand" "=d")
7413         (truncate:DI
7414           (lshiftrt:TI
7415             (mult:TI (zero_extend:TI
7416                        (match_operand:DI 1 "register_operand" "%a"))
7417                      (zero_extend:TI
7418                        (match_operand:DI 2 "nonimmediate_operand" "rm")))
7419             (const_int 64))))
7420    (clobber (match_scratch:DI 3 "=a"))
7421    (clobber (reg:CC 17))]
7422   "TARGET_64BIT"
7423   "mul{q}\t%2"
7424   [(set_attr "type" "imul")
7425    (set_attr "ppro_uops" "few")
7426    (set_attr "length_immediate" "0")
7427    (set_attr "mode" "DI")])
7428
7429 (define_insn "umulsi3_highpart"
7430   [(set (match_operand:SI 0 "register_operand" "=d")
7431         (truncate:SI
7432           (lshiftrt:DI
7433             (mult:DI (zero_extend:DI
7434                        (match_operand:SI 1 "register_operand" "%a"))
7435                      (zero_extend:DI
7436                        (match_operand:SI 2 "nonimmediate_operand" "rm")))
7437             (const_int 32))))
7438    (clobber (match_scratch:SI 3 "=a"))
7439    (clobber (reg:CC 17))]
7440   ""
7441   "mul{l}\t%2"
7442   [(set_attr "type" "imul")
7443    (set_attr "ppro_uops" "few")
7444    (set_attr "length_immediate" "0")
7445    (set_attr "mode" "SI")])
7446
7447 (define_insn "*umulsi3_highpart_zext"
7448   [(set (match_operand:DI 0 "register_operand" "=d")
7449         (zero_extend:DI (truncate:SI
7450           (lshiftrt:DI
7451             (mult:DI (zero_extend:DI
7452                        (match_operand:SI 1 "register_operand" "%a"))
7453                      (zero_extend:DI
7454                        (match_operand:SI 2 "nonimmediate_operand" "rm")))
7455             (const_int 32)))))
7456    (clobber (match_scratch:SI 3 "=a"))
7457    (clobber (reg:CC 17))]
7458   "TARGET_64BIT"
7459   "mul{l}\t%2"
7460   [(set_attr "type" "imul")
7461    (set_attr "ppro_uops" "few")
7462    (set_attr "length_immediate" "0")
7463    (set_attr "mode" "SI")])
7464
7465 (define_insn "*smuldi3_highpart_rex64"
7466   [(set (match_operand:DI 0 "register_operand" "=d")
7467         (truncate:DI
7468           (lshiftrt:TI
7469             (mult:TI (sign_extend:TI
7470                        (match_operand:DI 1 "register_operand" "%a"))
7471                      (sign_extend:TI
7472                        (match_operand:DI 2 "nonimmediate_operand" "rm")))
7473             (const_int 64))))
7474    (clobber (match_scratch:DI 3 "=a"))
7475    (clobber (reg:CC 17))]
7476   "TARGET_64BIT"
7477   "imul{q}\t%2"
7478   [(set_attr "type" "imul")
7479    (set_attr "ppro_uops" "few")
7480    (set_attr "mode" "DI")])
7481
7482 (define_insn "smulsi3_highpart"
7483   [(set (match_operand:SI 0 "register_operand" "=d")
7484         (truncate:SI
7485           (lshiftrt:DI
7486             (mult:DI (sign_extend:DI
7487                        (match_operand:SI 1 "register_operand" "%a"))
7488                      (sign_extend:DI
7489                        (match_operand:SI 2 "nonimmediate_operand" "rm")))
7490             (const_int 32))))
7491    (clobber (match_scratch:SI 3 "=a"))
7492    (clobber (reg:CC 17))]
7493   ""
7494   "imul{l}\t%2"
7495   [(set_attr "type" "imul")
7496    (set_attr "ppro_uops" "few")
7497    (set_attr "mode" "SI")])
7498
7499 (define_insn "*smulsi3_highpart_zext"
7500   [(set (match_operand:DI 0 "register_operand" "=d")
7501         (zero_extend:DI (truncate:SI
7502           (lshiftrt:DI
7503             (mult:DI (sign_extend:DI
7504                        (match_operand:SI 1 "register_operand" "%a"))
7505                      (sign_extend:DI
7506                        (match_operand:SI 2 "nonimmediate_operand" "rm")))
7507             (const_int 32)))))
7508    (clobber (match_scratch:SI 3 "=a"))
7509    (clobber (reg:CC 17))]
7510   "TARGET_64BIT"
7511   "imul{l}\t%2"
7512   [(set_attr "type" "imul")
7513    (set_attr "ppro_uops" "few")
7514    (set_attr "mode" "SI")])
7515
7516 ;; The patterns that match these are at the end of this file.
7517
7518 (define_expand "mulxf3"
7519   [(set (match_operand:XF 0 "register_operand" "")
7520         (mult:XF (match_operand:XF 1 "register_operand" "")
7521                  (match_operand:XF 2 "register_operand" "")))]
7522   "!TARGET_64BIT && TARGET_80387"
7523   "")
7524
7525 (define_expand "multf3"
7526   [(set (match_operand:TF 0 "register_operand" "")
7527         (mult:TF (match_operand:TF 1 "register_operand" "")
7528                  (match_operand:TF 2 "register_operand" "")))]
7529   "TARGET_80387"
7530   "")
7531
7532 (define_expand "muldf3"
7533   [(set (match_operand:DF 0 "register_operand" "")
7534         (mult:DF (match_operand:DF 1 "register_operand" "")
7535                  (match_operand:DF 2 "nonimmediate_operand" "")))]
7536   "TARGET_80387 || TARGET_SSE2"
7537   "")
7538
7539 (define_expand "mulsf3"
7540   [(set (match_operand:SF 0 "register_operand" "")
7541         (mult:SF (match_operand:SF 1 "register_operand" "")
7542                  (match_operand:SF 2 "nonimmediate_operand" "")))]
7543   "TARGET_80387 || TARGET_SSE"
7544   "")
7545 \f
7546 ;; Divide instructions
7547
7548 (define_insn "divqi3"
7549   [(set (match_operand:QI 0 "register_operand" "=a")
7550         (div:QI (match_operand:HI 1 "register_operand" "0")
7551                 (match_operand:QI 2 "nonimmediate_operand" "qm")))
7552    (clobber (reg:CC 17))]
7553   "TARGET_QIMODE_MATH"
7554   "idiv{b}\t%2"
7555   [(set_attr "type" "idiv")
7556    (set_attr "mode" "QI")
7557    (set_attr "ppro_uops" "few")])
7558
7559 (define_insn "udivqi3"
7560   [(set (match_operand:QI 0 "register_operand" "=a")
7561         (udiv:QI (match_operand:HI 1 "register_operand" "0")
7562                  (match_operand:QI 2 "nonimmediate_operand" "qm")))
7563    (clobber (reg:CC 17))]
7564   "TARGET_QIMODE_MATH"
7565   "div{b}\t%2"
7566   [(set_attr "type" "idiv")
7567    (set_attr "mode" "QI")
7568    (set_attr "ppro_uops" "few")])
7569
7570 ;; The patterns that match these are at the end of this file.
7571
7572 (define_expand "divxf3"
7573   [(set (match_operand:XF 0 "register_operand" "")
7574         (div:XF (match_operand:XF 1 "register_operand" "")
7575                 (match_operand:XF 2 "register_operand" "")))]
7576   "!TARGET_64BIT && TARGET_80387"
7577   "")
7578
7579 (define_expand "divtf3"
7580   [(set (match_operand:TF 0 "register_operand" "")
7581         (div:TF (match_operand:TF 1 "register_operand" "")
7582                 (match_operand:TF 2 "register_operand" "")))]
7583   "TARGET_80387"
7584   "")
7585
7586 (define_expand "divdf3"
7587   [(set (match_operand:DF 0 "register_operand" "")
7588         (div:DF (match_operand:DF 1 "register_operand" "")
7589                 (match_operand:DF 2 "nonimmediate_operand" "")))]
7590    "TARGET_80387 || TARGET_SSE2"
7591    "")
7592  
7593 (define_expand "divsf3"
7594   [(set (match_operand:SF 0 "register_operand" "")
7595         (div:SF (match_operand:SF 1 "register_operand" "")
7596                 (match_operand:SF 2 "nonimmediate_operand" "")))]
7597   "TARGET_80387 || TARGET_SSE"
7598   "")
7599 \f
7600 ;; Remainder instructions.
7601
7602 (define_expand "divmoddi4"
7603   [(parallel [(set (match_operand:DI 0 "register_operand" "")
7604                    (div:DI (match_operand:DI 1 "register_operand" "")
7605                            (match_operand:DI 2 "nonimmediate_operand" "")))
7606               (set (match_operand:DI 3 "register_operand" "")
7607                    (mod:DI (match_dup 1) (match_dup 2)))
7608               (clobber (reg:CC 17))])]
7609   "TARGET_64BIT"
7610   "")
7611
7612 ;; Allow to come the parameter in eax or edx to avoid extra moves.
7613 ;; Penalize eax case sligthly because it results in worse scheduling
7614 ;; of code.
7615 (define_insn "*divmoddi4_nocltd_rex64"
7616   [(set (match_operand:DI 0 "register_operand" "=&a,?a")
7617         (div:DI (match_operand:DI 2 "register_operand" "1,0")
7618                 (match_operand:DI 3 "nonimmediate_operand" "rm,rm")))
7619    (set (match_operand:DI 1 "register_operand" "=&d,&d")
7620         (mod:DI (match_dup 2) (match_dup 3)))
7621    (clobber (reg:CC 17))]
7622   "TARGET_64BIT && !optimize_size && !TARGET_USE_CLTD"
7623   "#"
7624   [(set_attr "type" "multi")])
7625
7626 (define_insn "*divmoddi4_cltd_rex64"
7627   [(set (match_operand:DI 0 "register_operand" "=a")
7628         (div:DI (match_operand:DI 2 "register_operand" "a")
7629                 (match_operand:DI 3 "nonimmediate_operand" "rm")))
7630    (set (match_operand:DI 1 "register_operand" "=&d")
7631         (mod:DI (match_dup 2) (match_dup 3)))
7632    (clobber (reg:CC 17))]
7633   "TARGET_64BIT && (optimize_size || TARGET_USE_CLTD)"
7634   "#"
7635   [(set_attr "type" "multi")])
7636
7637 (define_insn "*divmoddi_noext_rex64"
7638   [(set (match_operand:DI 0 "register_operand" "=a")
7639         (div:DI (match_operand:DI 1 "register_operand" "0")
7640                 (match_operand:DI 2 "nonimmediate_operand" "rm")))
7641    (set (match_operand:DI 3 "register_operand" "=d")
7642         (mod:DI (match_dup 1) (match_dup 2)))
7643    (use (match_operand:DI 4 "register_operand" "3"))
7644    (clobber (reg:CC 17))]
7645   "TARGET_64BIT"
7646   "idiv{q}\t%2"
7647   [(set_attr "type" "idiv")
7648    (set_attr "mode" "DI")
7649    (set_attr "ppro_uops" "few")])
7650
7651 (define_split
7652   [(set (match_operand:DI 0 "register_operand" "")
7653         (div:DI (match_operand:DI 1 "register_operand" "")
7654                 (match_operand:DI 2 "nonimmediate_operand" "")))
7655    (set (match_operand:DI 3 "register_operand" "")
7656         (mod:DI (match_dup 1) (match_dup 2)))
7657    (clobber (reg:CC 17))]
7658   "TARGET_64BIT && reload_completed"
7659   [(parallel [(set (match_dup 3)
7660                    (ashiftrt:DI (match_dup 4) (const_int 63)))
7661               (clobber (reg:CC 17))])
7662    (parallel [(set (match_dup 0)
7663                    (div:DI (reg:DI 0) (match_dup 2)))
7664               (set (match_dup 3)
7665                    (mod:DI (reg:DI 0) (match_dup 2)))
7666               (use (match_dup 3))
7667               (clobber (reg:CC 17))])]
7668 {
7669   /* Avoid use of cltd in favour of a mov+shift.  */
7670   if (!TARGET_USE_CLTD && !optimize_size)
7671     {
7672       if (true_regnum (operands[1]))
7673         emit_move_insn (operands[0], operands[1]);
7674       else
7675         emit_move_insn (operands[3], operands[1]);
7676       operands[4] = operands[3];
7677     }
7678   else
7679     {
7680       if (true_regnum (operands[1]))
7681         abort();
7682       operands[4] = operands[1];
7683     }
7684 })
7685
7686
7687 (define_expand "divmodsi4"
7688   [(parallel [(set (match_operand:SI 0 "register_operand" "")
7689                    (div:SI (match_operand:SI 1 "register_operand" "")
7690                            (match_operand:SI 2 "nonimmediate_operand" "")))
7691               (set (match_operand:SI 3 "register_operand" "")
7692                    (mod:SI (match_dup 1) (match_dup 2)))
7693               (clobber (reg:CC 17))])]
7694   ""
7695   "")
7696
7697 ;; Allow to come the parameter in eax or edx to avoid extra moves.
7698 ;; Penalize eax case sligthly because it results in worse scheduling
7699 ;; of code.
7700 (define_insn "*divmodsi4_nocltd"
7701   [(set (match_operand:SI 0 "register_operand" "=&a,?a")
7702         (div:SI (match_operand:SI 2 "register_operand" "1,0")
7703                 (match_operand:SI 3 "nonimmediate_operand" "rm,rm")))
7704    (set (match_operand:SI 1 "register_operand" "=&d,&d")
7705         (mod:SI (match_dup 2) (match_dup 3)))
7706    (clobber (reg:CC 17))]
7707   "!optimize_size && !TARGET_USE_CLTD"
7708   "#"
7709   [(set_attr "type" "multi")])
7710
7711 (define_insn "*divmodsi4_cltd"
7712   [(set (match_operand:SI 0 "register_operand" "=a")
7713         (div:SI (match_operand:SI 2 "register_operand" "a")
7714                 (match_operand:SI 3 "nonimmediate_operand" "rm")))
7715    (set (match_operand:SI 1 "register_operand" "=&d")
7716         (mod:SI (match_dup 2) (match_dup 3)))
7717    (clobber (reg:CC 17))]
7718   "optimize_size || TARGET_USE_CLTD"
7719   "#"
7720   [(set_attr "type" "multi")])
7721
7722 (define_insn "*divmodsi_noext"
7723   [(set (match_operand:SI 0 "register_operand" "=a")
7724         (div:SI (match_operand:SI 1 "register_operand" "0")
7725                 (match_operand:SI 2 "nonimmediate_operand" "rm")))
7726    (set (match_operand:SI 3 "register_operand" "=d")
7727         (mod:SI (match_dup 1) (match_dup 2)))
7728    (use (match_operand:SI 4 "register_operand" "3"))
7729    (clobber (reg:CC 17))]
7730   ""
7731   "idiv{l}\t%2"
7732   [(set_attr "type" "idiv")
7733    (set_attr "mode" "SI")
7734    (set_attr "ppro_uops" "few")])
7735
7736 (define_split
7737   [(set (match_operand:SI 0 "register_operand" "")
7738         (div:SI (match_operand:SI 1 "register_operand" "")
7739                 (match_operand:SI 2 "nonimmediate_operand" "")))
7740    (set (match_operand:SI 3 "register_operand" "")
7741         (mod:SI (match_dup 1) (match_dup 2)))
7742    (clobber (reg:CC 17))]
7743   "reload_completed"
7744   [(parallel [(set (match_dup 3)
7745                    (ashiftrt:SI (match_dup 4) (const_int 31)))
7746               (clobber (reg:CC 17))])
7747    (parallel [(set (match_dup 0)
7748                    (div:SI (reg:SI 0) (match_dup 2)))
7749               (set (match_dup 3)
7750                    (mod:SI (reg:SI 0) (match_dup 2)))
7751               (use (match_dup 3))
7752               (clobber (reg:CC 17))])]
7753 {
7754   /* Avoid use of cltd in favour of a mov+shift.  */
7755   if (!TARGET_USE_CLTD && !optimize_size)
7756     {
7757       if (true_regnum (operands[1]))
7758         emit_move_insn (operands[0], operands[1]);
7759       else
7760         emit_move_insn (operands[3], operands[1]);
7761       operands[4] = operands[3];
7762     }
7763   else
7764     {
7765       if (true_regnum (operands[1]))
7766         abort();
7767       operands[4] = operands[1];
7768     }
7769 })
7770 ;; %%% Split me.
7771 (define_insn "divmodhi4"
7772   [(set (match_operand:HI 0 "register_operand" "=a")
7773         (div:HI (match_operand:HI 1 "register_operand" "0")
7774                 (match_operand:HI 2 "nonimmediate_operand" "rm")))
7775    (set (match_operand:HI 3 "register_operand" "=&d")
7776         (mod:HI (match_dup 1) (match_dup 2)))
7777    (clobber (reg:CC 17))]
7778   "TARGET_HIMODE_MATH"
7779   "cwtd\;idiv{w}\t%2"
7780   [(set_attr "type" "multi")
7781    (set_attr "length_immediate" "0")
7782    (set_attr "mode" "SI")])
7783
7784 (define_insn "udivmoddi4"
7785   [(set (match_operand:DI 0 "register_operand" "=a")
7786         (udiv:DI (match_operand:DI 1 "register_operand" "0")
7787                  (match_operand:DI 2 "nonimmediate_operand" "rm")))
7788    (set (match_operand:DI 3 "register_operand" "=&d")
7789         (umod:DI (match_dup 1) (match_dup 2)))
7790    (clobber (reg:CC 17))]
7791   "TARGET_64BIT"
7792   "xor{q}\t%3, %3\;div{q}\t%2"
7793   [(set_attr "type" "multi")
7794    (set_attr "length_immediate" "0")
7795    (set_attr "mode" "DI")])
7796
7797 (define_insn "*udivmoddi4_noext"
7798   [(set (match_operand:DI 0 "register_operand" "=a")
7799         (udiv:DI (match_operand:DI 1 "register_operand" "0")
7800                  (match_operand:DI 2 "nonimmediate_operand" "rm")))
7801    (set (match_operand:DI 3 "register_operand" "=d")
7802         (umod:DI (match_dup 1) (match_dup 2)))
7803    (use (match_dup 3))
7804    (clobber (reg:CC 17))]
7805   "TARGET_64BIT"
7806   "div{q}\t%2"
7807   [(set_attr "type" "idiv")
7808    (set_attr "ppro_uops" "few")
7809    (set_attr "mode" "DI")])
7810
7811 (define_split
7812   [(set (match_operand:DI 0 "register_operand" "")
7813         (udiv:DI (match_operand:DI 1 "register_operand" "")
7814                  (match_operand:DI 2 "nonimmediate_operand" "")))
7815    (set (match_operand:DI 3 "register_operand" "")
7816         (umod:DI (match_dup 1) (match_dup 2)))
7817    (clobber (reg:CC 17))]
7818   "TARGET_64BIT && reload_completed"
7819   [(set (match_dup 3) (const_int 0))
7820    (parallel [(set (match_dup 0)
7821                    (udiv:DI (match_dup 1) (match_dup 2)))
7822               (set (match_dup 3)
7823                    (umod:DI (match_dup 1) (match_dup 2)))
7824               (use (match_dup 3))
7825               (clobber (reg:CC 17))])]
7826   "")
7827
7828 (define_insn "udivmodsi4"
7829   [(set (match_operand:SI 0 "register_operand" "=a")
7830         (udiv:SI (match_operand:SI 1 "register_operand" "0")
7831                  (match_operand:SI 2 "nonimmediate_operand" "rm")))
7832    (set (match_operand:SI 3 "register_operand" "=&d")
7833         (umod:SI (match_dup 1) (match_dup 2)))
7834    (clobber (reg:CC 17))]
7835   ""
7836   "xor{l}\t%3, %3\;div{l}\t%2"
7837   [(set_attr "type" "multi")
7838    (set_attr "length_immediate" "0")
7839    (set_attr "mode" "SI")])
7840
7841 (define_insn "*udivmodsi4_noext"
7842   [(set (match_operand:SI 0 "register_operand" "=a")
7843         (udiv:SI (match_operand:SI 1 "register_operand" "0")
7844                  (match_operand:SI 2 "nonimmediate_operand" "rm")))
7845    (set (match_operand:SI 3 "register_operand" "=d")
7846         (umod:SI (match_dup 1) (match_dup 2)))
7847    (use (match_dup 3))
7848    (clobber (reg:CC 17))]
7849   ""
7850   "div{l}\t%2"
7851   [(set_attr "type" "idiv")
7852    (set_attr "ppro_uops" "few")
7853    (set_attr "mode" "SI")])
7854
7855 (define_split
7856   [(set (match_operand:SI 0 "register_operand" "")
7857         (udiv:SI (match_operand:SI 1 "register_operand" "")
7858                  (match_operand:SI 2 "nonimmediate_operand" "")))
7859    (set (match_operand:SI 3 "register_operand" "")
7860         (umod:SI (match_dup 1) (match_dup 2)))
7861    (clobber (reg:CC 17))]
7862   "reload_completed"
7863   [(set (match_dup 3) (const_int 0))
7864    (parallel [(set (match_dup 0)
7865                    (udiv:SI (match_dup 1) (match_dup 2)))
7866               (set (match_dup 3)
7867                    (umod:SI (match_dup 1) (match_dup 2)))
7868               (use (match_dup 3))
7869               (clobber (reg:CC 17))])]
7870   "")
7871
7872 (define_expand "udivmodhi4"
7873   [(set (match_dup 4) (const_int 0))
7874    (parallel [(set (match_operand:HI 0 "register_operand" "")
7875                    (udiv:HI (match_operand:HI 1 "register_operand" "")
7876                             (match_operand:HI 2 "nonimmediate_operand" "")))
7877               (set (match_operand:HI 3 "register_operand" "")
7878                    (umod:HI (match_dup 1) (match_dup 2)))
7879               (use (match_dup 4))
7880               (clobber (reg:CC 17))])]
7881   "TARGET_HIMODE_MATH"
7882   "operands[4] = gen_reg_rtx (HImode);")
7883
7884 (define_insn "*udivmodhi_noext"
7885   [(set (match_operand:HI 0 "register_operand" "=a")
7886         (udiv:HI (match_operand:HI 1 "register_operand" "0")
7887                  (match_operand:HI 2 "nonimmediate_operand" "rm")))
7888    (set (match_operand:HI 3 "register_operand" "=d")
7889         (umod:HI (match_dup 1) (match_dup 2)))
7890    (use (match_operand:HI 4 "register_operand" "3"))
7891    (clobber (reg:CC 17))]
7892   ""
7893   "div{w}\t%2"
7894   [(set_attr "type" "idiv")
7895    (set_attr "mode" "HI")
7896    (set_attr "ppro_uops" "few")])
7897
7898 ;; We can not use div/idiv for double division, because it causes
7899 ;; "division by zero" on the overflow and that's not what we expect
7900 ;; from truncate.  Because true (non truncating) double division is
7901 ;; never generated, we can't create this insn anyway.
7902 ;
7903 ;(define_insn ""
7904 ;  [(set (match_operand:SI 0 "register_operand" "=a")
7905 ;       (truncate:SI
7906 ;         (udiv:DI (match_operand:DI 1 "register_operand" "A")
7907 ;                  (zero_extend:DI
7908 ;                    (match_operand:SI 2 "nonimmediate_operand" "rm")))))
7909 ;   (set (match_operand:SI 3 "register_operand" "=d")
7910 ;       (truncate:SI
7911 ;         (umod:DI (match_dup 1) (zero_extend:DI (match_dup 2)))))
7912 ;   (clobber (reg:CC 17))]
7913 ;  ""
7914 ;  "div{l}\t{%2, %0|%0, %2}"
7915 ;  [(set_attr "type" "idiv")
7916 ;   (set_attr "ppro_uops" "few")])
7917 \f
7918 ;;- Logical AND instructions
7919
7920 ;; On Pentium, "test imm, reg" is pairable only with eax, ax, and al.
7921 ;; Note that this excludes ah.
7922
7923 (define_insn "*testdi_1_rex64"
7924   [(set (reg 17)
7925         (compare
7926           (and:DI (match_operand:DI 0 "nonimmediate_operand" "%*a,r,*a,r,rm")
7927                   (match_operand:DI 1 "x86_64_szext_nonmemory_operand" "Z,Z,e,e,re"))
7928           (const_int 0)))]
7929   "TARGET_64BIT && ix86_match_ccmode (insn, CCNOmode)"
7930   "@
7931    test{l}\t{%k1, %k0|%k0, %k1} 
7932    test{l}\t{%k1, %k0|%k0, %k1} 
7933    test{q}\t{%1, %0|%0, %1} 
7934    test{q}\t{%1, %0|%0, %1} 
7935    test{q}\t{%1, %0|%0, %1}"
7936   [(set_attr "type" "test")
7937    (set_attr "modrm" "0,1,0,1,1")
7938    (set_attr "mode" "SI,SI,DI,DI,DI")
7939    (set_attr "pent_pair" "uv,np,uv,np,uv")])
7940
7941 (define_insn "testsi_1"
7942   [(set (reg 17)
7943         (compare
7944           (and:SI (match_operand:SI 0 "nonimmediate_operand" "%*a,r,rm")
7945                   (match_operand:SI 1 "nonmemory_operand" "in,in,rin"))
7946           (const_int 0)))]
7947   "ix86_match_ccmode (insn, CCNOmode)"
7948   "test{l}\t{%1, %0|%0, %1}"
7949   [(set_attr "type" "test")
7950    (set_attr "modrm" "0,1,1")
7951    (set_attr "mode" "SI")
7952    (set_attr "pent_pair" "uv,np,uv")])
7953
7954 (define_expand "testsi_ccno_1"
7955   [(set (reg:CCNO 17)
7956         (compare:CCNO
7957           (and:SI (match_operand:SI 0 "nonimmediate_operand" "")
7958                   (match_operand:SI 1 "nonmemory_operand" ""))
7959           (const_int 0)))]
7960   ""
7961   "")
7962
7963 (define_insn "*testhi_1"
7964   [(set (reg 17)
7965         (compare (and:HI (match_operand:HI 0 "nonimmediate_operand" "%*a,r,rm")
7966                          (match_operand:HI 1 "nonmemory_operand" "n,n,rn"))
7967                  (const_int 0)))]
7968   "ix86_match_ccmode (insn, CCNOmode)"
7969   "test{w}\t{%1, %0|%0, %1}"
7970   [(set_attr "type" "test")
7971    (set_attr "modrm" "0,1,1")
7972    (set_attr "mode" "HI")
7973    (set_attr "pent_pair" "uv,np,uv")])
7974
7975 (define_expand "testqi_ccz_1"
7976   [(set (reg:CCZ 17)
7977         (compare:CCZ (and:QI (match_operand:QI 0 "nonimmediate_operand" "")
7978                              (match_operand:QI 1 "nonmemory_operand" ""))
7979                  (const_int 0)))]
7980   ""
7981   "")
7982
7983 (define_insn "*testqi_1"
7984   [(set (reg 17)
7985         (compare (and:QI (match_operand:QI 0 "nonimmediate_operand" "%*a,q,qm,r")
7986                          (match_operand:QI 1 "nonmemory_operand" "n,n,qn,n"))
7987                  (const_int 0)))]
7988   "ix86_match_ccmode (insn, CCNOmode)"
7989 {
7990   if (which_alternative == 3)
7991     {
7992       if (GET_CODE (operands[1]) == CONST_INT
7993           && (INTVAL (operands[1]) & 0xffffff00))
7994         operands[1] = GEN_INT (INTVAL (operands[1]) & 0xff);
7995       return "test{l}\t{%1, %k0|%k0, %1}";
7996     }
7997   return "test{b}\t{%1, %0|%0, %1}";
7998 }
7999   [(set_attr "type" "test")
8000    (set_attr "modrm" "0,1,1,1")
8001    (set_attr "mode" "QI,QI,QI,SI")
8002    (set_attr "pent_pair" "uv,np,uv,np")])
8003
8004 (define_expand "testqi_ext_ccno_0"
8005   [(set (reg:CCNO 17)
8006         (compare:CCNO
8007           (and:SI
8008             (zero_extract:SI
8009               (match_operand 0 "ext_register_operand" "")
8010               (const_int 8)
8011               (const_int 8))
8012             (match_operand 1 "const_int_operand" ""))
8013           (const_int 0)))]
8014   ""
8015   "")
8016
8017 (define_insn "*testqi_ext_0"
8018   [(set (reg 17)
8019         (compare
8020           (and:SI
8021             (zero_extract:SI
8022               (match_operand 0 "ext_register_operand" "Q")
8023               (const_int 8)
8024               (const_int 8))
8025             (match_operand 1 "const_int_operand" "n"))
8026           (const_int 0)))]
8027   "(unsigned HOST_WIDE_INT) INTVAL (operands[1]) <= 0xff
8028    && ix86_match_ccmode (insn, CCNOmode)"
8029   "test{b}\t{%1, %h0|%h0, %1}"
8030   [(set_attr "type" "test")
8031    (set_attr "mode" "QI")
8032    (set_attr "length_immediate" "1")
8033    (set_attr "pent_pair" "np")])
8034
8035 (define_insn "*testqi_ext_1"
8036   [(set (reg 17)
8037         (compare
8038           (and:SI
8039             (zero_extract:SI
8040               (match_operand 0 "ext_register_operand" "Q")
8041               (const_int 8)
8042               (const_int 8))
8043             (zero_extend:SI
8044               (match_operand:QI 1 "nonimmediate_operand" "Qm")))
8045           (const_int 0)))]
8046   "!TARGET_64BIT && ix86_match_ccmode (insn, CCNOmode)"
8047   "test{b}\t{%1, %h0|%h0, %1}"
8048   [(set_attr "type" "test")
8049    (set_attr "mode" "QI")])
8050
8051 (define_insn "*testqi_ext_1_rex64"
8052   [(set (reg 17)
8053         (compare
8054           (and:SI
8055             (zero_extract:SI
8056               (match_operand 0 "ext_register_operand" "Q")
8057               (const_int 8)
8058               (const_int 8))
8059             (zero_extend:SI
8060               (match_operand:QI 1 "register_operand" "Q")))
8061           (const_int 0)))]
8062   "TARGET_64BIT && ix86_match_ccmode (insn, CCNOmode)"
8063   "test{b}\t{%1, %h0|%h0, %1}"
8064   [(set_attr "type" "test")
8065    (set_attr "mode" "QI")])
8066
8067 (define_insn "*testqi_ext_2"
8068   [(set (reg 17)
8069         (compare
8070           (and:SI
8071             (zero_extract:SI
8072               (match_operand 0 "ext_register_operand" "Q")
8073               (const_int 8)
8074               (const_int 8))
8075             (zero_extract:SI
8076               (match_operand 1 "ext_register_operand" "Q")
8077               (const_int 8)
8078               (const_int 8)))
8079           (const_int 0)))]
8080   "ix86_match_ccmode (insn, CCNOmode)"
8081   "test{b}\t{%h1, %h0|%h0, %h1}"
8082   [(set_attr "type" "test")
8083    (set_attr "mode" "QI")])
8084
8085 ;; Combine likes to form bit extractions for some tests.  Humor it.
8086 (define_insn "*testqi_ext_3"
8087   [(set (reg 17)
8088         (compare (zero_extract:SI
8089                    (match_operand 0 "nonimmediate_operand" "rm")
8090                    (match_operand:SI 1 "const_int_operand" "")
8091                    (match_operand:SI 2 "const_int_operand" ""))
8092                  (const_int 0)))]
8093   "ix86_match_ccmode (insn, CCNOmode)
8094    && (GET_MODE (operands[0]) == SImode
8095        || (TARGET_64BIT && GET_MODE (operands[0]) == DImode)
8096        || GET_MODE (operands[0]) == HImode
8097        || GET_MODE (operands[0]) == QImode)"
8098   "#")
8099
8100 (define_insn "*testqi_ext_3_rex64"
8101   [(set (reg 17)
8102         (compare (zero_extract:DI
8103                    (match_operand 0 "nonimmediate_operand" "rm")
8104                    (match_operand:DI 1 "const_int_operand" "")
8105                    (match_operand:DI 2 "const_int_operand" ""))
8106                  (const_int 0)))]
8107   "TARGET_64BIT
8108    && ix86_match_ccmode (insn, CCNOmode)
8109    /* The code below cannot deal with constants outside HOST_WIDE_INT.  */
8110    && INTVAL (operands[1]) + INTVAL (operands[2]) < HOST_BITS_PER_WIDE_INT
8111    /* Ensure that resulting mask is zero or sign extended operand.  */
8112    && (INTVAL (operands[1]) + INTVAL (operands[2]) <= 32
8113        || (INTVAL (operands[1]) + INTVAL (operands[2]) == 64
8114            && INTVAL (operands[1]) > 32))
8115    && (GET_MODE (operands[0]) == SImode
8116        || GET_MODE (operands[0]) == DImode
8117        || GET_MODE (operands[0]) == HImode
8118        || GET_MODE (operands[0]) == QImode)"
8119   "#")
8120
8121 (define_split
8122   [(set (reg 17)
8123         (compare (zero_extract
8124                    (match_operand 0 "nonimmediate_operand" "")
8125                    (match_operand 1 "const_int_operand" "")
8126                    (match_operand 2 "const_int_operand" ""))
8127                  (const_int 0)))]
8128   "ix86_match_ccmode (insn, CCNOmode)"
8129   [(set (reg:CCNO 17) (compare:CCNO (match_dup 3) (const_int 0)))]
8130 {
8131   HOST_WIDE_INT len = INTVAL (operands[1]);
8132   HOST_WIDE_INT pos = INTVAL (operands[2]);
8133   HOST_WIDE_INT mask;
8134   enum machine_mode mode, submode;
8135
8136   mode = GET_MODE (operands[0]);
8137   if (GET_CODE (operands[0]) == MEM)
8138     {
8139       /* ??? Combine likes to put non-volatile mem extractions in QImode
8140          no matter the size of the test.  So find a mode that works.  */
8141       if (! MEM_VOLATILE_P (operands[0]))
8142         {
8143           mode = smallest_mode_for_size (pos + len, MODE_INT);
8144           operands[0] = adjust_address (operands[0], mode, 0);
8145         }
8146     }
8147   else if (GET_CODE (operands[0]) == SUBREG
8148            && (submode = GET_MODE (SUBREG_REG (operands[0])),
8149                GET_MODE_BITSIZE (mode) > GET_MODE_BITSIZE (submode))
8150            && pos + len <= GET_MODE_BITSIZE (submode))
8151     {
8152       /* Narrow a paradoxical subreg to prevent partial register stalls.  */
8153       mode = submode;
8154       operands[0] = SUBREG_REG (operands[0]);
8155     }
8156   else if (mode == HImode && pos + len <= 8)
8157     {
8158       /* Small HImode tests can be converted to QImode.  */
8159       mode = QImode;
8160       operands[0] = gen_lowpart (QImode, operands[0]);
8161     }
8162
8163   mask  = ((HOST_WIDE_INT)1 << (pos + len)) - 1;
8164   mask &= ~(((HOST_WIDE_INT)1 << pos) - 1);
8165
8166   operands[3] = gen_rtx_AND (mode, operands[0],
8167                              GEN_INT (trunc_int_for_mode (mask, mode)));
8168 })
8169
8170 ;; %%% This used to optimize known byte-wide and operations to memory,
8171 ;; and sometimes to QImode registers.  If this is considered useful,
8172 ;; it should be done with splitters.
8173
8174 (define_expand "anddi3"
8175   [(set (match_operand:DI 0 "nonimmediate_operand" "")
8176         (and:DI (match_operand:DI 1 "nonimmediate_operand" "")
8177                 (match_operand:DI 2 "x86_64_szext_general_operand" "")))
8178    (clobber (reg:CC 17))]
8179   "TARGET_64BIT"
8180   "ix86_expand_binary_operator (AND, DImode, operands); DONE;")
8181
8182 (define_insn "*anddi_1_rex64"
8183   [(set (match_operand:DI 0 "nonimmediate_operand" "=r,rm,r,r")
8184         (and:DI (match_operand:DI 1 "nonimmediate_operand" "%0,0,0,qm")
8185                 (match_operand:DI 2 "x86_64_szext_general_operand" "Z,re,rm,L")))
8186    (clobber (reg:CC 17))]
8187   "TARGET_64BIT && ix86_binary_operator_ok (AND, DImode, operands)"
8188 {
8189   switch (get_attr_type (insn))
8190     {
8191     case TYPE_IMOVX:
8192       {
8193         enum machine_mode mode;
8194
8195         if (GET_CODE (operands[2]) != CONST_INT)
8196           abort ();
8197         if (INTVAL (operands[2]) == 0xff)
8198           mode = QImode;
8199         else if (INTVAL (operands[2]) == 0xffff)
8200           mode = HImode;
8201         else
8202           abort ();
8203         
8204         operands[1] = gen_lowpart (mode, operands[1]);
8205         if (mode == QImode)
8206           return "movz{bq|x}\t{%1,%0|%0, %1}";
8207         else
8208           return "movz{wq|x}\t{%1,%0|%0, %1}";
8209       }
8210
8211     default:
8212       if (! rtx_equal_p (operands[0], operands[1]))
8213         abort ();
8214       if (get_attr_mode (insn) == MODE_SI)
8215         return "and{l}\t{%k2, %k0|%k0, %k2}";
8216       else
8217         return "and{q}\t{%2, %0|%0, %2}";
8218     }
8219 }
8220   [(set_attr "type" "alu,alu,alu,imovx")
8221    (set_attr "length_immediate" "*,*,*,0")
8222    (set_attr "mode" "SI,DI,DI,DI")])
8223
8224 (define_insn "*anddi_2"
8225   [(set (reg 17)
8226         (compare (and:DI (match_operand:DI 1 "nonimmediate_operand" "%0,0,0")
8227                          (match_operand:DI 2 "x86_64_szext_general_operand" "Z,rem,re"))
8228                  (const_int 0)))
8229    (set (match_operand:DI 0 "nonimmediate_operand" "=r,r,rm")
8230         (and:DI (match_dup 1) (match_dup 2)))]
8231   "TARGET_64BIT && ix86_match_ccmode (insn, CCNOmode)
8232    && ix86_binary_operator_ok (AND, DImode, operands)"
8233   "@
8234    and{l}\t{%k2, %k0|%k0, %k2} 
8235    and{q}\t{%2, %0|%0, %2} 
8236    and{q}\t{%2, %0|%0, %2}"
8237   [(set_attr "type" "alu")
8238    (set_attr "mode" "SI,DI,DI")])
8239
8240 (define_expand "andsi3"
8241   [(set (match_operand:SI 0 "nonimmediate_operand" "")
8242         (and:SI (match_operand:SI 1 "nonimmediate_operand" "")
8243                 (match_operand:SI 2 "general_operand" "")))
8244    (clobber (reg:CC 17))]
8245   ""
8246   "ix86_expand_binary_operator (AND, SImode, operands); DONE;")
8247
8248 (define_insn "*andsi_1"
8249   [(set (match_operand:SI 0 "nonimmediate_operand" "=rm,r,r")
8250         (and:SI (match_operand:SI 1 "nonimmediate_operand" "%0,0,qm")
8251                 (match_operand:SI 2 "general_operand" "ri,rm,L")))
8252    (clobber (reg:CC 17))]
8253   "ix86_binary_operator_ok (AND, SImode, operands)"
8254 {
8255   switch (get_attr_type (insn))
8256     {
8257     case TYPE_IMOVX:
8258       {
8259         enum machine_mode mode;
8260
8261         if (GET_CODE (operands[2]) != CONST_INT)
8262           abort ();
8263         if (INTVAL (operands[2]) == 0xff)
8264           mode = QImode;
8265         else if (INTVAL (operands[2]) == 0xffff)
8266           mode = HImode;
8267         else
8268           abort ();
8269         
8270         operands[1] = gen_lowpart (mode, operands[1]);
8271         if (mode == QImode)
8272           return "movz{bl|x}\t{%1,%0|%0, %1}";
8273         else
8274           return "movz{wl|x}\t{%1,%0|%0, %1}";
8275       }
8276
8277     default:
8278       if (! rtx_equal_p (operands[0], operands[1]))
8279         abort ();
8280       return "and{l}\t{%2, %0|%0, %2}";
8281     }
8282 }
8283   [(set_attr "type" "alu,alu,imovx")
8284    (set_attr "length_immediate" "*,*,0")
8285    (set_attr "mode" "SI")])
8286
8287 (define_split
8288   [(set (match_operand 0 "register_operand" "")
8289         (and (match_dup 0)
8290              (const_int -65536)))
8291    (clobber (reg:CC 17))]
8292   "optimize_size"
8293   [(set (strict_low_part (match_dup 1)) (const_int 0))]
8294   "operands[1] = gen_lowpart (HImode, operands[0]);")
8295
8296 (define_split
8297   [(set (match_operand 0 "ext_register_operand" "")
8298         (and (match_dup 0)
8299              (const_int -256)))
8300    (clobber (reg:CC 17))]
8301   "(optimize_size || !TARGET_PARTIAL_REG_STALL) && reload_completed"
8302   [(set (strict_low_part (match_dup 1)) (const_int 0))]
8303   "operands[1] = gen_lowpart (QImode, operands[0]);")
8304
8305 (define_split
8306   [(set (match_operand 0 "ext_register_operand" "")
8307         (and (match_dup 0)
8308              (const_int -65281)))
8309    (clobber (reg:CC 17))]
8310   "(optimize_size || !TARGET_PARTIAL_REG_STALL) && reload_completed"
8311   [(parallel [(set (zero_extract:SI (match_dup 0)
8312                                     (const_int 8)
8313                                     (const_int 8))
8314                    (xor:SI 
8315                      (zero_extract:SI (match_dup 0)
8316                                       (const_int 8)
8317                                       (const_int 8))
8318                      (zero_extract:SI (match_dup 0)
8319                                       (const_int 8)
8320                                       (const_int 8))))
8321               (clobber (reg:CC 17))])]
8322   "operands[0] = gen_lowpart (SImode, operands[0]);")
8323
8324 ;; See comment for addsi_1_zext why we do use nonimmediate_operand
8325 (define_insn "*andsi_1_zext"
8326   [(set (match_operand:DI 0 "register_operand" "=r")
8327         (zero_extend:DI
8328           (and:SI (match_operand:SI 1 "nonimmediate_operand" "%0")
8329                   (match_operand:SI 2 "general_operand" "rim"))))
8330    (clobber (reg:CC 17))]
8331   "TARGET_64BIT && ix86_binary_operator_ok (AND, SImode, operands)"
8332   "and{l}\t{%2, %k0|%k0, %2}"
8333   [(set_attr "type" "alu")
8334    (set_attr "mode" "SI")])
8335
8336 (define_insn "*andsi_2"
8337   [(set (reg 17)
8338         (compare (and:SI (match_operand:SI 1 "nonimmediate_operand" "%0,0")
8339                          (match_operand:SI 2 "general_operand" "rim,ri"))
8340                  (const_int 0)))
8341    (set (match_operand:SI 0 "nonimmediate_operand" "=r,rm")
8342         (and:SI (match_dup 1) (match_dup 2)))]
8343   "ix86_match_ccmode (insn, CCNOmode)
8344    && ix86_binary_operator_ok (AND, SImode, operands)"
8345   "and{l}\t{%2, %0|%0, %2}"
8346   [(set_attr "type" "alu")
8347    (set_attr "mode" "SI")])
8348
8349 ;; See comment for addsi_1_zext why we do use nonimmediate_operand
8350 (define_insn "*andsi_2_zext"
8351   [(set (reg 17)
8352         (compare (and:SI (match_operand:SI 1 "nonimmediate_operand" "%0")
8353                          (match_operand:SI 2 "general_operand" "rim"))
8354                  (const_int 0)))
8355    (set (match_operand:DI 0 "register_operand" "=r")
8356         (zero_extend:DI (and:SI (match_dup 1) (match_dup 2))))]
8357   "TARGET_64BIT && ix86_match_ccmode (insn, CCNOmode)
8358    && ix86_binary_operator_ok (AND, SImode, operands)"
8359   "and{l}\t{%2, %k0|%k0, %2}"
8360   [(set_attr "type" "alu")
8361    (set_attr "mode" "SI")])
8362
8363 (define_expand "andhi3"
8364   [(set (match_operand:HI 0 "nonimmediate_operand" "")
8365         (and:HI (match_operand:HI 1 "nonimmediate_operand" "")
8366                 (match_operand:HI 2 "general_operand" "")))
8367    (clobber (reg:CC 17))]
8368   "TARGET_HIMODE_MATH"
8369   "ix86_expand_binary_operator (AND, HImode, operands); DONE;")
8370
8371 (define_insn "*andhi_1"
8372   [(set (match_operand:HI 0 "nonimmediate_operand" "=rm,r,r")
8373         (and:HI (match_operand:HI 1 "nonimmediate_operand" "%0,0,qm")
8374                 (match_operand:HI 2 "general_operand" "ri,rm,L")))
8375    (clobber (reg:CC 17))]
8376   "ix86_binary_operator_ok (AND, HImode, operands)"
8377 {
8378   switch (get_attr_type (insn))
8379     {
8380     case TYPE_IMOVX:
8381       if (GET_CODE (operands[2]) != CONST_INT)
8382         abort ();
8383       if (INTVAL (operands[2]) == 0xff)
8384         return "movz{bl|x}\t{%b1, %k0|%k0, %b1}";
8385       abort ();
8386
8387     default:
8388       if (! rtx_equal_p (operands[0], operands[1]))
8389         abort ();
8390
8391       return "and{w}\t{%2, %0|%0, %2}";
8392     }
8393 }
8394   [(set_attr "type" "alu,alu,imovx")
8395    (set_attr "length_immediate" "*,*,0")
8396    (set_attr "mode" "HI,HI,SI")])
8397
8398 (define_insn "*andhi_2"
8399   [(set (reg 17)
8400         (compare (and:HI (match_operand:HI 1 "nonimmediate_operand" "%0,0")
8401                          (match_operand:HI 2 "general_operand" "rim,ri"))
8402                  (const_int 0)))
8403    (set (match_operand:HI 0 "nonimmediate_operand" "=r,rm")
8404         (and:HI (match_dup 1) (match_dup 2)))]
8405   "ix86_match_ccmode (insn, CCNOmode)
8406    && ix86_binary_operator_ok (AND, HImode, operands)"
8407   "and{w}\t{%2, %0|%0, %2}"
8408   [(set_attr "type" "alu")
8409    (set_attr "mode" "HI")])
8410
8411 (define_expand "andqi3"
8412   [(set (match_operand:QI 0 "nonimmediate_operand" "")
8413         (and:QI (match_operand:QI 1 "nonimmediate_operand" "")
8414                 (match_operand:QI 2 "general_operand" "")))
8415    (clobber (reg:CC 17))]
8416   "TARGET_QIMODE_MATH"
8417   "ix86_expand_binary_operator (AND, QImode, operands); DONE;")
8418
8419 ;; %%% Potential partial reg stall on alternative 2.  What to do?
8420 (define_insn "*andqi_1"
8421   [(set (match_operand:QI 0 "nonimmediate_operand" "=qm,q,r")
8422         (and:QI (match_operand:QI 1 "nonimmediate_operand" "%0,0,0")
8423                 (match_operand:QI 2 "general_operand" "qi,qmi,ri")))
8424    (clobber (reg:CC 17))]
8425   "ix86_binary_operator_ok (AND, QImode, operands)"
8426   "@
8427    and{b}\t{%2, %0|%0, %2}
8428    and{b}\t{%2, %0|%0, %2}
8429    and{l}\t{%k2, %k0|%k0, %k2}"
8430   [(set_attr "type" "alu")
8431    (set_attr "mode" "QI,QI,SI")])
8432
8433 (define_insn "*andqi_1_slp"
8434   [(set (strict_low_part (match_operand:QI 0 "nonimmediate_operand" "+qm,q"))
8435         (and:QI (match_dup 0)
8436                 (match_operand:QI 1 "general_operand" "qi,qmi")))
8437    (clobber (reg:CC 17))]
8438   ""
8439   "and{b}\t{%1, %0|%0, %1}"
8440   [(set_attr "type" "alu1")
8441    (set_attr "mode" "QI")])
8442
8443 (define_insn "*andqi_2"
8444   [(set (reg 17)
8445         (compare (and:QI
8446                    (match_operand:QI 1 "nonimmediate_operand" "%0,0,0")
8447                    (match_operand:QI 2 "general_operand" "qim,qi,i"))
8448                  (const_int 0)))
8449    (set (match_operand:QI 0 "nonimmediate_operand" "=q,qm,*r")
8450         (and:QI (match_dup 1) (match_dup 2)))]
8451   "ix86_match_ccmode (insn, CCNOmode)
8452    && ix86_binary_operator_ok (AND, QImode, operands)"
8453 {
8454   if (which_alternative == 2)
8455     {
8456       if (GET_CODE (operands[2]) == CONST_INT
8457           && (INTVAL (operands[2]) & 0xffffff00))
8458         operands[2] = GEN_INT (INTVAL (operands[2]) & 0xff);
8459       return "and{l}\t{%2, %k0|%k0, %2}";
8460     }
8461   return "and{b}\t{%2, %0|%0, %2}";
8462 }
8463   [(set_attr "type" "alu")
8464    (set_attr "mode" "QI,QI,SI")])
8465
8466 (define_insn "*andqi_2_slp"
8467   [(set (reg 17)
8468         (compare (and:QI
8469                    (match_operand:QI 0 "nonimmediate_operand" "+q,qm")
8470                    (match_operand:QI 1 "nonimmediate_operand" "qmi,qi"))
8471                  (const_int 0)))
8472    (set (strict_low_part (match_dup 0))
8473         (and:QI (match_dup 0) (match_dup 1)))]
8474   "ix86_match_ccmode (insn, CCNOmode)"
8475   "and{b}\t{%1, %0|%0, %1}"
8476   [(set_attr "type" "alu1")
8477    (set_attr "mode" "QI")])
8478
8479 ;; ??? A bug in recog prevents it from recognizing a const_int as an
8480 ;; operand to zero_extend in andqi_ext_1.  It was checking explicitly
8481 ;; for a QImode operand, which of course failed.
8482
8483 (define_insn "andqi_ext_0"
8484   [(set (zero_extract:SI (match_operand 0 "ext_register_operand" "=Q")
8485                          (const_int 8)
8486                          (const_int 8))
8487         (and:SI 
8488           (zero_extract:SI
8489             (match_operand 1 "ext_register_operand" "0")
8490             (const_int 8)
8491             (const_int 8))
8492           (match_operand 2 "const_int_operand" "n")))
8493    (clobber (reg:CC 17))]
8494   "(unsigned HOST_WIDE_INT)INTVAL (operands[2]) <= 0xff"
8495   "and{b}\t{%2, %h0|%h0, %2}"
8496   [(set_attr "type" "alu")
8497    (set_attr "length_immediate" "1")
8498    (set_attr "mode" "QI")])
8499
8500 ;; Generated by peephole translating test to and.  This shows up
8501 ;; often in fp comparisons.
8502
8503 (define_insn "*andqi_ext_0_cc"
8504   [(set (reg 17)
8505         (compare
8506           (and:SI
8507             (zero_extract:SI
8508               (match_operand 1 "ext_register_operand" "0")
8509               (const_int 8)
8510               (const_int 8))
8511             (match_operand 2 "const_int_operand" "n"))
8512           (const_int 0)))
8513    (set (zero_extract:SI (match_operand 0 "ext_register_operand" "=Q")
8514                          (const_int 8)
8515                          (const_int 8))
8516         (and:SI 
8517           (zero_extract:SI
8518             (match_dup 1)
8519             (const_int 8)
8520             (const_int 8))
8521           (match_dup 2)))]
8522   "ix86_match_ccmode (insn, CCNOmode)
8523    && (unsigned HOST_WIDE_INT)INTVAL (operands[2]) <= 0xff"
8524   "and{b}\t{%2, %h0|%h0, %2}"
8525   [(set_attr "type" "alu")
8526    (set_attr "length_immediate" "1")
8527    (set_attr "mode" "QI")])
8528
8529 (define_insn "*andqi_ext_1"
8530   [(set (zero_extract:SI (match_operand 0 "ext_register_operand" "=Q")
8531                          (const_int 8)
8532                          (const_int 8))
8533         (and:SI 
8534           (zero_extract:SI
8535             (match_operand 1 "ext_register_operand" "0")
8536             (const_int 8)
8537             (const_int 8))
8538           (zero_extend:SI
8539             (match_operand:QI 2 "general_operand" "Qm"))))
8540    (clobber (reg:CC 17))]
8541   "!TARGET_64BIT"
8542   "and{b}\t{%2, %h0|%h0, %2}"
8543   [(set_attr "type" "alu")
8544    (set_attr "length_immediate" "0")
8545    (set_attr "mode" "QI")])
8546
8547 (define_insn "*andqi_ext_1_rex64"
8548   [(set (zero_extract:SI (match_operand 0 "ext_register_operand" "=Q")
8549                          (const_int 8)
8550                          (const_int 8))
8551         (and:SI 
8552           (zero_extract:SI
8553             (match_operand 1 "ext_register_operand" "0")
8554             (const_int 8)
8555             (const_int 8))
8556           (zero_extend:SI
8557             (match_operand 2 "ext_register_operand" "Q"))))
8558    (clobber (reg:CC 17))]
8559   "TARGET_64BIT"
8560   "and{b}\t{%2, %h0|%h0, %2}"
8561   [(set_attr "type" "alu")
8562    (set_attr "length_immediate" "0")
8563    (set_attr "mode" "QI")])
8564
8565 (define_insn "*andqi_ext_2"
8566   [(set (zero_extract:SI (match_operand 0 "ext_register_operand" "=Q")
8567                          (const_int 8)
8568                          (const_int 8))
8569         (and:SI
8570           (zero_extract:SI
8571             (match_operand 1 "ext_register_operand" "%0")
8572             (const_int 8)
8573             (const_int 8))
8574           (zero_extract:SI
8575             (match_operand 2 "ext_register_operand" "Q")
8576             (const_int 8)
8577             (const_int 8))))
8578    (clobber (reg:CC 17))]
8579   ""
8580   "and{b}\t{%h2, %h0|%h0, %h2}"
8581   [(set_attr "type" "alu")
8582    (set_attr "length_immediate" "0")
8583    (set_attr "mode" "QI")])
8584 \f
8585 ;; Logical inclusive OR instructions
8586
8587 ;; %%% This used to optimize known byte-wide and operations to memory.
8588 ;; If this is considered useful, it should be done with splitters.
8589
8590 (define_expand "iordi3"
8591   [(set (match_operand:DI 0 "nonimmediate_operand" "")
8592         (ior:DI (match_operand:DI 1 "nonimmediate_operand" "")
8593                 (match_operand:DI 2 "x86_64_general_operand" "")))
8594    (clobber (reg:CC 17))]
8595   "TARGET_64BIT"
8596   "ix86_expand_binary_operator (IOR, DImode, operands); DONE;")
8597
8598 (define_insn "*iordi_1_rex64"
8599   [(set (match_operand:DI 0 "nonimmediate_operand" "=rm,r")
8600         (ior:DI (match_operand:DI 1 "nonimmediate_operand" "%0,0")
8601                 (match_operand:DI 2 "x86_64_general_operand" "re,rme")))
8602    (clobber (reg:CC 17))]
8603   "TARGET_64BIT
8604    && ix86_binary_operator_ok (IOR, DImode, operands)"
8605   "or{q}\t{%2, %0|%0, %2}"
8606   [(set_attr "type" "alu")
8607    (set_attr "mode" "DI")])
8608
8609 (define_insn "*iordi_2_rex64"
8610   [(set (reg 17)
8611         (compare (ior:DI (match_operand:DI 1 "nonimmediate_operand" "%0,0")
8612                          (match_operand:DI 2 "x86_64_general_operand" "rem,re"))
8613                  (const_int 0)))
8614    (set (match_operand:DI 0 "nonimmediate_operand" "=r,rm")
8615         (ior:DI (match_dup 1) (match_dup 2)))]
8616   "TARGET_64BIT
8617    && ix86_match_ccmode (insn, CCNOmode)
8618    && ix86_binary_operator_ok (IOR, DImode, operands)"
8619   "or{q}\t{%2, %0|%0, %2}"
8620   [(set_attr "type" "alu")
8621    (set_attr "mode" "DI")])
8622
8623 (define_insn "*iordi_3_rex64"
8624   [(set (reg 17)
8625         (compare (ior:DI (match_operand:DI 1 "nonimmediate_operand" "%0")
8626                          (match_operand:DI 2 "x86_64_general_operand" "rem"))
8627                  (const_int 0)))
8628    (clobber (match_scratch:DI 0 "=r"))]
8629   "TARGET_64BIT
8630    && ix86_match_ccmode (insn, CCNOmode)
8631    && ix86_binary_operator_ok (IOR, DImode, operands)"
8632   "or{q}\t{%2, %0|%0, %2}"
8633   [(set_attr "type" "alu")
8634    (set_attr "mode" "DI")])
8635
8636
8637 (define_expand "iorsi3"
8638   [(set (match_operand:SI 0 "nonimmediate_operand" "")
8639         (ior:SI (match_operand:SI 1 "nonimmediate_operand" "")
8640                 (match_operand:SI 2 "general_operand" "")))
8641    (clobber (reg:CC 17))]
8642   ""
8643   "ix86_expand_binary_operator (IOR, SImode, operands); DONE;")
8644
8645 (define_insn "*iorsi_1"
8646   [(set (match_operand:SI 0 "nonimmediate_operand" "=rm,r")
8647         (ior:SI (match_operand:SI 1 "nonimmediate_operand" "%0,0")
8648                 (match_operand:SI 2 "general_operand" "ri,rmi")))
8649    (clobber (reg:CC 17))]
8650   "ix86_binary_operator_ok (IOR, SImode, operands)"
8651   "or{l}\t{%2, %0|%0, %2}"
8652   [(set_attr "type" "alu")
8653    (set_attr "mode" "SI")])
8654
8655 ;; See comment for addsi_1_zext why we do use nonimmediate_operand
8656 (define_insn "*iorsi_1_zext"
8657   [(set (match_operand:DI 0 "register_operand" "=rm")
8658         (zero_extend:DI
8659           (ior:SI (match_operand:SI 1 "nonimmediate_operand" "%0")
8660                   (match_operand:SI 2 "general_operand" "rim"))))
8661    (clobber (reg:CC 17))]
8662   "TARGET_64BIT && ix86_binary_operator_ok (IOR, SImode, operands)"
8663   "or{l}\t{%2, %k0|%k0, %2}"
8664   [(set_attr "type" "alu")
8665    (set_attr "mode" "SI")])
8666
8667 (define_insn "*iorsi_1_zext_imm"
8668   [(set (match_operand:DI 0 "register_operand" "=rm")
8669         (ior:DI (zero_extend:DI (match_operand:SI 1 "register_operand" "%0"))
8670                 (match_operand:DI 2 "x86_64_zext_immediate_operand" "Z")))
8671    (clobber (reg:CC 17))]
8672   "TARGET_64BIT"
8673   "or{l}\t{%2, %k0|%k0, %2}"
8674   [(set_attr "type" "alu")
8675    (set_attr "mode" "SI")])
8676
8677 (define_insn "*iorsi_2"
8678   [(set (reg 17)
8679         (compare (ior:SI (match_operand:SI 1 "nonimmediate_operand" "%0,0")
8680                          (match_operand:SI 2 "general_operand" "rim,ri"))
8681                  (const_int 0)))
8682    (set (match_operand:SI 0 "nonimmediate_operand" "=r,rm")
8683         (ior:SI (match_dup 1) (match_dup 2)))]
8684   "ix86_match_ccmode (insn, CCNOmode)
8685    && ix86_binary_operator_ok (IOR, SImode, operands)"
8686   "or{l}\t{%2, %0|%0, %2}"
8687   [(set_attr "type" "alu")
8688    (set_attr "mode" "SI")])
8689
8690 ;; See comment for addsi_1_zext why we do use nonimmediate_operand
8691 ;; ??? Special case for immediate operand is missing - it is tricky.
8692 (define_insn "*iorsi_2_zext"
8693   [(set (reg 17)
8694         (compare (ior:SI (match_operand:SI 1 "nonimmediate_operand" "%0")
8695                          (match_operand:SI 2 "general_operand" "rim"))
8696                  (const_int 0)))
8697    (set (match_operand:DI 0 "register_operand" "=r")
8698         (zero_extend:DI (ior:SI (match_dup 1) (match_dup 2))))]
8699   "TARGET_64BIT && ix86_match_ccmode (insn, CCNOmode)
8700    && ix86_binary_operator_ok (IOR, SImode, operands)"
8701   "or{l}\t{%2, %k0|%k0, %2}"
8702   [(set_attr "type" "alu")
8703    (set_attr "mode" "SI")])
8704
8705 (define_insn "*iorsi_2_zext_imm"
8706   [(set (reg 17)
8707         (compare (ior:SI (match_operand:SI 1 "nonimmediate_operand" "%0")
8708                          (match_operand 2 "x86_64_zext_immediate_operand" "Z"))
8709                  (const_int 0)))
8710    (set (match_operand:DI 0 "register_operand" "=r")
8711         (ior:DI (zero_extend:DI (match_dup 1)) (match_dup 2)))]
8712   "TARGET_64BIT && ix86_match_ccmode (insn, CCNOmode)
8713    && ix86_binary_operator_ok (IOR, SImode, operands)"
8714   "or{l}\t{%2, %k0|%k0, %2}"
8715   [(set_attr "type" "alu")
8716    (set_attr "mode" "SI")])
8717
8718 (define_insn "*iorsi_3"
8719   [(set (reg 17)
8720         (compare (ior:SI (match_operand:SI 1 "nonimmediate_operand" "%0")
8721                          (match_operand:SI 2 "general_operand" "rim"))
8722                  (const_int 0)))
8723    (clobber (match_scratch:SI 0 "=r"))]
8724   "ix86_match_ccmode (insn, CCNOmode)
8725    && (GET_CODE (operands[1]) != MEM || GET_CODE (operands[2]) != MEM)"
8726   "or{l}\t{%2, %0|%0, %2}"
8727   [(set_attr "type" "alu")
8728    (set_attr "mode" "SI")])
8729
8730 (define_expand "iorhi3"
8731   [(set (match_operand:HI 0 "nonimmediate_operand" "")
8732         (ior:HI (match_operand:HI 1 "nonimmediate_operand" "")
8733                 (match_operand:HI 2 "general_operand" "")))
8734    (clobber (reg:CC 17))]
8735   "TARGET_HIMODE_MATH"
8736   "ix86_expand_binary_operator (IOR, HImode, operands); DONE;")
8737
8738 (define_insn "*iorhi_1"
8739   [(set (match_operand:HI 0 "nonimmediate_operand" "=r,m")
8740         (ior:HI (match_operand:HI 1 "nonimmediate_operand" "%0,0")
8741                 (match_operand:HI 2 "general_operand" "rmi,ri")))
8742    (clobber (reg:CC 17))]
8743   "ix86_binary_operator_ok (IOR, HImode, operands)"
8744   "or{w}\t{%2, %0|%0, %2}"
8745   [(set_attr "type" "alu")
8746    (set_attr "mode" "HI")])
8747
8748 (define_insn "*iorhi_2"
8749   [(set (reg 17)
8750         (compare (ior:HI (match_operand:HI 1 "nonimmediate_operand" "%0,0")
8751                          (match_operand:HI 2 "general_operand" "rim,ri"))
8752                  (const_int 0)))
8753    (set (match_operand:HI 0 "nonimmediate_operand" "=r,rm")
8754         (ior:HI (match_dup 1) (match_dup 2)))]
8755   "ix86_match_ccmode (insn, CCNOmode)
8756    && ix86_binary_operator_ok (IOR, HImode, operands)"
8757   "or{w}\t{%2, %0|%0, %2}"
8758   [(set_attr "type" "alu")
8759    (set_attr "mode" "HI")])
8760
8761 (define_insn "*iorhi_3"
8762   [(set (reg 17)
8763         (compare (ior:HI (match_operand:HI 1 "nonimmediate_operand" "%0")
8764                          (match_operand:HI 2 "general_operand" "rim"))
8765                  (const_int 0)))
8766    (clobber (match_scratch:HI 0 "=r"))]
8767   "ix86_match_ccmode (insn, CCNOmode)
8768    && (GET_CODE (operands[1]) != MEM || GET_CODE (operands[2]) != MEM)"
8769   "or{w}\t{%2, %0|%0, %2}"
8770   [(set_attr "type" "alu")
8771    (set_attr "mode" "HI")])
8772
8773 (define_expand "iorqi3"
8774   [(set (match_operand:QI 0 "nonimmediate_operand" "")
8775         (ior:QI (match_operand:QI 1 "nonimmediate_operand" "")
8776                 (match_operand:QI 2 "general_operand" "")))
8777    (clobber (reg:CC 17))]
8778   "TARGET_QIMODE_MATH"
8779   "ix86_expand_binary_operator (IOR, QImode, operands); DONE;")
8780
8781 ;; %%% Potential partial reg stall on alternative 2.  What to do?
8782 (define_insn "*iorqi_1"
8783   [(set (match_operand:QI 0 "nonimmediate_operand" "=q,m,r")
8784         (ior:QI (match_operand:QI 1 "nonimmediate_operand" "%0,0,0")
8785                 (match_operand:QI 2 "general_operand" "qmi,qi,ri")))
8786    (clobber (reg:CC 17))]
8787   "ix86_binary_operator_ok (IOR, QImode, operands)"
8788   "@
8789    or{b}\t{%2, %0|%0, %2}
8790    or{b}\t{%2, %0|%0, %2}
8791    or{l}\t{%k2, %k0|%k0, %k2}"
8792   [(set_attr "type" "alu")
8793    (set_attr "mode" "QI,QI,SI")])
8794
8795 (define_insn "*iorqi_1_slp"
8796   [(set (strict_low_part (match_operand:QI 0 "nonimmediate_operand" "+q,m"))
8797         (ior:QI (match_dup 0)
8798                 (match_operand:QI 1 "general_operand" "qmi,qi")))
8799    (clobber (reg:CC 17))]
8800   ""
8801   "or{b}\t{%1, %0|%0, %1}"
8802   [(set_attr "type" "alu1")
8803    (set_attr "mode" "QI")])
8804
8805 (define_insn "*iorqi_2"
8806   [(set (reg 17)
8807         (compare (ior:QI (match_operand:QI 1 "nonimmediate_operand" "%0,0")
8808                          (match_operand:QI 2 "general_operand" "qim,qi"))
8809                  (const_int 0)))
8810    (set (match_operand:QI 0 "nonimmediate_operand" "=q,qm")
8811         (ior:QI (match_dup 1) (match_dup 2)))]
8812   "ix86_match_ccmode (insn, CCNOmode)
8813    && ix86_binary_operator_ok (IOR, QImode, operands)"
8814   "or{b}\t{%2, %0|%0, %2}"
8815   [(set_attr "type" "alu")
8816    (set_attr "mode" "QI")])
8817
8818 (define_insn "*iorqi_2_slp"
8819   [(set (reg 17)
8820         (compare (ior:QI (match_operand:QI 0 "nonimmediate_operand" "+q,qm")
8821                          (match_operand:QI 1 "general_operand" "qim,qi"))
8822                  (const_int 0)))
8823    (set (strict_low_part (match_dup 0))
8824         (ior:QI (match_dup 0) (match_dup 1)))]
8825   "ix86_match_ccmode (insn, CCNOmode)"
8826   "or{b}\t{%1, %0|%0, %1}"
8827   [(set_attr "type" "alu1")
8828    (set_attr "mode" "QI")])
8829
8830 (define_insn "*iorqi_3"
8831   [(set (reg 17)
8832         (compare (ior:QI (match_operand:QI 1 "nonimmediate_operand" "%0")
8833                          (match_operand:QI 2 "general_operand" "qim"))
8834                  (const_int 0)))
8835    (clobber (match_scratch:QI 0 "=q"))]
8836   "ix86_match_ccmode (insn, CCNOmode)
8837    && (GET_CODE (operands[1]) != MEM || GET_CODE (operands[2]) != MEM)"
8838   "or{b}\t{%2, %0|%0, %2}"
8839   [(set_attr "type" "alu")
8840    (set_attr "mode" "QI")])
8841
8842 \f
8843 ;; Logical XOR instructions
8844
8845 ;; %%% This used to optimize known byte-wide and operations to memory.
8846 ;; If this is considered useful, it should be done with splitters.
8847
8848 (define_expand "xordi3"
8849   [(set (match_operand:DI 0 "nonimmediate_operand" "")
8850         (xor:DI (match_operand:DI 1 "nonimmediate_operand" "")
8851                 (match_operand:DI 2 "x86_64_general_operand" "")))
8852    (clobber (reg:CC 17))]
8853   "TARGET_64BIT"
8854   "ix86_expand_binary_operator (XOR, DImode, operands); DONE;")
8855
8856 (define_insn "*xordi_1_rex64"
8857   [(set (match_operand:DI 0 "nonimmediate_operand" "=rm,r")
8858         (xor:DI (match_operand:DI 1 "nonimmediate_operand" "%0,0")
8859                 (match_operand:DI 2 "x86_64_general_operand" "re,rm")))
8860    (clobber (reg:CC 17))]
8861   "TARGET_64BIT
8862    && ix86_binary_operator_ok (XOR, DImode, operands)"
8863   "@
8864    xor{q}\t{%2, %0|%0, %2} 
8865    xor{q}\t{%2, %0|%0, %2}"
8866   [(set_attr "type" "alu")
8867    (set_attr "mode" "DI,DI")])
8868
8869 (define_insn "*xordi_2_rex64"
8870   [(set (reg 17)
8871         (compare (xor:DI (match_operand:DI 1 "nonimmediate_operand" "%0,0")
8872                          (match_operand:DI 2 "x86_64_general_operand" "rem,re"))
8873                  (const_int 0)))
8874    (set (match_operand:DI 0 "nonimmediate_operand" "=r,rm")
8875         (xor:DI (match_dup 1) (match_dup 2)))]
8876   "TARGET_64BIT
8877    && ix86_match_ccmode (insn, CCNOmode)
8878    && ix86_binary_operator_ok (XOR, DImode, operands)"
8879   "@
8880    xor{q}\t{%2, %0|%0, %2} 
8881    xor{q}\t{%2, %0|%0, %2}"
8882   [(set_attr "type" "alu")
8883    (set_attr "mode" "DI,DI")])
8884
8885 (define_insn "*xordi_3_rex64"
8886   [(set (reg 17)
8887         (compare (xor:DI (match_operand:DI 1 "nonimmediate_operand" "%0")
8888                          (match_operand:DI 2 "x86_64_general_operand" "rem"))
8889                  (const_int 0)))
8890    (clobber (match_scratch:DI 0 "=r"))]
8891   "TARGET_64BIT
8892    && ix86_match_ccmode (insn, CCNOmode)
8893    && ix86_binary_operator_ok (XOR, DImode, operands)"
8894   "xor{q}\t{%2, %0|%0, %2}"
8895   [(set_attr "type" "alu")
8896    (set_attr "mode" "DI")])
8897
8898 (define_expand "xorsi3"
8899   [(set (match_operand:SI 0 "nonimmediate_operand" "")
8900         (xor:SI (match_operand:SI 1 "nonimmediate_operand" "")
8901                 (match_operand:SI 2 "general_operand" "")))
8902    (clobber (reg:CC 17))]
8903   ""
8904   "ix86_expand_binary_operator (XOR, SImode, operands); DONE;")
8905
8906 (define_insn "*xorsi_1"
8907   [(set (match_operand:SI 0 "nonimmediate_operand" "=rm,r")
8908         (xor:SI (match_operand:SI 1 "nonimmediate_operand" "%0,0")
8909                 (match_operand:SI 2 "general_operand" "ri,rm")))
8910    (clobber (reg:CC 17))]
8911   "ix86_binary_operator_ok (XOR, SImode, operands)"
8912   "xor{l}\t{%2, %0|%0, %2}"
8913   [(set_attr "type" "alu")
8914    (set_attr "mode" "SI")])
8915
8916 ;; See comment for addsi_1_zext why we do use nonimmediate_operand
8917 ;; Add speccase for immediates
8918 (define_insn "*xorsi_1_zext"
8919   [(set (match_operand:DI 0 "register_operand" "=r")
8920         (zero_extend:DI
8921           (xor:SI (match_operand:SI 1 "nonimmediate_operand" "%0")
8922                   (match_operand:SI 2 "general_operand" "rim"))))
8923    (clobber (reg:CC 17))]
8924   "TARGET_64BIT && ix86_binary_operator_ok (XOR, SImode, operands)"
8925   "xor{l}\t{%2, %k0|%k0, %2}"
8926   [(set_attr "type" "alu")
8927    (set_attr "mode" "SI")])
8928
8929 (define_insn "*xorsi_1_zext_imm"
8930   [(set (match_operand:DI 0 "register_operand" "=r")
8931         (xor:DI (zero_extend:DI (match_operand:SI 1 "register_operand" "%0"))
8932                 (match_operand:DI 2 "x86_64_zext_immediate_operand" "Z")))
8933    (clobber (reg:CC 17))]
8934   "TARGET_64BIT && ix86_binary_operator_ok (XOR, SImode, operands)"
8935   "xor{l}\t{%2, %k0|%k0, %2}"
8936   [(set_attr "type" "alu")
8937    (set_attr "mode" "SI")])
8938
8939 (define_insn "*xorsi_2"
8940   [(set (reg 17)
8941         (compare (xor:SI (match_operand:SI 1 "nonimmediate_operand" "%0,0")
8942                          (match_operand:SI 2 "general_operand" "rim,ri"))
8943                  (const_int 0)))
8944    (set (match_operand:SI 0 "nonimmediate_operand" "=r,rm")
8945         (xor:SI (match_dup 1) (match_dup 2)))]
8946   "ix86_match_ccmode (insn, CCNOmode)
8947    && ix86_binary_operator_ok (XOR, SImode, operands)"
8948   "xor{l}\t{%2, %0|%0, %2}"
8949   [(set_attr "type" "alu")
8950    (set_attr "mode" "SI")])
8951
8952 ;; See comment for addsi_1_zext why we do use nonimmediate_operand
8953 ;; ??? Special case for immediate operand is missing - it is tricky.
8954 (define_insn "*xorsi_2_zext"
8955   [(set (reg 17)
8956         (compare (xor:SI (match_operand:SI 1 "nonimmediate_operand" "%0")
8957                          (match_operand:SI 2 "general_operand" "rim"))
8958                  (const_int 0)))
8959    (set (match_operand:DI 0 "register_operand" "=r")
8960         (zero_extend:DI (xor:SI (match_dup 1) (match_dup 2))))]
8961   "TARGET_64BIT && ix86_match_ccmode (insn, CCNOmode)
8962    && ix86_binary_operator_ok (XOR, SImode, operands)"
8963   "xor{l}\t{%2, %k0|%k0, %2}"
8964   [(set_attr "type" "alu")
8965    (set_attr "mode" "SI")])
8966
8967 (define_insn "*xorsi_2_zext_imm"
8968   [(set (reg 17)
8969         (compare (xor:SI (match_operand:SI 1 "nonimmediate_operand" "%0")
8970                          (match_operand 2 "x86_64_zext_immediate_operand" "Z"))
8971                  (const_int 0)))
8972    (set (match_operand:DI 0 "register_operand" "=r")
8973         (xor:DI (zero_extend:DI (match_dup 1)) (match_dup 2)))]
8974   "TARGET_64BIT && ix86_match_ccmode (insn, CCNOmode)
8975    && ix86_binary_operator_ok (XOR, SImode, operands)"
8976   "xor{l}\t{%2, %k0|%k0, %2}"
8977   [(set_attr "type" "alu")
8978    (set_attr "mode" "SI")])
8979
8980 (define_insn "*xorsi_3"
8981   [(set (reg 17)
8982         (compare (xor:SI (match_operand:SI 1 "nonimmediate_operand" "%0")
8983                          (match_operand:SI 2 "general_operand" "rim"))
8984                  (const_int 0)))
8985    (clobber (match_scratch:SI 0 "=r"))]
8986   "ix86_match_ccmode (insn, CCNOmode)
8987    && (GET_CODE (operands[1]) != MEM || GET_CODE (operands[2]) != MEM)"
8988   "xor{l}\t{%2, %0|%0, %2}"
8989   [(set_attr "type" "alu")
8990    (set_attr "mode" "SI")])
8991
8992 (define_expand "xorhi3"
8993   [(set (match_operand:HI 0 "nonimmediate_operand" "")
8994         (xor:HI (match_operand:HI 1 "nonimmediate_operand" "")
8995                 (match_operand:HI 2 "general_operand" "")))
8996    (clobber (reg:CC 17))]
8997   "TARGET_HIMODE_MATH"
8998   "ix86_expand_binary_operator (XOR, HImode, operands); DONE;")
8999
9000 (define_insn "*xorhi_1"
9001   [(set (match_operand:HI 0 "nonimmediate_operand" "=r,m")
9002         (xor:HI (match_operand:HI 1 "nonimmediate_operand" "%0,0")
9003                 (match_operand:HI 2 "general_operand" "rmi,ri")))
9004    (clobber (reg:CC 17))]
9005   "ix86_binary_operator_ok (XOR, HImode, operands)"
9006   "xor{w}\t{%2, %0|%0, %2}"
9007   [(set_attr "type" "alu")
9008    (set_attr "mode" "HI")])
9009
9010 (define_insn "*xorhi_2"
9011   [(set (reg 17)
9012         (compare (xor:HI (match_operand:HI 1 "nonimmediate_operand" "%0,0")
9013                          (match_operand:HI 2 "general_operand" "rim,ri"))
9014                  (const_int 0)))
9015    (set (match_operand:HI 0 "nonimmediate_operand" "=r,rm")
9016         (xor:HI (match_dup 1) (match_dup 2)))]
9017   "ix86_match_ccmode (insn, CCNOmode)
9018    && ix86_binary_operator_ok (XOR, HImode, operands)"
9019   "xor{w}\t{%2, %0|%0, %2}"
9020   [(set_attr "type" "alu")
9021    (set_attr "mode" "HI")])
9022
9023 (define_insn "*xorhi_3"
9024   [(set (reg 17)
9025         (compare (xor:HI (match_operand:HI 1 "nonimmediate_operand" "%0")
9026                          (match_operand:HI 2 "general_operand" "rim"))
9027                  (const_int 0)))
9028    (clobber (match_scratch:HI 0 "=r"))]
9029   "ix86_match_ccmode (insn, CCNOmode)
9030    && (GET_CODE (operands[1]) != MEM || GET_CODE (operands[2]) != MEM)"
9031   "xor{w}\t{%2, %0|%0, %2}"
9032   [(set_attr "type" "alu")
9033    (set_attr "mode" "HI")])
9034
9035 (define_expand "xorqi3"
9036   [(set (match_operand:QI 0 "nonimmediate_operand" "")
9037         (xor:QI (match_operand:QI 1 "nonimmediate_operand" "")
9038                 (match_operand:QI 2 "general_operand" "")))
9039    (clobber (reg:CC 17))]
9040   "TARGET_QIMODE_MATH"
9041   "ix86_expand_binary_operator (XOR, QImode, operands); DONE;")
9042
9043 ;; %%% Potential partial reg stall on alternative 2.  What to do?
9044 (define_insn "*xorqi_1"
9045   [(set (match_operand:QI 0 "nonimmediate_operand" "=q,m,r")
9046         (xor:QI (match_operand:QI 1 "nonimmediate_operand" "%0,0,0")
9047                 (match_operand:QI 2 "general_operand" "qmi,qi,ri")))
9048    (clobber (reg:CC 17))]
9049   "ix86_binary_operator_ok (XOR, QImode, operands)"
9050   "@
9051    xor{b}\t{%2, %0|%0, %2}
9052    xor{b}\t{%2, %0|%0, %2}
9053    xor{l}\t{%k2, %k0|%k0, %k2}"
9054   [(set_attr "type" "alu")
9055    (set_attr "mode" "QI,QI,SI")])
9056
9057 (define_insn "*xorqi_ext_1"
9058   [(set (zero_extract:SI (match_operand 0 "ext_register_operand" "=Q")
9059                          (const_int 8)
9060                          (const_int 8))
9061         (xor:SI 
9062           (zero_extract:SI (match_operand 1 "ext_register_operand" "0")
9063                            (const_int 8)
9064                            (const_int 8))
9065           (zero_extract:SI (match_operand 2 "ext_register_operand" "Q")
9066                            (const_int 8)
9067                            (const_int 8))))
9068    (clobber (reg:CC 17))]
9069   ""
9070   "xor{b}\t{%h2, %h0|%h0, %h2}"
9071   [(set_attr "type" "alu")
9072    (set_attr "length_immediate" "0")
9073    (set_attr "mode" "QI")])
9074
9075 (define_insn "*xorqi_cc_1"
9076   [(set (reg 17)
9077         (compare
9078           (xor:QI (match_operand:QI 1 "nonimmediate_operand" "%0,0")
9079                   (match_operand:QI 2 "general_operand" "qim,qi"))
9080           (const_int 0)))
9081    (set (match_operand:QI 0 "nonimmediate_operand" "=q,qm")
9082         (xor:QI (match_dup 1) (match_dup 2)))]
9083   "ix86_match_ccmode (insn, CCNOmode)
9084    && ix86_binary_operator_ok (XOR, QImode, operands)"
9085   "xor{b}\t{%2, %0|%0, %2}"
9086   [(set_attr "type" "alu")
9087    (set_attr "mode" "QI")])
9088
9089 (define_insn "*xorqi_cc_2"
9090   [(set (reg 17)
9091         (compare
9092           (xor:QI (match_operand:QI 1 "nonimmediate_operand" "%0")
9093                   (match_operand:QI 2 "general_operand" "qim"))
9094           (const_int 0)))
9095    (clobber (match_scratch:QI 0 "=q"))]
9096   "ix86_match_ccmode (insn, CCNOmode)
9097    && (GET_CODE (operands[1]) != MEM || GET_CODE (operands[2]) != MEM)"
9098   "xor{b}\t{%2, %0|%0, %2}"
9099   [(set_attr "type" "alu")
9100    (set_attr "mode" "QI")])
9101
9102 (define_insn "*xorqi_cc_ext_1"
9103   [(set (reg 17)
9104         (compare
9105           (xor:SI
9106             (zero_extract:SI
9107               (match_operand 1 "ext_register_operand" "0")
9108               (const_int 8)
9109               (const_int 8))
9110             (match_operand:QI 2 "general_operand" "qmn"))
9111           (const_int 0)))
9112    (set (zero_extract:SI (match_operand 0 "ext_register_operand" "=q")
9113                          (const_int 8)
9114                          (const_int 8))
9115         (xor:SI 
9116           (zero_extract:SI (match_dup 1) (const_int 8) (const_int 8))
9117           (match_dup 2)))]
9118   "!TARGET_64BIT && ix86_match_ccmode (insn, CCNOmode)"
9119   "xor{b}\t{%2, %h0|%h0, %2}"
9120   [(set_attr "type" "alu")
9121    (set_attr "mode" "QI")])
9122
9123 (define_insn "*xorqi_cc_ext_1_rex64"
9124   [(set (reg 17)
9125         (compare
9126           (xor:SI
9127             (zero_extract:SI
9128               (match_operand 1 "ext_register_operand" "0")
9129               (const_int 8)
9130               (const_int 8))
9131             (match_operand:QI 2 "nonmemory_operand" "Qn"))
9132           (const_int 0)))
9133    (set (zero_extract:SI (match_operand 0 "ext_register_operand" "=Q")
9134                          (const_int 8)
9135                          (const_int 8))
9136         (xor:SI 
9137           (zero_extract:SI (match_dup 1) (const_int 8) (const_int 8))
9138           (match_dup 2)))]
9139   "TARGET_64BIT && ix86_match_ccmode (insn, CCNOmode)"
9140   "xor{b}\t{%2, %h0|%h0, %2}"
9141   [(set_attr "type" "alu")
9142    (set_attr "mode" "QI")])
9143
9144 (define_expand "xorqi_cc_ext_1"
9145   [(parallel [
9146      (set (reg:CCNO 17)
9147           (compare:CCNO
9148             (xor:SI
9149               (zero_extract:SI
9150                 (match_operand 1 "ext_register_operand" "")
9151                 (const_int 8)
9152                 (const_int 8))
9153               (match_operand:QI 2 "general_operand" ""))
9154             (const_int 0)))
9155      (set (zero_extract:SI (match_operand 0 "ext_register_operand" "")
9156                            (const_int 8)
9157                            (const_int 8))
9158           (xor:SI 
9159             (zero_extract:SI (match_dup 1) (const_int 8) (const_int 8))
9160             (match_dup 2)))])]
9161   ""
9162   "")
9163 \f
9164 ;; Negation instructions
9165
9166 (define_expand "negdi2"
9167   [(parallel [(set (match_operand:DI 0 "nonimmediate_operand" "")
9168                    (neg:DI (match_operand:DI 1 "nonimmediate_operand" "")))
9169               (clobber (reg:CC 17))])]
9170   ""
9171   "ix86_expand_unary_operator (NEG, DImode, operands); DONE;")
9172
9173 (define_insn "*negdi2_1"
9174   [(set (match_operand:DI 0 "nonimmediate_operand" "=ro")
9175         (neg:DI (match_operand:DI 1 "general_operand" "0")))
9176    (clobber (reg:CC 17))]
9177   "!TARGET_64BIT
9178    && ix86_unary_operator_ok (NEG, DImode, operands)"
9179   "#")
9180
9181 (define_split
9182   [(set (match_operand:DI 0 "nonimmediate_operand" "")
9183         (neg:DI (match_operand:DI 1 "general_operand" "")))
9184    (clobber (reg:CC 17))]
9185   "!TARGET_64BIT && reload_completed"
9186   [(parallel
9187     [(set (reg:CCZ 17)
9188           (compare:CCZ (neg:SI (match_dup 2)) (const_int 0)))
9189      (set (match_dup 0) (neg:SI (match_dup 2)))])
9190    (parallel
9191     [(set (match_dup 1)
9192           (plus:SI (plus:SI (ltu:SI (reg:CC 17) (const_int 0))
9193                             (match_dup 3))
9194                    (const_int 0)))
9195      (clobber (reg:CC 17))])
9196    (parallel
9197     [(set (match_dup 1)
9198           (neg:SI (match_dup 1)))
9199      (clobber (reg:CC 17))])]
9200   "split_di (operands+1, 1, operands+2, operands+3);
9201    split_di (operands+0, 1, operands+0, operands+1);")
9202
9203 (define_insn "*negdi2_1_rex64"
9204   [(set (match_operand:DI 0 "nonimmediate_operand" "=rm")
9205         (neg:DI (match_operand:DI 1 "nonimmediate_operand" "0")))
9206    (clobber (reg:CC 17))]
9207   "TARGET_64BIT && ix86_unary_operator_ok (NEG, DImode, operands)"
9208   "neg{q}\t%0"
9209   [(set_attr "type" "negnot")
9210    (set_attr "mode" "DI")])
9211
9212 ;; The problem with neg is that it does not perform (compare x 0),
9213 ;; it really performs (compare 0 x), which leaves us with the zero
9214 ;; flag being the only useful item.
9215
9216 (define_insn "*negdi2_cmpz_rex64"
9217   [(set (reg:CCZ 17)
9218         (compare:CCZ (neg:DI (match_operand:DI 1 "nonimmediate_operand" "0"))
9219                      (const_int 0)))
9220    (set (match_operand:DI 0 "nonimmediate_operand" "=rm")
9221         (neg:DI (match_dup 1)))]
9222   "TARGET_64BIT && ix86_unary_operator_ok (NEG, DImode, operands)"
9223   "neg{q}\t%0"
9224   [(set_attr "type" "negnot")
9225    (set_attr "mode" "DI")])
9226
9227
9228 (define_expand "negsi2"
9229   [(parallel [(set (match_operand:SI 0 "nonimmediate_operand" "")
9230                    (neg:SI (match_operand:SI 1 "nonimmediate_operand" "")))
9231               (clobber (reg:CC 17))])]
9232   ""
9233   "ix86_expand_unary_operator (NEG, SImode, operands); DONE;")
9234
9235 (define_insn "*negsi2_1"
9236   [(set (match_operand:SI 0 "nonimmediate_operand" "=rm")
9237         (neg:SI (match_operand:SI 1 "nonimmediate_operand" "0")))
9238    (clobber (reg:CC 17))]
9239   "ix86_unary_operator_ok (NEG, SImode, operands)"
9240   "neg{l}\t%0"
9241   [(set_attr "type" "negnot")
9242    (set_attr "mode" "SI")])
9243
9244 ;; Combine is quite creative about this pattern.
9245 (define_insn "*negsi2_1_zext"
9246   [(set (match_operand:DI 0 "register_operand" "=r")
9247         (lshiftrt:DI (neg:DI (ashift:DI (match_operand:DI 1 "register_operand" "0")
9248                                         (const_int 32)))
9249                      (const_int 32)))
9250    (clobber (reg:CC 17))]
9251   "TARGET_64BIT && ix86_unary_operator_ok (NEG, SImode, operands)"
9252   "neg{l}\t%k0"
9253   [(set_attr "type" "negnot")
9254    (set_attr "mode" "SI")])
9255
9256 ;; The problem with neg is that it does not perform (compare x 0),
9257 ;; it really performs (compare 0 x), which leaves us with the zero
9258 ;; flag being the only useful item.
9259
9260 (define_insn "*negsi2_cmpz"
9261   [(set (reg:CCZ 17)
9262         (compare:CCZ (neg:SI (match_operand:SI 1 "nonimmediate_operand" "0"))
9263                      (const_int 0)))
9264    (set (match_operand:SI 0 "nonimmediate_operand" "=rm")
9265         (neg:SI (match_dup 1)))]
9266   "ix86_unary_operator_ok (NEG, SImode, operands)"
9267   "neg{l}\t%0"
9268   [(set_attr "type" "negnot")
9269    (set_attr "mode" "SI")])
9270
9271 (define_insn "*negsi2_cmpz_zext"
9272   [(set (reg:CCZ 17)
9273         (compare:CCZ (lshiftrt:DI
9274                        (neg:DI (ashift:DI
9275                                  (match_operand:DI 1 "register_operand" "0")
9276                                  (const_int 32)))
9277                        (const_int 32))
9278                      (const_int 0)))
9279    (set (match_operand:DI 0 "register_operand" "=r")
9280         (lshiftrt:DI (neg:DI (ashift:DI (match_dup 1)
9281                                         (const_int 32)))
9282                      (const_int 32)))]
9283   "TARGET_64BIT && ix86_unary_operator_ok (NEG, SImode, operands)"
9284   "neg{l}\t%k0"
9285   [(set_attr "type" "negnot")
9286    (set_attr "mode" "SI")])
9287
9288 (define_expand "neghi2"
9289   [(parallel [(set (match_operand:HI 0 "nonimmediate_operand" "")
9290                    (neg:HI (match_operand:HI 1 "nonimmediate_operand" "")))
9291               (clobber (reg:CC 17))])]
9292   "TARGET_HIMODE_MATH"
9293   "ix86_expand_unary_operator (NEG, HImode, operands); DONE;")
9294
9295 (define_insn "*neghi2_1"
9296   [(set (match_operand:HI 0 "nonimmediate_operand" "=rm")
9297         (neg:HI (match_operand:HI 1 "nonimmediate_operand" "0")))
9298    (clobber (reg:CC 17))]
9299   "ix86_unary_operator_ok (NEG, HImode, operands)"
9300   "neg{w}\t%0"
9301   [(set_attr "type" "negnot")
9302    (set_attr "mode" "HI")])
9303
9304 (define_insn "*neghi2_cmpz"
9305   [(set (reg:CCZ 17)
9306         (compare:CCZ (neg:HI (match_operand:HI 1 "nonimmediate_operand" "0"))
9307                      (const_int 0)))
9308    (set (match_operand:HI 0 "nonimmediate_operand" "=rm")
9309         (neg:HI (match_dup 1)))]
9310   "ix86_unary_operator_ok (NEG, HImode, operands)"
9311   "neg{w}\t%0"
9312   [(set_attr "type" "negnot")
9313    (set_attr "mode" "HI")])
9314
9315 (define_expand "negqi2"
9316   [(parallel [(set (match_operand:QI 0 "nonimmediate_operand" "")
9317                    (neg:QI (match_operand:QI 1 "nonimmediate_operand" "")))
9318               (clobber (reg:CC 17))])]
9319   "TARGET_QIMODE_MATH"
9320   "ix86_expand_unary_operator (NEG, QImode, operands); DONE;")
9321
9322 (define_insn "*negqi2_1"
9323   [(set (match_operand:QI 0 "nonimmediate_operand" "=qm")
9324         (neg:QI (match_operand:QI 1 "nonimmediate_operand" "0")))
9325    (clobber (reg:CC 17))]
9326   "ix86_unary_operator_ok (NEG, QImode, operands)"
9327   "neg{b}\t%0"
9328   [(set_attr "type" "negnot")
9329    (set_attr "mode" "QI")])
9330
9331 (define_insn "*negqi2_cmpz"
9332   [(set (reg:CCZ 17)
9333         (compare:CCZ (neg:QI (match_operand:QI 1 "nonimmediate_operand" "0"))
9334                      (const_int 0)))
9335    (set (match_operand:QI 0 "nonimmediate_operand" "=qm")
9336         (neg:QI (match_dup 1)))]
9337   "ix86_unary_operator_ok (NEG, QImode, operands)"
9338   "neg{b}\t%0"
9339   [(set_attr "type" "negnot")
9340    (set_attr "mode" "QI")])
9341
9342 ;; Changing of sign for FP values is doable using integer unit too.
9343
9344 (define_expand "negsf2"
9345   [(parallel [(set (match_operand:SF 0 "nonimmediate_operand" "")
9346                    (neg:SF (match_operand:SF 1 "nonimmediate_operand" "")))
9347               (clobber (reg:CC 17))])]
9348   "TARGET_80387"
9349   "if (TARGET_SSE)
9350      {
9351        /* In case operand is in memory,  we will not use SSE.  */
9352        if (memory_operand (operands[0], VOIDmode)
9353            && rtx_equal_p (operands[0], operands[1]))
9354          emit_insn (gen_negsf2_memory (operands[0], operands[1]));
9355        else
9356         {
9357           /* Using SSE is tricky, since we need bitwise negation of -0
9358              in register.  */
9359           rtx reg = gen_reg_rtx (SFmode);
9360           rtx dest = operands[0];
9361
9362           operands[1] = force_reg (SFmode, operands[1]);
9363           operands[0] = force_reg (SFmode, operands[0]);
9364           emit_move_insn (reg,
9365                           gen_lowpart (SFmode,
9366                                        GEN_INT (trunc_int_for_mode (0x80000000,
9367                                                                     SImode))));
9368           emit_insn (gen_negsf2_ifs (operands[0], operands[1], reg));
9369           if (dest != operands[0])
9370             emit_move_insn (dest, operands[0]);
9371         }
9372        DONE;
9373      }
9374    ix86_expand_unary_operator (NEG, SFmode, operands); DONE;")
9375
9376 (define_insn "negsf2_memory"
9377   [(set (match_operand:SF 0 "memory_operand" "=m")
9378         (neg:SF (match_operand:SF 1 "memory_operand" "0")))
9379    (clobber (reg:CC 17))]
9380   "ix86_unary_operator_ok (NEG, SFmode, operands)"
9381   "#")
9382
9383 (define_insn "negsf2_ifs"
9384   [(set (match_operand:SF 0 "nonimmediate_operand" "=x#fr,x#fr,f#xr,rm#xf")
9385         (neg:SF (match_operand:SF 1 "nonimmediate_operand" "0,x#fr,0,0")))
9386    (use (match_operand:SF 2 "nonmemory_operand" "x,0#x,*g#x,*g#x"))
9387    (clobber (reg:CC 17))]
9388   "TARGET_SSE
9389    && (reload_in_progress || reload_completed
9390        || (register_operand (operands[0], VOIDmode)
9391            && register_operand (operands[1], VOIDmode)))"
9392   "#")
9393
9394 (define_split
9395   [(set (match_operand:SF 0 "memory_operand" "")
9396         (neg:SF (match_operand:SF 1 "memory_operand" "")))
9397    (use (match_operand:SF 2 "" ""))
9398    (clobber (reg:CC 17))]
9399   ""
9400   [(parallel [(set (match_dup 0)
9401                    (neg:SF (match_dup 1)))
9402               (clobber (reg:CC 17))])])
9403
9404 (define_split
9405   [(set (match_operand:SF 0 "register_operand" "")
9406         (neg:SF (match_operand:SF 1 "register_operand" "")))
9407    (use (match_operand:SF 2 "" ""))
9408    (clobber (reg:CC 17))]
9409   "reload_completed && !SSE_REG_P (operands[0])"
9410   [(parallel [(set (match_dup 0)
9411                    (neg:SF (match_dup 1)))
9412               (clobber (reg:CC 17))])])
9413
9414 (define_split
9415   [(set (match_operand:SF 0 "register_operand" "")
9416         (neg:SF (match_operand:SF 1 "register_operand" "")))
9417    (use (match_operand:SF 2 "register_operand" ""))
9418    (clobber (reg:CC 17))]
9419   "reload_completed && SSE_REG_P (operands[0])"
9420   [(set (subreg:TI (match_dup 0) 0)
9421         (xor:TI (subreg:TI (match_dup 1) 0)
9422                 (subreg:TI (match_dup 2) 0)))]
9423 {
9424   if (operands_match_p (operands[0], operands[2]))
9425     {
9426       rtx tmp;
9427       tmp = operands[1];
9428       operands[1] = operands[2];
9429       operands[2] = tmp;
9430     }
9431 })
9432
9433
9434 ;; Keep 'f' and 'r' in separate alternatives to avoid reload problems
9435 ;; because of secondary memory needed to reload from class FLOAT_INT_REGS
9436 ;; to itself.
9437 (define_insn "*negsf2_if"
9438   [(set (match_operand:SF 0 "nonimmediate_operand" "=f#r,rm#f")
9439         (neg:SF (match_operand:SF 1 "nonimmediate_operand" "0,0")))
9440    (clobber (reg:CC 17))]
9441   "TARGET_80387 && !TARGET_SSE
9442    && ix86_unary_operator_ok (NEG, SFmode, operands)"
9443   "#")
9444
9445 (define_split
9446   [(set (match_operand:SF 0 "register_operand" "")
9447         (neg:SF (match_operand:SF 1 "register_operand" "")))
9448    (clobber (reg:CC 17))]
9449   "TARGET_80387 && FP_REGNO_P (REGNO (operands[0])) && reload_completed"
9450   [(set (match_dup 0)
9451         (neg:SF (match_dup 1)))]
9452   "")
9453
9454 (define_split
9455   [(set (match_operand:SF 0 "register_operand" "")
9456         (neg:SF (match_operand:SF 1 "register_operand" "")))
9457    (clobber (reg:CC 17))]
9458   "TARGET_80387 && reload_completed && !FP_REGNO_P (REGNO (operands[0]))"
9459   [(parallel [(set (match_dup 0) (xor:SI (match_dup 0) (match_dup 1)))
9460               (clobber (reg:CC 17))])]
9461   "operands[1] = GEN_INT (trunc_int_for_mode (0x80000000, SImode));
9462    operands[0] = gen_rtx_REG (SImode, REGNO (operands[0]));")
9463
9464 (define_split
9465   [(set (match_operand 0 "memory_operand" "")
9466         (neg (match_operand 1 "memory_operand" "")))
9467    (clobber (reg:CC 17))]
9468   "TARGET_80387 && reload_completed && FLOAT_MODE_P (GET_MODE (operands[0]))"
9469   [(parallel [(set (match_dup 0) (xor:QI (match_dup 0) (match_dup 1)))
9470               (clobber (reg:CC 17))])]
9471 {
9472   int size = GET_MODE_SIZE (GET_MODE (operands[1]));
9473
9474   /* XFmode's size is 12, TFmode 16, but only 10 bytes are used.  */
9475   if (size >= 12)
9476     size = 10;
9477   operands[0] = adjust_address (operands[0], QImode, size - 1);
9478   operands[1] = GEN_INT (trunc_int_for_mode (0x80, QImode));
9479 })
9480
9481 (define_expand "negdf2"
9482   [(parallel [(set (match_operand:DF 0 "nonimmediate_operand" "")
9483                    (neg:DF (match_operand:DF 1 "nonimmediate_operand" "")))
9484               (clobber (reg:CC 17))])]
9485   "TARGET_80387"
9486   "if (TARGET_SSE2)
9487      {
9488        /* In case operand is in memory,  we will not use SSE.  */
9489        if (memory_operand (operands[0], VOIDmode)
9490            && rtx_equal_p (operands[0], operands[1]))
9491          emit_insn (gen_negdf2_memory (operands[0], operands[1]));
9492        else
9493         {
9494           /* Using SSE is tricky, since we need bitwise negation of -0
9495              in register.  */
9496           rtx reg = gen_reg_rtx (DFmode);
9497 #if HOST_BITS_PER_WIDE_INT >= 64
9498           rtx imm = GEN_INT (trunc_int_for_mode(((HOST_WIDE_INT)1) << 63,
9499                                                 DImode));
9500 #else
9501           rtx imm = immed_double_const (0, 0x80000000, DImode);
9502 #endif
9503           rtx dest = operands[0];
9504
9505           operands[1] = force_reg (DFmode, operands[1]);
9506           operands[0] = force_reg (DFmode, operands[0]);
9507           emit_move_insn (reg, gen_lowpart (DFmode, imm));
9508           emit_insn (gen_negdf2_ifs (operands[0], operands[1], reg));
9509           if (dest != operands[0])
9510             emit_move_insn (dest, operands[0]);
9511         }
9512        DONE;
9513      }
9514    ix86_expand_unary_operator (NEG, DFmode, operands); DONE;")
9515
9516 (define_insn "negdf2_memory"
9517   [(set (match_operand:DF 0 "memory_operand" "=m")
9518         (neg:DF (match_operand:DF 1 "memory_operand" "0")))
9519    (clobber (reg:CC 17))]
9520   "ix86_unary_operator_ok (NEG, DFmode, operands)"
9521   "#")
9522
9523 (define_insn "negdf2_ifs"
9524   [(set (match_operand:DF 0 "nonimmediate_operand" "=Y#fr,Y#fr,f#Yr,rm#Yf")
9525         (neg:DF (match_operand:DF 1 "nonimmediate_operand" "0,Y#fr,0,0")))
9526    (use (match_operand:DF 2 "nonmemory_operand" "Y,0,*g#Y,*g#Y"))
9527    (clobber (reg:CC 17))]
9528   "!TARGET_64BIT && TARGET_SSE2
9529    && (reload_in_progress || reload_completed
9530        || (register_operand (operands[0], VOIDmode)
9531            && register_operand (operands[1], VOIDmode)))"
9532   "#")
9533
9534 (define_insn "*negdf2_ifs_rex64"
9535   [(set (match_operand:DF 0 "nonimmediate_operand" "=Y#fr,Y#fr,fm#Yr,r#Yf")
9536         (neg:DF (match_operand:DF 1 "nonimmediate_operand" "0,Y#fr,0,0")))
9537    (use (match_operand:DF 2 "general_operand" "Y,0,*g#Yr,*rm"))
9538    (clobber (reg:CC 17))]
9539   "TARGET_64BIT && TARGET_SSE2
9540    && (reload_in_progress || reload_completed
9541        || (register_operand (operands[0], VOIDmode)
9542            && register_operand (operands[1], VOIDmode)))"
9543   "#")
9544
9545 (define_split
9546   [(set (match_operand:DF 0 "memory_operand" "")
9547         (neg:DF (match_operand:DF 1 "memory_operand" "")))
9548    (use (match_operand:DF 2 "" ""))
9549    (clobber (reg:CC 17))]
9550   ""
9551   [(parallel [(set (match_dup 0)
9552                    (neg:DF (match_dup 1)))
9553               (clobber (reg:CC 17))])])
9554
9555 (define_split
9556   [(set (match_operand:DF 0 "register_operand" "")
9557         (neg:DF (match_operand:DF 1 "register_operand" "")))
9558    (use (match_operand:DF 2 "" ""))
9559    (clobber (reg:CC 17))]
9560   "reload_completed && !SSE_REG_P (operands[0])
9561    && (!TARGET_64BIT || FP_REG_P (operands[0]))"
9562   [(parallel [(set (match_dup 0)
9563                    (neg:DF (match_dup 1)))
9564               (clobber (reg:CC 17))])])
9565
9566 (define_split
9567   [(set (match_operand:DF 0 "register_operand" "")
9568         (neg:DF (match_operand:DF 1 "register_operand" "")))
9569    (use (match_operand:DF 2 "" ""))
9570    (clobber (reg:CC 17))]
9571   "TARGET_64BIT && reload_completed && GENERAL_REG_P (operands[0])"
9572   [(parallel [(set (match_dup 0)
9573                    (xor:DI (match_dup 1) (match_dup 2)))
9574               (clobber (reg:CC 17))])]
9575    "operands[0] = gen_lowpart (DImode, operands[0]);
9576     operands[1] = gen_lowpart (DImode, operands[1]);
9577     operands[2] = gen_lowpart (DImode, operands[2]);")
9578
9579 (define_split
9580   [(set (match_operand:DF 0 "register_operand" "")
9581         (neg:DF (match_operand:DF 1 "register_operand" "")))
9582    (use (match_operand:DF 2 "register_operand" ""))
9583    (clobber (reg:CC 17))]
9584   "reload_completed && SSE_REG_P (operands[0])"
9585   [(set (subreg:TI (match_dup 0) 0)
9586         (xor:TI (subreg:TI (match_dup 1) 0)
9587                 (subreg:TI (match_dup 2) 0)))]
9588 {
9589   if (operands_match_p (operands[0], operands[2]))
9590     {
9591       rtx tmp;
9592       tmp = operands[1];
9593       operands[1] = operands[2];
9594       operands[2] = tmp;
9595     }
9596 })
9597
9598 ;; Keep 'f' and 'r' in separate alternatives to avoid reload problems
9599 ;; because of secondary memory needed to reload from class FLOAT_INT_REGS
9600 ;; to itself.
9601 (define_insn "*negdf2_if"
9602   [(set (match_operand:DF 0 "nonimmediate_operand" "=f#r,rm#f")
9603         (neg:DF (match_operand:DF 1 "nonimmediate_operand" "0,0")))
9604    (clobber (reg:CC 17))]
9605   "!TARGET_64BIT && TARGET_80387
9606    && ix86_unary_operator_ok (NEG, DFmode, operands)"
9607   "#")
9608
9609 ;; FIXME: We should to allow integer registers here.  Problem is that
9610 ;; we need another scratch register to get constant from.
9611 ;; Forcing constant to mem if no register available in peep2 should be
9612 ;; safe even for PIC mode, because of RIP relative addressing.
9613 (define_insn "*negdf2_if_rex64"
9614   [(set (match_operand:DF 0 "nonimmediate_operand" "=f,mf")
9615         (neg:DF (match_operand:DF 1 "nonimmediate_operand" "0,0")))
9616    (clobber (reg:CC 17))]
9617   "TARGET_64BIT && TARGET_80387
9618    && ix86_unary_operator_ok (NEG, DFmode, operands)"
9619   "#")
9620
9621 (define_split
9622   [(set (match_operand:DF 0 "register_operand" "")
9623         (neg:DF (match_operand:DF 1 "register_operand" "")))
9624    (clobber (reg:CC 17))]
9625   "TARGET_80387 && FP_REGNO_P (REGNO (operands[0])) && reload_completed"
9626   [(set (match_dup 0)
9627         (neg:DF (match_dup 1)))]
9628   "")
9629
9630 (define_split
9631   [(set (match_operand:DF 0 "register_operand" "")
9632         (neg:DF (match_operand:DF 1 "register_operand" "")))
9633    (clobber (reg:CC 17))]
9634   "!TARGET_64BIT && TARGET_80387 && reload_completed
9635    && !FP_REGNO_P (REGNO (operands[0]))"
9636   [(parallel [(set (match_dup 3) (xor:SI (match_dup 3) (match_dup 4)))
9637               (clobber (reg:CC 17))])]
9638   "operands[4] = GEN_INT (trunc_int_for_mode (0x80000000, SImode));
9639    split_di (operands+0, 1, operands+2, operands+3);")
9640
9641 (define_expand "negxf2"
9642   [(parallel [(set (match_operand:XF 0 "nonimmediate_operand" "")
9643                    (neg:XF (match_operand:XF 1 "nonimmediate_operand" "")))
9644               (clobber (reg:CC 17))])]
9645   "!TARGET_64BIT && TARGET_80387"
9646   "ix86_expand_unary_operator (NEG, XFmode, operands); DONE;")
9647
9648 (define_expand "negtf2"
9649   [(parallel [(set (match_operand:TF 0 "nonimmediate_operand" "")
9650                    (neg:TF (match_operand:TF 1 "nonimmediate_operand" "")))
9651               (clobber (reg:CC 17))])]
9652   "TARGET_80387"
9653   "ix86_expand_unary_operator (NEG, TFmode, operands); DONE;")
9654
9655 ;; Keep 'f' and 'r' in separate alternatives to avoid reload problems
9656 ;; because of secondary memory needed to reload from class FLOAT_INT_REGS
9657 ;; to itself.
9658 (define_insn "*negxf2_if"
9659   [(set (match_operand:XF 0 "nonimmediate_operand" "=f#r,rm#f")
9660         (neg:XF (match_operand:XF 1 "nonimmediate_operand" "0,0")))
9661    (clobber (reg:CC 17))]
9662   "!TARGET_64BIT && TARGET_80387
9663    && ix86_unary_operator_ok (NEG, XFmode, operands)"
9664   "#")
9665
9666 (define_split
9667   [(set (match_operand:XF 0 "register_operand" "")
9668         (neg:XF (match_operand:XF 1 "register_operand" "")))
9669    (clobber (reg:CC 17))]
9670   "TARGET_80387 && FP_REGNO_P (REGNO (operands[0])) && reload_completed"
9671   [(set (match_dup 0)
9672         (neg:XF (match_dup 1)))]
9673   "")
9674
9675 (define_split
9676   [(set (match_operand:XF 0 "register_operand" "")
9677         (neg:XF (match_operand:XF 1 "register_operand" "")))
9678    (clobber (reg:CC 17))]
9679   "TARGET_80387 && reload_completed && !FP_REGNO_P (REGNO (operands[0]))"
9680   [(parallel [(set (match_dup 0) (xor:SI (match_dup 0) (match_dup 1)))
9681               (clobber (reg:CC 17))])]
9682   "operands[1] = GEN_INT (0x8000);
9683    operands[0] = gen_rtx_REG (SImode,
9684                               true_regnum (operands[0]) + (TARGET_64BIT ? 1 : 2));")
9685
9686 ;; Keep 'f' and 'r' in separate alternatives to avoid reload problems
9687 ;; because of secondary memory needed to reload from class FLOAT_INT_REGS
9688 ;; to itself.
9689 (define_insn "*negtf2_if"
9690   [(set (match_operand:TF 0 "nonimmediate_operand" "=f#r,rm#f")
9691         (neg:TF (match_operand:TF 1 "nonimmediate_operand" "0,0")))
9692    (clobber (reg:CC 17))]
9693   "TARGET_80387 && ix86_unary_operator_ok (NEG, TFmode, operands)"
9694   "#")
9695
9696 (define_split
9697   [(set (match_operand:TF 0 "register_operand" "")
9698         (neg:TF (match_operand:TF 1 "register_operand" "")))
9699    (clobber (reg:CC 17))]
9700   "TARGET_80387 && FP_REGNO_P (REGNO (operands[0])) && reload_completed"
9701   [(set (match_dup 0)
9702         (neg:TF (match_dup 1)))]
9703   "")
9704
9705 (define_split
9706   [(set (match_operand:TF 0 "register_operand" "")
9707         (neg:TF (match_operand:TF 1 "register_operand" "")))
9708    (clobber (reg:CC 17))]
9709   "TARGET_80387 && reload_completed && !FP_REGNO_P (REGNO (operands[0]))"
9710   [(parallel [(set (match_dup 0) (xor:SI (match_dup 0) (match_dup 1)))
9711               (clobber (reg:CC 17))])]
9712   "operands[1] = GEN_INT (0x8000);
9713    operands[0] = gen_rtx_REG (SImode,
9714                               true_regnum (operands[0]) + (TARGET_64BIT ? 1 : 2));")
9715
9716 ;; Conditionize these after reload. If they matches before reload, we 
9717 ;; lose the clobber and ability to use integer instructions.
9718
9719 (define_insn "*negsf2_1"
9720   [(set (match_operand:SF 0 "register_operand" "=f")
9721         (neg:SF (match_operand:SF 1 "register_operand" "0")))]
9722   "TARGET_80387 && reload_completed"
9723   "fchs"
9724   [(set_attr "type" "fsgn")
9725    (set_attr "mode" "SF")
9726    (set_attr "ppro_uops" "few")])
9727
9728 (define_insn "*negdf2_1"
9729   [(set (match_operand:DF 0 "register_operand" "=f")
9730         (neg:DF (match_operand:DF 1 "register_operand" "0")))]
9731   "TARGET_80387 && reload_completed"
9732   "fchs"
9733   [(set_attr "type" "fsgn")
9734    (set_attr "mode" "DF")
9735    (set_attr "ppro_uops" "few")])
9736
9737 (define_insn "*negextendsfdf2"
9738   [(set (match_operand:DF 0 "register_operand" "=f")
9739         (neg:DF (float_extend:DF
9740                   (match_operand:SF 1 "register_operand" "0"))))]
9741   "TARGET_80387"
9742   "fchs"
9743   [(set_attr "type" "fsgn")
9744    (set_attr "mode" "DF")
9745    (set_attr "ppro_uops" "few")])
9746
9747 (define_insn "*negxf2_1"
9748   [(set (match_operand:XF 0 "register_operand" "=f")
9749         (neg:XF (match_operand:XF 1 "register_operand" "0")))]
9750   "!TARGET_64BIT && TARGET_80387 && reload_completed"
9751   "fchs"
9752   [(set_attr "type" "fsgn")
9753    (set_attr "mode" "XF")
9754    (set_attr "ppro_uops" "few")])
9755
9756 (define_insn "*negextenddfxf2"
9757   [(set (match_operand:XF 0 "register_operand" "=f")
9758         (neg:XF (float_extend:XF
9759                   (match_operand:DF 1 "register_operand" "0"))))]
9760   "!TARGET_64BIT && TARGET_80387"
9761   "fchs"
9762   [(set_attr "type" "fsgn")
9763    (set_attr "mode" "XF")
9764    (set_attr "ppro_uops" "few")])
9765
9766 (define_insn "*negextendsfxf2"
9767   [(set (match_operand:XF 0 "register_operand" "=f")
9768         (neg:XF (float_extend:XF
9769                   (match_operand:SF 1 "register_operand" "0"))))]
9770   "!TARGET_64BIT && TARGET_80387"
9771   "fchs"
9772   [(set_attr "type" "fsgn")
9773    (set_attr "mode" "XF")
9774    (set_attr "ppro_uops" "few")])
9775
9776 (define_insn "*negtf2_1"
9777   [(set (match_operand:TF 0 "register_operand" "=f")
9778         (neg:TF (match_operand:TF 1 "register_operand" "0")))]
9779   "TARGET_80387 && reload_completed"
9780   "fchs"
9781   [(set_attr "type" "fsgn")
9782    (set_attr "mode" "XF")
9783    (set_attr "ppro_uops" "few")])
9784
9785 (define_insn "*negextenddftf2"
9786   [(set (match_operand:TF 0 "register_operand" "=f")
9787         (neg:TF (float_extend:TF
9788                   (match_operand:DF 1 "register_operand" "0"))))]
9789   "TARGET_80387"
9790   "fchs"
9791   [(set_attr "type" "fsgn")
9792    (set_attr "mode" "XF")
9793    (set_attr "ppro_uops" "few")])
9794
9795 (define_insn "*negextendsftf2"
9796   [(set (match_operand:TF 0 "register_operand" "=f")
9797         (neg:TF (float_extend:TF
9798                   (match_operand:SF 1 "register_operand" "0"))))]
9799   "TARGET_80387"
9800   "fchs"
9801   [(set_attr "type" "fsgn")
9802    (set_attr "mode" "XF")
9803    (set_attr "ppro_uops" "few")])
9804 \f
9805 ;; Absolute value instructions
9806
9807 (define_expand "abssf2"
9808   [(parallel [(set (match_operand:SF 0 "nonimmediate_operand" "")
9809                    (neg:SF (match_operand:SF 1 "nonimmediate_operand" "")))
9810               (clobber (reg:CC 17))])]
9811   "TARGET_80387"
9812   "if (TARGET_SSE)
9813      {
9814        /* In case operand is in memory,  we will not use SSE.  */
9815        if (memory_operand (operands[0], VOIDmode)
9816            && rtx_equal_p (operands[0], operands[1]))
9817          emit_insn (gen_abssf2_memory (operands[0], operands[1]));
9818        else
9819         {
9820           /* Using SSE is tricky, since we need bitwise negation of -0
9821              in register.  */
9822           rtx reg = gen_reg_rtx (SFmode);
9823           rtx dest = operands[0];
9824
9825           operands[1] = force_reg (SFmode, operands[1]);
9826           operands[0] = force_reg (SFmode, operands[0]);
9827           emit_move_insn (reg,
9828                           gen_lowpart (SFmode,
9829                                        GEN_INT (trunc_int_for_mode (0x80000000,
9830                                                                     SImode))));
9831           emit_insn (gen_abssf2_ifs (operands[0], operands[1], reg));
9832           if (dest != operands[0])
9833             emit_move_insn (dest, operands[0]);
9834         }
9835        DONE;
9836      }
9837    ix86_expand_unary_operator (ABS, SFmode, operands); DONE;")
9838
9839 (define_insn "abssf2_memory"
9840   [(set (match_operand:SF 0 "memory_operand" "=m")
9841         (abs:SF (match_operand:SF 1 "memory_operand" "0")))
9842    (clobber (reg:CC 17))]
9843   "ix86_unary_operator_ok (ABS, SFmode, operands)"
9844   "#")
9845
9846 (define_insn "abssf2_ifs"
9847   [(set (match_operand:SF 0 "nonimmediate_operand" "=x#fr,f#xr,rm#xf")
9848         (abs:SF (match_operand:SF 1 "nonimmediate_operand" "x,0,0")))
9849    (use (match_operand:SF 2 "nonmemory_operand" "*0#x,*g#x,*g#x"))
9850    (clobber (reg:CC 17))]
9851   "TARGET_SSE
9852    && (reload_in_progress || reload_completed
9853        || (register_operand (operands[0], VOIDmode)
9854            && register_operand (operands[1], VOIDmode)))"
9855   "#")
9856
9857 (define_split
9858   [(set (match_operand:SF 0 "memory_operand" "")
9859         (abs:SF (match_operand:SF 1 "memory_operand" "")))
9860    (use (match_operand:SF 2 "" ""))
9861    (clobber (reg:CC 17))]
9862   ""
9863   [(parallel [(set (match_dup 0)
9864                    (abs:SF (match_dup 1)))
9865               (clobber (reg:CC 17))])])
9866
9867 (define_split
9868   [(set (match_operand:SF 0 "register_operand" "")
9869         (abs:SF (match_operand:SF 1 "register_operand" "")))
9870    (use (match_operand:SF 2 "" ""))
9871    (clobber (reg:CC 17))]
9872   "reload_completed && !SSE_REG_P (operands[0])"
9873   [(parallel [(set (match_dup 0)
9874                    (abs:SF (match_dup 1)))
9875               (clobber (reg:CC 17))])])
9876
9877 (define_split
9878   [(set (match_operand:SF 0 "register_operand" "")
9879         (abs:SF (match_operand:SF 1 "register_operand" "")))
9880    (use (match_operand:SF 2 "register_operand" ""))
9881    (clobber (reg:CC 17))]
9882   "reload_completed && SSE_REG_P (operands[0])"
9883   [(set (subreg:TI (match_dup 0) 0)
9884         (and:TI (not:TI (subreg:TI (match_dup 2) 0))
9885                 (subreg:TI (match_dup 1) 0)))])
9886
9887 ;; Keep 'f' and 'r' in separate alternatives to avoid reload problems
9888 ;; because of secondary memory needed to reload from class FLOAT_INT_REGS
9889 ;; to itself.
9890 (define_insn "*abssf2_if"
9891   [(set (match_operand:SF 0 "nonimmediate_operand" "=f#r,rm#f")
9892         (abs:SF (match_operand:SF 1 "nonimmediate_operand" "0,0")))
9893    (clobber (reg:CC 17))]
9894   "TARGET_80387 && ix86_unary_operator_ok (ABS, SFmode, operands) && !TARGET_SSE"
9895   "#")
9896
9897 (define_split
9898   [(set (match_operand:SF 0 "register_operand" "")
9899         (abs:SF (match_operand:SF 1 "register_operand" "")))
9900    (clobber (reg:CC 17))]
9901   "TARGET_80387 && FP_REGNO_P (REGNO (operands[0]))"
9902   [(set (match_dup 0)
9903         (abs:SF (match_dup 1)))]
9904   "")
9905
9906 (define_split
9907   [(set (match_operand:SF 0 "register_operand" "")
9908         (abs:SF (match_operand:SF 1 "register_operand" "")))
9909    (clobber (reg:CC 17))]
9910   "TARGET_80387 && reload_completed && !FP_REGNO_P (REGNO (operands[0]))"
9911   [(parallel [(set (match_dup 0) (and:SI (match_dup 0) (match_dup 1)))
9912               (clobber (reg:CC 17))])]
9913   "operands[1] = GEN_INT (trunc_int_for_mode (~0x80000000, SImode));
9914    operands[0] = gen_rtx_REG (SImode, REGNO (operands[0]));")
9915
9916 (define_split
9917   [(set (match_operand 0 "memory_operand" "")
9918         (abs (match_operand 1 "memory_operand" "")))
9919    (clobber (reg:CC 17))]
9920   "TARGET_80387 && reload_completed && FLOAT_MODE_P (GET_MODE (operands[0]))"
9921   [(parallel [(set (match_dup 0) (and:QI (match_dup 0) (match_dup 1)))
9922               (clobber (reg:CC 17))])]
9923 {
9924   int size = GET_MODE_SIZE (GET_MODE (operands[1]));
9925
9926   /* XFmode's size is 12, TFmode 16, but only 10 bytes are used.  */
9927   if (size >= 12)
9928     size = 10;
9929   operands[0] = adjust_address (operands[0], QImode, size - 1);
9930   operands[1] = GEN_INT (trunc_int_for_mode (~0x80, QImode));
9931 })
9932
9933 (define_expand "absdf2"
9934   [(parallel [(set (match_operand:DF 0 "nonimmediate_operand" "")
9935                    (neg:DF (match_operand:DF 1 "nonimmediate_operand" "")))
9936               (clobber (reg:CC 17))])]
9937   "TARGET_80387"
9938   "if (TARGET_SSE2)
9939      {
9940        /* In case operand is in memory,  we will not use SSE.  */
9941        if (memory_operand (operands[0], VOIDmode)
9942            && rtx_equal_p (operands[0], operands[1]))
9943          emit_insn (gen_absdf2_memory (operands[0], operands[1]));
9944        else
9945         {
9946           /* Using SSE is tricky, since we need bitwise negation of -0
9947              in register.  */
9948           rtx reg = gen_reg_rtx (DFmode);
9949 #if HOST_BITS_PER_WIDE_INT >= 64
9950           rtx imm = GEN_INT (trunc_int_for_mode(((HOST_WIDE_INT)1) << 63,
9951                                                 DImode));
9952 #else
9953           rtx imm = immed_double_const (0, 0x80000000, DImode);
9954 #endif
9955           rtx dest = operands[0];
9956
9957           operands[1] = force_reg (DFmode, operands[1]);
9958           operands[0] = force_reg (DFmode, operands[0]);
9959           emit_move_insn (reg, gen_lowpart (DFmode, imm));
9960           emit_insn (gen_absdf2_ifs (operands[0], operands[1], reg));
9961           if (dest != operands[0])
9962             emit_move_insn (dest, operands[0]);
9963         }
9964        DONE;
9965      }
9966    ix86_expand_unary_operator (ABS, DFmode, operands); DONE;")
9967
9968 (define_insn "absdf2_memory"
9969   [(set (match_operand:DF 0 "memory_operand" "=m")
9970         (abs:DF (match_operand:DF 1 "memory_operand" "0")))
9971    (clobber (reg:CC 17))]
9972   "ix86_unary_operator_ok (ABS, DFmode, operands)"
9973   "#")
9974
9975 (define_insn "absdf2_ifs"
9976   [(set (match_operand:DF 0 "nonimmediate_operand" "=Y#fr,mf#Yr,mr#Yf")
9977         (abs:DF (match_operand:DF 1 "nonimmediate_operand" "Y,0,0")))
9978    (use (match_operand:DF 2 "nonmemory_operand" "*0#Y,*g#Y,*g#Y"))
9979    (clobber (reg:CC 17))]
9980   "!TARGET_64BIT && TARGET_SSE2
9981    && (reload_in_progress || reload_completed
9982        || (register_operand (operands[0], VOIDmode)
9983            && register_operand (operands[1], VOIDmode)))"
9984   "#")
9985
9986 (define_insn "*absdf2_ifs_rex64"
9987   [(set (match_operand:DF 0 "nonimmediate_operand" "=Y#fr,mf#Yr")
9988         (abs:DF (match_operand:DF 1 "nonimmediate_operand" "Y,0")))
9989    (use (match_operand:DF 2 "nonmemory_operand" "*0#Y,*g#Y"))
9990    (clobber (reg:CC 17))]
9991   "TARGET_64BIT && TARGET_SSE2
9992    && (reload_in_progress || reload_completed
9993        || (register_operand (operands[0], VOIDmode)
9994            && register_operand (operands[1], VOIDmode)))"
9995   "#")
9996
9997 (define_split
9998   [(set (match_operand:DF 0 "memory_operand" "")
9999         (abs:DF (match_operand:DF 1 "memory_operand" "")))
10000    (use (match_operand:DF 2 "" ""))
10001    (clobber (reg:CC 17))]
10002   ""
10003   [(parallel [(set (match_dup 0)
10004                    (abs:DF (match_dup 1)))
10005               (clobber (reg:CC 17))])])
10006
10007 (define_split
10008   [(set (match_operand:DF 0 "register_operand" "")
10009         (abs:DF (match_operand:DF 1 "register_operand" "")))
10010    (use (match_operand:DF 2 "" ""))
10011    (clobber (reg:CC 17))]
10012   "reload_completed && !SSE_REG_P (operands[0])"
10013   [(parallel [(set (match_dup 0)
10014                    (abs:DF (match_dup 1)))
10015               (clobber (reg:CC 17))])])
10016
10017 (define_split
10018   [(set (match_operand:DF 0 "register_operand" "")
10019         (abs:DF (match_operand:DF 1 "register_operand" "")))
10020    (use (match_operand:DF 2 "register_operand" ""))
10021    (clobber (reg:CC 17))]
10022   "reload_completed && SSE_REG_P (operands[0])"
10023   [(set (subreg:TI (match_dup 0) 0)
10024         (and:TI (not:TI (subreg:TI (match_dup 2) 0))
10025                 (subreg:TI (match_dup 1) 0)))])
10026
10027
10028 ;; Keep 'f' and 'r' in separate alternatives to avoid reload problems
10029 ;; because of secondary memory needed to reload from class FLOAT_INT_REGS
10030 ;; to itself.
10031 (define_insn "*absdf2_if"
10032   [(set (match_operand:DF 0 "nonimmediate_operand" "=f#r,rm#f")
10033         (abs:DF (match_operand:DF 1 "nonimmediate_operand" "0,0")))
10034    (clobber (reg:CC 17))]
10035   "!TARGET_64BIT && TARGET_80387
10036    && ix86_unary_operator_ok (ABS, DFmode, operands)"
10037   "#")
10038
10039 ;; FIXME: We should to allow integer registers here.  Problem is that
10040 ;; we need another scratch register to get constant from.
10041 ;; Forcing constant to mem if no register available in peep2 should be
10042 ;; safe even for PIC mode, because of RIP relative addressing.
10043 (define_insn "*absdf2_if_rex64"
10044   [(set (match_operand:DF 0 "nonimmediate_operand" "=f,mf")
10045         (abs:DF (match_operand:DF 1 "nonimmediate_operand" "0,0")))
10046    (clobber (reg:CC 17))]
10047   "TARGET_64BIT && TARGET_80387
10048    && ix86_unary_operator_ok (ABS, DFmode, operands)"
10049   "#")
10050
10051 (define_split
10052   [(set (match_operand:DF 0 "register_operand" "")
10053         (abs:DF (match_operand:DF 1 "register_operand" "")))
10054    (clobber (reg:CC 17))]
10055   "TARGET_80387 && FP_REGNO_P (REGNO (operands[0])) && reload_completed"
10056   [(set (match_dup 0)
10057         (abs:DF (match_dup 1)))]
10058   "")
10059
10060 (define_split
10061   [(set (match_operand:DF 0 "register_operand" "")
10062         (abs:DF (match_operand:DF 1 "register_operand" "")))
10063    (clobber (reg:CC 17))]
10064   "!TARGET_64BIT && TARGET_80387 && reload_completed &&
10065    !FP_REGNO_P (REGNO (operands[0]))"
10066   [(parallel [(set (match_dup 3) (and:SI (match_dup 3) (match_dup 4)))
10067               (clobber (reg:CC 17))])]
10068   "operands[4] = GEN_INT (trunc_int_for_mode (~0x80000000, SImode));
10069    split_di (operands+0, 1, operands+2, operands+3);")
10070
10071 (define_expand "absxf2"
10072   [(parallel [(set (match_operand:XF 0 "nonimmediate_operand" "")
10073                    (neg:XF (match_operand:XF 1 "nonimmediate_operand" "")))
10074               (clobber (reg:CC 17))])]
10075   "!TARGET_64BIT && TARGET_80387"
10076   "ix86_expand_unary_operator (ABS, XFmode, operands); DONE;")
10077
10078 (define_expand "abstf2"
10079   [(parallel [(set (match_operand:TF 0 "nonimmediate_operand" "")
10080                    (neg:TF (match_operand:TF 1 "nonimmediate_operand" "")))
10081               (clobber (reg:CC 17))])]
10082   "TARGET_80387"
10083   "ix86_expand_unary_operator (ABS, TFmode, operands); DONE;")
10084
10085 ;; Keep 'f' and 'r' in separate alternatives to avoid reload problems
10086 ;; because of secondary memory needed to reload from class FLOAT_INT_REGS
10087 ;; to itself.
10088 (define_insn "*absxf2_if"
10089   [(set (match_operand:XF 0 "nonimmediate_operand" "=f#r,rm#f")
10090         (abs:XF (match_operand:XF 1 "nonimmediate_operand" "0,0")))
10091    (clobber (reg:CC 17))]
10092   "!TARGET_64BIT && TARGET_80387
10093    && ix86_unary_operator_ok (ABS, XFmode, operands)"
10094   "#")
10095
10096 (define_split
10097   [(set (match_operand:XF 0 "register_operand" "")
10098         (abs:XF (match_operand:XF 1 "register_operand" "")))
10099    (clobber (reg:CC 17))]
10100   "TARGET_80387 && FP_REGNO_P (REGNO (operands[0])) && reload_completed"
10101   [(set (match_dup 0)
10102         (abs:XF (match_dup 1)))]
10103   "")
10104
10105 (define_split
10106   [(set (match_operand:XF 0 "register_operand" "")
10107         (abs:XF (match_operand:XF 1 "register_operand" "")))
10108    (clobber (reg:CC 17))]
10109   "TARGET_80387 && reload_completed && !FP_REGNO_P (REGNO (operands[0]))"
10110   [(parallel [(set (match_dup 0) (and:SI (match_dup 0) (match_dup 1)))
10111               (clobber (reg:CC 17))])]
10112   "operands[1] = GEN_INT (~0x8000);
10113    operands[0] = gen_rtx_REG (SImode,
10114                               true_regnum (operands[0]) + (TARGET_64BIT ? 1 : 2));")
10115
10116 (define_insn "*abstf2_if"
10117   [(set (match_operand:TF 0 "nonimmediate_operand" "=f#r,rm#f")
10118         (abs:TF (match_operand:TF 1 "nonimmediate_operand" "0,0")))
10119    (clobber (reg:CC 17))]
10120   "TARGET_80387 && ix86_unary_operator_ok (ABS, TFmode, operands)"
10121   "#")
10122
10123 (define_split
10124   [(set (match_operand:TF 0 "register_operand" "")
10125         (abs:TF (match_operand:TF 1 "register_operand" "")))
10126    (clobber (reg:CC 17))]
10127   "TARGET_80387 && FP_REGNO_P (REGNO (operands[0])) && reload_completed"
10128   [(set (match_dup 0)
10129         (abs:TF (match_dup 1)))]
10130   "")
10131
10132 (define_split
10133   [(set (match_operand:TF 0 "register_operand" "")
10134         (abs:TF (match_operand:TF 1 "register_operand" "")))
10135    (clobber (reg:CC 17))]
10136   "TARGET_80387 && reload_completed && !FP_REGNO_P (REGNO (operands[0]))"
10137   [(parallel [(set (match_dup 0) (and:SI (match_dup 0) (match_dup 1)))
10138               (clobber (reg:CC 17))])]
10139   "operands[1] = GEN_INT (~0x8000);
10140    operands[0] = gen_rtx_REG (SImode,
10141                               true_regnum (operands[0]) + (TARGET_64BIT ? 1 : 2));")
10142
10143 (define_insn "*abssf2_1"
10144   [(set (match_operand:SF 0 "register_operand" "=f")
10145         (abs:SF (match_operand:SF 1 "register_operand" "0")))]
10146   "TARGET_80387 && reload_completed"
10147   "fabs"
10148   [(set_attr "type" "fsgn")
10149    (set_attr "mode" "SF")])
10150
10151 (define_insn "*absdf2_1"
10152   [(set (match_operand:DF 0 "register_operand" "=f")
10153         (abs:DF (match_operand:DF 1 "register_operand" "0")))]
10154   "TARGET_80387 && reload_completed"
10155   "fabs"
10156   [(set_attr "type" "fsgn")
10157    (set_attr "mode" "DF")])
10158
10159 (define_insn "*absextendsfdf2"
10160   [(set (match_operand:DF 0 "register_operand" "=f")
10161         (abs:DF (float_extend:DF
10162                   (match_operand:SF 1 "register_operand" "0"))))]
10163   "TARGET_80387"
10164   "fabs"
10165   [(set_attr "type" "fsgn")
10166    (set_attr "mode" "DF")])
10167
10168 (define_insn "*absxf2_1"
10169   [(set (match_operand:XF 0 "register_operand" "=f")
10170         (abs:XF (match_operand:XF 1 "register_operand" "0")))]
10171   "!TARGET_64BIT && TARGET_80387 && reload_completed"
10172   "fabs"
10173   [(set_attr "type" "fsgn")
10174    (set_attr "mode" "DF")])
10175
10176 (define_insn "*absextenddfxf2"
10177   [(set (match_operand:XF 0 "register_operand" "=f")
10178         (abs:XF (float_extend:XF
10179           (match_operand:DF 1 "register_operand" "0"))))]
10180   "!TARGET_64BIT && TARGET_80387"
10181   "fabs"
10182   [(set_attr "type" "fsgn")
10183    (set_attr "mode" "XF")])
10184
10185 (define_insn "*absextendsfxf2"
10186   [(set (match_operand:XF 0 "register_operand" "=f")
10187         (abs:XF (float_extend:XF
10188           (match_operand:SF 1 "register_operand" "0"))))]
10189   "!TARGET_64BIT && TARGET_80387"
10190   "fabs"
10191   [(set_attr "type" "fsgn")
10192    (set_attr "mode" "XF")])
10193
10194 (define_insn "*abstf2_1"
10195   [(set (match_operand:TF 0 "register_operand" "=f")
10196         (abs:TF (match_operand:TF 1 "register_operand" "0")))]
10197   "TARGET_80387 && reload_completed"
10198   "fabs"
10199   [(set_attr "type" "fsgn")
10200    (set_attr "mode" "DF")])
10201
10202 (define_insn "*absextenddftf2"
10203   [(set (match_operand:TF 0 "register_operand" "=f")
10204         (abs:TF (float_extend:TF
10205           (match_operand:DF 1 "register_operand" "0"))))]
10206   "TARGET_80387"
10207   "fabs"
10208   [(set_attr "type" "fsgn")
10209    (set_attr "mode" "XF")])
10210
10211 (define_insn "*absextendsftf2"
10212   [(set (match_operand:TF 0 "register_operand" "=f")
10213         (abs:TF (float_extend:TF
10214           (match_operand:SF 1 "register_operand" "0"))))]
10215   "TARGET_80387"
10216   "fabs"
10217   [(set_attr "type" "fsgn")
10218    (set_attr "mode" "XF")])
10219 \f
10220 ;; One complement instructions
10221
10222 (define_expand "one_cmpldi2"
10223   [(set (match_operand:DI 0 "nonimmediate_operand" "")
10224         (not:DI (match_operand:DI 1 "nonimmediate_operand" "")))]
10225   "TARGET_64BIT"
10226   "ix86_expand_unary_operator (NOT, DImode, operands); DONE;")
10227
10228 (define_insn "*one_cmpldi2_1_rex64"
10229   [(set (match_operand:DI 0 "nonimmediate_operand" "=rm")
10230         (not:DI (match_operand:DI 1 "nonimmediate_operand" "0")))]
10231   "TARGET_64BIT && ix86_unary_operator_ok (NOT, DImode, operands)"
10232   "not{q}\t%0"
10233   [(set_attr "type" "negnot")
10234    (set_attr "mode" "DI")])
10235
10236 (define_insn "*one_cmpldi2_2_rex64"
10237   [(set (reg 17)
10238         (compare (not:DI (match_operand:DI 1 "nonimmediate_operand" "0"))
10239                  (const_int 0)))
10240    (set (match_operand:DI 0 "nonimmediate_operand" "=rm")
10241         (not:DI (match_dup 1)))]
10242   "TARGET_64BIT && ix86_match_ccmode (insn, CCNOmode)
10243    && ix86_unary_operator_ok (NOT, DImode, operands)"
10244   "#"
10245   [(set_attr "type" "alu1")
10246    (set_attr "mode" "DI")])
10247
10248 (define_split
10249   [(set (reg 17)
10250         (compare (not:DI (match_operand:DI 1 "nonimmediate_operand" ""))
10251                  (const_int 0)))
10252    (set (match_operand:DI 0 "nonimmediate_operand" "")
10253         (not:DI (match_dup 1)))]
10254   "TARGET_64BIT && ix86_match_ccmode (insn, CCNOmode)"
10255   [(parallel [(set (reg:CCNO 17)
10256                    (compare:CCNO (xor:DI (match_dup 1) (const_int -1))
10257                                  (const_int 0)))
10258               (set (match_dup 0)
10259                    (xor:DI (match_dup 1) (const_int -1)))])]
10260   "")
10261
10262 (define_expand "one_cmplsi2"
10263   [(set (match_operand:SI 0 "nonimmediate_operand" "")
10264         (not:SI (match_operand:SI 1 "nonimmediate_operand" "")))]
10265   ""
10266   "ix86_expand_unary_operator (NOT, SImode, operands); DONE;")
10267
10268 (define_insn "*one_cmplsi2_1"
10269   [(set (match_operand:SI 0 "nonimmediate_operand" "=rm")
10270         (not:SI (match_operand:SI 1 "nonimmediate_operand" "0")))]
10271   "ix86_unary_operator_ok (NOT, SImode, operands)"
10272   "not{l}\t%0"
10273   [(set_attr "type" "negnot")
10274    (set_attr "mode" "SI")])
10275
10276 ;; ??? Currently never generated - xor is used instead.
10277 (define_insn "*one_cmplsi2_1_zext"
10278   [(set (match_operand:DI 0 "register_operand" "=r")
10279         (zero_extend:DI (not:SI (match_operand:SI 1 "register_operand" "0"))))]
10280   "TARGET_64BIT && ix86_unary_operator_ok (NOT, SImode, operands)"
10281   "not{l}\t%k0"
10282   [(set_attr "type" "negnot")
10283    (set_attr "mode" "SI")])
10284
10285 (define_insn "*one_cmplsi2_2"
10286   [(set (reg 17)
10287         (compare (not:SI (match_operand:SI 1 "nonimmediate_operand" "0"))
10288                  (const_int 0)))
10289    (set (match_operand:SI 0 "nonimmediate_operand" "=rm")
10290         (not:SI (match_dup 1)))]
10291   "ix86_match_ccmode (insn, CCNOmode)
10292    && ix86_unary_operator_ok (NOT, SImode, operands)"
10293   "#"
10294   [(set_attr "type" "alu1")
10295    (set_attr "mode" "SI")])
10296
10297 (define_split
10298   [(set (reg 17)
10299         (compare (not:SI (match_operand:SI 1 "nonimmediate_operand" ""))
10300                  (const_int 0)))
10301    (set (match_operand:SI 0 "nonimmediate_operand" "")
10302         (not:SI (match_dup 1)))]
10303   "ix86_match_ccmode (insn, CCNOmode)"
10304   [(parallel [(set (reg:CCNO 17)
10305                    (compare:CCNO (xor:SI (match_dup 1) (const_int -1))
10306                                  (const_int 0)))
10307               (set (match_dup 0)
10308                    (xor:SI (match_dup 1) (const_int -1)))])]
10309   "")
10310
10311 ;; ??? Currently never generated - xor is used instead.
10312 (define_insn "*one_cmplsi2_2_zext"
10313   [(set (reg 17)
10314         (compare (not:SI (match_operand:SI 1 "register_operand" "0"))
10315                  (const_int 0)))
10316    (set (match_operand:DI 0 "register_operand" "=r")
10317         (zero_extend:DI (not:SI (match_dup 1))))]
10318   "TARGET_64BIT && ix86_match_ccmode (insn, CCNOmode)
10319    && ix86_unary_operator_ok (NOT, SImode, operands)"
10320   "#"
10321   [(set_attr "type" "alu1")
10322    (set_attr "mode" "SI")])
10323
10324 (define_split
10325   [(set (reg 17)
10326         (compare (not:SI (match_operand:SI 1 "register_operand" ""))
10327                  (const_int 0)))
10328    (set (match_operand:DI 0 "register_operand" "")
10329         (zero_extend:DI (not:SI (match_dup 1))))]
10330   "ix86_match_ccmode (insn, CCNOmode)"
10331   [(parallel [(set (reg:CCNO 17)
10332                    (compare:CCNO (xor:SI (match_dup 1) (const_int -1))
10333                                  (const_int 0)))
10334               (set (match_dup 0)
10335                    (zero_extend:DI (xor:SI (match_dup 1) (const_int -1))))])]
10336   "")
10337
10338 (define_expand "one_cmplhi2"
10339   [(set (match_operand:HI 0 "nonimmediate_operand" "")
10340         (not:HI (match_operand:HI 1 "nonimmediate_operand" "")))]
10341   "TARGET_HIMODE_MATH"
10342   "ix86_expand_unary_operator (NOT, HImode, operands); DONE;")
10343
10344 (define_insn "*one_cmplhi2_1"
10345   [(set (match_operand:HI 0 "nonimmediate_operand" "=rm")
10346         (not:HI (match_operand:HI 1 "nonimmediate_operand" "0")))]
10347   "ix86_unary_operator_ok (NOT, HImode, operands)"
10348   "not{w}\t%0"
10349   [(set_attr "type" "negnot")
10350    (set_attr "mode" "HI")])
10351
10352 (define_insn "*one_cmplhi2_2"
10353   [(set (reg 17)
10354         (compare (not:HI (match_operand:HI 1 "nonimmediate_operand" "0"))
10355                  (const_int 0)))
10356    (set (match_operand:HI 0 "nonimmediate_operand" "=rm")
10357         (not:HI (match_dup 1)))]
10358   "ix86_match_ccmode (insn, CCNOmode)
10359    && ix86_unary_operator_ok (NEG, HImode, operands)"
10360   "#"
10361   [(set_attr "type" "alu1")
10362    (set_attr "mode" "HI")])
10363
10364 (define_split
10365   [(set (reg 17)
10366         (compare (not:HI (match_operand:HI 1 "nonimmediate_operand" ""))
10367                  (const_int 0)))
10368    (set (match_operand:HI 0 "nonimmediate_operand" "")
10369         (not:HI (match_dup 1)))]
10370   "ix86_match_ccmode (insn, CCNOmode)"
10371   [(parallel [(set (reg:CCNO 17)
10372                    (compare:CCNO (xor:HI (match_dup 1) (const_int -1))
10373                                  (const_int 0)))
10374               (set (match_dup 0)
10375                    (xor:HI (match_dup 1) (const_int -1)))])]
10376   "")
10377
10378 ;; %%% Potential partial reg stall on alternative 1.  What to do?
10379 (define_expand "one_cmplqi2"
10380   [(set (match_operand:QI 0 "nonimmediate_operand" "")
10381         (not:QI (match_operand:QI 1 "nonimmediate_operand" "")))]
10382   "TARGET_QIMODE_MATH"
10383   "ix86_expand_unary_operator (NOT, QImode, operands); DONE;")
10384
10385 (define_insn "*one_cmplqi2_1"
10386   [(set (match_operand:QI 0 "nonimmediate_operand" "=qm,r")
10387         (not:QI (match_operand:QI 1 "nonimmediate_operand" "0,0")))]
10388   "ix86_unary_operator_ok (NOT, QImode, operands)"
10389   "@
10390    not{b}\t%0
10391    not{l}\t%k0"
10392   [(set_attr "type" "negnot")
10393    (set_attr "mode" "QI,SI")])
10394
10395 (define_insn "*one_cmplqi2_2"
10396   [(set (reg 17)
10397         (compare (not:QI (match_operand:QI 1 "nonimmediate_operand" "0"))
10398                  (const_int 0)))
10399    (set (match_operand:QI 0 "nonimmediate_operand" "=qm")
10400         (not:QI (match_dup 1)))]
10401   "ix86_match_ccmode (insn, CCNOmode)
10402    && ix86_unary_operator_ok (NOT, QImode, operands)"
10403   "#"
10404   [(set_attr "type" "alu1")
10405    (set_attr "mode" "QI")])
10406
10407 (define_split
10408   [(set (reg 17)
10409         (compare (not:QI (match_operand:QI 1 "nonimmediate_operand" ""))
10410                  (const_int 0)))
10411    (set (match_operand:QI 0 "nonimmediate_operand" "")
10412         (not:QI (match_dup 1)))]
10413   "ix86_match_ccmode (insn, CCNOmode)"
10414   [(parallel [(set (reg:CCNO 17)
10415                    (compare:CCNO (xor:QI (match_dup 1) (const_int -1))
10416                                  (const_int 0)))
10417               (set (match_dup 0)
10418                    (xor:QI (match_dup 1) (const_int -1)))])]
10419   "")
10420 \f
10421 ;; Arithmetic shift instructions
10422
10423 ;; DImode shifts are implemented using the i386 "shift double" opcode,
10424 ;; which is written as "sh[lr]d[lw] imm,reg,reg/mem".  If the shift count
10425 ;; is variable, then the count is in %cl and the "imm" operand is dropped
10426 ;; from the assembler input.
10427 ;;
10428 ;; This instruction shifts the target reg/mem as usual, but instead of
10429 ;; shifting in zeros, bits are shifted in from reg operand.  If the insn
10430 ;; is a left shift double, bits are taken from the high order bits of
10431 ;; reg, else if the insn is a shift right double, bits are taken from the
10432 ;; low order bits of reg.  So if %eax is "1234" and %edx is "5678",
10433 ;; "shldl $8,%edx,%eax" leaves %edx unchanged and sets %eax to "2345".
10434 ;;
10435 ;; Since sh[lr]d does not change the `reg' operand, that is done
10436 ;; separately, making all shifts emit pairs of shift double and normal
10437 ;; shift.  Since sh[lr]d does not shift more than 31 bits, and we wish to
10438 ;; support a 63 bit shift, each shift where the count is in a reg expands
10439 ;; to a pair of shifts, a branch, a shift by 32 and a label.
10440 ;;
10441 ;; If the shift count is a constant, we need never emit more than one
10442 ;; shift pair, instead using moves and sign extension for counts greater
10443 ;; than 31.
10444
10445 (define_expand "ashldi3"
10446   [(parallel [(set (match_operand:DI 0 "shiftdi_operand" "")
10447                    (ashift:DI (match_operand:DI 1 "shiftdi_operand" "")
10448                               (match_operand:QI 2 "nonmemory_operand" "")))
10449               (clobber (reg:CC 17))])]
10450   ""
10451 {
10452   if (!TARGET_64BIT && TARGET_CMOVE && ! immediate_operand (operands[2], QImode))
10453     {
10454       emit_insn (gen_ashldi3_1 (operands[0], operands[1], operands[2]));
10455       DONE;
10456     }
10457   ix86_expand_binary_operator (ASHIFT, DImode, operands);
10458   DONE;
10459 })
10460
10461 (define_insn "*ashldi3_1_rex64"
10462   [(set (match_operand:DI 0 "nonimmediate_operand" "=rm,r")
10463         (ashift:DI (match_operand:DI 1 "nonimmediate_operand" "0,r")
10464                    (match_operand:QI 2 "nonmemory_operand" "cJ,M")))
10465    (clobber (reg:CC 17))]
10466   "TARGET_64BIT && ix86_binary_operator_ok (ASHIFT, DImode, operands)"
10467 {
10468   switch (get_attr_type (insn))
10469     {
10470     case TYPE_ALU:
10471       if (operands[2] != const1_rtx)
10472         abort ();
10473       if (!rtx_equal_p (operands[0], operands[1]))
10474         abort ();
10475       return "add{q}\t{%0, %0|%0, %0}";
10476
10477     case TYPE_LEA:
10478       if (GET_CODE (operands[2]) != CONST_INT
10479           || (unsigned HOST_WIDE_INT) INTVAL (operands[2]) > 3)
10480         abort ();
10481       operands[1] = gen_rtx_MULT (DImode, operands[1],
10482                                   GEN_INT (1 << INTVAL (operands[2])));
10483       return "lea{q}\t{%a1, %0|%0, %a1}";
10484
10485     default:
10486       if (REG_P (operands[2]))
10487         return "sal{q}\t{%b2, %0|%0, %b2}";
10488       else if (GET_CODE (operands[2]) == CONST_INT
10489                && INTVAL (operands[2]) == 1
10490                && (TARGET_PENTIUM || TARGET_PENTIUMPRO))
10491         return "sal{q}\t%0";
10492       else
10493         return "sal{q}\t{%2, %0|%0, %2}";
10494     }
10495 }
10496   [(set (attr "type")
10497      (cond [(eq_attr "alternative" "1")
10498               (const_string "lea")
10499             (and (and (ne (symbol_ref "TARGET_DOUBLE_WITH_ADD")
10500                           (const_int 0))
10501                       (match_operand 0 "register_operand" ""))
10502                  (match_operand 2 "const1_operand" ""))
10503               (const_string "alu")
10504            ]
10505            (const_string "ishift")))
10506    (set_attr "mode" "DI")])
10507
10508 ;; Convert lea to the lea pattern to avoid flags dependency.
10509 (define_split
10510   [(set (match_operand:DI 0 "register_operand" "")
10511         (ashift:DI (match_operand:DI 1 "register_operand" "")
10512                    (match_operand:QI 2 "immediate_operand" "")))
10513    (clobber (reg:CC 17))]
10514   "TARGET_64BIT && reload_completed
10515    && true_regnum (operands[0]) != true_regnum (operands[1])"
10516   [(set (match_dup 0)
10517         (mult:DI (match_dup 1)
10518                  (match_dup 2)))]
10519   "operands[2] = GEN_INT (trunc_int_for_mode (1 << INTVAL (operands[2]),
10520                                               DImode));")
10521
10522 ;; This pattern can't accept a variable shift count, since shifts by
10523 ;; zero don't affect the flags.  We assume that shifts by constant
10524 ;; zero are optimized away.
10525 (define_insn "*ashldi3_cmp_rex64"
10526   [(set (reg 17)
10527         (compare
10528           (ashift:DI (match_operand:DI 1 "nonimmediate_operand" "0")
10529                      (match_operand:QI 2 "immediate_operand" "e"))
10530           (const_int 0)))
10531    (set (match_operand:DI 0 "nonimmediate_operand" "=rm")
10532         (ashift:DI (match_dup 1) (match_dup 2)))]
10533   "TARGET_64BIT && ix86_match_ccmode (insn, CCGOCmode)
10534    && ix86_binary_operator_ok (ASHIFT, DImode, operands)"
10535 {
10536   switch (get_attr_type (insn))
10537     {
10538     case TYPE_ALU:
10539       if (operands[2] != const1_rtx)
10540         abort ();
10541       return "add{q}\t{%0, %0|%0, %0}";
10542
10543     default:
10544       if (REG_P (operands[2]))
10545         return "sal{q}\t{%b2, %0|%0, %b2}";
10546       else if (GET_CODE (operands[2]) == CONST_INT
10547                && INTVAL (operands[2]) == 1
10548                && (TARGET_PENTIUM || TARGET_PENTIUMPRO))
10549         return "sal{q}\t%0";
10550       else
10551         return "sal{q}\t{%2, %0|%0, %2}";
10552     }
10553 }
10554   [(set (attr "type")
10555      (cond [(and (and (ne (symbol_ref "TARGET_DOUBLE_WITH_ADD")
10556                           (const_int 0))
10557                       (match_operand 0 "register_operand" ""))
10558                  (match_operand 2 "const1_operand" ""))
10559               (const_string "alu")
10560            ]
10561            (const_string "ishift")))
10562    (set_attr "mode" "DI")])
10563
10564 (define_insn "ashldi3_1"
10565   [(set (match_operand:DI 0 "register_operand" "=r")
10566         (ashift:DI (match_operand:DI 1 "register_operand" "0")
10567                    (match_operand:QI 2 "nonmemory_operand" "Jc")))
10568    (clobber (match_scratch:SI 3 "=&r"))
10569    (clobber (reg:CC 17))]
10570   "!TARGET_64BIT && TARGET_CMOVE"
10571   "#"
10572   [(set_attr "type" "multi")])
10573
10574 (define_insn "*ashldi3_2"
10575   [(set (match_operand:DI 0 "register_operand" "=r")
10576         (ashift:DI (match_operand:DI 1 "register_operand" "0")
10577                    (match_operand:QI 2 "nonmemory_operand" "Jc")))
10578    (clobber (reg:CC 17))]
10579   "!TARGET_64BIT"
10580   "#"
10581   [(set_attr "type" "multi")])
10582
10583 (define_split
10584   [(set (match_operand:DI 0 "register_operand" "")
10585         (ashift:DI (match_operand:DI 1 "register_operand" "")
10586                    (match_operand:QI 2 "nonmemory_operand" "")))
10587    (clobber (match_scratch:SI 3 ""))
10588    (clobber (reg:CC 17))]
10589   "!TARGET_64BIT && TARGET_CMOVE && reload_completed"
10590   [(const_int 0)]
10591   "ix86_split_ashldi (operands, operands[3]); DONE;")
10592
10593 (define_split
10594   [(set (match_operand:DI 0 "register_operand" "")
10595         (ashift:DI (match_operand:DI 1 "register_operand" "")
10596                    (match_operand:QI 2 "nonmemory_operand" "")))
10597    (clobber (reg:CC 17))]
10598   "!TARGET_64BIT && reload_completed"
10599   [(const_int 0)]
10600   "ix86_split_ashldi (operands, NULL_RTX); DONE;")
10601
10602 (define_insn "x86_shld_1"
10603   [(set (match_operand:SI 0 "nonimmediate_operand" "+r*m,r*m")
10604         (ior:SI (ashift:SI (match_dup 0)
10605                   (match_operand:QI 2 "nonmemory_operand" "I,c"))
10606                 (lshiftrt:SI (match_operand:SI 1 "register_operand" "r,r")
10607                   (minus:QI (const_int 32) (match_dup 2)))))
10608    (clobber (reg:CC 17))]
10609   ""
10610   "@
10611    shld{l}\t{%2, %1, %0|%0, %1, %2}
10612    shld{l}\t{%s2%1, %0|%0, %1, %2}"
10613   [(set_attr "type" "ishift")
10614    (set_attr "prefix_0f" "1")
10615    (set_attr "mode" "SI")
10616    (set_attr "pent_pair" "np")
10617    (set_attr "athlon_decode" "vector")
10618    (set_attr "ppro_uops" "few")])
10619
10620 (define_expand "x86_shift_adj_1"
10621   [(set (reg:CCZ 17)
10622         (compare:CCZ (and:QI (match_operand:QI 2 "register_operand" "")
10623                              (const_int 32))
10624                      (const_int 0)))
10625    (set (match_operand:SI 0 "register_operand" "")
10626         (if_then_else:SI (ne (reg:CCZ 17) (const_int 0))
10627                          (match_operand:SI 1 "register_operand" "")
10628                          (match_dup 0)))
10629    (set (match_dup 1)
10630         (if_then_else:SI (ne (reg:CCZ 17) (const_int 0))
10631                          (match_operand:SI 3 "register_operand" "r")
10632                          (match_dup 1)))]
10633   "TARGET_CMOVE"
10634   "")
10635
10636 (define_expand "x86_shift_adj_2"
10637   [(use (match_operand:SI 0 "register_operand" ""))
10638    (use (match_operand:SI 1 "register_operand" ""))
10639    (use (match_operand:QI 2 "register_operand" ""))]
10640   ""
10641 {
10642   rtx label = gen_label_rtx ();
10643   rtx tmp;
10644
10645   emit_insn (gen_testqi_ccz_1 (operands[2], GEN_INT (32)));
10646
10647   tmp = gen_rtx_REG (CCZmode, FLAGS_REG);
10648   tmp = gen_rtx_EQ (VOIDmode, tmp, const0_rtx);
10649   tmp = gen_rtx_IF_THEN_ELSE (VOIDmode, tmp,
10650                               gen_rtx_LABEL_REF (VOIDmode, label),
10651                               pc_rtx);
10652   tmp = emit_jump_insn (gen_rtx_SET (VOIDmode, pc_rtx, tmp));
10653   JUMP_LABEL (tmp) = label;
10654
10655   emit_move_insn (operands[0], operands[1]);
10656   emit_move_insn (operands[1], const0_rtx);
10657
10658   emit_label (label);
10659   LABEL_NUSES (label) = 1;
10660
10661   DONE;
10662 })
10663
10664 (define_expand "ashlsi3"
10665   [(set (match_operand:SI 0 "nonimmediate_operand" "")
10666         (ashift:SI (match_operand:SI 1 "nonimmediate_operand" "")
10667                    (match_operand:QI 2 "nonmemory_operand" "")))
10668    (clobber (reg:CC 17))]
10669   ""
10670   "ix86_expand_binary_operator (ASHIFT, SImode, operands); DONE;")
10671
10672 (define_insn "*ashlsi3_1"
10673   [(set (match_operand:SI 0 "nonimmediate_operand" "=rm,r")
10674         (ashift:SI (match_operand:SI 1 "nonimmediate_operand" "0,r")
10675                    (match_operand:QI 2 "nonmemory_operand" "cI,M")))
10676    (clobber (reg:CC 17))]
10677   "ix86_binary_operator_ok (ASHIFT, SImode, operands)"
10678 {
10679   switch (get_attr_type (insn))
10680     {
10681     case TYPE_ALU:
10682       if (operands[2] != const1_rtx)
10683         abort ();
10684       if (!rtx_equal_p (operands[0], operands[1]))
10685         abort ();
10686       return "add{l}\t{%0, %0|%0, %0}";
10687
10688     case TYPE_LEA:
10689       return "#";
10690
10691     default:
10692       if (REG_P (operands[2]))
10693         return "sal{l}\t{%b2, %0|%0, %b2}";
10694       else if (GET_CODE (operands[2]) == CONST_INT
10695                && INTVAL (operands[2]) == 1
10696                && (TARGET_PENTIUM || TARGET_PENTIUMPRO))
10697         return "sal{l}\t%0";
10698       else
10699         return "sal{l}\t{%2, %0|%0, %2}";
10700     }
10701 }
10702   [(set (attr "type")
10703      (cond [(eq_attr "alternative" "1")
10704               (const_string "lea")
10705             (and (and (ne (symbol_ref "TARGET_DOUBLE_WITH_ADD")
10706                           (const_int 0))
10707                       (match_operand 0 "register_operand" ""))
10708                  (match_operand 2 "const1_operand" ""))
10709               (const_string "alu")
10710            ]
10711            (const_string "ishift")))
10712    (set_attr "mode" "SI")])
10713
10714 ;; Convert lea to the lea pattern to avoid flags dependency.
10715 (define_split
10716   [(set (match_operand 0 "register_operand" "")
10717         (ashift (match_operand 1 "register_operand" "")
10718                 (match_operand:QI 2 "const_int_operand" "")))
10719    (clobber (reg:CC 17))]
10720   "reload_completed
10721    && true_regnum (operands[0]) != true_regnum (operands[1])"
10722   [(const_int 0)]
10723 {
10724   rtx pat;
10725   operands[0] = gen_lowpart (SImode, operands[0]);
10726   operands[1] = gen_lowpart (Pmode, operands[1]);
10727   operands[2] = GEN_INT (trunc_int_for_mode (1 << INTVAL (operands[2]),
10728                                              Pmode));
10729   pat = gen_rtx_MULT (Pmode, operands[1], operands[2]);
10730   if (Pmode != SImode)
10731     pat = gen_rtx_SUBREG (SImode, pat, 0);
10732   emit_insn (gen_rtx_SET (VOIDmode, operands[0], pat));
10733   DONE;
10734 })
10735
10736 (define_insn "*ashlsi3_1_zext"
10737   [(set (match_operand:DI 0 "register_operand" "=r,r")
10738         (zero_extend:DI (ashift:SI (match_operand:SI 1 "register_operand" "0,r")
10739                         (match_operand:QI 2 "nonmemory_operand" "cI,M"))))
10740    (clobber (reg:CC 17))]
10741   "TARGET_64BIT && ix86_binary_operator_ok (ASHIFT, SImode, operands)"
10742 {
10743   switch (get_attr_type (insn))
10744     {
10745     case TYPE_ALU:
10746       if (operands[2] != const1_rtx)
10747         abort ();
10748       return "add{l}\t{%k0, %k0|%k0, %k0}";
10749
10750     case TYPE_LEA:
10751       return "#";
10752
10753     default:
10754       if (REG_P (operands[2]))
10755         return "sal{l}\t{%b2, %k0|%k0, %b2}";
10756       else if (GET_CODE (operands[2]) == CONST_INT
10757                && INTVAL (operands[2]) == 1
10758                && (TARGET_PENTIUM || TARGET_PENTIUMPRO))
10759         return "sal{l}\t%k0";
10760       else
10761         return "sal{l}\t{%2, %k0|%k0, %2}";
10762     }
10763 }
10764   [(set (attr "type")
10765      (cond [(eq_attr "alternative" "1")
10766               (const_string "lea")
10767             (and (ne (symbol_ref "TARGET_DOUBLE_WITH_ADD")
10768                      (const_int 0))
10769                  (match_operand 2 "const1_operand" ""))
10770               (const_string "alu")
10771            ]
10772            (const_string "ishift")))
10773    (set_attr "mode" "SI")])
10774
10775 ;; Convert lea to the lea pattern to avoid flags dependency.
10776 (define_split
10777   [(set (match_operand:DI 0 "register_operand" "")
10778         (zero_extend:DI (ashift (match_operand 1 "register_operand" "")
10779                                 (match_operand:QI 2 "const_int_operand" ""))))
10780    (clobber (reg:CC 17))]
10781   "reload_completed
10782    && true_regnum (operands[0]) != true_regnum (operands[1])"
10783   [(set (match_dup 0) (zero_extend:DI (subreg:SI (mult:SI (match_dup 1) (match_dup 2)) 0)))]
10784 {
10785   operands[1] = gen_lowpart (Pmode, operands[1]);
10786   operands[2] = GEN_INT (trunc_int_for_mode (1 << INTVAL (operands[2]),
10787                                              Pmode));
10788 })
10789
10790 ;; This pattern can't accept a variable shift count, since shifts by
10791 ;; zero don't affect the flags.  We assume that shifts by constant
10792 ;; zero are optimized away.
10793 (define_insn "*ashlsi3_cmp"
10794   [(set (reg 17)
10795         (compare
10796           (ashift:SI (match_operand:SI 1 "nonimmediate_operand" "0")
10797                      (match_operand:QI 2 "immediate_operand" "I"))
10798           (const_int 0)))
10799    (set (match_operand:SI 0 "nonimmediate_operand" "=rm")
10800         (ashift:SI (match_dup 1) (match_dup 2)))]
10801   "ix86_match_ccmode (insn, CCGOCmode)
10802    && ix86_binary_operator_ok (ASHIFT, SImode, operands)"
10803 {
10804   switch (get_attr_type (insn))
10805     {
10806     case TYPE_ALU:
10807       if (operands[2] != const1_rtx)
10808         abort ();
10809       return "add{l}\t{%0, %0|%0, %0}";
10810
10811     default:
10812       if (REG_P (operands[2]))
10813         return "sal{l}\t{%b2, %0|%0, %b2}";
10814       else if (GET_CODE (operands[2]) == CONST_INT
10815                && INTVAL (operands[2]) == 1
10816                && (TARGET_PENTIUM || TARGET_PENTIUMPRO))
10817         return "sal{l}\t%0";
10818       else
10819         return "sal{l}\t{%2, %0|%0, %2}";
10820     }
10821 }
10822   [(set (attr "type")
10823      (cond [(and (and (ne (symbol_ref "TARGET_DOUBLE_WITH_ADD")
10824                           (const_int 0))
10825                       (match_operand 0 "register_operand" ""))
10826                  (match_operand 2 "const1_operand" ""))
10827               (const_string "alu")
10828            ]
10829            (const_string "ishift")))
10830    (set_attr "mode" "SI")])
10831
10832 (define_insn "*ashlsi3_cmp_zext"
10833   [(set (reg 17)
10834         (compare
10835           (ashift:SI (match_operand:SI 1 "register_operand" "0")
10836                      (match_operand:QI 2 "immediate_operand" "I"))
10837           (const_int 0)))
10838    (set (match_operand:DI 0 "register_operand" "=r")
10839         (zero_extend:DI (ashift:SI (match_dup 1) (match_dup 2))))]
10840   "TARGET_64BIT && ix86_match_ccmode (insn, CCGOCmode)
10841    && ix86_binary_operator_ok (ASHIFT, SImode, operands)"
10842 {
10843   switch (get_attr_type (insn))
10844     {
10845     case TYPE_ALU:
10846       if (operands[2] != const1_rtx)
10847         abort ();
10848       return "add{l}\t{%k0, %k0|%k0, %k0}";
10849
10850     default:
10851       if (REG_P (operands[2]))
10852         return "sal{l}\t{%b2, %k0|%k0, %b2}";
10853       else if (GET_CODE (operands[2]) == CONST_INT
10854                && INTVAL (operands[2]) == 1
10855                && (TARGET_PENTIUM || TARGET_PENTIUMPRO))
10856         return "sal{l}\t%k0";
10857       else
10858         return "sal{l}\t{%2, %k0|%k0, %2}";
10859     }
10860 }
10861   [(set (attr "type")
10862      (cond [(and (ne (symbol_ref "TARGET_DOUBLE_WITH_ADD")
10863                      (const_int 0))
10864                  (match_operand 2 "const1_operand" ""))
10865               (const_string "alu")
10866            ]
10867            (const_string "ishift")))
10868    (set_attr "mode" "SI")])
10869
10870 (define_expand "ashlhi3"
10871   [(set (match_operand:HI 0 "nonimmediate_operand" "")
10872         (ashift:HI (match_operand:HI 1 "nonimmediate_operand" "")
10873                    (match_operand:QI 2 "nonmemory_operand" "")))
10874    (clobber (reg:CC 17))]
10875   "TARGET_HIMODE_MATH"
10876   "ix86_expand_binary_operator (ASHIFT, HImode, operands); DONE;")
10877
10878 (define_insn "*ashlhi3_1_lea"
10879   [(set (match_operand:HI 0 "nonimmediate_operand" "=rm,r")
10880         (ashift:HI (match_operand:HI 1 "nonimmediate_operand" "0,r")
10881                    (match_operand:QI 2 "nonmemory_operand" "cI,M")))
10882    (clobber (reg:CC 17))]
10883   "!TARGET_PARTIAL_REG_STALL
10884    && ix86_binary_operator_ok (ASHIFT, HImode, operands)"
10885 {
10886   switch (get_attr_type (insn))
10887     {
10888     case TYPE_LEA:
10889       return "#";
10890     case TYPE_ALU:
10891       if (operands[2] != const1_rtx)
10892         abort ();
10893       return "add{w}\t{%0, %0|%0, %0}";
10894
10895     default:
10896       if (REG_P (operands[2]))
10897         return "sal{w}\t{%b2, %0|%0, %b2}";
10898       else if (GET_CODE (operands[2]) == CONST_INT
10899                && INTVAL (operands[2]) == 1
10900                && (TARGET_PENTIUM || TARGET_PENTIUMPRO))
10901         return "sal{w}\t%0";
10902       else
10903         return "sal{w}\t{%2, %0|%0, %2}";
10904     }
10905 }
10906   [(set (attr "type")
10907      (cond [(eq_attr "alternative" "1")
10908               (const_string "lea")
10909             (and (and (ne (symbol_ref "TARGET_DOUBLE_WITH_ADD")
10910                           (const_int 0))
10911                       (match_operand 0 "register_operand" ""))
10912                  (match_operand 2 "const1_operand" ""))
10913               (const_string "alu")
10914            ]
10915            (const_string "ishift")))
10916    (set_attr "mode" "HI,SI")])
10917
10918 (define_insn "*ashlhi3_1"
10919   [(set (match_operand:HI 0 "nonimmediate_operand" "=rm")
10920         (ashift:HI (match_operand:HI 1 "nonimmediate_operand" "0")
10921                    (match_operand:QI 2 "nonmemory_operand" "cI")))
10922    (clobber (reg:CC 17))]
10923   "TARGET_PARTIAL_REG_STALL
10924    && ix86_binary_operator_ok (ASHIFT, HImode, operands)"
10925 {
10926   switch (get_attr_type (insn))
10927     {
10928     case TYPE_ALU:
10929       if (operands[2] != const1_rtx)
10930         abort ();
10931       return "add{w}\t{%0, %0|%0, %0}";
10932
10933     default:
10934       if (REG_P (operands[2]))
10935         return "sal{w}\t{%b2, %0|%0, %b2}";
10936       else if (GET_CODE (operands[2]) == CONST_INT
10937                && INTVAL (operands[2]) == 1
10938                && (TARGET_PENTIUM || TARGET_PENTIUMPRO))
10939         return "sal{w}\t%0";
10940       else
10941         return "sal{w}\t{%2, %0|%0, %2}";
10942     }
10943 }
10944   [(set (attr "type")
10945      (cond [(and (and (ne (symbol_ref "TARGET_DOUBLE_WITH_ADD")
10946                           (const_int 0))
10947                       (match_operand 0 "register_operand" ""))
10948                  (match_operand 2 "const1_operand" ""))
10949               (const_string "alu")
10950            ]
10951            (const_string "ishift")))
10952    (set_attr "mode" "HI")])
10953
10954 ;; This pattern can't accept a variable shift count, since shifts by
10955 ;; zero don't affect the flags.  We assume that shifts by constant
10956 ;; zero are optimized away.
10957 (define_insn "*ashlhi3_cmp"
10958   [(set (reg 17)
10959         (compare
10960           (ashift:HI (match_operand:HI 1 "nonimmediate_operand" "0")
10961                      (match_operand:QI 2 "immediate_operand" "I"))
10962           (const_int 0)))
10963    (set (match_operand:HI 0 "nonimmediate_operand" "=rm")
10964         (ashift:HI (match_dup 1) (match_dup 2)))]
10965   "ix86_match_ccmode (insn, CCGOCmode)
10966    && ix86_binary_operator_ok (ASHIFT, HImode, operands)"
10967 {
10968   switch (get_attr_type (insn))
10969     {
10970     case TYPE_ALU:
10971       if (operands[2] != const1_rtx)
10972         abort ();
10973       return "add{w}\t{%0, %0|%0, %0}";
10974
10975     default:
10976       if (REG_P (operands[2]))
10977         return "sal{w}\t{%b2, %0|%0, %b2}";
10978       else if (GET_CODE (operands[2]) == CONST_INT
10979                && INTVAL (operands[2]) == 1
10980                && (TARGET_PENTIUM || TARGET_PENTIUMPRO))
10981         return "sal{w}\t%0";
10982       else
10983         return "sal{w}\t{%2, %0|%0, %2}";
10984     }
10985 }
10986   [(set (attr "type")
10987      (cond [(and (and (ne (symbol_ref "TARGET_DOUBLE_WITH_ADD")
10988                           (const_int 0))
10989                       (match_operand 0 "register_operand" ""))
10990                  (match_operand 2 "const1_operand" ""))
10991               (const_string "alu")
10992            ]
10993            (const_string "ishift")))
10994    (set_attr "mode" "HI")])
10995
10996 (define_expand "ashlqi3"
10997   [(set (match_operand:QI 0 "nonimmediate_operand" "")
10998         (ashift:QI (match_operand:QI 1 "nonimmediate_operand" "")
10999                    (match_operand:QI 2 "nonmemory_operand" "")))
11000    (clobber (reg:CC 17))]
11001   "TARGET_QIMODE_MATH"
11002   "ix86_expand_binary_operator (ASHIFT, QImode, operands); DONE;")
11003
11004 ;; %%% Potential partial reg stall on alternative 2.  What to do?
11005
11006 (define_insn "*ashlqi3_1_lea"
11007   [(set (match_operand:QI 0 "nonimmediate_operand" "=qm,r,r")
11008         (ashift:QI (match_operand:QI 1 "nonimmediate_operand" "0,0,r")
11009                    (match_operand:QI 2 "nonmemory_operand" "cI,cI,M")))
11010    (clobber (reg:CC 17))]
11011   "!TARGET_PARTIAL_REG_STALL
11012    && ix86_binary_operator_ok (ASHIFT, QImode, operands)"
11013 {
11014   switch (get_attr_type (insn))
11015     {
11016     case TYPE_LEA:
11017       return "#";
11018     case TYPE_ALU:
11019       if (operands[2] != const1_rtx)
11020         abort ();
11021       if (REG_P (operands[1]) && !ANY_QI_REG_P (operands[1]))
11022         return "add{l}\t{%k0, %k0|%k0, %k0}";
11023       else
11024         return "add{b}\t{%0, %0|%0, %0}";
11025
11026     default:
11027       if (REG_P (operands[2]))
11028         {
11029           if (get_attr_mode (insn) == MODE_SI)
11030             return "sal{l}\t{%b2, %k0|%k0, %b2}";
11031           else
11032             return "sal{b}\t{%b2, %0|%0, %b2}";
11033         }
11034       else if (GET_CODE (operands[2]) == CONST_INT
11035                && INTVAL (operands[2]) == 1
11036                && (TARGET_PENTIUM || TARGET_PENTIUMPRO))
11037         {
11038           if (get_attr_mode (insn) == MODE_SI)
11039             return "sal{l}\t%0";
11040           else
11041             return "sal{b}\t%0";
11042         }
11043       else
11044         {
11045           if (get_attr_mode (insn) == MODE_SI)
11046             return "sal{l}\t{%2, %k0|%k0, %2}";
11047           else
11048             return "sal{b}\t{%2, %0|%0, %2}";
11049         }
11050     }
11051 }
11052   [(set (attr "type")
11053      (cond [(eq_attr "alternative" "2")
11054               (const_string "lea")
11055             (and (and (ne (symbol_ref "TARGET_DOUBLE_WITH_ADD")
11056                           (const_int 0))
11057                       (match_operand 0 "register_operand" ""))
11058                  (match_operand 2 "const1_operand" ""))
11059               (const_string "alu")
11060            ]
11061            (const_string "ishift")))
11062    (set_attr "mode" "QI,SI,SI")])
11063
11064 (define_insn "*ashlqi3_1"
11065   [(set (match_operand:QI 0 "nonimmediate_operand" "=qm,r")
11066         (ashift:QI (match_operand:QI 1 "nonimmediate_operand" "0,0")
11067                    (match_operand:QI 2 "nonmemory_operand" "cI,cI")))
11068    (clobber (reg:CC 17))]
11069   "TARGET_PARTIAL_REG_STALL
11070    && ix86_binary_operator_ok (ASHIFT, QImode, operands)"
11071 {
11072   switch (get_attr_type (insn))
11073     {
11074     case TYPE_ALU:
11075       if (operands[2] != const1_rtx)
11076         abort ();
11077       if (REG_P (operands[1]) && !ANY_QI_REG_P (operands[1]))
11078         return "add{l}\t{%k0, %k0|%k0, %k0}";
11079       else
11080         return "add{b}\t{%0, %0|%0, %0}";
11081
11082     default:
11083       if (REG_P (operands[2]))
11084         {
11085           if (get_attr_mode (insn) == MODE_SI)
11086             return "sal{l}\t{%b2, %k0|%k0, %b2}";
11087           else
11088             return "sal{b}\t{%b2, %0|%0, %b2}";
11089         }
11090       else if (GET_CODE (operands[2]) == CONST_INT
11091                && INTVAL (operands[2]) == 1
11092                && (TARGET_PENTIUM || TARGET_PENTIUMPRO))
11093         {
11094           if (get_attr_mode (insn) == MODE_SI)
11095             return "sal{l}\t%0";
11096           else
11097             return "sal{b}\t%0";
11098         }
11099       else
11100         {
11101           if (get_attr_mode (insn) == MODE_SI)
11102             return "sal{l}\t{%2, %k0|%k0, %2}";
11103           else
11104             return "sal{b}\t{%2, %0|%0, %2}";
11105         }
11106     }
11107 }
11108   [(set (attr "type")
11109      (cond [(and (and (ne (symbol_ref "TARGET_DOUBLE_WITH_ADD")
11110                           (const_int 0))
11111                       (match_operand 0 "register_operand" ""))
11112                  (match_operand 2 "const1_operand" ""))
11113               (const_string "alu")
11114            ]
11115            (const_string "ishift")))
11116    (set_attr "mode" "QI,SI")])
11117
11118 ;; This pattern can't accept a variable shift count, since shifts by
11119 ;; zero don't affect the flags.  We assume that shifts by constant
11120 ;; zero are optimized away.
11121 (define_insn "*ashlqi3_cmp"
11122   [(set (reg 17)
11123         (compare
11124           (ashift:QI (match_operand:QI 1 "nonimmediate_operand" "0")
11125                      (match_operand:QI 2 "immediate_operand" "I"))
11126           (const_int 0)))
11127    (set (match_operand:QI 0 "nonimmediate_operand" "=qm")
11128         (ashift:QI (match_dup 1) (match_dup 2)))]
11129   "ix86_match_ccmode (insn, CCGOCmode)
11130    && ix86_binary_operator_ok (ASHIFT, QImode, operands)"
11131 {
11132   switch (get_attr_type (insn))
11133     {
11134     case TYPE_ALU:
11135       if (operands[2] != const1_rtx)
11136         abort ();
11137       return "add{b}\t{%0, %0|%0, %0}";
11138
11139     default:
11140       if (REG_P (operands[2]))
11141         return "sal{b}\t{%b2, %0|%0, %b2}";
11142       else if (GET_CODE (operands[2]) == CONST_INT
11143                && INTVAL (operands[2]) == 1
11144                && (TARGET_PENTIUM || TARGET_PENTIUMPRO))
11145         return "sal{b}\t%0";
11146       else
11147         return "sal{b}\t{%2, %0|%0, %2}";
11148     }
11149 }
11150   [(set (attr "type")
11151      (cond [(and (and (ne (symbol_ref "TARGET_DOUBLE_WITH_ADD")
11152                           (const_int 0))
11153                       (match_operand 0 "register_operand" ""))
11154                  (match_operand 2 "const1_operand" ""))
11155               (const_string "alu")
11156            ]
11157            (const_string "ishift")))
11158    (set_attr "mode" "QI")])
11159
11160 ;; See comment above `ashldi3' about how this works.
11161
11162 (define_expand "ashrdi3"
11163   [(parallel [(set (match_operand:DI 0 "shiftdi_operand" "")
11164                    (ashiftrt:DI (match_operand:DI 1 "shiftdi_operand" "")
11165                                 (match_operand:QI 2 "nonmemory_operand" "")))
11166               (clobber (reg:CC 17))])]
11167   ""
11168 {
11169   if (!TARGET_64BIT && TARGET_CMOVE && ! immediate_operand (operands[2], QImode))
11170     {
11171       emit_insn (gen_ashrdi3_1 (operands[0], operands[1], operands[2]));
11172       DONE;
11173     }
11174   ix86_expand_binary_operator (ASHIFTRT, DImode, operands);
11175   DONE;
11176 })
11177
11178 (define_insn "ashrdi3_63_rex64"
11179   [(set (match_operand:DI 0 "nonimmediate_operand" "=*d,rm")
11180         (ashiftrt:DI (match_operand:DI 1 "nonimmediate_operand" "*a,0")
11181                      (match_operand:DI 2 "const_int_operand" "i,i")))
11182    (clobber (reg:CC 17))]
11183   "TARGET_64BIT && INTVAL (operands[2]) == 63 && (TARGET_USE_CLTD || optimize_size)
11184    && ix86_binary_operator_ok (ASHIFTRT, DImode, operands)"
11185   "@
11186    {cqto|cqo}
11187    sar{q}\t{%2, %0|%0, %2}"
11188   [(set_attr "type" "imovx,ishift")
11189    (set_attr "prefix_0f" "0,*")
11190    (set_attr "length_immediate" "0,*")
11191    (set_attr "modrm" "0,1")
11192    (set_attr "mode" "DI")])
11193
11194 (define_insn "*ashrdi3_1_one_bit_rex64"
11195   [(set (match_operand:DI 0 "nonimmediate_operand" "=rm")
11196         (ashiftrt:DI (match_operand:DI 1 "nonimmediate_operand" "0")
11197                      (match_operand:QI 2 "const_int_1_operand" "")))
11198    (clobber (reg:CC 17))]
11199   "TARGET_64BIT && ix86_binary_operator_ok (ASHIFTRT, DImode, operands)
11200    && (TARGET_PENTIUM || TARGET_PENTIUMPRO)"
11201   "sar{q}\t%0"
11202   [(set_attr "type" "ishift")
11203    (set (attr "length") 
11204      (if_then_else (match_operand:DI 0 "register_operand" "") 
11205         (const_string "2")
11206         (const_string "*")))])
11207
11208 (define_insn "*ashrdi3_1_rex64"
11209   [(set (match_operand:DI 0 "nonimmediate_operand" "=rm,rm")
11210         (ashiftrt:DI (match_operand:DI 1 "nonimmediate_operand" "0,0")
11211                      (match_operand:QI 2 "nonmemory_operand" "J,c")))
11212    (clobber (reg:CC 17))]
11213   "TARGET_64BIT && ix86_binary_operator_ok (ASHIFTRT, DImode, operands)"
11214   "@
11215    sar{q}\t{%2, %0|%0, %2}
11216    sar{q}\t{%b2, %0|%0, %b2}"
11217   [(set_attr "type" "ishift")
11218    (set_attr "mode" "DI")])
11219
11220 ;; This pattern can't accept a variable shift count, since shifts by
11221 ;; zero don't affect the flags.  We assume that shifts by constant
11222 ;; zero are optimized away.
11223 (define_insn "*ashrdi3_one_bit_cmp_rex64"
11224   [(set (reg 17)
11225         (compare
11226           (ashiftrt:DI (match_operand:DI 1 "nonimmediate_operand" "0")
11227                        (match_operand:QI 2 "const_int_1_operand" ""))
11228           (const_int 0)))
11229    (set (match_operand:DI 0 "nonimmediate_operand" "=rm")
11230         (ashiftrt:DI (match_dup 1) (match_dup 2)))]
11231   "TARGET_64BIT && ix86_match_ccmode (insn, CCGOCmode)
11232    && (TARGET_PENTIUM || TARGET_PENTIUMPRO)
11233    && ix86_binary_operator_ok (ASHIFTRT, DImode, operands)"
11234   "sar{q}\t%0"
11235   [(set_attr "type" "ishift")
11236    (set (attr "length") 
11237      (if_then_else (match_operand:DI 0 "register_operand" "") 
11238         (const_string "2")
11239         (const_string "*")))])
11240
11241 ;; This pattern can't accept a variable shift count, since shifts by
11242 ;; zero don't affect the flags.  We assume that shifts by constant
11243 ;; zero are optimized away.
11244 (define_insn "*ashrdi3_cmp_rex64"
11245   [(set (reg 17)
11246         (compare
11247           (ashiftrt:DI (match_operand:DI 1 "nonimmediate_operand" "0")
11248                        (match_operand:QI 2 "const_int_operand" "n"))
11249           (const_int 0)))
11250    (set (match_operand:DI 0 "nonimmediate_operand" "=rm")
11251         (ashiftrt:DI (match_dup 1) (match_dup 2)))]
11252   "TARGET_64BIT && ix86_match_ccmode (insn, CCGOCmode)
11253    && ix86_binary_operator_ok (ASHIFTRT, DImode, operands)"
11254   "sar{q}\t{%2, %0|%0, %2}"
11255   [(set_attr "type" "ishift")
11256    (set_attr "mode" "DI")])
11257
11258
11259 (define_insn "ashrdi3_1"
11260   [(set (match_operand:DI 0 "register_operand" "=r")
11261         (ashiftrt:DI (match_operand:DI 1 "register_operand" "0")
11262                      (match_operand:QI 2 "nonmemory_operand" "Jc")))
11263    (clobber (match_scratch:SI 3 "=&r"))
11264    (clobber (reg:CC 17))]
11265   "!TARGET_64BIT && TARGET_CMOVE"
11266   "#"
11267   [(set_attr "type" "multi")])
11268
11269 (define_insn "*ashrdi3_2"
11270   [(set (match_operand:DI 0 "register_operand" "=r")
11271         (ashiftrt:DI (match_operand:DI 1 "register_operand" "0")
11272                      (match_operand:QI 2 "nonmemory_operand" "Jc")))
11273    (clobber (reg:CC 17))]
11274   "!TARGET_64BIT"
11275   "#"
11276   [(set_attr "type" "multi")])
11277
11278 (define_split
11279   [(set (match_operand:DI 0 "register_operand" "")
11280         (ashiftrt:DI (match_operand:DI 1 "register_operand" "")
11281                      (match_operand:QI 2 "nonmemory_operand" "")))
11282    (clobber (match_scratch:SI 3 ""))
11283    (clobber (reg:CC 17))]
11284   "!TARGET_64BIT && TARGET_CMOVE && reload_completed"
11285   [(const_int 0)]
11286   "ix86_split_ashrdi (operands, operands[3]); DONE;")
11287
11288 (define_split
11289   [(set (match_operand:DI 0 "register_operand" "")
11290         (ashiftrt:DI (match_operand:DI 1 "register_operand" "")
11291                      (match_operand:QI 2 "nonmemory_operand" "")))
11292    (clobber (reg:CC 17))]
11293   "!TARGET_64BIT && reload_completed"
11294   [(const_int 0)]
11295   "ix86_split_ashrdi (operands, NULL_RTX); DONE;")
11296
11297 (define_insn "x86_shrd_1"
11298   [(set (match_operand:SI 0 "nonimmediate_operand" "+r*m,r*m")
11299         (ior:SI (ashiftrt:SI (match_dup 0)
11300                   (match_operand:QI 2 "nonmemory_operand" "I,c"))
11301                 (ashift:SI (match_operand:SI 1 "register_operand" "r,r")
11302                   (minus:QI (const_int 32) (match_dup 2)))))
11303    (clobber (reg:CC 17))]
11304   ""
11305   "@
11306    shrd{l}\t{%2, %1, %0|%0, %1, %2}
11307    shrd{l}\t{%s2%1, %0|%0, %1, %2}"
11308   [(set_attr "type" "ishift")
11309    (set_attr "prefix_0f" "1")
11310    (set_attr "pent_pair" "np")
11311    (set_attr "ppro_uops" "few")
11312    (set_attr "mode" "SI")])
11313
11314 (define_expand "x86_shift_adj_3"
11315   [(use (match_operand:SI 0 "register_operand" ""))
11316    (use (match_operand:SI 1 "register_operand" ""))
11317    (use (match_operand:QI 2 "register_operand" ""))]
11318   ""
11319 {
11320   rtx label = gen_label_rtx ();
11321   rtx tmp;
11322
11323   emit_insn (gen_testqi_ccz_1 (operands[2], GEN_INT (32)));
11324
11325   tmp = gen_rtx_REG (CCZmode, FLAGS_REG);
11326   tmp = gen_rtx_EQ (VOIDmode, tmp, const0_rtx);
11327   tmp = gen_rtx_IF_THEN_ELSE (VOIDmode, tmp,
11328                               gen_rtx_LABEL_REF (VOIDmode, label),
11329                               pc_rtx);
11330   tmp = emit_jump_insn (gen_rtx_SET (VOIDmode, pc_rtx, tmp));
11331   JUMP_LABEL (tmp) = label;
11332
11333   emit_move_insn (operands[0], operands[1]);
11334   emit_insn (gen_ashrsi3_31 (operands[1], operands[1], GEN_INT (31)));
11335
11336   emit_label (label);
11337   LABEL_NUSES (label) = 1;
11338
11339   DONE;
11340 })
11341
11342 (define_insn "ashrsi3_31"
11343   [(set (match_operand:SI 0 "nonimmediate_operand" "=*d,rm")
11344         (ashiftrt:SI (match_operand:SI 1 "nonimmediate_operand" "*a,0")
11345                      (match_operand:SI 2 "const_int_operand" "i,i")))
11346    (clobber (reg:CC 17))]
11347   "INTVAL (operands[2]) == 31 && (TARGET_USE_CLTD || optimize_size)
11348    && ix86_binary_operator_ok (ASHIFTRT, SImode, operands)"
11349   "@
11350    {cltd|cdq}
11351    sar{l}\t{%2, %0|%0, %2}"
11352   [(set_attr "type" "imovx,ishift")
11353    (set_attr "prefix_0f" "0,*")
11354    (set_attr "length_immediate" "0,*")
11355    (set_attr "modrm" "0,1")
11356    (set_attr "mode" "SI")])
11357
11358 (define_insn "*ashrsi3_31_zext"
11359   [(set (match_operand:DI 0 "register_operand" "=*d,r")
11360         (zero_extend:DI (ashiftrt:SI (match_operand:SI 1 "register_operand" "*a,0")
11361                                      (match_operand:SI 2 "const_int_operand" "i,i"))))
11362    (clobber (reg:CC 17))]
11363   "TARGET_64BIT && (TARGET_USE_CLTD || optimize_size)
11364    && INTVAL (operands[2]) == 31
11365    && ix86_binary_operator_ok (ASHIFTRT, SImode, operands)"
11366   "@
11367    {cltd|cdq}
11368    sar{l}\t{%2, %k0|%k0, %2}"
11369   [(set_attr "type" "imovx,ishift")
11370    (set_attr "prefix_0f" "0,*")
11371    (set_attr "length_immediate" "0,*")
11372    (set_attr "modrm" "0,1")
11373    (set_attr "mode" "SI")])
11374
11375 (define_expand "ashrsi3"
11376   [(set (match_operand:SI 0 "nonimmediate_operand" "")
11377         (ashiftrt:SI (match_operand:SI 1 "nonimmediate_operand" "")
11378                      (match_operand:QI 2 "nonmemory_operand" "")))
11379    (clobber (reg:CC 17))]
11380   ""
11381   "ix86_expand_binary_operator (ASHIFTRT, SImode, operands); DONE;")
11382
11383 (define_insn "*ashrsi3_1_one_bit"
11384   [(set (match_operand:SI 0 "nonimmediate_operand" "=rm")
11385         (ashiftrt:SI (match_operand:SI 1 "nonimmediate_operand" "0")
11386                      (match_operand:QI 2 "const_int_1_operand" "")))
11387    (clobber (reg:CC 17))]
11388   "ix86_binary_operator_ok (ASHIFTRT, SImode, operands)
11389    && (TARGET_PENTIUM || TARGET_PENTIUMPRO)"
11390   "sar{l}\t%0"
11391   [(set_attr "type" "ishift")
11392    (set (attr "length") 
11393      (if_then_else (match_operand:SI 0 "register_operand" "") 
11394         (const_string "2")
11395         (const_string "*")))])
11396
11397 (define_insn "*ashrsi3_1_one_bit_zext"
11398   [(set (match_operand:DI 0 "register_operand" "=r")
11399         (zero_extend:DI (ashiftrt:SI (match_operand:SI 1 "register_operand" "0")
11400                                      (match_operand:QI 2 "const_int_1_operand" ""))))
11401    (clobber (reg:CC 17))]
11402   "TARGET_64BIT && ix86_binary_operator_ok (ASHIFTRT, SImode, operands)
11403    && (TARGET_PENTIUM || TARGET_PENTIUMPRO)"
11404   "sar{l}\t%k0"
11405   [(set_attr "type" "ishift")
11406    (set_attr "length" "2")])
11407
11408 (define_insn "*ashrsi3_1"
11409   [(set (match_operand:SI 0 "nonimmediate_operand" "=rm,rm")
11410         (ashiftrt:SI (match_operand:SI 1 "nonimmediate_operand" "0,0")
11411                      (match_operand:QI 2 "nonmemory_operand" "I,c")))
11412    (clobber (reg:CC 17))]
11413   "ix86_binary_operator_ok (ASHIFTRT, SImode, operands)"
11414   "@
11415    sar{l}\t{%2, %0|%0, %2}
11416    sar{l}\t{%b2, %0|%0, %b2}"
11417   [(set_attr "type" "ishift")
11418    (set_attr "mode" "SI")])
11419
11420 (define_insn "*ashrsi3_1_zext"
11421   [(set (match_operand:DI 0 "register_operand" "=r,r")
11422         (zero_extend:DI (ashiftrt:SI (match_operand:SI 1 "register_operand" "0,0")
11423                                      (match_operand:QI 2 "nonmemory_operand" "I,c"))))
11424    (clobber (reg:CC 17))]
11425   "TARGET_64BIT && ix86_binary_operator_ok (ASHIFTRT, SImode, operands)"
11426   "@
11427    sar{l}\t{%2, %k0|%k0, %2}
11428    sar{l}\t{%b2, %k0|%k0, %b2}"
11429   [(set_attr "type" "ishift")
11430    (set_attr "mode" "SI")])
11431
11432 ;; This pattern can't accept a variable shift count, since shifts by
11433 ;; zero don't affect the flags.  We assume that shifts by constant
11434 ;; zero are optimized away.
11435 (define_insn "*ashrsi3_one_bit_cmp"
11436   [(set (reg 17)
11437         (compare
11438           (ashiftrt:SI (match_operand:SI 1 "nonimmediate_operand" "0")
11439                        (match_operand:QI 2 "const_int_1_operand" ""))
11440           (const_int 0)))
11441    (set (match_operand:SI 0 "nonimmediate_operand" "=rm")
11442         (ashiftrt:SI (match_dup 1) (match_dup 2)))]
11443   "ix86_match_ccmode (insn, CCGOCmode)
11444    && (TARGET_PENTIUM || TARGET_PENTIUMPRO)
11445    && ix86_binary_operator_ok (ASHIFTRT, SImode, operands)"
11446   "sar{l}\t%0"
11447   [(set_attr "type" "ishift")
11448    (set (attr "length") 
11449      (if_then_else (match_operand:SI 0 "register_operand" "") 
11450         (const_string "2")
11451         (const_string "*")))])
11452
11453 (define_insn "*ashrsi3_one_bit_cmp_zext"
11454   [(set (reg 17)
11455         (compare
11456           (ashiftrt:SI (match_operand:SI 1 "register_operand" "0")
11457                        (match_operand:QI 2 "const_int_1_operand" ""))
11458           (const_int 0)))
11459    (set (match_operand:DI 0 "register_operand" "=r")
11460         (zero_extend:DI (ashiftrt:SI (match_dup 1) (match_dup 2))))]
11461   "TARGET_64BIT && ix86_match_ccmode (insn, CCmode)
11462    && (TARGET_PENTIUM || TARGET_PENTIUMPRO)
11463    && ix86_binary_operator_ok (ASHIFTRT, SImode, operands)"
11464   "sar{l}\t%k0"
11465   [(set_attr "type" "ishift")
11466    (set_attr "length" "2")])
11467
11468 ;; This pattern can't accept a variable shift count, since shifts by
11469 ;; zero don't affect the flags.  We assume that shifts by constant
11470 ;; zero are optimized away.
11471 (define_insn "*ashrsi3_cmp"
11472   [(set (reg 17)
11473         (compare
11474           (ashiftrt:SI (match_operand:SI 1 "nonimmediate_operand" "0")
11475                        (match_operand:QI 2 "immediate_operand" "I"))
11476           (const_int 0)))
11477    (set (match_operand:SI 0 "nonimmediate_operand" "=rm")
11478         (ashiftrt:SI (match_dup 1) (match_dup 2)))]
11479   "ix86_match_ccmode (insn, CCGOCmode)
11480    && ix86_binary_operator_ok (ASHIFTRT, SImode, operands)"
11481   "sar{l}\t{%2, %0|%0, %2}"
11482   [(set_attr "type" "ishift")
11483    (set_attr "mode" "SI")])
11484
11485 (define_insn "*ashrsi3_cmp_zext"
11486   [(set (reg 17)
11487         (compare
11488           (ashiftrt:SI (match_operand:SI 1 "register_operand" "0")
11489                        (match_operand:QI 2 "immediate_operand" "I"))
11490           (const_int 0)))
11491    (set (match_operand:DI 0 "register_operand" "=r")
11492         (zero_extend:DI (ashiftrt:SI (match_dup 1) (match_dup 2))))]
11493   "TARGET_64BIT && ix86_match_ccmode (insn, CCGOCmode)
11494    && ix86_binary_operator_ok (ASHIFTRT, SImode, operands)"
11495   "sar{l}\t{%2, %k0|%k0, %2}"
11496   [(set_attr "type" "ishift")
11497    (set_attr "mode" "SI")])
11498
11499 (define_expand "ashrhi3"
11500   [(set (match_operand:HI 0 "nonimmediate_operand" "")
11501         (ashiftrt:HI (match_operand:HI 1 "nonimmediate_operand" "")
11502                      (match_operand:QI 2 "nonmemory_operand" "")))
11503    (clobber (reg:CC 17))]
11504   "TARGET_HIMODE_MATH"
11505   "ix86_expand_binary_operator (ASHIFTRT, HImode, operands); DONE;")
11506
11507 (define_insn "*ashrhi3_1_one_bit"
11508   [(set (match_operand:HI 0 "nonimmediate_operand" "=rm")
11509         (ashiftrt:HI (match_operand:HI 1 "nonimmediate_operand" "0")
11510                      (match_operand:QI 2 "const_int_1_operand" "")))
11511    (clobber (reg:CC 17))]
11512   "ix86_binary_operator_ok (ASHIFTRT, HImode, operands)
11513    && (TARGET_PENTIUM || TARGET_PENTIUMPRO)"
11514   "sar{w}\t%0"
11515   [(set_attr "type" "ishift")
11516    (set (attr "length") 
11517      (if_then_else (match_operand 0 "register_operand" "") 
11518         (const_string "2")
11519         (const_string "*")))])
11520
11521 (define_insn "*ashrhi3_1"
11522   [(set (match_operand:HI 0 "nonimmediate_operand" "=rm,rm")
11523         (ashiftrt:HI (match_operand:HI 1 "nonimmediate_operand" "0,0")
11524                      (match_operand:QI 2 "nonmemory_operand" "I,c")))
11525    (clobber (reg:CC 17))]
11526   "ix86_binary_operator_ok (ASHIFTRT, HImode, operands)"
11527   "@
11528    sar{w}\t{%2, %0|%0, %2}
11529    sar{w}\t{%b2, %0|%0, %b2}"
11530   [(set_attr "type" "ishift")
11531    (set_attr "mode" "HI")])
11532
11533 ;; This pattern can't accept a variable shift count, since shifts by
11534 ;; zero don't affect the flags.  We assume that shifts by constant
11535 ;; zero are optimized away.
11536 (define_insn "*ashrhi3_one_bit_cmp"
11537   [(set (reg 17)
11538         (compare
11539           (ashiftrt:HI (match_operand:HI 1 "nonimmediate_operand" "0")
11540                        (match_operand:QI 2 "const_int_1_operand" ""))
11541           (const_int 0)))
11542    (set (match_operand:HI 0 "nonimmediate_operand" "=rm")
11543         (ashiftrt:HI (match_dup 1) (match_dup 2)))]
11544   "ix86_match_ccmode (insn, CCGOCmode)
11545    && (TARGET_PENTIUM || TARGET_PENTIUMPRO)
11546    && ix86_binary_operator_ok (ASHIFTRT, HImode, operands)"
11547   "sar{w}\t%0"
11548   [(set_attr "type" "ishift")
11549    (set (attr "length") 
11550      (if_then_else (match_operand 0 "register_operand" "") 
11551         (const_string "2")
11552         (const_string "*")))])
11553
11554 ;; This pattern can't accept a variable shift count, since shifts by
11555 ;; zero don't affect the flags.  We assume that shifts by constant
11556 ;; zero are optimized away.
11557 (define_insn "*ashrhi3_cmp"
11558   [(set (reg 17)
11559         (compare
11560           (ashiftrt:HI (match_operand:HI 1 "nonimmediate_operand" "0")
11561                        (match_operand:QI 2 "immediate_operand" "I"))
11562           (const_int 0)))
11563    (set (match_operand:HI 0 "nonimmediate_operand" "=rm")
11564         (ashiftrt:HI (match_dup 1) (match_dup 2)))]
11565   "ix86_match_ccmode (insn, CCGOCmode)
11566    && ix86_binary_operator_ok (ASHIFTRT, HImode, operands)"
11567   "sar{w}\t{%2, %0|%0, %2}"
11568   [(set_attr "type" "ishift")
11569    (set_attr "mode" "HI")])
11570
11571 (define_expand "ashrqi3"
11572   [(set (match_operand:QI 0 "nonimmediate_operand" "")
11573         (ashiftrt:QI (match_operand:QI 1 "nonimmediate_operand" "")
11574                      (match_operand:QI 2 "nonmemory_operand" "")))
11575    (clobber (reg:CC 17))]
11576   "TARGET_QIMODE_MATH"
11577   "ix86_expand_binary_operator (ASHIFTRT, QImode, operands); DONE;")
11578
11579 (define_insn "*ashrqi3_1_one_bit"
11580   [(set (match_operand:QI 0 "nonimmediate_operand" "=qm")
11581         (ashiftrt:QI (match_operand:QI 1 "nonimmediate_operand" "0")
11582                      (match_operand:QI 2 "const_int_1_operand" "")))
11583    (clobber (reg:CC 17))]
11584   "ix86_binary_operator_ok (ASHIFTRT, QImode, operands)
11585    && (TARGET_PENTIUM || TARGET_PENTIUMPRO)"
11586   "sar{b}\t%0"
11587   [(set_attr "type" "ishift")
11588    (set (attr "length") 
11589      (if_then_else (match_operand 0 "register_operand" "") 
11590         (const_string "2")
11591         (const_string "*")))])
11592
11593 (define_insn "*ashrqi3_1"
11594   [(set (match_operand:QI 0 "nonimmediate_operand" "=qm,qm")
11595         (ashiftrt:QI (match_operand:QI 1 "nonimmediate_operand" "0,0")
11596                      (match_operand:QI 2 "nonmemory_operand" "I,c")))
11597    (clobber (reg:CC 17))]
11598   "ix86_binary_operator_ok (ASHIFTRT, QImode, operands)"
11599   "@
11600    sar{b}\t{%2, %0|%0, %2}
11601    sar{b}\t{%b2, %0|%0, %b2}"
11602   [(set_attr "type" "ishift")
11603    (set_attr "mode" "QI")])
11604
11605 ;; This pattern can't accept a variable shift count, since shifts by
11606 ;; zero don't affect the flags.  We assume that shifts by constant
11607 ;; zero are optimized away.
11608 (define_insn "*ashrqi3_one_bit_cmp"
11609   [(set (reg 17)
11610         (compare
11611           (ashiftrt:QI (match_operand:QI 1 "nonimmediate_operand" "0")
11612                        (match_operand:QI 2 "const_int_1_operand" "I"))
11613           (const_int 0)))
11614    (set (match_operand:QI 0 "nonimmediate_operand" "=rm")
11615         (ashiftrt:QI (match_dup 1) (match_dup 2)))]
11616   "ix86_match_ccmode (insn, CCGOCmode)
11617    && (TARGET_PENTIUM || TARGET_PENTIUMPRO)
11618    && ix86_binary_operator_ok (ASHIFTRT, QImode, operands)"
11619   "sar{b}\t%0"
11620   [(set_attr "type" "ishift")
11621    (set (attr "length") 
11622      (if_then_else (match_operand 0 "register_operand" "") 
11623         (const_string "2")
11624         (const_string "*")))])
11625
11626 ;; This pattern can't accept a variable shift count, since shifts by
11627 ;; zero don't affect the flags.  We assume that shifts by constant
11628 ;; zero are optimized away.
11629 (define_insn "*ashrqi3_cmp"
11630   [(set (reg 17)
11631         (compare
11632           (ashiftrt:QI (match_operand:QI 1 "nonimmediate_operand" "0")
11633                        (match_operand:QI 2 "immediate_operand" "I"))
11634           (const_int 0)))
11635    (set (match_operand:QI 0 "nonimmediate_operand" "=rm")
11636         (ashiftrt:QI (match_dup 1) (match_dup 2)))]
11637   "ix86_match_ccmode (insn, CCGOCmode)
11638    && ix86_binary_operator_ok (ASHIFTRT, QImode, operands)"
11639   "sar{b}\t{%2, %0|%0, %2}"
11640   [(set_attr "type" "ishift")
11641    (set_attr "mode" "QI")])
11642 \f
11643 ;; Logical shift instructions
11644
11645 ;; See comment above `ashldi3' about how this works.
11646
11647 (define_expand "lshrdi3"
11648   [(parallel [(set (match_operand:DI 0 "shiftdi_operand" "")
11649                    (lshiftrt:DI (match_operand:DI 1 "shiftdi_operand" "")
11650                                 (match_operand:QI 2 "nonmemory_operand" "")))
11651               (clobber (reg:CC 17))])]
11652   ""
11653 {
11654   if (!TARGET_64BIT && TARGET_CMOVE && ! immediate_operand (operands[2], QImode))
11655     {
11656       emit_insn (gen_lshrdi3_1 (operands[0], operands[1], operands[2]));
11657       DONE;
11658     }
11659   ix86_expand_binary_operator (LSHIFTRT, DImode, operands);
11660   DONE;
11661 })
11662
11663 (define_insn "*lshrdi3_1_one_bit_rex64"
11664   [(set (match_operand:DI 0 "nonimmediate_operand" "=rm")
11665         (lshiftrt:DI (match_operand:DI 1 "nonimmediate_operand" "0")
11666                      (match_operand:QI 2 "const_int_1_operand" "")))
11667    (clobber (reg:CC 17))]
11668   "TARGET_64BIT && ix86_binary_operator_ok (LSHIFTRT, HImode, operands)
11669    && (TARGET_PENTIUM || TARGET_PENTIUMPRO)"
11670   "shr{q}\t%0"
11671   [(set_attr "type" "ishift")
11672    (set (attr "length") 
11673      (if_then_else (match_operand:DI 0 "register_operand" "") 
11674         (const_string "2")
11675         (const_string "*")))])
11676
11677 (define_insn "*lshrdi3_1_rex64"
11678   [(set (match_operand:DI 0 "nonimmediate_operand" "=rm,rm")
11679         (lshiftrt:DI (match_operand:DI 1 "nonimmediate_operand" "0,0")
11680                      (match_operand:QI 2 "nonmemory_operand" "J,c")))
11681    (clobber (reg:CC 17))]
11682   "TARGET_64BIT && ix86_binary_operator_ok (LSHIFTRT, HImode, operands)"
11683   "@
11684    shr{q}\t{%2, %0|%0, %2}
11685    shr{q}\t{%b2, %0|%0, %b2}"
11686   [(set_attr "type" "ishift")
11687    (set_attr "mode" "DI")])
11688
11689 ;; This pattern can't accept a variable shift count, since shifts by
11690 ;; zero don't affect the flags.  We assume that shifts by constant
11691 ;; zero are optimized away.
11692 (define_insn "*lshrdi3_cmp_one_bit_rex64"
11693   [(set (reg 17)
11694         (compare
11695           (lshiftrt:DI (match_operand:DI 1 "nonimmediate_operand" "0")
11696                        (match_operand:QI 2 "const_int_1_operand" ""))
11697           (const_int 0)))
11698    (set (match_operand:DI 0 "nonimmediate_operand" "=rm")
11699         (lshiftrt:DI (match_dup 1) (match_dup 2)))]
11700   "TARGET_64BIT && ix86_match_ccmode (insn, CCGOCmode)
11701    && (TARGET_PENTIUM || TARGET_PENTIUMPRO)
11702    && ix86_binary_operator_ok (LSHIFTRT, HImode, operands)"
11703   "shr{q}\t%0"
11704   [(set_attr "type" "ishift")
11705    (set (attr "length") 
11706      (if_then_else (match_operand:DI 0 "register_operand" "") 
11707         (const_string "2")
11708         (const_string "*")))])
11709
11710 ;; This pattern can't accept a variable shift count, since shifts by
11711 ;; zero don't affect the flags.  We assume that shifts by constant
11712 ;; zero are optimized away.
11713 (define_insn "*lshrdi3_cmp_rex64"
11714   [(set (reg 17)
11715         (compare
11716           (lshiftrt:DI (match_operand:DI 1 "nonimmediate_operand" "0")
11717                        (match_operand:QI 2 "const_int_operand" "e"))
11718           (const_int 0)))
11719    (set (match_operand:DI 0 "nonimmediate_operand" "=rm")
11720         (lshiftrt:DI (match_dup 1) (match_dup 2)))]
11721   "TARGET_64BIT && ix86_match_ccmode (insn, CCGOCmode)
11722    && ix86_binary_operator_ok (LSHIFTRT, HImode, operands)"
11723   "shr{q}\t{%2, %0|%0, %2}"
11724   [(set_attr "type" "ishift")
11725    (set_attr "mode" "DI")])
11726
11727 (define_insn "lshrdi3_1"
11728   [(set (match_operand:DI 0 "register_operand" "=r")
11729         (lshiftrt:DI (match_operand:DI 1 "register_operand" "0")
11730                      (match_operand:QI 2 "nonmemory_operand" "Jc")))
11731    (clobber (match_scratch:SI 3 "=&r"))
11732    (clobber (reg:CC 17))]
11733   "!TARGET_64BIT && TARGET_CMOVE"
11734   "#"
11735   [(set_attr "type" "multi")])
11736
11737 (define_insn "*lshrdi3_2"
11738   [(set (match_operand:DI 0 "register_operand" "=r")
11739         (lshiftrt:DI (match_operand:DI 1 "register_operand" "0")
11740                      (match_operand:QI 2 "nonmemory_operand" "Jc")))
11741    (clobber (reg:CC 17))]
11742   "!TARGET_64BIT"
11743   "#"
11744   [(set_attr "type" "multi")])
11745
11746 (define_split 
11747   [(set (match_operand:DI 0 "register_operand" "")
11748         (lshiftrt:DI (match_operand:DI 1 "register_operand" "")
11749                      (match_operand:QI 2 "nonmemory_operand" "")))
11750    (clobber (match_scratch:SI 3 ""))
11751    (clobber (reg:CC 17))]
11752   "!TARGET_64BIT && TARGET_CMOVE && reload_completed"
11753   [(const_int 0)]
11754   "ix86_split_lshrdi (operands, operands[3]); DONE;")
11755
11756 (define_split 
11757   [(set (match_operand:DI 0 "register_operand" "")
11758         (lshiftrt:DI (match_operand:DI 1 "register_operand" "")
11759                      (match_operand:QI 2 "nonmemory_operand" "")))
11760    (clobber (reg:CC 17))]
11761   "!TARGET_64BIT && reload_completed"
11762   [(const_int 0)]
11763   "ix86_split_lshrdi (operands, NULL_RTX); DONE;")
11764
11765 (define_expand "lshrsi3"
11766   [(set (match_operand:SI 0 "nonimmediate_operand" "")
11767         (lshiftrt:SI (match_operand:SI 1 "nonimmediate_operand" "")
11768                      (match_operand:QI 2 "nonmemory_operand" "")))
11769    (clobber (reg:CC 17))]
11770   ""
11771   "ix86_expand_binary_operator (LSHIFTRT, SImode, operands); DONE;")
11772
11773 (define_insn "*lshrsi3_1_one_bit"
11774   [(set (match_operand:SI 0 "nonimmediate_operand" "=rm")
11775         (lshiftrt:SI (match_operand:SI 1 "nonimmediate_operand" "0")
11776                      (match_operand:QI 2 "const_int_1_operand" "")))
11777    (clobber (reg:CC 17))]
11778   "ix86_binary_operator_ok (LSHIFTRT, HImode, operands)
11779    && (TARGET_PENTIUM || TARGET_PENTIUMPRO)"
11780   "shr{l}\t%0"
11781   [(set_attr "type" "ishift")
11782    (set (attr "length") 
11783      (if_then_else (match_operand:SI 0 "register_operand" "") 
11784         (const_string "2")
11785         (const_string "*")))])
11786
11787 (define_insn "*lshrsi3_1_one_bit_zext"
11788   [(set (match_operand:DI 0 "register_operand" "=r")
11789         (lshiftrt:DI (zero_extend:DI (match_operand:SI 1 "register_operand" "0"))
11790                      (match_operand:QI 2 "const_int_1_operand" "")))
11791    (clobber (reg:CC 17))]
11792   "TARGET_64BIT && ix86_binary_operator_ok (LSHIFTRT, HImode, operands)
11793    && (TARGET_PENTIUM || TARGET_PENTIUMPRO)"
11794   "shr{l}\t%k0"
11795   [(set_attr "type" "ishift")
11796    (set_attr "length" "2")])
11797
11798 (define_insn "*lshrsi3_1"
11799   [(set (match_operand:SI 0 "nonimmediate_operand" "=rm,rm")
11800         (lshiftrt:SI (match_operand:SI 1 "nonimmediate_operand" "0,0")
11801                      (match_operand:QI 2 "nonmemory_operand" "I,c")))
11802    (clobber (reg:CC 17))]
11803   "ix86_binary_operator_ok (LSHIFTRT, HImode, operands)"
11804   "@
11805    shr{l}\t{%2, %0|%0, %2}
11806    shr{l}\t{%b2, %0|%0, %b2}"
11807   [(set_attr "type" "ishift")
11808    (set_attr "mode" "SI")])
11809
11810 (define_insn "*lshrsi3_1_zext"
11811   [(set (match_operand:DI 0 "register_operand" "=r,r")
11812         (zero_extend:DI
11813           (lshiftrt:SI (match_operand:SI 1 "nonimmediate_operand" "0,0")
11814                        (match_operand:QI 2 "nonmemory_operand" "I,c"))))
11815    (clobber (reg:CC 17))]
11816   "TARGET_64BIT && ix86_binary_operator_ok (LSHIFTRT, HImode, operands)"
11817   "@
11818    shr{l}\t{%2, %k0|%k0, %2}
11819    shr{l}\t{%b2, %k0|%k0, %b2}"
11820   [(set_attr "type" "ishift")
11821    (set_attr "mode" "SI")])
11822
11823 ;; This pattern can't accept a variable shift count, since shifts by
11824 ;; zero don't affect the flags.  We assume that shifts by constant
11825 ;; zero are optimized away.
11826 (define_insn "*lshrsi3_one_bit_cmp"
11827   [(set (reg 17)
11828         (compare
11829           (lshiftrt:SI (match_operand:SI 1 "nonimmediate_operand" "0")
11830                        (match_operand:QI 2 "const_int_1_operand" ""))
11831           (const_int 0)))
11832    (set (match_operand:SI 0 "nonimmediate_operand" "=rm")
11833         (lshiftrt:SI (match_dup 1) (match_dup 2)))]
11834   "ix86_match_ccmode (insn, CCGOCmode)
11835    && (TARGET_PENTIUM || TARGET_PENTIUMPRO)
11836    && ix86_binary_operator_ok (LSHIFTRT, HImode, operands)"
11837   "shr{l}\t%0"
11838   [(set_attr "type" "ishift")
11839    (set (attr "length") 
11840      (if_then_else (match_operand:SI 0 "register_operand" "") 
11841         (const_string "2")
11842         (const_string "*")))])
11843
11844 (define_insn "*lshrsi3_cmp_one_bit_zext"
11845   [(set (reg 17)
11846         (compare
11847           (lshiftrt:SI (match_operand:SI 1 "register_operand" "0")
11848                        (match_operand:QI 2 "const_int_1_operand" ""))
11849           (const_int 0)))
11850    (set (match_operand:DI 0 "register_operand" "=r")
11851         (lshiftrt:DI (zero_extend:DI (match_dup 1)) (match_dup 2)))]
11852   "TARGET_64BIT && ix86_match_ccmode (insn, CCGOCmode)
11853    && (TARGET_PENTIUM || TARGET_PENTIUMPRO)
11854    && ix86_binary_operator_ok (LSHIFTRT, HImode, operands)"
11855   "shr{l}\t%k0"
11856   [(set_attr "type" "ishift")
11857    (set_attr "length" "2")])
11858
11859 ;; This pattern can't accept a variable shift count, since shifts by
11860 ;; zero don't affect the flags.  We assume that shifts by constant
11861 ;; zero are optimized away.
11862 (define_insn "*lshrsi3_cmp"
11863   [(set (reg 17)
11864         (compare
11865           (lshiftrt:SI (match_operand:SI 1 "nonimmediate_operand" "0")
11866                        (match_operand:QI 2 "immediate_operand" "I"))
11867           (const_int 0)))
11868    (set (match_operand:SI 0 "nonimmediate_operand" "=rm")
11869         (lshiftrt:SI (match_dup 1) (match_dup 2)))]
11870   "ix86_match_ccmode (insn, CCGOCmode)
11871    && ix86_binary_operator_ok (LSHIFTRT, HImode, operands)"
11872   "shr{l}\t{%2, %0|%0, %2}"
11873   [(set_attr "type" "ishift")
11874    (set_attr "mode" "SI")])
11875
11876 (define_insn "*lshrsi3_cmp_zext"
11877   [(set (reg 17)
11878         (compare
11879           (lshiftrt:SI (match_operand:SI 1 "register_operand" "0")
11880                        (match_operand:QI 2 "immediate_operand" "I"))
11881           (const_int 0)))
11882    (set (match_operand:DI 0 "register_operand" "=r")
11883         (lshiftrt:DI (zero_extend:DI (match_dup 1)) (match_dup 2)))]
11884   "TARGET_64BIT && ix86_match_ccmode (insn, CCGOCmode)
11885    && ix86_binary_operator_ok (LSHIFTRT, HImode, operands)"
11886   "shr{l}\t{%2, %k0|%k0, %2}"
11887   [(set_attr "type" "ishift")
11888    (set_attr "mode" "SI")])
11889
11890 (define_expand "lshrhi3"
11891   [(set (match_operand:HI 0 "nonimmediate_operand" "")
11892         (lshiftrt:HI (match_operand:HI 1 "nonimmediate_operand" "")
11893                      (match_operand:QI 2 "nonmemory_operand" "")))
11894    (clobber (reg:CC 17))]
11895   "TARGET_HIMODE_MATH"
11896   "ix86_expand_binary_operator (LSHIFTRT, HImode, operands); DONE;")
11897
11898 (define_insn "*lshrhi3_1_one_bit"
11899   [(set (match_operand:HI 0 "nonimmediate_operand" "=rm")
11900         (lshiftrt:HI (match_operand:HI 1 "nonimmediate_operand" "0")
11901                      (match_operand:QI 2 "const_int_1_operand" "")))
11902    (clobber (reg:CC 17))]
11903   "ix86_binary_operator_ok (LSHIFTRT, HImode, operands)
11904    && (TARGET_PENTIUM || TARGET_PENTIUMPRO)"
11905   "shr{w}\t%0"
11906   [(set_attr "type" "ishift")
11907    (set (attr "length") 
11908      (if_then_else (match_operand 0 "register_operand" "") 
11909         (const_string "2")
11910         (const_string "*")))])
11911
11912 (define_insn "*lshrhi3_1"
11913   [(set (match_operand:HI 0 "nonimmediate_operand" "=rm,rm")
11914         (lshiftrt:HI (match_operand:HI 1 "nonimmediate_operand" "0,0")
11915                      (match_operand:QI 2 "nonmemory_operand" "I,c")))
11916    (clobber (reg:CC 17))]
11917   "ix86_binary_operator_ok (LSHIFTRT, HImode, operands)"
11918   "@
11919    shr{w}\t{%2, %0|%0, %2}
11920    shr{w}\t{%b2, %0|%0, %b2}"
11921   [(set_attr "type" "ishift")
11922    (set_attr "mode" "HI")])
11923
11924 ;; This pattern can't accept a variable shift count, since shifts by
11925 ;; zero don't affect the flags.  We assume that shifts by constant
11926 ;; zero are optimized away.
11927 (define_insn "*lshrhi3_one_bit_cmp"
11928   [(set (reg 17)
11929         (compare
11930           (lshiftrt:HI (match_operand:HI 1 "nonimmediate_operand" "0")
11931                        (match_operand:QI 2 "const_int_1_operand" ""))
11932           (const_int 0)))
11933    (set (match_operand:HI 0 "nonimmediate_operand" "=rm")
11934         (lshiftrt:HI (match_dup 1) (match_dup 2)))]
11935   "ix86_match_ccmode (insn, CCGOCmode)
11936    && (TARGET_PENTIUM || TARGET_PENTIUMPRO)
11937    && ix86_binary_operator_ok (LSHIFTRT, HImode, operands)"
11938   "shr{w}\t%0"
11939   [(set_attr "type" "ishift")
11940    (set (attr "length") 
11941      (if_then_else (match_operand:SI 0 "register_operand" "") 
11942         (const_string "2")
11943         (const_string "*")))])
11944
11945 ;; This pattern can't accept a variable shift count, since shifts by
11946 ;; zero don't affect the flags.  We assume that shifts by constant
11947 ;; zero are optimized away.
11948 (define_insn "*lshrhi3_cmp"
11949   [(set (reg 17)
11950         (compare
11951           (lshiftrt:HI (match_operand:HI 1 "nonimmediate_operand" "0")
11952                        (match_operand:QI 2 "immediate_operand" "I"))
11953           (const_int 0)))
11954    (set (match_operand:HI 0 "nonimmediate_operand" "=rm")
11955         (lshiftrt:HI (match_dup 1) (match_dup 2)))]
11956   "ix86_match_ccmode (insn, CCGOCmode)
11957    && ix86_binary_operator_ok (LSHIFTRT, HImode, operands)"
11958   "shr{w}\t{%2, %0|%0, %2}"
11959   [(set_attr "type" "ishift")
11960    (set_attr "mode" "HI")])
11961
11962 (define_expand "lshrqi3"
11963   [(set (match_operand:QI 0 "nonimmediate_operand" "")
11964         (lshiftrt:QI (match_operand:QI 1 "nonimmediate_operand" "")
11965                      (match_operand:QI 2 "nonmemory_operand" "")))
11966    (clobber (reg:CC 17))]
11967   "TARGET_QIMODE_MATH"
11968   "ix86_expand_binary_operator (LSHIFTRT, QImode, operands); DONE;")
11969
11970 (define_insn "*lshrqi3_1_one_bit"
11971   [(set (match_operand:QI 0 "nonimmediate_operand" "=qm")
11972         (lshiftrt:QI (match_operand:QI 1 "nonimmediate_operand" "0")
11973                      (match_operand:QI 2 "const_int_1_operand" "")))
11974    (clobber (reg:CC 17))]
11975   "ix86_binary_operator_ok (LSHIFTRT, QImode, operands)
11976    && (TARGET_PENTIUM || TARGET_PENTIUMPRO)"
11977   "shr{b}\t%0"
11978   [(set_attr "type" "ishift")
11979    (set (attr "length") 
11980      (if_then_else (match_operand 0 "register_operand" "") 
11981         (const_string "2")
11982         (const_string "*")))])
11983
11984 (define_insn "*lshrqi3_1"
11985   [(set (match_operand:QI 0 "nonimmediate_operand" "=qm,qm")
11986         (lshiftrt:QI (match_operand:QI 1 "nonimmediate_operand" "0,0")
11987                      (match_operand:QI 2 "nonmemory_operand" "I,c")))
11988    (clobber (reg:CC 17))]
11989   "ix86_binary_operator_ok (LSHIFTRT, QImode, operands)"
11990   "@
11991    shr{b}\t{%2, %0|%0, %2}
11992    shr{b}\t{%b2, %0|%0, %b2}"
11993   [(set_attr "type" "ishift")
11994    (set_attr "mode" "QI")])
11995
11996 ;; This pattern can't accept a variable shift count, since shifts by
11997 ;; zero don't affect the flags.  We assume that shifts by constant
11998 ;; zero are optimized away.
11999 (define_insn "*lshrqi2_one_bit_cmp"
12000   [(set (reg 17)
12001         (compare
12002           (lshiftrt:QI (match_operand:QI 1 "nonimmediate_operand" "0")
12003                        (match_operand:QI 2 "const_int_1_operand" ""))
12004           (const_int 0)))
12005    (set (match_operand:QI 0 "nonimmediate_operand" "=qm")
12006         (lshiftrt:QI (match_dup 1) (match_dup 2)))]
12007   "ix86_match_ccmode (insn, CCGOCmode)
12008    && (TARGET_PENTIUM || TARGET_PENTIUMPRO)
12009    && ix86_binary_operator_ok (LSHIFTRT, QImode, operands)"
12010   "shr{b}\t%0"
12011   [(set_attr "type" "ishift")
12012    (set (attr "length") 
12013      (if_then_else (match_operand:SI 0 "register_operand" "") 
12014         (const_string "2")
12015         (const_string "*")))])
12016
12017 ;; This pattern can't accept a variable shift count, since shifts by
12018 ;; zero don't affect the flags.  We assume that shifts by constant
12019 ;; zero are optimized away.
12020 (define_insn "*lshrqi2_cmp"
12021   [(set (reg 17)
12022         (compare
12023           (lshiftrt:QI (match_operand:QI 1 "nonimmediate_operand" "0")
12024                        (match_operand:QI 2 "immediate_operand" "I"))
12025           (const_int 0)))
12026    (set (match_operand:QI 0 "nonimmediate_operand" "=qm")
12027         (lshiftrt:QI (match_dup 1) (match_dup 2)))]
12028   "ix86_match_ccmode (insn, CCGOCmode)
12029    && ix86_binary_operator_ok (LSHIFTRT, QImode, operands)"
12030   "shr{b}\t{%2, %0|%0, %2}"
12031   [(set_attr "type" "ishift")
12032    (set_attr "mode" "QI")])
12033 \f
12034 ;; Rotate instructions
12035
12036 (define_expand "rotldi3"
12037   [(set (match_operand:DI 0 "nonimmediate_operand" "")
12038         (rotate:DI (match_operand:DI 1 "nonimmediate_operand" "")
12039                    (match_operand:QI 2 "nonmemory_operand" "")))
12040    (clobber (reg:CC 17))]
12041   "TARGET_64BIT"
12042   "ix86_expand_binary_operator (ROTATE, DImode, operands); DONE;")
12043
12044 (define_insn "*rotlsi3_1_one_bit_rex64"
12045   [(set (match_operand:DI 0 "nonimmediate_operand" "=rm")
12046         (rotate:DI (match_operand:DI 1 "nonimmediate_operand" "0")
12047                    (match_operand:QI 2 "const_int_1_operand" "")))
12048    (clobber (reg:CC 17))]
12049   "TARGET_64BIT && ix86_binary_operator_ok (ROTATE, DImode, operands)
12050    && (TARGET_PENTIUM || TARGET_PENTIUMPRO)"
12051   "rol{q}\t%0"
12052   [(set_attr "type" "ishift")
12053    (set (attr "length") 
12054      (if_then_else (match_operand:DI 0 "register_operand" "") 
12055         (const_string "2")
12056         (const_string "*")))])
12057
12058 (define_insn "*rotldi3_1_rex64"
12059   [(set (match_operand:DI 0 "nonimmediate_operand" "=rm,rm")
12060         (rotate:DI (match_operand:DI 1 "nonimmediate_operand" "0,0")
12061                    (match_operand:QI 2 "nonmemory_operand" "e,c")))
12062    (clobber (reg:CC 17))]
12063   "TARGET_64BIT && ix86_binary_operator_ok (ROTATE, DImode, operands)"
12064   "@
12065    rol{q}\t{%2, %0|%0, %2}
12066    rol{q}\t{%b2, %0|%0, %b2}"
12067   [(set_attr "type" "ishift")
12068    (set_attr "mode" "DI")])
12069
12070 (define_expand "rotlsi3"
12071   [(set (match_operand:SI 0 "nonimmediate_operand" "")
12072         (rotate:SI (match_operand:SI 1 "nonimmediate_operand" "")
12073                    (match_operand:QI 2 "nonmemory_operand" "")))
12074    (clobber (reg:CC 17))]
12075   ""
12076   "ix86_expand_binary_operator (ROTATE, SImode, operands); DONE;")
12077
12078 (define_insn "*rotlsi3_1_one_bit"
12079   [(set (match_operand:SI 0 "nonimmediate_operand" "=rm")
12080         (rotate:SI (match_operand:SI 1 "nonimmediate_operand" "0")
12081                    (match_operand:QI 2 "const_int_1_operand" "")))
12082    (clobber (reg:CC 17))]
12083   "ix86_binary_operator_ok (ROTATE, SImode, operands)
12084    && (TARGET_PENTIUM || TARGET_PENTIUMPRO)"
12085   "rol{l}\t%0"
12086   [(set_attr "type" "ishift")
12087    (set (attr "length") 
12088      (if_then_else (match_operand:SI 0 "register_operand" "") 
12089         (const_string "2")
12090         (const_string "*")))])
12091
12092 (define_insn "*rotlsi3_1_one_bit_zext"
12093   [(set (match_operand:DI 0 "register_operand" "=r")
12094         (zero_extend:DI
12095           (rotate:SI (match_operand:SI 1 "register_operand" "0")
12096                      (match_operand:QI 2 "const_int_1_operand" ""))))
12097    (clobber (reg:CC 17))]
12098   "TARGET_64BIT && ix86_binary_operator_ok (ROTATE, SImode, operands)
12099    && (TARGET_PENTIUM || TARGET_PENTIUMPRO)"
12100   "rol{l}\t%k0"
12101   [(set_attr "type" "ishift")
12102    (set_attr "length" "2")])
12103
12104 (define_insn "*rotlsi3_1"
12105   [(set (match_operand:SI 0 "nonimmediate_operand" "=rm,rm")
12106         (rotate:SI (match_operand:SI 1 "nonimmediate_operand" "0,0")
12107                    (match_operand:QI 2 "nonmemory_operand" "I,c")))
12108    (clobber (reg:CC 17))]
12109   "ix86_binary_operator_ok (ROTATE, SImode, operands)"
12110   "@
12111    rol{l}\t{%2, %0|%0, %2}
12112    rol{l}\t{%b2, %0|%0, %b2}"
12113   [(set_attr "type" "ishift")
12114    (set_attr "mode" "SI")])
12115
12116 (define_insn "*rotlsi3_1_zext"
12117   [(set (match_operand:DI 0 "register_operand" "=r,r")
12118         (zero_extend:DI
12119           (rotate:SI (match_operand:SI 1 "register_operand" "0,0")
12120                      (match_operand:QI 2 "nonmemory_operand" "I,c"))))
12121    (clobber (reg:CC 17))]
12122   "TARGET_64BIT && ix86_binary_operator_ok (ROTATE, SImode, operands)"
12123   "@
12124    rol{l}\t{%2, %k0|%k0, %2}
12125    rol{l}\t{%b2, %k0|%k0, %b2}"
12126   [(set_attr "type" "ishift")
12127    (set_attr "mode" "SI")])
12128
12129 (define_expand "rotlhi3"
12130   [(set (match_operand:HI 0 "nonimmediate_operand" "")
12131         (rotate:HI (match_operand:HI 1 "nonimmediate_operand" "")
12132                    (match_operand:QI 2 "nonmemory_operand" "")))
12133    (clobber (reg:CC 17))]
12134   "TARGET_HIMODE_MATH"
12135   "ix86_expand_binary_operator (ROTATE, HImode, operands); DONE;")
12136
12137 (define_insn "*rotlhi3_1_one_bit"
12138   [(set (match_operand:HI 0 "nonimmediate_operand" "=rm")
12139         (rotate:HI (match_operand:HI 1 "nonimmediate_operand" "0")
12140                    (match_operand:QI 2 "const_int_1_operand" "")))
12141    (clobber (reg:CC 17))]
12142   "ix86_binary_operator_ok (ROTATE, HImode, operands)
12143    && (TARGET_PENTIUM || TARGET_PENTIUMPRO)"
12144   "rol{w}\t%0"
12145   [(set_attr "type" "ishift")
12146    (set (attr "length") 
12147      (if_then_else (match_operand 0 "register_operand" "") 
12148         (const_string "2")
12149         (const_string "*")))])
12150
12151 (define_insn "*rotlhi3_1"
12152   [(set (match_operand:HI 0 "nonimmediate_operand" "=rm,rm")
12153         (rotate:HI (match_operand:HI 1 "nonimmediate_operand" "0,0")
12154                    (match_operand:QI 2 "nonmemory_operand" "I,c")))
12155    (clobber (reg:CC 17))]
12156   "ix86_binary_operator_ok (ROTATE, HImode, operands)"
12157   "@
12158    rol{w}\t{%2, %0|%0, %2}
12159    rol{w}\t{%b2, %0|%0, %b2}"
12160   [(set_attr "type" "ishift")
12161    (set_attr "mode" "HI")])
12162
12163 (define_expand "rotlqi3"
12164   [(set (match_operand:QI 0 "nonimmediate_operand" "")
12165         (rotate:QI (match_operand:QI 1 "nonimmediate_operand" "")
12166                    (match_operand:QI 2 "nonmemory_operand" "")))
12167    (clobber (reg:CC 17))]
12168   "TARGET_QIMODE_MATH"
12169   "ix86_expand_binary_operator (ROTATE, QImode, operands); DONE;")
12170
12171 (define_insn "*rotlqi3_1_one_bit"
12172   [(set (match_operand:QI 0 "nonimmediate_operand" "=qm")
12173         (rotate:QI (match_operand:QI 1 "nonimmediate_operand" "0")
12174                    (match_operand:QI 2 "const_int_1_operand" "")))
12175    (clobber (reg:CC 17))]
12176   "ix86_binary_operator_ok (ROTATE, QImode, operands)
12177    && (TARGET_PENTIUM || TARGET_PENTIUMPRO)"
12178   "rol{b}\t%0"
12179   [(set_attr "type" "ishift")
12180    (set (attr "length") 
12181      (if_then_else (match_operand 0 "register_operand" "") 
12182         (const_string "2")
12183         (const_string "*")))])
12184
12185 (define_insn "*rotlqi3_1"
12186   [(set (match_operand:QI 0 "nonimmediate_operand" "=qm,qm")
12187         (rotate:QI (match_operand:QI 1 "nonimmediate_operand" "0,0")
12188                    (match_operand:QI 2 "nonmemory_operand" "I,c")))
12189    (clobber (reg:CC 17))]
12190   "ix86_binary_operator_ok (ROTATE, QImode, operands)"
12191   "@
12192    rol{b}\t{%2, %0|%0, %2}
12193    rol{b}\t{%b2, %0|%0, %b2}"
12194   [(set_attr "type" "ishift")
12195    (set_attr "mode" "QI")])
12196
12197 (define_expand "rotrdi3"
12198   [(set (match_operand:DI 0 "nonimmediate_operand" "")
12199         (rotatert:DI (match_operand:DI 1 "nonimmediate_operand" "")
12200                      (match_operand:QI 2 "nonmemory_operand" "")))
12201    (clobber (reg:CC 17))]
12202   "TARGET_64BIT"
12203   "ix86_expand_binary_operator (ROTATERT, DImode, operands); DONE;")
12204
12205 (define_insn "*rotrdi3_1_one_bit_rex64"
12206   [(set (match_operand:DI 0 "nonimmediate_operand" "=rm")
12207         (rotatert:DI (match_operand:DI 1 "nonimmediate_operand" "0")
12208                      (match_operand:QI 2 "const_int_1_operand" "")))
12209    (clobber (reg:CC 17))]
12210   "TARGET_64BIT && ix86_binary_operator_ok (ROTATERT, DImode, operands)
12211    && (TARGET_PENTIUM || TARGET_PENTIUMPRO)"
12212   "ror{q}\t%0"
12213   [(set_attr "type" "ishift")
12214    (set (attr "length") 
12215      (if_then_else (match_operand:DI 0 "register_operand" "") 
12216         (const_string "2")
12217         (const_string "*")))])
12218
12219 (define_insn "*rotrdi3_1_rex64"
12220   [(set (match_operand:DI 0 "nonimmediate_operand" "=rm,rm")
12221         (rotatert:DI (match_operand:DI 1 "nonimmediate_operand" "0,0")
12222                      (match_operand:QI 2 "nonmemory_operand" "J,c")))
12223    (clobber (reg:CC 17))]
12224   "TARGET_64BIT && ix86_binary_operator_ok (ROTATERT, DImode, operands)"
12225   "@
12226    ror{q}\t{%2, %0|%0, %2}
12227    ror{q}\t{%b2, %0|%0, %b2}"
12228   [(set_attr "type" "ishift")
12229    (set_attr "mode" "DI")])
12230
12231 (define_expand "rotrsi3"
12232   [(set (match_operand:SI 0 "nonimmediate_operand" "")
12233         (rotatert:SI (match_operand:SI 1 "nonimmediate_operand" "")
12234                      (match_operand:QI 2 "nonmemory_operand" "")))
12235    (clobber (reg:CC 17))]
12236   ""
12237   "ix86_expand_binary_operator (ROTATERT, SImode, operands); DONE;")
12238
12239 (define_insn "*rotrsi3_1_one_bit"
12240   [(set (match_operand:SI 0 "nonimmediate_operand" "=rm")
12241         (rotatert:SI (match_operand:SI 1 "nonimmediate_operand" "0")
12242                      (match_operand:QI 2 "const_int_1_operand" "")))
12243    (clobber (reg:CC 17))]
12244   "ix86_binary_operator_ok (ROTATERT, SImode, operands)
12245    && (TARGET_PENTIUM || TARGET_PENTIUMPRO)"
12246   "ror{l}\t%0"
12247   [(set_attr "type" "ishift")
12248    (set (attr "length") 
12249      (if_then_else (match_operand:SI 0 "register_operand" "") 
12250         (const_string "2")
12251         (const_string "*")))])
12252
12253 (define_insn "*rotrsi3_1_one_bit_zext"
12254   [(set (match_operand:DI 0 "register_operand" "=r")
12255         (zero_extend:DI
12256           (rotatert:SI (match_operand:SI 1 "register_operand" "0")
12257                        (match_operand:QI 2 "const_int_1_operand" ""))))
12258    (clobber (reg:CC 17))]
12259   "TARGET_64BIT && ix86_binary_operator_ok (ROTATERT, SImode, operands)
12260    && (TARGET_PENTIUM || TARGET_PENTIUMPRO)"
12261   "ror{l}\t%k0"
12262   [(set_attr "type" "ishift")
12263    (set (attr "length") 
12264      (if_then_else (match_operand:SI 0 "register_operand" "") 
12265         (const_string "2")
12266         (const_string "*")))])
12267
12268 (define_insn "*rotrsi3_1"
12269   [(set (match_operand:SI 0 "nonimmediate_operand" "=rm,rm")
12270         (rotatert:SI (match_operand:SI 1 "nonimmediate_operand" "0,0")
12271                      (match_operand:QI 2 "nonmemory_operand" "I,c")))
12272    (clobber (reg:CC 17))]
12273   "ix86_binary_operator_ok (ROTATERT, SImode, operands)"
12274   "@
12275    ror{l}\t{%2, %0|%0, %2}
12276    ror{l}\t{%b2, %0|%0, %b2}"
12277   [(set_attr "type" "ishift")
12278    (set_attr "mode" "SI")])
12279
12280 (define_insn "*rotrsi3_1_zext"
12281   [(set (match_operand:DI 0 "register_operand" "=r,r")
12282         (zero_extend:DI
12283           (rotatert:SI (match_operand:SI 1 "register_operand" "0,0")
12284                        (match_operand:QI 2 "nonmemory_operand" "I,c"))))
12285    (clobber (reg:CC 17))]
12286   "TARGET_64BIT && ix86_binary_operator_ok (ROTATERT, SImode, operands)"
12287   "@
12288    ror{l}\t{%2, %k0|%k0, %2}
12289    ror{l}\t{%b2, %k0|%k0, %b2}"
12290   [(set_attr "type" "ishift")
12291    (set_attr "mode" "SI")])
12292
12293 (define_expand "rotrhi3"
12294   [(set (match_operand:HI 0 "nonimmediate_operand" "")
12295         (rotatert:HI (match_operand:HI 1 "nonimmediate_operand" "")
12296                      (match_operand:QI 2 "nonmemory_operand" "")))
12297    (clobber (reg:CC 17))]
12298   "TARGET_HIMODE_MATH"
12299   "ix86_expand_binary_operator (ROTATERT, HImode, operands); DONE;")
12300
12301 (define_insn "*rotrhi3_one_bit"
12302   [(set (match_operand:HI 0 "nonimmediate_operand" "=rm")
12303         (rotatert:HI (match_operand:HI 1 "nonimmediate_operand" "0")
12304                      (match_operand:QI 2 "const_int_1_operand" "")))
12305    (clobber (reg:CC 17))]
12306   "ix86_binary_operator_ok (ROTATERT, HImode, operands)
12307    && (TARGET_PENTIUM || TARGET_PENTIUMPRO)"
12308   "ror{w}\t%0"
12309   [(set_attr "type" "ishift")
12310    (set (attr "length") 
12311      (if_then_else (match_operand 0 "register_operand" "") 
12312         (const_string "2")
12313         (const_string "*")))])
12314
12315 (define_insn "*rotrhi3"
12316   [(set (match_operand:HI 0 "nonimmediate_operand" "=rm,rm")
12317         (rotatert:HI (match_operand:HI 1 "nonimmediate_operand" "0,0")
12318                      (match_operand:QI 2 "nonmemory_operand" "I,c")))
12319    (clobber (reg:CC 17))]
12320   "ix86_binary_operator_ok (ROTATERT, HImode, operands)"
12321   "@
12322    ror{w}\t{%2, %0|%0, %2}
12323    ror{w}\t{%b2, %0|%0, %b2}"
12324   [(set_attr "type" "ishift")
12325    (set_attr "mode" "HI")])
12326
12327 (define_expand "rotrqi3"
12328   [(set (match_operand:QI 0 "nonimmediate_operand" "")
12329         (rotatert:QI (match_operand:QI 1 "nonimmediate_operand" "")
12330                      (match_operand:QI 2 "nonmemory_operand" "")))
12331    (clobber (reg:CC 17))]
12332   "TARGET_QIMODE_MATH"
12333   "ix86_expand_binary_operator (ROTATERT, QImode, operands); DONE;")
12334
12335 (define_insn "*rotrqi3_1_one_bit"
12336   [(set (match_operand:QI 0 "nonimmediate_operand" "=qm")
12337         (rotatert:QI (match_operand:QI 1 "nonimmediate_operand" "0")
12338                      (match_operand:QI 2 "const_int_1_operand" "")))
12339    (clobber (reg:CC 17))]
12340   "ix86_binary_operator_ok (ROTATERT, QImode, operands)
12341    && (TARGET_PENTIUM || TARGET_PENTIUMPRO)"
12342   "ror{b}\t%0"
12343   [(set_attr "type" "ishift")
12344    (set (attr "length") 
12345      (if_then_else (match_operand 0 "register_operand" "") 
12346         (const_string "2")
12347         (const_string "*")))])
12348
12349 (define_insn "*rotrqi3_1"
12350   [(set (match_operand:QI 0 "nonimmediate_operand" "=qm,qm")
12351         (rotatert:QI (match_operand:QI 1 "nonimmediate_operand" "0,0")
12352                      (match_operand:QI 2 "nonmemory_operand" "I,c")))
12353    (clobber (reg:CC 17))]
12354   "ix86_binary_operator_ok (ROTATERT, QImode, operands)"
12355   "@
12356    ror{b}\t{%2, %0|%0, %2}
12357    ror{b}\t{%b2, %0|%0, %b2}"
12358   [(set_attr "type" "ishift")
12359    (set_attr "mode" "QI")])
12360 \f
12361 ;; Bit set / bit test instructions
12362
12363 (define_expand "extv"
12364   [(set (match_operand:SI 0 "register_operand" "")
12365         (sign_extract:SI (match_operand:SI 1 "register_operand" "")
12366                          (match_operand:SI 2 "immediate_operand" "")
12367                          (match_operand:SI 3 "immediate_operand" "")))]
12368   ""
12369 {
12370   /* Handle extractions from %ah et al.  */
12371   if (INTVAL (operands[2]) != 8 || INTVAL (operands[3]) != 8)
12372     FAIL;
12373
12374   /* From mips.md: extract_bit_field doesn't verify that our source
12375      matches the predicate, so check it again here.  */
12376   if (! register_operand (operands[1], VOIDmode))
12377     FAIL;
12378 })
12379
12380 (define_expand "extzv"
12381   [(set (match_operand:SI 0 "register_operand" "")
12382         (zero_extract:SI (match_operand 1 "ext_register_operand" "")
12383                          (match_operand:SI 2 "immediate_operand" "")
12384                          (match_operand:SI 3 "immediate_operand" "")))]
12385   ""
12386 {
12387   /* Handle extractions from %ah et al.  */
12388   if (INTVAL (operands[2]) != 8 || INTVAL (operands[3]) != 8)
12389     FAIL;
12390
12391   /* From mips.md: extract_bit_field doesn't verify that our source
12392      matches the predicate, so check it again here.  */
12393   if (! register_operand (operands[1], VOIDmode))
12394     FAIL;
12395 })
12396
12397 (define_expand "insv"
12398   [(set (zero_extract:SI (match_operand 0 "ext_register_operand" "")
12399                          (match_operand:SI 1 "immediate_operand" "")
12400                          (match_operand:SI 2 "immediate_operand" ""))
12401         (match_operand:SI 3 "register_operand" ""))]
12402   ""
12403 {
12404   /* Handle extractions from %ah et al.  */
12405   if (INTVAL (operands[1]) != 8 || INTVAL (operands[2]) != 8)
12406     FAIL;
12407
12408   /* From mips.md: insert_bit_field doesn't verify that our source
12409      matches the predicate, so check it again here.  */
12410   if (! register_operand (operands[0], VOIDmode))
12411     FAIL;
12412 })
12413
12414 ;; %%% bts, btr, btc, bt.
12415 \f
12416 ;; Store-flag instructions.
12417
12418 ;; For all sCOND expanders, also expand the compare or test insn that
12419 ;; generates cc0.  Generate an equality comparison if `seq' or `sne'.
12420
12421 ;; %%% Do the expansion to SImode.  If PII, do things the xor+setcc way
12422 ;; to avoid partial register stalls.  Otherwise do things the setcc+movzx
12423 ;; way, which can later delete the movzx if only QImode is needed.
12424
12425 (define_expand "seq"
12426   [(set (match_operand:QI 0 "register_operand" "")
12427         (eq:QI (reg:CC 17) (const_int 0)))]
12428   ""
12429   "if (ix86_expand_setcc (EQ, operands[0])) DONE; else FAIL;")
12430
12431 (define_expand "sne"
12432   [(set (match_operand:QI 0 "register_operand" "")
12433         (ne:QI (reg:CC 17) (const_int 0)))]
12434   ""
12435   "if (ix86_expand_setcc (NE, operands[0])) DONE; else FAIL;")
12436
12437 (define_expand "sgt"
12438   [(set (match_operand:QI 0 "register_operand" "")
12439         (gt:QI (reg:CC 17) (const_int 0)))]
12440   ""
12441   "if (ix86_expand_setcc (GT, operands[0])) DONE; else FAIL;")
12442
12443 (define_expand "sgtu"
12444   [(set (match_operand:QI 0 "register_operand" "")
12445         (gtu:QI (reg:CC 17) (const_int 0)))]
12446   ""
12447   "if (ix86_expand_setcc (GTU, operands[0])) DONE; else FAIL;")
12448
12449 (define_expand "slt"
12450   [(set (match_operand:QI 0 "register_operand" "")
12451         (lt:QI (reg:CC 17) (const_int 0)))]
12452   ""
12453   "if (ix86_expand_setcc (LT, operands[0])) DONE; else FAIL;")
12454
12455 (define_expand "sltu"
12456   [(set (match_operand:QI 0 "register_operand" "")
12457         (ltu:QI (reg:CC 17) (const_int 0)))]
12458   ""
12459   "if (ix86_expand_setcc (LTU, operands[0])) DONE; else FAIL;")
12460
12461 (define_expand "sge"
12462   [(set (match_operand:QI 0 "register_operand" "")
12463         (ge:QI (reg:CC 17) (const_int 0)))]
12464   ""
12465   "if (ix86_expand_setcc (GE, operands[0])) DONE; else FAIL;")
12466
12467 (define_expand "sgeu"
12468   [(set (match_operand:QI 0 "register_operand" "")
12469         (geu:QI (reg:CC 17) (const_int 0)))]
12470   ""
12471   "if (ix86_expand_setcc (GEU, operands[0])) DONE; else FAIL;")
12472
12473 (define_expand "sle"
12474   [(set (match_operand:QI 0 "register_operand" "")
12475         (le:QI (reg:CC 17) (const_int 0)))]
12476   ""
12477   "if (ix86_expand_setcc (LE, operands[0])) DONE; else FAIL;")
12478
12479 (define_expand "sleu"
12480   [(set (match_operand:QI 0 "register_operand" "")
12481         (leu:QI (reg:CC 17) (const_int 0)))]
12482   ""
12483   "if (ix86_expand_setcc (LEU, operands[0])) DONE; else FAIL;")
12484
12485 (define_expand "sunordered"
12486   [(set (match_operand:QI 0 "register_operand" "")
12487         (unordered:QI (reg:CC 17) (const_int 0)))]
12488   "TARGET_80387 || TARGET_SSE"
12489   "if (ix86_expand_setcc (UNORDERED, operands[0])) DONE; else FAIL;")
12490
12491 (define_expand "sordered"
12492   [(set (match_operand:QI 0 "register_operand" "")
12493         (ordered:QI (reg:CC 17) (const_int 0)))]
12494   "TARGET_80387"
12495   "if (ix86_expand_setcc (ORDERED, operands[0])) DONE; else FAIL;")
12496
12497 (define_expand "suneq"
12498   [(set (match_operand:QI 0 "register_operand" "")
12499         (uneq:QI (reg:CC 17) (const_int 0)))]
12500   "TARGET_80387 || TARGET_SSE"
12501   "if (ix86_expand_setcc (UNEQ, operands[0])) DONE; else FAIL;")
12502
12503 (define_expand "sunge"
12504   [(set (match_operand:QI 0 "register_operand" "")
12505         (unge:QI (reg:CC 17) (const_int 0)))]
12506   "TARGET_80387 || TARGET_SSE"
12507   "if (ix86_expand_setcc (UNGE, operands[0])) DONE; else FAIL;")
12508
12509 (define_expand "sungt"
12510   [(set (match_operand:QI 0 "register_operand" "")
12511         (ungt:QI (reg:CC 17) (const_int 0)))]
12512   "TARGET_80387 || TARGET_SSE"
12513   "if (ix86_expand_setcc (UNGT, operands[0])) DONE; else FAIL;")
12514
12515 (define_expand "sunle"
12516   [(set (match_operand:QI 0 "register_operand" "")
12517         (unle:QI (reg:CC 17) (const_int 0)))]
12518   "TARGET_80387 || TARGET_SSE"
12519   "if (ix86_expand_setcc (UNLE, operands[0])) DONE; else FAIL;")
12520
12521 (define_expand "sunlt"
12522   [(set (match_operand:QI 0 "register_operand" "")
12523         (unlt:QI (reg:CC 17) (const_int 0)))]
12524   "TARGET_80387 || TARGET_SSE"
12525   "if (ix86_expand_setcc (UNLT, operands[0])) DONE; else FAIL;")
12526
12527 (define_expand "sltgt"
12528   [(set (match_operand:QI 0 "register_operand" "")
12529         (ltgt:QI (reg:CC 17) (const_int 0)))]
12530   "TARGET_80387 || TARGET_SSE"
12531   "if (ix86_expand_setcc (LTGT, operands[0])) DONE; else FAIL;")
12532
12533 (define_insn "*setcc_1"
12534   [(set (match_operand:QI 0 "nonimmediate_operand" "=qm")
12535         (match_operator:QI 1 "ix86_comparison_operator"
12536           [(reg 17) (const_int 0)]))]
12537   ""
12538   "set%C1\t%0"
12539   [(set_attr "type" "setcc")
12540    (set_attr "mode" "QI")])
12541
12542 (define_insn "setcc_2"
12543   [(set (strict_low_part (match_operand:QI 0 "nonimmediate_operand" "+qm"))
12544         (match_operator:QI 1 "ix86_comparison_operator"
12545           [(reg 17) (const_int 0)]))]
12546   ""
12547   "set%C1\t%0"
12548   [(set_attr "type" "setcc")
12549    (set_attr "mode" "QI")])
12550
12551 ;; In general it is not safe to assume too much about CCmode registers,
12552 ;; so simplify-rtx stops when it sees a second one.  Under certain 
12553 ;; conditions this is safe on x86, so help combine not create
12554 ;;
12555 ;;      seta    %al
12556 ;;      testb   %al, %al
12557 ;;      sete    %al
12558
12559 (define_split 
12560   [(set (match_operand:QI 0 "nonimmediate_operand" "")
12561         (ne:QI (match_operator 1 "ix86_comparison_operator"
12562                  [(reg 17) (const_int 0)])
12563             (const_int 0)))]
12564   ""
12565   [(set (match_dup 0) (match_dup 1))]
12566 {
12567   PUT_MODE (operands[1], QImode);
12568 })
12569
12570 (define_split 
12571   [(set (strict_low_part (match_operand:QI 0 "nonimmediate_operand" ""))
12572         (ne:QI (match_operator 1 "ix86_comparison_operator"
12573                  [(reg 17) (const_int 0)])
12574             (const_int 0)))]
12575   ""
12576   [(set (match_dup 0) (match_dup 1))]
12577 {
12578   PUT_MODE (operands[1], QImode);
12579 })
12580
12581 (define_split 
12582   [(set (match_operand:QI 0 "nonimmediate_operand" "")
12583         (eq:QI (match_operator 1 "ix86_comparison_operator"
12584                  [(reg 17) (const_int 0)])
12585             (const_int 0)))]
12586   ""
12587   [(set (match_dup 0) (match_dup 1))]
12588 {
12589   rtx new_op1 = copy_rtx (operands[1]);
12590   operands[1] = new_op1;
12591   PUT_MODE (new_op1, QImode);
12592   PUT_CODE (new_op1, REVERSE_CONDITION (GET_CODE (new_op1),
12593                                         GET_MODE (XEXP (new_op1, 0))));
12594
12595   /* Make sure that (a) the CCmode we have for the flags is strong
12596      enough for the reversed compare or (b) we have a valid FP compare.  */
12597   if (! ix86_comparison_operator (new_op1, VOIDmode))
12598     FAIL;
12599 })
12600
12601 (define_split 
12602   [(set (strict_low_part (match_operand:QI 0 "nonimmediate_operand" ""))
12603         (eq: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))]
12608 {
12609   rtx new_op1 = copy_rtx (operands[1]);
12610   operands[1] = new_op1;
12611   PUT_MODE (new_op1, QImode);
12612   PUT_CODE (new_op1, REVERSE_CONDITION (GET_CODE (new_op1),
12613                                         GET_MODE (XEXP (new_op1, 0))));
12614
12615   /* Make sure that (a) the CCmode we have for the flags is strong
12616      enough for the reversed compare or (b) we have a valid FP compare.  */
12617   if (! ix86_comparison_operator (new_op1, VOIDmode))
12618     FAIL;
12619 })
12620
12621 ;; The SSE store flag instructions saves 0 or 0xffffffff to the result.
12622 ;; subsequent logical operations are used to imitate conditional moves.
12623 ;; 0xffffffff is NaN, but not in normalized form, so we can't represent
12624 ;; it directly.  Futher holding this value in pseudo register might bring
12625 ;; problem in implicit normalization in spill code.
12626 ;; So we don't define FLOAT_STORE_FLAG_VALUE and create these
12627 ;; instructions after reload by splitting the conditional move patterns.
12628
12629 (define_insn "*sse_setccsf"
12630   [(set (match_operand:SF 0 "register_operand" "=x")
12631         (match_operator:SF 1 "sse_comparison_operator"
12632           [(match_operand:SF 2 "register_operand" "0")
12633            (match_operand:SF 3 "nonimmediate_operand" "xm")]))]
12634   "TARGET_SSE && reload_completed"
12635   "cmp%D1ss\t{%3, %0|%0, %3}"
12636   [(set_attr "type" "sse")
12637    (set_attr "mode" "SF")])
12638
12639 (define_insn "*sse_setccdf"
12640   [(set (match_operand:DF 0 "register_operand" "=Y")
12641         (match_operator:DF 1 "sse_comparison_operator"
12642           [(match_operand:DF 2 "register_operand" "0")
12643            (match_operand:DF 3 "nonimmediate_operand" "Ym")]))]
12644   "TARGET_SSE2 && reload_completed"
12645   "cmp%D1sd\t{%3, %0|%0, %3}"
12646   [(set_attr "type" "sse")
12647    (set_attr "mode" "DF")])
12648 \f
12649 ;; Basic conditional jump instructions.
12650 ;; We ignore the overflow flag for signed branch instructions.
12651
12652 ;; For all bCOND expanders, also expand the compare or test insn that
12653 ;; generates reg 17.  Generate an equality comparison if `beq' or `bne'.
12654
12655 (define_expand "beq"
12656   [(set (pc)
12657         (if_then_else (match_dup 1)
12658                       (label_ref (match_operand 0 "" ""))
12659                       (pc)))]
12660   ""
12661   "ix86_expand_branch (EQ, operands[0]); DONE;")
12662
12663 (define_expand "bne"
12664   [(set (pc)
12665         (if_then_else (match_dup 1)
12666                       (label_ref (match_operand 0 "" ""))
12667                       (pc)))]
12668   ""
12669   "ix86_expand_branch (NE, operands[0]); DONE;")
12670
12671 (define_expand "bgt"
12672   [(set (pc)
12673         (if_then_else (match_dup 1)
12674                       (label_ref (match_operand 0 "" ""))
12675                       (pc)))]
12676   ""
12677   "ix86_expand_branch (GT, operands[0]); DONE;")
12678
12679 (define_expand "bgtu"
12680   [(set (pc)
12681         (if_then_else (match_dup 1)
12682                       (label_ref (match_operand 0 "" ""))
12683                       (pc)))]
12684   ""
12685   "ix86_expand_branch (GTU, operands[0]); DONE;")
12686
12687 (define_expand "blt"
12688   [(set (pc)
12689         (if_then_else (match_dup 1)
12690                       (label_ref (match_operand 0 "" ""))
12691                       (pc)))]
12692   ""
12693   "ix86_expand_branch (LT, operands[0]); DONE;")
12694
12695 (define_expand "bltu"
12696   [(set (pc)
12697         (if_then_else (match_dup 1)
12698                       (label_ref (match_operand 0 "" ""))
12699                       (pc)))]
12700   ""
12701   "ix86_expand_branch (LTU, operands[0]); DONE;")
12702
12703 (define_expand "bge"
12704   [(set (pc)
12705         (if_then_else (match_dup 1)
12706                       (label_ref (match_operand 0 "" ""))
12707                       (pc)))]
12708   ""
12709   "ix86_expand_branch (GE, operands[0]); DONE;")
12710
12711 (define_expand "bgeu"
12712   [(set (pc)
12713         (if_then_else (match_dup 1)
12714                       (label_ref (match_operand 0 "" ""))
12715                       (pc)))]
12716   ""
12717   "ix86_expand_branch (GEU, operands[0]); DONE;")
12718
12719 (define_expand "ble"
12720   [(set (pc)
12721         (if_then_else (match_dup 1)
12722                       (label_ref (match_operand 0 "" ""))
12723                       (pc)))]
12724   ""
12725   "ix86_expand_branch (LE, operands[0]); DONE;")
12726
12727 (define_expand "bleu"
12728   [(set (pc)
12729         (if_then_else (match_dup 1)
12730                       (label_ref (match_operand 0 "" ""))
12731                       (pc)))]
12732   ""
12733   "ix86_expand_branch (LEU, operands[0]); DONE;")
12734
12735 (define_expand "bunordered"
12736   [(set (pc)
12737         (if_then_else (match_dup 1)
12738                       (label_ref (match_operand 0 "" ""))
12739                       (pc)))]
12740   "TARGET_80387 || TARGET_SSE"
12741   "ix86_expand_branch (UNORDERED, operands[0]); DONE;")
12742
12743 (define_expand "bordered"
12744   [(set (pc)
12745         (if_then_else (match_dup 1)
12746                       (label_ref (match_operand 0 "" ""))
12747                       (pc)))]
12748   "TARGET_80387 || TARGET_SSE"
12749   "ix86_expand_branch (ORDERED, operands[0]); DONE;")
12750
12751 (define_expand "buneq"
12752   [(set (pc)
12753         (if_then_else (match_dup 1)
12754                       (label_ref (match_operand 0 "" ""))
12755                       (pc)))]
12756   "TARGET_80387 || TARGET_SSE"
12757   "ix86_expand_branch (UNEQ, operands[0]); DONE;")
12758
12759 (define_expand "bunge"
12760   [(set (pc)
12761         (if_then_else (match_dup 1)
12762                       (label_ref (match_operand 0 "" ""))
12763                       (pc)))]
12764   "TARGET_80387 || TARGET_SSE"
12765   "ix86_expand_branch (UNGE, operands[0]); DONE;")
12766
12767 (define_expand "bungt"
12768   [(set (pc)
12769         (if_then_else (match_dup 1)
12770                       (label_ref (match_operand 0 "" ""))
12771                       (pc)))]
12772   "TARGET_80387 || TARGET_SSE"
12773   "ix86_expand_branch (UNGT, operands[0]); DONE;")
12774
12775 (define_expand "bunle"
12776   [(set (pc)
12777         (if_then_else (match_dup 1)
12778                       (label_ref (match_operand 0 "" ""))
12779                       (pc)))]
12780   "TARGET_80387 || TARGET_SSE"
12781   "ix86_expand_branch (UNLE, operands[0]); DONE;")
12782
12783 (define_expand "bunlt"
12784   [(set (pc)
12785         (if_then_else (match_dup 1)
12786                       (label_ref (match_operand 0 "" ""))
12787                       (pc)))]
12788   "TARGET_80387 || TARGET_SSE"
12789   "ix86_expand_branch (UNLT, operands[0]); DONE;")
12790
12791 (define_expand "bltgt"
12792   [(set (pc)
12793         (if_then_else (match_dup 1)
12794                       (label_ref (match_operand 0 "" ""))
12795                       (pc)))]
12796   "TARGET_80387 || TARGET_SSE"
12797   "ix86_expand_branch (LTGT, operands[0]); DONE;")
12798
12799 (define_insn "*jcc_1"
12800   [(set (pc)
12801         (if_then_else (match_operator 1 "ix86_comparison_operator"
12802                                       [(reg 17) (const_int 0)])
12803                       (label_ref (match_operand 0 "" ""))
12804                       (pc)))]
12805   ""
12806   "%+j%C1\t%l0"
12807   [(set_attr "type" "ibr")
12808    (set (attr "prefix_0f")
12809            (if_then_else (and (ge (minus (match_dup 0) (pc))
12810                                   (const_int -128))
12811                               (lt (minus (match_dup 0) (pc))
12812                                   (const_int 124)))
12813              (const_int 0)
12814              (const_int 1)))])
12815
12816 (define_insn "*jcc_2"
12817   [(set (pc)
12818         (if_then_else (match_operator 1 "ix86_comparison_operator"
12819                                       [(reg 17) (const_int 0)])
12820                       (pc)
12821                       (label_ref (match_operand 0 "" ""))))]
12822   ""
12823   "%+j%c1\t%l0"
12824   [(set_attr "type" "ibr")
12825    (set (attr "prefix_0f")
12826            (if_then_else (and (ge (minus (match_dup 0) (pc))
12827                                   (const_int -128))
12828                               (lt (minus (match_dup 0) (pc))
12829                                   (const_int 124)))
12830              (const_int 0)
12831              (const_int 1)))])
12832
12833 ;; In general it is not safe to assume too much about CCmode registers,
12834 ;; so simplify-rtx stops when it sees a second one.  Under certain 
12835 ;; conditions this is safe on x86, so help combine not create
12836 ;;
12837 ;;      seta    %al
12838 ;;      testb   %al, %al
12839 ;;      je      Lfoo
12840
12841 (define_split 
12842   [(set (pc)
12843         (if_then_else (ne (match_operator 0 "ix86_comparison_operator"
12844                                       [(reg 17) (const_int 0)])
12845                           (const_int 0))
12846                       (label_ref (match_operand 1 "" ""))
12847                       (pc)))]
12848   ""
12849   [(set (pc)
12850         (if_then_else (match_dup 0)
12851                       (label_ref (match_dup 1))
12852                       (pc)))]
12853 {
12854   PUT_MODE (operands[0], VOIDmode);
12855 })
12856   
12857 (define_split 
12858   [(set (pc)
12859         (if_then_else (eq (match_operator 0 "ix86_comparison_operator"
12860                                       [(reg 17) (const_int 0)])
12861                           (const_int 0))
12862                       (label_ref (match_operand 1 "" ""))
12863                       (pc)))]
12864   ""
12865   [(set (pc)
12866         (if_then_else (match_dup 0)
12867                       (label_ref (match_dup 1))
12868                       (pc)))]
12869 {
12870   rtx new_op0 = copy_rtx (operands[0]);
12871   operands[0] = new_op0;
12872   PUT_MODE (new_op0, VOIDmode);
12873   PUT_CODE (new_op0, REVERSE_CONDITION (GET_CODE (new_op0),
12874                                         GET_MODE (XEXP (new_op0, 0))));
12875
12876   /* Make sure that (a) the CCmode we have for the flags is strong
12877      enough for the reversed compare or (b) we have a valid FP compare.  */
12878   if (! ix86_comparison_operator (new_op0, VOIDmode))
12879     FAIL;
12880 })
12881
12882 ;; Define combination compare-and-branch fp compare instructions to use
12883 ;; during early optimization.  Splitting the operation apart early makes
12884 ;; for bad code when we want to reverse the operation.
12885
12886 (define_insn "*fp_jcc_1"
12887   [(set (pc)
12888         (if_then_else (match_operator 0 "comparison_operator"
12889                         [(match_operand 1 "register_operand" "f")
12890                          (match_operand 2 "register_operand" "f")])
12891           (label_ref (match_operand 3 "" ""))
12892           (pc)))
12893    (clobber (reg:CCFP 18))
12894    (clobber (reg:CCFP 17))]
12895   "TARGET_CMOVE && TARGET_80387
12896    && !SSE_FLOAT_MODE_P (GET_MODE (operands[1]))
12897    && FLOAT_MODE_P (GET_MODE (operands[1]))
12898    && GET_MODE (operands[1]) == GET_MODE (operands[2])
12899    && ix86_fp_jump_nontrivial_p (GET_CODE (operands[0]))"
12900   "#")
12901
12902 (define_insn "*fp_jcc_1_sse"
12903   [(set (pc)
12904         (if_then_else (match_operator 0 "comparison_operator"
12905                         [(match_operand 1 "register_operand" "f#x,x#f")
12906                          (match_operand 2 "nonimmediate_operand" "f#x,xm#f")])
12907           (label_ref (match_operand 3 "" ""))
12908           (pc)))
12909    (clobber (reg:CCFP 18))
12910    (clobber (reg:CCFP 17))]
12911   "TARGET_80387
12912    && SSE_FLOAT_MODE_P (GET_MODE (operands[1]))
12913    && GET_MODE (operands[1]) == GET_MODE (operands[2])
12914    && ix86_fp_jump_nontrivial_p (GET_CODE (operands[0]))"
12915   "#")
12916
12917 (define_insn "*fp_jcc_1_sse_only"
12918   [(set (pc)
12919         (if_then_else (match_operator 0 "comparison_operator"
12920                         [(match_operand 1 "register_operand" "x")
12921                          (match_operand 2 "nonimmediate_operand" "xm")])
12922           (label_ref (match_operand 3 "" ""))
12923           (pc)))
12924    (clobber (reg:CCFP 18))
12925    (clobber (reg:CCFP 17))]
12926   "SSE_FLOAT_MODE_P (GET_MODE (operands[1]))
12927    && GET_MODE (operands[1]) == GET_MODE (operands[2])
12928    && ix86_fp_jump_nontrivial_p (GET_CODE (operands[0]))"
12929   "#")
12930
12931 (define_insn "*fp_jcc_2"
12932   [(set (pc)
12933         (if_then_else (match_operator 0 "comparison_operator"
12934                         [(match_operand 1 "register_operand" "f")
12935                          (match_operand 2 "register_operand" "f")])
12936           (pc)
12937           (label_ref (match_operand 3 "" ""))))
12938    (clobber (reg:CCFP 18))
12939    (clobber (reg:CCFP 17))]
12940   "TARGET_CMOVE && TARGET_80387
12941    && !SSE_FLOAT_MODE_P (GET_MODE (operands[1]))
12942    && FLOAT_MODE_P (GET_MODE (operands[1]))
12943    && GET_MODE (operands[1]) == GET_MODE (operands[2])
12944    && ix86_fp_jump_nontrivial_p (GET_CODE (operands[0]))"
12945   "#")
12946
12947 (define_insn "*fp_jcc_2_sse"
12948   [(set (pc)
12949         (if_then_else (match_operator 0 "comparison_operator"
12950                         [(match_operand 1 "register_operand" "f#x,x#f")
12951                          (match_operand 2 "nonimmediate_operand" "f#x,xm#f")])
12952           (pc)
12953           (label_ref (match_operand 3 "" ""))))
12954    (clobber (reg:CCFP 18))
12955    (clobber (reg:CCFP 17))]
12956   "TARGET_80387
12957    && SSE_FLOAT_MODE_P (GET_MODE (operands[1]))
12958    && GET_MODE (operands[1]) == GET_MODE (operands[2])
12959    && ix86_fp_jump_nontrivial_p (GET_CODE (operands[0]))"
12960   "#")
12961
12962 (define_insn "*fp_jcc_2_sse_only"
12963   [(set (pc)
12964         (if_then_else (match_operator 0 "comparison_operator"
12965                         [(match_operand 1 "register_operand" "x")
12966                          (match_operand 2 "nonimmediate_operand" "xm")])
12967           (pc)
12968           (label_ref (match_operand 3 "" ""))))
12969    (clobber (reg:CCFP 18))
12970    (clobber (reg:CCFP 17))]
12971   "SSE_FLOAT_MODE_P (GET_MODE (operands[1]))
12972    && GET_MODE (operands[1]) == GET_MODE (operands[2])
12973    && ix86_fp_jump_nontrivial_p (GET_CODE (operands[0]))"
12974   "#")
12975
12976 (define_insn "*fp_jcc_3"
12977   [(set (pc)
12978         (if_then_else (match_operator 0 "comparison_operator"
12979                         [(match_operand 1 "register_operand" "f")
12980                          (match_operand 2 "nonimmediate_operand" "fm")])
12981           (label_ref (match_operand 3 "" ""))
12982           (pc)))
12983    (clobber (reg:CCFP 18))
12984    (clobber (reg:CCFP 17))
12985    (clobber (match_scratch:HI 4 "=a"))]
12986   "TARGET_80387
12987    && (GET_MODE (operands[1]) == SFmode || GET_MODE (operands[1]) == DFmode)
12988    && GET_MODE (operands[1]) == GET_MODE (operands[2])
12989    && !ix86_use_fcomi_compare (GET_CODE (operands[0]))
12990    && SELECT_CC_MODE (GET_CODE (operands[0]),
12991                       operands[1], operands[2]) == CCFPmode
12992    && ix86_fp_jump_nontrivial_p (GET_CODE (operands[0]))"
12993   "#")
12994
12995 (define_insn "*fp_jcc_4"
12996   [(set (pc)
12997         (if_then_else (match_operator 0 "comparison_operator"
12998                         [(match_operand 1 "register_operand" "f")
12999                          (match_operand 2 "nonimmediate_operand" "fm")])
13000           (pc)
13001           (label_ref (match_operand 3 "" ""))))
13002    (clobber (reg:CCFP 18))
13003    (clobber (reg:CCFP 17))
13004    (clobber (match_scratch:HI 4 "=a"))]
13005   "TARGET_80387
13006    && (GET_MODE (operands[1]) == SFmode || GET_MODE (operands[1]) == DFmode)
13007    && GET_MODE (operands[1]) == GET_MODE (operands[2])
13008    && !ix86_use_fcomi_compare (GET_CODE (operands[0]))
13009    && SELECT_CC_MODE (GET_CODE (operands[0]),
13010                       operands[1], operands[2]) == CCFPmode
13011    && ix86_fp_jump_nontrivial_p (GET_CODE (operands[0]))"
13012   "#")
13013
13014 (define_insn "*fp_jcc_5"
13015   [(set (pc)
13016         (if_then_else (match_operator 0 "comparison_operator"
13017                         [(match_operand 1 "register_operand" "f")
13018                          (match_operand 2 "register_operand" "f")])
13019           (label_ref (match_operand 3 "" ""))
13020           (pc)))
13021    (clobber (reg:CCFP 18))
13022    (clobber (reg:CCFP 17))
13023    (clobber (match_scratch:HI 4 "=a"))]
13024   "TARGET_80387
13025    && FLOAT_MODE_P (GET_MODE (operands[1]))
13026    && GET_MODE (operands[1]) == GET_MODE (operands[2])
13027    && ix86_fp_jump_nontrivial_p (GET_CODE (operands[0]))"
13028   "#")
13029
13030 (define_insn "*fp_jcc_6"
13031   [(set (pc)
13032         (if_then_else (match_operator 0 "comparison_operator"
13033                         [(match_operand 1 "register_operand" "f")
13034                          (match_operand 2 "register_operand" "f")])
13035           (pc)
13036           (label_ref (match_operand 3 "" ""))))
13037    (clobber (reg:CCFP 18))
13038    (clobber (reg:CCFP 17))
13039    (clobber (match_scratch:HI 4 "=a"))]
13040   "TARGET_80387
13041    && FLOAT_MODE_P (GET_MODE (operands[1]))
13042    && GET_MODE (operands[1]) == GET_MODE (operands[2])
13043    && ix86_fp_jump_nontrivial_p (GET_CODE (operands[0]))"
13044   "#")
13045
13046 (define_split
13047   [(set (pc)
13048         (if_then_else (match_operator 0 "comparison_operator"
13049                         [(match_operand 1 "register_operand" "")
13050                          (match_operand 2 "nonimmediate_operand" "")])
13051           (match_operand 3 "" "")
13052           (match_operand 4 "" "")))
13053    (clobber (reg:CCFP 18))
13054    (clobber (reg:CCFP 17))]
13055   "reload_completed"
13056   [(const_int 0)]
13057 {
13058   ix86_split_fp_branch (GET_CODE (operands[0]), operands[1], operands[2],
13059                         operands[3], operands[4], NULL_RTX);
13060   DONE;
13061 })
13062
13063 (define_split
13064   [(set (pc)
13065         (if_then_else (match_operator 0 "comparison_operator"
13066                         [(match_operand 1 "register_operand" "")
13067                          (match_operand 2 "nonimmediate_operand" "")])
13068           (match_operand 3 "" "")
13069           (match_operand 4 "" "")))
13070    (clobber (reg:CCFP 18))
13071    (clobber (reg:CCFP 17))
13072    (clobber (match_scratch:HI 5 "=a"))]
13073   "reload_completed"
13074   [(set (pc)
13075         (if_then_else (match_dup 6)
13076           (match_dup 3)
13077           (match_dup 4)))]
13078 {
13079   ix86_split_fp_branch (GET_CODE (operands[0]), operands[1], operands[2],
13080                         operands[3], operands[4], operands[5]);
13081   DONE;
13082 })
13083 \f
13084 ;; Unconditional and other jump instructions
13085
13086 (define_insn "jump"
13087   [(set (pc)
13088         (label_ref (match_operand 0 "" "")))]
13089   ""
13090   "jmp\t%l0"
13091   [(set_attr "type" "ibr")])
13092
13093 (define_expand "indirect_jump"
13094   [(set (pc) (match_operand 0 "nonimmediate_operand" "rm"))]
13095   ""
13096   "")
13097
13098 (define_insn "*indirect_jump"
13099   [(set (pc) (match_operand:SI 0 "nonimmediate_operand" "rm"))]
13100   "!TARGET_64BIT"
13101   "jmp\t%A0"
13102   [(set_attr "type" "ibr")
13103    (set_attr "length_immediate" "0")])
13104
13105 (define_insn "*indirect_jump_rtx64"
13106   [(set (pc) (match_operand:DI 0 "nonimmediate_operand" "rm"))]
13107   "TARGET_64BIT"
13108   "jmp\t%A0"
13109   [(set_attr "type" "ibr")
13110    (set_attr "length_immediate" "0")])
13111
13112 (define_expand "tablejump"
13113   [(parallel [(set (pc) (match_operand 0 "nonimmediate_operand" "rm"))
13114               (use (label_ref (match_operand 1 "" "")))])]
13115   ""
13116 {
13117   /* In PIC mode, the table entries are stored GOT-relative.  Convert
13118      the relative address to an absolute address.  */
13119   if (flag_pic)
13120     {
13121       if (TARGET_64BIT)
13122         operands[0] = expand_simple_binop (Pmode, PLUS, operands[0],
13123                                            gen_rtx_LABEL_REF (Pmode, operands[1]),
13124                                            NULL_RTX, 0,
13125                                            OPTAB_DIRECT);
13126       else if (HAVE_AS_GOTOFF_IN_DATA)
13127         {
13128           operands[0] = expand_simple_binop (Pmode, PLUS, operands[0],
13129                                              pic_offset_table_rtx, NULL_RTX,
13130                                              1, OPTAB_DIRECT);
13131           current_function_uses_pic_offset_table = 1;
13132         }
13133       else
13134         {
13135           operands[0] = expand_simple_binop (Pmode, MINUS, pic_offset_table_rtx,
13136                                              operands[0], NULL_RTX, 1,
13137                                              OPTAB_DIRECT);
13138           current_function_uses_pic_offset_table = 1;
13139         }
13140     }
13141 })
13142
13143 (define_insn "*tablejump_1"
13144   [(set (pc) (match_operand:SI 0 "nonimmediate_operand" "rm"))
13145    (use (label_ref (match_operand 1 "" "")))]
13146   "!TARGET_64BIT"
13147   "jmp\t%A0"
13148   [(set_attr "type" "ibr")
13149    (set_attr "length_immediate" "0")])
13150
13151 (define_insn "*tablejump_1_rtx64"
13152   [(set (pc) (match_operand:DI 0 "nonimmediate_operand" "rm"))
13153    (use (label_ref (match_operand 1 "" "")))]
13154   "TARGET_64BIT"
13155   "jmp\t%A0"
13156   [(set_attr "type" "ibr")
13157    (set_attr "length_immediate" "0")])
13158 \f
13159 ;; Loop instruction
13160 ;;
13161 ;; This is all complicated by the fact that since this is a jump insn
13162 ;; we must handle our own reloads.
13163
13164 (define_expand "doloop_end"
13165   [(use (match_operand 0 "" ""))        ; loop pseudo
13166    (use (match_operand 1 "" ""))        ; iterations; zero if unknown
13167    (use (match_operand 2 "" ""))        ; max iterations
13168    (use (match_operand 3 "" ""))        ; loop level 
13169    (use (match_operand 4 "" ""))]       ; label
13170   "!TARGET_64BIT && TARGET_USE_LOOP"
13171   "                                 
13172 {
13173   /* Only use cloop on innermost loops.  */
13174   if (INTVAL (operands[3]) > 1)
13175     FAIL;
13176   if (GET_MODE (operands[0]) != SImode)
13177     FAIL;
13178   emit_jump_insn (gen_doloop_end_internal (operands[4], operands[0],
13179                                            operands[0]));
13180   DONE;
13181 }")
13182
13183 (define_insn "doloop_end_internal"
13184   [(set (pc)
13185         (if_then_else (ne (match_operand:SI 1 "register_operand" "c,?*r,?*r")
13186                           (const_int 1))
13187                       (label_ref (match_operand 0 "" ""))
13188                       (pc)))
13189    (set (match_operand:SI 2 "register_operand" "=1,1,*m*r")
13190         (plus:SI (match_dup 1)
13191                  (const_int -1)))
13192    (clobber (match_scratch:SI 3 "=X,X,r"))
13193    (clobber (reg:CC 17))]
13194   "!TARGET_64BIT && TARGET_USE_LOOP"
13195 {
13196   if (which_alternative != 0)
13197     return "#";
13198   if (get_attr_length (insn) == 2)
13199     return "%+loop\t%l0";
13200   else
13201     return "dec{l}\t%1\;%+jne\t%l0";
13202 }
13203   [(set_attr "ppro_uops" "many")
13204    (set (attr "type")
13205         (if_then_else (and (eq_attr "alternative" "0")
13206                            (and (ge (minus (match_dup 0) (pc))
13207                                     (const_int -128))
13208                                 (lt (minus (match_dup 0) (pc))
13209                                     (const_int 124))))
13210                       (const_string "ibr")
13211                       (const_string "multi")))])
13212
13213 (define_split
13214   [(set (pc)
13215         (if_then_else (ne (match_operand:SI 1 "register_operand" "")
13216                           (const_int 1))
13217                       (match_operand 0 "" "")
13218                       (pc)))
13219    (set (match_dup 1)
13220         (plus:SI (match_dup 1)
13221                  (const_int -1)))
13222    (clobber (match_scratch:SI 2 ""))
13223    (clobber (reg:CC 17))]
13224   "!TARGET_64BIT && TARGET_USE_LOOP
13225    && reload_completed
13226    && REGNO (operands[1]) != 2"
13227   [(parallel [(set (reg:CCZ 17)
13228                    (compare:CCZ (plus:SI (match_dup 1) (const_int -1))
13229                                  (const_int 0)))
13230               (set (match_dup 1) (plus:SI (match_dup 1) (const_int -1)))])
13231    (set (pc) (if_then_else (ne (reg:CCZ 17) (const_int 0))
13232                            (match_dup 0)
13233                            (pc)))]
13234   "")
13235   
13236 (define_split
13237   [(set (pc)
13238         (if_then_else (ne (match_operand:SI 1 "register_operand" "")
13239                           (const_int 1))
13240                       (match_operand 0 "" "")
13241                       (pc)))
13242    (set (match_operand:SI 2 "nonimmediate_operand" "")
13243         (plus:SI (match_dup 1)
13244                  (const_int -1)))
13245    (clobber (match_scratch:SI 3 ""))
13246    (clobber (reg:CC 17))]
13247   "!TARGET_64BIT && TARGET_USE_LOOP
13248    && reload_completed
13249    && (! REG_P (operands[2])
13250        || ! rtx_equal_p (operands[1], operands[2]))"
13251   [(set (match_dup 3) (match_dup 1))
13252    (parallel [(set (reg:CCZ 17)
13253                    (compare:CCZ (plus:SI (match_dup 3) (const_int -1))
13254                                 (const_int 0)))
13255               (set (match_dup 3) (plus:SI (match_dup 3) (const_int -1)))])
13256    (set (match_dup 2) (match_dup 3))
13257    (set (pc) (if_then_else (ne (reg:CCZ 17) (const_int 0))
13258                            (match_dup 0)
13259                            (pc)))]
13260   "")
13261
13262 ;; Convert setcc + movzbl to xor + setcc if operands don't overlap.
13263
13264 (define_peephole2
13265   [(set (reg 17) (match_operand 0 "" ""))
13266    (set (match_operand:QI 1 "register_operand" "")
13267         (match_operator:QI 2 "ix86_comparison_operator"
13268           [(reg 17) (const_int 0)]))
13269    (set (match_operand 3 "q_regs_operand" "")
13270         (zero_extend (match_dup 1)))]
13271   "(peep2_reg_dead_p (3, operands[1])
13272     || operands_match_p (operands[1], operands[3]))
13273    && ! reg_overlap_mentioned_p (operands[3], operands[0])"
13274   [(set (match_dup 4) (match_dup 0))
13275    (set (strict_low_part (match_dup 5))
13276         (match_dup 2))]
13277 {
13278   operands[4] = gen_rtx_REG (GET_MODE (operands[0]), 17);
13279   operands[5] = gen_rtx_REG (QImode, REGNO (operands[3]));
13280   ix86_expand_clear (operands[3]);
13281 })
13282
13283 ;; Similar, but match zero_extendhisi2_and, which adds a clobber.
13284
13285 (define_peephole2
13286   [(set (reg 17) (match_operand 0 "" ""))
13287    (set (match_operand:QI 1 "register_operand" "")
13288         (match_operator:QI 2 "ix86_comparison_operator"
13289           [(reg 17) (const_int 0)]))
13290    (parallel [(set (match_operand 3 "q_regs_operand" "")
13291                    (zero_extend (match_dup 1)))
13292               (clobber (reg:CC 17))])]
13293   "(peep2_reg_dead_p (3, operands[1])
13294     || operands_match_p (operands[1], operands[3]))
13295    && ! reg_overlap_mentioned_p (operands[3], operands[0])"
13296   [(set (match_dup 4) (match_dup 0))
13297    (set (strict_low_part (match_dup 5))
13298         (match_dup 2))]
13299 {
13300   operands[4] = gen_rtx_REG (GET_MODE (operands[0]), 17);
13301   operands[5] = gen_rtx_REG (QImode, REGNO (operands[3]));
13302   ix86_expand_clear (operands[3]);
13303 })
13304 \f
13305 ;; Call instructions.
13306
13307 ;; The predicates normally associated with named expanders are not properly
13308 ;; checked for calls.  This is a bug in the generic code, but it isn't that
13309 ;; easy to fix.  Ignore it for now and be prepared to fix things up.
13310
13311 ;; Call subroutine returning no value.
13312
13313 (define_expand "call_pop"
13314   [(parallel [(call (match_operand:QI 0 "" "")
13315                     (match_operand:SI 1 "" ""))
13316               (set (reg:SI 7)
13317                    (plus:SI (reg:SI 7)
13318                             (match_operand:SI 3 "" "")))])]
13319   "!TARGET_64BIT"
13320 {
13321   if (operands[3] == const0_rtx)
13322     {
13323       emit_insn (gen_call (operands[0], operands[1], constm1_rtx));
13324       DONE;
13325     }
13326   /* Static functions and indirect calls don't need
13327      current_function_uses_pic_offset_table.  */
13328   if (flag_pic
13329       && GET_CODE (XEXP (operands[0], 0)) == SYMBOL_REF
13330       && ! SYMBOL_REF_FLAG (XEXP (operands[0], 0)))
13331     current_function_uses_pic_offset_table = 1;
13332   if (! call_insn_operand (XEXP (operands[0], 0), Pmode))
13333     XEXP (operands[0], 0) = copy_to_mode_reg (Pmode, XEXP (operands[0], 0));
13334   if (TARGET_64BIT)
13335     abort();
13336 })
13337
13338 (define_insn "*call_pop_0"
13339   [(call (mem:QI (match_operand:SI 0 "constant_call_address_operand" ""))
13340          (match_operand:SI 1 "" ""))
13341    (set (reg:SI 7) (plus:SI (reg:SI 7)
13342                             (match_operand:SI 2 "immediate_operand" "")))]
13343   "!TARGET_64BIT"
13344 {
13345   if (SIBLING_CALL_P (insn))
13346     return "jmp\t%P0";
13347   else
13348     return "call\t%P0";
13349 }
13350   [(set_attr "type" "call")])
13351   
13352 (define_insn "*call_pop_1"
13353   [(call (mem:QI (match_operand:SI 0 "call_insn_operand" "rsm"))
13354          (match_operand:SI 1 "" ""))
13355    (set (reg:SI 7) (plus:SI (reg:SI 7)
13356                             (match_operand:SI 2 "immediate_operand" "i")))]
13357   "!TARGET_64BIT"
13358 {
13359   if (constant_call_address_operand (operands[0], Pmode))
13360     {
13361       if (SIBLING_CALL_P (insn))
13362         return "jmp\t%P0";
13363       else
13364         return "call\t%P0";
13365     }
13366   if (SIBLING_CALL_P (insn))
13367     return "jmp\t%A0";
13368   else
13369     return "call\t%A0";
13370 }
13371   [(set_attr "type" "call")])
13372
13373 (define_expand "call"
13374   [(call (match_operand:QI 0 "" "")
13375          (match_operand 1 "" ""))
13376    (use (match_operand 2 "" ""))]
13377   ;; Operand 1 not used on the i386.
13378   ""
13379 {
13380   rtx insn;
13381   /* Static functions and indirect calls don't need
13382      current_function_uses_pic_offset_table.  */
13383   if (flag_pic
13384       && GET_CODE (XEXP (operands[0], 0)) == SYMBOL_REF
13385       && ! SYMBOL_REF_FLAG (XEXP (operands[0], 0)))
13386     current_function_uses_pic_offset_table = 1;
13387
13388   if (! call_insn_operand (XEXP (operands[0], 0), Pmode))
13389     XEXP (operands[0], 0) = copy_to_mode_reg (Pmode, XEXP (operands[0], 0));
13390   if (TARGET_64BIT && INTVAL (operands[2]) >= 0)
13391     {
13392       rtx reg = gen_rtx_REG (QImode, 0);
13393       emit_move_insn (reg, operands[2]);
13394       insn = emit_call_insn (gen_call_exp (operands[0], operands[1]));
13395       use_reg (&CALL_INSN_FUNCTION_USAGE (insn), reg);
13396       DONE;
13397     }
13398    insn = emit_call_insn (gen_call_exp (operands[0], operands[1]));
13399    DONE;
13400 })
13401
13402 (define_expand "call_exp"
13403   [(call (match_operand:QI 0 "" "")
13404          (match_operand 1 "" ""))]
13405   ""
13406   "")
13407
13408 (define_insn "*call_0"
13409   [(call (mem:QI (match_operand 0 "constant_call_address_operand" ""))
13410          (match_operand 1 "" ""))]
13411   ""
13412 {
13413   if (SIBLING_CALL_P (insn))
13414     return "jmp\t%P0";
13415   else
13416     return "call\t%P0";
13417 }
13418   [(set_attr "type" "call")])
13419
13420 (define_insn "*call_1"
13421   [(call (mem:QI (match_operand:SI 0 "call_insn_operand" "rsm"))
13422          (match_operand 1 "" ""))]
13423   "!TARGET_64BIT"
13424 {
13425   if (constant_call_address_operand (operands[0], QImode))
13426     {
13427       if (SIBLING_CALL_P (insn))
13428         return "jmp\t%P0";
13429       else
13430         return "call\t%P0";
13431     }
13432   if (SIBLING_CALL_P (insn))
13433     return "jmp\t%A0";
13434   else
13435     return "call\t%A0";
13436 }
13437   [(set_attr "type" "call")])
13438
13439 (define_insn "*call_1_rex64"
13440   [(call (mem:QI (match_operand:DI 0 "call_insn_operand" "rsm"))
13441          (match_operand 1 "" ""))]
13442   "TARGET_64BIT"
13443 {
13444   if (constant_call_address_operand (operands[0], QImode))
13445     {
13446       if (SIBLING_CALL_P (insn))
13447         return "jmp\t%P0";
13448       else
13449         return "call\t%P0";
13450     }
13451   if (SIBLING_CALL_P (insn))
13452     return "jmp\t%A0";
13453   else
13454     return "call\t%A0";
13455 }
13456   [(set_attr "type" "call")])
13457
13458 ;; Call subroutine, returning value in operand 0
13459 ;; (which must be a hard register).
13460
13461 (define_expand "call_value_pop"
13462   [(parallel [(set (match_operand 0 "" "")
13463                    (call (match_operand:QI 1 "" "")
13464                          (match_operand:SI 2 "" "")))
13465               (set (reg:SI 7)
13466                    (plus:SI (reg:SI 7)
13467                             (match_operand:SI 4 "" "")))])]
13468   "!TARGET_64BIT"
13469 {
13470   if (operands[4] == const0_rtx)
13471     {
13472       emit_insn (gen_call_value (operands[0], operands[1], operands[2],
13473                                  constm1_rtx));
13474       DONE;
13475     }
13476   /* Static functions and indirect calls don't need
13477      current_function_uses_pic_offset_table.  */
13478   if (flag_pic
13479       && GET_CODE (XEXP (operands[1], 0)) == SYMBOL_REF
13480       && ! SYMBOL_REF_FLAG (XEXP (operands[1], 0)))
13481     current_function_uses_pic_offset_table = 1;
13482   if (! call_insn_operand (XEXP (operands[1], 0), Pmode))
13483     XEXP (operands[1], 0) = copy_to_mode_reg (Pmode, XEXP (operands[1], 0));
13484 })
13485
13486 (define_expand "call_value"
13487   [(set (match_operand 0 "" "")
13488         (call (match_operand:QI 1 "" "")
13489               (match_operand:SI 2 "" "")))
13490    (use (match_operand:SI 3 "" ""))]
13491   ;; Operand 2 not used on the i386.
13492   ""
13493 {
13494   rtx insn;
13495   /* Static functions and indirect calls don't need
13496      current_function_uses_pic_offset_table.  */
13497   if (flag_pic
13498       && GET_CODE (XEXP (operands[1], 0)) == SYMBOL_REF
13499       && ! SYMBOL_REF_FLAG (XEXP (operands[1], 0)))
13500     current_function_uses_pic_offset_table = 1;
13501   if (! call_insn_operand (XEXP (operands[1], 0), Pmode))
13502     XEXP (operands[1], 0) = copy_to_mode_reg (Pmode, XEXP (operands[1], 0));
13503   if (TARGET_64BIT && INTVAL (operands[3]) >= 0)
13504     {
13505       rtx reg = gen_rtx_REG (QImode, 0);
13506       emit_move_insn (reg, operands[3]);
13507       insn = emit_call_insn (gen_call_value_exp (operands[0], operands[1],
13508                                                  operands[2]));
13509       use_reg (&CALL_INSN_FUNCTION_USAGE (insn), reg);
13510       DONE;
13511     }
13512   insn = emit_call_insn (gen_call_value_exp (operands[0], operands[1],
13513                                              operands[2]));
13514   DONE;
13515 })
13516
13517 (define_expand "call_value_exp"
13518   [(set (match_operand 0 "" "")
13519         (call (match_operand:QI 1 "" "")
13520               (match_operand:SI 2 "" "")))]
13521   ""
13522   "")
13523
13524 ;; Call subroutine returning any type.
13525
13526 (define_expand "untyped_call"
13527   [(parallel [(call (match_operand 0 "" "")
13528                     (const_int 0))
13529               (match_operand 1 "" "")
13530               (match_operand 2 "" "")])]
13531   ""
13532 {
13533   int i;
13534
13535   /* In order to give reg-stack an easier job in validating two
13536      coprocessor registers as containing a possible return value,
13537      simply pretend the untyped call returns a complex long double
13538      value.  */
13539
13540   emit_call_insn (TARGET_80387
13541                   ? gen_call_value (gen_rtx_REG (XCmode, FIRST_FLOAT_REG),
13542                                     operands[0], const0_rtx,
13543                                     GEN_INT (SSE_REGPARM_MAX - 1))
13544                   : gen_call (operands[0], const0_rtx,
13545                               GEN_INT (SSE_REGPARM_MAX - 1)));
13546
13547   for (i = 0; i < XVECLEN (operands[2], 0); i++)
13548     {
13549       rtx set = XVECEXP (operands[2], 0, i);
13550       emit_move_insn (SET_DEST (set), SET_SRC (set));
13551     }
13552
13553   /* The optimizer does not know that the call sets the function value
13554      registers we stored in the result block.  We avoid problems by
13555      claiming that all hard registers are used and clobbered at this
13556      point.  */
13557   emit_insn (gen_blockage ());
13558
13559   DONE;
13560 })
13561 \f
13562 ;; Prologue and epilogue instructions
13563
13564 ;; UNSPEC_VOLATILE is considered to use and clobber all hard registers and
13565 ;; all of memory.  This blocks insns from being moved across this point.
13566
13567 (define_insn "blockage"
13568   [(unspec_volatile [(const_int 0)] 0)]
13569   ""
13570   ""
13571   [(set_attr "length" "0")])
13572
13573 ;; Insn emitted into the body of a function to return from a function.
13574 ;; This is only done if the function's epilogue is known to be simple.
13575 ;; See comments for ix86_can_use_return_insn_p in i386.c.
13576
13577 (define_expand "return"
13578   [(return)]
13579   "ix86_can_use_return_insn_p ()"
13580 {
13581   if (current_function_pops_args)
13582     {
13583       rtx popc = GEN_INT (current_function_pops_args);
13584       emit_jump_insn (gen_return_pop_internal (popc));
13585       DONE;
13586     }
13587 })
13588
13589 (define_insn "return_internal"
13590   [(return)]
13591   "reload_completed"
13592   "ret"
13593   [(set_attr "length" "1")
13594    (set_attr "length_immediate" "0")
13595    (set_attr "modrm" "0")])
13596
13597 (define_insn "return_pop_internal"
13598   [(return)
13599    (use (match_operand:SI 0 "const_int_operand" ""))]
13600   "reload_completed"
13601   "ret\t%0"
13602   [(set_attr "length" "3")
13603    (set_attr "length_immediate" "2")
13604    (set_attr "modrm" "0")])
13605
13606 (define_insn "return_indirect_internal"
13607   [(return)
13608    (use (match_operand:SI 0 "register_operand" "r"))]
13609   "reload_completed"
13610   "jmp\t%A0"
13611   [(set_attr "type" "ibr")
13612    (set_attr "length_immediate" "0")])
13613
13614 (define_insn "nop"
13615   [(const_int 0)]
13616   ""
13617   "nop"
13618   [(set_attr "length" "1")
13619    (set_attr "length_immediate" "0")
13620    (set_attr "modrm" "0")
13621    (set_attr "ppro_uops" "one")])
13622
13623 (define_expand "prologue"
13624   [(const_int 1)]
13625   ""
13626   "ix86_expand_prologue (); DONE;")
13627
13628 (define_insn "prologue_set_got"
13629   [(set (match_operand:SI 0 "register_operand" "=r")
13630         (unspec_volatile:SI
13631          [(plus:SI (match_dup 0)
13632                    (plus:SI (match_operand:SI 1 "symbolic_operand" "")
13633                             (minus:SI (pc) (match_operand 2 "" ""))))] 1))
13634    (clobber (reg:CC 17))]
13635   "!TARGET_64BIT"
13636 {
13637   if (GET_CODE (operands[2]) == LABEL_REF)
13638      operands[2] = XEXP (operands[2], 0);
13639   if (TARGET_DEEP_BRANCH_PREDICTION) 
13640     return "add{l}\t{%1, %0|%0, %1}";
13641   else  
13642     return "add{l}\t{%1+[.-%X2], %0|%0, %a1+(.-%X2)}";
13643 }
13644   [(set_attr "type" "alu")
13645    ; Since this insn may have two constant operands, we must set the
13646    ; length manually.
13647    (set_attr "length_immediate" "4")
13648    (set_attr "mode" "SI")])
13649
13650 (define_insn "prologue_get_pc"
13651   [(set (match_operand:SI 0 "register_operand" "=r")
13652     (unspec_volatile:SI [(plus:SI (pc) (match_operand 1 "" ""))] 2))]
13653   "!TARGET_64BIT"
13654 {
13655   if (GET_CODE (operands[1]) == LABEL_REF)
13656     operands[1] = XEXP (operands[1], 0);
13657   output_asm_insn ("call\t%X1", operands);
13658   if (! TARGET_DEEP_BRANCH_PREDICTION)
13659     {
13660       ASM_OUTPUT_INTERNAL_LABEL (asm_out_file, "L",
13661                                  CODE_LABEL_NUMBER (operands[1]));
13662     }
13663   RET;
13664 }
13665   [(set_attr "type" "multi")])
13666
13667 (define_expand "epilogue"
13668   [(const_int 1)]
13669   ""
13670   "ix86_expand_epilogue (1); DONE;")
13671
13672 (define_expand "sibcall_epilogue"
13673   [(const_int 1)]
13674   ""
13675   "ix86_expand_epilogue (0); DONE;")
13676
13677 (define_expand "eh_return"
13678   [(use (match_operand 0 "register_operand" ""))
13679    (use (match_operand 1 "register_operand" ""))]
13680   ""
13681 {
13682   rtx tmp, sa = operands[0], ra = operands[1];
13683
13684   /* Tricky bit: we write the address of the handler to which we will
13685      be returning into someone else's stack frame, one word below the
13686      stack address we wish to restore.  */
13687   tmp = gen_rtx_PLUS (Pmode, arg_pointer_rtx, sa);
13688   tmp = plus_constant (tmp, -UNITS_PER_WORD);
13689   tmp = gen_rtx_MEM (Pmode, tmp);
13690   emit_move_insn (tmp, ra);
13691
13692   if (Pmode == SImode)
13693     emit_insn (gen_eh_return_si (sa));
13694   else
13695     emit_insn (gen_eh_return_di (sa));
13696   emit_barrier ();
13697   DONE;
13698 })
13699
13700 (define_insn_and_split "eh_return_si"
13701   [(unspec_volatile [(match_operand:SI 0 "register_operand" "c")] 13)]
13702   "!TARGET_64BIT"
13703   "#"
13704   "reload_completed"
13705   [(const_int 1)]
13706   "ix86_expand_epilogue (2); DONE;")
13707
13708 (define_insn_and_split "eh_return_di"
13709   [(unspec_volatile [(match_operand:DI 0 "register_operand" "c")] 13)]
13710   "TARGET_64BIT"
13711   "#"
13712   "reload_completed"
13713   [(const_int 1)]
13714   "ix86_expand_epilogue (2); DONE;")
13715
13716 (define_insn "leave"
13717   [(set (reg:SI 7) (reg:SI 6))
13718    (set (reg:SI 6) (mem:SI (pre_dec:SI (reg:SI 7))))
13719    (clobber (mem:BLK (scratch)))]
13720   "!TARGET_64BIT"
13721   "leave"
13722   [(set_attr "length_immediate" "0")
13723    (set_attr "length" "1")
13724    (set_attr "modrm" "0")
13725    (set_attr "modrm" "0")
13726    (set_attr "athlon_decode" "vector")
13727    (set_attr "ppro_uops" "few")])
13728
13729 (define_insn "leave_rex64"
13730   [(set (reg:DI 7) (reg:DI 6))
13731    (set (reg:DI 6) (mem:DI (pre_dec:DI (reg:DI 7))))
13732    (clobber (mem:BLK (scratch)))]
13733   "TARGET_64BIT"
13734   "leave"
13735   [(set_attr "length_immediate" "0")
13736    (set_attr "length" "1")
13737    (set_attr "modrm" "0")
13738    (set_attr "modrm" "0")
13739    (set_attr "athlon_decode" "vector")
13740    (set_attr "ppro_uops" "few")])
13741 \f
13742 (define_expand "ffssi2"
13743   [(set (match_operand:SI 0 "nonimmediate_operand" "") 
13744         (ffs:SI (match_operand:SI 1 "general_operand" "")))]
13745   ""
13746 {
13747   rtx out = gen_reg_rtx (SImode), tmp = gen_reg_rtx (SImode);
13748   rtx in = operands[1];
13749
13750   if (TARGET_CMOVE)
13751     {
13752       emit_move_insn (tmp, constm1_rtx);
13753       emit_insn (gen_ffssi_1 (out, in));
13754       emit_insn (gen_rtx_SET (VOIDmode, out,
13755                   gen_rtx_IF_THEN_ELSE (SImode, 
13756                     gen_rtx_EQ (VOIDmode, gen_rtx_REG (CCZmode, FLAGS_REG),
13757                                 const0_rtx),
13758                     tmp,
13759                     out)));
13760       emit_insn (gen_addsi3 (out, out, const1_rtx));
13761       emit_move_insn (operands[0], out);
13762     }
13763
13764   /* Pentium bsf instruction is extremly slow.  The following code is
13765      recommended by the Intel Optimizing Manual as a reasonable replacement:
13766            TEST    EAX,EAX
13767            JZ      SHORT BS2
13768            XOR     ECX,ECX
13769            MOV     DWORD PTR [TEMP+4],ECX
13770            SUB     ECX,EAX
13771            AND     EAX,ECX
13772            MOV     DWORD PTR [TEMP],EAX
13773            FILD    QWORD PTR [TEMP]
13774            FSTP    QWORD PTR [TEMP]
13775            WAIT    ; WAIT only needed for compatibility with
13776                    ; earlier processors
13777            MOV     ECX, DWORD PTR [TEMP+4]
13778            SHR     ECX,20
13779            SUB     ECX,3FFH
13780            TEST    EAX,EAX       ; clear zero flag
13781        BS2:
13782      Following piece of code expand ffs to similar beast.
13783        */
13784
13785   else if (TARGET_PENTIUM && !optimize_size && TARGET_80387)
13786     {
13787       rtx label = gen_label_rtx ();
13788       rtx lo, hi;
13789       rtx mem = assign_386_stack_local (DImode, 0);
13790       rtx fptmp = gen_reg_rtx (DFmode);
13791       split_di (&mem, 1, &lo, &hi);
13792
13793       emit_move_insn (out, const0_rtx);
13794
13795       emit_cmp_and_jump_insns (in, const0_rtx, EQ, 0, SImode, 1, label);
13796
13797       emit_move_insn (hi, out);
13798       emit_insn (gen_subsi3 (out, out, in));
13799       emit_insn (gen_andsi3 (out, out, in));
13800       emit_move_insn (lo, out);
13801       emit_insn (gen_floatdidf2 (fptmp,mem));
13802       emit_move_insn (gen_rtx_MEM (DFmode, XEXP (mem, 0)), fptmp);
13803       emit_move_insn (out, hi);
13804       emit_insn (gen_lshrsi3 (out, out, GEN_INT (20)));
13805       emit_insn (gen_subsi3 (out, out, GEN_INT (0x3ff - 1)));
13806
13807       emit_label (label);
13808       LABEL_NUSES (label) = 1;
13809
13810       emit_move_insn (operands[0], out);
13811     }
13812   else
13813     {
13814       emit_move_insn (tmp, const0_rtx);
13815       emit_insn (gen_ffssi_1 (out, in));
13816       emit_insn (gen_rtx_SET (VOIDmode, 
13817                   gen_rtx_STRICT_LOW_PART (VOIDmode, gen_lowpart (QImode, tmp)),
13818                   gen_rtx_EQ (QImode, gen_rtx_REG (CCZmode, FLAGS_REG),
13819                               const0_rtx)));
13820       emit_insn (gen_negsi2 (tmp, tmp));
13821       emit_insn (gen_iorsi3 (out, out, tmp));
13822       emit_insn (gen_addsi3 (out, out, const1_rtx));
13823       emit_move_insn (operands[0], out);
13824     }
13825   DONE;  
13826 })
13827
13828 (define_insn "ffssi_1"
13829   [(set (reg:CCZ 17)
13830         (compare:CCZ (match_operand:SI 1 "nonimmediate_operand" "rm")
13831                      (const_int 0)))
13832    (set (match_operand:SI 0 "register_operand" "=r")
13833         (unspec:SI [(match_dup 1)] 5))]
13834   ""
13835   "bsf{l}\t{%1, %0|%0, %1}"
13836   [(set_attr "prefix_0f" "1")
13837    (set_attr "ppro_uops" "few")])
13838
13839 ;; ffshi2 is not useful -- 4 word prefix ops are needed, which is larger
13840 ;; and slower than the two-byte movzx insn needed to do the work in SImode.
13841 \f
13842 ;; These patterns match the binary 387 instructions for addM3, subM3,
13843 ;; mulM3 and divM3.  There are three patterns for each of DFmode and
13844 ;; SFmode.  The first is the normal insn, the second the same insn but
13845 ;; with one operand a conversion, and the third the same insn but with
13846 ;; the other operand a conversion.  The conversion may be SFmode or
13847 ;; SImode if the target mode DFmode, but only SImode if the target mode
13848 ;; is SFmode.
13849
13850 ;; Gcc is slightly more smart about handling normal two address instructions
13851 ;; so use special patterns for add and mull.
13852 (define_insn "*fop_sf_comm"
13853   [(set (match_operand:SF 0 "register_operand" "=f#x,x#f")
13854         (match_operator:SF 3 "binary_fp_operator"
13855                         [(match_operand:SF 1 "register_operand" "%0,0")
13856                          (match_operand:SF 2 "nonimmediate_operand" "fm#x,xm#f")]))]
13857   "TARGET_80387 && (!TARGET_SSE || TARGET_MIX_SSE_I387)
13858    && GET_RTX_CLASS (GET_CODE (operands[3])) == 'c'"
13859   "* return output_387_binary_op (insn, operands);"
13860   [(set (attr "type") 
13861         (if_then_else (eq_attr "alternative" "1")
13862            (const_string "sse")
13863            (if_then_else (match_operand:SF 3 "mult_operator" "") 
13864               (const_string "fmul")
13865               (const_string "fop"))))
13866    (set_attr "mode" "SF")])
13867
13868 (define_insn "*fop_sf_comm_sse"
13869   [(set (match_operand:SF 0 "register_operand" "=x")
13870         (match_operator:SF 3 "binary_fp_operator"
13871                         [(match_operand:SF 1 "register_operand" "%0")
13872                          (match_operand:SF 2 "nonimmediate_operand" "xm")]))]
13873   "TARGET_SSE && GET_RTX_CLASS (GET_CODE (operands[3])) == 'c'"
13874   "* return output_387_binary_op (insn, operands);"
13875   [(set_attr "type" "sse")
13876    (set_attr "mode" "SF")])
13877
13878 (define_insn "*fop_df_comm"
13879   [(set (match_operand:DF 0 "register_operand" "=f#Y,Y#f")
13880         (match_operator:DF 3 "binary_fp_operator"
13881                         [(match_operand:DF 1 "register_operand" "%0,0")
13882                          (match_operand:DF 2 "nonimmediate_operand" "fm#Y,Ym#f")]))]
13883   "TARGET_80387 && (!TARGET_SSE2 || TARGET_MIX_SSE_I387)
13884    && GET_RTX_CLASS (GET_CODE (operands[3])) == 'c'"
13885   "* return output_387_binary_op (insn, operands);"
13886   [(set (attr "type") 
13887         (if_then_else (eq_attr "alternative" "1")
13888            (const_string "sse")
13889            (if_then_else (match_operand:SF 3 "mult_operator" "") 
13890               (const_string "fmul")
13891               (const_string "fop"))))
13892    (set_attr "mode" "DF")])
13893
13894 (define_insn "*fop_df_comm_sse"
13895   [(set (match_operand:DF 0 "register_operand" "=Y")
13896         (match_operator:DF 3 "binary_fp_operator"
13897                         [(match_operand:DF 1 "register_operand" "%0")
13898                          (match_operand:DF 2 "nonimmediate_operand" "Ym")]))]
13899   "TARGET_SSE2
13900    && GET_RTX_CLASS (GET_CODE (operands[3])) == 'c'"
13901   "* return output_387_binary_op (insn, operands);"
13902   [(set_attr "type" "sse")
13903    (set_attr "mode" "DF")])
13904
13905 (define_insn "*fop_xf_comm"
13906   [(set (match_operand:XF 0 "register_operand" "=f")
13907         (match_operator:XF 3 "binary_fp_operator"
13908                         [(match_operand:XF 1 "register_operand" "%0")
13909                          (match_operand:XF 2 "register_operand" "f")]))]
13910   "!TARGET_64BIT && TARGET_80387
13911    && GET_RTX_CLASS (GET_CODE (operands[3])) == 'c'"
13912   "* return output_387_binary_op (insn, operands);"
13913   [(set (attr "type") 
13914         (if_then_else (match_operand:XF 3 "mult_operator" "") 
13915            (const_string "fmul")
13916            (const_string "fop")))
13917    (set_attr "mode" "XF")])
13918
13919 (define_insn "*fop_tf_comm"
13920   [(set (match_operand:TF 0 "register_operand" "=f")
13921         (match_operator:TF 3 "binary_fp_operator"
13922                         [(match_operand:TF 1 "register_operand" "%0")
13923                          (match_operand:TF 2 "register_operand" "f")]))]
13924   "TARGET_80387 && GET_RTX_CLASS (GET_CODE (operands[3])) == 'c'"
13925   "* return output_387_binary_op (insn, operands);"
13926   [(set (attr "type") 
13927         (if_then_else (match_operand:TF 3 "mult_operator" "") 
13928            (const_string "fmul")
13929            (const_string "fop")))
13930    (set_attr "mode" "XF")])
13931
13932 (define_insn "*fop_sf_1"
13933   [(set (match_operand:SF 0 "register_operand" "=f,f,x")
13934         (match_operator:SF 3 "binary_fp_operator"
13935                         [(match_operand:SF 1 "nonimmediate_operand" "0,fm,0")
13936                          (match_operand:SF 2 "nonimmediate_operand" "fm,0,xm#f")]))]
13937   "TARGET_80387 && (!TARGET_SSE || TARGET_MIX_SSE_I387)
13938    && GET_RTX_CLASS (GET_CODE (operands[3])) != 'c'
13939    && (GET_CODE (operands[1]) != MEM || GET_CODE (operands[2]) != MEM)"
13940   "* return output_387_binary_op (insn, operands);"
13941   [(set (attr "type") 
13942         (cond [(eq_attr "alternative" "2")
13943                  (const_string "sse")
13944                (match_operand:SF 3 "mult_operator" "") 
13945                  (const_string "fmul")
13946                (match_operand:SF 3 "div_operator" "") 
13947                  (const_string "fdiv")
13948               ]
13949               (const_string "fop")))
13950    (set_attr "mode" "SF")])
13951
13952 (define_insn "*fop_sf_1_sse"
13953   [(set (match_operand:SF 0 "register_operand" "=x")
13954         (match_operator:SF 3 "binary_fp_operator"
13955                         [(match_operand:SF 1 "register_operand" "0")
13956                          (match_operand:SF 2 "nonimmediate_operand" "xm")]))]
13957   "TARGET_SSE
13958    && GET_RTX_CLASS (GET_CODE (operands[3])) != 'c'"
13959   "* return output_387_binary_op (insn, operands);"
13960   [(set_attr "type" "sse")
13961    (set_attr "mode" "SF")])
13962
13963 ;; ??? Add SSE splitters for these!
13964 (define_insn "*fop_sf_2"
13965   [(set (match_operand:SF 0 "register_operand" "=f,f")
13966         (match_operator:SF 3 "binary_fp_operator"
13967           [(float:SF (match_operand:SI 1 "nonimmediate_operand" "m,?r"))
13968            (match_operand:SF 2 "register_operand" "0,0")]))]
13969   "TARGET_80387 && TARGET_USE_FIOP && !TARGET_SSE"
13970   "* return which_alternative ? \"#\" : output_387_binary_op (insn, operands);"
13971   [(set (attr "type") 
13972         (cond [(match_operand:SF 3 "mult_operator" "") 
13973                  (const_string "fmul")
13974                (match_operand:SF 3 "div_operator" "") 
13975                  (const_string "fdiv")
13976               ]
13977               (const_string "fop")))
13978    (set_attr "fp_int_src" "true")
13979    (set_attr "ppro_uops" "many")
13980    (set_attr "mode" "SI")])
13981
13982 (define_insn "*fop_sf_3"
13983   [(set (match_operand:SF 0 "register_operand" "=f,f")
13984         (match_operator:SF 3 "binary_fp_operator"
13985           [(match_operand:SF 1 "register_operand" "0,0")
13986            (float:SF (match_operand:SI 2 "nonimmediate_operand" "m,?r"))]))]
13987   "TARGET_80387 && TARGET_USE_FIOP && !TARGET_SSE"
13988   "* return which_alternative ? \"#\" : output_387_binary_op (insn, operands);"
13989   [(set (attr "type") 
13990         (cond [(match_operand:SF 3 "mult_operator" "") 
13991                  (const_string "fmul")
13992                (match_operand:SF 3 "div_operator" "") 
13993                  (const_string "fdiv")
13994               ]
13995               (const_string "fop")))
13996    (set_attr "fp_int_src" "true")
13997    (set_attr "ppro_uops" "many")
13998    (set_attr "mode" "SI")])
13999
14000 (define_insn "*fop_df_1"
14001   [(set (match_operand:DF 0 "register_operand" "=f#Y,f#Y,Y#f")
14002         (match_operator:DF 3 "binary_fp_operator"
14003                         [(match_operand:DF 1 "nonimmediate_operand" "0,fm,0")
14004                          (match_operand:DF 2 "nonimmediate_operand" "fm,0,Ym#f")]))]
14005   "TARGET_80387 && (!TARGET_SSE2 || TARGET_MIX_SSE_I387)
14006    && GET_RTX_CLASS (GET_CODE (operands[3])) != 'c'
14007    && (GET_CODE (operands[1]) != MEM || GET_CODE (operands[2]) != MEM)"
14008   "* return output_387_binary_op (insn, operands);"
14009   [(set (attr "type") 
14010         (cond [(eq_attr "alternative" "2")
14011                  (const_string "sse")
14012                (match_operand:DF 3 "mult_operator" "") 
14013                  (const_string "fmul")
14014                (match_operand:DF 3 "div_operator" "") 
14015                  (const_string "fdiv")
14016               ]
14017               (const_string "fop")))
14018    (set_attr "mode" "DF")])
14019
14020 (define_insn "*fop_df_1_sse"
14021   [(set (match_operand:DF 0 "register_operand" "=Y")
14022         (match_operator:DF 3 "binary_fp_operator"
14023                         [(match_operand:DF 1 "register_operand" "0")
14024                          (match_operand:DF 2 "nonimmediate_operand" "Ym")]))]
14025   "TARGET_SSE
14026    && GET_RTX_CLASS (GET_CODE (operands[3])) != 'c'"
14027   "* return output_387_binary_op (insn, operands);"
14028   [(set_attr "type" "sse")])
14029
14030 ;; ??? Add SSE splitters for these!
14031 (define_insn "*fop_df_2"
14032   [(set (match_operand:DF 0 "register_operand" "=f,f")
14033         (match_operator:DF 3 "binary_fp_operator"
14034            [(float:DF (match_operand:SI 1 "nonimmediate_operand" "m,?r"))
14035             (match_operand:DF 2 "register_operand" "0,0")]))]
14036   "TARGET_80387 && TARGET_USE_FIOP && !TARGET_SSE2"
14037   "* return which_alternative ? \"#\" : output_387_binary_op (insn, operands);"
14038   [(set (attr "type") 
14039         (cond [(match_operand:DF 3 "mult_operator" "") 
14040                  (const_string "fmul")
14041                (match_operand:DF 3 "div_operator" "") 
14042                  (const_string "fdiv")
14043               ]
14044               (const_string "fop")))
14045    (set_attr "fp_int_src" "true")
14046    (set_attr "ppro_uops" "many")
14047    (set_attr "mode" "SI")])
14048
14049 (define_insn "*fop_df_3"
14050   [(set (match_operand:DF 0 "register_operand" "=f,f")
14051         (match_operator:DF 3 "binary_fp_operator"
14052            [(match_operand:DF 1 "register_operand" "0,0")
14053             (float:DF (match_operand:SI 2 "nonimmediate_operand" "m,?r"))]))]
14054   "TARGET_80387 && TARGET_USE_FIOP && !TARGET_SSE2"
14055   "* return which_alternative ? \"#\" : output_387_binary_op (insn, operands);"
14056   [(set (attr "type") 
14057         (cond [(match_operand:DF 3 "mult_operator" "") 
14058                  (const_string "fmul")
14059                (match_operand:DF 3 "div_operator" "") 
14060                  (const_string "fdiv")
14061               ]
14062               (const_string "fop")))
14063    (set_attr "fp_int_src" "true")
14064    (set_attr "ppro_uops" "many")
14065    (set_attr "mode" "SI")])
14066
14067 (define_insn "*fop_df_4"
14068   [(set (match_operand:DF 0 "register_operand" "=f,f")
14069         (match_operator:DF 3 "binary_fp_operator"
14070            [(float_extend:DF (match_operand:SF 1 "nonimmediate_operand" "fm,0"))
14071             (match_operand:DF 2 "register_operand" "0,f")]))]
14072   "TARGET_80387
14073    && (GET_CODE (operands[1]) != MEM || GET_CODE (operands[2]) != MEM)"
14074   "* return output_387_binary_op (insn, operands);"
14075   [(set (attr "type") 
14076         (cond [(match_operand:DF 3 "mult_operator" "") 
14077                  (const_string "fmul")
14078                (match_operand:DF 3 "div_operator" "") 
14079                  (const_string "fdiv")
14080               ]
14081               (const_string "fop")))
14082    (set_attr "mode" "SF")])
14083
14084 (define_insn "*fop_df_5"
14085   [(set (match_operand:DF 0 "register_operand" "=f,f")
14086         (match_operator:DF 3 "binary_fp_operator"
14087           [(match_operand:DF 1 "register_operand" "0,f")
14088            (float_extend:DF
14089             (match_operand:SF 2 "nonimmediate_operand" "fm,0"))]))]
14090   "TARGET_80387 && !TARGET_SSE2"
14091   "* return output_387_binary_op (insn, operands);"
14092   [(set (attr "type") 
14093         (cond [(match_operand:DF 3 "mult_operator" "") 
14094                  (const_string "fmul")
14095                (match_operand:DF 3 "div_operator" "") 
14096                  (const_string "fdiv")
14097               ]
14098               (const_string "fop")))
14099    (set_attr "mode" "SF")])
14100
14101 (define_insn "*fop_xf_1"
14102   [(set (match_operand:XF 0 "register_operand" "=f,f")
14103         (match_operator:XF 3 "binary_fp_operator"
14104                         [(match_operand:XF 1 "register_operand" "0,f")
14105                          (match_operand:XF 2 "register_operand" "f,0")]))]
14106   "!TARGET_64BIT && TARGET_80387
14107    && GET_RTX_CLASS (GET_CODE (operands[3])) != 'c'"
14108   "* return output_387_binary_op (insn, operands);"
14109   [(set (attr "type") 
14110         (cond [(match_operand:XF 3 "mult_operator" "") 
14111                  (const_string "fmul")
14112                (match_operand:XF 3 "div_operator" "") 
14113                  (const_string "fdiv")
14114               ]
14115               (const_string "fop")))
14116    (set_attr "mode" "XF")])
14117
14118 (define_insn "*fop_tf_1"
14119   [(set (match_operand:TF 0 "register_operand" "=f,f")
14120         (match_operator:TF 3 "binary_fp_operator"
14121                         [(match_operand:TF 1 "register_operand" "0,f")
14122                          (match_operand:TF 2 "register_operand" "f,0")]))]
14123   "TARGET_80387
14124    && GET_RTX_CLASS (GET_CODE (operands[3])) != 'c'"
14125   "* return output_387_binary_op (insn, operands);"
14126   [(set (attr "type") 
14127         (cond [(match_operand:TF 3 "mult_operator" "") 
14128                  (const_string "fmul")
14129                (match_operand:TF 3 "div_operator" "") 
14130                  (const_string "fdiv")
14131               ]
14132               (const_string "fop")))
14133    (set_attr "mode" "XF")])
14134
14135 (define_insn "*fop_xf_2"
14136   [(set (match_operand:XF 0 "register_operand" "=f,f")
14137         (match_operator:XF 3 "binary_fp_operator"
14138            [(float:XF (match_operand:SI 1 "nonimmediate_operand" "m,?r"))
14139             (match_operand:XF 2 "register_operand" "0,0")]))]
14140   "!TARGET_64BIT && TARGET_80387 && TARGET_USE_FIOP"
14141   "* return which_alternative ? \"#\" : output_387_binary_op (insn, operands);"
14142   [(set (attr "type") 
14143         (cond [(match_operand:XF 3 "mult_operator" "") 
14144                  (const_string "fmul")
14145                (match_operand:XF 3 "div_operator" "") 
14146                  (const_string "fdiv")
14147               ]
14148               (const_string "fop")))
14149    (set_attr "fp_int_src" "true")
14150    (set_attr "mode" "SI")
14151    (set_attr "ppro_uops" "many")])
14152
14153 (define_insn "*fop_tf_2"
14154   [(set (match_operand:TF 0 "register_operand" "=f,f")
14155         (match_operator:TF 3 "binary_fp_operator"
14156            [(float:TF (match_operand:SI 1 "nonimmediate_operand" "m,?r"))
14157             (match_operand:TF 2 "register_operand" "0,0")]))]
14158   "TARGET_80387 && TARGET_USE_FIOP"
14159   "* return which_alternative ? \"#\" : output_387_binary_op (insn, operands);"
14160   [(set (attr "type") 
14161         (cond [(match_operand:TF 3 "mult_operator" "") 
14162                  (const_string "fmul")
14163                (match_operand:TF 3 "div_operator" "") 
14164                  (const_string "fdiv")
14165               ]
14166               (const_string "fop")))
14167    (set_attr "fp_int_src" "true")
14168    (set_attr "mode" "SI")
14169    (set_attr "ppro_uops" "many")])
14170
14171 (define_insn "*fop_xf_3"
14172   [(set (match_operand:XF 0 "register_operand" "=f,f")
14173         (match_operator:XF 3 "binary_fp_operator"
14174           [(match_operand:XF 1 "register_operand" "0,0")
14175            (float:XF (match_operand:SI 2 "nonimmediate_operand" "m,?r"))]))]
14176   "!TARGET_64BIT && TARGET_80387 && TARGET_USE_FIOP"
14177   "* return which_alternative ? \"#\" : output_387_binary_op (insn, operands);"
14178   [(set (attr "type") 
14179         (cond [(match_operand:XF 3 "mult_operator" "") 
14180                  (const_string "fmul")
14181                (match_operand:XF 3 "div_operator" "") 
14182                  (const_string "fdiv")
14183               ]
14184               (const_string "fop")))
14185    (set_attr "fp_int_src" "true")
14186    (set_attr "mode" "SI")
14187    (set_attr "ppro_uops" "many")])
14188
14189 (define_insn "*fop_tf_3"
14190   [(set (match_operand:TF 0 "register_operand" "=f,f")
14191         (match_operator:TF 3 "binary_fp_operator"
14192           [(match_operand:TF 1 "register_operand" "0,0")
14193            (float:TF (match_operand:SI 2 "nonimmediate_operand" "m,?r"))]))]
14194   "TARGET_80387 && TARGET_USE_FIOP"
14195   "* return which_alternative ? \"#\" : output_387_binary_op (insn, operands);"
14196   [(set (attr "type") 
14197         (cond [(match_operand:TF 3 "mult_operator" "") 
14198                  (const_string "fmul")
14199                (match_operand:TF 3 "div_operator" "") 
14200                  (const_string "fdiv")
14201               ]
14202               (const_string "fop")))
14203    (set_attr "fp_int_src" "true")
14204    (set_attr "mode" "SI")
14205    (set_attr "ppro_uops" "many")])
14206
14207 (define_insn "*fop_xf_4"
14208   [(set (match_operand:XF 0 "register_operand" "=f,f")
14209         (match_operator:XF 3 "binary_fp_operator"
14210            [(float_extend:XF (match_operand:SF 1 "nonimmediate_operand" "fm,0"))
14211             (match_operand:XF 2 "register_operand" "0,f")]))]
14212   "!TARGET_64BIT && TARGET_80387"
14213   "* return output_387_binary_op (insn, operands);"
14214   [(set (attr "type") 
14215         (cond [(match_operand:XF 3 "mult_operator" "") 
14216                  (const_string "fmul")
14217                (match_operand:XF 3 "div_operator" "") 
14218                  (const_string "fdiv")
14219               ]
14220               (const_string "fop")))
14221    (set_attr "mode" "SF")])
14222
14223 (define_insn "*fop_tf_4"
14224   [(set (match_operand:TF 0 "register_operand" "=f,f")
14225         (match_operator:TF 3 "binary_fp_operator"
14226            [(float_extend:TF (match_operand:SF 1 "nonimmediate_operand" "fm,0"))
14227             (match_operand:TF 2 "register_operand" "0,f")]))]
14228   "TARGET_80387"
14229   "* return output_387_binary_op (insn, operands);"
14230   [(set (attr "type") 
14231         (cond [(match_operand:TF 3 "mult_operator" "") 
14232                  (const_string "fmul")
14233                (match_operand:TF 3 "div_operator" "") 
14234                  (const_string "fdiv")
14235               ]
14236               (const_string "fop")))
14237    (set_attr "mode" "SF")])
14238
14239 (define_insn "*fop_xf_5"
14240   [(set (match_operand:XF 0 "register_operand" "=f,f")
14241         (match_operator:XF 3 "binary_fp_operator"
14242           [(match_operand:XF 1 "register_operand" "0,f")
14243            (float_extend:XF
14244             (match_operand:SF 2 "nonimmediate_operand" "fm,0"))]))]
14245   "!TARGET_64BIT && TARGET_80387"
14246   "* return output_387_binary_op (insn, operands);"
14247   [(set (attr "type") 
14248         (cond [(match_operand:XF 3 "mult_operator" "") 
14249                  (const_string "fmul")
14250                (match_operand:XF 3 "div_operator" "") 
14251                  (const_string "fdiv")
14252               ]
14253               (const_string "fop")))
14254    (set_attr "mode" "SF")])
14255
14256 (define_insn "*fop_tf_5"
14257   [(set (match_operand:TF 0 "register_operand" "=f,f")
14258         (match_operator:TF 3 "binary_fp_operator"
14259           [(match_operand:TF 1 "register_operand" "0,f")
14260            (float_extend:TF
14261             (match_operand:SF 2 "nonimmediate_operand" "fm,0"))]))]
14262   "TARGET_80387"
14263   "* return output_387_binary_op (insn, operands);"
14264   [(set (attr "type") 
14265         (cond [(match_operand:TF 3 "mult_operator" "") 
14266                  (const_string "fmul")
14267                (match_operand:TF 3 "div_operator" "") 
14268                  (const_string "fdiv")
14269               ]
14270               (const_string "fop")))
14271    (set_attr "mode" "SF")])
14272
14273 (define_insn "*fop_xf_6"
14274   [(set (match_operand:XF 0 "register_operand" "=f,f")
14275         (match_operator:XF 3 "binary_fp_operator"
14276            [(float_extend:XF (match_operand:DF 1 "nonimmediate_operand" "fm,0"))
14277             (match_operand:XF 2 "register_operand" "0,f")]))]
14278   "!TARGET_64BIT && TARGET_80387"
14279   "* return output_387_binary_op (insn, operands);"
14280   [(set (attr "type") 
14281         (cond [(match_operand:XF 3 "mult_operator" "") 
14282                  (const_string "fmul")
14283                (match_operand:XF 3 "div_operator" "") 
14284                  (const_string "fdiv")
14285               ]
14286               (const_string "fop")))
14287    (set_attr "mode" "DF")])
14288
14289 (define_insn "*fop_tf_6"
14290   [(set (match_operand:TF 0 "register_operand" "=f,f")
14291         (match_operator:TF 3 "binary_fp_operator"
14292            [(float_extend:TF (match_operand:DF 1 "nonimmediate_operand" "fm,0"))
14293             (match_operand:TF 2 "register_operand" "0,f")]))]
14294   "TARGET_80387"
14295   "* return output_387_binary_op (insn, operands);"
14296   [(set (attr "type") 
14297         (cond [(match_operand:TF 3 "mult_operator" "") 
14298                  (const_string "fmul")
14299                (match_operand:TF 3 "div_operator" "") 
14300                  (const_string "fdiv")
14301               ]
14302               (const_string "fop")))
14303    (set_attr "mode" "DF")])
14304
14305 (define_insn "*fop_xf_7"
14306   [(set (match_operand:XF 0 "register_operand" "=f,f")
14307         (match_operator:XF 3 "binary_fp_operator"
14308           [(match_operand:XF 1 "register_operand" "0,f")
14309            (float_extend:XF
14310             (match_operand:DF 2 "nonimmediate_operand" "fm,0"))]))]
14311   "!TARGET_64BIT && TARGET_80387"
14312   "* return output_387_binary_op (insn, operands);"
14313   [(set (attr "type") 
14314         (cond [(match_operand:XF 3 "mult_operator" "") 
14315                  (const_string "fmul")
14316                (match_operand:XF 3 "div_operator" "") 
14317                  (const_string "fdiv")
14318               ]
14319               (const_string "fop")))
14320    (set_attr "mode" "DF")])
14321
14322 (define_insn "*fop_tf_7"
14323   [(set (match_operand:TF 0 "register_operand" "=f,f")
14324         (match_operator:TF 3 "binary_fp_operator"
14325           [(match_operand:TF 1 "register_operand" "0,f")
14326            (float_extend:TF
14327             (match_operand:DF 2 "nonimmediate_operand" "fm,0"))]))]
14328   "TARGET_80387"
14329   "* return output_387_binary_op (insn, operands);"
14330   [(set (attr "type") 
14331         (cond [(match_operand:TF 3 "mult_operator" "") 
14332                  (const_string "fmul")
14333                (match_operand:TF 3 "div_operator" "") 
14334                  (const_string "fdiv")
14335               ]
14336               (const_string "fop")))
14337    (set_attr "mode" "DF")])
14338
14339 (define_split
14340   [(set (match_operand 0 "register_operand" "")
14341         (match_operator 3 "binary_fp_operator"
14342            [(float (match_operand:SI 1 "register_operand" ""))
14343             (match_operand 2 "register_operand" "")]))]
14344   "TARGET_80387 && reload_completed
14345    && FLOAT_MODE_P (GET_MODE (operands[0]))"
14346   [(const_int 0)]
14347
14348   operands[4] = ix86_force_to_memory (GET_MODE (operands[1]), operands[1]);
14349   operands[4] = gen_rtx_FLOAT (GET_MODE (operands[0]), operands[4]);
14350   emit_insn (gen_rtx_SET (VOIDmode, operands[0],
14351                           gen_rtx_fmt_ee (GET_CODE (operands[3]),
14352                                           GET_MODE (operands[3]),
14353                                           operands[4],
14354                                           operands[2])));
14355   ix86_free_from_memory (GET_MODE (operands[1]));
14356   DONE;
14357 })
14358
14359 (define_split
14360   [(set (match_operand 0 "register_operand" "")
14361         (match_operator 3 "binary_fp_operator"
14362            [(match_operand 1 "register_operand" "")
14363             (float (match_operand:SI 2 "register_operand" ""))]))]
14364   "TARGET_80387 && reload_completed
14365    && FLOAT_MODE_P (GET_MODE (operands[0]))"
14366   [(const_int 0)]
14367 {
14368   operands[4] = ix86_force_to_memory (GET_MODE (operands[2]), operands[2]);
14369   operands[4] = gen_rtx_FLOAT (GET_MODE (operands[0]), operands[4]);
14370   emit_insn (gen_rtx_SET (VOIDmode, operands[0],
14371                           gen_rtx_fmt_ee (GET_CODE (operands[3]),
14372                                           GET_MODE (operands[3]),
14373                                           operands[1],
14374                                           operands[4])));
14375   ix86_free_from_memory (GET_MODE (operands[2]));
14376   DONE;
14377 })
14378 \f
14379 ;; FPU special functions.
14380
14381 (define_expand "sqrtsf2"
14382   [(set (match_operand:SF 0 "register_operand" "")
14383         (sqrt:SF (match_operand:SF 1 "nonimmediate_operand" "")))]
14384   "(! TARGET_NO_FANCY_MATH_387 && TARGET_80387) || TARGET_SSE"
14385 {
14386   if (!TARGET_SSE)
14387     operands[1] = force_reg (SFmode, operands[1]);
14388 })
14389
14390 (define_insn "sqrtsf2_1"
14391   [(set (match_operand:SF 0 "register_operand" "=f#x,x#f")
14392         (sqrt:SF (match_operand:SF 1 "nonimmediate_operand" "0#x,xm#f")))]
14393   "! TARGET_NO_FANCY_MATH_387 && TARGET_80387
14394    && (TARGET_SSE && TARGET_MIX_SSE_I387)"
14395   "@
14396    fsqrt
14397    sqrtss\t{%1, %0|%0, %1}"
14398   [(set_attr "type" "fpspc,sse")
14399    (set_attr "mode" "SF,SF")
14400    (set_attr "athlon_decode" "direct,*")])
14401
14402 (define_insn "sqrtsf2_1_sse_only"
14403   [(set (match_operand:SF 0 "register_operand" "=x")
14404         (sqrt:SF (match_operand:SF 1 "nonimmediate_operand" "xm")))]
14405   "TARGET_SSE && (!TARGET_80387 || !TARGET_MIX_SSE_I387)"
14406   "sqrtss\t{%1, %0|%0, %1}"
14407   [(set_attr "type" "sse")
14408    (set_attr "mode" "SF")
14409    (set_attr "athlon_decode" "*")])
14410
14411 (define_insn "sqrtsf2_i387"
14412   [(set (match_operand:SF 0 "register_operand" "=f")
14413         (sqrt:SF (match_operand:SF 1 "register_operand" "0")))]
14414   "! TARGET_NO_FANCY_MATH_387 && TARGET_80387
14415    && (!TARGET_SSE && !TARGET_MIX_SSE_I387)"
14416   "fsqrt"
14417   [(set_attr "type" "fpspc")
14418    (set_attr "mode" "SF")
14419    (set_attr "athlon_decode" "direct")])
14420
14421 (define_expand "sqrtdf2"
14422   [(set (match_operand:DF 0 "register_operand" "")
14423         (sqrt:DF (match_operand:DF 1 "nonimmediate_operand" "")))]
14424   "(! TARGET_NO_FANCY_MATH_387 && TARGET_80387) || TARGET_SSE2"
14425 {
14426   if (!TARGET_SSE2)
14427     operands[1] = force_reg (DFmode, operands[1]);
14428 })
14429
14430 (define_insn "sqrtdf2_1"
14431   [(set (match_operand:DF 0 "register_operand" "=f#Y,Y#f")
14432         (sqrt:DF (match_operand:DF 1 "nonimmediate_operand" "0#Y,Ym#f")))]
14433   "! TARGET_NO_FANCY_MATH_387 && TARGET_80387
14434    && (TARGET_SSE2 && TARGET_MIX_SSE_I387)"
14435   "@
14436    fsqrt
14437    sqrtsd\t{%1, %0|%0, %1}"
14438   [(set_attr "type" "fpspc,sse")
14439    (set_attr "mode" "DF,DF")
14440    (set_attr "athlon_decode" "direct,*")])
14441
14442 (define_insn "sqrtdf2_1_sse_only"
14443   [(set (match_operand:DF 0 "register_operand" "=Y")
14444         (sqrt:DF (match_operand:DF 1 "nonimmediate_operand" "Ym")))]
14445   "TARGET_SSE2 && (!TARGET_80387 || !TARGET_MIX_SSE_I387)"
14446   "sqrtsd\t{%1, %0|%0, %1}"
14447   [(set_attr "type" "sse")
14448    (set_attr "mode" "DF")
14449    (set_attr "athlon_decode" "*")])
14450
14451 (define_insn "sqrtdf2_i387"
14452   [(set (match_operand:DF 0 "register_operand" "=f")
14453         (sqrt:DF (match_operand:DF 1 "register_operand" "0")))]
14454   "! TARGET_NO_FANCY_MATH_387 && TARGET_80387
14455    && (!TARGET_SSE2 && !TARGET_MIX_SSE_I387)"
14456   "fsqrt"
14457   [(set_attr "type" "fpspc")
14458    (set_attr "mode" "DF")
14459    (set_attr "athlon_decode" "direct")])
14460
14461 (define_insn "*sqrtextendsfdf2"
14462   [(set (match_operand:DF 0 "register_operand" "=f")
14463         (sqrt:DF (float_extend:DF
14464                   (match_operand:SF 1 "register_operand" "0"))))]
14465   "! TARGET_NO_FANCY_MATH_387 && TARGET_80387 && !TARGET_SSE2"
14466   "fsqrt"
14467   [(set_attr "type" "fpspc")
14468    (set_attr "mode" "DF")
14469    (set_attr "athlon_decode" "direct")])
14470
14471 (define_insn "sqrtxf2"
14472   [(set (match_operand:XF 0 "register_operand" "=f")
14473         (sqrt:XF (match_operand:XF 1 "register_operand" "0")))]
14474   "!TARGET_64BIT && TARGET_80387 && !TARGET_NO_FANCY_MATH_387 
14475    && (TARGET_IEEE_FP || flag_unsafe_math_optimizations) "
14476   "fsqrt"
14477   [(set_attr "type" "fpspc")
14478    (set_attr "mode" "XF")
14479    (set_attr "athlon_decode" "direct")])
14480
14481 (define_insn "sqrttf2"
14482   [(set (match_operand:TF 0 "register_operand" "=f")
14483         (sqrt:TF (match_operand:TF 1 "register_operand" "0")))]
14484   "! TARGET_NO_FANCY_MATH_387 && TARGET_80387 
14485    && (TARGET_IEEE_FP || flag_unsafe_math_optimizations) "
14486   "fsqrt"
14487   [(set_attr "type" "fpspc")
14488    (set_attr "mode" "XF")
14489    (set_attr "athlon_decode" "direct")])
14490
14491 (define_insn "*sqrtextenddfxf2"
14492   [(set (match_operand:XF 0 "register_operand" "=f")
14493         (sqrt:XF (float_extend:XF
14494                   (match_operand:DF 1 "register_operand" "0"))))]
14495   "!TARGET_64BIT && TARGET_80387 && TARGET_NO_FANCY_MATH_387"
14496   "fsqrt"
14497   [(set_attr "type" "fpspc")
14498    (set_attr "mode" "XF")
14499    (set_attr "athlon_decode" "direct")])
14500
14501 (define_insn "*sqrtextenddftf2"
14502   [(set (match_operand:TF 0 "register_operand" "=f")
14503         (sqrt:TF (float_extend:TF
14504                   (match_operand:DF 1 "register_operand" "0"))))]
14505   "! TARGET_NO_FANCY_MATH_387 && TARGET_80387"
14506   "fsqrt"
14507   [(set_attr "type" "fpspc")
14508    (set_attr "mode" "XF")
14509    (set_attr "athlon_decode" "direct")])
14510
14511 (define_insn "*sqrtextendsfxf2"
14512   [(set (match_operand:XF 0 "register_operand" "=f")
14513         (sqrt:XF (float_extend:XF
14514                   (match_operand:SF 1 "register_operand" "0"))))]
14515   "!TARGET_64BIT && TARGET_80387 && TARGET_NO_FANCY_MATH_387"
14516   "fsqrt"
14517   [(set_attr "type" "fpspc")
14518    (set_attr "mode" "XF")
14519    (set_attr "athlon_decode" "direct")])
14520
14521 (define_insn "*sqrtextendsftf2"
14522   [(set (match_operand:TF 0 "register_operand" "=f")
14523         (sqrt:TF (float_extend:TF
14524                   (match_operand:SF 1 "register_operand" "0"))))]
14525   "! TARGET_NO_FANCY_MATH_387 && TARGET_80387"
14526   "fsqrt"
14527   [(set_attr "type" "fpspc")
14528    (set_attr "mode" "XF")
14529    (set_attr "athlon_decode" "direct")])
14530
14531 (define_insn "sindf2"
14532   [(set (match_operand:DF 0 "register_operand" "=f")
14533         (unspec:DF [(match_operand:DF 1 "register_operand" "0")] 1))]
14534   "! TARGET_NO_FANCY_MATH_387 && TARGET_80387 
14535    && flag_unsafe_math_optimizations"
14536   "fsin"
14537   [(set_attr "type" "fpspc")
14538    (set_attr "mode" "DF")])
14539
14540 (define_insn "sinsf2"
14541   [(set (match_operand:SF 0 "register_operand" "=f")
14542         (unspec:SF [(match_operand:SF 1 "register_operand" "0")] 1))]
14543   "! TARGET_NO_FANCY_MATH_387 && TARGET_80387 
14544    && flag_unsafe_math_optimizations"
14545   "fsin"
14546   [(set_attr "type" "fpspc")
14547    (set_attr "mode" "SF")])
14548
14549 (define_insn "*sinextendsfdf2"
14550   [(set (match_operand:DF 0 "register_operand" "=f")
14551         (unspec:DF [(float_extend:DF
14552                      (match_operand:SF 1 "register_operand" "0"))] 1))]
14553   "! TARGET_NO_FANCY_MATH_387 && TARGET_80387 
14554    && flag_unsafe_math_optimizations"
14555   "fsin"
14556   [(set_attr "type" "fpspc")
14557    (set_attr "mode" "DF")])
14558
14559 (define_insn "sinxf2"
14560   [(set (match_operand:XF 0 "register_operand" "=f")
14561         (unspec:XF [(match_operand:XF 1 "register_operand" "0")] 1))]
14562   "!TARGET_64BIT && TARGET_80387 && TARGET_NO_FANCY_MATH_387
14563    && flag_unsafe_math_optimizations"
14564   "fsin"
14565   [(set_attr "type" "fpspc")
14566    (set_attr "mode" "XF")])
14567
14568 (define_insn "sintf2"
14569   [(set (match_operand:TF 0 "register_operand" "=f")
14570         (unspec:TF [(match_operand:TF 1 "register_operand" "0")] 1))]
14571   "! TARGET_NO_FANCY_MATH_387 && TARGET_80387 
14572    && flag_unsafe_math_optimizations"
14573   "fsin"
14574   [(set_attr "type" "fpspc")
14575    (set_attr "mode" "XF")])
14576
14577 (define_insn "cosdf2"
14578   [(set (match_operand:DF 0 "register_operand" "=f")
14579         (unspec:DF [(match_operand:DF 1 "register_operand" "0")] 2))]
14580   "! TARGET_NO_FANCY_MATH_387 && TARGET_80387 
14581    && flag_unsafe_math_optimizations"
14582   "fcos"
14583   [(set_attr "type" "fpspc")
14584    (set_attr "mode" "DF")])
14585
14586 (define_insn "cossf2"
14587   [(set (match_operand:SF 0 "register_operand" "=f")
14588         (unspec:SF [(match_operand:SF 1 "register_operand" "0")] 2))]
14589   "! TARGET_NO_FANCY_MATH_387 && TARGET_80387 
14590    && flag_unsafe_math_optimizations"
14591   "fcos"
14592   [(set_attr "type" "fpspc")
14593    (set_attr "mode" "SF")])
14594
14595 (define_insn "*cosextendsfdf2"
14596   [(set (match_operand:DF 0 "register_operand" "=f")
14597         (unspec:DF [(float_extend:DF
14598                      (match_operand:SF 1 "register_operand" "0"))] 2))]
14599   "! TARGET_NO_FANCY_MATH_387 && TARGET_80387 
14600    && flag_unsafe_math_optimizations"
14601   "fcos"
14602   [(set_attr "type" "fpspc")
14603    (set_attr "mode" "DF")])
14604
14605 (define_insn "cosxf2"
14606   [(set (match_operand:XF 0 "register_operand" "=f")
14607         (unspec:XF [(match_operand:XF 1 "register_operand" "0")] 2))]
14608   "! TARGET_NO_FANCY_MATH_387 && TARGET_80387
14609    && flag_unsafe_math_optimizations"
14610   "fcos"
14611   [(set_attr "type" "fpspc")
14612    (set_attr "mode" "XF")])
14613
14614 (define_insn "costf2"
14615   [(set (match_operand:TF 0 "register_operand" "=f")
14616         (unspec:TF [(match_operand:TF 1 "register_operand" "0")] 2))]
14617   "! TARGET_NO_FANCY_MATH_387 && TARGET_80387 
14618    && flag_unsafe_math_optimizations"
14619   "fcos"
14620   [(set_attr "type" "fpspc")
14621    (set_attr "mode" "XF")])
14622 \f
14623 ;; Block operation instructions
14624
14625 (define_insn "cld"
14626  [(set (reg:SI 19) (const_int 0))]
14627  ""
14628  "cld"
14629   [(set_attr "type" "cld")])
14630
14631 (define_expand "movstrsi"
14632   [(use (match_operand:BLK 0 "memory_operand" ""))
14633    (use (match_operand:BLK 1 "memory_operand" ""))
14634    (use (match_operand:SI 2 "nonmemory_operand" ""))
14635    (use (match_operand:SI 3 "const_int_operand" ""))]
14636   ""
14637 {
14638  if (ix86_expand_movstr (operands[0], operands[1], operands[2], operands[3]))
14639    DONE;
14640  else
14641    FAIL;
14642 })
14643
14644 (define_expand "movstrdi"
14645   [(use (match_operand:BLK 0 "memory_operand" ""))
14646    (use (match_operand:BLK 1 "memory_operand" ""))
14647    (use (match_operand:DI 2 "nonmemory_operand" ""))
14648    (use (match_operand:DI 3 "const_int_operand" ""))]
14649   "TARGET_64BIT"
14650 {
14651  if (ix86_expand_movstr (operands[0], operands[1], operands[2], operands[3]))
14652    DONE;
14653  else
14654    FAIL;
14655 })
14656
14657 ;; Most CPUs don't like single string operations
14658 ;; Handle this case here to simplify previous expander.
14659
14660 (define_expand "strmovdi_rex64"
14661   [(set (match_dup 2)
14662         (mem:DI (match_operand:DI 1 "register_operand" "")))
14663    (set (mem:DI (match_operand:DI 0 "register_operand" ""))
14664         (match_dup 2))
14665    (parallel [(set (match_dup 0) (plus:DI (match_dup 0) (const_int 8)))
14666               (clobber (reg:CC 17))])
14667    (parallel [(set (match_dup 1) (plus:DI (match_dup 1) (const_int 8)))
14668               (clobber (reg:CC 17))])]
14669   "TARGET_64BIT"
14670 {
14671   if (TARGET_SINGLE_STRINGOP || optimize_size)
14672     {
14673       emit_insn (gen_strmovdi_rex_1 (operands[0], operands[1], operands[0],
14674                                      operands[1]));
14675       DONE;
14676     }
14677   else 
14678     operands[2] = gen_reg_rtx (DImode);
14679 })
14680
14681
14682 (define_expand "strmovsi"
14683   [(set (match_dup 2)
14684         (mem:SI (match_operand:SI 1 "register_operand" "")))
14685    (set (mem:SI (match_operand:SI 0 "register_operand" ""))
14686         (match_dup 2))
14687    (parallel [(set (match_dup 0) (plus:SI (match_dup 0) (const_int 4)))
14688               (clobber (reg:CC 17))])
14689    (parallel [(set (match_dup 1) (plus:SI (match_dup 1) (const_int 4)))
14690               (clobber (reg:CC 17))])]
14691   ""
14692 {
14693   if (TARGET_64BIT)
14694     {
14695       emit_insn (gen_strmovsi_rex64 (operands[0], operands[1]));
14696       DONE;
14697     }
14698   if (TARGET_SINGLE_STRINGOP || optimize_size)
14699     {
14700       emit_insn (gen_strmovsi_1 (operands[0], operands[1], operands[0],
14701                                 operands[1]));
14702       DONE;
14703     }
14704   else 
14705     operands[2] = gen_reg_rtx (SImode);
14706 })
14707
14708 (define_expand "strmovsi_rex64"
14709   [(set (match_dup 2)
14710         (mem:SI (match_operand:DI 1 "register_operand" "")))
14711    (set (mem:SI (match_operand:DI 0 "register_operand" ""))
14712         (match_dup 2))
14713    (parallel [(set (match_dup 0) (plus:DI (match_dup 0) (const_int 4)))
14714               (clobber (reg:CC 17))])
14715    (parallel [(set (match_dup 1) (plus:DI (match_dup 1) (const_int 4)))
14716               (clobber (reg:CC 17))])]
14717   "TARGET_64BIT"
14718 {
14719   if (TARGET_SINGLE_STRINGOP || optimize_size)
14720     {
14721       emit_insn (gen_strmovsi_rex_1 (operands[0], operands[1], operands[0],
14722                                      operands[1]));
14723       DONE;
14724     }
14725   else 
14726     operands[2] = gen_reg_rtx (SImode);
14727 })
14728
14729 (define_expand "strmovhi"
14730   [(set (match_dup 2)
14731         (mem:HI (match_operand:SI 1 "register_operand" "")))
14732    (set (mem:HI (match_operand:SI 0 "register_operand" ""))
14733         (match_dup 2))
14734    (parallel [(set (match_dup 0) (plus:SI (match_dup 0) (const_int 2)))
14735               (clobber (reg:CC 17))])
14736    (parallel [(set (match_dup 1) (plus:SI (match_dup 1) (const_int 2)))
14737               (clobber (reg:CC 17))])]
14738   ""
14739 {
14740   if (TARGET_64BIT)
14741     {
14742       emit_insn (gen_strmovhi_rex64 (operands[0], operands[1]));
14743       DONE;
14744     }
14745   if (TARGET_SINGLE_STRINGOP || optimize_size)
14746     {
14747       emit_insn (gen_strmovhi_1 (operands[0], operands[1], operands[0],
14748                                 operands[1]));
14749       DONE;
14750     }
14751   else 
14752     operands[2] = gen_reg_rtx (HImode);
14753 })
14754
14755 (define_expand "strmovhi_rex64"
14756   [(set (match_dup 2)
14757         (mem:HI (match_operand:DI 1 "register_operand" "")))
14758    (set (mem:HI (match_operand:DI 0 "register_operand" ""))
14759         (match_dup 2))
14760    (parallel [(set (match_dup 0) (plus:DI (match_dup 0) (const_int 2)))
14761               (clobber (reg:CC 17))])
14762    (parallel [(set (match_dup 1) (plus:DI (match_dup 1) (const_int 2)))
14763               (clobber (reg:CC 17))])]
14764   "TARGET_64BIT"
14765 {
14766   if (TARGET_SINGLE_STRINGOP || optimize_size)
14767     {
14768       emit_insn (gen_strmovhi_rex_1 (operands[0], operands[1], operands[0],
14769                                      operands[1]));
14770       DONE;
14771     }
14772   else 
14773     operands[2] = gen_reg_rtx (HImode);
14774 })
14775
14776 (define_expand "strmovqi"
14777   [(set (match_dup 2)
14778         (mem:QI (match_operand:SI 1 "register_operand" "")))
14779    (set (mem:QI (match_operand:SI 0 "register_operand" ""))
14780         (match_dup 2))
14781    (parallel [(set (match_dup 0) (plus:SI (match_dup 0) (const_int 1)))
14782               (clobber (reg:CC 17))])
14783    (parallel [(set (match_dup 1) (plus:SI (match_dup 1) (const_int 1)))
14784               (clobber (reg:CC 17))])]
14785   ""
14786 {
14787   if (TARGET_64BIT)
14788     {
14789       emit_insn (gen_strmovqi_rex64 (operands[0], operands[1]));
14790       DONE;
14791     }
14792   if (TARGET_SINGLE_STRINGOP || optimize_size)
14793     {
14794       emit_insn (gen_strmovqi_1 (operands[0], operands[1], operands[0],
14795                                 operands[1]));
14796       DONE;
14797     }
14798   else 
14799     operands[2] = gen_reg_rtx (QImode);
14800 })
14801
14802 (define_expand "strmovqi_rex64"
14803   [(set (match_dup 2)
14804         (mem:QI (match_operand:DI 1 "register_operand" "")))
14805    (set (mem:QI (match_operand:DI 0 "register_operand" ""))
14806         (match_dup 2))
14807    (parallel [(set (match_dup 0) (plus:DI (match_dup 0) (const_int 1)))
14808               (clobber (reg:CC 17))])
14809    (parallel [(set (match_dup 1) (plus:DI (match_dup 1) (const_int 1)))
14810               (clobber (reg:CC 17))])]
14811   "TARGET_64BIT"
14812 {
14813   if (TARGET_SINGLE_STRINGOP || optimize_size)
14814     {
14815       emit_insn (gen_strmovqi_rex_1 (operands[0], operands[1], operands[0],
14816                                      operands[1]));
14817       DONE;
14818     }
14819   else 
14820     operands[2] = gen_reg_rtx (QImode);
14821 })
14822
14823 (define_insn "strmovdi_rex_1"
14824   [(set (mem:DI (match_operand:DI 2 "register_operand" "0"))
14825         (mem:DI (match_operand:DI 3 "register_operand" "1")))
14826    (set (match_operand:DI 0 "register_operand" "=D")
14827         (plus:DI (match_dup 2)
14828                  (const_int 8)))
14829    (set (match_operand:DI 1 "register_operand" "=S")
14830         (plus:DI (match_dup 3)
14831                  (const_int 8)))
14832    (use (reg:SI 19))]
14833   "TARGET_64BIT && (TARGET_SINGLE_STRINGOP || optimize_size)"
14834   "movsq"
14835   [(set_attr "type" "str")
14836    (set_attr "mode" "DI")
14837    (set_attr "memory" "both")])
14838
14839 (define_insn "strmovsi_1"
14840   [(set (mem:SI (match_operand:SI 2 "register_operand" "0"))
14841         (mem:SI (match_operand:SI 3 "register_operand" "1")))
14842    (set (match_operand:SI 0 "register_operand" "=D")
14843         (plus:SI (match_dup 2)
14844                  (const_int 4)))
14845    (set (match_operand:SI 1 "register_operand" "=S")
14846         (plus:SI (match_dup 3)
14847                  (const_int 4)))
14848    (use (reg:SI 19))]
14849   "!TARGET_64BIT && (TARGET_SINGLE_STRINGOP || optimize_size)"
14850   "{movsl|movsd}"
14851   [(set_attr "type" "str")
14852    (set_attr "mode" "SI")
14853    (set_attr "memory" "both")])
14854
14855 (define_insn "strmovsi_rex_1"
14856   [(set (mem:SI (match_operand:DI 2 "register_operand" "0"))
14857         (mem:SI (match_operand:DI 3 "register_operand" "1")))
14858    (set (match_operand:DI 0 "register_operand" "=D")
14859         (plus:DI (match_dup 2)
14860                  (const_int 4)))
14861    (set (match_operand:DI 1 "register_operand" "=S")
14862         (plus:DI (match_dup 3)
14863                  (const_int 4)))
14864    (use (reg:SI 19))]
14865   "TARGET_64BIT && (TARGET_SINGLE_STRINGOP || optimize_size)"
14866   "{movsl|movsd}"
14867   [(set_attr "type" "str")
14868    (set_attr "mode" "SI")
14869    (set_attr "memory" "both")])
14870
14871 (define_insn "strmovhi_1"
14872   [(set (mem:HI (match_operand:SI 2 "register_operand" "0"))
14873         (mem:HI (match_operand:SI 3 "register_operand" "1")))
14874    (set (match_operand:SI 0 "register_operand" "=D")
14875         (plus:SI (match_dup 2)
14876                  (const_int 2)))
14877    (set (match_operand:SI 1 "register_operand" "=S")
14878         (plus:SI (match_dup 3)
14879                  (const_int 2)))
14880    (use (reg:SI 19))]
14881   "!TARGET_64BIT && (TARGET_SINGLE_STRINGOP || optimize_size)"
14882   "movsw"
14883   [(set_attr "type" "str")
14884    (set_attr "memory" "both")
14885    (set_attr "mode" "HI")])
14886
14887 (define_insn "strmovhi_rex_1"
14888   [(set (mem:HI (match_operand:DI 2 "register_operand" "0"))
14889         (mem:HI (match_operand:DI 3 "register_operand" "1")))
14890    (set (match_operand:DI 0 "register_operand" "=D")
14891         (plus:DI (match_dup 2)
14892                  (const_int 2)))
14893    (set (match_operand:DI 1 "register_operand" "=S")
14894         (plus:DI (match_dup 3)
14895                  (const_int 2)))
14896    (use (reg:SI 19))]
14897   "TARGET_64BIT && (TARGET_SINGLE_STRINGOP || optimize_size)"
14898   "movsw"
14899   [(set_attr "type" "str")
14900    (set_attr "memory" "both")
14901    (set_attr "mode" "HI")])
14902
14903 (define_insn "strmovqi_1"
14904   [(set (mem:QI (match_operand:SI 2 "register_operand" "0"))
14905         (mem:QI (match_operand:SI 3 "register_operand" "1")))
14906    (set (match_operand:SI 0 "register_operand" "=D")
14907         (plus:SI (match_dup 2)
14908                  (const_int 1)))
14909    (set (match_operand:SI 1 "register_operand" "=S")
14910         (plus:SI (match_dup 3)
14911                  (const_int 1)))
14912    (use (reg:SI 19))]
14913   "!TARGET_64BIT && (TARGET_SINGLE_STRINGOP || optimize_size)"
14914   "movsb"
14915   [(set_attr "type" "str")
14916    (set_attr "memory" "both")
14917    (set_attr "mode" "QI")])
14918
14919 (define_insn "strmovqi_rex_1"
14920   [(set (mem:QI (match_operand:DI 2 "register_operand" "0"))
14921         (mem:QI (match_operand:DI 3 "register_operand" "1")))
14922    (set (match_operand:DI 0 "register_operand" "=D")
14923         (plus:DI (match_dup 2)
14924                  (const_int 1)))
14925    (set (match_operand:DI 1 "register_operand" "=S")
14926         (plus:DI (match_dup 3)
14927                  (const_int 1)))
14928    (use (reg:SI 19))]
14929   "TARGET_64BIT && (TARGET_SINGLE_STRINGOP || optimize_size)"
14930   "movsb"
14931   [(set_attr "type" "str")
14932    (set_attr "memory" "both")
14933    (set_attr "mode" "QI")])
14934
14935 (define_insn "rep_movdi_rex64"
14936   [(set (match_operand:DI 2 "register_operand" "=c") (const_int 0))
14937    (set (match_operand:DI 0 "register_operand" "=D") 
14938         (plus:DI (ashift:DI (match_operand:DI 5 "register_operand" "2")
14939                             (const_int 3))
14940                  (match_operand:DI 3 "register_operand" "0")))
14941    (set (match_operand:DI 1 "register_operand" "=S") 
14942         (plus:DI (ashift:DI (match_dup 5) (const_int 3))
14943                  (match_operand:DI 4 "register_operand" "1")))
14944    (set (mem:BLK (match_dup 3))
14945         (mem:BLK (match_dup 4)))
14946    (use (match_dup 5))
14947    (use (reg:SI 19))]
14948   "TARGET_64BIT"
14949   "{rep\;movsq|rep movsq}"
14950   [(set_attr "type" "str")
14951    (set_attr "prefix_rep" "1")
14952    (set_attr "memory" "both")
14953    (set_attr "mode" "DI")])
14954
14955 (define_insn "rep_movsi"
14956   [(set (match_operand:SI 2 "register_operand" "=c") (const_int 0))
14957    (set (match_operand:SI 0 "register_operand" "=D") 
14958         (plus:SI (ashift:SI (match_operand:SI 5 "register_operand" "2")
14959                             (const_int 2))
14960                  (match_operand:SI 3 "register_operand" "0")))
14961    (set (match_operand:SI 1 "register_operand" "=S") 
14962         (plus:SI (ashift:SI (match_dup 5) (const_int 2))
14963                  (match_operand:SI 4 "register_operand" "1")))
14964    (set (mem:BLK (match_dup 3))
14965         (mem:BLK (match_dup 4)))
14966    (use (match_dup 5))
14967    (use (reg:SI 19))]
14968   "!TARGET_64BIT"
14969   "{rep\;movsl|rep movsd}"
14970   [(set_attr "type" "str")
14971    (set_attr "prefix_rep" "1")
14972    (set_attr "memory" "both")
14973    (set_attr "mode" "SI")])
14974
14975 (define_insn "rep_movsi_rex64"
14976   [(set (match_operand:DI 2 "register_operand" "=c") (const_int 0))
14977    (set (match_operand:DI 0 "register_operand" "=D") 
14978         (plus:DI (ashift:DI (match_operand:DI 5 "register_operand" "2")
14979                             (const_int 2))
14980                  (match_operand:DI 3 "register_operand" "0")))
14981    (set (match_operand:DI 1 "register_operand" "=S") 
14982         (plus:DI (ashift:DI (match_dup 5) (const_int 2))
14983                  (match_operand:DI 4 "register_operand" "1")))
14984    (set (mem:BLK (match_dup 3))
14985         (mem:BLK (match_dup 4)))
14986    (use (match_dup 5))
14987    (use (reg:SI 19))]
14988   "TARGET_64BIT"
14989   "{rep\;movsl|rep movsd}"
14990   [(set_attr "type" "str")
14991    (set_attr "prefix_rep" "1")
14992    (set_attr "memory" "both")
14993    (set_attr "mode" "SI")])
14994
14995 (define_insn "rep_movqi"
14996   [(set (match_operand:SI 2 "register_operand" "=c") (const_int 0))
14997    (set (match_operand:SI 0 "register_operand" "=D") 
14998         (plus:SI (match_operand:SI 3 "register_operand" "0")
14999                  (match_operand:SI 5 "register_operand" "2")))
15000    (set (match_operand:SI 1 "register_operand" "=S") 
15001         (plus:SI (match_operand:SI 4 "register_operand" "1") (match_dup 5)))
15002    (set (mem:BLK (match_dup 3))
15003         (mem:BLK (match_dup 4)))
15004    (use (match_dup 5))
15005    (use (reg:SI 19))]
15006   "!TARGET_64BIT"
15007   "{rep\;movsb|rep movsb}"
15008   [(set_attr "type" "str")
15009    (set_attr "prefix_rep" "1")
15010    (set_attr "memory" "both")
15011    (set_attr "mode" "SI")])
15012
15013 (define_insn "rep_movqi_rex64"
15014   [(set (match_operand:DI 2 "register_operand" "=c") (const_int 0))
15015    (set (match_operand:DI 0 "register_operand" "=D") 
15016         (plus:DI (match_operand:DI 3 "register_operand" "0")
15017                  (match_operand:DI 5 "register_operand" "2")))
15018    (set (match_operand:DI 1 "register_operand" "=S") 
15019         (plus:DI (match_operand:DI 4 "register_operand" "1") (match_dup 5)))
15020    (set (mem:BLK (match_dup 3))
15021         (mem:BLK (match_dup 4)))
15022    (use (match_dup 5))
15023    (use (reg:SI 19))]
15024   "TARGET_64BIT"
15025   "{rep\;movsb|rep movsb}"
15026   [(set_attr "type" "str")
15027    (set_attr "prefix_rep" "1")
15028    (set_attr "memory" "both")
15029    (set_attr "mode" "SI")])
15030
15031 (define_expand "clrstrsi"
15032    [(use (match_operand:BLK 0 "memory_operand" ""))
15033     (use (match_operand:SI 1 "nonmemory_operand" ""))
15034     (use (match_operand 2 "const_int_operand" ""))]
15035   ""
15036 {
15037  if (ix86_expand_clrstr (operands[0], operands[1], operands[2]))
15038    DONE;
15039  else
15040    FAIL;
15041 })
15042
15043 (define_expand "clrstrdi"
15044    [(use (match_operand:BLK 0 "memory_operand" ""))
15045     (use (match_operand:DI 1 "nonmemory_operand" ""))
15046     (use (match_operand 2 "const_int_operand" ""))]
15047   "TARGET_64BIT"
15048 {
15049  if (ix86_expand_clrstr (operands[0], operands[1], operands[2]))
15050    DONE;
15051  else
15052    FAIL;
15053 })
15054
15055 ;; Most CPUs don't like single string operations
15056 ;; Handle this case here to simplify previous expander.
15057
15058 (define_expand "strsetdi_rex64"
15059   [(set (mem:DI (match_operand:DI 0 "register_operand" ""))
15060         (match_operand:DI 1 "register_operand" ""))
15061    (parallel [(set (match_dup 0) (plus:DI (match_dup 0) (const_int 8)))
15062               (clobber (reg:CC 17))])]
15063   "TARGET_64BIT"
15064 {
15065   if (TARGET_SINGLE_STRINGOP || optimize_size)
15066     {
15067       emit_insn (gen_strsetdi_rex_1 (operands[0], operands[0], operands[1]));
15068       DONE;
15069     }
15070 })
15071
15072 (define_expand "strsetsi"
15073   [(set (mem:SI (match_operand:SI 0 "register_operand" ""))
15074         (match_operand:SI 1 "register_operand" ""))
15075    (parallel [(set (match_dup 0) (plus:SI (match_dup 0) (const_int 4)))
15076               (clobber (reg:CC 17))])]
15077   ""
15078 {
15079   if (TARGET_64BIT)
15080     {
15081       emit_insn (gen_strsetsi_rex64 (operands[0], operands[1]));
15082       DONE;
15083     }
15084   else if (TARGET_SINGLE_STRINGOP || optimize_size)
15085     {
15086       emit_insn (gen_strsetsi_1 (operands[0], operands[0], operands[1]));
15087       DONE;
15088     }
15089 })
15090
15091 (define_expand "strsetsi_rex64"
15092   [(set (mem:SI (match_operand:DI 0 "register_operand" ""))
15093         (match_operand:SI 1 "register_operand" ""))
15094    (parallel [(set (match_dup 0) (plus:DI (match_dup 0) (const_int 4)))
15095               (clobber (reg:CC 17))])]
15096   "TARGET_64BIT"
15097 {
15098   if (TARGET_SINGLE_STRINGOP || optimize_size)
15099     {
15100       emit_insn (gen_strsetsi_rex_1 (operands[0], operands[0], operands[1]));
15101       DONE;
15102     }
15103 })
15104
15105 (define_expand "strsethi"
15106   [(set (mem:HI (match_operand:SI 0 "register_operand" ""))
15107         (match_operand:HI 1 "register_operand" ""))
15108    (parallel [(set (match_dup 0) (plus:SI (match_dup 0) (const_int 2)))
15109               (clobber (reg:CC 17))])]
15110   ""
15111 {
15112   if (TARGET_64BIT)
15113     {
15114       emit_insn (gen_strsethi_rex64 (operands[0], operands[1]));
15115       DONE;
15116     }
15117   else if (TARGET_SINGLE_STRINGOP || optimize_size)
15118     {
15119       emit_insn (gen_strsethi_1 (operands[0], operands[0], operands[1]));
15120       DONE;
15121     }
15122 })
15123
15124 (define_expand "strsethi_rex64"
15125   [(set (mem:HI (match_operand:DI 0 "register_operand" ""))
15126         (match_operand:HI 1 "register_operand" ""))
15127    (parallel [(set (match_dup 0) (plus:DI (match_dup 0) (const_int 2)))
15128               (clobber (reg:CC 17))])]
15129   "TARGET_64BIT"
15130 {
15131   if (TARGET_SINGLE_STRINGOP || optimize_size)
15132     {
15133       emit_insn (gen_strsethi_rex_1 (operands[0], operands[0], operands[1]));
15134       DONE;
15135     }
15136 })
15137
15138 (define_expand "strsetqi"
15139   [(set (mem:QI (match_operand:SI 0 "register_operand" ""))
15140         (match_operand:QI 1 "register_operand" ""))
15141    (parallel [(set (match_dup 0) (plus:SI (match_dup 0) (const_int 1)))
15142               (clobber (reg:CC 17))])]
15143   ""
15144 {
15145   if (TARGET_64BIT)
15146     {
15147       emit_insn (gen_strsetqi_rex64 (operands[0], operands[1]));
15148       DONE;
15149     }
15150   else if (TARGET_SINGLE_STRINGOP || optimize_size)
15151     {
15152       emit_insn (gen_strsetqi_1 (operands[0], operands[0], operands[1]));
15153       DONE;
15154     }
15155 })
15156
15157 (define_expand "strsetqi_rex64"
15158   [(set (mem:QI (match_operand:DI 0 "register_operand" ""))
15159         (match_operand:QI 1 "register_operand" ""))
15160    (parallel [(set (match_dup 0) (plus:DI (match_dup 0) (const_int 1)))
15161               (clobber (reg:CC 17))])]
15162   "TARGET_64BIT"
15163 {
15164   if (TARGET_SINGLE_STRINGOP || optimize_size)
15165     {
15166       emit_insn (gen_strsetqi_rex_1 (operands[0], operands[0], operands[1]));
15167       DONE;
15168     }
15169 })
15170
15171 (define_insn "strsetdi_rex_1"
15172   [(set (mem:SI (match_operand:DI 1 "register_operand" "0"))
15173         (match_operand:SI 2 "register_operand" "a"))
15174    (set (match_operand:DI 0 "register_operand" "=D")
15175         (plus:DI (match_dup 1)
15176                  (const_int 8)))
15177    (use (reg:SI 19))]
15178   "TARGET_64BIT && (TARGET_SINGLE_STRINGOP || optimize_size)"
15179   "stosq"
15180   [(set_attr "type" "str")
15181    (set_attr "memory" "store")
15182    (set_attr "mode" "DI")])
15183
15184 (define_insn "strsetsi_1"
15185   [(set (mem:SI (match_operand:SI 1 "register_operand" "0"))
15186         (match_operand:SI 2 "register_operand" "a"))
15187    (set (match_operand:SI 0 "register_operand" "=D")
15188         (plus:SI (match_dup 1)
15189                  (const_int 4)))
15190    (use (reg:SI 19))]
15191   "!TARGET_64BIT && (TARGET_SINGLE_STRINGOP || optimize_size)"
15192   "{stosl|stosd}"
15193   [(set_attr "type" "str")
15194    (set_attr "memory" "store")
15195    (set_attr "mode" "SI")])
15196
15197 (define_insn "strsetsi_rex_1"
15198   [(set (mem:SI (match_operand:DI 1 "register_operand" "0"))
15199         (match_operand:SI 2 "register_operand" "a"))
15200    (set (match_operand:DI 0 "register_operand" "=D")
15201         (plus:DI (match_dup 1)
15202                  (const_int 4)))
15203    (use (reg:SI 19))]
15204   "TARGET_64BIT && (TARGET_SINGLE_STRINGOP || optimize_size)"
15205   "{stosl|stosd}"
15206   [(set_attr "type" "str")
15207    (set_attr "memory" "store")
15208    (set_attr "mode" "SI")])
15209
15210 (define_insn "strsethi_1"
15211   [(set (mem:HI (match_operand:SI 1 "register_operand" "0"))
15212         (match_operand:HI 2 "register_operand" "a"))
15213    (set (match_operand:SI 0 "register_operand" "=D")
15214         (plus:SI (match_dup 1)
15215                  (const_int 2)))
15216    (use (reg:SI 19))]
15217   "!TARGET_64BIT && (TARGET_SINGLE_STRINGOP || optimize_size)"
15218   "stosw"
15219   [(set_attr "type" "str")
15220    (set_attr "memory" "store")
15221    (set_attr "mode" "HI")])
15222
15223 (define_insn "strsethi_rex_1"
15224   [(set (mem:HI (match_operand:DI 1 "register_operand" "0"))
15225         (match_operand:HI 2 "register_operand" "a"))
15226    (set (match_operand:DI 0 "register_operand" "=D")
15227         (plus:DI (match_dup 1)
15228                  (const_int 2)))
15229    (use (reg:SI 19))]
15230   "TARGET_64BIT && (TARGET_SINGLE_STRINGOP || optimize_size)"
15231   "stosw"
15232   [(set_attr "type" "str")
15233    (set_attr "memory" "store")
15234    (set_attr "mode" "HI")])
15235
15236 (define_insn "strsetqi_1"
15237   [(set (mem:QI (match_operand:SI 1 "register_operand" "0"))
15238         (match_operand:QI 2 "register_operand" "a"))
15239    (set (match_operand:SI 0 "register_operand" "=D")
15240         (plus:SI (match_dup 1)
15241                  (const_int 1)))
15242    (use (reg:SI 19))]
15243   "!TARGET_64BIT && (TARGET_SINGLE_STRINGOP || optimize_size)"
15244   "stosb"
15245   [(set_attr "type" "str")
15246    (set_attr "memory" "store")
15247    (set_attr "mode" "QI")])
15248
15249 (define_insn "strsetqi_rex_1"
15250   [(set (mem:QI (match_operand:DI 1 "register_operand" "0"))
15251         (match_operand:QI 2 "register_operand" "a"))
15252    (set (match_operand:DI 0 "register_operand" "=D")
15253         (plus:DI (match_dup 1)
15254                  (const_int 1)))
15255    (use (reg:SI 19))]
15256   "TARGET_64BIT && (TARGET_SINGLE_STRINGOP || optimize_size)"
15257   "stosb"
15258   [(set_attr "type" "str")
15259    (set_attr "memory" "store")
15260    (set_attr "mode" "QI")])
15261
15262 (define_insn "rep_stosdi_rex64"
15263   [(set (match_operand:DI 1 "register_operand" "=c") (const_int 0))
15264    (set (match_operand:DI 0 "register_operand" "=D") 
15265         (plus:DI (ashift:DI (match_operand:DI 4 "register_operand" "1")
15266                             (const_int 3))
15267                  (match_operand:DI 3 "register_operand" "0")))
15268    (set (mem:BLK (match_dup 3))
15269         (const_int 0))
15270    (use (match_operand:DI 2 "register_operand" "a"))
15271    (use (match_dup 4))
15272    (use (reg:SI 19))]
15273   "TARGET_64BIT"
15274   "{rep\;stosq|rep stosq}"
15275   [(set_attr "type" "str")
15276    (set_attr "prefix_rep" "1")
15277    (set_attr "memory" "store")
15278    (set_attr "mode" "DI")])
15279
15280 (define_insn "rep_stossi"
15281   [(set (match_operand:SI 1 "register_operand" "=c") (const_int 0))
15282    (set (match_operand:SI 0 "register_operand" "=D") 
15283         (plus:SI (ashift:SI (match_operand:SI 4 "register_operand" "1")
15284                             (const_int 2))
15285                  (match_operand:SI 3 "register_operand" "0")))
15286    (set (mem:BLK (match_dup 3))
15287         (const_int 0))
15288    (use (match_operand:SI 2 "register_operand" "a"))
15289    (use (match_dup 4))
15290    (use (reg:SI 19))]
15291   "!TARGET_64BIT"
15292   "{rep\;stosl|rep stosd}"
15293   [(set_attr "type" "str")
15294    (set_attr "prefix_rep" "1")
15295    (set_attr "memory" "store")
15296    (set_attr "mode" "SI")])
15297
15298 (define_insn "rep_stossi_rex64"
15299   [(set (match_operand:DI 1 "register_operand" "=c") (const_int 0))
15300    (set (match_operand:DI 0 "register_operand" "=D") 
15301         (plus:DI (ashift:DI (match_operand:DI 4 "register_operand" "1")
15302                             (const_int 2))
15303                  (match_operand:DI 3 "register_operand" "0")))
15304    (set (mem:BLK (match_dup 3))
15305         (const_int 0))
15306    (use (match_operand:SI 2 "register_operand" "a"))
15307    (use (match_dup 4))
15308    (use (reg:SI 19))]
15309   "TARGET_64BIT"
15310   "{rep\;stosl|rep stosd}"
15311   [(set_attr "type" "str")
15312    (set_attr "prefix_rep" "1")
15313    (set_attr "memory" "store")
15314    (set_attr "mode" "SI")])
15315
15316 (define_insn "rep_stosqi"
15317   [(set (match_operand:SI 1 "register_operand" "=c") (const_int 0))
15318    (set (match_operand:SI 0 "register_operand" "=D") 
15319         (plus:SI (match_operand:SI 3 "register_operand" "0")
15320                  (match_operand:SI 4 "register_operand" "1")))
15321    (set (mem:BLK (match_dup 3))
15322         (const_int 0))
15323    (use (match_operand:QI 2 "register_operand" "a"))
15324    (use (match_dup 4))
15325    (use (reg:SI 19))]
15326   "!TARGET_64BIT"
15327   "{rep\;stosb|rep stosb}"
15328   [(set_attr "type" "str")
15329    (set_attr "prefix_rep" "1")
15330    (set_attr "memory" "store")
15331    (set_attr "mode" "QI")])
15332
15333 (define_insn "rep_stosqi_rex64"
15334   [(set (match_operand:DI 1 "register_operand" "=c") (const_int 0))
15335    (set (match_operand:DI 0 "register_operand" "=D") 
15336         (plus:DI (match_operand:DI 3 "register_operand" "0")
15337                  (match_operand:DI 4 "register_operand" "1")))
15338    (set (mem:BLK (match_dup 3))
15339         (const_int 0))
15340    (use (match_operand:QI 2 "register_operand" "a"))
15341    (use (match_dup 4))
15342    (use (reg:DI 19))]
15343   "TARGET_64BIT"
15344   "{rep\;stosb|rep stosb}"
15345   [(set_attr "type" "str")
15346    (set_attr "prefix_rep" "1")
15347    (set_attr "memory" "store")
15348    (set_attr "mode" "QI")])
15349
15350 (define_expand "cmpstrsi"
15351   [(set (match_operand:SI 0 "register_operand" "")
15352         (compare:SI (match_operand:BLK 1 "general_operand" "")
15353                     (match_operand:BLK 2 "general_operand" "")))
15354    (use (match_operand 3 "general_operand" ""))
15355    (use (match_operand 4 "immediate_operand" ""))]
15356   ""
15357 {
15358   rtx addr1, addr2, out, outlow, count, countreg, align;
15359
15360   out = operands[0];
15361   if (GET_CODE (out) != REG)
15362     out = gen_reg_rtx (SImode);
15363
15364   addr1 = copy_to_mode_reg (Pmode, XEXP (operands[1], 0));
15365   addr2 = copy_to_mode_reg (Pmode, XEXP (operands[2], 0));
15366   
15367   count = operands[3];
15368   countreg = ix86_zero_extend_to_Pmode (count);
15369
15370   /* %%% Iff we are testing strict equality, we can use known alignment
15371      to good advantage.  This may be possible with combine, particularly
15372      once cc0 is dead.  */
15373   align = operands[4];
15374
15375   emit_insn (gen_cld ());
15376   if (GET_CODE (count) == CONST_INT)
15377     {
15378       if (INTVAL (count) == 0)
15379         {
15380           emit_move_insn (operands[0], const0_rtx);
15381           DONE;
15382         }
15383       if (TARGET_64BIT)
15384         emit_insn (gen_cmpstrqi_nz_rex_1 (addr1, addr2, countreg, align,
15385                                           addr1, addr2, countreg));
15386       else
15387         emit_insn (gen_cmpstrqi_nz_1 (addr1, addr2, countreg, align,
15388                                       addr1, addr2, countreg));
15389     }
15390   else
15391     {
15392       if (TARGET_64BIT)
15393         {
15394           emit_insn (gen_cmpdi_1_rex64 (countreg, countreg));
15395           emit_insn (gen_cmpstrqi_rex_1 (addr1, addr2, countreg, align,
15396                                          addr1, addr2, countreg));
15397         }
15398       else
15399         {
15400           emit_insn (gen_cmpsi_1 (countreg, countreg));
15401           emit_insn (gen_cmpstrqi_1 (addr1, addr2, countreg, align,
15402                                      addr1, addr2, countreg));
15403         }
15404     }
15405
15406   outlow = gen_lowpart (QImode, out);
15407   emit_insn (gen_cmpintqi (outlow));
15408   emit_move_insn (out, gen_rtx_SIGN_EXTEND (SImode, outlow));
15409
15410   if (operands[0] != out)
15411     emit_move_insn (operands[0], out);
15412
15413   DONE;
15414 })
15415
15416 ;; Produce a tri-state integer (-1, 0, 1) from condition codes.
15417
15418 (define_expand "cmpintqi"
15419   [(set (match_dup 1)
15420         (gtu:QI (reg:CC 17) (const_int 0)))
15421    (set (match_dup 2)
15422         (ltu:QI (reg:CC 17) (const_int 0)))
15423    (parallel [(set (match_operand:QI 0 "register_operand" "")
15424                    (minus:QI (match_dup 1)
15425                              (match_dup 2)))
15426               (clobber (reg:CC 17))])]
15427   ""
15428   "operands[1] = gen_reg_rtx (QImode);
15429    operands[2] = gen_reg_rtx (QImode);")
15430
15431 ;; memcmp recognizers.  The `cmpsb' opcode does nothing if the count is
15432 ;; zero.  Emit extra code to make sure that a zero-length compare is EQ.
15433
15434 (define_insn "cmpstrqi_nz_1"
15435   [(set (reg:CC 17)
15436         (compare:CC (mem:BLK (match_operand:SI 4 "register_operand" "0"))
15437                     (mem:BLK (match_operand:SI 5 "register_operand" "1"))))
15438    (use (match_operand:SI 6 "register_operand" "2"))
15439    (use (match_operand:SI 3 "immediate_operand" "i"))
15440    (use (reg:SI 19))
15441    (clobber (match_operand:SI 0 "register_operand" "=S"))
15442    (clobber (match_operand:SI 1 "register_operand" "=D"))
15443    (clobber (match_operand:SI 2 "register_operand" "=c"))]
15444   "!TARGET_64BIT"
15445   "repz{\;| }cmpsb"
15446   [(set_attr "type" "str")
15447    (set_attr "mode" "QI")
15448    (set_attr "prefix_rep" "1")])
15449
15450 (define_insn "cmpstrqi_nz_rex_1"
15451   [(set (reg:CC 17)
15452         (compare:CC (mem:BLK (match_operand:DI 4 "register_operand" "0"))
15453                     (mem:BLK (match_operand:DI 5 "register_operand" "1"))))
15454    (use (match_operand:DI 6 "register_operand" "2"))
15455    (use (match_operand:SI 3 "immediate_operand" "i"))
15456    (use (reg:SI 19))
15457    (clobber (match_operand:DI 0 "register_operand" "=S"))
15458    (clobber (match_operand:DI 1 "register_operand" "=D"))
15459    (clobber (match_operand:DI 2 "register_operand" "=c"))]
15460   "TARGET_64BIT"
15461   "repz{\;| }cmpsb"
15462   [(set_attr "type" "str")
15463    (set_attr "mode" "QI")
15464    (set_attr "prefix_rep" "1")])
15465
15466 ;; The same, but the count is not known to not be zero.
15467
15468 (define_insn "cmpstrqi_1"
15469   [(set (reg:CC 17)
15470         (if_then_else:CC (ne (match_operand:SI 6 "register_operand" "2")
15471                              (const_int 0))
15472           (compare:CC (mem:BLK (match_operand:SI 4 "register_operand" "0"))
15473                       (mem:BLK (match_operand:SI 5 "register_operand" "1")))
15474           (const_int 0)))
15475    (use (match_operand:SI 3 "immediate_operand" "i"))
15476    (use (reg:CC 17))
15477    (use (reg:SI 19))
15478    (clobber (match_operand:SI 0 "register_operand" "=S"))
15479    (clobber (match_operand:SI 1 "register_operand" "=D"))
15480    (clobber (match_operand:SI 2 "register_operand" "=c"))]
15481   "!TARGET_64BIT"
15482   "repz{\;| }cmpsb"
15483   [(set_attr "type" "str")
15484    (set_attr "mode" "QI")
15485    (set_attr "prefix_rep" "1")])
15486
15487 (define_insn "cmpstrqi_rex_1"
15488   [(set (reg:CC 17)
15489         (if_then_else:CC (ne (match_operand:DI 6 "register_operand" "2")
15490                              (const_int 0))
15491           (compare:CC (mem:BLK (match_operand:DI 4 "register_operand" "0"))
15492                       (mem:BLK (match_operand:DI 5 "register_operand" "1")))
15493           (const_int 0)))
15494    (use (match_operand:SI 3 "immediate_operand" "i"))
15495    (use (reg:CC 17))
15496    (use (reg:SI 19))
15497    (clobber (match_operand:DI 0 "register_operand" "=S"))
15498    (clobber (match_operand:DI 1 "register_operand" "=D"))
15499    (clobber (match_operand:DI 2 "register_operand" "=c"))]
15500   "TARGET_64BIT"
15501   "repz{\;| }cmpsb"
15502   [(set_attr "type" "str")
15503    (set_attr "mode" "QI")
15504    (set_attr "prefix_rep" "1")])
15505
15506 (define_expand "strlensi"
15507   [(set (match_operand:SI 0 "register_operand" "")
15508         (unspec:SI [(match_operand:BLK 1 "general_operand" "")
15509                     (match_operand:QI 2 "immediate_operand" "")
15510                     (match_operand 3 "immediate_operand" "")] 0))]
15511   ""
15512 {
15513  if (ix86_expand_strlen (operands[0], operands[1], operands[2], operands[3]))
15514    DONE;
15515  else
15516    FAIL;
15517 })
15518
15519 (define_expand "strlendi"
15520   [(set (match_operand:DI 0 "register_operand" "")
15521         (unspec:DI [(match_operand:BLK 1 "general_operand" "")
15522                     (match_operand:QI 2 "immediate_operand" "")
15523                     (match_operand 3 "immediate_operand" "")] 0))]
15524   ""
15525 {
15526  if (ix86_expand_strlen (operands[0], operands[1], operands[2], operands[3]))
15527    DONE;
15528  else
15529    FAIL;
15530 })
15531
15532 (define_insn "strlenqi_1"
15533   [(set (match_operand:SI 0 "register_operand" "=&c")
15534         (unspec:SI [(mem:BLK (match_operand:SI 5 "register_operand" "1"))
15535                     (match_operand:QI 2 "register_operand" "a")
15536                     (match_operand:SI 3 "immediate_operand" "i")
15537                     (match_operand:SI 4 "register_operand" "0")] 0))
15538    (use (reg:SI 19))
15539    (clobber (match_operand:SI 1 "register_operand" "=D"))
15540    (clobber (reg:CC 17))]
15541   "!TARGET_64BIT"
15542   "repnz{\;| }scasb"
15543   [(set_attr "type" "str")
15544    (set_attr "mode" "QI")
15545    (set_attr "prefix_rep" "1")])
15546
15547 (define_insn "strlenqi_rex_1"
15548   [(set (match_operand:DI 0 "register_operand" "=&c")
15549         (unspec:DI [(mem:BLK (match_operand:DI 5 "register_operand" "1"))
15550                     (match_operand:QI 2 "register_operand" "a")
15551                     (match_operand:DI 3 "immediate_operand" "i")
15552                     (match_operand:DI 4 "register_operand" "0")] 0))
15553    (use (reg:SI 19))
15554    (clobber (match_operand:DI 1 "register_operand" "=D"))
15555    (clobber (reg:CC 17))]
15556   "TARGET_64BIT"
15557   "repnz{\;| }scasb"
15558   [(set_attr "type" "str")
15559    (set_attr "mode" "QI")
15560    (set_attr "prefix_rep" "1")])
15561
15562 ;; Peephole optimizations to clean up after cmpstr*.  This should be
15563 ;; handled in combine, but it is not currently up to the task.
15564 ;; When used for their truth value, the cmpstr* expanders generate
15565 ;; code like this:
15566 ;;
15567 ;;   repz cmpsb
15568 ;;   seta       %al
15569 ;;   setb       %dl
15570 ;;   cmpb       %al, %dl
15571 ;;   jcc        label
15572 ;;
15573 ;; The intermediate three instructions are unnecessary.
15574
15575 ;; This one handles cmpstr*_nz_1...
15576 (define_peephole2
15577   [(parallel[
15578      (set (reg:CC 17)
15579           (compare:CC (mem:BLK (match_operand 4 "register_operand" ""))
15580                       (mem:BLK (match_operand 5 "register_operand" ""))))
15581      (use (match_operand 6 "register_operand" ""))
15582      (use (match_operand:SI 3 "immediate_operand" ""))
15583      (use (reg:SI 19))
15584      (clobber (match_operand 0 "register_operand" ""))
15585      (clobber (match_operand 1 "register_operand" ""))
15586      (clobber (match_operand 2 "register_operand" ""))])
15587    (set (match_operand:QI 7 "register_operand" "")
15588         (gtu:QI (reg:CC 17) (const_int 0)))
15589    (set (match_operand:QI 8 "register_operand" "")
15590         (ltu:QI (reg:CC 17) (const_int 0)))
15591    (set (reg 17)
15592         (compare (match_dup 7) (match_dup 8)))
15593   ]
15594   "peep2_reg_dead_p (4, operands[7]) && peep2_reg_dead_p (4, operands[8])"
15595   [(parallel[
15596      (set (reg:CC 17)
15597           (compare:CC (mem:BLK (match_dup 4))
15598                       (mem:BLK (match_dup 5))))
15599      (use (match_dup 6))
15600      (use (match_dup 3))
15601      (use (reg:SI 19))
15602      (clobber (match_dup 0))
15603      (clobber (match_dup 1))
15604      (clobber (match_dup 2))])]
15605   "")
15606
15607 ;; ...and this one handles cmpstr*_1.
15608 (define_peephole2
15609   [(parallel[
15610      (set (reg:CC 17)
15611           (if_then_else:CC (ne (match_operand 6 "register_operand" "")
15612                                (const_int 0))
15613             (compare:CC (mem:BLK (match_operand 4 "register_operand" ""))
15614                         (mem:BLK (match_operand 5 "register_operand" "")))
15615             (const_int 0)))
15616      (use (match_operand:SI 3 "immediate_operand" ""))
15617      (use (reg:CC 17))
15618      (use (reg:SI 19))
15619      (clobber (match_operand 0 "register_operand" ""))
15620      (clobber (match_operand 1 "register_operand" ""))
15621      (clobber (match_operand 2 "register_operand" ""))])
15622    (set (match_operand:QI 7 "register_operand" "")
15623         (gtu:QI (reg:CC 17) (const_int 0)))
15624    (set (match_operand:QI 8 "register_operand" "")
15625         (ltu:QI (reg:CC 17) (const_int 0)))
15626    (set (reg 17)
15627         (compare (match_dup 7) (match_dup 8)))
15628   ]
15629   "peep2_reg_dead_p (4, operands[7]) && peep2_reg_dead_p (4, operands[8])"
15630   [(parallel[
15631      (set (reg:CC 17)
15632           (if_then_else:CC (ne (match_dup 6)
15633                                (const_int 0))
15634             (compare:CC (mem:BLK (match_dup 4))
15635                         (mem:BLK (match_dup 5)))
15636             (const_int 0)))
15637      (use (match_dup 3))
15638      (use (reg:CC 17))
15639      (use (reg:SI 19))
15640      (clobber (match_dup 0))
15641      (clobber (match_dup 1))
15642      (clobber (match_dup 2))])]
15643   "")
15644
15645
15646 \f
15647 ;; Conditional move instructions.
15648
15649 (define_expand "movdicc"
15650   [(set (match_operand:DI 0 "register_operand" "")
15651         (if_then_else:DI (match_operand 1 "comparison_operator" "")
15652                          (match_operand:DI 2 "general_operand" "")
15653                          (match_operand:DI 3 "general_operand" "")))]
15654   "TARGET_64BIT"
15655   "if (!ix86_expand_int_movcc (operands)) FAIL; DONE;")
15656
15657 (define_insn "x86_movdicc_0_m1_rex64"
15658   [(set (match_operand:DI 0 "register_operand" "=r")
15659         (if_then_else:DI (ltu (reg:CC 17) (const_int 0))
15660           (const_int -1)
15661           (const_int 0)))
15662    (clobber (reg:CC 17))]
15663   "TARGET_64BIT"
15664   "sbb{q}\t%0, %0"
15665   ; Since we don't have the proper number of operands for an alu insn,
15666   ; fill in all the blanks.
15667   [(set_attr "type" "alu")
15668    (set_attr "memory" "none")
15669    (set_attr "imm_disp" "false")
15670    (set_attr "mode" "DI")
15671    (set_attr "length_immediate" "0")])
15672
15673 (define_insn "*movdicc_c_rex64"
15674   [(set (match_operand:DI 0 "register_operand" "=r,r")
15675         (if_then_else:DI (match_operator 1 "ix86_comparison_operator" 
15676                                 [(reg 17) (const_int 0)])
15677                       (match_operand:DI 2 "nonimmediate_operand" "rm,0")
15678                       (match_operand:DI 3 "nonimmediate_operand" "0,rm")))]
15679   "TARGET_64BIT && TARGET_CMOVE
15680    && (GET_CODE (operands[2]) != MEM || GET_CODE (operands[3]) != MEM)"
15681   "@
15682    cmov%C1\t{%2, %0|%0, %2}
15683    cmov%c1\t{%3, %0|%0, %3}"
15684   [(set_attr "type" "icmov")
15685    (set_attr "mode" "DI")])
15686
15687 (define_expand "movsicc"
15688   [(set (match_operand:SI 0 "register_operand" "")
15689         (if_then_else:SI (match_operand 1 "comparison_operator" "")
15690                          (match_operand:SI 2 "general_operand" "")
15691                          (match_operand:SI 3 "general_operand" "")))]
15692   ""
15693   "if (!ix86_expand_int_movcc (operands)) FAIL; DONE;")
15694
15695 ;; Data flow gets confused by our desire for `sbbl reg,reg', and clearing
15696 ;; the register first winds up with `sbbl $0,reg', which is also weird.
15697 ;; So just document what we're doing explicitly.
15698
15699 (define_insn "x86_movsicc_0_m1"
15700   [(set (match_operand:SI 0 "register_operand" "=r")
15701         (if_then_else:SI (ltu (reg:CC 17) (const_int 0))
15702           (const_int -1)
15703           (const_int 0)))
15704    (clobber (reg:CC 17))]
15705   ""
15706   "sbb{l}\t%0, %0"
15707   ; Since we don't have the proper number of operands for an alu insn,
15708   ; fill in all the blanks.
15709   [(set_attr "type" "alu")
15710    (set_attr "memory" "none")
15711    (set_attr "imm_disp" "false")
15712    (set_attr "mode" "SI")
15713    (set_attr "length_immediate" "0")])
15714
15715 (define_insn "*movsicc_noc"
15716   [(set (match_operand:SI 0 "register_operand" "=r,r")
15717         (if_then_else:SI (match_operator 1 "ix86_comparison_operator" 
15718                                 [(reg 17) (const_int 0)])
15719                       (match_operand:SI 2 "nonimmediate_operand" "rm,0")
15720                       (match_operand:SI 3 "nonimmediate_operand" "0,rm")))]
15721   "TARGET_CMOVE
15722    && (GET_CODE (operands[2]) != MEM || GET_CODE (operands[3]) != MEM)"
15723   "@
15724    cmov%C1\t{%2, %0|%0, %2}
15725    cmov%c1\t{%3, %0|%0, %3}"
15726   [(set_attr "type" "icmov")
15727    (set_attr "mode" "SI")])
15728
15729 (define_expand "movhicc"
15730   [(set (match_operand:HI 0 "register_operand" "")
15731         (if_then_else:HI (match_operand 1 "comparison_operator" "")
15732                          (match_operand:HI 2 "nonimmediate_operand" "")
15733                          (match_operand:HI 3 "nonimmediate_operand" "")))]
15734   "TARGET_CMOVE && TARGET_HIMODE_MATH"
15735   "if (!ix86_expand_int_movcc (operands)) FAIL; DONE;")
15736
15737 (define_insn "*movhicc_noc"
15738   [(set (match_operand:HI 0 "register_operand" "=r,r")
15739         (if_then_else:HI (match_operator 1 "ix86_comparison_operator" 
15740                                 [(reg 17) (const_int 0)])
15741                       (match_operand:HI 2 "nonimmediate_operand" "rm,0")
15742                       (match_operand:HI 3 "nonimmediate_operand" "0,rm")))]
15743   "TARGET_CMOVE
15744    && (GET_CODE (operands[2]) != MEM || GET_CODE (operands[3]) != MEM)"
15745   "@
15746    cmov%C1\t{%2, %0|%0, %2}
15747    cmov%c1\t{%3, %0|%0, %3}"
15748   [(set_attr "type" "icmov")
15749    (set_attr "mode" "HI")])
15750
15751 (define_expand "movsfcc"
15752   [(set (match_operand:SF 0 "register_operand" "")
15753         (if_then_else:SF (match_operand 1 "comparison_operator" "")
15754                          (match_operand:SF 2 "register_operand" "")
15755                          (match_operand:SF 3 "register_operand" "")))]
15756   "TARGET_CMOVE"
15757   "if (! ix86_expand_fp_movcc (operands)) FAIL; DONE;")
15758
15759 (define_insn "*movsfcc_1"
15760   [(set (match_operand:SF 0 "register_operand" "=f,f,r,r")
15761         (if_then_else:SF (match_operator 1 "fcmov_comparison_operator" 
15762                                 [(reg 17) (const_int 0)])
15763                       (match_operand:SF 2 "nonimmediate_operand" "f,0,rm,0")
15764                       (match_operand:SF 3 "nonimmediate_operand" "0,f,0,rm")))]
15765   "TARGET_CMOVE
15766    && (GET_CODE (operands[2]) != MEM || GET_CODE (operands[3]) != MEM)"
15767   "@
15768    fcmov%F1\t{%2, %0|%0, %2}
15769    fcmov%f1\t{%3, %0|%0, %3}
15770    cmov%C1\t{%2, %0|%0, %2}
15771    cmov%c1\t{%3, %0|%0, %3}"
15772   [(set_attr "type" "fcmov,fcmov,icmov,icmov")
15773    (set_attr "mode" "SF,SF,SI,SI")])
15774
15775 (define_expand "movdfcc"
15776   [(set (match_operand:DF 0 "register_operand" "")
15777         (if_then_else:DF (match_operand 1 "comparison_operator" "")
15778                          (match_operand:DF 2 "register_operand" "")
15779                          (match_operand:DF 3 "register_operand" "")))]
15780   "TARGET_CMOVE"
15781   "if (! ix86_expand_fp_movcc (operands)) FAIL; DONE;")
15782
15783 (define_insn "*movdfcc_1"
15784   [(set (match_operand:DF 0 "register_operand" "=f,f,&r,&r")
15785         (if_then_else:DF (match_operator 1 "fcmov_comparison_operator" 
15786                                 [(reg 17) (const_int 0)])
15787                       (match_operand:DF 2 "nonimmediate_operand" "f,0,rm,0")
15788                       (match_operand:DF 3 "nonimmediate_operand" "0,f,0,rm")))]
15789   "!TARGET_64BIT && TARGET_CMOVE
15790    && (GET_CODE (operands[2]) != MEM || GET_CODE (operands[3]) != MEM)"
15791   "@
15792    fcmov%F1\t{%2, %0|%0, %2}
15793    fcmov%f1\t{%3, %0|%0, %3}
15794    #
15795    #"
15796   [(set_attr "type" "fcmov,fcmov,multi,multi")
15797    (set_attr "mode" "DF")])
15798
15799 (define_insn "*movdfcc_1_rex64"
15800   [(set (match_operand:DF 0 "register_operand" "=f,f,&r,&r")
15801         (if_then_else:DF (match_operator 1 "fcmov_comparison_operator" 
15802                                 [(reg 17) (const_int 0)])
15803                       (match_operand:DF 2 "nonimmediate_operand" "f,0,rm,0")
15804                       (match_operand:DF 3 "nonimmediate_operand" "0,f,0,rm")))]
15805   "TARGET_64BIT && TARGET_CMOVE
15806    && (GET_CODE (operands[2]) != MEM || GET_CODE (operands[3]) != MEM)"
15807   "@
15808    fcmov%F1\t{%2, %0|%0, %2}
15809    fcmov%f1\t{%3, %0|%0, %3}
15810    cmov%C1\t{%2, %0|%0, %2}
15811    cmov%c1\t{%3, %0|%0, %3}"
15812   [(set_attr "type" "fcmov,fcmov,icmov,icmov")
15813    (set_attr "mode" "DF")])
15814
15815 (define_split
15816   [(set (match_operand:DF 0 "register_operand" "")
15817         (if_then_else:DF (match_operator 1 "fcmov_comparison_operator" 
15818                                 [(match_operand 4 "" "") (const_int 0)])
15819                       (match_operand:DF 2 "nonimmediate_operand" "")
15820                       (match_operand:DF 3 "nonimmediate_operand" "")))]
15821   "!TARGET_64BIT && !ANY_FP_REG_P (operands[0]) && reload_completed"
15822   [(set (match_dup 2)
15823         (if_then_else:SI (match_op_dup 1 [(match_dup 4) (const_int 0)])
15824                       (match_dup 5)
15825                       (match_dup 7)))
15826    (set (match_dup 3)
15827         (if_then_else:SI (match_op_dup 1 [(match_dup 4) (const_int 0)])
15828                       (match_dup 6)
15829                       (match_dup 8)))]
15830   "split_di (operands+2, 1, operands+5, operands+6);
15831    split_di (operands+3, 1, operands+7, operands+8);
15832    split_di (operands, 1, operands+2, operands+3);")
15833
15834 (define_expand "movxfcc"
15835   [(set (match_operand:XF 0 "register_operand" "")
15836         (if_then_else:XF (match_operand 1 "comparison_operator" "")
15837                          (match_operand:XF 2 "register_operand" "")
15838                          (match_operand:XF 3 "register_operand" "")))]
15839   "!TARGET_64BIT && TARGET_CMOVE"
15840   "if (! ix86_expand_fp_movcc (operands)) FAIL; DONE;")
15841
15842 (define_expand "movtfcc"
15843   [(set (match_operand:TF 0 "register_operand" "")
15844         (if_then_else:TF (match_operand 1 "comparison_operator" "")
15845                          (match_operand:TF 2 "register_operand" "")
15846                          (match_operand:TF 3 "register_operand" "")))]
15847   "TARGET_CMOVE"
15848   "if (! ix86_expand_fp_movcc (operands)) FAIL; DONE;")
15849
15850 (define_insn "*movxfcc_1"
15851   [(set (match_operand:XF 0 "register_operand" "=f,f")
15852         (if_then_else:XF (match_operator 1 "fcmov_comparison_operator" 
15853                                 [(reg 17) (const_int 0)])
15854                       (match_operand:XF 2 "register_operand" "f,0")
15855                       (match_operand:XF 3 "register_operand" "0,f")))]
15856   "!TARGET_64BIT && TARGET_CMOVE"
15857   "@
15858    fcmov%F1\t{%2, %0|%0, %2}
15859    fcmov%f1\t{%3, %0|%0, %3}"
15860   [(set_attr "type" "fcmov")
15861    (set_attr "mode" "XF")])
15862
15863 (define_insn "*movtfcc_1"
15864   [(set (match_operand:TF 0 "register_operand" "=f,f")
15865         (if_then_else:TF (match_operator 1 "fcmov_comparison_operator" 
15866                                 [(reg 17) (const_int 0)])
15867                       (match_operand:TF 2 "register_operand" "f,0")
15868                       (match_operand:TF 3 "register_operand" "0,f")))]
15869   "TARGET_CMOVE"
15870   "@
15871    fcmov%F1\t{%2, %0|%0, %2}
15872    fcmov%f1\t{%3, %0|%0, %3}"
15873   [(set_attr "type" "fcmov")
15874    (set_attr "mode" "XF")])
15875
15876 (define_expand "minsf3"
15877   [(parallel [
15878      (set (match_operand:SF 0 "register_operand" "")
15879           (if_then_else:SF (lt (match_operand:SF 1 "register_operand" "")
15880                                (match_operand:SF 2 "nonimmediate_operand" ""))
15881                            (match_dup 1)
15882                            (match_dup 2)))
15883      (clobber (reg:CC 17))])]
15884   "TARGET_SSE"
15885   "")
15886
15887 (define_insn "*minsf"
15888   [(set (match_operand:SF 0 "register_operand" "=x#f,f#x,f#x")
15889         (if_then_else:SF (lt (match_operand:SF 1 "register_operand" "0,0,f#x")
15890                              (match_operand:SF 2 "nonimmediate_operand" "xm#f,f#x,0"))
15891                          (match_dup 1)
15892                          (match_dup 2)))
15893    (clobber (reg:CC 17))]
15894   "TARGET_SSE && TARGET_IEEE_FP"
15895   "#")
15896
15897 (define_insn "*minsf_nonieee"
15898   [(set (match_operand:SF 0 "register_operand" "=x#f,f#x")
15899         (if_then_else:SF (lt (match_operand:SF 1 "register_operand" "%0,0")
15900                              (match_operand:SF 2 "nonimmediate_operand" "xm#f,fm#x"))
15901                          (match_dup 1)
15902                          (match_dup 2)))
15903    (clobber (reg:CC 17))]
15904   "TARGET_SSE && !TARGET_IEEE_FP"
15905   "#")
15906
15907 (define_split
15908   [(set (match_operand:SF 0 "register_operand" "")
15909         (if_then_else:SF (lt (match_operand:SF 1 "register_operand" "")
15910                              (match_operand:SF 2 "nonimmediate_operand" ""))
15911                          (match_operand:SF 3 "register_operand" "")
15912                          (match_operand:SF 4 "nonimmediate_operand" "")))
15913    (clobber (reg:CC 17))]
15914   "SSE_REG_P (operands[0]) && reload_completed
15915    && ((operands_match_p (operands[1], operands[3])
15916         && operands_match_p (operands[2], operands[4]))
15917        || (operands_match_p (operands[1], operands[4])
15918            && operands_match_p (operands[2], operands[3])))"
15919   [(set (match_dup 0)
15920         (if_then_else:SF (lt (match_dup 1)
15921                              (match_dup 2))
15922                          (match_dup 1)
15923                          (match_dup 2)))])
15924
15925 ;; We can't represent the LT test directly.  Do this by swapping the operands.
15926
15927 (define_split
15928   [(set (match_operand:SF 0 "register_operand" "")
15929         (if_then_else:SF (lt (match_operand:SF 1 "register_operand" "")
15930                              (match_operand:SF 2 "register_operand" ""))
15931                          (match_operand:DF 3 "register_operand" "")
15932                          (match_operand:DF 4 "register_operand" "")))
15933    (clobber (reg:CC 17))]
15934   "FP_REG_P (operands[0]) && reload_completed
15935    && ((operands_match_p (operands[1], operands[3])
15936         && operands_match_p (operands[2], operands[4]))
15937        || (operands_match_p (operands[1], operands[4])
15938            && operands_match_p (operands[2], operands[3])))"
15939   [(set (reg:CCFP 17)
15940         (compare:CCFP (match_dup 2)
15941                       (match_dup 1)))
15942    (set (match_dup 0)
15943         (if_then_else:SF (ge (reg:CCFP 17) (const_int 0))
15944                          (match_dup 1)
15945                          (match_dup 2)))])
15946
15947 (define_insn "*minsf_sse"
15948   [(set (match_operand:SF 0 "register_operand" "=x")
15949         (if_then_else:SF (lt (match_operand:SF 1 "register_operand" "0")
15950                              (match_operand:SF 2 "nonimmediate_operand" "xm"))
15951                          (match_dup 1)
15952                          (match_dup 2)))]
15953   "TARGET_SSE && reload_completed"
15954   "minss\t{%2, %0|%0, %2}"
15955   [(set_attr "type" "sse")
15956    (set_attr "mode" "SF")])
15957
15958 (define_expand "mindf3"
15959   [(parallel [
15960      (set (match_operand:DF 0 "register_operand" "")
15961           (if_then_else:DF (lt (match_operand:DF 1 "register_operand" "")
15962                                (match_operand:DF 2 "nonimmediate_operand" ""))
15963                            (match_dup 1)
15964                            (match_dup 2)))
15965      (clobber (reg:CC 17))])]
15966   "TARGET_SSE2"
15967   "#")
15968
15969 (define_insn "*mindf"
15970   [(set (match_operand:DF 0 "register_operand" "=Y#f,f#Y,f#Y")
15971         (if_then_else:DF (lt (match_operand:DF 1 "register_operand" "0,0,f#Y")
15972                              (match_operand:DF 2 "nonimmediate_operand" "Ym#f,f#Y,0"))
15973                          (match_dup 1)
15974                          (match_dup 2)))
15975    (clobber (reg:CC 17))]
15976   "TARGET_SSE2 && TARGET_IEEE_FP"
15977   "#")
15978
15979 (define_insn "*mindf_nonieee"
15980   [(set (match_operand:DF 0 "register_operand" "=Y#f,f#Y")
15981         (if_then_else:DF (lt (match_operand:DF 1 "register_operand" "%0,0")
15982                              (match_operand:DF 2 "nonimmediate_operand" "Ym#f,fm#Y"))
15983                          (match_dup 1)
15984                          (match_dup 2)))
15985    (clobber (reg:CC 17))]
15986   "TARGET_SSE2 && !TARGET_IEEE_FP"
15987   "#")
15988
15989 (define_split
15990   [(set (match_operand:DF 0 "register_operand" "")
15991         (if_then_else:DF (lt (match_operand:DF 1 "register_operand" "")
15992                              (match_operand:DF 2 "nonimmediate_operand" ""))
15993                          (match_operand:DF 3 "register_operand" "")
15994                          (match_operand:DF 4 "nonimmediate_operand" "")))
15995    (clobber (reg:CC 17))]
15996   "SSE_REG_P (operands[0]) && reload_completed
15997    && ((operands_match_p (operands[1], operands[3])
15998         && operands_match_p (operands[2], operands[4]))
15999        || (operands_match_p (operands[1], operands[4])
16000            && operands_match_p (operands[2], operands[3])))"
16001   [(set (match_dup 0)
16002         (if_then_else:DF (lt (match_dup 1)
16003                              (match_dup 2))
16004                          (match_dup 1)
16005                          (match_dup 2)))])
16006
16007 ;; We can't represent the LT test directly.  Do this by swapping the operands.
16008 (define_split
16009   [(set (match_operand:DF 0 "register_operand" "")
16010         (if_then_else:DF (lt (match_operand:DF 1 "register_operand" "")
16011                              (match_operand:DF 2 "register_operand" ""))
16012                          (match_operand:DF 3 "register_operand" "")
16013                          (match_operand:DF 4 "register_operand" "")))
16014    (clobber (reg:CC 17))]
16015   "FP_REG_P (operands[0]) && reload_completed
16016    && ((operands_match_p (operands[1], operands[3])
16017         && operands_match_p (operands[2], operands[4]))
16018        || (operands_match_p (operands[1], operands[4])
16019            && operands_match_p (operands[2], operands[3])))"
16020   [(set (reg:CCFP 17)
16021         (compare:CCFP (match_dup 2)
16022                       (match_dup 2)))
16023    (set (match_dup 0)
16024         (if_then_else:DF (ge (reg:CCFP 17) (const_int 0))
16025                          (match_dup 1)
16026                          (match_dup 2)))])
16027
16028 (define_insn "*mindf_sse"
16029   [(set (match_operand:DF 0 "register_operand" "=Y")
16030         (if_then_else:DF (lt (match_operand:DF 1 "register_operand" "0")
16031                              (match_operand:DF 2 "nonimmediate_operand" "Ym"))
16032                          (match_dup 1)
16033                          (match_dup 2)))]
16034   "TARGET_SSE2 && reload_completed"
16035   "minsd\t{%2, %0|%0, %2}"
16036   [(set_attr "type" "sse")
16037    (set_attr "mode" "DF")])
16038
16039 (define_expand "maxsf3"
16040   [(parallel [
16041      (set (match_operand:SF 0 "register_operand" "")
16042           (if_then_else:SF (gt (match_operand:SF 1 "register_operand" "")
16043                                (match_operand:SF 2 "nonimmediate_operand" ""))
16044                            (match_dup 1)
16045                            (match_dup 2)))
16046      (clobber (reg:CC 17))])]
16047   "TARGET_SSE"
16048   "#")
16049
16050 (define_insn "*maxsf"
16051   [(set (match_operand:SF 0 "register_operand" "=x#f,f#x,f#x")
16052         (if_then_else:SF (gt (match_operand:SF 1 "register_operand" "0,0,f#x")
16053                              (match_operand:SF 2 "nonimmediate_operand" "xm#f,fm#x,0"))
16054                          (match_dup 1)
16055                          (match_dup 2)))
16056    (clobber (reg:CC 17))]
16057   "TARGET_SSE && TARGET_IEEE_FP"
16058   "#")
16059
16060 (define_insn "*maxsf_nonieee"
16061   [(set (match_operand:SF 0 "register_operand" "=x#f,f#x")
16062         (if_then_else:SF (gt (match_operand:SF 1 "register_operand" "%0,0")
16063                              (match_operand:SF 2 "nonimmediate_operand" "xm#f,fm#x"))
16064                          (match_dup 1)
16065                          (match_dup 2)))
16066    (clobber (reg:CC 17))]
16067   "TARGET_SSE && !TARGET_IEEE_FP"
16068   "#")
16069
16070 (define_split
16071   [(set (match_operand:SF 0 "register_operand" "")
16072         (if_then_else:SF (gt (match_operand:SF 1 "register_operand" "")
16073                              (match_operand:SF 2 "nonimmediate_operand" ""))
16074                          (match_operand:SF 3 "register_operand" "")
16075                          (match_operand:SF 4 "nonimmediate_operand" "")))
16076    (clobber (reg:CC 17))]
16077   "SSE_REG_P (operands[0]) && reload_completed
16078    && ((operands_match_p (operands[1], operands[3])
16079         && operands_match_p (operands[2], operands[4]))
16080        || (operands_match_p (operands[1], operands[4])
16081            && operands_match_p (operands[2], operands[3])))"
16082   [(set (match_dup 0)
16083         (if_then_else:SF (gt (match_dup 1)
16084                              (match_dup 2))
16085                          (match_dup 1)
16086                          (match_dup 2)))])
16087
16088 (define_split
16089   [(set (match_operand:SF 0 "register_operand" "")
16090         (if_then_else:SF (gt (match_operand:SF 1 "register_operand" "")
16091                              (match_operand:SF 2 "register_operand" ""))
16092                          (match_operand:SF 3 "register_operand" "")
16093                          (match_operand:SF 4 "register_operand" "")))
16094    (clobber (reg:CC 17))]
16095   "FP_REG_P (operands[0]) && reload_completed
16096    && ((operands_match_p (operands[1], operands[3])
16097         && operands_match_p (operands[2], operands[4]))
16098        || (operands_match_p (operands[1], operands[4])
16099            && operands_match_p (operands[2], operands[3])))"
16100   [(set (reg:CCFP 17)
16101         (compare:CCFP (match_dup 1)
16102                       (match_dup 2)))
16103    (set (match_dup 0)
16104         (if_then_else:SF (gt (reg:CCFP 17) (const_int 0))
16105                          (match_dup 1)
16106                          (match_dup 2)))])
16107
16108 (define_insn "*maxsf_sse"
16109   [(set (match_operand:SF 0 "register_operand" "=x")
16110         (if_then_else:SF (gt (match_operand:SF 1 "register_operand" "0")
16111                              (match_operand:SF 2 "nonimmediate_operand" "xm"))
16112                          (match_dup 1)
16113                          (match_dup 2)))]
16114   "TARGET_SSE && reload_completed"
16115   "maxss\t{%2, %0|%0, %2}"
16116   [(set_attr "type" "sse")
16117    (set_attr "mode" "SF")])
16118
16119 (define_expand "maxdf3"
16120   [(parallel [
16121      (set (match_operand:DF 0 "register_operand" "")
16122           (if_then_else:DF (gt (match_operand:DF 1 "register_operand" "")
16123                                (match_operand:DF 2 "nonimmediate_operand" ""))
16124                            (match_dup 1)
16125                            (match_dup 2)))
16126      (clobber (reg:CC 17))])]
16127   "TARGET_SSE2"
16128   "#")
16129
16130 (define_insn "*maxdf"
16131   [(set (match_operand:DF 0 "register_operand" "=Y#f,f#Y,f#Y")
16132         (if_then_else:DF (gt (match_operand:DF 1 "register_operand" "0,0,f#Y")
16133                              (match_operand:DF 2 "nonimmediate_operand" "Ym#f,fm#Y,0"))
16134                          (match_dup 1)
16135                          (match_dup 2)))
16136    (clobber (reg:CC 17))]
16137   "TARGET_SSE2 && TARGET_IEEE_FP"
16138   "#")
16139
16140 (define_insn "*maxdf_nonieee"
16141   [(set (match_operand:DF 0 "register_operand" "=Y#f,f#Y")
16142         (if_then_else:DF (gt (match_operand:DF 1 "register_operand" "%0,0")
16143                              (match_operand:DF 2 "nonimmediate_operand" "Ym#f,fm#Y"))
16144                          (match_dup 1)
16145                          (match_dup 2)))
16146    (clobber (reg:CC 17))]
16147   "TARGET_SSE2 && !TARGET_IEEE_FP"
16148   "#")
16149
16150 (define_split
16151   [(set (match_operand:DF 0 "register_operand" "")
16152         (if_then_else:DF (gt (match_operand:DF 1 "register_operand" "")
16153                              (match_operand:DF 2 "nonimmediate_operand" ""))
16154                          (match_operand:DF 3 "register_operand" "")
16155                          (match_operand:DF 4 "nonimmediate_operand" "")))
16156    (clobber (reg:CC 17))]
16157   "SSE_REG_P (operands[0]) && reload_completed
16158    && ((operands_match_p (operands[1], operands[3])
16159         && operands_match_p (operands[2], operands[4]))
16160        || (operands_match_p (operands[1], operands[4])
16161            && operands_match_p (operands[2], operands[3])))"
16162   [(set (match_dup 0)
16163         (if_then_else:DF (gt (match_dup 1)
16164                              (match_dup 2))
16165                          (match_dup 1)
16166                          (match_dup 2)))])
16167
16168 (define_split
16169   [(set (match_operand:DF 0 "register_operand" "")
16170         (if_then_else:DF (gt (match_operand:DF 1 "register_operand" "")
16171                              (match_operand:DF 2 "register_operand" ""))
16172                          (match_operand:DF 3 "register_operand" "")
16173                          (match_operand:DF 4 "register_operand" "")))
16174    (clobber (reg:CC 17))]
16175   "FP_REG_P (operands[0]) && reload_completed
16176    && ((operands_match_p (operands[1], operands[3])
16177         && operands_match_p (operands[2], operands[4]))
16178        || (operands_match_p (operands[1], operands[4])
16179            && operands_match_p (operands[2], operands[3])))"
16180   [(set (reg:CCFP 17)
16181         (compare:CCFP (match_dup 1)
16182                       (match_dup 2)))
16183    (set (match_dup 0)
16184         (if_then_else:DF (gt (reg:CCFP 17) (const_int 0))
16185                          (match_dup 1)
16186                          (match_dup 2)))])
16187
16188 (define_insn "*maxdf_sse"
16189   [(set (match_operand:DF 0 "register_operand" "=Y")
16190         (if_then_else:DF (gt (match_operand:DF 1 "register_operand" "0")
16191                              (match_operand:DF 2 "nonimmediate_operand" "Ym"))
16192                          (match_dup 1)
16193                          (match_dup 2)))]
16194   "TARGET_SSE2 && reload_completed"
16195   "maxsd\t{%2, %0|%0, %2}"
16196   [(set_attr "type" "sse")
16197    (set_attr "mode" "DF")])
16198 \f
16199 ;; Misc patterns (?)
16200
16201 ;; This pattern exists to put a dependency on all ebp-based memory accesses.
16202 ;; Otherwise there will be nothing to keep
16203 ;; 
16204 ;; [(set (reg ebp) (reg esp))]
16205 ;; [(set (reg esp) (plus (reg esp) (const_int -160000)))
16206 ;;  (clobber (eflags)]
16207 ;; [(set (mem (plus (reg ebp) (const_int -160000))) (const_int 0))]
16208 ;;
16209 ;; in proper program order.
16210 (define_expand "pro_epilogue_adjust_stack"
16211   [(parallel [(set (match_operand:SI 0 "register_operand" "=r,r")
16212                    (plus:SI (match_operand:SI 1 "register_operand" "0,r")
16213                             (match_operand:SI 2 "immediate_operand" "i,i")))
16214               (clobber (reg:CC 17))
16215               (clobber (mem:BLK (scratch)))])]
16216  ""
16217 {
16218   if (TARGET_64BIT)
16219     {
16220       emit_insn (gen_pro_epilogue_adjust_stack_rex64
16221                  (operands[0], operands[1], operands[2]));
16222       DONE;
16223     }
16224 })
16225
16226 (define_insn "*pro_epilogue_adjust_stack_1"
16227   [(set (match_operand:SI 0 "register_operand" "=r,r")
16228         (plus:SI (match_operand:SI 1 "register_operand" "0,r")
16229                  (match_operand:SI 2 "immediate_operand" "i,i")))
16230    (clobber (reg:CC 17))
16231    (clobber (mem:BLK (scratch)))]
16232   "!TARGET_64BIT"
16233 {
16234   switch (get_attr_type (insn))
16235     {
16236     case TYPE_IMOV:
16237       return "mov{l}\t{%1, %0|%0, %1}";
16238
16239     case TYPE_ALU:
16240       if (GET_CODE (operands[2]) == CONST_INT
16241           && (INTVAL (operands[2]) == 128
16242               || (INTVAL (operands[2]) < 0
16243                   && INTVAL (operands[2]) != -128)))
16244         {
16245           operands[2] = GEN_INT (-INTVAL (operands[2]));
16246           return "sub{l}\t{%2, %0|%0, %2}";
16247         }
16248       return "add{l}\t{%2, %0|%0, %2}";
16249
16250     case TYPE_LEA:
16251       operands[2] = SET_SRC (XVECEXP (PATTERN (insn), 0, 0));
16252       return "lea{l}\t{%a2, %0|%0, %a2}";
16253
16254     default:
16255       abort ();
16256     }
16257 }
16258   [(set (attr "type")
16259         (cond [(eq_attr "alternative" "0")
16260                  (const_string "alu")
16261                (match_operand:SI 2 "const0_operand" "")
16262                  (const_string "imov")
16263               ]
16264               (const_string "lea")))
16265    (set_attr "mode" "SI")])
16266
16267 (define_insn "pro_epilogue_adjust_stack_rex64"
16268   [(set (match_operand:DI 0 "register_operand" "=r,r")
16269         (plus:DI (match_operand:DI 1 "register_operand" "0,r")
16270                  (match_operand:DI 2 "x86_64_immediate_operand" "e,e")))
16271    (clobber (reg:CC 17))
16272    (clobber (mem:BLK (scratch)))]
16273   "TARGET_64BIT"
16274 {
16275   switch (get_attr_type (insn))
16276     {
16277     case TYPE_IMOV:
16278       return "mov{q}\t{%1, %0|%0, %1}";
16279
16280     case TYPE_ALU:
16281       if (GET_CODE (operands[2]) == CONST_INT
16282           && (INTVAL (operands[2]) == 128
16283               || (INTVAL (operands[2]) < 0
16284                   && INTVAL (operands[2]) != -128)))
16285         {
16286           operands[2] = GEN_INT (-INTVAL (operands[2]));
16287           return "sub{q}\t{%2, %0|%0, %2}";
16288         }
16289       return "add{q}\t{%2, %0|%0, %2}";
16290
16291     case TYPE_LEA:
16292       operands[2] = SET_SRC (XVECEXP (PATTERN (insn), 0, 0));
16293       return "lea{q}\t{%a2, %0|%0, %a2}";
16294
16295     default:
16296       abort ();
16297     }
16298 }
16299   [(set (attr "type")
16300         (cond [(eq_attr "alternative" "0")
16301                  (const_string "alu")
16302                (match_operand:DI 2 "const0_operand" "")
16303                  (const_string "imov")
16304               ]
16305               (const_string "lea")))
16306    (set_attr "mode" "DI")])
16307
16308
16309 ;; Placeholder for the conditional moves.  This one is split eighter to SSE
16310 ;; based moves emulation or to usual cmove sequence.  Little bit unfortunate
16311 ;; fact is that compares supported by the cmp??ss instructions are exactly
16312 ;; swapped of those supported by cmove sequence.
16313 ;; The EQ/NE comparisons also needs bit care, since they are not directly
16314 ;; supported by i387 comparisons and we do need to emit two conditional moves
16315 ;; in tandem.
16316
16317 (define_insn "sse_movsfcc"
16318   [(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")
16319         (if_then_else:SF (match_operator 1 "sse_comparison_operator"
16320                         [(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")
16321                          (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")])
16322                       (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")
16323                       (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")))
16324    (clobber (match_scratch:SF 6 "=2,&4,X,X,X,X,X,X,X,X"))
16325    (clobber (reg:CC 17))]
16326   "TARGET_SSE
16327    && (GET_CODE (operands[2]) != MEM || GET_CODE (operands[3]) != MEM)
16328    && (!TARGET_IEEE_FP
16329        || (GET_CODE (operands[1]) != EQ && GET_CODE (operands[1]) != NE))"
16330   "#")
16331
16332 (define_insn "sse_movsfcc_eq"
16333   [(set (match_operand:SF 0 "register_operand" "=&x#rf,x#rf,?f#xr,?f#xr,?r#xf,?r#xf")
16334         (if_then_else:SF (eq (match_operand:SF 3 "nonimmediate_operand" "%0#fx,x#fx,f#x,xm#f,f#x,xm#f")
16335                              (match_operand:SF 4 "nonimmediate_operand" "xm#f,xm#f,f#x,x#f,f#x,x#f"))
16336                       (match_operand:SF 1 "nonimmediate_operand" "x#fr,0#fr,0#fx,0#fx,0#rx,0#rx")
16337                       (match_operand:SF 2 "nonimmediate_operand" "x#fr,x#fr,f#fx,f#fx,rm#rx,rm#rx")))
16338    (clobber (match_scratch:SF 5 "=1,&3,X,X,X,X"))
16339    (clobber (reg:CC 17))]
16340   "TARGET_SSE
16341    && (GET_CODE (operands[2]) != MEM || GET_CODE (operands[3]) != MEM)"
16342   "#")
16343
16344 (define_insn "sse_movdfcc"
16345   [(set (match_operand:DF 0 "register_operand" "=&x#rf,x#rf,?f#xr,?f#xr,?f#xr,?f#xr,?r#xf,?r#xf,?r#xf,?r#xf")
16346         (if_then_else:DF (match_operator 1 "sse_comparison_operator"
16347                         [(match_operand:DF 4 "nonimmediate_operand" "0#fx,x#fx,f#x,f#x,xm#f,xm#f,f#x,f#x,xm#f,xm#f")
16348                          (match_operand:DF 5 "nonimmediate_operand" "xm#f,xm#f,f#x,f#x,x#f,x#f,f#x,f#x,x#f,x#f")])
16349                       (match_operand:DF 2 "nonimmediate_operand" "x#fr,0#fr,f#fx,0#fx,f#fx,0#fx,rm#rx,0#rx,rm#rx,0#rx")
16350                       (match_operand:DF 3 "nonimmediate_operand" "x#fr,x#fr,0#fx,f#fx,0#fx,f#fx,0#fx,rm#rx,0#rx,rm#rx")))
16351    (clobber (match_scratch:DF 6 "=2,&4,X,X,X,X,X,X,X,X"))
16352    (clobber (reg:CC 17))]
16353   "TARGET_SSE2
16354    && (GET_CODE (operands[2]) != MEM || GET_CODE (operands[3]) != MEM)
16355    && (!TARGET_IEEE_FP
16356        || (GET_CODE (operands[1]) != EQ && GET_CODE (operands[1]) != NE))"
16357   "#")
16358
16359 (define_insn "sse_movdfcc_eq"
16360   [(set (match_operand:DF 0 "register_operand" "=&x#rf,x#rf,?f#xr,?f#xr,?r#xf,?r#xf")
16361         (if_then_else:DF (eq (match_operand:DF 3 "nonimmediate_operand" "%0#fx,x#fx,f#x,xm#f,f#x,xm#f")
16362                              (match_operand:DF 4 "nonimmediate_operand" "xm#f,xm#f,f#x,x#f,f#x,x#f"))
16363                       (match_operand:DF 1 "nonimmediate_operand" "x#fr,0#fr,0#fx,0#fx,0#rx,0#rx")
16364                       (match_operand:DF 2 "nonimmediate_operand" "x#fr,x#fr,f#fx,f#fx,rm#rx,rm#rx")))
16365    (clobber (match_scratch:DF 5 "=1,&3,X,X,X,X"))
16366    (clobber (reg:CC 17))]
16367   "TARGET_SSE
16368    && (GET_CODE (operands[2]) != MEM || GET_CODE (operands[3]) != MEM)"
16369   "#")
16370
16371 ;; For non-sse moves just expand the usual cmove sequence.
16372 (define_split
16373   [(set (match_operand 0 "register_operand" "")
16374         (if_then_else (match_operator 1 "comparison_operator"
16375                         [(match_operand 4 "nonimmediate_operand" "")
16376                          (match_operand 5 "register_operand" "")])
16377                       (match_operand 2 "nonimmediate_operand" "")
16378                       (match_operand 3 "nonimmediate_operand" "")))
16379    (clobber (match_operand 6 "" ""))
16380    (clobber (reg:CC 17))]
16381   "!SSE_REG_P (operands[0]) && reload_completed
16382    && VALID_SSE_REG_MODE (GET_MODE (operands[0]))"
16383   [(const_int 0)]
16384 {
16385    ix86_compare_op0 = operands[5];
16386    ix86_compare_op1 = operands[4];
16387    operands[1] = gen_rtx_fmt_ee (swap_condition (GET_CODE (operands[1])),
16388                                  VOIDmode, operands[5], operands[4]);
16389    ix86_expand_fp_movcc (operands);
16390    DONE;
16391 })
16392
16393 ;; Split SSE based conditional move into seqence:
16394 ;; cmpCC op0, op4   -  set op0 to 0 or ffffffff depending on the comparison
16395 ;; and   op2, op0   -  zero op2 if comparison was false
16396 ;; nand  op0, op3   -  load op3 to op0 if comparison was false
16397 ;; or    op2, op0   -  get the non-zero one into the result.
16398 (define_split
16399   [(set (match_operand 0 "register_operand" "")
16400         (if_then_else (match_operator 1 "sse_comparison_operator"
16401                         [(match_operand 4 "register_operand" "")
16402                          (match_operand 5 "nonimmediate_operand" "")])
16403                       (match_operand 2 "register_operand" "")
16404                       (match_operand 3 "register_operand" "")))
16405    (clobber (match_operand 6 "" ""))
16406    (clobber (reg:CC 17))]
16407   "SSE_REG_P (operands[0]) && reload_completed"
16408   [(set (match_dup 4) (match_op_dup 1 [(match_dup 4) (match_dup 5)]))
16409    (set (subreg:TI (match_dup 2) 0) (and:TI (subreg:TI (match_dup 2) 0)
16410                                             (subreg:TI (match_dup 4) 0)))
16411    (set (subreg:TI (match_dup 4) 0) (and:TI (not:TI (subreg:TI (match_dup 4) 0))
16412                                             (subreg:TI (match_dup 3) 0)))
16413    (set (subreg:TI (match_dup 0) 0) (ior:TI (subreg:TI (match_dup 6) 0)
16414                                             (subreg:TI (match_dup 7) 0)))]
16415 {
16416   PUT_MODE (operands[1], GET_MODE (operands[0]));
16417   if (operands_match_p (operands[0], operands[4]))
16418     operands[6] = operands[4], operands[7] = operands[2];
16419   else
16420     operands[6] = operands[2], operands[7] = operands[4];
16421 })
16422
16423 ;; Special case of conditional move we can handle effectivly.
16424 ;; Do not brother with the integer/floating point case, since these are
16425 ;; bot considerably slower, unlike in the generic case.
16426 (define_insn "*sse_movsfcc_const0_1"
16427   [(set (match_operand:SF 0 "register_operand" "=x")
16428         (if_then_else:SF (match_operator 1 "sse_comparison_operator"
16429                         [(match_operand:SF 4 "register_operand" "0")
16430                          (match_operand:SF 5 "nonimmediate_operand" "xm")])
16431                       (match_operand:SF 2 "register_operand" "x")
16432                       (match_operand:SF 3 "const0_operand" "X")))]
16433   "TARGET_SSE"
16434   "#")
16435
16436 (define_insn "*sse_movsfcc_const0_2"
16437   [(set (match_operand:SF 0 "register_operand" "=x")
16438         (if_then_else:SF (match_operator 1 "sse_comparison_operator"
16439                         [(match_operand:SF 4 "register_operand" "0")
16440                          (match_operand:SF 5 "nonimmediate_operand" "xm")])
16441                       (match_operand:SF 2 "const0_operand" "x")
16442                       (match_operand:SF 3 "register_operand" "X")))]
16443   "TARGET_SSE"
16444   "#")
16445
16446 (define_insn "*sse_movsfcc_const0_3"
16447   [(set (match_operand:SF 0 "register_operand" "=x")
16448         (if_then_else:SF (match_operator 1 "fcmov_comparison_operator"
16449                         [(match_operand:SF 4 "nonimmediate_operand" "xm")
16450                          (match_operand:SF 5 "register_operand" "0")])
16451                       (match_operand:SF 2 "register_operand" "x")
16452                       (match_operand:SF 3 "const0_operand" "X")))]
16453   "TARGET_SSE"
16454   "#")
16455
16456 (define_insn "*sse_movsfcc_const0_4"
16457   [(set (match_operand:SF 0 "register_operand" "=x")
16458         (if_then_else:SF (match_operator 1 "fcmov_comparison_operator"
16459                         [(match_operand:SF 4 "nonimmediate_operand" "xm")
16460                          (match_operand:SF 5 "register_operand" "0")])
16461                       (match_operand:SF 2 "const0_operand" "x")
16462                       (match_operand:SF 3 "register_operand" "X")))]
16463   "TARGET_SSE"
16464   "#")
16465
16466 (define_insn "*sse_movdfcc_const0_1"
16467   [(set (match_operand:SF 0 "register_operand" "=x")
16468         (if_then_else:SF (match_operator 1 "sse_comparison_operator"
16469                         [(match_operand:SF 4 "register_operand" "0")
16470                          (match_operand:SF 5 "nonimmediate_operand" "xm")])
16471                       (match_operand:SF 2 "register_operand" "x")
16472                       (match_operand:SF 3 "const0_operand" "X")))]
16473   "TARGET_SSE2"
16474   "#")
16475
16476 (define_insn "*sse_movdfcc_const0_2"
16477   [(set (match_operand:SF 0 "register_operand" "=x")
16478         (if_then_else:SF (match_operator 1 "sse_comparison_operator"
16479                         [(match_operand:SF 4 "register_operand" "0")
16480                          (match_operand:SF 5 "nonimmediate_operand" "xm")])
16481                       (match_operand:SF 2 "const0_operand" "x")
16482                       (match_operand:SF 3 "register_operand" "X")))]
16483   "TARGET_SSE2"
16484   "#")
16485
16486 (define_insn "*sse_movdfcc_const0_3"
16487   [(set (match_operand:SF 0 "register_operand" "=x")
16488         (if_then_else:SF (match_operator 1 "fcmov_comparison_operator"
16489                         [(match_operand:SF 4 "nonimmediate_operand" "xm")
16490                          (match_operand:SF 5 "register_operand" "0")])
16491                       (match_operand:SF 2 "register_operand" "x")
16492                       (match_operand:SF 3 "const0_operand" "X")))]
16493   "TARGET_SSE2"
16494   "#")
16495
16496 (define_insn "*sse_movdfcc_const0_4"
16497   [(set (match_operand:SF 0 "register_operand" "=x")
16498         (if_then_else:SF (match_operator 1 "fcmov_comparison_operator"
16499                         [(match_operand:SF 4 "nonimmediate_operand" "xm")
16500                          (match_operand:SF 5 "register_operand" "0")])
16501                       (match_operand:SF 2 "const0_operand" "x")
16502                       (match_operand:SF 3 "register_operand" "X")))]
16503   "TARGET_SSE2"
16504   "#")
16505
16506 (define_split
16507   [(set (match_operand 0 "register_operand" "")
16508         (if_then_else (match_operator 1 "comparison_operator"
16509                         [(match_operand 4 "register_operand" "")
16510                          (match_operand 5 "nonimmediate_operand" "")])
16511                       (match_operand 2 "nonmemory_operand" "")
16512                       (match_operand 3 "nonmemory_operand" "")))]
16513   "SSE_REG_P (operands[0]) && reload_completed
16514    && (const0_operand (operands[2], GET_MODE (operands[0]))
16515        || const0_operand (operands[3], GET_MODE (operands[0])))"
16516   [(set (match_dup 0) (match_op_dup 1 [(match_dup 0) (match_dup 5)]))
16517    (set (subreg:TI (match_dup 0) 0) (and:TI (match_dup 6)
16518                                             (subreg:TI (match_dup 7) 0)))]
16519 {
16520   PUT_MODE (operands[1], GET_MODE (operands[0]));
16521   if (!sse_comparison_operator (operands[1], VOIDmode))
16522     {
16523       rtx tmp = operands[5];
16524       operands[5] = operands[4];
16525       operands[4] = tmp;
16526       PUT_CODE (operands[1], swap_condition (GET_CODE (operands[1])));
16527     }
16528   if (const0_operand (operands[2], GET_MODE (operands[0])))
16529     {
16530       operands[7] = operands[3];
16531       operands[6] = gen_rtx_NOT (TImode, gen_rtx_SUBREG (TImode, operands[0],
16532                                                          0));
16533     }
16534   else
16535     {
16536       operands[7] = operands[2];
16537       operands[6] = gen_rtx_SUBREG (TImode, operands[0], 0);
16538     }
16539 })
16540
16541 (define_expand "allocate_stack_worker"
16542   [(match_operand:SI 0 "register_operand" "")]
16543   "TARGET_STACK_PROBE"
16544 {
16545   if (TARGET_64BIT)
16546     emit_insn (gen_allocate_stack_worker_rex64 (operands[0]));
16547   else
16548     emit_insn (gen_allocate_stack_worker_1 (operands[0]));
16549   DONE;
16550 })
16551
16552 (define_insn "allocate_stack_worker_1"
16553   [(unspec:SI [(match_operand:SI 0 "register_operand" "a")] 3)
16554    (set (reg:SI 7) (minus:SI (reg:SI 7) (match_dup 0)))
16555    (clobber (match_dup 0))
16556    (clobber (reg:CC 17))]
16557   "!TARGET_64BIT && TARGET_STACK_PROBE"
16558   "call\t__alloca"
16559   [(set_attr "type" "multi")
16560    (set_attr "length" "5")])
16561
16562 (define_insn "allocate_stack_worker_rex64"
16563   [(unspec:DI [(match_operand:DI 0 "register_operand" "a")] 3)
16564    (set (reg:DI 7) (minus:DI (reg:DI 7) (match_dup 0)))
16565    (clobber (match_dup 0))
16566    (clobber (reg:CC 17))]
16567   "TARGET_64BIT && TARGET_STACK_PROBE"
16568   "call\t__alloca"
16569   [(set_attr "type" "multi")
16570    (set_attr "length" "5")])
16571
16572 (define_expand "allocate_stack"
16573   [(parallel [(set (match_operand:SI 0 "register_operand" "=r")
16574                    (minus:SI (reg:SI 7)
16575                              (match_operand:SI 1 "general_operand" "")))
16576               (clobber (reg:CC 17))])
16577    (parallel [(set (reg:SI 7)
16578                    (minus:SI (reg:SI 7) (match_dup 1)))
16579               (clobber (reg:CC 17))])]
16580   "TARGET_STACK_PROBE"
16581 {
16582 #ifdef CHECK_STACK_LIMIT
16583   if (GET_CODE (operands[1]) == CONST_INT
16584       && INTVAL (operands[1]) < CHECK_STACK_LIMIT)
16585     emit_insn (gen_subsi3 (stack_pointer_rtx, stack_pointer_rtx,
16586                            operands[1]));
16587   else 
16588 #endif
16589     emit_insn (gen_allocate_stack_worker (copy_to_mode_reg (SImode,
16590                                                             operands[1])));
16591
16592   emit_move_insn (operands[0], virtual_stack_dynamic_rtx);
16593   DONE;
16594 })
16595
16596 (define_expand "builtin_setjmp_receiver"
16597   [(label_ref (match_operand 0 "" ""))]
16598   "!TARGET_64BIT && flag_pic"
16599 {
16600   load_pic_register ();
16601   DONE;
16602 })
16603 \f
16604 ;; Avoid redundant prefixes by splitting HImode arithmetic to SImode.
16605
16606 (define_split
16607   [(set (match_operand 0 "register_operand" "")
16608         (match_operator 3 "promotable_binary_operator"
16609            [(match_operand 1 "register_operand" "")
16610             (match_operand 2 "aligned_operand" "")]))
16611    (clobber (reg:CC 17))]
16612   "! TARGET_PARTIAL_REG_STALL && reload_completed
16613    && ((GET_MODE (operands[0]) == HImode 
16614         && (!optimize_size || GET_CODE (operands[2]) != CONST_INT
16615             || CONST_OK_FOR_LETTER_P (INTVAL (operands[2]), 'K')))
16616        || (GET_MODE (operands[0]) == QImode 
16617            && (TARGET_PROMOTE_QImode || optimize_size)))"
16618   [(parallel [(set (match_dup 0)
16619                    (match_op_dup 3 [(match_dup 1) (match_dup 2)]))
16620               (clobber (reg:CC 17))])]
16621   "operands[0] = gen_lowpart (SImode, operands[0]);
16622    operands[1] = gen_lowpart (SImode, operands[1]);
16623    if (GET_CODE (operands[3]) != ASHIFT)
16624      operands[2] = gen_lowpart (SImode, operands[2]);
16625    PUT_MODE (operands[3], SImode);")
16626
16627 (define_split
16628   [(set (reg 17)
16629         (compare (and (match_operand 1 "aligned_operand" "")
16630                       (match_operand 2 "const_int_operand" ""))
16631                  (const_int 0)))
16632    (set (match_operand 0 "register_operand" "")
16633         (and (match_dup 1) (match_dup 2)))]
16634   "! TARGET_PARTIAL_REG_STALL && reload_completed
16635    && ix86_match_ccmode (insn, CCNOmode)
16636    && (GET_MODE (operands[0]) == HImode
16637        || (GET_MODE (operands[0]) == QImode 
16638            && (TARGET_PROMOTE_QImode || optimize_size)))"
16639   [(parallel [(set (reg:CCNO 17)
16640                    (compare:CCNO (and:SI (match_dup 1) (match_dup 2))
16641                                  (const_int 0)))
16642               (set (match_dup 0)
16643                    (and:SI (match_dup 1) (match_dup 2)))])]
16644   "operands[2]
16645      = GEN_INT (trunc_int_for_mode (INTVAL (operands[2])
16646                                     & GET_MODE_MASK (GET_MODE (operands[0])),
16647                                     SImode));
16648    operands[0] = gen_lowpart (SImode, operands[0]);
16649    operands[1] = gen_lowpart (SImode, operands[1]);")
16650
16651 (define_split
16652   [(set (reg 17)
16653         (compare (and (match_operand 0 "aligned_operand" "")
16654                       (match_operand 1 "const_int_operand" ""))
16655                  (const_int 0)))]
16656   "! TARGET_PARTIAL_REG_STALL && reload_completed
16657    && ix86_match_ccmode (insn, CCNOmode)
16658    && (GET_MODE (operands[0]) == HImode
16659        || (GET_MODE (operands[0]) == QImode 
16660            && (TARGET_PROMOTE_QImode || optimize_size)))"
16661   [(set (reg:CCNO 17)
16662         (compare:CCNO (and:SI (match_dup 0) (match_dup 1))
16663                       (const_int 0)))]
16664   "operands[1]
16665      = GEN_INT (trunc_int_for_mode (INTVAL (operands[1])
16666                                     & GET_MODE_MASK (GET_MODE (operands[0])),
16667                                     SImode));
16668    operands[0] = gen_lowpart (SImode, operands[0]);")
16669
16670 (define_split
16671   [(set (match_operand 0 "register_operand" "")
16672         (neg (match_operand 1 "register_operand" "")))
16673    (clobber (reg:CC 17))]
16674   "! TARGET_PARTIAL_REG_STALL && reload_completed
16675    && (GET_MODE (operands[0]) == HImode
16676        || (GET_MODE (operands[0]) == QImode 
16677            && (TARGET_PROMOTE_QImode || optimize_size)))"
16678   [(parallel [(set (match_dup 0)
16679                    (neg:SI (match_dup 1)))
16680               (clobber (reg:CC 17))])]
16681   "operands[0] = gen_lowpart (SImode, operands[0]);
16682    operands[1] = gen_lowpart (SImode, operands[1]);")
16683
16684 (define_split
16685   [(set (match_operand 0 "register_operand" "")
16686         (not (match_operand 1 "register_operand" "")))]
16687   "! TARGET_PARTIAL_REG_STALL && reload_completed
16688    && (GET_MODE (operands[0]) == HImode
16689        || (GET_MODE (operands[0]) == QImode 
16690            && (TARGET_PROMOTE_QImode || optimize_size)))"
16691   [(set (match_dup 0)
16692         (not:SI (match_dup 1)))]
16693   "operands[0] = gen_lowpart (SImode, operands[0]);
16694    operands[1] = gen_lowpart (SImode, operands[1]);")
16695
16696 (define_split 
16697   [(set (match_operand 0 "register_operand" "")
16698         (if_then_else (match_operator 1 "comparison_operator" 
16699                                 [(reg 17) (const_int 0)])
16700                       (match_operand 2 "register_operand" "")
16701                       (match_operand 3 "register_operand" "")))]
16702   "! TARGET_PARTIAL_REG_STALL && TARGET_CMOVE
16703    && (GET_MODE (operands[0]) == HImode
16704        || (GET_MODE (operands[0]) == QImode 
16705            && (TARGET_PROMOTE_QImode || optimize_size)))"
16706   [(set (match_dup 0)
16707         (if_then_else:SI (match_dup 1) (match_dup 2) (match_dup 3)))]
16708   "operands[0] = gen_lowpart (SImode, operands[0]);
16709    operands[2] = gen_lowpart (SImode, operands[2]);
16710    operands[3] = gen_lowpart (SImode, operands[3]);")
16711                         
16712 \f
16713 ;; RTL Peephole optimizations, run before sched2.  These primarily look to
16714 ;; transform a complex memory operation into two memory to register operations.
16715
16716 ;; Don't push memory operands
16717 (define_peephole2
16718   [(set (match_operand:SI 0 "push_operand" "")
16719         (match_operand:SI 1 "memory_operand" ""))
16720    (match_scratch:SI 2 "r")]
16721   "! optimize_size && ! TARGET_PUSH_MEMORY"
16722   [(set (match_dup 2) (match_dup 1))
16723    (set (match_dup 0) (match_dup 2))]
16724   "")
16725
16726 (define_peephole2
16727   [(set (match_operand:DI 0 "push_operand" "")
16728         (match_operand:DI 1 "memory_operand" ""))
16729    (match_scratch:DI 2 "r")]
16730   "! optimize_size && ! TARGET_PUSH_MEMORY"
16731   [(set (match_dup 2) (match_dup 1))
16732    (set (match_dup 0) (match_dup 2))]
16733   "")
16734
16735 ;; We need to handle SFmode only, because DFmode and XFmode is split to
16736 ;; SImode pushes.
16737 (define_peephole2
16738   [(set (match_operand:SF 0 "push_operand" "")
16739         (match_operand:SF 1 "memory_operand" ""))
16740    (match_scratch:SF 2 "r")]
16741   "! optimize_size && ! TARGET_PUSH_MEMORY"
16742   [(set (match_dup 2) (match_dup 1))
16743    (set (match_dup 0) (match_dup 2))]
16744   "")
16745
16746 (define_peephole2
16747   [(set (match_operand:HI 0 "push_operand" "")
16748         (match_operand:HI 1 "memory_operand" ""))
16749    (match_scratch:HI 2 "r")]
16750   "! optimize_size && ! TARGET_PUSH_MEMORY"
16751   [(set (match_dup 2) (match_dup 1))
16752    (set (match_dup 0) (match_dup 2))]
16753   "")
16754
16755 (define_peephole2
16756   [(set (match_operand:QI 0 "push_operand" "")
16757         (match_operand:QI 1 "memory_operand" ""))
16758    (match_scratch:QI 2 "q")]
16759   "! optimize_size && ! TARGET_PUSH_MEMORY"
16760   [(set (match_dup 2) (match_dup 1))
16761    (set (match_dup 0) (match_dup 2))]
16762   "")
16763
16764 ;; Don't move an immediate directly to memory when the instruction
16765 ;; gets too big.
16766 (define_peephole2
16767   [(match_scratch:SI 1 "r")
16768    (set (match_operand:SI 0 "memory_operand" "")
16769         (const_int 0))]
16770   "! optimize_size
16771    && ! TARGET_USE_MOV0
16772    && TARGET_SPLIT_LONG_MOVES
16773    && get_attr_length (insn) >= ix86_cost->large_insn
16774    && peep2_regno_dead_p (0, FLAGS_REG)"
16775   [(parallel [(set (match_dup 1) (const_int 0))
16776               (clobber (reg:CC 17))])
16777    (set (match_dup 0) (match_dup 1))]
16778   "")
16779
16780 (define_peephole2
16781   [(match_scratch:HI 1 "r")
16782    (set (match_operand:HI 0 "memory_operand" "")
16783         (const_int 0))]
16784   "! optimize_size
16785    && ! TARGET_USE_MOV0
16786    && TARGET_SPLIT_LONG_MOVES
16787    && get_attr_length (insn) >= ix86_cost->large_insn
16788    && peep2_regno_dead_p (0, FLAGS_REG)"
16789   [(parallel [(set (match_dup 2) (const_int 0))
16790               (clobber (reg:CC 17))])
16791    (set (match_dup 0) (match_dup 1))]
16792   "operands[2] = gen_rtx_REG (SImode, true_regnum (operands[1]));")
16793
16794 (define_peephole2
16795   [(match_scratch:QI 1 "q")
16796    (set (match_operand:QI 0 "memory_operand" "")
16797         (const_int 0))]
16798   "! optimize_size
16799    && ! TARGET_USE_MOV0
16800    && TARGET_SPLIT_LONG_MOVES
16801    && get_attr_length (insn) >= ix86_cost->large_insn
16802    && peep2_regno_dead_p (0, FLAGS_REG)"
16803   [(parallel [(set (match_dup 2) (const_int 0))
16804               (clobber (reg:CC 17))])
16805    (set (match_dup 0) (match_dup 1))]
16806   "operands[2] = gen_rtx_REG (SImode, true_regnum (operands[1]));")
16807
16808 (define_peephole2
16809   [(match_scratch:SI 2 "r")
16810    (set (match_operand:SI 0 "memory_operand" "")
16811         (match_operand:SI 1 "immediate_operand" ""))]
16812   "! optimize_size
16813    && get_attr_length (insn) >= ix86_cost->large_insn
16814    && TARGET_SPLIT_LONG_MOVES"
16815   [(set (match_dup 2) (match_dup 1))
16816    (set (match_dup 0) (match_dup 2))]
16817   "")
16818
16819 (define_peephole2
16820   [(match_scratch:HI 2 "r")
16821    (set (match_operand:HI 0 "memory_operand" "")
16822         (match_operand:HI 1 "immediate_operand" ""))]
16823   "! optimize_size && get_attr_length (insn) >= ix86_cost->large_insn
16824   && TARGET_SPLIT_LONG_MOVES"
16825   [(set (match_dup 2) (match_dup 1))
16826    (set (match_dup 0) (match_dup 2))]
16827   "")
16828
16829 (define_peephole2
16830   [(match_scratch:QI 2 "q")
16831    (set (match_operand:QI 0 "memory_operand" "")
16832         (match_operand:QI 1 "immediate_operand" ""))]
16833   "! optimize_size && get_attr_length (insn) >= ix86_cost->large_insn
16834   && TARGET_SPLIT_LONG_MOVES"
16835   [(set (match_dup 2) (match_dup 1))
16836    (set (match_dup 0) (match_dup 2))]
16837   "")
16838
16839 ;; Don't compare memory with zero, load and use a test instead.
16840 (define_peephole2
16841   [(set (reg 17)
16842         (compare (match_operand:SI 0 "memory_operand" "")
16843                  (const_int 0)))
16844    (match_scratch:SI 3 "r")]
16845   "ix86_match_ccmode (insn, CCNOmode) && ! optimize_size"
16846   [(set (match_dup 3) (match_dup 0))
16847    (set (reg:CCNO 17) (compare:CCNO (match_dup 3) (const_int 0)))]
16848   "")
16849
16850 ;; NOT is not pairable on Pentium, while XOR is, but one byte longer. 
16851 ;; Don't split NOTs with a displacement operand, because resulting XOR
16852 ;; will not be pariable anyway.
16853 ;;
16854 ;; On AMD K6, NOT is vector decoded with memory operand that can not be
16855 ;; represented using a modRM byte.  The XOR replacement is long decoded,
16856 ;; so this split helps here as well.
16857 ;;
16858 ;; Note: Can't do this as a regular split because we can't get proper
16859 ;; lifetime information then.
16860
16861 (define_peephole2
16862   [(set (match_operand:SI 0 "nonimmediate_operand" "")
16863         (not:SI (match_operand:SI 1 "nonimmediate_operand" "")))]
16864   "!optimize_size
16865    && peep2_regno_dead_p (0, FLAGS_REG)
16866    && ((TARGET_PENTIUM 
16867         && (GET_CODE (operands[0]) != MEM
16868             || !memory_displacement_operand (operands[0], SImode)))
16869        || (TARGET_K6 && long_memory_operand (operands[0], SImode)))"
16870   [(parallel [(set (match_dup 0)
16871                    (xor:SI (match_dup 1) (const_int -1)))
16872               (clobber (reg:CC 17))])]
16873   "")
16874
16875 (define_peephole2
16876   [(set (match_operand:HI 0 "nonimmediate_operand" "")
16877         (not:HI (match_operand:HI 1 "nonimmediate_operand" "")))]
16878   "!optimize_size
16879    && peep2_regno_dead_p (0, FLAGS_REG)
16880    && ((TARGET_PENTIUM 
16881         && (GET_CODE (operands[0]) != MEM
16882             || !memory_displacement_operand (operands[0], HImode)))
16883        || (TARGET_K6 && long_memory_operand (operands[0], HImode)))"
16884   [(parallel [(set (match_dup 0)
16885                    (xor:HI (match_dup 1) (const_int -1)))
16886               (clobber (reg:CC 17))])]
16887   "")
16888
16889 (define_peephole2
16890   [(set (match_operand:QI 0 "nonimmediate_operand" "")
16891         (not:QI (match_operand:QI 1 "nonimmediate_operand" "")))]
16892   "!optimize_size
16893    && peep2_regno_dead_p (0, FLAGS_REG)
16894    && ((TARGET_PENTIUM 
16895         && (GET_CODE (operands[0]) != MEM
16896             || !memory_displacement_operand (operands[0], QImode)))
16897        || (TARGET_K6 && long_memory_operand (operands[0], QImode)))"
16898   [(parallel [(set (match_dup 0)
16899                    (xor:QI (match_dup 1) (const_int -1)))
16900               (clobber (reg:CC 17))])]
16901   "")
16902
16903 ;; Non pairable "test imm, reg" instructions can be translated to
16904 ;; "and imm, reg" if reg dies.  The "and" form is also shorter (one
16905 ;; byte opcode instead of two, have a short form for byte operands),
16906 ;; so do it for other CPUs as well.  Given that the value was dead,
16907 ;; this should not create any new dependencies.  Pass on the sub-word
16908 ;; versions if we're concerned about partial register stalls.
16909
16910 (define_peephole2
16911   [(set (reg 17)
16912         (compare (and:SI (match_operand:SI 0 "register_operand" "")
16913                          (match_operand:SI 1 "immediate_operand" ""))
16914                  (const_int 0)))]
16915   "ix86_match_ccmode (insn, CCNOmode)
16916    && (true_regnum (operands[0]) != 0
16917        || CONST_OK_FOR_LETTER_P (INTVAL (operands[1]), 'K'))
16918    && find_regno_note (insn, REG_DEAD, true_regnum (operands[0]))"
16919   [(parallel
16920      [(set (reg:CCNO 17)
16921            (compare:CCNO (and:SI (match_dup 0)
16922                                  (match_dup 1))
16923                          (const_int 0)))
16924       (set (match_dup 0)
16925            (and:SI (match_dup 0) (match_dup 1)))])]
16926   "")
16927
16928 ;; We don't need to handle HImode case, because it will be promoted to SImode
16929 ;; on ! TARGET_PARTIAL_REG_STALL
16930
16931 (define_peephole2
16932   [(set (reg 17)
16933         (compare (and:QI (match_operand:QI 0 "register_operand" "")
16934                          (match_operand:QI 1 "immediate_operand" ""))
16935                  (const_int 0)))]
16936   "! TARGET_PARTIAL_REG_STALL
16937    && ix86_match_ccmode (insn, CCNOmode)
16938    && true_regnum (operands[0]) != 0
16939    && find_regno_note (insn, REG_DEAD, true_regnum (operands[0]))"
16940   [(parallel
16941      [(set (reg:CCNO 17)
16942            (compare:CCNO (and:QI (match_dup 0)
16943                                  (match_dup 1))
16944                          (const_int 0)))
16945       (set (match_dup 0)
16946            (and:QI (match_dup 0) (match_dup 1)))])]
16947   "")
16948
16949 (define_peephole2
16950   [(set (reg 17)
16951         (compare
16952           (and:SI
16953             (zero_extract:SI
16954               (match_operand 0 "ext_register_operand" "")
16955               (const_int 8)
16956               (const_int 8))
16957             (match_operand 1 "const_int_operand" ""))
16958           (const_int 0)))]
16959   "! TARGET_PARTIAL_REG_STALL
16960    && ix86_match_ccmode (insn, CCNOmode)
16961    && true_regnum (operands[0]) != 0
16962    && find_regno_note (insn, REG_DEAD, true_regnum (operands[0]))"
16963   [(parallel [(set (reg:CCNO 17)
16964                    (compare:CCNO
16965                        (and:SI
16966                          (zero_extract:SI
16967                          (match_dup 0)
16968                          (const_int 8)
16969                          (const_int 8))
16970                         (match_dup 1))
16971                    (const_int 0)))
16972               (set (zero_extract:SI (match_dup 0)
16973                                     (const_int 8)
16974                                     (const_int 8))
16975                    (and:SI 
16976                      (zero_extract:SI
16977                        (match_dup 0)
16978                        (const_int 8)
16979                        (const_int 8))
16980                      (match_dup 1)))])]
16981   "")
16982
16983 ;; Don't do logical operations with memory inputs.
16984 (define_peephole2
16985   [(match_scratch:SI 2 "r")
16986    (parallel [(set (match_operand:SI 0 "register_operand" "")
16987                    (match_operator:SI 3 "arith_or_logical_operator"
16988                      [(match_dup 0)
16989                       (match_operand:SI 1 "memory_operand" "")]))
16990               (clobber (reg:CC 17))])]
16991   "! optimize_size && ! TARGET_READ_MODIFY"
16992   [(set (match_dup 2) (match_dup 1))
16993    (parallel [(set (match_dup 0)
16994                    (match_op_dup 3 [(match_dup 0) (match_dup 2)]))
16995               (clobber (reg:CC 17))])]
16996   "")
16997
16998 (define_peephole2
16999   [(match_scratch:SI 2 "r")
17000    (parallel [(set (match_operand:SI 0 "register_operand" "")
17001                    (match_operator:SI 3 "arith_or_logical_operator"
17002                      [(match_operand:SI 1 "memory_operand" "")
17003                       (match_dup 0)]))
17004               (clobber (reg:CC 17))])]
17005   "! optimize_size && ! TARGET_READ_MODIFY"
17006   [(set (match_dup 2) (match_dup 1))
17007    (parallel [(set (match_dup 0)
17008                    (match_op_dup 3 [(match_dup 2) (match_dup 0)]))
17009               (clobber (reg:CC 17))])]
17010   "")
17011
17012 ; Don't do logical operations with memory outputs
17013 ;
17014 ; These two don't make sense for PPro/PII -- we're expanding a 4-uop
17015 ; instruction into two 1-uop insns plus a 2-uop insn.  That last has
17016 ; the same decoder scheduling characteristics as the original.
17017
17018 (define_peephole2
17019   [(match_scratch:SI 2 "r")
17020    (parallel [(set (match_operand:SI 0 "memory_operand" "")
17021                    (match_operator:SI 3 "arith_or_logical_operator"
17022                      [(match_dup 0)
17023                       (match_operand:SI 1 "nonmemory_operand" "")]))
17024               (clobber (reg:CC 17))])]
17025   "! optimize_size && ! TARGET_READ_MODIFY_WRITE"
17026   [(set (match_dup 2) (match_dup 0))
17027    (parallel [(set (match_dup 2)
17028                    (match_op_dup 3 [(match_dup 2) (match_dup 1)]))
17029               (clobber (reg:CC 17))])
17030    (set (match_dup 0) (match_dup 2))]
17031   "")
17032
17033 (define_peephole2
17034   [(match_scratch:SI 2 "r")
17035    (parallel [(set (match_operand:SI 0 "memory_operand" "")
17036                    (match_operator:SI 3 "arith_or_logical_operator"
17037                      [(match_operand:SI 1 "nonmemory_operand" "")
17038                       (match_dup 0)]))
17039               (clobber (reg:CC 17))])]
17040   "! optimize_size && ! TARGET_READ_MODIFY_WRITE"
17041   [(set (match_dup 2) (match_dup 0))
17042    (parallel [(set (match_dup 2)
17043                    (match_op_dup 3 [(match_dup 1) (match_dup 2)]))
17044               (clobber (reg:CC 17))])
17045    (set (match_dup 0) (match_dup 2))]
17046   "")
17047
17048 ;; Attempt to always use XOR for zeroing registers.
17049 (define_peephole2
17050   [(set (match_operand 0 "register_operand" "")
17051         (const_int 0))]
17052   "(GET_MODE (operands[0]) == QImode
17053     || GET_MODE (operands[0]) == HImode
17054     || GET_MODE (operands[0]) == SImode
17055     || (GET_MODE (operands[0]) == DImode && TARGET_64BIT))
17056    && (! TARGET_USE_MOV0 || optimize_size)
17057    && peep2_regno_dead_p (0, FLAGS_REG)"
17058   [(parallel [(set (match_dup 0) (const_int 0))
17059               (clobber (reg:CC 17))])]
17060   "operands[0] = gen_rtx_REG (GET_MODE (operands[0]) == DImode ? DImode : SImode,
17061                               true_regnum (operands[0]));")
17062
17063 (define_peephole2
17064   [(set (strict_low_part (match_operand 0 "register_operand" ""))
17065         (const_int 0))]
17066   "(GET_MODE (operands[0]) == QImode
17067     || GET_MODE (operands[0]) == HImode)
17068    && (! TARGET_USE_MOV0 || optimize_size)
17069    && peep2_regno_dead_p (0, FLAGS_REG)"
17070   [(parallel [(set (strict_low_part (match_dup 0)) (const_int 0))
17071               (clobber (reg:CC 17))])])
17072
17073 ;; For HI and SI modes, or $-1,reg is smaller than mov $-1,reg.
17074 (define_peephole2
17075   [(set (match_operand 0 "register_operand" "")
17076         (const_int -1))]
17077   "(GET_MODE (operands[0]) == HImode
17078     || GET_MODE (operands[0]) == SImode 
17079     || (GET_MODE (operands[0]) == DImode && TARGET_64BIT))
17080    && (optimize_size || TARGET_PENTIUM)
17081    && peep2_regno_dead_p (0, FLAGS_REG)"
17082   [(parallel [(set (match_dup 0) (const_int -1))
17083               (clobber (reg:CC 17))])]
17084   "operands[0] = gen_rtx_REG (GET_MODE (operands[0]) == DImode ? DImode : SImode,
17085                               true_regnum (operands[0]));")
17086
17087 ;; Attempt to convert simple leas to adds. These can be created by
17088 ;; move expanders.
17089 (define_peephole2
17090   [(set (match_operand:SI 0 "register_operand" "")
17091         (plus:SI (match_dup 0)
17092                  (match_operand:SI 1 "nonmemory_operand" "")))]
17093   "peep2_regno_dead_p (0, FLAGS_REG)"
17094   [(parallel [(set (match_dup 0) (plus:SI (match_dup 0) (match_dup 1)))
17095               (clobber (reg:CC 17))])]
17096   "")
17097
17098 (define_peephole2
17099   [(set (match_operand:SI 0 "register_operand" "")
17100         (subreg:SI (plus:DI (match_operand:DI 1 "register_operand" "")
17101                             (match_operand:DI 2 "nonmemory_operand" "")) 0))]
17102   "peep2_regno_dead_p (0, FLAGS_REG) && REGNO (operands[0]) == REGNO (operands[1])"
17103   [(parallel [(set (match_dup 0) (plus:SI (match_dup 0) (match_dup 2)))
17104               (clobber (reg:CC 17))])]
17105   "operands[2] = gen_lowpart (SImode, operands[2]);")
17106
17107 (define_peephole2
17108   [(set (match_operand:DI 0 "register_operand" "")
17109         (plus:DI (match_dup 0)
17110                  (match_operand:DI 1 "x86_64_general_operand" "")))]
17111   "peep2_regno_dead_p (0, FLAGS_REG)"
17112   [(parallel [(set (match_dup 0) (plus:DI (match_dup 0) (match_dup 1)))
17113               (clobber (reg:CC 17))])]
17114   "")
17115
17116 (define_peephole2
17117   [(set (match_operand:SI 0 "register_operand" "")
17118         (mult:SI (match_dup 0)
17119                  (match_operand:SI 1 "const_int_operand" "")))]
17120   "exact_log2 (INTVAL (operands[1])) >= 0
17121    && peep2_regno_dead_p (0, FLAGS_REG)"
17122   [(parallel [(set (match_dup 0) (ashift:SI (match_dup 0) (match_dup 2)))
17123               (clobber (reg:CC 17))])]
17124   "operands[2] = GEN_INT (exact_log2 (INTVAL (operands[1])));")
17125
17126 (define_peephole2
17127   [(set (match_operand:DI 0 "register_operand" "")
17128         (mult:DI (match_dup 0)
17129                  (match_operand:DI 1 "const_int_operand" "")))]
17130   "exact_log2 (INTVAL (operands[1])) >= 0
17131    && peep2_regno_dead_p (0, FLAGS_REG)"
17132   [(parallel [(set (match_dup 0) (ashift:DI (match_dup 0) (match_dup 2)))
17133               (clobber (reg:CC 17))])]
17134   "operands[2] = GEN_INT (exact_log2 (INTVAL (operands[1])));")
17135
17136 (define_peephole2
17137   [(set (match_operand:SI 0 "register_operand" "")
17138         (subreg:SI (mult:DI (match_operand:DI 1 "register_operand" "")
17139                    (match_operand:DI 2 "const_int_operand" "")) 0))]
17140   "exact_log2 (INTVAL (operands[1])) >= 0
17141    && REGNO (operands[0]) == REGNO (operands[1])
17142    && peep2_regno_dead_p (0, FLAGS_REG)"
17143   [(parallel [(set (match_dup 0) (ashift:SI (match_dup 0) (match_dup 2)))
17144               (clobber (reg:CC 17))])]
17145   "operands[2] = GEN_INT (exact_log2 (INTVAL (operands[2])));")
17146
17147 ;; The ESP adjustments can be done by the push and pop instructions.  Resulting
17148 ;; code is shorter, since push is only 1 byte, while add imm, %esp 3 bytes.  On
17149 ;; many CPUs it is also faster, since special hardware to avoid esp
17150 ;; dependencies is present.
17151
17152 ;; While some of these converisons may be done using splitters, we use peepholes
17153 ;; in order to allow combine_stack_adjustments pass to see nonobfuscated RTL.
17154
17155 ;; Convert prologue esp subtractions to push.
17156 ;; We need register to push.  In order to keep verify_flow_info happy we have
17157 ;; two choices
17158 ;; - use scratch and clobber it in order to avoid dependencies
17159 ;; - use already live register
17160 ;; We can't use the second way right now, since there is no reliable way how to
17161 ;; verify that given register is live.  First choice will also most likely in
17162 ;; fewer dependencies.  On the place of esp adjustments it is very likely that
17163 ;; call clobbered registers are dead.  We may want to use base pointer as an
17164 ;; alternative when no register is available later.
17165
17166 (define_peephole2
17167   [(match_scratch:SI 0 "r")
17168    (parallel [(set (reg:SI 7) (plus:SI (reg:SI 7) (const_int -4)))
17169               (clobber (reg:CC 17))
17170               (clobber (mem:BLK (scratch)))])]
17171   "optimize_size || !TARGET_SUB_ESP_4"
17172   [(clobber (match_dup 0))
17173    (parallel [(set (mem:SI (pre_dec:SI (reg:SI 7))) (match_dup 0))
17174               (clobber (mem:BLK (scratch)))])])
17175
17176 (define_peephole2
17177   [(match_scratch:SI 0 "r")
17178    (parallel [(set (reg:SI 7) (plus:SI (reg:SI 7) (const_int -8)))
17179               (clobber (reg:CC 17))
17180               (clobber (mem:BLK (scratch)))])]
17181   "optimize_size || !TARGET_SUB_ESP_8"
17182   [(clobber (match_dup 0))
17183    (set (mem:SI (pre_dec:SI (reg:SI 7))) (match_dup 0))
17184    (parallel [(set (mem:SI (pre_dec:SI (reg:SI 7))) (match_dup 0))
17185               (clobber (mem:BLK (scratch)))])])
17186
17187 ;; Convert esp subtractions to push.
17188 (define_peephole2
17189   [(match_scratch:SI 0 "r")
17190    (parallel [(set (reg:SI 7) (plus:SI (reg:SI 7) (const_int -4)))
17191               (clobber (reg:CC 17))])]
17192   "optimize_size || !TARGET_SUB_ESP_4"
17193   [(clobber (match_dup 0))
17194    (set (mem:SI (pre_dec:SI (reg:SI 7))) (match_dup 0))])
17195
17196 (define_peephole2
17197   [(match_scratch:SI 0 "r")
17198    (parallel [(set (reg:SI 7) (plus:SI (reg:SI 7) (const_int -8)))
17199               (clobber (reg:CC 17))])]
17200   "optimize_size || !TARGET_SUB_ESP_8"
17201   [(clobber (match_dup 0))
17202    (set (mem:SI (pre_dec:SI (reg:SI 7))) (match_dup 0))
17203    (set (mem:SI (pre_dec:SI (reg:SI 7))) (match_dup 0))])
17204
17205 ;; Convert epilogue deallocator to pop.
17206 (define_peephole2
17207   [(match_scratch:SI 0 "r")
17208    (parallel [(set (reg:SI 7) (plus:SI (reg:SI 7) (const_int 4)))
17209               (clobber (reg:CC 17))
17210               (clobber (mem:BLK (scratch)))])]
17211   "optimize_size || !TARGET_ADD_ESP_4"
17212   [(parallel [(set (match_dup 0) (mem:SI (reg:SI 7)))
17213               (set (reg:SI 7) (plus:SI (reg:SI 7) (const_int 4)))
17214               (clobber (mem:BLK (scratch)))])]
17215   "")
17216
17217 ;; Two pops case is tricky, since pop causes dependency on destination register.
17218 ;; We use two registers if available.
17219 (define_peephole2
17220   [(match_scratch:SI 0 "r")
17221    (match_scratch:SI 1 "r")
17222    (parallel [(set (reg:SI 7) (plus:SI (reg:SI 7) (const_int 8)))
17223               (clobber (reg:CC 17))
17224               (clobber (mem:BLK (scratch)))])]
17225   "optimize_size || !TARGET_ADD_ESP_8"
17226   [(parallel [(set (match_dup 0) (mem:SI (reg:SI 7)))
17227               (set (reg:SI 7) (plus:SI (reg:SI 7) (const_int 4)))
17228               (clobber (mem:BLK (scratch)))])
17229    (parallel [(set (match_dup 1) (mem:SI (reg:SI 7)))
17230               (set (reg:SI 7) (plus:SI (reg:SI 7) (const_int 4)))])]
17231   "")
17232
17233 (define_peephole2
17234   [(match_scratch:SI 0 "r")
17235    (parallel [(set (reg:SI 7) (plus:SI (reg:SI 7) (const_int 8)))
17236               (clobber (reg:CC 17))
17237               (clobber (mem:BLK (scratch)))])]
17238   "optimize_size"
17239   [(parallel [(set (match_dup 0) (mem:SI (reg:SI 7)))
17240               (set (reg:SI 7) (plus:SI (reg:SI 7) (const_int 4)))
17241               (clobber (mem:BLK (scratch)))])
17242    (parallel [(set (match_dup 0) (mem:SI (reg:SI 7)))
17243               (set (reg:SI 7) (plus:SI (reg:SI 7) (const_int 4)))])]
17244   "")
17245
17246 ;; Convert esp additions to pop.
17247 (define_peephole2
17248   [(match_scratch:SI 0 "r")
17249    (parallel [(set (reg:SI 7) (plus:SI (reg:SI 7) (const_int 4)))
17250               (clobber (reg:CC 17))])]
17251   ""
17252   [(parallel [(set (match_dup 0) (mem:SI (reg:SI 7)))
17253               (set (reg:SI 7) (plus:SI (reg:SI 7) (const_int 4)))])]
17254   "")
17255
17256 ;; Two pops case is tricky, since pop causes dependency on destination register.
17257 ;; We use two registers if available.
17258 (define_peephole2
17259   [(match_scratch:SI 0 "r")
17260    (match_scratch:SI 1 "r")
17261    (parallel [(set (reg:SI 7) (plus:SI (reg:SI 7) (const_int 8)))
17262               (clobber (reg:CC 17))])]
17263   ""
17264   [(parallel [(set (match_dup 0) (mem:SI (reg:SI 7)))
17265               (set (reg:SI 7) (plus:SI (reg:SI 7) (const_int 4)))])
17266    (parallel [(set (match_dup 1) (mem:SI (reg:SI 7)))
17267               (set (reg:SI 7) (plus:SI (reg:SI 7) (const_int 4)))])]
17268   "")
17269
17270 (define_peephole2
17271   [(match_scratch:SI 0 "r")
17272    (parallel [(set (reg:SI 7) (plus:SI (reg:SI 7) (const_int 8)))
17273               (clobber (reg:CC 17))])]
17274   "optimize_size"
17275   [(parallel [(set (match_dup 0) (mem:SI (reg:SI 7)))
17276               (set (reg:SI 7) (plus:SI (reg:SI 7) (const_int 4)))])
17277    (parallel [(set (match_dup 0) (mem:SI (reg:SI 7)))
17278               (set (reg:SI 7) (plus:SI (reg:SI 7) (const_int 4)))])]
17279   "")
17280 \f
17281 ;; Convert compares with 1 to shorter inc/dec operations when CF is not
17282 ;; required and register dies.
17283 (define_peephole2
17284   [(set (reg 17)
17285         (compare (match_operand:SI 0 "register_operand" "")
17286                  (match_operand:SI 1 "incdec_operand" "")))]
17287   "ix86_match_ccmode (insn, CCGCmode)
17288    && find_regno_note (insn, REG_DEAD, true_regnum (operands[0]))"
17289   [(parallel [(set (reg:CCGC 17)
17290                    (compare:CCGC (match_dup 0)
17291                                  (match_dup 1)))
17292               (clobber (match_dup 0))])]
17293   "")
17294
17295 (define_peephole2
17296   [(set (reg 17)
17297         (compare (match_operand:HI 0 "register_operand" "")
17298                  (match_operand:HI 1 "incdec_operand" "")))]
17299   "ix86_match_ccmode (insn, CCGCmode)
17300    && find_regno_note (insn, REG_DEAD, true_regnum (operands[0]))"
17301   [(parallel [(set (reg:CCGC 17)
17302                    (compare:CCGC (match_dup 0)
17303                                  (match_dup 1)))
17304               (clobber (match_dup 0))])]
17305   "")
17306
17307 (define_peephole2
17308   [(set (reg 17)
17309         (compare (match_operand:QI 0 "register_operand" "")
17310                  (match_operand:QI 1 "incdec_operand" "")))]
17311   "ix86_match_ccmode (insn, CCGCmode)
17312    && find_regno_note (insn, REG_DEAD, true_regnum (operands[0]))"
17313   [(parallel [(set (reg:CCGC 17)
17314                    (compare:CCGC (match_dup 0)
17315                                  (match_dup 1)))
17316               (clobber (match_dup 0))])]
17317   "")
17318
17319 ;; Convert compares with 128 to shorter add -128
17320 (define_peephole2
17321   [(set (reg 17)
17322         (compare (match_operand:SI 0 "register_operand" "")
17323                  (const_int 128)))]
17324   "ix86_match_ccmode (insn, CCGCmode)
17325    && find_regno_note (insn, REG_DEAD, true_regnum (operands[0]))"
17326   [(parallel [(set (reg:CCGC 17)
17327                    (compare:CCGC (match_dup 0)
17328                                  (const_int 128)))
17329               (clobber (match_dup 0))])]
17330   "")
17331
17332 (define_peephole2
17333   [(set (reg 17)
17334         (compare (match_operand:HI 0 "register_operand" "")
17335                  (const_int 128)))]
17336   "ix86_match_ccmode (insn, CCGCmode)
17337    && find_regno_note (insn, REG_DEAD, true_regnum (operands[0]))"
17338   [(parallel [(set (reg:CCGC 17)
17339                    (compare:CCGC (match_dup 0)
17340                                  (const_int 128)))
17341               (clobber (match_dup 0))])]
17342   "")
17343 \f
17344 (define_peephole2
17345   [(match_scratch:DI 0 "r")
17346    (parallel [(set (reg:DI 7) (plus:DI (reg:DI 7) (const_int -8)))
17347               (clobber (reg:CC 17))
17348               (clobber (mem:BLK (scratch)))])]
17349   "optimize_size || !TARGET_SUB_ESP_4"
17350   [(clobber (match_dup 0))
17351    (parallel [(set (mem:DI (pre_dec:DI (reg:DI 7))) (match_dup 0))
17352               (clobber (mem:BLK (scratch)))])])
17353
17354 (define_peephole2
17355   [(match_scratch:DI 0 "r")
17356    (parallel [(set (reg:DI 7) (plus:DI (reg:DI 7) (const_int -16)))
17357               (clobber (reg:CC 17))
17358               (clobber (mem:BLK (scratch)))])]
17359   "optimize_size || !TARGET_SUB_ESP_8"
17360   [(clobber (match_dup 0))
17361    (set (mem:DI (pre_dec:DI (reg:DI 7))) (match_dup 0))
17362    (parallel [(set (mem:DI (pre_dec:DI (reg:DI 7))) (match_dup 0))
17363               (clobber (mem:BLK (scratch)))])])
17364
17365 ;; Convert esp subtractions to push.
17366 (define_peephole2
17367   [(match_scratch:DI 0 "r")
17368    (parallel [(set (reg:DI 7) (plus:DI (reg:DI 7) (const_int -8)))
17369               (clobber (reg:CC 17))])]
17370   "optimize_size || !TARGET_SUB_ESP_4"
17371   [(clobber (match_dup 0))
17372    (set (mem:DI (pre_dec:DI (reg:DI 7))) (match_dup 0))])
17373
17374 (define_peephole2
17375   [(match_scratch:DI 0 "r")
17376    (parallel [(set (reg:DI 7) (plus:DI (reg:DI 7) (const_int -16)))
17377               (clobber (reg:CC 17))])]
17378   "optimize_size || !TARGET_SUB_ESP_8"
17379   [(clobber (match_dup 0))
17380    (set (mem:DI (pre_dec:DI (reg:DI 7))) (match_dup 0))
17381    (set (mem:DI (pre_dec:DI (reg:DI 7))) (match_dup 0))])
17382
17383 ;; Convert epilogue deallocator to pop.
17384 (define_peephole2
17385   [(match_scratch:DI 0 "r")
17386    (parallel [(set (reg:DI 7) (plus:DI (reg:DI 7) (const_int 8)))
17387               (clobber (reg:CC 17))
17388               (clobber (mem:BLK (scratch)))])]
17389   "optimize_size || !TARGET_ADD_ESP_4"
17390   [(parallel [(set (match_dup 0) (mem:DI (reg:DI 7)))
17391               (set (reg:DI 7) (plus:DI (reg:DI 7) (const_int 8)))
17392               (clobber (mem:BLK (scratch)))])]
17393   "")
17394
17395 ;; Two pops case is tricky, since pop causes dependency on destination register.
17396 ;; We use two registers if available.
17397 (define_peephole2
17398   [(match_scratch:DI 0 "r")
17399    (match_scratch:DI 1 "r")
17400    (parallel [(set (reg:DI 7) (plus:DI (reg:DI 7) (const_int 16)))
17401               (clobber (reg:CC 17))
17402               (clobber (mem:BLK (scratch)))])]
17403   "optimize_size || !TARGET_ADD_ESP_8"
17404   [(parallel [(set (match_dup 0) (mem:DI (reg:DI 7)))
17405               (set (reg:DI 7) (plus:DI (reg:DI 7) (const_int 8)))
17406               (clobber (mem:BLK (scratch)))])
17407    (parallel [(set (match_dup 1) (mem:DI (reg:DI 7)))
17408               (set (reg:DI 7) (plus:DI (reg:DI 7) (const_int 8)))])]
17409   "")
17410
17411 (define_peephole2
17412   [(match_scratch:DI 0 "r")
17413    (parallel [(set (reg:DI 7) (plus:DI (reg:DI 7) (const_int 16)))
17414               (clobber (reg:CC 17))
17415               (clobber (mem:BLK (scratch)))])]
17416   "optimize_size"
17417   [(parallel [(set (match_dup 0) (mem:DI (reg:DI 7)))
17418               (set (reg:DI 7) (plus:DI (reg:DI 7) (const_int 8)))
17419               (clobber (mem:BLK (scratch)))])
17420    (parallel [(set (match_dup 0) (mem:DI (reg:DI 7)))
17421               (set (reg:DI 7) (plus:DI (reg:DI 7) (const_int 8)))])]
17422   "")
17423
17424 ;; Convert esp additions to pop.
17425 (define_peephole2
17426   [(match_scratch:DI 0 "r")
17427    (parallel [(set (reg:DI 7) (plus:DI (reg:DI 7) (const_int 8)))
17428               (clobber (reg:CC 17))])]
17429   ""
17430   [(parallel [(set (match_dup 0) (mem:DI (reg:DI 7)))
17431               (set (reg:DI 7) (plus:DI (reg:DI 7) (const_int 8)))])]
17432   "")
17433
17434 ;; Two pops case is tricky, since pop causes dependency on destination register.
17435 ;; We use two registers if available.
17436 (define_peephole2
17437   [(match_scratch:DI 0 "r")
17438    (match_scratch:DI 1 "r")
17439    (parallel [(set (reg:DI 7) (plus:DI (reg:DI 7) (const_int 16)))
17440               (clobber (reg:CC 17))])]
17441   ""
17442   [(parallel [(set (match_dup 0) (mem:DI (reg:DI 7)))
17443               (set (reg:DI 7) (plus:DI (reg:DI 7) (const_int 8)))])
17444    (parallel [(set (match_dup 1) (mem:DI (reg:DI 7)))
17445               (set (reg:DI 7) (plus:DI (reg:DI 7) (const_int 8)))])]
17446   "")
17447
17448 (define_peephole2
17449   [(match_scratch:DI 0 "r")
17450    (parallel [(set (reg:DI 7) (plus:DI (reg:DI 7) (const_int 16)))
17451               (clobber (reg:CC 17))])]
17452   "optimize_size"
17453   [(parallel [(set (match_dup 0) (mem:DI (reg:DI 7)))
17454               (set (reg:DI 7) (plus:DI (reg:DI 7) (const_int 8)))])
17455    (parallel [(set (match_dup 0) (mem:DI (reg:DI 7)))
17456               (set (reg:DI 7) (plus:DI (reg:DI 7) (const_int 8)))])]
17457   "")
17458 \f
17459 ;; Call-value patterns last so that the wildcard operand does not
17460 ;; disrupt insn-recog's switch tables.
17461
17462 (define_insn "*call_value_pop_0"
17463   [(set (match_operand 0 "" "")
17464         (call (mem:QI (match_operand:SI 1 "constant_call_address_operand" ""))
17465               (match_operand:SI 2 "" "")))
17466    (set (reg:SI 7) (plus:SI (reg:SI 7)
17467                             (match_operand:SI 3 "immediate_operand" "")))]
17468   "!TARGET_64BIT"
17469 {
17470   if (SIBLING_CALL_P (insn))
17471     return "jmp\t%P1";
17472   else
17473     return "call\t%P1";
17474 }
17475   [(set_attr "type" "callv")])
17476
17477 (define_insn "*call_value_pop_1"
17478   [(set (match_operand 0 "" "")
17479         (call (mem:QI (match_operand:SI 1 "call_insn_operand" "rsm"))
17480               (match_operand:SI 2 "" "")))
17481    (set (reg:SI 7) (plus:SI (reg:SI 7)
17482                             (match_operand:SI 3 "immediate_operand" "i")))]
17483   "!TARGET_64BIT"
17484 {
17485   if (constant_call_address_operand (operands[1], QImode))
17486     {
17487       if (SIBLING_CALL_P (insn))
17488         return "jmp\t%P1";
17489       else
17490         return "call\t%P1";
17491     }
17492   if (SIBLING_CALL_P (insn))
17493     return "jmp\t%A1";
17494   else
17495     return "call\t%A1";
17496 }
17497   [(set_attr "type" "callv")])
17498
17499 (define_insn "*call_value_0"
17500   [(set (match_operand 0 "" "")
17501         (call (mem:QI (match_operand:SI 1 "constant_call_address_operand" ""))
17502               (match_operand:SI 2 "" "")))]
17503   "!TARGET_64BIT"
17504 {
17505   if (SIBLING_CALL_P (insn))
17506     return "jmp\t%P1";
17507   else
17508     return "call\t%P1";
17509 }
17510   [(set_attr "type" "callv")])
17511
17512 (define_insn "*call_value_0_rex64"
17513   [(set (match_operand 0 "" "")
17514         (call (mem:QI (match_operand:DI 1 "constant_call_address_operand" ""))
17515               (match_operand:DI 2 "const_int_operand" "")))]
17516   "TARGET_64BIT"
17517 {
17518   if (SIBLING_CALL_P (insn))
17519     return "jmp\t%P1";
17520   else
17521     return "call\t%P1";
17522 }
17523   [(set_attr "type" "callv")])
17524
17525 (define_insn "*call_value_1"
17526   [(set (match_operand 0 "" "")
17527         (call (mem:QI (match_operand:SI 1 "call_insn_operand" "rsm"))
17528               (match_operand:SI 2 "" "")))]
17529   "!TARGET_64BIT"
17530 {
17531   if (constant_call_address_operand (operands[1], QImode))
17532     {
17533       if (SIBLING_CALL_P (insn))
17534         return "jmp\t%P1";
17535       else
17536         return "call\t%P1";
17537     }
17538   if (SIBLING_CALL_P (insn))
17539     return "jmp\t%*%1";
17540   else
17541     return "call\t%*%1";
17542 }
17543   [(set_attr "type" "callv")])
17544
17545 (define_insn "*call_value_1_rex64"
17546   [(set (match_operand 0 "" "")
17547         (call (mem:QI (match_operand:DI 1 "call_insn_operand" "rsm"))
17548               (match_operand:DI 2 "" "")))]
17549   "TARGET_64BIT"
17550 {
17551   if (constant_call_address_operand (operands[1], QImode))
17552     {
17553       if (SIBLING_CALL_P (insn))
17554         return "jmp\t%P1";
17555       else
17556         return "call\t%P1";
17557     }
17558   if (SIBLING_CALL_P (insn))
17559     return "jmp\t%A1";
17560   else
17561     return "call\t%A1";
17562 }
17563   [(set_attr "type" "callv")])
17564 \f
17565 (define_insn "trap"
17566   [(trap_if (const_int 1) (const_int 5))]
17567   ""
17568   "int\t$5")
17569
17570 ;;; ix86 doesn't have conditional trap instructions, but we fake them
17571 ;;; for the sake of bounds checking.  By emitting bounds checks as
17572 ;;; conditional traps rather than as conditional jumps around
17573 ;;; unconditional traps we avoid introducing spurious basic-block
17574 ;;; boundaries and facilitate elimination of redundant checks.  In
17575 ;;; honor of the too-inflexible-for-BPs `bound' instruction, we use
17576 ;;; interrupt 5.
17577 ;;; 
17578 ;;; FIXME: Static branch prediction rules for ix86 are such that
17579 ;;; forward conditional branches predict as untaken.  As implemented
17580 ;;; below, pseudo conditional traps violate that rule.  We should use
17581 ;;; .pushsection/.popsection to place all of the `int 5's in a special
17582 ;;; section loaded at the end of the text segment and branch forward
17583 ;;; there on bounds-failure, and then jump back immediately (in case
17584 ;;; the system chooses to ignore bounds violations, or to report
17585 ;;; violations and continue execution).
17586
17587 (define_expand "conditional_trap"
17588   [(trap_if (match_operator 0 "comparison_operator"
17589              [(match_dup 2) (const_int 0)])
17590             (match_operand 1 "const_int_operand" ""))]
17591   ""
17592 {
17593   emit_insn (gen_rtx_TRAP_IF (VOIDmode,
17594                               ix86_expand_compare (GET_CODE (operands[0]),
17595                                                    NULL, NULL),
17596                               operands[1]));
17597   DONE;
17598 })
17599
17600 (define_insn "*conditional_trap_1"
17601   [(trap_if (match_operator 0 "comparison_operator"
17602              [(reg 17) (const_int 0)])
17603             (match_operand 1 "const_int_operand" ""))]
17604   ""
17605 {
17606   operands[2] = gen_label_rtx ();
17607   output_asm_insn ("j%c0\t%l2\; int\t%1", operands);
17608   ASM_OUTPUT_INTERNAL_LABEL (asm_out_file, "L",
17609                              CODE_LABEL_NUMBER (operands[2]));
17610   RET;
17611 })
17612
17613         ;; Pentium III SIMD instructions.
17614
17615 ;; Moves for SSE/MMX regs.
17616
17617 (define_insn "movv4sf_internal"
17618   [(set (match_operand:V4SF 0 "nonimmediate_operand" "=x,m")
17619         (match_operand:V4SF 1 "general_operand" "xm,x"))]
17620   "TARGET_SSE"
17621   ;; @@@ let's try to use movaps here.
17622   "movaps\t{%1, %0|%0, %1}"
17623   [(set_attr "type" "sse")])
17624
17625 (define_insn "movv4si_internal"
17626   [(set (match_operand:V4SI 0 "nonimmediate_operand" "=x,m")
17627         (match_operand:V4SI 1 "general_operand" "xm,x"))]
17628   "TARGET_SSE"
17629   ;; @@@ let's try to use movaps here.
17630   "movaps\t{%1, %0|%0, %1}"
17631   [(set_attr "type" "sse")])
17632
17633 (define_insn "movv8qi_internal"
17634   [(set (match_operand:V8QI 0 "nonimmediate_operand" "=y,m")
17635         (match_operand:V8QI 1 "general_operand" "ym,y"))]
17636   "TARGET_MMX"
17637   "movq\t{%1, %0|%0, %1}"
17638   [(set_attr "type" "mmx")])
17639
17640 (define_insn "movv4hi_internal"
17641   [(set (match_operand:V4HI 0 "nonimmediate_operand" "=y,m")
17642         (match_operand:V4HI 1 "general_operand" "ym,y"))]
17643   "TARGET_MMX"
17644   "movq\t{%1, %0|%0, %1}"
17645   [(set_attr "type" "mmx")])
17646
17647 (define_insn "movv2si_internal"
17648   [(set (match_operand:V2SI 0 "nonimmediate_operand" "=y,m")
17649         (match_operand:V2SI 1 "general_operand" "ym,y"))]
17650   "TARGET_MMX"
17651   "movq\t{%1, %0|%0, %1}"
17652   [(set_attr "type" "mmx")])
17653
17654 (define_insn "movv2sf_internal"
17655   [(set (match_operand:V2SF 0 "nonimmediate_operand" "=y,m")
17656         (match_operand:V2SF 1 "general_operand" "ym,y"))]
17657   "TARGET_3DNOW"
17658   "movq\\t{%1, %0|%0, %1}"
17659   [(set_attr "type" "mmx")])
17660
17661 (define_expand "movti"
17662   [(set (match_operand:TI 0 "general_operand" "")
17663         (match_operand:TI 1 "general_operand" ""))]
17664   "TARGET_SSE || TARGET_64BIT"
17665 {
17666   if (TARGET_64BIT)
17667     {
17668       ix86_expand_move (TImode, operands);
17669       DONE;
17670     }
17671   /* For constants other than zero into memory.  We do not know how the
17672      instructions used to build constants modify the upper 64 bits
17673      of the register, once we have that information we may be able
17674      to handle some of them more efficiently.  */
17675   if ((reload_in_progress | reload_completed) == 0
17676       && register_operand (operands[0], TImode)
17677       && CONSTANT_P (operands[1]))
17678     {
17679       rtx addr = gen_reg_rtx (Pmode);
17680
17681       emit_move_insn (addr, XEXP (force_const_mem (TImode, operands[1]), 0));
17682       operands[1] = gen_rtx_MEM (TImode, addr);
17683     }
17684
17685   /* Make operand1 a register if it isn't already.  */
17686   if ((reload_in_progress | reload_completed) == 0
17687       && !register_operand (operands[0], TImode)
17688       && !register_operand (operands[1], TImode)
17689       && operands[1] != CONST0_RTX (TImode))
17690     {
17691       rtx temp = force_reg (TImode, operands[1]);
17692       emit_move_insn (operands[0], temp);
17693       DONE;
17694     }
17695 })
17696
17697 (define_expand "movv4sf"
17698   [(set (match_operand:V4SF 0 "general_operand" "")
17699         (match_operand:V4SF 1 "general_operand" ""))]
17700   "TARGET_SSE"
17701 {
17702   /* For constants other than zero into memory.  We do not know how the
17703      instructions used to build constants modify the upper 64 bits
17704      of the register, once we have that information we may be able
17705      to handle some of them more efficiently.  */
17706   if ((reload_in_progress | reload_completed) == 0
17707       && register_operand (operands[0], V4SFmode)
17708       && CONSTANT_P (operands[1]))
17709     {
17710       rtx addr = gen_reg_rtx (Pmode);
17711
17712       emit_move_insn (addr, XEXP (force_const_mem (V4SFmode, operands[1]), 0));
17713       operands[1] = gen_rtx_MEM (V4SFmode, addr);
17714     }
17715
17716   /* Make operand1 a register if it isn't already.  */
17717   if ((reload_in_progress | reload_completed) == 0
17718       && !register_operand (operands[0], V4SFmode)
17719       && !register_operand (operands[1], V4SFmode)
17720       && operands[1] != CONST0_RTX (V4SFmode))
17721     {
17722       rtx temp = force_reg (V4SFmode, operands[1]);
17723       emit_move_insn (operands[0], temp);
17724       DONE;
17725     }
17726 })
17727
17728 (define_expand "movv4si"
17729   [(set (match_operand:V4SI 0 "general_operand" "")
17730         (match_operand:V4SI 1 "general_operand" ""))]
17731   "TARGET_MMX"
17732 {
17733   /* For constants other than zero into memory.  We do not know how the
17734      instructions used to build constants modify the upper 64 bits
17735      of the register, once we have that information we may be able
17736      to handle some of them more efficiently.  */
17737   if ((reload_in_progress | reload_completed) == 0
17738       && register_operand (operands[0], V4SImode)
17739       && CONSTANT_P (operands[1]))
17740     {
17741       rtx addr = gen_reg_rtx (Pmode);
17742
17743       emit_move_insn (addr, XEXP (force_const_mem (V4SImode, operands[1]), 0));
17744       operands[1] = gen_rtx_MEM (V4SImode, addr);
17745     }
17746
17747   /* Make operand1 a register if it isn't already.  */
17748   if ((reload_in_progress | reload_completed) == 0
17749       && !register_operand (operands[0], V4SImode)
17750       && !register_operand (operands[1], V4SImode)
17751       && operands[1] != CONST0_RTX (V4SImode))
17752     {
17753       rtx temp = force_reg (V4SImode, operands[1]);
17754       emit_move_insn (operands[0], temp);
17755       DONE;
17756     }
17757 })
17758
17759 (define_expand "movv2si"
17760   [(set (match_operand:V2SI 0 "general_operand" "")
17761         (match_operand:V2SI 1 "general_operand" ""))]
17762   "TARGET_MMX"
17763 {
17764   /* For constants other than zero into memory.  We do not know how the
17765      instructions used to build constants modify the upper 64 bits
17766      of the register, once we have that information we may be able
17767      to handle some of them more efficiently.  */
17768   if ((reload_in_progress | reload_completed) == 0
17769       && register_operand (operands[0], V2SImode)
17770       && CONSTANT_P (operands[1]))
17771     {
17772       rtx addr = gen_reg_rtx (Pmode);
17773
17774       emit_move_insn (addr, XEXP (force_const_mem (V2SImode, operands[1]), 0));
17775       operands[1] = gen_rtx_MEM (V2SImode, addr);
17776     }
17777
17778   /* Make operand1 a register if it isn't already.  */
17779   if ((reload_in_progress | reload_completed) == 0
17780       && !register_operand (operands[0], V2SImode)
17781       && !register_operand (operands[1], V2SImode)
17782       && operands[1] != CONST0_RTX (V2SImode))
17783     {
17784       rtx temp = force_reg (V2SImode, operands[1]);
17785       emit_move_insn (operands[0], temp);
17786       DONE;
17787     }
17788 })
17789
17790 (define_expand "movv4hi"
17791   [(set (match_operand:V4HI 0 "general_operand" "")
17792         (match_operand:V4HI 1 "general_operand" ""))]
17793   "TARGET_MMX"
17794 {
17795   /* For constants other than zero into memory.  We do not know how the
17796      instructions used to build constants modify the upper 64 bits
17797      of the register, once we have that information we may be able
17798      to handle some of them more efficiently.  */
17799   if ((reload_in_progress | reload_completed) == 0
17800       && register_operand (operands[0], V4HImode)
17801       && CONSTANT_P (operands[1]))
17802     {
17803       rtx addr = gen_reg_rtx (Pmode);
17804
17805       emit_move_insn (addr, XEXP (force_const_mem (V4HImode, operands[1]), 0));
17806       operands[1] = gen_rtx_MEM (V4HImode, addr);
17807     }
17808
17809   /* Make operand1 a register if it isn't already.  */
17810   if ((reload_in_progress | reload_completed) == 0
17811       && !register_operand (operands[0], V4HImode)
17812       && !register_operand (operands[1], V4HImode)
17813       && operands[1] != CONST0_RTX (V4HImode))
17814     {
17815       rtx temp = force_reg (V4HImode, operands[1]);
17816       emit_move_insn (operands[0], temp);
17817       DONE;
17818     }
17819 })
17820
17821 (define_expand "movv8qi"
17822   [(set (match_operand:V8QI 0 "general_operand" "")
17823         (match_operand:V8QI 1 "general_operand" ""))]
17824   "TARGET_MMX"
17825 {
17826   /* For constants other than zero into memory.  We do not know how the
17827      instructions used to build constants modify the upper 64 bits
17828      of the register, once we have that information we may be able
17829      to handle some of them more efficiently.  */
17830   if ((reload_in_progress | reload_completed) == 0
17831       && register_operand (operands[0], V8QImode)
17832       && CONSTANT_P (operands[1]))
17833     {
17834       rtx addr = gen_reg_rtx (Pmode);
17835
17836       emit_move_insn (addr, XEXP (force_const_mem (V8QImode, operands[1]), 0));
17837       operands[1] = gen_rtx_MEM (V8QImode, addr);
17838     }
17839
17840   /* Make operand1 a register if it isn't already.  */
17841   if ((reload_in_progress | reload_completed) == 0
17842       && !register_operand (operands[0], V8QImode)
17843       && !register_operand (operands[1], V8QImode)
17844       && operands[1] != CONST0_RTX (V8QImode))
17845     {
17846       rtx temp = force_reg (V8QImode, operands[1]);
17847       emit_move_insn (operands[0], temp);
17848       DONE;
17849     }
17850 })
17851
17852 (define_expand "movv2sf"
17853   [(set (match_operand:V2SF 0 "general_operand" "")
17854         (match_operand:V2SF 1 "general_operand" ""))]
17855    "TARGET_3DNOW"
17856    "
17857 {
17858   /* For constants other than zero into memory.  We do not know how the
17859      instructions used to build constants modify the upper 64 bits
17860      of the register, once we have that information we may be able
17861      to handle some of them more efficiently.  */
17862   if ((reload_in_progress | reload_completed) == 0
17863       && register_operand (operands[0], V2SFmode)
17864       && CONSTANT_P (operands[1]))
17865     {
17866       rtx addr = gen_reg_rtx (Pmode);
17867
17868       emit_move_insn (addr,
17869                       XEXP (force_const_mem (V2SFmode, operands[1]), 0));
17870       operands[1] = gen_rtx_MEM (V2SFmode, addr);
17871    }
17872
17873   /* Make operand1 a register is it isn't already.  */
17874   if ((reload_in_progress | reload_completed) == 0
17875       && !register_operand (operands[0], V2SFmode)
17876       && !register_operand (operands[1], V2SFmode)
17877       && (GET_CODE (operands[1]) != CONST_INT || INTVAL (operands[1]) != 0)
17878       && operands[1] != CONST0_RTX (V2SFmode))
17879    {
17880       rtx temp = force_reg (V2SFmode, operands[1]);
17881       emit_move_insn (operands[0], temp);
17882       DONE;
17883     }
17884 }")
17885
17886 (define_insn_and_split "*pushti"
17887   [(set (match_operand:TI 0 "push_operand" "=<")
17888         (match_operand:TI 1 "nonmemory_operand" "x"))]
17889   "TARGET_SSE"
17890   "#"
17891   ""
17892   [(set (reg:SI 7) (plus:SI (reg:SI 7) (const_int -16)))
17893    (set (mem:TI (reg:SI 7)) (match_dup 1))]
17894   ""
17895   [(set_attr "type" "sse")])
17896
17897 (define_insn_and_split "*pushv4sf"
17898   [(set (match_operand:V4SF 0 "push_operand" "=<")
17899         (match_operand:V4SF 1 "nonmemory_operand" "x"))]
17900   "TARGET_SSE"
17901   "#"
17902   ""
17903   [(set (reg:SI 7) (plus:SI (reg:SI 7) (const_int -16)))
17904    (set (mem:V4SF (reg:SI 7)) (match_dup 1))]
17905   ""
17906   [(set_attr "type" "sse")])
17907
17908 (define_insn_and_split "*pushv4si"
17909   [(set (match_operand:V4SI 0 "push_operand" "=<")
17910         (match_operand:V4SI 1 "nonmemory_operand" "x"))]
17911   "TARGET_SSE"
17912   "#"
17913   ""
17914   [(set (reg:SI 7) (plus:SI (reg:SI 7) (const_int -16)))
17915    (set (mem:V4SI (reg:SI 7)) (match_dup 1))]
17916   ""
17917   [(set_attr "type" "sse")])
17918
17919 (define_insn_and_split "*pushv2si"
17920   [(set (match_operand:V2SI 0 "push_operand" "=<")
17921         (match_operand:V2SI 1 "nonmemory_operand" "y"))]
17922   "TARGET_MMX"
17923   "#"
17924   ""
17925   [(set (reg:SI 7) (plus:SI (reg:SI 7) (const_int -8)))
17926    (set (mem:V2SI (reg:SI 7)) (match_dup 1))]
17927   ""
17928   [(set_attr "type" "mmx")])
17929
17930 (define_insn_and_split "*pushv4hi"
17931   [(set (match_operand:V4HI 0 "push_operand" "=<")
17932         (match_operand:V4HI 1 "nonmemory_operand" "y"))]
17933   "TARGET_MMX"
17934   "#"
17935   ""
17936   [(set (reg:SI 7) (plus:SI (reg:SI 7) (const_int -8)))
17937    (set (mem:V4HI (reg:SI 7)) (match_dup 1))]
17938   ""
17939   [(set_attr "type" "mmx")])
17940
17941 (define_insn_and_split "*pushv8qi"
17942   [(set (match_operand:V8QI 0 "push_operand" "=<")
17943         (match_operand:V8QI 1 "nonmemory_operand" "y"))]
17944   "TARGET_MMX"
17945   "#"
17946   ""
17947   [(set (reg:SI 7) (plus:SI (reg:SI 7) (const_int -8)))
17948    (set (mem:V8QI (reg:SI 7)) (match_dup 1))]
17949   ""
17950   [(set_attr "type" "mmx")])
17951
17952 (define_insn_and_split "*pushv2sf"
17953   [(set (match_operand:V2SF 0 "push_operand" "=<")
17954         (match_operand:V2SF 1 "nonmemory_operand" "y"))]
17955   "TARGET_3DNOW"
17956   "#"
17957   ""
17958   [(set (reg:SI 7) (plus:SI (reg:SI 7) (const_int -8)))
17959    (set (mem:V2SF (reg:SI 7)) (match_dup 1))]
17960   ""
17961   [(set_attr "type" "mmx")])
17962
17963 (define_insn "movti_internal"
17964   [(set (match_operand:TI 0 "nonimmediate_operand" "=x,m")
17965         (match_operand:TI 1 "general_operand" "xm,x"))]
17966   "TARGET_SSE && !TARGET_64BIT"
17967   "@
17968    movaps\t{%1, %0|%0, %1}
17969    movaps\t{%1, %0|%0, %1}"
17970   [(set_attr "type" "sse")])
17971
17972 (define_insn "*movti_rex64"
17973   [(set (match_operand:TI 0 "nonimmediate_operand" "=r,o,mx,x")
17974         (match_operand:TI 1 "general_operand" "riFo,riF,x,m"))]
17975   "TARGET_64BIT
17976    && (GET_CODE (operands[0]) != MEM || GET_CODE (operands[1]) != MEM)"
17977   "@
17978    #
17979    #
17980    movaps\\t{%1, %0|%0, %1}
17981    movaps\\t{%1, %0|%0, %1}"
17982   [(set_attr "type" "*,*,sse,sse")
17983    (set_attr "mode" "TI")])
17984
17985 (define_split
17986   [(set (match_operand:TI 0 "nonimmediate_operand" "")
17987         (match_operand:TI 1 "general_operand" ""))]
17988   "reload_completed && !SSE_REG_P (operands[0])
17989    && !SSE_REG_P (operands[1])"
17990   [(const_int 0)]
17991   "ix86_split_long_move (operands); DONE;")
17992
17993 ;; These two patterns are useful for specifying exactly whether to use
17994 ;; movaps or movups
17995 (define_insn "sse_movaps"
17996   [(set (match_operand:V4SF 0 "nonimmediate_operand" "=x,m")
17997         (unspec:V4SF [(match_operand:V4SF 1 "general_operand" "xm,x")] 38))]
17998   "TARGET_SSE"
17999   "@
18000    movaps\t{%1, %0|%0, %1}
18001    movaps\t{%1, %0|%0, %1}"
18002   [(set_attr "type" "sse")])
18003
18004 (define_insn "sse_movups"
18005   [(set (match_operand:V4SF 0 "nonimmediate_operand" "=x,m")
18006         (unspec:V4SF [(match_operand:V4SF 1 "general_operand" "xm,x")] 39))]
18007   "TARGET_SSE"
18008   "@
18009    movups\t{%1, %0|%0, %1}
18010    movups\t{%1, %0|%0, %1}"
18011   [(set_attr "type" "sse")])
18012
18013
18014 ;; SSE Strange Moves.
18015
18016 (define_insn "sse_movmskps"
18017   [(set (match_operand:SI 0 "register_operand" "=r")
18018         (unspec:SI [(match_operand:V4SF 1 "register_operand" "x")] 33))]
18019   "TARGET_SSE"
18020   "movmskps\t{%1, %0|%0, %1}"
18021   [(set_attr "type" "sse")])
18022
18023 (define_insn "mmx_pmovmskb"
18024   [(set (match_operand:SI 0 "register_operand" "=r")
18025         (unspec:SI [(match_operand:V8QI 1 "register_operand" "y")] 33))]
18026   "TARGET_SSE || TARGET_3DNOW_A"
18027   "pmovmskb\t{%1, %0|%0, %1}"
18028   [(set_attr "type" "sse")])
18029
18030 (define_insn "mmx_maskmovq"
18031   [(set (mem:V8QI (match_operand:SI 0 "register_operand" "D"))
18032         (unspec:V8QI [(match_operand:V8QI 1 "register_operand" "y")
18033                       (match_operand:V8QI 2 "register_operand" "y")] 32))]
18034   "TARGET_SSE || TARGET_3DNOW_A"
18035   ;; @@@ check ordering of operands in intel/nonintel syntax
18036   "maskmovq\t{%2, %1|%1, %2}"
18037   [(set_attr "type" "sse")])
18038
18039 (define_insn "sse_movntv4sf"
18040   [(set (match_operand:V4SF 0 "memory_operand" "=m")
18041         (unspec:V4SF [(match_operand:V4SF 1 "register_operand" "x")] 34))]
18042   "TARGET_SSE"
18043   "movntps\t{%1, %0|%0, %1}"
18044   [(set_attr "type" "sse")])
18045
18046 (define_insn "sse_movntdi"
18047   [(set (match_operand:DI 0 "memory_operand" "=m")
18048         (unspec:DI [(match_operand:DI 1 "register_operand" "y")] 34))]
18049   "TARGET_SSE || TARGET_3DNOW_A"
18050   "movntq\t{%1, %0|%0, %1}"
18051   [(set_attr "type" "sse")])
18052
18053 (define_insn "sse_movhlps"
18054   [(set (match_operand:V4SF 0 "register_operand" "=x")
18055         (vec_merge:V4SF
18056          (match_operand:V4SF 1 "register_operand" "0")
18057          (vec_select:V4SF (match_operand:V4SF 2 "register_operand" "x")
18058                           (parallel [(const_int 2)
18059                                      (const_int 3)
18060                                      (const_int 0)
18061                                      (const_int 1)]))
18062          (const_int 3)))]
18063   "TARGET_SSE"
18064   "movhlps\t{%2, %0|%0, %2}"
18065   [(set_attr "type" "sse")])
18066
18067 (define_insn "sse_movlhps"
18068   [(set (match_operand:V4SF 0 "register_operand" "=x")
18069         (vec_merge:V4SF
18070          (match_operand:V4SF 1 "register_operand" "0")
18071          (vec_select:V4SF (match_operand:V4SF 2 "register_operand" "x")
18072                           (parallel [(const_int 2)
18073                                      (const_int 3)
18074                                      (const_int 0)
18075                                      (const_int 1)]))
18076          (const_int 12)))]
18077   "TARGET_SSE"
18078   "movlhps\t{%2, %0|%0, %2}"
18079   [(set_attr "type" "sse")])
18080
18081 (define_insn "sse_movhps"
18082   [(set (match_operand:V4SF 0 "nonimmediate_operand" "=x,m")
18083         (vec_merge:V4SF
18084          (match_operand:V4SF 1 "nonimmediate_operand" "0,0")
18085          (match_operand:V4SF 2 "nonimmediate_operand" "m,x")
18086          (const_int 12)))]
18087   "TARGET_SSE && (GET_CODE (operands[1]) == MEM || GET_CODE (operands[2]) == MEM)"
18088   "movhps\t{%2, %0|%0, %2}"
18089   [(set_attr "type" "sse")])
18090
18091 (define_insn "sse_movlps"
18092   [(set (match_operand:V4SF 0 "nonimmediate_operand" "=x,m")
18093         (vec_merge:V4SF
18094          (match_operand:V4SF 1 "nonimmediate_operand" "0,0")
18095          (match_operand:V4SF 2 "nonimmediate_operand" "m,x")
18096          (const_int 3)))]
18097   "TARGET_SSE && (GET_CODE (operands[1]) == MEM || GET_CODE (operands[2]) == MEM)"
18098   "movlps\t{%2, %0|%0, %2}"
18099   [(set_attr "type" "sse")])
18100
18101 (define_insn "sse_loadss"
18102   [(set (match_operand:V4SF 0 "register_operand" "=x")
18103         (vec_merge:V4SF
18104          (match_operand:V4SF 1 "memory_operand" "m")
18105          (vec_duplicate:V4SF (float:SF (const_int 0)))
18106          (const_int 1)))]
18107   "TARGET_SSE"
18108   "movss\t{%1, %0|%0, %1}"
18109   [(set_attr "type" "sse")])
18110
18111 (define_insn "sse_movss"
18112   [(set (match_operand:V4SF 0 "register_operand" "=x")
18113         (vec_merge:V4SF
18114          (match_operand:V4SF 1 "register_operand" "0")
18115          (match_operand:V4SF 2 "register_operand" "x")
18116          (const_int 1)))]
18117   "TARGET_SSE"
18118   "movss\t{%2, %0|%0, %2}"
18119   [(set_attr "type" "sse")])
18120
18121 (define_insn "sse_storess"
18122   [(set (match_operand:SF 0 "memory_operand" "=m")
18123         (vec_select:SF
18124          (match_operand:V4SF 1 "register_operand" "x")
18125          (parallel [(const_int 0)])))]
18126   "TARGET_SSE"
18127   "movss\t{%1, %0|%0, %1}"
18128   [(set_attr "type" "sse")])
18129
18130 (define_insn "sse_shufps"
18131   [(set (match_operand:V4SF 0 "register_operand" "=x")
18132         (unspec:V4SF [(match_operand:V4SF 1 "register_operand" "0")
18133                       (match_operand:V4SF 2 "nonimmediate_operand" "xm")
18134                       (match_operand:SI 3 "immediate_operand" "i")] 41))]
18135   "TARGET_SSE"
18136   ;; @@@ check operand order for intel/nonintel syntax
18137   "shufps\t{%3, %2, %0|%0, %2, %3}"
18138   [(set_attr "type" "sse")])
18139
18140
18141 ;; SSE arithmetic
18142
18143 (define_insn "addv4sf3"
18144   [(set (match_operand:V4SF 0 "register_operand" "=x")
18145         (plus:V4SF (match_operand:V4SF 1 "register_operand" "0")
18146                    (match_operand:V4SF 2 "nonimmediate_operand" "xm")))]
18147   "TARGET_SSE"
18148   "addps\t{%2, %0|%0, %2}"
18149   [(set_attr "type" "sse")])
18150
18151 (define_insn "vmaddv4sf3"
18152   [(set (match_operand:V4SF 0 "register_operand" "=x")
18153         (vec_merge:V4SF (plus:V4SF (match_operand:V4SF 1 "register_operand" "0")
18154                                    (match_operand:V4SF 2 "nonimmediate_operand" "xm"))
18155                         (match_dup 1)
18156                         (const_int 1)))]
18157   "TARGET_SSE"
18158   "addss\t{%2, %0|%0, %2}"
18159   [(set_attr "type" "sse")])
18160
18161 (define_insn "subv4sf3"
18162   [(set (match_operand:V4SF 0 "register_operand" "=x")
18163         (minus:V4SF (match_operand:V4SF 1 "register_operand" "0")
18164                    (match_operand:V4SF 2 "nonimmediate_operand" "xm")))]
18165   "TARGET_SSE"
18166   "subps\t{%2, %0|%0, %2}"
18167   [(set_attr "type" "sse")])
18168
18169 (define_insn "vmsubv4sf3"
18170   [(set (match_operand:V4SF 0 "register_operand" "=x")
18171         (vec_merge:V4SF (minus:V4SF (match_operand:V4SF 1 "register_operand" "0")
18172                                    (match_operand:V4SF 2 "nonimmediate_operand" "xm"))
18173                         (match_dup 1)
18174                         (const_int 1)))]
18175   "TARGET_SSE"
18176   "subss\t{%2, %0|%0, %2}"
18177   [(set_attr "type" "sse")])
18178
18179 (define_insn "mulv4sf3"
18180   [(set (match_operand:V4SF 0 "register_operand" "=x")
18181         (mult:V4SF (match_operand:V4SF 1 "register_operand" "0")
18182                    (match_operand:V4SF 2 "nonimmediate_operand" "xm")))]
18183   "TARGET_SSE"
18184   "mulps\t{%2, %0|%0, %2}"
18185   [(set_attr "type" "sse")])
18186
18187 (define_insn "vmmulv4sf3"
18188   [(set (match_operand:V4SF 0 "register_operand" "=x")
18189         (vec_merge:V4SF (mult:V4SF (match_operand:V4SF 1 "register_operand" "0")
18190                                    (match_operand:V4SF 2 "nonimmediate_operand" "xm"))
18191                         (match_dup 1)
18192                         (const_int 1)))]
18193   "TARGET_SSE"
18194   "mulss\t{%2, %0|%0, %2}"
18195   [(set_attr "type" "sse")])
18196
18197 (define_insn "divv4sf3"
18198   [(set (match_operand:V4SF 0 "register_operand" "=x")
18199         (div:V4SF (match_operand:V4SF 1 "register_operand" "0")
18200                   (match_operand:V4SF 2 "nonimmediate_operand" "xm")))]
18201   "TARGET_SSE"
18202   "divps\t{%2, %0|%0, %2}"
18203   [(set_attr "type" "sse")])
18204
18205 (define_insn "vmdivv4sf3"
18206   [(set (match_operand:V4SF 0 "register_operand" "=x")
18207         (vec_merge:V4SF (div:V4SF (match_operand:V4SF 1 "register_operand" "0")
18208                                   (match_operand:V4SF 2 "nonimmediate_operand" "xm"))
18209                         (match_dup 1)
18210                         (const_int 1)))]
18211   "TARGET_SSE"
18212   "divss\t{%2, %0|%0, %2}"
18213   [(set_attr "type" "sse")])
18214
18215
18216 ;; SSE square root/reciprocal
18217
18218 (define_insn "rcpv4sf2"
18219   [(set (match_operand:V4SF 0 "register_operand" "=x")
18220         (unspec:V4SF [(match_operand:V4SF 1 "register_operand" "xm")] 42))]
18221   "TARGET_SSE"
18222   "rcpps\t{%1, %0|%0, %1}"
18223   [(set_attr "type" "sse")])
18224
18225 (define_insn "vmrcpv4sf2"
18226   [(set (match_operand:V4SF 0 "register_operand" "=x")
18227         (vec_merge:V4SF (unspec:V4SF [(match_operand:V4SF 1 "register_operand" "xm")] 42)
18228                         (match_operand:V4SF 2 "register_operand" "0")
18229                         (const_int 1)))]
18230   "TARGET_SSE"
18231   "rcpss\t{%1, %0|%0, %1}"
18232   [(set_attr "type" "sse")])
18233
18234 (define_insn "rsqrtv4sf2"
18235   [(set (match_operand:V4SF 0 "register_operand" "=x")
18236         (unspec:V4SF [(match_operand:V4SF 1 "register_operand" "xm")] 43))]
18237   "TARGET_SSE"
18238   "rsqrtps\t{%1, %0|%0, %1}"
18239   [(set_attr "type" "sse")])
18240
18241 (define_insn "vmrsqrtv4sf2"
18242   [(set (match_operand:V4SF 0 "register_operand" "=x")
18243         (vec_merge:V4SF (unspec:V4SF [(match_operand:V4SF 1 "register_operand" "xm")] 43)
18244                         (match_operand:V4SF 2 "register_operand" "0")
18245                         (const_int 1)))]
18246   "TARGET_SSE"
18247   "rsqrtss\t{%1, %0|%0, %1}"
18248   [(set_attr "type" "sse")])
18249
18250 (define_insn "sqrtv4sf2"
18251   [(set (match_operand:V4SF 0 "register_operand" "=x")
18252         (sqrt:V4SF (match_operand:V4SF 1 "register_operand" "xm")))]
18253   "TARGET_SSE"
18254   "sqrtps\t{%1, %0|%0, %1}"
18255   [(set_attr "type" "sse")])
18256
18257 (define_insn "vmsqrtv4sf2"
18258   [(set (match_operand:V4SF 0 "register_operand" "=x")
18259         (vec_merge:V4SF (sqrt:V4SF (match_operand:V4SF 1 "register_operand" "xm"))
18260                         (match_operand:V4SF 2 "register_operand" "0")
18261                         (const_int 1)))]
18262   "TARGET_SSE"
18263   "sqrtss\t{%1, %0|%0, %1}"
18264   [(set_attr "type" "sse")])
18265
18266
18267 ;; SSE logical operations.
18268
18269 ;; These are not called andti3 etc. because we really really don't want
18270 ;; the compiler to widen DImode ands to TImode ands and then try to move
18271 ;; into DImode subregs of SSE registers, and them together, and move out
18272 ;; of DImode subregs again!
18273
18274 (define_insn "*sse_andti3_df_1"
18275   [(set (subreg:TI (match_operand:DF 0 "register_operand" "=Y") 0)
18276         (and:TI (subreg:TI (match_operand:DF 1 "register_operand" "%0") 0)
18277                 (subreg:TI (match_operand:DF 2 "register_operand" "Y") 0)))]
18278   "TARGET_SSE2"
18279   "andpd\t{%2, %0|%0, %2}"
18280   [(set_attr "type" "sse")])
18281
18282 (define_insn "*sse_andti3_df_2"
18283   [(set (subreg:TI (match_operand:DF 0 "register_operand" "=Y") 0)
18284         (and:TI (subreg:TI (match_operand:DF 1 "register_operand" "0") 0)
18285                 (match_operand:TI 2 "nonimmediate_operand" "Ym")))]
18286   "TARGET_SSE2"
18287   "andpd\t{%2, %0|%0, %2}"
18288   [(set_attr "type" "sse")])
18289
18290 (define_insn "*sse_andti3_sf_1"
18291   [(set (subreg:TI (match_operand:SF 0 "register_operand" "=x") 0)
18292         (and:TI (subreg:TI (match_operand:SF 1 "register_operand" "%0") 0)
18293                 (subreg:TI (match_operand:SF 2 "register_operand" "x") 0)))]
18294   "TARGET_SSE"
18295   "andps\t{%2, %0|%0, %2}"
18296   [(set_attr "type" "sse")])
18297
18298 (define_insn "*sse_andti3_sf_2"
18299   [(set (subreg:TI (match_operand:SF 0 "register_operand" "=x") 0)
18300         (and:TI (subreg:TI (match_operand:SF 1 "register_operand" "0") 0)
18301                 (match_operand:TI 2 "nonimmediate_operand" "xm")))]
18302   "TARGET_SSE"
18303   "andps\t{%2, %0|%0, %2}"
18304   [(set_attr "type" "sse")])
18305
18306 (define_insn "sse_andti3"
18307   [(set (match_operand:TI 0 "register_operand" "=x")
18308         (and:TI (match_operand:TI 1 "register_operand" "%0")
18309                 (match_operand:TI 2 "nonimmediate_operand" "xm")))]
18310   "TARGET_SSE && !TARGET_SSE2"
18311   "andps\t{%2, %0|%0, %2}"
18312   [(set_attr "type" "sse")])
18313
18314 (define_insn "*sse_andti3_sse2"
18315   [(set (match_operand:TI 0 "register_operand" "=x")
18316         (and:TI (match_operand:TI 1 "register_operand" "%0")
18317                 (match_operand:TI 2 "nonimmediate_operand" "xm")))]
18318   "TARGET_SSE2"
18319   "pand\t{%2, %0|%0, %2}"
18320   [(set_attr "type" "sse")])
18321
18322 (define_insn "*sse_nandti3_df"
18323   [(set (subreg:TI (match_operand:DF 0 "register_operand" "=Y") 0)
18324         (and:TI (not:TI (subreg:TI (match_operand:DF 1 "register_operand" "0") 0))
18325                 (match_operand:TI 2 "nonimmediate_operand" "Ym")))]
18326   "TARGET_SSE2"
18327   "andnpd\t{%2, %0|%0, %2}"
18328   [(set_attr "type" "sse")])
18329
18330 (define_insn "*sse_nandti3_sf"
18331   [(set (subreg:TI (match_operand:SF 0 "register_operand" "=x") 0)
18332         (and:TI (not:TI (subreg:TI (match_operand:SF 1 "register_operand" "0") 0))
18333                 (match_operand:TI 2 "nonimmediate_operand" "xm")))]
18334   "TARGET_SSE"
18335   "andnps\t{%2, %0|%0, %2}"
18336   [(set_attr "type" "sse")])
18337
18338 (define_insn "sse_nandti3"
18339   [(set (match_operand:TI 0 "register_operand" "=x")
18340         (and:TI (not:TI (match_operand:TI 1 "register_operand" "0"))
18341                 (match_operand:TI 2 "nonimmediate_operand" "xm")))]
18342   "TARGET_SSE && !TARGET_SSE2"
18343   "andnps\t{%2, %0|%0, %2}"
18344   [(set_attr "type" "sse")])
18345
18346 (define_insn "*sse_nandti3_sse2"
18347   [(set (match_operand:TI 0 "register_operand" "=x")
18348         (and:TI (not:TI (match_operand:TI 1 "register_operand" "0"))
18349                 (match_operand:TI 2 "nonimmediate_operand" "xm")))]
18350   "TARGET_SSE2"
18351   "pnand\t{%2, %0|%0, %2}"
18352   [(set_attr "type" "sse")])
18353
18354 (define_insn "*sse_iorti3_df_1"
18355   [(set (subreg:TI (match_operand:DF 0 "register_operand" "=Y") 0)
18356         (ior:TI (subreg:TI (match_operand:DF 1 "register_operand" "%0") 0)
18357                 (subreg:TI (match_operand:DF 2 "register_operand" "Y") 0)))]
18358   "TARGET_SSE2"
18359   "orpd\t{%2, %0|%0, %2}"
18360   [(set_attr "type" "sse")])
18361
18362 (define_insn "*sse_iorti3_df_2"
18363   [(set (subreg:TI (match_operand:DF 0 "register_operand" "=Y") 0)
18364         (ior:TI (subreg:TI (match_operand:DF 1 "register_operand" "0") 0)
18365                 (match_operand:TI 2 "nonimmediate_operand" "Ym")))]
18366   "TARGET_SSE2"
18367   "orpd\t{%2, %0|%0, %2}"
18368   [(set_attr "type" "sse")])
18369
18370 (define_insn "*sse_iorti3_sf_1"
18371   [(set (subreg:TI (match_operand:SF 0 "register_operand" "=x") 0)
18372         (ior:TI (subreg:TI (match_operand:SF 1 "register_operand" "%0") 0)
18373                 (subreg:TI (match_operand:SF 2 "register_operand" "x") 0)))]
18374   "TARGET_SSE"
18375   "orps\t{%2, %0|%0, %2}"
18376   [(set_attr "type" "sse")])
18377
18378 (define_insn "*sse_iorti3_sf_2"
18379   [(set (subreg:TI (match_operand:SF 0 "register_operand" "=x") 0)
18380         (ior:TI (subreg:TI (match_operand:SF 1 "register_operand" "0") 0)
18381                 (match_operand:TI 2 "nonimmediate_operand" "xm")))]
18382   "TARGET_SSE"
18383   "orps\t{%2, %0|%0, %2}"
18384   [(set_attr "type" "sse")])
18385
18386 (define_insn "sse_iorti3"
18387   [(set (match_operand:TI 0 "register_operand" "=x")
18388         (ior:TI (match_operand:TI 1 "register_operand" "%0")
18389                 (match_operand:TI 2 "nonimmediate_operand" "xm")))]
18390   "TARGET_SSE && !TARGET_SSE2"
18391   "orps\t{%2, %0|%0, %2}"
18392   [(set_attr "type" "sse")])
18393
18394 (define_insn "*sse_iorti3_sse2"
18395   [(set (match_operand:TI 0 "register_operand" "=x")
18396         (ior:TI (match_operand:TI 1 "register_operand" "%0")
18397                 (match_operand:TI 2 "nonimmediate_operand" "xm")))]
18398   "TARGET_SSE2"
18399   "por\t{%2, %0|%0, %2}"
18400   [(set_attr "type" "sse")])
18401
18402 (define_insn "*sse_xorti3_df_1"
18403   [(set (subreg:TI (match_operand:DF 0 "register_operand" "=Y") 0)
18404         (xor:TI (subreg:TI (match_operand:DF 1 "register_operand" "%0") 0)
18405                 (subreg:TI (match_operand:DF 2 "register_operand" "Y") 0)))]
18406   "TARGET_SSE2"
18407   "xorpd\t{%2, %0|%0, %2}"
18408   [(set_attr "type" "sse")])
18409
18410 (define_insn "*sse_xorti3_df_2"
18411   [(set (subreg:TI (match_operand:DF 0 "register_operand" "=Y") 0)
18412         (xor:TI (subreg:TI (match_operand:DF 1 "register_operand" "0") 0)
18413                 (match_operand:TI 2 "nonimmediate_operand" "Ym")))]
18414   "TARGET_SSE2"
18415   "xorpd\t{%2, %0|%0, %2}"
18416   [(set_attr "type" "sse")])
18417
18418 (define_insn "*sse_xorti3_sf_1"
18419   [(set (subreg:TI (match_operand:SF 0 "register_operand" "=x") 0)
18420         (xor:TI (subreg:TI (match_operand:SF 1 "register_operand" "%0") 0)
18421                 (subreg:TI (match_operand:SF 2 "register_operand" "x") 0)))]
18422   "TARGET_SSE"
18423   "xorps\t{%2, %0|%0, %2}"
18424   [(set_attr "type" "sse")])
18425
18426 (define_insn "*sse_xorti3_sf_2"
18427   [(set (subreg:TI (match_operand:SF 0 "register_operand" "=x") 0)
18428         (xor:TI (subreg:TI (match_operand:SF 1 "register_operand" "0") 0)
18429                 (match_operand:TI 2 "nonimmediate_operand" "xm")))]
18430   "TARGET_SSE"
18431   "xorps\t{%2, %0|%0, %2}"
18432   [(set_attr "type" "sse")])
18433
18434 (define_insn "sse_xorti3"
18435   [(set (match_operand:TI 0 "register_operand" "=x")
18436         (xor:TI (match_operand:TI 1 "register_operand" "%0")
18437                 (match_operand:TI 2 "nonimmediate_operand" "xm")))]
18438   "TARGET_SSE && !TARGET_SSE2"
18439   "xorps\t{%2, %0|%0, %2}"
18440   [(set_attr "type" "sse")])
18441
18442 (define_insn "*sse_xorti3_sse2"
18443   [(set (match_operand:TI 0 "register_operand" "=x")
18444         (xor:TI (match_operand:TI 1 "register_operand" "%0")
18445                 (match_operand:TI 2 "nonimmediate_operand" "xm")))]
18446   "TARGET_SSE2"
18447   "pxor\t{%2, %0|%0, %2}"
18448   [(set_attr "type" "sse")])
18449
18450 ;; Use xor, but don't show input operands so they aren't live before
18451 ;; this insn.
18452 (define_insn "sse_clrti"
18453   [(set (match_operand:TI 0 "register_operand" "=x")
18454         (unspec:TI [(const_int 0)] 45))]
18455   "TARGET_SSE"
18456   "xorps\t{%0, %0|%0, %0}"
18457   [(set_attr "type" "sse")
18458    (set_attr "memory" "none")])
18459
18460 ;; SSE mask-generating compares
18461
18462 (define_insn "maskcmpv4sf3"
18463   [(set (match_operand:V4SI 0 "register_operand" "=x")
18464         (match_operator:V4SI 3 "sse_comparison_operator"
18465                              [(match_operand:V4SF 1 "register_operand" "0")
18466                               (match_operand:V4SF 2 "nonimmediate_operand" "x")]))]
18467   "TARGET_SSE"
18468   "cmp%D3ps\t{%2, %0|%0, %2}"
18469   [(set_attr "type" "sse")])
18470
18471 (define_insn "maskncmpv4sf3"
18472   [(set (match_operand:V4SI 0 "register_operand" "=x")
18473         (not:V4SI
18474          (match_operator:V4SI 3 "sse_comparison_operator"
18475                               [(match_operand:V4SF 1 "register_operand" "0")
18476                                (match_operand:V4SF 2 "nonimmediate_operand" "x")])))]
18477   "TARGET_SSE"
18478   "*
18479 {
18480   if (GET_CODE (operands[3]) == UNORDERED)
18481     return \"cmpordps\t{%2, %0|%0, %2}\";
18482
18483   return \"cmpn%D3ps\t{%2, %0|%0, %2}\";
18484 }"
18485   [(set_attr "type" "sse")])
18486
18487 (define_insn "vmmaskcmpv4sf3"
18488   [(set (match_operand:V4SI 0 "register_operand" "=x")
18489         (vec_merge:V4SI
18490          (match_operator:V4SI 3 "sse_comparison_operator"
18491                               [(match_operand:V4SF 1 "register_operand" "0")
18492                                (match_operand:V4SF 2 "nonimmediate_operand" "x")])
18493          (match_dup 1)
18494          (const_int 1)))]
18495   "TARGET_SSE"
18496   "cmp%D3ss\t{%2, %0|%0, %2}"
18497   [(set_attr "type" "sse")])
18498
18499 (define_insn "vmmaskncmpv4sf3"
18500   [(set (match_operand:V4SI 0 "register_operand" "=x")
18501         (vec_merge:V4SI
18502          (not:V4SI
18503           (match_operator:V4SI 3 "sse_comparison_operator"
18504                                [(match_operand:V4SF 1 "register_operand" "0")
18505                                 (match_operand:V4SF 2 "nonimmediate_operand" "x")]))
18506          (subreg:V4SI (match_dup 1) 0)
18507          (const_int 1)))]
18508   "TARGET_SSE"
18509   "*
18510 {
18511   if (GET_CODE (operands[3]) == UNORDERED)
18512     return \"cmpordss\t{%2, %0|%0, %2}\";
18513
18514   return \"cmpn%D3ss\t{%2, %0|%0, %2}\";
18515 }"
18516   [(set_attr "type" "sse")])
18517
18518 (define_insn "sse_comi"
18519   [(set (reg:CCFP 17)
18520         (match_operator:CCFP 2 "sse_comparison_operator"
18521                         [(vec_select:SF
18522                           (match_operand:V4SF 0 "register_operand" "x")
18523                           (parallel [(const_int 0)]))
18524                          (vec_select:SF
18525                           (match_operand:V4SF 1 "register_operand" "x")
18526                           (parallel [(const_int 0)]))]))]
18527   "TARGET_SSE"
18528   "comiss\t{%1, %0|%0, %1}"
18529   [(set_attr "type" "sse")])
18530
18531 (define_insn "sse_ucomi"
18532   [(set (reg:CCFPU 17)
18533         (match_operator:CCFPU 2 "sse_comparison_operator"
18534                         [(vec_select:SF
18535                           (match_operand:V4SF 0 "register_operand" "x")
18536                           (parallel [(const_int 0)]))
18537                          (vec_select:SF
18538                           (match_operand:V4SF 1 "register_operand" "x")
18539                           (parallel [(const_int 0)]))]))]
18540   "TARGET_SSE"
18541   "ucomiss\t{%1, %0|%0, %1}"
18542   [(set_attr "type" "sse")])
18543
18544
18545 ;; SSE unpack
18546
18547 (define_insn "sse_unpckhps"
18548   [(set (match_operand:V4SF 0 "register_operand" "=x")
18549         (vec_merge:V4SF
18550          (vec_select:V4SF (match_operand:V4SF 1 "register_operand" "0")
18551                           (parallel [(const_int 2)
18552                                      (const_int 0)
18553                                      (const_int 3)
18554                                      (const_int 1)]))
18555          (vec_select:V4SF (match_operand:V4SF 2 "register_operand" "x")
18556                           (parallel [(const_int 0)
18557                                      (const_int 2)
18558                                      (const_int 1)
18559                                      (const_int 3)]))
18560          (const_int 5)))]
18561   "TARGET_SSE"
18562   "unpckhps\t{%2, %0|%0, %2}"
18563   [(set_attr "type" "sse")])
18564
18565 (define_insn "sse_unpcklps"
18566   [(set (match_operand:V4SF 0 "register_operand" "=x")
18567         (vec_merge:V4SF
18568          (vec_select:V4SF (match_operand:V4SF 1 "register_operand" "0")
18569                           (parallel [(const_int 0)
18570                                      (const_int 2)
18571                                      (const_int 1)
18572                                      (const_int 3)]))
18573          (vec_select:V4SF (match_operand:V4SF 2 "register_operand" "x")
18574                           (parallel [(const_int 2)
18575                                      (const_int 0)
18576                                      (const_int 3)
18577                                      (const_int 1)]))
18578          (const_int 5)))]
18579   "TARGET_SSE"
18580   "unpcklps\t{%2, %0|%0, %2}"
18581   [(set_attr "type" "sse")])
18582
18583
18584 ;; SSE min/max
18585
18586 (define_insn "smaxv4sf3"
18587   [(set (match_operand:V4SF 0 "register_operand" "=x")
18588         (smax:V4SF (match_operand:V4SF 1 "register_operand" "0")
18589                    (match_operand:V4SF 2 "nonimmediate_operand" "xm")))]
18590   "TARGET_SSE"
18591   "maxps\t{%2, %0|%0, %2}"
18592   [(set_attr "type" "sse")])
18593
18594 (define_insn "vmsmaxv4sf3"
18595   [(set (match_operand:V4SF 0 "register_operand" "=x")
18596         (vec_merge:V4SF (smax:V4SF (match_operand:V4SF 1 "register_operand" "0")
18597                                    (match_operand:V4SF 2 "nonimmediate_operand" "xm"))
18598                         (match_dup 1)
18599                         (const_int 1)))]
18600   "TARGET_SSE"
18601   "maxss\t{%2, %0|%0, %2}"
18602   [(set_attr "type" "sse")])
18603
18604 (define_insn "sminv4sf3"
18605   [(set (match_operand:V4SF 0 "register_operand" "=x")
18606         (smin:V4SF (match_operand:V4SF 1 "register_operand" "0")
18607                    (match_operand:V4SF 2 "nonimmediate_operand" "xm")))]
18608   "TARGET_SSE"
18609   "minps\t{%2, %0|%0, %2}"
18610   [(set_attr "type" "sse")])
18611
18612 (define_insn "vmsminv4sf3"
18613   [(set (match_operand:V4SF 0 "register_operand" "=x")
18614         (vec_merge:V4SF (smin:V4SF (match_operand:V4SF 1 "register_operand" "0")
18615                                    (match_operand:V4SF 2 "nonimmediate_operand" "xm"))
18616                         (match_dup 1)
18617                         (const_int 1)))]
18618   "TARGET_SSE"
18619   "minss\t{%2, %0|%0, %2}"
18620   [(set_attr "type" "sse")])
18621
18622
18623 ;; SSE <-> integer/MMX conversions
18624
18625 (define_insn "cvtpi2ps"
18626   [(set (match_operand:V4SF 0 "register_operand" "=x")
18627         (vec_merge:V4SF (match_operand:V4SF 1 "register_operand" "0")
18628                         (vec_duplicate:V4SF
18629                          (float:V2SF (match_operand:V2SI 2 "register_operand" "ym")))
18630                         (const_int 12)))]
18631   "TARGET_SSE"
18632   "cvtpi2ps\t{%2, %0|%0, %2}"
18633   [(set_attr "type" "sse")])
18634
18635 (define_insn "cvtps2pi"
18636   [(set (match_operand:V2SI 0 "register_operand" "=y")
18637         (vec_select:V2SI (fix:V4SI (match_operand:V4SF 1 "register_operand" "xm"))
18638                          (parallel
18639                           [(const_int 0)
18640                            (const_int 1)])))]
18641   "TARGET_SSE"
18642   "cvtps2pi\t{%1, %0|%0, %1}"
18643   [(set_attr "type" "sse")])
18644
18645 (define_insn "cvttps2pi"
18646   [(set (match_operand:V2SI 0 "register_operand" "=y")
18647         (vec_select:V2SI (unspec:V4SI [(match_operand:V4SF 1 "register_operand" "xm")] 30)
18648                          (parallel
18649                           [(const_int 0)
18650                            (const_int 1)])))]
18651   "TARGET_SSE"
18652   "cvttps2pi\t{%1, %0|%0, %1}"
18653   [(set_attr "type" "sse")])
18654
18655 (define_insn "cvtsi2ss"
18656   [(set (match_operand:V4SF 0 "register_operand" "=x")
18657         (vec_merge:V4SF (match_operand:V4SF 1 "register_operand" "0")
18658                         (vec_duplicate:V4SF
18659                          (float:SF (match_operand:SI 2 "register_operand" "rm")))
18660                         (const_int 14)))]
18661   "TARGET_SSE"
18662   "cvtsi2ss\t{%2, %0|%0, %2}"
18663   [(set_attr "type" "sse")])
18664
18665 (define_insn "cvtss2si"
18666   [(set (match_operand:SI 0 "register_operand" "=r")
18667         (vec_select:SI (fix:V4SI (match_operand:V4SF 1 "register_operand" "xm"))
18668                        (parallel [(const_int 0)])))]
18669   "TARGET_SSE"
18670   "cvtss2si\t{%1, %0|%0, %1}"
18671   [(set_attr "type" "sse")])
18672
18673 (define_insn "cvttss2si"
18674   [(set (match_operand:SI 0 "register_operand" "=r")
18675         (vec_select:SI (unspec:V4SI [(match_operand:V4SF 1 "register_operand" "xm")] 30)
18676                        (parallel [(const_int 0)])))]
18677   "TARGET_SSE"
18678   "cvttss2si\t{%1, %0|%0, %1}"
18679   [(set_attr "type" "sse")])
18680
18681
18682 ;; MMX insns
18683
18684 ;; MMX arithmetic
18685
18686 (define_insn "addv8qi3"
18687   [(set (match_operand:V8QI 0 "register_operand" "=y")
18688         (plus:V8QI (match_operand:V8QI 1 "register_operand" "0")
18689                    (match_operand:V8QI 2 "nonimmediate_operand" "ym")))]
18690   "TARGET_MMX"
18691   "paddb\t{%2, %0|%0, %2}"
18692   [(set_attr "type" "mmx")])
18693
18694 (define_insn "addv4hi3"
18695   [(set (match_operand:V4HI 0 "register_operand" "=y")
18696         (plus:V4HI (match_operand:V4HI 1 "register_operand" "0")
18697                    (match_operand:V4HI 2 "nonimmediate_operand" "ym")))]
18698   "TARGET_MMX"
18699   "paddw\t{%2, %0|%0, %2}"
18700   [(set_attr "type" "mmx")])
18701
18702 (define_insn "addv2si3"
18703   [(set (match_operand:V2SI 0 "register_operand" "=y")
18704         (plus:V2SI (match_operand:V2SI 1 "register_operand" "0")
18705                    (match_operand:V2SI 2 "nonimmediate_operand" "ym")))]
18706   "TARGET_MMX"
18707   "paddd\t{%2, %0|%0, %2}"
18708   [(set_attr "type" "mmx")])
18709
18710 (define_insn "ssaddv8qi3"
18711   [(set (match_operand:V8QI 0 "register_operand" "=y")
18712         (ss_plus:V8QI (match_operand:V8QI 1 "register_operand" "0")
18713                       (match_operand:V8QI 2 "nonimmediate_operand" "ym")))]
18714   "TARGET_MMX"
18715   "paddsb\t{%2, %0|%0, %2}"
18716   [(set_attr "type" "mmx")])
18717
18718 (define_insn "ssaddv4hi3"
18719   [(set (match_operand:V4HI 0 "register_operand" "=y")
18720         (ss_plus:V4HI (match_operand:V4HI 1 "register_operand" "0")
18721                       (match_operand:V4HI 2 "nonimmediate_operand" "ym")))]
18722   "TARGET_MMX"
18723   "paddsw\t{%2, %0|%0, %2}"
18724   [(set_attr "type" "mmx")])
18725
18726 (define_insn "usaddv8qi3"
18727   [(set (match_operand:V8QI 0 "register_operand" "=y")
18728         (us_plus:V8QI (match_operand:V8QI 1 "register_operand" "0")
18729                       (match_operand:V8QI 2 "nonimmediate_operand" "ym")))]
18730   "TARGET_MMX"
18731   "paddusb\t{%2, %0|%0, %2}"
18732   [(set_attr "type" "mmx")])
18733
18734 (define_insn "usaddv4hi3"
18735   [(set (match_operand:V4HI 0 "register_operand" "=y")
18736         (us_plus:V4HI (match_operand:V4HI 1 "register_operand" "0")
18737                       (match_operand:V4HI 2 "nonimmediate_operand" "ym")))]
18738   "TARGET_MMX"
18739   "paddusw\t{%2, %0|%0, %2}"
18740   [(set_attr "type" "mmx")])
18741
18742 (define_insn "subv8qi3"
18743   [(set (match_operand:V8QI 0 "register_operand" "=y")
18744         (minus:V8QI (match_operand:V8QI 1 "register_operand" "0")
18745                     (match_operand:V8QI 2 "nonimmediate_operand" "ym")))]
18746   "TARGET_MMX"
18747   "psubb\t{%2, %0|%0, %2}"
18748   [(set_attr "type" "mmx")])
18749
18750 (define_insn "subv4hi3"
18751   [(set (match_operand:V4HI 0 "register_operand" "=y")
18752         (minus:V4HI (match_operand:V4HI 1 "register_operand" "0")
18753                     (match_operand:V4HI 2 "nonimmediate_operand" "ym")))]
18754   "TARGET_MMX"
18755   "psubw\t{%2, %0|%0, %2}"
18756   [(set_attr "type" "mmx")])
18757
18758 (define_insn "subv2si3"
18759   [(set (match_operand:V2SI 0 "register_operand" "=y")
18760         (minus:V2SI (match_operand:V2SI 1 "register_operand" "0")
18761                     (match_operand:V2SI 2 "nonimmediate_operand" "ym")))]
18762   "TARGET_MMX"
18763   "psubd\t{%2, %0|%0, %2}"
18764   [(set_attr "type" "mmx")])
18765
18766 (define_insn "sssubv8qi3"
18767   [(set (match_operand:V8QI 0 "register_operand" "=y")
18768         (ss_minus:V8QI (match_operand:V8QI 1 "register_operand" "0")
18769                        (match_operand:V8QI 2 "nonimmediate_operand" "ym")))]
18770   "TARGET_MMX"
18771   "psubsb\t{%2, %0|%0, %2}"
18772   [(set_attr "type" "mmx")])
18773
18774 (define_insn "sssubv4hi3"
18775   [(set (match_operand:V4HI 0 "register_operand" "=y")
18776         (ss_minus:V4HI (match_operand:V4HI 1 "register_operand" "0")
18777                        (match_operand:V4HI 2 "nonimmediate_operand" "ym")))]
18778   "TARGET_MMX"
18779   "psubsw\t{%2, %0|%0, %2}"
18780   [(set_attr "type" "mmx")])
18781
18782 (define_insn "ussubv8qi3"
18783   [(set (match_operand:V8QI 0 "register_operand" "=y")
18784         (us_minus:V8QI (match_operand:V8QI 1 "register_operand" "0")
18785                        (match_operand:V8QI 2 "nonimmediate_operand" "ym")))]
18786   "TARGET_MMX"
18787   "psubusb\t{%2, %0|%0, %2}"
18788   [(set_attr "type" "mmx")])
18789
18790 (define_insn "ussubv4hi3"
18791   [(set (match_operand:V4HI 0 "register_operand" "=y")
18792         (us_minus:V4HI (match_operand:V4HI 1 "register_operand" "0")
18793                        (match_operand:V4HI 2 "nonimmediate_operand" "ym")))]
18794   "TARGET_MMX"
18795   "psubusw\t{%2, %0|%0, %2}"
18796   [(set_attr "type" "mmx")])
18797
18798 (define_insn "mulv4hi3"
18799   [(set (match_operand:V4HI 0 "register_operand" "=y")
18800         (mult:V4HI (match_operand:V4HI 1 "register_operand" "0")
18801                    (match_operand:V4HI 2 "nonimmediate_operand" "ym")))]
18802   "TARGET_MMX"
18803   "pmullw\t{%2, %0|%0, %2}"
18804   [(set_attr "type" "mmx")])
18805
18806 (define_insn "smulv4hi3_highpart"
18807   [(set (match_operand:V4HI 0 "register_operand" "=y")
18808         (truncate:V4HI
18809          (lshiftrt:V4SI
18810           (mult:V4SI (sign_extend:V4SI (match_operand:V4HI 1 "register_operand" "0"))
18811                      (sign_extend:V4SI (match_operand:V4HI 2 "nonimmediate_operand" "ym")))
18812           (const_int 16))))]
18813   "TARGET_MMX"
18814   "pmulhw\t{%2, %0|%0, %2}"
18815   [(set_attr "type" "mmx")])
18816
18817 (define_insn "umulv4hi3_highpart"
18818   [(set (match_operand:V4HI 0 "register_operand" "=y")
18819         (truncate:V4HI
18820          (lshiftrt:V4SI
18821           (mult:V4SI (zero_extend:V4SI (match_operand:V4HI 1 "register_operand" "0"))
18822                      (zero_extend:V4SI (match_operand:V4HI 2 "nonimmediate_operand" "ym")))
18823           (const_int 16))))]
18824   "TARGET_SSE || TARGET_3DNOW_A"
18825   "pmulhuw\t{%2, %0|%0, %2}"
18826   [(set_attr "type" "mmx")])
18827
18828 (define_insn "mmx_pmaddwd"
18829   [(set (match_operand:V2SI 0 "register_operand" "=y")
18830         (plus:V2SI
18831          (mult:V2SI
18832           (sign_extend:V2SI (vec_select:V2HI (match_operand:V4HI 1 "register_operand" "0")
18833                                              (parallel [(const_int 0)
18834                                                         (const_int 2)])))
18835           (sign_extend:V2SI (vec_select:V2HI (match_operand:V4HI 2 "nonimmediate_operand" "ym")
18836                                              (parallel [(const_int 0)
18837                                                         (const_int 2)]))))
18838          (mult:V2SI
18839           (sign_extend:V2SI (vec_select:V2HI (match_dup 1)
18840                                              (parallel [(const_int 1)
18841                                                         (const_int 3)])))
18842           (sign_extend:V2SI (vec_select:V2HI (match_dup 2)
18843                                              (parallel [(const_int 1)
18844                                                         (const_int 3)]))))))]
18845   "TARGET_MMX"
18846   "pmaddwd\t{%2, %0|%0, %2}"
18847   [(set_attr "type" "mmx")])
18848
18849
18850 ;; MMX logical operations
18851 ;; Note we don't want to declare these as regular iordi3 insns to prevent
18852 ;; normal code that also wants to use the FPU from getting broken.
18853 ;; The UNSPECs are there to prevent the combiner from getting overly clever.
18854 (define_insn "mmx_iordi3"
18855   [(set (match_operand:DI 0 "register_operand" "=y")
18856         (unspec:DI
18857          [(ior:DI (match_operand:DI 1 "register_operand" "0")
18858                   (match_operand:DI 2 "nonimmediate_operand" "ym"))] 45))]
18859   "TARGET_MMX"
18860   "por\t{%2, %0|%0, %2}"
18861   [(set_attr "type" "mmx")])
18862
18863 (define_insn "mmx_xordi3"
18864   [(set (match_operand:DI 0 "register_operand" "=y")
18865         (unspec:DI
18866          [(xor:DI (match_operand:DI 1 "register_operand" "0")
18867                   (match_operand:DI 2 "nonimmediate_operand" "ym"))] 45))]
18868   "TARGET_MMX"
18869   "pxor\t{%2, %0|%0, %2}"
18870   [(set_attr "type" "mmx")
18871    (set_attr "memory" "none")])
18872
18873 ;; Same as pxor, but don't show input operands so that we don't think
18874 ;; they are live.
18875 (define_insn "mmx_clrdi"
18876   [(set (match_operand:DI 0 "register_operand" "=y")
18877         (unspec:DI [(const_int 0)] 45))]
18878   "TARGET_MMX"
18879   "pxor\t{%0, %0|%0, %0}"
18880   [(set_attr "type" "mmx")])
18881
18882 (define_insn "mmx_anddi3"
18883   [(set (match_operand:DI 0 "register_operand" "=y")
18884         (unspec:DI
18885          [(and:DI (match_operand:DI 1 "register_operand" "0")
18886                   (match_operand:DI 2 "nonimmediate_operand" "ym"))] 45))]
18887   "TARGET_MMX"
18888   "pand\t{%2, %0|%0, %2}"
18889   [(set_attr "type" "mmx")])
18890
18891 (define_insn "mmx_nanddi3"
18892   [(set (match_operand:DI 0 "register_operand" "=y")
18893         (unspec:DI
18894          [(and:DI (not:DI (match_operand:DI 1 "register_operand" "0"))
18895                           (match_operand:DI 2 "nonimmediate_operand" "ym"))] 45))]
18896   "TARGET_MMX"
18897   "pandn\t{%2, %0|%0, %2}"
18898   [(set_attr "type" "mmx")])
18899
18900
18901 ;; MMX unsigned averages/sum of absolute differences
18902
18903 (define_insn "mmx_uavgv8qi3"
18904   [(set (match_operand:V8QI 0 "register_operand" "=y")
18905         (ashiftrt:V8QI
18906          (plus:V8QI (plus:V8QI
18907                      (match_operand:V8QI 1 "register_operand" "0")
18908                      (match_operand:V8QI 2 "nonimmediate_operand" "ym"))
18909                     (vec_const:V8QI (parallel [(const_int 1)
18910                                                (const_int 1)
18911                                                (const_int 1)
18912                                                (const_int 1)
18913                                                (const_int 1)
18914                                                (const_int 1)
18915                                                (const_int 1)
18916                                                (const_int 1)])))
18917          (const_int 1)))]
18918   "TARGET_SSE || TARGET_3DNOW_A"
18919   "pavgb\t{%2, %0|%0, %2}"
18920   [(set_attr "type" "sse")])
18921
18922 (define_insn "mmx_uavgv4hi3"
18923   [(set (match_operand:V4HI 0 "register_operand" "=y")
18924         (ashiftrt:V4HI
18925          (plus:V4HI (plus:V4HI
18926                      (match_operand:V4HI 1 "register_operand" "0")
18927                      (match_operand:V4HI 2 "nonimmediate_operand" "ym"))
18928                     (vec_const:V4HI (parallel [(const_int 1)
18929                                                (const_int 1)
18930                                                (const_int 1)
18931                                                (const_int 1)])))
18932          (const_int 1)))]
18933   "TARGET_SSE || TARGET_3DNOW_A"
18934   "pavgw\t{%2, %0|%0, %2}"
18935   [(set_attr "type" "sse")])
18936
18937 (define_insn "mmx_psadbw"
18938   [(set (match_operand:V8QI 0 "register_operand" "=y")
18939         (abs:V8QI (minus:V8QI (match_operand:V8QI 1 "register_operand" "0")
18940                               (match_operand:V8QI 2 "nonimmediate_operand" "ym"))))]
18941   "TARGET_SSE || TARGET_3DNOW_A"
18942   "psadbw\t{%2, %0|%0, %2}"
18943   [(set_attr "type" "sse")])
18944
18945
18946 ;; MMX insert/extract/shuffle
18947
18948 (define_insn "mmx_pinsrw"
18949   [(set (match_operand:V4HI 0 "register_operand" "=y")
18950         (vec_merge:V4HI (match_operand:V4HI 1 "register_operand" "0")
18951                         (vec_duplicate:V4HI
18952                          (truncate:HI (match_operand:SI 2 "nonimmediate_operand" "rm")))
18953                         (match_operand:SI 3 "immediate_operand" "i")))]
18954   "TARGET_SSE || TARGET_3DNOW_A"
18955   "pinsrw\t{%3, %2, %0|%0, %2, %3}"
18956   [(set_attr "type" "sse")])
18957
18958 (define_insn "mmx_pextrw"
18959   [(set (match_operand:SI 0 "register_operand" "=r")
18960         (zero_extend:SI (vec_select:HI (match_operand:V4HI 1 "register_operand" "y")
18961                                        (parallel
18962                                         [(match_operand:SI 2 "immediate_operand" "i")]))))]
18963   "TARGET_SSE || TARGET_3DNOW_A"
18964   "pextrw\t{%2, %1, %0|%0, %1, %2}"
18965   [(set_attr "type" "sse")])
18966
18967 (define_insn "mmx_pshufw"
18968   [(set (match_operand:V4HI 0 "register_operand" "=y")
18969         (unspec:V4HI [(match_operand:V4HI 1 "register_operand" "0")
18970                       (match_operand:SI 2 "immediate_operand" "i")] 41))]
18971   "TARGET_SSE || TARGET_3DNOW_A"
18972   "pshufw\t{%2, %1, %0|%0, %1, %2}"
18973   [(set_attr "type" "sse")])
18974
18975
18976 ;; MMX mask-generating comparisons
18977
18978 (define_insn "eqv8qi3"
18979   [(set (match_operand:V8QI 0 "register_operand" "=y")
18980         (eq:V8QI (match_operand:V8QI 1 "register_operand" "0")
18981                  (match_operand:V8QI 2 "nonimmediate_operand" "ym")))]
18982   "TARGET_MMX"
18983   "pcmpeqb\t{%2, %0|%0, %2}"
18984   [(set_attr "type" "mmx")])
18985
18986 (define_insn "eqv4hi3"
18987   [(set (match_operand:V4HI 0 "register_operand" "=y")
18988         (eq:V4HI (match_operand:V4HI 1 "register_operand" "0")
18989                  (match_operand:V4HI 2 "nonimmediate_operand" "ym")))]
18990   "TARGET_MMX"
18991   "pcmpeqw\t{%2, %0|%0, %2}"
18992   [(set_attr "type" "mmx")])
18993
18994 (define_insn "eqv2si3"
18995   [(set (match_operand:V2SI 0 "register_operand" "=y")
18996         (eq:V2SI (match_operand:V2SI 1 "register_operand" "0")
18997                  (match_operand:V2SI 2 "nonimmediate_operand" "ym")))]
18998   "TARGET_MMX"
18999   "pcmpeqd\t{%2, %0|%0, %2}"
19000   [(set_attr "type" "mmx")])
19001
19002 (define_insn "gtv8qi3"
19003   [(set (match_operand:V8QI 0 "register_operand" "=y")
19004         (gt:V8QI (match_operand:V8QI 1 "register_operand" "0")
19005                  (match_operand:V8QI 2 "nonimmediate_operand" "ym")))]
19006   "TARGET_MMX"
19007   "pcmpgtb\t{%2, %0|%0, %2}"
19008   [(set_attr "type" "mmx")])
19009
19010 (define_insn "gtv4hi3"
19011   [(set (match_operand:V4HI 0 "register_operand" "=y")
19012         (gt:V4HI (match_operand:V4HI 1 "register_operand" "0")
19013                  (match_operand:V4HI 2 "nonimmediate_operand" "ym")))]
19014   "TARGET_MMX"
19015   "pcmpgtw\t{%2, %0|%0, %2}"
19016   [(set_attr "type" "mmx")])
19017
19018 (define_insn "gtv2si3"
19019   [(set (match_operand:V2SI 0 "register_operand" "=y")
19020         (gt:V2SI (match_operand:V2SI 1 "register_operand" "0")
19021                  (match_operand:V2SI 2 "nonimmediate_operand" "ym")))]
19022   "TARGET_MMX"
19023   "pcmpgtd\t{%2, %0|%0, %2}"
19024   [(set_attr "type" "mmx")])
19025
19026
19027 ;; MMX max/min insns
19028
19029 (define_insn "umaxv8qi3"
19030   [(set (match_operand:V8QI 0 "register_operand" "=y")
19031         (umax:V8QI (match_operand:V8QI 1 "register_operand" "0")
19032                    (match_operand:V8QI 2 "nonimmediate_operand" "ym")))]
19033   "TARGET_SSE || TARGET_3DNOW_A"
19034   "pmaxub\t{%2, %0|%0, %2}"
19035   [(set_attr "type" "sse")])
19036
19037 (define_insn "smaxv4hi3"
19038   [(set (match_operand:V4HI 0 "register_operand" "=y")
19039         (smax:V4HI (match_operand:V4HI 1 "register_operand" "0")
19040                    (match_operand:V4HI 2 "nonimmediate_operand" "ym")))]
19041   "TARGET_SSE || TARGET_3DNOW_A"
19042   "pmaxsw\t{%2, %0|%0, %2}"
19043   [(set_attr "type" "sse")])
19044
19045 (define_insn "uminv8qi3"
19046   [(set (match_operand:V8QI 0 "register_operand" "=y")
19047         (umin:V8QI (match_operand:V8QI 1 "register_operand" "0")
19048                    (match_operand:V8QI 2 "nonimmediate_operand" "ym")))]
19049   "TARGET_SSE || TARGET_3DNOW_A"
19050   "pminub\t{%2, %0|%0, %2}"
19051   [(set_attr "type" "sse")])
19052
19053 (define_insn "sminv4hi3"
19054   [(set (match_operand:V4HI 0 "register_operand" "=y")
19055         (smin:V4HI (match_operand:V4HI 1 "register_operand" "0")
19056                    (match_operand:V4HI 2 "nonimmediate_operand" "ym")))]
19057   "TARGET_SSE || TARGET_3DNOW_A"
19058   "pminsw\t{%2, %0|%0, %2}"
19059   [(set_attr "type" "sse")])
19060
19061
19062 ;; MMX shifts
19063
19064 (define_insn "ashrv4hi3"
19065   [(set (match_operand:V4HI 0 "register_operand" "=y")
19066         (ashiftrt:V4HI (match_operand:V4HI 1 "register_operand" "0")
19067                        (match_operand:DI 2 "nonmemory_operand" "yi")))]
19068   "TARGET_MMX"
19069   "psraw\t{%2, %0|%0, %2}"
19070   [(set_attr "type" "mmx")])
19071
19072 (define_insn "ashrv2si3"
19073   [(set (match_operand:V2SI 0 "register_operand" "=y")
19074         (ashiftrt:V2SI (match_operand:V2SI 1 "register_operand" "0")
19075                        (match_operand:DI 2 "nonmemory_operand" "yi")))]
19076   "TARGET_MMX"
19077   "psrad\t{%2, %0|%0, %2}"
19078   [(set_attr "type" "mmx")])
19079
19080 (define_insn "lshrv4hi3"
19081   [(set (match_operand:V4HI 0 "register_operand" "=y")
19082         (lshiftrt:V4HI (match_operand:V4HI 1 "register_operand" "0")
19083                        (match_operand:DI 2 "nonmemory_operand" "yi")))]
19084   "TARGET_MMX"
19085   "psrlw\t{%2, %0|%0, %2}"
19086   [(set_attr "type" "mmx")])
19087
19088 (define_insn "lshrv2si3"
19089   [(set (match_operand:V2SI 0 "register_operand" "=y")
19090         (lshiftrt:V2SI (match_operand:V2SI 1 "register_operand" "0")
19091                        (match_operand:DI 2 "nonmemory_operand" "yi")))]
19092   "TARGET_MMX"
19093   "psrld\t{%2, %0|%0, %2}"
19094   [(set_attr "type" "mmx")])
19095
19096 ;; See logical MMX insns.
19097 (define_insn "mmx_lshrdi3"
19098   [(set (match_operand:DI 0 "register_operand" "=y")
19099         (unspec:DI
19100           [(lshiftrt:DI (match_operand:DI 1 "register_operand" "0")
19101                        (match_operand:DI 2 "nonmemory_operand" "yi"))] 45))]
19102   "TARGET_MMX"
19103   "psrlq\t{%2, %0|%0, %2}"
19104   [(set_attr "type" "mmx")])
19105
19106 (define_insn "ashlv4hi3"
19107   [(set (match_operand:V4HI 0 "register_operand" "=y")
19108         (ashift:V4HI (match_operand:V4HI 1 "register_operand" "0")
19109                        (match_operand:DI 2 "nonmemory_operand" "yi")))]
19110   "TARGET_MMX"
19111   "psllw\t{%2, %0|%0, %2}"
19112   [(set_attr "type" "mmx")])
19113
19114 (define_insn "ashlv2si3"
19115   [(set (match_operand:V2SI 0 "register_operand" "=y")
19116         (ashift:V2SI (match_operand:V2SI 1 "register_operand" "0")
19117                        (match_operand:DI 2 "nonmemory_operand" "yi")))]
19118   "TARGET_MMX"
19119   "pslld\t{%2, %0|%0, %2}"
19120   [(set_attr "type" "mmx")])
19121
19122 ;; See logical MMX insns.
19123 (define_insn "mmx_ashldi3"
19124   [(set (match_operand:DI 0 "register_operand" "=y")
19125         (unspec:DI
19126          [(ashift:DI (match_operand:DI 1 "register_operand" "0")
19127                      (match_operand:DI 2 "nonmemory_operand" "yi"))] 45))]
19128   "TARGET_MMX"
19129   "psllq\t{%2, %0|%0, %2}"
19130   [(set_attr "type" "mmx")])
19131
19132
19133 ;; MMX pack/unpack insns.
19134
19135 (define_insn "mmx_packsswb"
19136   [(set (match_operand:V8QI 0 "register_operand" "=y")
19137         (vec_concat:V8QI
19138          (ss_truncate:V4QI (match_operand:V4HI 1 "register_operand" "0"))
19139          (ss_truncate:V4QI (match_operand:V4HI 2 "register_operand" "y"))))]
19140   "TARGET_MMX"
19141   "packsswb\t{%2, %0|%0, %2}"
19142   [(set_attr "type" "mmx")])
19143
19144 (define_insn "mmx_packssdw"
19145   [(set (match_operand:V4HI 0 "register_operand" "=y")
19146         (vec_concat:V4HI
19147          (ss_truncate:V2HI (match_operand:V2SI 1 "register_operand" "0"))
19148          (ss_truncate:V2HI (match_operand:V2SI 2 "register_operand" "y"))))]
19149   "TARGET_MMX"
19150   "packssdw\t{%2, %0|%0, %2}"
19151   [(set_attr "type" "mmx")])
19152
19153 (define_insn "mmx_packuswb"
19154   [(set (match_operand:V8QI 0 "register_operand" "=y")
19155         (vec_concat:V8QI
19156          (us_truncate:V4QI (match_operand:V4HI 1 "register_operand" "0"))
19157          (us_truncate:V4QI (match_operand:V4HI 2 "register_operand" "y"))))]
19158   "TARGET_MMX"
19159   "packuswb\t{%2, %0|%0, %2}"
19160   [(set_attr "type" "mmx")])
19161
19162 (define_insn "mmx_punpckhbw"
19163   [(set (match_operand:V8QI 0 "register_operand" "=y")
19164         (vec_merge:V8QI
19165          (vec_select:V8QI (match_operand:V8QI 1 "register_operand" "0")
19166                           (parallel [(const_int 4)
19167                                      (const_int 0)
19168                                      (const_int 5)
19169                                      (const_int 1)
19170                                      (const_int 6)
19171                                      (const_int 2)
19172                                      (const_int 7)
19173                                      (const_int 3)]))
19174          (vec_select:V8QI (match_operand:V8QI 2 "register_operand" "y")
19175                           (parallel [(const_int 0)
19176                                      (const_int 4)
19177                                      (const_int 1)
19178                                      (const_int 5)
19179                                      (const_int 2)
19180                                      (const_int 6)
19181                                      (const_int 3)
19182                                      (const_int 7)]))
19183          (const_int 85)))]
19184   "TARGET_MMX"
19185   "punpckhbw\t{%2, %0|%0, %2}"
19186   [(set_attr "type" "mmx")])
19187
19188 (define_insn "mmx_punpckhwd"
19189   [(set (match_operand:V4HI 0 "register_operand" "=y")
19190         (vec_merge:V4HI
19191          (vec_select:V4HI (match_operand:V4HI 1 "register_operand" "0")
19192                           (parallel [(const_int 0)
19193                                      (const_int 2)
19194                                      (const_int 1)
19195                                      (const_int 3)]))
19196          (vec_select:V4HI (match_operand:V4HI 2 "register_operand" "y")
19197                           (parallel [(const_int 2)
19198                                      (const_int 0)
19199                                      (const_int 3)
19200                                      (const_int 1)]))
19201          (const_int 5)))]
19202   "TARGET_MMX"
19203   "punpckhwd\t{%2, %0|%0, %2}"
19204   [(set_attr "type" "mmx")])
19205
19206 (define_insn "mmx_punpckhdq"
19207   [(set (match_operand:V2SI 0 "register_operand" "=y")
19208         (vec_merge:V2SI
19209          (vec_select:V2SI (match_operand:V2SI 1 "register_operand" "0")
19210                           (parallel [(const_int 0)
19211                                      (const_int 1)]))
19212          (vec_select:V2SI (match_operand:V2SI 2 "register_operand" "y")
19213                           (parallel [(const_int 1)
19214                                      (const_int 0)]))
19215          (const_int 1)))]
19216   "TARGET_MMX"
19217   "punpckhdq\t{%2, %0|%0, %2}"
19218   [(set_attr "type" "mmx")])
19219
19220 (define_insn "mmx_punpcklbw"
19221   [(set (match_operand:V8QI 0 "register_operand" "=y")
19222         (vec_merge:V8QI
19223          (vec_select:V8QI (match_operand:V8QI 1 "register_operand" "0")
19224                           (parallel [(const_int 0)
19225                                      (const_int 4)
19226                                      (const_int 1)
19227                                      (const_int 5)
19228                                      (const_int 2)
19229                                      (const_int 6)
19230                                      (const_int 3)
19231                                      (const_int 7)]))
19232          (vec_select:V8QI (match_operand:V8QI 2 "register_operand" "y")
19233                           (parallel [(const_int 4)
19234                                      (const_int 0)
19235                                      (const_int 5)
19236                                      (const_int 1)
19237                                      (const_int 6)
19238                                      (const_int 2)
19239                                      (const_int 7)
19240                                      (const_int 3)]))
19241          (const_int 85)))]
19242   "TARGET_MMX"
19243   "punpcklbw\t{%2, %0|%0, %2}"
19244   [(set_attr "type" "mmx")])
19245
19246 (define_insn "mmx_punpcklwd"
19247   [(set (match_operand:V4HI 0 "register_operand" "=y")
19248         (vec_merge:V4HI
19249          (vec_select:V4HI (match_operand:V4HI 1 "register_operand" "0")
19250                           (parallel [(const_int 2)
19251                                      (const_int 0)
19252                                      (const_int 3)
19253                                      (const_int 1)]))
19254          (vec_select:V4HI (match_operand:V4HI 2 "register_operand" "y")
19255                           (parallel [(const_int 0)
19256                                      (const_int 2)
19257                                      (const_int 1)
19258                                      (const_int 3)]))
19259          (const_int 5)))]
19260   "TARGET_MMX"
19261   "punpcklwd\t{%2, %0|%0, %2}"
19262   [(set_attr "type" "mmx")])
19263
19264 (define_insn "mmx_punpckldq"
19265   [(set (match_operand:V2SI 0 "register_operand" "=y")
19266         (vec_merge:V2SI
19267          (vec_select:V2SI (match_operand:V2SI 1 "register_operand" "0")
19268                            (parallel [(const_int 1)
19269                                       (const_int 0)]))
19270          (vec_select:V2SI (match_operand:V2SI 2 "register_operand" "y")
19271                           (parallel [(const_int 0)
19272                                      (const_int 1)]))
19273          (const_int 1)))]
19274   "TARGET_MMX"
19275   "punpckldq\t{%2, %0|%0, %2}"
19276   [(set_attr "type" "mmx")])
19277
19278
19279 ;; Miscellaneous stuff
19280
19281 (define_insn "emms"
19282   [(unspec_volatile [(const_int 0)] 31)
19283    (clobber (reg:XF 8))
19284    (clobber (reg:XF 9))
19285    (clobber (reg:XF 10))
19286    (clobber (reg:XF 11))
19287    (clobber (reg:XF 12))
19288    (clobber (reg:XF 13))
19289    (clobber (reg:XF 14))
19290    (clobber (reg:XF 15))
19291    (clobber (reg:DI 29))
19292    (clobber (reg:DI 30))
19293    (clobber (reg:DI 31))
19294    (clobber (reg:DI 32))
19295    (clobber (reg:DI 33))
19296    (clobber (reg:DI 34))
19297    (clobber (reg:DI 35))
19298    (clobber (reg:DI 36))]
19299   "TARGET_MMX"
19300   "emms"
19301   [(set_attr "type" "mmx")
19302    (set_attr "memory" "unknown")])
19303
19304 (define_insn "ldmxcsr"
19305   [(unspec_volatile [(match_operand:SI 0 "memory_operand" "m")] 37)]
19306   "TARGET_MMX"
19307   "ldmxcsr\t%0"
19308   [(set_attr "type" "mmx")
19309    (set_attr "memory" "load")])
19310
19311 (define_insn "stmxcsr"
19312   [(set (match_operand:SI 0 "memory_operand" "=m")
19313         (unspec_volatile:SI [(const_int 0)] 40))]
19314   "TARGET_MMX"
19315   "stmxcsr\t%0"
19316   [(set_attr "type" "mmx")
19317    (set_attr "memory" "store")])
19318
19319 (define_expand "sfence"
19320   [(set (match_dup 0)
19321         (unspec:BLK [(match_dup 0)] 44))]
19322   "TARGET_SSE || TARGET_3DNOW_A"
19323 {
19324   operands[0] = gen_rtx_MEM (BLKmode, gen_rtx_SCRATCH (Pmode));
19325   MEM_VOLATILE_P (operands[0]) = 1;
19326 })
19327
19328 (define_insn "*sfence_insn"
19329   [(set (match_operand:BLK 0 "" "")
19330         (unspec:BLK [(match_dup 0)] 44))]
19331   "TARGET_SSE || TARGET_3DNOW_A"
19332   "sfence"
19333   [(set_attr "type" "sse")
19334    (set_attr "memory" "unknown")])
19335
19336 (define_insn "prefetch"
19337   [(unspec [(match_operand:SI 0 "address_operand" "p")
19338             (match_operand:SI 1 "immediate_operand" "n")] 35)]
19339   "TARGET_SSE || TARGET_3DNOW_A"
19340 {
19341   switch (INTVAL (operands[1]))
19342     {
19343     case 0:
19344       return "prefetchnta\t%a0";
19345     case 1:
19346       return "prefetcht0\t%a0";
19347     case 2:
19348       return "prefetcht1\t%a0";
19349     case 3:
19350       return "prefetcht2\t%a0";
19351     default:
19352       abort ();
19353     }
19354 }
19355   [(set_attr "type" "sse")])
19356
19357 (define_expand "sse_prologue_save"
19358   [(parallel [(set (match_operand:BLK 0 "" "")
19359                    (unspec:BLK [(reg:DI 21)
19360                                 (reg:DI 22)
19361                                 (reg:DI 23)
19362                                 (reg:DI 24)
19363                                 (reg:DI 25)
19364                                 (reg:DI 26)
19365                                 (reg:DI 27)
19366                                 (reg:DI 28)] 13))
19367               (use (match_operand:DI 1 "register_operand" ""))
19368               (use (match_operand:DI 2 "immediate_operand" ""))
19369               (use (label_ref:DI (match_operand 3 "" "")))])]
19370   "TARGET_64BIT"
19371   "")
19372
19373 (define_insn "*sse_prologue_save_insn"
19374   [(set (mem:BLK (plus:DI (match_operand:DI 0 "register_operand" "R")
19375                           (match_operand:DI 4 "const_int_operand" "n")))
19376         (unspec:BLK [(reg:DI 21)
19377                      (reg:DI 22)
19378                      (reg:DI 23)
19379                      (reg:DI 24)
19380                      (reg:DI 25)
19381                      (reg:DI 26)
19382                      (reg:DI 27)
19383                      (reg:DI 28)] 13))
19384    (use (match_operand:DI 1 "register_operand" "r"))
19385    (use (match_operand:DI 2 "const_int_operand" "i"))
19386    (use (label_ref:DI (match_operand 3 "" "X")))]
19387   "TARGET_64BIT
19388    && INTVAL (operands[4]) + SSE_REGPARM_MAX * 16 - 16 < 128
19389    && INTVAL (operands[4]) + INTVAL (operands[2]) * 16 >= -128"
19390   "*
19391 {
19392   int i;
19393   operands[0] = gen_rtx_MEM (Pmode,
19394                              gen_rtx_PLUS (Pmode, operands[0], operands[4]));
19395   output_asm_insn (\"jmp\\t%A1\", operands);
19396   for (i = SSE_REGPARM_MAX - 1; i >= INTVAL (operands[2]); i--)
19397     {
19398       operands[4] = adjust_address (operands[0], DImode, i*16);
19399       operands[5] = gen_rtx_REG (TImode, SSE_REGNO (i));
19400       PUT_MODE (operands[4], TImode);
19401       if (GET_CODE (XEXP (operands[0], 0)) != PLUS)
19402         output_asm_insn (\"rex\", operands);
19403       output_asm_insn (\"movaps\\t{%5, %4|%4, %5}\", operands);
19404     }
19405   ASM_OUTPUT_INTERNAL_LABEL (asm_out_file, \"L\",
19406                              CODE_LABEL_NUMBER (operands[3]));
19407   RET;
19408 }
19409   "
19410   [(set_attr "type" "other")
19411    (set_attr "length_immediate" "0")
19412    (set_attr "length_address" "0")
19413    (set_attr "length" "135")
19414    (set_attr "memory" "store")
19415    (set_attr "modrm" "0")
19416    (set_attr "mode" "DI")])
19417
19418 ;; 3Dnow! instructions
19419
19420 (define_insn "addv2sf3"
19421   [(set (match_operand:V2SF 0 "register_operand" "=y")
19422         (plus:V2SF (match_operand:V2SF 1 "register_operand" "0")
19423                    (match_operand:V2SF 2 "nonimmediate_operand" "ym")))]
19424   "TARGET_3DNOW"
19425   "pfadd\\t{%2, %0|%0, %2}"
19426   [(set_attr "type" "mmx")])
19427
19428 (define_insn "subv2sf3"
19429   [(set (match_operand:V2SF 0 "register_operand" "=y")
19430         (minus:V2SF (match_operand:V2SF 1 "register_operand" "0")
19431                     (match_operand:V2SF 2 "nonimmediate_operand" "ym")))]
19432   "TARGET_3DNOW"
19433   "pfsub\\t{%2, %0|%0, %2}"
19434   [(set_attr "type" "mmx")])
19435
19436 (define_insn "subrv2sf3"
19437   [(set (match_operand:V2SF 0 "register_operand" "=y")
19438         (minus:V2SF (match_operand:V2SF 2 "nonimmediate_operand" "ym")
19439                     (match_operand:V2SF 1 "register_operand" "0")))]
19440   "TARGET_3DNOW"
19441   "pfsubr\\t{%2, %0|%0, %2}"
19442   [(set_attr "type" "mmx")])
19443
19444 (define_insn "gtv2sf3"
19445   [(set (match_operand:V2SI 0 "register_operand" "=y")
19446         (gt:V2SI (match_operand:V2SF 1 "register_operand" "0")
19447                  (match_operand:V2SF 2 "nonimmediate_operand" "ym")))]
19448  "TARGET_3DNOW"
19449   "pfcmpgt\\t{%2, %0|%0, %2}"
19450   [(set_attr "type" "mmx")])
19451
19452 (define_insn "gev2sf3"
19453   [(set (match_operand:V2SI 0 "register_operand" "=y")
19454         (ge:V2SI (match_operand:V2SF 1 "register_operand" "0")
19455                  (match_operand:V2SF 2 "nonimmediate_operand" "ym")))]
19456   "TARGET_3DNOW"
19457   "pfcmpge\\t{%2, %0|%0, %2}"
19458   [(set_attr "type" "mmx")])
19459
19460 (define_insn "eqv2sf3"
19461   [(set (match_operand:V2SI 0 "register_operand" "=y")
19462         (eq:V2SI (match_operand:V2SF 1 "register_operand" "0")
19463                  (match_operand:V2SF 2 "nonimmediate_operand" "ym")))]
19464   "TARGET_3DNOW"
19465   "pfcmpeq\\t{%2, %0|%0, %2}"
19466   [(set_attr "type" "mmx")])
19467
19468 (define_insn "pfmaxv2sf3"
19469   [(set (match_operand:V2SF 0 "register_operand" "=y")
19470         (smax:V2SF (match_operand:V2SF 1 "register_operand" "0")
19471                    (match_operand:V2SF 2 "nonimmediate_operand" "ym")))]
19472   "TARGET_3DNOW"
19473   "pfmax\\t{%2, %0|%0, %2}"
19474   [(set_attr "type" "mmx")])
19475
19476 (define_insn "pfminv2sf3"
19477   [(set (match_operand:V2SF 0 "register_operand" "=y")
19478         (smin:V2SF (match_operand:V2SF 1 "register_operand" "0")
19479                    (match_operand:V2SF 2 "nonimmediate_operand" "ym")))]
19480   "TARGET_3DNOW"
19481   "pfmin\\t{%2, %0|%0, %2}"
19482   [(set_attr "type" "mmx")])
19483
19484 (define_insn "mulv2sf3"
19485   [(set (match_operand:V2SF 0 "register_operand" "=y")
19486         (mult:V2SF (match_operand:V2SF 1 "register_operand" "0")
19487                    (match_operand:V2SF 2 "nonimmediate_operand" "ym")))]
19488   "TARGET_3DNOW"
19489   "pfmul\\t{%2, %0|%0, %2}"
19490   [(set_attr "type" "mmx")])
19491
19492 (define_insn "femms"
19493   [(unspec_volatile [(const_int 0)] 46)
19494    (clobber (reg:XF 8))
19495    (clobber (reg:XF 9))
19496    (clobber (reg:XF 10))
19497    (clobber (reg:XF 11))
19498    (clobber (reg:XF 12))
19499    (clobber (reg:XF 13))
19500    (clobber (reg:XF 14))
19501    (clobber (reg:XF 15))
19502    (clobber (reg:DI 29))
19503    (clobber (reg:DI 30))
19504    (clobber (reg:DI 31))
19505    (clobber (reg:DI 32))
19506    (clobber (reg:DI 33))
19507    (clobber (reg:DI 34))
19508    (clobber (reg:DI 35))
19509    (clobber (reg:DI 36))]
19510   "TARGET_3DNOW"
19511   "femms"
19512   [(set_attr "type" "mmx")])
19513
19514 (define_insn "prefetch_3dnow"
19515   [(unspec [(match_operand:SI 0 "address_operand" "p")] 47)]
19516   "TARGET_3DNOW"
19517   "prefetch\\t%a0"
19518   [(set_attr "type" "mmx")])
19519
19520 (define_insn "prefetchw"
19521   [(unspec [(match_operand:SI 0 "address_operand" "p")] 48)]
19522   "TARGET_3DNOW"
19523   "prefetchw\\t%a0"
19524   [(set_attr "type" "mmx")])
19525
19526 (define_insn "pf2id"
19527   [(set (match_operand:V2SI 0 "register_operand" "=y")
19528         (fix:V2SI (match_operand:V2SF 1 "nonimmediate_operand" "ym")))]
19529   "TARGET_3DNOW"
19530   "pf2id\\t{%1, %0|%0, %1}"
19531   [(set_attr "type" "mmx")])
19532
19533 (define_insn "pf2iw"
19534   [(set (match_operand:V2SI 0 "register_operand" "=y")
19535         (sign_extend:V2SI
19536            (ss_truncate:V2HI
19537               (fix:V2SI (match_operand:V2SF 1 "nonimmediate_operand" "ym")))))]
19538   "TARGET_3DNOW_A"
19539   "pf2iw\\t{%1, %0|%0, %1}"
19540   [(set_attr "type" "mmx")])
19541
19542 (define_insn "pfacc"
19543   [(set (match_operand:V2SF 0 "register_operand" "=y")
19544         (vec_concat:V2SF
19545            (plus:SF
19546               (vec_select:SF (match_operand:V2SF 1 "register_operand" "0")
19547                              (parallel [(const_int  0)]))
19548               (vec_select:SF (match_dup 1)
19549                              (parallel [(const_int 1)])))
19550            (plus:SF
19551               (vec_select:SF (match_operand:V2SF 2 "nonimmediate_operand" "y")
19552                              (parallel [(const_int  0)]))
19553               (vec_select:SF (match_dup 2)
19554                              (parallel [(const_int 1)])))))]
19555   "TARGET_3DNOW"
19556   "pfacc\\t{%2, %0|%0, %2}"
19557   [(set_attr "type" "mmx")])
19558
19559 (define_insn "pfnacc"
19560   [(set (match_operand:V2SF 0 "register_operand" "=y")
19561         (vec_concat:V2SF
19562            (minus:SF
19563               (vec_select:SF (match_operand:V2SF 1 "register_operand" "0")
19564                              (parallel [(const_int 0)]))
19565               (vec_select:SF (match_dup 1)
19566                              (parallel [(const_int 1)])))
19567            (minus:SF
19568               (vec_select:SF (match_operand:V2SF 2 "nonimmediate_operand" "y")
19569                              (parallel [(const_int  0)]))
19570               (vec_select:SF (match_dup 2)
19571                              (parallel [(const_int 1)])))))]
19572   "TARGET_3DNOW_A"
19573   "pfnacc\\t{%2, %0|%0, %2}"
19574   [(set_attr "type" "mmx")])
19575
19576 (define_insn "pfpnacc"
19577   [(set (match_operand:V2SF 0 "register_operand" "=y")
19578         (vec_concat:V2SF
19579            (minus:SF
19580               (vec_select:SF (match_operand:V2SF 1 "register_operand" "0")
19581                              (parallel [(const_int 0)]))
19582               (vec_select:SF (match_dup 1)
19583                              (parallel [(const_int 1)])))
19584            (plus:SF
19585               (vec_select:SF (match_operand:V2SF 2 "nonimmediate_operand" "y")
19586                              (parallel [(const_int 0)]))
19587               (vec_select:SF (match_dup 2)
19588                              (parallel [(const_int 1)])))))]
19589   "TARGET_3DNOW_A"
19590   "pfpnacc\\t{%2, %0|%0, %2}"
19591   [(set_attr "type" "mmx")])
19592
19593 (define_insn "pi2fw"
19594   [(set (match_operand:V2SF 0 "register_operand" "=y")
19595         (float:V2SF
19596            (vec_concat:V2SI
19597               (sign_extend:SI
19598                  (truncate:HI
19599                     (vec_select:SI (match_operand:V2SI 1 "nonimmediate_operand" "ym")
19600                                    (parallel [(const_int 0)]))))
19601               (sign_extend:SI
19602                  (truncate:HI
19603                     (vec_select:SI (match_dup 1)
19604                                    (parallel [(const_int  1)])))))))]
19605   "TARGET_3DNOW_A"
19606   "pi2fw\\t{%1, %0|%0, %1}"
19607   [(set_attr "type" "mmx")])
19608
19609 (define_insn "floatv2si2"
19610   [(set (match_operand:V2SF 0 "register_operand" "=y")
19611         (float:V2SF (match_operand:V2SI 1 "nonimmediate_operand" "ym")))]
19612   "TARGET_3DNOW"
19613   "pi2fd\\t{%1, %0|%0, %1}"
19614   [(set_attr "type" "mmx")])
19615
19616 ;; This insn is identical to pavgb in operation, but the opcode is
19617 ;; different.  To avoid accidentally matching pavgb, use an unspec.
19618
19619 (define_insn "pavgusb"
19620  [(set (match_operand:V8QI 0 "register_operand" "=y")
19621        (unspec:V8QI
19622           [(match_operand:V8QI 1 "register_operand" "0")
19623            (match_operand:V8QI 2 "nonimmediate_operand" "ym")] 49))]
19624   "TARGET_3DNOW"
19625   "pavgusb\\t{%2, %0|%0, %2}"
19626   [(set_attr "type" "mmx")])
19627
19628 ;; 3DNow reciprical and sqrt
19629  
19630 (define_insn "pfrcpv2sf2"
19631   [(set (match_operand:V2SF 0 "register_operand" "=y")
19632         (unspec:V2SF [(match_operand:V2SF 1 "nonimmediate_operand" "ym")] 50))]
19633   "TARGET_3DNOW"
19634   "pfrcp\\t{%1, %0|%0, %1}"
19635   [(set_attr "type" "mmx")])
19636
19637 (define_insn "pfrcpit1v2sf3"
19638   [(set (match_operand:V2SF 0 "register_operand" "=y")
19639         (unspec:V2SF [(match_operand:V2SF 1 "register_operand" "0")
19640                       (match_operand:V2SF 2 "nonimmediate_operand" "ym")] 51))]
19641   "TARGET_3DNOW"
19642   "pfrcpit1\\t{%2, %0|%0, %2}"
19643   [(set_attr "type" "mmx")])
19644
19645 (define_insn "pfrcpit2v2sf3"
19646   [(set (match_operand:V2SF 0 "register_operand" "=y")
19647         (unspec:V2SF [(match_operand:V2SF 1 "register_operand" "0")
19648                       (match_operand:V2SF 2 "nonimmediate_operand" "ym")] 52))]
19649   "TARGET_3DNOW"
19650   "pfrcpit2\\t{%2, %0|%0, %2}"
19651   [(set_attr "type" "mmx")])
19652
19653 (define_insn "pfrsqrtv2sf2"
19654   [(set (match_operand:V2SF 0 "register_operand" "=y")
19655         (unspec:V2SF [(match_operand:V2SF 1 "nonimmediate_operand" "ym")] 53))]
19656   "TARGET_3DNOW"
19657    "pfrsqrt\\t{%1, %0|%0, %1}"
19658    [(set_attr "type" "mmx")])
19659                 
19660 (define_insn "pfrsqit1v2sf3"
19661   [(set (match_operand:V2SF 0 "register_operand" "=y")
19662         (unspec:V2SF [(match_operand:V2SF 1 "register_operand" "0")
19663                       (match_operand:V2SF 2 "nonimmediate_operand" "ym")] 54))]
19664   "TARGET_3DNOW"
19665   "pfrsqit1\\t{%2, %0|%0, %2}"
19666   [(set_attr "type" "mmx")])
19667
19668 (define_insn "pmulhrwv4hi3"
19669   [(set (match_operand:V4HI 0 "register_operand" "=y")
19670         (truncate:V4HI
19671            (lshiftrt:V4SI
19672               (plus:V4SI
19673                  (mult:V4SI
19674                     (sign_extend:V4SI
19675                        (match_operand:V4HI 1 "register_operand" "0"))
19676                     (sign_extend:V4SI
19677                        (match_operand:V4HI 2 "nonimmediate_operand" "ym")))
19678               (vec_const:V4SI
19679                  (parallel [(const_int 32768)
19680                             (const_int 32768)
19681                             (const_int 32768)
19682                             (const_int 32768)])))
19683            (const_int 16))))]
19684   "TARGET_3DNOW"
19685   "pmulhrw\\t{%2, %0|%0, %2}"
19686   [(set_attr "type" "mmx")])
19687
19688 (define_insn "pswapdv2si2"
19689   [(set (match_operand:V2SI 0 "register_operand" "=y")
19690         (vec_select:V2SI (match_operand:V2SI 1 "nonimmediate_operand" "ym")
19691                          (parallel [(const_int 1) (const_int 0)])))]
19692   "TARGET_3DNOW_A"
19693   "pswapd\\t{%1, %0|%0, %1}"
19694   [(set_attr "type" "mmx")])
19695
19696 (define_insn "pswapdv2sf2"
19697   [(set (match_operand:V2SF 0 "register_operand" "=y")
19698         (vec_select:V2SF (match_operand:V2SF 1 "nonimmediate_operand" "ym")
19699                          (parallel [(const_int 1) (const_int 0)])))]
19700   "TARGET_3DNOW_A"
19701   "pswapd\\t{%1, %0|%0, %1}"
19702   [(set_attr "type" "mmx")])