]> gcc.gnu.org Git - gcc.git/blob - gcc/config/i386/i386.md
i386.md (prefetch): Tidy.
[gcc.git] / gcc / config / i386 / i386.md
1 ;; GCC machine description for IA-32 and x86-64.
2 ;; Copyright (C) 1988, 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002
3 ;; Free Software Foundation, Inc.
4 ;; Mostly by William Schelter.
5 ;; x86_64 support added by Jan Hubicka
6 ;;
7 ;; This file is part of GNU CC.
8 ;;
9 ;; GNU CC is free software; you can redistribute it and/or modify
10 ;; it under the terms of the GNU General Public License as published by
11 ;; the Free Software Foundation; either version 2, or (at your option)
12 ;; any later version.
13 ;;
14 ;; GNU CC is distributed in the hope that it will be useful,
15 ;; but WITHOUT ANY WARRANTY; without even the implied warranty of
16 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 ;; GNU General Public License for more details.
18 ;;
19 ;; You should have received a copy of the GNU General Public License
20 ;; along with GNU CC; see the file COPYING. If not, write to
21 ;; the Free Software Foundation, 59 Temple Place - Suite 330,
22 ;; Boston, MA 02111-1307, USA. */
23 ;;
24 ;; The original PO technology requires these to be ordered by speed,
25 ;; so that assigner will pick the fastest.
26 ;;
27 ;; See file "rtl.def" for documentation on define_insn, match_*, et. al.
28 ;;
29 ;; Macro #define NOTICE_UPDATE_CC in file i386.h handles condition code
30 ;; updates for most instructions.
31 ;;
32 ;; Macro REG_CLASS_FROM_LETTER in file i386.h defines the register
33 ;; constraint letters.
34 ;;
35 ;; The special asm out single letter directives following a '%' are:
36 ;; 'z' mov%z1 would be movl, movw, or movb depending on the mode of
37 ;; operands[1].
38 ;; 'L' Print the opcode suffix for a 32-bit integer opcode.
39 ;; 'W' Print the opcode suffix for a 16-bit integer opcode.
40 ;; 'B' Print the opcode suffix for an 8-bit integer opcode.
41 ;; 'Q' Print the opcode suffix for a 64-bit float opcode.
42 ;; 'S' Print the opcode suffix for a 32-bit float opcode.
43 ;; 'T' Print the opcode suffix for an 80-bit extended real XFmode float opcode.
44 ;; 'J' Print the appropriate jump operand.
45 ;;
46 ;; 'b' Print the QImode name of the register for the indicated operand.
47 ;; %b0 would print %al if operands[0] is reg 0.
48 ;; 'w' Likewise, print the HImode name of the register.
49 ;; 'k' Likewise, print the SImode name of the register.
50 ;; 'h' Print the QImode name for a "high" register, either ah, bh, ch or dh.
51 ;; 'y' Print "st(0)" instead of "st" as a register.
52 ;;
53 ;; UNSPEC usage:
54 ;; 0 This is a `scas' operation. The mode of the UNSPEC is always SImode.
55 ;; operand 0 is the memory address to scan.
56 ;; operand 1 is a register containing the value to scan for. The mode
57 ;; of the scas opcode will be the same as the mode of this operand.
58 ;; operand 2 is the known alignment of operand 0.
59 ;; 1 This is a `sin' operation. The mode of the UNSPEC is MODE_FLOAT.
60 ;; operand 0 is the argument for `sin'.
61 ;; 2 This is a `cos' operation. The mode of the UNSPEC is MODE_FLOAT.
62 ;; operand 0 is the argument for `cos'.
63 ;; 3 This is part of a `stack probe' operation. The mode of the UNSPEC is
64 ;; always SImode. operand 0 is the size of the stack allocation.
65 ;; 4 This is the source of a fake SET of the frame pointer which is used to
66 ;; prevent insns referencing it being scheduled across the initial
67 ;; decrement of the stack pointer.
68 ;; 5 This is a `bsf' operation.
69 ;; 6 This is the @GOT offset of a PIC address.
70 ;; 7 This is the @GOTOFF offset of a PIC address.
71 ;; 8 This is a reference to a symbol's @PLT address.
72 ;; 9 This is an `fnstsw' operation.
73 ;; 10 This is a `sahf' operation.
74 ;; 11 This is a `fstcw' operation
75 ;; 12 This is behaviour of add when setting carry flag.
76 ;; 13 This is a `eh_return' placeholder.
77
78 ;; For SSE/MMX support:
79 ;; 30 This is `fix', guaranteed to be truncating.
80 ;; 31 This is a `emms' operation.
81 ;; 32 This is a `maskmov' operation.
82 ;; 33 This is a `movmsk' operation.
83 ;; 34 This is a `non-temporal' move.
84 ;; 36 This is used to distinguish COMISS from UCOMISS.
85 ;; 37 This is a `ldmxcsr' operation.
86 ;; 38 This is a forced `movaps' instruction (rather than whatever movti does)
87 ;; 39 This is a forced `movups' instruction (rather than whatever movti does)
88 ;; 40 This is a `stmxcsr' operation.
89 ;; 41 This is a `shuffle' operation.
90 ;; 42 This is a `rcp' operation.
91 ;; 43 This is a `rsqsrt' operation.
92 ;; 44 This is a `sfence' operation.
93 ;; 45 This is a noop to prevent excessive combiner cleverness.
94 ;; 46 This is a `femms' operation.
95 ;; 49 This is a 'pavgusb' operation.
96 ;; 50 This is a `pfrcp' operation.
97 ;; 51 This is a `pfrcpit1' operation.
98 ;; 52 This is a `pfrcpit2' operation.
99 ;; 53 This is a `pfrsqrt' operation.
100 ;; 54 This is a `pfrsqrit1' operation.
101
102 ;; Insns whose names begin with "x86_" are emitted by gen_FOO calls
103 ;; from i386.c.
104
105 ;; In C guard expressions, put expressions which may be compile-time
106 ;; constants first. This allows for better optimization. For
107 ;; example, write "TARGET_64BIT && reload_completed", not
108 ;; "reload_completed && TARGET_64BIT".
109
110 \f
111 ;; Processor type. This attribute must exactly match the processor_type
112 ;; enumeration in i386.h.
113 (define_attr "cpu" "i386,i486,pentium,pentiumpro,k6,athlon,pentium4"
114 (const (symbol_ref "ix86_cpu")))
115
116 ;; A basic instruction type. Refinements due to arguments to be
117 ;; provided in other attributes.
118 (define_attr "type"
119 "other,multi,alu1,negnot,alu,icmp,test,imov,imovx,lea,incdec,ishift,imul,idiv,ibr,setcc,push,pop,call,callv,icmov,fmov,fop,fop1,fsgn,fmul,fdiv,fpspc,fcmov,fcmp,fxch,str,cld,sse,mmx,fistp"
120 (const_string "other"))
121
122 ;; Main data type used by the insn
123 (define_attr "mode" "unknown,none,QI,HI,SI,DI,unknownfp,SF,DF,XF,TI"
124 (const_string "unknown"))
125
126 ;; Set for i387 operations.
127 (define_attr "i387" ""
128 (if_then_else (eq_attr "type" "fmov,fop,fop1,fsgn,fmul,fdiv,fpspc,fcmov,fcmp,fxch,fistp")
129 (const_int 1)
130 (const_int 0)))
131
132 ;; The (bounding maximum) length of an instruction immediate.
133 (define_attr "length_immediate" ""
134 (cond [(eq_attr "type" "incdec,setcc,icmov,ibr,str,cld,lea,other,multi,idiv,sse,mmx")
135 (const_int 0)
136 (eq_attr "i387" "1")
137 (const_int 0)
138 (eq_attr "type" "alu1,negnot,alu,icmp,imovx,ishift,imul,push,pop")
139 (symbol_ref "ix86_attr_length_immediate_default(insn,1)")
140 (eq_attr "type" "imov,test")
141 (symbol_ref "ix86_attr_length_immediate_default(insn,0)")
142 (eq_attr "type" "call")
143 (if_then_else (match_operand 0 "constant_call_address_operand" "")
144 (const_int 4)
145 (const_int 0))
146 (eq_attr "type" "callv")
147 (if_then_else (match_operand 1 "constant_call_address_operand" "")
148 (const_int 4)
149 (const_int 0))
150 (eq_attr "type" "ibr")
151 (if_then_else (and (ge (minus (match_dup 0) (pc))
152 (const_int -128))
153 (lt (minus (match_dup 0) (pc))
154 (const_int 124)))
155 (const_int 1)
156 (const_int 4))
157 ]
158 (symbol_ref "/* Update immediate_length and other attributes! */ abort(),1")))
159
160 ;; The (bounding maximum) length of an instruction address.
161 (define_attr "length_address" ""
162 (cond [(eq_attr "type" "str,cld,other,multi,fxch")
163 (const_int 0)
164 (and (eq_attr "type" "call")
165 (match_operand 1 "constant_call_address_operand" ""))
166 (const_int 0)
167 (and (eq_attr "type" "callv")
168 (match_operand 1 "constant_call_address_operand" ""))
169 (const_int 0)
170 ]
171 (symbol_ref "ix86_attr_length_address_default (insn)")))
172
173 ;; Set when length prefix is used.
174 (define_attr "prefix_data16" ""
175 (if_then_else (eq_attr "mode" "HI")
176 (const_int 1)
177 (const_int 0)))
178
179 ;; Set when string REP prefix is used.
180 (define_attr "prefix_rep" "" (const_int 0))
181
182 ;; Set when 0f opcode prefix is used.
183 (define_attr "prefix_0f" ""
184 (if_then_else (eq_attr "type" "imovx,setcc,icmov,sse,mmx")
185 (const_int 1)
186 (const_int 0)))
187
188 ;; Set when modrm byte is used.
189 (define_attr "modrm" ""
190 (cond [(eq_attr "type" "str,cld")
191 (const_int 0)
192 (eq_attr "i387" "1")
193 (const_int 0)
194 (and (eq_attr "type" "incdec")
195 (ior (match_operand:SI 1 "register_operand" "")
196 (match_operand:HI 1 "register_operand" "")))
197 (const_int 0)
198 (and (eq_attr "type" "push")
199 (not (match_operand 1 "memory_operand" "")))
200 (const_int 0)
201 (and (eq_attr "type" "pop")
202 (not (match_operand 0 "memory_operand" "")))
203 (const_int 0)
204 (and (eq_attr "type" "imov")
205 (and (match_operand 0 "register_operand" "")
206 (match_operand 1 "immediate_operand" "")))
207 (const_int 0)
208 ]
209 (const_int 1)))
210
211 ;; The (bounding maximum) length of an instruction in bytes.
212 ;; ??? fistp is in fact fldcw/fistp/fldcw sequence. Later we may want
213 ;; to split it and compute proper length as for other insns.
214 (define_attr "length" ""
215 (cond [(eq_attr "type" "other,multi,fistp")
216 (const_int 16)
217 ]
218 (plus (plus (attr "modrm")
219 (plus (attr "prefix_0f")
220 (plus (attr "i387")
221 (const_int 1))))
222 (plus (attr "prefix_rep")
223 (plus (attr "prefix_data16")
224 (plus (attr "length_immediate")
225 (attr "length_address")))))))
226
227 ;; The `memory' attribute is `none' if no memory is referenced, `load' or
228 ;; `store' if there is a simple memory reference therein, or `unknown'
229 ;; if the instruction is complex.
230
231 (define_attr "memory" "none,load,store,both,unknown"
232 (cond [(eq_attr "type" "other,multi,str")
233 (const_string "unknown")
234 (eq_attr "type" "lea,fcmov,fpspc,cld")
235 (const_string "none")
236 (eq_attr "type" "fistp")
237 (const_string "both")
238 (eq_attr "type" "push")
239 (if_then_else (match_operand 1 "memory_operand" "")
240 (const_string "both")
241 (const_string "store"))
242 (eq_attr "type" "pop,setcc")
243 (if_then_else (match_operand 0 "memory_operand" "")
244 (const_string "both")
245 (const_string "load"))
246 (eq_attr "type" "icmp,test")
247 (if_then_else (ior (match_operand 0 "memory_operand" "")
248 (match_operand 1 "memory_operand" ""))
249 (const_string "load")
250 (const_string "none"))
251 (eq_attr "type" "ibr")
252 (if_then_else (match_operand 0 "memory_operand" "")
253 (const_string "load")
254 (const_string "none"))
255 (eq_attr "type" "call")
256 (if_then_else (match_operand 0 "constant_call_address_operand" "")
257 (const_string "none")
258 (const_string "load"))
259 (eq_attr "type" "callv")
260 (if_then_else (match_operand 1 "constant_call_address_operand" "")
261 (const_string "none")
262 (const_string "load"))
263 (and (eq_attr "type" "alu1,negnot")
264 (match_operand 1 "memory_operand" ""))
265 (const_string "both")
266 (and (match_operand 0 "memory_operand" "")
267 (match_operand 1 "memory_operand" ""))
268 (const_string "both")
269 (match_operand 0 "memory_operand" "")
270 (const_string "store")
271 (match_operand 1 "memory_operand" "")
272 (const_string "load")
273 (and (eq_attr "type" "!icmp,test,alu1,negnot,fop1,fsgn,imov,imovx,fmov,fcmp,sse,mmx")
274 (match_operand 2 "memory_operand" ""))
275 (const_string "load")
276 (and (eq_attr "type" "icmov")
277 (match_operand 3 "memory_operand" ""))
278 (const_string "load")
279 ]
280 (const_string "none")))
281
282 ;; Indicates if an instruction has both an immediate and a displacement.
283
284 (define_attr "imm_disp" "false,true,unknown"
285 (cond [(eq_attr "type" "other,multi")
286 (const_string "unknown")
287 (and (eq_attr "type" "icmp,test,imov")
288 (and (match_operand 0 "memory_displacement_operand" "")
289 (match_operand 1 "immediate_operand" "")))
290 (const_string "true")
291 (and (eq_attr "type" "alu,ishift,imul,idiv")
292 (and (match_operand 0 "memory_displacement_operand" "")
293 (match_operand 2 "immediate_operand" "")))
294 (const_string "true")
295 ]
296 (const_string "false")))
297
298 ;; Indicates if an FP operation has an integer source.
299
300 (define_attr "fp_int_src" "false,true"
301 (const_string "false"))
302
303 ;; Describe a user's asm statement.
304 (define_asm_attributes
305 [(set_attr "length" "128")
306 (set_attr "type" "multi")])
307 \f
308 ;; Pentium Scheduling
309 ;;
310 ;; The Pentium is an in-order core with two integer pipelines.
311
312 ;; True for insns that behave like prefixed insns on the Pentium.
313 (define_attr "pent_prefix" "false,true"
314 (if_then_else (ior (eq_attr "prefix_0f" "1")
315 (ior (eq_attr "prefix_data16" "1")
316 (eq_attr "prefix_rep" "1")))
317 (const_string "true")
318 (const_string "false")))
319
320 ;; Categorize how an instruction slots.
321
322 ;; The non-MMX Pentium slots an instruction with prefixes on U pipe only,
323 ;; while MMX Pentium can slot it on either U or V. Model non-MMX Pentium
324 ;; rules, because it results in noticeably better code on non-MMX Pentium
325 ;; and doesn't hurt much on MMX. (Prefixed instructions are not very
326 ;; common, so the scheduler usualy has a non-prefixed insn to pair).
327
328 (define_attr "pent_pair" "uv,pu,pv,np"
329 (cond [(eq_attr "imm_disp" "true")
330 (const_string "np")
331 (ior (eq_attr "type" "alu1,alu,imov,icmp,test,lea,incdec")
332 (and (eq_attr "type" "pop,push")
333 (eq_attr "memory" "!both")))
334 (if_then_else (eq_attr "pent_prefix" "true")
335 (const_string "pu")
336 (const_string "uv"))
337 (eq_attr "type" "ibr")
338 (const_string "pv")
339 (and (eq_attr "type" "ishift")
340 (match_operand 2 "const_int_operand" ""))
341 (const_string "pu")
342 (and (eq_attr "type" "call")
343 (match_operand 0 "constant_call_address_operand" ""))
344 (const_string "pv")
345 (and (eq_attr "type" "callv")
346 (match_operand 1 "constant_call_address_operand" ""))
347 (const_string "pv")
348 ]
349 (const_string "np")))
350
351 ;; Rough readiness numbers. Fine tuning happens in i386.c.
352 ;;
353 ;; u describes pipe U
354 ;; v describes pipe V
355 ;; uv describes either pipe U or V for those that can issue to either
356 ;; np describes not paring
357 ;; fpu describes fpu
358 ;; fpm describes fp insns of different types are not pipelined.
359 ;;
360 ;; ??? fxch isn't handled; not an issue until sched3 after reg-stack is real.
361
362 (define_function_unit "pent_np" 1 0
363 (and (eq_attr "cpu" "pentium")
364 (eq_attr "type" "imul"))
365 11 11)
366
367 (define_function_unit "pent_mul" 1 1
368 (and (eq_attr "cpu" "pentium")
369 (eq_attr "type" "imul"))
370 11 11)
371
372 ;; Rep movs takes minimally 12 cycles.
373 (define_function_unit "pent_np" 1 0
374 (and (eq_attr "cpu" "pentium")
375 (eq_attr "type" "str"))
376 12 12)
377
378 ; ??? IDIV for SI takes 46 cycles, for HI 30, for QI 22
379 (define_function_unit "pent_np" 1 0
380 (and (eq_attr "cpu" "pentium")
381 (eq_attr "type" "idiv"))
382 46 46)
383
384 ; Fp reg-reg moves takes 1 cycle. Loads takes 1 cycle for SF/DF mode,
385 ; 3 cycles for XFmode. Stores takes 2 cycles for SF/DF and 3 for XF.
386 ; fldz and fld1 takes 2 cycles. Only reg-reg moves are pairable.
387 ; The integer <-> fp conversion is not modeled correctly. Fild behaves
388 ; like normal fp operation and fist takes 6 cycles.
389
390 (define_function_unit "fpu" 1 0
391 (and (eq_attr "cpu" "pentium")
392 (and (eq_attr "type" "fmov")
393 (and (eq_attr "memory" "load,store")
394 (eq_attr "mode" "XF"))))
395 3 3)
396
397 (define_function_unit "pent_np" 1 0
398 (and (eq_attr "cpu" "pentium")
399 (and (eq_attr "type" "fmov")
400 (and (eq_attr "memory" "load,store")
401 (eq_attr "mode" "XF"))))
402 3 3)
403
404 (define_function_unit "fpu" 1 0
405 (and (eq_attr "cpu" "pentium")
406 (and (eq_attr "type" "fmov")
407 (ior (match_operand 1 "immediate_operand" "")
408 (eq_attr "memory" "store"))))
409 2 2)
410
411 (define_function_unit "pent_np" 1 0
412 (and (eq_attr "cpu" "pentium")
413 (and (eq_attr "type" "fmov")
414 (ior (match_operand 1 "immediate_operand" "")
415 (eq_attr "memory" "store"))))
416 2 2)
417
418 (define_function_unit "pent_np" 1 0
419 (and (eq_attr "cpu" "pentium")
420 (eq_attr "type" "cld"))
421 2 2)
422
423 (define_function_unit "fpu" 1 0
424 (and (eq_attr "cpu" "pentium")
425 (and (eq_attr "type" "fmov")
426 (eq_attr "memory" "none,load")))
427 1 1)
428
429 ; Read/Modify/Write instructions usually take 3 cycles.
430 (define_function_unit "pent_u" 1 0
431 (and (eq_attr "cpu" "pentium")
432 (and (eq_attr "type" "alu,alu1,ishift")
433 (and (eq_attr "pent_pair" "pu")
434 (eq_attr "memory" "both"))))
435 3 3)
436
437 (define_function_unit "pent_uv" 2 0
438 (and (eq_attr "cpu" "pentium")
439 (and (eq_attr "type" "alu,alu1,ishift")
440 (and (eq_attr "pent_pair" "!np")
441 (eq_attr "memory" "both"))))
442 3 3)
443
444 (define_function_unit "pent_np" 1 0
445 (and (eq_attr "cpu" "pentium")
446 (and (eq_attr "type" "alu,alu1,negnot,ishift")
447 (and (eq_attr "pent_pair" "np")
448 (eq_attr "memory" "both"))))
449 3 3)
450
451 ; Read/Modify or Modify/Write instructions usually take 2 cycles.
452 (define_function_unit "pent_u" 1 0
453 (and (eq_attr "cpu" "pentium")
454 (and (eq_attr "type" "alu,ishift")
455 (and (eq_attr "pent_pair" "pu")
456 (eq_attr "memory" "load,store"))))
457 2 2)
458
459 (define_function_unit "pent_uv" 2 0
460 (and (eq_attr "cpu" "pentium")
461 (and (eq_attr "type" "alu,ishift")
462 (and (eq_attr "pent_pair" "!np")
463 (eq_attr "memory" "load,store"))))
464 2 2)
465
466 (define_function_unit "pent_np" 1 0
467 (and (eq_attr "cpu" "pentium")
468 (and (eq_attr "type" "alu,ishift")
469 (and (eq_attr "pent_pair" "np")
470 (eq_attr "memory" "load,store"))))
471 2 2)
472
473 ; Insns w/o memory operands and move instructions usually take one cycle.
474 (define_function_unit "pent_u" 1 0
475 (and (eq_attr "cpu" "pentium")
476 (eq_attr "pent_pair" "pu"))
477 1 1)
478
479 (define_function_unit "pent_v" 1 0
480 (and (eq_attr "cpu" "pentium")
481 (eq_attr "pent_pair" "pv"))
482 1 1)
483
484 (define_function_unit "pent_uv" 2 0
485 (and (eq_attr "cpu" "pentium")
486 (eq_attr "pent_pair" "!np"))
487 1 1)
488
489 (define_function_unit "pent_np" 1 0
490 (and (eq_attr "cpu" "pentium")
491 (eq_attr "pent_pair" "np"))
492 1 1)
493
494 ; Pairable insns only conflict with other non-pairable insns.
495 (define_function_unit "pent_np" 1 0
496 (and (eq_attr "cpu" "pentium")
497 (and (eq_attr "type" "alu,alu1,ishift")
498 (and (eq_attr "pent_pair" "!np")
499 (eq_attr "memory" "both"))))
500 3 3
501 [(eq_attr "pent_pair" "np")])
502
503 (define_function_unit "pent_np" 1 0
504 (and (eq_attr "cpu" "pentium")
505 (and (eq_attr "type" "alu,alu1,ishift")
506 (and (eq_attr "pent_pair" "!np")
507 (eq_attr "memory" "load,store"))))
508 2 2
509 [(eq_attr "pent_pair" "np")])
510
511 (define_function_unit "pent_np" 1 0
512 (and (eq_attr "cpu" "pentium")
513 (eq_attr "pent_pair" "!np"))
514 1 1
515 [(eq_attr "pent_pair" "np")])
516
517 ; Floating point instructions usually blocks cycle longer when combined with
518 ; integer instructions, because of the inpaired fxch instruction.
519 (define_function_unit "pent_np" 1 0
520 (and (eq_attr "cpu" "pentium")
521 (eq_attr "type" "fmov,fop,fop1,fsgn,fmul,fpspc,fcmov,fcmp,fistp"))
522 2 2
523 [(eq_attr "type" "!fmov,fop,fop1,fsgn,fmul,fpspc,fcmov,fcmp,fistp")])
524
525 (define_function_unit "fpu" 1 0
526 (and (eq_attr "cpu" "pentium")
527 (eq_attr "type" "fcmp,fxch,fsgn"))
528 1 1)
529
530 ; Addition takes 3 cycles; assume other random cruft does as well.
531 ; ??? Trivial fp operations such as fabs or fchs takes only one cycle.
532 (define_function_unit "fpu" 1 0
533 (and (eq_attr "cpu" "pentium")
534 (eq_attr "type" "fop,fop1,fistp"))
535 3 1)
536
537 ; Multiplication takes 3 cycles and is only half pipelined.
538 (define_function_unit "fpu" 1 0
539 (and (eq_attr "cpu" "pentium")
540 (eq_attr "type" "fmul"))
541 3 1)
542
543 (define_function_unit "pent_mul" 1 1
544 (and (eq_attr "cpu" "pentium")
545 (eq_attr "type" "fmul"))
546 2 2)
547
548 ; ??? This is correct only for fdiv and sqrt -- sin/cos take 65-100 cycles.
549 ; They can overlap with integer insns. Only the last two cycles can overlap
550 ; with other fp insns. Only fsin/fcos can overlap with multiplies.
551 ; Only last two cycles of fsin/fcos can overlap with other instructions.
552 (define_function_unit "fpu" 1 0
553 (and (eq_attr "cpu" "pentium")
554 (eq_attr "type" "fdiv"))
555 39 37)
556
557 (define_function_unit "pent_mul" 1 1
558 (and (eq_attr "cpu" "pentium")
559 (eq_attr "type" "fdiv"))
560 39 39)
561
562 (define_function_unit "fpu" 1 0
563 (and (eq_attr "cpu" "pentium")
564 (eq_attr "type" "fpspc"))
565 70 68)
566
567 (define_function_unit "pent_mul" 1 1
568 (and (eq_attr "cpu" "pentium")
569 (eq_attr "type" "fpspc"))
570 70 70)
571 \f
572 ;; Pentium Pro/PII Scheduling
573 ;;
574 ;; The PPro has an out-of-order core, but the instruction decoders are
575 ;; naturally in-order and asymmetric. We get best performance by scheduling
576 ;; for the decoders, for in doing so we give the oo execution unit the
577 ;; most choices.
578
579 ;; Categorize how many uops an ia32 instruction evaluates to:
580 ;; one -- an instruction with 1 uop can be decoded by any of the
581 ;; three decoders.
582 ;; few -- an instruction with 1 to 4 uops can be decoded only by
583 ;; decoder 0.
584 ;; many -- a complex instruction may take an unspecified number of
585 ;; cycles to decode in decoder 0.
586
587 (define_attr "ppro_uops" "one,few,many"
588 (cond [(eq_attr "type" "other,multi,call,callv,fpspc,str")
589 (const_string "many")
590 (eq_attr "type" "icmov,fcmov,str,cld")
591 (const_string "few")
592 (eq_attr "type" "imov")
593 (if_then_else (eq_attr "memory" "store,both")
594 (const_string "few")
595 (const_string "one"))
596 (eq_attr "memory" "!none")
597 (const_string "few")
598 ]
599 (const_string "one")))
600
601 ;; Rough readiness numbers. Fine tuning happens in i386.c.
602 ;;
603 ;; p0 describes port 0.
604 ;; p01 describes ports 0 and 1 as a pair; alu insns can issue to either.
605 ;; p2 describes port 2 for loads.
606 ;; p34 describes ports 3 and 4 for stores.
607 ;; fpu describes the fpu accessed via port 0.
608 ;; ??? It is less than clear if there are separate fadd and fmul units
609 ;; that could operate in parallel.
610 ;;
611 ;; ??? fxch isn't handled; not an issue until sched3 after reg-stack is real.
612
613 (define_function_unit "ppro_p0" 1 0
614 (and (eq_attr "cpu" "pentiumpro")
615 (eq_attr "type" "ishift,lea,ibr,cld"))
616 1 1)
617
618 (define_function_unit "ppro_p0" 1 0
619 (and (eq_attr "cpu" "pentiumpro")
620 (eq_attr "type" "imul"))
621 4 1)
622
623 ;; ??? Does the divider lock out the pipe while it works,
624 ;; or is there a disconnected unit?
625 (define_function_unit "ppro_p0" 1 0
626 (and (eq_attr "cpu" "pentiumpro")
627 (eq_attr "type" "idiv"))
628 17 17)
629
630 (define_function_unit "ppro_p0" 1 0
631 (and (eq_attr "cpu" "pentiumpro")
632 (eq_attr "type" "fop,fop1,fsgn,fistp"))
633 3 1)
634
635 (define_function_unit "ppro_p0" 1 0
636 (and (eq_attr "cpu" "pentiumpro")
637 (eq_attr "type" "fcmov"))
638 2 1)
639
640 (define_function_unit "ppro_p0" 1 0
641 (and (eq_attr "cpu" "pentiumpro")
642 (eq_attr "type" "fcmp"))
643 1 1)
644
645 (define_function_unit "ppro_p0" 1 0
646 (and (eq_attr "cpu" "pentiumpro")
647 (eq_attr "type" "fmov"))
648 1 1)
649
650 (define_function_unit "ppro_p0" 1 0
651 (and (eq_attr "cpu" "pentiumpro")
652 (eq_attr "type" "fmul"))
653 5 1)
654
655 (define_function_unit "ppro_p0" 1 0
656 (and (eq_attr "cpu" "pentiumpro")
657 (eq_attr "type" "fdiv,fpspc"))
658 56 1)
659
660 (define_function_unit "ppro_p01" 2 0
661 (and (eq_attr "cpu" "pentiumpro")
662 (eq_attr "type" "!imov,fmov"))
663 1 1)
664
665 (define_function_unit "ppro_p01" 2 0
666 (and (and (eq_attr "cpu" "pentiumpro")
667 (eq_attr "type" "imov,fmov"))
668 (eq_attr "memory" "none"))
669 1 1)
670
671 (define_function_unit "ppro_p2" 1 0
672 (and (eq_attr "cpu" "pentiumpro")
673 (ior (eq_attr "type" "pop")
674 (eq_attr "memory" "load,both")))
675 3 1)
676
677 (define_function_unit "ppro_p34" 1 0
678 (and (eq_attr "cpu" "pentiumpro")
679 (ior (eq_attr "type" "push")
680 (eq_attr "memory" "store,both")))
681 1 1)
682
683 (define_function_unit "fpu" 1 0
684 (and (eq_attr "cpu" "pentiumpro")
685 (eq_attr "type" "fop,fop1,fsgn,fmov,fcmp,fcmov,fistp"))
686 1 1)
687
688 (define_function_unit "fpu" 1 0
689 (and (eq_attr "cpu" "pentiumpro")
690 (eq_attr "type" "fmul"))
691 5 2)
692
693 (define_function_unit "fpu" 1 0
694 (and (eq_attr "cpu" "pentiumpro")
695 (eq_attr "type" "fdiv,fpspc"))
696 56 56)
697
698 ;; imul uses the fpu. ??? does it have the same throughput as fmul?
699 (define_function_unit "fpu" 1 0
700 (and (eq_attr "cpu" "pentiumpro")
701 (eq_attr "type" "imul"))
702 4 1)
703 \f
704 ;; AMD K6/K6-2 Scheduling
705 ;;
706 ;; The K6 has similar architecture to PPro. Important difference is, that
707 ;; there are only two decoders and they seems to be much slower than execution
708 ;; units. So we have to pay much more attention to proper decoding for
709 ;; schedulers. We share most of scheduler code for PPro in i386.c
710 ;;
711 ;; The fp unit is not pipelined and do one operation per two cycles including
712 ;; the FXCH.
713 ;;
714 ;; alu describes both ALU units (ALU-X and ALU-Y).
715 ;; alux describes X alu unit
716 ;; fpu describes FPU unit
717 ;; load describes load unit.
718 ;; branch describes branch unit.
719 ;; store decsribes store unit. This unit is not modelled completely and only
720 ;; used to model lea operation. Otherwise it lie outside of the critical
721 ;; path.
722 ;;
723 ;; ??? fxch isn't handled; not an issue until sched3 after reg-stack is real.
724
725 ;; The decoder specification is in the PPro section above!
726
727 ;; Shift instructions and certain arithmetic are issued only to X pipe.
728 (define_function_unit "k6_alux" 1 0
729 (and (eq_attr "cpu" "k6")
730 (eq_attr "type" "ishift,alu1,negnot,cld"))
731 1 1)
732
733 ;; The QI mode arithmetic is issued to X pipe only.
734 (define_function_unit "k6_alux" 1 0
735 (and (eq_attr "cpu" "k6")
736 (and (eq_attr "type" "alu,alu1,negnot,icmp,test,imovx,incdec")
737 (match_operand:QI 0 "general_operand" "")))
738 1 1)
739
740 (define_function_unit "k6_alu" 2 0
741 (and (eq_attr "cpu" "k6")
742 (eq_attr "type" "ishift,alu1,negnot,alu,icmp,test,imovx,incdec,setcc,lea"))
743 1 1)
744
745 (define_function_unit "k6_alu" 2 0
746 (and (eq_attr "cpu" "k6")
747 (and (eq_attr "type" "imov")
748 (eq_attr "memory" "none")))
749 1 1)
750
751 (define_function_unit "k6_branch" 1 0
752 (and (eq_attr "cpu" "k6")
753 (eq_attr "type" "call,callv,ibr"))
754 1 1)
755
756 ;; Load unit have two cycle latency, but we take care for it in adjust_cost
757 (define_function_unit "k6_load" 1 0
758 (and (eq_attr "cpu" "k6")
759 (ior (eq_attr "type" "pop")
760 (eq_attr "memory" "load,both")))
761 1 1)
762
763 (define_function_unit "k6_load" 1 0
764 (and (eq_attr "cpu" "k6")
765 (and (eq_attr "type" "str")
766 (eq_attr "memory" "load,both")))
767 10 10)
768
769 ;; Lea have two instructions, so latency is probably 2
770 (define_function_unit "k6_store" 1 0
771 (and (eq_attr "cpu" "k6")
772 (eq_attr "type" "lea"))
773 2 1)
774
775 (define_function_unit "k6_store" 1 0
776 (and (eq_attr "cpu" "k6")
777 (eq_attr "type" "str"))
778 10 10)
779
780 (define_function_unit "k6_store" 1 0
781 (and (eq_attr "cpu" "k6")
782 (ior (eq_attr "type" "push")
783 (eq_attr "memory" "store,both")))
784 1 1)
785
786 (define_function_unit "k6_fpu" 1 1
787 (and (eq_attr "cpu" "k6")
788 (eq_attr "type" "fop,fop1,fmov,fcmp,fistp"))
789 2 2)
790
791 (define_function_unit "k6_fpu" 1 1
792 (and (eq_attr "cpu" "k6")
793 (eq_attr "type" "fmul"))
794 2 2)
795
796 ;; ??? Guess
797 (define_function_unit "k6_fpu" 1 1
798 (and (eq_attr "cpu" "k6")
799 (eq_attr "type" "fdiv,fpspc"))
800 56 56)
801
802 (define_function_unit "k6_alu" 2 0
803 (and (eq_attr "cpu" "k6")
804 (eq_attr "type" "imul"))
805 2 2)
806
807 (define_function_unit "k6_alux" 1 0
808 (and (eq_attr "cpu" "k6")
809 (eq_attr "type" "imul"))
810 2 2)
811
812 ;; ??? Guess
813 (define_function_unit "k6_alu" 2 0
814 (and (eq_attr "cpu" "k6")
815 (eq_attr "type" "idiv"))
816 17 17)
817
818 (define_function_unit "k6_alux" 1 0
819 (and (eq_attr "cpu" "k6")
820 (eq_attr "type" "idiv"))
821 17 17)
822 \f
823 ;; AMD Athlon Scheduling
824 ;;
825 ;; The Athlon does contain three pipelined FP units, three integer units and
826 ;; three address generation units.
827 ;;
828 ;; The predecode logic is determining boundaries of instructions in the 64
829 ;; byte cache line. So the cache line straddling problem of K6 might be issue
830 ;; here as well, but it is not noted in the documentation.
831 ;;
832 ;; Three DirectPath instructions decoders and only one VectorPath decoder
833 ;; is available. They can decode three DirectPath instructions or one VectorPath
834 ;; instruction per cycle.
835 ;; Decoded macro instructions are then passed to 72 entry instruction control
836 ;; unit, that passes
837 ;; it to the specialized integer (18 entry) and fp (36 entry) schedulers.
838 ;;
839 ;; The load/store queue unit is not attached to the schedulers but
840 ;; communicates with all the execution units separately instead.
841
842 (define_attr "athlon_decode" "direct,vector"
843 (cond [(eq_attr "type" "call,imul,idiv,other,multi,fcmov,fpspc,str,pop,cld,fcmov")
844 (const_string "vector")
845 (and (eq_attr "type" "push")
846 (match_operand 1 "memory_operand" ""))
847 (const_string "vector")
848 (and (eq_attr "type" "fmov")
849 (and (eq_attr "memory" "load,store")
850 (eq_attr "mode" "XF")))
851 (const_string "vector")]
852 (const_string "direct")))
853
854 (define_function_unit "athlon_vectordec" 1 0
855 (and (eq_attr "cpu" "athlon")
856 (eq_attr "athlon_decode" "vector"))
857 1 1)
858
859 (define_function_unit "athlon_directdec" 3 0
860 (and (eq_attr "cpu" "athlon")
861 (eq_attr "athlon_decode" "direct"))
862 1 1)
863
864 (define_function_unit "athlon_vectordec" 1 0
865 (and (eq_attr "cpu" "athlon")
866 (eq_attr "athlon_decode" "direct"))
867 1 1 [(eq_attr "athlon_decode" "vector")])
868
869 (define_function_unit "athlon_ieu" 3 0
870 (and (eq_attr "cpu" "athlon")
871 (eq_attr "type" "alu1,negnot,alu,icmp,test,imov,imovx,lea,incdec,ishift,ibr,call,callv,icmov,cld,pop,setcc,push,pop"))
872 1 1)
873
874 (define_function_unit "athlon_ieu" 3 0
875 (and (eq_attr "cpu" "athlon")
876 (eq_attr "type" "str"))
877 15 15)
878
879 (define_function_unit "athlon_ieu" 3 0
880 (and (eq_attr "cpu" "athlon")
881 (eq_attr "type" "imul"))
882 5 0)
883
884 (define_function_unit "athlon_ieu" 3 0
885 (and (eq_attr "cpu" "athlon")
886 (eq_attr "type" "idiv"))
887 42 0)
888
889 (define_function_unit "athlon_muldiv" 1 0
890 (and (eq_attr "cpu" "athlon")
891 (eq_attr "type" "imul"))
892 5 0)
893
894 (define_function_unit "athlon_muldiv" 1 0
895 (and (eq_attr "cpu" "athlon")
896 (eq_attr "type" "idiv"))
897 42 42)
898
899 (define_attr "athlon_fpunits" "none,store,mul,add,muladd,any"
900 (cond [(eq_attr "type" "fop,fop1,fcmp,fistp")
901 (const_string "add")
902 (eq_attr "type" "fmul,fdiv,fpspc,fsgn,fcmov")
903 (const_string "mul")
904 (and (eq_attr "type" "fmov") (eq_attr "memory" "store,both"))
905 (const_string "store")
906 (and (eq_attr "type" "fmov") (eq_attr "memory" "load"))
907 (const_string "any")
908 (and (eq_attr "type" "fmov")
909 (ior (match_operand:SI 1 "register_operand" "")
910 (match_operand 1 "immediate_operand" "")))
911 (const_string "store")
912 (eq_attr "type" "fmov")
913 (const_string "muladd")]
914 (const_string "none")))
915
916 ;; We use latencies 1 for definitions. This is OK to model colisions
917 ;; in execution units. The real latencies are modeled in the "fp" pipeline.
918
919 ;; fsin, fcos: 96-192
920 ;; fsincos: 107-211
921 ;; fsqrt: 19 for SFmode, 27 for DFmode, 35 for XFmode.
922 (define_function_unit "athlon_fp" 3 0
923 (and (eq_attr "cpu" "athlon")
924 (eq_attr "type" "fpspc"))
925 100 1)
926
927 ;; 16 cycles for SFmode, 20 for DFmode and 24 for XFmode.
928 (define_function_unit "athlon_fp" 3 0
929 (and (eq_attr "cpu" "athlon")
930 (eq_attr "type" "fdiv"))
931 24 1)
932
933 (define_function_unit "athlon_fp" 3 0
934 (and (eq_attr "cpu" "athlon")
935 (eq_attr "type" "fop,fop1,fmul,fistp"))
936 4 1)
937
938 ;; XFmode loads are slow.
939 ;; XFmode store is slow too (8 cycles), but we don't need to model it, because
940 ;; there are no dependent instructions.
941
942 (define_function_unit "athlon_fp" 3 0
943 (and (eq_attr "cpu" "athlon")
944 (and (eq_attr "type" "fmov")
945 (and (eq_attr "memory" "load")
946 (eq_attr "mode" "XF"))))
947 10 1)
948
949 (define_function_unit "athlon_fp" 3 0
950 (and (eq_attr "cpu" "athlon")
951 (eq_attr "type" "fmov,fsgn"))
952 2 1)
953
954 ;; fcmp and ftst instructions
955 (define_function_unit "athlon_fp" 3 0
956 (and (eq_attr "cpu" "athlon")
957 (and (eq_attr "type" "fcmp")
958 (eq_attr "athlon_decode" "direct")))
959 3 1)
960
961 ;; fcmpi instructions.
962 (define_function_unit "athlon_fp" 3 0
963 (and (eq_attr "cpu" "athlon")
964 (and (eq_attr "type" "fcmp")
965 (eq_attr "athlon_decode" "vector")))
966 3 1)
967
968 (define_function_unit "athlon_fp" 3 0
969 (and (eq_attr "cpu" "athlon")
970 (eq_attr "type" "fcmov"))
971 7 1)
972
973 (define_function_unit "athlon_fp_mul" 1 0
974 (and (eq_attr "cpu" "athlon")
975 (eq_attr "athlon_fpunits" "mul"))
976 1 1)
977
978 (define_function_unit "athlon_fp_add" 1 0
979 (and (eq_attr "cpu" "athlon")
980 (eq_attr "athlon_fpunits" "add"))
981 1 1)
982
983 (define_function_unit "athlon_fp_muladd" 2 0
984 (and (eq_attr "cpu" "athlon")
985 (eq_attr "athlon_fpunits" "muladd,mul,add"))
986 1 1)
987
988 (define_function_unit "athlon_fp_store" 1 0
989 (and (eq_attr "cpu" "athlon")
990 (eq_attr "athlon_fpunits" "store"))
991 1 1)
992
993 ;; We don't need to model the Address Generation Unit, since we don't model
994 ;; the re-order buffer yet and thus we never schedule more than three operations
995 ;; at time. Later we may want to experiment with MD_SCHED macros modeling the
996 ;; decoders independently on the functional units.
997
998 ;(define_function_unit "athlon_agu" 3 0
999 ; (and (eq_attr "cpu" "athlon")
1000 ; (and (eq_attr "memory" "!none")
1001 ; (eq_attr "athlon_fpunits" "none")))
1002 ; 1 1)
1003
1004 ;; Model load unit to avoid too long sequences of loads. We don't need to
1005 ;; model store queue, since it is hardly going to be bottleneck.
1006
1007 (define_function_unit "athlon_load" 2 0
1008 (and (eq_attr "cpu" "athlon")
1009 (eq_attr "memory" "load,both"))
1010 1 1)
1011
1012 \f
1013 ;; Compare instructions.
1014
1015 ;; All compare insns have expanders that save the operands away without
1016 ;; actually generating RTL. The bCOND or sCOND (emitted immediately
1017 ;; after the cmp) will actually emit the cmpM.
1018
1019 (define_expand "cmpdi"
1020 [(set (reg:CC 17)
1021 (compare:CC (match_operand:DI 0 "nonimmediate_operand" "")
1022 (match_operand:DI 1 "x86_64_general_operand" "")))]
1023 ""
1024 {
1025 if (GET_CODE (operands[0]) == MEM && GET_CODE (operands[1]) == MEM)
1026 operands[0] = force_reg (DImode, operands[0]);
1027 ix86_compare_op0 = operands[0];
1028 ix86_compare_op1 = operands[1];
1029 DONE;
1030 })
1031
1032 (define_expand "cmpsi"
1033 [(set (reg:CC 17)
1034 (compare:CC (match_operand:SI 0 "cmpsi_operand" "")
1035 (match_operand:SI 1 "general_operand" "")))]
1036 ""
1037 {
1038 if (GET_CODE (operands[0]) == MEM && GET_CODE (operands[1]) == MEM)
1039 operands[0] = force_reg (SImode, operands[0]);
1040 ix86_compare_op0 = operands[0];
1041 ix86_compare_op1 = operands[1];
1042 DONE;
1043 })
1044
1045 (define_expand "cmphi"
1046 [(set (reg:CC 17)
1047 (compare:CC (match_operand:HI 0 "nonimmediate_operand" "")
1048 (match_operand:HI 1 "general_operand" "")))]
1049 ""
1050 {
1051 if (GET_CODE (operands[0]) == MEM && GET_CODE (operands[1]) == MEM)
1052 operands[0] = force_reg (HImode, operands[0]);
1053 ix86_compare_op0 = operands[0];
1054 ix86_compare_op1 = operands[1];
1055 DONE;
1056 })
1057
1058 (define_expand "cmpqi"
1059 [(set (reg:CC 17)
1060 (compare:CC (match_operand:QI 0 "nonimmediate_operand" "")
1061 (match_operand:QI 1 "general_operand" "")))]
1062 "TARGET_QIMODE_MATH"
1063 {
1064 if (GET_CODE (operands[0]) == MEM && GET_CODE (operands[1]) == MEM)
1065 operands[0] = force_reg (QImode, operands[0]);
1066 ix86_compare_op0 = operands[0];
1067 ix86_compare_op1 = operands[1];
1068 DONE;
1069 })
1070
1071 (define_insn "cmpdi_ccno_1_rex64"
1072 [(set (reg 17)
1073 (compare (match_operand:DI 0 "nonimmediate_operand" "r,?mr")
1074 (match_operand:DI 1 "const0_operand" "n,n")))]
1075 "TARGET_64BIT && ix86_match_ccmode (insn, CCNOmode)"
1076 "@
1077 test{q}\t{%0, %0|%0, %0}
1078 cmp{q}\t{%1, %0|%0, %1}"
1079 [(set_attr "type" "test,icmp")
1080 (set_attr "length_immediate" "0,1")
1081 (set_attr "mode" "DI")])
1082
1083 (define_insn "*cmpdi_minus_1_rex64"
1084 [(set (reg 17)
1085 (compare (minus:DI (match_operand:DI 0 "nonimmediate_operand" "rm,r")
1086 (match_operand:DI 1 "x86_64_general_operand" "re,mr"))
1087 (const_int 0)))]
1088 "TARGET_64BIT && ix86_match_ccmode (insn, CCGOCmode)"
1089 "cmp{q}\t{%1, %0|%0, %1}"
1090 [(set_attr "type" "icmp")
1091 (set_attr "mode" "DI")])
1092
1093 (define_expand "cmpdi_1_rex64"
1094 [(set (reg:CC 17)
1095 (compare:CC (match_operand:DI 0 "nonimmediate_operand" "")
1096 (match_operand:DI 1 "general_operand" "")))]
1097 "TARGET_64BIT"
1098 "")
1099
1100 (define_insn "cmpdi_1_insn_rex64"
1101 [(set (reg 17)
1102 (compare (match_operand:DI 0 "nonimmediate_operand" "mr,r")
1103 (match_operand:DI 1 "x86_64_general_operand" "re,mr")))]
1104 "TARGET_64BIT && ix86_match_ccmode (insn, CCmode)"
1105 "cmp{q}\t{%1, %0|%0, %1}"
1106 [(set_attr "type" "icmp")
1107 (set_attr "mode" "DI")])
1108
1109
1110 (define_insn "*cmpsi_ccno_1"
1111 [(set (reg 17)
1112 (compare (match_operand:SI 0 "nonimmediate_operand" "r,?mr")
1113 (match_operand:SI 1 "const0_operand" "n,n")))]
1114 "ix86_match_ccmode (insn, CCNOmode)"
1115 "@
1116 test{l}\t{%0, %0|%0, %0}
1117 cmp{l}\t{%1, %0|%0, %1}"
1118 [(set_attr "type" "test,icmp")
1119 (set_attr "length_immediate" "0,1")
1120 (set_attr "mode" "SI")])
1121
1122 (define_insn "*cmpsi_minus_1"
1123 [(set (reg 17)
1124 (compare (minus:SI (match_operand:SI 0 "nonimmediate_operand" "rm,r")
1125 (match_operand:SI 1 "general_operand" "ri,mr"))
1126 (const_int 0)))]
1127 "ix86_match_ccmode (insn, CCGOCmode)"
1128 "cmp{l}\t{%1, %0|%0, %1}"
1129 [(set_attr "type" "icmp")
1130 (set_attr "mode" "SI")])
1131
1132 (define_expand "cmpsi_1"
1133 [(set (reg:CC 17)
1134 (compare:CC (match_operand:SI 0 "nonimmediate_operand" "rm,r")
1135 (match_operand:SI 1 "general_operand" "ri,mr")))]
1136 ""
1137 "")
1138
1139 (define_insn "*cmpsi_1_insn"
1140 [(set (reg 17)
1141 (compare (match_operand:SI 0 "nonimmediate_operand" "rm,r")
1142 (match_operand:SI 1 "general_operand" "ri,mr")))]
1143 "(GET_CODE (operands[0]) != MEM || GET_CODE (operands[1]) != MEM)
1144 && ix86_match_ccmode (insn, CCmode)"
1145 "cmp{l}\t{%1, %0|%0, %1}"
1146 [(set_attr "type" "icmp")
1147 (set_attr "mode" "SI")])
1148
1149 (define_insn "*cmphi_ccno_1"
1150 [(set (reg 17)
1151 (compare (match_operand:HI 0 "nonimmediate_operand" "r,?mr")
1152 (match_operand:HI 1 "const0_operand" "n,n")))]
1153 "ix86_match_ccmode (insn, CCNOmode)"
1154 "@
1155 test{w}\t{%0, %0|%0, %0}
1156 cmp{w}\t{%1, %0|%0, %1}"
1157 [(set_attr "type" "test,icmp")
1158 (set_attr "length_immediate" "0,1")
1159 (set_attr "mode" "HI")])
1160
1161 (define_insn "*cmphi_minus_1"
1162 [(set (reg 17)
1163 (compare (minus:HI (match_operand:HI 0 "nonimmediate_operand" "rm,r")
1164 (match_operand:HI 1 "general_operand" "ri,mr"))
1165 (const_int 0)))]
1166 "ix86_match_ccmode (insn, CCGOCmode)"
1167 "cmp{w}\t{%1, %0|%0, %1}"
1168 [(set_attr "type" "icmp")
1169 (set_attr "mode" "HI")])
1170
1171 (define_insn "*cmphi_1"
1172 [(set (reg 17)
1173 (compare (match_operand:HI 0 "nonimmediate_operand" "rm,r")
1174 (match_operand:HI 1 "general_operand" "ri,mr")))]
1175 "(GET_CODE (operands[0]) != MEM || GET_CODE (operands[1]) != MEM)
1176 && ix86_match_ccmode (insn, CCmode)"
1177 "cmp{w}\t{%1, %0|%0, %1}"
1178 [(set_attr "type" "icmp")
1179 (set_attr "mode" "HI")])
1180
1181 (define_insn "*cmpqi_ccno_1"
1182 [(set (reg 17)
1183 (compare (match_operand:QI 0 "nonimmediate_operand" "q,?mq")
1184 (match_operand:QI 1 "const0_operand" "n,n")))]
1185 "ix86_match_ccmode (insn, CCNOmode)"
1186 "@
1187 test{b}\t{%0, %0|%0, %0}
1188 cmp{b}\t{$0, %0|%0, 0}"
1189 [(set_attr "type" "test,icmp")
1190 (set_attr "length_immediate" "0,1")
1191 (set_attr "mode" "QI")])
1192
1193 (define_insn "*cmpqi_1"
1194 [(set (reg 17)
1195 (compare (match_operand:QI 0 "nonimmediate_operand" "qm,q")
1196 (match_operand:QI 1 "general_operand" "qi,mq")))]
1197 "(GET_CODE (operands[0]) != MEM || GET_CODE (operands[1]) != MEM)
1198 && ix86_match_ccmode (insn, CCmode)"
1199 "cmp{b}\t{%1, %0|%0, %1}"
1200 [(set_attr "type" "icmp")
1201 (set_attr "mode" "QI")])
1202
1203 (define_insn "*cmpqi_minus_1"
1204 [(set (reg 17)
1205 (compare (minus:QI (match_operand:QI 0 "nonimmediate_operand" "qm,q")
1206 (match_operand:QI 1 "general_operand" "qi,mq"))
1207 (const_int 0)))]
1208 "ix86_match_ccmode (insn, CCGOCmode)"
1209 "cmp{b}\t{%1, %0|%0, %1}"
1210 [(set_attr "type" "icmp")
1211 (set_attr "mode" "QI")])
1212
1213 (define_insn "*cmpqi_ext_1"
1214 [(set (reg 17)
1215 (compare
1216 (match_operand:QI 0 "general_operand" "Qm")
1217 (subreg:QI
1218 (zero_extract:SI
1219 (match_operand 1 "ext_register_operand" "Q")
1220 (const_int 8)
1221 (const_int 8)) 0)))]
1222 "!TARGET_64BIT && ix86_match_ccmode (insn, CCmode)"
1223 "cmp{b}\t{%h1, %0|%0, %h1}"
1224 [(set_attr "type" "icmp")
1225 (set_attr "mode" "QI")])
1226
1227 (define_insn "*cmpqi_ext_1_rex64"
1228 [(set (reg 17)
1229 (compare
1230 (match_operand:QI 0 "register_operand" "Q")
1231 (subreg:QI
1232 (zero_extract:SI
1233 (match_operand 1 "ext_register_operand" "Q")
1234 (const_int 8)
1235 (const_int 8)) 0)))]
1236 "TARGET_64BIT && ix86_match_ccmode (insn, CCmode)"
1237 "cmp{b}\t{%h1, %0|%0, %h1}"
1238 [(set_attr "type" "icmp")
1239 (set_attr "mode" "QI")])
1240
1241 (define_insn "*cmpqi_ext_2"
1242 [(set (reg 17)
1243 (compare
1244 (subreg:QI
1245 (zero_extract:SI
1246 (match_operand 0 "ext_register_operand" "Q")
1247 (const_int 8)
1248 (const_int 8)) 0)
1249 (match_operand:QI 1 "const0_operand" "n")))]
1250 "ix86_match_ccmode (insn, CCNOmode)"
1251 "test{b}\t%h0, %h0"
1252 [(set_attr "type" "test")
1253 (set_attr "length_immediate" "0")
1254 (set_attr "mode" "QI")])
1255
1256 (define_expand "cmpqi_ext_3"
1257 [(set (reg:CC 17)
1258 (compare:CC
1259 (subreg:QI
1260 (zero_extract:SI
1261 (match_operand 0 "ext_register_operand" "")
1262 (const_int 8)
1263 (const_int 8)) 0)
1264 (match_operand:QI 1 "general_operand" "")))]
1265 ""
1266 "")
1267
1268 (define_insn "cmpqi_ext_3_insn"
1269 [(set (reg 17)
1270 (compare
1271 (subreg:QI
1272 (zero_extract:SI
1273 (match_operand 0 "ext_register_operand" "Q")
1274 (const_int 8)
1275 (const_int 8)) 0)
1276 (match_operand:QI 1 "general_operand" "Qmn")))]
1277 "!TARGET_64BIT && ix86_match_ccmode (insn, CCmode)"
1278 "cmp{b}\t{%1, %h0|%h0, %1}"
1279 [(set_attr "type" "icmp")
1280 (set_attr "mode" "QI")])
1281
1282 (define_insn "cmpqi_ext_3_insn_rex64"
1283 [(set (reg 17)
1284 (compare
1285 (subreg:QI
1286 (zero_extract:SI
1287 (match_operand 0 "ext_register_operand" "Q")
1288 (const_int 8)
1289 (const_int 8)) 0)
1290 (match_operand:QI 1 "nonmemory_operand" "Qn")))]
1291 "TARGET_64BIT && ix86_match_ccmode (insn, CCmode)"
1292 "cmp{b}\t{%1, %h0|%h0, %1}"
1293 [(set_attr "type" "icmp")
1294 (set_attr "mode" "QI")])
1295
1296 (define_insn "*cmpqi_ext_4"
1297 [(set (reg 17)
1298 (compare
1299 (subreg:QI
1300 (zero_extract:SI
1301 (match_operand 0 "ext_register_operand" "Q")
1302 (const_int 8)
1303 (const_int 8)) 0)
1304 (subreg:QI
1305 (zero_extract:SI
1306 (match_operand 1 "ext_register_operand" "Q")
1307 (const_int 8)
1308 (const_int 8)) 0)))]
1309 "ix86_match_ccmode (insn, CCmode)"
1310 "cmp{b}\t{%h1, %h0|%h0, %h1}"
1311 [(set_attr "type" "icmp")
1312 (set_attr "mode" "QI")])
1313
1314 ;; These implement float point compares.
1315 ;; %%% See if we can get away with VOIDmode operands on the actual insns,
1316 ;; which would allow mix and match FP modes on the compares. Which is what
1317 ;; the old patterns did, but with many more of them.
1318
1319 (define_expand "cmpxf"
1320 [(set (reg:CC 17)
1321 (compare:CC (match_operand:XF 0 "cmp_fp_expander_operand" "")
1322 (match_operand:XF 1 "cmp_fp_expander_operand" "")))]
1323 "!TARGET_64BIT && TARGET_80387"
1324 {
1325 ix86_compare_op0 = operands[0];
1326 ix86_compare_op1 = operands[1];
1327 DONE;
1328 })
1329
1330 (define_expand "cmptf"
1331 [(set (reg:CC 17)
1332 (compare:CC (match_operand:TF 0 "cmp_fp_expander_operand" "")
1333 (match_operand:TF 1 "cmp_fp_expander_operand" "")))]
1334 "TARGET_80387"
1335 {
1336 ix86_compare_op0 = operands[0];
1337 ix86_compare_op1 = operands[1];
1338 DONE;
1339 })
1340
1341 (define_expand "cmpdf"
1342 [(set (reg:CC 17)
1343 (compare:CC (match_operand:DF 0 "cmp_fp_expander_operand" "")
1344 (match_operand:DF 1 "cmp_fp_expander_operand" "")))]
1345 "TARGET_80387 || TARGET_SSE2"
1346 {
1347 ix86_compare_op0 = operands[0];
1348 ix86_compare_op1 = operands[1];
1349 DONE;
1350 })
1351
1352 (define_expand "cmpsf"
1353 [(set (reg:CC 17)
1354 (compare:CC (match_operand:SF 0 "cmp_fp_expander_operand" "")
1355 (match_operand:SF 1 "cmp_fp_expander_operand" "")))]
1356 "TARGET_80387 || TARGET_SSE"
1357 {
1358 ix86_compare_op0 = operands[0];
1359 ix86_compare_op1 = operands[1];
1360 DONE;
1361 })
1362
1363 ;; FP compares, step 1:
1364 ;; Set the FP condition codes.
1365 ;;
1366 ;; CCFPmode compare with exceptions
1367 ;; CCFPUmode compare with no exceptions
1368
1369 ;; %%% It is an unfortunate fact that ftst has no non-popping variant,
1370 ;; and that fp moves clobber the condition codes, and that there is
1371 ;; currently no way to describe this fact to reg-stack. So there are
1372 ;; no splitters yet for this.
1373
1374 ;; %%% YIKES! This scheme does not retain a strong connection between
1375 ;; the real compare and the ultimate cc0 user, so CC_REVERSE does not
1376 ;; work! Only allow tos/mem with tos in op 0.
1377 ;;
1378 ;; Hmm, of course, this is what the actual _hardware_ does. Perhaps
1379 ;; things aren't as bad as they sound...
1380
1381 (define_insn "*cmpfp_0"
1382 [(set (match_operand:HI 0 "register_operand" "=a")
1383 (unspec:HI
1384 [(compare:CCFP (match_operand 1 "register_operand" "f")
1385 (match_operand 2 "const0_operand" "X"))] 9))]
1386 "TARGET_80387
1387 && FLOAT_MODE_P (GET_MODE (operands[1]))
1388 && GET_MODE (operands[1]) == GET_MODE (operands[2])"
1389 {
1390 if (find_regno_note (insn, REG_DEAD, REGNO (operands[1])))
1391 return "ftst\;fnstsw\t%0\;fstp\t%y0";
1392 else
1393 return "ftst\;fnstsw\t%0";
1394 }
1395 [(set_attr "type" "multi")
1396 (set_attr "mode" "unknownfp")])
1397
1398 ;; We may not use "#" to split and emit these, since the REG_DEAD notes
1399 ;; used to manage the reg stack popping would not be preserved.
1400
1401 (define_insn "*cmpfp_2_sf"
1402 [(set (reg:CCFP 18)
1403 (compare:CCFP
1404 (match_operand:SF 0 "register_operand" "f")
1405 (match_operand:SF 1 "nonimmediate_operand" "fm")))]
1406 "TARGET_80387"
1407 "* return output_fp_compare (insn, operands, 0, 0);"
1408 [(set_attr "type" "fcmp")
1409 (set_attr "mode" "SF")])
1410
1411 (define_insn "*cmpfp_2_sf_1"
1412 [(set (match_operand:HI 0 "register_operand" "=a")
1413 (unspec:HI
1414 [(compare:CCFP
1415 (match_operand:SF 1 "register_operand" "f")
1416 (match_operand:SF 2 "nonimmediate_operand" "fm"))] 9))]
1417 "TARGET_80387"
1418 "* return output_fp_compare (insn, operands, 2, 0);"
1419 [(set_attr "type" "fcmp")
1420 (set_attr "mode" "SF")])
1421
1422 (define_insn "*cmpfp_2_df"
1423 [(set (reg:CCFP 18)
1424 (compare:CCFP
1425 (match_operand:DF 0 "register_operand" "f")
1426 (match_operand:DF 1 "nonimmediate_operand" "fm")))]
1427 "TARGET_80387"
1428 "* return output_fp_compare (insn, operands, 0, 0);"
1429 [(set_attr "type" "fcmp")
1430 (set_attr "mode" "DF")])
1431
1432 (define_insn "*cmpfp_2_df_1"
1433 [(set (match_operand:HI 0 "register_operand" "=a")
1434 (unspec:HI
1435 [(compare:CCFP
1436 (match_operand:DF 1 "register_operand" "f")
1437 (match_operand:DF 2 "nonimmediate_operand" "fm"))] 9))]
1438 "TARGET_80387"
1439 "* return output_fp_compare (insn, operands, 2, 0);"
1440 [(set_attr "type" "multi")
1441 (set_attr "mode" "DF")])
1442
1443 (define_insn "*cmpfp_2_xf"
1444 [(set (reg:CCFP 18)
1445 (compare:CCFP
1446 (match_operand:XF 0 "register_operand" "f")
1447 (match_operand:XF 1 "register_operand" "f")))]
1448 "!TARGET_64BIT && TARGET_80387"
1449 "* return output_fp_compare (insn, operands, 0, 0);"
1450 [(set_attr "type" "fcmp")
1451 (set_attr "mode" "XF")])
1452
1453 (define_insn "*cmpfp_2_tf"
1454 [(set (reg:CCFP 18)
1455 (compare:CCFP
1456 (match_operand:TF 0 "register_operand" "f")
1457 (match_operand:TF 1 "register_operand" "f")))]
1458 "TARGET_80387"
1459 "* return output_fp_compare (insn, operands, 0, 0);"
1460 [(set_attr "type" "fcmp")
1461 (set_attr "mode" "XF")])
1462
1463 (define_insn "*cmpfp_2_xf_1"
1464 [(set (match_operand:HI 0 "register_operand" "=a")
1465 (unspec:HI
1466 [(compare:CCFP
1467 (match_operand:XF 1 "register_operand" "f")
1468 (match_operand:XF 2 "register_operand" "f"))] 9))]
1469 "!TARGET_64BIT && TARGET_80387"
1470 "* return output_fp_compare (insn, operands, 2, 0);"
1471 [(set_attr "type" "multi")
1472 (set_attr "mode" "XF")])
1473
1474 (define_insn "*cmpfp_2_tf_1"
1475 [(set (match_operand:HI 0 "register_operand" "=a")
1476 (unspec:HI
1477 [(compare:CCFP
1478 (match_operand:TF 1 "register_operand" "f")
1479 (match_operand:TF 2 "register_operand" "f"))] 9))]
1480 "TARGET_80387"
1481 "* return output_fp_compare (insn, operands, 2, 0);"
1482 [(set_attr "type" "multi")
1483 (set_attr "mode" "XF")])
1484
1485 (define_insn "*cmpfp_2u"
1486 [(set (reg:CCFPU 18)
1487 (compare:CCFPU
1488 (match_operand 0 "register_operand" "f")
1489 (match_operand 1 "register_operand" "f")))]
1490 "TARGET_80387
1491 && FLOAT_MODE_P (GET_MODE (operands[0]))
1492 && GET_MODE (operands[0]) == GET_MODE (operands[1])"
1493 "* return output_fp_compare (insn, operands, 0, 1);"
1494 [(set_attr "type" "fcmp")
1495 (set_attr "mode" "unknownfp")])
1496
1497 (define_insn "*cmpfp_2u_1"
1498 [(set (match_operand:HI 0 "register_operand" "=a")
1499 (unspec:HI
1500 [(compare:CCFPU
1501 (match_operand 1 "register_operand" "f")
1502 (match_operand 2 "register_operand" "f"))] 9))]
1503 "TARGET_80387
1504 && FLOAT_MODE_P (GET_MODE (operands[1]))
1505 && GET_MODE (operands[1]) == GET_MODE (operands[2])"
1506 "* return output_fp_compare (insn, operands, 2, 1);"
1507 [(set_attr "type" "multi")
1508 (set_attr "mode" "unknownfp")])
1509
1510 ;; Patterns to match the SImode-in-memory ficom instructions.
1511 ;;
1512 ;; %%% Play games with accepting gp registers, as otherwise we have to
1513 ;; force them to memory during rtl generation, which is no good. We
1514 ;; can get rid of this once we teach reload to do memory input reloads
1515 ;; via pushes.
1516
1517 (define_insn "*ficom_1"
1518 [(set (reg:CCFP 18)
1519 (compare:CCFP
1520 (match_operand 0 "register_operand" "f,f")
1521 (float (match_operand:SI 1 "nonimmediate_operand" "m,?r"))))]
1522 "0 && TARGET_80387 && FLOAT_MODE_P (GET_MODE (operands[0]))
1523 && GET_MODE (XEXP (SET_SRC (PATTERN (insn)), 1)) == GET_MODE (operands[0])"
1524 "#")
1525
1526 ;; Split the not-really-implemented gp register case into a
1527 ;; push-op-pop sequence.
1528 ;;
1529 ;; %%% This is most efficient, but am I gonna get in trouble
1530 ;; for separating cc0_setter and cc0_user?
1531
1532 (define_split
1533 [(set (reg:CCFP 18)
1534 (compare:CCFP
1535 (match_operand:SF 0 "register_operand" "")
1536 (float (match_operand:SI 1 "register_operand" ""))))]
1537 "0 && TARGET_80387 && reload_completed"
1538 [(set (mem:SI (pre_dec:SI (reg:SI 7))) (match_dup 1))
1539 (set (reg:CCFP 18) (compare:CCFP (match_dup 0) (match_dup 2)))
1540 (parallel [(set (match_dup 1) (mem:SI (reg:SI 7)))
1541 (set (reg:SI 7) (plus:SI (reg:SI 7) (const_int 4)))])]
1542 "operands[2] = gen_rtx_MEM (Pmode, stack_pointer_rtx);
1543 operands[2] = gen_rtx_FLOAT (GET_MODE (operands[0]), operands[2]);")
1544
1545 ;; FP compares, step 2
1546 ;; Move the fpsw to ax.
1547
1548 (define_insn "x86_fnstsw_1"
1549 [(set (match_operand:HI 0 "register_operand" "=a")
1550 (unspec:HI [(reg 18)] 9))]
1551 "TARGET_80387"
1552 "fnstsw\t%0"
1553 [(set_attr "length" "2")
1554 (set_attr "mode" "SI")
1555 (set_attr "i387" "1")
1556 (set_attr "ppro_uops" "few")])
1557
1558 ;; FP compares, step 3
1559 ;; Get ax into flags, general case.
1560
1561 (define_insn "x86_sahf_1"
1562 [(set (reg:CC 17)
1563 (unspec:CC [(match_operand:HI 0 "register_operand" "a")] 10))]
1564 "!TARGET_64BIT"
1565 "sahf"
1566 [(set_attr "length" "1")
1567 (set_attr "athlon_decode" "vector")
1568 (set_attr "mode" "SI")
1569 (set_attr "ppro_uops" "one")])
1570
1571 ;; Pentium Pro can do steps 1 through 3 in one go.
1572
1573 (define_insn "*cmpfp_i"
1574 [(set (reg:CCFP 17)
1575 (compare:CCFP (match_operand 0 "register_operand" "f")
1576 (match_operand 1 "register_operand" "f")))]
1577 "TARGET_80387 && TARGET_CMOVE
1578 && !SSE_FLOAT_MODE_P (GET_MODE (operands[0]))
1579 && FLOAT_MODE_P (GET_MODE (operands[0]))
1580 && GET_MODE (operands[0]) == GET_MODE (operands[0])"
1581 "* return output_fp_compare (insn, operands, 1, 0);"
1582 [(set_attr "type" "fcmp")
1583 (set_attr "mode" "unknownfp")
1584 (set_attr "athlon_decode" "vector")])
1585
1586 (define_insn "*cmpfp_i_sse"
1587 [(set (reg:CCFP 17)
1588 (compare:CCFP (match_operand 0 "register_operand" "f#x,x#f")
1589 (match_operand 1 "nonimmediate_operand" "f#x,xm#f")))]
1590 "TARGET_80387
1591 && SSE_FLOAT_MODE_P (GET_MODE (operands[0]))
1592 && GET_MODE (operands[0]) == GET_MODE (operands[0])"
1593 "* return output_fp_compare (insn, operands, 1, 0);"
1594 [(set_attr "type" "fcmp,sse")
1595 (set_attr "mode" "unknownfp")
1596 (set_attr "athlon_decode" "vector")])
1597
1598 (define_insn "*cmpfp_i_sse_only"
1599 [(set (reg:CCFP 17)
1600 (compare:CCFP (match_operand 0 "register_operand" "x")
1601 (match_operand 1 "nonimmediate_operand" "xm")))]
1602 "SSE_FLOAT_MODE_P (GET_MODE (operands[0]))
1603 && GET_MODE (operands[0]) == GET_MODE (operands[0])"
1604 "* return output_fp_compare (insn, operands, 1, 0);"
1605 [(set_attr "type" "sse")
1606 (set_attr "mode" "unknownfp")
1607 (set_attr "athlon_decode" "vector")])
1608
1609 (define_insn "*cmpfp_iu"
1610 [(set (reg:CCFPU 17)
1611 (compare:CCFPU (match_operand 0 "register_operand" "f")
1612 (match_operand 1 "register_operand" "f")))]
1613 "TARGET_80387 && TARGET_CMOVE
1614 && !SSE_FLOAT_MODE_P (GET_MODE (operands[0]))
1615 && FLOAT_MODE_P (GET_MODE (operands[0]))
1616 && GET_MODE (operands[0]) == GET_MODE (operands[1])"
1617 "* return output_fp_compare (insn, operands, 1, 1);"
1618 [(set_attr "type" "fcmp")
1619 (set_attr "mode" "unknownfp")
1620 (set_attr "athlon_decode" "vector")])
1621
1622 (define_insn "*cmpfp_iu_sse"
1623 [(set (reg:CCFPU 17)
1624 (compare:CCFPU (match_operand 0 "register_operand" "f#x,x#f")
1625 (match_operand 1 "nonimmediate_operand" "f#x,xm#f")))]
1626 "TARGET_80387
1627 && SSE_FLOAT_MODE_P (GET_MODE (operands[0]))
1628 && GET_MODE (operands[0]) == GET_MODE (operands[1])"
1629 "* return output_fp_compare (insn, operands, 1, 1);"
1630 [(set_attr "type" "fcmp,sse")
1631 (set_attr "mode" "unknownfp")
1632 (set_attr "athlon_decode" "vector")])
1633
1634 (define_insn "*cmpfp_iu_sse_only"
1635 [(set (reg:CCFPU 17)
1636 (compare:CCFPU (match_operand 0 "register_operand" "x")
1637 (match_operand 1 "nonimmediate_operand" "xm")))]
1638 "SSE_FLOAT_MODE_P (GET_MODE (operands[0]))
1639 && GET_MODE (operands[0]) == GET_MODE (operands[1])"
1640 "* return output_fp_compare (insn, operands, 1, 1);"
1641 [(set_attr "type" "sse")
1642 (set_attr "mode" "unknownfp")
1643 (set_attr "athlon_decode" "vector")])
1644 \f
1645 ;; Move instructions.
1646
1647 ;; General case of fullword move.
1648
1649 (define_expand "movsi"
1650 [(set (match_operand:SI 0 "nonimmediate_operand" "")
1651 (match_operand:SI 1 "general_operand" ""))]
1652 ""
1653 "ix86_expand_move (SImode, operands); DONE;")
1654
1655 ;; Push/pop instructions. They are separate since autoinc/dec is not a
1656 ;; general_operand.
1657 ;;
1658 ;; %%% We don't use a post-inc memory reference because x86 is not a
1659 ;; general AUTO_INC_DEC host, which impacts how it is treated in flow.
1660 ;; Changing this impacts compiler performance on other non-AUTO_INC_DEC
1661 ;; targets without our curiosities, and it is just as easy to represent
1662 ;; this differently.
1663
1664 (define_insn "*pushsi2"
1665 [(set (match_operand:SI 0 "push_operand" "=<")
1666 (match_operand:SI 1 "general_no_elim_operand" "ri*m"))]
1667 "!TARGET_64BIT"
1668 "push{l}\t%1"
1669 [(set_attr "type" "push")
1670 (set_attr "mode" "SI")])
1671
1672 ;; For 64BIT abi we always round up to 8 bytes.
1673 (define_insn "*pushsi2_rex64"
1674 [(set (match_operand:SI 0 "push_operand" "=X")
1675 (match_operand:SI 1 "nonmemory_no_elim_operand" "ri"))]
1676 "TARGET_64BIT"
1677 "push{q}\t%q1"
1678 [(set_attr "type" "push")
1679 (set_attr "mode" "SI")])
1680
1681 (define_insn "*pushsi2_prologue"
1682 [(set (match_operand:SI 0 "push_operand" "=<")
1683 (match_operand:SI 1 "general_no_elim_operand" "ri*m"))
1684 (clobber (mem:BLK (scratch)))]
1685 "!TARGET_64BIT"
1686 "push{l}\t%1"
1687 [(set_attr "type" "push")
1688 (set_attr "mode" "SI")])
1689
1690 (define_insn "*popsi1_epilogue"
1691 [(set (match_operand:SI 0 "nonimmediate_operand" "=r*m")
1692 (mem:SI (reg:SI 7)))
1693 (set (reg:SI 7)
1694 (plus:SI (reg:SI 7) (const_int 4)))
1695 (clobber (mem:BLK (scratch)))]
1696 "!TARGET_64BIT"
1697 "pop{l}\t%0"
1698 [(set_attr "type" "pop")
1699 (set_attr "mode" "SI")])
1700
1701 (define_insn "popsi1"
1702 [(set (match_operand:SI 0 "nonimmediate_operand" "=r*m")
1703 (mem:SI (reg:SI 7)))
1704 (set (reg:SI 7)
1705 (plus:SI (reg:SI 7) (const_int 4)))]
1706 "!TARGET_64BIT"
1707 "pop{l}\t%0"
1708 [(set_attr "type" "pop")
1709 (set_attr "mode" "SI")])
1710
1711 (define_insn "*movsi_xor"
1712 [(set (match_operand:SI 0 "register_operand" "=r")
1713 (match_operand:SI 1 "const0_operand" "i"))
1714 (clobber (reg:CC 17))]
1715 "reload_completed && (!TARGET_USE_MOV0 || optimize_size)"
1716 "xor{l}\t{%0, %0|%0, %0}"
1717 [(set_attr "type" "alu1")
1718 (set_attr "mode" "SI")
1719 (set_attr "length_immediate" "0")])
1720
1721 (define_insn "*movsi_or"
1722 [(set (match_operand:SI 0 "register_operand" "=r")
1723 (match_operand:SI 1 "immediate_operand" "i"))
1724 (clobber (reg:CC 17))]
1725 "reload_completed && GET_CODE (operands[1]) == CONST_INT
1726 && INTVAL (operands[1]) == -1
1727 && (TARGET_PENTIUM || optimize_size)"
1728 {
1729 operands[1] = constm1_rtx;
1730 return "or{l}\t{%1, %0|%0, %1}";
1731 }
1732 [(set_attr "type" "alu1")
1733 (set_attr "mode" "SI")
1734 (set_attr "length_immediate" "1")])
1735
1736 (define_insn "*movsi_1"
1737 [(set (match_operand:SI 0 "nonimmediate_operand" "=*a,r,*a,m,!*y,!rm,!*Y,!rm,!*Y")
1738 (match_operand:SI 1 "general_operand" "im,rinm,rinm,rin,rm,*y,rm,*Y,*Y"))]
1739 "GET_CODE (operands[0]) != MEM || GET_CODE (operands[1]) != MEM"
1740 {
1741 switch (get_attr_type (insn))
1742 {
1743 case TYPE_SSE:
1744 if (get_attr_mode (insn) == TImode)
1745 return "movdqa\t{%1, %0|%0, %1}";
1746 return "movd\t{%1, %0|%0, %1}";
1747
1748 case TYPE_MMX:
1749 return "movd\t{%1, %0|%0, %1}";
1750
1751 case TYPE_LEA:
1752 return "lea{l}\t{%1, %0|%0, %1}";
1753
1754 default:
1755 if (flag_pic && SYMBOLIC_CONST (operands[1]))
1756 abort();
1757 return "mov{l}\t{%1, %0|%0, %1}";
1758 }
1759 }
1760 [(set (attr "type")
1761 (cond [(eq_attr "alternative" "4,5")
1762 (const_string "mmx")
1763 (eq_attr "alternative" "6,7,8")
1764 (const_string "sse")
1765 (and (ne (symbol_ref "flag_pic") (const_int 0))
1766 (match_operand:SI 1 "symbolic_operand" ""))
1767 (const_string "lea")
1768 ]
1769 (const_string "imov")))
1770 (set_attr "modrm" "0,*,0,*,*,*,*,*,*")
1771 (set_attr "mode" "SI,SI,SI,SI,SI,SI,TI,SI,SI")])
1772
1773 ;; Stores and loads of ax to arbitary constant address.
1774 ;; We fake an second form of instruction to force reload to load address
1775 ;; into register when rax is not available
1776 (define_insn "*movabssi_1_rex64"
1777 [(set (mem:SI (match_operand:DI 0 "x86_64_movabs_operand" "i,r,r"))
1778 (match_operand:SI 1 "nonmemory_operand" "a,er,i"))]
1779 "TARGET_64BIT"
1780 "@
1781 movabs{l}\t{%1, %P0|%P0, %1}
1782 mov{l}\t{%1, %a0|%a0, %1}
1783 movabs{l}\t{%1, %a0|%a0, %1}"
1784 [(set_attr "type" "imov")
1785 (set_attr "modrm" "0,*,*")
1786 (set_attr "length_address" "8,0,0")
1787 (set_attr "length_immediate" "0,*,*")
1788 (set_attr "memory" "store")
1789 (set_attr "mode" "SI")])
1790
1791 (define_insn "*movabssi_2_rex64"
1792 [(set (match_operand:SI 0 "register_operand" "=a,r")
1793 (mem:SI (match_operand:DI 1 "x86_64_movabs_operand" "i,r")))]
1794 "TARGET_64BIT"
1795 "@
1796 movabs{l}\t{%P1, %0|%0, %P1}
1797 mov{l}\t{%a1, %0|%0, %a1}"
1798 [(set_attr "type" "imov")
1799 (set_attr "modrm" "0,*")
1800 (set_attr "length_address" "8,0")
1801 (set_attr "length_immediate" "0")
1802 (set_attr "memory" "load")
1803 (set_attr "mode" "SI")])
1804
1805 (define_insn "*swapsi"
1806 [(set (match_operand:SI 0 "register_operand" "+r")
1807 (match_operand:SI 1 "register_operand" "+r"))
1808 (set (match_dup 1)
1809 (match_dup 0))]
1810 ""
1811 "xchg{l}\t%1, %0"
1812 [(set_attr "type" "imov")
1813 (set_attr "pent_pair" "np")
1814 (set_attr "athlon_decode" "vector")
1815 (set_attr "mode" "SI")
1816 (set_attr "modrm" "0")
1817 (set_attr "ppro_uops" "few")])
1818
1819 (define_expand "movhi"
1820 [(set (match_operand:HI 0 "nonimmediate_operand" "")
1821 (match_operand:HI 1 "general_operand" ""))]
1822 ""
1823 "ix86_expand_move (HImode, operands); DONE;")
1824
1825 (define_insn "*pushhi2"
1826 [(set (match_operand:HI 0 "push_operand" "=<,<")
1827 (match_operand:HI 1 "general_no_elim_operand" "n,r*m"))]
1828 "!TARGET_64BIT"
1829 "@
1830 push{w}\t{|WORD PTR }%1
1831 push{w}\t%1"
1832 [(set_attr "type" "push")
1833 (set_attr "mode" "HI")])
1834
1835 ;; For 64BIT abi we always round up to 8 bytes.
1836 (define_insn "*pushhi2_rex64"
1837 [(set (match_operand:HI 0 "push_operand" "=X")
1838 (match_operand:HI 1 "nonmemory_no_elim_operand" "ri"))]
1839 "TARGET_64BIT"
1840 "push{q}\t%q1"
1841 [(set_attr "type" "push")
1842 (set_attr "mode" "QI")])
1843
1844 (define_insn "*movhi_1"
1845 [(set (match_operand:HI 0 "nonimmediate_operand" "=*a,r,r,*a,r,m")
1846 (match_operand:HI 1 "general_operand" "i,r,rn,rm,rm,rn"))]
1847 "GET_CODE (operands[0]) != MEM || GET_CODE (operands[1]) != MEM"
1848 {
1849 switch (get_attr_type (insn))
1850 {
1851 case TYPE_IMOVX:
1852 /* movzwl is faster than movw on p2 due to partial word stalls,
1853 though not as fast as an aligned movl. */
1854 return "movz{wl|x}\t{%1, %k0|%k0, %1}";
1855 default:
1856 if (get_attr_mode (insn) == MODE_SI)
1857 return "mov{l}\t{%k1, %k0|%k0, %k1}";
1858 else
1859 return "mov{w}\t{%1, %0|%0, %1}";
1860 }
1861 }
1862 [(set (attr "type")
1863 (cond [(and (eq_attr "alternative" "0,1")
1864 (ior (eq (symbol_ref "TARGET_PARTIAL_REG_STALL")
1865 (const_int 0))
1866 (eq (symbol_ref "TARGET_HIMODE_MATH")
1867 (const_int 0))))
1868 (const_string "imov")
1869 (and (eq_attr "alternative" "2,3,4")
1870 (match_operand:HI 1 "aligned_operand" ""))
1871 (const_string "imov")
1872 (and (ne (symbol_ref "TARGET_MOVX")
1873 (const_int 0))
1874 (eq_attr "alternative" "0,1,3,4"))
1875 (const_string "imovx")
1876 ]
1877 (const_string "imov")))
1878 (set (attr "mode")
1879 (cond [(eq_attr "type" "imovx")
1880 (const_string "SI")
1881 (and (eq_attr "alternative" "2,3,4")
1882 (match_operand:HI 1 "aligned_operand" ""))
1883 (const_string "SI")
1884 (and (eq_attr "alternative" "0,1")
1885 (ior (eq (symbol_ref "TARGET_PARTIAL_REG_STALL")
1886 (const_int 0))
1887 (eq (symbol_ref "TARGET_HIMODE_MATH")
1888 (const_int 0))))
1889 (const_string "SI")
1890 ]
1891 (const_string "HI")))
1892 (set_attr "modrm" "0,*,*,0,*,*")])
1893
1894 ;; Stores and loads of ax to arbitary constant address.
1895 ;; We fake an second form of instruction to force reload to load address
1896 ;; into register when rax is not available
1897 (define_insn "*movabshi_1_rex64"
1898 [(set (mem:HI (match_operand:DI 0 "x86_64_movabs_operand" "i,r,r"))
1899 (match_operand:HI 1 "nonmemory_operand" "a,er,i"))]
1900 "TARGET_64BIT"
1901 "@
1902 movabs{w}\t{%1, %P0|%P0, %1}
1903 mov{w}\t{%1, %a0|%a0, %1}
1904 movabs{w}\t{%1, %a0|%a0, %1}"
1905 [(set_attr "type" "imov")
1906 (set_attr "modrm" "0,*,*")
1907 (set_attr "length_address" "8,0,0")
1908 (set_attr "length_immediate" "0,*,*")
1909 (set_attr "memory" "store")
1910 (set_attr "mode" "HI")])
1911
1912 (define_insn "*movabshi_2_rex64"
1913 [(set (match_operand:HI 0 "register_operand" "=a,r")
1914 (mem:HI (match_operand:DI 1 "x86_64_movabs_operand" "i,r")))]
1915 "TARGET_64BIT"
1916 "@
1917 movabs{w}\t{%P1, %0|%0, %P1}
1918 mov{w}\t{%a1, %0|%0, %a1}"
1919 [(set_attr "type" "imov")
1920 (set_attr "modrm" "0,*")
1921 (set_attr "length_address" "8,0")
1922 (set_attr "length_immediate" "0")
1923 (set_attr "memory" "load")
1924 (set_attr "mode" "HI")])
1925
1926 (define_insn "*swaphi_1"
1927 [(set (match_operand:HI 0 "register_operand" "+r")
1928 (match_operand:HI 1 "register_operand" "+r"))
1929 (set (match_dup 1)
1930 (match_dup 0))]
1931 "TARGET_PARTIAL_REG_STALL"
1932 "xchg{w}\t%1, %0"
1933 [(set_attr "type" "imov")
1934 (set_attr "pent_pair" "np")
1935 (set_attr "mode" "HI")
1936 (set_attr "modrm" "0")
1937 (set_attr "ppro_uops" "few")])
1938
1939 (define_insn "*swaphi_2"
1940 [(set (match_operand:HI 0 "register_operand" "+r")
1941 (match_operand:HI 1 "register_operand" "+r"))
1942 (set (match_dup 1)
1943 (match_dup 0))]
1944 "! TARGET_PARTIAL_REG_STALL"
1945 "xchg{l}\t%k1, %k0"
1946 [(set_attr "type" "imov")
1947 (set_attr "pent_pair" "np")
1948 (set_attr "mode" "SI")
1949 (set_attr "modrm" "0")
1950 (set_attr "ppro_uops" "few")])
1951
1952 (define_expand "movstricthi"
1953 [(set (strict_low_part (match_operand:HI 0 "nonimmediate_operand" ""))
1954 (match_operand:HI 1 "general_operand" ""))]
1955 "! TARGET_PARTIAL_REG_STALL || optimize_size"
1956 {
1957 /* Don't generate memory->memory moves, go through a register */
1958 if (GET_CODE (operands[0]) == MEM && GET_CODE (operands[1]) == MEM)
1959 operands[1] = force_reg (HImode, operands[1]);
1960 })
1961
1962 (define_insn "*movstricthi_1"
1963 [(set (strict_low_part (match_operand:HI 0 "nonimmediate_operand" "+rm,r"))
1964 (match_operand:HI 1 "general_operand" "rn,m"))]
1965 "(! TARGET_PARTIAL_REG_STALL || optimize_size)
1966 && (GET_CODE (operands[0]) != MEM || GET_CODE (operands[1]) != MEM)"
1967 "mov{w}\t{%1, %0|%0, %1}"
1968 [(set_attr "type" "imov")
1969 (set_attr "mode" "HI")])
1970
1971 (define_insn "*movstricthi_xor"
1972 [(set (strict_low_part (match_operand:HI 0 "register_operand" "+r"))
1973 (match_operand:HI 1 "const0_operand" "i"))
1974 (clobber (reg:CC 17))]
1975 "reload_completed
1976 && ((!TARGET_USE_MOV0 && !TARGET_PARTIAL_REG_STALL) || optimize_size)"
1977 "xor{w}\t{%0, %0|%0, %0}"
1978 [(set_attr "type" "alu1")
1979 (set_attr "mode" "HI")
1980 (set_attr "length_immediate" "0")])
1981
1982 (define_expand "movqi"
1983 [(set (match_operand:QI 0 "nonimmediate_operand" "")
1984 (match_operand:QI 1 "general_operand" ""))]
1985 ""
1986 "ix86_expand_move (QImode, operands); DONE;")
1987
1988 ;; emit_push_insn when it calls move_by_pieces requires an insn to
1989 ;; "push a byte". But actually we use pushw, which has the effect
1990 ;; of rounding the amount pushed up to a halfword.
1991
1992 (define_insn "*pushqi2"
1993 [(set (match_operand:QI 0 "push_operand" "=X,X")
1994 (match_operand:QI 1 "nonmemory_no_elim_operand" "n,r"))]
1995 "!TARGET_64BIT"
1996 "@
1997 push{w}\t{|word ptr }%1
1998 push{w}\t%w1"
1999 [(set_attr "type" "push")
2000 (set_attr "mode" "HI")])
2001
2002 ;; For 64BIT abi we always round up to 8 bytes.
2003 (define_insn "*pushqi2_rex64"
2004 [(set (match_operand:QI 0 "push_operand" "=X")
2005 (match_operand:QI 1 "nonmemory_no_elim_operand" "ri"))]
2006 "TARGET_64BIT"
2007 "push{q}\t%q1"
2008 [(set_attr "type" "push")
2009 (set_attr "mode" "QI")])
2010
2011 ;; Situation is quite tricky about when to choose full sized (SImode) move
2012 ;; over QImode moves. For Q_REG -> Q_REG move we use full size only for
2013 ;; partial register dependency machines (such as AMD Athlon), where QImode
2014 ;; moves issue extra dependency and for partial register stalls machines
2015 ;; that don't use QImode patterns (and QImode move cause stall on the next
2016 ;; instruction).
2017 ;;
2018 ;; For loads of Q_REG to NONQ_REG we use full sized moves except for partial
2019 ;; register stall machines with, where we use QImode instructions, since
2020 ;; partial register stall can be caused there. Then we use movzx.
2021 (define_insn "*movqi_1"
2022 [(set (match_operand:QI 0 "nonimmediate_operand" "=q,q ,q ,r,r ,?r,m")
2023 (match_operand:QI 1 "general_operand" " q,qn,qm,q,rn,qm,qn"))]
2024 "GET_CODE (operands[0]) != MEM || GET_CODE (operands[1]) != MEM"
2025 {
2026 switch (get_attr_type (insn))
2027 {
2028 case TYPE_IMOVX:
2029 if (!ANY_QI_REG_P (operands[1]) && GET_CODE (operands[1]) != MEM)
2030 abort ();
2031 return "movz{bl|x}\t{%1, %k0|%k0, %1}";
2032 default:
2033 if (get_attr_mode (insn) == MODE_SI)
2034 return "mov{l}\t{%k1, %k0|%k0, %k1}";
2035 else
2036 return "mov{b}\t{%1, %0|%0, %1}";
2037 }
2038 }
2039 [(set (attr "type")
2040 (cond [(and (eq_attr "alternative" "3")
2041 (ior (eq (symbol_ref "TARGET_PARTIAL_REG_STALL")
2042 (const_int 0))
2043 (eq (symbol_ref "TARGET_QIMODE_MATH")
2044 (const_int 0))))
2045 (const_string "imov")
2046 (eq_attr "alternative" "3,5")
2047 (const_string "imovx")
2048 (and (ne (symbol_ref "TARGET_MOVX")
2049 (const_int 0))
2050 (eq_attr "alternative" "2"))
2051 (const_string "imovx")
2052 ]
2053 (const_string "imov")))
2054 (set (attr "mode")
2055 (cond [(eq_attr "alternative" "3,4,5")
2056 (const_string "SI")
2057 (eq_attr "alternative" "6")
2058 (const_string "QI")
2059 (eq_attr "type" "imovx")
2060 (const_string "SI")
2061 (and (eq_attr "type" "imov")
2062 (and (eq_attr "alternative" "0,1,2")
2063 (ne (symbol_ref "TARGET_PARTIAL_REG_DEPENDENCY")
2064 (const_int 0))))
2065 (const_string "SI")
2066 ;; Avoid partial register stalls when not using QImode arithmetic
2067 (and (eq_attr "type" "imov")
2068 (and (eq_attr "alternative" "0,1,2")
2069 (and (ne (symbol_ref "TARGET_PARTIAL_REG_STALL")
2070 (const_int 0))
2071 (eq (symbol_ref "TARGET_QIMODE_MATH")
2072 (const_int 0)))))
2073 (const_string "SI")
2074 ]
2075 (const_string "QI")))])
2076
2077 (define_expand "reload_outqi"
2078 [(parallel [(match_operand:QI 0 "" "=m")
2079 (match_operand:QI 1 "register_operand" "r")
2080 (match_operand:QI 2 "register_operand" "=&q")])]
2081 ""
2082 {
2083 rtx op0, op1, op2;
2084 op0 = operands[0]; op1 = operands[1]; op2 = operands[2];
2085
2086 if (reg_overlap_mentioned_p (op2, op0))
2087 abort ();
2088 if (! q_regs_operand (op1, QImode))
2089 {
2090 emit_insn (gen_movqi (op2, op1));
2091 op1 = op2;
2092 }
2093 emit_insn (gen_movqi (op0, op1));
2094 DONE;
2095 })
2096
2097 (define_insn "*swapqi"
2098 [(set (match_operand:QI 0 "register_operand" "+r")
2099 (match_operand:QI 1 "register_operand" "+r"))
2100 (set (match_dup 1)
2101 (match_dup 0))]
2102 ""
2103 "xchg{b}\t%1, %0"
2104 [(set_attr "type" "imov")
2105 (set_attr "pent_pair" "np")
2106 (set_attr "mode" "QI")
2107 (set_attr "modrm" "0")
2108 (set_attr "ppro_uops" "few")])
2109
2110 (define_expand "movstrictqi"
2111 [(set (strict_low_part (match_operand:QI 0 "nonimmediate_operand" ""))
2112 (match_operand:QI 1 "general_operand" ""))]
2113 "! TARGET_PARTIAL_REG_STALL"
2114 {
2115 /* Don't generate memory->memory moves, go through a register. */
2116 if (GET_CODE (operands[0]) == MEM && GET_CODE (operands[1]) == MEM)
2117 operands[1] = force_reg (QImode, operands[1]);
2118 })
2119
2120 (define_insn "*movstrictqi_1"
2121 [(set (strict_low_part (match_operand:QI 0 "nonimmediate_operand" "+qm,q"))
2122 (match_operand:QI 1 "general_operand" "*qn,m"))]
2123 "! TARGET_PARTIAL_REG_STALL
2124 && (GET_CODE (operands[0]) != MEM || GET_CODE (operands[1]) != MEM)"
2125 "mov{b}\t{%1, %0|%0, %1}"
2126 [(set_attr "type" "imov")
2127 (set_attr "mode" "QI")])
2128
2129 (define_insn "*movstrictqi_xor"
2130 [(set (strict_low_part (match_operand:QI 0 "q_regs_operand" "+q"))
2131 (match_operand:QI 1 "const0_operand" "i"))
2132 (clobber (reg:CC 17))]
2133 "reload_completed && (!TARGET_USE_MOV0 || optimize_size)"
2134 "xor{b}\t{%0, %0|%0, %0}"
2135 [(set_attr "type" "alu1")
2136 (set_attr "mode" "QI")
2137 (set_attr "length_immediate" "0")])
2138
2139 (define_insn "*movsi_extv_1"
2140 [(set (match_operand:SI 0 "register_operand" "=R")
2141 (sign_extract:SI (match_operand 1 "ext_register_operand" "Q")
2142 (const_int 8)
2143 (const_int 8)))]
2144 ""
2145 "movs{bl|x}\t{%h1, %0|%0, %h1}"
2146 [(set_attr "type" "imovx")
2147 (set_attr "mode" "SI")])
2148
2149 (define_insn "*movhi_extv_1"
2150 [(set (match_operand:HI 0 "register_operand" "=R")
2151 (sign_extract:HI (match_operand 1 "ext_register_operand" "Q")
2152 (const_int 8)
2153 (const_int 8)))]
2154 ""
2155 "movs{bl|x}\t{%h1, %k0|%k0, %h1}"
2156 [(set_attr "type" "imovx")
2157 (set_attr "mode" "SI")])
2158
2159 (define_insn "*movqi_extv_1"
2160 [(set (match_operand:QI 0 "nonimmediate_operand" "=Qm,?r")
2161 (sign_extract:QI (match_operand 1 "ext_register_operand" "Q,Q")
2162 (const_int 8)
2163 (const_int 8)))]
2164 "!TARGET_64BIT"
2165 {
2166 switch (get_attr_type (insn))
2167 {
2168 case TYPE_IMOVX:
2169 return "movs{bl|x}\t{%h1, %k0|%k0, %h1}";
2170 default:
2171 return "mov{b}\t{%h1, %0|%0, %h1}";
2172 }
2173 }
2174 [(set (attr "type")
2175 (if_then_else (and (match_operand:QI 0 "register_operand" "")
2176 (ior (not (match_operand:QI 0 "q_regs_operand" ""))
2177 (ne (symbol_ref "TARGET_MOVX")
2178 (const_int 0))))
2179 (const_string "imovx")
2180 (const_string "imov")))
2181 (set (attr "mode")
2182 (if_then_else (eq_attr "type" "imovx")
2183 (const_string "SI")
2184 (const_string "QI")))])
2185
2186 (define_insn "*movqi_extv_1_rex64"
2187 [(set (match_operand:QI 0 "register_operand" "=Q,?R")
2188 (sign_extract:QI (match_operand 1 "ext_register_operand" "Q,Q")
2189 (const_int 8)
2190 (const_int 8)))]
2191 "TARGET_64BIT"
2192 {
2193 switch (get_attr_type (insn))
2194 {
2195 case TYPE_IMOVX:
2196 return "movs{bl|x}\t{%h1, %k0|%k0, %h1}";
2197 default:
2198 return "mov{b}\t{%h1, %0|%0, %h1}";
2199 }
2200 }
2201 [(set (attr "type")
2202 (if_then_else (and (match_operand:QI 0 "register_operand" "")
2203 (ior (not (match_operand:QI 0 "q_regs_operand" ""))
2204 (ne (symbol_ref "TARGET_MOVX")
2205 (const_int 0))))
2206 (const_string "imovx")
2207 (const_string "imov")))
2208 (set (attr "mode")
2209 (if_then_else (eq_attr "type" "imovx")
2210 (const_string "SI")
2211 (const_string "QI")))])
2212
2213 ;; Stores and loads of ax to arbitary constant address.
2214 ;; We fake an second form of instruction to force reload to load address
2215 ;; into register when rax is not available
2216 (define_insn "*movabsqi_1_rex64"
2217 [(set (mem:QI (match_operand:DI 0 "x86_64_movabs_operand" "i,r,r"))
2218 (match_operand:QI 1 "nonmemory_operand" "a,er,i"))]
2219 "TARGET_64BIT"
2220 "@
2221 movabs{b}\t{%1, %P0|%P0, %1}
2222 mov{b}\t{%1, %a0|%a0, %1}
2223 movabs{b}\t{%1, %a0|%a0, %1}"
2224 [(set_attr "type" "imov")
2225 (set_attr "modrm" "0,*,*")
2226 (set_attr "length_address" "8,0,0")
2227 (set_attr "length_immediate" "0,*,*")
2228 (set_attr "memory" "store")
2229 (set_attr "mode" "QI")])
2230
2231 (define_insn "*movabsqi_2_rex64"
2232 [(set (match_operand:QI 0 "register_operand" "=a,r")
2233 (mem:QI (match_operand:DI 1 "x86_64_movabs_operand" "i,r")))]
2234 "TARGET_64BIT"
2235 "@
2236 movabs{b}\t{%P1, %0|%0, %P1}
2237 mov{b}\t{%a1, %0|%0, %a1}"
2238 [(set_attr "type" "imov")
2239 (set_attr "modrm" "0,*")
2240 (set_attr "length_address" "8,0")
2241 (set_attr "length_immediate" "0")
2242 (set_attr "memory" "load")
2243 (set_attr "mode" "QI")])
2244
2245 (define_insn "*movsi_extzv_1"
2246 [(set (match_operand:SI 0 "register_operand" "=R")
2247 (zero_extract:SI (match_operand 1 "ext_register_operand" "Q")
2248 (const_int 8)
2249 (const_int 8)))]
2250 ""
2251 "movz{bl|x}\t{%h1, %0|%0, %h1}"
2252 [(set_attr "type" "imovx")
2253 (set_attr "mode" "SI")])
2254
2255 (define_insn "*movqi_extzv_2"
2256 [(set (match_operand:QI 0 "nonimmediate_operand" "=Qm,?R")
2257 (subreg:QI (zero_extract:SI (match_operand 1 "ext_register_operand" "Q,Q")
2258 (const_int 8)
2259 (const_int 8)) 0))]
2260 "!TARGET_64BIT"
2261 {
2262 switch (get_attr_type (insn))
2263 {
2264 case TYPE_IMOVX:
2265 return "movz{bl|x}\t{%h1, %k0|%k0, %h1}";
2266 default:
2267 return "mov{b}\t{%h1, %0|%0, %h1}";
2268 }
2269 }
2270 [(set (attr "type")
2271 (if_then_else (and (match_operand:QI 0 "register_operand" "")
2272 (ior (not (match_operand:QI 0 "q_regs_operand" ""))
2273 (ne (symbol_ref "TARGET_MOVX")
2274 (const_int 0))))
2275 (const_string "imovx")
2276 (const_string "imov")))
2277 (set (attr "mode")
2278 (if_then_else (eq_attr "type" "imovx")
2279 (const_string "SI")
2280 (const_string "QI")))])
2281
2282 (define_insn "*movqi_extzv_2_rex64"
2283 [(set (match_operand:QI 0 "register_operand" "=Q,?R")
2284 (subreg:QI (zero_extract:SI (match_operand 1 "ext_register_operand" "Q,Q")
2285 (const_int 8)
2286 (const_int 8)) 0))]
2287 "TARGET_64BIT"
2288 {
2289 switch (get_attr_type (insn))
2290 {
2291 case TYPE_IMOVX:
2292 return "movz{bl|x}\t{%h1, %k0|%k0, %h1}";
2293 default:
2294 return "mov{b}\t{%h1, %0|%0, %h1}";
2295 }
2296 }
2297 [(set (attr "type")
2298 (if_then_else (ior (not (match_operand:QI 0 "q_regs_operand" ""))
2299 (ne (symbol_ref "TARGET_MOVX")
2300 (const_int 0)))
2301 (const_string "imovx")
2302 (const_string "imov")))
2303 (set (attr "mode")
2304 (if_then_else (eq_attr "type" "imovx")
2305 (const_string "SI")
2306 (const_string "QI")))])
2307
2308 (define_insn "movsi_insv_1"
2309 [(set (zero_extract:SI (match_operand 0 "ext_register_operand" "+Q")
2310 (const_int 8)
2311 (const_int 8))
2312 (match_operand:SI 1 "general_operand" "Qmn"))]
2313 "!TARGET_64BIT"
2314 "mov{b}\t{%b1, %h0|%h0, %b1}"
2315 [(set_attr "type" "imov")
2316 (set_attr "mode" "QI")])
2317
2318 (define_insn "*movsi_insv_1_rex64"
2319 [(set (zero_extract:SI (match_operand 0 "ext_register_operand" "+Q")
2320 (const_int 8)
2321 (const_int 8))
2322 (match_operand:SI 1 "nonmemory_operand" "Qn"))]
2323 "TARGET_64BIT"
2324 "mov{b}\t{%b1, %h0|%h0, %b1}"
2325 [(set_attr "type" "imov")
2326 (set_attr "mode" "QI")])
2327
2328 (define_insn "*movqi_insv_2"
2329 [(set (zero_extract:SI (match_operand 0 "ext_register_operand" "+Q")
2330 (const_int 8)
2331 (const_int 8))
2332 (and:SI (lshiftrt:SI (match_operand:SI 1 "register_operand" "Q")
2333 (const_int 8))
2334 (const_int 255)))]
2335 ""
2336 "mov{b}\t{%h1, %h0|%h0, %h1}"
2337 [(set_attr "type" "imov")
2338 (set_attr "mode" "QI")])
2339
2340 (define_expand "movdi"
2341 [(set (match_operand:DI 0 "nonimmediate_operand" "")
2342 (match_operand:DI 1 "general_operand" ""))]
2343 ""
2344 "ix86_expand_move (DImode, operands); DONE;")
2345
2346 (define_insn "*pushdi"
2347 [(set (match_operand:DI 0 "push_operand" "=<")
2348 (match_operand:DI 1 "general_no_elim_operand" "riF*m"))]
2349 "!TARGET_64BIT"
2350 "#")
2351
2352 (define_insn "pushdi2_rex64"
2353 [(set (match_operand:DI 0 "push_operand" "=<,!<")
2354 (match_operand:DI 1 "general_no_elim_operand" "re*m,n"))]
2355 "TARGET_64BIT"
2356 "@
2357 push{q}\t%1
2358 #"
2359 [(set_attr "type" "push,multi")
2360 (set_attr "mode" "DI")])
2361
2362 ;; Convert impossible pushes of immediate to existing instructions.
2363 ;; First try to get scratch register and go through it. In case this
2364 ;; fails, push sign extended lower part first and then overwrite
2365 ;; upper part by 32bit move.
2366 (define_peephole2
2367 [(match_scratch:DI 2 "r")
2368 (set (match_operand:DI 0 "push_operand" "")
2369 (match_operand:DI 1 "immediate_operand" ""))]
2370 "TARGET_64BIT && !symbolic_operand (operands[1], DImode)
2371 && !x86_64_immediate_operand (operands[1], DImode)"
2372 [(set (match_dup 2) (match_dup 1))
2373 (set (match_dup 0) (match_dup 2))]
2374 "")
2375
2376 ;; We need to define this as both peepholer and splitter for case
2377 ;; peephole2 pass is not run.
2378 (define_peephole2
2379 [(set (match_operand:DI 0 "push_operand" "")
2380 (match_operand:DI 1 "immediate_operand" ""))]
2381 "TARGET_64BIT && !symbolic_operand (operands[1], DImode)
2382 && !x86_64_immediate_operand (operands[1], DImode) && 1"
2383 [(set (match_dup 0) (match_dup 1))
2384 (set (match_dup 2) (match_dup 3))]
2385 "split_di (operands + 1, 1, operands + 2, operands + 3);
2386 operands[1] = gen_lowpart (DImode, operands[2]);
2387 operands[2] = gen_rtx_MEM (SImode, gen_rtx_PLUS (DImode, stack_pointer_rtx,
2388 GEN_INT (4)));
2389 ")
2390
2391 (define_split
2392 [(set (match_operand:DI 0 "push_operand" "")
2393 (match_operand:DI 1 "immediate_operand" ""))]
2394 "TARGET_64BIT && (flow2_completed || (reload_completed && !flag_peephole2))
2395 && !symbolic_operand (operands[1], DImode)
2396 && !x86_64_immediate_operand (operands[1], DImode)"
2397 [(set (match_dup 0) (match_dup 1))
2398 (set (match_dup 2) (match_dup 3))]
2399 "split_di (operands + 1, 1, operands + 2, operands + 3);
2400 operands[1] = gen_lowpart (DImode, operands[2]);
2401 operands[2] = gen_rtx_MEM (SImode, gen_rtx_PLUS (DImode, stack_pointer_rtx,
2402 GEN_INT (4)));
2403 ")
2404
2405 (define_insn "*pushdi2_prologue_rex64"
2406 [(set (match_operand:DI 0 "push_operand" "=<")
2407 (match_operand:DI 1 "general_no_elim_operand" "re*m"))
2408 (clobber (mem:BLK (scratch)))]
2409 "TARGET_64BIT"
2410 "push{q}\t%1"
2411 [(set_attr "type" "push")
2412 (set_attr "mode" "DI")])
2413
2414 (define_insn "*popdi1_epilogue_rex64"
2415 [(set (match_operand:DI 0 "nonimmediate_operand" "=r*m")
2416 (mem:DI (reg:DI 7)))
2417 (set (reg:DI 7)
2418 (plus:DI (reg:DI 7) (const_int 8)))
2419 (clobber (mem:BLK (scratch)))]
2420 "TARGET_64BIT"
2421 "pop{q}\t%0"
2422 [(set_attr "type" "pop")
2423 (set_attr "mode" "DI")])
2424
2425 (define_insn "popdi1"
2426 [(set (match_operand:DI 0 "nonimmediate_operand" "=r*m")
2427 (mem:DI (reg:DI 7)))
2428 (set (reg:DI 7)
2429 (plus:DI (reg:DI 7) (const_int 8)))]
2430 "TARGET_64BIT"
2431 "pop{q}\t%0"
2432 [(set_attr "type" "pop")
2433 (set_attr "mode" "DI")])
2434
2435 (define_insn "*movdi_xor_rex64"
2436 [(set (match_operand:DI 0 "register_operand" "=r")
2437 (match_operand:DI 1 "const0_operand" "i"))
2438 (clobber (reg:CC 17))]
2439 "TARGET_64BIT && (!TARGET_USE_MOV0 || optimize_size)
2440 && reload_completed"
2441 "xor{l}\t{%k0, %k0|%k0, %k0}"
2442 [(set_attr "type" "alu1")
2443 (set_attr "mode" "SI")
2444 (set_attr "length_immediate" "0")])
2445
2446 (define_insn "*movdi_or_rex64"
2447 [(set (match_operand:DI 0 "register_operand" "=r")
2448 (match_operand:DI 1 "const_int_operand" "i"))
2449 (clobber (reg:CC 17))]
2450 "TARGET_64BIT && (TARGET_PENTIUM || optimize_size)
2451 && reload_completed
2452 && GET_CODE (operands[1]) == CONST_INT
2453 && INTVAL (operands[1]) == -1"
2454 {
2455 operands[1] = constm1_rtx;
2456 return "or{q}\t{%1, %0|%0, %1}";
2457 }
2458 [(set_attr "type" "alu1")
2459 (set_attr "mode" "DI")
2460 (set_attr "length_immediate" "1")])
2461
2462 (define_insn "*movdi_2"
2463 [(set (match_operand:DI 0 "nonimmediate_operand" "=r,o,!m*y,!*y,!m,*Y,!*Y")
2464 (match_operand:DI 1 "general_operand" "riFo,riF,*y,m,*Y,*Y,m"))]
2465 "!TARGET_64BIT
2466 && (GET_CODE (operands[0]) != MEM || GET_CODE (operands[1]) != MEM)"
2467 "@
2468 #
2469 #
2470 movq\t{%1, %0|%0, %1}
2471 movq\t{%1, %0|%0, %1}
2472 movq\t{%1, %0|%0, %1}
2473 movdqa\t{%1, %0|%0, %1}
2474 movq\t{%1, %0|%0, %1}"
2475 [(set_attr "type" "*,*,mmx,mmx,sse,sse,sse")
2476 (set_attr "mode" "DI,DI,DI,DI,DI,TI,DI")])
2477
2478 (define_split
2479 [(set (match_operand:DI 0 "push_operand" "")
2480 (match_operand:DI 1 "general_operand" ""))]
2481 "!TARGET_64BIT && reload_completed
2482 && (! MMX_REG_P (operands[1]) && !SSE_REG_P (operands[1]))"
2483 [(const_int 0)]
2484 "ix86_split_long_move (operands); DONE;")
2485
2486 ;; %%% This multiword shite has got to go.
2487 (define_split
2488 [(set (match_operand:DI 0 "nonimmediate_operand" "")
2489 (match_operand:DI 1 "general_operand" ""))]
2490 "!TARGET_64BIT && reload_completed
2491 && (!MMX_REG_P (operands[0]) && !SSE_REG_P (operands[0]))
2492 && (!MMX_REG_P (operands[1]) && !SSE_REG_P (operands[1]))"
2493 [(const_int 0)]
2494 "ix86_split_long_move (operands); DONE;")
2495
2496 (define_insn "*movdi_1_rex64"
2497 [(set (match_operand:DI 0 "nonimmediate_operand" "=r,r,r,mr,!mr,!m*y,!*y,!*Y,!m,!*Y")
2498 (match_operand:DI 1 "general_operand" "Z,rem,i,re,n,*y,m,*Y,*Y,*m"))]
2499 "TARGET_64BIT
2500 && (GET_CODE (operands[0]) != MEM || GET_CODE (operands[1]) != MEM)"
2501 {
2502 switch (get_attr_type (insn))
2503 {
2504 case TYPE_SSE:
2505 if (register_operand (operands[0], DImode)
2506 && register_operand (operands[1], DImode))
2507 return "movdqa\t{%1, %0|%0, %1}";
2508 /* FALLTHRU */
2509 case TYPE_MMX:
2510 return "movq\t{%1, %0|%0, %1}";
2511 case TYPE_MULTI:
2512 return "#";
2513 case TYPE_LEA:
2514 return "lea{q}\t{%a1, %0|%0, %a1}";
2515 default:
2516 if (flag_pic && SYMBOLIC_CONST (operands[1]))
2517 abort ();
2518 if (get_attr_mode (insn) == MODE_SI)
2519 return "mov{l}\t{%k1, %k0|%k0, %k1}";
2520 else if (which_alternative == 2)
2521 return "movabs{q}\t{%1, %0|%0, %1}";
2522 else
2523 return "mov{q}\t{%1, %0|%0, %1}";
2524 }
2525 }
2526 [(set (attr "type")
2527 (cond [(eq_attr "alternative" "5,6")
2528 (const_string "mmx")
2529 (eq_attr "alternative" "7,8")
2530 (const_string "sse")
2531 (eq_attr "alternative" "4")
2532 (const_string "multi")
2533 (and (ne (symbol_ref "flag_pic") (const_int 0))
2534 (match_operand:DI 1 "symbolic_operand" ""))
2535 (const_string "lea")
2536 ]
2537 (const_string "imov")))
2538 (set_attr "modrm" "*,0,0,*,*,*,*,*,*,*")
2539 (set_attr "length_immediate" "*,4,8,*,*,*,*,*,*,*")
2540 (set_attr "mode" "SI,DI,DI,DI,SI,DI,DI,DI,TI,DI")])
2541
2542 ;; Stores and loads of ax to arbitary constant address.
2543 ;; We fake an second form of instruction to force reload to load address
2544 ;; into register when rax is not available
2545 (define_insn "*movabsdi_1_rex64"
2546 [(set (mem:DI (match_operand:DI 0 "x86_64_movabs_operand" "i,r,r"))
2547 (match_operand:DI 1 "nonmemory_operand" "a,er,i"))]
2548 "TARGET_64BIT"
2549 "@
2550 movabs{q}\t{%1, %P0|%P0, %1}
2551 mov{q}\t{%1, %a0|%a0, %1}
2552 movabs{q}\t{%1, %a0|%a0, %1}"
2553 [(set_attr "type" "imov")
2554 (set_attr "modrm" "0,*,*")
2555 (set_attr "length_address" "8,0,0")
2556 (set_attr "length_immediate" "0,*,*")
2557 (set_attr "memory" "store")
2558 (set_attr "mode" "DI")])
2559
2560 (define_insn "*movabsdi_2_rex64"
2561 [(set (match_operand:DI 0 "register_operand" "=a,r")
2562 (mem:DI (match_operand:DI 1 "x86_64_movabs_operand" "i,r")))]
2563 "TARGET_64BIT"
2564 "@
2565 movabs{q}\t{%P1, %0|%0, %P1}
2566 mov{q}\t{%a1, %0|%0, %a1}"
2567 [(set_attr "type" "imov")
2568 (set_attr "modrm" "0,*")
2569 (set_attr "length_address" "8,0")
2570 (set_attr "length_immediate" "0")
2571 (set_attr "memory" "load")
2572 (set_attr "mode" "DI")])
2573
2574 ;; Convert impossible stores of immediate to existing instructions.
2575 ;; First try to get scratch register and go through it. In case this
2576 ;; fails, move by 32bit parts.
2577 (define_peephole2
2578 [(match_scratch:DI 2 "r")
2579 (set (match_operand:DI 0 "memory_operand" "")
2580 (match_operand:DI 1 "immediate_operand" ""))]
2581 "TARGET_64BIT && !symbolic_operand (operands[1], DImode)
2582 && !x86_64_immediate_operand (operands[1], DImode)"
2583 [(set (match_dup 2) (match_dup 1))
2584 (set (match_dup 0) (match_dup 2))]
2585 "")
2586
2587 ;; We need to define this as both peepholer and splitter for case
2588 ;; peephole2 pass is not run.
2589 (define_peephole2
2590 [(set (match_operand:DI 0 "memory_operand" "")
2591 (match_operand:DI 1 "immediate_operand" ""))]
2592 "TARGET_64BIT && !symbolic_operand (operands[1], DImode)
2593 && !x86_64_immediate_operand (operands[1], DImode) && 1"
2594 [(set (match_dup 2) (match_dup 3))
2595 (set (match_dup 4) (match_dup 5))]
2596 "split_di (operands, 2, operands + 2, operands + 4);")
2597
2598 (define_split
2599 [(set (match_operand:DI 0 "memory_operand" "")
2600 (match_operand:DI 1 "immediate_operand" ""))]
2601 "TARGET_64BIT && (flow2_completed || (reload_completed && !flag_peephole2))
2602 && !symbolic_operand (operands[1], DImode)
2603 && !x86_64_immediate_operand (operands[1], DImode)"
2604 [(set (match_dup 2) (match_dup 3))
2605 (set (match_dup 4) (match_dup 5))]
2606 "split_di (operands, 2, operands + 2, operands + 4);")
2607
2608 (define_insn "*swapdi_rex64"
2609 [(set (match_operand:DI 0 "register_operand" "+r")
2610 (match_operand:DI 1 "register_operand" "+r"))
2611 (set (match_dup 1)
2612 (match_dup 0))]
2613 "TARGET_64BIT"
2614 "xchg{q}\t%1, %0"
2615 [(set_attr "type" "imov")
2616 (set_attr "pent_pair" "np")
2617 (set_attr "athlon_decode" "vector")
2618 (set_attr "mode" "DI")
2619 (set_attr "modrm" "0")
2620 (set_attr "ppro_uops" "few")])
2621
2622
2623 (define_expand "movsf"
2624 [(set (match_operand:SF 0 "nonimmediate_operand" "")
2625 (match_operand:SF 1 "general_operand" ""))]
2626 ""
2627 "ix86_expand_move (SFmode, operands); DONE;")
2628
2629 (define_insn "*pushsf"
2630 [(set (match_operand:SF 0 "push_operand" "=<,<,<")
2631 (match_operand:SF 1 "general_no_elim_operand" "f#rx,rFm#fx,x#rf"))]
2632 "!TARGET_64BIT"
2633 {
2634 switch (which_alternative)
2635 {
2636 case 0:
2637 /* %%% We loose REG_DEAD notes for controling pops if we split late. */
2638 operands[0] = gen_rtx_MEM (SFmode, stack_pointer_rtx);
2639 operands[2] = stack_pointer_rtx;
2640 operands[3] = GEN_INT (4);
2641 if (find_regno_note (insn, REG_DEAD, REGNO (operands[1])))
2642 return "sub{l}\t{%3, %2|%2, %3}\;fstp%z0\t%y0";
2643 else
2644 return "sub{l}\t{%3, %2|%2, %3}\;fst%z0\t%y0";
2645
2646 case 1:
2647 return "push{l}\t%1";
2648 case 2:
2649 return "#";
2650
2651 default:
2652 abort ();
2653 }
2654 }
2655 [(set_attr "type" "multi,push,multi")
2656 (set_attr "mode" "SF,SI,SF")])
2657
2658 (define_insn "*pushsf_rex64"
2659 [(set (match_operand:SF 0 "push_operand" "=X,X,X")
2660 (match_operand:SF 1 "nonmemory_no_elim_operand" "f#rx,rF#fx,x#rf"))]
2661 "TARGET_64BIT"
2662 {
2663 switch (which_alternative)
2664 {
2665 case 0:
2666 /* %%% We loose REG_DEAD notes for controling pops if we split late. */
2667 operands[0] = gen_rtx_MEM (SFmode, stack_pointer_rtx);
2668 operands[2] = stack_pointer_rtx;
2669 operands[3] = GEN_INT (8);
2670 if (find_regno_note (insn, REG_DEAD, REGNO (operands[1])))
2671 return "sub{q}\t{%3, %2|%2, %3}\;fstp%z0\t%y0";
2672 else
2673 return "sub{q}\t{%3, %2|%2, %3}\;fst%z0\t%y0";
2674
2675 case 1:
2676 return "push{q}\t%q1";
2677
2678 case 2:
2679 return "#";
2680
2681 default:
2682 abort ();
2683 }
2684 }
2685 [(set_attr "type" "multi,push,multi")
2686 (set_attr "mode" "SF,DI,SF")])
2687
2688 (define_split
2689 [(set (match_operand:SF 0 "push_operand" "")
2690 (match_operand:SF 1 "memory_operand" ""))]
2691 "reload_completed
2692 && GET_CODE (operands[1]) == MEM
2693 && GET_CODE (XEXP (operands[1], 0)) == SYMBOL_REF
2694 && CONSTANT_POOL_ADDRESS_P (XEXP (operands[1], 0))"
2695 [(set (match_dup 0)
2696 (match_dup 1))]
2697 "operands[1] = get_pool_constant (XEXP (operands[1], 0));")
2698
2699
2700 ;; %%% Kill this when call knows how to work this out.
2701 (define_split
2702 [(set (match_operand:SF 0 "push_operand" "")
2703 (match_operand:SF 1 "register_operand" ""))]
2704 "!TARGET_64BIT && ANY_FP_REGNO_P (REGNO (operands[1]))"
2705 [(set (reg:SI 7) (plus:SI (reg:SI 7) (const_int -4)))
2706 (set (mem:SF (reg:SI 7)) (match_dup 1))])
2707
2708 (define_split
2709 [(set (match_operand:SF 0 "push_operand" "")
2710 (match_operand:SF 1 "register_operand" ""))]
2711 "TARGET_64BIT && ANY_FP_REGNO_P (REGNO (operands[1]))"
2712 [(set (reg:DI 7) (plus:DI (reg:DI 7) (const_int -8)))
2713 (set (mem:SF (reg:DI 7)) (match_dup 1))])
2714
2715 (define_insn "*movsf_1"
2716 [(set (match_operand:SF 0 "nonimmediate_operand" "=f#xr,m,f#xr,r#xf,m,x#rf,x#rf,x#rf,m")
2717 (match_operand:SF 1 "general_operand" "fm#rx,f#rx,G,rmF#fx,Fr#fx,H,x,xm#rf,x#rf"))]
2718 "(GET_CODE (operands[0]) != MEM || GET_CODE (operands[1]) != MEM)
2719 && (reload_in_progress || reload_completed
2720 || (ix86_cmodel == CM_MEDIUM || ix86_cmodel == CM_LARGE)
2721 || GET_CODE (operands[1]) != CONST_DOUBLE
2722 || memory_operand (operands[0], SFmode))"
2723 {
2724 switch (which_alternative)
2725 {
2726 case 0:
2727 if (REG_P (operands[1])
2728 && find_regno_note (insn, REG_DEAD, REGNO (operands[1])))
2729 return "fstp\t%y0";
2730 else if (STACK_TOP_P (operands[0]))
2731 return "fld%z1\t%y1";
2732 else
2733 return "fst\t%y0";
2734
2735 case 1:
2736 if (find_regno_note (insn, REG_DEAD, REGNO (operands[1])))
2737 return "fstp%z0\t%y0";
2738 else
2739 return "fst%z0\t%y0";
2740
2741 case 2:
2742 switch (standard_80387_constant_p (operands[1]))
2743 {
2744 case 1:
2745 return "fldz";
2746 case 2:
2747 return "fld1";
2748 }
2749 abort();
2750
2751 case 3:
2752 case 4:
2753 return "mov{l}\t{%1, %0|%0, %1}";
2754 case 5:
2755 return "pxor\t%0, %0";
2756 case 6:
2757 if (TARGET_PARTIAL_REG_DEPENDENCY)
2758 return "movaps\t{%1, %0|%0, %1}";
2759 else
2760 return "movss\t{%1, %0|%0, %1}";
2761 case 7:
2762 case 8:
2763 return "movss\t{%1, %0|%0, %1}";
2764
2765 default:
2766 abort();
2767 }
2768 }
2769 [(set_attr "type" "fmov,fmov,fmov,imov,imov,sse,sse,sse,sse")
2770 (set_attr "mode" "SF,SF,SF,SI,SI,TI,SF,SF,SF")])
2771
2772 (define_insn "*swapsf"
2773 [(set (match_operand:SF 0 "register_operand" "+f")
2774 (match_operand:SF 1 "register_operand" "+f"))
2775 (set (match_dup 1)
2776 (match_dup 0))]
2777 "reload_completed || !TARGET_SSE"
2778 {
2779 if (STACK_TOP_P (operands[0]))
2780 return "fxch\t%1";
2781 else
2782 return "fxch\t%0";
2783 }
2784 [(set_attr "type" "fxch")
2785 (set_attr "mode" "SF")])
2786
2787 (define_expand "movdf"
2788 [(set (match_operand:DF 0 "nonimmediate_operand" "")
2789 (match_operand:DF 1 "general_operand" ""))]
2790 ""
2791 "ix86_expand_move (DFmode, operands); DONE;")
2792
2793 ;; Size of pushdf is 3 (for sub) + 2 (for fstp) + memory operand size.
2794 ;; Size of pushdf using integer insturctions is 2+2*memory operand size
2795 ;; On the average, pushdf using integers can be still shorter. Allow this
2796 ;; pattern for optimize_size too.
2797
2798 (define_insn "*pushdf_nointeger"
2799 [(set (match_operand:DF 0 "push_operand" "=<,<,<,<")
2800 (match_operand:DF 1 "general_no_elim_operand" "f#Y,Fo#fY,*r#fY,Y#f"))]
2801 "!TARGET_64BIT && !TARGET_INTEGER_DFMODE_MOVES"
2802 {
2803 switch (which_alternative)
2804 {
2805 case 0:
2806 /* %%% We loose REG_DEAD notes for controling pops if we split late. */
2807 operands[0] = gen_rtx_MEM (DFmode, stack_pointer_rtx);
2808 operands[2] = stack_pointer_rtx;
2809 operands[3] = GEN_INT (8);
2810 if (find_regno_note (insn, REG_DEAD, REGNO (operands[1])))
2811 return "sub{l}\t{%3, %2|%2, %3}\;fstp%z0\t%y0";
2812 else
2813 return "sub{l}\t{%3, %2|%2, %3}\;fst%z0\t%y0";
2814
2815 case 1:
2816 case 2:
2817 case 3:
2818 return "#";
2819
2820 default:
2821 abort ();
2822 }
2823 }
2824 [(set_attr "type" "multi")
2825 (set_attr "mode" "DF,SI,SI,DF")])
2826
2827 (define_insn "*pushdf_integer"
2828 [(set (match_operand:DF 0 "push_operand" "=<,<,<")
2829 (match_operand:DF 1 "general_no_elim_operand" "f#rY,rFo#fY,Y#rf"))]
2830 "TARGET_64BIT || TARGET_INTEGER_DFMODE_MOVES"
2831 {
2832 switch (which_alternative)
2833 {
2834 case 0:
2835 /* %%% We loose REG_DEAD notes for controling pops if we split late. */
2836 operands[0] = gen_rtx_MEM (DFmode, stack_pointer_rtx);
2837 operands[2] = stack_pointer_rtx;
2838 operands[3] = GEN_INT (8);
2839 if (TARGET_64BIT)
2840 if (find_regno_note (insn, REG_DEAD, REGNO (operands[1])))
2841 return "sub{q}\t{%3, %2|%2, %3}\;fstp%z0\t%y0";
2842 else
2843 return "sub{q}\t{%3, %2|%2, %3}\;fst%z0\t%y0";
2844 else
2845 if (find_regno_note (insn, REG_DEAD, REGNO (operands[1])))
2846 return "sub{l}\t{%3, %2|%2, %3}\;fstp%z0\t%y0";
2847 else
2848 return "sub{l}\t{%3, %2|%2, %3}\;fst%z0\t%y0";
2849
2850
2851 case 1:
2852 case 2:
2853 return "#";
2854
2855 default:
2856 abort ();
2857 }
2858 }
2859 [(set_attr "type" "multi")
2860 (set_attr "mode" "DF,SI,DF")])
2861
2862 ;; %%% Kill this when call knows how to work this out.
2863 (define_split
2864 [(set (match_operand:DF 0 "push_operand" "")
2865 (match_operand:DF 1 "register_operand" ""))]
2866 "!TARGET_64BIT && reload_completed && ANY_FP_REGNO_P (REGNO (operands[1]))"
2867 [(set (reg:SI 7) (plus:SI (reg:SI 7) (const_int -8)))
2868 (set (mem:DF (reg:SI 7)) (match_dup 1))]
2869 "")
2870
2871 (define_split
2872 [(set (match_operand:DF 0 "push_operand" "")
2873 (match_operand:DF 1 "register_operand" ""))]
2874 "TARGET_64BIT && reload_completed && ANY_FP_REGNO_P (REGNO (operands[1]))"
2875 [(set (reg:DI 7) (plus:DI (reg:DI 7) (const_int -8)))
2876 (set (mem:DF (reg:DI 7)) (match_dup 1))]
2877 "")
2878
2879 (define_split
2880 [(set (match_operand:DF 0 "push_operand" "")
2881 (match_operand:DF 1 "general_operand" ""))]
2882 "reload_completed"
2883 [(const_int 0)]
2884 "ix86_split_long_move (operands); DONE;")
2885
2886 ;; Moving is usually shorter when only FP registers are used. This separate
2887 ;; movdf pattern avoids the use of integer registers for FP operations
2888 ;; when optimizing for size.
2889
2890 (define_insn "*movdf_nointeger"
2891 [(set (match_operand:DF 0 "nonimmediate_operand" "=f#Y,m,f#Y,*r,o,Y#f,Y#f,Y#f,m")
2892 (match_operand:DF 1 "general_operand" "fm#Y,f#Y,G,*roF,F*r,H,Y#f,YHm#f,Y#f"))]
2893 "(GET_CODE (operands[0]) != MEM || GET_CODE (operands[1]) != MEM)
2894 && (optimize_size || !TARGET_INTEGER_DFMODE_MOVES)
2895 && (reload_in_progress || reload_completed
2896 || (ix86_cmodel == CM_MEDIUM || ix86_cmodel == CM_LARGE)
2897 || GET_CODE (operands[1]) != CONST_DOUBLE
2898 || memory_operand (operands[0], DFmode))"
2899 {
2900 switch (which_alternative)
2901 {
2902 case 0:
2903 if (REG_P (operands[1])
2904 && find_regno_note (insn, REG_DEAD, REGNO (operands[1])))
2905 return "fstp\t%y0";
2906 else if (STACK_TOP_P (operands[0]))
2907 return "fld%z1\t%y1";
2908 else
2909 return "fst\t%y0";
2910
2911 case 1:
2912 if (find_regno_note (insn, REG_DEAD, REGNO (operands[1])))
2913 return "fstp%z0\t%y0";
2914 else
2915 return "fst%z0\t%y0";
2916
2917 case 2:
2918 switch (standard_80387_constant_p (operands[1]))
2919 {
2920 case 1:
2921 return "fldz";
2922 case 2:
2923 return "fld1";
2924 }
2925 abort();
2926
2927 case 3:
2928 case 4:
2929 return "#";
2930 case 5:
2931 return "pxor\t%0, %0";
2932 case 6:
2933 if (TARGET_PARTIAL_REG_DEPENDENCY)
2934 return "movapd\t{%1, %0|%0, %1}";
2935 else
2936 return "movsd\t{%1, %0|%0, %1}";
2937 case 7:
2938 case 8:
2939 return "movsd\t{%1, %0|%0, %1}";
2940
2941 default:
2942 abort();
2943 }
2944 }
2945 [(set_attr "type" "fmov,fmov,fmov,multi,multi,sse,sse,sse,sse")
2946 (set_attr "mode" "DF,DF,DF,SI,SI,TI,DF,DF,DF")])
2947
2948 (define_insn "*movdf_integer"
2949 [(set (match_operand:DF 0 "nonimmediate_operand" "=f#Yr,m,f#Yr,r#Yf,o,Y#rf,Y#rf,Y#rf,m")
2950 (match_operand:DF 1 "general_operand" "fm#Yr,f#Yr,G,roF#Yf,Fr#Yf,H,Y#rf,Ym#rf,Y#rf"))]
2951 "(GET_CODE (operands[0]) != MEM || GET_CODE (operands[1]) != MEM)
2952 && !optimize_size && TARGET_INTEGER_DFMODE_MOVES
2953 && (reload_in_progress || reload_completed
2954 || (ix86_cmodel == CM_MEDIUM || ix86_cmodel == CM_LARGE)
2955 || GET_CODE (operands[1]) != CONST_DOUBLE
2956 || memory_operand (operands[0], DFmode))"
2957 {
2958 switch (which_alternative)
2959 {
2960 case 0:
2961 if (REG_P (operands[1])
2962 && find_regno_note (insn, REG_DEAD, REGNO (operands[1])))
2963 return "fstp\t%y0";
2964 else if (STACK_TOP_P (operands[0]))
2965 return "fld%z1\t%y1";
2966 else
2967 return "fst\t%y0";
2968
2969 case 1:
2970 if (find_regno_note (insn, REG_DEAD, REGNO (operands[1])))
2971 return "fstp%z0\t%y0";
2972 else
2973 return "fst%z0\t%y0";
2974
2975 case 2:
2976 switch (standard_80387_constant_p (operands[1]))
2977 {
2978 case 1:
2979 return "fldz";
2980 case 2:
2981 return "fld1";
2982 }
2983 abort();
2984
2985 case 3:
2986 case 4:
2987 return "#";
2988
2989 case 5:
2990 return "pxor\t%0, %0";
2991 case 6:
2992 if (TARGET_PARTIAL_REG_DEPENDENCY)
2993 return "movapd\t{%1, %0|%0, %1}";
2994 else
2995 return "movsd\t{%1, %0|%0, %1}";
2996 case 7:
2997 case 8:
2998 return "movsd\t{%1, %0|%0, %1}";
2999
3000 default:
3001 abort();
3002 }
3003 }
3004 [(set_attr "type" "fmov,fmov,fmov,multi,multi,sse,sse,sse,sse")
3005 (set_attr "mode" "DF,DF,DF,SI,SI,TI,DF,DF,DF")])
3006
3007 (define_split
3008 [(set (match_operand:DF 0 "nonimmediate_operand" "")
3009 (match_operand:DF 1 "general_operand" ""))]
3010 "reload_completed
3011 && (GET_CODE (operands[0]) != MEM || GET_CODE (operands[1]) != MEM)
3012 && ! (ANY_FP_REG_P (operands[0]) ||
3013 (GET_CODE (operands[0]) == SUBREG
3014 && ANY_FP_REG_P (SUBREG_REG (operands[0]))))
3015 && ! (ANY_FP_REG_P (operands[1]) ||
3016 (GET_CODE (operands[1]) == SUBREG
3017 && ANY_FP_REG_P (SUBREG_REG (operands[1]))))"
3018 [(const_int 0)]
3019 "ix86_split_long_move (operands); DONE;")
3020
3021 (define_insn "*swapdf"
3022 [(set (match_operand:DF 0 "register_operand" "+f")
3023 (match_operand:DF 1 "register_operand" "+f"))
3024 (set (match_dup 1)
3025 (match_dup 0))]
3026 "reload_completed || !TARGET_SSE2"
3027 {
3028 if (STACK_TOP_P (operands[0]))
3029 return "fxch\t%1";
3030 else
3031 return "fxch\t%0";
3032 }
3033 [(set_attr "type" "fxch")
3034 (set_attr "mode" "DF")])
3035
3036 (define_expand "movxf"
3037 [(set (match_operand:XF 0 "nonimmediate_operand" "")
3038 (match_operand:XF 1 "general_operand" ""))]
3039 "!TARGET_64BIT"
3040 "ix86_expand_move (XFmode, operands); DONE;")
3041
3042 (define_expand "movtf"
3043 [(set (match_operand:TF 0 "nonimmediate_operand" "")
3044 (match_operand:TF 1 "general_operand" ""))]
3045 ""
3046 "ix86_expand_move (TFmode, operands); DONE;")
3047
3048 ;; Size of pushdf is 3 (for sub) + 2 (for fstp) + memory operand size.
3049 ;; Size of pushdf using integer insturctions is 3+3*memory operand size
3050 ;; Pushing using integer instructions is longer except for constants
3051 ;; and direct memory references.
3052 ;; (assuming that any given constant is pushed only once, but this ought to be
3053 ;; handled elsewhere).
3054
3055 (define_insn "*pushxf_nointeger"
3056 [(set (match_operand:XF 0 "push_operand" "=X,X,X")
3057 (match_operand:XF 1 "general_no_elim_operand" "f,Fo,*r"))]
3058 "!TARGET_64BIT && optimize_size"
3059 {
3060 switch (which_alternative)
3061 {
3062 case 0:
3063 /* %%% We loose REG_DEAD notes for controling pops if we split late. */
3064 operands[0] = gen_rtx_MEM (XFmode, stack_pointer_rtx);
3065 operands[2] = stack_pointer_rtx;
3066 operands[3] = GEN_INT (12);
3067 if (find_regno_note (insn, REG_DEAD, REGNO (operands[1])))
3068 return "sub{l}\t{%3, %2|%2, %3}\;fstp%z0\t%y0";
3069 else
3070 return "sub{l}\t{%3, %2|%2, %3}\;fst%z0\t%y0";
3071
3072 case 1:
3073 case 2:
3074 return "#";
3075
3076 default:
3077 abort ();
3078 }
3079 }
3080 [(set_attr "type" "multi")
3081 (set_attr "mode" "XF,SI,SI")])
3082
3083 (define_insn "*pushtf_nointeger"
3084 [(set (match_operand:TF 0 "push_operand" "=<,<,<")
3085 (match_operand:TF 1 "general_no_elim_operand" "f,Fo,*r"))]
3086 "optimize_size"
3087 {
3088 switch (which_alternative)
3089 {
3090 case 0:
3091 /* %%% We loose REG_DEAD notes for controling pops if we split late. */
3092 operands[0] = gen_rtx_MEM (XFmode, stack_pointer_rtx);
3093 operands[2] = stack_pointer_rtx;
3094 operands[3] = GEN_INT (16);
3095 if (find_regno_note (insn, REG_DEAD, REGNO (operands[1])))
3096 return "sub{l}\t{%3, %2|%2, %3}\;fstp%z0\t%y0";
3097 else
3098 return "sub{l}\t{%3, %2|%2, %3}\;fst%z0\t%y0";
3099
3100 case 1:
3101 case 2:
3102 return "#";
3103
3104 default:
3105 abort ();
3106 }
3107 }
3108 [(set_attr "type" "multi")
3109 (set_attr "mode" "XF,SI,SI")])
3110
3111 (define_insn "*pushxf_integer"
3112 [(set (match_operand:XF 0 "push_operand" "=<,<")
3113 (match_operand:XF 1 "general_no_elim_operand" "f#r,ro#f"))]
3114 "!TARGET_64BIT && !optimize_size"
3115 {
3116 switch (which_alternative)
3117 {
3118 case 0:
3119 /* %%% We loose REG_DEAD notes for controling pops if we split late. */
3120 operands[0] = gen_rtx_MEM (XFmode, stack_pointer_rtx);
3121 operands[2] = stack_pointer_rtx;
3122 operands[3] = GEN_INT (12);
3123 if (find_regno_note (insn, REG_DEAD, REGNO (operands[1])))
3124 return "sub{l}\t{%3, %2|%2, %3}\;fstp%z0\t%y0";
3125 else
3126 return "sub{l}\t{%3, %2|%2, %3}\;fst%z0\t%y0";
3127
3128 case 1:
3129 return "#";
3130
3131 default:
3132 abort ();
3133 }
3134 }
3135 [(set_attr "type" "multi")
3136 (set_attr "mode" "XF,SI")])
3137
3138 (define_insn "*pushtf_integer"
3139 [(set (match_operand:TF 0 "push_operand" "=<,<")
3140 (match_operand:TF 1 "general_no_elim_operand" "f#r,rFo#f"))]
3141 "!optimize_size"
3142 {
3143 switch (which_alternative)
3144 {
3145 case 0:
3146 /* %%% We loose REG_DEAD notes for controling pops if we split late. */
3147 operands[0] = gen_rtx_MEM (XFmode, stack_pointer_rtx);
3148 operands[2] = stack_pointer_rtx;
3149 operands[3] = GEN_INT (16);
3150 if (TARGET_64BIT)
3151 if (find_regno_note (insn, REG_DEAD, REGNO (operands[1])))
3152 return "sub{q}\t{%3, %2|%2, %3}\;fstp%z0\t%y0";
3153 else
3154 return "sub{q}\t{%3, %2|%2, %3}\;fst%z0\t%y0";
3155 else
3156 if (find_regno_note (insn, REG_DEAD, REGNO (operands[1])))
3157 return "sub{l}\t{%3, %2|%2, %3}\;fstp%z0\t%y0";
3158 else
3159 return "sub{l}\t{%3, %2|%2, %3}\;fst%z0\t%y0";
3160
3161 case 1:
3162 return "#";
3163
3164 default:
3165 abort ();
3166 }
3167 }
3168 [(set_attr "type" "multi")
3169 (set_attr "mode" "XF,SI")])
3170
3171 (define_split
3172 [(set (match_operand 0 "push_operand" "")
3173 (match_operand 1 "general_operand" ""))]
3174 "reload_completed
3175 && (GET_MODE (operands[0]) == XFmode
3176 || GET_MODE (operands[0]) == TFmode
3177 || GET_MODE (operands[0]) == DFmode)
3178 && (!REG_P (operands[1]) || !ANY_FP_REGNO_P (REGNO (operands[1])))"
3179 [(const_int 0)]
3180 "ix86_split_long_move (operands); DONE;")
3181
3182 (define_split
3183 [(set (match_operand:XF 0 "push_operand" "")
3184 (match_operand:XF 1 "register_operand" ""))]
3185 "!TARGET_64BIT && ANY_FP_REGNO_P (REGNO (operands[1]))"
3186 [(set (reg:SI 7) (plus:SI (reg:SI 7) (const_int -12)))
3187 (set (mem:XF (reg:SI 7)) (match_dup 1))])
3188
3189 (define_split
3190 [(set (match_operand:TF 0 "push_operand" "")
3191 (match_operand:TF 1 "register_operand" ""))]
3192 "!TARGET_64BIT && ANY_FP_REGNO_P (REGNO (operands[1]))"
3193 [(set (reg:SI 7) (plus:SI (reg:SI 7) (const_int -16)))
3194 (set (mem:TF (reg:SI 7)) (match_dup 1))])
3195
3196 (define_split
3197 [(set (match_operand:TF 0 "push_operand" "")
3198 (match_operand:TF 1 "register_operand" ""))]
3199 "TARGET_64BIT && ANY_FP_REGNO_P (REGNO (operands[1]))"
3200 [(set (reg:DI 7) (plus:DI (reg:DI 7) (const_int -16)))
3201 (set (mem:TF (reg:DI 7)) (match_dup 1))])
3202
3203 ;; Do not use integer registers when optimizing for size
3204 (define_insn "*movxf_nointeger"
3205 [(set (match_operand:XF 0 "nonimmediate_operand" "=f,m,f,*r,o")
3206 (match_operand:XF 1 "general_operand" "fm,f,G,*roF,F*r"))]
3207 "!TARGET_64BIT
3208 && optimize_size
3209 && (GET_CODE (operands[0]) != MEM || GET_CODE (operands[1]) != MEM)
3210 && (reload_in_progress || reload_completed
3211 || GET_CODE (operands[1]) != CONST_DOUBLE
3212 || memory_operand (operands[0], XFmode))"
3213 {
3214 switch (which_alternative)
3215 {
3216 case 0:
3217 if (REG_P (operands[1])
3218 && find_regno_note (insn, REG_DEAD, REGNO (operands[1])))
3219 return "fstp\t%y0";
3220 else if (STACK_TOP_P (operands[0]))
3221 return "fld%z1\t%y1";
3222 else
3223 return "fst\t%y0";
3224
3225 case 1:
3226 /* There is no non-popping store to memory for XFmode. So if
3227 we need one, follow the store with a load. */
3228 if (! find_regno_note (insn, REG_DEAD, REGNO (operands[1])))
3229 return "fstp%z0\t%y0\;fld%z0\t%y0";
3230 else
3231 return "fstp%z0\t%y0";
3232
3233 case 2:
3234 switch (standard_80387_constant_p (operands[1]))
3235 {
3236 case 1:
3237 return "fldz";
3238 case 2:
3239 return "fld1";
3240 }
3241 break;
3242
3243 case 3: case 4:
3244 return "#";
3245 }
3246 abort();
3247 }
3248 [(set_attr "type" "fmov,fmov,fmov,multi,multi")
3249 (set_attr "mode" "XF,XF,XF,SI,SI")])
3250
3251 (define_insn "*movtf_nointeger"
3252 [(set (match_operand:TF 0 "nonimmediate_operand" "=f,m,f,*r,o")
3253 (match_operand:TF 1 "general_operand" "fm,f,G,*roF,F*r"))]
3254 "(GET_CODE (operands[0]) != MEM || GET_CODE (operands[1]) != MEM)
3255 && optimize_size
3256 && (reload_in_progress || reload_completed
3257 || GET_CODE (operands[1]) != CONST_DOUBLE
3258 || (ix86_cmodel == CM_MEDIUM || ix86_cmodel == CM_LARGE)
3259 || memory_operand (operands[0], TFmode))"
3260 {
3261 switch (which_alternative)
3262 {
3263 case 0:
3264 if (REG_P (operands[1])
3265 && find_regno_note (insn, REG_DEAD, REGNO (operands[1])))
3266 return "fstp\t%y0";
3267 else if (STACK_TOP_P (operands[0]))
3268 return "fld%z1\t%y1";
3269 else
3270 return "fst\t%y0";
3271
3272 case 1:
3273 /* There is no non-popping store to memory for XFmode. So if
3274 we need one, follow the store with a load. */
3275 if (! find_regno_note (insn, REG_DEAD, REGNO (operands[1])))
3276 return "fstp%z0\t%y0\;fld%z0\t%y0";
3277 else
3278 return "fstp%z0\t%y0";
3279
3280 case 2:
3281 switch (standard_80387_constant_p (operands[1]))
3282 {
3283 case 1:
3284 return "fldz";
3285 case 2:
3286 return "fld1";
3287 }
3288 break;
3289
3290 case 3: case 4:
3291 return "#";
3292 }
3293 abort();
3294 }
3295 [(set_attr "type" "fmov,fmov,fmov,multi,multi")
3296 (set_attr "mode" "XF,XF,XF,SI,SI")])
3297
3298 (define_insn "*movxf_integer"
3299 [(set (match_operand:XF 0 "nonimmediate_operand" "=f#r,m,f#r,r#f,o")
3300 (match_operand:XF 1 "general_operand" "fm#r,f#r,G,roF#f,Fr#f"))]
3301 "!TARGET_64BIT
3302 && !optimize_size
3303 && (GET_CODE (operands[0]) != MEM || GET_CODE (operands[1]) != MEM)
3304 && (reload_in_progress || reload_completed
3305 || GET_CODE (operands[1]) != CONST_DOUBLE
3306 || memory_operand (operands[0], XFmode))"
3307 {
3308 switch (which_alternative)
3309 {
3310 case 0:
3311 if (REG_P (operands[1])
3312 && find_regno_note (insn, REG_DEAD, REGNO (operands[1])))
3313 return "fstp\t%y0";
3314 else if (STACK_TOP_P (operands[0]))
3315 return "fld%z1\t%y1";
3316 else
3317 return "fst\t%y0";
3318
3319 case 1:
3320 /* There is no non-popping store to memory for XFmode. So if
3321 we need one, follow the store with a load. */
3322 if (! find_regno_note (insn, REG_DEAD, REGNO (operands[1])))
3323 return "fstp%z0\t%y0\;fld%z0\t%y0";
3324 else
3325 return "fstp%z0\t%y0";
3326
3327 case 2:
3328 switch (standard_80387_constant_p (operands[1]))
3329 {
3330 case 1:
3331 return "fldz";
3332 case 2:
3333 return "fld1";
3334 }
3335 break;
3336
3337 case 3: case 4:
3338 return "#";
3339 }
3340 abort();
3341 }
3342 [(set_attr "type" "fmov,fmov,fmov,multi,multi")
3343 (set_attr "mode" "XF,XF,XF,SI,SI")])
3344
3345 (define_insn "*movtf_integer"
3346 [(set (match_operand:TF 0 "nonimmediate_operand" "=f#r,m,f#r,r#f,o")
3347 (match_operand:TF 1 "general_operand" "fm#r,f#r,G,roF#f,Fr#f"))]
3348 "(GET_CODE (operands[0]) != MEM || GET_CODE (operands[1]) != MEM)
3349 && !optimize_size
3350 && (reload_in_progress || reload_completed
3351 || GET_CODE (operands[1]) != CONST_DOUBLE
3352 || (ix86_cmodel == CM_MEDIUM || ix86_cmodel == CM_LARGE)
3353 || memory_operand (operands[0], TFmode))"
3354 {
3355 switch (which_alternative)
3356 {
3357 case 0:
3358 if (REG_P (operands[1])
3359 && find_regno_note (insn, REG_DEAD, REGNO (operands[1])))
3360 return "fstp\t%y0";
3361 else if (STACK_TOP_P (operands[0]))
3362 return "fld%z1\t%y1";
3363 else
3364 return "fst\t%y0";
3365
3366 case 1:
3367 /* There is no non-popping store to memory for XFmode. So if
3368 we need one, follow the store with a load. */
3369 if (! find_regno_note (insn, REG_DEAD, REGNO (operands[1])))
3370 return "fstp%z0\t%y0\;fld%z0\t%y0";
3371 else
3372 return "fstp%z0\t%y0";
3373
3374 case 2:
3375 switch (standard_80387_constant_p (operands[1]))
3376 {
3377 case 1:
3378 return "fldz";
3379 case 2:
3380 return "fld1";
3381 }
3382 break;
3383
3384 case 3: case 4:
3385 return "#";
3386 }
3387 abort();
3388 }
3389 [(set_attr "type" "fmov,fmov,fmov,multi,multi")
3390 (set_attr "mode" "XF,XF,XF,SI,SI")])
3391
3392 (define_split
3393 [(set (match_operand 0 "nonimmediate_operand" "")
3394 (match_operand 1 "general_operand" ""))]
3395 "reload_completed
3396 && (GET_CODE (operands[0]) != MEM || GET_CODE (operands[1]) != MEM)
3397 && (GET_MODE (operands[0]) == XFmode || GET_MODE (operands[0]) == TFmode)
3398 && ! (ANY_FP_REG_P (operands[0]) ||
3399 (GET_CODE (operands[0]) == SUBREG
3400 && ANY_FP_REG_P (SUBREG_REG (operands[0]))))
3401 && ! (ANY_FP_REG_P (operands[1]) ||
3402 (GET_CODE (operands[1]) == SUBREG
3403 && ANY_FP_REG_P (SUBREG_REG (operands[1]))))"
3404 [(const_int 0)]
3405 "ix86_split_long_move (operands); DONE;")
3406
3407 (define_split
3408 [(set (match_operand 0 "register_operand" "")
3409 (match_operand 1 "memory_operand" ""))]
3410 "reload_completed
3411 && GET_CODE (operands[1]) == MEM
3412 && (GET_MODE (operands[0]) == XFmode || GET_MODE (operands[0]) == TFmode
3413 || GET_MODE (operands[0]) == SFmode || GET_MODE (operands[0]) == DFmode)
3414 && GET_CODE (XEXP (operands[1], 0)) == SYMBOL_REF
3415 && CONSTANT_POOL_ADDRESS_P (XEXP (operands[1], 0))
3416 && (!(SSE_REG_P (operands[0]) ||
3417 (GET_CODE (operands[0]) == SUBREG
3418 && SSE_REG_P (SUBREG_REG (operands[0]))))
3419 || standard_sse_constant_p (get_pool_constant (XEXP (operands[1], 0))))
3420 && (!(FP_REG_P (operands[0]) ||
3421 (GET_CODE (operands[0]) == SUBREG
3422 && FP_REG_P (SUBREG_REG (operands[0]))))
3423 || standard_80387_constant_p (get_pool_constant (XEXP (operands[1], 0))))"
3424 [(set (match_dup 0)
3425 (match_dup 1))]
3426 "operands[1] = get_pool_constant (XEXP (operands[1], 0));")
3427
3428 (define_insn "swapxf"
3429 [(set (match_operand:XF 0 "register_operand" "+f")
3430 (match_operand:XF 1 "register_operand" "+f"))
3431 (set (match_dup 1)
3432 (match_dup 0))]
3433 ""
3434 {
3435 if (STACK_TOP_P (operands[0]))
3436 return "fxch\t%1";
3437 else
3438 return "fxch\t%0";
3439 }
3440 [(set_attr "type" "fxch")
3441 (set_attr "mode" "XF")])
3442
3443 (define_insn "swaptf"
3444 [(set (match_operand:TF 0 "register_operand" "+f")
3445 (match_operand:TF 1 "register_operand" "+f"))
3446 (set (match_dup 1)
3447 (match_dup 0))]
3448 ""
3449 {
3450 if (STACK_TOP_P (operands[0]))
3451 return "fxch\t%1";
3452 else
3453 return "fxch\t%0";
3454 }
3455 [(set_attr "type" "fxch")
3456 (set_attr "mode" "XF")])
3457 \f
3458 ;; Zero extension instructions
3459
3460 (define_expand "zero_extendhisi2"
3461 [(set (match_operand:SI 0 "register_operand" "")
3462 (zero_extend:SI (match_operand:HI 1 "nonimmediate_operand" "")))]
3463 ""
3464 {
3465 if (TARGET_ZERO_EXTEND_WITH_AND && !optimize_size)
3466 {
3467 operands[1] = force_reg (HImode, operands[1]);
3468 emit_insn (gen_zero_extendhisi2_and (operands[0], operands[1]));
3469 DONE;
3470 }
3471 })
3472
3473 (define_insn "zero_extendhisi2_and"
3474 [(set (match_operand:SI 0 "register_operand" "=r")
3475 (zero_extend:SI (match_operand:HI 1 "register_operand" "0")))
3476 (clobber (reg:CC 17))]
3477 "TARGET_ZERO_EXTEND_WITH_AND && !optimize_size"
3478 "#"
3479 [(set_attr "type" "alu1")
3480 (set_attr "mode" "SI")])
3481
3482 (define_split
3483 [(set (match_operand:SI 0 "register_operand" "")
3484 (zero_extend:SI (match_operand:HI 1 "register_operand" "")))
3485 (clobber (reg:CC 17))]
3486 "reload_completed && TARGET_ZERO_EXTEND_WITH_AND && !optimize_size"
3487 [(parallel [(set (match_dup 0) (and:SI (match_dup 0) (const_int 65535)))
3488 (clobber (reg:CC 17))])]
3489 "")
3490
3491 (define_insn "*zero_extendhisi2_movzwl"
3492 [(set (match_operand:SI 0 "register_operand" "=r")
3493 (zero_extend:SI (match_operand:HI 1 "nonimmediate_operand" "rm")))]
3494 "!TARGET_ZERO_EXTEND_WITH_AND || optimize_size"
3495 "movz{wl|x}\t{%1, %0|%0, %1}"
3496 [(set_attr "type" "imovx")
3497 (set_attr "mode" "SI")])
3498
3499 (define_expand "zero_extendqihi2"
3500 [(parallel
3501 [(set (match_operand:HI 0 "register_operand" "")
3502 (zero_extend:HI (match_operand:QI 1 "nonimmediate_operand" "")))
3503 (clobber (reg:CC 17))])]
3504 ""
3505 "")
3506
3507 (define_insn "*zero_extendqihi2_and"
3508 [(set (match_operand:HI 0 "register_operand" "=r,?&q")
3509 (zero_extend:HI (match_operand:QI 1 "nonimmediate_operand" "0,qm")))
3510 (clobber (reg:CC 17))]
3511 "TARGET_ZERO_EXTEND_WITH_AND && !optimize_size"
3512 "#"
3513 [(set_attr "type" "alu1")
3514 (set_attr "mode" "HI")])
3515
3516 (define_insn "*zero_extendqihi2_movzbw_and"
3517 [(set (match_operand:HI 0 "register_operand" "=r,r")
3518 (zero_extend:HI (match_operand:QI 1 "nonimmediate_operand" "qm,0")))
3519 (clobber (reg:CC 17))]
3520 "!TARGET_ZERO_EXTEND_WITH_AND || optimize_size"
3521 "#"
3522 [(set_attr "type" "imovx,alu1")
3523 (set_attr "mode" "HI")])
3524
3525 (define_insn "*zero_extendqihi2_movzbw"
3526 [(set (match_operand:HI 0 "register_operand" "=r")
3527 (zero_extend:HI (match_operand:QI 1 "nonimmediate_operand" "qm")))]
3528 "(!TARGET_ZERO_EXTEND_WITH_AND || optimize_size) && reload_completed"
3529 "movz{bw|x}\t{%1, %0|%0, %1}"
3530 [(set_attr "type" "imovx")
3531 (set_attr "mode" "HI")])
3532
3533 ;; For the movzbw case strip only the clobber
3534 (define_split
3535 [(set (match_operand:HI 0 "register_operand" "")
3536 (zero_extend:HI (match_operand:QI 1 "nonimmediate_operand" "")))
3537 (clobber (reg:CC 17))]
3538 "reload_completed
3539 && (!TARGET_ZERO_EXTEND_WITH_AND || optimize_size)
3540 && (!REG_P (operands[1]) || ANY_QI_REG_P (operands[1]))"
3541 [(set (match_operand:HI 0 "register_operand" "")
3542 (zero_extend:HI (match_operand:QI 1 "nonimmediate_operand" "")))])
3543
3544 ;; When source and destination does not overlap, clear destination
3545 ;; first and then do the movb
3546 (define_split
3547 [(set (match_operand:HI 0 "register_operand" "")
3548 (zero_extend:HI (match_operand:QI 1 "nonimmediate_operand" "")))
3549 (clobber (reg:CC 17))]
3550 "reload_completed
3551 && ANY_QI_REG_P (operands[0])
3552 && (TARGET_ZERO_EXTEND_WITH_AND && !optimize_size)
3553 && !reg_overlap_mentioned_p (operands[0], operands[1])"
3554 [(set (match_dup 0) (const_int 0))
3555 (set (strict_low_part (match_dup 2)) (match_dup 1))]
3556 "operands[2] = gen_lowpart (QImode, operands[0]);")
3557
3558 ;; Rest is handled by single and.
3559 (define_split
3560 [(set (match_operand:HI 0 "register_operand" "")
3561 (zero_extend:HI (match_operand:QI 1 "register_operand" "")))
3562 (clobber (reg:CC 17))]
3563 "reload_completed
3564 && true_regnum (operands[0]) == true_regnum (operands[1])"
3565 [(parallel [(set (match_dup 0) (and:HI (match_dup 0) (const_int 255)))
3566 (clobber (reg:CC 17))])]
3567 "")
3568
3569 (define_expand "zero_extendqisi2"
3570 [(parallel
3571 [(set (match_operand:SI 0 "register_operand" "")
3572 (zero_extend:SI (match_operand:QI 1 "nonimmediate_operand" "")))
3573 (clobber (reg:CC 17))])]
3574 ""
3575 "")
3576
3577 (define_insn "*zero_extendqisi2_and"
3578 [(set (match_operand:SI 0 "register_operand" "=r,?&q")
3579 (zero_extend:SI (match_operand:QI 1 "nonimmediate_operand" "0,qm")))
3580 (clobber (reg:CC 17))]
3581 "TARGET_ZERO_EXTEND_WITH_AND && !optimize_size"
3582 "#"
3583 [(set_attr "type" "alu1")
3584 (set_attr "mode" "SI")])
3585
3586 (define_insn "*zero_extendqisi2_movzbw_and"
3587 [(set (match_operand:SI 0 "register_operand" "=r,r")
3588 (zero_extend:SI (match_operand:QI 1 "nonimmediate_operand" "qm,0")))
3589 (clobber (reg:CC 17))]
3590 "!TARGET_ZERO_EXTEND_WITH_AND || optimize_size"
3591 "#"
3592 [(set_attr "type" "imovx,alu1")
3593 (set_attr "mode" "SI")])
3594
3595 (define_insn "*zero_extendqisi2_movzbw"
3596 [(set (match_operand:SI 0 "register_operand" "=r")
3597 (zero_extend:SI (match_operand:QI 1 "nonimmediate_operand" "qm")))]
3598 "(!TARGET_ZERO_EXTEND_WITH_AND || optimize_size) && reload_completed"
3599 "movz{bl|x}\t{%1, %0|%0, %1}"
3600 [(set_attr "type" "imovx")
3601 (set_attr "mode" "SI")])
3602
3603 ;; For the movzbl case strip only the clobber
3604 (define_split
3605 [(set (match_operand:SI 0 "register_operand" "")
3606 (zero_extend:SI (match_operand:QI 1 "nonimmediate_operand" "")))
3607 (clobber (reg:CC 17))]
3608 "reload_completed
3609 && (!TARGET_ZERO_EXTEND_WITH_AND || optimize_size)
3610 && (!REG_P (operands[1]) || ANY_QI_REG_P (operands[1]))"
3611 [(set (match_dup 0)
3612 (zero_extend:SI (match_dup 1)))])
3613
3614 ;; When source and destination does not overlap, clear destination
3615 ;; first and then do the movb
3616 (define_split
3617 [(set (match_operand:SI 0 "register_operand" "")
3618 (zero_extend:SI (match_operand:QI 1 "nonimmediate_operand" "")))
3619 (clobber (reg:CC 17))]
3620 "reload_completed
3621 && ANY_QI_REG_P (operands[0])
3622 && (ANY_QI_REG_P (operands[1]) || GET_CODE (operands[1]) == MEM)
3623 && (TARGET_ZERO_EXTEND_WITH_AND && !optimize_size)
3624 && !reg_overlap_mentioned_p (operands[0], operands[1])"
3625 [(set (match_dup 0) (const_int 0))
3626 (set (strict_low_part (match_dup 2)) (match_dup 1))]
3627 "operands[2] = gen_lowpart (QImode, operands[0]);")
3628
3629 ;; Rest is handled by single and.
3630 (define_split
3631 [(set (match_operand:SI 0 "register_operand" "")
3632 (zero_extend:SI (match_operand:QI 1 "register_operand" "")))
3633 (clobber (reg:CC 17))]
3634 "reload_completed
3635 && true_regnum (operands[0]) == true_regnum (operands[1])"
3636 [(parallel [(set (match_dup 0) (and:SI (match_dup 0) (const_int 255)))
3637 (clobber (reg:CC 17))])]
3638 "")
3639
3640 ;; %%% Kill me once multi-word ops are sane.
3641 (define_expand "zero_extendsidi2"
3642 [(set (match_operand:DI 0 "register_operand" "=r")
3643 (zero_extend:DI (match_operand:SI 1 "nonimmediate_operand" "rm")))]
3644 ""
3645 "if (!TARGET_64BIT)
3646 {
3647 emit_insn (gen_zero_extendsidi2_32 (operands[0], operands[1]));
3648 DONE;
3649 }
3650 ")
3651
3652 (define_insn "zero_extendsidi2_32"
3653 [(set (match_operand:DI 0 "nonimmediate_operand" "=r,?r,?*o")
3654 (zero_extend:DI (match_operand:SI 1 "nonimmediate_operand" "0,rm,r")))
3655 (clobber (reg:CC 17))]
3656 "!TARGET_64BIT"
3657 "#"
3658 [(set_attr "mode" "SI")])
3659
3660 (define_insn "zero_extendsidi2_rex64"
3661 [(set (match_operand:DI 0 "nonimmediate_operand" "=r,o")
3662 (zero_extend:DI (match_operand:SI 1 "nonimmediate_operand" "rm,0")))]
3663 "TARGET_64BIT"
3664 "@
3665 mov\t{%k1, %k0|%k0, %k1}
3666 #"
3667 [(set_attr "type" "imovx,imov")
3668 (set_attr "mode" "SI,DI")])
3669
3670 (define_split
3671 [(set (match_operand:DI 0 "memory_operand" "")
3672 (zero_extend:DI (match_dup 0)))]
3673 "TARGET_64BIT"
3674 [(set (match_dup 4) (const_int 0))]
3675 "split_di (&operands[0], 1, &operands[3], &operands[4]);")
3676
3677 (define_split
3678 [(set (match_operand:DI 0 "register_operand" "")
3679 (zero_extend:DI (match_operand:SI 1 "register_operand" "")))
3680 (clobber (reg:CC 17))]
3681 "!TARGET_64BIT && reload_completed
3682 && true_regnum (operands[0]) == true_regnum (operands[1])"
3683 [(set (match_dup 4) (const_int 0))]
3684 "split_di (&operands[0], 1, &operands[3], &operands[4]);")
3685
3686 (define_split
3687 [(set (match_operand:DI 0 "nonimmediate_operand" "")
3688 (zero_extend:DI (match_operand:SI 1 "general_operand" "")))
3689 (clobber (reg:CC 17))]
3690 "!TARGET_64BIT && reload_completed"
3691 [(set (match_dup 3) (match_dup 1))
3692 (set (match_dup 4) (const_int 0))]
3693 "split_di (&operands[0], 1, &operands[3], &operands[4]);")
3694
3695 (define_insn "zero_extendhidi2"
3696 [(set (match_operand:DI 0 "register_operand" "=r,r")
3697 (zero_extend:DI (match_operand:HI 1 "nonimmediate_operand" "r,m")))]
3698 "TARGET_64BIT"
3699 "@
3700 movz{wl|x}\t{%1, %k0|%k0, %1}
3701 movz{wq|x}\t{%1, %0|%0, %1}"
3702 [(set_attr "type" "imovx")
3703 (set_attr "mode" "SI,DI")])
3704
3705 (define_insn "zero_extendqidi2"
3706 [(set (match_operand:DI 0 "register_operand" "=r,r")
3707 (zero_extend:DI (match_operand:QI 1 "nonimmediate_operand" "Q,m")))]
3708 "TARGET_64BIT"
3709 "@
3710 movz{bl|x}\t{%1, %k0|%k0, %1}
3711 movz{bq|x}\t{%1, %0|%0, %1}"
3712 [(set_attr "type" "imovx")
3713 (set_attr "mode" "SI,DI")])
3714 \f
3715 ;; Sign extension instructions
3716
3717 (define_expand "extendsidi2"
3718 [(parallel [(set (match_operand:DI 0 "register_operand" "")
3719 (sign_extend:DI (match_operand:SI 1 "register_operand" "")))
3720 (clobber (reg:CC 17))
3721 (clobber (match_scratch:SI 2 ""))])]
3722 ""
3723 {
3724 if (TARGET_64BIT)
3725 {
3726 emit_insn (gen_extendsidi2_rex64 (operands[0], operands[1]));
3727 DONE;
3728 }
3729 })
3730
3731 (define_insn "*extendsidi2_1"
3732 [(set (match_operand:DI 0 "nonimmediate_operand" "=*A,r,?r,?*o")
3733 (sign_extend:DI (match_operand:SI 1 "register_operand" "0,0,r,r")))
3734 (clobber (reg:CC 17))
3735 (clobber (match_scratch:SI 2 "=X,X,X,&r"))]
3736 "!TARGET_64BIT"
3737 "#")
3738
3739 (define_insn "extendsidi2_rex64"
3740 [(set (match_operand:DI 0 "register_operand" "=*a,r")
3741 (sign_extend:DI (match_operand:SI 1 "nonimmediate_operand" "*0,rm")))]
3742 "TARGET_64BIT"
3743 "@
3744 {cltq|cdqe}
3745 movs{lq|x}\t{%1,%0|%0, %1}"
3746 [(set_attr "type" "imovx")
3747 (set_attr "mode" "DI")
3748 (set_attr "prefix_0f" "0")
3749 (set_attr "modrm" "0,1")])
3750
3751 (define_insn "extendhidi2"
3752 [(set (match_operand:DI 0 "register_operand" "=r")
3753 (sign_extend:DI (match_operand:HI 1 "nonimmediate_operand" "rm")))]
3754 "TARGET_64BIT"
3755 "movs{wq|x}\t{%1,%0|%0, %1}"
3756 [(set_attr "type" "imovx")
3757 (set_attr "mode" "DI")])
3758
3759 (define_insn "extendqidi2"
3760 [(set (match_operand:DI 0 "register_operand" "=r")
3761 (sign_extend:DI (match_operand:QI 1 "nonimmediate_operand" "qm")))]
3762 "TARGET_64BIT"
3763 "movs{bq|x}\t{%1,%0|%0, %1}"
3764 [(set_attr "type" "imovx")
3765 (set_attr "mode" "DI")])
3766
3767 ;; Extend to memory case when source register does die.
3768 (define_split
3769 [(set (match_operand:DI 0 "memory_operand" "")
3770 (sign_extend:DI (match_operand:SI 1 "register_operand" "")))
3771 (clobber (reg:CC 17))
3772 (clobber (match_operand:SI 2 "register_operand" ""))]
3773 "(reload_completed
3774 && dead_or_set_p (insn, operands[1])
3775 && !reg_mentioned_p (operands[1], operands[0]))"
3776 [(set (match_dup 3) (match_dup 1))
3777 (parallel [(set (match_dup 1) (ashiftrt:SI (match_dup 1) (const_int 31)))
3778 (clobber (reg:CC 17))])
3779 (set (match_dup 4) (match_dup 1))]
3780 "split_di (&operands[0], 1, &operands[3], &operands[4]);")
3781
3782 ;; Extend to memory case when source register does not die.
3783 (define_split
3784 [(set (match_operand:DI 0 "memory_operand" "")
3785 (sign_extend:DI (match_operand:SI 1 "register_operand" "")))
3786 (clobber (reg:CC 17))
3787 (clobber (match_operand:SI 2 "register_operand" ""))]
3788 "reload_completed"
3789 [(const_int 0)]
3790 {
3791 split_di (&operands[0], 1, &operands[3], &operands[4]);
3792
3793 emit_move_insn (operands[3], operands[1]);
3794
3795 /* Generate a cltd if possible and doing so it profitable. */
3796 if (true_regnum (operands[1]) == 0
3797 && true_regnum (operands[2]) == 1
3798 && (optimize_size || TARGET_USE_CLTD))
3799 {
3800 emit_insn (gen_ashrsi3_31 (operands[2], operands[1], GEN_INT (31)));
3801 }
3802 else
3803 {
3804 emit_move_insn (operands[2], operands[1]);
3805 emit_insn (gen_ashrsi3_31 (operands[2], operands[2], GEN_INT (31)));
3806 }
3807 emit_move_insn (operands[4], operands[2]);
3808 DONE;
3809 })
3810
3811 ;; Extend to register case. Optimize case where source and destination
3812 ;; registers match and cases where we can use cltd.
3813 (define_split
3814 [(set (match_operand:DI 0 "register_operand" "")
3815 (sign_extend:DI (match_operand:SI 1 "register_operand" "")))
3816 (clobber (reg:CC 17))
3817 (clobber (match_scratch:SI 2 ""))]
3818 "reload_completed"
3819 [(const_int 0)]
3820 {
3821 split_di (&operands[0], 1, &operands[3], &operands[4]);
3822
3823 if (true_regnum (operands[3]) != true_regnum (operands[1]))
3824 emit_move_insn (operands[3], operands[1]);
3825
3826 /* Generate a cltd if possible and doing so it profitable. */
3827 if (true_regnum (operands[3]) == 0
3828 && (optimize_size || TARGET_USE_CLTD))
3829 {
3830 emit_insn (gen_ashrsi3_31 (operands[4], operands[3], GEN_INT (31)));
3831 DONE;
3832 }
3833
3834 if (true_regnum (operands[4]) != true_regnum (operands[1]))
3835 emit_move_insn (operands[4], operands[1]);
3836
3837 emit_insn (gen_ashrsi3_31 (operands[4], operands[4], GEN_INT (31)));
3838 DONE;
3839 })
3840
3841 (define_insn "extendhisi2"
3842 [(set (match_operand:SI 0 "register_operand" "=*a,r")
3843 (sign_extend:SI (match_operand:HI 1 "nonimmediate_operand" "*0,rm")))]
3844 ""
3845 {
3846 switch (get_attr_prefix_0f (insn))
3847 {
3848 case 0:
3849 return "{cwtl|cwde}";
3850 default:
3851 return "movs{wl|x}\t{%1,%0|%0, %1}";
3852 }
3853 }
3854 [(set_attr "type" "imovx")
3855 (set_attr "mode" "SI")
3856 (set (attr "prefix_0f")
3857 ;; movsx is short decodable while cwtl is vector decoded.
3858 (if_then_else (and (eq_attr "cpu" "!k6")
3859 (eq_attr "alternative" "0"))
3860 (const_string "0")
3861 (const_string "1")))
3862 (set (attr "modrm")
3863 (if_then_else (eq_attr "prefix_0f" "0")
3864 (const_string "0")
3865 (const_string "1")))])
3866
3867 (define_insn "*extendhisi2_zext"
3868 [(set (match_operand:DI 0 "register_operand" "=*a,r")
3869 (zero_extend:DI
3870 (sign_extend:SI (match_operand:HI 1 "nonimmediate_operand" "*0,rm"))))]
3871 "TARGET_64BIT"
3872 {
3873 switch (get_attr_prefix_0f (insn))
3874 {
3875 case 0:
3876 return "{cwtl|cwde}";
3877 default:
3878 return "movs{wl|x}\t{%1,%k0|%k0, %1}";
3879 }
3880 }
3881 [(set_attr "type" "imovx")
3882 (set_attr "mode" "SI")
3883 (set (attr "prefix_0f")
3884 ;; movsx is short decodable while cwtl is vector decoded.
3885 (if_then_else (and (eq_attr "cpu" "!k6")
3886 (eq_attr "alternative" "0"))
3887 (const_string "0")
3888 (const_string "1")))
3889 (set (attr "modrm")
3890 (if_then_else (eq_attr "prefix_0f" "0")
3891 (const_string "0")
3892 (const_string "1")))])
3893
3894 (define_insn "extendqihi2"
3895 [(set (match_operand:HI 0 "register_operand" "=*a,r")
3896 (sign_extend:HI (match_operand:QI 1 "nonimmediate_operand" "*0,qm")))]
3897 ""
3898 {
3899 switch (get_attr_prefix_0f (insn))
3900 {
3901 case 0:
3902 return "{cbtw|cbw}";
3903 default:
3904 return "movs{bw|x}\t{%1,%0|%0, %1}";
3905 }
3906 }
3907 [(set_attr "type" "imovx")
3908 (set_attr "mode" "HI")
3909 (set (attr "prefix_0f")
3910 ;; movsx is short decodable while cwtl is vector decoded.
3911 (if_then_else (and (eq_attr "cpu" "!k6")
3912 (eq_attr "alternative" "0"))
3913 (const_string "0")
3914 (const_string "1")))
3915 (set (attr "modrm")
3916 (if_then_else (eq_attr "prefix_0f" "0")
3917 (const_string "0")
3918 (const_string "1")))])
3919
3920 (define_insn "extendqisi2"
3921 [(set (match_operand:SI 0 "register_operand" "=r")
3922 (sign_extend:SI (match_operand:QI 1 "nonimmediate_operand" "qm")))]
3923 ""
3924 "movs{bl|x}\t{%1,%0|%0, %1}"
3925 [(set_attr "type" "imovx")
3926 (set_attr "mode" "SI")])
3927
3928 (define_insn "*extendqisi2_zext"
3929 [(set (match_operand:DI 0 "register_operand" "=r")
3930 (zero_extend:DI
3931 (sign_extend:SI (match_operand:QI 1 "nonimmediate_operand" "qm"))))]
3932 "TARGET_64BIT"
3933 "movs{bl|x}\t{%1,%k0|%k0, %1}"
3934 [(set_attr "type" "imovx")
3935 (set_attr "mode" "SI")])
3936 \f
3937 ;; Conversions between float and double.
3938
3939 ;; These are all no-ops in the model used for the 80387. So just
3940 ;; emit moves.
3941
3942 ;; %%% Kill these when call knows how to work out a DFmode push earlier.
3943 (define_insn "*dummy_extendsfdf2"
3944 [(set (match_operand:DF 0 "push_operand" "=<")
3945 (float_extend:DF (match_operand:SF 1 "nonimmediate_operand" "fY")))]
3946 "0"
3947 "#")
3948
3949 (define_split
3950 [(set (match_operand:DF 0 "push_operand" "")
3951 (float_extend:DF (match_operand:SF 1 "register_operand" "")))]
3952 "!TARGET_64BIT && FP_REGNO_P (REGNO (operands[1]))"
3953 [(set (reg:SI 7) (plus:SI (reg:SI 7) (const_int -8)))
3954 (set (mem:DF (reg:SI 7)) (float_extend:DF (match_dup 1)))])
3955
3956 (define_split
3957 [(set (match_operand:DF 0 "push_operand" "")
3958 (float_extend:DF (match_operand:SF 1 "register_operand" "")))]
3959 "TARGET_64BIT && FP_REGNO_P (REGNO (operands[1]))"
3960 [(set (reg:DI 7) (plus:DI (reg:DI 7) (const_int -8)))
3961 (set (mem:DF (reg:DI 7)) (float_extend:DF (match_dup 1)))])
3962
3963 (define_insn "*dummy_extendsfxf2"
3964 [(set (match_operand:XF 0 "push_operand" "=<")
3965 (float_extend:XF (match_operand:SF 1 "nonimmediate_operand" "f")))]
3966 "0"
3967 "#")
3968
3969 (define_split
3970 [(set (match_operand:XF 0 "push_operand" "")
3971 (float_extend:XF (match_operand:SF 1 "register_operand" "")))]
3972 "!TARGET_64BIT && FP_REGNO_P (REGNO (operands[1]))"
3973 [(set (reg:SI 7) (plus:SI (reg:SI 7) (const_int -12)))
3974 (set (mem:XF (reg:SI 7)) (float_extend:XF (match_dup 1)))])
3975
3976 (define_insn "*dummy_extendsftf2"
3977 [(set (match_operand:TF 0 "push_operand" "=<")
3978 (float_extend:TF (match_operand:SF 1 "nonimmediate_operand" "f")))]
3979 "0"
3980 "#")
3981
3982 (define_split
3983 [(set (match_operand:TF 0 "push_operand" "")
3984 (float_extend:TF (match_operand:SF 1 "register_operand" "")))]
3985 "!TARGET_64BIT && FP_REGNO_P (REGNO (operands[1]))"
3986 [(set (reg:SI 7) (plus:SI (reg:SI 7) (const_int -16)))
3987 (set (mem:TF (reg:SI 7)) (float_extend:TF (match_dup 1)))])
3988
3989 (define_split
3990 [(set (match_operand:TF 0 "push_operand" "")
3991 (float_extend:TF (match_operand:SF 1 "register_operand" "")))]
3992 "TARGET_64BIT && FP_REGNO_P (REGNO (operands[1]))"
3993 [(set (reg:DI 7) (plus:DI (reg:DI 7) (const_int -16)))
3994 (set (mem:DF (reg:DI 7)) (float_extend:TF (match_dup 1)))])
3995
3996 (define_insn "*dummy_extenddfxf2"
3997 [(set (match_operand:XF 0 "push_operand" "=<")
3998 (float_extend:XF (match_operand:DF 1 "nonimmediate_operand" "f")))]
3999 "0"
4000 "#")
4001
4002 (define_split
4003 [(set (match_operand:XF 0 "push_operand" "")
4004 (float_extend:XF (match_operand:DF 1 "register_operand" "")))]
4005 "!TARGET_64BIT && FP_REGNO_P (REGNO (operands[1]))"
4006 [(set (reg:SI 7) (plus:SI (reg:SI 7) (const_int -12)))
4007 (set (mem:DF (reg:SI 7)) (float_extend:XF (match_dup 1)))])
4008
4009 (define_insn "*dummy_extenddftf2"
4010 [(set (match_operand:TF 0 "push_operand" "=<")
4011 (float_extend:TF (match_operand:DF 1 "nonimmediate_operand" "f")))]
4012 "0"
4013 "#")
4014
4015 (define_split
4016 [(set (match_operand:TF 0 "push_operand" "")
4017 (float_extend:TF (match_operand:DF 1 "register_operand" "")))]
4018 "!TARGET_64BIT && FP_REGNO_P (REGNO (operands[1]))"
4019 [(set (reg:SI 7) (plus:SI (reg:SI 7) (const_int -16)))
4020 (set (mem:TF (reg:SI 7)) (float_extend:XF (match_dup 1)))])
4021
4022 (define_split
4023 [(set (match_operand:TF 0 "push_operand" "")
4024 (float_extend:TF (match_operand:DF 1 "register_operand" "")))]
4025 "TARGET_64BIT && FP_REGNO_P (REGNO (operands[1]))"
4026 [(set (reg:DI 7) (plus:DI (reg:DI 7) (const_int -16)))
4027 (set (mem:TF (reg:DI 7)) (float_extend:TF (match_dup 1)))])
4028
4029 (define_expand "extendsfdf2"
4030 [(set (match_operand:DF 0 "nonimmediate_operand" "")
4031 (float_extend:DF (match_operand:SF 1 "nonimmediate_operand" "")))]
4032 "TARGET_80387 || TARGET_SSE2"
4033 {
4034 if (GET_CODE (operands[0]) == MEM && GET_CODE (operands[1]) == MEM)
4035 operands[1] = force_reg (SFmode, operands[1]);
4036 })
4037
4038 (define_insn "*extendsfdf2_1"
4039 [(set (match_operand:DF 0 "nonimmediate_operand" "=f#Y,mf#Y,Y#f")
4040 (float_extend:DF (match_operand:SF 1 "nonimmediate_operand" "fm#Y,f#Y,mY#f")))]
4041 "(TARGET_80387 || TARGET_SSE2)
4042 && (GET_CODE (operands[0]) != MEM || GET_CODE (operands[1]) != MEM)"
4043 {
4044 switch (which_alternative)
4045 {
4046 case 0:
4047 if (REG_P (operands[1])
4048 && find_regno_note (insn, REG_DEAD, REGNO (operands[1])))
4049 return "fstp\t%y0";
4050 else if (STACK_TOP_P (operands[0]))
4051 return "fld%z1\t%y1";
4052 else
4053 return "fst\t%y0";
4054
4055 case 1:
4056 if (find_regno_note (insn, REG_DEAD, REGNO (operands[1])))
4057 return "fstp%z0\t%y0";
4058
4059 else
4060 return "fst%z0\t%y0";
4061 case 2:
4062 return "cvtss2sd\t{%1, %0|%0, %1}";
4063
4064 default:
4065 abort ();
4066 }
4067 }
4068 [(set_attr "type" "fmov,fmov,sse")
4069 (set_attr "mode" "SF,XF,DF")])
4070
4071 (define_insn "*extendsfdf2_1_sse_only"
4072 [(set (match_operand:DF 0 "register_operand" "=Y")
4073 (float_extend:DF (match_operand:SF 1 "nonimmediate_operand" "mY")))]
4074 "!TARGET_80387 && TARGET_SSE2
4075 && (GET_CODE (operands[0]) != MEM || GET_CODE (operands[1]) != MEM)"
4076 "cvtss2sd\t{%1, %0|%0, %1}"
4077 [(set_attr "type" "sse")
4078 (set_attr "mode" "DF")])
4079
4080 (define_expand "extendsfxf2"
4081 [(set (match_operand:XF 0 "nonimmediate_operand" "")
4082 (float_extend:XF (match_operand:SF 1 "nonimmediate_operand" "")))]
4083 "!TARGET_64BIT && TARGET_80387"
4084 {
4085 if (GET_CODE (operands[0]) == MEM && GET_CODE (operands[1]) == MEM)
4086 operands[1] = force_reg (SFmode, operands[1]);
4087 })
4088
4089 (define_insn "*extendsfxf2_1"
4090 [(set (match_operand:XF 0 "nonimmediate_operand" "=f,m")
4091 (float_extend:XF (match_operand:SF 1 "nonimmediate_operand" "fm,f")))]
4092 "!TARGET_64BIT && TARGET_80387
4093 && (GET_CODE (operands[0]) != MEM || GET_CODE (operands[1]) != MEM)"
4094 {
4095 switch (which_alternative)
4096 {
4097 case 0:
4098 if (REG_P (operands[1])
4099 && find_regno_note (insn, REG_DEAD, REGNO (operands[1])))
4100 return "fstp\t%y0";
4101 else if (STACK_TOP_P (operands[0]))
4102 return "fld%z1\t%y1";
4103 else
4104 return "fst\t%y0";
4105
4106 case 1:
4107 /* There is no non-popping store to memory for XFmode. So if
4108 we need one, follow the store with a load. */
4109 if (! find_regno_note (insn, REG_DEAD, REGNO (operands[1])))
4110 return "fstp%z0\t%y0\n\tfld%z0\t%y0";
4111 else
4112 return "fstp%z0\t%y0";
4113
4114 default:
4115 abort ();
4116 }
4117 }
4118 [(set_attr "type" "fmov")
4119 (set_attr "mode" "SF,XF")])
4120
4121 (define_expand "extendsftf2"
4122 [(set (match_operand:TF 0 "nonimmediate_operand" "")
4123 (float_extend:TF (match_operand:SF 1 "nonimmediate_operand" "")))]
4124 "TARGET_80387"
4125 {
4126 if (GET_CODE (operands[0]) == MEM && GET_CODE (operands[1]) == MEM)
4127 operands[1] = force_reg (SFmode, operands[1]);
4128 })
4129
4130 (define_insn "*extendsftf2_1"
4131 [(set (match_operand:TF 0 "nonimmediate_operand" "=f,m")
4132 (float_extend:TF (match_operand:SF 1 "nonimmediate_operand" "fm,f")))]
4133 "TARGET_80387
4134 && (GET_CODE (operands[0]) != MEM || GET_CODE (operands[1]) != MEM)"
4135 {
4136 switch (which_alternative)
4137 {
4138 case 0:
4139 if (REG_P (operands[1])
4140 && find_regno_note (insn, REG_DEAD, REGNO (operands[1])))
4141 return "fstp\t%y0";
4142 else if (STACK_TOP_P (operands[0]))
4143 return "fld%z1\t%y1";
4144 else
4145 return "fst\t%y0";
4146
4147 case 1:
4148 /* There is no non-popping store to memory for XFmode. So if
4149 we need one, follow the store with a load. */
4150 if (! find_regno_note (insn, REG_DEAD, REGNO (operands[1])))
4151 return "fstp%z0\t%y0\n\tfld%z0\t%y0";
4152 else
4153 return "fstp%z0\t%y0";
4154
4155 default:
4156 abort ();
4157 }
4158 }
4159 [(set_attr "type" "fmov")
4160 (set_attr "mode" "SF,XF")])
4161
4162 (define_expand "extenddfxf2"
4163 [(set (match_operand:XF 0 "nonimmediate_operand" "")
4164 (float_extend:XF (match_operand:DF 1 "nonimmediate_operand" "")))]
4165 "!TARGET_64BIT && TARGET_80387"
4166 {
4167 if (GET_CODE (operands[0]) == MEM && GET_CODE (operands[1]) == MEM)
4168 operands[1] = force_reg (DFmode, operands[1]);
4169 })
4170
4171 (define_insn "*extenddfxf2_1"
4172 [(set (match_operand:XF 0 "nonimmediate_operand" "=f,m")
4173 (float_extend:XF (match_operand:DF 1 "nonimmediate_operand" "fm,f")))]
4174 "!TARGET_64BIT && TARGET_80387
4175 && (GET_CODE (operands[0]) != MEM || GET_CODE (operands[1]) != MEM)"
4176 {
4177 switch (which_alternative)
4178 {
4179 case 0:
4180 if (REG_P (operands[1])
4181 && find_regno_note (insn, REG_DEAD, REGNO (operands[1])))
4182 return "fstp\t%y0";
4183 else if (STACK_TOP_P (operands[0]))
4184 return "fld%z1\t%y1";
4185 else
4186 return "fst\t%y0";
4187
4188 case 1:
4189 /* There is no non-popping store to memory for XFmode. So if
4190 we need one, follow the store with a load. */
4191 if (! find_regno_note (insn, REG_DEAD, REGNO (operands[1])))
4192 return "fstp%z0\t%y0\n\tfld%z0\t%y0";
4193 else
4194 return "fstp%z0\t%y0";
4195
4196 default:
4197 abort ();
4198 }
4199 }
4200 [(set_attr "type" "fmov")
4201 (set_attr "mode" "DF,XF")])
4202
4203 (define_expand "extenddftf2"
4204 [(set (match_operand:TF 0 "nonimmediate_operand" "")
4205 (float_extend:TF (match_operand:DF 1 "nonimmediate_operand" "")))]
4206 "TARGET_80387"
4207 {
4208 if (GET_CODE (operands[0]) == MEM && GET_CODE (operands[1]) == MEM)
4209 operands[1] = force_reg (DFmode, operands[1]);
4210 })
4211
4212 (define_insn "*extenddftf2_1"
4213 [(set (match_operand:TF 0 "nonimmediate_operand" "=f,m")
4214 (float_extend:TF (match_operand:DF 1 "nonimmediate_operand" "fm,f")))]
4215 "TARGET_80387
4216 && (GET_CODE (operands[0]) != MEM || GET_CODE (operands[1]) != MEM)"
4217 {
4218 switch (which_alternative)
4219 {
4220 case 0:
4221 if (REG_P (operands[1])
4222 && find_regno_note (insn, REG_DEAD, REGNO (operands[1])))
4223 return "fstp\t%y0";
4224 else if (STACK_TOP_P (operands[0]))
4225 return "fld%z1\t%y1";
4226 else
4227 return "fst\t%y0";
4228
4229 case 1:
4230 /* There is no non-popping store to memory for XFmode. So if
4231 we need one, follow the store with a load. */
4232 if (! find_regno_note (insn, REG_DEAD, REGNO (operands[1])))
4233 return "fstp%z0\t%y0\n\tfld%z0\t%y0";
4234 else
4235 return "fstp%z0\t%y0";
4236
4237 default:
4238 abort ();
4239 }
4240 }
4241 [(set_attr "type" "fmov")
4242 (set_attr "mode" "DF,XF")])
4243
4244 ;; %%% This seems bad bad news.
4245 ;; This cannot output into an f-reg because there is no way to be sure
4246 ;; of truncating in that case. Otherwise this is just like a simple move
4247 ;; insn. So we pretend we can output to a reg in order to get better
4248 ;; register preferencing, but we really use a stack slot.
4249
4250 (define_expand "truncdfsf2"
4251 [(parallel [(set (match_operand:SF 0 "nonimmediate_operand" "")
4252 (float_truncate:SF
4253 (match_operand:DF 1 "register_operand" "")))
4254 (clobber (match_dup 2))])]
4255 "TARGET_80387 || TARGET_SSE2"
4256 "
4257 if (TARGET_80387)
4258 operands[2] = assign_386_stack_local (SFmode, 0);
4259 else
4260 {
4261 emit_insn (gen_truncdfsf2_sse_only (operands[0], operands[1]));
4262 DONE;
4263 }
4264 ")
4265
4266 (define_insn "*truncdfsf2_1"
4267 [(set (match_operand:SF 0 "nonimmediate_operand" "=m,?f#rx,?r#fx,?x#rf")
4268 (float_truncate:SF
4269 (match_operand:DF 1 "register_operand" "f,f,f,f")))
4270 (clobber (match_operand:SF 2 "memory_operand" "=X,m,m,m"))]
4271 "TARGET_80387 && !TARGET_SSE2"
4272 {
4273 switch (which_alternative)
4274 {
4275 case 0:
4276 if (find_regno_note (insn, REG_DEAD, REGNO (operands[1])))
4277 return "fstp%z0\t%y0";
4278 else
4279 return "fst%z0\t%y0";
4280 default:
4281 abort ();
4282 }
4283 }
4284 [(set_attr "type" "fmov,multi,multi,multi")
4285 (set_attr "mode" "SF,SF,SF,SF")])
4286
4287 (define_insn "*truncdfsf2_1_sse"
4288 [(set (match_operand:SF 0 "nonimmediate_operand" "=*!m,?f#rx,?r#fx,?x#rf,Y")
4289 (float_truncate:SF
4290 (match_operand:DF 1 "nonimmediate_operand" "f,f,f,f,mY")))
4291 (clobber (match_operand:SF 2 "memory_operand" "=X,m,m,m,X"))]
4292 "TARGET_80387 && TARGET_SSE2"
4293 {
4294 switch (which_alternative)
4295 {
4296 case 0:
4297 if (find_regno_note (insn, REG_DEAD, REGNO (operands[1])))
4298 return "fstp%z0\t%y0";
4299 else
4300 return "fst%z0\t%y0";
4301 case 4:
4302 return "cvtsd2ss\t{%1, %0|%0, %1}";
4303 default:
4304 abort ();
4305 }
4306 }
4307 [(set_attr "type" "fmov,multi,multi,multi,sse")
4308 (set_attr "mode" "SF,SF,SF,SF,DF")])
4309
4310 (define_insn "*truncdfsf2_2"
4311 [(set (match_operand:SF 0 "nonimmediate_operand" "=Y,!m")
4312 (float_truncate:SF
4313 (match_operand:DF 1 "nonimmediate_operand" "mY,f")))]
4314 "TARGET_80387 && TARGET_SSE2
4315 && (GET_CODE (operands[0]) != MEM || GET_CODE (operands[1]) != MEM)"
4316 {
4317 switch (which_alternative)
4318 {
4319 case 0:
4320 return "cvtsd2ss\t{%1, %0|%0, %1}";
4321 case 1:
4322 if (find_regno_note (insn, REG_DEAD, REGNO (operands[1])))
4323 return "fstp%z0\t%y0";
4324 else
4325 return "fst%z0\t%y0";
4326 default:
4327 abort ();
4328 }
4329 }
4330 [(set_attr "type" "sse,fmov")
4331 (set_attr "mode" "DF,SF")])
4332
4333 (define_insn "truncdfsf2_3"
4334 [(set (match_operand:SF 0 "memory_operand" "=m")
4335 (float_truncate:SF
4336 (match_operand:DF 1 "register_operand" "f")))]
4337 "TARGET_80387"
4338 {
4339 if (find_regno_note (insn, REG_DEAD, REGNO (operands[1])))
4340 return "fstp%z0\t%y0";
4341 else
4342 return "fst%z0\t%y0";
4343 }
4344 [(set_attr "type" "fmov")
4345 (set_attr "mode" "SF")])
4346
4347 (define_insn "truncdfsf2_sse_only"
4348 [(set (match_operand:SF 0 "register_operand" "=Y")
4349 (float_truncate:SF
4350 (match_operand:DF 1 "nonimmediate_operand" "mY")))]
4351 "!TARGET_80387 && TARGET_SSE2"
4352 "cvtsd2ss\t{%1, %0|%0, %1}"
4353 [(set_attr "type" "sse")
4354 (set_attr "mode" "DF")])
4355
4356 (define_split
4357 [(set (match_operand:SF 0 "memory_operand" "")
4358 (float_truncate:SF
4359 (match_operand:DF 1 "register_operand" "")))
4360 (clobber (match_operand:SF 2 "memory_operand" ""))]
4361 "TARGET_80387"
4362 [(set (match_dup 0) (float_truncate:SF (match_dup 1)))]
4363 "")
4364
4365 (define_split
4366 [(set (match_operand:SF 0 "nonimmediate_operand" "")
4367 (float_truncate:SF
4368 (match_operand:DF 1 "nonimmediate_operand" "")))
4369 (clobber (match_operand 2 "" ""))]
4370 "TARGET_80387 && reload_completed
4371 && !FP_REG_P (operands[0]) && !FP_REG_P (operands[1])"
4372 [(set (match_dup 0) (float_truncate:SF (match_dup 1)))]
4373 "")
4374
4375 (define_split
4376 [(set (match_operand:SF 0 "register_operand" "")
4377 (float_truncate:SF
4378 (match_operand:DF 1 "register_operand" "")))
4379 (clobber (match_operand:SF 2 "memory_operand" ""))]
4380 "TARGET_80387 && reload_completed
4381 && FP_REG_P (operands[1])"
4382 [(set (match_dup 2) (float_truncate:SF (match_dup 1)))
4383 (set (match_dup 0) (match_dup 2))]
4384 "")
4385
4386 (define_expand "truncxfsf2"
4387 [(parallel [(set (match_operand:SF 0 "nonimmediate_operand" "")
4388 (float_truncate:SF
4389 (match_operand:XF 1 "register_operand" "")))
4390 (clobber (match_dup 2))])]
4391 "!TARGET_64BIT && TARGET_80387"
4392 "operands[2] = assign_386_stack_local (SFmode, 0);")
4393
4394 (define_insn "*truncxfsf2_1"
4395 [(set (match_operand:SF 0 "nonimmediate_operand" "=m,?f#rx,?r#fx,?x#rf")
4396 (float_truncate:SF
4397 (match_operand:XF 1 "register_operand" "f,f,f,f")))
4398 (clobber (match_operand:SF 2 "memory_operand" "=X,m,m,m"))]
4399 "!TARGET_64BIT && TARGET_80387"
4400 {
4401 switch (which_alternative)
4402 {
4403 case 0:
4404 if (find_regno_note (insn, REG_DEAD, REGNO (operands[1])))
4405 return "fstp%z0\t%y0";
4406 else
4407 return "fst%z0\t%y0";
4408 default:
4409 abort();
4410 }
4411 }
4412 [(set_attr "type" "fmov,multi,multi,multi")
4413 (set_attr "mode" "SF")])
4414
4415 (define_insn "*truncxfsf2_2"
4416 [(set (match_operand:SF 0 "memory_operand" "=m")
4417 (float_truncate:SF
4418 (match_operand:XF 1 "register_operand" "f")))]
4419 "!TARGET_64BIT && TARGET_80387"
4420 {
4421 if (find_regno_note (insn, REG_DEAD, REGNO (operands[1])))
4422 return "fstp%z0\t%y0";
4423 else
4424 return "fst%z0\t%y0";
4425 }
4426 [(set_attr "type" "fmov")
4427 (set_attr "mode" "SF")])
4428
4429 (define_split
4430 [(set (match_operand:SF 0 "memory_operand" "")
4431 (float_truncate:SF
4432 (match_operand:XF 1 "register_operand" "")))
4433 (clobber (match_operand:SF 2 "memory_operand" ""))]
4434 "TARGET_80387"
4435 [(set (match_dup 0) (float_truncate:SF (match_dup 1)))]
4436 "")
4437
4438 (define_split
4439 [(set (match_operand:SF 0 "register_operand" "")
4440 (float_truncate:SF
4441 (match_operand:XF 1 "register_operand" "")))
4442 (clobber (match_operand:SF 2 "memory_operand" ""))]
4443 "TARGET_80387 && reload_completed"
4444 [(set (match_dup 2) (float_truncate:SF (match_dup 1)))
4445 (set (match_dup 0) (match_dup 2))]
4446 "")
4447
4448 (define_expand "trunctfsf2"
4449 [(parallel [(set (match_operand:SF 0 "nonimmediate_operand" "")
4450 (float_truncate:SF
4451 (match_operand:TF 1 "register_operand" "")))
4452 (clobber (match_dup 2))])]
4453 "TARGET_80387"
4454 "operands[2] = assign_386_stack_local (SFmode, 0);")
4455
4456 (define_insn "*trunctfsf2_1"
4457 [(set (match_operand:SF 0 "nonimmediate_operand" "=m,?f#rx,?r#fx,?x#rf")
4458 (float_truncate:SF
4459 (match_operand:TF 1 "register_operand" "f,f,f,f")))
4460 (clobber (match_operand:SF 2 "memory_operand" "=X,m,m,m"))]
4461 "TARGET_80387"
4462 {
4463 switch (which_alternative)
4464 {
4465 case 0:
4466 if (find_regno_note (insn, REG_DEAD, REGNO (operands[1])))
4467 return "fstp%z0\t%y0";
4468 else
4469 return "fst%z0\t%y0";
4470 default:
4471 abort();
4472 }
4473 }
4474 [(set_attr "type" "fmov,multi,multi,multi")
4475 (set_attr "mode" "SF")])
4476
4477 (define_insn "*trunctfsf2_2"
4478 [(set (match_operand:SF 0 "memory_operand" "=m")
4479 (float_truncate:SF
4480 (match_operand:TF 1 "register_operand" "f")))]
4481 "TARGET_80387"
4482 {
4483 if (find_regno_note (insn, REG_DEAD, REGNO (operands[1])))
4484 return "fstp%z0\t%y0";
4485 else
4486 return "fst%z0\t%y0";
4487 }
4488 [(set_attr "type" "fmov")
4489 (set_attr "mode" "SF")])
4490
4491 (define_split
4492 [(set (match_operand:SF 0 "memory_operand" "")
4493 (float_truncate:SF
4494 (match_operand:TF 1 "register_operand" "")))
4495 (clobber (match_operand:SF 2 "memory_operand" ""))]
4496 "TARGET_80387"
4497 [(set (match_dup 0) (float_truncate:SF (match_dup 1)))]
4498 "")
4499
4500 (define_split
4501 [(set (match_operand:SF 0 "register_operand" "")
4502 (float_truncate:SF
4503 (match_operand:TF 1 "register_operand" "")))
4504 (clobber (match_operand:SF 2 "memory_operand" ""))]
4505 "TARGET_80387 && reload_completed"
4506 [(set (match_dup 2) (float_truncate:SF (match_dup 1)))
4507 (set (match_dup 0) (match_dup 2))]
4508 "")
4509
4510
4511 (define_expand "truncxfdf2"
4512 [(parallel [(set (match_operand:DF 0 "nonimmediate_operand" "")
4513 (float_truncate:DF
4514 (match_operand:XF 1 "register_operand" "")))
4515 (clobber (match_dup 2))])]
4516 "!TARGET_64BIT && TARGET_80387"
4517 "operands[2] = assign_386_stack_local (DFmode, 0);")
4518
4519 (define_insn "*truncxfdf2_1"
4520 [(set (match_operand:DF 0 "nonimmediate_operand" "=m,?f#rY,?r#fY,?Y#rf")
4521 (float_truncate:DF
4522 (match_operand:XF 1 "register_operand" "f,f,f,f")))
4523 (clobber (match_operand:DF 2 "memory_operand" "=X,m,m,m"))]
4524 "!TARGET_64BIT && TARGET_80387"
4525 {
4526 switch (which_alternative)
4527 {
4528 case 0:
4529 if (find_regno_note (insn, REG_DEAD, REGNO (operands[1])))
4530 return "fstp%z0\t%y0";
4531 else
4532 return "fst%z0\t%y0";
4533 default:
4534 abort();
4535 }
4536 abort ();
4537 }
4538 [(set_attr "type" "fmov,multi,multi,multi")
4539 (set_attr "mode" "DF")])
4540
4541 (define_insn "*truncxfdf2_2"
4542 [(set (match_operand:DF 0 "memory_operand" "=m")
4543 (float_truncate:DF
4544 (match_operand:XF 1 "register_operand" "f")))]
4545 "!TARGET_64BIT && TARGET_80387"
4546 {
4547 if (find_regno_note (insn, REG_DEAD, REGNO (operands[1])))
4548 return "fstp%z0\t%y0";
4549 else
4550 return "fst%z0\t%y0";
4551 }
4552 [(set_attr "type" "fmov")
4553 (set_attr "mode" "DF")])
4554
4555 (define_split
4556 [(set (match_operand:DF 0 "memory_operand" "")
4557 (float_truncate:DF
4558 (match_operand:XF 1 "register_operand" "")))
4559 (clobber (match_operand:DF 2 "memory_operand" ""))]
4560 "TARGET_80387"
4561 [(set (match_dup 0) (float_truncate:DF (match_dup 1)))]
4562 "")
4563
4564 (define_split
4565 [(set (match_operand:DF 0 "register_operand" "")
4566 (float_truncate:DF
4567 (match_operand:XF 1 "register_operand" "")))
4568 (clobber (match_operand:DF 2 "memory_operand" ""))]
4569 "TARGET_80387 && reload_completed"
4570 [(set (match_dup 2) (float_truncate:DF (match_dup 1)))
4571 (set (match_dup 0) (match_dup 2))]
4572 "")
4573
4574 (define_expand "trunctfdf2"
4575 [(parallel [(set (match_operand:DF 0 "nonimmediate_operand" "")
4576 (float_truncate:DF
4577 (match_operand:TF 1 "register_operand" "")))
4578 (clobber (match_dup 2))])]
4579 "TARGET_80387"
4580 "operands[2] = assign_386_stack_local (DFmode, 0);")
4581
4582 (define_insn "*trunctfdf2_1"
4583 [(set (match_operand:DF 0 "nonimmediate_operand" "=m,?f#rY,?r#fY,?Y#rf")
4584 (float_truncate:DF
4585 (match_operand:TF 1 "register_operand" "f,f,f,f")))
4586 (clobber (match_operand:DF 2 "memory_operand" "=X,m,m,m"))]
4587 "TARGET_80387"
4588 {
4589 switch (which_alternative)
4590 {
4591 case 0:
4592 if (find_regno_note (insn, REG_DEAD, REGNO (operands[1])))
4593 return "fstp%z0\t%y0";
4594 else
4595 return "fst%z0\t%y0";
4596 default:
4597 abort();
4598 }
4599 abort ();
4600 }
4601 [(set_attr "type" "fmov,multi,multi,multi")
4602 (set_attr "mode" "DF")])
4603
4604 (define_insn "*trunctfdf2_2"
4605 [(set (match_operand:DF 0 "memory_operand" "=m")
4606 (float_truncate:DF
4607 (match_operand:TF 1 "register_operand" "f")))]
4608 "TARGET_80387"
4609 {
4610 if (find_regno_note (insn, REG_DEAD, REGNO (operands[1])))
4611 return "fstp%z0\t%y0";
4612 else
4613 return "fst%z0\t%y0";
4614 }
4615 [(set_attr "type" "fmov")
4616 (set_attr "mode" "DF")])
4617
4618 (define_split
4619 [(set (match_operand:DF 0 "memory_operand" "")
4620 (float_truncate:DF
4621 (match_operand:TF 1 "register_operand" "")))
4622 (clobber (match_operand:DF 2 "memory_operand" ""))]
4623 "TARGET_80387"
4624 [(set (match_dup 0) (float_truncate:DF (match_dup 1)))]
4625 "")
4626
4627 (define_split
4628 [(set (match_operand:DF 0 "register_operand" "")
4629 (float_truncate:DF
4630 (match_operand:TF 1 "register_operand" "")))
4631 (clobber (match_operand:DF 2 "memory_operand" ""))]
4632 "TARGET_80387 && reload_completed"
4633 [(set (match_dup 2) (float_truncate:DF (match_dup 1)))
4634 (set (match_dup 0) (match_dup 2))]
4635 "")
4636
4637 \f
4638 ;; %%% Break up all these bad boys.
4639
4640 ;; Signed conversion to DImode.
4641
4642 (define_expand "fix_truncxfdi2"
4643 [(set (match_operand:DI 0 "nonimmediate_operand" "")
4644 (fix:DI (match_operand:XF 1 "register_operand" "")))]
4645 "!TARGET_64BIT && TARGET_80387"
4646 "")
4647
4648 (define_expand "fix_trunctfdi2"
4649 [(set (match_operand:DI 0 "nonimmediate_operand" "")
4650 (fix:DI (match_operand:TF 1 "register_operand" "")))]
4651 "TARGET_80387"
4652 "")
4653
4654 (define_expand "fix_truncdfdi2"
4655 [(set (match_operand:DI 0 "nonimmediate_operand" "")
4656 (fix:DI (match_operand:DF 1 "register_operand" "")))]
4657 "TARGET_80387 || (TARGET_SSE2 && TARGET_64BIT)"
4658 {
4659 if (TARGET_64BIT && TARGET_SSE2)
4660 {
4661 rtx out = REG_P (operands[0]) ? operands[0] : gen_reg_rtx (DImode);
4662 emit_insn (gen_fix_truncdfdi_sse (out, operands[1]));
4663 if (out != operands[0])
4664 emit_move_insn (operands[0], out);
4665 DONE;
4666 }
4667 })
4668
4669 (define_expand "fix_truncsfdi2"
4670 [(set (match_operand:DI 0 "nonimmediate_operand" "")
4671 (fix:DI (match_operand:SF 1 "register_operand" "")))]
4672 "TARGET_80387 || (TARGET_SSE && TARGET_64BIT)"
4673 {
4674 if (TARGET_SSE && TARGET_64BIT)
4675 {
4676 rtx out = REG_P (operands[0]) ? operands[0] : gen_reg_rtx (DImode);
4677 emit_insn (gen_fix_truncsfdi_sse (out, operands[1]));
4678 if (out != operands[0])
4679 emit_move_insn (operands[0], out);
4680 DONE;
4681 }
4682 })
4683
4684 ;; See the comments in i386.h near OPTIMIZE_MODE_SWITCHING for the description
4685 ;; of the machinery.
4686 (define_insn_and_split "*fix_truncdi_1"
4687 [(set (match_operand:DI 0 "nonimmediate_operand" "=m,?r")
4688 (fix:DI (match_operand 1 "register_operand" "f,f")))]
4689 "TARGET_80387 && FLOAT_MODE_P (GET_MODE (operands[1]))
4690 && !reload_completed && !reload_in_progress
4691 && (!SSE_FLOAT_MODE_P (GET_MODE (operands[1])) || !TARGET_64BIT)"
4692 "#"
4693 "&& 1"
4694 [(const_int 0)]
4695 {
4696 operands[2] = assign_386_stack_local (HImode, 1);
4697 operands[3] = assign_386_stack_local (HImode, 2);
4698 if (memory_operand (operands[0], VOIDmode))
4699 emit_insn (gen_fix_truncdi_memory (operands[0], operands[1],
4700 operands[2], operands[3]));
4701 else
4702 {
4703 operands[4] = assign_386_stack_local (DImode, 0);
4704 emit_insn (gen_fix_truncdi_nomemory (operands[0], operands[1],
4705 operands[2], operands[3],
4706 operands[4]));
4707 }
4708 DONE;
4709 }
4710 [(set_attr "type" "fistp")])
4711
4712 (define_insn "fix_truncdi_nomemory"
4713 [(set (match_operand:DI 0 "nonimmediate_operand" "=m,?r")
4714 (fix:DI (match_operand 1 "register_operand" "f,f")))
4715 (use (match_operand:HI 2 "memory_operand" "m,m"))
4716 (use (match_operand:HI 3 "memory_operand" "m,m"))
4717 (clobber (match_operand:DI 4 "memory_operand" "=m,m"))
4718 (clobber (match_scratch:DF 5 "=&1f,&1f"))]
4719 "TARGET_80387 && FLOAT_MODE_P (GET_MODE (operands[1]))
4720 && (!SSE_FLOAT_MODE_P (GET_MODE (operands[1])) || !TARGET_64BIT)"
4721 "#"
4722 [(set_attr "type" "fistp")])
4723
4724 (define_insn "fix_truncdi_memory"
4725 [(set (match_operand:DI 0 "memory_operand" "=m")
4726 (fix:DI (match_operand 1 "register_operand" "f")))
4727 (use (match_operand:HI 2 "memory_operand" "m"))
4728 (use (match_operand:HI 3 "memory_operand" "m"))
4729 (clobber (match_scratch:DF 4 "=&1f"))]
4730 "TARGET_80387 && FLOAT_MODE_P (GET_MODE (operands[1]))
4731 && (!SSE_FLOAT_MODE_P (GET_MODE (operands[1])) || !TARGET_64BIT)"
4732 "* operands[5] = operands[4]; return output_fix_trunc (insn, operands);"
4733 [(set_attr "type" "fistp")])
4734
4735 (define_split
4736 [(set (match_operand:DI 0 "register_operand" "")
4737 (fix:DI (match_operand 1 "register_operand" "")))
4738 (use (match_operand:HI 2 "memory_operand" ""))
4739 (use (match_operand:HI 3 "memory_operand" ""))
4740 (clobber (match_operand:DI 4 "memory_operand" ""))
4741 (clobber (match_scratch 5 ""))]
4742 "reload_completed"
4743 [(parallel [(set (match_dup 4) (fix:DI (match_dup 1)))
4744 (use (match_dup 2))
4745 (use (match_dup 3))
4746 (clobber (match_dup 5))])
4747 (set (match_dup 0) (match_dup 4))]
4748 "")
4749
4750 (define_split
4751 [(set (match_operand:DI 0 "memory_operand" "")
4752 (fix:DI (match_operand 1 "register_operand" "")))
4753 (use (match_operand:HI 2 "memory_operand" ""))
4754 (use (match_operand:HI 3 "memory_operand" ""))
4755 (clobber (match_operand:DI 4 "memory_operand" ""))
4756 (clobber (match_scratch 5 ""))]
4757 "reload_completed"
4758 [(parallel [(set (match_dup 0) (fix:DI (match_dup 1)))
4759 (use (match_dup 2))
4760 (use (match_dup 3))
4761 (clobber (match_dup 5))])]
4762 "")
4763
4764 ;; When SSE available, it is always faster to use it!
4765 (define_insn "fix_truncsfdi_sse"
4766 [(set (match_operand:DI 0 "register_operand" "=r")
4767 (fix:DI (match_operand:SF 1 "nonimmediate_operand" "xm")))]
4768 "TARGET_64BIT && TARGET_SSE"
4769 "cvttss2si{q}\t{%1, %0|%0, %1}"
4770 [(set_attr "type" "sse")])
4771
4772 (define_insn "fix_truncdfdi_sse"
4773 [(set (match_operand:DI 0 "register_operand" "=r")
4774 (fix:DI (match_operand:DF 1 "nonimmediate_operand" "Ym")))]
4775 "TARGET_64BIT && TARGET_SSE2"
4776 "cvttsd2si{q}\t{%1, %0|%0, %1}"
4777 [(set_attr "type" "sse")])
4778
4779 ;; Signed conversion to SImode.
4780
4781 (define_expand "fix_truncxfsi2"
4782 [(set (match_operand:SI 0 "nonimmediate_operand" "")
4783 (fix:SI (match_operand:XF 1 "register_operand" "")))]
4784 "!TARGET_64BIT && TARGET_80387"
4785 "")
4786
4787 (define_expand "fix_trunctfsi2"
4788 [(set (match_operand:SI 0 "nonimmediate_operand" "")
4789 (fix:SI (match_operand:TF 1 "register_operand" "")))]
4790 "TARGET_80387"
4791 "")
4792
4793 (define_expand "fix_truncdfsi2"
4794 [(set (match_operand:SI 0 "nonimmediate_operand" "")
4795 (fix:SI (match_operand:DF 1 "register_operand" "")))]
4796 "TARGET_80387 || TARGET_SSE2"
4797 {
4798 if (TARGET_SSE2)
4799 {
4800 rtx out = REG_P (operands[0]) ? operands[0] : gen_reg_rtx (SImode);
4801 emit_insn (gen_fix_truncdfsi_sse (out, operands[1]));
4802 if (out != operands[0])
4803 emit_move_insn (operands[0], out);
4804 DONE;
4805 }
4806 })
4807
4808 (define_expand "fix_truncsfsi2"
4809 [(set (match_operand:SI 0 "nonimmediate_operand" "")
4810 (fix:SI (match_operand:SF 1 "register_operand" "")))]
4811 "TARGET_80387 || TARGET_SSE"
4812 {
4813 if (TARGET_SSE)
4814 {
4815 rtx out = REG_P (operands[0]) ? operands[0] : gen_reg_rtx (SImode);
4816 emit_insn (gen_fix_truncsfsi_sse (out, operands[1]));
4817 if (out != operands[0])
4818 emit_move_insn (operands[0], out);
4819 DONE;
4820 }
4821 })
4822
4823 ;; See the comments in i386.h near OPTIMIZE_MODE_SWITCHING for the description
4824 ;; of the machinery.
4825 (define_insn_and_split "*fix_truncsi_1"
4826 [(set (match_operand:SI 0 "nonimmediate_operand" "=m,?r")
4827 (fix:SI (match_operand 1 "register_operand" "f,f")))]
4828 "TARGET_80387 && FLOAT_MODE_P (GET_MODE (operands[1]))
4829 && !reload_completed && !reload_in_progress
4830 && !SSE_FLOAT_MODE_P (GET_MODE (operands[1]))"
4831 "#"
4832 "&& 1"
4833 [(const_int 0)]
4834 {
4835 operands[2] = assign_386_stack_local (HImode, 1);
4836 operands[3] = assign_386_stack_local (HImode, 2);
4837 if (memory_operand (operands[0], VOIDmode))
4838 emit_insn (gen_fix_truncsi_memory (operands[0], operands[1],
4839 operands[2], operands[3]));
4840 else
4841 {
4842 operands[4] = assign_386_stack_local (SImode, 0);
4843 emit_insn (gen_fix_truncsi_nomemory (operands[0], operands[1],
4844 operands[2], operands[3],
4845 operands[4]));
4846 }
4847 DONE;
4848 }
4849 [(set_attr "type" "fistp")])
4850
4851 (define_insn "fix_truncsi_nomemory"
4852 [(set (match_operand:SI 0 "nonimmediate_operand" "=m,?r")
4853 (fix:SI (match_operand 1 "register_operand" "f,f")))
4854 (use (match_operand:HI 2 "memory_operand" "m,m"))
4855 (use (match_operand:HI 3 "memory_operand" "m,m"))
4856 (clobber (match_operand:SI 4 "memory_operand" "=m,m"))]
4857 "TARGET_80387 && FLOAT_MODE_P (GET_MODE (operands[1]))
4858 && !SSE_FLOAT_MODE_P (GET_MODE (operands[1]))"
4859 "#"
4860 [(set_attr "type" "fistp")])
4861
4862 (define_insn "fix_truncsi_memory"
4863 [(set (match_operand:SI 0 "memory_operand" "=m")
4864 (fix:SI (match_operand 1 "register_operand" "f")))
4865 (use (match_operand:HI 2 "memory_operand" "m"))
4866 (use (match_operand:HI 3 "memory_operand" "m"))]
4867 "TARGET_80387 && FLOAT_MODE_P (GET_MODE (operands[1]))
4868 && !SSE_FLOAT_MODE_P (GET_MODE (operands[1]))"
4869 "* return output_fix_trunc (insn, operands);"
4870 [(set_attr "type" "fistp")])
4871
4872 ;; When SSE available, it is always faster to use it!
4873 (define_insn "fix_truncsfsi_sse"
4874 [(set (match_operand:SI 0 "register_operand" "=r")
4875 (fix:SI (match_operand:SF 1 "nonimmediate_operand" "xm")))]
4876 "TARGET_SSE"
4877 "cvttss2si\t{%1, %0|%0, %1}"
4878 [(set_attr "type" "sse")])
4879
4880 (define_insn "fix_truncdfsi_sse"
4881 [(set (match_operand:SI 0 "register_operand" "=r")
4882 (fix:SI (match_operand:DF 1 "nonimmediate_operand" "Ym")))]
4883 "TARGET_SSE2"
4884 "cvttsd2si\t{%1, %0|%0, %1}"
4885 [(set_attr "type" "sse")])
4886
4887 (define_split
4888 [(set (match_operand:SI 0 "register_operand" "")
4889 (fix:SI (match_operand 1 "register_operand" "")))
4890 (use (match_operand:HI 2 "memory_operand" ""))
4891 (use (match_operand:HI 3 "memory_operand" ""))
4892 (clobber (match_operand:SI 4 "memory_operand" ""))]
4893 "reload_completed"
4894 [(parallel [(set (match_dup 4) (fix:SI (match_dup 1)))
4895 (use (match_dup 2))
4896 (use (match_dup 3))])
4897 (set (match_dup 0) (match_dup 4))]
4898 "")
4899
4900 (define_split
4901 [(set (match_operand:SI 0 "memory_operand" "")
4902 (fix:SI (match_operand 1 "register_operand" "")))
4903 (use (match_operand:HI 2 "memory_operand" ""))
4904 (use (match_operand:HI 3 "memory_operand" ""))
4905 (clobber (match_operand:SI 4 "memory_operand" ""))]
4906 "reload_completed"
4907 [(parallel [(set (match_dup 0) (fix:SI (match_dup 1)))
4908 (use (match_dup 2))
4909 (use (match_dup 3))])]
4910 "")
4911
4912 ;; Signed conversion to HImode.
4913
4914 (define_expand "fix_truncxfhi2"
4915 [(set (match_operand:HI 0 "nonimmediate_operand" "")
4916 (fix:HI (match_operand:XF 1 "register_operand" "")))]
4917 "!TARGET_64BIT && TARGET_80387"
4918 "")
4919
4920 (define_expand "fix_trunctfhi2"
4921 [(set (match_operand:HI 0 "nonimmediate_operand" "")
4922 (fix:HI (match_operand:TF 1 "register_operand" "")))]
4923 "TARGET_80387"
4924 "")
4925
4926 (define_expand "fix_truncdfhi2"
4927 [(set (match_operand:HI 0 "nonimmediate_operand" "")
4928 (fix:HI (match_operand:DF 1 "register_operand" "")))]
4929 "TARGET_80387 && !TARGET_SSE2"
4930 "")
4931
4932 (define_expand "fix_truncsfhi2"
4933 [(set (match_operand:HI 0 "nonimmediate_operand" "")
4934 (fix:HI (match_operand:SF 1 "register_operand" "")))]
4935 "TARGET_80387 && !TARGET_SSE"
4936 "")
4937
4938 ;; See the comments in i386.h near OPTIMIZE_MODE_SWITCHING for the description
4939 ;; of the machinery.
4940 (define_insn_and_split "*fix_trunchi_1"
4941 [(set (match_operand:HI 0 "nonimmediate_operand" "=m,?r")
4942 (fix:HI (match_operand 1 "register_operand" "f,f")))]
4943 "TARGET_80387 && FLOAT_MODE_P (GET_MODE (operands[1]))
4944 && !reload_completed && !reload_in_progress
4945 && !SSE_FLOAT_MODE_P (GET_MODE (operands[1]))"
4946 "#"
4947 ""
4948 [(const_int 0)]
4949 {
4950 operands[2] = assign_386_stack_local (HImode, 1);
4951 operands[3] = assign_386_stack_local (HImode, 2);
4952 if (memory_operand (operands[0], VOIDmode))
4953 emit_insn (gen_fix_trunchi_memory (operands[0], operands[1],
4954 operands[2], operands[3]));
4955 else
4956 {
4957 operands[4] = assign_386_stack_local (HImode, 0);
4958 emit_insn (gen_fix_trunchi_nomemory (operands[0], operands[1],
4959 operands[2], operands[3],
4960 operands[4]));
4961 }
4962 DONE;
4963 }
4964 [(set_attr "type" "fistp")])
4965
4966 (define_insn "fix_trunchi_nomemory"
4967 [(set (match_operand:HI 0 "nonimmediate_operand" "=m,?r")
4968 (fix:HI (match_operand 1 "register_operand" "f,f")))
4969 (use (match_operand:HI 2 "memory_operand" "m,m"))
4970 (use (match_operand:HI 3 "memory_operand" "m,m"))
4971 (clobber (match_operand:HI 4 "memory_operand" "=m,m"))]
4972 "TARGET_80387 && FLOAT_MODE_P (GET_MODE (operands[1]))
4973 && !SSE_FLOAT_MODE_P (GET_MODE (operands[1]))"
4974 "#"
4975 [(set_attr "type" "fistp")])
4976
4977 (define_insn "fix_trunchi_memory"
4978 [(set (match_operand:HI 0 "memory_operand" "=m")
4979 (fix:HI (match_operand 1 "register_operand" "f")))
4980 (use (match_operand:HI 2 "memory_operand" "m"))
4981 (use (match_operand:HI 3 "memory_operand" "m"))]
4982 "TARGET_80387 && FLOAT_MODE_P (GET_MODE (operands[1]))
4983 && !SSE_FLOAT_MODE_P (GET_MODE (operands[1]))"
4984 "* return output_fix_trunc (insn, operands);"
4985 [(set_attr "type" "fistp")])
4986
4987 (define_split
4988 [(set (match_operand:HI 0 "memory_operand" "")
4989 (fix:HI (match_operand 1 "register_operand" "")))
4990 (use (match_operand:HI 2 "memory_operand" ""))
4991 (use (match_operand:HI 3 "memory_operand" ""))
4992 (clobber (match_operand:HI 4 "memory_operand" ""))]
4993 "reload_completed"
4994 [(parallel [(set (match_dup 0) (fix:HI (match_dup 1)))
4995 (use (match_dup 2))
4996 (use (match_dup 3))])]
4997 "")
4998
4999 (define_split
5000 [(set (match_operand:HI 0 "register_operand" "")
5001 (fix:HI (match_operand 1 "register_operand" "")))
5002 (use (match_operand:HI 2 "memory_operand" ""))
5003 (use (match_operand:HI 3 "memory_operand" ""))
5004 (clobber (match_operand:HI 4 "memory_operand" ""))]
5005 "reload_completed"
5006 [(parallel [(set (match_dup 4) (fix:HI (match_dup 1)))
5007 (use (match_dup 2))
5008 (use (match_dup 3))
5009 (clobber (match_dup 4))])
5010 (set (match_dup 0) (match_dup 4))]
5011 "")
5012
5013 ;; %% Not used yet.
5014 (define_insn "x86_fnstcw_1"
5015 [(set (match_operand:HI 0 "memory_operand" "=m")
5016 (unspec:HI [(reg:HI 18)] 11))]
5017 "TARGET_80387"
5018 "fnstcw\t%0"
5019 [(set_attr "length" "2")
5020 (set_attr "mode" "HI")
5021 (set_attr "i387" "1")
5022 (set_attr "ppro_uops" "few")])
5023
5024 (define_insn "x86_fldcw_1"
5025 [(set (reg:HI 18)
5026 (unspec:HI [(match_operand:HI 0 "memory_operand" "m")] 12))]
5027 "TARGET_80387"
5028 "fldcw\t%0"
5029 [(set_attr "length" "2")
5030 (set_attr "mode" "HI")
5031 (set_attr "i387" "1")
5032 (set_attr "athlon_decode" "vector")
5033 (set_attr "ppro_uops" "few")])
5034 \f
5035 ;; Conversion between fixed point and floating point.
5036
5037 ;; Even though we only accept memory inputs, the backend _really_
5038 ;; wants to be able to do this between registers.
5039
5040 (define_insn "floathisf2"
5041 [(set (match_operand:SF 0 "register_operand" "=f,f")
5042 (float:SF (match_operand:HI 1 "nonimmediate_operand" "m,r")))]
5043 "TARGET_80387 && !TARGET_SSE"
5044 "@
5045 fild%z1\t%1
5046 #"
5047 [(set_attr "type" "fmov,multi")
5048 (set_attr "mode" "SF")
5049 (set_attr "fp_int_src" "true")])
5050
5051 (define_expand "floatsisf2"
5052 [(set (match_operand:SF 0 "register_operand" "")
5053 (float:SF (match_operand:SI 1 "nonimmediate_operand" "")))]
5054 "TARGET_SSE || TARGET_80387"
5055 "")
5056
5057 (define_insn "*floatsisf2_i387"
5058 [(set (match_operand:SF 0 "register_operand" "=f,?f,x")
5059 (float:SF (match_operand:SI 1 "nonimmediate_operand" "m,r,mr")))]
5060 "TARGET_80387 && (!TARGET_SSE || TARGET_MIX_SSE_I387)"
5061 "@
5062 fild%z1\t%1
5063 #
5064 cvtsi2ss\t{%1, %0|%0, %1}"
5065 [(set_attr "type" "fmov,multi,sse")
5066 (set_attr "mode" "SF")
5067 (set_attr "fp_int_src" "true")])
5068
5069 (define_insn "*floatsisf2_sse"
5070 [(set (match_operand:SF 0 "register_operand" "=x")
5071 (float:SF (match_operand:SI 1 "nonimmediate_operand" "mr")))]
5072 "TARGET_SSE"
5073 "cvtsi2ss\t{%1, %0|%0, %1}"
5074 [(set_attr "type" "sse")
5075 (set_attr "mode" "SF")
5076 (set_attr "fp_int_src" "true")])
5077
5078 (define_expand "floatdisf2"
5079 [(set (match_operand:SF 0 "register_operand" "")
5080 (float:SF (match_operand:DI 1 "nonimmediate_operand" "")))]
5081 "(TARGET_64BIT && TARGET_SSE) || TARGET_80387"
5082 "")
5083
5084 (define_insn "*floatdisf2_i387_only"
5085 [(set (match_operand:SF 0 "register_operand" "=f,?f")
5086 (float:SF (match_operand:DI 1 "nonimmediate_operand" "m,r")))]
5087 "TARGET_80387 && (!TARGET_SSE || !TARGET_64BIT || TARGET_MIX_SSE_I387)"
5088 "@
5089 fild%z1\t%1
5090 #"
5091 [(set_attr "type" "fmov,multi")
5092 (set_attr "mode" "SF")
5093 (set_attr "fp_int_src" "true")])
5094
5095 (define_insn "*floatdisf2_i387"
5096 [(set (match_operand:SF 0 "register_operand" "=f,?f,x")
5097 (float:SF (match_operand:DI 1 "nonimmediate_operand" "m,r,mr")))]
5098 "TARGET_64BIT && TARGET_80387 && (!TARGET_SSE || TARGET_MIX_SSE_I387)"
5099 "@
5100 fild%z1\t%1
5101 #
5102 cvtsi2ss{q}\t{%1, %0|%0, %1}"
5103 [(set_attr "type" "fmov,multi,sse")
5104 (set_attr "mode" "SF")
5105 (set_attr "fp_int_src" "true")])
5106
5107 (define_insn "*floatdisf2_sse"
5108 [(set (match_operand:SF 0 "register_operand" "=x")
5109 (float:SF (match_operand:DI 1 "nonimmediate_operand" "mr")))]
5110 "TARGET_64BIT && TARGET_SSE"
5111 "cvtsi2ss{q}\t{%1, %0|%0, %1}"
5112 [(set_attr "type" "sse")
5113 (set_attr "mode" "SF")
5114 (set_attr "fp_int_src" "true")])
5115
5116 (define_insn "floathidf2"
5117 [(set (match_operand:DF 0 "register_operand" "=f,f")
5118 (float:DF (match_operand:HI 1 "nonimmediate_operand" "m,r")))]
5119 "TARGET_80387 && !TARGET_SSE2"
5120 "@
5121 fild%z1\t%1
5122 #"
5123 [(set_attr "type" "fmov,multi")
5124 (set_attr "mode" "DF")
5125 (set_attr "fp_int_src" "true")])
5126
5127 (define_expand "floatsidf2"
5128 [(set (match_operand:DF 0 "register_operand" "")
5129 (float:DF (match_operand:SI 1 "nonimmediate_operand" "")))]
5130 ""
5131 "")
5132
5133 (define_insn "*floatsidf2_i387"
5134 [(set (match_operand:DF 0 "register_operand" "=f,?f,Y")
5135 (float:DF (match_operand:SI 1 "nonimmediate_operand" "m,r,mr")))]
5136 "TARGET_80387 && (!TARGET_SSE2 || TARGET_MIX_SSE_I387)"
5137 "@
5138 fild%z1\t%1
5139 #
5140 cvtsi2sd\t{%1, %0|%0, %1}"
5141 [(set_attr "type" "fmov,multi,sse")
5142 (set_attr "mode" "DF")
5143 (set_attr "fp_int_src" "true")])
5144
5145 (define_insn "*floatsidf2_sse"
5146 [(set (match_operand:DF 0 "register_operand" "=Y")
5147 (float:DF (match_operand:SI 1 "nonimmediate_operand" "mr")))]
5148 "TARGET_SSE2"
5149 "cvtsi2sd\t{%1, %0|%0, %1}"
5150 [(set_attr "type" "sse")
5151 (set_attr "mode" "DF")
5152 (set_attr "fp_int_src" "true")])
5153
5154 (define_expand "floatdidf2"
5155 [(set (match_operand:DF 0 "register_operand" "")
5156 (float:DF (match_operand:DI 1 "nonimmediate_operand" "")))]
5157 "(TARGET_64BIT && TARGET_SSE2) || TARGET_80387"
5158 "")
5159
5160 (define_insn "*floatdidf2_i387_only"
5161 [(set (match_operand:DF 0 "register_operand" "=f,?f")
5162 (float:DF (match_operand:DI 1 "nonimmediate_operand" "m,r")))]
5163 "TARGET_80387 && (!TARGET_SSE2 || !TARGET_64BIT)"
5164 "@
5165 fild%z1\t%1
5166 #"
5167 [(set_attr "type" "fmov,multi")
5168 (set_attr "mode" "DF")
5169 (set_attr "fp_int_src" "true")])
5170
5171 (define_insn "*floatdidf2_i387"
5172 [(set (match_operand:DF 0 "register_operand" "=f,?f,Y")
5173 (float:DF (match_operand:DI 1 "nonimmediate_operand" "m,r,mr")))]
5174 "TARGET_64BIT && TARGET_80387 && (!TARGET_SSE2 || TARGET_MIX_SSE_I387)"
5175 "@
5176 fild%z1\t%1
5177 #
5178 cvtsi2sd{q}\t{%1, %0|%0, %1}"
5179 [(set_attr "type" "fmov,multi,sse")
5180 (set_attr "mode" "DF")
5181 (set_attr "fp_int_src" "true")])
5182
5183 (define_insn "*floatdidf2_sse"
5184 [(set (match_operand:DF 0 "register_operand" "=Y")
5185 (float:DF (match_operand:DI 1 "nonimmediate_operand" "mr")))]
5186 "TARGET_SSE2"
5187 "cvtsi2sd{q}\t{%1, %0|%0, %1}"
5188 [(set_attr "type" "sse")
5189 (set_attr "mode" "DF")
5190 (set_attr "fp_int_src" "true")])
5191
5192 (define_insn "floathixf2"
5193 [(set (match_operand:XF 0 "register_operand" "=f,f")
5194 (float:XF (match_operand:HI 1 "nonimmediate_operand" "m,r")))]
5195 "!TARGET_64BIT && TARGET_80387"
5196 "@
5197 fild%z1\t%1
5198 #"
5199 [(set_attr "type" "fmov,multi")
5200 (set_attr "mode" "XF")
5201 (set_attr "fp_int_src" "true")])
5202
5203 (define_insn "floathitf2"
5204 [(set (match_operand:TF 0 "register_operand" "=f,f")
5205 (float:TF (match_operand:HI 1 "nonimmediate_operand" "m,r")))]
5206 "TARGET_80387"
5207 "@
5208 fild%z1\t%1
5209 #"
5210 [(set_attr "type" "fmov,multi")
5211 (set_attr "mode" "XF")
5212 (set_attr "fp_int_src" "true")])
5213
5214 (define_insn "floatsixf2"
5215 [(set (match_operand:XF 0 "register_operand" "=f,f")
5216 (float:XF (match_operand:SI 1 "nonimmediate_operand" "m,r")))]
5217 "!TARGET_64BIT && TARGET_80387"
5218 "@
5219 fild%z1\t%1
5220 #"
5221 [(set_attr "type" "fmov,multi")
5222 (set_attr "mode" "XF")
5223 (set_attr "fp_int_src" "true")])
5224
5225 (define_insn "floatsitf2"
5226 [(set (match_operand:TF 0 "register_operand" "=f,f")
5227 (float:TF (match_operand:SI 1 "nonimmediate_operand" "m,r")))]
5228 "TARGET_80387"
5229 "@
5230 fild%z1\t%1
5231 #"
5232 [(set_attr "type" "fmov,multi")
5233 (set_attr "mode" "XF")
5234 (set_attr "fp_int_src" "true")])
5235
5236 (define_insn "floatdixf2"
5237 [(set (match_operand:XF 0 "register_operand" "=f,f")
5238 (float:XF (match_operand:DI 1 "nonimmediate_operand" "m,r")))]
5239 "!TARGET_64BIT && TARGET_80387"
5240 "@
5241 fild%z1\t%1
5242 #"
5243 [(set_attr "type" "fmov,multi")
5244 (set_attr "mode" "XF")
5245 (set_attr "fp_int_src" "true")])
5246
5247 (define_insn "floatditf2"
5248 [(set (match_operand:TF 0 "register_operand" "=f,f")
5249 (float:TF (match_operand:DI 1 "nonimmediate_operand" "m,r")))]
5250 "TARGET_80387"
5251 "@
5252 fild%z1\t%1
5253 #"
5254 [(set_attr "type" "fmov,multi")
5255 (set_attr "mode" "XF")
5256 (set_attr "fp_int_src" "true")])
5257
5258 ;; %%% Kill these when reload knows how to do it.
5259 (define_split
5260 [(set (match_operand 0 "register_operand" "")
5261 (float (match_operand 1 "register_operand" "")))]
5262 "reload_completed && FLOAT_MODE_P (GET_MODE (operands[0]))
5263 && FP_REG_P (operands[0])"
5264 [(const_int 0)]
5265 {
5266 operands[2] = ix86_force_to_memory (GET_MODE (operands[1]), operands[1]);
5267 operands[2] = gen_rtx_FLOAT (GET_MODE (operands[0]), operands[2]);
5268 emit_insn (gen_rtx_SET (VOIDmode, operands[0], operands[2]));
5269 ix86_free_from_memory (GET_MODE (operands[1]));
5270 DONE;
5271 })
5272 \f
5273 ;; Add instructions
5274
5275 ;; %%% splits for addsidi3
5276 ; [(set (match_operand:DI 0 "nonimmediate_operand" "")
5277 ; (plus:DI (match_operand:DI 1 "general_operand" "")
5278 ; (zero_extend:DI (match_operand:SI 2 "general_operand" ""))))]
5279
5280 (define_expand "adddi3"
5281 [(set (match_operand:DI 0 "nonimmediate_operand" "")
5282 (plus:DI (match_operand:DI 1 "nonimmediate_operand" "")
5283 (match_operand:DI 2 "x86_64_general_operand" "")))
5284 (clobber (reg:CC 17))]
5285 ""
5286 "ix86_expand_binary_operator (PLUS, DImode, operands); DONE;")
5287
5288 (define_insn "*adddi3_1"
5289 [(set (match_operand:DI 0 "nonimmediate_operand" "=r,o")
5290 (plus:DI (match_operand:DI 1 "nonimmediate_operand" "%0,0")
5291 (match_operand:DI 2 "general_operand" "roiF,riF")))
5292 (clobber (reg:CC 17))]
5293 "!TARGET_64BIT"
5294 "#")
5295
5296 (define_split
5297 [(set (match_operand:DI 0 "nonimmediate_operand" "")
5298 (plus:DI (match_operand:DI 1 "nonimmediate_operand" "")
5299 (match_operand:DI 2 "general_operand" "")))
5300 (clobber (reg:CC 17))]
5301 "!TARGET_64BIT && reload_completed"
5302 [(parallel [(set (reg:CC 17) (unspec:CC [(match_dup 1) (match_dup 2)] 12))
5303 (set (match_dup 0) (plus:SI (match_dup 1) (match_dup 2)))])
5304 (parallel [(set (match_dup 3)
5305 (plus:SI (plus:SI (ltu:SI (reg:CC 17) (const_int 0))
5306 (match_dup 4))
5307 (match_dup 5)))
5308 (clobber (reg:CC 17))])]
5309 "split_di (operands+0, 1, operands+0, operands+3);
5310 split_di (operands+1, 1, operands+1, operands+4);
5311 split_di (operands+2, 1, operands+2, operands+5);")
5312
5313 (define_insn "*adddi3_carry_rex64"
5314 [(set (match_operand:DI 0 "nonimmediate_operand" "=rm,r")
5315 (plus:DI (plus:DI (ltu:DI (reg:CC 17) (const_int 0))
5316 (match_operand:DI 1 "nonimmediate_operand" "%0,0"))
5317 (match_operand:DI 2 "x86_64_general_operand" "re,rm")))
5318 (clobber (reg:CC 17))]
5319 "TARGET_64BIT && ix86_binary_operator_ok (PLUS, DImode, operands)"
5320 "adc{q}\t{%2, %0|%0, %2}"
5321 [(set_attr "type" "alu")
5322 (set_attr "pent_pair" "pu")
5323 (set_attr "mode" "DI")
5324 (set_attr "ppro_uops" "few")])
5325
5326 (define_insn "*adddi3_cc_rex64"
5327 [(set (reg:CC 17) (unspec:CC [(match_operand:DI 1 "nonimmediate_operand" "%0,0")
5328 (match_operand:DI 2 "x86_64_general_operand" "re,rm")] 12))
5329 (set (match_operand:DI 0 "nonimmediate_operand" "=rm,r")
5330 (plus:DI (match_dup 1) (match_dup 2)))]
5331 "TARGET_64BIT && ix86_binary_operator_ok (PLUS, DImode, operands)"
5332 "add{q}\t{%2, %0|%0, %2}"
5333 [(set_attr "type" "alu")
5334 (set_attr "mode" "DI")])
5335
5336 (define_insn "*addsi3_carry"
5337 [(set (match_operand:SI 0 "nonimmediate_operand" "=rm,r")
5338 (plus:SI (plus:SI (ltu:SI (reg:CC 17) (const_int 0))
5339 (match_operand:SI 1 "nonimmediate_operand" "%0,0"))
5340 (match_operand:SI 2 "general_operand" "ri,rm")))
5341 (clobber (reg:CC 17))]
5342 "ix86_binary_operator_ok (PLUS, SImode, operands)"
5343 "adc{l}\t{%2, %0|%0, %2}"
5344 [(set_attr "type" "alu")
5345 (set_attr "pent_pair" "pu")
5346 (set_attr "mode" "SI")
5347 (set_attr "ppro_uops" "few")])
5348
5349 (define_insn "*addsi3_carry_zext"
5350 [(set (match_operand:DI 0 "register_operand" "=r")
5351 (zero_extend:DI
5352 (plus:SI (plus:SI (ltu:SI (reg:CC 17) (const_int 0))
5353 (match_operand:SI 1 "nonimmediate_operand" "%0"))
5354 (match_operand:SI 2 "general_operand" "rim"))))
5355 (clobber (reg:CC 17))]
5356 "TARGET_64BIT && ix86_binary_operator_ok (PLUS, SImode, operands)"
5357 "adc{l}\t{%2, %k0|%k0, %2}"
5358 [(set_attr "type" "alu")
5359 (set_attr "pent_pair" "pu")
5360 (set_attr "mode" "SI")
5361 (set_attr "ppro_uops" "few")])
5362
5363 (define_insn "*addsi3_cc"
5364 [(set (reg:CC 17) (unspec:CC [(match_operand:SI 1 "nonimmediate_operand" "%0,0")
5365 (match_operand:SI 2 "general_operand" "ri,rm")] 12))
5366 (set (match_operand:SI 0 "nonimmediate_operand" "=rm,r")
5367 (plus:SI (match_dup 1) (match_dup 2)))]
5368 "ix86_binary_operator_ok (PLUS, SImode, operands)"
5369 "add{l}\t{%2, %0|%0, %2}"
5370 [(set_attr "type" "alu")
5371 (set_attr "mode" "SI")])
5372
5373 (define_insn "addqi3_cc"
5374 [(set (reg:CC 17) (unspec:CC [(match_operand:QI 1 "nonimmediate_operand" "%0,0")
5375 (match_operand:QI 2 "general_operand" "qi,qm")] 12))
5376 (set (match_operand:QI 0 "nonimmediate_operand" "=qm,q")
5377 (plus:QI (match_dup 1) (match_dup 2)))]
5378 "ix86_binary_operator_ok (PLUS, QImode, operands)"
5379 "add{b}\t{%2, %0|%0, %2}"
5380 [(set_attr "type" "alu")
5381 (set_attr "mode" "QI")])
5382
5383 (define_expand "addsi3"
5384 [(parallel [(set (match_operand:SI 0 "nonimmediate_operand" "")
5385 (plus:SI (match_operand:SI 1 "nonimmediate_operand" "")
5386 (match_operand:SI 2 "general_operand" "")))
5387 (clobber (reg:CC 17))])]
5388 ""
5389 "ix86_expand_binary_operator (PLUS, SImode, operands); DONE;")
5390
5391 (define_insn "*lea_1"
5392 [(set (match_operand:SI 0 "register_operand" "=r")
5393 (match_operand:SI 1 "address_operand" "p"))]
5394 "!TARGET_64BIT"
5395 "lea{l}\t{%a1, %0|%0, %a1}"
5396 [(set_attr "type" "lea")
5397 (set_attr "mode" "SI")])
5398
5399 (define_insn "*lea_1_rex64"
5400 [(set (match_operand:SI 0 "register_operand" "=r")
5401 (subreg:SI (match_operand:DI 1 "address_operand" "p") 0))]
5402 "TARGET_64BIT"
5403 "lea{l}\t{%a1, %0|%0, %a1}"
5404 [(set_attr "type" "lea")
5405 (set_attr "mode" "SI")])
5406
5407 (define_insn "*lea_1_zext"
5408 [(set (match_operand:DI 0 "register_operand" "=r")
5409 (zero_extend:DI (subreg:SI (match_operand:DI 1 "address_operand" "p") 0)))]
5410 "TARGET_64BIT"
5411 "lea{l}\t{%a1, %k0|%k0, %a1}"
5412 [(set_attr "type" "lea")
5413 (set_attr "mode" "SI")])
5414
5415 (define_insn "*lea_2_rex64"
5416 [(set (match_operand:DI 0 "register_operand" "=r")
5417 (match_operand:DI 1 "address_operand" "p"))]
5418 "TARGET_64BIT"
5419 "lea{q}\t{%a1, %0|%0, %a1}"
5420 [(set_attr "type" "lea")
5421 (set_attr "mode" "DI")])
5422
5423 ;; The lea patterns for non-Pmodes needs to be matched by several
5424 ;; insns converted to real lea by splitters.
5425
5426 (define_insn_and_split "*lea_general_1"
5427 [(set (match_operand 0 "register_operand" "=r")
5428 (plus (plus (match_operand 1 "register_operand" "r")
5429 (match_operand 2 "register_operand" "r"))
5430 (match_operand 3 "immediate_operand" "i")))]
5431 "(GET_MODE (operands[0]) == QImode || GET_MODE (operands[0]) == HImode
5432 || (TARGET_64BIT && GET_MODE (operands[0]) == SImode))
5433 && (!TARGET_PARTIAL_REG_STALL || optimize_size)
5434 && GET_MODE (operands[0]) == GET_MODE (operands[1])
5435 && GET_MODE (operands[0]) == GET_MODE (operands[2])
5436 && (GET_MODE (operands[0]) == GET_MODE (operands[3])
5437 || GET_MODE (operands[3]) == VOIDmode)"
5438 "#"
5439 "&& reload_completed"
5440 [(const_int 0)]
5441 {
5442 rtx pat;
5443 operands[0] = gen_lowpart (SImode, operands[0]);
5444 operands[1] = gen_lowpart (Pmode, operands[1]);
5445 operands[2] = gen_lowpart (Pmode, operands[2]);
5446 operands[3] = gen_lowpart (Pmode, operands[3]);
5447 pat = gen_rtx_PLUS (Pmode, gen_rtx_PLUS (Pmode, operands[1], operands[2]),
5448 operands[3]);
5449 if (Pmode != SImode)
5450 pat = gen_rtx_SUBREG (SImode, pat, 0);
5451 emit_insn (gen_rtx_SET (VOIDmode, operands[0], pat));
5452 DONE;
5453 }
5454 [(set_attr "type" "lea")
5455 (set_attr "mode" "SI")])
5456
5457 (define_insn_and_split "*lea_general_1_zext"
5458 [(set (match_operand:DI 0 "register_operand" "=r")
5459 (zero_extend:DI
5460 (plus:SI (plus:SI (match_operand:SI 1 "register_operand" "r")
5461 (match_operand:SI 2 "register_operand" "r"))
5462 (match_operand:SI 3 "immediate_operand" "i"))))]
5463 "TARGET_64BIT"
5464 "#"
5465 "&& reload_completed"
5466 [(set (match_dup 0)
5467 (zero_extend:DI (subreg:SI (plus:DI (plus:DI (match_dup 1)
5468 (match_dup 2))
5469 (match_dup 3)) 0)))]
5470 {
5471 operands[1] = gen_lowpart (Pmode, operands[1]);
5472 operands[2] = gen_lowpart (Pmode, operands[2]);
5473 operands[3] = gen_lowpart (Pmode, operands[3]);
5474 }
5475 [(set_attr "type" "lea")
5476 (set_attr "mode" "SI")])
5477
5478 (define_insn_and_split "*lea_general_2"
5479 [(set (match_operand 0 "register_operand" "=r")
5480 (plus (mult (match_operand 1 "register_operand" "r")
5481 (match_operand 2 "const248_operand" "i"))
5482 (match_operand 3 "nonmemory_operand" "ri")))]
5483 "(GET_MODE (operands[0]) == QImode || GET_MODE (operands[0]) == HImode
5484 || (TARGET_64BIT && GET_MODE (operands[0]) == SImode))
5485 && (!TARGET_PARTIAL_REG_STALL || optimize_size)
5486 && GET_MODE (operands[0]) == GET_MODE (operands[1])
5487 && (GET_MODE (operands[0]) == GET_MODE (operands[3])
5488 || GET_MODE (operands[3]) == VOIDmode)"
5489 "#"
5490 "&& reload_completed"
5491 [(const_int 0)]
5492 {
5493 rtx pat;
5494 operands[0] = gen_lowpart (SImode, operands[0]);
5495 operands[1] = gen_lowpart (Pmode, operands[1]);
5496 operands[3] = gen_lowpart (Pmode, operands[3]);
5497 pat = gen_rtx_PLUS (Pmode, gen_rtx_MULT (Pmode, operands[1], operands[2]),
5498 operands[3]);
5499 if (Pmode != SImode)
5500 pat = gen_rtx_SUBREG (SImode, pat, 0);
5501 emit_insn (gen_rtx_SET (VOIDmode, operands[0], pat));
5502 DONE;
5503 }
5504 [(set_attr "type" "lea")
5505 (set_attr "mode" "SI")])
5506
5507 (define_insn_and_split "*lea_general_2_zext"
5508 [(set (match_operand:DI 0 "register_operand" "=r")
5509 (zero_extend:DI
5510 (plus:SI (mult:SI (match_operand:SI 1 "register_operand" "r")
5511 (match_operand:SI 2 "const248_operand" "n"))
5512 (match_operand:SI 3 "nonmemory_operand" "ri"))))]
5513 "TARGET_64BIT"
5514 "#"
5515 "&& reload_completed"
5516 [(set (match_dup 0)
5517 (zero_extend:DI (subreg:SI (plus:DI (mult:DI (match_dup 1)
5518 (match_dup 2))
5519 (match_dup 3)) 0)))]
5520 {
5521 operands[1] = gen_lowpart (Pmode, operands[1]);
5522 operands[3] = gen_lowpart (Pmode, operands[3]);
5523 }
5524 [(set_attr "type" "lea")
5525 (set_attr "mode" "SI")])
5526
5527 (define_insn_and_split "*lea_general_3"
5528 [(set (match_operand 0 "register_operand" "=r")
5529 (plus (plus (mult (match_operand 1 "register_operand" "r")
5530 (match_operand 2 "const248_operand" "i"))
5531 (match_operand 3 "register_operand" "r"))
5532 (match_operand 4 "immediate_operand" "i")))]
5533 "(GET_MODE (operands[0]) == QImode || GET_MODE (operands[0]) == HImode
5534 || (TARGET_64BIT && GET_MODE (operands[0]) == SImode))
5535 && (!TARGET_PARTIAL_REG_STALL || optimize_size)
5536 && GET_MODE (operands[0]) == GET_MODE (operands[1])
5537 && GET_MODE (operands[0]) == GET_MODE (operands[3])"
5538 "#"
5539 "&& reload_completed"
5540 [(const_int 0)]
5541 {
5542 rtx pat;
5543 operands[0] = gen_lowpart (SImode, operands[0]);
5544 operands[1] = gen_lowpart (Pmode, operands[1]);
5545 operands[3] = gen_lowpart (Pmode, operands[3]);
5546 operands[4] = gen_lowpart (Pmode, operands[4]);
5547 pat = gen_rtx_PLUS (Pmode,
5548 gen_rtx_PLUS (Pmode, gen_rtx_MULT (Pmode, operands[1],
5549 operands[2]),
5550 operands[3]),
5551 operands[4]);
5552 if (Pmode != SImode)
5553 pat = gen_rtx_SUBREG (SImode, pat, 0);
5554 emit_insn (gen_rtx_SET (VOIDmode, operands[0], pat));
5555 DONE;
5556 }
5557 [(set_attr "type" "lea")
5558 (set_attr "mode" "SI")])
5559
5560 (define_insn_and_split "*lea_general_3_zext"
5561 [(set (match_operand:DI 0 "register_operand" "=r")
5562 (zero_extend:DI
5563 (plus:SI (plus:SI (mult:SI (match_operand:SI 1 "register_operand" "r")
5564 (match_operand:SI 2 "const248_operand" "n"))
5565 (match_operand:SI 3 "register_operand" "r"))
5566 (match_operand:SI 4 "immediate_operand" "i"))))]
5567 "TARGET_64BIT"
5568 "#"
5569 "&& reload_completed"
5570 [(set (match_dup 0)
5571 (zero_extend:DI (subreg:SI (plus:DI (plus:DI (mult:DI (match_dup 1)
5572 (match_dup 2))
5573 (match_dup 3))
5574 (match_dup 4)) 0)))]
5575 {
5576 operands[1] = gen_lowpart (Pmode, operands[1]);
5577 operands[3] = gen_lowpart (Pmode, operands[3]);
5578 operands[4] = gen_lowpart (Pmode, operands[4]);
5579 }
5580 [(set_attr "type" "lea")
5581 (set_attr "mode" "SI")])
5582
5583 (define_insn "*adddi_1_rex64"
5584 [(set (match_operand:DI 0 "nonimmediate_operand" "=r,rm,r")
5585 (plus:DI (match_operand:DI 1 "nonimmediate_operand" "%0,0,r")
5586 (match_operand:DI 2 "x86_64_general_operand" "rme,re,re")))
5587 (clobber (reg:CC 17))]
5588 "TARGET_64BIT && ix86_binary_operator_ok (PLUS, DImode, operands)"
5589 {
5590 switch (get_attr_type (insn))
5591 {
5592 case TYPE_LEA:
5593 operands[2] = SET_SRC (XVECEXP (PATTERN (insn), 0, 0));
5594 return "lea{q}\t{%a2, %0|%0, %a2}";
5595
5596 case TYPE_INCDEC:
5597 if (! rtx_equal_p (operands[0], operands[1]))
5598 abort ();
5599 if (operands[2] == const1_rtx)
5600 return "inc{q}\t%0";
5601 else if (operands[2] == constm1_rtx)
5602 return "dec{q}\t%0";
5603 else
5604 abort ();
5605
5606 default:
5607 if (! rtx_equal_p (operands[0], operands[1]))
5608 abort ();
5609
5610 /* Make things pretty and `subl $4,%eax' rather than `addl $-4, %eax'.
5611 Exceptions: -128 encodes smaller than 128, so swap sign and op. */
5612 if (GET_CODE (operands[2]) == CONST_INT
5613 /* Avoid overflows. */
5614 && ((INTVAL (operands[2]) & ((((unsigned int) 1) << 31) - 1)))
5615 && (INTVAL (operands[2]) == 128
5616 || (INTVAL (operands[2]) < 0
5617 && INTVAL (operands[2]) != -128)))
5618 {
5619 operands[2] = GEN_INT (-INTVAL (operands[2]));
5620 return "sub{q}\t{%2, %0|%0, %2}";
5621 }
5622 return "add{q}\t{%2, %0|%0, %2}";
5623 }
5624 }
5625 [(set (attr "type")
5626 (cond [(eq_attr "alternative" "2")
5627 (const_string "lea")
5628 ; Current assemblers are broken and do not allow @GOTOFF in
5629 ; ought but a memory context.
5630 (match_operand:DI 2 "pic_symbolic_operand" "")
5631 (const_string "lea")
5632 (match_operand:DI 2 "incdec_operand" "")
5633 (const_string "incdec")
5634 ]
5635 (const_string "alu")))
5636 (set_attr "mode" "DI")])
5637
5638 ;; Convert lea to the lea pattern to avoid flags dependency.
5639 (define_split
5640 [(set (match_operand:DI 0 "register_operand" "")
5641 (plus:DI (match_operand:DI 1 "register_operand" "")
5642 (match_operand:DI 2 "x86_64_nonmemory_operand" "")))
5643 (clobber (reg:CC 17))]
5644 "TARGET_64BIT && reload_completed
5645 && true_regnum (operands[0]) != true_regnum (operands[1])"
5646 [(set (match_dup 0)
5647 (plus:DI (match_dup 1)
5648 (match_dup 2)))]
5649 "")
5650
5651 (define_insn "*adddi_2_rex64"
5652 [(set (reg 17)
5653 (compare
5654 (plus:DI (match_operand:DI 1 "nonimmediate_operand" "%0,0")
5655 (match_operand:DI 2 "x86_64_general_operand" "rme,re"))
5656 (const_int 0)))
5657 (set (match_operand:DI 0 "nonimmediate_operand" "=r,rm")
5658 (plus:DI (match_dup 1) (match_dup 2)))]
5659 "TARGET_64BIT && ix86_match_ccmode (insn, CCGOCmode)
5660 && ix86_binary_operator_ok (PLUS, DImode, operands)
5661 /* Current assemblers are broken and do not allow @GOTOFF in
5662 ought but a memory context. */
5663 && ! pic_symbolic_operand (operands[2], VOIDmode)"
5664 {
5665 switch (get_attr_type (insn))
5666 {
5667 case TYPE_INCDEC:
5668 if (! rtx_equal_p (operands[0], operands[1]))
5669 abort ();
5670 if (operands[2] == const1_rtx)
5671 return "inc{q}\t%0";
5672 else if (operands[2] == constm1_rtx)
5673 return "dec{q}\t%0";
5674 else
5675 abort ();
5676
5677 default:
5678 if (! rtx_equal_p (operands[0], operands[1]))
5679 abort ();
5680 /* ???? We ought to handle there the 32bit case too
5681 - do we need new constrant? */
5682 /* Make things pretty and `subl $4,%eax' rather than `addl $-4, %eax'.
5683 Exceptions: -128 encodes smaller than 128, so swap sign and op. */
5684 if (GET_CODE (operands[2]) == CONST_INT
5685 /* Avoid overflows. */
5686 && ((INTVAL (operands[2]) & ((((unsigned int) 1) << 31) - 1)))
5687 && (INTVAL (operands[2]) == 128
5688 || (INTVAL (operands[2]) < 0
5689 && INTVAL (operands[2]) != -128)))
5690 {
5691 operands[2] = GEN_INT (-INTVAL (operands[2]));
5692 return "sub{q}\t{%2, %0|%0, %2}";
5693 }
5694 return "add{q}\t{%2, %0|%0, %2}";
5695 }
5696 }
5697 [(set (attr "type")
5698 (if_then_else (match_operand:DI 2 "incdec_operand" "")
5699 (const_string "incdec")
5700 (const_string "alu")))
5701 (set_attr "mode" "DI")])
5702
5703 (define_insn "*adddi_3_rex64"
5704 [(set (reg 17)
5705 (compare (neg:DI (match_operand:DI 2 "x86_64_general_operand" "rme"))
5706 (match_operand:DI 1 "x86_64_general_operand" "%0")))
5707 (clobber (match_scratch:DI 0 "=r"))]
5708 "TARGET_64BIT
5709 && ix86_match_ccmode (insn, CCZmode)
5710 && (GET_CODE (operands[1]) != MEM || GET_CODE (operands[2]) != MEM)
5711 /* Current assemblers are broken and do not allow @GOTOFF in
5712 ought but a memory context. */
5713 && ! pic_symbolic_operand (operands[2], VOIDmode)"
5714 {
5715 switch (get_attr_type (insn))
5716 {
5717 case TYPE_INCDEC:
5718 if (! rtx_equal_p (operands[0], operands[1]))
5719 abort ();
5720 if (operands[2] == const1_rtx)
5721 return "inc{q}\t%0";
5722 else if (operands[2] == constm1_rtx)
5723 return "dec{q}\t%0";
5724 else
5725 abort ();
5726
5727 default:
5728 if (! rtx_equal_p (operands[0], operands[1]))
5729 abort ();
5730 /* ???? We ought to handle there the 32bit case too
5731 - do we need new constrant? */
5732 /* Make things pretty and `subl $4,%eax' rather than `addl $-4, %eax'.
5733 Exceptions: -128 encodes smaller than 128, so swap sign and op. */
5734 if (GET_CODE (operands[2]) == CONST_INT
5735 /* Avoid overflows. */
5736 && ((INTVAL (operands[2]) & ((((unsigned int) 1) << 31) - 1)))
5737 && (INTVAL (operands[2]) == 128
5738 || (INTVAL (operands[2]) < 0
5739 && INTVAL (operands[2]) != -128)))
5740 {
5741 operands[2] = GEN_INT (-INTVAL (operands[2]));
5742 return "sub{q}\t{%2, %0|%0, %2}";
5743 }
5744 return "add{q}\t{%2, %0|%0, %2}";
5745 }
5746 }
5747 [(set (attr "type")
5748 (if_then_else (match_operand:DI 2 "incdec_operand" "")
5749 (const_string "incdec")
5750 (const_string "alu")))
5751 (set_attr "mode" "DI")])
5752
5753 ; For comparisons against 1, -1 and 128, we may generate better code
5754 ; by converting cmp to add, inc or dec as done by peephole2. This pattern
5755 ; is matched then. We can't accept general immediate, because for
5756 ; case of overflows, the result is messed up.
5757 ; This pattern also don't hold of 0x8000000000000000, since the value overflows
5758 ; when negated.
5759 ; Also carry flag is reversed compared to cmp, so this conversion is valid
5760 ; only for comparisons not depending on it.
5761 (define_insn "*adddi_4_rex64"
5762 [(set (reg 17)
5763 (compare (match_operand:DI 1 "nonimmediate_operand" "0")
5764 (match_operand:DI 2 "x86_64_immediate_operand" "e")))
5765 (clobber (match_scratch:DI 0 "=rm"))]
5766 "TARGET_64BIT
5767 && ix86_match_ccmode (insn, CCGCmode)"
5768 {
5769 switch (get_attr_type (insn))
5770 {
5771 case TYPE_INCDEC:
5772 if (operands[2] == constm1_rtx)
5773 return "inc{q}\t%0";
5774 else if (operands[2] == const1_rtx)
5775 return "dec{q}\t%0";
5776 else
5777 abort();
5778
5779 default:
5780 if (! rtx_equal_p (operands[0], operands[1]))
5781 abort ();
5782 /* Make things pretty and `subl $4,%eax' rather than `addl $-4, %eax'.
5783 Exceptions: -128 encodes smaller than 128, so swap sign and op. */
5784 if ((INTVAL (operands[2]) == -128
5785 || (INTVAL (operands[2]) > 0
5786 && INTVAL (operands[2]) != 128))
5787 /* Avoid overflows. */
5788 && ((INTVAL (operands[2]) & ((((unsigned int) 1) << 31) - 1))))
5789 return "sub{q}\t{%2, %0|%0, %2}";
5790 operands[2] = GEN_INT (-INTVAL (operands[2]));
5791 return "add{q}\t{%2, %0|%0, %2}";
5792 }
5793 }
5794 [(set (attr "type")
5795 (if_then_else (match_operand:DI 2 "incdec_operand" "")
5796 (const_string "incdec")
5797 (const_string "alu")))
5798 (set_attr "mode" "DI")])
5799
5800 (define_insn "*adddi_5_rex64"
5801 [(set (reg 17)
5802 (compare
5803 (plus:DI (match_operand:DI 1 "nonimmediate_operand" "%0")
5804 (match_operand:DI 2 "x86_64_general_operand" "rme"))
5805 (const_int 0)))
5806 (clobber (match_scratch:DI 0 "=r"))]
5807 "TARGET_64BIT
5808 && ix86_match_ccmode (insn, CCGOCmode)
5809 && (GET_CODE (operands[1]) != MEM || GET_CODE (operands[2]) != MEM)
5810 /* Current assemblers are broken and do not allow @GOTOFF in
5811 ought but a memory context. */
5812 && ! pic_symbolic_operand (operands[2], VOIDmode)"
5813 {
5814 switch (get_attr_type (insn))
5815 {
5816 case TYPE_INCDEC:
5817 if (! rtx_equal_p (operands[0], operands[1]))
5818 abort ();
5819 if (operands[2] == const1_rtx)
5820 return "inc{q}\t%0";
5821 else if (operands[2] == constm1_rtx)
5822 return "dec{q}\t%0";
5823 else
5824 abort();
5825
5826 default:
5827 if (! rtx_equal_p (operands[0], operands[1]))
5828 abort ();
5829 /* Make things pretty and `subl $4,%eax' rather than `addl $-4, %eax'.
5830 Exceptions: -128 encodes smaller than 128, so swap sign and op. */
5831 if (GET_CODE (operands[2]) == CONST_INT
5832 /* Avoid overflows. */
5833 && ((INTVAL (operands[2]) & ((((unsigned int) 1) << 31) - 1)))
5834 && (INTVAL (operands[2]) == 128
5835 || (INTVAL (operands[2]) < 0
5836 && INTVAL (operands[2]) != -128)))
5837 {
5838 operands[2] = GEN_INT (-INTVAL (operands[2]));
5839 return "sub{q}\t{%2, %0|%0, %2}";
5840 }
5841 return "add{q}\t{%2, %0|%0, %2}";
5842 }
5843 }
5844 [(set (attr "type")
5845 (if_then_else (match_operand:DI 2 "incdec_operand" "")
5846 (const_string "incdec")
5847 (const_string "alu")))
5848 (set_attr "mode" "DI")])
5849
5850
5851 (define_insn "*addsi_1"
5852 [(set (match_operand:SI 0 "nonimmediate_operand" "=r,rm,r")
5853 (plus:SI (match_operand:SI 1 "nonimmediate_operand" "%0,0,r")
5854 (match_operand:SI 2 "general_operand" "rmni,rni,rni")))
5855 (clobber (reg:CC 17))]
5856 "ix86_binary_operator_ok (PLUS, SImode, operands)"
5857 {
5858 switch (get_attr_type (insn))
5859 {
5860 case TYPE_LEA:
5861 operands[2] = SET_SRC (XVECEXP (PATTERN (insn), 0, 0));
5862 return "lea{l}\t{%a2, %0|%0, %a2}";
5863
5864 case TYPE_INCDEC:
5865 if (! rtx_equal_p (operands[0], operands[1]))
5866 abort ();
5867 if (operands[2] == const1_rtx)
5868 return "inc{l}\t%0";
5869 else if (operands[2] == constm1_rtx)
5870 return "dec{l}\t%0";
5871 else
5872 abort();
5873
5874 default:
5875 if (! rtx_equal_p (operands[0], operands[1]))
5876 abort ();
5877
5878 /* Make things pretty and `subl $4,%eax' rather than `addl $-4, %eax'.
5879 Exceptions: -128 encodes smaller than 128, so swap sign and op. */
5880 if (GET_CODE (operands[2]) == CONST_INT
5881 && (INTVAL (operands[2]) == 128
5882 || (INTVAL (operands[2]) < 0
5883 && INTVAL (operands[2]) != -128)))
5884 {
5885 operands[2] = GEN_INT (-INTVAL (operands[2]));
5886 return "sub{l}\t{%2, %0|%0, %2}";
5887 }
5888 return "add{l}\t{%2, %0|%0, %2}";
5889 }
5890 }
5891 [(set (attr "type")
5892 (cond [(eq_attr "alternative" "2")
5893 (const_string "lea")
5894 ; Current assemblers are broken and do not allow @GOTOFF in
5895 ; ought but a memory context.
5896 (match_operand:SI 2 "pic_symbolic_operand" "")
5897 (const_string "lea")
5898 (match_operand:SI 2 "incdec_operand" "")
5899 (const_string "incdec")
5900 ]
5901 (const_string "alu")))
5902 (set_attr "mode" "SI")])
5903
5904 ;; Convert lea to the lea pattern to avoid flags dependency.
5905 (define_split
5906 [(set (match_operand 0 "register_operand" "")
5907 (plus (match_operand 1 "register_operand" "")
5908 (match_operand 2 "nonmemory_operand" "")))
5909 (clobber (reg:CC 17))]
5910 "reload_completed
5911 && true_regnum (operands[0]) != true_regnum (operands[1])"
5912 [(const_int 0)]
5913 {
5914 rtx pat;
5915 /* In -fPIC mode the constructs like (const (unspec [symbol_ref]))
5916 may confuse gen_lowpart. */
5917 if (GET_MODE (operands[0]) != Pmode)
5918 {
5919 operands[1] = gen_lowpart (Pmode, operands[1]);
5920 operands[2] = gen_lowpart (Pmode, operands[2]);
5921 }
5922 operands[0] = gen_lowpart (SImode, operands[0]);
5923 pat = gen_rtx_PLUS (Pmode, operands[1], operands[2]);
5924 if (Pmode != SImode)
5925 pat = gen_rtx_SUBREG (SImode, pat, 0);
5926 emit_insn (gen_rtx_SET (VOIDmode, operands[0], pat));
5927 DONE;
5928 })
5929
5930 ;; It may seem that nonimmediate operand is proper one for operand 1.
5931 ;; The addsi_1 pattern allows nonimmediate operand at that place and
5932 ;; we take care in ix86_binary_operator_ok to not allow two memory
5933 ;; operands so proper swapping will be done in reload. This allow
5934 ;; patterns constructed from addsi_1 to match.
5935 (define_insn "addsi_1_zext"
5936 [(set (match_operand:DI 0 "register_operand" "=r,r")
5937 (zero_extend:DI
5938 (plus:SI (match_operand:SI 1 "nonimmediate_operand" "%0,r")
5939 (match_operand:SI 2 "general_operand" "rmni,rni"))))
5940 (clobber (reg:CC 17))]
5941 "TARGET_64BIT && ix86_binary_operator_ok (PLUS, SImode, operands)"
5942 {
5943 switch (get_attr_type (insn))
5944 {
5945 case TYPE_LEA:
5946 operands[2] = SET_SRC (XVECEXP (PATTERN (insn), 0, 0));
5947 return "lea{l}\t{%a2, %k0|%k0, %a2}";
5948
5949 case TYPE_INCDEC:
5950 if (operands[2] == const1_rtx)
5951 return "inc{l}\t%k0";
5952 else if (operands[2] == constm1_rtx)
5953 return "dec{l}\t%k0";
5954 else
5955 abort();
5956
5957 default:
5958 /* Make things pretty and `subl $4,%eax' rather than `addl $-4, %eax'.
5959 Exceptions: -128 encodes smaller than 128, so swap sign and op. */
5960 if (GET_CODE (operands[2]) == CONST_INT
5961 && (INTVAL (operands[2]) == 128
5962 || (INTVAL (operands[2]) < 0
5963 && INTVAL (operands[2]) != -128)))
5964 {
5965 operands[2] = GEN_INT (-INTVAL (operands[2]));
5966 return "sub{l}\t{%2, %k0|%k0, %2}";
5967 }
5968 return "add{l}\t{%2, %k0|%k0, %2}";
5969 }
5970 }
5971 [(set (attr "type")
5972 (cond [(eq_attr "alternative" "1")
5973 (const_string "lea")
5974 ; Current assemblers are broken and do not allow @GOTOFF in
5975 ; ought but a memory context.
5976 (match_operand:SI 2 "pic_symbolic_operand" "")
5977 (const_string "lea")
5978 (match_operand:SI 2 "incdec_operand" "")
5979 (const_string "incdec")
5980 ]
5981 (const_string "alu")))
5982 (set_attr "mode" "SI")])
5983
5984 ;; Convert lea to the lea pattern to avoid flags dependency.
5985 (define_split
5986 [(set (match_operand:DI 0 "register_operand" "")
5987 (zero_extend:DI
5988 (plus:SI (match_operand:SI 1 "register_operand" "")
5989 (match_operand:SI 2 "nonmemory_operand" ""))))
5990 (clobber (reg:CC 17))]
5991 "reload_completed
5992 && true_regnum (operands[0]) != true_regnum (operands[1])"
5993 [(set (match_dup 0)
5994 (zero_extend:DI (subreg:SI (plus:DI (match_dup 1) (match_dup 2)) 0)))]
5995 {
5996 operands[1] = gen_lowpart (Pmode, operands[1]);
5997 operands[2] = gen_lowpart (Pmode, operands[2]);
5998 })
5999
6000 (define_insn "*addsi_2"
6001 [(set (reg 17)
6002 (compare
6003 (plus:SI (match_operand:SI 1 "nonimmediate_operand" "%0,0")
6004 (match_operand:SI 2 "general_operand" "rmni,rni"))
6005 (const_int 0)))
6006 (set (match_operand:SI 0 "nonimmediate_operand" "=r,rm")
6007 (plus:SI (match_dup 1) (match_dup 2)))]
6008 "ix86_match_ccmode (insn, CCGOCmode)
6009 && ix86_binary_operator_ok (PLUS, SImode, operands)
6010 /* Current assemblers are broken and do not allow @GOTOFF in
6011 ought but a memory context. */
6012 && ! pic_symbolic_operand (operands[2], VOIDmode)"
6013 {
6014 switch (get_attr_type (insn))
6015 {
6016 case TYPE_INCDEC:
6017 if (! rtx_equal_p (operands[0], operands[1]))
6018 abort ();
6019 if (operands[2] == const1_rtx)
6020 return "inc{l}\t%0";
6021 else if (operands[2] == constm1_rtx)
6022 return "dec{l}\t%0";
6023 else
6024 abort();
6025
6026 default:
6027 if (! rtx_equal_p (operands[0], operands[1]))
6028 abort ();
6029 /* Make things pretty and `subl $4,%eax' rather than `addl $-4, %eax'.
6030 Exceptions: -128 encodes smaller than 128, so swap sign and op. */
6031 if (GET_CODE (operands[2]) == CONST_INT
6032 && (INTVAL (operands[2]) == 128
6033 || (INTVAL (operands[2]) < 0
6034 && INTVAL (operands[2]) != -128)))
6035 {
6036 operands[2] = GEN_INT (-INTVAL (operands[2]));
6037 return "sub{l}\t{%2, %0|%0, %2}";
6038 }
6039 return "add{l}\t{%2, %0|%0, %2}";
6040 }
6041 }
6042 [(set (attr "type")
6043 (if_then_else (match_operand:SI 2 "incdec_operand" "")
6044 (const_string "incdec")
6045 (const_string "alu")))
6046 (set_attr "mode" "SI")])
6047
6048 ;; See comment for addsi_1_zext why we do use nonimmediate_operand
6049 (define_insn "*addsi_2_zext"
6050 [(set (reg 17)
6051 (compare
6052 (plus:SI (match_operand:SI 1 "nonimmediate_operand" "%0")
6053 (match_operand:SI 2 "general_operand" "rmni"))
6054 (const_int 0)))
6055 (set (match_operand:DI 0 "register_operand" "=r")
6056 (zero_extend:DI (plus:SI (match_dup 1) (match_dup 2))))]
6057 "TARGET_64BIT && ix86_match_ccmode (insn, CCGOCmode)
6058 && ix86_binary_operator_ok (PLUS, SImode, operands)
6059 /* Current assemblers are broken and do not allow @GOTOFF in
6060 ought but a memory context. */
6061 && ! pic_symbolic_operand (operands[2], VOIDmode)"
6062 {
6063 switch (get_attr_type (insn))
6064 {
6065 case TYPE_INCDEC:
6066 if (operands[2] == const1_rtx)
6067 return "inc{l}\t%k0";
6068 else if (operands[2] == constm1_rtx)
6069 return "dec{l}\t%k0";
6070 else
6071 abort();
6072
6073 default:
6074 /* Make things pretty and `subl $4,%eax' rather than `addl $-4, %eax'.
6075 Exceptions: -128 encodes smaller than 128, so swap sign and op. */
6076 if (GET_CODE (operands[2]) == CONST_INT
6077 && (INTVAL (operands[2]) == 128
6078 || (INTVAL (operands[2]) < 0
6079 && INTVAL (operands[2]) != -128)))
6080 {
6081 operands[2] = GEN_INT (-INTVAL (operands[2]));
6082 return "sub{l}\t{%2, %k0|%k0, %2}";
6083 }
6084 return "add{l}\t{%2, %k0|%k0, %2}";
6085 }
6086 }
6087 [(set (attr "type")
6088 (if_then_else (match_operand:SI 2 "incdec_operand" "")
6089 (const_string "incdec")
6090 (const_string "alu")))
6091 (set_attr "mode" "SI")])
6092
6093 (define_insn "*addsi_3"
6094 [(set (reg 17)
6095 (compare (neg:SI (match_operand:SI 2 "general_operand" "rmni"))
6096 (match_operand:SI 1 "nonimmediate_operand" "%0")))
6097 (clobber (match_scratch:SI 0 "=r"))]
6098 "ix86_match_ccmode (insn, CCZmode)
6099 && (GET_CODE (operands[1]) != MEM || GET_CODE (operands[2]) != MEM)
6100 /* Current assemblers are broken and do not allow @GOTOFF in
6101 ought but a memory context. */
6102 && ! pic_symbolic_operand (operands[2], VOIDmode)"
6103 {
6104 switch (get_attr_type (insn))
6105 {
6106 case TYPE_INCDEC:
6107 if (! rtx_equal_p (operands[0], operands[1]))
6108 abort ();
6109 if (operands[2] == const1_rtx)
6110 return "inc{l}\t%0";
6111 else if (operands[2] == constm1_rtx)
6112 return "dec{l}\t%0";
6113 else
6114 abort();
6115
6116 default:
6117 if (! rtx_equal_p (operands[0], operands[1]))
6118 abort ();
6119 /* Make things pretty and `subl $4,%eax' rather than `addl $-4, %eax'.
6120 Exceptions: -128 encodes smaller than 128, so swap sign and op. */
6121 if (GET_CODE (operands[2]) == CONST_INT
6122 && (INTVAL (operands[2]) == 128
6123 || (INTVAL (operands[2]) < 0
6124 && INTVAL (operands[2]) != -128)))
6125 {
6126 operands[2] = GEN_INT (-INTVAL (operands[2]));
6127 return "sub{l}\t{%2, %0|%0, %2}";
6128 }
6129 return "add{l}\t{%2, %0|%0, %2}";
6130 }
6131 }
6132 [(set (attr "type")
6133 (if_then_else (match_operand:SI 2 "incdec_operand" "")
6134 (const_string "incdec")
6135 (const_string "alu")))
6136 (set_attr "mode" "SI")])
6137
6138 ;; See comment for addsi_1_zext why we do use nonimmediate_operand
6139 (define_insn "*addsi_3_zext"
6140 [(set (reg 17)
6141 (compare (neg:SI (match_operand:SI 2 "general_operand" "rmni"))
6142 (match_operand:SI 1 "nonimmediate_operand" "%0")))
6143 (set (match_operand:DI 0 "register_operand" "=r")
6144 (zero_extend:DI (plus:SI (match_dup 1) (match_dup 2))))]
6145 "TARGET_64BIT && ix86_match_ccmode (insn, CCZmode)
6146 && ix86_binary_operator_ok (PLUS, SImode, operands)
6147 /* Current assemblers are broken and do not allow @GOTOFF in
6148 ought but a memory context. */
6149 && ! pic_symbolic_operand (operands[2], VOIDmode)"
6150 {
6151 switch (get_attr_type (insn))
6152 {
6153 case TYPE_INCDEC:
6154 if (operands[2] == const1_rtx)
6155 return "inc{l}\t%k0";
6156 else if (operands[2] == constm1_rtx)
6157 return "dec{l}\t%k0";
6158 else
6159 abort();
6160
6161 default:
6162 /* Make things pretty and `subl $4,%eax' rather than `addl $-4, %eax'.
6163 Exceptions: -128 encodes smaller than 128, so swap sign and op. */
6164 if (GET_CODE (operands[2]) == CONST_INT
6165 && (INTVAL (operands[2]) == 128
6166 || (INTVAL (operands[2]) < 0
6167 && INTVAL (operands[2]) != -128)))
6168 {
6169 operands[2] = GEN_INT (-INTVAL (operands[2]));
6170 return "sub{l}\t{%2, %k0|%k0, %2}";
6171 }
6172 return "add{l}\t{%2, %k0|%k0, %2}";
6173 }
6174 }
6175 [(set (attr "type")
6176 (if_then_else (match_operand:SI 2 "incdec_operand" "")
6177 (const_string "incdec")
6178 (const_string "alu")))
6179 (set_attr "mode" "SI")])
6180
6181 ; For comparisons agains 1, -1 and 128, we may generate better code
6182 ; by converting cmp to add, inc or dec as done by peephole2. This pattern
6183 ; is matched then. We can't accept general immediate, because for
6184 ; case of overflows, the result is messed up.
6185 ; This pattern also don't hold of 0x80000000, since the value overflows
6186 ; when negated.
6187 ; Also carry flag is reversed compared to cmp, so this conversion is valid
6188 ; only for comparisons not depending on it.
6189 (define_insn "*addsi_4"
6190 [(set (reg 17)
6191 (compare (match_operand:SI 1 "nonimmediate_operand" "0")
6192 (match_operand:SI 2 "const_int_operand" "n")))
6193 (clobber (match_scratch:SI 0 "=rm"))]
6194 "ix86_match_ccmode (insn, CCGCmode)
6195 && (INTVAL (operands[2]) & 0xffffffff) != 0x80000000"
6196 {
6197 switch (get_attr_type (insn))
6198 {
6199 case TYPE_INCDEC:
6200 if (operands[2] == constm1_rtx)
6201 return "inc{l}\t%0";
6202 else if (operands[2] == const1_rtx)
6203 return "dec{l}\t%0";
6204 else
6205 abort();
6206
6207 default:
6208 if (! rtx_equal_p (operands[0], operands[1]))
6209 abort ();
6210 /* Make things pretty and `subl $4,%eax' rather than `addl $-4, %eax'.
6211 Exceptions: -128 encodes smaller than 128, so swap sign and op. */
6212 if ((INTVAL (operands[2]) == -128
6213 || (INTVAL (operands[2]) > 0
6214 && INTVAL (operands[2]) != 128)))
6215 return "sub{l}\t{%2, %0|%0, %2}";
6216 operands[2] = GEN_INT (-INTVAL (operands[2]));
6217 return "add{l}\t{%2, %0|%0, %2}";
6218 }
6219 }
6220 [(set (attr "type")
6221 (if_then_else (match_operand:SI 2 "incdec_operand" "")
6222 (const_string "incdec")
6223 (const_string "alu")))
6224 (set_attr "mode" "SI")])
6225
6226 (define_insn "*addsi_5"
6227 [(set (reg 17)
6228 (compare
6229 (plus:SI (match_operand:SI 1 "nonimmediate_operand" "%0")
6230 (match_operand:SI 2 "general_operand" "rmni"))
6231 (const_int 0)))
6232 (clobber (match_scratch:SI 0 "=r"))]
6233 "ix86_match_ccmode (insn, CCGOCmode)
6234 && (GET_CODE (operands[1]) != MEM || GET_CODE (operands[2]) != MEM)
6235 /* Current assemblers are broken and do not allow @GOTOFF in
6236 ought but a memory context. */
6237 && ! pic_symbolic_operand (operands[2], VOIDmode)"
6238 {
6239 switch (get_attr_type (insn))
6240 {
6241 case TYPE_INCDEC:
6242 if (! rtx_equal_p (operands[0], operands[1]))
6243 abort ();
6244 if (operands[2] == const1_rtx)
6245 return "inc{l}\t%0";
6246 else if (operands[2] == constm1_rtx)
6247 return "dec{l}\t%0";
6248 else
6249 abort();
6250
6251 default:
6252 if (! rtx_equal_p (operands[0], operands[1]))
6253 abort ();
6254 /* Make things pretty and `subl $4,%eax' rather than `addl $-4, %eax'.
6255 Exceptions: -128 encodes smaller than 128, so swap sign and op. */
6256 if (GET_CODE (operands[2]) == CONST_INT
6257 && (INTVAL (operands[2]) == 128
6258 || (INTVAL (operands[2]) < 0
6259 && INTVAL (operands[2]) != -128)))
6260 {
6261 operands[2] = GEN_INT (-INTVAL (operands[2]));
6262 return "sub{l}\t{%2, %0|%0, %2}";
6263 }
6264 return "add{l}\t{%2, %0|%0, %2}";
6265 }
6266 }
6267 [(set (attr "type")
6268 (if_then_else (match_operand:SI 2 "incdec_operand" "")
6269 (const_string "incdec")
6270 (const_string "alu")))
6271 (set_attr "mode" "SI")])
6272
6273 (define_expand "addhi3"
6274 [(parallel [(set (match_operand:HI 0 "nonimmediate_operand" "")
6275 (plus:HI (match_operand:HI 1 "nonimmediate_operand" "")
6276 (match_operand:HI 2 "general_operand" "")))
6277 (clobber (reg:CC 17))])]
6278 "TARGET_HIMODE_MATH"
6279 "ix86_expand_binary_operator (PLUS, HImode, operands); DONE;")
6280
6281 ;; %%% After Dave's SUBREG_BYTE stuff goes in, re-enable incb %ah
6282 ;; type optimizations enabled by define-splits. This is not important
6283 ;; for PII, and in fact harmful because of partial register stalls.
6284
6285 (define_insn "*addhi_1_lea"
6286 [(set (match_operand:HI 0 "nonimmediate_operand" "=rm,r,r")
6287 (plus:HI (match_operand:HI 1 "nonimmediate_operand" "%0,0,r")
6288 (match_operand:HI 2 "general_operand" "ri,rm,rni")))
6289 (clobber (reg:CC 17))]
6290 "!TARGET_PARTIAL_REG_STALL
6291 && ix86_binary_operator_ok (PLUS, HImode, operands)"
6292 {
6293 switch (get_attr_type (insn))
6294 {
6295 case TYPE_LEA:
6296 return "#";
6297 case TYPE_INCDEC:
6298 if (operands[2] == const1_rtx)
6299 return "inc{w}\t%0";
6300 else if (operands[2] == constm1_rtx
6301 || (GET_CODE (operands[2]) == CONST_INT
6302 && INTVAL (operands[2]) == 65535))
6303 return "dec{w}\t%0";
6304 abort();
6305
6306 default:
6307 /* Make things pretty and `subl $4,%eax' rather than `addl $-4, %eax'.
6308 Exceptions: -128 encodes smaller than 128, so swap sign and op. */
6309 if (GET_CODE (operands[2]) == CONST_INT
6310 && (INTVAL (operands[2]) == 128
6311 || (INTVAL (operands[2]) < 0
6312 && INTVAL (operands[2]) != -128)))
6313 {
6314 operands[2] = GEN_INT (-INTVAL (operands[2]));
6315 return "sub{w}\t{%2, %0|%0, %2}";
6316 }
6317 return "add{w}\t{%2, %0|%0, %2}";
6318 }
6319 }
6320 [(set (attr "type")
6321 (if_then_else (eq_attr "alternative" "2")
6322 (const_string "lea")
6323 (if_then_else (match_operand:HI 2 "incdec_operand" "")
6324 (const_string "incdec")
6325 (const_string "alu"))))
6326 (set_attr "mode" "HI,HI,SI")])
6327
6328 (define_insn "*addhi_1"
6329 [(set (match_operand:HI 0 "nonimmediate_operand" "=rm,r")
6330 (plus:HI (match_operand:HI 1 "nonimmediate_operand" "%0,0")
6331 (match_operand:HI 2 "general_operand" "ri,rm")))
6332 (clobber (reg:CC 17))]
6333 "TARGET_PARTIAL_REG_STALL
6334 && ix86_binary_operator_ok (PLUS, HImode, operands)"
6335 {
6336 switch (get_attr_type (insn))
6337 {
6338 case TYPE_INCDEC:
6339 if (operands[2] == const1_rtx)
6340 return "inc{w}\t%0";
6341 else if (operands[2] == constm1_rtx
6342 || (GET_CODE (operands[2]) == CONST_INT
6343 && INTVAL (operands[2]) == 65535))
6344 return "dec{w}\t%0";
6345 abort();
6346
6347 default:
6348 /* Make things pretty and `subl $4,%eax' rather than `addl $-4, %eax'.
6349 Exceptions: -128 encodes smaller than 128, so swap sign and op. */
6350 if (GET_CODE (operands[2]) == CONST_INT
6351 && (INTVAL (operands[2]) == 128
6352 || (INTVAL (operands[2]) < 0
6353 && INTVAL (operands[2]) != -128)))
6354 {
6355 operands[2] = GEN_INT (-INTVAL (operands[2]));
6356 return "sub{w}\t{%2, %0|%0, %2}";
6357 }
6358 return "add{w}\t{%2, %0|%0, %2}";
6359 }
6360 }
6361 [(set (attr "type")
6362 (if_then_else (match_operand:HI 2 "incdec_operand" "")
6363 (const_string "incdec")
6364 (const_string "alu")))
6365 (set_attr "mode" "HI")])
6366
6367 (define_insn "*addhi_2"
6368 [(set (reg 17)
6369 (compare
6370 (plus:HI (match_operand:HI 1 "nonimmediate_operand" "%0,0")
6371 (match_operand:HI 2 "general_operand" "rmni,rni"))
6372 (const_int 0)))
6373 (set (match_operand:HI 0 "nonimmediate_operand" "=r,rm")
6374 (plus:HI (match_dup 1) (match_dup 2)))]
6375 "ix86_match_ccmode (insn, CCGOCmode)
6376 && ix86_binary_operator_ok (PLUS, HImode, operands)"
6377 {
6378 switch (get_attr_type (insn))
6379 {
6380 case TYPE_INCDEC:
6381 if (operands[2] == const1_rtx)
6382 return "inc{w}\t%0";
6383 else if (operands[2] == constm1_rtx
6384 || (GET_CODE (operands[2]) == CONST_INT
6385 && INTVAL (operands[2]) == 65535))
6386 return "dec{w}\t%0";
6387 abort();
6388
6389 default:
6390 /* Make things pretty and `subl $4,%eax' rather than `addl $-4, %eax'.
6391 Exceptions: -128 encodes smaller than 128, so swap sign and op. */
6392 if (GET_CODE (operands[2]) == CONST_INT
6393 && (INTVAL (operands[2]) == 128
6394 || (INTVAL (operands[2]) < 0
6395 && INTVAL (operands[2]) != -128)))
6396 {
6397 operands[2] = GEN_INT (-INTVAL (operands[2]));
6398 return "sub{w}\t{%2, %0|%0, %2}";
6399 }
6400 return "add{w}\t{%2, %0|%0, %2}";
6401 }
6402 }
6403 [(set (attr "type")
6404 (if_then_else (match_operand:HI 2 "incdec_operand" "")
6405 (const_string "incdec")
6406 (const_string "alu")))
6407 (set_attr "mode" "HI")])
6408
6409 (define_insn "*addhi_3"
6410 [(set (reg 17)
6411 (compare (neg:HI (match_operand:HI 2 "general_operand" "rmni"))
6412 (match_operand:HI 1 "nonimmediate_operand" "%0")))
6413 (clobber (match_scratch:HI 0 "=r"))]
6414 "ix86_match_ccmode (insn, CCZmode)
6415 && (GET_CODE (operands[1]) != MEM || GET_CODE (operands[2]) != MEM)"
6416 {
6417 switch (get_attr_type (insn))
6418 {
6419 case TYPE_INCDEC:
6420 if (operands[2] == const1_rtx)
6421 return "inc{w}\t%0";
6422 else if (operands[2] == constm1_rtx
6423 || (GET_CODE (operands[2]) == CONST_INT
6424 && INTVAL (operands[2]) == 65535))
6425 return "dec{w}\t%0";
6426 abort();
6427
6428 default:
6429 /* Make things pretty and `subl $4,%eax' rather than `addl $-4, %eax'.
6430 Exceptions: -128 encodes smaller than 128, so swap sign and op. */
6431 if (GET_CODE (operands[2]) == CONST_INT
6432 && (INTVAL (operands[2]) == 128
6433 || (INTVAL (operands[2]) < 0
6434 && INTVAL (operands[2]) != -128)))
6435 {
6436 operands[2] = GEN_INT (-INTVAL (operands[2]));
6437 return "sub{w}\t{%2, %0|%0, %2}";
6438 }
6439 return "add{w}\t{%2, %0|%0, %2}";
6440 }
6441 }
6442 [(set (attr "type")
6443 (if_then_else (match_operand:HI 2 "incdec_operand" "")
6444 (const_string "incdec")
6445 (const_string "alu")))
6446 (set_attr "mode" "HI")])
6447
6448 ; See comments above addsi_3_imm for details.
6449 (define_insn "*addhi_4"
6450 [(set (reg 17)
6451 (compare (match_operand:HI 1 "nonimmediate_operand" "0")
6452 (match_operand:HI 2 "const_int_operand" "n")))
6453 (clobber (match_scratch:HI 0 "=rm"))]
6454 "ix86_match_ccmode (insn, CCGCmode)
6455 && (INTVAL (operands[2]) & 0xffff) != 0x8000"
6456 {
6457 switch (get_attr_type (insn))
6458 {
6459 case TYPE_INCDEC:
6460 if (operands[2] == constm1_rtx
6461 || (GET_CODE (operands[2]) == CONST_INT
6462 && INTVAL (operands[2]) == 65535))
6463 return "inc{w}\t%0";
6464 else if (operands[2] == const1_rtx)
6465 return "dec{w}\t%0";
6466 else
6467 abort();
6468
6469 default:
6470 if (! rtx_equal_p (operands[0], operands[1]))
6471 abort ();
6472 /* Make things pretty and `subl $4,%eax' rather than `addl $-4, %eax'.
6473 Exceptions: -128 encodes smaller than 128, so swap sign and op. */
6474 if ((INTVAL (operands[2]) == -128
6475 || (INTVAL (operands[2]) > 0
6476 && INTVAL (operands[2]) != 128)))
6477 return "sub{w}\t{%2, %0|%0, %2}";
6478 operands[2] = GEN_INT (-INTVAL (operands[2]));
6479 return "add{w}\t{%2, %0|%0, %2}";
6480 }
6481 }
6482 [(set (attr "type")
6483 (if_then_else (match_operand:HI 2 "incdec_operand" "")
6484 (const_string "incdec")
6485 (const_string "alu")))
6486 (set_attr "mode" "SI")])
6487
6488
6489 (define_insn "*addhi_5"
6490 [(set (reg 17)
6491 (compare
6492 (plus:HI (match_operand:HI 1 "nonimmediate_operand" "%0")
6493 (match_operand:HI 2 "general_operand" "rmni"))
6494 (const_int 0)))
6495 (clobber (match_scratch:HI 0 "=r"))]
6496 "ix86_match_ccmode (insn, CCGOCmode)
6497 && (GET_CODE (operands[1]) != MEM || GET_CODE (operands[2]) != MEM)"
6498 {
6499 switch (get_attr_type (insn))
6500 {
6501 case TYPE_INCDEC:
6502 if (operands[2] == const1_rtx)
6503 return "inc{w}\t%0";
6504 else if (operands[2] == constm1_rtx
6505 || (GET_CODE (operands[2]) == CONST_INT
6506 && INTVAL (operands[2]) == 65535))
6507 return "dec{w}\t%0";
6508 abort();
6509
6510 default:
6511 /* Make things pretty and `subl $4,%eax' rather than `addl $-4, %eax'.
6512 Exceptions: -128 encodes smaller than 128, so swap sign and op. */
6513 if (GET_CODE (operands[2]) == CONST_INT
6514 && (INTVAL (operands[2]) == 128
6515 || (INTVAL (operands[2]) < 0
6516 && INTVAL (operands[2]) != -128)))
6517 {
6518 operands[2] = GEN_INT (-INTVAL (operands[2]));
6519 return "sub{w}\t{%2, %0|%0, %2}";
6520 }
6521 return "add{w}\t{%2, %0|%0, %2}";
6522 }
6523 }
6524 [(set (attr "type")
6525 (if_then_else (match_operand:HI 2 "incdec_operand" "")
6526 (const_string "incdec")
6527 (const_string "alu")))
6528 (set_attr "mode" "HI")])
6529
6530 (define_expand "addqi3"
6531 [(parallel [(set (match_operand:QI 0 "nonimmediate_operand" "")
6532 (plus:QI (match_operand:QI 1 "nonimmediate_operand" "")
6533 (match_operand:QI 2 "general_operand" "")))
6534 (clobber (reg:CC 17))])]
6535 "TARGET_QIMODE_MATH"
6536 "ix86_expand_binary_operator (PLUS, QImode, operands); DONE;")
6537
6538 ;; %%% Potential partial reg stall on alternative 2. What to do?
6539 (define_insn "*addqi_1_lea"
6540 [(set (match_operand:QI 0 "nonimmediate_operand" "=qm,q,r,r")
6541 (plus:QI (match_operand:QI 1 "nonimmediate_operand" "%0,0,0,r")
6542 (match_operand:QI 2 "general_operand" "qn,qmn,rn,rn")))
6543 (clobber (reg:CC 17))]
6544 "!TARGET_PARTIAL_REG_STALL
6545 && ix86_binary_operator_ok (PLUS, QImode, operands)"
6546 {
6547 int widen = (which_alternative == 2);
6548 switch (get_attr_type (insn))
6549 {
6550 case TYPE_LEA:
6551 return "#";
6552 case TYPE_INCDEC:
6553 if (operands[2] == const1_rtx)
6554 return widen ? "inc{l}\t%k0" : "inc{b}\t%0";
6555 else if (operands[2] == constm1_rtx
6556 || (GET_CODE (operands[2]) == CONST_INT
6557 && INTVAL (operands[2]) == 255))
6558 return widen ? "dec{l}\t%k0" : "dec{b}\t%0";
6559 abort();
6560
6561 default:
6562 /* Make things pretty and `subl $4,%eax' rather than `addl $-4, %eax'.
6563 Exceptions: -128 encodes smaller than 128, so swap sign and op. */
6564 if (GET_CODE (operands[2]) == CONST_INT
6565 && (INTVAL (operands[2]) == 128
6566 || (INTVAL (operands[2]) < 0
6567 && INTVAL (operands[2]) != -128)))
6568 {
6569 operands[2] = GEN_INT (-INTVAL (operands[2]));
6570 if (widen)
6571 return "sub{l}\t{%2, %k0|%k0, %2}";
6572 else
6573 return "sub{b}\t{%2, %0|%0, %2}";
6574 }
6575 if (widen)
6576 return "add{l}\t{%k2, %k0|%k0, %k2}";
6577 else
6578 return "add{b}\t{%2, %0|%0, %2}";
6579 }
6580 }
6581 [(set (attr "type")
6582 (if_then_else (eq_attr "alternative" "3")
6583 (const_string "lea")
6584 (if_then_else (match_operand:QI 2 "incdec_operand" "")
6585 (const_string "incdec")
6586 (const_string "alu"))))
6587 (set_attr "mode" "QI,QI,SI,SI")])
6588
6589 (define_insn "*addqi_1"
6590 [(set (match_operand:QI 0 "nonimmediate_operand" "=qm,q,r")
6591 (plus:QI (match_operand:QI 1 "nonimmediate_operand" "%0,0,0")
6592 (match_operand:QI 2 "general_operand" "qn,qmn,rn")))
6593 (clobber (reg:CC 17))]
6594 "TARGET_PARTIAL_REG_STALL
6595 && ix86_binary_operator_ok (PLUS, QImode, operands)"
6596 {
6597 int widen = (which_alternative == 2);
6598 switch (get_attr_type (insn))
6599 {
6600 case TYPE_INCDEC:
6601 if (operands[2] == const1_rtx)
6602 return widen ? "inc{l}\t%k0" : "inc{b}\t%0";
6603 else if (operands[2] == constm1_rtx
6604 || (GET_CODE (operands[2]) == CONST_INT
6605 && INTVAL (operands[2]) == 255))
6606 return widen ? "dec{l}\t%k0" : "dec{b}\t%0";
6607 abort();
6608
6609 default:
6610 /* Make things pretty and `subl $4,%eax' rather than `addl $-4, %eax'.
6611 Exceptions: -128 encodes smaller than 128, so swap sign and op. */
6612 if (GET_CODE (operands[2]) == CONST_INT
6613 && (INTVAL (operands[2]) == 128
6614 || (INTVAL (operands[2]) < 0
6615 && INTVAL (operands[2]) != -128)))
6616 {
6617 operands[2] = GEN_INT (-INTVAL (operands[2]));
6618 if (widen)
6619 return "sub{l}\t{%2, %k0|%k0, %2}";
6620 else
6621 return "sub{b}\t{%2, %0|%0, %2}";
6622 }
6623 if (widen)
6624 return "add{l}\t{%k2, %k0|%k0, %k2}";
6625 else
6626 return "add{b}\t{%2, %0|%0, %2}";
6627 }
6628 }
6629 [(set (attr "type")
6630 (if_then_else (match_operand:QI 2 "incdec_operand" "")
6631 (const_string "incdec")
6632 (const_string "alu")))
6633 (set_attr "mode" "QI,QI,SI")])
6634
6635 (define_insn "*addqi_2"
6636 [(set (reg 17)
6637 (compare
6638 (plus:QI (match_operand:QI 1 "nonimmediate_operand" "%0,0")
6639 (match_operand:QI 2 "general_operand" "qmni,qni"))
6640 (const_int 0)))
6641 (set (match_operand:QI 0 "nonimmediate_operand" "=q,qm")
6642 (plus:QI (match_dup 1) (match_dup 2)))]
6643 "ix86_match_ccmode (insn, CCGOCmode)
6644 && ix86_binary_operator_ok (PLUS, QImode, operands)"
6645 {
6646 switch (get_attr_type (insn))
6647 {
6648 case TYPE_INCDEC:
6649 if (operands[2] == const1_rtx)
6650 return "inc{b}\t%0";
6651 else if (operands[2] == constm1_rtx
6652 || (GET_CODE (operands[2]) == CONST_INT
6653 && INTVAL (operands[2]) == 255))
6654 return "dec{b}\t%0";
6655 abort();
6656
6657 default:
6658 /* Make things pretty and `subb $4,%al' rather than `addb $-4, %al'. */
6659 if (GET_CODE (operands[2]) == CONST_INT
6660 && INTVAL (operands[2]) < 0)
6661 {
6662 operands[2] = GEN_INT (-INTVAL (operands[2]));
6663 return "sub{b}\t{%2, %0|%0, %2}";
6664 }
6665 return "add{b}\t{%2, %0|%0, %2}";
6666 }
6667 }
6668 [(set (attr "type")
6669 (if_then_else (match_operand:QI 2 "incdec_operand" "")
6670 (const_string "incdec")
6671 (const_string "alu")))
6672 (set_attr "mode" "QI")])
6673
6674 (define_insn "*addqi_3"
6675 [(set (reg 17)
6676 (compare (neg:QI (match_operand:QI 2 "general_operand" "qmni"))
6677 (match_operand:QI 1 "nonimmediate_operand" "%0")))
6678 (clobber (match_scratch:QI 0 "=q"))]
6679 "ix86_match_ccmode (insn, CCZmode)
6680 && (GET_CODE (operands[1]) != MEM || GET_CODE (operands[2]) != MEM)"
6681 {
6682 switch (get_attr_type (insn))
6683 {
6684 case TYPE_INCDEC:
6685 if (operands[2] == const1_rtx)
6686 return "inc{b}\t%0";
6687 else if (operands[2] == constm1_rtx
6688 || (GET_CODE (operands[2]) == CONST_INT
6689 && INTVAL (operands[2]) == 255))
6690 return "dec{b}\t%0";
6691 abort();
6692
6693 default:
6694 /* Make things pretty and `subb $4,%al' rather than `addb $-4, %al'. */
6695 if (GET_CODE (operands[2]) == CONST_INT
6696 && INTVAL (operands[2]) < 0)
6697 {
6698 operands[2] = GEN_INT (-INTVAL (operands[2]));
6699 return "sub{b}\t{%2, %0|%0, %2}";
6700 }
6701 return "add{b}\t{%2, %0|%0, %2}";
6702 }
6703 }
6704 [(set (attr "type")
6705 (if_then_else (match_operand:QI 2 "incdec_operand" "")
6706 (const_string "incdec")
6707 (const_string "alu")))
6708 (set_attr "mode" "QI")])
6709
6710 ; See comments above addsi_3_imm for details.
6711 (define_insn "*addqi_4"
6712 [(set (reg 17)
6713 (compare (match_operand:QI 1 "nonimmediate_operand" "0")
6714 (match_operand:QI 2 "const_int_operand" "n")))
6715 (clobber (match_scratch:QI 0 "=qm"))]
6716 "ix86_match_ccmode (insn, CCGCmode)
6717 && (INTVAL (operands[2]) & 0xff) != 0x80"
6718 {
6719 switch (get_attr_type (insn))
6720 {
6721 case TYPE_INCDEC:
6722 if (operands[2] == constm1_rtx
6723 || (GET_CODE (operands[2]) == CONST_INT
6724 && INTVAL (operands[2]) == 255))
6725 return "inc{b}\t%0";
6726 else if (operands[2] == const1_rtx)
6727 return "dec{b}\t%0";
6728 else
6729 abort();
6730
6731 default:
6732 if (! rtx_equal_p (operands[0], operands[1]))
6733 abort ();
6734 if (INTVAL (operands[2]) < 0)
6735 {
6736 operands[2] = GEN_INT (-INTVAL (operands[2]));
6737 return "add{b}\t{%2, %0|%0, %2}";
6738 }
6739 return "sub{b}\t{%2, %0|%0, %2}";
6740 }
6741 }
6742 [(set (attr "type")
6743 (if_then_else (match_operand:HI 2 "incdec_operand" "")
6744 (const_string "incdec")
6745 (const_string "alu")))
6746 (set_attr "mode" "QI")])
6747
6748
6749 (define_insn "*addqi_5"
6750 [(set (reg 17)
6751 (compare
6752 (plus:QI (match_operand:QI 1 "nonimmediate_operand" "%0")
6753 (match_operand:QI 2 "general_operand" "qmni"))
6754 (const_int 0)))
6755 (clobber (match_scratch:QI 0 "=q"))]
6756 "ix86_match_ccmode (insn, CCGOCmode)
6757 && (GET_CODE (operands[1]) != MEM || GET_CODE (operands[2]) != MEM)"
6758 {
6759 switch (get_attr_type (insn))
6760 {
6761 case TYPE_INCDEC:
6762 if (operands[2] == const1_rtx)
6763 return "inc{b}\t%0";
6764 else if (operands[2] == constm1_rtx
6765 || (GET_CODE (operands[2]) == CONST_INT
6766 && INTVAL (operands[2]) == 255))
6767 return "dec{b}\t%0";
6768 abort();
6769
6770 default:
6771 /* Make things pretty and `subb $4,%al' rather than `addb $-4, %al'. */
6772 if (GET_CODE (operands[2]) == CONST_INT
6773 && INTVAL (operands[2]) < 0)
6774 {
6775 operands[2] = GEN_INT (-INTVAL (operands[2]));
6776 return "sub{b}\t{%2, %0|%0, %2}";
6777 }
6778 return "add{b}\t{%2, %0|%0, %2}";
6779 }
6780 }
6781 [(set (attr "type")
6782 (if_then_else (match_operand:QI 2 "incdec_operand" "")
6783 (const_string "incdec")
6784 (const_string "alu")))
6785 (set_attr "mode" "QI")])
6786
6787
6788 (define_insn "addqi_ext_1"
6789 [(set (zero_extract:SI (match_operand 0 "ext_register_operand" "=Q")
6790 (const_int 8)
6791 (const_int 8))
6792 (plus:SI
6793 (zero_extract:SI
6794 (match_operand 1 "ext_register_operand" "0")
6795 (const_int 8)
6796 (const_int 8))
6797 (match_operand:QI 2 "general_operand" "Qmn")))
6798 (clobber (reg:CC 17))]
6799 "!TARGET_64BIT"
6800 {
6801 switch (get_attr_type (insn))
6802 {
6803 case TYPE_INCDEC:
6804 if (operands[2] == const1_rtx)
6805 return "inc{b}\t%h0";
6806 else if (operands[2] == constm1_rtx
6807 || (GET_CODE (operands[2]) == CONST_INT
6808 && INTVAL (operands[2]) == 255))
6809 return "dec{b}\t%h0";
6810 abort();
6811
6812 default:
6813 return "add{b}\t{%2, %h0|%h0, %2}";
6814 }
6815 }
6816 [(set (attr "type")
6817 (if_then_else (match_operand:QI 2 "incdec_operand" "")
6818 (const_string "incdec")
6819 (const_string "alu")))
6820 (set_attr "mode" "QI")])
6821
6822 (define_insn "*addqi_ext_1_rex64"
6823 [(set (zero_extract:SI (match_operand 0 "ext_register_operand" "=Q")
6824 (const_int 8)
6825 (const_int 8))
6826 (plus:SI
6827 (zero_extract:SI
6828 (match_operand 1 "ext_register_operand" "0")
6829 (const_int 8)
6830 (const_int 8))
6831 (match_operand:QI 2 "nonmemory_operand" "Qn")))
6832 (clobber (reg:CC 17))]
6833 "TARGET_64BIT"
6834 {
6835 switch (get_attr_type (insn))
6836 {
6837 case TYPE_INCDEC:
6838 if (operands[2] == const1_rtx)
6839 return "inc{b}\t%h0";
6840 else if (operands[2] == constm1_rtx
6841 || (GET_CODE (operands[2]) == CONST_INT
6842 && INTVAL (operands[2]) == 255))
6843 return "dec{b}\t%h0";
6844 abort();
6845
6846 default:
6847 return "add{b}\t{%2, %h0|%h0, %2}";
6848 }
6849 }
6850 [(set (attr "type")
6851 (if_then_else (match_operand:QI 2 "incdec_operand" "")
6852 (const_string "incdec")
6853 (const_string "alu")))
6854 (set_attr "mode" "QI")])
6855
6856 (define_insn "*addqi_ext_2"
6857 [(set (zero_extract:SI (match_operand 0 "ext_register_operand" "=Q")
6858 (const_int 8)
6859 (const_int 8))
6860 (plus:SI
6861 (zero_extract:SI
6862 (match_operand 1 "ext_register_operand" "%0")
6863 (const_int 8)
6864 (const_int 8))
6865 (zero_extract:SI
6866 (match_operand 2 "ext_register_operand" "Q")
6867 (const_int 8)
6868 (const_int 8))))
6869 (clobber (reg:CC 17))]
6870 ""
6871 "add{b}\t{%h2, %h0|%h0, %h2}"
6872 [(set_attr "type" "alu")
6873 (set_attr "mode" "QI")])
6874
6875 ;; The patterns that match these are at the end of this file.
6876
6877 (define_expand "addxf3"
6878 [(set (match_operand:XF 0 "register_operand" "")
6879 (plus:XF (match_operand:XF 1 "register_operand" "")
6880 (match_operand:XF 2 "register_operand" "")))]
6881 "!TARGET_64BIT && TARGET_80387"
6882 "")
6883
6884 (define_expand "addtf3"
6885 [(set (match_operand:TF 0 "register_operand" "")
6886 (plus:TF (match_operand:TF 1 "register_operand" "")
6887 (match_operand:TF 2 "register_operand" "")))]
6888 "TARGET_80387"
6889 "")
6890
6891 (define_expand "adddf3"
6892 [(set (match_operand:DF 0 "register_operand" "")
6893 (plus:DF (match_operand:DF 1 "register_operand" "")
6894 (match_operand:DF 2 "nonimmediate_operand" "")))]
6895 "TARGET_80387 || (TARGET_SSE2 && TARGET_SSE_MATH)"
6896 "")
6897
6898 (define_expand "addsf3"
6899 [(set (match_operand:SF 0 "register_operand" "")
6900 (plus:SF (match_operand:SF 1 "register_operand" "")
6901 (match_operand:SF 2 "nonimmediate_operand" "")))]
6902 "TARGET_80387 || TARGET_SSE_MATH"
6903 "")
6904 \f
6905 ;; Subtract instructions
6906
6907 ;; %%% splits for subsidi3
6908
6909 (define_expand "subdi3"
6910 [(parallel [(set (match_operand:DI 0 "nonimmediate_operand" "")
6911 (minus:DI (match_operand:DI 1 "nonimmediate_operand" "")
6912 (match_operand:DI 2 "x86_64_general_operand" "")))
6913 (clobber (reg:CC 17))])]
6914 ""
6915 "ix86_expand_binary_operator (MINUS, DImode, operands); DONE;")
6916
6917 (define_insn "*subdi3_1"
6918 [(set (match_operand:DI 0 "nonimmediate_operand" "=r,o")
6919 (minus:DI (match_operand:DI 1 "nonimmediate_operand" "0,0")
6920 (match_operand:DI 2 "general_operand" "roiF,riF")))
6921 (clobber (reg:CC 17))]
6922 "!TARGET_64BIT"
6923 "#")
6924
6925 (define_split
6926 [(set (match_operand:DI 0 "nonimmediate_operand" "")
6927 (minus:DI (match_operand:DI 1 "nonimmediate_operand" "")
6928 (match_operand:DI 2 "general_operand" "")))
6929 (clobber (reg:CC 17))]
6930 "!TARGET_64BIT && reload_completed"
6931 [(parallel [(set (reg:CC 17) (compare:CC (match_dup 1) (match_dup 2)))
6932 (set (match_dup 0) (minus:SI (match_dup 1) (match_dup 2)))])
6933 (parallel [(set (match_dup 3)
6934 (minus:SI (match_dup 4)
6935 (plus:SI (ltu:SI (reg:CC 17) (const_int 0))
6936 (match_dup 5))))
6937 (clobber (reg:CC 17))])]
6938 "split_di (operands+0, 1, operands+0, operands+3);
6939 split_di (operands+1, 1, operands+1, operands+4);
6940 split_di (operands+2, 1, operands+2, operands+5);")
6941
6942 (define_insn "subdi3_carry_rex64"
6943 [(set (match_operand:DI 0 "nonimmediate_operand" "=rm,r")
6944 (minus:DI (match_operand:DI 1 "nonimmediate_operand" "0,0")
6945 (plus:DI (ltu:DI (reg:CC 17) (const_int 0))
6946 (match_operand:DI 2 "x86_64_general_operand" "re,rm"))))
6947 (clobber (reg:CC 17))]
6948 "TARGET_64BIT && ix86_binary_operator_ok (MINUS, DImode, operands)"
6949 "sbb{q}\t{%2, %0|%0, %2}"
6950 [(set_attr "type" "alu")
6951 (set_attr "pent_pair" "pu")
6952 (set_attr "ppro_uops" "few")
6953 (set_attr "mode" "DI")])
6954
6955 (define_insn "*subdi_1_rex64"
6956 [(set (match_operand:DI 0 "nonimmediate_operand" "=rm,r")
6957 (minus:DI (match_operand:DI 1 "nonimmediate_operand" "0,0")
6958 (match_operand:DI 2 "x86_64_general_operand" "re,rm")))
6959 (clobber (reg:CC 17))]
6960 "TARGET_64BIT && ix86_binary_operator_ok (MINUS, DImode, operands)"
6961 "sub{q}\t{%2, %0|%0, %2}"
6962 [(set_attr "type" "alu")
6963 (set_attr "mode" "DI")])
6964
6965 (define_insn "*subdi_2_rex64"
6966 [(set (reg 17)
6967 (compare
6968 (minus:DI (match_operand:DI 1 "nonimmediate_operand" "0,0")
6969 (match_operand:DI 2 "x86_64_general_operand" "re,rm"))
6970 (const_int 0)))
6971 (set (match_operand:DI 0 "nonimmediate_operand" "=rm,r")
6972 (minus:DI (match_dup 1) (match_dup 2)))]
6973 "TARGET_64BIT && ix86_match_ccmode (insn, CCGOCmode)
6974 && ix86_binary_operator_ok (MINUS, DImode, operands)"
6975 "sub{q}\t{%2, %0|%0, %2}"
6976 [(set_attr "type" "alu")
6977 (set_attr "mode" "DI")])
6978
6979 (define_insn "*subdi_3_rex63"
6980 [(set (reg 17)
6981 (compare (match_operand:DI 1 "nonimmediate_operand" "0,0")
6982 (match_operand:DI 2 "x86_64_general_operand" "re,rm")))
6983 (set (match_operand:DI 0 "nonimmediate_operand" "=rm,r")
6984 (minus:DI (match_dup 1) (match_dup 2)))]
6985 "TARGET_64BIT && ix86_match_ccmode (insn, CCmode)
6986 && ix86_binary_operator_ok (MINUS, SImode, operands)"
6987 "sub{q}\t{%2, %0|%0, %2}"
6988 [(set_attr "type" "alu")
6989 (set_attr "mode" "DI")])
6990
6991
6992 (define_insn "subsi3_carry"
6993 [(set (match_operand:SI 0 "nonimmediate_operand" "=rm,r")
6994 (minus:SI (match_operand:SI 1 "nonimmediate_operand" "0,0")
6995 (plus:SI (ltu:SI (reg:CC 17) (const_int 0))
6996 (match_operand:SI 2 "general_operand" "ri,rm"))))
6997 (clobber (reg:CC 17))]
6998 "ix86_binary_operator_ok (MINUS, SImode, operands)"
6999 "sbb{l}\t{%2, %0|%0, %2}"
7000 [(set_attr "type" "alu")
7001 (set_attr "pent_pair" "pu")
7002 (set_attr "ppro_uops" "few")
7003 (set_attr "mode" "SI")])
7004
7005 (define_insn "subsi3_carry_zext"
7006 [(set (match_operand:DI 0 "register_operand" "=rm,r")
7007 (zero_extend:DI
7008 (minus:SI (match_operand:SI 1 "register_operand" "0,0")
7009 (plus:SI (ltu:SI (reg:CC 17) (const_int 0))
7010 (match_operand:SI 2 "general_operand" "ri,rm")))))
7011 (clobber (reg:CC 17))]
7012 "TARGET_64BIT && ix86_binary_operator_ok (MINUS, SImode, operands)"
7013 "sbb{l}\t{%2, %k0|%k0, %2}"
7014 [(set_attr "type" "alu")
7015 (set_attr "pent_pair" "pu")
7016 (set_attr "ppro_uops" "few")
7017 (set_attr "mode" "SI")])
7018
7019 (define_expand "subsi3"
7020 [(parallel [(set (match_operand:SI 0 "nonimmediate_operand" "")
7021 (minus:SI (match_operand:SI 1 "nonimmediate_operand" "")
7022 (match_operand:SI 2 "general_operand" "")))
7023 (clobber (reg:CC 17))])]
7024 ""
7025 "ix86_expand_binary_operator (MINUS, SImode, operands); DONE;")
7026
7027 (define_insn "*subsi_1"
7028 [(set (match_operand:SI 0 "nonimmediate_operand" "=rm,r")
7029 (minus:SI (match_operand:SI 1 "nonimmediate_operand" "0,0")
7030 (match_operand:SI 2 "general_operand" "ri,rm")))
7031 (clobber (reg:CC 17))]
7032 "ix86_binary_operator_ok (MINUS, SImode, operands)"
7033 "sub{l}\t{%2, %0|%0, %2}"
7034 [(set_attr "type" "alu")
7035 (set_attr "mode" "SI")])
7036
7037 (define_insn "*subsi_1_zext"
7038 [(set (match_operand:DI 0 "register_operand" "=r")
7039 (zero_extend:DI
7040 (minus:SI (match_operand:SI 1 "register_operand" "0")
7041 (match_operand:SI 2 "general_operand" "rim"))))
7042 (clobber (reg:CC 17))]
7043 "TARGET_64BIT && ix86_binary_operator_ok (MINUS, SImode, operands)"
7044 "sub{l}\t{%2, %k0|%k0, %2}"
7045 [(set_attr "type" "alu")
7046 (set_attr "mode" "SI")])
7047
7048 (define_insn "*subsi_2"
7049 [(set (reg 17)
7050 (compare
7051 (minus:SI (match_operand:SI 1 "nonimmediate_operand" "0,0")
7052 (match_operand:SI 2 "general_operand" "ri,rm"))
7053 (const_int 0)))
7054 (set (match_operand:SI 0 "nonimmediate_operand" "=rm,r")
7055 (minus:SI (match_dup 1) (match_dup 2)))]
7056 "ix86_match_ccmode (insn, CCGOCmode)
7057 && ix86_binary_operator_ok (MINUS, SImode, operands)"
7058 "sub{l}\t{%2, %0|%0, %2}"
7059 [(set_attr "type" "alu")
7060 (set_attr "mode" "SI")])
7061
7062 (define_insn "*subsi_2_zext"
7063 [(set (reg 17)
7064 (compare
7065 (minus:SI (match_operand:SI 1 "register_operand" "0")
7066 (match_operand:SI 2 "general_operand" "rim"))
7067 (const_int 0)))
7068 (set (match_operand:DI 0 "register_operand" "=r")
7069 (zero_extend:DI
7070 (minus:SI (match_dup 1)
7071 (match_dup 2))))]
7072 "TARGET_64BIT && ix86_match_ccmode (insn, CCGOCmode)
7073 && ix86_binary_operator_ok (MINUS, SImode, operands)"
7074 "sub{l}\t{%2, %k0|%k0, %2}"
7075 [(set_attr "type" "alu")
7076 (set_attr "mode" "SI")])
7077
7078 (define_insn "*subsi_3"
7079 [(set (reg 17)
7080 (compare (match_operand:SI 1 "nonimmediate_operand" "0,0")
7081 (match_operand:SI 2 "general_operand" "ri,rm")))
7082 (set (match_operand:SI 0 "nonimmediate_operand" "=rm,r")
7083 (minus:SI (match_dup 1) (match_dup 2)))]
7084 "ix86_match_ccmode (insn, CCmode)
7085 && ix86_binary_operator_ok (MINUS, SImode, operands)"
7086 "sub{l}\t{%2, %0|%0, %2}"
7087 [(set_attr "type" "alu")
7088 (set_attr "mode" "SI")])
7089
7090 (define_insn "*subsi_3_zext"
7091 [(set (reg 17)
7092 (compare (match_operand:SI 1 "nonimmediate_operand" "0")
7093 (match_operand:SI 2 "general_operand" "rim")))
7094 (set (match_operand:DI 0 "register_operand" "=r")
7095 (zero_extend:DI
7096 (minus:SI (match_dup 1)
7097 (match_dup 2))))]
7098 "TARGET_64BIT && ix86_match_ccmode (insn, CCmode)
7099 && ix86_binary_operator_ok (MINUS, SImode, operands)"
7100 "sub{q}\t{%2, %0|%0, %2}"
7101 [(set_attr "type" "alu")
7102 (set_attr "mode" "DI")])
7103
7104 (define_expand "subhi3"
7105 [(parallel [(set (match_operand:HI 0 "nonimmediate_operand" "")
7106 (minus:HI (match_operand:HI 1 "nonimmediate_operand" "")
7107 (match_operand:HI 2 "general_operand" "")))
7108 (clobber (reg:CC 17))])]
7109 "TARGET_HIMODE_MATH"
7110 "ix86_expand_binary_operator (MINUS, HImode, operands); DONE;")
7111
7112 (define_insn "*subhi_1"
7113 [(set (match_operand:HI 0 "nonimmediate_operand" "=rm,r")
7114 (minus:HI (match_operand:HI 1 "nonimmediate_operand" "0,0")
7115 (match_operand:HI 2 "general_operand" "ri,rm")))
7116 (clobber (reg:CC 17))]
7117 "ix86_binary_operator_ok (MINUS, HImode, operands)"
7118 "sub{w}\t{%2, %0|%0, %2}"
7119 [(set_attr "type" "alu")
7120 (set_attr "mode" "HI")])
7121
7122 (define_insn "*subhi_2"
7123 [(set (reg 17)
7124 (compare
7125 (minus:HI (match_operand:HI 1 "nonimmediate_operand" "0,0")
7126 (match_operand:HI 2 "general_operand" "ri,rm"))
7127 (const_int 0)))
7128 (set (match_operand:HI 0 "nonimmediate_operand" "=rm,r")
7129 (minus:HI (match_dup 1) (match_dup 2)))]
7130 "ix86_match_ccmode (insn, CCGOCmode)
7131 && ix86_binary_operator_ok (MINUS, HImode, operands)"
7132 "sub{w}\t{%2, %0|%0, %2}"
7133 [(set_attr "type" "alu")
7134 (set_attr "mode" "HI")])
7135
7136 (define_insn "*subhi_3"
7137 [(set (reg 17)
7138 (compare (match_operand:HI 1 "nonimmediate_operand" "0,0")
7139 (match_operand:HI 2 "general_operand" "ri,rm")))
7140 (set (match_operand:HI 0 "nonimmediate_operand" "=rm,r")
7141 (minus:HI (match_dup 1) (match_dup 2)))]
7142 "ix86_match_ccmode (insn, CCmode)
7143 && ix86_binary_operator_ok (MINUS, HImode, operands)"
7144 "sub{w}\t{%2, %0|%0, %2}"
7145 [(set_attr "type" "alu")
7146 (set_attr "mode" "HI")])
7147
7148 (define_expand "subqi3"
7149 [(parallel [(set (match_operand:QI 0 "nonimmediate_operand" "")
7150 (minus:QI (match_operand:QI 1 "nonimmediate_operand" "")
7151 (match_operand:QI 2 "general_operand" "")))
7152 (clobber (reg:CC 17))])]
7153 "TARGET_QIMODE_MATH"
7154 "ix86_expand_binary_operator (MINUS, QImode, operands); DONE;")
7155
7156 (define_insn "*subqi_1"
7157 [(set (match_operand:QI 0 "nonimmediate_operand" "=qm,q")
7158 (minus:QI (match_operand:QI 1 "nonimmediate_operand" "0,0")
7159 (match_operand:QI 2 "general_operand" "qn,qmn")))
7160 (clobber (reg:CC 17))]
7161 "ix86_binary_operator_ok (MINUS, QImode, operands)"
7162 "sub{b}\t{%2, %0|%0, %2}"
7163 [(set_attr "type" "alu")
7164 (set_attr "mode" "QI")])
7165
7166 (define_insn "*subqi_2"
7167 [(set (reg 17)
7168 (compare
7169 (minus:QI (match_operand:QI 1 "nonimmediate_operand" "0,0")
7170 (match_operand:QI 2 "general_operand" "qi,qm"))
7171 (const_int 0)))
7172 (set (match_operand:HI 0 "nonimmediate_operand" "=qm,q")
7173 (minus:HI (match_dup 1) (match_dup 2)))]
7174 "ix86_match_ccmode (insn, CCGOCmode)
7175 && ix86_binary_operator_ok (MINUS, QImode, operands)"
7176 "sub{b}\t{%2, %0|%0, %2}"
7177 [(set_attr "type" "alu")
7178 (set_attr "mode" "QI")])
7179
7180 (define_insn "*subqi_3"
7181 [(set (reg 17)
7182 (compare (match_operand:QI 1 "nonimmediate_operand" "0,0")
7183 (match_operand:QI 2 "general_operand" "qi,qm")))
7184 (set (match_operand:HI 0 "nonimmediate_operand" "=qm,q")
7185 (minus:HI (match_dup 1) (match_dup 2)))]
7186 "ix86_match_ccmode (insn, CCmode)
7187 && ix86_binary_operator_ok (MINUS, QImode, operands)"
7188 "sub{b}\t{%2, %0|%0, %2}"
7189 [(set_attr "type" "alu")
7190 (set_attr "mode" "QI")])
7191
7192 ;; The patterns that match these are at the end of this file.
7193
7194 (define_expand "subxf3"
7195 [(set (match_operand:XF 0 "register_operand" "")
7196 (minus:XF (match_operand:XF 1 "register_operand" "")
7197 (match_operand:XF 2 "register_operand" "")))]
7198 "!TARGET_64BIT && TARGET_80387"
7199 "")
7200
7201 (define_expand "subtf3"
7202 [(set (match_operand:TF 0 "register_operand" "")
7203 (minus:TF (match_operand:TF 1 "register_operand" "")
7204 (match_operand:TF 2 "register_operand" "")))]
7205 "TARGET_80387"
7206 "")
7207
7208 (define_expand "subdf3"
7209 [(set (match_operand:DF 0 "register_operand" "")
7210 (minus:DF (match_operand:DF 1 "register_operand" "")
7211 (match_operand:DF 2 "nonimmediate_operand" "")))]
7212 "TARGET_80387 || (TARGET_SSE2 && TARGET_SSE_MATH)"
7213 "")
7214
7215 (define_expand "subsf3"
7216 [(set (match_operand:SF 0 "register_operand" "")
7217 (minus:SF (match_operand:SF 1 "register_operand" "")
7218 (match_operand:SF 2 "nonimmediate_operand" "")))]
7219 "TARGET_80387 || TARGET_SSE_MATH"
7220 "")
7221 \f
7222 ;; Multiply instructions
7223
7224 (define_expand "muldi3"
7225 [(parallel [(set (match_operand:DI 0 "register_operand" "")
7226 (mult:DI (match_operand:DI 1 "register_operand" "")
7227 (match_operand:DI 2 "x86_64_general_operand" "")))
7228 (clobber (reg:CC 17))])]
7229 "TARGET_64BIT"
7230 "")
7231
7232 (define_insn "*muldi3_1_rex64"
7233 [(set (match_operand:DI 0 "register_operand" "=r,r,r")
7234 (mult:DI (match_operand:DI 1 "nonimmediate_operand" "%rm,0,0")
7235 (match_operand:DI 2 "x86_64_general_operand" "K,e,mr")))
7236 (clobber (reg:CC 17))]
7237 "TARGET_64BIT
7238 && (GET_CODE (operands[1]) != MEM || GET_CODE (operands[2]) != MEM)"
7239 "@
7240 imul{q}\t{%2, %1, %0|%0, %1, %2}
7241 imul{q}\t{%2, %1, %0|%0, %1, %2}
7242 imul{q}\t{%2, %0|%0, %2}"
7243 [(set_attr "type" "imul")
7244 (set_attr "prefix_0f" "0,0,1")
7245 (set_attr "mode" "DI")])
7246
7247 (define_expand "mulsi3"
7248 [(parallel [(set (match_operand:SI 0 "register_operand" "")
7249 (mult:SI (match_operand:SI 1 "register_operand" "")
7250 (match_operand:SI 2 "general_operand" "")))
7251 (clobber (reg:CC 17))])]
7252 ""
7253 "")
7254
7255 (define_insn "*mulsi3_1"
7256 [(set (match_operand:SI 0 "register_operand" "=r,r,r")
7257 (mult:SI (match_operand:SI 1 "nonimmediate_operand" "%rm,0,0")
7258 (match_operand:SI 2 "general_operand" "K,i,mr")))
7259 (clobber (reg:CC 17))]
7260 "GET_CODE (operands[1]) != MEM || GET_CODE (operands[2]) != MEM"
7261 ; For the {r,0,i} alternative (i.e., register <- register * immediate),
7262 ; there are two ways of writing the exact same machine instruction
7263 ; in assembly language. One, for example, is:
7264 ;
7265 ; imul $12, %eax
7266 ;
7267 ; while the other is:
7268 ;
7269 ; imul $12, %eax, %eax
7270 ;
7271 ; The first is simply short-hand for the latter. But, some assemblers,
7272 ; like the SCO OSR5 COFF assembler, don't handle the first form.
7273 "@
7274 imul{l}\t{%2, %1, %0|%0, %1, %2}
7275 imul{l}\t{%2, %1, %0|%0, %1, %2}
7276 imul{l}\t{%2, %0|%0, %2}"
7277 [(set_attr "type" "imul")
7278 (set_attr "prefix_0f" "0,0,1")
7279 (set_attr "mode" "SI")])
7280
7281 (define_insn "*mulsi3_1_zext"
7282 [(set (match_operand:DI 0 "register_operand" "=r,r,r")
7283 (zero_extend:DI
7284 (mult:SI (match_operand:SI 1 "nonimmediate_operand" "%rm,0,0")
7285 (match_operand:SI 2 "general_operand" "K,i,mr"))))
7286 (clobber (reg:CC 17))]
7287 "TARGET_64BIT
7288 && (GET_CODE (operands[1]) != MEM || GET_CODE (operands[2]) != MEM)"
7289 ; For the {r,0,i} alternative (i.e., register <- register * immediate),
7290 ; there are two ways of writing the exact same machine instruction
7291 ; in assembly language. One, for example, is:
7292 ;
7293 ; imul $12, %eax
7294 ;
7295 ; while the other is:
7296 ;
7297 ; imul $12, %eax, %eax
7298 ;
7299 ; The first is simply short-hand for the latter. But, some assemblers,
7300 ; like the SCO OSR5 COFF assembler, don't handle the first form.
7301 "@
7302 imul{l}\t{%2, %1, %k0|%k0, %1, %2}
7303 imul{l}\t{%2, %1, %k0|%k0, %1, %2}
7304 imul{l}\t{%2, %k0|%k0, %2}"
7305 [(set_attr "type" "imul")
7306 (set_attr "prefix_0f" "0,0,1")
7307 (set_attr "mode" "SI")])
7308
7309 (define_expand "mulhi3"
7310 [(parallel [(set (match_operand:HI 0 "register_operand" "")
7311 (mult:HI (match_operand:HI 1 "register_operand" "")
7312 (match_operand:HI 2 "general_operand" "")))
7313 (clobber (reg:CC 17))])]
7314 "TARGET_HIMODE_MATH"
7315 "")
7316
7317 (define_insn "*mulhi3_1"
7318 [(set (match_operand:HI 0 "register_operand" "=r,r,r")
7319 (mult:HI (match_operand:HI 1 "nonimmediate_operand" "%rm,0,0")
7320 (match_operand:HI 2 "general_operand" "K,i,mr")))
7321 (clobber (reg:CC 17))]
7322 "GET_CODE (operands[1]) != MEM || GET_CODE (operands[2]) != MEM"
7323 ; %%% There was a note about "Assembler has weird restrictions",
7324 ; concerning alternative 1 when op1 == op0. True?
7325 "@
7326 imul{w}\t{%2, %1, %0|%0, %1, %2}
7327 imul{w}\t{%2, %1, %0|%0, %1, %2}
7328 imul{w}\t{%2, %0|%0, %2}"
7329 [(set_attr "type" "imul")
7330 (set_attr "prefix_0f" "0,0,1")
7331 (set_attr "mode" "HI")])
7332
7333 (define_insn "mulqi3"
7334 [(set (match_operand:QI 0 "register_operand" "=a")
7335 (mult:QI (match_operand:QI 1 "register_operand" "%0")
7336 (match_operand:QI 2 "nonimmediate_operand" "qm")))
7337 (clobber (reg:CC 17))]
7338 "TARGET_QIMODE_MATH"
7339 "mul{b}\t%2"
7340 [(set_attr "type" "imul")
7341 (set_attr "length_immediate" "0")
7342 (set_attr "mode" "QI")])
7343
7344 (define_insn "umulqihi3"
7345 [(set (match_operand:HI 0 "register_operand" "=a")
7346 (mult:HI (zero_extend:HI (match_operand:QI 1 "register_operand" "%0"))
7347 (zero_extend:HI (match_operand:QI 2 "nonimmediate_operand" "qm"))))
7348 (clobber (reg:CC 17))]
7349 "TARGET_QIMODE_MATH"
7350 "mul{b}\t%2"
7351 [(set_attr "type" "imul")
7352 (set_attr "length_immediate" "0")
7353 (set_attr "mode" "QI")])
7354
7355 (define_insn "mulqihi3"
7356 [(set (match_operand:HI 0 "register_operand" "=a")
7357 (mult:HI (sign_extend:HI (match_operand:QI 1 "register_operand" "%0"))
7358 (sign_extend:HI (match_operand:QI 2 "nonimmediate_operand" "qm"))))
7359 (clobber (reg:CC 17))]
7360 "TARGET_QIMODE_MATH"
7361 "imul{b}\t%2"
7362 [(set_attr "type" "imul")
7363 (set_attr "length_immediate" "0")
7364 (set_attr "mode" "QI")])
7365
7366 (define_insn "umulditi3"
7367 [(set (match_operand:TI 0 "register_operand" "=A")
7368 (mult:TI (zero_extend:TI (match_operand:DI 1 "register_operand" "%0"))
7369 (zero_extend:TI (match_operand:DI 2 "nonimmediate_operand" "rm"))))
7370 (clobber (reg:CC 17))]
7371 "TARGET_64BIT"
7372 "mul{q}\t%2"
7373 [(set_attr "type" "imul")
7374 (set_attr "ppro_uops" "few")
7375 (set_attr "length_immediate" "0")
7376 (set_attr "mode" "DI")])
7377
7378 ;; We can't use this pattern in 64bit mode, since it results in two separate 32bit registers
7379 (define_insn "umulsidi3"
7380 [(set (match_operand:DI 0 "register_operand" "=A")
7381 (mult:DI (zero_extend:DI (match_operand:SI 1 "register_operand" "%0"))
7382 (zero_extend:DI (match_operand:SI 2 "nonimmediate_operand" "rm"))))
7383 (clobber (reg:CC 17))]
7384 "!TARGET_64BIT"
7385 "mul{l}\t%2"
7386 [(set_attr "type" "imul")
7387 (set_attr "ppro_uops" "few")
7388 (set_attr "length_immediate" "0")
7389 (set_attr "mode" "SI")])
7390
7391 (define_insn "mulditi3"
7392 [(set (match_operand:TI 0 "register_operand" "=A")
7393 (mult:TI (sign_extend:TI (match_operand:DI 1 "register_operand" "%0"))
7394 (sign_extend:TI (match_operand:DI 2 "nonimmediate_operand" "rm"))))
7395 (clobber (reg:CC 17))]
7396 "TARGET_64BIT"
7397 "imul{q}\t%2"
7398 [(set_attr "type" "imul")
7399 (set_attr "length_immediate" "0")
7400 (set_attr "mode" "DI")])
7401
7402 (define_insn "mulsidi3"
7403 [(set (match_operand:DI 0 "register_operand" "=A")
7404 (mult:DI (sign_extend:DI (match_operand:SI 1 "register_operand" "%0"))
7405 (sign_extend:DI (match_operand:SI 2 "nonimmediate_operand" "rm"))))
7406 (clobber (reg:CC 17))]
7407 "!TARGET_64BIT"
7408 "imul{l}\t%2"
7409 [(set_attr "type" "imul")
7410 (set_attr "length_immediate" "0")
7411 (set_attr "mode" "SI")])
7412
7413 (define_insn "*umuldi3_highpart_rex64"
7414 [(set (match_operand:DI 0 "register_operand" "=d")
7415 (truncate:DI
7416 (lshiftrt:TI
7417 (mult:TI (zero_extend:TI
7418 (match_operand:DI 1 "register_operand" "%a"))
7419 (zero_extend:TI
7420 (match_operand:DI 2 "nonimmediate_operand" "rm")))
7421 (const_int 64))))
7422 (clobber (match_scratch:DI 3 "=a"))
7423 (clobber (reg:CC 17))]
7424 "TARGET_64BIT"
7425 "mul{q}\t%2"
7426 [(set_attr "type" "imul")
7427 (set_attr "ppro_uops" "few")
7428 (set_attr "length_immediate" "0")
7429 (set_attr "mode" "DI")])
7430
7431 (define_insn "umulsi3_highpart"
7432 [(set (match_operand:SI 0 "register_operand" "=d")
7433 (truncate:SI
7434 (lshiftrt:DI
7435 (mult:DI (zero_extend:DI
7436 (match_operand:SI 1 "register_operand" "%a"))
7437 (zero_extend:DI
7438 (match_operand:SI 2 "nonimmediate_operand" "rm")))
7439 (const_int 32))))
7440 (clobber (match_scratch:SI 3 "=a"))
7441 (clobber (reg:CC 17))]
7442 ""
7443 "mul{l}\t%2"
7444 [(set_attr "type" "imul")
7445 (set_attr "ppro_uops" "few")
7446 (set_attr "length_immediate" "0")
7447 (set_attr "mode" "SI")])
7448
7449 (define_insn "*umulsi3_highpart_zext"
7450 [(set (match_operand:DI 0 "register_operand" "=d")
7451 (zero_extend:DI (truncate:SI
7452 (lshiftrt:DI
7453 (mult:DI (zero_extend:DI
7454 (match_operand:SI 1 "register_operand" "%a"))
7455 (zero_extend:DI
7456 (match_operand:SI 2 "nonimmediate_operand" "rm")))
7457 (const_int 32)))))
7458 (clobber (match_scratch:SI 3 "=a"))
7459 (clobber (reg:CC 17))]
7460 "TARGET_64BIT"
7461 "mul{l}\t%2"
7462 [(set_attr "type" "imul")
7463 (set_attr "ppro_uops" "few")
7464 (set_attr "length_immediate" "0")
7465 (set_attr "mode" "SI")])
7466
7467 (define_insn "*smuldi3_highpart_rex64"
7468 [(set (match_operand:DI 0 "register_operand" "=d")
7469 (truncate:DI
7470 (lshiftrt:TI
7471 (mult:TI (sign_extend:TI
7472 (match_operand:DI 1 "register_operand" "%a"))
7473 (sign_extend:TI
7474 (match_operand:DI 2 "nonimmediate_operand" "rm")))
7475 (const_int 64))))
7476 (clobber (match_scratch:DI 3 "=a"))
7477 (clobber (reg:CC 17))]
7478 "TARGET_64BIT"
7479 "imul{q}\t%2"
7480 [(set_attr "type" "imul")
7481 (set_attr "ppro_uops" "few")
7482 (set_attr "mode" "DI")])
7483
7484 (define_insn "smulsi3_highpart"
7485 [(set (match_operand:SI 0 "register_operand" "=d")
7486 (truncate:SI
7487 (lshiftrt:DI
7488 (mult:DI (sign_extend:DI
7489 (match_operand:SI 1 "register_operand" "%a"))
7490 (sign_extend:DI
7491 (match_operand:SI 2 "nonimmediate_operand" "rm")))
7492 (const_int 32))))
7493 (clobber (match_scratch:SI 3 "=a"))
7494 (clobber (reg:CC 17))]
7495 ""
7496 "imul{l}\t%2"
7497 [(set_attr "type" "imul")
7498 (set_attr "ppro_uops" "few")
7499 (set_attr "mode" "SI")])
7500
7501 (define_insn "*smulsi3_highpart_zext"
7502 [(set (match_operand:DI 0 "register_operand" "=d")
7503 (zero_extend:DI (truncate:SI
7504 (lshiftrt:DI
7505 (mult:DI (sign_extend:DI
7506 (match_operand:SI 1 "register_operand" "%a"))
7507 (sign_extend:DI
7508 (match_operand:SI 2 "nonimmediate_operand" "rm")))
7509 (const_int 32)))))
7510 (clobber (match_scratch:SI 3 "=a"))
7511 (clobber (reg:CC 17))]
7512 "TARGET_64BIT"
7513 "imul{l}\t%2"
7514 [(set_attr "type" "imul")
7515 (set_attr "ppro_uops" "few")
7516 (set_attr "mode" "SI")])
7517
7518 ;; The patterns that match these are at the end of this file.
7519
7520 (define_expand "mulxf3"
7521 [(set (match_operand:XF 0 "register_operand" "")
7522 (mult:XF (match_operand:XF 1 "register_operand" "")
7523 (match_operand:XF 2 "register_operand" "")))]
7524 "!TARGET_64BIT && TARGET_80387"
7525 "")
7526
7527 (define_expand "multf3"
7528 [(set (match_operand:TF 0 "register_operand" "")
7529 (mult:TF (match_operand:TF 1 "register_operand" "")
7530 (match_operand:TF 2 "register_operand" "")))]
7531 "TARGET_80387"
7532 "")
7533
7534 (define_expand "muldf3"
7535 [(set (match_operand:DF 0 "register_operand" "")
7536 (mult:DF (match_operand:DF 1 "register_operand" "")
7537 (match_operand:DF 2 "nonimmediate_operand" "")))]
7538 "TARGET_80387 || (TARGET_SSE2 && TARGET_SSE_MATH)"
7539 "")
7540
7541 (define_expand "mulsf3"
7542 [(set (match_operand:SF 0 "register_operand" "")
7543 (mult:SF (match_operand:SF 1 "register_operand" "")
7544 (match_operand:SF 2 "nonimmediate_operand" "")))]
7545 "TARGET_80387 || TARGET_SSE_MATH"
7546 "")
7547 \f
7548 ;; Divide instructions
7549
7550 (define_insn "divqi3"
7551 [(set (match_operand:QI 0 "register_operand" "=a")
7552 (div:QI (match_operand:HI 1 "register_operand" "0")
7553 (match_operand:QI 2 "nonimmediate_operand" "qm")))
7554 (clobber (reg:CC 17))]
7555 "TARGET_QIMODE_MATH"
7556 "idiv{b}\t%2"
7557 [(set_attr "type" "idiv")
7558 (set_attr "mode" "QI")
7559 (set_attr "ppro_uops" "few")])
7560
7561 (define_insn "udivqi3"
7562 [(set (match_operand:QI 0 "register_operand" "=a")
7563 (udiv:QI (match_operand:HI 1 "register_operand" "0")
7564 (match_operand:QI 2 "nonimmediate_operand" "qm")))
7565 (clobber (reg:CC 17))]
7566 "TARGET_QIMODE_MATH"
7567 "div{b}\t%2"
7568 [(set_attr "type" "idiv")
7569 (set_attr "mode" "QI")
7570 (set_attr "ppro_uops" "few")])
7571
7572 ;; The patterns that match these are at the end of this file.
7573
7574 (define_expand "divxf3"
7575 [(set (match_operand:XF 0 "register_operand" "")
7576 (div:XF (match_operand:XF 1 "register_operand" "")
7577 (match_operand:XF 2 "register_operand" "")))]
7578 "!TARGET_64BIT && TARGET_80387"
7579 "")
7580
7581 (define_expand "divtf3"
7582 [(set (match_operand:TF 0 "register_operand" "")
7583 (div:TF (match_operand:TF 1 "register_operand" "")
7584 (match_operand:TF 2 "register_operand" "")))]
7585 "TARGET_80387"
7586 "")
7587
7588 (define_expand "divdf3"
7589 [(set (match_operand:DF 0 "register_operand" "")
7590 (div:DF (match_operand:DF 1 "register_operand" "")
7591 (match_operand:DF 2 "nonimmediate_operand" "")))]
7592 "TARGET_80387 || (TARGET_SSE2 && TARGET_SSE_MATH)"
7593 "")
7594
7595 (define_expand "divsf3"
7596 [(set (match_operand:SF 0 "register_operand" "")
7597 (div:SF (match_operand:SF 1 "register_operand" "")
7598 (match_operand:SF 2 "nonimmediate_operand" "")))]
7599 "TARGET_80387 || TARGET_SSE_MATH"
7600 "")
7601 \f
7602 ;; Remainder instructions.
7603
7604 (define_expand "divmoddi4"
7605 [(parallel [(set (match_operand:DI 0 "register_operand" "")
7606 (div:DI (match_operand:DI 1 "register_operand" "")
7607 (match_operand:DI 2 "nonimmediate_operand" "")))
7608 (set (match_operand:DI 3 "register_operand" "")
7609 (mod:DI (match_dup 1) (match_dup 2)))
7610 (clobber (reg:CC 17))])]
7611 "TARGET_64BIT"
7612 "")
7613
7614 ;; Allow to come the parameter in eax or edx to avoid extra moves.
7615 ;; Penalize eax case sligthly because it results in worse scheduling
7616 ;; of code.
7617 (define_insn "*divmoddi4_nocltd_rex64"
7618 [(set (match_operand:DI 0 "register_operand" "=&a,?a")
7619 (div:DI (match_operand:DI 2 "register_operand" "1,0")
7620 (match_operand:DI 3 "nonimmediate_operand" "rm,rm")))
7621 (set (match_operand:DI 1 "register_operand" "=&d,&d")
7622 (mod:DI (match_dup 2) (match_dup 3)))
7623 (clobber (reg:CC 17))]
7624 "TARGET_64BIT && !optimize_size && !TARGET_USE_CLTD"
7625 "#"
7626 [(set_attr "type" "multi")])
7627
7628 (define_insn "*divmoddi4_cltd_rex64"
7629 [(set (match_operand:DI 0 "register_operand" "=a")
7630 (div:DI (match_operand:DI 2 "register_operand" "a")
7631 (match_operand:DI 3 "nonimmediate_operand" "rm")))
7632 (set (match_operand:DI 1 "register_operand" "=&d")
7633 (mod:DI (match_dup 2) (match_dup 3)))
7634 (clobber (reg:CC 17))]
7635 "TARGET_64BIT && (optimize_size || TARGET_USE_CLTD)"
7636 "#"
7637 [(set_attr "type" "multi")])
7638
7639 (define_insn "*divmoddi_noext_rex64"
7640 [(set (match_operand:DI 0 "register_operand" "=a")
7641 (div:DI (match_operand:DI 1 "register_operand" "0")
7642 (match_operand:DI 2 "nonimmediate_operand" "rm")))
7643 (set (match_operand:DI 3 "register_operand" "=d")
7644 (mod:DI (match_dup 1) (match_dup 2)))
7645 (use (match_operand:DI 4 "register_operand" "3"))
7646 (clobber (reg:CC 17))]
7647 "TARGET_64BIT"
7648 "idiv{q}\t%2"
7649 [(set_attr "type" "idiv")
7650 (set_attr "mode" "DI")
7651 (set_attr "ppro_uops" "few")])
7652
7653 (define_split
7654 [(set (match_operand:DI 0 "register_operand" "")
7655 (div:DI (match_operand:DI 1 "register_operand" "")
7656 (match_operand:DI 2 "nonimmediate_operand" "")))
7657 (set (match_operand:DI 3 "register_operand" "")
7658 (mod:DI (match_dup 1) (match_dup 2)))
7659 (clobber (reg:CC 17))]
7660 "TARGET_64BIT && reload_completed"
7661 [(parallel [(set (match_dup 3)
7662 (ashiftrt:DI (match_dup 4) (const_int 63)))
7663 (clobber (reg:CC 17))])
7664 (parallel [(set (match_dup 0)
7665 (div:DI (reg:DI 0) (match_dup 2)))
7666 (set (match_dup 3)
7667 (mod:DI (reg:DI 0) (match_dup 2)))
7668 (use (match_dup 3))
7669 (clobber (reg:CC 17))])]
7670 {
7671 /* Avoid use of cltd in favour of a mov+shift. */
7672 if (!TARGET_USE_CLTD && !optimize_size)
7673 {
7674 if (true_regnum (operands[1]))
7675 emit_move_insn (operands[0], operands[1]);
7676 else
7677 emit_move_insn (operands[3], operands[1]);
7678 operands[4] = operands[3];
7679 }
7680 else
7681 {
7682 if (true_regnum (operands[1]))
7683 abort();
7684 operands[4] = operands[1];
7685 }
7686 })
7687
7688
7689 (define_expand "divmodsi4"
7690 [(parallel [(set (match_operand:SI 0 "register_operand" "")
7691 (div:SI (match_operand:SI 1 "register_operand" "")
7692 (match_operand:SI 2 "nonimmediate_operand" "")))
7693 (set (match_operand:SI 3 "register_operand" "")
7694 (mod:SI (match_dup 1) (match_dup 2)))
7695 (clobber (reg:CC 17))])]
7696 ""
7697 "")
7698
7699 ;; Allow to come the parameter in eax or edx to avoid extra moves.
7700 ;; Penalize eax case sligthly because it results in worse scheduling
7701 ;; of code.
7702 (define_insn "*divmodsi4_nocltd"
7703 [(set (match_operand:SI 0 "register_operand" "=&a,?a")
7704 (div:SI (match_operand:SI 2 "register_operand" "1,0")
7705 (match_operand:SI 3 "nonimmediate_operand" "rm,rm")))
7706 (set (match_operand:SI 1 "register_operand" "=&d,&d")
7707 (mod:SI (match_dup 2) (match_dup 3)))
7708 (clobber (reg:CC 17))]
7709 "!optimize_size && !TARGET_USE_CLTD"
7710 "#"
7711 [(set_attr "type" "multi")])
7712
7713 (define_insn "*divmodsi4_cltd"
7714 [(set (match_operand:SI 0 "register_operand" "=a")
7715 (div:SI (match_operand:SI 2 "register_operand" "a")
7716 (match_operand:SI 3 "nonimmediate_operand" "rm")))
7717 (set (match_operand:SI 1 "register_operand" "=&d")
7718 (mod:SI (match_dup 2) (match_dup 3)))
7719 (clobber (reg:CC 17))]
7720 "optimize_size || TARGET_USE_CLTD"
7721 "#"
7722 [(set_attr "type" "multi")])
7723
7724 (define_insn "*divmodsi_noext"
7725 [(set (match_operand:SI 0 "register_operand" "=a")
7726 (div:SI (match_operand:SI 1 "register_operand" "0")
7727 (match_operand:SI 2 "nonimmediate_operand" "rm")))
7728 (set (match_operand:SI 3 "register_operand" "=d")
7729 (mod:SI (match_dup 1) (match_dup 2)))
7730 (use (match_operand:SI 4 "register_operand" "3"))
7731 (clobber (reg:CC 17))]
7732 ""
7733 "idiv{l}\t%2"
7734 [(set_attr "type" "idiv")
7735 (set_attr "mode" "SI")
7736 (set_attr "ppro_uops" "few")])
7737
7738 (define_split
7739 [(set (match_operand:SI 0 "register_operand" "")
7740 (div:SI (match_operand:SI 1 "register_operand" "")
7741 (match_operand:SI 2 "nonimmediate_operand" "")))
7742 (set (match_operand:SI 3 "register_operand" "")
7743 (mod:SI (match_dup 1) (match_dup 2)))
7744 (clobber (reg:CC 17))]
7745 "reload_completed"
7746 [(parallel [(set (match_dup 3)
7747 (ashiftrt:SI (match_dup 4) (const_int 31)))
7748 (clobber (reg:CC 17))])
7749 (parallel [(set (match_dup 0)
7750 (div:SI (reg:SI 0) (match_dup 2)))
7751 (set (match_dup 3)
7752 (mod:SI (reg:SI 0) (match_dup 2)))
7753 (use (match_dup 3))
7754 (clobber (reg:CC 17))])]
7755 {
7756 /* Avoid use of cltd in favour of a mov+shift. */
7757 if (!TARGET_USE_CLTD && !optimize_size)
7758 {
7759 if (true_regnum (operands[1]))
7760 emit_move_insn (operands[0], operands[1]);
7761 else
7762 emit_move_insn (operands[3], operands[1]);
7763 operands[4] = operands[3];
7764 }
7765 else
7766 {
7767 if (true_regnum (operands[1]))
7768 abort();
7769 operands[4] = operands[1];
7770 }
7771 })
7772 ;; %%% Split me.
7773 (define_insn "divmodhi4"
7774 [(set (match_operand:HI 0 "register_operand" "=a")
7775 (div:HI (match_operand:HI 1 "register_operand" "0")
7776 (match_operand:HI 2 "nonimmediate_operand" "rm")))
7777 (set (match_operand:HI 3 "register_operand" "=&d")
7778 (mod:HI (match_dup 1) (match_dup 2)))
7779 (clobber (reg:CC 17))]
7780 "TARGET_HIMODE_MATH"
7781 "cwtd\;idiv{w}\t%2"
7782 [(set_attr "type" "multi")
7783 (set_attr "length_immediate" "0")
7784 (set_attr "mode" "SI")])
7785
7786 (define_insn "udivmoddi4"
7787 [(set (match_operand:DI 0 "register_operand" "=a")
7788 (udiv:DI (match_operand:DI 1 "register_operand" "0")
7789 (match_operand:DI 2 "nonimmediate_operand" "rm")))
7790 (set (match_operand:DI 3 "register_operand" "=&d")
7791 (umod:DI (match_dup 1) (match_dup 2)))
7792 (clobber (reg:CC 17))]
7793 "TARGET_64BIT"
7794 "xor{q}\t%3, %3\;div{q}\t%2"
7795 [(set_attr "type" "multi")
7796 (set_attr "length_immediate" "0")
7797 (set_attr "mode" "DI")])
7798
7799 (define_insn "*udivmoddi4_noext"
7800 [(set (match_operand:DI 0 "register_operand" "=a")
7801 (udiv:DI (match_operand:DI 1 "register_operand" "0")
7802 (match_operand:DI 2 "nonimmediate_operand" "rm")))
7803 (set (match_operand:DI 3 "register_operand" "=d")
7804 (umod:DI (match_dup 1) (match_dup 2)))
7805 (use (match_dup 3))
7806 (clobber (reg:CC 17))]
7807 "TARGET_64BIT"
7808 "div{q}\t%2"
7809 [(set_attr "type" "idiv")
7810 (set_attr "ppro_uops" "few")
7811 (set_attr "mode" "DI")])
7812
7813 (define_split
7814 [(set (match_operand:DI 0 "register_operand" "")
7815 (udiv:DI (match_operand:DI 1 "register_operand" "")
7816 (match_operand:DI 2 "nonimmediate_operand" "")))
7817 (set (match_operand:DI 3 "register_operand" "")
7818 (umod:DI (match_dup 1) (match_dup 2)))
7819 (clobber (reg:CC 17))]
7820 "TARGET_64BIT && reload_completed"
7821 [(set (match_dup 3) (const_int 0))
7822 (parallel [(set (match_dup 0)
7823 (udiv:DI (match_dup 1) (match_dup 2)))
7824 (set (match_dup 3)
7825 (umod:DI (match_dup 1) (match_dup 2)))
7826 (use (match_dup 3))
7827 (clobber (reg:CC 17))])]
7828 "")
7829
7830 (define_insn "udivmodsi4"
7831 [(set (match_operand:SI 0 "register_operand" "=a")
7832 (udiv:SI (match_operand:SI 1 "register_operand" "0")
7833 (match_operand:SI 2 "nonimmediate_operand" "rm")))
7834 (set (match_operand:SI 3 "register_operand" "=&d")
7835 (umod:SI (match_dup 1) (match_dup 2)))
7836 (clobber (reg:CC 17))]
7837 ""
7838 "xor{l}\t%3, %3\;div{l}\t%2"
7839 [(set_attr "type" "multi")
7840 (set_attr "length_immediate" "0")
7841 (set_attr "mode" "SI")])
7842
7843 (define_insn "*udivmodsi4_noext"
7844 [(set (match_operand:SI 0 "register_operand" "=a")
7845 (udiv:SI (match_operand:SI 1 "register_operand" "0")
7846 (match_operand:SI 2 "nonimmediate_operand" "rm")))
7847 (set (match_operand:SI 3 "register_operand" "=d")
7848 (umod:SI (match_dup 1) (match_dup 2)))
7849 (use (match_dup 3))
7850 (clobber (reg:CC 17))]
7851 ""
7852 "div{l}\t%2"
7853 [(set_attr "type" "idiv")
7854 (set_attr "ppro_uops" "few")
7855 (set_attr "mode" "SI")])
7856
7857 (define_split
7858 [(set (match_operand:SI 0 "register_operand" "")
7859 (udiv:SI (match_operand:SI 1 "register_operand" "")
7860 (match_operand:SI 2 "nonimmediate_operand" "")))
7861 (set (match_operand:SI 3 "register_operand" "")
7862 (umod:SI (match_dup 1) (match_dup 2)))
7863 (clobber (reg:CC 17))]
7864 "reload_completed"
7865 [(set (match_dup 3) (const_int 0))
7866 (parallel [(set (match_dup 0)
7867 (udiv:SI (match_dup 1) (match_dup 2)))
7868 (set (match_dup 3)
7869 (umod:SI (match_dup 1) (match_dup 2)))
7870 (use (match_dup 3))
7871 (clobber (reg:CC 17))])]
7872 "")
7873
7874 (define_expand "udivmodhi4"
7875 [(set (match_dup 4) (const_int 0))
7876 (parallel [(set (match_operand:HI 0 "register_operand" "")
7877 (udiv:HI (match_operand:HI 1 "register_operand" "")
7878 (match_operand:HI 2 "nonimmediate_operand" "")))
7879 (set (match_operand:HI 3 "register_operand" "")
7880 (umod:HI (match_dup 1) (match_dup 2)))
7881 (use (match_dup 4))
7882 (clobber (reg:CC 17))])]
7883 "TARGET_HIMODE_MATH"
7884 "operands[4] = gen_reg_rtx (HImode);")
7885
7886 (define_insn "*udivmodhi_noext"
7887 [(set (match_operand:HI 0 "register_operand" "=a")
7888 (udiv:HI (match_operand:HI 1 "register_operand" "0")
7889 (match_operand:HI 2 "nonimmediate_operand" "rm")))
7890 (set (match_operand:HI 3 "register_operand" "=d")
7891 (umod:HI (match_dup 1) (match_dup 2)))
7892 (use (match_operand:HI 4 "register_operand" "3"))
7893 (clobber (reg:CC 17))]
7894 ""
7895 "div{w}\t%2"
7896 [(set_attr "type" "idiv")
7897 (set_attr "mode" "HI")
7898 (set_attr "ppro_uops" "few")])
7899
7900 ;; We can not use div/idiv for double division, because it causes
7901 ;; "division by zero" on the overflow and that's not what we expect
7902 ;; from truncate. Because true (non truncating) double division is
7903 ;; never generated, we can't create this insn anyway.
7904 ;
7905 ;(define_insn ""
7906 ; [(set (match_operand:SI 0 "register_operand" "=a")
7907 ; (truncate:SI
7908 ; (udiv:DI (match_operand:DI 1 "register_operand" "A")
7909 ; (zero_extend:DI
7910 ; (match_operand:SI 2 "nonimmediate_operand" "rm")))))
7911 ; (set (match_operand:SI 3 "register_operand" "=d")
7912 ; (truncate:SI
7913 ; (umod:DI (match_dup 1) (zero_extend:DI (match_dup 2)))))
7914 ; (clobber (reg:CC 17))]
7915 ; ""
7916 ; "div{l}\t{%2, %0|%0, %2}"
7917 ; [(set_attr "type" "idiv")
7918 ; (set_attr "ppro_uops" "few")])
7919 \f
7920 ;;- Logical AND instructions
7921
7922 ;; On Pentium, "test imm, reg" is pairable only with eax, ax, and al.
7923 ;; Note that this excludes ah.
7924
7925 (define_insn "*testdi_1_rex64"
7926 [(set (reg 17)
7927 (compare
7928 (and:DI (match_operand:DI 0 "nonimmediate_operand" "%*a,r,*a,r,rm")
7929 (match_operand:DI 1 "x86_64_szext_nonmemory_operand" "Z,Z,e,e,re"))
7930 (const_int 0)))]
7931 "TARGET_64BIT && ix86_match_ccmode (insn, CCNOmode)"
7932 "@
7933 test{l}\t{%k1, %k0|%k0, %k1}
7934 test{l}\t{%k1, %k0|%k0, %k1}
7935 test{q}\t{%1, %0|%0, %1}
7936 test{q}\t{%1, %0|%0, %1}
7937 test{q}\t{%1, %0|%0, %1}"
7938 [(set_attr "type" "test")
7939 (set_attr "modrm" "0,1,0,1,1")
7940 (set_attr "mode" "SI,SI,DI,DI,DI")
7941 (set_attr "pent_pair" "uv,np,uv,np,uv")])
7942
7943 (define_insn "testsi_1"
7944 [(set (reg 17)
7945 (compare
7946 (and:SI (match_operand:SI 0 "nonimmediate_operand" "%*a,r,rm")
7947 (match_operand:SI 1 "nonmemory_operand" "in,in,rin"))
7948 (const_int 0)))]
7949 "ix86_match_ccmode (insn, CCNOmode)"
7950 "test{l}\t{%1, %0|%0, %1}"
7951 [(set_attr "type" "test")
7952 (set_attr "modrm" "0,1,1")
7953 (set_attr "mode" "SI")
7954 (set_attr "pent_pair" "uv,np,uv")])
7955
7956 (define_expand "testsi_ccno_1"
7957 [(set (reg:CCNO 17)
7958 (compare:CCNO
7959 (and:SI (match_operand:SI 0 "nonimmediate_operand" "")
7960 (match_operand:SI 1 "nonmemory_operand" ""))
7961 (const_int 0)))]
7962 ""
7963 "")
7964
7965 (define_insn "*testhi_1"
7966 [(set (reg 17)
7967 (compare (and:HI (match_operand:HI 0 "nonimmediate_operand" "%*a,r,rm")
7968 (match_operand:HI 1 "nonmemory_operand" "n,n,rn"))
7969 (const_int 0)))]
7970 "ix86_match_ccmode (insn, CCNOmode)"
7971 "test{w}\t{%1, %0|%0, %1}"
7972 [(set_attr "type" "test")
7973 (set_attr "modrm" "0,1,1")
7974 (set_attr "mode" "HI")
7975 (set_attr "pent_pair" "uv,np,uv")])
7976
7977 (define_expand "testqi_ccz_1"
7978 [(set (reg:CCZ 17)
7979 (compare:CCZ (and:QI (match_operand:QI 0 "nonimmediate_operand" "")
7980 (match_operand:QI 1 "nonmemory_operand" ""))
7981 (const_int 0)))]
7982 ""
7983 "")
7984
7985 (define_insn "*testqi_1"
7986 [(set (reg 17)
7987 (compare (and:QI (match_operand:QI 0 "nonimmediate_operand" "%*a,q,qm,r")
7988 (match_operand:QI 1 "nonmemory_operand" "n,n,qn,n"))
7989 (const_int 0)))]
7990 "ix86_match_ccmode (insn, CCNOmode)"
7991 {
7992 if (which_alternative == 3)
7993 {
7994 if (GET_CODE (operands[1]) == CONST_INT
7995 && (INTVAL (operands[1]) & 0xffffff00))
7996 operands[1] = GEN_INT (INTVAL (operands[1]) & 0xff);
7997 return "test{l}\t{%1, %k0|%k0, %1}";
7998 }
7999 return "test{b}\t{%1, %0|%0, %1}";
8000 }
8001 [(set_attr "type" "test")
8002 (set_attr "modrm" "0,1,1,1")
8003 (set_attr "mode" "QI,QI,QI,SI")
8004 (set_attr "pent_pair" "uv,np,uv,np")])
8005
8006 (define_expand "testqi_ext_ccno_0"
8007 [(set (reg:CCNO 17)
8008 (compare:CCNO
8009 (and:SI
8010 (zero_extract:SI
8011 (match_operand 0 "ext_register_operand" "")
8012 (const_int 8)
8013 (const_int 8))
8014 (match_operand 1 "const_int_operand" ""))
8015 (const_int 0)))]
8016 ""
8017 "")
8018
8019 (define_insn "*testqi_ext_0"
8020 [(set (reg 17)
8021 (compare
8022 (and:SI
8023 (zero_extract:SI
8024 (match_operand 0 "ext_register_operand" "Q")
8025 (const_int 8)
8026 (const_int 8))
8027 (match_operand 1 "const_int_operand" "n"))
8028 (const_int 0)))]
8029 "(unsigned HOST_WIDE_INT) INTVAL (operands[1]) <= 0xff
8030 && ix86_match_ccmode (insn, CCNOmode)"
8031 "test{b}\t{%1, %h0|%h0, %1}"
8032 [(set_attr "type" "test")
8033 (set_attr "mode" "QI")
8034 (set_attr "length_immediate" "1")
8035 (set_attr "pent_pair" "np")])
8036
8037 (define_insn "*testqi_ext_1"
8038 [(set (reg 17)
8039 (compare
8040 (and:SI
8041 (zero_extract:SI
8042 (match_operand 0 "ext_register_operand" "Q")
8043 (const_int 8)
8044 (const_int 8))
8045 (zero_extend:SI
8046 (match_operand:QI 1 "nonimmediate_operand" "Qm")))
8047 (const_int 0)))]
8048 "!TARGET_64BIT && ix86_match_ccmode (insn, CCNOmode)"
8049 "test{b}\t{%1, %h0|%h0, %1}"
8050 [(set_attr "type" "test")
8051 (set_attr "mode" "QI")])
8052
8053 (define_insn "*testqi_ext_1_rex64"
8054 [(set (reg 17)
8055 (compare
8056 (and:SI
8057 (zero_extract:SI
8058 (match_operand 0 "ext_register_operand" "Q")
8059 (const_int 8)
8060 (const_int 8))
8061 (zero_extend:SI
8062 (match_operand:QI 1 "register_operand" "Q")))
8063 (const_int 0)))]
8064 "TARGET_64BIT && ix86_match_ccmode (insn, CCNOmode)"
8065 "test{b}\t{%1, %h0|%h0, %1}"
8066 [(set_attr "type" "test")
8067 (set_attr "mode" "QI")])
8068
8069 (define_insn "*testqi_ext_2"
8070 [(set (reg 17)
8071 (compare
8072 (and:SI
8073 (zero_extract:SI
8074 (match_operand 0 "ext_register_operand" "Q")
8075 (const_int 8)
8076 (const_int 8))
8077 (zero_extract:SI
8078 (match_operand 1 "ext_register_operand" "Q")
8079 (const_int 8)
8080 (const_int 8)))
8081 (const_int 0)))]
8082 "ix86_match_ccmode (insn, CCNOmode)"
8083 "test{b}\t{%h1, %h0|%h0, %h1}"
8084 [(set_attr "type" "test")
8085 (set_attr "mode" "QI")])
8086
8087 ;; Combine likes to form bit extractions for some tests. Humor it.
8088 (define_insn "*testqi_ext_3"
8089 [(set (reg 17)
8090 (compare (zero_extract:SI
8091 (match_operand 0 "nonimmediate_operand" "rm")
8092 (match_operand:SI 1 "const_int_operand" "")
8093 (match_operand:SI 2 "const_int_operand" ""))
8094 (const_int 0)))]
8095 "ix86_match_ccmode (insn, CCNOmode)
8096 && (GET_MODE (operands[0]) == SImode
8097 || (TARGET_64BIT && GET_MODE (operands[0]) == DImode)
8098 || GET_MODE (operands[0]) == HImode
8099 || GET_MODE (operands[0]) == QImode)"
8100 "#")
8101
8102 (define_insn "*testqi_ext_3_rex64"
8103 [(set (reg 17)
8104 (compare (zero_extract:DI
8105 (match_operand 0 "nonimmediate_operand" "rm")
8106 (match_operand:DI 1 "const_int_operand" "")
8107 (match_operand:DI 2 "const_int_operand" ""))
8108 (const_int 0)))]
8109 "TARGET_64BIT
8110 && ix86_match_ccmode (insn, CCNOmode)
8111 /* The code below cannot deal with constants outside HOST_WIDE_INT. */
8112 && INTVAL (operands[1]) + INTVAL (operands[2]) < HOST_BITS_PER_WIDE_INT
8113 /* Ensure that resulting mask is zero or sign extended operand. */
8114 && (INTVAL (operands[1]) + INTVAL (operands[2]) <= 32
8115 || (INTVAL (operands[1]) + INTVAL (operands[2]) == 64
8116 && INTVAL (operands[1]) > 32))
8117 && (GET_MODE (operands[0]) == SImode
8118 || GET_MODE (operands[0]) == DImode
8119 || GET_MODE (operands[0]) == HImode
8120 || GET_MODE (operands[0]) == QImode)"
8121 "#")
8122
8123 (define_split
8124 [(set (reg 17)
8125 (compare (zero_extract
8126 (match_operand 0 "nonimmediate_operand" "")
8127 (match_operand 1 "const_int_operand" "")
8128 (match_operand 2 "const_int_operand" ""))
8129 (const_int 0)))]
8130 "ix86_match_ccmode (insn, CCNOmode)"
8131 [(set (reg:CCNO 17) (compare:CCNO (match_dup 3) (const_int 0)))]
8132 {
8133 HOST_WIDE_INT len = INTVAL (operands[1]);
8134 HOST_WIDE_INT pos = INTVAL (operands[2]);
8135 HOST_WIDE_INT mask;
8136 enum machine_mode mode, submode;
8137
8138 mode = GET_MODE (operands[0]);
8139 if (GET_CODE (operands[0]) == MEM)
8140 {
8141 /* ??? Combine likes to put non-volatile mem extractions in QImode
8142 no matter the size of the test. So find a mode that works. */
8143 if (! MEM_VOLATILE_P (operands[0]))
8144 {
8145 mode = smallest_mode_for_size (pos + len, MODE_INT);
8146 operands[0] = adjust_address (operands[0], mode, 0);
8147 }
8148 }
8149 else if (GET_CODE (operands[0]) == SUBREG
8150 && (submode = GET_MODE (SUBREG_REG (operands[0])),
8151 GET_MODE_BITSIZE (mode) > GET_MODE_BITSIZE (submode))
8152 && pos + len <= GET_MODE_BITSIZE (submode))
8153 {
8154 /* Narrow a paradoxical subreg to prevent partial register stalls. */
8155 mode = submode;
8156 operands[0] = SUBREG_REG (operands[0]);
8157 }
8158 else if (mode == HImode && pos + len <= 8)
8159 {
8160 /* Small HImode tests can be converted to QImode. */
8161 mode = QImode;
8162 operands[0] = gen_lowpart (QImode, operands[0]);
8163 }
8164
8165 mask = ((HOST_WIDE_INT)1 << (pos + len)) - 1;
8166 mask &= ~(((HOST_WIDE_INT)1 << pos) - 1);
8167
8168 operands[3] = gen_rtx_AND (mode, operands[0],
8169 GEN_INT (trunc_int_for_mode (mask, mode)));
8170 })
8171
8172 ;; %%% This used to optimize known byte-wide and operations to memory,
8173 ;; and sometimes to QImode registers. If this is considered useful,
8174 ;; it should be done with splitters.
8175
8176 (define_expand "anddi3"
8177 [(set (match_operand:DI 0 "nonimmediate_operand" "")
8178 (and:DI (match_operand:DI 1 "nonimmediate_operand" "")
8179 (match_operand:DI 2 "x86_64_szext_general_operand" "")))
8180 (clobber (reg:CC 17))]
8181 "TARGET_64BIT"
8182 "ix86_expand_binary_operator (AND, DImode, operands); DONE;")
8183
8184 (define_insn "*anddi_1_rex64"
8185 [(set (match_operand:DI 0 "nonimmediate_operand" "=r,rm,r,r")
8186 (and:DI (match_operand:DI 1 "nonimmediate_operand" "%0,0,0,qm")
8187 (match_operand:DI 2 "x86_64_szext_general_operand" "Z,re,rm,L")))
8188 (clobber (reg:CC 17))]
8189 "TARGET_64BIT && ix86_binary_operator_ok (AND, DImode, operands)"
8190 {
8191 switch (get_attr_type (insn))
8192 {
8193 case TYPE_IMOVX:
8194 {
8195 enum machine_mode mode;
8196
8197 if (GET_CODE (operands[2]) != CONST_INT)
8198 abort ();
8199 if (INTVAL (operands[2]) == 0xff)
8200 mode = QImode;
8201 else if (INTVAL (operands[2]) == 0xffff)
8202 mode = HImode;
8203 else
8204 abort ();
8205
8206 operands[1] = gen_lowpart (mode, operands[1]);
8207 if (mode == QImode)
8208 return "movz{bq|x}\t{%1,%0|%0, %1}";
8209 else
8210 return "movz{wq|x}\t{%1,%0|%0, %1}";
8211 }
8212
8213 default:
8214 if (! rtx_equal_p (operands[0], operands[1]))
8215 abort ();
8216 if (get_attr_mode (insn) == MODE_SI)
8217 return "and{l}\t{%k2, %k0|%k0, %k2}";
8218 else
8219 return "and{q}\t{%2, %0|%0, %2}";
8220 }
8221 }
8222 [(set_attr "type" "alu,alu,alu,imovx")
8223 (set_attr "length_immediate" "*,*,*,0")
8224 (set_attr "mode" "SI,DI,DI,DI")])
8225
8226 (define_insn "*anddi_2"
8227 [(set (reg 17)
8228 (compare (and:DI (match_operand:DI 1 "nonimmediate_operand" "%0,0,0")
8229 (match_operand:DI 2 "x86_64_szext_general_operand" "Z,rem,re"))
8230 (const_int 0)))
8231 (set (match_operand:DI 0 "nonimmediate_operand" "=r,r,rm")
8232 (and:DI (match_dup 1) (match_dup 2)))]
8233 "TARGET_64BIT && ix86_match_ccmode (insn, CCNOmode)
8234 && ix86_binary_operator_ok (AND, DImode, operands)"
8235 "@
8236 and{l}\t{%k2, %k0|%k0, %k2}
8237 and{q}\t{%2, %0|%0, %2}
8238 and{q}\t{%2, %0|%0, %2}"
8239 [(set_attr "type" "alu")
8240 (set_attr "mode" "SI,DI,DI")])
8241
8242 (define_expand "andsi3"
8243 [(set (match_operand:SI 0 "nonimmediate_operand" "")
8244 (and:SI (match_operand:SI 1 "nonimmediate_operand" "")
8245 (match_operand:SI 2 "general_operand" "")))
8246 (clobber (reg:CC 17))]
8247 ""
8248 "ix86_expand_binary_operator (AND, SImode, operands); DONE;")
8249
8250 (define_insn "*andsi_1"
8251 [(set (match_operand:SI 0 "nonimmediate_operand" "=rm,r,r")
8252 (and:SI (match_operand:SI 1 "nonimmediate_operand" "%0,0,qm")
8253 (match_operand:SI 2 "general_operand" "ri,rm,L")))
8254 (clobber (reg:CC 17))]
8255 "ix86_binary_operator_ok (AND, SImode, operands)"
8256 {
8257 switch (get_attr_type (insn))
8258 {
8259 case TYPE_IMOVX:
8260 {
8261 enum machine_mode mode;
8262
8263 if (GET_CODE (operands[2]) != CONST_INT)
8264 abort ();
8265 if (INTVAL (operands[2]) == 0xff)
8266 mode = QImode;
8267 else if (INTVAL (operands[2]) == 0xffff)
8268 mode = HImode;
8269 else
8270 abort ();
8271
8272 operands[1] = gen_lowpart (mode, operands[1]);
8273 if (mode == QImode)
8274 return "movz{bl|x}\t{%1,%0|%0, %1}";
8275 else
8276 return "movz{wl|x}\t{%1,%0|%0, %1}";
8277 }
8278
8279 default:
8280 if (! rtx_equal_p (operands[0], operands[1]))
8281 abort ();
8282 return "and{l}\t{%2, %0|%0, %2}";
8283 }
8284 }
8285 [(set_attr "type" "alu,alu,imovx")
8286 (set_attr "length_immediate" "*,*,0")
8287 (set_attr "mode" "SI")])
8288
8289 (define_split
8290 [(set (match_operand 0 "register_operand" "")
8291 (and (match_dup 0)
8292 (const_int -65536)))
8293 (clobber (reg:CC 17))]
8294 "optimize_size"
8295 [(set (strict_low_part (match_dup 1)) (const_int 0))]
8296 "operands[1] = gen_lowpart (HImode, operands[0]);")
8297
8298 (define_split
8299 [(set (match_operand 0 "ext_register_operand" "")
8300 (and (match_dup 0)
8301 (const_int -256)))
8302 (clobber (reg:CC 17))]
8303 "(optimize_size || !TARGET_PARTIAL_REG_STALL) && reload_completed"
8304 [(set (strict_low_part (match_dup 1)) (const_int 0))]
8305 "operands[1] = gen_lowpart (QImode, operands[0]);")
8306
8307 (define_split
8308 [(set (match_operand 0 "ext_register_operand" "")
8309 (and (match_dup 0)
8310 (const_int -65281)))
8311 (clobber (reg:CC 17))]
8312 "(optimize_size || !TARGET_PARTIAL_REG_STALL) && reload_completed"
8313 [(parallel [(set (zero_extract:SI (match_dup 0)
8314 (const_int 8)
8315 (const_int 8))
8316 (xor:SI
8317 (zero_extract:SI (match_dup 0)
8318 (const_int 8)
8319 (const_int 8))
8320 (zero_extract:SI (match_dup 0)
8321 (const_int 8)
8322 (const_int 8))))
8323 (clobber (reg:CC 17))])]
8324 "operands[0] = gen_lowpart (SImode, operands[0]);")
8325
8326 ;; See comment for addsi_1_zext why we do use nonimmediate_operand
8327 (define_insn "*andsi_1_zext"
8328 [(set (match_operand:DI 0 "register_operand" "=r")
8329 (zero_extend:DI
8330 (and:SI (match_operand:SI 1 "nonimmediate_operand" "%0")
8331 (match_operand:SI 2 "general_operand" "rim"))))
8332 (clobber (reg:CC 17))]
8333 "TARGET_64BIT && ix86_binary_operator_ok (AND, SImode, operands)"
8334 "and{l}\t{%2, %k0|%k0, %2}"
8335 [(set_attr "type" "alu")
8336 (set_attr "mode" "SI")])
8337
8338 (define_insn "*andsi_2"
8339 [(set (reg 17)
8340 (compare (and:SI (match_operand:SI 1 "nonimmediate_operand" "%0,0")
8341 (match_operand:SI 2 "general_operand" "rim,ri"))
8342 (const_int 0)))
8343 (set (match_operand:SI 0 "nonimmediate_operand" "=r,rm")
8344 (and:SI (match_dup 1) (match_dup 2)))]
8345 "ix86_match_ccmode (insn, CCNOmode)
8346 && ix86_binary_operator_ok (AND, SImode, operands)"
8347 "and{l}\t{%2, %0|%0, %2}"
8348 [(set_attr "type" "alu")
8349 (set_attr "mode" "SI")])
8350
8351 ;; See comment for addsi_1_zext why we do use nonimmediate_operand
8352 (define_insn "*andsi_2_zext"
8353 [(set (reg 17)
8354 (compare (and:SI (match_operand:SI 1 "nonimmediate_operand" "%0")
8355 (match_operand:SI 2 "general_operand" "rim"))
8356 (const_int 0)))
8357 (set (match_operand:DI 0 "register_operand" "=r")
8358 (zero_extend:DI (and:SI (match_dup 1) (match_dup 2))))]
8359 "TARGET_64BIT && ix86_match_ccmode (insn, CCNOmode)
8360 && ix86_binary_operator_ok (AND, SImode, operands)"
8361 "and{l}\t{%2, %k0|%k0, %2}"
8362 [(set_attr "type" "alu")
8363 (set_attr "mode" "SI")])
8364
8365 (define_expand "andhi3"
8366 [(set (match_operand:HI 0 "nonimmediate_operand" "")
8367 (and:HI (match_operand:HI 1 "nonimmediate_operand" "")
8368 (match_operand:HI 2 "general_operand" "")))
8369 (clobber (reg:CC 17))]
8370 "TARGET_HIMODE_MATH"
8371 "ix86_expand_binary_operator (AND, HImode, operands); DONE;")
8372
8373 (define_insn "*andhi_1"
8374 [(set (match_operand:HI 0 "nonimmediate_operand" "=rm,r,r")
8375 (and:HI (match_operand:HI 1 "nonimmediate_operand" "%0,0,qm")
8376 (match_operand:HI 2 "general_operand" "ri,rm,L")))
8377 (clobber (reg:CC 17))]
8378 "ix86_binary_operator_ok (AND, HImode, operands)"
8379 {
8380 switch (get_attr_type (insn))
8381 {
8382 case TYPE_IMOVX:
8383 if (GET_CODE (operands[2]) != CONST_INT)
8384 abort ();
8385 if (INTVAL (operands[2]) == 0xff)
8386 return "movz{bl|x}\t{%b1, %k0|%k0, %b1}";
8387 abort ();
8388
8389 default:
8390 if (! rtx_equal_p (operands[0], operands[1]))
8391 abort ();
8392
8393 return "and{w}\t{%2, %0|%0, %2}";
8394 }
8395 }
8396 [(set_attr "type" "alu,alu,imovx")
8397 (set_attr "length_immediate" "*,*,0")
8398 (set_attr "mode" "HI,HI,SI")])
8399
8400 (define_insn "*andhi_2"
8401 [(set (reg 17)
8402 (compare (and:HI (match_operand:HI 1 "nonimmediate_operand" "%0,0")
8403 (match_operand:HI 2 "general_operand" "rim,ri"))
8404 (const_int 0)))
8405 (set (match_operand:HI 0 "nonimmediate_operand" "=r,rm")
8406 (and:HI (match_dup 1) (match_dup 2)))]
8407 "ix86_match_ccmode (insn, CCNOmode)
8408 && ix86_binary_operator_ok (AND, HImode, operands)"
8409 "and{w}\t{%2, %0|%0, %2}"
8410 [(set_attr "type" "alu")
8411 (set_attr "mode" "HI")])
8412
8413 (define_expand "andqi3"
8414 [(set (match_operand:QI 0 "nonimmediate_operand" "")
8415 (and:QI (match_operand:QI 1 "nonimmediate_operand" "")
8416 (match_operand:QI 2 "general_operand" "")))
8417 (clobber (reg:CC 17))]
8418 "TARGET_QIMODE_MATH"
8419 "ix86_expand_binary_operator (AND, QImode, operands); DONE;")
8420
8421 ;; %%% Potential partial reg stall on alternative 2. What to do?
8422 (define_insn "*andqi_1"
8423 [(set (match_operand:QI 0 "nonimmediate_operand" "=qm,q,r")
8424 (and:QI (match_operand:QI 1 "nonimmediate_operand" "%0,0,0")
8425 (match_operand:QI 2 "general_operand" "qi,qmi,ri")))
8426 (clobber (reg:CC 17))]
8427 "ix86_binary_operator_ok (AND, QImode, operands)"
8428 "@
8429 and{b}\t{%2, %0|%0, %2}
8430 and{b}\t{%2, %0|%0, %2}
8431 and{l}\t{%k2, %k0|%k0, %k2}"
8432 [(set_attr "type" "alu")
8433 (set_attr "mode" "QI,QI,SI")])
8434
8435 (define_insn "*andqi_1_slp"
8436 [(set (strict_low_part (match_operand:QI 0 "nonimmediate_operand" "+qm,q"))
8437 (and:QI (match_dup 0)
8438 (match_operand:QI 1 "general_operand" "qi,qmi")))
8439 (clobber (reg:CC 17))]
8440 ""
8441 "and{b}\t{%1, %0|%0, %1}"
8442 [(set_attr "type" "alu1")
8443 (set_attr "mode" "QI")])
8444
8445 (define_insn "*andqi_2"
8446 [(set (reg 17)
8447 (compare (and:QI
8448 (match_operand:QI 1 "nonimmediate_operand" "%0,0,0")
8449 (match_operand:QI 2 "general_operand" "qim,qi,i"))
8450 (const_int 0)))
8451 (set (match_operand:QI 0 "nonimmediate_operand" "=q,qm,*r")
8452 (and:QI (match_dup 1) (match_dup 2)))]
8453 "ix86_match_ccmode (insn, CCNOmode)
8454 && ix86_binary_operator_ok (AND, QImode, operands)"
8455 {
8456 if (which_alternative == 2)
8457 {
8458 if (GET_CODE (operands[2]) == CONST_INT
8459 && (INTVAL (operands[2]) & 0xffffff00))
8460 operands[2] = GEN_INT (INTVAL (operands[2]) & 0xff);
8461 return "and{l}\t{%2, %k0|%k0, %2}";
8462 }
8463 return "and{b}\t{%2, %0|%0, %2}";
8464 }
8465 [(set_attr "type" "alu")
8466 (set_attr "mode" "QI,QI,SI")])
8467
8468 (define_insn "*andqi_2_slp"
8469 [(set (reg 17)
8470 (compare (and:QI
8471 (match_operand:QI 0 "nonimmediate_operand" "+q,qm")
8472 (match_operand:QI 1 "nonimmediate_operand" "qmi,qi"))
8473 (const_int 0)))
8474 (set (strict_low_part (match_dup 0))
8475 (and:QI (match_dup 0) (match_dup 1)))]
8476 "ix86_match_ccmode (insn, CCNOmode)"
8477 "and{b}\t{%1, %0|%0, %1}"
8478 [(set_attr "type" "alu1")
8479 (set_attr "mode" "QI")])
8480
8481 ;; ??? A bug in recog prevents it from recognizing a const_int as an
8482 ;; operand to zero_extend in andqi_ext_1. It was checking explicitly
8483 ;; for a QImode operand, which of course failed.
8484
8485 (define_insn "andqi_ext_0"
8486 [(set (zero_extract:SI (match_operand 0 "ext_register_operand" "=Q")
8487 (const_int 8)
8488 (const_int 8))
8489 (and:SI
8490 (zero_extract:SI
8491 (match_operand 1 "ext_register_operand" "0")
8492 (const_int 8)
8493 (const_int 8))
8494 (match_operand 2 "const_int_operand" "n")))
8495 (clobber (reg:CC 17))]
8496 "(unsigned HOST_WIDE_INT)INTVAL (operands[2]) <= 0xff"
8497 "and{b}\t{%2, %h0|%h0, %2}"
8498 [(set_attr "type" "alu")
8499 (set_attr "length_immediate" "1")
8500 (set_attr "mode" "QI")])
8501
8502 ;; Generated by peephole translating test to and. This shows up
8503 ;; often in fp comparisons.
8504
8505 (define_insn "*andqi_ext_0_cc"
8506 [(set (reg 17)
8507 (compare
8508 (and:SI
8509 (zero_extract:SI
8510 (match_operand 1 "ext_register_operand" "0")
8511 (const_int 8)
8512 (const_int 8))
8513 (match_operand 2 "const_int_operand" "n"))
8514 (const_int 0)))
8515 (set (zero_extract:SI (match_operand 0 "ext_register_operand" "=Q")
8516 (const_int 8)
8517 (const_int 8))
8518 (and:SI
8519 (zero_extract:SI
8520 (match_dup 1)
8521 (const_int 8)
8522 (const_int 8))
8523 (match_dup 2)))]
8524 "ix86_match_ccmode (insn, CCNOmode)
8525 && (unsigned HOST_WIDE_INT)INTVAL (operands[2]) <= 0xff"
8526 "and{b}\t{%2, %h0|%h0, %2}"
8527 [(set_attr "type" "alu")
8528 (set_attr "length_immediate" "1")
8529 (set_attr "mode" "QI")])
8530
8531 (define_insn "*andqi_ext_1"
8532 [(set (zero_extract:SI (match_operand 0 "ext_register_operand" "=Q")
8533 (const_int 8)
8534 (const_int 8))
8535 (and:SI
8536 (zero_extract:SI
8537 (match_operand 1 "ext_register_operand" "0")
8538 (const_int 8)
8539 (const_int 8))
8540 (zero_extend:SI
8541 (match_operand:QI 2 "general_operand" "Qm"))))
8542 (clobber (reg:CC 17))]
8543 "!TARGET_64BIT"
8544 "and{b}\t{%2, %h0|%h0, %2}"
8545 [(set_attr "type" "alu")
8546 (set_attr "length_immediate" "0")
8547 (set_attr "mode" "QI")])
8548
8549 (define_insn "*andqi_ext_1_rex64"
8550 [(set (zero_extract:SI (match_operand 0 "ext_register_operand" "=Q")
8551 (const_int 8)
8552 (const_int 8))
8553 (and:SI
8554 (zero_extract:SI
8555 (match_operand 1 "ext_register_operand" "0")
8556 (const_int 8)
8557 (const_int 8))
8558 (zero_extend:SI
8559 (match_operand 2 "ext_register_operand" "Q"))))
8560 (clobber (reg:CC 17))]
8561 "TARGET_64BIT"
8562 "and{b}\t{%2, %h0|%h0, %2}"
8563 [(set_attr "type" "alu")
8564 (set_attr "length_immediate" "0")
8565 (set_attr "mode" "QI")])
8566
8567 (define_insn "*andqi_ext_2"
8568 [(set (zero_extract:SI (match_operand 0 "ext_register_operand" "=Q")
8569 (const_int 8)
8570 (const_int 8))
8571 (and:SI
8572 (zero_extract:SI
8573 (match_operand 1 "ext_register_operand" "%0")
8574 (const_int 8)
8575 (const_int 8))
8576 (zero_extract:SI
8577 (match_operand 2 "ext_register_operand" "Q")
8578 (const_int 8)
8579 (const_int 8))))
8580 (clobber (reg:CC 17))]
8581 ""
8582 "and{b}\t{%h2, %h0|%h0, %h2}"
8583 [(set_attr "type" "alu")
8584 (set_attr "length_immediate" "0")
8585 (set_attr "mode" "QI")])
8586 \f
8587 ;; Logical inclusive OR instructions
8588
8589 ;; %%% This used to optimize known byte-wide and operations to memory.
8590 ;; If this is considered useful, it should be done with splitters.
8591
8592 (define_expand "iordi3"
8593 [(set (match_operand:DI 0 "nonimmediate_operand" "")
8594 (ior:DI (match_operand:DI 1 "nonimmediate_operand" "")
8595 (match_operand:DI 2 "x86_64_general_operand" "")))
8596 (clobber (reg:CC 17))]
8597 "TARGET_64BIT"
8598 "ix86_expand_binary_operator (IOR, DImode, operands); DONE;")
8599
8600 (define_insn "*iordi_1_rex64"
8601 [(set (match_operand:DI 0 "nonimmediate_operand" "=rm,r")
8602 (ior:DI (match_operand:DI 1 "nonimmediate_operand" "%0,0")
8603 (match_operand:DI 2 "x86_64_general_operand" "re,rme")))
8604 (clobber (reg:CC 17))]
8605 "TARGET_64BIT
8606 && ix86_binary_operator_ok (IOR, DImode, operands)"
8607 "or{q}\t{%2, %0|%0, %2}"
8608 [(set_attr "type" "alu")
8609 (set_attr "mode" "DI")])
8610
8611 (define_insn "*iordi_2_rex64"
8612 [(set (reg 17)
8613 (compare (ior:DI (match_operand:DI 1 "nonimmediate_operand" "%0,0")
8614 (match_operand:DI 2 "x86_64_general_operand" "rem,re"))
8615 (const_int 0)))
8616 (set (match_operand:DI 0 "nonimmediate_operand" "=r,rm")
8617 (ior:DI (match_dup 1) (match_dup 2)))]
8618 "TARGET_64BIT
8619 && ix86_match_ccmode (insn, CCNOmode)
8620 && ix86_binary_operator_ok (IOR, DImode, operands)"
8621 "or{q}\t{%2, %0|%0, %2}"
8622 [(set_attr "type" "alu")
8623 (set_attr "mode" "DI")])
8624
8625 (define_insn "*iordi_3_rex64"
8626 [(set (reg 17)
8627 (compare (ior:DI (match_operand:DI 1 "nonimmediate_operand" "%0")
8628 (match_operand:DI 2 "x86_64_general_operand" "rem"))
8629 (const_int 0)))
8630 (clobber (match_scratch:DI 0 "=r"))]
8631 "TARGET_64BIT
8632 && ix86_match_ccmode (insn, CCNOmode)
8633 && ix86_binary_operator_ok (IOR, DImode, operands)"
8634 "or{q}\t{%2, %0|%0, %2}"
8635 [(set_attr "type" "alu")
8636 (set_attr "mode" "DI")])
8637
8638
8639 (define_expand "iorsi3"
8640 [(set (match_operand:SI 0 "nonimmediate_operand" "")
8641 (ior:SI (match_operand:SI 1 "nonimmediate_operand" "")
8642 (match_operand:SI 2 "general_operand" "")))
8643 (clobber (reg:CC 17))]
8644 ""
8645 "ix86_expand_binary_operator (IOR, SImode, operands); DONE;")
8646
8647 (define_insn "*iorsi_1"
8648 [(set (match_operand:SI 0 "nonimmediate_operand" "=rm,r")
8649 (ior:SI (match_operand:SI 1 "nonimmediate_operand" "%0,0")
8650 (match_operand:SI 2 "general_operand" "ri,rmi")))
8651 (clobber (reg:CC 17))]
8652 "ix86_binary_operator_ok (IOR, SImode, operands)"
8653 "or{l}\t{%2, %0|%0, %2}"
8654 [(set_attr "type" "alu")
8655 (set_attr "mode" "SI")])
8656
8657 ;; See comment for addsi_1_zext why we do use nonimmediate_operand
8658 (define_insn "*iorsi_1_zext"
8659 [(set (match_operand:DI 0 "register_operand" "=rm")
8660 (zero_extend:DI
8661 (ior:SI (match_operand:SI 1 "nonimmediate_operand" "%0")
8662 (match_operand:SI 2 "general_operand" "rim"))))
8663 (clobber (reg:CC 17))]
8664 "TARGET_64BIT && ix86_binary_operator_ok (IOR, SImode, operands)"
8665 "or{l}\t{%2, %k0|%k0, %2}"
8666 [(set_attr "type" "alu")
8667 (set_attr "mode" "SI")])
8668
8669 (define_insn "*iorsi_1_zext_imm"
8670 [(set (match_operand:DI 0 "register_operand" "=rm")
8671 (ior:DI (zero_extend:DI (match_operand:SI 1 "register_operand" "%0"))
8672 (match_operand:DI 2 "x86_64_zext_immediate_operand" "Z")))
8673 (clobber (reg:CC 17))]
8674 "TARGET_64BIT"
8675 "or{l}\t{%2, %k0|%k0, %2}"
8676 [(set_attr "type" "alu")
8677 (set_attr "mode" "SI")])
8678
8679 (define_insn "*iorsi_2"
8680 [(set (reg 17)
8681 (compare (ior:SI (match_operand:SI 1 "nonimmediate_operand" "%0,0")
8682 (match_operand:SI 2 "general_operand" "rim,ri"))
8683 (const_int 0)))
8684 (set (match_operand:SI 0 "nonimmediate_operand" "=r,rm")
8685 (ior:SI (match_dup 1) (match_dup 2)))]
8686 "ix86_match_ccmode (insn, CCNOmode)
8687 && ix86_binary_operator_ok (IOR, SImode, operands)"
8688 "or{l}\t{%2, %0|%0, %2}"
8689 [(set_attr "type" "alu")
8690 (set_attr "mode" "SI")])
8691
8692 ;; See comment for addsi_1_zext why we do use nonimmediate_operand
8693 ;; ??? Special case for immediate operand is missing - it is tricky.
8694 (define_insn "*iorsi_2_zext"
8695 [(set (reg 17)
8696 (compare (ior:SI (match_operand:SI 1 "nonimmediate_operand" "%0")
8697 (match_operand:SI 2 "general_operand" "rim"))
8698 (const_int 0)))
8699 (set (match_operand:DI 0 "register_operand" "=r")
8700 (zero_extend:DI (ior:SI (match_dup 1) (match_dup 2))))]
8701 "TARGET_64BIT && ix86_match_ccmode (insn, CCNOmode)
8702 && ix86_binary_operator_ok (IOR, SImode, operands)"
8703 "or{l}\t{%2, %k0|%k0, %2}"
8704 [(set_attr "type" "alu")
8705 (set_attr "mode" "SI")])
8706
8707 (define_insn "*iorsi_2_zext_imm"
8708 [(set (reg 17)
8709 (compare (ior:SI (match_operand:SI 1 "nonimmediate_operand" "%0")
8710 (match_operand 2 "x86_64_zext_immediate_operand" "Z"))
8711 (const_int 0)))
8712 (set (match_operand:DI 0 "register_operand" "=r")
8713 (ior:DI (zero_extend:DI (match_dup 1)) (match_dup 2)))]
8714 "TARGET_64BIT && ix86_match_ccmode (insn, CCNOmode)
8715 && ix86_binary_operator_ok (IOR, SImode, operands)"
8716 "or{l}\t{%2, %k0|%k0, %2}"
8717 [(set_attr "type" "alu")
8718 (set_attr "mode" "SI")])
8719
8720 (define_insn "*iorsi_3"
8721 [(set (reg 17)
8722 (compare (ior:SI (match_operand:SI 1 "nonimmediate_operand" "%0")
8723 (match_operand:SI 2 "general_operand" "rim"))
8724 (const_int 0)))
8725 (clobber (match_scratch:SI 0 "=r"))]
8726 "ix86_match_ccmode (insn, CCNOmode)
8727 && (GET_CODE (operands[1]) != MEM || GET_CODE (operands[2]) != MEM)"
8728 "or{l}\t{%2, %0|%0, %2}"
8729 [(set_attr "type" "alu")
8730 (set_attr "mode" "SI")])
8731
8732 (define_expand "iorhi3"
8733 [(set (match_operand:HI 0 "nonimmediate_operand" "")
8734 (ior:HI (match_operand:HI 1 "nonimmediate_operand" "")
8735 (match_operand:HI 2 "general_operand" "")))
8736 (clobber (reg:CC 17))]
8737 "TARGET_HIMODE_MATH"
8738 "ix86_expand_binary_operator (IOR, HImode, operands); DONE;")
8739
8740 (define_insn "*iorhi_1"
8741 [(set (match_operand:HI 0 "nonimmediate_operand" "=r,m")
8742 (ior:HI (match_operand:HI 1 "nonimmediate_operand" "%0,0")
8743 (match_operand:HI 2 "general_operand" "rmi,ri")))
8744 (clobber (reg:CC 17))]
8745 "ix86_binary_operator_ok (IOR, HImode, operands)"
8746 "or{w}\t{%2, %0|%0, %2}"
8747 [(set_attr "type" "alu")
8748 (set_attr "mode" "HI")])
8749
8750 (define_insn "*iorhi_2"
8751 [(set (reg 17)
8752 (compare (ior:HI (match_operand:HI 1 "nonimmediate_operand" "%0,0")
8753 (match_operand:HI 2 "general_operand" "rim,ri"))
8754 (const_int 0)))
8755 (set (match_operand:HI 0 "nonimmediate_operand" "=r,rm")
8756 (ior:HI (match_dup 1) (match_dup 2)))]
8757 "ix86_match_ccmode (insn, CCNOmode)
8758 && ix86_binary_operator_ok (IOR, HImode, operands)"
8759 "or{w}\t{%2, %0|%0, %2}"
8760 [(set_attr "type" "alu")
8761 (set_attr "mode" "HI")])
8762
8763 (define_insn "*iorhi_3"
8764 [(set (reg 17)
8765 (compare (ior:HI (match_operand:HI 1 "nonimmediate_operand" "%0")
8766 (match_operand:HI 2 "general_operand" "rim"))
8767 (const_int 0)))
8768 (clobber (match_scratch:HI 0 "=r"))]
8769 "ix86_match_ccmode (insn, CCNOmode)
8770 && (GET_CODE (operands[1]) != MEM || GET_CODE (operands[2]) != MEM)"
8771 "or{w}\t{%2, %0|%0, %2}"
8772 [(set_attr "type" "alu")
8773 (set_attr "mode" "HI")])
8774
8775 (define_expand "iorqi3"
8776 [(set (match_operand:QI 0 "nonimmediate_operand" "")
8777 (ior:QI (match_operand:QI 1 "nonimmediate_operand" "")
8778 (match_operand:QI 2 "general_operand" "")))
8779 (clobber (reg:CC 17))]
8780 "TARGET_QIMODE_MATH"
8781 "ix86_expand_binary_operator (IOR, QImode, operands); DONE;")
8782
8783 ;; %%% Potential partial reg stall on alternative 2. What to do?
8784 (define_insn "*iorqi_1"
8785 [(set (match_operand:QI 0 "nonimmediate_operand" "=q,m,r")
8786 (ior:QI (match_operand:QI 1 "nonimmediate_operand" "%0,0,0")
8787 (match_operand:QI 2 "general_operand" "qmi,qi,ri")))
8788 (clobber (reg:CC 17))]
8789 "ix86_binary_operator_ok (IOR, QImode, operands)"
8790 "@
8791 or{b}\t{%2, %0|%0, %2}
8792 or{b}\t{%2, %0|%0, %2}
8793 or{l}\t{%k2, %k0|%k0, %k2}"
8794 [(set_attr "type" "alu")
8795 (set_attr "mode" "QI,QI,SI")])
8796
8797 (define_insn "*iorqi_1_slp"
8798 [(set (strict_low_part (match_operand:QI 0 "nonimmediate_operand" "+q,m"))
8799 (ior:QI (match_dup 0)
8800 (match_operand:QI 1 "general_operand" "qmi,qi")))
8801 (clobber (reg:CC 17))]
8802 ""
8803 "or{b}\t{%1, %0|%0, %1}"
8804 [(set_attr "type" "alu1")
8805 (set_attr "mode" "QI")])
8806
8807 (define_insn "*iorqi_2"
8808 [(set (reg 17)
8809 (compare (ior:QI (match_operand:QI 1 "nonimmediate_operand" "%0,0")
8810 (match_operand:QI 2 "general_operand" "qim,qi"))
8811 (const_int 0)))
8812 (set (match_operand:QI 0 "nonimmediate_operand" "=q,qm")
8813 (ior:QI (match_dup 1) (match_dup 2)))]
8814 "ix86_match_ccmode (insn, CCNOmode)
8815 && ix86_binary_operator_ok (IOR, QImode, operands)"
8816 "or{b}\t{%2, %0|%0, %2}"
8817 [(set_attr "type" "alu")
8818 (set_attr "mode" "QI")])
8819
8820 (define_insn "*iorqi_2_slp"
8821 [(set (reg 17)
8822 (compare (ior:QI (match_operand:QI 0 "nonimmediate_operand" "+q,qm")
8823 (match_operand:QI 1 "general_operand" "qim,qi"))
8824 (const_int 0)))
8825 (set (strict_low_part (match_dup 0))
8826 (ior:QI (match_dup 0) (match_dup 1)))]
8827 "ix86_match_ccmode (insn, CCNOmode)"
8828 "or{b}\t{%1, %0|%0, %1}"
8829 [(set_attr "type" "alu1")
8830 (set_attr "mode" "QI")])
8831
8832 (define_insn "*iorqi_3"
8833 [(set (reg 17)
8834 (compare (ior:QI (match_operand:QI 1 "nonimmediate_operand" "%0")
8835 (match_operand:QI 2 "general_operand" "qim"))
8836 (const_int 0)))
8837 (clobber (match_scratch:QI 0 "=q"))]
8838 "ix86_match_ccmode (insn, CCNOmode)
8839 && (GET_CODE (operands[1]) != MEM || GET_CODE (operands[2]) != MEM)"
8840 "or{b}\t{%2, %0|%0, %2}"
8841 [(set_attr "type" "alu")
8842 (set_attr "mode" "QI")])
8843
8844 \f
8845 ;; Logical XOR instructions
8846
8847 ;; %%% This used to optimize known byte-wide and operations to memory.
8848 ;; If this is considered useful, it should be done with splitters.
8849
8850 (define_expand "xordi3"
8851 [(set (match_operand:DI 0 "nonimmediate_operand" "")
8852 (xor:DI (match_operand:DI 1 "nonimmediate_operand" "")
8853 (match_operand:DI 2 "x86_64_general_operand" "")))
8854 (clobber (reg:CC 17))]
8855 "TARGET_64BIT"
8856 "ix86_expand_binary_operator (XOR, DImode, operands); DONE;")
8857
8858 (define_insn "*xordi_1_rex64"
8859 [(set (match_operand:DI 0 "nonimmediate_operand" "=rm,r")
8860 (xor:DI (match_operand:DI 1 "nonimmediate_operand" "%0,0")
8861 (match_operand:DI 2 "x86_64_general_operand" "re,rm")))
8862 (clobber (reg:CC 17))]
8863 "TARGET_64BIT
8864 && ix86_binary_operator_ok (XOR, DImode, operands)"
8865 "@
8866 xor{q}\t{%2, %0|%0, %2}
8867 xor{q}\t{%2, %0|%0, %2}"
8868 [(set_attr "type" "alu")
8869 (set_attr "mode" "DI,DI")])
8870
8871 (define_insn "*xordi_2_rex64"
8872 [(set (reg 17)
8873 (compare (xor:DI (match_operand:DI 1 "nonimmediate_operand" "%0,0")
8874 (match_operand:DI 2 "x86_64_general_operand" "rem,re"))
8875 (const_int 0)))
8876 (set (match_operand:DI 0 "nonimmediate_operand" "=r,rm")
8877 (xor:DI (match_dup 1) (match_dup 2)))]
8878 "TARGET_64BIT
8879 && ix86_match_ccmode (insn, CCNOmode)
8880 && ix86_binary_operator_ok (XOR, DImode, operands)"
8881 "@
8882 xor{q}\t{%2, %0|%0, %2}
8883 xor{q}\t{%2, %0|%0, %2}"
8884 [(set_attr "type" "alu")
8885 (set_attr "mode" "DI,DI")])
8886
8887 (define_insn "*xordi_3_rex64"
8888 [(set (reg 17)
8889 (compare (xor:DI (match_operand:DI 1 "nonimmediate_operand" "%0")
8890 (match_operand:DI 2 "x86_64_general_operand" "rem"))
8891 (const_int 0)))
8892 (clobber (match_scratch:DI 0 "=r"))]
8893 "TARGET_64BIT
8894 && ix86_match_ccmode (insn, CCNOmode)
8895 && ix86_binary_operator_ok (XOR, DImode, operands)"
8896 "xor{q}\t{%2, %0|%0, %2}"
8897 [(set_attr "type" "alu")
8898 (set_attr "mode" "DI")])
8899
8900 (define_expand "xorsi3"
8901 [(set (match_operand:SI 0 "nonimmediate_operand" "")
8902 (xor:SI (match_operand:SI 1 "nonimmediate_operand" "")
8903 (match_operand:SI 2 "general_operand" "")))
8904 (clobber (reg:CC 17))]
8905 ""
8906 "ix86_expand_binary_operator (XOR, SImode, operands); DONE;")
8907
8908 (define_insn "*xorsi_1"
8909 [(set (match_operand:SI 0 "nonimmediate_operand" "=rm,r")
8910 (xor:SI (match_operand:SI 1 "nonimmediate_operand" "%0,0")
8911 (match_operand:SI 2 "general_operand" "ri,rm")))
8912 (clobber (reg:CC 17))]
8913 "ix86_binary_operator_ok (XOR, SImode, operands)"
8914 "xor{l}\t{%2, %0|%0, %2}"
8915 [(set_attr "type" "alu")
8916 (set_attr "mode" "SI")])
8917
8918 ;; See comment for addsi_1_zext why we do use nonimmediate_operand
8919 ;; Add speccase for immediates
8920 (define_insn "*xorsi_1_zext"
8921 [(set (match_operand:DI 0 "register_operand" "=r")
8922 (zero_extend:DI
8923 (xor:SI (match_operand:SI 1 "nonimmediate_operand" "%0")
8924 (match_operand:SI 2 "general_operand" "rim"))))
8925 (clobber (reg:CC 17))]
8926 "TARGET_64BIT && ix86_binary_operator_ok (XOR, SImode, operands)"
8927 "xor{l}\t{%2, %k0|%k0, %2}"
8928 [(set_attr "type" "alu")
8929 (set_attr "mode" "SI")])
8930
8931 (define_insn "*xorsi_1_zext_imm"
8932 [(set (match_operand:DI 0 "register_operand" "=r")
8933 (xor:DI (zero_extend:DI (match_operand:SI 1 "register_operand" "%0"))
8934 (match_operand:DI 2 "x86_64_zext_immediate_operand" "Z")))
8935 (clobber (reg:CC 17))]
8936 "TARGET_64BIT && ix86_binary_operator_ok (XOR, SImode, operands)"
8937 "xor{l}\t{%2, %k0|%k0, %2}"
8938 [(set_attr "type" "alu")
8939 (set_attr "mode" "SI")])
8940
8941 (define_insn "*xorsi_2"
8942 [(set (reg 17)
8943 (compare (xor:SI (match_operand:SI 1 "nonimmediate_operand" "%0,0")
8944 (match_operand:SI 2 "general_operand" "rim,ri"))
8945 (const_int 0)))
8946 (set (match_operand:SI 0 "nonimmediate_operand" "=r,rm")
8947 (xor:SI (match_dup 1) (match_dup 2)))]
8948 "ix86_match_ccmode (insn, CCNOmode)
8949 && ix86_binary_operator_ok (XOR, SImode, operands)"
8950 "xor{l}\t{%2, %0|%0, %2}"
8951 [(set_attr "type" "alu")
8952 (set_attr "mode" "SI")])
8953
8954 ;; See comment for addsi_1_zext why we do use nonimmediate_operand
8955 ;; ??? Special case for immediate operand is missing - it is tricky.
8956 (define_insn "*xorsi_2_zext"
8957 [(set (reg 17)
8958 (compare (xor:SI (match_operand:SI 1 "nonimmediate_operand" "%0")
8959 (match_operand:SI 2 "general_operand" "rim"))
8960 (const_int 0)))
8961 (set (match_operand:DI 0 "register_operand" "=r")
8962 (zero_extend:DI (xor:SI (match_dup 1) (match_dup 2))))]
8963 "TARGET_64BIT && ix86_match_ccmode (insn, CCNOmode)
8964 && ix86_binary_operator_ok (XOR, SImode, operands)"
8965 "xor{l}\t{%2, %k0|%k0, %2}"
8966 [(set_attr "type" "alu")
8967 (set_attr "mode" "SI")])
8968
8969 (define_insn "*xorsi_2_zext_imm"
8970 [(set (reg 17)
8971 (compare (xor:SI (match_operand:SI 1 "nonimmediate_operand" "%0")
8972 (match_operand 2 "x86_64_zext_immediate_operand" "Z"))
8973 (const_int 0)))
8974 (set (match_operand:DI 0 "register_operand" "=r")
8975 (xor:DI (zero_extend:DI (match_dup 1)) (match_dup 2)))]
8976 "TARGET_64BIT && ix86_match_ccmode (insn, CCNOmode)
8977 && ix86_binary_operator_ok (XOR, SImode, operands)"
8978 "xor{l}\t{%2, %k0|%k0, %2}"
8979 [(set_attr "type" "alu")
8980 (set_attr "mode" "SI")])
8981
8982 (define_insn "*xorsi_3"
8983 [(set (reg 17)
8984 (compare (xor:SI (match_operand:SI 1 "nonimmediate_operand" "%0")
8985 (match_operand:SI 2 "general_operand" "rim"))
8986 (const_int 0)))
8987 (clobber (match_scratch:SI 0 "=r"))]
8988 "ix86_match_ccmode (insn, CCNOmode)
8989 && (GET_CODE (operands[1]) != MEM || GET_CODE (operands[2]) != MEM)"
8990 "xor{l}\t{%2, %0|%0, %2}"
8991 [(set_attr "type" "alu")
8992 (set_attr "mode" "SI")])
8993
8994 (define_expand "xorhi3"
8995 [(set (match_operand:HI 0 "nonimmediate_operand" "")
8996 (xor:HI (match_operand:HI 1 "nonimmediate_operand" "")
8997 (match_operand:HI 2 "general_operand" "")))
8998 (clobber (reg:CC 17))]
8999 "TARGET_HIMODE_MATH"
9000 "ix86_expand_binary_operator (XOR, HImode, operands); DONE;")
9001
9002 (define_insn "*xorhi_1"
9003 [(set (match_operand:HI 0 "nonimmediate_operand" "=r,m")
9004 (xor:HI (match_operand:HI 1 "nonimmediate_operand" "%0,0")
9005 (match_operand:HI 2 "general_operand" "rmi,ri")))
9006 (clobber (reg:CC 17))]
9007 "ix86_binary_operator_ok (XOR, HImode, operands)"
9008 "xor{w}\t{%2, %0|%0, %2}"
9009 [(set_attr "type" "alu")
9010 (set_attr "mode" "HI")])
9011
9012 (define_insn "*xorhi_2"
9013 [(set (reg 17)
9014 (compare (xor:HI (match_operand:HI 1 "nonimmediate_operand" "%0,0")
9015 (match_operand:HI 2 "general_operand" "rim,ri"))
9016 (const_int 0)))
9017 (set (match_operand:HI 0 "nonimmediate_operand" "=r,rm")
9018 (xor:HI (match_dup 1) (match_dup 2)))]
9019 "ix86_match_ccmode (insn, CCNOmode)
9020 && ix86_binary_operator_ok (XOR, HImode, operands)"
9021 "xor{w}\t{%2, %0|%0, %2}"
9022 [(set_attr "type" "alu")
9023 (set_attr "mode" "HI")])
9024
9025 (define_insn "*xorhi_3"
9026 [(set (reg 17)
9027 (compare (xor:HI (match_operand:HI 1 "nonimmediate_operand" "%0")
9028 (match_operand:HI 2 "general_operand" "rim"))
9029 (const_int 0)))
9030 (clobber (match_scratch:HI 0 "=r"))]
9031 "ix86_match_ccmode (insn, CCNOmode)
9032 && (GET_CODE (operands[1]) != MEM || GET_CODE (operands[2]) != MEM)"
9033 "xor{w}\t{%2, %0|%0, %2}"
9034 [(set_attr "type" "alu")
9035 (set_attr "mode" "HI")])
9036
9037 (define_expand "xorqi3"
9038 [(set (match_operand:QI 0 "nonimmediate_operand" "")
9039 (xor:QI (match_operand:QI 1 "nonimmediate_operand" "")
9040 (match_operand:QI 2 "general_operand" "")))
9041 (clobber (reg:CC 17))]
9042 "TARGET_QIMODE_MATH"
9043 "ix86_expand_binary_operator (XOR, QImode, operands); DONE;")
9044
9045 ;; %%% Potential partial reg stall on alternative 2. What to do?
9046 (define_insn "*xorqi_1"
9047 [(set (match_operand:QI 0 "nonimmediate_operand" "=q,m,r")
9048 (xor:QI (match_operand:QI 1 "nonimmediate_operand" "%0,0,0")
9049 (match_operand:QI 2 "general_operand" "qmi,qi,ri")))
9050 (clobber (reg:CC 17))]
9051 "ix86_binary_operator_ok (XOR, QImode, operands)"
9052 "@
9053 xor{b}\t{%2, %0|%0, %2}
9054 xor{b}\t{%2, %0|%0, %2}
9055 xor{l}\t{%k2, %k0|%k0, %k2}"
9056 [(set_attr "type" "alu")
9057 (set_attr "mode" "QI,QI,SI")])
9058
9059 (define_insn "*xorqi_ext_1"
9060 [(set (zero_extract:SI (match_operand 0 "ext_register_operand" "=Q")
9061 (const_int 8)
9062 (const_int 8))
9063 (xor:SI
9064 (zero_extract:SI (match_operand 1 "ext_register_operand" "0")
9065 (const_int 8)
9066 (const_int 8))
9067 (zero_extract:SI (match_operand 2 "ext_register_operand" "Q")
9068 (const_int 8)
9069 (const_int 8))))
9070 (clobber (reg:CC 17))]
9071 ""
9072 "xor{b}\t{%h2, %h0|%h0, %h2}"
9073 [(set_attr "type" "alu")
9074 (set_attr "length_immediate" "0")
9075 (set_attr "mode" "QI")])
9076
9077 (define_insn "*xorqi_cc_1"
9078 [(set (reg 17)
9079 (compare
9080 (xor:QI (match_operand:QI 1 "nonimmediate_operand" "%0,0")
9081 (match_operand:QI 2 "general_operand" "qim,qi"))
9082 (const_int 0)))
9083 (set (match_operand:QI 0 "nonimmediate_operand" "=q,qm")
9084 (xor:QI (match_dup 1) (match_dup 2)))]
9085 "ix86_match_ccmode (insn, CCNOmode)
9086 && ix86_binary_operator_ok (XOR, QImode, operands)"
9087 "xor{b}\t{%2, %0|%0, %2}"
9088 [(set_attr "type" "alu")
9089 (set_attr "mode" "QI")])
9090
9091 (define_insn "*xorqi_cc_2"
9092 [(set (reg 17)
9093 (compare
9094 (xor:QI (match_operand:QI 1 "nonimmediate_operand" "%0")
9095 (match_operand:QI 2 "general_operand" "qim"))
9096 (const_int 0)))
9097 (clobber (match_scratch:QI 0 "=q"))]
9098 "ix86_match_ccmode (insn, CCNOmode)
9099 && (GET_CODE (operands[1]) != MEM || GET_CODE (operands[2]) != MEM)"
9100 "xor{b}\t{%2, %0|%0, %2}"
9101 [(set_attr "type" "alu")
9102 (set_attr "mode" "QI")])
9103
9104 (define_insn "*xorqi_cc_ext_1"
9105 [(set (reg 17)
9106 (compare
9107 (xor:SI
9108 (zero_extract:SI
9109 (match_operand 1 "ext_register_operand" "0")
9110 (const_int 8)
9111 (const_int 8))
9112 (match_operand:QI 2 "general_operand" "qmn"))
9113 (const_int 0)))
9114 (set (zero_extract:SI (match_operand 0 "ext_register_operand" "=q")
9115 (const_int 8)
9116 (const_int 8))
9117 (xor:SI
9118 (zero_extract:SI (match_dup 1) (const_int 8) (const_int 8))
9119 (match_dup 2)))]
9120 "!TARGET_64BIT && ix86_match_ccmode (insn, CCNOmode)"
9121 "xor{b}\t{%2, %h0|%h0, %2}"
9122 [(set_attr "type" "alu")
9123 (set_attr "mode" "QI")])
9124
9125 (define_insn "*xorqi_cc_ext_1_rex64"
9126 [(set (reg 17)
9127 (compare
9128 (xor:SI
9129 (zero_extract:SI
9130 (match_operand 1 "ext_register_operand" "0")
9131 (const_int 8)
9132 (const_int 8))
9133 (match_operand:QI 2 "nonmemory_operand" "Qn"))
9134 (const_int 0)))
9135 (set (zero_extract:SI (match_operand 0 "ext_register_operand" "=Q")
9136 (const_int 8)
9137 (const_int 8))
9138 (xor:SI
9139 (zero_extract:SI (match_dup 1) (const_int 8) (const_int 8))
9140 (match_dup 2)))]
9141 "TARGET_64BIT && ix86_match_ccmode (insn, CCNOmode)"
9142 "xor{b}\t{%2, %h0|%h0, %2}"
9143 [(set_attr "type" "alu")
9144 (set_attr "mode" "QI")])
9145
9146 (define_expand "xorqi_cc_ext_1"
9147 [(parallel [
9148 (set (reg:CCNO 17)
9149 (compare:CCNO
9150 (xor:SI
9151 (zero_extract:SI
9152 (match_operand 1 "ext_register_operand" "")
9153 (const_int 8)
9154 (const_int 8))
9155 (match_operand:QI 2 "general_operand" ""))
9156 (const_int 0)))
9157 (set (zero_extract:SI (match_operand 0 "ext_register_operand" "")
9158 (const_int 8)
9159 (const_int 8))
9160 (xor:SI
9161 (zero_extract:SI (match_dup 1) (const_int 8) (const_int 8))
9162 (match_dup 2)))])]
9163 ""
9164 "")
9165 \f
9166 ;; Negation instructions
9167
9168 (define_expand "negdi2"
9169 [(parallel [(set (match_operand:DI 0 "nonimmediate_operand" "")
9170 (neg:DI (match_operand:DI 1 "nonimmediate_operand" "")))
9171 (clobber (reg:CC 17))])]
9172 ""
9173 "ix86_expand_unary_operator (NEG, DImode, operands); DONE;")
9174
9175 (define_insn "*negdi2_1"
9176 [(set (match_operand:DI 0 "nonimmediate_operand" "=ro")
9177 (neg:DI (match_operand:DI 1 "general_operand" "0")))
9178 (clobber (reg:CC 17))]
9179 "!TARGET_64BIT
9180 && ix86_unary_operator_ok (NEG, DImode, operands)"
9181 "#")
9182
9183 (define_split
9184 [(set (match_operand:DI 0 "nonimmediate_operand" "")
9185 (neg:DI (match_operand:DI 1 "general_operand" "")))
9186 (clobber (reg:CC 17))]
9187 "!TARGET_64BIT && reload_completed"
9188 [(parallel
9189 [(set (reg:CCZ 17)
9190 (compare:CCZ (neg:SI (match_dup 2)) (const_int 0)))
9191 (set (match_dup 0) (neg:SI (match_dup 2)))])
9192 (parallel
9193 [(set (match_dup 1)
9194 (plus:SI (plus:SI (ltu:SI (reg:CC 17) (const_int 0))
9195 (match_dup 3))
9196 (const_int 0)))
9197 (clobber (reg:CC 17))])
9198 (parallel
9199 [(set (match_dup 1)
9200 (neg:SI (match_dup 1)))
9201 (clobber (reg:CC 17))])]
9202 "split_di (operands+1, 1, operands+2, operands+3);
9203 split_di (operands+0, 1, operands+0, operands+1);")
9204
9205 (define_insn "*negdi2_1_rex64"
9206 [(set (match_operand:DI 0 "nonimmediate_operand" "=rm")
9207 (neg:DI (match_operand:DI 1 "nonimmediate_operand" "0")))
9208 (clobber (reg:CC 17))]
9209 "TARGET_64BIT && ix86_unary_operator_ok (NEG, DImode, operands)"
9210 "neg{q}\t%0"
9211 [(set_attr "type" "negnot")
9212 (set_attr "mode" "DI")])
9213
9214 ;; The problem with neg is that it does not perform (compare x 0),
9215 ;; it really performs (compare 0 x), which leaves us with the zero
9216 ;; flag being the only useful item.
9217
9218 (define_insn "*negdi2_cmpz_rex64"
9219 [(set (reg:CCZ 17)
9220 (compare:CCZ (neg:DI (match_operand:DI 1 "nonimmediate_operand" "0"))
9221 (const_int 0)))
9222 (set (match_operand:DI 0 "nonimmediate_operand" "=rm")
9223 (neg:DI (match_dup 1)))]
9224 "TARGET_64BIT && ix86_unary_operator_ok (NEG, DImode, operands)"
9225 "neg{q}\t%0"
9226 [(set_attr "type" "negnot")
9227 (set_attr "mode" "DI")])
9228
9229
9230 (define_expand "negsi2"
9231 [(parallel [(set (match_operand:SI 0 "nonimmediate_operand" "")
9232 (neg:SI (match_operand:SI 1 "nonimmediate_operand" "")))
9233 (clobber (reg:CC 17))])]
9234 ""
9235 "ix86_expand_unary_operator (NEG, SImode, operands); DONE;")
9236
9237 (define_insn "*negsi2_1"
9238 [(set (match_operand:SI 0 "nonimmediate_operand" "=rm")
9239 (neg:SI (match_operand:SI 1 "nonimmediate_operand" "0")))
9240 (clobber (reg:CC 17))]
9241 "ix86_unary_operator_ok (NEG, SImode, operands)"
9242 "neg{l}\t%0"
9243 [(set_attr "type" "negnot")
9244 (set_attr "mode" "SI")])
9245
9246 ;; Combine is quite creative about this pattern.
9247 (define_insn "*negsi2_1_zext"
9248 [(set (match_operand:DI 0 "register_operand" "=r")
9249 (lshiftrt:DI (neg:DI (ashift:DI (match_operand:DI 1 "register_operand" "0")
9250 (const_int 32)))
9251 (const_int 32)))
9252 (clobber (reg:CC 17))]
9253 "TARGET_64BIT && ix86_unary_operator_ok (NEG, SImode, operands)"
9254 "neg{l}\t%k0"
9255 [(set_attr "type" "negnot")
9256 (set_attr "mode" "SI")])
9257
9258 ;; The problem with neg is that it does not perform (compare x 0),
9259 ;; it really performs (compare 0 x), which leaves us with the zero
9260 ;; flag being the only useful item.
9261
9262 (define_insn "*negsi2_cmpz"
9263 [(set (reg:CCZ 17)
9264 (compare:CCZ (neg:SI (match_operand:SI 1 "nonimmediate_operand" "0"))
9265 (const_int 0)))
9266 (set (match_operand:SI 0 "nonimmediate_operand" "=rm")
9267 (neg:SI (match_dup 1)))]
9268 "ix86_unary_operator_ok (NEG, SImode, operands)"
9269 "neg{l}\t%0"
9270 [(set_attr "type" "negnot")
9271 (set_attr "mode" "SI")])
9272
9273 (define_insn "*negsi2_cmpz_zext"
9274 [(set (reg:CCZ 17)
9275 (compare:CCZ (lshiftrt:DI
9276 (neg:DI (ashift:DI
9277 (match_operand:DI 1 "register_operand" "0")
9278 (const_int 32)))
9279 (const_int 32))
9280 (const_int 0)))
9281 (set (match_operand:DI 0 "register_operand" "=r")
9282 (lshiftrt:DI (neg:DI (ashift:DI (match_dup 1)
9283 (const_int 32)))
9284 (const_int 32)))]
9285 "TARGET_64BIT && ix86_unary_operator_ok (NEG, SImode, operands)"
9286 "neg{l}\t%k0"
9287 [(set_attr "type" "negnot")
9288 (set_attr "mode" "SI")])
9289
9290 (define_expand "neghi2"
9291 [(parallel [(set (match_operand:HI 0 "nonimmediate_operand" "")
9292 (neg:HI (match_operand:HI 1 "nonimmediate_operand" "")))
9293 (clobber (reg:CC 17))])]
9294 "TARGET_HIMODE_MATH"
9295 "ix86_expand_unary_operator (NEG, HImode, operands); DONE;")
9296
9297 (define_insn "*neghi2_1"
9298 [(set (match_operand:HI 0 "nonimmediate_operand" "=rm")
9299 (neg:HI (match_operand:HI 1 "nonimmediate_operand" "0")))
9300 (clobber (reg:CC 17))]
9301 "ix86_unary_operator_ok (NEG, HImode, operands)"
9302 "neg{w}\t%0"
9303 [(set_attr "type" "negnot")
9304 (set_attr "mode" "HI")])
9305
9306 (define_insn "*neghi2_cmpz"
9307 [(set (reg:CCZ 17)
9308 (compare:CCZ (neg:HI (match_operand:HI 1 "nonimmediate_operand" "0"))
9309 (const_int 0)))
9310 (set (match_operand:HI 0 "nonimmediate_operand" "=rm")
9311 (neg:HI (match_dup 1)))]
9312 "ix86_unary_operator_ok (NEG, HImode, operands)"
9313 "neg{w}\t%0"
9314 [(set_attr "type" "negnot")
9315 (set_attr "mode" "HI")])
9316
9317 (define_expand "negqi2"
9318 [(parallel [(set (match_operand:QI 0 "nonimmediate_operand" "")
9319 (neg:QI (match_operand:QI 1 "nonimmediate_operand" "")))
9320 (clobber (reg:CC 17))])]
9321 "TARGET_QIMODE_MATH"
9322 "ix86_expand_unary_operator (NEG, QImode, operands); DONE;")
9323
9324 (define_insn "*negqi2_1"
9325 [(set (match_operand:QI 0 "nonimmediate_operand" "=qm")
9326 (neg:QI (match_operand:QI 1 "nonimmediate_operand" "0")))
9327 (clobber (reg:CC 17))]
9328 "ix86_unary_operator_ok (NEG, QImode, operands)"
9329 "neg{b}\t%0"
9330 [(set_attr "type" "negnot")
9331 (set_attr "mode" "QI")])
9332
9333 (define_insn "*negqi2_cmpz"
9334 [(set (reg:CCZ 17)
9335 (compare:CCZ (neg:QI (match_operand:QI 1 "nonimmediate_operand" "0"))
9336 (const_int 0)))
9337 (set (match_operand:QI 0 "nonimmediate_operand" "=qm")
9338 (neg:QI (match_dup 1)))]
9339 "ix86_unary_operator_ok (NEG, QImode, operands)"
9340 "neg{b}\t%0"
9341 [(set_attr "type" "negnot")
9342 (set_attr "mode" "QI")])
9343
9344 ;; Changing of sign for FP values is doable using integer unit too.
9345
9346 (define_expand "negsf2"
9347 [(parallel [(set (match_operand:SF 0 "nonimmediate_operand" "")
9348 (neg:SF (match_operand:SF 1 "nonimmediate_operand" "")))
9349 (clobber (reg:CC 17))])]
9350 "TARGET_80387"
9351 "if (TARGET_SSE)
9352 {
9353 /* In case operand is in memory, we will not use SSE. */
9354 if (memory_operand (operands[0], VOIDmode)
9355 && rtx_equal_p (operands[0], operands[1]))
9356 emit_insn (gen_negsf2_memory (operands[0], operands[1]));
9357 else
9358 {
9359 /* Using SSE is tricky, since we need bitwise negation of -0
9360 in register. */
9361 rtx reg = gen_reg_rtx (SFmode);
9362 rtx dest = operands[0];
9363
9364 operands[1] = force_reg (SFmode, operands[1]);
9365 operands[0] = force_reg (SFmode, operands[0]);
9366 emit_move_insn (reg,
9367 gen_lowpart (SFmode,
9368 GEN_INT (trunc_int_for_mode (0x80000000,
9369 SImode))));
9370 emit_insn (gen_negsf2_ifs (operands[0], operands[1], reg));
9371 if (dest != operands[0])
9372 emit_move_insn (dest, operands[0]);
9373 }
9374 DONE;
9375 }
9376 ix86_expand_unary_operator (NEG, SFmode, operands); DONE;")
9377
9378 (define_insn "negsf2_memory"
9379 [(set (match_operand:SF 0 "memory_operand" "=m")
9380 (neg:SF (match_operand:SF 1 "memory_operand" "0")))
9381 (clobber (reg:CC 17))]
9382 "ix86_unary_operator_ok (NEG, SFmode, operands)"
9383 "#")
9384
9385 (define_insn "negsf2_ifs"
9386 [(set (match_operand:SF 0 "nonimmediate_operand" "=x#fr,x#fr,f#xr,rm#xf")
9387 (neg:SF (match_operand:SF 1 "nonimmediate_operand" "0,x#fr,0,0")))
9388 (use (match_operand:SF 2 "nonmemory_operand" "x,0#x,*g#x,*g#x"))
9389 (clobber (reg:CC 17))]
9390 "TARGET_SSE
9391 && (reload_in_progress || reload_completed
9392 || (register_operand (operands[0], VOIDmode)
9393 && register_operand (operands[1], VOIDmode)))"
9394 "#")
9395
9396 (define_split
9397 [(set (match_operand:SF 0 "memory_operand" "")
9398 (neg:SF (match_operand:SF 1 "memory_operand" "")))
9399 (use (match_operand:SF 2 "" ""))
9400 (clobber (reg:CC 17))]
9401 ""
9402 [(parallel [(set (match_dup 0)
9403 (neg:SF (match_dup 1)))
9404 (clobber (reg:CC 17))])])
9405
9406 (define_split
9407 [(set (match_operand:SF 0 "register_operand" "")
9408 (neg:SF (match_operand:SF 1 "register_operand" "")))
9409 (use (match_operand:SF 2 "" ""))
9410 (clobber (reg:CC 17))]
9411 "reload_completed && !SSE_REG_P (operands[0])"
9412 [(parallel [(set (match_dup 0)
9413 (neg:SF (match_dup 1)))
9414 (clobber (reg:CC 17))])])
9415
9416 (define_split
9417 [(set (match_operand:SF 0 "register_operand" "")
9418 (neg:SF (match_operand:SF 1 "register_operand" "")))
9419 (use (match_operand:SF 2 "register_operand" ""))
9420 (clobber (reg:CC 17))]
9421 "reload_completed && SSE_REG_P (operands[0])"
9422 [(set (subreg:TI (match_dup 0) 0)
9423 (xor:TI (subreg:TI (match_dup 1) 0)
9424 (subreg:TI (match_dup 2) 0)))]
9425 {
9426 if (operands_match_p (operands[0], operands[2]))
9427 {
9428 rtx tmp;
9429 tmp = operands[1];
9430 operands[1] = operands[2];
9431 operands[2] = tmp;
9432 }
9433 })
9434
9435
9436 ;; Keep 'f' and 'r' in separate alternatives to avoid reload problems
9437 ;; because of secondary memory needed to reload from class FLOAT_INT_REGS
9438 ;; to itself.
9439 (define_insn "*negsf2_if"
9440 [(set (match_operand:SF 0 "nonimmediate_operand" "=f#r,rm#f")
9441 (neg:SF (match_operand:SF 1 "nonimmediate_operand" "0,0")))
9442 (clobber (reg:CC 17))]
9443 "TARGET_80387 && !TARGET_SSE
9444 && ix86_unary_operator_ok (NEG, SFmode, operands)"
9445 "#")
9446
9447 (define_split
9448 [(set (match_operand:SF 0 "register_operand" "")
9449 (neg:SF (match_operand:SF 1 "register_operand" "")))
9450 (clobber (reg:CC 17))]
9451 "TARGET_80387 && FP_REGNO_P (REGNO (operands[0])) && reload_completed"
9452 [(set (match_dup 0)
9453 (neg:SF (match_dup 1)))]
9454 "")
9455
9456 (define_split
9457 [(set (match_operand:SF 0 "register_operand" "")
9458 (neg:SF (match_operand:SF 1 "register_operand" "")))
9459 (clobber (reg:CC 17))]
9460 "TARGET_80387 && reload_completed && !FP_REGNO_P (REGNO (operands[0]))"
9461 [(parallel [(set (match_dup 0) (xor:SI (match_dup 0) (match_dup 1)))
9462 (clobber (reg:CC 17))])]
9463 "operands[1] = GEN_INT (trunc_int_for_mode (0x80000000, SImode));
9464 operands[0] = gen_rtx_REG (SImode, REGNO (operands[0]));")
9465
9466 (define_split
9467 [(set (match_operand 0 "memory_operand" "")
9468 (neg (match_operand 1 "memory_operand" "")))
9469 (clobber (reg:CC 17))]
9470 "TARGET_80387 && reload_completed && FLOAT_MODE_P (GET_MODE (operands[0]))"
9471 [(parallel [(set (match_dup 0) (xor:QI (match_dup 0) (match_dup 1)))
9472 (clobber (reg:CC 17))])]
9473 {
9474 int size = GET_MODE_SIZE (GET_MODE (operands[1]));
9475
9476 /* XFmode's size is 12, TFmode 16, but only 10 bytes are used. */
9477 if (size >= 12)
9478 size = 10;
9479 operands[0] = adjust_address (operands[0], QImode, size - 1);
9480 operands[1] = GEN_INT (trunc_int_for_mode (0x80, QImode));
9481 })
9482
9483 (define_expand "negdf2"
9484 [(parallel [(set (match_operand:DF 0 "nonimmediate_operand" "")
9485 (neg:DF (match_operand:DF 1 "nonimmediate_operand" "")))
9486 (clobber (reg:CC 17))])]
9487 "TARGET_80387"
9488 "if (TARGET_SSE2)
9489 {
9490 /* In case operand is in memory, we will not use SSE. */
9491 if (memory_operand (operands[0], VOIDmode)
9492 && rtx_equal_p (operands[0], operands[1]))
9493 emit_insn (gen_negdf2_memory (operands[0], operands[1]));
9494 else
9495 {
9496 /* Using SSE is tricky, since we need bitwise negation of -0
9497 in register. */
9498 rtx reg = gen_reg_rtx (DFmode);
9499 #if HOST_BITS_PER_WIDE_INT >= 64
9500 rtx imm = GEN_INT (trunc_int_for_mode(((HOST_WIDE_INT)1) << 63,
9501 DImode));
9502 #else
9503 rtx imm = immed_double_const (0, 0x80000000, DImode);
9504 #endif
9505 rtx dest = operands[0];
9506
9507 operands[1] = force_reg (DFmode, operands[1]);
9508 operands[0] = force_reg (DFmode, operands[0]);
9509 emit_move_insn (reg, gen_lowpart (DFmode, imm));
9510 emit_insn (gen_negdf2_ifs (operands[0], operands[1], reg));
9511 if (dest != operands[0])
9512 emit_move_insn (dest, operands[0]);
9513 }
9514 DONE;
9515 }
9516 ix86_expand_unary_operator (NEG, DFmode, operands); DONE;")
9517
9518 (define_insn "negdf2_memory"
9519 [(set (match_operand:DF 0 "memory_operand" "=m")
9520 (neg:DF (match_operand:DF 1 "memory_operand" "0")))
9521 (clobber (reg:CC 17))]
9522 "ix86_unary_operator_ok (NEG, DFmode, operands)"
9523 "#")
9524
9525 (define_insn "negdf2_ifs"
9526 [(set (match_operand:DF 0 "nonimmediate_operand" "=Y#fr,Y#fr,f#Yr,rm#Yf")
9527 (neg:DF (match_operand:DF 1 "nonimmediate_operand" "0,Y#fr,0,0")))
9528 (use (match_operand:DF 2 "nonmemory_operand" "Y,0,*g#Y,*g#Y"))
9529 (clobber (reg:CC 17))]
9530 "!TARGET_64BIT && TARGET_SSE2
9531 && (reload_in_progress || reload_completed
9532 || (register_operand (operands[0], VOIDmode)
9533 && register_operand (operands[1], VOIDmode)))"
9534 "#")
9535
9536 (define_insn "*negdf2_ifs_rex64"
9537 [(set (match_operand:DF 0 "nonimmediate_operand" "=Y#fr,Y#fr,fm#Yr,r#Yf")
9538 (neg:DF (match_operand:DF 1 "nonimmediate_operand" "0,Y#fr,0,0")))
9539 (use (match_operand:DF 2 "general_operand" "Y,0,*g#Yr,*rm"))
9540 (clobber (reg:CC 17))]
9541 "TARGET_64BIT && TARGET_SSE2
9542 && (reload_in_progress || reload_completed
9543 || (register_operand (operands[0], VOIDmode)
9544 && register_operand (operands[1], VOIDmode)))"
9545 "#")
9546
9547 (define_split
9548 [(set (match_operand:DF 0 "memory_operand" "")
9549 (neg:DF (match_operand:DF 1 "memory_operand" "")))
9550 (use (match_operand:DF 2 "" ""))
9551 (clobber (reg:CC 17))]
9552 ""
9553 [(parallel [(set (match_dup 0)
9554 (neg:DF (match_dup 1)))
9555 (clobber (reg:CC 17))])])
9556
9557 (define_split
9558 [(set (match_operand:DF 0 "register_operand" "")
9559 (neg:DF (match_operand:DF 1 "register_operand" "")))
9560 (use (match_operand:DF 2 "" ""))
9561 (clobber (reg:CC 17))]
9562 "reload_completed && !SSE_REG_P (operands[0])
9563 && (!TARGET_64BIT || FP_REG_P (operands[0]))"
9564 [(parallel [(set (match_dup 0)
9565 (neg:DF (match_dup 1)))
9566 (clobber (reg:CC 17))])])
9567
9568 (define_split
9569 [(set (match_operand:DF 0 "register_operand" "")
9570 (neg:DF (match_operand:DF 1 "register_operand" "")))
9571 (use (match_operand:DF 2 "" ""))
9572 (clobber (reg:CC 17))]
9573 "TARGET_64BIT && reload_completed && GENERAL_REG_P (operands[0])"
9574 [(parallel [(set (match_dup 0)
9575 (xor:DI (match_dup 1) (match_dup 2)))
9576 (clobber (reg:CC 17))])]
9577 "operands[0] = gen_lowpart (DImode, operands[0]);
9578 operands[1] = gen_lowpart (DImode, operands[1]);
9579 operands[2] = gen_lowpart (DImode, operands[2]);")
9580
9581 (define_split
9582 [(set (match_operand:DF 0 "register_operand" "")
9583 (neg:DF (match_operand:DF 1 "register_operand" "")))
9584 (use (match_operand:DF 2 "register_operand" ""))
9585 (clobber (reg:CC 17))]
9586 "reload_completed && SSE_REG_P (operands[0])"
9587 [(set (subreg:TI (match_dup 0) 0)
9588 (xor:TI (subreg:TI (match_dup 1) 0)
9589 (subreg:TI (match_dup 2) 0)))]
9590 {
9591 if (operands_match_p (operands[0], operands[2]))
9592 {
9593 rtx tmp;
9594 tmp = operands[1];
9595 operands[1] = operands[2];
9596 operands[2] = tmp;
9597 }
9598 })
9599
9600 ;; Keep 'f' and 'r' in separate alternatives to avoid reload problems
9601 ;; because of secondary memory needed to reload from class FLOAT_INT_REGS
9602 ;; to itself.
9603 (define_insn "*negdf2_if"
9604 [(set (match_operand:DF 0 "nonimmediate_operand" "=f#r,rm#f")
9605 (neg:DF (match_operand:DF 1 "nonimmediate_operand" "0,0")))
9606 (clobber (reg:CC 17))]
9607 "!TARGET_64BIT && TARGET_80387
9608 && ix86_unary_operator_ok (NEG, DFmode, operands)"
9609 "#")
9610
9611 ;; FIXME: We should to allow integer registers here. Problem is that
9612 ;; we need another scratch register to get constant from.
9613 ;; Forcing constant to mem if no register available in peep2 should be
9614 ;; safe even for PIC mode, because of RIP relative addressing.
9615 (define_insn "*negdf2_if_rex64"
9616 [(set (match_operand:DF 0 "nonimmediate_operand" "=f,mf")
9617 (neg:DF (match_operand:DF 1 "nonimmediate_operand" "0,0")))
9618 (clobber (reg:CC 17))]
9619 "TARGET_64BIT && TARGET_80387
9620 && ix86_unary_operator_ok (NEG, DFmode, operands)"
9621 "#")
9622
9623 (define_split
9624 [(set (match_operand:DF 0 "register_operand" "")
9625 (neg:DF (match_operand:DF 1 "register_operand" "")))
9626 (clobber (reg:CC 17))]
9627 "TARGET_80387 && FP_REGNO_P (REGNO (operands[0])) && reload_completed"
9628 [(set (match_dup 0)
9629 (neg:DF (match_dup 1)))]
9630 "")
9631
9632 (define_split
9633 [(set (match_operand:DF 0 "register_operand" "")
9634 (neg:DF (match_operand:DF 1 "register_operand" "")))
9635 (clobber (reg:CC 17))]
9636 "!TARGET_64BIT && TARGET_80387 && reload_completed
9637 && !FP_REGNO_P (REGNO (operands[0]))"
9638 [(parallel [(set (match_dup 3) (xor:SI (match_dup 3) (match_dup 4)))
9639 (clobber (reg:CC 17))])]
9640 "operands[4] = GEN_INT (trunc_int_for_mode (0x80000000, SImode));
9641 split_di (operands+0, 1, operands+2, operands+3);")
9642
9643 (define_expand "negxf2"
9644 [(parallel [(set (match_operand:XF 0 "nonimmediate_operand" "")
9645 (neg:XF (match_operand:XF 1 "nonimmediate_operand" "")))
9646 (clobber (reg:CC 17))])]
9647 "!TARGET_64BIT && TARGET_80387"
9648 "ix86_expand_unary_operator (NEG, XFmode, operands); DONE;")
9649
9650 (define_expand "negtf2"
9651 [(parallel [(set (match_operand:TF 0 "nonimmediate_operand" "")
9652 (neg:TF (match_operand:TF 1 "nonimmediate_operand" "")))
9653 (clobber (reg:CC 17))])]
9654 "TARGET_80387"
9655 "ix86_expand_unary_operator (NEG, TFmode, operands); DONE;")
9656
9657 ;; Keep 'f' and 'r' in separate alternatives to avoid reload problems
9658 ;; because of secondary memory needed to reload from class FLOAT_INT_REGS
9659 ;; to itself.
9660 (define_insn "*negxf2_if"
9661 [(set (match_operand:XF 0 "nonimmediate_operand" "=f#r,rm#f")
9662 (neg:XF (match_operand:XF 1 "nonimmediate_operand" "0,0")))
9663 (clobber (reg:CC 17))]
9664 "!TARGET_64BIT && TARGET_80387
9665 && ix86_unary_operator_ok (NEG, XFmode, operands)"
9666 "#")
9667
9668 (define_split
9669 [(set (match_operand:XF 0 "register_operand" "")
9670 (neg:XF (match_operand:XF 1 "register_operand" "")))
9671 (clobber (reg:CC 17))]
9672 "TARGET_80387 && FP_REGNO_P (REGNO (operands[0])) && reload_completed"
9673 [(set (match_dup 0)
9674 (neg:XF (match_dup 1)))]
9675 "")
9676
9677 (define_split
9678 [(set (match_operand:XF 0 "register_operand" "")
9679 (neg:XF (match_operand:XF 1 "register_operand" "")))
9680 (clobber (reg:CC 17))]
9681 "TARGET_80387 && reload_completed && !FP_REGNO_P (REGNO (operands[0]))"
9682 [(parallel [(set (match_dup 0) (xor:SI (match_dup 0) (match_dup 1)))
9683 (clobber (reg:CC 17))])]
9684 "operands[1] = GEN_INT (0x8000);
9685 operands[0] = gen_rtx_REG (SImode,
9686 true_regnum (operands[0]) + (TARGET_64BIT ? 1 : 2));")
9687
9688 ;; Keep 'f' and 'r' in separate alternatives to avoid reload problems
9689 ;; because of secondary memory needed to reload from class FLOAT_INT_REGS
9690 ;; to itself.
9691 (define_insn "*negtf2_if"
9692 [(set (match_operand:TF 0 "nonimmediate_operand" "=f#r,rm#f")
9693 (neg:TF (match_operand:TF 1 "nonimmediate_operand" "0,0")))
9694 (clobber (reg:CC 17))]
9695 "TARGET_80387 && ix86_unary_operator_ok (NEG, TFmode, operands)"
9696 "#")
9697
9698 (define_split
9699 [(set (match_operand:TF 0 "register_operand" "")
9700 (neg:TF (match_operand:TF 1 "register_operand" "")))
9701 (clobber (reg:CC 17))]
9702 "TARGET_80387 && FP_REGNO_P (REGNO (operands[0])) && reload_completed"
9703 [(set (match_dup 0)
9704 (neg:TF (match_dup 1)))]
9705 "")
9706
9707 (define_split
9708 [(set (match_operand:TF 0 "register_operand" "")
9709 (neg:TF (match_operand:TF 1 "register_operand" "")))
9710 (clobber (reg:CC 17))]
9711 "TARGET_80387 && reload_completed && !FP_REGNO_P (REGNO (operands[0]))"
9712 [(parallel [(set (match_dup 0) (xor:SI (match_dup 0) (match_dup 1)))
9713 (clobber (reg:CC 17))])]
9714 "operands[1] = GEN_INT (0x8000);
9715 operands[0] = gen_rtx_REG (SImode,
9716 true_regnum (operands[0]) + (TARGET_64BIT ? 1 : 2));")
9717
9718 ;; Conditionize these after reload. If they matches before reload, we
9719 ;; lose the clobber and ability to use integer instructions.
9720
9721 (define_insn "*negsf2_1"
9722 [(set (match_operand:SF 0 "register_operand" "=f")
9723 (neg:SF (match_operand:SF 1 "register_operand" "0")))]
9724 "TARGET_80387 && reload_completed"
9725 "fchs"
9726 [(set_attr "type" "fsgn")
9727 (set_attr "mode" "SF")
9728 (set_attr "ppro_uops" "few")])
9729
9730 (define_insn "*negdf2_1"
9731 [(set (match_operand:DF 0 "register_operand" "=f")
9732 (neg:DF (match_operand:DF 1 "register_operand" "0")))]
9733 "TARGET_80387 && reload_completed"
9734 "fchs"
9735 [(set_attr "type" "fsgn")
9736 (set_attr "mode" "DF")
9737 (set_attr "ppro_uops" "few")])
9738
9739 (define_insn "*negextendsfdf2"
9740 [(set (match_operand:DF 0 "register_operand" "=f")
9741 (neg:DF (float_extend:DF
9742 (match_operand:SF 1 "register_operand" "0"))))]
9743 "TARGET_80387"
9744 "fchs"
9745 [(set_attr "type" "fsgn")
9746 (set_attr "mode" "DF")
9747 (set_attr "ppro_uops" "few")])
9748
9749 (define_insn "*negxf2_1"
9750 [(set (match_operand:XF 0 "register_operand" "=f")
9751 (neg:XF (match_operand:XF 1 "register_operand" "0")))]
9752 "!TARGET_64BIT && TARGET_80387 && reload_completed"
9753 "fchs"
9754 [(set_attr "type" "fsgn")
9755 (set_attr "mode" "XF")
9756 (set_attr "ppro_uops" "few")])
9757
9758 (define_insn "*negextenddfxf2"
9759 [(set (match_operand:XF 0 "register_operand" "=f")
9760 (neg:XF (float_extend:XF
9761 (match_operand:DF 1 "register_operand" "0"))))]
9762 "!TARGET_64BIT && TARGET_80387"
9763 "fchs"
9764 [(set_attr "type" "fsgn")
9765 (set_attr "mode" "XF")
9766 (set_attr "ppro_uops" "few")])
9767
9768 (define_insn "*negextendsfxf2"
9769 [(set (match_operand:XF 0 "register_operand" "=f")
9770 (neg:XF (float_extend:XF
9771 (match_operand:SF 1 "register_operand" "0"))))]
9772 "!TARGET_64BIT && TARGET_80387"
9773 "fchs"
9774 [(set_attr "type" "fsgn")
9775 (set_attr "mode" "XF")
9776 (set_attr "ppro_uops" "few")])
9777
9778 (define_insn "*negtf2_1"
9779 [(set (match_operand:TF 0 "register_operand" "=f")
9780 (neg:TF (match_operand:TF 1 "register_operand" "0")))]
9781 "TARGET_80387 && reload_completed"
9782 "fchs"
9783 [(set_attr "type" "fsgn")
9784 (set_attr "mode" "XF")
9785 (set_attr "ppro_uops" "few")])
9786
9787 (define_insn "*negextenddftf2"
9788 [(set (match_operand:TF 0 "register_operand" "=f")
9789 (neg:TF (float_extend:TF
9790 (match_operand:DF 1 "register_operand" "0"))))]
9791 "TARGET_80387"
9792 "fchs"
9793 [(set_attr "type" "fsgn")
9794 (set_attr "mode" "XF")
9795 (set_attr "ppro_uops" "few")])
9796
9797 (define_insn "*negextendsftf2"
9798 [(set (match_operand:TF 0 "register_operand" "=f")
9799 (neg:TF (float_extend:TF
9800 (match_operand:SF 1 "register_operand" "0"))))]
9801 "TARGET_80387"
9802 "fchs"
9803 [(set_attr "type" "fsgn")
9804 (set_attr "mode" "XF")
9805 (set_attr "ppro_uops" "few")])
9806 \f
9807 ;; Absolute value instructions
9808
9809 (define_expand "abssf2"
9810 [(parallel [(set (match_operand:SF 0 "nonimmediate_operand" "")
9811 (neg:SF (match_operand:SF 1 "nonimmediate_operand" "")))
9812 (clobber (reg:CC 17))])]
9813 "TARGET_80387"
9814 "if (TARGET_SSE)
9815 {
9816 /* In case operand is in memory, we will not use SSE. */
9817 if (memory_operand (operands[0], VOIDmode)
9818 && rtx_equal_p (operands[0], operands[1]))
9819 emit_insn (gen_abssf2_memory (operands[0], operands[1]));
9820 else
9821 {
9822 /* Using SSE is tricky, since we need bitwise negation of -0
9823 in register. */
9824 rtx reg = gen_reg_rtx (SFmode);
9825 rtx dest = operands[0];
9826
9827 operands[1] = force_reg (SFmode, operands[1]);
9828 operands[0] = force_reg (SFmode, operands[0]);
9829 emit_move_insn (reg,
9830 gen_lowpart (SFmode,
9831 GEN_INT (trunc_int_for_mode (0x80000000,
9832 SImode))));
9833 emit_insn (gen_abssf2_ifs (operands[0], operands[1], reg));
9834 if (dest != operands[0])
9835 emit_move_insn (dest, operands[0]);
9836 }
9837 DONE;
9838 }
9839 ix86_expand_unary_operator (ABS, SFmode, operands); DONE;")
9840
9841 (define_insn "abssf2_memory"
9842 [(set (match_operand:SF 0 "memory_operand" "=m")
9843 (abs:SF (match_operand:SF 1 "memory_operand" "0")))
9844 (clobber (reg:CC 17))]
9845 "ix86_unary_operator_ok (ABS, SFmode, operands)"
9846 "#")
9847
9848 (define_insn "abssf2_ifs"
9849 [(set (match_operand:SF 0 "nonimmediate_operand" "=x#fr,f#xr,rm#xf")
9850 (abs:SF (match_operand:SF 1 "nonimmediate_operand" "x,0,0")))
9851 (use (match_operand:SF 2 "nonmemory_operand" "*0#x,*g#x,*g#x"))
9852 (clobber (reg:CC 17))]
9853 "TARGET_SSE
9854 && (reload_in_progress || reload_completed
9855 || (register_operand (operands[0], VOIDmode)
9856 && register_operand (operands[1], VOIDmode)))"
9857 "#")
9858
9859 (define_split
9860 [(set (match_operand:SF 0 "memory_operand" "")
9861 (abs:SF (match_operand:SF 1 "memory_operand" "")))
9862 (use (match_operand:SF 2 "" ""))
9863 (clobber (reg:CC 17))]
9864 ""
9865 [(parallel [(set (match_dup 0)
9866 (abs:SF (match_dup 1)))
9867 (clobber (reg:CC 17))])])
9868
9869 (define_split
9870 [(set (match_operand:SF 0 "register_operand" "")
9871 (abs:SF (match_operand:SF 1 "register_operand" "")))
9872 (use (match_operand:SF 2 "" ""))
9873 (clobber (reg:CC 17))]
9874 "reload_completed && !SSE_REG_P (operands[0])"
9875 [(parallel [(set (match_dup 0)
9876 (abs:SF (match_dup 1)))
9877 (clobber (reg:CC 17))])])
9878
9879 (define_split
9880 [(set (match_operand:SF 0 "register_operand" "")
9881 (abs:SF (match_operand:SF 1 "register_operand" "")))
9882 (use (match_operand:SF 2 "register_operand" ""))
9883 (clobber (reg:CC 17))]
9884 "reload_completed && SSE_REG_P (operands[0])"
9885 [(set (subreg:TI (match_dup 0) 0)
9886 (and:TI (not:TI (subreg:TI (match_dup 2) 0))
9887 (subreg:TI (match_dup 1) 0)))])
9888
9889 ;; Keep 'f' and 'r' in separate alternatives to avoid reload problems
9890 ;; because of secondary memory needed to reload from class FLOAT_INT_REGS
9891 ;; to itself.
9892 (define_insn "*abssf2_if"
9893 [(set (match_operand:SF 0 "nonimmediate_operand" "=f#r,rm#f")
9894 (abs:SF (match_operand:SF 1 "nonimmediate_operand" "0,0")))
9895 (clobber (reg:CC 17))]
9896 "TARGET_80387 && ix86_unary_operator_ok (ABS, SFmode, operands) && !TARGET_SSE"
9897 "#")
9898
9899 (define_split
9900 [(set (match_operand:SF 0 "register_operand" "")
9901 (abs:SF (match_operand:SF 1 "register_operand" "")))
9902 (clobber (reg:CC 17))]
9903 "TARGET_80387 && FP_REGNO_P (REGNO (operands[0]))"
9904 [(set (match_dup 0)
9905 (abs:SF (match_dup 1)))]
9906 "")
9907
9908 (define_split
9909 [(set (match_operand:SF 0 "register_operand" "")
9910 (abs:SF (match_operand:SF 1 "register_operand" "")))
9911 (clobber (reg:CC 17))]
9912 "TARGET_80387 && reload_completed && !FP_REGNO_P (REGNO (operands[0]))"
9913 [(parallel [(set (match_dup 0) (and:SI (match_dup 0) (match_dup 1)))
9914 (clobber (reg:CC 17))])]
9915 "operands[1] = GEN_INT (trunc_int_for_mode (~0x80000000, SImode));
9916 operands[0] = gen_rtx_REG (SImode, REGNO (operands[0]));")
9917
9918 (define_split
9919 [(set (match_operand 0 "memory_operand" "")
9920 (abs (match_operand 1 "memory_operand" "")))
9921 (clobber (reg:CC 17))]
9922 "TARGET_80387 && reload_completed && FLOAT_MODE_P (GET_MODE (operands[0]))"
9923 [(parallel [(set (match_dup 0) (and:QI (match_dup 0) (match_dup 1)))
9924 (clobber (reg:CC 17))])]
9925 {
9926 int size = GET_MODE_SIZE (GET_MODE (operands[1]));
9927
9928 /* XFmode's size is 12, TFmode 16, but only 10 bytes are used. */
9929 if (size >= 12)
9930 size = 10;
9931 operands[0] = adjust_address (operands[0], QImode, size - 1);
9932 operands[1] = GEN_INT (trunc_int_for_mode (~0x80, QImode));
9933 })
9934
9935 (define_expand "absdf2"
9936 [(parallel [(set (match_operand:DF 0 "nonimmediate_operand" "")
9937 (neg:DF (match_operand:DF 1 "nonimmediate_operand" "")))
9938 (clobber (reg:CC 17))])]
9939 "TARGET_80387"
9940 "if (TARGET_SSE2)
9941 {
9942 /* In case operand is in memory, we will not use SSE. */
9943 if (memory_operand (operands[0], VOIDmode)
9944 && rtx_equal_p (operands[0], operands[1]))
9945 emit_insn (gen_absdf2_memory (operands[0], operands[1]));
9946 else
9947 {
9948 /* Using SSE is tricky, since we need bitwise negation of -0
9949 in register. */
9950 rtx reg = gen_reg_rtx (DFmode);
9951 #if HOST_BITS_PER_WIDE_INT >= 64
9952 rtx imm = GEN_INT (trunc_int_for_mode(((HOST_WIDE_INT)1) << 63,
9953 DImode));
9954 #else
9955 rtx imm = immed_double_const (0, 0x80000000, DImode);
9956 #endif
9957 rtx dest = operands[0];
9958
9959 operands[1] = force_reg (DFmode, operands[1]);
9960 operands[0] = force_reg (DFmode, operands[0]);
9961 emit_move_insn (reg, gen_lowpart (DFmode, imm));
9962 emit_insn (gen_absdf2_ifs (operands[0], operands[1], reg));
9963 if (dest != operands[0])
9964 emit_move_insn (dest, operands[0]);
9965 }
9966 DONE;
9967 }
9968 ix86_expand_unary_operator (ABS, DFmode, operands); DONE;")
9969
9970 (define_insn "absdf2_memory"
9971 [(set (match_operand:DF 0 "memory_operand" "=m")
9972 (abs:DF (match_operand:DF 1 "memory_operand" "0")))
9973 (clobber (reg:CC 17))]
9974 "ix86_unary_operator_ok (ABS, DFmode, operands)"
9975 "#")
9976
9977 (define_insn "absdf2_ifs"
9978 [(set (match_operand:DF 0 "nonimmediate_operand" "=Y#fr,mf#Yr,mr#Yf")
9979 (abs:DF (match_operand:DF 1 "nonimmediate_operand" "Y,0,0")))
9980 (use (match_operand:DF 2 "nonmemory_operand" "*0#Y,*g#Y,*g#Y"))
9981 (clobber (reg:CC 17))]
9982 "!TARGET_64BIT && TARGET_SSE2
9983 && (reload_in_progress || reload_completed
9984 || (register_operand (operands[0], VOIDmode)
9985 && register_operand (operands[1], VOIDmode)))"
9986 "#")
9987
9988 (define_insn "*absdf2_ifs_rex64"
9989 [(set (match_operand:DF 0 "nonimmediate_operand" "=Y#fr,mf#Yr")
9990 (abs:DF (match_operand:DF 1 "nonimmediate_operand" "Y,0")))
9991 (use (match_operand:DF 2 "nonmemory_operand" "*0#Y,*g#Y"))
9992 (clobber (reg:CC 17))]
9993 "TARGET_64BIT && TARGET_SSE2
9994 && (reload_in_progress || reload_completed
9995 || (register_operand (operands[0], VOIDmode)
9996 && register_operand (operands[1], VOIDmode)))"
9997 "#")
9998
9999 (define_split
10000 [(set (match_operand:DF 0 "memory_operand" "")
10001 (abs:DF (match_operand:DF 1 "memory_operand" "")))
10002 (use (match_operand:DF 2 "" ""))
10003 (clobber (reg:CC 17))]
10004 ""
10005 [(parallel [(set (match_dup 0)
10006 (abs:DF (match_dup 1)))
10007 (clobber (reg:CC 17))])])
10008
10009 (define_split
10010 [(set (match_operand:DF 0 "register_operand" "")
10011 (abs:DF (match_operand:DF 1 "register_operand" "")))
10012 (use (match_operand:DF 2 "" ""))
10013 (clobber (reg:CC 17))]
10014 "reload_completed && !SSE_REG_P (operands[0])"
10015 [(parallel [(set (match_dup 0)
10016 (abs:DF (match_dup 1)))
10017 (clobber (reg:CC 17))])])
10018
10019 (define_split
10020 [(set (match_operand:DF 0 "register_operand" "")
10021 (abs:DF (match_operand:DF 1 "register_operand" "")))
10022 (use (match_operand:DF 2 "register_operand" ""))
10023 (clobber (reg:CC 17))]
10024 "reload_completed && SSE_REG_P (operands[0])"
10025 [(set (subreg:TI (match_dup 0) 0)
10026 (and:TI (not:TI (subreg:TI (match_dup 2) 0))
10027 (subreg:TI (match_dup 1) 0)))])
10028
10029
10030 ;; Keep 'f' and 'r' in separate alternatives to avoid reload problems
10031 ;; because of secondary memory needed to reload from class FLOAT_INT_REGS
10032 ;; to itself.
10033 (define_insn "*absdf2_if"
10034 [(set (match_operand:DF 0 "nonimmediate_operand" "=f#r,rm#f")
10035 (abs:DF (match_operand:DF 1 "nonimmediate_operand" "0,0")))
10036 (clobber (reg:CC 17))]
10037 "!TARGET_64BIT && TARGET_80387
10038 && ix86_unary_operator_ok (ABS, DFmode, operands)"
10039 "#")
10040
10041 ;; FIXME: We should to allow integer registers here. Problem is that
10042 ;; we need another scratch register to get constant from.
10043 ;; Forcing constant to mem if no register available in peep2 should be
10044 ;; safe even for PIC mode, because of RIP relative addressing.
10045 (define_insn "*absdf2_if_rex64"
10046 [(set (match_operand:DF 0 "nonimmediate_operand" "=f,mf")
10047 (abs:DF (match_operand:DF 1 "nonimmediate_operand" "0,0")))
10048 (clobber (reg:CC 17))]
10049 "TARGET_64BIT && TARGET_80387
10050 && ix86_unary_operator_ok (ABS, DFmode, operands)"
10051 "#")
10052
10053 (define_split
10054 [(set (match_operand:DF 0 "register_operand" "")
10055 (abs:DF (match_operand:DF 1 "register_operand" "")))
10056 (clobber (reg:CC 17))]
10057 "TARGET_80387 && FP_REGNO_P (REGNO (operands[0])) && reload_completed"
10058 [(set (match_dup 0)
10059 (abs:DF (match_dup 1)))]
10060 "")
10061
10062 (define_split
10063 [(set (match_operand:DF 0 "register_operand" "")
10064 (abs:DF (match_operand:DF 1 "register_operand" "")))
10065 (clobber (reg:CC 17))]
10066 "!TARGET_64BIT && TARGET_80387 && reload_completed &&
10067 !FP_REGNO_P (REGNO (operands[0]))"
10068 [(parallel [(set (match_dup 3) (and:SI (match_dup 3) (match_dup 4)))
10069 (clobber (reg:CC 17))])]
10070 "operands[4] = GEN_INT (trunc_int_for_mode (~0x80000000, SImode));
10071 split_di (operands+0, 1, operands+2, operands+3);")
10072
10073 (define_expand "absxf2"
10074 [(parallel [(set (match_operand:XF 0 "nonimmediate_operand" "")
10075 (neg:XF (match_operand:XF 1 "nonimmediate_operand" "")))
10076 (clobber (reg:CC 17))])]
10077 "!TARGET_64BIT && TARGET_80387"
10078 "ix86_expand_unary_operator (ABS, XFmode, operands); DONE;")
10079
10080 (define_expand "abstf2"
10081 [(parallel [(set (match_operand:TF 0 "nonimmediate_operand" "")
10082 (neg:TF (match_operand:TF 1 "nonimmediate_operand" "")))
10083 (clobber (reg:CC 17))])]
10084 "TARGET_80387"
10085 "ix86_expand_unary_operator (ABS, TFmode, operands); DONE;")
10086
10087 ;; Keep 'f' and 'r' in separate alternatives to avoid reload problems
10088 ;; because of secondary memory needed to reload from class FLOAT_INT_REGS
10089 ;; to itself.
10090 (define_insn "*absxf2_if"
10091 [(set (match_operand:XF 0 "nonimmediate_operand" "=f#r,rm#f")
10092 (abs:XF (match_operand:XF 1 "nonimmediate_operand" "0,0")))
10093 (clobber (reg:CC 17))]
10094 "!TARGET_64BIT && TARGET_80387
10095 && ix86_unary_operator_ok (ABS, XFmode, operands)"
10096 "#")
10097
10098 (define_split
10099 [(set (match_operand:XF 0 "register_operand" "")
10100 (abs:XF (match_operand:XF 1 "register_operand" "")))
10101 (clobber (reg:CC 17))]
10102 "TARGET_80387 && FP_REGNO_P (REGNO (operands[0])) && reload_completed"
10103 [(set (match_dup 0)
10104 (abs:XF (match_dup 1)))]
10105 "")
10106
10107 (define_split
10108 [(set (match_operand:XF 0 "register_operand" "")
10109 (abs:XF (match_operand:XF 1 "register_operand" "")))
10110 (clobber (reg:CC 17))]
10111 "TARGET_80387 && reload_completed && !FP_REGNO_P (REGNO (operands[0]))"
10112 [(parallel [(set (match_dup 0) (and:SI (match_dup 0) (match_dup 1)))
10113 (clobber (reg:CC 17))])]
10114 "operands[1] = GEN_INT (~0x8000);
10115 operands[0] = gen_rtx_REG (SImode,
10116 true_regnum (operands[0]) + (TARGET_64BIT ? 1 : 2));")
10117
10118 (define_insn "*abstf2_if"
10119 [(set (match_operand:TF 0 "nonimmediate_operand" "=f#r,rm#f")
10120 (abs:TF (match_operand:TF 1 "nonimmediate_operand" "0,0")))
10121 (clobber (reg:CC 17))]
10122 "TARGET_80387 && ix86_unary_operator_ok (ABS, TFmode, operands)"
10123 "#")
10124
10125 (define_split
10126 [(set (match_operand:TF 0 "register_operand" "")
10127 (abs:TF (match_operand:TF 1 "register_operand" "")))
10128 (clobber (reg:CC 17))]
10129 "TARGET_80387 && FP_REGNO_P (REGNO (operands[0])) && reload_completed"
10130 [(set (match_dup 0)
10131 (abs:TF (match_dup 1)))]
10132 "")
10133
10134 (define_split
10135 [(set (match_operand:TF 0 "register_operand" "")
10136 (abs:TF (match_operand:TF 1 "register_operand" "")))
10137 (clobber (reg:CC 17))]
10138 "TARGET_80387 && reload_completed && !FP_REGNO_P (REGNO (operands[0]))"
10139 [(parallel [(set (match_dup 0) (and:SI (match_dup 0) (match_dup 1)))
10140 (clobber (reg:CC 17))])]
10141 "operands[1] = GEN_INT (~0x8000);
10142 operands[0] = gen_rtx_REG (SImode,
10143 true_regnum (operands[0]) + (TARGET_64BIT ? 1 : 2));")
10144
10145 (define_insn "*abssf2_1"
10146 [(set (match_operand:SF 0 "register_operand" "=f")
10147 (abs:SF (match_operand:SF 1 "register_operand" "0")))]
10148 "TARGET_80387 && reload_completed"
10149 "fabs"
10150 [(set_attr "type" "fsgn")
10151 (set_attr "mode" "SF")])
10152
10153 (define_insn "*absdf2_1"
10154 [(set (match_operand:DF 0 "register_operand" "=f")
10155 (abs:DF (match_operand:DF 1 "register_operand" "0")))]
10156 "TARGET_80387 && reload_completed"
10157 "fabs"
10158 [(set_attr "type" "fsgn")
10159 (set_attr "mode" "DF")])
10160
10161 (define_insn "*absextendsfdf2"
10162 [(set (match_operand:DF 0 "register_operand" "=f")
10163 (abs:DF (float_extend:DF
10164 (match_operand:SF 1 "register_operand" "0"))))]
10165 "TARGET_80387"
10166 "fabs"
10167 [(set_attr "type" "fsgn")
10168 (set_attr "mode" "DF")])
10169
10170 (define_insn "*absxf2_1"
10171 [(set (match_operand:XF 0 "register_operand" "=f")
10172 (abs:XF (match_operand:XF 1 "register_operand" "0")))]
10173 "!TARGET_64BIT && TARGET_80387 && reload_completed"
10174 "fabs"
10175 [(set_attr "type" "fsgn")
10176 (set_attr "mode" "DF")])
10177
10178 (define_insn "*absextenddfxf2"
10179 [(set (match_operand:XF 0 "register_operand" "=f")
10180 (abs:XF (float_extend:XF
10181 (match_operand:DF 1 "register_operand" "0"))))]
10182 "!TARGET_64BIT && TARGET_80387"
10183 "fabs"
10184 [(set_attr "type" "fsgn")
10185 (set_attr "mode" "XF")])
10186
10187 (define_insn "*absextendsfxf2"
10188 [(set (match_operand:XF 0 "register_operand" "=f")
10189 (abs:XF (float_extend:XF
10190 (match_operand:SF 1 "register_operand" "0"))))]
10191 "!TARGET_64BIT && TARGET_80387"
10192 "fabs"
10193 [(set_attr "type" "fsgn")
10194 (set_attr "mode" "XF")])
10195
10196 (define_insn "*abstf2_1"
10197 [(set (match_operand:TF 0 "register_operand" "=f")
10198 (abs:TF (match_operand:TF 1 "register_operand" "0")))]
10199 "TARGET_80387 && reload_completed"
10200 "fabs"
10201 [(set_attr "type" "fsgn")
10202 (set_attr "mode" "DF")])
10203
10204 (define_insn "*absextenddftf2"
10205 [(set (match_operand:TF 0 "register_operand" "=f")
10206 (abs:TF (float_extend:TF
10207 (match_operand:DF 1 "register_operand" "0"))))]
10208 "TARGET_80387"
10209 "fabs"
10210 [(set_attr "type" "fsgn")
10211 (set_attr "mode" "XF")])
10212
10213 (define_insn "*absextendsftf2"
10214 [(set (match_operand:TF 0 "register_operand" "=f")
10215 (abs:TF (float_extend:TF
10216 (match_operand:SF 1 "register_operand" "0"))))]
10217 "TARGET_80387"
10218 "fabs"
10219 [(set_attr "type" "fsgn")
10220 (set_attr "mode" "XF")])
10221 \f
10222 ;; One complement instructions
10223
10224 (define_expand "one_cmpldi2"
10225 [(set (match_operand:DI 0 "nonimmediate_operand" "")
10226 (not:DI (match_operand:DI 1 "nonimmediate_operand" "")))]
10227 "TARGET_64BIT"
10228 "ix86_expand_unary_operator (NOT, DImode, operands); DONE;")
10229
10230 (define_insn "*one_cmpldi2_1_rex64"
10231 [(set (match_operand:DI 0 "nonimmediate_operand" "=rm")
10232 (not:DI (match_operand:DI 1 "nonimmediate_operand" "0")))]
10233 "TARGET_64BIT && ix86_unary_operator_ok (NOT, DImode, operands)"
10234 "not{q}\t%0"
10235 [(set_attr "type" "negnot")
10236 (set_attr "mode" "DI")])
10237
10238 (define_insn "*one_cmpldi2_2_rex64"
10239 [(set (reg 17)
10240 (compare (not:DI (match_operand:DI 1 "nonimmediate_operand" "0"))
10241 (const_int 0)))
10242 (set (match_operand:DI 0 "nonimmediate_operand" "=rm")
10243 (not:DI (match_dup 1)))]
10244 "TARGET_64BIT && ix86_match_ccmode (insn, CCNOmode)
10245 && ix86_unary_operator_ok (NOT, DImode, operands)"
10246 "#"
10247 [(set_attr "type" "alu1")
10248 (set_attr "mode" "DI")])
10249
10250 (define_split
10251 [(set (reg 17)
10252 (compare (not:DI (match_operand:DI 1 "nonimmediate_operand" ""))
10253 (const_int 0)))
10254 (set (match_operand:DI 0 "nonimmediate_operand" "")
10255 (not:DI (match_dup 1)))]
10256 "TARGET_64BIT && ix86_match_ccmode (insn, CCNOmode)"
10257 [(parallel [(set (reg:CCNO 17)
10258 (compare:CCNO (xor:DI (match_dup 1) (const_int -1))
10259 (const_int 0)))
10260 (set (match_dup 0)
10261 (xor:DI (match_dup 1) (const_int -1)))])]
10262 "")
10263
10264 (define_expand "one_cmplsi2"
10265 [(set (match_operand:SI 0 "nonimmediate_operand" "")
10266 (not:SI (match_operand:SI 1 "nonimmediate_operand" "")))]
10267 ""
10268 "ix86_expand_unary_operator (NOT, SImode, operands); DONE;")
10269
10270 (define_insn "*one_cmplsi2_1"
10271 [(set (match_operand:SI 0 "nonimmediate_operand" "=rm")
10272 (not:SI (match_operand:SI 1 "nonimmediate_operand" "0")))]
10273 "ix86_unary_operator_ok (NOT, SImode, operands)"
10274 "not{l}\t%0"
10275 [(set_attr "type" "negnot")
10276 (set_attr "mode" "SI")])
10277
10278 ;; ??? Currently never generated - xor is used instead.
10279 (define_insn "*one_cmplsi2_1_zext"
10280 [(set (match_operand:DI 0 "register_operand" "=r")
10281 (zero_extend:DI (not:SI (match_operand:SI 1 "register_operand" "0"))))]
10282 "TARGET_64BIT && ix86_unary_operator_ok (NOT, SImode, operands)"
10283 "not{l}\t%k0"
10284 [(set_attr "type" "negnot")
10285 (set_attr "mode" "SI")])
10286
10287 (define_insn "*one_cmplsi2_2"
10288 [(set (reg 17)
10289 (compare (not:SI (match_operand:SI 1 "nonimmediate_operand" "0"))
10290 (const_int 0)))
10291 (set (match_operand:SI 0 "nonimmediate_operand" "=rm")
10292 (not:SI (match_dup 1)))]
10293 "ix86_match_ccmode (insn, CCNOmode)
10294 && ix86_unary_operator_ok (NOT, SImode, operands)"
10295 "#"
10296 [(set_attr "type" "alu1")
10297 (set_attr "mode" "SI")])
10298
10299 (define_split
10300 [(set (reg 17)
10301 (compare (not:SI (match_operand:SI 1 "nonimmediate_operand" ""))
10302 (const_int 0)))
10303 (set (match_operand:SI 0 "nonimmediate_operand" "")
10304 (not:SI (match_dup 1)))]
10305 "ix86_match_ccmode (insn, CCNOmode)"
10306 [(parallel [(set (reg:CCNO 17)
10307 (compare:CCNO (xor:SI (match_dup 1) (const_int -1))
10308 (const_int 0)))
10309 (set (match_dup 0)
10310 (xor:SI (match_dup 1) (const_int -1)))])]
10311 "")
10312
10313 ;; ??? Currently never generated - xor is used instead.
10314 (define_insn "*one_cmplsi2_2_zext"
10315 [(set (reg 17)
10316 (compare (not:SI (match_operand:SI 1 "register_operand" "0"))
10317 (const_int 0)))
10318 (set (match_operand:DI 0 "register_operand" "=r")
10319 (zero_extend:DI (not:SI (match_dup 1))))]
10320 "TARGET_64BIT && ix86_match_ccmode (insn, CCNOmode)
10321 && ix86_unary_operator_ok (NOT, SImode, operands)"
10322 "#"
10323 [(set_attr "type" "alu1")
10324 (set_attr "mode" "SI")])
10325
10326 (define_split
10327 [(set (reg 17)
10328 (compare (not:SI (match_operand:SI 1 "register_operand" ""))
10329 (const_int 0)))
10330 (set (match_operand:DI 0 "register_operand" "")
10331 (zero_extend:DI (not:SI (match_dup 1))))]
10332 "ix86_match_ccmode (insn, CCNOmode)"
10333 [(parallel [(set (reg:CCNO 17)
10334 (compare:CCNO (xor:SI (match_dup 1) (const_int -1))
10335 (const_int 0)))
10336 (set (match_dup 0)
10337 (zero_extend:DI (xor:SI (match_dup 1) (const_int -1))))])]
10338 "")
10339
10340 (define_expand "one_cmplhi2"
10341 [(set (match_operand:HI 0 "nonimmediate_operand" "")
10342 (not:HI (match_operand:HI 1 "nonimmediate_operand" "")))]
10343 "TARGET_HIMODE_MATH"
10344 "ix86_expand_unary_operator (NOT, HImode, operands); DONE;")
10345
10346 (define_insn "*one_cmplhi2_1"
10347 [(set (match_operand:HI 0 "nonimmediate_operand" "=rm")
10348 (not:HI (match_operand:HI 1 "nonimmediate_operand" "0")))]
10349 "ix86_unary_operator_ok (NOT, HImode, operands)"
10350 "not{w}\t%0"
10351 [(set_attr "type" "negnot")
10352 (set_attr "mode" "HI")])
10353
10354 (define_insn "*one_cmplhi2_2"
10355 [(set (reg 17)
10356 (compare (not:HI (match_operand:HI 1 "nonimmediate_operand" "0"))
10357 (const_int 0)))
10358 (set (match_operand:HI 0 "nonimmediate_operand" "=rm")
10359 (not:HI (match_dup 1)))]
10360 "ix86_match_ccmode (insn, CCNOmode)
10361 && ix86_unary_operator_ok (NEG, HImode, operands)"
10362 "#"
10363 [(set_attr "type" "alu1")
10364 (set_attr "mode" "HI")])
10365
10366 (define_split
10367 [(set (reg 17)
10368 (compare (not:HI (match_operand:HI 1 "nonimmediate_operand" ""))
10369 (const_int 0)))
10370 (set (match_operand:HI 0 "nonimmediate_operand" "")
10371 (not:HI (match_dup 1)))]
10372 "ix86_match_ccmode (insn, CCNOmode)"
10373 [(parallel [(set (reg:CCNO 17)
10374 (compare:CCNO (xor:HI (match_dup 1) (const_int -1))
10375 (const_int 0)))
10376 (set (match_dup 0)
10377 (xor:HI (match_dup 1) (const_int -1)))])]
10378 "")
10379
10380 ;; %%% Potential partial reg stall on alternative 1. What to do?
10381 (define_expand "one_cmplqi2"
10382 [(set (match_operand:QI 0 "nonimmediate_operand" "")
10383 (not:QI (match_operand:QI 1 "nonimmediate_operand" "")))]
10384 "TARGET_QIMODE_MATH"
10385 "ix86_expand_unary_operator (NOT, QImode, operands); DONE;")
10386
10387 (define_insn "*one_cmplqi2_1"
10388 [(set (match_operand:QI 0 "nonimmediate_operand" "=qm,r")
10389 (not:QI (match_operand:QI 1 "nonimmediate_operand" "0,0")))]
10390 "ix86_unary_operator_ok (NOT, QImode, operands)"
10391 "@
10392 not{b}\t%0
10393 not{l}\t%k0"
10394 [(set_attr "type" "negnot")
10395 (set_attr "mode" "QI,SI")])
10396
10397 (define_insn "*one_cmplqi2_2"
10398 [(set (reg 17)
10399 (compare (not:QI (match_operand:QI 1 "nonimmediate_operand" "0"))
10400 (const_int 0)))
10401 (set (match_operand:QI 0 "nonimmediate_operand" "=qm")
10402 (not:QI (match_dup 1)))]
10403 "ix86_match_ccmode (insn, CCNOmode)
10404 && ix86_unary_operator_ok (NOT, QImode, operands)"
10405 "#"
10406 [(set_attr "type" "alu1")
10407 (set_attr "mode" "QI")])
10408
10409 (define_split
10410 [(set (reg 17)
10411 (compare (not:QI (match_operand:QI 1 "nonimmediate_operand" ""))
10412 (const_int 0)))
10413 (set (match_operand:QI 0 "nonimmediate_operand" "")
10414 (not:QI (match_dup 1)))]
10415 "ix86_match_ccmode (insn, CCNOmode)"
10416 [(parallel [(set (reg:CCNO 17)
10417 (compare:CCNO (xor:QI (match_dup 1) (const_int -1))
10418 (const_int 0)))
10419 (set (match_dup 0)
10420 (xor:QI (match_dup 1) (const_int -1)))])]
10421 "")
10422 \f
10423 ;; Arithmetic shift instructions
10424
10425 ;; DImode shifts are implemented using the i386 "shift double" opcode,
10426 ;; which is written as "sh[lr]d[lw] imm,reg,reg/mem". If the shift count
10427 ;; is variable, then the count is in %cl and the "imm" operand is dropped
10428 ;; from the assembler input.
10429 ;;
10430 ;; This instruction shifts the target reg/mem as usual, but instead of
10431 ;; shifting in zeros, bits are shifted in from reg operand. If the insn
10432 ;; is a left shift double, bits are taken from the high order bits of
10433 ;; reg, else if the insn is a shift right double, bits are taken from the
10434 ;; low order bits of reg. So if %eax is "1234" and %edx is "5678",
10435 ;; "shldl $8,%edx,%eax" leaves %edx unchanged and sets %eax to "2345".
10436 ;;
10437 ;; Since sh[lr]d does not change the `reg' operand, that is done
10438 ;; separately, making all shifts emit pairs of shift double and normal
10439 ;; shift. Since sh[lr]d does not shift more than 31 bits, and we wish to
10440 ;; support a 63 bit shift, each shift where the count is in a reg expands
10441 ;; to a pair of shifts, a branch, a shift by 32 and a label.
10442 ;;
10443 ;; If the shift count is a constant, we need never emit more than one
10444 ;; shift pair, instead using moves and sign extension for counts greater
10445 ;; than 31.
10446
10447 (define_expand "ashldi3"
10448 [(parallel [(set (match_operand:DI 0 "shiftdi_operand" "")
10449 (ashift:DI (match_operand:DI 1 "shiftdi_operand" "")
10450 (match_operand:QI 2 "nonmemory_operand" "")))
10451 (clobber (reg:CC 17))])]
10452 ""
10453 {
10454 if (!TARGET_64BIT && TARGET_CMOVE && ! immediate_operand (operands[2], QImode))
10455 {
10456 emit_insn (gen_ashldi3_1 (operands[0], operands[1], operands[2]));
10457 DONE;
10458 }
10459 ix86_expand_binary_operator (ASHIFT, DImode, operands);
10460 DONE;
10461 })
10462
10463 (define_insn "*ashldi3_1_rex64"
10464 [(set (match_operand:DI 0 "nonimmediate_operand" "=rm,r")
10465 (ashift:DI (match_operand:DI 1 "nonimmediate_operand" "0,r")
10466 (match_operand:QI 2 "nonmemory_operand" "cJ,M")))
10467 (clobber (reg:CC 17))]
10468 "TARGET_64BIT && ix86_binary_operator_ok (ASHIFT, DImode, operands)"
10469 {
10470 switch (get_attr_type (insn))
10471 {
10472 case TYPE_ALU:
10473 if (operands[2] != const1_rtx)
10474 abort ();
10475 if (!rtx_equal_p (operands[0], operands[1]))
10476 abort ();
10477 return "add{q}\t{%0, %0|%0, %0}";
10478
10479 case TYPE_LEA:
10480 if (GET_CODE (operands[2]) != CONST_INT
10481 || (unsigned HOST_WIDE_INT) INTVAL (operands[2]) > 3)
10482 abort ();
10483 operands[1] = gen_rtx_MULT (DImode, operands[1],
10484 GEN_INT (1 << INTVAL (operands[2])));
10485 return "lea{q}\t{%a1, %0|%0, %a1}";
10486
10487 default:
10488 if (REG_P (operands[2]))
10489 return "sal{q}\t{%b2, %0|%0, %b2}";
10490 else if (GET_CODE (operands[2]) == CONST_INT
10491 && INTVAL (operands[2]) == 1
10492 && (TARGET_PENTIUM || TARGET_PENTIUMPRO))
10493 return "sal{q}\t%0";
10494 else
10495 return "sal{q}\t{%2, %0|%0, %2}";
10496 }
10497 }
10498 [(set (attr "type")
10499 (cond [(eq_attr "alternative" "1")
10500 (const_string "lea")
10501 (and (and (ne (symbol_ref "TARGET_DOUBLE_WITH_ADD")
10502 (const_int 0))
10503 (match_operand 0 "register_operand" ""))
10504 (match_operand 2 "const1_operand" ""))
10505 (const_string "alu")
10506 ]
10507 (const_string "ishift")))
10508 (set_attr "mode" "DI")])
10509
10510 ;; Convert lea to the lea pattern to avoid flags dependency.
10511 (define_split
10512 [(set (match_operand:DI 0 "register_operand" "")
10513 (ashift:DI (match_operand:DI 1 "register_operand" "")
10514 (match_operand:QI 2 "immediate_operand" "")))
10515 (clobber (reg:CC 17))]
10516 "TARGET_64BIT && reload_completed
10517 && true_regnum (operands[0]) != true_regnum (operands[1])"
10518 [(set (match_dup 0)
10519 (mult:DI (match_dup 1)
10520 (match_dup 2)))]
10521 "operands[2] = GEN_INT (trunc_int_for_mode (1 << INTVAL (operands[2]),
10522 DImode));")
10523
10524 ;; This pattern can't accept a variable shift count, since shifts by
10525 ;; zero don't affect the flags. We assume that shifts by constant
10526 ;; zero are optimized away.
10527 (define_insn "*ashldi3_cmp_rex64"
10528 [(set (reg 17)
10529 (compare
10530 (ashift:DI (match_operand:DI 1 "nonimmediate_operand" "0")
10531 (match_operand:QI 2 "immediate_operand" "e"))
10532 (const_int 0)))
10533 (set (match_operand:DI 0 "nonimmediate_operand" "=rm")
10534 (ashift:DI (match_dup 1) (match_dup 2)))]
10535 "TARGET_64BIT && ix86_match_ccmode (insn, CCGOCmode)
10536 && ix86_binary_operator_ok (ASHIFT, DImode, operands)"
10537 {
10538 switch (get_attr_type (insn))
10539 {
10540 case TYPE_ALU:
10541 if (operands[2] != const1_rtx)
10542 abort ();
10543 return "add{q}\t{%0, %0|%0, %0}";
10544
10545 default:
10546 if (REG_P (operands[2]))
10547 return "sal{q}\t{%b2, %0|%0, %b2}";
10548 else if (GET_CODE (operands[2]) == CONST_INT
10549 && INTVAL (operands[2]) == 1
10550 && (TARGET_PENTIUM || TARGET_PENTIUMPRO))
10551 return "sal{q}\t%0";
10552 else
10553 return "sal{q}\t{%2, %0|%0, %2}";
10554 }
10555 }
10556 [(set (attr "type")
10557 (cond [(and (and (ne (symbol_ref "TARGET_DOUBLE_WITH_ADD")
10558 (const_int 0))
10559 (match_operand 0 "register_operand" ""))
10560 (match_operand 2 "const1_operand" ""))
10561 (const_string "alu")
10562 ]
10563 (const_string "ishift")))
10564 (set_attr "mode" "DI")])
10565
10566 (define_insn "ashldi3_1"
10567 [(set (match_operand:DI 0 "register_operand" "=r")
10568 (ashift:DI (match_operand:DI 1 "register_operand" "0")
10569 (match_operand:QI 2 "nonmemory_operand" "Jc")))
10570 (clobber (match_scratch:SI 3 "=&r"))
10571 (clobber (reg:CC 17))]
10572 "!TARGET_64BIT && TARGET_CMOVE"
10573 "#"
10574 [(set_attr "type" "multi")])
10575
10576 (define_insn "*ashldi3_2"
10577 [(set (match_operand:DI 0 "register_operand" "=r")
10578 (ashift:DI (match_operand:DI 1 "register_operand" "0")
10579 (match_operand:QI 2 "nonmemory_operand" "Jc")))
10580 (clobber (reg:CC 17))]
10581 "!TARGET_64BIT"
10582 "#"
10583 [(set_attr "type" "multi")])
10584
10585 (define_split
10586 [(set (match_operand:DI 0 "register_operand" "")
10587 (ashift:DI (match_operand:DI 1 "register_operand" "")
10588 (match_operand:QI 2 "nonmemory_operand" "")))
10589 (clobber (match_scratch:SI 3 ""))
10590 (clobber (reg:CC 17))]
10591 "!TARGET_64BIT && TARGET_CMOVE && reload_completed"
10592 [(const_int 0)]
10593 "ix86_split_ashldi (operands, operands[3]); DONE;")
10594
10595 (define_split
10596 [(set (match_operand:DI 0 "register_operand" "")
10597 (ashift:DI (match_operand:DI 1 "register_operand" "")
10598 (match_operand:QI 2 "nonmemory_operand" "")))
10599 (clobber (reg:CC 17))]
10600 "!TARGET_64BIT && reload_completed"
10601 [(const_int 0)]
10602 "ix86_split_ashldi (operands, NULL_RTX); DONE;")
10603
10604 (define_insn "x86_shld_1"
10605 [(set (match_operand:SI 0 "nonimmediate_operand" "+r*m,r*m")
10606 (ior:SI (ashift:SI (match_dup 0)
10607 (match_operand:QI 2 "nonmemory_operand" "I,c"))
10608 (lshiftrt:SI (match_operand:SI 1 "register_operand" "r,r")
10609 (minus:QI (const_int 32) (match_dup 2)))))
10610 (clobber (reg:CC 17))]
10611 ""
10612 "@
10613 shld{l}\t{%2, %1, %0|%0, %1, %2}
10614 shld{l}\t{%s2%1, %0|%0, %1, %2}"
10615 [(set_attr "type" "ishift")
10616 (set_attr "prefix_0f" "1")
10617 (set_attr "mode" "SI")
10618 (set_attr "pent_pair" "np")
10619 (set_attr "athlon_decode" "vector")
10620 (set_attr "ppro_uops" "few")])
10621
10622 (define_expand "x86_shift_adj_1"
10623 [(set (reg:CCZ 17)
10624 (compare:CCZ (and:QI (match_operand:QI 2 "register_operand" "")
10625 (const_int 32))
10626 (const_int 0)))
10627 (set (match_operand:SI 0 "register_operand" "")
10628 (if_then_else:SI (ne (reg:CCZ 17) (const_int 0))
10629 (match_operand:SI 1 "register_operand" "")
10630 (match_dup 0)))
10631 (set (match_dup 1)
10632 (if_then_else:SI (ne (reg:CCZ 17) (const_int 0))
10633 (match_operand:SI 3 "register_operand" "r")
10634 (match_dup 1)))]
10635 "TARGET_CMOVE"
10636 "")
10637
10638 (define_expand "x86_shift_adj_2"
10639 [(use (match_operand:SI 0 "register_operand" ""))
10640 (use (match_operand:SI 1 "register_operand" ""))
10641 (use (match_operand:QI 2 "register_operand" ""))]
10642 ""
10643 {
10644 rtx label = gen_label_rtx ();
10645 rtx tmp;
10646
10647 emit_insn (gen_testqi_ccz_1 (operands[2], GEN_INT (32)));
10648
10649 tmp = gen_rtx_REG (CCZmode, FLAGS_REG);
10650 tmp = gen_rtx_EQ (VOIDmode, tmp, const0_rtx);
10651 tmp = gen_rtx_IF_THEN_ELSE (VOIDmode, tmp,
10652 gen_rtx_LABEL_REF (VOIDmode, label),
10653 pc_rtx);
10654 tmp = emit_jump_insn (gen_rtx_SET (VOIDmode, pc_rtx, tmp));
10655 JUMP_LABEL (tmp) = label;
10656
10657 emit_move_insn (operands[0], operands[1]);
10658 emit_move_insn (operands[1], const0_rtx);
10659
10660 emit_label (label);
10661 LABEL_NUSES (label) = 1;
10662
10663 DONE;
10664 })
10665
10666 (define_expand "ashlsi3"
10667 [(set (match_operand:SI 0 "nonimmediate_operand" "")
10668 (ashift:SI (match_operand:SI 1 "nonimmediate_operand" "")
10669 (match_operand:QI 2 "nonmemory_operand" "")))
10670 (clobber (reg:CC 17))]
10671 ""
10672 "ix86_expand_binary_operator (ASHIFT, SImode, operands); DONE;")
10673
10674 (define_insn "*ashlsi3_1"
10675 [(set (match_operand:SI 0 "nonimmediate_operand" "=rm,r")
10676 (ashift:SI (match_operand:SI 1 "nonimmediate_operand" "0,r")
10677 (match_operand:QI 2 "nonmemory_operand" "cI,M")))
10678 (clobber (reg:CC 17))]
10679 "ix86_binary_operator_ok (ASHIFT, SImode, operands)"
10680 {
10681 switch (get_attr_type (insn))
10682 {
10683 case TYPE_ALU:
10684 if (operands[2] != const1_rtx)
10685 abort ();
10686 if (!rtx_equal_p (operands[0], operands[1]))
10687 abort ();
10688 return "add{l}\t{%0, %0|%0, %0}";
10689
10690 case TYPE_LEA:
10691 return "#";
10692
10693 default:
10694 if (REG_P (operands[2]))
10695 return "sal{l}\t{%b2, %0|%0, %b2}";
10696 else if (GET_CODE (operands[2]) == CONST_INT
10697 && INTVAL (operands[2]) == 1
10698 && (TARGET_PENTIUM || TARGET_PENTIUMPRO))
10699 return "sal{l}\t%0";
10700 else
10701 return "sal{l}\t{%2, %0|%0, %2}";
10702 }
10703 }
10704 [(set (attr "type")
10705 (cond [(eq_attr "alternative" "1")
10706 (const_string "lea")
10707 (and (and (ne (symbol_ref "TARGET_DOUBLE_WITH_ADD")
10708 (const_int 0))
10709 (match_operand 0 "register_operand" ""))
10710 (match_operand 2 "const1_operand" ""))
10711 (const_string "alu")
10712 ]
10713 (const_string "ishift")))
10714 (set_attr "mode" "SI")])
10715
10716 ;; Convert lea to the lea pattern to avoid flags dependency.
10717 (define_split
10718 [(set (match_operand 0 "register_operand" "")
10719 (ashift (match_operand 1 "register_operand" "")
10720 (match_operand:QI 2 "const_int_operand" "")))
10721 (clobber (reg:CC 17))]
10722 "reload_completed
10723 && true_regnum (operands[0]) != true_regnum (operands[1])"
10724 [(const_int 0)]
10725 {
10726 rtx pat;
10727 operands[0] = gen_lowpart (SImode, operands[0]);
10728 operands[1] = gen_lowpart (Pmode, operands[1]);
10729 operands[2] = GEN_INT (trunc_int_for_mode (1 << INTVAL (operands[2]),
10730 Pmode));
10731 pat = gen_rtx_MULT (Pmode, operands[1], operands[2]);
10732 if (Pmode != SImode)
10733 pat = gen_rtx_SUBREG (SImode, pat, 0);
10734 emit_insn (gen_rtx_SET (VOIDmode, operands[0], pat));
10735 DONE;
10736 })
10737
10738 (define_insn "*ashlsi3_1_zext"
10739 [(set (match_operand:DI 0 "register_operand" "=r,r")
10740 (zero_extend:DI (ashift:SI (match_operand:SI 1 "register_operand" "0,r")
10741 (match_operand:QI 2 "nonmemory_operand" "cI,M"))))
10742 (clobber (reg:CC 17))]
10743 "TARGET_64BIT && ix86_binary_operator_ok (ASHIFT, SImode, operands)"
10744 {
10745 switch (get_attr_type (insn))
10746 {
10747 case TYPE_ALU:
10748 if (operands[2] != const1_rtx)
10749 abort ();
10750 return "add{l}\t{%k0, %k0|%k0, %k0}";
10751
10752 case TYPE_LEA:
10753 return "#";
10754
10755 default:
10756 if (REG_P (operands[2]))
10757 return "sal{l}\t{%b2, %k0|%k0, %b2}";
10758 else if (GET_CODE (operands[2]) == CONST_INT
10759 && INTVAL (operands[2]) == 1
10760 && (TARGET_PENTIUM || TARGET_PENTIUMPRO))
10761 return "sal{l}\t%k0";
10762 else
10763 return "sal{l}\t{%2, %k0|%k0, %2}";
10764 }
10765 }
10766 [(set (attr "type")
10767 (cond [(eq_attr "alternative" "1")
10768 (const_string "lea")
10769 (and (ne (symbol_ref "TARGET_DOUBLE_WITH_ADD")
10770 (const_int 0))
10771 (match_operand 2 "const1_operand" ""))
10772 (const_string "alu")
10773 ]
10774 (const_string "ishift")))
10775 (set_attr "mode" "SI")])
10776
10777 ;; Convert lea to the lea pattern to avoid flags dependency.
10778 (define_split
10779 [(set (match_operand:DI 0 "register_operand" "")
10780 (zero_extend:DI (ashift (match_operand 1 "register_operand" "")
10781 (match_operand:QI 2 "const_int_operand" ""))))
10782 (clobber (reg:CC 17))]
10783 "reload_completed
10784 && true_regnum (operands[0]) != true_regnum (operands[1])"
10785 [(set (match_dup 0) (zero_extend:DI (subreg:SI (mult:SI (match_dup 1) (match_dup 2)) 0)))]
10786 {
10787 operands[1] = gen_lowpart (Pmode, operands[1]);
10788 operands[2] = GEN_INT (trunc_int_for_mode (1 << INTVAL (operands[2]),
10789 Pmode));
10790 })
10791
10792 ;; This pattern can't accept a variable shift count, since shifts by
10793 ;; zero don't affect the flags. We assume that shifts by constant
10794 ;; zero are optimized away.
10795 (define_insn "*ashlsi3_cmp"
10796 [(set (reg 17)
10797 (compare
10798 (ashift:SI (match_operand:SI 1 "nonimmediate_operand" "0")
10799 (match_operand:QI 2 "immediate_operand" "I"))
10800 (const_int 0)))
10801 (set (match_operand:SI 0 "nonimmediate_operand" "=rm")
10802 (ashift:SI (match_dup 1) (match_dup 2)))]
10803 "ix86_match_ccmode (insn, CCGOCmode)
10804 && ix86_binary_operator_ok (ASHIFT, SImode, operands)"
10805 {
10806 switch (get_attr_type (insn))
10807 {
10808 case TYPE_ALU:
10809 if (operands[2] != const1_rtx)
10810 abort ();
10811 return "add{l}\t{%0, %0|%0, %0}";
10812
10813 default:
10814 if (REG_P (operands[2]))
10815 return "sal{l}\t{%b2, %0|%0, %b2}";
10816 else if (GET_CODE (operands[2]) == CONST_INT
10817 && INTVAL (operands[2]) == 1
10818 && (TARGET_PENTIUM || TARGET_PENTIUMPRO))
10819 return "sal{l}\t%0";
10820 else
10821 return "sal{l}\t{%2, %0|%0, %2}";
10822 }
10823 }
10824 [(set (attr "type")
10825 (cond [(and (and (ne (symbol_ref "TARGET_DOUBLE_WITH_ADD")
10826 (const_int 0))
10827 (match_operand 0 "register_operand" ""))
10828 (match_operand 2 "const1_operand" ""))
10829 (const_string "alu")
10830 ]
10831 (const_string "ishift")))
10832 (set_attr "mode" "SI")])
10833
10834 (define_insn "*ashlsi3_cmp_zext"
10835 [(set (reg 17)
10836 (compare
10837 (ashift:SI (match_operand:SI 1 "register_operand" "0")
10838 (match_operand:QI 2 "immediate_operand" "I"))
10839 (const_int 0)))
10840 (set (match_operand:DI 0 "register_operand" "=r")
10841 (zero_extend:DI (ashift:SI (match_dup 1) (match_dup 2))))]
10842 "TARGET_64BIT && ix86_match_ccmode (insn, CCGOCmode)
10843 && ix86_binary_operator_ok (ASHIFT, SImode, operands)"
10844 {
10845 switch (get_attr_type (insn))
10846 {
10847 case TYPE_ALU:
10848 if (operands[2] != const1_rtx)
10849 abort ();
10850 return "add{l}\t{%k0, %k0|%k0, %k0}";
10851
10852 default:
10853 if (REG_P (operands[2]))
10854 return "sal{l}\t{%b2, %k0|%k0, %b2}";
10855 else if (GET_CODE (operands[2]) == CONST_INT
10856 && INTVAL (operands[2]) == 1
10857 && (TARGET_PENTIUM || TARGET_PENTIUMPRO))
10858 return "sal{l}\t%k0";
10859 else
10860 return "sal{l}\t{%2, %k0|%k0, %2}";
10861 }
10862 }
10863 [(set (attr "type")
10864 (cond [(and (ne (symbol_ref "TARGET_DOUBLE_WITH_ADD")
10865 (const_int 0))
10866 (match_operand 2 "const1_operand" ""))
10867 (const_string "alu")
10868 ]
10869 (const_string "ishift")))
10870 (set_attr "mode" "SI")])
10871
10872 (define_expand "ashlhi3"
10873 [(set (match_operand:HI 0 "nonimmediate_operand" "")
10874 (ashift:HI (match_operand:HI 1 "nonimmediate_operand" "")
10875 (match_operand:QI 2 "nonmemory_operand" "")))
10876 (clobber (reg:CC 17))]
10877 "TARGET_HIMODE_MATH"
10878 "ix86_expand_binary_operator (ASHIFT, HImode, operands); DONE;")
10879
10880 (define_insn "*ashlhi3_1_lea"
10881 [(set (match_operand:HI 0 "nonimmediate_operand" "=rm,r")
10882 (ashift:HI (match_operand:HI 1 "nonimmediate_operand" "0,r")
10883 (match_operand:QI 2 "nonmemory_operand" "cI,M")))
10884 (clobber (reg:CC 17))]
10885 "!TARGET_PARTIAL_REG_STALL
10886 && ix86_binary_operator_ok (ASHIFT, HImode, operands)"
10887 {
10888 switch (get_attr_type (insn))
10889 {
10890 case TYPE_LEA:
10891 return "#";
10892 case TYPE_ALU:
10893 if (operands[2] != const1_rtx)
10894 abort ();
10895 return "add{w}\t{%0, %0|%0, %0}";
10896
10897 default:
10898 if (REG_P (operands[2]))
10899 return "sal{w}\t{%b2, %0|%0, %b2}";
10900 else if (GET_CODE (operands[2]) == CONST_INT
10901 && INTVAL (operands[2]) == 1
10902 && (TARGET_PENTIUM || TARGET_PENTIUMPRO))
10903 return "sal{w}\t%0";
10904 else
10905 return "sal{w}\t{%2, %0|%0, %2}";
10906 }
10907 }
10908 [(set (attr "type")
10909 (cond [(eq_attr "alternative" "1")
10910 (const_string "lea")
10911 (and (and (ne (symbol_ref "TARGET_DOUBLE_WITH_ADD")
10912 (const_int 0))
10913 (match_operand 0 "register_operand" ""))
10914 (match_operand 2 "const1_operand" ""))
10915 (const_string "alu")
10916 ]
10917 (const_string "ishift")))
10918 (set_attr "mode" "HI,SI")])
10919
10920 (define_insn "*ashlhi3_1"
10921 [(set (match_operand:HI 0 "nonimmediate_operand" "=rm")
10922 (ashift:HI (match_operand:HI 1 "nonimmediate_operand" "0")
10923 (match_operand:QI 2 "nonmemory_operand" "cI")))
10924 (clobber (reg:CC 17))]
10925 "TARGET_PARTIAL_REG_STALL
10926 && ix86_binary_operator_ok (ASHIFT, HImode, operands)"
10927 {
10928 switch (get_attr_type (insn))
10929 {
10930 case TYPE_ALU:
10931 if (operands[2] != const1_rtx)
10932 abort ();
10933 return "add{w}\t{%0, %0|%0, %0}";
10934
10935 default:
10936 if (REG_P (operands[2]))
10937 return "sal{w}\t{%b2, %0|%0, %b2}";
10938 else if (GET_CODE (operands[2]) == CONST_INT
10939 && INTVAL (operands[2]) == 1
10940 && (TARGET_PENTIUM || TARGET_PENTIUMPRO))
10941 return "sal{w}\t%0";
10942 else
10943 return "sal{w}\t{%2, %0|%0, %2}";
10944 }
10945 }
10946 [(set (attr "type")
10947 (cond [(and (and (ne (symbol_ref "TARGET_DOUBLE_WITH_ADD")
10948 (const_int 0))
10949 (match_operand 0 "register_operand" ""))
10950 (match_operand 2 "const1_operand" ""))
10951 (const_string "alu")
10952 ]
10953 (const_string "ishift")))
10954 (set_attr "mode" "HI")])
10955
10956 ;; This pattern can't accept a variable shift count, since shifts by
10957 ;; zero don't affect the flags. We assume that shifts by constant
10958 ;; zero are optimized away.
10959 (define_insn "*ashlhi3_cmp"
10960 [(set (reg 17)
10961 (compare
10962 (ashift:HI (match_operand:HI 1 "nonimmediate_operand" "0")
10963 (match_operand:QI 2 "immediate_operand" "I"))
10964 (const_int 0)))
10965 (set (match_operand:HI 0 "nonimmediate_operand" "=rm")
10966 (ashift:HI (match_dup 1) (match_dup 2)))]
10967 "ix86_match_ccmode (insn, CCGOCmode)
10968 && ix86_binary_operator_ok (ASHIFT, HImode, operands)"
10969 {
10970 switch (get_attr_type (insn))
10971 {
10972 case TYPE_ALU:
10973 if (operands[2] != const1_rtx)
10974 abort ();
10975 return "add{w}\t{%0, %0|%0, %0}";
10976
10977 default:
10978 if (REG_P (operands[2]))
10979 return "sal{w}\t{%b2, %0|%0, %b2}";
10980 else if (GET_CODE (operands[2]) == CONST_INT
10981 && INTVAL (operands[2]) == 1
10982 && (TARGET_PENTIUM || TARGET_PENTIUMPRO))
10983 return "sal{w}\t%0";
10984 else
10985 return "sal{w}\t{%2, %0|%0, %2}";
10986 }
10987 }
10988 [(set (attr "type")
10989 (cond [(and (and (ne (symbol_ref "TARGET_DOUBLE_WITH_ADD")
10990 (const_int 0))
10991 (match_operand 0 "register_operand" ""))
10992 (match_operand 2 "const1_operand" ""))
10993 (const_string "alu")
10994 ]
10995 (const_string "ishift")))
10996 (set_attr "mode" "HI")])
10997
10998 (define_expand "ashlqi3"
10999 [(set (match_operand:QI 0 "nonimmediate_operand" "")
11000 (ashift:QI (match_operand:QI 1 "nonimmediate_operand" "")
11001 (match_operand:QI 2 "nonmemory_operand" "")))
11002 (clobber (reg:CC 17))]
11003 "TARGET_QIMODE_MATH"
11004 "ix86_expand_binary_operator (ASHIFT, QImode, operands); DONE;")
11005
11006 ;; %%% Potential partial reg stall on alternative 2. What to do?
11007
11008 (define_insn "*ashlqi3_1_lea"
11009 [(set (match_operand:QI 0 "nonimmediate_operand" "=qm,r,r")
11010 (ashift:QI (match_operand:QI 1 "nonimmediate_operand" "0,0,r")
11011 (match_operand:QI 2 "nonmemory_operand" "cI,cI,M")))
11012 (clobber (reg:CC 17))]
11013 "!TARGET_PARTIAL_REG_STALL
11014 && ix86_binary_operator_ok (ASHIFT, QImode, operands)"
11015 {
11016 switch (get_attr_type (insn))
11017 {
11018 case TYPE_LEA:
11019 return "#";
11020 case TYPE_ALU:
11021 if (operands[2] != const1_rtx)
11022 abort ();
11023 if (REG_P (operands[1]) && !ANY_QI_REG_P (operands[1]))
11024 return "add{l}\t{%k0, %k0|%k0, %k0}";
11025 else
11026 return "add{b}\t{%0, %0|%0, %0}";
11027
11028 default:
11029 if (REG_P (operands[2]))
11030 {
11031 if (get_attr_mode (insn) == MODE_SI)
11032 return "sal{l}\t{%b2, %k0|%k0, %b2}";
11033 else
11034 return "sal{b}\t{%b2, %0|%0, %b2}";
11035 }
11036 else if (GET_CODE (operands[2]) == CONST_INT
11037 && INTVAL (operands[2]) == 1
11038 && (TARGET_PENTIUM || TARGET_PENTIUMPRO))
11039 {
11040 if (get_attr_mode (insn) == MODE_SI)
11041 return "sal{l}\t%0";
11042 else
11043 return "sal{b}\t%0";
11044 }
11045 else
11046 {
11047 if (get_attr_mode (insn) == MODE_SI)
11048 return "sal{l}\t{%2, %k0|%k0, %2}";
11049 else
11050 return "sal{b}\t{%2, %0|%0, %2}";
11051 }
11052 }
11053 }
11054 [(set (attr "type")
11055 (cond [(eq_attr "alternative" "2")
11056 (const_string "lea")
11057 (and (and (ne (symbol_ref "TARGET_DOUBLE_WITH_ADD")
11058 (const_int 0))
11059 (match_operand 0 "register_operand" ""))
11060 (match_operand 2 "const1_operand" ""))
11061 (const_string "alu")
11062 ]
11063 (const_string "ishift")))
11064 (set_attr "mode" "QI,SI,SI")])
11065
11066 (define_insn "*ashlqi3_1"
11067 [(set (match_operand:QI 0 "nonimmediate_operand" "=qm,r")
11068 (ashift:QI (match_operand:QI 1 "nonimmediate_operand" "0,0")
11069 (match_operand:QI 2 "nonmemory_operand" "cI,cI")))
11070 (clobber (reg:CC 17))]
11071 "TARGET_PARTIAL_REG_STALL
11072 && ix86_binary_operator_ok (ASHIFT, QImode, operands)"
11073 {
11074 switch (get_attr_type (insn))
11075 {
11076 case TYPE_ALU:
11077 if (operands[2] != const1_rtx)
11078 abort ();
11079 if (REG_P (operands[1]) && !ANY_QI_REG_P (operands[1]))
11080 return "add{l}\t{%k0, %k0|%k0, %k0}";
11081 else
11082 return "add{b}\t{%0, %0|%0, %0}";
11083
11084 default:
11085 if (REG_P (operands[2]))
11086 {
11087 if (get_attr_mode (insn) == MODE_SI)
11088 return "sal{l}\t{%b2, %k0|%k0, %b2}";
11089 else
11090 return "sal{b}\t{%b2, %0|%0, %b2}";
11091 }
11092 else if (GET_CODE (operands[2]) == CONST_INT
11093 && INTVAL (operands[2]) == 1
11094 && (TARGET_PENTIUM || TARGET_PENTIUMPRO))
11095 {
11096 if (get_attr_mode (insn) == MODE_SI)
11097 return "sal{l}\t%0";
11098 else
11099 return "sal{b}\t%0";
11100 }
11101 else
11102 {
11103 if (get_attr_mode (insn) == MODE_SI)
11104 return "sal{l}\t{%2, %k0|%k0, %2}";
11105 else
11106 return "sal{b}\t{%2, %0|%0, %2}";
11107 }
11108 }
11109 }
11110 [(set (attr "type")
11111 (cond [(and (and (ne (symbol_ref "TARGET_DOUBLE_WITH_ADD")
11112 (const_int 0))
11113 (match_operand 0 "register_operand" ""))
11114 (match_operand 2 "const1_operand" ""))
11115 (const_string "alu")
11116 ]
11117 (const_string "ishift")))
11118 (set_attr "mode" "QI,SI")])
11119
11120 ;; This pattern can't accept a variable shift count, since shifts by
11121 ;; zero don't affect the flags. We assume that shifts by constant
11122 ;; zero are optimized away.
11123 (define_insn "*ashlqi3_cmp"
11124 [(set (reg 17)
11125 (compare
11126 (ashift:QI (match_operand:QI 1 "nonimmediate_operand" "0")
11127 (match_operand:QI 2 "immediate_operand" "I"))
11128 (const_int 0)))
11129 (set (match_operand:QI 0 "nonimmediate_operand" "=qm")
11130 (ashift:QI (match_dup 1) (match_dup 2)))]
11131 "ix86_match_ccmode (insn, CCGOCmode)
11132 && ix86_binary_operator_ok (ASHIFT, QImode, operands)"
11133 {
11134 switch (get_attr_type (insn))
11135 {
11136 case TYPE_ALU:
11137 if (operands[2] != const1_rtx)
11138 abort ();
11139 return "add{b}\t{%0, %0|%0, %0}";
11140
11141 default:
11142 if (REG_P (operands[2]))
11143 return "sal{b}\t{%b2, %0|%0, %b2}";
11144 else if (GET_CODE (operands[2]) == CONST_INT
11145 && INTVAL (operands[2]) == 1
11146 && (TARGET_PENTIUM || TARGET_PENTIUMPRO))
11147 return "sal{b}\t%0";
11148 else
11149 return "sal{b}\t{%2, %0|%0, %2}";
11150 }
11151 }
11152 [(set (attr "type")
11153 (cond [(and (and (ne (symbol_ref "TARGET_DOUBLE_WITH_ADD")
11154 (const_int 0))
11155 (match_operand 0 "register_operand" ""))
11156 (match_operand 2 "const1_operand" ""))
11157 (const_string "alu")
11158 ]
11159 (const_string "ishift")))
11160 (set_attr "mode" "QI")])
11161
11162 ;; See comment above `ashldi3' about how this works.
11163
11164 (define_expand "ashrdi3"
11165 [(parallel [(set (match_operand:DI 0 "shiftdi_operand" "")
11166 (ashiftrt:DI (match_operand:DI 1 "shiftdi_operand" "")
11167 (match_operand:QI 2 "nonmemory_operand" "")))
11168 (clobber (reg:CC 17))])]
11169 ""
11170 {
11171 if (!TARGET_64BIT && TARGET_CMOVE && ! immediate_operand (operands[2], QImode))
11172 {
11173 emit_insn (gen_ashrdi3_1 (operands[0], operands[1], operands[2]));
11174 DONE;
11175 }
11176 ix86_expand_binary_operator (ASHIFTRT, DImode, operands);
11177 DONE;
11178 })
11179
11180 (define_insn "ashrdi3_63_rex64"
11181 [(set (match_operand:DI 0 "nonimmediate_operand" "=*d,rm")
11182 (ashiftrt:DI (match_operand:DI 1 "nonimmediate_operand" "*a,0")
11183 (match_operand:DI 2 "const_int_operand" "i,i")))
11184 (clobber (reg:CC 17))]
11185 "TARGET_64BIT && INTVAL (operands[2]) == 63 && (TARGET_USE_CLTD || optimize_size)
11186 && ix86_binary_operator_ok (ASHIFTRT, DImode, operands)"
11187 "@
11188 {cqto|cqo}
11189 sar{q}\t{%2, %0|%0, %2}"
11190 [(set_attr "type" "imovx,ishift")
11191 (set_attr "prefix_0f" "0,*")
11192 (set_attr "length_immediate" "0,*")
11193 (set_attr "modrm" "0,1")
11194 (set_attr "mode" "DI")])
11195
11196 (define_insn "*ashrdi3_1_one_bit_rex64"
11197 [(set (match_operand:DI 0 "nonimmediate_operand" "=rm")
11198 (ashiftrt:DI (match_operand:DI 1 "nonimmediate_operand" "0")
11199 (match_operand:QI 2 "const_int_1_operand" "")))
11200 (clobber (reg:CC 17))]
11201 "TARGET_64BIT && ix86_binary_operator_ok (ASHIFTRT, DImode, operands)
11202 && (TARGET_PENTIUM || TARGET_PENTIUMPRO)"
11203 "sar{q}\t%0"
11204 [(set_attr "type" "ishift")
11205 (set (attr "length")
11206 (if_then_else (match_operand:DI 0 "register_operand" "")
11207 (const_string "2")
11208 (const_string "*")))])
11209
11210 (define_insn "*ashrdi3_1_rex64"
11211 [(set (match_operand:DI 0 "nonimmediate_operand" "=rm,rm")
11212 (ashiftrt:DI (match_operand:DI 1 "nonimmediate_operand" "0,0")
11213 (match_operand:QI 2 "nonmemory_operand" "J,c")))
11214 (clobber (reg:CC 17))]
11215 "TARGET_64BIT && ix86_binary_operator_ok (ASHIFTRT, DImode, operands)"
11216 "@
11217 sar{q}\t{%2, %0|%0, %2}
11218 sar{q}\t{%b2, %0|%0, %b2}"
11219 [(set_attr "type" "ishift")
11220 (set_attr "mode" "DI")])
11221
11222 ;; This pattern can't accept a variable shift count, since shifts by
11223 ;; zero don't affect the flags. We assume that shifts by constant
11224 ;; zero are optimized away.
11225 (define_insn "*ashrdi3_one_bit_cmp_rex64"
11226 [(set (reg 17)
11227 (compare
11228 (ashiftrt:DI (match_operand:DI 1 "nonimmediate_operand" "0")
11229 (match_operand:QI 2 "const_int_1_operand" ""))
11230 (const_int 0)))
11231 (set (match_operand:DI 0 "nonimmediate_operand" "=rm")
11232 (ashiftrt:DI (match_dup 1) (match_dup 2)))]
11233 "TARGET_64BIT && ix86_match_ccmode (insn, CCGOCmode)
11234 && (TARGET_PENTIUM || TARGET_PENTIUMPRO)
11235 && ix86_binary_operator_ok (ASHIFTRT, DImode, operands)"
11236 "sar{q}\t%0"
11237 [(set_attr "type" "ishift")
11238 (set (attr "length")
11239 (if_then_else (match_operand:DI 0 "register_operand" "")
11240 (const_string "2")
11241 (const_string "*")))])
11242
11243 ;; This pattern can't accept a variable shift count, since shifts by
11244 ;; zero don't affect the flags. We assume that shifts by constant
11245 ;; zero are optimized away.
11246 (define_insn "*ashrdi3_cmp_rex64"
11247 [(set (reg 17)
11248 (compare
11249 (ashiftrt:DI (match_operand:DI 1 "nonimmediate_operand" "0")
11250 (match_operand:QI 2 "const_int_operand" "n"))
11251 (const_int 0)))
11252 (set (match_operand:DI 0 "nonimmediate_operand" "=rm")
11253 (ashiftrt:DI (match_dup 1) (match_dup 2)))]
11254 "TARGET_64BIT && ix86_match_ccmode (insn, CCGOCmode)
11255 && ix86_binary_operator_ok (ASHIFTRT, DImode, operands)"
11256 "sar{q}\t{%2, %0|%0, %2}"
11257 [(set_attr "type" "ishift")
11258 (set_attr "mode" "DI")])
11259
11260
11261 (define_insn "ashrdi3_1"
11262 [(set (match_operand:DI 0 "register_operand" "=r")
11263 (ashiftrt:DI (match_operand:DI 1 "register_operand" "0")
11264 (match_operand:QI 2 "nonmemory_operand" "Jc")))
11265 (clobber (match_scratch:SI 3 "=&r"))
11266 (clobber (reg:CC 17))]
11267 "!TARGET_64BIT && TARGET_CMOVE"
11268 "#"
11269 [(set_attr "type" "multi")])
11270
11271 (define_insn "*ashrdi3_2"
11272 [(set (match_operand:DI 0 "register_operand" "=r")
11273 (ashiftrt:DI (match_operand:DI 1 "register_operand" "0")
11274 (match_operand:QI 2 "nonmemory_operand" "Jc")))
11275 (clobber (reg:CC 17))]
11276 "!TARGET_64BIT"
11277 "#"
11278 [(set_attr "type" "multi")])
11279
11280 (define_split
11281 [(set (match_operand:DI 0 "register_operand" "")
11282 (ashiftrt:DI (match_operand:DI 1 "register_operand" "")
11283 (match_operand:QI 2 "nonmemory_operand" "")))
11284 (clobber (match_scratch:SI 3 ""))
11285 (clobber (reg:CC 17))]
11286 "!TARGET_64BIT && TARGET_CMOVE && reload_completed"
11287 [(const_int 0)]
11288 "ix86_split_ashrdi (operands, operands[3]); DONE;")
11289
11290 (define_split
11291 [(set (match_operand:DI 0 "register_operand" "")
11292 (ashiftrt:DI (match_operand:DI 1 "register_operand" "")
11293 (match_operand:QI 2 "nonmemory_operand" "")))
11294 (clobber (reg:CC 17))]
11295 "!TARGET_64BIT && reload_completed"
11296 [(const_int 0)]
11297 "ix86_split_ashrdi (operands, NULL_RTX); DONE;")
11298
11299 (define_insn "x86_shrd_1"
11300 [(set (match_operand:SI 0 "nonimmediate_operand" "+r*m,r*m")
11301 (ior:SI (ashiftrt:SI (match_dup 0)
11302 (match_operand:QI 2 "nonmemory_operand" "I,c"))
11303 (ashift:SI (match_operand:SI 1 "register_operand" "r,r")
11304 (minus:QI (const_int 32) (match_dup 2)))))
11305 (clobber (reg:CC 17))]
11306 ""
11307 "@
11308 shrd{l}\t{%2, %1, %0|%0, %1, %2}
11309 shrd{l}\t{%s2%1, %0|%0, %1, %2}"
11310 [(set_attr "type" "ishift")
11311 (set_attr "prefix_0f" "1")
11312 (set_attr "pent_pair" "np")
11313 (set_attr "ppro_uops" "few")
11314 (set_attr "mode" "SI")])
11315
11316 (define_expand "x86_shift_adj_3"
11317 [(use (match_operand:SI 0 "register_operand" ""))
11318 (use (match_operand:SI 1 "register_operand" ""))
11319 (use (match_operand:QI 2 "register_operand" ""))]
11320 ""
11321 {
11322 rtx label = gen_label_rtx ();
11323 rtx tmp;
11324
11325 emit_insn (gen_testqi_ccz_1 (operands[2], GEN_INT (32)));
11326
11327 tmp = gen_rtx_REG (CCZmode, FLAGS_REG);
11328 tmp = gen_rtx_EQ (VOIDmode, tmp, const0_rtx);
11329 tmp = gen_rtx_IF_THEN_ELSE (VOIDmode, tmp,
11330 gen_rtx_LABEL_REF (VOIDmode, label),
11331 pc_rtx);
11332 tmp = emit_jump_insn (gen_rtx_SET (VOIDmode, pc_rtx, tmp));
11333 JUMP_LABEL (tmp) = label;
11334
11335 emit_move_insn (operands[0], operands[1]);
11336 emit_insn (gen_ashrsi3_31 (operands[1], operands[1], GEN_INT (31)));
11337
11338 emit_label (label);
11339 LABEL_NUSES (label) = 1;
11340
11341 DONE;
11342 })
11343
11344 (define_insn "ashrsi3_31"
11345 [(set (match_operand:SI 0 "nonimmediate_operand" "=*d,rm")
11346 (ashiftrt:SI (match_operand:SI 1 "nonimmediate_operand" "*a,0")
11347 (match_operand:SI 2 "const_int_operand" "i,i")))
11348 (clobber (reg:CC 17))]
11349 "INTVAL (operands[2]) == 31 && (TARGET_USE_CLTD || optimize_size)
11350 && ix86_binary_operator_ok (ASHIFTRT, SImode, operands)"
11351 "@
11352 {cltd|cdq}
11353 sar{l}\t{%2, %0|%0, %2}"
11354 [(set_attr "type" "imovx,ishift")
11355 (set_attr "prefix_0f" "0,*")
11356 (set_attr "length_immediate" "0,*")
11357 (set_attr "modrm" "0,1")
11358 (set_attr "mode" "SI")])
11359
11360 (define_insn "*ashrsi3_31_zext"
11361 [(set (match_operand:DI 0 "register_operand" "=*d,r")
11362 (zero_extend:DI (ashiftrt:SI (match_operand:SI 1 "register_operand" "*a,0")
11363 (match_operand:SI 2 "const_int_operand" "i,i"))))
11364 (clobber (reg:CC 17))]
11365 "TARGET_64BIT && (TARGET_USE_CLTD || optimize_size)
11366 && INTVAL (operands[2]) == 31
11367 && ix86_binary_operator_ok (ASHIFTRT, SImode, operands)"
11368 "@
11369 {cltd|cdq}
11370 sar{l}\t{%2, %k0|%k0, %2}"
11371 [(set_attr "type" "imovx,ishift")
11372 (set_attr "prefix_0f" "0,*")
11373 (set_attr "length_immediate" "0,*")
11374 (set_attr "modrm" "0,1")
11375 (set_attr "mode" "SI")])
11376
11377 (define_expand "ashrsi3"
11378 [(set (match_operand:SI 0 "nonimmediate_operand" "")
11379 (ashiftrt:SI (match_operand:SI 1 "nonimmediate_operand" "")
11380 (match_operand:QI 2 "nonmemory_operand" "")))
11381 (clobber (reg:CC 17))]
11382 ""
11383 "ix86_expand_binary_operator (ASHIFTRT, SImode, operands); DONE;")
11384
11385 (define_insn "*ashrsi3_1_one_bit"
11386 [(set (match_operand:SI 0 "nonimmediate_operand" "=rm")
11387 (ashiftrt:SI (match_operand:SI 1 "nonimmediate_operand" "0")
11388 (match_operand:QI 2 "const_int_1_operand" "")))
11389 (clobber (reg:CC 17))]
11390 "ix86_binary_operator_ok (ASHIFTRT, SImode, operands)
11391 && (TARGET_PENTIUM || TARGET_PENTIUMPRO)"
11392 "sar{l}\t%0"
11393 [(set_attr "type" "ishift")
11394 (set (attr "length")
11395 (if_then_else (match_operand:SI 0 "register_operand" "")
11396 (const_string "2")
11397 (const_string "*")))])
11398
11399 (define_insn "*ashrsi3_1_one_bit_zext"
11400 [(set (match_operand:DI 0 "register_operand" "=r")
11401 (zero_extend:DI (ashiftrt:SI (match_operand:SI 1 "register_operand" "0")
11402 (match_operand:QI 2 "const_int_1_operand" ""))))
11403 (clobber (reg:CC 17))]
11404 "TARGET_64BIT && ix86_binary_operator_ok (ASHIFTRT, SImode, operands)
11405 && (TARGET_PENTIUM || TARGET_PENTIUMPRO)"
11406 "sar{l}\t%k0"
11407 [(set_attr "type" "ishift")
11408 (set_attr "length" "2")])
11409
11410 (define_insn "*ashrsi3_1"
11411 [(set (match_operand:SI 0 "nonimmediate_operand" "=rm,rm")
11412 (ashiftrt:SI (match_operand:SI 1 "nonimmediate_operand" "0,0")
11413 (match_operand:QI 2 "nonmemory_operand" "I,c")))
11414 (clobber (reg:CC 17))]
11415 "ix86_binary_operator_ok (ASHIFTRT, SImode, operands)"
11416 "@
11417 sar{l}\t{%2, %0|%0, %2}
11418 sar{l}\t{%b2, %0|%0, %b2}"
11419 [(set_attr "type" "ishift")
11420 (set_attr "mode" "SI")])
11421
11422 (define_insn "*ashrsi3_1_zext"
11423 [(set (match_operand:DI 0 "register_operand" "=r,r")
11424 (zero_extend:DI (ashiftrt:SI (match_operand:SI 1 "register_operand" "0,0")
11425 (match_operand:QI 2 "nonmemory_operand" "I,c"))))
11426 (clobber (reg:CC 17))]
11427 "TARGET_64BIT && ix86_binary_operator_ok (ASHIFTRT, SImode, operands)"
11428 "@
11429 sar{l}\t{%2, %k0|%k0, %2}
11430 sar{l}\t{%b2, %k0|%k0, %b2}"
11431 [(set_attr "type" "ishift")
11432 (set_attr "mode" "SI")])
11433
11434 ;; This pattern can't accept a variable shift count, since shifts by
11435 ;; zero don't affect the flags. We assume that shifts by constant
11436 ;; zero are optimized away.
11437 (define_insn "*ashrsi3_one_bit_cmp"
11438 [(set (reg 17)
11439 (compare
11440 (ashiftrt:SI (match_operand:SI 1 "nonimmediate_operand" "0")
11441 (match_operand:QI 2 "const_int_1_operand" ""))
11442 (const_int 0)))
11443 (set (match_operand:SI 0 "nonimmediate_operand" "=rm")
11444 (ashiftrt:SI (match_dup 1) (match_dup 2)))]
11445 "ix86_match_ccmode (insn, CCGOCmode)
11446 && (TARGET_PENTIUM || TARGET_PENTIUMPRO)
11447 && ix86_binary_operator_ok (ASHIFTRT, SImode, operands)"
11448 "sar{l}\t%0"
11449 [(set_attr "type" "ishift")
11450 (set (attr "length")
11451 (if_then_else (match_operand:SI 0 "register_operand" "")
11452 (const_string "2")
11453 (const_string "*")))])
11454
11455 (define_insn "*ashrsi3_one_bit_cmp_zext"
11456 [(set (reg 17)
11457 (compare
11458 (ashiftrt:SI (match_operand:SI 1 "register_operand" "0")
11459 (match_operand:QI 2 "const_int_1_operand" ""))
11460 (const_int 0)))
11461 (set (match_operand:DI 0 "register_operand" "=r")
11462 (zero_extend:DI (ashiftrt:SI (match_dup 1) (match_dup 2))))]
11463 "TARGET_64BIT && ix86_match_ccmode (insn, CCmode)
11464 && (TARGET_PENTIUM || TARGET_PENTIUMPRO)
11465 && ix86_binary_operator_ok (ASHIFTRT, SImode, operands)"
11466 "sar{l}\t%k0"
11467 [(set_attr "type" "ishift")
11468 (set_attr "length" "2")])
11469
11470 ;; This pattern can't accept a variable shift count, since shifts by
11471 ;; zero don't affect the flags. We assume that shifts by constant
11472 ;; zero are optimized away.
11473 (define_insn "*ashrsi3_cmp"
11474 [(set (reg 17)
11475 (compare
11476 (ashiftrt:SI (match_operand:SI 1 "nonimmediate_operand" "0")
11477 (match_operand:QI 2 "immediate_operand" "I"))
11478 (const_int 0)))
11479 (set (match_operand:SI 0 "nonimmediate_operand" "=rm")
11480 (ashiftrt:SI (match_dup 1) (match_dup 2)))]
11481 "ix86_match_ccmode (insn, CCGOCmode)
11482 && ix86_binary_operator_ok (ASHIFTRT, SImode, operands)"
11483 "sar{l}\t{%2, %0|%0, %2}"
11484 [(set_attr "type" "ishift")
11485 (set_attr "mode" "SI")])
11486
11487 (define_insn "*ashrsi3_cmp_zext"
11488 [(set (reg 17)
11489 (compare
11490 (ashiftrt:SI (match_operand:SI 1 "register_operand" "0")
11491 (match_operand:QI 2 "immediate_operand" "I"))
11492 (const_int 0)))
11493 (set (match_operand:DI 0 "register_operand" "=r")
11494 (zero_extend:DI (ashiftrt:SI (match_dup 1) (match_dup 2))))]
11495 "TARGET_64BIT && ix86_match_ccmode (insn, CCGOCmode)
11496 && ix86_binary_operator_ok (ASHIFTRT, SImode, operands)"
11497 "sar{l}\t{%2, %k0|%k0, %2}"
11498 [(set_attr "type" "ishift")
11499 (set_attr "mode" "SI")])
11500
11501 (define_expand "ashrhi3"
11502 [(set (match_operand:HI 0 "nonimmediate_operand" "")
11503 (ashiftrt:HI (match_operand:HI 1 "nonimmediate_operand" "")
11504 (match_operand:QI 2 "nonmemory_operand" "")))
11505 (clobber (reg:CC 17))]
11506 "TARGET_HIMODE_MATH"
11507 "ix86_expand_binary_operator (ASHIFTRT, HImode, operands); DONE;")
11508
11509 (define_insn "*ashrhi3_1_one_bit"
11510 [(set (match_operand:HI 0 "nonimmediate_operand" "=rm")
11511 (ashiftrt:HI (match_operand:HI 1 "nonimmediate_operand" "0")
11512 (match_operand:QI 2 "const_int_1_operand" "")))
11513 (clobber (reg:CC 17))]
11514 "ix86_binary_operator_ok (ASHIFTRT, HImode, operands)
11515 && (TARGET_PENTIUM || TARGET_PENTIUMPRO)"
11516 "sar{w}\t%0"
11517 [(set_attr "type" "ishift")
11518 (set (attr "length")
11519 (if_then_else (match_operand 0 "register_operand" "")
11520 (const_string "2")
11521 (const_string "*")))])
11522
11523 (define_insn "*ashrhi3_1"
11524 [(set (match_operand:HI 0 "nonimmediate_operand" "=rm,rm")
11525 (ashiftrt:HI (match_operand:HI 1 "nonimmediate_operand" "0,0")
11526 (match_operand:QI 2 "nonmemory_operand" "I,c")))
11527 (clobber (reg:CC 17))]
11528 "ix86_binary_operator_ok (ASHIFTRT, HImode, operands)"
11529 "@
11530 sar{w}\t{%2, %0|%0, %2}
11531 sar{w}\t{%b2, %0|%0, %b2}"
11532 [(set_attr "type" "ishift")
11533 (set_attr "mode" "HI")])
11534
11535 ;; This pattern can't accept a variable shift count, since shifts by
11536 ;; zero don't affect the flags. We assume that shifts by constant
11537 ;; zero are optimized away.
11538 (define_insn "*ashrhi3_one_bit_cmp"
11539 [(set (reg 17)
11540 (compare
11541 (ashiftrt:HI (match_operand:HI 1 "nonimmediate_operand" "0")
11542 (match_operand:QI 2 "const_int_1_operand" ""))
11543 (const_int 0)))
11544 (set (match_operand:HI 0 "nonimmediate_operand" "=rm")
11545 (ashiftrt:HI (match_dup 1) (match_dup 2)))]
11546 "ix86_match_ccmode (insn, CCGOCmode)
11547 && (TARGET_PENTIUM || TARGET_PENTIUMPRO)
11548 && ix86_binary_operator_ok (ASHIFTRT, HImode, operands)"
11549 "sar{w}\t%0"
11550 [(set_attr "type" "ishift")
11551 (set (attr "length")
11552 (if_then_else (match_operand 0 "register_operand" "")
11553 (const_string "2")
11554 (const_string "*")))])
11555
11556 ;; This pattern can't accept a variable shift count, since shifts by
11557 ;; zero don't affect the flags. We assume that shifts by constant
11558 ;; zero are optimized away.
11559 (define_insn "*ashrhi3_cmp"
11560 [(set (reg 17)
11561 (compare
11562 (ashiftrt:HI (match_operand:HI 1 "nonimmediate_operand" "0")
11563 (match_operand:QI 2 "immediate_operand" "I"))
11564 (const_int 0)))
11565 (set (match_operand:HI 0 "nonimmediate_operand" "=rm")
11566 (ashiftrt:HI (match_dup 1) (match_dup 2)))]
11567 "ix86_match_ccmode (insn, CCGOCmode)
11568 && ix86_binary_operator_ok (ASHIFTRT, HImode, operands)"
11569 "sar{w}\t{%2, %0|%0, %2}"
11570 [(set_attr "type" "ishift")
11571 (set_attr "mode" "HI")])
11572
11573 (define_expand "ashrqi3"
11574 [(set (match_operand:QI 0 "nonimmediate_operand" "")
11575 (ashiftrt:QI (match_operand:QI 1 "nonimmediate_operand" "")
11576 (match_operand:QI 2 "nonmemory_operand" "")))
11577 (clobber (reg:CC 17))]
11578 "TARGET_QIMODE_MATH"
11579 "ix86_expand_binary_operator (ASHIFTRT, QImode, operands); DONE;")
11580
11581 (define_insn "*ashrqi3_1_one_bit"
11582 [(set (match_operand:QI 0 "nonimmediate_operand" "=qm")
11583 (ashiftrt:QI (match_operand:QI 1 "nonimmediate_operand" "0")
11584 (match_operand:QI 2 "const_int_1_operand" "")))
11585 (clobber (reg:CC 17))]
11586 "ix86_binary_operator_ok (ASHIFTRT, QImode, operands)
11587 && (TARGET_PENTIUM || TARGET_PENTIUMPRO)"
11588 "sar{b}\t%0"
11589 [(set_attr "type" "ishift")
11590 (set (attr "length")
11591 (if_then_else (match_operand 0 "register_operand" "")
11592 (const_string "2")
11593 (const_string "*")))])
11594
11595 (define_insn "*ashrqi3_1"
11596 [(set (match_operand:QI 0 "nonimmediate_operand" "=qm,qm")
11597 (ashiftrt:QI (match_operand:QI 1 "nonimmediate_operand" "0,0")
11598 (match_operand:QI 2 "nonmemory_operand" "I,c")))
11599 (clobber (reg:CC 17))]
11600 "ix86_binary_operator_ok (ASHIFTRT, QImode, operands)"
11601 "@
11602 sar{b}\t{%2, %0|%0, %2}
11603 sar{b}\t{%b2, %0|%0, %b2}"
11604 [(set_attr "type" "ishift")
11605 (set_attr "mode" "QI")])
11606
11607 ;; This pattern can't accept a variable shift count, since shifts by
11608 ;; zero don't affect the flags. We assume that shifts by constant
11609 ;; zero are optimized away.
11610 (define_insn "*ashrqi3_one_bit_cmp"
11611 [(set (reg 17)
11612 (compare
11613 (ashiftrt:QI (match_operand:QI 1 "nonimmediate_operand" "0")
11614 (match_operand:QI 2 "const_int_1_operand" "I"))
11615 (const_int 0)))
11616 (set (match_operand:QI 0 "nonimmediate_operand" "=rm")
11617 (ashiftrt:QI (match_dup 1) (match_dup 2)))]
11618 "ix86_match_ccmode (insn, CCGOCmode)
11619 && (TARGET_PENTIUM || TARGET_PENTIUMPRO)
11620 && ix86_binary_operator_ok (ASHIFTRT, QImode, operands)"
11621 "sar{b}\t%0"
11622 [(set_attr "type" "ishift")
11623 (set (attr "length")
11624 (if_then_else (match_operand 0 "register_operand" "")
11625 (const_string "2")
11626 (const_string "*")))])
11627
11628 ;; This pattern can't accept a variable shift count, since shifts by
11629 ;; zero don't affect the flags. We assume that shifts by constant
11630 ;; zero are optimized away.
11631 (define_insn "*ashrqi3_cmp"
11632 [(set (reg 17)
11633 (compare
11634 (ashiftrt:QI (match_operand:QI 1 "nonimmediate_operand" "0")
11635 (match_operand:QI 2 "immediate_operand" "I"))
11636 (const_int 0)))
11637 (set (match_operand:QI 0 "nonimmediate_operand" "=rm")
11638 (ashiftrt:QI (match_dup 1) (match_dup 2)))]
11639 "ix86_match_ccmode (insn, CCGOCmode)
11640 && ix86_binary_operator_ok (ASHIFTRT, QImode, operands)"
11641 "sar{b}\t{%2, %0|%0, %2}"
11642 [(set_attr "type" "ishift")
11643 (set_attr "mode" "QI")])
11644 \f
11645 ;; Logical shift instructions
11646
11647 ;; See comment above `ashldi3' about how this works.
11648
11649 (define_expand "lshrdi3"
11650 [(parallel [(set (match_operand:DI 0 "shiftdi_operand" "")
11651 (lshiftrt:DI (match_operand:DI 1 "shiftdi_operand" "")
11652 (match_operand:QI 2 "nonmemory_operand" "")))
11653 (clobber (reg:CC 17))])]
11654 ""
11655 {
11656 if (!TARGET_64BIT && TARGET_CMOVE && ! immediate_operand (operands[2], QImode))
11657 {
11658 emit_insn (gen_lshrdi3_1 (operands[0], operands[1], operands[2]));
11659 DONE;
11660 }
11661 ix86_expand_binary_operator (LSHIFTRT, DImode, operands);
11662 DONE;
11663 })
11664
11665 (define_insn "*lshrdi3_1_one_bit_rex64"
11666 [(set (match_operand:DI 0 "nonimmediate_operand" "=rm")
11667 (lshiftrt:DI (match_operand:DI 1 "nonimmediate_operand" "0")
11668 (match_operand:QI 2 "const_int_1_operand" "")))
11669 (clobber (reg:CC 17))]
11670 "TARGET_64BIT && ix86_binary_operator_ok (LSHIFTRT, HImode, operands)
11671 && (TARGET_PENTIUM || TARGET_PENTIUMPRO)"
11672 "shr{q}\t%0"
11673 [(set_attr "type" "ishift")
11674 (set (attr "length")
11675 (if_then_else (match_operand:DI 0 "register_operand" "")
11676 (const_string "2")
11677 (const_string "*")))])
11678
11679 (define_insn "*lshrdi3_1_rex64"
11680 [(set (match_operand:DI 0 "nonimmediate_operand" "=rm,rm")
11681 (lshiftrt:DI (match_operand:DI 1 "nonimmediate_operand" "0,0")
11682 (match_operand:QI 2 "nonmemory_operand" "J,c")))
11683 (clobber (reg:CC 17))]
11684 "TARGET_64BIT && ix86_binary_operator_ok (LSHIFTRT, HImode, operands)"
11685 "@
11686 shr{q}\t{%2, %0|%0, %2}
11687 shr{q}\t{%b2, %0|%0, %b2}"
11688 [(set_attr "type" "ishift")
11689 (set_attr "mode" "DI")])
11690
11691 ;; This pattern can't accept a variable shift count, since shifts by
11692 ;; zero don't affect the flags. We assume that shifts by constant
11693 ;; zero are optimized away.
11694 (define_insn "*lshrdi3_cmp_one_bit_rex64"
11695 [(set (reg 17)
11696 (compare
11697 (lshiftrt:DI (match_operand:DI 1 "nonimmediate_operand" "0")
11698 (match_operand:QI 2 "const_int_1_operand" ""))
11699 (const_int 0)))
11700 (set (match_operand:DI 0 "nonimmediate_operand" "=rm")
11701 (lshiftrt:DI (match_dup 1) (match_dup 2)))]
11702 "TARGET_64BIT && ix86_match_ccmode (insn, CCGOCmode)
11703 && (TARGET_PENTIUM || TARGET_PENTIUMPRO)
11704 && ix86_binary_operator_ok (LSHIFTRT, HImode, operands)"
11705 "shr{q}\t%0"
11706 [(set_attr "type" "ishift")
11707 (set (attr "length")
11708 (if_then_else (match_operand:DI 0 "register_operand" "")
11709 (const_string "2")
11710 (const_string "*")))])
11711
11712 ;; This pattern can't accept a variable shift count, since shifts by
11713 ;; zero don't affect the flags. We assume that shifts by constant
11714 ;; zero are optimized away.
11715 (define_insn "*lshrdi3_cmp_rex64"
11716 [(set (reg 17)
11717 (compare
11718 (lshiftrt:DI (match_operand:DI 1 "nonimmediate_operand" "0")
11719 (match_operand:QI 2 "const_int_operand" "e"))
11720 (const_int 0)))
11721 (set (match_operand:DI 0 "nonimmediate_operand" "=rm")
11722 (lshiftrt:DI (match_dup 1) (match_dup 2)))]
11723 "TARGET_64BIT && ix86_match_ccmode (insn, CCGOCmode)
11724 && ix86_binary_operator_ok (LSHIFTRT, HImode, operands)"
11725 "shr{q}\t{%2, %0|%0, %2}"
11726 [(set_attr "type" "ishift")
11727 (set_attr "mode" "DI")])
11728
11729 (define_insn "lshrdi3_1"
11730 [(set (match_operand:DI 0 "register_operand" "=r")
11731 (lshiftrt:DI (match_operand:DI 1 "register_operand" "0")
11732 (match_operand:QI 2 "nonmemory_operand" "Jc")))
11733 (clobber (match_scratch:SI 3 "=&r"))
11734 (clobber (reg:CC 17))]
11735 "!TARGET_64BIT && TARGET_CMOVE"
11736 "#"
11737 [(set_attr "type" "multi")])
11738
11739 (define_insn "*lshrdi3_2"
11740 [(set (match_operand:DI 0 "register_operand" "=r")
11741 (lshiftrt:DI (match_operand:DI 1 "register_operand" "0")
11742 (match_operand:QI 2 "nonmemory_operand" "Jc")))
11743 (clobber (reg:CC 17))]
11744 "!TARGET_64BIT"
11745 "#"
11746 [(set_attr "type" "multi")])
11747
11748 (define_split
11749 [(set (match_operand:DI 0 "register_operand" "")
11750 (lshiftrt:DI (match_operand:DI 1 "register_operand" "")
11751 (match_operand:QI 2 "nonmemory_operand" "")))
11752 (clobber (match_scratch:SI 3 ""))
11753 (clobber (reg:CC 17))]
11754 "!TARGET_64BIT && TARGET_CMOVE && reload_completed"
11755 [(const_int 0)]
11756 "ix86_split_lshrdi (operands, operands[3]); DONE;")
11757
11758 (define_split
11759 [(set (match_operand:DI 0 "register_operand" "")
11760 (lshiftrt:DI (match_operand:DI 1 "register_operand" "")
11761 (match_operand:QI 2 "nonmemory_operand" "")))
11762 (clobber (reg:CC 17))]
11763 "!TARGET_64BIT && reload_completed"
11764 [(const_int 0)]
11765 "ix86_split_lshrdi (operands, NULL_RTX); DONE;")
11766
11767 (define_expand "lshrsi3"
11768 [(set (match_operand:SI 0 "nonimmediate_operand" "")
11769 (lshiftrt:SI (match_operand:SI 1 "nonimmediate_operand" "")
11770 (match_operand:QI 2 "nonmemory_operand" "")))
11771 (clobber (reg:CC 17))]
11772 ""
11773 "ix86_expand_binary_operator (LSHIFTRT, SImode, operands); DONE;")
11774
11775 (define_insn "*lshrsi3_1_one_bit"
11776 [(set (match_operand:SI 0 "nonimmediate_operand" "=rm")
11777 (lshiftrt:SI (match_operand:SI 1 "nonimmediate_operand" "0")
11778 (match_operand:QI 2 "const_int_1_operand" "")))
11779 (clobber (reg:CC 17))]
11780 "ix86_binary_operator_ok (LSHIFTRT, HImode, operands)
11781 && (TARGET_PENTIUM || TARGET_PENTIUMPRO)"
11782 "shr{l}\t%0"
11783 [(set_attr "type" "ishift")
11784 (set (attr "length")
11785 (if_then_else (match_operand:SI 0 "register_operand" "")
11786 (const_string "2")
11787 (const_string "*")))])
11788
11789 (define_insn "*lshrsi3_1_one_bit_zext"
11790 [(set (match_operand:DI 0 "register_operand" "=r")
11791 (lshiftrt:DI (zero_extend:DI (match_operand:SI 1 "register_operand" "0"))
11792 (match_operand:QI 2 "const_int_1_operand" "")))
11793 (clobber (reg:CC 17))]
11794 "TARGET_64BIT && ix86_binary_operator_ok (LSHIFTRT, HImode, operands)
11795 && (TARGET_PENTIUM || TARGET_PENTIUMPRO)"
11796 "shr{l}\t%k0"
11797 [(set_attr "type" "ishift")
11798 (set_attr "length" "2")])
11799
11800 (define_insn "*lshrsi3_1"
11801 [(set (match_operand:SI 0 "nonimmediate_operand" "=rm,rm")
11802 (lshiftrt:SI (match_operand:SI 1 "nonimmediate_operand" "0,0")
11803 (match_operand:QI 2 "nonmemory_operand" "I,c")))
11804 (clobber (reg:CC 17))]
11805 "ix86_binary_operator_ok (LSHIFTRT, HImode, operands)"
11806 "@
11807 shr{l}\t{%2, %0|%0, %2}
11808 shr{l}\t{%b2, %0|%0, %b2}"
11809 [(set_attr "type" "ishift")
11810 (set_attr "mode" "SI")])
11811
11812 (define_insn "*lshrsi3_1_zext"
11813 [(set (match_operand:DI 0 "register_operand" "=r,r")
11814 (zero_extend:DI
11815 (lshiftrt:SI (match_operand:SI 1 "nonimmediate_operand" "0,0")
11816 (match_operand:QI 2 "nonmemory_operand" "I,c"))))
11817 (clobber (reg:CC 17))]
11818 "TARGET_64BIT && ix86_binary_operator_ok (LSHIFTRT, HImode, operands)"
11819 "@
11820 shr{l}\t{%2, %k0|%k0, %2}
11821 shr{l}\t{%b2, %k0|%k0, %b2}"
11822 [(set_attr "type" "ishift")
11823 (set_attr "mode" "SI")])
11824
11825 ;; This pattern can't accept a variable shift count, since shifts by
11826 ;; zero don't affect the flags. We assume that shifts by constant
11827 ;; zero are optimized away.
11828 (define_insn "*lshrsi3_one_bit_cmp"
11829 [(set (reg 17)
11830 (compare
11831 (lshiftrt:SI (match_operand:SI 1 "nonimmediate_operand" "0")
11832 (match_operand:QI 2 "const_int_1_operand" ""))
11833 (const_int 0)))
11834 (set (match_operand:SI 0 "nonimmediate_operand" "=rm")
11835 (lshiftrt:SI (match_dup 1) (match_dup 2)))]
11836 "ix86_match_ccmode (insn, CCGOCmode)
11837 && (TARGET_PENTIUM || TARGET_PENTIUMPRO)
11838 && ix86_binary_operator_ok (LSHIFTRT, HImode, operands)"
11839 "shr{l}\t%0"
11840 [(set_attr "type" "ishift")
11841 (set (attr "length")
11842 (if_then_else (match_operand:SI 0 "register_operand" "")
11843 (const_string "2")
11844 (const_string "*")))])
11845
11846 (define_insn "*lshrsi3_cmp_one_bit_zext"
11847 [(set (reg 17)
11848 (compare
11849 (lshiftrt:SI (match_operand:SI 1 "register_operand" "0")
11850 (match_operand:QI 2 "const_int_1_operand" ""))
11851 (const_int 0)))
11852 (set (match_operand:DI 0 "register_operand" "=r")
11853 (lshiftrt:DI (zero_extend:DI (match_dup 1)) (match_dup 2)))]
11854 "TARGET_64BIT && ix86_match_ccmode (insn, CCGOCmode)
11855 && (TARGET_PENTIUM || TARGET_PENTIUMPRO)
11856 && ix86_binary_operator_ok (LSHIFTRT, HImode, operands)"
11857 "shr{l}\t%k0"
11858 [(set_attr "type" "ishift")
11859 (set_attr "length" "2")])
11860
11861 ;; This pattern can't accept a variable shift count, since shifts by
11862 ;; zero don't affect the flags. We assume that shifts by constant
11863 ;; zero are optimized away.
11864 (define_insn "*lshrsi3_cmp"
11865 [(set (reg 17)
11866 (compare
11867 (lshiftrt:SI (match_operand:SI 1 "nonimmediate_operand" "0")
11868 (match_operand:QI 2 "immediate_operand" "I"))
11869 (const_int 0)))
11870 (set (match_operand:SI 0 "nonimmediate_operand" "=rm")
11871 (lshiftrt:SI (match_dup 1) (match_dup 2)))]
11872 "ix86_match_ccmode (insn, CCGOCmode)
11873 && ix86_binary_operator_ok (LSHIFTRT, HImode, operands)"
11874 "shr{l}\t{%2, %0|%0, %2}"
11875 [(set_attr "type" "ishift")
11876 (set_attr "mode" "SI")])
11877
11878 (define_insn "*lshrsi3_cmp_zext"
11879 [(set (reg 17)
11880 (compare
11881 (lshiftrt:SI (match_operand:SI 1 "register_operand" "0")
11882 (match_operand:QI 2 "immediate_operand" "I"))
11883 (const_int 0)))
11884 (set (match_operand:DI 0 "register_operand" "=r")
11885 (lshiftrt:DI (zero_extend:DI (match_dup 1)) (match_dup 2)))]
11886 "TARGET_64BIT && ix86_match_ccmode (insn, CCGOCmode)
11887 && ix86_binary_operator_ok (LSHIFTRT, HImode, operands)"
11888 "shr{l}\t{%2, %k0|%k0, %2}"
11889 [(set_attr "type" "ishift")
11890 (set_attr "mode" "SI")])
11891
11892 (define_expand "lshrhi3"
11893 [(set (match_operand:HI 0 "nonimmediate_operand" "")
11894 (lshiftrt:HI (match_operand:HI 1 "nonimmediate_operand" "")
11895 (match_operand:QI 2 "nonmemory_operand" "")))
11896 (clobber (reg:CC 17))]
11897 "TARGET_HIMODE_MATH"
11898 "ix86_expand_binary_operator (LSHIFTRT, HImode, operands); DONE;")
11899
11900 (define_insn "*lshrhi3_1_one_bit"
11901 [(set (match_operand:HI 0 "nonimmediate_operand" "=rm")
11902 (lshiftrt:HI (match_operand:HI 1 "nonimmediate_operand" "0")
11903 (match_operand:QI 2 "const_int_1_operand" "")))
11904 (clobber (reg:CC 17))]
11905 "ix86_binary_operator_ok (LSHIFTRT, HImode, operands)
11906 && (TARGET_PENTIUM || TARGET_PENTIUMPRO)"
11907 "shr{w}\t%0"
11908 [(set_attr "type" "ishift")
11909 (set (attr "length")
11910 (if_then_else (match_operand 0 "register_operand" "")
11911 (const_string "2")
11912 (const_string "*")))])
11913
11914 (define_insn "*lshrhi3_1"
11915 [(set (match_operand:HI 0 "nonimmediate_operand" "=rm,rm")
11916 (lshiftrt:HI (match_operand:HI 1 "nonimmediate_operand" "0,0")
11917 (match_operand:QI 2 "nonmemory_operand" "I,c")))
11918 (clobber (reg:CC 17))]
11919 "ix86_binary_operator_ok (LSHIFTRT, HImode, operands)"
11920 "@
11921 shr{w}\t{%2, %0|%0, %2}
11922 shr{w}\t{%b2, %0|%0, %b2}"
11923 [(set_attr "type" "ishift")
11924 (set_attr "mode" "HI")])
11925
11926 ;; This pattern can't accept a variable shift count, since shifts by
11927 ;; zero don't affect the flags. We assume that shifts by constant
11928 ;; zero are optimized away.
11929 (define_insn "*lshrhi3_one_bit_cmp"
11930 [(set (reg 17)
11931 (compare
11932 (lshiftrt:HI (match_operand:HI 1 "nonimmediate_operand" "0")
11933 (match_operand:QI 2 "const_int_1_operand" ""))
11934 (const_int 0)))
11935 (set (match_operand:HI 0 "nonimmediate_operand" "=rm")
11936 (lshiftrt:HI (match_dup 1) (match_dup 2)))]
11937 "ix86_match_ccmode (insn, CCGOCmode)
11938 && (TARGET_PENTIUM || TARGET_PENTIUMPRO)
11939 && ix86_binary_operator_ok (LSHIFTRT, HImode, operands)"
11940 "shr{w}\t%0"
11941 [(set_attr "type" "ishift")
11942 (set (attr "length")
11943 (if_then_else (match_operand:SI 0 "register_operand" "")
11944 (const_string "2")
11945 (const_string "*")))])
11946
11947 ;; This pattern can't accept a variable shift count, since shifts by
11948 ;; zero don't affect the flags. We assume that shifts by constant
11949 ;; zero are optimized away.
11950 (define_insn "*lshrhi3_cmp"
11951 [(set (reg 17)
11952 (compare
11953 (lshiftrt:HI (match_operand:HI 1 "nonimmediate_operand" "0")
11954 (match_operand:QI 2 "immediate_operand" "I"))
11955 (const_int 0)))
11956 (set (match_operand:HI 0 "nonimmediate_operand" "=rm")
11957 (lshiftrt:HI (match_dup 1) (match_dup 2)))]
11958 "ix86_match_ccmode (insn, CCGOCmode)
11959 && ix86_binary_operator_ok (LSHIFTRT, HImode, operands)"
11960 "shr{w}\t{%2, %0|%0, %2}"
11961 [(set_attr "type" "ishift")
11962 (set_attr "mode" "HI")])
11963
11964 (define_expand "lshrqi3"
11965 [(set (match_operand:QI 0 "nonimmediate_operand" "")
11966 (lshiftrt:QI (match_operand:QI 1 "nonimmediate_operand" "")
11967 (match_operand:QI 2 "nonmemory_operand" "")))
11968 (clobber (reg:CC 17))]
11969 "TARGET_QIMODE_MATH"
11970 "ix86_expand_binary_operator (LSHIFTRT, QImode, operands); DONE;")
11971
11972 (define_insn "*lshrqi3_1_one_bit"
11973 [(set (match_operand:QI 0 "nonimmediate_operand" "=qm")
11974 (lshiftrt:QI (match_operand:QI 1 "nonimmediate_operand" "0")
11975 (match_operand:QI 2 "const_int_1_operand" "")))
11976 (clobber (reg:CC 17))]
11977 "ix86_binary_operator_ok (LSHIFTRT, QImode, operands)
11978 && (TARGET_PENTIUM || TARGET_PENTIUMPRO)"
11979 "shr{b}\t%0"
11980 [(set_attr "type" "ishift")
11981 (set (attr "length")
11982 (if_then_else (match_operand 0 "register_operand" "")
11983 (const_string "2")
11984 (const_string "*")))])
11985
11986 (define_insn "*lshrqi3_1"
11987 [(set (match_operand:QI 0 "nonimmediate_operand" "=qm,qm")
11988 (lshiftrt:QI (match_operand:QI 1 "nonimmediate_operand" "0,0")
11989 (match_operand:QI 2 "nonmemory_operand" "I,c")))
11990 (clobber (reg:CC 17))]
11991 "ix86_binary_operator_ok (LSHIFTRT, QImode, operands)"
11992 "@
11993 shr{b}\t{%2, %0|%0, %2}
11994 shr{b}\t{%b2, %0|%0, %b2}"
11995 [(set_attr "type" "ishift")
11996 (set_attr "mode" "QI")])
11997
11998 ;; This pattern can't accept a variable shift count, since shifts by
11999 ;; zero don't affect the flags. We assume that shifts by constant
12000 ;; zero are optimized away.
12001 (define_insn "*lshrqi2_one_bit_cmp"
12002 [(set (reg 17)
12003 (compare
12004 (lshiftrt:QI (match_operand:QI 1 "nonimmediate_operand" "0")
12005 (match_operand:QI 2 "const_int_1_operand" ""))
12006 (const_int 0)))
12007 (set (match_operand:QI 0 "nonimmediate_operand" "=qm")
12008 (lshiftrt:QI (match_dup 1) (match_dup 2)))]
12009 "ix86_match_ccmode (insn, CCGOCmode)
12010 && (TARGET_PENTIUM || TARGET_PENTIUMPRO)
12011 && ix86_binary_operator_ok (LSHIFTRT, QImode, operands)"
12012 "shr{b}\t%0"
12013 [(set_attr "type" "ishift")
12014 (set (attr "length")
12015 (if_then_else (match_operand:SI 0 "register_operand" "")
12016 (const_string "2")
12017 (const_string "*")))])
12018
12019 ;; This pattern can't accept a variable shift count, since shifts by
12020 ;; zero don't affect the flags. We assume that shifts by constant
12021 ;; zero are optimized away.
12022 (define_insn "*lshrqi2_cmp"
12023 [(set (reg 17)
12024 (compare
12025 (lshiftrt:QI (match_operand:QI 1 "nonimmediate_operand" "0")
12026 (match_operand:QI 2 "immediate_operand" "I"))
12027 (const_int 0)))
12028 (set (match_operand:QI 0 "nonimmediate_operand" "=qm")
12029 (lshiftrt:QI (match_dup 1) (match_dup 2)))]
12030 "ix86_match_ccmode (insn, CCGOCmode)
12031 && ix86_binary_operator_ok (LSHIFTRT, QImode, operands)"
12032 "shr{b}\t{%2, %0|%0, %2}"
12033 [(set_attr "type" "ishift")
12034 (set_attr "mode" "QI")])
12035 \f
12036 ;; Rotate instructions
12037
12038 (define_expand "rotldi3"
12039 [(set (match_operand:DI 0 "nonimmediate_operand" "")
12040 (rotate:DI (match_operand:DI 1 "nonimmediate_operand" "")
12041 (match_operand:QI 2 "nonmemory_operand" "")))
12042 (clobber (reg:CC 17))]
12043 "TARGET_64BIT"
12044 "ix86_expand_binary_operator (ROTATE, DImode, operands); DONE;")
12045
12046 (define_insn "*rotlsi3_1_one_bit_rex64"
12047 [(set (match_operand:DI 0 "nonimmediate_operand" "=rm")
12048 (rotate:DI (match_operand:DI 1 "nonimmediate_operand" "0")
12049 (match_operand:QI 2 "const_int_1_operand" "")))
12050 (clobber (reg:CC 17))]
12051 "TARGET_64BIT && ix86_binary_operator_ok (ROTATE, DImode, operands)
12052 && (TARGET_PENTIUM || TARGET_PENTIUMPRO)"
12053 "rol{q}\t%0"
12054 [(set_attr "type" "ishift")
12055 (set (attr "length")
12056 (if_then_else (match_operand:DI 0 "register_operand" "")
12057 (const_string "2")
12058 (const_string "*")))])
12059
12060 (define_insn "*rotldi3_1_rex64"
12061 [(set (match_operand:DI 0 "nonimmediate_operand" "=rm,rm")
12062 (rotate:DI (match_operand:DI 1 "nonimmediate_operand" "0,0")
12063 (match_operand:QI 2 "nonmemory_operand" "e,c")))
12064 (clobber (reg:CC 17))]
12065 "TARGET_64BIT && ix86_binary_operator_ok (ROTATE, DImode, operands)"
12066 "@
12067 rol{q}\t{%2, %0|%0, %2}
12068 rol{q}\t{%b2, %0|%0, %b2}"
12069 [(set_attr "type" "ishift")
12070 (set_attr "mode" "DI")])
12071
12072 (define_expand "rotlsi3"
12073 [(set (match_operand:SI 0 "nonimmediate_operand" "")
12074 (rotate:SI (match_operand:SI 1 "nonimmediate_operand" "")
12075 (match_operand:QI 2 "nonmemory_operand" "")))
12076 (clobber (reg:CC 17))]
12077 ""
12078 "ix86_expand_binary_operator (ROTATE, SImode, operands); DONE;")
12079
12080 (define_insn "*rotlsi3_1_one_bit"
12081 [(set (match_operand:SI 0 "nonimmediate_operand" "=rm")
12082 (rotate:SI (match_operand:SI 1 "nonimmediate_operand" "0")
12083 (match_operand:QI 2 "const_int_1_operand" "")))
12084 (clobber (reg:CC 17))]
12085 "ix86_binary_operator_ok (ROTATE, SImode, operands)
12086 && (TARGET_PENTIUM || TARGET_PENTIUMPRO)"
12087 "rol{l}\t%0"
12088 [(set_attr "type" "ishift")
12089 (set (attr "length")
12090 (if_then_else (match_operand:SI 0 "register_operand" "")
12091 (const_string "2")
12092 (const_string "*")))])
12093
12094 (define_insn "*rotlsi3_1_one_bit_zext"
12095 [(set (match_operand:DI 0 "register_operand" "=r")
12096 (zero_extend:DI
12097 (rotate:SI (match_operand:SI 1 "register_operand" "0")
12098 (match_operand:QI 2 "const_int_1_operand" ""))))
12099 (clobber (reg:CC 17))]
12100 "TARGET_64BIT && ix86_binary_operator_ok (ROTATE, SImode, operands)
12101 && (TARGET_PENTIUM || TARGET_PENTIUMPRO)"
12102 "rol{l}\t%k0"
12103 [(set_attr "type" "ishift")
12104 (set_attr "length" "2")])
12105
12106 (define_insn "*rotlsi3_1"
12107 [(set (match_operand:SI 0 "nonimmediate_operand" "=rm,rm")
12108 (rotate:SI (match_operand:SI 1 "nonimmediate_operand" "0,0")
12109 (match_operand:QI 2 "nonmemory_operand" "I,c")))
12110 (clobber (reg:CC 17))]
12111 "ix86_binary_operator_ok (ROTATE, SImode, operands)"
12112 "@
12113 rol{l}\t{%2, %0|%0, %2}
12114 rol{l}\t{%b2, %0|%0, %b2}"
12115 [(set_attr "type" "ishift")
12116 (set_attr "mode" "SI")])
12117
12118 (define_insn "*rotlsi3_1_zext"
12119 [(set (match_operand:DI 0 "register_operand" "=r,r")
12120 (zero_extend:DI
12121 (rotate:SI (match_operand:SI 1 "register_operand" "0,0")
12122 (match_operand:QI 2 "nonmemory_operand" "I,c"))))
12123 (clobber (reg:CC 17))]
12124 "TARGET_64BIT && ix86_binary_operator_ok (ROTATE, SImode, operands)"
12125 "@
12126 rol{l}\t{%2, %k0|%k0, %2}
12127 rol{l}\t{%b2, %k0|%k0, %b2}"
12128 [(set_attr "type" "ishift")
12129 (set_attr "mode" "SI")])
12130
12131 (define_expand "rotlhi3"
12132 [(set (match_operand:HI 0 "nonimmediate_operand" "")
12133 (rotate:HI (match_operand:HI 1 "nonimmediate_operand" "")
12134 (match_operand:QI 2 "nonmemory_operand" "")))
12135 (clobber (reg:CC 17))]
12136 "TARGET_HIMODE_MATH"
12137 "ix86_expand_binary_operator (ROTATE, HImode, operands); DONE;")
12138
12139 (define_insn "*rotlhi3_1_one_bit"
12140 [(set (match_operand:HI 0 "nonimmediate_operand" "=rm")
12141 (rotate:HI (match_operand:HI 1 "nonimmediate_operand" "0")
12142 (match_operand:QI 2 "const_int_1_operand" "")))
12143 (clobber (reg:CC 17))]
12144 "ix86_binary_operator_ok (ROTATE, HImode, operands)
12145 && (TARGET_PENTIUM || TARGET_PENTIUMPRO)"
12146 "rol{w}\t%0"
12147 [(set_attr "type" "ishift")
12148 (set (attr "length")
12149 (if_then_else (match_operand 0 "register_operand" "")
12150 (const_string "2")
12151 (const_string "*")))])
12152
12153 (define_insn "*rotlhi3_1"
12154 [(set (match_operand:HI 0 "nonimmediate_operand" "=rm,rm")
12155 (rotate:HI (match_operand:HI 1 "nonimmediate_operand" "0,0")
12156 (match_operand:QI 2 "nonmemory_operand" "I,c")))
12157 (clobber (reg:CC 17))]
12158 "ix86_binary_operator_ok (ROTATE, HImode, operands)"
12159 "@
12160 rol{w}\t{%2, %0|%0, %2}
12161 rol{w}\t{%b2, %0|%0, %b2}"
12162 [(set_attr "type" "ishift")
12163 (set_attr "mode" "HI")])
12164
12165 (define_expand "rotlqi3"
12166 [(set (match_operand:QI 0 "nonimmediate_operand" "")
12167 (rotate:QI (match_operand:QI 1 "nonimmediate_operand" "")
12168 (match_operand:QI 2 "nonmemory_operand" "")))
12169 (clobber (reg:CC 17))]
12170 "TARGET_QIMODE_MATH"
12171 "ix86_expand_binary_operator (ROTATE, QImode, operands); DONE;")
12172
12173 (define_insn "*rotlqi3_1_one_bit"
12174 [(set (match_operand:QI 0 "nonimmediate_operand" "=qm")
12175 (rotate:QI (match_operand:QI 1 "nonimmediate_operand" "0")
12176 (match_operand:QI 2 "const_int_1_operand" "")))
12177 (clobber (reg:CC 17))]
12178 "ix86_binary_operator_ok (ROTATE, QImode, operands)
12179 && (TARGET_PENTIUM || TARGET_PENTIUMPRO)"
12180 "rol{b}\t%0"
12181 [(set_attr "type" "ishift")
12182 (set (attr "length")
12183 (if_then_else (match_operand 0 "register_operand" "")
12184 (const_string "2")
12185 (const_string "*")))])
12186
12187 (define_insn "*rotlqi3_1"
12188 [(set (match_operand:QI 0 "nonimmediate_operand" "=qm,qm")
12189 (rotate:QI (match_operand:QI 1 "nonimmediate_operand" "0,0")
12190 (match_operand:QI 2 "nonmemory_operand" "I,c")))
12191 (clobber (reg:CC 17))]
12192 "ix86_binary_operator_ok (ROTATE, QImode, operands)"
12193 "@
12194 rol{b}\t{%2, %0|%0, %2}
12195 rol{b}\t{%b2, %0|%0, %b2}"
12196 [(set_attr "type" "ishift")
12197 (set_attr "mode" "QI")])
12198
12199 (define_expand "rotrdi3"
12200 [(set (match_operand:DI 0 "nonimmediate_operand" "")
12201 (rotatert:DI (match_operand:DI 1 "nonimmediate_operand" "")
12202 (match_operand:QI 2 "nonmemory_operand" "")))
12203 (clobber (reg:CC 17))]
12204 "TARGET_64BIT"
12205 "ix86_expand_binary_operator (ROTATERT, DImode, operands); DONE;")
12206
12207 (define_insn "*rotrdi3_1_one_bit_rex64"
12208 [(set (match_operand:DI 0 "nonimmediate_operand" "=rm")
12209 (rotatert:DI (match_operand:DI 1 "nonimmediate_operand" "0")
12210 (match_operand:QI 2 "const_int_1_operand" "")))
12211 (clobber (reg:CC 17))]
12212 "TARGET_64BIT && ix86_binary_operator_ok (ROTATERT, DImode, operands)
12213 && (TARGET_PENTIUM || TARGET_PENTIUMPRO)"
12214 "ror{q}\t%0"
12215 [(set_attr "type" "ishift")
12216 (set (attr "length")
12217 (if_then_else (match_operand:DI 0 "register_operand" "")
12218 (const_string "2")
12219 (const_string "*")))])
12220
12221 (define_insn "*rotrdi3_1_rex64"
12222 [(set (match_operand:DI 0 "nonimmediate_operand" "=rm,rm")
12223 (rotatert:DI (match_operand:DI 1 "nonimmediate_operand" "0,0")
12224 (match_operand:QI 2 "nonmemory_operand" "J,c")))
12225 (clobber (reg:CC 17))]
12226 "TARGET_64BIT && ix86_binary_operator_ok (ROTATERT, DImode, operands)"
12227 "@
12228 ror{q}\t{%2, %0|%0, %2}
12229 ror{q}\t{%b2, %0|%0, %b2}"
12230 [(set_attr "type" "ishift")
12231 (set_attr "mode" "DI")])
12232
12233 (define_expand "rotrsi3"
12234 [(set (match_operand:SI 0 "nonimmediate_operand" "")
12235 (rotatert:SI (match_operand:SI 1 "nonimmediate_operand" "")
12236 (match_operand:QI 2 "nonmemory_operand" "")))
12237 (clobber (reg:CC 17))]
12238 ""
12239 "ix86_expand_binary_operator (ROTATERT, SImode, operands); DONE;")
12240
12241 (define_insn "*rotrsi3_1_one_bit"
12242 [(set (match_operand:SI 0 "nonimmediate_operand" "=rm")
12243 (rotatert:SI (match_operand:SI 1 "nonimmediate_operand" "0")
12244 (match_operand:QI 2 "const_int_1_operand" "")))
12245 (clobber (reg:CC 17))]
12246 "ix86_binary_operator_ok (ROTATERT, SImode, operands)
12247 && (TARGET_PENTIUM || TARGET_PENTIUMPRO)"
12248 "ror{l}\t%0"
12249 [(set_attr "type" "ishift")
12250 (set (attr "length")
12251 (if_then_else (match_operand:SI 0 "register_operand" "")
12252 (const_string "2")
12253 (const_string "*")))])
12254
12255 (define_insn "*rotrsi3_1_one_bit_zext"
12256 [(set (match_operand:DI 0 "register_operand" "=r")
12257 (zero_extend:DI
12258 (rotatert:SI (match_operand:SI 1 "register_operand" "0")
12259 (match_operand:QI 2 "const_int_1_operand" ""))))
12260 (clobber (reg:CC 17))]
12261 "TARGET_64BIT && ix86_binary_operator_ok (ROTATERT, SImode, operands)
12262 && (TARGET_PENTIUM || TARGET_PENTIUMPRO)"
12263 "ror{l}\t%k0"
12264 [(set_attr "type" "ishift")
12265 (set (attr "length")
12266 (if_then_else (match_operand:SI 0 "register_operand" "")
12267 (const_string "2")
12268 (const_string "*")))])
12269
12270 (define_insn "*rotrsi3_1"
12271 [(set (match_operand:SI 0 "nonimmediate_operand" "=rm,rm")
12272 (rotatert:SI (match_operand:SI 1 "nonimmediate_operand" "0,0")
12273 (match_operand:QI 2 "nonmemory_operand" "I,c")))
12274 (clobber (reg:CC 17))]
12275 "ix86_binary_operator_ok (ROTATERT, SImode, operands)"
12276 "@
12277 ror{l}\t{%2, %0|%0, %2}
12278 ror{l}\t{%b2, %0|%0, %b2}"
12279 [(set_attr "type" "ishift")
12280 (set_attr "mode" "SI")])
12281
12282 (define_insn "*rotrsi3_1_zext"
12283 [(set (match_operand:DI 0 "register_operand" "=r,r")
12284 (zero_extend:DI
12285 (rotatert:SI (match_operand:SI 1 "register_operand" "0,0")
12286 (match_operand:QI 2 "nonmemory_operand" "I,c"))))
12287 (clobber (reg:CC 17))]
12288 "TARGET_64BIT && ix86_binary_operator_ok (ROTATERT, SImode, operands)"
12289 "@
12290 ror{l}\t{%2, %k0|%k0, %2}
12291 ror{l}\t{%b2, %k0|%k0, %b2}"
12292 [(set_attr "type" "ishift")
12293 (set_attr "mode" "SI")])
12294
12295 (define_expand "rotrhi3"
12296 [(set (match_operand:HI 0 "nonimmediate_operand" "")
12297 (rotatert:HI (match_operand:HI 1 "nonimmediate_operand" "")
12298 (match_operand:QI 2 "nonmemory_operand" "")))
12299 (clobber (reg:CC 17))]
12300 "TARGET_HIMODE_MATH"
12301 "ix86_expand_binary_operator (ROTATERT, HImode, operands); DONE;")
12302
12303 (define_insn "*rotrhi3_one_bit"
12304 [(set (match_operand:HI 0 "nonimmediate_operand" "=rm")
12305 (rotatert:HI (match_operand:HI 1 "nonimmediate_operand" "0")
12306 (match_operand:QI 2 "const_int_1_operand" "")))
12307 (clobber (reg:CC 17))]
12308 "ix86_binary_operator_ok (ROTATERT, HImode, operands)
12309 && (TARGET_PENTIUM || TARGET_PENTIUMPRO)"
12310 "ror{w}\t%0"
12311 [(set_attr "type" "ishift")
12312 (set (attr "length")
12313 (if_then_else (match_operand 0 "register_operand" "")
12314 (const_string "2")
12315 (const_string "*")))])
12316
12317 (define_insn "*rotrhi3"
12318 [(set (match_operand:HI 0 "nonimmediate_operand" "=rm,rm")
12319 (rotatert:HI (match_operand:HI 1 "nonimmediate_operand" "0,0")
12320 (match_operand:QI 2 "nonmemory_operand" "I,c")))
12321 (clobber (reg:CC 17))]
12322 "ix86_binary_operator_ok (ROTATERT, HImode, operands)"
12323 "@
12324 ror{w}\t{%2, %0|%0, %2}
12325 ror{w}\t{%b2, %0|%0, %b2}"
12326 [(set_attr "type" "ishift")
12327 (set_attr "mode" "HI")])
12328
12329 (define_expand "rotrqi3"
12330 [(set (match_operand:QI 0 "nonimmediate_operand" "")
12331 (rotatert:QI (match_operand:QI 1 "nonimmediate_operand" "")
12332 (match_operand:QI 2 "nonmemory_operand" "")))
12333 (clobber (reg:CC 17))]
12334 "TARGET_QIMODE_MATH"
12335 "ix86_expand_binary_operator (ROTATERT, QImode, operands); DONE;")
12336
12337 (define_insn "*rotrqi3_1_one_bit"
12338 [(set (match_operand:QI 0 "nonimmediate_operand" "=qm")
12339 (rotatert:QI (match_operand:QI 1 "nonimmediate_operand" "0")
12340 (match_operand:QI 2 "const_int_1_operand" "")))
12341 (clobber (reg:CC 17))]
12342 "ix86_binary_operator_ok (ROTATERT, QImode, operands)
12343 && (TARGET_PENTIUM || TARGET_PENTIUMPRO)"
12344 "ror{b}\t%0"
12345 [(set_attr "type" "ishift")
12346 (set (attr "length")
12347 (if_then_else (match_operand 0 "register_operand" "")
12348 (const_string "2")
12349 (const_string "*")))])
12350
12351 (define_insn "*rotrqi3_1"
12352 [(set (match_operand:QI 0 "nonimmediate_operand" "=qm,qm")
12353 (rotatert:QI (match_operand:QI 1 "nonimmediate_operand" "0,0")
12354 (match_operand:QI 2 "nonmemory_operand" "I,c")))
12355 (clobber (reg:CC 17))]
12356 "ix86_binary_operator_ok (ROTATERT, QImode, operands)"
12357 "@
12358 ror{b}\t{%2, %0|%0, %2}
12359 ror{b}\t{%b2, %0|%0, %b2}"
12360 [(set_attr "type" "ishift")
12361 (set_attr "mode" "QI")])
12362 \f
12363 ;; Bit set / bit test instructions
12364
12365 (define_expand "extv"
12366 [(set (match_operand:SI 0 "register_operand" "")
12367 (sign_extract:SI (match_operand:SI 1 "register_operand" "")
12368 (match_operand:SI 2 "immediate_operand" "")
12369 (match_operand:SI 3 "immediate_operand" "")))]
12370 ""
12371 {
12372 /* Handle extractions from %ah et al. */
12373 if (INTVAL (operands[2]) != 8 || INTVAL (operands[3]) != 8)
12374 FAIL;
12375
12376 /* From mips.md: extract_bit_field doesn't verify that our source
12377 matches the predicate, so check it again here. */
12378 if (! register_operand (operands[1], VOIDmode))
12379 FAIL;
12380 })
12381
12382 (define_expand "extzv"
12383 [(set (match_operand:SI 0 "register_operand" "")
12384 (zero_extract:SI (match_operand 1 "ext_register_operand" "")
12385 (match_operand:SI 2 "immediate_operand" "")
12386 (match_operand:SI 3 "immediate_operand" "")))]
12387 ""
12388 {
12389 /* Handle extractions from %ah et al. */
12390 if (INTVAL (operands[2]) != 8 || INTVAL (operands[3]) != 8)
12391 FAIL;
12392
12393 /* From mips.md: extract_bit_field doesn't verify that our source
12394 matches the predicate, so check it again here. */
12395 if (! register_operand (operands[1], VOIDmode))
12396 FAIL;
12397 })
12398
12399 (define_expand "insv"
12400 [(set (zero_extract:SI (match_operand 0 "ext_register_operand" "")
12401 (match_operand:SI 1 "immediate_operand" "")
12402 (match_operand:SI 2 "immediate_operand" ""))
12403 (match_operand:SI 3 "register_operand" ""))]
12404 ""
12405 {
12406 /* Handle extractions from %ah et al. */
12407 if (INTVAL (operands[1]) != 8 || INTVAL (operands[2]) != 8)
12408 FAIL;
12409
12410 /* From mips.md: insert_bit_field doesn't verify that our source
12411 matches the predicate, so check it again here. */
12412 if (! register_operand (operands[0], VOIDmode))
12413 FAIL;
12414 })
12415
12416 ;; %%% bts, btr, btc, bt.
12417 \f
12418 ;; Store-flag instructions.
12419
12420 ;; For all sCOND expanders, also expand the compare or test insn that
12421 ;; generates cc0. Generate an equality comparison if `seq' or `sne'.
12422
12423 ;; %%% Do the expansion to SImode. If PII, do things the xor+setcc way
12424 ;; to avoid partial register stalls. Otherwise do things the setcc+movzx
12425 ;; way, which can later delete the movzx if only QImode is needed.
12426
12427 (define_expand "seq"
12428 [(set (match_operand:QI 0 "register_operand" "")
12429 (eq:QI (reg:CC 17) (const_int 0)))]
12430 ""
12431 "if (ix86_expand_setcc (EQ, operands[0])) DONE; else FAIL;")
12432
12433 (define_expand "sne"
12434 [(set (match_operand:QI 0 "register_operand" "")
12435 (ne:QI (reg:CC 17) (const_int 0)))]
12436 ""
12437 "if (ix86_expand_setcc (NE, operands[0])) DONE; else FAIL;")
12438
12439 (define_expand "sgt"
12440 [(set (match_operand:QI 0 "register_operand" "")
12441 (gt:QI (reg:CC 17) (const_int 0)))]
12442 ""
12443 "if (ix86_expand_setcc (GT, operands[0])) DONE; else FAIL;")
12444
12445 (define_expand "sgtu"
12446 [(set (match_operand:QI 0 "register_operand" "")
12447 (gtu:QI (reg:CC 17) (const_int 0)))]
12448 ""
12449 "if (ix86_expand_setcc (GTU, operands[0])) DONE; else FAIL;")
12450
12451 (define_expand "slt"
12452 [(set (match_operand:QI 0 "register_operand" "")
12453 (lt:QI (reg:CC 17) (const_int 0)))]
12454 ""
12455 "if (ix86_expand_setcc (LT, operands[0])) DONE; else FAIL;")
12456
12457 (define_expand "sltu"
12458 [(set (match_operand:QI 0 "register_operand" "")
12459 (ltu:QI (reg:CC 17) (const_int 0)))]
12460 ""
12461 "if (ix86_expand_setcc (LTU, operands[0])) DONE; else FAIL;")
12462
12463 (define_expand "sge"
12464 [(set (match_operand:QI 0 "register_operand" "")
12465 (ge:QI (reg:CC 17) (const_int 0)))]
12466 ""
12467 "if (ix86_expand_setcc (GE, operands[0])) DONE; else FAIL;")
12468
12469 (define_expand "sgeu"
12470 [(set (match_operand:QI 0 "register_operand" "")
12471 (geu:QI (reg:CC 17) (const_int 0)))]
12472 ""
12473 "if (ix86_expand_setcc (GEU, operands[0])) DONE; else FAIL;")
12474
12475 (define_expand "sle"
12476 [(set (match_operand:QI 0 "register_operand" "")
12477 (le:QI (reg:CC 17) (const_int 0)))]
12478 ""
12479 "if (ix86_expand_setcc (LE, operands[0])) DONE; else FAIL;")
12480
12481 (define_expand "sleu"
12482 [(set (match_operand:QI 0 "register_operand" "")
12483 (leu:QI (reg:CC 17) (const_int 0)))]
12484 ""
12485 "if (ix86_expand_setcc (LEU, operands[0])) DONE; else FAIL;")
12486
12487 (define_expand "sunordered"
12488 [(set (match_operand:QI 0 "register_operand" "")
12489 (unordered:QI (reg:CC 17) (const_int 0)))]
12490 "TARGET_80387 || TARGET_SSE"
12491 "if (ix86_expand_setcc (UNORDERED, operands[0])) DONE; else FAIL;")
12492
12493 (define_expand "sordered"
12494 [(set (match_operand:QI 0 "register_operand" "")
12495 (ordered:QI (reg:CC 17) (const_int 0)))]
12496 "TARGET_80387"
12497 "if (ix86_expand_setcc (ORDERED, operands[0])) DONE; else FAIL;")
12498
12499 (define_expand "suneq"
12500 [(set (match_operand:QI 0 "register_operand" "")
12501 (uneq:QI (reg:CC 17) (const_int 0)))]
12502 "TARGET_80387 || TARGET_SSE"
12503 "if (ix86_expand_setcc (UNEQ, operands[0])) DONE; else FAIL;")
12504
12505 (define_expand "sunge"
12506 [(set (match_operand:QI 0 "register_operand" "")
12507 (unge:QI (reg:CC 17) (const_int 0)))]
12508 "TARGET_80387 || TARGET_SSE"
12509 "if (ix86_expand_setcc (UNGE, operands[0])) DONE; else FAIL;")
12510
12511 (define_expand "sungt"
12512 [(set (match_operand:QI 0 "register_operand" "")
12513 (ungt:QI (reg:CC 17) (const_int 0)))]
12514 "TARGET_80387 || TARGET_SSE"
12515 "if (ix86_expand_setcc (UNGT, operands[0])) DONE; else FAIL;")
12516
12517 (define_expand "sunle"
12518 [(set (match_operand:QI 0 "register_operand" "")
12519 (unle:QI (reg:CC 17) (const_int 0)))]
12520 "TARGET_80387 || TARGET_SSE"
12521 "if (ix86_expand_setcc (UNLE, operands[0])) DONE; else FAIL;")
12522
12523 (define_expand "sunlt"
12524 [(set (match_operand:QI 0 "register_operand" "")
12525 (unlt:QI (reg:CC 17) (const_int 0)))]
12526 "TARGET_80387 || TARGET_SSE"
12527 "if (ix86_expand_setcc (UNLT, operands[0])) DONE; else FAIL;")
12528
12529 (define_expand "sltgt"
12530 [(set (match_operand:QI 0 "register_operand" "")
12531 (ltgt:QI (reg:CC 17) (const_int 0)))]
12532 "TARGET_80387 || TARGET_SSE"
12533 "if (ix86_expand_setcc (LTGT, operands[0])) DONE; else FAIL;")
12534
12535 (define_insn "*setcc_1"
12536 [(set (match_operand:QI 0 "nonimmediate_operand" "=qm")
12537 (match_operator:QI 1 "ix86_comparison_operator"
12538 [(reg 17) (const_int 0)]))]
12539 ""
12540 "set%C1\t%0"
12541 [(set_attr "type" "setcc")
12542 (set_attr "mode" "QI")])
12543
12544 (define_insn "setcc_2"
12545 [(set (strict_low_part (match_operand:QI 0 "nonimmediate_operand" "+qm"))
12546 (match_operator:QI 1 "ix86_comparison_operator"
12547 [(reg 17) (const_int 0)]))]
12548 ""
12549 "set%C1\t%0"
12550 [(set_attr "type" "setcc")
12551 (set_attr "mode" "QI")])
12552
12553 ;; In general it is not safe to assume too much about CCmode registers,
12554 ;; so simplify-rtx stops when it sees a second one. Under certain
12555 ;; conditions this is safe on x86, so help combine not create
12556 ;;
12557 ;; seta %al
12558 ;; testb %al, %al
12559 ;; sete %al
12560
12561 (define_split
12562 [(set (match_operand:QI 0 "nonimmediate_operand" "")
12563 (ne:QI (match_operator 1 "ix86_comparison_operator"
12564 [(reg 17) (const_int 0)])
12565 (const_int 0)))]
12566 ""
12567 [(set (match_dup 0) (match_dup 1))]
12568 {
12569 PUT_MODE (operands[1], QImode);
12570 })
12571
12572 (define_split
12573 [(set (strict_low_part (match_operand:QI 0 "nonimmediate_operand" ""))
12574 (ne:QI (match_operator 1 "ix86_comparison_operator"
12575 [(reg 17) (const_int 0)])
12576 (const_int 0)))]
12577 ""
12578 [(set (match_dup 0) (match_dup 1))]
12579 {
12580 PUT_MODE (operands[1], QImode);
12581 })
12582
12583 (define_split
12584 [(set (match_operand:QI 0 "nonimmediate_operand" "")
12585 (eq:QI (match_operator 1 "ix86_comparison_operator"
12586 [(reg 17) (const_int 0)])
12587 (const_int 0)))]
12588 ""
12589 [(set (match_dup 0) (match_dup 1))]
12590 {
12591 rtx new_op1 = copy_rtx (operands[1]);
12592 operands[1] = new_op1;
12593 PUT_MODE (new_op1, QImode);
12594 PUT_CODE (new_op1, REVERSE_CONDITION (GET_CODE (new_op1),
12595 GET_MODE (XEXP (new_op1, 0))));
12596
12597 /* Make sure that (a) the CCmode we have for the flags is strong
12598 enough for the reversed compare or (b) we have a valid FP compare. */
12599 if (! ix86_comparison_operator (new_op1, VOIDmode))
12600 FAIL;
12601 })
12602
12603 (define_split
12604 [(set (strict_low_part (match_operand:QI 0 "nonimmediate_operand" ""))
12605 (eq:QI (match_operator 1 "ix86_comparison_operator"
12606 [(reg 17) (const_int 0)])
12607 (const_int 0)))]
12608 ""
12609 [(set (match_dup 0) (match_dup 1))]
12610 {
12611 rtx new_op1 = copy_rtx (operands[1]);
12612 operands[1] = new_op1;
12613 PUT_MODE (new_op1, QImode);
12614 PUT_CODE (new_op1, REVERSE_CONDITION (GET_CODE (new_op1),
12615 GET_MODE (XEXP (new_op1, 0))));
12616
12617 /* Make sure that (a) the CCmode we have for the flags is strong
12618 enough for the reversed compare or (b) we have a valid FP compare. */
12619 if (! ix86_comparison_operator (new_op1, VOIDmode))
12620 FAIL;
12621 })
12622
12623 ;; The SSE store flag instructions saves 0 or 0xffffffff to the result.
12624 ;; subsequent logical operations are used to imitate conditional moves.
12625 ;; 0xffffffff is NaN, but not in normalized form, so we can't represent
12626 ;; it directly. Futher holding this value in pseudo register might bring
12627 ;; problem in implicit normalization in spill code.
12628 ;; So we don't define FLOAT_STORE_FLAG_VALUE and create these
12629 ;; instructions after reload by splitting the conditional move patterns.
12630
12631 (define_insn "*sse_setccsf"
12632 [(set (match_operand:SF 0 "register_operand" "=x")
12633 (match_operator:SF 1 "sse_comparison_operator"
12634 [(match_operand:SF 2 "register_operand" "0")
12635 (match_operand:SF 3 "nonimmediate_operand" "xm")]))]
12636 "TARGET_SSE && reload_completed"
12637 "cmp%D1ss\t{%3, %0|%0, %3}"
12638 [(set_attr "type" "sse")
12639 (set_attr "mode" "SF")])
12640
12641 (define_insn "*sse_setccdf"
12642 [(set (match_operand:DF 0 "register_operand" "=Y")
12643 (match_operator:DF 1 "sse_comparison_operator"
12644 [(match_operand:DF 2 "register_operand" "0")
12645 (match_operand:DF 3 "nonimmediate_operand" "Ym")]))]
12646 "TARGET_SSE2 && reload_completed"
12647 "cmp%D1sd\t{%3, %0|%0, %3}"
12648 [(set_attr "type" "sse")
12649 (set_attr "mode" "DF")])
12650 \f
12651 ;; Basic conditional jump instructions.
12652 ;; We ignore the overflow flag for signed branch instructions.
12653
12654 ;; For all bCOND expanders, also expand the compare or test insn that
12655 ;; generates reg 17. Generate an equality comparison if `beq' or `bne'.
12656
12657 (define_expand "beq"
12658 [(set (pc)
12659 (if_then_else (match_dup 1)
12660 (label_ref (match_operand 0 "" ""))
12661 (pc)))]
12662 ""
12663 "ix86_expand_branch (EQ, operands[0]); DONE;")
12664
12665 (define_expand "bne"
12666 [(set (pc)
12667 (if_then_else (match_dup 1)
12668 (label_ref (match_operand 0 "" ""))
12669 (pc)))]
12670 ""
12671 "ix86_expand_branch (NE, operands[0]); DONE;")
12672
12673 (define_expand "bgt"
12674 [(set (pc)
12675 (if_then_else (match_dup 1)
12676 (label_ref (match_operand 0 "" ""))
12677 (pc)))]
12678 ""
12679 "ix86_expand_branch (GT, operands[0]); DONE;")
12680
12681 (define_expand "bgtu"
12682 [(set (pc)
12683 (if_then_else (match_dup 1)
12684 (label_ref (match_operand 0 "" ""))
12685 (pc)))]
12686 ""
12687 "ix86_expand_branch (GTU, operands[0]); DONE;")
12688
12689 (define_expand "blt"
12690 [(set (pc)
12691 (if_then_else (match_dup 1)
12692 (label_ref (match_operand 0 "" ""))
12693 (pc)))]
12694 ""
12695 "ix86_expand_branch (LT, operands[0]); DONE;")
12696
12697 (define_expand "bltu"
12698 [(set (pc)
12699 (if_then_else (match_dup 1)
12700 (label_ref (match_operand 0 "" ""))
12701 (pc)))]
12702 ""
12703 "ix86_expand_branch (LTU, operands[0]); DONE;")
12704
12705 (define_expand "bge"
12706 [(set (pc)
12707 (if_then_else (match_dup 1)
12708 (label_ref (match_operand 0 "" ""))
12709 (pc)))]
12710 ""
12711 "ix86_expand_branch (GE, operands[0]); DONE;")
12712
12713 (define_expand "bgeu"
12714 [(set (pc)
12715 (if_then_else (match_dup 1)
12716 (label_ref (match_operand 0 "" ""))
12717 (pc)))]
12718 ""
12719 "ix86_expand_branch (GEU, operands[0]); DONE;")
12720
12721 (define_expand "ble"
12722 [(set (pc)
12723 (if_then_else (match_dup 1)
12724 (label_ref (match_operand 0 "" ""))
12725 (pc)))]
12726 ""
12727 "ix86_expand_branch (LE, operands[0]); DONE;")
12728
12729 (define_expand "bleu"
12730 [(set (pc)
12731 (if_then_else (match_dup 1)
12732 (label_ref (match_operand 0 "" ""))
12733 (pc)))]
12734 ""
12735 "ix86_expand_branch (LEU, operands[0]); DONE;")
12736
12737 (define_expand "bunordered"
12738 [(set (pc)
12739 (if_then_else (match_dup 1)
12740 (label_ref (match_operand 0 "" ""))
12741 (pc)))]
12742 "TARGET_80387 || TARGET_SSE"
12743 "ix86_expand_branch (UNORDERED, operands[0]); DONE;")
12744
12745 (define_expand "bordered"
12746 [(set (pc)
12747 (if_then_else (match_dup 1)
12748 (label_ref (match_operand 0 "" ""))
12749 (pc)))]
12750 "TARGET_80387 || TARGET_SSE"
12751 "ix86_expand_branch (ORDERED, operands[0]); DONE;")
12752
12753 (define_expand "buneq"
12754 [(set (pc)
12755 (if_then_else (match_dup 1)
12756 (label_ref (match_operand 0 "" ""))
12757 (pc)))]
12758 "TARGET_80387 || TARGET_SSE"
12759 "ix86_expand_branch (UNEQ, operands[0]); DONE;")
12760
12761 (define_expand "bunge"
12762 [(set (pc)
12763 (if_then_else (match_dup 1)
12764 (label_ref (match_operand 0 "" ""))
12765 (pc)))]
12766 "TARGET_80387 || TARGET_SSE"
12767 "ix86_expand_branch (UNGE, operands[0]); DONE;")
12768
12769 (define_expand "bungt"
12770 [(set (pc)
12771 (if_then_else (match_dup 1)
12772 (label_ref (match_operand 0 "" ""))
12773 (pc)))]
12774 "TARGET_80387 || TARGET_SSE"
12775 "ix86_expand_branch (UNGT, operands[0]); DONE;")
12776
12777 (define_expand "bunle"
12778 [(set (pc)
12779 (if_then_else (match_dup 1)
12780 (label_ref (match_operand 0 "" ""))
12781 (pc)))]
12782 "TARGET_80387 || TARGET_SSE"
12783 "ix86_expand_branch (UNLE, operands[0]); DONE;")
12784
12785 (define_expand "bunlt"
12786 [(set (pc)
12787 (if_then_else (match_dup 1)
12788 (label_ref (match_operand 0 "" ""))
12789 (pc)))]
12790 "TARGET_80387 || TARGET_SSE"
12791 "ix86_expand_branch (UNLT, operands[0]); DONE;")
12792
12793 (define_expand "bltgt"
12794 [(set (pc)
12795 (if_then_else (match_dup 1)
12796 (label_ref (match_operand 0 "" ""))
12797 (pc)))]
12798 "TARGET_80387 || TARGET_SSE"
12799 "ix86_expand_branch (LTGT, operands[0]); DONE;")
12800
12801 (define_insn "*jcc_1"
12802 [(set (pc)
12803 (if_then_else (match_operator 1 "ix86_comparison_operator"
12804 [(reg 17) (const_int 0)])
12805 (label_ref (match_operand 0 "" ""))
12806 (pc)))]
12807 ""
12808 "%+j%C1\t%l0"
12809 [(set_attr "type" "ibr")
12810 (set (attr "prefix_0f")
12811 (if_then_else (and (ge (minus (match_dup 0) (pc))
12812 (const_int -128))
12813 (lt (minus (match_dup 0) (pc))
12814 (const_int 124)))
12815 (const_int 0)
12816 (const_int 1)))])
12817
12818 (define_insn "*jcc_2"
12819 [(set (pc)
12820 (if_then_else (match_operator 1 "ix86_comparison_operator"
12821 [(reg 17) (const_int 0)])
12822 (pc)
12823 (label_ref (match_operand 0 "" ""))))]
12824 ""
12825 "%+j%c1\t%l0"
12826 [(set_attr "type" "ibr")
12827 (set (attr "prefix_0f")
12828 (if_then_else (and (ge (minus (match_dup 0) (pc))
12829 (const_int -128))
12830 (lt (minus (match_dup 0) (pc))
12831 (const_int 124)))
12832 (const_int 0)
12833 (const_int 1)))])
12834
12835 ;; In general it is not safe to assume too much about CCmode registers,
12836 ;; so simplify-rtx stops when it sees a second one. Under certain
12837 ;; conditions this is safe on x86, so help combine not create
12838 ;;
12839 ;; seta %al
12840 ;; testb %al, %al
12841 ;; je Lfoo
12842
12843 (define_split
12844 [(set (pc)
12845 (if_then_else (ne (match_operator 0 "ix86_comparison_operator"
12846 [(reg 17) (const_int 0)])
12847 (const_int 0))
12848 (label_ref (match_operand 1 "" ""))
12849 (pc)))]
12850 ""
12851 [(set (pc)
12852 (if_then_else (match_dup 0)
12853 (label_ref (match_dup 1))
12854 (pc)))]
12855 {
12856 PUT_MODE (operands[0], VOIDmode);
12857 })
12858
12859 (define_split
12860 [(set (pc)
12861 (if_then_else (eq (match_operator 0 "ix86_comparison_operator"
12862 [(reg 17) (const_int 0)])
12863 (const_int 0))
12864 (label_ref (match_operand 1 "" ""))
12865 (pc)))]
12866 ""
12867 [(set (pc)
12868 (if_then_else (match_dup 0)
12869 (label_ref (match_dup 1))
12870 (pc)))]
12871 {
12872 rtx new_op0 = copy_rtx (operands[0]);
12873 operands[0] = new_op0;
12874 PUT_MODE (new_op0, VOIDmode);
12875 PUT_CODE (new_op0, REVERSE_CONDITION (GET_CODE (new_op0),
12876 GET_MODE (XEXP (new_op0, 0))));
12877
12878 /* Make sure that (a) the CCmode we have for the flags is strong
12879 enough for the reversed compare or (b) we have a valid FP compare. */
12880 if (! ix86_comparison_operator (new_op0, VOIDmode))
12881 FAIL;
12882 })
12883
12884 ;; Define combination compare-and-branch fp compare instructions to use
12885 ;; during early optimization. Splitting the operation apart early makes
12886 ;; for bad code when we want to reverse the operation.
12887
12888 (define_insn "*fp_jcc_1"
12889 [(set (pc)
12890 (if_then_else (match_operator 0 "comparison_operator"
12891 [(match_operand 1 "register_operand" "f")
12892 (match_operand 2 "register_operand" "f")])
12893 (label_ref (match_operand 3 "" ""))
12894 (pc)))
12895 (clobber (reg:CCFP 18))
12896 (clobber (reg:CCFP 17))]
12897 "TARGET_CMOVE && TARGET_80387
12898 && !SSE_FLOAT_MODE_P (GET_MODE (operands[1]))
12899 && FLOAT_MODE_P (GET_MODE (operands[1]))
12900 && GET_MODE (operands[1]) == GET_MODE (operands[2])
12901 && ix86_fp_jump_nontrivial_p (GET_CODE (operands[0]))"
12902 "#")
12903
12904 (define_insn "*fp_jcc_1_sse"
12905 [(set (pc)
12906 (if_then_else (match_operator 0 "comparison_operator"
12907 [(match_operand 1 "register_operand" "f#x,x#f")
12908 (match_operand 2 "nonimmediate_operand" "f#x,xm#f")])
12909 (label_ref (match_operand 3 "" ""))
12910 (pc)))
12911 (clobber (reg:CCFP 18))
12912 (clobber (reg:CCFP 17))]
12913 "TARGET_80387
12914 && SSE_FLOAT_MODE_P (GET_MODE (operands[1]))
12915 && GET_MODE (operands[1]) == GET_MODE (operands[2])
12916 && ix86_fp_jump_nontrivial_p (GET_CODE (operands[0]))"
12917 "#")
12918
12919 (define_insn "*fp_jcc_1_sse_only"
12920 [(set (pc)
12921 (if_then_else (match_operator 0 "comparison_operator"
12922 [(match_operand 1 "register_operand" "x")
12923 (match_operand 2 "nonimmediate_operand" "xm")])
12924 (label_ref (match_operand 3 "" ""))
12925 (pc)))
12926 (clobber (reg:CCFP 18))
12927 (clobber (reg:CCFP 17))]
12928 "SSE_FLOAT_MODE_P (GET_MODE (operands[1]))
12929 && GET_MODE (operands[1]) == GET_MODE (operands[2])
12930 && ix86_fp_jump_nontrivial_p (GET_CODE (operands[0]))"
12931 "#")
12932
12933 (define_insn "*fp_jcc_2"
12934 [(set (pc)
12935 (if_then_else (match_operator 0 "comparison_operator"
12936 [(match_operand 1 "register_operand" "f")
12937 (match_operand 2 "register_operand" "f")])
12938 (pc)
12939 (label_ref (match_operand 3 "" ""))))
12940 (clobber (reg:CCFP 18))
12941 (clobber (reg:CCFP 17))]
12942 "TARGET_CMOVE && TARGET_80387
12943 && !SSE_FLOAT_MODE_P (GET_MODE (operands[1]))
12944 && FLOAT_MODE_P (GET_MODE (operands[1]))
12945 && GET_MODE (operands[1]) == GET_MODE (operands[2])
12946 && ix86_fp_jump_nontrivial_p (GET_CODE (operands[0]))"
12947 "#")
12948
12949 (define_insn "*fp_jcc_2_sse"
12950 [(set (pc)
12951 (if_then_else (match_operator 0 "comparison_operator"
12952 [(match_operand 1 "register_operand" "f#x,x#f")
12953 (match_operand 2 "nonimmediate_operand" "f#x,xm#f")])
12954 (pc)
12955 (label_ref (match_operand 3 "" ""))))
12956 (clobber (reg:CCFP 18))
12957 (clobber (reg:CCFP 17))]
12958 "TARGET_80387
12959 && SSE_FLOAT_MODE_P (GET_MODE (operands[1]))
12960 && GET_MODE (operands[1]) == GET_MODE (operands[2])
12961 && ix86_fp_jump_nontrivial_p (GET_CODE (operands[0]))"
12962 "#")
12963
12964 (define_insn "*fp_jcc_2_sse_only"
12965 [(set (pc)
12966 (if_then_else (match_operator 0 "comparison_operator"
12967 [(match_operand 1 "register_operand" "x")
12968 (match_operand 2 "nonimmediate_operand" "xm")])
12969 (pc)
12970 (label_ref (match_operand 3 "" ""))))
12971 (clobber (reg:CCFP 18))
12972 (clobber (reg:CCFP 17))]
12973 "SSE_FLOAT_MODE_P (GET_MODE (operands[1]))
12974 && GET_MODE (operands[1]) == GET_MODE (operands[2])
12975 && ix86_fp_jump_nontrivial_p (GET_CODE (operands[0]))"
12976 "#")
12977
12978 (define_insn "*fp_jcc_3"
12979 [(set (pc)
12980 (if_then_else (match_operator 0 "comparison_operator"
12981 [(match_operand 1 "register_operand" "f")
12982 (match_operand 2 "nonimmediate_operand" "fm")])
12983 (label_ref (match_operand 3 "" ""))
12984 (pc)))
12985 (clobber (reg:CCFP 18))
12986 (clobber (reg:CCFP 17))
12987 (clobber (match_scratch:HI 4 "=a"))]
12988 "TARGET_80387
12989 && (GET_MODE (operands[1]) == SFmode || GET_MODE (operands[1]) == DFmode)
12990 && GET_MODE (operands[1]) == GET_MODE (operands[2])
12991 && !ix86_use_fcomi_compare (GET_CODE (operands[0]))
12992 && SELECT_CC_MODE (GET_CODE (operands[0]),
12993 operands[1], operands[2]) == CCFPmode
12994 && ix86_fp_jump_nontrivial_p (GET_CODE (operands[0]))"
12995 "#")
12996
12997 (define_insn "*fp_jcc_4"
12998 [(set (pc)
12999 (if_then_else (match_operator 0 "comparison_operator"
13000 [(match_operand 1 "register_operand" "f")
13001 (match_operand 2 "nonimmediate_operand" "fm")])
13002 (pc)
13003 (label_ref (match_operand 3 "" ""))))
13004 (clobber (reg:CCFP 18))
13005 (clobber (reg:CCFP 17))
13006 (clobber (match_scratch:HI 4 "=a"))]
13007 "TARGET_80387
13008 && (GET_MODE (operands[1]) == SFmode || GET_MODE (operands[1]) == DFmode)
13009 && GET_MODE (operands[1]) == GET_MODE (operands[2])
13010 && !ix86_use_fcomi_compare (GET_CODE (operands[0]))
13011 && SELECT_CC_MODE (GET_CODE (operands[0]),
13012 operands[1], operands[2]) == CCFPmode
13013 && ix86_fp_jump_nontrivial_p (GET_CODE (operands[0]))"
13014 "#")
13015
13016 (define_insn "*fp_jcc_5"
13017 [(set (pc)
13018 (if_then_else (match_operator 0 "comparison_operator"
13019 [(match_operand 1 "register_operand" "f")
13020 (match_operand 2 "register_operand" "f")])
13021 (label_ref (match_operand 3 "" ""))
13022 (pc)))
13023 (clobber (reg:CCFP 18))
13024 (clobber (reg:CCFP 17))
13025 (clobber (match_scratch:HI 4 "=a"))]
13026 "TARGET_80387
13027 && FLOAT_MODE_P (GET_MODE (operands[1]))
13028 && GET_MODE (operands[1]) == GET_MODE (operands[2])
13029 && ix86_fp_jump_nontrivial_p (GET_CODE (operands[0]))"
13030 "#")
13031
13032 (define_insn "*fp_jcc_6"
13033 [(set (pc)
13034 (if_then_else (match_operator 0 "comparison_operator"
13035 [(match_operand 1 "register_operand" "f")
13036 (match_operand 2 "register_operand" "f")])
13037 (pc)
13038 (label_ref (match_operand 3 "" ""))))
13039 (clobber (reg:CCFP 18))
13040 (clobber (reg:CCFP 17))
13041 (clobber (match_scratch:HI 4 "=a"))]
13042 "TARGET_80387
13043 && FLOAT_MODE_P (GET_MODE (operands[1]))
13044 && GET_MODE (operands[1]) == GET_MODE (operands[2])
13045 && ix86_fp_jump_nontrivial_p (GET_CODE (operands[0]))"
13046 "#")
13047
13048 (define_split
13049 [(set (pc)
13050 (if_then_else (match_operator 0 "comparison_operator"
13051 [(match_operand 1 "register_operand" "")
13052 (match_operand 2 "nonimmediate_operand" "")])
13053 (match_operand 3 "" "")
13054 (match_operand 4 "" "")))
13055 (clobber (reg:CCFP 18))
13056 (clobber (reg:CCFP 17))]
13057 "reload_completed"
13058 [(const_int 0)]
13059 {
13060 ix86_split_fp_branch (GET_CODE (operands[0]), operands[1], operands[2],
13061 operands[3], operands[4], NULL_RTX);
13062 DONE;
13063 })
13064
13065 (define_split
13066 [(set (pc)
13067 (if_then_else (match_operator 0 "comparison_operator"
13068 [(match_operand 1 "register_operand" "")
13069 (match_operand 2 "nonimmediate_operand" "")])
13070 (match_operand 3 "" "")
13071 (match_operand 4 "" "")))
13072 (clobber (reg:CCFP 18))
13073 (clobber (reg:CCFP 17))
13074 (clobber (match_scratch:HI 5 "=a"))]
13075 "reload_completed"
13076 [(set (pc)
13077 (if_then_else (match_dup 6)
13078 (match_dup 3)
13079 (match_dup 4)))]
13080 {
13081 ix86_split_fp_branch (GET_CODE (operands[0]), operands[1], operands[2],
13082 operands[3], operands[4], operands[5]);
13083 DONE;
13084 })
13085 \f
13086 ;; Unconditional and other jump instructions
13087
13088 (define_insn "jump"
13089 [(set (pc)
13090 (label_ref (match_operand 0 "" "")))]
13091 ""
13092 "jmp\t%l0"
13093 [(set_attr "type" "ibr")])
13094
13095 (define_expand "indirect_jump"
13096 [(set (pc) (match_operand 0 "nonimmediate_operand" "rm"))]
13097 ""
13098 "")
13099
13100 (define_insn "*indirect_jump"
13101 [(set (pc) (match_operand:SI 0 "nonimmediate_operand" "rm"))]
13102 "!TARGET_64BIT"
13103 "jmp\t%A0"
13104 [(set_attr "type" "ibr")
13105 (set_attr "length_immediate" "0")])
13106
13107 (define_insn "*indirect_jump_rtx64"
13108 [(set (pc) (match_operand:DI 0 "nonimmediate_operand" "rm"))]
13109 "TARGET_64BIT"
13110 "jmp\t%A0"
13111 [(set_attr "type" "ibr")
13112 (set_attr "length_immediate" "0")])
13113
13114 (define_expand "tablejump"
13115 [(parallel [(set (pc) (match_operand 0 "nonimmediate_operand" "rm"))
13116 (use (label_ref (match_operand 1 "" "")))])]
13117 ""
13118 {
13119 /* In PIC mode, the table entries are stored GOT-relative. Convert
13120 the relative address to an absolute address. */
13121 if (flag_pic)
13122 {
13123 if (TARGET_64BIT)
13124 operands[0] = expand_simple_binop (Pmode, PLUS, operands[0],
13125 gen_rtx_LABEL_REF (Pmode, operands[1]),
13126 NULL_RTX, 0,
13127 OPTAB_DIRECT);
13128 else if (HAVE_AS_GOTOFF_IN_DATA)
13129 {
13130 operands[0] = expand_simple_binop (Pmode, PLUS, operands[0],
13131 pic_offset_table_rtx, NULL_RTX,
13132 1, OPTAB_DIRECT);
13133 current_function_uses_pic_offset_table = 1;
13134 }
13135 else
13136 {
13137 operands[0] = expand_simple_binop (Pmode, MINUS, pic_offset_table_rtx,
13138 operands[0], NULL_RTX, 1,
13139 OPTAB_DIRECT);
13140 current_function_uses_pic_offset_table = 1;
13141 }
13142 }
13143 })
13144
13145 (define_insn "*tablejump_1"
13146 [(set (pc) (match_operand:SI 0 "nonimmediate_operand" "rm"))
13147 (use (label_ref (match_operand 1 "" "")))]
13148 "!TARGET_64BIT"
13149 "jmp\t%A0"
13150 [(set_attr "type" "ibr")
13151 (set_attr "length_immediate" "0")])
13152
13153 (define_insn "*tablejump_1_rtx64"
13154 [(set (pc) (match_operand:DI 0 "nonimmediate_operand" "rm"))
13155 (use (label_ref (match_operand 1 "" "")))]
13156 "TARGET_64BIT"
13157 "jmp\t%A0"
13158 [(set_attr "type" "ibr")
13159 (set_attr "length_immediate" "0")])
13160 \f
13161 ;; Loop instruction
13162 ;;
13163 ;; This is all complicated by the fact that since this is a jump insn
13164 ;; we must handle our own reloads.
13165
13166 (define_expand "doloop_end"
13167 [(use (match_operand 0 "" "")) ; loop pseudo
13168 (use (match_operand 1 "" "")) ; iterations; zero if unknown
13169 (use (match_operand 2 "" "")) ; max iterations
13170 (use (match_operand 3 "" "")) ; loop level
13171 (use (match_operand 4 "" ""))] ; label
13172 "!TARGET_64BIT && TARGET_USE_LOOP"
13173 "
13174 {
13175 /* Only use cloop on innermost loops. */
13176 if (INTVAL (operands[3]) > 1)
13177 FAIL;
13178 if (GET_MODE (operands[0]) != SImode)
13179 FAIL;
13180 emit_jump_insn (gen_doloop_end_internal (operands[4], operands[0],
13181 operands[0]));
13182 DONE;
13183 }")
13184
13185 (define_insn "doloop_end_internal"
13186 [(set (pc)
13187 (if_then_else (ne (match_operand:SI 1 "register_operand" "c,?*r,?*r")
13188 (const_int 1))
13189 (label_ref (match_operand 0 "" ""))
13190 (pc)))
13191 (set (match_operand:SI 2 "register_operand" "=1,1,*m*r")
13192 (plus:SI (match_dup 1)
13193 (const_int -1)))
13194 (clobber (match_scratch:SI 3 "=X,X,r"))
13195 (clobber (reg:CC 17))]
13196 "!TARGET_64BIT && TARGET_USE_LOOP"
13197 {
13198 if (which_alternative != 0)
13199 return "#";
13200 if (get_attr_length (insn) == 2)
13201 return "%+loop\t%l0";
13202 else
13203 return "dec{l}\t%1\;%+jne\t%l0";
13204 }
13205 [(set_attr "ppro_uops" "many")
13206 (set (attr "type")
13207 (if_then_else (and (eq_attr "alternative" "0")
13208 (and (ge (minus (match_dup 0) (pc))
13209 (const_int -128))
13210 (lt (minus (match_dup 0) (pc))
13211 (const_int 124))))
13212 (const_string "ibr")
13213 (const_string "multi")))])
13214
13215 (define_split
13216 [(set (pc)
13217 (if_then_else (ne (match_operand:SI 1 "register_operand" "")
13218 (const_int 1))
13219 (match_operand 0 "" "")
13220 (pc)))
13221 (set (match_dup 1)
13222 (plus:SI (match_dup 1)
13223 (const_int -1)))
13224 (clobber (match_scratch:SI 2 ""))
13225 (clobber (reg:CC 17))]
13226 "!TARGET_64BIT && TARGET_USE_LOOP
13227 && reload_completed
13228 && REGNO (operands[1]) != 2"
13229 [(parallel [(set (reg:CCZ 17)
13230 (compare:CCZ (plus:SI (match_dup 1) (const_int -1))
13231 (const_int 0)))
13232 (set (match_dup 1) (plus:SI (match_dup 1) (const_int -1)))])
13233 (set (pc) (if_then_else (ne (reg:CCZ 17) (const_int 0))
13234 (match_dup 0)
13235 (pc)))]
13236 "")
13237
13238 (define_split
13239 [(set (pc)
13240 (if_then_else (ne (match_operand:SI 1 "register_operand" "")
13241 (const_int 1))
13242 (match_operand 0 "" "")
13243 (pc)))
13244 (set (match_operand:SI 2 "nonimmediate_operand" "")
13245 (plus:SI (match_dup 1)
13246 (const_int -1)))
13247 (clobber (match_scratch:SI 3 ""))
13248 (clobber (reg:CC 17))]
13249 "!TARGET_64BIT && TARGET_USE_LOOP
13250 && reload_completed
13251 && (! REG_P (operands[2])
13252 || ! rtx_equal_p (operands[1], operands[2]))"
13253 [(set (match_dup 3) (match_dup 1))
13254 (parallel [(set (reg:CCZ 17)
13255 (compare:CCZ (plus:SI (match_dup 3) (const_int -1))
13256 (const_int 0)))
13257 (set (match_dup 3) (plus:SI (match_dup 3) (const_int -1)))])
13258 (set (match_dup 2) (match_dup 3))
13259 (set (pc) (if_then_else (ne (reg:CCZ 17) (const_int 0))
13260 (match_dup 0)
13261 (pc)))]
13262 "")
13263
13264 ;; Convert setcc + movzbl to xor + setcc if operands don't overlap.
13265
13266 (define_peephole2
13267 [(set (reg 17) (match_operand 0 "" ""))
13268 (set (match_operand:QI 1 "register_operand" "")
13269 (match_operator:QI 2 "ix86_comparison_operator"
13270 [(reg 17) (const_int 0)]))
13271 (set (match_operand 3 "q_regs_operand" "")
13272 (zero_extend (match_dup 1)))]
13273 "(peep2_reg_dead_p (3, operands[1])
13274 || operands_match_p (operands[1], operands[3]))
13275 && ! reg_overlap_mentioned_p (operands[3], operands[0])"
13276 [(set (match_dup 4) (match_dup 0))
13277 (set (strict_low_part (match_dup 5))
13278 (match_dup 2))]
13279 {
13280 operands[4] = gen_rtx_REG (GET_MODE (operands[0]), 17);
13281 operands[5] = gen_rtx_REG (QImode, REGNO (operands[3]));
13282 ix86_expand_clear (operands[3]);
13283 })
13284
13285 ;; Similar, but match zero_extendhisi2_and, which adds a clobber.
13286
13287 (define_peephole2
13288 [(set (reg 17) (match_operand 0 "" ""))
13289 (set (match_operand:QI 1 "register_operand" "")
13290 (match_operator:QI 2 "ix86_comparison_operator"
13291 [(reg 17) (const_int 0)]))
13292 (parallel [(set (match_operand 3 "q_regs_operand" "")
13293 (zero_extend (match_dup 1)))
13294 (clobber (reg:CC 17))])]
13295 "(peep2_reg_dead_p (3, operands[1])
13296 || operands_match_p (operands[1], operands[3]))
13297 && ! reg_overlap_mentioned_p (operands[3], operands[0])"
13298 [(set (match_dup 4) (match_dup 0))
13299 (set (strict_low_part (match_dup 5))
13300 (match_dup 2))]
13301 {
13302 operands[4] = gen_rtx_REG (GET_MODE (operands[0]), 17);
13303 operands[5] = gen_rtx_REG (QImode, REGNO (operands[3]));
13304 ix86_expand_clear (operands[3]);
13305 })
13306 \f
13307 ;; Call instructions.
13308
13309 ;; The predicates normally associated with named expanders are not properly
13310 ;; checked for calls. This is a bug in the generic code, but it isn't that
13311 ;; easy to fix. Ignore it for now and be prepared to fix things up.
13312
13313 ;; Call subroutine returning no value.
13314
13315 (define_expand "call_pop"
13316 [(parallel [(call (match_operand:QI 0 "" "")
13317 (match_operand:SI 1 "" ""))
13318 (set (reg:SI 7)
13319 (plus:SI (reg:SI 7)
13320 (match_operand:SI 3 "" "")))])]
13321 "!TARGET_64BIT"
13322 {
13323 if (operands[3] == const0_rtx)
13324 {
13325 emit_insn (gen_call (operands[0], operands[1], constm1_rtx));
13326 DONE;
13327 }
13328 /* Static functions and indirect calls don't need
13329 current_function_uses_pic_offset_table. */
13330 if (flag_pic
13331 && GET_CODE (XEXP (operands[0], 0)) == SYMBOL_REF
13332 && ! SYMBOL_REF_FLAG (XEXP (operands[0], 0)))
13333 current_function_uses_pic_offset_table = 1;
13334 if (! call_insn_operand (XEXP (operands[0], 0), Pmode))
13335 XEXP (operands[0], 0) = copy_to_mode_reg (Pmode, XEXP (operands[0], 0));
13336 if (TARGET_64BIT)
13337 abort();
13338 })
13339
13340 (define_insn "*call_pop_0"
13341 [(call (mem:QI (match_operand:SI 0 "constant_call_address_operand" ""))
13342 (match_operand:SI 1 "" ""))
13343 (set (reg:SI 7) (plus:SI (reg:SI 7)
13344 (match_operand:SI 2 "immediate_operand" "")))]
13345 "!TARGET_64BIT"
13346 {
13347 if (SIBLING_CALL_P (insn))
13348 return "jmp\t%P0";
13349 else
13350 return "call\t%P0";
13351 }
13352 [(set_attr "type" "call")])
13353
13354 (define_insn "*call_pop_1"
13355 [(call (mem:QI (match_operand:SI 0 "call_insn_operand" "rsm"))
13356 (match_operand:SI 1 "" ""))
13357 (set (reg:SI 7) (plus:SI (reg:SI 7)
13358 (match_operand:SI 2 "immediate_operand" "i")))]
13359 "!TARGET_64BIT"
13360 {
13361 if (constant_call_address_operand (operands[0], Pmode))
13362 {
13363 if (SIBLING_CALL_P (insn))
13364 return "jmp\t%P0";
13365 else
13366 return "call\t%P0";
13367 }
13368 if (SIBLING_CALL_P (insn))
13369 return "jmp\t%A0";
13370 else
13371 return "call\t%A0";
13372 }
13373 [(set_attr "type" "call")])
13374
13375 (define_expand "call"
13376 [(call (match_operand:QI 0 "" "")
13377 (match_operand 1 "" ""))
13378 (use (match_operand 2 "" ""))]
13379 ;; Operand 1 not used on the i386.
13380 ""
13381 {
13382 rtx insn;
13383 /* Static functions and indirect calls don't need
13384 current_function_uses_pic_offset_table. */
13385 if (flag_pic
13386 && GET_CODE (XEXP (operands[0], 0)) == SYMBOL_REF
13387 && ! SYMBOL_REF_FLAG (XEXP (operands[0], 0)))
13388 current_function_uses_pic_offset_table = 1;
13389
13390 if (! call_insn_operand (XEXP (operands[0], 0), Pmode))
13391 XEXP (operands[0], 0) = copy_to_mode_reg (Pmode, XEXP (operands[0], 0));
13392 if (TARGET_64BIT && INTVAL (operands[2]) >= 0)
13393 {
13394 rtx reg = gen_rtx_REG (QImode, 0);
13395 emit_move_insn (reg, operands[2]);
13396 insn = emit_call_insn (gen_call_exp (operands[0], operands[1]));
13397 use_reg (&CALL_INSN_FUNCTION_USAGE (insn), reg);
13398 DONE;
13399 }
13400 insn = emit_call_insn (gen_call_exp (operands[0], operands[1]));
13401 DONE;
13402 })
13403
13404 (define_expand "call_exp"
13405 [(call (match_operand:QI 0 "" "")
13406 (match_operand 1 "" ""))]
13407 ""
13408 "")
13409
13410 (define_insn "*call_0"
13411 [(call (mem:QI (match_operand 0 "constant_call_address_operand" ""))
13412 (match_operand 1 "" ""))]
13413 ""
13414 {
13415 if (SIBLING_CALL_P (insn))
13416 return "jmp\t%P0";
13417 else
13418 return "call\t%P0";
13419 }
13420 [(set_attr "type" "call")])
13421
13422 (define_insn "*call_1"
13423 [(call (mem:QI (match_operand:SI 0 "call_insn_operand" "rsm"))
13424 (match_operand 1 "" ""))]
13425 "!TARGET_64BIT"
13426 {
13427 if (constant_call_address_operand (operands[0], QImode))
13428 {
13429 if (SIBLING_CALL_P (insn))
13430 return "jmp\t%P0";
13431 else
13432 return "call\t%P0";
13433 }
13434 if (SIBLING_CALL_P (insn))
13435 return "jmp\t%A0";
13436 else
13437 return "call\t%A0";
13438 }
13439 [(set_attr "type" "call")])
13440
13441 (define_insn "*call_1_rex64"
13442 [(call (mem:QI (match_operand:DI 0 "call_insn_operand" "rsm"))
13443 (match_operand 1 "" ""))]
13444 "TARGET_64BIT"
13445 {
13446 if (constant_call_address_operand (operands[0], QImode))
13447 {
13448 if (SIBLING_CALL_P (insn))
13449 return "jmp\t%P0";
13450 else
13451 return "call\t%P0";
13452 }
13453 if (SIBLING_CALL_P (insn))
13454 return "jmp\t%A0";
13455 else
13456 return "call\t%A0";
13457 }
13458 [(set_attr "type" "call")])
13459
13460 ;; Call subroutine, returning value in operand 0
13461 ;; (which must be a hard register).
13462
13463 (define_expand "call_value_pop"
13464 [(parallel [(set (match_operand 0 "" "")
13465 (call (match_operand:QI 1 "" "")
13466 (match_operand:SI 2 "" "")))
13467 (set (reg:SI 7)
13468 (plus:SI (reg:SI 7)
13469 (match_operand:SI 4 "" "")))])]
13470 "!TARGET_64BIT"
13471 {
13472 if (operands[4] == const0_rtx)
13473 {
13474 emit_insn (gen_call_value (operands[0], operands[1], operands[2],
13475 constm1_rtx));
13476 DONE;
13477 }
13478 /* Static functions and indirect calls don't need
13479 current_function_uses_pic_offset_table. */
13480 if (flag_pic
13481 && GET_CODE (XEXP (operands[1], 0)) == SYMBOL_REF
13482 && ! SYMBOL_REF_FLAG (XEXP (operands[1], 0)))
13483 current_function_uses_pic_offset_table = 1;
13484 if (! call_insn_operand (XEXP (operands[1], 0), Pmode))
13485 XEXP (operands[1], 0) = copy_to_mode_reg (Pmode, XEXP (operands[1], 0));
13486 })
13487
13488 (define_expand "call_value"
13489 [(set (match_operand 0 "" "")
13490 (call (match_operand:QI 1 "" "")
13491 (match_operand:SI 2 "" "")))
13492 (use (match_operand:SI 3 "" ""))]
13493 ;; Operand 2 not used on the i386.
13494 ""
13495 {
13496 rtx insn;
13497 /* Static functions and indirect calls don't need
13498 current_function_uses_pic_offset_table. */
13499 if (flag_pic
13500 && GET_CODE (XEXP (operands[1], 0)) == SYMBOL_REF
13501 && ! SYMBOL_REF_FLAG (XEXP (operands[1], 0)))
13502 current_function_uses_pic_offset_table = 1;
13503 if (! call_insn_operand (XEXP (operands[1], 0), Pmode))
13504 XEXP (operands[1], 0) = copy_to_mode_reg (Pmode, XEXP (operands[1], 0));
13505 if (TARGET_64BIT && INTVAL (operands[3]) >= 0)
13506 {
13507 rtx reg = gen_rtx_REG (QImode, 0);
13508 emit_move_insn (reg, operands[3]);
13509 insn = emit_call_insn (gen_call_value_exp (operands[0], operands[1],
13510 operands[2]));
13511 use_reg (&CALL_INSN_FUNCTION_USAGE (insn), reg);
13512 DONE;
13513 }
13514 insn = emit_call_insn (gen_call_value_exp (operands[0], operands[1],
13515 operands[2]));
13516 DONE;
13517 })
13518
13519 (define_expand "call_value_exp"
13520 [(set (match_operand 0 "" "")
13521 (call (match_operand:QI 1 "" "")
13522 (match_operand:SI 2 "" "")))]
13523 ""
13524 "")
13525
13526 ;; Call subroutine returning any type.
13527
13528 (define_expand "untyped_call"
13529 [(parallel [(call (match_operand 0 "" "")
13530 (const_int 0))
13531 (match_operand 1 "" "")
13532 (match_operand 2 "" "")])]
13533 ""
13534 {
13535 int i;
13536
13537 /* In order to give reg-stack an easier job in validating two
13538 coprocessor registers as containing a possible return value,
13539 simply pretend the untyped call returns a complex long double
13540 value. */
13541
13542 emit_call_insn (TARGET_80387
13543 ? gen_call_value (gen_rtx_REG (XCmode, FIRST_FLOAT_REG),
13544 operands[0], const0_rtx,
13545 GEN_INT (SSE_REGPARM_MAX - 1))
13546 : gen_call (operands[0], const0_rtx,
13547 GEN_INT (SSE_REGPARM_MAX - 1)));
13548
13549 for (i = 0; i < XVECLEN (operands[2], 0); i++)
13550 {
13551 rtx set = XVECEXP (operands[2], 0, i);
13552 emit_move_insn (SET_DEST (set), SET_SRC (set));
13553 }
13554
13555 /* The optimizer does not know that the call sets the function value
13556 registers we stored in the result block. We avoid problems by
13557 claiming that all hard registers are used and clobbered at this
13558 point. */
13559 emit_insn (gen_blockage ());
13560
13561 DONE;
13562 })
13563 \f
13564 ;; Prologue and epilogue instructions
13565
13566 ;; UNSPEC_VOLATILE is considered to use and clobber all hard registers and
13567 ;; all of memory. This blocks insns from being moved across this point.
13568
13569 (define_insn "blockage"
13570 [(unspec_volatile [(const_int 0)] 0)]
13571 ""
13572 ""
13573 [(set_attr "length" "0")])
13574
13575 ;; Insn emitted into the body of a function to return from a function.
13576 ;; This is only done if the function's epilogue is known to be simple.
13577 ;; See comments for ix86_can_use_return_insn_p in i386.c.
13578
13579 (define_expand "return"
13580 [(return)]
13581 "ix86_can_use_return_insn_p ()"
13582 {
13583 if (current_function_pops_args)
13584 {
13585 rtx popc = GEN_INT (current_function_pops_args);
13586 emit_jump_insn (gen_return_pop_internal (popc));
13587 DONE;
13588 }
13589 })
13590
13591 (define_insn "return_internal"
13592 [(return)]
13593 "reload_completed"
13594 "ret"
13595 [(set_attr "length" "1")
13596 (set_attr "length_immediate" "0")
13597 (set_attr "modrm" "0")])
13598
13599 (define_insn "return_pop_internal"
13600 [(return)
13601 (use (match_operand:SI 0 "const_int_operand" ""))]
13602 "reload_completed"
13603 "ret\t%0"
13604 [(set_attr "length" "3")
13605 (set_attr "length_immediate" "2")
13606 (set_attr "modrm" "0")])
13607
13608 (define_insn "return_indirect_internal"
13609 [(return)
13610 (use (match_operand:SI 0 "register_operand" "r"))]
13611 "reload_completed"
13612 "jmp\t%A0"
13613 [(set_attr "type" "ibr")
13614 (set_attr "length_immediate" "0")])
13615
13616 (define_insn "nop"
13617 [(const_int 0)]
13618 ""
13619 "nop"
13620 [(set_attr "length" "1")
13621 (set_attr "length_immediate" "0")
13622 (set_attr "modrm" "0")
13623 (set_attr "ppro_uops" "one")])
13624
13625 (define_expand "prologue"
13626 [(const_int 1)]
13627 ""
13628 "ix86_expand_prologue (); DONE;")
13629
13630 (define_insn "prologue_set_got"
13631 [(set (match_operand:SI 0 "register_operand" "=r")
13632 (unspec_volatile:SI
13633 [(plus:SI (match_dup 0)
13634 (plus:SI (match_operand:SI 1 "symbolic_operand" "")
13635 (minus:SI (pc) (match_operand 2 "" ""))))] 1))
13636 (clobber (reg:CC 17))]
13637 "!TARGET_64BIT"
13638 {
13639 if (GET_CODE (operands[2]) == LABEL_REF)
13640 operands[2] = XEXP (operands[2], 0);
13641 if (TARGET_DEEP_BRANCH_PREDICTION)
13642 return "add{l}\t{%1, %0|%0, %1}";
13643 else
13644 return "add{l}\t{%1+[.-%X2], %0|%0, %a1+(.-%X2)}";
13645 }
13646 [(set_attr "type" "alu")
13647 ; Since this insn may have two constant operands, we must set the
13648 ; length manually.
13649 (set_attr "length_immediate" "4")
13650 (set_attr "mode" "SI")])
13651
13652 (define_insn "prologue_get_pc"
13653 [(set (match_operand:SI 0 "register_operand" "=r")
13654 (unspec_volatile:SI [(plus:SI (pc) (match_operand 1 "" ""))] 2))]
13655 "!TARGET_64BIT"
13656 {
13657 if (GET_CODE (operands[1]) == LABEL_REF)
13658 operands[1] = XEXP (operands[1], 0);
13659 output_asm_insn ("call\t%X1", operands);
13660 if (! TARGET_DEEP_BRANCH_PREDICTION)
13661 {
13662 ASM_OUTPUT_INTERNAL_LABEL (asm_out_file, "L",
13663 CODE_LABEL_NUMBER (operands[1]));
13664 }
13665 RET;
13666 }
13667 [(set_attr "type" "multi")])
13668
13669 (define_expand "epilogue"
13670 [(const_int 1)]
13671 ""
13672 "ix86_expand_epilogue (1); DONE;")
13673
13674 (define_expand "sibcall_epilogue"
13675 [(const_int 1)]
13676 ""
13677 "ix86_expand_epilogue (0); DONE;")
13678
13679 (define_expand "eh_return"
13680 [(use (match_operand 0 "register_operand" ""))
13681 (use (match_operand 1 "register_operand" ""))]
13682 ""
13683 {
13684 rtx tmp, sa = operands[0], ra = operands[1];
13685
13686 /* Tricky bit: we write the address of the handler to which we will
13687 be returning into someone else's stack frame, one word below the
13688 stack address we wish to restore. */
13689 tmp = gen_rtx_PLUS (Pmode, arg_pointer_rtx, sa);
13690 tmp = plus_constant (tmp, -UNITS_PER_WORD);
13691 tmp = gen_rtx_MEM (Pmode, tmp);
13692 emit_move_insn (tmp, ra);
13693
13694 if (Pmode == SImode)
13695 emit_insn (gen_eh_return_si (sa));
13696 else
13697 emit_insn (gen_eh_return_di (sa));
13698 emit_barrier ();
13699 DONE;
13700 })
13701
13702 (define_insn_and_split "eh_return_si"
13703 [(unspec_volatile [(match_operand:SI 0 "register_operand" "c")] 13)]
13704 "!TARGET_64BIT"
13705 "#"
13706 "reload_completed"
13707 [(const_int 1)]
13708 "ix86_expand_epilogue (2); DONE;")
13709
13710 (define_insn_and_split "eh_return_di"
13711 [(unspec_volatile [(match_operand:DI 0 "register_operand" "c")] 13)]
13712 "TARGET_64BIT"
13713 "#"
13714 "reload_completed"
13715 [(const_int 1)]
13716 "ix86_expand_epilogue (2); DONE;")
13717
13718 (define_insn "leave"
13719 [(set (reg:SI 7) (plus:SI (reg:SI 6) (const_int 4)))
13720 (set (reg:SI 6) (mem:SI (reg:SI 6)))
13721 (clobber (mem:BLK (scratch)))]
13722 "!TARGET_64BIT"
13723 "leave"
13724 [(set_attr "length_immediate" "0")
13725 (set_attr "length" "1")
13726 (set_attr "modrm" "0")
13727 (set_attr "modrm" "0")
13728 (set_attr "athlon_decode" "vector")
13729 (set_attr "ppro_uops" "few")])
13730
13731 (define_insn "leave_rex64"
13732 [(set (reg:DI 7) (plus:DI (reg:DI 6) (const_int 8)))
13733 (set (reg:DI 6) (mem:DI (reg:DI 6)))
13734 (clobber (mem:BLK (scratch)))]
13735 "TARGET_64BIT"
13736 "leave"
13737 [(set_attr "length_immediate" "0")
13738 (set_attr "length" "1")
13739 (set_attr "modrm" "0")
13740 (set_attr "modrm" "0")
13741 (set_attr "athlon_decode" "vector")
13742 (set_attr "ppro_uops" "few")])
13743 \f
13744 (define_expand "ffssi2"
13745 [(set (match_operand:SI 0 "nonimmediate_operand" "")
13746 (ffs:SI (match_operand:SI 1 "general_operand" "")))]
13747 ""
13748 {
13749 rtx out = gen_reg_rtx (SImode), tmp = gen_reg_rtx (SImode);
13750 rtx in = operands[1];
13751
13752 if (TARGET_CMOVE)
13753 {
13754 emit_move_insn (tmp, constm1_rtx);
13755 emit_insn (gen_ffssi_1 (out, in));
13756 emit_insn (gen_rtx_SET (VOIDmode, out,
13757 gen_rtx_IF_THEN_ELSE (SImode,
13758 gen_rtx_EQ (VOIDmode, gen_rtx_REG (CCZmode, FLAGS_REG),
13759 const0_rtx),
13760 tmp,
13761 out)));
13762 emit_insn (gen_addsi3 (out, out, const1_rtx));
13763 emit_move_insn (operands[0], out);
13764 }
13765
13766 /* Pentium bsf instruction is extremly slow. The following code is
13767 recommended by the Intel Optimizing Manual as a reasonable replacement:
13768 TEST EAX,EAX
13769 JZ SHORT BS2
13770 XOR ECX,ECX
13771 MOV DWORD PTR [TEMP+4],ECX
13772 SUB ECX,EAX
13773 AND EAX,ECX
13774 MOV DWORD PTR [TEMP],EAX
13775 FILD QWORD PTR [TEMP]
13776 FSTP QWORD PTR [TEMP]
13777 WAIT ; WAIT only needed for compatibility with
13778 ; earlier processors
13779 MOV ECX, DWORD PTR [TEMP+4]
13780 SHR ECX,20
13781 SUB ECX,3FFH
13782 TEST EAX,EAX ; clear zero flag
13783 BS2:
13784 Following piece of code expand ffs to similar beast.
13785 */
13786
13787 else if (TARGET_PENTIUM && !optimize_size && TARGET_80387)
13788 {
13789 rtx label = gen_label_rtx ();
13790 rtx lo, hi;
13791 rtx mem = assign_386_stack_local (DImode, 0);
13792 rtx fptmp = gen_reg_rtx (DFmode);
13793 split_di (&mem, 1, &lo, &hi);
13794
13795 emit_move_insn (out, const0_rtx);
13796
13797 emit_cmp_and_jump_insns (in, const0_rtx, EQ, 0, SImode, 1, label);
13798
13799 emit_move_insn (hi, out);
13800 emit_insn (gen_subsi3 (out, out, in));
13801 emit_insn (gen_andsi3 (out, out, in));
13802 emit_move_insn (lo, out);
13803 emit_insn (gen_floatdidf2 (fptmp,mem));
13804 emit_move_insn (gen_rtx_MEM (DFmode, XEXP (mem, 0)), fptmp);
13805 emit_move_insn (out, hi);
13806 emit_insn (gen_lshrsi3 (out, out, GEN_INT (20)));
13807 emit_insn (gen_subsi3 (out, out, GEN_INT (0x3ff - 1)));
13808
13809 emit_label (label);
13810 LABEL_NUSES (label) = 1;
13811
13812 emit_move_insn (operands[0], out);
13813 }
13814 else
13815 {
13816 emit_move_insn (tmp, const0_rtx);
13817 emit_insn (gen_ffssi_1 (out, in));
13818 emit_insn (gen_rtx_SET (VOIDmode,
13819 gen_rtx_STRICT_LOW_PART (VOIDmode, gen_lowpart (QImode, tmp)),
13820 gen_rtx_EQ (QImode, gen_rtx_REG (CCZmode, FLAGS_REG),
13821 const0_rtx)));
13822 emit_insn (gen_negsi2 (tmp, tmp));
13823 emit_insn (gen_iorsi3 (out, out, tmp));
13824 emit_insn (gen_addsi3 (out, out, const1_rtx));
13825 emit_move_insn (operands[0], out);
13826 }
13827 DONE;
13828 })
13829
13830 (define_insn "ffssi_1"
13831 [(set (reg:CCZ 17)
13832 (compare:CCZ (match_operand:SI 1 "nonimmediate_operand" "rm")
13833 (const_int 0)))
13834 (set (match_operand:SI 0 "register_operand" "=r")
13835 (unspec:SI [(match_dup 1)] 5))]
13836 ""
13837 "bsf{l}\t{%1, %0|%0, %1}"
13838 [(set_attr "prefix_0f" "1")
13839 (set_attr "ppro_uops" "few")])
13840
13841 ;; ffshi2 is not useful -- 4 word prefix ops are needed, which is larger
13842 ;; and slower than the two-byte movzx insn needed to do the work in SImode.
13843 \f
13844 ;; These patterns match the binary 387 instructions for addM3, subM3,
13845 ;; mulM3 and divM3. There are three patterns for each of DFmode and
13846 ;; SFmode. The first is the normal insn, the second the same insn but
13847 ;; with one operand a conversion, and the third the same insn but with
13848 ;; the other operand a conversion. The conversion may be SFmode or
13849 ;; SImode if the target mode DFmode, but only SImode if the target mode
13850 ;; is SFmode.
13851
13852 ;; Gcc is slightly more smart about handling normal two address instructions
13853 ;; so use special patterns for add and mull.
13854 (define_insn "*fop_sf_comm_nosse"
13855 [(set (match_operand:SF 0 "register_operand" "=f")
13856 (match_operator:SF 3 "binary_fp_operator"
13857 [(match_operand:SF 1 "register_operand" "%0")
13858 (match_operand:SF 2 "nonimmediate_operand" "fm")]))]
13859 "TARGET_80387 && !TARGET_SSE_MATH
13860 && GET_RTX_CLASS (GET_CODE (operands[3])) == 'c'"
13861 "* return output_387_binary_op (insn, operands);"
13862 [(set (attr "type")
13863 (if_then_else (match_operand:SF 3 "mult_operator" "")
13864 (const_string "fmul")
13865 (const_string "fop")))
13866 (set_attr "mode" "SF")])
13867
13868 (define_insn "*fop_sf_comm"
13869 [(set (match_operand:SF 0 "register_operand" "=f#x,x#f")
13870 (match_operator:SF 3 "binary_fp_operator"
13871 [(match_operand:SF 1 "register_operand" "%0,0")
13872 (match_operand:SF 2 "nonimmediate_operand" "fm#x,xm#f")]))]
13873 "TARGET_80387 && TARGET_SSE_MATH && TARGET_MIX_SSE_I387
13874 && GET_RTX_CLASS (GET_CODE (operands[3])) == 'c'"
13875 "* return output_387_binary_op (insn, operands);"
13876 [(set (attr "type")
13877 (if_then_else (eq_attr "alternative" "1")
13878 (const_string "sse")
13879 (if_then_else (match_operand:SF 3 "mult_operator" "")
13880 (const_string "fmul")
13881 (const_string "fop"))))
13882 (set_attr "mode" "SF")])
13883
13884 (define_insn "*fop_sf_comm_sse"
13885 [(set (match_operand:SF 0 "register_operand" "=x")
13886 (match_operator:SF 3 "binary_fp_operator"
13887 [(match_operand:SF 1 "register_operand" "%0")
13888 (match_operand:SF 2 "nonimmediate_operand" "xm")]))]
13889 "TARGET_SSE_MATH && GET_RTX_CLASS (GET_CODE (operands[3])) == 'c'"
13890 "* return output_387_binary_op (insn, operands);"
13891 [(set_attr "type" "sse")
13892 (set_attr "mode" "SF")])
13893
13894 (define_insn "*fop_df_comm_nosse"
13895 [(set (match_operand:DF 0 "register_operand" "=f")
13896 (match_operator:DF 3 "binary_fp_operator"
13897 [(match_operand:DF 1 "register_operand" "%0")
13898 (match_operand:DF 2 "nonimmediate_operand" "fm")]))]
13899 "TARGET_80387 && (!TARGET_SSE2 || !TARGET_SSE_MATH)
13900 && GET_RTX_CLASS (GET_CODE (operands[3])) == 'c'"
13901 "* return output_387_binary_op (insn, operands);"
13902 [(set (attr "type")
13903 (if_then_else (match_operand:SF 3 "mult_operator" "")
13904 (const_string "fmul")
13905 (const_string "fop")))
13906 (set_attr "mode" "DF")])
13907
13908 (define_insn "*fop_df_comm"
13909 [(set (match_operand:DF 0 "register_operand" "=f#Y,Y#f")
13910 (match_operator:DF 3 "binary_fp_operator"
13911 [(match_operand:DF 1 "register_operand" "%0,0")
13912 (match_operand:DF 2 "nonimmediate_operand" "fm#Y,Ym#f")]))]
13913 "TARGET_80387 && TARGET_SSE_MATH && TARGET_SSE2 && TARGET_MIX_SSE_I387
13914 && GET_RTX_CLASS (GET_CODE (operands[3])) == 'c'"
13915 "* return output_387_binary_op (insn, operands);"
13916 [(set (attr "type")
13917 (if_then_else (eq_attr "alternative" "1")
13918 (const_string "sse")
13919 (if_then_else (match_operand:SF 3 "mult_operator" "")
13920 (const_string "fmul")
13921 (const_string "fop"))))
13922 (set_attr "mode" "DF")])
13923
13924 (define_insn "*fop_df_comm_sse"
13925 [(set (match_operand:DF 0 "register_operand" "=Y")
13926 (match_operator:DF 3 "binary_fp_operator"
13927 [(match_operand:DF 1 "register_operand" "%0")
13928 (match_operand:DF 2 "nonimmediate_operand" "Ym")]))]
13929 "TARGET_SSE2 && TARGET_SSE_MATH
13930 && GET_RTX_CLASS (GET_CODE (operands[3])) == 'c'"
13931 "* return output_387_binary_op (insn, operands);"
13932 [(set_attr "type" "sse")
13933 (set_attr "mode" "DF")])
13934
13935 (define_insn "*fop_xf_comm"
13936 [(set (match_operand:XF 0 "register_operand" "=f")
13937 (match_operator:XF 3 "binary_fp_operator"
13938 [(match_operand:XF 1 "register_operand" "%0")
13939 (match_operand:XF 2 "register_operand" "f")]))]
13940 "!TARGET_64BIT && TARGET_80387
13941 && GET_RTX_CLASS (GET_CODE (operands[3])) == 'c'"
13942 "* return output_387_binary_op (insn, operands);"
13943 [(set (attr "type")
13944 (if_then_else (match_operand:XF 3 "mult_operator" "")
13945 (const_string "fmul")
13946 (const_string "fop")))
13947 (set_attr "mode" "XF")])
13948
13949 (define_insn "*fop_tf_comm"
13950 [(set (match_operand:TF 0 "register_operand" "=f")
13951 (match_operator:TF 3 "binary_fp_operator"
13952 [(match_operand:TF 1 "register_operand" "%0")
13953 (match_operand:TF 2 "register_operand" "f")]))]
13954 "TARGET_80387 && GET_RTX_CLASS (GET_CODE (operands[3])) == 'c'"
13955 "* return output_387_binary_op (insn, operands);"
13956 [(set (attr "type")
13957 (if_then_else (match_operand:TF 3 "mult_operator" "")
13958 (const_string "fmul")
13959 (const_string "fop")))
13960 (set_attr "mode" "XF")])
13961
13962 (define_insn "*fop_sf_1_nosse"
13963 [(set (match_operand:SF 0 "register_operand" "=f,f")
13964 (match_operator:SF 3 "binary_fp_operator"
13965 [(match_operand:SF 1 "nonimmediate_operand" "0,fm")
13966 (match_operand:SF 2 "nonimmediate_operand" "fm,0")]))]
13967 "TARGET_80387 && !TARGET_SSE_MATH
13968 && GET_RTX_CLASS (GET_CODE (operands[3])) != 'c'
13969 && (GET_CODE (operands[1]) != MEM || GET_CODE (operands[2]) != MEM)"
13970 "* return output_387_binary_op (insn, operands);"
13971 [(set (attr "type")
13972 (cond [(match_operand:SF 3 "mult_operator" "")
13973 (const_string "fmul")
13974 (match_operand:SF 3 "div_operator" "")
13975 (const_string "fdiv")
13976 ]
13977 (const_string "fop")))
13978 (set_attr "mode" "SF")])
13979
13980 (define_insn "*fop_sf_1"
13981 [(set (match_operand:SF 0 "register_operand" "=f,f,x")
13982 (match_operator:SF 3 "binary_fp_operator"
13983 [(match_operand:SF 1 "nonimmediate_operand" "0,fm,0")
13984 (match_operand:SF 2 "nonimmediate_operand" "fm,0,xm#f")]))]
13985 "TARGET_80387 && TARGET_SSE_MATH && TARGET_MIX_SSE_I387
13986 && GET_RTX_CLASS (GET_CODE (operands[3])) != 'c'
13987 && (GET_CODE (operands[1]) != MEM || GET_CODE (operands[2]) != MEM)"
13988 "* return output_387_binary_op (insn, operands);"
13989 [(set (attr "type")
13990 (cond [(eq_attr "alternative" "2")
13991 (const_string "sse")
13992 (match_operand:SF 3 "mult_operator" "")
13993 (const_string "fmul")
13994 (match_operand:SF 3 "div_operator" "")
13995 (const_string "fdiv")
13996 ]
13997 (const_string "fop")))
13998 (set_attr "mode" "SF")])
13999
14000 (define_insn "*fop_sf_1_sse"
14001 [(set (match_operand:SF 0 "register_operand" "=x")
14002 (match_operator:SF 3 "binary_fp_operator"
14003 [(match_operand:SF 1 "register_operand" "0")
14004 (match_operand:SF 2 "nonimmediate_operand" "xm")]))]
14005 "TARGET_SSE_MATH
14006 && GET_RTX_CLASS (GET_CODE (operands[3])) != 'c'"
14007 "* return output_387_binary_op (insn, operands);"
14008 [(set_attr "type" "sse")
14009 (set_attr "mode" "SF")])
14010
14011 ;; ??? Add SSE splitters for these!
14012 (define_insn "*fop_sf_2"
14013 [(set (match_operand:SF 0 "register_operand" "=f,f")
14014 (match_operator:SF 3 "binary_fp_operator"
14015 [(float:SF (match_operand:SI 1 "nonimmediate_operand" "m,?r"))
14016 (match_operand:SF 2 "register_operand" "0,0")]))]
14017 "TARGET_80387 && TARGET_USE_FIOP && !TARGET_SSE_MATH"
14018 "* return which_alternative ? \"#\" : output_387_binary_op (insn, operands);"
14019 [(set (attr "type")
14020 (cond [(match_operand:SF 3 "mult_operator" "")
14021 (const_string "fmul")
14022 (match_operand:SF 3 "div_operator" "")
14023 (const_string "fdiv")
14024 ]
14025 (const_string "fop")))
14026 (set_attr "fp_int_src" "true")
14027 (set_attr "ppro_uops" "many")
14028 (set_attr "mode" "SI")])
14029
14030 (define_insn "*fop_sf_3"
14031 [(set (match_operand:SF 0 "register_operand" "=f,f")
14032 (match_operator:SF 3 "binary_fp_operator"
14033 [(match_operand:SF 1 "register_operand" "0,0")
14034 (float:SF (match_operand:SI 2 "nonimmediate_operand" "m,?r"))]))]
14035 "TARGET_80387 && TARGET_USE_FIOP && !TARGET_SSE_MATH"
14036 "* return which_alternative ? \"#\" : output_387_binary_op (insn, operands);"
14037 [(set (attr "type")
14038 (cond [(match_operand:SF 3 "mult_operator" "")
14039 (const_string "fmul")
14040 (match_operand:SF 3 "div_operator" "")
14041 (const_string "fdiv")
14042 ]
14043 (const_string "fop")))
14044 (set_attr "fp_int_src" "true")
14045 (set_attr "ppro_uops" "many")
14046 (set_attr "mode" "SI")])
14047
14048 (define_insn "*fop_df_1_nosse"
14049 [(set (match_operand:DF 0 "register_operand" "=f,f")
14050 (match_operator:DF 3 "binary_fp_operator"
14051 [(match_operand:DF 1 "nonimmediate_operand" "0,fm")
14052 (match_operand:DF 2 "nonimmediate_operand" "fm,0")]))]
14053 "TARGET_80387 && (!TARGET_SSE2 || !TARGET_SSE_MATH)
14054 && GET_RTX_CLASS (GET_CODE (operands[3])) != 'c'
14055 && (GET_CODE (operands[1]) != MEM || GET_CODE (operands[2]) != MEM)"
14056 "* return output_387_binary_op (insn, operands);"
14057 [(set (attr "type")
14058 (cond [(match_operand:DF 3 "mult_operator" "")
14059 (const_string "fmul")
14060 (match_operand:DF 3 "div_operator" "")
14061 (const_string "fdiv")
14062 ]
14063 (const_string "fop")))
14064 (set_attr "mode" "DF")])
14065
14066
14067 (define_insn "*fop_df_1"
14068 [(set (match_operand:DF 0 "register_operand" "=f#Y,f#Y,Y#f")
14069 (match_operator:DF 3 "binary_fp_operator"
14070 [(match_operand:DF 1 "nonimmediate_operand" "0,fm,0")
14071 (match_operand:DF 2 "nonimmediate_operand" "fm,0,Ym#f")]))]
14072 "TARGET_80387 && TARGET_SSE2 && TARGET_SSE_MATH && TARGET_MIX_SSE_I387
14073 && GET_RTX_CLASS (GET_CODE (operands[3])) != 'c'
14074 && (GET_CODE (operands[1]) != MEM || GET_CODE (operands[2]) != MEM)"
14075 "* return output_387_binary_op (insn, operands);"
14076 [(set (attr "type")
14077 (cond [(eq_attr "alternative" "2")
14078 (const_string "sse")
14079 (match_operand:DF 3 "mult_operator" "")
14080 (const_string "fmul")
14081 (match_operand:DF 3 "div_operator" "")
14082 (const_string "fdiv")
14083 ]
14084 (const_string "fop")))
14085 (set_attr "mode" "DF")])
14086
14087 (define_insn "*fop_df_1_sse"
14088 [(set (match_operand:DF 0 "register_operand" "=Y")
14089 (match_operator:DF 3 "binary_fp_operator"
14090 [(match_operand:DF 1 "register_operand" "0")
14091 (match_operand:DF 2 "nonimmediate_operand" "Ym")]))]
14092 "TARGET_SSE2 && TARGET_SSE_MATH
14093 && GET_RTX_CLASS (GET_CODE (operands[3])) != 'c'"
14094 "* return output_387_binary_op (insn, operands);"
14095 [(set_attr "type" "sse")])
14096
14097 ;; ??? Add SSE splitters for these!
14098 (define_insn "*fop_df_2"
14099 [(set (match_operand:DF 0 "register_operand" "=f,f")
14100 (match_operator:DF 3 "binary_fp_operator"
14101 [(float:DF (match_operand:SI 1 "nonimmediate_operand" "m,?r"))
14102 (match_operand:DF 2 "register_operand" "0,0")]))]
14103 "TARGET_80387 && TARGET_USE_FIOP && !(TARGET_SSE2 && TARGET_SSE_MATH)"
14104 "* return which_alternative ? \"#\" : output_387_binary_op (insn, operands);"
14105 [(set (attr "type")
14106 (cond [(match_operand:DF 3 "mult_operator" "")
14107 (const_string "fmul")
14108 (match_operand:DF 3 "div_operator" "")
14109 (const_string "fdiv")
14110 ]
14111 (const_string "fop")))
14112 (set_attr "fp_int_src" "true")
14113 (set_attr "ppro_uops" "many")
14114 (set_attr "mode" "SI")])
14115
14116 (define_insn "*fop_df_3"
14117 [(set (match_operand:DF 0 "register_operand" "=f,f")
14118 (match_operator:DF 3 "binary_fp_operator"
14119 [(match_operand:DF 1 "register_operand" "0,0")
14120 (float:DF (match_operand:SI 2 "nonimmediate_operand" "m,?r"))]))]
14121 "TARGET_80387 && TARGET_USE_FIOP && !(TARGET_SSE2 && TARGET_SSE_MATH)"
14122 "* return which_alternative ? \"#\" : output_387_binary_op (insn, operands);"
14123 [(set (attr "type")
14124 (cond [(match_operand:DF 3 "mult_operator" "")
14125 (const_string "fmul")
14126 (match_operand:DF 3 "div_operator" "")
14127 (const_string "fdiv")
14128 ]
14129 (const_string "fop")))
14130 (set_attr "fp_int_src" "true")
14131 (set_attr "ppro_uops" "many")
14132 (set_attr "mode" "SI")])
14133
14134 (define_insn "*fop_df_4"
14135 [(set (match_operand:DF 0 "register_operand" "=f,f")
14136 (match_operator:DF 3 "binary_fp_operator"
14137 [(float_extend:DF (match_operand:SF 1 "nonimmediate_operand" "fm,0"))
14138 (match_operand:DF 2 "register_operand" "0,f")]))]
14139 "TARGET_80387 && (!TARGET_SSE2 || !TARGET_SSE_MATH)
14140 && (GET_CODE (operands[1]) != MEM || GET_CODE (operands[2]) != MEM)"
14141 "* return output_387_binary_op (insn, operands);"
14142 [(set (attr "type")
14143 (cond [(match_operand:DF 3 "mult_operator" "")
14144 (const_string "fmul")
14145 (match_operand:DF 3 "div_operator" "")
14146 (const_string "fdiv")
14147 ]
14148 (const_string "fop")))
14149 (set_attr "mode" "SF")])
14150
14151 (define_insn "*fop_df_5"
14152 [(set (match_operand:DF 0 "register_operand" "=f,f")
14153 (match_operator:DF 3 "binary_fp_operator"
14154 [(match_operand:DF 1 "register_operand" "0,f")
14155 (float_extend:DF
14156 (match_operand:SF 2 "nonimmediate_operand" "fm,0"))]))]
14157 "TARGET_80387 && !(TARGET_SSE2 && TARGET_SSE_MATH)"
14158 "* return output_387_binary_op (insn, operands);"
14159 [(set (attr "type")
14160 (cond [(match_operand:DF 3 "mult_operator" "")
14161 (const_string "fmul")
14162 (match_operand:DF 3 "div_operator" "")
14163 (const_string "fdiv")
14164 ]
14165 (const_string "fop")))
14166 (set_attr "mode" "SF")])
14167
14168 (define_insn "*fop_xf_1"
14169 [(set (match_operand:XF 0 "register_operand" "=f,f")
14170 (match_operator:XF 3 "binary_fp_operator"
14171 [(match_operand:XF 1 "register_operand" "0,f")
14172 (match_operand:XF 2 "register_operand" "f,0")]))]
14173 "!TARGET_64BIT && TARGET_80387
14174 && GET_RTX_CLASS (GET_CODE (operands[3])) != 'c'"
14175 "* return output_387_binary_op (insn, operands);"
14176 [(set (attr "type")
14177 (cond [(match_operand:XF 3 "mult_operator" "")
14178 (const_string "fmul")
14179 (match_operand:XF 3 "div_operator" "")
14180 (const_string "fdiv")
14181 ]
14182 (const_string "fop")))
14183 (set_attr "mode" "XF")])
14184
14185 (define_insn "*fop_tf_1"
14186 [(set (match_operand:TF 0 "register_operand" "=f,f")
14187 (match_operator:TF 3 "binary_fp_operator"
14188 [(match_operand:TF 1 "register_operand" "0,f")
14189 (match_operand:TF 2 "register_operand" "f,0")]))]
14190 "TARGET_80387
14191 && GET_RTX_CLASS (GET_CODE (operands[3])) != 'c'"
14192 "* return output_387_binary_op (insn, operands);"
14193 [(set (attr "type")
14194 (cond [(match_operand:TF 3 "mult_operator" "")
14195 (const_string "fmul")
14196 (match_operand:TF 3 "div_operator" "")
14197 (const_string "fdiv")
14198 ]
14199 (const_string "fop")))
14200 (set_attr "mode" "XF")])
14201
14202 (define_insn "*fop_xf_2"
14203 [(set (match_operand:XF 0 "register_operand" "=f,f")
14204 (match_operator:XF 3 "binary_fp_operator"
14205 [(float:XF (match_operand:SI 1 "nonimmediate_operand" "m,?r"))
14206 (match_operand:XF 2 "register_operand" "0,0")]))]
14207 "!TARGET_64BIT && TARGET_80387 && TARGET_USE_FIOP"
14208 "* return which_alternative ? \"#\" : output_387_binary_op (insn, operands);"
14209 [(set (attr "type")
14210 (cond [(match_operand:XF 3 "mult_operator" "")
14211 (const_string "fmul")
14212 (match_operand:XF 3 "div_operator" "")
14213 (const_string "fdiv")
14214 ]
14215 (const_string "fop")))
14216 (set_attr "fp_int_src" "true")
14217 (set_attr "mode" "SI")
14218 (set_attr "ppro_uops" "many")])
14219
14220 (define_insn "*fop_tf_2"
14221 [(set (match_operand:TF 0 "register_operand" "=f,f")
14222 (match_operator:TF 3 "binary_fp_operator"
14223 [(float:TF (match_operand:SI 1 "nonimmediate_operand" "m,?r"))
14224 (match_operand:TF 2 "register_operand" "0,0")]))]
14225 "TARGET_80387 && TARGET_USE_FIOP"
14226 "* return which_alternative ? \"#\" : output_387_binary_op (insn, operands);"
14227 [(set (attr "type")
14228 (cond [(match_operand:TF 3 "mult_operator" "")
14229 (const_string "fmul")
14230 (match_operand:TF 3 "div_operator" "")
14231 (const_string "fdiv")
14232 ]
14233 (const_string "fop")))
14234 (set_attr "fp_int_src" "true")
14235 (set_attr "mode" "SI")
14236 (set_attr "ppro_uops" "many")])
14237
14238 (define_insn "*fop_xf_3"
14239 [(set (match_operand:XF 0 "register_operand" "=f,f")
14240 (match_operator:XF 3 "binary_fp_operator"
14241 [(match_operand:XF 1 "register_operand" "0,0")
14242 (float:XF (match_operand:SI 2 "nonimmediate_operand" "m,?r"))]))]
14243 "!TARGET_64BIT && TARGET_80387 && TARGET_USE_FIOP"
14244 "* return which_alternative ? \"#\" : output_387_binary_op (insn, operands);"
14245 [(set (attr "type")
14246 (cond [(match_operand:XF 3 "mult_operator" "")
14247 (const_string "fmul")
14248 (match_operand:XF 3 "div_operator" "")
14249 (const_string "fdiv")
14250 ]
14251 (const_string "fop")))
14252 (set_attr "fp_int_src" "true")
14253 (set_attr "mode" "SI")
14254 (set_attr "ppro_uops" "many")])
14255
14256 (define_insn "*fop_tf_3"
14257 [(set (match_operand:TF 0 "register_operand" "=f,f")
14258 (match_operator:TF 3 "binary_fp_operator"
14259 [(match_operand:TF 1 "register_operand" "0,0")
14260 (float:TF (match_operand:SI 2 "nonimmediate_operand" "m,?r"))]))]
14261 "TARGET_80387 && TARGET_USE_FIOP"
14262 "* return which_alternative ? \"#\" : output_387_binary_op (insn, operands);"
14263 [(set (attr "type")
14264 (cond [(match_operand:TF 3 "mult_operator" "")
14265 (const_string "fmul")
14266 (match_operand:TF 3 "div_operator" "")
14267 (const_string "fdiv")
14268 ]
14269 (const_string "fop")))
14270 (set_attr "fp_int_src" "true")
14271 (set_attr "mode" "SI")
14272 (set_attr "ppro_uops" "many")])
14273
14274 (define_insn "*fop_xf_4"
14275 [(set (match_operand:XF 0 "register_operand" "=f,f")
14276 (match_operator:XF 3 "binary_fp_operator"
14277 [(float_extend:XF (match_operand:SF 1 "nonimmediate_operand" "fm,0"))
14278 (match_operand:XF 2 "register_operand" "0,f")]))]
14279 "!TARGET_64BIT && TARGET_80387"
14280 "* return output_387_binary_op (insn, operands);"
14281 [(set (attr "type")
14282 (cond [(match_operand:XF 3 "mult_operator" "")
14283 (const_string "fmul")
14284 (match_operand:XF 3 "div_operator" "")
14285 (const_string "fdiv")
14286 ]
14287 (const_string "fop")))
14288 (set_attr "mode" "SF")])
14289
14290 (define_insn "*fop_tf_4"
14291 [(set (match_operand:TF 0 "register_operand" "=f,f")
14292 (match_operator:TF 3 "binary_fp_operator"
14293 [(float_extend:TF (match_operand:SF 1 "nonimmediate_operand" "fm,0"))
14294 (match_operand:TF 2 "register_operand" "0,f")]))]
14295 "TARGET_80387"
14296 "* return output_387_binary_op (insn, operands);"
14297 [(set (attr "type")
14298 (cond [(match_operand:TF 3 "mult_operator" "")
14299 (const_string "fmul")
14300 (match_operand:TF 3 "div_operator" "")
14301 (const_string "fdiv")
14302 ]
14303 (const_string "fop")))
14304 (set_attr "mode" "SF")])
14305
14306 (define_insn "*fop_xf_5"
14307 [(set (match_operand:XF 0 "register_operand" "=f,f")
14308 (match_operator:XF 3 "binary_fp_operator"
14309 [(match_operand:XF 1 "register_operand" "0,f")
14310 (float_extend:XF
14311 (match_operand:SF 2 "nonimmediate_operand" "fm,0"))]))]
14312 "!TARGET_64BIT && TARGET_80387"
14313 "* return output_387_binary_op (insn, operands);"
14314 [(set (attr "type")
14315 (cond [(match_operand:XF 3 "mult_operator" "")
14316 (const_string "fmul")
14317 (match_operand:XF 3 "div_operator" "")
14318 (const_string "fdiv")
14319 ]
14320 (const_string "fop")))
14321 (set_attr "mode" "SF")])
14322
14323 (define_insn "*fop_tf_5"
14324 [(set (match_operand:TF 0 "register_operand" "=f,f")
14325 (match_operator:TF 3 "binary_fp_operator"
14326 [(match_operand:TF 1 "register_operand" "0,f")
14327 (float_extend:TF
14328 (match_operand:SF 2 "nonimmediate_operand" "fm,0"))]))]
14329 "TARGET_80387"
14330 "* return output_387_binary_op (insn, operands);"
14331 [(set (attr "type")
14332 (cond [(match_operand:TF 3 "mult_operator" "")
14333 (const_string "fmul")
14334 (match_operand:TF 3 "div_operator" "")
14335 (const_string "fdiv")
14336 ]
14337 (const_string "fop")))
14338 (set_attr "mode" "SF")])
14339
14340 (define_insn "*fop_xf_6"
14341 [(set (match_operand:XF 0 "register_operand" "=f,f")
14342 (match_operator:XF 3 "binary_fp_operator"
14343 [(float_extend:XF (match_operand:DF 1 "nonimmediate_operand" "fm,0"))
14344 (match_operand:XF 2 "register_operand" "0,f")]))]
14345 "!TARGET_64BIT && TARGET_80387"
14346 "* return output_387_binary_op (insn, operands);"
14347 [(set (attr "type")
14348 (cond [(match_operand:XF 3 "mult_operator" "")
14349 (const_string "fmul")
14350 (match_operand:XF 3 "div_operator" "")
14351 (const_string "fdiv")
14352 ]
14353 (const_string "fop")))
14354 (set_attr "mode" "DF")])
14355
14356 (define_insn "*fop_tf_6"
14357 [(set (match_operand:TF 0 "register_operand" "=f,f")
14358 (match_operator:TF 3 "binary_fp_operator"
14359 [(float_extend:TF (match_operand:DF 1 "nonimmediate_operand" "fm,0"))
14360 (match_operand:TF 2 "register_operand" "0,f")]))]
14361 "TARGET_80387"
14362 "* return output_387_binary_op (insn, operands);"
14363 [(set (attr "type")
14364 (cond [(match_operand:TF 3 "mult_operator" "")
14365 (const_string "fmul")
14366 (match_operand:TF 3 "div_operator" "")
14367 (const_string "fdiv")
14368 ]
14369 (const_string "fop")))
14370 (set_attr "mode" "DF")])
14371
14372 (define_insn "*fop_xf_7"
14373 [(set (match_operand:XF 0 "register_operand" "=f,f")
14374 (match_operator:XF 3 "binary_fp_operator"
14375 [(match_operand:XF 1 "register_operand" "0,f")
14376 (float_extend:XF
14377 (match_operand:DF 2 "nonimmediate_operand" "fm,0"))]))]
14378 "!TARGET_64BIT && TARGET_80387"
14379 "* return output_387_binary_op (insn, operands);"
14380 [(set (attr "type")
14381 (cond [(match_operand:XF 3 "mult_operator" "")
14382 (const_string "fmul")
14383 (match_operand:XF 3 "div_operator" "")
14384 (const_string "fdiv")
14385 ]
14386 (const_string "fop")))
14387 (set_attr "mode" "DF")])
14388
14389 (define_insn "*fop_tf_7"
14390 [(set (match_operand:TF 0 "register_operand" "=f,f")
14391 (match_operator:TF 3 "binary_fp_operator"
14392 [(match_operand:TF 1 "register_operand" "0,f")
14393 (float_extend:TF
14394 (match_operand:DF 2 "nonimmediate_operand" "fm,0"))]))]
14395 "TARGET_80387"
14396 "* return output_387_binary_op (insn, operands);"
14397 [(set (attr "type")
14398 (cond [(match_operand:TF 3 "mult_operator" "")
14399 (const_string "fmul")
14400 (match_operand:TF 3 "div_operator" "")
14401 (const_string "fdiv")
14402 ]
14403 (const_string "fop")))
14404 (set_attr "mode" "DF")])
14405
14406 (define_split
14407 [(set (match_operand 0 "register_operand" "")
14408 (match_operator 3 "binary_fp_operator"
14409 [(float (match_operand:SI 1 "register_operand" ""))
14410 (match_operand 2 "register_operand" "")]))]
14411 "TARGET_80387 && reload_completed
14412 && FLOAT_MODE_P (GET_MODE (operands[0]))"
14413 [(const_int 0)]
14414 {
14415 operands[4] = ix86_force_to_memory (GET_MODE (operands[1]), operands[1]);
14416 operands[4] = gen_rtx_FLOAT (GET_MODE (operands[0]), operands[4]);
14417 emit_insn (gen_rtx_SET (VOIDmode, operands[0],
14418 gen_rtx_fmt_ee (GET_CODE (operands[3]),
14419 GET_MODE (operands[3]),
14420 operands[4],
14421 operands[2])));
14422 ix86_free_from_memory (GET_MODE (operands[1]));
14423 DONE;
14424 })
14425
14426 (define_split
14427 [(set (match_operand 0 "register_operand" "")
14428 (match_operator 3 "binary_fp_operator"
14429 [(match_operand 1 "register_operand" "")
14430 (float (match_operand:SI 2 "register_operand" ""))]))]
14431 "TARGET_80387 && reload_completed
14432 && FLOAT_MODE_P (GET_MODE (operands[0]))"
14433 [(const_int 0)]
14434 {
14435 operands[4] = ix86_force_to_memory (GET_MODE (operands[2]), operands[2]);
14436 operands[4] = gen_rtx_FLOAT (GET_MODE (operands[0]), operands[4]);
14437 emit_insn (gen_rtx_SET (VOIDmode, operands[0],
14438 gen_rtx_fmt_ee (GET_CODE (operands[3]),
14439 GET_MODE (operands[3]),
14440 operands[1],
14441 operands[4])));
14442 ix86_free_from_memory (GET_MODE (operands[2]));
14443 DONE;
14444 })
14445 \f
14446 ;; FPU special functions.
14447
14448 (define_expand "sqrtsf2"
14449 [(set (match_operand:SF 0 "register_operand" "")
14450 (sqrt:SF (match_operand:SF 1 "nonimmediate_operand" "")))]
14451 "(! TARGET_NO_FANCY_MATH_387 && TARGET_80387) || TARGET_SSE_MATH"
14452 {
14453 if (!TARGET_SSE_MATH)
14454 operands[1] = force_reg (SFmode, operands[1]);
14455 })
14456
14457 (define_insn "sqrtsf2_1"
14458 [(set (match_operand:SF 0 "register_operand" "=f#x,x#f")
14459 (sqrt:SF (match_operand:SF 1 "nonimmediate_operand" "0#x,xm#f")))]
14460 "! TARGET_NO_FANCY_MATH_387 && TARGET_80387
14461 && (TARGET_SSE_MATH && TARGET_MIX_SSE_I387)"
14462 "@
14463 fsqrt
14464 sqrtss\t{%1, %0|%0, %1}"
14465 [(set_attr "type" "fpspc,sse")
14466 (set_attr "mode" "SF,SF")
14467 (set_attr "athlon_decode" "direct,*")])
14468
14469 (define_insn "sqrtsf2_1_sse_only"
14470 [(set (match_operand:SF 0 "register_operand" "=x")
14471 (sqrt:SF (match_operand:SF 1 "nonimmediate_operand" "xm")))]
14472 "TARGET_SSE_MATH && (!TARGET_80387 || !TARGET_MIX_SSE_I387)"
14473 "sqrtss\t{%1, %0|%0, %1}"
14474 [(set_attr "type" "sse")
14475 (set_attr "mode" "SF")
14476 (set_attr "athlon_decode" "*")])
14477
14478 (define_insn "sqrtsf2_i387"
14479 [(set (match_operand:SF 0 "register_operand" "=f")
14480 (sqrt:SF (match_operand:SF 1 "register_operand" "0")))]
14481 "! TARGET_NO_FANCY_MATH_387 && TARGET_80387
14482 && !TARGET_SSE_MATH"
14483 "fsqrt"
14484 [(set_attr "type" "fpspc")
14485 (set_attr "mode" "SF")
14486 (set_attr "athlon_decode" "direct")])
14487
14488 (define_expand "sqrtdf2"
14489 [(set (match_operand:DF 0 "register_operand" "")
14490 (sqrt:DF (match_operand:DF 1 "nonimmediate_operand" "")))]
14491 "(! TARGET_NO_FANCY_MATH_387 && TARGET_80387)
14492 || (TARGET_SSE2 && TARGET_SSE_MATH)"
14493 {
14494 if (!TARGET_SSE2 || !TARGET_SSE_MATH)
14495 operands[1] = force_reg (DFmode, operands[1]);
14496 })
14497
14498 (define_insn "sqrtdf2_1"
14499 [(set (match_operand:DF 0 "register_operand" "=f#Y,Y#f")
14500 (sqrt:DF (match_operand:DF 1 "nonimmediate_operand" "0#Y,Ym#f")))]
14501 "! TARGET_NO_FANCY_MATH_387 && TARGET_80387
14502 && (TARGET_SSE2 && TARGET_SSE_MATH && TARGET_MIX_SSE_I387)"
14503 "@
14504 fsqrt
14505 sqrtsd\t{%1, %0|%0, %1}"
14506 [(set_attr "type" "fpspc,sse")
14507 (set_attr "mode" "DF,DF")
14508 (set_attr "athlon_decode" "direct,*")])
14509
14510 (define_insn "sqrtdf2_1_sse_only"
14511 [(set (match_operand:DF 0 "register_operand" "=Y")
14512 (sqrt:DF (match_operand:DF 1 "nonimmediate_operand" "Ym")))]
14513 "TARGET_SSE2 && TARGET_SSE_MATH && (!TARGET_80387 || !TARGET_MIX_SSE_I387)"
14514 "sqrtsd\t{%1, %0|%0, %1}"
14515 [(set_attr "type" "sse")
14516 (set_attr "mode" "DF")
14517 (set_attr "athlon_decode" "*")])
14518
14519 (define_insn "sqrtdf2_i387"
14520 [(set (match_operand:DF 0 "register_operand" "=f")
14521 (sqrt:DF (match_operand:DF 1 "register_operand" "0")))]
14522 "! TARGET_NO_FANCY_MATH_387 && TARGET_80387
14523 && (!TARGET_SSE2 || !TARGET_SSE_MATH)"
14524 "fsqrt"
14525 [(set_attr "type" "fpspc")
14526 (set_attr "mode" "DF")
14527 (set_attr "athlon_decode" "direct")])
14528
14529 (define_insn "*sqrtextendsfdf2"
14530 [(set (match_operand:DF 0 "register_operand" "=f")
14531 (sqrt:DF (float_extend:DF
14532 (match_operand:SF 1 "register_operand" "0"))))]
14533 "! TARGET_NO_FANCY_MATH_387 && TARGET_80387
14534 && !(TARGET_SSE2 && TARGET_SSE_MATH)"
14535 "fsqrt"
14536 [(set_attr "type" "fpspc")
14537 (set_attr "mode" "DF")
14538 (set_attr "athlon_decode" "direct")])
14539
14540 (define_insn "sqrtxf2"
14541 [(set (match_operand:XF 0 "register_operand" "=f")
14542 (sqrt:XF (match_operand:XF 1 "register_operand" "0")))]
14543 "!TARGET_64BIT && TARGET_80387 && !TARGET_NO_FANCY_MATH_387
14544 && (TARGET_IEEE_FP || flag_unsafe_math_optimizations) "
14545 "fsqrt"
14546 [(set_attr "type" "fpspc")
14547 (set_attr "mode" "XF")
14548 (set_attr "athlon_decode" "direct")])
14549
14550 (define_insn "sqrttf2"
14551 [(set (match_operand:TF 0 "register_operand" "=f")
14552 (sqrt:TF (match_operand:TF 1 "register_operand" "0")))]
14553 "! TARGET_NO_FANCY_MATH_387 && TARGET_80387
14554 && (TARGET_IEEE_FP || flag_unsafe_math_optimizations) "
14555 "fsqrt"
14556 [(set_attr "type" "fpspc")
14557 (set_attr "mode" "XF")
14558 (set_attr "athlon_decode" "direct")])
14559
14560 (define_insn "*sqrtextenddfxf2"
14561 [(set (match_operand:XF 0 "register_operand" "=f")
14562 (sqrt:XF (float_extend:XF
14563 (match_operand:DF 1 "register_operand" "0"))))]
14564 "!TARGET_64BIT && TARGET_80387 && TARGET_NO_FANCY_MATH_387"
14565 "fsqrt"
14566 [(set_attr "type" "fpspc")
14567 (set_attr "mode" "XF")
14568 (set_attr "athlon_decode" "direct")])
14569
14570 (define_insn "*sqrtextenddftf2"
14571 [(set (match_operand:TF 0 "register_operand" "=f")
14572 (sqrt:TF (float_extend:TF
14573 (match_operand:DF 1 "register_operand" "0"))))]
14574 "! TARGET_NO_FANCY_MATH_387 && TARGET_80387"
14575 "fsqrt"
14576 [(set_attr "type" "fpspc")
14577 (set_attr "mode" "XF")
14578 (set_attr "athlon_decode" "direct")])
14579
14580 (define_insn "*sqrtextendsfxf2"
14581 [(set (match_operand:XF 0 "register_operand" "=f")
14582 (sqrt:XF (float_extend:XF
14583 (match_operand:SF 1 "register_operand" "0"))))]
14584 "!TARGET_64BIT && TARGET_80387 && TARGET_NO_FANCY_MATH_387"
14585 "fsqrt"
14586 [(set_attr "type" "fpspc")
14587 (set_attr "mode" "XF")
14588 (set_attr "athlon_decode" "direct")])
14589
14590 (define_insn "*sqrtextendsftf2"
14591 [(set (match_operand:TF 0 "register_operand" "=f")
14592 (sqrt:TF (float_extend:TF
14593 (match_operand:SF 1 "register_operand" "0"))))]
14594 "! TARGET_NO_FANCY_MATH_387 && TARGET_80387"
14595 "fsqrt"
14596 [(set_attr "type" "fpspc")
14597 (set_attr "mode" "XF")
14598 (set_attr "athlon_decode" "direct")])
14599
14600 (define_insn "sindf2"
14601 [(set (match_operand:DF 0 "register_operand" "=f")
14602 (unspec:DF [(match_operand:DF 1 "register_operand" "0")] 1))]
14603 "! TARGET_NO_FANCY_MATH_387 && TARGET_80387
14604 && flag_unsafe_math_optimizations"
14605 "fsin"
14606 [(set_attr "type" "fpspc")
14607 (set_attr "mode" "DF")])
14608
14609 (define_insn "sinsf2"
14610 [(set (match_operand:SF 0 "register_operand" "=f")
14611 (unspec:SF [(match_operand:SF 1 "register_operand" "0")] 1))]
14612 "! TARGET_NO_FANCY_MATH_387 && TARGET_80387
14613 && flag_unsafe_math_optimizations"
14614 "fsin"
14615 [(set_attr "type" "fpspc")
14616 (set_attr "mode" "SF")])
14617
14618 (define_insn "*sinextendsfdf2"
14619 [(set (match_operand:DF 0 "register_operand" "=f")
14620 (unspec:DF [(float_extend:DF
14621 (match_operand:SF 1 "register_operand" "0"))] 1))]
14622 "! TARGET_NO_FANCY_MATH_387 && TARGET_80387
14623 && flag_unsafe_math_optimizations"
14624 "fsin"
14625 [(set_attr "type" "fpspc")
14626 (set_attr "mode" "DF")])
14627
14628 (define_insn "sinxf2"
14629 [(set (match_operand:XF 0 "register_operand" "=f")
14630 (unspec:XF [(match_operand:XF 1 "register_operand" "0")] 1))]
14631 "!TARGET_64BIT && TARGET_80387 && TARGET_NO_FANCY_MATH_387
14632 && flag_unsafe_math_optimizations"
14633 "fsin"
14634 [(set_attr "type" "fpspc")
14635 (set_attr "mode" "XF")])
14636
14637 (define_insn "sintf2"
14638 [(set (match_operand:TF 0 "register_operand" "=f")
14639 (unspec:TF [(match_operand:TF 1 "register_operand" "0")] 1))]
14640 "! TARGET_NO_FANCY_MATH_387 && TARGET_80387
14641 && flag_unsafe_math_optimizations"
14642 "fsin"
14643 [(set_attr "type" "fpspc")
14644 (set_attr "mode" "XF")])
14645
14646 (define_insn "cosdf2"
14647 [(set (match_operand:DF 0 "register_operand" "=f")
14648 (unspec:DF [(match_operand:DF 1 "register_operand" "0")] 2))]
14649 "! TARGET_NO_FANCY_MATH_387 && TARGET_80387
14650 && flag_unsafe_math_optimizations"
14651 "fcos"
14652 [(set_attr "type" "fpspc")
14653 (set_attr "mode" "DF")])
14654
14655 (define_insn "cossf2"
14656 [(set (match_operand:SF 0 "register_operand" "=f")
14657 (unspec:SF [(match_operand:SF 1 "register_operand" "0")] 2))]
14658 "! TARGET_NO_FANCY_MATH_387 && TARGET_80387
14659 && flag_unsafe_math_optimizations"
14660 "fcos"
14661 [(set_attr "type" "fpspc")
14662 (set_attr "mode" "SF")])
14663
14664 (define_insn "*cosextendsfdf2"
14665 [(set (match_operand:DF 0 "register_operand" "=f")
14666 (unspec:DF [(float_extend:DF
14667 (match_operand:SF 1 "register_operand" "0"))] 2))]
14668 "! TARGET_NO_FANCY_MATH_387 && TARGET_80387
14669 && flag_unsafe_math_optimizations"
14670 "fcos"
14671 [(set_attr "type" "fpspc")
14672 (set_attr "mode" "DF")])
14673
14674 (define_insn "cosxf2"
14675 [(set (match_operand:XF 0 "register_operand" "=f")
14676 (unspec:XF [(match_operand:XF 1 "register_operand" "0")] 2))]
14677 "! TARGET_NO_FANCY_MATH_387 && TARGET_80387
14678 && flag_unsafe_math_optimizations"
14679 "fcos"
14680 [(set_attr "type" "fpspc")
14681 (set_attr "mode" "XF")])
14682
14683 (define_insn "costf2"
14684 [(set (match_operand:TF 0 "register_operand" "=f")
14685 (unspec:TF [(match_operand:TF 1 "register_operand" "0")] 2))]
14686 "! TARGET_NO_FANCY_MATH_387 && TARGET_80387
14687 && flag_unsafe_math_optimizations"
14688 "fcos"
14689 [(set_attr "type" "fpspc")
14690 (set_attr "mode" "XF")])
14691 \f
14692 ;; Block operation instructions
14693
14694 (define_insn "cld"
14695 [(set (reg:SI 19) (const_int 0))]
14696 ""
14697 "cld"
14698 [(set_attr "type" "cld")])
14699
14700 (define_expand "movstrsi"
14701 [(use (match_operand:BLK 0 "memory_operand" ""))
14702 (use (match_operand:BLK 1 "memory_operand" ""))
14703 (use (match_operand:SI 2 "nonmemory_operand" ""))
14704 (use (match_operand:SI 3 "const_int_operand" ""))]
14705 ""
14706 {
14707 if (ix86_expand_movstr (operands[0], operands[1], operands[2], operands[3]))
14708 DONE;
14709 else
14710 FAIL;
14711 })
14712
14713 (define_expand "movstrdi"
14714 [(use (match_operand:BLK 0 "memory_operand" ""))
14715 (use (match_operand:BLK 1 "memory_operand" ""))
14716 (use (match_operand:DI 2 "nonmemory_operand" ""))
14717 (use (match_operand:DI 3 "const_int_operand" ""))]
14718 "TARGET_64BIT"
14719 {
14720 if (ix86_expand_movstr (operands[0], operands[1], operands[2], operands[3]))
14721 DONE;
14722 else
14723 FAIL;
14724 })
14725
14726 ;; Most CPUs don't like single string operations
14727 ;; Handle this case here to simplify previous expander.
14728
14729 (define_expand "strmovdi_rex64"
14730 [(set (match_dup 2)
14731 (mem:DI (match_operand:DI 1 "register_operand" "")))
14732 (set (mem:DI (match_operand:DI 0 "register_operand" ""))
14733 (match_dup 2))
14734 (parallel [(set (match_dup 0) (plus:DI (match_dup 0) (const_int 8)))
14735 (clobber (reg:CC 17))])
14736 (parallel [(set (match_dup 1) (plus:DI (match_dup 1) (const_int 8)))
14737 (clobber (reg:CC 17))])]
14738 "TARGET_64BIT"
14739 {
14740 if (TARGET_SINGLE_STRINGOP || optimize_size)
14741 {
14742 emit_insn (gen_strmovdi_rex_1 (operands[0], operands[1], operands[0],
14743 operands[1]));
14744 DONE;
14745 }
14746 else
14747 operands[2] = gen_reg_rtx (DImode);
14748 })
14749
14750
14751 (define_expand "strmovsi"
14752 [(set (match_dup 2)
14753 (mem:SI (match_operand:SI 1 "register_operand" "")))
14754 (set (mem:SI (match_operand:SI 0 "register_operand" ""))
14755 (match_dup 2))
14756 (parallel [(set (match_dup 0) (plus:SI (match_dup 0) (const_int 4)))
14757 (clobber (reg:CC 17))])
14758 (parallel [(set (match_dup 1) (plus:SI (match_dup 1) (const_int 4)))
14759 (clobber (reg:CC 17))])]
14760 ""
14761 {
14762 if (TARGET_64BIT)
14763 {
14764 emit_insn (gen_strmovsi_rex64 (operands[0], operands[1]));
14765 DONE;
14766 }
14767 if (TARGET_SINGLE_STRINGOP || optimize_size)
14768 {
14769 emit_insn (gen_strmovsi_1 (operands[0], operands[1], operands[0],
14770 operands[1]));
14771 DONE;
14772 }
14773 else
14774 operands[2] = gen_reg_rtx (SImode);
14775 })
14776
14777 (define_expand "strmovsi_rex64"
14778 [(set (match_dup 2)
14779 (mem:SI (match_operand:DI 1 "register_operand" "")))
14780 (set (mem:SI (match_operand:DI 0 "register_operand" ""))
14781 (match_dup 2))
14782 (parallel [(set (match_dup 0) (plus:DI (match_dup 0) (const_int 4)))
14783 (clobber (reg:CC 17))])
14784 (parallel [(set (match_dup 1) (plus:DI (match_dup 1) (const_int 4)))
14785 (clobber (reg:CC 17))])]
14786 "TARGET_64BIT"
14787 {
14788 if (TARGET_SINGLE_STRINGOP || optimize_size)
14789 {
14790 emit_insn (gen_strmovsi_rex_1 (operands[0], operands[1], operands[0],
14791 operands[1]));
14792 DONE;
14793 }
14794 else
14795 operands[2] = gen_reg_rtx (SImode);
14796 })
14797
14798 (define_expand "strmovhi"
14799 [(set (match_dup 2)
14800 (mem:HI (match_operand:SI 1 "register_operand" "")))
14801 (set (mem:HI (match_operand:SI 0 "register_operand" ""))
14802 (match_dup 2))
14803 (parallel [(set (match_dup 0) (plus:SI (match_dup 0) (const_int 2)))
14804 (clobber (reg:CC 17))])
14805 (parallel [(set (match_dup 1) (plus:SI (match_dup 1) (const_int 2)))
14806 (clobber (reg:CC 17))])]
14807 ""
14808 {
14809 if (TARGET_64BIT)
14810 {
14811 emit_insn (gen_strmovhi_rex64 (operands[0], operands[1]));
14812 DONE;
14813 }
14814 if (TARGET_SINGLE_STRINGOP || optimize_size)
14815 {
14816 emit_insn (gen_strmovhi_1 (operands[0], operands[1], operands[0],
14817 operands[1]));
14818 DONE;
14819 }
14820 else
14821 operands[2] = gen_reg_rtx (HImode);
14822 })
14823
14824 (define_expand "strmovhi_rex64"
14825 [(set (match_dup 2)
14826 (mem:HI (match_operand:DI 1 "register_operand" "")))
14827 (set (mem:HI (match_operand:DI 0 "register_operand" ""))
14828 (match_dup 2))
14829 (parallel [(set (match_dup 0) (plus:DI (match_dup 0) (const_int 2)))
14830 (clobber (reg:CC 17))])
14831 (parallel [(set (match_dup 1) (plus:DI (match_dup 1) (const_int 2)))
14832 (clobber (reg:CC 17))])]
14833 "TARGET_64BIT"
14834 {
14835 if (TARGET_SINGLE_STRINGOP || optimize_size)
14836 {
14837 emit_insn (gen_strmovhi_rex_1 (operands[0], operands[1], operands[0],
14838 operands[1]));
14839 DONE;
14840 }
14841 else
14842 operands[2] = gen_reg_rtx (HImode);
14843 })
14844
14845 (define_expand "strmovqi"
14846 [(set (match_dup 2)
14847 (mem:QI (match_operand:SI 1 "register_operand" "")))
14848 (set (mem:QI (match_operand:SI 0 "register_operand" ""))
14849 (match_dup 2))
14850 (parallel [(set (match_dup 0) (plus:SI (match_dup 0) (const_int 1)))
14851 (clobber (reg:CC 17))])
14852 (parallel [(set (match_dup 1) (plus:SI (match_dup 1) (const_int 1)))
14853 (clobber (reg:CC 17))])]
14854 ""
14855 {
14856 if (TARGET_64BIT)
14857 {
14858 emit_insn (gen_strmovqi_rex64 (operands[0], operands[1]));
14859 DONE;
14860 }
14861 if (TARGET_SINGLE_STRINGOP || optimize_size)
14862 {
14863 emit_insn (gen_strmovqi_1 (operands[0], operands[1], operands[0],
14864 operands[1]));
14865 DONE;
14866 }
14867 else
14868 operands[2] = gen_reg_rtx (QImode);
14869 })
14870
14871 (define_expand "strmovqi_rex64"
14872 [(set (match_dup 2)
14873 (mem:QI (match_operand:DI 1 "register_operand" "")))
14874 (set (mem:QI (match_operand:DI 0 "register_operand" ""))
14875 (match_dup 2))
14876 (parallel [(set (match_dup 0) (plus:DI (match_dup 0) (const_int 1)))
14877 (clobber (reg:CC 17))])
14878 (parallel [(set (match_dup 1) (plus:DI (match_dup 1) (const_int 1)))
14879 (clobber (reg:CC 17))])]
14880 "TARGET_64BIT"
14881 {
14882 if (TARGET_SINGLE_STRINGOP || optimize_size)
14883 {
14884 emit_insn (gen_strmovqi_rex_1 (operands[0], operands[1], operands[0],
14885 operands[1]));
14886 DONE;
14887 }
14888 else
14889 operands[2] = gen_reg_rtx (QImode);
14890 })
14891
14892 (define_insn "strmovdi_rex_1"
14893 [(set (mem:DI (match_operand:DI 2 "register_operand" "0"))
14894 (mem:DI (match_operand:DI 3 "register_operand" "1")))
14895 (set (match_operand:DI 0 "register_operand" "=D")
14896 (plus:DI (match_dup 2)
14897 (const_int 8)))
14898 (set (match_operand:DI 1 "register_operand" "=S")
14899 (plus:DI (match_dup 3)
14900 (const_int 8)))
14901 (use (reg:SI 19))]
14902 "TARGET_64BIT && (TARGET_SINGLE_STRINGOP || optimize_size)"
14903 "movsq"
14904 [(set_attr "type" "str")
14905 (set_attr "mode" "DI")
14906 (set_attr "memory" "both")])
14907
14908 (define_insn "strmovsi_1"
14909 [(set (mem:SI (match_operand:SI 2 "register_operand" "0"))
14910 (mem:SI (match_operand:SI 3 "register_operand" "1")))
14911 (set (match_operand:SI 0 "register_operand" "=D")
14912 (plus:SI (match_dup 2)
14913 (const_int 4)))
14914 (set (match_operand:SI 1 "register_operand" "=S")
14915 (plus:SI (match_dup 3)
14916 (const_int 4)))
14917 (use (reg:SI 19))]
14918 "!TARGET_64BIT && (TARGET_SINGLE_STRINGOP || optimize_size)"
14919 "{movsl|movsd}"
14920 [(set_attr "type" "str")
14921 (set_attr "mode" "SI")
14922 (set_attr "memory" "both")])
14923
14924 (define_insn "strmovsi_rex_1"
14925 [(set (mem:SI (match_operand:DI 2 "register_operand" "0"))
14926 (mem:SI (match_operand:DI 3 "register_operand" "1")))
14927 (set (match_operand:DI 0 "register_operand" "=D")
14928 (plus:DI (match_dup 2)
14929 (const_int 4)))
14930 (set (match_operand:DI 1 "register_operand" "=S")
14931 (plus:DI (match_dup 3)
14932 (const_int 4)))
14933 (use (reg:SI 19))]
14934 "TARGET_64BIT && (TARGET_SINGLE_STRINGOP || optimize_size)"
14935 "{movsl|movsd}"
14936 [(set_attr "type" "str")
14937 (set_attr "mode" "SI")
14938 (set_attr "memory" "both")])
14939
14940 (define_insn "strmovhi_1"
14941 [(set (mem:HI (match_operand:SI 2 "register_operand" "0"))
14942 (mem:HI (match_operand:SI 3 "register_operand" "1")))
14943 (set (match_operand:SI 0 "register_operand" "=D")
14944 (plus:SI (match_dup 2)
14945 (const_int 2)))
14946 (set (match_operand:SI 1 "register_operand" "=S")
14947 (plus:SI (match_dup 3)
14948 (const_int 2)))
14949 (use (reg:SI 19))]
14950 "!TARGET_64BIT && (TARGET_SINGLE_STRINGOP || optimize_size)"
14951 "movsw"
14952 [(set_attr "type" "str")
14953 (set_attr "memory" "both")
14954 (set_attr "mode" "HI")])
14955
14956 (define_insn "strmovhi_rex_1"
14957 [(set (mem:HI (match_operand:DI 2 "register_operand" "0"))
14958 (mem:HI (match_operand:DI 3 "register_operand" "1")))
14959 (set (match_operand:DI 0 "register_operand" "=D")
14960 (plus:DI (match_dup 2)
14961 (const_int 2)))
14962 (set (match_operand:DI 1 "register_operand" "=S")
14963 (plus:DI (match_dup 3)
14964 (const_int 2)))
14965 (use (reg:SI 19))]
14966 "TARGET_64BIT && (TARGET_SINGLE_STRINGOP || optimize_size)"
14967 "movsw"
14968 [(set_attr "type" "str")
14969 (set_attr "memory" "both")
14970 (set_attr "mode" "HI")])
14971
14972 (define_insn "strmovqi_1"
14973 [(set (mem:QI (match_operand:SI 2 "register_operand" "0"))
14974 (mem:QI (match_operand:SI 3 "register_operand" "1")))
14975 (set (match_operand:SI 0 "register_operand" "=D")
14976 (plus:SI (match_dup 2)
14977 (const_int 1)))
14978 (set (match_operand:SI 1 "register_operand" "=S")
14979 (plus:SI (match_dup 3)
14980 (const_int 1)))
14981 (use (reg:SI 19))]
14982 "!TARGET_64BIT && (TARGET_SINGLE_STRINGOP || optimize_size)"
14983 "movsb"
14984 [(set_attr "type" "str")
14985 (set_attr "memory" "both")
14986 (set_attr "mode" "QI")])
14987
14988 (define_insn "strmovqi_rex_1"
14989 [(set (mem:QI (match_operand:DI 2 "register_operand" "0"))
14990 (mem:QI (match_operand:DI 3 "register_operand" "1")))
14991 (set (match_operand:DI 0 "register_operand" "=D")
14992 (plus:DI (match_dup 2)
14993 (const_int 1)))
14994 (set (match_operand:DI 1 "register_operand" "=S")
14995 (plus:DI (match_dup 3)
14996 (const_int 1)))
14997 (use (reg:SI 19))]
14998 "TARGET_64BIT && (TARGET_SINGLE_STRINGOP || optimize_size)"
14999 "movsb"
15000 [(set_attr "type" "str")
15001 (set_attr "memory" "both")
15002 (set_attr "mode" "QI")])
15003
15004 (define_insn "rep_movdi_rex64"
15005 [(set (match_operand:DI 2 "register_operand" "=c") (const_int 0))
15006 (set (match_operand:DI 0 "register_operand" "=D")
15007 (plus:DI (ashift:DI (match_operand:DI 5 "register_operand" "2")
15008 (const_int 3))
15009 (match_operand:DI 3 "register_operand" "0")))
15010 (set (match_operand:DI 1 "register_operand" "=S")
15011 (plus:DI (ashift:DI (match_dup 5) (const_int 3))
15012 (match_operand:DI 4 "register_operand" "1")))
15013 (set (mem:BLK (match_dup 3))
15014 (mem:BLK (match_dup 4)))
15015 (use (match_dup 5))
15016 (use (reg:SI 19))]
15017 "TARGET_64BIT"
15018 "{rep\;movsq|rep movsq}"
15019 [(set_attr "type" "str")
15020 (set_attr "prefix_rep" "1")
15021 (set_attr "memory" "both")
15022 (set_attr "mode" "DI")])
15023
15024 (define_insn "rep_movsi"
15025 [(set (match_operand:SI 2 "register_operand" "=c") (const_int 0))
15026 (set (match_operand:SI 0 "register_operand" "=D")
15027 (plus:SI (ashift:SI (match_operand:SI 5 "register_operand" "2")
15028 (const_int 2))
15029 (match_operand:SI 3 "register_operand" "0")))
15030 (set (match_operand:SI 1 "register_operand" "=S")
15031 (plus:SI (ashift:SI (match_dup 5) (const_int 2))
15032 (match_operand:SI 4 "register_operand" "1")))
15033 (set (mem:BLK (match_dup 3))
15034 (mem:BLK (match_dup 4)))
15035 (use (match_dup 5))
15036 (use (reg:SI 19))]
15037 "!TARGET_64BIT"
15038 "{rep\;movsl|rep movsd}"
15039 [(set_attr "type" "str")
15040 (set_attr "prefix_rep" "1")
15041 (set_attr "memory" "both")
15042 (set_attr "mode" "SI")])
15043
15044 (define_insn "rep_movsi_rex64"
15045 [(set (match_operand:DI 2 "register_operand" "=c") (const_int 0))
15046 (set (match_operand:DI 0 "register_operand" "=D")
15047 (plus:DI (ashift:DI (match_operand:DI 5 "register_operand" "2")
15048 (const_int 2))
15049 (match_operand:DI 3 "register_operand" "0")))
15050 (set (match_operand:DI 1 "register_operand" "=S")
15051 (plus:DI (ashift:DI (match_dup 5) (const_int 2))
15052 (match_operand:DI 4 "register_operand" "1")))
15053 (set (mem:BLK (match_dup 3))
15054 (mem:BLK (match_dup 4)))
15055 (use (match_dup 5))
15056 (use (reg:SI 19))]
15057 "TARGET_64BIT"
15058 "{rep\;movsl|rep movsd}"
15059 [(set_attr "type" "str")
15060 (set_attr "prefix_rep" "1")
15061 (set_attr "memory" "both")
15062 (set_attr "mode" "SI")])
15063
15064 (define_insn "rep_movqi"
15065 [(set (match_operand:SI 2 "register_operand" "=c") (const_int 0))
15066 (set (match_operand:SI 0 "register_operand" "=D")
15067 (plus:SI (match_operand:SI 3 "register_operand" "0")
15068 (match_operand:SI 5 "register_operand" "2")))
15069 (set (match_operand:SI 1 "register_operand" "=S")
15070 (plus:SI (match_operand:SI 4 "register_operand" "1") (match_dup 5)))
15071 (set (mem:BLK (match_dup 3))
15072 (mem:BLK (match_dup 4)))
15073 (use (match_dup 5))
15074 (use (reg:SI 19))]
15075 "!TARGET_64BIT"
15076 "{rep\;movsb|rep movsb}"
15077 [(set_attr "type" "str")
15078 (set_attr "prefix_rep" "1")
15079 (set_attr "memory" "both")
15080 (set_attr "mode" "SI")])
15081
15082 (define_insn "rep_movqi_rex64"
15083 [(set (match_operand:DI 2 "register_operand" "=c") (const_int 0))
15084 (set (match_operand:DI 0 "register_operand" "=D")
15085 (plus:DI (match_operand:DI 3 "register_operand" "0")
15086 (match_operand:DI 5 "register_operand" "2")))
15087 (set (match_operand:DI 1 "register_operand" "=S")
15088 (plus:DI (match_operand:DI 4 "register_operand" "1") (match_dup 5)))
15089 (set (mem:BLK (match_dup 3))
15090 (mem:BLK (match_dup 4)))
15091 (use (match_dup 5))
15092 (use (reg:SI 19))]
15093 "TARGET_64BIT"
15094 "{rep\;movsb|rep movsb}"
15095 [(set_attr "type" "str")
15096 (set_attr "prefix_rep" "1")
15097 (set_attr "memory" "both")
15098 (set_attr "mode" "SI")])
15099
15100 (define_expand "clrstrsi"
15101 [(use (match_operand:BLK 0 "memory_operand" ""))
15102 (use (match_operand:SI 1 "nonmemory_operand" ""))
15103 (use (match_operand 2 "const_int_operand" ""))]
15104 ""
15105 {
15106 if (ix86_expand_clrstr (operands[0], operands[1], operands[2]))
15107 DONE;
15108 else
15109 FAIL;
15110 })
15111
15112 (define_expand "clrstrdi"
15113 [(use (match_operand:BLK 0 "memory_operand" ""))
15114 (use (match_operand:DI 1 "nonmemory_operand" ""))
15115 (use (match_operand 2 "const_int_operand" ""))]
15116 "TARGET_64BIT"
15117 {
15118 if (ix86_expand_clrstr (operands[0], operands[1], operands[2]))
15119 DONE;
15120 else
15121 FAIL;
15122 })
15123
15124 ;; Most CPUs don't like single string operations
15125 ;; Handle this case here to simplify previous expander.
15126
15127 (define_expand "strsetdi_rex64"
15128 [(set (mem:DI (match_operand:DI 0 "register_operand" ""))
15129 (match_operand:DI 1 "register_operand" ""))
15130 (parallel [(set (match_dup 0) (plus:DI (match_dup 0) (const_int 8)))
15131 (clobber (reg:CC 17))])]
15132 "TARGET_64BIT"
15133 {
15134 if (TARGET_SINGLE_STRINGOP || optimize_size)
15135 {
15136 emit_insn (gen_strsetdi_rex_1 (operands[0], operands[0], operands[1]));
15137 DONE;
15138 }
15139 })
15140
15141 (define_expand "strsetsi"
15142 [(set (mem:SI (match_operand:SI 0 "register_operand" ""))
15143 (match_operand:SI 1 "register_operand" ""))
15144 (parallel [(set (match_dup 0) (plus:SI (match_dup 0) (const_int 4)))
15145 (clobber (reg:CC 17))])]
15146 ""
15147 {
15148 if (TARGET_64BIT)
15149 {
15150 emit_insn (gen_strsetsi_rex64 (operands[0], operands[1]));
15151 DONE;
15152 }
15153 else if (TARGET_SINGLE_STRINGOP || optimize_size)
15154 {
15155 emit_insn (gen_strsetsi_1 (operands[0], operands[0], operands[1]));
15156 DONE;
15157 }
15158 })
15159
15160 (define_expand "strsetsi_rex64"
15161 [(set (mem:SI (match_operand:DI 0 "register_operand" ""))
15162 (match_operand:SI 1 "register_operand" ""))
15163 (parallel [(set (match_dup 0) (plus:DI (match_dup 0) (const_int 4)))
15164 (clobber (reg:CC 17))])]
15165 "TARGET_64BIT"
15166 {
15167 if (TARGET_SINGLE_STRINGOP || optimize_size)
15168 {
15169 emit_insn (gen_strsetsi_rex_1 (operands[0], operands[0], operands[1]));
15170 DONE;
15171 }
15172 })
15173
15174 (define_expand "strsethi"
15175 [(set (mem:HI (match_operand:SI 0 "register_operand" ""))
15176 (match_operand:HI 1 "register_operand" ""))
15177 (parallel [(set (match_dup 0) (plus:SI (match_dup 0) (const_int 2)))
15178 (clobber (reg:CC 17))])]
15179 ""
15180 {
15181 if (TARGET_64BIT)
15182 {
15183 emit_insn (gen_strsethi_rex64 (operands[0], operands[1]));
15184 DONE;
15185 }
15186 else if (TARGET_SINGLE_STRINGOP || optimize_size)
15187 {
15188 emit_insn (gen_strsethi_1 (operands[0], operands[0], operands[1]));
15189 DONE;
15190 }
15191 })
15192
15193 (define_expand "strsethi_rex64"
15194 [(set (mem:HI (match_operand:DI 0 "register_operand" ""))
15195 (match_operand:HI 1 "register_operand" ""))
15196 (parallel [(set (match_dup 0) (plus:DI (match_dup 0) (const_int 2)))
15197 (clobber (reg:CC 17))])]
15198 "TARGET_64BIT"
15199 {
15200 if (TARGET_SINGLE_STRINGOP || optimize_size)
15201 {
15202 emit_insn (gen_strsethi_rex_1 (operands[0], operands[0], operands[1]));
15203 DONE;
15204 }
15205 })
15206
15207 (define_expand "strsetqi"
15208 [(set (mem:QI (match_operand:SI 0 "register_operand" ""))
15209 (match_operand:QI 1 "register_operand" ""))
15210 (parallel [(set (match_dup 0) (plus:SI (match_dup 0) (const_int 1)))
15211 (clobber (reg:CC 17))])]
15212 ""
15213 {
15214 if (TARGET_64BIT)
15215 {
15216 emit_insn (gen_strsetqi_rex64 (operands[0], operands[1]));
15217 DONE;
15218 }
15219 else if (TARGET_SINGLE_STRINGOP || optimize_size)
15220 {
15221 emit_insn (gen_strsetqi_1 (operands[0], operands[0], operands[1]));
15222 DONE;
15223 }
15224 })
15225
15226 (define_expand "strsetqi_rex64"
15227 [(set (mem:QI (match_operand:DI 0 "register_operand" ""))
15228 (match_operand:QI 1 "register_operand" ""))
15229 (parallel [(set (match_dup 0) (plus:DI (match_dup 0) (const_int 1)))
15230 (clobber (reg:CC 17))])]
15231 "TARGET_64BIT"
15232 {
15233 if (TARGET_SINGLE_STRINGOP || optimize_size)
15234 {
15235 emit_insn (gen_strsetqi_rex_1 (operands[0], operands[0], operands[1]));
15236 DONE;
15237 }
15238 })
15239
15240 (define_insn "strsetdi_rex_1"
15241 [(set (mem:SI (match_operand:DI 1 "register_operand" "0"))
15242 (match_operand:SI 2 "register_operand" "a"))
15243 (set (match_operand:DI 0 "register_operand" "=D")
15244 (plus:DI (match_dup 1)
15245 (const_int 8)))
15246 (use (reg:SI 19))]
15247 "TARGET_64BIT && (TARGET_SINGLE_STRINGOP || optimize_size)"
15248 "stosq"
15249 [(set_attr "type" "str")
15250 (set_attr "memory" "store")
15251 (set_attr "mode" "DI")])
15252
15253 (define_insn "strsetsi_1"
15254 [(set (mem:SI (match_operand:SI 1 "register_operand" "0"))
15255 (match_operand:SI 2 "register_operand" "a"))
15256 (set (match_operand:SI 0 "register_operand" "=D")
15257 (plus:SI (match_dup 1)
15258 (const_int 4)))
15259 (use (reg:SI 19))]
15260 "!TARGET_64BIT && (TARGET_SINGLE_STRINGOP || optimize_size)"
15261 "{stosl|stosd}"
15262 [(set_attr "type" "str")
15263 (set_attr "memory" "store")
15264 (set_attr "mode" "SI")])
15265
15266 (define_insn "strsetsi_rex_1"
15267 [(set (mem:SI (match_operand:DI 1 "register_operand" "0"))
15268 (match_operand:SI 2 "register_operand" "a"))
15269 (set (match_operand:DI 0 "register_operand" "=D")
15270 (plus:DI (match_dup 1)
15271 (const_int 4)))
15272 (use (reg:SI 19))]
15273 "TARGET_64BIT && (TARGET_SINGLE_STRINGOP || optimize_size)"
15274 "{stosl|stosd}"
15275 [(set_attr "type" "str")
15276 (set_attr "memory" "store")
15277 (set_attr "mode" "SI")])
15278
15279 (define_insn "strsethi_1"
15280 [(set (mem:HI (match_operand:SI 1 "register_operand" "0"))
15281 (match_operand:HI 2 "register_operand" "a"))
15282 (set (match_operand:SI 0 "register_operand" "=D")
15283 (plus:SI (match_dup 1)
15284 (const_int 2)))
15285 (use (reg:SI 19))]
15286 "!TARGET_64BIT && (TARGET_SINGLE_STRINGOP || optimize_size)"
15287 "stosw"
15288 [(set_attr "type" "str")
15289 (set_attr "memory" "store")
15290 (set_attr "mode" "HI")])
15291
15292 (define_insn "strsethi_rex_1"
15293 [(set (mem:HI (match_operand:DI 1 "register_operand" "0"))
15294 (match_operand:HI 2 "register_operand" "a"))
15295 (set (match_operand:DI 0 "register_operand" "=D")
15296 (plus:DI (match_dup 1)
15297 (const_int 2)))
15298 (use (reg:SI 19))]
15299 "TARGET_64BIT && (TARGET_SINGLE_STRINGOP || optimize_size)"
15300 "stosw"
15301 [(set_attr "type" "str")
15302 (set_attr "memory" "store")
15303 (set_attr "mode" "HI")])
15304
15305 (define_insn "strsetqi_1"
15306 [(set (mem:QI (match_operand:SI 1 "register_operand" "0"))
15307 (match_operand:QI 2 "register_operand" "a"))
15308 (set (match_operand:SI 0 "register_operand" "=D")
15309 (plus:SI (match_dup 1)
15310 (const_int 1)))
15311 (use (reg:SI 19))]
15312 "!TARGET_64BIT && (TARGET_SINGLE_STRINGOP || optimize_size)"
15313 "stosb"
15314 [(set_attr "type" "str")
15315 (set_attr "memory" "store")
15316 (set_attr "mode" "QI")])
15317
15318 (define_insn "strsetqi_rex_1"
15319 [(set (mem:QI (match_operand:DI 1 "register_operand" "0"))
15320 (match_operand:QI 2 "register_operand" "a"))
15321 (set (match_operand:DI 0 "register_operand" "=D")
15322 (plus:DI (match_dup 1)
15323 (const_int 1)))
15324 (use (reg:SI 19))]
15325 "TARGET_64BIT && (TARGET_SINGLE_STRINGOP || optimize_size)"
15326 "stosb"
15327 [(set_attr "type" "str")
15328 (set_attr "memory" "store")
15329 (set_attr "mode" "QI")])
15330
15331 (define_insn "rep_stosdi_rex64"
15332 [(set (match_operand:DI 1 "register_operand" "=c") (const_int 0))
15333 (set (match_operand:DI 0 "register_operand" "=D")
15334 (plus:DI (ashift:DI (match_operand:DI 4 "register_operand" "1")
15335 (const_int 3))
15336 (match_operand:DI 3 "register_operand" "0")))
15337 (set (mem:BLK (match_dup 3))
15338 (const_int 0))
15339 (use (match_operand:DI 2 "register_operand" "a"))
15340 (use (match_dup 4))
15341 (use (reg:SI 19))]
15342 "TARGET_64BIT"
15343 "{rep\;stosq|rep stosq}"
15344 [(set_attr "type" "str")
15345 (set_attr "prefix_rep" "1")
15346 (set_attr "memory" "store")
15347 (set_attr "mode" "DI")])
15348
15349 (define_insn "rep_stossi"
15350 [(set (match_operand:SI 1 "register_operand" "=c") (const_int 0))
15351 (set (match_operand:SI 0 "register_operand" "=D")
15352 (plus:SI (ashift:SI (match_operand:SI 4 "register_operand" "1")
15353 (const_int 2))
15354 (match_operand:SI 3 "register_operand" "0")))
15355 (set (mem:BLK (match_dup 3))
15356 (const_int 0))
15357 (use (match_operand:SI 2 "register_operand" "a"))
15358 (use (match_dup 4))
15359 (use (reg:SI 19))]
15360 "!TARGET_64BIT"
15361 "{rep\;stosl|rep stosd}"
15362 [(set_attr "type" "str")
15363 (set_attr "prefix_rep" "1")
15364 (set_attr "memory" "store")
15365 (set_attr "mode" "SI")])
15366
15367 (define_insn "rep_stossi_rex64"
15368 [(set (match_operand:DI 1 "register_operand" "=c") (const_int 0))
15369 (set (match_operand:DI 0 "register_operand" "=D")
15370 (plus:DI (ashift:DI (match_operand:DI 4 "register_operand" "1")
15371 (const_int 2))
15372 (match_operand:DI 3 "register_operand" "0")))
15373 (set (mem:BLK (match_dup 3))
15374 (const_int 0))
15375 (use (match_operand:SI 2 "register_operand" "a"))
15376 (use (match_dup 4))
15377 (use (reg:SI 19))]
15378 "TARGET_64BIT"
15379 "{rep\;stosl|rep stosd}"
15380 [(set_attr "type" "str")
15381 (set_attr "prefix_rep" "1")
15382 (set_attr "memory" "store")
15383 (set_attr "mode" "SI")])
15384
15385 (define_insn "rep_stosqi"
15386 [(set (match_operand:SI 1 "register_operand" "=c") (const_int 0))
15387 (set (match_operand:SI 0 "register_operand" "=D")
15388 (plus:SI (match_operand:SI 3 "register_operand" "0")
15389 (match_operand:SI 4 "register_operand" "1")))
15390 (set (mem:BLK (match_dup 3))
15391 (const_int 0))
15392 (use (match_operand:QI 2 "register_operand" "a"))
15393 (use (match_dup 4))
15394 (use (reg:SI 19))]
15395 "!TARGET_64BIT"
15396 "{rep\;stosb|rep stosb}"
15397 [(set_attr "type" "str")
15398 (set_attr "prefix_rep" "1")
15399 (set_attr "memory" "store")
15400 (set_attr "mode" "QI")])
15401
15402 (define_insn "rep_stosqi_rex64"
15403 [(set (match_operand:DI 1 "register_operand" "=c") (const_int 0))
15404 (set (match_operand:DI 0 "register_operand" "=D")
15405 (plus:DI (match_operand:DI 3 "register_operand" "0")
15406 (match_operand:DI 4 "register_operand" "1")))
15407 (set (mem:BLK (match_dup 3))
15408 (const_int 0))
15409 (use (match_operand:QI 2 "register_operand" "a"))
15410 (use (match_dup 4))
15411 (use (reg:DI 19))]
15412 "TARGET_64BIT"
15413 "{rep\;stosb|rep stosb}"
15414 [(set_attr "type" "str")
15415 (set_attr "prefix_rep" "1")
15416 (set_attr "memory" "store")
15417 (set_attr "mode" "QI")])
15418
15419 (define_expand "cmpstrsi"
15420 [(set (match_operand:SI 0 "register_operand" "")
15421 (compare:SI (match_operand:BLK 1 "general_operand" "")
15422 (match_operand:BLK 2 "general_operand" "")))
15423 (use (match_operand 3 "general_operand" ""))
15424 (use (match_operand 4 "immediate_operand" ""))]
15425 ""
15426 {
15427 rtx addr1, addr2, out, outlow, count, countreg, align;
15428
15429 out = operands[0];
15430 if (GET_CODE (out) != REG)
15431 out = gen_reg_rtx (SImode);
15432
15433 addr1 = copy_to_mode_reg (Pmode, XEXP (operands[1], 0));
15434 addr2 = copy_to_mode_reg (Pmode, XEXP (operands[2], 0));
15435
15436 count = operands[3];
15437 countreg = ix86_zero_extend_to_Pmode (count);
15438
15439 /* %%% Iff we are testing strict equality, we can use known alignment
15440 to good advantage. This may be possible with combine, particularly
15441 once cc0 is dead. */
15442 align = operands[4];
15443
15444 emit_insn (gen_cld ());
15445 if (GET_CODE (count) == CONST_INT)
15446 {
15447 if (INTVAL (count) == 0)
15448 {
15449 emit_move_insn (operands[0], const0_rtx);
15450 DONE;
15451 }
15452 if (TARGET_64BIT)
15453 emit_insn (gen_cmpstrqi_nz_rex_1 (addr1, addr2, countreg, align,
15454 addr1, addr2, countreg));
15455 else
15456 emit_insn (gen_cmpstrqi_nz_1 (addr1, addr2, countreg, align,
15457 addr1, addr2, countreg));
15458 }
15459 else
15460 {
15461 if (TARGET_64BIT)
15462 {
15463 emit_insn (gen_cmpdi_1_rex64 (countreg, countreg));
15464 emit_insn (gen_cmpstrqi_rex_1 (addr1, addr2, countreg, align,
15465 addr1, addr2, countreg));
15466 }
15467 else
15468 {
15469 emit_insn (gen_cmpsi_1 (countreg, countreg));
15470 emit_insn (gen_cmpstrqi_1 (addr1, addr2, countreg, align,
15471 addr1, addr2, countreg));
15472 }
15473 }
15474
15475 outlow = gen_lowpart (QImode, out);
15476 emit_insn (gen_cmpintqi (outlow));
15477 emit_move_insn (out, gen_rtx_SIGN_EXTEND (SImode, outlow));
15478
15479 if (operands[0] != out)
15480 emit_move_insn (operands[0], out);
15481
15482 DONE;
15483 })
15484
15485 ;; Produce a tri-state integer (-1, 0, 1) from condition codes.
15486
15487 (define_expand "cmpintqi"
15488 [(set (match_dup 1)
15489 (gtu:QI (reg:CC 17) (const_int 0)))
15490 (set (match_dup 2)
15491 (ltu:QI (reg:CC 17) (const_int 0)))
15492 (parallel [(set (match_operand:QI 0 "register_operand" "")
15493 (minus:QI (match_dup 1)
15494 (match_dup 2)))
15495 (clobber (reg:CC 17))])]
15496 ""
15497 "operands[1] = gen_reg_rtx (QImode);
15498 operands[2] = gen_reg_rtx (QImode);")
15499
15500 ;; memcmp recognizers. The `cmpsb' opcode does nothing if the count is
15501 ;; zero. Emit extra code to make sure that a zero-length compare is EQ.
15502
15503 (define_insn "cmpstrqi_nz_1"
15504 [(set (reg:CC 17)
15505 (compare:CC (mem:BLK (match_operand:SI 4 "register_operand" "0"))
15506 (mem:BLK (match_operand:SI 5 "register_operand" "1"))))
15507 (use (match_operand:SI 6 "register_operand" "2"))
15508 (use (match_operand:SI 3 "immediate_operand" "i"))
15509 (use (reg:SI 19))
15510 (clobber (match_operand:SI 0 "register_operand" "=S"))
15511 (clobber (match_operand:SI 1 "register_operand" "=D"))
15512 (clobber (match_operand:SI 2 "register_operand" "=c"))]
15513 "!TARGET_64BIT"
15514 "repz{\;| }cmpsb"
15515 [(set_attr "type" "str")
15516 (set_attr "mode" "QI")
15517 (set_attr "prefix_rep" "1")])
15518
15519 (define_insn "cmpstrqi_nz_rex_1"
15520 [(set (reg:CC 17)
15521 (compare:CC (mem:BLK (match_operand:DI 4 "register_operand" "0"))
15522 (mem:BLK (match_operand:DI 5 "register_operand" "1"))))
15523 (use (match_operand:DI 6 "register_operand" "2"))
15524 (use (match_operand:SI 3 "immediate_operand" "i"))
15525 (use (reg:SI 19))
15526 (clobber (match_operand:DI 0 "register_operand" "=S"))
15527 (clobber (match_operand:DI 1 "register_operand" "=D"))
15528 (clobber (match_operand:DI 2 "register_operand" "=c"))]
15529 "TARGET_64BIT"
15530 "repz{\;| }cmpsb"
15531 [(set_attr "type" "str")
15532 (set_attr "mode" "QI")
15533 (set_attr "prefix_rep" "1")])
15534
15535 ;; The same, but the count is not known to not be zero.
15536
15537 (define_insn "cmpstrqi_1"
15538 [(set (reg:CC 17)
15539 (if_then_else:CC (ne (match_operand:SI 6 "register_operand" "2")
15540 (const_int 0))
15541 (compare:CC (mem:BLK (match_operand:SI 4 "register_operand" "0"))
15542 (mem:BLK (match_operand:SI 5 "register_operand" "1")))
15543 (const_int 0)))
15544 (use (match_operand:SI 3 "immediate_operand" "i"))
15545 (use (reg:CC 17))
15546 (use (reg:SI 19))
15547 (clobber (match_operand:SI 0 "register_operand" "=S"))
15548 (clobber (match_operand:SI 1 "register_operand" "=D"))
15549 (clobber (match_operand:SI 2 "register_operand" "=c"))]
15550 "!TARGET_64BIT"
15551 "repz{\;| }cmpsb"
15552 [(set_attr "type" "str")
15553 (set_attr "mode" "QI")
15554 (set_attr "prefix_rep" "1")])
15555
15556 (define_insn "cmpstrqi_rex_1"
15557 [(set (reg:CC 17)
15558 (if_then_else:CC (ne (match_operand:DI 6 "register_operand" "2")
15559 (const_int 0))
15560 (compare:CC (mem:BLK (match_operand:DI 4 "register_operand" "0"))
15561 (mem:BLK (match_operand:DI 5 "register_operand" "1")))
15562 (const_int 0)))
15563 (use (match_operand:SI 3 "immediate_operand" "i"))
15564 (use (reg:CC 17))
15565 (use (reg:SI 19))
15566 (clobber (match_operand:DI 0 "register_operand" "=S"))
15567 (clobber (match_operand:DI 1 "register_operand" "=D"))
15568 (clobber (match_operand:DI 2 "register_operand" "=c"))]
15569 "TARGET_64BIT"
15570 "repz{\;| }cmpsb"
15571 [(set_attr "type" "str")
15572 (set_attr "mode" "QI")
15573 (set_attr "prefix_rep" "1")])
15574
15575 (define_expand "strlensi"
15576 [(set (match_operand:SI 0 "register_operand" "")
15577 (unspec:SI [(match_operand:BLK 1 "general_operand" "")
15578 (match_operand:QI 2 "immediate_operand" "")
15579 (match_operand 3 "immediate_operand" "")] 0))]
15580 ""
15581 {
15582 if (ix86_expand_strlen (operands[0], operands[1], operands[2], operands[3]))
15583 DONE;
15584 else
15585 FAIL;
15586 })
15587
15588 (define_expand "strlendi"
15589 [(set (match_operand:DI 0 "register_operand" "")
15590 (unspec:DI [(match_operand:BLK 1 "general_operand" "")
15591 (match_operand:QI 2 "immediate_operand" "")
15592 (match_operand 3 "immediate_operand" "")] 0))]
15593 ""
15594 {
15595 if (ix86_expand_strlen (operands[0], operands[1], operands[2], operands[3]))
15596 DONE;
15597 else
15598 FAIL;
15599 })
15600
15601 (define_insn "strlenqi_1"
15602 [(set (match_operand:SI 0 "register_operand" "=&c")
15603 (unspec:SI [(mem:BLK (match_operand:SI 5 "register_operand" "1"))
15604 (match_operand:QI 2 "register_operand" "a")
15605 (match_operand:SI 3 "immediate_operand" "i")
15606 (match_operand:SI 4 "register_operand" "0")] 0))
15607 (use (reg:SI 19))
15608 (clobber (match_operand:SI 1 "register_operand" "=D"))
15609 (clobber (reg:CC 17))]
15610 "!TARGET_64BIT"
15611 "repnz{\;| }scasb"
15612 [(set_attr "type" "str")
15613 (set_attr "mode" "QI")
15614 (set_attr "prefix_rep" "1")])
15615
15616 (define_insn "strlenqi_rex_1"
15617 [(set (match_operand:DI 0 "register_operand" "=&c")
15618 (unspec:DI [(mem:BLK (match_operand:DI 5 "register_operand" "1"))
15619 (match_operand:QI 2 "register_operand" "a")
15620 (match_operand:DI 3 "immediate_operand" "i")
15621 (match_operand:DI 4 "register_operand" "0")] 0))
15622 (use (reg:SI 19))
15623 (clobber (match_operand:DI 1 "register_operand" "=D"))
15624 (clobber (reg:CC 17))]
15625 "TARGET_64BIT"
15626 "repnz{\;| }scasb"
15627 [(set_attr "type" "str")
15628 (set_attr "mode" "QI")
15629 (set_attr "prefix_rep" "1")])
15630
15631 ;; Peephole optimizations to clean up after cmpstr*. This should be
15632 ;; handled in combine, but it is not currently up to the task.
15633 ;; When used for their truth value, the cmpstr* expanders generate
15634 ;; code like this:
15635 ;;
15636 ;; repz cmpsb
15637 ;; seta %al
15638 ;; setb %dl
15639 ;; cmpb %al, %dl
15640 ;; jcc label
15641 ;;
15642 ;; The intermediate three instructions are unnecessary.
15643
15644 ;; This one handles cmpstr*_nz_1...
15645 (define_peephole2
15646 [(parallel[
15647 (set (reg:CC 17)
15648 (compare:CC (mem:BLK (match_operand 4 "register_operand" ""))
15649 (mem:BLK (match_operand 5 "register_operand" ""))))
15650 (use (match_operand 6 "register_operand" ""))
15651 (use (match_operand:SI 3 "immediate_operand" ""))
15652 (use (reg:SI 19))
15653 (clobber (match_operand 0 "register_operand" ""))
15654 (clobber (match_operand 1 "register_operand" ""))
15655 (clobber (match_operand 2 "register_operand" ""))])
15656 (set (match_operand:QI 7 "register_operand" "")
15657 (gtu:QI (reg:CC 17) (const_int 0)))
15658 (set (match_operand:QI 8 "register_operand" "")
15659 (ltu:QI (reg:CC 17) (const_int 0)))
15660 (set (reg 17)
15661 (compare (match_dup 7) (match_dup 8)))
15662 ]
15663 "peep2_reg_dead_p (4, operands[7]) && peep2_reg_dead_p (4, operands[8])"
15664 [(parallel[
15665 (set (reg:CC 17)
15666 (compare:CC (mem:BLK (match_dup 4))
15667 (mem:BLK (match_dup 5))))
15668 (use (match_dup 6))
15669 (use (match_dup 3))
15670 (use (reg:SI 19))
15671 (clobber (match_dup 0))
15672 (clobber (match_dup 1))
15673 (clobber (match_dup 2))])]
15674 "")
15675
15676 ;; ...and this one handles cmpstr*_1.
15677 (define_peephole2
15678 [(parallel[
15679 (set (reg:CC 17)
15680 (if_then_else:CC (ne (match_operand 6 "register_operand" "")
15681 (const_int 0))
15682 (compare:CC (mem:BLK (match_operand 4 "register_operand" ""))
15683 (mem:BLK (match_operand 5 "register_operand" "")))
15684 (const_int 0)))
15685 (use (match_operand:SI 3 "immediate_operand" ""))
15686 (use (reg:CC 17))
15687 (use (reg:SI 19))
15688 (clobber (match_operand 0 "register_operand" ""))
15689 (clobber (match_operand 1 "register_operand" ""))
15690 (clobber (match_operand 2 "register_operand" ""))])
15691 (set (match_operand:QI 7 "register_operand" "")
15692 (gtu:QI (reg:CC 17) (const_int 0)))
15693 (set (match_operand:QI 8 "register_operand" "")
15694 (ltu:QI (reg:CC 17) (const_int 0)))
15695 (set (reg 17)
15696 (compare (match_dup 7) (match_dup 8)))
15697 ]
15698 "peep2_reg_dead_p (4, operands[7]) && peep2_reg_dead_p (4, operands[8])"
15699 [(parallel[
15700 (set (reg:CC 17)
15701 (if_then_else:CC (ne (match_dup 6)
15702 (const_int 0))
15703 (compare:CC (mem:BLK (match_dup 4))
15704 (mem:BLK (match_dup 5)))
15705 (const_int 0)))
15706 (use (match_dup 3))
15707 (use (reg:CC 17))
15708 (use (reg:SI 19))
15709 (clobber (match_dup 0))
15710 (clobber (match_dup 1))
15711 (clobber (match_dup 2))])]
15712 "")
15713
15714
15715 \f
15716 ;; Conditional move instructions.
15717
15718 (define_expand "movdicc"
15719 [(set (match_operand:DI 0 "register_operand" "")
15720 (if_then_else:DI (match_operand 1 "comparison_operator" "")
15721 (match_operand:DI 2 "general_operand" "")
15722 (match_operand:DI 3 "general_operand" "")))]
15723 "TARGET_64BIT"
15724 "if (!ix86_expand_int_movcc (operands)) FAIL; DONE;")
15725
15726 (define_insn "x86_movdicc_0_m1_rex64"
15727 [(set (match_operand:DI 0 "register_operand" "=r")
15728 (if_then_else:DI (ltu (reg:CC 17) (const_int 0))
15729 (const_int -1)
15730 (const_int 0)))
15731 (clobber (reg:CC 17))]
15732 "TARGET_64BIT"
15733 "sbb{q}\t%0, %0"
15734 ; Since we don't have the proper number of operands for an alu insn,
15735 ; fill in all the blanks.
15736 [(set_attr "type" "alu")
15737 (set_attr "memory" "none")
15738 (set_attr "imm_disp" "false")
15739 (set_attr "mode" "DI")
15740 (set_attr "length_immediate" "0")])
15741
15742 (define_insn "*movdicc_c_rex64"
15743 [(set (match_operand:DI 0 "register_operand" "=r,r")
15744 (if_then_else:DI (match_operator 1 "ix86_comparison_operator"
15745 [(reg 17) (const_int 0)])
15746 (match_operand:DI 2 "nonimmediate_operand" "rm,0")
15747 (match_operand:DI 3 "nonimmediate_operand" "0,rm")))]
15748 "TARGET_64BIT && TARGET_CMOVE
15749 && (GET_CODE (operands[2]) != MEM || GET_CODE (operands[3]) != MEM)"
15750 "@
15751 cmov%C1\t{%2, %0|%0, %2}
15752 cmov%c1\t{%3, %0|%0, %3}"
15753 [(set_attr "type" "icmov")
15754 (set_attr "mode" "DI")])
15755
15756 (define_expand "movsicc"
15757 [(set (match_operand:SI 0 "register_operand" "")
15758 (if_then_else:SI (match_operand 1 "comparison_operator" "")
15759 (match_operand:SI 2 "general_operand" "")
15760 (match_operand:SI 3 "general_operand" "")))]
15761 ""
15762 "if (!ix86_expand_int_movcc (operands)) FAIL; DONE;")
15763
15764 ;; Data flow gets confused by our desire for `sbbl reg,reg', and clearing
15765 ;; the register first winds up with `sbbl $0,reg', which is also weird.
15766 ;; So just document what we're doing explicitly.
15767
15768 (define_insn "x86_movsicc_0_m1"
15769 [(set (match_operand:SI 0 "register_operand" "=r")
15770 (if_then_else:SI (ltu (reg:CC 17) (const_int 0))
15771 (const_int -1)
15772 (const_int 0)))
15773 (clobber (reg:CC 17))]
15774 ""
15775 "sbb{l}\t%0, %0"
15776 ; Since we don't have the proper number of operands for an alu insn,
15777 ; fill in all the blanks.
15778 [(set_attr "type" "alu")
15779 (set_attr "memory" "none")
15780 (set_attr "imm_disp" "false")
15781 (set_attr "mode" "SI")
15782 (set_attr "length_immediate" "0")])
15783
15784 (define_insn "*movsicc_noc"
15785 [(set (match_operand:SI 0 "register_operand" "=r,r")
15786 (if_then_else:SI (match_operator 1 "ix86_comparison_operator"
15787 [(reg 17) (const_int 0)])
15788 (match_operand:SI 2 "nonimmediate_operand" "rm,0")
15789 (match_operand:SI 3 "nonimmediate_operand" "0,rm")))]
15790 "TARGET_CMOVE
15791 && (GET_CODE (operands[2]) != MEM || GET_CODE (operands[3]) != MEM)"
15792 "@
15793 cmov%C1\t{%2, %0|%0, %2}
15794 cmov%c1\t{%3, %0|%0, %3}"
15795 [(set_attr "type" "icmov")
15796 (set_attr "mode" "SI")])
15797
15798 (define_expand "movhicc"
15799 [(set (match_operand:HI 0 "register_operand" "")
15800 (if_then_else:HI (match_operand 1 "comparison_operator" "")
15801 (match_operand:HI 2 "nonimmediate_operand" "")
15802 (match_operand:HI 3 "nonimmediate_operand" "")))]
15803 "TARGET_CMOVE && TARGET_HIMODE_MATH"
15804 "if (!ix86_expand_int_movcc (operands)) FAIL; DONE;")
15805
15806 (define_insn "*movhicc_noc"
15807 [(set (match_operand:HI 0 "register_operand" "=r,r")
15808 (if_then_else:HI (match_operator 1 "ix86_comparison_operator"
15809 [(reg 17) (const_int 0)])
15810 (match_operand:HI 2 "nonimmediate_operand" "rm,0")
15811 (match_operand:HI 3 "nonimmediate_operand" "0,rm")))]
15812 "TARGET_CMOVE
15813 && (GET_CODE (operands[2]) != MEM || GET_CODE (operands[3]) != MEM)"
15814 "@
15815 cmov%C1\t{%2, %0|%0, %2}
15816 cmov%c1\t{%3, %0|%0, %3}"
15817 [(set_attr "type" "icmov")
15818 (set_attr "mode" "HI")])
15819
15820 (define_expand "movsfcc"
15821 [(set (match_operand:SF 0 "register_operand" "")
15822 (if_then_else:SF (match_operand 1 "comparison_operator" "")
15823 (match_operand:SF 2 "register_operand" "")
15824 (match_operand:SF 3 "register_operand" "")))]
15825 "TARGET_CMOVE"
15826 "if (! ix86_expand_fp_movcc (operands)) FAIL; DONE;")
15827
15828 (define_insn "*movsfcc_1"
15829 [(set (match_operand:SF 0 "register_operand" "=f,f,r,r")
15830 (if_then_else:SF (match_operator 1 "fcmov_comparison_operator"
15831 [(reg 17) (const_int 0)])
15832 (match_operand:SF 2 "nonimmediate_operand" "f,0,rm,0")
15833 (match_operand:SF 3 "nonimmediate_operand" "0,f,0,rm")))]
15834 "TARGET_CMOVE
15835 && (GET_CODE (operands[2]) != MEM || GET_CODE (operands[3]) != MEM)"
15836 "@
15837 fcmov%F1\t{%2, %0|%0, %2}
15838 fcmov%f1\t{%3, %0|%0, %3}
15839 cmov%C1\t{%2, %0|%0, %2}
15840 cmov%c1\t{%3, %0|%0, %3}"
15841 [(set_attr "type" "fcmov,fcmov,icmov,icmov")
15842 (set_attr "mode" "SF,SF,SI,SI")])
15843
15844 (define_expand "movdfcc"
15845 [(set (match_operand:DF 0 "register_operand" "")
15846 (if_then_else:DF (match_operand 1 "comparison_operator" "")
15847 (match_operand:DF 2 "register_operand" "")
15848 (match_operand:DF 3 "register_operand" "")))]
15849 "TARGET_CMOVE"
15850 "if (! ix86_expand_fp_movcc (operands)) FAIL; DONE;")
15851
15852 (define_insn "*movdfcc_1"
15853 [(set (match_operand:DF 0 "register_operand" "=f,f,&r,&r")
15854 (if_then_else:DF (match_operator 1 "fcmov_comparison_operator"
15855 [(reg 17) (const_int 0)])
15856 (match_operand:DF 2 "nonimmediate_operand" "f,0,rm,0")
15857 (match_operand:DF 3 "nonimmediate_operand" "0,f,0,rm")))]
15858 "!TARGET_64BIT && TARGET_CMOVE
15859 && (GET_CODE (operands[2]) != MEM || GET_CODE (operands[3]) != MEM)"
15860 "@
15861 fcmov%F1\t{%2, %0|%0, %2}
15862 fcmov%f1\t{%3, %0|%0, %3}
15863 #
15864 #"
15865 [(set_attr "type" "fcmov,fcmov,multi,multi")
15866 (set_attr "mode" "DF")])
15867
15868 (define_insn "*movdfcc_1_rex64"
15869 [(set (match_operand:DF 0 "register_operand" "=f,f,&r,&r")
15870 (if_then_else:DF (match_operator 1 "fcmov_comparison_operator"
15871 [(reg 17) (const_int 0)])
15872 (match_operand:DF 2 "nonimmediate_operand" "f,0,rm,0")
15873 (match_operand:DF 3 "nonimmediate_operand" "0,f,0,rm")))]
15874 "TARGET_64BIT && TARGET_CMOVE
15875 && (GET_CODE (operands[2]) != MEM || GET_CODE (operands[3]) != MEM)"
15876 "@
15877 fcmov%F1\t{%2, %0|%0, %2}
15878 fcmov%f1\t{%3, %0|%0, %3}
15879 cmov%C1\t{%2, %0|%0, %2}
15880 cmov%c1\t{%3, %0|%0, %3}"
15881 [(set_attr "type" "fcmov,fcmov,icmov,icmov")
15882 (set_attr "mode" "DF")])
15883
15884 (define_split
15885 [(set (match_operand:DF 0 "register_operand" "")
15886 (if_then_else:DF (match_operator 1 "fcmov_comparison_operator"
15887 [(match_operand 4 "" "") (const_int 0)])
15888 (match_operand:DF 2 "nonimmediate_operand" "")
15889 (match_operand:DF 3 "nonimmediate_operand" "")))]
15890 "!TARGET_64BIT && !ANY_FP_REG_P (operands[0]) && reload_completed"
15891 [(set (match_dup 2)
15892 (if_then_else:SI (match_op_dup 1 [(match_dup 4) (const_int 0)])
15893 (match_dup 5)
15894 (match_dup 7)))
15895 (set (match_dup 3)
15896 (if_then_else:SI (match_op_dup 1 [(match_dup 4) (const_int 0)])
15897 (match_dup 6)
15898 (match_dup 8)))]
15899 "split_di (operands+2, 1, operands+5, operands+6);
15900 split_di (operands+3, 1, operands+7, operands+8);
15901 split_di (operands, 1, operands+2, operands+3);")
15902
15903 (define_expand "movxfcc"
15904 [(set (match_operand:XF 0 "register_operand" "")
15905 (if_then_else:XF (match_operand 1 "comparison_operator" "")
15906 (match_operand:XF 2 "register_operand" "")
15907 (match_operand:XF 3 "register_operand" "")))]
15908 "!TARGET_64BIT && TARGET_CMOVE"
15909 "if (! ix86_expand_fp_movcc (operands)) FAIL; DONE;")
15910
15911 (define_expand "movtfcc"
15912 [(set (match_operand:TF 0 "register_operand" "")
15913 (if_then_else:TF (match_operand 1 "comparison_operator" "")
15914 (match_operand:TF 2 "register_operand" "")
15915 (match_operand:TF 3 "register_operand" "")))]
15916 "TARGET_CMOVE"
15917 "if (! ix86_expand_fp_movcc (operands)) FAIL; DONE;")
15918
15919 (define_insn "*movxfcc_1"
15920 [(set (match_operand:XF 0 "register_operand" "=f,f")
15921 (if_then_else:XF (match_operator 1 "fcmov_comparison_operator"
15922 [(reg 17) (const_int 0)])
15923 (match_operand:XF 2 "register_operand" "f,0")
15924 (match_operand:XF 3 "register_operand" "0,f")))]
15925 "!TARGET_64BIT && TARGET_CMOVE"
15926 "@
15927 fcmov%F1\t{%2, %0|%0, %2}
15928 fcmov%f1\t{%3, %0|%0, %3}"
15929 [(set_attr "type" "fcmov")
15930 (set_attr "mode" "XF")])
15931
15932 (define_insn "*movtfcc_1"
15933 [(set (match_operand:TF 0 "register_operand" "=f,f")
15934 (if_then_else:TF (match_operator 1 "fcmov_comparison_operator"
15935 [(reg 17) (const_int 0)])
15936 (match_operand:TF 2 "register_operand" "f,0")
15937 (match_operand:TF 3 "register_operand" "0,f")))]
15938 "TARGET_CMOVE"
15939 "@
15940 fcmov%F1\t{%2, %0|%0, %2}
15941 fcmov%f1\t{%3, %0|%0, %3}"
15942 [(set_attr "type" "fcmov")
15943 (set_attr "mode" "XF")])
15944
15945 (define_expand "minsf3"
15946 [(parallel [
15947 (set (match_operand:SF 0 "register_operand" "")
15948 (if_then_else:SF (lt (match_operand:SF 1 "register_operand" "")
15949 (match_operand:SF 2 "nonimmediate_operand" ""))
15950 (match_dup 1)
15951 (match_dup 2)))
15952 (clobber (reg:CC 17))])]
15953 "TARGET_SSE"
15954 "")
15955
15956 (define_insn "*minsf"
15957 [(set (match_operand:SF 0 "register_operand" "=x#f,f#x,f#x")
15958 (if_then_else:SF (lt (match_operand:SF 1 "register_operand" "0,0,f#x")
15959 (match_operand:SF 2 "nonimmediate_operand" "xm#f,f#x,0"))
15960 (match_dup 1)
15961 (match_dup 2)))
15962 (clobber (reg:CC 17))]
15963 "TARGET_SSE && TARGET_IEEE_FP"
15964 "#")
15965
15966 (define_insn "*minsf_nonieee"
15967 [(set (match_operand:SF 0 "register_operand" "=x#f,f#x")
15968 (if_then_else:SF (lt (match_operand:SF 1 "register_operand" "%0,0")
15969 (match_operand:SF 2 "nonimmediate_operand" "xm#f,f#x"))
15970 (match_dup 1)
15971 (match_dup 2)))
15972 (clobber (reg:CC 17))]
15973 "TARGET_SSE && !TARGET_IEEE_FP"
15974 "#")
15975
15976 (define_split
15977 [(set (match_operand:SF 0 "register_operand" "")
15978 (if_then_else:SF (lt (match_operand:SF 1 "register_operand" "")
15979 (match_operand:SF 2 "nonimmediate_operand" ""))
15980 (match_operand:SF 3 "register_operand" "")
15981 (match_operand:SF 4 "nonimmediate_operand" "")))
15982 (clobber (reg:CC 17))]
15983 "SSE_REG_P (operands[0]) && reload_completed
15984 && ((operands_match_p (operands[1], operands[3])
15985 && operands_match_p (operands[2], operands[4]))
15986 || (operands_match_p (operands[1], operands[4])
15987 && operands_match_p (operands[2], operands[3])))"
15988 [(set (match_dup 0)
15989 (if_then_else:SF (lt (match_dup 1)
15990 (match_dup 2))
15991 (match_dup 1)
15992 (match_dup 2)))])
15993
15994 ;; We can't represent the LT test directly. Do this by swapping the operands.
15995
15996 (define_split
15997 [(set (match_operand:SF 0 "register_operand" "")
15998 (if_then_else:SF (lt (match_operand:SF 1 "register_operand" "")
15999 (match_operand:SF 2 "register_operand" ""))
16000 (match_operand:DF 3 "register_operand" "")
16001 (match_operand:DF 4 "register_operand" "")))
16002 (clobber (reg:CC 17))]
16003 "FP_REG_P (operands[0]) && reload_completed
16004 && ((operands_match_p (operands[1], operands[3])
16005 && operands_match_p (operands[2], operands[4]))
16006 || (operands_match_p (operands[1], operands[4])
16007 && operands_match_p (operands[2], operands[3])))"
16008 [(set (reg:CCFP 17)
16009 (compare:CCFP (match_dup 2)
16010 (match_dup 1)))
16011 (set (match_dup 0)
16012 (if_then_else:SF (ge (reg:CCFP 17) (const_int 0))
16013 (match_dup 1)
16014 (match_dup 2)))])
16015
16016 (define_insn "*minsf_sse"
16017 [(set (match_operand:SF 0 "register_operand" "=x")
16018 (if_then_else:SF (lt (match_operand:SF 1 "register_operand" "0")
16019 (match_operand:SF 2 "nonimmediate_operand" "xm"))
16020 (match_dup 1)
16021 (match_dup 2)))]
16022 "TARGET_SSE && reload_completed"
16023 "minss\t{%2, %0|%0, %2}"
16024 [(set_attr "type" "sse")
16025 (set_attr "mode" "SF")])
16026
16027 (define_expand "mindf3"
16028 [(parallel [
16029 (set (match_operand:DF 0 "register_operand" "")
16030 (if_then_else:DF (lt (match_operand:DF 1 "register_operand" "")
16031 (match_operand:DF 2 "nonimmediate_operand" ""))
16032 (match_dup 1)
16033 (match_dup 2)))
16034 (clobber (reg:CC 17))])]
16035 "TARGET_SSE2 && TARGET_SSE_MATH"
16036 "#")
16037
16038 (define_insn "*mindf"
16039 [(set (match_operand:DF 0 "register_operand" "=Y#f,f#Y,f#Y")
16040 (if_then_else:DF (lt (match_operand:DF 1 "register_operand" "0,0,f#Y")
16041 (match_operand:DF 2 "nonimmediate_operand" "Ym#f,f#Y,0"))
16042 (match_dup 1)
16043 (match_dup 2)))
16044 (clobber (reg:CC 17))]
16045 "TARGET_SSE2 && TARGET_IEEE_FP && TARGET_SSE_MATH"
16046 "#")
16047
16048 (define_insn "*mindf_nonieee"
16049 [(set (match_operand:DF 0 "register_operand" "=Y#f,f#Y")
16050 (if_then_else:DF (lt (match_operand:DF 1 "register_operand" "%0,0")
16051 (match_operand:DF 2 "nonimmediate_operand" "Ym#f,f#Y"))
16052 (match_dup 1)
16053 (match_dup 2)))
16054 (clobber (reg:CC 17))]
16055 "TARGET_SSE2 && TARGET_SSE_MATH && !TARGET_IEEE_FP"
16056 "#")
16057
16058 (define_split
16059 [(set (match_operand:DF 0 "register_operand" "")
16060 (if_then_else:DF (lt (match_operand:DF 1 "register_operand" "")
16061 (match_operand:DF 2 "nonimmediate_operand" ""))
16062 (match_operand:DF 3 "register_operand" "")
16063 (match_operand:DF 4 "nonimmediate_operand" "")))
16064 (clobber (reg:CC 17))]
16065 "SSE_REG_P (operands[0]) && reload_completed
16066 && ((operands_match_p (operands[1], operands[3])
16067 && operands_match_p (operands[2], operands[4]))
16068 || (operands_match_p (operands[1], operands[4])
16069 && operands_match_p (operands[2], operands[3])))"
16070 [(set (match_dup 0)
16071 (if_then_else:DF (lt (match_dup 1)
16072 (match_dup 2))
16073 (match_dup 1)
16074 (match_dup 2)))])
16075
16076 ;; We can't represent the LT test directly. Do this by swapping the operands.
16077 (define_split
16078 [(set (match_operand:DF 0 "register_operand" "")
16079 (if_then_else:DF (lt (match_operand:DF 1 "register_operand" "")
16080 (match_operand:DF 2 "register_operand" ""))
16081 (match_operand:DF 3 "register_operand" "")
16082 (match_operand:DF 4 "register_operand" "")))
16083 (clobber (reg:CC 17))]
16084 "FP_REG_P (operands[0]) && reload_completed
16085 && ((operands_match_p (operands[1], operands[3])
16086 && operands_match_p (operands[2], operands[4]))
16087 || (operands_match_p (operands[1], operands[4])
16088 && operands_match_p (operands[2], operands[3])))"
16089 [(set (reg:CCFP 17)
16090 (compare:CCFP (match_dup 2)
16091 (match_dup 2)))
16092 (set (match_dup 0)
16093 (if_then_else:DF (ge (reg:CCFP 17) (const_int 0))
16094 (match_dup 1)
16095 (match_dup 2)))])
16096
16097 (define_insn "*mindf_sse"
16098 [(set (match_operand:DF 0 "register_operand" "=Y")
16099 (if_then_else:DF (lt (match_operand:DF 1 "register_operand" "0")
16100 (match_operand:DF 2 "nonimmediate_operand" "Ym"))
16101 (match_dup 1)
16102 (match_dup 2)))]
16103 "TARGET_SSE2 && TARGET_SSE_MATH && reload_completed"
16104 "minsd\t{%2, %0|%0, %2}"
16105 [(set_attr "type" "sse")
16106 (set_attr "mode" "DF")])
16107
16108 (define_expand "maxsf3"
16109 [(parallel [
16110 (set (match_operand:SF 0 "register_operand" "")
16111 (if_then_else:SF (gt (match_operand:SF 1 "register_operand" "")
16112 (match_operand:SF 2 "nonimmediate_operand" ""))
16113 (match_dup 1)
16114 (match_dup 2)))
16115 (clobber (reg:CC 17))])]
16116 "TARGET_SSE"
16117 "#")
16118
16119 (define_insn "*maxsf"
16120 [(set (match_operand:SF 0 "register_operand" "=x#f,f#x,f#x")
16121 (if_then_else:SF (gt (match_operand:SF 1 "register_operand" "0,0,f#x")
16122 (match_operand:SF 2 "nonimmediate_operand" "xm#f,f#x,0"))
16123 (match_dup 1)
16124 (match_dup 2)))
16125 (clobber (reg:CC 17))]
16126 "TARGET_SSE && TARGET_IEEE_FP"
16127 "#")
16128
16129 (define_insn "*maxsf_nonieee"
16130 [(set (match_operand:SF 0 "register_operand" "=x#f,f#x")
16131 (if_then_else:SF (gt (match_operand:SF 1 "register_operand" "%0,0")
16132 (match_operand:SF 2 "nonimmediate_operand" "xm#f,f#x"))
16133 (match_dup 1)
16134 (match_dup 2)))
16135 (clobber (reg:CC 17))]
16136 "TARGET_SSE && !TARGET_IEEE_FP"
16137 "#")
16138
16139 (define_split
16140 [(set (match_operand:SF 0 "register_operand" "")
16141 (if_then_else:SF (gt (match_operand:SF 1 "register_operand" "")
16142 (match_operand:SF 2 "nonimmediate_operand" ""))
16143 (match_operand:SF 3 "register_operand" "")
16144 (match_operand:SF 4 "nonimmediate_operand" "")))
16145 (clobber (reg:CC 17))]
16146 "SSE_REG_P (operands[0]) && reload_completed
16147 && ((operands_match_p (operands[1], operands[3])
16148 && operands_match_p (operands[2], operands[4]))
16149 || (operands_match_p (operands[1], operands[4])
16150 && operands_match_p (operands[2], operands[3])))"
16151 [(set (match_dup 0)
16152 (if_then_else:SF (gt (match_dup 1)
16153 (match_dup 2))
16154 (match_dup 1)
16155 (match_dup 2)))])
16156
16157 (define_split
16158 [(set (match_operand:SF 0 "register_operand" "")
16159 (if_then_else:SF (gt (match_operand:SF 1 "register_operand" "")
16160 (match_operand:SF 2 "register_operand" ""))
16161 (match_operand:SF 3 "register_operand" "")
16162 (match_operand:SF 4 "register_operand" "")))
16163 (clobber (reg:CC 17))]
16164 "FP_REG_P (operands[0]) && reload_completed
16165 && ((operands_match_p (operands[1], operands[3])
16166 && operands_match_p (operands[2], operands[4]))
16167 || (operands_match_p (operands[1], operands[4])
16168 && operands_match_p (operands[2], operands[3])))"
16169 [(set (reg:CCFP 17)
16170 (compare:CCFP (match_dup 1)
16171 (match_dup 2)))
16172 (set (match_dup 0)
16173 (if_then_else:SF (gt (reg:CCFP 17) (const_int 0))
16174 (match_dup 1)
16175 (match_dup 2)))])
16176
16177 (define_insn "*maxsf_sse"
16178 [(set (match_operand:SF 0 "register_operand" "=x")
16179 (if_then_else:SF (gt (match_operand:SF 1 "register_operand" "0")
16180 (match_operand:SF 2 "nonimmediate_operand" "xm"))
16181 (match_dup 1)
16182 (match_dup 2)))]
16183 "TARGET_SSE && reload_completed"
16184 "maxss\t{%2, %0|%0, %2}"
16185 [(set_attr "type" "sse")
16186 (set_attr "mode" "SF")])
16187
16188 (define_expand "maxdf3"
16189 [(parallel [
16190 (set (match_operand:DF 0 "register_operand" "")
16191 (if_then_else:DF (gt (match_operand:DF 1 "register_operand" "")
16192 (match_operand:DF 2 "nonimmediate_operand" ""))
16193 (match_dup 1)
16194 (match_dup 2)))
16195 (clobber (reg:CC 17))])]
16196 "TARGET_SSE2 && TARGET_SSE_MATH"
16197 "#")
16198
16199 (define_insn "*maxdf"
16200 [(set (match_operand:DF 0 "register_operand" "=Y#f,f#Y,f#Y")
16201 (if_then_else:DF (gt (match_operand:DF 1 "register_operand" "0,0,f#Y")
16202 (match_operand:DF 2 "nonimmediate_operand" "Ym#f,f#Y,0"))
16203 (match_dup 1)
16204 (match_dup 2)))
16205 (clobber (reg:CC 17))]
16206 "TARGET_SSE2 && TARGET_SSE_MATH && TARGET_IEEE_FP"
16207 "#")
16208
16209 (define_insn "*maxdf_nonieee"
16210 [(set (match_operand:DF 0 "register_operand" "=Y#f,f#Y")
16211 (if_then_else:DF (gt (match_operand:DF 1 "register_operand" "%0,0")
16212 (match_operand:DF 2 "nonimmediate_operand" "Ym#f,f#Y"))
16213 (match_dup 1)
16214 (match_dup 2)))
16215 (clobber (reg:CC 17))]
16216 "TARGET_SSE2 && TARGET_SSE_MATH && !TARGET_IEEE_FP"
16217 "#")
16218
16219 (define_split
16220 [(set (match_operand:DF 0 "register_operand" "")
16221 (if_then_else:DF (gt (match_operand:DF 1 "register_operand" "")
16222 (match_operand:DF 2 "nonimmediate_operand" ""))
16223 (match_operand:DF 3 "register_operand" "")
16224 (match_operand:DF 4 "nonimmediate_operand" "")))
16225 (clobber (reg:CC 17))]
16226 "SSE_REG_P (operands[0]) && reload_completed
16227 && ((operands_match_p (operands[1], operands[3])
16228 && operands_match_p (operands[2], operands[4]))
16229 || (operands_match_p (operands[1], operands[4])
16230 && operands_match_p (operands[2], operands[3])))"
16231 [(set (match_dup 0)
16232 (if_then_else:DF (gt (match_dup 1)
16233 (match_dup 2))
16234 (match_dup 1)
16235 (match_dup 2)))])
16236
16237 (define_split
16238 [(set (match_operand:DF 0 "register_operand" "")
16239 (if_then_else:DF (gt (match_operand:DF 1 "register_operand" "")
16240 (match_operand:DF 2 "register_operand" ""))
16241 (match_operand:DF 3 "register_operand" "")
16242 (match_operand:DF 4 "register_operand" "")))
16243 (clobber (reg:CC 17))]
16244 "FP_REG_P (operands[0]) && reload_completed
16245 && ((operands_match_p (operands[1], operands[3])
16246 && operands_match_p (operands[2], operands[4]))
16247 || (operands_match_p (operands[1], operands[4])
16248 && operands_match_p (operands[2], operands[3])))"
16249 [(set (reg:CCFP 17)
16250 (compare:CCFP (match_dup 1)
16251 (match_dup 2)))
16252 (set (match_dup 0)
16253 (if_then_else:DF (gt (reg:CCFP 17) (const_int 0))
16254 (match_dup 1)
16255 (match_dup 2)))])
16256
16257 (define_insn "*maxdf_sse"
16258 [(set (match_operand:DF 0 "register_operand" "=Y")
16259 (if_then_else:DF (gt (match_operand:DF 1 "register_operand" "0")
16260 (match_operand:DF 2 "nonimmediate_operand" "Ym"))
16261 (match_dup 1)
16262 (match_dup 2)))]
16263 "TARGET_SSE2 && TARGET_SSE_MATH && reload_completed"
16264 "maxsd\t{%2, %0|%0, %2}"
16265 [(set_attr "type" "sse")
16266 (set_attr "mode" "DF")])
16267 \f
16268 ;; Misc patterns (?)
16269
16270 ;; This pattern exists to put a dependency on all ebp-based memory accesses.
16271 ;; Otherwise there will be nothing to keep
16272 ;;
16273 ;; [(set (reg ebp) (reg esp))]
16274 ;; [(set (reg esp) (plus (reg esp) (const_int -160000)))
16275 ;; (clobber (eflags)]
16276 ;; [(set (mem (plus (reg ebp) (const_int -160000))) (const_int 0))]
16277 ;;
16278 ;; in proper program order.
16279 (define_expand "pro_epilogue_adjust_stack"
16280 [(parallel [(set (match_operand:SI 0 "register_operand" "=r,r")
16281 (plus:SI (match_operand:SI 1 "register_operand" "0,r")
16282 (match_operand:SI 2 "immediate_operand" "i,i")))
16283 (clobber (reg:CC 17))
16284 (clobber (mem:BLK (scratch)))])]
16285 ""
16286 {
16287 if (TARGET_64BIT)
16288 {
16289 emit_insn (gen_pro_epilogue_adjust_stack_rex64
16290 (operands[0], operands[1], operands[2]));
16291 DONE;
16292 }
16293 })
16294
16295 (define_insn "*pro_epilogue_adjust_stack_1"
16296 [(set (match_operand:SI 0 "register_operand" "=r,r")
16297 (plus:SI (match_operand:SI 1 "register_operand" "0,r")
16298 (match_operand:SI 2 "immediate_operand" "i,i")))
16299 (clobber (reg:CC 17))
16300 (clobber (mem:BLK (scratch)))]
16301 "!TARGET_64BIT"
16302 {
16303 switch (get_attr_type (insn))
16304 {
16305 case TYPE_IMOV:
16306 return "mov{l}\t{%1, %0|%0, %1}";
16307
16308 case TYPE_ALU:
16309 if (GET_CODE (operands[2]) == CONST_INT
16310 && (INTVAL (operands[2]) == 128
16311 || (INTVAL (operands[2]) < 0
16312 && INTVAL (operands[2]) != -128)))
16313 {
16314 operands[2] = GEN_INT (-INTVAL (operands[2]));
16315 return "sub{l}\t{%2, %0|%0, %2}";
16316 }
16317 return "add{l}\t{%2, %0|%0, %2}";
16318
16319 case TYPE_LEA:
16320 operands[2] = SET_SRC (XVECEXP (PATTERN (insn), 0, 0));
16321 return "lea{l}\t{%a2, %0|%0, %a2}";
16322
16323 default:
16324 abort ();
16325 }
16326 }
16327 [(set (attr "type")
16328 (cond [(eq_attr "alternative" "0")
16329 (const_string "alu")
16330 (match_operand:SI 2 "const0_operand" "")
16331 (const_string "imov")
16332 ]
16333 (const_string "lea")))
16334 (set_attr "mode" "SI")])
16335
16336 (define_insn "pro_epilogue_adjust_stack_rex64"
16337 [(set (match_operand:DI 0 "register_operand" "=r,r")
16338 (plus:DI (match_operand:DI 1 "register_operand" "0,r")
16339 (match_operand:DI 2 "x86_64_immediate_operand" "e,e")))
16340 (clobber (reg:CC 17))
16341 (clobber (mem:BLK (scratch)))]
16342 "TARGET_64BIT"
16343 {
16344 switch (get_attr_type (insn))
16345 {
16346 case TYPE_IMOV:
16347 return "mov{q}\t{%1, %0|%0, %1}";
16348
16349 case TYPE_ALU:
16350 if (GET_CODE (operands[2]) == CONST_INT
16351 && (INTVAL (operands[2]) == 128
16352 || (INTVAL (operands[2]) < 0
16353 && INTVAL (operands[2]) != -128)))
16354 {
16355 operands[2] = GEN_INT (-INTVAL (operands[2]));
16356 return "sub{q}\t{%2, %0|%0, %2}";
16357 }
16358 return "add{q}\t{%2, %0|%0, %2}";
16359
16360 case TYPE_LEA:
16361 operands[2] = SET_SRC (XVECEXP (PATTERN (insn), 0, 0));
16362 return "lea{q}\t{%a2, %0|%0, %a2}";
16363
16364 default:
16365 abort ();
16366 }
16367 }
16368 [(set (attr "type")
16369 (cond [(eq_attr "alternative" "0")
16370 (const_string "alu")
16371 (match_operand:DI 2 "const0_operand" "")
16372 (const_string "imov")
16373 ]
16374 (const_string "lea")))
16375 (set_attr "mode" "DI")])
16376
16377
16378 ;; Placeholder for the conditional moves. This one is split either to SSE
16379 ;; based moves emulation or to usual cmove sequence. Little bit unfortunate
16380 ;; fact is that compares supported by the cmp??ss instructions are exactly
16381 ;; swapped of those supported by cmove sequence.
16382 ;; The EQ/NE comparisons also needs bit care, since they are not directly
16383 ;; supported by i387 comparisons and we do need to emit two conditional moves
16384 ;; in tandem.
16385
16386 (define_insn "sse_movsfcc"
16387 [(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")
16388 (if_then_else:SF (match_operator 1 "sse_comparison_operator"
16389 [(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")
16390 (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")])
16391 (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")
16392 (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")))
16393 (clobber (match_scratch:SF 6 "=2,&4,X,X,X,X,X,X,X,X"))
16394 (clobber (reg:CC 17))]
16395 "TARGET_SSE
16396 && (GET_CODE (operands[2]) != MEM || GET_CODE (operands[3]) != MEM)
16397 && (!TARGET_IEEE_FP
16398 || (GET_CODE (operands[1]) != EQ && GET_CODE (operands[1]) != NE))"
16399 "#")
16400
16401 (define_insn "sse_movsfcc_eq"
16402 [(set (match_operand:SF 0 "register_operand" "=&x#rf,x#rf,?f#xr,?f#xr,?r#xf,?r#xf")
16403 (if_then_else:SF (eq (match_operand:SF 3 "nonimmediate_operand" "%0#fx,x#fx,f#x,xm#f,f#x,xm#f")
16404 (match_operand:SF 4 "nonimmediate_operand" "xm#f,xm#f,f#x,x#f,f#x,x#f"))
16405 (match_operand:SF 1 "nonimmediate_operand" "x#fr,0#fr,0#fx,0#fx,0#rx,0#rx")
16406 (match_operand:SF 2 "nonimmediate_operand" "x#fr,x#fr,f#fx,f#fx,rm#rx,rm#rx")))
16407 (clobber (match_scratch:SF 5 "=1,&3,X,X,X,X"))
16408 (clobber (reg:CC 17))]
16409 "TARGET_SSE
16410 && (GET_CODE (operands[2]) != MEM || GET_CODE (operands[3]) != MEM)"
16411 "#")
16412
16413 (define_insn "sse_movdfcc"
16414 [(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")
16415 (if_then_else:DF (match_operator 1 "sse_comparison_operator"
16416 [(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")
16417 (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")])
16418 (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")
16419 (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")))
16420 (clobber (match_scratch:DF 6 "=2,&4,X,X,X,X,X,X,X,X"))
16421 (clobber (reg:CC 17))]
16422 "TARGET_SSE2
16423 && (GET_CODE (operands[2]) != MEM || GET_CODE (operands[3]) != MEM)
16424 && (!TARGET_IEEE_FP
16425 || (GET_CODE (operands[1]) != EQ && GET_CODE (operands[1]) != NE))"
16426 "#")
16427
16428 (define_insn "sse_movdfcc_eq"
16429 [(set (match_operand:DF 0 "register_operand" "=&x#rf,x#rf,?f#xr,?f#xr,?r#xf,?r#xf")
16430 (if_then_else:DF (eq (match_operand:DF 3 "nonimmediate_operand" "%0#fx,x#fx,f#x,xm#f,f#x,xm#f")
16431 (match_operand:DF 4 "nonimmediate_operand" "xm#f,xm#f,f#x,x#f,f#x,x#f"))
16432 (match_operand:DF 1 "nonimmediate_operand" "x#fr,0#fr,0#fx,0#fx,0#rx,0#rx")
16433 (match_operand:DF 2 "nonimmediate_operand" "x#fr,x#fr,f#fx,f#fx,rm#rx,rm#rx")))
16434 (clobber (match_scratch:DF 5 "=1,&3,X,X,X,X"))
16435 (clobber (reg:CC 17))]
16436 "TARGET_SSE
16437 && (GET_CODE (operands[2]) != MEM || GET_CODE (operands[3]) != MEM)"
16438 "#")
16439
16440 ;; For non-sse moves just expand the usual cmove sequence.
16441 (define_split
16442 [(set (match_operand 0 "register_operand" "")
16443 (if_then_else (match_operator 1 "comparison_operator"
16444 [(match_operand 4 "nonimmediate_operand" "")
16445 (match_operand 5 "register_operand" "")])
16446 (match_operand 2 "nonimmediate_operand" "")
16447 (match_operand 3 "nonimmediate_operand" "")))
16448 (clobber (match_operand 6 "" ""))
16449 (clobber (reg:CC 17))]
16450 "!SSE_REG_P (operands[0]) && reload_completed
16451 && VALID_SSE_REG_MODE (GET_MODE (operands[0]))"
16452 [(const_int 0)]
16453 {
16454 ix86_compare_op0 = operands[5];
16455 ix86_compare_op1 = operands[4];
16456 operands[1] = gen_rtx_fmt_ee (swap_condition (GET_CODE (operands[1])),
16457 VOIDmode, operands[5], operands[4]);
16458 ix86_expand_fp_movcc (operands);
16459 DONE;
16460 })
16461
16462 ;; Split SSE based conditional move into seqence:
16463 ;; cmpCC op0, op4 - set op0 to 0 or ffffffff depending on the comparison
16464 ;; and op2, op0 - zero op2 if comparison was false
16465 ;; nand op0, op3 - load op3 to op0 if comparison was false
16466 ;; or op2, op0 - get the non-zero one into the result.
16467 (define_split
16468 [(set (match_operand 0 "register_operand" "")
16469 (if_then_else (match_operator 1 "sse_comparison_operator"
16470 [(match_operand 4 "register_operand" "")
16471 (match_operand 5 "nonimmediate_operand" "")])
16472 (match_operand 2 "register_operand" "")
16473 (match_operand 3 "register_operand" "")))
16474 (clobber (match_operand 6 "" ""))
16475 (clobber (reg:CC 17))]
16476 "SSE_REG_P (operands[0]) && reload_completed"
16477 [(set (match_dup 4) (match_op_dup 1 [(match_dup 4) (match_dup 5)]))
16478 (set (subreg:TI (match_dup 2) 0) (and:TI (subreg:TI (match_dup 2) 0)
16479 (subreg:TI (match_dup 4) 0)))
16480 (set (subreg:TI (match_dup 4) 0) (and:TI (not:TI (subreg:TI (match_dup 4) 0))
16481 (subreg:TI (match_dup 3) 0)))
16482 (set (subreg:TI (match_dup 0) 0) (ior:TI (subreg:TI (match_dup 6) 0)
16483 (subreg:TI (match_dup 7) 0)))]
16484 {
16485 PUT_MODE (operands[1], GET_MODE (operands[0]));
16486 if (operands_match_p (operands[0], operands[4]))
16487 operands[6] = operands[4], operands[7] = operands[2];
16488 else
16489 operands[6] = operands[2], operands[7] = operands[4];
16490 })
16491
16492 ;; Special case of conditional move we can handle effectivly.
16493 ;; Do not brother with the integer/floating point case, since these are
16494 ;; bot considerably slower, unlike in the generic case.
16495 (define_insn "*sse_movsfcc_const0_1"
16496 [(set (match_operand:SF 0 "register_operand" "=x")
16497 (if_then_else:SF (match_operator 1 "sse_comparison_operator"
16498 [(match_operand:SF 4 "register_operand" "0")
16499 (match_operand:SF 5 "nonimmediate_operand" "xm")])
16500 (match_operand:SF 2 "register_operand" "x")
16501 (match_operand:SF 3 "const0_operand" "X")))]
16502 "TARGET_SSE"
16503 "#")
16504
16505 (define_insn "*sse_movsfcc_const0_2"
16506 [(set (match_operand:SF 0 "register_operand" "=x")
16507 (if_then_else:SF (match_operator 1 "sse_comparison_operator"
16508 [(match_operand:SF 4 "register_operand" "0")
16509 (match_operand:SF 5 "nonimmediate_operand" "xm")])
16510 (match_operand:SF 2 "const0_operand" "X")
16511 (match_operand:SF 3 "register_operand" "x")))]
16512 "TARGET_SSE"
16513 "#")
16514
16515 (define_insn "*sse_movsfcc_const0_3"
16516 [(set (match_operand:SF 0 "register_operand" "=x")
16517 (if_then_else:SF (match_operator 1 "fcmov_comparison_operator"
16518 [(match_operand:SF 4 "nonimmediate_operand" "xm")
16519 (match_operand:SF 5 "register_operand" "0")])
16520 (match_operand:SF 2 "register_operand" "x")
16521 (match_operand:SF 3 "const0_operand" "X")))]
16522 "TARGET_SSE"
16523 "#")
16524
16525 (define_insn "*sse_movsfcc_const0_4"
16526 [(set (match_operand:SF 0 "register_operand" "=x")
16527 (if_then_else:SF (match_operator 1 "fcmov_comparison_operator"
16528 [(match_operand:SF 4 "nonimmediate_operand" "xm")
16529 (match_operand:SF 5 "register_operand" "0")])
16530 (match_operand:SF 2 "const0_operand" "X")
16531 (match_operand:SF 3 "register_operand" "x")))]
16532 "TARGET_SSE"
16533 "#")
16534
16535 (define_insn "*sse_movdfcc_const0_1"
16536 [(set (match_operand:SF 0 "register_operand" "=x")
16537 (if_then_else:SF (match_operator 1 "sse_comparison_operator"
16538 [(match_operand:SF 4 "register_operand" "0")
16539 (match_operand:SF 5 "nonimmediate_operand" "xm")])
16540 (match_operand:SF 2 "register_operand" "x")
16541 (match_operand:SF 3 "const0_operand" "X")))]
16542 "TARGET_SSE2"
16543 "#")
16544
16545 (define_insn "*sse_movdfcc_const0_2"
16546 [(set (match_operand:SF 0 "register_operand" "=x")
16547 (if_then_else:SF (match_operator 1 "sse_comparison_operator"
16548 [(match_operand:SF 4 "register_operand" "0")
16549 (match_operand:SF 5 "nonimmediate_operand" "xm")])
16550 (match_operand:SF 2 "const0_operand" "X")
16551 (match_operand:SF 3 "register_operand" "x")))]
16552 "TARGET_SSE2"
16553 "#")
16554
16555 (define_insn "*sse_movdfcc_const0_3"
16556 [(set (match_operand:SF 0 "register_operand" "=x")
16557 (if_then_else:SF (match_operator 1 "fcmov_comparison_operator"
16558 [(match_operand:SF 4 "nonimmediate_operand" "xm")
16559 (match_operand:SF 5 "register_operand" "0")])
16560 (match_operand:SF 2 "register_operand" "x")
16561 (match_operand:SF 3 "const0_operand" "X")))]
16562 "TARGET_SSE2"
16563 "#")
16564
16565 (define_insn "*sse_movdfcc_const0_4"
16566 [(set (match_operand:SF 0 "register_operand" "=x")
16567 (if_then_else:SF (match_operator 1 "fcmov_comparison_operator"
16568 [(match_operand:SF 4 "nonimmediate_operand" "xm")
16569 (match_operand:SF 5 "register_operand" "0")])
16570 (match_operand:SF 2 "const0_operand" "X")
16571 (match_operand:SF 3 "register_operand" "x")))]
16572 "TARGET_SSE2"
16573 "#")
16574
16575 (define_split
16576 [(set (match_operand 0 "register_operand" "")
16577 (if_then_else (match_operator 1 "comparison_operator"
16578 [(match_operand 4 "register_operand" "")
16579 (match_operand 5 "nonimmediate_operand" "")])
16580 (match_operand 2 "nonmemory_operand" "")
16581 (match_operand 3 "nonmemory_operand" "")))]
16582 "SSE_REG_P (operands[0]) && reload_completed
16583 && (const0_operand (operands[2], GET_MODE (operands[0]))
16584 || const0_operand (operands[3], GET_MODE (operands[0])))"
16585 [(set (match_dup 0) (match_op_dup 1 [(match_dup 0) (match_dup 5)]))
16586 (set (subreg:TI (match_dup 0) 0) (and:TI (match_dup 6)
16587 (subreg:TI (match_dup 7) 0)))]
16588 {
16589 PUT_MODE (operands[1], GET_MODE (operands[0]));
16590 if (!sse_comparison_operator (operands[1], VOIDmode))
16591 {
16592 rtx tmp = operands[5];
16593 operands[5] = operands[4];
16594 operands[4] = tmp;
16595 PUT_CODE (operands[1], swap_condition (GET_CODE (operands[1])));
16596 }
16597 if (const0_operand (operands[2], GET_MODE (operands[0])))
16598 {
16599 operands[7] = operands[3];
16600 operands[6] = gen_rtx_NOT (TImode, gen_rtx_SUBREG (TImode, operands[0],
16601 0));
16602 }
16603 else
16604 {
16605 operands[7] = operands[2];
16606 operands[6] = gen_rtx_SUBREG (TImode, operands[0], 0);
16607 }
16608 })
16609
16610 (define_expand "allocate_stack_worker"
16611 [(match_operand:SI 0 "register_operand" "")]
16612 "TARGET_STACK_PROBE"
16613 {
16614 if (TARGET_64BIT)
16615 emit_insn (gen_allocate_stack_worker_rex64 (operands[0]));
16616 else
16617 emit_insn (gen_allocate_stack_worker_1 (operands[0]));
16618 DONE;
16619 })
16620
16621 (define_insn "allocate_stack_worker_1"
16622 [(unspec:SI [(match_operand:SI 0 "register_operand" "a")] 3)
16623 (set (reg:SI 7) (minus:SI (reg:SI 7) (match_dup 0)))
16624 (clobber (match_dup 0))
16625 (clobber (reg:CC 17))]
16626 "!TARGET_64BIT && TARGET_STACK_PROBE"
16627 "call\t__alloca"
16628 [(set_attr "type" "multi")
16629 (set_attr "length" "5")])
16630
16631 (define_insn "allocate_stack_worker_rex64"
16632 [(unspec:DI [(match_operand:DI 0 "register_operand" "a")] 3)
16633 (set (reg:DI 7) (minus:DI (reg:DI 7) (match_dup 0)))
16634 (clobber (match_dup 0))
16635 (clobber (reg:CC 17))]
16636 "TARGET_64BIT && TARGET_STACK_PROBE"
16637 "call\t__alloca"
16638 [(set_attr "type" "multi")
16639 (set_attr "length" "5")])
16640
16641 (define_expand "allocate_stack"
16642 [(parallel [(set (match_operand:SI 0 "register_operand" "=r")
16643 (minus:SI (reg:SI 7)
16644 (match_operand:SI 1 "general_operand" "")))
16645 (clobber (reg:CC 17))])
16646 (parallel [(set (reg:SI 7)
16647 (minus:SI (reg:SI 7) (match_dup 1)))
16648 (clobber (reg:CC 17))])]
16649 "TARGET_STACK_PROBE"
16650 {
16651 #ifdef CHECK_STACK_LIMIT
16652 if (GET_CODE (operands[1]) == CONST_INT
16653 && INTVAL (operands[1]) < CHECK_STACK_LIMIT)
16654 emit_insn (gen_subsi3 (stack_pointer_rtx, stack_pointer_rtx,
16655 operands[1]));
16656 else
16657 #endif
16658 emit_insn (gen_allocate_stack_worker (copy_to_mode_reg (SImode,
16659 operands[1])));
16660
16661 emit_move_insn (operands[0], virtual_stack_dynamic_rtx);
16662 DONE;
16663 })
16664
16665 (define_expand "builtin_setjmp_receiver"
16666 [(label_ref (match_operand 0 "" ""))]
16667 "!TARGET_64BIT && flag_pic"
16668 {
16669 load_pic_register ();
16670 DONE;
16671 })
16672 \f
16673 ;; Avoid redundant prefixes by splitting HImode arithmetic to SImode.
16674
16675 (define_split
16676 [(set (match_operand 0 "register_operand" "")
16677 (match_operator 3 "promotable_binary_operator"
16678 [(match_operand 1 "register_operand" "")
16679 (match_operand 2 "aligned_operand" "")]))
16680 (clobber (reg:CC 17))]
16681 "! TARGET_PARTIAL_REG_STALL && reload_completed
16682 && ((GET_MODE (operands[0]) == HImode
16683 && (!optimize_size || GET_CODE (operands[2]) != CONST_INT
16684 || CONST_OK_FOR_LETTER_P (INTVAL (operands[2]), 'K')))
16685 || (GET_MODE (operands[0]) == QImode
16686 && (TARGET_PROMOTE_QImode || optimize_size)))"
16687 [(parallel [(set (match_dup 0)
16688 (match_op_dup 3 [(match_dup 1) (match_dup 2)]))
16689 (clobber (reg:CC 17))])]
16690 "operands[0] = gen_lowpart (SImode, operands[0]);
16691 operands[1] = gen_lowpart (SImode, operands[1]);
16692 if (GET_CODE (operands[3]) != ASHIFT)
16693 operands[2] = gen_lowpart (SImode, operands[2]);
16694 PUT_MODE (operands[3], SImode);")
16695
16696 (define_split
16697 [(set (reg 17)
16698 (compare (and (match_operand 1 "aligned_operand" "")
16699 (match_operand 2 "const_int_operand" ""))
16700 (const_int 0)))
16701 (set (match_operand 0 "register_operand" "")
16702 (and (match_dup 1) (match_dup 2)))]
16703 "! TARGET_PARTIAL_REG_STALL && reload_completed
16704 && ix86_match_ccmode (insn, CCNOmode)
16705 && (GET_MODE (operands[0]) == HImode
16706 || (GET_MODE (operands[0]) == QImode
16707 && (TARGET_PROMOTE_QImode || optimize_size)))"
16708 [(parallel [(set (reg:CCNO 17)
16709 (compare:CCNO (and:SI (match_dup 1) (match_dup 2))
16710 (const_int 0)))
16711 (set (match_dup 0)
16712 (and:SI (match_dup 1) (match_dup 2)))])]
16713 "operands[2]
16714 = GEN_INT (trunc_int_for_mode (INTVAL (operands[2])
16715 & GET_MODE_MASK (GET_MODE (operands[0])),
16716 SImode));
16717 operands[0] = gen_lowpart (SImode, operands[0]);
16718 operands[1] = gen_lowpart (SImode, operands[1]);")
16719
16720 (define_split
16721 [(set (reg 17)
16722 (compare (and (match_operand 0 "aligned_operand" "")
16723 (match_operand 1 "const_int_operand" ""))
16724 (const_int 0)))]
16725 "! TARGET_PARTIAL_REG_STALL && reload_completed
16726 && ix86_match_ccmode (insn, CCNOmode)
16727 && (GET_MODE (operands[0]) == HImode
16728 || (GET_MODE (operands[0]) == QImode
16729 && (TARGET_PROMOTE_QImode || optimize_size)))"
16730 [(set (reg:CCNO 17)
16731 (compare:CCNO (and:SI (match_dup 0) (match_dup 1))
16732 (const_int 0)))]
16733 "operands[1]
16734 = GEN_INT (trunc_int_for_mode (INTVAL (operands[1])
16735 & GET_MODE_MASK (GET_MODE (operands[0])),
16736 SImode));
16737 operands[0] = gen_lowpart (SImode, operands[0]);")
16738
16739 (define_split
16740 [(set (match_operand 0 "register_operand" "")
16741 (neg (match_operand 1 "register_operand" "")))
16742 (clobber (reg:CC 17))]
16743 "! TARGET_PARTIAL_REG_STALL && reload_completed
16744 && (GET_MODE (operands[0]) == HImode
16745 || (GET_MODE (operands[0]) == QImode
16746 && (TARGET_PROMOTE_QImode || optimize_size)))"
16747 [(parallel [(set (match_dup 0)
16748 (neg:SI (match_dup 1)))
16749 (clobber (reg:CC 17))])]
16750 "operands[0] = gen_lowpart (SImode, operands[0]);
16751 operands[1] = gen_lowpart (SImode, operands[1]);")
16752
16753 (define_split
16754 [(set (match_operand 0 "register_operand" "")
16755 (not (match_operand 1 "register_operand" "")))]
16756 "! TARGET_PARTIAL_REG_STALL && reload_completed
16757 && (GET_MODE (operands[0]) == HImode
16758 || (GET_MODE (operands[0]) == QImode
16759 && (TARGET_PROMOTE_QImode || optimize_size)))"
16760 [(set (match_dup 0)
16761 (not:SI (match_dup 1)))]
16762 "operands[0] = gen_lowpart (SImode, operands[0]);
16763 operands[1] = gen_lowpart (SImode, operands[1]);")
16764
16765 (define_split
16766 [(set (match_operand 0 "register_operand" "")
16767 (if_then_else (match_operator 1 "comparison_operator"
16768 [(reg 17) (const_int 0)])
16769 (match_operand 2 "register_operand" "")
16770 (match_operand 3 "register_operand" "")))]
16771 "! TARGET_PARTIAL_REG_STALL && TARGET_CMOVE
16772 && (GET_MODE (operands[0]) == HImode
16773 || (GET_MODE (operands[0]) == QImode
16774 && (TARGET_PROMOTE_QImode || optimize_size)))"
16775 [(set (match_dup 0)
16776 (if_then_else:SI (match_dup 1) (match_dup 2) (match_dup 3)))]
16777 "operands[0] = gen_lowpart (SImode, operands[0]);
16778 operands[2] = gen_lowpart (SImode, operands[2]);
16779 operands[3] = gen_lowpart (SImode, operands[3]);")
16780
16781 \f
16782 ;; RTL Peephole optimizations, run before sched2. These primarily look to
16783 ;; transform a complex memory operation into two memory to register operations.
16784
16785 ;; Don't push memory operands
16786 (define_peephole2
16787 [(set (match_operand:SI 0 "push_operand" "")
16788 (match_operand:SI 1 "memory_operand" ""))
16789 (match_scratch:SI 2 "r")]
16790 "! optimize_size && ! TARGET_PUSH_MEMORY"
16791 [(set (match_dup 2) (match_dup 1))
16792 (set (match_dup 0) (match_dup 2))]
16793 "")
16794
16795 (define_peephole2
16796 [(set (match_operand:DI 0 "push_operand" "")
16797 (match_operand:DI 1 "memory_operand" ""))
16798 (match_scratch:DI 2 "r")]
16799 "! optimize_size && ! TARGET_PUSH_MEMORY"
16800 [(set (match_dup 2) (match_dup 1))
16801 (set (match_dup 0) (match_dup 2))]
16802 "")
16803
16804 ;; We need to handle SFmode only, because DFmode and XFmode is split to
16805 ;; SImode pushes.
16806 (define_peephole2
16807 [(set (match_operand:SF 0 "push_operand" "")
16808 (match_operand:SF 1 "memory_operand" ""))
16809 (match_scratch:SF 2 "r")]
16810 "! optimize_size && ! TARGET_PUSH_MEMORY"
16811 [(set (match_dup 2) (match_dup 1))
16812 (set (match_dup 0) (match_dup 2))]
16813 "")
16814
16815 (define_peephole2
16816 [(set (match_operand:HI 0 "push_operand" "")
16817 (match_operand:HI 1 "memory_operand" ""))
16818 (match_scratch:HI 2 "r")]
16819 "! optimize_size && ! TARGET_PUSH_MEMORY"
16820 [(set (match_dup 2) (match_dup 1))
16821 (set (match_dup 0) (match_dup 2))]
16822 "")
16823
16824 (define_peephole2
16825 [(set (match_operand:QI 0 "push_operand" "")
16826 (match_operand:QI 1 "memory_operand" ""))
16827 (match_scratch:QI 2 "q")]
16828 "! optimize_size && ! TARGET_PUSH_MEMORY"
16829 [(set (match_dup 2) (match_dup 1))
16830 (set (match_dup 0) (match_dup 2))]
16831 "")
16832
16833 ;; Don't move an immediate directly to memory when the instruction
16834 ;; gets too big.
16835 (define_peephole2
16836 [(match_scratch:SI 1 "r")
16837 (set (match_operand:SI 0 "memory_operand" "")
16838 (const_int 0))]
16839 "! optimize_size
16840 && ! TARGET_USE_MOV0
16841 && TARGET_SPLIT_LONG_MOVES
16842 && get_attr_length (insn) >= ix86_cost->large_insn
16843 && peep2_regno_dead_p (0, FLAGS_REG)"
16844 [(parallel [(set (match_dup 1) (const_int 0))
16845 (clobber (reg:CC 17))])
16846 (set (match_dup 0) (match_dup 1))]
16847 "")
16848
16849 (define_peephole2
16850 [(match_scratch:HI 1 "r")
16851 (set (match_operand:HI 0 "memory_operand" "")
16852 (const_int 0))]
16853 "! optimize_size
16854 && ! TARGET_USE_MOV0
16855 && TARGET_SPLIT_LONG_MOVES
16856 && get_attr_length (insn) >= ix86_cost->large_insn
16857 && peep2_regno_dead_p (0, FLAGS_REG)"
16858 [(parallel [(set (match_dup 2) (const_int 0))
16859 (clobber (reg:CC 17))])
16860 (set (match_dup 0) (match_dup 1))]
16861 "operands[2] = gen_rtx_REG (SImode, true_regnum (operands[1]));")
16862
16863 (define_peephole2
16864 [(match_scratch:QI 1 "q")
16865 (set (match_operand:QI 0 "memory_operand" "")
16866 (const_int 0))]
16867 "! optimize_size
16868 && ! TARGET_USE_MOV0
16869 && TARGET_SPLIT_LONG_MOVES
16870 && get_attr_length (insn) >= ix86_cost->large_insn
16871 && peep2_regno_dead_p (0, FLAGS_REG)"
16872 [(parallel [(set (match_dup 2) (const_int 0))
16873 (clobber (reg:CC 17))])
16874 (set (match_dup 0) (match_dup 1))]
16875 "operands[2] = gen_rtx_REG (SImode, true_regnum (operands[1]));")
16876
16877 (define_peephole2
16878 [(match_scratch:SI 2 "r")
16879 (set (match_operand:SI 0 "memory_operand" "")
16880 (match_operand:SI 1 "immediate_operand" ""))]
16881 "! optimize_size
16882 && get_attr_length (insn) >= ix86_cost->large_insn
16883 && TARGET_SPLIT_LONG_MOVES"
16884 [(set (match_dup 2) (match_dup 1))
16885 (set (match_dup 0) (match_dup 2))]
16886 "")
16887
16888 (define_peephole2
16889 [(match_scratch:HI 2 "r")
16890 (set (match_operand:HI 0 "memory_operand" "")
16891 (match_operand:HI 1 "immediate_operand" ""))]
16892 "! optimize_size && get_attr_length (insn) >= ix86_cost->large_insn
16893 && TARGET_SPLIT_LONG_MOVES"
16894 [(set (match_dup 2) (match_dup 1))
16895 (set (match_dup 0) (match_dup 2))]
16896 "")
16897
16898 (define_peephole2
16899 [(match_scratch:QI 2 "q")
16900 (set (match_operand:QI 0 "memory_operand" "")
16901 (match_operand:QI 1 "immediate_operand" ""))]
16902 "! optimize_size && get_attr_length (insn) >= ix86_cost->large_insn
16903 && TARGET_SPLIT_LONG_MOVES"
16904 [(set (match_dup 2) (match_dup 1))
16905 (set (match_dup 0) (match_dup 2))]
16906 "")
16907
16908 ;; Don't compare memory with zero, load and use a test instead.
16909 (define_peephole2
16910 [(set (reg 17)
16911 (compare (match_operand:SI 0 "memory_operand" "")
16912 (const_int 0)))
16913 (match_scratch:SI 3 "r")]
16914 "ix86_match_ccmode (insn, CCNOmode) && ! optimize_size"
16915 [(set (match_dup 3) (match_dup 0))
16916 (set (reg:CCNO 17) (compare:CCNO (match_dup 3) (const_int 0)))]
16917 "")
16918
16919 ;; NOT is not pairable on Pentium, while XOR is, but one byte longer.
16920 ;; Don't split NOTs with a displacement operand, because resulting XOR
16921 ;; will not be pariable anyway.
16922 ;;
16923 ;; On AMD K6, NOT is vector decoded with memory operand that can not be
16924 ;; represented using a modRM byte. The XOR replacement is long decoded,
16925 ;; so this split helps here as well.
16926 ;;
16927 ;; Note: Can't do this as a regular split because we can't get proper
16928 ;; lifetime information then.
16929
16930 (define_peephole2
16931 [(set (match_operand:SI 0 "nonimmediate_operand" "")
16932 (not:SI (match_operand:SI 1 "nonimmediate_operand" "")))]
16933 "!optimize_size
16934 && peep2_regno_dead_p (0, FLAGS_REG)
16935 && ((TARGET_PENTIUM
16936 && (GET_CODE (operands[0]) != MEM
16937 || !memory_displacement_operand (operands[0], SImode)))
16938 || (TARGET_K6 && long_memory_operand (operands[0], SImode)))"
16939 [(parallel [(set (match_dup 0)
16940 (xor:SI (match_dup 1) (const_int -1)))
16941 (clobber (reg:CC 17))])]
16942 "")
16943
16944 (define_peephole2
16945 [(set (match_operand:HI 0 "nonimmediate_operand" "")
16946 (not:HI (match_operand:HI 1 "nonimmediate_operand" "")))]
16947 "!optimize_size
16948 && peep2_regno_dead_p (0, FLAGS_REG)
16949 && ((TARGET_PENTIUM
16950 && (GET_CODE (operands[0]) != MEM
16951 || !memory_displacement_operand (operands[0], HImode)))
16952 || (TARGET_K6 && long_memory_operand (operands[0], HImode)))"
16953 [(parallel [(set (match_dup 0)
16954 (xor:HI (match_dup 1) (const_int -1)))
16955 (clobber (reg:CC 17))])]
16956 "")
16957
16958 (define_peephole2
16959 [(set (match_operand:QI 0 "nonimmediate_operand" "")
16960 (not:QI (match_operand:QI 1 "nonimmediate_operand" "")))]
16961 "!optimize_size
16962 && peep2_regno_dead_p (0, FLAGS_REG)
16963 && ((TARGET_PENTIUM
16964 && (GET_CODE (operands[0]) != MEM
16965 || !memory_displacement_operand (operands[0], QImode)))
16966 || (TARGET_K6 && long_memory_operand (operands[0], QImode)))"
16967 [(parallel [(set (match_dup 0)
16968 (xor:QI (match_dup 1) (const_int -1)))
16969 (clobber (reg:CC 17))])]
16970 "")
16971
16972 ;; Non pairable "test imm, reg" instructions can be translated to
16973 ;; "and imm, reg" if reg dies. The "and" form is also shorter (one
16974 ;; byte opcode instead of two, have a short form for byte operands),
16975 ;; so do it for other CPUs as well. Given that the value was dead,
16976 ;; this should not create any new dependencies. Pass on the sub-word
16977 ;; versions if we're concerned about partial register stalls.
16978
16979 (define_peephole2
16980 [(set (reg 17)
16981 (compare (and:SI (match_operand:SI 0 "register_operand" "")
16982 (match_operand:SI 1 "immediate_operand" ""))
16983 (const_int 0)))]
16984 "ix86_match_ccmode (insn, CCNOmode)
16985 && (true_regnum (operands[0]) != 0
16986 || CONST_OK_FOR_LETTER_P (INTVAL (operands[1]), 'K'))
16987 && find_regno_note (insn, REG_DEAD, true_regnum (operands[0]))"
16988 [(parallel
16989 [(set (reg:CCNO 17)
16990 (compare:CCNO (and:SI (match_dup 0)
16991 (match_dup 1))
16992 (const_int 0)))
16993 (set (match_dup 0)
16994 (and:SI (match_dup 0) (match_dup 1)))])]
16995 "")
16996
16997 ;; We don't need to handle HImode case, because it will be promoted to SImode
16998 ;; on ! TARGET_PARTIAL_REG_STALL
16999
17000 (define_peephole2
17001 [(set (reg 17)
17002 (compare (and:QI (match_operand:QI 0 "register_operand" "")
17003 (match_operand:QI 1 "immediate_operand" ""))
17004 (const_int 0)))]
17005 "! TARGET_PARTIAL_REG_STALL
17006 && ix86_match_ccmode (insn, CCNOmode)
17007 && true_regnum (operands[0]) != 0
17008 && find_regno_note (insn, REG_DEAD, true_regnum (operands[0]))"
17009 [(parallel
17010 [(set (reg:CCNO 17)
17011 (compare:CCNO (and:QI (match_dup 0)
17012 (match_dup 1))
17013 (const_int 0)))
17014 (set (match_dup 0)
17015 (and:QI (match_dup 0) (match_dup 1)))])]
17016 "")
17017
17018 (define_peephole2
17019 [(set (reg 17)
17020 (compare
17021 (and:SI
17022 (zero_extract:SI
17023 (match_operand 0 "ext_register_operand" "")
17024 (const_int 8)
17025 (const_int 8))
17026 (match_operand 1 "const_int_operand" ""))
17027 (const_int 0)))]
17028 "! TARGET_PARTIAL_REG_STALL
17029 && ix86_match_ccmode (insn, CCNOmode)
17030 && true_regnum (operands[0]) != 0
17031 && find_regno_note (insn, REG_DEAD, true_regnum (operands[0]))"
17032 [(parallel [(set (reg:CCNO 17)
17033 (compare:CCNO
17034 (and:SI
17035 (zero_extract:SI
17036 (match_dup 0)
17037 (const_int 8)
17038 (const_int 8))
17039 (match_dup 1))
17040 (const_int 0)))
17041 (set (zero_extract:SI (match_dup 0)
17042 (const_int 8)
17043 (const_int 8))
17044 (and:SI
17045 (zero_extract:SI
17046 (match_dup 0)
17047 (const_int 8)
17048 (const_int 8))
17049 (match_dup 1)))])]
17050 "")
17051
17052 ;; Don't do logical operations with memory inputs.
17053 (define_peephole2
17054 [(match_scratch:SI 2 "r")
17055 (parallel [(set (match_operand:SI 0 "register_operand" "")
17056 (match_operator:SI 3 "arith_or_logical_operator"
17057 [(match_dup 0)
17058 (match_operand:SI 1 "memory_operand" "")]))
17059 (clobber (reg:CC 17))])]
17060 "! optimize_size && ! TARGET_READ_MODIFY"
17061 [(set (match_dup 2) (match_dup 1))
17062 (parallel [(set (match_dup 0)
17063 (match_op_dup 3 [(match_dup 0) (match_dup 2)]))
17064 (clobber (reg:CC 17))])]
17065 "")
17066
17067 (define_peephole2
17068 [(match_scratch:SI 2 "r")
17069 (parallel [(set (match_operand:SI 0 "register_operand" "")
17070 (match_operator:SI 3 "arith_or_logical_operator"
17071 [(match_operand:SI 1 "memory_operand" "")
17072 (match_dup 0)]))
17073 (clobber (reg:CC 17))])]
17074 "! optimize_size && ! TARGET_READ_MODIFY"
17075 [(set (match_dup 2) (match_dup 1))
17076 (parallel [(set (match_dup 0)
17077 (match_op_dup 3 [(match_dup 2) (match_dup 0)]))
17078 (clobber (reg:CC 17))])]
17079 "")
17080
17081 ; Don't do logical operations with memory outputs
17082 ;
17083 ; These two don't make sense for PPro/PII -- we're expanding a 4-uop
17084 ; instruction into two 1-uop insns plus a 2-uop insn. That last has
17085 ; the same decoder scheduling characteristics as the original.
17086
17087 (define_peephole2
17088 [(match_scratch:SI 2 "r")
17089 (parallel [(set (match_operand:SI 0 "memory_operand" "")
17090 (match_operator:SI 3 "arith_or_logical_operator"
17091 [(match_dup 0)
17092 (match_operand:SI 1 "nonmemory_operand" "")]))
17093 (clobber (reg:CC 17))])]
17094 "! optimize_size && ! TARGET_READ_MODIFY_WRITE"
17095 [(set (match_dup 2) (match_dup 0))
17096 (parallel [(set (match_dup 2)
17097 (match_op_dup 3 [(match_dup 2) (match_dup 1)]))
17098 (clobber (reg:CC 17))])
17099 (set (match_dup 0) (match_dup 2))]
17100 "")
17101
17102 (define_peephole2
17103 [(match_scratch:SI 2 "r")
17104 (parallel [(set (match_operand:SI 0 "memory_operand" "")
17105 (match_operator:SI 3 "arith_or_logical_operator"
17106 [(match_operand:SI 1 "nonmemory_operand" "")
17107 (match_dup 0)]))
17108 (clobber (reg:CC 17))])]
17109 "! optimize_size && ! TARGET_READ_MODIFY_WRITE"
17110 [(set (match_dup 2) (match_dup 0))
17111 (parallel [(set (match_dup 2)
17112 (match_op_dup 3 [(match_dup 1) (match_dup 2)]))
17113 (clobber (reg:CC 17))])
17114 (set (match_dup 0) (match_dup 2))]
17115 "")
17116
17117 ;; Attempt to always use XOR for zeroing registers.
17118 (define_peephole2
17119 [(set (match_operand 0 "register_operand" "")
17120 (const_int 0))]
17121 "(GET_MODE (operands[0]) == QImode
17122 || GET_MODE (operands[0]) == HImode
17123 || GET_MODE (operands[0]) == SImode
17124 || (GET_MODE (operands[0]) == DImode && TARGET_64BIT))
17125 && (! TARGET_USE_MOV0 || optimize_size)
17126 && peep2_regno_dead_p (0, FLAGS_REG)"
17127 [(parallel [(set (match_dup 0) (const_int 0))
17128 (clobber (reg:CC 17))])]
17129 "operands[0] = gen_rtx_REG (GET_MODE (operands[0]) == DImode ? DImode : SImode,
17130 true_regnum (operands[0]));")
17131
17132 (define_peephole2
17133 [(set (strict_low_part (match_operand 0 "register_operand" ""))
17134 (const_int 0))]
17135 "(GET_MODE (operands[0]) == QImode
17136 || GET_MODE (operands[0]) == HImode)
17137 && (! TARGET_USE_MOV0 || optimize_size)
17138 && peep2_regno_dead_p (0, FLAGS_REG)"
17139 [(parallel [(set (strict_low_part (match_dup 0)) (const_int 0))
17140 (clobber (reg:CC 17))])])
17141
17142 ;; For HI and SI modes, or $-1,reg is smaller than mov $-1,reg.
17143 (define_peephole2
17144 [(set (match_operand 0 "register_operand" "")
17145 (const_int -1))]
17146 "(GET_MODE (operands[0]) == HImode
17147 || GET_MODE (operands[0]) == SImode
17148 || (GET_MODE (operands[0]) == DImode && TARGET_64BIT))
17149 && (optimize_size || TARGET_PENTIUM)
17150 && peep2_regno_dead_p (0, FLAGS_REG)"
17151 [(parallel [(set (match_dup 0) (const_int -1))
17152 (clobber (reg:CC 17))])]
17153 "operands[0] = gen_rtx_REG (GET_MODE (operands[0]) == DImode ? DImode : SImode,
17154 true_regnum (operands[0]));")
17155
17156 ;; Attempt to convert simple leas to adds. These can be created by
17157 ;; move expanders.
17158 (define_peephole2
17159 [(set (match_operand:SI 0 "register_operand" "")
17160 (plus:SI (match_dup 0)
17161 (match_operand:SI 1 "nonmemory_operand" "")))]
17162 "peep2_regno_dead_p (0, FLAGS_REG)"
17163 [(parallel [(set (match_dup 0) (plus:SI (match_dup 0) (match_dup 1)))
17164 (clobber (reg:CC 17))])]
17165 "")
17166
17167 (define_peephole2
17168 [(set (match_operand:SI 0 "register_operand" "")
17169 (subreg:SI (plus:DI (match_operand:DI 1 "register_operand" "")
17170 (match_operand:DI 2 "nonmemory_operand" "")) 0))]
17171 "peep2_regno_dead_p (0, FLAGS_REG) && REGNO (operands[0]) == REGNO (operands[1])"
17172 [(parallel [(set (match_dup 0) (plus:SI (match_dup 0) (match_dup 2)))
17173 (clobber (reg:CC 17))])]
17174 "operands[2] = gen_lowpart (SImode, operands[2]);")
17175
17176 (define_peephole2
17177 [(set (match_operand:DI 0 "register_operand" "")
17178 (plus:DI (match_dup 0)
17179 (match_operand:DI 1 "x86_64_general_operand" "")))]
17180 "peep2_regno_dead_p (0, FLAGS_REG)"
17181 [(parallel [(set (match_dup 0) (plus:DI (match_dup 0) (match_dup 1)))
17182 (clobber (reg:CC 17))])]
17183 "")
17184
17185 (define_peephole2
17186 [(set (match_operand:SI 0 "register_operand" "")
17187 (mult:SI (match_dup 0)
17188 (match_operand:SI 1 "const_int_operand" "")))]
17189 "exact_log2 (INTVAL (operands[1])) >= 0
17190 && peep2_regno_dead_p (0, FLAGS_REG)"
17191 [(parallel [(set (match_dup 0) (ashift:SI (match_dup 0) (match_dup 2)))
17192 (clobber (reg:CC 17))])]
17193 "operands[2] = GEN_INT (exact_log2 (INTVAL (operands[1])));")
17194
17195 (define_peephole2
17196 [(set (match_operand:DI 0 "register_operand" "")
17197 (mult:DI (match_dup 0)
17198 (match_operand:DI 1 "const_int_operand" "")))]
17199 "exact_log2 (INTVAL (operands[1])) >= 0
17200 && peep2_regno_dead_p (0, FLAGS_REG)"
17201 [(parallel [(set (match_dup 0) (ashift:DI (match_dup 0) (match_dup 2)))
17202 (clobber (reg:CC 17))])]
17203 "operands[2] = GEN_INT (exact_log2 (INTVAL (operands[1])));")
17204
17205 (define_peephole2
17206 [(set (match_operand:SI 0 "register_operand" "")
17207 (subreg:SI (mult:DI (match_operand:DI 1 "register_operand" "")
17208 (match_operand:DI 2 "const_int_operand" "")) 0))]
17209 "exact_log2 (INTVAL (operands[1])) >= 0
17210 && REGNO (operands[0]) == REGNO (operands[1])
17211 && peep2_regno_dead_p (0, FLAGS_REG)"
17212 [(parallel [(set (match_dup 0) (ashift:SI (match_dup 0) (match_dup 2)))
17213 (clobber (reg:CC 17))])]
17214 "operands[2] = GEN_INT (exact_log2 (INTVAL (operands[2])));")
17215
17216 ;; The ESP adjustments can be done by the push and pop instructions. Resulting
17217 ;; code is shorter, since push is only 1 byte, while add imm, %esp 3 bytes. On
17218 ;; many CPUs it is also faster, since special hardware to avoid esp
17219 ;; dependencies is present.
17220
17221 ;; While some of these conversions may be done using splitters, we use peepholes
17222 ;; in order to allow combine_stack_adjustments pass to see nonobfuscated RTL.
17223
17224 ;; Convert prologue esp subtractions to push.
17225 ;; We need register to push. In order to keep verify_flow_info happy we have
17226 ;; two choices
17227 ;; - use scratch and clobber it in order to avoid dependencies
17228 ;; - use already live register
17229 ;; We can't use the second way right now, since there is no reliable way how to
17230 ;; verify that given register is live. First choice will also most likely in
17231 ;; fewer dependencies. On the place of esp adjustments it is very likely that
17232 ;; call clobbered registers are dead. We may want to use base pointer as an
17233 ;; alternative when no register is available later.
17234
17235 (define_peephole2
17236 [(match_scratch:SI 0 "r")
17237 (parallel [(set (reg:SI 7) (plus:SI (reg:SI 7) (const_int -4)))
17238 (clobber (reg:CC 17))
17239 (clobber (mem:BLK (scratch)))])]
17240 "optimize_size || !TARGET_SUB_ESP_4"
17241 [(clobber (match_dup 0))
17242 (parallel [(set (mem:SI (pre_dec:SI (reg:SI 7))) (match_dup 0))
17243 (clobber (mem:BLK (scratch)))])])
17244
17245 (define_peephole2
17246 [(match_scratch:SI 0 "r")
17247 (parallel [(set (reg:SI 7) (plus:SI (reg:SI 7) (const_int -8)))
17248 (clobber (reg:CC 17))
17249 (clobber (mem:BLK (scratch)))])]
17250 "optimize_size || !TARGET_SUB_ESP_8"
17251 [(clobber (match_dup 0))
17252 (set (mem:SI (pre_dec:SI (reg:SI 7))) (match_dup 0))
17253 (parallel [(set (mem:SI (pre_dec:SI (reg:SI 7))) (match_dup 0))
17254 (clobber (mem:BLK (scratch)))])])
17255
17256 ;; Convert esp subtractions to push.
17257 (define_peephole2
17258 [(match_scratch:SI 0 "r")
17259 (parallel [(set (reg:SI 7) (plus:SI (reg:SI 7) (const_int -4)))
17260 (clobber (reg:CC 17))])]
17261 "optimize_size || !TARGET_SUB_ESP_4"
17262 [(clobber (match_dup 0))
17263 (set (mem:SI (pre_dec:SI (reg:SI 7))) (match_dup 0))])
17264
17265 (define_peephole2
17266 [(match_scratch:SI 0 "r")
17267 (parallel [(set (reg:SI 7) (plus:SI (reg:SI 7) (const_int -8)))
17268 (clobber (reg:CC 17))])]
17269 "optimize_size || !TARGET_SUB_ESP_8"
17270 [(clobber (match_dup 0))
17271 (set (mem:SI (pre_dec:SI (reg:SI 7))) (match_dup 0))
17272 (set (mem:SI (pre_dec:SI (reg:SI 7))) (match_dup 0))])
17273
17274 ;; Convert epilogue deallocator to pop.
17275 (define_peephole2
17276 [(match_scratch:SI 0 "r")
17277 (parallel [(set (reg:SI 7) (plus:SI (reg:SI 7) (const_int 4)))
17278 (clobber (reg:CC 17))
17279 (clobber (mem:BLK (scratch)))])]
17280 "optimize_size || !TARGET_ADD_ESP_4"
17281 [(parallel [(set (match_dup 0) (mem:SI (reg:SI 7)))
17282 (set (reg:SI 7) (plus:SI (reg:SI 7) (const_int 4)))
17283 (clobber (mem:BLK (scratch)))])]
17284 "")
17285
17286 ;; Two pops case is tricky, since pop causes dependency on destination register.
17287 ;; We use two registers if available.
17288 (define_peephole2
17289 [(match_scratch:SI 0 "r")
17290 (match_scratch:SI 1 "r")
17291 (parallel [(set (reg:SI 7) (plus:SI (reg:SI 7) (const_int 8)))
17292 (clobber (reg:CC 17))
17293 (clobber (mem:BLK (scratch)))])]
17294 "optimize_size || !TARGET_ADD_ESP_8"
17295 [(parallel [(set (match_dup 0) (mem:SI (reg:SI 7)))
17296 (set (reg:SI 7) (plus:SI (reg:SI 7) (const_int 4)))
17297 (clobber (mem:BLK (scratch)))])
17298 (parallel [(set (match_dup 1) (mem:SI (reg:SI 7)))
17299 (set (reg:SI 7) (plus:SI (reg:SI 7) (const_int 4)))])]
17300 "")
17301
17302 (define_peephole2
17303 [(match_scratch:SI 0 "r")
17304 (parallel [(set (reg:SI 7) (plus:SI (reg:SI 7) (const_int 8)))
17305 (clobber (reg:CC 17))
17306 (clobber (mem:BLK (scratch)))])]
17307 "optimize_size"
17308 [(parallel [(set (match_dup 0) (mem:SI (reg:SI 7)))
17309 (set (reg:SI 7) (plus:SI (reg:SI 7) (const_int 4)))
17310 (clobber (mem:BLK (scratch)))])
17311 (parallel [(set (match_dup 0) (mem:SI (reg:SI 7)))
17312 (set (reg:SI 7) (plus:SI (reg:SI 7) (const_int 4)))])]
17313 "")
17314
17315 ;; Convert esp additions to pop.
17316 (define_peephole2
17317 [(match_scratch:SI 0 "r")
17318 (parallel [(set (reg:SI 7) (plus:SI (reg:SI 7) (const_int 4)))
17319 (clobber (reg:CC 17))])]
17320 ""
17321 [(parallel [(set (match_dup 0) (mem:SI (reg:SI 7)))
17322 (set (reg:SI 7) (plus:SI (reg:SI 7) (const_int 4)))])]
17323 "")
17324
17325 ;; Two pops case is tricky, since pop causes dependency on destination register.
17326 ;; We use two registers if available.
17327 (define_peephole2
17328 [(match_scratch:SI 0 "r")
17329 (match_scratch:SI 1 "r")
17330 (parallel [(set (reg:SI 7) (plus:SI (reg:SI 7) (const_int 8)))
17331 (clobber (reg:CC 17))])]
17332 ""
17333 [(parallel [(set (match_dup 0) (mem:SI (reg:SI 7)))
17334 (set (reg:SI 7) (plus:SI (reg:SI 7) (const_int 4)))])
17335 (parallel [(set (match_dup 1) (mem:SI (reg:SI 7)))
17336 (set (reg:SI 7) (plus:SI (reg:SI 7) (const_int 4)))])]
17337 "")
17338
17339 (define_peephole2
17340 [(match_scratch:SI 0 "r")
17341 (parallel [(set (reg:SI 7) (plus:SI (reg:SI 7) (const_int 8)))
17342 (clobber (reg:CC 17))])]
17343 "optimize_size"
17344 [(parallel [(set (match_dup 0) (mem:SI (reg:SI 7)))
17345 (set (reg:SI 7) (plus:SI (reg:SI 7) (const_int 4)))])
17346 (parallel [(set (match_dup 0) (mem:SI (reg:SI 7)))
17347 (set (reg:SI 7) (plus:SI (reg:SI 7) (const_int 4)))])]
17348 "")
17349 \f
17350 ;; Convert compares with 1 to shorter inc/dec operations when CF is not
17351 ;; required and register dies.
17352 (define_peephole2
17353 [(set (reg 17)
17354 (compare (match_operand:SI 0 "register_operand" "")
17355 (match_operand:SI 1 "incdec_operand" "")))]
17356 "ix86_match_ccmode (insn, CCGCmode)
17357 && find_regno_note (insn, REG_DEAD, true_regnum (operands[0]))"
17358 [(parallel [(set (reg:CCGC 17)
17359 (compare:CCGC (match_dup 0)
17360 (match_dup 1)))
17361 (clobber (match_dup 0))])]
17362 "")
17363
17364 (define_peephole2
17365 [(set (reg 17)
17366 (compare (match_operand:HI 0 "register_operand" "")
17367 (match_operand:HI 1 "incdec_operand" "")))]
17368 "ix86_match_ccmode (insn, CCGCmode)
17369 && find_regno_note (insn, REG_DEAD, true_regnum (operands[0]))"
17370 [(parallel [(set (reg:CCGC 17)
17371 (compare:CCGC (match_dup 0)
17372 (match_dup 1)))
17373 (clobber (match_dup 0))])]
17374 "")
17375
17376 (define_peephole2
17377 [(set (reg 17)
17378 (compare (match_operand:QI 0 "register_operand" "")
17379 (match_operand:QI 1 "incdec_operand" "")))]
17380 "ix86_match_ccmode (insn, CCGCmode)
17381 && find_regno_note (insn, REG_DEAD, true_regnum (operands[0]))"
17382 [(parallel [(set (reg:CCGC 17)
17383 (compare:CCGC (match_dup 0)
17384 (match_dup 1)))
17385 (clobber (match_dup 0))])]
17386 "")
17387
17388 ;; Convert compares with 128 to shorter add -128
17389 (define_peephole2
17390 [(set (reg 17)
17391 (compare (match_operand:SI 0 "register_operand" "")
17392 (const_int 128)))]
17393 "ix86_match_ccmode (insn, CCGCmode)
17394 && find_regno_note (insn, REG_DEAD, true_regnum (operands[0]))"
17395 [(parallel [(set (reg:CCGC 17)
17396 (compare:CCGC (match_dup 0)
17397 (const_int 128)))
17398 (clobber (match_dup 0))])]
17399 "")
17400
17401 (define_peephole2
17402 [(set (reg 17)
17403 (compare (match_operand:HI 0 "register_operand" "")
17404 (const_int 128)))]
17405 "ix86_match_ccmode (insn, CCGCmode)
17406 && find_regno_note (insn, REG_DEAD, true_regnum (operands[0]))"
17407 [(parallel [(set (reg:CCGC 17)
17408 (compare:CCGC (match_dup 0)
17409 (const_int 128)))
17410 (clobber (match_dup 0))])]
17411 "")
17412 \f
17413 (define_peephole2
17414 [(match_scratch:DI 0 "r")
17415 (parallel [(set (reg:DI 7) (plus:DI (reg:DI 7) (const_int -8)))
17416 (clobber (reg:CC 17))
17417 (clobber (mem:BLK (scratch)))])]
17418 "optimize_size || !TARGET_SUB_ESP_4"
17419 [(clobber (match_dup 0))
17420 (parallel [(set (mem:DI (pre_dec:DI (reg:DI 7))) (match_dup 0))
17421 (clobber (mem:BLK (scratch)))])])
17422
17423 (define_peephole2
17424 [(match_scratch:DI 0 "r")
17425 (parallel [(set (reg:DI 7) (plus:DI (reg:DI 7) (const_int -16)))
17426 (clobber (reg:CC 17))
17427 (clobber (mem:BLK (scratch)))])]
17428 "optimize_size || !TARGET_SUB_ESP_8"
17429 [(clobber (match_dup 0))
17430 (set (mem:DI (pre_dec:DI (reg:DI 7))) (match_dup 0))
17431 (parallel [(set (mem:DI (pre_dec:DI (reg:DI 7))) (match_dup 0))
17432 (clobber (mem:BLK (scratch)))])])
17433
17434 ;; Convert esp subtractions to push.
17435 (define_peephole2
17436 [(match_scratch:DI 0 "r")
17437 (parallel [(set (reg:DI 7) (plus:DI (reg:DI 7) (const_int -8)))
17438 (clobber (reg:CC 17))])]
17439 "optimize_size || !TARGET_SUB_ESP_4"
17440 [(clobber (match_dup 0))
17441 (set (mem:DI (pre_dec:DI (reg:DI 7))) (match_dup 0))])
17442
17443 (define_peephole2
17444 [(match_scratch:DI 0 "r")
17445 (parallel [(set (reg:DI 7) (plus:DI (reg:DI 7) (const_int -16)))
17446 (clobber (reg:CC 17))])]
17447 "optimize_size || !TARGET_SUB_ESP_8"
17448 [(clobber (match_dup 0))
17449 (set (mem:DI (pre_dec:DI (reg:DI 7))) (match_dup 0))
17450 (set (mem:DI (pre_dec:DI (reg:DI 7))) (match_dup 0))])
17451
17452 ;; Convert epilogue deallocator to pop.
17453 (define_peephole2
17454 [(match_scratch:DI 0 "r")
17455 (parallel [(set (reg:DI 7) (plus:DI (reg:DI 7) (const_int 8)))
17456 (clobber (reg:CC 17))
17457 (clobber (mem:BLK (scratch)))])]
17458 "optimize_size || !TARGET_ADD_ESP_4"
17459 [(parallel [(set (match_dup 0) (mem:DI (reg:DI 7)))
17460 (set (reg:DI 7) (plus:DI (reg:DI 7) (const_int 8)))
17461 (clobber (mem:BLK (scratch)))])]
17462 "")
17463
17464 ;; Two pops case is tricky, since pop causes dependency on destination register.
17465 ;; We use two registers if available.
17466 (define_peephole2
17467 [(match_scratch:DI 0 "r")
17468 (match_scratch:DI 1 "r")
17469 (parallel [(set (reg:DI 7) (plus:DI (reg:DI 7) (const_int 16)))
17470 (clobber (reg:CC 17))
17471 (clobber (mem:BLK (scratch)))])]
17472 "optimize_size || !TARGET_ADD_ESP_8"
17473 [(parallel [(set (match_dup 0) (mem:DI (reg:DI 7)))
17474 (set (reg:DI 7) (plus:DI (reg:DI 7) (const_int 8)))
17475 (clobber (mem:BLK (scratch)))])
17476 (parallel [(set (match_dup 1) (mem:DI (reg:DI 7)))
17477 (set (reg:DI 7) (plus:DI (reg:DI 7) (const_int 8)))])]
17478 "")
17479
17480 (define_peephole2
17481 [(match_scratch:DI 0 "r")
17482 (parallel [(set (reg:DI 7) (plus:DI (reg:DI 7) (const_int 16)))
17483 (clobber (reg:CC 17))
17484 (clobber (mem:BLK (scratch)))])]
17485 "optimize_size"
17486 [(parallel [(set (match_dup 0) (mem:DI (reg:DI 7)))
17487 (set (reg:DI 7) (plus:DI (reg:DI 7) (const_int 8)))
17488 (clobber (mem:BLK (scratch)))])
17489 (parallel [(set (match_dup 0) (mem:DI (reg:DI 7)))
17490 (set (reg:DI 7) (plus:DI (reg:DI 7) (const_int 8)))])]
17491 "")
17492
17493 ;; Convert esp additions to pop.
17494 (define_peephole2
17495 [(match_scratch:DI 0 "r")
17496 (parallel [(set (reg:DI 7) (plus:DI (reg:DI 7) (const_int 8)))
17497 (clobber (reg:CC 17))])]
17498 ""
17499 [(parallel [(set (match_dup 0) (mem:DI (reg:DI 7)))
17500 (set (reg:DI 7) (plus:DI (reg:DI 7) (const_int 8)))])]
17501 "")
17502
17503 ;; Two pops case is tricky, since pop causes dependency on destination register.
17504 ;; We use two registers if available.
17505 (define_peephole2
17506 [(match_scratch:DI 0 "r")
17507 (match_scratch:DI 1 "r")
17508 (parallel [(set (reg:DI 7) (plus:DI (reg:DI 7) (const_int 16)))
17509 (clobber (reg:CC 17))])]
17510 ""
17511 [(parallel [(set (match_dup 0) (mem:DI (reg:DI 7)))
17512 (set (reg:DI 7) (plus:DI (reg:DI 7) (const_int 8)))])
17513 (parallel [(set (match_dup 1) (mem:DI (reg:DI 7)))
17514 (set (reg:DI 7) (plus:DI (reg:DI 7) (const_int 8)))])]
17515 "")
17516
17517 (define_peephole2
17518 [(match_scratch:DI 0 "r")
17519 (parallel [(set (reg:DI 7) (plus:DI (reg:DI 7) (const_int 16)))
17520 (clobber (reg:CC 17))])]
17521 "optimize_size"
17522 [(parallel [(set (match_dup 0) (mem:DI (reg:DI 7)))
17523 (set (reg:DI 7) (plus:DI (reg:DI 7) (const_int 8)))])
17524 (parallel [(set (match_dup 0) (mem:DI (reg:DI 7)))
17525 (set (reg:DI 7) (plus:DI (reg:DI 7) (const_int 8)))])]
17526 "")
17527 \f
17528 ;; Call-value patterns last so that the wildcard operand does not
17529 ;; disrupt insn-recog's switch tables.
17530
17531 (define_insn "*call_value_pop_0"
17532 [(set (match_operand 0 "" "")
17533 (call (mem:QI (match_operand:SI 1 "constant_call_address_operand" ""))
17534 (match_operand:SI 2 "" "")))
17535 (set (reg:SI 7) (plus:SI (reg:SI 7)
17536 (match_operand:SI 3 "immediate_operand" "")))]
17537 "!TARGET_64BIT"
17538 {
17539 if (SIBLING_CALL_P (insn))
17540 return "jmp\t%P1";
17541 else
17542 return "call\t%P1";
17543 }
17544 [(set_attr "type" "callv")])
17545
17546 (define_insn "*call_value_pop_1"
17547 [(set (match_operand 0 "" "")
17548 (call (mem:QI (match_operand:SI 1 "call_insn_operand" "rsm"))
17549 (match_operand:SI 2 "" "")))
17550 (set (reg:SI 7) (plus:SI (reg:SI 7)
17551 (match_operand:SI 3 "immediate_operand" "i")))]
17552 "!TARGET_64BIT"
17553 {
17554 if (constant_call_address_operand (operands[1], QImode))
17555 {
17556 if (SIBLING_CALL_P (insn))
17557 return "jmp\t%P1";
17558 else
17559 return "call\t%P1";
17560 }
17561 if (SIBLING_CALL_P (insn))
17562 return "jmp\t%A1";
17563 else
17564 return "call\t%A1";
17565 }
17566 [(set_attr "type" "callv")])
17567
17568 (define_insn "*call_value_0"
17569 [(set (match_operand 0 "" "")
17570 (call (mem:QI (match_operand:SI 1 "constant_call_address_operand" ""))
17571 (match_operand:SI 2 "" "")))]
17572 "!TARGET_64BIT"
17573 {
17574 if (SIBLING_CALL_P (insn))
17575 return "jmp\t%P1";
17576 else
17577 return "call\t%P1";
17578 }
17579 [(set_attr "type" "callv")])
17580
17581 (define_insn "*call_value_0_rex64"
17582 [(set (match_operand 0 "" "")
17583 (call (mem:QI (match_operand:DI 1 "constant_call_address_operand" ""))
17584 (match_operand:DI 2 "const_int_operand" "")))]
17585 "TARGET_64BIT"
17586 {
17587 if (SIBLING_CALL_P (insn))
17588 return "jmp\t%P1";
17589 else
17590 return "call\t%P1";
17591 }
17592 [(set_attr "type" "callv")])
17593
17594 (define_insn "*call_value_1"
17595 [(set (match_operand 0 "" "")
17596 (call (mem:QI (match_operand:SI 1 "call_insn_operand" "rsm"))
17597 (match_operand:SI 2 "" "")))]
17598 "!TARGET_64BIT"
17599 {
17600 if (constant_call_address_operand (operands[1], QImode))
17601 {
17602 if (SIBLING_CALL_P (insn))
17603 return "jmp\t%P1";
17604 else
17605 return "call\t%P1";
17606 }
17607 if (SIBLING_CALL_P (insn))
17608 return "jmp\t%*%1";
17609 else
17610 return "call\t%*%1";
17611 }
17612 [(set_attr "type" "callv")])
17613
17614 (define_insn "*call_value_1_rex64"
17615 [(set (match_operand 0 "" "")
17616 (call (mem:QI (match_operand:DI 1 "call_insn_operand" "rsm"))
17617 (match_operand:DI 2 "" "")))]
17618 "TARGET_64BIT"
17619 {
17620 if (constant_call_address_operand (operands[1], QImode))
17621 {
17622 if (SIBLING_CALL_P (insn))
17623 return "jmp\t%P1";
17624 else
17625 return "call\t%P1";
17626 }
17627 if (SIBLING_CALL_P (insn))
17628 return "jmp\t%A1";
17629 else
17630 return "call\t%A1";
17631 }
17632 [(set_attr "type" "callv")])
17633 \f
17634 (define_insn "trap"
17635 [(trap_if (const_int 1) (const_int 5))]
17636 ""
17637 "int\t$5")
17638
17639 ;;; ix86 doesn't have conditional trap instructions, but we fake them
17640 ;;; for the sake of bounds checking. By emitting bounds checks as
17641 ;;; conditional traps rather than as conditional jumps around
17642 ;;; unconditional traps we avoid introducing spurious basic-block
17643 ;;; boundaries and facilitate elimination of redundant checks. In
17644 ;;; honor of the too-inflexible-for-BPs `bound' instruction, we use
17645 ;;; interrupt 5.
17646 ;;;
17647 ;;; FIXME: Static branch prediction rules for ix86 are such that
17648 ;;; forward conditional branches predict as untaken. As implemented
17649 ;;; below, pseudo conditional traps violate that rule. We should use
17650 ;;; .pushsection/.popsection to place all of the `int 5's in a special
17651 ;;; section loaded at the end of the text segment and branch forward
17652 ;;; there on bounds-failure, and then jump back immediately (in case
17653 ;;; the system chooses to ignore bounds violations, or to report
17654 ;;; violations and continue execution).
17655
17656 (define_expand "conditional_trap"
17657 [(trap_if (match_operator 0 "comparison_operator"
17658 [(match_dup 2) (const_int 0)])
17659 (match_operand 1 "const_int_operand" ""))]
17660 ""
17661 {
17662 emit_insn (gen_rtx_TRAP_IF (VOIDmode,
17663 ix86_expand_compare (GET_CODE (operands[0]),
17664 NULL, NULL),
17665 operands[1]));
17666 DONE;
17667 })
17668
17669 (define_insn "*conditional_trap_1"
17670 [(trap_if (match_operator 0 "comparison_operator"
17671 [(reg 17) (const_int 0)])
17672 (match_operand 1 "const_int_operand" ""))]
17673 ""
17674 {
17675 operands[2] = gen_label_rtx ();
17676 output_asm_insn ("j%c0\t%l2\; int\t%1", operands);
17677 ASM_OUTPUT_INTERNAL_LABEL (asm_out_file, "L",
17678 CODE_LABEL_NUMBER (operands[2]));
17679 RET;
17680 })
17681
17682 ;; Pentium III SIMD instructions.
17683
17684 ;; Moves for SSE/MMX regs.
17685
17686 (define_insn "movv4sf_internal"
17687 [(set (match_operand:V4SF 0 "nonimmediate_operand" "=x,m")
17688 (match_operand:V4SF 1 "nonimmediate_operand" "xm,x"))]
17689 "TARGET_SSE"
17690 ;; @@@ let's try to use movaps here.
17691 "movaps\t{%1, %0|%0, %1}"
17692 [(set_attr "type" "sse")])
17693
17694 (define_insn "movv4si_internal"
17695 [(set (match_operand:V4SI 0 "nonimmediate_operand" "=x,m")
17696 (match_operand:V4SI 1 "nonimmediate_operand" "xm,x"))]
17697 "TARGET_SSE"
17698 ;; @@@ let's try to use movaps here.
17699 "movaps\t{%1, %0|%0, %1}"
17700 [(set_attr "type" "sse")])
17701
17702 (define_insn "movv8qi_internal"
17703 [(set (match_operand:V8QI 0 "nonimmediate_operand" "=y,m")
17704 (match_operand:V8QI 1 "nonimmediate_operand" "ym,y"))]
17705 "TARGET_MMX"
17706 "movq\t{%1, %0|%0, %1}"
17707 [(set_attr "type" "mmx")])
17708
17709 (define_insn "movv4hi_internal"
17710 [(set (match_operand:V4HI 0 "nonimmediate_operand" "=y,m")
17711 (match_operand:V4HI 1 "nonimmediate_operand" "ym,y"))]
17712 "TARGET_MMX"
17713 "movq\t{%1, %0|%0, %1}"
17714 [(set_attr "type" "mmx")])
17715
17716 (define_insn "movv2si_internal"
17717 [(set (match_operand:V2SI 0 "nonimmediate_operand" "=y,m")
17718 (match_operand:V2SI 1 "nonimmediate_operand" "ym,y"))]
17719 "TARGET_MMX"
17720 "movq\t{%1, %0|%0, %1}"
17721 [(set_attr "type" "mmx")])
17722
17723 (define_insn "movv2sf_internal"
17724 [(set (match_operand:V2SF 0 "nonimmediate_operand" "=y,m")
17725 (match_operand:V2SF 1 "nonimmediate_operand" "ym,y"))]
17726 "TARGET_3DNOW"
17727 "movq\\t{%1, %0|%0, %1}"
17728 [(set_attr "type" "mmx")])
17729
17730 (define_expand "movti"
17731 [(set (match_operand:TI 0 "general_operand" "")
17732 (match_operand:TI 1 "general_operand" ""))]
17733 "TARGET_SSE || TARGET_64BIT"
17734 {
17735 if (TARGET_64BIT)
17736 ix86_expand_move (TImode, operands);
17737 else
17738 ix86_expand_vector_move (TImode, operands);
17739 DONE;
17740 })
17741
17742 (define_expand "movv4sf"
17743 [(set (match_operand:V4SF 0 "general_operand" "")
17744 (match_operand:V4SF 1 "general_operand" ""))]
17745 "TARGET_SSE"
17746 {
17747 ix86_expand_vector_move (V4SFmode, operands);
17748 DONE;
17749 })
17750
17751 (define_expand "movv4si"
17752 [(set (match_operand:V4SI 0 "general_operand" "")
17753 (match_operand:V4SI 1 "general_operand" ""))]
17754 "TARGET_MMX"
17755 {
17756 ix86_expand_vector_move (V4SImode, operands);
17757 DONE;
17758 })
17759
17760 (define_expand "movv2si"
17761 [(set (match_operand:V2SI 0 "general_operand" "")
17762 (match_operand:V2SI 1 "general_operand" ""))]
17763 "TARGET_MMX"
17764 {
17765 ix86_expand_vector_move (V2SImode, operands);
17766 DONE;
17767 })
17768
17769 (define_expand "movv4hi"
17770 [(set (match_operand:V4HI 0 "general_operand" "")
17771 (match_operand:V4HI 1 "general_operand" ""))]
17772 "TARGET_MMX"
17773 {
17774 ix86_expand_vector_move (V4HImode, operands);
17775 DONE;
17776 })
17777
17778 (define_expand "movv8qi"
17779 [(set (match_operand:V8QI 0 "general_operand" "")
17780 (match_operand:V8QI 1 "general_operand" ""))]
17781 "TARGET_MMX"
17782 {
17783 ix86_expand_vector_move (V8QImode, operands);
17784 DONE;
17785 })
17786
17787 (define_expand "movv2sf"
17788 [(set (match_operand:V2SF 0 "general_operand" "")
17789 (match_operand:V2SF 1 "general_operand" ""))]
17790 "TARGET_3DNOW"
17791 {
17792 ix86_expand_vector_move (V2SFmode, operands);
17793 DONE;
17794 })
17795
17796 (define_insn_and_split "*pushti"
17797 [(set (match_operand:TI 0 "push_operand" "=<")
17798 (match_operand:TI 1 "nonmemory_operand" "x"))]
17799 "TARGET_SSE"
17800 "#"
17801 ""
17802 [(set (reg:SI 7) (plus:SI (reg:SI 7) (const_int -16)))
17803 (set (mem:TI (reg:SI 7)) (match_dup 1))]
17804 ""
17805 [(set_attr "type" "sse")])
17806
17807 (define_insn_and_split "*pushv4sf"
17808 [(set (match_operand:V4SF 0 "push_operand" "=<")
17809 (match_operand:V4SF 1 "nonmemory_operand" "x"))]
17810 "TARGET_SSE"
17811 "#"
17812 ""
17813 [(set (reg:SI 7) (plus:SI (reg:SI 7) (const_int -16)))
17814 (set (mem:V4SF (reg:SI 7)) (match_dup 1))]
17815 ""
17816 [(set_attr "type" "sse")])
17817
17818 (define_insn_and_split "*pushv4si"
17819 [(set (match_operand:V4SI 0 "push_operand" "=<")
17820 (match_operand:V4SI 1 "nonmemory_operand" "x"))]
17821 "TARGET_SSE"
17822 "#"
17823 ""
17824 [(set (reg:SI 7) (plus:SI (reg:SI 7) (const_int -16)))
17825 (set (mem:V4SI (reg:SI 7)) (match_dup 1))]
17826 ""
17827 [(set_attr "type" "sse")])
17828
17829 (define_insn_and_split "*pushv2si"
17830 [(set (match_operand:V2SI 0 "push_operand" "=<")
17831 (match_operand:V2SI 1 "nonmemory_operand" "y"))]
17832 "TARGET_MMX"
17833 "#"
17834 ""
17835 [(set (reg:SI 7) (plus:SI (reg:SI 7) (const_int -8)))
17836 (set (mem:V2SI (reg:SI 7)) (match_dup 1))]
17837 ""
17838 [(set_attr "type" "mmx")])
17839
17840 (define_insn_and_split "*pushv4hi"
17841 [(set (match_operand:V4HI 0 "push_operand" "=<")
17842 (match_operand:V4HI 1 "nonmemory_operand" "y"))]
17843 "TARGET_MMX"
17844 "#"
17845 ""
17846 [(set (reg:SI 7) (plus:SI (reg:SI 7) (const_int -8)))
17847 (set (mem:V4HI (reg:SI 7)) (match_dup 1))]
17848 ""
17849 [(set_attr "type" "mmx")])
17850
17851 (define_insn_and_split "*pushv8qi"
17852 [(set (match_operand:V8QI 0 "push_operand" "=<")
17853 (match_operand:V8QI 1 "nonmemory_operand" "y"))]
17854 "TARGET_MMX"
17855 "#"
17856 ""
17857 [(set (reg:SI 7) (plus:SI (reg:SI 7) (const_int -8)))
17858 (set (mem:V8QI (reg:SI 7)) (match_dup 1))]
17859 ""
17860 [(set_attr "type" "mmx")])
17861
17862 (define_insn_and_split "*pushv2sf"
17863 [(set (match_operand:V2SF 0 "push_operand" "=<")
17864 (match_operand:V2SF 1 "nonmemory_operand" "y"))]
17865 "TARGET_3DNOW"
17866 "#"
17867 ""
17868 [(set (reg:SI 7) (plus:SI (reg:SI 7) (const_int -8)))
17869 (set (mem:V2SF (reg:SI 7)) (match_dup 1))]
17870 ""
17871 [(set_attr "type" "mmx")])
17872
17873 (define_insn "movti_internal"
17874 [(set (match_operand:TI 0 "nonimmediate_operand" "=x,x,m")
17875 (match_operand:TI 1 "general_operand" "O,xm,x"))]
17876 "TARGET_SSE && !TARGET_64BIT"
17877 "@
17878 xorps\t%0, %0
17879 movaps\t{%1, %0|%0, %1}
17880 movaps\t{%1, %0|%0, %1}"
17881 [(set_attr "type" "sse")])
17882
17883 (define_insn "*movti_rex64"
17884 [(set (match_operand:TI 0 "nonimmediate_operand" "=r,o,x,mx,x")
17885 (match_operand:TI 1 "general_operand" "riFo,riF,O,x,m"))]
17886 "TARGET_64BIT
17887 && (GET_CODE (operands[0]) != MEM || GET_CODE (operands[1]) != MEM)"
17888 "@
17889 #
17890 #
17891 xorps\t%0, %0
17892 movaps\\t{%1, %0|%0, %1}
17893 movaps\\t{%1, %0|%0, %1}"
17894 [(set_attr "type" "*,*,sse,sse,sse")
17895 (set_attr "mode" "TI")])
17896
17897 (define_split
17898 [(set (match_operand:TI 0 "nonimmediate_operand" "")
17899 (match_operand:TI 1 "general_operand" ""))]
17900 "reload_completed && !SSE_REG_P (operands[0])
17901 && !SSE_REG_P (operands[1])"
17902 [(const_int 0)]
17903 "ix86_split_long_move (operands); DONE;")
17904
17905 ;; These two patterns are useful for specifying exactly whether to use
17906 ;; movaps or movups
17907 (define_insn "sse_movaps"
17908 [(set (match_operand:V4SF 0 "nonimmediate_operand" "=x,m")
17909 (unspec:V4SF
17910 [(match_operand:V4SF 1 "nonimmediate_operand" "xm,x")] 38))]
17911 "TARGET_SSE"
17912 "@
17913 movaps\t{%1, %0|%0, %1}
17914 movaps\t{%1, %0|%0, %1}"
17915 [(set_attr "type" "sse")])
17916
17917 (define_insn "sse_movups"
17918 [(set (match_operand:V4SF 0 "nonimmediate_operand" "=x,m")
17919 (unspec:V4SF
17920 [(match_operand:V4SF 1 "nonimmediate_operand" "xm,x")] 39))]
17921 "TARGET_SSE"
17922 "@
17923 movups\t{%1, %0|%0, %1}
17924 movups\t{%1, %0|%0, %1}"
17925 [(set_attr "type" "sse")])
17926
17927
17928 ;; SSE Strange Moves.
17929
17930 (define_insn "sse_movmskps"
17931 [(set (match_operand:SI 0 "register_operand" "=r")
17932 (unspec:SI [(match_operand:V4SF 1 "register_operand" "x")] 33))]
17933 "TARGET_SSE"
17934 "movmskps\t{%1, %0|%0, %1}"
17935 [(set_attr "type" "sse")])
17936
17937 (define_insn "mmx_pmovmskb"
17938 [(set (match_operand:SI 0 "register_operand" "=r")
17939 (unspec:SI [(match_operand:V8QI 1 "register_operand" "y")] 33))]
17940 "TARGET_SSE || TARGET_3DNOW_A"
17941 "pmovmskb\t{%1, %0|%0, %1}"
17942 [(set_attr "type" "sse")])
17943
17944 (define_insn "mmx_maskmovq"
17945 [(set (mem:V8QI (match_operand:SI 0 "register_operand" "D"))
17946 (unspec:V8QI [(match_operand:V8QI 1 "register_operand" "y")
17947 (match_operand:V8QI 2 "register_operand" "y")] 32))]
17948 "TARGET_SSE || TARGET_3DNOW_A"
17949 ;; @@@ check ordering of operands in intel/nonintel syntax
17950 "maskmovq\t{%2, %1|%1, %2}"
17951 [(set_attr "type" "sse")])
17952
17953 (define_insn "sse_movntv4sf"
17954 [(set (match_operand:V4SF 0 "memory_operand" "=m")
17955 (unspec:V4SF [(match_operand:V4SF 1 "register_operand" "x")] 34))]
17956 "TARGET_SSE"
17957 "movntps\t{%1, %0|%0, %1}"
17958 [(set_attr "type" "sse")])
17959
17960 (define_insn "sse_movntdi"
17961 [(set (match_operand:DI 0 "memory_operand" "=m")
17962 (unspec:DI [(match_operand:DI 1 "register_operand" "y")] 34))]
17963 "TARGET_SSE || TARGET_3DNOW_A"
17964 "movntq\t{%1, %0|%0, %1}"
17965 [(set_attr "type" "sse")])
17966
17967 (define_insn "sse_movhlps"
17968 [(set (match_operand:V4SF 0 "register_operand" "=x")
17969 (vec_merge:V4SF
17970 (match_operand:V4SF 1 "register_operand" "0")
17971 (vec_select:V4SF (match_operand:V4SF 2 "register_operand" "x")
17972 (parallel [(const_int 2)
17973 (const_int 3)
17974 (const_int 0)
17975 (const_int 1)]))
17976 (const_int 3)))]
17977 "TARGET_SSE"
17978 "movhlps\t{%2, %0|%0, %2}"
17979 [(set_attr "type" "sse")])
17980
17981 (define_insn "sse_movlhps"
17982 [(set (match_operand:V4SF 0 "register_operand" "=x")
17983 (vec_merge:V4SF
17984 (match_operand:V4SF 1 "register_operand" "0")
17985 (vec_select:V4SF (match_operand:V4SF 2 "register_operand" "x")
17986 (parallel [(const_int 2)
17987 (const_int 3)
17988 (const_int 0)
17989 (const_int 1)]))
17990 (const_int 12)))]
17991 "TARGET_SSE"
17992 "movlhps\t{%2, %0|%0, %2}"
17993 [(set_attr "type" "sse")])
17994
17995 (define_insn "sse_movhps"
17996 [(set (match_operand:V4SF 0 "nonimmediate_operand" "=x,m")
17997 (vec_merge:V4SF
17998 (match_operand:V4SF 1 "nonimmediate_operand" "0,0")
17999 (match_operand:V4SF 2 "nonimmediate_operand" "m,x")
18000 (const_int 12)))]
18001 "TARGET_SSE
18002 && (GET_CODE (operands[1]) == MEM || GET_CODE (operands[2]) == MEM)"
18003 "movhps\t{%2, %0|%0, %2}"
18004 [(set_attr "type" "sse")])
18005
18006 (define_insn "sse_movlps"
18007 [(set (match_operand:V4SF 0 "nonimmediate_operand" "=x,m")
18008 (vec_merge:V4SF
18009 (match_operand:V4SF 1 "nonimmediate_operand" "0,0")
18010 (match_operand:V4SF 2 "nonimmediate_operand" "m,x")
18011 (const_int 3)))]
18012 "TARGET_SSE
18013 && (GET_CODE (operands[1]) == MEM || GET_CODE (operands[2]) == MEM)"
18014 "movlps\t{%2, %0|%0, %2}"
18015 [(set_attr "type" "sse")])
18016
18017 (define_insn "sse_loadss"
18018 [(set (match_operand:V4SF 0 "register_operand" "=x")
18019 (vec_merge:V4SF
18020 (match_operand:V4SF 1 "memory_operand" "m")
18021 (vec_duplicate:V4SF (float:SF (const_int 0)))
18022 (const_int 1)))]
18023 "TARGET_SSE"
18024 "movss\t{%1, %0|%0, %1}"
18025 [(set_attr "type" "sse")])
18026
18027 (define_insn "sse_movss"
18028 [(set (match_operand:V4SF 0 "register_operand" "=x")
18029 (vec_merge:V4SF
18030 (match_operand:V4SF 1 "register_operand" "0")
18031 (match_operand:V4SF 2 "register_operand" "x")
18032 (const_int 1)))]
18033 "TARGET_SSE"
18034 "movss\t{%2, %0|%0, %2}"
18035 [(set_attr "type" "sse")])
18036
18037 (define_insn "sse_storess"
18038 [(set (match_operand:SF 0 "memory_operand" "=m")
18039 (vec_select:SF
18040 (match_operand:V4SF 1 "register_operand" "x")
18041 (parallel [(const_int 0)])))]
18042 "TARGET_SSE"
18043 "movss\t{%1, %0|%0, %1}"
18044 [(set_attr "type" "sse")])
18045
18046 (define_insn "sse_shufps"
18047 [(set (match_operand:V4SF 0 "register_operand" "=x")
18048 (unspec:V4SF [(match_operand:V4SF 1 "register_operand" "0")
18049 (match_operand:V4SF 2 "nonimmediate_operand" "xm")
18050 (match_operand:SI 3 "immediate_operand" "i")] 41))]
18051 "TARGET_SSE"
18052 ;; @@@ check operand order for intel/nonintel syntax
18053 "shufps\t{%3, %2, %0|%0, %2, %3}"
18054 [(set_attr "type" "sse")])
18055
18056
18057 ;; SSE arithmetic
18058
18059 (define_insn "addv4sf3"
18060 [(set (match_operand:V4SF 0 "register_operand" "=x")
18061 (plus:V4SF (match_operand:V4SF 1 "register_operand" "0")
18062 (match_operand:V4SF 2 "nonimmediate_operand" "xm")))]
18063 "TARGET_SSE"
18064 "addps\t{%2, %0|%0, %2}"
18065 [(set_attr "type" "sse")])
18066
18067 (define_insn "vmaddv4sf3"
18068 [(set (match_operand:V4SF 0 "register_operand" "=x")
18069 (vec_merge:V4SF
18070 (plus:V4SF (match_operand:V4SF 1 "register_operand" "0")
18071 (match_operand:V4SF 2 "nonimmediate_operand" "xm"))
18072 (match_dup 1)
18073 (const_int 1)))]
18074 "TARGET_SSE"
18075 "addss\t{%2, %0|%0, %2}"
18076 [(set_attr "type" "sse")])
18077
18078 (define_insn "subv4sf3"
18079 [(set (match_operand:V4SF 0 "register_operand" "=x")
18080 (minus:V4SF (match_operand:V4SF 1 "register_operand" "0")
18081 (match_operand:V4SF 2 "nonimmediate_operand" "xm")))]
18082 "TARGET_SSE"
18083 "subps\t{%2, %0|%0, %2}"
18084 [(set_attr "type" "sse")])
18085
18086 (define_insn "vmsubv4sf3"
18087 [(set (match_operand:V4SF 0 "register_operand" "=x")
18088 (vec_merge:V4SF
18089 (minus:V4SF (match_operand:V4SF 1 "register_operand" "0")
18090 (match_operand:V4SF 2 "nonimmediate_operand" "xm"))
18091 (match_dup 1)
18092 (const_int 1)))]
18093 "TARGET_SSE"
18094 "subss\t{%2, %0|%0, %2}"
18095 [(set_attr "type" "sse")])
18096
18097 (define_insn "mulv4sf3"
18098 [(set (match_operand:V4SF 0 "register_operand" "=x")
18099 (mult:V4SF (match_operand:V4SF 1 "register_operand" "0")
18100 (match_operand:V4SF 2 "nonimmediate_operand" "xm")))]
18101 "TARGET_SSE"
18102 "mulps\t{%2, %0|%0, %2}"
18103 [(set_attr "type" "sse")])
18104
18105 (define_insn "vmmulv4sf3"
18106 [(set (match_operand:V4SF 0 "register_operand" "=x")
18107 (vec_merge:V4SF
18108 (mult:V4SF (match_operand:V4SF 1 "register_operand" "0")
18109 (match_operand:V4SF 2 "nonimmediate_operand" "xm"))
18110 (match_dup 1)
18111 (const_int 1)))]
18112 "TARGET_SSE"
18113 "mulss\t{%2, %0|%0, %2}"
18114 [(set_attr "type" "sse")])
18115
18116 (define_insn "divv4sf3"
18117 [(set (match_operand:V4SF 0 "register_operand" "=x")
18118 (div:V4SF (match_operand:V4SF 1 "register_operand" "0")
18119 (match_operand:V4SF 2 "nonimmediate_operand" "xm")))]
18120 "TARGET_SSE"
18121 "divps\t{%2, %0|%0, %2}"
18122 [(set_attr "type" "sse")])
18123
18124 (define_insn "vmdivv4sf3"
18125 [(set (match_operand:V4SF 0 "register_operand" "=x")
18126 (vec_merge:V4SF
18127 (div:V4SF (match_operand:V4SF 1 "register_operand" "0")
18128 (match_operand:V4SF 2 "nonimmediate_operand" "xm"))
18129 (match_dup 1)
18130 (const_int 1)))]
18131 "TARGET_SSE"
18132 "divss\t{%2, %0|%0, %2}"
18133 [(set_attr "type" "sse")])
18134
18135
18136 ;; SSE square root/reciprocal
18137
18138 (define_insn "rcpv4sf2"
18139 [(set (match_operand:V4SF 0 "register_operand" "=x")
18140 (unspec:V4SF
18141 [(match_operand:V4SF 1 "nonimmediate_operand" "xm")] 42))]
18142 "TARGET_SSE"
18143 "rcpps\t{%1, %0|%0, %1}"
18144 [(set_attr "type" "sse")])
18145
18146 (define_insn "vmrcpv4sf2"
18147 [(set (match_operand:V4SF 0 "register_operand" "=x")
18148 (vec_merge:V4SF
18149 (unspec:V4SF [(match_operand:V4SF 1 "nonimmediate_operand" "xm")] 42)
18150 (match_operand:V4SF 2 "register_operand" "0")
18151 (const_int 1)))]
18152 "TARGET_SSE"
18153 "rcpss\t{%1, %0|%0, %1}"
18154 [(set_attr "type" "sse")])
18155
18156 (define_insn "rsqrtv4sf2"
18157 [(set (match_operand:V4SF 0 "register_operand" "=x")
18158 (unspec:V4SF
18159 [(match_operand:V4SF 1 "nonimmediate_operand" "xm")] 43))]
18160 "TARGET_SSE"
18161 "rsqrtps\t{%1, %0|%0, %1}"
18162 [(set_attr "type" "sse")])
18163
18164 (define_insn "vmrsqrtv4sf2"
18165 [(set (match_operand:V4SF 0 "register_operand" "=x")
18166 (vec_merge:V4SF
18167 (unspec:V4SF [(match_operand:V4SF 1 "nonimmediate_operand" "xm")] 43)
18168 (match_operand:V4SF 2 "register_operand" "0")
18169 (const_int 1)))]
18170 "TARGET_SSE"
18171 "rsqrtss\t{%1, %0|%0, %1}"
18172 [(set_attr "type" "sse")])
18173
18174 (define_insn "sqrtv4sf2"
18175 [(set (match_operand:V4SF 0 "register_operand" "=x")
18176 (sqrt:V4SF (match_operand:V4SF 1 "nonimmediate_operand" "xm")))]
18177 "TARGET_SSE"
18178 "sqrtps\t{%1, %0|%0, %1}"
18179 [(set_attr "type" "sse")])
18180
18181 (define_insn "vmsqrtv4sf2"
18182 [(set (match_operand:V4SF 0 "register_operand" "=x")
18183 (vec_merge:V4SF
18184 (sqrt:V4SF (match_operand:V4SF 1 "nonimmediate_operand" "xm"))
18185 (match_operand:V4SF 2 "register_operand" "0")
18186 (const_int 1)))]
18187 "TARGET_SSE"
18188 "sqrtss\t{%1, %0|%0, %1}"
18189 [(set_attr "type" "sse")])
18190
18191 ;; SSE logical operations.
18192
18193 ;; These are not called andti3 etc. because we really really don't want
18194 ;; the compiler to widen DImode ands to TImode ands and then try to move
18195 ;; into DImode subregs of SSE registers, and them together, and move out
18196 ;; of DImode subregs again!
18197
18198 (define_insn "*sse_andti3_df_1"
18199 [(set (subreg:TI (match_operand:DF 0 "register_operand" "=Y") 0)
18200 (and:TI (subreg:TI (match_operand:DF 1 "register_operand" "%0") 0)
18201 (subreg:TI (match_operand:DF 2 "register_operand" "Y") 0)))]
18202 "TARGET_SSE2"
18203 "andpd\t{%2, %0|%0, %2}"
18204 [(set_attr "type" "sse")])
18205
18206 (define_insn "*sse_andti3_df_2"
18207 [(set (subreg:TI (match_operand:DF 0 "register_operand" "=Y") 0)
18208 (and:TI (subreg:TI (match_operand:DF 1 "register_operand" "0") 0)
18209 (match_operand:TI 2 "nonimmediate_operand" "Ym")))]
18210 "TARGET_SSE2"
18211 "andpd\t{%2, %0|%0, %2}"
18212 [(set_attr "type" "sse")])
18213
18214 (define_insn "*sse_andti3_sf_1"
18215 [(set (subreg:TI (match_operand:SF 0 "register_operand" "=x") 0)
18216 (and:TI (subreg:TI (match_operand:SF 1 "register_operand" "%0") 0)
18217 (subreg:TI (match_operand:SF 2 "register_operand" "x") 0)))]
18218 "TARGET_SSE"
18219 "andps\t{%2, %0|%0, %2}"
18220 [(set_attr "type" "sse")])
18221
18222 (define_insn "*sse_andti3_sf_2"
18223 [(set (subreg:TI (match_operand:SF 0 "register_operand" "=x") 0)
18224 (and:TI (subreg:TI (match_operand:SF 1 "register_operand" "0") 0)
18225 (match_operand:TI 2 "nonimmediate_operand" "xm")))]
18226 "TARGET_SSE"
18227 "andps\t{%2, %0|%0, %2}"
18228 [(set_attr "type" "sse")])
18229
18230 (define_insn "sse_andti3"
18231 [(set (match_operand:TI 0 "register_operand" "=x")
18232 (and:TI (match_operand:TI 1 "register_operand" "%0")
18233 (match_operand:TI 2 "nonimmediate_operand" "xm")))]
18234 "TARGET_SSE && !TARGET_SSE2"
18235 "andps\t{%2, %0|%0, %2}"
18236 [(set_attr "type" "sse")])
18237
18238 (define_insn "*sse_andti3_sse2"
18239 [(set (match_operand:TI 0 "register_operand" "=x")
18240 (and:TI (match_operand:TI 1 "register_operand" "%0")
18241 (match_operand:TI 2 "nonimmediate_operand" "xm")))]
18242 "TARGET_SSE2"
18243 "pand\t{%2, %0|%0, %2}"
18244 [(set_attr "type" "sse")])
18245
18246 (define_insn "*sse_nandti3_df"
18247 [(set (subreg:TI (match_operand:DF 0 "register_operand" "=Y") 0)
18248 (and:TI (not:TI (subreg:TI (match_operand:DF 1 "register_operand" "0") 0))
18249 (match_operand:TI 2 "nonimmediate_operand" "Ym")))]
18250 "TARGET_SSE2"
18251 "andnpd\t{%2, %0|%0, %2}"
18252 [(set_attr "type" "sse")])
18253
18254 (define_insn "*sse_nandti3_sf"
18255 [(set (subreg:TI (match_operand:SF 0 "register_operand" "=x") 0)
18256 (and:TI (not:TI (subreg:TI (match_operand:SF 1 "register_operand" "0") 0))
18257 (match_operand:TI 2 "nonimmediate_operand" "xm")))]
18258 "TARGET_SSE"
18259 "andnps\t{%2, %0|%0, %2}"
18260 [(set_attr "type" "sse")])
18261
18262 (define_insn "sse_nandti3"
18263 [(set (match_operand:TI 0 "register_operand" "=x")
18264 (and:TI (not:TI (match_operand:TI 1 "register_operand" "0"))
18265 (match_operand:TI 2 "nonimmediate_operand" "xm")))]
18266 "TARGET_SSE && !TARGET_SSE2"
18267 "andnps\t{%2, %0|%0, %2}"
18268 [(set_attr "type" "sse")])
18269
18270 (define_insn "*sse_nandti3_sse2"
18271 [(set (match_operand:TI 0 "register_operand" "=x")
18272 (and:TI (not:TI (match_operand:TI 1 "register_operand" "0"))
18273 (match_operand:TI 2 "nonimmediate_operand" "xm")))]
18274 "TARGET_SSE2"
18275 "pnand\t{%2, %0|%0, %2}"
18276 [(set_attr "type" "sse")])
18277
18278 (define_insn "*sse_iorti3_df_1"
18279 [(set (subreg:TI (match_operand:DF 0 "register_operand" "=Y") 0)
18280 (ior:TI (subreg:TI (match_operand:DF 1 "register_operand" "%0") 0)
18281 (subreg:TI (match_operand:DF 2 "register_operand" "Y") 0)))]
18282 "TARGET_SSE2"
18283 "orpd\t{%2, %0|%0, %2}"
18284 [(set_attr "type" "sse")])
18285
18286 (define_insn "*sse_iorti3_df_2"
18287 [(set (subreg:TI (match_operand:DF 0 "register_operand" "=Y") 0)
18288 (ior:TI (subreg:TI (match_operand:DF 1 "register_operand" "0") 0)
18289 (match_operand:TI 2 "nonimmediate_operand" "Ym")))]
18290 "TARGET_SSE2"
18291 "orpd\t{%2, %0|%0, %2}"
18292 [(set_attr "type" "sse")])
18293
18294 (define_insn "*sse_iorti3_sf_1"
18295 [(set (subreg:TI (match_operand:SF 0 "register_operand" "=x") 0)
18296 (ior:TI (subreg:TI (match_operand:SF 1 "register_operand" "%0") 0)
18297 (subreg:TI (match_operand:SF 2 "register_operand" "x") 0)))]
18298 "TARGET_SSE"
18299 "orps\t{%2, %0|%0, %2}"
18300 [(set_attr "type" "sse")])
18301
18302 (define_insn "*sse_iorti3_sf_2"
18303 [(set (subreg:TI (match_operand:SF 0 "register_operand" "=x") 0)
18304 (ior:TI (subreg:TI (match_operand:SF 1 "register_operand" "0") 0)
18305 (match_operand:TI 2 "nonimmediate_operand" "xm")))]
18306 "TARGET_SSE"
18307 "orps\t{%2, %0|%0, %2}"
18308 [(set_attr "type" "sse")])
18309
18310 (define_insn "sse_iorti3"
18311 [(set (match_operand:TI 0 "register_operand" "=x")
18312 (ior:TI (match_operand:TI 1 "register_operand" "%0")
18313 (match_operand:TI 2 "nonimmediate_operand" "xm")))]
18314 "TARGET_SSE && !TARGET_SSE2"
18315 "orps\t{%2, %0|%0, %2}"
18316 [(set_attr "type" "sse")])
18317
18318 (define_insn "*sse_iorti3_sse2"
18319 [(set (match_operand:TI 0 "register_operand" "=x")
18320 (ior:TI (match_operand:TI 1 "register_operand" "%0")
18321 (match_operand:TI 2 "nonimmediate_operand" "xm")))]
18322 "TARGET_SSE2"
18323 "por\t{%2, %0|%0, %2}"
18324 [(set_attr "type" "sse")])
18325
18326 (define_insn "*sse_xorti3_df_1"
18327 [(set (subreg:TI (match_operand:DF 0 "register_operand" "=Y") 0)
18328 (xor:TI (subreg:TI (match_operand:DF 1 "register_operand" "%0") 0)
18329 (subreg:TI (match_operand:DF 2 "register_operand" "Y") 0)))]
18330 "TARGET_SSE2"
18331 "xorpd\t{%2, %0|%0, %2}"
18332 [(set_attr "type" "sse")])
18333
18334 (define_insn "*sse_xorti3_df_2"
18335 [(set (subreg:TI (match_operand:DF 0 "register_operand" "=Y") 0)
18336 (xor:TI (subreg:TI (match_operand:DF 1 "register_operand" "0") 0)
18337 (match_operand:TI 2 "nonimmediate_operand" "Ym")))]
18338 "TARGET_SSE2"
18339 "xorpd\t{%2, %0|%0, %2}"
18340 [(set_attr "type" "sse")])
18341
18342 (define_insn "*sse_xorti3_sf_1"
18343 [(set (subreg:TI (match_operand:SF 0 "register_operand" "=x") 0)
18344 (xor:TI (subreg:TI (match_operand:SF 1 "register_operand" "%0") 0)
18345 (subreg:TI (match_operand:SF 2 "register_operand" "x") 0)))]
18346 "TARGET_SSE"
18347 "xorps\t{%2, %0|%0, %2}"
18348 [(set_attr "type" "sse")])
18349
18350 (define_insn "*sse_xorti3_sf_2"
18351 [(set (subreg:TI (match_operand:SF 0 "register_operand" "=x") 0)
18352 (xor:TI (subreg:TI (match_operand:SF 1 "register_operand" "0") 0)
18353 (match_operand:TI 2 "nonimmediate_operand" "xm")))]
18354 "TARGET_SSE"
18355 "xorps\t{%2, %0|%0, %2}"
18356 [(set_attr "type" "sse")])
18357
18358 (define_insn "sse_xorti3"
18359 [(set (match_operand:TI 0 "register_operand" "=x")
18360 (xor:TI (match_operand:TI 1 "register_operand" "%0")
18361 (match_operand:TI 2 "nonimmediate_operand" "xm")))]
18362 "TARGET_SSE && !TARGET_SSE2"
18363 "xorps\t{%2, %0|%0, %2}"
18364 [(set_attr "type" "sse")])
18365
18366 (define_insn "*sse_xorti3_sse2"
18367 [(set (match_operand:TI 0 "register_operand" "=x")
18368 (xor:TI (match_operand:TI 1 "register_operand" "%0")
18369 (match_operand:TI 2 "nonimmediate_operand" "xm")))]
18370 "TARGET_SSE2"
18371 "pxor\t{%2, %0|%0, %2}"
18372 [(set_attr "type" "sse")])
18373
18374 ;; Use xor, but don't show input operands so they aren't live before
18375 ;; this insn.
18376 (define_insn "sse_clrv4sf"
18377 [(set (match_operand:V4SF 0 "register_operand" "=x")
18378 (unspec:V4SF [(const_int 0)] 45))]
18379 "TARGET_SSE"
18380 "xorps\t{%0, %0|%0, %0}"
18381 [(set_attr "type" "sse")
18382 (set_attr "memory" "none")])
18383
18384 ;; SSE mask-generating compares
18385
18386 (define_insn "maskcmpv4sf3"
18387 [(set (match_operand:V4SI 0 "register_operand" "=x")
18388 (match_operator:V4SI 3 "sse_comparison_operator"
18389 [(match_operand:V4SF 1 "register_operand" "0")
18390 (match_operand:V4SF 2 "register_operand" "x")]))]
18391 "TARGET_SSE"
18392 "cmp%D3ps\t{%2, %0|%0, %2}"
18393 [(set_attr "type" "sse")])
18394
18395 (define_insn "maskncmpv4sf3"
18396 [(set (match_operand:V4SI 0 "register_operand" "=x")
18397 (not:V4SI
18398 (match_operator:V4SI 3 "sse_comparison_operator"
18399 [(match_operand:V4SF 1 "register_operand" "0")
18400 (match_operand:V4SF 2 "register_operand" "x")])))]
18401 "TARGET_SSE"
18402 {
18403 if (GET_CODE (operands[3]) == UNORDERED)
18404 return "cmpordps\t{%2, %0|%0, %2}";
18405 else
18406 return "cmpn%D3ps\t{%2, %0|%0, %2}";
18407 }
18408 [(set_attr "type" "sse")])
18409
18410 (define_insn "vmmaskcmpv4sf3"
18411 [(set (match_operand:V4SI 0 "register_operand" "=x")
18412 (vec_merge:V4SI
18413 (match_operator:V4SI 3 "sse_comparison_operator"
18414 [(match_operand:V4SF 1 "register_operand" "0")
18415 (match_operand:V4SF 2 "register_operand" "x")])
18416 (match_dup 1)
18417 (const_int 1)))]
18418 "TARGET_SSE"
18419 "cmp%D3ss\t{%2, %0|%0, %2}"
18420 [(set_attr "type" "sse")])
18421
18422 (define_insn "vmmaskncmpv4sf3"
18423 [(set (match_operand:V4SI 0 "register_operand" "=x")
18424 (vec_merge:V4SI
18425 (not:V4SI
18426 (match_operator:V4SI 3 "sse_comparison_operator"
18427 [(match_operand:V4SF 1 "register_operand" "0")
18428 (match_operand:V4SF 2 "register_operand" "x")]))
18429 (subreg:V4SI (match_dup 1) 0)
18430 (const_int 1)))]
18431 "TARGET_SSE"
18432 {
18433 if (GET_CODE (operands[3]) == UNORDERED)
18434 return "cmpordss\t{%2, %0|%0, %2}";
18435 else
18436 return "cmpn%D3ss\t{%2, %0|%0, %2}";
18437 }
18438 [(set_attr "type" "sse")])
18439
18440 (define_insn "sse_comi"
18441 [(set (reg:CCFP 17)
18442 (match_operator:CCFP 2 "sse_comparison_operator"
18443 [(vec_select:SF
18444 (match_operand:V4SF 0 "register_operand" "x")
18445 (parallel [(const_int 0)]))
18446 (vec_select:SF
18447 (match_operand:V4SF 1 "register_operand" "x")
18448 (parallel [(const_int 0)]))]))]
18449 "TARGET_SSE"
18450 "comiss\t{%1, %0|%0, %1}"
18451 [(set_attr "type" "sse")])
18452
18453 (define_insn "sse_ucomi"
18454 [(set (reg:CCFPU 17)
18455 (match_operator:CCFPU 2 "sse_comparison_operator"
18456 [(vec_select:SF
18457 (match_operand:V4SF 0 "register_operand" "x")
18458 (parallel [(const_int 0)]))
18459 (vec_select:SF
18460 (match_operand:V4SF 1 "register_operand" "x")
18461 (parallel [(const_int 0)]))]))]
18462 "TARGET_SSE"
18463 "ucomiss\t{%1, %0|%0, %1}"
18464 [(set_attr "type" "sse")])
18465
18466
18467 ;; SSE unpack
18468
18469 (define_insn "sse_unpckhps"
18470 [(set (match_operand:V4SF 0 "register_operand" "=x")
18471 (vec_merge:V4SF
18472 (vec_select:V4SF (match_operand:V4SF 1 "register_operand" "0")
18473 (parallel [(const_int 2)
18474 (const_int 0)
18475 (const_int 3)
18476 (const_int 1)]))
18477 (vec_select:V4SF (match_operand:V4SF 2 "register_operand" "x")
18478 (parallel [(const_int 0)
18479 (const_int 2)
18480 (const_int 1)
18481 (const_int 3)]))
18482 (const_int 5)))]
18483 "TARGET_SSE"
18484 "unpckhps\t{%2, %0|%0, %2}"
18485 [(set_attr "type" "sse")])
18486
18487 (define_insn "sse_unpcklps"
18488 [(set (match_operand:V4SF 0 "register_operand" "=x")
18489 (vec_merge:V4SF
18490 (vec_select:V4SF (match_operand:V4SF 1 "register_operand" "0")
18491 (parallel [(const_int 0)
18492 (const_int 2)
18493 (const_int 1)
18494 (const_int 3)]))
18495 (vec_select:V4SF (match_operand:V4SF 2 "register_operand" "x")
18496 (parallel [(const_int 2)
18497 (const_int 0)
18498 (const_int 3)
18499 (const_int 1)]))
18500 (const_int 5)))]
18501 "TARGET_SSE"
18502 "unpcklps\t{%2, %0|%0, %2}"
18503 [(set_attr "type" "sse")])
18504
18505
18506 ;; SSE min/max
18507
18508 (define_insn "smaxv4sf3"
18509 [(set (match_operand:V4SF 0 "register_operand" "=x")
18510 (smax:V4SF (match_operand:V4SF 1 "register_operand" "0")
18511 (match_operand:V4SF 2 "nonimmediate_operand" "xm")))]
18512 "TARGET_SSE"
18513 "maxps\t{%2, %0|%0, %2}"
18514 [(set_attr "type" "sse")])
18515
18516 (define_insn "vmsmaxv4sf3"
18517 [(set (match_operand:V4SF 0 "register_operand" "=x")
18518 (vec_merge:V4SF
18519 (smax:V4SF (match_operand:V4SF 1 "register_operand" "0")
18520 (match_operand:V4SF 2 "nonimmediate_operand" "xm"))
18521 (match_dup 1)
18522 (const_int 1)))]
18523 "TARGET_SSE"
18524 "maxss\t{%2, %0|%0, %2}"
18525 [(set_attr "type" "sse")])
18526
18527 (define_insn "sminv4sf3"
18528 [(set (match_operand:V4SF 0 "register_operand" "=x")
18529 (smin:V4SF (match_operand:V4SF 1 "register_operand" "0")
18530 (match_operand:V4SF 2 "nonimmediate_operand" "xm")))]
18531 "TARGET_SSE"
18532 "minps\t{%2, %0|%0, %2}"
18533 [(set_attr "type" "sse")])
18534
18535 (define_insn "vmsminv4sf3"
18536 [(set (match_operand:V4SF 0 "register_operand" "=x")
18537 (vec_merge:V4SF
18538 (smin:V4SF (match_operand:V4SF 1 "register_operand" "0")
18539 (match_operand:V4SF 2 "nonimmediate_operand" "xm"))
18540 (match_dup 1)
18541 (const_int 1)))]
18542 "TARGET_SSE"
18543 "minss\t{%2, %0|%0, %2}"
18544 [(set_attr "type" "sse")])
18545
18546
18547 ;; SSE <-> integer/MMX conversions
18548
18549 (define_insn "cvtpi2ps"
18550 [(set (match_operand:V4SF 0 "register_operand" "=x")
18551 (vec_merge:V4SF
18552 (match_operand:V4SF 1 "register_operand" "0")
18553 (vec_duplicate:V4SF
18554 (float:V2SF (match_operand:V2SI 2 "nonimmediate_operand" "ym")))
18555 (const_int 12)))]
18556 "TARGET_SSE"
18557 "cvtpi2ps\t{%2, %0|%0, %2}"
18558 [(set_attr "type" "sse")])
18559
18560 (define_insn "cvtps2pi"
18561 [(set (match_operand:V2SI 0 "register_operand" "=y")
18562 (vec_select:V2SI
18563 (fix:V4SI (match_operand:V4SF 1 "nonimmediate_operand" "xm"))
18564 (parallel [(const_int 0) (const_int 1)])))]
18565 "TARGET_SSE"
18566 "cvtps2pi\t{%1, %0|%0, %1}"
18567 [(set_attr "type" "sse")])
18568
18569 (define_insn "cvttps2pi"
18570 [(set (match_operand:V2SI 0 "register_operand" "=y")
18571 (vec_select:V2SI
18572 (unspec:V4SI [(match_operand:V4SF 1 "nonimmediate_operand" "xm")] 30)
18573 (parallel [(const_int 0) (const_int 1)])))]
18574 "TARGET_SSE"
18575 "cvttps2pi\t{%1, %0|%0, %1}"
18576 [(set_attr "type" "sse")])
18577
18578 (define_insn "cvtsi2ss"
18579 [(set (match_operand:V4SF 0 "register_operand" "=x")
18580 (vec_merge:V4SF
18581 (match_operand:V4SF 1 "register_operand" "0")
18582 (vec_duplicate:V4SF
18583 (float:SF (match_operand:SI 2 "nonimmediate_operand" "rm")))
18584 (const_int 14)))]
18585 "TARGET_SSE"
18586 "cvtsi2ss\t{%2, %0|%0, %2}"
18587 [(set_attr "type" "sse")])
18588
18589 (define_insn "cvtss2si"
18590 [(set (match_operand:SI 0 "register_operand" "=r")
18591 (vec_select:SI
18592 (fix:V4SI (match_operand:V4SF 1 "nonimmediate_operand" "xm"))
18593 (parallel [(const_int 0)])))]
18594 "TARGET_SSE"
18595 "cvtss2si\t{%1, %0|%0, %1}"
18596 [(set_attr "type" "sse")])
18597
18598 (define_insn "cvttss2si"
18599 [(set (match_operand:SI 0 "register_operand" "=r")
18600 (vec_select:SI
18601 (unspec:V4SI [(match_operand:V4SF 1 "nonimmediate_operand" "xm")] 30)
18602 (parallel [(const_int 0)])))]
18603 "TARGET_SSE"
18604 "cvttss2si\t{%1, %0|%0, %1}"
18605 [(set_attr "type" "sse")])
18606
18607
18608 ;; MMX insns
18609
18610 ;; MMX arithmetic
18611
18612 (define_insn "addv8qi3"
18613 [(set (match_operand:V8QI 0 "register_operand" "=y")
18614 (plus:V8QI (match_operand:V8QI 1 "register_operand" "0")
18615 (match_operand:V8QI 2 "nonimmediate_operand" "ym")))]
18616 "TARGET_MMX"
18617 "paddb\t{%2, %0|%0, %2}"
18618 [(set_attr "type" "mmx")])
18619
18620 (define_insn "addv4hi3"
18621 [(set (match_operand:V4HI 0 "register_operand" "=y")
18622 (plus:V4HI (match_operand:V4HI 1 "register_operand" "0")
18623 (match_operand:V4HI 2 "nonimmediate_operand" "ym")))]
18624 "TARGET_MMX"
18625 "paddw\t{%2, %0|%0, %2}"
18626 [(set_attr "type" "mmx")])
18627
18628 (define_insn "addv2si3"
18629 [(set (match_operand:V2SI 0 "register_operand" "=y")
18630 (plus:V2SI (match_operand:V2SI 1 "register_operand" "0")
18631 (match_operand:V2SI 2 "nonimmediate_operand" "ym")))]
18632 "TARGET_MMX"
18633 "paddd\t{%2, %0|%0, %2}"
18634 [(set_attr "type" "mmx")])
18635
18636 (define_insn "ssaddv8qi3"
18637 [(set (match_operand:V8QI 0 "register_operand" "=y")
18638 (ss_plus:V8QI (match_operand:V8QI 1 "register_operand" "0")
18639 (match_operand:V8QI 2 "nonimmediate_operand" "ym")))]
18640 "TARGET_MMX"
18641 "paddsb\t{%2, %0|%0, %2}"
18642 [(set_attr "type" "mmx")])
18643
18644 (define_insn "ssaddv4hi3"
18645 [(set (match_operand:V4HI 0 "register_operand" "=y")
18646 (ss_plus:V4HI (match_operand:V4HI 1 "register_operand" "0")
18647 (match_operand:V4HI 2 "nonimmediate_operand" "ym")))]
18648 "TARGET_MMX"
18649 "paddsw\t{%2, %0|%0, %2}"
18650 [(set_attr "type" "mmx")])
18651
18652 (define_insn "usaddv8qi3"
18653 [(set (match_operand:V8QI 0 "register_operand" "=y")
18654 (us_plus:V8QI (match_operand:V8QI 1 "register_operand" "0")
18655 (match_operand:V8QI 2 "nonimmediate_operand" "ym")))]
18656 "TARGET_MMX"
18657 "paddusb\t{%2, %0|%0, %2}"
18658 [(set_attr "type" "mmx")])
18659
18660 (define_insn "usaddv4hi3"
18661 [(set (match_operand:V4HI 0 "register_operand" "=y")
18662 (us_plus:V4HI (match_operand:V4HI 1 "register_operand" "0")
18663 (match_operand:V4HI 2 "nonimmediate_operand" "ym")))]
18664 "TARGET_MMX"
18665 "paddusw\t{%2, %0|%0, %2}"
18666 [(set_attr "type" "mmx")])
18667
18668 (define_insn "subv8qi3"
18669 [(set (match_operand:V8QI 0 "register_operand" "=y")
18670 (minus:V8QI (match_operand:V8QI 1 "register_operand" "0")
18671 (match_operand:V8QI 2 "nonimmediate_operand" "ym")))]
18672 "TARGET_MMX"
18673 "psubb\t{%2, %0|%0, %2}"
18674 [(set_attr "type" "mmx")])
18675
18676 (define_insn "subv4hi3"
18677 [(set (match_operand:V4HI 0 "register_operand" "=y")
18678 (minus:V4HI (match_operand:V4HI 1 "register_operand" "0")
18679 (match_operand:V4HI 2 "nonimmediate_operand" "ym")))]
18680 "TARGET_MMX"
18681 "psubw\t{%2, %0|%0, %2}"
18682 [(set_attr "type" "mmx")])
18683
18684 (define_insn "subv2si3"
18685 [(set (match_operand:V2SI 0 "register_operand" "=y")
18686 (minus:V2SI (match_operand:V2SI 1 "register_operand" "0")
18687 (match_operand:V2SI 2 "nonimmediate_operand" "ym")))]
18688 "TARGET_MMX"
18689 "psubd\t{%2, %0|%0, %2}"
18690 [(set_attr "type" "mmx")])
18691
18692 (define_insn "sssubv8qi3"
18693 [(set (match_operand:V8QI 0 "register_operand" "=y")
18694 (ss_minus:V8QI (match_operand:V8QI 1 "register_operand" "0")
18695 (match_operand:V8QI 2 "nonimmediate_operand" "ym")))]
18696 "TARGET_MMX"
18697 "psubsb\t{%2, %0|%0, %2}"
18698 [(set_attr "type" "mmx")])
18699
18700 (define_insn "sssubv4hi3"
18701 [(set (match_operand:V4HI 0 "register_operand" "=y")
18702 (ss_minus:V4HI (match_operand:V4HI 1 "register_operand" "0")
18703 (match_operand:V4HI 2 "nonimmediate_operand" "ym")))]
18704 "TARGET_MMX"
18705 "psubsw\t{%2, %0|%0, %2}"
18706 [(set_attr "type" "mmx")])
18707
18708 (define_insn "ussubv8qi3"
18709 [(set (match_operand:V8QI 0 "register_operand" "=y")
18710 (us_minus:V8QI (match_operand:V8QI 1 "register_operand" "0")
18711 (match_operand:V8QI 2 "nonimmediate_operand" "ym")))]
18712 "TARGET_MMX"
18713 "psubusb\t{%2, %0|%0, %2}"
18714 [(set_attr "type" "mmx")])
18715
18716 (define_insn "ussubv4hi3"
18717 [(set (match_operand:V4HI 0 "register_operand" "=y")
18718 (us_minus:V4HI (match_operand:V4HI 1 "register_operand" "0")
18719 (match_operand:V4HI 2 "nonimmediate_operand" "ym")))]
18720 "TARGET_MMX"
18721 "psubusw\t{%2, %0|%0, %2}"
18722 [(set_attr "type" "mmx")])
18723
18724 (define_insn "mulv4hi3"
18725 [(set (match_operand:V4HI 0 "register_operand" "=y")
18726 (mult:V4HI (match_operand:V4HI 1 "register_operand" "0")
18727 (match_operand:V4HI 2 "nonimmediate_operand" "ym")))]
18728 "TARGET_MMX"
18729 "pmullw\t{%2, %0|%0, %2}"
18730 [(set_attr "type" "mmx")])
18731
18732 (define_insn "smulv4hi3_highpart"
18733 [(set (match_operand:V4HI 0 "register_operand" "=y")
18734 (truncate:V4HI
18735 (lshiftrt:V4SI
18736 (mult:V4SI (sign_extend:V4SI
18737 (match_operand:V4HI 1 "register_operand" "0"))
18738 (sign_extend:V4SI
18739 (match_operand:V4HI 2 "nonimmediate_operand" "ym")))
18740 (const_int 16))))]
18741 "TARGET_MMX"
18742 "pmulhw\t{%2, %0|%0, %2}"
18743 [(set_attr "type" "mmx")])
18744
18745 (define_insn "umulv4hi3_highpart"
18746 [(set (match_operand:V4HI 0 "register_operand" "=y")
18747 (truncate:V4HI
18748 (lshiftrt:V4SI
18749 (mult:V4SI (zero_extend:V4SI
18750 (match_operand:V4HI 1 "register_operand" "0"))
18751 (zero_extend:V4SI
18752 (match_operand:V4HI 2 "nonimmediate_operand" "ym")))
18753 (const_int 16))))]
18754 "TARGET_SSE || TARGET_3DNOW_A"
18755 "pmulhuw\t{%2, %0|%0, %2}"
18756 [(set_attr "type" "mmx")])
18757
18758 (define_insn "mmx_pmaddwd"
18759 [(set (match_operand:V2SI 0 "register_operand" "=y")
18760 (plus:V2SI
18761 (mult:V2SI
18762 (sign_extend:V2SI
18763 (vec_select:V2HI (match_operand:V4HI 1 "register_operand" "0")
18764 (parallel [(const_int 0) (const_int 2)])))
18765 (sign_extend:V2SI
18766 (vec_select:V2HI (match_operand:V4HI 2 "nonimmediate_operand" "ym")
18767 (parallel [(const_int 0) (const_int 2)]))))
18768 (mult:V2SI
18769 (sign_extend:V2SI (vec_select:V2HI (match_dup 1)
18770 (parallel [(const_int 1)
18771 (const_int 3)])))
18772 (sign_extend:V2SI (vec_select:V2HI (match_dup 2)
18773 (parallel [(const_int 1)
18774 (const_int 3)]))))))]
18775 "TARGET_MMX"
18776 "pmaddwd\t{%2, %0|%0, %2}"
18777 [(set_attr "type" "mmx")])
18778
18779
18780 ;; MMX logical operations
18781 ;; Note we don't want to declare these as regular iordi3 insns to prevent
18782 ;; normal code that also wants to use the FPU from getting broken.
18783 ;; The UNSPECs are there to prevent the combiner from getting overly clever.
18784 (define_insn "mmx_iordi3"
18785 [(set (match_operand:DI 0 "register_operand" "=y")
18786 (unspec:DI
18787 [(ior:DI (match_operand:DI 1 "register_operand" "0")
18788 (match_operand:DI 2 "nonimmediate_operand" "ym"))] 45))]
18789 "TARGET_MMX"
18790 "por\t{%2, %0|%0, %2}"
18791 [(set_attr "type" "mmx")])
18792
18793 (define_insn "mmx_xordi3"
18794 [(set (match_operand:DI 0 "register_operand" "=y")
18795 (unspec:DI
18796 [(xor:DI (match_operand:DI 1 "register_operand" "0")
18797 (match_operand:DI 2 "nonimmediate_operand" "ym"))] 45))]
18798 "TARGET_MMX"
18799 "pxor\t{%2, %0|%0, %2}"
18800 [(set_attr "type" "mmx")
18801 (set_attr "memory" "none")])
18802
18803 ;; Same as pxor, but don't show input operands so that we don't think
18804 ;; they are live.
18805 (define_insn "mmx_clrdi"
18806 [(set (match_operand:DI 0 "register_operand" "=y")
18807 (unspec:DI [(const_int 0)] 45))]
18808 "TARGET_MMX"
18809 "pxor\t{%0, %0|%0, %0}"
18810 [(set_attr "type" "mmx")
18811 (set_attr "memory" "none")])
18812
18813 (define_insn "mmx_anddi3"
18814 [(set (match_operand:DI 0 "register_operand" "=y")
18815 (unspec:DI
18816 [(and:DI (match_operand:DI 1 "register_operand" "0")
18817 (match_operand:DI 2 "nonimmediate_operand" "ym"))] 45))]
18818 "TARGET_MMX"
18819 "pand\t{%2, %0|%0, %2}"
18820 [(set_attr "type" "mmx")])
18821
18822 (define_insn "mmx_nanddi3"
18823 [(set (match_operand:DI 0 "register_operand" "=y")
18824 (unspec:DI
18825 [(and:DI (not:DI (match_operand:DI 1 "register_operand" "0"))
18826 (match_operand:DI 2 "nonimmediate_operand" "ym"))] 45))]
18827 "TARGET_MMX"
18828 "pandn\t{%2, %0|%0, %2}"
18829 [(set_attr "type" "mmx")])
18830
18831
18832 ;; MMX unsigned averages/sum of absolute differences
18833
18834 (define_insn "mmx_uavgv8qi3"
18835 [(set (match_operand:V8QI 0 "register_operand" "=y")
18836 (ashiftrt:V8QI
18837 (plus:V8QI (plus:V8QI
18838 (match_operand:V8QI 1 "register_operand" "0")
18839 (match_operand:V8QI 2 "nonimmediate_operand" "ym"))
18840 (vec_const:V8QI (parallel [(const_int 1)
18841 (const_int 1)
18842 (const_int 1)
18843 (const_int 1)
18844 (const_int 1)
18845 (const_int 1)
18846 (const_int 1)
18847 (const_int 1)])))
18848 (const_int 1)))]
18849 "TARGET_SSE || TARGET_3DNOW_A"
18850 "pavgb\t{%2, %0|%0, %2}"
18851 [(set_attr "type" "sse")])
18852
18853 (define_insn "mmx_uavgv4hi3"
18854 [(set (match_operand:V4HI 0 "register_operand" "=y")
18855 (ashiftrt:V4HI
18856 (plus:V4HI (plus:V4HI
18857 (match_operand:V4HI 1 "register_operand" "0")
18858 (match_operand:V4HI 2 "nonimmediate_operand" "ym"))
18859 (vec_const:V4HI (parallel [(const_int 1)
18860 (const_int 1)
18861 (const_int 1)
18862 (const_int 1)])))
18863 (const_int 1)))]
18864 "TARGET_SSE || TARGET_3DNOW_A"
18865 "pavgw\t{%2, %0|%0, %2}"
18866 [(set_attr "type" "sse")])
18867
18868 (define_insn "mmx_psadbw"
18869 [(set (match_operand:V8QI 0 "register_operand" "=y")
18870 (abs:V8QI (minus:V8QI (match_operand:V8QI 1 "register_operand" "0")
18871 (match_operand:V8QI 2 "nonimmediate_operand" "ym"))))]
18872 "TARGET_SSE || TARGET_3DNOW_A"
18873 "psadbw\t{%2, %0|%0, %2}"
18874 [(set_attr "type" "sse")])
18875
18876
18877 ;; MMX insert/extract/shuffle
18878
18879 (define_insn "mmx_pinsrw"
18880 [(set (match_operand:V4HI 0 "register_operand" "=y")
18881 (vec_merge:V4HI (match_operand:V4HI 1 "register_operand" "0")
18882 (vec_duplicate:V4HI
18883 (truncate:HI (match_operand:SI 2 "nonimmediate_operand" "rm")))
18884 (match_operand:SI 3 "immediate_operand" "i")))]
18885 "TARGET_SSE || TARGET_3DNOW_A"
18886 "pinsrw\t{%3, %2, %0|%0, %2, %3}"
18887 [(set_attr "type" "sse")])
18888
18889 (define_insn "mmx_pextrw"
18890 [(set (match_operand:SI 0 "register_operand" "=r")
18891 (zero_extend:SI (vec_select:HI (match_operand:V4HI 1 "register_operand" "y")
18892 (parallel
18893 [(match_operand:SI 2 "immediate_operand" "i")]))))]
18894 "TARGET_SSE || TARGET_3DNOW_A"
18895 "pextrw\t{%2, %1, %0|%0, %1, %2}"
18896 [(set_attr "type" "sse")])
18897
18898 (define_insn "mmx_pshufw"
18899 [(set (match_operand:V4HI 0 "register_operand" "=y")
18900 (unspec:V4HI [(match_operand:V4HI 1 "register_operand" "0")
18901 (match_operand:SI 2 "immediate_operand" "i")] 41))]
18902 "TARGET_SSE || TARGET_3DNOW_A"
18903 "pshufw\t{%2, %1, %0|%0, %1, %2}"
18904 [(set_attr "type" "sse")])
18905
18906
18907 ;; MMX mask-generating comparisons
18908
18909 (define_insn "eqv8qi3"
18910 [(set (match_operand:V8QI 0 "register_operand" "=y")
18911 (eq:V8QI (match_operand:V8QI 1 "register_operand" "0")
18912 (match_operand:V8QI 2 "nonimmediate_operand" "ym")))]
18913 "TARGET_MMX"
18914 "pcmpeqb\t{%2, %0|%0, %2}"
18915 [(set_attr "type" "mmx")])
18916
18917 (define_insn "eqv4hi3"
18918 [(set (match_operand:V4HI 0 "register_operand" "=y")
18919 (eq:V4HI (match_operand:V4HI 1 "register_operand" "0")
18920 (match_operand:V4HI 2 "nonimmediate_operand" "ym")))]
18921 "TARGET_MMX"
18922 "pcmpeqw\t{%2, %0|%0, %2}"
18923 [(set_attr "type" "mmx")])
18924
18925 (define_insn "eqv2si3"
18926 [(set (match_operand:V2SI 0 "register_operand" "=y")
18927 (eq:V2SI (match_operand:V2SI 1 "register_operand" "0")
18928 (match_operand:V2SI 2 "nonimmediate_operand" "ym")))]
18929 "TARGET_MMX"
18930 "pcmpeqd\t{%2, %0|%0, %2}"
18931 [(set_attr "type" "mmx")])
18932
18933 (define_insn "gtv8qi3"
18934 [(set (match_operand:V8QI 0 "register_operand" "=y")
18935 (gt:V8QI (match_operand:V8QI 1 "register_operand" "0")
18936 (match_operand:V8QI 2 "nonimmediate_operand" "ym")))]
18937 "TARGET_MMX"
18938 "pcmpgtb\t{%2, %0|%0, %2}"
18939 [(set_attr "type" "mmx")])
18940
18941 (define_insn "gtv4hi3"
18942 [(set (match_operand:V4HI 0 "register_operand" "=y")
18943 (gt:V4HI (match_operand:V4HI 1 "register_operand" "0")
18944 (match_operand:V4HI 2 "nonimmediate_operand" "ym")))]
18945 "TARGET_MMX"
18946 "pcmpgtw\t{%2, %0|%0, %2}"
18947 [(set_attr "type" "mmx")])
18948
18949 (define_insn "gtv2si3"
18950 [(set (match_operand:V2SI 0 "register_operand" "=y")
18951 (gt:V2SI (match_operand:V2SI 1 "register_operand" "0")
18952 (match_operand:V2SI 2 "nonimmediate_operand" "ym")))]
18953 "TARGET_MMX"
18954 "pcmpgtd\t{%2, %0|%0, %2}"
18955 [(set_attr "type" "mmx")])
18956
18957
18958 ;; MMX max/min insns
18959
18960 (define_insn "umaxv8qi3"
18961 [(set (match_operand:V8QI 0 "register_operand" "=y")
18962 (umax:V8QI (match_operand:V8QI 1 "register_operand" "0")
18963 (match_operand:V8QI 2 "nonimmediate_operand" "ym")))]
18964 "TARGET_SSE || TARGET_3DNOW_A"
18965 "pmaxub\t{%2, %0|%0, %2}"
18966 [(set_attr "type" "sse")])
18967
18968 (define_insn "smaxv4hi3"
18969 [(set (match_operand:V4HI 0 "register_operand" "=y")
18970 (smax:V4HI (match_operand:V4HI 1 "register_operand" "0")
18971 (match_operand:V4HI 2 "nonimmediate_operand" "ym")))]
18972 "TARGET_SSE || TARGET_3DNOW_A"
18973 "pmaxsw\t{%2, %0|%0, %2}"
18974 [(set_attr "type" "sse")])
18975
18976 (define_insn "uminv8qi3"
18977 [(set (match_operand:V8QI 0 "register_operand" "=y")
18978 (umin:V8QI (match_operand:V8QI 1 "register_operand" "0")
18979 (match_operand:V8QI 2 "nonimmediate_operand" "ym")))]
18980 "TARGET_SSE || TARGET_3DNOW_A"
18981 "pminub\t{%2, %0|%0, %2}"
18982 [(set_attr "type" "sse")])
18983
18984 (define_insn "sminv4hi3"
18985 [(set (match_operand:V4HI 0 "register_operand" "=y")
18986 (smin:V4HI (match_operand:V4HI 1 "register_operand" "0")
18987 (match_operand:V4HI 2 "nonimmediate_operand" "ym")))]
18988 "TARGET_SSE || TARGET_3DNOW_A"
18989 "pminsw\t{%2, %0|%0, %2}"
18990 [(set_attr "type" "sse")])
18991
18992
18993 ;; MMX shifts
18994
18995 (define_insn "ashrv4hi3"
18996 [(set (match_operand:V4HI 0 "register_operand" "=y")
18997 (ashiftrt:V4HI (match_operand:V4HI 1 "register_operand" "0")
18998 (match_operand:DI 2 "nonmemory_operand" "yi")))]
18999 "TARGET_MMX"
19000 "psraw\t{%2, %0|%0, %2}"
19001 [(set_attr "type" "mmx")])
19002
19003 (define_insn "ashrv2si3"
19004 [(set (match_operand:V2SI 0 "register_operand" "=y")
19005 (ashiftrt:V2SI (match_operand:V2SI 1 "register_operand" "0")
19006 (match_operand:DI 2 "nonmemory_operand" "yi")))]
19007 "TARGET_MMX"
19008 "psrad\t{%2, %0|%0, %2}"
19009 [(set_attr "type" "mmx")])
19010
19011 (define_insn "lshrv4hi3"
19012 [(set (match_operand:V4HI 0 "register_operand" "=y")
19013 (lshiftrt:V4HI (match_operand:V4HI 1 "register_operand" "0")
19014 (match_operand:DI 2 "nonmemory_operand" "yi")))]
19015 "TARGET_MMX"
19016 "psrlw\t{%2, %0|%0, %2}"
19017 [(set_attr "type" "mmx")])
19018
19019 (define_insn "lshrv2si3"
19020 [(set (match_operand:V2SI 0 "register_operand" "=y")
19021 (lshiftrt:V2SI (match_operand:V2SI 1 "register_operand" "0")
19022 (match_operand:DI 2 "nonmemory_operand" "yi")))]
19023 "TARGET_MMX"
19024 "psrld\t{%2, %0|%0, %2}"
19025 [(set_attr "type" "mmx")])
19026
19027 ;; See logical MMX insns.
19028 (define_insn "mmx_lshrdi3"
19029 [(set (match_operand:DI 0 "register_operand" "=y")
19030 (unspec:DI
19031 [(lshiftrt:DI (match_operand:DI 1 "register_operand" "0")
19032 (match_operand:DI 2 "nonmemory_operand" "yi"))] 45))]
19033 "TARGET_MMX"
19034 "psrlq\t{%2, %0|%0, %2}"
19035 [(set_attr "type" "mmx")])
19036
19037 (define_insn "ashlv4hi3"
19038 [(set (match_operand:V4HI 0 "register_operand" "=y")
19039 (ashift:V4HI (match_operand:V4HI 1 "register_operand" "0")
19040 (match_operand:DI 2 "nonmemory_operand" "yi")))]
19041 "TARGET_MMX"
19042 "psllw\t{%2, %0|%0, %2}"
19043 [(set_attr "type" "mmx")])
19044
19045 (define_insn "ashlv2si3"
19046 [(set (match_operand:V2SI 0 "register_operand" "=y")
19047 (ashift:V2SI (match_operand:V2SI 1 "register_operand" "0")
19048 (match_operand:DI 2 "nonmemory_operand" "yi")))]
19049 "TARGET_MMX"
19050 "pslld\t{%2, %0|%0, %2}"
19051 [(set_attr "type" "mmx")])
19052
19053 ;; See logical MMX insns.
19054 (define_insn "mmx_ashldi3"
19055 [(set (match_operand:DI 0 "register_operand" "=y")
19056 (unspec:DI
19057 [(ashift:DI (match_operand:DI 1 "register_operand" "0")
19058 (match_operand:DI 2 "nonmemory_operand" "yi"))] 45))]
19059 "TARGET_MMX"
19060 "psllq\t{%2, %0|%0, %2}"
19061 [(set_attr "type" "mmx")])
19062
19063
19064 ;; MMX pack/unpack insns.
19065
19066 (define_insn "mmx_packsswb"
19067 [(set (match_operand:V8QI 0 "register_operand" "=y")
19068 (vec_concat:V8QI
19069 (ss_truncate:V4QI (match_operand:V4HI 1 "register_operand" "0"))
19070 (ss_truncate:V4QI (match_operand:V4HI 2 "register_operand" "y"))))]
19071 "TARGET_MMX"
19072 "packsswb\t{%2, %0|%0, %2}"
19073 [(set_attr "type" "mmx")])
19074
19075 (define_insn "mmx_packssdw"
19076 [(set (match_operand:V4HI 0 "register_operand" "=y")
19077 (vec_concat:V4HI
19078 (ss_truncate:V2HI (match_operand:V2SI 1 "register_operand" "0"))
19079 (ss_truncate:V2HI (match_operand:V2SI 2 "register_operand" "y"))))]
19080 "TARGET_MMX"
19081 "packssdw\t{%2, %0|%0, %2}"
19082 [(set_attr "type" "mmx")])
19083
19084 (define_insn "mmx_packuswb"
19085 [(set (match_operand:V8QI 0 "register_operand" "=y")
19086 (vec_concat:V8QI
19087 (us_truncate:V4QI (match_operand:V4HI 1 "register_operand" "0"))
19088 (us_truncate:V4QI (match_operand:V4HI 2 "register_operand" "y"))))]
19089 "TARGET_MMX"
19090 "packuswb\t{%2, %0|%0, %2}"
19091 [(set_attr "type" "mmx")])
19092
19093 (define_insn "mmx_punpckhbw"
19094 [(set (match_operand:V8QI 0 "register_operand" "=y")
19095 (vec_merge:V8QI
19096 (vec_select:V8QI (match_operand:V8QI 1 "register_operand" "0")
19097 (parallel [(const_int 4)
19098 (const_int 0)
19099 (const_int 5)
19100 (const_int 1)
19101 (const_int 6)
19102 (const_int 2)
19103 (const_int 7)
19104 (const_int 3)]))
19105 (vec_select:V8QI (match_operand:V8QI 2 "register_operand" "y")
19106 (parallel [(const_int 0)
19107 (const_int 4)
19108 (const_int 1)
19109 (const_int 5)
19110 (const_int 2)
19111 (const_int 6)
19112 (const_int 3)
19113 (const_int 7)]))
19114 (const_int 85)))]
19115 "TARGET_MMX"
19116 "punpckhbw\t{%2, %0|%0, %2}"
19117 [(set_attr "type" "mmx")])
19118
19119 (define_insn "mmx_punpckhwd"
19120 [(set (match_operand:V4HI 0 "register_operand" "=y")
19121 (vec_merge:V4HI
19122 (vec_select:V4HI (match_operand:V4HI 1 "register_operand" "0")
19123 (parallel [(const_int 0)
19124 (const_int 2)
19125 (const_int 1)
19126 (const_int 3)]))
19127 (vec_select:V4HI (match_operand:V4HI 2 "register_operand" "y")
19128 (parallel [(const_int 2)
19129 (const_int 0)
19130 (const_int 3)
19131 (const_int 1)]))
19132 (const_int 5)))]
19133 "TARGET_MMX"
19134 "punpckhwd\t{%2, %0|%0, %2}"
19135 [(set_attr "type" "mmx")])
19136
19137 (define_insn "mmx_punpckhdq"
19138 [(set (match_operand:V2SI 0 "register_operand" "=y")
19139 (vec_merge:V2SI
19140 (vec_select:V2SI (match_operand:V2SI 1 "register_operand" "0")
19141 (parallel [(const_int 0)
19142 (const_int 1)]))
19143 (vec_select:V2SI (match_operand:V2SI 2 "register_operand" "y")
19144 (parallel [(const_int 1)
19145 (const_int 0)]))
19146 (const_int 1)))]
19147 "TARGET_MMX"
19148 "punpckhdq\t{%2, %0|%0, %2}"
19149 [(set_attr "type" "mmx")])
19150
19151 (define_insn "mmx_punpcklbw"
19152 [(set (match_operand:V8QI 0 "register_operand" "=y")
19153 (vec_merge:V8QI
19154 (vec_select:V8QI (match_operand:V8QI 1 "register_operand" "0")
19155 (parallel [(const_int 0)
19156 (const_int 4)
19157 (const_int 1)
19158 (const_int 5)
19159 (const_int 2)
19160 (const_int 6)
19161 (const_int 3)
19162 (const_int 7)]))
19163 (vec_select:V8QI (match_operand:V8QI 2 "register_operand" "y")
19164 (parallel [(const_int 4)
19165 (const_int 0)
19166 (const_int 5)
19167 (const_int 1)
19168 (const_int 6)
19169 (const_int 2)
19170 (const_int 7)
19171 (const_int 3)]))
19172 (const_int 85)))]
19173 "TARGET_MMX"
19174 "punpcklbw\t{%2, %0|%0, %2}"
19175 [(set_attr "type" "mmx")])
19176
19177 (define_insn "mmx_punpcklwd"
19178 [(set (match_operand:V4HI 0 "register_operand" "=y")
19179 (vec_merge:V4HI
19180 (vec_select:V4HI (match_operand:V4HI 1 "register_operand" "0")
19181 (parallel [(const_int 2)
19182 (const_int 0)
19183 (const_int 3)
19184 (const_int 1)]))
19185 (vec_select:V4HI (match_operand:V4HI 2 "register_operand" "y")
19186 (parallel [(const_int 0)
19187 (const_int 2)
19188 (const_int 1)
19189 (const_int 3)]))
19190 (const_int 5)))]
19191 "TARGET_MMX"
19192 "punpcklwd\t{%2, %0|%0, %2}"
19193 [(set_attr "type" "mmx")])
19194
19195 (define_insn "mmx_punpckldq"
19196 [(set (match_operand:V2SI 0 "register_operand" "=y")
19197 (vec_merge:V2SI
19198 (vec_select:V2SI (match_operand:V2SI 1 "register_operand" "0")
19199 (parallel [(const_int 1)
19200 (const_int 0)]))
19201 (vec_select:V2SI (match_operand:V2SI 2 "register_operand" "y")
19202 (parallel [(const_int 0)
19203 (const_int 1)]))
19204 (const_int 1)))]
19205 "TARGET_MMX"
19206 "punpckldq\t{%2, %0|%0, %2}"
19207 [(set_attr "type" "mmx")])
19208
19209
19210 ;; Miscellaneous stuff
19211
19212 (define_insn "emms"
19213 [(unspec_volatile [(const_int 0)] 31)
19214 (clobber (reg:XF 8))
19215 (clobber (reg:XF 9))
19216 (clobber (reg:XF 10))
19217 (clobber (reg:XF 11))
19218 (clobber (reg:XF 12))
19219 (clobber (reg:XF 13))
19220 (clobber (reg:XF 14))
19221 (clobber (reg:XF 15))
19222 (clobber (reg:DI 29))
19223 (clobber (reg:DI 30))
19224 (clobber (reg:DI 31))
19225 (clobber (reg:DI 32))
19226 (clobber (reg:DI 33))
19227 (clobber (reg:DI 34))
19228 (clobber (reg:DI 35))
19229 (clobber (reg:DI 36))]
19230 "TARGET_MMX"
19231 "emms"
19232 [(set_attr "type" "mmx")
19233 (set_attr "memory" "unknown")])
19234
19235 (define_insn "ldmxcsr"
19236 [(unspec_volatile [(match_operand:SI 0 "memory_operand" "m")] 37)]
19237 "TARGET_MMX"
19238 "ldmxcsr\t%0"
19239 [(set_attr "type" "mmx")
19240 (set_attr "memory" "load")])
19241
19242 (define_insn "stmxcsr"
19243 [(set (match_operand:SI 0 "memory_operand" "=m")
19244 (unspec_volatile:SI [(const_int 0)] 40))]
19245 "TARGET_MMX"
19246 "stmxcsr\t%0"
19247 [(set_attr "type" "mmx")
19248 (set_attr "memory" "store")])
19249
19250 (define_expand "sfence"
19251 [(set (match_dup 0)
19252 (unspec:BLK [(match_dup 0)] 44))]
19253 "TARGET_SSE || TARGET_3DNOW_A"
19254 {
19255 operands[0] = gen_rtx_MEM (BLKmode, gen_rtx_SCRATCH (Pmode));
19256 MEM_VOLATILE_P (operands[0]) = 1;
19257 })
19258
19259 (define_insn "*sfence_insn"
19260 [(set (match_operand:BLK 0 "" "")
19261 (unspec:BLK [(match_dup 0)] 44))]
19262 "TARGET_SSE || TARGET_3DNOW_A"
19263 "sfence"
19264 [(set_attr "type" "sse")
19265 (set_attr "memory" "unknown")])
19266
19267 (define_expand "sse_prologue_save"
19268 [(parallel [(set (match_operand:BLK 0 "" "")
19269 (unspec:BLK [(reg:DI 21)
19270 (reg:DI 22)
19271 (reg:DI 23)
19272 (reg:DI 24)
19273 (reg:DI 25)
19274 (reg:DI 26)
19275 (reg:DI 27)
19276 (reg:DI 28)] 13))
19277 (use (match_operand:DI 1 "register_operand" ""))
19278 (use (match_operand:DI 2 "immediate_operand" ""))
19279 (use (label_ref:DI (match_operand 3 "" "")))])]
19280 "TARGET_64BIT"
19281 "")
19282
19283 (define_insn "*sse_prologue_save_insn"
19284 [(set (mem:BLK (plus:DI (match_operand:DI 0 "register_operand" "R")
19285 (match_operand:DI 4 "const_int_operand" "n")))
19286 (unspec:BLK [(reg:DI 21)
19287 (reg:DI 22)
19288 (reg:DI 23)
19289 (reg:DI 24)
19290 (reg:DI 25)
19291 (reg:DI 26)
19292 (reg:DI 27)
19293 (reg:DI 28)] 13))
19294 (use (match_operand:DI 1 "register_operand" "r"))
19295 (use (match_operand:DI 2 "const_int_operand" "i"))
19296 (use (label_ref:DI (match_operand 3 "" "X")))]
19297 "TARGET_64BIT
19298 && INTVAL (operands[4]) + SSE_REGPARM_MAX * 16 - 16 < 128
19299 && INTVAL (operands[4]) + INTVAL (operands[2]) * 16 >= -128"
19300 "*
19301 {
19302 int i;
19303 operands[0] = gen_rtx_MEM (Pmode,
19304 gen_rtx_PLUS (Pmode, operands[0], operands[4]));
19305 output_asm_insn (\"jmp\\t%A1\", operands);
19306 for (i = SSE_REGPARM_MAX - 1; i >= INTVAL (operands[2]); i--)
19307 {
19308 operands[4] = adjust_address (operands[0], DImode, i*16);
19309 operands[5] = gen_rtx_REG (TImode, SSE_REGNO (i));
19310 PUT_MODE (operands[4], TImode);
19311 if (GET_CODE (XEXP (operands[0], 0)) != PLUS)
19312 output_asm_insn (\"rex\", operands);
19313 output_asm_insn (\"movaps\\t{%5, %4|%4, %5}\", operands);
19314 }
19315 ASM_OUTPUT_INTERNAL_LABEL (asm_out_file, \"L\",
19316 CODE_LABEL_NUMBER (operands[3]));
19317 RET;
19318 }
19319 "
19320 [(set_attr "type" "other")
19321 (set_attr "length_immediate" "0")
19322 (set_attr "length_address" "0")
19323 (set_attr "length" "135")
19324 (set_attr "memory" "store")
19325 (set_attr "modrm" "0")
19326 (set_attr "mode" "DI")])
19327
19328 ;; 3Dnow! instructions
19329
19330 (define_insn "addv2sf3"
19331 [(set (match_operand:V2SF 0 "register_operand" "=y")
19332 (plus:V2SF (match_operand:V2SF 1 "register_operand" "0")
19333 (match_operand:V2SF 2 "nonimmediate_operand" "ym")))]
19334 "TARGET_3DNOW"
19335 "pfadd\\t{%2, %0|%0, %2}"
19336 [(set_attr "type" "mmx")])
19337
19338 (define_insn "subv2sf3"
19339 [(set (match_operand:V2SF 0 "register_operand" "=y")
19340 (minus:V2SF (match_operand:V2SF 1 "register_operand" "0")
19341 (match_operand:V2SF 2 "nonimmediate_operand" "ym")))]
19342 "TARGET_3DNOW"
19343 "pfsub\\t{%2, %0|%0, %2}"
19344 [(set_attr "type" "mmx")])
19345
19346 (define_insn "subrv2sf3"
19347 [(set (match_operand:V2SF 0 "register_operand" "=y")
19348 (minus:V2SF (match_operand:V2SF 2 "nonimmediate_operand" "ym")
19349 (match_operand:V2SF 1 "register_operand" "0")))]
19350 "TARGET_3DNOW"
19351 "pfsubr\\t{%2, %0|%0, %2}"
19352 [(set_attr "type" "mmx")])
19353
19354 (define_insn "gtv2sf3"
19355 [(set (match_operand:V2SI 0 "register_operand" "=y")
19356 (gt:V2SI (match_operand:V2SF 1 "register_operand" "0")
19357 (match_operand:V2SF 2 "nonimmediate_operand" "ym")))]
19358 "TARGET_3DNOW"
19359 "pfcmpgt\\t{%2, %0|%0, %2}"
19360 [(set_attr "type" "mmx")])
19361
19362 (define_insn "gev2sf3"
19363 [(set (match_operand:V2SI 0 "register_operand" "=y")
19364 (ge:V2SI (match_operand:V2SF 1 "register_operand" "0")
19365 (match_operand:V2SF 2 "nonimmediate_operand" "ym")))]
19366 "TARGET_3DNOW"
19367 "pfcmpge\\t{%2, %0|%0, %2}"
19368 [(set_attr "type" "mmx")])
19369
19370 (define_insn "eqv2sf3"
19371 [(set (match_operand:V2SI 0 "register_operand" "=y")
19372 (eq:V2SI (match_operand:V2SF 1 "register_operand" "0")
19373 (match_operand:V2SF 2 "nonimmediate_operand" "ym")))]
19374 "TARGET_3DNOW"
19375 "pfcmpeq\\t{%2, %0|%0, %2}"
19376 [(set_attr "type" "mmx")])
19377
19378 (define_insn "pfmaxv2sf3"
19379 [(set (match_operand:V2SF 0 "register_operand" "=y")
19380 (smax:V2SF (match_operand:V2SF 1 "register_operand" "0")
19381 (match_operand:V2SF 2 "nonimmediate_operand" "ym")))]
19382 "TARGET_3DNOW"
19383 "pfmax\\t{%2, %0|%0, %2}"
19384 [(set_attr "type" "mmx")])
19385
19386 (define_insn "pfminv2sf3"
19387 [(set (match_operand:V2SF 0 "register_operand" "=y")
19388 (smin:V2SF (match_operand:V2SF 1 "register_operand" "0")
19389 (match_operand:V2SF 2 "nonimmediate_operand" "ym")))]
19390 "TARGET_3DNOW"
19391 "pfmin\\t{%2, %0|%0, %2}"
19392 [(set_attr "type" "mmx")])
19393
19394 (define_insn "mulv2sf3"
19395 [(set (match_operand:V2SF 0 "register_operand" "=y")
19396 (mult:V2SF (match_operand:V2SF 1 "register_operand" "0")
19397 (match_operand:V2SF 2 "nonimmediate_operand" "ym")))]
19398 "TARGET_3DNOW"
19399 "pfmul\\t{%2, %0|%0, %2}"
19400 [(set_attr "type" "mmx")])
19401
19402 (define_insn "femms"
19403 [(unspec_volatile [(const_int 0)] 46)
19404 (clobber (reg:XF 8))
19405 (clobber (reg:XF 9))
19406 (clobber (reg:XF 10))
19407 (clobber (reg:XF 11))
19408 (clobber (reg:XF 12))
19409 (clobber (reg:XF 13))
19410 (clobber (reg:XF 14))
19411 (clobber (reg:XF 15))
19412 (clobber (reg:DI 29))
19413 (clobber (reg:DI 30))
19414 (clobber (reg:DI 31))
19415 (clobber (reg:DI 32))
19416 (clobber (reg:DI 33))
19417 (clobber (reg:DI 34))
19418 (clobber (reg:DI 35))
19419 (clobber (reg:DI 36))]
19420 "TARGET_3DNOW"
19421 "femms"
19422 [(set_attr "type" "mmx")])
19423
19424 (define_insn "pf2id"
19425 [(set (match_operand:V2SI 0 "register_operand" "=y")
19426 (fix:V2SI (match_operand:V2SF 1 "nonimmediate_operand" "ym")))]
19427 "TARGET_3DNOW"
19428 "pf2id\\t{%1, %0|%0, %1}"
19429 [(set_attr "type" "mmx")])
19430
19431 (define_insn "pf2iw"
19432 [(set (match_operand:V2SI 0 "register_operand" "=y")
19433 (sign_extend:V2SI
19434 (ss_truncate:V2HI
19435 (fix:V2SI (match_operand:V2SF 1 "nonimmediate_operand" "ym")))))]
19436 "TARGET_3DNOW_A"
19437 "pf2iw\\t{%1, %0|%0, %1}"
19438 [(set_attr "type" "mmx")])
19439
19440 (define_insn "pfacc"
19441 [(set (match_operand:V2SF 0 "register_operand" "=y")
19442 (vec_concat:V2SF
19443 (plus:SF
19444 (vec_select:SF (match_operand:V2SF 1 "register_operand" "0")
19445 (parallel [(const_int 0)]))
19446 (vec_select:SF (match_dup 1)
19447 (parallel [(const_int 1)])))
19448 (plus:SF
19449 (vec_select:SF (match_operand:V2SF 2 "nonimmediate_operand" "y")
19450 (parallel [(const_int 0)]))
19451 (vec_select:SF (match_dup 2)
19452 (parallel [(const_int 1)])))))]
19453 "TARGET_3DNOW"
19454 "pfacc\\t{%2, %0|%0, %2}"
19455 [(set_attr "type" "mmx")])
19456
19457 (define_insn "pfnacc"
19458 [(set (match_operand:V2SF 0 "register_operand" "=y")
19459 (vec_concat:V2SF
19460 (minus:SF
19461 (vec_select:SF (match_operand:V2SF 1 "register_operand" "0")
19462 (parallel [(const_int 0)]))
19463 (vec_select:SF (match_dup 1)
19464 (parallel [(const_int 1)])))
19465 (minus:SF
19466 (vec_select:SF (match_operand:V2SF 2 "nonimmediate_operand" "y")
19467 (parallel [(const_int 0)]))
19468 (vec_select:SF (match_dup 2)
19469 (parallel [(const_int 1)])))))]
19470 "TARGET_3DNOW_A"
19471 "pfnacc\\t{%2, %0|%0, %2}"
19472 [(set_attr "type" "mmx")])
19473
19474 (define_insn "pfpnacc"
19475 [(set (match_operand:V2SF 0 "register_operand" "=y")
19476 (vec_concat:V2SF
19477 (minus:SF
19478 (vec_select:SF (match_operand:V2SF 1 "register_operand" "0")
19479 (parallel [(const_int 0)]))
19480 (vec_select:SF (match_dup 1)
19481 (parallel [(const_int 1)])))
19482 (plus:SF
19483 (vec_select:SF (match_operand:V2SF 2 "nonimmediate_operand" "y")
19484 (parallel [(const_int 0)]))
19485 (vec_select:SF (match_dup 2)
19486 (parallel [(const_int 1)])))))]
19487 "TARGET_3DNOW_A"
19488 "pfpnacc\\t{%2, %0|%0, %2}"
19489 [(set_attr "type" "mmx")])
19490
19491 (define_insn "pi2fw"
19492 [(set (match_operand:V2SF 0 "register_operand" "=y")
19493 (float:V2SF
19494 (vec_concat:V2SI
19495 (sign_extend:SI
19496 (truncate:HI
19497 (vec_select:SI (match_operand:V2SI 1 "nonimmediate_operand" "ym")
19498 (parallel [(const_int 0)]))))
19499 (sign_extend:SI
19500 (truncate:HI
19501 (vec_select:SI (match_dup 1)
19502 (parallel [(const_int 1)])))))))]
19503 "TARGET_3DNOW_A"
19504 "pi2fw\\t{%1, %0|%0, %1}"
19505 [(set_attr "type" "mmx")])
19506
19507 (define_insn "floatv2si2"
19508 [(set (match_operand:V2SF 0 "register_operand" "=y")
19509 (float:V2SF (match_operand:V2SI 1 "nonimmediate_operand" "ym")))]
19510 "TARGET_3DNOW"
19511 "pi2fd\\t{%1, %0|%0, %1}"
19512 [(set_attr "type" "mmx")])
19513
19514 ;; This insn is identical to pavgb in operation, but the opcode is
19515 ;; different. To avoid accidentally matching pavgb, use an unspec.
19516
19517 (define_insn "pavgusb"
19518 [(set (match_operand:V8QI 0 "register_operand" "=y")
19519 (unspec:V8QI
19520 [(match_operand:V8QI 1 "register_operand" "0")
19521 (match_operand:V8QI 2 "nonimmediate_operand" "ym")] 49))]
19522 "TARGET_3DNOW"
19523 "pavgusb\\t{%2, %0|%0, %2}"
19524 [(set_attr "type" "mmx")])
19525
19526 ;; 3DNow reciprical and sqrt
19527
19528 (define_insn "pfrcpv2sf2"
19529 [(set (match_operand:V2SF 0 "register_operand" "=y")
19530 (unspec:V2SF [(match_operand:V2SF 1 "nonimmediate_operand" "ym")] 50))]
19531 "TARGET_3DNOW"
19532 "pfrcp\\t{%1, %0|%0, %1}"
19533 [(set_attr "type" "mmx")])
19534
19535 (define_insn "pfrcpit1v2sf3"
19536 [(set (match_operand:V2SF 0 "register_operand" "=y")
19537 (unspec:V2SF [(match_operand:V2SF 1 "register_operand" "0")
19538 (match_operand:V2SF 2 "nonimmediate_operand" "ym")] 51))]
19539 "TARGET_3DNOW"
19540 "pfrcpit1\\t{%2, %0|%0, %2}"
19541 [(set_attr "type" "mmx")])
19542
19543 (define_insn "pfrcpit2v2sf3"
19544 [(set (match_operand:V2SF 0 "register_operand" "=y")
19545 (unspec:V2SF [(match_operand:V2SF 1 "register_operand" "0")
19546 (match_operand:V2SF 2 "nonimmediate_operand" "ym")] 52))]
19547 "TARGET_3DNOW"
19548 "pfrcpit2\\t{%2, %0|%0, %2}"
19549 [(set_attr "type" "mmx")])
19550
19551 (define_insn "pfrsqrtv2sf2"
19552 [(set (match_operand:V2SF 0 "register_operand" "=y")
19553 (unspec:V2SF [(match_operand:V2SF 1 "nonimmediate_operand" "ym")] 53))]
19554 "TARGET_3DNOW"
19555 "pfrsqrt\\t{%1, %0|%0, %1}"
19556 [(set_attr "type" "mmx")])
19557
19558 (define_insn "pfrsqit1v2sf3"
19559 [(set (match_operand:V2SF 0 "register_operand" "=y")
19560 (unspec:V2SF [(match_operand:V2SF 1 "register_operand" "0")
19561 (match_operand:V2SF 2 "nonimmediate_operand" "ym")] 54))]
19562 "TARGET_3DNOW"
19563 "pfrsqit1\\t{%2, %0|%0, %2}"
19564 [(set_attr "type" "mmx")])
19565
19566 (define_insn "pmulhrwv4hi3"
19567 [(set (match_operand:V4HI 0 "register_operand" "=y")
19568 (truncate:V4HI
19569 (lshiftrt:V4SI
19570 (plus:V4SI
19571 (mult:V4SI
19572 (sign_extend:V4SI
19573 (match_operand:V4HI 1 "register_operand" "0"))
19574 (sign_extend:V4SI
19575 (match_operand:V4HI 2 "nonimmediate_operand" "ym")))
19576 (vec_const:V4SI
19577 (parallel [(const_int 32768)
19578 (const_int 32768)
19579 (const_int 32768)
19580 (const_int 32768)])))
19581 (const_int 16))))]
19582 "TARGET_3DNOW"
19583 "pmulhrw\\t{%2, %0|%0, %2}"
19584 [(set_attr "type" "mmx")])
19585
19586 (define_insn "pswapdv2si2"
19587 [(set (match_operand:V2SI 0 "register_operand" "=y")
19588 (vec_select:V2SI (match_operand:V2SI 1 "nonimmediate_operand" "ym")
19589 (parallel [(const_int 1) (const_int 0)])))]
19590 "TARGET_3DNOW_A"
19591 "pswapd\\t{%1, %0|%0, %1}"
19592 [(set_attr "type" "mmx")])
19593
19594 (define_insn "pswapdv2sf2"
19595 [(set (match_operand:V2SF 0 "register_operand" "=y")
19596 (vec_select:V2SF (match_operand:V2SF 1 "nonimmediate_operand" "ym")
19597 (parallel [(const_int 1) (const_int 0)])))]
19598 "TARGET_3DNOW_A"
19599 "pswapd\\t{%1, %0|%0, %1}"
19600 [(set_attr "type" "mmx")])
19601
19602 (define_expand "prefetch"
19603 [(prefetch (match_operand:SI 0 "address_operand" "")
19604 (match_operand:SI 1 "const_int_operand" "")
19605 (match_operand:SI 2 "const_int_operand" ""))]
19606 "TARGET_PREFETCH_SSE || TARGET_3DNOW"
19607 {
19608 int rw = INTVAL (operands[1]);
19609 int locality = INTVAL (operands[2]);
19610
19611 if (rw != 0 && rw != 1)
19612 abort ();
19613 if (locality < 0 || locality > 3)
19614 abort ();
19615
19616 /* Use 3dNOW prefetch in case we are asking for write prefetch not
19617 suported by SSE counterpart or the SSE prefetch is not available
19618 (K6 machines). Otherwise use SSE prefetch as it allows specifying
19619 of locality. */
19620 if (TARGET_3DNOW && (!TARGET_PREFETCH_SSE || rw))
19621 operands[2] = GEN_INT (3);
19622 else
19623 operands[1] = const0_rtx;
19624 })
19625
19626 (define_insn "*prefetch_sse"
19627 [(prefetch (match_operand:SI 0 "address_operand" "")
19628 (const_int 0)
19629 (match_operand:SI 1 "const_int_operand" ""))]
19630 "TARGET_PREFETCH_SSE"
19631 {
19632 static const char * const patterns[4] = {
19633 "prefetchnta\t%a0", "prefetcht2\t%a0", "prefetcht1\t%a0", "prefetcht0\t%a0"
19634 };
19635
19636 int locality = INTVAL (operands[1]);
19637 if (locality < 0 || locality > 3)
19638 abort ();
19639
19640 return patterns[locality];
19641 }
19642 [(set_attr "type" "sse")])
19643
19644 (define_insn "*prefetch_3dnow"
19645 [(prefetch (match_operand:SI 0 "address_operand" "p")
19646 (match_operand:SI 1 "const_int_operand" "n")
19647 (const_int 3))]
19648 "TARGET_3DNOW"
19649 {
19650 if (INTVAL (operands[1]) == 0)
19651 return "prefetch\t%a0";
19652 else
19653 return "prefetchw\t%a0";
19654 }
19655 [(set_attr "type" "mmx")])
This page took 0.907484 seconds and 5 git commands to generate.