OSDN Git Service

* print-rtl.c (print_rtx): Cast enums to int for comparison.
[pf3gnuchains/gcc-fork.git] / gcc / config / i386 / i386.md
1 ;; GCC machine description for IA-32.
2 ;; Copyright (C) 1988, 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001
3 ;; Free Software Foundation, Inc.
4 ;; Mostly by William Schelter.
5 ;;
6 ;; This file is part of GNU CC.
7 ;;
8 ;; GNU CC is free software; you can redistribute it and/or modify
9 ;; it under the terms of the GNU General Public License as published by
10 ;; the Free Software Foundation; either version 2, or (at your option)
11 ;; any later version.
12 ;;
13 ;; GNU CC is distributed in the hope that it will be useful,
14 ;; but WITHOUT ANY WARRANTY; without even the implied warranty of
15 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
16 ;; GNU General Public License for more details.
17 ;;
18 ;; You should have received a copy of the GNU General Public License
19 ;; along with GNU CC; see the file COPYING.  If not, write to
20 ;; the Free Software Foundation, 59 Temple Place - Suite 330,
21 ;; Boston, MA 02111-1307, USA. */
22 ;;
23 ;; The original PO technology requires these to be ordered by speed,
24 ;; so that assigner will pick the fastest.
25 ;;
26 ;; See file "rtl.def" for documentation on define_insn, match_*, et. al.
27 ;;
28 ;; Macro #define NOTICE_UPDATE_CC in file i386.h handles condition code
29 ;; updates for most instructions.
30 ;;
31 ;; Macro REG_CLASS_FROM_LETTER in file i386.h defines the register
32 ;; constraint letters.
33 ;;
34 ;; The special asm out single letter directives following a '%' are:
35 ;; 'z' mov%z1 would be movl, movw, or movb depending on the mode of
36 ;;     operands[1].
37 ;; 'L' Print the opcode suffix for a 32-bit integer opcode.
38 ;; 'W' Print the opcode suffix for a 16-bit integer opcode.
39 ;; 'B' Print the opcode suffix for an 8-bit integer opcode.
40 ;; 'Q' Print the opcode suffix for a 64-bit float opcode.
41 ;; 'S' Print the opcode suffix for a 32-bit float opcode.
42 ;; 'T' Print the opcode suffix for an 80-bit extended real XFmode float opcode.
43 ;; 'J' Print the appropriate jump operand.
44 ;;
45 ;; 'b' Print the QImode name of the register for the indicated operand.
46 ;;     %b0 would print %al if operands[0] is reg 0.
47 ;; 'w' Likewise, print the HImode name of the register.
48 ;; 'k' Likewise, print the SImode name of the register.
49 ;; 'h' Print the QImode name for a "high" register, either ah, bh, ch or dh.
50 ;; 'y' Print "st(0)" instead of "st" as a register.
51 ;;
52 ;; UNSPEC usage:
53 ;; 0  This is a `scas' operation.  The mode of the UNSPEC is always SImode.
54 ;;    operand 0 is the memory address to scan.
55 ;;    operand 1 is a register containing the value to scan for.  The mode
56 ;;       of the scas opcode will be the same as the mode of this operand.
57 ;;    operand 2 is the known alignment of operand 0.
58 ;; 1  This is a `sin' operation.  The mode of the UNSPEC is MODE_FLOAT.
59 ;;    operand 0 is the argument for `sin'.
60 ;; 2  This is a `cos' operation.  The mode of the UNSPEC is MODE_FLOAT.
61 ;;    operand 0 is the argument for `cos'.
62 ;; 3  This is part of a `stack probe' operation.  The mode of the UNSPEC is 
63 ;;    always SImode.  operand 0 is the size of the stack allocation.
64 ;; 4  This is the source of a fake SET of the frame pointer which is used to
65 ;;    prevent insns referencing it being scheduled across the initial
66 ;;    decrement of the stack pointer.
67 ;; 5  This is a `bsf' operation.
68 ;; 6  This is the @GOT offset of a PIC address.
69 ;; 7  This is the @GOTOFF offset of a PIC address.
70 ;; 8  This is a reference to a symbol's @PLT address.
71 ;; 9  This is an `fnstsw' operation.
72 ;; 10 This is a `sahf' operation.
73 ;; 11 This is a `fstcw' operation
74 ;; 12 This is behaviour of add when setting carry flag.
75
76 ;; For SSE/MMX support:
77 ;; 30 This is `fix', guaranteed to be truncating.
78 ;; 31 This is a `emms' operation.
79 ;; 32 This is a `maskmov' operation.
80 ;; 33 This is a `movmsk' operation.
81 ;; 34 This is a `non-temporal' move.
82 ;; 35 This is a `prefetch' operation.
83 ;; 36 This is used to distinguish COMISS from UCOMISS.
84 ;; 37 This is a `ldmxcsr' operation.
85 ;; 38 This is a forced `movaps' instruction (rather than whatever movti does)
86 ;; 39 This is a forced `movups' instruction (rather than whatever movti does)
87 ;; 40 This is a `stmxcsr' operation.
88 ;; 41 This is a `shuffle' operation.
89 ;; 42 This is a `rcp' operation.
90 ;; 43 This is a `rsqsrt' operation.
91 ;; 44 This is a `sfence' operation.
92 ;; 45 This is a noop to prevent excessive combiner cleverness.
93
94 ;; Insns whose names begin with "x86_" are emitted by gen_FOO calls
95 ;; from i386.c.
96
97 \f
98 ;; Processor type.  This attribute must exactly match the processor_type
99 ;; enumeration in i386.h.
100 (define_attr "cpu" "i386,i486,pentium,pentiumpro,k6,athlon,pentium4"
101   (const (symbol_ref "ix86_cpu")))
102
103 ;; A basic instruction type.  Refinements due to arguments to be
104 ;; provided in other attributes.
105 (define_attr "type"
106   "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"
107   (const_string "other"))
108
109 ;; Main data type used by the insn
110 (define_attr "mode" "unknown,none,QI,HI,SI,DI,unknownfp,SF,DF,XF,TI"
111   (const_string "unknown"))
112
113 ;; Set for i387 operations.
114 (define_attr "i387" ""
115   (if_then_else (eq_attr "type" "fmov,fop,fop1,fsgn,fmul,fdiv,fpspc,fcmov,fcmp,fxch")
116     (const_int 1)
117     (const_int 0)))
118
119 ;; The (bounding maximum) length of an instruction immediate.
120 (define_attr "length_immediate" ""
121   (cond [(eq_attr "type" "incdec,setcc,icmov,ibr,str,cld,lea,other,multi,idiv,sse,mmx")
122            (const_int 0)
123          (eq_attr "i387" "1")
124            (const_int 0)
125          (eq_attr "type" "alu1,negnot,alu,icmp,imovx,ishift,imul,push,pop")
126            (symbol_ref "ix86_attr_length_immediate_default(insn,1)")
127          (eq_attr "type" "imov,test")
128            (symbol_ref "ix86_attr_length_immediate_default(insn,0)")
129          (eq_attr "type" "call")
130            (if_then_else (match_operand 0 "constant_call_address_operand" "")
131              (const_int 4)
132              (const_int 0))
133          (eq_attr "type" "callv")
134            (if_then_else (match_operand 1 "constant_call_address_operand" "")
135              (const_int 4)
136              (const_int 0))
137          (eq_attr "type" "ibr")
138            (if_then_else (and (ge (minus (match_dup 0) (pc))
139                                   (const_int -128))
140                               (lt (minus (match_dup 0) (pc))
141                                   (const_int 124)))
142              (const_int 1)
143              (const_int 4))
144          ]
145          (symbol_ref "/* Update immediate_length and other attributes! */ abort(),1")))
146
147 ;; The (bounding maximum) length of an instruction address.
148 (define_attr "length_address" ""
149   (cond [(eq_attr "type" "str,cld,other,multi,fxch")
150            (const_int 0)
151          (and (eq_attr "type" "call")
152               (match_operand 1 "constant_call_address_operand" ""))
153              (const_int 0)
154          (and (eq_attr "type" "callv")
155               (match_operand 1 "constant_call_address_operand" ""))
156              (const_int 0)
157          ]
158          (symbol_ref "ix86_attr_length_address_default (insn)")))
159
160 ;; Set when length prefix is used.
161 (define_attr "prefix_data16" ""
162   (if_then_else (eq_attr "mode" "HI")
163     (const_int 1)
164     (const_int 0)))
165
166 ;; Set when string REP prefix is used.
167 (define_attr "prefix_rep" "" (const_int 0))
168
169 ;; Set when 0f opcode prefix is used.
170 (define_attr "prefix_0f" ""
171   (if_then_else (eq_attr "type" "imovx,setcc,icmov,sse,mmx")
172     (const_int 1)
173     (const_int 0)))
174
175 ;; Set when modrm byte is used.
176 (define_attr "modrm" ""
177   (cond [(eq_attr "type" "str,cld")
178            (const_int 0)
179          (eq_attr "i387" "1")
180            (const_int 0)
181          (and (eq_attr "type" "incdec")
182               (ior (match_operand:SI 1 "register_operand" "")
183                    (match_operand:HI 1 "register_operand" "")))
184            (const_int 0)
185          (and (eq_attr "type" "push")
186               (not (match_operand 1 "memory_operand" "")))
187            (const_int 0)
188          (and (eq_attr "type" "pop")
189               (not (match_operand 0 "memory_operand" "")))
190            (const_int 0)
191          (and (eq_attr "type" "imov")
192               (and (match_operand 0 "register_operand" "")
193                    (match_operand 1 "immediate_operand" "")))
194            (const_int 0)
195          ]
196          (const_int 1)))
197
198 ;; The (bounding maximum) length of an instruction in bytes.
199 (define_attr "length" ""
200   (cond [(eq_attr "type" "other,multi")
201            (const_int 16)
202          ]
203          (plus (plus (attr "modrm")
204                      (plus (attr "prefix_0f")
205                            (plus (attr "i387")
206                                  (const_int 1))))
207                (plus (attr "prefix_rep")
208                      (plus (attr "prefix_data16")
209                            (plus (attr "length_immediate")
210                                  (attr "length_address")))))))
211
212 ;; The `memory' attribute is `none' if no memory is referenced, `load' or
213 ;; `store' if there is a simple memory reference therein, or `unknown'
214 ;; if the instruction is complex.
215
216 (define_attr "memory" "none,load,store,both,unknown"
217   (cond [(eq_attr "type" "other,multi,str")
218            (const_string "unknown")
219          (eq_attr "type" "lea,fcmov,fpspc,cld")
220            (const_string "none")
221          (eq_attr "type" "push")
222            (if_then_else (match_operand 1 "memory_operand" "")
223              (const_string "both")
224              (const_string "store"))
225          (eq_attr "type" "pop,setcc")
226            (if_then_else (match_operand 0 "memory_operand" "")
227              (const_string "both")
228              (const_string "load"))
229          (eq_attr "type" "icmp,test")
230            (if_then_else (ior (match_operand 0 "memory_operand" "")
231                               (match_operand 1 "memory_operand" ""))
232              (const_string "load")
233              (const_string "none"))
234          (eq_attr "type" "ibr")
235            (if_then_else (match_operand 0 "memory_operand" "")
236              (const_string "load")
237              (const_string "none"))
238          (eq_attr "type" "call")
239            (if_then_else (match_operand 0 "constant_call_address_operand" "")
240              (const_string "none")
241              (const_string "load"))
242          (eq_attr "type" "callv")
243            (if_then_else (match_operand 1 "constant_call_address_operand" "")
244              (const_string "none")
245              (const_string "load"))
246          (and (eq_attr "type" "alu1,negnot")
247               (match_operand 1 "memory_operand" ""))
248            (const_string "both")
249          (and (match_operand 0 "memory_operand" "")
250               (match_operand 1 "memory_operand" ""))
251            (const_string "both")
252          (match_operand 0 "memory_operand" "")
253            (const_string "store")
254          (match_operand 1 "memory_operand" "")
255            (const_string "load")
256          (and (eq_attr "type" "!icmp,test,alu1,negnot,fop1,fsgn,imov,imovx,fmov,fcmp,sse,mmx")
257               (match_operand 2 "memory_operand" ""))
258            (const_string "load")
259          (and (eq_attr "type" "icmov")
260               (match_operand 3 "memory_operand" ""))
261            (const_string "load")
262         ]
263         (const_string "none")))
264
265 ;; Indicates if an instruction has both an immediate and a displacement.
266
267 (define_attr "imm_disp" "false,true,unknown"
268   (cond [(eq_attr "type" "other,multi")
269            (const_string "unknown")
270          (and (eq_attr "type" "icmp,test,imov")
271               (and (match_operand 0 "memory_displacement_operand" "")
272                    (match_operand 1 "immediate_operand" "")))
273            (const_string "true")
274          (and (eq_attr "type" "alu,ishift,imul,idiv")
275               (and (match_operand 0 "memory_displacement_operand" "")
276                    (match_operand 2 "immediate_operand" "")))
277            (const_string "true")
278         ]
279         (const_string "false")))
280
281 ;; Indicates if an FP operation has an integer source.
282
283 (define_attr "fp_int_src" "false,true"
284   (const_string "false"))
285
286 ;; Describe a user's asm statement.
287 (define_asm_attributes
288   [(set_attr "length" "128")
289    (set_attr "type" "multi")])
290 \f
291 ;; Pentium Scheduling
292 ;;
293 ;; The Pentium is an in-order core with two integer pipelines.
294
295 ;; True for insns that behave like prefixed insns on the Pentium.
296 (define_attr "pent_prefix" "false,true"
297   (if_then_else (ior (eq_attr "prefix_0f" "1")
298                      (ior (eq_attr "prefix_data16" "1")
299                           (eq_attr "prefix_rep" "1")))
300     (const_string "true")
301     (const_string "false")))
302
303 ;; Categorize how an instruction slots.
304
305 ;; The non-MMX Pentium slots an instruction with prefixes on U pipe only,
306 ;; while MMX Pentium can slot it on either U or V.  Model non-MMX Pentium
307 ;; rules, because it results in noticeably better code on non-MMX Pentium
308 ;; and doesn't hurt much on MMX.  (Prefixed instructions are not very
309 ;; common, so the scheduler usualy has a non-prefixed insn to pair).
310
311 (define_attr "pent_pair" "uv,pu,pv,np"
312   (cond [(eq_attr "imm_disp" "true")
313            (const_string "np")
314          (ior (eq_attr "type" "alu1,alu,imov,icmp,test,lea,incdec")
315               (and (eq_attr "type" "pop,push")
316                    (eq_attr "memory" "!both")))
317            (if_then_else (eq_attr "pent_prefix" "true")
318              (const_string "pu")
319              (const_string "uv"))
320          (eq_attr "type" "ibr")
321            (const_string "pv")
322          (and (eq_attr "type" "ishift")
323               (match_operand 2 "const_int_operand" ""))
324            (const_string "pu")
325          (and (eq_attr "type" "call")
326               (match_operand 0 "constant_call_address_operand" ""))
327            (const_string "pv")
328          (and (eq_attr "type" "callv")
329               (match_operand 1 "constant_call_address_operand" ""))
330            (const_string "pv")
331         ]
332         (const_string "np")))
333
334 ;; Rough readiness numbers.  Fine tuning happens in i386.c.
335 ;;
336 ;; u    describes pipe U
337 ;; v    describes pipe V
338 ;; uv   describes either pipe U or V for those that can issue to either
339 ;; np   describes not paring
340 ;; fpu  describes fpu
341 ;; fpm  describes fp insns of different types are not pipelined.
342 ;;
343 ;; ??? fxch isn't handled; not an issue until sched3 after reg-stack is real.
344
345 (define_function_unit "pent_np" 1 0
346   (and (eq_attr "cpu" "pentium")
347        (eq_attr "type" "imul"))
348   11 11)
349
350 (define_function_unit "pent_mul" 1 1
351   (and (eq_attr "cpu" "pentium")
352        (eq_attr "type" "imul"))
353   11 11)
354
355 ;; Rep movs takes minimally 12 cycles.
356 (define_function_unit "pent_np" 1 0
357   (and (eq_attr "cpu" "pentium")
358        (eq_attr "type" "str"))
359   12 12)
360
361 ; ??? IDIV for SI takes 46 cycles, for HI 30, for QI 22
362 (define_function_unit "pent_np" 1 0
363   (and (eq_attr "cpu" "pentium")
364        (eq_attr "type" "idiv"))
365   46 46)
366
367 ; Fp reg-reg moves takes 1 cycle. Loads takes 1 cycle for SF/DF mode,
368 ; 3 cycles for XFmode.  Stores takes 2 cycles for SF/DF and 3 for XF.
369 ; fldz and fld1 takes 2 cycles.  Only reg-reg moves are pairable.
370 ; The integer <-> fp conversion is not modeled correctly. Fild behaves
371 ; like normal fp operation and fist takes 6 cycles.
372
373 (define_function_unit "fpu" 1 0
374   (and (eq_attr "cpu" "pentium")
375        (and (eq_attr "type" "fmov")
376             (and (eq_attr "memory" "load,store")
377                  (eq_attr "mode" "XF"))))
378   3 3)
379
380 (define_function_unit "pent_np" 1 0
381   (and (eq_attr "cpu" "pentium")
382        (and (eq_attr "type" "fmov")
383             (and (eq_attr "memory" "load,store")
384                  (eq_attr "mode" "XF"))))
385   3 3)
386
387 (define_function_unit "fpu" 1 0
388   (and (eq_attr "cpu" "pentium")
389        (and (eq_attr "type" "fmov")
390             (ior (match_operand 1 "immediate_operand" "")
391                  (eq_attr "memory" "store"))))
392   2 2)
393
394 (define_function_unit "pent_np" 1 0
395   (and (eq_attr "cpu" "pentium")
396        (and (eq_attr "type" "fmov")
397             (ior (match_operand 1 "immediate_operand" "")
398                  (eq_attr "memory" "store"))))
399   2 2)
400
401 (define_function_unit "pent_np" 1 0
402   (and (eq_attr "cpu" "pentium")
403        (eq_attr "type" "cld"))
404   2 2)
405
406 (define_function_unit "fpu" 1 0
407   (and (eq_attr "cpu" "pentium")
408        (and (eq_attr "type" "fmov")
409             (eq_attr "memory" "none,load")))
410   1 1)
411
412 ; Read/Modify/Write instructions usually take 3 cycles.
413 (define_function_unit "pent_u" 1 0
414   (and (eq_attr "cpu" "pentium")
415        (and (eq_attr "type" "alu,alu1,ishift")
416             (and (eq_attr "pent_pair" "pu")
417                  (eq_attr "memory" "both"))))
418   3 3)
419
420 (define_function_unit "pent_uv" 2 0
421   (and (eq_attr "cpu" "pentium")
422        (and (eq_attr "type" "alu,alu1,ishift")
423             (and (eq_attr "pent_pair" "!np")
424                  (eq_attr "memory" "both"))))
425   3 3)
426
427 (define_function_unit "pent_np" 1 0
428   (and (eq_attr "cpu" "pentium")
429        (and (eq_attr "type" "alu,alu1,negnot,ishift")
430             (and (eq_attr "pent_pair" "np")
431                  (eq_attr "memory" "both"))))
432   3 3)
433
434 ; Read/Modify or Modify/Write instructions usually take 2 cycles.
435 (define_function_unit "pent_u" 1 0
436   (and (eq_attr "cpu" "pentium")
437        (and (eq_attr "type" "alu,ishift")
438             (and (eq_attr "pent_pair" "pu")
439                  (eq_attr "memory" "load,store"))))
440   2 2)
441
442 (define_function_unit "pent_uv" 2 0
443   (and (eq_attr "cpu" "pentium")
444        (and (eq_attr "type" "alu,ishift")
445             (and (eq_attr "pent_pair" "!np")
446                  (eq_attr "memory" "load,store"))))
447   2 2)
448
449 (define_function_unit "pent_np" 1 0
450   (and (eq_attr "cpu" "pentium")
451        (and (eq_attr "type" "alu,ishift")
452             (and (eq_attr "pent_pair" "np")
453                  (eq_attr "memory" "load,store"))))
454   2 2)
455
456 ; Insns w/o memory operands and move instructions usually take one cycle.
457 (define_function_unit "pent_u" 1 0
458   (and (eq_attr "cpu" "pentium")
459        (eq_attr "pent_pair" "pu"))
460   1 1)
461
462 (define_function_unit "pent_v" 1 0
463   (and (eq_attr "cpu" "pentium")
464        (eq_attr "pent_pair" "pv"))
465   1 1)
466
467 (define_function_unit "pent_uv" 2 0
468   (and (eq_attr "cpu" "pentium")
469        (eq_attr "pent_pair" "!np"))
470   1 1)
471
472 (define_function_unit "pent_np" 1 0
473   (and (eq_attr "cpu" "pentium")
474        (eq_attr "pent_pair" "np"))
475   1 1)
476
477 ; Pairable insns only conflict with other non-pairable insns.
478 (define_function_unit "pent_np" 1 0
479   (and (eq_attr "cpu" "pentium")
480        (and (eq_attr "type" "alu,alu1,ishift")
481             (and (eq_attr "pent_pair" "!np")
482                  (eq_attr "memory" "both"))))
483   3 3
484   [(eq_attr "pent_pair" "np")])
485
486 (define_function_unit "pent_np" 1 0
487   (and (eq_attr "cpu" "pentium")
488        (and (eq_attr "type" "alu,alu1,ishift")
489             (and (eq_attr "pent_pair" "!np")
490                  (eq_attr "memory" "load,store"))))
491   2 2
492   [(eq_attr "pent_pair" "np")])
493
494 (define_function_unit "pent_np" 1 0
495   (and (eq_attr "cpu" "pentium")
496        (eq_attr "pent_pair" "!np"))
497   1 1
498   [(eq_attr "pent_pair" "np")])
499
500 ; Floating point instructions usually blocks cycle longer when combined with
501 ; integer instructions, because of the inpaired fxch instruction.
502 (define_function_unit "pent_np" 1 0
503   (and (eq_attr "cpu" "pentium")
504        (eq_attr "type" "fmov,fop,fop1,fsgn,fmul,fpspc,fcmov,fcmp"))
505   2 2
506   [(eq_attr "type" "!fmov,fop,fop1,fsgn,fmul,fpspc,fcmov,fcmp")])
507
508 (define_function_unit "fpu" 1 0
509   (and (eq_attr "cpu" "pentium")
510        (eq_attr "type" "fcmp,fxch,fsgn"))
511   1 1)
512
513 ; Addition takes 3 cycles; assume other random cruft does as well.
514 ; ??? Trivial fp operations such as fabs or fchs takes only one cycle.
515 (define_function_unit "fpu" 1 0
516   (and (eq_attr "cpu" "pentium")
517        (eq_attr "type" "fop,fop1"))
518   3 1)
519
520 ; Multiplication takes 3 cycles and is only half pipelined.
521 (define_function_unit "fpu" 1 0
522   (and (eq_attr "cpu" "pentium")
523        (eq_attr "type" "fmul"))
524   3 1)
525
526 (define_function_unit "pent_mul" 1 1
527   (and (eq_attr "cpu" "pentium")
528        (eq_attr "type" "fmul"))
529   2 2)
530
531 ; ??? This is correct only for fdiv and sqrt -- sin/cos take 65-100 cycles. 
532 ; They can overlap with integer insns.  Only the last two cycles can overlap
533 ; with other fp insns.  Only fsin/fcos can overlap with multiplies.
534 ; Only last two cycles of fsin/fcos can overlap with other instructions.
535 (define_function_unit "fpu" 1 0
536   (and (eq_attr "cpu" "pentium")
537        (eq_attr "type" "fdiv"))
538   39 37)
539
540 (define_function_unit "pent_mul" 1 1
541   (and (eq_attr "cpu" "pentium")
542        (eq_attr "type" "fdiv"))
543   39 39)
544
545 (define_function_unit "fpu" 1 0
546   (and (eq_attr "cpu" "pentium")
547        (eq_attr "type" "fpspc"))
548   70 68)
549
550 (define_function_unit "pent_mul" 1 1
551   (and (eq_attr "cpu" "pentium")
552        (eq_attr "type" "fpspc"))
553   70 70)
554 \f
555 ;; Pentium Pro/PII Scheduling
556 ;;
557 ;; The PPro has an out-of-order core, but the instruction decoders are
558 ;; naturally in-order and asymmetric.  We get best performance by scheduling
559 ;; for the decoders, for in doing so we give the oo execution unit the 
560 ;; most choices.
561
562 ;; Categorize how many uops an ia32 instruction evaluates to:
563 ;;   one --  an instruction with 1 uop can be decoded by any of the
564 ;;           three decoders.
565 ;;   few --  an instruction with 1 to 4 uops can be decoded only by 
566 ;;           decoder 0.
567 ;;   many -- a complex instruction may take an unspecified number of
568 ;;           cycles to decode in decoder 0.
569
570 (define_attr "ppro_uops" "one,few,many"
571   (cond [(eq_attr "type" "other,multi,call,callv,fpspc,str")
572            (const_string "many")
573          (eq_attr "type" "icmov,fcmov,str,cld")
574            (const_string "few")
575          (eq_attr "type" "imov")
576            (if_then_else (eq_attr "memory" "store,both")
577              (const_string "few")
578              (const_string "one"))
579          (eq_attr "memory" "!none")
580            (const_string "few")
581         ]
582         (const_string "one")))
583
584 ;; Rough readiness numbers.  Fine tuning happens in i386.c.
585 ;;
586 ;; p0   describes port 0.
587 ;; p01  describes ports 0 and 1 as a pair; alu insns can issue to either.
588 ;; p2   describes port 2 for loads.
589 ;; p34  describes ports 3 and 4 for stores.
590 ;; fpu  describes the fpu accessed via port 0. 
591 ;;      ??? It is less than clear if there are separate fadd and fmul units
592 ;;      that could operate in parallel.
593 ;;
594 ;; ??? fxch isn't handled; not an issue until sched3 after reg-stack is real.
595
596 (define_function_unit "ppro_p0" 1 0
597   (and (eq_attr "cpu" "pentiumpro")
598        (eq_attr "type" "ishift,lea,ibr,cld"))
599   1 1)
600
601 (define_function_unit "ppro_p0" 1 0
602   (and (eq_attr "cpu" "pentiumpro")
603        (eq_attr "type" "imul"))
604   4 1)
605
606 ;; ??? Does the divider lock out the pipe while it works,
607 ;; or is there a disconnected unit?
608 (define_function_unit "ppro_p0" 1 0
609   (and (eq_attr "cpu" "pentiumpro")
610        (eq_attr "type" "idiv"))
611   17 17)
612
613 (define_function_unit "ppro_p0" 1 0
614   (and (eq_attr "cpu" "pentiumpro")
615        (eq_attr "type" "fop,fop1,fsgn"))
616   3 1)
617
618 (define_function_unit "ppro_p0" 1 0
619   (and (eq_attr "cpu" "pentiumpro")
620        (eq_attr "type" "fcmov"))
621   2 1)
622
623 (define_function_unit "ppro_p0" 1 0
624   (and (eq_attr "cpu" "pentiumpro")
625        (eq_attr "type" "fcmp"))
626   1 1)
627
628 (define_function_unit "ppro_p0" 1 0
629   (and (eq_attr "cpu" "pentiumpro")
630        (eq_attr "type" "fmov"))
631   1 1)
632
633 (define_function_unit "ppro_p0" 1 0
634   (and (eq_attr "cpu" "pentiumpro")
635        (eq_attr "type" "fmul"))
636   5 1)
637
638 (define_function_unit "ppro_p0" 1 0
639   (and (eq_attr "cpu" "pentiumpro")
640        (eq_attr "type" "fdiv,fpspc"))
641   56 1)
642
643 (define_function_unit "ppro_p01" 2 0
644   (and (eq_attr "cpu" "pentiumpro")
645        (eq_attr "type" "!imov,fmov"))
646   1 1)
647
648 (define_function_unit "ppro_p01" 2 0
649   (and (and (eq_attr "cpu" "pentiumpro")
650             (eq_attr "type" "imov,fmov"))
651        (eq_attr "memory" "none"))
652   1 1)
653
654 (define_function_unit "ppro_p2" 1 0
655   (and (eq_attr "cpu" "pentiumpro")
656        (ior (eq_attr "type" "pop")
657             (eq_attr "memory" "load,both")))
658   3 1)
659
660 (define_function_unit "ppro_p34" 1 0
661   (and (eq_attr "cpu" "pentiumpro")
662        (ior (eq_attr "type" "push")
663             (eq_attr "memory" "store,both")))
664   1 1)
665
666 (define_function_unit "fpu" 1 0
667   (and (eq_attr "cpu" "pentiumpro")
668        (eq_attr "type" "fop,fop1,fsgn,fmov,fcmp,fcmov"))
669   1 1)
670
671 (define_function_unit "fpu" 1 0
672   (and (eq_attr "cpu" "pentiumpro")
673        (eq_attr "type" "fmul"))
674   5 2)
675
676 (define_function_unit "fpu" 1 0
677   (and (eq_attr "cpu" "pentiumpro")
678        (eq_attr "type" "fdiv,fpspc"))
679   56 56)
680
681 ;; imul uses the fpu.  ??? does it have the same throughput as fmul?
682 (define_function_unit "fpu" 1 0
683   (and (eq_attr "cpu" "pentiumpro")
684        (eq_attr "type" "imul"))
685   4 1)
686 \f
687 ;; AMD K6/K6-2 Scheduling
688 ;;
689 ;; The K6 has similar architecture to PPro.  Important difference is, that
690 ;; there are only two decoders and they seems to be much slower than execution
691 ;; units.  So we have to pay much more attention to proper decoding for
692 ;; schedulers.  We share most of scheduler code for PPro in i386.c
693 ;;
694 ;; The fp unit is not pipelined and do one operation per two cycles including
695 ;; the FXCH.
696 ;;
697 ;; alu    describes both ALU units (ALU-X and ALU-Y).
698 ;; alux   describes X alu unit
699 ;; fpu    describes FPU unit
700 ;; load   describes load unit.
701 ;; branch describes branch unit.
702 ;; store  decsribes store unit.  This unit is not modelled completely and only
703 ;;        used to model lea operation.  Otherwise it lie outside of the critical
704 ;;        path.
705 ;;
706 ;; ??? fxch isn't handled; not an issue until sched3 after reg-stack is real.
707
708 ;; The decoder specification is in the PPro section above!
709
710 ;; Shift instructions and certain arithmetic are issued only to X pipe.
711 (define_function_unit "k6_alux" 1 0
712   (and (eq_attr "cpu" "k6")
713        (eq_attr "type" "ishift,alu1,negnot,cld"))
714   1 1)
715
716 ;; The QI mode arithmetic is issued to X pipe only.
717 (define_function_unit "k6_alux" 1 0
718   (and (eq_attr "cpu" "k6")
719        (and (eq_attr "type" "alu,alu1,negnot,icmp,test,imovx,incdec")
720             (match_operand:QI 0 "general_operand" "")))
721   1 1)
722
723 (define_function_unit "k6_alu" 2 0
724   (and (eq_attr "cpu" "k6")
725        (eq_attr "type" "ishift,alu1,negnot,alu,icmp,test,imovx,incdec,setcc,lea"))
726   1 1)
727
728 (define_function_unit "k6_alu" 2 0
729   (and (eq_attr "cpu" "k6")
730        (and (eq_attr "type" "imov")
731             (eq_attr "memory" "none")))
732   1 1)
733
734 (define_function_unit "k6_branch" 1 0
735   (and (eq_attr "cpu" "k6")
736        (eq_attr "type" "call,callv,ibr"))
737   1 1)
738
739 ;; Load unit have two cycle latency, but we take care for it in adjust_cost
740 (define_function_unit "k6_load" 1 0
741   (and (eq_attr "cpu" "k6")
742        (ior (eq_attr "type" "pop")
743             (eq_attr "memory" "load,both")))
744   1 1)
745
746 (define_function_unit "k6_load" 1 0
747   (and (eq_attr "cpu" "k6")
748        (and (eq_attr "type" "str")
749             (eq_attr "memory" "load,both")))
750   10 10)
751
752 ;; Lea have two instructions, so latency is probably 2
753 (define_function_unit "k6_store" 1 0
754   (and (eq_attr "cpu" "k6")
755        (eq_attr "type" "lea"))
756   2 1)
757
758 (define_function_unit "k6_store" 1 0
759   (and (eq_attr "cpu" "k6")
760        (eq_attr "type" "str"))
761   10 10)
762
763 (define_function_unit "k6_store" 1 0
764   (and (eq_attr "cpu" "k6")
765        (ior (eq_attr "type" "push")
766             (eq_attr "memory" "store,both")))
767   1 1)
768
769 (define_function_unit "k6_fpu" 1 1
770   (and (eq_attr "cpu" "k6")
771        (eq_attr "type" "fop,fop1,fmov,fcmp"))
772   2 2)
773
774 (define_function_unit "k6_fpu" 1 1
775   (and (eq_attr "cpu" "k6")
776        (eq_attr "type" "fmul"))
777   2 2)
778
779 ;; ??? Guess
780 (define_function_unit "k6_fpu" 1 1
781   (and (eq_attr "cpu" "k6")
782        (eq_attr "type" "fdiv,fpspc"))
783   56 56)
784
785 (define_function_unit "k6_alu" 2 0
786   (and (eq_attr "cpu" "k6")
787        (eq_attr "type" "imul"))
788   2 2)
789
790 (define_function_unit "k6_alux" 1 0
791   (and (eq_attr "cpu" "k6")
792        (eq_attr "type" "imul"))
793   2 2)
794
795 ;; ??? Guess
796 (define_function_unit "k6_alu" 2 0
797   (and (eq_attr "cpu" "k6")
798        (eq_attr "type" "idiv"))
799   17 17)
800
801 (define_function_unit "k6_alux" 1 0
802   (and (eq_attr "cpu" "k6")
803        (eq_attr "type" "idiv"))
804   17 17)
805 \f
806 ;; AMD Athlon Scheduling
807 ;;
808 ;; The Athlon does contain three pipelined FP units, three integer units and
809 ;; three address generation units. 
810 ;;
811 ;; The predecode logic is determining boundaries of instructions in the 64
812 ;; byte cache line. So the cache line straddling problem of K6 might be issue
813 ;; here as well, but it is not noted in the documentation.
814 ;;
815 ;; Three DirectPath instructions decoders and only one VectorPath decoder
816 ;; is available. They can decode three DirectPath instructions or one VectorPath
817 ;; instruction per cycle.
818 ;; Decoded macro instructions are then passed to 72 entry instruction control
819 ;; unit, that passes
820 ;; it to the specialized integer (18 entry) and fp (36 entry) schedulers.
821 ;;
822 ;; The load/store queue unit is not attached to the schedulers but
823 ;; communicates with all the execution units seperately instead.
824
825 (define_attr "athlon_decode" "direct,vector"
826   (cond [(eq_attr "type" "call,imul,idiv,other,multi,fcmov,fpspc,str,pop,cld,fcmov")
827            (const_string "vector")
828          (and (eq_attr "type" "push")
829               (match_operand 1 "memory_operand" ""))
830            (const_string "vector")
831          (and (eq_attr "type" "fmov")
832               (and (eq_attr "memory" "load,store")
833                    (eq_attr "mode" "XF")))
834            (const_string "vector")]
835         (const_string "direct")))
836
837 (define_function_unit "athlon_vectordec" 1 0
838   (and (eq_attr "cpu" "athlon")
839        (eq_attr "athlon_decode" "vector"))
840   1 1)
841
842 (define_function_unit "athlon_directdec" 3 0
843   (and (eq_attr "cpu" "athlon")
844        (eq_attr "athlon_decode" "direct"))
845   1 1)
846
847 (define_function_unit "athlon_vectordec" 1 0
848   (and (eq_attr "cpu" "athlon")
849        (eq_attr "athlon_decode" "direct"))
850   1 1 [(eq_attr "athlon_decode" "vector")])
851
852 (define_function_unit "athlon_ieu" 3 0
853   (and (eq_attr "cpu" "athlon")
854        (eq_attr "type" "alu1,negnot,alu,icmp,test,imov,imovx,lea,incdec,ishift,ibr,call,callv,icmov,cld,pop,setcc,push,pop"))
855   1 1)
856
857 (define_function_unit "athlon_ieu" 3 0
858   (and (eq_attr "cpu" "athlon")
859        (eq_attr "type" "str"))
860   15 15)
861
862 (define_function_unit "athlon_ieu" 3 0
863   (and (eq_attr "cpu" "athlon")
864        (eq_attr "type" "imul"))
865   5 0)
866
867 (define_function_unit "athlon_ieu" 3 0
868   (and (eq_attr "cpu" "athlon")
869        (eq_attr "type" "idiv"))
870   42 0)
871
872 (define_function_unit "athlon_muldiv" 1 0
873   (and (eq_attr "cpu" "athlon")
874        (eq_attr "type" "imul"))
875   5 0)
876
877 (define_function_unit "athlon_muldiv" 1 0
878   (and (eq_attr "cpu" "athlon")
879        (eq_attr "type" "idiv"))
880   42 42)
881
882 (define_attr "athlon_fpunits" "none,store,mul,add,muladd,any"
883   (cond [(eq_attr "type" "fop,fop1,fcmp")
884            (const_string "add")
885          (eq_attr "type" "fmul,fdiv,fpspc,fsgn,fcmov")
886            (const_string "mul")
887          (and (eq_attr "type" "fmov") (eq_attr "memory" "store,both"))
888            (const_string "store")
889          (and (eq_attr "type" "fmov") (eq_attr "memory" "load"))
890            (const_string "any")
891          (and (eq_attr "type" "fmov")
892               (ior (match_operand:SI 1 "register_operand" "")
893                    (match_operand 1 "immediate_operand" "")))
894            (const_string "store")
895          (eq_attr "type" "fmov")
896            (const_string "muladd")]
897         (const_string "none")))
898
899 ;; We use latencies 1 for definitions.  This is OK to model colisions
900 ;; in execution units.  The real latencies are modeled in the "fp" pipeline.
901
902 ;; fsin, fcos: 96-192
903 ;; fsincos: 107-211
904 ;; fsqrt: 19 for SFmode, 27 for DFmode, 35 for XFmode.
905 (define_function_unit "athlon_fp" 3 0
906   (and (eq_attr "cpu" "athlon")
907        (eq_attr "type" "fpspc"))
908   100 1)
909
910 ;; 16 cycles for SFmode, 20 for DFmode and 24 for XFmode.
911 (define_function_unit "athlon_fp" 3 0
912   (and (eq_attr "cpu" "athlon")
913        (eq_attr "type" "fdiv"))
914   24 1)
915
916 (define_function_unit "athlon_fp" 3 0
917   (and (eq_attr "cpu" "athlon")
918        (eq_attr "type" "fop,fop1,fmul"))
919   4 1)
920
921 ;; XFmode loads are slow.
922 ;; XFmode store is slow too (8 cycles), but we don't need to model it, because
923 ;; there are no dependent instructions.
924
925 (define_function_unit "athlon_fp" 3 0
926   (and (eq_attr "cpu" "athlon")
927        (and (eq_attr "type" "fmov")
928             (and (eq_attr "memory" "load")
929                  (eq_attr "mode" "XF"))))
930   10 1)
931
932 (define_function_unit "athlon_fp" 3 0
933   (and (eq_attr "cpu" "athlon")
934        (eq_attr "type" "fmov,fsgn"))
935   2 1)
936
937 ;; fcmp and ftst instructions
938 (define_function_unit "athlon_fp" 3 0
939   (and (eq_attr "cpu" "athlon")
940        (and (eq_attr "type" "fcmp")
941             (eq_attr "athlon_decode" "direct")))
942   3 1)
943
944 ;; fcmpi instructions.
945 (define_function_unit "athlon_fp" 3 0
946   (and (eq_attr "cpu" "athlon")
947        (and (eq_attr "type" "fcmp")
948             (eq_attr "athlon_decode" "vector")))
949   3 1)
950
951 (define_function_unit "athlon_fp" 3 0
952   (and (eq_attr "cpu" "athlon")
953        (eq_attr "type" "fcmov"))
954   7 1)
955
956 (define_function_unit "athlon_fp_mul" 1 0
957   (and (eq_attr "cpu" "athlon")
958        (eq_attr "athlon_fpunits" "mul"))
959   1 1)
960
961 (define_function_unit "athlon_fp_add" 1 0
962   (and (eq_attr "cpu" "athlon")
963        (eq_attr "athlon_fpunits" "add"))
964   1 1)
965
966 (define_function_unit "athlon_fp_muladd" 2 0
967   (and (eq_attr "cpu" "athlon")
968        (eq_attr "athlon_fpunits" "muladd,mul,add"))
969   1 1)
970
971 (define_function_unit "athlon_fp_store" 1 0
972   (and (eq_attr "cpu" "athlon")
973        (eq_attr "athlon_fpunits" "store"))
974   1 1)
975
976 ;; We don't need to model the Adress Generation Unit, since we don't model
977 ;; the re-order buffer yet and thus we never schedule more than three operations
978 ;; at time.  Later we may want to experiment with MD_SCHED macros modeling the
979 ;; decoders independently on the functional units.
980
981 ;(define_function_unit "athlon_agu" 3 0
982 ;  (and (eq_attr "cpu" "athlon")
983 ;       (and (eq_attr "memory" "!none")
984 ;            (eq_attr "athlon_fpunits" "none")))
985 ;  1 1)
986
987 ;; Model load unit to avoid too long sequences of loads.  We don't need to
988 ;; model store queue, since it is hardly going to be bottleneck.
989
990 (define_function_unit "athlon_load" 2 0
991   (and (eq_attr "cpu" "athlon")
992        (eq_attr "memory" "load,both"))
993   1 1)
994
995 \f
996 ;; Compare instructions.
997
998 ;; All compare insns have expanders that save the operands away without
999 ;; actually generating RTL.  The bCOND or sCOND (emitted immediately
1000 ;; after the cmp) will actually emit the cmpM.
1001
1002 (define_expand "cmpdi"
1003   [(set (reg:CC 17)
1004         (compare:CC (match_operand:DI 0 "general_operand" "")
1005                     (match_operand:DI 1 "general_operand" "")))]
1006   ""
1007   "
1008 {
1009   if ((GET_CODE (operands[0]) == MEM && GET_CODE (operands[1]) == MEM)
1010       || (CONSTANT_P (operands[0]) && CONSTANT_P (operands[1])))
1011     operands[0] = force_reg (DImode, operands[0]);
1012   ix86_compare_op0 = operands[0];
1013   ix86_compare_op1 = operands[1];
1014   DONE;
1015 }")
1016
1017 (define_expand "cmpsi"
1018   [(set (reg:CC 17)
1019         (compare:CC (match_operand:SI 0 "cmpsi_operand" "")
1020                     (match_operand:SI 1 "general_operand" "")))]
1021   ""
1022   "
1023 {
1024   if ((GET_CODE (operands[0]) == MEM && GET_CODE (operands[1]) == MEM)
1025       || (CONSTANT_P (operands[0]) && CONSTANT_P (operands[1])))
1026     operands[0] = force_reg (SImode, operands[0]);
1027   ix86_compare_op0 = operands[0];
1028   ix86_compare_op1 = operands[1];
1029   DONE;
1030 }")
1031
1032 (define_expand "cmphi"
1033   [(set (reg:CC 17)
1034         (compare:CC (match_operand:HI 0 "general_operand" "")
1035                     (match_operand:HI 1 "general_operand" "")))]
1036   ""
1037   "
1038 {
1039   if ((GET_CODE (operands[0]) == MEM && GET_CODE (operands[1]) == MEM)
1040       || (CONSTANT_P (operands[0]) && CONSTANT_P (operands[1])))
1041     operands[0] = force_reg (HImode, operands[0]);
1042   ix86_compare_op0 = operands[0];
1043   ix86_compare_op1 = operands[1];
1044   DONE;
1045 }")
1046
1047 (define_expand "cmpqi"
1048   [(set (reg:CC 17)
1049         (compare:CC (match_operand:QI 0 "general_operand" "")
1050                     (match_operand:QI 1 "general_operand" "")))]
1051   "TARGET_QIMODE_MATH"
1052   "
1053 {
1054   if ((GET_CODE (operands[0]) == MEM && GET_CODE (operands[1]) == MEM)
1055       || (CONSTANT_P (operands[0]) && CONSTANT_P (operands[1])))
1056     operands[0] = force_reg (QImode, operands[0]);
1057   ix86_compare_op0 = operands[0];
1058   ix86_compare_op1 = operands[1];
1059   DONE;
1060 }")
1061
1062 (define_insn "*cmpsi_ccno_1"
1063   [(set (reg 17)
1064         (compare (match_operand:SI 0 "nonimmediate_operand" "r,?mr")
1065                  (match_operand:SI 1 "const0_operand" "n,n")))]
1066   "ix86_match_ccmode (insn, CCNOmode)"
1067   "@
1068    test{l}\\t{%0, %0|%0, %0}
1069    cmp{l}\\t{%1, %0|%0, %1}"
1070   [(set_attr "type" "test,icmp")
1071    (set_attr "length_immediate" "0,1")
1072    (set_attr "mode" "SI")])
1073
1074 (define_insn "*cmpsi_minus_1"
1075   [(set (reg 17)
1076         (compare (minus:SI (match_operand:SI 0 "nonimmediate_operand" "rm,r")
1077                            (match_operand:SI 1 "general_operand" "ri,mr"))
1078                  (const_int 0)))]
1079   "ix86_match_ccmode (insn, CCGOCmode)"
1080   "cmp{l}\\t{%1, %0|%0, %1}"
1081   [(set_attr "type" "icmp")
1082    (set_attr "mode" "SI")])
1083
1084 (define_expand "cmpsi_1"
1085   [(set (reg:CC 17)
1086         (compare:CC (match_operand:SI 0 "nonimmediate_operand" "rm,r")
1087                     (match_operand:SI 1 "general_operand" "ri,mr")))]
1088   ""
1089   "")
1090
1091 (define_insn "*cmpsi_1_insn"
1092   [(set (reg 17)
1093         (compare (match_operand:SI 0 "nonimmediate_operand" "rm,r")
1094                  (match_operand:SI 1 "general_operand" "ri,mr")))]
1095   "(GET_CODE (operands[0]) != MEM || GET_CODE (operands[1]) != MEM)
1096     && ix86_match_ccmode (insn, CCmode)"
1097   "cmp{l}\\t{%1, %0|%0, %1}"
1098   [(set_attr "type" "icmp")
1099    (set_attr "mode" "SI")])
1100
1101 (define_insn "*cmphi_ccno_1"
1102   [(set (reg 17)
1103         (compare (match_operand:HI 0 "nonimmediate_operand" "r,?mr")
1104                  (match_operand:HI 1 "const0_operand" "n,n")))]
1105   "ix86_match_ccmode (insn, CCNOmode)"
1106   "@
1107    test{w}\\t{%0, %0|%0, %0}
1108    cmp{w}\\t{%1, %0|%0, %1}"
1109   [(set_attr "type" "test,icmp")
1110    (set_attr "length_immediate" "0,1")
1111    (set_attr "mode" "HI")])
1112
1113 (define_insn "*cmphi_minus_1"
1114   [(set (reg 17)
1115         (compare (minus:HI (match_operand:HI 0 "nonimmediate_operand" "rm,r")
1116                            (match_operand:HI 1 "general_operand" "ri,mr"))
1117                  (const_int 0)))]
1118   "ix86_match_ccmode (insn, CCGOCmode)"
1119   "cmp{w}\\t{%1, %0|%0, %1}"
1120   [(set_attr "type" "icmp")
1121    (set_attr "mode" "HI")])
1122
1123 (define_insn "*cmphi_1"
1124   [(set (reg 17)
1125         (compare (match_operand:HI 0 "nonimmediate_operand" "rm,r")
1126                  (match_operand:HI 1 "general_operand" "ri,mr")))]
1127   "(GET_CODE (operands[0]) != MEM || GET_CODE (operands[1]) != MEM)
1128    && ix86_match_ccmode (insn, CCmode)"
1129   "cmp{w}\\t{%1, %0|%0, %1}"
1130   [(set_attr "type" "icmp")
1131    (set_attr "mode" "HI")])
1132
1133 (define_insn "*cmpqi_ccno_1"
1134   [(set (reg 17)
1135         (compare (match_operand:QI 0 "nonimmediate_operand" "q,?mq")
1136                  (match_operand:QI 1 "const0_operand" "n,n")))]
1137   "ix86_match_ccmode (insn, CCNOmode)"
1138   "@
1139    test{b}\\t{%0, %0|%0, %0}
1140    cmp{b}\\t{$0, %0|%0, 0}"
1141   [(set_attr "type" "test,icmp")
1142    (set_attr "length_immediate" "0,1")
1143    (set_attr "mode" "QI")])
1144
1145 (define_insn "*cmpqi_1"
1146   [(set (reg 17)
1147         (compare (match_operand:QI 0 "nonimmediate_operand" "qm,q")
1148                  (match_operand:QI 1 "general_operand" "qi,mq")))]
1149   "(GET_CODE (operands[0]) != MEM || GET_CODE (operands[1]) != MEM)
1150     && ix86_match_ccmode (insn, CCmode)"
1151   "cmp{b}\\t{%1, %0|%0, %1}"
1152   [(set_attr "type" "icmp")
1153    (set_attr "mode" "QI")])
1154
1155 (define_insn "*cmpqi_minus_1"
1156   [(set (reg 17)
1157         (compare (minus:QI (match_operand:QI 0 "nonimmediate_operand" "qm,q")
1158                            (match_operand:QI 1 "general_operand" "qi,mq"))
1159                  (const_int 0)))]
1160   "ix86_match_ccmode (insn, CCGOCmode)"
1161   "cmp{b}\\t{%1, %0|%0, %1}"
1162   [(set_attr "type" "icmp")
1163    (set_attr "mode" "QI")])
1164
1165 (define_insn "*cmpqi_ext_1"
1166   [(set (reg 17)
1167         (compare
1168           (match_operand:QI 0 "general_operand" "qm")
1169           (subreg:QI
1170             (zero_extract:SI
1171               (match_operand 1 "ext_register_operand" "q")
1172               (const_int 8)
1173               (const_int 8)) 0)))]
1174   "ix86_match_ccmode (insn, CCmode)"
1175   "cmp{b}\\t{%h1, %0|%0, %h1}"
1176   [(set_attr "type" "icmp")
1177    (set_attr "mode" "QI")])
1178
1179 (define_insn "*cmpqi_ext_2"
1180   [(set (reg 17)
1181         (compare
1182           (subreg:QI
1183             (zero_extract:SI
1184               (match_operand 0 "ext_register_operand" "q")
1185               (const_int 8)
1186               (const_int 8)) 0)
1187           (match_operand:QI 1 "const0_operand" "n")))]
1188   "ix86_match_ccmode (insn, CCNOmode)"
1189   "test{b}\\t%h0, %h0"
1190   [(set_attr "type" "test")
1191    (set_attr "length_immediate" "0")
1192    (set_attr "mode" "QI")])
1193
1194 (define_expand "cmpqi_ext_3"
1195   [(set (reg:CC 17)
1196         (compare:CC
1197           (subreg:QI
1198             (zero_extract:SI
1199               (match_operand 0 "ext_register_operand" "q")
1200               (const_int 8)
1201               (const_int 8)) 0)
1202           (match_operand:QI 1 "general_operand" "qmn")))]
1203   ""
1204   "")
1205
1206 (define_insn "cmpqi_ext_3_insn"
1207   [(set (reg 17)
1208         (compare
1209           (subreg:QI
1210             (zero_extract:SI
1211               (match_operand 0 "ext_register_operand" "q")
1212               (const_int 8)
1213               (const_int 8)) 0)
1214           (match_operand:QI 1 "general_operand" "qmn")))]
1215   "ix86_match_ccmode (insn, CCmode)"
1216   "cmp{b}\\t{%1, %h0|%h0, %1}"
1217   [(set_attr "type" "icmp")
1218    (set_attr "mode" "QI")])
1219
1220 (define_insn "*cmpqi_ext_4"
1221   [(set (reg 17)
1222         (compare
1223           (subreg:QI
1224             (zero_extract:SI
1225               (match_operand 0 "ext_register_operand" "q")
1226               (const_int 8)
1227               (const_int 8)) 0)
1228           (subreg:QI
1229             (zero_extract:SI
1230               (match_operand 1 "ext_register_operand" "q")
1231               (const_int 8)
1232               (const_int 8)) 0)))]
1233   "ix86_match_ccmode (insn, CCmode)"
1234   "cmp{b}\\t{%h1, %h0|%h0, %h1}"
1235   [(set_attr "type" "icmp")
1236    (set_attr "mode" "QI")])
1237
1238 ;; These implement float point compares.
1239 ;; %%% See if we can get away with VOIDmode operands on the actual insns,
1240 ;; which would allow mix and match FP modes on the compares.  Which is what
1241 ;; the old patterns did, but with many more of them.
1242
1243 (define_expand "cmpxf"
1244   [(set (reg:CC 17)
1245         (compare:CC (match_operand:XF 0 "cmp_fp_expander_operand" "")
1246                     (match_operand:XF 1 "cmp_fp_expander_operand" "")))]
1247   "TARGET_80387"
1248   "
1249 {
1250   ix86_compare_op0 = operands[0];
1251   ix86_compare_op1 = operands[1];
1252   DONE;
1253 }")
1254
1255 (define_expand "cmptf"
1256   [(set (reg:CC 17)
1257         (compare:CC (match_operand:TF 0 "cmp_fp_expander_operand" "")
1258                     (match_operand:TF 1 "cmp_fp_expander_operand" "")))]
1259   "TARGET_80387"
1260   "
1261 {
1262   ix86_compare_op0 = operands[0];
1263   ix86_compare_op1 = operands[1];
1264   DONE;
1265 }")
1266
1267 (define_expand "cmpdf"
1268   [(set (reg:CC 17)
1269         (compare:CC (match_operand:DF 0 "cmp_fp_expander_operand" "")
1270                     (match_operand:DF 1 "cmp_fp_expander_operand" "")))]
1271   "TARGET_80387 || TARGET_SSE2"
1272   "
1273 {
1274   ix86_compare_op0 = operands[0];
1275   ix86_compare_op1 = operands[1];
1276   DONE;
1277 }")
1278
1279 (define_expand "cmpsf"
1280   [(set (reg:CC 17)
1281         (compare:CC (match_operand:SF 0 "cmp_fp_expander_operand" "")
1282                     (match_operand:SF 1 "cmp_fp_expander_operand" "")))]
1283   "TARGET_80387 || TARGET_SSE"
1284   "
1285 {
1286   ix86_compare_op0 = operands[0];
1287   ix86_compare_op1 = operands[1];
1288   DONE;
1289 }")
1290
1291 ;; FP compares, step 1:
1292 ;; Set the FP condition codes.
1293 ;;
1294 ;; CCFPmode     compare with exceptions
1295 ;; CCFPUmode    compare with no exceptions
1296
1297 ;; %%% It is an unfortunate fact that ftst has no non-popping variant,
1298 ;; and that fp moves clobber the condition codes, and that there is
1299 ;; currently no way to describe this fact to reg-stack.  So there are
1300 ;; no splitters yet for this.
1301
1302 ;; %%% YIKES!  This scheme does not retain a strong connection between 
1303 ;; the real compare and the ultimate cc0 user, so CC_REVERSE does not
1304 ;; work!  Only allow tos/mem with tos in op 0.
1305 ;;
1306 ;; Hmm, of course, this is what the actual _hardware_ does.  Perhaps
1307 ;; things aren't as bad as they sound...
1308
1309 (define_insn "*cmpfp_0"
1310   [(set (match_operand:HI 0 "register_operand" "=a")
1311         (unspec:HI
1312           [(compare:CCFP (match_operand 1 "register_operand" "f")
1313                          (match_operand 2 "const0_operand" "X"))] 9))]
1314   "TARGET_80387
1315    && FLOAT_MODE_P (GET_MODE (operands[1]))
1316    && GET_MODE (operands[1]) == GET_MODE (operands[2])"
1317   "*
1318 {
1319   if (find_regno_note (insn, REG_DEAD, REGNO (operands[1])))
1320     return \"ftst\;fnstsw\\t%0\;fstp\\t%y0\";
1321   else
1322     return \"ftst\;fnstsw\\t%0\";
1323 }"
1324   [(set_attr "type" "multi")
1325    (set_attr "mode" "unknownfp")])
1326
1327 ;; We may not use "#" to split and emit these, since the REG_DEAD notes
1328 ;; used to manage the reg stack popping would not be preserved.
1329
1330 (define_insn "*cmpfp_2_sf"
1331   [(set (reg:CCFP 18)
1332         (compare:CCFP
1333           (match_operand:SF 0 "register_operand" "f")
1334           (match_operand:SF 1 "nonimmediate_operand" "fm")))]
1335   "TARGET_80387"
1336   "* return output_fp_compare (insn, operands, 0, 0);"
1337   [(set_attr "type" "fcmp")
1338    (set_attr "mode" "SF")])
1339
1340 (define_insn "*cmpfp_2_sf_1"
1341   [(set (match_operand:HI 0 "register_operand" "=a")
1342         (unspec:HI
1343           [(compare:CCFP
1344              (match_operand:SF 1 "register_operand" "f")
1345              (match_operand:SF 2 "nonimmediate_operand" "fm"))] 9))]
1346   "TARGET_80387"
1347   "* return output_fp_compare (insn, operands, 2, 0);"
1348   [(set_attr "type" "fcmp")
1349    (set_attr "mode" "SF")])
1350
1351 (define_insn "*cmpfp_2_df"
1352   [(set (reg:CCFP 18)
1353         (compare:CCFP
1354           (match_operand:DF 0 "register_operand" "f")
1355           (match_operand:DF 1 "nonimmediate_operand" "fm")))]
1356   "TARGET_80387"
1357   "* return output_fp_compare (insn, operands, 0, 0);"
1358   [(set_attr "type" "fcmp")
1359    (set_attr "mode" "DF")])
1360
1361 (define_insn "*cmpfp_2_df_1"
1362   [(set (match_operand:HI 0 "register_operand" "=a")
1363         (unspec:HI
1364           [(compare:CCFP
1365              (match_operand:DF 1 "register_operand" "f")
1366              (match_operand:DF 2 "nonimmediate_operand" "fm"))] 9))]
1367   "TARGET_80387"
1368   "* return output_fp_compare (insn, operands, 2, 0);"
1369   [(set_attr "type" "multi")
1370    (set_attr "mode" "DF")])
1371
1372 (define_insn "*cmpfp_2_xf"
1373   [(set (reg:CCFP 18)
1374         (compare:CCFP
1375           (match_operand:XF 0 "register_operand" "f")
1376           (match_operand:XF 1 "register_operand" "f")))]
1377   "TARGET_80387"
1378   "* return output_fp_compare (insn, operands, 0, 0);"
1379   [(set_attr "type" "fcmp")
1380    (set_attr "mode" "XF")])
1381
1382 (define_insn "*cmpfp_2_tf"
1383   [(set (reg:CCFP 18)
1384         (compare:CCFP
1385           (match_operand:TF 0 "register_operand" "f")
1386           (match_operand:TF 1 "register_operand" "f")))]
1387   "TARGET_80387"
1388   "* return output_fp_compare (insn, operands, 0, 0);"
1389   [(set_attr "type" "fcmp")
1390    (set_attr "mode" "XF")])
1391
1392 (define_insn "*cmpfp_2_xf_1"
1393   [(set (match_operand:HI 0 "register_operand" "=a")
1394         (unspec:HI
1395           [(compare:CCFP
1396              (match_operand:XF 1 "register_operand" "f")
1397              (match_operand:XF 2 "register_operand" "f"))] 9))]
1398   "TARGET_80387"
1399   "* return output_fp_compare (insn, operands, 2, 0);"
1400   [(set_attr "type" "multi")
1401    (set_attr "mode" "XF")])
1402
1403 (define_insn "*cmpfp_2_tf_1"
1404   [(set (match_operand:HI 0 "register_operand" "=a")
1405         (unspec:HI
1406           [(compare:CCFP
1407              (match_operand:TF 1 "register_operand" "f")
1408              (match_operand:TF 2 "register_operand" "f"))] 9))]
1409   "TARGET_80387"
1410   "* return output_fp_compare (insn, operands, 2, 0);"
1411   [(set_attr "type" "multi")
1412    (set_attr "mode" "XF")])
1413
1414 (define_insn "*cmpfp_2u"
1415   [(set (reg:CCFPU 18)
1416         (compare:CCFPU
1417           (match_operand 0 "register_operand" "f")
1418           (match_operand 1 "register_operand" "f")))]
1419   "TARGET_80387
1420    && FLOAT_MODE_P (GET_MODE (operands[0]))
1421    && GET_MODE (operands[0]) == GET_MODE (operands[1])"
1422   "* return output_fp_compare (insn, operands, 0, 1);"
1423   [(set_attr "type" "fcmp")
1424    (set_attr "mode" "unknownfp")])
1425
1426 (define_insn "*cmpfp_2u_1"
1427   [(set (match_operand:HI 0 "register_operand" "=a")
1428         (unspec:HI
1429           [(compare:CCFPU
1430              (match_operand 1 "register_operand" "f")
1431              (match_operand 2 "register_operand" "f"))] 9))]
1432   "TARGET_80387
1433    && FLOAT_MODE_P (GET_MODE (operands[1]))
1434    && GET_MODE (operands[1]) == GET_MODE (operands[2])"
1435   "* return output_fp_compare (insn, operands, 2, 1);"
1436   [(set_attr "type" "multi")
1437    (set_attr "mode" "unknownfp")])
1438
1439 ;; Patterns to match the SImode-in-memory ficom instructions.
1440 ;;
1441 ;; %%% Play games with accepting gp registers, as otherwise we have to
1442 ;; force them to memory during rtl generation, which is no good.  We
1443 ;; can get rid of this once we teach reload to do memory input reloads 
1444 ;; via pushes.
1445
1446 (define_insn "*ficom_1"
1447   [(set (reg:CCFP 18)
1448         (compare:CCFP
1449           (match_operand 0 "register_operand" "f,f")
1450           (float (match_operand:SI 1 "nonimmediate_operand" "m,?r"))))]
1451   "0 && TARGET_80387 && FLOAT_MODE_P (GET_MODE (operands[0]))
1452    && GET_MODE (XEXP (SET_SRC (PATTERN (insn)), 1)) == GET_MODE (operands[0])"
1453   "#")
1454
1455 ;; Split the not-really-implemented gp register case into a
1456 ;; push-op-pop sequence.
1457 ;;
1458 ;; %%% This is most efficient, but am I gonna get in trouble
1459 ;; for separating cc0_setter and cc0_user?
1460
1461 (define_split
1462   [(set (reg:CCFP 18)
1463         (compare:CCFP
1464           (match_operand:SF 0 "register_operand" "")
1465           (float (match_operand:SI 1 "register_operand" ""))))]
1466   "0 && TARGET_80387 && reload_completed"
1467   [(set (mem:SI (pre_dec:SI (reg:SI 7))) (match_dup 1))
1468    (set (reg:CCFP 18) (compare:CCFP (match_dup 0) (match_dup 2)))
1469    (parallel [(set (match_dup 1) (mem:SI (reg:SI 7)))
1470               (set (reg:SI 7) (plus:SI (reg:SI 7) (const_int 4)))])]
1471   "operands[2] = gen_rtx_MEM (Pmode, stack_pointer_rtx);
1472    operands[2] = gen_rtx_FLOAT (GET_MODE (operands[0]), operands[2]);")
1473
1474 ;; FP compares, step 2
1475 ;; Move the fpsw to ax.
1476
1477 (define_insn "x86_fnstsw_1"
1478   [(set (match_operand:HI 0 "register_operand" "=a")
1479         (unspec:HI [(reg 18)] 9))]
1480   "TARGET_80387"
1481   "fnstsw\\t%0"
1482   [(set_attr "length" "2")
1483    (set_attr "mode" "SI")
1484    (set_attr "i387" "1")
1485    (set_attr "ppro_uops" "few")])
1486
1487 ;; FP compares, step 3
1488 ;; Get ax into flags, general case.
1489
1490 (define_insn "x86_sahf_1"
1491   [(set (reg:CC 17)
1492         (unspec:CC [(match_operand:HI 0 "register_operand" "a")] 10))]
1493   ""
1494   "sahf"
1495   [(set_attr "length" "1")
1496    (set_attr "athlon_decode" "vector")
1497    (set_attr "mode" "SI")
1498    (set_attr "ppro_uops" "one")])
1499
1500 ;; Pentium Pro can do steps 1 through 3 in one go.
1501
1502 (define_insn "*cmpfp_i"
1503   [(set (reg:CCFP 17)
1504         (compare:CCFP (match_operand 0 "register_operand" "f")
1505                       (match_operand 1 "register_operand" "f")))]
1506   "TARGET_80387 && TARGET_CMOVE
1507    && !SSE_FLOAT_MODE_P (GET_MODE (operands[0]))
1508    && FLOAT_MODE_P (GET_MODE (operands[0]))
1509    && GET_MODE (operands[0]) == GET_MODE (operands[0])"
1510   "* return output_fp_compare (insn, operands, 1, 0);"
1511   [(set_attr "type" "fcmp")
1512    (set_attr "mode" "unknownfp")
1513    (set_attr "athlon_decode" "vector")])
1514
1515 (define_insn "*cmpfp_i_sse"
1516   [(set (reg:CCFP 17)
1517         (compare:CCFP (match_operand 0 "register_operand" "f#x,x#f")
1518                       (match_operand 1 "nonimmediate_operand" "f#x,xm#f")))]
1519   "TARGET_80387
1520    && SSE_FLOAT_MODE_P (GET_MODE (operands[0]))
1521    && GET_MODE (operands[0]) == GET_MODE (operands[0])"
1522   "* return output_fp_compare (insn, operands, 1, 0);"
1523   [(set_attr "type" "fcmp,sse")
1524    (set_attr "mode" "unknownfp")
1525    (set_attr "athlon_decode" "vector")])
1526
1527 (define_insn "*cmpfp_i_sse_only"
1528   [(set (reg:CCFP 17)
1529         (compare:CCFP (match_operand 0 "register_operand" "x")
1530                       (match_operand 1 "nonimmediate_operand" "xm")))]
1531   "SSE_FLOAT_MODE_P (GET_MODE (operands[0]))
1532    && GET_MODE (operands[0]) == GET_MODE (operands[0])"
1533   "* return output_fp_compare (insn, operands, 1, 0);"
1534   [(set_attr "type" "sse")
1535    (set_attr "mode" "unknownfp")
1536    (set_attr "athlon_decode" "vector")])
1537
1538 (define_insn "*cmpfp_iu"
1539   [(set (reg:CCFPU 17)
1540         (compare:CCFPU (match_operand 0 "register_operand" "f")
1541                        (match_operand 1 "register_operand" "f")))]
1542   "TARGET_80387 && TARGET_CMOVE
1543    && !SSE_FLOAT_MODE_P (GET_MODE (operands[0]))
1544    && FLOAT_MODE_P (GET_MODE (operands[0]))
1545    && GET_MODE (operands[0]) == GET_MODE (operands[1])"
1546   "* return output_fp_compare (insn, operands, 1, 1);"
1547   [(set_attr "type" "fcmp")
1548    (set_attr "mode" "unknownfp")
1549    (set_attr "athlon_decode" "vector")])
1550
1551 (define_insn "*cmpfp_iu_sse"
1552   [(set (reg:CCFPU 17)
1553         (compare:CCFPU (match_operand 0 "register_operand" "f#x,x#f")
1554                        (match_operand 1 "nonimmediate_operand" "f#x,xm#f")))]
1555   "TARGET_80387
1556    && SSE_FLOAT_MODE_P (GET_MODE (operands[0]))
1557    && GET_MODE (operands[0]) == GET_MODE (operands[1])"
1558   "* return output_fp_compare (insn, operands, 1, 1);"
1559   [(set_attr "type" "fcmp,sse")
1560    (set_attr "mode" "unknownfp")
1561    (set_attr "athlon_decode" "vector")])
1562
1563 (define_insn "*cmpfp_iu_sse_only"
1564   [(set (reg:CCFPU 17)
1565         (compare:CCFPU (match_operand 0 "register_operand" "x")
1566                        (match_operand 1 "nonimmediate_operand" "xm")))]
1567   "SSE_FLOAT_MODE_P (GET_MODE (operands[0]))
1568    && GET_MODE (operands[0]) == GET_MODE (operands[1])"
1569   "* return output_fp_compare (insn, operands, 1, 1);"
1570   [(set_attr "type" "sse")
1571    (set_attr "mode" "unknownfp")
1572    (set_attr "athlon_decode" "vector")])
1573 \f
1574 ;; Move instructions.
1575
1576 ;; General case of fullword move.
1577
1578 (define_expand "movsi"
1579   [(set (match_operand:SI 0 "nonimmediate_operand" "")
1580         (match_operand:SI 1 "general_operand" ""))]
1581   ""
1582   "ix86_expand_move (SImode, operands); DONE;")
1583
1584 ;; Push/pop instructions.  They are separate since autoinc/dec is not a
1585 ;; general_operand.
1586 ;;
1587 ;; %%% We don't use a post-inc memory reference because x86 is not a 
1588 ;; general AUTO_INC_DEC host, which impacts how it is treated in flow.
1589 ;; Changing this impacts compiler performance on other non-AUTO_INC_DEC
1590 ;; targets without our curiosities, and it is just as easy to represent
1591 ;; this differently.
1592
1593 (define_insn "*pushsi2"
1594   [(set (match_operand:SI 0 "push_operand" "=<")
1595         (match_operand:SI 1 "general_no_elim_operand" "ri*m"))]
1596   ""
1597   "push{l}\\t%1"
1598   [(set_attr "type" "push")
1599    (set_attr "mode" "SI")])
1600
1601 (define_insn "*pushsi2_prologue"
1602   [(set (match_operand:SI 0 "push_operand" "=<")
1603         (match_operand:SI 1 "general_no_elim_operand" "ri*m"))
1604    (set (reg:SI 6) (reg:SI 6))]
1605   ""
1606   "push{l}\\t%1"
1607   [(set_attr "type" "push")
1608    (set_attr "mode" "SI")])
1609
1610 (define_insn "*popsi1_epilogue"
1611   [(set (match_operand:SI 0 "nonimmediate_operand" "=r*m")
1612         (mem:SI (reg:SI 7)))
1613    (set (reg:SI 7)
1614         (plus:SI (reg:SI 7) (const_int 4)))
1615    (set (reg:SI 6) (reg:SI 6))]
1616   ""
1617   "pop{l}\\t%0"
1618   [(set_attr "type" "pop")
1619    (set_attr "mode" "SI")])
1620
1621 (define_insn "popsi1"
1622   [(set (match_operand:SI 0 "nonimmediate_operand" "=r*m")
1623         (mem:SI (reg:SI 7)))
1624    (set (reg:SI 7)
1625         (plus:SI (reg:SI 7) (const_int 4)))]
1626   ""
1627   "pop{l}\\t%0"
1628   [(set_attr "type" "pop")
1629    (set_attr "mode" "SI")])
1630
1631 (define_insn "*movsi_xor"
1632   [(set (match_operand:SI 0 "register_operand" "=r")
1633         (match_operand:SI 1 "const0_operand" "i"))
1634    (clobber (reg:CC 17))]
1635   "reload_completed && (!TARGET_USE_MOV0 || optimize_size)"
1636   "xor{l}\\t{%0, %0|%0, %0}"
1637   [(set_attr "type" "alu1")
1638    (set_attr "mode" "SI")
1639    (set_attr "length_immediate" "0")])
1640
1641 (define_insn "*movsi_or"
1642   [(set (match_operand:SI 0 "register_operand" "=r")
1643         (match_operand:SI 1 "immediate_operand" "i"))
1644    (clobber (reg:CC 17))]
1645   "reload_completed && GET_CODE (operands[1]) == CONST_INT
1646    && INTVAL (operands[1]) == -1
1647    && (TARGET_PENTIUM || optimize_size)"
1648   "*
1649 {
1650   operands[1] = constm1_rtx;
1651   return \"or{l}\\t{%1, %0|%0, %1}\";
1652 }"
1653   [(set_attr "type" "alu1")
1654    (set_attr "mode" "SI")
1655    (set_attr "length_immediate" "1")])
1656
1657 (define_insn "*movsi_1"
1658   [(set (match_operand:SI 0 "nonimmediate_operand" "=*a,r,*a,m,!*y,!r")
1659         (match_operand:SI 1 "general_operand" "im,rinm,rinm,rin,r,*y"))]
1660   "GET_CODE (operands[0]) != MEM || GET_CODE (operands[1]) != MEM"
1661   "*
1662 {
1663   switch (get_attr_type (insn))
1664     {
1665     case TYPE_MMX:
1666       return \"movd\\t{%1, %0|%0, %1}\";
1667
1668     case TYPE_LEA:
1669       return \"lea{l}\\t{%1, %0|%0, %1}\";
1670
1671     default:
1672       if (flag_pic && SYMBOLIC_CONST (operands[1]))
1673         abort();
1674       return \"mov{l}\\t{%1, %0|%0, %1}\";
1675     }
1676 }"
1677   [(set (attr "type")
1678      (cond [(ior (match_operand:SI 0 "mmx_reg_operand" "")
1679                  (match_operand:SI 1 "mmx_reg_operand" ""))
1680               (const_string "mmx")
1681             (and (ne (symbol_ref "flag_pic") (const_int 0))
1682                  (match_operand:SI 1 "symbolic_operand" ""))
1683               (const_string "lea")
1684            ]
1685            (const_string "imov")))
1686    (set_attr "modrm" "0,*,0,*,*,*")
1687    (set_attr "mode" "SI")])
1688
1689 (define_insn "*swapsi"
1690   [(set (match_operand:SI 0 "register_operand" "+r")
1691         (match_operand:SI 1 "register_operand" "+r"))
1692    (set (match_dup 1)
1693         (match_dup 0))]
1694   ""
1695   "xchg{l}\\t%1, %0"
1696   [(set_attr "type" "imov")
1697    (set_attr "pent_pair" "np")
1698    (set_attr "athlon_decode" "vector")
1699    (set_attr "mode" "SI")
1700    (set_attr "modrm" "0")
1701    (set_attr "ppro_uops" "few")])
1702
1703 (define_expand "movhi"
1704   [(set (match_operand:HI 0 "nonimmediate_operand" "")
1705         (match_operand:HI 1 "general_operand" ""))]
1706   ""
1707   "ix86_expand_move (HImode, operands); DONE;")
1708
1709 (define_insn "*pushhi2"
1710   [(set (match_operand:HI 0 "push_operand" "=<,<")
1711         (match_operand:HI 1 "general_no_elim_operand" "n,r*m"))]
1712   ""
1713   "@
1714    push{w}\\t{|WORD PTR }%1
1715    push{w}\\t%1"
1716   [(set_attr "type" "push")
1717    (set_attr "mode" "HI")])
1718
1719 (define_insn "*pophi1"
1720   [(set (match_operand:HI 0 "nonimmediate_operand" "=r*m")
1721         (mem:HI (reg:SI 7)))
1722    (set (reg:SI 7)
1723         (plus:SI (reg:SI 7) (const_int 2)))]
1724   ""
1725   "pop{w}\\t%0"
1726   [(set_attr "type" "pop")
1727    (set_attr "mode" "HI")])
1728
1729 (define_insn "*movhi_1"
1730   [(set (match_operand:HI 0 "nonimmediate_operand" "=*a,r,r,*a,r,m")
1731         (match_operand:HI 1 "general_operand" "i,r,rn,rm,rm,rn"))]
1732   "GET_CODE (operands[0]) != MEM || GET_CODE (operands[1]) != MEM"
1733   "*
1734 {
1735   switch (get_attr_type (insn))
1736     {
1737     case TYPE_IMOVX:
1738       /* movzwl is faster than movw on p2 due to partial word stalls,
1739          though not as fast as an aligned movl.  */
1740       return \"movz{wl|x}\\t{%1, %k0|%k0, %1}\";
1741     default:
1742       if (get_attr_mode (insn) == MODE_SI)
1743         return \"mov{l}\\t{%k1, %k0|%k0, %k1}\";
1744       else
1745         return \"mov{w}\\t{%1, %0|%0, %1}\";
1746     }
1747 }"
1748   [(set (attr "type")
1749      (cond [(and (eq_attr "alternative" "0,1")
1750                  (ior (eq (symbol_ref "TARGET_PARTIAL_REG_STALL")
1751                           (const_int 0))
1752                       (eq (symbol_ref "TARGET_HIMODE_MATH")
1753                           (const_int 0))))
1754               (const_string "imov")
1755             (and (eq_attr "alternative" "2,3,4")
1756                  (match_operand:HI 1 "aligned_operand" ""))
1757               (const_string "imov")
1758             (and (ne (symbol_ref "TARGET_MOVX")
1759                      (const_int 0))
1760                  (eq_attr "alternative" "0,1,3,4"))
1761               (const_string "imovx")
1762            ]
1763            (const_string "imov")))
1764     (set (attr "mode")
1765       (cond [(eq_attr "type" "imovx")
1766                (const_string "SI")
1767              (and (eq_attr "alternative" "2,3,4")
1768                   (match_operand:HI 1 "aligned_operand" ""))
1769                (const_string "SI")
1770              (and (eq_attr "alternative" "0,1")
1771                   (ior (eq (symbol_ref "TARGET_PARTIAL_REG_STALL")
1772                            (const_int 0))
1773                        (eq (symbol_ref "TARGET_HIMODE_MATH")
1774                            (const_int 0))))
1775                (const_string "SI")
1776             ]
1777             (const_string "HI")))
1778    (set_attr "modrm" "0,*,*,0,*,*")])
1779
1780 (define_insn "*swaphi_1"
1781   [(set (match_operand:HI 0 "register_operand" "+r")
1782         (match_operand:HI 1 "register_operand" "+r"))
1783    (set (match_dup 1)
1784         (match_dup 0))]
1785   "TARGET_PARTIAL_REG_STALL"
1786   "xchg{w}\\t%1, %0"
1787   [(set_attr "type" "imov")
1788    (set_attr "pent_pair" "np")
1789    (set_attr "mode" "HI")
1790    (set_attr "modrm" "0")
1791    (set_attr "ppro_uops" "few")])
1792
1793 (define_insn "*swaphi_2"
1794   [(set (match_operand:HI 0 "register_operand" "+r")
1795         (match_operand:HI 1 "register_operand" "+r"))
1796    (set (match_dup 1)
1797         (match_dup 0))]
1798   "! TARGET_PARTIAL_REG_STALL"
1799   "xchg{l}\\t%k1, %k0"
1800   [(set_attr "type" "imov")
1801    (set_attr "pent_pair" "np")
1802    (set_attr "mode" "SI")
1803    (set_attr "modrm" "0")
1804    (set_attr "ppro_uops" "few")])
1805
1806 (define_expand "movstricthi"
1807   [(set (strict_low_part (match_operand:HI 0 "nonimmediate_operand" ""))
1808         (match_operand:HI 1 "general_operand" ""))]
1809   "! TARGET_PARTIAL_REG_STALL"
1810   "
1811 {
1812   /* Don't generate memory->memory moves, go through a register */
1813   if (GET_CODE (operands[0]) == MEM && GET_CODE (operands[1]) == MEM)
1814     operands[1] = force_reg (HImode, operands[1]);
1815 }")
1816
1817 (define_insn "*movstricthi_1"
1818   [(set (strict_low_part (match_operand:HI 0 "nonimmediate_operand" "+rm,r"))
1819         (match_operand:HI 1 "general_operand" "rn,m"))]
1820   "! TARGET_PARTIAL_REG_STALL
1821    && (GET_CODE (operands[0]) != MEM || GET_CODE (operands[1]) != MEM)"
1822   "mov{w}\\t{%1, %0|%0, %1}"
1823   [(set_attr "type" "imov")
1824    (set_attr "mode" "HI")])
1825
1826 (define_insn "*movstricthi_xor"
1827   [(set (strict_low_part (match_operand:HI 0 "register_operand" "+r"))
1828         (match_operand:HI 1 "const0_operand" "i"))
1829    (clobber (reg:CC 17))]
1830   "reload_completed && (!TARGET_USE_MOV0 || optimize_size)"
1831   "xor{w}\\t{%0, %0|%0, %0}"
1832   [(set_attr "type" "alu1")
1833    (set_attr "mode" "HI")
1834    (set_attr "length_immediate" "0")])
1835
1836 (define_expand "movqi"
1837   [(set (match_operand:QI 0 "nonimmediate_operand" "")
1838         (match_operand:QI 1 "general_operand" ""))]
1839   ""
1840   "ix86_expand_move (QImode, operands); DONE;")
1841
1842 ;; emit_push_insn when it calls move_by_pieces requires an insn to
1843 ;; "push a byte".  But actually we use pushw, which has the effect
1844 ;; of rounding the amount pushed up to a halfword.
1845
1846 (define_insn "*pushqi2"
1847   [(set (match_operand:QI 0 "push_operand" "=<,<")
1848         (match_operand:QI 1 "nonmemory_no_elim_operand" "n,r"))]
1849   ""
1850   "@
1851    push{w}\\t{|word ptr }%1
1852    push{w}\\t%w1"
1853   [(set_attr "type" "push")
1854    (set_attr "mode" "HI")])
1855
1856 (define_insn "*popqi1"
1857   [(set (match_operand:QI 0 "nonimmediate_operand" "=r*m")
1858         (mem:QI (reg:SI 7)))
1859    (set (reg:SI 7)
1860         (plus:SI (reg:SI 7) (const_int 2)))]
1861   ""
1862   "pop{w}\\t%0"
1863   [(set_attr "type" "pop")
1864    (set_attr "mode" "HI")])
1865
1866 ;; Situation is quite tricky about when to choose full sized (SImode) move
1867 ;; over QImode moves.  For Q_REG -> Q_REG move we use full size only for
1868 ;; partial register dependency machines (such as AMD Athlon), where QImode
1869 ;; moves issue extra dependency and for partial register stalls machines
1870 ;; that don't use QImode patterns (and QImode move cause stall on the next
1871 ;; instruction).
1872 ;;
1873 ;; For loads of Q_REG to NONQ_REG we use full sized moves except for partial
1874 ;; register stall machines with, where we use QImode instructions, since
1875 ;; partial register stall can be caused there.  Then we use movzx.
1876 (define_insn "*movqi_1"
1877   [(set (match_operand:QI 0 "nonimmediate_operand" "=q,q ,q ,r,r ,?r,m")
1878         (match_operand:QI 1 "general_operand"      " q,qn,qm,q,rn,qm,qn"))]
1879   "GET_CODE (operands[0]) != MEM || GET_CODE (operands[1]) != MEM"
1880   "*
1881 {
1882   switch (get_attr_type (insn))
1883     {
1884     case TYPE_IMOVX:
1885       if (!QI_REG_P (operands[1]) && GET_CODE (operands[1]) != MEM)
1886         abort ();
1887       return \"movz{bl|x}\\t{%1, %k0|%k0, %1}\";
1888     default:
1889       if (get_attr_mode (insn) == MODE_SI)
1890         return \"mov{l}\\t{%k1, %k0|%k0, %k1}\";
1891       else
1892         return \"mov{b}\\t{%1, %0|%0, %1}\";
1893     }
1894 }"
1895   [(set (attr "type")
1896      (cond [(and (eq_attr "alternative" "3")
1897                  (ior (eq (symbol_ref "TARGET_PARTIAL_REG_STALL")
1898                           (const_int 0))
1899                       (eq (symbol_ref "TARGET_QIMODE_MATH")
1900                           (const_int 0))))
1901               (const_string "imov")
1902             (eq_attr "alternative" "3,5")
1903               (const_string "imovx")
1904             (and (ne (symbol_ref "TARGET_MOVX")
1905                      (const_int 0))
1906                  (eq_attr "alternative" "2"))
1907               (const_string "imovx")
1908            ]
1909            (const_string "imov")))
1910    (set (attr "mode")
1911       (cond [(eq_attr "alternative" "3,4,5")
1912                (const_string "SI")
1913              (eq_attr "alternative" "6")
1914                (const_string "QI")
1915              (eq_attr "type" "imovx")
1916                (const_string "SI")
1917              (and (eq_attr "type" "imov")
1918                   (and (eq_attr "alternative" "0,1,2")
1919                        (ne (symbol_ref "TARGET_PARTIAL_REG_DEPENDENCY")
1920                            (const_int 0))))
1921                (const_string "SI")
1922              ;; Avoid partial register stalls when not using QImode arithmetic
1923              (and (eq_attr "type" "imov")
1924                   (and (eq_attr "alternative" "0,1,2")
1925                        (and (ne (symbol_ref "TARGET_PARTIAL_REG_STALL")
1926                                 (const_int 0))
1927                             (eq (symbol_ref "TARGET_QIMODE_MATH")
1928                                 (const_int 0)))))
1929                (const_string "SI")
1930            ]
1931            (const_string "QI")))])
1932
1933 (define_expand "reload_outqi"
1934   [(parallel [(match_operand:QI 0 "" "=m")
1935               (match_operand:QI 1 "register_operand" "r")
1936               (match_operand:QI 2 "register_operand" "=&q")])]
1937   ""
1938   "
1939 {
1940   rtx op0, op1, op2;
1941   op0 = operands[0]; op1 = operands[1]; op2 = operands[2];
1942
1943   if (reg_overlap_mentioned_p (op2, op0))
1944     abort ();
1945   if (! q_regs_operand (op1, QImode))
1946     {
1947       emit_insn (gen_movqi (op2, op1));
1948       op1 = op2;
1949     }
1950   emit_insn (gen_movqi (op0, op1));
1951   DONE;
1952 }")
1953
1954 (define_insn "*swapqi"
1955   [(set (match_operand:QI 0 "register_operand" "+r")
1956         (match_operand:QI 1 "register_operand" "+r"))
1957    (set (match_dup 1)
1958         (match_dup 0))]
1959   ""
1960   "xchg{b}\\t%1, %0"
1961   [(set_attr "type" "imov")
1962    (set_attr "pent_pair" "np")
1963    (set_attr "mode" "QI")
1964    (set_attr "modrm" "0")
1965    (set_attr "ppro_uops" "few")])
1966
1967 (define_expand "movstrictqi"
1968   [(set (strict_low_part (match_operand:QI 0 "nonimmediate_operand" ""))
1969         (match_operand:QI 1 "general_operand" ""))]
1970   "! TARGET_PARTIAL_REG_STALL"
1971   "
1972 {
1973   /* Don't generate memory->memory moves, go through a register */
1974   if (GET_CODE (operands[0]) == MEM && GET_CODE (operands[1]) == MEM)
1975     operands[1] = force_reg (QImode, operands[1]);
1976 }")
1977
1978 (define_insn "*movstrictqi_1"
1979   [(set (strict_low_part (match_operand:QI 0 "nonimmediate_operand" "+qm,q"))
1980         (match_operand:QI 1 "general_operand" "*qn,m"))]
1981   "! TARGET_PARTIAL_REG_STALL
1982    && (GET_CODE (operands[0]) != MEM || GET_CODE (operands[1]) != MEM)"
1983   "mov{b}\\t{%1, %0|%0, %1}"
1984   [(set_attr "type" "imov")
1985    (set_attr "mode" "QI")])
1986
1987 (define_insn "*movstrictqi_xor"
1988   [(set (strict_low_part (match_operand:QI 0 "q_regs_operand" "+q"))
1989         (match_operand:QI 1 "const0_operand" "i"))
1990    (clobber (reg:CC 17))]
1991   "reload_completed && (!TARGET_USE_MOV0 || optimize_size)"
1992   "xor{b}\\t{%0, %0|%0, %0}"
1993   [(set_attr "type" "alu1")
1994    (set_attr "mode" "QI")
1995    (set_attr "length_immediate" "0")])
1996
1997 (define_insn "*movsi_extv_1"
1998   [(set (match_operand:SI 0 "register_operand" "=r")
1999         (sign_extract:SI (match_operand:SI 1 "register_operand" "q")
2000                          (const_int 8)
2001                          (const_int 8)))]
2002   ""
2003   "movs{bl|x}\\t{%h1, %0|%0, %h1}"
2004   [(set_attr "type" "imovx")
2005    (set_attr "mode" "SI")])
2006
2007 (define_insn "*movhi_extv_1"
2008   [(set (match_operand:HI 0 "register_operand" "=r")
2009         (sign_extract:HI (match_operand:SI 1 "register_operand" "q")
2010                          (const_int 8)
2011                          (const_int 8)))]
2012   ""
2013   "movs{bl|x}\\t{%h1, %k0|%k0, %h1}"
2014   [(set_attr "type" "imovx")
2015    (set_attr "mode" "SI")])
2016
2017 (define_insn "*movqi_extv_1"
2018   [(set (match_operand:QI 0 "nonimmediate_operand" "=qm,?r")
2019         (sign_extract:QI (match_operand:SI 1 "register_operand" "q,q")
2020                          (const_int 8)
2021                          (const_int 8)))]
2022   ""
2023   "*
2024 {
2025   switch (get_attr_type (insn))
2026     {
2027     case TYPE_IMOVX:
2028       return \"movs{bl|x}\\t{%h1, %k0|%k0, %h1}\";
2029     default:
2030       return \"mov{b}\\t{%h1, %0|%0, %h1}\";
2031     }
2032 }"
2033   [(set (attr "type")
2034      (if_then_else (and (match_operand:QI 0 "register_operand" "")
2035                         (ior (not (match_operand:QI 0 "q_regs_operand" ""))
2036                              (ne (symbol_ref "TARGET_MOVX")
2037                                  (const_int 0))))
2038         (const_string "imovx")
2039         (const_string "imov")))
2040    (set (attr "mode")
2041      (if_then_else (eq_attr "type" "imovx")
2042         (const_string "SI")
2043         (const_string "QI")))])
2044
2045 (define_insn "*movsi_extzv_1"
2046   [(set (match_operand:SI 0 "register_operand" "=r")
2047         (zero_extract:SI (match_operand 1 "ext_register_operand" "q")
2048                          (const_int 8)
2049                          (const_int 8)))]
2050   ""
2051   "movz{bl|x}\\t{%h1, %0|%0, %h1}"
2052   [(set_attr "type" "imovx")
2053    (set_attr "mode" "SI")])
2054
2055 (define_insn "*movqi_extzv_1"
2056   [(set (match_operand:QI 0 "nonimmediate_operand" "=qm,?r")
2057         (subreg:QI (zero_extract:SI (match_operand 1 "ext_register_operand" "q,q")
2058                                     (const_int 8)
2059                                     (const_int 8)) 0))]
2060   ""
2061   "*
2062 {
2063   switch (get_attr_type (insn))
2064     {
2065     case TYPE_IMOVX:
2066       return \"movz{bl|x}\\t{%h1, %k0|%k0, %h1}\";
2067     default:
2068       return \"mov{b}\\t{%h1, %0|%0, %h1}\";
2069     }
2070 }"
2071   [(set (attr "type")
2072      (if_then_else (and (match_operand:QI 0 "register_operand" "")
2073                         (ior (not (match_operand:QI 0 "q_regs_operand" ""))
2074                              (ne (symbol_ref "TARGET_MOVX")
2075                                  (const_int 0))))
2076         (const_string "imovx")
2077         (const_string "imov")))
2078    (set (attr "mode")
2079      (if_then_else (eq_attr "type" "imovx")
2080         (const_string "SI")
2081         (const_string "QI")))])
2082
2083 (define_insn "*movsi_insv_1"
2084   [(set (zero_extract:SI (match_operand 0 "ext_register_operand" "+q")
2085                          (const_int 8)
2086                          (const_int 8))
2087         (match_operand:SI 1 "nonimmediate_operand" "qm"))]
2088   ""
2089   "mov{b}\\t{%b1, %h0|%h0, %b1}"
2090   [(set_attr "type" "imov")
2091    (set_attr "mode" "QI")])
2092
2093 (define_insn "*movqi_insv_2"
2094   [(set (zero_extract:SI (match_operand 0 "ext_register_operand" "+q")
2095                          (const_int 8)
2096                          (const_int 8))
2097         (and:SI (lshiftrt:SI (match_operand:SI 1 "register_operand" "q")
2098                              (const_int 8))
2099                 (const_int 255)))]
2100   ""
2101   "mov{b}\\t{%h1, %h0|%h0, %h1}"
2102   [(set_attr "type" "imov")
2103    (set_attr "mode" "QI")])
2104
2105 (define_expand "movdi"
2106   [(set (match_operand:DI 0 "nonimmediate_operand" "")
2107         (match_operand:DI 1 "general_operand" ""))]
2108   ""
2109   "ix86_expand_move (DImode, operands); DONE;")
2110
2111 (define_insn "*pushdi"
2112   [(set (match_operand:DI 0 "push_operand" "=<")
2113         (match_operand:DI 1 "general_no_elim_operand" "riF*m"))]
2114   ""
2115   "#")
2116
2117 (define_insn "*movdi_2"
2118   [(set (match_operand:DI 0 "nonimmediate_operand" "=r,o,!m*y,!*y")
2119         (match_operand:DI 1 "general_operand" "riFo,riF,*y,m"))]
2120   "GET_CODE (operands[0]) != MEM || GET_CODE (operands[1]) != MEM"
2121   "@
2122    #
2123    #
2124    movq\\t{%1, %0|%0, %1}
2125    movq\\t{%1, %0|%0, %1}"
2126   [(set_attr "type" "*,*,mmx,mmx")])
2127
2128 (define_split
2129   [(set (match_operand:DI 0 "push_operand" "")
2130         (match_operand:DI 1 "general_operand" ""))]
2131   "reload_completed && ! MMX_REG_P (operands[1])"
2132   [(const_int 0)]
2133   "if (!ix86_split_long_move (operands)) abort (); DONE;")
2134
2135 ;; %%% This multiword shite has got to go.
2136 (define_split
2137   [(set (match_operand:DI 0 "nonimmediate_operand" "")
2138         (match_operand:DI 1 "general_operand" ""))]
2139   "reload_completed && ! MMX_REG_P (operands[0]) && ! MMX_REG_P (operands[1])"
2140   [(set (match_dup 2) (match_dup 5))
2141    (set (match_dup 3) (match_dup 6))]
2142   "if (ix86_split_long_move (operands)) DONE;")
2143   
2144 (define_expand "movsf"
2145   [(set (match_operand:SF 0 "nonimmediate_operand" "")
2146         (match_operand:SF 1 "general_operand" ""))]
2147   ""
2148   "ix86_expand_move (SFmode, operands); DONE;")
2149
2150 (define_insn "*pushsf"
2151   [(set (match_operand:SF 0 "push_operand" "=<,<,<")
2152         (match_operand:SF 1 "general_no_elim_operand" "f#rx,rFm#fx,x#rf"))]
2153   ""
2154   "*
2155 {
2156   switch (which_alternative)
2157     {
2158     case 0:
2159       /* %%% We loose REG_DEAD notes for controling pops if we split late.  */
2160       operands[0] = gen_rtx_MEM (SFmode, stack_pointer_rtx);
2161       operands[2] = stack_pointer_rtx;
2162       operands[3] = GEN_INT (4);
2163       if (find_regno_note (insn, REG_DEAD, REGNO (operands[1])))
2164         return \"sub{l}\\t{%3, %2|%2, %3}\;fstp%z0\\t%y0\";
2165       else
2166         return \"sub{l}\\t{%3, %2|%2, %3}\;fst%z0\\t%y0\";
2167
2168     case 1:
2169       return \"push{l}\\t%1\";
2170     case 2:
2171       return \"#\";
2172
2173     default:
2174       abort ();
2175     }
2176 }"
2177   [(set_attr "type" "multi,push,multi")
2178    (set_attr "mode" "SF,SI,SF")])
2179
2180 (define_split
2181   [(set (match_operand:SF 0 "push_operand" "")
2182         (match_operand:SF 1 "memory_operand" ""))]
2183   "reload_completed
2184    && GET_CODE (operands[1]) == MEM
2185    && GET_CODE (XEXP (operands[1], 0)) == SYMBOL_REF
2186    && CONSTANT_POOL_ADDRESS_P (XEXP (operands[1], 0))"
2187   [(set (match_dup 0)
2188         (match_dup 1))]
2189   "operands[1] = get_pool_constant (XEXP (operands[1], 0));")
2190
2191
2192 ;; %%% Kill this when call knows how to work this out.
2193 (define_split
2194   [(set (match_operand:SF 0 "push_operand" "")
2195         (match_operand:SF 1 "register_operand" ""))]
2196   "ANY_FP_REGNO_P (REGNO (operands[1]))"
2197   [(set (reg:SI 7) (plus:SI (reg:SI 7) (const_int -4)))
2198    (set (mem:SF (reg:SI 7)) (match_dup 1))])
2199
2200 (define_insn "*movsf_1"
2201   [(set (match_operand:SF 0 "nonimmediate_operand" "=f#xr,m,f#xr,r#xf,m,x#rf,x#rf,x#rf,m")
2202         (match_operand:SF 1 "general_operand" "fm#rx,f#rx,G,rmF#fx,Fr#fx,H,x,xm#rf,x#rf"))]
2203   "(GET_CODE (operands[0]) != MEM || GET_CODE (operands[1]) != MEM)
2204    && (reload_in_progress || reload_completed
2205        || GET_CODE (operands[1]) != CONST_DOUBLE
2206        || memory_operand (operands[0], SFmode))" 
2207   "*
2208 {
2209   switch (which_alternative)
2210     {
2211     case 0:
2212       if (REG_P (operands[1])
2213           && find_regno_note (insn, REG_DEAD, REGNO (operands[1])))
2214         return \"fstp\\t%y0\";
2215       else if (STACK_TOP_P (operands[0]))
2216         return \"fld%z1\\t%y1\";
2217       else
2218         return \"fst\\t%y0\";
2219
2220     case 1:
2221       if (find_regno_note (insn, REG_DEAD, REGNO (operands[1])))
2222         return \"fstp%z0\\t%y0\";
2223       else
2224         return \"fst%z0\\t%y0\";
2225
2226     case 2:
2227       switch (standard_80387_constant_p (operands[1]))
2228         {
2229         case 1:
2230           return \"fldz\";
2231         case 2:
2232           return \"fld1\";
2233         }
2234       abort();
2235
2236     case 3:
2237     case 4:
2238       return \"mov{l}\\t{%1, %0|%0, %1}\";
2239     case 5:
2240       return \"pxor\\t%0, %0\";
2241     case 6:
2242       if (TARGET_PARTIAL_REG_DEPENDENCY)
2243         return \"movaps\\t{%1, %0|%0, %1}\";
2244       else
2245         return \"movss\\t{%1, %0|%0, %1}\";
2246     case 7:
2247     case 8:
2248       return \"movss\\t{%1, %0|%0, %1}\";
2249
2250     default:
2251       abort();
2252     }
2253 }"
2254   [(set_attr "type" "fmov,fmov,fmov,imov,imov,sse,sse,sse,sse")
2255    (set_attr "mode" "SF,SF,SF,SI,SI,TI,SF,SF,SF")])
2256
2257 (define_insn "*swapsf"
2258   [(set (match_operand:SF 0 "register_operand" "+f")
2259         (match_operand:SF 1 "register_operand" "+f"))
2260    (set (match_dup 1)
2261         (match_dup 0))]
2262   "reload_completed || !TARGET_SSE2"
2263   "*
2264 {
2265   if (STACK_TOP_P (operands[0]))
2266     return \"fxch\\t%1\";
2267   else
2268     return \"fxch\\t%0\";
2269 }"
2270   [(set_attr "type" "fxch")
2271    (set_attr "mode" "SF")])
2272
2273 (define_expand "movdf"
2274   [(set (match_operand:DF 0 "nonimmediate_operand" "")
2275         (match_operand:DF 1 "general_operand" ""))]
2276   ""
2277   "ix86_expand_move (DFmode, operands); DONE;")
2278
2279 ;; Size of pushdf is 3 (for sub) + 2 (for fstp) + memory operand size.
2280 ;; Size of pushdf using integer insturctions is 2+2*memory operand size
2281 ;; On the average, pushdf using integers can be still shorter.  Allow this
2282 ;; pattern for optimize_size too.
2283
2284 (define_insn "*pushdf_nointeger"
2285   [(set (match_operand:DF 0 "push_operand" "=<,<,<,<")
2286         (match_operand:DF 1 "general_no_elim_operand" "f#Y,Fo#fY,*r#fY,Y#f"))]
2287   "!TARGET_INTEGER_DFMODE_MOVES"
2288   "*
2289 {
2290   switch (which_alternative)
2291     {
2292     case 0:
2293       /* %%% We loose REG_DEAD notes for controling pops if we split late.  */
2294       operands[0] = gen_rtx_MEM (DFmode, stack_pointer_rtx);
2295       operands[2] = stack_pointer_rtx;
2296       operands[3] = GEN_INT (8);
2297       if (find_regno_note (insn, REG_DEAD, REGNO (operands[1])))
2298         return \"sub{l}\\t{%3, %2|%2, %3}\;fstp%z0\\t%y0\";
2299       else
2300         return \"sub{l}\\t{%3, %2|%2, %3}\;fst%z0\\t%y0\";
2301
2302     case 1:
2303     case 2:
2304     case 3:
2305       return \"#\";
2306
2307     default:
2308       abort ();
2309     }
2310 }"
2311   [(set_attr "type" "multi")
2312    (set_attr "mode" "DF,SI,SI,DF")])
2313
2314 (define_insn "*pushdf_integer"
2315   [(set (match_operand:DF 0 "push_operand" "=<,<,<")
2316         (match_operand:DF 1 "general_no_elim_operand" "f#rY,rFo#fY,Y#rf"))]
2317   "TARGET_INTEGER_DFMODE_MOVES"
2318   "*
2319 {
2320   switch (which_alternative)
2321     {
2322     case 0:
2323       /* %%% We loose REG_DEAD notes for controling pops if we split late.  */
2324       operands[0] = gen_rtx_MEM (DFmode, stack_pointer_rtx);
2325       operands[2] = stack_pointer_rtx;
2326       operands[3] = GEN_INT (8);
2327       if (find_regno_note (insn, REG_DEAD, REGNO (operands[1])))
2328         return \"sub{l}\\t{%3, %2|%2, %3}\;fstp%z0\\t%y0\";
2329       else
2330         return \"sub{l}\\t{%3, %2|%2, %3}\;fst%z0\\t%y0\";
2331
2332     case 1:
2333     case 2:
2334       return \"#\";
2335
2336     default:
2337       abort ();
2338     }
2339 }"
2340   [(set_attr "type" "multi")
2341    (set_attr "mode" "DF,SI,DF")])
2342
2343 ;; %%% Kill this when call knows how to work this out.
2344 (define_split
2345   [(set (match_operand:DF 0 "push_operand" "")
2346         (match_operand:DF 1 "register_operand" ""))]
2347   "reload_completed && ANY_FP_REGNO_P (REGNO (operands[1]))"
2348   [(set (reg:SI 7) (plus:SI (reg:SI 7) (const_int -8)))
2349    (set (mem:DF (reg:SI 7)) (match_dup 1))]
2350   "")
2351
2352 (define_split
2353   [(set (match_operand:DF 0 "push_operand" "")
2354         (match_operand:DF 1 "general_operand" ""))]
2355   "reload_completed"
2356   [(const_int 0)]
2357   "if (!ix86_split_long_move (operands)) abort (); DONE;")
2358
2359 ;; Moving is usually shorter when only FP registers are used. This separate
2360 ;; movdf pattern avoids the use of integer registers for FP operations
2361 ;; when optimizing for size.
2362
2363 (define_insn "*movdf_nointeger"
2364   [(set (match_operand:DF 0 "nonimmediate_operand" "=f#Y,m,f#Y,*r,o,Y#f,Y#f,Y#f,m")
2365         (match_operand:DF 1 "general_operand" "fm#Y,f#Y,G,*roF,F*r,H,Y#f,YHm#f,Y#f"))]
2366   "(GET_CODE (operands[0]) != MEM || GET_CODE (operands[1]) != MEM)
2367    && (optimize_size || !TARGET_INTEGER_DFMODE_MOVES)
2368    && (reload_in_progress || reload_completed
2369        || GET_CODE (operands[1]) != CONST_DOUBLE
2370        || memory_operand (operands[0], DFmode))" 
2371   "*
2372 {
2373   switch (which_alternative)
2374     {
2375     case 0:
2376       if (REG_P (operands[1])
2377           && find_regno_note (insn, REG_DEAD, REGNO (operands[1])))
2378         return \"fstp\\t%y0\";
2379       else if (STACK_TOP_P (operands[0]))
2380         return \"fld%z1\\t%y1\";
2381       else
2382         return \"fst\\t%y0\";
2383
2384     case 1:
2385       if (find_regno_note (insn, REG_DEAD, REGNO (operands[1])))
2386         return \"fstp%z0\\t%y0\";
2387       else
2388         return \"fst%z0\\t%y0\";
2389
2390     case 2:
2391       switch (standard_80387_constant_p (operands[1]))
2392         {
2393         case 1:
2394           return \"fldz\";
2395         case 2:
2396           return \"fld1\";
2397         }
2398       abort();
2399
2400     case 3:
2401     case 4:
2402       return \"#\";
2403     case 5:
2404       return \"pxor\\t%0, %0\";
2405     case 6:
2406       if (TARGET_PARTIAL_REG_DEPENDENCY)
2407         return \"movapd\\t{%1, %0|%0, %1}\";
2408       else
2409         return \"movsd\\t{%1, %0|%0, %1}\";
2410     case 7:
2411     case 8:
2412         return \"movsd\\t{%1, %0|%0, %1}\";
2413
2414     default:
2415       abort();
2416     }
2417 }"
2418   [(set_attr "type" "fmov,fmov,fmov,multi,multi,sse,sse,sse,sse")
2419    (set_attr "mode" "DF,DF,DF,SI,SI,TI,DF,DF,DF")])
2420
2421 (define_insn "*movdf_integer"
2422   [(set (match_operand:DF 0 "nonimmediate_operand" "=f#Yr,m,f#Yr,r#Yf,o,Y#rf,Y#rf,Y#rf,m")
2423         (match_operand:DF 1 "general_operand" "fm#Yr,f#Yr,G,roF#Yf,Fr#Yf,H,Y#rf,Ym#rf,Y#rf"))]
2424   "(GET_CODE (operands[0]) != MEM || GET_CODE (operands[1]) != MEM)
2425    && !optimize_size && TARGET_INTEGER_DFMODE_MOVES
2426    && (reload_in_progress || reload_completed
2427        || GET_CODE (operands[1]) != CONST_DOUBLE
2428        || memory_operand (operands[0], DFmode))" 
2429   "*
2430 {
2431   switch (which_alternative)
2432     {
2433     case 0:
2434       if (REG_P (operands[1])
2435           && find_regno_note (insn, REG_DEAD, REGNO (operands[1])))
2436         return \"fstp\\t%y0\";
2437       else if (STACK_TOP_P (operands[0]))
2438         return \"fld%z1\\t%y1\";
2439       else
2440         return \"fst\\t%y0\";
2441
2442     case 1:
2443       if (find_regno_note (insn, REG_DEAD, REGNO (operands[1])))
2444         return \"fstp%z0\\t%y0\";
2445       else
2446         return \"fst%z0\\t%y0\";
2447
2448     case 2:
2449       switch (standard_80387_constant_p (operands[1]))
2450         {
2451         case 1:
2452           return \"fldz\";
2453         case 2:
2454           return \"fld1\";
2455         }
2456       abort();
2457
2458     case 3:
2459     case 4:
2460       return \"#\";
2461
2462     case 5:
2463       return \"pxor\\t%0, %0\";
2464     case 6:
2465       if (TARGET_PARTIAL_REG_DEPENDENCY)
2466         return \"movapd\\t{%1, %0|%0, %1}\";
2467       else
2468         return \"movsd\\t{%1, %0|%0, %1}\";
2469     case 7:
2470     case 8:
2471       return \"movsd\\t{%1, %0|%0, %1}\";
2472
2473     default:
2474       abort();
2475     }
2476 }"
2477   [(set_attr "type" "fmov,fmov,fmov,multi,multi,sse,sse,sse,sse")
2478    (set_attr "mode" "DF,DF,DF,SI,SI,TI,DF,DF,DF")])
2479
2480 (define_split
2481   [(set (match_operand:DF 0 "nonimmediate_operand" "")
2482         (match_operand:DF 1 "general_operand" ""))]
2483   "reload_completed
2484    && (GET_CODE (operands[0]) != MEM || GET_CODE (operands[1]) != MEM)
2485    && ! (ANY_FP_REG_P (operands[0]) || 
2486          (GET_CODE (operands[0]) == SUBREG
2487           && ANY_FP_REG_P (SUBREG_REG (operands[0]))))
2488    && ! (ANY_FP_REG_P (operands[1]) || 
2489          (GET_CODE (operands[1]) == SUBREG
2490           && ANY_FP_REG_P (SUBREG_REG (operands[1]))))"
2491   [(set (match_dup 2) (match_dup 5))
2492    (set (match_dup 3) (match_dup 6))]
2493   "if (ix86_split_long_move (operands)) DONE;")
2494
2495 (define_insn "*swapdf"
2496   [(set (match_operand:DF 0 "register_operand" "+f")
2497         (match_operand:DF 1 "register_operand" "+f"))
2498    (set (match_dup 1)
2499         (match_dup 0))]
2500   "reload_completed || !TARGET_SSE2"
2501   "*
2502 {
2503   if (STACK_TOP_P (operands[0]))
2504     return \"fxch\\t%1\";
2505   else
2506     return \"fxch\\t%0\";
2507 }"
2508   [(set_attr "type" "fxch")
2509    (set_attr "mode" "DF")])
2510
2511 (define_expand "movxf"
2512   [(set (match_operand:XF 0 "nonimmediate_operand" "")
2513         (match_operand:XF 1 "general_operand" ""))]
2514   ""
2515   "ix86_expand_move (XFmode, operands); DONE;")
2516
2517 (define_expand "movtf"
2518   [(set (match_operand:TF 0 "nonimmediate_operand" "")
2519         (match_operand:TF 1 "general_operand" ""))]
2520   ""
2521   "ix86_expand_move (TFmode, operands); DONE;")
2522
2523 ;; Size of pushdf is 3 (for sub) + 2 (for fstp) + memory operand size.
2524 ;; Size of pushdf using integer insturctions is 3+3*memory operand size
2525 ;; Pushing using integer instructions is longer except for constants
2526 ;; and direct memory references.
2527 ;; (assuming that any given constant is pushed only once, but this ought to be
2528 ;;  handled elsewhere).
2529
2530 (define_insn "*pushxf_nointeger"
2531   [(set (match_operand:XF 0 "push_operand" "=<,<,<")
2532         (match_operand:XF 1 "general_no_elim_operand" "f,Fo,*r"))]
2533   "optimize_size"
2534   "*
2535 {
2536   switch (which_alternative)
2537     {
2538     case 0:
2539       /* %%% We loose REG_DEAD notes for controling pops if we split late.  */
2540       operands[0] = gen_rtx_MEM (XFmode, stack_pointer_rtx);
2541       operands[2] = stack_pointer_rtx;
2542       operands[3] = GEN_INT (12);
2543       if (find_regno_note (insn, REG_DEAD, REGNO (operands[1])))
2544         return \"sub{l}\\t{%3, %2|%2, %3}\;fstp%z0\\t%y0\";
2545       else
2546         return \"sub{l}\\t{%3, %2|%2, %3}\;fst%z0\\t%y0\";
2547
2548     case 1:
2549     case 2:
2550       return \"#\";
2551
2552     default:
2553       abort ();
2554     }
2555 }"
2556   [(set_attr "type" "multi")
2557    (set_attr "mode" "XF,SI,SI")])
2558
2559 (define_insn "*pushtf_nointeger"
2560   [(set (match_operand:TF 0 "push_operand" "=<,<,<")
2561         (match_operand:TF 1 "general_no_elim_operand" "f,Fo,*r"))]
2562   "optimize_size"
2563   "*
2564 {
2565   switch (which_alternative)
2566     {
2567     case 0:
2568       /* %%% We loose REG_DEAD notes for controling pops if we split late.  */
2569       operands[0] = gen_rtx_MEM (XFmode, stack_pointer_rtx);
2570       operands[2] = stack_pointer_rtx;
2571       operands[3] = GEN_INT (16);
2572       if (find_regno_note (insn, REG_DEAD, REGNO (operands[1])))
2573         return \"sub{l}\\t{%3, %2|%2, %3}\;fstp%z0\\t%y0\";
2574       else
2575         return \"sub{l}\\t{%3, %2|%2, %3}\;fst%z0\\t%y0\";
2576
2577     case 1:
2578     case 2:
2579       return \"#\";
2580
2581     default:
2582       abort ();
2583     }
2584 }"
2585   [(set_attr "type" "multi")
2586    (set_attr "mode" "XF,SI,SI")])
2587
2588 (define_insn "*pushxf_integer"
2589   [(set (match_operand:XF 0 "push_operand" "=<,<")
2590         (match_operand:XF 1 "general_no_elim_operand" "f#r,rFo#f"))]
2591   "!optimize_size"
2592   "*
2593 {
2594   switch (which_alternative)
2595     {
2596     case 0:
2597       /* %%% We loose REG_DEAD notes for controling pops if we split late.  */
2598       operands[0] = gen_rtx_MEM (XFmode, stack_pointer_rtx);
2599       operands[2] = stack_pointer_rtx;
2600       operands[3] = GEN_INT (12);
2601       if (find_regno_note (insn, REG_DEAD, REGNO (operands[1])))
2602         return \"sub{l}\\t{%3, %2|%2, %3}\;fstp%z0\\t%y0\";
2603       else
2604         return \"sub{l}\\t{%3, %2|%2, %3}\;fst%z0\\t%y0\";
2605
2606     case 1:
2607       return \"#\";
2608
2609     default:
2610       abort ();
2611     }
2612 }"
2613   [(set_attr "type" "multi")
2614    (set_attr "mode" "XF,SI")])
2615
2616 (define_insn "*pushtf_integer"
2617   [(set (match_operand:TF 0 "push_operand" "=<,<")
2618         (match_operand:TF 1 "general_no_elim_operand" "f#r,rFo#f"))]
2619   "!optimize_size"
2620   "*
2621 {
2622   switch (which_alternative)
2623     {
2624     case 0:
2625       /* %%% We loose REG_DEAD notes for controling pops if we split late.  */
2626       operands[0] = gen_rtx_MEM (XFmode, stack_pointer_rtx);
2627       operands[2] = stack_pointer_rtx;
2628       operands[3] = GEN_INT (16);
2629       if (find_regno_note (insn, REG_DEAD, REGNO (operands[1])))
2630         return \"sub{l}\\t{%3, %2|%2, %3}\;fstp%z0\\t%y0\";
2631       else
2632         return \"sub{l}\\t{%3, %2|%2, %3}\;fst%z0\\t%y0\";
2633
2634     case 1:
2635       return \"#\";
2636
2637     default:
2638       abort ();
2639     }
2640 }"
2641   [(set_attr "type" "multi")
2642    (set_attr "mode" "XF,SI")])
2643
2644 (define_split
2645   [(set (match_operand 0 "push_operand" "")
2646         (match_operand 1 "general_operand" ""))]
2647   "reload_completed
2648    && (GET_MODE (operands[0]) == XFmode
2649        || GET_MODE (operands[0]) == TFmode
2650        || GET_MODE (operands[0]) == DFmode)
2651    && (!REG_P (operands[1]) || !ANY_FP_REGNO_P (REGNO (operands[1])))"
2652   [(const_int 0)]
2653   "if (!ix86_split_long_move (operands)) abort (); DONE;")
2654
2655 (define_split
2656   [(set (match_operand:XF 0 "push_operand" "")
2657         (match_operand:XF 1 "register_operand" ""))]
2658   "ANY_FP_REGNO_P (REGNO (operands[1]))"
2659   [(set (reg:SI 7) (plus:SI (reg:SI 7) (const_int -12)))
2660    (set (mem:XF (reg:SI 7)) (match_dup 1))])
2661
2662 (define_split
2663   [(set (match_operand:TF 0 "push_operand" "")
2664         (match_operand:TF 1 "register_operand" ""))]
2665   "ANY_FP_REGNO_P (REGNO (operands[1]))"
2666   [(set (reg:SI 7) (plus:SI (reg:SI 7) (const_int -16)))
2667    (set (mem:TF (reg:SI 7)) (match_dup 1))])
2668
2669 ;; Do not use integer registers when optimizing for size
2670 (define_insn "*movxf_nointeger"
2671   [(set (match_operand:XF 0 "nonimmediate_operand" "=f,m,f,*r,o")
2672         (match_operand:XF 1 "general_operand" "fm,f,G,*roF,F*r"))]
2673   "(GET_CODE (operands[0]) != MEM || GET_CODE (operands[1]) != MEM)
2674    && optimize_size
2675    && (reload_in_progress || reload_completed
2676        || GET_CODE (operands[1]) != CONST_DOUBLE
2677        || memory_operand (operands[0], XFmode))" 
2678   "*
2679 {
2680   switch (which_alternative)
2681     {
2682     case 0:
2683       if (REG_P (operands[1])
2684           && find_regno_note (insn, REG_DEAD, REGNO (operands[1])))
2685         return \"fstp\\t%y0\";
2686       else if (STACK_TOP_P (operands[0]))
2687         return \"fld%z1\\t%y1\";
2688       else
2689         return \"fst\\t%y0\";
2690
2691     case 1:
2692       /* There is no non-popping store to memory for XFmode.  So if
2693          we need one, follow the store with a load.  */
2694       if (! find_regno_note (insn, REG_DEAD, REGNO (operands[1])))
2695         return \"fstp%z0\\t%y0\;fld%z0\\t%y0\";
2696       else
2697         return \"fstp%z0\\t%y0\";
2698
2699     case 2:
2700       switch (standard_80387_constant_p (operands[1]))
2701         {
2702         case 1:
2703           return \"fldz\";
2704         case 2:
2705           return \"fld1\";
2706         }
2707       break;
2708
2709     case 3: case 4:
2710       return \"#\";
2711     }
2712   abort();
2713 }"
2714   [(set_attr "type" "fmov,fmov,fmov,multi,multi")
2715    (set_attr "mode" "XF,XF,XF,SI,SI")])
2716
2717 (define_insn "*movtf_nointeger"
2718   [(set (match_operand:TF 0 "nonimmediate_operand" "=f,m,f,*r,o")
2719         (match_operand:TF 1 "general_operand" "fm,f,G,*roF,F*r"))]
2720   "(GET_CODE (operands[0]) != MEM || GET_CODE (operands[1]) != MEM)
2721    && optimize_size
2722    && (reload_in_progress || reload_completed
2723        || GET_CODE (operands[1]) != CONST_DOUBLE
2724        || memory_operand (operands[0], TFmode))" 
2725   "*
2726 {
2727   switch (which_alternative)
2728     {
2729     case 0:
2730       if (REG_P (operands[1])
2731           && find_regno_note (insn, REG_DEAD, REGNO (operands[1])))
2732         return \"fstp\\t%y0\";
2733       else if (STACK_TOP_P (operands[0]))
2734         return \"fld%z1\\t%y1\";
2735       else
2736         return \"fst\\t%y0\";
2737
2738     case 1:
2739       /* There is no non-popping store to memory for XFmode.  So if
2740          we need one, follow the store with a load.  */
2741       if (! find_regno_note (insn, REG_DEAD, REGNO (operands[1])))
2742         return \"fstp%z0\\t%y0\;fld%z0\\t%y0\";
2743       else
2744         return \"fstp%z0\\t%y0\";
2745
2746     case 2:
2747       switch (standard_80387_constant_p (operands[1]))
2748         {
2749         case 1:
2750           return \"fldz\";
2751         case 2:
2752           return \"fld1\";
2753         }
2754       break;
2755
2756     case 3: case 4:
2757       return \"#\";
2758     }
2759   abort();
2760 }"
2761   [(set_attr "type" "fmov,fmov,fmov,multi,multi")
2762    (set_attr "mode" "XF,XF,XF,SI,SI")])
2763
2764 (define_insn "*movxf_integer"
2765   [(set (match_operand:XF 0 "nonimmediate_operand" "=f#r,m,f#r,r#f,o")
2766         (match_operand:XF 1 "general_operand" "fm#r,f#r,G,roF#f,Fr#f"))]
2767   "(GET_CODE (operands[0]) != MEM || GET_CODE (operands[1]) != MEM)
2768    && !optimize_size
2769    && (reload_in_progress || reload_completed
2770        || GET_CODE (operands[1]) != CONST_DOUBLE
2771        || memory_operand (operands[0], XFmode))" 
2772   "*
2773 {
2774   switch (which_alternative)
2775     {
2776     case 0:
2777       if (REG_P (operands[1])
2778           && find_regno_note (insn, REG_DEAD, REGNO (operands[1])))
2779         return \"fstp\\t%y0\";
2780       else if (STACK_TOP_P (operands[0]))
2781         return \"fld%z1\\t%y1\";
2782       else
2783         return \"fst\\t%y0\";
2784
2785     case 1:
2786       /* There is no non-popping store to memory for XFmode.  So if
2787          we need one, follow the store with a load.  */
2788       if (! find_regno_note (insn, REG_DEAD, REGNO (operands[1])))
2789         return \"fstp%z0\\t%y0\;fld%z0\\t%y0\";
2790       else
2791         return \"fstp%z0\\t%y0\";
2792
2793     case 2:
2794       switch (standard_80387_constant_p (operands[1]))
2795         {
2796         case 1:
2797           return \"fldz\";
2798         case 2:
2799           return \"fld1\";
2800         }
2801       break;
2802
2803     case 3: case 4:
2804       return \"#\";
2805     }
2806   abort();
2807 }"
2808   [(set_attr "type" "fmov,fmov,fmov,multi,multi")
2809    (set_attr "mode" "XF,XF,XF,SI,SI")])
2810
2811 (define_insn "*movtf_integer"
2812   [(set (match_operand:TF 0 "nonimmediate_operand" "=f#r,m,f#r,r#f,o")
2813         (match_operand:TF 1 "general_operand" "fm#r,f#r,G,roF#f,Fr#f"))]
2814   "(GET_CODE (operands[0]) != MEM || GET_CODE (operands[1]) != MEM)
2815    && !optimize_size
2816    && (reload_in_progress || reload_completed
2817        || GET_CODE (operands[1]) != CONST_DOUBLE
2818        || memory_operand (operands[0], TFmode))" 
2819   "*
2820 {
2821   switch (which_alternative)
2822     {
2823     case 0:
2824       if (REG_P (operands[1])
2825           && find_regno_note (insn, REG_DEAD, REGNO (operands[1])))
2826         return \"fstp\\t%y0\";
2827       else if (STACK_TOP_P (operands[0]))
2828         return \"fld%z1\\t%y1\";
2829       else
2830         return \"fst\\t%y0\";
2831
2832     case 1:
2833       /* There is no non-popping store to memory for XFmode.  So if
2834          we need one, follow the store with a load.  */
2835       if (! find_regno_note (insn, REG_DEAD, REGNO (operands[1])))
2836         return \"fstp%z0\\t%y0\;fld%z0\\t%y0\";
2837       else
2838         return \"fstp%z0\\t%y0\";
2839
2840     case 2:
2841       switch (standard_80387_constant_p (operands[1]))
2842         {
2843         case 1:
2844           return \"fldz\";
2845         case 2:
2846           return \"fld1\";
2847         }
2848       break;
2849
2850     case 3: case 4:
2851       return \"#\";
2852     }
2853   abort();
2854 }"
2855   [(set_attr "type" "fmov,fmov,fmov,multi,multi")
2856    (set_attr "mode" "XF,XF,XF,SI,SI")])
2857
2858 (define_split
2859   [(set (match_operand 0 "nonimmediate_operand" "")
2860         (match_operand 1 "general_operand" ""))]
2861   "reload_completed
2862    && (GET_CODE (operands[0]) != MEM || GET_CODE (operands[1]) != MEM)
2863    && (GET_MODE (operands[0]) == XFmode || GET_MODE (operands[0]) == TFmode)
2864    && ! (ANY_FP_REG_P (operands[0]) || 
2865          (GET_CODE (operands[0]) == SUBREG
2866           && ANY_FP_REG_P (SUBREG_REG (operands[0]))))
2867    && ! (ANY_FP_REG_P (operands[1]) || 
2868          (GET_CODE (operands[1]) == SUBREG
2869           && ANY_FP_REG_P (SUBREG_REG (operands[1]))))"
2870   [(set (match_dup 2) (match_dup 5))
2871    (set (match_dup 3) (match_dup 6))
2872    (set (match_dup 4) (match_dup 7))]
2873   "if (ix86_split_long_move (operands)) DONE;")
2874
2875 (define_split
2876   [(set (match_operand 0 "register_operand" "")
2877         (match_operand 1 "memory_operand" ""))]
2878   "reload_completed
2879    && GET_CODE (operands[1]) == MEM
2880    && (GET_MODE (operands[0]) == XFmode || GET_MODE (operands[0]) == TFmode
2881        || GET_MODE (operands[0]) == SFmode || GET_MODE (operands[0]) == DFmode)
2882    && GET_CODE (XEXP (operands[1], 0)) == SYMBOL_REF
2883    && CONSTANT_POOL_ADDRESS_P (XEXP (operands[1], 0))
2884    && (!(SSE_REG_P (operands[0]) || 
2885          (GET_CODE (operands[0]) == SUBREG
2886           && SSE_REG_P (SUBREG_REG (operands[0]))))
2887        || standard_sse_constant_p (get_pool_constant (XEXP (operands[1], 0))))
2888    && (!(FP_REG_P (operands[0]) || 
2889          (GET_CODE (operands[0]) == SUBREG
2890           && FP_REG_P (SUBREG_REG (operands[0]))))
2891        || standard_80387_constant_p (get_pool_constant (XEXP (operands[1], 0))))"
2892   [(set (match_dup 0)
2893         (match_dup 1))]
2894   "operands[1] = get_pool_constant (XEXP (operands[1], 0));")
2895
2896 (define_insn "swapxf"
2897   [(set (match_operand:XF 0 "register_operand" "+f")
2898         (match_operand:XF 1 "register_operand" "+f"))
2899    (set (match_dup 1)
2900         (match_dup 0))]
2901   ""
2902   "*
2903 {
2904   if (STACK_TOP_P (operands[0]))
2905     return \"fxch\\t%1\";
2906   else
2907     return \"fxch\\t%0\";
2908 }"
2909   [(set_attr "type" "fxch")
2910    (set_attr "mode" "XF")])
2911
2912 (define_insn "swaptf"
2913   [(set (match_operand:TF 0 "register_operand" "+f")
2914         (match_operand:TF 1 "register_operand" "+f"))
2915    (set (match_dup 1)
2916         (match_dup 0))]
2917   ""
2918   "*
2919 {
2920   if (STACK_TOP_P (operands[0]))
2921     return \"fxch\\t%1\";
2922   else
2923     return \"fxch\\t%0\";
2924 }"
2925   [(set_attr "type" "fxch")
2926    (set_attr "mode" "XF")])
2927 \f
2928 ;; Zero extension instructions
2929
2930 (define_expand "zero_extendhisi2"
2931   [(set (match_operand:SI 0 "register_operand" "")
2932      (zero_extend:SI (match_operand:HI 1 "nonimmediate_operand" "")))]
2933   ""
2934   "
2935 {
2936   if (TARGET_ZERO_EXTEND_WITH_AND && !optimize_size)
2937     {
2938       operands[1] = force_reg (HImode, operands[1]);
2939       emit_insn (gen_zero_extendhisi2_and (operands[0], operands[1]));
2940       DONE;
2941     }
2942 }")
2943
2944 (define_insn "zero_extendhisi2_and"
2945   [(set (match_operand:SI 0 "register_operand" "=r")
2946      (zero_extend:SI (match_operand:HI 1 "register_operand" "0")))
2947    (clobber (reg:CC 17))]
2948   "TARGET_ZERO_EXTEND_WITH_AND && !optimize_size"
2949   "#"
2950   [(set_attr "type" "alu1")
2951    (set_attr "mode" "SI")])
2952
2953 (define_split
2954   [(set (match_operand:SI 0 "register_operand" "")
2955         (zero_extend:SI (match_operand:HI 1 "register_operand" "")))
2956    (clobber (reg:CC 17))]
2957   "reload_completed && TARGET_ZERO_EXTEND_WITH_AND && !optimize_size"
2958   [(parallel [(set (match_dup 0) (and:SI (match_dup 0) (const_int 65535)))
2959               (clobber (reg:CC 17))])]
2960   "")
2961
2962 (define_insn "*zero_extendhisi2_movzwl"
2963   [(set (match_operand:SI 0 "register_operand" "=r")
2964      (zero_extend:SI (match_operand:HI 1 "nonimmediate_operand" "rm")))]
2965   "!TARGET_ZERO_EXTEND_WITH_AND || optimize_size"
2966   "movz{wl|x}\\t{%1, %0|%0, %1}"
2967   [(set_attr "type" "imovx")
2968    (set_attr "mode" "SI")])
2969
2970 (define_expand "zero_extendqihi2"
2971   [(parallel
2972     [(set (match_operand:HI 0 "register_operand" "")
2973        (zero_extend:HI (match_operand:QI 1 "nonimmediate_operand" "")))
2974      (clobber (reg:CC 17))])]
2975   ""
2976   "")
2977
2978 (define_insn "*zero_extendqihi2_and"
2979   [(set (match_operand:HI 0 "register_operand" "=r,?&q")
2980      (zero_extend:HI (match_operand:QI 1 "nonimmediate_operand" "0,qm")))
2981    (clobber (reg:CC 17))]
2982   "TARGET_ZERO_EXTEND_WITH_AND && !optimize_size"
2983   "#"
2984   [(set_attr "type" "alu1")
2985    (set_attr "mode" "HI")])
2986
2987 (define_insn "*zero_extendqihi2_movzbw_and"
2988   [(set (match_operand:HI 0 "register_operand" "=r,r")
2989      (zero_extend:HI (match_operand:QI 1 "nonimmediate_operand" "qm,0")))
2990    (clobber (reg:CC 17))]
2991   "!TARGET_ZERO_EXTEND_WITH_AND || optimize_size"
2992   "#"
2993   [(set_attr "type" "imovx,alu1")
2994    (set_attr "mode" "HI")])
2995
2996 (define_insn "*zero_extendqihi2_movzbw"
2997   [(set (match_operand:HI 0 "register_operand" "=r")
2998      (zero_extend:HI (match_operand:QI 1 "nonimmediate_operand" "qm")))]
2999   "(!TARGET_ZERO_EXTEND_WITH_AND || optimize_size) && reload_completed"
3000   "movz{bw|x}\\t{%1, %0|%0, %1}"
3001   [(set_attr "type" "imovx")
3002    (set_attr "mode" "HI")])
3003
3004 ;; For the movzbw case strip only the clobber
3005 (define_split
3006   [(set (match_operand:HI 0 "register_operand" "")
3007         (zero_extend:HI (match_operand:QI 1 "nonimmediate_operand" "")))
3008    (clobber (reg:CC 17))]
3009   "reload_completed 
3010    && (!TARGET_ZERO_EXTEND_WITH_AND || optimize_size)
3011    && (!REG_P (operands[1]) || QI_REG_P (operands[1]))"
3012   [(set (match_operand:HI 0 "register_operand" "")
3013         (zero_extend:HI (match_operand:QI 1 "nonimmediate_operand" "")))])
3014
3015 ;; When source and destination does not overlap, clear destination
3016 ;; first and then do the movb
3017 (define_split
3018   [(set (match_operand:HI 0 "register_operand" "")
3019         (zero_extend:HI (match_operand:QI 1 "nonimmediate_operand" "")))
3020    (clobber (reg:CC 17))]
3021   "reload_completed
3022    && QI_REG_P (operands[0])
3023    && (TARGET_ZERO_EXTEND_WITH_AND && !optimize_size)
3024    && !reg_overlap_mentioned_p (operands[0], operands[1])"
3025   [(set (match_dup 0) (const_int 0))
3026    (set (strict_low_part (match_dup 2)) (match_dup 1))]
3027   "operands[2] = gen_lowpart (QImode, operands[0]);")
3028
3029 ;; Rest is handled by single and.
3030 (define_split
3031   [(set (match_operand:HI 0 "register_operand" "")
3032         (zero_extend:HI (match_operand:QI 1 "register_operand" "")))
3033    (clobber (reg:CC 17))]
3034   "reload_completed
3035    && true_regnum (operands[0]) == true_regnum (operands[1])"
3036   [(parallel [(set (match_dup 0) (and:HI (match_dup 0) (const_int 255)))
3037               (clobber (reg:CC 17))])]
3038   "")
3039
3040 (define_expand "zero_extendqisi2"
3041   [(parallel
3042     [(set (match_operand:SI 0 "register_operand" "")
3043        (zero_extend:SI (match_operand:QI 1 "nonimmediate_operand" "")))
3044      (clobber (reg:CC 17))])]
3045   ""
3046   "")
3047
3048 (define_insn "*zero_extendqisi2_and"
3049   [(set (match_operand:SI 0 "register_operand" "=r,?&q")
3050      (zero_extend:SI (match_operand:QI 1 "nonimmediate_operand" "0,qm")))
3051    (clobber (reg:CC 17))]
3052   "TARGET_ZERO_EXTEND_WITH_AND && !optimize_size"
3053   "#"
3054   [(set_attr "type" "alu1")
3055    (set_attr "mode" "SI")])
3056
3057 (define_insn "*zero_extendqisi2_movzbw_and"
3058   [(set (match_operand:SI 0 "register_operand" "=r,r")
3059      (zero_extend:SI (match_operand:QI 1 "nonimmediate_operand" "qm,0")))
3060    (clobber (reg:CC 17))]
3061   "!TARGET_ZERO_EXTEND_WITH_AND || optimize_size"
3062   "#"
3063   [(set_attr "type" "imovx,alu1")
3064    (set_attr "mode" "SI")])
3065
3066 (define_insn "*zero_extendqisi2_movzbw"
3067   [(set (match_operand:SI 0 "register_operand" "=r")
3068      (zero_extend:SI (match_operand:QI 1 "nonimmediate_operand" "qm")))]
3069   "(!TARGET_ZERO_EXTEND_WITH_AND || optimize_size) && reload_completed"
3070   "movz{bl|x}\\t{%1, %0|%0, %1}"
3071   [(set_attr "type" "imovx")
3072    (set_attr "mode" "SI")])
3073
3074 ;; For the movzbl case strip only the clobber
3075 (define_split
3076   [(set (match_operand:SI 0 "register_operand" "")
3077         (zero_extend:SI (match_operand:QI 1 "nonimmediate_operand" "")))
3078    (clobber (reg:CC 17))]
3079   "reload_completed 
3080    && (!TARGET_ZERO_EXTEND_WITH_AND || optimize_size)
3081    && (!REG_P (operands[1]) || QI_REG_P (operands[1]))"
3082   [(set (match_dup 0)
3083         (zero_extend:SI (match_dup 1)))])
3084
3085 ;; When source and destination does not overlap, clear destination
3086 ;; first and then do the movb
3087 (define_split
3088   [(set (match_operand:SI 0 "register_operand" "")
3089         (zero_extend:SI (match_operand:QI 1 "nonimmediate_operand" "")))
3090    (clobber (reg:CC 17))]
3091   "reload_completed
3092    && QI_REG_P (operands[0])
3093    && (QI_REG_P (operands[1]) || GET_CODE (operands[1]) == MEM)
3094    && (TARGET_ZERO_EXTEND_WITH_AND && !optimize_size)
3095    && !reg_overlap_mentioned_p (operands[0], operands[1])"
3096   [(set (match_dup 0) (const_int 0))
3097    (set (strict_low_part (match_dup 2)) (match_dup 1))]
3098   "operands[2] = gen_lowpart (QImode, operands[0]);")
3099
3100 ;; Rest is handled by single and.
3101 (define_split
3102   [(set (match_operand:SI 0 "register_operand" "")
3103         (zero_extend:SI (match_operand:QI 1 "register_operand" "")))
3104    (clobber (reg:CC 17))]
3105   "reload_completed
3106    && true_regnum (operands[0]) == true_regnum (operands[1])"
3107   [(parallel [(set (match_dup 0) (and:SI (match_dup 0) (const_int 255)))
3108               (clobber (reg:CC 17))])]
3109   "")
3110
3111 ;; %%% Kill me once multi-word ops are sane.
3112 (define_insn "zero_extendsidi2"
3113   [(set (match_operand:DI 0 "nonimmediate_operand" "=r,?r,?*o")
3114         (zero_extend:DI (match_operand:SI 1 "general_operand" "0,rm,r")))
3115    (clobber (reg:CC 17))]
3116   ""
3117   "#"
3118   [(set_attr "mode" "SI")])
3119
3120 (define_split 
3121   [(set (match_operand:DI 0 "register_operand" "")
3122         (zero_extend:DI (match_operand:SI 1 "register_operand" "")))
3123    (clobber (reg:CC 17))]
3124   "reload_completed && true_regnum (operands[0]) == true_regnum (operands[1])"
3125   [(set (match_dup 4) (const_int 0))]
3126   "split_di (&operands[0], 1, &operands[3], &operands[4]);")
3127
3128 (define_split 
3129   [(set (match_operand:DI 0 "nonimmediate_operand" "")
3130         (zero_extend:DI (match_operand:SI 1 "general_operand" "")))
3131    (clobber (reg:CC 17))]
3132   "reload_completed"
3133   [(set (match_dup 3) (match_dup 1))
3134    (set (match_dup 4) (const_int 0))]
3135   "split_di (&operands[0], 1, &operands[3], &operands[4]);")
3136 \f
3137 ;; Sign extension instructions
3138
3139 (define_insn "extendsidi2"
3140   [(set (match_operand:DI 0 "nonimmediate_operand" "=*A,r,?r,?*o")
3141         (sign_extend:DI (match_operand:SI 1 "register_operand" "0,0,r,r")))
3142    (clobber (reg:CC 17))
3143    (clobber (match_scratch:SI 2 "=X,X,X,&r"))]
3144   ""
3145   "#")
3146
3147 ;; Extend to memory case when source register does die.
3148 (define_split 
3149   [(set (match_operand:DI 0 "memory_operand" "")
3150         (sign_extend:DI (match_operand:SI 1 "register_operand" "")))
3151    (clobber (reg:CC 17))
3152    (clobber (match_operand:SI 2 "register_operand" ""))]
3153   "(reload_completed
3154     && dead_or_set_p (insn, operands[1])
3155     && !reg_mentioned_p (operands[1], operands[0]))"
3156   [(set (match_dup 3) (match_dup 1))
3157    (parallel [(set (match_dup 1) (ashiftrt:SI (match_dup 1) (const_int 31)))
3158               (clobber (reg:CC 17))])
3159    (set (match_dup 4) (match_dup 1))]
3160   "split_di (&operands[0], 1, &operands[3], &operands[4]);")
3161
3162 ;; Extend to memory case when source register does not die.
3163 (define_split 
3164   [(set (match_operand:DI 0 "memory_operand" "")
3165         (sign_extend:DI (match_operand:SI 1 "register_operand" "")))
3166    (clobber (reg:CC 17))
3167    (clobber (match_operand:SI 2 "register_operand" ""))]
3168   "reload_completed"
3169   [(const_int 0)]
3170   "
3171 {
3172   split_di (&operands[0], 1, &operands[3], &operands[4]);
3173
3174   emit_move_insn (operands[3], operands[1]);
3175
3176   /* Generate a cltd if possible and doing so it profitable.  */
3177   if (true_regnum (operands[1]) == 0
3178       && true_regnum (operands[2]) == 1
3179       && (optimize_size || TARGET_USE_CLTD))
3180     {
3181       emit_insn (gen_ashrsi3_31 (operands[2], operands[1], GEN_INT (31)));
3182     }
3183   else
3184     {
3185       emit_move_insn (operands[2], operands[1]);
3186       emit_insn (gen_ashrsi3_31 (operands[2], operands[2], GEN_INT (31)));
3187     }
3188   emit_move_insn (operands[4], operands[2]);
3189   DONE;
3190 }")
3191
3192 ;; Extend to register case.  Optimize case where source and destination
3193 ;; registers match and cases where we can use cltd.
3194 (define_split 
3195   [(set (match_operand:DI 0 "register_operand" "")
3196         (sign_extend:DI (match_operand:SI 1 "register_operand" "")))
3197    (clobber (reg:CC 17))
3198    (clobber (match_scratch:SI 2 ""))]
3199   "reload_completed"
3200   [(const_int 0)]
3201   "
3202 {
3203   split_di (&operands[0], 1, &operands[3], &operands[4]);
3204
3205   if (true_regnum (operands[3]) != true_regnum (operands[1]))
3206     emit_move_insn (operands[3], operands[1]);
3207
3208   /* Generate a cltd if possible and doing so it profitable.  */
3209   if (true_regnum (operands[3]) == 0
3210       && (optimize_size || TARGET_USE_CLTD))
3211     {
3212       emit_insn (gen_ashrsi3_31 (operands[4], operands[3], GEN_INT (31)));
3213       DONE;
3214     }
3215
3216   if (true_regnum (operands[4]) != true_regnum (operands[1]))
3217     emit_move_insn (operands[4], operands[1]);
3218
3219   emit_insn (gen_ashrsi3_31 (operands[4], operands[4], GEN_INT (31)));
3220   DONE;
3221 }")
3222
3223 (define_insn "extendhisi2"
3224   [(set (match_operand:SI 0 "register_operand" "=*a,r")
3225         (sign_extend:SI (match_operand:HI 1 "nonimmediate_operand" "*0,rm")))]
3226   ""
3227   "*
3228 {
3229   switch (get_attr_prefix_0f (insn))
3230     {
3231     case 0:
3232       return \"{cwtl|cwde}\";
3233     default:
3234       return \"movs{wl|x}\\t{%1,%0|%0, %1}\";
3235     }
3236 }"
3237   [(set_attr "type" "imovx")
3238    (set_attr "mode" "SI")
3239    (set (attr "prefix_0f")
3240      ;; movsx is short decodable while cwtl is vector decoded.
3241      (if_then_else (and (eq_attr "cpu" "!k6")
3242                         (eq_attr "alternative" "0"))
3243         (const_string "0")
3244         (const_string "1")))
3245    (set (attr "modrm")
3246      (if_then_else (eq_attr "prefix_0f" "0")
3247         (const_string "0")
3248         (const_string "1")))])
3249
3250 (define_insn "extendqihi2"
3251   [(set (match_operand:HI 0 "register_operand" "=*a,r")
3252         (sign_extend:HI (match_operand:QI 1 "nonimmediate_operand" "*0,qm")))]
3253   ""
3254   "*
3255 {
3256   switch (get_attr_prefix_0f (insn))
3257     {
3258     case 0:
3259       return \"{cbtw|cbw}\";
3260     default:
3261       return \"movs{bw|x}\\t{%1,%0|%0, %1}\";
3262     }
3263 }"
3264   [(set_attr "type" "imovx")
3265    (set_attr "mode" "HI")
3266    (set (attr "prefix_0f")
3267      ;; movsx is short decodable while cwtl is vector decoded.
3268      (if_then_else (and (eq_attr "cpu" "!k6")
3269                         (eq_attr "alternative" "0"))
3270         (const_string "0")
3271         (const_string "1")))
3272    (set (attr "modrm")
3273      (if_then_else (eq_attr "prefix_0f" "0")
3274         (const_string "0")
3275         (const_string "1")))])
3276
3277 (define_insn "extendqisi2"
3278   [(set (match_operand:SI 0 "register_operand" "=r")
3279         (sign_extend:SI (match_operand:QI 1 "nonimmediate_operand" "qm")))]
3280   ""
3281   "movs{bl|x}\\t{%1,%0|%0, %1}"
3282    [(set_attr "type" "imovx")
3283     (set_attr "mode" "SI")])
3284 \f
3285 ;; Conversions between float and double.
3286
3287 ;; These are all no-ops in the model used for the 80387.  So just
3288 ;; emit moves.
3289
3290 ;; %%% Kill these when call knows how to work out a DFmode push earlier. 
3291 (define_insn "*dummy_extendsfdf2"
3292   [(set (match_operand:DF 0 "push_operand" "=<")
3293         (float_extend:DF (match_operand:SF 1 "nonimmediate_operand" "fY")))]
3294   "0"
3295   "#")
3296
3297 (define_split
3298   [(set (match_operand:DF 0 "push_operand" "")
3299         (float_extend:DF (match_operand:SF 1 "register_operand" "")))]
3300   "FP_REGNO_P (REGNO (operands[1]))"
3301   [(set (reg:SI 7) (plus:SI (reg:SI 7) (const_int -8)))
3302    (set (mem:DF (reg:SI 7)) (float_extend:DF (match_dup 1)))])
3303
3304 (define_insn "*dummy_extendsfxf2"
3305   [(set (match_operand:XF 0 "push_operand" "=<")
3306         (float_extend:XF (match_operand:SF 1 "nonimmediate_operand" "f")))]
3307   "0"
3308   "#")
3309
3310 (define_split
3311   [(set (match_operand:XF 0 "push_operand" "")
3312         (float_extend:XF (match_operand:SF 1 "register_operand" "")))]
3313   "FP_REGNO_P (REGNO (operands[1]))"
3314   [(set (reg:SI 7) (plus:SI (reg:SI 7) (const_int -12)))
3315    (set (mem:XF (reg:SI 7)) (float_extend:XF (match_dup 1)))])
3316
3317 (define_insn "*dummy_extendsftf2"
3318   [(set (match_operand:TF 0 "push_operand" "=<")
3319         (float_extend:TF (match_operand:SF 1 "nonimmediate_operand" "f")))]
3320   "0"
3321   "#")
3322
3323 (define_split
3324   [(set (match_operand:TF 0 "push_operand" "")
3325         (float_extend:TF (match_operand:SF 1 "register_operand" "")))]
3326   "FP_REGNO_P (REGNO (operands[1]))"
3327   [(set (reg:SI 7) (plus:SI (reg:SI 7) (const_int -16)))
3328    (set (mem:TF (reg:SI 7)) (float_extend:XF (match_dup 1)))])
3329
3330 (define_insn "*dummy_extenddfxf2"
3331   [(set (match_operand:XF 0 "push_operand" "=<")
3332         (float_extend:XF (match_operand:DF 1 "nonimmediate_operand" "f")))]
3333   "0"
3334   "#")
3335
3336 (define_split
3337   [(set (match_operand:XF 0 "push_operand" "")
3338         (float_extend:XF (match_operand:DF 1 "register_operand" "")))]
3339   "FP_REGNO_P (REGNO (operands[1]))"
3340   [(set (reg:SI 7) (plus:SI (reg:SI 7) (const_int -12)))
3341    (set (mem:XF (reg:SI 7)) (float_extend:XF (match_dup 1)))])
3342
3343 (define_insn "*dummy_extenddftf2"
3344   [(set (match_operand:TF 0 "push_operand" "=<")
3345         (float_extend:TF (match_operand:DF 1 "nonimmediate_operand" "f")))]
3346   "0"
3347   "#")
3348
3349 (define_split
3350   [(set (match_operand:TF 0 "push_operand" "")
3351         (float_extend:TF (match_operand:DF 1 "register_operand" "")))]
3352   "FP_REGNO_P (REGNO (operands[1]))"
3353   [(set (reg:SI 7) (plus:SI (reg:SI 7) (const_int -16)))
3354    (set (mem:TF (reg:SI 7)) (float_extend:XF (match_dup 1)))])
3355
3356 (define_expand "extendsfdf2"
3357   [(set (match_operand:DF 0 "nonimmediate_operand" "")
3358         (float_extend:DF (match_operand:SF 1 "nonimmediate_operand" "")))]
3359   "TARGET_80387 || TARGET_SSE2"
3360   "
3361 {
3362   if (GET_CODE (operands[0]) == MEM && GET_CODE (operands[1]) == MEM)
3363     operands[1] = force_reg (SFmode, operands[1]);
3364 }")
3365
3366 (define_insn "*extendsfdf2_1"
3367   [(set (match_operand:DF 0 "nonimmediate_operand" "=f#Y,mf#Y,Y#f")
3368         (float_extend:DF (match_operand:SF 1 "nonimmediate_operand" "fm#Y,f#Y,mY#f")))]
3369   "(TARGET_80387 || TARGET_SSE2)
3370    && (GET_CODE (operands[0]) != MEM || GET_CODE (operands[1]) != MEM)"
3371   "*
3372 {
3373   switch (which_alternative)
3374     {
3375     case 0:
3376       if (REG_P (operands[1])
3377           && find_regno_note (insn, REG_DEAD, REGNO (operands[1])))
3378         return \"fstp\\t%y0\";
3379       else if (STACK_TOP_P (operands[0]))
3380         return \"fld%z1\\t%y1\";
3381       else
3382         return \"fst\\t%y0\";
3383
3384     case 1:
3385       if (find_regno_note (insn, REG_DEAD, REGNO (operands[1])))
3386         return \"fstp%z0\\t%y0\";
3387
3388       else
3389         return \"fst%z0\\t%y0\";
3390     case 2:
3391       return \"cvtss2sd\\t{%1, %0|%0, %1}\";
3392
3393     default:
3394       abort ();
3395     }
3396 }"
3397   [(set_attr "type" "fmov,fmov,sse")
3398    (set_attr "mode" "SF,XF,DF")])
3399
3400 (define_insn "*extendsfdf2_1_sse_only"
3401   [(set (match_operand:DF 0 "register_operand" "=Y")
3402         (float_extend:DF (match_operand:SF 1 "nonimmediate_operand" "mY")))]
3403   "!TARGET_80387 && TARGET_SSE2
3404    && (GET_CODE (operands[0]) != MEM || GET_CODE (operands[1]) != MEM)"
3405   "cvtss2sd\\t{%1, %0|%0, %1}"
3406   [(set_attr "type" "sse")
3407    (set_attr "mode" "DF")])
3408
3409 (define_expand "extendsfxf2"
3410   [(set (match_operand:XF 0 "nonimmediate_operand" "")
3411         (float_extend:XF (match_operand:SF 1 "nonimmediate_operand" "")))]
3412   "TARGET_80387"
3413   "
3414 {
3415   if (GET_CODE (operands[0]) == MEM && GET_CODE (operands[1]) == MEM)
3416     operands[1] = force_reg (SFmode, operands[1]);
3417 }")
3418
3419 (define_insn "*extendsfxf2_1"
3420   [(set (match_operand:XF 0 "nonimmediate_operand" "=f,m")
3421         (float_extend:XF (match_operand:SF 1 "nonimmediate_operand" "fm,f")))]
3422   "TARGET_80387
3423    && (GET_CODE (operands[0]) != MEM || GET_CODE (operands[1]) != MEM)"
3424   "*
3425 {
3426   switch (which_alternative)
3427     {
3428     case 0:
3429       if (REG_P (operands[1])
3430           && find_regno_note (insn, REG_DEAD, REGNO (operands[1])))
3431         return \"fstp\\t%y0\";
3432       else if (STACK_TOP_P (operands[0]))
3433         return \"fld%z1\\t%y1\";
3434       else
3435         return \"fst\\t%y0\";
3436
3437     case 1:
3438       /* There is no non-popping store to memory for XFmode.  So if
3439          we need one, follow the store with a load.  */
3440       if (! find_regno_note (insn, REG_DEAD, REGNO (operands[1])))
3441         return \"fstp%z0\\t%y0\\n\\tfld%z0\\t%y0\";
3442       else
3443         return \"fstp%z0\\t%y0\";
3444
3445     default:
3446       abort ();
3447     }
3448 }"
3449   [(set_attr "type" "fmov")
3450    (set_attr "mode" "SF,XF")])
3451
3452 (define_expand "extendsftf2"
3453   [(set (match_operand:TF 0 "nonimmediate_operand" "")
3454         (float_extend:TF (match_operand:SF 1 "nonimmediate_operand" "")))]
3455   "TARGET_80387"
3456   "
3457 {
3458   if (GET_CODE (operands[0]) == MEM && GET_CODE (operands[1]) == MEM)
3459     operands[1] = force_reg (SFmode, operands[1]);
3460 }")
3461
3462 (define_insn "*extendsftf2_1"
3463   [(set (match_operand:TF 0 "nonimmediate_operand" "=f,m")
3464         (float_extend:TF (match_operand:SF 1 "nonimmediate_operand" "fm,f")))]
3465   "TARGET_80387
3466    && (GET_CODE (operands[0]) != MEM || GET_CODE (operands[1]) != MEM)"
3467   "*
3468 {
3469   switch (which_alternative)
3470     {
3471     case 0:
3472       if (REG_P (operands[1])
3473           && find_regno_note (insn, REG_DEAD, REGNO (operands[1])))
3474         return \"fstp\\t%y0\";
3475       else if (STACK_TOP_P (operands[0]))
3476         return \"fld%z1\\t%y1\";
3477       else
3478         return \"fst\\t%y0\";
3479
3480     case 1:
3481       /* There is no non-popping store to memory for XFmode.  So if
3482          we need one, follow the store with a load.  */
3483       if (! find_regno_note (insn, REG_DEAD, REGNO (operands[1])))
3484         return \"fstp%z0\\t%y0\\n\\tfld%z0\\t%y0\";
3485       else
3486         return \"fstp%z0\\t%y0\";
3487
3488     default:
3489       abort ();
3490     }
3491 }"
3492   [(set_attr "type" "fmov")
3493    (set_attr "mode" "SF,XF")])
3494
3495 (define_expand "extenddfxf2"
3496   [(set (match_operand:XF 0 "nonimmediate_operand" "")
3497         (float_extend:XF (match_operand:DF 1 "nonimmediate_operand" "")))]
3498   "TARGET_80387"
3499   "
3500 {
3501   if (GET_CODE (operands[0]) == MEM && GET_CODE (operands[1]) == MEM)
3502     operands[1] = force_reg (DFmode, operands[1]);
3503 }")
3504
3505 (define_insn "*extenddfxf2_1"
3506   [(set (match_operand:XF 0 "nonimmediate_operand" "=f,m")
3507         (float_extend:XF (match_operand:DF 1 "nonimmediate_operand" "fm,f")))]
3508   "TARGET_80387
3509    && (GET_CODE (operands[0]) != MEM || GET_CODE (operands[1]) != MEM)"
3510   "*
3511 {
3512   switch (which_alternative)
3513     {
3514     case 0:
3515       if (REG_P (operands[1])
3516           && find_regno_note (insn, REG_DEAD, REGNO (operands[1])))
3517         return \"fstp\\t%y0\";
3518       else if (STACK_TOP_P (operands[0]))
3519         return \"fld%z1\\t%y1\";
3520       else
3521         return \"fst\\t%y0\";
3522
3523     case 1:
3524       /* There is no non-popping store to memory for XFmode.  So if
3525          we need one, follow the store with a load.  */
3526       if (! find_regno_note (insn, REG_DEAD, REGNO (operands[1])))
3527         return \"fstp%z0\\t%y0\\n\\tfld%z0\\t%y0\";
3528       else
3529         return \"fstp%z0\\t%y0\";
3530
3531     default:
3532       abort ();
3533     }
3534 }"
3535   [(set_attr "type" "fmov")
3536    (set_attr "mode" "DF,XF")])
3537
3538 (define_expand "extenddftf2"
3539   [(set (match_operand:TF 0 "nonimmediate_operand" "")
3540         (float_extend:TF (match_operand:DF 1 "nonimmediate_operand" "")))]
3541   "TARGET_80387"
3542   "
3543 {
3544   if (GET_CODE (operands[0]) == MEM && GET_CODE (operands[1]) == MEM)
3545     operands[1] = force_reg (DFmode, operands[1]);
3546 }")
3547
3548 (define_insn "*extenddftf2_1"
3549   [(set (match_operand:TF 0 "nonimmediate_operand" "=f,m")
3550         (float_extend:TF (match_operand:DF 1 "nonimmediate_operand" "fm,f")))]
3551   "TARGET_80387
3552    && (GET_CODE (operands[0]) != MEM || GET_CODE (operands[1]) != MEM)"
3553   "*
3554 {
3555   switch (which_alternative)
3556     {
3557     case 0:
3558       if (REG_P (operands[1])
3559           && find_regno_note (insn, REG_DEAD, REGNO (operands[1])))
3560         return \"fstp\\t%y0\";
3561       else if (STACK_TOP_P (operands[0]))
3562         return \"fld%z1\\t%y1\";
3563       else
3564         return \"fst\\t%y0\";
3565
3566     case 1:
3567       /* There is no non-popping store to memory for XFmode.  So if
3568          we need one, follow the store with a load.  */
3569       if (! find_regno_note (insn, REG_DEAD, REGNO (operands[1])))
3570         return \"fstp%z0\\t%y0\\n\\tfld%z0\\t%y0\";
3571       else
3572         return \"fstp%z0\\t%y0\";
3573
3574     default:
3575       abort ();
3576     }
3577 }"
3578   [(set_attr "type" "fmov")
3579    (set_attr "mode" "DF,XF")])
3580
3581 ;; %%% This seems bad bad news.
3582 ;; This cannot output into an f-reg because there is no way to be sure
3583 ;; of truncating in that case.  Otherwise this is just like a simple move
3584 ;; insn.  So we pretend we can output to a reg in order to get better
3585 ;; register preferencing, but we really use a stack slot.
3586
3587 (define_expand "truncdfsf2"
3588   [(parallel [(set (match_operand:SF 0 "nonimmediate_operand" "")
3589                    (float_truncate:SF
3590                     (match_operand:DF 1 "register_operand" "")))
3591               (clobber (match_dup 2))])]
3592   "TARGET_80387 || TARGET_SSE2"
3593   "
3594    if (TARGET_80387)
3595      operands[2] = assign_386_stack_local (SFmode, 0);
3596    else
3597      {
3598         emit_insn (gen_truncdfsf2_sse_only (operands[0], operands[1]));
3599         DONE;
3600      }
3601 ")
3602
3603 (define_insn "*truncdfsf2_1"
3604   [(set (match_operand:SF 0 "nonimmediate_operand" "=m,?f")
3605         (float_truncate:SF
3606          (match_operand:DF 1 "register_operand" "f,0")))
3607    (clobber (match_operand:SF 2 "memory_operand" "=X,m"))]
3608   "TARGET_80387 && !TARGET_SSE2"
3609   "*
3610 {
3611   switch (which_alternative)
3612     {
3613     case 0:
3614       if (find_regno_note (insn, REG_DEAD, REGNO (operands[1])))
3615         return \"fstp%z0\\t%y0\";
3616       else
3617         return \"fst%z0\\t%y0\";
3618     case 1:
3619       return \"fstp%z2\\t%y2\;fld%z2\\t%y2\";
3620     }
3621   abort ();
3622 }"
3623   [(set_attr "type" "fmov,multi")
3624    (set_attr "mode" "SF,SF")])
3625
3626 (define_insn "*truncdfsf2_1_sse"
3627   [(set (match_operand:SF 0 "nonimmediate_operand" "=*!m,?f,Y")
3628         (float_truncate:SF
3629          (match_operand:DF 1 "nonimmediate_operand" "f,0,mY")))
3630    (clobber (match_operand:SF 2 "memory_operand" "=X,m,X"))]
3631   "TARGET_80387 && TARGET_SSE2"
3632   "*
3633 {
3634   switch (which_alternative)
3635     {
3636     case 0:
3637       if (find_regno_note (insn, REG_DEAD, REGNO (operands[1])))
3638         return \"fstp%z0\\t%y0\";
3639       else
3640         return \"fst%z0\\t%y0\";
3641     case 1:
3642       return \"fstp%z2\\t%y2\;fld%z2\\t%y2\";
3643     case 2:
3644     case 3:
3645       return \"cvtsd2ss\\t{%1, %0|%0, %1}\";
3646     }
3647   abort ();
3648 }"
3649   [(set_attr "type" "fmov,multi,sse")
3650    (set_attr "mode" "SF,SF,DF")])
3651
3652 (define_insn "*truncdfsf2_2"
3653   [(set (match_operand:SF 0 "nonimmediate_operand" "=Y,!m")
3654         (float_truncate:SF
3655          (match_operand:DF 1 "nonimmediate_operand" "mY,f")))]
3656   "TARGET_80387 && TARGET_SSE2
3657    && (GET_CODE (operands[0]) != MEM || GET_CODE (operands[1]) != MEM)"
3658   "*
3659 {
3660   switch (which_alternative)
3661     {
3662     case 0:
3663       return \"cvtsd2ss\\t{%1, %0|%0, %1}\";
3664     case 1:
3665       if (find_regno_note (insn, REG_DEAD, REGNO (operands[1])))
3666         return \"fstp%z0\\t%y0\";
3667       else
3668         return \"fst%z0\\t%y0\";
3669     }
3670 }"
3671   [(set_attr "type" "sse,fmov")
3672    (set_attr "mode" "DF,SF")])
3673
3674 (define_insn "truncdfsf2_3"
3675   [(set (match_operand:SF 0 "nonimmediate_operand" "=m")
3676         (float_truncate:SF
3677          (match_operand:DF 1 "register_operand" "f")))]
3678   "TARGET_80387"
3679   "*
3680 {
3681   if (find_regno_note (insn, REG_DEAD, REGNO (operands[1])))
3682     return \"fstp%z0\\t%y0\";
3683   else
3684     return \"fst%z0\\t%y0\";
3685 }"
3686   [(set_attr "type" "fmov")
3687    (set_attr "mode" "SF")])
3688
3689 (define_insn "truncdfsf2_sse_only"
3690   [(set (match_operand:SF 0 "register_operand" "=Y")
3691         (float_truncate:SF
3692          (match_operand:DF 1 "nonimmediate_operand" "mY")))]
3693   "!TARGET_80387 && TARGET_SSE2"
3694   "cvtsd2ss\\t{%1, %0|%0, %1}"
3695   [(set_attr "type" "sse")
3696    (set_attr "mode" "DF")])
3697
3698 (define_split
3699   [(set (match_operand:SF 0 "memory_operand" "")
3700         (float_truncate:SF
3701          (match_operand:DF 1 "register_operand" "")))
3702    (clobber (match_operand:SF 2 "memory_operand" ""))]
3703   "TARGET_80387"
3704   [(set (match_dup 0) (float_truncate:SF (match_dup 1)))]
3705   "")
3706
3707 (define_split
3708   [(set (match_operand:SF 0 "nonimmediate_operand" "")
3709         (float_truncate:SF
3710          (match_operand:DF 1 "nonimmediate_operand" "")))
3711    (clobber (match_operand 2 "" ""))]
3712   "TARGET_80387 && !FP_REG_P (operands[0]) && !FP_REG_P (operands[1])"
3713   [(set (match_dup 0) (float_truncate:SF (match_dup 1)))]
3714   "")
3715
3716 (define_split
3717   [(set (match_operand:SF 0 "register_operand" "")
3718         (float_truncate:SF
3719          (match_operand:DF 1 "register_operand" "")))
3720    (clobber (match_operand:SF 2 "memory_operand" ""))]
3721   "TARGET_80387 && reload_completed
3722    && FP_REG_P (operands[0])"
3723   [(set (match_dup 2) (float_truncate:SF (match_dup 1)))
3724    (set (match_dup 0) (match_dup 2))]
3725   "")
3726
3727 (define_expand "truncxfsf2"
3728   [(parallel [(set (match_operand:SF 0 "nonimmediate_operand" "")
3729                    (float_truncate:SF
3730                     (match_operand:XF 1 "register_operand" "")))
3731               (clobber (match_dup 2))])]
3732   "TARGET_80387"
3733   "operands[2] = assign_386_stack_local (SFmode, 0);")
3734
3735 (define_insn "*truncxfsf2_1"
3736   [(set (match_operand:SF 0 "nonimmediate_operand" "=m,f")
3737         (float_truncate:SF
3738          (match_operand:XF 1 "register_operand" "f,0")))
3739    (clobber (match_operand:SF 2 "memory_operand" "=m,m"))]
3740   "TARGET_80387"
3741   "*
3742 {
3743   switch (which_alternative)
3744     {
3745     case 0:
3746       if (find_regno_note (insn, REG_DEAD, REGNO (operands[1])))
3747         return \"fstp%z0\\t%y0\";
3748       else
3749         return \"fst%z0\\t%y0\";
3750     case 1:
3751       return \"fstp%z2\\t%y2\;fld%z2\\t%y2\";
3752     }
3753   abort ();
3754 }"
3755   [(set_attr "type" "fmov,multi")
3756    (set_attr "mode" "SF")])
3757
3758 (define_insn "*truncxfsf2_2"
3759   [(set (match_operand:SF 0 "memory_operand" "=m")
3760         (float_truncate:SF
3761          (match_operand:XF 1 "register_operand" "f")))]
3762   "TARGET_80387"
3763   "*
3764 {
3765   if (find_regno_note (insn, REG_DEAD, REGNO (operands[1])))
3766     return \"fstp%z0\\t%y0\";
3767   else
3768     return \"fst%z0\\t%y0\";
3769 }"
3770   [(set_attr "type" "fmov")
3771    (set_attr "mode" "SF")])
3772
3773 (define_split
3774   [(set (match_operand:SF 0 "memory_operand" "")
3775         (float_truncate:SF
3776          (match_operand:XF 1 "register_operand" "")))
3777    (clobber (match_operand:SF 2 "memory_operand" ""))]
3778   "TARGET_80387"
3779   [(set (match_dup 0) (float_truncate:SF (match_dup 1)))]
3780   "")
3781
3782 (define_split
3783   [(set (match_operand:SF 0 "register_operand" "")
3784         (float_truncate:SF
3785          (match_operand:XF 1 "register_operand" "")))
3786    (clobber (match_operand:SF 2 "memory_operand" ""))]
3787   "TARGET_80387 && reload_completed"
3788   [(set (match_dup 2) (float_truncate:SF (match_dup 1)))
3789    (set (match_dup 0) (match_dup 2))]
3790   "")
3791
3792 (define_expand "trunctfsf2"
3793   [(parallel [(set (match_operand:SF 0 "nonimmediate_operand" "")
3794                    (float_truncate:SF
3795                     (match_operand:TF 1 "register_operand" "")))
3796               (clobber (match_dup 2))])]
3797   "TARGET_80387"
3798   "operands[2] = assign_386_stack_local (SFmode, 0);")
3799
3800 (define_insn "*trunctfsf2_1"
3801   [(set (match_operand:SF 0 "nonimmediate_operand" "=m,f")
3802         (float_truncate:SF
3803          (match_operand:TF 1 "register_operand" "f,0")))
3804    (clobber (match_operand:SF 2 "memory_operand" "=m,m"))]
3805   "TARGET_80387"
3806   "*
3807 {
3808   switch (which_alternative)
3809     {
3810     case 0:
3811       if (find_regno_note (insn, REG_DEAD, REGNO (operands[1])))
3812         return \"fstp%z0\\t%y0\";
3813       else
3814         return \"fst%z0\\t%y0\";
3815     case 1:
3816       return \"fstp%z2\\t%y2\;fld%z2\\t%y2\";
3817     }
3818   abort ();
3819 }"
3820   [(set_attr "type" "fmov,multi")
3821    (set_attr "mode" "SF")])
3822
3823 (define_insn "*truncxfsf2_2"
3824   [(set (match_operand:SF 0 "nonimmediate_operand" "=m")
3825         (float_truncate:SF
3826          (match_operand:TF 1 "register_operand" "f")))]
3827   "TARGET_80387"
3828   "*
3829 {
3830   if (find_regno_note (insn, REG_DEAD, REGNO (operands[1])))
3831     return \"fstp%z0\\t%y0\";
3832   else
3833     return \"fst%z0\\t%y0\";
3834 }"
3835   [(set_attr "type" "fmov")
3836    (set_attr "mode" "SF")])
3837
3838 (define_split
3839   [(set (match_operand:SF 0 "memory_operand" "")
3840         (float_truncate:SF
3841          (match_operand:TF 1 "register_operand" "")))
3842    (clobber (match_operand:SF 2 "memory_operand" ""))]
3843   "TARGET_80387"
3844   [(set (match_dup 0) (float_truncate:SF (match_dup 1)))]
3845   "")
3846
3847 (define_split
3848   [(set (match_operand:SF 0 "register_operand" "")
3849         (float_truncate:SF
3850          (match_operand:TF 1 "register_operand" "")))
3851    (clobber (match_operand:SF 2 "memory_operand" ""))]
3852   "TARGET_80387 && reload_completed"
3853   [(set (match_dup 2) (float_truncate:SF (match_dup 1)))
3854    (set (match_dup 0) (match_dup 2))]
3855   "")
3856
3857
3858 (define_expand "truncxfdf2"
3859   [(parallel [(set (match_operand:DF 0 "nonimmediate_operand" "")
3860                    (float_truncate:DF
3861                     (match_operand:XF 1 "register_operand" "")))
3862               (clobber (match_dup 2))])]
3863   "TARGET_80387"
3864   "operands[2] = assign_386_stack_local (DFmode, 0);")
3865
3866 (define_insn "*truncxfdf2_1"
3867   [(set (match_operand:DF 0 "nonimmediate_operand" "=m,f")
3868         (float_truncate:DF
3869          (match_operand:XF 1 "register_operand" "f,0")))
3870    (clobber (match_operand:DF 2 "memory_operand" "=m,m"))]
3871   "TARGET_80387"
3872   "*
3873 {
3874   switch (which_alternative)
3875     {
3876     case 0:
3877       if (find_regno_note (insn, REG_DEAD, REGNO (operands[1])))
3878         return \"fstp%z0\\t%y0\";
3879       else
3880         return \"fst%z0\\t%y0\";
3881     case 1:
3882       return \"fstp%z2\\t%y2\;fld%z2\\t%y2\";
3883     }
3884   abort ();
3885 }"
3886   [(set_attr "type" "fmov,multi")
3887    (set_attr "mode" "DF")])
3888
3889 (define_insn "*truncxfdf2_2"
3890   [(set (match_operand:DF 0 "memory_operand" "=m")
3891         (float_truncate:DF
3892           (match_operand:XF 1 "register_operand" "f")))]
3893   "TARGET_80387"
3894   "*
3895 {
3896   if (find_regno_note (insn, REG_DEAD, REGNO (operands[1])))
3897     return \"fstp%z0\\t%y0\";
3898   else
3899     return \"fst%z0\\t%y0\";
3900 }"
3901   [(set_attr "type" "fmov")
3902    (set_attr "mode" "DF")])
3903
3904 (define_split
3905   [(set (match_operand:DF 0 "memory_operand" "")
3906         (float_truncate:DF
3907          (match_operand:XF 1 "register_operand" "")))
3908    (clobber (match_operand:DF 2 "memory_operand" ""))]
3909   "TARGET_80387"
3910   [(set (match_dup 0) (float_truncate:DF (match_dup 1)))]
3911   "")
3912
3913 (define_split
3914   [(set (match_operand:DF 0 "register_operand" "")
3915         (float_truncate:DF
3916          (match_operand:XF 1 "register_operand" "")))
3917    (clobber (match_operand:DF 2 "memory_operand" ""))]
3918   "TARGET_80387 && reload_completed"
3919   [(set (match_dup 2) (float_truncate:DF (match_dup 1)))
3920    (set (match_dup 0) (match_dup 2))]
3921   "")
3922
3923 (define_expand "trunctfdf2"
3924   [(parallel [(set (match_operand:DF 0 "nonimmediate_operand" "")
3925                    (float_truncate:DF
3926                     (match_operand:TF 1 "register_operand" "")))
3927               (clobber (match_dup 2))])]
3928   "TARGET_80387"
3929   "operands[2] = assign_386_stack_local (DFmode, 0);")
3930
3931 (define_insn "*trunctfdf2_1"
3932   [(set (match_operand:DF 0 "nonimmediate_operand" "=m,f")
3933         (float_truncate:DF
3934          (match_operand:TF 1 "register_operand" "f,0")))
3935    (clobber (match_operand:DF 2 "memory_operand" "=m,m"))]
3936   "TARGET_80387"
3937   "*
3938 {
3939   switch (which_alternative)
3940     {
3941     case 0:
3942       if (find_regno_note (insn, REG_DEAD, REGNO (operands[1])))
3943         return \"fstp%z0\\t%y0\";
3944       else
3945         return \"fst%z0\\t%y0\";
3946     case 1:
3947       return \"fstp%z2\\t%y2\;fld%z2\\t%y2\";
3948     }
3949   abort ();
3950 }"
3951   [(set_attr "type" "fmov,multi")
3952    (set_attr "mode" "DF")])
3953
3954 (define_insn "*truncxfdf2_2"
3955   [(set (match_operand:DF 0 "memory_operand" "=m")
3956         (float_truncate:DF
3957           (match_operand:TF 1 "register_operand" "f")))]
3958   "TARGET_80387"
3959   "*
3960 {
3961   if (find_regno_note (insn, REG_DEAD, REGNO (operands[1])))
3962     return \"fstp%z0\\t%y0\";
3963   else
3964     return \"fst%z0\\t%y0\";
3965 }"
3966   [(set_attr "type" "fmov")
3967    (set_attr "mode" "DF")])
3968
3969 (define_split
3970   [(set (match_operand:DF 0 "memory_operand" "")
3971         (float_truncate:DF
3972          (match_operand:TF 1 "register_operand" "")))
3973    (clobber (match_operand:DF 2 "memory_operand" ""))]
3974   "TARGET_80387"
3975   [(set (match_dup 0) (float_truncate:DF (match_dup 1)))]
3976   "")
3977
3978 (define_split
3979   [(set (match_operand:DF 0 "register_operand" "")
3980         (float_truncate:DF
3981          (match_operand:TF 1 "register_operand" "")))
3982    (clobber (match_operand:DF 2 "memory_operand" ""))]
3983   "TARGET_80387 && reload_completed"
3984   [(set (match_dup 2) (float_truncate:DF (match_dup 1)))
3985    (set (match_dup 0) (match_dup 2))]
3986   "")
3987
3988 \f
3989 ;; %%% Break up all these bad boys.
3990
3991 ;; Signed conversion to DImode.
3992
3993 (define_expand "fix_truncxfdi2"
3994   [(parallel [(set (match_operand:DI 0 "nonimmediate_operand" "")
3995                    (fix:DI (match_operand:XF 1 "register_operand" "")))
3996               (clobber (match_dup 2))
3997               (clobber (match_dup 3))
3998               (clobber (match_scratch:SI 4 ""))
3999               (clobber (match_scratch:XF 5 ""))])]
4000   "TARGET_80387"
4001   "operands[2] = assign_386_stack_local (SImode, 0);
4002    operands[3] = assign_386_stack_local (DImode, 1);")
4003
4004 (define_expand "fix_trunctfdi2"
4005   [(parallel [(set (match_operand:DI 0 "nonimmediate_operand" "")
4006                    (fix:DI (match_operand:TF 1 "register_operand" "")))
4007               (clobber (match_dup 2))
4008               (clobber (match_dup 3))
4009               (clobber (match_scratch:SI 4 ""))
4010               (clobber (match_scratch:TF 5 ""))])]
4011   "TARGET_80387"
4012   "operands[2] = assign_386_stack_local (SImode, 0);
4013    operands[3] = assign_386_stack_local (DImode, 1);")
4014
4015 (define_expand "fix_truncdfdi2"
4016   [(parallel [(set (match_operand:DI 0 "nonimmediate_operand" "")
4017                    (fix:DI (match_operand:DF 1 "register_operand" "")))
4018               (clobber (match_dup 2))
4019               (clobber (match_dup 3))
4020               (clobber (match_scratch:SI 4 ""))
4021               (clobber (match_scratch:DF 5 ""))])]
4022   "TARGET_80387"
4023   "operands[2] = assign_386_stack_local (SImode, 0);
4024    operands[3] = assign_386_stack_local (DImode, 1);")
4025
4026 (define_expand "fix_truncsfdi2"
4027   [(parallel [(set (match_operand:DI 0 "nonimmediate_operand" "")
4028                    (fix:DI (match_operand:SF 1 "register_operand" "")))
4029               (clobber (match_dup 2))
4030               (clobber (match_dup 3))
4031               (clobber (match_scratch:SI 4 ""))
4032               (clobber (match_scratch:SF 5 ""))])]
4033   "TARGET_80387"
4034   "operands[2] = assign_386_stack_local (SImode, 0);
4035    operands[3] = assign_386_stack_local (DImode, 1);")
4036
4037 (define_insn "*fix_truncdi_1"
4038   [(set (match_operand:DI 0 "nonimmediate_operand" "=m,?r")
4039         (fix:DI (match_operand 1 "register_operand" "f,f")))
4040    (clobber (match_operand:SI 2 "memory_operand" "=o,o"))
4041    (clobber (match_operand:DI 3 "memory_operand" "=m,m"))
4042    (clobber (match_scratch:SI 4 "=&r,&r"))
4043    (clobber (match_scratch 5 "=&f,&f"))]
4044   "TARGET_80387 && FLOAT_MODE_P (GET_MODE (operands[1]))"
4045   "* return output_fix_trunc (insn, operands);"
4046   [(set_attr "type" "multi")])
4047
4048 (define_split 
4049   [(set (match_operand:DI 0 "register_operand" "")
4050         (fix:DI (match_operand 1 "register_operand" "")))
4051    (clobber (match_operand:SI 2 "memory_operand" ""))
4052    (clobber (match_operand:DI 3 "memory_operand" ""))
4053    (clobber (match_scratch:SI 4 ""))
4054    (clobber (match_scratch 5 ""))]
4055   "reload_completed && !reg_overlap_mentioned_p (operands[4], operands[3])"
4056   [(parallel [(set (match_dup 3) (fix:DI (match_dup 1)))
4057               (clobber (match_dup 2))
4058               (clobber (match_dup 3))
4059               (clobber (match_dup 4))
4060               (clobber (match_dup 5))])
4061    (set (match_dup 0) (match_dup 3))]
4062   "")
4063
4064 ;; Signed conversion to SImode.
4065
4066 (define_expand "fix_truncxfsi2"
4067   [(parallel [(set (match_operand:SI 0 "nonimmediate_operand" "")
4068                    (fix:SI (match_operand:XF 1 "register_operand" "")))
4069               (clobber (match_dup 2))
4070               (clobber (match_dup 3))
4071               (clobber (match_scratch:SI 4 ""))])]
4072   "TARGET_80387"
4073   "operands[2] = assign_386_stack_local (SImode, 0);
4074    operands[3] = assign_386_stack_local (SImode, 1);")
4075
4076 (define_expand "fix_trunctfsi2"
4077   [(parallel [(set (match_operand:SI 0 "nonimmediate_operand" "")
4078                    (fix:SI (match_operand:TF 1 "register_operand" "")))
4079               (clobber (match_dup 2))
4080               (clobber (match_dup 3))
4081               (clobber (match_scratch:SI 4 ""))])]
4082   "TARGET_80387"
4083   "operands[2] = assign_386_stack_local (SImode, 0);
4084    operands[3] = assign_386_stack_local (SImode, 1);")
4085
4086 (define_expand "fix_truncdfsi2"
4087   [(parallel [(set (match_operand:SI 0 "nonimmediate_operand" "")
4088                    (fix:SI (match_operand:DF 1 "register_operand" "")))
4089               (clobber (match_dup 2))
4090               (clobber (match_dup 3))
4091               (clobber (match_scratch:SI 4 ""))])]
4092   "TARGET_80387 || TARGET_SSE2"
4093   "
4094 {
4095   if (TARGET_SSE2)
4096    {
4097      rtx out = REG_P (operands[0]) ? operands[0] : gen_reg_rtx (SImode);
4098      emit_insn (gen_fix_truncdfsi_sse (out, operands[1]));
4099      if (out != operands[0])
4100         emit_move_insn (operands[0], out);
4101      DONE;
4102    }
4103   else
4104    {
4105      operands[2] = assign_386_stack_local (SImode, 0);
4106      operands[3] = assign_386_stack_local (SImode, 1);
4107    }
4108 }")
4109
4110 (define_expand "fix_truncsfsi2"
4111   [(parallel [(set (match_operand:SI 0 "nonimmediate_operand" "")
4112                    (fix:SI (match_operand:SF 1 "register_operand" "")))
4113               (clobber (match_dup 2))
4114               (clobber (match_dup 3))
4115               (clobber (match_scratch:SI 4 ""))])]
4116   "TARGET_80387 || TARGET_SSE"
4117   "
4118 {
4119   if (TARGET_SSE2)
4120    {
4121      rtx out = REG_P (operands[0]) ? operands[0] : gen_reg_rtx (SImode);
4122      emit_insn (gen_fix_truncdfsi_sse (out, operands[1]));
4123      if (out != operands[0])
4124         emit_move_insn (operands[0], out);
4125      DONE;
4126    }
4127   else
4128    {
4129      operands[2] = assign_386_stack_local (SImode, 0);
4130      operands[3] = assign_386_stack_local (SImode, 1);
4131    }
4132 }")
4133
4134 (define_insn "*fix_truncsi_1"
4135   [(set (match_operand:SI 0 "nonimmediate_operand" "=m,?r")
4136         (fix:SI (match_operand 1 "register_operand" "f,f")))
4137    (clobber (match_operand:SI 2 "memory_operand" "=o,o"))
4138    (clobber (match_operand:SI 3 "memory_operand" "=m,m"))
4139    (clobber (match_scratch:SI 4 "=&r,r"))]
4140   "TARGET_80387 && FLOAT_MODE_P (GET_MODE (operands[1]))
4141    && (!TARGET_SSE2 || !SSE_FLOAT_MODE_P (GET_MODE (operands[1])))"
4142   "* return output_fix_trunc (insn, operands);"
4143   [(set_attr "type" "multi")])
4144
4145 ;; When SSE available, it is always faster to use it!
4146 (define_insn "fix_truncsfsi_sse"
4147   [(set (match_operand:SI 0 "register_operand" "=r")
4148         (fix:SI (match_operand:SF 1 "nonimmediate_operand" "xm")))]
4149   "TARGET_SSE"
4150   "cvttss2si\\t{%1, %0|%0, %1}"
4151   [(set_attr "type" "sse")])
4152
4153 (define_insn "fix_truncdfsi_sse"
4154   [(set (match_operand:SI 0 "register_operand" "=r")
4155         (fix:SI (match_operand:DF 1 "nonimmediate_operand" "Ym")))]
4156   "TARGET_SSE2"
4157   "cvttsd2si\\t{%1, %0|%0, %1}"
4158   [(set_attr "type" "sse")])
4159
4160 (define_split 
4161   [(set (match_operand:SI 0 "register_operand" "")
4162         (fix:SI (match_operand 1 "register_operand" "")))
4163    (clobber (match_operand:SI 2 "memory_operand" ""))
4164    (clobber (match_operand:SI 3 "memory_operand" ""))
4165    (clobber (match_scratch:SI 4 ""))]
4166   "reload_completed"
4167   [(parallel [(set (match_dup 3) (fix:SI (match_dup 1)))
4168               (clobber (match_dup 2))
4169               (clobber (match_dup 3))
4170               (clobber (match_dup 4))])
4171    (set (match_dup 0) (match_dup 3))]
4172   "")
4173
4174 ;; Signed conversion to HImode.
4175
4176 (define_expand "fix_truncxfhi2"
4177   [(parallel [(set (match_operand:HI 0 "nonimmediate_operand" "")
4178                    (fix:HI (match_operand:XF 1 "register_operand" "")))
4179               (clobber (match_dup 2))
4180               (clobber (match_dup 3))
4181               (clobber (match_scratch:SI 4 ""))])]
4182   "TARGET_80387"
4183   "operands[2] = assign_386_stack_local (SImode, 0);
4184    operands[3] = assign_386_stack_local (HImode, 1);")
4185
4186 (define_expand "fix_trunctfhi2"
4187   [(parallel [(set (match_operand:HI 0 "nonimmediate_operand" "")
4188                    (fix:HI (match_operand:TF 1 "register_operand" "")))
4189               (clobber (match_dup 2))
4190               (clobber (match_dup 3))
4191               (clobber (match_scratch:SI 4 ""))])]
4192   "TARGET_80387"
4193   "operands[2] = assign_386_stack_local (SImode, 0);
4194    operands[3] = assign_386_stack_local (HImode, 1);")
4195
4196 (define_expand "fix_truncdfhi2"
4197   [(parallel [(set (match_operand:HI 0 "nonimmediate_operand" "")
4198                    (fix:HI (match_operand:DF 1 "register_operand" "")))
4199               (clobber (match_dup 2))
4200               (clobber (match_dup 3))
4201               (clobber (match_scratch:SI 4 ""))])]
4202   "TARGET_80387 && !TARGET_SSE2"
4203   "operands[2] = assign_386_stack_local (SImode, 0);
4204    operands[3] = assign_386_stack_local (HImode, 1);")
4205
4206 (define_expand "fix_truncsfhi2"
4207   [(parallel [(set (match_operand:HI 0 "nonimmediate_operand" "")
4208                    (fix:HI (match_operand:SF 1 "register_operand" "")))
4209               (clobber (match_dup 2))
4210               (clobber (match_dup 3))
4211               (clobber (match_scratch:SI 4 ""))])]
4212   "TARGET_80387 && !TARGET_SSE"
4213   "operands[2] = assign_386_stack_local (SImode, 0);
4214    operands[3] = assign_386_stack_local (HImode, 1);")
4215
4216 (define_insn "*fix_trunchi_1"
4217   [(set (match_operand:HI 0 "nonimmediate_operand" "=m,?r")
4218         (fix:HI (match_operand 1 "register_operand" "f,f")))
4219    (clobber (match_operand:SI 2 "memory_operand" "=o,o"))
4220    (clobber (match_operand:HI 3 "memory_operand" "=m,m"))
4221    (clobber (match_scratch:SI 4 "=&r,r"))]
4222   "TARGET_80387 && FLOAT_MODE_P (GET_MODE (operands[1]))
4223    && (TARGET_SSE2 || !SSE_FLOAT_MODE_P (GET_MODE (operands[1])))"
4224   "* return output_fix_trunc (insn, operands);"
4225   [(set_attr "type" "multi")])
4226
4227 (define_split 
4228   [(set (match_operand:HI 0 "register_operand" "")
4229         (fix:HI (match_operand 1 "register_operand" "")))
4230    (clobber (match_operand:SI 2 "memory_operand" ""))
4231    (clobber (match_operand:HI 3 "memory_operand" ""))
4232    (clobber (match_scratch:SI 4 ""))]
4233   "reload_completed"
4234   [(parallel [(set (match_dup 3) (fix:HI (match_dup 1)))
4235               (clobber (match_dup 2))
4236               (clobber (match_dup 3))
4237               (clobber (match_dup 4))])
4238    (set (match_dup 0) (match_dup 3))]
4239   "")
4240
4241 ;; %%% Kill these when reload knows how to do it.
4242 (define_split
4243   [(set (match_operand 0 "register_operand" "")
4244         (fix (match_operand 1 "register_operand" "")))]
4245   "reload_completed && FLOAT_MODE_P (GET_MODE (operands[1]))
4246    && FP_REG_P (operands[1])"
4247   [(const_int 0)]
4248   "
4249 {
4250   operands[2] = ix86_force_to_memory (GET_MODE (operands[0]), operands[0]);
4251   operands[2] = gen_rtx_FIX (GET_MODE (operands[2]), operands[1]);
4252   emit_insn (gen_rtx_SET (VOIDmode, operands[2], operands[1]));
4253   emit_move_insn (operands[0], operands[2]);
4254   ix86_free_from_memory (GET_MODE (operands[0]));
4255   DONE;
4256 }")
4257
4258 ;; %% Not used yet.
4259 (define_insn "x86_fnstcw_1"
4260   [(set (match_operand:HI 0 "memory_operand" "=m")
4261         (unspec:HI [(reg:HI 18)] 11))]
4262   "TARGET_80387"
4263   "fnstcw\\t%0"
4264   [(set_attr "length" "2")
4265    (set_attr "mode" "HI")
4266    (set_attr "i387" "1")
4267    (set_attr "ppro_uops" "few")])
4268
4269 (define_insn "x86_fldcw_1"
4270   [(set (reg:HI 18)
4271         (unspec:HI [(match_operand:HI 0 "memory_operand" "m")] 12))]
4272   "TARGET_80387"
4273   "fldcw\\t%0"
4274   [(set_attr "length" "2")
4275    (set_attr "mode" "HI")
4276    (set_attr "i387" "1")
4277    (set_attr "athlon_decode" "vector")
4278    (set_attr "ppro_uops" "few")])
4279 \f
4280 ;; Conversion between fixed point and floating point.
4281
4282 ;; Even though we only accept memory inputs, the backend _really_
4283 ;; wants to be able to do this between registers.
4284
4285 (define_insn "floathisf2"
4286   [(set (match_operand:SF 0 "register_operand" "=f,f")
4287         (float:SF (match_operand:HI 1 "nonimmediate_operand" "m,r")))]
4288   "TARGET_80387 && !TARGET_SSE"
4289   "@
4290    fild%z1\\t%1
4291    #"
4292   [(set_attr "type" "fmov,multi")
4293    (set_attr "mode" "SF")
4294    (set_attr "fp_int_src" "true")])
4295
4296 (define_expand "floatsisf2"
4297   [(set (match_operand:SF 0 "register_operand" "")
4298         (float:SF (match_operand:SI 1 "nonimmediate_operand" "")))]
4299   "TARGET_SSE || TARGET_80387"
4300   "")
4301
4302 (define_insn "*floatsisf2_i387"
4303   [(set (match_operand:SF 0 "register_operand" "=f,?f,x")
4304         (float:SF (match_operand:SI 1 "nonimmediate_operand" "m,r,mr")))]
4305   "TARGET_80387 && (!TARGET_SSE || TARGET_MIX_SSE_I387)"
4306   "@
4307    fild%z1\\t%1
4308    #
4309    cvtsi2ss\\t{%1, %0|%0, %1}"
4310   [(set_attr "type" "fmov,multi,sse")
4311    (set_attr "mode" "SF")
4312    (set_attr "fp_int_src" "true")])
4313
4314 (define_insn "*floatsisf2_sse"
4315   [(set (match_operand:SF 0 "register_operand" "=x")
4316         (float:SF (match_operand:SI 1 "nonimmediate_operand" "mr")))]
4317   "TARGET_80387 && TARGET_SSE"
4318   "cvtsi2ss\\t{%1, %0|%0, %1}"
4319   [(set_attr "type" "sse")
4320    (set_attr "mode" "SF")
4321    (set_attr "fp_int_src" "true")])
4322
4323 (define_insn "floatdisf2"
4324   [(set (match_operand:SF 0 "register_operand" "=f,f")
4325         (float:SF (match_operand:DI 1 "nonimmediate_operand" "m,r")))]
4326   "TARGET_80387"
4327   "@
4328    fild%z1\\t%1
4329    #"
4330   [(set_attr "type" "fmov,multi")
4331    (set_attr "mode" "SF")
4332    (set_attr "fp_int_src" "true")])
4333
4334 (define_insn "floathidf2"
4335   [(set (match_operand:DF 0 "register_operand" "=f,f")
4336         (float:DF (match_operand:HI 1 "nonimmediate_operand" "m,r")))]
4337   "TARGET_80387 && !TARGET_SSE2"
4338   "@
4339    fild%z1\\t%1
4340    #"
4341   [(set_attr "type" "fmov,multi")
4342    (set_attr "mode" "DF")
4343    (set_attr "fp_int_src" "true")])
4344
4345 (define_expand "floatsidf2"
4346   [(set (match_operand:DF 0 "register_operand" "")
4347         (float:DF (match_operand:SI 1 "nonimmediate_operand" "")))]
4348   ""
4349   "")
4350
4351 (define_insn "*floatsidf2_i387"
4352   [(set (match_operand:DF 0 "register_operand" "=f,?f,Y")
4353         (float:DF (match_operand:SI 1 "nonimmediate_operand" "m,r,mr")))]
4354   "TARGET_80387 && (!TARGET_SSE2 || TARGET_MIX_SSE_I387)"
4355   "@
4356    fild%z1\\t%1
4357    #
4358    cvtsi2sd\\t{%1, %0|%0, %1}"
4359   [(set_attr "type" "fmov,multi,sse")
4360    (set_attr "mode" "DF")
4361    (set_attr "fp_int_src" "true")])
4362
4363 (define_insn "*floatsidf2_sse"
4364   [(set (match_operand:DF 0 "register_operand" "=Y")
4365         (float:DF (match_operand:SI 1 "nonimmediate_operand" "mr")))]
4366   "TARGET_SSE2"
4367   "cvtsi2sd\\t{%1, %0|%0, %1}"
4368   [(set_attr "type" "sse")
4369    (set_attr "mode" "DF")
4370    (set_attr "fp_int_src" "true")])
4371
4372 (define_insn "floatdidf2"
4373   [(set (match_operand:DF 0 "register_operand" "=f,f")
4374         (float:DF (match_operand:DI 1 "nonimmediate_operand" "m,r")))]
4375   "TARGET_80387 && TARGET_SSE2"
4376   "@
4377    fild%z1\\t%1
4378    #"
4379   [(set_attr "type" "fmov,multi")
4380    (set_attr "mode" "DF")
4381    (set_attr "fp_int_src" "true")])
4382
4383 (define_insn "floathixf2"
4384   [(set (match_operand:XF 0 "register_operand" "=f,f")
4385         (float:XF (match_operand:HI 1 "nonimmediate_operand" "m,r")))]
4386   "TARGET_80387"
4387   "@
4388    fild%z1\\t%1
4389    #"
4390   [(set_attr "type" "fmov,multi")
4391    (set_attr "mode" "XF")
4392    (set_attr "fp_int_src" "true")])
4393
4394 (define_insn "floathitf2"
4395   [(set (match_operand:TF 0 "register_operand" "=f,f")
4396         (float:TF (match_operand:HI 1 "nonimmediate_operand" "m,r")))]
4397   "TARGET_80387"
4398   "@
4399    fild%z1\\t%1
4400    #"
4401   [(set_attr "type" "fmov,multi")
4402    (set_attr "mode" "XF")
4403    (set_attr "fp_int_src" "true")])
4404
4405 (define_insn "floatsixf2"
4406   [(set (match_operand:XF 0 "register_operand" "=f,f")
4407         (float:XF (match_operand:SI 1 "nonimmediate_operand" "m,r")))]
4408   "TARGET_80387"
4409   "@
4410    fild%z1\\t%1
4411    #"
4412   [(set_attr "type" "fmov,multi")
4413    (set_attr "mode" "XF")
4414    (set_attr "fp_int_src" "true")])
4415
4416 (define_insn "floatsitf2"
4417   [(set (match_operand:TF 0 "register_operand" "=f,f")
4418         (float:TF (match_operand:SI 1 "nonimmediate_operand" "m,r")))]
4419   "TARGET_80387"
4420   "@
4421    fild%z1\\t%1
4422    #"
4423   [(set_attr "type" "fmov,multi")
4424    (set_attr "mode" "XF")
4425    (set_attr "fp_int_src" "true")])
4426
4427 (define_insn "floatdixf2"
4428   [(set (match_operand:XF 0 "register_operand" "=f,f")
4429         (float:XF (match_operand:DI 1 "nonimmediate_operand" "m,r")))]
4430   "TARGET_80387"
4431   "@
4432    fild%z1\\t%1
4433    #"
4434   [(set_attr "type" "fmov,multi")
4435    (set_attr "mode" "XF")
4436    (set_attr "fp_int_src" "true")])
4437
4438 (define_insn "floatditf2"
4439   [(set (match_operand:TF 0 "register_operand" "=f,f")
4440         (float:TF (match_operand:DI 1 "nonimmediate_operand" "m,r")))]
4441   "TARGET_80387"
4442   "@
4443    fild%z1\\t%1
4444    #"
4445   [(set_attr "type" "fmov,multi")
4446    (set_attr "mode" "XF")
4447    (set_attr "fp_int_src" "true")])
4448
4449 ;; %%% Kill these when reload knows how to do it.
4450 (define_split
4451   [(set (match_operand 0 "register_operand" "")
4452         (float (match_operand 1 "register_operand" "")))]
4453   "reload_completed && FLOAT_MODE_P (GET_MODE (operands[0]))"
4454   [(const_int 0)]
4455   "
4456 {
4457   operands[2] = ix86_force_to_memory (GET_MODE (operands[1]), operands[1]);
4458   operands[2] = gen_rtx_FLOAT (GET_MODE (operands[0]), operands[2]);
4459   emit_insn (gen_rtx_SET (VOIDmode, operands[0], operands[2]));
4460   ix86_free_from_memory (GET_MODE (operands[1]));
4461   DONE;
4462 }")
4463 \f
4464 ;; Add instructions
4465
4466 ;; %%% define_expand from the very first?
4467 ;; %%% splits for addsidi3
4468 ;  [(set (match_operand:DI 0 "nonimmediate_operand" "")
4469 ;       (plus:DI (match_operand:DI 1 "general_operand" "")
4470 ;                (zero_extend:DI (match_operand:SI 2 "general_operand" ""))))]
4471
4472 (define_insn "adddi3"
4473   [(set (match_operand:DI 0 "nonimmediate_operand" "=r,o")
4474         (plus:DI (match_operand:DI 1 "nonimmediate_operand" "%0,0")
4475                  (match_operand:DI 2 "general_operand" "roiF,riF")))
4476    (clobber (reg:CC 17))]
4477   ""
4478   "#")
4479
4480 (define_split
4481   [(set (match_operand:DI 0 "nonimmediate_operand" "")
4482         (plus:DI (match_operand:DI 1 "nonimmediate_operand" "")
4483                  (match_operand:DI 2 "general_operand" "")))
4484    (clobber (reg:CC 17))]
4485   "reload_completed"
4486   [(parallel [(set (reg:CC 17) (unspec:CC [(match_dup 1) (match_dup 2)] 12))
4487               (set (match_dup 0) (plus:SI (match_dup 1) (match_dup 2)))])
4488    (parallel [(set (match_dup 3)
4489                    (plus:SI (plus:SI (ltu:SI (reg:CC 17) (const_int 0))
4490                                      (match_dup 4))
4491                             (match_dup 5)))
4492               (clobber (reg:CC 17))])]
4493   "split_di (operands+0, 1, operands+0, operands+3);
4494    split_di (operands+1, 1, operands+1, operands+4);
4495    split_di (operands+2, 1, operands+2, operands+5);")
4496
4497 (define_insn "*addsi3_carry"
4498   [(set (match_operand:SI 0 "nonimmediate_operand" "=rm,r")
4499           (plus:SI (plus:SI (ltu:SI (reg:CC 17) (const_int 0))
4500                             (match_operand:SI 1 "nonimmediate_operand" "%0,0"))
4501                    (match_operand:SI 2 "general_operand" "ri,rm")))
4502    (clobber (reg:CC 17))]
4503   "ix86_binary_operator_ok (PLUS, SImode, operands)"
4504   "adc{l}\\t{%2, %0|%0, %2}"
4505   [(set_attr "type" "alu")
4506    (set_attr "pent_pair" "pu")
4507    (set_attr "mode" "SI")
4508    (set_attr "ppro_uops" "few")])
4509
4510 (define_insn "*addsi3_cc"
4511   [(set (reg:CC 17) (unspec:CC [(match_operand:SI 1 "nonimmediate_operand" "%0,0")
4512                                 (match_operand:SI 2 "general_operand" "ri,rm")] 12))
4513    (set (match_operand:SI 0 "nonimmediate_operand" "=rm,r")
4514         (plus:SI (match_dup 1) (match_dup 2)))]
4515   "ix86_binary_operator_ok (PLUS, SImode, operands)"
4516   "add{l}\\t{%2, %0|%0, %2}"
4517   [(set_attr "type" "alu")
4518    (set_attr "mode" "SI")])
4519
4520 (define_insn "addqi3_cc"
4521   [(set (reg:CC 17) (unspec:CC [(match_operand:QI 1 "nonimmediate_operand" "%0,0")
4522                                 (match_operand:QI 2 "general_operand" "qi,qm")] 12))
4523    (set (match_operand:QI 0 "nonimmediate_operand" "=qm,q")
4524         (plus:QI (match_dup 1) (match_dup 2)))]
4525   "ix86_binary_operator_ok (PLUS, QImode, operands)"
4526   "add{b}\\t{%2, %0|%0, %2}"
4527   [(set_attr "type" "alu")
4528    (set_attr "mode" "QI")])
4529
4530 (define_expand "addsi3"
4531   [(parallel [(set (match_operand:SI 0 "nonimmediate_operand" "")
4532                    (plus:SI (match_operand:SI 1 "nonimmediate_operand" "")
4533                             (match_operand:SI 2 "general_operand" "")))
4534               (clobber (reg:CC 17))])]
4535   ""
4536   "ix86_expand_binary_operator (PLUS, SImode, operands); DONE;")
4537
4538 (define_insn "*lea_0"
4539   [(set (match_operand:SI 0 "register_operand" "=r")
4540         (match_operand:SI 1 "address_operand" "p"))]
4541   ""
4542   "lea{l}\\t{%a1, %0|%0, %a1}"
4543   [(set_attr "type" "lea")
4544    (set_attr "mode" "SI")])
4545
4546 ;; The lea patterns for non-Pmodes needs to be matched by several
4547 ;; insns converted to real lea by splitters.
4548
4549 (define_insn_and_split "*lea_general_1"
4550   [(set (match_operand 0 "register_operand" "=r")
4551         (plus (plus (match_operand 1 "register_operand" "r")
4552                     (match_operand 2 "register_operand" "r"))
4553               (match_operand 3 "immediate_operand" "i")))]
4554   "(GET_MODE (operands[0]) == QImode || GET_MODE (operands[0]) == HImode)
4555    && (!TARGET_PARTIAL_REG_STALL || optimize_size)
4556    && GET_MODE (operands[0]) == GET_MODE (operands[1])
4557    && GET_MODE (operands[0]) == GET_MODE (operands[2])
4558    && (GET_MODE (operands[0]) == GET_MODE (operands[3])
4559        || GET_MODE (operands[3]) == VOIDmode)"
4560   "#"
4561   "&& reload_completed"
4562   [(const_int 0)]
4563   "
4564 {
4565   rtx pat;
4566   operands[0] = gen_lowpart (SImode, operands[0]);
4567   operands[1] = gen_lowpart (Pmode, operands[1]);
4568   operands[2] = gen_lowpart (Pmode, operands[2]);
4569   operands[3] = gen_lowpart (Pmode, operands[3]);
4570   pat = gen_rtx_PLUS (Pmode, gen_rtx_PLUS (Pmode, operands[1], operands[2]),
4571                       operands[3]);
4572   if (Pmode != SImode)
4573     pat = gen_rtx_SUBREG (SImode, pat, 0);
4574   emit_insn (gen_rtx_SET (VOIDmode, operands[0], pat));
4575   DONE;
4576 }"
4577   [(set_attr "type" "lea")
4578    (set_attr "mode" "SI")])
4579
4580 (define_insn_and_split "*lea_general_2"
4581   [(set (match_operand 0 "register_operand" "=r")
4582         (plus (mult (match_operand 1 "register_operand" "r")
4583                     (match_operand 2 "const248_operand" "i"))
4584               (match_operand 3 "nonmemory_operand" "ri")))]
4585   "(GET_MODE (operands[0]) == QImode || GET_MODE (operands[0]) == HImode)
4586    && (!TARGET_PARTIAL_REG_STALL || optimize_size)
4587    && GET_MODE (operands[0]) == GET_MODE (operands[1])
4588    && (GET_MODE (operands[0]) == GET_MODE (operands[3])
4589        || GET_MODE (operands[3]) == VOIDmode)"
4590   "#"
4591   "&& reload_completed"
4592   [(const_int 0)]
4593   "
4594 {
4595   rtx pat;
4596   operands[0] = gen_lowpart (SImode, operands[0]);
4597   operands[1] = gen_lowpart (Pmode, operands[1]);
4598   operands[3] = gen_lowpart (Pmode, operands[3]);
4599   pat = gen_rtx_PLUS (Pmode, gen_rtx_MULT (Pmode, operands[1], operands[2]),
4600                       operands[3]);
4601   if (Pmode != SImode)
4602     pat = gen_rtx_SUBREG (SImode, pat, 0);
4603   emit_insn (gen_rtx_SET (VOIDmode, operands[0], pat));
4604   DONE;
4605 }"
4606   [(set_attr "type" "lea")
4607    (set_attr "mode" "SI")])
4608
4609 (define_insn_and_split "*lea_general_3"
4610   [(set (match_operand 0 "register_operand" "=r")
4611         (plus (plus (mult (match_operand 1 "register_operand" "r")
4612                           (match_operand 2 "const248_operand" "i"))
4613                     (match_operand 3 "register_operand" "r"))
4614               (match_operand 4 "immediate_operand" "i")))]
4615   "(GET_MODE (operands[0]) == QImode || GET_MODE (operands[0]) == HImode)
4616    && (!TARGET_PARTIAL_REG_STALL || optimize_size)
4617    && GET_MODE (operands[0]) == GET_MODE (operands[1])
4618    && GET_MODE (operands[0]) == GET_MODE (operands[3])"
4619   "#"
4620   "&& reload_completed"
4621   [(const_int 0)]
4622   "
4623 {
4624   rtx pat;
4625   operands[0] = gen_lowpart (SImode, operands[0]);
4626   operands[1] = gen_lowpart (Pmode, operands[1]);
4627   operands[3] = gen_lowpart (Pmode, operands[3]);
4628   operands[4] = gen_lowpart (Pmode, operands[4]);
4629   pat = gen_rtx_PLUS (Pmode,
4630                       gen_rtx_PLUS (Pmode, gen_rtx_MULT (Pmode, operands[1],
4631                                                          operands[2]),
4632                                     operands[3]),
4633                       operands[4]);
4634   if (Pmode != SImode)
4635     pat = gen_rtx_SUBREG (SImode, pat, 0);
4636   emit_insn (gen_rtx_SET (VOIDmode, operands[0], pat));
4637   DONE;
4638 }"
4639   [(set_attr "type" "lea")
4640    (set_attr "mode" "SI")])
4641
4642 (define_insn "*addsi_1"
4643   [(set (match_operand:SI 0 "nonimmediate_operand" "=r,rm,r")
4644         (plus:SI (match_operand:SI 1 "nonimmediate_operand" "%0,0,r")
4645                  (match_operand:SI 2 "general_operand" "rmni,rni,rni")))
4646    (clobber (reg:CC 17))]
4647   "ix86_binary_operator_ok (PLUS, SImode, operands)"
4648   "*
4649 {
4650   switch (get_attr_type (insn))
4651     {
4652     case TYPE_LEA:
4653       operands[2] = SET_SRC (XVECEXP (PATTERN (insn), 0, 0));
4654       return \"lea{l}\\t{%a2, %0|%0, %a2}\";
4655
4656     case TYPE_INCDEC:
4657       if (! rtx_equal_p (operands[0], operands[1]))
4658         abort ();
4659       if (operands[2] == const1_rtx)
4660         return \"inc{l}\\t%0\";
4661       else if (operands[2] == constm1_rtx)
4662         return \"dec{l}\\t%0\";
4663       else
4664         abort();
4665
4666     default:
4667       if (! rtx_equal_p (operands[0], operands[1]))
4668         abort ();
4669
4670       /* Make things pretty and `subl $4,%eax' rather than `addl $-4, %eax'.
4671          Exceptions: -128 encodes smaller than 128, so swap sign and op.  */
4672       if (GET_CODE (operands[2]) == CONST_INT
4673           && (INTVAL (operands[2]) == 128
4674               || (INTVAL (operands[2]) < 0
4675                   && INTVAL (operands[2]) != -128)))
4676         {
4677           operands[2] = GEN_INT (-INTVAL (operands[2]));
4678           return \"sub{l}\\t{%2, %0|%0, %2}\";
4679         }
4680       return \"add{l}\\t{%2, %0|%0, %2}\";
4681     }
4682 }"
4683   [(set (attr "type")
4684      (cond [(eq_attr "alternative" "2")
4685               (const_string "lea")
4686             ; Current assemblers are broken and do not allow @GOTOFF in
4687             ; ought but a memory context.
4688             (match_operand:SI 2 "pic_symbolic_operand" "")
4689               (const_string "lea")
4690             (match_operand:SI 2 "incdec_operand" "")
4691               (const_string "incdec")
4692            ]
4693            (const_string "alu")))
4694    (set_attr "mode" "SI")])
4695
4696 ;; Convert lea to the lea pattern to avoid flags dependency.
4697 (define_split
4698   [(set (match_operand 0 "register_operand" "")
4699         (plus (match_operand 1 "register_operand" "")
4700               (match_operand 2 "nonmemory_operand" "")))
4701    (clobber (reg:CC 17))]
4702   "reload_completed
4703    && true_regnum (operands[0]) != true_regnum (operands[1])"
4704   [(const_int 0)]
4705   "
4706 {
4707   rtx pat;
4708   /* In -fPIC mode the constructs like (const (unspec [symbol_ref]))
4709      may confuse gen_lowpart.  */
4710   if (GET_MODE (operands[0]) != Pmode)
4711     {
4712       operands[1] = gen_lowpart (Pmode, operands[1]);
4713       operands[2] = gen_lowpart (Pmode, operands[2]);
4714     }
4715   operands[0] = gen_lowpart (SImode, operands[0]);
4716   pat = gen_rtx_PLUS (Pmode, operands[1], operands[2]);
4717   if (Pmode != SImode)
4718     pat = gen_rtx_SUBREG (SImode, pat, 0);
4719   emit_insn (gen_rtx_SET (VOIDmode, operands[0], pat));
4720   DONE;
4721 }")
4722
4723 (define_insn "*addsi_2"
4724   [(set (reg 17)
4725         (compare
4726           (plus:SI (match_operand:SI 1 "nonimmediate_operand" "%0,0")
4727                    (match_operand:SI 2 "general_operand" "rmni,rni"))
4728           (const_int 0)))                       
4729    (set (match_operand:SI 0 "nonimmediate_operand" "=r,rm")
4730         (plus:SI (match_dup 1) (match_dup 2)))]
4731   "ix86_match_ccmode (insn, CCGOCmode)
4732    && ix86_binary_operator_ok (PLUS, SImode, operands)
4733    /* Current assemblers are broken and do not allow @GOTOFF in
4734       ought but a memory context. */
4735    && ! pic_symbolic_operand (operands[2], VOIDmode)"
4736   "*
4737 {
4738   switch (get_attr_type (insn))
4739     {
4740     case TYPE_INCDEC:
4741       if (! rtx_equal_p (operands[0], operands[1]))
4742         abort ();
4743       if (operands[2] == const1_rtx)
4744         return \"inc{l}\\t%0\";
4745       else if (operands[2] == constm1_rtx)
4746         return \"dec{l}\\t%0\";
4747       else
4748         abort();
4749
4750     default:
4751       if (! rtx_equal_p (operands[0], operands[1]))
4752         abort ();
4753       /* Make things pretty and `subl $4,%eax' rather than `addl $-4, %eax'.
4754          Exceptions: -128 encodes smaller than 128, so swap sign and op.  */
4755       if (GET_CODE (operands[2]) == CONST_INT
4756           && (INTVAL (operands[2]) == 128
4757               || (INTVAL (operands[2]) < 0
4758                   && INTVAL (operands[2]) != -128)))
4759         {
4760           operands[2] = GEN_INT (-INTVAL (operands[2]));
4761           return \"sub{l}\\t{%2, %0|%0, %2}\";
4762         }
4763       return \"add{l}\\t{%2, %0|%0, %2}\";
4764     }
4765 }"
4766   [(set (attr "type")
4767      (if_then_else (match_operand:SI 2 "incdec_operand" "")
4768         (const_string "incdec")
4769         (const_string "alu")))
4770    (set_attr "mode" "SI")])
4771
4772 (define_insn "*addsi_3"
4773   [(set (reg 17)
4774         (compare (neg:SI (match_operand:SI 2 "general_operand" "rmni"))
4775                  (match_operand:SI 1 "nonimmediate_operand" "%0")))
4776    (clobber (match_scratch:SI 0 "=r"))]
4777   "ix86_match_ccmode (insn, CCZmode)
4778    && (GET_CODE (operands[1]) != MEM || GET_CODE (operands[2]) != MEM)
4779    /* Current assemblers are broken and do not allow @GOTOFF in
4780       ought but a memory context. */
4781    && ! pic_symbolic_operand (operands[2], VOIDmode)"
4782   "*
4783 {
4784   switch (get_attr_type (insn))
4785     {
4786     case TYPE_INCDEC:
4787       if (! rtx_equal_p (operands[0], operands[1]))
4788         abort ();
4789       if (operands[2] == const1_rtx)
4790         return \"inc{l}\\t%0\";
4791       else if (operands[2] == constm1_rtx)
4792         return \"dec{l}\\t%0\";
4793       else
4794         abort();
4795
4796     default:
4797       if (! rtx_equal_p (operands[0], operands[1]))
4798         abort ();
4799       /* Make things pretty and `subl $4,%eax' rather than `addl $-4, %eax'.
4800          Exceptions: -128 encodes smaller than 128, so swap sign and op.  */
4801       if (GET_CODE (operands[2]) == CONST_INT
4802           && (INTVAL (operands[2]) == 128
4803               || (INTVAL (operands[2]) < 0
4804                   && INTVAL (operands[2]) != -128)))
4805         {
4806           operands[2] = GEN_INT (-INTVAL (operands[2]));
4807           return \"sub{l}\\t{%2, %0|%0, %2}\";
4808         }
4809       return \"add{l}\\t{%2, %0|%0, %2}\";
4810     }
4811 }"
4812   [(set (attr "type")
4813      (if_then_else (match_operand:SI 2 "incdec_operand" "")
4814         (const_string "incdec")
4815         (const_string "alu")))
4816    (set_attr "mode" "SI")])
4817
4818 ; For comparisons agains 1, -1 and 128, we may generate better code
4819 ; by converting cmp to add, inc or dec as done by peephole2.  This pattern
4820 ; is matched then.  We can't accept general immediate, because for
4821 ; case of overflows,  the result is messed up.
4822 ; This pattern also don't hold of 0x80000000, since the value overflows
4823 ; when negated.
4824 ; Also carry flag is reversed compared to cmp, so this converison is valid
4825 ; only for comparisons not depending on it.
4826 (define_insn "*addsi_4"
4827   [(set (reg 17)
4828         (compare (match_operand:SI 1 "nonimmediate_operand" "0")
4829                  (match_operand:SI 2 "const_int_operand" "n")))
4830    (clobber (match_scratch:SI 0 "=rm"))]
4831   "ix86_match_ccmode (insn, CCGCmode)
4832    && (INTVAL (operands[2]) & 0xffffffff) != 0x80000000"
4833   "*
4834 {
4835   switch (get_attr_type (insn))
4836     {
4837     case TYPE_INCDEC:
4838       if (operands[2] == constm1_rtx)
4839         return \"inc{l}\\t%0\";
4840       else if (operands[2] == const1_rtx)
4841         return \"dec{l}\\t%0\";
4842       else
4843         abort();
4844
4845     default:
4846       if (! rtx_equal_p (operands[0], operands[1]))
4847         abort ();
4848       /* Make things pretty and `subl $4,%eax' rather than `addl $-4, %eax'.
4849          Exceptions: -128 encodes smaller than 128, so swap sign and op.  */
4850       if ((INTVAL (operands[2]) == -128
4851            || (INTVAL (operands[2]) > 0
4852                && INTVAL (operands[2]) != 128)))
4853         return \"sub{l}\\t{%2, %0|%0, %2}\";
4854       operands[2] = GEN_INT (-INTVAL (operands[2]));
4855       return \"add{l}\\t{%2, %0|%0, %2}\";
4856     }
4857 }"
4858   [(set (attr "type")
4859      (if_then_else (match_operand:SI 2 "incdec_operand" "")
4860         (const_string "incdec")
4861         (const_string "alu")))
4862    (set_attr "mode" "SI")])
4863
4864 (define_insn "*addsi_5"
4865   [(set (reg 17)
4866         (compare
4867           (plus:SI (match_operand:SI 1 "nonimmediate_operand" "%0")
4868                    (match_operand:SI 2 "general_operand" "rmni"))
4869           (const_int 0)))                       
4870    (clobber (match_scratch:SI 0 "=r"))]
4871   "ix86_match_ccmode (insn, CCGOCmode)
4872    && (GET_CODE (operands[1]) != MEM || GET_CODE (operands[2]) != MEM)
4873    /* Current assemblers are broken and do not allow @GOTOFF in
4874       ought but a memory context. */
4875    && ! pic_symbolic_operand (operands[2], VOIDmode)"
4876   "*
4877 {
4878   switch (get_attr_type (insn))
4879     {
4880     case TYPE_INCDEC:
4881       if (! rtx_equal_p (operands[0], operands[1]))
4882         abort ();
4883       if (operands[2] == const1_rtx)
4884         return \"inc{l}\\t%0\";
4885       else if (operands[2] == constm1_rtx)
4886         return \"dec{l}\\t%0\";
4887       else
4888         abort();
4889
4890     default:
4891       if (! rtx_equal_p (operands[0], operands[1]))
4892         abort ();
4893       /* Make things pretty and `subl $4,%eax' rather than `addl $-4, %eax'.
4894          Exceptions: -128 encodes smaller than 128, so swap sign and op.  */
4895       if (GET_CODE (operands[2]) == CONST_INT
4896           && (INTVAL (operands[2]) == 128
4897               || (INTVAL (operands[2]) < 0
4898                   && INTVAL (operands[2]) != -128)))
4899         {
4900           operands[2] = GEN_INT (-INTVAL (operands[2]));
4901           return \"sub{l}\\t{%2, %0|%0, %2}\";
4902         }
4903       return \"add{l}\\t{%2, %0|%0, %2}\";
4904     }
4905 }"
4906   [(set (attr "type")
4907      (if_then_else (match_operand:SI 2 "incdec_operand" "")
4908         (const_string "incdec")
4909         (const_string "alu")))
4910    (set_attr "mode" "SI")])
4911
4912 (define_expand "addhi3"
4913   [(parallel [(set (match_operand:HI 0 "nonimmediate_operand" "")
4914                    (plus:HI (match_operand:HI 1 "nonimmediate_operand" "")
4915                             (match_operand:HI 2 "general_operand" "")))
4916               (clobber (reg:CC 17))])]
4917   "TARGET_HIMODE_MATH"
4918   "ix86_expand_binary_operator (PLUS, HImode, operands); DONE;")
4919
4920 ;; %%% After Dave's SUBREG_BYTE stuff goes in, re-enable incb %ah
4921 ;; type optimizations enabled by define-splits.  This is not important
4922 ;; for PII, and in fact harmful because of partial register stalls.
4923
4924 (define_insn "*addhi_1_lea"
4925   [(set (match_operand:HI 0 "nonimmediate_operand" "=rm,r,r")
4926         (plus:HI (match_operand:HI 1 "nonimmediate_operand" "%0,0,r")
4927                  (match_operand:HI 2 "general_operand" "ri,rm,rni")))
4928    (clobber (reg:CC 17))]
4929   "!TARGET_PARTIAL_REG_STALL
4930    && ix86_binary_operator_ok (PLUS, HImode, operands)"
4931   "*
4932 {
4933   switch (get_attr_type (insn))
4934     {
4935     case TYPE_LEA:
4936       return \"#\";
4937     case TYPE_INCDEC:
4938       if (operands[2] == const1_rtx)
4939         return \"inc{w}\\t%0\";
4940       else if (operands[2] == constm1_rtx
4941                || (GET_CODE (operands[2]) == CONST_INT
4942                    && INTVAL (operands[2]) == 65535))
4943         return \"dec{w}\\t%0\";
4944       abort();
4945
4946     default:
4947       /* Make things pretty and `subl $4,%eax' rather than `addl $-4, %eax'.
4948          Exceptions: -128 encodes smaller than 128, so swap sign and op.  */
4949       if (GET_CODE (operands[2]) == CONST_INT
4950           && (INTVAL (operands[2]) == 128
4951               || (INTVAL (operands[2]) < 0
4952                   && INTVAL (operands[2]) != -128)))
4953         {
4954           operands[2] = GEN_INT (-INTVAL (operands[2]));
4955           return \"sub{w}\\t{%2, %0|%0, %2}\";
4956         }
4957       return \"add{w}\\t{%2, %0|%0, %2}\";
4958     }
4959 }"
4960   [(set (attr "type")
4961      (if_then_else (eq_attr "alternative" "2")
4962         (const_string "lea")
4963         (if_then_else (match_operand:HI 2 "incdec_operand" "")
4964            (const_string "incdec")
4965            (const_string "alu"))))
4966    (set_attr "mode" "HI,HI,SI")])
4967
4968 (define_insn "*addhi_1"
4969   [(set (match_operand:HI 0 "nonimmediate_operand" "=rm,r")
4970         (plus:HI (match_operand:HI 1 "nonimmediate_operand" "%0,0")
4971                  (match_operand:HI 2 "general_operand" "ri,rm")))
4972    (clobber (reg:CC 17))]
4973   "TARGET_PARTIAL_REG_STALL
4974    && ix86_binary_operator_ok (PLUS, HImode, operands)"
4975   "*
4976 {
4977   switch (get_attr_type (insn))
4978     {
4979     case TYPE_INCDEC:
4980       if (operands[2] == const1_rtx)
4981         return \"inc{w}\\t%0\";
4982       else if (operands[2] == constm1_rtx
4983                || (GET_CODE (operands[2]) == CONST_INT
4984                    && INTVAL (operands[2]) == 65535))
4985         return \"dec{w}\\t%0\";
4986       abort();
4987
4988     default:
4989       /* Make things pretty and `subl $4,%eax' rather than `addl $-4, %eax'.
4990          Exceptions: -128 encodes smaller than 128, so swap sign and op.  */
4991       if (GET_CODE (operands[2]) == CONST_INT
4992           && (INTVAL (operands[2]) == 128
4993               || (INTVAL (operands[2]) < 0
4994                   && INTVAL (operands[2]) != -128)))
4995         {
4996           operands[2] = GEN_INT (-INTVAL (operands[2]));
4997           return \"sub{w}\\t{%2, %0|%0, %2}\";
4998         }
4999       return \"add{w}\\t{%2, %0|%0, %2}\";
5000     }
5001 }"
5002   [(set (attr "type")
5003      (if_then_else (match_operand:HI 2 "incdec_operand" "")
5004         (const_string "incdec")
5005         (const_string "alu")))
5006    (set_attr "mode" "HI")])
5007
5008 (define_insn "*addhi_2"
5009   [(set (reg 17)
5010         (compare
5011           (plus:HI (match_operand:HI 1 "nonimmediate_operand" "%0,0")
5012                    (match_operand:HI 2 "general_operand" "rmni,rni"))
5013           (const_int 0)))                       
5014    (set (match_operand:HI 0 "nonimmediate_operand" "=r,rm")
5015         (plus:HI (match_dup 1) (match_dup 2)))]
5016   "ix86_match_ccmode (insn, CCGOCmode)
5017    && ix86_binary_operator_ok (PLUS, HImode, operands)"
5018   "*
5019 {
5020   switch (get_attr_type (insn))
5021     {
5022     case TYPE_INCDEC:
5023       if (operands[2] == const1_rtx)
5024         return \"inc{w}\\t%0\";
5025       else if (operands[2] == constm1_rtx
5026                || (GET_CODE (operands[2]) == CONST_INT
5027                    && INTVAL (operands[2]) == 65535))
5028         return \"dec{w}\\t%0\";
5029       abort();
5030
5031     default:
5032       /* Make things pretty and `subl $4,%eax' rather than `addl $-4, %eax'.
5033          Exceptions: -128 encodes smaller than 128, so swap sign and op.  */
5034       if (GET_CODE (operands[2]) == CONST_INT
5035           && (INTVAL (operands[2]) == 128
5036               || (INTVAL (operands[2]) < 0
5037                   && INTVAL (operands[2]) != -128)))
5038         {
5039           operands[2] = GEN_INT (-INTVAL (operands[2]));
5040           return \"sub{w}\\t{%2, %0|%0, %2}\";
5041         }
5042       return \"add{w}\\t{%2, %0|%0, %2}\";
5043     }
5044 }"
5045   [(set (attr "type")
5046      (if_then_else (match_operand:HI 2 "incdec_operand" "")
5047         (const_string "incdec")
5048         (const_string "alu")))
5049    (set_attr "mode" "HI")])
5050
5051 (define_insn "*addhi_3"
5052   [(set (reg 17)
5053         (compare (neg:HI (match_operand:HI 2 "general_operand" "rmni"))
5054                  (match_operand:HI 1 "nonimmediate_operand" "%0")))
5055    (clobber (match_scratch:HI 0 "=r"))]
5056   "ix86_match_ccmode (insn, CCZmode)
5057    && (GET_CODE (operands[1]) != MEM || GET_CODE (operands[2]) != MEM)"
5058   "*
5059 {
5060   switch (get_attr_type (insn))
5061     {
5062     case TYPE_INCDEC:
5063       if (operands[2] == const1_rtx)
5064         return \"inc{w}\\t%0\";
5065       else if (operands[2] == constm1_rtx
5066                || (GET_CODE (operands[2]) == CONST_INT
5067                    && INTVAL (operands[2]) == 65535))
5068         return \"dec{w}\\t%0\";
5069       abort();
5070
5071     default:
5072       /* Make things pretty and `subl $4,%eax' rather than `addl $-4, %eax'.
5073          Exceptions: -128 encodes smaller than 128, so swap sign and op.  */
5074       if (GET_CODE (operands[2]) == CONST_INT
5075           && (INTVAL (operands[2]) == 128
5076               || (INTVAL (operands[2]) < 0
5077                   && INTVAL (operands[2]) != -128)))
5078         {
5079           operands[2] = GEN_INT (-INTVAL (operands[2]));
5080           return \"sub{w}\\t{%2, %0|%0, %2}\";
5081         }
5082       return \"add{w}\\t{%2, %0|%0, %2}\";
5083     }
5084 }"
5085   [(set (attr "type")
5086      (if_then_else (match_operand:HI 2 "incdec_operand" "")
5087         (const_string "incdec")
5088         (const_string "alu")))
5089    (set_attr "mode" "HI")])
5090
5091 ; See comments above addsi_3_imm for details.
5092 (define_insn "*addhi_4"
5093   [(set (reg 17)
5094         (compare (match_operand:HI 1 "nonimmediate_operand" "0")
5095                  (match_operand:HI 2 "const_int_operand" "n")))
5096    (clobber (match_scratch:HI 0 "=rm"))]
5097   "ix86_match_ccmode (insn, CCGCmode)
5098    && (INTVAL (operands[2]) & 0xffff) != 0x8000"
5099   "*
5100 {
5101   switch (get_attr_type (insn))
5102     {
5103     case TYPE_INCDEC:
5104       if (operands[2] == constm1_rtx
5105           || (GET_CODE (operands[2]) == CONST_INT
5106               && INTVAL (operands[2]) == 65535))
5107         return \"inc{w}\\t%0\";
5108       else if (operands[2] == const1_rtx)
5109         return \"dec{w}\\t%0\";
5110       else
5111         abort();
5112
5113     default:
5114       if (! rtx_equal_p (operands[0], operands[1]))
5115         abort ();
5116       /* Make things pretty and `subl $4,%eax' rather than `addl $-4, %eax'.
5117          Exceptions: -128 encodes smaller than 128, so swap sign and op.  */
5118       if ((INTVAL (operands[2]) == -128
5119            || (INTVAL (operands[2]) > 0
5120                && INTVAL (operands[2]) != 128)))
5121         return \"sub{w}\\t{%2, %0|%0, %2}\";
5122       operands[2] = GEN_INT (-INTVAL (operands[2]));
5123       return \"add{w}\\t{%2, %0|%0, %2}\";
5124     }
5125 }"
5126   [(set (attr "type")
5127      (if_then_else (match_operand:HI 2 "incdec_operand" "")
5128         (const_string "incdec")
5129         (const_string "alu")))
5130    (set_attr "mode" "SI")])
5131
5132
5133 (define_insn "*addhi_5"
5134   [(set (reg 17)
5135         (compare
5136           (plus:HI (match_operand:HI 1 "nonimmediate_operand" "%0")
5137                    (match_operand:HI 2 "general_operand" "rmni"))
5138           (const_int 0)))                       
5139    (clobber (match_scratch:HI 0 "=r"))]
5140   "ix86_match_ccmode (insn, CCGOCmode)
5141    && (GET_CODE (operands[1]) != MEM || GET_CODE (operands[2]) != MEM)"
5142   "*
5143 {
5144   switch (get_attr_type (insn))
5145     {
5146     case TYPE_INCDEC:
5147       if (operands[2] == const1_rtx)
5148         return \"inc{w}\\t%0\";
5149       else if (operands[2] == constm1_rtx
5150                || (GET_CODE (operands[2]) == CONST_INT
5151                    && INTVAL (operands[2]) == 65535))
5152         return \"dec{w}\\t%0\";
5153       abort();
5154
5155     default:
5156       /* Make things pretty and `subl $4,%eax' rather than `addl $-4, %eax'.
5157          Exceptions: -128 encodes smaller than 128, so swap sign and op.  */
5158       if (GET_CODE (operands[2]) == CONST_INT
5159           && (INTVAL (operands[2]) == 128
5160               || (INTVAL (operands[2]) < 0
5161                   && INTVAL (operands[2]) != -128)))
5162         {
5163           operands[2] = GEN_INT (-INTVAL (operands[2]));
5164           return \"sub{w}\\t{%2, %0|%0, %2}\";
5165         }
5166       return \"add{w}\\t{%2, %0|%0, %2}\";
5167     }
5168 }"
5169   [(set (attr "type")
5170      (if_then_else (match_operand:HI 2 "incdec_operand" "")
5171         (const_string "incdec")
5172         (const_string "alu")))
5173    (set_attr "mode" "HI")])
5174
5175 (define_expand "addqi3"
5176   [(parallel [(set (match_operand:QI 0 "nonimmediate_operand" "")
5177                    (plus:QI (match_operand:QI 1 "nonimmediate_operand" "")
5178                             (match_operand:QI 2 "general_operand" "")))
5179               (clobber (reg:CC 17))])]
5180   "TARGET_QIMODE_MATH"
5181   "ix86_expand_binary_operator (PLUS, QImode, operands); DONE;")
5182
5183 ;; %%% Potential partial reg stall on alternative 2.  What to do?
5184 (define_insn "*addqi_1_lea"
5185   [(set (match_operand:QI 0 "nonimmediate_operand" "=qm,q,r,r")
5186         (plus:QI (match_operand:QI 1 "nonimmediate_operand" "%0,0,0,r")
5187                  (match_operand:QI 2 "general_operand" "qn,qmn,rn,rn")))
5188    (clobber (reg:CC 17))]
5189   "!TARGET_PARTIAL_REG_STALL
5190    && ix86_binary_operator_ok (PLUS, QImode, operands)"
5191   "*
5192 {
5193   int widen = (which_alternative == 2);
5194   switch (get_attr_type (insn))
5195     {
5196     case TYPE_LEA:
5197       return \"#\";
5198     case TYPE_INCDEC:
5199       if (operands[2] == const1_rtx)
5200         return widen ? \"inc{l}\\t%k0\" : \"inc{b}\\t%0\";
5201       else if (operands[2] == constm1_rtx
5202                || (GET_CODE (operands[2]) == CONST_INT
5203                    && INTVAL (operands[2]) == 255))
5204         return widen ? \"dec{l}\\t%k0\" : \"dec{b}\\t%0\";
5205       abort();
5206
5207     default:
5208       /* Make things pretty and `subl $4,%eax' rather than `addl $-4, %eax'.
5209          Exceptions: -128 encodes smaller than 128, so swap sign and op.  */
5210       if (GET_CODE (operands[2]) == CONST_INT
5211           && (INTVAL (operands[2]) == 128
5212               || (INTVAL (operands[2]) < 0
5213                   && INTVAL (operands[2]) != -128)))
5214         {
5215           operands[2] = GEN_INT (-INTVAL (operands[2]));
5216           if (widen)
5217             return \"sub{l}\\t{%2, %k0|%k0, %2}\";
5218           else
5219             return \"sub{b}\\t{%2, %0|%0, %2}\";
5220         }
5221       if (widen)
5222         return \"add{l}\\t{%k2, %k0|%k0, %k2}\";
5223       else
5224         return \"add{b}\\t{%2, %0|%0, %2}\";
5225     }
5226 }"
5227   [(set (attr "type")
5228      (if_then_else (eq_attr "alternative" "3")
5229         (const_string "lea")
5230         (if_then_else (match_operand:QI 2 "incdec_operand" "")
5231            (const_string "incdec")
5232            (const_string "alu"))))
5233    (set_attr "mode" "QI,QI,SI,SI")])
5234
5235 (define_insn "*addqi_1"
5236   [(set (match_operand:QI 0 "nonimmediate_operand" "=qm,q,r")
5237         (plus:QI (match_operand:QI 1 "nonimmediate_operand" "%0,0,0")
5238                  (match_operand:QI 2 "general_operand" "qn,qmn,rn")))
5239    (clobber (reg:CC 17))]
5240   "TARGET_PARTIAL_REG_STALL
5241    && ix86_binary_operator_ok (PLUS, QImode, operands)"
5242   "*
5243 {
5244   int widen = (which_alternative == 2);
5245   switch (get_attr_type (insn))
5246     {
5247     case TYPE_INCDEC:
5248       if (operands[2] == const1_rtx)
5249         return widen ? \"inc{l}\\t%k0\" : \"inc{b}\\t%0\";
5250       else if (operands[2] == constm1_rtx
5251                || (GET_CODE (operands[2]) == CONST_INT
5252                    && INTVAL (operands[2]) == 255))
5253         return widen ? \"dec{l}\\t%k0\" : \"dec{b}\\t%0\";
5254       abort();
5255
5256     default:
5257       /* Make things pretty and `subl $4,%eax' rather than `addl $-4, %eax'.
5258          Exceptions: -128 encodes smaller than 128, so swap sign and op.  */
5259       if (GET_CODE (operands[2]) == CONST_INT
5260           && (INTVAL (operands[2]) == 128
5261               || (INTVAL (operands[2]) < 0
5262                   && INTVAL (operands[2]) != -128)))
5263         {
5264           operands[2] = GEN_INT (-INTVAL (operands[2]));
5265           if (widen)
5266             return \"sub{l}\\t{%2, %k0|%k0, %2}\";
5267           else
5268             return \"sub{b}\\t{%2, %0|%0, %2}\";
5269         }
5270       if (widen)
5271         return \"add{l}\\t{%k2, %k0|%k0, %k2}\";
5272       else
5273         return \"add{b}\\t{%2, %0|%0, %2}\";
5274     }
5275 }"
5276   [(set (attr "type")
5277      (if_then_else (match_operand:QI 2 "incdec_operand" "")
5278         (const_string "incdec")
5279         (const_string "alu")))
5280    (set_attr "mode" "QI,QI,SI")])
5281
5282 (define_insn "*addqi_2"
5283   [(set (reg 17)
5284         (compare
5285           (plus:QI (match_operand:QI 1 "nonimmediate_operand" "%0,0")
5286                    (match_operand:QI 2 "general_operand" "qmni,qni"))
5287           (const_int 0)))
5288    (set (match_operand:QI 0 "nonimmediate_operand" "=q,qm")
5289         (plus:QI (match_dup 1) (match_dup 2)))]
5290   "ix86_match_ccmode (insn, CCGOCmode)
5291    && ix86_binary_operator_ok (PLUS, QImode, operands)"
5292   "*
5293 {
5294   switch (get_attr_type (insn))
5295     {
5296     case TYPE_INCDEC:
5297       if (operands[2] == const1_rtx)
5298         return \"inc{b}\\t%0\";
5299       else if (operands[2] == constm1_rtx
5300                || (GET_CODE (operands[2]) == CONST_INT
5301                    && INTVAL (operands[2]) == 255))
5302         return \"dec{b}\\t%0\";
5303       abort();
5304
5305     default:
5306       /* Make things pretty and `subb $4,%al' rather than `addb $-4, %al'.  */
5307       if (GET_CODE (operands[2]) == CONST_INT
5308           && INTVAL (operands[2]) < 0)
5309         {
5310           operands[2] = GEN_INT (-INTVAL (operands[2]));
5311           return \"sub{b}\\t{%2, %0|%0, %2}\";
5312         }
5313       return \"add{b}\\t{%2, %0|%0, %2}\";
5314     }
5315 }"
5316   [(set (attr "type")
5317      (if_then_else (match_operand:QI 2 "incdec_operand" "")
5318         (const_string "incdec")
5319         (const_string "alu")))
5320    (set_attr "mode" "QI")])
5321
5322 (define_insn "*addqi_3"
5323   [(set (reg 17)
5324         (compare (neg:QI (match_operand:QI 2 "general_operand" "qmni"))
5325                  (match_operand:QI 1 "nonimmediate_operand" "%0")))
5326    (clobber (match_scratch:QI 0 "=q"))]
5327   "ix86_match_ccmode (insn, CCZmode)
5328    && (GET_CODE (operands[1]) != MEM || GET_CODE (operands[2]) != MEM)"
5329   "*
5330 {
5331   switch (get_attr_type (insn))
5332     {
5333     case TYPE_INCDEC:
5334       if (operands[2] == const1_rtx)
5335         return \"inc{b}\\t%0\";
5336       else if (operands[2] == constm1_rtx
5337                || (GET_CODE (operands[2]) == CONST_INT
5338                    && INTVAL (operands[2]) == 255))
5339         return \"dec{b}\\t%0\";
5340       abort();
5341
5342     default:
5343       /* Make things pretty and `subb $4,%al' rather than `addb $-4, %al'.  */
5344       if (GET_CODE (operands[2]) == CONST_INT
5345           && INTVAL (operands[2]) < 0)
5346         {
5347           operands[2] = GEN_INT (-INTVAL (operands[2]));
5348           return \"sub{b}\\t{%2, %0|%0, %2}\";
5349         }
5350       return \"add{b}\\t{%2, %0|%0, %2}\";
5351     }
5352 }"
5353   [(set (attr "type")
5354      (if_then_else (match_operand:QI 2 "incdec_operand" "")
5355         (const_string "incdec")
5356         (const_string "alu")))
5357    (set_attr "mode" "QI")])
5358
5359 ; See comments above addsi_3_imm for details.
5360 (define_insn "*addqi_4"
5361   [(set (reg 17)
5362         (compare (match_operand:QI 1 "nonimmediate_operand" "0")
5363                  (match_operand:QI 2 "const_int_operand" "n")))
5364    (clobber (match_scratch:QI 0 "=qm"))]
5365   "ix86_match_ccmode (insn, CCGCmode)
5366    && (INTVAL (operands[2]) & 0xff) != 0x80"
5367   "*
5368 {
5369   switch (get_attr_type (insn))
5370     {
5371     case TYPE_INCDEC:
5372       if (operands[2] == constm1_rtx
5373           || (GET_CODE (operands[2]) == CONST_INT
5374               && INTVAL (operands[2]) == 255))
5375         return \"inc{b}\\t%0\";
5376       else if (operands[2] == const1_rtx)
5377         return \"dec{b}\\t%0\";
5378       else
5379         abort();
5380
5381     default:
5382       if (! rtx_equal_p (operands[0], operands[1]))
5383         abort ();
5384       if (INTVAL (operands[2]) < 0)
5385         {
5386           operands[2] = GEN_INT (-INTVAL (operands[2]));
5387           return \"add{b}\\t{%2, %0|%0, %2}\";
5388         }
5389       return \"sub{b}\\t{%2, %0|%0, %2}\";
5390     }
5391 }"
5392   [(set (attr "type")
5393      (if_then_else (match_operand:HI 2 "incdec_operand" "")
5394         (const_string "incdec")
5395         (const_string "alu")))
5396    (set_attr "mode" "QI")])
5397
5398
5399 (define_insn "*addqi_5"
5400   [(set (reg 17)
5401         (compare
5402           (plus:QI (match_operand:QI 1 "nonimmediate_operand" "%0")
5403                    (match_operand:QI 2 "general_operand" "qmni"))
5404           (const_int 0)))
5405    (clobber (match_scratch:QI 0 "=q"))]
5406   "ix86_match_ccmode (insn, CCGOCmode)
5407    && (GET_CODE (operands[1]) != MEM || GET_CODE (operands[2]) != MEM)"
5408   "*
5409 {
5410   switch (get_attr_type (insn))
5411     {
5412     case TYPE_INCDEC:
5413       if (operands[2] == const1_rtx)
5414         return \"inc{b}\\t%0\";
5415       else if (operands[2] == constm1_rtx
5416                || (GET_CODE (operands[2]) == CONST_INT
5417                    && INTVAL (operands[2]) == 255))
5418         return \"dec{b}\\t%0\";
5419       abort();
5420
5421     default:
5422       /* Make things pretty and `subb $4,%al' rather than `addb $-4, %al'.  */
5423       if (GET_CODE (operands[2]) == CONST_INT
5424           && INTVAL (operands[2]) < 0)
5425         {
5426           operands[2] = GEN_INT (-INTVAL (operands[2]));
5427           return \"sub{b}\\t{%2, %0|%0, %2}\";
5428         }
5429       return \"add{b}\\t{%2, %0|%0, %2}\";
5430     }
5431 }"
5432   [(set (attr "type")
5433      (if_then_else (match_operand:QI 2 "incdec_operand" "")
5434         (const_string "incdec")
5435         (const_string "alu")))
5436    (set_attr "mode" "QI")])
5437
5438
5439 (define_insn "addqi_ext_1"
5440   [(set (zero_extract:SI (match_operand 0 "ext_register_operand" "=q")
5441                          (const_int 8)
5442                          (const_int 8))
5443         (plus:SI
5444           (zero_extract:SI
5445             (match_operand 1 "ext_register_operand" "0")
5446             (const_int 8)
5447             (const_int 8))
5448           (match_operand:QI 2 "general_operand" "qmn")))
5449    (clobber (reg:CC 17))]
5450   ""
5451   "*
5452 {
5453   switch (get_attr_type (insn))
5454     {
5455     case TYPE_INCDEC:
5456       if (operands[2] == const1_rtx)
5457         return \"inc{b}\\t%h0\";
5458       else if (operands[2] == constm1_rtx
5459                || (GET_CODE (operands[2]) == CONST_INT
5460                    && INTVAL (operands[2]) == 255))
5461         return \"dec{b}\\t%h0\";
5462       abort();
5463
5464     default:
5465       return \"add{b}\\t{%2, %h0|%h0, %2}\";
5466     }
5467 }"
5468   [(set (attr "type")
5469      (if_then_else (match_operand:QI 2 "incdec_operand" "")
5470         (const_string "incdec")
5471         (const_string "alu")))
5472    (set_attr "mode" "QI")])
5473
5474 (define_insn "*addqi_ext_2"
5475   [(set (zero_extract:SI (match_operand 0 "ext_register_operand" "=q")
5476                          (const_int 8)
5477                          (const_int 8))
5478         (plus:SI
5479           (zero_extract:SI
5480             (match_operand 1 "ext_register_operand" "%0")
5481             (const_int 8)
5482             (const_int 8))
5483           (zero_extract:SI
5484             (match_operand 2 "ext_register_operand" "q")
5485             (const_int 8)
5486             (const_int 8))))
5487    (clobber (reg:CC 17))]
5488   ""
5489   "add{b}\\t{%h2, %h0|%h0, %h2}"
5490   [(set_attr "type" "alu")
5491    (set_attr "mode" "QI")])
5492
5493 ;; The patterns that match these are at the end of this file.
5494
5495 (define_expand "addxf3"
5496   [(set (match_operand:XF 0 "register_operand" "")
5497         (plus:XF (match_operand:XF 1 "register_operand" "")
5498                  (match_operand:XF 2 "register_operand" "")))]
5499   "TARGET_80387"
5500   "")
5501
5502 (define_expand "addtf3"
5503   [(set (match_operand:TF 0 "register_operand" "")
5504         (plus:TF (match_operand:TF 1 "register_operand" "")
5505                  (match_operand:TF 2 "register_operand" "")))]
5506   "TARGET_80387"
5507   "")
5508
5509 (define_expand "adddf3"
5510   [(set (match_operand:DF 0 "register_operand" "")
5511         (plus:DF (match_operand:DF 1 "register_operand" "")
5512                  (match_operand:DF 2 "nonimmediate_operand" "")))]
5513   "TARGET_80387 || TARGET_SSE2"
5514   "")
5515
5516 (define_expand "addsf3"
5517   [(set (match_operand:SF 0 "register_operand" "")
5518         (plus:SF (match_operand:SF 1 "register_operand" "")
5519                  (match_operand:SF 2 "nonimmediate_operand" "")))]
5520   "TARGET_80387 || TARGET_SSE"
5521   "")
5522 \f
5523 ;; Subtract instructions
5524
5525 ;; %%% define_expand from the very first?
5526 ;; %%% splits for subsidi3
5527
5528 (define_insn "subdi3"
5529   [(set (match_operand:DI 0 "nonimmediate_operand" "=r,o")
5530         (minus:DI (match_operand:DI 1 "nonimmediate_operand" "0,0")
5531                   (match_operand:DI 2 "general_operand" "roiF,riF")))
5532    (clobber (reg:CC 17))]
5533   ""
5534   "#")
5535
5536 (define_split
5537   [(set (match_operand:DI 0 "nonimmediate_operand" "")
5538         (minus:DI (match_operand:DI 1 "nonimmediate_operand" "")
5539                   (match_operand:DI 2 "general_operand" "")))
5540    (clobber (reg:CC 17))]
5541   "reload_completed"
5542   [(parallel [(set (reg:CC 17) (compare:CC (match_dup 1) (match_dup 2)))
5543               (set (match_dup 0) (minus:SI (match_dup 1) (match_dup 2)))])
5544    (parallel [(set (match_dup 3)
5545                    (minus:SI (match_dup 4)
5546                              (plus:SI (ltu:SI (reg:CC 17) (const_int 0))
5547                                       (match_dup 5))))
5548               (clobber (reg:CC 17))])]
5549   "split_di (operands+0, 1, operands+0, operands+3);
5550    split_di (operands+1, 1, operands+1, operands+4);
5551    split_di (operands+2, 1, operands+2, operands+5);")
5552
5553 (define_insn "subsi3_carry"
5554   [(set (match_operand:SI 0 "nonimmediate_operand" "=rm,r")
5555           (minus:SI (match_operand:SI 1 "nonimmediate_operand" "0,0")
5556             (plus:SI (ltu:SI (reg:CC 17) (const_int 0))
5557                (match_operand:SI 2 "general_operand" "ri,rm"))))
5558    (clobber (reg:CC 17))]
5559   "ix86_binary_operator_ok (MINUS, SImode, operands)"
5560   "sbb{l}\\t{%2, %0|%0, %2}"
5561   [(set_attr "type" "alu")
5562    (set_attr "pent_pair" "pu")
5563    (set_attr "ppro_uops" "few")
5564    (set_attr "mode" "SI")])
5565
5566 (define_expand "subsi3"
5567   [(parallel [(set (match_operand:SI 0 "nonimmediate_operand" "")
5568                    (minus:SI (match_operand:SI 1 "nonimmediate_operand" "")
5569                              (match_operand:SI 2 "general_operand" "")))
5570               (clobber (reg:CC 17))])]
5571   ""
5572   "ix86_expand_binary_operator (MINUS, SImode, operands); DONE;")
5573
5574 (define_insn "*subsi_1"
5575   [(set (match_operand:SI 0 "nonimmediate_operand" "=rm,r")
5576         (minus:SI (match_operand:SI 1 "nonimmediate_operand" "0,0")
5577                   (match_operand:SI 2 "general_operand" "ri,rm")))
5578    (clobber (reg:CC 17))]
5579   "ix86_binary_operator_ok (MINUS, SImode, operands)"
5580   "sub{l}\\t{%2, %0|%0, %2}"
5581   [(set_attr "type" "alu")
5582    (set_attr "mode" "SI")])
5583
5584 (define_insn "*subsi_2"
5585   [(set (reg 17)
5586         (compare
5587           (minus:SI (match_operand:SI 1 "nonimmediate_operand" "0,0")
5588                     (match_operand:SI 2 "general_operand" "ri,rm"))
5589           (const_int 0)))
5590    (set (match_operand:SI 0 "nonimmediate_operand" "=rm,r")
5591         (minus:SI (match_dup 1) (match_dup 2)))]
5592   "ix86_match_ccmode (insn, CCGOCmode)
5593    && ix86_binary_operator_ok (MINUS, SImode, operands)"
5594   "sub{l}\\t{%2, %0|%0, %2}"
5595   [(set_attr "type" "alu")
5596    (set_attr "mode" "SI")])
5597
5598 (define_insn "*subsi_3"
5599   [(set (reg 17)
5600         (compare (match_operand:SI 1 "nonimmediate_operand" "0,0")
5601                  (match_operand:SI 2 "general_operand" "ri,rm")))
5602    (set (match_operand:SI 0 "nonimmediate_operand" "=rm,r")
5603         (minus:SI (match_dup 1) (match_dup 2)))]
5604   "ix86_match_ccmode (insn, CCmode)
5605    && ix86_binary_operator_ok (MINUS, SImode, operands)"
5606   "sub{l}\\t{%2, %0|%0, %2}"
5607   [(set_attr "type" "alu")
5608    (set_attr "mode" "SI")])
5609
5610 (define_expand "subhi3"
5611   [(parallel [(set (match_operand:HI 0 "nonimmediate_operand" "")
5612                    (minus:HI (match_operand:HI 1 "nonimmediate_operand" "")
5613                              (match_operand:HI 2 "general_operand" "")))
5614               (clobber (reg:CC 17))])]
5615   "TARGET_HIMODE_MATH"
5616   "ix86_expand_binary_operator (MINUS, HImode, operands); DONE;")
5617
5618 (define_insn "*subhi_1"
5619   [(set (match_operand:HI 0 "nonimmediate_operand" "=rm,r")
5620         (minus:HI (match_operand:HI 1 "nonimmediate_operand" "0,0")
5621                   (match_operand:HI 2 "general_operand" "ri,rm")))
5622    (clobber (reg:CC 17))]
5623   "ix86_binary_operator_ok (MINUS, HImode, operands)"
5624   "sub{w}\\t{%2, %0|%0, %2}"
5625   [(set_attr "type" "alu")
5626    (set_attr "mode" "HI")])
5627
5628 (define_insn "*subhi_2"
5629   [(set (reg 17)
5630         (compare
5631           (minus:HI (match_operand:HI 1 "nonimmediate_operand" "0,0")
5632                     (match_operand:HI 2 "general_operand" "ri,rm"))
5633           (const_int 0)))
5634    (set (match_operand:HI 0 "nonimmediate_operand" "=rm,r")
5635         (minus:HI (match_dup 1) (match_dup 2)))]
5636   "ix86_match_ccmode (insn, CCGOCmode)
5637    && ix86_binary_operator_ok (MINUS, HImode, operands)"
5638   "sub{w}\\t{%2, %0|%0, %2}"
5639   [(set_attr "type" "alu")
5640    (set_attr "mode" "HI")])
5641
5642 (define_insn "*subhi_3"
5643   [(set (reg 17)
5644         (compare (match_operand:HI 1 "nonimmediate_operand" "0,0")
5645                  (match_operand:HI 2 "general_operand" "ri,rm")))
5646    (set (match_operand:HI 0 "nonimmediate_operand" "=rm,r")
5647         (minus:HI (match_dup 1) (match_dup 2)))]
5648   "ix86_match_ccmode (insn, CCmode)
5649    && ix86_binary_operator_ok (MINUS, HImode, operands)"
5650   "sub{w}\\t{%2, %0|%0, %2}"
5651   [(set_attr "type" "alu")
5652    (set_attr "mode" "HI")])
5653
5654 (define_expand "subqi3"
5655   [(parallel [(set (match_operand:QI 0 "nonimmediate_operand" "")
5656                    (minus:QI (match_operand:QI 1 "nonimmediate_operand" "")
5657                              (match_operand:QI 2 "general_operand" "")))
5658               (clobber (reg:CC 17))])]
5659   "TARGET_QIMODE_MATH"
5660   "ix86_expand_binary_operator (MINUS, QImode, operands); DONE;")
5661
5662 (define_insn "*subqi_1"
5663   [(set (match_operand:QI 0 "nonimmediate_operand" "=qm,q")
5664         (minus:QI (match_operand:QI 1 "nonimmediate_operand" "0,0")
5665                   (match_operand:QI 2 "general_operand" "qn,qmn")))
5666    (clobber (reg:CC 17))]
5667   "ix86_binary_operator_ok (MINUS, QImode, operands)"
5668   "sub{b}\\t{%2, %0|%0, %2}"
5669   [(set_attr "type" "alu")
5670    (set_attr "mode" "QI")])
5671
5672 (define_insn "*subqi_2"
5673   [(set (reg 17)
5674         (compare
5675           (minus:QI (match_operand:QI 1 "nonimmediate_operand" "0,0")
5676                     (match_operand:QI 2 "general_operand" "qi,qm"))
5677           (const_int 0)))
5678    (set (match_operand:HI 0 "nonimmediate_operand" "=qm,q")
5679         (minus:HI (match_dup 1) (match_dup 2)))]
5680   "ix86_match_ccmode (insn, CCGOCmode)
5681    && ix86_binary_operator_ok (MINUS, QImode, operands)"
5682   "sub{b}\\t{%2, %0|%0, %2}"
5683   [(set_attr "type" "alu")
5684    (set_attr "mode" "QI")])
5685
5686 (define_insn "*subqi_3"
5687   [(set (reg 17)
5688         (compare (match_operand:QI 1 "nonimmediate_operand" "0,0")
5689                  (match_operand:QI 2 "general_operand" "qi,qm")))
5690    (set (match_operand:HI 0 "nonimmediate_operand" "=qm,q")
5691         (minus:HI (match_dup 1) (match_dup 2)))]
5692   "ix86_match_ccmode (insn, CCmode)
5693    && ix86_binary_operator_ok (MINUS, QImode, operands)"
5694   "sub{b}\\t{%2, %0|%0, %2}"
5695   [(set_attr "type" "alu")
5696    (set_attr "mode" "QI")])
5697
5698 ;; The patterns that match these are at the end of this file.
5699
5700 (define_expand "subxf3"
5701   [(set (match_operand:XF 0 "register_operand" "")
5702         (minus:XF (match_operand:XF 1 "register_operand" "")
5703                   (match_operand:XF 2 "register_operand" "")))]
5704   "TARGET_80387"
5705   "")
5706
5707 (define_expand "subtf3"
5708   [(set (match_operand:TF 0 "register_operand" "")
5709         (minus:TF (match_operand:TF 1 "register_operand" "")
5710                   (match_operand:TF 2 "register_operand" "")))]
5711   "TARGET_80387"
5712   "")
5713
5714 (define_expand "subdf3"
5715   [(set (match_operand:DF 0 "register_operand" "")
5716         (minus:DF (match_operand:DF 1 "register_operand" "")
5717                   (match_operand:DF 2 "nonimmediate_operand" "")))]
5718   "TARGET_80387 || TARGET_SSE2"
5719   "")
5720
5721 (define_expand "subsf3"
5722   [(set (match_operand:SF 0 "register_operand" "")
5723         (minus:SF (match_operand:SF 1 "register_operand" "")
5724                   (match_operand:SF 2 "nonimmediate_operand" "")))]
5725   "TARGET_80387 || TARGET_SSE"
5726   "")
5727 \f
5728 ;; Multiply instructions
5729
5730 (define_expand "mulsi3"
5731   [(parallel [(set (match_operand:SI 0 "register_operand" "")
5732                    (mult:SI (match_operand:SI 1 "register_operand" "")
5733                             (match_operand:SI 2 "general_operand" "")))
5734               (clobber (reg:CC 17))])]
5735   ""
5736   "")
5737
5738 (define_insn "*mulsi3_1"
5739   [(set (match_operand:SI 0 "register_operand" "=r,r,r")
5740         (mult:SI (match_operand:SI 1 "nonimmediate_operand" "%rm,0,0")
5741                  (match_operand:SI 2 "general_operand" "K,i,mr")))
5742    (clobber (reg:CC 17))]
5743   "GET_CODE (operands[1]) != MEM || GET_CODE (operands[2]) != MEM"
5744   ; For the {r,0,i} alternative (i.e., register <- register * immediate),
5745   ; there are two ways of writing the exact same machine instruction
5746   ; in assembly language.  One, for example, is:
5747   ;
5748   ;   imul $12, %eax
5749   ;
5750   ; while the other is:
5751   ;
5752   ;   imul $12, %eax, %eax
5753   ;
5754   ; The first is simply short-hand for the latter.  But, some assemblers,
5755   ; like the SCO OSR5 COFF assembler, don't handle the first form.
5756   "@
5757    imul{l}\\t{%2, %1, %0|%0, %1, %2}
5758    imul{l}\\t{%2, %1, %0|%0, %1, %2}
5759    imul{l}\\t{%2, %0|%0, %2}"
5760   [(set_attr "type" "imul")
5761    (set_attr "prefix_0f" "0,0,1")
5762    (set_attr "mode" "SI")])
5763
5764 (define_expand "mulhi3"
5765   [(parallel [(set (match_operand:HI 0 "register_operand" "")
5766                    (mult:HI (match_operand:HI 1 "register_operand" "")
5767                             (match_operand:HI 2 "general_operand" "")))
5768               (clobber (reg:CC 17))])]
5769   "TARGET_HIMODE_MATH"
5770   "")
5771
5772 (define_insn "*mulhi3_1"
5773   [(set (match_operand:HI 0 "register_operand" "=r,r,r")
5774         (mult:HI (match_operand:HI 1 "nonimmediate_operand" "%rm,0,0")
5775                  (match_operand:HI 2 "general_operand" "K,i,mr")))
5776    (clobber (reg:CC 17))]
5777   "GET_CODE (operands[1]) != MEM || GET_CODE (operands[2]) != MEM"
5778   ; %%% There was a note about "Assembler has weird restrictions",
5779   ; concerning alternative 1 when op1 == op0.  True?
5780   "@
5781    imul{w}\\t{%2, %1, %0|%0, %1, %2}
5782    imul{w}\\t{%2, %1, %0|%0, %1, %2}
5783    imul{w}\\t{%2, %0|%0, %2}"
5784   [(set_attr "type" "imul")
5785    (set_attr "prefix_0f" "0,0,1")
5786    (set_attr "mode" "HI")])
5787
5788 (define_insn "mulqi3"
5789   [(set (match_operand:QI 0 "register_operand" "=a")
5790         (mult:QI (match_operand:QI 1 "register_operand" "%0")
5791                  (match_operand:QI 2 "nonimmediate_operand" "qm")))
5792    (clobber (reg:CC 17))]
5793   "TARGET_QIMODE_MATH"
5794   "mul{b}\\t%2"
5795   [(set_attr "type" "imul")
5796    (set_attr "length_immediate" "0")
5797    (set_attr "mode" "QI")])
5798
5799 (define_insn "umulqihi3"
5800   [(set (match_operand:HI 0 "register_operand" "=a")
5801         (mult:HI (zero_extend:HI (match_operand:QI 1 "register_operand" "%0"))
5802                  (zero_extend:HI (match_operand:QI 2 "nonimmediate_operand" "qm"))))
5803    (clobber (reg:CC 17))]
5804   "TARGET_QIMODE_MATH"
5805   "mul{b}\\t%2"
5806   [(set_attr "type" "imul")
5807    (set_attr "length_immediate" "0")
5808    (set_attr "mode" "QI")])
5809
5810 (define_insn "mulqihi3"
5811   [(set (match_operand:HI 0 "register_operand" "=a")
5812         (mult:HI (sign_extend:HI (match_operand:QI 1 "register_operand" "%0"))
5813                  (sign_extend:HI (match_operand:QI 2 "nonimmediate_operand" "qm"))))
5814    (clobber (reg:CC 17))]
5815   "TARGET_QIMODE_MATH"
5816   "imul{b}\\t%2"
5817   [(set_attr "type" "imul")
5818    (set_attr "length_immediate" "0")
5819    (set_attr "mode" "QI")])
5820
5821 (define_insn "umulsidi3"
5822   [(set (match_operand:DI 0 "register_operand" "=A")
5823         (mult:DI (zero_extend:DI (match_operand:SI 1 "register_operand" "%0"))
5824                  (zero_extend:DI (match_operand:SI 2 "nonimmediate_operand" "rm"))))
5825    (clobber (reg:CC 17))]
5826   ""
5827   "mul{l}\\t%2"
5828   [(set_attr "type" "imul")
5829    (set_attr "ppro_uops" "few")
5830    (set_attr "length_immediate" "0")
5831    (set_attr "mode" "SI")])
5832
5833 (define_insn "mulsidi3"
5834   [(set (match_operand:DI 0 "register_operand" "=A")
5835         (mult:DI (sign_extend:DI (match_operand:SI 1 "register_operand" "%0"))
5836                  (sign_extend:DI (match_operand:SI 2 "nonimmediate_operand" "rm"))))
5837    (clobber (reg:CC 17))]
5838   ""
5839   "imul{l}\\t%2"
5840   [(set_attr "type" "imul")
5841    (set_attr "length_immediate" "0")
5842    (set_attr "mode" "SI")])
5843
5844 (define_insn "umulsi3_highpart"
5845   [(set (match_operand:SI 0 "register_operand" "=d")
5846         (truncate:SI
5847           (lshiftrt:DI
5848             (mult:DI (zero_extend:DI
5849                        (match_operand:SI 1 "register_operand" "%a"))
5850                      (zero_extend:DI
5851                        (match_operand:SI 2 "nonimmediate_operand" "rm")))
5852             (const_int 32))))
5853    (clobber (match_scratch:SI 3 "=a"))
5854    (clobber (reg:CC 17))]
5855   ""
5856   "mul{l}\\t%2"
5857   [(set_attr "type" "imul")
5858    (set_attr "ppro_uops" "few")
5859    (set_attr "length_immediate" "0")
5860    (set_attr "mode" "SI")])
5861
5862 (define_insn "smulsi3_highpart"
5863   [(set (match_operand:SI 0 "register_operand" "=d")
5864         (truncate:SI
5865           (lshiftrt:DI
5866             (mult:DI (sign_extend:DI
5867                        (match_operand:SI 1 "register_operand" "%a"))
5868                      (sign_extend:DI
5869                        (match_operand:SI 2 "nonimmediate_operand" "rm")))
5870             (const_int 32))))
5871    (clobber (match_scratch:SI 3 "=a"))
5872    (clobber (reg:CC 17))]
5873   ""
5874   "imul{l}\\t%2"
5875   [(set_attr "type" "imul")
5876    (set_attr "ppro_uops" "few")
5877    (set_attr "mode" "SI")])
5878
5879 ;; The patterns that match these are at the end of this file.
5880
5881 (define_expand "mulxf3"
5882   [(set (match_operand:XF 0 "register_operand" "")
5883         (mult:XF (match_operand:XF 1 "register_operand" "")
5884                  (match_operand:XF 2 "register_operand" "")))]
5885   "TARGET_80387"
5886   "")
5887
5888 (define_expand "multf3"
5889   [(set (match_operand:TF 0 "register_operand" "")
5890         (mult:TF (match_operand:TF 1 "register_operand" "")
5891                  (match_operand:TF 2 "register_operand" "")))]
5892   "TARGET_80387"
5893   "")
5894
5895 (define_expand "muldf3"
5896   [(set (match_operand:DF 0 "register_operand" "")
5897         (mult:DF (match_operand:DF 1 "register_operand" "")
5898                  (match_operand:DF 2 "nonimmediate_operand" "")))]
5899   "TARGET_80387 || TARGET_SSE2"
5900   "")
5901
5902 (define_expand "mulsf3"
5903   [(set (match_operand:SF 0 "register_operand" "")
5904         (mult:SF (match_operand:SF 1 "register_operand" "")
5905                  (match_operand:SF 2 "nonimmediate_operand" "")))]
5906   "TARGET_80387 || TARGET_SSE"
5907   "")
5908 \f
5909 ;; Divide instructions
5910
5911 (define_insn "divqi3"
5912   [(set (match_operand:QI 0 "register_operand" "=a")
5913         (div:QI (match_operand:HI 1 "register_operand" "0")
5914                 (match_operand:QI 2 "nonimmediate_operand" "qm")))
5915    (clobber (reg:CC 17))]
5916   "TARGET_QIMODE_MATH"
5917   "idiv{b}\\t%2"
5918   [(set_attr "type" "idiv")
5919    (set_attr "mode" "QI")
5920    (set_attr "ppro_uops" "few")])
5921
5922 (define_insn "udivqi3"
5923   [(set (match_operand:QI 0 "register_operand" "=a")
5924         (udiv:QI (match_operand:HI 1 "register_operand" "0")
5925                  (match_operand:QI 2 "nonimmediate_operand" "qm")))
5926    (clobber (reg:CC 17))]
5927   "TARGET_QIMODE_MATH"
5928   "div{b}\\t%2"
5929   [(set_attr "type" "idiv")
5930    (set_attr "mode" "QI")
5931    (set_attr "ppro_uops" "few")])
5932
5933 ;; The patterns that match these are at the end of this file.
5934
5935 (define_expand "divxf3"
5936   [(set (match_operand:XF 0 "register_operand" "")
5937         (div:XF (match_operand:XF 1 "register_operand" "")
5938                 (match_operand:XF 2 "register_operand" "")))]
5939   "TARGET_80387"
5940   "")
5941
5942 (define_expand "divtf3"
5943   [(set (match_operand:TF 0 "register_operand" "")
5944         (div:TF (match_operand:TF 1 "register_operand" "")
5945                 (match_operand:TF 2 "register_operand" "")))]
5946   "TARGET_80387"
5947   "")
5948
5949 (define_expand "divdf3"
5950   [(set (match_operand:DF 0 "register_operand" "")
5951         (div:DF (match_operand:DF 1 "register_operand" "")
5952                 (match_operand:DF 2 "nonimmediate_operand" "")))]
5953    "TARGET_80387 || TARGET_SSE2"
5954    "")
5955  
5956 (define_expand "divsf3"
5957   [(set (match_operand:SF 0 "register_operand" "")
5958         (div:SF (match_operand:SF 1 "register_operand" "")
5959                 (match_operand:SF 2 "nonimmediate_operand" "")))]
5960   "TARGET_80387 || TARGET_SSE"
5961   "")
5962 \f
5963 ;; Remainder instructions.
5964 (define_expand "divmodsi4"
5965   [(parallel [(set (match_operand:SI 0 "register_operand" "")
5966                    (div:SI (match_operand:SI 1 "register_operand" "")
5967                            (match_operand:SI 2 "nonimmediate_operand" "")))
5968               (set (match_operand:SI 3 "register_operand" "")
5969                    (mod:SI (match_dup 1) (match_dup 2)))
5970               (clobber (reg:CC 17))])]
5971   ""
5972   "")
5973
5974 ;; Allow to come the parameter in eax or edx to avoid extra moves.
5975 ;; Penalize eax case sligthly because it results in worse scheduling
5976 ;; of code.
5977 (define_insn "*divmodsi4_nocltd"
5978   [(set (match_operand:SI 0 "register_operand" "=&a,?a")
5979         (div:SI (match_operand:SI 2 "register_operand" "1,0")
5980                 (match_operand:SI 3 "nonimmediate_operand" "rm,rm")))
5981    (set (match_operand:SI 1 "register_operand" "=&d,&d")
5982         (mod:SI (match_dup 2) (match_dup 3)))
5983    (clobber (reg:CC 17))]
5984   "!optimize_size && !TARGET_USE_CLTD"
5985   "#"
5986   [(set_attr "type" "multi")])
5987
5988 (define_insn "*divmodsi4_cltd"
5989   [(set (match_operand:SI 0 "register_operand" "=a")
5990         (div:SI (match_operand:SI 2 "register_operand" "a")
5991                 (match_operand:SI 3 "nonimmediate_operand" "rm")))
5992    (set (match_operand:SI 1 "register_operand" "=&d")
5993         (mod:SI (match_dup 2) (match_dup 3)))
5994    (clobber (reg:CC 17))]
5995   "optimize_size || TARGET_USE_CLTD"
5996   "#"
5997   [(set_attr "type" "multi")])
5998
5999 (define_insn "*divmodsi_noext"
6000   [(set (match_operand:SI 0 "register_operand" "=a")
6001         (div:SI (match_operand:SI 1 "register_operand" "0")
6002                 (match_operand:SI 2 "nonimmediate_operand" "rm")))
6003    (set (match_operand:SI 3 "register_operand" "=d")
6004         (mod:SI (match_dup 1) (match_dup 2)))
6005    (use (match_operand:SI 4 "register_operand" "3"))
6006    (clobber (reg:CC 17))]
6007   ""
6008   "idiv{l}\\t%2"
6009   [(set_attr "type" "idiv")
6010    (set_attr "mode" "SI")
6011    (set_attr "ppro_uops" "few")])
6012
6013 (define_split
6014   [(set (match_operand:SI 0 "register_operand" "")
6015         (div:SI (match_operand:SI 1 "register_operand" "")
6016                 (match_operand:SI 2 "nonimmediate_operand" "")))
6017    (set (match_operand:SI 3 "register_operand" "")
6018         (mod:SI (match_dup 1) (match_dup 2)))
6019    (clobber (reg:CC 17))]
6020   "reload_completed"
6021   [(parallel [(set (match_dup 3)
6022                    (ashiftrt:SI (match_dup 4) (const_int 31)))
6023               (clobber (reg:CC 17))])
6024    (parallel [(set (match_dup 0)
6025                    (div:SI (reg:SI 0) (match_dup 2)))
6026               (set (match_dup 3)
6027                    (mod:SI (reg:SI 0) (match_dup 2)))
6028               (use (match_dup 3))
6029               (clobber (reg:CC 17))])]
6030   "
6031 {
6032   /* Avoid use of cltd in favour of a mov+shift.  */
6033   if (!TARGET_USE_CLTD && !optimize_size)
6034     {
6035       if (true_regnum (operands[1]))
6036         emit_move_insn (operands[0], operands[1]);
6037       else
6038         emit_move_insn (operands[3], operands[1]);
6039       operands[4] = operands[3];
6040     }
6041   else
6042     {
6043       if (true_regnum (operands[1]))
6044         abort();
6045       operands[4] = operands[1];
6046     }
6047 }")
6048 ;; %%% Split me.
6049 (define_insn "divmodhi4"
6050   [(set (match_operand:HI 0 "register_operand" "=a")
6051         (div:HI (match_operand:HI 1 "register_operand" "0")
6052                 (match_operand:HI 2 "nonimmediate_operand" "rm")))
6053    (set (match_operand:HI 3 "register_operand" "=&d")
6054         (mod:HI (match_dup 1) (match_dup 2)))
6055    (clobber (reg:CC 17))]
6056   "TARGET_HIMODE_MATH"
6057   "cwtd\;idiv{w}\\t%2"
6058   [(set_attr "type" "multi")
6059    (set_attr "length_immediate" "0")
6060    (set_attr "mode" "SI")])
6061
6062 (define_insn "udivmodsi4"
6063   [(set (match_operand:SI 0 "register_operand" "=a")
6064         (udiv:SI (match_operand:SI 1 "register_operand" "0")
6065                  (match_operand:SI 2 "nonimmediate_operand" "rm")))
6066    (set (match_operand:SI 3 "register_operand" "=&d")
6067         (umod:SI (match_dup 1) (match_dup 2)))
6068    (clobber (reg:CC 17))]
6069   ""
6070   "xor{l}\\t%3, %3\;div{l}\\t%2"
6071   [(set_attr "type" "multi")
6072    (set_attr "length_immediate" "0")
6073    (set_attr "mode" "SI")])
6074
6075 (define_insn "*udivmodsi4_noext"
6076   [(set (match_operand:SI 0 "register_operand" "=a")
6077         (udiv:SI (match_operand:SI 1 "register_operand" "0")
6078                  (match_operand:SI 2 "nonimmediate_operand" "rm")))
6079    (set (match_operand:SI 3 "register_operand" "=d")
6080         (umod:SI (match_dup 1) (match_dup 2)))
6081    (use (match_dup 3))
6082    (clobber (reg:CC 17))]
6083   ""
6084   "div{l}\\t%2"
6085   [(set_attr "type" "idiv")
6086    (set_attr "ppro_uops" "few")
6087    (set_attr "mode" "SI")])
6088
6089 (define_split
6090   [(set (match_operand:SI 0 "register_operand" "")
6091         (udiv:SI (match_operand:SI 1 "register_operand" "")
6092                  (match_operand:SI 2 "nonimmediate_operand" "")))
6093    (set (match_operand:SI 3 "register_operand" "")
6094         (umod:SI (match_dup 1) (match_dup 2)))
6095    (clobber (reg:CC 17))]
6096   "reload_completed"
6097   [(set (match_dup 3) (const_int 0))
6098    (parallel [(set (match_dup 0)
6099                    (udiv:SI (match_dup 1) (match_dup 2)))
6100               (set (match_dup 3)
6101                    (umod:SI (match_dup 1) (match_dup 2)))
6102               (use (match_dup 3))
6103               (clobber (reg:CC 17))])]
6104   "")
6105
6106 (define_expand "udivmodhi4"
6107   [(set (match_dup 4) (const_int 0))
6108    (parallel [(set (match_operand:HI 0 "register_operand" "")
6109                    (udiv:HI (match_operand:HI 1 "register_operand" "")
6110                             (match_operand:HI 2 "nonimmediate_operand" "")))
6111               (set (match_operand:HI 3 "register_operand" "")
6112                    (umod:HI (match_dup 1) (match_dup 2)))
6113               (use (match_dup 4))
6114               (clobber (reg:CC 17))])]
6115   "TARGET_HIMODE_MATH"
6116   "operands[4] = gen_reg_rtx (HImode);")
6117
6118 (define_insn "*udivmodhi_noext"
6119   [(set (match_operand:HI 0 "register_operand" "=a")
6120         (udiv:HI (match_operand:HI 1 "register_operand" "0")
6121                  (match_operand:HI 2 "nonimmediate_operand" "rm")))
6122    (set (match_operand:HI 3 "register_operand" "=d")
6123         (umod:HI (match_dup 1) (match_dup 2)))
6124    (use (match_operand:HI 4 "register_operand" "3"))
6125    (clobber (reg:CC 17))]
6126   ""
6127   "div{w}\\t%2"
6128   [(set_attr "type" "idiv")
6129    (set_attr "mode" "HI")
6130    (set_attr "ppro_uops" "few")])
6131
6132 ;; We can not use div/idiv for double division, because it causes
6133 ;; "division by zero" on the overflow and that's not what we expect
6134 ;; from truncate.  Because true (non truncating) double division is
6135 ;; never generated, we can't create this insn anyway.
6136 ;
6137 ;(define_insn ""
6138 ;  [(set (match_operand:SI 0 "register_operand" "=a")
6139 ;       (truncate:SI
6140 ;         (udiv:DI (match_operand:DI 1 "register_operand" "A")
6141 ;                  (zero_extend:DI
6142 ;                    (match_operand:SI 2 "nonimmediate_operand" "rm")))))
6143 ;   (set (match_operand:SI 3 "register_operand" "=d")
6144 ;       (truncate:SI
6145 ;         (umod:DI (match_dup 1) (zero_extend:DI (match_dup 2)))))
6146 ;   (clobber (reg:CC 17))]
6147 ;  ""
6148 ;  "div{l}\\t{%2, %0|%0, %2}"
6149 ;  [(set_attr "type" "idiv")
6150 ;   (set_attr "ppro_uops" "few")])
6151 \f
6152 ;;- Logical AND instructions
6153
6154 ;; On Pentium, "test imm, reg" is pairable only with eax, ax, and al.
6155 ;; Note that this excludes ah.
6156
6157
6158 (define_insn "testsi_1"
6159   [(set (reg 17)
6160         (compare
6161           (and:SI (match_operand:SI 0 "nonimmediate_operand" "%*a,r,rm")
6162                   (match_operand:SI 1 "nonmemory_operand" "in,in,rin"))
6163           (const_int 0)))]
6164   "ix86_match_ccmode (insn, CCNOmode)"
6165   "test{l}\\t{%1, %0|%0, %1}"
6166   [(set_attr "type" "test")
6167    (set_attr "modrm" "0,1,1")
6168    (set_attr "mode" "SI")
6169    (set_attr "pent_pair" "uv,np,uv")])
6170
6171 (define_expand "testsi_ccno_1"
6172   [(set (reg:CCNO 17)
6173         (compare:CCNO
6174           (and:SI (match_operand:SI 0 "nonimmediate_operand" "")
6175                   (match_operand:SI 1 "nonmemory_operand" ""))
6176           (const_int 0)))]
6177   ""
6178   "")
6179
6180 (define_insn "*testhi_1"
6181   [(set (reg 17)
6182         (compare (and:HI (match_operand:HI 0 "nonimmediate_operand" "%*a,r,rm")
6183                          (match_operand:HI 1 "nonmemory_operand" "n,n,rn"))
6184                  (const_int 0)))]
6185   "ix86_match_ccmode (insn, CCNOmode)"
6186   "test{w}\\t{%1, %0|%0, %1}"
6187   [(set_attr "type" "test")
6188    (set_attr "modrm" "0,1,1")
6189    (set_attr "mode" "HI")
6190    (set_attr "pent_pair" "uv,np,uv")])
6191
6192 (define_expand "testqi_ccz_1"
6193   [(set (reg:CCZ 17)
6194         (compare:CCZ (and:QI (match_operand:QI 0 "nonimmediate_operand" "")
6195                              (match_operand:QI 1 "nonmemory_operand" ""))
6196                  (const_int 0)))]
6197   ""
6198   "")
6199
6200 (define_insn "*testqi_1"
6201   [(set (reg 17)
6202         (compare (and:QI (match_operand:QI 0 "nonimmediate_operand" "%*a,q,qm,r")
6203                          (match_operand:QI 1 "nonmemory_operand" "n,n,qn,n"))
6204                  (const_int 0)))]
6205   "ix86_match_ccmode (insn, CCNOmode)"
6206   "*
6207 {
6208   if (which_alternative == 3)
6209     {
6210       if (GET_CODE (operands[1]) == CONST_INT
6211           && (INTVAL (operands[1]) & 0xffffff00))
6212         operands[1] = GEN_INT (INTVAL (operands[1]) & 0xff);
6213       return \"test{l}\\t{%1, %k0|%k0, %1}\";
6214     }
6215   return \"test{b}\\t{%1, %0|%0, %1}\";
6216 }"
6217   [(set_attr "type" "test")
6218    (set_attr "modrm" "0,1,1,1")
6219    (set_attr "mode" "QI,QI,QI,SI")
6220    (set_attr "pent_pair" "uv,np,uv,np")])
6221
6222 (define_expand "testqi_ext_ccno_0"
6223   [(set (reg:CCNO 17)
6224         (compare:CCNO
6225           (and:SI
6226             (zero_extract:SI
6227               (match_operand 0 "ext_register_operand" "")
6228               (const_int 8)
6229               (const_int 8))
6230             (match_operand 1 "const_int_operand" ""))
6231           (const_int 0)))]
6232   ""
6233   "")
6234
6235 (define_insn "*testqi_ext_0"
6236   [(set (reg 17)
6237         (compare
6238           (and:SI
6239             (zero_extract:SI
6240               (match_operand 0 "ext_register_operand" "q")
6241               (const_int 8)
6242               (const_int 8))
6243             (match_operand 1 "const_int_operand" "n"))
6244           (const_int 0)))]
6245   "(unsigned HOST_WIDE_INT) INTVAL (operands[1]) <= 0xff
6246    && ix86_match_ccmode (insn, CCNOmode)"
6247   "test{b}\\t{%1, %h0|%h0, %1}"
6248   [(set_attr "type" "test")
6249    (set_attr "mode" "QI")
6250    (set_attr "length_immediate" "1")
6251    (set_attr "pent_pair" "np")])
6252
6253 (define_insn "*testqi_ext_1"
6254   [(set (reg 17)
6255         (compare
6256           (and:SI
6257             (zero_extract:SI
6258               (match_operand 0 "ext_register_operand" "q")
6259               (const_int 8)
6260               (const_int 8))
6261             (zero_extend:SI
6262               (match_operand:QI 1 "nonimmediate_operand" "qm")))
6263           (const_int 0)))]
6264   "ix86_match_ccmode (insn, CCNOmode)"
6265   "test{b}\\t{%1, %h0|%h0, %1}"
6266   [(set_attr "type" "test")
6267    (set_attr "mode" "QI")])
6268
6269 (define_insn "*testqi_ext_2"
6270   [(set (reg 17)
6271         (compare
6272           (and:SI
6273             (zero_extract:SI
6274               (match_operand 0 "ext_register_operand" "q")
6275               (const_int 8)
6276               (const_int 8))
6277             (zero_extract:SI
6278               (match_operand 1 "ext_register_operand" "q")
6279               (const_int 8)
6280               (const_int 8)))
6281           (const_int 0)))]
6282   "ix86_match_ccmode (insn, CCNOmode)"
6283   "test{b}\\t{%h1, %h0|%h0, %h1}"
6284   [(set_attr "type" "test")
6285    (set_attr "mode" "QI")])
6286
6287 ;; Combine likes to form bit extractions for some tests.  Humor it.
6288 (define_insn "*testqi_ext_3"
6289   [(set (reg 17)
6290         (compare (zero_extract:SI
6291                    (match_operand 0 "nonimmediate_operand" "rm")
6292                    (match_operand:SI 1 "const_int_operand" "")
6293                    (match_operand:SI 2 "const_int_operand" ""))
6294                  (const_int 0)))]
6295   "ix86_match_ccmode (insn, CCNOmode)
6296    && (GET_MODE (operands[0]) == SImode
6297        || GET_MODE (operands[0]) == HImode
6298        || GET_MODE (operands[0]) == QImode)"
6299   "#")
6300
6301 (define_split
6302   [(set (reg 17)
6303         (compare (zero_extract:SI
6304                    (match_operand 0 "nonimmediate_operand" "rm")
6305                    (match_operand:SI 1 "const_int_operand" "")
6306                    (match_operand:SI 2 "const_int_operand" ""))
6307                  (const_int 0)))]
6308   "ix86_match_ccmode (insn, CCNOmode)"
6309   [(set (reg:CCNO 17) (compare:CCNO (match_dup 3) (const_int 0)))]
6310   "
6311 {
6312   HOST_WIDE_INT len = INTVAL (operands[1]);
6313   HOST_WIDE_INT pos = INTVAL (operands[2]);
6314   HOST_WIDE_INT mask;
6315   enum machine_mode mode;
6316
6317   mode = GET_MODE (operands[0]);
6318   if (GET_CODE (operands[0]) == MEM)
6319     {
6320       /* ??? Combine likes to put non-volatile mem extractions in QImode
6321          no matter the size of the test.  So find a mode that works.  */
6322       if (! MEM_VOLATILE_P (operands[0]))
6323         {
6324           mode = smallest_mode_for_size (pos + len, MODE_INT);
6325           operands[0] = change_address (operands[0], mode, NULL_RTX);
6326         }
6327     }
6328   else if (mode == HImode && pos + len <= 8)
6329     {
6330       /* Small HImode tests can be converted to QImode.  */
6331       mode = QImode;
6332       operands[0] = gen_lowpart (QImode, operands[0]);
6333     }
6334
6335   mask  = ((HOST_WIDE_INT)1 << (pos + len)) - 1;
6336   mask &= ~(((HOST_WIDE_INT)1 << pos) - 1);
6337
6338   operands[3] = gen_rtx_AND (mode, operands[0], GEN_INT (mask));
6339 }")
6340
6341 ;; %%% This used to optimize known byte-wide and operations to memory,
6342 ;; and sometimes to QImode registers.  If this is considered useful,
6343 ;; it should be done with splitters.
6344
6345 (define_expand "andsi3"
6346   [(set (match_operand:SI 0 "nonimmediate_operand" "")
6347         (and:SI (match_operand:SI 1 "nonimmediate_operand" "")
6348                 (match_operand:SI 2 "general_operand" "")))
6349    (clobber (reg:CC 17))]
6350   ""
6351   "ix86_expand_binary_operator (AND, SImode, operands); DONE;")
6352
6353 (define_insn "*andsi_1"
6354   [(set (match_operand:SI 0 "nonimmediate_operand" "=rm,r,r")
6355         (and:SI (match_operand:SI 1 "nonimmediate_operand" "%0,0,qm")
6356                 (match_operand:SI 2 "general_operand" "ri,rm,L")))
6357    (clobber (reg:CC 17))]
6358   "ix86_binary_operator_ok (AND, SImode, operands)"
6359   "*
6360 {
6361   switch (get_attr_type (insn))
6362     {
6363     case TYPE_IMOVX:
6364       {
6365         enum machine_mode mode;
6366
6367         if (GET_CODE (operands[2]) != CONST_INT)
6368           abort ();
6369         if (INTVAL (operands[2]) == 0xff)
6370           mode = QImode;
6371         else if (INTVAL (operands[2]) == 0xffff)
6372           mode = HImode;
6373         else
6374           abort ();
6375         
6376         operands[1] = gen_lowpart (mode, operands[1]);
6377         if (mode == QImode)
6378           return \"movz{bl|x}\\t{%1,%0|%0, %1}\";
6379         else
6380           return \"movz{wl|x}\\t{%1,%0|%0, %1}\";
6381       }
6382
6383     default:
6384       if (! rtx_equal_p (operands[0], operands[1]))
6385         abort ();
6386       return \"and{l}\\t{%2, %0|%0, %2}\";
6387     }
6388 }"
6389   [(set_attr "type" "alu,alu,imovx")
6390    (set_attr "length_immediate" "*,*,0")
6391    (set_attr "mode" "SI")])
6392
6393 (define_split
6394   [(set (match_operand:SI 0 "register_operand" "")
6395         (and:SI (match_dup 0)
6396                 (const_int -65536)))
6397    (clobber (reg:CC 17))]
6398   "optimize_size"
6399   [(set (strict_low_part (match_dup 1)) (const_int 0))]
6400   "operands[1] = gen_lowpart (HImode, operands[0]);")
6401
6402 (define_split
6403   [(set (match_operand 0 "q_regs_operand" "")
6404         (and (match_dup 0)
6405                 (const_int -256)))
6406    (clobber (reg:CC 17))]
6407   "(optimize_size || !TARGET_PARTIAL_REG_STALL)
6408    && (GET_MODE (operands[0]) == SImode || GET_MODE (operands[0]) == HImode)"
6409   [(set (strict_low_part (match_dup 1)) (const_int 0))]
6410   "operands[1] = gen_lowpart (QImode, operands[0]);")
6411
6412 (define_split
6413   [(set (match_operand 0 "q_regs_operand" "")
6414         (and (match_dup 0)
6415              (const_int -65281)))
6416    (clobber (reg:CC 17))]
6417   "(optimize_size || !TARGET_PARTIAL_REG_STALL)
6418    && (GET_MODE (operands[0]) == SImode || GET_MODE (operands[0]) == HImode)"
6419   [(parallel [(set (zero_extract:SI (match_dup 0)
6420                                     (const_int 8)
6421                                     (const_int 8))
6422                    (xor:SI 
6423                      (zero_extract:SI (match_dup 0)
6424                                       (const_int 8)
6425                                       (const_int 8))
6426                      (zero_extract:SI (match_dup 0)
6427                                       (const_int 8)
6428                                       (const_int 8))))
6429               (clobber (reg:CC 17))])]
6430   "operands[0] = gen_lowpart (SImode, operands[0]);")
6431
6432 (define_insn "*andsi_2"
6433   [(set (reg 17)
6434         (compare (and:SI (match_operand:SI 1 "nonimmediate_operand" "%0,0")
6435                          (match_operand:SI 2 "general_operand" "rim,ri"))
6436                  (const_int 0)))
6437    (set (match_operand:SI 0 "nonimmediate_operand" "=r,rm")
6438         (and:SI (match_dup 1) (match_dup 2)))]
6439   "ix86_match_ccmode (insn, CCNOmode)
6440    && ix86_binary_operator_ok (AND, SImode, operands)"
6441   "and{l}\\t{%2, %0|%0, %2}"
6442   [(set_attr "type" "alu")
6443    (set_attr "mode" "SI")])
6444
6445 (define_expand "andhi3"
6446   [(set (match_operand:HI 0 "nonimmediate_operand" "")
6447         (and:HI (match_operand:HI 1 "nonimmediate_operand" "")
6448                 (match_operand:HI 2 "general_operand" "")))
6449    (clobber (reg:CC 17))]
6450   "TARGET_HIMODE_MATH"
6451   "ix86_expand_binary_operator (AND, HImode, operands); DONE;")
6452
6453 (define_insn "*andhi_1"
6454   [(set (match_operand:HI 0 "nonimmediate_operand" "=rm,r,r")
6455         (and:HI (match_operand:HI 1 "nonimmediate_operand" "%0,0,qm")
6456                 (match_operand:HI 2 "general_operand" "ri,rm,L")))
6457    (clobber (reg:CC 17))]
6458   "ix86_binary_operator_ok (AND, HImode, operands)"
6459   "*
6460 {
6461   switch (get_attr_type (insn))
6462     {
6463     case TYPE_IMOVX:
6464       if (GET_CODE (operands[2]) != CONST_INT)
6465         abort ();
6466       if (INTVAL (operands[2]) == 0xff)
6467         return \"movz{bl|x}\\t{%b1, %k0|%k0, %b1}\";
6468       abort ();
6469
6470     default:
6471       if (! rtx_equal_p (operands[0], operands[1]))
6472         abort ();
6473
6474       return \"and{w}\\t{%2, %0|%0, %2}\";
6475     }
6476 }"
6477   [(set_attr "type" "alu,alu,imovx")
6478    (set_attr "length_immediate" "*,*,0")
6479    (set_attr "mode" "HI,HI,SI")])
6480
6481 (define_insn "*andhi_2"
6482   [(set (reg 17)
6483         (compare (and:HI (match_operand:HI 1 "nonimmediate_operand" "%0,0")
6484                          (match_operand:HI 2 "general_operand" "rim,ri"))
6485                  (const_int 0)))
6486    (set (match_operand:HI 0 "nonimmediate_operand" "=r,rm")
6487         (and:HI (match_dup 1) (match_dup 2)))]
6488   "ix86_match_ccmode (insn, CCNOmode)
6489    && ix86_binary_operator_ok (AND, HImode, operands)"
6490   "and{w}\\t{%2, %0|%0, %2}"
6491   [(set_attr "type" "alu")
6492    (set_attr "mode" "HI")])
6493
6494 (define_expand "andqi3"
6495   [(set (match_operand:QI 0 "nonimmediate_operand" "")
6496         (and:QI (match_operand:QI 1 "nonimmediate_operand" "")
6497                 (match_operand:QI 2 "general_operand" "")))
6498    (clobber (reg:CC 17))]
6499   "TARGET_QIMODE_MATH"
6500   "ix86_expand_binary_operator (AND, QImode, operands); DONE;")
6501
6502 ;; %%% Potential partial reg stall on alternative 2.  What to do?
6503 (define_insn "*andqi_1"
6504   [(set (match_operand:QI 0 "nonimmediate_operand" "=qm,q,r")
6505         (and:QI (match_operand:QI 1 "nonimmediate_operand" "%0,0,0")
6506                 (match_operand:QI 2 "general_operand" "qi,qmi,ri")))
6507    (clobber (reg:CC 17))]
6508   "ix86_binary_operator_ok (AND, QImode, operands)"
6509   "@
6510    and{b}\\t{%2, %0|%0, %2}
6511    and{b}\\t{%2, %0|%0, %2}
6512    and{l}\\t{%k2, %k0|%k0, %k2}"
6513   [(set_attr "type" "alu")
6514    (set_attr "mode" "QI,QI,SI")])
6515
6516 (define_insn "*andqi_1_slp"
6517   [(set (strict_low_part (match_operand:QI 0 "nonimmediate_operand" "+qm,q"))
6518         (and:QI (match_dup 0)
6519                 (match_operand:QI 1 "general_operand" "qi,qmi")))
6520    (clobber (reg:CC 17))]
6521   ""
6522   "and{b}\\t{%1, %0|%0, %1}"
6523   [(set_attr "type" "alu1")
6524    (set_attr "mode" "QI")])
6525
6526 (define_insn "*andqi_2"
6527   [(set (reg 17)
6528         (compare (and:QI
6529                    (match_operand:QI 1 "nonimmediate_operand" "%0,0,0")
6530                    (match_operand:QI 2 "general_operand" "qim,qi,i"))
6531                  (const_int 0)))
6532    (set (match_operand:QI 0 "nonimmediate_operand" "=q,qm,*r")
6533         (and:QI (match_dup 1) (match_dup 2)))]
6534   "ix86_match_ccmode (insn, CCNOmode)
6535    && ix86_binary_operator_ok (AND, QImode, operands)"
6536   "*
6537 {
6538   if (which_alternative == 2)
6539     {
6540       if (GET_CODE (operands[2]) == CONST_INT
6541           && (INTVAL (operands[2]) & 0xffffff00))
6542         operands[2] = GEN_INT (INTVAL (operands[2]) & 0xff);
6543       return \"and{l}\\t{%2, %k0|%k0, %2}\";
6544     }
6545   return \"and{b}\\t{%2, %0|%0, %2}\";
6546 }"
6547   [(set_attr "type" "alu")
6548    (set_attr "mode" "QI,QI,SI")])
6549
6550 (define_insn "*andqi_2_slp"
6551   [(set (reg 17)
6552         (compare (and:QI
6553                    (match_operand:QI 0 "nonimmediate_operand" "+q,qm")
6554                    (match_operand:QI 1 "nonimmediate_operand" "qmi,qi"))
6555                  (const_int 0)))
6556    (set (strict_low_part (match_dup 0))
6557         (and:QI (match_dup 0) (match_dup 1)))]
6558   "ix86_match_ccmode (insn, CCNOmode)"
6559   "and{b}\\t{%1, %0|%0, %1}"
6560   [(set_attr "type" "alu1")
6561    (set_attr "mode" "QI")])
6562
6563 ;; ??? A bug in recog prevents it from recognizing a const_int as an
6564 ;; operand to zero_extend in andqi_ext_1.  It was checking explicitly
6565 ;; for a QImode operand, which of course failed.
6566
6567 (define_insn "andqi_ext_0"
6568   [(set (zero_extract:SI (match_operand 0 "ext_register_operand" "=q")
6569                          (const_int 8)
6570                          (const_int 8))
6571         (and:SI 
6572           (zero_extract:SI
6573             (match_operand 1 "ext_register_operand" "0")
6574             (const_int 8)
6575             (const_int 8))
6576           (match_operand 2 "const_int_operand" "n")))
6577    (clobber (reg:CC 17))]
6578   "(unsigned HOST_WIDE_INT)INTVAL (operands[2]) <= 0xff"
6579   "and{b}\\t{%2, %h0|%h0, %2}"
6580   [(set_attr "type" "alu")
6581    (set_attr "length_immediate" "1")
6582    (set_attr "mode" "QI")])
6583
6584 ;; Generated by peephole translating test to and.  This shows up
6585 ;; often in fp comparisons.
6586
6587 (define_insn "*andqi_ext_0_cc"
6588   [(set (reg 17)
6589         (compare
6590           (and:SI
6591             (zero_extract:SI
6592               (match_operand 1 "ext_register_operand" "0")
6593               (const_int 8)
6594               (const_int 8))
6595             (match_operand 2 "const_int_operand" "n"))
6596           (const_int 0)))
6597    (set (zero_extract:SI (match_operand 0 "ext_register_operand" "=q")
6598                          (const_int 8)
6599                          (const_int 8))
6600         (and:SI 
6601           (zero_extract:SI
6602             (match_dup 1)
6603             (const_int 8)
6604             (const_int 8))
6605           (match_dup 2)))]
6606   "ix86_match_ccmode (insn, CCNOmode)
6607    && (unsigned HOST_WIDE_INT)INTVAL (operands[2]) <= 0xff"
6608   "and{b}\\t{%2, %h0|%h0, %2}"
6609   [(set_attr "type" "alu")
6610    (set_attr "length_immediate" "1")
6611    (set_attr "mode" "QI")])
6612
6613 (define_insn "*andqi_ext_1"
6614   [(set (zero_extract:SI (match_operand 0 "ext_register_operand" "=q")
6615                          (const_int 8)
6616                          (const_int 8))
6617         (and:SI 
6618           (zero_extract:SI
6619             (match_operand 1 "ext_register_operand" "0")
6620             (const_int 8)
6621             (const_int 8))
6622           (zero_extend:SI
6623             (match_operand:QI 2 "general_operand" "qm"))))
6624    (clobber (reg:CC 17))]
6625   ""
6626   "and{b}\\t{%2, %h0|%h0, %2}"
6627   [(set_attr "type" "alu")
6628    (set_attr "length_immediate" "0")
6629    (set_attr "mode" "QI")])
6630
6631 (define_insn "*andqi_ext_2"
6632   [(set (zero_extract:SI (match_operand 0 "ext_register_operand" "=q")
6633                          (const_int 8)
6634                          (const_int 8))
6635         (and:SI
6636           (zero_extract:SI
6637             (match_operand 1 "ext_register_operand" "%0")
6638             (const_int 8)
6639             (const_int 8))
6640           (zero_extract:SI
6641             (match_operand 2 "ext_register_operand" "q")
6642             (const_int 8)
6643             (const_int 8))))
6644    (clobber (reg:CC 17))]
6645   ""
6646   "and{b}\\t{%h2, %h0|%h0, %h2}"
6647   [(set_attr "type" "alu")
6648    (set_attr "length_immediate" "0")
6649    (set_attr "mode" "QI")])
6650 \f
6651 ;; Logical inclusive OR instructions
6652
6653 ;; %%% This used to optimize known byte-wide and operations to memory.
6654 ;; If this is considered useful, it should be done with splitters.
6655
6656 (define_expand "iorsi3"
6657   [(set (match_operand:SI 0 "nonimmediate_operand" "")
6658         (ior:SI (match_operand:SI 1 "nonimmediate_operand" "")
6659                 (match_operand:SI 2 "general_operand" "")))
6660    (clobber (reg:CC 17))]
6661   ""
6662   "ix86_expand_binary_operator (IOR, SImode, operands); DONE;")
6663
6664 (define_insn "*iorsi_1"
6665   [(set (match_operand:SI 0 "nonimmediate_operand" "=rm,r")
6666         (ior:SI (match_operand:SI 1 "nonimmediate_operand" "%0,0")
6667                 (match_operand:SI 2 "general_operand" "ri,rmi")))
6668    (clobber (reg:CC 17))]
6669   "ix86_binary_operator_ok (IOR, SImode, operands)"
6670   "or{l}\\t{%2, %0|%0, %2}"
6671   [(set_attr "type" "alu")
6672    (set_attr "mode" "SI")])
6673
6674 (define_insn "*iorsi_2"
6675   [(set (reg 17)
6676         (compare (ior:SI (match_operand:SI 1 "nonimmediate_operand" "%0,0")
6677                          (match_operand:SI 2 "general_operand" "rim,ri"))
6678                  (const_int 0)))
6679    (set (match_operand:SI 0 "nonimmediate_operand" "=r,rm")
6680         (ior:SI (match_dup 1) (match_dup 2)))]
6681   "ix86_match_ccmode (insn, CCNOmode)
6682    && ix86_binary_operator_ok (IOR, SImode, operands)"
6683   "or{l}\\t{%2, %0|%0, %2}"
6684   [(set_attr "type" "alu")
6685    (set_attr "mode" "SI")])
6686
6687 (define_insn "*iorsi_3"
6688   [(set (reg 17)
6689         (compare (ior:SI (match_operand:SI 1 "nonimmediate_operand" "%0")
6690                          (match_operand:SI 2 "general_operand" "rim"))
6691                  (const_int 0)))
6692    (clobber (match_scratch:SI 0 "=r"))]
6693   "ix86_match_ccmode (insn, CCNOmode)
6694    && (GET_CODE (operands[1]) != MEM || GET_CODE (operands[2]) != MEM)"
6695   "or{l}\\t{%2, %0|%0, %2}"
6696   [(set_attr "type" "alu")
6697    (set_attr "mode" "SI")])
6698
6699 (define_expand "iorhi3"
6700   [(set (match_operand:HI 0 "nonimmediate_operand" "")
6701         (ior:HI (match_operand:HI 1 "nonimmediate_operand" "")
6702                 (match_operand:HI 2 "general_operand" "")))
6703    (clobber (reg:CC 17))]
6704   "TARGET_HIMODE_MATH"
6705   "ix86_expand_binary_operator (IOR, HImode, operands); DONE;")
6706
6707 (define_insn "*iorhi_1"
6708   [(set (match_operand:HI 0 "nonimmediate_operand" "=r,m")
6709         (ior:HI (match_operand:HI 1 "nonimmediate_operand" "%0,0")
6710                 (match_operand:HI 2 "general_operand" "rmi,ri")))
6711    (clobber (reg:CC 17))]
6712   "ix86_binary_operator_ok (IOR, HImode, operands)"
6713   "or{w}\\t{%2, %0|%0, %2}"
6714   [(set_attr "type" "alu")
6715    (set_attr "mode" "HI")])
6716
6717 (define_insn "*iorhi_2"
6718   [(set (reg 17)
6719         (compare (ior:HI (match_operand:HI 1 "nonimmediate_operand" "%0,0")
6720                          (match_operand:HI 2 "general_operand" "rim,ri"))
6721                  (const_int 0)))
6722    (set (match_operand:HI 0 "nonimmediate_operand" "=r,rm")
6723         (ior:HI (match_dup 1) (match_dup 2)))]
6724   "ix86_match_ccmode (insn, CCNOmode)
6725    && ix86_binary_operator_ok (IOR, HImode, operands)"
6726   "or{w}\\t{%2, %0|%0, %2}"
6727   [(set_attr "type" "alu")
6728    (set_attr "mode" "HI")])
6729
6730 (define_insn "*iorhi_3"
6731   [(set (reg 17)
6732         (compare (ior:HI (match_operand:HI 1 "nonimmediate_operand" "%0")
6733                          (match_operand:HI 2 "general_operand" "rim"))
6734                  (const_int 0)))
6735    (clobber (match_scratch:HI 0 "=r"))]
6736   "ix86_match_ccmode (insn, CCNOmode)
6737    && (GET_CODE (operands[1]) != MEM || GET_CODE (operands[2]) != MEM)"
6738   "or{w}\\t{%2, %0|%0, %2}"
6739   [(set_attr "type" "alu")
6740    (set_attr "mode" "HI")])
6741
6742 (define_expand "iorqi3"
6743   [(set (match_operand:QI 0 "nonimmediate_operand" "")
6744         (ior:QI (match_operand:QI 1 "nonimmediate_operand" "")
6745                 (match_operand:QI 2 "general_operand" "")))
6746    (clobber (reg:CC 17))]
6747   "TARGET_QIMODE_MATH"
6748   "ix86_expand_binary_operator (IOR, QImode, operands); DONE;")
6749
6750 ;; %%% Potential partial reg stall on alternative 2.  What to do?
6751 (define_insn "*iorqi_1"
6752   [(set (match_operand:QI 0 "nonimmediate_operand" "=q,m,r")
6753         (ior:QI (match_operand:QI 1 "nonimmediate_operand" "%0,0,0")
6754                 (match_operand:QI 2 "general_operand" "qmi,qi,ri")))
6755    (clobber (reg:CC 17))]
6756   "ix86_binary_operator_ok (IOR, QImode, operands)"
6757   "@
6758    or{b}\\t{%2, %0|%0, %2}
6759    or{b}\\t{%2, %0|%0, %2}
6760    or{l}\\t{%k2, %k0|%k0, %k2}"
6761   [(set_attr "type" "alu")
6762    (set_attr "mode" "QI,QI,SI")])
6763
6764 (define_insn "*iorqi_1_slp"
6765   [(set (strict_low_part (match_operand:QI 0 "nonimmediate_operand" "+q,m"))
6766         (ior:QI (match_dup 0)
6767                 (match_operand:QI 1 "general_operand" "qmi,qi")))
6768    (clobber (reg:CC 17))]
6769   ""
6770   "or{b}\\t{%1, %0|%0, %1}"
6771   [(set_attr "type" "alu1")
6772    (set_attr "mode" "QI")])
6773
6774 (define_insn "*iorqi_2"
6775   [(set (reg 17)
6776         (compare (ior:QI (match_operand:QI 1 "nonimmediate_operand" "%0,0")
6777                          (match_operand:QI 2 "general_operand" "qim,qi"))
6778                  (const_int 0)))
6779    (set (match_operand:QI 0 "nonimmediate_operand" "=q,qm")
6780         (ior:QI (match_dup 1) (match_dup 2)))]
6781   "ix86_match_ccmode (insn, CCNOmode)
6782    && ix86_binary_operator_ok (IOR, QImode, operands)"
6783   "or{b}\\t{%2, %0|%0, %2}"
6784   [(set_attr "type" "alu")
6785    (set_attr "mode" "QI")])
6786
6787 (define_insn "*iorqi_2_slp"
6788   [(set (reg 17)
6789         (compare (ior:QI (match_operand:QI 0 "nonimmediate_operand" "+q,qm")
6790                          (match_operand:QI 1 "general_operand" "qim,qi"))
6791                  (const_int 0)))
6792    (set (strict_low_part (match_dup 0))
6793         (ior:QI (match_dup 0) (match_dup 1)))]
6794   "ix86_match_ccmode (insn, CCNOmode)"
6795   "or{b}\\t{%1, %0|%0, %1}"
6796   [(set_attr "type" "alu1")
6797    (set_attr "mode" "QI")])
6798
6799 (define_insn "*iorqi_3"
6800   [(set (reg 17)
6801         (compare (ior:QI (match_operand:QI 1 "nonimmediate_operand" "%0")
6802                          (match_operand:QI 2 "general_operand" "qim"))
6803                  (const_int 0)))
6804    (clobber (match_scratch:QI 0 "=q"))]
6805   "ix86_match_ccmode (insn, CCNOmode)
6806    && (GET_CODE (operands[1]) != MEM || GET_CODE (operands[2]) != MEM)"
6807   "or{b}\\t{%2, %0|%0, %2}"
6808   [(set_attr "type" "alu")
6809    (set_attr "mode" "QI")])
6810
6811 \f
6812 ;; Logical XOR instructions
6813
6814 ;; %%% This used to optimize known byte-wide and operations to memory.
6815 ;; If this is considered useful, it should be done with splitters.
6816
6817 (define_expand "xorsi3"
6818   [(set (match_operand:SI 0 "nonimmediate_operand" "")
6819         (xor:SI (match_operand:SI 1 "nonimmediate_operand" "")
6820                 (match_operand:SI 2 "general_operand" "")))
6821    (clobber (reg:CC 17))]
6822   ""
6823   "ix86_expand_binary_operator (XOR, SImode, operands); DONE;")
6824
6825 (define_insn "*xorsi_1"
6826   [(set (match_operand:SI 0 "nonimmediate_operand" "=rm,r")
6827         (xor:SI (match_operand:SI 1 "nonimmediate_operand" "%0,0")
6828                 (match_operand:SI 2 "general_operand" "ri,rm")))
6829    (clobber (reg:CC 17))]
6830   "ix86_binary_operator_ok (XOR, SImode, operands)"
6831   "xor{l}\\t{%2, %0|%0, %2}"
6832   [(set_attr "type" "alu")
6833    (set_attr "mode" "SI")])
6834
6835 (define_insn "*xorsi_2"
6836   [(set (reg 17)
6837         (compare (xor:SI (match_operand:SI 1 "nonimmediate_operand" "%0,0")
6838                          (match_operand:SI 2 "general_operand" "rim,ri"))
6839                  (const_int 0)))
6840    (set (match_operand:SI 0 "nonimmediate_operand" "=r,rm")
6841         (xor:SI (match_dup 1) (match_dup 2)))]
6842   "ix86_match_ccmode (insn, CCNOmode)
6843    && ix86_binary_operator_ok (XOR, SImode, operands)"
6844   "xor{l}\\t{%2, %0|%0, %2}"
6845   [(set_attr "type" "alu")
6846    (set_attr "mode" "SI")])
6847
6848 (define_insn "*xorsi_3"
6849   [(set (reg 17)
6850         (compare (xor:SI (match_operand:SI 1 "nonimmediate_operand" "%0")
6851                          (match_operand:SI 2 "general_operand" "rim"))
6852                  (const_int 0)))
6853    (clobber (match_scratch:SI 0 "=r"))]
6854   "ix86_match_ccmode (insn, CCNOmode)
6855    && (GET_CODE (operands[1]) != MEM || GET_CODE (operands[2]) != MEM)"
6856   "xor{l}\\t{%2, %0|%0, %2}"
6857   [(set_attr "type" "alu")
6858    (set_attr "mode" "SI")])
6859
6860 (define_expand "xorhi3"
6861   [(set (match_operand:HI 0 "nonimmediate_operand" "")
6862         (xor:HI (match_operand:HI 1 "nonimmediate_operand" "")
6863                 (match_operand:HI 2 "general_operand" "")))
6864    (clobber (reg:CC 17))]
6865   "TARGET_HIMODE_MATH"
6866   "ix86_expand_binary_operator (XOR, HImode, operands); DONE;")
6867
6868 (define_insn "*xorhi_1"
6869   [(set (match_operand:HI 0 "nonimmediate_operand" "=r,m")
6870         (xor:HI (match_operand:HI 1 "nonimmediate_operand" "%0,0")
6871                 (match_operand:HI 2 "general_operand" "rmi,ri")))
6872    (clobber (reg:CC 17))]
6873   "ix86_binary_operator_ok (XOR, HImode, operands)"
6874   "xor{w}\\t{%2, %0|%0, %2}"
6875   [(set_attr "type" "alu")
6876    (set_attr "mode" "HI")])
6877
6878 (define_insn "*xorhi_2"
6879   [(set (reg 17)
6880         (compare (xor:HI (match_operand:HI 1 "nonimmediate_operand" "%0,0")
6881                          (match_operand:HI 2 "general_operand" "rim,ri"))
6882                  (const_int 0)))
6883    (set (match_operand:HI 0 "nonimmediate_operand" "=r,rm")
6884         (xor:HI (match_dup 1) (match_dup 2)))]
6885   "ix86_match_ccmode (insn, CCNOmode)
6886    && ix86_binary_operator_ok (XOR, HImode, operands)"
6887   "xor{w}\\t{%2, %0|%0, %2}"
6888   [(set_attr "type" "alu")
6889    (set_attr "mode" "HI")])
6890
6891 (define_insn "*xorhi_3"
6892   [(set (reg 17)
6893         (compare (xor:HI (match_operand:HI 1 "nonimmediate_operand" "%0")
6894                          (match_operand:HI 2 "general_operand" "rim"))
6895                  (const_int 0)))
6896    (clobber (match_scratch:HI 0 "=r"))]
6897   "ix86_match_ccmode (insn, CCNOmode)
6898    && (GET_CODE (operands[1]) != MEM || GET_CODE (operands[2]) != MEM)"
6899   "xor{w}\\t{%2, %0|%0, %2}"
6900   [(set_attr "type" "alu")
6901    (set_attr "mode" "HI")])
6902
6903 (define_expand "xorqi3"
6904   [(set (match_operand:QI 0 "nonimmediate_operand" "")
6905         (xor:QI (match_operand:QI 1 "nonimmediate_operand" "")
6906                 (match_operand:QI 2 "general_operand" "")))
6907    (clobber (reg:CC 17))]
6908   "TARGET_QIMODE_MATH"
6909   "ix86_expand_binary_operator (XOR, QImode, operands); DONE;")
6910
6911 ;; %%% Potential partial reg stall on alternative 2.  What to do?
6912 (define_insn "*xorqi_1"
6913   [(set (match_operand:QI 0 "nonimmediate_operand" "=q,m,r")
6914         (xor:QI (match_operand:QI 1 "nonimmediate_operand" "%0,0,0")
6915                 (match_operand:QI 2 "general_operand" "qmi,qi,ri")))
6916    (clobber (reg:CC 17))]
6917   "ix86_binary_operator_ok (XOR, QImode, operands)"
6918   "@
6919    xor{b}\\t{%2, %0|%0, %2}
6920    xor{b}\\t{%2, %0|%0, %2}
6921    xor{l}\\t{%k2, %k0|%k0, %k2}"
6922   [(set_attr "type" "alu")
6923    (set_attr "mode" "QI,QI,SI")])
6924
6925 (define_insn "*xorqi_ext_1"
6926   [(set (zero_extract:SI (match_operand 0 "ext_register_operand" "=q")
6927                          (const_int 8)
6928                          (const_int 8))
6929         (xor:SI 
6930           (zero_extract:SI (match_operand 1 "ext_register_operand" "0")
6931                            (const_int 8)
6932                            (const_int 8))
6933           (zero_extract:SI (match_operand 2 "ext_register_operand" "q")
6934                            (const_int 8)
6935                            (const_int 8))))
6936    (clobber (reg:CC 17))]
6937   ""
6938   "xor{b}\\t{%h2, %h0|%h0, %h2}"
6939   [(set_attr "type" "alu")
6940    (set_attr "length_immediate" "0")
6941    (set_attr "mode" "QI")])
6942
6943 (define_insn "*xorqi_cc_1"
6944   [(set (reg 17)
6945         (compare
6946           (xor:QI (match_operand:QI 1 "nonimmediate_operand" "%0,0")
6947                   (match_operand:QI 2 "general_operand" "qim,qi"))
6948           (const_int 0)))
6949    (set (match_operand:QI 0 "nonimmediate_operand" "=q,qm")
6950         (xor:QI (match_dup 1) (match_dup 2)))]
6951   "ix86_match_ccmode (insn, CCNOmode)
6952    && ix86_binary_operator_ok (XOR, QImode, operands)"
6953   "xor{b}\\t{%2, %0|%0, %2}"
6954   [(set_attr "type" "alu")
6955    (set_attr "mode" "QI")])
6956
6957 (define_insn "*xorqi_cc_2"
6958   [(set (reg 17)
6959         (compare
6960           (xor:QI (match_operand:QI 1 "nonimmediate_operand" "%0")
6961                   (match_operand:QI 2 "general_operand" "qim"))
6962           (const_int 0)))
6963    (clobber (match_scratch:QI 0 "=q"))]
6964   "ix86_match_ccmode (insn, CCNOmode)
6965    && (GET_CODE (operands[1]) != MEM || GET_CODE (operands[2]) != MEM)"
6966   "xor{b}\\t{%2, %0|%0, %2}"
6967   [(set_attr "type" "alu")
6968    (set_attr "mode" "QI")])
6969
6970 (define_insn "*xorqi_cc_ext_1"
6971   [(set (reg 17)
6972         (compare
6973           (xor:SI
6974             (zero_extract:SI
6975               (match_operand 1 "ext_register_operand" "0")
6976               (const_int 8)
6977               (const_int 8))
6978             (match_operand:QI 2 "general_operand" "qmn"))
6979           (const_int 0)))
6980    (set (zero_extract:SI (match_operand 0 "ext_register_operand" "=q")
6981                          (const_int 8)
6982                          (const_int 8))
6983         (xor:SI 
6984           (zero_extract:SI (match_dup 1) (const_int 8) (const_int 8))
6985           (match_dup 2)))]
6986   "ix86_match_ccmode (insn, CCNOmode)"
6987   "xor{b}\\t{%2, %h0|%h0, %2}"
6988   [(set_attr "type" "alu")
6989    (set_attr "mode" "QI")])
6990
6991 (define_expand "xorqi_cc_ext_1"
6992   [(parallel [
6993      (set (reg:CCNO 17)
6994           (compare:CCNO
6995             (xor:SI
6996               (zero_extract:SI
6997                 (match_operand 1 "ext_register_operand" "")
6998                 (const_int 8)
6999                 (const_int 8))
7000               (match_operand:QI 2 "general_operand" ""))
7001             (const_int 0)))
7002      (set (zero_extract:SI (match_operand 0 "ext_register_operand" "")
7003                            (const_int 8)
7004                            (const_int 8))
7005           (xor:SI 
7006             (zero_extract:SI (match_dup 1) (const_int 8) (const_int 8))
7007             (match_dup 2)))])]
7008   ""
7009   "")
7010 \f
7011 ;; Negation instructions
7012
7013 ;; %%% define_expand from the very first?
7014
7015 (define_expand "negdi2"
7016   [(parallel [(set (match_operand:DI 0 "nonimmediate_operand" "")
7017                    (neg:DI (match_operand:DI 1 "nonimmediate_operand" "")))
7018               (clobber (reg:CC 17))])]
7019   ""
7020   "ix86_expand_unary_operator (NEG, DImode, operands); DONE;")
7021
7022 (define_insn "*negdi2_1"
7023   [(set (match_operand:DI 0 "nonimmediate_operand" "=ro")
7024         (neg:DI (match_operand:DI 1 "general_operand" "0")))
7025    (clobber (reg:CC 17))]
7026   "ix86_unary_operator_ok (NEG, DImode, operands)"
7027   "#")
7028
7029 (define_split
7030   [(set (match_operand:DI 0 "nonimmediate_operand" "")
7031         (neg:DI (match_operand:DI 1 "general_operand" "")))
7032    (clobber (reg:CC 17))]
7033   "reload_completed"
7034   [(parallel
7035     [(set (reg:CCZ 17)
7036           (compare:CCZ (neg:SI (match_dup 2)) (const_int 0)))
7037      (set (match_dup 0) (neg:SI (match_dup 2)))])
7038    (parallel
7039     [(set (match_dup 1)
7040           (plus:SI (plus:SI (ltu:SI (reg:CC 17) (const_int 0))
7041                             (match_dup 3))
7042                    (const_int 0)))
7043      (clobber (reg:CC 17))])
7044    (parallel
7045     [(set (match_dup 1)
7046           (neg:SI (match_dup 1)))
7047      (clobber (reg:CC 17))])]
7048   "split_di (operands+1, 1, operands+2, operands+3);
7049    split_di (operands+0, 1, operands+0, operands+1);")
7050
7051 (define_expand "negsi2"
7052   [(parallel [(set (match_operand:SI 0 "nonimmediate_operand" "")
7053                    (neg:SI (match_operand:SI 1 "nonimmediate_operand" "")))
7054               (clobber (reg:CC 17))])]
7055   ""
7056   "ix86_expand_unary_operator (NEG, SImode, operands); DONE;")
7057
7058 (define_insn "*negsi2_1"
7059   [(set (match_operand:SI 0 "nonimmediate_operand" "=rm")
7060         (neg:SI (match_operand:SI 1 "nonimmediate_operand" "0")))
7061    (clobber (reg:CC 17))]
7062   "ix86_unary_operator_ok (NEG, SImode, operands)"
7063   "neg{l}\\t%0"
7064   [(set_attr "type" "negnot")
7065    (set_attr "mode" "SI")])
7066
7067 ;; The problem with neg is that it does not perform (compare x 0),
7068 ;; it really performs (compare 0 x), which leaves us with the zero
7069 ;; flag being the only useful item.
7070
7071 (define_insn "*negsi2_cmpz"
7072   [(set (reg:CCZ 17)
7073         (compare:CCZ (neg:SI (match_operand:SI 1 "nonimmediate_operand" "0"))
7074                      (const_int 0)))
7075    (set (match_operand:SI 0 "nonimmediate_operand" "=rm")
7076         (neg:SI (match_dup 1)))]
7077   "ix86_unary_operator_ok (NEG, SImode, operands)"
7078   "neg{l}\\t%0"
7079   [(set_attr "type" "negnot")
7080    (set_attr "mode" "SI")])
7081
7082 (define_expand "neghi2"
7083   [(parallel [(set (match_operand:HI 0 "nonimmediate_operand" "")
7084                    (neg:HI (match_operand:HI 1 "nonimmediate_operand" "")))
7085               (clobber (reg:CC 17))])]
7086   "TARGET_HIMODE_MATH"
7087   "ix86_expand_unary_operator (NEG, HImode, operands); DONE;")
7088
7089 (define_insn "*neghi2_1"
7090   [(set (match_operand:HI 0 "nonimmediate_operand" "=rm")
7091         (neg:HI (match_operand:HI 1 "nonimmediate_operand" "0")))
7092    (clobber (reg:CC 17))]
7093   "ix86_unary_operator_ok (NEG, HImode, operands)"
7094   "neg{w}\\t%0"
7095   [(set_attr "type" "negnot")
7096    (set_attr "mode" "HI")])
7097
7098 (define_insn "*neghi2_cmpz"
7099   [(set (reg:CCZ 17)
7100         (compare:CCZ (neg:HI (match_operand:HI 1 "nonimmediate_operand" "0"))
7101                      (const_int 0)))
7102    (set (match_operand:HI 0 "nonimmediate_operand" "=rm")
7103         (neg:HI (match_dup 1)))]
7104   "ix86_unary_operator_ok (NEG, HImode, operands)"
7105   "neg{w}\\t%0"
7106   [(set_attr "type" "negnot")
7107    (set_attr "mode" "HI")])
7108
7109 (define_expand "negqi2"
7110   [(parallel [(set (match_operand:QI 0 "nonimmediate_operand" "")
7111                    (neg:QI (match_operand:QI 1 "nonimmediate_operand" "")))
7112               (clobber (reg:CC 17))])]
7113   "TARGET_QIMODE_MATH"
7114   "ix86_expand_unary_operator (NEG, QImode, operands); DONE;")
7115
7116 (define_insn "*negqi2_1"
7117   [(set (match_operand:QI 0 "nonimmediate_operand" "=qm")
7118         (neg:QI (match_operand:QI 1 "nonimmediate_operand" "0")))
7119    (clobber (reg:CC 17))]
7120   "ix86_unary_operator_ok (NEG, QImode, operands)"
7121   "neg{b}\\t%0"
7122   [(set_attr "type" "negnot")
7123    (set_attr "mode" "QI")])
7124
7125 (define_insn "*negqi2_cmpz"
7126   [(set (reg:CCZ 17)
7127         (compare:CCZ (neg:QI (match_operand:QI 1 "nonimmediate_operand" "0"))
7128                      (const_int 0)))
7129    (set (match_operand:QI 0 "nonimmediate_operand" "=qm")
7130         (neg:QI (match_dup 1)))]
7131   "ix86_unary_operator_ok (NEG, QImode, operands)"
7132   "neg{b}\\t%0"
7133   [(set_attr "type" "negnot")
7134    (set_attr "mode" "QI")])
7135
7136 ;; Changing of sign for FP values is doable using integer unit too.
7137
7138 (define_expand "negsf2"
7139   [(parallel [(set (match_operand:SF 0 "nonimmediate_operand" "")
7140                    (neg:SF (match_operand:SF 1 "nonimmediate_operand" "")))
7141               (clobber (reg:CC 17))])]
7142   "TARGET_80387"
7143   "ix86_expand_unary_operator (NEG, SFmode, operands); DONE;")
7144
7145 ;; Keep 'f' and 'r' in separate alternatives to avoid reload problems
7146 ;; because of secondary memory needed to reload from class FLOAT_INT_REGS
7147 ;; to itself.
7148 (define_insn "*negsf2_if"
7149   [(set (match_operand:SF 0 "nonimmediate_operand" "=f#r,rm#f")
7150         (neg:SF (match_operand:SF 1 "nonimmediate_operand" "0,0")))
7151    (clobber (reg:CC 17))]
7152   "TARGET_80387 && ix86_unary_operator_ok (NEG, SFmode, operands)"
7153   "#")
7154
7155 (define_split
7156   [(set (match_operand:SF 0 "register_operand" "")
7157         (neg:SF (match_operand:SF 1 "register_operand" "")))
7158    (clobber (reg:CC 17))]
7159   "TARGET_80387 && FP_REGNO_P (REGNO (operands[0])) && reload_completed"
7160   [(set (match_dup 0)
7161         (neg:SF (match_dup 1)))]
7162   "")
7163
7164 (define_split
7165   [(set (match_operand:SF 0 "register_operand" "")
7166         (neg:SF (match_operand:SF 1 "register_operand" "")))
7167    (clobber (reg:CC 17))]
7168   "TARGET_80387 && reload_completed && !FP_REGNO_P (REGNO (operands[0]))"
7169   [(parallel [(set (match_dup 0) (xor:SI (match_dup 0) (match_dup 1)))
7170               (clobber (reg:CC 17))])]
7171   "operands[1] = GEN_INT (0x80000000);
7172    operands[0] = gen_rtx_REG (SImode, REGNO (operands[0]));")
7173
7174 (define_split
7175   [(set (match_operand 0 "memory_operand" "")
7176         (neg (match_operand 1 "memory_operand" "")))
7177    (clobber (reg:CC 17))]
7178   "TARGET_80387 && reload_completed && FLOAT_MODE_P (GET_MODE (operands[0]))"
7179   [(parallel [(set (match_dup 0) (xor:QI (match_dup 0) (match_dup 1)))
7180               (clobber (reg:CC 17))])]
7181   "
7182 {
7183   int size = GET_MODE_SIZE (GET_MODE (operands[1]));
7184
7185   /* XFmode's size is 12, but only 10 bytes are used.  */
7186   if (size == 12)
7187     size = 10;
7188   operands[0] = gen_rtx_MEM (QImode, XEXP (operands[0], 0));
7189   operands[0] = adj_offsettable_operand (operands[0], size - 1);
7190   operands[1] = GEN_INT (0x80);
7191 }")
7192
7193 (define_expand "negdf2"
7194   [(parallel [(set (match_operand:DF 0 "nonimmediate_operand" "")
7195                    (neg:DF (match_operand:DF 1 "nonimmediate_operand" "")))
7196               (clobber (reg:CC 17))])]
7197   "TARGET_80387"
7198   "ix86_expand_unary_operator (NEG, DFmode, operands); DONE;")
7199
7200 ;; Keep 'f' and 'r' in separate alternatives to avoid reload problems
7201 ;; because of secondary memory needed to reload from class FLOAT_INT_REGS
7202 ;; to itself.
7203 (define_insn "*negdf2_if"
7204   [(set (match_operand:DF 0 "nonimmediate_operand" "=f#r,rm#f")
7205         (neg:DF (match_operand:DF 1 "nonimmediate_operand" "0,0")))
7206    (clobber (reg:CC 17))]
7207   "TARGET_80387 && ix86_unary_operator_ok (NEG, DFmode, operands)"
7208   "#")
7209
7210 (define_split
7211   [(set (match_operand:DF 0 "register_operand" "")
7212         (neg:DF (match_operand:DF 1 "register_operand" "")))
7213    (clobber (reg:CC 17))]
7214   "TARGET_80387 && FP_REGNO_P (REGNO (operands[0])) && reload_completed"
7215   [(set (match_dup 0)
7216         (neg:DF (match_dup 1)))]
7217   "")
7218
7219 (define_split
7220   [(set (match_operand:DF 0 "register_operand" "")
7221         (neg:DF (match_operand:DF 1 "register_operand" "")))
7222    (clobber (reg:CC 17))]
7223   "TARGET_80387 && reload_completed && !FP_REGNO_P (REGNO (operands[0]))"
7224   [(parallel [(set (match_dup 3) (xor:SI (match_dup 3) (match_dup 4)))
7225               (clobber (reg:CC 17))])]
7226   "operands[4] = GEN_INT (0x80000000);
7227    split_di (operands+0, 1, operands+2, operands+3);")
7228
7229 (define_expand "negxf2"
7230   [(parallel [(set (match_operand:XF 0 "nonimmediate_operand" "")
7231                    (neg:XF (match_operand:XF 1 "nonimmediate_operand" "")))
7232               (clobber (reg:CC 17))])]
7233   "TARGET_80387"
7234   "ix86_expand_unary_operator (NEG, XFmode, operands); DONE;")
7235
7236 (define_expand "negtf2"
7237   [(parallel [(set (match_operand:TF 0 "nonimmediate_operand" "")
7238                    (neg:TF (match_operand:TF 1 "nonimmediate_operand" "")))
7239               (clobber (reg:CC 17))])]
7240   "TARGET_80387"
7241   "ix86_expand_unary_operator (NEG, TFmode, operands); DONE;")
7242
7243 ;; Keep 'f' and 'r' in separate alternatives to avoid reload problems
7244 ;; because of secondary memory needed to reload from class FLOAT_INT_REGS
7245 ;; to itself.
7246 (define_insn "*negxf2_if"
7247   [(set (match_operand:XF 0 "nonimmediate_operand" "=f#r,rm#f")
7248         (neg:XF (match_operand:XF 1 "nonimmediate_operand" "0,0")))
7249    (clobber (reg:CC 17))]
7250   "TARGET_80387 && ix86_unary_operator_ok (NEG, XFmode, operands)"
7251   "#")
7252
7253 (define_split
7254   [(set (match_operand:XF 0 "register_operand" "")
7255         (neg:XF (match_operand:XF 1 "register_operand" "")))
7256    (clobber (reg:CC 17))]
7257   "TARGET_80387 && FP_REGNO_P (REGNO (operands[0])) && reload_completed"
7258   [(set (match_dup 0)
7259         (neg:XF (match_dup 1)))]
7260   "")
7261
7262 (define_split
7263   [(set (match_operand:XF 0 "register_operand" "")
7264         (neg:XF (match_operand:XF 1 "register_operand" "")))
7265    (clobber (reg:CC 17))]
7266   "TARGET_80387 && reload_completed && !FP_REGNO_P (REGNO (operands[0]))"
7267   [(parallel [(set (match_dup 0) (xor:SI (match_dup 0) (match_dup 1)))
7268               (clobber (reg:CC 17))])]
7269   "operands[1] = GEN_INT (0x8000);
7270    operands[0] = gen_rtx_REG (SImode, true_regnum (operands[0]) + 2);")
7271
7272 ;; Keep 'f' and 'r' in separate alternatives to avoid reload problems
7273 ;; because of secondary memory needed to reload from class FLOAT_INT_REGS
7274 ;; to itself.
7275 (define_insn "*negtf2_if"
7276   [(set (match_operand:TF 0 "nonimmediate_operand" "=f#r,rm#f")
7277         (neg:TF (match_operand:TF 1 "nonimmediate_operand" "0,0")))
7278    (clobber (reg:CC 17))]
7279   "TARGET_80387 && ix86_unary_operator_ok (NEG, TFmode, operands)"
7280   "#")
7281
7282 (define_split
7283   [(set (match_operand:TF 0 "register_operand" "")
7284         (neg:TF (match_operand:TF 1 "register_operand" "")))
7285    (clobber (reg:CC 17))]
7286   "TARGET_80387 && FP_REGNO_P (REGNO (operands[0])) && reload_completed"
7287   [(set (match_dup 0)
7288         (neg:TF (match_dup 1)))]
7289   "")
7290
7291 (define_split
7292   [(set (match_operand:TF 0 "register_operand" "")
7293         (neg:TF (match_operand:TF 1 "register_operand" "")))
7294    (clobber (reg:CC 17))]
7295   "TARGET_80387 && reload_completed && !FP_REGNO_P (REGNO (operands[0]))"
7296   [(parallel [(set (match_dup 0) (xor:SI (match_dup 0) (match_dup 1)))
7297               (clobber (reg:CC 17))])]
7298   "operands[1] = GEN_INT (0x8000);
7299    operands[0] = gen_rtx_REG (SImode, true_regnum (operands[0]) + 2);")
7300
7301 ;; Conditionize these after reload. If they matches before reload, we 
7302 ;; lose the clobber and ability to use integer instructions.
7303
7304 (define_insn "*negsf2_1"
7305   [(set (match_operand:SF 0 "register_operand" "=f")
7306         (neg:SF (match_operand:SF 1 "register_operand" "0")))]
7307   "TARGET_80387 && reload_completed"
7308   "fchs"
7309   [(set_attr "type" "fsgn")
7310    (set_attr "mode" "SF")
7311    (set_attr "ppro_uops" "few")])
7312
7313 (define_insn "*negdf2_1"
7314   [(set (match_operand:DF 0 "register_operand" "=f")
7315         (neg:DF (match_operand:DF 1 "register_operand" "0")))]
7316   "TARGET_80387 && reload_completed"
7317   "fchs"
7318   [(set_attr "type" "fsgn")
7319    (set_attr "mode" "DF")
7320    (set_attr "ppro_uops" "few")])
7321
7322 (define_insn "*negextendsfdf2"
7323   [(set (match_operand:DF 0 "register_operand" "=f")
7324         (neg:DF (float_extend:DF
7325                   (match_operand:SF 1 "register_operand" "0"))))]
7326   "TARGET_80387"
7327   "fchs"
7328   [(set_attr "type" "fsgn")
7329    (set_attr "mode" "DF")
7330    (set_attr "ppro_uops" "few")])
7331
7332 (define_insn "*negxf2_1"
7333   [(set (match_operand:XF 0 "register_operand" "=f")
7334         (neg:XF (match_operand:XF 1 "register_operand" "0")))]
7335   "TARGET_80387 && reload_completed"
7336   "fchs"
7337   [(set_attr "type" "fsgn")
7338    (set_attr "mode" "XF")
7339    (set_attr "ppro_uops" "few")])
7340
7341 (define_insn "*negextenddfxf2"
7342   [(set (match_operand:XF 0 "register_operand" "=f")
7343         (neg:XF (float_extend:XF
7344                   (match_operand:DF 1 "register_operand" "0"))))]
7345   "TARGET_80387"
7346   "fchs"
7347   [(set_attr "type" "fsgn")
7348    (set_attr "mode" "XF")
7349    (set_attr "ppro_uops" "few")])
7350
7351 (define_insn "*negextendsfxf2"
7352   [(set (match_operand:XF 0 "register_operand" "=f")
7353         (neg:XF (float_extend:XF
7354                   (match_operand:SF 1 "register_operand" "0"))))]
7355   "TARGET_80387"
7356   "fchs"
7357   [(set_attr "type" "fsgn")
7358    (set_attr "mode" "XF")
7359    (set_attr "ppro_uops" "few")])
7360
7361 (define_insn "*negtf2_1"
7362   [(set (match_operand:TF 0 "register_operand" "=f")
7363         (neg:TF (match_operand:TF 1 "register_operand" "0")))]
7364   "TARGET_80387 && reload_completed"
7365   "fchs"
7366   [(set_attr "type" "fsgn")
7367    (set_attr "mode" "XF")
7368    (set_attr "ppro_uops" "few")])
7369
7370 (define_insn "*negextenddftf2"
7371   [(set (match_operand:TF 0 "register_operand" "=f")
7372         (neg:TF (float_extend:TF
7373                   (match_operand:DF 1 "register_operand" "0"))))]
7374   "TARGET_80387"
7375   "fchs"
7376   [(set_attr "type" "fsgn")
7377    (set_attr "mode" "XF")
7378    (set_attr "ppro_uops" "few")])
7379
7380 (define_insn "*negextendsftf2"
7381   [(set (match_operand:TF 0 "register_operand" "=f")
7382         (neg:TF (float_extend:TF
7383                   (match_operand:SF 1 "register_operand" "0"))))]
7384   "TARGET_80387"
7385   "fchs"
7386   [(set_attr "type" "fsgn")
7387    (set_attr "mode" "XF")
7388    (set_attr "ppro_uops" "few")])
7389 \f
7390 ;; Absolute value instructions
7391
7392 (define_expand "abssf2"
7393   [(parallel [(set (match_operand:SF 0 "nonimmediate_operand" "")
7394                    (neg:SF (match_operand:SF 1 "nonimmediate_operand" "")))
7395               (clobber (reg:CC 17))])]
7396   "TARGET_80387"
7397   "ix86_expand_unary_operator (ABS, SFmode, operands); DONE;")
7398
7399 ;; Keep 'f' and 'r' in separate alternatives to avoid reload problems
7400 ;; because of secondary memory needed to reload from class FLOAT_INT_REGS
7401 ;; to itself.
7402 (define_insn "*abssf2_if"
7403   [(set (match_operand:SF 0 "nonimmediate_operand" "=f#r,rm#f")
7404         (abs:SF (match_operand:SF 1 "nonimmediate_operand" "0,0")))
7405    (clobber (reg:CC 17))]
7406   "TARGET_80387 && ix86_unary_operator_ok (ABS, SFmode, operands)"
7407   "#")
7408
7409 (define_split
7410   [(set (match_operand:SF 0 "register_operand" "")
7411         (abs:SF (match_operand:SF 1 "register_operand" "")))
7412    (clobber (reg:CC 17))]
7413   "TARGET_80387 && FP_REGNO_P (REGNO (operands[0]))"
7414   [(set (match_dup 0)
7415         (abs:SF (match_dup 1)))]
7416   "")
7417
7418 (define_split
7419   [(set (match_operand:SF 0 "register_operand" "")
7420         (abs:SF (match_operand:SF 1 "register_operand" "")))
7421    (clobber (reg:CC 17))]
7422   "TARGET_80387 && reload_completed && !FP_REGNO_P (REGNO (operands[0]))"
7423   [(parallel [(set (match_dup 0) (and:SI (match_dup 0) (match_dup 1)))
7424               (clobber (reg:CC 17))])]
7425   "operands[1] = GEN_INT (~0x80000000);
7426    operands[0] = gen_rtx_REG (SImode, REGNO (operands[0]));")
7427
7428 (define_split
7429   [(set (match_operand 0 "memory_operand" "")
7430         (abs (match_operand 1 "memory_operand" "")))
7431    (clobber (reg:CC 17))]
7432   "TARGET_80387 && reload_completed && FLOAT_MODE_P (GET_MODE (operands[0]))"
7433   [(parallel [(set (match_dup 0) (and:QI (match_dup 0) (match_dup 1)))
7434               (clobber (reg:CC 17))])]
7435   "
7436 {
7437   int size = GET_MODE_SIZE (GET_MODE (operands[1]));
7438
7439   /* XFmode's size is 12, but only 10 bytes are used.  */
7440   if (size == 12)
7441     size = 10;
7442   operands[0] = gen_rtx_MEM (QImode, XEXP (operands[0], 0));
7443   operands[0] = adj_offsettable_operand (operands[0], size - 1);
7444   operands[1] = GEN_INT (~0x80);
7445 }")
7446
7447 (define_expand "absdf2"
7448   [(parallel [(set (match_operand:DF 0 "nonimmediate_operand" "")
7449                    (neg:DF (match_operand:DF 1 "nonimmediate_operand" "")))
7450               (clobber (reg:CC 17))])]
7451   "TARGET_80387"
7452   "ix86_expand_unary_operator (ABS, DFmode, operands); DONE;")
7453
7454 ;; Keep 'f' and 'r' in separate alternatives to avoid reload problems
7455 ;; because of secondary memory needed to reload from class FLOAT_INT_REGS
7456 ;; to itself.
7457 (define_insn "*absdf2_if"
7458   [(set (match_operand:DF 0 "nonimmediate_operand" "=f#r,rm#f")
7459         (abs:DF (match_operand:DF 1 "nonimmediate_operand" "0,0")))
7460    (clobber (reg:CC 17))]
7461   "TARGET_80387 && ix86_unary_operator_ok (ABS, DFmode, operands)"
7462   "#")
7463
7464 (define_split
7465   [(set (match_operand:DF 0 "register_operand" "")
7466         (abs:DF (match_operand:DF 1 "register_operand" "")))
7467    (clobber (reg:CC 17))]
7468   "TARGET_80387 && FP_REGNO_P (REGNO (operands[0])) && reload_completed"
7469   [(set (match_dup 0)
7470         (abs:DF (match_dup 1)))]
7471   "")
7472
7473 (define_split
7474   [(set (match_operand:DF 0 "register_operand" "")
7475         (abs:DF (match_operand:DF 1 "register_operand" "")))
7476    (clobber (reg:CC 17))]
7477   "TARGET_80387 && reload_completed && !FP_REGNO_P (REGNO (operands[0]))"
7478   [(parallel [(set (match_dup 3) (and:SI (match_dup 3) (match_dup 4)))
7479               (clobber (reg:CC 17))])]
7480   "operands[4] = GEN_INT (~0x80000000);
7481    split_di (operands+0, 1, operands+2, operands+3);")
7482
7483 (define_expand "absxf2"
7484   [(parallel [(set (match_operand:XF 0 "nonimmediate_operand" "")
7485                    (neg:XF (match_operand:XF 1 "nonimmediate_operand" "")))
7486               (clobber (reg:CC 17))])]
7487   "TARGET_80387"
7488   "ix86_expand_unary_operator (ABS, XFmode, operands); DONE;")
7489
7490 (define_expand "abstf2"
7491   [(parallel [(set (match_operand:TF 0 "nonimmediate_operand" "")
7492                    (neg:TF (match_operand:TF 1 "nonimmediate_operand" "")))
7493               (clobber (reg:CC 17))])]
7494   "TARGET_80387"
7495   "ix86_expand_unary_operator (ABS, TFmode, operands); DONE;")
7496
7497 ;; Keep 'f' and 'r' in separate alternatives to avoid reload problems
7498 ;; because of secondary memory needed to reload from class FLOAT_INT_REGS
7499 ;; to itself.
7500 (define_insn "*absxf2_if"
7501   [(set (match_operand:XF 0 "nonimmediate_operand" "=f#r,rm#f")
7502         (abs:XF (match_operand:XF 1 "nonimmediate_operand" "0,0")))
7503    (clobber (reg:CC 17))]
7504   "TARGET_80387 && ix86_unary_operator_ok (ABS, XFmode, operands)"
7505   "#")
7506
7507 (define_split
7508   [(set (match_operand:XF 0 "register_operand" "")
7509         (abs:XF (match_operand:XF 1 "register_operand" "")))
7510    (clobber (reg:CC 17))]
7511   "TARGET_80387 && FP_REGNO_P (REGNO (operands[0])) && reload_completed"
7512   [(set (match_dup 0)
7513         (abs:XF (match_dup 1)))]
7514   "")
7515
7516 (define_split
7517   [(set (match_operand:XF 0 "register_operand" "")
7518         (abs:XF (match_operand:XF 1 "register_operand" "")))
7519    (clobber (reg:CC 17))]
7520   "TARGET_80387 && reload_completed && !FP_REGNO_P (REGNO (operands[0]))"
7521   [(parallel [(set (match_dup 0) (and:SI (match_dup 0) (match_dup 1)))
7522               (clobber (reg:CC 17))])]
7523   "operands[1] = GEN_INT (~0x8000);
7524    operands[0] = gen_rtx_REG (SImode, true_regnum (operands[0]) + 2);")
7525
7526 (define_insn "*abstf2_if"
7527   [(set (match_operand:TF 0 "nonimmediate_operand" "=f#r,rm#f")
7528         (abs:TF (match_operand:TF 1 "nonimmediate_operand" "0,0")))
7529    (clobber (reg:CC 17))]
7530   "TARGET_80387 && ix86_unary_operator_ok (ABS, TFmode, operands)"
7531   "#")
7532
7533 (define_split
7534   [(set (match_operand:TF 0 "register_operand" "")
7535         (abs:TF (match_operand:TF 1 "register_operand" "")))
7536    (clobber (reg:CC 17))]
7537   "TARGET_80387 && FP_REGNO_P (REGNO (operands[0])) && reload_completed"
7538   [(set (match_dup 0)
7539         (abs:TF (match_dup 1)))]
7540   "")
7541
7542 (define_split
7543   [(set (match_operand:TF 0 "register_operand" "")
7544         (abs:TF (match_operand:TF 1 "register_operand" "")))
7545    (clobber (reg:CC 17))]
7546   "TARGET_80387 && reload_completed && !FP_REGNO_P (REGNO (operands[0]))"
7547   [(parallel [(set (match_dup 0) (and:SI (match_dup 0) (match_dup 1)))
7548               (clobber (reg:CC 17))])]
7549   "operands[1] = GEN_INT (~0x8000);
7550    operands[0] = gen_rtx_REG (SImode, true_regnum (operands[0]) + 2);")
7551
7552 (define_insn "*abssf2_1"
7553   [(set (match_operand:SF 0 "register_operand" "=f")
7554         (abs:SF (match_operand:SF 1 "register_operand" "0")))]
7555   "TARGET_80387 && reload_completed"
7556   "fabs"
7557   [(set_attr "type" "fsgn")
7558    (set_attr "mode" "SF")])
7559
7560 (define_insn "*absdf2_1"
7561   [(set (match_operand:DF 0 "register_operand" "=f")
7562         (abs:DF (match_operand:DF 1 "register_operand" "0")))]
7563   "TARGET_80387 && reload_completed"
7564   "fabs"
7565   [(set_attr "type" "fsgn")
7566    (set_attr "mode" "DF")])
7567
7568 (define_insn "*absextendsfdf2"
7569   [(set (match_operand:DF 0 "register_operand" "=f")
7570         (abs:DF (float_extend:DF
7571                   (match_operand:SF 1 "register_operand" "0"))))]
7572   "TARGET_80387"
7573   "fabs"
7574   [(set_attr "type" "fsgn")
7575    (set_attr "mode" "DF")])
7576
7577 (define_insn "*absxf2_1"
7578   [(set (match_operand:XF 0 "register_operand" "=f")
7579         (abs:XF (match_operand:XF 1 "register_operand" "0")))]
7580   "TARGET_80387 && reload_completed"
7581   "fabs"
7582   [(set_attr "type" "fsgn")
7583    (set_attr "mode" "DF")])
7584
7585 (define_insn "*absextenddfxf2"
7586   [(set (match_operand:XF 0 "register_operand" "=f")
7587         (abs:XF (float_extend:XF
7588           (match_operand:DF 1 "register_operand" "0"))))]
7589   "TARGET_80387"
7590   "fabs"
7591   [(set_attr "type" "fsgn")
7592    (set_attr "mode" "XF")])
7593
7594 (define_insn "*absextendsfxf2"
7595   [(set (match_operand:XF 0 "register_operand" "=f")
7596         (abs:XF (float_extend:XF
7597           (match_operand:SF 1 "register_operand" "0"))))]
7598   "TARGET_80387"
7599   "fabs"
7600   [(set_attr "type" "fsgn")
7601    (set_attr "mode" "XF")])
7602
7603 (define_insn "*abstf2_1"
7604   [(set (match_operand:TF 0 "register_operand" "=f")
7605         (abs:TF (match_operand:TF 1 "register_operand" "0")))]
7606   "TARGET_80387 && reload_completed"
7607   "fabs"
7608   [(set_attr "type" "fsgn")
7609    (set_attr "mode" "DF")])
7610
7611 (define_insn "*absextenddftf2"
7612   [(set (match_operand:TF 0 "register_operand" "=f")
7613         (abs:TF (float_extend:TF
7614           (match_operand:DF 1 "register_operand" "0"))))]
7615   "TARGET_80387"
7616   "fabs"
7617   [(set_attr "type" "fsgn")
7618    (set_attr "mode" "XF")])
7619
7620 (define_insn "*absextendsftf2"
7621   [(set (match_operand:TF 0 "register_operand" "=f")
7622         (abs:TF (float_extend:TF
7623           (match_operand:SF 1 "register_operand" "0"))))]
7624   "TARGET_80387"
7625   "fabs"
7626   [(set_attr "type" "fsgn")
7627    (set_attr "mode" "XF")])
7628 \f
7629 ;; One complement instructions
7630
7631 (define_expand "one_cmplsi2"
7632   [(set (match_operand:SI 0 "nonimmediate_operand" "")
7633         (not:SI (match_operand:SI 1 "nonimmediate_operand" "")))]
7634   ""
7635   "ix86_expand_unary_operator (NOT, SImode, operands); DONE;")
7636
7637 (define_insn "*one_cmplsi2_1"
7638   [(set (match_operand:SI 0 "nonimmediate_operand" "=rm")
7639         (not:SI (match_operand:SI 1 "nonimmediate_operand" "0")))]
7640   "ix86_unary_operator_ok (NOT, SImode, operands)"
7641   "not{l}\\t%0"
7642   [(set_attr "type" "negnot")
7643    (set_attr "mode" "SI")])
7644
7645 (define_insn "*one_cmplsi2_2"
7646   [(set (reg 17)
7647         (compare (not:SI (match_operand:SI 1 "nonimmediate_operand" "0"))
7648                  (const_int 0)))
7649    (set (match_operand:SI 0 "nonimmediate_operand" "=rm")
7650         (not:SI (match_dup 1)))]
7651   "ix86_match_ccmode (insn, CCNOmode)
7652    && ix86_unary_operator_ok (NOT, SImode, operands)"
7653   "#"
7654   [(set_attr "type" "alu1")
7655    (set_attr "mode" "SI")])
7656
7657 (define_split
7658   [(set (reg 17)
7659         (compare (not:SI (match_operand:SI 1 "nonimmediate_operand" ""))
7660                  (const_int 0)))
7661    (set (match_operand:SI 0 "nonimmediate_operand" "")
7662         (not:SI (match_dup 1)))]
7663   "ix86_match_ccmode (insn, CCNOmode)"
7664   [(parallel [(set (reg:CCNO 17)
7665                    (compare:CCNO (xor:SI (match_dup 1) (const_int -1))
7666                                  (const_int 0)))
7667               (set (match_dup 0)
7668                    (xor:SI (match_dup 1) (const_int -1)))])]
7669   "")
7670
7671 (define_expand "one_cmplhi2"
7672   [(set (match_operand:HI 0 "nonimmediate_operand" "")
7673         (not:HI (match_operand:HI 1 "nonimmediate_operand" "")))]
7674   "TARGET_HIMODE_MATH"
7675   "ix86_expand_unary_operator (NOT, HImode, operands); DONE;")
7676
7677 (define_insn "*one_cmplhi2_1"
7678   [(set (match_operand:HI 0 "nonimmediate_operand" "=rm")
7679         (not:HI (match_operand:HI 1 "nonimmediate_operand" "0")))]
7680   "ix86_unary_operator_ok (NOT, HImode, operands)"
7681   "not{w}\\t%0"
7682   [(set_attr "type" "negnot")
7683    (set_attr "mode" "HI")])
7684
7685 (define_insn "*one_cmplhi2_2"
7686   [(set (reg 17)
7687         (compare (not:HI (match_operand:HI 1 "nonimmediate_operand" "0"))
7688                  (const_int 0)))
7689    (set (match_operand:HI 0 "nonimmediate_operand" "=rm")
7690         (not:HI (match_dup 1)))]
7691   "ix86_match_ccmode (insn, CCNOmode)
7692    && ix86_unary_operator_ok (NEG, HImode, operands)"
7693   "#"
7694   [(set_attr "type" "alu1")
7695    (set_attr "mode" "HI")])
7696
7697 (define_split
7698   [(set (reg 17)
7699         (compare (not:HI (match_operand:HI 1 "nonimmediate_operand" ""))
7700                  (const_int 0)))
7701    (set (match_operand:HI 0 "nonimmediate_operand" "")
7702         (not:HI (match_dup 1)))]
7703   "ix86_match_ccmode (insn, CCNOmode)"
7704   [(parallel [(set (reg:CCNO 17)
7705                    (compare:CCNO (xor:HI (match_dup 1) (const_int -1))
7706                                  (const_int 0)))
7707               (set (match_dup 0)
7708                    (xor:HI (match_dup 1) (const_int -1)))])]
7709   "")
7710
7711 ;; %%% Potential partial reg stall on alternative 1.  What to do?
7712 (define_expand "one_cmplqi2"
7713   [(set (match_operand:QI 0 "nonimmediate_operand" "")
7714         (not:QI (match_operand:QI 1 "nonimmediate_operand" "")))]
7715   "TARGET_QIMODE_MATH"
7716   "ix86_expand_unary_operator (NOT, QImode, operands); DONE;")
7717
7718 (define_insn "*one_cmplqi2_1"
7719   [(set (match_operand:QI 0 "nonimmediate_operand" "=qm,r")
7720         (not:QI (match_operand:QI 1 "nonimmediate_operand" "0,0")))]
7721   "ix86_unary_operator_ok (NOT, QImode, operands)"
7722   "@
7723    not{b}\\t%0
7724    not{l}\\t%k0"
7725   [(set_attr "type" "negnot")
7726    (set_attr "mode" "QI,SI")])
7727
7728 (define_insn "*one_cmplqi2_2"
7729   [(set (reg 17)
7730         (compare (not:QI (match_operand:QI 1 "nonimmediate_operand" "0"))
7731                  (const_int 0)))
7732    (set (match_operand:QI 0 "nonimmediate_operand" "=qm")
7733         (not:QI (match_dup 1)))]
7734   "ix86_match_ccmode (insn, CCNOmode)
7735    && ix86_unary_operator_ok (NOT, QImode, operands)"
7736   "#"
7737   [(set_attr "type" "alu1")
7738    (set_attr "mode" "QI")])
7739
7740 (define_split
7741   [(set (reg 17)
7742         (compare (not:QI (match_operand:QI 1 "nonimmediate_operand" ""))
7743                  (const_int 0)))
7744    (set (match_operand:QI 0 "nonimmediate_operand" "")
7745         (not:QI (match_dup 1)))]
7746   "ix86_match_ccmode (insn, CCNOmode)"
7747   [(parallel [(set (reg:CCNO 17)
7748                    (compare:CCNO (xor:QI (match_dup 1) (const_int -1))
7749                                  (const_int 0)))
7750               (set (match_dup 0)
7751                    (xor:QI (match_dup 1) (const_int -1)))])]
7752   "")
7753 \f
7754 ;; Arithmetic shift instructions
7755
7756 ;; DImode shifts are implemented using the i386 "shift double" opcode,
7757 ;; which is written as "sh[lr]d[lw] imm,reg,reg/mem".  If the shift count
7758 ;; is variable, then the count is in %cl and the "imm" operand is dropped
7759 ;; from the assembler input.
7760 ;;
7761 ;; This instruction shifts the target reg/mem as usual, but instead of
7762 ;; shifting in zeros, bits are shifted in from reg operand.  If the insn
7763 ;; is a left shift double, bits are taken from the high order bits of
7764 ;; reg, else if the insn is a shift right double, bits are taken from the
7765 ;; low order bits of reg.  So if %eax is "1234" and %edx is "5678",
7766 ;; "shldl $8,%edx,%eax" leaves %edx unchanged and sets %eax to "2345".
7767 ;;
7768 ;; Since sh[lr]d does not change the `reg' operand, that is done
7769 ;; separately, making all shifts emit pairs of shift double and normal
7770 ;; shift.  Since sh[lr]d does not shift more than 31 bits, and we wish to
7771 ;; support a 63 bit shift, each shift where the count is in a reg expands
7772 ;; to a pair of shifts, a branch, a shift by 32 and a label.
7773 ;;
7774 ;; If the shift count is a constant, we need never emit more than one
7775 ;; shift pair, instead using moves and sign extension for counts greater
7776 ;; than 31.
7777
7778 (define_expand "ashldi3"
7779   [(parallel [(set (match_operand:DI 0 "register_operand" "=r")
7780                    (ashift:DI (match_operand:DI 1 "register_operand" "0")
7781                               (match_operand:QI 2 "nonmemory_operand" "Jc")))
7782               (clobber (reg:CC 17))])]
7783   ""
7784   "
7785 {
7786   if (TARGET_CMOVE && ! immediate_operand (operands[2], QImode))
7787     {
7788       emit_insn (gen_ashldi3_1 (operands[0], operands[1], operands[2]));
7789       DONE;
7790     }
7791 }")
7792
7793 (define_insn "ashldi3_1"
7794   [(set (match_operand:DI 0 "register_operand" "=r")
7795         (ashift:DI (match_operand:DI 1 "register_operand" "0")
7796                    (match_operand:QI 2 "nonmemory_operand" "Jc")))
7797    (clobber (match_scratch:SI 3 "=&r"))
7798    (clobber (reg:CC 17))]
7799   "TARGET_CMOVE"
7800   "#"
7801   [(set_attr "type" "multi")])
7802
7803 (define_insn "*ashldi3_2"
7804   [(set (match_operand:DI 0 "register_operand" "=r")
7805         (ashift:DI (match_operand:DI 1 "register_operand" "0")
7806                    (match_operand:QI 2 "nonmemory_operand" "Jc")))
7807    (clobber (reg:CC 17))]
7808   ""
7809   "#"
7810   [(set_attr "type" "multi")])
7811
7812 (define_split
7813   [(set (match_operand:DI 0 "register_operand" "")
7814         (ashift:DI (match_operand:DI 1 "register_operand" "")
7815                    (match_operand:QI 2 "nonmemory_operand" "")))
7816    (clobber (match_scratch:SI 3 ""))
7817    (clobber (reg:CC 17))]
7818   "TARGET_CMOVE && reload_completed"
7819   [(const_int 0)]
7820   "ix86_split_ashldi (operands, operands[3]); DONE;")
7821
7822 (define_split
7823   [(set (match_operand:DI 0 "register_operand" "")
7824         (ashift:DI (match_operand:DI 1 "register_operand" "")
7825                    (match_operand:QI 2 "nonmemory_operand" "")))
7826    (clobber (reg:CC 17))]
7827   "reload_completed"
7828   [(const_int 0)]
7829   "ix86_split_ashldi (operands, NULL_RTX); DONE;")
7830
7831 (define_insn "x86_shld_1"
7832   [(set (match_operand:SI 0 "nonimmediate_operand" "+r*m,r*m")
7833         (ior:SI (ashift:SI (match_dup 0)
7834                   (match_operand:QI 2 "nonmemory_operand" "I,c"))
7835                 (lshiftrt:SI (match_operand:SI 1 "register_operand" "r,r")
7836                   (minus:QI (const_int 32) (match_dup 2)))))
7837    (clobber (reg:CC 17))]
7838   ""
7839   "@
7840    shld{l}\\t{%2, %1, %0|%0, %1, %2}
7841    shld{l}\\t{%s2%1, %0|%0, %1, %2}"
7842   [(set_attr "type" "ishift")
7843    (set_attr "prefix_0f" "1")
7844    (set_attr "mode" "SI")
7845    (set_attr "pent_pair" "np")
7846    (set_attr "athlon_decode" "vector")
7847    (set_attr "ppro_uops" "few")])
7848
7849 (define_expand "x86_shift_adj_1"
7850   [(set (reg:CCZ 17)
7851         (compare:CCZ (and:QI (match_operand:QI 2 "register_operand" "")
7852                              (const_int 32))
7853                      (const_int 0)))
7854    (set (match_operand:SI 0 "register_operand" "")
7855         (if_then_else:SI (ne (reg:CCZ 17) (const_int 0))
7856                          (match_operand:SI 1 "register_operand" "")
7857                          (match_dup 0)))
7858    (set (match_dup 1)
7859         (if_then_else:SI (ne (reg:CCZ 17) (const_int 0))
7860                          (match_operand:SI 3 "register_operand" "r")
7861                          (match_dup 1)))]
7862   "TARGET_CMOVE"
7863   "")
7864
7865 (define_expand "x86_shift_adj_2"
7866   [(use (match_operand:SI 0 "register_operand" ""))
7867    (use (match_operand:SI 1 "register_operand" ""))
7868    (use (match_operand:QI 2 "register_operand" ""))]
7869   ""
7870   "
7871 {
7872   rtx label = gen_label_rtx ();
7873   rtx tmp;
7874
7875   emit_insn (gen_testqi_ccz_1 (operands[2], GEN_INT (32)));
7876
7877   tmp = gen_rtx_REG (CCZmode, FLAGS_REG);
7878   tmp = gen_rtx_EQ (VOIDmode, tmp, const0_rtx);
7879   tmp = gen_rtx_IF_THEN_ELSE (VOIDmode, tmp,
7880                               gen_rtx_LABEL_REF (VOIDmode, label),
7881                               pc_rtx);
7882   tmp = emit_jump_insn (gen_rtx_SET (VOIDmode, pc_rtx, tmp));
7883   JUMP_LABEL (tmp) = label;
7884
7885   emit_move_insn (operands[0], operands[1]);
7886   emit_move_insn (operands[1], const0_rtx);
7887
7888   emit_label (label);
7889   LABEL_NUSES (label) = 1;
7890
7891   DONE;
7892 }")
7893
7894 (define_expand "ashlsi3"
7895   [(set (match_operand:SI 0 "nonimmediate_operand" "")
7896         (ashift:SI (match_operand:SI 1 "nonimmediate_operand" "")
7897                    (match_operand:QI 2 "nonmemory_operand" "")))
7898    (clobber (reg:CC 17))]
7899   ""
7900   "ix86_expand_binary_operator (ASHIFT, SImode, operands); DONE;")
7901
7902 (define_insn "*ashlsi3_1"
7903   [(set (match_operand:SI 0 "nonimmediate_operand" "=rm,r")
7904         (ashift:SI (match_operand:SI 1 "nonimmediate_operand" "0,r")
7905                    (match_operand:QI 2 "nonmemory_operand" "cI,M")))
7906    (clobber (reg:CC 17))]
7907   "ix86_binary_operator_ok (ASHIFT, SImode, operands)"
7908   "*
7909 {
7910   switch (get_attr_type (insn))
7911     {
7912     case TYPE_ALU:
7913       if (operands[2] != const1_rtx)
7914         abort ();
7915       if (!rtx_equal_p (operands[0], operands[1]))
7916         abort ();
7917       return \"add{l}\\t{%0, %0|%0, %0}\";
7918
7919     case TYPE_LEA:
7920       if (GET_CODE (operands[2]) != CONST_INT
7921           || (unsigned HOST_WIDE_INT) INTVAL (operands[2]) > 3)
7922         abort ();
7923       operands[1] = gen_rtx_MULT (SImode, operands[1],
7924                                   GEN_INT (1 << INTVAL (operands[2])));
7925       return \"lea{l}\\t{%a1, %0|%0, %a1}\";
7926
7927     default:
7928       if (REG_P (operands[2]))
7929         return \"sal{l}\\t{%b2, %0|%0, %b2}\";
7930       else if (GET_CODE (operands[2]) == CONST_INT
7931                && INTVAL (operands[2]) == 1
7932                && (TARGET_PENTIUM || TARGET_PENTIUMPRO))
7933         return \"sal{l}\\t%0\";
7934       else
7935         return \"sal{l}\\t{%2, %0|%0, %2}\";
7936     }
7937 }"
7938   [(set (attr "type")
7939      (cond [(eq_attr "alternative" "1")
7940               (const_string "lea")
7941             (and (and (ne (symbol_ref "TARGET_DOUBLE_WITH_ADD")
7942                           (const_int 0))
7943                       (match_operand 0 "register_operand" ""))
7944                  (match_operand 2 "const1_operand" ""))
7945               (const_string "alu")
7946            ]
7947            (const_string "ishift")))
7948    (set_attr "mode" "SI")])
7949
7950 ;; Convert lea to the lea pattern to avoid flags dependency.
7951 (define_split
7952   [(set (match_operand 0 "register_operand" "")
7953         (ashift (match_operand 1 "register_operand" "")
7954                 (match_operand:QI 2 "const_int_operand" "")))
7955    (clobber (reg:CC 17))]
7956   "reload_completed
7957    && true_regnum (operands[0]) != true_regnum (operands[1])"
7958   [(const_int 0)]
7959   "
7960 {
7961   rtx pat;
7962   operands[0] = gen_lowpart (SImode, operands[0]);
7963   operands[1] = gen_lowpart (Pmode, operands[1]);
7964   operands[2] = GEN_INT (1 << INTVAL (operands[2]));
7965   pat = gen_rtx_MULT (Pmode, operands[1], operands[2]);
7966   if (Pmode != SImode)
7967     pat = gen_rtx_SUBREG (SImode, pat, 0);
7968   emit_insn (gen_rtx_SET (VOIDmode, operands[0], pat));
7969   DONE;
7970 }")
7971
7972 ;; This pattern can't accept a variable shift count, since shifts by
7973 ;; zero don't affect the flags.  We assume that shifts by constant
7974 ;; zero are optimized away.
7975 (define_insn "*ashlsi3_cmp"
7976   [(set (reg 17)
7977         (compare
7978           (ashift:SI (match_operand:SI 1 "nonimmediate_operand" "0")
7979                      (match_operand:QI 2 "immediate_operand" "I"))
7980           (const_int 0)))
7981    (set (match_operand:SI 0 "nonimmediate_operand" "=rm")
7982         (ashift:SI (match_dup 1) (match_dup 2)))]
7983   "ix86_match_ccmode (insn, CCGOCmode)
7984    && ix86_binary_operator_ok (ASHIFT, SImode, operands)"
7985   "*
7986 {
7987   switch (get_attr_type (insn))
7988     {
7989     case TYPE_ALU:
7990       if (operands[2] != const1_rtx)
7991         abort ();
7992       return \"add{l}\\t{%0, %0|%0, %0}\";
7993
7994     default:
7995       if (REG_P (operands[2]))
7996         return \"sal{l}\\t{%b2, %0|%0, %b2}\";
7997       else if (GET_CODE (operands[2]) == CONST_INT
7998                && INTVAL (operands[2]) == 1
7999                && (TARGET_PENTIUM || TARGET_PENTIUMPRO))
8000         return \"sal{l}\\t%0\";
8001       else
8002         return \"sal{l}\\t{%2, %0|%0, %2}\";
8003     }
8004 }"
8005   [(set (attr "type")
8006      (cond [(and (and (ne (symbol_ref "TARGET_DOUBLE_WITH_ADD")
8007                           (const_int 0))
8008                       (match_operand 0 "register_operand" ""))
8009                  (match_operand 2 "const1_operand" ""))
8010               (const_string "alu")
8011            ]
8012            (const_string "ishift")))
8013    (set_attr "mode" "SI")])
8014
8015 (define_expand "ashlhi3"
8016   [(set (match_operand:HI 0 "nonimmediate_operand" "")
8017         (ashift:HI (match_operand:HI 1 "nonimmediate_operand" "")
8018                    (match_operand:QI 2 "nonmemory_operand" "")))
8019    (clobber (reg:CC 17))]
8020   "TARGET_HIMODE_MATH"
8021   "ix86_expand_binary_operator (ASHIFT, HImode, operands); DONE;")
8022
8023 (define_insn "*ashlhi3_1_lea"
8024   [(set (match_operand:HI 0 "nonimmediate_operand" "=rm,r")
8025         (ashift:HI (match_operand:HI 1 "nonimmediate_operand" "0,r")
8026                    (match_operand:QI 2 "nonmemory_operand" "cI,M")))
8027    (clobber (reg:CC 17))]
8028   "!TARGET_PARTIAL_REG_STALL
8029    && ix86_binary_operator_ok (ASHIFT, HImode, operands)"
8030   "*
8031 {
8032   switch (get_attr_type (insn))
8033     {
8034     case TYPE_LEA:
8035       return \"#\";
8036     case TYPE_ALU:
8037       if (operands[2] != const1_rtx)
8038         abort ();
8039       return \"add{w}\\t{%0, %0|%0, %0}\";
8040
8041     default:
8042       if (REG_P (operands[2]))
8043         return \"sal{w}\\t{%b2, %0|%0, %b2}\";
8044       else if (GET_CODE (operands[2]) == CONST_INT
8045                && INTVAL (operands[2]) == 1
8046                && (TARGET_PENTIUM || TARGET_PENTIUMPRO))
8047         return \"sal{w}\\t%0\";
8048       else
8049         return \"sal{w}\\t{%2, %0|%0, %2}\";
8050     }
8051 }"
8052   [(set (attr "type")
8053      (cond [(eq_attr "alternative" "1")
8054               (const_string "lea")
8055             (and (and (ne (symbol_ref "TARGET_DOUBLE_WITH_ADD")
8056                           (const_int 0))
8057                       (match_operand 0 "register_operand" ""))
8058                  (match_operand 2 "const1_operand" ""))
8059               (const_string "alu")
8060            ]
8061            (const_string "ishift")))
8062    (set_attr "mode" "HI,SI")])
8063
8064 (define_insn "*ashlhi3_1"
8065   [(set (match_operand:HI 0 "nonimmediate_operand" "=rm")
8066         (ashift:HI (match_operand:HI 1 "nonimmediate_operand" "0")
8067                    (match_operand:QI 2 "nonmemory_operand" "cI")))
8068    (clobber (reg:CC 17))]
8069   "TARGET_PARTIAL_REG_STALL
8070    && ix86_binary_operator_ok (ASHIFT, HImode, operands)"
8071   "*
8072 {
8073   switch (get_attr_type (insn))
8074     {
8075     case TYPE_ALU:
8076       if (operands[2] != const1_rtx)
8077         abort ();
8078       return \"add{w}\\t{%0, %0|%0, %0}\";
8079
8080     default:
8081       if (REG_P (operands[2]))
8082         return \"sal{w}\\t{%b2, %0|%0, %b2}\";
8083       else if (GET_CODE (operands[2]) == CONST_INT
8084                && INTVAL (operands[2]) == 1
8085                && (TARGET_PENTIUM || TARGET_PENTIUMPRO))
8086         return \"sal{w}\\t%0\";
8087       else
8088         return \"sal{w}\\t{%2, %0|%0, %2}\";
8089     }
8090 }"
8091   [(set (attr "type")
8092      (cond [(and (and (ne (symbol_ref "TARGET_DOUBLE_WITH_ADD")
8093                           (const_int 0))
8094                       (match_operand 0 "register_operand" ""))
8095                  (match_operand 2 "const1_operand" ""))
8096               (const_string "alu")
8097            ]
8098            (const_string "ishift")))
8099    (set_attr "mode" "HI")])
8100
8101 ;; This pattern can't accept a variable shift count, since shifts by
8102 ;; zero don't affect the flags.  We assume that shifts by constant
8103 ;; zero are optimized away.
8104 (define_insn "*ashlhi3_cmp"
8105   [(set (reg 17)
8106         (compare
8107           (ashift:HI (match_operand:HI 1 "nonimmediate_operand" "0")
8108                      (match_operand:QI 2 "immediate_operand" "I"))
8109           (const_int 0)))
8110    (set (match_operand:HI 0 "nonimmediate_operand" "=rm")
8111         (ashift:HI (match_dup 1) (match_dup 2)))]
8112   "ix86_match_ccmode (insn, CCGOCmode)
8113    && ix86_binary_operator_ok (ASHIFT, HImode, operands)"
8114   "*
8115 {
8116   switch (get_attr_type (insn))
8117     {
8118     case TYPE_ALU:
8119       if (operands[2] != const1_rtx)
8120         abort ();
8121       return \"add{w}\\t{%0, %0|%0, %0}\";
8122
8123     default:
8124       if (REG_P (operands[2]))
8125         return \"sal{w}\\t{%b2, %0|%0, %b2}\";
8126       else if (GET_CODE (operands[2]) == CONST_INT
8127                && INTVAL (operands[2]) == 1
8128                && (TARGET_PENTIUM || TARGET_PENTIUMPRO))
8129         return \"sal{w}\\t%0\";
8130       else
8131         return \"sal{w}\\t{%2, %0|%0, %2}\";
8132     }
8133 }"
8134   [(set (attr "type")
8135      (cond [(and (and (ne (symbol_ref "TARGET_DOUBLE_WITH_ADD")
8136                           (const_int 0))
8137                       (match_operand 0 "register_operand" ""))
8138                  (match_operand 2 "const1_operand" ""))
8139               (const_string "alu")
8140            ]
8141            (const_string "ishift")))
8142    (set_attr "mode" "HI")])
8143
8144 (define_expand "ashlqi3"
8145   [(set (match_operand:QI 0 "nonimmediate_operand" "")
8146         (ashift:QI (match_operand:QI 1 "nonimmediate_operand" "")
8147                    (match_operand:QI 2 "nonmemory_operand" "")))
8148    (clobber (reg:CC 17))]
8149   "TARGET_QIMODE_MATH"
8150   "ix86_expand_binary_operator (ASHIFT, QImode, operands); DONE;")
8151
8152 ;; %%% Potential partial reg stall on alternative 2.  What to do?
8153
8154 (define_insn "*ashlqi3_1_lea"
8155   [(set (match_operand:QI 0 "nonimmediate_operand" "=qm,r,r")
8156         (ashift:QI (match_operand:QI 1 "nonimmediate_operand" "0,0,r")
8157                    (match_operand:QI 2 "nonmemory_operand" "cI,cI,M")))
8158    (clobber (reg:CC 17))]
8159   "!TARGET_PARTIAL_REG_STALL
8160    && ix86_binary_operator_ok (ASHIFT, QImode, operands)"
8161   "*
8162 {
8163   switch (get_attr_type (insn))
8164     {
8165     case TYPE_LEA:
8166       return \"#\";
8167     case TYPE_ALU:
8168       if (operands[2] != const1_rtx)
8169         abort ();
8170       if (NON_QI_REG_P (operands[1]))
8171         return \"add{l}\\t{%k0, %k0|%k0, %k0}\";
8172       else
8173         return \"add{b}\\t{%0, %0|%0, %0}\";
8174
8175     default:
8176       if (REG_P (operands[2]))
8177         {
8178           if (get_attr_mode (insn) == MODE_SI)
8179             return \"sal{l}\\t{%b2, %k0|%k0, %b2}\";
8180           else
8181             return \"sal{b}\\t{%b2, %0|%0, %b2}\";
8182         }
8183       else if (GET_CODE (operands[2]) == CONST_INT
8184                && INTVAL (operands[2]) == 1
8185                && (TARGET_PENTIUM || TARGET_PENTIUMPRO))
8186         {
8187           if (get_attr_mode (insn) == MODE_SI)
8188             return \"sal{l}\\t%0\";
8189           else
8190             return \"sal{b}\\t%0\";
8191         }
8192       else
8193         {
8194           if (get_attr_mode (insn) == MODE_SI)
8195             return \"sal{l}\\t{%2, %k0|%k0, %2}\";
8196           else
8197             return \"sal{b}\\t{%2, %0|%0, %2}\";
8198         }
8199     }
8200 }"
8201   [(set (attr "type")
8202      (cond [(eq_attr "alternative" "2")
8203               (const_string "lea")
8204             (and (and (ne (symbol_ref "TARGET_DOUBLE_WITH_ADD")
8205                           (const_int 0))
8206                       (match_operand 0 "register_operand" ""))
8207                  (match_operand 2 "const1_operand" ""))
8208               (const_string "alu")
8209            ]
8210            (const_string "ishift")))
8211    (set_attr "mode" "QI,SI,SI")])
8212
8213 (define_insn "*ashlqi3_1"
8214   [(set (match_operand:QI 0 "nonimmediate_operand" "=qm,r")
8215         (ashift:QI (match_operand:QI 1 "nonimmediate_operand" "0,0")
8216                    (match_operand:QI 2 "nonmemory_operand" "cI,cI")))
8217    (clobber (reg:CC 17))]
8218   "TARGET_PARTIAL_REG_STALL
8219    && ix86_binary_operator_ok (ASHIFT, QImode, operands)"
8220   "*
8221 {
8222   switch (get_attr_type (insn))
8223     {
8224     case TYPE_ALU:
8225       if (operands[2] != const1_rtx)
8226         abort ();
8227       if (NON_QI_REG_P (operands[1]))
8228         return \"add{l}\\t{%k0, %k0|%k0, %k0}\";
8229       else
8230         return \"add{b}\\t{%0, %0|%0, %0}\";
8231
8232     default:
8233       if (REG_P (operands[2]))
8234         {
8235           if (NON_QI_REG_P (operands[1]))
8236             return \"sal{l}\\t{%b2, %k0|%k0, %b2}\";
8237           else
8238             return \"sal{b}\\t{%b2, %0|%0, %b2}\";
8239         }
8240       else if (GET_CODE (operands[2]) == CONST_INT
8241                && INTVAL (operands[2]) == 1
8242                && (TARGET_PENTIUM || TARGET_PENTIUMPRO))
8243         {
8244           if (NON_QI_REG_P (operands[1]))
8245             return \"sal{l}\\t%0\";
8246           else
8247             return \"sal{b}\\t%0\";
8248         }
8249       else
8250         {
8251           if (NON_QI_REG_P (operands[1]))
8252             return \"sal{l}\\t{%2, %k0|%k0, %2}\";
8253           else
8254             return \"sal{b}\\t{%2, %0|%0, %2}\";
8255         }
8256     }
8257 }"
8258   [(set (attr "type")
8259      (cond [(and (and (ne (symbol_ref "TARGET_DOUBLE_WITH_ADD")
8260                           (const_int 0))
8261                       (match_operand 0 "register_operand" ""))
8262                  (match_operand 2 "const1_operand" ""))
8263               (const_string "alu")
8264            ]
8265            (const_string "ishift")))
8266    (set_attr "mode" "QI,SI")])
8267
8268 ;; This pattern can't accept a variable shift count, since shifts by
8269 ;; zero don't affect the flags.  We assume that shifts by constant
8270 ;; zero are optimized away.
8271 (define_insn "*ashlqi3_cmp"
8272   [(set (reg 17)
8273         (compare
8274           (ashift:QI (match_operand:QI 1 "nonimmediate_operand" "0")
8275                      (match_operand:QI 2 "immediate_operand" "I"))
8276           (const_int 0)))
8277    (set (match_operand:QI 0 "nonimmediate_operand" "=qm")
8278         (ashift:QI (match_dup 1) (match_dup 2)))]
8279   "ix86_match_ccmode (insn, CCGOCmode)
8280    && ix86_binary_operator_ok (ASHIFT, QImode, operands)"
8281   "*
8282 {
8283   switch (get_attr_type (insn))
8284     {
8285     case TYPE_ALU:
8286       if (operands[2] != const1_rtx)
8287         abort ();
8288       return \"add{b}\\t{%0, %0|%0, %0}\";
8289
8290     default:
8291       if (REG_P (operands[2]))
8292         return \"sal{b}\\t{%b2, %0|%0, %b2}\";
8293       else if (GET_CODE (operands[2]) == CONST_INT
8294                && INTVAL (operands[2]) == 1
8295                && (TARGET_PENTIUM || TARGET_PENTIUMPRO))
8296         return \"sal{b}\\t%0\";
8297       else
8298         return \"sal{b}\\t{%2, %0|%0, %2}\";
8299     }
8300 }"
8301   [(set (attr "type")
8302      (cond [(and (and (ne (symbol_ref "TARGET_DOUBLE_WITH_ADD")
8303                           (const_int 0))
8304                       (match_operand 0 "register_operand" ""))
8305                  (match_operand 2 "const1_operand" ""))
8306               (const_string "alu")
8307            ]
8308            (const_string "ishift")))
8309    (set_attr "mode" "QI")])
8310
8311 ;; See comment above `ashldi3' about how this works.
8312
8313 (define_expand "ashrdi3"
8314   [(parallel [(set (match_operand:DI 0 "register_operand" "=r")
8315                    (ashiftrt:DI (match_operand:DI 1 "register_operand" "0")
8316                                 (match_operand:QI 2 "nonmemory_operand" "Jc")))
8317               (clobber (reg:CC 17))])]
8318   ""
8319   "
8320 {
8321   if (TARGET_CMOVE && ! immediate_operand (operands[2], QImode))
8322     {
8323       emit_insn (gen_ashrdi3_1 (operands[0], operands[1], operands[2]));
8324       DONE;
8325     }
8326 }")
8327
8328 (define_insn "ashrdi3_1"
8329   [(set (match_operand:DI 0 "register_operand" "=r")
8330         (ashiftrt:DI (match_operand:DI 1 "register_operand" "0")
8331                      (match_operand:QI 2 "nonmemory_operand" "Jc")))
8332    (clobber (match_scratch:SI 3 "=&r"))
8333    (clobber (reg:CC 17))]
8334   "TARGET_CMOVE"
8335   "#"
8336   [(set_attr "type" "multi")])
8337
8338 (define_insn "*ashrdi3_2"
8339   [(set (match_operand:DI 0 "register_operand" "=r")
8340         (ashiftrt:DI (match_operand:DI 1 "register_operand" "0")
8341                      (match_operand:QI 2 "nonmemory_operand" "Jc")))
8342    (clobber (reg:CC 17))]
8343   ""
8344   "#"
8345   [(set_attr "type" "multi")])
8346
8347 (define_split
8348   [(set (match_operand:DI 0 "register_operand" "")
8349         (ashiftrt:DI (match_operand:DI 1 "register_operand" "")
8350                      (match_operand:QI 2 "nonmemory_operand" "")))
8351    (clobber (match_scratch:SI 3 ""))
8352    (clobber (reg:CC 17))]
8353   "TARGET_CMOVE && reload_completed"
8354   [(const_int 0)]
8355   "ix86_split_ashrdi (operands, operands[3]); DONE;")
8356
8357 (define_split
8358   [(set (match_operand:DI 0 "register_operand" "")
8359         (ashiftrt:DI (match_operand:DI 1 "register_operand" "")
8360                      (match_operand:QI 2 "nonmemory_operand" "")))
8361    (clobber (reg:CC 17))]
8362   "reload_completed"
8363   [(const_int 0)]
8364   "ix86_split_ashrdi (operands, NULL_RTX); DONE;")
8365
8366 (define_insn "x86_shrd_1"
8367   [(set (match_operand:SI 0 "nonimmediate_operand" "+r*m,r*m")
8368         (ior:SI (ashiftrt:SI (match_dup 0)
8369                   (match_operand:QI 2 "nonmemory_operand" "I,c"))
8370                 (ashift:SI (match_operand:SI 1 "register_operand" "r,r")
8371                   (minus:QI (const_int 32) (match_dup 2)))))
8372    (clobber (reg:CC 17))]
8373   ""
8374   "@
8375    shrd{l}\\t{%2, %1, %0|%0, %1, %2}
8376    shrd{l}\\t{%s2%1, %0|%0, %1, %2}"
8377   [(set_attr "type" "ishift")
8378    (set_attr "prefix_0f" "1")
8379    (set_attr "pent_pair" "np")
8380    (set_attr "ppro_uops" "few")
8381    (set_attr "mode" "SI")])
8382
8383 (define_expand "x86_shift_adj_3"
8384   [(use (match_operand:SI 0 "register_operand" ""))
8385    (use (match_operand:SI 1 "register_operand" ""))
8386    (use (match_operand:QI 2 "register_operand" ""))]
8387   ""
8388   "
8389 {
8390   rtx label = gen_label_rtx ();
8391   rtx tmp;
8392
8393   emit_insn (gen_testqi_ccz_1 (operands[2], GEN_INT (32)));
8394
8395   tmp = gen_rtx_REG (CCZmode, FLAGS_REG);
8396   tmp = gen_rtx_EQ (VOIDmode, tmp, const0_rtx);
8397   tmp = gen_rtx_IF_THEN_ELSE (VOIDmode, tmp,
8398                               gen_rtx_LABEL_REF (VOIDmode, label),
8399                               pc_rtx);
8400   tmp = emit_jump_insn (gen_rtx_SET (VOIDmode, pc_rtx, tmp));
8401   JUMP_LABEL (tmp) = label;
8402
8403   emit_move_insn (operands[0], operands[1]);
8404   emit_insn (gen_ashrsi3_31 (operands[1], operands[1], GEN_INT (31)));
8405
8406   emit_label (label);
8407   LABEL_NUSES (label) = 1;
8408
8409   DONE;
8410 }")
8411
8412 (define_insn "ashrsi3_31"
8413   [(set (match_operand:SI 0 "nonimmediate_operand" "=*d,rm")
8414         (ashiftrt:SI (match_operand:SI 1 "nonimmediate_operand" "*a,0")
8415                      (match_operand:SI 2 "const_int_operand" "i,i")))
8416    (clobber (reg:CC 17))]
8417   "INTVAL (operands[2]) == 31 && (TARGET_USE_CLTD || optimize_size)
8418    && ix86_binary_operator_ok (ASHIFTRT, SImode, operands)"
8419   "@
8420    {cltd|cdq}
8421    sar{l}\\t{%2, %0|%0, %2}"
8422   [(set_attr "type" "imovx,ishift")
8423    (set_attr "prefix_0f" "0,*")
8424    (set_attr "length_immediate" "0,*")
8425    (set_attr "modrm" "0,1")
8426    (set_attr "mode" "SI")])
8427
8428 (define_expand "ashrsi3"
8429   [(set (match_operand:SI 0 "nonimmediate_operand" "")
8430         (ashiftrt:SI (match_operand:SI 1 "nonimmediate_operand" "")
8431                      (match_operand:QI 2 "nonmemory_operand" "")))
8432    (clobber (reg:CC 17))]
8433   ""
8434   "ix86_expand_binary_operator (ASHIFTRT, SImode, operands); DONE;")
8435
8436 (define_insn "*ashrsi3_1_one_bit"
8437   [(set (match_operand:SI 0 "nonimmediate_operand" "=rm")
8438         (ashiftrt:SI (match_operand:SI 1 "nonimmediate_operand" "0")
8439                      (match_operand:QI 2 "const_int_1_operand" "")))
8440    (clobber (reg:CC 17))]
8441   "ix86_binary_operator_ok (ASHIFTRT, SImode, operands)
8442    && (TARGET_PENTIUM || TARGET_PENTIUMPRO)"
8443   "sar{l}\\t%0"
8444   [(set_attr "type" "ishift")
8445    (set (attr "length") 
8446      (if_then_else (match_operand:SI 0 "register_operand" "") 
8447         (const_string "2")
8448         (const_string "*")))])
8449
8450 (define_insn "*ashrsi3_1"
8451   [(set (match_operand:SI 0 "nonimmediate_operand" "=rm,rm")
8452         (ashiftrt:SI (match_operand:SI 1 "nonimmediate_operand" "0,0")
8453                      (match_operand:QI 2 "nonmemory_operand" "I,c")))
8454    (clobber (reg:CC 17))]
8455   "ix86_binary_operator_ok (ASHIFTRT, SImode, operands)"
8456   "@
8457    sar{l}\\t{%2, %0|%0, %2}
8458    sar{l}\\t{%b2, %0|%0, %b2}"
8459   [(set_attr "type" "ishift")
8460    (set_attr "mode" "SI")])
8461
8462 ;; This pattern can't accept a variable shift count, since shifts by
8463 ;; zero don't affect the flags.  We assume that shifts by constant
8464 ;; zero are optimized away.
8465 (define_insn "*ashrsi3_one_bit_cmp"
8466   [(set (reg 17)
8467         (compare
8468           (ashiftrt:SI (match_operand:SI 1 "nonimmediate_operand" "0")
8469                        (match_operand:QI 2 "const_int_1_operand" ""))
8470           (const_int 0)))
8471    (set (match_operand:SI 0 "nonimmediate_operand" "=rm")
8472         (ashiftrt:SI (match_dup 1) (match_dup 2)))]
8473   "ix86_match_ccmode (insn, CCGOCmode)
8474    && (TARGET_PENTIUM || TARGET_PENTIUMPRO)
8475    && ix86_binary_operator_ok (ASHIFTRT, SImode, operands)"
8476   "sar{l}\\t%0"
8477   [(set_attr "type" "ishift")
8478    (set (attr "length") 
8479      (if_then_else (match_operand:SI 0 "register_operand" "") 
8480         (const_string "2")
8481         (const_string "*")))])
8482
8483 ;; This pattern can't accept a variable shift count, since shifts by
8484 ;; zero don't affect the flags.  We assume that shifts by constant
8485 ;; zero are optimized away.
8486 (define_insn "*ashrsi3_cmp"
8487   [(set (reg 17)
8488         (compare
8489           (ashiftrt:SI (match_operand:SI 1 "nonimmediate_operand" "0")
8490                        (match_operand:QI 2 "immediate_operand" "I"))
8491           (const_int 0)))
8492    (set (match_operand:SI 0 "nonimmediate_operand" "=rm")
8493         (ashiftrt:SI (match_dup 1) (match_dup 2)))]
8494   "ix86_match_ccmode (insn, CCGOCmode)
8495    && ix86_binary_operator_ok (ASHIFTRT, SImode, operands)"
8496   "sar{l}\\t{%2, %0|%0, %2}"
8497   [(set_attr "type" "ishift")
8498    (set_attr "mode" "SI")])
8499
8500 (define_expand "ashrhi3"
8501   [(set (match_operand:HI 0 "nonimmediate_operand" "")
8502         (ashiftrt:HI (match_operand:HI 1 "nonimmediate_operand" "")
8503                      (match_operand:QI 2 "nonmemory_operand" "")))
8504    (clobber (reg:CC 17))]
8505   "TARGET_HIMODE_MATH"
8506   "ix86_expand_binary_operator (ASHIFTRT, HImode, operands); DONE;")
8507
8508 (define_insn "*ashrhi3_1_one_bit"
8509   [(set (match_operand:HI 0 "nonimmediate_operand" "=rm")
8510         (ashiftrt:HI (match_operand:HI 1 "nonimmediate_operand" "0")
8511                      (match_operand:QI 2 "const_int_1_operand" "")))
8512    (clobber (reg:CC 17))]
8513   "ix86_binary_operator_ok (ASHIFTRT, HImode, operands)
8514    && (TARGET_PENTIUM || TARGET_PENTIUMPRO)"
8515   "sar{w}\\t%0"
8516   [(set_attr "type" "ishift")
8517    (set (attr "length") 
8518      (if_then_else (match_operand:SI 0 "register_operand" "") 
8519         (const_string "2")
8520         (const_string "*")))])
8521
8522 (define_insn "*ashrhi3_1"
8523   [(set (match_operand:HI 0 "nonimmediate_operand" "=rm,rm")
8524         (ashiftrt:HI (match_operand:HI 1 "nonimmediate_operand" "0,0")
8525                      (match_operand:QI 2 "nonmemory_operand" "I,c")))
8526    (clobber (reg:CC 17))]
8527   "ix86_binary_operator_ok (ASHIFTRT, HImode, operands)"
8528   "@
8529    sar{w}\\t{%2, %0|%0, %2}
8530    sar{w}\\t{%b2, %0|%0, %b2}"
8531   [(set_attr "type" "ishift")
8532    (set_attr "mode" "HI")])
8533
8534 ;; This pattern can't accept a variable shift count, since shifts by
8535 ;; zero don't affect the flags.  We assume that shifts by constant
8536 ;; zero are optimized away.
8537 (define_insn "*ashrhi3_one_bit_cmp"
8538   [(set (reg 17)
8539         (compare
8540           (ashiftrt:HI (match_operand:HI 1 "nonimmediate_operand" "0")
8541                        (match_operand:QI 2 "const_int_1_operand" ""))
8542           (const_int 0)))
8543    (set (match_operand:HI 0 "nonimmediate_operand" "=rm")
8544         (ashiftrt:HI (match_dup 1) (match_dup 2)))]
8545   "ix86_match_ccmode (insn, CCGOCmode)
8546    && (TARGET_PENTIUM || TARGET_PENTIUMPRO)
8547    && ix86_binary_operator_ok (ASHIFTRT, HImode, operands)"
8548   "sar{w}\\t%0"
8549   [(set_attr "type" "ishift")
8550    (set (attr "length") 
8551      (if_then_else (match_operand:SI 0 "register_operand" "") 
8552         (const_string "2")
8553         (const_string "*")))])
8554
8555 ;; This pattern can't accept a variable shift count, since shifts by
8556 ;; zero don't affect the flags.  We assume that shifts by constant
8557 ;; zero are optimized away.
8558 (define_insn "*ashrhi3_cmp"
8559   [(set (reg 17)
8560         (compare
8561           (ashiftrt:HI (match_operand:HI 1 "nonimmediate_operand" "0")
8562                        (match_operand:QI 2 "immediate_operand" "I"))
8563           (const_int 0)))
8564    (set (match_operand:HI 0 "nonimmediate_operand" "=rm")
8565         (ashiftrt:HI (match_dup 1) (match_dup 2)))]
8566   "ix86_match_ccmode (insn, CCGOCmode)
8567    && ix86_binary_operator_ok (ASHIFTRT, HImode, operands)"
8568   "sar{w}\\t{%2, %0|%0, %2}"
8569   [(set_attr "type" "ishift")
8570    (set_attr "mode" "HI")])
8571
8572 (define_expand "ashrqi3"
8573   [(set (match_operand:QI 0 "nonimmediate_operand" "")
8574         (ashiftrt:QI (match_operand:QI 1 "nonimmediate_operand" "")
8575                      (match_operand:QI 2 "nonmemory_operand" "")))
8576    (clobber (reg:CC 17))]
8577   "TARGET_QIMODE_MATH"
8578   "ix86_expand_binary_operator (ASHIFTRT, QImode, operands); DONE;")
8579
8580 (define_insn "*ashrqi3_1_one_bit"
8581   [(set (match_operand:QI 0 "nonimmediate_operand" "=qm")
8582         (ashiftrt:QI (match_operand:QI 1 "nonimmediate_operand" "0")
8583                      (match_operand:QI 2 "const_int_1_operand" "")))
8584    (clobber (reg:CC 17))]
8585   "ix86_binary_operator_ok (ASHIFTRT, QImode, operands)
8586    && (TARGET_PENTIUM || TARGET_PENTIUMPRO)"
8587   "sar{b}\\t%0"
8588   [(set_attr "type" "ishift")
8589    (set (attr "length") 
8590      (if_then_else (match_operand:SI 0 "register_operand" "") 
8591         (const_string "2")
8592         (const_string "*")))])
8593
8594 (define_insn "*ashrqi3_1"
8595   [(set (match_operand:QI 0 "nonimmediate_operand" "=qm,qm")
8596         (ashiftrt:QI (match_operand:QI 1 "nonimmediate_operand" "0,0")
8597                      (match_operand:QI 2 "nonmemory_operand" "I,c")))
8598    (clobber (reg:CC 17))]
8599   "ix86_binary_operator_ok (ASHIFTRT, QImode, operands)"
8600   "@
8601    sar{b}\\t{%2, %0|%0, %2}
8602    sar{b}\\t{%b2, %0|%0, %b2}"
8603   [(set_attr "type" "ishift")
8604    (set_attr "mode" "QI")])
8605
8606 ;; This pattern can't accept a variable shift count, since shifts by
8607 ;; zero don't affect the flags.  We assume that shifts by constant
8608 ;; zero are optimized away.
8609 (define_insn "*ashrqi3_one_bit_cmp"
8610   [(set (reg 17)
8611         (compare
8612           (ashiftrt:QI (match_operand:QI 1 "nonimmediate_operand" "0")
8613                        (match_operand:QI 2 "const_int_1_operand" "I"))
8614           (const_int 0)))
8615    (set (match_operand:QI 0 "nonimmediate_operand" "=rm")
8616         (ashiftrt:QI (match_dup 1) (match_dup 2)))]
8617   "ix86_match_ccmode (insn, CCGOCmode)
8618    && (TARGET_PENTIUM || TARGET_PENTIUMPRO)
8619    && ix86_binary_operator_ok (ASHIFTRT, QImode, operands)"
8620   "sar{b}\\t%0"
8621   [(set_attr "type" "ishift")
8622    (set (attr "length") 
8623      (if_then_else (match_operand:SI 0 "register_operand" "") 
8624         (const_string "2")
8625         (const_string "*")))])
8626
8627 ;; This pattern can't accept a variable shift count, since shifts by
8628 ;; zero don't affect the flags.  We assume that shifts by constant
8629 ;; zero are optimized away.
8630 (define_insn "*ashrqi3_cmp"
8631   [(set (reg 17)
8632         (compare
8633           (ashiftrt:QI (match_operand:QI 1 "nonimmediate_operand" "0")
8634                        (match_operand:QI 2 "immediate_operand" "I"))
8635           (const_int 0)))
8636    (set (match_operand:QI 0 "nonimmediate_operand" "=rm")
8637         (ashiftrt:QI (match_dup 1) (match_dup 2)))]
8638   "ix86_match_ccmode (insn, CCGOCmode)
8639    && ix86_binary_operator_ok (ASHIFTRT, QImode, operands)"
8640   "sar{b}\\t{%2, %0|%0, %2}"
8641   [(set_attr "type" "ishift")
8642    (set_attr "mode" "QI")])
8643 \f
8644 ;; Logical shift instructions
8645
8646 ;; See comment above `ashldi3' about how this works.
8647
8648 (define_expand "lshrdi3"
8649   [(parallel [(set (match_operand:DI 0 "register_operand" "=r")
8650                    (lshiftrt:DI (match_operand:DI 1 "register_operand" "0")
8651                                 (match_operand:QI 2 "nonmemory_operand" "Jc")))
8652               (clobber (reg:CC 17))])]
8653   ""
8654   "
8655 {
8656   if (TARGET_CMOVE && ! immediate_operand (operands[2], QImode))
8657     {
8658       emit_insn (gen_lshrdi3_1 (operands[0], operands[1], operands[2]));
8659       DONE;
8660     }
8661 }")
8662
8663 (define_insn "lshrdi3_1"
8664   [(set (match_operand:DI 0 "register_operand" "=r")
8665         (lshiftrt:DI (match_operand:DI 1 "register_operand" "0")
8666                      (match_operand:QI 2 "nonmemory_operand" "Jc")))
8667    (clobber (match_scratch:SI 3 "=&r"))
8668    (clobber (reg:CC 17))]
8669   "TARGET_CMOVE"
8670   "#"
8671   [(set_attr "type" "multi")])
8672
8673 (define_insn "*lshrdi3_2"
8674   [(set (match_operand:DI 0 "register_operand" "=r")
8675         (lshiftrt:DI (match_operand:DI 1 "register_operand" "0")
8676                      (match_operand:QI 2 "nonmemory_operand" "Jc")))
8677    (clobber (reg:CC 17))]
8678   ""
8679   "#"
8680   [(set_attr "type" "multi")])
8681
8682 (define_split 
8683   [(set (match_operand:DI 0 "register_operand" "")
8684         (lshiftrt:DI (match_operand:DI 1 "register_operand" "")
8685                      (match_operand:QI 2 "nonmemory_operand" "")))
8686    (clobber (match_scratch:SI 3 ""))
8687    (clobber (reg:CC 17))]
8688   "TARGET_CMOVE && reload_completed"
8689   [(const_int 0)]
8690   "ix86_split_lshrdi (operands, operands[3]); DONE;")
8691
8692 (define_split 
8693   [(set (match_operand:DI 0 "register_operand" "")
8694         (lshiftrt:DI (match_operand:DI 1 "register_operand" "")
8695                      (match_operand:QI 2 "nonmemory_operand" "")))
8696    (clobber (reg:CC 17))]
8697   "reload_completed"
8698   [(const_int 0)]
8699   "ix86_split_lshrdi (operands, NULL_RTX); DONE;")
8700
8701 (define_expand "lshrsi3"
8702   [(set (match_operand:SI 0 "nonimmediate_operand" "")
8703         (lshiftrt:SI (match_operand:SI 1 "nonimmediate_operand" "")
8704                      (match_operand:QI 2 "nonmemory_operand" "")))
8705    (clobber (reg:CC 17))]
8706   ""
8707   "ix86_expand_binary_operator (LSHIFTRT, SImode, operands); DONE;")
8708
8709 (define_insn "*lshrsi3_1_one_bit"
8710   [(set (match_operand:SI 0 "nonimmediate_operand" "=rm")
8711         (lshiftrt:SI (match_operand:SI 1 "nonimmediate_operand" "0")
8712                      (match_operand:QI 2 "const_int_1_operand" "")))
8713    (clobber (reg:CC 17))]
8714   "ix86_binary_operator_ok (LSHIFTRT, HImode, operands)
8715    && (TARGET_PENTIUM || TARGET_PENTIUMPRO)"
8716   "shr{l}\\t%0"
8717   [(set_attr "type" "ishift")
8718    (set (attr "length") 
8719      (if_then_else (match_operand:SI 0 "register_operand" "") 
8720         (const_string "2")
8721         (const_string "*")))])
8722
8723 (define_insn "*lshrsi3_1"
8724   [(set (match_operand:SI 0 "nonimmediate_operand" "=rm,rm")
8725         (lshiftrt:SI (match_operand:SI 1 "nonimmediate_operand" "0,0")
8726                      (match_operand:QI 2 "nonmemory_operand" "I,c")))
8727    (clobber (reg:CC 17))]
8728   "ix86_binary_operator_ok (LSHIFTRT, HImode, operands)"
8729   "@
8730    shr{l}\\t{%2, %0|%0, %2}
8731    shr{l}\\t{%b2, %0|%0, %b2}"
8732   [(set_attr "type" "ishift")
8733    (set_attr "mode" "SI")])
8734
8735 ;; This pattern can't accept a variable shift count, since shifts by
8736 ;; zero don't affect the flags.  We assume that shifts by constant
8737 ;; zero are optimized away.
8738 (define_insn "*lshrsi3_one_bit_cmp"
8739   [(set (reg 17)
8740         (compare
8741           (lshiftrt:SI (match_operand:SI 1 "nonimmediate_operand" "0")
8742                        (match_operand:QI 2 "const_int_1_operand" ""))
8743           (const_int 0)))
8744    (set (match_operand:SI 0 "nonimmediate_operand" "=rm")
8745         (lshiftrt:SI (match_dup 1) (match_dup 2)))]
8746   "ix86_match_ccmode (insn, CCGOCmode)
8747    && (TARGET_PENTIUM || TARGET_PENTIUMPRO)
8748    && ix86_binary_operator_ok (LSHIFTRT, HImode, operands)"
8749   "shr{l}\\t%0"
8750   [(set_attr "type" "ishift")
8751    (set (attr "length") 
8752      (if_then_else (match_operand:SI 0 "register_operand" "") 
8753         (const_string "2")
8754         (const_string "*")))])
8755
8756 ;; This pattern can't accept a variable shift count, since shifts by
8757 ;; zero don't affect the flags.  We assume that shifts by constant
8758 ;; zero are optimized away.
8759 (define_insn "*lshrsi3_cmp"
8760   [(set (reg 17)
8761         (compare
8762           (lshiftrt:SI (match_operand:SI 1 "nonimmediate_operand" "0")
8763                        (match_operand:QI 2 "immediate_operand" "I"))
8764           (const_int 0)))
8765    (set (match_operand:SI 0 "nonimmediate_operand" "=rm")
8766         (lshiftrt:SI (match_dup 1) (match_dup 2)))]
8767   "ix86_match_ccmode (insn, CCGOCmode)
8768    && ix86_binary_operator_ok (LSHIFTRT, HImode, operands)"
8769   "shr{l}\\t{%2, %0|%0, %2}"
8770   [(set_attr "type" "ishift")
8771    (set_attr "mode" "SI")])
8772
8773 (define_expand "lshrhi3"
8774   [(set (match_operand:HI 0 "nonimmediate_operand" "")
8775         (lshiftrt:HI (match_operand:HI 1 "nonimmediate_operand" "")
8776                      (match_operand:QI 2 "nonmemory_operand" "")))
8777    (clobber (reg:CC 17))]
8778   "TARGET_HIMODE_MATH"
8779   "ix86_expand_binary_operator (LSHIFTRT, HImode, operands); DONE;")
8780
8781 (define_insn "*lshrhi3_1_one_bit"
8782   [(set (match_operand:HI 0 "nonimmediate_operand" "=rm")
8783         (lshiftrt:HI (match_operand:HI 1 "nonimmediate_operand" "0")
8784                      (match_operand:QI 2 "const_int_1_operand" "")))
8785    (clobber (reg:CC 17))]
8786   "ix86_binary_operator_ok (LSHIFTRT, HImode, operands)
8787    && (TARGET_PENTIUM || TARGET_PENTIUMPRO)"
8788   "shr{w}\\t%0"
8789   [(set_attr "type" "ishift")
8790    (set (attr "length") 
8791      (if_then_else (match_operand:SI 0 "register_operand" "") 
8792         (const_string "2")
8793         (const_string "*")))])
8794
8795 (define_insn "*lshrhi3_1"
8796   [(set (match_operand:HI 0 "nonimmediate_operand" "=rm,rm")
8797         (lshiftrt:HI (match_operand:HI 1 "nonimmediate_operand" "0,0")
8798                      (match_operand:QI 2 "nonmemory_operand" "I,c")))
8799    (clobber (reg:CC 17))]
8800   "ix86_binary_operator_ok (LSHIFTRT, HImode, operands)"
8801   "@
8802    shr{w}\\t{%2, %0|%0, %2}
8803    shr{w}\\t{%b2, %0|%0, %b2}"
8804   [(set_attr "type" "ishift")
8805    (set_attr "mode" "HI")])
8806
8807 ;; This pattern can't accept a variable shift count, since shifts by
8808 ;; zero don't affect the flags.  We assume that shifts by constant
8809 ;; zero are optimized away.
8810 (define_insn "*lshrhi3_one_bit_cmp"
8811   [(set (reg 17)
8812         (compare
8813           (lshiftrt:HI (match_operand:HI 1 "nonimmediate_operand" "0")
8814                        (match_operand:QI 2 "const_int_1_operand" ""))
8815           (const_int 0)))
8816    (set (match_operand:HI 0 "nonimmediate_operand" "=rm")
8817         (lshiftrt:HI (match_dup 1) (match_dup 2)))]
8818   "ix86_match_ccmode (insn, CCGOCmode)
8819    && (TARGET_PENTIUM || TARGET_PENTIUMPRO)
8820    && ix86_binary_operator_ok (LSHIFTRT, HImode, operands)"
8821   "shr{w}\\t%0"
8822   [(set_attr "type" "ishift")
8823    (set (attr "length") 
8824      (if_then_else (match_operand:SI 0 "register_operand" "") 
8825         (const_string "2")
8826         (const_string "*")))])
8827
8828 ;; This pattern can't accept a variable shift count, since shifts by
8829 ;; zero don't affect the flags.  We assume that shifts by constant
8830 ;; zero are optimized away.
8831 (define_insn "*lshrhi3_cmp"
8832   [(set (reg 17)
8833         (compare
8834           (lshiftrt:HI (match_operand:HI 1 "nonimmediate_operand" "0")
8835                        (match_operand:QI 2 "immediate_operand" "I"))
8836           (const_int 0)))
8837    (set (match_operand:HI 0 "nonimmediate_operand" "=rm")
8838         (lshiftrt:HI (match_dup 1) (match_dup 2)))]
8839   "ix86_match_ccmode (insn, CCGOCmode)
8840    && ix86_binary_operator_ok (LSHIFTRT, HImode, operands)"
8841   "shr{w}\\t{%2, %0|%0, %2}"
8842   [(set_attr "type" "ishift")
8843    (set_attr "mode" "HI")])
8844
8845 (define_expand "lshrqi3"
8846   [(set (match_operand:QI 0 "nonimmediate_operand" "")
8847         (lshiftrt:QI (match_operand:QI 1 "nonimmediate_operand" "")
8848                      (match_operand:QI 2 "nonmemory_operand" "")))
8849    (clobber (reg:CC 17))]
8850   "TARGET_QIMODE_MATH"
8851   "ix86_expand_binary_operator (LSHIFTRT, QImode, operands); DONE;")
8852
8853 (define_insn "*lshrqi3_1_one_bit"
8854   [(set (match_operand:QI 0 "nonimmediate_operand" "=qm")
8855         (lshiftrt:QI (match_operand:QI 1 "nonimmediate_operand" "0")
8856                      (match_operand:QI 2 "const_int_1_operand" "")))
8857    (clobber (reg:CC 17))]
8858   "ix86_binary_operator_ok (LSHIFTRT, QImode, operands)
8859    && (TARGET_PENTIUM || TARGET_PENTIUMPRO)"
8860   "shr{b}\\t%0"
8861   [(set_attr "type" "ishift")
8862    (set (attr "length") 
8863      (if_then_else (match_operand:SI 0 "register_operand" "") 
8864         (const_string "2")
8865         (const_string "*")))])
8866
8867 (define_insn "*lshrqi3_1"
8868   [(set (match_operand:QI 0 "nonimmediate_operand" "=qm,qm")
8869         (lshiftrt:QI (match_operand:QI 1 "nonimmediate_operand" "0,0")
8870                      (match_operand:QI 2 "nonmemory_operand" "I,c")))
8871    (clobber (reg:CC 17))]
8872   "ix86_binary_operator_ok (LSHIFTRT, QImode, operands)"
8873   "@
8874    shr{b}\\t{%2, %0|%0, %2}
8875    shr{b}\\t{%b2, %0|%0, %b2}"
8876   [(set_attr "type" "ishift")
8877    (set_attr "mode" "QI")])
8878
8879 ;; This pattern can't accept a variable shift count, since shifts by
8880 ;; zero don't affect the flags.  We assume that shifts by constant
8881 ;; zero are optimized away.
8882 (define_insn "*lshrqi2_one_bit_cmp"
8883   [(set (reg 17)
8884         (compare
8885           (lshiftrt:QI (match_operand:QI 1 "nonimmediate_operand" "0")
8886                        (match_operand:QI 2 "const_int_1_operand" ""))
8887           (const_int 0)))
8888    (set (match_operand:QI 0 "nonimmediate_operand" "=qm")
8889         (lshiftrt:QI (match_dup 1) (match_dup 2)))]
8890   "ix86_match_ccmode (insn, CCGOCmode)
8891    && (TARGET_PENTIUM || TARGET_PENTIUMPRO)
8892    && ix86_binary_operator_ok (LSHIFTRT, QImode, operands)"
8893   "shr{b}\\t%0"
8894   [(set_attr "type" "ishift")
8895    (set (attr "length") 
8896      (if_then_else (match_operand:SI 0 "register_operand" "") 
8897         (const_string "2")
8898         (const_string "*")))])
8899
8900 ;; This pattern can't accept a variable shift count, since shifts by
8901 ;; zero don't affect the flags.  We assume that shifts by constant
8902 ;; zero are optimized away.
8903 (define_insn "*lshrqi2_cmp"
8904   [(set (reg 17)
8905         (compare
8906           (lshiftrt:QI (match_operand:QI 1 "nonimmediate_operand" "0")
8907                        (match_operand:QI 2 "immediate_operand" "I"))
8908           (const_int 0)))
8909    (set (match_operand:QI 0 "nonimmediate_operand" "=qm")
8910         (lshiftrt:QI (match_dup 1) (match_dup 2)))]
8911   "ix86_match_ccmode (insn, CCGOCmode)
8912    && ix86_binary_operator_ok (LSHIFTRT, QImode, operands)"
8913   "shr{b}\\t{%2, %0|%0, %2}"
8914   [(set_attr "type" "ishift")
8915    (set_attr "mode" "QI")])
8916 \f
8917 ;; Rotate instructions
8918
8919 (define_expand "rotlsi3"
8920   [(set (match_operand:SI 0 "nonimmediate_operand" "")
8921         (rotate:SI (match_operand:SI 1 "nonimmediate_operand" "")
8922                    (match_operand:QI 2 "nonmemory_operand" "")))
8923    (clobber (reg:CC 17))]
8924   ""
8925   "ix86_expand_binary_operator (ROTATE, SImode, operands); DONE;")
8926
8927 (define_insn "*rotlsi3_1_one_bit"
8928   [(set (match_operand:SI 0 "nonimmediate_operand" "=rm")
8929         (rotate:SI (match_operand:SI 1 "nonimmediate_operand" "0")
8930                    (match_operand:QI 2 "const_int_1_operand" "")))
8931    (clobber (reg:CC 17))]
8932   "ix86_binary_operator_ok (ROTATE, SImode, operands)
8933    && (TARGET_PENTIUM || TARGET_PENTIUMPRO)"
8934   "rol{l}\\t%0"
8935   [(set_attr "type" "ishift")
8936    (set (attr "length") 
8937      (if_then_else (match_operand:SI 0 "register_operand" "") 
8938         (const_string "2")
8939         (const_string "*")))])
8940
8941 (define_insn "*rotlsi3_1"
8942   [(set (match_operand:SI 0 "nonimmediate_operand" "=rm,rm")
8943         (rotate:SI (match_operand:SI 1 "nonimmediate_operand" "0,0")
8944                    (match_operand:QI 2 "nonmemory_operand" "I,c")))
8945    (clobber (reg:CC 17))]
8946   "ix86_binary_operator_ok (ROTATE, SImode, operands)"
8947   "@
8948    rol{l}\\t{%2, %0|%0, %2}
8949    rol{l}\\t{%b2, %0|%0, %b2}"
8950   [(set_attr "type" "ishift")
8951    (set_attr "mode" "SI")])
8952
8953 (define_expand "rotlhi3"
8954   [(set (match_operand:HI 0 "nonimmediate_operand" "")
8955         (rotate:HI (match_operand:HI 1 "nonimmediate_operand" "")
8956                    (match_operand:QI 2 "nonmemory_operand" "")))
8957    (clobber (reg:CC 17))]
8958   "TARGET_HIMODE_MATH"
8959   "ix86_expand_binary_operator (ROTATE, HImode, operands); DONE;")
8960
8961 (define_insn "*rotlhi3_1_one_bit"
8962   [(set (match_operand:HI 0 "nonimmediate_operand" "=rm")
8963         (rotate:HI (match_operand:HI 1 "nonimmediate_operand" "0")
8964                    (match_operand:QI 2 "const_int_1_operand" "")))
8965    (clobber (reg:CC 17))]
8966   "ix86_binary_operator_ok (ROTATE, HImode, operands)
8967    && (TARGET_PENTIUM || TARGET_PENTIUMPRO)"
8968   "rol{w}\\t%0"
8969   [(set_attr "type" "ishift")
8970    (set (attr "length") 
8971      (if_then_else (match_operand:SI 0 "register_operand" "") 
8972         (const_string "2")
8973         (const_string "*")))])
8974
8975 (define_insn "*rotlhi3_1"
8976   [(set (match_operand:HI 0 "nonimmediate_operand" "=rm,rm")
8977         (rotate:HI (match_operand:HI 1 "nonimmediate_operand" "0,0")
8978                    (match_operand:QI 2 "nonmemory_operand" "I,c")))
8979    (clobber (reg:CC 17))]
8980   "ix86_binary_operator_ok (ROTATE, HImode, operands)"
8981   "@
8982    rol{w}\\t{%2, %0|%0, %2}
8983    rol{w}\\t{%b2, %0|%0, %b2}"
8984   [(set_attr "type" "ishift")
8985    (set_attr "mode" "HI")])
8986
8987 (define_expand "rotlqi3"
8988   [(set (match_operand:QI 0 "nonimmediate_operand" "")
8989         (rotate:QI (match_operand:QI 1 "nonimmediate_operand" "")
8990                    (match_operand:QI 2 "nonmemory_operand" "")))
8991    (clobber (reg:CC 17))]
8992   "TARGET_QIMODE_MATH"
8993   "ix86_expand_binary_operator (ROTATE, QImode, operands); DONE;")
8994
8995 (define_insn "*rotlqi3_1_one_bit"
8996   [(set (match_operand:QI 0 "nonimmediate_operand" "=qm")
8997         (rotate:QI (match_operand:QI 1 "nonimmediate_operand" "0")
8998                    (match_operand:QI 2 "const_int_1_operand" "")))
8999    (clobber (reg:CC 17))]
9000   "ix86_binary_operator_ok (ROTATE, QImode, operands)
9001    && (TARGET_PENTIUM || TARGET_PENTIUMPRO)"
9002   "rol{b}\\t%0"
9003   [(set_attr "type" "ishift")
9004    (set (attr "length") 
9005      (if_then_else (match_operand:SI 0 "register_operand" "") 
9006         (const_string "2")
9007         (const_string "*")))])
9008
9009 (define_insn "*rotlqi3_1"
9010   [(set (match_operand:QI 0 "nonimmediate_operand" "=qm,qm")
9011         (rotate:QI (match_operand:QI 1 "nonimmediate_operand" "0,0")
9012                    (match_operand:QI 2 "nonmemory_operand" "I,c")))
9013    (clobber (reg:CC 17))]
9014   "ix86_binary_operator_ok (ROTATE, QImode, operands)"
9015   "@
9016    rol{b}\\t{%2, %0|%0, %2}
9017    rol{b}\\t{%b2, %0|%0, %b2}"
9018   [(set_attr "type" "ishift")
9019    (set_attr "mode" "QI")])
9020
9021 (define_expand "rotrsi3"
9022   [(set (match_operand:SI 0 "nonimmediate_operand" "")
9023         (rotatert:SI (match_operand:SI 1 "nonimmediate_operand" "")
9024                      (match_operand:QI 2 "nonmemory_operand" "")))
9025    (clobber (reg:CC 17))]
9026   ""
9027   "ix86_expand_binary_operator (ROTATERT, SImode, operands); DONE;")
9028
9029 (define_insn "*rotrsi3_1_one_bit"
9030   [(set (match_operand:SI 0 "nonimmediate_operand" "=rm")
9031         (rotatert:SI (match_operand:SI 1 "nonimmediate_operand" "0")
9032                      (match_operand:QI 2 "const_int_1_operand" "")))
9033    (clobber (reg:CC 17))]
9034   "ix86_binary_operator_ok (ROTATERT, SImode, operands)
9035    && (TARGET_PENTIUM || TARGET_PENTIUMPRO)"
9036   "ror{l}\\t%0"
9037   [(set_attr "type" "ishift")
9038    (set (attr "length") 
9039      (if_then_else (match_operand:SI 0 "register_operand" "") 
9040         (const_string "2")
9041         (const_string "*")))])
9042
9043 (define_insn "*rotrsi3_1"
9044   [(set (match_operand:SI 0 "nonimmediate_operand" "=rm,rm")
9045         (rotatert:SI (match_operand:SI 1 "nonimmediate_operand" "0,0")
9046                      (match_operand:QI 2 "nonmemory_operand" "I,c")))
9047    (clobber (reg:CC 17))]
9048   "ix86_binary_operator_ok (ROTATERT, SImode, operands)"
9049   "@
9050    ror{l}\\t{%2, %0|%0, %2}
9051    ror{l}\\t{%b2, %0|%0, %b2}"
9052   [(set_attr "type" "ishift")
9053    (set_attr "mode" "SI")])
9054
9055 (define_expand "rotrhi3"
9056   [(set (match_operand:HI 0 "nonimmediate_operand" "")
9057         (rotatert:HI (match_operand:HI 1 "nonimmediate_operand" "")
9058                      (match_operand:QI 2 "nonmemory_operand" "")))
9059    (clobber (reg:CC 17))]
9060   "TARGET_HIMODE_MATH"
9061   "ix86_expand_binary_operator (ROTATERT, HImode, operands); DONE;")
9062
9063 (define_insn "*rotrhi3_one_bit"
9064   [(set (match_operand:HI 0 "nonimmediate_operand" "=rm")
9065         (rotatert:HI (match_operand:HI 1 "nonimmediate_operand" "0")
9066                      (match_operand:QI 2 "const_int_1_operand" "")))
9067    (clobber (reg:CC 17))]
9068   "ix86_binary_operator_ok (ROTATERT, HImode, operands)
9069    && (TARGET_PENTIUM || TARGET_PENTIUMPRO)"
9070   "ror{w}\\t%0"
9071   [(set_attr "type" "ishift")
9072    (set (attr "length") 
9073      (if_then_else (match_operand:SI 0 "register_operand" "") 
9074         (const_string "2")
9075         (const_string "*")))])
9076
9077 (define_insn "*rotrhi3"
9078   [(set (match_operand:HI 0 "nonimmediate_operand" "=rm,rm")
9079         (rotatert:HI (match_operand:HI 1 "nonimmediate_operand" "0,0")
9080                      (match_operand:QI 2 "nonmemory_operand" "I,c")))
9081    (clobber (reg:CC 17))]
9082   "ix86_binary_operator_ok (ROTATERT, HImode, operands)"
9083   "@
9084    ror{w}\\t{%2, %0|%0, %2}
9085    ror{w}\\t{%b2, %0|%0, %b2}"
9086   [(set_attr "type" "ishift")
9087    (set_attr "mode" "HI")])
9088
9089 (define_expand "rotrqi3"
9090   [(set (match_operand:QI 0 "nonimmediate_operand" "")
9091         (rotatert:QI (match_operand:QI 1 "nonimmediate_operand" "")
9092                      (match_operand:QI 2 "nonmemory_operand" "")))
9093    (clobber (reg:CC 17))]
9094   "TARGET_QIMODE_MATH"
9095   "ix86_expand_binary_operator (ROTATERT, QImode, operands); DONE;")
9096
9097 (define_insn "*rotrqi3_1_one_bit"
9098   [(set (match_operand:QI 0 "nonimmediate_operand" "=qm")
9099         (rotatert:QI (match_operand:QI 1 "nonimmediate_operand" "0")
9100                      (match_operand:QI 2 "const_int_1_operand" "")))
9101    (clobber (reg:CC 17))]
9102   "ix86_binary_operator_ok (ROTATERT, QImode, operands)
9103    && (TARGET_PENTIUM || TARGET_PENTIUMPRO)"
9104   "ror{b}\\t%0"
9105   [(set_attr "type" "ishift")
9106    (set (attr "length") 
9107      (if_then_else (match_operand:SI 0 "register_operand" "") 
9108         (const_string "2")
9109         (const_string "*")))])
9110
9111 (define_insn "*rotrqi3_1"
9112   [(set (match_operand:QI 0 "nonimmediate_operand" "=qm,qm")
9113         (rotatert:QI (match_operand:QI 1 "nonimmediate_operand" "0,0")
9114                      (match_operand:QI 2 "nonmemory_operand" "I,c")))
9115    (clobber (reg:CC 17))]
9116   "ix86_binary_operator_ok (ROTATERT, QImode, operands)"
9117   "@
9118    ror{b}\\t{%2, %0|%0, %2}
9119    ror{b}\\t{%b2, %0|%0, %b2}"
9120   [(set_attr "type" "ishift")
9121    (set_attr "mode" "QI")])
9122 \f
9123 ;; Bit set / bit test instructions
9124
9125 (define_expand "extv"
9126   [(set (match_operand:SI 0 "register_operand" "")
9127         (sign_extract:SI (match_operand:SI 1 "register_operand" "")
9128                          (match_operand:SI 2 "immediate_operand" "")
9129                          (match_operand:SI 3 "immediate_operand" "")))]
9130   ""
9131   "
9132 {
9133   /* Handle extractions from %ah et al.  */
9134   if (INTVAL (operands[2]) != 8 || INTVAL (operands[3]) != 8)
9135     FAIL;
9136
9137   /* From mips.md: extract_bit_field doesn't verify that our source
9138      matches the predicate, so check it again here.  */
9139   if (! register_operand (operands[1], VOIDmode))
9140     FAIL;
9141 }")
9142
9143 (define_expand "extzv"
9144   [(set (match_operand:SI 0 "register_operand" "")
9145         (zero_extract:SI (match_operand 1 "ext_register_operand" "")
9146                          (match_operand:SI 2 "immediate_operand" "")
9147                          (match_operand:SI 3 "immediate_operand" "")))]
9148   ""
9149   "
9150 {
9151   /* Handle extractions from %ah et al.  */
9152   if (INTVAL (operands[2]) != 8 || INTVAL (operands[3]) != 8)
9153     FAIL;
9154
9155   /* From mips.md: extract_bit_field doesn't verify that our source
9156      matches the predicate, so check it again here.  */
9157   if (! register_operand (operands[1], VOIDmode))
9158     FAIL;
9159 }")
9160
9161 (define_expand "insv"
9162   [(set (zero_extract:SI (match_operand 0 "ext_register_operand" "")
9163                          (match_operand:SI 1 "immediate_operand" "")
9164                          (match_operand:SI 2 "immediate_operand" ""))
9165         (match_operand:SI 3 "register_operand" ""))]
9166   ""
9167   "
9168 {
9169   /* Handle extractions from %ah et al.  */
9170   if (INTVAL (operands[1]) != 8 || INTVAL (operands[2]) != 8)
9171     FAIL;
9172
9173   /* From mips.md: insert_bit_field doesn't verify that our source
9174      matches the predicate, so check it again here.  */
9175   if (! register_operand (operands[0], VOIDmode))
9176     FAIL;
9177 }")
9178
9179 ;; %%% bts, btr, btc, bt.
9180 \f
9181 ;; Store-flag instructions.
9182
9183 ;; For all sCOND expanders, also expand the compare or test insn that
9184 ;; generates cc0.  Generate an equality comparison if `seq' or `sne'.
9185
9186 ;; %%% Do the expansion to SImode.  If PII, do things the xor+setcc way
9187 ;; to avoid partial register stalls.  Otherwise do things the setcc+movzx
9188 ;; way, which can later delete the movzx if only QImode is needed.
9189
9190 (define_expand "seq"
9191   [(set (match_operand:SI 0 "register_operand" "")
9192         (eq:SI (reg:CC 17) (const_int 0)))]
9193   ""
9194   "if (ix86_expand_setcc (EQ, operands[0])) DONE; else FAIL;")
9195
9196 (define_expand "sne"
9197   [(set (match_operand:SI 0 "register_operand" "")
9198         (ne:SI (reg:CC 17) (const_int 0)))]
9199   ""
9200   "if (ix86_expand_setcc (NE, operands[0])) DONE; else FAIL;")
9201
9202 (define_expand "sgt"
9203   [(set (match_operand:SI 0 "register_operand" "")
9204         (gt:SI (reg:CC 17) (const_int 0)))]
9205   ""
9206   "if (ix86_expand_setcc (GT, operands[0])) DONE; else FAIL;")
9207
9208 (define_expand "sgtu"
9209   [(set (match_operand:SI 0 "register_operand" "")
9210         (gtu:SI (reg:CC 17) (const_int 0)))]
9211   ""
9212   "if (ix86_expand_setcc (GTU, operands[0])) DONE; else FAIL;")
9213
9214 (define_expand "slt"
9215   [(set (match_operand:SI 0 "register_operand" "")
9216         (lt:SI (reg:CC 17) (const_int 0)))]
9217   ""
9218   "if (ix86_expand_setcc (LT, operands[0])) DONE; else FAIL;")
9219
9220 (define_expand "sltu"
9221   [(set (match_operand:SI 0 "register_operand" "")
9222         (ltu:SI (reg:CC 17) (const_int 0)))]
9223   ""
9224   "if (ix86_expand_setcc (LTU, operands[0])) DONE; else FAIL;")
9225
9226 (define_expand "sge"
9227   [(set (match_operand:SI 0 "register_operand" "")
9228         (ge:SI (reg:CC 17) (const_int 0)))]
9229   ""
9230   "if (ix86_expand_setcc (GE, operands[0])) DONE; else FAIL;")
9231
9232 (define_expand "sgeu"
9233   [(set (match_operand:SI 0 "register_operand" "")
9234         (geu:SI (reg:CC 17) (const_int 0)))]
9235   ""
9236   "if (ix86_expand_setcc (GEU, operands[0])) DONE; else FAIL;")
9237
9238 (define_expand "sle"
9239   [(set (match_operand:SI 0 "register_operand" "")
9240         (le:SI (reg:CC 17) (const_int 0)))]
9241   ""
9242   "if (ix86_expand_setcc (LE, operands[0])) DONE; else FAIL;")
9243
9244 (define_expand "sleu"
9245   [(set (match_operand:SI 0 "register_operand" "")
9246         (leu:SI (reg:CC 17) (const_int 0)))]
9247   ""
9248   "if (ix86_expand_setcc (LEU, operands[0])) DONE; else FAIL;")
9249
9250 (define_expand "sunordered"
9251   [(set (match_operand:SI 0 "register_operand" "")
9252         (unordered:SI (reg:CC 17) (const_int 0)))]
9253   "TARGET_80387 || TARGET_SSE"
9254   "if (ix86_expand_setcc (UNORDERED, operands[0])) DONE; else FAIL;")
9255
9256 (define_expand "sordered"
9257   [(set (match_operand:SI 0 "register_operand" "")
9258         (ordered:SI (reg:CC 17) (const_int 0)))]
9259   "TARGET_80387"
9260   "if (ix86_expand_setcc (ORDERED, operands[0])) DONE; else FAIL;")
9261
9262 (define_expand "suneq"
9263   [(set (match_operand:SI 0 "register_operand" "")
9264         (uneq:SI (reg:CC 17) (const_int 0)))]
9265   "TARGET_80387 || TARGET_SSE"
9266   "if (ix86_expand_setcc (UNEQ, operands[0])) DONE; else FAIL;")
9267
9268 (define_expand "sunge"
9269   [(set (match_operand:SI 0 "register_operand" "")
9270         (unge:SI (reg:CC 17) (const_int 0)))]
9271   "TARGET_80387 || TARGET_SSE"
9272   "if (ix86_expand_setcc (UNGE, operands[0])) DONE; else FAIL;")
9273
9274 (define_expand "sungt"
9275   [(set (match_operand:SI 0 "register_operand" "")
9276         (ungt:SI (reg:CC 17) (const_int 0)))]
9277   "TARGET_80387 || TARGET_SSE"
9278   "if (ix86_expand_setcc (UNGT, operands[0])) DONE; else FAIL;")
9279
9280 (define_expand "sunle"
9281   [(set (match_operand:SI 0 "register_operand" "")
9282         (unle:SI (reg:CC 17) (const_int 0)))]
9283   "TARGET_80387 || TARGET_SSE"
9284   "if (ix86_expand_setcc (UNLE, operands[0])) DONE; else FAIL;")
9285
9286 (define_expand "sunlt"
9287   [(set (match_operand:SI 0 "register_operand" "")
9288         (unlt:SI (reg:CC 17) (const_int 0)))]
9289   "TARGET_80387 || TARGET_SSE"
9290   "if (ix86_expand_setcc (UNLT, operands[0])) DONE; else FAIL;")
9291
9292 (define_expand "sltgt"
9293   [(set (match_operand:SI 0 "register_operand" "")
9294         (ltgt:SI (reg:CC 17) (const_int 0)))]
9295   "TARGET_80387 || TARGET_SSE"
9296   "if (ix86_expand_setcc (LTGT, operands[0])) DONE; else FAIL;")
9297
9298 (define_insn "*setcc_1"
9299   [(set (match_operand:QI 0 "nonimmediate_operand" "=qm")
9300         (match_operator:QI 1 "ix86_comparison_operator"
9301           [(reg 17) (const_int 0)]))]
9302   ""
9303   "set%C1\\t%0"
9304   [(set_attr "type" "setcc")
9305    (set_attr "mode" "QI")])
9306
9307 (define_insn "setcc_2"
9308   [(set (strict_low_part (match_operand:QI 0 "nonimmediate_operand" "+qm"))
9309         (match_operator:QI 1 "ix86_comparison_operator"
9310           [(reg 17) (const_int 0)]))]
9311   ""
9312   "set%C1\\t%0"
9313   [(set_attr "type" "setcc")
9314    (set_attr "mode" "QI")])
9315
9316 ;; The SSE store flag instructions saves 0 or 0xffffffff to the result.
9317 ;; subsequent logical operations are used to imitate conditional moves.
9318 ;; 0xffffffff is NaN, but not in normalized form, so we can't represent
9319 ;; it directly.  Futher holding this value in pseudo register might bring
9320 ;; problem in implicit normalization in spill code.
9321 ;; So we don't define FLOAT_STORE_FLAG_VALUE and create these
9322 ;; instructions after reload by splitting the conditional move patterns.
9323
9324 (define_insn "*sse_setccsf"
9325   [(set (match_operand:SF 0 "register_operand" "=x")
9326         (match_operator:SF 1 "sse_comparison_operator"
9327           [(match_operand:SF 2 "register_operand" "0")
9328            (match_operand:SF 3 "nonimmediate_operand" "xm")]))]
9329   "TARGET_SSE && reload_completed"
9330   "cmp%D1ss\\t{%3, %0|%0, %3}"
9331   [(set_attr "type" "sse")
9332    (set_attr "mode" "SF")])
9333
9334 (define_insn "*sse_setccdf"
9335   [(set (match_operand:DF 0 "register_operand" "=Y")
9336         (match_operator:DF 1 "sse_comparison_operator"
9337           [(match_operand:DF 2 "register_operand" "0")
9338            (match_operand:DF 3 "nonimmediate_operand" "Ym")]))]
9339   "TARGET_SSE2 && reload_completed"
9340   "cmp%D1sd\\t{%3, %0|%0, %3}"
9341   [(set_attr "type" "sse")
9342    (set_attr "mode" "DF")])
9343 \f
9344 ;; Basic conditional jump instructions.
9345 ;; We ignore the overflow flag for signed branch instructions.
9346
9347 ;; For all bCOND expanders, also expand the compare or test insn that
9348 ;; generates reg 17.  Generate an equality comparison if `beq' or `bne'.
9349
9350 (define_expand "beq"
9351   [(set (pc)
9352         (if_then_else (match_dup 1)
9353                       (label_ref (match_operand 0 "" ""))
9354                       (pc)))]
9355   ""
9356   "ix86_expand_branch (EQ, operands[0]); DONE;")
9357
9358 (define_expand "bne"
9359   [(set (pc)
9360         (if_then_else (match_dup 1)
9361                       (label_ref (match_operand 0 "" ""))
9362                       (pc)))]
9363   ""
9364   "ix86_expand_branch (NE, operands[0]); DONE;")
9365
9366 (define_expand "bgt"
9367   [(set (pc)
9368         (if_then_else (match_dup 1)
9369                       (label_ref (match_operand 0 "" ""))
9370                       (pc)))]
9371   ""
9372   "ix86_expand_branch (GT, operands[0]); DONE;")
9373
9374 (define_expand "bgtu"
9375   [(set (pc)
9376         (if_then_else (match_dup 1)
9377                       (label_ref (match_operand 0 "" ""))
9378                       (pc)))]
9379   ""
9380   "ix86_expand_branch (GTU, operands[0]); DONE;")
9381
9382 (define_expand "blt"
9383   [(set (pc)
9384         (if_then_else (match_dup 1)
9385                       (label_ref (match_operand 0 "" ""))
9386                       (pc)))]
9387   ""
9388   "ix86_expand_branch (LT, operands[0]); DONE;")
9389
9390 (define_expand "bltu"
9391   [(set (pc)
9392         (if_then_else (match_dup 1)
9393                       (label_ref (match_operand 0 "" ""))
9394                       (pc)))]
9395   ""
9396   "ix86_expand_branch (LTU, operands[0]); DONE;")
9397
9398 (define_expand "bge"
9399   [(set (pc)
9400         (if_then_else (match_dup 1)
9401                       (label_ref (match_operand 0 "" ""))
9402                       (pc)))]
9403   ""
9404   "ix86_expand_branch (GE, operands[0]); DONE;")
9405
9406 (define_expand "bgeu"
9407   [(set (pc)
9408         (if_then_else (match_dup 1)
9409                       (label_ref (match_operand 0 "" ""))
9410                       (pc)))]
9411   ""
9412   "ix86_expand_branch (GEU, operands[0]); DONE;")
9413
9414 (define_expand "ble"
9415   [(set (pc)
9416         (if_then_else (match_dup 1)
9417                       (label_ref (match_operand 0 "" ""))
9418                       (pc)))]
9419   ""
9420   "ix86_expand_branch (LE, operands[0]); DONE;")
9421
9422 (define_expand "bleu"
9423   [(set (pc)
9424         (if_then_else (match_dup 1)
9425                       (label_ref (match_operand 0 "" ""))
9426                       (pc)))]
9427   ""
9428   "ix86_expand_branch (LEU, operands[0]); DONE;")
9429
9430 (define_expand "bunordered"
9431   [(set (pc)
9432         (if_then_else (match_dup 1)
9433                       (label_ref (match_operand 0 "" ""))
9434                       (pc)))]
9435   "TARGET_80387 || TARGET_SSE"
9436   "ix86_expand_branch (UNORDERED, operands[0]); DONE;")
9437
9438 (define_expand "bordered"
9439   [(set (pc)
9440         (if_then_else (match_dup 1)
9441                       (label_ref (match_operand 0 "" ""))
9442                       (pc)))]
9443   "TARGET_80387 || TARGET_SSE"
9444   "ix86_expand_branch (ORDERED, operands[0]); DONE;")
9445
9446 (define_expand "buneq"
9447   [(set (pc)
9448         (if_then_else (match_dup 1)
9449                       (label_ref (match_operand 0 "" ""))
9450                       (pc)))]
9451   "TARGET_80387 || TARGET_SSE"
9452   "ix86_expand_branch (UNEQ, operands[0]); DONE;")
9453
9454 (define_expand "bunge"
9455   [(set (pc)
9456         (if_then_else (match_dup 1)
9457                       (label_ref (match_operand 0 "" ""))
9458                       (pc)))]
9459   "TARGET_80387 || TARGET_SSE"
9460   "ix86_expand_branch (UNGE, operands[0]); DONE;")
9461
9462 (define_expand "bungt"
9463   [(set (pc)
9464         (if_then_else (match_dup 1)
9465                       (label_ref (match_operand 0 "" ""))
9466                       (pc)))]
9467   "TARGET_80387 || TARGET_SSE"
9468   "ix86_expand_branch (UNGT, operands[0]); DONE;")
9469
9470 (define_expand "bunle"
9471   [(set (pc)
9472         (if_then_else (match_dup 1)
9473                       (label_ref (match_operand 0 "" ""))
9474                       (pc)))]
9475   "TARGET_80387 || TARGET_SSE"
9476   "ix86_expand_branch (UNLE, operands[0]); DONE;")
9477
9478 (define_expand "bunlt"
9479   [(set (pc)
9480         (if_then_else (match_dup 1)
9481                       (label_ref (match_operand 0 "" ""))
9482                       (pc)))]
9483   "TARGET_80387 || TARGET_SSE"
9484   "ix86_expand_branch (UNLT, operands[0]); DONE;")
9485
9486 (define_expand "bltgt"
9487   [(set (pc)
9488         (if_then_else (match_dup 1)
9489                       (label_ref (match_operand 0 "" ""))
9490                       (pc)))]
9491   "TARGET_80387 || TARGET_SSE"
9492   "ix86_expand_branch (LTGT, operands[0]); DONE;")
9493
9494 (define_insn "*jcc_1"
9495   [(set (pc)
9496         (if_then_else (match_operator 1 "ix86_comparison_operator"
9497                                       [(reg 17) (const_int 0)])
9498                       (label_ref (match_operand 0 "" ""))
9499                       (pc)))]
9500   ""
9501   "j%C1\\t%l0"
9502   [(set_attr "type" "ibr")
9503    (set (attr "prefix_0f")
9504            (if_then_else (and (ge (minus (match_dup 0) (pc))
9505                                   (const_int -128))
9506                               (lt (minus (match_dup 0) (pc))
9507                                   (const_int 124)))
9508              (const_int 0)
9509              (const_int 1)))])
9510
9511 (define_insn "*jcc_2"
9512   [(set (pc)
9513         (if_then_else (match_operator 1 "ix86_comparison_operator"
9514                                       [(reg 17) (const_int 0)])
9515                       (pc)
9516                       (label_ref (match_operand 0 "" ""))))]
9517   ""
9518   "j%c1\\t%l0"
9519   [(set_attr "type" "ibr")
9520    (set (attr "prefix_0f")
9521            (if_then_else (and (ge (minus (match_dup 0) (pc))
9522                                   (const_int -128))
9523                               (lt (minus (match_dup 0) (pc))
9524                                   (const_int 124)))
9525              (const_int 0)
9526              (const_int 1)))])
9527
9528 ;; Define combination compare-and-branch fp compare instructions to use
9529 ;; during early optimization.  Splitting the operation apart early makes
9530 ;; for bad code when we want to reverse the operation.
9531
9532 (define_insn "*fp_jcc_1"
9533   [(set (pc)
9534         (if_then_else (match_operator 0 "comparison_operator"
9535                         [(match_operand 1 "register_operand" "f")
9536                          (match_operand 2 "register_operand" "f")])
9537           (label_ref (match_operand 3 "" ""))
9538           (pc)))
9539    (clobber (reg:CCFP 18))
9540    (clobber (reg:CCFP 17))]
9541   "TARGET_CMOVE && TARGET_80387
9542    && !SSE_FLOAT_MODE_P (GET_MODE (operands[1]))
9543    && FLOAT_MODE_P (GET_MODE (operands[1]))
9544    && GET_MODE (operands[1]) == GET_MODE (operands[2])"
9545   "#")
9546
9547 (define_insn "*fp_jcc_1_sse"
9548   [(set (pc)
9549         (if_then_else (match_operator 0 "comparison_operator"
9550                         [(match_operand 1 "register_operand" "f#x,x#f")
9551                          (match_operand 2 "nonimmediate_operand" "f#x,xm#f")])
9552           (label_ref (match_operand 3 "" ""))
9553           (pc)))
9554    (clobber (reg:CCFP 18))
9555    (clobber (reg:CCFP 17))]
9556   "TARGET_80387
9557    && SSE_FLOAT_MODE_P (GET_MODE (operands[1]))
9558    && GET_MODE (operands[1]) == GET_MODE (operands[2])"
9559   "#")
9560
9561 (define_insn "*fp_jcc_1_sse_only"
9562   [(set (pc)
9563         (if_then_else (match_operator 0 "comparison_operator"
9564                         [(match_operand 1 "register_operand" "x")
9565                          (match_operand 2 "nonimmediate_operand" "xm")])
9566           (label_ref (match_operand 3 "" ""))
9567           (pc)))
9568    (clobber (reg:CCFP 18))
9569    (clobber (reg:CCFP 17))]
9570   "SSE_FLOAT_MODE_P (GET_MODE (operands[1]))
9571    && GET_MODE (operands[1]) == GET_MODE (operands[2])"
9572   "#")
9573
9574 (define_insn "*fp_jcc_2"
9575   [(set (pc)
9576         (if_then_else (match_operator 0 "comparison_operator"
9577                         [(match_operand 1 "register_operand" "f")
9578                          (match_operand 2 "register_operand" "f")])
9579           (pc)
9580           (label_ref (match_operand 3 "" ""))))
9581    (clobber (reg:CCFP 18))
9582    (clobber (reg:CCFP 17))]
9583   "TARGET_CMOVE && TARGET_80387
9584    && !SSE_FLOAT_MODE_P (GET_MODE (operands[1]))
9585    && FLOAT_MODE_P (GET_MODE (operands[1]))
9586    && GET_MODE (operands[1]) == GET_MODE (operands[2])"
9587   "#")
9588
9589 (define_insn "*fp_jcc_2_sse"
9590   [(set (pc)
9591         (if_then_else (match_operator 0 "comparison_operator"
9592                         [(match_operand 1 "register_operand" "f#x,x#f")
9593                          (match_operand 2 "nonimmediate_operand" "f#x,xm#f")])
9594           (pc)
9595           (label_ref (match_operand 3 "" ""))))
9596    (clobber (reg:CCFP 18))
9597    (clobber (reg:CCFP 17))]
9598   "TARGET_80387
9599    && SSE_FLOAT_MODE_P (GET_MODE (operands[1]))
9600    && GET_MODE (operands[1]) == GET_MODE (operands[2])"
9601   "#")
9602
9603 (define_insn "*fp_jcc_2_sse_only"
9604   [(set (pc)
9605         (if_then_else (match_operator 0 "comparison_operator"
9606                         [(match_operand 1 "register_operand" "x")
9607                          (match_operand 2 "nonimmediate_operand" "xm")])
9608           (pc)
9609           (label_ref (match_operand 3 "" ""))))
9610    (clobber (reg:CCFP 18))
9611    (clobber (reg:CCFP 17))]
9612   "SSE_FLOAT_MODE_P (GET_MODE (operands[1]))
9613    && GET_MODE (operands[1]) == GET_MODE (operands[2])"
9614   "#")
9615
9616 (define_insn "*fp_jcc_3"
9617   [(set (pc)
9618         (if_then_else (match_operator 0 "comparison_operator"
9619                         [(match_operand 1 "register_operand" "f")
9620                          (match_operand 2 "nonimmediate_operand" "fm")])
9621           (label_ref (match_operand 3 "" ""))
9622           (pc)))
9623    (clobber (reg:CCFP 18))
9624    (clobber (reg:CCFP 17))
9625    (clobber (match_scratch:HI 4 "=a"))]
9626   "TARGET_80387
9627    && (GET_MODE (operands[1]) == SFmode || GET_MODE (operands[1]) == DFmode)
9628    && GET_MODE (operands[1]) == GET_MODE (operands[2])
9629    && !ix86_use_fcomi_compare (GET_CODE (operands[0]))
9630    && SELECT_CC_MODE (GET_CODE (operands[0]),
9631                       operands[1], operands[2]) == CCFPmode"
9632   "#")
9633
9634 (define_insn "*fp_jcc_4"
9635   [(set (pc)
9636         (if_then_else (match_operator 0 "comparison_operator"
9637                         [(match_operand 1 "register_operand" "f")
9638                          (match_operand 2 "nonimmediate_operand" "fm")])
9639           (pc)
9640           (label_ref (match_operand 3 "" ""))))
9641    (clobber (reg:CCFP 18))
9642    (clobber (reg:CCFP 17))
9643    (clobber (match_scratch:HI 4 "=a"))]
9644   "TARGET_80387
9645    && (GET_MODE (operands[1]) == SFmode || GET_MODE (operands[1]) == DFmode)
9646    && GET_MODE (operands[1]) == GET_MODE (operands[2])
9647    && !ix86_use_fcomi_compare (GET_CODE (operands[0]))
9648    && SELECT_CC_MODE (GET_CODE (operands[0]),
9649                       operands[1], operands[2]) == CCFPmode"
9650   "#")
9651
9652 (define_insn "*fp_jcc_5"
9653   [(set (pc)
9654         (if_then_else (match_operator 0 "comparison_operator"
9655                         [(match_operand 1 "register_operand" "f")
9656                          (match_operand 2 "register_operand" "f")])
9657           (label_ref (match_operand 3 "" ""))
9658           (pc)))
9659    (clobber (reg:CCFP 18))
9660    (clobber (reg:CCFP 17))
9661    (clobber (match_scratch:HI 4 "=a"))]
9662   "TARGET_80387
9663    && FLOAT_MODE_P (GET_MODE (operands[1]))
9664    && GET_MODE (operands[1]) == GET_MODE (operands[2])"
9665   "#")
9666
9667 (define_insn "*fp_jcc_6"
9668   [(set (pc)
9669         (if_then_else (match_operator 0 "comparison_operator"
9670                         [(match_operand 1 "register_operand" "f")
9671                          (match_operand 2 "register_operand" "f")])
9672           (pc)
9673           (label_ref (match_operand 3 "" ""))))
9674    (clobber (reg:CCFP 18))
9675    (clobber (reg:CCFP 17))
9676    (clobber (match_scratch:HI 4 "=a"))]
9677   "TARGET_80387
9678    && FLOAT_MODE_P (GET_MODE (operands[1]))
9679    && GET_MODE (operands[1]) == GET_MODE (operands[2])"
9680   "#")
9681
9682 (define_split
9683   [(set (pc)
9684         (if_then_else (match_operator 0 "comparison_operator"
9685                         [(match_operand 1 "register_operand" "")
9686                          (match_operand 2 "nonimmediate_operand" "")])
9687           (match_operand 3 "" "")
9688           (match_operand 4 "" "")))
9689    (clobber (reg:CCFP 18))
9690    (clobber (reg:CCFP 17))]
9691   "reload_completed"
9692   [(const_int 0)]
9693   "
9694 {
9695   ix86_split_fp_branch (operands[0], operands[1], operands[2],
9696                         operands[3], operands[4], NULL_RTX);
9697   DONE;
9698 }")
9699
9700 (define_split
9701   [(set (pc)
9702         (if_then_else (match_operator 0 "comparison_operator"
9703                         [(match_operand 1 "register_operand" "")
9704                          (match_operand 2 "nonimmediate_operand" "")])
9705           (match_operand 3 "" "")
9706           (match_operand 4 "" "")))
9707    (clobber (reg:CCFP 18))
9708    (clobber (reg:CCFP 17))
9709    (clobber (match_scratch:HI 5 "=a"))]
9710   "reload_completed"
9711   [(set (pc)
9712         (if_then_else (match_dup 6)
9713           (match_dup 3)
9714           (match_dup 4)))]
9715   "
9716 {
9717   ix86_split_fp_branch (operands[0], operands[1], operands[2],
9718                         operands[3], operands[4], operands[5]);
9719   DONE;
9720 }")
9721 \f
9722 ;; Unconditional and other jump instructions
9723
9724 (define_insn "jump"
9725   [(set (pc)
9726         (label_ref (match_operand 0 "" "")))]
9727   ""
9728   "jmp\\t%l0"
9729   [(set_attr "type" "ibr")])
9730
9731 (define_insn "indirect_jump"
9732   [(set (pc) (match_operand:SI 0 "nonimmediate_operand" "rm"))]
9733   ""
9734   "jmp\\t%A0"
9735   [(set_attr "type" "ibr")
9736    (set_attr "length_immediate" "0")])
9737
9738 (define_insn "tablejump"
9739   [(set (pc) (match_operand:SI 0 "nonimmediate_operand" "rm"))
9740    (use (label_ref (match_operand 1 "" "")))]
9741   "! flag_pic"
9742   "jmp\\t%A0"
9743   [(set_attr "type" "ibr")
9744    (set_attr "length_immediate" "0")])
9745
9746 ;; Implement switch statements when generating PIC code.  Switches are
9747 ;; implemented by `tablejump' when not using -fpic.
9748 ;;
9749 ;; Emit code here to do the range checking and make the index zero based.
9750 ;;
9751 ;; Each entry in the "addr_diff_vec" looks like this as the result of the
9752 ;; two rules below:
9753 ;; 
9754 ;;      .long _GLOBAL_OFFSET_TABLE_+[.-.L2]
9755 ;; 
9756 ;; 1. An expression involving an external reference may only use the
9757 ;;    addition operator, and only with an assembly-time constant.
9758 ;;    The example above satisfies this because ".-.L2" is a constant.
9759 ;; 
9760 ;; 2. The symbol _GLOBAL_OFFSET_TABLE_ is magic, and at link time is
9761 ;;    given the value of "GOT - .", where GOT is the actual address of
9762 ;;    the Global Offset Table.  Therefore, the .long above actually
9763 ;;    stores the value "( GOT - . ) + [ . - .L2 ]", or "GOT - .L2".  The
9764 ;;    expression "GOT - .L2" by itself would generate an error from as(1).
9765 ;; 
9766 ;; The pattern below emits code that looks like this:
9767 ;; 
9768 ;;      movl %ebx,reg
9769 ;;      subl TABLE@GOTOFF(%ebx,index,4),reg
9770 ;;      jmp reg
9771 ;; 
9772 ;; The addr_diff_vec contents may be directly referenced with @GOTOFF, since
9773 ;; the addr_diff_vec is known to be part of this module.
9774 ;; 
9775 ;; The subl above calculates "GOT - (( GOT - . ) + [ . - .L2 ])", which
9776 ;; evaluates to just ".L2".
9777
9778 (define_expand "casesi"
9779   [(set (match_dup 5)
9780         (match_operand:SI 0 "general_operand" ""))
9781    (parallel [(set (match_dup 6)
9782                    (minus:SI (match_dup 5)
9783                              (match_operand:SI 1 "general_operand" "")))
9784               (clobber (reg:CC 17))])
9785    (set (reg:CC 17)
9786         (compare:CC (match_dup 6)
9787                     (match_operand:SI 2 "general_operand" "")))
9788    (set (pc)
9789         (if_then_else (gtu (reg:CC 17)
9790                            (const_int 0))
9791                       (label_ref (match_operand 4 "" ""))
9792                       (pc)))
9793    (parallel
9794      [(set (match_dup 7)
9795            (minus:SI (match_dup 8)
9796              (mem:SI (plus:SI (plus:SI (mult:SI (match_dup 6) (const_int 4))
9797                               (match_dup 8))
9798                      (const (unspec [(label_ref (match_operand 3 "" ""))] 7))))))
9799       (clobber (reg:CC 17))])
9800    (parallel [(set (pc) (match_dup 7))
9801               (use (label_ref (match_dup 3)))])]
9802   "flag_pic"
9803   "
9804 {
9805   operands[5] = gen_reg_rtx (SImode);
9806   operands[6] = gen_reg_rtx (SImode);
9807   operands[7] = gen_reg_rtx (SImode);
9808   operands[8] = pic_offset_table_rtx;
9809   current_function_uses_pic_offset_table = 1;
9810 }")
9811
9812 (define_insn "*tablejump_pic"
9813   [(set (pc) (match_operand:SI 0 "nonimmediate_operand" "rm"))
9814    (use (label_ref (match_operand 1 "" "")))]
9815   ""
9816   "jmp\\t%A0"
9817   [(set_attr "type" "ibr")
9818    (set_attr "length_immediate" "0")])
9819 \f
9820 ;; Loop instruction
9821 ;;
9822 ;; This is all complicated by the fact that since this is a jump insn
9823 ;; we must handle our own reloads.
9824
9825 (define_expand "doloop_end"
9826   [(use (match_operand 0 "" ""))        ; loop pseudo
9827    (use (match_operand 1 "" ""))        ; iterations; zero if unknown
9828    (use (match_operand 2 "" ""))        ; max iterations
9829    (use (match_operand 3 "" ""))        ; loop level 
9830    (use (match_operand 4 "" ""))]       ; label
9831   "TARGET_USE_LOOP"
9832   "                                 
9833 {
9834   /* Only use cloop on innermost loops.  */
9835   if (INTVAL (operands[3]) > 1)
9836     FAIL;
9837   if (GET_MODE (operands[0]) != SImode)
9838     FAIL;
9839   emit_jump_insn (gen_doloop_end_internal (operands[4], operands[0],
9840                                            operands[0]));
9841   DONE;
9842 }")
9843
9844 (define_insn "doloop_end_internal"
9845   [(set (pc)
9846         (if_then_else (ne (match_operand:SI 1 "register_operand" "c,?*r,?*r")
9847                           (const_int 1))
9848                       (label_ref (match_operand 0 "" ""))
9849                       (pc)))
9850    (set (match_operand:SI 2 "register_operand" "=1,1,*m*r")
9851         (plus:SI (match_dup 1)
9852                  (const_int -1)))
9853    (clobber (match_scratch:SI 3 "=X,X,r"))
9854    (clobber (reg:CC 17))]
9855   "TARGET_USE_LOOP"
9856   "*
9857 {
9858   if (which_alternative != 0)
9859     return \"#\";
9860   if (get_attr_length (insn) == 2)
9861     return \"loop\\t%l0\";
9862   else
9863     return \"dec{l}\\t%1\;jne\\t%l0\";
9864 }"
9865   [(set_attr "ppro_uops" "many")
9866    (set (attr "type")
9867         (if_then_else (and (eq_attr "alternative" "0")
9868                            (and (ge (minus (match_dup 0) (pc))
9869                                     (const_int -128))
9870                                 (lt (minus (match_dup 0) (pc))
9871                                     (const_int 124))))
9872                       (const_string "ibr")
9873                       (const_string "multi")))])
9874
9875 (define_split
9876   [(set (pc)
9877         (if_then_else (ne (match_operand:SI 1 "register_operand" "")
9878                           (const_int 1))
9879                       (match_operand 0 "" "")
9880                       (pc)))
9881    (set (match_dup 1)
9882         (plus:SI (match_dup 1)
9883                  (const_int -1)))
9884    (clobber (match_scratch:SI 2 ""))
9885    (clobber (reg:CC 17))]
9886   "TARGET_USE_LOOP
9887    && reload_completed
9888    && REGNO (operands[1]) != 2"
9889   [(parallel [(set (reg:CCZ 17)
9890                    (compare:CCZ (plus:SI (match_dup 1) (const_int -1))
9891                                  (const_int 0)))
9892               (set (match_dup 1) (plus:SI (match_dup 1) (const_int -1)))])
9893    (set (pc) (if_then_else (ne (reg:CCZ 17) (const_int 0))
9894                            (match_dup 0)
9895                            (pc)))]
9896   "")
9897   
9898 (define_split
9899   [(set (pc)
9900         (if_then_else (ne (match_operand:SI 1 "register_operand" "")
9901                           (const_int 1))
9902                       (match_operand 0 "" "")
9903                       (pc)))
9904    (set (match_operand:SI 2 "nonimmediate_operand" "")
9905         (plus:SI (match_dup 1)
9906                  (const_int -1)))
9907    (clobber (match_scratch:SI 3 ""))
9908    (clobber (reg:CC 17))]
9909   "TARGET_USE_LOOP
9910    && reload_completed
9911    && (! REG_P (operands[2])
9912        || ! rtx_equal_p (operands[1], operands[2]))"
9913   [(set (match_dup 3) (match_dup 1))
9914    (parallel [(set (reg:CCZ 17)
9915                    (compare:CCZ (plus:SI (match_dup 3) (const_int -1))
9916                                 (const_int 0)))
9917               (set (match_dup 3) (plus:SI (match_dup 3) (const_int -1)))])
9918    (set (match_dup 2) (match_dup 3))
9919    (set (pc) (if_then_else (ne (reg:CCZ 17) (const_int 0))
9920                            (match_dup 0)
9921                            (pc)))]
9922   "")
9923 \f
9924 ;; Call instructions.
9925
9926 ;; The predicates normally associated with named expanders are not properly
9927 ;; checked for calls.  This is a bug in the generic code, but it isn't that
9928 ;; easy to fix.  Ignore it for now and be prepared to fix things up.
9929
9930 ;; Call subroutine returning no value.
9931
9932 (define_expand "call_pop"
9933   [(parallel [(call (match_operand:QI 0 "" "")
9934                     (match_operand:SI 1 "" ""))
9935               (set (reg:SI 7)
9936                    (plus:SI (reg:SI 7)
9937                             (match_operand:SI 3 "" "")))])]
9938   ""
9939   "
9940 {
9941   if (operands[3] == const0_rtx)
9942     {
9943       emit_insn (gen_call (operands[0], operands[1]));
9944       DONE;
9945     }
9946   /* Static functions and indirect calls don't need
9947      current_function_uses_pic_offset_table.  */
9948   if (flag_pic
9949       && GET_CODE (XEXP (operands[0], 0)) == SYMBOL_REF
9950       && ! SYMBOL_REF_FLAG (XEXP (operands[0], 0)))
9951     current_function_uses_pic_offset_table = 1;
9952   if (! call_insn_operand (XEXP (operands[0], 0), Pmode))
9953     XEXP (operands[0], 0) = copy_to_mode_reg (Pmode, XEXP (operands[0], 0));
9954 }")
9955
9956 (define_insn "*call_pop_0"
9957   [(call (mem:QI (match_operand:SI 0 "constant_call_address_operand" ""))
9958          (match_operand:SI 1 "" ""))
9959    (set (reg:SI 7) (plus:SI (reg:SI 7)
9960                             (match_operand:SI 2 "immediate_operand" "")))]
9961   ""
9962   "*
9963 {
9964   if (SIBLING_CALL_P (insn))
9965     return \"jmp\\t%P0\";
9966   else
9967     return \"call\\t%P0\";
9968 }"
9969   [(set_attr "type" "call")])
9970   
9971 (define_insn "*call_pop_1"
9972   [(call (mem:QI (match_operand:SI 0 "call_insn_operand" "rsm"))
9973          (match_operand:SI 1 "" ""))
9974    (set (reg:SI 7) (plus:SI (reg:SI 7)
9975                             (match_operand:SI 2 "immediate_operand" "i")))]
9976   ""
9977   "*
9978 {
9979   if (constant_call_address_operand (operands[0], Pmode))
9980     {
9981       if (SIBLING_CALL_P (insn))
9982         return \"jmp\\t%P0\";
9983       else
9984         return \"call\\t%P0\";
9985     }
9986   if (SIBLING_CALL_P (insn))
9987     return \"jmp\\t%A0\";
9988   else
9989     return \"call\\t%A0\";
9990 }"
9991   [(set_attr "type" "call")])
9992
9993 (define_expand "call"
9994   [(call (match_operand:QI 0 "" "")
9995          (match_operand:SI 1 "" ""))]
9996   ;; Operand 1 not used on the i386.
9997   ""
9998   "
9999 {
10000   /* Static functions and indirect calls don't need
10001      current_function_uses_pic_offset_table.  */
10002   if (flag_pic
10003       && GET_CODE (XEXP (operands[0], 0)) == SYMBOL_REF
10004       && ! SYMBOL_REF_FLAG (XEXP (operands[0], 0)))
10005     current_function_uses_pic_offset_table = 1;
10006   if (! call_insn_operand (XEXP (operands[0], 0), Pmode))
10007     XEXP (operands[0], 0) = copy_to_mode_reg (Pmode, XEXP (operands[0], 0));
10008 }")
10009
10010 (define_insn "*call_0"
10011   [(call (mem:QI (match_operand:SI 0 "constant_call_address_operand" ""))
10012          (match_operand:SI 1 "" ""))]
10013   ""
10014   "*
10015 {
10016   if (SIBLING_CALL_P (insn))
10017     return \"jmp\\t%P0\";
10018   else
10019     return \"call\\t%P0\";
10020 }"
10021   [(set_attr "type" "call")])
10022
10023 (define_insn "*call_1"
10024   [(call (mem:QI (match_operand:SI 0 "call_insn_operand" "rsm"))
10025          (match_operand:SI 1 "" ""))]
10026   ""
10027   "*
10028 {
10029   if (constant_call_address_operand (operands[0], QImode))
10030     {
10031       if (SIBLING_CALL_P (insn))
10032         return \"jmp\\t%P0\";
10033       else
10034         return \"call\\t%P0\";
10035     }
10036   if (SIBLING_CALL_P (insn))
10037     return \"jmp\\t%A0\";
10038   else
10039     return \"call\\t%A0\";
10040 }"
10041   [(set_attr "type" "call")])
10042
10043 ;; Call subroutine, returning value in operand 0
10044 ;; (which must be a hard register).
10045
10046 (define_expand "call_value_pop"
10047   [(parallel [(set (match_operand 0 "" "")
10048                    (call (match_operand:QI 1 "" "")
10049                          (match_operand:SI 2 "" "")))
10050               (set (reg:SI 7)
10051                    (plus:SI (reg:SI 7)
10052                             (match_operand:SI 4 "" "")))])]
10053   ""
10054   "
10055 {
10056   if (operands[4] == const0_rtx)
10057     {
10058       emit_insn (gen_call_value (operands[0], operands[1], operands[2]));
10059       DONE;
10060     }
10061   /* Static functions and indirect calls don't need
10062      current_function_uses_pic_offset_table.  */
10063   if (flag_pic
10064       && GET_CODE (XEXP (operands[1], 0)) == SYMBOL_REF
10065       && ! SYMBOL_REF_FLAG (XEXP (operands[1], 0)))
10066     current_function_uses_pic_offset_table = 1;
10067   if (! call_insn_operand (XEXP (operands[1], 0), Pmode))
10068     XEXP (operands[1], 0) = copy_to_mode_reg (Pmode, XEXP (operands[1], 0));
10069 }")
10070
10071 (define_expand "call_value"
10072   [(set (match_operand 0 "" "")
10073         (call (match_operand:QI 1 "" "")
10074               (match_operand:SI 2 "" "")))]
10075   ;; Operand 2 not used on the i386.
10076   ""
10077   "
10078 {
10079   /* Static functions and indirect calls don't need
10080      current_function_uses_pic_offset_table.  */
10081   if (flag_pic
10082       && GET_CODE (XEXP (operands[1], 0)) == SYMBOL_REF
10083       && ! SYMBOL_REF_FLAG (XEXP (operands[1], 0)))
10084     current_function_uses_pic_offset_table = 1;
10085   if (! call_insn_operand (XEXP (operands[1], 0), Pmode))
10086     XEXP (operands[1], 0) = copy_to_mode_reg (Pmode, XEXP (operands[1], 0));
10087 }")
10088
10089 ;; Call subroutine returning any type.
10090
10091 (define_expand "untyped_call"
10092   [(parallel [(call (match_operand 0 "" "")
10093                     (const_int 0))
10094               (match_operand 1 "" "")
10095               (match_operand 2 "" "")])]
10096   ""
10097   "
10098 {
10099   int i;
10100
10101   /* In order to give reg-stack an easier job in validating two
10102      coprocessor registers as containing a possible return value,
10103      simply pretend the untyped call returns a complex long double
10104      value.  */
10105
10106   emit_call_insn (TARGET_80387
10107                   ? gen_call_value (gen_rtx_REG (XCmode, FIRST_FLOAT_REG),
10108                                     operands[0], const0_rtx)
10109                   : gen_call (operands[0], const0_rtx));
10110
10111   for (i = 0; i < XVECLEN (operands[2], 0); i++)
10112     {
10113       rtx set = XVECEXP (operands[2], 0, i);
10114       emit_move_insn (SET_DEST (set), SET_SRC (set));
10115     }
10116
10117   /* The optimizer does not know that the call sets the function value
10118      registers we stored in the result block.  We avoid problems by
10119      claiming that all hard registers are used and clobbered at this
10120      point.  */
10121   emit_insn (gen_blockage ());
10122
10123   DONE;
10124 }")
10125 \f
10126 ;; Prologue and epilogue instructions
10127
10128 ;; UNSPEC_VOLATILE is considered to use and clobber all hard registers and
10129 ;; all of memory.  This blocks insns from being moved across this point.
10130
10131 (define_insn "blockage"
10132   [(unspec_volatile [(const_int 0)] 0)]
10133   ""
10134   ""
10135   [(set_attr "length" "0")])
10136
10137 ;; Insn emitted into the body of a function to return from a function.
10138 ;; This is only done if the function's epilogue is known to be simple.
10139 ;; See comments for ix86_can_use_return_insn_p in i386.c.
10140
10141 (define_expand "return"
10142   [(return)]
10143   "ix86_can_use_return_insn_p ()"
10144   "
10145 {
10146   if (current_function_pops_args)
10147     {
10148       rtx popc = GEN_INT (current_function_pops_args);
10149       emit_jump_insn (gen_return_pop_internal (popc));
10150       DONE;
10151     }
10152 }")
10153
10154 (define_insn "return_internal"
10155   [(return)]
10156   "reload_completed"
10157   "ret"
10158   [(set_attr "length" "1")
10159    (set_attr "length_immediate" "0")
10160    (set_attr "modrm" "0")])
10161
10162 (define_insn "return_pop_internal"
10163   [(return)
10164    (use (match_operand:SI 0 "const_int_operand" ""))]
10165   "reload_completed"
10166   "ret\\t%0"
10167   [(set_attr "length" "3")
10168    (set_attr "length_immediate" "2")
10169    (set_attr "modrm" "0")])
10170
10171 (define_insn "return_indirect_internal"
10172   [(return)
10173    (use (match_operand:SI 0 "register_operand" "r"))]
10174   "reload_completed"
10175   "jmp\\t%A0"
10176   [(set_attr "type" "ibr")
10177    (set_attr "length_immediate" "0")])
10178
10179 (define_insn "nop"
10180   [(const_int 0)]
10181   ""
10182   "nop"
10183   [(set_attr "length" "1")
10184    (set_attr "length_immediate" "0")
10185    (set_attr "modrm" "0")
10186    (set_attr "ppro_uops" "one")])
10187
10188 (define_expand "prologue"
10189   [(const_int 1)]
10190   ""
10191   "ix86_expand_prologue (); DONE;")
10192
10193 (define_insn "prologue_set_got"
10194   [(set (match_operand:SI 0 "register_operand" "=r")
10195         (unspec_volatile:SI
10196          [(plus:SI (match_dup 0)
10197                    (plus:SI (match_operand:SI 1 "symbolic_operand" "")
10198                             (minus:SI (pc) (match_operand 2 "" ""))))] 1))
10199    (clobber (reg:CC 17))]
10200   ""
10201   "*
10202 {
10203   if (GET_CODE (operands[2]) == LABEL_REF)
10204      operands[2] = XEXP (operands[2], 0);
10205   if (TARGET_DEEP_BRANCH_PREDICTION) 
10206     return \"add{l}\\t{%1, %0|%0, %1}\";
10207   else  
10208     return \"add{l}\\t{%1+[.-%X2], %0|%0, %a1+(.-%X2)}\";
10209 }"
10210   [(set_attr "type" "alu")
10211    ; Since this insn may have two constant operands, we must set the
10212    ; length manually.
10213    (set_attr "length_immediate" "4")
10214    (set_attr "mode" "SI")])
10215
10216 (define_insn "prologue_get_pc"
10217   [(set (match_operand:SI 0 "register_operand" "=r")
10218     (unspec_volatile:SI [(plus:SI (pc) (match_operand 1 "" ""))] 2))]
10219   ""
10220   "*
10221 {
10222   if (GET_CODE (operands[1]) == LABEL_REF)
10223     operands[1] = XEXP (operands[1], 0);
10224   output_asm_insn (\"call\\t%X1\", operands);
10225   if (! TARGET_DEEP_BRANCH_PREDICTION)
10226     {
10227       ASM_OUTPUT_INTERNAL_LABEL (asm_out_file, \"L\",
10228                                  CODE_LABEL_NUMBER (operands[1]));
10229     }
10230   RET;
10231 }"
10232   [(set_attr "type" "multi")])
10233
10234 (define_expand "epilogue"
10235   [(const_int 1)]
10236   ""
10237   "ix86_expand_epilogue (1); DONE;")
10238
10239 (define_expand "sibcall_epilogue"
10240   [(const_int 1)]
10241   ""
10242   "ix86_expand_epilogue (0); DONE;")
10243
10244 (define_insn "leave"
10245   [(set (reg:SI 7) (reg:SI 6))
10246    (set (reg:SI 6) (mem:SI (pre_dec:SI (reg:SI 7))))]
10247   ""
10248   "leave"
10249   [(set_attr "length_immediate" "0")
10250    (set_attr "length" "1")
10251    (set_attr "modrm" "0")
10252    (set_attr "modrm" "0")
10253    (set_attr "athlon_decode" "vector")
10254    (set_attr "ppro_uops" "few")])
10255 \f
10256 (define_expand "ffssi2"
10257   [(set (match_operand:SI 0 "nonimmediate_operand" "") 
10258         (ffs:SI (match_operand:SI 1 "general_operand" "")))]
10259   ""
10260   "
10261 {
10262   rtx out = gen_reg_rtx (SImode), tmp = gen_reg_rtx (SImode);
10263   rtx in = operands[1];
10264
10265   if (TARGET_CMOVE)
10266     {
10267       emit_move_insn (tmp, constm1_rtx);
10268       emit_insn (gen_ffssi_1 (out, in));
10269       emit_insn (gen_rtx_SET (VOIDmode, out,
10270                   gen_rtx_IF_THEN_ELSE (SImode, 
10271                     gen_rtx_EQ (VOIDmode, gen_rtx_REG (CCZmode, FLAGS_REG),
10272                                 const0_rtx),
10273                     tmp,
10274                     out)));
10275       emit_insn (gen_addsi3 (out, out, const1_rtx));
10276       emit_move_insn (operands[0], out);
10277     }
10278
10279   /* Pentium bsf instruction is extremly slow.  The following code is
10280      recommended by the Intel Optimizing Manual as a reasonable replacement:
10281            TEST    EAX,EAX
10282            JZ      SHORT BS2
10283            XOR     ECX,ECX
10284            MOV     DWORD PTR [TEMP+4],ECX
10285            SUB     ECX,EAX
10286            AND     EAX,ECX
10287            MOV     DWORD PTR [TEMP],EAX
10288            FILD    QWORD PTR [TEMP]
10289            FSTP    QWORD PTR [TEMP]
10290            WAIT    ; WAIT only needed for compatibility with
10291                    ; earlier processors
10292            MOV     ECX, DWORD PTR [TEMP+4]
10293            SHR     ECX,20
10294            SUB     ECX,3FFH
10295            TEST    EAX,EAX       ; clear zero flag
10296        BS2:
10297      Following piece of code expand ffs to similar beast.
10298        */
10299
10300   else if (TARGET_PENTIUM && !optimize_size && TARGET_80387)
10301     {
10302       rtx label = gen_label_rtx ();
10303       rtx lo, hi;
10304       rtx mem = assign_386_stack_local (DImode, 0);
10305       rtx fptmp = gen_reg_rtx (DFmode);
10306       split_di (&mem, 1, &lo, &hi);
10307
10308       emit_move_insn (out, const0_rtx);
10309
10310       emit_cmp_and_jump_insns (in, const0_rtx, EQ, 0, SImode, 1, 0, label);
10311
10312       emit_move_insn (hi, out);
10313       emit_insn (gen_subsi3 (out, out, in));
10314       emit_insn (gen_andsi3 (out, out, in));
10315       emit_move_insn (lo, out);
10316       emit_insn (gen_floatdidf2 (fptmp,mem));
10317       emit_move_insn (gen_rtx_MEM (DFmode, XEXP (mem, 0)), fptmp);
10318       emit_move_insn (out, hi);
10319       emit_insn (gen_lshrsi3 (out, out, GEN_INT (20)));
10320       emit_insn (gen_subsi3 (out, out, GEN_INT (0x3ff - 1)));
10321
10322       emit_label (label);
10323       LABEL_NUSES (label) = 1;
10324
10325       emit_move_insn (operands[0], out);
10326     }
10327   else
10328     {
10329       emit_move_insn (tmp, const0_rtx);
10330       emit_insn (gen_ffssi_1 (out, in));
10331       emit_insn (gen_rtx_SET (VOIDmode, 
10332                   gen_rtx_STRICT_LOW_PART (VOIDmode, gen_lowpart (QImode, tmp)),
10333                   gen_rtx_EQ (QImode, gen_rtx_REG (CCZmode, FLAGS_REG),
10334                               const0_rtx)));
10335       emit_insn (gen_negsi2 (tmp, tmp));
10336       emit_insn (gen_iorsi3 (out, out, tmp));
10337       emit_insn (gen_addsi3 (out, out, const1_rtx));
10338       emit_move_insn (operands[0], out);
10339     }
10340   DONE;  
10341 }")
10342
10343 (define_insn "ffssi_1"
10344   [(set (reg:CCZ 17)
10345         (compare:CCZ (match_operand:SI 1 "nonimmediate_operand" "rm")
10346                      (const_int 0)))
10347    (set (match_operand:SI 0 "register_operand" "=r")
10348         (unspec:SI [(match_dup 1)] 5))]
10349   ""
10350   "bsf{l}\\t{%1, %0|%0, %1}"
10351   [(set_attr "prefix_0f" "1")
10352    (set_attr "ppro_uops" "few")])
10353
10354 ;; ffshi2 is not useful -- 4 word prefix ops are needed, which is larger
10355 ;; and slower than the two-byte movzx insn needed to do the work in SImode.
10356 \f
10357 ;; These patterns match the binary 387 instructions for addM3, subM3,
10358 ;; mulM3 and divM3.  There are three patterns for each of DFmode and
10359 ;; SFmode.  The first is the normal insn, the second the same insn but
10360 ;; with one operand a conversion, and the third the same insn but with
10361 ;; the other operand a conversion.  The conversion may be SFmode or
10362 ;; SImode if the target mode DFmode, but only SImode if the target mode
10363 ;; is SFmode.
10364
10365 ;; Gcc is slightly more smart about handling normal two address instructions
10366 ;; so use special patterns for add and mull.
10367 (define_insn "*fop_sf_comm"
10368   [(set (match_operand:SF 0 "register_operand" "=f#x,x#f")
10369         (match_operator:SF 3 "binary_fp_operator"
10370                         [(match_operand:SF 1 "register_operand" "%0,0")
10371                          (match_operand:SF 2 "nonimmediate_operand" "fm#x,xm#f")]))]
10372   "TARGET_80387 && (!TARGET_SSE || TARGET_MIX_SSE_I387)
10373    && GET_RTX_CLASS (GET_CODE (operands[3])) == 'c'"
10374   "* return output_387_binary_op (insn, operands);"
10375   [(set (attr "type") 
10376         (if_then_else (eq_attr "alternative" "1")
10377            (const_string "sse")
10378            (if_then_else (match_operand:SF 3 "mult_operator" "") 
10379               (const_string "fmul")
10380               (const_string "fop"))))
10381    (set_attr "mode" "SF")])
10382
10383 (define_insn "*fop_sf_comm_sse"
10384   [(set (match_operand:SF 0 "register_operand" "=x")
10385         (match_operator:SF 3 "binary_fp_operator"
10386                         [(match_operand:SF 1 "register_operand" "%0")
10387                          (match_operand:SF 2 "nonimmediate_operand" "xm")]))]
10388   "TARGET_SSE && GET_RTX_CLASS (GET_CODE (operands[3])) == 'c'"
10389   "* return output_387_binary_op (insn, operands);"
10390   [(set_attr "type" "sse")
10391    (set_attr "mode" "SF")])
10392
10393 (define_insn "*fop_df_comm"
10394   [(set (match_operand:DF 0 "register_operand" "=f#Y,Y#f")
10395         (match_operator:DF 3 "binary_fp_operator"
10396                         [(match_operand:DF 1 "register_operand" "%0,0")
10397                          (match_operand:DF 2 "nonimmediate_operand" "fm#Y,Ym#f")]))]
10398   "TARGET_80387 && (!TARGET_SSE2 || TARGET_MIX_SSE_I387)
10399    && GET_RTX_CLASS (GET_CODE (operands[3])) == 'c'"
10400   "* return output_387_binary_op (insn, operands);"
10401   [(set (attr "type") 
10402         (if_then_else (eq_attr "alternative" "1")
10403            (const_string "sse")
10404            (if_then_else (match_operand:SF 3 "mult_operator" "") 
10405               (const_string "fmul")
10406               (const_string "fop"))))
10407    (set_attr "mode" "DF")])
10408
10409 (define_insn "*fop_df_comm_sse"
10410   [(set (match_operand:DF 0 "register_operand" "=Y")
10411         (match_operator:DF 3 "binary_fp_operator"
10412                         [(match_operand:DF 1 "register_operand" "%0")
10413                          (match_operand:DF 2 "nonimmediate_operand" "Ym")]))]
10414   "TARGET_SSE2
10415    && GET_RTX_CLASS (GET_CODE (operands[3])) == 'c'"
10416   "* return output_387_binary_op (insn, operands);"
10417   [(set_attr "type" "sse")
10418    (set_attr "mode" "DF")])
10419
10420 (define_insn "*fop_xf_comm"
10421   [(set (match_operand:XF 0 "register_operand" "=f")
10422         (match_operator:XF 3 "binary_fp_operator"
10423                         [(match_operand:XF 1 "register_operand" "%0")
10424                          (match_operand:XF 2 "register_operand" "f")]))]
10425   "TARGET_80387 && GET_RTX_CLASS (GET_CODE (operands[3])) == 'c'"
10426   "* return output_387_binary_op (insn, operands);"
10427   [(set (attr "type") 
10428         (if_then_else (match_operand:XF 3 "mult_operator" "") 
10429            (const_string "fmul")
10430            (const_string "fop")))
10431    (set_attr "mode" "XF")])
10432
10433 (define_insn "*fop_tf_comm"
10434   [(set (match_operand:TF 0 "register_operand" "=f")
10435         (match_operator:TF 3 "binary_fp_operator"
10436                         [(match_operand:TF 1 "register_operand" "%0")
10437                          (match_operand:TF 2 "register_operand" "f")]))]
10438   "TARGET_80387 && GET_RTX_CLASS (GET_CODE (operands[3])) == 'c'"
10439   "* return output_387_binary_op (insn, operands);"
10440   [(set (attr "type") 
10441         (if_then_else (match_operand:TF 3 "mult_operator" "") 
10442            (const_string "fmul")
10443            (const_string "fop")))
10444    (set_attr "mode" "XF")])
10445
10446 (define_insn "*fop_sf_1"
10447   [(set (match_operand:SF 0 "register_operand" "=f,f,x")
10448         (match_operator:SF 3 "binary_fp_operator"
10449                         [(match_operand:SF 1 "nonimmediate_operand" "0,fm,0")
10450                          (match_operand:SF 2 "nonimmediate_operand" "fm,0,xm#f")]))]
10451   "TARGET_80387 && (!TARGET_SSE || TARGET_MIX_SSE_I387)
10452    && GET_RTX_CLASS (GET_CODE (operands[3])) != 'c'
10453    && (GET_CODE (operands[1]) != MEM || GET_CODE (operands[2]) != MEM)"
10454   "* return output_387_binary_op (insn, operands);"
10455   [(set (attr "type") 
10456         (cond [(eq_attr "alternative" "2")
10457                  (const_string "sse")
10458                (match_operand:SF 3 "mult_operator" "") 
10459                  (const_string "fmul")
10460                (match_operand:SF 3 "div_operator" "") 
10461                  (const_string "fdiv")
10462               ]
10463               (const_string "fop")))
10464    (set_attr "mode" "SF")])
10465
10466 (define_insn "*fop_sf_1_sse"
10467   [(set (match_operand:SF 0 "register_operand" "=x")
10468         (match_operator:SF 3 "binary_fp_operator"
10469                         [(match_operand:SF 1 "register_operand" "0")
10470                          (match_operand:SF 2 "nonimmediate_operand" "xm")]))]
10471   "TARGET_SSE
10472    && GET_RTX_CLASS (GET_CODE (operands[3])) != 'c'"
10473   "* return output_387_binary_op (insn, operands);"
10474   [(set_attr "type" "sse")
10475    (set_attr "mode" "SF")])
10476
10477 ;; ??? Add SSE splitters for these!
10478 (define_insn "*fop_sf_2"
10479   [(set (match_operand:SF 0 "register_operand" "=f,f")
10480         (match_operator:SF 3 "binary_fp_operator"
10481           [(float:SF (match_operand:SI 1 "nonimmediate_operand" "m,?r"))
10482            (match_operand:SF 2 "register_operand" "0,0")]))]
10483   "TARGET_80387 && TARGET_USE_FIOP && !TARGET_SSE"
10484   "* return which_alternative ? \"#\" : output_387_binary_op (insn, operands);"
10485   [(set (attr "type") 
10486         (cond [(match_operand:SF 3 "mult_operator" "") 
10487                  (const_string "fmul")
10488                (match_operand:SF 3 "div_operator" "") 
10489                  (const_string "fdiv")
10490               ]
10491               (const_string "fop")))
10492    (set_attr "fp_int_src" "true")
10493    (set_attr "ppro_uops" "many")
10494    (set_attr "mode" "SI")])
10495
10496 (define_insn "*fop_sf_3"
10497   [(set (match_operand:SF 0 "register_operand" "=f,f")
10498         (match_operator:SF 3 "binary_fp_operator"
10499           [(match_operand:SF 1 "register_operand" "0,0")
10500            (float:SF (match_operand:SI 2 "nonimmediate_operand" "m,?r"))]))]
10501   "TARGET_80387 && TARGET_USE_FIOP && !TARGET_SSE"
10502   "* return which_alternative ? \"#\" : output_387_binary_op (insn, operands);"
10503   [(set (attr "type") 
10504         (cond [(match_operand:SF 3 "mult_operator" "") 
10505                  (const_string "fmul")
10506                (match_operand:SF 3 "div_operator" "") 
10507                  (const_string "fdiv")
10508               ]
10509               (const_string "fop")))
10510    (set_attr "fp_int_src" "true")
10511    (set_attr "ppro_uops" "many")
10512    (set_attr "mode" "SI")])
10513
10514 (define_insn "*fop_df_1"
10515   [(set (match_operand:DF 0 "register_operand" "=f#Y,f#Y,Y#f")
10516         (match_operator:DF 3 "binary_fp_operator"
10517                         [(match_operand:DF 1 "nonimmediate_operand" "0,fm,0")
10518                          (match_operand:DF 2 "nonimmediate_operand" "fm,0,Ym#f")]))]
10519   "TARGET_80387 && (!TARGET_SSE2 || TARGET_MIX_SSE_I387)
10520    && GET_RTX_CLASS (GET_CODE (operands[3])) != 'c'
10521    && (GET_CODE (operands[1]) != MEM || GET_CODE (operands[2]) != MEM)"
10522   "* return output_387_binary_op (insn, operands);"
10523   [(set (attr "type") 
10524         (cond [(eq_attr "alternative" "2")
10525                  (const_string "sse")
10526                (match_operand:DF 3 "mult_operator" "") 
10527                  (const_string "fmul")
10528                (match_operand:DF 3 "div_operator" "") 
10529                  (const_string "fdiv")
10530               ]
10531               (const_string "fop")))
10532    (set_attr "mode" "DF")])
10533
10534 (define_insn "*fop_df_1_sse"
10535   [(set (match_operand:DF 0 "register_operand" "=Y")
10536         (match_operator:DF 3 "binary_fp_operator"
10537                         [(match_operand:DF 1 "register_operand" "0")
10538                          (match_operand:DF 2 "nonimmediate_operand" "Ym")]))]
10539   "TARGET_SSE
10540    && GET_RTX_CLASS (GET_CODE (operands[3])) != 'c'"
10541   "* return output_387_binary_op (insn, operands);"
10542   [(set_attr "type" "sse")])
10543
10544 ;; ??? Add SSE splitters for these!
10545 (define_insn "*fop_df_2"
10546   [(set (match_operand:DF 0 "register_operand" "=f,f")
10547         (match_operator:DF 3 "binary_fp_operator"
10548            [(float:DF (match_operand:SI 1 "nonimmediate_operand" "m,?r"))
10549             (match_operand:DF 2 "register_operand" "0,0")]))]
10550   "TARGET_80387 && TARGET_USE_FIOP && !TARGET_SSE2"
10551   "* return which_alternative ? \"#\" : output_387_binary_op (insn, operands);"
10552   [(set (attr "type") 
10553         (cond [(match_operand:DF 3 "mult_operator" "") 
10554                  (const_string "fmul")
10555                (match_operand:DF 3 "div_operator" "") 
10556                  (const_string "fdiv")
10557               ]
10558               (const_string "fop")))
10559    (set_attr "fp_int_src" "true")
10560    (set_attr "ppro_uops" "many")
10561    (set_attr "mode" "SI")])
10562
10563 (define_insn "*fop_df_3"
10564   [(set (match_operand:DF 0 "register_operand" "=f,f")
10565         (match_operator:DF 3 "binary_fp_operator"
10566            [(match_operand:DF 1 "register_operand" "0,0")
10567             (float:DF (match_operand:SI 2 "nonimmediate_operand" "m,?r"))]))]
10568   "TARGET_80387 && TARGET_USE_FIOP && !TARGET_SSE2"
10569   "* return which_alternative ? \"#\" : output_387_binary_op (insn, operands);"
10570   [(set (attr "type") 
10571         (cond [(match_operand:DF 3 "mult_operator" "") 
10572                  (const_string "fmul")
10573                (match_operand:DF 3 "div_operator" "") 
10574                  (const_string "fdiv")
10575               ]
10576               (const_string "fop")))
10577    (set_attr "fp_int_src" "true")
10578    (set_attr "ppro_uops" "many")
10579    (set_attr "mode" "SI")])
10580
10581 (define_insn "*fop_df_4"
10582   [(set (match_operand:DF 0 "register_operand" "=f,f")
10583         (match_operator:DF 3 "binary_fp_operator"
10584            [(float_extend:DF (match_operand:SF 1 "nonimmediate_operand" "fm,0"))
10585             (match_operand:DF 2 "register_operand" "0,f")]))]
10586   "TARGET_80387
10587    && (GET_CODE (operands[1]) != MEM || GET_CODE (operands[2]) != MEM)"
10588   "* return output_387_binary_op (insn, operands);"
10589   [(set (attr "type") 
10590         (cond [(match_operand:DF 3 "mult_operator" "") 
10591                  (const_string "fmul")
10592                (match_operand:DF 3 "div_operator" "") 
10593                  (const_string "fdiv")
10594               ]
10595               (const_string "fop")))
10596    (set_attr "mode" "SF")])
10597
10598 (define_insn "*fop_df_5"
10599   [(set (match_operand:DF 0 "register_operand" "=f,f")
10600         (match_operator:DF 3 "binary_fp_operator"
10601           [(match_operand:DF 1 "register_operand" "0,f")
10602            (float_extend:DF
10603             (match_operand:SF 2 "nonimmediate_operand" "fm,0"))]))]
10604   "TARGET_80387 && !TARGET_SSE2"
10605   "* return output_387_binary_op (insn, operands);"
10606   [(set (attr "type") 
10607         (cond [(match_operand:DF 3 "mult_operator" "") 
10608                  (const_string "fmul")
10609                (match_operand:DF 3 "div_operator" "") 
10610                  (const_string "fdiv")
10611               ]
10612               (const_string "fop")))
10613    (set_attr "mode" "SF")])
10614
10615 (define_insn "*fop_xf_1"
10616   [(set (match_operand:XF 0 "register_operand" "=f,f")
10617         (match_operator:XF 3 "binary_fp_operator"
10618                         [(match_operand:XF 1 "register_operand" "0,f")
10619                          (match_operand:XF 2 "register_operand" "f,0")]))]
10620   "TARGET_80387
10621    && GET_RTX_CLASS (GET_CODE (operands[3])) != 'c'"
10622   "* return output_387_binary_op (insn, operands);"
10623   [(set (attr "type") 
10624         (cond [(match_operand:XF 3 "mult_operator" "") 
10625                  (const_string "fmul")
10626                (match_operand:XF 3 "div_operator" "") 
10627                  (const_string "fdiv")
10628               ]
10629               (const_string "fop")))
10630    (set_attr "mode" "XF")])
10631
10632 (define_insn "*fop_tf_1"
10633   [(set (match_operand:TF 0 "register_operand" "=f,f")
10634         (match_operator:TF 3 "binary_fp_operator"
10635                         [(match_operand:TF 1 "register_operand" "0,f")
10636                          (match_operand:TF 2 "register_operand" "f,0")]))]
10637   "TARGET_80387
10638    && GET_RTX_CLASS (GET_CODE (operands[3])) != 'c'"
10639   "* return output_387_binary_op (insn, operands);"
10640   [(set (attr "type") 
10641         (cond [(match_operand:TF 3 "mult_operator" "") 
10642                  (const_string "fmul")
10643                (match_operand:TF 3 "div_operator" "") 
10644                  (const_string "fdiv")
10645               ]
10646               (const_string "fop")))
10647    (set_attr "mode" "XF")])
10648
10649 (define_insn "*fop_xf_2"
10650   [(set (match_operand:XF 0 "register_operand" "=f,f")
10651         (match_operator:XF 3 "binary_fp_operator"
10652            [(float:XF (match_operand:SI 1 "nonimmediate_operand" "m,?r"))
10653             (match_operand:XF 2 "register_operand" "0,0")]))]
10654   "TARGET_80387 && TARGET_USE_FIOP"
10655   "* return which_alternative ? \"#\" : output_387_binary_op (insn, operands);"
10656   [(set (attr "type") 
10657         (cond [(match_operand:XF 3 "mult_operator" "") 
10658                  (const_string "fmul")
10659                (match_operand:XF 3 "div_operator" "") 
10660                  (const_string "fdiv")
10661               ]
10662               (const_string "fop")))
10663    (set_attr "fp_int_src" "true")
10664    (set_attr "mode" "SI")
10665    (set_attr "ppro_uops" "many")])
10666
10667 (define_insn "*fop_tf_2"
10668   [(set (match_operand:TF 0 "register_operand" "=f,f")
10669         (match_operator:TF 3 "binary_fp_operator"
10670            [(float:TF (match_operand:SI 1 "nonimmediate_operand" "m,?r"))
10671             (match_operand:TF 2 "register_operand" "0,0")]))]
10672   "TARGET_80387 && TARGET_USE_FIOP"
10673   "* return which_alternative ? \"#\" : output_387_binary_op (insn, operands);"
10674   [(set (attr "type") 
10675         (cond [(match_operand:TF 3 "mult_operator" "") 
10676                  (const_string "fmul")
10677                (match_operand:TF 3 "div_operator" "") 
10678                  (const_string "fdiv")
10679               ]
10680               (const_string "fop")))
10681    (set_attr "fp_int_src" "true")
10682    (set_attr "mode" "SI")
10683    (set_attr "ppro_uops" "many")])
10684
10685 (define_insn "*fop_xf_3"
10686   [(set (match_operand:XF 0 "register_operand" "=f,f")
10687         (match_operator:XF 3 "binary_fp_operator"
10688           [(match_operand:XF 1 "register_operand" "0,0")
10689            (float:XF (match_operand:SI 2 "nonimmediate_operand" "m,?r"))]))]
10690   "TARGET_80387 && TARGET_USE_FIOP"
10691   "* return which_alternative ? \"#\" : output_387_binary_op (insn, operands);"
10692   [(set (attr "type") 
10693         (cond [(match_operand:XF 3 "mult_operator" "") 
10694                  (const_string "fmul")
10695                (match_operand:XF 3 "div_operator" "") 
10696                  (const_string "fdiv")
10697               ]
10698               (const_string "fop")))
10699    (set_attr "fp_int_src" "true")
10700    (set_attr "mode" "SI")
10701    (set_attr "ppro_uops" "many")])
10702
10703 (define_insn "*fop_tf_3"
10704   [(set (match_operand:TF 0 "register_operand" "=f,f")
10705         (match_operator:TF 3 "binary_fp_operator"
10706           [(match_operand:TF 1 "register_operand" "0,0")
10707            (float:TF (match_operand:SI 2 "nonimmediate_operand" "m,?r"))]))]
10708   "TARGET_80387 && TARGET_USE_FIOP"
10709   "* return which_alternative ? \"#\" : output_387_binary_op (insn, operands);"
10710   [(set (attr "type") 
10711         (cond [(match_operand:TF 3 "mult_operator" "") 
10712                  (const_string "fmul")
10713                (match_operand:TF 3 "div_operator" "") 
10714                  (const_string "fdiv")
10715               ]
10716               (const_string "fop")))
10717    (set_attr "fp_int_src" "true")
10718    (set_attr "mode" "SI")
10719    (set_attr "ppro_uops" "many")])
10720
10721 (define_insn "*fop_xf_4"
10722   [(set (match_operand:XF 0 "register_operand" "=f,f")
10723         (match_operator:XF 3 "binary_fp_operator"
10724            [(float_extend:XF (match_operand:SF 1 "nonimmediate_operand" "fm,0"))
10725             (match_operand:XF 2 "register_operand" "0,f")]))]
10726   "TARGET_80387"
10727   "* return output_387_binary_op (insn, operands);"
10728   [(set (attr "type") 
10729         (cond [(match_operand:XF 3 "mult_operator" "") 
10730                  (const_string "fmul")
10731                (match_operand:XF 3 "div_operator" "") 
10732                  (const_string "fdiv")
10733               ]
10734               (const_string "fop")))
10735    (set_attr "mode" "SF")])
10736
10737 (define_insn "*fop_tf_4"
10738   [(set (match_operand:TF 0 "register_operand" "=f,f")
10739         (match_operator:TF 3 "binary_fp_operator"
10740            [(float_extend:TF (match_operand:SF 1 "nonimmediate_operand" "fm,0"))
10741             (match_operand:TF 2 "register_operand" "0,f")]))]
10742   "TARGET_80387"
10743   "* return output_387_binary_op (insn, operands);"
10744   [(set (attr "type") 
10745         (cond [(match_operand:TF 3 "mult_operator" "") 
10746                  (const_string "fmul")
10747                (match_operand:TF 3 "div_operator" "") 
10748                  (const_string "fdiv")
10749               ]
10750               (const_string "fop")))
10751    (set_attr "mode" "SF")])
10752
10753 (define_insn "*fop_xf_5"
10754   [(set (match_operand:XF 0 "register_operand" "=f,f")
10755         (match_operator:XF 3 "binary_fp_operator"
10756           [(match_operand:XF 1 "register_operand" "0,f")
10757            (float_extend:XF
10758             (match_operand:SF 2 "nonimmediate_operand" "fm,0"))]))]
10759   "TARGET_80387"
10760   "* return output_387_binary_op (insn, operands);"
10761   [(set (attr "type") 
10762         (cond [(match_operand:XF 3 "mult_operator" "") 
10763                  (const_string "fmul")
10764                (match_operand:XF 3 "div_operator" "") 
10765                  (const_string "fdiv")
10766               ]
10767               (const_string "fop")))
10768    (set_attr "mode" "SF")])
10769
10770 (define_insn "*fop_tf_5"
10771   [(set (match_operand:TF 0 "register_operand" "=f,f")
10772         (match_operator:TF 3 "binary_fp_operator"
10773           [(match_operand:TF 1 "register_operand" "0,f")
10774            (float_extend:TF
10775             (match_operand:SF 2 "nonimmediate_operand" "fm,0"))]))]
10776   "TARGET_80387"
10777   "* return output_387_binary_op (insn, operands);"
10778   [(set (attr "type") 
10779         (cond [(match_operand:TF 3 "mult_operator" "") 
10780                  (const_string "fmul")
10781                (match_operand:TF 3 "div_operator" "") 
10782                  (const_string "fdiv")
10783               ]
10784               (const_string "fop")))
10785    (set_attr "mode" "SF")])
10786
10787 (define_insn "*fop_xf_6"
10788   [(set (match_operand:XF 0 "register_operand" "=f,f")
10789         (match_operator:XF 3 "binary_fp_operator"
10790            [(float_extend:XF (match_operand:DF 1 "nonimmediate_operand" "fm,0"))
10791             (match_operand:XF 2 "register_operand" "0,f")]))]
10792   "TARGET_80387"
10793   "* return output_387_binary_op (insn, operands);"
10794   [(set (attr "type") 
10795         (cond [(match_operand:XF 3 "mult_operator" "") 
10796                  (const_string "fmul")
10797                (match_operand:XF 3 "div_operator" "") 
10798                  (const_string "fdiv")
10799               ]
10800               (const_string "fop")))
10801    (set_attr "mode" "DF")])
10802
10803 (define_insn "*fop_tf_6"
10804   [(set (match_operand:TF 0 "register_operand" "=f,f")
10805         (match_operator:TF 3 "binary_fp_operator"
10806            [(float_extend:TF (match_operand:DF 1 "nonimmediate_operand" "fm,0"))
10807             (match_operand:TF 2 "register_operand" "0,f")]))]
10808   "TARGET_80387"
10809   "* return output_387_binary_op (insn, operands);"
10810   [(set (attr "type") 
10811         (cond [(match_operand:TF 3 "mult_operator" "") 
10812                  (const_string "fmul")
10813                (match_operand:TF 3 "div_operator" "") 
10814                  (const_string "fdiv")
10815               ]
10816               (const_string "fop")))
10817    (set_attr "mode" "DF")])
10818
10819 (define_insn "*fop_xf_7"
10820   [(set (match_operand:XF 0 "register_operand" "=f,f")
10821         (match_operator:XF 3 "binary_fp_operator"
10822           [(match_operand:XF 1 "register_operand" "0,f")
10823            (float_extend:XF
10824             (match_operand:DF 2 "nonimmediate_operand" "fm,0"))]))]
10825   "TARGET_80387"
10826   "* return output_387_binary_op (insn, operands);"
10827   [(set (attr "type") 
10828         (cond [(match_operand:XF 3 "mult_operator" "") 
10829                  (const_string "fmul")
10830                (match_operand:XF 3 "div_operator" "") 
10831                  (const_string "fdiv")
10832               ]
10833               (const_string "fop")))
10834    (set_attr "mode" "DF")])
10835
10836 (define_insn "*fop_tf_7"
10837   [(set (match_operand:TF 0 "register_operand" "=f,f")
10838         (match_operator:TF 3 "binary_fp_operator"
10839           [(match_operand:TF 1 "register_operand" "0,f")
10840            (float_extend:TF
10841             (match_operand:DF 2 "nonimmediate_operand" "fm,0"))]))]
10842   "TARGET_80387"
10843   "* return output_387_binary_op (insn, operands);"
10844   [(set (attr "type") 
10845         (cond [(match_operand:TF 3 "mult_operator" "") 
10846                  (const_string "fmul")
10847                (match_operand:TF 3 "div_operator" "") 
10848                  (const_string "fdiv")
10849               ]
10850               (const_string "fop")))
10851    (set_attr "mode" "DF")])
10852
10853 (define_split
10854   [(set (match_operand 0 "register_operand" "")
10855         (match_operator 3 "binary_fp_operator"
10856            [(float (match_operand:SI 1 "register_operand" ""))
10857             (match_operand 2 "register_operand" "")]))]
10858   "TARGET_80387 && reload_completed
10859    && FLOAT_MODE_P (GET_MODE (operands[0]))"
10860   [(const_int 0)]
10861   "
10862
10863   operands[4] = ix86_force_to_memory (GET_MODE (operands[1]), operands[1]);
10864   operands[4] = gen_rtx_FLOAT (GET_MODE (operands[0]), operands[4]);
10865   emit_insn (gen_rtx_SET (VOIDmode, operands[0],
10866                           gen_rtx_fmt_ee (GET_CODE (operands[3]),
10867                                           GET_MODE (operands[3]),
10868                                           operands[4],
10869                                           operands[2])));
10870   ix86_free_from_memory (GET_MODE (operands[1]));
10871   DONE;
10872 }")
10873
10874 (define_split
10875   [(set (match_operand 0 "register_operand" "")
10876         (match_operator 3 "binary_fp_operator"
10877            [(match_operand 1 "register_operand" "")
10878             (float (match_operand:SI 2 "register_operand" ""))]))]
10879   "TARGET_80387 && reload_completed
10880    && FLOAT_MODE_P (GET_MODE (operands[0]))"
10881   [(const_int 0)]
10882   "
10883 {
10884   operands[4] = ix86_force_to_memory (GET_MODE (operands[2]), operands[2]);
10885   operands[4] = gen_rtx_FLOAT (GET_MODE (operands[0]), operands[4]);
10886   emit_insn (gen_rtx_SET (VOIDmode, operands[0],
10887                           gen_rtx_fmt_ee (GET_CODE (operands[3]),
10888                                           GET_MODE (operands[3]),
10889                                           operands[1],
10890                                           operands[4])));
10891   ix86_free_from_memory (GET_MODE (operands[2]));
10892   DONE;
10893 }")
10894 \f
10895 ;; FPU special functions.
10896
10897 (define_expand "sqrtsf2"
10898   [(set (match_operand:SF 0 "register_operand" "")
10899         (sqrt:SF (match_operand:SF 1 "nonimmediate_operand" "")))]
10900   "(! TARGET_NO_FANCY_MATH_387 && TARGET_80387) || TARGET_SSE"
10901   "
10902 {
10903   if (!TARGET_SSE)
10904     operands[1] = force_reg (SFmode, operands[1]);
10905 }")
10906
10907 (define_insn "sqrtsf2_1"
10908   [(set (match_operand:SF 0 "register_operand" "=f#x,x#f")
10909         (sqrt:SF (match_operand:SF 1 "nonimmediate_operand" "0#x,xm#f")))]
10910   "! TARGET_NO_FANCY_MATH_387 && TARGET_80387
10911    && (TARGET_SSE && TARGET_MIX_SSE_I387)"
10912   "@
10913    fsqrt
10914    sqrtss\\t{%1, %0|%0, %1}"
10915   [(set_attr "type" "fpspc,sse")
10916    (set_attr "mode" "SF,SF")
10917    (set_attr "athlon_decode" "direct,*")])
10918
10919 (define_insn "sqrtsf2_1_sse_only"
10920   [(set (match_operand:SF 0 "register_operand" "=x")
10921         (sqrt:SF (match_operand:SF 1 "nonimmediate_operand" "xm")))]
10922   "TARGET_SSE && (!TARGET_80387 || !TARGET_MIX_SSE_I387)"
10923   "sqrtss\\t{%1, %0|%0, %1}"
10924   [(set_attr "type" "sse")
10925    (set_attr "mode" "SF")
10926    (set_attr "athlon_decode" "*")])
10927
10928 (define_insn "sqrtsf2_i387"
10929   [(set (match_operand:SF 0 "register_operand" "=f")
10930         (sqrt:SF (match_operand:SF 1 "register_operand" "0")))]
10931   "! TARGET_NO_FANCY_MATH_387 && TARGET_80387
10932    && (!TARGET_SSE && !TARGET_MIX_SSE_I387)"
10933   "fsqrt"
10934   [(set_attr "type" "fpspc")
10935    (set_attr "mode" "SF")
10936    (set_attr "athlon_decode" "direct")])
10937
10938 (define_expand "sqrtdf2"
10939   [(set (match_operand:DF 0 "register_operand" "")
10940         (sqrt:DF (match_operand:DF 1 "nonimmediate_operand" "")))]
10941   "(! TARGET_NO_FANCY_MATH_387 && TARGET_80387) || TARGET_SSE2"
10942   "
10943 {
10944   if (!TARGET_SSE2)
10945     operands[1] = force_reg (SFmode, operands[1]);
10946 }")
10947
10948 (define_insn "sqrtdf2_1"
10949   [(set (match_operand:DF 0 "register_operand" "=f#Y,Y#f")
10950         (sqrt:DF (match_operand:DF 1 "nonimmediate_operand" "0#Y,Ym#f")))]
10951   "! TARGET_NO_FANCY_MATH_387 && TARGET_80387
10952    && (TARGET_SSE2 && TARGET_MIX_SSE_I387)"
10953   "@
10954    fsqrt
10955    sqrtsd\\t{%1, %0|%0, %1}"
10956   [(set_attr "type" "fpspc,sse")
10957    (set_attr "mode" "DF,DF")
10958    (set_attr "athlon_decode" "direct,*")])
10959
10960 (define_insn "sqrtdf2_1_sse_only"
10961   [(set (match_operand:DF 0 "register_operand" "=Y")
10962         (sqrt:DF (match_operand:DF 1 "nonimmediate_operand" "Ym")))]
10963   "TARGET_SSE2 && (!TARGET_80387 || !TARGET_MIX_SSE_I387)"
10964   "sqrtsd\\t{%1, %0|%0, %1}"
10965   [(set_attr "type" "sse")
10966    (set_attr "mode" "DF")
10967    (set_attr "athlon_decode" "*")])
10968
10969 (define_insn "sqrtdf2_i387"
10970   [(set (match_operand:DF 0 "register_operand" "=f")
10971         (sqrt:DF (match_operand:DF 1 "register_operand" "0")))]
10972   "! TARGET_NO_FANCY_MATH_387 && TARGET_80387
10973    && (!TARGET_SSE2 && !TARGET_MIX_SSE_I387)"
10974   "fsqrt"
10975   [(set_attr "type" "fpspc")
10976    (set_attr "mode" "DF")
10977    (set_attr "athlon_decode" "direct")])
10978
10979 (define_insn "*sqrtextendsfdf2"
10980   [(set (match_operand:DF 0 "register_operand" "=f")
10981         (sqrt:DF (float_extend:DF
10982                   (match_operand:SF 1 "register_operand" "0"))))]
10983   "! TARGET_NO_FANCY_MATH_387 && TARGET_80387 && !TARGET_SSE2"
10984   "fsqrt"
10985   [(set_attr "type" "fpspc")
10986    (set_attr "mode" "DF")
10987    (set_attr "athlon_decode" "direct")])
10988
10989 (define_insn "sqrtxf2"
10990   [(set (match_operand:XF 0 "register_operand" "=f")
10991         (sqrt:XF (match_operand:XF 1 "register_operand" "0")))]
10992   "! TARGET_NO_FANCY_MATH_387 && TARGET_80387 
10993    && (TARGET_IEEE_FP || flag_fast_math) "
10994   "fsqrt"
10995   [(set_attr "type" "fpspc")
10996    (set_attr "mode" "XF")
10997    (set_attr "athlon_decode" "direct")])
10998
10999 (define_insn "sqrttf2"
11000   [(set (match_operand:TF 0 "register_operand" "=f")
11001         (sqrt:TF (match_operand:TF 1 "register_operand" "0")))]
11002   "! TARGET_NO_FANCY_MATH_387 && TARGET_80387 
11003    && (TARGET_IEEE_FP || flag_fast_math) "
11004   "fsqrt"
11005   [(set_attr "type" "fpspc")
11006    (set_attr "mode" "XF")
11007    (set_attr "athlon_decode" "direct")])
11008
11009 (define_insn "*sqrtextenddfxf2"
11010   [(set (match_operand:XF 0 "register_operand" "=f")
11011         (sqrt:XF (float_extend:XF
11012                   (match_operand:DF 1 "register_operand" "0"))))]
11013   "! TARGET_NO_FANCY_MATH_387 && TARGET_80387"
11014   "fsqrt"
11015   [(set_attr "type" "fpspc")
11016    (set_attr "mode" "XF")
11017    (set_attr "athlon_decode" "direct")])
11018
11019 (define_insn "*sqrtextenddftf2"
11020   [(set (match_operand:TF 0 "register_operand" "=f")
11021         (sqrt:TF (float_extend:TF
11022                   (match_operand:DF 1 "register_operand" "0"))))]
11023   "! TARGET_NO_FANCY_MATH_387 && TARGET_80387"
11024   "fsqrt"
11025   [(set_attr "type" "fpspc")
11026    (set_attr "mode" "XF")
11027    (set_attr "athlon_decode" "direct")])
11028
11029 (define_insn "*sqrtextendsfxf2"
11030   [(set (match_operand:XF 0 "register_operand" "=f")
11031         (sqrt:XF (float_extend:XF
11032                   (match_operand:SF 1 "register_operand" "0"))))]
11033   "! TARGET_NO_FANCY_MATH_387 && TARGET_80387"
11034   "fsqrt"
11035   [(set_attr "type" "fpspc")
11036    (set_attr "mode" "XF")
11037    (set_attr "athlon_decode" "direct")])
11038
11039 (define_insn "*sqrtextendsftf2"
11040   [(set (match_operand:TF 0 "register_operand" "=f")
11041         (sqrt:TF (float_extend:TF
11042                   (match_operand:SF 1 "register_operand" "0"))))]
11043   "! TARGET_NO_FANCY_MATH_387 && TARGET_80387"
11044   "fsqrt"
11045   [(set_attr "type" "fpspc")
11046    (set_attr "mode" "XF")
11047    (set_attr "athlon_decode" "direct")])
11048
11049 (define_insn "sindf2"
11050   [(set (match_operand:DF 0 "register_operand" "=f")
11051         (unspec:DF [(match_operand:DF 1 "register_operand" "0")] 1))]
11052   "! TARGET_NO_FANCY_MATH_387 && TARGET_80387 && flag_fast_math"
11053   "fsin"
11054   [(set_attr "type" "fpspc")
11055    (set_attr "mode" "DF")])
11056
11057 (define_insn "sinsf2"
11058   [(set (match_operand:SF 0 "register_operand" "=f")
11059         (unspec:SF [(match_operand:SF 1 "register_operand" "0")] 1))]
11060   "! TARGET_NO_FANCY_MATH_387 && TARGET_80387 && flag_fast_math"
11061   "fsin"
11062   [(set_attr "type" "fpspc")
11063    (set_attr "mode" "SF")])
11064
11065 (define_insn "*sinextendsfdf2"
11066   [(set (match_operand:DF 0 "register_operand" "=f")
11067         (unspec:DF [(float_extend:DF
11068                      (match_operand:SF 1 "register_operand" "0"))] 1))]
11069   "! TARGET_NO_FANCY_MATH_387 && TARGET_80387 && flag_fast_math"
11070   "fsin"
11071   [(set_attr "type" "fpspc")
11072    (set_attr "mode" "DF")])
11073
11074 (define_insn "sinxf2"
11075   [(set (match_operand:XF 0 "register_operand" "=f")
11076         (unspec:XF [(match_operand:XF 1 "register_operand" "0")] 1))]
11077   "! TARGET_NO_FANCY_MATH_387 && TARGET_80387 && flag_fast_math"
11078   "fsin"
11079   [(set_attr "type" "fpspc")
11080    (set_attr "mode" "XF")])
11081
11082 (define_insn "sintf2"
11083   [(set (match_operand:TF 0 "register_operand" "=f")
11084         (unspec:TF [(match_operand:TF 1 "register_operand" "0")] 1))]
11085   "! TARGET_NO_FANCY_MATH_387 && TARGET_80387 && flag_fast_math"
11086   "fsin"
11087   [(set_attr "type" "fpspc")
11088    (set_attr "mode" "XF")])
11089
11090 (define_insn "cosdf2"
11091   [(set (match_operand:DF 0 "register_operand" "=f")
11092         (unspec:DF [(match_operand:DF 1 "register_operand" "0")] 2))]
11093   "! TARGET_NO_FANCY_MATH_387 && TARGET_80387 && flag_fast_math"
11094   "fcos"
11095   [(set_attr "type" "fpspc")
11096    (set_attr "mode" "DF")])
11097
11098 (define_insn "cossf2"
11099   [(set (match_operand:SF 0 "register_operand" "=f")
11100         (unspec:SF [(match_operand:SF 1 "register_operand" "0")] 2))]
11101   "! TARGET_NO_FANCY_MATH_387 && TARGET_80387 && flag_fast_math"
11102   "fcos"
11103   [(set_attr "type" "fpspc")
11104    (set_attr "mode" "SF")])
11105
11106 (define_insn "*cosextendsfdf2"
11107   [(set (match_operand:DF 0 "register_operand" "=f")
11108         (unspec:DF [(float_extend:DF
11109                      (match_operand:SF 1 "register_operand" "0"))] 2))]
11110   "! TARGET_NO_FANCY_MATH_387 && TARGET_80387 && flag_fast_math"
11111   "fcos"
11112   [(set_attr "type" "fpspc")
11113    (set_attr "mode" "DF")])
11114
11115 (define_insn "cosxf2"
11116   [(set (match_operand:XF 0 "register_operand" "=f")
11117         (unspec:XF [(match_operand:XF 1 "register_operand" "0")] 2))]
11118   "! TARGET_NO_FANCY_MATH_387 && TARGET_80387 && flag_fast_math"
11119   "fcos"
11120   [(set_attr "type" "fpspc")
11121    (set_attr "mode" "XF")])
11122
11123 (define_insn "costf2"
11124   [(set (match_operand:TF 0 "register_operand" "=f")
11125         (unspec:TF [(match_operand:TF 1 "register_operand" "0")] 2))]
11126   "! TARGET_NO_FANCY_MATH_387 && TARGET_80387 && flag_fast_math"
11127   "fcos"
11128   [(set_attr "type" "fpspc")
11129    (set_attr "mode" "XF")])
11130 \f
11131 ;; Block operation instructions
11132
11133 (define_insn "cld"
11134  [(set (reg:SI 19) (const_int 0))]
11135  ""
11136  "cld"
11137   [(set_attr "type" "cld")])
11138
11139 (define_expand "movstrsi"
11140   [(use (match_operand:BLK 0 "memory_operand" ""))
11141    (use (match_operand:BLK 1 "memory_operand" ""))
11142    (use (match_operand:SI 2 "nonmemory_operand" ""))
11143    (use (match_operand:SI 3 "const_int_operand" ""))]
11144   ""
11145   "
11146 {
11147   rtx srcreg, destreg, countreg;
11148   int align = 0;
11149   int count = -1;
11150   rtx insns;
11151
11152   start_sequence ();
11153
11154   if (GET_CODE (operands[3]) == CONST_INT)
11155     align = INTVAL (operands[3]);
11156
11157   /* This simple hack avoids all inlining code and simplifies code bellow.  */
11158   if (!TARGET_ALIGN_STRINGOPS)
11159     align = 32;
11160
11161   if (GET_CODE (operands[2]) == CONST_INT)
11162     count = INTVAL (operands[2]);
11163
11164   destreg = copy_to_mode_reg (Pmode, XEXP (operands[0], 0));
11165   srcreg = copy_to_mode_reg (Pmode, XEXP (operands[1], 0));
11166
11167   emit_insn (gen_cld ());
11168
11169   /* When optimizing for size emit simple rep ; movsb instruction for
11170      counts not divisible by 4.  */
11171
11172   if ((!optimize || optimize_size) 
11173       && (count < 0 || (count & 0x03)))
11174     {
11175       countreg = copy_to_mode_reg (SImode, operands[2]);
11176       emit_insn (gen_rep_movqi (destreg, srcreg, countreg,
11177                                 destreg, srcreg, countreg));
11178     }
11179
11180   /* For constant aligned (or small unaligned) copies use rep movsl
11181      followed by code copying the rest.  For PentiumPro ensure 8 byte
11182      alignment to allow rep movsl acceleration.  */
11183
11184   else if (count >= 0 
11185            && (align >= 8
11186                || (!TARGET_PENTIUMPRO && align >= 4)
11187                || optimize_size || count < 64))
11188     {
11189       if (count & ~0x03)
11190         {
11191           countreg = copy_to_mode_reg (SImode,
11192                                        GEN_INT ((count >> 2)
11193                                                 & 0x3fffffff));
11194           emit_insn (gen_rep_movsi (destreg, srcreg, countreg,
11195                                     destreg, srcreg, countreg));
11196         }
11197       if (count & 0x02)
11198         emit_insn (gen_strmovhi (destreg, srcreg));
11199       if (count & 0x01)
11200         emit_insn (gen_strmovqi (destreg, srcreg));
11201     }
11202   /* The generic code based on the glibc implementation:
11203      - align destination to 4 bytes (8 byte alignment is used for PentiumPro
11204        allowing accelerated copying there)
11205      - copy the data using rep movsl
11206      - copy the rest.  */
11207   else
11208     {
11209       rtx countreg2;
11210       rtx label = NULL;
11211
11212       /* In case we don't know anything about the alignment, default to
11213          library version, since it is usually equally fast and result in
11214          shorter code.  */
11215       if (!TARGET_INLINE_ALL_STRINGOPS && align < 4)
11216         {
11217           end_sequence ();
11218           FAIL;
11219         }
11220
11221       if (TARGET_SINGLE_STRINGOP)
11222         emit_insn (gen_cld ());
11223
11224       countreg2 = gen_reg_rtx (SImode);
11225       countreg = copy_to_mode_reg (SImode, operands[2]);
11226
11227       /* We don't use loops to align destination and to copy parts smaller
11228          than 4 bytes, because gcc is able to optimize such code better (in
11229          the case the destination or the count really is aligned, gcc is often
11230          able to predict the branches) and also it is friendlier to the
11231          hardware branch prediction.  
11232
11233          Using loops is benefical for generic case, because we can
11234          handle small counts using the loops.  Many CPUs (such as Athlon)
11235          have large REP prefix setup costs.
11236
11237          This is quite costy.  Maybe we can revisit this decision later or
11238          add some customizability to this code.  */
11239
11240       if (count < 0
11241           && align < (TARGET_PENTIUMPRO && (count < 0 || count >= 260) ? 8 : 4))
11242         {
11243           label = gen_label_rtx ();
11244           emit_cmp_and_jump_insns (countreg, GEN_INT (3),
11245                                    LEU, 0, SImode, 1, 0, label);
11246         }
11247       if (align <= 1)
11248         {
11249           rtx label = gen_label_rtx ();
11250           rtx tmpcount = gen_reg_rtx (SImode);
11251           emit_insn (gen_andsi3 (tmpcount, destreg, GEN_INT (1)));
11252           emit_cmp_and_jump_insns (tmpcount, GEN_INT (0), EQ, 0,
11253                                    SImode, 1, 0, label);
11254           emit_insn (gen_strmovqi (destreg, srcreg));
11255           emit_insn (gen_addsi3 (countreg, countreg, constm1_rtx));
11256           emit_label (label);
11257           LABEL_NUSES (label) = 1;
11258         }
11259       if (align <= 2)
11260         {
11261           rtx label = gen_label_rtx ();
11262           rtx tmpcount = gen_reg_rtx (SImode);
11263           emit_insn (gen_andsi3 (tmpcount, destreg, GEN_INT (2)));
11264           emit_cmp_and_jump_insns (tmpcount, GEN_INT (0), EQ, 0,
11265                                    SImode, 1, 0, label);
11266           emit_insn (gen_strmovhi (destreg, srcreg));
11267           emit_insn (gen_addsi3 (countreg, countreg, GEN_INT (-2)));
11268           emit_label (label);
11269           LABEL_NUSES (label) = 1;
11270         }
11271       if (align <= 4 && TARGET_PENTIUMPRO && (count < 1 || count >= 260))
11272         {
11273           rtx label = gen_label_rtx ();
11274           rtx tmpcount = gen_reg_rtx (SImode);
11275           emit_insn (gen_andsi3 (tmpcount, destreg, GEN_INT (4)));
11276           emit_cmp_and_jump_insns (tmpcount, GEN_INT (0), EQ, 0,
11277                                    SImode, 1, 0, label);
11278           emit_insn (gen_strmovsi (destreg, srcreg));
11279           emit_insn (gen_addsi3 (countreg, countreg, GEN_INT (-4)));
11280           emit_label (label);
11281           LABEL_NUSES (label) = 1;
11282         }
11283
11284       if (!TARGET_SINGLE_STRINGOP)
11285         emit_insn (gen_cld());
11286       emit_insn (gen_lshrsi3 (countreg2, countreg, GEN_INT (2)));
11287       emit_insn (gen_rep_movsi (destreg, srcreg, countreg2,
11288                                 destreg, srcreg, countreg2));
11289
11290       if (label)
11291         {
11292           emit_label (label);
11293           LABEL_NUSES (label) = 1;
11294         }
11295       if (align > 2 && count > 0 && (count & 2))
11296         emit_insn (gen_strmovhi (destreg, srcreg));
11297       if (align <= 2 || count < 0)
11298         {
11299           rtx label = gen_label_rtx ();
11300           rtx tmpcount = gen_reg_rtx (SImode);
11301           emit_insn (gen_andsi3 (tmpcount, countreg, GEN_INT (2)));
11302           emit_cmp_and_jump_insns (tmpcount, GEN_INT (0), EQ, 0,
11303                                    SImode, 1, 0, label);
11304           emit_insn (gen_strmovhi (destreg, srcreg));
11305           emit_label (label);
11306           LABEL_NUSES (label) = 1;
11307         }
11308       if (align > 1 && count > 0 && (count & 1))
11309         emit_insn (gen_strmovsi (destreg, srcreg));
11310       if (align <= 1 || count < 0)
11311         {
11312           rtx label = gen_label_rtx ();
11313           rtx tmpcount = gen_reg_rtx (SImode);
11314           emit_insn (gen_andsi3 (tmpcount, countreg, GEN_INT (1)));
11315           emit_cmp_and_jump_insns (tmpcount, GEN_INT (0), EQ, 0,
11316                                    SImode, 1, 0, label);
11317           emit_insn (gen_strmovqi (destreg, srcreg));
11318           emit_label (label);
11319           LABEL_NUSES (label) = 1;
11320         }
11321     }
11322
11323   insns = get_insns ();
11324   end_sequence ();
11325
11326   ix86_set_move_mem_attrs (insns, operands[0], operands[1], destreg, srcreg);
11327   emit_insns (insns);
11328   DONE;
11329 }")
11330
11331 ;; Most CPUs don't like single string operations
11332 ;; Handle this case here to simplify previous expander.
11333
11334 (define_expand "strmovsi"
11335   [(set (match_dup 2)
11336         (mem:SI (match_operand:SI 1 "register_operand" "")))
11337    (set (mem:SI (match_operand:SI 0 "register_operand" ""))
11338         (match_dup 2))
11339    (parallel [(set (match_dup 0) (plus:SI (match_dup 0) (const_int 4)))
11340               (clobber (reg:CC 17))])
11341    (parallel [(set (match_dup 1) (plus:SI (match_dup 1) (const_int 4)))
11342               (clobber (reg:CC 17))])]
11343   ""
11344   "
11345 {
11346   if (TARGET_SINGLE_STRINGOP || optimize_size)
11347     {
11348       emit_insn (gen_strmovsi_1 (operands[0], operands[1], operands[0],
11349                                 operands[1]));
11350       DONE;
11351     }
11352   else 
11353     operands[2] = gen_reg_rtx (SImode);
11354 }")
11355
11356 (define_expand "strmovhi"
11357   [(set (match_dup 2)
11358         (mem:HI (match_operand:SI 1 "register_operand" "")))
11359    (set (mem:HI (match_operand:SI 0 "register_operand" ""))
11360         (match_dup 2))
11361    (parallel [(set (match_dup 0) (plus:SI (match_dup 0) (const_int 2)))
11362               (clobber (reg:CC 17))])
11363    (parallel [(set (match_dup 1) (plus:SI (match_dup 1) (const_int 2)))
11364               (clobber (reg:CC 17))])]
11365   ""
11366   "
11367 {
11368   if (TARGET_SINGLE_STRINGOP || optimize_size)
11369     {
11370       emit_insn (gen_strmovhi_1 (operands[0], operands[1], operands[0],
11371                                 operands[1]));
11372       DONE;
11373     }
11374   else 
11375     operands[2] = gen_reg_rtx (HImode);
11376 }")
11377
11378 (define_expand "strmovqi"
11379   [(set (match_dup 2)
11380         (mem:QI (match_operand:SI 1 "register_operand" "")))
11381    (set (mem:QI (match_operand:SI 0 "register_operand" ""))
11382         (match_dup 2))
11383    (parallel [(set (match_dup 0) (plus:SI (match_dup 0) (const_int 1)))
11384               (clobber (reg:CC 17))])
11385    (parallel [(set (match_dup 1) (plus:SI (match_dup 1) (const_int 1)))
11386               (clobber (reg:CC 17))])]
11387   ""
11388   "
11389 {
11390   if (TARGET_SINGLE_STRINGOP || optimize_size)
11391     {
11392       emit_insn (gen_strmovqi_1 (operands[0], operands[1], operands[0],
11393                                 operands[1]));
11394       DONE;
11395     }
11396   else 
11397     operands[2] = gen_reg_rtx (QImode);
11398 }")
11399
11400 (define_insn "strmovsi_1"
11401   [(set (mem:SI (match_operand:SI 2 "register_operand" "0"))
11402         (mem:SI (match_operand:SI 3 "register_operand" "1")))
11403    (set (match_operand:SI 0 "register_operand" "=D")
11404         (plus:SI (match_dup 2)
11405                  (const_int 4)))
11406    (set (match_operand:SI 1 "register_operand" "=S")
11407         (plus:SI (match_dup 3)
11408                  (const_int 4)))
11409    (use (reg:SI 19))]
11410   "TARGET_SINGLE_STRINGOP || optimize_size"
11411   "movsl"
11412   [(set_attr "type" "str")
11413    (set_attr "mode" "SI")
11414    (set_attr "memory" "both")])
11415
11416 (define_insn "strmovhi_1"
11417   [(set (mem:HI (match_operand:SI 2 "register_operand" "0"))
11418         (mem:HI (match_operand:SI 3 "register_operand" "1")))
11419    (set (match_operand:SI 0 "register_operand" "=D")
11420         (plus:SI (match_dup 2)
11421                  (const_int 2)))
11422    (set (match_operand:SI 1 "register_operand" "=S")
11423         (plus:SI (match_dup 3)
11424                  (const_int 2)))
11425    (use (reg:SI 19))]
11426   "TARGET_SINGLE_STRINGOP || optimize_size"
11427   "movsw"
11428   [(set_attr "type" "str")
11429    (set_attr "memory" "both")
11430    (set_attr "mode" "HI")])
11431
11432 (define_insn "strmovqi_1"
11433   [(set (mem:QI (match_operand:SI 2 "register_operand" "0"))
11434         (mem:QI (match_operand:SI 3 "register_operand" "1")))
11435    (set (match_operand:SI 0 "register_operand" "=D")
11436         (plus:SI (match_dup 2)
11437                  (const_int 1)))
11438    (set (match_operand:SI 1 "register_operand" "=S")
11439         (plus:SI (match_dup 3)
11440                  (const_int 1)))
11441    (use (reg:SI 19))]
11442   "TARGET_SINGLE_STRINGOP || optimize_size"
11443   "movsb"
11444   [(set_attr "type" "str")
11445    (set_attr "memory" "both")
11446    (set_attr "mode" "QI")])
11447
11448 (define_insn "rep_movsi"
11449   [(set (match_operand:SI 2 "register_operand" "=c") (const_int 0))
11450    (set (match_operand:SI 0 "register_operand" "=D") 
11451         (plus:SI (ashift:SI (match_operand:SI 5 "register_operand" "2")
11452                             (const_int 2))
11453                  (match_operand:SI 3 "register_operand" "0")))
11454    (set (match_operand:SI 1 "register_operand" "=S") 
11455         (plus:SI (ashift:SI (match_dup 5) (const_int 2))
11456                  (match_operand:SI 4 "register_operand" "1")))
11457    (set (mem:BLK (match_dup 3))
11458         (mem:BLK (match_dup 4)))
11459    (use (match_dup 5))
11460    (use (reg:SI 19))]
11461   ""
11462   "rep\;movsl|rep movsd"
11463   [(set_attr "type" "str")
11464    (set_attr "prefix_rep" "1")
11465    (set_attr "memory" "both")
11466    (set_attr "mode" "SI")])
11467
11468 (define_insn "rep_movqi"
11469   [(set (match_operand:SI 2 "register_operand" "=c") (const_int 0))
11470    (set (match_operand:SI 0 "register_operand" "=D") 
11471         (plus:SI (match_operand:SI 3 "register_operand" "0")
11472                  (match_operand:SI 5 "register_operand" "2")))
11473    (set (match_operand:SI 1 "register_operand" "=S") 
11474         (plus:SI (match_operand:SI 4 "register_operand" "1") (match_dup 5)))
11475    (set (mem:BLK (match_dup 3))
11476         (mem:BLK (match_dup 4)))
11477    (use (match_dup 5))
11478    (use (reg:SI 19))]
11479   ""
11480   "rep\;movsb|rep movsb"
11481   [(set_attr "type" "str")
11482    (set_attr "prefix_rep" "1")
11483    (set_attr "memory" "both")
11484    (set_attr "mode" "SI")])
11485
11486 (define_expand "clrstrsi"
11487    [(use (match_operand:BLK 0 "memory_operand" ""))
11488     (use (match_operand:SI 1 "nonmemory_operand" ""))
11489     (use (match_operand:SI 2 "const_int_operand" ""))]
11490   ""
11491   "
11492 {
11493   /* See comments in movstr expanders.  The code is mostly identical.  */
11494
11495   rtx destreg, zeroreg, countreg;
11496   int align = 0;
11497   int count = -1;
11498
11499   if (GET_CODE (operands[2]) == CONST_INT)
11500     align = INTVAL (operands[2]);
11501
11502   /* This simple hack avoids all inlining code and simplifies code bellow.  */
11503   if (!TARGET_ALIGN_STRINGOPS)
11504     align = 32;
11505
11506   if (GET_CODE (operands[1]) == CONST_INT)
11507     count = INTVAL (operands[1]);
11508
11509   destreg = copy_to_mode_reg (Pmode, XEXP (operands[0], 0));
11510
11511   emit_insn (gen_cld());
11512
11513   /* When optimizing for size emit simple rep ; movsb instruction for
11514      counts not divisible by 4.  */
11515
11516   if ((!optimize || optimize_size) 
11517       && (count < 0 || (count & 0x03)))
11518     {
11519       countreg = copy_to_mode_reg (SImode, operands[1]);
11520       zeroreg = copy_to_mode_reg (QImode, const0_rtx);
11521       emit_insn (gen_rep_stosqi (destreg, countreg, zeroreg,
11522                                  destreg, countreg));
11523     }
11524   else if (count >= 0 
11525            && (align >= 8
11526                || (!TARGET_PENTIUMPRO && align >= 4)
11527                || optimize_size || count < 64))
11528     {
11529       zeroreg = copy_to_mode_reg (SImode, const0_rtx);
11530       if (INTVAL (operands[1]) & ~0x03)
11531         {
11532           countreg = copy_to_mode_reg (SImode,
11533                                        GEN_INT ((INTVAL (operands[1]) >> 2)
11534                                                 & 0x3fffffff));
11535           emit_insn (gen_rep_stossi (destreg, countreg, zeroreg,
11536                                      destreg, countreg));
11537         }
11538       if (INTVAL (operands[1]) & 0x02)
11539         emit_insn (gen_strsethi (destreg,
11540                                  gen_rtx_SUBREG (HImode, zeroreg, 0)));
11541       if (INTVAL (operands[1]) & 0x01)
11542         emit_insn (gen_strsetqi (destreg,
11543                                  gen_rtx_SUBREG (QImode, zeroreg, 0)));
11544     }
11545   else
11546     {
11547       rtx countreg2;
11548       rtx label = NULL;
11549
11550       /* In case we don't know anything about the alignment, default to
11551          library version, since it is usually equally fast and result in
11552          shorter code.  */
11553       if (!TARGET_INLINE_ALL_STRINGOPS && align < 4)
11554         FAIL;
11555
11556       if (TARGET_SINGLE_STRINGOP)
11557         emit_insn (gen_cld());
11558
11559       countreg2 = gen_reg_rtx (SImode);
11560       countreg = copy_to_mode_reg (SImode, operands[1]);
11561       zeroreg = copy_to_mode_reg (SImode, const0_rtx);
11562
11563       if (count < 0
11564           && align < (TARGET_PENTIUMPRO && (count < 0 || count >= 260) ? 8 : 4))
11565         {
11566           label = gen_label_rtx ();
11567           emit_cmp_and_jump_insns (countreg, GEN_INT (3),
11568                                    LEU, 0, SImode, 1, 0, label);
11569         }
11570       if (align <= 1)
11571         {
11572           rtx label = gen_label_rtx ();
11573           rtx tmpcount = gen_reg_rtx (SImode);
11574           emit_insn (gen_andsi3 (tmpcount, destreg, GEN_INT (1)));
11575           emit_cmp_and_jump_insns (tmpcount, GEN_INT (0), EQ, 0,
11576                                    SImode, 1, 0, label);
11577           emit_insn (gen_strsetqi (destreg,
11578                                    gen_rtx_SUBREG (QImode, zeroreg, 0)));
11579           emit_insn (gen_addsi3 (countreg, countreg, constm1_rtx));
11580           emit_label (label);
11581           LABEL_NUSES (label) = 1;
11582         }
11583       if (align <= 2)
11584         {
11585           rtx label = gen_label_rtx ();
11586           rtx tmpcount = gen_reg_rtx (SImode);
11587           emit_insn (gen_andsi3 (tmpcount, destreg, GEN_INT (2)));
11588           emit_cmp_and_jump_insns (tmpcount, GEN_INT (0), EQ, 0,
11589                                    SImode, 1, 0, label);
11590           emit_insn (gen_strsethi (destreg,
11591                                    gen_rtx_SUBREG (HImode, zeroreg, 0)));
11592           emit_insn (gen_addsi3 (countreg, countreg, GEN_INT (-2)));
11593           emit_label (label);
11594           LABEL_NUSES (label) = 1;
11595         }
11596       if (align <= 4 && TARGET_PENTIUMPRO && (count < 1 || count >= 260))
11597         {
11598           rtx label = gen_label_rtx ();
11599           rtx tmpcount = gen_reg_rtx (SImode);
11600           emit_insn (gen_andsi3 (tmpcount, destreg, GEN_INT (4)));
11601           emit_cmp_and_jump_insns (tmpcount, GEN_INT (0), EQ, 0,
11602                                    SImode, 1, 0, label);
11603           emit_insn (gen_strsetsi (destreg, zeroreg));
11604           emit_insn (gen_addsi3 (countreg, countreg, GEN_INT (-4)));
11605           emit_label (label);
11606           LABEL_NUSES (label) = 1;
11607         }
11608
11609       if (!TARGET_SINGLE_STRINGOP)
11610         emit_insn (gen_cld());
11611       emit_insn (gen_lshrsi3 (countreg2, countreg, GEN_INT (2)));
11612       emit_insn (gen_rep_stossi (destreg, countreg2, zeroreg,
11613                                  destreg, countreg2));
11614
11615       if (label)
11616         {
11617           emit_label (label);
11618           LABEL_NUSES (label) = 1;
11619         }
11620       if (align > 2 && count > 0 && (count & 2))
11621         emit_insn (gen_strsethi (destreg,
11622                                  gen_rtx_SUBREG (HImode, zeroreg, 0)));
11623       if (align <= 2 || count < 0)
11624         {
11625           rtx label = gen_label_rtx ();
11626           rtx tmpcount = gen_reg_rtx (SImode);
11627           emit_insn (gen_andsi3 (tmpcount, countreg, GEN_INT (2)));
11628           emit_cmp_and_jump_insns (tmpcount, GEN_INT (0), EQ, 0,
11629                                    SImode, 1, 0, label);
11630           emit_insn (gen_strsethi (destreg,
11631                                    gen_rtx_SUBREG (HImode, zeroreg, 0)));
11632           emit_label (label);
11633           LABEL_NUSES (label) = 1;
11634         }
11635       if (align > 1 && count > 0 && (count & 1))
11636         emit_insn (gen_strsetqi (destreg,
11637                                  gen_rtx_SUBREG (QImode, zeroreg, 0)));
11638       if (align <= 1 || count < 0)
11639         {
11640           rtx label = gen_label_rtx ();
11641           rtx tmpcount = gen_reg_rtx (SImode);
11642           emit_insn (gen_andsi3 (tmpcount, countreg, GEN_INT (1)));
11643           emit_cmp_and_jump_insns (tmpcount, GEN_INT (0), EQ, 0,
11644                                    SImode, 1, 0, label);
11645           emit_insn (gen_strsetqi (destreg,
11646                                    gen_rtx_SUBREG (QImode, zeroreg, 0)));
11647           emit_label (label);
11648           LABEL_NUSES (label) = 1;
11649         }
11650     }
11651   DONE;
11652 }")
11653
11654 ;; Most CPUs don't like single string operations
11655 ;; Handle this case here to simplify previous expander.
11656
11657 (define_expand "strsetsi"
11658   [(set (mem:SI (match_operand:SI 0 "register_operand" ""))
11659         (match_operand:SI 1 "register_operand" ""))
11660    (parallel [(set (match_dup 0) (plus:SI (match_dup 0) (const_int 4)))
11661               (clobber (reg:CC 17))])]
11662   ""
11663   "
11664 {
11665   if (TARGET_SINGLE_STRINGOP || optimize_size)
11666     {
11667       emit_insn (gen_strsetsi_1 (operands[0], operands[0], operands[1]));
11668       DONE;
11669     }
11670 }")
11671
11672 (define_expand "strsethi"
11673   [(set (mem:HI (match_operand:SI 0 "register_operand" ""))
11674         (match_operand:HI 1 "register_operand" ""))
11675    (parallel [(set (match_dup 0) (plus:SI (match_dup 0) (const_int 2)))
11676               (clobber (reg:CC 17))])]
11677   ""
11678   "
11679 {
11680   if (TARGET_SINGLE_STRINGOP || optimize_size)
11681     {
11682       emit_insn (gen_strsethi_1 (operands[0], operands[0], operands[1]));
11683       DONE;
11684     }
11685 }")
11686
11687 (define_expand "strsetqi"
11688   [(set (mem:QI (match_operand:SI 0 "register_operand" ""))
11689         (match_operand:QI 1 "register_operand" ""))
11690    (parallel [(set (match_dup 0) (plus:SI (match_dup 0) (const_int 1)))
11691               (clobber (reg:CC 17))])]
11692   ""
11693   "
11694 {
11695   if (TARGET_SINGLE_STRINGOP || optimize_size)
11696     {
11697       emit_insn (gen_strsetqi_1 (operands[0], operands[0], operands[1]));
11698       DONE;
11699     }
11700 }")
11701
11702 (define_insn "strsetsi_1"
11703   [(set (mem:SI (match_operand:SI 1 "register_operand" "0"))
11704         (match_operand:SI 2 "register_operand" "a"))
11705    (set (match_operand:SI 0 "register_operand" "=D")
11706         (plus:SI (match_dup 1)
11707                  (const_int 4)))
11708    (use (reg:SI 19))]
11709   "TARGET_SINGLE_STRINGOP || optimize_size"
11710   "stosl"
11711   [(set_attr "type" "str")
11712    (set_attr "memory" "store")
11713    (set_attr "mode" "SI")])
11714
11715 (define_insn "strsethi_1"
11716   [(set (mem:HI (match_operand:SI 1 "register_operand" "0"))
11717         (match_operand:HI 2 "register_operand" "a"))
11718    (set (match_operand:SI 0 "register_operand" "=D")
11719         (plus:SI (match_dup 1)
11720                  (const_int 2)))
11721    (use (reg:SI 19))]
11722   "TARGET_SINGLE_STRINGOP || optimize_size"
11723   "stosw"
11724   [(set_attr "type" "str")
11725    (set_attr "memory" "store")
11726    (set_attr "mode" "HI")])
11727
11728 (define_insn "strsetqi_1"
11729   [(set (mem:QI (match_operand:SI 1 "register_operand" "0"))
11730         (match_operand:QI 2 "register_operand" "a"))
11731    (set (match_operand:SI 0 "register_operand" "=D")
11732         (plus:SI (match_dup 1)
11733                  (const_int 1)))
11734    (use (reg:SI 19))]
11735   "TARGET_SINGLE_STRINGOP || optimize_size"
11736   "stosb"
11737   [(set_attr "type" "str")
11738    (set_attr "memory" "store")
11739    (set_attr "mode" "QI")])
11740
11741 (define_insn "rep_stossi"
11742   [(set (match_operand:SI 1 "register_operand" "=c") (const_int 0))
11743    (set (match_operand:SI 0 "register_operand" "=D") 
11744         (plus:SI (ashift:SI (match_operand:SI 4 "register_operand" "1")
11745                             (const_int 2))
11746                  (match_operand:SI 3 "register_operand" "0")))
11747    (set (mem:BLK (match_dup 3))
11748         (const_int 0))
11749    (use (match_operand:SI 2 "register_operand" "a"))
11750    (use (match_dup 4))
11751    (use (reg:SI 19))]
11752   ""
11753   "rep\;stosl|rep stosd"
11754   [(set_attr "type" "str")
11755    (set_attr "prefix_rep" "1")
11756    (set_attr "memory" "store")
11757    (set_attr "mode" "SI")])
11758
11759 (define_insn "rep_stosqi"
11760   [(set (match_operand:SI 1 "register_operand" "=c") (const_int 0))
11761    (set (match_operand:SI 0 "register_operand" "=D") 
11762         (plus:SI (match_operand:SI 3 "register_operand" "0")
11763                  (match_operand:SI 4 "register_operand" "1")))
11764    (set (mem:BLK (match_dup 3))
11765         (const_int 0))
11766    (use (match_operand:QI 2 "register_operand" "a"))
11767    (use (match_dup 4))
11768    (use (reg:SI 19))]
11769   ""
11770   "rep\;stosb|rep stosb"
11771   [(set_attr "type" "str")
11772    (set_attr "prefix_rep" "1")
11773    (set_attr "memory" "store")
11774    (set_attr "mode" "QI")])
11775
11776 (define_expand "cmpstrsi"
11777   [(set (match_operand:SI 0 "register_operand" "")
11778         (compare:SI (match_operand:BLK 1 "general_operand" "")
11779                     (match_operand:BLK 2 "general_operand" "")))
11780    (use (match_operand:SI 3 "general_operand" ""))
11781    (use (match_operand:SI 4 "immediate_operand" ""))]
11782   ""
11783   "
11784 {
11785   rtx addr1, addr2, out, outlow, count, countreg, align;
11786
11787   out = operands[0];
11788   if (GET_CODE (out) != REG)
11789     out = gen_reg_rtx (SImode);
11790
11791   addr1 = copy_to_mode_reg (Pmode, XEXP (operands[1], 0));
11792   addr2 = copy_to_mode_reg (Pmode, XEXP (operands[2], 0));
11793   
11794   count = operands[3];
11795   countreg = copy_to_mode_reg (SImode, count);
11796
11797   /* %%% Iff we are testing strict equality, we can use known alignment
11798      to good advantage.  This may be possible with combine, particularly
11799      once cc0 is dead.  */
11800   align = operands[4];
11801
11802   emit_insn (gen_cld ());
11803   if (GET_CODE (count) == CONST_INT)
11804     {
11805       if (INTVAL (count) == 0)
11806         {
11807           emit_move_insn (operands[0], const0_rtx);
11808           DONE;
11809         }
11810       emit_insn (gen_cmpstrsi_nz_1 (addr1, addr2, countreg, align,
11811                                     addr1, addr2, countreg));
11812     }
11813   else
11814     {
11815       emit_insn (gen_cmpsi_1 (countreg, countreg));
11816       emit_insn (gen_cmpstrsi_1 (addr1, addr2, countreg, align,
11817                                  addr1, addr2, countreg));
11818     }
11819
11820   outlow = gen_lowpart (QImode, out);
11821   emit_insn (gen_cmpintqi (outlow));
11822   emit_move_insn (out, gen_rtx_SIGN_EXTEND (SImode, outlow));
11823
11824   if (operands[0] != out)
11825     emit_move_insn (operands[0], out);
11826
11827   DONE;
11828 }")
11829
11830 ;; Produce a tri-state integer (-1, 0, 1) from condition codes.
11831
11832 (define_expand "cmpintqi"
11833   [(set (match_dup 1)
11834         (gtu:QI (reg:CC 17) (const_int 0)))
11835    (set (match_dup 2)
11836         (ltu:QI (reg:CC 17) (const_int 0)))
11837    (parallel [(set (match_operand:QI 0 "register_operand" "")
11838                    (minus:QI (match_dup 1)
11839                              (match_dup 2)))
11840               (clobber (reg:CC 17))])]
11841   ""
11842   "operands[1] = gen_reg_rtx (QImode);
11843    operands[2] = gen_reg_rtx (QImode);")
11844
11845 ;; memcmp recognizers.  The `cmpsb' opcode does nothing if the count is
11846 ;; zero.  Emit extra code to make sure that a zero-length compare is EQ.
11847
11848 (define_insn "cmpstrsi_nz_1"
11849   [(set (reg:CC 17)
11850         (compare:CC (mem:BLK (match_operand:SI 4 "register_operand" "0"))
11851                     (mem:BLK (match_operand:SI 5 "register_operand" "1"))))
11852    (use (match_operand:SI 6 "register_operand" "2"))
11853    (use (match_operand:SI 3 "immediate_operand" "i"))
11854    (use (reg:SI 19))
11855    (clobber (match_operand:SI 0 "register_operand" "=S"))
11856    (clobber (match_operand:SI 1 "register_operand" "=D"))
11857    (clobber (match_operand:SI 2 "register_operand" "=c"))]
11858   ""
11859   "repz{\;| }cmpsb"
11860   [(set_attr "type" "str")
11861    (set_attr "mode" "QI")
11862    (set_attr "prefix_rep" "1")])
11863
11864 ;; The same, but the count is not known to not be zero.
11865
11866 (define_insn "cmpstrsi_1"
11867   [(set (reg:CC 17)
11868         (if_then_else:CC (ne (match_operand:SI 6 "register_operand" "2")
11869                              (const_int 0))
11870           (compare:CC (mem:BLK (match_operand:SI 4 "register_operand" "0"))
11871                       (mem:BLK (match_operand:SI 5 "register_operand" "1")))
11872           (const_int 0)))
11873    (use (match_operand:SI 3 "immediate_operand" "i"))
11874    (use (reg:CC 17))
11875    (use (reg:SI 19))
11876    (clobber (match_operand:SI 0 "register_operand" "=S"))
11877    (clobber (match_operand:SI 1 "register_operand" "=D"))
11878    (clobber (match_operand:SI 2 "register_operand" "=c"))]
11879   ""
11880   "repz{\;| }cmpsb"
11881   [(set_attr "type" "str")
11882    (set_attr "mode" "QI")
11883    (set_attr "prefix_rep" "1")])
11884
11885 (define_expand "strlensi"
11886   [(set (match_operand:SI 0 "register_operand" "")
11887         (unspec:SI [(match_operand:BLK 1 "general_operand" "")
11888                     (match_operand:QI 2 "immediate_operand" "")
11889                     (match_operand:SI 3 "immediate_operand" "")] 0))]
11890   ""
11891   "
11892 {
11893   rtx out, addr, scratch1, scratch2, scratch3;
11894   rtx eoschar = operands[2];
11895   rtx align = operands[3];
11896
11897   /* The generic case of strlen expander is long.  Avoid it's
11898      expanding unless TARGET_INLINE_ALL_STRINGOPS.  */
11899
11900   if (TARGET_UNROLL_STRLEN && eoschar == const0_rtx && optimize > 1
11901       && !TARGET_INLINE_ALL_STRINGOPS
11902       && !optimize_size
11903       && (GET_CODE (align) != CONST_INT || INTVAL (align) < 4))
11904     FAIL;
11905
11906   out = operands[0];
11907   addr = force_reg (Pmode, XEXP (operands[1], 0));
11908   scratch1 = gen_reg_rtx (SImode);
11909
11910   if (TARGET_UNROLL_STRLEN && eoschar == const0_rtx && optimize > 1
11911       && !optimize_size)
11912     {
11913       /* Well it seems that some optimizer does not combine a call like
11914              foo(strlen(bar), strlen(bar));
11915          when the move and the subtraction is done here.  It does calculate
11916          the length just once when these instructions are done inside of
11917          output_strlen_unroll().  But I think since &bar[strlen(bar)] is
11918          often used and I use one fewer register for the lifetime of
11919          output_strlen_unroll() this is better.  */
11920
11921       if (GET_CODE (align) != CONST_INT || INTVAL (align) < 4)
11922         emit_move_insn (scratch1, addr);
11923
11924       emit_move_insn (out, addr);
11925
11926       ix86_expand_strlensi_unroll_1 (out, align, scratch1);
11927
11928       /* strlensi_unroll_1 returns the address of the zero at the end of
11929          the string, like memchr(), so compute the length by subtracting
11930          the start address.  */
11931       emit_insn (gen_subsi3 (out, out, addr));
11932     }
11933   else
11934     {
11935       scratch2 = gen_reg_rtx (SImode);
11936       scratch3 = gen_reg_rtx (SImode);
11937
11938       emit_move_insn (scratch3, addr);
11939
11940       emit_insn (gen_cld ());
11941       emit_insn (gen_strlensi_1 (scratch1, scratch3, eoschar,
11942                                  align, constm1_rtx, scratch3));
11943       emit_insn (gen_one_cmplsi2 (scratch2, scratch1));
11944       emit_insn (gen_addsi3 (out, scratch2, constm1_rtx));
11945     }
11946   DONE;
11947 }")
11948
11949 (define_insn "strlensi_1"
11950   [(set (match_operand:SI 0 "register_operand" "=&c")
11951         (unspec:SI [(mem:BLK (match_operand:SI 5 "register_operand" "1"))
11952                     (match_operand:QI 2 "general_operand" "a")
11953                     (match_operand:SI 3 "immediate_operand" "i")
11954                     (match_operand:SI 4 "immediate_operand" "0")] 0))
11955    (use (reg:SI 19))
11956    (clobber (match_operand:SI 1 "register_operand" "=D"))
11957    (clobber (reg:CC 17))]
11958   ""
11959   "repnz{\;| }scasb"
11960   [(set_attr "type" "str")
11961    (set_attr "mode" "QI")
11962    (set_attr "prefix_rep" "1")])
11963 \f
11964 ;; Conditional move instructions.
11965
11966 (define_expand "movsicc"
11967   [(set (match_operand:SI 0 "register_operand" "")
11968         (if_then_else:SI (match_operand 1 "comparison_operator" "")
11969                          (match_operand:SI 2 "general_operand" "")
11970                          (match_operand:SI 3 "general_operand" "")))]
11971   ""
11972   "if (!ix86_expand_int_movcc (operands)) FAIL; DONE;")
11973
11974 ;; Data flow gets confused by our desire for `sbbl reg,reg', and clearing
11975 ;; the register first winds up with `sbbl $0,reg', which is also weird.
11976 ;; So just document what we're doing explicitly.
11977
11978 (define_insn "x86_movsicc_0_m1"
11979   [(set (match_operand:SI 0 "register_operand" "=r")
11980         (if_then_else:SI (ltu (reg:CC 17) (const_int 0))
11981           (const_int -1)
11982           (const_int 0)))
11983    (clobber (reg:CC 17))]
11984   ""
11985   "sbb{l}\\t%0, %0"
11986   ; Since we don't have the proper number of operands for an alu insn,
11987   ; fill in all the blanks.
11988   [(set_attr "type" "alu")
11989    (set_attr "memory" "none")
11990    (set_attr "imm_disp" "false")
11991    (set_attr "mode" "SI")
11992    (set_attr "length_immediate" "0")])
11993
11994 (define_insn "*movsicc_noc"
11995   [(set (match_operand:SI 0 "register_operand" "=r,r")
11996         (if_then_else:SI (match_operator 1 "ix86_comparison_operator" 
11997                                 [(reg 17) (const_int 0)])
11998                       (match_operand:SI 2 "nonimmediate_operand" "rm,0")
11999                       (match_operand:SI 3 "nonimmediate_operand" "0,rm")))]
12000   "TARGET_CMOVE
12001    && (GET_CODE (operands[2]) != MEM || GET_CODE (operands[3]) != MEM)"
12002   "@
12003    cmov%C1\\t{%2, %0|%0, %2}
12004    cmov%c1\\t{%3, %0|%0, %3}"
12005   [(set_attr "type" "icmov")
12006    (set_attr "mode" "SI")])
12007
12008 (define_expand "movhicc"
12009   [(set (match_operand:HI 0 "register_operand" "")
12010         (if_then_else:HI (match_operand 1 "comparison_operator" "")
12011                          (match_operand:HI 2 "nonimmediate_operand" "")
12012                          (match_operand:HI 3 "nonimmediate_operand" "")))]
12013   "TARGET_CMOVE && TARGET_HIMODE_MATH"
12014   "if (!ix86_expand_int_movcc (operands)) FAIL; DONE;")
12015
12016 (define_insn "*movhicc_noc"
12017   [(set (match_operand:HI 0 "register_operand" "=r,r")
12018         (if_then_else:HI (match_operator 1 "ix86_comparison_operator" 
12019                                 [(reg 17) (const_int 0)])
12020                       (match_operand:HI 2 "nonimmediate_operand" "rm,0")
12021                       (match_operand:HI 3 "nonimmediate_operand" "0,rm")))]
12022   "TARGET_CMOVE
12023    && (GET_CODE (operands[2]) != MEM || GET_CODE (operands[3]) != MEM)"
12024   "@
12025    cmov%C1\\t{%2, %0|%0, %2}
12026    cmov%c1\\t{%3, %0|%0, %3}"
12027   [(set_attr "type" "icmov")
12028    (set_attr "mode" "HI")])
12029
12030 (define_expand "movsfcc"
12031   [(set (match_operand:SF 0 "register_operand" "")
12032         (if_then_else:SF (match_operand 1 "comparison_operator" "")
12033                          (match_operand:SF 2 "register_operand" "")
12034                          (match_operand:SF 3 "register_operand" "")))]
12035   "TARGET_CMOVE"
12036   "if (! ix86_expand_fp_movcc (operands)) FAIL; DONE;")
12037
12038 (define_insn "*movsfcc_1"
12039   [(set (match_operand:SF 0 "register_operand" "=f,f,r,r")
12040         (if_then_else:SF (match_operator 1 "fcmov_comparison_operator" 
12041                                 [(reg 17) (const_int 0)])
12042                       (match_operand:SF 2 "nonimmediate_operand" "f,0,rm,0")
12043                       (match_operand:SF 3 "nonimmediate_operand" "0,f,0,rm")))]
12044   "TARGET_CMOVE
12045    && (GET_CODE (operands[2]) != MEM || GET_CODE (operands[3]) != MEM)"
12046   "@
12047    fcmov%F1\\t{%2, %0|%0, %2}
12048    fcmov%f1\\t{%3, %0|%0, %3}
12049    cmov%C1\\t{%2, %0|%0, %2}
12050    cmov%c1\\t{%3, %0|%0, %3}"
12051   [(set_attr "type" "fcmov,fcmov,icmov,icmov")
12052    (set_attr "mode" "SF,SF,SI,SI")])
12053
12054 (define_expand "movdfcc"
12055   [(set (match_operand:DF 0 "register_operand" "")
12056         (if_then_else:DF (match_operand 1 "comparison_operator" "")
12057                          (match_operand:DF 2 "register_operand" "")
12058                          (match_operand:DF 3 "register_operand" "")))]
12059   "TARGET_CMOVE"
12060   "if (! ix86_expand_fp_movcc (operands)) FAIL; DONE;")
12061
12062 (define_insn "*movdfcc_1"
12063   [(set (match_operand:DF 0 "register_operand" "=f,f,&r,&r")
12064         (if_then_else:DF (match_operator 1 "fcmov_comparison_operator" 
12065                                 [(reg 17) (const_int 0)])
12066                       (match_operand:DF 2 "nonimmediate_operand" "f,0,rm,0")
12067                       (match_operand:DF 3 "nonimmediate_operand" "0,f,0,rm")))]
12068   "TARGET_CMOVE
12069    && (GET_CODE (operands[2]) != MEM || GET_CODE (operands[3]) != MEM)"
12070   "@
12071    fcmov%F1\\t{%2, %0|%0, %2}
12072    fcmov%f1\\t{%3, %0|%0, %3}
12073    #
12074    #"
12075   [(set_attr "type" "fcmov,fcmov,multi,multi")
12076    (set_attr "mode" "DF")])
12077
12078 (define_split
12079   [(set (match_operand:DF 0 "register_operand" "")
12080         (if_then_else:DF (match_operator 1 "fcmov_comparison_operator" 
12081                                 [(match_operand 4 "" "") (const_int 0)])
12082                       (match_operand:DF 2 "nonimmediate_operand" "")
12083                       (match_operand:DF 3 "nonimmediate_operand" "")))]
12084   "!ANY_FP_REG_P (operands[0]) && reload_completed"
12085   [(set (match_dup 2)
12086         (if_then_else:SI (match_op_dup 1 [(match_dup 4) (const_int 0)])
12087                       (match_dup 5)
12088                       (match_dup 7)))
12089    (set (match_dup 3)
12090         (if_then_else:SI (match_op_dup 1 [(match_dup 4) (const_int 0)])
12091                       (match_dup 6)
12092                       (match_dup 8)))]
12093   "split_di (operands+2, 1, operands+5, operands+6);
12094    split_di (operands+3, 1, operands+7, operands+8);
12095    split_di (operands, 1, operands+2, operands+3);")
12096
12097 (define_expand "movxfcc"
12098   [(set (match_operand:XF 0 "register_operand" "")
12099         (if_then_else:XF (match_operand 1 "comparison_operator" "")
12100                          (match_operand:XF 2 "register_operand" "")
12101                          (match_operand:XF 3 "register_operand" "")))]
12102   "TARGET_CMOVE"
12103   "if (! ix86_expand_fp_movcc (operands)) FAIL; DONE;")
12104
12105 (define_expand "movtfcc"
12106   [(set (match_operand:TF 0 "register_operand" "")
12107         (if_then_else:TF (match_operand 1 "comparison_operator" "")
12108                          (match_operand:TF 2 "register_operand" "")
12109                          (match_operand:TF 3 "register_operand" "")))]
12110   "TARGET_CMOVE"
12111   "if (! ix86_expand_fp_movcc (operands)) FAIL; DONE;")
12112
12113 (define_insn "*movxfcc_1"
12114   [(set (match_operand:XF 0 "register_operand" "=f,f")
12115         (if_then_else:XF (match_operator 1 "fcmov_comparison_operator" 
12116                                 [(reg 17) (const_int 0)])
12117                       (match_operand:XF 2 "register_operand" "f,0")
12118                       (match_operand:XF 3 "register_operand" "0,f")))]
12119   "TARGET_CMOVE"
12120   "@
12121    fcmov%F1\\t{%2, %0|%0, %2}
12122    fcmov%f1\\t{%3, %0|%0, %3}"
12123   [(set_attr "type" "fcmov")
12124    (set_attr "mode" "XF")])
12125
12126 (define_insn "*movtfcc_1"
12127   [(set (match_operand:TF 0 "register_operand" "=f,f")
12128         (if_then_else:TF (match_operator 1 "fcmov_comparison_operator" 
12129                                 [(reg 17) (const_int 0)])
12130                       (match_operand:TF 2 "register_operand" "f,0")
12131                       (match_operand:TF 3 "register_operand" "0,f")))]
12132   "TARGET_CMOVE"
12133   "@
12134    fcmov%F1\\t{%2, %0|%0, %2}
12135    fcmov%f1\\t{%3, %0|%0, %3}"
12136   [(set_attr "type" "fcmov")
12137    (set_attr "mode" "XF")])
12138
12139 (define_expand "minsf3"
12140   [(parallel [
12141      (set (match_operand:SF 0 "register_operand" "")
12142           (if_then_else:SF (lt (match_operand:SF 1 "register_operand" "")
12143                                (match_operand:SF 2 "nonimmediate_operand" ""))
12144                            (match_dup 1)
12145                            (match_dup 2)))
12146      (clobber (reg:CC 17))])]
12147   "TARGET_SSE"
12148   "")
12149
12150 (define_insn "*minsf"
12151   [(set (match_operand:SF 0 "register_operand" "=x#f,f#x,f#x")
12152         (if_then_else:SF (lt (match_operand:SF 1 "register_operand" "0,0,f#x")
12153                              (match_operand:SF 2 "nonimmediate_operand" "xm#f,f#x,0"))
12154                          (match_dup 1)
12155                          (match_dup 2)))
12156    (clobber (reg:CC 17))]
12157   "TARGET_SSE && TARGET_IEEE_FP"
12158   "#")
12159
12160 (define_insn "*minsf_nonieee"
12161   [(set (match_operand:SF 0 "register_operand" "=x#f,f#x")
12162         (if_then_else:SF (lt (match_operand:SF 1 "register_operand" "%0,0")
12163                              (match_operand:SF 2 "nonimmediate_operand" "xm#f,fm#x"))
12164                          (match_dup 1)
12165                          (match_dup 2)))
12166    (clobber (reg:CC 17))]
12167   "TARGET_SSE && !TARGET_IEEE_FP"
12168   "#")
12169
12170 (define_split
12171   [(set (match_operand:SF 0 "register_operand" "")
12172         (if_then_else:SF (lt (match_operand:SF 1 "register_operand" "")
12173                              (match_operand:SF 2 "nonimmediate_operand" ""))
12174                          (match_dup 1)
12175                          (match_dup 2)))
12176    (clobber (reg:CC 17))]
12177   "SSE_REG_P (operands[0]) && reload_completed"
12178   [(set (match_dup 0)
12179         (if_then_else:SF (lt (match_dup 1)
12180                              (match_dup 2))
12181                          (match_dup 1)
12182                          (match_dup 2)))])
12183
12184 ;; We can't represent the LT test directly.  Do this by swapping the operands.
12185 (define_split
12186   [(set (match_operand:SF 0 "register_operand" "")
12187         (if_then_else:SF (lt (match_operand:SF 1 "register_operand" "")
12188                              (match_operand:SF 2 "register_operand" ""))
12189                          (match_dup 1)
12190                          (match_dup 2)))
12191    (clobber (reg:CC 17))]
12192   "FP_REG_P (operands[0]) && reload_completed"
12193   [(set (reg:CCFP 17)
12194         (compare:CCFP (match_dup 2)
12195                       (match_dup 1)))
12196    (set (match_dup 0)
12197         (if_then_else:SF (ge (reg:CCFP 17) (const_int 0))
12198                          (match_dup 1)
12199                          (match_dup 2)))])
12200
12201 (define_insn "*minsf_sse"
12202   [(set (match_operand:SF 0 "register_operand" "=x")
12203         (if_then_else:SF (lt (match_operand:SF 1 "register_operand" "0")
12204                              (match_operand:SF 2 "nonimmediate_operand" "xm"))
12205                          (match_dup 1)
12206                          (match_dup 2)))]
12207   "TARGET_SSE && reload_completed"
12208   "minss\\t{%2, %0|%0, %2}"
12209   [(set_attr "type" "sse")
12210    (set_attr "mode" "SF")])
12211
12212 (define_expand "mindf3"
12213   [(parallel [
12214      (set (match_operand:DF 0 "register_operand" "")
12215           (if_then_else:DF (lt (match_operand:DF 1 "register_operand" "")
12216                                (match_operand:DF 2 "nonimmediate_operand" ""))
12217                            (match_dup 1)
12218                            (match_dup 2)))
12219      (clobber (reg:CC 17))])]
12220   "TARGET_SSE2"
12221   "#")
12222
12223 (define_insn "*mindf"
12224   [(set (match_operand:DF 0 "register_operand" "=Y#f,f#Y,f#Y")
12225         (if_then_else:DF (lt (match_operand:DF 1 "register_operand" "0,0,f#Y")
12226                              (match_operand:DF 2 "nonimmediate_operand" "Ym#f,f#Y,0"))
12227                          (match_dup 1)
12228                          (match_dup 2)))
12229    (clobber (reg:CC 17))]
12230   "TARGET_SSE2 && TARGET_IEEE_FP"
12231   "#")
12232
12233 (define_insn "*mindf_nonieee"
12234   [(set (match_operand:DF 0 "register_operand" "=Y#f,f#Y")
12235         (if_then_else:DF (lt (match_operand:DF 1 "register_operand" "%0,0")
12236                              (match_operand:DF 2 "nonimmediate_operand" "Ym#f,fm#Y"))
12237                          (match_dup 1)
12238                          (match_dup 2)))
12239    (clobber (reg:CC 17))]
12240   "TARGET_SSE2 && !TARGET_IEEE_FP"
12241   "#")
12242
12243 (define_split
12244   [(set (match_operand:DF 0 "register_operand" "")
12245         (if_then_else:DF (lt (match_operand:DF 1 "register_operand" "")
12246                              (match_operand:DF 2 "nonimmediate_operand" ""))
12247                          (match_dup 1)
12248                          (match_dup 2)))
12249    (clobber (reg:CC 17))]
12250   "SSE_REG_P (operands[0]) && reload_completed"
12251   [(set (match_dup 0)
12252         (if_then_else:DF (lt (match_dup 1)
12253                              (match_dup 2))
12254                          (match_dup 1)
12255                          (match_dup 2)))])
12256
12257 ;; We can't represent the LT test directly.  Do this by swapping the operands.
12258 (define_split
12259   [(set (match_operand:DF 0 "register_operand" "")
12260         (if_then_else:DF (lt (match_operand:DF 1 "register_operand" "")
12261                              (match_operand:DF 2 "register_operand" ""))
12262                          (match_dup 1)
12263                          (match_dup 2)))
12264    (clobber (reg:CC 17))]
12265   "FP_REG_P (operands[0]) && reload_completed"
12266   [(set (reg:CCFP 17)
12267         (compare:CCFP (match_dup 2)
12268                       (match_dup 2)))
12269    (set (match_dup 0)
12270         (if_then_else:DF (ge (reg:CCFP 17) (const_int 0))
12271                          (match_dup 1)
12272                          (match_dup 2)))])
12273
12274 (define_insn "*mindf_sse"
12275   [(set (match_operand:DF 0 "register_operand" "=Y")
12276         (if_then_else:DF (lt (match_operand:DF 1 "register_operand" "0")
12277                              (match_operand:DF 2 "nonimmediate_operand" "Ym"))
12278                          (match_dup 1)
12279                          (match_dup 2)))]
12280   "TARGET_SSE2 && reload_completed"
12281   "minsd\\t{%2, %0|%0, %2}"
12282   [(set_attr "type" "sse")
12283    (set_attr "mode" "DF")])
12284
12285 (define_expand "maxsf3"
12286   [(parallel [
12287      (set (match_operand:SF 0 "register_operand" "")
12288           (if_then_else:SF (gt (match_operand:SF 1 "register_operand" "")
12289                                (match_operand:SF 2 "nonimmediate_operand" ""))
12290                            (match_dup 1)
12291                            (match_dup 2)))
12292      (clobber (reg:CC 17))])]
12293   "TARGET_SSE"
12294   "#")
12295
12296 (define_insn "*maxsf"
12297   [(set (match_operand:SF 0 "register_operand" "=x#f,f#x,f#x")
12298         (if_then_else:SF (gt (match_operand:SF 1 "register_operand" "0,0,f#x")
12299                              (match_operand:SF 2 "nonimmediate_operand" "xm#f,fm#x,0"))
12300                          (match_dup 1)
12301                          (match_dup 2)))
12302    (clobber (reg:CC 17))]
12303   "TARGET_SSE && TARGET_IEEE_FP"
12304   "#")
12305
12306 (define_insn "*maxsf_nonieee"
12307   [(set (match_operand:SF 0 "register_operand" "=x#f,f#x")
12308         (if_then_else:SF (gt (match_operand:SF 1 "register_operand" "%0,0")
12309                              (match_operand:SF 2 "nonimmediate_operand" "xm#f,fm#x"))
12310                          (match_dup 1)
12311                          (match_dup 2)))
12312    (clobber (reg:CC 17))]
12313   "TARGET_SSE && !TARGET_IEEE_FP"
12314   "#")
12315
12316 (define_split
12317   [(set (match_operand:SF 0 "register_operand" "")
12318         (if_then_else:SF (gt (match_operand:SF 1 "register_operand" "")
12319                              (match_operand:SF 2 "nonimmediate_operand" ""))
12320                          (match_dup 1)
12321                          (match_dup 2)))
12322    (clobber (reg:CC 17))]
12323   "SSE_REG_P (operands[0]) && reload_completed"
12324   [(set (match_dup 0)
12325         (if_then_else:SF (gt (match_dup 1)
12326                              (match_dup 2))
12327                          (match_dup 1)
12328                          (match_dup 2)))])
12329
12330 (define_split
12331   [(set (match_operand:SF 0 "register_operand" "")
12332         (if_then_else:SF (gt (match_operand:SF 1 "register_operand" "")
12333                              (match_operand:SF 2 "register_operand" ""))
12334                          (match_dup 1)
12335                          (match_dup 2)))
12336    (clobber (reg:CC 17))]
12337   "FP_REG_P (operands[0]) && reload_completed"
12338   [(set (reg:CCFP 17)
12339         (compare:CCFP (match_dup 1)
12340                       (match_dup 2)))
12341    (set (match_dup 0)
12342         (if_then_else:SF (gt (reg:CCFP 17) (const_int 0))
12343                          (match_dup 1)
12344                          (match_dup 2)))])
12345
12346 (define_insn "*maxsf_sse"
12347   [(set (match_operand:SF 0 "register_operand" "=x")
12348         (if_then_else:SF (gt (match_operand:SF 1 "register_operand" "0")
12349                              (match_operand:SF 2 "nonimmediate_operand" "xm"))
12350                          (match_dup 1)
12351                          (match_dup 2)))]
12352   "TARGET_SSE && reload_completed"
12353   "maxss\\t{%2, %0|%0, %2}"
12354   [(set_attr "type" "sse")
12355    (set_attr "mode" "SF")])
12356
12357 (define_expand "maxdf3"
12358   [(parallel [
12359      (set (match_operand:DF 0 "register_operand" "")
12360           (if_then_else:DF (gt (match_operand:DF 1 "register_operand" "")
12361                                (match_operand:DF 2 "nonimmediate_operand" ""))
12362                            (match_dup 1)
12363                            (match_dup 2)))
12364      (clobber (reg:CC 17))])]
12365   "TARGET_SSE2"
12366   "#")
12367
12368 (define_insn "*maxdf"
12369   [(set (match_operand:DF 0 "register_operand" "=Y#f,f#Y,f#Y")
12370         (if_then_else:DF (gt (match_operand:DF 1 "register_operand" "0,0,f#Y")
12371                              (match_operand:DF 2 "nonimmediate_operand" "Ym#f,fm#Y,0"))
12372                          (match_dup 1)
12373                          (match_dup 2)))
12374    (clobber (reg:CC 17))]
12375   "TARGET_SSE2 && TARGET_IEEE_FP"
12376   "#")
12377
12378 (define_insn "*maxdf_nonieee"
12379   [(set (match_operand:DF 0 "register_operand" "=Y#f,f#Y")
12380         (if_then_else:DF (gt (match_operand:DF 1 "register_operand" "%0,0")
12381                              (match_operand:DF 2 "nonimmediate_operand" "Ym#f,fm#Y"))
12382                          (match_dup 1)
12383                          (match_dup 2)))
12384    (clobber (reg:CC 17))]
12385   "TARGET_SSE2 && !TARGET_IEEE_FP"
12386   "#")
12387
12388 (define_split
12389   [(set (match_operand:DF 0 "register_operand" "")
12390         (if_then_else:DF (gt (match_operand:DF 1 "register_operand" "")
12391                              (match_operand:DF 2 "nonimmediate_operand" ""))
12392                          (match_dup 1)
12393                          (match_dup 2)))
12394    (clobber (reg:CC 17))]
12395   "SSE_REG_P (operands[0]) && reload_completed"
12396   [(set (match_dup 0)
12397         (if_then_else:DF (gt (match_dup 1)
12398                              (match_dup 2))
12399                          (match_dup 1)
12400                          (match_dup 2)))])
12401
12402 (define_split
12403   [(set (match_operand:DF 0 "register_operand" "")
12404         (if_then_else:DF (gt (match_operand:DF 1 "register_operand" "")
12405                              (match_operand:DF 2 "register_operand" ""))
12406                          (match_dup 1)
12407                          (match_dup 2)))
12408    (clobber (reg:CC 17))]
12409   "FP_REG_P (operands[0]) && reload_completed"
12410   [(set (reg:CCFP 17)
12411         (compare:CCFP (match_dup 1)
12412                       (match_dup 2)))
12413    (set (match_dup 0)
12414         (if_then_else:DF (gt (reg:CCFP 17) (const_int 0))
12415                          (match_dup 1)
12416                          (match_dup 2)))])
12417
12418 (define_insn "*maxdf_sse"
12419   [(set (match_operand:DF 0 "register_operand" "=Y")
12420         (if_then_else:DF (gt (match_operand:DF 1 "register_operand" "0")
12421                              (match_operand:DF 2 "nonimmediate_operand" "Ym"))
12422                          (match_dup 1)
12423                          (match_dup 2)))]
12424   "TARGET_SSE2 && reload_completed"
12425   "maxsd\\t{%2, %0|%0, %2}"
12426   [(set_attr "type" "sse")
12427    (set_attr "mode" "DF")])
12428 \f
12429 ;; Misc patterns (?)
12430
12431 ;; This pattern exists to put a dependancy on all ebp-based memory accesses.
12432 ;; Otherwise there will be nothing to keep
12433 ;; 
12434 ;; [(set (reg ebp) (reg esp))]
12435 ;; [(set (reg esp) (plus (reg esp) (const_int -160000)))
12436 ;;  (clobber (eflags)]
12437 ;; [(set (mem (plus (reg ebp) (const_int -160000))) (const_int 0))]
12438 ;;
12439 ;; in proper program order.
12440
12441 (define_insn "pro_epilogue_adjust_stack"
12442   [(set (match_operand:SI 0 "register_operand" "=r,r")
12443         (plus:SI (match_operand:SI 1 "register_operand" "0,r")
12444                  (match_operand:SI 2 "immediate_operand" "i,i")))
12445    (set (match_operand:SI 3 "register_operand" "+r,r")
12446         (match_dup 3))
12447    (clobber (reg:CC 17))]
12448   ""
12449   "*
12450 {
12451   switch (get_attr_type (insn))
12452     {
12453     case TYPE_IMOV:
12454       return \"mov{l}\\t{%1, %0|%0, %1}\";
12455
12456     case TYPE_ALU:
12457       if (GET_CODE (operands[2]) == CONST_INT
12458           && (INTVAL (operands[2]) == 128
12459               || (INTVAL (operands[2]) < 0
12460                   && INTVAL (operands[2]) != -128)))
12461         {
12462           operands[2] = GEN_INT (-INTVAL (operands[2]));
12463           return \"sub{l}\\t{%2, %0|%0, %2}\";
12464         }
12465       return \"add{l}\\t{%2, %0|%0, %2}\";
12466
12467     case TYPE_LEA:
12468       operands[2] = SET_SRC (XVECEXP (PATTERN (insn), 0, 0));
12469       return \"lea{l}\\t{%a2, %0|%0, %a2}\";
12470
12471     default:
12472       abort ();
12473     }
12474 }"
12475   [(set (attr "type")
12476         (cond [(eq_attr "alternative" "0")
12477                  (const_string "alu")
12478                (match_operand:SI 2 "const0_operand" "")
12479                  (const_string "imov")
12480               ]
12481               (const_string "lea")))
12482    (set_attr "mode" "SI")])
12483
12484 ;; Placeholder for the conditional moves.  This one is split eighter to SSE
12485 ;; based moves emulation or to usual cmove sequence.  Little bit unfortunate
12486 ;; fact is that compares supported by the cmp??ss instructions are exactly
12487 ;; swapped of those supported by cmove sequence.
12488
12489 (define_insn "sse_movsfcc"
12490   [(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")
12491         (if_then_else:SF (match_operator 1 "sse_comparison_operator"
12492                         [(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")
12493                          (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")])
12494                       (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")
12495                       (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")))
12496    (clobber (match_scratch:SF 6 "=2,&5,X,X,X,X,X,X,X,X"))
12497    (clobber (reg:CC 17))]
12498   "TARGET_SSE
12499    && (GET_CODE (operands[2]) != MEM || GET_CODE (operands[3]) != MEM)"
12500   "#")
12501
12502 (define_insn "sse_movdfcc"
12503   [(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")
12504         (if_then_else:DF (match_operator 1 "sse_comparison_operator"
12505                         [(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")
12506                          (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")])
12507                       (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")
12508                       (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")))
12509    (clobber (match_scratch:DF 6 "=2,&5,X,X,X,X,X,X,X,X"))
12510    (clobber (reg:CC 17))]
12511   "TARGET_SSE2
12512    && (GET_CODE (operands[2]) != MEM || GET_CODE (operands[3]) != MEM)"
12513   "#")
12514
12515 ;; For non-sse moves just expand the usual cmove sequence.
12516 (define_split
12517   [(set (match_operand 0 "register_operand" "")
12518         (if_then_else (match_operator 1 "comparison_operator"
12519                         [(match_operand 4 "nonimmediate_operand" "")
12520                          (match_operand 5 "register_operand" "")])
12521                       (match_operand 2 "nonimmediate_operand" "")
12522                       (match_operand 3 "nonimmediate_operand" "")))
12523    (clobber (match_operand 6 "" ""))
12524    (clobber (reg:CC 17))]
12525   "!SSE_REG_P (operands[0]) && reload_completed
12526    && VALID_SSE_REG_MODE (GET_MODE (operands[0]))"
12527   [(const_int 0)]
12528   "
12529 {
12530    ix86_compare_op0 = operands[5];
12531    ix86_compare_op1 = operands[4];
12532    operands[1] = gen_rtx_fmt_ee (swap_condition (GET_CODE (operands[1])),
12533                                  VOIDmode, operands[5], operands[4]);
12534    ix86_expand_fp_movcc (operands);
12535    DONE;
12536 }")
12537
12538 ;; Split SSE based conditional move into seqence:
12539 ;; cmpCC op0, op4   -  set op0 to 0 or ffffffff depending on the comparison
12540 ;; and   op2, op0   -  zero op2 if comparison was false
12541 ;; nand  op0, op3   -  load op3 to op0 if comparison was false
12542 ;; or    op2, op0   -  get the non-zero one into the result.
12543 (define_split
12544   [(set (match_operand 0 "register_operand" "")
12545         (if_then_else (match_operator 1 "sse_comparison_operator"
12546                         [(match_operand 4 "register_operand" "")
12547                          (match_operand 5 "nonimmediate_operand" "")])
12548                       (match_operand 2 "register_operand" "")
12549                       (match_operand 3 "register_operand" "")))
12550    (clobber (match_dup 2))
12551    (clobber (reg:CC 17))]
12552   "SSE_REG_P (operands[0]) && reload_completed"
12553   [(set (match_dup 4) (match_op_dup 1 [(match_dup 4) (match_dup 5)]))
12554    (set (subreg:TI (match_dup 2) 0) (and:TI (subreg:TI (match_dup 2) 0)
12555                                             (subreg:TI (match_dup 0) 0)))
12556    (set (subreg:TI (match_dup 4) 0) (and:TI (not:TI (subreg:TI (match_dup 0) 0))
12557                                             (subreg:TI (match_dup 3) 0)))
12558    (set (subreg:TI (match_dup 0) 0) (ior:TI (subreg:TI (match_dup 6) 0)
12559                                             (subreg:TI (match_dup 7) 0)))]
12560   "
12561 {
12562   PUT_MODE (operands[1], GET_MODE (operands[0]));
12563   if (rtx_equal_p (operands[0], operands[4]))
12564     operands[6] = operands[4], operands[7] = operands[2];
12565   else
12566     operands[6] = operands[2], operands[7] = operands[0];
12567 }")
12568
12569 ;; Special case of conditional move we can handle effectivly.
12570 ;; Do not brother with the integer/floating point case, since these are
12571 ;; bot considerably slower, unlike in the generic case.
12572 (define_insn "*sse_movsfcc_const0_1"
12573   [(set (match_operand:SF 0 "register_operand" "=x")
12574         (if_then_else:SF (match_operator 1 "sse_comparison_operator"
12575                         [(match_operand:SF 4 "register_operand" "0")
12576                          (match_operand:SF 5 "nonimmediate_operand" "xm")])
12577                       (match_operand:SF 2 "register_operand" "x")
12578                       (match_operand:SF 3 "const0_operand" "X")))]
12579   "TARGET_SSE"
12580   "#")
12581
12582 (define_insn "*sse_movsfcc_const0_2"
12583   [(set (match_operand:SF 0 "register_operand" "=x")
12584         (if_then_else:SF (match_operator 1 "sse_comparison_operator"
12585                         [(match_operand:SF 4 "register_operand" "0")
12586                          (match_operand:SF 5 "nonimmediate_operand" "xm")])
12587                       (match_operand:SF 2 "const0_operand" "x")
12588                       (match_operand:SF 3 "register_operand" "X")))]
12589   "TARGET_SSE"
12590   "#")
12591
12592 (define_insn "*sse_movsfcc_const0_3"
12593   [(set (match_operand:SF 0 "register_operand" "=x")
12594         (if_then_else:SF (match_operator 1 "fcmov_comparison_operator"
12595                         [(match_operand:SF 4 "nonimmediate_operand" "xm")
12596                          (match_operand:SF 5 "register_operand" "0")])
12597                       (match_operand:SF 2 "register_operand" "x")
12598                       (match_operand:SF 3 "const0_operand" "X")))]
12599   "TARGET_SSE"
12600   "#")
12601
12602 (define_insn "*sse_movsfcc_const0_4"
12603   [(set (match_operand:SF 0 "register_operand" "=x")
12604         (if_then_else:SF (match_operator 1 "fcmov_comparison_operator"
12605                         [(match_operand:SF 4 "nonimmediate_operand" "xm")
12606                          (match_operand:SF 5 "register_operand" "0")])
12607                       (match_operand:SF 2 "const0_operand" "x")
12608                       (match_operand:SF 3 "register_operand" "X")))]
12609   "TARGET_SSE"
12610   "#")
12611
12612 (define_insn "*sse_movdfcc_const0_1"
12613   [(set (match_operand:SF 0 "register_operand" "=x")
12614         (if_then_else:SF (match_operator 1 "sse_comparison_operator"
12615                         [(match_operand:SF 4 "register_operand" "0")
12616                          (match_operand:SF 5 "nonimmediate_operand" "xm")])
12617                       (match_operand:SF 2 "register_operand" "x")
12618                       (match_operand:SF 3 "const0_operand" "X")))]
12619   "TARGET_SSE2"
12620   "#")
12621
12622 (define_insn "*sse_movdfcc_const0_2"
12623   [(set (match_operand:SF 0 "register_operand" "=x")
12624         (if_then_else:SF (match_operator 1 "sse_comparison_operator"
12625                         [(match_operand:SF 4 "register_operand" "0")
12626                          (match_operand:SF 5 "nonimmediate_operand" "xm")])
12627                       (match_operand:SF 2 "const0_operand" "x")
12628                       (match_operand:SF 3 "register_operand" "X")))]
12629   "TARGET_SSE2"
12630   "#")
12631
12632 (define_insn "*sse_movdfcc_const0_3"
12633   [(set (match_operand:SF 0 "register_operand" "=x")
12634         (if_then_else:SF (match_operator 1 "fcmov_comparison_operator"
12635                         [(match_operand:SF 4 "nonimmediate_operand" "xm")
12636                          (match_operand:SF 5 "register_operand" "0")])
12637                       (match_operand:SF 2 "register_operand" "x")
12638                       (match_operand:SF 3 "const0_operand" "X")))]
12639   "TARGET_SSE2"
12640   "#")
12641
12642 (define_insn "*sse_movdfcc_const0_4"
12643   [(set (match_operand:SF 0 "register_operand" "=x")
12644         (if_then_else:SF (match_operator 1 "fcmov_comparison_operator"
12645                         [(match_operand:SF 4 "nonimmediate_operand" "xm")
12646                          (match_operand:SF 5 "register_operand" "0")])
12647                       (match_operand:SF 2 "const0_operand" "x")
12648                       (match_operand:SF 3 "register_operand" "X")))]
12649   "TARGET_SSE2"
12650   "#")
12651
12652 (define_split
12653   [(set (match_operand 0 "register_operand" "")
12654         (if_then_else (match_operator 1 "comparison_operator"
12655                         [(match_operand 4 "register_operand" "")
12656                          (match_operand 5 "nonimmediate_operand" "")])
12657                       (match_operand 2 "nonmemory_operand" "")
12658                       (match_operand 3 "nonmemory_operand" "")))]
12659   "SSE_REG_P (operands[0]) && reload_completed
12660    && (const0_operand (operands[2], GET_MODE (operands[0]))
12661        || const0_operand (operands[3], GET_MODE (operands[0])))"
12662   [(set (match_dup 0) (match_op_dup 1 [(match_dup 0) (match_dup 5)]))
12663    (set (subreg:TI (match_dup 0) 0) (and:TI (match_dup 6)
12664                                             (subreg:TI (match_dup 7) 0)))]
12665   "
12666 {
12667   PUT_MODE (operands[1], GET_MODE (operands[0]));
12668   if (!sse_comparison_operator (operands[1], VOIDmode))
12669     {
12670       rtx tmp = operands[5];
12671       operands[5] = operands[4];
12672       operands[4] = tmp;
12673       PUT_CODE (operands[1], swap_condition (GET_CODE (operands[1])));
12674     }
12675   if (const0_operand (operands[2], GET_MODE (operands[0])))
12676     {
12677       operands[7] = operands[3];
12678       operands[6] = gen_rtx_NOT (TImode, gen_rtx_SUBREG (TImode, operands[0],
12679                                                          0));
12680     }
12681   else
12682     {
12683       operands[7] = operands[2];
12684       operands[6] = gen_rtx_SUBREG (TImode, operands[0], 0);
12685     }
12686 }")
12687
12688 (define_insn "allocate_stack_worker"
12689   [(unspec:SI [(match_operand:SI 0 "register_operand" "a")] 3)
12690    (set (reg:SI 7) (minus:SI (reg:SI 7) (match_dup 0)))
12691    (clobber (match_dup 0))
12692    (clobber (reg:CC 17))]
12693   "TARGET_STACK_PROBE"
12694   "call\\t__alloca"
12695   [(set_attr "type" "multi")
12696    (set_attr "length" "5")])
12697
12698 (define_expand "allocate_stack"
12699   [(parallel [(set (match_operand:SI 0 "register_operand" "=r")
12700                    (minus:SI (reg:SI 7)
12701                              (match_operand:SI 1 "general_operand" "")))
12702               (clobber (reg:CC 17))])
12703    (parallel [(set (reg:SI 7)
12704                    (minus:SI (reg:SI 7) (match_dup 1)))
12705               (clobber (reg:CC 17))])]
12706   "TARGET_STACK_PROBE"
12707   "
12708 {
12709 #ifdef CHECK_STACK_LIMIT
12710   if (GET_CODE (operands[1]) == CONST_INT
12711       && INTVAL (operands[1]) < CHECK_STACK_LIMIT)
12712     emit_insn (gen_subsi3 (stack_pointer_rtx, stack_pointer_rtx,
12713                            operands[1]));
12714   else 
12715 #endif
12716     emit_insn (gen_allocate_stack_worker (copy_to_mode_reg (SImode,
12717                                                             operands[1])));
12718
12719   emit_move_insn (operands[0], virtual_stack_dynamic_rtx);
12720   DONE;
12721 }")
12722
12723 (define_expand "exception_receiver"
12724   [(const_int 0)]
12725   "flag_pic"
12726   "
12727 {
12728   load_pic_register ();
12729   DONE;
12730 }")
12731
12732 (define_expand "builtin_setjmp_receiver"
12733   [(label_ref (match_operand 0 "" ""))]
12734   "flag_pic"
12735   "
12736 {
12737   load_pic_register ();
12738   DONE;
12739 }")
12740 \f
12741 ;; Avoid redundant prefixes by splitting HImode arithmetic to SImode.
12742
12743 (define_split
12744   [(set (match_operand 0 "register_operand" "")
12745         (match_operator 3 "promotable_binary_operator"
12746            [(match_operand 1 "register_operand" "")
12747             (match_operand 2 "aligned_operand" "")]))
12748    (clobber (reg:CC 17))]
12749   "! TARGET_PARTIAL_REG_STALL && reload_completed
12750    && ((GET_MODE (operands[0]) == HImode 
12751         && (!optimize_size || GET_CODE (operands[2]) != CONST_INT
12752             || CONST_OK_FOR_LETTER_P (INTVAL (operands[2]), 'K')))
12753        || (GET_MODE (operands[0]) == QImode 
12754            && (TARGET_PROMOTE_QImode || optimize_size)))"
12755   [(parallel [(set (match_dup 0)
12756                    (match_op_dup 3 [(match_dup 1) (match_dup 2)]))
12757               (clobber (reg:CC 17))])]
12758   "operands[0] = gen_lowpart (SImode, operands[0]);
12759    operands[1] = gen_lowpart (SImode, operands[1]);
12760    if (GET_CODE (operands[3]) != ASHIFT)
12761      operands[2] = gen_lowpart (SImode, operands[2]);
12762    PUT_MODE (operands[3], SImode);")
12763
12764 (define_split
12765   [(set (reg 17)
12766         (compare (and (match_operand 1 "aligned_operand" "")
12767                       (match_operand 2 "const_int_operand" ""))
12768                  (const_int 0)))
12769    (set (match_operand 0 "register_operand" "")
12770         (and (match_dup 1) (match_dup 2)))]
12771   "! TARGET_PARTIAL_REG_STALL && reload_completed
12772    && ix86_match_ccmode (insn, CCNOmode)
12773    && (GET_MODE (operands[0]) == HImode
12774        || (GET_MODE (operands[0]) == QImode 
12775            && (TARGET_PROMOTE_QImode || optimize_size)))"
12776   [(parallel [(set (reg:CCNO 17)
12777                    (compare:CCNO (and:SI (match_dup 1) (match_dup 2))
12778                                  (const_int 0)))
12779               (set (match_dup 0)
12780                    (and:SI (match_dup 1) (match_dup 2)))])]
12781   "operands[2]
12782      = GEN_INT (INTVAL (operands[2]) & GET_MODE_MASK (GET_MODE (operands[0])));
12783    operands[0] = gen_lowpart (SImode, operands[0]);
12784    operands[1] = gen_lowpart (SImode, operands[1]);")
12785
12786 (define_split
12787   [(set (reg 17)
12788         (compare (and (match_operand 0 "aligned_operand" "")
12789                       (match_operand 1 "const_int_operand" ""))
12790                  (const_int 0)))]
12791   "! TARGET_PARTIAL_REG_STALL && reload_completed
12792    && ix86_match_ccmode (insn, CCNOmode)
12793    && (GET_MODE (operands[0]) == HImode
12794        || (GET_MODE (operands[0]) == QImode 
12795            && (TARGET_PROMOTE_QImode || optimize_size)))"
12796   [(set (reg:CCNO 17)
12797         (compare:CCNO (and:SI (match_dup 0) (match_dup 1))
12798                       (const_int 0)))]
12799   "operands[1]
12800      = GEN_INT (INTVAL (operands[1]) & GET_MODE_MASK (GET_MODE (operands[0])));
12801    operands[0] = gen_lowpart (SImode, operands[0]);")
12802
12803 (define_split
12804   [(set (match_operand 0 "register_operand" "")
12805         (neg (match_operand 1 "register_operand" "")))
12806    (clobber (reg:CC 17))]
12807   "! TARGET_PARTIAL_REG_STALL && reload_completed
12808    && (GET_MODE (operands[0]) == HImode
12809        || (GET_MODE (operands[0]) == QImode 
12810            && (TARGET_PROMOTE_QImode || optimize_size)))"
12811   [(parallel [(set (match_dup 0)
12812                    (neg:SI (match_dup 1)))
12813               (clobber (reg:CC 17))])]
12814   "operands[0] = gen_lowpart (SImode, operands[0]);
12815    operands[1] = gen_lowpart (SImode, operands[1]);")
12816
12817 (define_split
12818   [(set (match_operand 0 "register_operand" "")
12819         (not (match_operand 1 "register_operand" "")))]
12820   "! TARGET_PARTIAL_REG_STALL && reload_completed
12821    && (GET_MODE (operands[0]) == HImode
12822        || (GET_MODE (operands[0]) == QImode 
12823            && (TARGET_PROMOTE_QImode || optimize_size)))"
12824   [(set (match_dup 0)
12825         (not:SI (match_dup 1)))]
12826   "operands[0] = gen_lowpart (SImode, operands[0]);
12827    operands[1] = gen_lowpart (SImode, operands[1]);")
12828
12829 (define_split 
12830   [(set (match_operand 0 "register_operand" "")
12831         (if_then_else (match_operator 1 "comparison_operator" 
12832                                 [(reg 17) (const_int 0)])
12833                       (match_operand 2 "register_operand" "")
12834                       (match_operand 3 "register_operand" "")))]
12835   "! TARGET_PARTIAL_REG_STALL && TARGET_CMOVE
12836    && (GET_MODE (operands[0]) == HImode
12837        || (GET_MODE (operands[0]) == QImode 
12838            && (TARGET_PROMOTE_QImode || optimize_size)))"
12839   [(set (match_dup 0)
12840         (if_then_else:SI (match_dup 1) (match_dup 2) (match_dup 3)))]
12841   "operands[0] = gen_lowpart (SImode, operands[0]);
12842    operands[2] = gen_lowpart (SImode, operands[2]);
12843    operands[3] = gen_lowpart (SImode, operands[3]);")
12844                         
12845 \f
12846 ;; RTL Peephole optimizations, run before sched2.  These primarily look to
12847 ;; transform a complex memory operation into two memory to register operations.
12848
12849 ;; Don't push memory operands
12850 (define_peephole2
12851   [(set (match_operand:SI 0 "push_operand" "")
12852         (match_operand:SI 1 "memory_operand" ""))
12853    (match_scratch:SI 2 "r")]
12854   "! optimize_size && ! TARGET_PUSH_MEMORY"
12855   [(set (match_dup 2) (match_dup 1))
12856    (set (match_dup 0) (match_dup 2))]
12857   "")
12858
12859 ;; We need to handle SFmode only, because DFmode and XFmode is split to
12860 ;; SImode pushes.
12861 (define_peephole2
12862   [(set (match_operand:SF 0 "push_operand" "")
12863         (match_operand:SF 1 "memory_operand" ""))
12864    (match_scratch:SF 2 "r")]
12865   "! optimize_size && ! TARGET_PUSH_MEMORY"
12866   [(set (match_dup 2) (match_dup 1))
12867    (set (match_dup 0) (match_dup 2))]
12868   "")
12869
12870 (define_peephole2
12871   [(set (match_operand:HI 0 "push_operand" "")
12872         (match_operand:HI 1 "memory_operand" ""))
12873    (match_scratch:HI 2 "r")]
12874   "! optimize_size && ! TARGET_PUSH_MEMORY"
12875   [(set (match_dup 2) (match_dup 1))
12876    (set (match_dup 0) (match_dup 2))]
12877   "")
12878
12879 (define_peephole2
12880   [(set (match_operand:QI 0 "push_operand" "")
12881         (match_operand:QI 1 "memory_operand" ""))
12882    (match_scratch:QI 2 "q")]
12883   "! optimize_size && ! TARGET_PUSH_MEMORY"
12884   [(set (match_dup 2) (match_dup 1))
12885    (set (match_dup 0) (match_dup 2))]
12886   "")
12887
12888 ;; Don't move an immediate directly to memory when the instruction
12889 ;; gets too big.
12890 (define_peephole2
12891   [(match_scratch:SI 1 "r")
12892    (set (match_operand:SI 0 "memory_operand" "")
12893         (const_int 0))]
12894   "! optimize_size
12895    && ! TARGET_USE_MOV0
12896    && TARGET_SPLIT_LONG_MOVES
12897    && get_attr_length (insn) >= ix86_cost->large_insn
12898    && peep2_regno_dead_p (0, FLAGS_REG)"
12899   [(parallel [(set (match_dup 1) (const_int 0))
12900               (clobber (reg:CC 17))])
12901    (set (match_dup 0) (match_dup 1))]
12902   "")
12903
12904 (define_peephole2
12905   [(match_scratch:HI 1 "r")
12906    (set (match_operand:HI 0 "memory_operand" "")
12907         (const_int 0))]
12908   "! optimize_size
12909    && ! TARGET_USE_MOV0
12910    && TARGET_SPLIT_LONG_MOVES
12911    && get_attr_length (insn) >= ix86_cost->large_insn
12912    && peep2_regno_dead_p (0, FLAGS_REG)"
12913   [(parallel [(set (match_dup 2) (const_int 0))
12914               (clobber (reg:CC 17))])
12915    (set (match_dup 0) (match_dup 1))]
12916   "operands[2] = gen_rtx_REG (SImode, true_regnum (operands[1]));")
12917
12918 (define_peephole2
12919   [(match_scratch:QI 1 "q")
12920    (set (match_operand:QI 0 "memory_operand" "")
12921         (const_int 0))]
12922   "! optimize_size
12923    && ! TARGET_USE_MOV0
12924    && TARGET_SPLIT_LONG_MOVES
12925    && get_attr_length (insn) >= ix86_cost->large_insn
12926    && peep2_regno_dead_p (0, FLAGS_REG)"
12927   [(parallel [(set (match_dup 2) (const_int 0))
12928               (clobber (reg:CC 17))])
12929    (set (match_dup 0) (match_dup 1))]
12930   "operands[2] = gen_rtx_REG (SImode, true_regnum (operands[1]));")
12931
12932 (define_peephole2
12933   [(match_scratch:SI 2 "r")
12934    (set (match_operand:SI 0 "memory_operand" "")
12935         (match_operand:SI 1 "immediate_operand" ""))]
12936   "! optimize_size
12937    && get_attr_length (insn) >= ix86_cost->large_insn
12938    && TARGET_SPLIT_LONG_MOVES"
12939   [(set (match_dup 2) (match_dup 1))
12940    (set (match_dup 0) (match_dup 2))]
12941   "")
12942
12943 (define_peephole2
12944   [(match_scratch:HI 2 "r")
12945    (set (match_operand:HI 0 "memory_operand" "")
12946         (match_operand:HI 1 "immediate_operand" ""))]
12947   "! optimize_size && get_attr_length (insn) >= ix86_cost->large_insn
12948   && TARGET_SPLIT_LONG_MOVES"
12949   [(set (match_dup 2) (match_dup 1))
12950    (set (match_dup 0) (match_dup 2))]
12951   "")
12952
12953 (define_peephole2
12954   [(match_scratch:QI 2 "q")
12955    (set (match_operand:QI 0 "memory_operand" "")
12956         (match_operand:QI 1 "immediate_operand" ""))]
12957   "! optimize_size && get_attr_length (insn) >= ix86_cost->large_insn
12958   && TARGET_SPLIT_LONG_MOVES"
12959   [(set (match_dup 2) (match_dup 1))
12960    (set (match_dup 0) (match_dup 2))]
12961   "")
12962
12963 ;; Don't compare memory with zero, load and use a test instead.
12964 (define_peephole2
12965   [(set (reg 17)
12966         (compare (match_operand:SI 0 "memory_operand" "")
12967                  (const_int 0)))
12968    (match_scratch:SI 3 "r")]
12969   "ix86_match_ccmode (insn, CCNOmode) && ! optimize_size"
12970   [(set (match_dup 3) (match_dup 0))
12971    (set (reg:CCNO 17) (compare:CCNO (match_dup 3) (const_int 0)))]
12972   "")
12973
12974 ;; NOT is not pairable on Pentium, while XOR is, but one byte longer. 
12975 ;; Don't split NOTs with a displacement operand, because resulting XOR
12976 ;; will not be pariable anyway.
12977 ;;
12978 ;; On AMD K6, NOT is vector decoded with memory operand that can not be
12979 ;; represented using a modRM byte.  The XOR replacement is long decoded,
12980 ;; so this split helps here as well.
12981 ;;
12982 ;; Note: Can't do this as a regular split because we can't get proper
12983 ;; lifetime information then.
12984
12985 (define_peephole2
12986   [(set (match_operand:SI 0 "nonimmediate_operand" "=rm")
12987         (not:SI (match_operand:SI 1 "nonimmediate_operand" "0")))]
12988   "!optimize_size
12989    && peep2_regno_dead_p (0, FLAGS_REG)
12990    && ((TARGET_PENTIUM 
12991         && (GET_CODE (operands[0]) != MEM
12992             || !memory_displacement_operand (operands[0], SImode)))
12993        || (TARGET_K6 && long_memory_operand (operands[0], SImode)))"
12994   [(parallel [(set (match_dup 0)
12995                    (xor:SI (match_dup 1) (const_int -1)))
12996               (clobber (reg:CC 17))])]
12997   "")
12998
12999 (define_peephole2
13000   [(set (match_operand:HI 0 "nonimmediate_operand" "=rm")
13001         (not:HI (match_operand:HI 1 "nonimmediate_operand" "0")))]
13002   "!optimize_size
13003    && peep2_regno_dead_p (0, FLAGS_REG)
13004    && ((TARGET_PENTIUM 
13005         && (GET_CODE (operands[0]) != MEM
13006             || !memory_displacement_operand (operands[0], HImode)))
13007        || (TARGET_K6 && long_memory_operand (operands[0], HImode)))"
13008   [(parallel [(set (match_dup 0)
13009                    (xor:HI (match_dup 1) (const_int -1)))
13010               (clobber (reg:CC 17))])]
13011   "")
13012
13013 (define_peephole2
13014   [(set (match_operand:QI 0 "nonimmediate_operand" "=rm")
13015         (not:QI (match_operand:QI 1 "nonimmediate_operand" "0")))]
13016   "!optimize_size
13017    && peep2_regno_dead_p (0, FLAGS_REG)
13018    && ((TARGET_PENTIUM 
13019         && (GET_CODE (operands[0]) != MEM
13020             || !memory_displacement_operand (operands[0], QImode)))
13021        || (TARGET_K6 && long_memory_operand (operands[0], QImode)))"
13022   [(parallel [(set (match_dup 0)
13023                    (xor:QI (match_dup 1) (const_int -1)))
13024               (clobber (reg:CC 17))])]
13025   "")
13026
13027 ;; Non pairable "test imm, reg" instructions can be translated to
13028 ;; "and imm, reg" if reg dies.  The "and" form is also shorter (one
13029 ;; byte opcode instead of two, have a short form for byte operands),
13030 ;; so do it for other CPUs as well.  Given that the value was dead,
13031 ;; this should not create any new dependancies.  Pass on the sub-word
13032 ;; versions if we're concerned about partial register stalls.
13033
13034 (define_peephole2
13035   [(set (reg 17)
13036         (compare (and:SI (match_operand:SI 0 "register_operand" "")
13037                          (match_operand:SI 1 "immediate_operand" ""))
13038                  (const_int 0)))]
13039   "ix86_match_ccmode (insn, CCNOmode)
13040    && (true_regnum (operands[0]) != 0
13041        || CONST_OK_FOR_LETTER_P (INTVAL (operands[1]), 'K'))
13042    && find_regno_note (insn, REG_DEAD, true_regnum (operands[0]))"
13043   [(parallel
13044      [(set (reg:CCNO 17)
13045            (compare:CCNO (and:SI (match_dup 0)
13046                                  (match_dup 1))
13047                          (const_int 0)))
13048       (set (match_dup 0)
13049            (and:SI (match_dup 0) (match_dup 1)))])]
13050   "")
13051
13052 ;; We don't need to handle HImode case, because it will be promoted to SImode
13053 ;; on ! TARGET_PARTIAL_REG_STALL
13054
13055 (define_peephole2
13056   [(set (reg 17)
13057         (compare (and:QI (match_operand:QI 0 "register_operand" "")
13058                          (match_operand:QI 1 "immediate_operand" ""))
13059                  (const_int 0)))]
13060   "! TARGET_PARTIAL_REG_STALL
13061    && ix86_match_ccmode (insn, CCNOmode)
13062    && true_regnum (operands[0]) != 0
13063    && find_regno_note (insn, REG_DEAD, true_regnum (operands[0]))"
13064   [(parallel
13065      [(set (reg:CCNO 17)
13066            (compare:CCNO (and:QI (match_dup 0)
13067                                  (match_dup 1))
13068                          (const_int 0)))
13069       (set (match_dup 0)
13070            (and:QI (match_dup 0) (match_dup 1)))])]
13071   "")
13072
13073 (define_peephole2
13074   [(set (reg 17)
13075         (compare
13076           (and:SI
13077             (zero_extract:SI
13078               (match_operand 0 "ext_register_operand" "q")
13079               (const_int 8)
13080               (const_int 8))
13081             (match_operand 1 "const_int_operand" "n"))
13082           (const_int 0)))]
13083   "! TARGET_PARTIAL_REG_STALL
13084    && ix86_match_ccmode (insn, CCNOmode)
13085    && true_regnum (operands[0]) != 0
13086    && find_regno_note (insn, REG_DEAD, true_regnum (operands[0]))"
13087   [(parallel [(set (reg:CCNO 17)
13088                    (compare:CCNO
13089                        (and:SI
13090                          (zero_extract:SI
13091                          (match_dup 0)
13092                          (const_int 8)
13093                          (const_int 8))
13094                         (match_dup 1))
13095                    (const_int 0)))
13096               (set (zero_extract:SI (match_dup 0)
13097                                     (const_int 8)
13098                                     (const_int 8))
13099                    (and:SI 
13100                      (zero_extract:SI
13101                        (match_dup 0)
13102                        (const_int 8)
13103                        (const_int 8))
13104                      (match_dup 1)))])]
13105   "")
13106
13107 ;; Don't do logical operations with memory inputs.
13108 (define_peephole2
13109   [(match_scratch:SI 2 "r")
13110    (parallel [(set (match_operand:SI 0 "register_operand" "")
13111                    (match_operator:SI 3 "arith_or_logical_operator"
13112                      [(match_dup 0)
13113                       (match_operand:SI 1 "memory_operand" "")]))
13114               (clobber (reg:CC 17))])]
13115   "! optimize_size && ! TARGET_READ_MODIFY"
13116   [(set (match_dup 2) (match_dup 1))
13117    (parallel [(set (match_dup 0)
13118                    (match_op_dup 3 [(match_dup 0) (match_dup 2)]))
13119               (clobber (reg:CC 17))])]
13120   "")
13121
13122 (define_peephole2
13123   [(match_scratch:SI 2 "r")
13124    (parallel [(set (match_operand:SI 0 "register_operand" "")
13125                    (match_operator:SI 3 "arith_or_logical_operator"
13126                      [(match_operand:SI 1 "memory_operand" "")
13127                       (match_dup 0)]))
13128               (clobber (reg:CC 17))])]
13129   "! optimize_size && ! TARGET_READ_MODIFY"
13130   [(set (match_dup 2) (match_dup 1))
13131    (parallel [(set (match_dup 0)
13132                    (match_op_dup 3 [(match_dup 2) (match_dup 0)]))
13133               (clobber (reg:CC 17))])]
13134   "")
13135
13136 ; Don't do logical operations with memory outputs
13137 ;
13138 ; These two don't make sense for PPro/PII -- we're expanding a 4-uop
13139 ; instruction into two 1-uop insns plus a 2-uop insn.  That last has
13140 ; the same decoder scheduling characteristics as the original.
13141
13142 (define_peephole2
13143   [(match_scratch:SI 2 "r")
13144    (parallel [(set (match_operand:SI 0 "memory_operand" "")
13145                    (match_operator:SI 3 "arith_or_logical_operator"
13146                      [(match_dup 0)
13147                       (match_operand:SI 1 "nonmemory_operand" "")]))
13148               (clobber (reg:CC 17))])]
13149   "! optimize_size && ! TARGET_READ_MODIFY_WRITE"
13150   [(set (match_dup 2) (match_dup 0))
13151    (parallel [(set (match_dup 2)
13152                    (match_op_dup 3 [(match_dup 2) (match_dup 1)]))
13153               (clobber (reg:CC 17))])
13154    (set (match_dup 0) (match_dup 2))]
13155   "")
13156
13157 (define_peephole2
13158   [(match_scratch:SI 2 "r")
13159    (parallel [(set (match_operand:SI 0 "memory_operand" "")
13160                    (match_operator:SI 3 "arith_or_logical_operator"
13161                      [(match_operand:SI 1 "nonmemory_operand" "")
13162                       (match_dup 0)]))
13163               (clobber (reg:CC 17))])]
13164   "! optimize_size && ! TARGET_READ_MODIFY_WRITE"
13165   [(set (match_dup 2) (match_dup 0))
13166    (parallel [(set (match_dup 2)
13167                    (match_op_dup 3 [(match_dup 1) (match_dup 2)]))
13168               (clobber (reg:CC 17))])
13169    (set (match_dup 0) (match_dup 2))]
13170   "")
13171
13172 ;; Attempt to always use XOR for zeroing registers.
13173 (define_peephole2
13174   [(set (match_operand 0 "register_operand" "")
13175         (const_int 0))]
13176   "(GET_MODE (operands[0]) == QImode
13177     || GET_MODE (operands[0]) == HImode
13178     || GET_MODE (operands[0]) == SImode)
13179    && (! TARGET_USE_MOV0 || optimize_size)
13180    && peep2_regno_dead_p (0, FLAGS_REG)"
13181   [(parallel [(set (match_dup 0) (const_int 0))
13182               (clobber (reg:CC 17))])]
13183   "operands[0] = gen_rtx_REG (SImode, true_regnum (operands[0]));")
13184
13185 (define_peephole2
13186   [(set (strict_low_part (match_operand 0 "register_operand" ""))
13187         (const_int 0))]
13188   "(GET_MODE (operands[0]) == QImode
13189     || GET_MODE (operands[0]) == HImode)
13190    && (! TARGET_USE_MOV0 || optimize_size)
13191    && peep2_regno_dead_p (0, FLAGS_REG)"
13192   [(parallel [(set (strict_low_part (match_dup 0)) (const_int 0))
13193               (clobber (reg:CC 17))])])
13194
13195 ;; For HI and SI modes, or $-1,reg is smaller than mov $-1,reg.
13196 (define_peephole2
13197   [(set (match_operand 0 "register_operand" "")
13198         (const_int -1))]
13199   "(GET_MODE (operands[0]) == HImode
13200     || GET_MODE (operands[0]) == SImode)
13201    && (optimize_size || TARGET_PENTIUM)
13202    && peep2_regno_dead_p (0, FLAGS_REG)"
13203   [(parallel [(set (match_dup 0) (const_int -1))
13204               (clobber (reg:CC 17))])]
13205   "operands[0] = gen_rtx_REG (SImode, true_regnum (operands[0]));")
13206
13207 ;; Attempt to convert simple leas to adds. These can be created by
13208 ;; move expanders.
13209 (define_peephole2
13210   [(set (match_operand:SI 0 "register_operand" "")
13211         (plus:SI (match_dup 0)
13212                  (match_operand:SI 1 "nonmemory_operand" "")))]
13213   "peep2_regno_dead_p (0, FLAGS_REG)"
13214   [(parallel [(set (match_dup 0) (plus:SI (match_dup 0) (match_dup 1)))
13215               (clobber (reg:CC 17))])]
13216   "")
13217
13218 (define_peephole2
13219   [(set (match_operand:SI 0 "register_operand" "")
13220         (mult:SI (match_dup 0)
13221                  (match_operand:SI 1 "immediate_operand" "")))]
13222   "exact_log2 (INTVAL (operands[1])) >= 0
13223    && peep2_regno_dead_p (0, FLAGS_REG)"
13224   [(parallel [(set (match_dup 0) (ashift:SI (match_dup 0) (match_dup 2)))
13225               (clobber (reg:CC 17))])]
13226   "operands[2] = GEN_INT (exact_log2 (INTVAL (operands[1])));")
13227
13228 ;; The ESP adjustments can be done by the push and pop instructions.  Resulting
13229 ;; code is shorter, since push is only 1 byte, while add imm, %esp 3 bytes.  On
13230 ;; many CPUs it is also faster, since special hardware to avoid esp
13231 ;; dependancies is present.
13232
13233 ;; While some of these converisons may be done using splitters, we use peepholes
13234 ;; in order to allow combine_stack_adjustments pass to see nonobfuscated RTL.
13235
13236 ;; Convert prologue esp substractions to push.
13237 ;; We need register to push.  In order to keep verify_flow_info happy we have
13238 ;; two choices
13239 ;; - use scratch and clobber it in order to avoid dependencies
13240 ;; - use already live register
13241 ;; We can't use the second way right now, since there is no reliable way how to
13242 ;; verify that given register is live.  First choice will also most likely in
13243 ;; fewer dependencies.  On the place of esp adjustments it is very likely that
13244 ;; call clobbered registers are dead.  We may want to use base pointer as an
13245 ;; alternative when no register is available later.
13246
13247 (define_peephole2
13248   [(match_scratch:SI 0 "r")
13249    (parallel [(set (reg:SI 7) (plus:SI (reg:SI 7) (const_int -4)))
13250               (set (reg:SI 6) (reg:SI 6))
13251               (clobber (reg:CC 17))])]
13252   "optimize_size || !TARGET_SUB_ESP_4"
13253   [(clobber (match_dup 0))
13254    (parallel [(set (mem:SI (pre_dec:SI (reg:SI 7))) (match_dup 0))
13255               (set (reg:SI 6) (reg:SI 6))])])
13256
13257 (define_peephole2
13258   [(match_scratch:SI 0 "r")
13259    (parallel [(set (reg:SI 7) (plus:SI (reg:SI 7) (const_int -8)))
13260               (set (reg:SI 6) (reg:SI 6))
13261               (clobber (reg:CC 17))])]
13262   "optimize_size || !TARGET_SUB_ESP_8"
13263   [(clobber (match_dup 0))
13264    (set (mem:SI (pre_dec:SI (reg:SI 7))) (match_dup 0))
13265    (parallel [(set (mem:SI (pre_dec:SI (reg:SI 7))) (match_dup 0))
13266               (set (reg:SI 6) (reg:SI 6))])])
13267
13268 ;; Convert esp substractions to push.
13269 (define_peephole2
13270   [(match_scratch:SI 0 "r")
13271    (parallel [(set (reg:SI 7) (plus:SI (reg:SI 7) (const_int -4)))
13272               (clobber (reg:CC 17))])]
13273   "optimize_size || !TARGET_SUB_ESP_4"
13274   [(clobber (match_dup 0))
13275    (set (mem:SI (pre_dec:SI (reg:SI 7))) (match_dup 0))])
13276
13277 (define_peephole2
13278   [(match_scratch:SI 0 "r")
13279    (parallel [(set (reg:SI 7) (plus:SI (reg:SI 7) (const_int -8)))
13280               (clobber (reg:CC 17))])]
13281   "optimize_size || !TARGET_SUB_ESP_8"
13282   [(clobber (match_dup 0))
13283    (set (mem:SI (pre_dec:SI (reg:SI 7))) (match_dup 0))
13284    (set (mem:SI (pre_dec:SI (reg:SI 7))) (match_dup 0))])
13285
13286 ;; Convert epilogue deallocator to pop.
13287 (define_peephole2
13288   [(match_scratch:SI 0 "r")
13289    (parallel [(set (reg:SI 7) (plus:SI (reg:SI 7) (const_int 4)))
13290               (set (reg:SI 6) (reg:SI 6))
13291               (clobber (reg:CC 17))])]
13292   "optimize_size || !TARGET_ADD_ESP_4"
13293   [(parallel [(set (match_dup 0) (mem:SI (reg:SI 7)))
13294               (set (reg:SI 7) (plus:SI (reg:SI 7) (const_int 4)))
13295               (set (reg:SI 6) (reg:SI 6))])]
13296   "")
13297
13298 ;; Two pops case is tricky, since pop causes dependency on destination register.
13299 ;; We use two registers if available.
13300 (define_peephole2
13301   [(match_scratch:SI 0 "r")
13302    (match_scratch:SI 1 "r")
13303    (parallel [(set (reg:SI 7) (plus:SI (reg:SI 7) (const_int 8)))
13304               (set (reg:SI 6) (reg:SI 6))
13305               (clobber (reg:CC 17))])]
13306   "optimize_size || !TARGET_ADD_ESP_8"
13307   [(parallel [(set (match_dup 0) (mem:SI (reg:SI 7)))
13308               (set (reg:SI 7) (plus:SI (reg:SI 7) (const_int 4)))
13309               (set (reg:SI 6) (reg:SI 6))])
13310    (parallel [(set (match_dup 1) (mem:SI (reg:SI 7)))
13311               (set (reg:SI 7) (plus:SI (reg:SI 7) (const_int 4)))])]
13312   "")
13313
13314 (define_peephole2
13315   [(match_scratch:SI 0 "r")
13316    (parallel [(set (reg:SI 7) (plus:SI (reg:SI 7) (const_int 8)))
13317               (set (reg:SI 6) (reg:SI 6))
13318               (clobber (reg:CC 17))])]
13319   "optimize_size"
13320   [(parallel [(set (match_dup 0) (mem:SI (reg:SI 7)))
13321               (set (reg:SI 7) (plus:SI (reg:SI 7) (const_int 4)))
13322               (set (reg:SI 6) (reg:SI 6))])
13323    (parallel [(set (match_dup 0) (mem:SI (reg:SI 7)))
13324               (set (reg:SI 7) (plus:SI (reg:SI 7) (const_int 4)))])]
13325   "")
13326
13327 ;; Convert esp additions to pop.
13328 (define_peephole2
13329   [(match_scratch:SI 0 "r")
13330    (parallel [(set (reg:SI 7) (plus:SI (reg:SI 7) (const_int 4)))
13331               (clobber (reg:CC 17))])]
13332   ""
13333   [(parallel [(set (match_dup 0) (mem:SI (reg:SI 7)))
13334               (set (reg:SI 7) (plus:SI (reg:SI 7) (const_int 4)))])]
13335   "")
13336
13337 ;; Two pops case is tricky, since pop causes dependency on destination register.
13338 ;; We use two registers if available.
13339 (define_peephole2
13340   [(match_scratch:SI 0 "r")
13341    (match_scratch:SI 1 "r")
13342    (parallel [(set (reg:SI 7) (plus:SI (reg:SI 7) (const_int 8)))
13343               (clobber (reg:CC 17))])]
13344   ""
13345   [(parallel [(set (match_dup 0) (mem:SI (reg:SI 7)))
13346               (set (reg:SI 7) (plus:SI (reg:SI 7) (const_int 4)))])
13347    (parallel [(set (match_dup 1) (mem:SI (reg:SI 7)))
13348               (set (reg:SI 7) (plus:SI (reg:SI 7) (const_int 4)))])]
13349   "")
13350
13351 (define_peephole2
13352   [(match_scratch:SI 0 "r")
13353    (parallel [(set (reg:SI 7) (plus:SI (reg:SI 7) (const_int 8)))
13354               (clobber (reg:CC 17))])]
13355   "optimize_size"
13356   [(parallel [(set (match_dup 0) (mem:SI (reg:SI 7)))
13357               (set (reg:SI 7) (plus:SI (reg:SI 7) (const_int 4)))])
13358    (parallel [(set (match_dup 0) (mem:SI (reg:SI 7)))
13359               (set (reg:SI 7) (plus:SI (reg:SI 7) (const_int 4)))])]
13360   "")
13361 \f
13362 ;; Convert compares with 1 to shorter inc/dec operations when CF is not
13363 ;; required and register dies.
13364 (define_peephole2
13365   [(set (reg 17)
13366         (compare (match_operand:SI 0 "register_operand" "")
13367                  (match_operand:SI 1 "incdec_operand" "")))]
13368   "ix86_match_ccmode (insn, CCGCmode)
13369    && find_regno_note (insn, REG_DEAD, true_regnum (operands[0]))"
13370   [(parallel [(set (reg:CCGC 17)
13371                    (compare:CCGC (match_dup 0)
13372                                  (match_dup 1)))
13373               (clobber (match_dup 0))])]
13374   "")
13375
13376 (define_peephole2
13377   [(set (reg 17)
13378         (compare (match_operand:HI 0 "register_operand" "")
13379                  (match_operand:HI 1 "incdec_operand" "")))]
13380   "ix86_match_ccmode (insn, CCGCmode)
13381    && find_regno_note (insn, REG_DEAD, true_regnum (operands[0]))"
13382   [(parallel [(set (reg:CCGC 17)
13383                    (compare:CCGC (match_dup 0)
13384                                  (match_dup 1)))
13385               (clobber (match_dup 0))])]
13386   "")
13387
13388 (define_peephole2
13389   [(set (reg 17)
13390         (compare (match_operand:QI 0 "register_operand" "")
13391                  (match_operand:QI 1 "incdec_operand" "")))]
13392   "ix86_match_ccmode (insn, CCGCmode)
13393    && find_regno_note (insn, REG_DEAD, true_regnum (operands[0]))"
13394   [(parallel [(set (reg:CCGC 17)
13395                    (compare:CCGC (match_dup 0)
13396                                  (match_dup 1)))
13397               (clobber (match_dup 0))])]
13398   "")
13399
13400 ;; Convert compares with 128 to shorter add -128
13401 (define_peephole2
13402   [(set (reg 17)
13403         (compare (match_operand:SI 0 "register_operand" "")
13404                  (const_int 128)))]
13405   "ix86_match_ccmode (insn, CCGCmode)
13406    && find_regno_note (insn, REG_DEAD, true_regnum (operands[0]))"
13407   [(parallel [(set (reg:CCGC 17)
13408                    (compare:CCGC (match_dup 0)
13409                                  (const_int 128)))
13410               (clobber (match_dup 0))])]
13411   "")
13412
13413 (define_peephole2
13414   [(set (reg 17)
13415         (compare (match_operand:HI 0 "register_operand" "")
13416                  (const_int 128)))]
13417   "ix86_match_ccmode (insn, CCGCmode)
13418    && find_regno_note (insn, REG_DEAD, true_regnum (operands[0]))"
13419   [(parallel [(set (reg:CCGC 17)
13420                    (compare:CCGC (match_dup 0)
13421                                  (const_int 128)))
13422               (clobber (match_dup 0))])]
13423   "")
13424 \f
13425 ;; Call-value patterns last so that the wildcard operand does not
13426 ;; disrupt insn-recog's switch tables.
13427
13428 (define_insn "*call_value_pop_0"
13429   [(set (match_operand 0 "" "")
13430         (call (mem:QI (match_operand:SI 1 "constant_call_address_operand" ""))
13431               (match_operand:SI 2 "" "")))
13432    (set (reg:SI 7) (plus:SI (reg:SI 7)
13433                             (match_operand:SI 3 "immediate_operand" "")))]
13434   ""
13435   "*
13436 {
13437   if (SIBLING_CALL_P (insn))
13438     return \"jmp\\t%P1\";
13439   else
13440     return \"call\\t%P1\";
13441 }"
13442   [(set_attr "type" "callv")])
13443
13444 (define_insn "*call_value_pop_1"
13445   [(set (match_operand 0 "" "")
13446         (call (mem:QI (match_operand:SI 1 "call_insn_operand" "rsm"))
13447               (match_operand:SI 2 "" "")))
13448    (set (reg:SI 7) (plus:SI (reg:SI 7)
13449                             (match_operand:SI 3 "immediate_operand" "i")))]
13450   ""
13451   "*
13452 {
13453   if (constant_call_address_operand (operands[1], QImode))
13454     {
13455       if (SIBLING_CALL_P (insn))
13456         return \"jmp\\t%P1\";
13457       else
13458         return \"call\\t%P1\";
13459     }
13460   if (SIBLING_CALL_P (insn))
13461     return \"jmp\\t%A1\";
13462   else
13463     return \"call\\t%A1\";
13464 }"
13465   [(set_attr "type" "callv")])
13466
13467 (define_insn "*call_value_0"
13468   [(set (match_operand 0 "" "")
13469         (call (mem:QI (match_operand:SI 1 "constant_call_address_operand" ""))
13470               (match_operand:SI 2 "" "")))]
13471   ""
13472   "*
13473 {
13474   if (SIBLING_CALL_P (insn))
13475     return \"jmp\\t%P1\";
13476   else
13477     return \"call\\t%P1\";
13478 }"
13479   [(set_attr "type" "callv")])
13480
13481 (define_insn "*call_value_1"
13482   [(set (match_operand 0 "" "")
13483         (call (mem:QI (match_operand:SI 1 "call_insn_operand" "rsm"))
13484               (match_operand:SI 2 "" "")))]
13485   ""
13486   "*
13487 {
13488   if (constant_call_address_operand (operands[1], QImode))
13489     {
13490       if (SIBLING_CALL_P (insn))
13491         return \"jmp\\t%P1\";
13492       else
13493         return \"call\\t%P1\";
13494     }
13495   if (SIBLING_CALL_P (insn))
13496     return \"jmp\\t%A1\";
13497   else
13498     return \"call\\t%A1\";
13499 }"
13500   [(set_attr "type" "callv")])
13501 \f
13502 (define_insn "trap"
13503   [(trap_if (const_int 1) (const_int 5))]
13504   ""
13505   "int\\t$5")
13506
13507 ;;; ix86 doesn't have conditional trap instructions, but we fake them
13508 ;;; for the sake of bounds checking.  By emitting bounds checks as
13509 ;;; conditional traps rather than as conditional jumps around
13510 ;;; unconditional traps we avoid introducing spurious basic-block
13511 ;;; boundaries and facilitate elimination of redundant checks.  In
13512 ;;; honor of the too-inflexible-for-BPs `bound' instruction, we use
13513 ;;; interrupt 5.
13514 ;;; 
13515 ;;; FIXME: Static branch prediction rules for ix86 are such that
13516 ;;; forward conditional branches predict as untaken.  As implemented
13517 ;;; below, pseudo conditional traps violate that rule.  We should use
13518 ;;; .pushsection/.popsection to place all of the `int 5's in a special
13519 ;;; section loaded at the end of the text segment and branch forward
13520 ;;; there on bounds-failure, and then jump back immediately (in case
13521 ;;; the system chooses to ignore bounds violations, or to report
13522 ;;; violations and continue execution).
13523
13524 (define_expand "conditional_trap"
13525   [(trap_if (match_operator 0 "comparison_operator"
13526              [(match_dup 2) (const_int 0)])
13527             (match_operand 1 "const_int_operand" ""))]
13528   ""
13529   "
13530 {
13531   emit_insn (gen_rtx_TRAP_IF (VOIDmode,
13532                               ix86_expand_compare (GET_CODE (operands[0]),
13533                                                    NULL_RTX, NULL_RTX),
13534                               operands[1]));
13535   DONE;
13536 }")
13537
13538 (define_insn ""
13539   [(trap_if (match_operator 0 "comparison_operator"
13540              [(reg 17) (const_int 0)])
13541             (match_operand 1 "const_int_operand" ""))]
13542   ""
13543   "*
13544 {
13545   operands[2] = gen_label_rtx ();
13546   output_asm_insn (\"j%c0\\t%l2\; int\\t%1\", operands);
13547   ASM_OUTPUT_INTERNAL_LABEL (asm_out_file, \"L\",
13548                              CODE_LABEL_NUMBER (operands[2]));
13549   RET;
13550 }")
13551
13552         ;; Pentium III SIMD instructions.
13553
13554 ;; Moves for SSE/MMX regs.
13555
13556 (define_insn "movv4sf_internal"
13557   [(set (match_operand:V4SF 0 "nonimmediate_operand" "=x,m")
13558         (match_operand:V4SF 1 "general_operand" "xm,x"))]
13559   "TARGET_SSE"
13560   ;; @@@ let's try to use movaps here.
13561   "movaps\\t{%1, %0|%0, %1}"
13562   [(set_attr "type" "sse")])
13563
13564 (define_insn "movv4si_internal"
13565   [(set (match_operand:V4SI 0 "nonimmediate_operand" "=x,m")
13566         (match_operand:V4SI 1 "general_operand" "xm,x"))]
13567   "TARGET_SSE"
13568   ;; @@@ let's try to use movaps here.
13569   "movaps\\t{%1, %0|%0, %1}"
13570   [(set_attr "type" "sse")])
13571
13572 (define_insn "movv8qi_internal"
13573   [(set (match_operand:V8QI 0 "nonimmediate_operand" "=y,m")
13574         (match_operand:V8QI 1 "general_operand" "ym,y"))]
13575   "TARGET_MMX"
13576   "movq\\t{%1, %0|%0, %1}"
13577   [(set_attr "type" "mmx")])
13578
13579 (define_insn "movv4hi_internal"
13580   [(set (match_operand:V4HI 0 "nonimmediate_operand" "=y,m")
13581         (match_operand:V4HI 1 "general_operand" "ym,y"))]
13582   "TARGET_MMX"
13583   "movq\\t{%1, %0|%0, %1}"
13584   [(set_attr "type" "mmx")])
13585
13586 (define_insn "movv2si_internal"
13587   [(set (match_operand:V2SI 0 "nonimmediate_operand" "=y,m")
13588         (match_operand:V2SI 1 "general_operand" "ym,y"))]
13589   "TARGET_MMX"
13590   "movq\\t{%1, %0|%0, %1}"
13591   [(set_attr "type" "mmx")])
13592
13593 (define_expand "movti"
13594   [(set (match_operand:TI 0 "general_operand" "")
13595         (match_operand:TI 1 "general_operand" ""))]
13596   "TARGET_SSE"
13597   "
13598 {
13599   /* For constants other than zero into memory.  We do not know how the
13600      instructions used to build constants modify the upper 64 bits
13601      of the register, once we have that information we may be able
13602      to handle some of them more efficiently.  */
13603   if ((reload_in_progress | reload_completed) == 0
13604       && register_operand (operands[0], TImode)
13605       && CONSTANT_P (operands[1]))
13606     {
13607       rtx addr = gen_reg_rtx (Pmode);
13608
13609       emit_move_insn (addr, XEXP (force_const_mem (TImode, operands[1]), 0));
13610       operands[1] = gen_rtx_MEM (TImode, addr);
13611     }
13612
13613   /* Make operand1 a register if it isn't already.  */
13614   if ((reload_in_progress | reload_completed) == 0
13615       && !register_operand (operands[0], TImode)
13616       && !register_operand (operands[1], TImode)
13617       && operands[1] != CONST0_RTX (TImode))
13618     {
13619       rtx temp = force_reg (TImode, operands[1]);
13620       emit_move_insn (operands[0], temp);
13621       DONE;
13622     }
13623 }")
13624
13625 (define_expand "movv4sf"
13626   [(set (match_operand:V4SF 0 "general_operand" "")
13627         (match_operand:V4SF 1 "general_operand" ""))]
13628   "TARGET_SSE"
13629   "
13630 {
13631   /* For constants other than zero into memory.  We do not know how the
13632      instructions used to build constants modify the upper 64 bits
13633      of the register, once we have that information we may be able
13634      to handle some of them more efficiently.  */
13635   if ((reload_in_progress | reload_completed) == 0
13636       && register_operand (operands[0], V4SFmode)
13637       && CONSTANT_P (operands[1]))
13638     {
13639       rtx addr = gen_reg_rtx (Pmode);
13640
13641       emit_move_insn (addr, XEXP (force_const_mem (V4SFmode, operands[1]), 0));
13642       operands[1] = gen_rtx_MEM (V4SFmode, addr);
13643     }
13644
13645   /* Make operand1 a register if it isn't already.  */
13646   if ((reload_in_progress | reload_completed) == 0
13647       && !register_operand (operands[0], V4SFmode)
13648       && !register_operand (operands[1], V4SFmode)
13649       && operands[1] != CONST0_RTX (V4SFmode))
13650     {
13651       rtx temp = force_reg (V4SFmode, operands[1]);
13652       emit_move_insn (operands[0], temp);
13653       DONE;
13654     }
13655 }")
13656
13657 (define_expand "movv4si"
13658   [(set (match_operand:V4SI 0 "general_operand" "")
13659         (match_operand:V4SI 1 "general_operand" ""))]
13660   "TARGET_MMX"
13661   "
13662 {
13663   /* For constants other than zero into memory.  We do not know how the
13664      instructions used to build constants modify the upper 64 bits
13665      of the register, once we have that information we may be able
13666      to handle some of them more efficiently.  */
13667   if ((reload_in_progress | reload_completed) == 0
13668       && register_operand (operands[0], V4SImode)
13669       && CONSTANT_P (operands[1]))
13670     {
13671       rtx addr = gen_reg_rtx (Pmode);
13672
13673       emit_move_insn (addr, XEXP (force_const_mem (V4SImode, operands[1]), 0));
13674       operands[1] = gen_rtx_MEM (V4SImode, addr);
13675     }
13676
13677   /* Make operand1 a register if it isn't already.  */
13678   if ((reload_in_progress | reload_completed) == 0
13679       && !register_operand (operands[0], V4SImode)
13680       && !register_operand (operands[1], V4SImode)
13681       && operands[1] != CONST0_RTX (V4SImode))
13682     {
13683       rtx temp = force_reg (V4SImode, operands[1]);
13684       emit_move_insn (operands[0], temp);
13685       DONE;
13686     }
13687 }")
13688
13689 (define_expand "movv2si"
13690   [(set (match_operand:V2SI 0 "general_operand" "")
13691         (match_operand:V2SI 1 "general_operand" ""))]
13692   "TARGET_MMX"
13693   "
13694 {
13695   /* For constants other than zero into memory.  We do not know how the
13696      instructions used to build constants modify the upper 64 bits
13697      of the register, once we have that information we may be able
13698      to handle some of them more efficiently.  */
13699   if ((reload_in_progress | reload_completed) == 0
13700       && register_operand (operands[0], V2SImode)
13701       && CONSTANT_P (operands[1]))
13702     {
13703       rtx addr = gen_reg_rtx (Pmode);
13704
13705       emit_move_insn (addr, XEXP (force_const_mem (V2SImode, operands[1]), 0));
13706       operands[1] = gen_rtx_MEM (V2SImode, addr);
13707     }
13708
13709   /* Make operand1 a register if it isn't already.  */
13710   if ((reload_in_progress | reload_completed) == 0
13711       && !register_operand (operands[0], V2SImode)
13712       && !register_operand (operands[1], V2SImode)
13713       && operands[1] != CONST0_RTX (V2SImode))
13714     {
13715       rtx temp = force_reg (V2SImode, operands[1]);
13716       emit_move_insn (operands[0], temp);
13717       DONE;
13718     }
13719 }")
13720
13721 (define_expand "movv4hi"
13722   [(set (match_operand:V4HI 0 "general_operand" "")
13723         (match_operand:V4HI 1 "general_operand" ""))]
13724   "TARGET_MMX"
13725   "
13726 {
13727   /* For constants other than zero into memory.  We do not know how the
13728      instructions used to build constants modify the upper 64 bits
13729      of the register, once we have that information we may be able
13730      to handle some of them more efficiently.  */
13731   if ((reload_in_progress | reload_completed) == 0
13732       && register_operand (operands[0], V4HImode)
13733       && CONSTANT_P (operands[1]))
13734     {
13735       rtx addr = gen_reg_rtx (Pmode);
13736
13737       emit_move_insn (addr, XEXP (force_const_mem (V4HImode, operands[1]), 0));
13738       operands[1] = gen_rtx_MEM (V4HImode, addr);
13739     }
13740
13741   /* Make operand1 a register if it isn't already.  */
13742   if ((reload_in_progress | reload_completed) == 0
13743       && !register_operand (operands[0], V4HImode)
13744       && !register_operand (operands[1], V4HImode)
13745       && operands[1] != CONST0_RTX (V4HImode))
13746     {
13747       rtx temp = force_reg (V4HImode, operands[1]);
13748       emit_move_insn (operands[0], temp);
13749       DONE;
13750     }
13751 }")
13752
13753 (define_expand "movv8qi"
13754   [(set (match_operand:V8QI 0 "general_operand" "")
13755         (match_operand:V8QI 1 "general_operand" ""))]
13756   "TARGET_MMX"
13757   "
13758 {
13759   /* For constants other than zero into memory.  We do not know how the
13760      instructions used to build constants modify the upper 64 bits
13761      of the register, once we have that information we may be able
13762      to handle some of them more efficiently.  */
13763   if ((reload_in_progress | reload_completed) == 0
13764       && register_operand (operands[0], V8QImode)
13765       && CONSTANT_P (operands[1]))
13766     {
13767       rtx addr = gen_reg_rtx (Pmode);
13768
13769       emit_move_insn (addr, XEXP (force_const_mem (V8QImode, operands[1]), 0));
13770       operands[1] = gen_rtx_MEM (V8QImode, addr);
13771     }
13772
13773   /* Make operand1 a register if it isn't already.  */
13774   if ((reload_in_progress | reload_completed) == 0
13775       && !register_operand (operands[0], V8QImode)
13776       && !register_operand (operands[1], V8QImode)
13777       && operands[1] != CONST0_RTX (V8QImode))
13778     {
13779       rtx temp = force_reg (V8QImode, operands[1]);
13780       emit_move_insn (operands[0], temp);
13781       DONE;
13782     }
13783 }")
13784
13785 (define_insn_and_split "*pushti"
13786   [(set (match_operand:TI 0 "push_operand" "=<")
13787         (match_operand:TI 1 "nonmemory_operand" "x"))]
13788   "TARGET_SSE"
13789   "#"
13790   ""
13791   [(set (reg:SI 7) (plus:SI (reg:SI 7) (const_int -16)))
13792    (set (mem:TI (reg:SI 7)) (match_dup 1))]
13793   ""
13794   [(set_attr "type" "sse")])
13795
13796 (define_insn_and_split "*pushv4sf"
13797   [(set (match_operand:V4SF 0 "push_operand" "=<")
13798         (match_operand:V4SF 1 "nonmemory_operand" "x"))]
13799   "TARGET_SSE"
13800   "#"
13801   ""
13802   [(set (reg:SI 7) (plus:SI (reg:SI 7) (const_int -16)))
13803    (set (mem:V4SF (reg:SI 7)) (match_dup 1))]
13804   ""
13805   [(set_attr "type" "sse")])
13806
13807 (define_insn_and_split "*pushv4si"
13808   [(set (match_operand:V4SI 0 "push_operand" "=<")
13809         (match_operand:V4SI 1 "nonmemory_operand" "x"))]
13810   "TARGET_SSE"
13811   "#"
13812   ""
13813   [(set (reg:SI 7) (plus:SI (reg:SI 7) (const_int -16)))
13814    (set (mem:V4SI (reg:SI 7)) (match_dup 1))]
13815   ""
13816   [(set_attr "type" "sse")])
13817
13818 (define_insn_and_split "*pushv2si"
13819   [(set (match_operand:V2SI 0 "push_operand" "=<")
13820         (match_operand:V2SI 1 "nonmemory_operand" "y"))]
13821   "TARGET_MMX"
13822   "#"
13823   ""
13824   [(set (reg:SI 7) (plus:SI (reg:SI 7) (const_int -8)))
13825    (set (mem:V2SI (reg:SI 7)) (match_dup 1))]
13826   ""
13827   [(set_attr "type" "mmx")])
13828
13829 (define_insn_and_split "*pushv4hi"
13830   [(set (match_operand:V4HI 0 "push_operand" "=<")
13831         (match_operand:V4HI 1 "nonmemory_operand" "y"))]
13832   "TARGET_MMX"
13833   "#"
13834   ""
13835   [(set (reg:SI 7) (plus:SI (reg:SI 7) (const_int -8)))
13836    (set (mem:V4HI (reg:SI 7)) (match_dup 1))]
13837   ""
13838   [(set_attr "type" "mmx")])
13839
13840 (define_insn_and_split "*pushv8qi"
13841   [(set (match_operand:V8QI 0 "push_operand" "=<")
13842         (match_operand:V8QI 1 "nonmemory_operand" "y"))]
13843   "TARGET_MMX"
13844   "#"
13845   ""
13846   [(set (reg:SI 7) (plus:SI (reg:SI 7) (const_int -8)))
13847    (set (mem:V8QI (reg:SI 7)) (match_dup 1))]
13848   ""
13849   [(set_attr "type" "mmx")])
13850
13851 (define_insn "movti_internal"
13852   [(set (match_operand:TI 0 "nonimmediate_operand" "=x,m")
13853         (match_operand:TI 1 "general_operand" "xm,x"))]
13854   "TARGET_SSE"
13855   "@
13856    movaps\\t{%1, %0|%0, %1}
13857    movaps\\t{%1, %0|%0, %1}"
13858   [(set_attr "type" "sse")])
13859
13860 ;; These two patterns are useful for specifying exactly whether to use
13861 ;; movaps or movups
13862 (define_insn "sse_movaps"
13863   [(set (match_operand:V4SF 0 "nonimmediate_operand" "=x,m")
13864         (unspec:V4SF [(match_operand:V4SF 1 "general_operand" "xm,x")] 38))]
13865   "TARGET_SSE"
13866   "@
13867    movaps\\t{%1, %0|%0, %1}
13868    movaps\\t{%1, %0|%0, %1}"
13869   [(set_attr "type" "sse")])
13870
13871 (define_insn "sse_movups"
13872   [(set (match_operand:V4SF 0 "nonimmediate_operand" "=x,m")
13873         (unspec:V4SF [(match_operand:V4SF 1 "general_operand" "xm,x")] 39))]
13874   "TARGET_SSE"
13875   "@
13876    movups\\t{%1, %0|%0, %1}
13877    movups\\t{%1, %0|%0, %1}"
13878   [(set_attr "type" "sse")])
13879
13880
13881 ;; SSE Strange Moves.
13882
13883 (define_insn "sse_movmskps"
13884   [(set (match_operand:SI 0 "register_operand" "=r")
13885         (unspec:SI [(match_operand:V4SF 1 "register_operand" "x")] 33))]
13886   "TARGET_SSE"
13887   "movmskps\\t{%1, %0|%0, %1}"
13888   [(set_attr "type" "sse")])
13889
13890 (define_insn "mmx_pmovmskb"
13891   [(set (match_operand:SI 0 "register_operand" "=r")
13892         (unspec:SI [(match_operand:V8QI 1 "register_operand" "y")] 33))]
13893   "TARGET_SSE"
13894   "pmovmskb\\t{%1, %0|%0, %1}"
13895   [(set_attr "type" "sse")])
13896
13897 (define_insn "mmx_maskmovq"
13898   [(set (mem:V8QI (match_operand:SI 0 "register_operand" "D"))
13899         (unspec:V8QI [(match_operand:V8QI 1 "register_operand" "y")
13900                       (match_operand:V8QI 2 "register_operand" "y")] 32))]
13901   "TARGET_SSE"
13902   ;; @@@ check ordering of operands in intel/nonintel syntax
13903   "maskmovq\\t{%2, %1|%1, %2}"
13904   [(set_attr "type" "sse")])
13905
13906 (define_insn "sse_movntv4sf"
13907   [(set (match_operand:V4SF 0 "memory_operand" "=m")
13908         (unspec:V4SF [(match_operand:V4SF 1 "register_operand" "x")] 34))]
13909   "TARGET_SSE"
13910   "movntps\\t{%1, %0|%0, %1}"
13911   [(set_attr "type" "sse")])
13912
13913 (define_insn "sse_movntdi"
13914   [(set (match_operand:DI 0 "memory_operand" "=m")
13915         (unspec:DI [(match_operand:DI 1 "register_operand" "y")] 34))]
13916   "TARGET_SSE"
13917   "movntq\\t{%1, %0|%0, %1}"
13918   [(set_attr "type" "sse")])
13919
13920 (define_insn "sse_movhlps"
13921   [(set (match_operand:V4SF 0 "register_operand" "=x")
13922         (vec_merge:V4SF
13923          (match_operand:V4SF 1 "register_operand" "0")
13924          (vec_select:V4SF (match_operand:V4SF 2 "register_operand" "x")
13925                           (parallel [(const_int 2)
13926                                      (const_int 3)
13927                                      (const_int 0)
13928                                      (const_int 1)]))
13929          (const_int 3)))]
13930   "TARGET_SSE"
13931   "movhlps\\t{%2, %0|%0, %2}"
13932   [(set_attr "type" "sse")])
13933
13934 (define_insn "sse_movlhps"
13935   [(set (match_operand:V4SF 0 "register_operand" "=x")
13936         (vec_merge:V4SF
13937          (match_operand:V4SF 1 "register_operand" "0")
13938          (vec_select:V4SF (match_operand:V4SF 2 "register_operand" "x")
13939                           (parallel [(const_int 2)
13940                                      (const_int 3)
13941                                      (const_int 0)
13942                                      (const_int 1)]))
13943          (const_int 12)))]
13944   "TARGET_SSE"
13945   "movlhps\\t{%2, %0|%0, %2}"
13946   [(set_attr "type" "sse")])
13947
13948 (define_insn "sse_movhps"
13949   [(set (match_operand:V4SF 0 "nonimmediate_operand" "=x,m")
13950         (vec_merge:V4SF
13951          (match_operand:V4SF 1 "nonimmediate_operand" "0,0")
13952          (match_operand:V4SF 2 "nonimmediate_operand" "m,x")
13953          (const_int 12)))]
13954   "TARGET_SSE && (GET_CODE (operands[1]) == MEM || GET_CODE (operands[2]) == MEM)"
13955   "movhps\\t{%2, %0|%0, %2}"
13956   [(set_attr "type" "sse")])
13957
13958 (define_insn "sse_movlps"
13959   [(set (match_operand:V4SF 0 "nonimmediate_operand" "=x,m")
13960         (vec_merge:V4SF
13961          (match_operand:V4SF 1 "nonimmediate_operand" "0,0")
13962          (match_operand:V4SF 2 "nonimmediate_operand" "m,x")
13963          (const_int 3)))]
13964   "TARGET_SSE && (GET_CODE (operands[1]) == MEM || GET_CODE (operands[2]) == MEM)"
13965   "movlps\\t{%2, %0|%0, %2}"
13966   [(set_attr "type" "sse")])
13967
13968 (define_insn "sse_loadss"
13969   [(set (match_operand:V4SF 0 "register_operand" "=x")
13970         (vec_merge:V4SF
13971          (match_operand:V4SF 1 "memory_operand" "m")
13972          (vec_duplicate:V4SF (float:SF (const_int 0)))
13973          (const_int 1)))]
13974   "TARGET_SSE"
13975   "movss\\t{%1, %0|%0, %1}"
13976   [(set_attr "type" "sse")])
13977
13978 (define_insn "sse_movss"
13979   [(set (match_operand:V4SF 0 "register_operand" "=x")
13980         (vec_merge:V4SF
13981          (match_operand:V4SF 1 "register_operand" "0")
13982          (match_operand:V4SF 2 "register_operand" "x")
13983          (const_int 1)))]
13984   "TARGET_SSE"
13985   "movss\\t{%2, %0|%0, %2}"
13986   [(set_attr "type" "sse")])
13987
13988 (define_insn "sse_storess"
13989   [(set (match_operand:SF 0 "memory_operand" "=m")
13990         (vec_select:SF
13991          (match_operand:V4SF 1 "register_operand" "x")
13992          (parallel [(const_int 0)])))]
13993   "TARGET_SSE"
13994   "movss\\t{%1, %0|%0, %1}"
13995   [(set_attr "type" "sse")])
13996
13997 (define_insn "sse_shufps"
13998   [(set (match_operand:V4SF 0 "register_operand" "=x")
13999         (unspec:V4SF [(match_operand:V4SF 1 "register_operand" "0")
14000                       (match_operand:V4SF 2 "nonimmediate_operand" "xm")
14001                       (match_operand:SI 3 "immediate_operand" "i")] 41))]
14002   "TARGET_SSE"
14003   ;; @@@ check operand order for intel/nonintel syntax
14004   "shufps\\t{%3, %2, %0|%0, %2, %3}"
14005   [(set_attr "type" "sse")])
14006
14007
14008 ;; SSE arithmetic
14009
14010 (define_insn "addv4sf3"
14011   [(set (match_operand:V4SF 0 "register_operand" "=x")
14012         (plus:V4SF (match_operand:V4SF 1 "register_operand" "0")
14013                    (match_operand:V4SF 2 "nonimmediate_operand" "xm")))]
14014   "TARGET_SSE"
14015   "addps\\t{%2, %0|%0, %2}"
14016   [(set_attr "type" "sse")])
14017
14018 (define_insn "vmaddv4sf3"
14019   [(set (match_operand:V4SF 0 "register_operand" "=x")
14020         (vec_merge:V4SF (plus:V4SF (match_operand:V4SF 1 "register_operand" "0")
14021                                    (match_operand:V4SF 2 "nonimmediate_operand" "xm"))
14022                         (match_dup 1)
14023                         (const_int 1)))]
14024   "TARGET_SSE"
14025   "addss\\t{%2, %0|%0, %2}"
14026   [(set_attr "type" "sse")])
14027
14028 (define_insn "subv4sf3"
14029   [(set (match_operand:V4SF 0 "register_operand" "=x")
14030         (minus:V4SF (match_operand:V4SF 1 "register_operand" "0")
14031                    (match_operand:V4SF 2 "nonimmediate_operand" "xm")))]
14032   "TARGET_SSE"
14033   "subps\\t{%2, %0|%0, %2}"
14034   [(set_attr "type" "sse")])
14035
14036 (define_insn "vmsubv4sf3"
14037   [(set (match_operand:V4SF 0 "register_operand" "=x")
14038         (vec_merge:V4SF (minus:V4SF (match_operand:V4SF 1 "register_operand" "0")
14039                                    (match_operand:V4SF 2 "nonimmediate_operand" "xm"))
14040                         (match_dup 1)
14041                         (const_int 1)))]
14042   "TARGET_SSE"
14043   "subss\\t{%2, %0|%0, %2}"
14044   [(set_attr "type" "sse")])
14045
14046 (define_insn "mulv4sf3"
14047   [(set (match_operand:V4SF 0 "register_operand" "=x")
14048         (mult:V4SF (match_operand:V4SF 1 "register_operand" "0")
14049                    (match_operand:V4SF 2 "nonimmediate_operand" "xm")))]
14050   "TARGET_SSE"
14051   "mulps\\t{%2, %0|%0, %2}"
14052   [(set_attr "type" "sse")])
14053
14054 (define_insn "vmmulv4sf3"
14055   [(set (match_operand:V4SF 0 "register_operand" "=x")
14056         (vec_merge:V4SF (mult:V4SF (match_operand:V4SF 1 "register_operand" "0")
14057                                    (match_operand:V4SF 2 "nonimmediate_operand" "xm"))
14058                         (match_dup 1)
14059                         (const_int 1)))]
14060   "TARGET_SSE"
14061   "mulss\\t{%2, %0|%0, %2}"
14062   [(set_attr "type" "sse")])
14063
14064 (define_insn "divv4sf3"
14065   [(set (match_operand:V4SF 0 "register_operand" "=x")
14066         (div:V4SF (match_operand:V4SF 1 "register_operand" "0")
14067                   (match_operand:V4SF 2 "nonimmediate_operand" "xm")))]
14068   "TARGET_SSE"
14069   "divps\\t{%2, %0|%0, %2}"
14070   [(set_attr "type" "sse")])
14071
14072 (define_insn "vmdivv4sf3"
14073   [(set (match_operand:V4SF 0 "register_operand" "=x")
14074         (vec_merge:V4SF (div:V4SF (match_operand:V4SF 1 "register_operand" "0")
14075                                   (match_operand:V4SF 2 "nonimmediate_operand" "xm"))
14076                         (match_dup 1)
14077                         (const_int 1)))]
14078   "TARGET_SSE"
14079   "divss\\t{%2, %0|%0, %2}"
14080   [(set_attr "type" "sse")])
14081
14082
14083 ;; SSE square root/reciprocal
14084
14085 (define_insn "rcpv4sf2"
14086   [(set (match_operand:V4SF 0 "register_operand" "=x")
14087         (unspec:V4SF [(match_operand:V4SF 1 "register_operand" "xm")] 42))]
14088   "TARGET_SSE"
14089   "rcpps\\t{%1, %0|%0, %1}"
14090   [(set_attr "type" "sse")])
14091
14092 (define_insn "vmrcpv4sf2"
14093   [(set (match_operand:V4SF 0 "register_operand" "=x")
14094         (vec_merge:V4SF (unspec:V4SF [(match_operand:V4SF 1 "register_operand" "xm")] 42)
14095                         (match_operand:V4SF 2 "register_operand" "0")
14096                         (const_int 1)))]
14097   "TARGET_SSE"
14098   "rcpss\\t{%1, %0|%0, %1}"
14099   [(set_attr "type" "sse")])
14100
14101 (define_insn "rsqrtv4sf2"
14102   [(set (match_operand:V4SF 0 "register_operand" "=x")
14103         (unspec:V4SF [(match_operand:V4SF 1 "register_operand" "xm")] 43))]
14104   "TARGET_SSE"
14105   "rsqrtps\\t{%1, %0|%0, %1}"
14106   [(set_attr "type" "sse")])
14107
14108 (define_insn "vmrsqrtv4sf2"
14109   [(set (match_operand:V4SF 0 "register_operand" "=x")
14110         (vec_merge:V4SF (unspec:V4SF [(match_operand:V4SF 1 "register_operand" "xm")] 43)
14111                         (match_operand:V4SF 2 "register_operand" "0")
14112                         (const_int 1)))]
14113   "TARGET_SSE"
14114   "rsqrtss\\t{%1, %0|%0, %1}"
14115   [(set_attr "type" "sse")])
14116
14117 (define_insn "sqrtv4sf2"
14118   [(set (match_operand:V4SF 0 "register_operand" "=x")
14119         (sqrt:V4SF (match_operand:V4SF 1 "register_operand" "xm")))]
14120   "TARGET_SSE"
14121   "sqrtps\\t{%1, %0|%0, %1}"
14122   [(set_attr "type" "sse")])
14123
14124 (define_insn "vmsqrtv4sf2"
14125   [(set (match_operand:V4SF 0 "register_operand" "=x")
14126         (vec_merge:V4SF (sqrt:V4SF (match_operand:V4SF 1 "register_operand" "xm"))
14127                         (match_operand:V4SF 2 "register_operand" "0")
14128                         (const_int 1)))]
14129   "TARGET_SSE"
14130   "sqrtss\\t{%1, %0|%0, %1}"
14131   [(set_attr "type" "sse")])
14132
14133
14134 ;; SSE logical operations.
14135
14136 ;; These are not called andti3 etc. because we really really don't want
14137 ;; the compiler to widen DImode ands to TImode ands and then try to move
14138 ;; into DImode subregs of SSE registers, and them together, and move out
14139 ;; of DImode subregs again!
14140
14141 (define_insn "*sse_andti3_df_1"
14142   [(set (subreg:TI (match_operand:DF 0 "register_operand" "=Y") 0)
14143         (and:TI (subreg:TI (match_operand:DF 1 "register_operand" "%0") 0)
14144                 (subreg:TI (match_operand:DF 2 "register_operand" "Y") 0)))]
14145   "TARGET_SSE2"
14146   "andpd\\t{%2, %0|%0, %2}"
14147   [(set_attr "type" "sse")])
14148
14149 (define_insn "*sse_andti3_df_2"
14150   [(set (subreg:TI (match_operand:DF 0 "register_operand" "=Y") 0)
14151         (and:TI (subreg:TI (match_operand:DF 1 "register_operand" "0") 0)
14152                 (match_operand:TI 2 "nonimmediate_operand" "Ym")))]
14153   "TARGET_SSE2"
14154   "andpd\\t{%2, %0|%0, %2}"
14155   [(set_attr "type" "sse")])
14156
14157 (define_insn "*sse_andti3_sf_1"
14158   [(set (subreg:TI (match_operand:SF 0 "register_operand" "=x") 0)
14159         (and:TI (subreg:TI (match_operand:SF 1 "register_operand" "%0") 0)
14160                 (subreg:TI (match_operand:SF 2 "register_operand" "x") 0)))]
14161   "TARGET_SSE"
14162   "andps\\t{%2, %0|%0, %2}"
14163   [(set_attr "type" "sse")])
14164
14165 (define_insn "*sse_andti3_sf_2"
14166   [(set (subreg:TI (match_operand:SF 0 "register_operand" "=x") 0)
14167         (and:TI (subreg:TI (match_operand:SF 1 "register_operand" "0") 0)
14168                 (match_operand:TI 2 "nonimmediate_operand" "xm")))]
14169   "TARGET_SSE"
14170   "andps\\t{%2, %0|%0, %2}"
14171   [(set_attr "type" "sse")])
14172
14173 (define_insn "sse_andti3"
14174   [(set (match_operand:TI 0 "register_operand" "=x")
14175         (and:TI (match_operand:TI 1 "register_operand" "%0")
14176                 (match_operand:TI 2 "nonimmediate_operand" "xm")))]
14177   "TARGET_SSE && !TARGET_SSE2"
14178   "andps\\t{%2, %0|%0, %2}"
14179   [(set_attr "type" "sse")])
14180
14181 (define_insn "*sse_andti3_sse2"
14182   [(set (match_operand:TI 0 "register_operand" "=x")
14183         (and:TI (match_operand:TI 1 "register_operand" "%0")
14184                 (match_operand:TI 2 "nonimmediate_operand" "xm")))]
14185   "TARGET_SSE2"
14186   "pand\\t{%2, %0|%0, %2}"
14187   [(set_attr "type" "sse")])
14188
14189 (define_insn "*sse_nandti3_df"
14190   [(set (subreg:TI (match_operand:DF 0 "register_operand" "=Y") 0)
14191         (and:TI (not:TI (subreg:TI (match_operand:DF 1 "register_operand" "0") 0))
14192                 (match_operand:TI 2 "nonimmediate_operand" "Ym")))]
14193   "TARGET_SSE2"
14194   "andnpd\\t{%2, %0|%0, %2}"
14195   [(set_attr "type" "sse")])
14196
14197 (define_insn "*sse_nandti3_sf"
14198   [(set (subreg:TI (match_operand:SF 0 "register_operand" "=x") 0)
14199         (and:TI (not:TI (subreg:TI (match_operand:SF 1 "register_operand" "0") 0))
14200                 (match_operand:TI 2 "nonimmediate_operand" "xm")))]
14201   "TARGET_SSE"
14202   "andnps\\t{%2, %0|%0, %2}"
14203   [(set_attr "type" "sse")])
14204
14205 (define_insn "sse_nandti3"
14206   [(set (match_operand:TI 0 "register_operand" "=x")
14207         (and:TI (not:TI (match_operand:TI 1 "register_operand" "0"))
14208                 (match_operand:TI 2 "nonimmediate_operand" "xm")))]
14209   "TARGET_SSE && !TARGET_SSE2"
14210   "andnps\\t{%2, %0|%0, %2}"
14211   [(set_attr "type" "sse")])
14212
14213 (define_insn "*sse_nandti3_sse2"
14214   [(set (match_operand:TI 0 "register_operand" "=x")
14215         (and:TI (not:TI (match_operand:TI 1 "register_operand" "0"))
14216                 (match_operand:TI 2 "nonimmediate_operand" "xm")))]
14217   "TARGET_SSE2"
14218   "pnand\\t{%2, %0|%0, %2}"
14219   [(set_attr "type" "sse")])
14220
14221 (define_insn "*sse_iorti3_df_1"
14222   [(set (subreg:TI (match_operand:DF 0 "register_operand" "=Y") 0)
14223         (ior:TI (subreg:TI (match_operand:DF 1 "register_operand" "%0") 0)
14224                 (subreg:TI (match_operand:DF 2 "register_operand" "Y") 0)))]
14225   "TARGET_SSE2"
14226   "orpd\\t{%2, %0|%0, %2}"
14227   [(set_attr "type" "sse")])
14228
14229 (define_insn "*sse_iorti3_df_2"
14230   [(set (subreg:TI (match_operand:DF 0 "register_operand" "=Y") 0)
14231         (ior:TI (subreg:TI (match_operand:DF 1 "register_operand" "0") 0)
14232                 (match_operand:TI 2 "nonimmediate_operand" "Ym")))]
14233   "TARGET_SSE2"
14234   "orpd\\t{%2, %0|%0, %2}"
14235   [(set_attr "type" "sse")])
14236
14237 (define_insn "*sse_iorti3_sf_1"
14238   [(set (subreg:TI (match_operand:SF 0 "register_operand" "=x") 0)
14239         (ior:TI (subreg:TI (match_operand:SF 1 "register_operand" "%0") 0)
14240                 (subreg:TI (match_operand:SF 2 "register_operand" "x") 0)))]
14241   "TARGET_SSE"
14242   "orps\\t{%2, %0|%0, %2}"
14243   [(set_attr "type" "sse")])
14244
14245 (define_insn "*sse_iorti3_sf_2"
14246   [(set (subreg:TI (match_operand:SF 0 "register_operand" "=x") 0)
14247         (ior:TI (subreg:TI (match_operand:SF 1 "register_operand" "0") 0)
14248                 (match_operand:TI 2 "nonimmediate_operand" "xm")))]
14249   "TARGET_SSE"
14250   "orps\\t{%2, %0|%0, %2}"
14251   [(set_attr "type" "sse")])
14252
14253 (define_insn "sse_iorti3"
14254   [(set (match_operand:TI 0 "register_operand" "=x")
14255         (ior:TI (match_operand:TI 1 "register_operand" "%0")
14256                 (match_operand:TI 2 "nonimmediate_operand" "xm")))]
14257   "TARGET_SSE && !TARGET_SSE2"
14258   "orps\\t{%2, %0|%0, %2}"
14259   [(set_attr "type" "sse")])
14260
14261 (define_insn "*sse_iorti3_sse2"
14262   [(set (match_operand:TI 0 "register_operand" "=x")
14263         (ior:TI (match_operand:TI 1 "register_operand" "%0")
14264                 (match_operand:TI 2 "nonimmediate_operand" "xm")))]
14265   "TARGET_SSE2"
14266   "por\\t{%2, %0|%0, %2}"
14267   [(set_attr "type" "sse")])
14268
14269 (define_insn "*sse_xorti3_df_1"
14270   [(set (subreg:TI (match_operand:DF 0 "register_operand" "=Y") 0)
14271         (xor:TI (subreg:TI (match_operand:DF 1 "register_operand" "%0") 0)
14272                 (subreg:TI (match_operand:DF 2 "register_operand" "Y") 0)))]
14273   "TARGET_SSE2"
14274   "xorpd\\t{%2, %0|%0, %2}"
14275   [(set_attr "type" "sse")])
14276
14277 (define_insn "*sse_xorti3_df_2"
14278   [(set (subreg:TI (match_operand:DF 0 "register_operand" "=Y") 0)
14279         (xor:TI (subreg:TI (match_operand:DF 1 "register_operand" "0") 0)
14280                 (match_operand:TI 2 "nonimmediate_operand" "Ym")))]
14281   "TARGET_SSE2"
14282   "xorpd\\t{%2, %0|%0, %2}"
14283   [(set_attr "type" "sse")])
14284
14285 (define_insn "*sse_xorti3_sf_1"
14286   [(set (subreg:TI (match_operand:SF 0 "register_operand" "=x") 0)
14287         (xor:TI (subreg:TI (match_operand:SF 1 "register_operand" "%0") 0)
14288                 (subreg:TI (match_operand:SF 2 "register_operand" "x") 0)))]
14289   "TARGET_SSE"
14290   "xorps\\t{%2, %0|%0, %2}"
14291   [(set_attr "type" "sse")])
14292
14293 (define_insn "*sse_xorti3_sf_2"
14294   [(set (subreg:TI (match_operand:SF 0 "register_operand" "=x") 0)
14295         (xor:TI (subreg:TI (match_operand:SF 1 "register_operand" "0") 0)
14296                 (match_operand:TI 2 "nonimmediate_operand" "xm")))]
14297   "TARGET_SSE"
14298   "xorps\\t{%2, %0|%0, %2}"
14299   [(set_attr "type" "sse")])
14300
14301 (define_insn "sse_xorti3"
14302   [(set (match_operand:TI 0 "register_operand" "=x")
14303         (xor:TI (match_operand:TI 1 "register_operand" "%0")
14304                 (match_operand:TI 2 "nonimmediate_operand" "xm")))]
14305   "TARGET_SSE && !TARGET_SSE2"
14306   "xorps\\t{%2, %0|%0, %2}"
14307   [(set_attr "type" "sse")])
14308
14309 (define_insn "*sse_xorti3_sse2"
14310   [(set (match_operand:TI 0 "register_operand" "=x")
14311         (xor:TI (match_operand:TI 1 "register_operand" "%0")
14312                 (match_operand:TI 2 "nonimmediate_operand" "xm")))]
14313   "TARGET_SSE2"
14314   "pxor\\t{%2, %0|%0, %2}"
14315   [(set_attr "type" "sse")])
14316
14317 ;; Use xor, but don't show input operands so they aren't live before
14318 ;; this insn.
14319 (define_insn "sse_clrti"
14320   [(set (match_operand:TI 0 "register_operand" "=x")
14321         (unspec:TI [(const_int 0)] 45))]
14322   "TARGET_SSE"
14323   "xorps\\t{%0, %0|%0, %0}"
14324   [(set_attr "type" "sse")])
14325
14326
14327 ;; SSE mask-generating compares
14328
14329 (define_insn "maskcmpv4sf3"
14330   [(set (match_operand:V4SI 0 "register_operand" "=x")
14331         (match_operator:V4SI 3 "sse_comparison_operator"
14332                              [(match_operand:V4SF 1 "register_operand" "0")
14333                               (match_operand:V4SF 2 "nonimmediate_operand" "x")]))]
14334   "TARGET_SSE"
14335   "cmp%D3ps\\t{%2, %0|%0, %2}"
14336   [(set_attr "type" "sse")])
14337
14338 (define_insn "maskncmpv4sf3"
14339   [(set (match_operand:V4SI 0 "register_operand" "=x")
14340         (not:V4SI
14341          (match_operator:V4SI 3 "sse_comparison_operator"
14342                               [(match_operand:V4SF 1 "register_operand" "0")
14343                                (match_operand:V4SF 2 "nonimmediate_operand" "x")])))]
14344   "TARGET_SSE"
14345   "cmpn%D3ps\\t{%2, %0|%0, %2}"
14346   [(set_attr "type" "sse")])
14347
14348 (define_insn "vmmaskcmpv4sf3"
14349   [(set (match_operand:V4SI 0 "register_operand" "=x")
14350         (vec_merge:V4SI
14351          (match_operator:V4SI 3 "sse_comparison_operator"
14352                               [(match_operand:V4SF 1 "register_operand" "0")
14353                                (match_operand:V4SF 2 "nonimmediate_operand" "x")])
14354          (match_dup 1)
14355          (const_int 1)))]
14356   "TARGET_SSE"
14357   "cmp%D3ss\\t{%2, %0|%0, %2}"
14358   [(set_attr "type" "sse")])
14359
14360 (define_insn "vmmaskncmpv4sf3"
14361   [(set (match_operand:V4SI 0 "register_operand" "=x")
14362         (vec_merge:V4SI
14363          (not:V4SI
14364           (match_operator:V4SI 3 "sse_comparison_operator"
14365                                [(match_operand:V4SF 1 "register_operand" "0")
14366                                 (match_operand:V4SF 2 "nonimmediate_operand" "x")]))
14367          (subreg:V4SI (match_dup 1) 0)
14368          (const_int 1)))]
14369   "TARGET_SSE"
14370   "cmp%D3ss\\t{%2, %0|%0, %2}"
14371   [(set_attr "type" "sse")])
14372
14373 (define_insn "sse_comi"
14374   [(set (reg:CCFP 17)
14375         (match_operator:CCFP 2 "sse_comparison_operator"
14376                         [(vec_select:SF
14377                           (match_operand:V4SF 0 "register_operand" "x")
14378                           (parallel [(const_int 0)]))
14379                          (vec_select:SF
14380                           (match_operand:V4SF 1 "register_operand" "x")
14381                           (parallel [(const_int 0)]))]))]
14382   "TARGET_SSE"
14383   "comiss\\t{%2, %0|%0, %2}"
14384   [(set_attr "type" "sse")])
14385
14386 (define_insn "sse_ucomi"
14387   [(set (reg:CCFPU 17)
14388         (match_operator:CCFPU 2 "sse_comparison_operator"
14389                         [(vec_select:SF
14390                           (match_operand:V4SF 0 "register_operand" "x")
14391                           (parallel [(const_int 0)]))
14392                          (vec_select:SF
14393                           (match_operand:V4SF 1 "register_operand" "x")
14394                           (parallel [(const_int 0)]))]))]
14395   "TARGET_SSE"
14396   "ucomiss\\t{%2, %0|%0, %2}"
14397   [(set_attr "type" "sse")])
14398
14399
14400 ;; SSE unpack
14401
14402 (define_insn "sse_unpckhps"
14403   [(set (match_operand:V4SF 0 "register_operand" "=x")
14404         (vec_merge:V4SF
14405          (vec_select:V4SF (match_operand:V4SF 1 "register_operand" "0")
14406                           (parallel [(const_int 2)
14407                                      (const_int 0)
14408                                      (const_int 3)
14409                                      (const_int 1)]))
14410          (vec_select:V8QI (match_operand:V8QI 2 "register_operand" "x")
14411                           (parallel [(const_int 0)
14412                                      (const_int 2)
14413                                      (const_int 1)
14414                                      (const_int 3)]))
14415          (const_int 5)))]
14416   "TARGET_SSE"
14417   "unpckhps\\t{%2, %0|%0, %2}"
14418   [(set_attr "type" "sse")])
14419
14420 (define_insn "sse_unpcklps"
14421   [(set (match_operand:V4SF 0 "register_operand" "=x")
14422         (vec_merge:V4SF
14423          (vec_select:V4SF (match_operand:V4SF 1 "register_operand" "0")
14424                           (parallel [(const_int 0)
14425                                      (const_int 2)
14426                                      (const_int 1)
14427                                      (const_int 3)]))
14428          (vec_select:V8QI (match_operand:V8QI 2 "register_operand" "x")
14429                           (parallel [(const_int 2)
14430                                      (const_int 0)
14431                                      (const_int 3)
14432                                      (const_int 1)]))
14433          (const_int 5)))]
14434   "TARGET_SSE"
14435   "unpcklps\\t{%2, %0|%0, %2}"
14436   [(set_attr "type" "sse")])
14437
14438
14439 ;; SSE min/max
14440
14441 (define_insn "smaxv4sf3"
14442   [(set (match_operand:V4SF 0 "register_operand" "=x")
14443         (smax:V4SF (match_operand:V4SF 1 "register_operand" "0")
14444                    (match_operand:V4SF 2 "nonimmediate_operand" "xm")))]
14445   "TARGET_SSE"
14446   "maxps\\t{%2, %0|%0, %2}"
14447   [(set_attr "type" "sse")])
14448
14449 (define_insn "vmsmaxv4sf3"
14450   [(set (match_operand:V4SF 0 "register_operand" "=x")
14451         (vec_merge:V4SF (smax:V4SF (match_operand:V4SF 1 "register_operand" "0")
14452                                    (match_operand:V4SF 2 "nonimmediate_operand" "xm"))
14453                         (match_dup 1)
14454                         (const_int 1)))]
14455   "TARGET_SSE"
14456   "maxss\\t{%2, %0|%0, %2}"
14457   [(set_attr "type" "sse")])
14458
14459 (define_insn "sminv4sf3"
14460   [(set (match_operand:V4SF 0 "register_operand" "=x")
14461         (smin:V4SF (match_operand:V4SF 1 "register_operand" "0")
14462                    (match_operand:V4SF 2 "nonimmediate_operand" "xm")))]
14463   "TARGET_SSE"
14464   "minps\\t{%2, %0|%0, %2}"
14465   [(set_attr "type" "sse")])
14466
14467 (define_insn "vmsminv4sf3"
14468   [(set (match_operand:V4SF 0 "register_operand" "=x")
14469         (vec_merge:V4SF (smin:V4SF (match_operand:V4SF 1 "register_operand" "0")
14470                                    (match_operand:V4SF 2 "nonimmediate_operand" "xm"))
14471                         (match_dup 1)
14472                         (const_int 1)))]
14473   "TARGET_SSE"
14474   "minss\\t{%2, %0|%0, %2}"
14475   [(set_attr "type" "sse")])
14476
14477
14478 ;; SSE <-> integer/MMX conversions
14479
14480 (define_insn "cvtpi2ps"
14481   [(set (match_operand:V4SF 0 "register_operand" "=x")
14482         (vec_merge:V4SF (match_operand:V4SF 1 "register_operand" "0")
14483                         (vec_duplicate:V4SF
14484                          (float:V2SF (match_operand:V2SI 2 "register_operand" "ym")))
14485                         (const_int 12)))]
14486   "TARGET_SSE"
14487   "cvtpi2ps\\t{%2, %0|%0, %2}"
14488   [(set_attr "type" "sse")])
14489
14490 (define_insn "cvtps2pi"
14491   [(set (match_operand:V2SI 0 "register_operand" "=y")
14492         (vec_select:V2SI (fix:V4SI (match_operand:V4SF 1 "register_operand" "xm"))
14493                          (parallel
14494                           [(const_int 0)
14495                            (const_int 1)])))]
14496   "TARGET_SSE"
14497   "cvtps2pi\\t{%1, %0|%0, %1}"
14498   [(set_attr "type" "sse")])
14499
14500 (define_insn "cvttps2pi"
14501   [(set (match_operand:V2SI 0 "register_operand" "=y")
14502         (vec_select:V2SI (unspec:V4SI [(match_operand:V4SF 1 "register_operand" "xm")] 30)
14503                          (parallel
14504                           [(const_int 0)
14505                            (const_int 1)])))]
14506   "TARGET_SSE"
14507   "cvttps2pi\\t{%1, %0|%0, %1}"
14508   [(set_attr "type" "sse")])
14509
14510 (define_insn "cvtsi2ss"
14511   [(set (match_operand:V4SF 0 "register_operand" "=x")
14512         (vec_merge:V4SF (match_operand:V4SF 1 "register_operand" "0")
14513                         (vec_duplicate:V4SF
14514                          (float:SF (match_operand:SI 2 "register_operand" "rm")))
14515                         (const_int 15)))]
14516   "TARGET_SSE"
14517   "cvtsi2ss\\t{%2, %0|%0, %2}"
14518   [(set_attr "type" "sse")])
14519
14520 (define_insn "cvtss2si"
14521   [(set (match_operand:SI 0 "register_operand" "=y")
14522         (vec_select:SI (fix:V4SI (match_operand:V4SF 1 "register_operand" "xm"))
14523                        (parallel [(const_int 0)])))]
14524   "TARGET_SSE"
14525   "cvtss2si\\t{%1, %0|%0, %1}"
14526   [(set_attr "type" "sse")])
14527
14528 (define_insn "cvttss2si"
14529   [(set (match_operand:SI 0 "register_operand" "=y")
14530         (vec_select:SI (unspec:V4SI [(match_operand:V4SF 1 "register_operand" "xm")] 30)
14531                        (parallel [(const_int 0)])))]
14532   "TARGET_SSE"
14533   "cvttss2si\\t{%1, %0|%0, %1}"
14534   [(set_attr "type" "sse")])
14535
14536
14537 ;; MMX insns
14538
14539 ;; MMX arithmetic
14540
14541 (define_insn "addv8qi3"
14542   [(set (match_operand:V8QI 0 "register_operand" "=y")
14543         (plus:V8QI (match_operand:V8QI 1 "register_operand" "0")
14544                    (match_operand:V8QI 2 "nonimmediate_operand" "ym")))]
14545   "TARGET_MMX"
14546   "paddb\\t{%2, %0|%0, %2}"
14547   [(set_attr "type" "mmx")])
14548
14549 (define_insn "addv4hi3"
14550   [(set (match_operand:V4HI 0 "register_operand" "=y")
14551         (plus:V4HI (match_operand:V4HI 1 "register_operand" "0")
14552                    (match_operand:V4HI 2 "nonimmediate_operand" "ym")))]
14553   "TARGET_MMX"
14554   "paddw\\t{%2, %0|%0, %2}"
14555   [(set_attr "type" "mmx")])
14556
14557 (define_insn "addv2si3"
14558   [(set (match_operand:V2SI 0 "register_operand" "=y")
14559         (plus:V2SI (match_operand:V2SI 1 "register_operand" "0")
14560                    (match_operand:V2SI 2 "nonimmediate_operand" "ym")))]
14561   "TARGET_MMX"
14562   "paddd\\t{%2, %0|%0, %2}"
14563   [(set_attr "type" "mmx")])
14564
14565 (define_insn "ssaddv8qi3"
14566   [(set (match_operand:V8QI 0 "register_operand" "=y")
14567         (ss_plus:V8QI (match_operand:V8QI 1 "register_operand" "0")
14568                       (match_operand:V8QI 2 "nonimmediate_operand" "ym")))]
14569   "TARGET_MMX"
14570   "paddsb\\t{%2, %0|%0, %2}"
14571   [(set_attr "type" "mmx")])
14572
14573 (define_insn "ssaddv4hi3"
14574   [(set (match_operand:V4HI 0 "register_operand" "=y")
14575         (ss_plus:V4HI (match_operand:V4HI 1 "register_operand" "0")
14576                       (match_operand:V4HI 2 "nonimmediate_operand" "ym")))]
14577   "TARGET_MMX"
14578   "paddsw\\t{%2, %0|%0, %2}"
14579   [(set_attr "type" "mmx")])
14580
14581 (define_insn "usaddv8qi3"
14582   [(set (match_operand:V8QI 0 "register_operand" "=y")
14583         (us_plus:V8QI (match_operand:V8QI 1 "register_operand" "0")
14584                       (match_operand:V8QI 2 "nonimmediate_operand" "ym")))]
14585   "TARGET_MMX"
14586   "paddusb\\t{%2, %0|%0, %2}"
14587   [(set_attr "type" "mmx")])
14588
14589 (define_insn "usaddv4hi3"
14590   [(set (match_operand:V4HI 0 "register_operand" "=y")
14591         (us_plus:V4HI (match_operand:V4HI 1 "register_operand" "0")
14592                       (match_operand:V4HI 2 "nonimmediate_operand" "ym")))]
14593   "TARGET_MMX"
14594   "paddusw\\t{%2, %0|%0, %2}"
14595   [(set_attr "type" "mmx")])
14596
14597 (define_insn "subv8qi3"
14598   [(set (match_operand:V8QI 0 "register_operand" "=y")
14599         (minus:V8QI (match_operand:V8QI 1 "register_operand" "0")
14600                     (match_operand:V8QI 2 "nonimmediate_operand" "ym")))]
14601   "TARGET_MMX"
14602   "psubb\\t{%2, %0|%0, %2}"
14603   [(set_attr "type" "mmx")])
14604
14605 (define_insn "subv4hi3"
14606   [(set (match_operand:V4HI 0 "register_operand" "=y")
14607         (minus:V4HI (match_operand:V4HI 1 "register_operand" "0")
14608                     (match_operand:V4HI 2 "nonimmediate_operand" "ym")))]
14609   "TARGET_MMX"
14610   "psubw\\t{%2, %0|%0, %2}"
14611   [(set_attr "type" "mmx")])
14612
14613 (define_insn "subv2si3"
14614   [(set (match_operand:V2SI 0 "register_operand" "=y")
14615         (minus:V2SI (match_operand:V2SI 1 "register_operand" "0")
14616                     (match_operand:V2SI 2 "nonimmediate_operand" "ym")))]
14617   "TARGET_MMX"
14618   "psubd\\t{%2, %0|%0, %2}"
14619   [(set_attr "type" "mmx")])
14620
14621 (define_insn "sssubv8qi3"
14622   [(set (match_operand:V8QI 0 "register_operand" "=y")
14623         (ss_minus:V8QI (match_operand:V8QI 1 "register_operand" "0")
14624                        (match_operand:V8QI 2 "nonimmediate_operand" "ym")))]
14625   "TARGET_MMX"
14626   "psubsb\\t{%2, %0|%0, %2}"
14627   [(set_attr "type" "mmx")])
14628
14629 (define_insn "sssubv4hi3"
14630   [(set (match_operand:V4HI 0 "register_operand" "=y")
14631         (ss_minus:V4HI (match_operand:V4HI 1 "register_operand" "0")
14632                        (match_operand:V4HI 2 "nonimmediate_operand" "ym")))]
14633   "TARGET_MMX"
14634   "psubsw\\t{%2, %0|%0, %2}"
14635   [(set_attr "type" "mmx")])
14636
14637 (define_insn "ussubv8qi3"
14638   [(set (match_operand:V8QI 0 "register_operand" "=y")
14639         (us_minus:V8QI (match_operand:V8QI 1 "register_operand" "0")
14640                        (match_operand:V8QI 2 "nonimmediate_operand" "ym")))]
14641   "TARGET_MMX"
14642   "psubusb\\t{%2, %0|%0, %2}"
14643   [(set_attr "type" "mmx")])
14644
14645 (define_insn "ussubv4hi3"
14646   [(set (match_operand:V4HI 0 "register_operand" "=y")
14647         (us_minus:V4HI (match_operand:V4HI 1 "register_operand" "0")
14648                        (match_operand:V4HI 2 "nonimmediate_operand" "ym")))]
14649   "TARGET_MMX"
14650   "psubusw\\t{%2, %0|%0, %2}"
14651   [(set_attr "type" "mmx")])
14652
14653 (define_insn "mulv4hi3"
14654   [(set (match_operand:V4HI 0 "register_operand" "=y")
14655         (mult:V4HI (match_operand:V4HI 1 "register_operand" "0")
14656                    (match_operand:V4HI 2 "nonimmediate_operand" "ym")))]
14657   "TARGET_MMX"
14658   "pmullw\\t{%2, %0|%0, %2}"
14659   [(set_attr "type" "mmx")])
14660
14661 (define_insn "smulv4hi3_highpart"
14662   [(set (match_operand:V4HI 0 "register_operand" "=y")
14663         (truncate:V4HI
14664          (lshiftrt:V4SI
14665           (mult:V4SI (sign_extend:V4SI (match_operand:V4HI 1 "register_operand" "0"))
14666                      (sign_extend:V4SI (match_operand:V4HI 2 "nonimmediate_operand" "ym")))
14667           (const_int 16))))]
14668   "TARGET_MMX"
14669   "pmulhw\\t{%2, %0|%0, %2}"
14670   [(set_attr "type" "mmx")])
14671
14672 (define_insn "umulv4hi3_highpart"
14673   [(set (match_operand:V4HI 0 "register_operand" "=y")
14674         (truncate:V4HI
14675          (lshiftrt:V4SI
14676           (mult:V4SI (zero_extend:V4SI (match_operand:V4HI 1 "register_operand" "0"))
14677                      (zero_extend:V4SI (match_operand:V4HI 2 "nonimmediate_operand" "ym")))
14678           (const_int 16))))]
14679   "TARGET_MMX"
14680   "pmulhuw\\t{%2, %0|%0, %2}"
14681   [(set_attr "type" "mmx")])
14682
14683 (define_insn "mmx_pmaddwd"
14684   [(set (match_operand:V2SI 0 "register_operand" "=y")
14685         (plus:V2SI
14686          (mult:V2SI
14687           (sign_extend:V2SI (vec_select:V2HI (match_operand:V4HI 1 "register_operand" "0")
14688                                              (parallel [(const_int 0)
14689                                                         (const_int 2)])))
14690           (sign_extend:V2SI (vec_select:V2HI (match_operand:V4HI 2 "nonimmediate_operand" "ym")
14691                                              (parallel [(const_int 0)
14692                                                         (const_int 2)]))))
14693          (mult:V2SI
14694           (sign_extend:V2SI (vec_select:V2HI (match_dup 1)
14695                                              (parallel [(const_int 1)
14696                                                         (const_int 3)])))
14697           (sign_extend:V2SI (vec_select:V2HI (match_dup 2)
14698                                              (parallel [(const_int 1)
14699                                                         (const_int 3)]))))))]
14700   "TARGET_MMX"
14701   "pmaddwd\\t{%2, %0|%0, %2}"
14702   [(set_attr "type" "mmx")])
14703
14704
14705 ;; MMX logical operations
14706 ;; Note we don't want to declare these as regular iordi3 insns to prevent
14707 ;; normal code that also wants to use the FPU from getting broken.
14708 ;; The UNSPECs are there to prevent the combiner from getting overly clever.
14709 (define_insn "mmx_iordi3"
14710   [(set (match_operand:DI 0 "register_operand" "=y")
14711         (unspec:DI
14712          [(ior:DI (match_operand:DI 1 "register_operand" "0")
14713                   (match_operand:DI 2 "nonimmediate_operand" "ym"))] 45))]
14714   "TARGET_MMX"
14715   "por\\t{%2, %0|%0, %2}"
14716   [(set_attr "type" "mmx")])
14717
14718 (define_insn "mmx_xordi3"
14719   [(set (match_operand:DI 0 "register_operand" "=y")
14720         (unspec:DI
14721          [(xor:DI (match_operand:DI 1 "register_operand" "0")
14722                   (match_operand:DI 2 "nonimmediate_operand" "ym"))] 45))]
14723   "TARGET_MMX"
14724   "pxor\\t{%2, %0|%0, %2}"
14725   [(set_attr "type" "mmx")])
14726
14727 ;; Same as pxor, but don't show input operands so that we don't think
14728 ;; they are live.
14729 (define_insn "mmx_clrdi"
14730   [(set (match_operand:DI 0 "register_operand" "=y")
14731         (unspec:DI [(const_int 0)] 45))]
14732   "TARGET_MMX"
14733   "pxor\\t{%0, %0|%0, %0}"
14734   [(set_attr "type" "mmx")])
14735
14736 (define_insn "mmx_anddi3"
14737   [(set (match_operand:DI 0 "register_operand" "=y")
14738         (unspec:DI
14739          [(and:DI (match_operand:DI 1 "register_operand" "0")
14740                   (match_operand:DI 2 "nonimmediate_operand" "ym"))] 45))]
14741   "TARGET_MMX"
14742   "pand\\t{%2, %0|%0, %2}"
14743   [(set_attr "type" "mmx")])
14744
14745 (define_insn "mmx_nanddi3"
14746   [(set (match_operand:DI 0 "register_operand" "=y")
14747         (unspec:DI
14748          [(and:DI (not:DI (match_operand:DI 1 "register_operand" "0"))
14749                           (match_operand:DI 2 "nonimmediate_operand" "ym"))] 45))]
14750   "TARGET_MMX"
14751   "pandn\\t{%2, %0|%0, %2}"
14752   [(set_attr "type" "mmx")])
14753
14754
14755 ;; MMX unsigned averages/sum of absolute differences
14756
14757 (define_insn "mmx_uavgv8qi3"
14758   [(set (match_operand:V8QI 0 "register_operand" "=y")
14759         (ashiftrt:V8QI
14760          (plus:V8QI (plus:V8QI
14761                      (match_operand:V8QI 1 "register_operand" "0")
14762                      (match_operand:V8QI 2 "nonimmediate_operand" "ym"))
14763                     (vec_const:V8QI (parallel [(const_int 1)
14764                                                (const_int 1)
14765                                                (const_int 1)
14766                                                (const_int 1)
14767                                                (const_int 1)
14768                                                (const_int 1)
14769                                                (const_int 1)
14770                                                (const_int 1)])))
14771          (const_int 1)))]
14772   "TARGET_SSE"
14773   "pavgb\\t{%2, %0|%0, %2}"
14774   [(set_attr "type" "sse")])
14775
14776 (define_insn "mmx_uavgv4hi3"
14777   [(set (match_operand:V4HI 0 "register_operand" "=y")
14778         (ashiftrt:V4HI
14779          (plus:V4HI (plus:V4HI
14780                      (match_operand:V4HI 1 "register_operand" "0")
14781                      (match_operand:V4HI 2 "nonimmediate_operand" "ym"))
14782                     (vec_const:V4HI (parallel [(const_int 1)
14783                                                (const_int 1)
14784                                                (const_int 1)
14785                                                (const_int 1)])))
14786          (const_int 1)))]
14787   "TARGET_SSE"
14788   "pavgw\\t{%2, %0|%0, %2}"
14789   [(set_attr "type" "sse")])
14790
14791 (define_insn "mmx_psadbw"
14792   [(set (match_operand:V8QI 0 "register_operand" "=y")
14793         (abs:V8QI (minus:V8QI (match_operand:V8QI 1 "register_operand" "0")
14794                               (match_operand:V8QI 2 "nonimmediate_operand" "ym"))))]
14795   "TARGET_SSE"
14796   "psadbw\\t{%2, %0|%0, %2}"
14797   [(set_attr "type" "sse")])
14798
14799
14800 ;; MMX insert/extract/shuffle
14801
14802 (define_insn "mmx_pinsrw"
14803   [(set (match_operand:V4HI 0 "register_operand" "=y")
14804         (vec_merge:V4HI (match_operand:V4HI 1 "register_operand" "0")
14805                         (vec_duplicate:V4HI
14806                          (truncate:HI (match_operand:SI 2 "nonimmediate_operand" "rm")))
14807                         (match_operand:SI 3 "immediate_operand" "i")))]
14808   "TARGET_SSE"
14809   "pinsrw\\t{%3, %2, %0|%0, %2, %3}"
14810   [(set_attr "type" "sse")])
14811
14812 (define_insn "mmx_pextrw"
14813   [(set (match_operand:SI 0 "register_operand" "=r")
14814         (zero_extend:SI (vec_select:HI (match_operand:V4HI 1 "register_operand" "y")
14815                                        (parallel
14816                                         [(match_operand:SI 2 "immediate_operand" "i")]))))]
14817   "TARGET_SSE"
14818   "pextrw\\t{%2, %1, %0|%0, %1, %2}"
14819   [(set_attr "type" "sse")])
14820
14821 (define_insn "mmx_pshufw"
14822   [(set (match_operand:V4HI 0 "register_operand" "=y")
14823         (unspec:V4HI [(match_operand:V4HI 1 "register_operand" "0")
14824                       (match_operand:V4HI 2 "nonimmediate_operand" "ym")
14825                       (match_operand:SI 3 "immediate_operand" "i")] 41))]
14826   "TARGET_SSE"
14827   "pshufw\\t{%3, %2, %0|%0, %2, %3}"
14828   [(set_attr "type" "sse")])
14829
14830
14831 ;; MMX mask-generating comparisons
14832
14833 (define_insn "eqv8qi3"
14834   [(set (match_operand:V8QI 0 "register_operand" "=y")
14835         (eq:V8QI (match_operand:V8QI 1 "register_operand" "0")
14836                  (match_operand:V8QI 2 "nonimmediate_operand" "ym")))]
14837   "TARGET_MMX"
14838   "pcmpeqb\\t{%2, %0|%0, %2}"
14839   [(set_attr "type" "mmx")])
14840
14841 (define_insn "eqv4hi3"
14842   [(set (match_operand:V4HI 0 "register_operand" "=y")
14843         (eq:V4HI (match_operand:V4HI 1 "register_operand" "0")
14844                  (match_operand:V4HI 2 "nonimmediate_operand" "ym")))]
14845   "TARGET_MMX"
14846   "pcmpeqw\\t{%2, %0|%0, %2}"
14847   [(set_attr "type" "mmx")])
14848
14849 (define_insn "eqv2si3"
14850   [(set (match_operand:V2SI 0 "register_operand" "=y")
14851         (eq:V2SI (match_operand:V2SI 1 "register_operand" "0")
14852                  (match_operand:V2SI 2 "nonimmediate_operand" "ym")))]
14853   "TARGET_MMX"
14854   "pcmpeqd\\t{%2, %0|%0, %2}"
14855   [(set_attr "type" "mmx")])
14856
14857 (define_insn "gtv8qi3"
14858   [(set (match_operand:V8QI 0 "register_operand" "=y")
14859         (gt:V8QI (match_operand:V8QI 1 "register_operand" "0")
14860                  (match_operand:V8QI 2 "nonimmediate_operand" "ym")))]
14861   "TARGET_MMX"
14862   "pcmpgtb\\t{%2, %0|%0, %2}"
14863   [(set_attr "type" "mmx")])
14864
14865 (define_insn "gtv4hi3"
14866   [(set (match_operand:V4HI 0 "register_operand" "=y")
14867         (gt:V4HI (match_operand:V4HI 1 "register_operand" "0")
14868                  (match_operand:V4HI 2 "nonimmediate_operand" "ym")))]
14869   "TARGET_MMX"
14870   "pcmpgtw\\t{%2, %0|%0, %2}"
14871   [(set_attr "type" "mmx")])
14872
14873 (define_insn "gtv2si3"
14874   [(set (match_operand:V2SI 0 "register_operand" "=y")
14875         (gt:V2SI (match_operand:V2SI 1 "register_operand" "0")
14876                  (match_operand:V2SI 2 "nonimmediate_operand" "ym")))]
14877   "TARGET_MMX"
14878   "pcmpgtd\\t{%2, %0|%0, %2}"
14879   [(set_attr "type" "mmx")])
14880
14881
14882 ;; MMX max/min insns
14883
14884 (define_insn "umaxv8qi3"
14885   [(set (match_operand:V8QI 0 "register_operand" "=y")
14886         (umax:V8QI (match_operand:V8QI 1 "register_operand" "0")
14887                    (match_operand:V8QI 2 "nonimmediate_operand" "ym")))]
14888   "TARGET_SSE"
14889   "pmaxub\\t{%2, %0|%0, %2}"
14890   [(set_attr "type" "sse")])
14891
14892 (define_insn "smaxv4hi3"
14893   [(set (match_operand:V4HI 0 "register_operand" "=y")
14894         (smax:V4HI (match_operand:V4HI 1 "register_operand" "0")
14895                    (match_operand:V4HI 2 "nonimmediate_operand" "ym")))]
14896   "TARGET_SSE"
14897   "pmaxsw\\t{%2, %0|%0, %2}"
14898   [(set_attr "type" "sse")])
14899
14900 (define_insn "uminv8qi3"
14901   [(set (match_operand:V8QI 0 "register_operand" "=y")
14902         (umin:V8QI (match_operand:V8QI 1 "register_operand" "0")
14903                    (match_operand:V8QI 2 "nonimmediate_operand" "ym")))]
14904   "TARGET_SSE"
14905   "pminub\\t{%2, %0|%0, %2}"
14906   [(set_attr "type" "sse")])
14907
14908 (define_insn "sminv4hi3"
14909   [(set (match_operand:V4HI 0 "register_operand" "=y")
14910         (smin:V4HI (match_operand:V4HI 1 "register_operand" "0")
14911                    (match_operand:V4HI 2 "nonimmediate_operand" "ym")))]
14912   "TARGET_SSE"
14913   "pminsw\\t{%2, %0|%0, %2}"
14914   [(set_attr "type" "sse")])
14915
14916
14917 ;; MMX shifts
14918
14919 (define_insn "ashrv4hi3"
14920   [(set (match_operand:V4HI 0 "register_operand" "=y")
14921         (ashiftrt:V4HI (match_operand:V4HI 1 "register_operand" "0")
14922                        (match_operand:DI 2 "nonmemory_operand" "yi")))]
14923   "TARGET_MMX"
14924   "psraw\\t{%2, %0|%0, %2}"
14925   [(set_attr "type" "mmx")])
14926
14927 (define_insn "ashrv2si3"
14928   [(set (match_operand:V2SI 0 "register_operand" "=y")
14929         (ashiftrt:V2SI (match_operand:V2SI 1 "register_operand" "0")
14930                        (match_operand:DI 2 "nonmemory_operand" "yi")))]
14931   "TARGET_MMX"
14932   "psrad\\t{%2, %0|%0, %2}"
14933   [(set_attr "type" "mmx")])
14934
14935 (define_insn "lshrv4hi3"
14936   [(set (match_operand:V4HI 0 "register_operand" "=y")
14937         (lshiftrt:V4HI (match_operand:V4HI 1 "register_operand" "0")
14938                        (match_operand:DI 2 "nonmemory_operand" "yi")))]
14939   "TARGET_MMX"
14940   "psrlw\\t{%2, %0|%0, %2}"
14941   [(set_attr "type" "mmx")])
14942
14943 (define_insn "lshrv2si3"
14944   [(set (match_operand:V2SI 0 "register_operand" "=y")
14945         (lshiftrt:V2SI (match_operand:V2SI 1 "register_operand" "0")
14946                        (match_operand:DI 2 "nonmemory_operand" "yi")))]
14947   "TARGET_MMX"
14948   "psrld\\t{%2, %0|%0, %2}"
14949   [(set_attr "type" "mmx")])
14950
14951 ;; See logical MMX insns.
14952 (define_insn "mmx_lshrdi3"
14953   [(set (match_operand:DI 0 "register_operand" "=y")
14954         (unspec:DI
14955           [(lshiftrt:DI (match_operand:DI 1 "register_operand" "0")
14956                        (match_operand:DI 2 "nonmemory_operand" "yi"))] 45))]
14957   "TARGET_MMX"
14958   "psrlq\\t{%2, %0|%0, %2}"
14959   [(set_attr "type" "mmx")])
14960
14961 (define_insn "ashlv4hi3"
14962   [(set (match_operand:V4HI 0 "register_operand" "=y")
14963         (ashift:V4HI (match_operand:V4HI 1 "register_operand" "0")
14964                        (match_operand:DI 2 "nonmemory_operand" "yi")))]
14965   "TARGET_MMX"
14966   "psllw\\t{%2, %0|%0, %2}"
14967   [(set_attr "type" "mmx")])
14968
14969 (define_insn "ashlv2si3"
14970   [(set (match_operand:V2SI 0 "register_operand" "=y")
14971         (ashift:V2SI (match_operand:V2SI 1 "register_operand" "0")
14972                        (match_operand:DI 2 "nonmemory_operand" "yi")))]
14973   "TARGET_MMX"
14974   "pslld\\t{%2, %0|%0, %2}"
14975   [(set_attr "type" "mmx")])
14976
14977 ;; See logical MMX insns.
14978 (define_insn "mmx_ashldi3"
14979   [(set (match_operand:DI 0 "register_operand" "=y")
14980         (unspec:DI
14981          [(ashift:DI (match_operand:DI 1 "register_operand" "0")
14982                      (match_operand:DI 2 "nonmemory_operand" "yi"))] 45))]
14983   "TARGET_MMX"
14984   "psllq\\t{%2, %0|%0, %2}"
14985   [(set_attr "type" "mmx")])
14986
14987
14988 ;; MMX pack/unpack insns.
14989
14990 (define_insn "mmx_packsswb"
14991   [(set (match_operand:V8QI 0 "register_operand" "=y")
14992         (vec_concat:V8QI
14993          (ss_truncate:V4QI (match_operand:V4HI 1 "register_operand" "0"))
14994          (ss_truncate:V4QI (match_operand:V4HI 2 "register_operand" "y"))))]
14995   "TARGET_MMX"
14996   "packsswb\\t{%2, %0|%0, %2}"
14997   [(set_attr "type" "mmx")])
14998
14999 (define_insn "mmx_packssdw"
15000   [(set (match_operand:V4HI 0 "register_operand" "=y")
15001         (vec_concat:V4HI
15002          (ss_truncate:V2HI (match_operand:V2SI 1 "register_operand" "0"))
15003          (ss_truncate:V2HI (match_operand:V2SI 2 "register_operand" "y"))))]
15004   "TARGET_MMX"
15005   "packssdw\\t{%2, %0|%0, %2}"
15006   [(set_attr "type" "mmx")])
15007
15008 (define_insn "mmx_packuswb"
15009   [(set (match_operand:V8QI 0 "register_operand" "=y")
15010         (vec_concat:V8QI
15011          (us_truncate:V4QI (match_operand:V4HI 1 "register_operand" "0"))
15012          (us_truncate:V4QI (match_operand:V4HI 2 "register_operand" "y"))))]
15013   "TARGET_MMX"
15014   "packuswb\\t{%2, %0|%0, %2}"
15015   [(set_attr "type" "mmx")])
15016
15017 (define_insn "mmx_punpckhbw"
15018   [(set (match_operand:V8QI 0 "register_operand" "=y")
15019         (vec_merge:V8QI
15020          (vec_select:V8QI (match_operand:V8QI 1 "register_operand" "0")
15021                           (parallel [(const_int 4)
15022                                      (const_int 0)
15023                                      (const_int 5)
15024                                      (const_int 1)
15025                                      (const_int 6)
15026                                      (const_int 2)
15027                                      (const_int 7)
15028                                      (const_int 3)]))
15029          (vec_select:V8QI (match_operand:V8QI 2 "register_operand" "y")
15030                           (parallel [(const_int 0)
15031                                      (const_int 4)
15032                                      (const_int 1)
15033                                      (const_int 5)
15034                                      (const_int 2)
15035                                      (const_int 6)
15036                                      (const_int 3)
15037                                      (const_int 7)]))
15038          (const_int 85)))]
15039   "TARGET_MMX"
15040   "punpckhbw\\t{%2, %0|%0, %2}"
15041   [(set_attr "type" "mmx")])
15042
15043 (define_insn "mmx_punpckhwd"
15044   [(set (match_operand:V4HI 0 "register_operand" "=y")
15045         (vec_merge:V4HI
15046          (vec_select:V4HI (match_operand:V4HI 1 "register_operand" "0")
15047                           (parallel [(const_int 0)
15048                                      (const_int 2)
15049                                      (const_int 1)
15050                                      (const_int 3)]))
15051          (vec_select:V4HI (match_operand:V4HI 2 "register_operand" "y")
15052                           (parallel [(const_int 2)
15053                                      (const_int 0)
15054                                      (const_int 3)
15055                                      (const_int 1)]))
15056          (const_int 5)))]
15057   "TARGET_MMX"
15058   "punpckhwd\\t{%2, %0|%0, %2}"
15059   [(set_attr "type" "mmx")])
15060
15061 (define_insn "mmx_punpckhdq"
15062   [(set (match_operand:V2SI 0 "register_operand" "=y")
15063         (vec_merge:V2SI
15064          (vec_select:V2SI (match_operand:V2SI 1 "register_operand" "0")
15065                           (parallel [(const_int 0)
15066                                      (const_int 1)]))
15067          (vec_select:V2SI (match_operand:V2SI 2 "register_operand" "y")
15068                           (parallel [(const_int 1)
15069                                      (const_int 0)]))
15070          (const_int 1)))]
15071   "TARGET_MMX"
15072   "punpckhdq\\t{%2, %0|%0, %2}"
15073   [(set_attr "type" "mmx")])
15074
15075 (define_insn "mmx_punpcklbw"
15076   [(set (match_operand:V8QI 0 "register_operand" "=y")
15077         (vec_merge:V8QI
15078          (vec_select:V8QI (match_operand:V8QI 1 "register_operand" "0")
15079                           (parallel [(const_int 0)
15080                                      (const_int 4)
15081                                      (const_int 1)
15082                                      (const_int 5)
15083                                      (const_int 2)
15084                                      (const_int 6)
15085                                      (const_int 3)
15086                                      (const_int 7)]))
15087          (vec_select:V8QI (match_operand:V8QI 2 "register_operand" "y")
15088                           (parallel [(const_int 4)
15089                                      (const_int 0)
15090                                      (const_int 5)
15091                                      (const_int 1)
15092                                      (const_int 6)
15093                                      (const_int 2)
15094                                      (const_int 7)
15095                                      (const_int 3)]))
15096          (const_int 85)))]
15097   "TARGET_MMX"
15098   "punpcklbw\\t{%2, %0|%0, %2}"
15099   [(set_attr "type" "mmx")])
15100
15101 (define_insn "mmx_punpcklwd"
15102   [(set (match_operand:V4HI 0 "register_operand" "=y")
15103         (vec_merge:V4HI
15104          (vec_select:V4HI (match_operand:V4HI 1 "register_operand" "0")
15105                           (parallel [(const_int 2)
15106                                      (const_int 0)
15107                                      (const_int 3)
15108                                      (const_int 1)]))
15109          (vec_select:V4HI (match_operand:V4HI 2 "register_operand" "y")
15110                           (parallel [(const_int 0)
15111                                      (const_int 2)
15112                                      (const_int 1)
15113                                      (const_int 3)]))
15114          (const_int 5)))]
15115   "TARGET_MMX"
15116   "punpcklwd\\t{%2, %0|%0, %2}"
15117   [(set_attr "type" "mmx")])
15118
15119 (define_insn "mmx_punpckldq"
15120   [(set (match_operand:V2SI 0 "register_operand" "=y")
15121         (vec_merge:V2SI
15122          (vec_select:V2SI (match_operand:V2SI 1 "register_operand" "0")
15123                            (parallel [(const_int 1)
15124                                       (const_int 0)]))
15125          (vec_select:V2SI (match_operand:V2SI 2 "register_operand" "y")
15126                           (parallel [(const_int 0)
15127                                      (const_int 1)]))
15128          (const_int 1)))]
15129   "TARGET_MMX"
15130   "punpckldq\\t{%2, %0|%0, %2}"
15131   [(set_attr "type" "mmx")])
15132
15133
15134 ;; Miscellaneous stuff
15135
15136 (define_insn "emms"
15137   [(unspec_volatile [(const_int 0)] 31)
15138    (clobber (reg:XF 8))
15139    (clobber (reg:XF 9))
15140    (clobber (reg:XF 10))
15141    (clobber (reg:XF 11))
15142    (clobber (reg:XF 12))
15143    (clobber (reg:XF 13))
15144    (clobber (reg:XF 14))
15145    (clobber (reg:XF 15))
15146    (clobber (reg:DI 29))
15147    (clobber (reg:DI 30))
15148    (clobber (reg:DI 31))
15149    (clobber (reg:DI 32))
15150    (clobber (reg:DI 33))
15151    (clobber (reg:DI 34))
15152    (clobber (reg:DI 35))
15153    (clobber (reg:DI 36))]
15154   "TARGET_MMX"
15155   "emms"
15156   [(set_attr "type" "mmx")
15157    (set_attr "memory" "unknown")])
15158
15159 (define_insn "ldmxcsr"
15160   [(unspec_volatile [(match_operand:SI 0 "memory_operand" "m")] 37)]
15161   "TARGET_MMX"
15162   "ldmxcsr\\t%0"
15163   [(set_attr "type" "mmx")])
15164
15165 (define_insn "stmxcsr"
15166   [(set (match_operand:SI 0 "memory_operand" "=m")
15167         (unspec_volatile:SI [(const_int 0)] 40))]
15168   "TARGET_MMX"
15169   "stmxcsr\\t%0"
15170   [(set_attr "type" "mmx")])
15171
15172 (define_expand "sfence"
15173   [(set (match_dup 0)
15174         (unspec:BLK [(match_dup 0)] 44))]
15175   "TARGET_SSE"
15176   "
15177 {
15178   operands[0] = gen_rtx_MEM (BLKmode, gen_rtx_SCRATCH (Pmode));
15179   MEM_VOLATILE_P (operands[0]) = 1;
15180 }")
15181
15182 (define_insn "*sfence_insn"
15183   [(set (match_operand:BLK 0 "" "")
15184         (unspec:BLK [(match_dup 0)] 44))]
15185   "TARGET_SSE"
15186   "sfence"
15187   [(set_attr "type" "sse")
15188    (set_attr "memory" "unknown")])
15189
15190 (define_insn "prefetch"
15191   [(unspec [(match_operand:SI 0 "address_operand" "p")
15192             (match_operand:SI 1 "immediate_operand" "n")] 35)]
15193   "TARGET_SSE"
15194   "*
15195 {
15196   switch (INTVAL (operands[1]))
15197     {
15198     case 0:
15199       return \"prefetchnta\\t%a0\";
15200     case 1:
15201       return \"prefetcht0\\t%a0\";
15202     case 2:
15203       return \"prefetcht1\\t%a0\";
15204     case 3:
15205       return \"prefetcht2\\t%a0\";
15206     default:
15207       abort ();
15208     }
15209 }"
15210   [(set_attr "type" "sse")])
15211