]> gcc.gnu.org Git - gcc.git/blame - gcc/config/i386/i386.md
* i386.md (cosxf2): Fix conditional.
[gcc.git] / gcc / config / i386 / i386.md
CommitLineData
d2836273 1;; GCC machine description for IA-32 and x86-64.
36210500
SP
2;; Copyright (C) 1988, 1994, 1995, 1996, 1997, 1998, 1999, 2000,
3;; 2001, 2002, 2003
4592bdcb 4;; Free Software Foundation, Inc.
886c62d1 5;; Mostly by William Schelter.
d2836273 6;; x86_64 support added by Jan Hubicka
e075ae69 7;;
886c62d1 8;; This file is part of GNU CC.
e075ae69 9;;
886c62d1
JVA
10;; GNU CC is free software; you can redistribute it and/or modify
11;; it under the terms of the GNU General Public License as published by
12;; the Free Software Foundation; either version 2, or (at your option)
13;; any later version.
e075ae69 14;;
886c62d1
JVA
15;; GNU CC is distributed in the hope that it will be useful,
16;; but WITHOUT ANY WARRANTY; without even the implied warranty of
17;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18;; GNU General Public License for more details.
e075ae69 19;;
886c62d1
JVA
20;; You should have received a copy of the GNU General Public License
21;; along with GNU CC; see the file COPYING. If not, write to
3f63df56 22;; the Free Software Foundation, 59 Temple Place - Suite 330,
892a2d68 23;; Boston, MA 02111-1307, USA. */
e075ae69 24;;
4af3895e
JVA
25;; The original PO technology requires these to be ordered by speed,
26;; so that assigner will pick the fastest.
e075ae69 27;;
4af3895e 28;; See file "rtl.def" for documentation on define_insn, match_*, et. al.
e075ae69 29;;
4af3895e
JVA
30;; Macro #define NOTICE_UPDATE_CC in file i386.h handles condition code
31;; updates for most instructions.
e075ae69 32;;
4af3895e
JVA
33;; Macro REG_CLASS_FROM_LETTER in file i386.h defines the register
34;; constraint letters.
e075ae69
RH
35;;
36;; The special asm out single letter directives following a '%' are:
4af3895e
JVA
37;; 'z' mov%z1 would be movl, movw, or movb depending on the mode of
38;; operands[1].
39;; 'L' Print the opcode suffix for a 32-bit integer opcode.
40;; 'W' Print the opcode suffix for a 16-bit integer opcode.
41;; 'B' Print the opcode suffix for an 8-bit integer opcode.
4af3895e 42;; 'Q' Print the opcode suffix for a 64-bit float opcode.
56710e42 43;; 'S' Print the opcode suffix for a 32-bit float opcode.
b08de47e
MM
44;; 'T' Print the opcode suffix for an 80-bit extended real XFmode float opcode.
45;; 'J' Print the appropriate jump operand.
e075ae69 46;;
4af3895e
JVA
47;; 'b' Print the QImode name of the register for the indicated operand.
48;; %b0 would print %al if operands[0] is reg 0.
49;; 'w' Likewise, print the HImode name of the register.
50;; 'k' Likewise, print the SImode name of the register.
51;; 'h' Print the QImode name for a "high" register, either ah, bh, ch or dh.
52;; 'y' Print "st(0)" instead of "st" as a register.
8ee41eaf 53
4af3895e 54;; UNSPEC usage:
8ee41eaf
RH
55
56(define_constants
f996902d
RH
57 [; Relocation specifiers
58 (UNSPEC_GOT 0)
59 (UNSPEC_GOTOFF 1)
60 (UNSPEC_GOTPCREL 2)
61 (UNSPEC_GOTTPOFF 3)
62 (UNSPEC_TPOFF 4)
63 (UNSPEC_NTPOFF 5)
64 (UNSPEC_DTPOFF 6)
dea73790
JJ
65 (UNSPEC_GOTNTPOFF 7)
66 (UNSPEC_INDNTPOFF 8)
f996902d
RH
67
68 ; Prologue support
69 (UNSPEC_STACK_PROBE 10)
70 (UNSPEC_STACK_ALLOC 11)
71 (UNSPEC_SET_GOT 12)
8ee41eaf 72 (UNSPEC_SSE_PROLOGUE_SAVE 13)
f996902d
RH
73
74 ; TLS support
75 (UNSPEC_TP 15)
76 (UNSPEC_TLS_GD 16)
77 (UNSPEC_TLS_LD_BASE 17)
78
79 ; Other random patterns
80 (UNSPEC_SCAS 20)
81 (UNSPEC_SIN 21)
82 (UNSPEC_COS 22)
f996902d
RH
83 (UNSPEC_FNSTSW 24)
84 (UNSPEC_SAHF 25)
85 (UNSPEC_FSTCW 26)
86 (UNSPEC_ADD_CARRY 27)
87 (UNSPEC_FLDCW 28)
8ee41eaf
RH
88
89 ; For SSE/MMX support:
90 (UNSPEC_FIX 30)
91 (UNSPEC_MASKMOV 32)
92 (UNSPEC_MOVMSK 33)
93 (UNSPEC_MOVNT 34)
94 (UNSPEC_MOVA 38)
95 (UNSPEC_MOVU 39)
96 (UNSPEC_SHUFFLE 41)
97 (UNSPEC_RCP 42)
98 (UNSPEC_RSQRT 43)
99 (UNSPEC_SFENCE 44)
100 (UNSPEC_NOP 45) ; prevents combiner cleverness
101 (UNSPEC_PAVGUSB 49)
102 (UNSPEC_PFRCP 50)
103 (UNSPEC_PFRCPIT1 51)
104 (UNSPEC_PFRCPIT2 52)
105 (UNSPEC_PFRSQRT 53)
106 (UNSPEC_PFRSQIT1 54)
107 (UNSPEC_PSHUFLW 55)
108 (UNSPEC_PSHUFHW 56)
109 (UNSPEC_MFENCE 59)
110 (UNSPEC_LFENCE 60)
111 (UNSPEC_PSADBW 61)
1fb54135
RS
112
113 ; x87 Floating point
114 (UNSPEC_FPATAN 65)
8ee41eaf
RH
115 ])
116
117(define_constants
118 [(UNSPECV_BLOCKAGE 0)
8ee41eaf
RH
119 (UNSPECV_EH_RETURN 13)
120 (UNSPECV_EMMS 31)
121 (UNSPECV_LDMXCSR 37)
122 (UNSPECV_STMXCSR 40)
123 (UNSPECV_FEMMS 46)
124 (UNSPECV_CLFLUSH 57)
125 ])
915119a5 126
6343a50e
ZW
127;; Insns whose names begin with "x86_" are emitted by gen_FOO calls
128;; from i386.c.
129
1b0c37d7
ZW
130;; In C guard expressions, put expressions which may be compile-time
131;; constants first. This allows for better optimization. For
132;; example, write "TARGET_64BIT && reload_completed", not
133;; "reload_completed && TARGET_64BIT".
134
2ae0f82c 135\f
e075ae69
RH
136;; Processor type. This attribute must exactly match the processor_type
137;; enumeration in i386.h.
4977bab6 138(define_attr "cpu" "i386,i486,pentium,pentiumpro,k6,athlon,pentium4,k8"
e075ae69 139 (const (symbol_ref "ix86_cpu")))
2ae0f82c 140
e075ae69
RH
141;; A basic instruction type. Refinements due to arguments to be
142;; provided in other attributes.
a269a03c 143(define_attr "type"
9a5834ae
ZW
144 "other,multi,
145 alu,alu1,negnot,imov,imovx,lea,
1b245ade 146 incdec,ishift,ishift1,rotate,rotate1,imul,idiv,
9a5834ae 147 icmp,test,ibr,setcc,icmov,
4977bab6 148 push,pop,call,callv,leave,
9a5834ae
ZW
149 str,cld,
150 fmov,fop,fsgn,fmul,fdiv,fpspc,fcmov,fcmp,fxch,fistp,
151 sselog,sseiadd,sseishft,sseimul,
f56e86bd 152 sse,ssemov,sseadd,ssemul,ssecmp,ssecomi,ssecvt,sseicvt,ssediv,
9a5834ae 153 mmx,mmxmov,mmxadd,mmxmul,mmxcmp,mmxcvt,mmxshft"
e075ae69
RH
154 (const_string "other"))
155
6ef67412 156;; Main data type used by the insn
9a5834ae 157(define_attr "mode"
4977bab6 158 "unknown,none,QI,HI,SI,DI,SF,DF,XF,TI,V4SF,V2DF,V2SF"
6ef67412
JH
159 (const_string "unknown"))
160
3d34cd91
JH
161;; The CPU unit operations uses.
162(define_attr "unit" "integer,i387,sse,mmx,unknown"
163 (cond [(eq_attr "type" "fmov,fop,fsgn,fmul,fdiv,fpspc,fcmov,fcmp,fxch,fistp")
164 (const_string "i387")
9a5834ae 165 (eq_attr "type" "sselog,sseiadd,sseishft,sseimul,
cb297538 166 sse,ssemov,sseadd,ssemul,ssecmp,ssecomi,ssecvt,sseicvt,ssediv")
3d34cd91 167 (const_string "sse")
9a5834ae 168 (eq_attr "type" "mmx,mmxmov,mmxadd,mmxmul,mmxcmp,mmxcvt,mmxshft")
4c9c9a3d
JH
169 (const_string "mmx")
170 (eq_attr "type" "other")
171 (const_string "unknown")]
3d34cd91 172 (const_string "integer")))
6ef67412
JH
173
174;; The (bounding maximum) length of an instruction immediate.
175(define_attr "length_immediate" ""
4977bab6 176 (cond [(eq_attr "type" "incdec,setcc,icmov,str,cld,lea,other,multi,idiv,leave")
6ef67412 177 (const_int 0)
3d34cd91 178 (eq_attr "unit" "i387,sse,mmx")
6ef67412 179 (const_int 0)
1b245ade
JH
180 (eq_attr "type" "alu,alu1,negnot,imovx,ishift,rotate,ishift1,rotate1,
181 imul,icmp,push,pop")
6ef67412
JH
182 (symbol_ref "ix86_attr_length_immediate_default(insn,1)")
183 (eq_attr "type" "imov,test")
184 (symbol_ref "ix86_attr_length_immediate_default(insn,0)")
185 (eq_attr "type" "call")
186 (if_then_else (match_operand 0 "constant_call_address_operand" "")
187 (const_int 4)
188 (const_int 0))
189 (eq_attr "type" "callv")
190 (if_then_else (match_operand 1 "constant_call_address_operand" "")
191 (const_int 4)
192 (const_int 0))
efcc7037
JH
193 ;; We don't know the size before shorten_branches. Expect
194 ;; the instruction to fit for better scheduling.
6ef67412 195 (eq_attr "type" "ibr")
efcc7037 196 (const_int 1)
6ef67412 197 ]
9a5834ae
ZW
198 (symbol_ref "/* Update immediate_length and other attributes! */
199 abort(),1")))
e075ae69 200
6ef67412
JH
201;; The (bounding maximum) length of an instruction address.
202(define_attr "length_address" ""
203 (cond [(eq_attr "type" "str,cld,other,multi,fxch")
204 (const_int 0)
205 (and (eq_attr "type" "call")
c7375e61 206 (match_operand 0 "constant_call_address_operand" ""))
6ef67412
JH
207 (const_int 0)
208 (and (eq_attr "type" "callv")
209 (match_operand 1 "constant_call_address_operand" ""))
210 (const_int 0)
211 ]
212 (symbol_ref "ix86_attr_length_address_default (insn)")))
213
214;; Set when length prefix is used.
215(define_attr "prefix_data16" ""
3d34cd91
JH
216 (if_then_else (ior (eq_attr "mode" "HI")
217 (and (eq_attr "unit" "sse") (eq_attr "mode" "V2DF")))
6ef67412
JH
218 (const_int 1)
219 (const_int 0)))
220
221;; Set when string REP prefix is used.
3d34cd91
JH
222(define_attr "prefix_rep" ""
223 (if_then_else (and (eq_attr "unit" "sse") (eq_attr "mode" "SF,DF"))
224 (const_int 1)
225 (const_int 0)))
6ef67412
JH
226
227;; Set when 0f opcode prefix is used.
228(define_attr "prefix_0f" ""
9a5834ae 229 (if_then_else
cb297538
JH
230 (ior (eq_attr "type" "imovx,setcc,icmov")
231 (eq_attr "unit" "sse,mmx"))
6ef67412
JH
232 (const_int 1)
233 (const_int 0)))
234
4977bab6
ZW
235;; Set when 0f opcode prefix is used.
236(define_attr "prefix_rex" ""
237 (cond [(and (eq_attr "mode" "DI")
238 (eq_attr "type" "!push,pop,call,callv,leave,ibr"))
239 (const_int 1)
240 (and (eq_attr "mode" "QI")
241 (ne (symbol_ref "x86_extended_QIreg_mentioned_p (insn)")
242 (const_int 0)))
243 (const_int 1)
244 (ne (symbol_ref "x86_extended_reg_mentioned_p (insn)")
245 (const_int 0))
246 (const_int 1)
247 ]
248 (const_int 0)))
249
6ef67412
JH
250;; Set when modrm byte is used.
251(define_attr "modrm" ""
4977bab6 252 (cond [(eq_attr "type" "str,cld,leave")
6ef67412 253 (const_int 0)
3d34cd91 254 (eq_attr "unit" "i387")
6ef67412 255 (const_int 0)
e075ae69
RH
256 (and (eq_attr "type" "incdec")
257 (ior (match_operand:SI 1 "register_operand" "")
258 (match_operand:HI 1 "register_operand" "")))
6ef67412 259 (const_int 0)
e075ae69
RH
260 (and (eq_attr "type" "push")
261 (not (match_operand 1 "memory_operand" "")))
6ef67412 262 (const_int 0)
e075ae69
RH
263 (and (eq_attr "type" "pop")
264 (not (match_operand 0 "memory_operand" "")))
6ef67412 265 (const_int 0)
e075ae69
RH
266 (and (eq_attr "type" "imov")
267 (and (match_operand 0 "register_operand" "")
268 (match_operand 1 "immediate_operand" "")))
6ef67412 269 (const_int 0)
c7375e61
EB
270 (and (eq_attr "type" "call")
271 (match_operand 0 "constant_call_address_operand" ""))
272 (const_int 0)
273 (and (eq_attr "type" "callv")
274 (match_operand 1 "constant_call_address_operand" ""))
275 (const_int 0)
e075ae69 276 ]
6ef67412
JH
277 (const_int 1)))
278
279;; The (bounding maximum) length of an instruction in bytes.
22fb740d
JH
280;; ??? fistp is in fact fldcw/fistp/fldcw sequence. Later we may want
281;; to split it and compute proper length as for other insns.
6ef67412 282(define_attr "length" ""
22fb740d 283 (cond [(eq_attr "type" "other,multi,fistp")
6ef67412 284 (const_int 16)
3d34cd91
JH
285 (eq_attr "unit" "i387")
286 (plus (const_int 2)
287 (plus (attr "prefix_data16")
288 (attr "length_address")))]
6ef67412
JH
289 (plus (plus (attr "modrm")
290 (plus (attr "prefix_0f")
4977bab6
ZW
291 (plus (attr "prefix_rex")
292 (const_int 1))))
6ef67412
JH
293 (plus (attr "prefix_rep")
294 (plus (attr "prefix_data16")
295 (plus (attr "length_immediate")
296 (attr "length_address")))))))
e075ae69
RH
297
298;; The `memory' attribute is `none' if no memory is referenced, `load' or
299;; `store' if there is a simple memory reference therein, or `unknown'
300;; if the instruction is complex.
301
302(define_attr "memory" "none,load,store,both,unknown"
7c7ef435 303 (cond [(eq_attr "type" "other,multi,str")
e075ae69 304 (const_string "unknown")
7c7ef435 305 (eq_attr "type" "lea,fcmov,fpspc,cld")
e075ae69 306 (const_string "none")
4977bab6 307 (eq_attr "type" "fistp,leave")
22fb740d 308 (const_string "both")
e075ae69
RH
309 (eq_attr "type" "push")
310 (if_then_else (match_operand 1 "memory_operand" "")
311 (const_string "both")
312 (const_string "store"))
abd2dd6d 313 (eq_attr "type" "pop")
e075ae69
RH
314 (if_then_else (match_operand 0 "memory_operand" "")
315 (const_string "both")
316 (const_string "load"))
abd2dd6d
JH
317 (eq_attr "type" "setcc")
318 (if_then_else (match_operand 0 "memory_operand" "")
319 (const_string "store")
320 (const_string "none"))
f56e86bd 321 (eq_attr "type" "icmp,test,ssecmp,ssecomi,mmxcmp,fcmp")
e075ae69
RH
322 (if_then_else (ior (match_operand 0 "memory_operand" "")
323 (match_operand 1 "memory_operand" ""))
324 (const_string "load")
325 (const_string "none"))
326 (eq_attr "type" "ibr")
327 (if_then_else (match_operand 0 "memory_operand" "")
328 (const_string "load")
329 (const_string "none"))
330 (eq_attr "type" "call")
331 (if_then_else (match_operand 0 "constant_call_address_operand" "")
332 (const_string "none")
333 (const_string "load"))
334 (eq_attr "type" "callv")
335 (if_then_else (match_operand 1 "constant_call_address_operand" "")
336 (const_string "none")
337 (const_string "load"))
338 (and (eq_attr "type" "alu1,negnot")
a269a03c 339 (match_operand 1 "memory_operand" ""))
e075ae69
RH
340 (const_string "both")
341 (and (match_operand 0 "memory_operand" "")
342 (match_operand 1 "memory_operand" ""))
343 (const_string "both")
344 (match_operand 0 "memory_operand" "")
345 (const_string "store")
346 (match_operand 1 "memory_operand" "")
347 (const_string "load")
9a5834ae
ZW
348 (and (eq_attr "type"
349 "!alu1,negnot,
350 imov,imovx,icmp,test,
351 fmov,fcmp,fsgn,
cb297538 352 sse,ssemov,ssecmp,ssecomi,ssecvt,sseicvt,
9a5834ae 353 mmx,mmxmov,mmxcmp,mmxcvt")
e075ae69
RH
354 (match_operand 2 "memory_operand" ""))
355 (const_string "load")
356 (and (eq_attr "type" "icmov")
357 (match_operand 3 "memory_operand" ""))
358 (const_string "load")
359 ]
a269a03c
JC
360 (const_string "none")))
361
e075ae69
RH
362;; Indicates if an instruction has both an immediate and a displacement.
363
364(define_attr "imm_disp" "false,true,unknown"
365 (cond [(eq_attr "type" "other,multi")
366 (const_string "unknown")
1b245ade 367 (and (eq_attr "type" "icmp,test,imov,alu1,ishift1,rotate1")
e075ae69
RH
368 (and (match_operand 0 "memory_displacement_operand" "")
369 (match_operand 1 "immediate_operand" "")))
370 (const_string "true")
890d52e8 371 (and (eq_attr "type" "alu,ishift,rotate,imul,idiv")
e075ae69
RH
372 (and (match_operand 0 "memory_displacement_operand" "")
373 (match_operand 2 "immediate_operand" "")))
374 (const_string "true")
375 ]
376 (const_string "false")))
377
378;; Indicates if an FP operation has an integer source.
379
380(define_attr "fp_int_src" "false,true"
381 (const_string "false"))
382
383;; Describe a user's asm statement.
384(define_asm_attributes
385 [(set_attr "length" "128")
386 (set_attr "type" "multi")])
387\f
af2728a4
JL
388(include "pentium.md")
389(include "ppro.md")
390(include "k6.md")
391(include "athlon.md")
309ada50 392\f
e075ae69 393;; Compare instructions.
886c62d1 394
e075ae69 395;; All compare insns have expanders that save the operands away without
c572e5ba 396;; actually generating RTL. The bCOND or sCOND (emitted immediately
e075ae69 397;; after the cmp) will actually emit the cmpM.
886c62d1 398
e075ae69
RH
399(define_expand "cmpdi"
400 [(set (reg:CC 17)
b9b2c339 401 (compare:CC (match_operand:DI 0 "nonimmediate_operand" "")
9b70259d 402 (match_operand:DI 1 "x86_64_general_operand" "")))]
c572e5ba 403 ""
c572e5ba 404{
b9b2c339 405 if (GET_CODE (operands[0]) == MEM && GET_CODE (operands[1]) == MEM)
e075ae69
RH
406 operands[0] = force_reg (DImode, operands[0]);
407 ix86_compare_op0 = operands[0];
408 ix86_compare_op1 = operands[1];
c572e5ba 409 DONE;
0f40f9f7 410})
c572e5ba 411
e075ae69
RH
412(define_expand "cmpsi"
413 [(set (reg:CC 17)
414 (compare:CC (match_operand:SI 0 "cmpsi_operand" "")
415 (match_operand:SI 1 "general_operand" "")))]
c572e5ba 416 ""
c572e5ba 417{
b9b2c339 418 if (GET_CODE (operands[0]) == MEM && GET_CODE (operands[1]) == MEM)
e075ae69
RH
419 operands[0] = force_reg (SImode, operands[0]);
420 ix86_compare_op0 = operands[0];
421 ix86_compare_op1 = operands[1];
c572e5ba 422 DONE;
0f40f9f7 423})
c572e5ba 424
e075ae69
RH
425(define_expand "cmphi"
426 [(set (reg:CC 17)
b9b2c339 427 (compare:CC (match_operand:HI 0 "nonimmediate_operand" "")
e075ae69 428 (match_operand:HI 1 "general_operand" "")))]
c572e5ba 429 ""
c572e5ba 430{
b9b2c339 431 if (GET_CODE (operands[0]) == MEM && GET_CODE (operands[1]) == MEM)
e075ae69
RH
432 operands[0] = force_reg (HImode, operands[0]);
433 ix86_compare_op0 = operands[0];
434 ix86_compare_op1 = operands[1];
c572e5ba 435 DONE;
0f40f9f7 436})
c572e5ba 437
e075ae69
RH
438(define_expand "cmpqi"
439 [(set (reg:CC 17)
b9b2c339 440 (compare:CC (match_operand:QI 0 "nonimmediate_operand" "")
e075ae69 441 (match_operand:QI 1 "general_operand" "")))]
d9f32422 442 "TARGET_QIMODE_MATH"
c572e5ba 443{
b9b2c339 444 if (GET_CODE (operands[0]) == MEM && GET_CODE (operands[1]) == MEM)
e075ae69
RH
445 operands[0] = force_reg (QImode, operands[0]);
446 ix86_compare_op0 = operands[0];
447 ix86_compare_op1 = operands[1];
c572e5ba 448 DONE;
0f40f9f7 449})
886c62d1 450
9b70259d
JH
451(define_insn "cmpdi_ccno_1_rex64"
452 [(set (reg 17)
453 (compare (match_operand:DI 0 "nonimmediate_operand" "r,?mr")
454 (match_operand:DI 1 "const0_operand" "n,n")))]
455 "TARGET_64BIT && ix86_match_ccmode (insn, CCNOmode)"
456 "@
0f40f9f7
ZW
457 test{q}\t{%0, %0|%0, %0}
458 cmp{q}\t{%1, %0|%0, %1}"
9b70259d
JH
459 [(set_attr "type" "test,icmp")
460 (set_attr "length_immediate" "0,1")
461 (set_attr "mode" "DI")])
462
463(define_insn "*cmpdi_minus_1_rex64"
464 [(set (reg 17)
465 (compare (minus:DI (match_operand:DI 0 "nonimmediate_operand" "rm,r")
466 (match_operand:DI 1 "x86_64_general_operand" "re,mr"))
467 (const_int 0)))]
1b0c37d7 468 "TARGET_64BIT && ix86_match_ccmode (insn, CCGOCmode)"
0f40f9f7 469 "cmp{q}\t{%1, %0|%0, %1}"
9b70259d
JH
470 [(set_attr "type" "icmp")
471 (set_attr "mode" "DI")])
472
473(define_expand "cmpdi_1_rex64"
474 [(set (reg:CC 17)
475 (compare:CC (match_operand:DI 0 "nonimmediate_operand" "")
476 (match_operand:DI 1 "general_operand" "")))]
1b0c37d7 477 "TARGET_64BIT"
9b70259d
JH
478 "")
479
480(define_insn "cmpdi_1_insn_rex64"
481 [(set (reg 17)
482 (compare (match_operand:DI 0 "nonimmediate_operand" "mr,r")
483 (match_operand:DI 1 "x86_64_general_operand" "re,mr")))]
484 "TARGET_64BIT && ix86_match_ccmode (insn, CCmode)"
0f40f9f7 485 "cmp{q}\t{%1, %0|%0, %1}"
9b70259d
JH
486 [(set_attr "type" "icmp")
487 (set_attr "mode" "DI")])
488
489
9076b9c1
JH
490(define_insn "*cmpsi_ccno_1"
491 [(set (reg 17)
492 (compare (match_operand:SI 0 "nonimmediate_operand" "r,?mr")
493 (match_operand:SI 1 "const0_operand" "n,n")))]
494 "ix86_match_ccmode (insn, CCNOmode)"
16189740 495 "@
0f40f9f7
ZW
496 test{l}\t{%0, %0|%0, %0}
497 cmp{l}\t{%1, %0|%0, %1}"
6ef67412
JH
498 [(set_attr "type" "test,icmp")
499 (set_attr "length_immediate" "0,1")
500 (set_attr "mode" "SI")])
16189740 501
9076b9c1
JH
502(define_insn "*cmpsi_minus_1"
503 [(set (reg 17)
504 (compare (minus:SI (match_operand:SI 0 "nonimmediate_operand" "rm,r")
505 (match_operand:SI 1 "general_operand" "ri,mr"))
506 (const_int 0)))]
507 "ix86_match_ccmode (insn, CCGOCmode)"
0f40f9f7 508 "cmp{l}\t{%1, %0|%0, %1}"
9076b9c1 509 [(set_attr "type" "icmp")
6ef67412 510 (set_attr "mode" "SI")])
886c62d1 511
9076b9c1 512(define_expand "cmpsi_1"
e075ae69
RH
513 [(set (reg:CC 17)
514 (compare:CC (match_operand:SI 0 "nonimmediate_operand" "rm,r")
515 (match_operand:SI 1 "general_operand" "ri,mr")))]
9076b9c1
JH
516 ""
517 "")
518
519(define_insn "*cmpsi_1_insn"
520 [(set (reg 17)
521 (compare (match_operand:SI 0 "nonimmediate_operand" "rm,r")
522 (match_operand:SI 1 "general_operand" "ri,mr")))]
523 "(GET_CODE (operands[0]) != MEM || GET_CODE (operands[1]) != MEM)
524 && ix86_match_ccmode (insn, CCmode)"
0f40f9f7 525 "cmp{l}\t{%1, %0|%0, %1}"
6ef67412
JH
526 [(set_attr "type" "icmp")
527 (set_attr "mode" "SI")])
886c62d1 528
9076b9c1 529(define_insn "*cmphi_ccno_1"
16189740
RH
530 [(set (reg 17)
531 (compare (match_operand:HI 0 "nonimmediate_operand" "r,?mr")
532 (match_operand:HI 1 "const0_operand" "n,n")))]
533 "ix86_match_ccmode (insn, CCNOmode)"
e075ae69 534 "@
0f40f9f7
ZW
535 test{w}\t{%0, %0|%0, %0}
536 cmp{w}\t{%1, %0|%0, %1}"
6ef67412
JH
537 [(set_attr "type" "test,icmp")
538 (set_attr "length_immediate" "0,1")
539 (set_attr "mode" "HI")])
886c62d1 540
9076b9c1
JH
541(define_insn "*cmphi_minus_1"
542 [(set (reg 17)
543 (compare (minus:HI (match_operand:HI 0 "nonimmediate_operand" "rm,r")
544 (match_operand:HI 1 "general_operand" "ri,mr"))
545 (const_int 0)))]
546 "ix86_match_ccmode (insn, CCGOCmode)"
0f40f9f7 547 "cmp{w}\t{%1, %0|%0, %1}"
6ef67412
JH
548 [(set_attr "type" "icmp")
549 (set_attr "mode" "HI")])
e075ae69 550
9076b9c1
JH
551(define_insn "*cmphi_1"
552 [(set (reg 17)
553 (compare (match_operand:HI 0 "nonimmediate_operand" "rm,r")
554 (match_operand:HI 1 "general_operand" "ri,mr")))]
555 "(GET_CODE (operands[0]) != MEM || GET_CODE (operands[1]) != MEM)
556 && ix86_match_ccmode (insn, CCmode)"
0f40f9f7 557 "cmp{w}\t{%1, %0|%0, %1}"
9076b9c1
JH
558 [(set_attr "type" "icmp")
559 (set_attr "mode" "HI")])
16189740
RH
560
561(define_insn "*cmpqi_ccno_1"
9076b9c1
JH
562 [(set (reg 17)
563 (compare (match_operand:QI 0 "nonimmediate_operand" "q,?mq")
564 (match_operand:QI 1 "const0_operand" "n,n")))]
565 "ix86_match_ccmode (insn, CCNOmode)"
e075ae69 566 "@
0f40f9f7
ZW
567 test{b}\t{%0, %0|%0, %0}
568 cmp{b}\t{$0, %0|%0, 0}"
6ef67412
JH
569 [(set_attr "type" "test,icmp")
570 (set_attr "length_immediate" "0,1")
571 (set_attr "mode" "QI")])
886c62d1 572
16189740 573(define_insn "*cmpqi_1"
9076b9c1
JH
574 [(set (reg 17)
575 (compare (match_operand:QI 0 "nonimmediate_operand" "qm,q")
576 (match_operand:QI 1 "general_operand" "qi,mq")))]
577 "(GET_CODE (operands[0]) != MEM || GET_CODE (operands[1]) != MEM)
578 && ix86_match_ccmode (insn, CCmode)"
0f40f9f7 579 "cmp{b}\t{%1, %0|%0, %1}"
6ef67412
JH
580 [(set_attr "type" "icmp")
581 (set_attr "mode" "QI")])
e075ae69 582
9076b9c1
JH
583(define_insn "*cmpqi_minus_1"
584 [(set (reg 17)
d70401eb
JJ
585 (compare (minus:QI (match_operand:QI 0 "nonimmediate_operand" "qm,q")
586 (match_operand:QI 1 "general_operand" "qi,mq"))
9076b9c1
JH
587 (const_int 0)))]
588 "ix86_match_ccmode (insn, CCGOCmode)"
0f40f9f7 589 "cmp{b}\t{%1, %0|%0, %1}"
9076b9c1
JH
590 [(set_attr "type" "icmp")
591 (set_attr "mode" "QI")])
592
e075ae69 593(define_insn "*cmpqi_ext_1"
9076b9c1
JH
594 [(set (reg 17)
595 (compare
d2836273 596 (match_operand:QI 0 "general_operand" "Qm")
e075ae69
RH
597 (subreg:QI
598 (zero_extract:SI
d2836273 599 (match_operand 1 "ext_register_operand" "Q")
e075ae69
RH
600 (const_int 8)
601 (const_int 8)) 0)))]
d2836273 602 "!TARGET_64BIT && ix86_match_ccmode (insn, CCmode)"
0f40f9f7 603 "cmp{b}\t{%h1, %0|%0, %h1}"
d2836273
JH
604 [(set_attr "type" "icmp")
605 (set_attr "mode" "QI")])
606
607(define_insn "*cmpqi_ext_1_rex64"
608 [(set (reg 17)
609 (compare
3522082b 610 (match_operand:QI 0 "register_operand" "Q")
d2836273
JH
611 (subreg:QI
612 (zero_extract:SI
613 (match_operand 1 "ext_register_operand" "Q")
614 (const_int 8)
615 (const_int 8)) 0)))]
616 "TARGET_64BIT && ix86_match_ccmode (insn, CCmode)"
0f40f9f7 617 "cmp{b}\t{%h1, %0|%0, %h1}"
6ef67412
JH
618 [(set_attr "type" "icmp")
619 (set_attr "mode" "QI")])
e075ae69
RH
620
621(define_insn "*cmpqi_ext_2"
16189740
RH
622 [(set (reg 17)
623 (compare
e075ae69
RH
624 (subreg:QI
625 (zero_extract:SI
d2836273 626 (match_operand 0 "ext_register_operand" "Q")
e075ae69
RH
627 (const_int 8)
628 (const_int 8)) 0)
629 (match_operand:QI 1 "const0_operand" "n")))]
16189740 630 "ix86_match_ccmode (insn, CCNOmode)"
0f40f9f7 631 "test{b}\t%h0, %h0"
6ef67412
JH
632 [(set_attr "type" "test")
633 (set_attr "length_immediate" "0")
634 (set_attr "mode" "QI")])
e075ae69 635
9076b9c1 636(define_expand "cmpqi_ext_3"
e075ae69
RH
637 [(set (reg:CC 17)
638 (compare:CC
639 (subreg:QI
640 (zero_extract:SI
d2836273 641 (match_operand 0 "ext_register_operand" "")
e075ae69
RH
642 (const_int 8)
643 (const_int 8)) 0)
d2836273 644 (match_operand:QI 1 "general_operand" "")))]
e075ae69 645 ""
9076b9c1
JH
646 "")
647
648(define_insn "cmpqi_ext_3_insn"
649 [(set (reg 17)
650 (compare
651 (subreg:QI
652 (zero_extract:SI
d2836273 653 (match_operand 0 "ext_register_operand" "Q")
9076b9c1
JH
654 (const_int 8)
655 (const_int 8)) 0)
d2836273
JH
656 (match_operand:QI 1 "general_operand" "Qmn")))]
657 "!TARGET_64BIT && ix86_match_ccmode (insn, CCmode)"
0f40f9f7 658 "cmp{b}\t{%1, %h0|%h0, %1}"
d2836273
JH
659 [(set_attr "type" "icmp")
660 (set_attr "mode" "QI")])
661
662(define_insn "cmpqi_ext_3_insn_rex64"
663 [(set (reg 17)
664 (compare
665 (subreg:QI
666 (zero_extract:SI
667 (match_operand 0 "ext_register_operand" "Q")
668 (const_int 8)
669 (const_int 8)) 0)
670 (match_operand:QI 1 "nonmemory_operand" "Qn")))]
671 "TARGET_64BIT && ix86_match_ccmode (insn, CCmode)"
0f40f9f7 672 "cmp{b}\t{%1, %h0|%h0, %1}"
6ef67412
JH
673 [(set_attr "type" "icmp")
674 (set_attr "mode" "QI")])
e075ae69
RH
675
676(define_insn "*cmpqi_ext_4"
9076b9c1
JH
677 [(set (reg 17)
678 (compare
e075ae69
RH
679 (subreg:QI
680 (zero_extract:SI
d2836273 681 (match_operand 0 "ext_register_operand" "Q")
e075ae69
RH
682 (const_int 8)
683 (const_int 8)) 0)
684 (subreg:QI
685 (zero_extract:SI
d2836273 686 (match_operand 1 "ext_register_operand" "Q")
e075ae69
RH
687 (const_int 8)
688 (const_int 8)) 0)))]
9076b9c1 689 "ix86_match_ccmode (insn, CCmode)"
0f40f9f7 690 "cmp{b}\t{%h1, %h0|%h0, %h1}"
6ef67412
JH
691 [(set_attr "type" "icmp")
692 (set_attr "mode" "QI")])
e075ae69
RH
693
694;; These implement float point compares.
695;; %%% See if we can get away with VOIDmode operands on the actual insns,
696;; which would allow mix and match FP modes on the compares. Which is what
697;; the old patterns did, but with many more of them.
c572e5ba 698
e075ae69
RH
699(define_expand "cmpxf"
700 [(set (reg:CC 17)
701 (compare:CC (match_operand:XF 0 "cmp_fp_expander_operand" "")
702 (match_operand:XF 1 "cmp_fp_expander_operand" "")))]
1b0c37d7 703 "!TARGET_64BIT && TARGET_80387"
c572e5ba 704{
e075ae69
RH
705 ix86_compare_op0 = operands[0];
706 ix86_compare_op1 = operands[1];
c572e5ba 707 DONE;
0f40f9f7 708})
4fb21e90 709
2b589241
JH
710(define_expand "cmptf"
711 [(set (reg:CC 17)
712 (compare:CC (match_operand:TF 0 "cmp_fp_expander_operand" "")
713 (match_operand:TF 1 "cmp_fp_expander_operand" "")))]
714 "TARGET_80387"
2b589241
JH
715{
716 ix86_compare_op0 = operands[0];
717 ix86_compare_op1 = operands[1];
718 DONE;
0f40f9f7 719})
2b589241 720
e075ae69
RH
721(define_expand "cmpdf"
722 [(set (reg:CC 17)
723 (compare:CC (match_operand:DF 0 "cmp_fp_expander_operand" "")
724 (match_operand:DF 1 "cmp_fp_expander_operand" "")))]
0644b628 725 "TARGET_80387 || TARGET_SSE2"
4fb21e90 726{
e075ae69
RH
727 ix86_compare_op0 = operands[0];
728 ix86_compare_op1 = operands[1];
4fb21e90 729 DONE;
0f40f9f7 730})
886c62d1 731
e075ae69
RH
732(define_expand "cmpsf"
733 [(set (reg:CC 17)
734 (compare:CC (match_operand:SF 0 "cmp_fp_expander_operand" "")
735 (match_operand:SF 1 "cmp_fp_expander_operand" "")))]
0644b628 736 "TARGET_80387 || TARGET_SSE"
c572e5ba 737{
e075ae69
RH
738 ix86_compare_op0 = operands[0];
739 ix86_compare_op1 = operands[1];
c572e5ba 740 DONE;
0f40f9f7 741})
c572e5ba 742
e075ae69
RH
743;; FP compares, step 1:
744;; Set the FP condition codes.
745;;
746;; CCFPmode compare with exceptions
747;; CCFPUmode compare with no exceptions
fe4435d9 748
e075ae69
RH
749;; %%% It is an unfortunate fact that ftst has no non-popping variant,
750;; and that fp moves clobber the condition codes, and that there is
751;; currently no way to describe this fact to reg-stack. So there are
752;; no splitters yet for this.
c572e5ba 753
e075ae69
RH
754;; %%% YIKES! This scheme does not retain a strong connection between
755;; the real compare and the ultimate cc0 user, so CC_REVERSE does not
756;; work! Only allow tos/mem with tos in op 0.
757;;
758;; Hmm, of course, this is what the actual _hardware_ does. Perhaps
759;; things aren't as bad as they sound...
886c62d1 760
e075ae69
RH
761(define_insn "*cmpfp_0"
762 [(set (match_operand:HI 0 "register_operand" "=a")
763 (unspec:HI
764 [(compare:CCFP (match_operand 1 "register_operand" "f")
8ee41eaf
RH
765 (match_operand 2 "const0_operand" "X"))]
766 UNSPEC_FNSTSW))]
e075ae69
RH
767 "TARGET_80387
768 && FLOAT_MODE_P (GET_MODE (operands[1]))
769 && GET_MODE (operands[1]) == GET_MODE (operands[2])"
c572e5ba 770{
e075ae69 771 if (find_regno_note (insn, REG_DEAD, REGNO (operands[1])))
0f40f9f7 772 return "ftst\;fnstsw\t%0\;fstp\t%y0";
e075ae69 773 else
0f40f9f7
ZW
774 return "ftst\;fnstsw\t%0";
775}
6ef67412 776 [(set_attr "type" "multi")
4977bab6
ZW
777 (set (attr "mode")
778 (cond [(match_operand:SF 1 "" "")
779 (const_string "SF")
780 (match_operand:DF 1 "" "")
781 (const_string "DF")
782 ]
783 (const_string "XF")))])
c572e5ba 784
e075ae69
RH
785;; We may not use "#" to split and emit these, since the REG_DEAD notes
786;; used to manage the reg stack popping would not be preserved.
886c62d1 787
e075ae69
RH
788(define_insn "*cmpfp_2_sf"
789 [(set (reg:CCFP 18)
790 (compare:CCFP
791 (match_operand:SF 0 "register_operand" "f")
792 (match_operand:SF 1 "nonimmediate_operand" "fm")))]
cac58785 793 "TARGET_80387"
e075ae69 794 "* return output_fp_compare (insn, operands, 0, 0);"
6ef67412
JH
795 [(set_attr "type" "fcmp")
796 (set_attr "mode" "SF")])
4fb21e90 797
6343a50e 798(define_insn "*cmpfp_2_sf_1"
e075ae69
RH
799 [(set (match_operand:HI 0 "register_operand" "=a")
800 (unspec:HI
801 [(compare:CCFP
802 (match_operand:SF 1 "register_operand" "f")
8ee41eaf
RH
803 (match_operand:SF 2 "nonimmediate_operand" "fm"))]
804 UNSPEC_FNSTSW))]
4fb21e90 805 "TARGET_80387"
e075ae69 806 "* return output_fp_compare (insn, operands, 2, 0);"
6ef67412
JH
807 [(set_attr "type" "fcmp")
808 (set_attr "mode" "SF")])
e075ae69
RH
809
810(define_insn "*cmpfp_2_df"
811 [(set (reg:CCFP 18)
812 (compare:CCFP
813 (match_operand:DF 0 "register_operand" "f")
814 (match_operand:DF 1 "nonimmediate_operand" "fm")))]
926b3fae 815 "TARGET_80387"
e075ae69 816 "* return output_fp_compare (insn, operands, 0, 0);"
6ef67412
JH
817 [(set_attr "type" "fcmp")
818 (set_attr "mode" "DF")])
926b3fae 819
6343a50e 820(define_insn "*cmpfp_2_df_1"
e075ae69
RH
821 [(set (match_operand:HI 0 "register_operand" "=a")
822 (unspec:HI
823 [(compare:CCFP
824 (match_operand:DF 1 "register_operand" "f")
8ee41eaf
RH
825 (match_operand:DF 2 "nonimmediate_operand" "fm"))]
826 UNSPEC_FNSTSW))]
4fb21e90 827 "TARGET_80387"
e075ae69 828 "* return output_fp_compare (insn, operands, 2, 0);"
6ef67412
JH
829 [(set_attr "type" "multi")
830 (set_attr "mode" "DF")])
e075ae69
RH
831
832(define_insn "*cmpfp_2_xf"
833 [(set (reg:CCFP 18)
834 (compare:CCFP
835 (match_operand:XF 0 "register_operand" "f")
836 (match_operand:XF 1 "register_operand" "f")))]
1b0c37d7 837 "!TARGET_64BIT && TARGET_80387"
e075ae69 838 "* return output_fp_compare (insn, operands, 0, 0);"
6ef67412
JH
839 [(set_attr "type" "fcmp")
840 (set_attr "mode" "XF")])
9ec36da5 841
2b589241
JH
842(define_insn "*cmpfp_2_tf"
843 [(set (reg:CCFP 18)
844 (compare:CCFP
845 (match_operand:TF 0 "register_operand" "f")
846 (match_operand:TF 1 "register_operand" "f")))]
847 "TARGET_80387"
848 "* return output_fp_compare (insn, operands, 0, 0);"
849 [(set_attr "type" "fcmp")
850 (set_attr "mode" "XF")])
851
6343a50e 852(define_insn "*cmpfp_2_xf_1"
e075ae69
RH
853 [(set (match_operand:HI 0 "register_operand" "=a")
854 (unspec:HI
855 [(compare:CCFP
856 (match_operand:XF 1 "register_operand" "f")
8ee41eaf
RH
857 (match_operand:XF 2 "register_operand" "f"))]
858 UNSPEC_FNSTSW))]
1b0c37d7 859 "!TARGET_64BIT && TARGET_80387"
e075ae69 860 "* return output_fp_compare (insn, operands, 2, 0);"
6ef67412
JH
861 [(set_attr "type" "multi")
862 (set_attr "mode" "XF")])
e075ae69 863
2b589241
JH
864(define_insn "*cmpfp_2_tf_1"
865 [(set (match_operand:HI 0 "register_operand" "=a")
866 (unspec:HI
867 [(compare:CCFP
868 (match_operand:TF 1 "register_operand" "f")
8ee41eaf
RH
869 (match_operand:TF 2 "register_operand" "f"))]
870 UNSPEC_FNSTSW))]
2b589241
JH
871 "TARGET_80387"
872 "* return output_fp_compare (insn, operands, 2, 0);"
873 [(set_attr "type" "multi")
874 (set_attr "mode" "XF")])
875
e075ae69
RH
876(define_insn "*cmpfp_2u"
877 [(set (reg:CCFPU 18)
878 (compare:CCFPU
879 (match_operand 0 "register_operand" "f")
880 (match_operand 1 "register_operand" "f")))]
881 "TARGET_80387
882 && FLOAT_MODE_P (GET_MODE (operands[0]))
883 && GET_MODE (operands[0]) == GET_MODE (operands[1])"
884 "* return output_fp_compare (insn, operands, 0, 1);"
6ef67412 885 [(set_attr "type" "fcmp")
4977bab6
ZW
886 (set (attr "mode")
887 (cond [(match_operand:SF 1 "" "")
888 (const_string "SF")
889 (match_operand:DF 1 "" "")
890 (const_string "DF")
891 ]
892 (const_string "XF")))])
4fb21e90 893
6343a50e 894(define_insn "*cmpfp_2u_1"
e075ae69
RH
895 [(set (match_operand:HI 0 "register_operand" "=a")
896 (unspec:HI
897 [(compare:CCFPU
898 (match_operand 1 "register_operand" "f")
8ee41eaf
RH
899 (match_operand 2 "register_operand" "f"))]
900 UNSPEC_FNSTSW))]
08a7baac 901 "TARGET_80387
e075ae69
RH
902 && FLOAT_MODE_P (GET_MODE (operands[1]))
903 && GET_MODE (operands[1]) == GET_MODE (operands[2])"
904 "* return output_fp_compare (insn, operands, 2, 1);"
6ef67412 905 [(set_attr "type" "multi")
4977bab6
ZW
906 (set (attr "mode")
907 (cond [(match_operand:SF 1 "" "")
908 (const_string "SF")
909 (match_operand:DF 1 "" "")
910 (const_string "DF")
911 ]
912 (const_string "XF")))])
08a7baac 913
e075ae69
RH
914;; Patterns to match the SImode-in-memory ficom instructions.
915;;
916;; %%% Play games with accepting gp registers, as otherwise we have to
917;; force them to memory during rtl generation, which is no good. We
918;; can get rid of this once we teach reload to do memory input reloads
919;; via pushes.
920
6343a50e 921(define_insn "*ficom_1"
e075ae69
RH
922 [(set (reg:CCFP 18)
923 (compare:CCFP
924 (match_operand 0 "register_operand" "f,f")
925 (float (match_operand:SI 1 "nonimmediate_operand" "m,?r"))))]
926 "0 && TARGET_80387 && FLOAT_MODE_P (GET_MODE (operands[0]))
927 && GET_MODE (XEXP (SET_SRC (PATTERN (insn)), 1)) == GET_MODE (operands[0])"
928 "#")
08a7baac 929
e075ae69
RH
930;; Split the not-really-implemented gp register case into a
931;; push-op-pop sequence.
932;;
933;; %%% This is most efficient, but am I gonna get in trouble
934;; for separating cc0_setter and cc0_user?
2bb7a0f5 935
e075ae69
RH
936(define_split
937 [(set (reg:CCFP 18)
938 (compare:CCFP
939 (match_operand:SF 0 "register_operand" "")
940 (float (match_operand:SI 1 "register_operand" ""))))]
941 "0 && TARGET_80387 && reload_completed"
942 [(set (mem:SI (pre_dec:SI (reg:SI 7))) (match_dup 1))
943 (set (reg:CCFP 18) (compare:CCFP (match_dup 0) (match_dup 2)))
944 (parallel [(set (match_dup 1) (mem:SI (reg:SI 7)))
945 (set (reg:SI 7) (plus:SI (reg:SI 7) (const_int 4)))])]
946 "operands[2] = gen_rtx_MEM (Pmode, stack_pointer_rtx);
947 operands[2] = gen_rtx_FLOAT (GET_MODE (operands[0]), operands[2]);")
948
949;; FP compares, step 2
950;; Move the fpsw to ax.
951
4977bab6 952(define_insn "*x86_fnstsw_1"
e075ae69 953 [(set (match_operand:HI 0 "register_operand" "=a")
8ee41eaf 954 (unspec:HI [(reg 18)] UNSPEC_FNSTSW))]
2ae0f82c 955 "TARGET_80387"
0f40f9f7 956 "fnstsw\t%0"
e075ae69 957 [(set_attr "length" "2")
6ef67412 958 (set_attr "mode" "SI")
3d34cd91 959 (set_attr "unit" "i387")
e075ae69
RH
960 (set_attr "ppro_uops" "few")])
961
962;; FP compares, step 3
963;; Get ax into flags, general case.
964
965(define_insn "x86_sahf_1"
966 [(set (reg:CC 17)
8ee41eaf 967 (unspec:CC [(match_operand:HI 0 "register_operand" "a")] UNSPEC_SAHF))]
1e07edd3 968 "!TARGET_64BIT"
e075ae69
RH
969 "sahf"
970 [(set_attr "length" "1")
0b5107cf 971 (set_attr "athlon_decode" "vector")
6ef67412 972 (set_attr "mode" "SI")
e075ae69
RH
973 (set_attr "ppro_uops" "one")])
974
975;; Pentium Pro can do steps 1 through 3 in one go.
976
977(define_insn "*cmpfp_i"
978 [(set (reg:CCFP 17)
979 (compare:CCFP (match_operand 0 "register_operand" "f")
980 (match_operand 1 "register_operand" "f")))]
981 "TARGET_80387 && TARGET_CMOVE
0644b628 982 && !SSE_FLOAT_MODE_P (GET_MODE (operands[0]))
e075ae69
RH
983 && FLOAT_MODE_P (GET_MODE (operands[0]))
984 && GET_MODE (operands[0]) == GET_MODE (operands[0])"
985 "* return output_fp_compare (insn, operands, 1, 0);"
309ada50 986 [(set_attr "type" "fcmp")
4977bab6
ZW
987 (set (attr "mode")
988 (cond [(match_operand:SF 1 "" "")
989 (const_string "SF")
990 (match_operand:DF 1 "" "")
991 (const_string "DF")
992 ]
993 (const_string "XF")))
309ada50 994 (set_attr "athlon_decode" "vector")])
e075ae69 995
0644b628
JH
996(define_insn "*cmpfp_i_sse"
997 [(set (reg:CCFP 17)
998 (compare:CCFP (match_operand 0 "register_operand" "f#x,x#f")
999 (match_operand 1 "nonimmediate_operand" "f#x,xm#f")))]
1000 "TARGET_80387
1001 && SSE_FLOAT_MODE_P (GET_MODE (operands[0]))
1002 && GET_MODE (operands[0]) == GET_MODE (operands[0])"
1003 "* return output_fp_compare (insn, operands, 1, 0);"
26771da7 1004 [(set_attr "type" "fcmp,ssecomi")
4977bab6
ZW
1005 (set (attr "mode")
1006 (if_then_else (match_operand:SF 1 "" "")
1007 (const_string "SF")
1008 (const_string "DF")))
0644b628
JH
1009 (set_attr "athlon_decode" "vector")])
1010
1011(define_insn "*cmpfp_i_sse_only"
1012 [(set (reg:CCFP 17)
1013 (compare:CCFP (match_operand 0 "register_operand" "x")
1014 (match_operand 1 "nonimmediate_operand" "xm")))]
1015 "SSE_FLOAT_MODE_P (GET_MODE (operands[0]))
1016 && GET_MODE (operands[0]) == GET_MODE (operands[0])"
1017 "* return output_fp_compare (insn, operands, 1, 0);"
26771da7 1018 [(set_attr "type" "ssecomi")
4977bab6
ZW
1019 (set (attr "mode")
1020 (if_then_else (match_operand:SF 1 "" "")
1021 (const_string "SF")
1022 (const_string "DF")))
0644b628
JH
1023 (set_attr "athlon_decode" "vector")])
1024
e075ae69
RH
1025(define_insn "*cmpfp_iu"
1026 [(set (reg:CCFPU 17)
1027 (compare:CCFPU (match_operand 0 "register_operand" "f")
1028 (match_operand 1 "register_operand" "f")))]
1029 "TARGET_80387 && TARGET_CMOVE
0644b628 1030 && !SSE_FLOAT_MODE_P (GET_MODE (operands[0]))
e075ae69
RH
1031 && FLOAT_MODE_P (GET_MODE (operands[0]))
1032 && GET_MODE (operands[0]) == GET_MODE (operands[1])"
1033 "* return output_fp_compare (insn, operands, 1, 1);"
309ada50 1034 [(set_attr "type" "fcmp")
4977bab6
ZW
1035 (set (attr "mode")
1036 (cond [(match_operand:SF 1 "" "")
1037 (const_string "SF")
1038 (match_operand:DF 1 "" "")
1039 (const_string "DF")
1040 ]
1041 (const_string "XF")))
309ada50 1042 (set_attr "athlon_decode" "vector")])
0644b628
JH
1043
1044(define_insn "*cmpfp_iu_sse"
1045 [(set (reg:CCFPU 17)
1046 (compare:CCFPU (match_operand 0 "register_operand" "f#x,x#f")
1047 (match_operand 1 "nonimmediate_operand" "f#x,xm#f")))]
1048 "TARGET_80387
1049 && SSE_FLOAT_MODE_P (GET_MODE (operands[0]))
1050 && GET_MODE (operands[0]) == GET_MODE (operands[1])"
1051 "* return output_fp_compare (insn, operands, 1, 1);"
26771da7 1052 [(set_attr "type" "fcmp,ssecomi")
4977bab6
ZW
1053 (set (attr "mode")
1054 (if_then_else (match_operand:SF 1 "" "")
1055 (const_string "SF")
1056 (const_string "DF")))
0644b628
JH
1057 (set_attr "athlon_decode" "vector")])
1058
1059(define_insn "*cmpfp_iu_sse_only"
1060 [(set (reg:CCFPU 17)
1061 (compare:CCFPU (match_operand 0 "register_operand" "x")
1062 (match_operand 1 "nonimmediate_operand" "xm")))]
1063 "SSE_FLOAT_MODE_P (GET_MODE (operands[0]))
1064 && GET_MODE (operands[0]) == GET_MODE (operands[1])"
1065 "* return output_fp_compare (insn, operands, 1, 1);"
26771da7 1066 [(set_attr "type" "ssecomi")
4977bab6
ZW
1067 (set (attr "mode")
1068 (if_then_else (match_operand:SF 1 "" "")
1069 (const_string "SF")
1070 (const_string "DF")))
0644b628 1071 (set_attr "athlon_decode" "vector")])
e075ae69
RH
1072\f
1073;; Move instructions.
2ae0f82c 1074
e075ae69 1075;; General case of fullword move.
886c62d1 1076
e075ae69
RH
1077(define_expand "movsi"
1078 [(set (match_operand:SI 0 "nonimmediate_operand" "")
1079 (match_operand:SI 1 "general_operand" ""))]
1080 ""
1081 "ix86_expand_move (SImode, operands); DONE;")
08a7baac 1082
e075ae69
RH
1083;; Push/pop instructions. They are separate since autoinc/dec is not a
1084;; general_operand.
1085;;
1086;; %%% We don't use a post-inc memory reference because x86 is not a
1087;; general AUTO_INC_DEC host, which impacts how it is treated in flow.
1088;; Changing this impacts compiler performance on other non-AUTO_INC_DEC
1089;; targets without our curiosities, and it is just as easy to represent
1090;; this differently.
886c62d1 1091
a4414093 1092(define_insn "*pushsi2"
e075ae69 1093 [(set (match_operand:SI 0 "push_operand" "=<")
2c5a510c 1094 (match_operand:SI 1 "general_no_elim_operand" "ri*m"))]
0ec259ed 1095 "!TARGET_64BIT"
0f40f9f7 1096 "push{l}\t%1"
6ef67412
JH
1097 [(set_attr "type" "push")
1098 (set_attr "mode" "SI")])
4fb21e90 1099
0ec259ed
JH
1100;; For 64BIT abi we always round up to 8 bytes.
1101(define_insn "*pushsi2_rex64"
1102 [(set (match_operand:SI 0 "push_operand" "=X")
1103 (match_operand:SI 1 "nonmemory_no_elim_operand" "ri"))]
1104 "TARGET_64BIT"
0f40f9f7 1105 "push{q}\t%q1"
0ec259ed
JH
1106 [(set_attr "type" "push")
1107 (set_attr "mode" "SI")])
1108
bdeb029c
JH
1109(define_insn "*pushsi2_prologue"
1110 [(set (match_operand:SI 0 "push_operand" "=<")
1111 (match_operand:SI 1 "general_no_elim_operand" "ri*m"))
f2042df3 1112 (clobber (mem:BLK (scratch)))]
0ec259ed 1113 "!TARGET_64BIT"
0f40f9f7 1114 "push{l}\t%1"
6ef67412
JH
1115 [(set_attr "type" "push")
1116 (set_attr "mode" "SI")])
bdeb029c
JH
1117
1118(define_insn "*popsi1_epilogue"
1119 [(set (match_operand:SI 0 "nonimmediate_operand" "=r*m")
1120 (mem:SI (reg:SI 7)))
1121 (set (reg:SI 7)
1122 (plus:SI (reg:SI 7) (const_int 4)))
f2042df3 1123 (clobber (mem:BLK (scratch)))]
1e07edd3 1124 "!TARGET_64BIT"
0f40f9f7 1125 "pop{l}\t%0"
6ef67412
JH
1126 [(set_attr "type" "pop")
1127 (set_attr "mode" "SI")])
bdeb029c 1128
e075ae69
RH
1129(define_insn "popsi1"
1130 [(set (match_operand:SI 0 "nonimmediate_operand" "=r*m")
1131 (mem:SI (reg:SI 7)))
1132 (set (reg:SI 7)
1133 (plus:SI (reg:SI 7) (const_int 4)))]
1e07edd3 1134 "!TARGET_64BIT"
0f40f9f7 1135 "pop{l}\t%0"
6ef67412
JH
1136 [(set_attr "type" "pop")
1137 (set_attr "mode" "SI")])
c572e5ba 1138
a8bac9ab 1139(define_insn "*movsi_xor"
591702de
JH
1140 [(set (match_operand:SI 0 "register_operand" "=r")
1141 (match_operand:SI 1 "const0_operand" "i"))
e075ae69 1142 (clobber (reg:CC 17))]
591702de 1143 "reload_completed && (!TARGET_USE_MOV0 || optimize_size)"
0f40f9f7 1144 "xor{l}\t{%0, %0|%0, %0}"
591702de 1145 [(set_attr "type" "alu1")
6ef67412
JH
1146 (set_attr "mode" "SI")
1147 (set_attr "length_immediate" "0")])
591702de
JH
1148
1149(define_insn "*movsi_or"
1150 [(set (match_operand:SI 0 "register_operand" "=r")
1151 (match_operand:SI 1 "immediate_operand" "i"))
1152 (clobber (reg:CC 17))]
1153 "reload_completed && GET_CODE (operands[1]) == CONST_INT
1154 && INTVAL (operands[1]) == -1
1155 && (TARGET_PENTIUM || optimize_size)"
c572e5ba 1156{
591702de 1157 operands[1] = constm1_rtx;
0f40f9f7
ZW
1158 return "or{l}\t{%1, %0|%0, %1}";
1159}
591702de 1160 [(set_attr "type" "alu1")
6ef67412
JH
1161 (set_attr "mode" "SI")
1162 (set_attr "length_immediate" "1")])
e075ae69 1163
de80110b
JH
1164; The first alternative is used only to compute proper length of instruction.
1165; Reload's algorithm does not take into account the cost of spill instructions
1166; needed to free register in given class, so avoid it from choosing the first
1167; alternative when eax is not available.
1168
591702de 1169(define_insn "*movsi_1"
de80110b 1170 [(set (match_operand:SI 0 "nonimmediate_operand" "=*?a,r,*?a,m,!*y,!rm,!*y,!*Y,!rm,!*Y")
8f62128d
JH
1171 (match_operand:SI 1 "general_operand" "im,rinm,rinm,rin,*y,*y,rm,*Y,*Y,rm"))]
1172 "(TARGET_INTER_UNIT_MOVES || optimize_size)
1173 && (GET_CODE (operands[0]) != MEM || GET_CODE (operands[1]) != MEM)"
1174{
1175 switch (get_attr_type (insn))
1176 {
1177 case TYPE_SSEMOV:
1178 if (get_attr_mode (insn) == TImode)
1179 return "movdqa\t{%1, %0|%0, %1}";
1180 return "movd\t{%1, %0|%0, %1}";
1181
1182 case TYPE_MMXMOV:
1183 if (get_attr_mode (insn) == DImode)
1184 return "movq\t{%1, %0|%0, %1}";
1185 return "movd\t{%1, %0|%0, %1}";
1186
1187 case TYPE_LEA:
1188 return "lea{l}\t{%1, %0|%0, %1}";
1189
1190 default:
1191 if (flag_pic && !LEGITIMATE_PIC_OPERAND_P (operands[1]))
1192 abort();
1193 return "mov{l}\t{%1, %0|%0, %1}";
1194 }
1195}
1196 [(set (attr "type")
1197 (cond [(eq_attr "alternative" "4,5,6")
1198 (const_string "mmxmov")
1199 (eq_attr "alternative" "7,8,9")
1200 (const_string "ssemov")
1201 (and (ne (symbol_ref "flag_pic") (const_int 0))
1202 (match_operand:SI 1 "symbolic_operand" ""))
1203 (const_string "lea")
1204 ]
1205 (const_string "imov")))
1206 (set_attr "modrm" "0,*,0,*,*,*,*,*,*,*")
1207 (set_attr "mode" "SI,SI,SI,SI,DI,SI,SI,TI,SI,SI")])
1208
1209(define_insn "*movsi_1_nointernunit"
1210 [(set (match_operand:SI 0 "nonimmediate_operand" "=*?a,r,*?a,m,!*y,!m,!*y,!*Y,!m,!*Y")
1211 (match_operand:SI 1 "general_operand" "im,rinm,rinm,rin,*y,*y,m,*Y,*Y,m"))]
1212 "(!TARGET_INTER_UNIT_MOVES && !optimize_size)
1213 && (GET_CODE (operands[0]) != MEM || GET_CODE (operands[1]) != MEM)"
886c62d1 1214{
e075ae69 1215 switch (get_attr_type (insn))
886c62d1 1216 {
5f90a099 1217 case TYPE_SSEMOV:
371c988b 1218 if (get_attr_mode (insn) == TImode || which_alternative == 9)
0f40f9f7
ZW
1219 return "movdqa\t{%1, %0|%0, %1}";
1220 return "movd\t{%1, %0|%0, %1}";
141e454b 1221
5f90a099 1222 case TYPE_MMXMOV:
e5a20888
JJ
1223 if (get_attr_mode (insn) == DImode)
1224 return "movq\t{%1, %0|%0, %1}";
0f40f9f7 1225 return "movd\t{%1, %0|%0, %1}";
915119a5 1226
e075ae69 1227 case TYPE_LEA:
0f40f9f7 1228 return "lea{l}\t{%1, %0|%0, %1}";
915119a5 1229
e075ae69 1230 default:
57d47446 1231 if (flag_pic && !LEGITIMATE_PIC_OPERAND_P (operands[1]))
e075ae69 1232 abort();
0f40f9f7 1233 return "mov{l}\t{%1, %0|%0, %1}";
886c62d1 1234 }
0f40f9f7 1235}
e075ae69 1236 [(set (attr "type")
e5a20888 1237 (cond [(eq_attr "alternative" "4,5,6")
3d34cd91 1238 (const_string "mmxmov")
e5a20888 1239 (eq_attr "alternative" "7,8,9")
3d34cd91 1240 (const_string "ssemov")
915119a5 1241 (and (ne (symbol_ref "flag_pic") (const_int 0))
e075ae69
RH
1242 (match_operand:SI 1 "symbolic_operand" ""))
1243 (const_string "lea")
1244 ]
6ef67412 1245 (const_string "imov")))
e5a20888 1246 (set_attr "modrm" "0,*,0,*,*,*,*,*,*,*")
8f62128d 1247 (set_attr "mode" "SI,SI,SI,SI,DI,SI,SI,TI,SI,SI")])
e075ae69 1248
d1f87653 1249;; Stores and loads of ax to arbitrary constant address.
0ec259ed
JH
1250;; We fake an second form of instruction to force reload to load address
1251;; into register when rax is not available
1252(define_insn "*movabssi_1_rex64"
1253 [(set (mem:SI (match_operand:DI 0 "x86_64_movabs_operand" "i,r,r"))
1254 (match_operand:SI 1 "nonmemory_operand" "a,er,i"))]
1255 "TARGET_64BIT"
1256 "@
0f40f9f7
ZW
1257 movabs{l}\t{%1, %P0|%P0, %1}
1258 mov{l}\t{%1, %a0|%a0, %1}
1259 movabs{l}\t{%1, %a0|%a0, %1}"
0ec259ed
JH
1260 [(set_attr "type" "imov")
1261 (set_attr "modrm" "0,*,*")
1262 (set_attr "length_address" "8,0,0")
1263 (set_attr "length_immediate" "0,*,*")
1264 (set_attr "memory" "store")
1265 (set_attr "mode" "SI")])
1266
1267(define_insn "*movabssi_2_rex64"
1268 [(set (match_operand:SI 0 "register_operand" "=a,r")
1269 (mem:SI (match_operand:DI 1 "x86_64_movabs_operand" "i,r")))]
1270 "TARGET_64BIT"
1271 "@
0f40f9f7
ZW
1272 movabs{l}\t{%P1, %0|%0, %P1}
1273 mov{l}\t{%a1, %0|%0, %a1}"
0ec259ed
JH
1274 [(set_attr "type" "imov")
1275 (set_attr "modrm" "0,*")
1276 (set_attr "length_address" "8,0")
1277 (set_attr "length_immediate" "0")
1278 (set_attr "memory" "load")
1279 (set_attr "mode" "SI")])
1280
e075ae69
RH
1281(define_insn "*swapsi"
1282 [(set (match_operand:SI 0 "register_operand" "+r")
1283 (match_operand:SI 1 "register_operand" "+r"))
1284 (set (match_dup 1)
1285 (match_dup 0))]
2bb7a0f5 1286 ""
0f40f9f7 1287 "xchg{l}\t%1, %0"
e075ae69
RH
1288 [(set_attr "type" "imov")
1289 (set_attr "pent_pair" "np")
0b5107cf 1290 (set_attr "athlon_decode" "vector")
6ef67412
JH
1291 (set_attr "mode" "SI")
1292 (set_attr "modrm" "0")
e075ae69 1293 (set_attr "ppro_uops" "few")])
886c62d1 1294
e075ae69
RH
1295(define_expand "movhi"
1296 [(set (match_operand:HI 0 "nonimmediate_operand" "")
1297 (match_operand:HI 1 "general_operand" ""))]
ca097615 1298 ""
e075ae69 1299 "ix86_expand_move (HImode, operands); DONE;")
2f2a49e8 1300
a4414093 1301(define_insn "*pushhi2"
e075ae69 1302 [(set (match_operand:HI 0 "push_operand" "=<,<")
2c5a510c 1303 (match_operand:HI 1 "general_no_elim_operand" "n,r*m"))]
1e07edd3 1304 "!TARGET_64BIT"
e075ae69 1305 "@
0f40f9f7
ZW
1306 push{w}\t{|WORD PTR }%1
1307 push{w}\t%1"
6ef67412
JH
1308 [(set_attr "type" "push")
1309 (set_attr "mode" "HI")])
e075ae69 1310
b3298882
JH
1311;; For 64BIT abi we always round up to 8 bytes.
1312(define_insn "*pushhi2_rex64"
1313 [(set (match_operand:HI 0 "push_operand" "=X")
1314 (match_operand:HI 1 "nonmemory_no_elim_operand" "ri"))]
1315 "TARGET_64BIT"
0f40f9f7 1316 "push{q}\t%q1"
b3298882
JH
1317 [(set_attr "type" "push")
1318 (set_attr "mode" "QI")])
1319
de80110b
JH
1320; The first alternative is used only to compute proper length of instruction.
1321; Reload's algorithm does not take into account the cost of spill instructions
1322; needed to free register in given class, so avoid it from choosing the first
1323; alternative when eax is not available.
1324
e075ae69 1325(define_insn "*movhi_1"
de80110b 1326 [(set (match_operand:HI 0 "nonimmediate_operand" "=*?a,r,r,*?a,r,m")
6ef67412 1327 (match_operand:HI 1 "general_operand" "i,r,rn,rm,rm,rn"))]
e075ae69 1328 "GET_CODE (operands[0]) != MEM || GET_CODE (operands[1]) != MEM"
886c62d1 1329{
e075ae69 1330 switch (get_attr_type (insn))
886c62d1 1331 {
e075ae69
RH
1332 case TYPE_IMOVX:
1333 /* movzwl is faster than movw on p2 due to partial word stalls,
1334 though not as fast as an aligned movl. */
0f40f9f7 1335 return "movz{wl|x}\t{%1, %k0|%k0, %1}";
e075ae69 1336 default:
6ef67412 1337 if (get_attr_mode (insn) == MODE_SI)
0f40f9f7 1338 return "mov{l}\t{%k1, %k0|%k0, %k1}";
e075ae69 1339 else
0f40f9f7 1340 return "mov{w}\t{%1, %0|%0, %1}";
886c62d1 1341 }
0f40f9f7 1342}
e075ae69 1343 [(set (attr "type")
6ef67412 1344 (cond [(and (eq_attr "alternative" "0,1")
0b5107cf
JH
1345 (ior (eq (symbol_ref "TARGET_PARTIAL_REG_STALL")
1346 (const_int 0))
1347 (eq (symbol_ref "TARGET_HIMODE_MATH")
1348 (const_int 0))))
369e59b1 1349 (const_string "imov")
6ef67412 1350 (and (eq_attr "alternative" "2,3,4")
2247f6ed 1351 (match_operand:HI 1 "aligned_operand" ""))
e075ae69
RH
1352 (const_string "imov")
1353 (and (ne (symbol_ref "TARGET_MOVX")
1354 (const_int 0))
6ef67412 1355 (eq_attr "alternative" "0,1,3,4"))
e075ae69
RH
1356 (const_string "imovx")
1357 ]
1358 (const_string "imov")))
6ef67412 1359 (set (attr "mode")
e075ae69 1360 (cond [(eq_attr "type" "imovx")
6ef67412
JH
1361 (const_string "SI")
1362 (and (eq_attr "alternative" "2,3,4")
369e59b1 1363 (match_operand:HI 1 "aligned_operand" ""))
6ef67412
JH
1364 (const_string "SI")
1365 (and (eq_attr "alternative" "0,1")
0b5107cf
JH
1366 (ior (eq (symbol_ref "TARGET_PARTIAL_REG_STALL")
1367 (const_int 0))
1368 (eq (symbol_ref "TARGET_HIMODE_MATH")
1369 (const_int 0))))
6ef67412 1370 (const_string "SI")
e075ae69 1371 ]
6ef67412
JH
1372 (const_string "HI")))
1373 (set_attr "modrm" "0,*,*,0,*,*")])
e075ae69 1374
d1f87653 1375;; Stores and loads of ax to arbitrary constant address.
0ec259ed
JH
1376;; We fake an second form of instruction to force reload to load address
1377;; into register when rax is not available
1378(define_insn "*movabshi_1_rex64"
1379 [(set (mem:HI (match_operand:DI 0 "x86_64_movabs_operand" "i,r,r"))
1380 (match_operand:HI 1 "nonmemory_operand" "a,er,i"))]
1381 "TARGET_64BIT"
1382 "@
0f40f9f7
ZW
1383 movabs{w}\t{%1, %P0|%P0, %1}
1384 mov{w}\t{%1, %a0|%a0, %1}
1385 movabs{w}\t{%1, %a0|%a0, %1}"
0ec259ed
JH
1386 [(set_attr "type" "imov")
1387 (set_attr "modrm" "0,*,*")
1388 (set_attr "length_address" "8,0,0")
1389 (set_attr "length_immediate" "0,*,*")
1390 (set_attr "memory" "store")
1391 (set_attr "mode" "HI")])
1392
1393(define_insn "*movabshi_2_rex64"
1394 [(set (match_operand:HI 0 "register_operand" "=a,r")
1395 (mem:HI (match_operand:DI 1 "x86_64_movabs_operand" "i,r")))]
1396 "TARGET_64BIT"
1397 "@
0f40f9f7
ZW
1398 movabs{w}\t{%P1, %0|%0, %P1}
1399 mov{w}\t{%a1, %0|%0, %a1}"
0ec259ed
JH
1400 [(set_attr "type" "imov")
1401 (set_attr "modrm" "0,*")
1402 (set_attr "length_address" "8,0")
1403 (set_attr "length_immediate" "0")
1404 (set_attr "memory" "load")
1405 (set_attr "mode" "HI")])
1406
e075ae69
RH
1407(define_insn "*swaphi_1"
1408 [(set (match_operand:HI 0 "register_operand" "+r")
1409 (match_operand:HI 1 "register_operand" "+r"))
1410 (set (match_dup 1)
1411 (match_dup 0))]
1412 "TARGET_PARTIAL_REG_STALL"
0f40f9f7 1413 "xchg{w}\t%1, %0"
e075ae69
RH
1414 [(set_attr "type" "imov")
1415 (set_attr "pent_pair" "np")
6ef67412
JH
1416 (set_attr "mode" "HI")
1417 (set_attr "modrm" "0")
e075ae69
RH
1418 (set_attr "ppro_uops" "few")])
1419
1420(define_insn "*swaphi_2"
1421 [(set (match_operand:HI 0 "register_operand" "+r")
1422 (match_operand:HI 1 "register_operand" "+r"))
1423 (set (match_dup 1)
1424 (match_dup 0))]
1425 "! TARGET_PARTIAL_REG_STALL"
0f40f9f7 1426 "xchg{l}\t%k1, %k0"
e075ae69 1427 [(set_attr "type" "imov")
e075ae69 1428 (set_attr "pent_pair" "np")
6ef67412
JH
1429 (set_attr "mode" "SI")
1430 (set_attr "modrm" "0")
e075ae69 1431 (set_attr "ppro_uops" "few")])
886c62d1 1432
2f2a49e8 1433(define_expand "movstricthi"
e075ae69 1434 [(set (strict_low_part (match_operand:HI 0 "nonimmediate_operand" ""))
2f2a49e8 1435 (match_operand:HI 1 "general_operand" ""))]
b9b2c339 1436 "! TARGET_PARTIAL_REG_STALL || optimize_size"
2f2a49e8
MM
1437{
1438 /* Don't generate memory->memory moves, go through a register */
e075ae69
RH
1439 if (GET_CODE (operands[0]) == MEM && GET_CODE (operands[1]) == MEM)
1440 operands[1] = force_reg (HImode, operands[1]);
0f40f9f7 1441})
2f2a49e8 1442
e075ae69 1443(define_insn "*movstricthi_1"
fc524c1c 1444 [(set (strict_low_part (match_operand:HI 0 "nonimmediate_operand" "+rm,r"))
e075ae69 1445 (match_operand:HI 1 "general_operand" "rn,m"))]
b9b2c339 1446 "(! TARGET_PARTIAL_REG_STALL || optimize_size)
e075ae69 1447 && (GET_CODE (operands[0]) != MEM || GET_CODE (operands[1]) != MEM)"
0f40f9f7 1448 "mov{w}\t{%1, %0|%0, %1}"
6ef67412
JH
1449 [(set_attr "type" "imov")
1450 (set_attr "mode" "HI")])
1451
1452(define_insn "*movstricthi_xor"
208b0ab1 1453 [(set (strict_low_part (match_operand:HI 0 "register_operand" "+r"))
6ef67412
JH
1454 (match_operand:HI 1 "const0_operand" "i"))
1455 (clobber (reg:CC 17))]
b9b2c339
JH
1456 "reload_completed
1457 && ((!TARGET_USE_MOV0 && !TARGET_PARTIAL_REG_STALL) || optimize_size)"
0f40f9f7 1458 "xor{w}\t{%0, %0|%0, %0}"
6ef67412
JH
1459 [(set_attr "type" "alu1")
1460 (set_attr "mode" "HI")
1461 (set_attr "length_immediate" "0")])
886c62d1 1462
2f2a49e8 1463(define_expand "movqi"
4cbfbb1b 1464 [(set (match_operand:QI 0 "nonimmediate_operand" "")
2f2a49e8
MM
1465 (match_operand:QI 1 "general_operand" ""))]
1466 ""
e075ae69
RH
1467 "ix86_expand_move (QImode, operands); DONE;")
1468
7dd4b4a3
JH
1469;; emit_push_insn when it calls move_by_pieces requires an insn to
1470;; "push a byte". But actually we use pushw, which has the effect
1471;; of rounding the amount pushed up to a halfword.
1472
1473(define_insn "*pushqi2"
1474 [(set (match_operand:QI 0 "push_operand" "=X,X")
1475 (match_operand:QI 1 "nonmemory_no_elim_operand" "n,r"))]
1476 "!TARGET_64BIT"
1477 "@
0f40f9f7
ZW
1478 push{w}\t{|word ptr }%1
1479 push{w}\t%w1"
7dd4b4a3
JH
1480 [(set_attr "type" "push")
1481 (set_attr "mode" "HI")])
1482
b3298882
JH
1483;; For 64BIT abi we always round up to 8 bytes.
1484(define_insn "*pushqi2_rex64"
1485 [(set (match_operand:QI 0 "push_operand" "=X")
5f90a099 1486 (match_operand:QI 1 "nonmemory_no_elim_operand" "qi"))]
b3298882 1487 "TARGET_64BIT"
0f40f9f7 1488 "push{q}\t%q1"
b3298882
JH
1489 [(set_attr "type" "push")
1490 (set_attr "mode" "QI")])
1491
0b5107cf
JH
1492;; Situation is quite tricky about when to choose full sized (SImode) move
1493;; over QImode moves. For Q_REG -> Q_REG move we use full size only for
1494;; partial register dependency machines (such as AMD Athlon), where QImode
1495;; moves issue extra dependency and for partial register stalls machines
1496;; that don't use QImode patterns (and QImode move cause stall on the next
1497;; instruction).
1498;;
1499;; For loads of Q_REG to NONQ_REG we use full sized moves except for partial
1500;; register stall machines with, where we use QImode instructions, since
1501;; partial register stall can be caused there. Then we use movzx.
e075ae69 1502(define_insn "*movqi_1"
0b5107cf
JH
1503 [(set (match_operand:QI 0 "nonimmediate_operand" "=q,q ,q ,r,r ,?r,m")
1504 (match_operand:QI 1 "general_operand" " q,qn,qm,q,rn,qm,qn"))]
e075ae69 1505 "GET_CODE (operands[0]) != MEM || GET_CODE (operands[1]) != MEM"
886c62d1 1506{
e075ae69 1507 switch (get_attr_type (insn))
b76c90cf 1508 {
e075ae69 1509 case TYPE_IMOVX:
1a06f5fe 1510 if (!ANY_QI_REG_P (operands[1]) && GET_CODE (operands[1]) != MEM)
e075ae69 1511 abort ();
0f40f9f7 1512 return "movz{bl|x}\t{%1, %k0|%k0, %1}";
e075ae69 1513 default:
6ef67412 1514 if (get_attr_mode (insn) == MODE_SI)
0f40f9f7 1515 return "mov{l}\t{%k1, %k0|%k0, %k1}";
b76c90cf 1516 else
0f40f9f7 1517 return "mov{b}\t{%1, %0|%0, %1}";
b76c90cf 1518 }
0f40f9f7 1519}
e075ae69 1520 [(set (attr "type")
0b5107cf
JH
1521 (cond [(and (eq_attr "alternative" "3")
1522 (ior (eq (symbol_ref "TARGET_PARTIAL_REG_STALL")
1523 (const_int 0))
1524 (eq (symbol_ref "TARGET_QIMODE_MATH")
1525 (const_int 0))))
1526 (const_string "imov")
1527 (eq_attr "alternative" "3,5")
e075ae69
RH
1528 (const_string "imovx")
1529 (and (ne (symbol_ref "TARGET_MOVX")
1530 (const_int 0))
0b5107cf 1531 (eq_attr "alternative" "2"))
e075ae69
RH
1532 (const_string "imovx")
1533 ]
1534 (const_string "imov")))
6ef67412
JH
1535 (set (attr "mode")
1536 (cond [(eq_attr "alternative" "3,4,5")
1537 (const_string "SI")
1538 (eq_attr "alternative" "6")
1539 (const_string "QI")
1540 (eq_attr "type" "imovx")
1541 (const_string "SI")
0b5107cf 1542 (and (eq_attr "type" "imov")
6ef67412 1543 (and (eq_attr "alternative" "0,1,2")
0b5107cf
JH
1544 (ne (symbol_ref "TARGET_PARTIAL_REG_DEPENDENCY")
1545 (const_int 0))))
6ef67412 1546 (const_string "SI")
0b5107cf
JH
1547 ;; Avoid partial register stalls when not using QImode arithmetic
1548 (and (eq_attr "type" "imov")
6ef67412 1549 (and (eq_attr "alternative" "0,1,2")
0b5107cf
JH
1550 (and (ne (symbol_ref "TARGET_PARTIAL_REG_STALL")
1551 (const_int 0))
1552 (eq (symbol_ref "TARGET_QIMODE_MATH")
1553 (const_int 0)))))
6ef67412
JH
1554 (const_string "SI")
1555 ]
1556 (const_string "QI")))])
e075ae69
RH
1557
1558(define_expand "reload_outqi"
1559 [(parallel [(match_operand:QI 0 "" "=m")
1560 (match_operand:QI 1 "register_operand" "r")
1561 (match_operand:QI 2 "register_operand" "=&q")])]
1562 ""
e075ae69
RH
1563{
1564 rtx op0, op1, op2;
1565 op0 = operands[0]; op1 = operands[1]; op2 = operands[2];
886c62d1 1566
e075ae69
RH
1567 if (reg_overlap_mentioned_p (op2, op0))
1568 abort ();
1569 if (! q_regs_operand (op1, QImode))
1570 {
1571 emit_insn (gen_movqi (op2, op1));
1572 op1 = op2;
1573 }
1574 emit_insn (gen_movqi (op0, op1));
1575 DONE;
0f40f9f7 1576})
886c62d1 1577
e075ae69
RH
1578(define_insn "*swapqi"
1579 [(set (match_operand:QI 0 "register_operand" "+r")
1580 (match_operand:QI 1 "register_operand" "+r"))
1581 (set (match_dup 1)
1582 (match_dup 0))]
1583 ""
0f40f9f7 1584 "xchg{b}\t%1, %0"
e075ae69
RH
1585 [(set_attr "type" "imov")
1586 (set_attr "pent_pair" "np")
6ef67412
JH
1587 (set_attr "mode" "QI")
1588 (set_attr "modrm" "0")
e075ae69 1589 (set_attr "ppro_uops" "few")])
886c62d1 1590
2f2a49e8 1591(define_expand "movstrictqi"
4cbfbb1b 1592 [(set (strict_low_part (match_operand:QI 0 "nonimmediate_operand" ""))
2f2a49e8 1593 (match_operand:QI 1 "general_operand" ""))]
e075ae69 1594 "! TARGET_PARTIAL_REG_STALL"
2f2a49e8 1595{
e03f5d43 1596 /* Don't generate memory->memory moves, go through a register. */
e075ae69
RH
1597 if (GET_CODE (operands[0]) == MEM && GET_CODE (operands[1]) == MEM)
1598 operands[1] = force_reg (QImode, operands[1]);
0f40f9f7 1599})
2f2a49e8 1600
e075ae69 1601(define_insn "*movstrictqi_1"
2ae0f82c 1602 [(set (strict_low_part (match_operand:QI 0 "nonimmediate_operand" "+qm,q"))
c0f06344 1603 (match_operand:QI 1 "general_operand" "*qn,m"))]
e075ae69
RH
1604 "! TARGET_PARTIAL_REG_STALL
1605 && (GET_CODE (operands[0]) != MEM || GET_CODE (operands[1]) != MEM)"
0f40f9f7 1606 "mov{b}\t{%1, %0|%0, %1}"
6ef67412
JH
1607 [(set_attr "type" "imov")
1608 (set_attr "mode" "QI")])
1609
1610(define_insn "*movstrictqi_xor"
5e6d6bf0 1611 [(set (strict_low_part (match_operand:QI 0 "q_regs_operand" "+q"))
6ef67412
JH
1612 (match_operand:QI 1 "const0_operand" "i"))
1613 (clobber (reg:CC 17))]
1614 "reload_completed && (!TARGET_USE_MOV0 || optimize_size)"
0f40f9f7 1615 "xor{b}\t{%0, %0|%0, %0}"
6ef67412
JH
1616 [(set_attr "type" "alu1")
1617 (set_attr "mode" "QI")
1618 (set_attr "length_immediate" "0")])
e075ae69
RH
1619
1620(define_insn "*movsi_extv_1"
d2836273 1621 [(set (match_operand:SI 0 "register_operand" "=R")
3522082b 1622 (sign_extract:SI (match_operand 1 "ext_register_operand" "Q")
e075ae69
RH
1623 (const_int 8)
1624 (const_int 8)))]
1625 ""
0f40f9f7 1626 "movs{bl|x}\t{%h1, %0|%0, %h1}"
6ef67412
JH
1627 [(set_attr "type" "imovx")
1628 (set_attr "mode" "SI")])
e075ae69
RH
1629
1630(define_insn "*movhi_extv_1"
d2836273 1631 [(set (match_operand:HI 0 "register_operand" "=R")
3522082b 1632 (sign_extract:HI (match_operand 1 "ext_register_operand" "Q")
e075ae69
RH
1633 (const_int 8)
1634 (const_int 8)))]
1635 ""
0f40f9f7 1636 "movs{bl|x}\t{%h1, %k0|%k0, %h1}"
6ef67412
JH
1637 [(set_attr "type" "imovx")
1638 (set_attr "mode" "SI")])
e075ae69
RH
1639
1640(define_insn "*movqi_extv_1"
0ec259ed 1641 [(set (match_operand:QI 0 "nonimmediate_operand" "=Qm,?r")
3522082b 1642 (sign_extract:QI (match_operand 1 "ext_register_operand" "Q,Q")
e075ae69
RH
1643 (const_int 8)
1644 (const_int 8)))]
0ec259ed 1645 "!TARGET_64BIT"
886c62d1 1646{
e075ae69 1647 switch (get_attr_type (insn))
886c62d1 1648 {
e075ae69 1649 case TYPE_IMOVX:
0f40f9f7 1650 return "movs{bl|x}\t{%h1, %k0|%k0, %h1}";
e075ae69 1651 default:
0f40f9f7 1652 return "mov{b}\t{%h1, %0|%0, %h1}";
886c62d1 1653 }
0f40f9f7 1654}
e075ae69
RH
1655 [(set (attr "type")
1656 (if_then_else (and (match_operand:QI 0 "register_operand" "")
1657 (ior (not (match_operand:QI 0 "q_regs_operand" ""))
1658 (ne (symbol_ref "TARGET_MOVX")
1659 (const_int 0))))
1660 (const_string "imovx")
6ef67412
JH
1661 (const_string "imov")))
1662 (set (attr "mode")
1663 (if_then_else (eq_attr "type" "imovx")
1664 (const_string "SI")
1665 (const_string "QI")))])
e075ae69 1666
0ec259ed
JH
1667(define_insn "*movqi_extv_1_rex64"
1668 [(set (match_operand:QI 0 "register_operand" "=Q,?R")
3522082b 1669 (sign_extract:QI (match_operand 1 "ext_register_operand" "Q,Q")
0ec259ed
JH
1670 (const_int 8)
1671 (const_int 8)))]
1672 "TARGET_64BIT"
0ec259ed
JH
1673{
1674 switch (get_attr_type (insn))
1675 {
1676 case TYPE_IMOVX:
0f40f9f7 1677 return "movs{bl|x}\t{%h1, %k0|%k0, %h1}";
0ec259ed 1678 default:
0f40f9f7 1679 return "mov{b}\t{%h1, %0|%0, %h1}";
0ec259ed 1680 }
0f40f9f7 1681}
0ec259ed
JH
1682 [(set (attr "type")
1683 (if_then_else (and (match_operand:QI 0 "register_operand" "")
1684 (ior (not (match_operand:QI 0 "q_regs_operand" ""))
1685 (ne (symbol_ref "TARGET_MOVX")
1686 (const_int 0))))
1687 (const_string "imovx")
1688 (const_string "imov")))
1689 (set (attr "mode")
1690 (if_then_else (eq_attr "type" "imovx")
1691 (const_string "SI")
1692 (const_string "QI")))])
1693
d1f87653 1694;; Stores and loads of ax to arbitrary constant address.
0ec259ed
JH
1695;; We fake an second form of instruction to force reload to load address
1696;; into register when rax is not available
1697(define_insn "*movabsqi_1_rex64"
1698 [(set (mem:QI (match_operand:DI 0 "x86_64_movabs_operand" "i,r,r"))
1699 (match_operand:QI 1 "nonmemory_operand" "a,er,i"))]
1700 "TARGET_64BIT"
1701 "@
5e2ce672
JH
1702 movabs{b}\t{%1, %P0|%P0, %1}
1703 mov{b}\t{%1, %a0|%a0, %1}
1704 movabs{b}\t{%1, %a0|%a0, %1}"
0ec259ed
JH
1705 [(set_attr "type" "imov")
1706 (set_attr "modrm" "0,*,*")
1707 (set_attr "length_address" "8,0,0")
1708 (set_attr "length_immediate" "0,*,*")
1709 (set_attr "memory" "store")
1710 (set_attr "mode" "QI")])
1711
1712(define_insn "*movabsqi_2_rex64"
1713 [(set (match_operand:QI 0 "register_operand" "=a,r")
1714 (mem:QI (match_operand:DI 1 "x86_64_movabs_operand" "i,r")))]
1715 "TARGET_64BIT"
1716 "@
5e2ce672
JH
1717 movabs{b}\t{%P1, %0|%0, %P1}
1718 mov{b}\t{%a1, %0|%0, %a1}"
0ec259ed
JH
1719 [(set_attr "type" "imov")
1720 (set_attr "modrm" "0,*")
1721 (set_attr "length_address" "8,0")
1722 (set_attr "length_immediate" "0")
1723 (set_attr "memory" "load")
1724 (set_attr "mode" "QI")])
1725
e075ae69 1726(define_insn "*movsi_extzv_1"
d2836273
JH
1727 [(set (match_operand:SI 0 "register_operand" "=R")
1728 (zero_extract:SI (match_operand 1 "ext_register_operand" "Q")
e075ae69
RH
1729 (const_int 8)
1730 (const_int 8)))]
1731 ""
0f40f9f7 1732 "movz{bl|x}\t{%h1, %0|%0, %h1}"
6ef67412
JH
1733 [(set_attr "type" "imovx")
1734 (set_attr "mode" "SI")])
886c62d1 1735
d2836273
JH
1736(define_insn "*movqi_extzv_2"
1737 [(set (match_operand:QI 0 "nonimmediate_operand" "=Qm,?R")
1738 (subreg:QI (zero_extract:SI (match_operand 1 "ext_register_operand" "Q,Q")
e075ae69
RH
1739 (const_int 8)
1740 (const_int 8)) 0))]
d2836273 1741 "!TARGET_64BIT"
f31fce3f 1742{
e075ae69 1743 switch (get_attr_type (insn))
f31fce3f 1744 {
e075ae69 1745 case TYPE_IMOVX:
0f40f9f7 1746 return "movz{bl|x}\t{%h1, %k0|%k0, %h1}";
e075ae69 1747 default:
0f40f9f7 1748 return "mov{b}\t{%h1, %0|%0, %h1}";
e075ae69 1749 }
0f40f9f7 1750}
e075ae69
RH
1751 [(set (attr "type")
1752 (if_then_else (and (match_operand:QI 0 "register_operand" "")
1753 (ior (not (match_operand:QI 0 "q_regs_operand" ""))
1754 (ne (symbol_ref "TARGET_MOVX")
1755 (const_int 0))))
1756 (const_string "imovx")
6ef67412
JH
1757 (const_string "imov")))
1758 (set (attr "mode")
1759 (if_then_else (eq_attr "type" "imovx")
1760 (const_string "SI")
1761 (const_string "QI")))])
e075ae69 1762
d2836273
JH
1763(define_insn "*movqi_extzv_2_rex64"
1764 [(set (match_operand:QI 0 "register_operand" "=Q,?R")
1765 (subreg:QI (zero_extract:SI (match_operand 1 "ext_register_operand" "Q,Q")
1766 (const_int 8)
1767 (const_int 8)) 0))]
1768 "TARGET_64BIT"
d2836273
JH
1769{
1770 switch (get_attr_type (insn))
1771 {
1772 case TYPE_IMOVX:
0f40f9f7 1773 return "movz{bl|x}\t{%h1, %k0|%k0, %h1}";
d2836273 1774 default:
0f40f9f7 1775 return "mov{b}\t{%h1, %0|%0, %h1}";
d2836273 1776 }
0f40f9f7 1777}
d2836273
JH
1778 [(set (attr "type")
1779 (if_then_else (ior (not (match_operand:QI 0 "q_regs_operand" ""))
1780 (ne (symbol_ref "TARGET_MOVX")
1781 (const_int 0)))
1782 (const_string "imovx")
1783 (const_string "imov")))
1784 (set (attr "mode")
1785 (if_then_else (eq_attr "type" "imovx")
1786 (const_string "SI")
1787 (const_string "QI")))])
1788
7a2e09f4 1789(define_insn "movsi_insv_1"
d2836273 1790 [(set (zero_extract:SI (match_operand 0 "ext_register_operand" "+Q")
e075ae69
RH
1791 (const_int 8)
1792 (const_int 8))
f47c8646 1793 (match_operand:SI 1 "general_operand" "Qmn"))]
d2836273 1794 "!TARGET_64BIT"
0f40f9f7 1795 "mov{b}\t{%b1, %h0|%h0, %b1}"
d2836273
JH
1796 [(set_attr "type" "imov")
1797 (set_attr "mode" "QI")])
1798
1799(define_insn "*movsi_insv_1_rex64"
1800 [(set (zero_extract:SI (match_operand 0 "ext_register_operand" "+Q")
1801 (const_int 8)
1802 (const_int 8))
f47c8646 1803 (match_operand:SI 1 "nonmemory_operand" "Qn"))]
d2836273 1804 "TARGET_64BIT"
0f40f9f7 1805 "mov{b}\t{%b1, %h0|%h0, %b1}"
6ef67412
JH
1806 [(set_attr "type" "imov")
1807 (set_attr "mode" "QI")])
e075ae69
RH
1808
1809(define_insn "*movqi_insv_2"
d2836273 1810 [(set (zero_extract:SI (match_operand 0 "ext_register_operand" "+Q")
e075ae69
RH
1811 (const_int 8)
1812 (const_int 8))
3522082b 1813 (and:SI (lshiftrt:SI (match_operand:SI 1 "register_operand" "Q")
e075ae69
RH
1814 (const_int 8))
1815 (const_int 255)))]
1816 ""
0f40f9f7 1817 "mov{b}\t{%h1, %h0|%h0, %h1}"
6ef67412
JH
1818 [(set_attr "type" "imov")
1819 (set_attr "mode" "QI")])
f31fce3f 1820
e075ae69 1821(define_expand "movdi"
4cbfbb1b 1822 [(set (match_operand:DI 0 "nonimmediate_operand" "")
e075ae69
RH
1823 (match_operand:DI 1 "general_operand" ""))]
1824 ""
1825 "ix86_expand_move (DImode, operands); DONE;")
f31fce3f 1826
e075ae69
RH
1827(define_insn "*pushdi"
1828 [(set (match_operand:DI 0 "push_operand" "=<")
2c5a510c 1829 (match_operand:DI 1 "general_no_elim_operand" "riF*m"))]
1e07edd3 1830 "!TARGET_64BIT"
e075ae69 1831 "#")
f31fce3f 1832
0ec259ed
JH
1833(define_insn "pushdi2_rex64"
1834 [(set (match_operand:DI 0 "push_operand" "=<,!<")
1835 (match_operand:DI 1 "general_no_elim_operand" "re*m,n"))]
1836 "TARGET_64BIT"
1837 "@
0f40f9f7 1838 push{q}\t%1
0ec259ed
JH
1839 #"
1840 [(set_attr "type" "push,multi")
1841 (set_attr "mode" "DI")])
1842
1843;; Convert impossible pushes of immediate to existing instructions.
f5143c46 1844;; First try to get scratch register and go through it. In case this
0ec259ed
JH
1845;; fails, push sign extended lower part first and then overwrite
1846;; upper part by 32bit move.
1847(define_peephole2
1848 [(match_scratch:DI 2 "r")
1849 (set (match_operand:DI 0 "push_operand" "")
1850 (match_operand:DI 1 "immediate_operand" ""))]
1851 "TARGET_64BIT && !symbolic_operand (operands[1], DImode)
1852 && !x86_64_immediate_operand (operands[1], DImode)"
1853 [(set (match_dup 2) (match_dup 1))
1854 (set (match_dup 0) (match_dup 2))]
1855 "")
1856
1857;; We need to define this as both peepholer and splitter for case
1858;; peephole2 pass is not run.
1859(define_peephole2
1860 [(set (match_operand:DI 0 "push_operand" "")
1861 (match_operand:DI 1 "immediate_operand" ""))]
1862 "TARGET_64BIT && !symbolic_operand (operands[1], DImode)
1863 && !x86_64_immediate_operand (operands[1], DImode) && 1"
1864 [(set (match_dup 0) (match_dup 1))
1865 (set (match_dup 2) (match_dup 3))]
1866 "split_di (operands + 1, 1, operands + 2, operands + 3);
1867 operands[1] = gen_lowpart (DImode, operands[2]);
1868 operands[2] = gen_rtx_MEM (SImode, gen_rtx_PLUS (DImode, stack_pointer_rtx,
1869 GEN_INT (4)));
1870 ")
1871
1872(define_split
1873 [(set (match_operand:DI 0 "push_operand" "")
1874 (match_operand:DI 1 "immediate_operand" ""))]
1875 "TARGET_64BIT && (flow2_completed || (reload_completed && !flag_peephole2))
1876 && !symbolic_operand (operands[1], DImode)
1877 && !x86_64_immediate_operand (operands[1], DImode)"
1878 [(set (match_dup 0) (match_dup 1))
1879 (set (match_dup 2) (match_dup 3))]
1880 "split_di (operands + 1, 1, operands + 2, operands + 3);
1881 operands[1] = gen_lowpart (DImode, operands[2]);
1882 operands[2] = gen_rtx_MEM (SImode, gen_rtx_PLUS (DImode, stack_pointer_rtx,
1883 GEN_INT (4)));
1884 ")
1885
1886(define_insn "*pushdi2_prologue_rex64"
1887 [(set (match_operand:DI 0 "push_operand" "=<")
1888 (match_operand:DI 1 "general_no_elim_operand" "re*m"))
f2042df3 1889 (clobber (mem:BLK (scratch)))]
0ec259ed 1890 "TARGET_64BIT"
0f40f9f7 1891 "push{q}\t%1"
0ec259ed
JH
1892 [(set_attr "type" "push")
1893 (set_attr "mode" "DI")])
1894
1895(define_insn "*popdi1_epilogue_rex64"
1896 [(set (match_operand:DI 0 "nonimmediate_operand" "=r*m")
1897 (mem:DI (reg:DI 7)))
1898 (set (reg:DI 7)
1899 (plus:DI (reg:DI 7) (const_int 8)))
f2042df3 1900 (clobber (mem:BLK (scratch)))]
0ec259ed 1901 "TARGET_64BIT"
0f40f9f7 1902 "pop{q}\t%0"
0ec259ed
JH
1903 [(set_attr "type" "pop")
1904 (set_attr "mode" "DI")])
1905
1906(define_insn "popdi1"
1907 [(set (match_operand:DI 0 "nonimmediate_operand" "=r*m")
1908 (mem:DI (reg:DI 7)))
1909 (set (reg:DI 7)
1910 (plus:DI (reg:DI 7) (const_int 8)))]
1911 "TARGET_64BIT"
0f40f9f7 1912 "pop{q}\t%0"
0ec259ed
JH
1913 [(set_attr "type" "pop")
1914 (set_attr "mode" "DI")])
1915
1916(define_insn "*movdi_xor_rex64"
1917 [(set (match_operand:DI 0 "register_operand" "=r")
1918 (match_operand:DI 1 "const0_operand" "i"))
1919 (clobber (reg:CC 17))]
1b0c37d7
ZW
1920 "TARGET_64BIT && (!TARGET_USE_MOV0 || optimize_size)
1921 && reload_completed"
0f40f9f7 1922 "xor{l}\t{%k0, %k0|%k0, %k0}"
0ec259ed
JH
1923 [(set_attr "type" "alu1")
1924 (set_attr "mode" "SI")
1925 (set_attr "length_immediate" "0")])
1926
1927(define_insn "*movdi_or_rex64"
1928 [(set (match_operand:DI 0 "register_operand" "=r")
1929 (match_operand:DI 1 "const_int_operand" "i"))
1930 (clobber (reg:CC 17))]
1b0c37d7
ZW
1931 "TARGET_64BIT && (TARGET_PENTIUM || optimize_size)
1932 && reload_completed
1933 && GET_CODE (operands[1]) == CONST_INT
1934 && INTVAL (operands[1]) == -1"
0ec259ed
JH
1935{
1936 operands[1] = constm1_rtx;
0f40f9f7
ZW
1937 return "or{q}\t{%1, %0|%0, %1}";
1938}
0ec259ed
JH
1939 [(set_attr "type" "alu1")
1940 (set_attr "mode" "DI")
1941 (set_attr "length_immediate" "1")])
1942
e075ae69 1943(define_insn "*movdi_2"
749e7b80 1944 [(set (match_operand:DI 0 "nonimmediate_operand" "=r,o,!m*y,!*y,!m,!*Y,!*Y")
141e454b 1945 (match_operand:DI 1 "general_operand" "riFo,riF,*y,m,*Y,*Y,m"))]
1e07edd3
JH
1946 "!TARGET_64BIT
1947 && (GET_CODE (operands[0]) != MEM || GET_CODE (operands[1]) != MEM)"
915119a5
BS
1948 "@
1949 #
1950 #
0f40f9f7
ZW
1951 movq\t{%1, %0|%0, %1}
1952 movq\t{%1, %0|%0, %1}
1953 movq\t{%1, %0|%0, %1}
1954 movdqa\t{%1, %0|%0, %1}
1955 movq\t{%1, %0|%0, %1}"
3d34cd91 1956 [(set_attr "type" "*,*,mmx,mmx,ssemov,ssemov,ssemov")
141e454b 1957 (set_attr "mode" "DI,DI,DI,DI,DI,TI,DI")])
dc0f0eb8 1958
e075ae69
RH
1959(define_split
1960 [(set (match_operand:DI 0 "push_operand" "")
1961 (match_operand:DI 1 "general_operand" ""))]
6c12e488
JH
1962 "!TARGET_64BIT && reload_completed
1963 && (! MMX_REG_P (operands[1]) && !SSE_REG_P (operands[1]))"
2450a057 1964 [(const_int 0)]
26e5b205 1965 "ix86_split_long_move (operands); DONE;")
f31fce3f 1966
e075ae69 1967;; %%% This multiword shite has got to go.
e075ae69 1968(define_split
c76aab11 1969 [(set (match_operand:DI 0 "nonimmediate_operand" "")
e075ae69 1970 (match_operand:DI 1 "general_operand" ""))]
6c12e488
JH
1971 "!TARGET_64BIT && reload_completed
1972 && (!MMX_REG_P (operands[0]) && !SSE_REG_P (operands[0]))
1973 && (!MMX_REG_P (operands[1]) && !SSE_REG_P (operands[1]))"
26e5b205
JH
1974 [(const_int 0)]
1975 "ix86_split_long_move (operands); DONE;")
0ec259ed
JH
1976
1977(define_insn "*movdi_1_rex64"
8f62128d
JH
1978 [(set (match_operand:DI 0 "nonimmediate_operand" "=r,r,r,mr,!mr,!*y,!rm,!*y,!*Y,!rm,!*Y")
1979 (match_operand:DI 1 "general_operand" "Z,rem,i,re,n,*y,*y,rm,*Y,*Y,rm"))]
1b0c37d7 1980 "TARGET_64BIT
8f62128d 1981 && (TARGET_INTER_UNIT_MOVES || optimize_size)
1b0c37d7 1982 && (GET_CODE (operands[0]) != MEM || GET_CODE (operands[1]) != MEM)"
0ec259ed
JH
1983{
1984 switch (get_attr_type (insn))
1985 {
5f90a099 1986 case TYPE_SSEMOV:
8f62128d 1987 if (get_attr_mode (insn) == MODE_TI)
0f40f9f7 1988 return "movdqa\t{%1, %0|%0, %1}";
5ccbcd8c
JH
1989 /* FALLTHRU */
1990 case TYPE_MMXMOV:
8f62128d
JH
1991 /* Moves from and into integer register is done using movd opcode with
1992 REX prefix. */
1993 if (GENERAL_REG_P (operands[0]) || GENERAL_REG_P (operands[1]))
1994 return "movd\t{%1, %0|%0, %1}";
0f40f9f7 1995 return "movq\t{%1, %0|%0, %1}";
0ec259ed 1996 case TYPE_MULTI:
0f40f9f7 1997 return "#";
0ec259ed 1998 case TYPE_LEA:
0f40f9f7 1999 return "lea{q}\t{%a1, %0|%0, %a1}";
0ec259ed 2000 default:
57d47446 2001 if (flag_pic && !LEGITIMATE_PIC_OPERAND_P (operands[1]))
0ec259ed
JH
2002 abort ();
2003 if (get_attr_mode (insn) == MODE_SI)
0f40f9f7 2004 return "mov{l}\t{%k1, %k0|%k0, %k1}";
0ec259ed 2005 else if (which_alternative == 2)
0f40f9f7 2006 return "movabs{q}\t{%1, %0|%0, %1}";
0ec259ed 2007 else
0f40f9f7 2008 return "mov{q}\t{%1, %0|%0, %1}";
0ec259ed 2009 }
0f40f9f7 2010}
0ec259ed 2011 [(set (attr "type")
8f62128d 2012 (cond [(eq_attr "alternative" "5,6,7")
3d34cd91 2013 (const_string "mmxmov")
8f62128d 2014 (eq_attr "alternative" "8,9,10")
3d34cd91 2015 (const_string "ssemov")
0ec259ed
JH
2016 (eq_attr "alternative" "4")
2017 (const_string "multi")
2018 (and (ne (symbol_ref "flag_pic") (const_int 0))
2019 (match_operand:DI 1 "symbolic_operand" ""))
2020 (const_string "lea")
2021 ]
2022 (const_string "imov")))
8f62128d
JH
2023 (set_attr "modrm" "*,0,0,*,*,*,*,*,*,*,*")
2024 (set_attr "length_immediate" "*,4,8,*,*,*,*,*,*,*,*")
2025 (set_attr "mode" "SI,DI,DI,DI,SI,DI,DI,DI,TI,DI,DI")])
2026
2027(define_insn "*movdi_1_rex64_nointerunit"
2028 [(set (match_operand:DI 0 "nonimmediate_operand" "=r,r,r,mr,!mr,!*y,!m,!*y,!*Y,!m,!*Y")
2029 (match_operand:DI 1 "general_operand" "Z,rem,i,re,n,*y,*y,m,*Y,*Y,m"))]
2030 "TARGET_64BIT
2031 && (!TARGET_INTER_UNIT_MOVES && !optimize_size)
2032 && (GET_CODE (operands[0]) != MEM || GET_CODE (operands[1]) != MEM)"
2033{
2034 switch (get_attr_type (insn))
2035 {
2036 case TYPE_SSEMOV:
2037 if (get_attr_mode (insn) == MODE_TI)
2038 return "movdqa\t{%1, %0|%0, %1}";
2039 /* FALLTHRU */
2040 case TYPE_MMXMOV:
2041 return "movq\t{%1, %0|%0, %1}";
2042 case TYPE_MULTI:
2043 return "#";
2044 case TYPE_LEA:
2045 return "lea{q}\t{%a1, %0|%0, %a1}";
2046 default:
2047 if (flag_pic && !LEGITIMATE_PIC_OPERAND_P (operands[1]))
2048 abort ();
2049 if (get_attr_mode (insn) == MODE_SI)
2050 return "mov{l}\t{%k1, %k0|%k0, %k1}";
2051 else if (which_alternative == 2)
2052 return "movabs{q}\t{%1, %0|%0, %1}";
2053 else
2054 return "mov{q}\t{%1, %0|%0, %1}";
2055 }
2056}
2057 [(set (attr "type")
2058 (cond [(eq_attr "alternative" "5,6,7")
2059 (const_string "mmxmov")
2060 (eq_attr "alternative" "8,9,10")
2061 (const_string "ssemov")
2062 (eq_attr "alternative" "4")
2063 (const_string "multi")
2064 (and (ne (symbol_ref "flag_pic") (const_int 0))
2065 (match_operand:DI 1 "symbolic_operand" ""))
2066 (const_string "lea")
2067 ]
2068 (const_string "imov")))
2069 (set_attr "modrm" "*,0,0,*,*,*,*,*,*,*,*")
2070 (set_attr "length_immediate" "*,4,8,*,*,*,*,*,*,*,*")
2071 (set_attr "mode" "SI,DI,DI,DI,SI,DI,DI,DI,TI,DI,DI")])
0ec259ed 2072
d1f87653 2073;; Stores and loads of ax to arbitrary constant address.
0ec259ed
JH
2074;; We fake an second form of instruction to force reload to load address
2075;; into register when rax is not available
2076(define_insn "*movabsdi_1_rex64"
2077 [(set (mem:DI (match_operand:DI 0 "x86_64_movabs_operand" "i,r,r"))
2078 (match_operand:DI 1 "nonmemory_operand" "a,er,i"))]
2079 "TARGET_64BIT"
2080 "@
0f40f9f7
ZW
2081 movabs{q}\t{%1, %P0|%P0, %1}
2082 mov{q}\t{%1, %a0|%a0, %1}
2083 movabs{q}\t{%1, %a0|%a0, %1}"
0ec259ed
JH
2084 [(set_attr "type" "imov")
2085 (set_attr "modrm" "0,*,*")
2086 (set_attr "length_address" "8,0,0")
2087 (set_attr "length_immediate" "0,*,*")
2088 (set_attr "memory" "store")
2089 (set_attr "mode" "DI")])
2090
2091(define_insn "*movabsdi_2_rex64"
2092 [(set (match_operand:DI 0 "register_operand" "=a,r")
2093 (mem:DI (match_operand:DI 1 "x86_64_movabs_operand" "i,r")))]
2094 "TARGET_64BIT"
2095 "@
0f40f9f7
ZW
2096 movabs{q}\t{%P1, %0|%0, %P1}
2097 mov{q}\t{%a1, %0|%0, %a1}"
0ec259ed
JH
2098 [(set_attr "type" "imov")
2099 (set_attr "modrm" "0,*")
2100 (set_attr "length_address" "8,0")
2101 (set_attr "length_immediate" "0")
2102 (set_attr "memory" "load")
2103 (set_attr "mode" "DI")])
2104
2105;; Convert impossible stores of immediate to existing instructions.
f5143c46 2106;; First try to get scratch register and go through it. In case this
0ec259ed
JH
2107;; fails, move by 32bit parts.
2108(define_peephole2
2109 [(match_scratch:DI 2 "r")
2110 (set (match_operand:DI 0 "memory_operand" "")
2111 (match_operand:DI 1 "immediate_operand" ""))]
2112 "TARGET_64BIT && !symbolic_operand (operands[1], DImode)
2113 && !x86_64_immediate_operand (operands[1], DImode)"
2114 [(set (match_dup 2) (match_dup 1))
2115 (set (match_dup 0) (match_dup 2))]
2116 "")
2117
2118;; We need to define this as both peepholer and splitter for case
2119;; peephole2 pass is not run.
2120(define_peephole2
2121 [(set (match_operand:DI 0 "memory_operand" "")
2122 (match_operand:DI 1 "immediate_operand" ""))]
2123 "TARGET_64BIT && !symbolic_operand (operands[1], DImode)
2124 && !x86_64_immediate_operand (operands[1], DImode) && 1"
2125 [(set (match_dup 2) (match_dup 3))
2126 (set (match_dup 4) (match_dup 5))]
2127 "split_di (operands, 2, operands + 2, operands + 4);")
2128
2129(define_split
2130 [(set (match_operand:DI 0 "memory_operand" "")
2131 (match_operand:DI 1 "immediate_operand" ""))]
2132 "TARGET_64BIT && (flow2_completed || (reload_completed && !flag_peephole2))
2133 && !symbolic_operand (operands[1], DImode)
2134 && !x86_64_immediate_operand (operands[1], DImode)"
2135 [(set (match_dup 2) (match_dup 3))
2136 (set (match_dup 4) (match_dup 5))]
2137 "split_di (operands, 2, operands + 2, operands + 4);")
2138
2139(define_insn "*swapdi_rex64"
2140 [(set (match_operand:DI 0 "register_operand" "+r")
2141 (match_operand:DI 1 "register_operand" "+r"))
2142 (set (match_dup 1)
2143 (match_dup 0))]
2144 "TARGET_64BIT"
0f40f9f7 2145 "xchg{q}\t%1, %0"
0ec259ed
JH
2146 [(set_attr "type" "imov")
2147 (set_attr "pent_pair" "np")
2148 (set_attr "athlon_decode" "vector")
2149 (set_attr "mode" "DI")
2150 (set_attr "modrm" "0")
2151 (set_attr "ppro_uops" "few")])
2152
e075ae69 2153
0be5d99f 2154(define_expand "movsf"
4cbfbb1b 2155 [(set (match_operand:SF 0 "nonimmediate_operand" "")
0be5d99f
MM
2156 (match_operand:SF 1 "general_operand" ""))]
2157 ""
e075ae69
RH
2158 "ix86_expand_move (SFmode, operands); DONE;")
2159
2160(define_insn "*pushsf"
446988df 2161 [(set (match_operand:SF 0 "push_operand" "=<,<,<")
c6e95f34 2162 (match_operand:SF 1 "general_no_elim_operand" "f#rx,rFm#fx,x#rf"))]
0ec259ed 2163 "!TARGET_64BIT"
0be5d99f 2164{
e075ae69 2165 switch (which_alternative)
0be5d99f 2166 {
e075ae69 2167 case 1:
0f40f9f7 2168 return "push{l}\t%1";
e075ae69
RH
2169
2170 default:
4977bab6 2171 /* This insn should be already splitted before reg-stack. */
e075ae69 2172 abort ();
0bb6c81b 2173 }
0f40f9f7 2174}
446988df
JH
2175 [(set_attr "type" "multi,push,multi")
2176 (set_attr "mode" "SF,SI,SF")])
0be5d99f 2177
0ec259ed
JH
2178(define_insn "*pushsf_rex64"
2179 [(set (match_operand:SF 0 "push_operand" "=X,X,X")
2180 (match_operand:SF 1 "nonmemory_no_elim_operand" "f#rx,rF#fx,x#rf"))]
2181 "TARGET_64BIT"
0ec259ed
JH
2182{
2183 switch (which_alternative)
2184 {
0ec259ed 2185 case 1:
0f40f9f7 2186 return "push{q}\t%q1";
0ec259ed 2187
0ec259ed 2188 default:
4977bab6 2189 /* This insn should be already splitted before reg-stack. */
0ec259ed
JH
2190 abort ();
2191 }
0f40f9f7 2192}
0ec259ed
JH
2193 [(set_attr "type" "multi,push,multi")
2194 (set_attr "mode" "SF,DI,SF")])
2195
d7a29404
JH
2196(define_split
2197 [(set (match_operand:SF 0 "push_operand" "")
2198 (match_operand:SF 1 "memory_operand" ""))]
2199 "reload_completed
2200 && GET_CODE (operands[1]) == MEM
2201 && GET_CODE (XEXP (operands[1], 0)) == SYMBOL_REF
2202 && CONSTANT_POOL_ADDRESS_P (XEXP (operands[1], 0))"
2203 [(set (match_dup 0)
2204 (match_dup 1))]
2205 "operands[1] = get_pool_constant (XEXP (operands[1], 0));")
2206
2207
e075ae69
RH
2208;; %%% Kill this when call knows how to work this out.
2209(define_split
2210 [(set (match_operand:SF 0 "push_operand" "")
c3c637e3
GS
2211 (match_operand:SF 1 "any_fp_register_operand" ""))]
2212 "!TARGET_64BIT"
e075ae69
RH
2213 [(set (reg:SI 7) (plus:SI (reg:SI 7) (const_int -4)))
2214 (set (mem:SF (reg:SI 7)) (match_dup 1))])
2215
0ec259ed
JH
2216(define_split
2217 [(set (match_operand:SF 0 "push_operand" "")
c3c637e3
GS
2218 (match_operand:SF 1 "any_fp_register_operand" ""))]
2219 "TARGET_64BIT"
0ec259ed
JH
2220 [(set (reg:DI 7) (plus:DI (reg:DI 7) (const_int -8)))
2221 (set (mem:SF (reg:DI 7)) (match_dup 1))])
2222
e075ae69 2223(define_insn "*movsf_1"
e5a20888 2224 [(set (match_operand:SF 0 "nonimmediate_operand" "=f#xr,m,f#xr,r#xf,m,x#rf,x#rf,x#rf,m,!*y,!rm,!*y")
f8ca7923 2225 (match_operand:SF 1 "general_operand" "fm#rx,f#rx,G,rmF#fx,Fr#fx,C,x,xm#rf,x#rf,rm,*y,*y"))]
8f62128d
JH
2226 "(TARGET_INTER_UNIT_MOVES || optimize_size)
2227 && (GET_CODE (operands[0]) != MEM || GET_CODE (operands[1]) != MEM)
2228 && (reload_in_progress || reload_completed
2229 || (ix86_cmodel == CM_MEDIUM || ix86_cmodel == CM_LARGE)
2230 || GET_CODE (operands[1]) != CONST_DOUBLE
2231 || memory_operand (operands[0], SFmode))"
2232{
2233 switch (which_alternative)
2234 {
2235 case 0:
2236 if (REG_P (operands[1])
2237 && find_regno_note (insn, REG_DEAD, REGNO (operands[1])))
2238 return "fstp\t%y0";
2239 else if (STACK_TOP_P (operands[0]))
2240 return "fld%z1\t%y1";
2241 else
2242 return "fst\t%y0";
2243
2244 case 1:
2245 if (find_regno_note (insn, REG_DEAD, REGNO (operands[1])))
2246 return "fstp%z0\t%y0";
2247 else
2248 return "fst%z0\t%y0";
2249
2250 case 2:
881b2a96 2251 return standard_80387_constant_opcode (operands[1]);
8f62128d
JH
2252
2253 case 3:
2254 case 4:
2255 return "mov{l}\t{%1, %0|%0, %1}";
2256 case 5:
2257 if (get_attr_mode (insn) == MODE_TI)
2258 return "pxor\t%0, %0";
2259 else
2260 return "xorps\t%0, %0";
2261 case 6:
2262 if (get_attr_mode (insn) == MODE_V4SF)
2263 return "movaps\t{%1, %0|%0, %1}";
2264 else
2265 return "movss\t{%1, %0|%0, %1}";
2266 case 7:
2267 case 8:
2268 return "movss\t{%1, %0|%0, %1}";
2269
2270 case 9:
2271 case 10:
2272 return "movd\t{%1, %0|%0, %1}";
2273
2274 case 11:
2275 return "movq\t{%1, %0|%0, %1}";
2276
2277 default:
2278 abort();
2279 }
2280}
2281 [(set_attr "type" "fmov,fmov,fmov,imov,imov,ssemov,ssemov,ssemov,ssemov,mmxmov,mmxmov,mmxmov")
2282 (set (attr "mode")
2283 (cond [(eq_attr "alternative" "3,4,9,10")
2284 (const_string "SI")
2285 (eq_attr "alternative" "5")
2286 (if_then_else
2287 (and (and (ne (symbol_ref "TARGET_SSE_LOAD0_BY_PXOR")
2288 (const_int 0))
2289 (ne (symbol_ref "TARGET_SSE2")
2290 (const_int 0)))
2291 (eq (symbol_ref "optimize_size")
2292 (const_int 0)))
2293 (const_string "TI")
2294 (const_string "V4SF"))
2295 /* For architectures resolving dependencies on
2296 whole SSE registers use APS move to break dependency
2297 chains, otherwise use short move to avoid extra work.
2298
2299 Do the same for architectures resolving dependencies on
2300 the parts. While in DF mode it is better to always handle
2301 just register parts, the SF mode is different due to lack
2302 of instructions to load just part of the register. It is
2303 better to maintain the whole registers in single format
2304 to avoid problems on using packed logical operations. */
2305 (eq_attr "alternative" "6")
2306 (if_then_else
2307 (ior (ne (symbol_ref "TARGET_SSE_PARTIAL_REG_DEPENDENCY")
2308 (const_int 0))
2309 (ne (symbol_ref "TARGET_SSE_PARTIAL_REGS")
2310 (const_int 0)))
2311 (const_string "V4SF")
2312 (const_string "SF"))
2313 (eq_attr "alternative" "11")
2314 (const_string "DI")]
2315 (const_string "SF")))])
2316
2317(define_insn "*movsf_1_nointerunit"
2318 [(set (match_operand:SF 0 "nonimmediate_operand" "=f#xr,m,f#xr,r#xf,m,x#rf,x#rf,x#rf,m,!*y,!m,!*y")
2319 (match_operand:SF 1 "general_operand" "fm#rx,f#rx,G,rmF#fx,Fr#fx,C,x,xm#rf,x#rf,m,*y,*y"))]
2320 "(!TARGET_INTER_UNIT_MOVES && !optimize_size)
2321 && (GET_CODE (operands[0]) != MEM || GET_CODE (operands[1]) != MEM)
d7a29404 2322 && (reload_in_progress || reload_completed
3987b9db 2323 || (ix86_cmodel == CM_MEDIUM || ix86_cmodel == CM_LARGE)
d7a29404
JH
2324 || GET_CODE (operands[1]) != CONST_DOUBLE
2325 || memory_operand (operands[0], SFmode))"
886c62d1 2326{
e075ae69 2327 switch (which_alternative)
886c62d1 2328 {
e075ae69 2329 case 0:
0c174a68
AB
2330 if (REG_P (operands[1])
2331 && find_regno_note (insn, REG_DEAD, REGNO (operands[1])))
4977bab6
ZW
2332 {
2333 if (REGNO (operands[0]) == FIRST_STACK_REG
2334 && TARGET_USE_FFREEP)
2335 return "ffreep\t%y0";
2336 return "fstp\t%y0";
2337 }
e075ae69 2338 else if (STACK_TOP_P (operands[0]))
0f40f9f7 2339 return "fld%z1\t%y1";
886c62d1 2340 else
0f40f9f7 2341 return "fst\t%y0";
886c62d1 2342
e075ae69
RH
2343 case 1:
2344 if (find_regno_note (insn, REG_DEAD, REGNO (operands[1])))
0f40f9f7 2345 return "fstp%z0\t%y0";
886c62d1 2346 else
0f40f9f7 2347 return "fst%z0\t%y0";
886c62d1 2348
e075ae69 2349 case 2:
881b2a96 2350 return standard_80387_constant_opcode (operands[1]);
886c62d1 2351
e075ae69
RH
2352 case 3:
2353 case 4:
0f40f9f7 2354 return "mov{l}\t{%1, %0|%0, %1}";
446988df 2355 case 5:
4977bab6 2356 if (get_attr_mode (insn) == MODE_TI)
692efa8e
JJ
2357 return "pxor\t%0, %0";
2358 else
2359 return "xorps\t%0, %0";
446988df 2360 case 6:
4977bab6 2361 if (get_attr_mode (insn) == MODE_V4SF)
0f40f9f7 2362 return "movaps\t{%1, %0|%0, %1}";
2b04e52b 2363 else
0f40f9f7 2364 return "movss\t{%1, %0|%0, %1}";
2b04e52b
JH
2365 case 7:
2366 case 8:
0f40f9f7 2367 return "movss\t{%1, %0|%0, %1}";
886c62d1 2368
ac300a45
JJ
2369 case 9:
2370 case 10:
2371 return "movd\t{%1, %0|%0, %1}";
2372
e5a20888
JJ
2373 case 11:
2374 return "movq\t{%1, %0|%0, %1}";
2375
e075ae69
RH
2376 default:
2377 abort();
2378 }
0f40f9f7 2379}
3d34cd91 2380 [(set_attr "type" "fmov,fmov,fmov,imov,imov,ssemov,ssemov,ssemov,ssemov,mmxmov,mmxmov,mmxmov")
4977bab6
ZW
2381 (set (attr "mode")
2382 (cond [(eq_attr "alternative" "3,4,9,10")
2383 (const_string "SI")
2384 (eq_attr "alternative" "5")
2385 (if_then_else
2386 (and (and (ne (symbol_ref "TARGET_SSE_LOAD0_BY_PXOR")
2387 (const_int 0))
2388 (ne (symbol_ref "TARGET_SSE2")
2389 (const_int 0)))
2390 (eq (symbol_ref "optimize_size")
2391 (const_int 0)))
2392 (const_string "TI")
2393 (const_string "V4SF"))
2394 /* For architectures resolving dependencies on
2395 whole SSE registers use APS move to break dependency
2396 chains, otherwise use short move to avoid extra work.
2397
2398 Do the same for architectures resolving dependencies on
2399 the parts. While in DF mode it is better to always handle
2400 just register parts, the SF mode is different due to lack
2401 of instructions to load just part of the register. It is
2402 better to maintain the whole registers in single format
2403 to avoid problems on using packed logical operations. */
2404 (eq_attr "alternative" "6")
2405 (if_then_else
2406 (ior (ne (symbol_ref "TARGET_SSE_PARTIAL_REG_DEPENDENCY")
2407 (const_int 0))
2408 (ne (symbol_ref "TARGET_SSE_PARTIAL_REGS")
2409 (const_int 0)))
2410 (const_string "V4SF")
2411 (const_string "SF"))
2412 (eq_attr "alternative" "11")
2413 (const_string "DI")]
2414 (const_string "SF")))])
d7a29404 2415
a4414093 2416(define_insn "*swapsf"
e075ae69
RH
2417 [(set (match_operand:SF 0 "register_operand" "+f")
2418 (match_operand:SF 1 "register_operand" "+f"))
0be5d99f
MM
2419 (set (match_dup 1)
2420 (match_dup 0))]
965f5423 2421 "reload_completed || !TARGET_SSE"
0be5d99f
MM
2422{
2423 if (STACK_TOP_P (operands[0]))
0f40f9f7 2424 return "fxch\t%1";
0be5d99f 2425 else
0f40f9f7
ZW
2426 return "fxch\t%0";
2427}
6ef67412
JH
2428 [(set_attr "type" "fxch")
2429 (set_attr "mode" "SF")])
0be5d99f 2430
e075ae69 2431(define_expand "movdf"
4cbfbb1b 2432 [(set (match_operand:DF 0 "nonimmediate_operand" "")
e075ae69
RH
2433 (match_operand:DF 1 "general_operand" ""))]
2434 ""
2435 "ix86_expand_move (DFmode, operands); DONE;")
55953cea 2436
8fcaaa80 2437;; Size of pushdf is 3 (for sub) + 2 (for fstp) + memory operand size.
d1f87653 2438;; Size of pushdf using integer instructions is 2+2*memory operand size
8fcaaa80
JH
2439;; On the average, pushdf using integers can be still shorter. Allow this
2440;; pattern for optimize_size too.
2441
0b5107cf 2442(define_insn "*pushdf_nointeger"
446988df 2443 [(set (match_operand:DF 0 "push_operand" "=<,<,<,<")
c6e95f34 2444 (match_operand:DF 1 "general_no_elim_operand" "f#Y,Fo#fY,*r#fY,Y#f"))]
0ec259ed 2445 "!TARGET_64BIT && !TARGET_INTEGER_DFMODE_MOVES"
0b5107cf 2446{
4977bab6
ZW
2447 /* This insn should be already splitted before reg-stack. */
2448 abort ();
0f40f9f7 2449}
6ef67412 2450 [(set_attr "type" "multi")
446988df 2451 (set_attr "mode" "DF,SI,SI,DF")])
0b5107cf
JH
2452
2453(define_insn "*pushdf_integer"
446988df
JH
2454 [(set (match_operand:DF 0 "push_operand" "=<,<,<")
2455 (match_operand:DF 1 "general_no_elim_operand" "f#rY,rFo#fY,Y#rf"))]
0ec259ed 2456 "TARGET_64BIT || TARGET_INTEGER_DFMODE_MOVES"
f31fce3f 2457{
4977bab6
ZW
2458 /* This insn should be already splitted before reg-stack. */
2459 abort ();
0f40f9f7 2460}
6ef67412 2461 [(set_attr "type" "multi")
446988df 2462 (set_attr "mode" "DF,SI,DF")])
f31fce3f 2463
e075ae69 2464;; %%% Kill this when call knows how to work this out.
f72b27a5
JH
2465(define_split
2466 [(set (match_operand:DF 0 "push_operand" "")
c3c637e3
GS
2467 (match_operand:DF 1 "any_fp_register_operand" ""))]
2468 "!TARGET_64BIT && reload_completed"
e075ae69
RH
2469 [(set (reg:SI 7) (plus:SI (reg:SI 7) (const_int -8)))
2470 (set (mem:DF (reg:SI 7)) (match_dup 1))]
f72b27a5 2471 "")
f31fce3f 2472
0ec259ed
JH
2473(define_split
2474 [(set (match_operand:DF 0 "push_operand" "")
c3c637e3
GS
2475 (match_operand:DF 1 "any_fp_register_operand" ""))]
2476 "TARGET_64BIT && reload_completed"
0ec259ed
JH
2477 [(set (reg:DI 7) (plus:DI (reg:DI 7) (const_int -8)))
2478 (set (mem:DF (reg:DI 7)) (match_dup 1))]
2479 "")
2480
e075ae69
RH
2481(define_split
2482 [(set (match_operand:DF 0 "push_operand" "")
0be5d99f 2483 (match_operand:DF 1 "general_operand" ""))]
e075ae69 2484 "reload_completed"
2450a057 2485 [(const_int 0)]
26e5b205 2486 "ix86_split_long_move (operands); DONE;")
0be5d99f 2487
8fcaaa80
JH
2488;; Moving is usually shorter when only FP registers are used. This separate
2489;; movdf pattern avoids the use of integer registers for FP operations
2490;; when optimizing for size.
2491
2492(define_insn "*movdf_nointeger"
2b04e52b 2493 [(set (match_operand:DF 0 "nonimmediate_operand" "=f#Y,m,f#Y,*r,o,Y#f,Y#f,Y#f,m")
f8ca7923 2494 (match_operand:DF 1 "general_operand" "fm#Y,f#Y,G,*roF,F*r,C,Y#f,YHm#f,Y#f"))]
8fcaaa80 2495 "(GET_CODE (operands[0]) != MEM || GET_CODE (operands[1]) != MEM)
4977bab6 2496 && ((optimize_size || !TARGET_INTEGER_DFMODE_MOVES) && !TARGET_64BIT)
d7a29404 2497 && (reload_in_progress || reload_completed
3987b9db 2498 || (ix86_cmodel == CM_MEDIUM || ix86_cmodel == CM_LARGE)
d7a29404
JH
2499 || GET_CODE (operands[1]) != CONST_DOUBLE
2500 || memory_operand (operands[0], DFmode))"
8fcaaa80
JH
2501{
2502 switch (which_alternative)
2503 {
2504 case 0:
2505 if (REG_P (operands[1])
2506 && find_regno_note (insn, REG_DEAD, REGNO (operands[1])))
4977bab6
ZW
2507 {
2508 if (REGNO (operands[0]) == FIRST_STACK_REG
2509 && TARGET_USE_FFREEP)
2510 return "ffreep\t%y0";
2511 return "fstp\t%y0";
2512 }
8fcaaa80 2513 else if (STACK_TOP_P (operands[0]))
0f40f9f7 2514 return "fld%z1\t%y1";
8fcaaa80 2515 else
0f40f9f7 2516 return "fst\t%y0";
8fcaaa80
JH
2517
2518 case 1:
2519 if (find_regno_note (insn, REG_DEAD, REGNO (operands[1])))
0f40f9f7 2520 return "fstp%z0\t%y0";
8fcaaa80 2521 else
0f40f9f7 2522 return "fst%z0\t%y0";
8fcaaa80
JH
2523
2524 case 2:
881b2a96 2525 return standard_80387_constant_opcode (operands[1]);
8fcaaa80
JH
2526
2527 case 3:
2528 case 4:
0f40f9f7 2529 return "#";
446988df 2530 case 5:
4977bab6
ZW
2531 switch (get_attr_mode (insn))
2532 {
2533 case MODE_V4SF:
2534 return "xorps\t%0, %0";
2535 case MODE_V2DF:
2536 return "xorpd\t%0, %0";
2537 case MODE_TI:
2538 return "pxor\t%0, %0";
2539 default:
2540 abort ();
2541 }
446988df 2542 case 6:
4977bab6
ZW
2543 switch (get_attr_mode (insn))
2544 {
2545 case MODE_V4SF:
2546 return "movaps\t{%1, %0|%0, %1}";
2547 case MODE_V2DF:
2548 return "movapd\t{%1, %0|%0, %1}";
2549 case MODE_DF:
2550 return "movsd\t{%1, %0|%0, %1}";
2551 default:
2552 abort ();
2553 }
2554 case 7:
2555 if (get_attr_mode (insn) == MODE_V2DF)
2556 return "movlpd\t{%1, %0|%0, %1}";
2b04e52b 2557 else
0f40f9f7 2558 return "movsd\t{%1, %0|%0, %1}";
2b04e52b 2559 case 8:
4977bab6 2560 return "movsd\t{%1, %0|%0, %1}";
8fcaaa80
JH
2561
2562 default:
2563 abort();
2564 }
0f40f9f7 2565}
3d34cd91 2566 [(set_attr "type" "fmov,fmov,fmov,multi,multi,ssemov,ssemov,ssemov,ssemov")
4977bab6
ZW
2567 (set (attr "mode")
2568 (cond [(eq_attr "alternative" "3,4")
2569 (const_string "SI")
2570 /* xorps is one byte shorter. */
2571 (eq_attr "alternative" "5")
2572 (cond [(ne (symbol_ref "optimize_size")
2573 (const_int 0))
2574 (const_string "V4SF")
2575 (ne (symbol_ref "TARGET_SSE_LOAD0_BY_PXOR")
2576 (const_int 0))
2577 (const_string "TI")]
2578 (const_string "V2DF"))
2579 /* For architectures resolving dependencies on
2580 whole SSE registers use APD move to break dependency
2581 chains, otherwise use short move to avoid extra work.
2582
2583 movaps encodes one byte shorter. */
2584 (eq_attr "alternative" "6")
2585 (cond
2586 [(ne (symbol_ref "optimize_size")
2587 (const_int 0))
2588 (const_string "V4SF")
2589 (ne (symbol_ref "TARGET_SSE_PARTIAL_REG_DEPENDENCY")
2590 (const_int 0))
2591 (const_string "V2DF")]
2592 (const_string "DF"))
d1f87653 2593 /* For architectures resolving dependencies on register
4977bab6
ZW
2594 parts we may avoid extra work to zero out upper part
2595 of register. */
2596 (eq_attr "alternative" "7")
2597 (if_then_else
2598 (ne (symbol_ref "TARGET_SSE_PARTIAL_REGS")
2599 (const_int 0))
2600 (const_string "V2DF")
2601 (const_string "DF"))]
2602 (const_string "DF")))])
8fcaaa80
JH
2603
2604(define_insn "*movdf_integer"
2b04e52b 2605 [(set (match_operand:DF 0 "nonimmediate_operand" "=f#Yr,m,f#Yr,r#Yf,o,Y#rf,Y#rf,Y#rf,m")
f8ca7923 2606 (match_operand:DF 1 "general_operand" "fm#Yr,f#Yr,G,roF#Yf,Fr#Yf,C,Y#rf,Ym#rf,Y#rf"))]
8fcaaa80 2607 "(GET_CODE (operands[0]) != MEM || GET_CODE (operands[1]) != MEM)
4977bab6 2608 && ((!optimize_size && TARGET_INTEGER_DFMODE_MOVES) || TARGET_64BIT)
d7a29404 2609 && (reload_in_progress || reload_completed
3987b9db 2610 || (ix86_cmodel == CM_MEDIUM || ix86_cmodel == CM_LARGE)
d7a29404
JH
2611 || GET_CODE (operands[1]) != CONST_DOUBLE
2612 || memory_operand (operands[0], DFmode))"
886c62d1 2613{
e075ae69 2614 switch (which_alternative)
886c62d1 2615 {
e075ae69 2616 case 0:
0c174a68
AB
2617 if (REG_P (operands[1])
2618 && find_regno_note (insn, REG_DEAD, REGNO (operands[1])))
4977bab6
ZW
2619 {
2620 if (REGNO (operands[0]) == FIRST_STACK_REG
2621 && TARGET_USE_FFREEP)
2622 return "ffreep\t%y0";
2623 return "fstp\t%y0";
2624 }
e075ae69 2625 else if (STACK_TOP_P (operands[0]))
0f40f9f7 2626 return "fld%z1\t%y1";
886c62d1 2627 else
0f40f9f7 2628 return "fst\t%y0";
886c62d1 2629
e075ae69
RH
2630 case 1:
2631 if (find_regno_note (insn, REG_DEAD, REGNO (operands[1])))
0f40f9f7 2632 return "fstp%z0\t%y0";
886c62d1 2633 else
0f40f9f7 2634 return "fst%z0\t%y0";
886c62d1 2635
e075ae69 2636 case 2:
881b2a96 2637 return standard_80387_constant_opcode (operands[1]);
886c62d1 2638
e075ae69
RH
2639 case 3:
2640 case 4:
0f40f9f7 2641 return "#";
886c62d1 2642
446988df 2643 case 5:
4977bab6
ZW
2644 switch (get_attr_mode (insn))
2645 {
2646 case MODE_V4SF:
2647 return "xorps\t%0, %0";
2648 case MODE_V2DF:
2649 return "xorpd\t%0, %0";
2650 case MODE_TI:
2651 return "pxor\t%0, %0";
2652 default:
2653 abort ();
2654 }
446988df 2655 case 6:
4977bab6
ZW
2656 switch (get_attr_mode (insn))
2657 {
2658 case MODE_V4SF:
2659 return "movaps\t{%1, %0|%0, %1}";
2660 case MODE_V2DF:
2661 return "movapd\t{%1, %0|%0, %1}";
2662 case MODE_DF:
2663 return "movsd\t{%1, %0|%0, %1}";
2664 default:
2665 abort ();
2666 }
2667 case 7:
2668 if (get_attr_mode (insn) == MODE_V2DF)
2669 return "movlpd\t{%1, %0|%0, %1}";
2b04e52b 2670 else
0f40f9f7 2671 return "movsd\t{%1, %0|%0, %1}";
2b04e52b 2672 case 8:
0f40f9f7 2673 return "movsd\t{%1, %0|%0, %1}";
446988df 2674
e075ae69
RH
2675 default:
2676 abort();
2677 }
0f40f9f7 2678}
3d34cd91 2679 [(set_attr "type" "fmov,fmov,fmov,multi,multi,ssemov,ssemov,ssemov,ssemov")
4977bab6
ZW
2680 (set (attr "mode")
2681 (cond [(eq_attr "alternative" "3,4")
2682 (const_string "SI")
2683 /* xorps is one byte shorter. */
2684 (eq_attr "alternative" "5")
2685 (cond [(ne (symbol_ref "optimize_size")
2686 (const_int 0))
2687 (const_string "V4SF")
2688 (ne (symbol_ref "TARGET_SSE_LOAD0_BY_PXOR")
2689 (const_int 0))
2690 (const_string "TI")]
2691 (const_string "V2DF"))
2692 /* For architectures resolving dependencies on
2693 whole SSE registers use APD move to break dependency
2694 chains, otherwise use short move to avoid extra work.
2695
2696 movaps encodes one byte shorter. */
2697 (eq_attr "alternative" "6")
2698 (cond
2699 [(ne (symbol_ref "optimize_size")
2700 (const_int 0))
2701 (const_string "V4SF")
2702 (ne (symbol_ref "TARGET_SSE_PARTIAL_REG_DEPENDENCY")
2703 (const_int 0))
2704 (const_string "V2DF")]
2705 (const_string "DF"))
d1f87653 2706 /* For architectures resolving dependencies on register
4977bab6
ZW
2707 parts we may avoid extra work to zero out upper part
2708 of register. */
2709 (eq_attr "alternative" "7")
2710 (if_then_else
2711 (ne (symbol_ref "TARGET_SSE_PARTIAL_REGS")
2712 (const_int 0))
2713 (const_string "V2DF")
2714 (const_string "DF"))]
2715 (const_string "DF")))])
2ae0f82c 2716
e075ae69
RH
2717(define_split
2718 [(set (match_operand:DF 0 "nonimmediate_operand" "")
2719 (match_operand:DF 1 "general_operand" ""))]
2720 "reload_completed
2721 && (GET_CODE (operands[0]) != MEM || GET_CODE (operands[1]) != MEM)
446988df 2722 && ! (ANY_FP_REG_P (operands[0]) ||
e075ae69 2723 (GET_CODE (operands[0]) == SUBREG
446988df
JH
2724 && ANY_FP_REG_P (SUBREG_REG (operands[0]))))
2725 && ! (ANY_FP_REG_P (operands[1]) ||
e075ae69 2726 (GET_CODE (operands[1]) == SUBREG
446988df 2727 && ANY_FP_REG_P (SUBREG_REG (operands[1]))))"
26e5b205
JH
2728 [(const_int 0)]
2729 "ix86_split_long_move (operands); DONE;")
886c62d1 2730
a4414093 2731(define_insn "*swapdf"
e075ae69
RH
2732 [(set (match_operand:DF 0 "register_operand" "+f")
2733 (match_operand:DF 1 "register_operand" "+f"))
0be5d99f
MM
2734 (set (match_dup 1)
2735 (match_dup 0))]
446988df 2736 "reload_completed || !TARGET_SSE2"
0be5d99f
MM
2737{
2738 if (STACK_TOP_P (operands[0]))
0f40f9f7 2739 return "fxch\t%1";
0be5d99f 2740 else
0f40f9f7
ZW
2741 return "fxch\t%0";
2742}
6ef67412
JH
2743 [(set_attr "type" "fxch")
2744 (set_attr "mode" "DF")])
e075ae69
RH
2745
2746(define_expand "movxf"
4cbfbb1b 2747 [(set (match_operand:XF 0 "nonimmediate_operand" "")
e075ae69 2748 (match_operand:XF 1 "general_operand" ""))]
1e07edd3 2749 "!TARGET_64BIT"
e075ae69 2750 "ix86_expand_move (XFmode, operands); DONE;")
0be5d99f 2751
2b589241
JH
2752(define_expand "movtf"
2753 [(set (match_operand:TF 0 "nonimmediate_operand" "")
2754 (match_operand:TF 1 "general_operand" ""))]
2755 ""
2756 "ix86_expand_move (TFmode, operands); DONE;")
2757
8fcaaa80 2758;; Size of pushdf is 3 (for sub) + 2 (for fstp) + memory operand size.
d1f87653 2759;; Size of pushdf using integer instructions is 3+3*memory operand size
8fcaaa80
JH
2760;; Pushing using integer instructions is longer except for constants
2761;; and direct memory references.
2762;; (assuming that any given constant is pushed only once, but this ought to be
2763;; handled elsewhere).
2764
2765(define_insn "*pushxf_nointeger"
1e07edd3 2766 [(set (match_operand:XF 0 "push_operand" "=X,X,X")
2c5a510c 2767 (match_operand:XF 1 "general_no_elim_operand" "f,Fo,*r"))]
1b0c37d7 2768 "!TARGET_64BIT && optimize_size"
8fcaaa80 2769{
4977bab6
ZW
2770 /* This insn should be already splitted before reg-stack. */
2771 abort ();
0f40f9f7 2772}
6ef67412
JH
2773 [(set_attr "type" "multi")
2774 (set_attr "mode" "XF,SI,SI")])
8fcaaa80 2775
2b589241
JH
2776(define_insn "*pushtf_nointeger"
2777 [(set (match_operand:TF 0 "push_operand" "=<,<,<")
2778 (match_operand:TF 1 "general_no_elim_operand" "f,Fo,*r"))]
2779 "optimize_size"
2b589241 2780{
4977bab6
ZW
2781 /* This insn should be already splitted before reg-stack. */
2782 abort ();
0f40f9f7 2783}
2b589241
JH
2784 [(set_attr "type" "multi")
2785 (set_attr "mode" "XF,SI,SI")])
2786
8fcaaa80 2787(define_insn "*pushxf_integer"
2450a057 2788 [(set (match_operand:XF 0 "push_operand" "=<,<")
1e07edd3 2789 (match_operand:XF 1 "general_no_elim_operand" "f#r,ro#f"))]
1b0c37d7 2790 "!TARGET_64BIT && !optimize_size"
f31fce3f 2791{
4977bab6
ZW
2792 /* This insn should be already splitted before reg-stack. */
2793 abort ();
0f40f9f7 2794}
6ef67412
JH
2795 [(set_attr "type" "multi")
2796 (set_attr "mode" "XF,SI")])
f31fce3f 2797
2b589241
JH
2798(define_insn "*pushtf_integer"
2799 [(set (match_operand:TF 0 "push_operand" "=<,<")
2800 (match_operand:TF 1 "general_no_elim_operand" "f#r,rFo#f"))]
2801 "!optimize_size"
2b589241 2802{
4977bab6
ZW
2803 /* This insn should be already splitted before reg-stack. */
2804 abort ();
0f40f9f7 2805}
2b589241
JH
2806 [(set_attr "type" "multi")
2807 (set_attr "mode" "XF,SI")])
2808
2450a057 2809(define_split
2b589241
JH
2810 [(set (match_operand 0 "push_operand" "")
2811 (match_operand 1 "general_operand" ""))]
2450a057 2812 "reload_completed
2b589241
JH
2813 && (GET_MODE (operands[0]) == XFmode
2814 || GET_MODE (operands[0]) == TFmode
2815 || GET_MODE (operands[0]) == DFmode)
c3c637e3 2816 && !ANY_FP_REG_P (operands[1])"
2450a057 2817 [(const_int 0)]
26e5b205 2818 "ix86_split_long_move (operands); DONE;")
2450a057 2819
f72b27a5
JH
2820(define_split
2821 [(set (match_operand:XF 0 "push_operand" "")
c3c637e3
GS
2822 (match_operand:XF 1 "any_fp_register_operand" ""))]
2823 "!TARGET_64BIT"
e075ae69
RH
2824 [(set (reg:SI 7) (plus:SI (reg:SI 7) (const_int -12)))
2825 (set (mem:XF (reg:SI 7)) (match_dup 1))])
f31fce3f 2826
2b589241
JH
2827(define_split
2828 [(set (match_operand:TF 0 "push_operand" "")
c3c637e3
GS
2829 (match_operand:TF 1 "any_fp_register_operand" ""))]
2830 "!TARGET_64BIT"
2b589241
JH
2831 [(set (reg:SI 7) (plus:SI (reg:SI 7) (const_int -16)))
2832 (set (mem:TF (reg:SI 7)) (match_dup 1))])
2833
0ec259ed
JH
2834(define_split
2835 [(set (match_operand:TF 0 "push_operand" "")
c3c637e3
GS
2836 (match_operand:TF 1 "any_fp_register_operand" ""))]
2837 "TARGET_64BIT"
0ec259ed
JH
2838 [(set (reg:DI 7) (plus:DI (reg:DI 7) (const_int -16)))
2839 (set (mem:TF (reg:DI 7)) (match_dup 1))])
2840
8fcaaa80
JH
2841;; Do not use integer registers when optimizing for size
2842(define_insn "*movxf_nointeger"
2843 [(set (match_operand:XF 0 "nonimmediate_operand" "=f,m,f,*r,o")
2844 (match_operand:XF 1 "general_operand" "fm,f,G,*roF,F*r"))]
1b0c37d7 2845 "!TARGET_64BIT
d7a29404 2846 && optimize_size
1b0c37d7 2847 && (GET_CODE (operands[0]) != MEM || GET_CODE (operands[1]) != MEM)
d7a29404
JH
2848 && (reload_in_progress || reload_completed
2849 || GET_CODE (operands[1]) != CONST_DOUBLE
2850 || memory_operand (operands[0], XFmode))"
0be5d99f 2851{
8fcaaa80
JH
2852 switch (which_alternative)
2853 {
2854 case 0:
2855 if (REG_P (operands[1])
2856 && find_regno_note (insn, REG_DEAD, REGNO (operands[1])))
4977bab6
ZW
2857 {
2858 if (REGNO (operands[0]) == FIRST_STACK_REG
2859 && TARGET_USE_FFREEP)
2860 return "ffreep\t%y0";
2861 return "fstp\t%y0";
2862 }
8fcaaa80 2863 else if (STACK_TOP_P (operands[0]))
0f40f9f7 2864 return "fld%z1\t%y1";
8fcaaa80 2865 else
0f40f9f7 2866 return "fst\t%y0";
0be5d99f 2867
8fcaaa80
JH
2868 case 1:
2869 /* There is no non-popping store to memory for XFmode. So if
2870 we need one, follow the store with a load. */
2871 if (! find_regno_note (insn, REG_DEAD, REGNO (operands[1])))
0f40f9f7 2872 return "fstp%z0\t%y0\;fld%z0\t%y0";
8fcaaa80 2873 else
0f40f9f7 2874 return "fstp%z0\t%y0";
8fcaaa80
JH
2875
2876 case 2:
881b2a96 2877 return standard_80387_constant_opcode (operands[1]);
8fcaaa80
JH
2878
2879 case 3: case 4:
0f40f9f7 2880 return "#";
8fcaaa80
JH
2881 }
2882 abort();
0f40f9f7 2883}
6ef67412
JH
2884 [(set_attr "type" "fmov,fmov,fmov,multi,multi")
2885 (set_attr "mode" "XF,XF,XF,SI,SI")])
8fcaaa80 2886
2b589241
JH
2887(define_insn "*movtf_nointeger"
2888 [(set (match_operand:TF 0 "nonimmediate_operand" "=f,m,f,*r,o")
2889 (match_operand:TF 1 "general_operand" "fm,f,G,*roF,F*r"))]
2890 "(GET_CODE (operands[0]) != MEM || GET_CODE (operands[1]) != MEM)
2891 && optimize_size
2892 && (reload_in_progress || reload_completed
2893 || GET_CODE (operands[1]) != CONST_DOUBLE
3987b9db 2894 || (ix86_cmodel == CM_MEDIUM || ix86_cmodel == CM_LARGE)
2b589241 2895 || memory_operand (operands[0], TFmode))"
2b589241
JH
2896{
2897 switch (which_alternative)
2898 {
2899 case 0:
2900 if (REG_P (operands[1])
2901 && find_regno_note (insn, REG_DEAD, REGNO (operands[1])))
4977bab6
ZW
2902 {
2903 if (REGNO (operands[0]) == FIRST_STACK_REG
2904 && TARGET_USE_FFREEP)
2905 return "ffreep\t%y0";
2906 return "fstp\t%y0";
2907 }
2b589241 2908 else if (STACK_TOP_P (operands[0]))
0f40f9f7 2909 return "fld%z1\t%y1";
2b589241 2910 else
0f40f9f7 2911 return "fst\t%y0";
2b589241
JH
2912
2913 case 1:
2914 /* There is no non-popping store to memory for XFmode. So if
2915 we need one, follow the store with a load. */
2916 if (! find_regno_note (insn, REG_DEAD, REGNO (operands[1])))
0f40f9f7 2917 return "fstp%z0\t%y0\;fld%z0\t%y0";
2b589241 2918 else
0f40f9f7 2919 return "fstp%z0\t%y0";
2b589241
JH
2920
2921 case 2:
881b2a96 2922 return standard_80387_constant_opcode (operands[1]);
2b589241
JH
2923
2924 case 3: case 4:
0f40f9f7 2925 return "#";
2b589241
JH
2926 }
2927 abort();
0f40f9f7 2928}
2b589241
JH
2929 [(set_attr "type" "fmov,fmov,fmov,multi,multi")
2930 (set_attr "mode" "XF,XF,XF,SI,SI")])
2931
8fcaaa80
JH
2932(define_insn "*movxf_integer"
2933 [(set (match_operand:XF 0 "nonimmediate_operand" "=f#r,m,f#r,r#f,o")
2934 (match_operand:XF 1 "general_operand" "fm#r,f#r,G,roF#f,Fr#f"))]
1b0c37d7 2935 "!TARGET_64BIT
d7a29404 2936 && !optimize_size
1b0c37d7 2937 && (GET_CODE (operands[0]) != MEM || GET_CODE (operands[1]) != MEM)
d7a29404
JH
2938 && (reload_in_progress || reload_completed
2939 || GET_CODE (operands[1]) != CONST_DOUBLE
2940 || memory_operand (operands[0], XFmode))"
4fb21e90 2941{
e075ae69 2942 switch (which_alternative)
4fb21e90 2943 {
e075ae69 2944 case 0:
0c174a68
AB
2945 if (REG_P (operands[1])
2946 && find_regno_note (insn, REG_DEAD, REGNO (operands[1])))
4977bab6
ZW
2947 {
2948 if (REGNO (operands[0]) == FIRST_STACK_REG
2949 && TARGET_USE_FFREEP)
2950 return "ffreep\t%y0";
2951 return "fstp\t%y0";
2952 }
e075ae69 2953 else if (STACK_TOP_P (operands[0]))
0f40f9f7 2954 return "fld%z1\t%y1";
4fb21e90 2955 else
0f40f9f7 2956 return "fst\t%y0";
4fb21e90 2957
e075ae69
RH
2958 case 1:
2959 /* There is no non-popping store to memory for XFmode. So if
2960 we need one, follow the store with a load. */
2961 if (! find_regno_note (insn, REG_DEAD, REGNO (operands[1])))
0f40f9f7 2962 return "fstp%z0\t%y0\;fld%z0\t%y0";
e075ae69 2963 else
0f40f9f7 2964 return "fstp%z0\t%y0";
2f17722a 2965
e075ae69 2966 case 2:
881b2a96 2967 return standard_80387_constant_opcode (operands[1]);
467403ca
RH
2968
2969 case 3: case 4:
0f40f9f7 2970 return "#";
4fb21e90 2971 }
e075ae69 2972 abort();
0f40f9f7 2973}
6ef67412
JH
2974 [(set_attr "type" "fmov,fmov,fmov,multi,multi")
2975 (set_attr "mode" "XF,XF,XF,SI,SI")])
4fb21e90 2976
2b589241
JH
2977(define_insn "*movtf_integer"
2978 [(set (match_operand:TF 0 "nonimmediate_operand" "=f#r,m,f#r,r#f,o")
2979 (match_operand:TF 1 "general_operand" "fm#r,f#r,G,roF#f,Fr#f"))]
2980 "(GET_CODE (operands[0]) != MEM || GET_CODE (operands[1]) != MEM)
2981 && !optimize_size
2982 && (reload_in_progress || reload_completed
2983 || GET_CODE (operands[1]) != CONST_DOUBLE
3987b9db 2984 || (ix86_cmodel == CM_MEDIUM || ix86_cmodel == CM_LARGE)
2b589241 2985 || memory_operand (operands[0], TFmode))"
2b589241
JH
2986{
2987 switch (which_alternative)
2988 {
2989 case 0:
2990 if (REG_P (operands[1])
2991 && find_regno_note (insn, REG_DEAD, REGNO (operands[1])))
4977bab6
ZW
2992 {
2993 if (REGNO (operands[0]) == FIRST_STACK_REG
2994 && TARGET_USE_FFREEP)
2995 return "ffreep\t%y0";
2996 return "fstp\t%y0";
2997 }
2b589241 2998 else if (STACK_TOP_P (operands[0]))
0f40f9f7 2999 return "fld%z1\t%y1";
2b589241 3000 else
0f40f9f7 3001 return "fst\t%y0";
2b589241
JH
3002
3003 case 1:
3004 /* There is no non-popping store to memory for XFmode. So if
3005 we need one, follow the store with a load. */
3006 if (! find_regno_note (insn, REG_DEAD, REGNO (operands[1])))
0f40f9f7 3007 return "fstp%z0\t%y0\;fld%z0\t%y0";
2b589241 3008 else
0f40f9f7 3009 return "fstp%z0\t%y0";
2b589241
JH
3010
3011 case 2:
881b2a96 3012 return standard_80387_constant_opcode (operands[1]);
2b589241
JH
3013
3014 case 3: case 4:
0f40f9f7 3015 return "#";
2b589241
JH
3016 }
3017 abort();
0f40f9f7 3018}
2b589241
JH
3019 [(set_attr "type" "fmov,fmov,fmov,multi,multi")
3020 (set_attr "mode" "XF,XF,XF,SI,SI")])
3021
467403ca 3022(define_split
2b589241
JH
3023 [(set (match_operand 0 "nonimmediate_operand" "")
3024 (match_operand 1 "general_operand" ""))]
2450a057 3025 "reload_completed
8fcaaa80 3026 && (GET_CODE (operands[0]) != MEM || GET_CODE (operands[1]) != MEM)
2b589241 3027 && (GET_MODE (operands[0]) == XFmode || GET_MODE (operands[0]) == TFmode)
446988df 3028 && ! (ANY_FP_REG_P (operands[0]) ||
8fcaaa80 3029 (GET_CODE (operands[0]) == SUBREG
446988df
JH
3030 && ANY_FP_REG_P (SUBREG_REG (operands[0]))))
3031 && ! (ANY_FP_REG_P (operands[1]) ||
8fcaaa80 3032 (GET_CODE (operands[1]) == SUBREG
446988df 3033 && ANY_FP_REG_P (SUBREG_REG (operands[1]))))"
26e5b205
JH
3034 [(const_int 0)]
3035 "ix86_split_long_move (operands); DONE;")
467403ca 3036
d7a29404 3037(define_split
2b589241
JH
3038 [(set (match_operand 0 "register_operand" "")
3039 (match_operand 1 "memory_operand" ""))]
d7a29404
JH
3040 "reload_completed
3041 && GET_CODE (operands[1]) == MEM
2b04e52b
JH
3042 && (GET_MODE (operands[0]) == XFmode || GET_MODE (operands[0]) == TFmode
3043 || GET_MODE (operands[0]) == SFmode || GET_MODE (operands[0]) == DFmode)
d7a29404
JH
3044 && GET_CODE (XEXP (operands[1], 0)) == SYMBOL_REF
3045 && CONSTANT_POOL_ADDRESS_P (XEXP (operands[1], 0))
2b04e52b
JH
3046 && (!(SSE_REG_P (operands[0]) ||
3047 (GET_CODE (operands[0]) == SUBREG
3048 && SSE_REG_P (SUBREG_REG (operands[0]))))
3049 || standard_sse_constant_p (get_pool_constant (XEXP (operands[1], 0))))
3050 && (!(FP_REG_P (operands[0]) ||
3051 (GET_CODE (operands[0]) == SUBREG
3052 && FP_REG_P (SUBREG_REG (operands[0]))))
3053 || standard_80387_constant_p (get_pool_constant (XEXP (operands[1], 0))))"
d7a29404
JH
3054 [(set (match_dup 0)
3055 (match_dup 1))]
3056 "operands[1] = get_pool_constant (XEXP (operands[1], 0));")
3057
e075ae69
RH
3058(define_insn "swapxf"
3059 [(set (match_operand:XF 0 "register_operand" "+f")
3060 (match_operand:XF 1 "register_operand" "+f"))
0be5d99f
MM
3061 (set (match_dup 1)
3062 (match_dup 0))]
3063 ""
0be5d99f
MM
3064{
3065 if (STACK_TOP_P (operands[0]))
0f40f9f7 3066 return "fxch\t%1";
0be5d99f 3067 else
0f40f9f7
ZW
3068 return "fxch\t%0";
3069}
0b5107cf 3070 [(set_attr "type" "fxch")
6ef67412 3071 (set_attr "mode" "XF")])
2b589241
JH
3072
3073(define_insn "swaptf"
3074 [(set (match_operand:TF 0 "register_operand" "+f")
3075 (match_operand:TF 1 "register_operand" "+f"))
3076 (set (match_dup 1)
3077 (match_dup 0))]
3078 ""
2b589241
JH
3079{
3080 if (STACK_TOP_P (operands[0]))
0f40f9f7 3081 return "fxch\t%1";
2b589241 3082 else
0f40f9f7
ZW
3083 return "fxch\t%0";
3084}
2b589241
JH
3085 [(set_attr "type" "fxch")
3086 (set_attr "mode" "XF")])
886c62d1 3087\f
e075ae69 3088;; Zero extension instructions
886c62d1 3089
8f7661f2
JH
3090(define_expand "zero_extendhisi2"
3091 [(set (match_operand:SI 0 "register_operand" "")
3092 (zero_extend:SI (match_operand:HI 1 "nonimmediate_operand" "")))]
d626200a 3093 ""
e075ae69 3094{
8f7661f2 3095 if (TARGET_ZERO_EXTEND_WITH_AND && !optimize_size)
2ae0f82c 3096 {
8f7661f2
JH
3097 operands[1] = force_reg (HImode, operands[1]);
3098 emit_insn (gen_zero_extendhisi2_and (operands[0], operands[1]));
3099 DONE;
2ae0f82c 3100 }
0f40f9f7 3101})
886c62d1 3102
8f7661f2
JH
3103(define_insn "zero_extendhisi2_and"
3104 [(set (match_operand:SI 0 "register_operand" "=r")
3105 (zero_extend:SI (match_operand:HI 1 "register_operand" "0")))
e075ae69 3106 (clobber (reg:CC 17))]
8f7661f2
JH
3107 "TARGET_ZERO_EXTEND_WITH_AND && !optimize_size"
3108 "#"
6ef67412
JH
3109 [(set_attr "type" "alu1")
3110 (set_attr "mode" "SI")])
2ae0f82c
SC
3111
3112(define_split
3113 [(set (match_operand:SI 0 "register_operand" "")
8f7661f2 3114 (zero_extend:SI (match_operand:HI 1 "register_operand" "")))
e075ae69 3115 (clobber (reg:CC 17))]
8f7661f2
JH
3116 "reload_completed && TARGET_ZERO_EXTEND_WITH_AND && !optimize_size"
3117 [(parallel [(set (match_dup 0) (and:SI (match_dup 0) (const_int 65535)))
e075ae69 3118 (clobber (reg:CC 17))])]
d626200a
JL
3119 "")
3120
8f7661f2
JH
3121(define_insn "*zero_extendhisi2_movzwl"
3122 [(set (match_operand:SI 0 "register_operand" "=r")
3123 (zero_extend:SI (match_operand:HI 1 "nonimmediate_operand" "rm")))]
3124 "!TARGET_ZERO_EXTEND_WITH_AND || optimize_size"
0f40f9f7 3125 "movz{wl|x}\t{%1, %0|%0, %1}"
6ef67412
JH
3126 [(set_attr "type" "imovx")
3127 (set_attr "mode" "SI")])
8f7661f2
JH
3128
3129(define_expand "zero_extendqihi2"
3130 [(parallel
3131 [(set (match_operand:HI 0 "register_operand" "")
3132 (zero_extend:HI (match_operand:QI 1 "nonimmediate_operand" "")))
3133 (clobber (reg:CC 17))])]
e075ae69 3134 ""
8f7661f2
JH
3135 "")
3136
3137(define_insn "*zero_extendqihi2_and"
3138 [(set (match_operand:HI 0 "register_operand" "=r,?&q")
3139 (zero_extend:HI (match_operand:QI 1 "nonimmediate_operand" "0,qm")))
3140 (clobber (reg:CC 17))]
3141 "TARGET_ZERO_EXTEND_WITH_AND && !optimize_size"
3142 "#"
6ef67412
JH
3143 [(set_attr "type" "alu1")
3144 (set_attr "mode" "HI")])
8f7661f2
JH
3145
3146(define_insn "*zero_extendqihi2_movzbw_and"
3147 [(set (match_operand:HI 0 "register_operand" "=r,r")
3148 (zero_extend:HI (match_operand:QI 1 "nonimmediate_operand" "qm,0")))
3149 (clobber (reg:CC 17))]
3150 "!TARGET_ZERO_EXTEND_WITH_AND || optimize_size"
3151 "#"
6ef67412
JH
3152 [(set_attr "type" "imovx,alu1")
3153 (set_attr "mode" "HI")])
886c62d1 3154
8f7661f2
JH
3155(define_insn "*zero_extendqihi2_movzbw"
3156 [(set (match_operand:HI 0 "register_operand" "=r")
3157 (zero_extend:HI (match_operand:QI 1 "nonimmediate_operand" "qm")))]
1c27d4b2 3158 "(!TARGET_ZERO_EXTEND_WITH_AND || optimize_size) && reload_completed"
0f40f9f7 3159 "movz{bw|x}\t{%1, %0|%0, %1}"
6ef67412
JH
3160 [(set_attr "type" "imovx")
3161 (set_attr "mode" "HI")])
8f7661f2
JH
3162
3163;; For the movzbw case strip only the clobber
2ae0f82c
SC
3164(define_split
3165 [(set (match_operand:HI 0 "register_operand" "")
e075ae69
RH
3166 (zero_extend:HI (match_operand:QI 1 "nonimmediate_operand" "")))
3167 (clobber (reg:CC 17))]
8f7661f2
JH
3168 "reload_completed
3169 && (!TARGET_ZERO_EXTEND_WITH_AND || optimize_size)
1a06f5fe 3170 && (!REG_P (operands[1]) || ANY_QI_REG_P (operands[1]))"
8f7661f2
JH
3171 [(set (match_operand:HI 0 "register_operand" "")
3172 (zero_extend:HI (match_operand:QI 1 "nonimmediate_operand" "")))])
2ae0f82c 3173
8f7661f2
JH
3174;; When source and destination does not overlap, clear destination
3175;; first and then do the movb
2ae0f82c
SC
3176(define_split
3177 [(set (match_operand:HI 0 "register_operand" "")
8f7661f2 3178 (zero_extend:HI (match_operand:QI 1 "nonimmediate_operand" "")))
e075ae69
RH
3179 (clobber (reg:CC 17))]
3180 "reload_completed
1a06f5fe 3181 && ANY_QI_REG_P (operands[0])
8f7661f2
JH
3182 && (TARGET_ZERO_EXTEND_WITH_AND && !optimize_size)
3183 && !reg_overlap_mentioned_p (operands[0], operands[1])"
3184 [(set (match_dup 0) (const_int 0))
3185 (set (strict_low_part (match_dup 2)) (match_dup 1))]
3186 "operands[2] = gen_lowpart (QImode, operands[0]);")
2ae0f82c 3187
8f7661f2 3188;; Rest is handled by single and.
2ae0f82c
SC
3189(define_split
3190 [(set (match_operand:HI 0 "register_operand" "")
e075ae69
RH
3191 (zero_extend:HI (match_operand:QI 1 "register_operand" "")))
3192 (clobber (reg:CC 17))]
3193 "reload_completed
8f7661f2
JH
3194 && true_regnum (operands[0]) == true_regnum (operands[1])"
3195 [(parallel [(set (match_dup 0) (and:HI (match_dup 0) (const_int 255)))
e075ae69 3196 (clobber (reg:CC 17))])]
d626200a
JL
3197 "")
3198
8f7661f2
JH
3199(define_expand "zero_extendqisi2"
3200 [(parallel
3201 [(set (match_operand:SI 0 "register_operand" "")
3202 (zero_extend:SI (match_operand:QI 1 "nonimmediate_operand" "")))
3203 (clobber (reg:CC 17))])]
e075ae69 3204 ""
8f7661f2
JH
3205 "")
3206
3207(define_insn "*zero_extendqisi2_and"
3208 [(set (match_operand:SI 0 "register_operand" "=r,?&q")
3209 (zero_extend:SI (match_operand:QI 1 "nonimmediate_operand" "0,qm")))
3210 (clobber (reg:CC 17))]
3211 "TARGET_ZERO_EXTEND_WITH_AND && !optimize_size"
3212 "#"
6ef67412
JH
3213 [(set_attr "type" "alu1")
3214 (set_attr "mode" "SI")])
8f7661f2
JH
3215
3216(define_insn "*zero_extendqisi2_movzbw_and"
3217 [(set (match_operand:SI 0 "register_operand" "=r,r")
3218 (zero_extend:SI (match_operand:QI 1 "nonimmediate_operand" "qm,0")))
3219 (clobber (reg:CC 17))]
3220 "!TARGET_ZERO_EXTEND_WITH_AND || optimize_size"
3221 "#"
6ef67412
JH
3222 [(set_attr "type" "imovx,alu1")
3223 (set_attr "mode" "SI")])
2ae0f82c 3224
8f7661f2
JH
3225(define_insn "*zero_extendqisi2_movzbw"
3226 [(set (match_operand:SI 0 "register_operand" "=r")
3227 (zero_extend:SI (match_operand:QI 1 "nonimmediate_operand" "qm")))]
3228 "(!TARGET_ZERO_EXTEND_WITH_AND || optimize_size) && reload_completed"
0f40f9f7 3229 "movz{bl|x}\t{%1, %0|%0, %1}"
6ef67412
JH
3230 [(set_attr "type" "imovx")
3231 (set_attr "mode" "SI")])
8f7661f2
JH
3232
3233;; For the movzbl case strip only the clobber
3234(define_split
3235 [(set (match_operand:SI 0 "register_operand" "")
3236 (zero_extend:SI (match_operand:QI 1 "nonimmediate_operand" "")))
3237 (clobber (reg:CC 17))]
3238 "reload_completed
3239 && (!TARGET_ZERO_EXTEND_WITH_AND || optimize_size)
1a06f5fe 3240 && (!REG_P (operands[1]) || ANY_QI_REG_P (operands[1]))"
8f7661f2
JH
3241 [(set (match_dup 0)
3242 (zero_extend:SI (match_dup 1)))])
3243
3244;; When source and destination does not overlap, clear destination
3245;; first and then do the movb
2ae0f82c
SC
3246(define_split
3247 [(set (match_operand:SI 0 "register_operand" "")
e075ae69
RH
3248 (zero_extend:SI (match_operand:QI 1 "nonimmediate_operand" "")))
3249 (clobber (reg:CC 17))]
3250 "reload_completed
1a06f5fe
JH
3251 && ANY_QI_REG_P (operands[0])
3252 && (ANY_QI_REG_P (operands[1]) || GET_CODE (operands[1]) == MEM)
8f7661f2 3253 && (TARGET_ZERO_EXTEND_WITH_AND && !optimize_size)
e075ae69 3254 && !reg_overlap_mentioned_p (operands[0], operands[1])"
8f7661f2
JH
3255 [(set (match_dup 0) (const_int 0))
3256 (set (strict_low_part (match_dup 2)) (match_dup 1))]
3257 "operands[2] = gen_lowpart (QImode, operands[0]);")
2ae0f82c 3258
8f7661f2 3259;; Rest is handled by single and.
2ae0f82c
SC
3260(define_split
3261 [(set (match_operand:SI 0 "register_operand" "")
e075ae69
RH
3262 (zero_extend:SI (match_operand:QI 1 "register_operand" "")))
3263 (clobber (reg:CC 17))]
3264 "reload_completed
8f7661f2
JH
3265 && true_regnum (operands[0]) == true_regnum (operands[1])"
3266 [(parallel [(set (match_dup 0) (and:SI (match_dup 0) (const_int 255)))
e075ae69
RH
3267 (clobber (reg:CC 17))])]
3268 "")
2ae0f82c 3269
e075ae69 3270;; %%% Kill me once multi-word ops are sane.
123bf9e3
JH
3271(define_expand "zero_extendsidi2"
3272 [(set (match_operand:DI 0 "register_operand" "=r")
3273 (zero_extend:DI (match_operand:SI 1 "nonimmediate_operand" "rm")))]
3274 ""
3275 "if (!TARGET_64BIT)
3276 {
3277 emit_insn (gen_zero_extendsidi2_32 (operands[0], operands[1]));
3278 DONE;
3279 }
3280 ")
3281
3282(define_insn "zero_extendsidi2_32"
bb62e19a 3283 [(set (match_operand:DI 0 "nonimmediate_operand" "=r,?r,?*o")
123bf9e3 3284 (zero_extend:DI (match_operand:SI 1 "nonimmediate_operand" "0,rm,r")))
e075ae69 3285 (clobber (reg:CC 17))]
123bf9e3 3286 "!TARGET_64BIT"
6ef67412
JH
3287 "#"
3288 [(set_attr "mode" "SI")])
2ae0f82c 3289
123bf9e3
JH
3290(define_insn "zero_extendsidi2_rex64"
3291 [(set (match_operand:DI 0 "nonimmediate_operand" "=r,o")
3292 (zero_extend:DI (match_operand:SI 1 "nonimmediate_operand" "rm,0")))]
3293 "TARGET_64BIT"
3294 "@
0f40f9f7 3295 mov\t{%k1, %k0|%k0, %k1}
123bf9e3
JH
3296 #"
3297 [(set_attr "type" "imovx,imov")
3298 (set_attr "mode" "SI,DI")])
3299
3300(define_split
3301 [(set (match_operand:DI 0 "memory_operand" "")
3302 (zero_extend:DI (match_dup 0)))]
1b0c37d7 3303 "TARGET_64BIT"
123bf9e3
JH
3304 [(set (match_dup 4) (const_int 0))]
3305 "split_di (&operands[0], 1, &operands[3], &operands[4]);")
3306
bb62e19a
JH
3307(define_split
3308 [(set (match_operand:DI 0 "register_operand" "")
e075ae69
RH
3309 (zero_extend:DI (match_operand:SI 1 "register_operand" "")))
3310 (clobber (reg:CC 17))]
1b0c37d7
ZW
3311 "!TARGET_64BIT && reload_completed
3312 && true_regnum (operands[0]) == true_regnum (operands[1])"
591702de 3313 [(set (match_dup 4) (const_int 0))]
bb62e19a
JH
3314 "split_di (&operands[0], 1, &operands[3], &operands[4]);")
3315
3316(define_split
3317 [(set (match_operand:DI 0 "nonimmediate_operand" "")
e075ae69
RH
3318 (zero_extend:DI (match_operand:SI 1 "general_operand" "")))
3319 (clobber (reg:CC 17))]
1b0c37d7 3320 "!TARGET_64BIT && reload_completed"
bb62e19a 3321 [(set (match_dup 3) (match_dup 1))
591702de 3322 (set (match_dup 4) (const_int 0))]
bb62e19a 3323 "split_di (&operands[0], 1, &operands[3], &operands[4]);")
123bf9e3
JH
3324
3325(define_insn "zero_extendhidi2"
3326 [(set (match_operand:DI 0 "register_operand" "=r,r")
3327 (zero_extend:DI (match_operand:HI 1 "nonimmediate_operand" "r,m")))]
3328 "TARGET_64BIT"
3329 "@
0f40f9f7
ZW
3330 movz{wl|x}\t{%1, %k0|%k0, %1}
3331 movz{wq|x}\t{%1, %0|%0, %1}"
123bf9e3
JH
3332 [(set_attr "type" "imovx")
3333 (set_attr "mode" "SI,DI")])
3334
3335(define_insn "zero_extendqidi2"
3336 [(set (match_operand:DI 0 "register_operand" "=r,r")
3337 (zero_extend:DI (match_operand:QI 1 "nonimmediate_operand" "Q,m")))]
3338 "TARGET_64BIT"
3339 "@
0f40f9f7
ZW
3340 movz{bl|x}\t{%1, %k0|%k0, %1}
3341 movz{bq|x}\t{%1, %0|%0, %1}"
123bf9e3
JH
3342 [(set_attr "type" "imovx")
3343 (set_attr "mode" "SI,DI")])
886c62d1 3344\f
e075ae69 3345;; Sign extension instructions
886c62d1 3346
123bf9e3
JH
3347(define_expand "extendsidi2"
3348 [(parallel [(set (match_operand:DI 0 "register_operand" "")
3349 (sign_extend:DI (match_operand:SI 1 "register_operand" "")))
3350 (clobber (reg:CC 17))
3351 (clobber (match_scratch:SI 2 ""))])]
3352 ""
123bf9e3
JH
3353{
3354 if (TARGET_64BIT)
3355 {
3356 emit_insn (gen_extendsidi2_rex64 (operands[0], operands[1]));
3357 DONE;
3358 }
0f40f9f7 3359})
123bf9e3
JH
3360
3361(define_insn "*extendsidi2_1"
e075ae69
RH
3362 [(set (match_operand:DI 0 "nonimmediate_operand" "=*A,r,?r,?*o")
3363 (sign_extend:DI (match_operand:SI 1 "register_operand" "0,0,r,r")))
6b29b0e2
JW
3364 (clobber (reg:CC 17))
3365 (clobber (match_scratch:SI 2 "=X,X,X,&r"))]
123bf9e3 3366 "!TARGET_64BIT"
724d568a
JH
3367 "#")
3368
123bf9e3
JH
3369(define_insn "extendsidi2_rex64"
3370 [(set (match_operand:DI 0 "register_operand" "=*a,r")
3371 (sign_extend:DI (match_operand:SI 1 "nonimmediate_operand" "*0,rm")))]
3372 "TARGET_64BIT"
3373 "@
3374 {cltq|cdqe}
0f40f9f7 3375 movs{lq|x}\t{%1,%0|%0, %1}"
123bf9e3
JH
3376 [(set_attr "type" "imovx")
3377 (set_attr "mode" "DI")
3378 (set_attr "prefix_0f" "0")
3379 (set_attr "modrm" "0,1")])
3380
3381(define_insn "extendhidi2"
3382 [(set (match_operand:DI 0 "register_operand" "=r")
3383 (sign_extend:DI (match_operand:HI 1 "nonimmediate_operand" "rm")))]
3384 "TARGET_64BIT"
0f40f9f7 3385 "movs{wq|x}\t{%1,%0|%0, %1}"
123bf9e3
JH
3386 [(set_attr "type" "imovx")
3387 (set_attr "mode" "DI")])
3388
3389(define_insn "extendqidi2"
3390 [(set (match_operand:DI 0 "register_operand" "=r")
3391 (sign_extend:DI (match_operand:QI 1 "nonimmediate_operand" "qm")))]
3392 "TARGET_64BIT"
0f40f9f7 3393 "movs{bq|x}\t{%1,%0|%0, %1}"
123bf9e3
JH
3394 [(set_attr "type" "imovx")
3395 (set_attr "mode" "DI")])
3396
724d568a
JH
3397;; Extend to memory case when source register does die.
3398(define_split
3399 [(set (match_operand:DI 0 "memory_operand" "")
3400 (sign_extend:DI (match_operand:SI 1 "register_operand" "")))
6b29b0e2
JW
3401 (clobber (reg:CC 17))
3402 (clobber (match_operand:SI 2 "register_operand" ""))]
d7a29404 3403 "(reload_completed
724d568a
JH
3404 && dead_or_set_p (insn, operands[1])
3405 && !reg_mentioned_p (operands[1], operands[0]))"
3406 [(set (match_dup 3) (match_dup 1))
e075ae69
RH
3407 (parallel [(set (match_dup 1) (ashiftrt:SI (match_dup 1) (const_int 31)))
3408 (clobber (reg:CC 17))])
724d568a
JH
3409 (set (match_dup 4) (match_dup 1))]
3410 "split_di (&operands[0], 1, &operands[3], &operands[4]);")
3411
3412;; Extend to memory case when source register does not die.
3413(define_split
3414 [(set (match_operand:DI 0 "memory_operand" "")
3415 (sign_extend:DI (match_operand:SI 1 "register_operand" "")))
6b29b0e2
JW
3416 (clobber (reg:CC 17))
3417 (clobber (match_operand:SI 2 "register_operand" ""))]
d7a29404 3418 "reload_completed"
724d568a 3419 [(const_int 0)]
9c530261 3420{
724d568a
JH
3421 split_di (&operands[0], 1, &operands[3], &operands[4]);
3422
3423 emit_move_insn (operands[3], operands[1]);
3424
3425 /* Generate a cltd if possible and doing so it profitable. */
3426 if (true_regnum (operands[1]) == 0
3427 && true_regnum (operands[2]) == 1
e075ae69 3428 && (optimize_size || TARGET_USE_CLTD))
71a247f0 3429 {
e075ae69 3430 emit_insn (gen_ashrsi3_31 (operands[2], operands[1], GEN_INT (31)));
724d568a
JH
3431 }
3432 else
3433 {
3434 emit_move_insn (operands[2], operands[1]);
e075ae69 3435 emit_insn (gen_ashrsi3_31 (operands[2], operands[2], GEN_INT (31)));
71a247f0 3436 }
724d568a
JH
3437 emit_move_insn (operands[4], operands[2]);
3438 DONE;
0f40f9f7 3439})
9c530261 3440
724d568a
JH
3441;; Extend to register case. Optimize case where source and destination
3442;; registers match and cases where we can use cltd.
3443(define_split
3444 [(set (match_operand:DI 0 "register_operand" "")
3445 (sign_extend:DI (match_operand:SI 1 "register_operand" "")))
6b29b0e2
JW
3446 (clobber (reg:CC 17))
3447 (clobber (match_scratch:SI 2 ""))]
724d568a
JH
3448 "reload_completed"
3449 [(const_int 0)]
724d568a
JH
3450{
3451 split_di (&operands[0], 1, &operands[3], &operands[4]);
3452
3453 if (true_regnum (operands[3]) != true_regnum (operands[1]))
3454 emit_move_insn (operands[3], operands[1]);
9c530261 3455
724d568a
JH
3456 /* Generate a cltd if possible and doing so it profitable. */
3457 if (true_regnum (operands[3]) == 0
e075ae69 3458 && (optimize_size || TARGET_USE_CLTD))
724d568a 3459 {
e075ae69 3460 emit_insn (gen_ashrsi3_31 (operands[4], operands[3], GEN_INT (31)));
724d568a
JH
3461 DONE;
3462 }
3463
3464 if (true_regnum (operands[4]) != true_regnum (operands[1]))
3465 emit_move_insn (operands[4], operands[1]);
3466
e075ae69 3467 emit_insn (gen_ashrsi3_31 (operands[4], operands[4], GEN_INT (31)));
724d568a 3468 DONE;
0f40f9f7 3469})
886c62d1 3470
886c62d1 3471(define_insn "extendhisi2"
e075ae69
RH
3472 [(set (match_operand:SI 0 "register_operand" "=*a,r")
3473 (sign_extend:SI (match_operand:HI 1 "nonimmediate_operand" "*0,rm")))]
886c62d1 3474 ""
886c62d1 3475{
6ef67412 3476 switch (get_attr_prefix_0f (insn))
e075ae69 3477 {
6ef67412 3478 case 0:
0f40f9f7 3479 return "{cwtl|cwde}";
e075ae69 3480 default:
0f40f9f7 3481 return "movs{wl|x}\t{%1,%0|%0, %1}";
e075ae69 3482 }
0f40f9f7 3483}
e075ae69 3484 [(set_attr "type" "imovx")
6ef67412
JH
3485 (set_attr "mode" "SI")
3486 (set (attr "prefix_0f")
3487 ;; movsx is short decodable while cwtl is vector decoded.
3488 (if_then_else (and (eq_attr "cpu" "!k6")
3489 (eq_attr "alternative" "0"))
3490 (const_string "0")
3491 (const_string "1")))
3492 (set (attr "modrm")
3493 (if_then_else (eq_attr "prefix_0f" "0")
3494 (const_string "0")
3495 (const_string "1")))])
886c62d1 3496
123bf9e3
JH
3497(define_insn "*extendhisi2_zext"
3498 [(set (match_operand:DI 0 "register_operand" "=*a,r")
3499 (zero_extend:DI
3500 (sign_extend:SI (match_operand:HI 1 "nonimmediate_operand" "*0,rm"))))]
3501 "TARGET_64BIT"
123bf9e3
JH
3502{
3503 switch (get_attr_prefix_0f (insn))
3504 {
3505 case 0:
0f40f9f7 3506 return "{cwtl|cwde}";
123bf9e3 3507 default:
0f40f9f7 3508 return "movs{wl|x}\t{%1,%k0|%k0, %1}";
123bf9e3 3509 }
0f40f9f7 3510}
123bf9e3
JH
3511 [(set_attr "type" "imovx")
3512 (set_attr "mode" "SI")
3513 (set (attr "prefix_0f")
3514 ;; movsx is short decodable while cwtl is vector decoded.
3515 (if_then_else (and (eq_attr "cpu" "!k6")
3516 (eq_attr "alternative" "0"))
3517 (const_string "0")
3518 (const_string "1")))
3519 (set (attr "modrm")
3520 (if_then_else (eq_attr "prefix_0f" "0")
3521 (const_string "0")
3522 (const_string "1")))])
3523
886c62d1 3524(define_insn "extendqihi2"
e075ae69
RH
3525 [(set (match_operand:HI 0 "register_operand" "=*a,r")
3526 (sign_extend:HI (match_operand:QI 1 "nonimmediate_operand" "*0,qm")))]
886c62d1 3527 ""
886c62d1 3528{
6ef67412 3529 switch (get_attr_prefix_0f (insn))
e075ae69 3530 {
6ef67412 3531 case 0:
0f40f9f7 3532 return "{cbtw|cbw}";
e075ae69 3533 default:
0f40f9f7 3534 return "movs{bw|x}\t{%1,%0|%0, %1}";
e075ae69 3535 }
0f40f9f7 3536}
e075ae69 3537 [(set_attr "type" "imovx")
6ef67412
JH
3538 (set_attr "mode" "HI")
3539 (set (attr "prefix_0f")
3540 ;; movsx is short decodable while cwtl is vector decoded.
3541 (if_then_else (and (eq_attr "cpu" "!k6")
3542 (eq_attr "alternative" "0"))
3543 (const_string "0")
3544 (const_string "1")))
3545 (set (attr "modrm")
3546 (if_then_else (eq_attr "prefix_0f" "0")
3547 (const_string "0")
3548 (const_string "1")))])
886c62d1
JVA
3549
3550(define_insn "extendqisi2"
2ae0f82c
SC
3551 [(set (match_operand:SI 0 "register_operand" "=r")
3552 (sign_extend:SI (match_operand:QI 1 "nonimmediate_operand" "qm")))]
886c62d1 3553 ""
0f40f9f7 3554 "movs{bl|x}\t{%1,%0|%0, %1}"
6ef67412
JH
3555 [(set_attr "type" "imovx")
3556 (set_attr "mode" "SI")])
123bf9e3
JH
3557
3558(define_insn "*extendqisi2_zext"
3559 [(set (match_operand:DI 0 "register_operand" "=r")
3560 (zero_extend:DI
3561 (sign_extend:SI (match_operand:QI 1 "nonimmediate_operand" "qm"))))]
3562 "TARGET_64BIT"
0f40f9f7 3563 "movs{bl|x}\t{%1,%k0|%k0, %1}"
123bf9e3
JH
3564 [(set_attr "type" "imovx")
3565 (set_attr "mode" "SI")])
886c62d1
JVA
3566\f
3567;; Conversions between float and double.
3568
e075ae69
RH
3569;; These are all no-ops in the model used for the 80387. So just
3570;; emit moves.
6a4a5d95 3571
e075ae69 3572;; %%% Kill these when call knows how to work out a DFmode push earlier.
6343a50e 3573(define_insn "*dummy_extendsfdf2"
e075ae69 3574 [(set (match_operand:DF 0 "push_operand" "=<")
42a0aa6f 3575 (float_extend:DF (match_operand:SF 1 "nonimmediate_operand" "fY")))]
e075ae69
RH
3576 "0"
3577 "#")
6a4a5d95
JW
3578
3579(define_split
e075ae69 3580 [(set (match_operand:DF 0 "push_operand" "")
c3c637e3
GS
3581 (float_extend:DF (match_operand:SF 1 "fp_register_operand" "")))]
3582 "!TARGET_64BIT"
e075ae69
RH
3583 [(set (reg:SI 7) (plus:SI (reg:SI 7) (const_int -8)))
3584 (set (mem:DF (reg:SI 7)) (float_extend:DF (match_dup 1)))])
0fcad513 3585
123bf9e3
JH
3586(define_split
3587 [(set (match_operand:DF 0 "push_operand" "")
c3c637e3
GS
3588 (float_extend:DF (match_operand:SF 1 "fp_register_operand" "")))]
3589 "TARGET_64BIT"
123bf9e3
JH
3590 [(set (reg:DI 7) (plus:DI (reg:DI 7) (const_int -8)))
3591 (set (mem:DF (reg:DI 7)) (float_extend:DF (match_dup 1)))])
3592
6343a50e 3593(define_insn "*dummy_extendsfxf2"
e075ae69
RH
3594 [(set (match_operand:XF 0 "push_operand" "=<")
3595 (float_extend:XF (match_operand:SF 1 "nonimmediate_operand" "f")))]
3596 "0"
3597 "#")
e4ad1003
JW
3598
3599(define_split
e075ae69 3600 [(set (match_operand:XF 0 "push_operand" "")
c3c637e3
GS
3601 (float_extend:XF (match_operand:SF 1 "fp_register_operand" "")))]
3602 "!TARGET_64BIT"
e075ae69 3603 [(set (reg:SI 7) (plus:SI (reg:SI 7) (const_int -12)))
2b589241
JH
3604 (set (mem:XF (reg:SI 7)) (float_extend:XF (match_dup 1)))])
3605
3606(define_insn "*dummy_extendsftf2"
3607 [(set (match_operand:TF 0 "push_operand" "=<")
3608 (float_extend:TF (match_operand:SF 1 "nonimmediate_operand" "f")))]
3609 "0"
3610 "#")
3611
3612(define_split
3613 [(set (match_operand:TF 0 "push_operand" "")
c3c637e3
GS
3614 (float_extend:TF (match_operand:SF 1 "fp_register_operand" "")))]
3615 "!TARGET_64BIT"
2b589241 3616 [(set (reg:SI 7) (plus:SI (reg:SI 7) (const_int -16)))
123bf9e3
JH
3617 (set (mem:TF (reg:SI 7)) (float_extend:TF (match_dup 1)))])
3618
3619(define_split
3620 [(set (match_operand:TF 0 "push_operand" "")
c3c637e3
GS
3621 (float_extend:TF (match_operand:SF 1 "fp_register_operand" "")))]
3622 "TARGET_64BIT"
123bf9e3
JH
3623 [(set (reg:DI 7) (plus:DI (reg:DI 7) (const_int -16)))
3624 (set (mem:DF (reg:DI 7)) (float_extend:TF (match_dup 1)))])
4fb21e90 3625
6343a50e 3626(define_insn "*dummy_extenddfxf2"
e075ae69
RH
3627 [(set (match_operand:XF 0 "push_operand" "=<")
3628 (float_extend:XF (match_operand:DF 1 "nonimmediate_operand" "f")))]
3629 "0"
3630 "#")
e4ad1003
JW
3631
3632(define_split
e075ae69 3633 [(set (match_operand:XF 0 "push_operand" "")
c3c637e3
GS
3634 (float_extend:XF (match_operand:DF 1 "fp_register_operand" "")))]
3635 "!TARGET_64BIT"
e075ae69 3636 [(set (reg:SI 7) (plus:SI (reg:SI 7) (const_int -12)))
123bf9e3 3637 (set (mem:DF (reg:SI 7)) (float_extend:XF (match_dup 1)))])
2b589241
JH
3638
3639(define_insn "*dummy_extenddftf2"
3640 [(set (match_operand:TF 0 "push_operand" "=<")
3641 (float_extend:TF (match_operand:DF 1 "nonimmediate_operand" "f")))]
3642 "0"
3643 "#")
3644
3645(define_split
3646 [(set (match_operand:TF 0 "push_operand" "")
c3c637e3
GS
3647 (float_extend:TF (match_operand:DF 1 "fp_register_operand" "")))]
3648 "!TARGET_64BIT"
2b589241
JH
3649 [(set (reg:SI 7) (plus:SI (reg:SI 7) (const_int -16)))
3650 (set (mem:TF (reg:SI 7)) (float_extend:XF (match_dup 1)))])
4fb21e90 3651
123bf9e3
JH
3652(define_split
3653 [(set (match_operand:TF 0 "push_operand" "")
c3c637e3
GS
3654 (float_extend:TF (match_operand:DF 1 "fp_register_operand" "")))]
3655 "TARGET_64BIT"
123bf9e3 3656 [(set (reg:DI 7) (plus:DI (reg:DI 7) (const_int -16)))
a2bafd20 3657 (set (mem:TF (reg:DI 7)) (float_extend:TF (match_dup 1)))])
123bf9e3 3658
f97d9ec3
JH
3659(define_expand "extendsfdf2"
3660 [(set (match_operand:DF 0 "nonimmediate_operand" "")
51286de6 3661 (float_extend:DF (match_operand:SF 1 "general_operand" "")))]
42a0aa6f 3662 "TARGET_80387 || TARGET_SSE2"
f97d9ec3 3663{
51286de6
RH
3664 /* ??? Needed for compress_float_constant since all fp constants
3665 are LEGITIMATE_CONSTANT_P. */
3666 if (GET_CODE (operands[1]) == CONST_DOUBLE)
3667 operands[1] = validize_mem (force_const_mem (SFmode, operands[1]));
f97d9ec3 3668 if (GET_CODE (operands[0]) == MEM && GET_CODE (operands[1]) == MEM)
34289d57 3669 operands[1] = force_reg (SFmode, operands[1]);
0f40f9f7 3670})
f97d9ec3
JH
3671
3672(define_insn "*extendsfdf2_1"
a811cc63
JH
3673 [(set (match_operand:DF 0 "nonimmediate_operand" "=f#Y,mf#Y,Y#f")
3674 (float_extend:DF (match_operand:SF 1 "nonimmediate_operand" "fm#Y,f#Y,mY#f")))]
42a0aa6f 3675 "(TARGET_80387 || TARGET_SSE2)
f97d9ec3 3676 && (GET_CODE (operands[0]) != MEM || GET_CODE (operands[1]) != MEM)"
4fb21e90 3677{
e075ae69 3678 switch (which_alternative)
4fb21e90 3679 {
e075ae69 3680 case 0:
0c174a68
AB
3681 if (REG_P (operands[1])
3682 && find_regno_note (insn, REG_DEAD, REGNO (operands[1])))
0f40f9f7 3683 return "fstp\t%y0";
e075ae69 3684 else if (STACK_TOP_P (operands[0]))
0f40f9f7 3685 return "fld%z1\t%y1";
e075ae69 3686 else
0f40f9f7 3687 return "fst\t%y0";
886c62d1 3688
e075ae69
RH
3689 case 1:
3690 if (find_regno_note (insn, REG_DEAD, REGNO (operands[1])))
0f40f9f7 3691 return "fstp%z0\t%y0";
10195bd8 3692
e075ae69 3693 else
0f40f9f7 3694 return "fst%z0\t%y0";
42a0aa6f 3695 case 2:
0f40f9f7 3696 return "cvtss2sd\t{%1, %0|%0, %1}";
4fb21e90 3697
e075ae69
RH
3698 default:
3699 abort ();
3700 }
0f40f9f7 3701}
3d34cd91 3702 [(set_attr "type" "fmov,fmov,ssecvt")
a811cc63 3703 (set_attr "mode" "SF,XF,DF")])
42a0aa6f
JH
3704
3705(define_insn "*extendsfdf2_1_sse_only"
3706 [(set (match_operand:DF 0 "register_operand" "=Y")
3707 (float_extend:DF (match_operand:SF 1 "nonimmediate_operand" "mY")))]
3708 "!TARGET_80387 && TARGET_SSE2
3709 && (GET_CODE (operands[0]) != MEM || GET_CODE (operands[1]) != MEM)"
0f40f9f7 3710 "cvtss2sd\t{%1, %0|%0, %1}"
3d34cd91 3711 [(set_attr "type" "ssecvt")
42a0aa6f 3712 (set_attr "mode" "DF")])
e075ae69 3713
f97d9ec3
JH
3714(define_expand "extendsfxf2"
3715 [(set (match_operand:XF 0 "nonimmediate_operand" "")
51286de6 3716 (float_extend:XF (match_operand:SF 1 "general_operand" "")))]
1b0c37d7 3717 "!TARGET_64BIT && TARGET_80387"
f97d9ec3 3718{
51286de6
RH
3719 /* ??? Needed for compress_float_constant since all fp constants
3720 are LEGITIMATE_CONSTANT_P. */
3721 if (GET_CODE (operands[1]) == CONST_DOUBLE)
3722 operands[1] = validize_mem (force_const_mem (SFmode, operands[1]));
f97d9ec3 3723 if (GET_CODE (operands[0]) == MEM && GET_CODE (operands[1]) == MEM)
34289d57 3724 operands[1] = force_reg (SFmode, operands[1]);
0f40f9f7 3725})
f97d9ec3
JH
3726
3727(define_insn "*extendsfxf2_1"
e075ae69
RH
3728 [(set (match_operand:XF 0 "nonimmediate_operand" "=f,m")
3729 (float_extend:XF (match_operand:SF 1 "nonimmediate_operand" "fm,f")))]
1b0c37d7 3730 "!TARGET_64BIT && TARGET_80387
f97d9ec3 3731 && (GET_CODE (operands[0]) != MEM || GET_CODE (operands[1]) != MEM)"
10195bd8 3732{
e075ae69
RH
3733 switch (which_alternative)
3734 {
3735 case 0:
0c174a68
AB
3736 if (REG_P (operands[1])
3737 && find_regno_note (insn, REG_DEAD, REGNO (operands[1])))
0f40f9f7 3738 return "fstp\t%y0";
e075ae69 3739 else if (STACK_TOP_P (operands[0]))
0f40f9f7 3740 return "fld%z1\t%y1";
e075ae69 3741 else
0f40f9f7 3742 return "fst\t%y0";
886c62d1 3743
e075ae69
RH
3744 case 1:
3745 /* There is no non-popping store to memory for XFmode. So if
3746 we need one, follow the store with a load. */
3747 if (! find_regno_note (insn, REG_DEAD, REGNO (operands[1])))
0f40f9f7 3748 return "fstp%z0\t%y0\n\tfld%z0\t%y0";
e075ae69 3749 else
0f40f9f7 3750 return "fstp%z0\t%y0";
886c62d1 3751
e075ae69
RH
3752 default:
3753 abort ();
3754 }
0f40f9f7 3755}
6ef67412
JH
3756 [(set_attr "type" "fmov")
3757 (set_attr "mode" "SF,XF")])
886c62d1 3758
2b589241
JH
3759(define_expand "extendsftf2"
3760 [(set (match_operand:TF 0 "nonimmediate_operand" "")
51286de6 3761 (float_extend:TF (match_operand:SF 1 "general_operand" "")))]
2b589241 3762 "TARGET_80387"
2b589241 3763{
51286de6
RH
3764 /* ??? Needed for compress_float_constant since all fp constants
3765 are LEGITIMATE_CONSTANT_P. */
3766 if (GET_CODE (operands[1]) == CONST_DOUBLE)
3767 operands[1] = validize_mem (force_const_mem (SFmode, operands[1]));
2b589241
JH
3768 if (GET_CODE (operands[0]) == MEM && GET_CODE (operands[1]) == MEM)
3769 operands[1] = force_reg (SFmode, operands[1]);
0f40f9f7 3770})
2b589241
JH
3771
3772(define_insn "*extendsftf2_1"
3773 [(set (match_operand:TF 0 "nonimmediate_operand" "=f,m")
3774 (float_extend:TF (match_operand:SF 1 "nonimmediate_operand" "fm,f")))]
3775 "TARGET_80387
3776 && (GET_CODE (operands[0]) != MEM || GET_CODE (operands[1]) != MEM)"
2b589241
JH
3777{
3778 switch (which_alternative)
3779 {
3780 case 0:
3781 if (REG_P (operands[1])
3782 && find_regno_note (insn, REG_DEAD, REGNO (operands[1])))
0f40f9f7 3783 return "fstp\t%y0";
2b589241 3784 else if (STACK_TOP_P (operands[0]))
0f40f9f7 3785 return "fld%z1\t%y1";
2b589241 3786 else
0f40f9f7 3787 return "fst\t%y0";
2b589241
JH
3788
3789 case 1:
3790 /* There is no non-popping store to memory for XFmode. So if
3791 we need one, follow the store with a load. */
3792 if (! find_regno_note (insn, REG_DEAD, REGNO (operands[1])))
0f40f9f7 3793 return "fstp%z0\t%y0\n\tfld%z0\t%y0";
2b589241 3794 else
0f40f9f7 3795 return "fstp%z0\t%y0";
2b589241
JH
3796
3797 default:
3798 abort ();
3799 }
0f40f9f7 3800}
2b589241
JH
3801 [(set_attr "type" "fmov")
3802 (set_attr "mode" "SF,XF")])
3803
f97d9ec3
JH
3804(define_expand "extenddfxf2"
3805 [(set (match_operand:XF 0 "nonimmediate_operand" "")
51286de6 3806 (float_extend:XF (match_operand:DF 1 "general_operand" "")))]
1b0c37d7 3807 "!TARGET_64BIT && TARGET_80387"
f97d9ec3 3808{
51286de6
RH
3809 /* ??? Needed for compress_float_constant since all fp constants
3810 are LEGITIMATE_CONSTANT_P. */
3811 if (GET_CODE (operands[1]) == CONST_DOUBLE)
110b3faa 3812 operands[1] = validize_mem (force_const_mem (DFmode, operands[1]));
f97d9ec3 3813 if (GET_CODE (operands[0]) == MEM && GET_CODE (operands[1]) == MEM)
34289d57 3814 operands[1] = force_reg (DFmode, operands[1]);
0f40f9f7 3815})
f97d9ec3
JH
3816
3817(define_insn "*extenddfxf2_1"
e075ae69
RH
3818 [(set (match_operand:XF 0 "nonimmediate_operand" "=f,m")
3819 (float_extend:XF (match_operand:DF 1 "nonimmediate_operand" "fm,f")))]
1b0c37d7 3820 "!TARGET_64BIT && TARGET_80387
f97d9ec3 3821 && (GET_CODE (operands[0]) != MEM || GET_CODE (operands[1]) != MEM)"
e075ae69
RH
3822{
3823 switch (which_alternative)
3824 {
3825 case 0:
0c174a68
AB
3826 if (REG_P (operands[1])
3827 && find_regno_note (insn, REG_DEAD, REGNO (operands[1])))
0f40f9f7 3828 return "fstp\t%y0";
e075ae69 3829 else if (STACK_TOP_P (operands[0]))
0f40f9f7 3830 return "fld%z1\t%y1";
e075ae69 3831 else
0f40f9f7 3832 return "fst\t%y0";
bc725565 3833
e075ae69
RH
3834 case 1:
3835 /* There is no non-popping store to memory for XFmode. So if
3836 we need one, follow the store with a load. */
3837 if (! find_regno_note (insn, REG_DEAD, REGNO (operands[1])))
0f40f9f7 3838 return "fstp%z0\t%y0\n\tfld%z0\t%y0";
e075ae69 3839 else
0f40f9f7 3840 return "fstp%z0\t%y0";
bc725565 3841
e075ae69
RH
3842 default:
3843 abort ();
3844 }
0f40f9f7 3845}
6ef67412
JH
3846 [(set_attr "type" "fmov")
3847 (set_attr "mode" "DF,XF")])
bc725565 3848
2b589241
JH
3849(define_expand "extenddftf2"
3850 [(set (match_operand:TF 0 "nonimmediate_operand" "")
51286de6 3851 (float_extend:TF (match_operand:DF 1 "general_operand" "")))]
2b589241 3852 "TARGET_80387"
2b589241 3853{
51286de6
RH
3854 /* ??? Needed for compress_float_constant since all fp constants
3855 are LEGITIMATE_CONSTANT_P. */
3856 if (GET_CODE (operands[1]) == CONST_DOUBLE)
110b3faa 3857 operands[1] = validize_mem (force_const_mem (DFmode, operands[1]));
2b589241
JH
3858 if (GET_CODE (operands[0]) == MEM && GET_CODE (operands[1]) == MEM)
3859 operands[1] = force_reg (DFmode, operands[1]);
0f40f9f7 3860})
2b589241
JH
3861
3862(define_insn "*extenddftf2_1"
3863 [(set (match_operand:TF 0 "nonimmediate_operand" "=f,m")
3864 (float_extend:TF (match_operand:DF 1 "nonimmediate_operand" "fm,f")))]
3865 "TARGET_80387
3866 && (GET_CODE (operands[0]) != MEM || GET_CODE (operands[1]) != MEM)"
2b589241
JH
3867{
3868 switch (which_alternative)
3869 {
3870 case 0:
3871 if (REG_P (operands[1])
3872 && find_regno_note (insn, REG_DEAD, REGNO (operands[1])))
0f40f9f7 3873 return "fstp\t%y0";
2b589241 3874 else if (STACK_TOP_P (operands[0]))
0f40f9f7 3875 return "fld%z1\t%y1";
2b589241 3876 else
0f40f9f7 3877 return "fst\t%y0";
2b589241
JH
3878
3879 case 1:
3880 /* There is no non-popping store to memory for XFmode. So if
3881 we need one, follow the store with a load. */
3882 if (! find_regno_note (insn, REG_DEAD, REGNO (operands[1])))
0f40f9f7 3883 return "fstp%z0\t%y0\n\tfld%z0\t%y0";
2b589241 3884 else
0f40f9f7 3885 return "fstp%z0\t%y0";
2b589241
JH
3886
3887 default:
3888 abort ();
3889 }
0f40f9f7 3890}
2b589241
JH
3891 [(set_attr "type" "fmov")
3892 (set_attr "mode" "DF,XF")])
3893
e075ae69
RH
3894;; %%% This seems bad bad news.
3895;; This cannot output into an f-reg because there is no way to be sure
3896;; of truncating in that case. Otherwise this is just like a simple move
3897;; insn. So we pretend we can output to a reg in order to get better
3898;; register preferencing, but we really use a stack slot.
886c62d1 3899
e075ae69
RH
3900(define_expand "truncdfsf2"
3901 [(parallel [(set (match_operand:SF 0 "nonimmediate_operand" "")
3902 (float_truncate:SF
3903 (match_operand:DF 1 "register_operand" "")))
3904 (clobber (match_dup 2))])]
42a0aa6f
JH
3905 "TARGET_80387 || TARGET_SSE2"
3906 "
3907 if (TARGET_80387)
3908 operands[2] = assign_386_stack_local (SFmode, 0);
3909 else
3910 {
3911 emit_insn (gen_truncdfsf2_sse_only (operands[0], operands[1]));
3912 DONE;
3913 }
3914")
bc725565 3915
e075ae69 3916(define_insn "*truncdfsf2_1"
46ed7963 3917 [(set (match_operand:SF 0 "nonimmediate_operand" "=m,?f#rx,?r#fx,?x#rf")
e075ae69 3918 (float_truncate:SF
46ed7963
JH
3919 (match_operand:DF 1 "register_operand" "f,f,f,f")))
3920 (clobber (match_operand:SF 2 "memory_operand" "=X,m,m,m"))]
42a0aa6f 3921 "TARGET_80387 && !TARGET_SSE2"
e075ae69
RH
3922{
3923 switch (which_alternative)
3924 {
3925 case 0:
3926 if (find_regno_note (insn, REG_DEAD, REGNO (operands[1])))
0f40f9f7 3927 return "fstp%z0\t%y0";
e075ae69 3928 else
0f40f9f7 3929 return "fst%z0\t%y0";
46ed7963
JH
3930 default:
3931 abort ();
e075ae69 3932 }
0f40f9f7 3933}
46ed7963
JH
3934 [(set_attr "type" "fmov,multi,multi,multi")
3935 (set_attr "mode" "SF,SF,SF,SF")])
42a0aa6f
JH
3936
3937(define_insn "*truncdfsf2_1_sse"
4977bab6 3938 [(set (match_operand:SF 0 "nonimmediate_operand" "=*!m#fxr,?f#xr,?r#fx,?x#fr,Y#fr")
42a0aa6f 3939 (float_truncate:SF
4977bab6 3940 (match_operand:DF 1 "nonimmediate_operand" "f#Y,f#Y,f#Y,f#Y,mY#f")))
46ed7963 3941 (clobber (match_operand:SF 2 "memory_operand" "=X,m,m,m,X"))]
4977bab6 3942 "TARGET_80387 && TARGET_SSE2 && !TARGET_SSE_PARTIAL_REGS_FOR_CVTSD2SS"
42a0aa6f
JH
3943{
3944 switch (which_alternative)
3945 {
3946 case 0:
3947 if (find_regno_note (insn, REG_DEAD, REGNO (operands[1])))
0f40f9f7 3948 return "fstp%z0\t%y0";
42a0aa6f 3949 else
0f40f9f7 3950 return "fst%z0\t%y0";
46ed7963 3951 case 4:
4977bab6
ZW
3952 return "#";
3953 default:
3954 abort ();
3955 }
3956}
3957 [(set_attr "type" "fmov,multi,multi,multi,ssecvt")
3958 (set_attr "mode" "SF,SF,SF,SF,DF")])
3959
3960(define_insn "*truncdfsf2_1_sse_nooverlap"
3961 [(set (match_operand:SF 0 "nonimmediate_operand" "=*!m,?f#rx,?r#fx,?x#rf,&Y")
3962 (float_truncate:SF
3963 (match_operand:DF 1 "nonimmediate_operand" "f#Y,f#Y,f#Y,f#Y,mY#f")))
3964 (clobber (match_operand:SF 2 "memory_operand" "=X,m,m,m,X"))]
3965 "TARGET_80387 && TARGET_SSE2 && TARGET_SSE_PARTIAL_REGS_FOR_CVTSD2SS"
3966{
3967 switch (which_alternative)
3968 {
3969 case 0:
3970 if (find_regno_note (insn, REG_DEAD, REGNO (operands[1])))
3971 return "fstp%z0\t%y0";
3972 else
3973 return "fst%z0\t%y0";
3974 case 4:
3975 return "#";
46ed7963
JH
3976 default:
3977 abort ();
42a0aa6f 3978 }
0f40f9f7 3979}
3d34cd91 3980 [(set_attr "type" "fmov,multi,multi,multi,ssecvt")
46ed7963 3981 (set_attr "mode" "SF,SF,SF,SF,DF")])
53b5ce19 3982
e075ae69 3983(define_insn "*truncdfsf2_2"
f56e86bd 3984 [(set (match_operand:SF 0 "nonimmediate_operand" "=Y,Y,!m")
42a0aa6f 3985 (float_truncate:SF
f56e86bd 3986 (match_operand:DF 1 "nonimmediate_operand" "Y,mY,f#Y")))]
4977bab6 3987 "TARGET_80387 && TARGET_SSE2 && !TARGET_SSE_PARTIAL_REGS_FOR_CVTSD2SS
79005df5 3988 && (GET_CODE (operands[0]) != MEM || GET_CODE (operands[1]) != MEM)"
42a0aa6f
JH
3989{
3990 switch (which_alternative)
3991 {
3992 case 0:
79005df5 3993 case 1:
f56e86bd
JH
3994 return "cvtsd2ss\t{%1, %0|%0, %1}";
3995 case 2:
42a0aa6f 3996 if (find_regno_note (insn, REG_DEAD, REGNO (operands[1])))
0f40f9f7 3997 return "fstp%z0\t%y0";
42a0aa6f 3998 else
0f40f9f7
ZW
3999 return "fst%z0\t%y0";
4000 default:
4001 abort ();
42a0aa6f 4002 }
0f40f9f7 4003}
f56e86bd
JH
4004 [(set_attr "type" "ssecvt,ssecvt,fmov")
4005 (set_attr "athlon_decode" "vector,double,*")
4006 (set_attr "mode" "DF,DF,SF")])
42a0aa6f 4007
4977bab6
ZW
4008(define_insn "*truncdfsf2_2_nooverlap"
4009 [(set (match_operand:SF 0 "nonimmediate_operand" "=&Y,!m")
4010 (float_truncate:SF
4011 (match_operand:DF 1 "nonimmediate_operand" "mY,f")))]
4012 "TARGET_80387 && TARGET_SSE2 && TARGET_SSE_PARTIAL_REGS_FOR_CVTSD2SS
4013 && (GET_CODE (operands[0]) != MEM || GET_CODE (operands[1]) != MEM)"
4014{
4015 switch (which_alternative)
4016 {
4017 case 0:
4018 return "#";
4019 case 1:
4020 if (find_regno_note (insn, REG_DEAD, REGNO (operands[1])))
4021 return "fstp%z0\t%y0";
4022 else
4023 return "fst%z0\t%y0";
4024 default:
4025 abort ();
4026 }
4027}
4028 [(set_attr "type" "ssecvt,fmov")
4029 (set_attr "mode" "DF,SF")])
4030
4031(define_insn "*truncdfsf2_3"
cc2e591b 4032 [(set (match_operand:SF 0 "memory_operand" "=m")
e075ae69
RH
4033 (float_truncate:SF
4034 (match_operand:DF 1 "register_operand" "f")))]
53b5ce19 4035 "TARGET_80387"
e075ae69
RH
4036{
4037 if (find_regno_note (insn, REG_DEAD, REGNO (operands[1])))
0f40f9f7 4038 return "fstp%z0\t%y0";
e075ae69 4039 else
0f40f9f7
ZW
4040 return "fst%z0\t%y0";
4041}
6ef67412
JH
4042 [(set_attr "type" "fmov")
4043 (set_attr "mode" "SF")])
53b5ce19 4044
42a0aa6f 4045(define_insn "truncdfsf2_sse_only"
f56e86bd 4046 [(set (match_operand:SF 0 "register_operand" "=Y,Y")
42a0aa6f 4047 (float_truncate:SF
f56e86bd 4048 (match_operand:DF 1 "nonimmediate_operand" "Y,mY")))]
4977bab6 4049 "!TARGET_80387 && TARGET_SSE2 && !TARGET_SSE_PARTIAL_REGS_FOR_CVTSD2SS"
0f40f9f7 4050 "cvtsd2ss\t{%1, %0|%0, %1}"
3d34cd91 4051 [(set_attr "type" "ssecvt")
f56e86bd 4052 (set_attr "athlon_decode" "vector,double")
42a0aa6f
JH
4053 (set_attr "mode" "DF")])
4054
4977bab6
ZW
4055(define_insn "*truncdfsf2_sse_only_nooverlap"
4056 [(set (match_operand:SF 0 "register_operand" "=&Y")
4057 (float_truncate:SF
4058 (match_operand:DF 1 "nonimmediate_operand" "mY")))]
4059 "!TARGET_80387 && TARGET_SSE2 && TARGET_SSE_PARTIAL_REGS_FOR_CVTSD2SS"
4060 "#"
4061 [(set_attr "type" "ssecvt")
4062 (set_attr "mode" "DF")])
4063
53b5ce19 4064(define_split
e075ae69
RH
4065 [(set (match_operand:SF 0 "memory_operand" "")
4066 (float_truncate:SF
4067 (match_operand:DF 1 "register_operand" "")))
4068 (clobber (match_operand:SF 2 "memory_operand" ""))]
4069 "TARGET_80387"
4070 [(set (match_dup 0) (float_truncate:SF (match_dup 1)))]
53b5ce19
JW
4071 "")
4072
d1f87653 4073; Avoid possible reformatting penalty on the destination by first
4977bab6 4074; zeroing it out
42a0aa6f 4075(define_split
4977bab6 4076 [(set (match_operand:SF 0 "register_operand" "")
42a0aa6f
JH
4077 (float_truncate:SF
4078 (match_operand:DF 1 "nonimmediate_operand" "")))
4079 (clobber (match_operand 2 "" ""))]
05b432db 4080 "TARGET_80387 && reload_completed
4977bab6
ZW
4081 && SSE_REG_P (operands[0])
4082 && !STACK_REG_P (operands[1])"
4083 [(const_int 0)]
4084{
4085 rtx src, dest;
4086 if (!TARGET_SSE_PARTIAL_REGS_FOR_CVTSD2SS)
4087 emit_insn (gen_truncdfsf2_sse_only (operands[0], operands[1]));
4088 else
4089 {
4090 dest = simplify_gen_subreg (V4SFmode, operands[0], SFmode, 0);
4091 src = simplify_gen_subreg (V2DFmode, operands[1], DFmode, 0);
4092 /* simplify_gen_subreg refuses to widen memory references. */
4093 if (GET_CODE (src) == SUBREG)
4094 alter_subreg (&src);
4095 if (reg_overlap_mentioned_p (operands[0], operands[1]))
4096 abort ();
4097 emit_insn (gen_sse_clrv4sf (dest, CONST0_RTX (V4SFmode)));
4098 emit_insn (gen_cvtsd2ss (dest, dest, src));
4099 }
4100 DONE;
4101})
4102
4103(define_split
4104 [(set (match_operand:SF 0 "register_operand" "")
4105 (float_truncate:SF
4106 (match_operand:DF 1 "nonimmediate_operand" "")))]
4107 "TARGET_80387 && reload_completed
4108 && SSE_REG_P (operands[0]) && TARGET_SSE_PARTIAL_REGS_FOR_CVTSD2SS"
4109 [(const_int 0)]
4110{
4111 rtx src, dest;
4112 dest = simplify_gen_subreg (V4SFmode, operands[0], SFmode, 0);
4113 src = simplify_gen_subreg (V2DFmode, operands[1], DFmode, 0);
4114 /* simplify_gen_subreg refuses to widen memory references. */
4115 if (GET_CODE (src) == SUBREG)
4116 alter_subreg (&src);
4117 if (reg_overlap_mentioned_p (operands[0], operands[1]))
4118 abort ();
4119 emit_insn (gen_sse_clrv4sf (dest, CONST0_RTX (V4SFmode)));
4120 emit_insn (gen_cvtsd2ss (dest, dest, src));
4121 DONE;
4122})
42a0aa6f 4123
53b5ce19
JW
4124(define_split
4125 [(set (match_operand:SF 0 "register_operand" "")
e075ae69 4126 (float_truncate:SF
c3c637e3 4127 (match_operand:DF 1 "fp_register_operand" "")))
e075ae69 4128 (clobber (match_operand:SF 2 "memory_operand" ""))]
c3c637e3 4129 "TARGET_80387 && reload_completed"
e075ae69
RH
4130 [(set (match_dup 2) (float_truncate:SF (match_dup 1)))
4131 (set (match_dup 0) (match_dup 2))]
53b5ce19
JW
4132 "")
4133
e075ae69
RH
4134(define_expand "truncxfsf2"
4135 [(parallel [(set (match_operand:SF 0 "nonimmediate_operand" "")
4136 (float_truncate:SF
4137 (match_operand:XF 1 "register_operand" "")))
4138 (clobber (match_dup 2))])]
1b0c37d7 4139 "!TARGET_64BIT && TARGET_80387"
e075ae69 4140 "operands[2] = assign_386_stack_local (SFmode, 0);")
53b5ce19 4141
e075ae69 4142(define_insn "*truncxfsf2_1"
46ed7963 4143 [(set (match_operand:SF 0 "nonimmediate_operand" "=m,?f#rx,?r#fx,?x#rf")
e075ae69 4144 (float_truncate:SF
46ed7963
JH
4145 (match_operand:XF 1 "register_operand" "f,f,f,f")))
4146 (clobber (match_operand:SF 2 "memory_operand" "=X,m,m,m"))]
1b0c37d7 4147 "!TARGET_64BIT && TARGET_80387"
e075ae69
RH
4148{
4149 switch (which_alternative)
4150 {
4151 case 0:
4152 if (find_regno_note (insn, REG_DEAD, REGNO (operands[1])))
0f40f9f7 4153 return "fstp%z0\t%y0";
e075ae69 4154 else
0f40f9f7 4155 return "fst%z0\t%y0";
46ed7963
JH
4156 default:
4157 abort();
e075ae69 4158 }
0f40f9f7 4159}
46ed7963 4160 [(set_attr "type" "fmov,multi,multi,multi")
6ef67412 4161 (set_attr "mode" "SF")])
886c62d1 4162
e075ae69 4163(define_insn "*truncxfsf2_2"
dd80b906 4164 [(set (match_operand:SF 0 "memory_operand" "=m")
e075ae69
RH
4165 (float_truncate:SF
4166 (match_operand:XF 1 "register_operand" "f")))]
1b0c37d7 4167 "!TARGET_64BIT && TARGET_80387"
e075ae69
RH
4168{
4169 if (find_regno_note (insn, REG_DEAD, REGNO (operands[1])))
0f40f9f7 4170 return "fstp%z0\t%y0";
e075ae69 4171 else
0f40f9f7
ZW
4172 return "fst%z0\t%y0";
4173}
6ef67412
JH
4174 [(set_attr "type" "fmov")
4175 (set_attr "mode" "SF")])
bc725565
JW
4176
4177(define_split
e075ae69
RH
4178 [(set (match_operand:SF 0 "memory_operand" "")
4179 (float_truncate:SF
4180 (match_operand:XF 1 "register_operand" "")))
4181 (clobber (match_operand:SF 2 "memory_operand" ""))]
4182 "TARGET_80387"
4183 [(set (match_dup 0) (float_truncate:SF (match_dup 1)))]
886c62d1
JVA
4184 "")
4185
bc725565 4186(define_split
6a4a5d95 4187 [(set (match_operand:SF 0 "register_operand" "")
e075ae69
RH
4188 (float_truncate:SF
4189 (match_operand:XF 1 "register_operand" "")))
4190 (clobber (match_operand:SF 2 "memory_operand" ""))]
bc725565 4191 "TARGET_80387 && reload_completed"
e075ae69
RH
4192 [(set (match_dup 2) (float_truncate:SF (match_dup 1)))
4193 (set (match_dup 0) (match_dup 2))]
886c62d1
JVA
4194 "")
4195
2b589241
JH
4196(define_expand "trunctfsf2"
4197 [(parallel [(set (match_operand:SF 0 "nonimmediate_operand" "")
4198 (float_truncate:SF
4199 (match_operand:TF 1 "register_operand" "")))
4200 (clobber (match_dup 2))])]
4201 "TARGET_80387"
4202 "operands[2] = assign_386_stack_local (SFmode, 0);")
4203
4204(define_insn "*trunctfsf2_1"
46ed7963 4205 [(set (match_operand:SF 0 "nonimmediate_operand" "=m,?f#rx,?r#fx,?x#rf")
2b589241 4206 (float_truncate:SF
46ed7963
JH
4207 (match_operand:TF 1 "register_operand" "f,f,f,f")))
4208 (clobber (match_operand:SF 2 "memory_operand" "=X,m,m,m"))]
2b589241 4209 "TARGET_80387"
2b589241
JH
4210{
4211 switch (which_alternative)
4212 {
4213 case 0:
4214 if (find_regno_note (insn, REG_DEAD, REGNO (operands[1])))
0f40f9f7 4215 return "fstp%z0\t%y0";
2b589241 4216 else
0f40f9f7 4217 return "fst%z0\t%y0";
46ed7963
JH
4218 default:
4219 abort();
2b589241 4220 }
0f40f9f7 4221}
46ed7963 4222 [(set_attr "type" "fmov,multi,multi,multi")
2b589241
JH
4223 (set_attr "mode" "SF")])
4224
1e07edd3 4225(define_insn "*trunctfsf2_2"
cc2e591b 4226 [(set (match_operand:SF 0 "memory_operand" "=m")
2b589241
JH
4227 (float_truncate:SF
4228 (match_operand:TF 1 "register_operand" "f")))]
4229 "TARGET_80387"
2b589241
JH
4230{
4231 if (find_regno_note (insn, REG_DEAD, REGNO (operands[1])))
0f40f9f7 4232 return "fstp%z0\t%y0";
2b589241 4233 else
0f40f9f7
ZW
4234 return "fst%z0\t%y0";
4235}
2b589241
JH
4236 [(set_attr "type" "fmov")
4237 (set_attr "mode" "SF")])
4238
4239(define_split
4240 [(set (match_operand:SF 0 "memory_operand" "")
4241 (float_truncate:SF
4242 (match_operand:TF 1 "register_operand" "")))
4243 (clobber (match_operand:SF 2 "memory_operand" ""))]
4244 "TARGET_80387"
4245 [(set (match_dup 0) (float_truncate:SF (match_dup 1)))]
4246 "")
4247
4248(define_split
4249 [(set (match_operand:SF 0 "register_operand" "")
4250 (float_truncate:SF
4251 (match_operand:TF 1 "register_operand" "")))
4252 (clobber (match_operand:SF 2 "memory_operand" ""))]
4253 "TARGET_80387 && reload_completed"
4254 [(set (match_dup 2) (float_truncate:SF (match_dup 1)))
4255 (set (match_dup 0) (match_dup 2))]
4256 "")
4257
4258
e075ae69
RH
4259(define_expand "truncxfdf2"
4260 [(parallel [(set (match_operand:DF 0 "nonimmediate_operand" "")
4261 (float_truncate:DF
4262 (match_operand:XF 1 "register_operand" "")))
4263 (clobber (match_dup 2))])]
1b0c37d7 4264 "!TARGET_64BIT && TARGET_80387"
e075ae69 4265 "operands[2] = assign_386_stack_local (DFmode, 0);")
bc725565 4266
e075ae69 4267(define_insn "*truncxfdf2_1"
46ed7963 4268 [(set (match_operand:DF 0 "nonimmediate_operand" "=m,?f#rY,?r#fY,?Y#rf")
e075ae69 4269 (float_truncate:DF
46ed7963
JH
4270 (match_operand:XF 1 "register_operand" "f,f,f,f")))
4271 (clobber (match_operand:DF 2 "memory_operand" "=X,m,m,m"))]
1b0c37d7 4272 "!TARGET_64BIT && TARGET_80387"
e075ae69
RH
4273{
4274 switch (which_alternative)
4275 {
4276 case 0:
4277 if (find_regno_note (insn, REG_DEAD, REGNO (operands[1])))
0f40f9f7 4278 return "fstp%z0\t%y0";
e075ae69 4279 else
0f40f9f7 4280 return "fst%z0\t%y0";
46ed7963
JH
4281 default:
4282 abort();
e075ae69
RH
4283 }
4284 abort ();
0f40f9f7 4285}
46ed7963 4286 [(set_attr "type" "fmov,multi,multi,multi")
6ef67412 4287 (set_attr "mode" "DF")])
bc725565 4288
e075ae69
RH
4289(define_insn "*truncxfdf2_2"
4290 [(set (match_operand:DF 0 "memory_operand" "=m")
4291 (float_truncate:DF
4292 (match_operand:XF 1 "register_operand" "f")))]
1b0c37d7 4293 "!TARGET_64BIT && TARGET_80387"
e075ae69
RH
4294{
4295 if (find_regno_note (insn, REG_DEAD, REGNO (operands[1])))
0f40f9f7 4296 return "fstp%z0\t%y0";
e075ae69 4297 else
0f40f9f7
ZW
4298 return "fst%z0\t%y0";
4299}
6ef67412
JH
4300 [(set_attr "type" "fmov")
4301 (set_attr "mode" "DF")])
bc725565
JW
4302
4303(define_split
e075ae69
RH
4304 [(set (match_operand:DF 0 "memory_operand" "")
4305 (float_truncate:DF
4306 (match_operand:XF 1 "register_operand" "")))
4307 (clobber (match_operand:DF 2 "memory_operand" ""))]
ca285e07
JH
4308 "TARGET_80387"
4309 [(set (match_dup 0) (float_truncate:DF (match_dup 1)))]
4fb21e90
JVA
4310 "")
4311
bc725565 4312(define_split
6a4a5d95 4313 [(set (match_operand:DF 0 "register_operand" "")
e075ae69
RH
4314 (float_truncate:DF
4315 (match_operand:XF 1 "register_operand" "")))
4316 (clobber (match_operand:DF 2 "memory_operand" ""))]
bc725565 4317 "TARGET_80387 && reload_completed"
ca285e07 4318 [(set (match_dup 2) (float_truncate:DF (match_dup 1)))
e075ae69 4319 (set (match_dup 0) (match_dup 2))]
4fb21e90 4320 "")
ca285e07 4321
2b589241
JH
4322(define_expand "trunctfdf2"
4323 [(parallel [(set (match_operand:DF 0 "nonimmediate_operand" "")
4324 (float_truncate:DF
4325 (match_operand:TF 1 "register_operand" "")))
4326 (clobber (match_dup 2))])]
4327 "TARGET_80387"
4328 "operands[2] = assign_386_stack_local (DFmode, 0);")
4329
4330(define_insn "*trunctfdf2_1"
46ed7963 4331 [(set (match_operand:DF 0 "nonimmediate_operand" "=m,?f#rY,?r#fY,?Y#rf")
2b589241 4332 (float_truncate:DF
46ed7963
JH
4333 (match_operand:TF 1 "register_operand" "f,f,f,f")))
4334 (clobber (match_operand:DF 2 "memory_operand" "=X,m,m,m"))]
2b589241 4335 "TARGET_80387"
2b589241
JH
4336{
4337 switch (which_alternative)
4338 {
4339 case 0:
4340 if (find_regno_note (insn, REG_DEAD, REGNO (operands[1])))
0f40f9f7 4341 return "fstp%z0\t%y0";
2b589241 4342 else
0f40f9f7 4343 return "fst%z0\t%y0";
46ed7963
JH
4344 default:
4345 abort();
2b589241
JH
4346 }
4347 abort ();
0f40f9f7 4348}
46ed7963 4349 [(set_attr "type" "fmov,multi,multi,multi")
2b589241
JH
4350 (set_attr "mode" "DF")])
4351
46ed7963 4352 (define_insn "*trunctfdf2_2"
2b589241
JH
4353 [(set (match_operand:DF 0 "memory_operand" "=m")
4354 (float_truncate:DF
4355 (match_operand:TF 1 "register_operand" "f")))]
4356 "TARGET_80387"
2b589241
JH
4357{
4358 if (find_regno_note (insn, REG_DEAD, REGNO (operands[1])))
0f40f9f7 4359 return "fstp%z0\t%y0";
2b589241 4360 else
0f40f9f7
ZW
4361 return "fst%z0\t%y0";
4362}
2b589241
JH
4363 [(set_attr "type" "fmov")
4364 (set_attr "mode" "DF")])
4365
4366(define_split
4367 [(set (match_operand:DF 0 "memory_operand" "")
4368 (float_truncate:DF
4369 (match_operand:TF 1 "register_operand" "")))
4370 (clobber (match_operand:DF 2 "memory_operand" ""))]
4371 "TARGET_80387"
4372 [(set (match_dup 0) (float_truncate:DF (match_dup 1)))]
4373 "")
4374
4375(define_split
4376 [(set (match_operand:DF 0 "register_operand" "")
4377 (float_truncate:DF
4378 (match_operand:TF 1 "register_operand" "")))
4379 (clobber (match_operand:DF 2 "memory_operand" ""))]
4380 "TARGET_80387 && reload_completed"
4381 [(set (match_dup 2) (float_truncate:DF (match_dup 1)))
4382 (set (match_dup 0) (match_dup 2))]
4383 "")
4384
e075ae69
RH
4385\f
4386;; %%% Break up all these bad boys.
4fb21e90 4387
e075ae69
RH
4388;; Signed conversion to DImode.
4389
2b589241 4390(define_expand "fix_truncxfdi2"
22fb740d
JH
4391 [(set (match_operand:DI 0 "nonimmediate_operand" "")
4392 (fix:DI (match_operand:XF 1 "register_operand" "")))]
1b0c37d7 4393 "!TARGET_64BIT && TARGET_80387"
22fb740d 4394 "")
2b589241
JH
4395
4396(define_expand "fix_trunctfdi2"
22fb740d
JH
4397 [(set (match_operand:DI 0 "nonimmediate_operand" "")
4398 (fix:DI (match_operand:TF 1 "register_operand" "")))]
bc725565 4399 "TARGET_80387"
22fb740d 4400 "")
bc725565 4401
e075ae69 4402(define_expand "fix_truncdfdi2"
22fb740d
JH
4403 [(set (match_operand:DI 0 "nonimmediate_operand" "")
4404 (fix:DI (match_operand:DF 1 "register_operand" "")))]
46ed7963 4405 "TARGET_80387 || (TARGET_SSE2 && TARGET_64BIT)"
46ed7963 4406{
1b0c37d7 4407 if (TARGET_64BIT && TARGET_SSE2)
46ed7963
JH
4408 {
4409 rtx out = REG_P (operands[0]) ? operands[0] : gen_reg_rtx (DImode);
4410 emit_insn (gen_fix_truncdfdi_sse (out, operands[1]));
4411 if (out != operands[0])
4412 emit_move_insn (operands[0], out);
4413 DONE;
4414 }
0f40f9f7 4415})
53b5ce19 4416
e075ae69 4417(define_expand "fix_truncsfdi2"
22fb740d
JH
4418 [(set (match_operand:DI 0 "nonimmediate_operand" "")
4419 (fix:DI (match_operand:SF 1 "register_operand" "")))]
46ed7963 4420 "TARGET_80387 || (TARGET_SSE && TARGET_64BIT)"
46ed7963 4421{
22fb740d 4422 if (TARGET_SSE && TARGET_64BIT)
46ed7963
JH
4423 {
4424 rtx out = REG_P (operands[0]) ? operands[0] : gen_reg_rtx (DImode);
4425 emit_insn (gen_fix_truncsfdi_sse (out, operands[1]));
4426 if (out != operands[0])
4427 emit_move_insn (operands[0], out);
4428 DONE;
4429 }
0f40f9f7 4430})
e075ae69 4431
22fb740d
JH
4432;; See the comments in i386.h near OPTIMIZE_MODE_SWITCHING for the description
4433;; of the machinery.
4434(define_insn_and_split "*fix_truncdi_1"
4435 [(set (match_operand:DI 0 "nonimmediate_operand" "=m,?r")
4436 (fix:DI (match_operand 1 "register_operand" "f,f")))]
4437 "TARGET_80387 && FLOAT_MODE_P (GET_MODE (operands[1]))
4438 && !reload_completed && !reload_in_progress
4439 && (!SSE_FLOAT_MODE_P (GET_MODE (operands[1])) || !TARGET_64BIT)"
4440 "#"
14f73b5a 4441 "&& 1"
22fb740d
JH
4442 [(const_int 0)]
4443{
4444 operands[2] = assign_386_stack_local (HImode, 1);
4445 operands[3] = assign_386_stack_local (HImode, 2);
4446 if (memory_operand (operands[0], VOIDmode))
4447 emit_insn (gen_fix_truncdi_memory (operands[0], operands[1],
4448 operands[2], operands[3]));
4449 else
4450 {
4451 operands[4] = assign_386_stack_local (DImode, 0);
4452 emit_insn (gen_fix_truncdi_nomemory (operands[0], operands[1],
4453 operands[2], operands[3],
4454 operands[4]));
4455 }
4456 DONE;
4457}
4458 [(set_attr "type" "fistp")])
4459
4460(define_insn "fix_truncdi_nomemory"
c76aab11 4461 [(set (match_operand:DI 0 "nonimmediate_operand" "=m,?r")
e075ae69 4462 (fix:DI (match_operand 1 "register_operand" "f,f")))
7a2e09f4
JH
4463 (use (match_operand:HI 2 "memory_operand" "m,m"))
4464 (use (match_operand:HI 3 "memory_operand" "m,m"))
4465 (clobber (match_operand:DI 4 "memory_operand" "=m,m"))
22fb740d 4466 (clobber (match_scratch:DF 5 "=&1f,&1f"))]
46ed7963 4467 "TARGET_80387 && FLOAT_MODE_P (GET_MODE (operands[1]))
22fb740d
JH
4468 && (!SSE_FLOAT_MODE_P (GET_MODE (operands[1])) || !TARGET_64BIT)"
4469 "#"
4470 [(set_attr "type" "fistp")])
4471
4472(define_insn "fix_truncdi_memory"
4473 [(set (match_operand:DI 0 "memory_operand" "=m")
4474 (fix:DI (match_operand 1 "register_operand" "f")))
4475 (use (match_operand:HI 2 "memory_operand" "m"))
4476 (use (match_operand:HI 3 "memory_operand" "m"))
4477 (clobber (match_scratch:DF 4 "=&1f"))]
4478 "TARGET_80387 && FLOAT_MODE_P (GET_MODE (operands[1]))
4479 && (!SSE_FLOAT_MODE_P (GET_MODE (operands[1])) || !TARGET_64BIT)"
4480 "* operands[5] = operands[4]; return output_fix_trunc (insn, operands);"
4481 [(set_attr "type" "fistp")])
53b5ce19 4482
e075ae69
RH
4483(define_split
4484 [(set (match_operand:DI 0 "register_operand" "")
4485 (fix:DI (match_operand 1 "register_operand" "")))
7a2e09f4
JH
4486 (use (match_operand:HI 2 "memory_operand" ""))
4487 (use (match_operand:HI 3 "memory_operand" ""))
4488 (clobber (match_operand:DI 4 "memory_operand" ""))
a05924f9 4489 (clobber (match_scratch 5 ""))]
7a2e09f4
JH
4490 "reload_completed"
4491 [(parallel [(set (match_dup 4) (fix:DI (match_dup 1)))
4492 (use (match_dup 2))
4493 (use (match_dup 3))
e075ae69 4494 (clobber (match_dup 5))])
7a2e09f4 4495 (set (match_dup 0) (match_dup 4))]
53b5ce19
JW
4496 "")
4497
22fb740d
JH
4498(define_split
4499 [(set (match_operand:DI 0 "memory_operand" "")
4500 (fix:DI (match_operand 1 "register_operand" "")))
4501 (use (match_operand:HI 2 "memory_operand" ""))
4502 (use (match_operand:HI 3 "memory_operand" ""))
4503 (clobber (match_operand:DI 4 "memory_operand" ""))
4504 (clobber (match_scratch 5 ""))]
4505 "reload_completed"
4506 [(parallel [(set (match_dup 0) (fix:DI (match_dup 1)))
4507 (use (match_dup 2))
4508 (use (match_dup 3))
4509 (clobber (match_dup 5))])]
4510 "")
4511
46ed7963
JH
4512;; When SSE available, it is always faster to use it!
4513(define_insn "fix_truncsfdi_sse"
f56e86bd
JH
4514 [(set (match_operand:DI 0 "register_operand" "=r,r")
4515 (fix:DI (match_operand:SF 1 "nonimmediate_operand" "x,xm")))]
1b0c37d7 4516 "TARGET_64BIT && TARGET_SSE"
0f40f9f7 4517 "cvttss2si{q}\t{%1, %0|%0, %1}"
f56e86bd
JH
4518 [(set_attr "type" "sseicvt")
4519 (set_attr "athlon_decode" "double,vector")])
46ed7963
JH
4520
4521(define_insn "fix_truncdfdi_sse"
f56e86bd
JH
4522 [(set (match_operand:DI 0 "register_operand" "=r,r")
4523 (fix:DI (match_operand:DF 1 "nonimmediate_operand" "Y,Ym")))]
1b0c37d7 4524 "TARGET_64BIT && TARGET_SSE2"
0f40f9f7 4525 "cvttsd2si{q}\t{%1, %0|%0, %1}"
f56e86bd
JH
4526 [(set_attr "type" "sseicvt,sseicvt")
4527 (set_attr "athlon_decode" "double,vector")])
46ed7963 4528
e075ae69 4529;; Signed conversion to SImode.
53b5ce19 4530
e075ae69 4531(define_expand "fix_truncxfsi2"
22fb740d
JH
4532 [(set (match_operand:SI 0 "nonimmediate_operand" "")
4533 (fix:SI (match_operand:XF 1 "register_operand" "")))]
1b0c37d7 4534 "!TARGET_64BIT && TARGET_80387"
22fb740d 4535 "")
53b5ce19 4536
2b589241 4537(define_expand "fix_trunctfsi2"
22fb740d
JH
4538 [(set (match_operand:SI 0 "nonimmediate_operand" "")
4539 (fix:SI (match_operand:TF 1 "register_operand" "")))]
2b589241 4540 "TARGET_80387"
22fb740d 4541 "")
2b589241 4542
e075ae69 4543(define_expand "fix_truncdfsi2"
22fb740d
JH
4544 [(set (match_operand:SI 0 "nonimmediate_operand" "")
4545 (fix:SI (match_operand:DF 1 "register_operand" "")))]
42a0aa6f 4546 "TARGET_80387 || TARGET_SSE2"
42a0aa6f
JH
4547{
4548 if (TARGET_SSE2)
4549 {
ca9a9b12 4550 rtx out = REG_P (operands[0]) ? operands[0] : gen_reg_rtx (SImode);
b1675dbd
JH
4551 emit_insn (gen_fix_truncdfsi_sse (out, operands[1]));
4552 if (out != operands[0])
4553 emit_move_insn (operands[0], out);
42a0aa6f
JH
4554 DONE;
4555 }
0f40f9f7 4556})
886c62d1 4557
e075ae69 4558(define_expand "fix_truncsfsi2"
22fb740d
JH
4559 [(set (match_operand:SI 0 "nonimmediate_operand" "")
4560 (fix:SI (match_operand:SF 1 "register_operand" "")))]
42a0aa6f 4561 "TARGET_80387 || TARGET_SSE"
42a0aa6f 4562{
22fb740d 4563 if (TARGET_SSE)
42a0aa6f 4564 {
ca9a9b12 4565 rtx out = REG_P (operands[0]) ? operands[0] : gen_reg_rtx (SImode);
46ed7963 4566 emit_insn (gen_fix_truncsfsi_sse (out, operands[1]));
b1675dbd
JH
4567 if (out != operands[0])
4568 emit_move_insn (operands[0], out);
42a0aa6f
JH
4569 DONE;
4570 }
0f40f9f7 4571})
e075ae69 4572
22fb740d
JH
4573;; See the comments in i386.h near OPTIMIZE_MODE_SWITCHING for the description
4574;; of the machinery.
4575(define_insn_and_split "*fix_truncsi_1"
4576 [(set (match_operand:SI 0 "nonimmediate_operand" "=m,?r")
4577 (fix:SI (match_operand 1 "register_operand" "f,f")))]
4578 "TARGET_80387 && FLOAT_MODE_P (GET_MODE (operands[1]))
4579 && !reload_completed && !reload_in_progress
4580 && !SSE_FLOAT_MODE_P (GET_MODE (operands[1]))"
4581 "#"
ab75d1f1 4582 "&& 1"
22fb740d
JH
4583 [(const_int 0)]
4584{
4585 operands[2] = assign_386_stack_local (HImode, 1);
4586 operands[3] = assign_386_stack_local (HImode, 2);
4587 if (memory_operand (operands[0], VOIDmode))
4588 emit_insn (gen_fix_truncsi_memory (operands[0], operands[1],
4589 operands[2], operands[3]));
4590 else
4591 {
4592 operands[4] = assign_386_stack_local (SImode, 0);
4593 emit_insn (gen_fix_truncsi_nomemory (operands[0], operands[1],
4594 operands[2], operands[3],
4595 operands[4]));
4596 }
4597 DONE;
4598}
4599 [(set_attr "type" "fistp")])
4600
4601(define_insn "fix_truncsi_nomemory"
c76aab11 4602 [(set (match_operand:SI 0 "nonimmediate_operand" "=m,?r")
e075ae69 4603 (fix:SI (match_operand 1 "register_operand" "f,f")))
7a2e09f4
JH
4604 (use (match_operand:HI 2 "memory_operand" "m,m"))
4605 (use (match_operand:HI 3 "memory_operand" "m,m"))
4606 (clobber (match_operand:SI 4 "memory_operand" "=m,m"))]
42a0aa6f 4607 "TARGET_80387 && FLOAT_MODE_P (GET_MODE (operands[1]))
22fb740d
JH
4608 && !SSE_FLOAT_MODE_P (GET_MODE (operands[1]))"
4609 "#"
4610 [(set_attr "type" "fistp")])
4611
4612(define_insn "fix_truncsi_memory"
4613 [(set (match_operand:SI 0 "memory_operand" "=m")
4614 (fix:SI (match_operand 1 "register_operand" "f")))
4615 (use (match_operand:HI 2 "memory_operand" "m"))
4616 (use (match_operand:HI 3 "memory_operand" "m"))]
4617 "TARGET_80387 && FLOAT_MODE_P (GET_MODE (operands[1]))
4618 && !SSE_FLOAT_MODE_P (GET_MODE (operands[1]))"
e075ae69 4619 "* return output_fix_trunc (insn, operands);"
22fb740d 4620 [(set_attr "type" "fistp")])
bc725565 4621
42a0aa6f
JH
4622;; When SSE available, it is always faster to use it!
4623(define_insn "fix_truncsfsi_sse"
f56e86bd
JH
4624 [(set (match_operand:SI 0 "register_operand" "=r,r")
4625 (fix:SI (match_operand:SF 1 "nonimmediate_operand" "x,xm")))]
42a0aa6f 4626 "TARGET_SSE"
0f40f9f7 4627 "cvttss2si\t{%1, %0|%0, %1}"
f56e86bd
JH
4628 [(set_attr "type" "sseicvt")
4629 (set_attr "athlon_decode" "double,vector")])
42a0aa6f
JH
4630
4631(define_insn "fix_truncdfsi_sse"
f56e86bd
JH
4632 [(set (match_operand:SI 0 "register_operand" "=r,r")
4633 (fix:SI (match_operand:DF 1 "nonimmediate_operand" "Y,Ym")))]
42a0aa6f 4634 "TARGET_SSE2"
0f40f9f7 4635 "cvttsd2si\t{%1, %0|%0, %1}"
f56e86bd
JH
4636 [(set_attr "type" "sseicvt")
4637 (set_attr "athlon_decode" "double,vector")])
42a0aa6f 4638
e075ae69
RH
4639(define_split
4640 [(set (match_operand:SI 0 "register_operand" "")
4641 (fix:SI (match_operand 1 "register_operand" "")))
7a2e09f4
JH
4642 (use (match_operand:HI 2 "memory_operand" ""))
4643 (use (match_operand:HI 3 "memory_operand" ""))
4644 (clobber (match_operand:SI 4 "memory_operand" ""))]
e075ae69 4645 "reload_completed"
7a2e09f4
JH
4646 [(parallel [(set (match_dup 4) (fix:SI (match_dup 1)))
4647 (use (match_dup 2))
22fb740d 4648 (use (match_dup 3))])
7a2e09f4 4649 (set (match_dup 0) (match_dup 4))]
bc725565 4650 "")
4fb21e90 4651
22fb740d
JH
4652(define_split
4653 [(set (match_operand:SI 0 "memory_operand" "")
4654 (fix:SI (match_operand 1 "register_operand" "")))
4655 (use (match_operand:HI 2 "memory_operand" ""))
4656 (use (match_operand:HI 3 "memory_operand" ""))
4657 (clobber (match_operand:SI 4 "memory_operand" ""))]
4658 "reload_completed"
4659 [(parallel [(set (match_dup 0) (fix:SI (match_dup 1)))
4660 (use (match_dup 2))
4661 (use (match_dup 3))])]
4662 "")
4663
46d21d2c
JW
4664;; Signed conversion to HImode.
4665
4666(define_expand "fix_truncxfhi2"
22fb740d
JH
4667 [(set (match_operand:HI 0 "nonimmediate_operand" "")
4668 (fix:HI (match_operand:XF 1 "register_operand" "")))]
1b0c37d7 4669 "!TARGET_64BIT && TARGET_80387"
22fb740d 4670 "")
46d21d2c 4671
2b589241 4672(define_expand "fix_trunctfhi2"
22fb740d
JH
4673 [(set (match_operand:HI 0 "nonimmediate_operand" "")
4674 (fix:HI (match_operand:TF 1 "register_operand" "")))]
2b589241 4675 "TARGET_80387"
22fb740d 4676 "")
2b589241 4677
46d21d2c 4678(define_expand "fix_truncdfhi2"
22fb740d
JH
4679 [(set (match_operand:HI 0 "nonimmediate_operand" "")
4680 (fix:HI (match_operand:DF 1 "register_operand" "")))]
42a0aa6f 4681 "TARGET_80387 && !TARGET_SSE2"
22fb740d 4682 "")
46d21d2c
JW
4683
4684(define_expand "fix_truncsfhi2"
22fb740d
JH
4685 [(set (match_operand:HI 0 "nonimmediate_operand" "")
4686 (fix:HI (match_operand:SF 1 "register_operand" "")))]
42a0aa6f 4687 "TARGET_80387 && !TARGET_SSE"
22fb740d
JH
4688 "")
4689
4690;; See the comments in i386.h near OPTIMIZE_MODE_SWITCHING for the description
4691;; of the machinery.
4692(define_insn_and_split "*fix_trunchi_1"
4693 [(set (match_operand:HI 0 "nonimmediate_operand" "=m,?r")
4694 (fix:HI (match_operand 1 "register_operand" "f,f")))]
4695 "TARGET_80387 && FLOAT_MODE_P (GET_MODE (operands[1]))
4696 && !reload_completed && !reload_in_progress
4697 && !SSE_FLOAT_MODE_P (GET_MODE (operands[1]))"
4698 "#"
4699 ""
4700 [(const_int 0)]
4701{
4702 operands[2] = assign_386_stack_local (HImode, 1);
4703 operands[3] = assign_386_stack_local (HImode, 2);
4704 if (memory_operand (operands[0], VOIDmode))
4705 emit_insn (gen_fix_trunchi_memory (operands[0], operands[1],
4706 operands[2], operands[3]));
4707 else
4708 {
4709 operands[4] = assign_386_stack_local (HImode, 0);
4710 emit_insn (gen_fix_trunchi_nomemory (operands[0], operands[1],
4711 operands[2], operands[3],
4712 operands[4]));
4713 }
4714 DONE;
4715}
4716 [(set_attr "type" "fistp")])
46d21d2c 4717
22fb740d 4718(define_insn "fix_trunchi_nomemory"
46d21d2c
JW
4719 [(set (match_operand:HI 0 "nonimmediate_operand" "=m,?r")
4720 (fix:HI (match_operand 1 "register_operand" "f,f")))
7a2e09f4
JH
4721 (use (match_operand:HI 2 "memory_operand" "m,m"))
4722 (use (match_operand:HI 3 "memory_operand" "m,m"))
4723 (clobber (match_operand:HI 4 "memory_operand" "=m,m"))]
42a0aa6f 4724 "TARGET_80387 && FLOAT_MODE_P (GET_MODE (operands[1]))
22fb740d
JH
4725 && !SSE_FLOAT_MODE_P (GET_MODE (operands[1]))"
4726 "#"
4727 [(set_attr "type" "fistp")])
4728
4729(define_insn "fix_trunchi_memory"
4730 [(set (match_operand:HI 0 "memory_operand" "=m")
4731 (fix:HI (match_operand 1 "register_operand" "f")))
4732 (use (match_operand:HI 2 "memory_operand" "m"))
4733 (use (match_operand:HI 3 "memory_operand" "m"))]
4734 "TARGET_80387 && FLOAT_MODE_P (GET_MODE (operands[1]))
4735 && !SSE_FLOAT_MODE_P (GET_MODE (operands[1]))"
46d21d2c 4736 "* return output_fix_trunc (insn, operands);"
22fb740d
JH
4737 [(set_attr "type" "fistp")])
4738
4739(define_split
4740 [(set (match_operand:HI 0 "memory_operand" "")
4741 (fix:HI (match_operand 1 "register_operand" "")))
4742 (use (match_operand:HI 2 "memory_operand" ""))
4743 (use (match_operand:HI 3 "memory_operand" ""))
4744 (clobber (match_operand:HI 4 "memory_operand" ""))]
4745 "reload_completed"
4746 [(parallel [(set (match_dup 0) (fix:HI (match_dup 1)))
4747 (use (match_dup 2))
4748 (use (match_dup 3))])]
4749 "")
46d21d2c
JW
4750
4751(define_split
4752 [(set (match_operand:HI 0 "register_operand" "")
4753 (fix:HI (match_operand 1 "register_operand" "")))
7a2e09f4
JH
4754 (use (match_operand:HI 2 "memory_operand" ""))
4755 (use (match_operand:HI 3 "memory_operand" ""))
4756 (clobber (match_operand:HI 4 "memory_operand" ""))]
46d21d2c 4757 "reload_completed"
7a2e09f4
JH
4758 [(parallel [(set (match_dup 4) (fix:HI (match_dup 1)))
4759 (use (match_dup 2))
4760 (use (match_dup 3))
46d21d2c 4761 (clobber (match_dup 4))])
7a2e09f4 4762 (set (match_dup 0) (match_dup 4))]
46d21d2c
JW
4763 "")
4764
e075ae69
RH
4765;; %% Not used yet.
4766(define_insn "x86_fnstcw_1"
c76aab11 4767 [(set (match_operand:HI 0 "memory_operand" "=m")
8ee41eaf 4768 (unspec:HI [(reg:HI 18)] UNSPEC_FSTCW))]
e1f998ad 4769 "TARGET_80387"
0f40f9f7 4770 "fnstcw\t%0"
6ef67412
JH
4771 [(set_attr "length" "2")
4772 (set_attr "mode" "HI")
3d34cd91 4773 (set_attr "unit" "i387")
e075ae69 4774 (set_attr "ppro_uops" "few")])
bc725565 4775
e075ae69
RH
4776(define_insn "x86_fldcw_1"
4777 [(set (reg:HI 18)
8ee41eaf 4778 (unspec:HI [(match_operand:HI 0 "memory_operand" "m")] UNSPEC_FLDCW))]
bc725565 4779 "TARGET_80387"
0f40f9f7 4780 "fldcw\t%0"
6ef67412
JH
4781 [(set_attr "length" "2")
4782 (set_attr "mode" "HI")
3d34cd91 4783 (set_attr "unit" "i387")
0b5107cf 4784 (set_attr "athlon_decode" "vector")
e075ae69
RH
4785 (set_attr "ppro_uops" "few")])
4786\f
4787;; Conversion between fixed point and floating point.
886c62d1 4788
e075ae69
RH
4789;; Even though we only accept memory inputs, the backend _really_
4790;; wants to be able to do this between registers.
4791
35c28a13
JH
4792(define_expand "floathisf2"
4793 [(set (match_operand:SF 0 "register_operand" "")
4794 (float:SF (match_operand:HI 1 "nonimmediate_operand" "")))]
4795 "TARGET_SSE || TARGET_80387"
4796{
4797 if (TARGET_SSE && TARGET_SSE_MATH)
4798 {
4799 emit_insn (gen_floatsisf2 (operands[0],
4800 convert_to_mode (SImode, operands[1], 0)));
4801 DONE;
4802 }
4803})
4804
4805(define_insn "*floathisf2_1"
155d8a47
JW
4806 [(set (match_operand:SF 0 "register_operand" "=f,f")
4807 (float:SF (match_operand:HI 1 "nonimmediate_operand" "m,r")))]
35c28a13 4808 "TARGET_80387 && (!TARGET_SSE || !TARGET_SSE_MATH)"
155d8a47 4809 "@
0f40f9f7 4810 fild%z1\t%1
155d8a47
JW
4811 #"
4812 [(set_attr "type" "fmov,multi")
6ef67412 4813 (set_attr "mode" "SF")
155d8a47
JW
4814 (set_attr "fp_int_src" "true")])
4815
42a0aa6f
JH
4816(define_expand "floatsisf2"
4817 [(set (match_operand:SF 0 "register_operand" "")
4818 (float:SF (match_operand:SI 1 "nonimmediate_operand" "")))]
4819 "TARGET_SSE || TARGET_80387"
4820 "")
4821
4822(define_insn "*floatsisf2_i387"
f56e86bd
JH
4823 [(set (match_operand:SF 0 "register_operand" "=f#x,?f#x,x#f,x#f")
4824 (float:SF (match_operand:SI 1 "nonimmediate_operand" "m,r,r,mr")))]
42a0aa6f 4825 "TARGET_80387 && (!TARGET_SSE || TARGET_MIX_SSE_I387)"
e075ae69 4826 "@
0f40f9f7 4827 fild%z1\t%1
42a0aa6f 4828 #
f56e86bd 4829 cvtsi2ss\t{%1, %0|%0, %1}
0f40f9f7 4830 cvtsi2ss\t{%1, %0|%0, %1}"
f56e86bd 4831 [(set_attr "type" "fmov,multi,sseicvt,sseicvt")
42a0aa6f 4832 (set_attr "mode" "SF")
f56e86bd 4833 (set_attr "athlon_decode" "*,*,vector,double")
42a0aa6f
JH
4834 (set_attr "fp_int_src" "true")])
4835
4836(define_insn "*floatsisf2_sse"
f56e86bd
JH
4837 [(set (match_operand:SF 0 "register_operand" "=x,x")
4838 (float:SF (match_operand:SI 1 "nonimmediate_operand" "r,mr")))]
46ed7963 4839 "TARGET_SSE"
0f40f9f7 4840 "cvtsi2ss\t{%1, %0|%0, %1}"
f56e86bd 4841 [(set_attr "type" "sseicvt")
6ef67412 4842 (set_attr "mode" "SF")
f56e86bd 4843 (set_attr "athlon_decode" "vector,double")
e075ae69 4844 (set_attr "fp_int_src" "true")])
bc725565 4845
d1f87653 4846; Avoid possible reformatting penalty on the destination by first
4977bab6
ZW
4847; zeroing it out
4848(define_split
4849 [(set (match_operand:SF 0 "register_operand" "")
4850 (float:SF (match_operand:SI 1 "nonimmediate_operand" "")))]
4851 "TARGET_80387 && reload_completed && TARGET_SSE_PARTIAL_REGS
4852 && SSE_REG_P (operands[0])"
4853 [(const_int 0)]
4854{
4855 rtx dest;
4856 dest = simplify_gen_subreg (V4SFmode, operands[0], SFmode, 0);
4857 emit_insn (gen_sse_clrv4sf (dest, CONST0_RTX (V4SFmode)));
4858 emit_insn (gen_cvtsi2ss (dest, dest, operands[1]));
4859 DONE;
4860})
4861
46ed7963
JH
4862(define_expand "floatdisf2"
4863 [(set (match_operand:SF 0 "register_operand" "")
4864 (float:SF (match_operand:DI 1 "nonimmediate_operand" "")))]
1b0c37d7 4865 "(TARGET_64BIT && TARGET_SSE) || TARGET_80387"
46ed7963
JH
4866 "")
4867
ef6257cd
JH
4868(define_insn "*floatdisf2_i387_only"
4869 [(set (match_operand:SF 0 "register_operand" "=f,?f")
4870 (float:SF (match_operand:DI 1 "nonimmediate_operand" "m,r")))]
4871 "TARGET_80387 && (!TARGET_SSE || !TARGET_64BIT || TARGET_MIX_SSE_I387)"
4872 "@
0f40f9f7 4873 fild%z1\t%1
ef6257cd
JH
4874 #"
4875 [(set_attr "type" "fmov,multi")
4876 (set_attr "mode" "SF")
4877 (set_attr "fp_int_src" "true")])
4878
46ed7963 4879(define_insn "*floatdisf2_i387"
f56e86bd
JH
4880 [(set (match_operand:SF 0 "register_operand" "=f#x,?f#x,x#f,x#f")
4881 (float:SF (match_operand:DI 1 "nonimmediate_operand" "m,r,r,mr")))]
1b0c37d7 4882 "TARGET_64BIT && TARGET_80387 && (!TARGET_SSE || TARGET_MIX_SSE_I387)"
e075ae69 4883 "@
0f40f9f7 4884 fild%z1\t%1
46ed7963 4885 #
f56e86bd 4886 cvtsi2ss{q}\t{%1, %0|%0, %1}
0f40f9f7 4887 cvtsi2ss{q}\t{%1, %0|%0, %1}"
f56e86bd 4888 [(set_attr "type" "fmov,multi,sseicvt,sseicvt")
46ed7963 4889 (set_attr "mode" "SF")
f56e86bd 4890 (set_attr "athlon_decode" "*,*,vector,double")
46ed7963
JH
4891 (set_attr "fp_int_src" "true")])
4892
4893(define_insn "*floatdisf2_sse"
f56e86bd
JH
4894 [(set (match_operand:SF 0 "register_operand" "=x,x")
4895 (float:SF (match_operand:DI 1 "nonimmediate_operand" "r,mr")))]
1b0c37d7 4896 "TARGET_64BIT && TARGET_SSE"
0f40f9f7 4897 "cvtsi2ss{q}\t{%1, %0|%0, %1}"
f56e86bd 4898 [(set_attr "type" "sseicvt")
6ef67412 4899 (set_attr "mode" "SF")
f56e86bd 4900 (set_attr "athlon_decode" "vector,double")
e075ae69 4901 (set_attr "fp_int_src" "true")])
bc725565 4902
d1f87653 4903; Avoid possible reformatting penalty on the destination by first
4977bab6
ZW
4904; zeroing it out
4905(define_split
4906 [(set (match_operand:SF 0 "register_operand" "")
4907 (float:SF (match_operand:DI 1 "nonimmediate_operand" "")))]
4908 "TARGET_80387 && reload_completed && TARGET_SSE_PARTIAL_REGS
4909 && SSE_REG_P (operands[0])"
4910 [(const_int 0)]
4911{
4912 rtx dest;
4913 dest = simplify_gen_subreg (V4SFmode, operands[0], SFmode, 0);
4914 emit_insn (gen_sse_clrv4sf (dest, CONST0_RTX (V4SFmode)));
4915 emit_insn (gen_cvtsi2ssq (dest, dest, operands[1]));
4916 DONE;
4917})
4918
35c28a13
JH
4919(define_expand "floathidf2"
4920 [(set (match_operand:DF 0 "register_operand" "")
4921 (float:DF (match_operand:HI 1 "nonimmediate_operand" "")))]
4922 "TARGET_SSE2 || TARGET_80387"
4923{
4924 if (TARGET_SSE && TARGET_SSE_MATH)
4925 {
4926 emit_insn (gen_floatsidf2 (operands[0],
4927 convert_to_mode (SImode, operands[1], 0)));
4928 DONE;
4929 }
4930})
4931
4932(define_insn "*floathidf2_1"
155d8a47
JW
4933 [(set (match_operand:DF 0 "register_operand" "=f,f")
4934 (float:DF (match_operand:HI 1 "nonimmediate_operand" "m,r")))]
35c28a13 4935 "TARGET_80387 && (!TARGET_SSE2 || !TARGET_SSE_MATH)"
155d8a47 4936 "@
0f40f9f7 4937 fild%z1\t%1
155d8a47
JW
4938 #"
4939 [(set_attr "type" "fmov,multi")
6ef67412 4940 (set_attr "mode" "DF")
155d8a47
JW
4941 (set_attr "fp_int_src" "true")])
4942
42a0aa6f
JH
4943(define_expand "floatsidf2"
4944 [(set (match_operand:DF 0 "register_operand" "")
4945 (float:DF (match_operand:SI 1 "nonimmediate_operand" "")))]
6185f217 4946 "TARGET_80387 || TARGET_SSE2"
42a0aa6f
JH
4947 "")
4948
4949(define_insn "*floatsidf2_i387"
f56e86bd
JH
4950 [(set (match_operand:DF 0 "register_operand" "=f#Y,?f#Y,Y#f,Y#f")
4951 (float:DF (match_operand:SI 1 "nonimmediate_operand" "m,r,r,mr")))]
42a0aa6f 4952 "TARGET_80387 && (!TARGET_SSE2 || TARGET_MIX_SSE_I387)"
e075ae69 4953 "@
0f40f9f7 4954 fild%z1\t%1
42a0aa6f 4955 #
f56e86bd 4956 cvtsi2sd\t{%1, %0|%0, %1}
0f40f9f7 4957 cvtsi2sd\t{%1, %0|%0, %1}"
f56e86bd 4958 [(set_attr "type" "fmov,multi,sseicvt,sseicvt")
42a0aa6f 4959 (set_attr "mode" "DF")
f56e86bd 4960 (set_attr "athlon_decode" "*,*,double,direct")
42a0aa6f
JH
4961 (set_attr "fp_int_src" "true")])
4962
4963(define_insn "*floatsidf2_sse"
f56e86bd
JH
4964 [(set (match_operand:DF 0 "register_operand" "=Y,Y")
4965 (float:DF (match_operand:SI 1 "nonimmediate_operand" "r,mr")))]
42a0aa6f 4966 "TARGET_SSE2"
0f40f9f7 4967 "cvtsi2sd\t{%1, %0|%0, %1}"
f56e86bd 4968 [(set_attr "type" "sseicvt")
6ef67412 4969 (set_attr "mode" "DF")
f56e86bd 4970 (set_attr "athlon_decode" "double,direct")
e075ae69 4971 (set_attr "fp_int_src" "true")])
e1f998ad 4972
46ed7963
JH
4973(define_expand "floatdidf2"
4974 [(set (match_operand:DF 0 "register_operand" "")
4975 (float:DF (match_operand:DI 1 "nonimmediate_operand" "")))]
1b0c37d7 4976 "(TARGET_64BIT && TARGET_SSE2) || TARGET_80387"
46ed7963
JH
4977 "")
4978
ef6257cd
JH
4979(define_insn "*floatdidf2_i387_only"
4980 [(set (match_operand:DF 0 "register_operand" "=f,?f")
4981 (float:DF (match_operand:DI 1 "nonimmediate_operand" "m,r")))]
4982 "TARGET_80387 && (!TARGET_SSE2 || !TARGET_64BIT)"
4983 "@
0f40f9f7 4984 fild%z1\t%1
ef6257cd
JH
4985 #"
4986 [(set_attr "type" "fmov,multi")
4987 (set_attr "mode" "DF")
4988 (set_attr "fp_int_src" "true")])
4989
46ed7963 4990(define_insn "*floatdidf2_i387"
f56e86bd
JH
4991 [(set (match_operand:DF 0 "register_operand" "=f#Y,?f#Y,Y#f,Y#f")
4992 (float:DF (match_operand:DI 1 "nonimmediate_operand" "m,r,r,mr")))]
1b0c37d7 4993 "TARGET_64BIT && TARGET_80387 && (!TARGET_SSE2 || TARGET_MIX_SSE_I387)"
e075ae69 4994 "@
0f40f9f7 4995 fild%z1\t%1
46ed7963 4996 #
f56e86bd 4997 cvtsi2sd{q}\t{%1, %0|%0, %1}
0f40f9f7 4998 cvtsi2sd{q}\t{%1, %0|%0, %1}"
f56e86bd 4999 [(set_attr "type" "fmov,multi,sseicvt,sseicvt")
46ed7963 5000 (set_attr "mode" "DF")
f56e86bd 5001 (set_attr "athlon_decode" "*,*,double,direct")
46ed7963
JH
5002 (set_attr "fp_int_src" "true")])
5003
5004(define_insn "*floatdidf2_sse"
f56e86bd
JH
5005 [(set (match_operand:DF 0 "register_operand" "=Y,Y")
5006 (float:DF (match_operand:DI 1 "nonimmediate_operand" "r,mr")))]
46ed7963 5007 "TARGET_SSE2"
0f40f9f7 5008 "cvtsi2sd{q}\t{%1, %0|%0, %1}"
f56e86bd 5009 [(set_attr "type" "sseicvt")
6ef67412 5010 (set_attr "mode" "DF")
f56e86bd 5011 (set_attr "athlon_decode" "double,direct")
e075ae69 5012 (set_attr "fp_int_src" "true")])
bc725565 5013
155d8a47
JW
5014(define_insn "floathixf2"
5015 [(set (match_operand:XF 0 "register_operand" "=f,f")
5016 (float:XF (match_operand:HI 1 "nonimmediate_operand" "m,r")))]
1b0c37d7 5017 "!TARGET_64BIT && TARGET_80387"
155d8a47 5018 "@
0f40f9f7 5019 fild%z1\t%1
155d8a47
JW
5020 #"
5021 [(set_attr "type" "fmov,multi")
6ef67412 5022 (set_attr "mode" "XF")
155d8a47
JW
5023 (set_attr "fp_int_src" "true")])
5024
2b589241
JH
5025(define_insn "floathitf2"
5026 [(set (match_operand:TF 0 "register_operand" "=f,f")
5027 (float:TF (match_operand:HI 1 "nonimmediate_operand" "m,r")))]
5028 "TARGET_80387"
5029 "@
0f40f9f7 5030 fild%z1\t%1
2b589241
JH
5031 #"
5032 [(set_attr "type" "fmov,multi")
5033 (set_attr "mode" "XF")
5034 (set_attr "fp_int_src" "true")])
5035
e075ae69
RH
5036(define_insn "floatsixf2"
5037 [(set (match_operand:XF 0 "register_operand" "=f,f")
5038 (float:XF (match_operand:SI 1 "nonimmediate_operand" "m,r")))]
1b0c37d7 5039 "!TARGET_64BIT && TARGET_80387"
e075ae69 5040 "@
0f40f9f7 5041 fild%z1\t%1
e075ae69
RH
5042 #"
5043 [(set_attr "type" "fmov,multi")
6ef67412 5044 (set_attr "mode" "XF")
e075ae69 5045 (set_attr "fp_int_src" "true")])
53b5ce19 5046
2b589241
JH
5047(define_insn "floatsitf2"
5048 [(set (match_operand:TF 0 "register_operand" "=f,f")
5049 (float:TF (match_operand:SI 1 "nonimmediate_operand" "m,r")))]
5050 "TARGET_80387"
5051 "@
0f40f9f7 5052 fild%z1\t%1
2b589241
JH
5053 #"
5054 [(set_attr "type" "fmov,multi")
5055 (set_attr "mode" "XF")
5056 (set_attr "fp_int_src" "true")])
5057
e075ae69 5058(define_insn "floatdixf2"
53b5ce19 5059 [(set (match_operand:XF 0 "register_operand" "=f,f")
e075ae69 5060 (float:XF (match_operand:DI 1 "nonimmediate_operand" "m,r")))]
1b0c37d7 5061 "!TARGET_64BIT && TARGET_80387"
e075ae69 5062 "@
0f40f9f7 5063 fild%z1\t%1
e075ae69
RH
5064 #"
5065 [(set_attr "type" "fmov,multi")
6ef67412 5066 (set_attr "mode" "XF")
e075ae69 5067 (set_attr "fp_int_src" "true")])
53b5ce19 5068
2b589241
JH
5069(define_insn "floatditf2"
5070 [(set (match_operand:TF 0 "register_operand" "=f,f")
5071 (float:TF (match_operand:DI 1 "nonimmediate_operand" "m,r")))]
5072 "TARGET_80387"
5073 "@
0f40f9f7 5074 fild%z1\t%1
2b589241
JH
5075 #"
5076 [(set_attr "type" "fmov,multi")
5077 (set_attr "mode" "XF")
5078 (set_attr "fp_int_src" "true")])
5079
e075ae69 5080;; %%% Kill these when reload knows how to do it.
155d8a47 5081(define_split
c3c637e3 5082 [(set (match_operand 0 "fp_register_operand" "")
4211a8fb 5083 (float (match_operand 1 "register_operand" "")))]
c3c637e3 5084 "reload_completed && FLOAT_MODE_P (GET_MODE (operands[0]))"
4211a8fb 5085 [(const_int 0)]
4211a8fb
JH
5086{
5087 operands[2] = ix86_force_to_memory (GET_MODE (operands[1]), operands[1]);
5088 operands[2] = gen_rtx_FLOAT (GET_MODE (operands[0]), operands[2]);
5089 emit_insn (gen_rtx_SET (VOIDmode, operands[0], operands[2]));
5090 ix86_free_from_memory (GET_MODE (operands[1]));
5091 DONE;
0f40f9f7 5092})
8d705469
JH
5093
5094(define_expand "floatunssisf2"
5095 [(use (match_operand:SF 0 "register_operand" ""))
5096 (use (match_operand:SI 1 "register_operand" ""))]
5097 "TARGET_SSE && TARGET_SSE_MATH && !TARGET_64BIT"
5098 "x86_emit_floatuns (operands); DONE;")
5099
5100(define_expand "floatunsdisf2"
5101 [(use (match_operand:SF 0 "register_operand" ""))
5102 (use (match_operand:DI 1 "register_operand" ""))]
5103 "TARGET_SSE && TARGET_SSE_MATH && TARGET_64BIT"
5104 "x86_emit_floatuns (operands); DONE;")
5105
5106(define_expand "floatunsdidf2"
5107 [(use (match_operand:DF 0 "register_operand" ""))
5108 (use (match_operand:DI 1 "register_operand" ""))]
5109 "TARGET_SSE2 && TARGET_SSE_MATH && TARGET_64BIT"
5110 "x86_emit_floatuns (operands); DONE;")
e075ae69
RH
5111\f
5112;; Add instructions
53b5ce19 5113
e075ae69
RH
5114;; %%% splits for addsidi3
5115; [(set (match_operand:DI 0 "nonimmediate_operand" "")
5116; (plus:DI (match_operand:DI 1 "general_operand" "")
5117; (zero_extend:DI (match_operand:SI 2 "general_operand" ""))))]
e1f998ad 5118
9b70259d
JH
5119(define_expand "adddi3"
5120 [(set (match_operand:DI 0 "nonimmediate_operand" "")
5121 (plus:DI (match_operand:DI 1 "nonimmediate_operand" "")
5122 (match_operand:DI 2 "x86_64_general_operand" "")))
5123 (clobber (reg:CC 17))]
5124 ""
5125 "ix86_expand_binary_operator (PLUS, DImode, operands); DONE;")
5126
5127(define_insn "*adddi3_1"
e075ae69
RH
5128 [(set (match_operand:DI 0 "nonimmediate_operand" "=r,o")
5129 (plus:DI (match_operand:DI 1 "nonimmediate_operand" "%0,0")
5130 (match_operand:DI 2 "general_operand" "roiF,riF")))
5131 (clobber (reg:CC 17))]
c15c18c5 5132 "!TARGET_64BIT && ix86_binary_operator_ok (PLUS, DImode, operands)"
bc725565
JW
5133 "#")
5134
5135(define_split
e075ae69 5136 [(set (match_operand:DI 0 "nonimmediate_operand" "")
4cbfbb1b 5137 (plus:DI (match_operand:DI 1 "nonimmediate_operand" "")
e075ae69
RH
5138 (match_operand:DI 2 "general_operand" "")))
5139 (clobber (reg:CC 17))]
1b0c37d7 5140 "!TARGET_64BIT && reload_completed"
8ee41eaf
RH
5141 [(parallel [(set (reg:CC 17) (unspec:CC [(match_dup 1) (match_dup 2)]
5142 UNSPEC_ADD_CARRY))
e075ae69
RH
5143 (set (match_dup 0) (plus:SI (match_dup 1) (match_dup 2)))])
5144 (parallel [(set (match_dup 3)
7e08e190 5145 (plus:SI (plus:SI (ltu:SI (reg:CC 17) (const_int 0))
9dcbdc7e
JH
5146 (match_dup 4))
5147 (match_dup 5)))
e075ae69
RH
5148 (clobber (reg:CC 17))])]
5149 "split_di (operands+0, 1, operands+0, operands+3);
5150 split_di (operands+1, 1, operands+1, operands+4);
5151 split_di (operands+2, 1, operands+2, operands+5);")
5152
7b52eede 5153(define_insn "adddi3_carry_rex64"
9b70259d 5154 [(set (match_operand:DI 0 "nonimmediate_operand" "=rm,r")
e6e81735 5155 (plus:DI (plus:DI (match_operand:DI 3 "ix86_carry_flag_operator" "")
9b70259d
JH
5156 (match_operand:DI 1 "nonimmediate_operand" "%0,0"))
5157 (match_operand:DI 2 "x86_64_general_operand" "re,rm")))
5158 (clobber (reg:CC 17))]
1b0c37d7 5159 "TARGET_64BIT && ix86_binary_operator_ok (PLUS, DImode, operands)"
0f40f9f7 5160 "adc{q}\t{%2, %0|%0, %2}"
9b70259d
JH
5161 [(set_attr "type" "alu")
5162 (set_attr "pent_pair" "pu")
5163 (set_attr "mode" "DI")
5164 (set_attr "ppro_uops" "few")])
5165
5166(define_insn "*adddi3_cc_rex64"
8ee41eaf
RH
5167 [(set (reg:CC 17)
5168 (unspec:CC [(match_operand:DI 1 "nonimmediate_operand" "%0,0")
5169 (match_operand:DI 2 "x86_64_general_operand" "re,rm")]
5170 UNSPEC_ADD_CARRY))
9b70259d
JH
5171 (set (match_operand:DI 0 "nonimmediate_operand" "=rm,r")
5172 (plus:DI (match_dup 1) (match_dup 2)))]
5173 "TARGET_64BIT && ix86_binary_operator_ok (PLUS, DImode, operands)"
0f40f9f7 5174 "add{q}\t{%2, %0|%0, %2}"
9b70259d
JH
5175 [(set_attr "type" "alu")
5176 (set_attr "mode" "DI")])
5177
7b52eede
JH
5178(define_insn "addqi3_carry"
5179 [(set (match_operand:QI 0 "nonimmediate_operand" "=rm,r")
e6e81735 5180 (plus:QI (plus:QI (match_operand:QI 3 "ix86_carry_flag_operator" "")
7b52eede
JH
5181 (match_operand:QI 1 "nonimmediate_operand" "%0,0"))
5182 (match_operand:QI 2 "general_operand" "ri,rm")))
5183 (clobber (reg:CC 17))]
5184 "ix86_binary_operator_ok (PLUS, QImode, operands)"
5185 "adc{b}\t{%2, %0|%0, %2}"
5186 [(set_attr "type" "alu")
5187 (set_attr "pent_pair" "pu")
5188 (set_attr "mode" "QI")
5189 (set_attr "ppro_uops" "few")])
5190
5191(define_insn "addhi3_carry"
5192 [(set (match_operand:HI 0 "nonimmediate_operand" "=rm,r")
e6e81735 5193 (plus:HI (plus:HI (match_operand:HI 3 "ix86_carry_flag_operator" "")
7b52eede
JH
5194 (match_operand:HI 1 "nonimmediate_operand" "%0,0"))
5195 (match_operand:HI 2 "general_operand" "ri,rm")))
5196 (clobber (reg:CC 17))]
5197 "ix86_binary_operator_ok (PLUS, HImode, operands)"
5198 "adc{w}\t{%2, %0|%0, %2}"
5199 [(set_attr "type" "alu")
5200 (set_attr "pent_pair" "pu")
5201 (set_attr "mode" "HI")
5202 (set_attr "ppro_uops" "few")])
5203
5204(define_insn "addsi3_carry"
e075ae69 5205 [(set (match_operand:SI 0 "nonimmediate_operand" "=rm,r")
e6e81735 5206 (plus:SI (plus:SI (match_operand:SI 3 "ix86_carry_flag_operator" "")
9dcbdc7e
JH
5207 (match_operand:SI 1 "nonimmediate_operand" "%0,0"))
5208 (match_operand:SI 2 "general_operand" "ri,rm")))
e075ae69 5209 (clobber (reg:CC 17))]
d525dfdf 5210 "ix86_binary_operator_ok (PLUS, SImode, operands)"
0f40f9f7 5211 "adc{l}\t{%2, %0|%0, %2}"
e075ae69
RH
5212 [(set_attr "type" "alu")
5213 (set_attr "pent_pair" "pu")
6ef67412 5214 (set_attr "mode" "SI")
e075ae69 5215 (set_attr "ppro_uops" "few")])
4fb21e90 5216
9b70259d
JH
5217(define_insn "*addsi3_carry_zext"
5218 [(set (match_operand:DI 0 "register_operand" "=r")
5219 (zero_extend:DI
e6e81735 5220 (plus:SI (plus:SI (match_operand:SI 3 "ix86_carry_flag_operator" "")
9b70259d
JH
5221 (match_operand:SI 1 "nonimmediate_operand" "%0"))
5222 (match_operand:SI 2 "general_operand" "rim"))))
5223 (clobber (reg:CC 17))]
5224 "TARGET_64BIT && ix86_binary_operator_ok (PLUS, SImode, operands)"
0f40f9f7 5225 "adc{l}\t{%2, %k0|%k0, %2}"
9b70259d
JH
5226 [(set_attr "type" "alu")
5227 (set_attr "pent_pair" "pu")
5228 (set_attr "mode" "SI")
5229 (set_attr "ppro_uops" "few")])
5230
7e08e190 5231(define_insn "*addsi3_cc"
8ee41eaf
RH
5232 [(set (reg:CC 17)
5233 (unspec:CC [(match_operand:SI 1 "nonimmediate_operand" "%0,0")
5234 (match_operand:SI 2 "general_operand" "ri,rm")]
5235 UNSPEC_ADD_CARRY))
7e08e190
JH
5236 (set (match_operand:SI 0 "nonimmediate_operand" "=rm,r")
5237 (plus:SI (match_dup 1) (match_dup 2)))]
265dab10 5238 "ix86_binary_operator_ok (PLUS, SImode, operands)"
0f40f9f7 5239 "add{l}\t{%2, %0|%0, %2}"
265dab10 5240 [(set_attr "type" "alu")
7e08e190
JH
5241 (set_attr "mode" "SI")])
5242
5243(define_insn "addqi3_cc"
8ee41eaf
RH
5244 [(set (reg:CC 17)
5245 (unspec:CC [(match_operand:QI 1 "nonimmediate_operand" "%0,0")
5246 (match_operand:QI 2 "general_operand" "qi,qm")]
5247 UNSPEC_ADD_CARRY))
7e08e190
JH
5248 (set (match_operand:QI 0 "nonimmediate_operand" "=qm,q")
5249 (plus:QI (match_dup 1) (match_dup 2)))]
5250 "ix86_binary_operator_ok (PLUS, QImode, operands)"
0f40f9f7 5251 "add{b}\t{%2, %0|%0, %2}"
7e08e190
JH
5252 [(set_attr "type" "alu")
5253 (set_attr "mode" "QI")])
265dab10 5254
e075ae69
RH
5255(define_expand "addsi3"
5256 [(parallel [(set (match_operand:SI 0 "nonimmediate_operand" "")
5257 (plus:SI (match_operand:SI 1 "nonimmediate_operand" "")
5258 (match_operand:SI 2 "general_operand" "")))
5259 (clobber (reg:CC 17))])]
5260 ""
5261 "ix86_expand_binary_operator (PLUS, SImode, operands); DONE;")
886c62d1 5262
ac62a60e 5263(define_insn "*lea_1"
e075ae69 5264 [(set (match_operand:SI 0 "register_operand" "=r")
ad678cb0 5265 (match_operand:SI 1 "address_operand" "p"))]
ac62a60e 5266 "!TARGET_64BIT"
0f40f9f7 5267 "lea{l}\t{%a1, %0|%0, %a1}"
6ef67412
JH
5268 [(set_attr "type" "lea")
5269 (set_attr "mode" "SI")])
2ae0f82c 5270
ac62a60e
JH
5271(define_insn "*lea_1_rex64"
5272 [(set (match_operand:SI 0 "register_operand" "=r")
5273 (subreg:SI (match_operand:DI 1 "address_operand" "p") 0))]
5274 "TARGET_64BIT"
0f40f9f7 5275 "lea{l}\t{%a1, %0|%0, %a1}"
ac62a60e
JH
5276 [(set_attr "type" "lea")
5277 (set_attr "mode" "SI")])
5278
5279(define_insn "*lea_1_zext"
5280 [(set (match_operand:DI 0 "register_operand" "=r")
5281 (zero_extend:DI (subreg:SI (match_operand:DI 1 "address_operand" "p") 0)))]
d4f33f6c 5282 "TARGET_64BIT"
0f40f9f7 5283 "lea{l}\t{%a1, %k0|%k0, %a1}"
ac62a60e
JH
5284 [(set_attr "type" "lea")
5285 (set_attr "mode" "SI")])
5286
5287(define_insn "*lea_2_rex64"
5288 [(set (match_operand:DI 0 "register_operand" "=r")
5289 (match_operand:DI 1 "address_operand" "p"))]
5290 "TARGET_64BIT"
0f40f9f7 5291 "lea{q}\t{%a1, %0|%0, %a1}"
ac62a60e
JH
5292 [(set_attr "type" "lea")
5293 (set_attr "mode" "DI")])
5294
58787064
JH
5295;; The lea patterns for non-Pmodes needs to be matched by several
5296;; insns converted to real lea by splitters.
5297
5298(define_insn_and_split "*lea_general_1"
5299 [(set (match_operand 0 "register_operand" "=r")
7ec70495 5300 (plus (plus (match_operand 1 "index_register_operand" "r")
58787064
JH
5301 (match_operand 2 "register_operand" "r"))
5302 (match_operand 3 "immediate_operand" "i")))]
ac62a60e
JH
5303 "(GET_MODE (operands[0]) == QImode || GET_MODE (operands[0]) == HImode
5304 || (TARGET_64BIT && GET_MODE (operands[0]) == SImode))
58787064
JH
5305 && (!TARGET_PARTIAL_REG_STALL || optimize_size)
5306 && GET_MODE (operands[0]) == GET_MODE (operands[1])
5307 && GET_MODE (operands[0]) == GET_MODE (operands[2])
5308 && (GET_MODE (operands[0]) == GET_MODE (operands[3])
5309 || GET_MODE (operands[3]) == VOIDmode)"
5310 "#"
cb694d2c 5311 "&& reload_completed"
58787064 5312 [(const_int 0)]
58787064
JH
5313{
5314 rtx pat;
5315 operands[0] = gen_lowpart (SImode, operands[0]);
5316 operands[1] = gen_lowpart (Pmode, operands[1]);
5317 operands[2] = gen_lowpart (Pmode, operands[2]);
5318 operands[3] = gen_lowpart (Pmode, operands[3]);
5319 pat = gen_rtx_PLUS (Pmode, gen_rtx_PLUS (Pmode, operands[1], operands[2]),
5320 operands[3]);
5321 if (Pmode != SImode)
5322 pat = gen_rtx_SUBREG (SImode, pat, 0);
5323 emit_insn (gen_rtx_SET (VOIDmode, operands[0], pat));
5324 DONE;
0f40f9f7 5325}
58787064
JH
5326 [(set_attr "type" "lea")
5327 (set_attr "mode" "SI")])
5328
ac62a60e
JH
5329(define_insn_and_split "*lea_general_1_zext"
5330 [(set (match_operand:DI 0 "register_operand" "=r")
5331 (zero_extend:DI
7ec70495 5332 (plus:SI (plus:SI (match_operand:SI 1 "index_register_operand" "r")
ac62a60e
JH
5333 (match_operand:SI 2 "register_operand" "r"))
5334 (match_operand:SI 3 "immediate_operand" "i"))))]
5335 "TARGET_64BIT"
5336 "#"
5337 "&& reload_completed"
5338 [(set (match_dup 0)
5339 (zero_extend:DI (subreg:SI (plus:DI (plus:DI (match_dup 1)
5340 (match_dup 2))
5341 (match_dup 3)) 0)))]
ac62a60e
JH
5342{
5343 operands[1] = gen_lowpart (Pmode, operands[1]);
5344 operands[2] = gen_lowpart (Pmode, operands[2]);
5345 operands[3] = gen_lowpart (Pmode, operands[3]);
0f40f9f7 5346}
ac62a60e
JH
5347 [(set_attr "type" "lea")
5348 (set_attr "mode" "SI")])
5349
58787064
JH
5350(define_insn_and_split "*lea_general_2"
5351 [(set (match_operand 0 "register_operand" "=r")
7ec70495 5352 (plus (mult (match_operand 1 "index_register_operand" "r")
58787064
JH
5353 (match_operand 2 "const248_operand" "i"))
5354 (match_operand 3 "nonmemory_operand" "ri")))]
ac62a60e
JH
5355 "(GET_MODE (operands[0]) == QImode || GET_MODE (operands[0]) == HImode
5356 || (TARGET_64BIT && GET_MODE (operands[0]) == SImode))
58787064
JH
5357 && (!TARGET_PARTIAL_REG_STALL || optimize_size)
5358 && GET_MODE (operands[0]) == GET_MODE (operands[1])
5359 && (GET_MODE (operands[0]) == GET_MODE (operands[3])
5360 || GET_MODE (operands[3]) == VOIDmode)"
5361 "#"
cb694d2c 5362 "&& reload_completed"
58787064 5363 [(const_int 0)]
58787064
JH
5364{
5365 rtx pat;
5366 operands[0] = gen_lowpart (SImode, operands[0]);
5367 operands[1] = gen_lowpart (Pmode, operands[1]);
5368 operands[3] = gen_lowpart (Pmode, operands[3]);
5369 pat = gen_rtx_PLUS (Pmode, gen_rtx_MULT (Pmode, operands[1], operands[2]),
5370 operands[3]);
5371 if (Pmode != SImode)
5372 pat = gen_rtx_SUBREG (SImode, pat, 0);
5373 emit_insn (gen_rtx_SET (VOIDmode, operands[0], pat));
5374 DONE;
0f40f9f7 5375}
58787064
JH
5376 [(set_attr "type" "lea")
5377 (set_attr "mode" "SI")])
5378
ac62a60e
JH
5379(define_insn_and_split "*lea_general_2_zext"
5380 [(set (match_operand:DI 0 "register_operand" "=r")
5381 (zero_extend:DI
7ec70495 5382 (plus:SI (mult:SI (match_operand:SI 1 "index_register_operand" "r")
ac62a60e
JH
5383 (match_operand:SI 2 "const248_operand" "n"))
5384 (match_operand:SI 3 "nonmemory_operand" "ri"))))]
5385 "TARGET_64BIT"
5386 "#"
5387 "&& reload_completed"
5388 [(set (match_dup 0)
5389 (zero_extend:DI (subreg:SI (plus:DI (mult:DI (match_dup 1)
5390 (match_dup 2))
5391 (match_dup 3)) 0)))]
ac62a60e
JH
5392{
5393 operands[1] = gen_lowpart (Pmode, operands[1]);
5394 operands[3] = gen_lowpart (Pmode, operands[3]);
0f40f9f7 5395}
ac62a60e
JH
5396 [(set_attr "type" "lea")
5397 (set_attr "mode" "SI")])
5398
58787064
JH
5399(define_insn_and_split "*lea_general_3"
5400 [(set (match_operand 0 "register_operand" "=r")
7ec70495 5401 (plus (plus (mult (match_operand 1 "index_register_operand" "r")
58787064
JH
5402 (match_operand 2 "const248_operand" "i"))
5403 (match_operand 3 "register_operand" "r"))
5404 (match_operand 4 "immediate_operand" "i")))]
ac62a60e
JH
5405 "(GET_MODE (operands[0]) == QImode || GET_MODE (operands[0]) == HImode
5406 || (TARGET_64BIT && GET_MODE (operands[0]) == SImode))
58787064
JH
5407 && (!TARGET_PARTIAL_REG_STALL || optimize_size)
5408 && GET_MODE (operands[0]) == GET_MODE (operands[1])
5409 && GET_MODE (operands[0]) == GET_MODE (operands[3])"
5410 "#"
cb694d2c 5411 "&& reload_completed"
58787064 5412 [(const_int 0)]
58787064
JH
5413{
5414 rtx pat;
5415 operands[0] = gen_lowpart (SImode, operands[0]);
5416 operands[1] = gen_lowpart (Pmode, operands[1]);
5417 operands[3] = gen_lowpart (Pmode, operands[3]);
5418 operands[4] = gen_lowpart (Pmode, operands[4]);
5419 pat = gen_rtx_PLUS (Pmode,
5420 gen_rtx_PLUS (Pmode, gen_rtx_MULT (Pmode, operands[1],
5421 operands[2]),
5422 operands[3]),
5423 operands[4]);
5424 if (Pmode != SImode)
5425 pat = gen_rtx_SUBREG (SImode, pat, 0);
5426 emit_insn (gen_rtx_SET (VOIDmode, operands[0], pat));
5427 DONE;
0f40f9f7 5428}
58787064
JH
5429 [(set_attr "type" "lea")
5430 (set_attr "mode" "SI")])
5431
ac62a60e
JH
5432(define_insn_and_split "*lea_general_3_zext"
5433 [(set (match_operand:DI 0 "register_operand" "=r")
5434 (zero_extend:DI
7ec70495 5435 (plus:SI (plus:SI (mult:SI (match_operand:SI 1 "index_register_operand" "r")
ac62a60e
JH
5436 (match_operand:SI 2 "const248_operand" "n"))
5437 (match_operand:SI 3 "register_operand" "r"))
5438 (match_operand:SI 4 "immediate_operand" "i"))))]
5439 "TARGET_64BIT"
5440 "#"
5441 "&& reload_completed"
5442 [(set (match_dup 0)
5443 (zero_extend:DI (subreg:SI (plus:DI (plus:DI (mult:DI (match_dup 1)
5444 (match_dup 2))
5445 (match_dup 3))
5446 (match_dup 4)) 0)))]
ac62a60e
JH
5447{
5448 operands[1] = gen_lowpart (Pmode, operands[1]);
5449 operands[3] = gen_lowpart (Pmode, operands[3]);
5450 operands[4] = gen_lowpart (Pmode, operands[4]);
0f40f9f7 5451}
ac62a60e
JH
5452 [(set_attr "type" "lea")
5453 (set_attr "mode" "SI")])
5454
9b70259d
JH
5455(define_insn "*adddi_1_rex64"
5456 [(set (match_operand:DI 0 "nonimmediate_operand" "=r,rm,r")
5457 (plus:DI (match_operand:DI 1 "nonimmediate_operand" "%0,0,r")
5458 (match_operand:DI 2 "x86_64_general_operand" "rme,re,re")))
e075ae69 5459 (clobber (reg:CC 17))]
9b70259d 5460 "TARGET_64BIT && ix86_binary_operator_ok (PLUS, DImode, operands)"
2ae0f82c 5461{
e075ae69 5462 switch (get_attr_type (insn))
2ae0f82c 5463 {
e075ae69
RH
5464 case TYPE_LEA:
5465 operands[2] = SET_SRC (XVECEXP (PATTERN (insn), 0, 0));
0f40f9f7 5466 return "lea{q}\t{%a2, %0|%0, %a2}";
2ae0f82c 5467
e075ae69
RH
5468 case TYPE_INCDEC:
5469 if (! rtx_equal_p (operands[0], operands[1]))
5470 abort ();
5471 if (operands[2] == const1_rtx)
0f40f9f7 5472 return "inc{q}\t%0";
e075ae69 5473 else if (operands[2] == constm1_rtx)
0f40f9f7 5474 return "dec{q}\t%0";
2ae0f82c 5475 else
9b70259d 5476 abort ();
2ae0f82c 5477
e075ae69
RH
5478 default:
5479 if (! rtx_equal_p (operands[0], operands[1]))
5480 abort ();
2ae0f82c 5481
e075ae69
RH
5482 /* Make things pretty and `subl $4,%eax' rather than `addl $-4, %eax'.
5483 Exceptions: -128 encodes smaller than 128, so swap sign and op. */
5484 if (GET_CODE (operands[2]) == CONST_INT
ef6257cd 5485 /* Avoid overflows. */
0f40f9f7 5486 && ((INTVAL (operands[2]) & ((((unsigned int) 1) << 31) - 1)))
e075ae69
RH
5487 && (INTVAL (operands[2]) == 128
5488 || (INTVAL (operands[2]) < 0
5489 && INTVAL (operands[2]) != -128)))
5490 {
5491 operands[2] = GEN_INT (-INTVAL (operands[2]));
0f40f9f7 5492 return "sub{q}\t{%2, %0|%0, %2}";
e075ae69 5493 }
0f40f9f7 5494 return "add{q}\t{%2, %0|%0, %2}";
e075ae69 5495 }
0f40f9f7 5496}
e075ae69
RH
5497 [(set (attr "type")
5498 (cond [(eq_attr "alternative" "2")
5499 (const_string "lea")
5500 ; Current assemblers are broken and do not allow @GOTOFF in
5501 ; ought but a memory context.
9b70259d 5502 (match_operand:DI 2 "pic_symbolic_operand" "")
e075ae69 5503 (const_string "lea")
9b70259d 5504 (match_operand:DI 2 "incdec_operand" "")
e075ae69
RH
5505 (const_string "incdec")
5506 ]
6ef67412 5507 (const_string "alu")))
9b70259d 5508 (set_attr "mode" "DI")])
e075ae69 5509
1c27d4b2
JH
5510;; Convert lea to the lea pattern to avoid flags dependency.
5511(define_split
9b70259d
JH
5512 [(set (match_operand:DI 0 "register_operand" "")
5513 (plus:DI (match_operand:DI 1 "register_operand" "")
5514 (match_operand:DI 2 "x86_64_nonmemory_operand" "")))
1c27d4b2 5515 (clobber (reg:CC 17))]
1b0c37d7 5516 "TARGET_64BIT && reload_completed
abe24fb3 5517 && true_regnum (operands[0]) != true_regnum (operands[1])"
9b70259d
JH
5518 [(set (match_dup 0)
5519 (plus:DI (match_dup 1)
5520 (match_dup 2)))]
5521 "")
1c27d4b2 5522
9b70259d 5523(define_insn "*adddi_2_rex64"
16189740
RH
5524 [(set (reg 17)
5525 (compare
9b70259d
JH
5526 (plus:DI (match_operand:DI 1 "nonimmediate_operand" "%0,0")
5527 (match_operand:DI 2 "x86_64_general_operand" "rme,re"))
e075ae69 5528 (const_int 0)))
9b70259d
JH
5529 (set (match_operand:DI 0 "nonimmediate_operand" "=r,rm")
5530 (plus:DI (match_dup 1) (match_dup 2)))]
5531 "TARGET_64BIT && ix86_match_ccmode (insn, CCGOCmode)
5532 && ix86_binary_operator_ok (PLUS, DImode, operands)
e075ae69 5533 /* Current assemblers are broken and do not allow @GOTOFF in
892a2d68 5534 ought but a memory context. */
e075ae69 5535 && ! pic_symbolic_operand (operands[2], VOIDmode)"
886c62d1 5536{
e075ae69 5537 switch (get_attr_type (insn))
96f218bb 5538 {
e075ae69
RH
5539 case TYPE_INCDEC:
5540 if (! rtx_equal_p (operands[0], operands[1]))
5541 abort ();
5542 if (operands[2] == const1_rtx)
0f40f9f7 5543 return "inc{q}\t%0";
e075ae69 5544 else if (operands[2] == constm1_rtx)
0f40f9f7 5545 return "dec{q}\t%0";
96f218bb 5546 else
9b70259d 5547 abort ();
96f218bb 5548
e075ae69
RH
5549 default:
5550 if (! rtx_equal_p (operands[0], operands[1]))
5551 abort ();
9b70259d 5552 /* ???? We ought to handle there the 32bit case too
5bdc5878 5553 - do we need new constraint? */
e075ae69
RH
5554 /* Make things pretty and `subl $4,%eax' rather than `addl $-4, %eax'.
5555 Exceptions: -128 encodes smaller than 128, so swap sign and op. */
5556 if (GET_CODE (operands[2]) == CONST_INT
ef6257cd 5557 /* Avoid overflows. */
0f40f9f7 5558 && ((INTVAL (operands[2]) & ((((unsigned int) 1) << 31) - 1)))
e075ae69
RH
5559 && (INTVAL (operands[2]) == 128
5560 || (INTVAL (operands[2]) < 0
5561 && INTVAL (operands[2]) != -128)))
5562 {
5563 operands[2] = GEN_INT (-INTVAL (operands[2]));
0f40f9f7 5564 return "sub{q}\t{%2, %0|%0, %2}";
e075ae69 5565 }
0f40f9f7 5566 return "add{q}\t{%2, %0|%0, %2}";
9c530261 5567 }
0f40f9f7 5568}
e075ae69 5569 [(set (attr "type")
9b70259d 5570 (if_then_else (match_operand:DI 2 "incdec_operand" "")
e075ae69 5571 (const_string "incdec")
6ef67412 5572 (const_string "alu")))
9b70259d 5573 (set_attr "mode" "DI")])
e075ae69 5574
e74061a9 5575(define_insn "*adddi_3_rex64"
d90ffc8d 5576 [(set (reg 17)
9b70259d
JH
5577 (compare (neg:DI (match_operand:DI 2 "x86_64_general_operand" "rme"))
5578 (match_operand:DI 1 "x86_64_general_operand" "%0")))
5579 (clobber (match_scratch:DI 0 "=r"))]
e74061a9
JH
5580 "TARGET_64BIT
5581 && ix86_match_ccmode (insn, CCZmode)
d90ffc8d
JH
5582 && (GET_CODE (operands[1]) != MEM || GET_CODE (operands[2]) != MEM)
5583 /* Current assemblers are broken and do not allow @GOTOFF in
892a2d68 5584 ought but a memory context. */
d90ffc8d 5585 && ! pic_symbolic_operand (operands[2], VOIDmode)"
d90ffc8d
JH
5586{
5587 switch (get_attr_type (insn))
5588 {
5589 case TYPE_INCDEC:
5590 if (! rtx_equal_p (operands[0], operands[1]))
5591 abort ();
5592 if (operands[2] == const1_rtx)
0f40f9f7 5593 return "inc{q}\t%0";
d90ffc8d 5594 else if (operands[2] == constm1_rtx)
0f40f9f7 5595 return "dec{q}\t%0";
d90ffc8d 5596 else
9b70259d 5597 abort ();
d90ffc8d
JH
5598
5599 default:
5600 if (! rtx_equal_p (operands[0], operands[1]))
5601 abort ();
9b70259d 5602 /* ???? We ought to handle there the 32bit case too
5bdc5878 5603 - do we need new constraint? */
d90ffc8d
JH
5604 /* Make things pretty and `subl $4,%eax' rather than `addl $-4, %eax'.
5605 Exceptions: -128 encodes smaller than 128, so swap sign and op. */
5606 if (GET_CODE (operands[2]) == CONST_INT
ef6257cd 5607 /* Avoid overflows. */
0f40f9f7 5608 && ((INTVAL (operands[2]) & ((((unsigned int) 1) << 31) - 1)))
d90ffc8d
JH
5609 && (INTVAL (operands[2]) == 128
5610 || (INTVAL (operands[2]) < 0
5611 && INTVAL (operands[2]) != -128)))
5612 {
5613 operands[2] = GEN_INT (-INTVAL (operands[2]));
0f40f9f7 5614 return "sub{q}\t{%2, %0|%0, %2}";
d90ffc8d 5615 }
0f40f9f7 5616 return "add{q}\t{%2, %0|%0, %2}";
d90ffc8d 5617 }
0f40f9f7 5618}
d90ffc8d 5619 [(set (attr "type")
9b70259d 5620 (if_then_else (match_operand:DI 2 "incdec_operand" "")
d90ffc8d
JH
5621 (const_string "incdec")
5622 (const_string "alu")))
9b70259d 5623 (set_attr "mode" "DI")])
d90ffc8d 5624
9b70259d 5625; For comparisons against 1, -1 and 128, we may generate better code
7e08e190
JH
5626; by converting cmp to add, inc or dec as done by peephole2. This pattern
5627; is matched then. We can't accept general immediate, because for
5628; case of overflows, the result is messed up.
9b70259d 5629; This pattern also don't hold of 0x8000000000000000, since the value overflows
7e08e190 5630; when negated.
d6a7951f 5631; Also carry flag is reversed compared to cmp, so this conversion is valid
7e08e190 5632; only for comparisons not depending on it.
e74061a9 5633(define_insn "*adddi_4_rex64"
9076b9c1 5634 [(set (reg 17)
9b70259d
JH
5635 (compare (match_operand:DI 1 "nonimmediate_operand" "0")
5636 (match_operand:DI 2 "x86_64_immediate_operand" "e")))
5637 (clobber (match_scratch:DI 0 "=rm"))]
e74061a9
JH
5638 "TARGET_64BIT
5639 && ix86_match_ccmode (insn, CCGCmode)"
7e08e190
JH
5640{
5641 switch (get_attr_type (insn))
5642 {
5643 case TYPE_INCDEC:
5644 if (operands[2] == constm1_rtx)
0f40f9f7 5645 return "inc{q}\t%0";
7e08e190 5646 else if (operands[2] == const1_rtx)
0f40f9f7 5647 return "dec{q}\t%0";
7e08e190
JH
5648 else
5649 abort();
e075ae69 5650
7e08e190
JH
5651 default:
5652 if (! rtx_equal_p (operands[0], operands[1]))
5653 abort ();
5654 /* Make things pretty and `subl $4,%eax' rather than `addl $-4, %eax'.
5655 Exceptions: -128 encodes smaller than 128, so swap sign and op. */
5656 if ((INTVAL (operands[2]) == -128
5657 || (INTVAL (operands[2]) > 0
ef6257cd
JH
5658 && INTVAL (operands[2]) != 128))
5659 /* Avoid overflows. */
0f40f9f7
ZW
5660 && ((INTVAL (operands[2]) & ((((unsigned int) 1) << 31) - 1))))
5661 return "sub{q}\t{%2, %0|%0, %2}";
7e08e190 5662 operands[2] = GEN_INT (-INTVAL (operands[2]));
0f40f9f7 5663 return "add{q}\t{%2, %0|%0, %2}";
7e08e190 5664 }
0f40f9f7 5665}
7e08e190 5666 [(set (attr "type")
9b70259d 5667 (if_then_else (match_operand:DI 2 "incdec_operand" "")
7e08e190
JH
5668 (const_string "incdec")
5669 (const_string "alu")))
9b70259d 5670 (set_attr "mode" "DI")])
d90ffc8d 5671
e74061a9 5672(define_insn "*adddi_5_rex64"
9076b9c1
JH
5673 [(set (reg 17)
5674 (compare
9b70259d
JH
5675 (plus:DI (match_operand:DI 1 "nonimmediate_operand" "%0")
5676 (match_operand:DI 2 "x86_64_general_operand" "rme"))
9076b9c1 5677 (const_int 0)))
9b70259d 5678 (clobber (match_scratch:DI 0 "=r"))]
e74061a9
JH
5679 "TARGET_64BIT
5680 && ix86_match_ccmode (insn, CCGOCmode)
9076b9c1
JH
5681 && (GET_CODE (operands[1]) != MEM || GET_CODE (operands[2]) != MEM)
5682 /* Current assemblers are broken and do not allow @GOTOFF in
892a2d68 5683 ought but a memory context. */
9076b9c1 5684 && ! pic_symbolic_operand (operands[2], VOIDmode)"
9076b9c1
JH
5685{
5686 switch (get_attr_type (insn))
5687 {
5688 case TYPE_INCDEC:
5689 if (! rtx_equal_p (operands[0], operands[1]))
5690 abort ();
5691 if (operands[2] == const1_rtx)
0f40f9f7 5692 return "inc{q}\t%0";
9076b9c1 5693 else if (operands[2] == constm1_rtx)
0f40f9f7 5694 return "dec{q}\t%0";
9076b9c1
JH
5695 else
5696 abort();
5697
5698 default:
5699 if (! rtx_equal_p (operands[0], operands[1]))
5700 abort ();
5701 /* Make things pretty and `subl $4,%eax' rather than `addl $-4, %eax'.
5702 Exceptions: -128 encodes smaller than 128, so swap sign and op. */
5703 if (GET_CODE (operands[2]) == CONST_INT
ef6257cd 5704 /* Avoid overflows. */
0f40f9f7 5705 && ((INTVAL (operands[2]) & ((((unsigned int) 1) << 31) - 1)))
9076b9c1
JH
5706 && (INTVAL (operands[2]) == 128
5707 || (INTVAL (operands[2]) < 0
5708 && INTVAL (operands[2]) != -128)))
5709 {
5710 operands[2] = GEN_INT (-INTVAL (operands[2]));
0f40f9f7 5711 return "sub{q}\t{%2, %0|%0, %2}";
9076b9c1 5712 }
0f40f9f7 5713 return "add{q}\t{%2, %0|%0, %2}";
9076b9c1 5714 }
0f40f9f7 5715}
9076b9c1 5716 [(set (attr "type")
9b70259d 5717 (if_then_else (match_operand:DI 2 "incdec_operand" "")
9076b9c1
JH
5718 (const_string "incdec")
5719 (const_string "alu")))
9b70259d 5720 (set_attr "mode" "DI")])
2ae0f82c 5721
e075ae69 5722
9b70259d
JH
5723(define_insn "*addsi_1"
5724 [(set (match_operand:SI 0 "nonimmediate_operand" "=r,rm,r")
5725 (plus:SI (match_operand:SI 1 "nonimmediate_operand" "%0,0,r")
5726 (match_operand:SI 2 "general_operand" "rmni,rni,rni")))
58787064 5727 (clobber (reg:CC 17))]
9b70259d 5728 "ix86_binary_operator_ok (PLUS, SImode, operands)"
58787064
JH
5729{
5730 switch (get_attr_type (insn))
5731 {
5732 case TYPE_LEA:
9b70259d 5733 operands[2] = SET_SRC (XVECEXP (PATTERN (insn), 0, 0));
0f40f9f7 5734 return "lea{l}\t{%a2, %0|%0, %a2}";
9b70259d 5735
58787064 5736 case TYPE_INCDEC:
9b70259d
JH
5737 if (! rtx_equal_p (operands[0], operands[1]))
5738 abort ();
58787064 5739 if (operands[2] == const1_rtx)
0f40f9f7 5740 return "inc{l}\t%0";
9b70259d 5741 else if (operands[2] == constm1_rtx)
0f40f9f7 5742 return "dec{l}\t%0";
9b70259d
JH
5743 else
5744 abort();
58787064
JH
5745
5746 default:
9b70259d
JH
5747 if (! rtx_equal_p (operands[0], operands[1]))
5748 abort ();
5749
58787064
JH
5750 /* Make things pretty and `subl $4,%eax' rather than `addl $-4, %eax'.
5751 Exceptions: -128 encodes smaller than 128, so swap sign and op. */
5752 if (GET_CODE (operands[2]) == CONST_INT
5753 && (INTVAL (operands[2]) == 128
5754 || (INTVAL (operands[2]) < 0
5755 && INTVAL (operands[2]) != -128)))
9b70259d
JH
5756 {
5757 operands[2] = GEN_INT (-INTVAL (operands[2]));
0f40f9f7 5758 return "sub{l}\t{%2, %0|%0, %2}";
9b70259d 5759 }
0f40f9f7 5760 return "add{l}\t{%2, %0|%0, %2}";
58787064 5761 }
0f40f9f7 5762}
58787064 5763 [(set (attr "type")
9b70259d
JH
5764 (cond [(eq_attr "alternative" "2")
5765 (const_string "lea")
5766 ; Current assemblers are broken and do not allow @GOTOFF in
5767 ; ought but a memory context.
5768 (match_operand:SI 2 "pic_symbolic_operand" "")
5769 (const_string "lea")
5770 (match_operand:SI 2 "incdec_operand" "")
5771 (const_string "incdec")
5772 ]
5773 (const_string "alu")))
5774 (set_attr "mode" "SI")])
58787064 5775
9b70259d
JH
5776;; Convert lea to the lea pattern to avoid flags dependency.
5777(define_split
5778 [(set (match_operand 0 "register_operand" "")
5779 (plus (match_operand 1 "register_operand" "")
5780 (match_operand 2 "nonmemory_operand" "")))
e075ae69 5781 (clobber (reg:CC 17))]
9b70259d
JH
5782 "reload_completed
5783 && true_regnum (operands[0]) != true_regnum (operands[1])"
5784 [(const_int 0)]
9b70259d
JH
5785{
5786 rtx pat;
5787 /* In -fPIC mode the constructs like (const (unspec [symbol_ref]))
5788 may confuse gen_lowpart. */
5789 if (GET_MODE (operands[0]) != Pmode)
5790 {
5791 operands[1] = gen_lowpart (Pmode, operands[1]);
5792 operands[2] = gen_lowpart (Pmode, operands[2]);
5793 }
5794 operands[0] = gen_lowpart (SImode, operands[0]);
5795 pat = gen_rtx_PLUS (Pmode, operands[1], operands[2]);
5796 if (Pmode != SImode)
5797 pat = gen_rtx_SUBREG (SImode, pat, 0);
5798 emit_insn (gen_rtx_SET (VOIDmode, operands[0], pat));
5799 DONE;
0f40f9f7 5800})
9b70259d
JH
5801
5802;; It may seem that nonimmediate operand is proper one for operand 1.
5803;; The addsi_1 pattern allows nonimmediate operand at that place and
5804;; we take care in ix86_binary_operator_ok to not allow two memory
5805;; operands so proper swapping will be done in reload. This allow
5806;; patterns constructed from addsi_1 to match.
5807(define_insn "addsi_1_zext"
5808 [(set (match_operand:DI 0 "register_operand" "=r,r")
5809 (zero_extend:DI
5810 (plus:SI (match_operand:SI 1 "nonimmediate_operand" "%0,r")
5811 (match_operand:SI 2 "general_operand" "rmni,rni"))))
5812 (clobber (reg:CC 17))]
5813 "TARGET_64BIT && ix86_binary_operator_ok (PLUS, SImode, operands)"
886c62d1 5814{
e075ae69 5815 switch (get_attr_type (insn))
7c802a40 5816 {
9b70259d
JH
5817 case TYPE_LEA:
5818 operands[2] = SET_SRC (XVECEXP (PATTERN (insn), 0, 0));
0f40f9f7 5819 return "lea{l}\t{%a2, %k0|%k0, %a2}";
9b70259d 5820
e075ae69
RH
5821 case TYPE_INCDEC:
5822 if (operands[2] == const1_rtx)
0f40f9f7 5823 return "inc{l}\t%k0";
9b70259d 5824 else if (operands[2] == constm1_rtx)
0f40f9f7 5825 return "dec{l}\t%k0";
9b70259d
JH
5826 else
5827 abort();
5828
5829 default:
5830 /* Make things pretty and `subl $4,%eax' rather than `addl $-4, %eax'.
5831 Exceptions: -128 encodes smaller than 128, so swap sign and op. */
5832 if (GET_CODE (operands[2]) == CONST_INT
5833 && (INTVAL (operands[2]) == 128
5834 || (INTVAL (operands[2]) < 0
5835 && INTVAL (operands[2]) != -128)))
5836 {
5837 operands[2] = GEN_INT (-INTVAL (operands[2]));
0f40f9f7 5838 return "sub{l}\t{%2, %k0|%k0, %2}";
9b70259d 5839 }
0f40f9f7 5840 return "add{l}\t{%2, %k0|%k0, %2}";
9b70259d 5841 }
0f40f9f7 5842}
9b70259d
JH
5843 [(set (attr "type")
5844 (cond [(eq_attr "alternative" "1")
5845 (const_string "lea")
5846 ; Current assemblers are broken and do not allow @GOTOFF in
5847 ; ought but a memory context.
5848 (match_operand:SI 2 "pic_symbolic_operand" "")
5849 (const_string "lea")
5850 (match_operand:SI 2 "incdec_operand" "")
5851 (const_string "incdec")
5852 ]
5853 (const_string "alu")))
5854 (set_attr "mode" "SI")])
5855
5856;; Convert lea to the lea pattern to avoid flags dependency.
5857(define_split
5858 [(set (match_operand:DI 0 "register_operand" "")
5859 (zero_extend:DI
5860 (plus:SI (match_operand:SI 1 "register_operand" "")
5861 (match_operand:SI 2 "nonmemory_operand" ""))))
5862 (clobber (reg:CC 17))]
bc8a6d63 5863 "TARGET_64BIT && reload_completed
9b70259d
JH
5864 && true_regnum (operands[0]) != true_regnum (operands[1])"
5865 [(set (match_dup 0)
5866 (zero_extend:DI (subreg:SI (plus:DI (match_dup 1) (match_dup 2)) 0)))]
9b70259d
JH
5867{
5868 operands[1] = gen_lowpart (Pmode, operands[1]);
5869 operands[2] = gen_lowpart (Pmode, operands[2]);
0f40f9f7 5870})
9b70259d
JH
5871
5872(define_insn "*addsi_2"
5873 [(set (reg 17)
5874 (compare
5875 (plus:SI (match_operand:SI 1 "nonimmediate_operand" "%0,0")
5876 (match_operand:SI 2 "general_operand" "rmni,rni"))
5877 (const_int 0)))
5878 (set (match_operand:SI 0 "nonimmediate_operand" "=r,rm")
5879 (plus:SI (match_dup 1) (match_dup 2)))]
5880 "ix86_match_ccmode (insn, CCGOCmode)
5881 && ix86_binary_operator_ok (PLUS, SImode, operands)
5882 /* Current assemblers are broken and do not allow @GOTOFF in
892a2d68 5883 ought but a memory context. */
9b70259d 5884 && ! pic_symbolic_operand (operands[2], VOIDmode)"
9b70259d
JH
5885{
5886 switch (get_attr_type (insn))
5887 {
5888 case TYPE_INCDEC:
5889 if (! rtx_equal_p (operands[0], operands[1]))
5890 abort ();
5891 if (operands[2] == const1_rtx)
0f40f9f7 5892 return "inc{l}\t%0";
9b70259d 5893 else if (operands[2] == constm1_rtx)
0f40f9f7 5894 return "dec{l}\t%0";
9b70259d
JH
5895 else
5896 abort();
5897
5898 default:
5899 if (! rtx_equal_p (operands[0], operands[1]))
5900 abort ();
5901 /* Make things pretty and `subl $4,%eax' rather than `addl $-4, %eax'.
5902 Exceptions: -128 encodes smaller than 128, so swap sign and op. */
5903 if (GET_CODE (operands[2]) == CONST_INT
5904 && (INTVAL (operands[2]) == 128
5905 || (INTVAL (operands[2]) < 0
5906 && INTVAL (operands[2]) != -128)))
5907 {
5908 operands[2] = GEN_INT (-INTVAL (operands[2]));
0f40f9f7 5909 return "sub{l}\t{%2, %0|%0, %2}";
9b70259d 5910 }
0f40f9f7 5911 return "add{l}\t{%2, %0|%0, %2}";
9b70259d 5912 }
0f40f9f7 5913}
9b70259d
JH
5914 [(set (attr "type")
5915 (if_then_else (match_operand:SI 2 "incdec_operand" "")
5916 (const_string "incdec")
5917 (const_string "alu")))
5918 (set_attr "mode" "SI")])
5919
5920;; See comment for addsi_1_zext why we do use nonimmediate_operand
5921(define_insn "*addsi_2_zext"
5922 [(set (reg 17)
5923 (compare
5924 (plus:SI (match_operand:SI 1 "nonimmediate_operand" "%0")
5925 (match_operand:SI 2 "general_operand" "rmni"))
5926 (const_int 0)))
5927 (set (match_operand:DI 0 "register_operand" "=r")
5928 (zero_extend:DI (plus:SI (match_dup 1) (match_dup 2))))]
5929 "TARGET_64BIT && ix86_match_ccmode (insn, CCGOCmode)
5930 && ix86_binary_operator_ok (PLUS, SImode, operands)
5931 /* Current assemblers are broken and do not allow @GOTOFF in
892a2d68 5932 ought but a memory context. */
9b70259d 5933 && ! pic_symbolic_operand (operands[2], VOIDmode)"
9b70259d
JH
5934{
5935 switch (get_attr_type (insn))
5936 {
5937 case TYPE_INCDEC:
5938 if (operands[2] == const1_rtx)
0f40f9f7 5939 return "inc{l}\t%k0";
9b70259d 5940 else if (operands[2] == constm1_rtx)
0f40f9f7 5941 return "dec{l}\t%k0";
9b70259d
JH
5942 else
5943 abort();
5944
5945 default:
5946 /* Make things pretty and `subl $4,%eax' rather than `addl $-4, %eax'.
5947 Exceptions: -128 encodes smaller than 128, so swap sign and op. */
5948 if (GET_CODE (operands[2]) == CONST_INT
5949 && (INTVAL (operands[2]) == 128
5950 || (INTVAL (operands[2]) < 0
5951 && INTVAL (operands[2]) != -128)))
5952 {
5953 operands[2] = GEN_INT (-INTVAL (operands[2]));
0f40f9f7 5954 return "sub{l}\t{%2, %k0|%k0, %2}";
9b70259d 5955 }
0f40f9f7 5956 return "add{l}\t{%2, %k0|%k0, %2}";
9b70259d 5957 }
0f40f9f7 5958}
9b70259d
JH
5959 [(set (attr "type")
5960 (if_then_else (match_operand:SI 2 "incdec_operand" "")
5961 (const_string "incdec")
5962 (const_string "alu")))
5963 (set_attr "mode" "SI")])
5964
5965(define_insn "*addsi_3"
5966 [(set (reg 17)
5967 (compare (neg:SI (match_operand:SI 2 "general_operand" "rmni"))
5968 (match_operand:SI 1 "nonimmediate_operand" "%0")))
5969 (clobber (match_scratch:SI 0 "=r"))]
5970 "ix86_match_ccmode (insn, CCZmode)
5971 && (GET_CODE (operands[1]) != MEM || GET_CODE (operands[2]) != MEM)
5972 /* Current assemblers are broken and do not allow @GOTOFF in
892a2d68 5973 ought but a memory context. */
9b70259d 5974 && ! pic_symbolic_operand (operands[2], VOIDmode)"
9b70259d
JH
5975{
5976 switch (get_attr_type (insn))
5977 {
5978 case TYPE_INCDEC:
5979 if (! rtx_equal_p (operands[0], operands[1]))
5980 abort ();
5981 if (operands[2] == const1_rtx)
0f40f9f7 5982 return "inc{l}\t%0";
9b70259d 5983 else if (operands[2] == constm1_rtx)
0f40f9f7 5984 return "dec{l}\t%0";
9b70259d
JH
5985 else
5986 abort();
5987
5988 default:
5989 if (! rtx_equal_p (operands[0], operands[1]))
5990 abort ();
5991 /* Make things pretty and `subl $4,%eax' rather than `addl $-4, %eax'.
5992 Exceptions: -128 encodes smaller than 128, so swap sign and op. */
5993 if (GET_CODE (operands[2]) == CONST_INT
5994 && (INTVAL (operands[2]) == 128
5995 || (INTVAL (operands[2]) < 0
5996 && INTVAL (operands[2]) != -128)))
5997 {
5998 operands[2] = GEN_INT (-INTVAL (operands[2]));
0f40f9f7 5999 return "sub{l}\t{%2, %0|%0, %2}";
9b70259d 6000 }
0f40f9f7 6001 return "add{l}\t{%2, %0|%0, %2}";
9b70259d 6002 }
0f40f9f7 6003}
9b70259d
JH
6004 [(set (attr "type")
6005 (if_then_else (match_operand:SI 2 "incdec_operand" "")
6006 (const_string "incdec")
6007 (const_string "alu")))
6008 (set_attr "mode" "SI")])
6009
6010;; See comment for addsi_1_zext why we do use nonimmediate_operand
6011(define_insn "*addsi_3_zext"
6012 [(set (reg 17)
6013 (compare (neg:SI (match_operand:SI 2 "general_operand" "rmni"))
6014 (match_operand:SI 1 "nonimmediate_operand" "%0")))
6015 (set (match_operand:DI 0 "register_operand" "=r")
6016 (zero_extend:DI (plus:SI (match_dup 1) (match_dup 2))))]
6017 "TARGET_64BIT && ix86_match_ccmode (insn, CCZmode)
6018 && ix86_binary_operator_ok (PLUS, SImode, operands)
6019 /* Current assemblers are broken and do not allow @GOTOFF in
892a2d68 6020 ought but a memory context. */
9b70259d 6021 && ! pic_symbolic_operand (operands[2], VOIDmode)"
9b70259d
JH
6022{
6023 switch (get_attr_type (insn))
6024 {
6025 case TYPE_INCDEC:
6026 if (operands[2] == const1_rtx)
0f40f9f7 6027 return "inc{l}\t%k0";
9b70259d 6028 else if (operands[2] == constm1_rtx)
0f40f9f7 6029 return "dec{l}\t%k0";
9b70259d
JH
6030 else
6031 abort();
6032
6033 default:
6034 /* Make things pretty and `subl $4,%eax' rather than `addl $-4, %eax'.
6035 Exceptions: -128 encodes smaller than 128, so swap sign and op. */
6036 if (GET_CODE (operands[2]) == CONST_INT
6037 && (INTVAL (operands[2]) == 128
6038 || (INTVAL (operands[2]) < 0
6039 && INTVAL (operands[2]) != -128)))
6040 {
6041 operands[2] = GEN_INT (-INTVAL (operands[2]));
0f40f9f7 6042 return "sub{l}\t{%2, %k0|%k0, %2}";
9b70259d 6043 }
0f40f9f7 6044 return "add{l}\t{%2, %k0|%k0, %2}";
9b70259d 6045 }
0f40f9f7 6046}
9b70259d
JH
6047 [(set (attr "type")
6048 (if_then_else (match_operand:SI 2 "incdec_operand" "")
6049 (const_string "incdec")
6050 (const_string "alu")))
6051 (set_attr "mode" "SI")])
6052
4aae8a9a 6053; For comparisons against 1, -1 and 128, we may generate better code
9b70259d
JH
6054; by converting cmp to add, inc or dec as done by peephole2. This pattern
6055; is matched then. We can't accept general immediate, because for
6056; case of overflows, the result is messed up.
6057; This pattern also don't hold of 0x80000000, since the value overflows
6058; when negated.
d6a7951f 6059; Also carry flag is reversed compared to cmp, so this conversion is valid
9b70259d
JH
6060; only for comparisons not depending on it.
6061(define_insn "*addsi_4"
6062 [(set (reg 17)
6063 (compare (match_operand:SI 1 "nonimmediate_operand" "0")
6064 (match_operand:SI 2 "const_int_operand" "n")))
6065 (clobber (match_scratch:SI 0 "=rm"))]
6066 "ix86_match_ccmode (insn, CCGCmode)
6067 && (INTVAL (operands[2]) & 0xffffffff) != 0x80000000"
9b70259d
JH
6068{
6069 switch (get_attr_type (insn))
6070 {
6071 case TYPE_INCDEC:
6072 if (operands[2] == constm1_rtx)
0f40f9f7 6073 return "inc{l}\t%0";
9b70259d 6074 else if (operands[2] == const1_rtx)
0f40f9f7 6075 return "dec{l}\t%0";
9b70259d
JH
6076 else
6077 abort();
6078
6079 default:
6080 if (! rtx_equal_p (operands[0], operands[1]))
6081 abort ();
6082 /* Make things pretty and `subl $4,%eax' rather than `addl $-4, %eax'.
6083 Exceptions: -128 encodes smaller than 128, so swap sign and op. */
6084 if ((INTVAL (operands[2]) == -128
6085 || (INTVAL (operands[2]) > 0
6086 && INTVAL (operands[2]) != 128)))
0f40f9f7 6087 return "sub{l}\t{%2, %0|%0, %2}";
9b70259d 6088 operands[2] = GEN_INT (-INTVAL (operands[2]));
0f40f9f7 6089 return "add{l}\t{%2, %0|%0, %2}";
9b70259d 6090 }
0f40f9f7 6091}
9b70259d
JH
6092 [(set (attr "type")
6093 (if_then_else (match_operand:SI 2 "incdec_operand" "")
6094 (const_string "incdec")
6095 (const_string "alu")))
6096 (set_attr "mode" "SI")])
6097
6098(define_insn "*addsi_5"
6099 [(set (reg 17)
6100 (compare
6101 (plus:SI (match_operand:SI 1 "nonimmediate_operand" "%0")
6102 (match_operand:SI 2 "general_operand" "rmni"))
6103 (const_int 0)))
6104 (clobber (match_scratch:SI 0 "=r"))]
6105 "ix86_match_ccmode (insn, CCGOCmode)
6106 && (GET_CODE (operands[1]) != MEM || GET_CODE (operands[2]) != MEM)
6107 /* Current assemblers are broken and do not allow @GOTOFF in
892a2d68 6108 ought but a memory context. */
9b70259d 6109 && ! pic_symbolic_operand (operands[2], VOIDmode)"
9b70259d
JH
6110{
6111 switch (get_attr_type (insn))
6112 {
6113 case TYPE_INCDEC:
6114 if (! rtx_equal_p (operands[0], operands[1]))
6115 abort ();
6116 if (operands[2] == const1_rtx)
0f40f9f7 6117 return "inc{l}\t%0";
9b70259d 6118 else if (operands[2] == constm1_rtx)
0f40f9f7 6119 return "dec{l}\t%0";
9b70259d
JH
6120 else
6121 abort();
6122
6123 default:
6124 if (! rtx_equal_p (operands[0], operands[1]))
6125 abort ();
6126 /* Make things pretty and `subl $4,%eax' rather than `addl $-4, %eax'.
6127 Exceptions: -128 encodes smaller than 128, so swap sign and op. */
6128 if (GET_CODE (operands[2]) == CONST_INT
6129 && (INTVAL (operands[2]) == 128
6130 || (INTVAL (operands[2]) < 0
6131 && INTVAL (operands[2]) != -128)))
6132 {
6133 operands[2] = GEN_INT (-INTVAL (operands[2]));
0f40f9f7 6134 return "sub{l}\t{%2, %0|%0, %2}";
9b70259d 6135 }
0f40f9f7 6136 return "add{l}\t{%2, %0|%0, %2}";
9b70259d 6137 }
0f40f9f7 6138}
9b70259d
JH
6139 [(set (attr "type")
6140 (if_then_else (match_operand:SI 2 "incdec_operand" "")
6141 (const_string "incdec")
6142 (const_string "alu")))
6143 (set_attr "mode" "SI")])
6144
6145(define_expand "addhi3"
6146 [(parallel [(set (match_operand:HI 0 "nonimmediate_operand" "")
6147 (plus:HI (match_operand:HI 1 "nonimmediate_operand" "")
6148 (match_operand:HI 2 "general_operand" "")))
6149 (clobber (reg:CC 17))])]
6150 "TARGET_HIMODE_MATH"
6151 "ix86_expand_binary_operator (PLUS, HImode, operands); DONE;")
6152
6153;; %%% After Dave's SUBREG_BYTE stuff goes in, re-enable incb %ah
6154;; type optimizations enabled by define-splits. This is not important
6155;; for PII, and in fact harmful because of partial register stalls.
6156
6157(define_insn "*addhi_1_lea"
6158 [(set (match_operand:HI 0 "nonimmediate_operand" "=rm,r,r")
6159 (plus:HI (match_operand:HI 1 "nonimmediate_operand" "%0,0,r")
6160 (match_operand:HI 2 "general_operand" "ri,rm,rni")))
6161 (clobber (reg:CC 17))]
6162 "!TARGET_PARTIAL_REG_STALL
6163 && ix86_binary_operator_ok (PLUS, HImode, operands)"
9b70259d
JH
6164{
6165 switch (get_attr_type (insn))
6166 {
6167 case TYPE_LEA:
0f40f9f7 6168 return "#";
9b70259d
JH
6169 case TYPE_INCDEC:
6170 if (operands[2] == const1_rtx)
0f40f9f7 6171 return "inc{w}\t%0";
2f41793e 6172 else if (operands[2] == constm1_rtx)
0f40f9f7 6173 return "dec{w}\t%0";
9b70259d
JH
6174 abort();
6175
6176 default:
6177 /* Make things pretty and `subl $4,%eax' rather than `addl $-4, %eax'.
6178 Exceptions: -128 encodes smaller than 128, so swap sign and op. */
6179 if (GET_CODE (operands[2]) == CONST_INT
6180 && (INTVAL (operands[2]) == 128
6181 || (INTVAL (operands[2]) < 0
6182 && INTVAL (operands[2]) != -128)))
6183 {
6184 operands[2] = GEN_INT (-INTVAL (operands[2]));
0f40f9f7 6185 return "sub{w}\t{%2, %0|%0, %2}";
9b70259d 6186 }
0f40f9f7 6187 return "add{w}\t{%2, %0|%0, %2}";
9b70259d 6188 }
0f40f9f7 6189}
9b70259d
JH
6190 [(set (attr "type")
6191 (if_then_else (eq_attr "alternative" "2")
6192 (const_string "lea")
6193 (if_then_else (match_operand:HI 2 "incdec_operand" "")
6194 (const_string "incdec")
6195 (const_string "alu"))))
6196 (set_attr "mode" "HI,HI,SI")])
6197
6198(define_insn "*addhi_1"
6199 [(set (match_operand:HI 0 "nonimmediate_operand" "=rm,r")
6200 (plus:HI (match_operand:HI 1 "nonimmediate_operand" "%0,0")
6201 (match_operand:HI 2 "general_operand" "ri,rm")))
6202 (clobber (reg:CC 17))]
6203 "TARGET_PARTIAL_REG_STALL
6204 && ix86_binary_operator_ok (PLUS, HImode, operands)"
9b70259d
JH
6205{
6206 switch (get_attr_type (insn))
6207 {
6208 case TYPE_INCDEC:
6209 if (operands[2] == const1_rtx)
0f40f9f7 6210 return "inc{w}\t%0";
2f41793e 6211 else if (operands[2] == constm1_rtx)
0f40f9f7 6212 return "dec{w}\t%0";
e075ae69 6213 abort();
7c802a40 6214
e075ae69
RH
6215 default:
6216 /* Make things pretty and `subl $4,%eax' rather than `addl $-4, %eax'.
6217 Exceptions: -128 encodes smaller than 128, so swap sign and op. */
6218 if (GET_CODE (operands[2]) == CONST_INT
6219 && (INTVAL (operands[2]) == 128
6220 || (INTVAL (operands[2]) < 0
6221 && INTVAL (operands[2]) != -128)))
6222 {
6223 operands[2] = GEN_INT (-INTVAL (operands[2]));
0f40f9f7 6224 return "sub{w}\t{%2, %0|%0, %2}";
e075ae69 6225 }
0f40f9f7 6226 return "add{w}\t{%2, %0|%0, %2}";
7c802a40 6227 }
0f40f9f7 6228}
e075ae69
RH
6229 [(set (attr "type")
6230 (if_then_else (match_operand:HI 2 "incdec_operand" "")
6231 (const_string "incdec")
6ef67412
JH
6232 (const_string "alu")))
6233 (set_attr "mode" "HI")])
7c802a40 6234
e075ae69 6235(define_insn "*addhi_2"
16189740
RH
6236 [(set (reg 17)
6237 (compare
e075ae69
RH
6238 (plus:HI (match_operand:HI 1 "nonimmediate_operand" "%0,0")
6239 (match_operand:HI 2 "general_operand" "rmni,rni"))
6240 (const_int 0)))
6241 (set (match_operand:HI 0 "nonimmediate_operand" "=r,rm")
6242 (plus:HI (match_dup 1) (match_dup 2)))]
9076b9c1 6243 "ix86_match_ccmode (insn, CCGOCmode)
16189740 6244 && ix86_binary_operator_ok (PLUS, HImode, operands)"
e075ae69
RH
6245{
6246 switch (get_attr_type (insn))
b980bec0 6247 {
e075ae69
RH
6248 case TYPE_INCDEC:
6249 if (operands[2] == const1_rtx)
0f40f9f7 6250 return "inc{w}\t%0";
2f41793e 6251 else if (operands[2] == constm1_rtx)
0f40f9f7 6252 return "dec{w}\t%0";
e075ae69 6253 abort();
b980bec0 6254
e075ae69
RH
6255 default:
6256 /* Make things pretty and `subl $4,%eax' rather than `addl $-4, %eax'.
6257 Exceptions: -128 encodes smaller than 128, so swap sign and op. */
6258 if (GET_CODE (operands[2]) == CONST_INT
6259 && (INTVAL (operands[2]) == 128
6260 || (INTVAL (operands[2]) < 0
6261 && INTVAL (operands[2]) != -128)))
6262 {
6263 operands[2] = GEN_INT (-INTVAL (operands[2]));
0f40f9f7 6264 return "sub{w}\t{%2, %0|%0, %2}";
e075ae69 6265 }
0f40f9f7 6266 return "add{w}\t{%2, %0|%0, %2}";
b980bec0 6267 }
0f40f9f7 6268}
e075ae69
RH
6269 [(set (attr "type")
6270 (if_then_else (match_operand:HI 2 "incdec_operand" "")
6271 (const_string "incdec")
6ef67412
JH
6272 (const_string "alu")))
6273 (set_attr "mode" "HI")])
e075ae69
RH
6274
6275(define_insn "*addhi_3"
d90ffc8d 6276 [(set (reg 17)
7e08e190
JH
6277 (compare (neg:HI (match_operand:HI 2 "general_operand" "rmni"))
6278 (match_operand:HI 1 "nonimmediate_operand" "%0")))
d90ffc8d 6279 (clobber (match_scratch:HI 0 "=r"))]
7e08e190 6280 "ix86_match_ccmode (insn, CCZmode)
d90ffc8d 6281 && (GET_CODE (operands[1]) != MEM || GET_CODE (operands[2]) != MEM)"
d90ffc8d
JH
6282{
6283 switch (get_attr_type (insn))
6284 {
6285 case TYPE_INCDEC:
6286 if (operands[2] == const1_rtx)
0f40f9f7 6287 return "inc{w}\t%0";
2f41793e 6288 else if (operands[2] == constm1_rtx)
0f40f9f7 6289 return "dec{w}\t%0";
d90ffc8d
JH
6290 abort();
6291
6292 default:
6293 /* Make things pretty and `subl $4,%eax' rather than `addl $-4, %eax'.
6294 Exceptions: -128 encodes smaller than 128, so swap sign and op. */
6295 if (GET_CODE (operands[2]) == CONST_INT
6296 && (INTVAL (operands[2]) == 128
6297 || (INTVAL (operands[2]) < 0
6298 && INTVAL (operands[2]) != -128)))
6299 {
6300 operands[2] = GEN_INT (-INTVAL (operands[2]));
0f40f9f7 6301 return "sub{w}\t{%2, %0|%0, %2}";
d90ffc8d 6302 }
0f40f9f7 6303 return "add{w}\t{%2, %0|%0, %2}";
d90ffc8d 6304 }
0f40f9f7 6305}
d90ffc8d
JH
6306 [(set (attr "type")
6307 (if_then_else (match_operand:HI 2 "incdec_operand" "")
6308 (const_string "incdec")
6309 (const_string "alu")))
6310 (set_attr "mode" "HI")])
6311
7e08e190 6312; See comments above addsi_3_imm for details.
d90ffc8d 6313(define_insn "*addhi_4"
9076b9c1 6314 [(set (reg 17)
7e08e190
JH
6315 (compare (match_operand:HI 1 "nonimmediate_operand" "0")
6316 (match_operand:HI 2 "const_int_operand" "n")))
6317 (clobber (match_scratch:HI 0 "=rm"))]
6318 "ix86_match_ccmode (insn, CCGCmode)
6319 && (INTVAL (operands[2]) & 0xffff) != 0x8000"
7e08e190
JH
6320{
6321 switch (get_attr_type (insn))
6322 {
6323 case TYPE_INCDEC:
2f41793e 6324 if (operands[2] == constm1_rtx)
0f40f9f7 6325 return "inc{w}\t%0";
7e08e190 6326 else if (operands[2] == const1_rtx)
0f40f9f7 6327 return "dec{w}\t%0";
7e08e190
JH
6328 else
6329 abort();
6330
6331 default:
6332 if (! rtx_equal_p (operands[0], operands[1]))
6333 abort ();
6334 /* Make things pretty and `subl $4,%eax' rather than `addl $-4, %eax'.
6335 Exceptions: -128 encodes smaller than 128, so swap sign and op. */
6336 if ((INTVAL (operands[2]) == -128
6337 || (INTVAL (operands[2]) > 0
6338 && INTVAL (operands[2]) != 128)))
0f40f9f7 6339 return "sub{w}\t{%2, %0|%0, %2}";
7e08e190 6340 operands[2] = GEN_INT (-INTVAL (operands[2]));
0f40f9f7 6341 return "add{w}\t{%2, %0|%0, %2}";
7e08e190 6342 }
0f40f9f7 6343}
7e08e190
JH
6344 [(set (attr "type")
6345 (if_then_else (match_operand:HI 2 "incdec_operand" "")
6346 (const_string "incdec")
6347 (const_string "alu")))
6348 (set_attr "mode" "SI")])
b980bec0 6349
d90ffc8d 6350
7e08e190 6351(define_insn "*addhi_5"
9076b9c1
JH
6352 [(set (reg 17)
6353 (compare
6354 (plus:HI (match_operand:HI 1 "nonimmediate_operand" "%0")
6355 (match_operand:HI 2 "general_operand" "rmni"))
6356 (const_int 0)))
6357 (clobber (match_scratch:HI 0 "=r"))]
6358 "ix86_match_ccmode (insn, CCGOCmode)
6359 && (GET_CODE (operands[1]) != MEM || GET_CODE (operands[2]) != MEM)"
9076b9c1
JH
6360{
6361 switch (get_attr_type (insn))
6362 {
6363 case TYPE_INCDEC:
6364 if (operands[2] == const1_rtx)
0f40f9f7 6365 return "inc{w}\t%0";
2f41793e 6366 else if (operands[2] == constm1_rtx)
0f40f9f7 6367 return "dec{w}\t%0";
9076b9c1
JH
6368 abort();
6369
6370 default:
6371 /* Make things pretty and `subl $4,%eax' rather than `addl $-4, %eax'.
6372 Exceptions: -128 encodes smaller than 128, so swap sign and op. */
6373 if (GET_CODE (operands[2]) == CONST_INT
6374 && (INTVAL (operands[2]) == 128
6375 || (INTVAL (operands[2]) < 0
6376 && INTVAL (operands[2]) != -128)))
6377 {
6378 operands[2] = GEN_INT (-INTVAL (operands[2]));
0f40f9f7 6379 return "sub{w}\t{%2, %0|%0, %2}";
9076b9c1 6380 }
0f40f9f7 6381 return "add{w}\t{%2, %0|%0, %2}";
9076b9c1 6382 }
0f40f9f7 6383}
9076b9c1
JH
6384 [(set (attr "type")
6385 (if_then_else (match_operand:HI 2 "incdec_operand" "")
6386 (const_string "incdec")
6387 (const_string "alu")))
6388 (set_attr "mode" "HI")])
6389
e075ae69 6390(define_expand "addqi3"
4cbfbb1b
JH
6391 [(parallel [(set (match_operand:QI 0 "nonimmediate_operand" "")
6392 (plus:QI (match_operand:QI 1 "nonimmediate_operand" "")
e075ae69
RH
6393 (match_operand:QI 2 "general_operand" "")))
6394 (clobber (reg:CC 17))])]
d9f32422 6395 "TARGET_QIMODE_MATH"
e075ae69
RH
6396 "ix86_expand_binary_operator (PLUS, QImode, operands); DONE;")
6397
6398;; %%% Potential partial reg stall on alternative 2. What to do?
58787064
JH
6399(define_insn "*addqi_1_lea"
6400 [(set (match_operand:QI 0 "nonimmediate_operand" "=qm,q,r,r")
6401 (plus:QI (match_operand:QI 1 "nonimmediate_operand" "%0,0,0,r")
6402 (match_operand:QI 2 "general_operand" "qn,qmn,rn,rn")))
6403 (clobber (reg:CC 17))]
6404 "!TARGET_PARTIAL_REG_STALL
6405 && ix86_binary_operator_ok (PLUS, QImode, operands)"
58787064
JH
6406{
6407 int widen = (which_alternative == 2);
6408 switch (get_attr_type (insn))
6409 {
6410 case TYPE_LEA:
0f40f9f7 6411 return "#";
58787064
JH
6412 case TYPE_INCDEC:
6413 if (operands[2] == const1_rtx)
0f40f9f7 6414 return widen ? "inc{l}\t%k0" : "inc{b}\t%0";
2f41793e 6415 else if (operands[2] == constm1_rtx)
0f40f9f7 6416 return widen ? "dec{l}\t%k0" : "dec{b}\t%0";
58787064
JH
6417 abort();
6418
6419 default:
6420 /* Make things pretty and `subl $4,%eax' rather than `addl $-4, %eax'.
6421 Exceptions: -128 encodes smaller than 128, so swap sign and op. */
6422 if (GET_CODE (operands[2]) == CONST_INT
6423 && (INTVAL (operands[2]) == 128
6424 || (INTVAL (operands[2]) < 0
6425 && INTVAL (operands[2]) != -128)))
6426 {
6427 operands[2] = GEN_INT (-INTVAL (operands[2]));
6428 if (widen)
0f40f9f7 6429 return "sub{l}\t{%2, %k0|%k0, %2}";
58787064 6430 else
0f40f9f7 6431 return "sub{b}\t{%2, %0|%0, %2}";
58787064
JH
6432 }
6433 if (widen)
0f40f9f7 6434 return "add{l}\t{%k2, %k0|%k0, %k2}";
58787064 6435 else
0f40f9f7 6436 return "add{b}\t{%2, %0|%0, %2}";
58787064 6437 }
0f40f9f7 6438}
58787064
JH
6439 [(set (attr "type")
6440 (if_then_else (eq_attr "alternative" "3")
6441 (const_string "lea")
adc88131 6442 (if_then_else (match_operand:QI 2 "incdec_operand" "")
58787064
JH
6443 (const_string "incdec")
6444 (const_string "alu"))))
adc88131 6445 (set_attr "mode" "QI,QI,SI,SI")])
58787064 6446
e075ae69 6447(define_insn "*addqi_1"
7c6b971d 6448 [(set (match_operand:QI 0 "nonimmediate_operand" "=qm,q,r")
e075ae69 6449 (plus:QI (match_operand:QI 1 "nonimmediate_operand" "%0,0,0")
7c6b971d 6450 (match_operand:QI 2 "general_operand" "qn,qmn,rn")))
e075ae69 6451 (clobber (reg:CC 17))]
58787064
JH
6452 "TARGET_PARTIAL_REG_STALL
6453 && ix86_binary_operator_ok (PLUS, QImode, operands)"
e075ae69
RH
6454{
6455 int widen = (which_alternative == 2);
6456 switch (get_attr_type (insn))
5bc7cd8e 6457 {
e075ae69
RH
6458 case TYPE_INCDEC:
6459 if (operands[2] == const1_rtx)
0f40f9f7 6460 return widen ? "inc{l}\t%k0" : "inc{b}\t%0";
2f41793e 6461 else if (operands[2] == constm1_rtx)
0f40f9f7 6462 return widen ? "dec{l}\t%k0" : "dec{b}\t%0";
e075ae69 6463 abort();
5bc7cd8e 6464
e075ae69
RH
6465 default:
6466 /* Make things pretty and `subl $4,%eax' rather than `addl $-4, %eax'.
6467 Exceptions: -128 encodes smaller than 128, so swap sign and op. */
6468 if (GET_CODE (operands[2]) == CONST_INT
6469 && (INTVAL (operands[2]) == 128
6470 || (INTVAL (operands[2]) < 0
6471 && INTVAL (operands[2]) != -128)))
5bc7cd8e 6472 {
e075ae69
RH
6473 operands[2] = GEN_INT (-INTVAL (operands[2]));
6474 if (widen)
0f40f9f7 6475 return "sub{l}\t{%2, %k0|%k0, %2}";
e075ae69 6476 else
0f40f9f7 6477 return "sub{b}\t{%2, %0|%0, %2}";
5bc7cd8e 6478 }
e075ae69 6479 if (widen)
0f40f9f7 6480 return "add{l}\t{%k2, %k0|%k0, %k2}";
e075ae69 6481 else
0f40f9f7 6482 return "add{b}\t{%2, %0|%0, %2}";
5bc7cd8e 6483 }
0f40f9f7 6484}
e075ae69
RH
6485 [(set (attr "type")
6486 (if_then_else (match_operand:QI 2 "incdec_operand" "")
6487 (const_string "incdec")
6ef67412
JH
6488 (const_string "alu")))
6489 (set_attr "mode" "QI,QI,SI")])
e075ae69 6490
2f41793e
JH
6491(define_insn "*addqi_1_slp"
6492 [(set (strict_low_part (match_operand:QI 0 "nonimmediate_operand" "+qm,q"))
1b245ade
JH
6493 (plus:QI (match_dup 0)
6494 (match_operand:QI 1 "general_operand" "qn,qnm")))
2f41793e
JH
6495 (clobber (reg:CC 17))]
6496 "(! TARGET_PARTIAL_REG_STALL || optimize_size)
1b245ade 6497 && (GET_CODE (operands[0]) != MEM || GET_CODE (operands[1]) != MEM)"
2f41793e
JH
6498{
6499 switch (get_attr_type (insn))
6500 {
6501 case TYPE_INCDEC:
95199202 6502 if (operands[1] == const1_rtx)
2f41793e 6503 return "inc{b}\t%0";
95199202 6504 else if (operands[1] == constm1_rtx)
2f41793e
JH
6505 return "dec{b}\t%0";
6506 abort();
6507
6508 default:
6509 /* Make things pretty and `subl $4,%eax' rather than `addl $-4, %eax'. */
95199202
JH
6510 if (GET_CODE (operands[1]) == CONST_INT
6511 && INTVAL (operands[1]) < 0)
2f41793e
JH
6512 {
6513 operands[2] = GEN_INT (-INTVAL (operands[2]));
1b245ade 6514 return "sub{b}\t{%1, %0|%0, %1}";
2f41793e 6515 }
1b245ade 6516 return "add{b}\t{%1, %0|%0, %1}";
2f41793e
JH
6517 }
6518}
6519 [(set (attr "type")
6520 (if_then_else (match_operand:QI 2 "incdec_operand" "")
6521 (const_string "incdec")
95199202 6522 (const_string "alu1")))
2f41793e
JH
6523 (set_attr "mode" "QI")])
6524
e075ae69 6525(define_insn "*addqi_2"
16189740
RH
6526 [(set (reg 17)
6527 (compare
e075ae69
RH
6528 (plus:QI (match_operand:QI 1 "nonimmediate_operand" "%0,0")
6529 (match_operand:QI 2 "general_operand" "qmni,qni"))
6530 (const_int 0)))
6531 (set (match_operand:QI 0 "nonimmediate_operand" "=q,qm")
6532 (plus:QI (match_dup 1) (match_dup 2)))]
9076b9c1 6533 "ix86_match_ccmode (insn, CCGOCmode)
16189740 6534 && ix86_binary_operator_ok (PLUS, QImode, operands)"
e075ae69
RH
6535{
6536 switch (get_attr_type (insn))
6537 {
6538 case TYPE_INCDEC:
6539 if (operands[2] == const1_rtx)
0f40f9f7 6540 return "inc{b}\t%0";
e075ae69
RH
6541 else if (operands[2] == constm1_rtx
6542 || (GET_CODE (operands[2]) == CONST_INT
6543 && INTVAL (operands[2]) == 255))
0f40f9f7 6544 return "dec{b}\t%0";
e075ae69 6545 abort();
5bc7cd8e 6546
e075ae69
RH
6547 default:
6548 /* Make things pretty and `subb $4,%al' rather than `addb $-4, %al'. */
6549 if (GET_CODE (operands[2]) == CONST_INT
6550 && INTVAL (operands[2]) < 0)
6551 {
6552 operands[2] = GEN_INT (-INTVAL (operands[2]));
0f40f9f7 6553 return "sub{b}\t{%2, %0|%0, %2}";
e075ae69 6554 }
0f40f9f7 6555 return "add{b}\t{%2, %0|%0, %2}";
e075ae69 6556 }
0f40f9f7 6557}
e075ae69
RH
6558 [(set (attr "type")
6559 (if_then_else (match_operand:QI 2 "incdec_operand" "")
6560 (const_string "incdec")
6ef67412
JH
6561 (const_string "alu")))
6562 (set_attr "mode" "QI")])
e075ae69
RH
6563
6564(define_insn "*addqi_3"
d90ffc8d 6565 [(set (reg 17)
7e08e190
JH
6566 (compare (neg:QI (match_operand:QI 2 "general_operand" "qmni"))
6567 (match_operand:QI 1 "nonimmediate_operand" "%0")))
6568 (clobber (match_scratch:QI 0 "=q"))]
6569 "ix86_match_ccmode (insn, CCZmode)
d90ffc8d 6570 && (GET_CODE (operands[1]) != MEM || GET_CODE (operands[2]) != MEM)"
d90ffc8d
JH
6571{
6572 switch (get_attr_type (insn))
6573 {
6574 case TYPE_INCDEC:
6575 if (operands[2] == const1_rtx)
0f40f9f7 6576 return "inc{b}\t%0";
d90ffc8d
JH
6577 else if (operands[2] == constm1_rtx
6578 || (GET_CODE (operands[2]) == CONST_INT
6579 && INTVAL (operands[2]) == 255))
0f40f9f7 6580 return "dec{b}\t%0";
d90ffc8d
JH
6581 abort();
6582
6583 default:
6584 /* Make things pretty and `subb $4,%al' rather than `addb $-4, %al'. */
6585 if (GET_CODE (operands[2]) == CONST_INT
6586 && INTVAL (operands[2]) < 0)
6587 {
6588 operands[2] = GEN_INT (-INTVAL (operands[2]));
0f40f9f7 6589 return "sub{b}\t{%2, %0|%0, %2}";
d90ffc8d 6590 }
0f40f9f7 6591 return "add{b}\t{%2, %0|%0, %2}";
d90ffc8d 6592 }
0f40f9f7 6593}
d90ffc8d
JH
6594 [(set (attr "type")
6595 (if_then_else (match_operand:QI 2 "incdec_operand" "")
6596 (const_string "incdec")
6597 (const_string "alu")))
6598 (set_attr "mode" "QI")])
6599
7e08e190 6600; See comments above addsi_3_imm for details.
d90ffc8d 6601(define_insn "*addqi_4"
9076b9c1 6602 [(set (reg 17)
7e08e190
JH
6603 (compare (match_operand:QI 1 "nonimmediate_operand" "0")
6604 (match_operand:QI 2 "const_int_operand" "n")))
6605 (clobber (match_scratch:QI 0 "=qm"))]
6606 "ix86_match_ccmode (insn, CCGCmode)
6607 && (INTVAL (operands[2]) & 0xff) != 0x80"
7e08e190
JH
6608{
6609 switch (get_attr_type (insn))
6610 {
6611 case TYPE_INCDEC:
6612 if (operands[2] == constm1_rtx
6613 || (GET_CODE (operands[2]) == CONST_INT
6614 && INTVAL (operands[2]) == 255))
0f40f9f7 6615 return "inc{b}\t%0";
7e08e190 6616 else if (operands[2] == const1_rtx)
0f40f9f7 6617 return "dec{b}\t%0";
7e08e190
JH
6618 else
6619 abort();
6620
6621 default:
6622 if (! rtx_equal_p (operands[0], operands[1]))
6623 abort ();
6624 if (INTVAL (operands[2]) < 0)
6625 {
6626 operands[2] = GEN_INT (-INTVAL (operands[2]));
0f40f9f7 6627 return "add{b}\t{%2, %0|%0, %2}";
7e08e190 6628 }
0f40f9f7 6629 return "sub{b}\t{%2, %0|%0, %2}";
7e08e190 6630 }
0f40f9f7 6631}
7e08e190
JH
6632 [(set (attr "type")
6633 (if_then_else (match_operand:HI 2 "incdec_operand" "")
6634 (const_string "incdec")
6635 (const_string "alu")))
6ef67412 6636 (set_attr "mode" "QI")])
886c62d1 6637
9dcbdc7e 6638
d90ffc8d 6639(define_insn "*addqi_5"
9076b9c1
JH
6640 [(set (reg 17)
6641 (compare
6642 (plus:QI (match_operand:QI 1 "nonimmediate_operand" "%0")
6643 (match_operand:QI 2 "general_operand" "qmni"))
6644 (const_int 0)))
7e08e190 6645 (clobber (match_scratch:QI 0 "=q"))]
9076b9c1
JH
6646 "ix86_match_ccmode (insn, CCGOCmode)
6647 && (GET_CODE (operands[1]) != MEM || GET_CODE (operands[2]) != MEM)"
9076b9c1
JH
6648{
6649 switch (get_attr_type (insn))
6650 {
6651 case TYPE_INCDEC:
6652 if (operands[2] == const1_rtx)
0f40f9f7 6653 return "inc{b}\t%0";
9076b9c1
JH
6654 else if (operands[2] == constm1_rtx
6655 || (GET_CODE (operands[2]) == CONST_INT
6656 && INTVAL (operands[2]) == 255))
0f40f9f7 6657 return "dec{b}\t%0";
9076b9c1
JH
6658 abort();
6659
6660 default:
6661 /* Make things pretty and `subb $4,%al' rather than `addb $-4, %al'. */
6662 if (GET_CODE (operands[2]) == CONST_INT
6663 && INTVAL (operands[2]) < 0)
6664 {
6665 operands[2] = GEN_INT (-INTVAL (operands[2]));
0f40f9f7 6666 return "sub{b}\t{%2, %0|%0, %2}";
9076b9c1 6667 }
0f40f9f7 6668 return "add{b}\t{%2, %0|%0, %2}";
9076b9c1 6669 }
0f40f9f7 6670}
9076b9c1
JH
6671 [(set (attr "type")
6672 (if_then_else (match_operand:QI 2 "incdec_operand" "")
6673 (const_string "incdec")
6674 (const_string "alu")))
6675 (set_attr "mode" "QI")])
6676
e075ae69
RH
6677
6678(define_insn "addqi_ext_1"
3522082b 6679 [(set (zero_extract:SI (match_operand 0 "ext_register_operand" "=Q")
e075ae69
RH
6680 (const_int 8)
6681 (const_int 8))
6682 (plus:SI
6683 (zero_extract:SI
6684 (match_operand 1 "ext_register_operand" "0")
6685 (const_int 8)
6686 (const_int 8))
3522082b 6687 (match_operand:QI 2 "general_operand" "Qmn")))
e075ae69 6688 (clobber (reg:CC 17))]
d2836273 6689 "!TARGET_64BIT"
d2836273
JH
6690{
6691 switch (get_attr_type (insn))
6692 {
6693 case TYPE_INCDEC:
6694 if (operands[2] == const1_rtx)
0f40f9f7 6695 return "inc{b}\t%h0";
d2836273
JH
6696 else if (operands[2] == constm1_rtx
6697 || (GET_CODE (operands[2]) == CONST_INT
6698 && INTVAL (operands[2]) == 255))
0f40f9f7 6699 return "dec{b}\t%h0";
d2836273
JH
6700 abort();
6701
6702 default:
0f40f9f7 6703 return "add{b}\t{%2, %h0|%h0, %2}";
d2836273 6704 }
0f40f9f7 6705}
d2836273
JH
6706 [(set (attr "type")
6707 (if_then_else (match_operand:QI 2 "incdec_operand" "")
6708 (const_string "incdec")
6709 (const_string "alu")))
6710 (set_attr "mode" "QI")])
6711
6712(define_insn "*addqi_ext_1_rex64"
6713 [(set (zero_extract:SI (match_operand 0 "ext_register_operand" "=Q")
6714 (const_int 8)
6715 (const_int 8))
6716 (plus:SI
6717 (zero_extract:SI
6718 (match_operand 1 "ext_register_operand" "0")
6719 (const_int 8)
6720 (const_int 8))
6721 (match_operand:QI 2 "nonmemory_operand" "Qn")))
6722 (clobber (reg:CC 17))]
6723 "TARGET_64BIT"
e075ae69
RH
6724{
6725 switch (get_attr_type (insn))
6726 {
6727 case TYPE_INCDEC:
6728 if (operands[2] == const1_rtx)
0f40f9f7 6729 return "inc{b}\t%h0";
e075ae69
RH
6730 else if (operands[2] == constm1_rtx
6731 || (GET_CODE (operands[2]) == CONST_INT
6732 && INTVAL (operands[2]) == 255))
0f40f9f7 6733 return "dec{b}\t%h0";
e075ae69 6734 abort();
886c62d1 6735
e075ae69 6736 default:
0f40f9f7 6737 return "add{b}\t{%2, %h0|%h0, %2}";
e075ae69 6738 }
0f40f9f7 6739}
e075ae69
RH
6740 [(set (attr "type")
6741 (if_then_else (match_operand:QI 2 "incdec_operand" "")
6742 (const_string "incdec")
6ef67412
JH
6743 (const_string "alu")))
6744 (set_attr "mode" "QI")])
e075ae69
RH
6745
6746(define_insn "*addqi_ext_2"
d2836273 6747 [(set (zero_extract:SI (match_operand 0 "ext_register_operand" "=Q")
e075ae69
RH
6748 (const_int 8)
6749 (const_int 8))
6750 (plus:SI
6751 (zero_extract:SI
6752 (match_operand 1 "ext_register_operand" "%0")
6753 (const_int 8)
6754 (const_int 8))
6755 (zero_extract:SI
d2836273 6756 (match_operand 2 "ext_register_operand" "Q")
e075ae69
RH
6757 (const_int 8)
6758 (const_int 8))))
6759 (clobber (reg:CC 17))]
6760 ""
0f40f9f7 6761 "add{b}\t{%h2, %h0|%h0, %h2}"
6ef67412
JH
6762 [(set_attr "type" "alu")
6763 (set_attr "mode" "QI")])
886c62d1 6764
886c62d1
JVA
6765;; The patterns that match these are at the end of this file.
6766
4fb21e90
JVA
6767(define_expand "addxf3"
6768 [(set (match_operand:XF 0 "register_operand" "")
2ae0f82c
SC
6769 (plus:XF (match_operand:XF 1 "register_operand" "")
6770 (match_operand:XF 2 "register_operand" "")))]
1b0c37d7 6771 "!TARGET_64BIT && TARGET_80387"
4fb21e90
JVA
6772 "")
6773
2b589241
JH
6774(define_expand "addtf3"
6775 [(set (match_operand:TF 0 "register_operand" "")
6776 (plus:TF (match_operand:TF 1 "register_operand" "")
6777 (match_operand:TF 2 "register_operand" "")))]
6778 "TARGET_80387"
6779 "")
6780
886c62d1
JVA
6781(define_expand "adddf3"
6782 [(set (match_operand:DF 0 "register_operand" "")
06a964de 6783 (plus:DF (match_operand:DF 1 "register_operand" "")
886c62d1 6784 (match_operand:DF 2 "nonimmediate_operand" "")))]
965f5423 6785 "TARGET_80387 || (TARGET_SSE2 && TARGET_SSE_MATH)"
886c62d1
JVA
6786 "")
6787
6788(define_expand "addsf3"
6789 [(set (match_operand:SF 0 "register_operand" "")
06a964de 6790 (plus:SF (match_operand:SF 1 "register_operand" "")
886c62d1 6791 (match_operand:SF 2 "nonimmediate_operand" "")))]
965f5423 6792 "TARGET_80387 || TARGET_SSE_MATH"
886c62d1
JVA
6793 "")
6794\f
e075ae69 6795;; Subtract instructions
a269a03c 6796
e075ae69 6797;; %%% splits for subsidi3
2ae0f82c 6798
9b70259d
JH
6799(define_expand "subdi3"
6800 [(parallel [(set (match_operand:DI 0 "nonimmediate_operand" "")
6801 (minus:DI (match_operand:DI 1 "nonimmediate_operand" "")
6802 (match_operand:DI 2 "x86_64_general_operand" "")))
6803 (clobber (reg:CC 17))])]
6804 ""
6805 "ix86_expand_binary_operator (MINUS, DImode, operands); DONE;")
6806
6807(define_insn "*subdi3_1"
e075ae69 6808 [(set (match_operand:DI 0 "nonimmediate_operand" "=r,o")
4cbfbb1b 6809 (minus:DI (match_operand:DI 1 "nonimmediate_operand" "0,0")
e075ae69
RH
6810 (match_operand:DI 2 "general_operand" "roiF,riF")))
6811 (clobber (reg:CC 17))]
43146684 6812 "!TARGET_64BIT && ix86_binary_operator_ok (MINUS, DImode, operands)"
e075ae69 6813 "#")
9c530261 6814
e075ae69
RH
6815(define_split
6816 [(set (match_operand:DI 0 "nonimmediate_operand" "")
4cbfbb1b 6817 (minus:DI (match_operand:DI 1 "nonimmediate_operand" "")
e075ae69
RH
6818 (match_operand:DI 2 "general_operand" "")))
6819 (clobber (reg:CC 17))]
1b0c37d7 6820 "!TARGET_64BIT && reload_completed"
9dcbdc7e 6821 [(parallel [(set (reg:CC 17) (compare:CC (match_dup 1) (match_dup 2)))
e075ae69
RH
6822 (set (match_dup 0) (minus:SI (match_dup 1) (match_dup 2)))])
6823 (parallel [(set (match_dup 3)
6824 (minus:SI (match_dup 4)
9dcbdc7e
JH
6825 (plus:SI (ltu:SI (reg:CC 17) (const_int 0))
6826 (match_dup 5))))
e075ae69
RH
6827 (clobber (reg:CC 17))])]
6828 "split_di (operands+0, 1, operands+0, operands+3);
6829 split_di (operands+1, 1, operands+1, operands+4);
6830 split_di (operands+2, 1, operands+2, operands+5);")
6831
9b70259d
JH
6832(define_insn "subdi3_carry_rex64"
6833 [(set (match_operand:DI 0 "nonimmediate_operand" "=rm,r")
6834 (minus:DI (match_operand:DI 1 "nonimmediate_operand" "0,0")
9b74f3ea 6835 (plus:DI (match_operand:DI 3 "ix86_carry_flag_operator" "")
9b70259d
JH
6836 (match_operand:DI 2 "x86_64_general_operand" "re,rm"))))
6837 (clobber (reg:CC 17))]
1b0c37d7 6838 "TARGET_64BIT && ix86_binary_operator_ok (MINUS, DImode, operands)"
0f40f9f7 6839 "sbb{q}\t{%2, %0|%0, %2}"
9b70259d
JH
6840 [(set_attr "type" "alu")
6841 (set_attr "pent_pair" "pu")
6842 (set_attr "ppro_uops" "few")
6843 (set_attr "mode" "DI")])
6844
6845(define_insn "*subdi_1_rex64"
6846 [(set (match_operand:DI 0 "nonimmediate_operand" "=rm,r")
6847 (minus:DI (match_operand:DI 1 "nonimmediate_operand" "0,0")
6848 (match_operand:DI 2 "x86_64_general_operand" "re,rm")))
6849 (clobber (reg:CC 17))]
6850 "TARGET_64BIT && ix86_binary_operator_ok (MINUS, DImode, operands)"
0f40f9f7 6851 "sub{q}\t{%2, %0|%0, %2}"
9b70259d
JH
6852 [(set_attr "type" "alu")
6853 (set_attr "mode" "DI")])
6854
6855(define_insn "*subdi_2_rex64"
6856 [(set (reg 17)
6857 (compare
6858 (minus:DI (match_operand:DI 1 "nonimmediate_operand" "0,0")
6859 (match_operand:DI 2 "x86_64_general_operand" "re,rm"))
6860 (const_int 0)))
6861 (set (match_operand:DI 0 "nonimmediate_operand" "=rm,r")
6862 (minus:DI (match_dup 1) (match_dup 2)))]
6863 "TARGET_64BIT && ix86_match_ccmode (insn, CCGOCmode)
6864 && ix86_binary_operator_ok (MINUS, DImode, operands)"
0f40f9f7 6865 "sub{q}\t{%2, %0|%0, %2}"
9b70259d
JH
6866 [(set_attr "type" "alu")
6867 (set_attr "mode" "DI")])
6868
6869(define_insn "*subdi_3_rex63"
6870 [(set (reg 17)
6871 (compare (match_operand:DI 1 "nonimmediate_operand" "0,0")
6872 (match_operand:DI 2 "x86_64_general_operand" "re,rm")))
6873 (set (match_operand:DI 0 "nonimmediate_operand" "=rm,r")
6874 (minus:DI (match_dup 1) (match_dup 2)))]
6875 "TARGET_64BIT && ix86_match_ccmode (insn, CCmode)
6876 && ix86_binary_operator_ok (MINUS, SImode, operands)"
0f40f9f7 6877 "sub{q}\t{%2, %0|%0, %2}"
9b70259d
JH
6878 [(set_attr "type" "alu")
6879 (set_attr "mode" "DI")])
6880
7b52eede
JH
6881(define_insn "subqi3_carry"
6882 [(set (match_operand:QI 0 "nonimmediate_operand" "=rm,r")
6883 (minus:QI (match_operand:QI 1 "nonimmediate_operand" "0,0")
e6e81735 6884 (plus:QI (match_operand:QI 3 "ix86_carry_flag_operator" "")
7b52eede
JH
6885 (match_operand:QI 2 "general_operand" "ri,rm"))))
6886 (clobber (reg:CC 17))]
6887 "ix86_binary_operator_ok (MINUS, QImode, operands)"
6888 "sbb{b}\t{%2, %0|%0, %2}"
6889 [(set_attr "type" "alu")
6890 (set_attr "pent_pair" "pu")
6891 (set_attr "ppro_uops" "few")
6892 (set_attr "mode" "QI")])
6893
6894(define_insn "subhi3_carry"
6895 [(set (match_operand:HI 0 "nonimmediate_operand" "=rm,r")
6896 (minus:HI (match_operand:HI 1 "nonimmediate_operand" "0,0")
e6e81735 6897 (plus:HI (match_operand:HI 3 "ix86_carry_flag_operator" "")
7b52eede
JH
6898 (match_operand:HI 2 "general_operand" "ri,rm"))))
6899 (clobber (reg:CC 17))]
6900 "ix86_binary_operator_ok (MINUS, HImode, operands)"
6901 "sbb{w}\t{%2, %0|%0, %2}"
6902 [(set_attr "type" "alu")
6903 (set_attr "pent_pair" "pu")
6904 (set_attr "ppro_uops" "few")
6905 (set_attr "mode" "HI")])
9b70259d 6906
7e08e190 6907(define_insn "subsi3_carry"
e075ae69
RH
6908 [(set (match_operand:SI 0 "nonimmediate_operand" "=rm,r")
6909 (minus:SI (match_operand:SI 1 "nonimmediate_operand" "0,0")
e6e81735 6910 (plus:SI (match_operand:SI 3 "ix86_carry_flag_operator" "")
9dcbdc7e 6911 (match_operand:SI 2 "general_operand" "ri,rm"))))
e075ae69 6912 (clobber (reg:CC 17))]
d525dfdf 6913 "ix86_binary_operator_ok (MINUS, SImode, operands)"
0f40f9f7 6914 "sbb{l}\t{%2, %0|%0, %2}"
e075ae69
RH
6915 [(set_attr "type" "alu")
6916 (set_attr "pent_pair" "pu")
6ef67412
JH
6917 (set_attr "ppro_uops" "few")
6918 (set_attr "mode" "SI")])
886c62d1 6919
9b70259d
JH
6920(define_insn "subsi3_carry_zext"
6921 [(set (match_operand:DI 0 "register_operand" "=rm,r")
6922 (zero_extend:DI
6923 (minus:SI (match_operand:SI 1 "register_operand" "0,0")
e6e81735 6924 (plus:SI (match_operand:SI 3 "ix86_carry_flag_operator" "")
9b70259d
JH
6925 (match_operand:SI 2 "general_operand" "ri,rm")))))
6926 (clobber (reg:CC 17))]
6927 "TARGET_64BIT && ix86_binary_operator_ok (MINUS, SImode, operands)"
0f40f9f7 6928 "sbb{l}\t{%2, %k0|%k0, %2}"
9b70259d
JH
6929 [(set_attr "type" "alu")
6930 (set_attr "pent_pair" "pu")
6931 (set_attr "ppro_uops" "few")
6932 (set_attr "mode" "SI")])
6933
2ae0f82c 6934(define_expand "subsi3"
e075ae69
RH
6935 [(parallel [(set (match_operand:SI 0 "nonimmediate_operand" "")
6936 (minus:SI (match_operand:SI 1 "nonimmediate_operand" "")
6937 (match_operand:SI 2 "general_operand" "")))
6938 (clobber (reg:CC 17))])]
886c62d1 6939 ""
e075ae69 6940 "ix86_expand_binary_operator (MINUS, SImode, operands); DONE;")
2ae0f82c 6941
e075ae69 6942(define_insn "*subsi_1"
2ae0f82c
SC
6943 [(set (match_operand:SI 0 "nonimmediate_operand" "=rm,r")
6944 (minus:SI (match_operand:SI 1 "nonimmediate_operand" "0,0")
e075ae69
RH
6945 (match_operand:SI 2 "general_operand" "ri,rm")))
6946 (clobber (reg:CC 17))]
6947 "ix86_binary_operator_ok (MINUS, SImode, operands)"
0f40f9f7 6948 "sub{l}\t{%2, %0|%0, %2}"
6ef67412
JH
6949 [(set_attr "type" "alu")
6950 (set_attr "mode" "SI")])
e075ae69 6951
9b70259d
JH
6952(define_insn "*subsi_1_zext"
6953 [(set (match_operand:DI 0 "register_operand" "=r")
6954 (zero_extend:DI
6955 (minus:SI (match_operand:SI 1 "register_operand" "0")
6956 (match_operand:SI 2 "general_operand" "rim"))))
6957 (clobber (reg:CC 17))]
6958 "TARGET_64BIT && ix86_binary_operator_ok (MINUS, SImode, operands)"
0f40f9f7 6959 "sub{l}\t{%2, %k0|%k0, %2}"
9b70259d
JH
6960 [(set_attr "type" "alu")
6961 (set_attr "mode" "SI")])
6962
e075ae69 6963(define_insn "*subsi_2"
16189740
RH
6964 [(set (reg 17)
6965 (compare
e075ae69
RH
6966 (minus:SI (match_operand:SI 1 "nonimmediate_operand" "0,0")
6967 (match_operand:SI 2 "general_operand" "ri,rm"))
6968 (const_int 0)))
6969 (set (match_operand:SI 0 "nonimmediate_operand" "=rm,r")
6970 (minus:SI (match_dup 1) (match_dup 2)))]
9076b9c1 6971 "ix86_match_ccmode (insn, CCGOCmode)
d90ffc8d 6972 && ix86_binary_operator_ok (MINUS, SImode, operands)"
0f40f9f7 6973 "sub{l}\t{%2, %0|%0, %2}"
d90ffc8d
JH
6974 [(set_attr "type" "alu")
6975 (set_attr "mode" "SI")])
6976
9b70259d
JH
6977(define_insn "*subsi_2_zext"
6978 [(set (reg 17)
6979 (compare
6980 (minus:SI (match_operand:SI 1 "register_operand" "0")
6981 (match_operand:SI 2 "general_operand" "rim"))
6982 (const_int 0)))
6983 (set (match_operand:DI 0 "register_operand" "=r")
6984 (zero_extend:DI
6985 (minus:SI (match_dup 1)
6986 (match_dup 2))))]
6987 "TARGET_64BIT && ix86_match_ccmode (insn, CCGOCmode)
6988 && ix86_binary_operator_ok (MINUS, SImode, operands)"
0f40f9f7 6989 "sub{l}\t{%2, %k0|%k0, %2}"
9b70259d
JH
6990 [(set_attr "type" "alu")
6991 (set_attr "mode" "SI")])
6992
d90ffc8d
JH
6993(define_insn "*subsi_3"
6994 [(set (reg 17)
6995 (compare (match_operand:SI 1 "nonimmediate_operand" "0,0")
6996 (match_operand:SI 2 "general_operand" "ri,rm")))
6997 (set (match_operand:SI 0 "nonimmediate_operand" "=rm,r")
6998 (minus:SI (match_dup 1) (match_dup 2)))]
16189740
RH
6999 "ix86_match_ccmode (insn, CCmode)
7000 && ix86_binary_operator_ok (MINUS, SImode, operands)"
0f40f9f7 7001 "sub{l}\t{%2, %0|%0, %2}"
6ef67412
JH
7002 [(set_attr "type" "alu")
7003 (set_attr "mode" "SI")])
886c62d1 7004
9b70259d
JH
7005(define_insn "*subsi_3_zext"
7006 [(set (reg 17)
7007 (compare (match_operand:SI 1 "nonimmediate_operand" "0")
7008 (match_operand:SI 2 "general_operand" "rim")))
7009 (set (match_operand:DI 0 "register_operand" "=r")
7010 (zero_extend:DI
7011 (minus:SI (match_dup 1)
7012 (match_dup 2))))]
8362f420 7013 "TARGET_64BIT && ix86_match_ccmode (insn, CCmode)
9b70259d 7014 && ix86_binary_operator_ok (MINUS, SImode, operands)"
0f40f9f7 7015 "sub{q}\t{%2, %0|%0, %2}"
9b70259d
JH
7016 [(set_attr "type" "alu")
7017 (set_attr "mode" "DI")])
7018
2ae0f82c 7019(define_expand "subhi3"
4cbfbb1b 7020 [(parallel [(set (match_operand:HI 0 "nonimmediate_operand" "")
e075ae69
RH
7021 (minus:HI (match_operand:HI 1 "nonimmediate_operand" "")
7022 (match_operand:HI 2 "general_operand" "")))
7023 (clobber (reg:CC 17))])]
d9f32422 7024 "TARGET_HIMODE_MATH"
e075ae69 7025 "ix86_expand_binary_operator (MINUS, HImode, operands); DONE;")
2ae0f82c 7026
e075ae69 7027(define_insn "*subhi_1"
2ae0f82c 7028 [(set (match_operand:HI 0 "nonimmediate_operand" "=rm,r")
87fd1847 7029 (minus:HI (match_operand:HI 1 "nonimmediate_operand" "0,0")
e075ae69
RH
7030 (match_operand:HI 2 "general_operand" "ri,rm")))
7031 (clobber (reg:CC 17))]
2ae0f82c 7032 "ix86_binary_operator_ok (MINUS, HImode, operands)"
0f40f9f7 7033 "sub{w}\t{%2, %0|%0, %2}"
6ef67412
JH
7034 [(set_attr "type" "alu")
7035 (set_attr "mode" "HI")])
e075ae69
RH
7036
7037(define_insn "*subhi_2"
16189740
RH
7038 [(set (reg 17)
7039 (compare
e075ae69
RH
7040 (minus:HI (match_operand:HI 1 "nonimmediate_operand" "0,0")
7041 (match_operand:HI 2 "general_operand" "ri,rm"))
7042 (const_int 0)))
7043 (set (match_operand:HI 0 "nonimmediate_operand" "=rm,r")
7044 (minus:HI (match_dup 1) (match_dup 2)))]
9076b9c1 7045 "ix86_match_ccmode (insn, CCGOCmode)
d90ffc8d 7046 && ix86_binary_operator_ok (MINUS, HImode, operands)"
0f40f9f7 7047 "sub{w}\t{%2, %0|%0, %2}"
d90ffc8d
JH
7048 [(set_attr "type" "alu")
7049 (set_attr "mode" "HI")])
7050
7051(define_insn "*subhi_3"
7052 [(set (reg 17)
7053 (compare (match_operand:HI 1 "nonimmediate_operand" "0,0")
7054 (match_operand:HI 2 "general_operand" "ri,rm")))
7055 (set (match_operand:HI 0 "nonimmediate_operand" "=rm,r")
7056 (minus:HI (match_dup 1) (match_dup 2)))]
16189740
RH
7057 "ix86_match_ccmode (insn, CCmode)
7058 && ix86_binary_operator_ok (MINUS, HImode, operands)"
0f40f9f7 7059 "sub{w}\t{%2, %0|%0, %2}"
6ef67412
JH
7060 [(set_attr "type" "alu")
7061 (set_attr "mode" "HI")])
886c62d1 7062
2ae0f82c 7063(define_expand "subqi3"
4cbfbb1b
JH
7064 [(parallel [(set (match_operand:QI 0 "nonimmediate_operand" "")
7065 (minus:QI (match_operand:QI 1 "nonimmediate_operand" "")
e075ae69
RH
7066 (match_operand:QI 2 "general_operand" "")))
7067 (clobber (reg:CC 17))])]
d9f32422 7068 "TARGET_QIMODE_MATH"
e075ae69 7069 "ix86_expand_binary_operator (MINUS, QImode, operands); DONE;")
2ae0f82c 7070
e075ae69 7071(define_insn "*subqi_1"
2ae0f82c
SC
7072 [(set (match_operand:QI 0 "nonimmediate_operand" "=qm,q")
7073 (minus:QI (match_operand:QI 1 "nonimmediate_operand" "0,0")
e075ae69
RH
7074 (match_operand:QI 2 "general_operand" "qn,qmn")))
7075 (clobber (reg:CC 17))]
7076 "ix86_binary_operator_ok (MINUS, QImode, operands)"
0f40f9f7 7077 "sub{b}\t{%2, %0|%0, %2}"
6ef67412
JH
7078 [(set_attr "type" "alu")
7079 (set_attr "mode" "QI")])
e075ae69 7080
2f41793e
JH
7081(define_insn "*subqi_1_slp"
7082 [(set (strict_low_part (match_operand:QI 0 "nonimmediate_operand" "+qm,q"))
1b245ade
JH
7083 (minus:QI (match_dup 0)
7084 (match_operand:QI 1 "general_operand" "qn,qmn")))
2f41793e
JH
7085 (clobber (reg:CC 17))]
7086 "(! TARGET_PARTIAL_REG_STALL || optimize_size)
1b245ade
JH
7087 && (GET_CODE (operands[0]) != MEM || GET_CODE (operands[1]) != MEM)"
7088 "sub{b}\t{%1, %0|%0, %1}"
95199202 7089 [(set_attr "type" "alu1")
2f41793e
JH
7090 (set_attr "mode" "QI")])
7091
e075ae69 7092(define_insn "*subqi_2"
16189740
RH
7093 [(set (reg 17)
7094 (compare
e075ae69
RH
7095 (minus:QI (match_operand:QI 1 "nonimmediate_operand" "0,0")
7096 (match_operand:QI 2 "general_operand" "qi,qm"))
7097 (const_int 0)))
7098 (set (match_operand:HI 0 "nonimmediate_operand" "=qm,q")
7099 (minus:HI (match_dup 1) (match_dup 2)))]
9076b9c1 7100 "ix86_match_ccmode (insn, CCGOCmode)
d90ffc8d 7101 && ix86_binary_operator_ok (MINUS, QImode, operands)"
0f40f9f7 7102 "sub{b}\t{%2, %0|%0, %2}"
d90ffc8d
JH
7103 [(set_attr "type" "alu")
7104 (set_attr "mode" "QI")])
7105
7106(define_insn "*subqi_3"
7107 [(set (reg 17)
7108 (compare (match_operand:QI 1 "nonimmediate_operand" "0,0")
7109 (match_operand:QI 2 "general_operand" "qi,qm")))
7110 (set (match_operand:HI 0 "nonimmediate_operand" "=qm,q")
7111 (minus:HI (match_dup 1) (match_dup 2)))]
16189740
RH
7112 "ix86_match_ccmode (insn, CCmode)
7113 && ix86_binary_operator_ok (MINUS, QImode, operands)"
0f40f9f7 7114 "sub{b}\t{%2, %0|%0, %2}"
6ef67412
JH
7115 [(set_attr "type" "alu")
7116 (set_attr "mode" "QI")])
2ae0f82c 7117
886c62d1
JVA
7118;; The patterns that match these are at the end of this file.
7119
4fb21e90
JVA
7120(define_expand "subxf3"
7121 [(set (match_operand:XF 0 "register_operand" "")
2ae0f82c
SC
7122 (minus:XF (match_operand:XF 1 "register_operand" "")
7123 (match_operand:XF 2 "register_operand" "")))]
1b0c37d7 7124 "!TARGET_64BIT && TARGET_80387"
4fb21e90
JVA
7125 "")
7126
2b589241
JH
7127(define_expand "subtf3"
7128 [(set (match_operand:TF 0 "register_operand" "")
7129 (minus:TF (match_operand:TF 1 "register_operand" "")
7130 (match_operand:TF 2 "register_operand" "")))]
7131 "TARGET_80387"
7132 "")
7133
886c62d1
JVA
7134(define_expand "subdf3"
7135 [(set (match_operand:DF 0 "register_operand" "")
06a964de 7136 (minus:DF (match_operand:DF 1 "register_operand" "")
886c62d1 7137 (match_operand:DF 2 "nonimmediate_operand" "")))]
965f5423 7138 "TARGET_80387 || (TARGET_SSE2 && TARGET_SSE_MATH)"
886c62d1
JVA
7139 "")
7140
7141(define_expand "subsf3"
7142 [(set (match_operand:SF 0 "register_operand" "")
06a964de 7143 (minus:SF (match_operand:SF 1 "register_operand" "")
886c62d1 7144 (match_operand:SF 2 "nonimmediate_operand" "")))]
965f5423 7145 "TARGET_80387 || TARGET_SSE_MATH"
886c62d1
JVA
7146 "")
7147\f
e075ae69 7148;; Multiply instructions
886c62d1 7149
9b70259d
JH
7150(define_expand "muldi3"
7151 [(parallel [(set (match_operand:DI 0 "register_operand" "")
7152 (mult:DI (match_operand:DI 1 "register_operand" "")
7153 (match_operand:DI 2 "x86_64_general_operand" "")))
7154 (clobber (reg:CC 17))])]
7155 "TARGET_64BIT"
7156 "")
7157
7158(define_insn "*muldi3_1_rex64"
7159 [(set (match_operand:DI 0 "register_operand" "=r,r,r")
f56e86bd 7160 (mult:DI (match_operand:DI 1 "nonimmediate_operand" "%rm,rm,0")
9b70259d
JH
7161 (match_operand:DI 2 "x86_64_general_operand" "K,e,mr")))
7162 (clobber (reg:CC 17))]
1b0c37d7
ZW
7163 "TARGET_64BIT
7164 && (GET_CODE (operands[1]) != MEM || GET_CODE (operands[2]) != MEM)"
9b70259d 7165 "@
0f40f9f7
ZW
7166 imul{q}\t{%2, %1, %0|%0, %1, %2}
7167 imul{q}\t{%2, %1, %0|%0, %1, %2}
7168 imul{q}\t{%2, %0|%0, %2}"
9b70259d
JH
7169 [(set_attr "type" "imul")
7170 (set_attr "prefix_0f" "0,0,1")
f56e86bd
JH
7171 (set (attr "athlon_decode")
7172 (cond [(eq_attr "cpu" "athlon")
7173 (const_string "vector")
7174 (eq_attr "alternative" "1")
7175 (const_string "vector")
7176 (and (eq_attr "alternative" "2")
7177 (match_operand 1 "memory_operand" ""))
7178 (const_string "vector")]
7179 (const_string "direct")))
9b70259d
JH
7180 (set_attr "mode" "DI")])
7181
d525dfdf
JH
7182(define_expand "mulsi3"
7183 [(parallel [(set (match_operand:SI 0 "register_operand" "")
7184 (mult:SI (match_operand:SI 1 "register_operand" "")
7185 (match_operand:SI 2 "general_operand" "")))
7186 (clobber (reg:CC 17))])]
7187 ""
7188 "")
7189
7190(define_insn "*mulsi3_1"
e075ae69 7191 [(set (match_operand:SI 0 "register_operand" "=r,r,r")
f56e86bd 7192 (mult:SI (match_operand:SI 1 "nonimmediate_operand" "%rm,rm,0")
e075ae69
RH
7193 (match_operand:SI 2 "general_operand" "K,i,mr")))
7194 (clobber (reg:CC 17))]
d525dfdf 7195 "GET_CODE (operands[1]) != MEM || GET_CODE (operands[2]) != MEM"
e075ae69 7196 "@
0f40f9f7
ZW
7197 imul{l}\t{%2, %1, %0|%0, %1, %2}
7198 imul{l}\t{%2, %1, %0|%0, %1, %2}
7199 imul{l}\t{%2, %0|%0, %2}"
e075ae69 7200 [(set_attr "type" "imul")
6ef67412 7201 (set_attr "prefix_0f" "0,0,1")
f56e86bd
JH
7202 (set (attr "athlon_decode")
7203 (cond [(eq_attr "cpu" "athlon")
7204 (const_string "vector")
7205 (eq_attr "alternative" "1")
7206 (const_string "vector")
7207 (and (eq_attr "alternative" "2")
7208 (match_operand 1 "memory_operand" ""))
7209 (const_string "vector")]
7210 (const_string "direct")))
6ef67412 7211 (set_attr "mode" "SI")])
886c62d1 7212
9b70259d
JH
7213(define_insn "*mulsi3_1_zext"
7214 [(set (match_operand:DI 0 "register_operand" "=r,r,r")
7215 (zero_extend:DI
f56e86bd 7216 (mult:SI (match_operand:SI 1 "nonimmediate_operand" "%rm,rm,0")
9b70259d
JH
7217 (match_operand:SI 2 "general_operand" "K,i,mr"))))
7218 (clobber (reg:CC 17))]
7219 "TARGET_64BIT
7220 && (GET_CODE (operands[1]) != MEM || GET_CODE (operands[2]) != MEM)"
9b70259d 7221 "@
0f40f9f7
ZW
7222 imul{l}\t{%2, %1, %k0|%k0, %1, %2}
7223 imul{l}\t{%2, %1, %k0|%k0, %1, %2}
7224 imul{l}\t{%2, %k0|%k0, %2}"
9b70259d
JH
7225 [(set_attr "type" "imul")
7226 (set_attr "prefix_0f" "0,0,1")
f56e86bd
JH
7227 (set (attr "athlon_decode")
7228 (cond [(eq_attr "cpu" "athlon")
7229 (const_string "vector")
7230 (eq_attr "alternative" "1")
7231 (const_string "vector")
7232 (and (eq_attr "alternative" "2")
7233 (match_operand 1 "memory_operand" ""))
7234 (const_string "vector")]
7235 (const_string "direct")))
9b70259d
JH
7236 (set_attr "mode" "SI")])
7237
d525dfdf
JH
7238(define_expand "mulhi3"
7239 [(parallel [(set (match_operand:HI 0 "register_operand" "")
7240 (mult:HI (match_operand:HI 1 "register_operand" "")
7241 (match_operand:HI 2 "general_operand" "")))
7242 (clobber (reg:CC 17))])]
d9f32422 7243 "TARGET_HIMODE_MATH"
d525dfdf
JH
7244 "")
7245
7246(define_insn "*mulhi3_1"
6ef67412 7247 [(set (match_operand:HI 0 "register_operand" "=r,r,r")
f56e86bd 7248 (mult:HI (match_operand:HI 1 "nonimmediate_operand" "%rm,rm,0")
6ef67412 7249 (match_operand:HI 2 "general_operand" "K,i,mr")))
e075ae69 7250 (clobber (reg:CC 17))]
d525dfdf 7251 "GET_CODE (operands[1]) != MEM || GET_CODE (operands[2]) != MEM"
e075ae69 7252 "@
0f40f9f7
ZW
7253 imul{w}\t{%2, %1, %0|%0, %1, %2}
7254 imul{w}\t{%2, %1, %0|%0, %1, %2}
7255 imul{w}\t{%2, %0|%0, %2}"
6ef67412
JH
7256 [(set_attr "type" "imul")
7257 (set_attr "prefix_0f" "0,0,1")
f56e86bd
JH
7258 (set (attr "athlon_decode")
7259 (cond [(eq_attr "cpu" "athlon")
7260 (const_string "vector")
7261 (eq_attr "alternative" "1,2")
7262 (const_string "vector")]
7263 (const_string "direct")))
6ef67412 7264 (set_attr "mode" "HI")])
886c62d1 7265
558740bf
JH
7266(define_expand "mulqi3"
7267 [(parallel [(set (match_operand:QI 0 "register_operand" "")
7268 (mult:QI (match_operand:QI 1 "nonimmediate_operand" "")
7269 (match_operand:QI 2 "register_operand" "")))
7270 (clobber (reg:CC 17))])]
7271 "TARGET_QIMODE_MATH"
7272 "")
7273
7274(define_insn "*mulqi3_1"
765a46f9 7275 [(set (match_operand:QI 0 "register_operand" "=a")
558740bf 7276 (mult:QI (match_operand:QI 1 "nonimmediate_operand" "%0")
765a46f9
JH
7277 (match_operand:QI 2 "nonimmediate_operand" "qm")))
7278 (clobber (reg:CC 17))]
558740bf
JH
7279 "TARGET_QIMODE_MATH
7280 && (GET_CODE (operands[1]) != MEM || GET_CODE (operands[2]) != MEM)"
0f40f9f7 7281 "mul{b}\t%2"
6ef67412
JH
7282 [(set_attr "type" "imul")
7283 (set_attr "length_immediate" "0")
f56e86bd
JH
7284 (set (attr "athlon_decode")
7285 (if_then_else (eq_attr "cpu" "athlon")
7286 (const_string "vector")
7287 (const_string "direct")))
6ef67412 7288 (set_attr "mode" "QI")])
765a46f9 7289
558740bf
JH
7290(define_expand "umulqihi3"
7291 [(parallel [(set (match_operand:HI 0 "register_operand" "")
7292 (mult:HI (zero_extend:HI
7293 (match_operand:QI 1 "nonimmediate_operand" ""))
7294 (zero_extend:HI
7295 (match_operand:QI 2 "register_operand" ""))))
7296 (clobber (reg:CC 17))])]
7297 "TARGET_QIMODE_MATH"
7298 "")
7299
7300(define_insn "*umulqihi3_1"
2ae0f82c 7301 [(set (match_operand:HI 0 "register_operand" "=a")
558740bf 7302 (mult:HI (zero_extend:HI (match_operand:QI 1 "nonimmediate_operand" "%0"))
e075ae69
RH
7303 (zero_extend:HI (match_operand:QI 2 "nonimmediate_operand" "qm"))))
7304 (clobber (reg:CC 17))]
558740bf
JH
7305 "TARGET_QIMODE_MATH
7306 && (GET_CODE (operands[1]) != MEM || GET_CODE (operands[2]) != MEM)"
0f40f9f7 7307 "mul{b}\t%2"
6ef67412
JH
7308 [(set_attr "type" "imul")
7309 (set_attr "length_immediate" "0")
f56e86bd
JH
7310 (set (attr "athlon_decode")
7311 (if_then_else (eq_attr "cpu" "athlon")
7312 (const_string "vector")
7313 (const_string "direct")))
6ef67412 7314 (set_attr "mode" "QI")])
886c62d1 7315
558740bf
JH
7316(define_expand "mulqihi3"
7317 [(parallel [(set (match_operand:HI 0 "register_operand" "")
7318 (mult:HI (sign_extend:HI (match_operand:QI 1 "nonimmediate_operand" ""))
7319 (sign_extend:HI (match_operand:QI 2 "register_operand" ""))))
7320 (clobber (reg:CC 17))])]
7321 "TARGET_QIMODE_MATH"
7322 "")
7323
7324(define_insn "*mulqihi3_insn"
2ae0f82c 7325 [(set (match_operand:HI 0 "register_operand" "=a")
558740bf 7326 (mult:HI (sign_extend:HI (match_operand:QI 1 "nonimmediate_operand" "%0"))
e075ae69
RH
7327 (sign_extend:HI (match_operand:QI 2 "nonimmediate_operand" "qm"))))
7328 (clobber (reg:CC 17))]
558740bf
JH
7329 "TARGET_QIMODE_MATH
7330 && (GET_CODE (operands[1]) != MEM || GET_CODE (operands[2]) != MEM)"
0f40f9f7 7331 "imul{b}\t%2"
6ef67412
JH
7332 [(set_attr "type" "imul")
7333 (set_attr "length_immediate" "0")
f56e86bd
JH
7334 (set (attr "athlon_decode")
7335 (if_then_else (eq_attr "cpu" "athlon")
7336 (const_string "vector")
7337 (const_string "direct")))
6ef67412 7338 (set_attr "mode" "QI")])
4b71cd6e 7339
558740bf
JH
7340(define_expand "umulditi3"
7341 [(parallel [(set (match_operand:TI 0 "register_operand" "")
7342 (mult:TI (zero_extend:TI
7343 (match_operand:DI 1 "nonimmediate_operand" ""))
7344 (zero_extend:TI
7345 (match_operand:DI 2 "register_operand" ""))))
7346 (clobber (reg:CC 17))])]
7347 "TARGET_64BIT"
7348 "")
7349
7350(define_insn "*umulditi3_insn"
9b70259d 7351 [(set (match_operand:TI 0 "register_operand" "=A")
558740bf 7352 (mult:TI (zero_extend:TI (match_operand:DI 1 "nonimmediate_operand" "%0"))
9b70259d 7353 (zero_extend:TI (match_operand:DI 2 "nonimmediate_operand" "rm"))))
1e07edd3 7354 (clobber (reg:CC 17))]
558740bf
JH
7355 "TARGET_64BIT
7356 && (GET_CODE (operands[1]) != MEM || GET_CODE (operands[2]) != MEM)"
0f40f9f7 7357 "mul{q}\t%2"
1e07edd3
JH
7358 [(set_attr "type" "imul")
7359 (set_attr "ppro_uops" "few")
7360 (set_attr "length_immediate" "0")
f56e86bd
JH
7361 (set (attr "athlon_decode")
7362 (if_then_else (eq_attr "cpu" "athlon")
7363 (const_string "vector")
7364 (const_string "double")))
9b70259d 7365 (set_attr "mode" "DI")])
1e07edd3
JH
7366
7367;; We can't use this pattern in 64bit mode, since it results in two separate 32bit registers
558740bf
JH
7368(define_expand "umulsidi3"
7369 [(parallel [(set (match_operand:DI 0 "register_operand" "")
7370 (mult:DI (zero_extend:DI
7371 (match_operand:SI 1 "nonimmediate_operand" ""))
7372 (zero_extend:DI
7373 (match_operand:SI 2 "register_operand" ""))))
7374 (clobber (reg:CC 17))])]
7375 "!TARGET_64BIT"
7376 "")
7377
7378(define_insn "*umulsidi3_insn"
4b71cd6e 7379 [(set (match_operand:DI 0 "register_operand" "=A")
558740bf 7380 (mult:DI (zero_extend:DI (match_operand:SI 1 "nonimmediate_operand" "%0"))
e075ae69
RH
7381 (zero_extend:DI (match_operand:SI 2 "nonimmediate_operand" "rm"))))
7382 (clobber (reg:CC 17))]
558740bf
JH
7383 "!TARGET_64BIT
7384 && (GET_CODE (operands[1]) != MEM || GET_CODE (operands[2]) != MEM)"
0f40f9f7 7385 "mul{l}\t%2"
e075ae69 7386 [(set_attr "type" "imul")
6ef67412
JH
7387 (set_attr "ppro_uops" "few")
7388 (set_attr "length_immediate" "0")
f56e86bd
JH
7389 (set (attr "athlon_decode")
7390 (if_then_else (eq_attr "cpu" "athlon")
7391 (const_string "vector")
7392 (const_string "double")))
6ef67412 7393 (set_attr "mode" "SI")])
4b71cd6e 7394
558740bf
JH
7395(define_expand "mulditi3"
7396 [(parallel [(set (match_operand:TI 0 "register_operand" "")
7397 (mult:TI (sign_extend:TI
7398 (match_operand:DI 1 "nonimmediate_operand" ""))
7399 (sign_extend:TI
7400 (match_operand:DI 2 "register_operand" ""))))
7401 (clobber (reg:CC 17))])]
7402 "TARGET_64BIT"
7403 "")
7404
7405(define_insn "*mulditi3_insn"
9b70259d 7406 [(set (match_operand:TI 0 "register_operand" "=A")
558740bf 7407 (mult:TI (sign_extend:TI (match_operand:DI 1 "nonimmediate_operand" "%0"))
9b70259d
JH
7408 (sign_extend:TI (match_operand:DI 2 "nonimmediate_operand" "rm"))))
7409 (clobber (reg:CC 17))]
558740bf
JH
7410 "TARGET_64BIT
7411 && (GET_CODE (operands[1]) != MEM || GET_CODE (operands[2]) != MEM)"
0f40f9f7 7412 "imul{q}\t%2"
9b70259d
JH
7413 [(set_attr "type" "imul")
7414 (set_attr "length_immediate" "0")
f56e86bd
JH
7415 (set (attr "athlon_decode")
7416 (if_then_else (eq_attr "cpu" "athlon")
7417 (const_string "vector")
7418 (const_string "double")))
9b70259d
JH
7419 (set_attr "mode" "DI")])
7420
558740bf
JH
7421(define_expand "mulsidi3"
7422 [(parallel [(set (match_operand:DI 0 "register_operand" "")
7423 (mult:DI (sign_extend:DI
7424 (match_operand:SI 1 "nonimmediate_operand" ""))
7425 (sign_extend:DI
7426 (match_operand:SI 2 "register_operand" ""))))
7427 (clobber (reg:CC 17))])]
7428 "!TARGET_64BIT"
7429 "")
7430
7431(define_insn "*mulsidi3_insn"
4b71cd6e 7432 [(set (match_operand:DI 0 "register_operand" "=A")
558740bf 7433 (mult:DI (sign_extend:DI (match_operand:SI 1 "nonimmediate_operand" "%0"))
e075ae69
RH
7434 (sign_extend:DI (match_operand:SI 2 "nonimmediate_operand" "rm"))))
7435 (clobber (reg:CC 17))]
558740bf
JH
7436 "!TARGET_64BIT
7437 && (GET_CODE (operands[1]) != MEM || GET_CODE (operands[2]) != MEM)"
0f40f9f7 7438 "imul{l}\t%2"
6ef67412
JH
7439 [(set_attr "type" "imul")
7440 (set_attr "length_immediate" "0")
f56e86bd
JH
7441 (set (attr "athlon_decode")
7442 (if_then_else (eq_attr "cpu" "athlon")
7443 (const_string "vector")
7444 (const_string "double")))
6ef67412 7445 (set_attr "mode" "SI")])
2f2a49e8 7446
558740bf
JH
7447(define_expand "umuldi3_highpart"
7448 [(parallel [(set (match_operand:DI 0 "register_operand" "")
7449 (truncate:DI
7450 (lshiftrt:TI
7451 (mult:TI (zero_extend:TI
7452 (match_operand:DI 1 "nonimmediate_operand" ""))
7453 (zero_extend:TI
7454 (match_operand:DI 2 "register_operand" "")))
7455 (const_int 64))))
7456 (clobber (match_scratch:DI 3 ""))
7457 (clobber (reg:CC 17))])]
7458 "TARGET_64BIT"
7459 "")
7460
9b70259d
JH
7461(define_insn "*umuldi3_highpart_rex64"
7462 [(set (match_operand:DI 0 "register_operand" "=d")
7463 (truncate:DI
7464 (lshiftrt:TI
7465 (mult:TI (zero_extend:TI
558740bf 7466 (match_operand:DI 1 "nonimmediate_operand" "%a"))
9b70259d
JH
7467 (zero_extend:TI
7468 (match_operand:DI 2 "nonimmediate_operand" "rm")))
7469 (const_int 64))))
558740bf 7470 (clobber (match_scratch:DI 3 "=1"))
9b70259d 7471 (clobber (reg:CC 17))]
558740bf
JH
7472 "TARGET_64BIT
7473 && (GET_CODE (operands[1]) != MEM || GET_CODE (operands[2]) != MEM)"
0f40f9f7 7474 "mul{q}\t%2"
9b70259d
JH
7475 [(set_attr "type" "imul")
7476 (set_attr "ppro_uops" "few")
7477 (set_attr "length_immediate" "0")
f56e86bd
JH
7478 (set (attr "athlon_decode")
7479 (if_then_else (eq_attr "cpu" "athlon")
7480 (const_string "vector")
7481 (const_string "double")))
9b70259d
JH
7482 (set_attr "mode" "DI")])
7483
558740bf
JH
7484(define_expand "umulsi3_highpart"
7485 [(parallel [(set (match_operand:SI 0 "register_operand" "")
7486 (truncate:SI
7487 (lshiftrt:DI
7488 (mult:DI (zero_extend:DI
7489 (match_operand:SI 1 "nonimmediate_operand" ""))
7490 (zero_extend:DI
7491 (match_operand:SI 2 "register_operand" "")))
7492 (const_int 32))))
7493 (clobber (match_scratch:SI 3 ""))
7494 (clobber (reg:CC 17))])]
7495 ""
7496 "")
7497
7498(define_insn "*umulsi3_highpart_insn"
2f2a49e8 7499 [(set (match_operand:SI 0 "register_operand" "=d")
e075ae69
RH
7500 (truncate:SI
7501 (lshiftrt:DI
7502 (mult:DI (zero_extend:DI
558740bf 7503 (match_operand:SI 1 "nonimmediate_operand" "%a"))
e075ae69
RH
7504 (zero_extend:DI
7505 (match_operand:SI 2 "nonimmediate_operand" "rm")))
7506 (const_int 32))))
558740bf 7507 (clobber (match_scratch:SI 3 "=1"))
e075ae69 7508 (clobber (reg:CC 17))]
558740bf 7509 "GET_CODE (operands[1]) != MEM || GET_CODE (operands[2]) != MEM"
0f40f9f7 7510 "mul{l}\t%2"
32ee7d1d
JH
7511 [(set_attr "type" "imul")
7512 (set_attr "ppro_uops" "few")
7513 (set_attr "length_immediate" "0")
f56e86bd
JH
7514 (set (attr "athlon_decode")
7515 (if_then_else (eq_attr "cpu" "athlon")
7516 (const_string "vector")
7517 (const_string "double")))
32ee7d1d
JH
7518 (set_attr "mode" "SI")])
7519
7520(define_insn "*umulsi3_highpart_zext"
7521 [(set (match_operand:DI 0 "register_operand" "=d")
7522 (zero_extend:DI (truncate:SI
7523 (lshiftrt:DI
7524 (mult:DI (zero_extend:DI
558740bf 7525 (match_operand:SI 1 "nonimmediate_operand" "%a"))
32ee7d1d
JH
7526 (zero_extend:DI
7527 (match_operand:SI 2 "nonimmediate_operand" "rm")))
7528 (const_int 32)))))
558740bf 7529 (clobber (match_scratch:SI 3 "=1"))
32ee7d1d 7530 (clobber (reg:CC 17))]
558740bf
JH
7531 "TARGET_64BIT
7532 && (GET_CODE (operands[1]) != MEM || GET_CODE (operands[2]) != MEM)"
0f40f9f7 7533 "mul{l}\t%2"
e075ae69 7534 [(set_attr "type" "imul")
6ef67412
JH
7535 (set_attr "ppro_uops" "few")
7536 (set_attr "length_immediate" "0")
f56e86bd
JH
7537 (set (attr "athlon_decode")
7538 (if_then_else (eq_attr "cpu" "athlon")
7539 (const_string "vector")
7540 (const_string "double")))
6ef67412 7541 (set_attr "mode" "SI")])
2f2a49e8 7542
558740bf
JH
7543(define_expand "smuldi3_highpart"
7544 [(parallel [(set (match_operand:DI 0 "register_operand" "=d")
7545 (truncate:DI
7546 (lshiftrt:TI
7547 (mult:TI (sign_extend:TI
7548 (match_operand:DI 1 "nonimmediate_operand" ""))
7549 (sign_extend:TI
7550 (match_operand:DI 2 "register_operand" "")))
7551 (const_int 64))))
7552 (clobber (match_scratch:DI 3 ""))
7553 (clobber (reg:CC 17))])]
7554 "TARGET_64BIT"
7555 "")
7556
9b70259d
JH
7557(define_insn "*smuldi3_highpart_rex64"
7558 [(set (match_operand:DI 0 "register_operand" "=d")
7559 (truncate:DI
7560 (lshiftrt:TI
7561 (mult:TI (sign_extend:TI
558740bf 7562 (match_operand:DI 1 "nonimmediate_operand" "%a"))
9b70259d
JH
7563 (sign_extend:TI
7564 (match_operand:DI 2 "nonimmediate_operand" "rm")))
7565 (const_int 64))))
558740bf 7566 (clobber (match_scratch:DI 3 "=1"))
9b70259d 7567 (clobber (reg:CC 17))]
558740bf
JH
7568 "TARGET_64BIT
7569 && (GET_CODE (operands[1]) != MEM || GET_CODE (operands[2]) != MEM)"
0f40f9f7 7570 "imul{q}\t%2"
9b70259d
JH
7571 [(set_attr "type" "imul")
7572 (set_attr "ppro_uops" "few")
f56e86bd
JH
7573 (set (attr "athlon_decode")
7574 (if_then_else (eq_attr "cpu" "athlon")
7575 (const_string "vector")
7576 (const_string "double")))
9b70259d
JH
7577 (set_attr "mode" "DI")])
7578
558740bf
JH
7579(define_expand "smulsi3_highpart"
7580 [(parallel [(set (match_operand:SI 0 "register_operand" "")
7581 (truncate:SI
7582 (lshiftrt:DI
7583 (mult:DI (sign_extend:DI
7584 (match_operand:SI 1 "nonimmediate_operand" ""))
7585 (sign_extend:DI
7586 (match_operand:SI 2 "register_operand" "")))
7587 (const_int 32))))
7588 (clobber (match_scratch:SI 3 ""))
7589 (clobber (reg:CC 17))])]
7590 ""
7591 "")
7592
7593(define_insn "*smulsi3_highpart_insn"
2f2a49e8 7594 [(set (match_operand:SI 0 "register_operand" "=d")
e075ae69
RH
7595 (truncate:SI
7596 (lshiftrt:DI
7597 (mult:DI (sign_extend:DI
558740bf 7598 (match_operand:SI 1 "nonimmediate_operand" "%a"))
e075ae69
RH
7599 (sign_extend:DI
7600 (match_operand:SI 2 "nonimmediate_operand" "rm")))
7601 (const_int 32))))
558740bf 7602 (clobber (match_scratch:SI 3 "=1"))
e075ae69 7603 (clobber (reg:CC 17))]
558740bf 7604 "GET_CODE (operands[1]) != MEM || GET_CODE (operands[2]) != MEM"
0f40f9f7 7605 "imul{l}\t%2"
e075ae69 7606 [(set_attr "type" "imul")
6ef67412 7607 (set_attr "ppro_uops" "few")
f56e86bd
JH
7608 (set (attr "athlon_decode")
7609 (if_then_else (eq_attr "cpu" "athlon")
7610 (const_string "vector")
7611 (const_string "double")))
6ef67412 7612 (set_attr "mode" "SI")])
4b71cd6e 7613
9b70259d
JH
7614(define_insn "*smulsi3_highpart_zext"
7615 [(set (match_operand:DI 0 "register_operand" "=d")
7616 (zero_extend:DI (truncate:SI
7617 (lshiftrt:DI
7618 (mult:DI (sign_extend:DI
558740bf 7619 (match_operand:SI 1 "nonimmediate_operand" "%a"))
9b70259d
JH
7620 (sign_extend:DI
7621 (match_operand:SI 2 "nonimmediate_operand" "rm")))
7622 (const_int 32)))))
558740bf 7623 (clobber (match_scratch:SI 3 "=1"))
9b70259d 7624 (clobber (reg:CC 17))]
558740bf
JH
7625 "TARGET_64BIT
7626 && (GET_CODE (operands[1]) != MEM || GET_CODE (operands[2]) != MEM)"
0f40f9f7 7627 "imul{l}\t%2"
9b70259d
JH
7628 [(set_attr "type" "imul")
7629 (set_attr "ppro_uops" "few")
f56e86bd
JH
7630 (set (attr "athlon_decode")
7631 (if_then_else (eq_attr "cpu" "athlon")
7632 (const_string "vector")
7633 (const_string "double")))
9b70259d
JH
7634 (set_attr "mode" "SI")])
7635
886c62d1
JVA
7636;; The patterns that match these are at the end of this file.
7637
4fb21e90
JVA
7638(define_expand "mulxf3"
7639 [(set (match_operand:XF 0 "register_operand" "")
2ae0f82c
SC
7640 (mult:XF (match_operand:XF 1 "register_operand" "")
7641 (match_operand:XF 2 "register_operand" "")))]
1b0c37d7 7642 "!TARGET_64BIT && TARGET_80387"
4fb21e90
JVA
7643 "")
7644
2b589241
JH
7645(define_expand "multf3"
7646 [(set (match_operand:TF 0 "register_operand" "")
7647 (mult:TF (match_operand:TF 1 "register_operand" "")
7648 (match_operand:TF 2 "register_operand" "")))]
7649 "TARGET_80387"
7650 "")
7651
886c62d1
JVA
7652(define_expand "muldf3"
7653 [(set (match_operand:DF 0 "register_operand" "")
2ae0f82c 7654 (mult:DF (match_operand:DF 1 "register_operand" "")
886c62d1 7655 (match_operand:DF 2 "nonimmediate_operand" "")))]
965f5423 7656 "TARGET_80387 || (TARGET_SSE2 && TARGET_SSE_MATH)"
886c62d1
JVA
7657 "")
7658
7659(define_expand "mulsf3"
7660 [(set (match_operand:SF 0 "register_operand" "")
2ae0f82c 7661 (mult:SF (match_operand:SF 1 "register_operand" "")
886c62d1 7662 (match_operand:SF 2 "nonimmediate_operand" "")))]
965f5423 7663 "TARGET_80387 || TARGET_SSE_MATH"
886c62d1
JVA
7664 "")
7665\f
e075ae69 7666;; Divide instructions
886c62d1
JVA
7667
7668(define_insn "divqi3"
2ae0f82c
SC
7669 [(set (match_operand:QI 0 "register_operand" "=a")
7670 (div:QI (match_operand:HI 1 "register_operand" "0")
e075ae69
RH
7671 (match_operand:QI 2 "nonimmediate_operand" "qm")))
7672 (clobber (reg:CC 17))]
d9f32422 7673 "TARGET_QIMODE_MATH"
0f40f9f7 7674 "idiv{b}\t%2"
e075ae69 7675 [(set_attr "type" "idiv")
6ef67412 7676 (set_attr "mode" "QI")
e075ae69 7677 (set_attr "ppro_uops" "few")])
886c62d1
JVA
7678
7679(define_insn "udivqi3"
2ae0f82c
SC
7680 [(set (match_operand:QI 0 "register_operand" "=a")
7681 (udiv:QI (match_operand:HI 1 "register_operand" "0")
e075ae69
RH
7682 (match_operand:QI 2 "nonimmediate_operand" "qm")))
7683 (clobber (reg:CC 17))]
d9f32422 7684 "TARGET_QIMODE_MATH"
0f40f9f7 7685 "div{b}\t%2"
e075ae69 7686 [(set_attr "type" "idiv")
6ef67412 7687 (set_attr "mode" "QI")
e075ae69 7688 (set_attr "ppro_uops" "few")])
886c62d1
JVA
7689
7690;; The patterns that match these are at the end of this file.
7691
4fb21e90
JVA
7692(define_expand "divxf3"
7693 [(set (match_operand:XF 0 "register_operand" "")
2ae0f82c
SC
7694 (div:XF (match_operand:XF 1 "register_operand" "")
7695 (match_operand:XF 2 "register_operand" "")))]
1b0c37d7 7696 "!TARGET_64BIT && TARGET_80387"
886c62d1
JVA
7697 "")
7698
2b589241
JH
7699(define_expand "divtf3"
7700 [(set (match_operand:TF 0 "register_operand" "")
7701 (div:TF (match_operand:TF 1 "register_operand" "")
7702 (match_operand:TF 2 "register_operand" "")))]
7703 "TARGET_80387"
7704 "")
7705
a78cb986
SC
7706(define_expand "divdf3"
7707 [(set (match_operand:DF 0 "register_operand" "")
7708 (div:DF (match_operand:DF 1 "register_operand" "")
7709 (match_operand:DF 2 "nonimmediate_operand" "")))]
965f5423 7710 "TARGET_80387 || (TARGET_SSE2 && TARGET_SSE_MATH)"
a78cb986
SC
7711 "")
7712
886c62d1
JVA
7713(define_expand "divsf3"
7714 [(set (match_operand:SF 0 "register_operand" "")
2ae0f82c 7715 (div:SF (match_operand:SF 1 "register_operand" "")
886c62d1 7716 (match_operand:SF 2 "nonimmediate_operand" "")))]
965f5423 7717 "TARGET_80387 || TARGET_SSE_MATH"
886c62d1
JVA
7718 "")
7719\f
7720;; Remainder instructions.
9b70259d
JH
7721
7722(define_expand "divmoddi4"
7723 [(parallel [(set (match_operand:DI 0 "register_operand" "")
7724 (div:DI (match_operand:DI 1 "register_operand" "")
7725 (match_operand:DI 2 "nonimmediate_operand" "")))
7726 (set (match_operand:DI 3 "register_operand" "")
7727 (mod:DI (match_dup 1) (match_dup 2)))
7728 (clobber (reg:CC 17))])]
7729 "TARGET_64BIT"
7730 "")
7731
7732;; Allow to come the parameter in eax or edx to avoid extra moves.
d1f87653 7733;; Penalize eax case slightly because it results in worse scheduling
9b70259d
JH
7734;; of code.
7735(define_insn "*divmoddi4_nocltd_rex64"
7736 [(set (match_operand:DI 0 "register_operand" "=&a,?a")
7737 (div:DI (match_operand:DI 2 "register_operand" "1,0")
7738 (match_operand:DI 3 "nonimmediate_operand" "rm,rm")))
7739 (set (match_operand:DI 1 "register_operand" "=&d,&d")
7740 (mod:DI (match_dup 2) (match_dup 3)))
7741 (clobber (reg:CC 17))]
7742 "TARGET_64BIT && !optimize_size && !TARGET_USE_CLTD"
7743 "#"
7744 [(set_attr "type" "multi")])
7745
7746(define_insn "*divmoddi4_cltd_rex64"
7747 [(set (match_operand:DI 0 "register_operand" "=a")
7748 (div:DI (match_operand:DI 2 "register_operand" "a")
7749 (match_operand:DI 3 "nonimmediate_operand" "rm")))
7750 (set (match_operand:DI 1 "register_operand" "=&d")
7751 (mod:DI (match_dup 2) (match_dup 3)))
7752 (clobber (reg:CC 17))]
7753 "TARGET_64BIT && (optimize_size || TARGET_USE_CLTD)"
7754 "#"
7755 [(set_attr "type" "multi")])
7756
7757(define_insn "*divmoddi_noext_rex64"
7758 [(set (match_operand:DI 0 "register_operand" "=a")
7759 (div:DI (match_operand:DI 1 "register_operand" "0")
7760 (match_operand:DI 2 "nonimmediate_operand" "rm")))
7761 (set (match_operand:DI 3 "register_operand" "=d")
7762 (mod:DI (match_dup 1) (match_dup 2)))
7763 (use (match_operand:DI 4 "register_operand" "3"))
7764 (clobber (reg:CC 17))]
7765 "TARGET_64BIT"
0f40f9f7 7766 "idiv{q}\t%2"
9b70259d
JH
7767 [(set_attr "type" "idiv")
7768 (set_attr "mode" "DI")
7769 (set_attr "ppro_uops" "few")])
7770
7771(define_split
7772 [(set (match_operand:DI 0 "register_operand" "")
7773 (div:DI (match_operand:DI 1 "register_operand" "")
7774 (match_operand:DI 2 "nonimmediate_operand" "")))
7775 (set (match_operand:DI 3 "register_operand" "")
7776 (mod:DI (match_dup 1) (match_dup 2)))
7777 (clobber (reg:CC 17))]
7778 "TARGET_64BIT && reload_completed"
7779 [(parallel [(set (match_dup 3)
7780 (ashiftrt:DI (match_dup 4) (const_int 63)))
7781 (clobber (reg:CC 17))])
7782 (parallel [(set (match_dup 0)
7783 (div:DI (reg:DI 0) (match_dup 2)))
7784 (set (match_dup 3)
7785 (mod:DI (reg:DI 0) (match_dup 2)))
7786 (use (match_dup 3))
7787 (clobber (reg:CC 17))])]
9b70259d 7788{
9cd10576 7789 /* Avoid use of cltd in favor of a mov+shift. */
9b70259d
JH
7790 if (!TARGET_USE_CLTD && !optimize_size)
7791 {
7792 if (true_regnum (operands[1]))
7793 emit_move_insn (operands[0], operands[1]);
7794 else
7795 emit_move_insn (operands[3], operands[1]);
7796 operands[4] = operands[3];
7797 }
7798 else
7799 {
7800 if (true_regnum (operands[1]))
7801 abort();
7802 operands[4] = operands[1];
7803 }
0f40f9f7 7804})
9b70259d
JH
7805
7806
40745eec
JH
7807(define_expand "divmodsi4"
7808 [(parallel [(set (match_operand:SI 0 "register_operand" "")
7809 (div:SI (match_operand:SI 1 "register_operand" "")
7810 (match_operand:SI 2 "nonimmediate_operand" "")))
7811 (set (match_operand:SI 3 "register_operand" "")
7812 (mod:SI (match_dup 1) (match_dup 2)))
7813 (clobber (reg:CC 17))])]
7814 ""
7815 "")
7816
7817;; Allow to come the parameter in eax or edx to avoid extra moves.
d1f87653 7818;; Penalize eax case slightly because it results in worse scheduling
40745eec
JH
7819;; of code.
7820(define_insn "*divmodsi4_nocltd"
7821 [(set (match_operand:SI 0 "register_operand" "=&a,?a")
7822 (div:SI (match_operand:SI 2 "register_operand" "1,0")
7823 (match_operand:SI 3 "nonimmediate_operand" "rm,rm")))
7824 (set (match_operand:SI 1 "register_operand" "=&d,&d")
7825 (mod:SI (match_dup 2) (match_dup 3)))
7826 (clobber (reg:CC 17))]
7827 "!optimize_size && !TARGET_USE_CLTD"
7828 "#"
7829 [(set_attr "type" "multi")])
886c62d1 7830
40745eec 7831(define_insn "*divmodsi4_cltd"
2bb7a0f5 7832 [(set (match_operand:SI 0 "register_operand" "=a")
40745eec
JH
7833 (div:SI (match_operand:SI 2 "register_operand" "a")
7834 (match_operand:SI 3 "nonimmediate_operand" "rm")))
7835 (set (match_operand:SI 1 "register_operand" "=&d")
7836 (mod:SI (match_dup 2) (match_dup 3)))
e075ae69 7837 (clobber (reg:CC 17))]
40745eec
JH
7838 "optimize_size || TARGET_USE_CLTD"
7839 "#"
e075ae69
RH
7840 [(set_attr "type" "multi")])
7841
6343a50e 7842(define_insn "*divmodsi_noext"
e075ae69 7843 [(set (match_operand:SI 0 "register_operand" "=a")
40745eec 7844 (div:SI (match_operand:SI 1 "register_operand" "0")
e075ae69
RH
7845 (match_operand:SI 2 "nonimmediate_operand" "rm")))
7846 (set (match_operand:SI 3 "register_operand" "=d")
7847 (mod:SI (match_dup 1) (match_dup 2)))
40745eec 7848 (use (match_operand:SI 4 "register_operand" "3"))
e075ae69
RH
7849 (clobber (reg:CC 17))]
7850 ""
0f40f9f7 7851 "idiv{l}\t%2"
e075ae69 7852 [(set_attr "type" "idiv")
6ef67412 7853 (set_attr "mode" "SI")
e075ae69
RH
7854 (set_attr "ppro_uops" "few")])
7855
7856(define_split
7857 [(set (match_operand:SI 0 "register_operand" "")
7858 (div:SI (match_operand:SI 1 "register_operand" "")
7859 (match_operand:SI 2 "nonimmediate_operand" "")))
7860 (set (match_operand:SI 3 "register_operand" "")
7861 (mod:SI (match_dup 1) (match_dup 2)))
7862 (clobber (reg:CC 17))]
7863 "reload_completed"
7864 [(parallel [(set (match_dup 3)
7865 (ashiftrt:SI (match_dup 4) (const_int 31)))
7866 (clobber (reg:CC 17))])
7867 (parallel [(set (match_dup 0)
40745eec 7868 (div:SI (reg:SI 0) (match_dup 2)))
e075ae69 7869 (set (match_dup 3)
40745eec 7870 (mod:SI (reg:SI 0) (match_dup 2)))
e075ae69
RH
7871 (use (match_dup 3))
7872 (clobber (reg:CC 17))])]
886c62d1 7873{
9cd10576 7874 /* Avoid use of cltd in favor of a mov+shift. */
40745eec 7875 if (!TARGET_USE_CLTD && !optimize_size)
e075ae69 7876 {
40745eec
JH
7877 if (true_regnum (operands[1]))
7878 emit_move_insn (operands[0], operands[1]);
7879 else
7880 emit_move_insn (operands[3], operands[1]);
e075ae69
RH
7881 operands[4] = operands[3];
7882 }
7883 else
40745eec
JH
7884 {
7885 if (true_regnum (operands[1]))
7886 abort();
7887 operands[4] = operands[1];
7888 }
0f40f9f7 7889})
e075ae69 7890;; %%% Split me.
886c62d1 7891(define_insn "divmodhi4"
2bb7a0f5
RS
7892 [(set (match_operand:HI 0 "register_operand" "=a")
7893 (div:HI (match_operand:HI 1 "register_operand" "0")
2ae0f82c 7894 (match_operand:HI 2 "nonimmediate_operand" "rm")))
2bb7a0f5 7895 (set (match_operand:HI 3 "register_operand" "=&d")
e075ae69
RH
7896 (mod:HI (match_dup 1) (match_dup 2)))
7897 (clobber (reg:CC 17))]
d9f32422 7898 "TARGET_HIMODE_MATH"
0f40f9f7 7899 "cwtd\;idiv{w}\t%2"
6ef67412
JH
7900 [(set_attr "type" "multi")
7901 (set_attr "length_immediate" "0")
7902 (set_attr "mode" "SI")])
886c62d1 7903
9b70259d
JH
7904(define_insn "udivmoddi4"
7905 [(set (match_operand:DI 0 "register_operand" "=a")
7906 (udiv:DI (match_operand:DI 1 "register_operand" "0")
7907 (match_operand:DI 2 "nonimmediate_operand" "rm")))
7908 (set (match_operand:DI 3 "register_operand" "=&d")
7909 (umod:DI (match_dup 1) (match_dup 2)))
7910 (clobber (reg:CC 17))]
7911 "TARGET_64BIT"
0f40f9f7 7912 "xor{q}\t%3, %3\;div{q}\t%2"
9b70259d
JH
7913 [(set_attr "type" "multi")
7914 (set_attr "length_immediate" "0")
7915 (set_attr "mode" "DI")])
7916
7917(define_insn "*udivmoddi4_noext"
7918 [(set (match_operand:DI 0 "register_operand" "=a")
7919 (udiv:DI (match_operand:DI 1 "register_operand" "0")
7920 (match_operand:DI 2 "nonimmediate_operand" "rm")))
7921 (set (match_operand:DI 3 "register_operand" "=d")
7922 (umod:DI (match_dup 1) (match_dup 2)))
7923 (use (match_dup 3))
7924 (clobber (reg:CC 17))]
7925 "TARGET_64BIT"
0f40f9f7 7926 "div{q}\t%2"
9b70259d
JH
7927 [(set_attr "type" "idiv")
7928 (set_attr "ppro_uops" "few")
7929 (set_attr "mode" "DI")])
7930
7931(define_split
7932 [(set (match_operand:DI 0 "register_operand" "")
7933 (udiv:DI (match_operand:DI 1 "register_operand" "")
7934 (match_operand:DI 2 "nonimmediate_operand" "")))
7935 (set (match_operand:DI 3 "register_operand" "")
7936 (umod:DI (match_dup 1) (match_dup 2)))
7937 (clobber (reg:CC 17))]
1b0c37d7 7938 "TARGET_64BIT && reload_completed"
9b70259d
JH
7939 [(set (match_dup 3) (const_int 0))
7940 (parallel [(set (match_dup 0)
7941 (udiv:DI (match_dup 1) (match_dup 2)))
7942 (set (match_dup 3)
7943 (umod:DI (match_dup 1) (match_dup 2)))
7944 (use (match_dup 3))
7945 (clobber (reg:CC 17))])]
7946 "")
7947
886c62d1 7948(define_insn "udivmodsi4"
2bb7a0f5
RS
7949 [(set (match_operand:SI 0 "register_operand" "=a")
7950 (udiv:SI (match_operand:SI 1 "register_operand" "0")
2ae0f82c 7951 (match_operand:SI 2 "nonimmediate_operand" "rm")))
2bb7a0f5 7952 (set (match_operand:SI 3 "register_operand" "=&d")
e075ae69
RH
7953 (umod:SI (match_dup 1) (match_dup 2)))
7954 (clobber (reg:CC 17))]
886c62d1 7955 ""
0f40f9f7 7956 "xor{l}\t%3, %3\;div{l}\t%2"
6ef67412
JH
7957 [(set_attr "type" "multi")
7958 (set_attr "length_immediate" "0")
7959 (set_attr "mode" "SI")])
886c62d1 7960
6343a50e 7961(define_insn "*udivmodsi4_noext"
2bb7a0f5 7962 [(set (match_operand:SI 0 "register_operand" "=a")
e075ae69 7963 (udiv:SI (match_operand:SI 1 "register_operand" "0")
2ae0f82c 7964 (match_operand:SI 2 "nonimmediate_operand" "rm")))
2bb7a0f5 7965 (set (match_operand:SI 3 "register_operand" "=d")
e075ae69
RH
7966 (umod:SI (match_dup 1) (match_dup 2)))
7967 (use (match_dup 3))
7968 (clobber (reg:CC 17))]
886c62d1 7969 ""
0f40f9f7 7970 "div{l}\t%2"
e075ae69 7971 [(set_attr "type" "idiv")
6ef67412
JH
7972 (set_attr "ppro_uops" "few")
7973 (set_attr "mode" "SI")])
886c62d1 7974
e075ae69
RH
7975(define_split
7976 [(set (match_operand:SI 0 "register_operand" "")
7977 (udiv:SI (match_operand:SI 1 "register_operand" "")
7978 (match_operand:SI 2 "nonimmediate_operand" "")))
7979 (set (match_operand:SI 3 "register_operand" "")
7980 (umod:SI (match_dup 1) (match_dup 2)))
7981 (clobber (reg:CC 17))]
7982 "reload_completed"
591702de 7983 [(set (match_dup 3) (const_int 0))
e075ae69
RH
7984 (parallel [(set (match_dup 0)
7985 (udiv:SI (match_dup 1) (match_dup 2)))
7986 (set (match_dup 3)
7987 (umod:SI (match_dup 1) (match_dup 2)))
7988 (use (match_dup 3))
7989 (clobber (reg:CC 17))])]
7990 "")
886c62d1 7991
e075ae69 7992(define_expand "udivmodhi4"
591702de 7993 [(set (match_dup 4) (const_int 0))
40745eec
JH
7994 (parallel [(set (match_operand:HI 0 "register_operand" "")
7995 (udiv:HI (match_operand:HI 1 "register_operand" "")
7996 (match_operand:HI 2 "nonimmediate_operand" "")))
7997 (set (match_operand:HI 3 "register_operand" "")
e075ae69
RH
7998 (umod:HI (match_dup 1) (match_dup 2)))
7999 (use (match_dup 4))
8000 (clobber (reg:CC 17))])]
d9f32422 8001 "TARGET_HIMODE_MATH"
e075ae69 8002 "operands[4] = gen_reg_rtx (HImode);")
886c62d1 8003
6343a50e 8004(define_insn "*udivmodhi_noext"
e075ae69
RH
8005 [(set (match_operand:HI 0 "register_operand" "=a")
8006 (udiv:HI (match_operand:HI 1 "register_operand" "0")
8007 (match_operand:HI 2 "nonimmediate_operand" "rm")))
8008 (set (match_operand:HI 3 "register_operand" "=d")
8009 (umod:HI (match_dup 1) (match_dup 2)))
8010 (use (match_operand:HI 4 "register_operand" "3"))
8011 (clobber (reg:CC 17))]
8012 ""
0f40f9f7 8013 "div{w}\t%2"
e075ae69 8014 [(set_attr "type" "idiv")
6ef67412 8015 (set_attr "mode" "HI")
e075ae69
RH
8016 (set_attr "ppro_uops" "few")])
8017
8018;; We can not use div/idiv for double division, because it causes
8019;; "division by zero" on the overflow and that's not what we expect
8020;; from truncate. Because true (non truncating) double division is
8021;; never generated, we can't create this insn anyway.
8022;
8023;(define_insn ""
8024; [(set (match_operand:SI 0 "register_operand" "=a")
8025; (truncate:SI
8026; (udiv:DI (match_operand:DI 1 "register_operand" "A")
8027; (zero_extend:DI
8028; (match_operand:SI 2 "nonimmediate_operand" "rm")))))
8029; (set (match_operand:SI 3 "register_operand" "=d")
8030; (truncate:SI
8031; (umod:DI (match_dup 1) (zero_extend:DI (match_dup 2)))))
8032; (clobber (reg:CC 17))]
8033; ""
0f40f9f7 8034; "div{l}\t{%2, %0|%0, %2}"
e075ae69
RH
8035; [(set_attr "type" "idiv")
8036; (set_attr "ppro_uops" "few")])
886c62d1 8037\f
e075ae69
RH
8038;;- Logical AND instructions
8039
8040;; On Pentium, "test imm, reg" is pairable only with eax, ax, and al.
8041;; Note that this excludes ah.
8042
9b70259d
JH
8043(define_insn "*testdi_1_rex64"
8044 [(set (reg 17)
8045 (compare
8046 (and:DI (match_operand:DI 0 "nonimmediate_operand" "%*a,r,*a,r,rm")
8047 (match_operand:DI 1 "x86_64_szext_nonmemory_operand" "Z,Z,e,e,re"))
8048 (const_int 0)))]
8049 "TARGET_64BIT && ix86_match_ccmode (insn, CCNOmode)"
8050 "@
0f40f9f7
ZW
8051 test{l}\t{%k1, %k0|%k0, %k1}
8052 test{l}\t{%k1, %k0|%k0, %k1}
8053 test{q}\t{%1, %0|%0, %1}
8054 test{q}\t{%1, %0|%0, %1}
8055 test{q}\t{%1, %0|%0, %1}"
9b70259d
JH
8056 [(set_attr "type" "test")
8057 (set_attr "modrm" "0,1,0,1,1")
8058 (set_attr "mode" "SI,SI,DI,DI,DI")
8059 (set_attr "pent_pair" "uv,np,uv,np,uv")])
9076b9c1
JH
8060
8061(define_insn "testsi_1"
8062 [(set (reg 17)
8063 (compare
16189740
RH
8064 (and:SI (match_operand:SI 0 "nonimmediate_operand" "%*a,r,rm")
8065 (match_operand:SI 1 "nonmemory_operand" "in,in,rin"))
8066 (const_int 0)))]
9076b9c1 8067 "ix86_match_ccmode (insn, CCNOmode)"
0f40f9f7 8068 "test{l}\t{%1, %0|%0, %1}"
6ef67412
JH
8069 [(set_attr "type" "test")
8070 (set_attr "modrm" "0,1,1")
8071 (set_attr "mode" "SI")
e075ae69
RH
8072 (set_attr "pent_pair" "uv,np,uv")])
8073
9076b9c1 8074(define_expand "testsi_ccno_1"
e075ae69 8075 [(set (reg:CCNO 17)
16189740 8076 (compare:CCNO
9076b9c1
JH
8077 (and:SI (match_operand:SI 0 "nonimmediate_operand" "")
8078 (match_operand:SI 1 "nonmemory_operand" ""))
16189740 8079 (const_int 0)))]
a1cbdd7f 8080 ""
9076b9c1 8081 "")
16189740
RH
8082
8083(define_insn "*testhi_1"
8084 [(set (reg 17)
8085 (compare (and:HI (match_operand:HI 0 "nonimmediate_operand" "%*a,r,rm")
8086 (match_operand:HI 1 "nonmemory_operand" "n,n,rn"))
8087 (const_int 0)))]
8088 "ix86_match_ccmode (insn, CCNOmode)"
0f40f9f7 8089 "test{w}\t{%1, %0|%0, %1}"
6ef67412
JH
8090 [(set_attr "type" "test")
8091 (set_attr "modrm" "0,1,1")
8092 (set_attr "mode" "HI")
e075ae69
RH
8093 (set_attr "pent_pair" "uv,np,uv")])
8094
9076b9c1 8095(define_expand "testqi_ccz_1"
16189740 8096 [(set (reg:CCZ 17)
9076b9c1
JH
8097 (compare:CCZ (and:QI (match_operand:QI 0 "nonimmediate_operand" "")
8098 (match_operand:QI 1 "nonmemory_operand" ""))
8099 (const_int 0)))]
16189740 8100 ""
9076b9c1 8101 "")
16189740 8102
9076b9c1
JH
8103(define_insn "*testqi_1"
8104 [(set (reg 17)
8105 (compare (and:QI (match_operand:QI 0 "nonimmediate_operand" "%*a,q,qm,r")
8106 (match_operand:QI 1 "nonmemory_operand" "n,n,qn,n"))
8107 (const_int 0)))]
8108 "ix86_match_ccmode (insn, CCNOmode)"
adc88131
JJ
8109{
8110 if (which_alternative == 3)
8111 {
8112 if (GET_CODE (operands[1]) == CONST_INT
8113 && (INTVAL (operands[1]) & 0xffffff00))
8114 operands[1] = GEN_INT (INTVAL (operands[1]) & 0xff);
0f40f9f7 8115 return "test{l}\t{%1, %k0|%k0, %1}";
adc88131 8116 }
0f40f9f7
ZW
8117 return "test{b}\t{%1, %0|%0, %1}";
8118}
6ef67412
JH
8119 [(set_attr "type" "test")
8120 (set_attr "modrm" "0,1,1,1")
8121 (set_attr "mode" "QI,QI,QI,SI")
8122 (set_attr "pent_pair" "uv,np,uv,np")])
e075ae69 8123
9076b9c1
JH
8124(define_expand "testqi_ext_ccno_0"
8125 [(set (reg:CCNO 17)
8126 (compare:CCNO
16189740
RH
8127 (and:SI
8128 (zero_extract:SI
9076b9c1 8129 (match_operand 0 "ext_register_operand" "")
16189740
RH
8130 (const_int 8)
8131 (const_int 8))
9076b9c1 8132 (match_operand 1 "const_int_operand" ""))
16189740 8133 (const_int 0)))]
9076b9c1
JH
8134 ""
8135 "")
e075ae69 8136
9076b9c1
JH
8137(define_insn "*testqi_ext_0"
8138 [(set (reg 17)
8139 (compare
e075ae69
RH
8140 (and:SI
8141 (zero_extract:SI
d2836273 8142 (match_operand 0 "ext_register_operand" "Q")
e075ae69
RH
8143 (const_int 8)
8144 (const_int 8))
8145 (match_operand 1 "const_int_operand" "n"))
8146 (const_int 0)))]
2f41793e 8147 "ix86_match_ccmode (insn, CCNOmode)"
0f40f9f7 8148 "test{b}\t{%1, %h0|%h0, %1}"
6ef67412
JH
8149 [(set_attr "type" "test")
8150 (set_attr "mode" "QI")
8151 (set_attr "length_immediate" "1")
e075ae69
RH
8152 (set_attr "pent_pair" "np")])
8153
8154(define_insn "*testqi_ext_1"
16189740
RH
8155 [(set (reg 17)
8156 (compare
e075ae69
RH
8157 (and:SI
8158 (zero_extract:SI
d2836273 8159 (match_operand 0 "ext_register_operand" "Q")
e075ae69
RH
8160 (const_int 8)
8161 (const_int 8))
8162 (zero_extend:SI
d2836273 8163 (match_operand:QI 1 "nonimmediate_operand" "Qm")))
e075ae69 8164 (const_int 0)))]
d2836273 8165 "!TARGET_64BIT && ix86_match_ccmode (insn, CCNOmode)"
0f40f9f7 8166 "test{b}\t{%1, %h0|%h0, %1}"
d2836273
JH
8167 [(set_attr "type" "test")
8168 (set_attr "mode" "QI")])
8169
8170(define_insn "*testqi_ext_1_rex64"
8171 [(set (reg 17)
8172 (compare
8173 (and:SI
8174 (zero_extract:SI
8175 (match_operand 0 "ext_register_operand" "Q")
8176 (const_int 8)
8177 (const_int 8))
8178 (zero_extend:SI
3522082b 8179 (match_operand:QI 1 "register_operand" "Q")))
d2836273
JH
8180 (const_int 0)))]
8181 "TARGET_64BIT && ix86_match_ccmode (insn, CCNOmode)"
0f40f9f7 8182 "test{b}\t{%1, %h0|%h0, %1}"
6ef67412
JH
8183 [(set_attr "type" "test")
8184 (set_attr "mode" "QI")])
e075ae69
RH
8185
8186(define_insn "*testqi_ext_2"
16189740
RH
8187 [(set (reg 17)
8188 (compare
e075ae69
RH
8189 (and:SI
8190 (zero_extract:SI
d2836273 8191 (match_operand 0 "ext_register_operand" "Q")
e075ae69
RH
8192 (const_int 8)
8193 (const_int 8))
8194 (zero_extract:SI
d2836273 8195 (match_operand 1 "ext_register_operand" "Q")
e075ae69
RH
8196 (const_int 8)
8197 (const_int 8)))
8198 (const_int 0)))]
16189740 8199 "ix86_match_ccmode (insn, CCNOmode)"
0f40f9f7 8200 "test{b}\t{%h1, %h0|%h0, %h1}"
6ef67412
JH
8201 [(set_attr "type" "test")
8202 (set_attr "mode" "QI")])
e075ae69
RH
8203
8204;; Combine likes to form bit extractions for some tests. Humor it.
6343a50e 8205(define_insn "*testqi_ext_3"
16189740
RH
8206 [(set (reg 17)
8207 (compare (zero_extract:SI
8208 (match_operand 0 "nonimmediate_operand" "rm")
8209 (match_operand:SI 1 "const_int_operand" "")
8210 (match_operand:SI 2 "const_int_operand" ""))
8211 (const_int 0)))]
8212 "ix86_match_ccmode (insn, CCNOmode)
8213 && (GET_MODE (operands[0]) == SImode
9b70259d
JH
8214 || (TARGET_64BIT && GET_MODE (operands[0]) == DImode)
8215 || GET_MODE (operands[0]) == HImode
8216 || GET_MODE (operands[0]) == QImode)"
8217 "#")
8218
8219(define_insn "*testqi_ext_3_rex64"
8220 [(set (reg 17)
8221 (compare (zero_extract:DI
8222 (match_operand 0 "nonimmediate_operand" "rm")
8223 (match_operand:DI 1 "const_int_operand" "")
8224 (match_operand:DI 2 "const_int_operand" ""))
8225 (const_int 0)))]
1b0c37d7
ZW
8226 "TARGET_64BIT
8227 && ix86_match_ccmode (insn, CCNOmode)
f5143c46 8228 /* The code below cannot deal with constants outside HOST_WIDE_INT. */
44cf5b6a
JH
8229 && INTVAL (operands[1]) + INTVAL (operands[2]) < HOST_BITS_PER_WIDE_INT
8230 /* Ensure that resulting mask is zero or sign extended operand. */
8231 && (INTVAL (operands[1]) + INTVAL (operands[2]) <= 32
8232 || (INTVAL (operands[1]) + INTVAL (operands[2]) == 64
8233 && INTVAL (operands[1]) > 32))
9b70259d
JH
8234 && (GET_MODE (operands[0]) == SImode
8235 || GET_MODE (operands[0]) == DImode
16189740
RH
8236 || GET_MODE (operands[0]) == HImode
8237 || GET_MODE (operands[0]) == QImode)"
e075ae69 8238 "#")
4fce8e83 8239
e075ae69 8240(define_split
16189740 8241 [(set (reg 17)
9b70259d 8242 (compare (zero_extract
d5d6a58b 8243 (match_operand 0 "nonimmediate_operand" "")
9b70259d
JH
8244 (match_operand 1 "const_int_operand" "")
8245 (match_operand 2 "const_int_operand" ""))
16189740
RH
8246 (const_int 0)))]
8247 "ix86_match_ccmode (insn, CCNOmode)"
e075ae69 8248 [(set (reg:CCNO 17) (compare:CCNO (match_dup 3) (const_int 0)))]
e075ae69
RH
8249{
8250 HOST_WIDE_INT len = INTVAL (operands[1]);
8251 HOST_WIDE_INT pos = INTVAL (operands[2]);
8252 HOST_WIDE_INT mask;
592188a5 8253 enum machine_mode mode, submode;
886c62d1 8254
e075ae69
RH
8255 mode = GET_MODE (operands[0]);
8256 if (GET_CODE (operands[0]) == MEM)
5bc7cd8e 8257 {
e075ae69
RH
8258 /* ??? Combine likes to put non-volatile mem extractions in QImode
8259 no matter the size of the test. So find a mode that works. */
8260 if (! MEM_VOLATILE_P (operands[0]))
8261 {
8262 mode = smallest_mode_for_size (pos + len, MODE_INT);
f4ef873c 8263 operands[0] = adjust_address (operands[0], mode, 0);
e075ae69 8264 }
5bc7cd8e 8265 }
592188a5
RH
8266 else if (GET_CODE (operands[0]) == SUBREG
8267 && (submode = GET_MODE (SUBREG_REG (operands[0])),
8268 GET_MODE_BITSIZE (mode) > GET_MODE_BITSIZE (submode))
8269 && pos + len <= GET_MODE_BITSIZE (submode))
8270 {
8271 /* Narrow a paradoxical subreg to prevent partial register stalls. */
8272 mode = submode;
8273 operands[0] = SUBREG_REG (operands[0]);
8274 }
e075ae69 8275 else if (mode == HImode && pos + len <= 8)
5bc7cd8e 8276 {
e075ae69
RH
8277 /* Small HImode tests can be converted to QImode. */
8278 mode = QImode;
8279 operands[0] = gen_lowpart (QImode, operands[0]);
5bc7cd8e
SC
8280 }
8281
e075ae69
RH
8282 mask = ((HOST_WIDE_INT)1 << (pos + len)) - 1;
8283 mask &= ~(((HOST_WIDE_INT)1 << pos) - 1);
886c62d1 8284
d8bf17f9 8285 operands[3] = gen_rtx_AND (mode, operands[0], gen_int_mode (mask, mode));
0f40f9f7 8286})
886c62d1 8287
6c81a490
JH
8288;; Convert HImode/SImode test instructions with immediate to QImode ones.
8289;; i386 does not allow to encode test with 8bit sign extended immediate, so
8290;; this is relatively important trick.
d1f87653 8291;; Do the conversion only post-reload to avoid limiting of the register class
6c81a490
JH
8292;; to QI regs.
8293(define_split
8294 [(set (reg 17)
8295 (compare
8296 (and (match_operand 0 "register_operand" "")
8297 (match_operand 1 "const_int_operand" ""))
8298 (const_int 0)))]
2f41793e 8299 "reload_completed
6c81a490
JH
8300 && QI_REG_P (operands[0])
8301 && ((ix86_match_ccmode (insn, CCZmode)
8302 && !(INTVAL (operands[1]) & ~(255 << 8)))
8303 || (ix86_match_ccmode (insn, CCNOmode)
8304 && !(INTVAL (operands[1]) & ~(127 << 8))))
8305 && GET_MODE (operands[0]) != QImode"
8306 [(set (reg:CCNO 17)
8307 (compare:CCNO
8308 (and:SI (zero_extract:SI (match_dup 0) (const_int 8) (const_int 8))
8309 (match_dup 1))
8310 (const_int 0)))]
8311 "operands[0] = gen_lowpart (SImode, operands[0]);
b18b06ed 8312 operands[1] = gen_int_mode (INTVAL (operands[1]) >> 8, SImode);")
6c81a490
JH
8313
8314(define_split
8315 [(set (reg 17)
8316 (compare
8317 (and (match_operand 0 "nonimmediate_operand" "")
8318 (match_operand 1 "const_int_operand" ""))
8319 (const_int 0)))]
2f41793e 8320 "reload_completed
6c81a490
JH
8321 && (!REG_P (operands[0]) || ANY_QI_REG_P (operands[0]))
8322 && ((ix86_match_ccmode (insn, CCZmode)
8323 && !(INTVAL (operands[1]) & ~255))
8324 || (ix86_match_ccmode (insn, CCNOmode)
8325 && !(INTVAL (operands[1]) & ~127)))
8326 && GET_MODE (operands[0]) != QImode"
8327 [(set (reg:CCNO 17)
8328 (compare:CCNO
8329 (and:QI (match_dup 0)
8330 (match_dup 1))
8331 (const_int 0)))]
8332 "operands[0] = gen_lowpart (QImode, operands[0]);
8333 operands[1] = gen_lowpart (QImode, operands[1]);")
8334
8335
e075ae69
RH
8336;; %%% This used to optimize known byte-wide and operations to memory,
8337;; and sometimes to QImode registers. If this is considered useful,
8338;; it should be done with splitters.
8339
9b70259d
JH
8340(define_expand "anddi3"
8341 [(set (match_operand:DI 0 "nonimmediate_operand" "")
8342 (and:DI (match_operand:DI 1 "nonimmediate_operand" "")
8343 (match_operand:DI 2 "x86_64_szext_general_operand" "")))
8344 (clobber (reg:CC 17))]
8345 "TARGET_64BIT"
8346 "ix86_expand_binary_operator (AND, DImode, operands); DONE;")
8347
8348(define_insn "*anddi_1_rex64"
8349 [(set (match_operand:DI 0 "nonimmediate_operand" "=r,rm,r,r")
8350 (and:DI (match_operand:DI 1 "nonimmediate_operand" "%0,0,0,qm")
8351 (match_operand:DI 2 "x86_64_szext_general_operand" "Z,re,rm,L")))
8352 (clobber (reg:CC 17))]
8353 "TARGET_64BIT && ix86_binary_operator_ok (AND, DImode, operands)"
9b70259d
JH
8354{
8355 switch (get_attr_type (insn))
8356 {
8357 case TYPE_IMOVX:
8358 {
8359 enum machine_mode mode;
8360
8361 if (GET_CODE (operands[2]) != CONST_INT)
8362 abort ();
8363 if (INTVAL (operands[2]) == 0xff)
8364 mode = QImode;
8365 else if (INTVAL (operands[2]) == 0xffff)
8366 mode = HImode;
8367 else
8368 abort ();
8369
8370 operands[1] = gen_lowpart (mode, operands[1]);
8371 if (mode == QImode)
0f40f9f7 8372 return "movz{bq|x}\t{%1,%0|%0, %1}";
9b70259d 8373 else
0f40f9f7 8374 return "movz{wq|x}\t{%1,%0|%0, %1}";
9b70259d
JH
8375 }
8376
8377 default:
8378 if (! rtx_equal_p (operands[0], operands[1]))
8379 abort ();
8380 if (get_attr_mode (insn) == MODE_SI)
0f40f9f7 8381 return "and{l}\t{%k2, %k0|%k0, %k2}";
9b70259d 8382 else
0f40f9f7 8383 return "and{q}\t{%2, %0|%0, %2}";
9b70259d 8384 }
0f40f9f7 8385}
9b70259d
JH
8386 [(set_attr "type" "alu,alu,alu,imovx")
8387 (set_attr "length_immediate" "*,*,*,0")
8388 (set_attr "mode" "SI,DI,DI,DI")])
8389
8390(define_insn "*anddi_2"
8391 [(set (reg 17)
8392 (compare (and:DI (match_operand:DI 1 "nonimmediate_operand" "%0,0,0")
8393 (match_operand:DI 2 "x86_64_szext_general_operand" "Z,rem,re"))
8394 (const_int 0)))
8395 (set (match_operand:DI 0 "nonimmediate_operand" "=r,r,rm")
8396 (and:DI (match_dup 1) (match_dup 2)))]
8397 "TARGET_64BIT && ix86_match_ccmode (insn, CCNOmode)
8398 && ix86_binary_operator_ok (AND, DImode, operands)"
8399 "@
0f40f9f7
ZW
8400 and{l}\t{%k2, %k0|%k0, %k2}
8401 and{q}\t{%2, %0|%0, %2}
8402 and{q}\t{%2, %0|%0, %2}"
9b70259d
JH
8403 [(set_attr "type" "alu")
8404 (set_attr "mode" "SI,DI,DI")])
8405
e075ae69
RH
8406(define_expand "andsi3"
8407 [(set (match_operand:SI 0 "nonimmediate_operand" "")
8408 (and:SI (match_operand:SI 1 "nonimmediate_operand" "")
8409 (match_operand:SI 2 "general_operand" "")))
8410 (clobber (reg:CC 17))]
8411 ""
8412 "ix86_expand_binary_operator (AND, SImode, operands); DONE;")
8413
8414(define_insn "*andsi_1"
8415 [(set (match_operand:SI 0 "nonimmediate_operand" "=rm,r,r")
8416 (and:SI (match_operand:SI 1 "nonimmediate_operand" "%0,0,qm")
8417 (match_operand:SI 2 "general_operand" "ri,rm,L")))
8418 (clobber (reg:CC 17))]
8419 "ix86_binary_operator_ok (AND, SImode, operands)"
886c62d1 8420{
e075ae69 8421 switch (get_attr_type (insn))
886c62d1 8422 {
e075ae69
RH
8423 case TYPE_IMOVX:
8424 {
8425 enum machine_mode mode;
5bc7cd8e 8426
e075ae69
RH
8427 if (GET_CODE (operands[2]) != CONST_INT)
8428 abort ();
8429 if (INTVAL (operands[2]) == 0xff)
8430 mode = QImode;
8431 else if (INTVAL (operands[2]) == 0xffff)
8432 mode = HImode;
8433 else
8434 abort ();
8435
8436 operands[1] = gen_lowpart (mode, operands[1]);
8437 if (mode == QImode)
0f40f9f7 8438 return "movz{bl|x}\t{%1,%0|%0, %1}";
e075ae69 8439 else
0f40f9f7 8440 return "movz{wl|x}\t{%1,%0|%0, %1}";
e075ae69 8441 }
5bc7cd8e 8442
e075ae69
RH
8443 default:
8444 if (! rtx_equal_p (operands[0], operands[1]))
8445 abort ();
0f40f9f7 8446 return "and{l}\t{%2, %0|%0, %2}";
886c62d1 8447 }
0f40f9f7 8448}
6ef67412
JH
8449 [(set_attr "type" "alu,alu,imovx")
8450 (set_attr "length_immediate" "*,*,0")
8451 (set_attr "mode" "SI")])
8452
8453(define_split
05b432db 8454 [(set (match_operand 0 "register_operand" "")
9b70259d
JH
8455 (and (match_dup 0)
8456 (const_int -65536)))
6ef67412 8457 (clobber (reg:CC 17))]
285464d0 8458 "optimize_size || (TARGET_FAST_PREFIX && !TARGET_PARTIAL_REG_STALL)"
6ef67412
JH
8459 [(set (strict_low_part (match_dup 1)) (const_int 0))]
8460 "operands[1] = gen_lowpart (HImode, operands[0]);")
8461
8462(define_split
3522082b 8463 [(set (match_operand 0 "ext_register_operand" "")
5e1a2fc7 8464 (and (match_dup 0)
9b70259d 8465 (const_int -256)))
6ef67412 8466 (clobber (reg:CC 17))]
05b432db 8467 "(optimize_size || !TARGET_PARTIAL_REG_STALL) && reload_completed"
6ef67412
JH
8468 [(set (strict_low_part (match_dup 1)) (const_int 0))]
8469 "operands[1] = gen_lowpart (QImode, operands[0]);")
8470
8471(define_split
3522082b 8472 [(set (match_operand 0 "ext_register_operand" "")
6ef67412
JH
8473 (and (match_dup 0)
8474 (const_int -65281)))
8475 (clobber (reg:CC 17))]
05b432db 8476 "(optimize_size || !TARGET_PARTIAL_REG_STALL) && reload_completed"
6ef67412
JH
8477 [(parallel [(set (zero_extract:SI (match_dup 0)
8478 (const_int 8)
8479 (const_int 8))
8480 (xor:SI
8481 (zero_extract:SI (match_dup 0)
8482 (const_int 8)
8483 (const_int 8))
8484 (zero_extract:SI (match_dup 0)
8485 (const_int 8)
8486 (const_int 8))))
8487 (clobber (reg:CC 17))])]
8488 "operands[0] = gen_lowpart (SImode, operands[0]);")
e075ae69 8489
9b70259d
JH
8490;; See comment for addsi_1_zext why we do use nonimmediate_operand
8491(define_insn "*andsi_1_zext"
8492 [(set (match_operand:DI 0 "register_operand" "=r")
8493 (zero_extend:DI
8494 (and:SI (match_operand:SI 1 "nonimmediate_operand" "%0")
8495 (match_operand:SI 2 "general_operand" "rim"))))
8496 (clobber (reg:CC 17))]
8497 "TARGET_64BIT && ix86_binary_operator_ok (AND, SImode, operands)"
0f40f9f7 8498 "and{l}\t{%2, %k0|%k0, %2}"
9b70259d
JH
8499 [(set_attr "type" "alu")
8500 (set_attr "mode" "SI")])
8501
e075ae69 8502(define_insn "*andsi_2"
16189740
RH
8503 [(set (reg 17)
8504 (compare (and:SI (match_operand:SI 1 "nonimmediate_operand" "%0,0")
8505 (match_operand:SI 2 "general_operand" "rim,ri"))
8506 (const_int 0)))
e075ae69
RH
8507 (set (match_operand:SI 0 "nonimmediate_operand" "=r,rm")
8508 (and:SI (match_dup 1) (match_dup 2)))]
16189740
RH
8509 "ix86_match_ccmode (insn, CCNOmode)
8510 && ix86_binary_operator_ok (AND, SImode, operands)"
0f40f9f7 8511 "and{l}\t{%2, %0|%0, %2}"
6ef67412
JH
8512 [(set_attr "type" "alu")
8513 (set_attr "mode" "SI")])
e075ae69 8514
9b70259d
JH
8515;; See comment for addsi_1_zext why we do use nonimmediate_operand
8516(define_insn "*andsi_2_zext"
8517 [(set (reg 17)
8518 (compare (and:SI (match_operand:SI 1 "nonimmediate_operand" "%0")
8519 (match_operand:SI 2 "general_operand" "rim"))
8520 (const_int 0)))
8521 (set (match_operand:DI 0 "register_operand" "=r")
8522 (zero_extend:DI (and:SI (match_dup 1) (match_dup 2))))]
8523 "TARGET_64BIT && ix86_match_ccmode (insn, CCNOmode)
8524 && ix86_binary_operator_ok (AND, SImode, operands)"
0f40f9f7 8525 "and{l}\t{%2, %k0|%k0, %2}"
9b70259d
JH
8526 [(set_attr "type" "alu")
8527 (set_attr "mode" "SI")])
8528
e075ae69
RH
8529(define_expand "andhi3"
8530 [(set (match_operand:HI 0 "nonimmediate_operand" "")
8531 (and:HI (match_operand:HI 1 "nonimmediate_operand" "")
8532 (match_operand:HI 2 "general_operand" "")))
8533 (clobber (reg:CC 17))]
d9f32422 8534 "TARGET_HIMODE_MATH"
e075ae69
RH
8535 "ix86_expand_binary_operator (AND, HImode, operands); DONE;")
8536
8537(define_insn "*andhi_1"
8538 [(set (match_operand:HI 0 "nonimmediate_operand" "=rm,r,r")
8539 (and:HI (match_operand:HI 1 "nonimmediate_operand" "%0,0,qm")
8540 (match_operand:HI 2 "general_operand" "ri,rm,L")))
8541 (clobber (reg:CC 17))]
8542 "ix86_binary_operator_ok (AND, HImode, operands)"
886c62d1 8543{
e075ae69 8544 switch (get_attr_type (insn))
886c62d1 8545 {
e075ae69
RH
8546 case TYPE_IMOVX:
8547 if (GET_CODE (operands[2]) != CONST_INT)
8548 abort ();
8549 if (INTVAL (operands[2]) == 0xff)
0f40f9f7 8550 return "movz{bl|x}\t{%b1, %k0|%k0, %b1}";
e075ae69 8551 abort ();
886c62d1 8552
e075ae69
RH
8553 default:
8554 if (! rtx_equal_p (operands[0], operands[1]))
8555 abort ();
886c62d1 8556
0f40f9f7 8557 return "and{w}\t{%2, %0|%0, %2}";
5bc7cd8e 8558 }
0f40f9f7 8559}
6ef67412
JH
8560 [(set_attr "type" "alu,alu,imovx")
8561 (set_attr "length_immediate" "*,*,0")
8562 (set_attr "mode" "HI,HI,SI")])
5bc7cd8e 8563
e075ae69 8564(define_insn "*andhi_2"
16189740
RH
8565 [(set (reg 17)
8566 (compare (and:HI (match_operand:HI 1 "nonimmediate_operand" "%0,0")
8567 (match_operand:HI 2 "general_operand" "rim,ri"))
8568 (const_int 0)))
e075ae69
RH
8569 (set (match_operand:HI 0 "nonimmediate_operand" "=r,rm")
8570 (and:HI (match_dup 1) (match_dup 2)))]
16189740
RH
8571 "ix86_match_ccmode (insn, CCNOmode)
8572 && ix86_binary_operator_ok (AND, HImode, operands)"
0f40f9f7 8573 "and{w}\t{%2, %0|%0, %2}"
6ef67412
JH
8574 [(set_attr "type" "alu")
8575 (set_attr "mode" "HI")])
5bc7cd8e 8576
e075ae69
RH
8577(define_expand "andqi3"
8578 [(set (match_operand:QI 0 "nonimmediate_operand" "")
8579 (and:QI (match_operand:QI 1 "nonimmediate_operand" "")
8580 (match_operand:QI 2 "general_operand" "")))
8581 (clobber (reg:CC 17))]
d9f32422 8582 "TARGET_QIMODE_MATH"
e075ae69
RH
8583 "ix86_expand_binary_operator (AND, QImode, operands); DONE;")
8584
8585;; %%% Potential partial reg stall on alternative 2. What to do?
8586(define_insn "*andqi_1"
7c6b971d 8587 [(set (match_operand:QI 0 "nonimmediate_operand" "=qm,q,r")
e075ae69 8588 (and:QI (match_operand:QI 1 "nonimmediate_operand" "%0,0,0")
7c6b971d 8589 (match_operand:QI 2 "general_operand" "qi,qmi,ri")))
e075ae69
RH
8590 (clobber (reg:CC 17))]
8591 "ix86_binary_operator_ok (AND, QImode, operands)"
8592 "@
0f40f9f7
ZW
8593 and{b}\t{%2, %0|%0, %2}
8594 and{b}\t{%2, %0|%0, %2}
8595 and{l}\t{%k2, %k0|%k0, %k2}"
6ef67412
JH
8596 [(set_attr "type" "alu")
8597 (set_attr "mode" "QI,QI,SI")])
e075ae69 8598
a1b8572c
JH
8599(define_insn "*andqi_1_slp"
8600 [(set (strict_low_part (match_operand:QI 0 "nonimmediate_operand" "+qm,q"))
8601 (and:QI (match_dup 0)
8602 (match_operand:QI 1 "general_operand" "qi,qmi")))
8603 (clobber (reg:CC 17))]
1b245ade
JH
8604 "(! TARGET_PARTIAL_REG_STALL || optimize_size)
8605 && (GET_CODE (operands[0]) != MEM || GET_CODE (operands[1]) != MEM)"
0f40f9f7 8606 "and{b}\t{%1, %0|%0, %1}"
a1b8572c
JH
8607 [(set_attr "type" "alu1")
8608 (set_attr "mode" "QI")])
8609
e075ae69 8610(define_insn "*andqi_2"
16189740
RH
8611 [(set (reg 17)
8612 (compare (and:QI
8613 (match_operand:QI 1 "nonimmediate_operand" "%0,0,0")
8614 (match_operand:QI 2 "general_operand" "qim,qi,i"))
8615 (const_int 0)))
e075ae69
RH
8616 (set (match_operand:QI 0 "nonimmediate_operand" "=q,qm,*r")
8617 (and:QI (match_dup 1) (match_dup 2)))]
16189740
RH
8618 "ix86_match_ccmode (insn, CCNOmode)
8619 && ix86_binary_operator_ok (AND, QImode, operands)"
adc88131
JJ
8620{
8621 if (which_alternative == 2)
8622 {
8623 if (GET_CODE (operands[2]) == CONST_INT
8624 && (INTVAL (operands[2]) & 0xffffff00))
8625 operands[2] = GEN_INT (INTVAL (operands[2]) & 0xff);
0f40f9f7 8626 return "and{l}\t{%2, %k0|%k0, %2}";
adc88131 8627 }
0f40f9f7
ZW
8628 return "and{b}\t{%2, %0|%0, %2}";
8629}
6ef67412
JH
8630 [(set_attr "type" "alu")
8631 (set_attr "mode" "QI,QI,SI")])
e075ae69 8632
a1b8572c
JH
8633(define_insn "*andqi_2_slp"
8634 [(set (reg 17)
8635 (compare (and:QI
8636 (match_operand:QI 0 "nonimmediate_operand" "+q,qm")
8637 (match_operand:QI 1 "nonimmediate_operand" "qmi,qi"))
8638 (const_int 0)))
8639 (set (strict_low_part (match_dup 0))
8640 (and:QI (match_dup 0) (match_dup 1)))]
2f41793e 8641 "(! TARGET_PARTIAL_REG_STALL || optimize_size)
1b245ade
JH
8642 && ix86_match_ccmode (insn, CCNOmode)
8643 && (GET_CODE (operands[0]) != MEM || GET_CODE (operands[1]) != MEM)"
0f40f9f7 8644 "and{b}\t{%1, %0|%0, %1}"
a1b8572c
JH
8645 [(set_attr "type" "alu1")
8646 (set_attr "mode" "QI")])
8647
e075ae69
RH
8648;; ??? A bug in recog prevents it from recognizing a const_int as an
8649;; operand to zero_extend in andqi_ext_1. It was checking explicitly
8650;; for a QImode operand, which of course failed.
8651
8652(define_insn "andqi_ext_0"
d2836273 8653 [(set (zero_extract:SI (match_operand 0 "ext_register_operand" "=Q")
e075ae69
RH
8654 (const_int 8)
8655 (const_int 8))
8656 (and:SI
8657 (zero_extract:SI
8658 (match_operand 1 "ext_register_operand" "0")
8659 (const_int 8)
8660 (const_int 8))
8661 (match_operand 2 "const_int_operand" "n")))
8662 (clobber (reg:CC 17))]
2f41793e 8663 ""
0f40f9f7 8664 "and{b}\t{%2, %h0|%h0, %2}"
6ef67412
JH
8665 [(set_attr "type" "alu")
8666 (set_attr "length_immediate" "1")
8667 (set_attr "mode" "QI")])
e075ae69
RH
8668
8669;; Generated by peephole translating test to and. This shows up
8670;; often in fp comparisons.
8671
8672(define_insn "*andqi_ext_0_cc"
16189740
RH
8673 [(set (reg 17)
8674 (compare
e075ae69
RH
8675 (and:SI
8676 (zero_extract:SI
084e679a 8677 (match_operand 1 "ext_register_operand" "0")
3522082b 8678 (const_int 8)
e075ae69
RH
8679 (const_int 8))
8680 (match_operand 2 "const_int_operand" "n"))
8681 (const_int 0)))
d2836273 8682 (set (zero_extract:SI (match_operand 0 "ext_register_operand" "=Q")
e075ae69
RH
8683 (const_int 8)
8684 (const_int 8))
8685 (and:SI
8686 (zero_extract:SI
8687 (match_dup 1)
8688 (const_int 8)
8689 (const_int 8))
8690 (match_dup 2)))]
2f41793e 8691 "ix86_match_ccmode (insn, CCNOmode)"
0f40f9f7 8692 "and{b}\t{%2, %h0|%h0, %2}"
6ef67412
JH
8693 [(set_attr "type" "alu")
8694 (set_attr "length_immediate" "1")
8695 (set_attr "mode" "QI")])
e075ae69
RH
8696
8697(define_insn "*andqi_ext_1"
d2836273 8698 [(set (zero_extract:SI (match_operand 0 "ext_register_operand" "=Q")
e075ae69
RH
8699 (const_int 8)
8700 (const_int 8))
8701 (and:SI
8702 (zero_extract:SI
8703 (match_operand 1 "ext_register_operand" "0")
8704 (const_int 8)
8705 (const_int 8))
8706 (zero_extend:SI
d2836273 8707 (match_operand:QI 2 "general_operand" "Qm"))))
e075ae69 8708 (clobber (reg:CC 17))]
d2836273 8709 "!TARGET_64BIT"
0f40f9f7 8710 "and{b}\t{%2, %h0|%h0, %2}"
d2836273
JH
8711 [(set_attr "type" "alu")
8712 (set_attr "length_immediate" "0")
8713 (set_attr "mode" "QI")])
8714
8715(define_insn "*andqi_ext_1_rex64"
8716 [(set (zero_extract:SI (match_operand 0 "ext_register_operand" "=Q")
8717 (const_int 8)
8718 (const_int 8))
8719 (and:SI
8720 (zero_extract:SI
8721 (match_operand 1 "ext_register_operand" "0")
8722 (const_int 8)
8723 (const_int 8))
8724 (zero_extend:SI
3522082b 8725 (match_operand 2 "ext_register_operand" "Q"))))
d2836273
JH
8726 (clobber (reg:CC 17))]
8727 "TARGET_64BIT"
0f40f9f7 8728 "and{b}\t{%2, %h0|%h0, %2}"
6ef67412
JH
8729 [(set_attr "type" "alu")
8730 (set_attr "length_immediate" "0")
8731 (set_attr "mode" "QI")])
e075ae69
RH
8732
8733(define_insn "*andqi_ext_2"
d2836273 8734 [(set (zero_extract:SI (match_operand 0 "ext_register_operand" "=Q")
e075ae69
RH
8735 (const_int 8)
8736 (const_int 8))
8737 (and:SI
8738 (zero_extract:SI
8739 (match_operand 1 "ext_register_operand" "%0")
8740 (const_int 8)
8741 (const_int 8))
8742 (zero_extract:SI
d2836273 8743 (match_operand 2 "ext_register_operand" "Q")
e075ae69
RH
8744 (const_int 8)
8745 (const_int 8))))
8746 (clobber (reg:CC 17))]
8747 ""
0f40f9f7 8748 "and{b}\t{%h2, %h0|%h0, %h2}"
6ef67412
JH
8749 [(set_attr "type" "alu")
8750 (set_attr "length_immediate" "0")
8751 (set_attr "mode" "QI")])
2f41793e
JH
8752
8753;; Convert wide AND instructions with immediate operand to shorter QImode
8754;; equivalents when possible.
d1f87653 8755;; Don't do the splitting with memory operands, since it introduces risk
2f41793e
JH
8756;; of memory mismatch stalls. We may want to do the splitting for optimizing
8757;; for size, but that can (should?) be handled by generic code instead.
8758(define_split
8759 [(set (match_operand 0 "register_operand" "")
8760 (and (match_operand 1 "register_operand" "")
8761 (match_operand 2 "const_int_operand" "")))
8762 (clobber (reg:CC 17))]
8763 "reload_completed
8764 && QI_REG_P (operands[0])
8765 && (!TARGET_PARTIAL_REG_STALL || optimize_size)
8766 && !(~INTVAL (operands[2]) & ~(255 << 8))
8767 && GET_MODE (operands[0]) != QImode"
8768 [(parallel [(set (zero_extract:SI (match_dup 0) (const_int 8) (const_int 8))
8769 (and:SI (zero_extract:SI (match_dup 1)
8770 (const_int 8) (const_int 8))
8771 (match_dup 2)))
8772 (clobber (reg:CC 17))])]
8773 "operands[0] = gen_lowpart (SImode, operands[0]);
8774 operands[1] = gen_lowpart (SImode, operands[1]);
8775 operands[2] = gen_int_mode ((INTVAL (operands[2]) >> 8) & 0xff, SImode);")
8776
8777;; Since AND can be encoded with sign extended immediate, this is only
8778;; profitable when 7th bit is not set.
8779(define_split
8780 [(set (match_operand 0 "register_operand" "")
8781 (and (match_operand 1 "general_operand" "")
8782 (match_operand 2 "const_int_operand" "")))
8783 (clobber (reg:CC 17))]
8784 "reload_completed
8785 && ANY_QI_REG_P (operands[0])
8786 && (!TARGET_PARTIAL_REG_STALL || optimize_size)
8787 && !(~INTVAL (operands[2]) & ~255)
8788 && !(INTVAL (operands[2]) & 128)
8789 && GET_MODE (operands[0]) != QImode"
8790 [(parallel [(set (strict_low_part (match_dup 0))
8791 (and:QI (match_dup 1)
8792 (match_dup 2)))
8793 (clobber (reg:CC 17))])]
8794 "operands[0] = gen_lowpart (QImode, operands[0]);
8795 operands[1] = gen_lowpart (QImode, operands[1]);
8796 operands[2] = gen_lowpart (QImode, operands[2]);")
886c62d1 8797\f
e075ae69 8798;; Logical inclusive OR instructions
57dbca5e 8799
e075ae69
RH
8800;; %%% This used to optimize known byte-wide and operations to memory.
8801;; If this is considered useful, it should be done with splitters.
8802
9b70259d
JH
8803(define_expand "iordi3"
8804 [(set (match_operand:DI 0 "nonimmediate_operand" "")
8805 (ior:DI (match_operand:DI 1 "nonimmediate_operand" "")
8806 (match_operand:DI 2 "x86_64_general_operand" "")))
8807 (clobber (reg:CC 17))]
8808 "TARGET_64BIT"
8809 "ix86_expand_binary_operator (IOR, DImode, operands); DONE;")
8810
8811(define_insn "*iordi_1_rex64"
8812 [(set (match_operand:DI 0 "nonimmediate_operand" "=rm,r")
8813 (ior:DI (match_operand:DI 1 "nonimmediate_operand" "%0,0")
8814 (match_operand:DI 2 "x86_64_general_operand" "re,rme")))
8815 (clobber (reg:CC 17))]
8816 "TARGET_64BIT
8817 && ix86_binary_operator_ok (IOR, DImode, operands)"
0f40f9f7 8818 "or{q}\t{%2, %0|%0, %2}"
9b70259d
JH
8819 [(set_attr "type" "alu")
8820 (set_attr "mode" "DI")])
8821
8822(define_insn "*iordi_2_rex64"
8823 [(set (reg 17)
8824 (compare (ior:DI (match_operand:DI 1 "nonimmediate_operand" "%0,0")
8825 (match_operand:DI 2 "x86_64_general_operand" "rem,re"))
8826 (const_int 0)))
8827 (set (match_operand:DI 0 "nonimmediate_operand" "=r,rm")
8828 (ior:DI (match_dup 1) (match_dup 2)))]
8829 "TARGET_64BIT
8830 && ix86_match_ccmode (insn, CCNOmode)
8831 && ix86_binary_operator_ok (IOR, DImode, operands)"
0f40f9f7 8832 "or{q}\t{%2, %0|%0, %2}"
9b70259d
JH
8833 [(set_attr "type" "alu")
8834 (set_attr "mode" "DI")])
8835
8836(define_insn "*iordi_3_rex64"
8837 [(set (reg 17)
8838 (compare (ior:DI (match_operand:DI 1 "nonimmediate_operand" "%0")
8839 (match_operand:DI 2 "x86_64_general_operand" "rem"))
8840 (const_int 0)))
8841 (clobber (match_scratch:DI 0 "=r"))]
8842 "TARGET_64BIT
8843 && ix86_match_ccmode (insn, CCNOmode)
8844 && ix86_binary_operator_ok (IOR, DImode, operands)"
0f40f9f7 8845 "or{q}\t{%2, %0|%0, %2}"
9b70259d
JH
8846 [(set_attr "type" "alu")
8847 (set_attr "mode" "DI")])
8848
8849
e075ae69
RH
8850(define_expand "iorsi3"
8851 [(set (match_operand:SI 0 "nonimmediate_operand" "")
8852 (ior:SI (match_operand:SI 1 "nonimmediate_operand" "")
8853 (match_operand:SI 2 "general_operand" "")))
8854 (clobber (reg:CC 17))]
57dbca5e 8855 ""
e075ae69
RH
8856 "ix86_expand_binary_operator (IOR, SImode, operands); DONE;")
8857
8858(define_insn "*iorsi_1"
8859 [(set (match_operand:SI 0 "nonimmediate_operand" "=rm,r")
8860 (ior:SI (match_operand:SI 1 "nonimmediate_operand" "%0,0")
8861 (match_operand:SI 2 "general_operand" "ri,rmi")))
8862 (clobber (reg:CC 17))]
8863 "ix86_binary_operator_ok (IOR, SImode, operands)"
0f40f9f7 8864 "or{l}\t{%2, %0|%0, %2}"
6ef67412
JH
8865 [(set_attr "type" "alu")
8866 (set_attr "mode" "SI")])
e075ae69 8867
9b70259d
JH
8868;; See comment for addsi_1_zext why we do use nonimmediate_operand
8869(define_insn "*iorsi_1_zext"
8870 [(set (match_operand:DI 0 "register_operand" "=rm")
8871 (zero_extend:DI
8872 (ior:SI (match_operand:SI 1 "nonimmediate_operand" "%0")
8873 (match_operand:SI 2 "general_operand" "rim"))))
8874 (clobber (reg:CC 17))]
8875 "TARGET_64BIT && ix86_binary_operator_ok (IOR, SImode, operands)"
0f40f9f7 8876 "or{l}\t{%2, %k0|%k0, %2}"
9b70259d
JH
8877 [(set_attr "type" "alu")
8878 (set_attr "mode" "SI")])
8879
8880(define_insn "*iorsi_1_zext_imm"
8881 [(set (match_operand:DI 0 "register_operand" "=rm")
8882 (ior:DI (zero_extend:DI (match_operand:SI 1 "register_operand" "%0"))
8883 (match_operand:DI 2 "x86_64_zext_immediate_operand" "Z")))
8884 (clobber (reg:CC 17))]
8885 "TARGET_64BIT"
0f40f9f7 8886 "or{l}\t{%2, %k0|%k0, %2}"
9b70259d
JH
8887 [(set_attr "type" "alu")
8888 (set_attr "mode" "SI")])
8889
e075ae69 8890(define_insn "*iorsi_2"
16189740
RH
8891 [(set (reg 17)
8892 (compare (ior:SI (match_operand:SI 1 "nonimmediate_operand" "%0,0")
8893 (match_operand:SI 2 "general_operand" "rim,ri"))
8894 (const_int 0)))
e075ae69
RH
8895 (set (match_operand:SI 0 "nonimmediate_operand" "=r,rm")
8896 (ior:SI (match_dup 1) (match_dup 2)))]
16189740
RH
8897 "ix86_match_ccmode (insn, CCNOmode)
8898 && ix86_binary_operator_ok (IOR, SImode, operands)"
0f40f9f7 8899 "or{l}\t{%2, %0|%0, %2}"
6ef67412
JH
8900 [(set_attr "type" "alu")
8901 (set_attr "mode" "SI")])
e075ae69 8902
9b70259d
JH
8903;; See comment for addsi_1_zext why we do use nonimmediate_operand
8904;; ??? Special case for immediate operand is missing - it is tricky.
8905(define_insn "*iorsi_2_zext"
8906 [(set (reg 17)
8907 (compare (ior:SI (match_operand:SI 1 "nonimmediate_operand" "%0")
8908 (match_operand:SI 2 "general_operand" "rim"))
8909 (const_int 0)))
8910 (set (match_operand:DI 0 "register_operand" "=r")
8911 (zero_extend:DI (ior:SI (match_dup 1) (match_dup 2))))]
8912 "TARGET_64BIT && ix86_match_ccmode (insn, CCNOmode)
8913 && ix86_binary_operator_ok (IOR, SImode, operands)"
0f40f9f7 8914 "or{l}\t{%2, %k0|%k0, %2}"
9b70259d
JH
8915 [(set_attr "type" "alu")
8916 (set_attr "mode" "SI")])
8917
8918(define_insn "*iorsi_2_zext_imm"
8919 [(set (reg 17)
8920 (compare (ior:SI (match_operand:SI 1 "nonimmediate_operand" "%0")
8921 (match_operand 2 "x86_64_zext_immediate_operand" "Z"))
8922 (const_int 0)))
8923 (set (match_operand:DI 0 "register_operand" "=r")
8924 (ior:DI (zero_extend:DI (match_dup 1)) (match_dup 2)))]
8925 "TARGET_64BIT && ix86_match_ccmode (insn, CCNOmode)
8926 && ix86_binary_operator_ok (IOR, SImode, operands)"
0f40f9f7 8927 "or{l}\t{%2, %k0|%k0, %2}"
9b70259d
JH
8928 [(set_attr "type" "alu")
8929 (set_attr "mode" "SI")])
8930
d90ffc8d
JH
8931(define_insn "*iorsi_3"
8932 [(set (reg 17)
8933 (compare (ior:SI (match_operand:SI 1 "nonimmediate_operand" "%0")
8934 (match_operand:SI 2 "general_operand" "rim"))
8935 (const_int 0)))
8936 (clobber (match_scratch:SI 0 "=r"))]
8937 "ix86_match_ccmode (insn, CCNOmode)
8938 && (GET_CODE (operands[1]) != MEM || GET_CODE (operands[2]) != MEM)"
0f40f9f7 8939 "or{l}\t{%2, %0|%0, %2}"
d90ffc8d
JH
8940 [(set_attr "type" "alu")
8941 (set_attr "mode" "SI")])
8942
e075ae69
RH
8943(define_expand "iorhi3"
8944 [(set (match_operand:HI 0 "nonimmediate_operand" "")
8945 (ior:HI (match_operand:HI 1 "nonimmediate_operand" "")
8946 (match_operand:HI 2 "general_operand" "")))
8947 (clobber (reg:CC 17))]
d9f32422 8948 "TARGET_HIMODE_MATH"
e075ae69
RH
8949 "ix86_expand_binary_operator (IOR, HImode, operands); DONE;")
8950
8951(define_insn "*iorhi_1"
8952 [(set (match_operand:HI 0 "nonimmediate_operand" "=r,m")
8953 (ior:HI (match_operand:HI 1 "nonimmediate_operand" "%0,0")
8954 (match_operand:HI 2 "general_operand" "rmi,ri")))
8955 (clobber (reg:CC 17))]
8956 "ix86_binary_operator_ok (IOR, HImode, operands)"
0f40f9f7 8957 "or{w}\t{%2, %0|%0, %2}"
6ef67412
JH
8958 [(set_attr "type" "alu")
8959 (set_attr "mode" "HI")])
e075ae69 8960
e075ae69 8961(define_insn "*iorhi_2"
16189740
RH
8962 [(set (reg 17)
8963 (compare (ior:HI (match_operand:HI 1 "nonimmediate_operand" "%0,0")
8964 (match_operand:HI 2 "general_operand" "rim,ri"))
8965 (const_int 0)))
e075ae69
RH
8966 (set (match_operand:HI 0 "nonimmediate_operand" "=r,rm")
8967 (ior:HI (match_dup 1) (match_dup 2)))]
16189740
RH
8968 "ix86_match_ccmode (insn, CCNOmode)
8969 && ix86_binary_operator_ok (IOR, HImode, operands)"
0f40f9f7 8970 "or{w}\t{%2, %0|%0, %2}"
6ef67412
JH
8971 [(set_attr "type" "alu")
8972 (set_attr "mode" "HI")])
e075ae69 8973
d90ffc8d
JH
8974(define_insn "*iorhi_3"
8975 [(set (reg 17)
8976 (compare (ior:HI (match_operand:HI 1 "nonimmediate_operand" "%0")
8977 (match_operand:HI 2 "general_operand" "rim"))
8978 (const_int 0)))
8979 (clobber (match_scratch:HI 0 "=r"))]
8980 "ix86_match_ccmode (insn, CCNOmode)
8981 && (GET_CODE (operands[1]) != MEM || GET_CODE (operands[2]) != MEM)"
0f40f9f7 8982 "or{w}\t{%2, %0|%0, %2}"
d90ffc8d
JH
8983 [(set_attr "type" "alu")
8984 (set_attr "mode" "HI")])
8985
e075ae69
RH
8986(define_expand "iorqi3"
8987 [(set (match_operand:QI 0 "nonimmediate_operand" "")
8988 (ior:QI (match_operand:QI 1 "nonimmediate_operand" "")
8989 (match_operand:QI 2 "general_operand" "")))
8990 (clobber (reg:CC 17))]
d9f32422 8991 "TARGET_QIMODE_MATH"
e075ae69
RH
8992 "ix86_expand_binary_operator (IOR, QImode, operands); DONE;")
8993
8994;; %%% Potential partial reg stall on alternative 2. What to do?
8995(define_insn "*iorqi_1"
7c6b971d 8996 [(set (match_operand:QI 0 "nonimmediate_operand" "=q,m,r")
e075ae69 8997 (ior:QI (match_operand:QI 1 "nonimmediate_operand" "%0,0,0")
7c6b971d 8998 (match_operand:QI 2 "general_operand" "qmi,qi,ri")))
e075ae69
RH
8999 (clobber (reg:CC 17))]
9000 "ix86_binary_operator_ok (IOR, QImode, operands)"
9001 "@
0f40f9f7
ZW
9002 or{b}\t{%2, %0|%0, %2}
9003 or{b}\t{%2, %0|%0, %2}
9004 or{l}\t{%k2, %k0|%k0, %k2}"
6ef67412 9005 [(set_attr "type" "alu")
a1b8572c
JH
9006 (set_attr "mode" "QI,QI,SI")])
9007
9008(define_insn "*iorqi_1_slp"
9009 [(set (strict_low_part (match_operand:QI 0 "nonimmediate_operand" "+q,m"))
9010 (ior:QI (match_dup 0)
9011 (match_operand:QI 1 "general_operand" "qmi,qi")))
9012 (clobber (reg:CC 17))]
1b245ade
JH
9013 "(! TARGET_PARTIAL_REG_STALL || optimize_size)
9014 && (GET_CODE (operands[0]) != MEM || GET_CODE (operands[1]) != MEM)"
0f40f9f7 9015 "or{b}\t{%1, %0|%0, %1}"
a1b8572c 9016 [(set_attr "type" "alu1")
6ef67412 9017 (set_attr "mode" "QI")])
e075ae69
RH
9018
9019(define_insn "*iorqi_2"
16189740
RH
9020 [(set (reg 17)
9021 (compare (ior:QI (match_operand:QI 1 "nonimmediate_operand" "%0,0")
9022 (match_operand:QI 2 "general_operand" "qim,qi"))
9023 (const_int 0)))
e075ae69
RH
9024 (set (match_operand:QI 0 "nonimmediate_operand" "=q,qm")
9025 (ior:QI (match_dup 1) (match_dup 2)))]
16189740
RH
9026 "ix86_match_ccmode (insn, CCNOmode)
9027 && ix86_binary_operator_ok (IOR, QImode, operands)"
0f40f9f7 9028 "or{b}\t{%2, %0|%0, %2}"
6ef67412
JH
9029 [(set_attr "type" "alu")
9030 (set_attr "mode" "QI")])
d90ffc8d 9031
a1b8572c
JH
9032(define_insn "*iorqi_2_slp"
9033 [(set (reg 17)
9034 (compare (ior:QI (match_operand:QI 0 "nonimmediate_operand" "+q,qm")
9035 (match_operand:QI 1 "general_operand" "qim,qi"))
9036 (const_int 0)))
9037 (set (strict_low_part (match_dup 0))
9038 (ior:QI (match_dup 0) (match_dup 1)))]
2f41793e 9039 "(! TARGET_PARTIAL_REG_STALL || optimize_size)
1b245ade
JH
9040 && ix86_match_ccmode (insn, CCNOmode)
9041 && (GET_CODE (operands[0]) != MEM || GET_CODE (operands[1]) != MEM)"
0f40f9f7 9042 "or{b}\t{%1, %0|%0, %1}"
a1b8572c
JH
9043 [(set_attr "type" "alu1")
9044 (set_attr "mode" "QI")])
9045
d90ffc8d
JH
9046(define_insn "*iorqi_3"
9047 [(set (reg 17)
9048 (compare (ior:QI (match_operand:QI 1 "nonimmediate_operand" "%0")
9049 (match_operand:QI 2 "general_operand" "qim"))
9050 (const_int 0)))
7e08e190 9051 (clobber (match_scratch:QI 0 "=q"))]
d90ffc8d
JH
9052 "ix86_match_ccmode (insn, CCNOmode)
9053 && (GET_CODE (operands[1]) != MEM || GET_CODE (operands[2]) != MEM)"
0f40f9f7 9054 "or{b}\t{%2, %0|%0, %2}"
d90ffc8d
JH
9055 [(set_attr "type" "alu")
9056 (set_attr "mode" "QI")])
9057
2f41793e
JH
9058(define_insn "iorqi_ext_0"
9059 [(set (zero_extract:SI (match_operand 0 "ext_register_operand" "=Q")
9060 (const_int 8)
9061 (const_int 8))
9062 (ior:SI
9063 (zero_extract:SI
9064 (match_operand 1 "ext_register_operand" "0")
9065 (const_int 8)
9066 (const_int 8))
9067 (match_operand 2 "const_int_operand" "n")))
9068 (clobber (reg:CC 17))]
9069 "(!TARGET_PARTIAL_REG_STALL || optimize_size)"
9070 "or{b}\t{%2, %h0|%h0, %2}"
9071 [(set_attr "type" "alu")
9072 (set_attr "length_immediate" "1")
9073 (set_attr "mode" "QI")])
9074
9075(define_insn "*iorqi_ext_1"
9076 [(set (zero_extract:SI (match_operand 0 "ext_register_operand" "=Q")
9077 (const_int 8)
9078 (const_int 8))
9079 (ior:SI
9080 (zero_extract:SI
9081 (match_operand 1 "ext_register_operand" "0")
9082 (const_int 8)
9083 (const_int 8))
9084 (zero_extend:SI
9085 (match_operand:QI 2 "general_operand" "Qm"))))
9086 (clobber (reg:CC 17))]
9087 "!TARGET_64BIT
9088 && (!TARGET_PARTIAL_REG_STALL || optimize_size)"
9089 "or{b}\t{%2, %h0|%h0, %2}"
9090 [(set_attr "type" "alu")
9091 (set_attr "length_immediate" "0")
9092 (set_attr "mode" "QI")])
9093
9094(define_insn "*iorqi_ext_1_rex64"
9095 [(set (zero_extract:SI (match_operand 0 "ext_register_operand" "=Q")
9096 (const_int 8)
9097 (const_int 8))
9098 (ior:SI
9099 (zero_extract:SI
9100 (match_operand 1 "ext_register_operand" "0")
9101 (const_int 8)
9102 (const_int 8))
9103 (zero_extend:SI
9104 (match_operand 2 "ext_register_operand" "Q"))))
9105 (clobber (reg:CC 17))]
9106 "TARGET_64BIT
9107 && (!TARGET_PARTIAL_REG_STALL || optimize_size)"
9108 "or{b}\t{%2, %h0|%h0, %2}"
9109 [(set_attr "type" "alu")
9110 (set_attr "length_immediate" "0")
9111 (set_attr "mode" "QI")])
9112
9113(define_insn "*iorqi_ext_2"
9114 [(set (zero_extract:SI (match_operand 0 "ext_register_operand" "=Q")
9115 (const_int 8)
9116 (const_int 8))
9117 (ior:SI
9118 (zero_extract:SI (match_operand 1 "ext_register_operand" "0")
9119 (const_int 8)
9120 (const_int 8))
9121 (zero_extract:SI (match_operand 2 "ext_register_operand" "Q")
9122 (const_int 8)
9123 (const_int 8))))
9124 (clobber (reg:CC 17))]
9125 "(!TARGET_PARTIAL_REG_STALL || optimize_size)"
9126 "ior{b}\t{%h2, %h0|%h0, %h2}"
9127 [(set_attr "type" "alu")
9128 (set_attr "length_immediate" "0")
9129 (set_attr "mode" "QI")])
9130
9131(define_split
9132 [(set (match_operand 0 "register_operand" "")
9133 (ior (match_operand 1 "register_operand" "")
9134 (match_operand 2 "const_int_operand" "")))
9135 (clobber (reg:CC 17))]
9136 "reload_completed
9137 && QI_REG_P (operands[0])
9138 && (!TARGET_PARTIAL_REG_STALL || optimize_size)
9139 && !(INTVAL (operands[2]) & ~(255 << 8))
9140 && GET_MODE (operands[0]) != QImode"
9141 [(parallel [(set (zero_extract:SI (match_dup 0) (const_int 8) (const_int 8))
9142 (ior:SI (zero_extract:SI (match_dup 1)
9143 (const_int 8) (const_int 8))
9144 (match_dup 2)))
9145 (clobber (reg:CC 17))])]
9146 "operands[0] = gen_lowpart (SImode, operands[0]);
9147 operands[1] = gen_lowpart (SImode, operands[1]);
9148 operands[2] = gen_int_mode ((INTVAL (operands[2]) >> 8) & 0xff, SImode);")
9149
9150;; Since OR can be encoded with sign extended immediate, this is only
9151;; profitable when 7th bit is set.
9152(define_split
9153 [(set (match_operand 0 "register_operand" "")
9154 (ior (match_operand 1 "general_operand" "")
9155 (match_operand 2 "const_int_operand" "")))
9156 (clobber (reg:CC 17))]
9157 "reload_completed
9158 && ANY_QI_REG_P (operands[0])
9159 && (!TARGET_PARTIAL_REG_STALL || optimize_size)
9160 && !(INTVAL (operands[2]) & ~255)
9161 && (INTVAL (operands[2]) & 128)
9162 && GET_MODE (operands[0]) != QImode"
9163 [(parallel [(set (strict_low_part (match_dup 0))
9164 (ior:QI (match_dup 1)
9165 (match_dup 2)))
9166 (clobber (reg:CC 17))])]
9167 "operands[0] = gen_lowpart (QImode, operands[0]);
9168 operands[1] = gen_lowpart (QImode, operands[1]);
9169 operands[2] = gen_lowpart (QImode, operands[2]);")
e075ae69
RH
9170\f
9171;; Logical XOR instructions
a269a03c 9172
e075ae69
RH
9173;; %%% This used to optimize known byte-wide and operations to memory.
9174;; If this is considered useful, it should be done with splitters.
57dbca5e 9175
9b70259d
JH
9176(define_expand "xordi3"
9177 [(set (match_operand:DI 0 "nonimmediate_operand" "")
9178 (xor:DI (match_operand:DI 1 "nonimmediate_operand" "")
9179 (match_operand:DI 2 "x86_64_general_operand" "")))
9180 (clobber (reg:CC 17))]
9181 "TARGET_64BIT"
9182 "ix86_expand_binary_operator (XOR, DImode, operands); DONE;")
9183
9184(define_insn "*xordi_1_rex64"
9185 [(set (match_operand:DI 0 "nonimmediate_operand" "=rm,r")
9186 (xor:DI (match_operand:DI 1 "nonimmediate_operand" "%0,0")
9187 (match_operand:DI 2 "x86_64_general_operand" "re,rm")))
9188 (clobber (reg:CC 17))]
9189 "TARGET_64BIT
9190 && ix86_binary_operator_ok (XOR, DImode, operands)"
9191 "@
0f40f9f7
ZW
9192 xor{q}\t{%2, %0|%0, %2}
9193 xor{q}\t{%2, %0|%0, %2}"
9b70259d
JH
9194 [(set_attr "type" "alu")
9195 (set_attr "mode" "DI,DI")])
9196
9197(define_insn "*xordi_2_rex64"
9198 [(set (reg 17)
9199 (compare (xor:DI (match_operand:DI 1 "nonimmediate_operand" "%0,0")
9200 (match_operand:DI 2 "x86_64_general_operand" "rem,re"))
9201 (const_int 0)))
9202 (set (match_operand:DI 0 "nonimmediate_operand" "=r,rm")
9203 (xor:DI (match_dup 1) (match_dup 2)))]
9204 "TARGET_64BIT
9205 && ix86_match_ccmode (insn, CCNOmode)
9206 && ix86_binary_operator_ok (XOR, DImode, operands)"
9207 "@
0f40f9f7
ZW
9208 xor{q}\t{%2, %0|%0, %2}
9209 xor{q}\t{%2, %0|%0, %2}"
9b70259d
JH
9210 [(set_attr "type" "alu")
9211 (set_attr "mode" "DI,DI")])
9212
9213(define_insn "*xordi_3_rex64"
9214 [(set (reg 17)
9215 (compare (xor:DI (match_operand:DI 1 "nonimmediate_operand" "%0")
9216 (match_operand:DI 2 "x86_64_general_operand" "rem"))
9217 (const_int 0)))
9218 (clobber (match_scratch:DI 0 "=r"))]
9219 "TARGET_64BIT
9220 && ix86_match_ccmode (insn, CCNOmode)
9221 && ix86_binary_operator_ok (XOR, DImode, operands)"
0f40f9f7 9222 "xor{q}\t{%2, %0|%0, %2}"
9b70259d
JH
9223 [(set_attr "type" "alu")
9224 (set_attr "mode" "DI")])
9225
e075ae69
RH
9226(define_expand "xorsi3"
9227 [(set (match_operand:SI 0 "nonimmediate_operand" "")
9228 (xor:SI (match_operand:SI 1 "nonimmediate_operand" "")
9229 (match_operand:SI 2 "general_operand" "")))
9230 (clobber (reg:CC 17))]
57dbca5e 9231 ""
e075ae69 9232 "ix86_expand_binary_operator (XOR, SImode, operands); DONE;")
a269a03c 9233
e075ae69
RH
9234(define_insn "*xorsi_1"
9235 [(set (match_operand:SI 0 "nonimmediate_operand" "=rm,r")
9236 (xor:SI (match_operand:SI 1 "nonimmediate_operand" "%0,0")
9237 (match_operand:SI 2 "general_operand" "ri,rm")))
9238 (clobber (reg:CC 17))]
9239 "ix86_binary_operator_ok (XOR, SImode, operands)"
0f40f9f7 9240 "xor{l}\t{%2, %0|%0, %2}"
6ef67412
JH
9241 [(set_attr "type" "alu")
9242 (set_attr "mode" "SI")])
e075ae69 9243
9b70259d
JH
9244;; See comment for addsi_1_zext why we do use nonimmediate_operand
9245;; Add speccase for immediates
9246(define_insn "*xorsi_1_zext"
9247 [(set (match_operand:DI 0 "register_operand" "=r")
9248 (zero_extend:DI
9249 (xor:SI (match_operand:SI 1 "nonimmediate_operand" "%0")
9250 (match_operand:SI 2 "general_operand" "rim"))))
9251 (clobber (reg:CC 17))]
9252 "TARGET_64BIT && ix86_binary_operator_ok (XOR, SImode, operands)"
0f40f9f7 9253 "xor{l}\t{%2, %k0|%k0, %2}"
9b70259d
JH
9254 [(set_attr "type" "alu")
9255 (set_attr "mode" "SI")])
9256
9257(define_insn "*xorsi_1_zext_imm"
9258 [(set (match_operand:DI 0 "register_operand" "=r")
9259 (xor:DI (zero_extend:DI (match_operand:SI 1 "register_operand" "%0"))
9260 (match_operand:DI 2 "x86_64_zext_immediate_operand" "Z")))
9261 (clobber (reg:CC 17))]
9262 "TARGET_64BIT && ix86_binary_operator_ok (XOR, SImode, operands)"
0f40f9f7 9263 "xor{l}\t{%2, %k0|%k0, %2}"
9b70259d
JH
9264 [(set_attr "type" "alu")
9265 (set_attr "mode" "SI")])
9266
e075ae69 9267(define_insn "*xorsi_2"
16189740
RH
9268 [(set (reg 17)
9269 (compare (xor:SI (match_operand:SI 1 "nonimmediate_operand" "%0,0")
9270 (match_operand:SI 2 "general_operand" "rim,ri"))
9271 (const_int 0)))
e075ae69
RH
9272 (set (match_operand:SI 0 "nonimmediate_operand" "=r,rm")
9273 (xor:SI (match_dup 1) (match_dup 2)))]
16189740
RH
9274 "ix86_match_ccmode (insn, CCNOmode)
9275 && ix86_binary_operator_ok (XOR, SImode, operands)"
0f40f9f7 9276 "xor{l}\t{%2, %0|%0, %2}"
6ef67412
JH
9277 [(set_attr "type" "alu")
9278 (set_attr "mode" "SI")])
e075ae69 9279
9b70259d
JH
9280;; See comment for addsi_1_zext why we do use nonimmediate_operand
9281;; ??? Special case for immediate operand is missing - it is tricky.
9282(define_insn "*xorsi_2_zext"
9283 [(set (reg 17)
9284 (compare (xor:SI (match_operand:SI 1 "nonimmediate_operand" "%0")
9285 (match_operand:SI 2 "general_operand" "rim"))
9286 (const_int 0)))
9287 (set (match_operand:DI 0 "register_operand" "=r")
9288 (zero_extend:DI (xor:SI (match_dup 1) (match_dup 2))))]
9289 "TARGET_64BIT && ix86_match_ccmode (insn, CCNOmode)
9290 && ix86_binary_operator_ok (XOR, SImode, operands)"
0f40f9f7 9291 "xor{l}\t{%2, %k0|%k0, %2}"
9b70259d
JH
9292 [(set_attr "type" "alu")
9293 (set_attr "mode" "SI")])
9294
9295(define_insn "*xorsi_2_zext_imm"
9296 [(set (reg 17)
9297 (compare (xor:SI (match_operand:SI 1 "nonimmediate_operand" "%0")
9298 (match_operand 2 "x86_64_zext_immediate_operand" "Z"))
9299 (const_int 0)))
9300 (set (match_operand:DI 0 "register_operand" "=r")
9301 (xor:DI (zero_extend:DI (match_dup 1)) (match_dup 2)))]
9302 "TARGET_64BIT && ix86_match_ccmode (insn, CCNOmode)
9303 && ix86_binary_operator_ok (XOR, SImode, operands)"
0f40f9f7 9304 "xor{l}\t{%2, %k0|%k0, %2}"
9b70259d
JH
9305 [(set_attr "type" "alu")
9306 (set_attr "mode" "SI")])
9307
d90ffc8d
JH
9308(define_insn "*xorsi_3"
9309 [(set (reg 17)
9310 (compare (xor:SI (match_operand:SI 1 "nonimmediate_operand" "%0")
9311 (match_operand:SI 2 "general_operand" "rim"))
9312 (const_int 0)))
9313 (clobber (match_scratch:SI 0 "=r"))]
9314 "ix86_match_ccmode (insn, CCNOmode)
9315 && (GET_CODE (operands[1]) != MEM || GET_CODE (operands[2]) != MEM)"
0f40f9f7 9316 "xor{l}\t{%2, %0|%0, %2}"
d90ffc8d
JH
9317 [(set_attr "type" "alu")
9318 (set_attr "mode" "SI")])
9319
e075ae69
RH
9320(define_expand "xorhi3"
9321 [(set (match_operand:HI 0 "nonimmediate_operand" "")
9322 (xor:HI (match_operand:HI 1 "nonimmediate_operand" "")
9323 (match_operand:HI 2 "general_operand" "")))
9324 (clobber (reg:CC 17))]
d9f32422 9325 "TARGET_HIMODE_MATH"
e075ae69
RH
9326 "ix86_expand_binary_operator (XOR, HImode, operands); DONE;")
9327
9328(define_insn "*xorhi_1"
9329 [(set (match_operand:HI 0 "nonimmediate_operand" "=r,m")
9330 (xor:HI (match_operand:HI 1 "nonimmediate_operand" "%0,0")
9331 (match_operand:HI 2 "general_operand" "rmi,ri")))
9332 (clobber (reg:CC 17))]
9333 "ix86_binary_operator_ok (XOR, HImode, operands)"
0f40f9f7 9334 "xor{w}\t{%2, %0|%0, %2}"
6ef67412
JH
9335 [(set_attr "type" "alu")
9336 (set_attr "mode" "HI")])
57dbca5e 9337
e075ae69 9338(define_insn "*xorhi_2"
16189740
RH
9339 [(set (reg 17)
9340 (compare (xor:HI (match_operand:HI 1 "nonimmediate_operand" "%0,0")
9341 (match_operand:HI 2 "general_operand" "rim,ri"))
9342 (const_int 0)))
e075ae69
RH
9343 (set (match_operand:HI 0 "nonimmediate_operand" "=r,rm")
9344 (xor:HI (match_dup 1) (match_dup 2)))]
16189740
RH
9345 "ix86_match_ccmode (insn, CCNOmode)
9346 && ix86_binary_operator_ok (XOR, HImode, operands)"
0f40f9f7 9347 "xor{w}\t{%2, %0|%0, %2}"
6ef67412
JH
9348 [(set_attr "type" "alu")
9349 (set_attr "mode" "HI")])
e075ae69 9350
d90ffc8d
JH
9351(define_insn "*xorhi_3"
9352 [(set (reg 17)
9353 (compare (xor:HI (match_operand:HI 1 "nonimmediate_operand" "%0")
9354 (match_operand:HI 2 "general_operand" "rim"))
9355 (const_int 0)))
9356 (clobber (match_scratch:HI 0 "=r"))]
9357 "ix86_match_ccmode (insn, CCNOmode)
9358 && (GET_CODE (operands[1]) != MEM || GET_CODE (operands[2]) != MEM)"
0f40f9f7 9359 "xor{w}\t{%2, %0|%0, %2}"
d90ffc8d
JH
9360 [(set_attr "type" "alu")
9361 (set_attr "mode" "HI")])
9362
e075ae69
RH
9363(define_expand "xorqi3"
9364 [(set (match_operand:QI 0 "nonimmediate_operand" "")
9365 (xor:QI (match_operand:QI 1 "nonimmediate_operand" "")
9366 (match_operand:QI 2 "general_operand" "")))
9367 (clobber (reg:CC 17))]
d9f32422 9368 "TARGET_QIMODE_MATH"
e075ae69
RH
9369 "ix86_expand_binary_operator (XOR, QImode, operands); DONE;")
9370
9371;; %%% Potential partial reg stall on alternative 2. What to do?
9372(define_insn "*xorqi_1"
7c6b971d 9373 [(set (match_operand:QI 0 "nonimmediate_operand" "=q,m,r")
e075ae69 9374 (xor:QI (match_operand:QI 1 "nonimmediate_operand" "%0,0,0")
7c6b971d 9375 (match_operand:QI 2 "general_operand" "qmi,qi,ri")))
e075ae69
RH
9376 (clobber (reg:CC 17))]
9377 "ix86_binary_operator_ok (XOR, QImode, operands)"
9378 "@
0f40f9f7
ZW
9379 xor{b}\t{%2, %0|%0, %2}
9380 xor{b}\t{%2, %0|%0, %2}
9381 xor{l}\t{%k2, %k0|%k0, %k2}"
6ef67412
JH
9382 [(set_attr "type" "alu")
9383 (set_attr "mode" "QI,QI,SI")])
9384
b6bb1d56
JH
9385(define_insn "*xorqi_1_slp"
9386 [(set (strict_low_part (match_operand:QI 0 "nonimmediate_operand" "+qm,q"))
9387 (xor:QI (match_dup 0)
9388 (match_operand:QI 1 "general_operand" "qi,qmi")))
9389 (clobber (reg:CC 17))]
1b245ade
JH
9390 "(! TARGET_PARTIAL_REG_STALL || optimize_size)
9391 && (GET_CODE (operands[0]) != MEM || GET_CODE (operands[1]) != MEM)"
b6bb1d56
JH
9392 "xor{b}\t{%1, %0|%0, %1}"
9393 [(set_attr "type" "alu1")
9394 (set_attr "mode" "QI")])
9395
2f41793e
JH
9396(define_insn "xorqi_ext_0"
9397 [(set (zero_extract:SI (match_operand 0 "ext_register_operand" "=Q")
9398 (const_int 8)
9399 (const_int 8))
9400 (xor:SI
9401 (zero_extract:SI
9402 (match_operand 1 "ext_register_operand" "0")
9403 (const_int 8)
9404 (const_int 8))
9405 (match_operand 2 "const_int_operand" "n")))
9406 (clobber (reg:CC 17))]
9407 "(!TARGET_PARTIAL_REG_STALL || optimize_size)"
9408 "xor{b}\t{%2, %h0|%h0, %2}"
9409 [(set_attr "type" "alu")
9410 (set_attr "length_immediate" "1")
9411 (set_attr "mode" "QI")])
9412
a4414093 9413(define_insn "*xorqi_ext_1"
2f41793e
JH
9414 [(set (zero_extract:SI (match_operand 0 "ext_register_operand" "=Q")
9415 (const_int 8)
9416 (const_int 8))
9417 (xor:SI
9418 (zero_extract:SI
9419 (match_operand 1 "ext_register_operand" "0")
9420 (const_int 8)
9421 (const_int 8))
9422 (zero_extend:SI
9423 (match_operand:QI 2 "general_operand" "Qm"))))
9424 (clobber (reg:CC 17))]
9425 "!TARGET_64BIT
9426 && (!TARGET_PARTIAL_REG_STALL || optimize_size)"
9427 "xor{b}\t{%2, %h0|%h0, %2}"
9428 [(set_attr "type" "alu")
9429 (set_attr "length_immediate" "0")
9430 (set_attr "mode" "QI")])
9431
9432(define_insn "*xorqi_ext_1_rex64"
9433 [(set (zero_extract:SI (match_operand 0 "ext_register_operand" "=Q")
9434 (const_int 8)
9435 (const_int 8))
9436 (xor:SI
9437 (zero_extract:SI
9438 (match_operand 1 "ext_register_operand" "0")
9439 (const_int 8)
9440 (const_int 8))
9441 (zero_extend:SI
9442 (match_operand 2 "ext_register_operand" "Q"))))
9443 (clobber (reg:CC 17))]
9444 "TARGET_64BIT
9445 && (!TARGET_PARTIAL_REG_STALL || optimize_size)"
9446 "xor{b}\t{%2, %h0|%h0, %2}"
9447 [(set_attr "type" "alu")
9448 (set_attr "length_immediate" "0")
9449 (set_attr "mode" "QI")])
9450
9451(define_insn "*xorqi_ext_2"
d2836273 9452 [(set (zero_extract:SI (match_operand 0 "ext_register_operand" "=Q")
6ef67412
JH
9453 (const_int 8)
9454 (const_int 8))
9455 (xor:SI
9456 (zero_extract:SI (match_operand 1 "ext_register_operand" "0")
9457 (const_int 8)
9458 (const_int 8))
d2836273 9459 (zero_extract:SI (match_operand 2 "ext_register_operand" "Q")
6ef67412
JH
9460 (const_int 8)
9461 (const_int 8))))
9462 (clobber (reg:CC 17))]
2f41793e 9463 "(!TARGET_PARTIAL_REG_STALL || optimize_size)"
0f40f9f7 9464 "xor{b}\t{%h2, %h0|%h0, %h2}"
6ef67412
JH
9465 [(set_attr "type" "alu")
9466 (set_attr "length_immediate" "0")
9467 (set_attr "mode" "QI")])
e075ae69 9468
7abd4e00 9469(define_insn "*xorqi_cc_1"
16189740
RH
9470 [(set (reg 17)
9471 (compare
e075ae69
RH
9472 (xor:QI (match_operand:QI 1 "nonimmediate_operand" "%0,0")
9473 (match_operand:QI 2 "general_operand" "qim,qi"))
9474 (const_int 0)))
9475 (set (match_operand:QI 0 "nonimmediate_operand" "=q,qm")
9476 (xor:QI (match_dup 1) (match_dup 2)))]
16189740
RH
9477 "ix86_match_ccmode (insn, CCNOmode)
9478 && ix86_binary_operator_ok (XOR, QImode, operands)"
0f40f9f7 9479 "xor{b}\t{%2, %0|%0, %2}"
6ef67412
JH
9480 [(set_attr "type" "alu")
9481 (set_attr "mode" "QI")])
e075ae69 9482
b6bb1d56
JH
9483(define_insn "*xorqi_2_slp"
9484 [(set (reg 17)
9485 (compare (xor:QI (match_operand:QI 0 "nonimmediate_operand" "+q,qm")
9486 (match_operand:QI 1 "general_operand" "qim,qi"))
9487 (const_int 0)))
9488 (set (strict_low_part (match_dup 0))
9489 (xor:QI (match_dup 0) (match_dup 1)))]
9490 "(! TARGET_PARTIAL_REG_STALL || optimize_size)
1b245ade
JH
9491 && ix86_match_ccmode (insn, CCNOmode)
9492 && (GET_CODE (operands[0]) != MEM || GET_CODE (operands[1]) != MEM)"
b6bb1d56
JH
9493 "xor{b}\t{%1, %0|%0, %1}"
9494 [(set_attr "type" "alu1")
9495 (set_attr "mode" "QI")])
9496
d90ffc8d
JH
9497(define_insn "*xorqi_cc_2"
9498 [(set (reg 17)
9499 (compare
9500 (xor:QI (match_operand:QI 1 "nonimmediate_operand" "%0")
9501 (match_operand:QI 2 "general_operand" "qim"))
9502 (const_int 0)))
7e08e190 9503 (clobber (match_scratch:QI 0 "=q"))]
d90ffc8d
JH
9504 "ix86_match_ccmode (insn, CCNOmode)
9505 && (GET_CODE (operands[1]) != MEM || GET_CODE (operands[2]) != MEM)"
0f40f9f7 9506 "xor{b}\t{%2, %0|%0, %2}"
d90ffc8d
JH
9507 [(set_attr "type" "alu")
9508 (set_attr "mode" "QI")])
9509
9076b9c1
JH
9510(define_insn "*xorqi_cc_ext_1"
9511 [(set (reg 17)
9512 (compare
e075ae69
RH
9513 (xor:SI
9514 (zero_extract:SI
9515 (match_operand 1 "ext_register_operand" "0")
9516 (const_int 8)
9517 (const_int 8))
9518 (match_operand:QI 2 "general_operand" "qmn"))
9519 (const_int 0)))
9520 (set (zero_extract:SI (match_operand 0 "ext_register_operand" "=q")
9521 (const_int 8)
9522 (const_int 8))
9523 (xor:SI
9524 (zero_extract:SI (match_dup 1) (const_int 8) (const_int 8))
9525 (match_dup 2)))]
d2836273 9526 "!TARGET_64BIT && ix86_match_ccmode (insn, CCNOmode)"
0f40f9f7 9527 "xor{b}\t{%2, %h0|%h0, %2}"
d2836273
JH
9528 [(set_attr "type" "alu")
9529 (set_attr "mode" "QI")])
9530
9531(define_insn "*xorqi_cc_ext_1_rex64"
9532 [(set (reg 17)
9533 (compare
9534 (xor:SI
9535 (zero_extract:SI
9536 (match_operand 1 "ext_register_operand" "0")
9537 (const_int 8)
9538 (const_int 8))
9539 (match_operand:QI 2 "nonmemory_operand" "Qn"))
9540 (const_int 0)))
9541 (set (zero_extract:SI (match_operand 0 "ext_register_operand" "=Q")
9542 (const_int 8)
9543 (const_int 8))
9544 (xor:SI
9545 (zero_extract:SI (match_dup 1) (const_int 8) (const_int 8))
9546 (match_dup 2)))]
9547 "TARGET_64BIT && ix86_match_ccmode (insn, CCNOmode)"
0f40f9f7 9548 "xor{b}\t{%2, %h0|%h0, %2}"
6ef67412
JH
9549 [(set_attr "type" "alu")
9550 (set_attr "mode" "QI")])
9076b9c1
JH
9551
9552(define_expand "xorqi_cc_ext_1"
9553 [(parallel [
9554 (set (reg:CCNO 17)
9555 (compare:CCNO
9556 (xor:SI
9557 (zero_extract:SI
9558 (match_operand 1 "ext_register_operand" "")
9559 (const_int 8)
9560 (const_int 8))
9561 (match_operand:QI 2 "general_operand" ""))
9562 (const_int 0)))
9563 (set (zero_extract:SI (match_operand 0 "ext_register_operand" "")
9564 (const_int 8)
9565 (const_int 8))
9566 (xor:SI
9567 (zero_extract:SI (match_dup 1) (const_int 8) (const_int 8))
9568 (match_dup 2)))])]
9569 ""
9570 "")
2f41793e
JH
9571
9572(define_split
9573 [(set (match_operand 0 "register_operand" "")
9574 (xor (match_operand 1 "register_operand" "")
9575 (match_operand 2 "const_int_operand" "")))
9576 (clobber (reg:CC 17))]
9577 "reload_completed
9578 && QI_REG_P (operands[0])
9579 && (!TARGET_PARTIAL_REG_STALL || optimize_size)
9580 && !(INTVAL (operands[2]) & ~(255 << 8))
9581 && GET_MODE (operands[0]) != QImode"
9582 [(parallel [(set (zero_extract:SI (match_dup 0) (const_int 8) (const_int 8))
9583 (xor:SI (zero_extract:SI (match_dup 1)
9584 (const_int 8) (const_int 8))
9585 (match_dup 2)))
9586 (clobber (reg:CC 17))])]
9587 "operands[0] = gen_lowpart (SImode, operands[0]);
9588 operands[1] = gen_lowpart (SImode, operands[1]);
9589 operands[2] = gen_int_mode ((INTVAL (operands[2]) >> 8) & 0xff, SImode);")
9590
9591;; Since XOR can be encoded with sign extended immediate, this is only
9592;; profitable when 7th bit is set.
9593(define_split
9594 [(set (match_operand 0 "register_operand" "")
9595 (xor (match_operand 1 "general_operand" "")
9596 (match_operand 2 "const_int_operand" "")))
9597 (clobber (reg:CC 17))]
9598 "reload_completed
9599 && ANY_QI_REG_P (operands[0])
9600 && (!TARGET_PARTIAL_REG_STALL || optimize_size)
9601 && !(INTVAL (operands[2]) & ~255)
9602 && (INTVAL (operands[2]) & 128)
9603 && GET_MODE (operands[0]) != QImode"
9604 [(parallel [(set (strict_low_part (match_dup 0))
9605 (xor:QI (match_dup 1)
9606 (match_dup 2)))
9607 (clobber (reg:CC 17))])]
9608 "operands[0] = gen_lowpart (QImode, operands[0]);
9609 operands[1] = gen_lowpart (QImode, operands[1]);
9610 operands[2] = gen_lowpart (QImode, operands[2]);")
e075ae69
RH
9611\f
9612;; Negation instructions
57dbca5e 9613
06a964de
JH
9614(define_expand "negdi2"
9615 [(parallel [(set (match_operand:DI 0 "nonimmediate_operand" "")
2756c3d8 9616 (neg:DI (match_operand:DI 1 "nonimmediate_operand" "")))
06a964de
JH
9617 (clobber (reg:CC 17))])]
9618 ""
9619 "ix86_expand_unary_operator (NEG, DImode, operands); DONE;")
9620
9621(define_insn "*negdi2_1"
e075ae69
RH
9622 [(set (match_operand:DI 0 "nonimmediate_operand" "=ro")
9623 (neg:DI (match_operand:DI 1 "general_operand" "0")))
9624 (clobber (reg:CC 17))]
d2836273
JH
9625 "!TARGET_64BIT
9626 && ix86_unary_operator_ok (NEG, DImode, operands)"
e075ae69 9627 "#")
886c62d1 9628
e075ae69
RH
9629(define_split
9630 [(set (match_operand:DI 0 "nonimmediate_operand" "")
9631 (neg:DI (match_operand:DI 1 "general_operand" "")))
9632 (clobber (reg:CC 17))]
1b0c37d7 9633 "!TARGET_64BIT && reload_completed"
e075ae69 9634 [(parallel
16189740
RH
9635 [(set (reg:CCZ 17)
9636 (compare:CCZ (neg:SI (match_dup 2)) (const_int 0)))
e075ae69
RH
9637 (set (match_dup 0) (neg:SI (match_dup 2)))])
9638 (parallel
9639 [(set (match_dup 1)
7e08e190 9640 (plus:SI (plus:SI (ltu:SI (reg:CC 17) (const_int 0))
9dcbdc7e
JH
9641 (match_dup 3))
9642 (const_int 0)))
e075ae69
RH
9643 (clobber (reg:CC 17))])
9644 (parallel
9645 [(set (match_dup 1)
9646 (neg:SI (match_dup 1)))
9647 (clobber (reg:CC 17))])]
9648 "split_di (operands+1, 1, operands+2, operands+3);
9649 split_di (operands+0, 1, operands+0, operands+1);")
886c62d1 9650
9b70259d
JH
9651(define_insn "*negdi2_1_rex64"
9652 [(set (match_operand:DI 0 "nonimmediate_operand" "=rm")
9653 (neg:DI (match_operand:DI 1 "nonimmediate_operand" "0")))
9654 (clobber (reg:CC 17))]
9655 "TARGET_64BIT && ix86_unary_operator_ok (NEG, DImode, operands)"
0f40f9f7 9656 "neg{q}\t%0"
9b70259d
JH
9657 [(set_attr "type" "negnot")
9658 (set_attr "mode" "DI")])
9659
9660;; The problem with neg is that it does not perform (compare x 0),
9661;; it really performs (compare 0 x), which leaves us with the zero
9662;; flag being the only useful item.
9663
9664(define_insn "*negdi2_cmpz_rex64"
9665 [(set (reg:CCZ 17)
9666 (compare:CCZ (neg:DI (match_operand:DI 1 "nonimmediate_operand" "0"))
9667 (const_int 0)))
9668 (set (match_operand:DI 0 "nonimmediate_operand" "=rm")
9669 (neg:DI (match_dup 1)))]
9670 "TARGET_64BIT && ix86_unary_operator_ok (NEG, DImode, operands)"
0f40f9f7 9671 "neg{q}\t%0"
9b70259d
JH
9672 [(set_attr "type" "negnot")
9673 (set_attr "mode" "DI")])
9674
9675
06a964de
JH
9676(define_expand "negsi2"
9677 [(parallel [(set (match_operand:SI 0 "nonimmediate_operand" "")
2756c3d8 9678 (neg:SI (match_operand:SI 1 "nonimmediate_operand" "")))
06a964de
JH
9679 (clobber (reg:CC 17))])]
9680 ""
9681 "ix86_expand_unary_operator (NEG, SImode, operands); DONE;")
9682
9683(define_insn "*negsi2_1"
2ae0f82c 9684 [(set (match_operand:SI 0 "nonimmediate_operand" "=rm")
e075ae69
RH
9685 (neg:SI (match_operand:SI 1 "nonimmediate_operand" "0")))
9686 (clobber (reg:CC 17))]
06a964de 9687 "ix86_unary_operator_ok (NEG, SImode, operands)"
0f40f9f7 9688 "neg{l}\t%0"
6ef67412
JH
9689 [(set_attr "type" "negnot")
9690 (set_attr "mode" "SI")])
e075ae69 9691
9b70259d
JH
9692;; Combine is quite creative about this pattern.
9693(define_insn "*negsi2_1_zext"
9694 [(set (match_operand:DI 0 "register_operand" "=r")
9695 (lshiftrt:DI (neg:DI (ashift:DI (match_operand:DI 1 "register_operand" "0")
9696 (const_int 32)))
9697 (const_int 32)))
9698 (clobber (reg:CC 17))]
9699 "TARGET_64BIT && ix86_unary_operator_ok (NEG, SImode, operands)"
0f40f9f7 9700 "neg{l}\t%k0"
9b70259d
JH
9701 [(set_attr "type" "negnot")
9702 (set_attr "mode" "SI")])
9703
16189740
RH
9704;; The problem with neg is that it does not perform (compare x 0),
9705;; it really performs (compare 0 x), which leaves us with the zero
9706;; flag being the only useful item.
e075ae69 9707
16189740
RH
9708(define_insn "*negsi2_cmpz"
9709 [(set (reg:CCZ 17)
9710 (compare:CCZ (neg:SI (match_operand:SI 1 "nonimmediate_operand" "0"))
9711 (const_int 0)))
e075ae69
RH
9712 (set (match_operand:SI 0 "nonimmediate_operand" "=rm")
9713 (neg:SI (match_dup 1)))]
06a964de 9714 "ix86_unary_operator_ok (NEG, SImode, operands)"
0f40f9f7 9715 "neg{l}\t%0"
6ef67412
JH
9716 [(set_attr "type" "negnot")
9717 (set_attr "mode" "SI")])
886c62d1 9718
9b70259d
JH
9719(define_insn "*negsi2_cmpz_zext"
9720 [(set (reg:CCZ 17)
9721 (compare:CCZ (lshiftrt:DI
9722 (neg:DI (ashift:DI
9723 (match_operand:DI 1 "register_operand" "0")
9724 (const_int 32)))
9725 (const_int 32))
9726 (const_int 0)))
9727 (set (match_operand:DI 0 "register_operand" "=r")
9728 (lshiftrt:DI (neg:DI (ashift:DI (match_dup 1)
9729 (const_int 32)))
9730 (const_int 32)))]
9731 "TARGET_64BIT && ix86_unary_operator_ok (NEG, SImode, operands)"
0f40f9f7 9732 "neg{l}\t%k0"
9b70259d
JH
9733 [(set_attr "type" "negnot")
9734 (set_attr "mode" "SI")])
9735
06a964de
JH
9736(define_expand "neghi2"
9737 [(parallel [(set (match_operand:HI 0 "nonimmediate_operand" "")
2756c3d8 9738 (neg:HI (match_operand:HI 1 "nonimmediate_operand" "")))
06a964de 9739 (clobber (reg:CC 17))])]
d9f32422 9740 "TARGET_HIMODE_MATH"
06a964de
JH
9741 "ix86_expand_unary_operator (NEG, HImode, operands); DONE;")
9742
9743(define_insn "*neghi2_1"
2ae0f82c 9744 [(set (match_operand:HI 0 "nonimmediate_operand" "=rm")
e075ae69
RH
9745 (neg:HI (match_operand:HI 1 "nonimmediate_operand" "0")))
9746 (clobber (reg:CC 17))]
06a964de 9747 "ix86_unary_operator_ok (NEG, HImode, operands)"
0f40f9f7 9748 "neg{w}\t%0"
6ef67412
JH
9749 [(set_attr "type" "negnot")
9750 (set_attr "mode" "HI")])
e075ae69 9751
16189740
RH
9752(define_insn "*neghi2_cmpz"
9753 [(set (reg:CCZ 17)
9754 (compare:CCZ (neg:HI (match_operand:HI 1 "nonimmediate_operand" "0"))
9755 (const_int 0)))
e075ae69
RH
9756 (set (match_operand:HI 0 "nonimmediate_operand" "=rm")
9757 (neg:HI (match_dup 1)))]
06a964de 9758 "ix86_unary_operator_ok (NEG, HImode, operands)"
0f40f9f7 9759 "neg{w}\t%0"
6ef67412
JH
9760 [(set_attr "type" "negnot")
9761 (set_attr "mode" "HI")])
886c62d1 9762
06a964de
JH
9763(define_expand "negqi2"
9764 [(parallel [(set (match_operand:QI 0 "nonimmediate_operand" "")
2756c3d8 9765 (neg:QI (match_operand:QI 1 "nonimmediate_operand" "")))
06a964de 9766 (clobber (reg:CC 17))])]
d9f32422 9767 "TARGET_QIMODE_MATH"
06a964de
JH
9768 "ix86_expand_unary_operator (NEG, QImode, operands); DONE;")
9769
9770(define_insn "*negqi2_1"
2ae0f82c 9771 [(set (match_operand:QI 0 "nonimmediate_operand" "=qm")
e075ae69
RH
9772 (neg:QI (match_operand:QI 1 "nonimmediate_operand" "0")))
9773 (clobber (reg:CC 17))]
06a964de 9774 "ix86_unary_operator_ok (NEG, QImode, operands)"
0f40f9f7 9775 "neg{b}\t%0"
6ef67412
JH
9776 [(set_attr "type" "negnot")
9777 (set_attr "mode" "QI")])
e075ae69 9778
16189740
RH
9779(define_insn "*negqi2_cmpz"
9780 [(set (reg:CCZ 17)
9781 (compare:CCZ (neg:QI (match_operand:QI 1 "nonimmediate_operand" "0"))
9782 (const_int 0)))
e075ae69
RH
9783 (set (match_operand:QI 0 "nonimmediate_operand" "=qm")
9784 (neg:QI (match_dup 1)))]
06a964de 9785 "ix86_unary_operator_ok (NEG, QImode, operands)"
0f40f9f7 9786 "neg{b}\t%0"
6ef67412
JH
9787 [(set_attr "type" "negnot")
9788 (set_attr "mode" "QI")])
886c62d1 9789
06a964de 9790;; Changing of sign for FP values is doable using integer unit too.
1ce485ec 9791
06a964de
JH
9792(define_expand "negsf2"
9793 [(parallel [(set (match_operand:SF 0 "nonimmediate_operand" "")
2756c3d8 9794 (neg:SF (match_operand:SF 1 "nonimmediate_operand" "")))
06a964de
JH
9795 (clobber (reg:CC 17))])]
9796 "TARGET_80387"
b3298882
JH
9797 "if (TARGET_SSE)
9798 {
9799 /* In case operand is in memory, we will not use SSE. */
9800 if (memory_operand (operands[0], VOIDmode)
9801 && rtx_equal_p (operands[0], operands[1]))
9802 emit_insn (gen_negsf2_memory (operands[0], operands[1]));
9803 else
9804 {
9805 /* Using SSE is tricky, since we need bitwise negation of -0
9806 in register. */
9807 rtx reg = gen_reg_rtx (SFmode);
141e454b 9808 rtx dest = operands[0];
4977bab6 9809 rtx imm = gen_lowpart (SFmode, gen_int_mode (0x80000000, SImode));
141e454b
JH
9810
9811 operands[1] = force_reg (SFmode, operands[1]);
9812 operands[0] = force_reg (SFmode, operands[0]);
4977bab6
ZW
9813 reg = force_reg (V4SFmode,
9814 gen_rtx_CONST_VECTOR (V4SFmode,
9815 gen_rtvec (4, imm, CONST0_RTX (SFmode),
9816 CONST0_RTX (SFmode),
9817 CONST0_RTX (SFmode))));
b3298882 9818 emit_insn (gen_negsf2_ifs (operands[0], operands[1], reg));
141e454b
JH
9819 if (dest != operands[0])
9820 emit_move_insn (dest, operands[0]);
b3298882
JH
9821 }
9822 DONE;
9823 }
9824 ix86_expand_unary_operator (NEG, SFmode, operands); DONE;")
9825
9826(define_insn "negsf2_memory"
9827 [(set (match_operand:SF 0 "memory_operand" "=m")
9828 (neg:SF (match_operand:SF 1 "memory_operand" "0")))
9829 (clobber (reg:CC 17))]
9830 "ix86_unary_operator_ok (NEG, SFmode, operands)"
9831 "#")
9832
9833(define_insn "negsf2_ifs"
141e454b 9834 [(set (match_operand:SF 0 "nonimmediate_operand" "=x#fr,x#fr,f#xr,rm#xf")
b3298882 9835 (neg:SF (match_operand:SF 1 "nonimmediate_operand" "0,x#fr,0,0")))
4977bab6 9836 (use (match_operand:V4SF 2 "nonimmediate_operand" "xm,0,xm*r,xm*r"))
b3298882 9837 (clobber (reg:CC 17))]
141e454b
JH
9838 "TARGET_SSE
9839 && (reload_in_progress || reload_completed
9840 || (register_operand (operands[0], VOIDmode)
9841 && register_operand (operands[1], VOIDmode)))"
b3298882
JH
9842 "#")
9843
9844(define_split
9845 [(set (match_operand:SF 0 "memory_operand" "")
9846 (neg:SF (match_operand:SF 1 "memory_operand" "")))
9847 (use (match_operand:SF 2 "" ""))
9848 (clobber (reg:CC 17))]
9849 ""
9850 [(parallel [(set (match_dup 0)
9851 (neg:SF (match_dup 1)))
9852 (clobber (reg:CC 17))])])
9853
9854(define_split
9855 [(set (match_operand:SF 0 "register_operand" "")
9856 (neg:SF (match_operand:SF 1 "register_operand" "")))
4977bab6 9857 (use (match_operand:V4SF 2 "" ""))
b3298882
JH
9858 (clobber (reg:CC 17))]
9859 "reload_completed && !SSE_REG_P (operands[0])"
9860 [(parallel [(set (match_dup 0)
9861 (neg:SF (match_dup 1)))
9862 (clobber (reg:CC 17))])])
9863
9864(define_split
9865 [(set (match_operand:SF 0 "register_operand" "")
9866 (neg:SF (match_operand:SF 1 "register_operand" "")))
4977bab6 9867 (use (match_operand:V4SF 2 "nonimmediate_operand" ""))
b3298882
JH
9868 (clobber (reg:CC 17))]
9869 "reload_completed && SSE_REG_P (operands[0])"
9870 [(set (subreg:TI (match_dup 0) 0)
4977bab6
ZW
9871 (xor:TI (match_dup 1)
9872 (match_dup 2)))]
b3298882 9873{
4977bab6
ZW
9874 operands[1] = simplify_gen_subreg (TImode, operands[1], SFmode, 0);
9875 operands[2] = simplify_gen_subreg (TImode, operands[2], V4SFmode, 0);
b3298882
JH
9876 if (operands_match_p (operands[0], operands[2]))
9877 {
9878 rtx tmp;
9879 tmp = operands[1];
9880 operands[1] = operands[2];
9881 operands[2] = tmp;
9882 }
0f40f9f7 9883})
b3298882 9884
06a964de 9885
e20440c1
JH
9886;; Keep 'f' and 'r' in separate alternatives to avoid reload problems
9887;; because of secondary memory needed to reload from class FLOAT_INT_REGS
9888;; to itself.
06a964de 9889(define_insn "*negsf2_if"
e20440c1
JH
9890 [(set (match_operand:SF 0 "nonimmediate_operand" "=f#r,rm#f")
9891 (neg:SF (match_operand:SF 1 "nonimmediate_operand" "0,0")))
1ce485ec 9892 (clobber (reg:CC 17))]
b3298882
JH
9893 "TARGET_80387 && !TARGET_SSE
9894 && ix86_unary_operator_ok (NEG, SFmode, operands)"
1ce485ec
JH
9895 "#")
9896
9897(define_split
c3c637e3 9898 [(set (match_operand:SF 0 "fp_register_operand" "")
1ce485ec
JH
9899 (neg:SF (match_operand:SF 1 "register_operand" "")))
9900 (clobber (reg:CC 17))]
c3c637e3 9901 "TARGET_80387 && reload_completed"
1ce485ec
JH
9902 [(set (match_dup 0)
9903 (neg:SF (match_dup 1)))]
9904 "")
9905
9906(define_split
c3c637e3 9907 [(set (match_operand:SF 0 "register_and_not_fp_reg_operand" "")
1ce485ec
JH
9908 (neg:SF (match_operand:SF 1 "register_operand" "")))
9909 (clobber (reg:CC 17))]
c3c637e3 9910 "TARGET_80387 && reload_completed"
1ce485ec
JH
9911 [(parallel [(set (match_dup 0) (xor:SI (match_dup 0) (match_dup 1)))
9912 (clobber (reg:CC 17))])]
d8bf17f9 9913 "operands[1] = gen_int_mode (0x80000000, SImode);
1ce485ec
JH
9914 operands[0] = gen_rtx_REG (SImode, REGNO (operands[0]));")
9915
9916(define_split
9917 [(set (match_operand 0 "memory_operand" "")
9918 (neg (match_operand 1 "memory_operand" "")))
9919 (clobber (reg:CC 17))]
9920 "TARGET_80387 && reload_completed && FLOAT_MODE_P (GET_MODE (operands[0]))"
9921 [(parallel [(set (match_dup 0) (xor:QI (match_dup 0) (match_dup 1)))
9922 (clobber (reg:CC 17))])]
1ce485ec
JH
9923{
9924 int size = GET_MODE_SIZE (GET_MODE (operands[1]));
9925
b3298882
JH
9926 /* XFmode's size is 12, TFmode 16, but only 10 bytes are used. */
9927 if (size >= 12)
1ce485ec 9928 size = 10;
b72f00af 9929 operands[0] = adjust_address (operands[0], QImode, size - 1);
d8bf17f9 9930 operands[1] = gen_int_mode (0x80, QImode);
0f40f9f7 9931})
1ce485ec 9932
06a964de
JH
9933(define_expand "negdf2"
9934 [(parallel [(set (match_operand:DF 0 "nonimmediate_operand" "")
2756c3d8 9935 (neg:DF (match_operand:DF 1 "nonimmediate_operand" "")))
06a964de
JH
9936 (clobber (reg:CC 17))])]
9937 "TARGET_80387"
141e454b 9938 "if (TARGET_SSE2)
b3298882
JH
9939 {
9940 /* In case operand is in memory, we will not use SSE. */
9941 if (memory_operand (operands[0], VOIDmode)
9942 && rtx_equal_p (operands[0], operands[1]))
9943 emit_insn (gen_negdf2_memory (operands[0], operands[1]));
9944 else
9945 {
9946 /* Using SSE is tricky, since we need bitwise negation of -0
9947 in register. */
4977bab6 9948 rtx reg;
b3298882 9949#if HOST_BITS_PER_WIDE_INT >= 64
d8bf17f9 9950 rtx imm = gen_int_mode (((HOST_WIDE_INT)1) << 63, DImode);
b3298882
JH
9951#else
9952 rtx imm = immed_double_const (0, 0x80000000, DImode);
9953#endif
141e454b
JH
9954 rtx dest = operands[0];
9955
9956 operands[1] = force_reg (DFmode, operands[1]);
9957 operands[0] = force_reg (DFmode, operands[0]);
4977bab6
ZW
9958 imm = gen_lowpart (DFmode, imm);
9959 reg = force_reg (V2DFmode,
9960 gen_rtx_CONST_VECTOR (V2DFmode,
9961 gen_rtvec (2, imm, CONST0_RTX (DFmode))));
b3298882 9962 emit_insn (gen_negdf2_ifs (operands[0], operands[1], reg));
141e454b
JH
9963 if (dest != operands[0])
9964 emit_move_insn (dest, operands[0]);
b3298882
JH
9965 }
9966 DONE;
9967 }
9968 ix86_expand_unary_operator (NEG, DFmode, operands); DONE;")
9969
9970(define_insn "negdf2_memory"
9971 [(set (match_operand:DF 0 "memory_operand" "=m")
9972 (neg:DF (match_operand:DF 1 "memory_operand" "0")))
9973 (clobber (reg:CC 17))]
9974 "ix86_unary_operator_ok (NEG, DFmode, operands)"
9975 "#")
9976
9977(define_insn "negdf2_ifs"
141e454b
JH
9978 [(set (match_operand:DF 0 "nonimmediate_operand" "=Y#fr,Y#fr,f#Yr,rm#Yf")
9979 (neg:DF (match_operand:DF 1 "nonimmediate_operand" "0,Y#fr,0,0")))
4977bab6 9980 (use (match_operand:V2DF 2 "nonimmediate_operand" "Ym,0,Ym*r,Ym*r"))
b3298882 9981 (clobber (reg:CC 17))]
1b0c37d7 9982 "!TARGET_64BIT && TARGET_SSE2
141e454b
JH
9983 && (reload_in_progress || reload_completed
9984 || (register_operand (operands[0], VOIDmode)
9985 && register_operand (operands[1], VOIDmode)))"
9986 "#")
9987
9988(define_insn "*negdf2_ifs_rex64"
f7e5dfbd 9989 [(set (match_operand:DF 0 "nonimmediate_operand" "=Y#f,Y#f,fm#Y")
4977bab6
ZW
9990 (neg:DF (match_operand:DF 1 "nonimmediate_operand" "0,Y#fr,0")))
9991 (use (match_operand:V2DF 2 "nonimmediate_operand" "Ym,0,Ym*r"))
141e454b 9992 (clobber (reg:CC 17))]
1b0c37d7 9993 "TARGET_64BIT && TARGET_SSE2
141e454b
JH
9994 && (reload_in_progress || reload_completed
9995 || (register_operand (operands[0], VOIDmode)
9996 && register_operand (operands[1], VOIDmode)))"
b3298882
JH
9997 "#")
9998
9999(define_split
10000 [(set (match_operand:DF 0 "memory_operand" "")
10001 (neg:DF (match_operand:DF 1 "memory_operand" "")))
4977bab6 10002 (use (match_operand:V2DF 2 "" ""))
b3298882
JH
10003 (clobber (reg:CC 17))]
10004 ""
10005 [(parallel [(set (match_dup 0)
10006 (neg:DF (match_dup 1)))
10007 (clobber (reg:CC 17))])])
10008
10009(define_split
10010 [(set (match_operand:DF 0 "register_operand" "")
10011 (neg:DF (match_operand:DF 1 "register_operand" "")))
4977bab6 10012 (use (match_operand:V2DF 2 "" ""))
b3298882 10013 (clobber (reg:CC 17))]
141e454b
JH
10014 "reload_completed && !SSE_REG_P (operands[0])
10015 && (!TARGET_64BIT || FP_REG_P (operands[0]))"
b3298882
JH
10016 [(parallel [(set (match_dup 0)
10017 (neg:DF (match_dup 1)))
10018 (clobber (reg:CC 17))])])
10019
141e454b
JH
10020(define_split
10021 [(set (match_operand:DF 0 "register_operand" "")
10022 (neg:DF (match_operand:DF 1 "register_operand" "")))
4977bab6 10023 (use (match_operand:V2DF 2 "" ""))
141e454b 10024 (clobber (reg:CC 17))]
1b0c37d7 10025 "TARGET_64BIT && reload_completed && GENERAL_REG_P (operands[0])"
141e454b
JH
10026 [(parallel [(set (match_dup 0)
10027 (xor:DI (match_dup 1) (match_dup 2)))
10028 (clobber (reg:CC 17))])]
10029 "operands[0] = gen_lowpart (DImode, operands[0]);
10030 operands[1] = gen_lowpart (DImode, operands[1]);
10031 operands[2] = gen_lowpart (DImode, operands[2]);")
10032
b3298882
JH
10033(define_split
10034 [(set (match_operand:DF 0 "register_operand" "")
10035 (neg:DF (match_operand:DF 1 "register_operand" "")))
4977bab6 10036 (use (match_operand:V2DF 2 "nonimmediate_operand" ""))
b3298882
JH
10037 (clobber (reg:CC 17))]
10038 "reload_completed && SSE_REG_P (operands[0])"
10039 [(set (subreg:TI (match_dup 0) 0)
4977bab6
ZW
10040 (xor:TI (match_dup 1)
10041 (match_dup 2)))]
b3298882 10042{
4977bab6
ZW
10043 operands[0] = simplify_gen_subreg (V2DFmode, operands[0], DFmode, 0);
10044 operands[1] = simplify_gen_subreg (TImode, operands[1], DFmode, 0);
10045 operands[2] = simplify_gen_subreg (TImode, operands[2], V2DFmode, 0);
d1f87653 10046 /* Avoid possible reformatting on the operands. */
4977bab6
ZW
10047 if (TARGET_SSE_PARTIAL_REGS && !optimize_size)
10048 emit_insn (gen_sse2_unpcklpd (operands[0], operands[0], operands[0]));
b3298882
JH
10049 if (operands_match_p (operands[0], operands[2]))
10050 {
10051 rtx tmp;
10052 tmp = operands[1];
10053 operands[1] = operands[2];
10054 operands[2] = tmp;
10055 }
0f40f9f7 10056})
06a964de 10057
e20440c1
JH
10058;; Keep 'f' and 'r' in separate alternatives to avoid reload problems
10059;; because of secondary memory needed to reload from class FLOAT_INT_REGS
10060;; to itself.
06a964de 10061(define_insn "*negdf2_if"
e20440c1
JH
10062 [(set (match_operand:DF 0 "nonimmediate_operand" "=f#r,rm#f")
10063 (neg:DF (match_operand:DF 1 "nonimmediate_operand" "0,0")))
1ce485ec 10064 (clobber (reg:CC 17))]
1b0c37d7 10065 "!TARGET_64BIT && TARGET_80387
141e454b
JH
10066 && ix86_unary_operator_ok (NEG, DFmode, operands)"
10067 "#")
10068
10069;; FIXME: We should to allow integer registers here. Problem is that
10070;; we need another scratch register to get constant from.
10071;; Forcing constant to mem if no register available in peep2 should be
10072;; safe even for PIC mode, because of RIP relative addressing.
10073(define_insn "*negdf2_if_rex64"
10074 [(set (match_operand:DF 0 "nonimmediate_operand" "=f,mf")
10075 (neg:DF (match_operand:DF 1 "nonimmediate_operand" "0,0")))
10076 (clobber (reg:CC 17))]
1b0c37d7 10077 "TARGET_64BIT && TARGET_80387
141e454b 10078 && ix86_unary_operator_ok (NEG, DFmode, operands)"
1ce485ec
JH
10079 "#")
10080
10081(define_split
c3c637e3 10082 [(set (match_operand:DF 0 "fp_register_operand" "")
1ce485ec
JH
10083 (neg:DF (match_operand:DF 1 "register_operand" "")))
10084 (clobber (reg:CC 17))]
c3c637e3 10085 "TARGET_80387 && reload_completed"
1ce485ec
JH
10086 [(set (match_dup 0)
10087 (neg:DF (match_dup 1)))]
10088 "")
10089
10090(define_split
c3c637e3 10091 [(set (match_operand:DF 0 "register_and_not_fp_reg_operand" "")
1ce485ec
JH
10092 (neg:DF (match_operand:DF 1 "register_operand" "")))
10093 (clobber (reg:CC 17))]
c3c637e3 10094 "!TARGET_64BIT && TARGET_80387 && reload_completed"
1ce485ec
JH
10095 [(parallel [(set (match_dup 3) (xor:SI (match_dup 3) (match_dup 4)))
10096 (clobber (reg:CC 17))])]
d8bf17f9 10097 "operands[4] = gen_int_mode (0x80000000, SImode);
1ce485ec
JH
10098 split_di (operands+0, 1, operands+2, operands+3);")
10099
06a964de
JH
10100(define_expand "negxf2"
10101 [(parallel [(set (match_operand:XF 0 "nonimmediate_operand" "")
2756c3d8 10102 (neg:XF (match_operand:XF 1 "nonimmediate_operand" "")))
06a964de 10103 (clobber (reg:CC 17))])]
1b0c37d7 10104 "!TARGET_64BIT && TARGET_80387"
06a964de
JH
10105 "ix86_expand_unary_operator (NEG, XFmode, operands); DONE;")
10106
2b589241
JH
10107(define_expand "negtf2"
10108 [(parallel [(set (match_operand:TF 0 "nonimmediate_operand" "")
10109 (neg:TF (match_operand:TF 1 "nonimmediate_operand" "")))
10110 (clobber (reg:CC 17))])]
10111 "TARGET_80387"
10112 "ix86_expand_unary_operator (NEG, TFmode, operands); DONE;")
10113
e20440c1
JH
10114;; Keep 'f' and 'r' in separate alternatives to avoid reload problems
10115;; because of secondary memory needed to reload from class FLOAT_INT_REGS
10116;; to itself.
06a964de 10117(define_insn "*negxf2_if"
e20440c1
JH
10118 [(set (match_operand:XF 0 "nonimmediate_operand" "=f#r,rm#f")
10119 (neg:XF (match_operand:XF 1 "nonimmediate_operand" "0,0")))
1ce485ec 10120 (clobber (reg:CC 17))]
1b0c37d7 10121 "!TARGET_64BIT && TARGET_80387
1e07edd3 10122 && ix86_unary_operator_ok (NEG, XFmode, operands)"
1ce485ec
JH
10123 "#")
10124
10125(define_split
c3c637e3 10126 [(set (match_operand:XF 0 "fp_register_operand" "")
1ce485ec
JH
10127 (neg:XF (match_operand:XF 1 "register_operand" "")))
10128 (clobber (reg:CC 17))]
c3c637e3 10129 "TARGET_80387 && reload_completed"
1ce485ec
JH
10130 [(set (match_dup 0)
10131 (neg:XF (match_dup 1)))]
10132 "")
10133
10134(define_split
c3c637e3 10135 [(set (match_operand:XF 0 "register_and_not_fp_reg_operand" "")
1ce485ec
JH
10136 (neg:XF (match_operand:XF 1 "register_operand" "")))
10137 (clobber (reg:CC 17))]
c3c637e3 10138 "TARGET_80387 && reload_completed"
1ce485ec
JH
10139 [(parallel [(set (match_dup 0) (xor:SI (match_dup 0) (match_dup 1)))
10140 (clobber (reg:CC 17))])]
10141 "operands[1] = GEN_INT (0x8000);
141e454b
JH
10142 operands[0] = gen_rtx_REG (SImode,
10143 true_regnum (operands[0]) + (TARGET_64BIT ? 1 : 2));")
1ce485ec 10144
2b589241
JH
10145;; Keep 'f' and 'r' in separate alternatives to avoid reload problems
10146;; because of secondary memory needed to reload from class FLOAT_INT_REGS
10147;; to itself.
10148(define_insn "*negtf2_if"
10149 [(set (match_operand:TF 0 "nonimmediate_operand" "=f#r,rm#f")
10150 (neg:TF (match_operand:TF 1 "nonimmediate_operand" "0,0")))
10151 (clobber (reg:CC 17))]
10152 "TARGET_80387 && ix86_unary_operator_ok (NEG, TFmode, operands)"
10153 "#")
10154
10155(define_split
c3c637e3 10156 [(set (match_operand:TF 0 "fp_register_operand" "")
2b589241
JH
10157 (neg:TF (match_operand:TF 1 "register_operand" "")))
10158 (clobber (reg:CC 17))]
c3c637e3 10159 "TARGET_80387 && reload_completed"
2b589241
JH
10160 [(set (match_dup 0)
10161 (neg:TF (match_dup 1)))]
10162 "")
10163
10164(define_split
c3c637e3 10165 [(set (match_operand:TF 0 "register_and_not_fp_reg_operand" "")
2b589241
JH
10166 (neg:TF (match_operand:TF 1 "register_operand" "")))
10167 (clobber (reg:CC 17))]
c3c637e3 10168 "TARGET_80387 && reload_completed"
2b589241
JH
10169 [(parallel [(set (match_dup 0) (xor:SI (match_dup 0) (match_dup 1)))
10170 (clobber (reg:CC 17))])]
10171 "operands[1] = GEN_INT (0x8000);
141e454b
JH
10172 operands[0] = gen_rtx_REG (SImode,
10173 true_regnum (operands[0]) + (TARGET_64BIT ? 1 : 2));")
2b589241 10174
d1f87653 10175;; Conditionalize these after reload. If they matches before reload, we
1ce485ec
JH
10176;; lose the clobber and ability to use integer instructions.
10177
10178(define_insn "*negsf2_1"
886c62d1 10179 [(set (match_operand:SF 0 "register_operand" "=f")
2ae0f82c 10180 (neg:SF (match_operand:SF 1 "register_operand" "0")))]
1ce485ec 10181 "TARGET_80387 && reload_completed"
10195bd8 10182 "fchs"
e075ae69 10183 [(set_attr "type" "fsgn")
6ef67412 10184 (set_attr "mode" "SF")
e075ae69 10185 (set_attr "ppro_uops" "few")])
886c62d1 10186
1ce485ec 10187(define_insn "*negdf2_1"
886c62d1 10188 [(set (match_operand:DF 0 "register_operand" "=f")
2ae0f82c 10189 (neg:DF (match_operand:DF 1 "register_operand" "0")))]
1ce485ec 10190 "TARGET_80387 && reload_completed"
10195bd8 10191 "fchs"
e075ae69 10192 [(set_attr "type" "fsgn")
6ef67412 10193 (set_attr "mode" "DF")
e075ae69 10194 (set_attr "ppro_uops" "few")])
886c62d1 10195
6343a50e 10196(define_insn "*negextendsfdf2"
886c62d1 10197 [(set (match_operand:DF 0 "register_operand" "=f")
e075ae69
RH
10198 (neg:DF (float_extend:DF
10199 (match_operand:SF 1 "register_operand" "0"))))]
886c62d1 10200 "TARGET_80387"
10195bd8 10201 "fchs"
e075ae69 10202 [(set_attr "type" "fsgn")
6ef67412 10203 (set_attr "mode" "DF")
e075ae69 10204 (set_attr "ppro_uops" "few")])
4fb21e90 10205
1ce485ec 10206(define_insn "*negxf2_1"
4fb21e90 10207 [(set (match_operand:XF 0 "register_operand" "=f")
2ae0f82c 10208 (neg:XF (match_operand:XF 1 "register_operand" "0")))]
1b0c37d7 10209 "!TARGET_64BIT && TARGET_80387 && reload_completed"
10195bd8 10210 "fchs"
e075ae69 10211 [(set_attr "type" "fsgn")
6ef67412 10212 (set_attr "mode" "XF")
e075ae69
RH
10213 (set_attr "ppro_uops" "few")])
10214
6343a50e 10215(define_insn "*negextenddfxf2"
e075ae69
RH
10216 [(set (match_operand:XF 0 "register_operand" "=f")
10217 (neg:XF (float_extend:XF
10218 (match_operand:DF 1 "register_operand" "0"))))]
1b0c37d7 10219 "!TARGET_64BIT && TARGET_80387"
e075ae69
RH
10220 "fchs"
10221 [(set_attr "type" "fsgn")
6ef67412 10222 (set_attr "mode" "XF")
e075ae69 10223 (set_attr "ppro_uops" "few")])
4fb21e90 10224
6343a50e 10225(define_insn "*negextendsfxf2"
4fb21e90 10226 [(set (match_operand:XF 0 "register_operand" "=f")
e075ae69
RH
10227 (neg:XF (float_extend:XF
10228 (match_operand:SF 1 "register_operand" "0"))))]
1b0c37d7 10229 "!TARGET_64BIT && TARGET_80387"
10195bd8 10230 "fchs"
e075ae69 10231 [(set_attr "type" "fsgn")
6ef67412 10232 (set_attr "mode" "XF")
e075ae69 10233 (set_attr "ppro_uops" "few")])
2b589241
JH
10234
10235(define_insn "*negtf2_1"
10236 [(set (match_operand:TF 0 "register_operand" "=f")
10237 (neg:TF (match_operand:TF 1 "register_operand" "0")))]
10238 "TARGET_80387 && reload_completed"
10239 "fchs"
10240 [(set_attr "type" "fsgn")
10241 (set_attr "mode" "XF")
10242 (set_attr "ppro_uops" "few")])
10243
10244(define_insn "*negextenddftf2"
10245 [(set (match_operand:TF 0 "register_operand" "=f")
10246 (neg:TF (float_extend:TF
10247 (match_operand:DF 1 "register_operand" "0"))))]
10248 "TARGET_80387"
10249 "fchs"
10250 [(set_attr "type" "fsgn")
10251 (set_attr "mode" "XF")
10252 (set_attr "ppro_uops" "few")])
10253
10254(define_insn "*negextendsftf2"
10255 [(set (match_operand:TF 0 "register_operand" "=f")
10256 (neg:TF (float_extend:TF
10257 (match_operand:SF 1 "register_operand" "0"))))]
10258 "TARGET_80387"
10259 "fchs"
10260 [(set_attr "type" "fsgn")
10261 (set_attr "mode" "XF")
10262 (set_attr "ppro_uops" "few")])
886c62d1
JVA
10263\f
10264;; Absolute value instructions
10265
06a964de
JH
10266(define_expand "abssf2"
10267 [(parallel [(set (match_operand:SF 0 "nonimmediate_operand" "")
2756c3d8 10268 (neg:SF (match_operand:SF 1 "nonimmediate_operand" "")))
06a964de
JH
10269 (clobber (reg:CC 17))])]
10270 "TARGET_80387"
ca29d1dc
JH
10271 "if (TARGET_SSE)
10272 {
10273 /* In case operand is in memory, we will not use SSE. */
10274 if (memory_operand (operands[0], VOIDmode)
10275 && rtx_equal_p (operands[0], operands[1]))
10276 emit_insn (gen_abssf2_memory (operands[0], operands[1]));
10277 else
10278 {
10279 /* Using SSE is tricky, since we need bitwise negation of -0
10280 in register. */
4977bab6 10281 rtx reg = gen_reg_rtx (V4SFmode);
141e454b 10282 rtx dest = operands[0];
4977bab6 10283 rtx imm;
141e454b
JH
10284
10285 operands[1] = force_reg (SFmode, operands[1]);
10286 operands[0] = force_reg (SFmode, operands[0]);
4977bab6
ZW
10287 imm = gen_lowpart (SFmode, gen_int_mode(~0x80000000, SImode));
10288 reg = force_reg (V4SFmode,
10289 gen_rtx_CONST_VECTOR (V4SFmode,
10290 gen_rtvec (4, imm, CONST0_RTX (SFmode),
10291 CONST0_RTX (SFmode),
10292 CONST0_RTX (SFmode))));
ca29d1dc 10293 emit_insn (gen_abssf2_ifs (operands[0], operands[1], reg));
141e454b
JH
10294 if (dest != operands[0])
10295 emit_move_insn (dest, operands[0]);
ca29d1dc
JH
10296 }
10297 DONE;
10298 }
10299 ix86_expand_unary_operator (ABS, SFmode, operands); DONE;")
10300
10301(define_insn "abssf2_memory"
10302 [(set (match_operand:SF 0 "memory_operand" "=m")
10303 (abs:SF (match_operand:SF 1 "memory_operand" "0")))
10304 (clobber (reg:CC 17))]
10305 "ix86_unary_operator_ok (ABS, SFmode, operands)"
10306 "#")
10307
10308(define_insn "abssf2_ifs"
4977bab6
ZW
10309 [(set (match_operand:SF 0 "nonimmediate_operand" "=x#fr,x#fr,f#xr,rm#xf")
10310 (abs:SF (match_operand:SF 1 "nonimmediate_operand" "0,x#fr,0,0")))
10311 (use (match_operand:V4SF 2 "nonimmediate_operand" "xm,0,xm*r,xm*r"))
ca29d1dc 10312 (clobber (reg:CC 17))]
141e454b
JH
10313 "TARGET_SSE
10314 && (reload_in_progress || reload_completed
10315 || (register_operand (operands[0], VOIDmode)
4977bab6 10316 && register_operand (operands[1], VOIDmode)))"
ca29d1dc
JH
10317 "#")
10318
10319(define_split
10320 [(set (match_operand:SF 0 "memory_operand" "")
10321 (abs:SF (match_operand:SF 1 "memory_operand" "")))
4977bab6 10322 (use (match_operand:V4SF 2 "" ""))
ca29d1dc
JH
10323 (clobber (reg:CC 17))]
10324 ""
10325 [(parallel [(set (match_dup 0)
10326 (abs:SF (match_dup 1)))
10327 (clobber (reg:CC 17))])])
10328
10329(define_split
10330 [(set (match_operand:SF 0 "register_operand" "")
10331 (abs:SF (match_operand:SF 1 "register_operand" "")))
4977bab6 10332 (use (match_operand:V4SF 2 "" ""))
ca29d1dc
JH
10333 (clobber (reg:CC 17))]
10334 "reload_completed && !SSE_REG_P (operands[0])"
10335 [(parallel [(set (match_dup 0)
10336 (abs:SF (match_dup 1)))
10337 (clobber (reg:CC 17))])])
10338
10339(define_split
10340 [(set (match_operand:SF 0 "register_operand" "")
10341 (abs:SF (match_operand:SF 1 "register_operand" "")))
4977bab6 10342 (use (match_operand:V4SF 2 "nonimmediate_operand" ""))
ca29d1dc
JH
10343 (clobber (reg:CC 17))]
10344 "reload_completed && SSE_REG_P (operands[0])"
10345 [(set (subreg:TI (match_dup 0) 0)
4977bab6
ZW
10346 (and:TI (match_dup 1)
10347 (match_dup 2)))]
10348{
10349 operands[1] = simplify_gen_subreg (TImode, operands[1], SFmode, 0);
10350 operands[2] = simplify_gen_subreg (TImode, operands[2], V4SFmode, 0);
10351 if (operands_match_p (operands[0], operands[2]))
10352 {
10353 rtx tmp;
10354 tmp = operands[1];
10355 operands[1] = operands[2];
10356 operands[2] = tmp;
10357 }
10358})
06a964de 10359
e20440c1
JH
10360;; Keep 'f' and 'r' in separate alternatives to avoid reload problems
10361;; because of secondary memory needed to reload from class FLOAT_INT_REGS
10362;; to itself.
06a964de 10363(define_insn "*abssf2_if"
e20440c1
JH
10364 [(set (match_operand:SF 0 "nonimmediate_operand" "=f#r,rm#f")
10365 (abs:SF (match_operand:SF 1 "nonimmediate_operand" "0,0")))
1ce485ec 10366 (clobber (reg:CC 17))]
ca29d1dc 10367 "TARGET_80387 && ix86_unary_operator_ok (ABS, SFmode, operands) && !TARGET_SSE"
1ce485ec
JH
10368 "#")
10369
10370(define_split
c3c637e3 10371 [(set (match_operand:SF 0 "fp_register_operand" "")
1ce485ec
JH
10372 (abs:SF (match_operand:SF 1 "register_operand" "")))
10373 (clobber (reg:CC 17))]
c3c637e3 10374 "TARGET_80387"
1ce485ec
JH
10375 [(set (match_dup 0)
10376 (abs:SF (match_dup 1)))]
10377 "")
10378
10379(define_split
c3c637e3 10380 [(set (match_operand:SF 0 "register_and_not_fp_reg_operand" "")
1ce485ec
JH
10381 (abs:SF (match_operand:SF 1 "register_operand" "")))
10382 (clobber (reg:CC 17))]
c3c637e3 10383 "TARGET_80387 && reload_completed"
1ce485ec
JH
10384 [(parallel [(set (match_dup 0) (and:SI (match_dup 0) (match_dup 1)))
10385 (clobber (reg:CC 17))])]
d8bf17f9 10386 "operands[1] = gen_int_mode (~0x80000000, SImode);
1ce485ec
JH
10387 operands[0] = gen_rtx_REG (SImode, REGNO (operands[0]));")
10388
10389(define_split
10390 [(set (match_operand 0 "memory_operand" "")
10391 (abs (match_operand 1 "memory_operand" "")))
10392 (clobber (reg:CC 17))]
10393 "TARGET_80387 && reload_completed && FLOAT_MODE_P (GET_MODE (operands[0]))"
10394 [(parallel [(set (match_dup 0) (and:QI (match_dup 0) (match_dup 1)))
10395 (clobber (reg:CC 17))])]
1ce485ec
JH
10396{
10397 int size = GET_MODE_SIZE (GET_MODE (operands[1]));
10398
b3298882
JH
10399 /* XFmode's size is 12, TFmode 16, but only 10 bytes are used. */
10400 if (size >= 12)
1ce485ec 10401 size = 10;
b72f00af 10402 operands[0] = adjust_address (operands[0], QImode, size - 1);
d8bf17f9 10403 operands[1] = gen_int_mode (~0x80, QImode);
0f40f9f7 10404})
1ce485ec 10405
06a964de
JH
10406(define_expand "absdf2"
10407 [(parallel [(set (match_operand:DF 0 "nonimmediate_operand" "")
2756c3d8 10408 (neg:DF (match_operand:DF 1 "nonimmediate_operand" "")))
06a964de 10409 (clobber (reg:CC 17))])]
1ce485ec 10410 "TARGET_80387"
ca29d1dc
JH
10411 "if (TARGET_SSE2)
10412 {
10413 /* In case operand is in memory, we will not use SSE. */
10414 if (memory_operand (operands[0], VOIDmode)
10415 && rtx_equal_p (operands[0], operands[1]))
10416 emit_insn (gen_absdf2_memory (operands[0], operands[1]));
10417 else
10418 {
10419 /* Using SSE is tricky, since we need bitwise negation of -0
10420 in register. */
4977bab6 10421 rtx reg = gen_reg_rtx (V2DFmode);
ca29d1dc 10422#if HOST_BITS_PER_WIDE_INT >= 64
4977bab6 10423 rtx imm = gen_int_mode (~(((HOST_WIDE_INT)1) << 63), DImode);
ca29d1dc 10424#else
4977bab6 10425 rtx imm = immed_double_const (~0, ~0x80000000, DImode);
ca29d1dc 10426#endif
141e454b
JH
10427 rtx dest = operands[0];
10428
10429 operands[1] = force_reg (DFmode, operands[1]);
10430 operands[0] = force_reg (DFmode, operands[0]);
4977bab6
ZW
10431
10432 /* Produce LONG_DOUBLE with the proper immediate argument. */
10433 imm = gen_lowpart (DFmode, imm);
10434 reg = force_reg (V2DFmode,
10435 gen_rtx_CONST_VECTOR (V2DFmode,
10436 gen_rtvec (2, imm, CONST0_RTX (DFmode))));
ca29d1dc 10437 emit_insn (gen_absdf2_ifs (operands[0], operands[1], reg));
141e454b
JH
10438 if (dest != operands[0])
10439 emit_move_insn (dest, operands[0]);
ca29d1dc
JH
10440 }
10441 DONE;
10442 }
10443 ix86_expand_unary_operator (ABS, DFmode, operands); DONE;")
10444
10445(define_insn "absdf2_memory"
10446 [(set (match_operand:DF 0 "memory_operand" "=m")
10447 (abs:DF (match_operand:DF 1 "memory_operand" "0")))
10448 (clobber (reg:CC 17))]
10449 "ix86_unary_operator_ok (ABS, DFmode, operands)"
10450 "#")
10451
10452(define_insn "absdf2_ifs"
4977bab6
ZW
10453 [(set (match_operand:DF 0 "nonimmediate_operand" "=Y#fr,Y#fr,mf#Yr,mr#Yf")
10454 (abs:DF (match_operand:DF 1 "nonimmediate_operand" "0,Y#fr,0,0")))
10455 (use (match_operand:V2DF 2 "nonimmediate_operand" "Ym,0,Ym*r,Ym*r"))
ca29d1dc 10456 (clobber (reg:CC 17))]
1b0c37d7 10457 "!TARGET_64BIT && TARGET_SSE2
141e454b
JH
10458 && (reload_in_progress || reload_completed
10459 || (register_operand (operands[0], VOIDmode)
10460 && register_operand (operands[1], VOIDmode)))"
10461 "#")
10462
10463(define_insn "*absdf2_ifs_rex64"
4977bab6
ZW
10464 [(set (match_operand:DF 0 "nonimmediate_operand" "=Y#fr,Y#fr,mf#Yr")
10465 (abs:DF (match_operand:DF 1 "nonimmediate_operand" "0,Y#fr,0")))
10466 (use (match_operand:V2DF 2 "nonimmediate_operand" "Ym,0,Ym*r"))
141e454b 10467 (clobber (reg:CC 17))]
1b0c37d7 10468 "TARGET_64BIT && TARGET_SSE2
141e454b
JH
10469 && (reload_in_progress || reload_completed
10470 || (register_operand (operands[0], VOIDmode)
10471 && register_operand (operands[1], VOIDmode)))"
ca29d1dc
JH
10472 "#")
10473
10474(define_split
10475 [(set (match_operand:DF 0 "memory_operand" "")
10476 (abs:DF (match_operand:DF 1 "memory_operand" "")))
4977bab6 10477 (use (match_operand:V2DF 2 "" ""))
ca29d1dc
JH
10478 (clobber (reg:CC 17))]
10479 ""
10480 [(parallel [(set (match_dup 0)
10481 (abs:DF (match_dup 1)))
10482 (clobber (reg:CC 17))])])
10483
10484(define_split
10485 [(set (match_operand:DF 0 "register_operand" "")
10486 (abs:DF (match_operand:DF 1 "register_operand" "")))
4977bab6 10487 (use (match_operand:V2DF 2 "" ""))
ca29d1dc
JH
10488 (clobber (reg:CC 17))]
10489 "reload_completed && !SSE_REG_P (operands[0])"
10490 [(parallel [(set (match_dup 0)
10491 (abs:DF (match_dup 1)))
10492 (clobber (reg:CC 17))])])
10493
10494(define_split
10495 [(set (match_operand:DF 0 "register_operand" "")
10496 (abs:DF (match_operand:DF 1 "register_operand" "")))
4977bab6 10497 (use (match_operand:V2DF 2 "nonimmediate_operand" ""))
ca29d1dc
JH
10498 (clobber (reg:CC 17))]
10499 "reload_completed && SSE_REG_P (operands[0])"
10500 [(set (subreg:TI (match_dup 0) 0)
4977bab6
ZW
10501 (and:TI (match_dup 1)
10502 (match_dup 2)))]
10503{
10504 operands[0] = simplify_gen_subreg (V2DFmode, operands[0], DFmode, 0);
10505 operands[1] = simplify_gen_subreg (TImode, operands[1], DFmode, 0);
10506 operands[2] = simplify_gen_subreg (TImode, operands[2], V2DFmode, 0);
d1f87653 10507 /* Avoid possible reformatting on the operands. */
4977bab6
ZW
10508 if (TARGET_SSE_PARTIAL_REGS && !optimize_size)
10509 emit_insn (gen_sse2_unpcklpd (operands[0], operands[0], operands[0]));
10510 if (operands_match_p (operands[0], operands[2]))
10511 {
10512 rtx tmp;
10513 tmp = operands[1];
10514 operands[1] = operands[2];
10515 operands[2] = tmp;
10516 }
10517})
ca29d1dc 10518
06a964de 10519
e20440c1
JH
10520;; Keep 'f' and 'r' in separate alternatives to avoid reload problems
10521;; because of secondary memory needed to reload from class FLOAT_INT_REGS
10522;; to itself.
06a964de 10523(define_insn "*absdf2_if"
e20440c1
JH
10524 [(set (match_operand:DF 0 "nonimmediate_operand" "=f#r,rm#f")
10525 (abs:DF (match_operand:DF 1 "nonimmediate_operand" "0,0")))
06a964de 10526 (clobber (reg:CC 17))]
1b0c37d7 10527 "!TARGET_64BIT && TARGET_80387
141e454b
JH
10528 && ix86_unary_operator_ok (ABS, DFmode, operands)"
10529 "#")
10530
10531;; FIXME: We should to allow integer registers here. Problem is that
10532;; we need another scratch register to get constant from.
10533;; Forcing constant to mem if no register available in peep2 should be
10534;; safe even for PIC mode, because of RIP relative addressing.
10535(define_insn "*absdf2_if_rex64"
10536 [(set (match_operand:DF 0 "nonimmediate_operand" "=f,mf")
10537 (abs:DF (match_operand:DF 1 "nonimmediate_operand" "0,0")))
10538 (clobber (reg:CC 17))]
1b0c37d7 10539 "TARGET_64BIT && TARGET_80387
141e454b 10540 && ix86_unary_operator_ok (ABS, DFmode, operands)"
1ce485ec
JH
10541 "#")
10542
10543(define_split
c3c637e3 10544 [(set (match_operand:DF 0 "fp_register_operand" "")
1ce485ec
JH
10545 (abs:DF (match_operand:DF 1 "register_operand" "")))
10546 (clobber (reg:CC 17))]
c3c637e3 10547 "TARGET_80387 && reload_completed"
1ce485ec
JH
10548 [(set (match_dup 0)
10549 (abs:DF (match_dup 1)))]
10550 "")
10551
10552(define_split
c3c637e3 10553 [(set (match_operand:DF 0 "register_and_not_fp_reg_operand" "")
1ce485ec
JH
10554 (abs:DF (match_operand:DF 1 "register_operand" "")))
10555 (clobber (reg:CC 17))]
c3c637e3 10556 "!TARGET_64BIT && TARGET_80387 && reload_completed"
1ce485ec
JH
10557 [(parallel [(set (match_dup 3) (and:SI (match_dup 3) (match_dup 4)))
10558 (clobber (reg:CC 17))])]
d8bf17f9 10559 "operands[4] = gen_int_mode (~0x80000000, SImode);
1ce485ec
JH
10560 split_di (operands+0, 1, operands+2, operands+3);")
10561
06a964de
JH
10562(define_expand "absxf2"
10563 [(parallel [(set (match_operand:XF 0 "nonimmediate_operand" "")
2756c3d8 10564 (neg:XF (match_operand:XF 1 "nonimmediate_operand" "")))
06a964de 10565 (clobber (reg:CC 17))])]
1b0c37d7 10566 "!TARGET_64BIT && TARGET_80387"
06a964de
JH
10567 "ix86_expand_unary_operator (ABS, XFmode, operands); DONE;")
10568
2b589241
JH
10569(define_expand "abstf2"
10570 [(parallel [(set (match_operand:TF 0 "nonimmediate_operand" "")
10571 (neg:TF (match_operand:TF 1 "nonimmediate_operand" "")))
10572 (clobber (reg:CC 17))])]
10573 "TARGET_80387"
10574 "ix86_expand_unary_operator (ABS, TFmode, operands); DONE;")
10575
e20440c1
JH
10576;; Keep 'f' and 'r' in separate alternatives to avoid reload problems
10577;; because of secondary memory needed to reload from class FLOAT_INT_REGS
10578;; to itself.
06a964de 10579(define_insn "*absxf2_if"
e20440c1
JH
10580 [(set (match_operand:XF 0 "nonimmediate_operand" "=f#r,rm#f")
10581 (abs:XF (match_operand:XF 1 "nonimmediate_operand" "0,0")))
1ce485ec 10582 (clobber (reg:CC 17))]
1b0c37d7 10583 "!TARGET_64BIT && TARGET_80387
1e07edd3 10584 && ix86_unary_operator_ok (ABS, XFmode, operands)"
1ce485ec
JH
10585 "#")
10586
10587(define_split
c3c637e3 10588 [(set (match_operand:XF 0 "fp_register_operand" "")
1ce485ec
JH
10589 (abs:XF (match_operand:XF 1 "register_operand" "")))
10590 (clobber (reg:CC 17))]
c3c637e3 10591 "TARGET_80387 && reload_completed"
1ce485ec
JH
10592 [(set (match_dup 0)
10593 (abs:XF (match_dup 1)))]
10594 "")
10595
10596(define_split
c3c637e3 10597 [(set (match_operand:XF 0 "register_and_not_fp_reg_operand" "")
1ce485ec
JH
10598 (abs:XF (match_operand:XF 1 "register_operand" "")))
10599 (clobber (reg:CC 17))]
c3c637e3 10600 "TARGET_80387 && reload_completed"
1ce485ec
JH
10601 [(parallel [(set (match_dup 0) (and:SI (match_dup 0) (match_dup 1)))
10602 (clobber (reg:CC 17))])]
141e454b
JH
10603 "operands[1] = GEN_INT (~0x8000);
10604 operands[0] = gen_rtx_REG (SImode,
10605 true_regnum (operands[0]) + (TARGET_64BIT ? 1 : 2));")
1ce485ec 10606
2b589241
JH
10607(define_insn "*abstf2_if"
10608 [(set (match_operand:TF 0 "nonimmediate_operand" "=f#r,rm#f")
10609 (abs:TF (match_operand:TF 1 "nonimmediate_operand" "0,0")))
10610 (clobber (reg:CC 17))]
10611 "TARGET_80387 && ix86_unary_operator_ok (ABS, TFmode, operands)"
10612 "#")
10613
10614(define_split
c3c637e3 10615 [(set (match_operand:TF 0 "fp_register_operand" "")
2b589241
JH
10616 (abs:TF (match_operand:TF 1 "register_operand" "")))
10617 (clobber (reg:CC 17))]
c3c637e3 10618 "TARGET_80387 && reload_completed"
2b589241
JH
10619 [(set (match_dup 0)
10620 (abs:TF (match_dup 1)))]
10621 "")
10622
10623(define_split
c3c637e3 10624 [(set (match_operand:TF 0 "register_and_not_any_fp_reg_operand" "")
2b589241
JH
10625 (abs:TF (match_operand:TF 1 "register_operand" "")))
10626 (clobber (reg:CC 17))]
c3c637e3 10627 "TARGET_80387 && reload_completed"
2b589241
JH
10628 [(parallel [(set (match_dup 0) (and:SI (match_dup 0) (match_dup 1)))
10629 (clobber (reg:CC 17))])]
141e454b
JH
10630 "operands[1] = GEN_INT (~0x8000);
10631 operands[0] = gen_rtx_REG (SImode,
10632 true_regnum (operands[0]) + (TARGET_64BIT ? 1 : 2));")
2b589241 10633
1ce485ec 10634(define_insn "*abssf2_1"
886c62d1 10635 [(set (match_operand:SF 0 "register_operand" "=f")
2ae0f82c 10636 (abs:SF (match_operand:SF 1 "register_operand" "0")))]
1ce485ec 10637 "TARGET_80387 && reload_completed"
2ae0f82c 10638 "fabs"
6ef67412
JH
10639 [(set_attr "type" "fsgn")
10640 (set_attr "mode" "SF")])
886c62d1 10641
1ce485ec 10642(define_insn "*absdf2_1"
886c62d1 10643 [(set (match_operand:DF 0 "register_operand" "=f")
2ae0f82c 10644 (abs:DF (match_operand:DF 1 "register_operand" "0")))]
1ce485ec 10645 "TARGET_80387 && reload_completed"
2ae0f82c 10646 "fabs"
6ef67412
JH
10647 [(set_attr "type" "fsgn")
10648 (set_attr "mode" "DF")])
886c62d1 10649
6343a50e 10650(define_insn "*absextendsfdf2"
886c62d1 10651 [(set (match_operand:DF 0 "register_operand" "=f")
e075ae69
RH
10652 (abs:DF (float_extend:DF
10653 (match_operand:SF 1 "register_operand" "0"))))]
886c62d1 10654 "TARGET_80387"
2ae0f82c 10655 "fabs"
6ef67412
JH
10656 [(set_attr "type" "fsgn")
10657 (set_attr "mode" "DF")])
886c62d1 10658
1ce485ec 10659(define_insn "*absxf2_1"
4fb21e90 10660 [(set (match_operand:XF 0 "register_operand" "=f")
2ae0f82c 10661 (abs:XF (match_operand:XF 1 "register_operand" "0")))]
1b0c37d7 10662 "!TARGET_64BIT && TARGET_80387 && reload_completed"
2ae0f82c 10663 "fabs"
6ef67412
JH
10664 [(set_attr "type" "fsgn")
10665 (set_attr "mode" "DF")])
4fb21e90 10666
6343a50e 10667(define_insn "*absextenddfxf2"
4fb21e90 10668 [(set (match_operand:XF 0 "register_operand" "=f")
e075ae69
RH
10669 (abs:XF (float_extend:XF
10670 (match_operand:DF 1 "register_operand" "0"))))]
1b0c37d7 10671 "!TARGET_64BIT && TARGET_80387"
2ae0f82c 10672 "fabs"
6ef67412
JH
10673 [(set_attr "type" "fsgn")
10674 (set_attr "mode" "XF")])
a199fdd6 10675
6343a50e 10676(define_insn "*absextendsfxf2"
58733f96 10677 [(set (match_operand:XF 0 "register_operand" "=f")
e075ae69
RH
10678 (abs:XF (float_extend:XF
10679 (match_operand:SF 1 "register_operand" "0"))))]
1b0c37d7 10680 "!TARGET_64BIT && TARGET_80387"
e075ae69 10681 "fabs"
6ef67412
JH
10682 [(set_attr "type" "fsgn")
10683 (set_attr "mode" "XF")])
2b589241
JH
10684
10685(define_insn "*abstf2_1"
10686 [(set (match_operand:TF 0 "register_operand" "=f")
10687 (abs:TF (match_operand:TF 1 "register_operand" "0")))]
10688 "TARGET_80387 && reload_completed"
10689 "fabs"
10690 [(set_attr "type" "fsgn")
10691 (set_attr "mode" "DF")])
10692
10693(define_insn "*absextenddftf2"
10694 [(set (match_operand:TF 0 "register_operand" "=f")
10695 (abs:TF (float_extend:TF
10696 (match_operand:DF 1 "register_operand" "0"))))]
10697 "TARGET_80387"
10698 "fabs"
10699 [(set_attr "type" "fsgn")
10700 (set_attr "mode" "XF")])
10701
10702(define_insn "*absextendsftf2"
10703 [(set (match_operand:TF 0 "register_operand" "=f")
10704 (abs:TF (float_extend:TF
10705 (match_operand:SF 1 "register_operand" "0"))))]
10706 "TARGET_80387"
10707 "fabs"
10708 [(set_attr "type" "fsgn")
10709 (set_attr "mode" "XF")])
886c62d1 10710\f
e075ae69 10711;; One complement instructions
886c62d1 10712
9b70259d
JH
10713(define_expand "one_cmpldi2"
10714 [(set (match_operand:DI 0 "nonimmediate_operand" "")
10715 (not:DI (match_operand:DI 1 "nonimmediate_operand" "")))]
10716 "TARGET_64BIT"
10717 "ix86_expand_unary_operator (NOT, DImode, operands); DONE;")
10718
10719(define_insn "*one_cmpldi2_1_rex64"
10720 [(set (match_operand:DI 0 "nonimmediate_operand" "=rm")
10721 (not:DI (match_operand:DI 1 "nonimmediate_operand" "0")))]
10722 "TARGET_64BIT && ix86_unary_operator_ok (NOT, DImode, operands)"
0f40f9f7 10723 "not{q}\t%0"
9b70259d
JH
10724 [(set_attr "type" "negnot")
10725 (set_attr "mode" "DI")])
10726
10727(define_insn "*one_cmpldi2_2_rex64"
10728 [(set (reg 17)
10729 (compare (not:DI (match_operand:DI 1 "nonimmediate_operand" "0"))
10730 (const_int 0)))
10731 (set (match_operand:DI 0 "nonimmediate_operand" "=rm")
10732 (not:DI (match_dup 1)))]
10733 "TARGET_64BIT && ix86_match_ccmode (insn, CCNOmode)
10734 && ix86_unary_operator_ok (NOT, DImode, operands)"
10735 "#"
10736 [(set_attr "type" "alu1")
10737 (set_attr "mode" "DI")])
10738
10739(define_split
10740 [(set (reg 17)
10741 (compare (not:DI (match_operand:DI 1 "nonimmediate_operand" ""))
10742 (const_int 0)))
10743 (set (match_operand:DI 0 "nonimmediate_operand" "")
10744 (not:DI (match_dup 1)))]
10745 "TARGET_64BIT && ix86_match_ccmode (insn, CCNOmode)"
10746 [(parallel [(set (reg:CCNO 17)
10747 (compare:CCNO (xor:DI (match_dup 1) (const_int -1))
10748 (const_int 0)))
10749 (set (match_dup 0)
10750 (xor:DI (match_dup 1) (const_int -1)))])]
10751 "")
10752
06a964de 10753(define_expand "one_cmplsi2"
a1cbdd7f
JH
10754 [(set (match_operand:SI 0 "nonimmediate_operand" "")
10755 (not:SI (match_operand:SI 1 "nonimmediate_operand" "")))]
06a964de
JH
10756 ""
10757 "ix86_expand_unary_operator (NOT, SImode, operands); DONE;")
10758
10759(define_insn "*one_cmplsi2_1"
2ae0f82c
SC
10760 [(set (match_operand:SI 0 "nonimmediate_operand" "=rm")
10761 (not:SI (match_operand:SI 1 "nonimmediate_operand" "0")))]
a1cbdd7f 10762 "ix86_unary_operator_ok (NOT, SImode, operands)"
0f40f9f7 10763 "not{l}\t%0"
6ef67412
JH
10764 [(set_attr "type" "negnot")
10765 (set_attr "mode" "SI")])
bb524860 10766
9b70259d
JH
10767;; ??? Currently never generated - xor is used instead.
10768(define_insn "*one_cmplsi2_1_zext"
10769 [(set (match_operand:DI 0 "register_operand" "=r")
10770 (zero_extend:DI (not:SI (match_operand:SI 1 "register_operand" "0"))))]
10771 "TARGET_64BIT && ix86_unary_operator_ok (NOT, SImode, operands)"
0f40f9f7 10772 "not{l}\t%k0"
9b70259d
JH
10773 [(set_attr "type" "negnot")
10774 (set_attr "mode" "SI")])
10775
06a964de 10776(define_insn "*one_cmplsi2_2"
16189740
RH
10777 [(set (reg 17)
10778 (compare (not:SI (match_operand:SI 1 "nonimmediate_operand" "0"))
10779 (const_int 0)))
e075ae69
RH
10780 (set (match_operand:SI 0 "nonimmediate_operand" "=rm")
10781 (not:SI (match_dup 1)))]
16189740
RH
10782 "ix86_match_ccmode (insn, CCNOmode)
10783 && ix86_unary_operator_ok (NOT, SImode, operands)"
e075ae69 10784 "#"
6ef67412
JH
10785 [(set_attr "type" "alu1")
10786 (set_attr "mode" "SI")])
e075ae69
RH
10787
10788(define_split
16189740
RH
10789 [(set (reg 17)
10790 (compare (not:SI (match_operand:SI 1 "nonimmediate_operand" ""))
10791 (const_int 0)))
e075ae69
RH
10792 (set (match_operand:SI 0 "nonimmediate_operand" "")
10793 (not:SI (match_dup 1)))]
16189740 10794 "ix86_match_ccmode (insn, CCNOmode)"
e075ae69
RH
10795 [(parallel [(set (reg:CCNO 17)
10796 (compare:CCNO (xor:SI (match_dup 1) (const_int -1))
10797 (const_int 0)))
10798 (set (match_dup 0)
10799 (xor:SI (match_dup 1) (const_int -1)))])]
10800 "")
886c62d1 10801
9b70259d
JH
10802;; ??? Currently never generated - xor is used instead.
10803(define_insn "*one_cmplsi2_2_zext"
10804 [(set (reg 17)
10805 (compare (not:SI (match_operand:SI 1 "register_operand" "0"))
10806 (const_int 0)))
10807 (set (match_operand:DI 0 "register_operand" "=r")
10808 (zero_extend:DI (not:SI (match_dup 1))))]
10809 "TARGET_64BIT && ix86_match_ccmode (insn, CCNOmode)
10810 && ix86_unary_operator_ok (NOT, SImode, operands)"
10811 "#"
10812 [(set_attr "type" "alu1")
10813 (set_attr "mode" "SI")])
10814
10815(define_split
10816 [(set (reg 17)
10817 (compare (not:SI (match_operand:SI 1 "register_operand" ""))
10818 (const_int 0)))
10819 (set (match_operand:DI 0 "register_operand" "")
10820 (zero_extend:DI (not:SI (match_dup 1))))]
10821 "ix86_match_ccmode (insn, CCNOmode)"
10822 [(parallel [(set (reg:CCNO 17)
10823 (compare:CCNO (xor:SI (match_dup 1) (const_int -1))
10824 (const_int 0)))
10825 (set (match_dup 0)
10826 (zero_extend:DI (xor:SI (match_dup 1) (const_int -1))))])]
10827 "")
10828
06a964de 10829(define_expand "one_cmplhi2"
a1cbdd7f
JH
10830 [(set (match_operand:HI 0 "nonimmediate_operand" "")
10831 (not:HI (match_operand:HI 1 "nonimmediate_operand" "")))]
d9f32422 10832 "TARGET_HIMODE_MATH"
06a964de
JH
10833 "ix86_expand_unary_operator (NOT, HImode, operands); DONE;")
10834
10835(define_insn "*one_cmplhi2_1"
2ae0f82c
SC
10836 [(set (match_operand:HI 0 "nonimmediate_operand" "=rm")
10837 (not:HI (match_operand:HI 1 "nonimmediate_operand" "0")))]
a1cbdd7f 10838 "ix86_unary_operator_ok (NOT, HImode, operands)"
0f40f9f7 10839 "not{w}\t%0"
6ef67412
JH
10840 [(set_attr "type" "negnot")
10841 (set_attr "mode" "HI")])
bb524860 10842
06a964de 10843(define_insn "*one_cmplhi2_2"
16189740
RH
10844 [(set (reg 17)
10845 (compare (not:HI (match_operand:HI 1 "nonimmediate_operand" "0"))
10846 (const_int 0)))
e075ae69
RH
10847 (set (match_operand:HI 0 "nonimmediate_operand" "=rm")
10848 (not:HI (match_dup 1)))]
16189740
RH
10849 "ix86_match_ccmode (insn, CCNOmode)
10850 && ix86_unary_operator_ok (NEG, HImode, operands)"
e075ae69 10851 "#"
6ef67412
JH
10852 [(set_attr "type" "alu1")
10853 (set_attr "mode" "HI")])
e075ae69
RH
10854
10855(define_split
16189740
RH
10856 [(set (reg 17)
10857 (compare (not:HI (match_operand:HI 1 "nonimmediate_operand" ""))
10858 (const_int 0)))
e075ae69
RH
10859 (set (match_operand:HI 0 "nonimmediate_operand" "")
10860 (not:HI (match_dup 1)))]
16189740 10861 "ix86_match_ccmode (insn, CCNOmode)"
e075ae69
RH
10862 [(parallel [(set (reg:CCNO 17)
10863 (compare:CCNO (xor:HI (match_dup 1) (const_int -1))
10864 (const_int 0)))
10865 (set (match_dup 0)
10866 (xor:HI (match_dup 1) (const_int -1)))])]
10867 "")
886c62d1 10868
e075ae69 10869;; %%% Potential partial reg stall on alternative 1. What to do?
06a964de 10870(define_expand "one_cmplqi2"
a1cbdd7f
JH
10871 [(set (match_operand:QI 0 "nonimmediate_operand" "")
10872 (not:QI (match_operand:QI 1 "nonimmediate_operand" "")))]
d9f32422 10873 "TARGET_QIMODE_MATH"
06a964de
JH
10874 "ix86_expand_unary_operator (NOT, QImode, operands); DONE;")
10875
10876(define_insn "*one_cmplqi2_1"
7c6b971d 10877 [(set (match_operand:QI 0 "nonimmediate_operand" "=qm,r")
e075ae69 10878 (not:QI (match_operand:QI 1 "nonimmediate_operand" "0,0")))]
a1cbdd7f 10879 "ix86_unary_operator_ok (NOT, QImode, operands)"
e075ae69 10880 "@
0f40f9f7
ZW
10881 not{b}\t%0
10882 not{l}\t%k0"
6ef67412
JH
10883 [(set_attr "type" "negnot")
10884 (set_attr "mode" "QI,SI")])
bb524860 10885
06a964de 10886(define_insn "*one_cmplqi2_2"
16189740
RH
10887 [(set (reg 17)
10888 (compare (not:QI (match_operand:QI 1 "nonimmediate_operand" "0"))
10889 (const_int 0)))
e075ae69
RH
10890 (set (match_operand:QI 0 "nonimmediate_operand" "=qm")
10891 (not:QI (match_dup 1)))]
16189740
RH
10892 "ix86_match_ccmode (insn, CCNOmode)
10893 && ix86_unary_operator_ok (NOT, QImode, operands)"
e075ae69 10894 "#"
6ef67412
JH
10895 [(set_attr "type" "alu1")
10896 (set_attr "mode" "QI")])
e075ae69
RH
10897
10898(define_split
16189740
RH
10899 [(set (reg 17)
10900 (compare (not:QI (match_operand:QI 1 "nonimmediate_operand" ""))
10901 (const_int 0)))
e075ae69
RH
10902 (set (match_operand:QI 0 "nonimmediate_operand" "")
10903 (not:QI (match_dup 1)))]
16189740 10904 "ix86_match_ccmode (insn, CCNOmode)"
e075ae69
RH
10905 [(parallel [(set (reg:CCNO 17)
10906 (compare:CCNO (xor:QI (match_dup 1) (const_int -1))
10907 (const_int 0)))
10908 (set (match_dup 0)
10909 (xor:QI (match_dup 1) (const_int -1)))])]
10910 "")
886c62d1 10911\f
e075ae69 10912;; Arithmetic shift instructions
886c62d1
JVA
10913
10914;; DImode shifts are implemented using the i386 "shift double" opcode,
10915;; which is written as "sh[lr]d[lw] imm,reg,reg/mem". If the shift count
10916;; is variable, then the count is in %cl and the "imm" operand is dropped
10917;; from the assembler input.
e075ae69 10918;;
886c62d1
JVA
10919;; This instruction shifts the target reg/mem as usual, but instead of
10920;; shifting in zeros, bits are shifted in from reg operand. If the insn
10921;; is a left shift double, bits are taken from the high order bits of
10922;; reg, else if the insn is a shift right double, bits are taken from the
10923;; low order bits of reg. So if %eax is "1234" and %edx is "5678",
10924;; "shldl $8,%edx,%eax" leaves %edx unchanged and sets %eax to "2345".
e075ae69 10925;;
886c62d1
JVA
10926;; Since sh[lr]d does not change the `reg' operand, that is done
10927;; separately, making all shifts emit pairs of shift double and normal
10928;; shift. Since sh[lr]d does not shift more than 31 bits, and we wish to
10929;; support a 63 bit shift, each shift where the count is in a reg expands
f58acb67 10930;; to a pair of shifts, a branch, a shift by 32 and a label.
e075ae69 10931;;
886c62d1
JVA
10932;; If the shift count is a constant, we need never emit more than one
10933;; shift pair, instead using moves and sign extension for counts greater
10934;; than 31.
10935
56c0e8fa 10936(define_expand "ashldi3"
371bc54b
JH
10937 [(parallel [(set (match_operand:DI 0 "shiftdi_operand" "")
10938 (ashift:DI (match_operand:DI 1 "shiftdi_operand" "")
3d117b30 10939 (match_operand:QI 2 "nonmemory_operand" "")))
e075ae69 10940 (clobber (reg:CC 17))])]
56c0e8fa 10941 ""
56c0e8fa 10942{
3d117b30 10943 if (!TARGET_64BIT && TARGET_CMOVE && ! immediate_operand (operands[2], QImode))
56c0e8fa 10944 {
e075ae69
RH
10945 emit_insn (gen_ashldi3_1 (operands[0], operands[1], operands[2]));
10946 DONE;
56c0e8fa 10947 }
371bc54b
JH
10948 ix86_expand_binary_operator (ASHIFT, DImode, operands);
10949 DONE;
0f40f9f7 10950})
56c0e8fa 10951
371bc54b
JH
10952(define_insn "*ashldi3_1_rex64"
10953 [(set (match_operand:DI 0 "nonimmediate_operand" "=rm,r")
10954 (ashift:DI (match_operand:DI 1 "nonimmediate_operand" "0,r")
7c17f553 10955 (match_operand:QI 2 "nonmemory_operand" "cJ,M")))
371bc54b
JH
10956 (clobber (reg:CC 17))]
10957 "TARGET_64BIT && ix86_binary_operator_ok (ASHIFT, DImode, operands)"
371bc54b
JH
10958{
10959 switch (get_attr_type (insn))
10960 {
10961 case TYPE_ALU:
10962 if (operands[2] != const1_rtx)
10963 abort ();
10964 if (!rtx_equal_p (operands[0], operands[1]))
10965 abort ();
0f40f9f7 10966 return "add{q}\t{%0, %0|%0, %0}";
371bc54b
JH
10967
10968 case TYPE_LEA:
10969 if (GET_CODE (operands[2]) != CONST_INT
10970 || (unsigned HOST_WIDE_INT) INTVAL (operands[2]) > 3)
10971 abort ();
10972 operands[1] = gen_rtx_MULT (DImode, operands[1],
10973 GEN_INT (1 << INTVAL (operands[2])));
0f40f9f7 10974 return "lea{q}\t{%a1, %0|%0, %a1}";
371bc54b
JH
10975
10976 default:
10977 if (REG_P (operands[2]))
0f40f9f7 10978 return "sal{q}\t{%b2, %0|%0, %b2}";
371bc54b
JH
10979 else if (GET_CODE (operands[2]) == CONST_INT
10980 && INTVAL (operands[2]) == 1
495333a6 10981 && (TARGET_SHIFT1 || optimize_size))
0f40f9f7 10982 return "sal{q}\t%0";
371bc54b 10983 else
0f40f9f7 10984 return "sal{q}\t{%2, %0|%0, %2}";
371bc54b 10985 }
0f40f9f7 10986}
371bc54b
JH
10987 [(set (attr "type")
10988 (cond [(eq_attr "alternative" "1")
10989 (const_string "lea")
10990 (and (and (ne (symbol_ref "TARGET_DOUBLE_WITH_ADD")
10991 (const_int 0))
10992 (match_operand 0 "register_operand" ""))
10993 (match_operand 2 "const1_operand" ""))
10994 (const_string "alu")
10995 ]
10996 (const_string "ishift")))
10997 (set_attr "mode" "DI")])
10998
10999;; Convert lea to the lea pattern to avoid flags dependency.
11000(define_split
11001 [(set (match_operand:DI 0 "register_operand" "")
11002 (ashift:DI (match_operand:DI 1 "register_operand" "")
11003 (match_operand:QI 2 "immediate_operand" "")))
11004 (clobber (reg:CC 17))]
1b0c37d7 11005 "TARGET_64BIT && reload_completed
371bc54b
JH
11006 && true_regnum (operands[0]) != true_regnum (operands[1])"
11007 [(set (match_dup 0)
11008 (mult:DI (match_dup 1)
11009 (match_dup 2)))]
d8bf17f9 11010 "operands[2] = gen_int_mode (1 << INTVAL (operands[2]), DImode);")
371bc54b
JH
11011
11012;; This pattern can't accept a variable shift count, since shifts by
11013;; zero don't affect the flags. We assume that shifts by constant
11014;; zero are optimized away.
11015(define_insn "*ashldi3_cmp_rex64"
11016 [(set (reg 17)
11017 (compare
11018 (ashift:DI (match_operand:DI 1 "nonimmediate_operand" "0")
11019 (match_operand:QI 2 "immediate_operand" "e"))
11020 (const_int 0)))
11021 (set (match_operand:DI 0 "nonimmediate_operand" "=rm")
11022 (ashift:DI (match_dup 1) (match_dup 2)))]
11023 "TARGET_64BIT && ix86_match_ccmode (insn, CCGOCmode)
11024 && ix86_binary_operator_ok (ASHIFT, DImode, operands)"
371bc54b
JH
11025{
11026 switch (get_attr_type (insn))
11027 {
11028 case TYPE_ALU:
11029 if (operands[2] != const1_rtx)
11030 abort ();
0f40f9f7 11031 return "add{q}\t{%0, %0|%0, %0}";
371bc54b
JH
11032
11033 default:
11034 if (REG_P (operands[2]))
0f40f9f7 11035 return "sal{q}\t{%b2, %0|%0, %b2}";
371bc54b
JH
11036 else if (GET_CODE (operands[2]) == CONST_INT
11037 && INTVAL (operands[2]) == 1
495333a6 11038 && (TARGET_SHIFT1 || optimize_size))
0f40f9f7 11039 return "sal{q}\t%0";
371bc54b 11040 else
0f40f9f7 11041 return "sal{q}\t{%2, %0|%0, %2}";
371bc54b 11042 }
0f40f9f7 11043}
371bc54b
JH
11044 [(set (attr "type")
11045 (cond [(and (and (ne (symbol_ref "TARGET_DOUBLE_WITH_ADD")
11046 (const_int 0))
11047 (match_operand 0 "register_operand" ""))
11048 (match_operand 2 "const1_operand" ""))
11049 (const_string "alu")
11050 ]
11051 (const_string "ishift")))
11052 (set_attr "mode" "DI")])
11053
e075ae69
RH
11054(define_insn "ashldi3_1"
11055 [(set (match_operand:DI 0 "register_operand" "=r")
56c0e8fa 11056 (ashift:DI (match_operand:DI 1 "register_operand" "0")
e075ae69
RH
11057 (match_operand:QI 2 "nonmemory_operand" "Jc")))
11058 (clobber (match_scratch:SI 3 "=&r"))
11059 (clobber (reg:CC 17))]
371bc54b 11060 "!TARGET_64BIT && TARGET_CMOVE"
e075ae69
RH
11061 "#"
11062 [(set_attr "type" "multi")])
886c62d1 11063
e075ae69
RH
11064(define_insn "*ashldi3_2"
11065 [(set (match_operand:DI 0 "register_operand" "=r")
56c0e8fa 11066 (ashift:DI (match_operand:DI 1 "register_operand" "0")
e075ae69
RH
11067 (match_operand:QI 2 "nonmemory_operand" "Jc")))
11068 (clobber (reg:CC 17))]
371bc54b 11069 "!TARGET_64BIT"
e075ae69
RH
11070 "#"
11071 [(set_attr "type" "multi")])
886c62d1 11072
e075ae69
RH
11073(define_split
11074 [(set (match_operand:DI 0 "register_operand" "")
11075 (ashift:DI (match_operand:DI 1 "register_operand" "")
11076 (match_operand:QI 2 "nonmemory_operand" "")))
11077 (clobber (match_scratch:SI 3 ""))
11078 (clobber (reg:CC 17))]
371bc54b 11079 "!TARGET_64BIT && TARGET_CMOVE && reload_completed"
e075ae69
RH
11080 [(const_int 0)]
11081 "ix86_split_ashldi (operands, operands[3]); DONE;")
47f59fd4 11082
e075ae69
RH
11083(define_split
11084 [(set (match_operand:DI 0 "register_operand" "")
11085 (ashift:DI (match_operand:DI 1 "register_operand" "")
11086 (match_operand:QI 2 "nonmemory_operand" "")))
11087 (clobber (reg:CC 17))]
371bc54b 11088 "!TARGET_64BIT && reload_completed"
e075ae69
RH
11089 [(const_int 0)]
11090 "ix86_split_ashldi (operands, NULL_RTX); DONE;")
6ec6d558 11091
e075ae69
RH
11092(define_insn "x86_shld_1"
11093 [(set (match_operand:SI 0 "nonimmediate_operand" "+r*m,r*m")
11094 (ior:SI (ashift:SI (match_dup 0)
11095 (match_operand:QI 2 "nonmemory_operand" "I,c"))
11096 (lshiftrt:SI (match_operand:SI 1 "register_operand" "r,r")
11097 (minus:QI (const_int 32) (match_dup 2)))))
11098 (clobber (reg:CC 17))]
6ec6d558 11099 ""
e075ae69 11100 "@
0f40f9f7
ZW
11101 shld{l}\t{%2, %1, %0|%0, %1, %2}
11102 shld{l}\t{%s2%1, %0|%0, %1, %2}"
e075ae69 11103 [(set_attr "type" "ishift")
6ef67412
JH
11104 (set_attr "prefix_0f" "1")
11105 (set_attr "mode" "SI")
e075ae69 11106 (set_attr "pent_pair" "np")
309ada50 11107 (set_attr "athlon_decode" "vector")
e075ae69
RH
11108 (set_attr "ppro_uops" "few")])
11109
11110(define_expand "x86_shift_adj_1"
16189740
RH
11111 [(set (reg:CCZ 17)
11112 (compare:CCZ (and:QI (match_operand:QI 2 "register_operand" "")
11113 (const_int 32))
11114 (const_int 0)))
e075ae69 11115 (set (match_operand:SI 0 "register_operand" "")
16189740 11116 (if_then_else:SI (ne (reg:CCZ 17) (const_int 0))
e075ae69
RH
11117 (match_operand:SI 1 "register_operand" "")
11118 (match_dup 0)))
11119 (set (match_dup 1)
16189740 11120 (if_then_else:SI (ne (reg:CCZ 17) (const_int 0))
e075ae69
RH
11121 (match_operand:SI 3 "register_operand" "r")
11122 (match_dup 1)))]
11123 "TARGET_CMOVE"
6ec6d558
JH
11124 "")
11125
e075ae69
RH
11126(define_expand "x86_shift_adj_2"
11127 [(use (match_operand:SI 0 "register_operand" ""))
11128 (use (match_operand:SI 1 "register_operand" ""))
11129 (use (match_operand:QI 2 "register_operand" ""))]
886c62d1 11130 ""
e075ae69
RH
11131{
11132 rtx label = gen_label_rtx ();
11133 rtx tmp;
886c62d1 11134
16189740 11135 emit_insn (gen_testqi_ccz_1 (operands[2], GEN_INT (32)));
886c62d1 11136
16189740 11137 tmp = gen_rtx_REG (CCZmode, FLAGS_REG);
e075ae69
RH
11138 tmp = gen_rtx_EQ (VOIDmode, tmp, const0_rtx);
11139 tmp = gen_rtx_IF_THEN_ELSE (VOIDmode, tmp,
11140 gen_rtx_LABEL_REF (VOIDmode, label),
11141 pc_rtx);
11142 tmp = emit_jump_insn (gen_rtx_SET (VOIDmode, pc_rtx, tmp));
11143 JUMP_LABEL (tmp) = label;
886c62d1 11144
e075ae69
RH
11145 emit_move_insn (operands[0], operands[1]);
11146 emit_move_insn (operands[1], const0_rtx);
886c62d1 11147
e075ae69
RH
11148 emit_label (label);
11149 LABEL_NUSES (label) = 1;
56c0e8fa
JVA
11150
11151 DONE;
0f40f9f7 11152})
56c0e8fa 11153
d525dfdf
JH
11154(define_expand "ashlsi3"
11155 [(set (match_operand:SI 0 "nonimmediate_operand" "")
11156 (ashift:SI (match_operand:SI 1 "nonimmediate_operand" "")
11157 (match_operand:QI 2 "nonmemory_operand" "")))
11158 (clobber (reg:CC 17))]
11159 ""
11160 "ix86_expand_binary_operator (ASHIFT, SImode, operands); DONE;")
11161
11162(define_insn "*ashlsi3_1"
e075ae69
RH
11163 [(set (match_operand:SI 0 "nonimmediate_operand" "=rm,r")
11164 (ashift:SI (match_operand:SI 1 "nonimmediate_operand" "0,r")
11165 (match_operand:QI 2 "nonmemory_operand" "cI,M")))
11166 (clobber (reg:CC 17))]
d525dfdf 11167 "ix86_binary_operator_ok (ASHIFT, SImode, operands)"
2ae0f82c 11168{
e075ae69
RH
11169 switch (get_attr_type (insn))
11170 {
11171 case TYPE_ALU:
11172 if (operands[2] != const1_rtx)
11173 abort ();
11174 if (!rtx_equal_p (operands[0], operands[1]))
11175 abort ();
0f40f9f7 11176 return "add{l}\t{%0, %0|%0, %0}";
2ae0f82c 11177
e075ae69 11178 case TYPE_LEA:
0f40f9f7 11179 return "#";
2ae0f82c 11180
e075ae69
RH
11181 default:
11182 if (REG_P (operands[2]))
0f40f9f7 11183 return "sal{l}\t{%b2, %0|%0, %b2}";
8bad7136
JL
11184 else if (GET_CODE (operands[2]) == CONST_INT
11185 && INTVAL (operands[2]) == 1
495333a6 11186 && (TARGET_SHIFT1 || optimize_size))
0f40f9f7 11187 return "sal{l}\t%0";
e075ae69 11188 else
0f40f9f7 11189 return "sal{l}\t{%2, %0|%0, %2}";
e075ae69 11190 }
0f40f9f7 11191}
e075ae69
RH
11192 [(set (attr "type")
11193 (cond [(eq_attr "alternative" "1")
11194 (const_string "lea")
11195 (and (and (ne (symbol_ref "TARGET_DOUBLE_WITH_ADD")
11196 (const_int 0))
11197 (match_operand 0 "register_operand" ""))
11198 (match_operand 2 "const1_operand" ""))
11199 (const_string "alu")
11200 ]
6ef67412
JH
11201 (const_string "ishift")))
11202 (set_attr "mode" "SI")])
e075ae69 11203
1c27d4b2
JH
11204;; Convert lea to the lea pattern to avoid flags dependency.
11205(define_split
58787064 11206 [(set (match_operand 0 "register_operand" "")
7ec70495 11207 (ashift (match_operand 1 "index_register_operand" "")
ca4ae08d 11208 (match_operand:QI 2 "const_int_operand" "")))
1c27d4b2 11209 (clobber (reg:CC 17))]
abe24fb3
JH
11210 "reload_completed
11211 && true_regnum (operands[0]) != true_regnum (operands[1])"
58787064 11212 [(const_int 0)]
58787064
JH
11213{
11214 rtx pat;
11215 operands[0] = gen_lowpart (SImode, operands[0]);
11216 operands[1] = gen_lowpart (Pmode, operands[1]);
d8bf17f9 11217 operands[2] = gen_int_mode (1 << INTVAL (operands[2]), Pmode);
58787064
JH
11218 pat = gen_rtx_MULT (Pmode, operands[1], operands[2]);
11219 if (Pmode != SImode)
11220 pat = gen_rtx_SUBREG (SImode, pat, 0);
11221 emit_insn (gen_rtx_SET (VOIDmode, operands[0], pat));
11222 DONE;
0f40f9f7 11223})
1c27d4b2 11224
7ec70495
JH
11225;; Rare case of shifting RSP is handled by generating move and shift
11226(define_split
11227 [(set (match_operand 0 "register_operand" "")
11228 (ashift (match_operand 1 "register_operand" "")
11229 (match_operand:QI 2 "const_int_operand" "")))
11230 (clobber (reg:CC 17))]
11231 "reload_completed
11232 && true_regnum (operands[0]) != true_regnum (operands[1])"
11233 [(const_int 0)]
11234{
11235 rtx pat, clob;
11236 emit_move_insn (operands[1], operands[0]);
11237 pat = gen_rtx_SET (VOIDmode, operands[0],
11238 gen_rtx_ASHIFT (GET_MODE (operands[0]),
11239 operands[0], operands[2]));
11240 clob = gen_rtx_CLOBBER (VOIDmode, gen_rtx_REG (CCmode, FLAGS_REG));
11241 emit_insn (gen_rtx_PARALLEL (VOIDmode, gen_rtvec (2, pat, clob)));
11242 DONE;
11243})
11244
371bc54b
JH
11245(define_insn "*ashlsi3_1_zext"
11246 [(set (match_operand:DI 0 "register_operand" "=r,r")
11247 (zero_extend:DI (ashift:SI (match_operand:SI 1 "register_operand" "0,r")
11248 (match_operand:QI 2 "nonmemory_operand" "cI,M"))))
11249 (clobber (reg:CC 17))]
1b0c37d7 11250 "TARGET_64BIT && ix86_binary_operator_ok (ASHIFT, SImode, operands)"
371bc54b
JH
11251{
11252 switch (get_attr_type (insn))
11253 {
11254 case TYPE_ALU:
11255 if (operands[2] != const1_rtx)
11256 abort ();
0f40f9f7 11257 return "add{l}\t{%k0, %k0|%k0, %k0}";
371bc54b
JH
11258
11259 case TYPE_LEA:
0f40f9f7 11260 return "#";
371bc54b
JH
11261
11262 default:
11263 if (REG_P (operands[2]))
0f40f9f7 11264 return "sal{l}\t{%b2, %k0|%k0, %b2}";
371bc54b
JH
11265 else if (GET_CODE (operands[2]) == CONST_INT
11266 && INTVAL (operands[2]) == 1
495333a6 11267 && (TARGET_SHIFT1 || optimize_size))
0f40f9f7 11268 return "sal{l}\t%k0";
371bc54b 11269 else
0f40f9f7 11270 return "sal{l}\t{%2, %k0|%k0, %2}";
371bc54b 11271 }
0f40f9f7 11272}
371bc54b
JH
11273 [(set (attr "type")
11274 (cond [(eq_attr "alternative" "1")
11275 (const_string "lea")
11276 (and (ne (symbol_ref "TARGET_DOUBLE_WITH_ADD")
11277 (const_int 0))
11278 (match_operand 2 "const1_operand" ""))
11279 (const_string "alu")
11280 ]
11281 (const_string "ishift")))
11282 (set_attr "mode" "SI")])
11283
11284;; Convert lea to the lea pattern to avoid flags dependency.
11285(define_split
11286 [(set (match_operand:DI 0 "register_operand" "")
11287 (zero_extend:DI (ashift (match_operand 1 "register_operand" "")
11288 (match_operand:QI 2 "const_int_operand" ""))))
11289 (clobber (reg:CC 17))]
bc8a6d63 11290 "TARGET_64BIT && reload_completed
371bc54b 11291 && true_regnum (operands[0]) != true_regnum (operands[1])"
bc8a6d63
RH
11292 [(set (match_dup 0) (zero_extend:DI
11293 (subreg:SI (mult:SI (match_dup 1)
11294 (match_dup 2)) 0)))]
371bc54b
JH
11295{
11296 operands[1] = gen_lowpart (Pmode, operands[1]);
d8bf17f9 11297 operands[2] = gen_int_mode (1 << INTVAL (operands[2]), Pmode);
0f40f9f7 11298})
371bc54b 11299
28cefcd2
BS
11300;; This pattern can't accept a variable shift count, since shifts by
11301;; zero don't affect the flags. We assume that shifts by constant
11302;; zero are optimized away.
2c873473 11303(define_insn "*ashlsi3_cmp"
16189740
RH
11304 [(set (reg 17)
11305 (compare
e075ae69 11306 (ashift:SI (match_operand:SI 1 "nonimmediate_operand" "0")
794a292d 11307 (match_operand:QI 2 "const_int_1_31_operand" "I"))
e075ae69
RH
11308 (const_int 0)))
11309 (set (match_operand:SI 0 "nonimmediate_operand" "=rm")
11310 (ashift:SI (match_dup 1) (match_dup 2)))]
9076b9c1 11311 "ix86_match_ccmode (insn, CCGOCmode)
16189740 11312 && ix86_binary_operator_ok (ASHIFT, SImode, operands)"
886c62d1 11313{
e075ae69 11314 switch (get_attr_type (insn))
886c62d1 11315 {
e075ae69
RH
11316 case TYPE_ALU:
11317 if (operands[2] != const1_rtx)
11318 abort ();
0f40f9f7 11319 return "add{l}\t{%0, %0|%0, %0}";
886c62d1 11320
e075ae69
RH
11321 default:
11322 if (REG_P (operands[2]))
0f40f9f7 11323 return "sal{l}\t{%b2, %0|%0, %b2}";
8bad7136
JL
11324 else if (GET_CODE (operands[2]) == CONST_INT
11325 && INTVAL (operands[2]) == 1
495333a6 11326 && (TARGET_SHIFT1 || optimize_size))
0f40f9f7 11327 return "sal{l}\t%0";
e075ae69 11328 else
0f40f9f7 11329 return "sal{l}\t{%2, %0|%0, %2}";
56c0e8fa 11330 }
0f40f9f7 11331}
e075ae69
RH
11332 [(set (attr "type")
11333 (cond [(and (and (ne (symbol_ref "TARGET_DOUBLE_WITH_ADD")
11334 (const_int 0))
11335 (match_operand 0 "register_operand" ""))
11336 (match_operand 2 "const1_operand" ""))
11337 (const_string "alu")
11338 ]
6ef67412
JH
11339 (const_string "ishift")))
11340 (set_attr "mode" "SI")])
e075ae69 11341
371bc54b
JH
11342(define_insn "*ashlsi3_cmp_zext"
11343 [(set (reg 17)
11344 (compare
11345 (ashift:SI (match_operand:SI 1 "register_operand" "0")
794a292d 11346 (match_operand:QI 2 "const_int_1_31_operand" "I"))
371bc54b
JH
11347 (const_int 0)))
11348 (set (match_operand:DI 0 "register_operand" "=r")
11349 (zero_extend:DI (ashift:SI (match_dup 1) (match_dup 2))))]
11350 "TARGET_64BIT && ix86_match_ccmode (insn, CCGOCmode)
11351 && ix86_binary_operator_ok (ASHIFT, SImode, operands)"
371bc54b
JH
11352{
11353 switch (get_attr_type (insn))
11354 {
11355 case TYPE_ALU:
11356 if (operands[2] != const1_rtx)
11357 abort ();
0f40f9f7 11358 return "add{l}\t{%k0, %k0|%k0, %k0}";
371bc54b
JH
11359
11360 default:
11361 if (REG_P (operands[2]))
0f40f9f7 11362 return "sal{l}\t{%b2, %k0|%k0, %b2}";
371bc54b
JH
11363 else if (GET_CODE (operands[2]) == CONST_INT
11364 && INTVAL (operands[2]) == 1
495333a6 11365 && (TARGET_SHIFT1 || optimize_size))
0f40f9f7 11366 return "sal{l}\t%k0";
371bc54b 11367 else
0f40f9f7 11368 return "sal{l}\t{%2, %k0|%k0, %2}";
371bc54b 11369 }
0f40f9f7 11370}
371bc54b
JH
11371 [(set (attr "type")
11372 (cond [(and (ne (symbol_ref "TARGET_DOUBLE_WITH_ADD")
11373 (const_int 0))
11374 (match_operand 2 "const1_operand" ""))
11375 (const_string "alu")
11376 ]
11377 (const_string "ishift")))
11378 (set_attr "mode" "SI")])
11379
d525dfdf
JH
11380(define_expand "ashlhi3"
11381 [(set (match_operand:HI 0 "nonimmediate_operand" "")
11382 (ashift:HI (match_operand:HI 1 "nonimmediate_operand" "")
11383 (match_operand:QI 2 "nonmemory_operand" "")))
11384 (clobber (reg:CC 17))]
d9f32422 11385 "TARGET_HIMODE_MATH"
d525dfdf
JH
11386 "ix86_expand_binary_operator (ASHIFT, HImode, operands); DONE;")
11387
58787064
JH
11388(define_insn "*ashlhi3_1_lea"
11389 [(set (match_operand:HI 0 "nonimmediate_operand" "=rm,r")
11390 (ashift:HI (match_operand:HI 1 "nonimmediate_operand" "0,r")
11391 (match_operand:QI 2 "nonmemory_operand" "cI,M")))
11392 (clobber (reg:CC 17))]
11393 "!TARGET_PARTIAL_REG_STALL
11394 && ix86_binary_operator_ok (ASHIFT, HImode, operands)"
58787064
JH
11395{
11396 switch (get_attr_type (insn))
11397 {
11398 case TYPE_LEA:
0f40f9f7 11399 return "#";
58787064
JH
11400 case TYPE_ALU:
11401 if (operands[2] != const1_rtx)
11402 abort ();
0f40f9f7 11403 return "add{w}\t{%0, %0|%0, %0}";
58787064
JH
11404
11405 default:
11406 if (REG_P (operands[2]))
0f40f9f7 11407 return "sal{w}\t{%b2, %0|%0, %b2}";
58787064
JH
11408 else if (GET_CODE (operands[2]) == CONST_INT
11409 && INTVAL (operands[2]) == 1
495333a6 11410 && (TARGET_SHIFT1 || optimize_size))
0f40f9f7 11411 return "sal{w}\t%0";
58787064 11412 else
0f40f9f7 11413 return "sal{w}\t{%2, %0|%0, %2}";
58787064 11414 }
0f40f9f7 11415}
58787064
JH
11416 [(set (attr "type")
11417 (cond [(eq_attr "alternative" "1")
11418 (const_string "lea")
11419 (and (and (ne (symbol_ref "TARGET_DOUBLE_WITH_ADD")
11420 (const_int 0))
11421 (match_operand 0 "register_operand" ""))
11422 (match_operand 2 "const1_operand" ""))
11423 (const_string "alu")
11424 ]
11425 (const_string "ishift")))
11426 (set_attr "mode" "HI,SI")])
11427
d525dfdf 11428(define_insn "*ashlhi3_1"
e075ae69
RH
11429 [(set (match_operand:HI 0 "nonimmediate_operand" "=rm")
11430 (ashift:HI (match_operand:HI 1 "nonimmediate_operand" "0")
11431 (match_operand:QI 2 "nonmemory_operand" "cI")))
11432 (clobber (reg:CC 17))]
58787064
JH
11433 "TARGET_PARTIAL_REG_STALL
11434 && ix86_binary_operator_ok (ASHIFT, HImode, operands)"
56c0e8fa 11435{
e075ae69
RH
11436 switch (get_attr_type (insn))
11437 {
11438 case TYPE_ALU:
11439 if (operands[2] != const1_rtx)
11440 abort ();
0f40f9f7 11441 return "add{w}\t{%0, %0|%0, %0}";
886c62d1 11442
e075ae69
RH
11443 default:
11444 if (REG_P (operands[2]))
0f40f9f7 11445 return "sal{w}\t{%b2, %0|%0, %b2}";
8bad7136
JL
11446 else if (GET_CODE (operands[2]) == CONST_INT
11447 && INTVAL (operands[2]) == 1
495333a6 11448 && (TARGET_SHIFT1 || optimize_size))
0f40f9f7 11449 return "sal{w}\t%0";
e075ae69 11450 else
0f40f9f7 11451 return "sal{w}\t{%2, %0|%0, %2}";
e075ae69 11452 }
0f40f9f7 11453}
e075ae69
RH
11454 [(set (attr "type")
11455 (cond [(and (and (ne (symbol_ref "TARGET_DOUBLE_WITH_ADD")
11456 (const_int 0))
11457 (match_operand 0 "register_operand" ""))
11458 (match_operand 2 "const1_operand" ""))
11459 (const_string "alu")
11460 ]
6ef67412
JH
11461 (const_string "ishift")))
11462 (set_attr "mode" "HI")])
bb62e19a 11463
28cefcd2
BS
11464;; This pattern can't accept a variable shift count, since shifts by
11465;; zero don't affect the flags. We assume that shifts by constant
11466;; zero are optimized away.
2c873473 11467(define_insn "*ashlhi3_cmp"
16189740
RH
11468 [(set (reg 17)
11469 (compare
e075ae69 11470 (ashift:HI (match_operand:HI 1 "nonimmediate_operand" "0")
794a292d 11471 (match_operand:QI 2 "const_int_1_31_operand" "I"))
e075ae69
RH
11472 (const_int 0)))
11473 (set (match_operand:HI 0 "nonimmediate_operand" "=rm")
11474 (ashift:HI (match_dup 1) (match_dup 2)))]
9076b9c1 11475 "ix86_match_ccmode (insn, CCGOCmode)
16189740 11476 && ix86_binary_operator_ok (ASHIFT, HImode, operands)"
886c62d1 11477{
e075ae69
RH
11478 switch (get_attr_type (insn))
11479 {
11480 case TYPE_ALU:
11481 if (operands[2] != const1_rtx)
11482 abort ();
0f40f9f7 11483 return "add{w}\t{%0, %0|%0, %0}";
886c62d1 11484
e075ae69
RH
11485 default:
11486 if (REG_P (operands[2]))
0f40f9f7 11487 return "sal{w}\t{%b2, %0|%0, %b2}";
8bad7136
JL
11488 else if (GET_CODE (operands[2]) == CONST_INT
11489 && INTVAL (operands[2]) == 1
495333a6 11490 && (TARGET_SHIFT1 || optimize_size))
0f40f9f7 11491 return "sal{w}\t%0";
e075ae69 11492 else
0f40f9f7 11493 return "sal{w}\t{%2, %0|%0, %2}";
e075ae69 11494 }
0f40f9f7 11495}
e075ae69
RH
11496 [(set (attr "type")
11497 (cond [(and (and (ne (symbol_ref "TARGET_DOUBLE_WITH_ADD")
11498 (const_int 0))
11499 (match_operand 0 "register_operand" ""))
11500 (match_operand 2 "const1_operand" ""))
11501 (const_string "alu")
11502 ]
6ef67412
JH
11503 (const_string "ishift")))
11504 (set_attr "mode" "HI")])
e075ae69 11505
d525dfdf
JH
11506(define_expand "ashlqi3"
11507 [(set (match_operand:QI 0 "nonimmediate_operand" "")
11508 (ashift:QI (match_operand:QI 1 "nonimmediate_operand" "")
11509 (match_operand:QI 2 "nonmemory_operand" "")))
11510 (clobber (reg:CC 17))]
d9f32422 11511 "TARGET_QIMODE_MATH"
d525dfdf
JH
11512 "ix86_expand_binary_operator (ASHIFT, QImode, operands); DONE;")
11513
e075ae69 11514;; %%% Potential partial reg stall on alternative 2. What to do?
58787064
JH
11515
11516(define_insn "*ashlqi3_1_lea"
11517 [(set (match_operand:QI 0 "nonimmediate_operand" "=qm,r,r")
11518 (ashift:QI (match_operand:QI 1 "nonimmediate_operand" "0,0,r")
91f9a498 11519 (match_operand:QI 2 "nonmemory_operand" "cI,cI,M")))
58787064
JH
11520 (clobber (reg:CC 17))]
11521 "!TARGET_PARTIAL_REG_STALL
11522 && ix86_binary_operator_ok (ASHIFT, QImode, operands)"
58787064
JH
11523{
11524 switch (get_attr_type (insn))
11525 {
11526 case TYPE_LEA:
0f40f9f7 11527 return "#";
58787064
JH
11528 case TYPE_ALU:
11529 if (operands[2] != const1_rtx)
11530 abort ();
1a06f5fe 11531 if (REG_P (operands[1]) && !ANY_QI_REG_P (operands[1]))
0f40f9f7 11532 return "add{l}\t{%k0, %k0|%k0, %k0}";
58787064 11533 else
0f40f9f7 11534 return "add{b}\t{%0, %0|%0, %0}";
58787064
JH
11535
11536 default:
11537 if (REG_P (operands[2]))
11538 {
11539 if (get_attr_mode (insn) == MODE_SI)
0f40f9f7 11540 return "sal{l}\t{%b2, %k0|%k0, %b2}";
58787064 11541 else
0f40f9f7 11542 return "sal{b}\t{%b2, %0|%0, %b2}";
58787064
JH
11543 }
11544 else if (GET_CODE (operands[2]) == CONST_INT
11545 && INTVAL (operands[2]) == 1
495333a6 11546 && (TARGET_SHIFT1 || optimize_size))
58787064
JH
11547 {
11548 if (get_attr_mode (insn) == MODE_SI)
0f40f9f7 11549 return "sal{l}\t%0";
58787064 11550 else
0f40f9f7 11551 return "sal{b}\t%0";
58787064
JH
11552 }
11553 else
11554 {
11555 if (get_attr_mode (insn) == MODE_SI)
0f40f9f7 11556 return "sal{l}\t{%2, %k0|%k0, %2}";
58787064 11557 else
0f40f9f7 11558 return "sal{b}\t{%2, %0|%0, %2}";
58787064
JH
11559 }
11560 }
0f40f9f7 11561}
58787064
JH
11562 [(set (attr "type")
11563 (cond [(eq_attr "alternative" "2")
11564 (const_string "lea")
11565 (and (and (ne (symbol_ref "TARGET_DOUBLE_WITH_ADD")
11566 (const_int 0))
11567 (match_operand 0 "register_operand" ""))
11568 (match_operand 2 "const1_operand" ""))
11569 (const_string "alu")
11570 ]
11571 (const_string "ishift")))
11572 (set_attr "mode" "QI,SI,SI")])
11573
d525dfdf
JH
11574(define_insn "*ashlqi3_1"
11575 [(set (match_operand:QI 0 "nonimmediate_operand" "=qm,r")
e075ae69
RH
11576 (ashift:QI (match_operand:QI 1 "nonimmediate_operand" "0,0")
11577 (match_operand:QI 2 "nonmemory_operand" "cI,cI")))
11578 (clobber (reg:CC 17))]
58787064
JH
11579 "TARGET_PARTIAL_REG_STALL
11580 && ix86_binary_operator_ok (ASHIFT, QImode, operands)"
886c62d1 11581{
e075ae69
RH
11582 switch (get_attr_type (insn))
11583 {
11584 case TYPE_ALU:
11585 if (operands[2] != const1_rtx)
11586 abort ();
1a06f5fe 11587 if (REG_P (operands[1]) && !ANY_QI_REG_P (operands[1]))
0f40f9f7 11588 return "add{l}\t{%k0, %k0|%k0, %k0}";
e075ae69 11589 else
0f40f9f7 11590 return "add{b}\t{%0, %0|%0, %0}";
886c62d1 11591
e075ae69
RH
11592 default:
11593 if (REG_P (operands[2]))
11594 {
1a06f5fe 11595 if (get_attr_mode (insn) == MODE_SI)
0f40f9f7 11596 return "sal{l}\t{%b2, %k0|%k0, %b2}";
e075ae69 11597 else
0f40f9f7 11598 return "sal{b}\t{%b2, %0|%0, %b2}";
e075ae69 11599 }
8bad7136
JL
11600 else if (GET_CODE (operands[2]) == CONST_INT
11601 && INTVAL (operands[2]) == 1
495333a6 11602 && (TARGET_SHIFT1 || optimize_size))
8bad7136 11603 {
1a06f5fe 11604 if (get_attr_mode (insn) == MODE_SI)
0f40f9f7 11605 return "sal{l}\t%0";
8bad7136 11606 else
0f40f9f7 11607 return "sal{b}\t%0";
8bad7136 11608 }
e075ae69
RH
11609 else
11610 {
1a06f5fe 11611 if (get_attr_mode (insn) == MODE_SI)
0f40f9f7 11612 return "sal{l}\t{%2, %k0|%k0, %2}";
e075ae69 11613 else
0f40f9f7 11614 return "sal{b}\t{%2, %0|%0, %2}";
e075ae69
RH
11615 }
11616 }
0f40f9f7 11617}
e075ae69
RH
11618 [(set (attr "type")
11619 (cond [(and (and (ne (symbol_ref "TARGET_DOUBLE_WITH_ADD")
11620 (const_int 0))
11621 (match_operand 0 "register_operand" ""))
11622 (match_operand 2 "const1_operand" ""))
11623 (const_string "alu")
11624 ]
6ef67412
JH
11625 (const_string "ishift")))
11626 (set_attr "mode" "QI,SI")])
e075ae69 11627
28cefcd2
BS
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.
2c873473 11631(define_insn "*ashlqi3_cmp"
16189740
RH
11632 [(set (reg 17)
11633 (compare
e075ae69 11634 (ashift:QI (match_operand:QI 1 "nonimmediate_operand" "0")
794a292d 11635 (match_operand:QI 2 "const_int_1_31_operand" "I"))
e075ae69
RH
11636 (const_int 0)))
11637 (set (match_operand:QI 0 "nonimmediate_operand" "=qm")
11638 (ashift:QI (match_dup 1) (match_dup 2)))]
9076b9c1 11639 "ix86_match_ccmode (insn, CCGOCmode)
16189740 11640 && ix86_binary_operator_ok (ASHIFT, QImode, operands)"
886c62d1 11641{
e075ae69
RH
11642 switch (get_attr_type (insn))
11643 {
11644 case TYPE_ALU:
11645 if (operands[2] != const1_rtx)
11646 abort ();
0f40f9f7 11647 return "add{b}\t{%0, %0|%0, %0}";
e075ae69
RH
11648
11649 default:
11650 if (REG_P (operands[2]))
0f40f9f7 11651 return "sal{b}\t{%b2, %0|%0, %b2}";
8bad7136
JL
11652 else if (GET_CODE (operands[2]) == CONST_INT
11653 && INTVAL (operands[2]) == 1
495333a6 11654 && (TARGET_SHIFT1 || optimize_size))
0f40f9f7 11655 return "sal{b}\t%0";
e075ae69 11656 else
0f40f9f7 11657 return "sal{b}\t{%2, %0|%0, %2}";
e075ae69 11658 }
0f40f9f7 11659}
e075ae69
RH
11660 [(set (attr "type")
11661 (cond [(and (and (ne (symbol_ref "TARGET_DOUBLE_WITH_ADD")
11662 (const_int 0))
11663 (match_operand 0 "register_operand" ""))
11664 (match_operand 2 "const1_operand" ""))
11665 (const_string "alu")
11666 ]
6ef67412
JH
11667 (const_string "ishift")))
11668 (set_attr "mode" "QI")])
886c62d1
JVA
11669
11670;; See comment above `ashldi3' about how this works.
11671
e075ae69 11672(define_expand "ashrdi3"
371bc54b
JH
11673 [(parallel [(set (match_operand:DI 0 "shiftdi_operand" "")
11674 (ashiftrt:DI (match_operand:DI 1 "shiftdi_operand" "")
11675 (match_operand:QI 2 "nonmemory_operand" "")))
e075ae69 11676 (clobber (reg:CC 17))])]
56c0e8fa 11677 ""
56c0e8fa 11678{
371bc54b 11679 if (!TARGET_64BIT && TARGET_CMOVE && ! immediate_operand (operands[2], QImode))
56c0e8fa 11680 {
e075ae69
RH
11681 emit_insn (gen_ashrdi3_1 (operands[0], operands[1], operands[2]));
11682 DONE;
56c0e8fa 11683 }
371bc54b
JH
11684 ix86_expand_binary_operator (ASHIFTRT, DImode, operands);
11685 DONE;
0f40f9f7 11686})
2ae0f82c 11687
371bc54b
JH
11688(define_insn "ashrdi3_63_rex64"
11689 [(set (match_operand:DI 0 "nonimmediate_operand" "=*d,rm")
11690 (ashiftrt:DI (match_operand:DI 1 "nonimmediate_operand" "*a,0")
11691 (match_operand:DI 2 "const_int_operand" "i,i")))
11692 (clobber (reg:CC 17))]
11693 "TARGET_64BIT && INTVAL (operands[2]) == 63 && (TARGET_USE_CLTD || optimize_size)
11694 && ix86_binary_operator_ok (ASHIFTRT, DImode, operands)"
11695 "@
11696 {cqto|cqo}
0f40f9f7 11697 sar{q}\t{%2, %0|%0, %2}"
371bc54b
JH
11698 [(set_attr "type" "imovx,ishift")
11699 (set_attr "prefix_0f" "0,*")
11700 (set_attr "length_immediate" "0,*")
11701 (set_attr "modrm" "0,1")
11702 (set_attr "mode" "DI")])
11703
11704(define_insn "*ashrdi3_1_one_bit_rex64"
11705 [(set (match_operand:DI 0 "nonimmediate_operand" "=rm")
11706 (ashiftrt:DI (match_operand:DI 1 "nonimmediate_operand" "0")
11707 (match_operand:QI 2 "const_int_1_operand" "")))
11708 (clobber (reg:CC 17))]
11709 "TARGET_64BIT && ix86_binary_operator_ok (ASHIFTRT, DImode, operands)
495333a6 11710 && (TARGET_SHIFT1 || optimize_size)"
0f40f9f7 11711 "sar{q}\t%0"
371bc54b
JH
11712 [(set_attr "type" "ishift")
11713 (set (attr "length")
11714 (if_then_else (match_operand:DI 0 "register_operand" "")
11715 (const_string "2")
11716 (const_string "*")))])
11717
11718(define_insn "*ashrdi3_1_rex64"
11719 [(set (match_operand:DI 0 "nonimmediate_operand" "=rm,rm")
11720 (ashiftrt:DI (match_operand:DI 1 "nonimmediate_operand" "0,0")
7c17f553 11721 (match_operand:QI 2 "nonmemory_operand" "J,c")))
371bc54b
JH
11722 (clobber (reg:CC 17))]
11723 "TARGET_64BIT && ix86_binary_operator_ok (ASHIFTRT, DImode, operands)"
11724 "@
0f40f9f7
ZW
11725 sar{q}\t{%2, %0|%0, %2}
11726 sar{q}\t{%b2, %0|%0, %b2}"
371bc54b
JH
11727 [(set_attr "type" "ishift")
11728 (set_attr "mode" "DI")])
11729
11730;; This pattern can't accept a variable shift count, since shifts by
11731;; zero don't affect the flags. We assume that shifts by constant
11732;; zero are optimized away.
11733(define_insn "*ashrdi3_one_bit_cmp_rex64"
11734 [(set (reg 17)
11735 (compare
11736 (ashiftrt:DI (match_operand:DI 1 "nonimmediate_operand" "0")
11737 (match_operand:QI 2 "const_int_1_operand" ""))
11738 (const_int 0)))
11739 (set (match_operand:DI 0 "nonimmediate_operand" "=rm")
11740 (ashiftrt:DI (match_dup 1) (match_dup 2)))]
11741 "TARGET_64BIT && ix86_match_ccmode (insn, CCGOCmode)
495333a6 11742 && (TARGET_SHIFT1 || optimize_size)
371bc54b 11743 && ix86_binary_operator_ok (ASHIFTRT, DImode, operands)"
0f40f9f7 11744 "sar{q}\t%0"
371bc54b
JH
11745 [(set_attr "type" "ishift")
11746 (set (attr "length")
11747 (if_then_else (match_operand:DI 0 "register_operand" "")
11748 (const_string "2")
11749 (const_string "*")))])
11750
11751;; This pattern can't accept a variable shift count, since shifts by
11752;; zero don't affect the flags. We assume that shifts by constant
11753;; zero are optimized away.
11754(define_insn "*ashrdi3_cmp_rex64"
11755 [(set (reg 17)
11756 (compare
11757 (ashiftrt:DI (match_operand:DI 1 "nonimmediate_operand" "0")
11758 (match_operand:QI 2 "const_int_operand" "n"))
11759 (const_int 0)))
11760 (set (match_operand:DI 0 "nonimmediate_operand" "=rm")
11761 (ashiftrt:DI (match_dup 1) (match_dup 2)))]
11762 "TARGET_64BIT && ix86_match_ccmode (insn, CCGOCmode)
11763 && ix86_binary_operator_ok (ASHIFTRT, DImode, operands)"
0f40f9f7 11764 "sar{q}\t{%2, %0|%0, %2}"
371bc54b
JH
11765 [(set_attr "type" "ishift")
11766 (set_attr "mode" "DI")])
11767
11768
e075ae69
RH
11769(define_insn "ashrdi3_1"
11770 [(set (match_operand:DI 0 "register_operand" "=r")
11771 (ashiftrt:DI (match_operand:DI 1 "register_operand" "0")
11772 (match_operand:QI 2 "nonmemory_operand" "Jc")))
11773 (clobber (match_scratch:SI 3 "=&r"))
11774 (clobber (reg:CC 17))]
371bc54b 11775 "!TARGET_64BIT && TARGET_CMOVE"
e075ae69
RH
11776 "#"
11777 [(set_attr "type" "multi")])
886c62d1 11778
e075ae69
RH
11779(define_insn "*ashrdi3_2"
11780 [(set (match_operand:DI 0 "register_operand" "=r")
11781 (ashiftrt:DI (match_operand:DI 1 "register_operand" "0")
11782 (match_operand:QI 2 "nonmemory_operand" "Jc")))
11783 (clobber (reg:CC 17))]
371bc54b 11784 "!TARGET_64BIT"
e075ae69
RH
11785 "#"
11786 [(set_attr "type" "multi")])
886c62d1 11787
e075ae69
RH
11788(define_split
11789 [(set (match_operand:DI 0 "register_operand" "")
11790 (ashiftrt:DI (match_operand:DI 1 "register_operand" "")
11791 (match_operand:QI 2 "nonmemory_operand" "")))
11792 (clobber (match_scratch:SI 3 ""))
11793 (clobber (reg:CC 17))]
371bc54b 11794 "!TARGET_64BIT && TARGET_CMOVE && reload_completed"
e075ae69
RH
11795 [(const_int 0)]
11796 "ix86_split_ashrdi (operands, operands[3]); DONE;")
886c62d1 11797
e075ae69
RH
11798(define_split
11799 [(set (match_operand:DI 0 "register_operand" "")
11800 (ashiftrt:DI (match_operand:DI 1 "register_operand" "")
11801 (match_operand:QI 2 "nonmemory_operand" "")))
11802 (clobber (reg:CC 17))]
371bc54b 11803 "!TARGET_64BIT && reload_completed"
e075ae69
RH
11804 [(const_int 0)]
11805 "ix86_split_ashrdi (operands, NULL_RTX); DONE;")
886c62d1 11806
e075ae69
RH
11807(define_insn "x86_shrd_1"
11808 [(set (match_operand:SI 0 "nonimmediate_operand" "+r*m,r*m")
11809 (ior:SI (ashiftrt:SI (match_dup 0)
11810 (match_operand:QI 2 "nonmemory_operand" "I,c"))
11811 (ashift:SI (match_operand:SI 1 "register_operand" "r,r")
11812 (minus:QI (const_int 32) (match_dup 2)))))
11813 (clobber (reg:CC 17))]
886c62d1 11814 ""
e075ae69 11815 "@
0f40f9f7
ZW
11816 shrd{l}\t{%2, %1, %0|%0, %1, %2}
11817 shrd{l}\t{%s2%1, %0|%0, %1, %2}"
e075ae69 11818 [(set_attr "type" "ishift")
6ef67412 11819 (set_attr "prefix_0f" "1")
e075ae69 11820 (set_attr "pent_pair" "np")
6ef67412
JH
11821 (set_attr "ppro_uops" "few")
11822 (set_attr "mode" "SI")])
e075ae69
RH
11823
11824(define_expand "x86_shift_adj_3"
11825 [(use (match_operand:SI 0 "register_operand" ""))
11826 (use (match_operand:SI 1 "register_operand" ""))
11827 (use (match_operand:QI 2 "register_operand" ""))]
11828 ""
886c62d1 11829{
e075ae69
RH
11830 rtx label = gen_label_rtx ();
11831 rtx tmp;
11832
16189740 11833 emit_insn (gen_testqi_ccz_1 (operands[2], GEN_INT (32)));
e075ae69 11834
16189740 11835 tmp = gen_rtx_REG (CCZmode, FLAGS_REG);
e075ae69
RH
11836 tmp = gen_rtx_EQ (VOIDmode, tmp, const0_rtx);
11837 tmp = gen_rtx_IF_THEN_ELSE (VOIDmode, tmp,
11838 gen_rtx_LABEL_REF (VOIDmode, label),
11839 pc_rtx);
11840 tmp = emit_jump_insn (gen_rtx_SET (VOIDmode, pc_rtx, tmp));
11841 JUMP_LABEL (tmp) = label;
11842
11843 emit_move_insn (operands[0], operands[1]);
11844 emit_insn (gen_ashrsi3_31 (operands[1], operands[1], GEN_INT (31)));
11845
11846 emit_label (label);
11847 LABEL_NUSES (label) = 1;
11848
11849 DONE;
0f40f9f7 11850})
886c62d1 11851
e075ae69
RH
11852(define_insn "ashrsi3_31"
11853 [(set (match_operand:SI 0 "nonimmediate_operand" "=*d,rm")
11854 (ashiftrt:SI (match_operand:SI 1 "nonimmediate_operand" "*a,0")
11855 (match_operand:SI 2 "const_int_operand" "i,i")))
11856 (clobber (reg:CC 17))]
d525dfdf
JH
11857 "INTVAL (operands[2]) == 31 && (TARGET_USE_CLTD || optimize_size)
11858 && ix86_binary_operator_ok (ASHIFTRT, SImode, operands)"
e075ae69
RH
11859 "@
11860 {cltd|cdq}
0f40f9f7 11861 sar{l}\t{%2, %0|%0, %2}"
6ef67412
JH
11862 [(set_attr "type" "imovx,ishift")
11863 (set_attr "prefix_0f" "0,*")
11864 (set_attr "length_immediate" "0,*")
11865 (set_attr "modrm" "0,1")
11866 (set_attr "mode" "SI")])
e075ae69 11867
371bc54b
JH
11868(define_insn "*ashrsi3_31_zext"
11869 [(set (match_operand:DI 0 "register_operand" "=*d,r")
11870 (zero_extend:DI (ashiftrt:SI (match_operand:SI 1 "register_operand" "*a,0")
11871 (match_operand:SI 2 "const_int_operand" "i,i"))))
11872 (clobber (reg:CC 17))]
1b0c37d7
ZW
11873 "TARGET_64BIT && (TARGET_USE_CLTD || optimize_size)
11874 && INTVAL (operands[2]) == 31
11875 && ix86_binary_operator_ok (ASHIFTRT, SImode, operands)"
371bc54b
JH
11876 "@
11877 {cltd|cdq}
0f40f9f7 11878 sar{l}\t{%2, %k0|%k0, %2}"
371bc54b
JH
11879 [(set_attr "type" "imovx,ishift")
11880 (set_attr "prefix_0f" "0,*")
11881 (set_attr "length_immediate" "0,*")
11882 (set_attr "modrm" "0,1")
11883 (set_attr "mode" "SI")])
11884
d525dfdf
JH
11885(define_expand "ashrsi3"
11886 [(set (match_operand:SI 0 "nonimmediate_operand" "")
155d8a47 11887 (ashiftrt:SI (match_operand:SI 1 "nonimmediate_operand" "")
d525dfdf
JH
11888 (match_operand:QI 2 "nonmemory_operand" "")))
11889 (clobber (reg:CC 17))]
11890 ""
11891 "ix86_expand_binary_operator (ASHIFTRT, SImode, operands); DONE;")
11892
8bad7136
JL
11893(define_insn "*ashrsi3_1_one_bit"
11894 [(set (match_operand:SI 0 "nonimmediate_operand" "=rm")
11895 (ashiftrt:SI (match_operand:SI 1 "nonimmediate_operand" "0")
11896 (match_operand:QI 2 "const_int_1_operand" "")))
11897 (clobber (reg:CC 17))]
11898 "ix86_binary_operator_ok (ASHIFTRT, SImode, operands)
495333a6 11899 && (TARGET_SHIFT1 || optimize_size)"
0f40f9f7 11900 "sar{l}\t%0"
8bad7136
JL
11901 [(set_attr "type" "ishift")
11902 (set (attr "length")
11903 (if_then_else (match_operand:SI 0 "register_operand" "")
11904 (const_string "2")
11905 (const_string "*")))])
11906
371bc54b
JH
11907(define_insn "*ashrsi3_1_one_bit_zext"
11908 [(set (match_operand:DI 0 "register_operand" "=r")
11909 (zero_extend:DI (ashiftrt:SI (match_operand:SI 1 "register_operand" "0")
11910 (match_operand:QI 2 "const_int_1_operand" ""))))
11911 (clobber (reg:CC 17))]
11912 "TARGET_64BIT && ix86_binary_operator_ok (ASHIFTRT, SImode, operands)
495333a6 11913 && (TARGET_SHIFT1 || optimize_size)"
0f40f9f7 11914 "sar{l}\t%k0"
371bc54b
JH
11915 [(set_attr "type" "ishift")
11916 (set_attr "length" "2")])
11917
d525dfdf 11918(define_insn "*ashrsi3_1"
e075ae69
RH
11919 [(set (match_operand:SI 0 "nonimmediate_operand" "=rm,rm")
11920 (ashiftrt:SI (match_operand:SI 1 "nonimmediate_operand" "0,0")
11921 (match_operand:QI 2 "nonmemory_operand" "I,c")))
11922 (clobber (reg:CC 17))]
d525dfdf 11923 "ix86_binary_operator_ok (ASHIFTRT, SImode, operands)"
e075ae69 11924 "@
0f40f9f7
ZW
11925 sar{l}\t{%2, %0|%0, %2}
11926 sar{l}\t{%b2, %0|%0, %b2}"
6ef67412
JH
11927 [(set_attr "type" "ishift")
11928 (set_attr "mode" "SI")])
886c62d1 11929
371bc54b
JH
11930(define_insn "*ashrsi3_1_zext"
11931 [(set (match_operand:DI 0 "register_operand" "=r,r")
11932 (zero_extend:DI (ashiftrt:SI (match_operand:SI 1 "register_operand" "0,0")
11933 (match_operand:QI 2 "nonmemory_operand" "I,c"))))
11934 (clobber (reg:CC 17))]
11935 "TARGET_64BIT && ix86_binary_operator_ok (ASHIFTRT, SImode, operands)"
11936 "@
0f40f9f7
ZW
11937 sar{l}\t{%2, %k0|%k0, %2}
11938 sar{l}\t{%b2, %k0|%k0, %b2}"
371bc54b
JH
11939 [(set_attr "type" "ishift")
11940 (set_attr "mode" "SI")])
11941
8bad7136
JL
11942;; This pattern can't accept a variable shift count, since shifts by
11943;; zero don't affect the flags. We assume that shifts by constant
11944;; zero are optimized away.
2c873473 11945(define_insn "*ashrsi3_one_bit_cmp"
8bad7136
JL
11946 [(set (reg 17)
11947 (compare
11948 (ashiftrt:SI (match_operand:SI 1 "nonimmediate_operand" "0")
11949 (match_operand:QI 2 "const_int_1_operand" ""))
11950 (const_int 0)))
11951 (set (match_operand:SI 0 "nonimmediate_operand" "=rm")
11952 (ashiftrt:SI (match_dup 1) (match_dup 2)))]
2c873473 11953 "ix86_match_ccmode (insn, CCGOCmode)
495333a6 11954 && (TARGET_SHIFT1 || optimize_size)
8bad7136 11955 && ix86_binary_operator_ok (ASHIFTRT, SImode, operands)"
0f40f9f7 11956 "sar{l}\t%0"
8bad7136
JL
11957 [(set_attr "type" "ishift")
11958 (set (attr "length")
11959 (if_then_else (match_operand:SI 0 "register_operand" "")
11960 (const_string "2")
11961 (const_string "*")))])
11962
371bc54b
JH
11963(define_insn "*ashrsi3_one_bit_cmp_zext"
11964 [(set (reg 17)
11965 (compare
11966 (ashiftrt:SI (match_operand:SI 1 "register_operand" "0")
11967 (match_operand:QI 2 "const_int_1_operand" ""))
11968 (const_int 0)))
11969 (set (match_operand:DI 0 "register_operand" "=r")
11970 (zero_extend:DI (ashiftrt:SI (match_dup 1) (match_dup 2))))]
11971 "TARGET_64BIT && ix86_match_ccmode (insn, CCmode)
495333a6 11972 && (TARGET_SHIFT1 || optimize_size)
371bc54b 11973 && ix86_binary_operator_ok (ASHIFTRT, SImode, operands)"
0f40f9f7 11974 "sar{l}\t%k0"
371bc54b
JH
11975 [(set_attr "type" "ishift")
11976 (set_attr "length" "2")])
11977
28cefcd2
BS
11978;; This pattern can't accept a variable shift count, since shifts by
11979;; zero don't affect the flags. We assume that shifts by constant
11980;; zero are optimized away.
2c873473 11981(define_insn "*ashrsi3_cmp"
16189740
RH
11982 [(set (reg 17)
11983 (compare
28cefcd2 11984 (ashiftrt:SI (match_operand:SI 1 "nonimmediate_operand" "0")
794a292d 11985 (match_operand:QI 2 "const_int_1_31_operand" "I"))
e075ae69 11986 (const_int 0)))
28cefcd2 11987 (set (match_operand:SI 0 "nonimmediate_operand" "=rm")
e075ae69 11988 (ashiftrt:SI (match_dup 1) (match_dup 2)))]
2c873473 11989 "ix86_match_ccmode (insn, CCGOCmode)
16189740 11990 && ix86_binary_operator_ok (ASHIFTRT, SImode, operands)"
0f40f9f7 11991 "sar{l}\t{%2, %0|%0, %2}"
6ef67412
JH
11992 [(set_attr "type" "ishift")
11993 (set_attr "mode" "SI")])
886c62d1 11994
371bc54b
JH
11995(define_insn "*ashrsi3_cmp_zext"
11996 [(set (reg 17)
11997 (compare
11998 (ashiftrt:SI (match_operand:SI 1 "register_operand" "0")
794a292d 11999 (match_operand:QI 2 "const_int_1_31_operand" "I"))
371bc54b
JH
12000 (const_int 0)))
12001 (set (match_operand:DI 0 "register_operand" "=r")
12002 (zero_extend:DI (ashiftrt:SI (match_dup 1) (match_dup 2))))]
12003 "TARGET_64BIT && ix86_match_ccmode (insn, CCGOCmode)
12004 && ix86_binary_operator_ok (ASHIFTRT, SImode, operands)"
0f40f9f7 12005 "sar{l}\t{%2, %k0|%k0, %2}"
371bc54b
JH
12006 [(set_attr "type" "ishift")
12007 (set_attr "mode" "SI")])
12008
d525dfdf
JH
12009(define_expand "ashrhi3"
12010 [(set (match_operand:HI 0 "nonimmediate_operand" "")
155d8a47 12011 (ashiftrt:HI (match_operand:HI 1 "nonimmediate_operand" "")
d525dfdf
JH
12012 (match_operand:QI 2 "nonmemory_operand" "")))
12013 (clobber (reg:CC 17))]
d9f32422 12014 "TARGET_HIMODE_MATH"
d525dfdf
JH
12015 "ix86_expand_binary_operator (ASHIFTRT, HImode, operands); DONE;")
12016
8bad7136
JL
12017(define_insn "*ashrhi3_1_one_bit"
12018 [(set (match_operand:HI 0 "nonimmediate_operand" "=rm")
12019 (ashiftrt:HI (match_operand:HI 1 "nonimmediate_operand" "0")
12020 (match_operand:QI 2 "const_int_1_operand" "")))
12021 (clobber (reg:CC 17))]
12022 "ix86_binary_operator_ok (ASHIFTRT, HImode, operands)
495333a6 12023 && (TARGET_SHIFT1 || optimize_size)"
0f40f9f7 12024 "sar{w}\t%0"
8bad7136
JL
12025 [(set_attr "type" "ishift")
12026 (set (attr "length")
3d117b30 12027 (if_then_else (match_operand 0 "register_operand" "")
8bad7136
JL
12028 (const_string "2")
12029 (const_string "*")))])
12030
d525dfdf 12031(define_insn "*ashrhi3_1"
e075ae69
RH
12032 [(set (match_operand:HI 0 "nonimmediate_operand" "=rm,rm")
12033 (ashiftrt:HI (match_operand:HI 1 "nonimmediate_operand" "0,0")
12034 (match_operand:QI 2 "nonmemory_operand" "I,c")))
12035 (clobber (reg:CC 17))]
d525dfdf 12036 "ix86_binary_operator_ok (ASHIFTRT, HImode, operands)"
e075ae69 12037 "@
0f40f9f7
ZW
12038 sar{w}\t{%2, %0|%0, %2}
12039 sar{w}\t{%b2, %0|%0, %b2}"
6ef67412
JH
12040 [(set_attr "type" "ishift")
12041 (set_attr "mode" "HI")])
886c62d1 12042
8bad7136
JL
12043;; This pattern can't accept a variable shift count, since shifts by
12044;; zero don't affect the flags. We assume that shifts by constant
12045;; zero are optimized away.
2c873473 12046(define_insn "*ashrhi3_one_bit_cmp"
8bad7136
JL
12047 [(set (reg 17)
12048 (compare
12049 (ashiftrt:HI (match_operand:HI 1 "nonimmediate_operand" "0")
12050 (match_operand:QI 2 "const_int_1_operand" ""))
12051 (const_int 0)))
12052 (set (match_operand:HI 0 "nonimmediate_operand" "=rm")
12053 (ashiftrt:HI (match_dup 1) (match_dup 2)))]
2c873473 12054 "ix86_match_ccmode (insn, CCGOCmode)
495333a6 12055 && (TARGET_SHIFT1 || optimize_size)
8bad7136 12056 && ix86_binary_operator_ok (ASHIFTRT, HImode, operands)"
0f40f9f7 12057 "sar{w}\t%0"
8bad7136
JL
12058 [(set_attr "type" "ishift")
12059 (set (attr "length")
3d117b30 12060 (if_then_else (match_operand 0 "register_operand" "")
8bad7136
JL
12061 (const_string "2")
12062 (const_string "*")))])
12063
28cefcd2
BS
12064;; This pattern can't accept a variable shift count, since shifts by
12065;; zero don't affect the flags. We assume that shifts by constant
12066;; zero are optimized away.
2c873473 12067(define_insn "*ashrhi3_cmp"
16189740
RH
12068 [(set (reg 17)
12069 (compare
28cefcd2 12070 (ashiftrt:HI (match_operand:HI 1 "nonimmediate_operand" "0")
794a292d 12071 (match_operand:QI 2 "const_int_1_31_operand" "I"))
e075ae69 12072 (const_int 0)))
28cefcd2 12073 (set (match_operand:HI 0 "nonimmediate_operand" "=rm")
e075ae69 12074 (ashiftrt:HI (match_dup 1) (match_dup 2)))]
2c873473 12075 "ix86_match_ccmode (insn, CCGOCmode)
16189740 12076 && ix86_binary_operator_ok (ASHIFTRT, HImode, operands)"
0f40f9f7 12077 "sar{w}\t{%2, %0|%0, %2}"
6ef67412
JH
12078 [(set_attr "type" "ishift")
12079 (set_attr "mode" "HI")])
886c62d1 12080
d525dfdf
JH
12081(define_expand "ashrqi3"
12082 [(set (match_operand:QI 0 "nonimmediate_operand" "")
155d8a47 12083 (ashiftrt:QI (match_operand:QI 1 "nonimmediate_operand" "")
d525dfdf
JH
12084 (match_operand:QI 2 "nonmemory_operand" "")))
12085 (clobber (reg:CC 17))]
d9f32422 12086 "TARGET_QIMODE_MATH"
d525dfdf
JH
12087 "ix86_expand_binary_operator (ASHIFTRT, QImode, operands); DONE;")
12088
8bad7136
JL
12089(define_insn "*ashrqi3_1_one_bit"
12090 [(set (match_operand:QI 0 "nonimmediate_operand" "=qm")
12091 (ashiftrt:QI (match_operand:QI 1 "nonimmediate_operand" "0")
12092 (match_operand:QI 2 "const_int_1_operand" "")))
12093 (clobber (reg:CC 17))]
12094 "ix86_binary_operator_ok (ASHIFTRT, QImode, operands)
495333a6 12095 && (TARGET_SHIFT1 || optimize_size)"
0f40f9f7 12096 "sar{b}\t%0"
8bad7136
JL
12097 [(set_attr "type" "ishift")
12098 (set (attr "length")
3d117b30 12099 (if_then_else (match_operand 0 "register_operand" "")
8bad7136
JL
12100 (const_string "2")
12101 (const_string "*")))])
12102
2f41793e
JH
12103(define_insn "*ashrqi3_1_one_bit_slp"
12104 [(set (strict_low_part (match_operand:QI 0 "nonimmediate_operand" "+qm"))
1b245ade
JH
12105 (ashiftrt:QI (match_dup 0)
12106 (match_operand:QI 1 "const_int_1_operand" "")))
2f41793e
JH
12107 (clobber (reg:CC 17))]
12108 "ix86_binary_operator_ok (ASHIFTRT, QImode, operands)
12109 && (! TARGET_PARTIAL_REG_STALL || optimize_size)
495333a6 12110 && (TARGET_SHIFT1 || optimize_size)"
2f41793e 12111 "sar{b}\t%0"
1b245ade 12112 [(set_attr "type" "ishift1")
2f41793e
JH
12113 (set (attr "length")
12114 (if_then_else (match_operand 0 "register_operand" "")
12115 (const_string "2")
12116 (const_string "*")))])
12117
d525dfdf 12118(define_insn "*ashrqi3_1"
e075ae69
RH
12119 [(set (match_operand:QI 0 "nonimmediate_operand" "=qm,qm")
12120 (ashiftrt:QI (match_operand:QI 1 "nonimmediate_operand" "0,0")
12121 (match_operand:QI 2 "nonmemory_operand" "I,c")))
12122 (clobber (reg:CC 17))]
d525dfdf 12123 "ix86_binary_operator_ok (ASHIFTRT, QImode, operands)"
e075ae69 12124 "@
0f40f9f7
ZW
12125 sar{b}\t{%2, %0|%0, %2}
12126 sar{b}\t{%b2, %0|%0, %b2}"
6ef67412
JH
12127 [(set_attr "type" "ishift")
12128 (set_attr "mode" "QI")])
886c62d1 12129
2f41793e
JH
12130(define_insn "*ashrqi3_1_slp"
12131 [(set (strict_low_part (match_operand:QI 0 "nonimmediate_operand" "+qm,qm"))
1b245ade
JH
12132 (ashiftrt:QI (match_dup 0)
12133 (match_operand:QI 1 "nonmemory_operand" "I,c")))
2f41793e
JH
12134 (clobber (reg:CC 17))]
12135 "(! TARGET_PARTIAL_REG_STALL || optimize_size)
1b245ade 12136 && (GET_CODE (operands[0]) != MEM || GET_CODE (operands[1]) != MEM)"
2f41793e 12137 "@
1b245ade
JH
12138 sar{b}\t{%1, %0|%0, %1}
12139 sar{b}\t{%b1, %0|%0, %b1}"
12140 [(set_attr "type" "ishift1")
2f41793e
JH
12141 (set_attr "mode" "QI")])
12142
8bad7136
JL
12143;; This pattern can't accept a variable shift count, since shifts by
12144;; zero don't affect the flags. We assume that shifts by constant
12145;; zero are optimized away.
2c873473 12146(define_insn "*ashrqi3_one_bit_cmp"
8bad7136
JL
12147 [(set (reg 17)
12148 (compare
12149 (ashiftrt:QI (match_operand:QI 1 "nonimmediate_operand" "0")
12150 (match_operand:QI 2 "const_int_1_operand" "I"))
12151 (const_int 0)))
5f90a099 12152 (set (match_operand:QI 0 "nonimmediate_operand" "=qm")
8bad7136 12153 (ashiftrt:QI (match_dup 1) (match_dup 2)))]
2c873473 12154 "ix86_match_ccmode (insn, CCGOCmode)
495333a6 12155 && (TARGET_SHIFT1 || optimize_size)
8bad7136 12156 && ix86_binary_operator_ok (ASHIFTRT, QImode, operands)"
0f40f9f7 12157 "sar{b}\t%0"
8bad7136
JL
12158 [(set_attr "type" "ishift")
12159 (set (attr "length")
3d117b30 12160 (if_then_else (match_operand 0 "register_operand" "")
8bad7136
JL
12161 (const_string "2")
12162 (const_string "*")))])
12163
28cefcd2
BS
12164;; This pattern can't accept a variable shift count, since shifts by
12165;; zero don't affect the flags. We assume that shifts by constant
12166;; zero are optimized away.
2c873473 12167(define_insn "*ashrqi3_cmp"
16189740
RH
12168 [(set (reg 17)
12169 (compare
28cefcd2 12170 (ashiftrt:QI (match_operand:QI 1 "nonimmediate_operand" "0")
794a292d 12171 (match_operand:QI 2 "const_int_1_31_operand" "I"))
e075ae69 12172 (const_int 0)))
5f90a099 12173 (set (match_operand:QI 0 "nonimmediate_operand" "=qm")
e075ae69 12174 (ashiftrt:QI (match_dup 1) (match_dup 2)))]
2c873473 12175 "ix86_match_ccmode (insn, CCGOCmode)
16189740 12176 && ix86_binary_operator_ok (ASHIFTRT, QImode, operands)"
0f40f9f7 12177 "sar{b}\t{%2, %0|%0, %2}"
6ef67412
JH
12178 [(set_attr "type" "ishift")
12179 (set_attr "mode" "QI")])
886c62d1 12180\f
e075ae69
RH
12181;; Logical shift instructions
12182
12183;; See comment above `ashldi3' about how this works.
12184
12185(define_expand "lshrdi3"
371bc54b
JH
12186 [(parallel [(set (match_operand:DI 0 "shiftdi_operand" "")
12187 (lshiftrt:DI (match_operand:DI 1 "shiftdi_operand" "")
12188 (match_operand:QI 2 "nonmemory_operand" "")))
e075ae69 12189 (clobber (reg:CC 17))])]
886c62d1 12190 ""
886c62d1 12191{
371bc54b 12192 if (!TARGET_64BIT && TARGET_CMOVE && ! immediate_operand (operands[2], QImode))
886c62d1 12193 {
e075ae69
RH
12194 emit_insn (gen_lshrdi3_1 (operands[0], operands[1], operands[2]));
12195 DONE;
886c62d1 12196 }
371bc54b
JH
12197 ix86_expand_binary_operator (LSHIFTRT, DImode, operands);
12198 DONE;
0f40f9f7 12199})
886c62d1 12200
371bc54b
JH
12201(define_insn "*lshrdi3_1_one_bit_rex64"
12202 [(set (match_operand:DI 0 "nonimmediate_operand" "=rm")
12203 (lshiftrt:DI (match_operand:DI 1 "nonimmediate_operand" "0")
12204 (match_operand:QI 2 "const_int_1_operand" "")))
12205 (clobber (reg:CC 17))]
12206 "TARGET_64BIT && ix86_binary_operator_ok (LSHIFTRT, HImode, operands)
495333a6 12207 && (TARGET_SHIFT1 || optimize_size)"
0f40f9f7 12208 "shr{q}\t%0"
371bc54b
JH
12209 [(set_attr "type" "ishift")
12210 (set (attr "length")
12211 (if_then_else (match_operand:DI 0 "register_operand" "")
12212 (const_string "2")
12213 (const_string "*")))])
12214
12215(define_insn "*lshrdi3_1_rex64"
12216 [(set (match_operand:DI 0 "nonimmediate_operand" "=rm,rm")
12217 (lshiftrt:DI (match_operand:DI 1 "nonimmediate_operand" "0,0")
12218 (match_operand:QI 2 "nonmemory_operand" "J,c")))
12219 (clobber (reg:CC 17))]
12220 "TARGET_64BIT && ix86_binary_operator_ok (LSHIFTRT, HImode, operands)"
12221 "@
0f40f9f7
ZW
12222 shr{q}\t{%2, %0|%0, %2}
12223 shr{q}\t{%b2, %0|%0, %b2}"
371bc54b
JH
12224 [(set_attr "type" "ishift")
12225 (set_attr "mode" "DI")])
12226
12227;; This pattern can't accept a variable shift count, since shifts by
12228;; zero don't affect the flags. We assume that shifts by constant
12229;; zero are optimized away.
12230(define_insn "*lshrdi3_cmp_one_bit_rex64"
12231 [(set (reg 17)
12232 (compare
12233 (lshiftrt:DI (match_operand:DI 1 "nonimmediate_operand" "0")
12234 (match_operand:QI 2 "const_int_1_operand" ""))
12235 (const_int 0)))
12236 (set (match_operand:DI 0 "nonimmediate_operand" "=rm")
12237 (lshiftrt:DI (match_dup 1) (match_dup 2)))]
12238 "TARGET_64BIT && ix86_match_ccmode (insn, CCGOCmode)
495333a6 12239 && (TARGET_SHIFT1 || optimize_size)
371bc54b 12240 && ix86_binary_operator_ok (LSHIFTRT, HImode, operands)"
0f40f9f7 12241 "shr{q}\t%0"
371bc54b
JH
12242 [(set_attr "type" "ishift")
12243 (set (attr "length")
12244 (if_then_else (match_operand:DI 0 "register_operand" "")
12245 (const_string "2")
12246 (const_string "*")))])
12247
12248;; This pattern can't accept a variable shift count, since shifts by
12249;; zero don't affect the flags. We assume that shifts by constant
12250;; zero are optimized away.
12251(define_insn "*lshrdi3_cmp_rex64"
12252 [(set (reg 17)
12253 (compare
12254 (lshiftrt:DI (match_operand:DI 1 "nonimmediate_operand" "0")
12255 (match_operand:QI 2 "const_int_operand" "e"))
12256 (const_int 0)))
12257 (set (match_operand:DI 0 "nonimmediate_operand" "=rm")
12258 (lshiftrt:DI (match_dup 1) (match_dup 2)))]
12259 "TARGET_64BIT && ix86_match_ccmode (insn, CCGOCmode)
12260 && ix86_binary_operator_ok (LSHIFTRT, HImode, operands)"
0f40f9f7 12261 "shr{q}\t{%2, %0|%0, %2}"
371bc54b
JH
12262 [(set_attr "type" "ishift")
12263 (set_attr "mode" "DI")])
12264
e075ae69
RH
12265(define_insn "lshrdi3_1"
12266 [(set (match_operand:DI 0 "register_operand" "=r")
12267 (lshiftrt:DI (match_operand:DI 1 "register_operand" "0")
12268 (match_operand:QI 2 "nonmemory_operand" "Jc")))
12269 (clobber (match_scratch:SI 3 "=&r"))
12270 (clobber (reg:CC 17))]
1e07edd3 12271 "!TARGET_64BIT && TARGET_CMOVE"
e075ae69
RH
12272 "#"
12273 [(set_attr "type" "multi")])
886c62d1 12274
e075ae69
RH
12275(define_insn "*lshrdi3_2"
12276 [(set (match_operand:DI 0 "register_operand" "=r")
12277 (lshiftrt:DI (match_operand:DI 1 "register_operand" "0")
12278 (match_operand:QI 2 "nonmemory_operand" "Jc")))
12279 (clobber (reg:CC 17))]
1e07edd3 12280 "!TARGET_64BIT"
e075ae69
RH
12281 "#"
12282 [(set_attr "type" "multi")])
886c62d1 12283
e075ae69
RH
12284(define_split
12285 [(set (match_operand:DI 0 "register_operand" "")
12286 (lshiftrt:DI (match_operand:DI 1 "register_operand" "")
12287 (match_operand:QI 2 "nonmemory_operand" "")))
12288 (clobber (match_scratch:SI 3 ""))
12289 (clobber (reg:CC 17))]
1e07edd3 12290 "!TARGET_64BIT && TARGET_CMOVE && reload_completed"
e075ae69
RH
12291 [(const_int 0)]
12292 "ix86_split_lshrdi (operands, operands[3]); DONE;")
886c62d1 12293
e075ae69
RH
12294(define_split
12295 [(set (match_operand:DI 0 "register_operand" "")
12296 (lshiftrt:DI (match_operand:DI 1 "register_operand" "")
12297 (match_operand:QI 2 "nonmemory_operand" "")))
12298 (clobber (reg:CC 17))]
1e07edd3 12299 "!TARGET_64BIT && reload_completed"
e075ae69
RH
12300 [(const_int 0)]
12301 "ix86_split_lshrdi (operands, NULL_RTX); DONE;")
886c62d1 12302
d525dfdf
JH
12303(define_expand "lshrsi3"
12304 [(set (match_operand:SI 0 "nonimmediate_operand" "")
12305 (lshiftrt:SI (match_operand:SI 1 "nonimmediate_operand" "")
12306 (match_operand:QI 2 "nonmemory_operand" "")))
12307 (clobber (reg:CC 17))]
12308 ""
12309 "ix86_expand_binary_operator (LSHIFTRT, SImode, operands); DONE;")
12310
8bad7136
JL
12311(define_insn "*lshrsi3_1_one_bit"
12312 [(set (match_operand:SI 0 "nonimmediate_operand" "=rm")
12313 (lshiftrt:SI (match_operand:SI 1 "nonimmediate_operand" "0")
12314 (match_operand:QI 2 "const_int_1_operand" "")))
12315 (clobber (reg:CC 17))]
12316 "ix86_binary_operator_ok (LSHIFTRT, HImode, operands)
495333a6 12317 && (TARGET_SHIFT1 || optimize_size)"
0f40f9f7 12318 "shr{l}\t%0"
8bad7136
JL
12319 [(set_attr "type" "ishift")
12320 (set (attr "length")
12321 (if_then_else (match_operand:SI 0 "register_operand" "")
12322 (const_string "2")
12323 (const_string "*")))])
12324
371bc54b
JH
12325(define_insn "*lshrsi3_1_one_bit_zext"
12326 [(set (match_operand:DI 0 "register_operand" "=r")
12327 (lshiftrt:DI (zero_extend:DI (match_operand:SI 1 "register_operand" "0"))
12328 (match_operand:QI 2 "const_int_1_operand" "")))
12329 (clobber (reg:CC 17))]
12330 "TARGET_64BIT && ix86_binary_operator_ok (LSHIFTRT, HImode, operands)
495333a6 12331 && (TARGET_SHIFT1 || optimize_size)"
0f40f9f7 12332 "shr{l}\t%k0"
371bc54b
JH
12333 [(set_attr "type" "ishift")
12334 (set_attr "length" "2")])
12335
d525dfdf 12336(define_insn "*lshrsi3_1"
e075ae69
RH
12337 [(set (match_operand:SI 0 "nonimmediate_operand" "=rm,rm")
12338 (lshiftrt:SI (match_operand:SI 1 "nonimmediate_operand" "0,0")
12339 (match_operand:QI 2 "nonmemory_operand" "I,c")))
12340 (clobber (reg:CC 17))]
d525dfdf 12341 "ix86_binary_operator_ok (LSHIFTRT, HImode, operands)"
e075ae69 12342 "@
0f40f9f7
ZW
12343 shr{l}\t{%2, %0|%0, %2}
12344 shr{l}\t{%b2, %0|%0, %b2}"
6ef67412
JH
12345 [(set_attr "type" "ishift")
12346 (set_attr "mode" "SI")])
886c62d1 12347
371bc54b
JH
12348(define_insn "*lshrsi3_1_zext"
12349 [(set (match_operand:DI 0 "register_operand" "=r,r")
12350 (zero_extend:DI
12351 (lshiftrt:SI (match_operand:SI 1 "nonimmediate_operand" "0,0")
12352 (match_operand:QI 2 "nonmemory_operand" "I,c"))))
12353 (clobber (reg:CC 17))]
12354 "TARGET_64BIT && ix86_binary_operator_ok (LSHIFTRT, HImode, operands)"
12355 "@
0f40f9f7
ZW
12356 shr{l}\t{%2, %k0|%k0, %2}
12357 shr{l}\t{%b2, %k0|%k0, %b2}"
371bc54b
JH
12358 [(set_attr "type" "ishift")
12359 (set_attr "mode" "SI")])
12360
8bad7136
JL
12361;; This pattern can't accept a variable shift count, since shifts by
12362;; zero don't affect the flags. We assume that shifts by constant
12363;; zero are optimized away.
2c873473 12364(define_insn "*lshrsi3_one_bit_cmp"
8bad7136
JL
12365 [(set (reg 17)
12366 (compare
12367 (lshiftrt:SI (match_operand:SI 1 "nonimmediate_operand" "0")
12368 (match_operand:QI 2 "const_int_1_operand" ""))
12369 (const_int 0)))
12370 (set (match_operand:SI 0 "nonimmediate_operand" "=rm")
12371 (lshiftrt:SI (match_dup 1) (match_dup 2)))]
9076b9c1 12372 "ix86_match_ccmode (insn, CCGOCmode)
495333a6 12373 && (TARGET_SHIFT1 || optimize_size)
8bad7136 12374 && ix86_binary_operator_ok (LSHIFTRT, HImode, operands)"
0f40f9f7 12375 "shr{l}\t%0"
8bad7136
JL
12376 [(set_attr "type" "ishift")
12377 (set (attr "length")
12378 (if_then_else (match_operand:SI 0 "register_operand" "")
12379 (const_string "2")
12380 (const_string "*")))])
12381
371bc54b
JH
12382(define_insn "*lshrsi3_cmp_one_bit_zext"
12383 [(set (reg 17)
12384 (compare
12385 (lshiftrt:SI (match_operand:SI 1 "register_operand" "0")
12386 (match_operand:QI 2 "const_int_1_operand" ""))
12387 (const_int 0)))
12388 (set (match_operand:DI 0 "register_operand" "=r")
12389 (lshiftrt:DI (zero_extend:DI (match_dup 1)) (match_dup 2)))]
12390 "TARGET_64BIT && ix86_match_ccmode (insn, CCGOCmode)
495333a6 12391 && (TARGET_SHIFT1 || optimize_size)
371bc54b 12392 && ix86_binary_operator_ok (LSHIFTRT, HImode, operands)"
0f40f9f7 12393 "shr{l}\t%k0"
371bc54b
JH
12394 [(set_attr "type" "ishift")
12395 (set_attr "length" "2")])
12396
28cefcd2
BS
12397;; This pattern can't accept a variable shift count, since shifts by
12398;; zero don't affect the flags. We assume that shifts by constant
12399;; zero are optimized away.
2c873473 12400(define_insn "*lshrsi3_cmp"
16189740
RH
12401 [(set (reg 17)
12402 (compare
28cefcd2 12403 (lshiftrt:SI (match_operand:SI 1 "nonimmediate_operand" "0")
794a292d 12404 (match_operand:QI 2 "const_int_1_31_operand" "I"))
e075ae69 12405 (const_int 0)))
28cefcd2 12406 (set (match_operand:SI 0 "nonimmediate_operand" "=rm")
e075ae69 12407 (lshiftrt:SI (match_dup 1) (match_dup 2)))]
9076b9c1 12408 "ix86_match_ccmode (insn, CCGOCmode)
16189740 12409 && ix86_binary_operator_ok (LSHIFTRT, HImode, operands)"
0f40f9f7 12410 "shr{l}\t{%2, %0|%0, %2}"
6ef67412
JH
12411 [(set_attr "type" "ishift")
12412 (set_attr "mode" "SI")])
886c62d1 12413
371bc54b
JH
12414(define_insn "*lshrsi3_cmp_zext"
12415 [(set (reg 17)
12416 (compare
12417 (lshiftrt:SI (match_operand:SI 1 "register_operand" "0")
794a292d 12418 (match_operand:QI 2 "const_int_1_31_operand" "I"))
371bc54b
JH
12419 (const_int 0)))
12420 (set (match_operand:DI 0 "register_operand" "=r")
12421 (lshiftrt:DI (zero_extend:DI (match_dup 1)) (match_dup 2)))]
12422 "TARGET_64BIT && ix86_match_ccmode (insn, CCGOCmode)
12423 && ix86_binary_operator_ok (LSHIFTRT, HImode, operands)"
0f40f9f7 12424 "shr{l}\t{%2, %k0|%k0, %2}"
371bc54b
JH
12425 [(set_attr "type" "ishift")
12426 (set_attr "mode" "SI")])
12427
d525dfdf
JH
12428(define_expand "lshrhi3"
12429 [(set (match_operand:HI 0 "nonimmediate_operand" "")
12430 (lshiftrt:HI (match_operand:HI 1 "nonimmediate_operand" "")
12431 (match_operand:QI 2 "nonmemory_operand" "")))
12432 (clobber (reg:CC 17))]
d9f32422 12433 "TARGET_HIMODE_MATH"
d525dfdf
JH
12434 "ix86_expand_binary_operator (LSHIFTRT, HImode, operands); DONE;")
12435
8bad7136
JL
12436(define_insn "*lshrhi3_1_one_bit"
12437 [(set (match_operand:HI 0 "nonimmediate_operand" "=rm")
12438 (lshiftrt:HI (match_operand:HI 1 "nonimmediate_operand" "0")
12439 (match_operand:QI 2 "const_int_1_operand" "")))
12440 (clobber (reg:CC 17))]
12441 "ix86_binary_operator_ok (LSHIFTRT, HImode, operands)
495333a6 12442 && (TARGET_SHIFT1 || optimize_size)"
0f40f9f7 12443 "shr{w}\t%0"
8bad7136
JL
12444 [(set_attr "type" "ishift")
12445 (set (attr "length")
3d117b30 12446 (if_then_else (match_operand 0 "register_operand" "")
8bad7136
JL
12447 (const_string "2")
12448 (const_string "*")))])
12449
d525dfdf 12450(define_insn "*lshrhi3_1"
e075ae69
RH
12451 [(set (match_operand:HI 0 "nonimmediate_operand" "=rm,rm")
12452 (lshiftrt:HI (match_operand:HI 1 "nonimmediate_operand" "0,0")
12453 (match_operand:QI 2 "nonmemory_operand" "I,c")))
12454 (clobber (reg:CC 17))]
d525dfdf 12455 "ix86_binary_operator_ok (LSHIFTRT, HImode, operands)"
e075ae69 12456 "@
0f40f9f7
ZW
12457 shr{w}\t{%2, %0|%0, %2}
12458 shr{w}\t{%b2, %0|%0, %b2}"
6ef67412
JH
12459 [(set_attr "type" "ishift")
12460 (set_attr "mode" "HI")])
886c62d1 12461
8bad7136
JL
12462;; This pattern can't accept a variable shift count, since shifts by
12463;; zero don't affect the flags. We assume that shifts by constant
12464;; zero are optimized away.
2c873473 12465(define_insn "*lshrhi3_one_bit_cmp"
8bad7136
JL
12466 [(set (reg 17)
12467 (compare
12468 (lshiftrt:HI (match_operand:HI 1 "nonimmediate_operand" "0")
12469 (match_operand:QI 2 "const_int_1_operand" ""))
12470 (const_int 0)))
12471 (set (match_operand:HI 0 "nonimmediate_operand" "=rm")
12472 (lshiftrt:HI (match_dup 1) (match_dup 2)))]
9076b9c1 12473 "ix86_match_ccmode (insn, CCGOCmode)
495333a6 12474 && (TARGET_SHIFT1 || optimize_size)
8bad7136 12475 && ix86_binary_operator_ok (LSHIFTRT, HImode, operands)"
0f40f9f7 12476 "shr{w}\t%0"
8bad7136
JL
12477 [(set_attr "type" "ishift")
12478 (set (attr "length")
12479 (if_then_else (match_operand:SI 0 "register_operand" "")
12480 (const_string "2")
12481 (const_string "*")))])
12482
28cefcd2
BS
12483;; This pattern can't accept a variable shift count, since shifts by
12484;; zero don't affect the flags. We assume that shifts by constant
12485;; zero are optimized away.
2c873473 12486(define_insn "*lshrhi3_cmp"
16189740
RH
12487 [(set (reg 17)
12488 (compare
28cefcd2 12489 (lshiftrt:HI (match_operand:HI 1 "nonimmediate_operand" "0")
794a292d 12490 (match_operand:QI 2 "const_int_1_31_operand" "I"))
e075ae69 12491 (const_int 0)))
28cefcd2 12492 (set (match_operand:HI 0 "nonimmediate_operand" "=rm")
e075ae69 12493 (lshiftrt:HI (match_dup 1) (match_dup 2)))]
9076b9c1 12494 "ix86_match_ccmode (insn, CCGOCmode)
16189740 12495 && ix86_binary_operator_ok (LSHIFTRT, HImode, operands)"
0f40f9f7 12496 "shr{w}\t{%2, %0|%0, %2}"
6ef67412
JH
12497 [(set_attr "type" "ishift")
12498 (set_attr "mode" "HI")])
886c62d1 12499
d525dfdf
JH
12500(define_expand "lshrqi3"
12501 [(set (match_operand:QI 0 "nonimmediate_operand" "")
12502 (lshiftrt:QI (match_operand:QI 1 "nonimmediate_operand" "")
12503 (match_operand:QI 2 "nonmemory_operand" "")))
12504 (clobber (reg:CC 17))]
d9f32422 12505 "TARGET_QIMODE_MATH"
d525dfdf
JH
12506 "ix86_expand_binary_operator (LSHIFTRT, QImode, operands); DONE;")
12507
8bad7136
JL
12508(define_insn "*lshrqi3_1_one_bit"
12509 [(set (match_operand:QI 0 "nonimmediate_operand" "=qm")
12510 (lshiftrt:QI (match_operand:QI 1 "nonimmediate_operand" "0")
12511 (match_operand:QI 2 "const_int_1_operand" "")))
12512 (clobber (reg:CC 17))]
12513 "ix86_binary_operator_ok (LSHIFTRT, QImode, operands)
495333a6 12514 && (TARGET_SHIFT1 || optimize_size)"
0f40f9f7 12515 "shr{b}\t%0"
8bad7136
JL
12516 [(set_attr "type" "ishift")
12517 (set (attr "length")
3d117b30 12518 (if_then_else (match_operand 0 "register_operand" "")
8bad7136
JL
12519 (const_string "2")
12520 (const_string "*")))])
12521
2f41793e
JH
12522(define_insn "*lshrqi3_1_one_bit_slp"
12523 [(set (strict_low_part (match_operand:QI 0 "nonimmediate_operand" "+qm"))
1b245ade
JH
12524 (lshiftrt:QI (match_dup 0)
12525 (match_operand:QI 1 "const_int_1_operand" "")))
2f41793e
JH
12526 (clobber (reg:CC 17))]
12527 "(! TARGET_PARTIAL_REG_STALL || optimize_size)
495333a6 12528 && (TARGET_SHIFT1 || optimize_size)"
2f41793e 12529 "shr{b}\t%0"
1b245ade 12530 [(set_attr "type" "ishift1")
2f41793e
JH
12531 (set (attr "length")
12532 (if_then_else (match_operand 0 "register_operand" "")
12533 (const_string "2")
12534 (const_string "*")))])
12535
d525dfdf 12536(define_insn "*lshrqi3_1"
e075ae69
RH
12537 [(set (match_operand:QI 0 "nonimmediate_operand" "=qm,qm")
12538 (lshiftrt:QI (match_operand:QI 1 "nonimmediate_operand" "0,0")
12539 (match_operand:QI 2 "nonmemory_operand" "I,c")))
12540 (clobber (reg:CC 17))]
d525dfdf 12541 "ix86_binary_operator_ok (LSHIFTRT, QImode, operands)"
e075ae69 12542 "@
0f40f9f7
ZW
12543 shr{b}\t{%2, %0|%0, %2}
12544 shr{b}\t{%b2, %0|%0, %b2}"
6ef67412
JH
12545 [(set_attr "type" "ishift")
12546 (set_attr "mode" "QI")])
886c62d1 12547
2f41793e
JH
12548(define_insn "*lshrqi3_1_slp"
12549 [(set (strict_low_part (match_operand:QI 0 "nonimmediate_operand" "+qm,qm"))
1b245ade
JH
12550 (lshiftrt:QI (match_dup 0)
12551 (match_operand:QI 1 "nonmemory_operand" "I,c")))
2f41793e
JH
12552 (clobber (reg:CC 17))]
12553 "(! TARGET_PARTIAL_REG_STALL || optimize_size)
1b245ade 12554 && (GET_CODE (operands[0]) != MEM || GET_CODE (operands[1]) != MEM)"
2f41793e 12555 "@
1b245ade
JH
12556 shr{b}\t{%1, %0|%0, %1}
12557 shr{b}\t{%b1, %0|%0, %b1}"
12558 [(set_attr "type" "ishift1")
2f41793e
JH
12559 (set_attr "mode" "QI")])
12560
8bad7136
JL
12561;; This pattern can't accept a variable shift count, since shifts by
12562;; zero don't affect the flags. We assume that shifts by constant
12563;; zero are optimized away.
2c873473 12564(define_insn "*lshrqi2_one_bit_cmp"
8bad7136
JL
12565 [(set (reg 17)
12566 (compare
12567 (lshiftrt:QI (match_operand:QI 1 "nonimmediate_operand" "0")
12568 (match_operand:QI 2 "const_int_1_operand" ""))
12569 (const_int 0)))
12570 (set (match_operand:QI 0 "nonimmediate_operand" "=qm")
12571 (lshiftrt:QI (match_dup 1) (match_dup 2)))]
9076b9c1 12572 "ix86_match_ccmode (insn, CCGOCmode)
495333a6 12573 && (TARGET_SHIFT1 || optimize_size)
8bad7136 12574 && ix86_binary_operator_ok (LSHIFTRT, QImode, operands)"
0f40f9f7 12575 "shr{b}\t%0"
8bad7136
JL
12576 [(set_attr "type" "ishift")
12577 (set (attr "length")
12578 (if_then_else (match_operand:SI 0 "register_operand" "")
12579 (const_string "2")
12580 (const_string "*")))])
12581
28cefcd2
BS
12582;; This pattern can't accept a variable shift count, since shifts by
12583;; zero don't affect the flags. We assume that shifts by constant
12584;; zero are optimized away.
2c873473 12585(define_insn "*lshrqi2_cmp"
16189740
RH
12586 [(set (reg 17)
12587 (compare
28cefcd2 12588 (lshiftrt:QI (match_operand:QI 1 "nonimmediate_operand" "0")
794a292d 12589 (match_operand:QI 2 "const_int_1_31_operand" "I"))
e075ae69 12590 (const_int 0)))
122ddbf9 12591 (set (match_operand:QI 0 "nonimmediate_operand" "=qm")
e075ae69 12592 (lshiftrt:QI (match_dup 1) (match_dup 2)))]
9076b9c1 12593 "ix86_match_ccmode (insn, CCGOCmode)
16189740 12594 && ix86_binary_operator_ok (LSHIFTRT, QImode, operands)"
0f40f9f7 12595 "shr{b}\t{%2, %0|%0, %2}"
6ef67412
JH
12596 [(set_attr "type" "ishift")
12597 (set_attr "mode" "QI")])
886c62d1 12598\f
e075ae69 12599;; Rotate instructions
886c62d1 12600
371bc54b
JH
12601(define_expand "rotldi3"
12602 [(set (match_operand:DI 0 "nonimmediate_operand" "")
12603 (rotate:DI (match_operand:DI 1 "nonimmediate_operand" "")
12604 (match_operand:QI 2 "nonmemory_operand" "")))
12605 (clobber (reg:CC 17))]
12606 "TARGET_64BIT"
12607 "ix86_expand_binary_operator (ROTATE, DImode, operands); DONE;")
12608
12609(define_insn "*rotlsi3_1_one_bit_rex64"
12610 [(set (match_operand:DI 0 "nonimmediate_operand" "=rm")
12611 (rotate:DI (match_operand:DI 1 "nonimmediate_operand" "0")
12612 (match_operand:QI 2 "const_int_1_operand" "")))
12613 (clobber (reg:CC 17))]
12614 "TARGET_64BIT && ix86_binary_operator_ok (ROTATE, DImode, operands)
495333a6 12615 && (TARGET_SHIFT1 || optimize_size)"
0f40f9f7 12616 "rol{q}\t%0"
890d52e8 12617 [(set_attr "type" "rotate")
371bc54b
JH
12618 (set (attr "length")
12619 (if_then_else (match_operand:DI 0 "register_operand" "")
12620 (const_string "2")
12621 (const_string "*")))])
12622
12623(define_insn "*rotldi3_1_rex64"
12624 [(set (match_operand:DI 0 "nonimmediate_operand" "=rm,rm")
12625 (rotate:DI (match_operand:DI 1 "nonimmediate_operand" "0,0")
12626 (match_operand:QI 2 "nonmemory_operand" "e,c")))
12627 (clobber (reg:CC 17))]
12628 "TARGET_64BIT && ix86_binary_operator_ok (ROTATE, DImode, operands)"
12629 "@
0f40f9f7
ZW
12630 rol{q}\t{%2, %0|%0, %2}
12631 rol{q}\t{%b2, %0|%0, %b2}"
890d52e8 12632 [(set_attr "type" "rotate")
371bc54b
JH
12633 (set_attr "mode" "DI")])
12634
d525dfdf
JH
12635(define_expand "rotlsi3"
12636 [(set (match_operand:SI 0 "nonimmediate_operand" "")
12637 (rotate:SI (match_operand:SI 1 "nonimmediate_operand" "")
12638 (match_operand:QI 2 "nonmemory_operand" "")))
12639 (clobber (reg:CC 17))]
12640 ""
12641 "ix86_expand_binary_operator (ROTATE, SImode, operands); DONE;")
12642
8bad7136
JL
12643(define_insn "*rotlsi3_1_one_bit"
12644 [(set (match_operand:SI 0 "nonimmediate_operand" "=rm")
12645 (rotate:SI (match_operand:SI 1 "nonimmediate_operand" "0")
12646 (match_operand:QI 2 "const_int_1_operand" "")))
12647 (clobber (reg:CC 17))]
12648 "ix86_binary_operator_ok (ROTATE, SImode, operands)
495333a6 12649 && (TARGET_SHIFT1 || optimize_size)"
0f40f9f7 12650 "rol{l}\t%0"
890d52e8 12651 [(set_attr "type" "rotate")
8bad7136
JL
12652 (set (attr "length")
12653 (if_then_else (match_operand:SI 0 "register_operand" "")
12654 (const_string "2")
12655 (const_string "*")))])
12656
371bc54b
JH
12657(define_insn "*rotlsi3_1_one_bit_zext"
12658 [(set (match_operand:DI 0 "register_operand" "=r")
12659 (zero_extend:DI
12660 (rotate:SI (match_operand:SI 1 "register_operand" "0")
12661 (match_operand:QI 2 "const_int_1_operand" ""))))
12662 (clobber (reg:CC 17))]
12663 "TARGET_64BIT && ix86_binary_operator_ok (ROTATE, SImode, operands)
495333a6 12664 && (TARGET_SHIFT1 || optimize_size)"
0f40f9f7 12665 "rol{l}\t%k0"
890d52e8 12666 [(set_attr "type" "rotate")
371bc54b
JH
12667 (set_attr "length" "2")])
12668
d525dfdf 12669(define_insn "*rotlsi3_1"
e075ae69
RH
12670 [(set (match_operand:SI 0 "nonimmediate_operand" "=rm,rm")
12671 (rotate:SI (match_operand:SI 1 "nonimmediate_operand" "0,0")
12672 (match_operand:QI 2 "nonmemory_operand" "I,c")))
12673 (clobber (reg:CC 17))]
d525dfdf 12674 "ix86_binary_operator_ok (ROTATE, SImode, operands)"
e075ae69 12675 "@
0f40f9f7
ZW
12676 rol{l}\t{%2, %0|%0, %2}
12677 rol{l}\t{%b2, %0|%0, %b2}"
890d52e8 12678 [(set_attr "type" "rotate")
6ef67412 12679 (set_attr "mode" "SI")])
b4ac57ab 12680
371bc54b
JH
12681(define_insn "*rotlsi3_1_zext"
12682 [(set (match_operand:DI 0 "register_operand" "=r,r")
12683 (zero_extend:DI
12684 (rotate:SI (match_operand:SI 1 "register_operand" "0,0")
12685 (match_operand:QI 2 "nonmemory_operand" "I,c"))))
12686 (clobber (reg:CC 17))]
12687 "TARGET_64BIT && ix86_binary_operator_ok (ROTATE, SImode, operands)"
12688 "@
0f40f9f7
ZW
12689 rol{l}\t{%2, %k0|%k0, %2}
12690 rol{l}\t{%b2, %k0|%k0, %b2}"
890d52e8 12691 [(set_attr "type" "rotate")
371bc54b
JH
12692 (set_attr "mode" "SI")])
12693
d525dfdf
JH
12694(define_expand "rotlhi3"
12695 [(set (match_operand:HI 0 "nonimmediate_operand" "")
12696 (rotate:HI (match_operand:HI 1 "nonimmediate_operand" "")
12697 (match_operand:QI 2 "nonmemory_operand" "")))
12698 (clobber (reg:CC 17))]
d9f32422 12699 "TARGET_HIMODE_MATH"
d525dfdf
JH
12700 "ix86_expand_binary_operator (ROTATE, HImode, operands); DONE;")
12701
8bad7136
JL
12702(define_insn "*rotlhi3_1_one_bit"
12703 [(set (match_operand:HI 0 "nonimmediate_operand" "=rm")
12704 (rotate:HI (match_operand:HI 1 "nonimmediate_operand" "0")
12705 (match_operand:QI 2 "const_int_1_operand" "")))
12706 (clobber (reg:CC 17))]
12707 "ix86_binary_operator_ok (ROTATE, HImode, operands)
495333a6 12708 && (TARGET_SHIFT1 || optimize_size)"
0f40f9f7 12709 "rol{w}\t%0"
890d52e8 12710 [(set_attr "type" "rotate")
8bad7136 12711 (set (attr "length")
3d117b30 12712 (if_then_else (match_operand 0 "register_operand" "")
8bad7136
JL
12713 (const_string "2")
12714 (const_string "*")))])
12715
d525dfdf 12716(define_insn "*rotlhi3_1"
e075ae69
RH
12717 [(set (match_operand:HI 0 "nonimmediate_operand" "=rm,rm")
12718 (rotate:HI (match_operand:HI 1 "nonimmediate_operand" "0,0")
12719 (match_operand:QI 2 "nonmemory_operand" "I,c")))
12720 (clobber (reg:CC 17))]
d525dfdf 12721 "ix86_binary_operator_ok (ROTATE, HImode, operands)"
e075ae69 12722 "@
0f40f9f7
ZW
12723 rol{w}\t{%2, %0|%0, %2}
12724 rol{w}\t{%b2, %0|%0, %b2}"
890d52e8 12725 [(set_attr "type" "rotate")
6ef67412 12726 (set_attr "mode" "HI")])
47af5d50 12727
d525dfdf
JH
12728(define_expand "rotlqi3"
12729 [(set (match_operand:QI 0 "nonimmediate_operand" "")
12730 (rotate:QI (match_operand:QI 1 "nonimmediate_operand" "")
12731 (match_operand:QI 2 "nonmemory_operand" "")))
12732 (clobber (reg:CC 17))]
d9f32422 12733 "TARGET_QIMODE_MATH"
d525dfdf
JH
12734 "ix86_expand_binary_operator (ROTATE, QImode, operands); DONE;")
12735
2f41793e
JH
12736(define_insn "*rotlqi3_1_one_bit_slp"
12737 [(set (strict_low_part (match_operand:QI 0 "nonimmediate_operand" "+qm"))
1b245ade
JH
12738 (rotate:QI (match_dup 0)
12739 (match_operand:QI 1 "const_int_1_operand" "")))
2f41793e
JH
12740 (clobber (reg:CC 17))]
12741 "(! TARGET_PARTIAL_REG_STALL || optimize_size)
495333a6 12742 && (TARGET_SHIFT1 || optimize_size)"
2f41793e 12743 "rol{b}\t%0"
1b245ade 12744 [(set_attr "type" "rotate1")
2f41793e
JH
12745 (set (attr "length")
12746 (if_then_else (match_operand 0 "register_operand" "")
12747 (const_string "2")
12748 (const_string "*")))])
12749
8bad7136
JL
12750(define_insn "*rotlqi3_1_one_bit"
12751 [(set (match_operand:QI 0 "nonimmediate_operand" "=qm")
12752 (rotate:QI (match_operand:QI 1 "nonimmediate_operand" "0")
12753 (match_operand:QI 2 "const_int_1_operand" "")))
12754 (clobber (reg:CC 17))]
12755 "ix86_binary_operator_ok (ROTATE, QImode, operands)
495333a6 12756 && (TARGET_SHIFT1 || optimize_size)"
0f40f9f7 12757 "rol{b}\t%0"
890d52e8 12758 [(set_attr "type" "rotate")
8bad7136 12759 (set (attr "length")
3d117b30 12760 (if_then_else (match_operand 0 "register_operand" "")
8bad7136
JL
12761 (const_string "2")
12762 (const_string "*")))])
12763
2f41793e
JH
12764(define_insn "*rotlqi3_1_slp"
12765 [(set (strict_low_part (match_operand:QI 0 "nonimmediate_operand" "+qm,qm"))
1b245ade
JH
12766 (rotate:QI (match_dup 0)
12767 (match_operand:QI 1 "nonmemory_operand" "I,c")))
2f41793e
JH
12768 (clobber (reg:CC 17))]
12769 "(! TARGET_PARTIAL_REG_STALL || optimize_size)
1b245ade 12770 && (GET_CODE (operands[0]) != MEM || GET_CODE (operands[1]) != MEM)"
2f41793e 12771 "@
1b245ade
JH
12772 rol{b}\t{%1, %0|%0, %1}
12773 rol{b}\t{%b1, %0|%0, %b1}"
12774 [(set_attr "type" "rotate1")
2f41793e
JH
12775 (set_attr "mode" "QI")])
12776
d525dfdf 12777(define_insn "*rotlqi3_1"
e075ae69
RH
12778 [(set (match_operand:QI 0 "nonimmediate_operand" "=qm,qm")
12779 (rotate:QI (match_operand:QI 1 "nonimmediate_operand" "0,0")
12780 (match_operand:QI 2 "nonmemory_operand" "I,c")))
12781 (clobber (reg:CC 17))]
d525dfdf 12782 "ix86_binary_operator_ok (ROTATE, QImode, operands)"
e075ae69 12783 "@
0f40f9f7
ZW
12784 rol{b}\t{%2, %0|%0, %2}
12785 rol{b}\t{%b2, %0|%0, %b2}"
890d52e8 12786 [(set_attr "type" "rotate")
6ef67412 12787 (set_attr "mode" "QI")])
47af5d50 12788
371bc54b
JH
12789(define_expand "rotrdi3"
12790 [(set (match_operand:DI 0 "nonimmediate_operand" "")
12791 (rotatert:DI (match_operand:DI 1 "nonimmediate_operand" "")
12792 (match_operand:QI 2 "nonmemory_operand" "")))
12793 (clobber (reg:CC 17))]
12794 "TARGET_64BIT"
12795 "ix86_expand_binary_operator (ROTATERT, DImode, operands); DONE;")
12796
12797(define_insn "*rotrdi3_1_one_bit_rex64"
12798 [(set (match_operand:DI 0 "nonimmediate_operand" "=rm")
12799 (rotatert:DI (match_operand:DI 1 "nonimmediate_operand" "0")
12800 (match_operand:QI 2 "const_int_1_operand" "")))
12801 (clobber (reg:CC 17))]
12802 "TARGET_64BIT && ix86_binary_operator_ok (ROTATERT, DImode, operands)
495333a6 12803 && (TARGET_SHIFT1 || optimize_size)"
0f40f9f7 12804 "ror{q}\t%0"
890d52e8 12805 [(set_attr "type" "rotate")
371bc54b
JH
12806 (set (attr "length")
12807 (if_then_else (match_operand:DI 0 "register_operand" "")
12808 (const_string "2")
12809 (const_string "*")))])
12810
12811(define_insn "*rotrdi3_1_rex64"
12812 [(set (match_operand:DI 0 "nonimmediate_operand" "=rm,rm")
12813 (rotatert:DI (match_operand:DI 1 "nonimmediate_operand" "0,0")
12814 (match_operand:QI 2 "nonmemory_operand" "J,c")))
12815 (clobber (reg:CC 17))]
12816 "TARGET_64BIT && ix86_binary_operator_ok (ROTATERT, DImode, operands)"
12817 "@
0f40f9f7
ZW
12818 ror{q}\t{%2, %0|%0, %2}
12819 ror{q}\t{%b2, %0|%0, %b2}"
890d52e8 12820 [(set_attr "type" "rotate")
371bc54b
JH
12821 (set_attr "mode" "DI")])
12822
d525dfdf
JH
12823(define_expand "rotrsi3"
12824 [(set (match_operand:SI 0 "nonimmediate_operand" "")
12825 (rotatert:SI (match_operand:SI 1 "nonimmediate_operand" "")
12826 (match_operand:QI 2 "nonmemory_operand" "")))
12827 (clobber (reg:CC 17))]
12828 ""
12829 "ix86_expand_binary_operator (ROTATERT, SImode, operands); DONE;")
12830
8bad7136
JL
12831(define_insn "*rotrsi3_1_one_bit"
12832 [(set (match_operand:SI 0 "nonimmediate_operand" "=rm")
12833 (rotatert:SI (match_operand:SI 1 "nonimmediate_operand" "0")
12834 (match_operand:QI 2 "const_int_1_operand" "")))
12835 (clobber (reg:CC 17))]
12836 "ix86_binary_operator_ok (ROTATERT, SImode, operands)
495333a6 12837 && (TARGET_SHIFT1 || optimize_size)"
0f40f9f7 12838 "ror{l}\t%0"
890d52e8 12839 [(set_attr "type" "rotate")
8bad7136
JL
12840 (set (attr "length")
12841 (if_then_else (match_operand:SI 0 "register_operand" "")
12842 (const_string "2")
12843 (const_string "*")))])
12844
371bc54b
JH
12845(define_insn "*rotrsi3_1_one_bit_zext"
12846 [(set (match_operand:DI 0 "register_operand" "=r")
12847 (zero_extend:DI
12848 (rotatert:SI (match_operand:SI 1 "register_operand" "0")
12849 (match_operand:QI 2 "const_int_1_operand" ""))))
12850 (clobber (reg:CC 17))]
12851 "TARGET_64BIT && ix86_binary_operator_ok (ROTATERT, SImode, operands)
495333a6 12852 && (TARGET_SHIFT1 || optimize_size)"
0f40f9f7 12853 "ror{l}\t%k0"
890d52e8 12854 [(set_attr "type" "rotate")
371bc54b
JH
12855 (set (attr "length")
12856 (if_then_else (match_operand:SI 0 "register_operand" "")
12857 (const_string "2")
12858 (const_string "*")))])
12859
d525dfdf 12860(define_insn "*rotrsi3_1"
e075ae69
RH
12861 [(set (match_operand:SI 0 "nonimmediate_operand" "=rm,rm")
12862 (rotatert:SI (match_operand:SI 1 "nonimmediate_operand" "0,0")
12863 (match_operand:QI 2 "nonmemory_operand" "I,c")))
12864 (clobber (reg:CC 17))]
d525dfdf 12865 "ix86_binary_operator_ok (ROTATERT, SImode, operands)"
e075ae69 12866 "@
0f40f9f7
ZW
12867 ror{l}\t{%2, %0|%0, %2}
12868 ror{l}\t{%b2, %0|%0, %b2}"
890d52e8 12869 [(set_attr "type" "rotate")
6ef67412 12870 (set_attr "mode" "SI")])
47af5d50 12871
371bc54b
JH
12872(define_insn "*rotrsi3_1_zext"
12873 [(set (match_operand:DI 0 "register_operand" "=r,r")
12874 (zero_extend:DI
12875 (rotatert:SI (match_operand:SI 1 "register_operand" "0,0")
12876 (match_operand:QI 2 "nonmemory_operand" "I,c"))))
12877 (clobber (reg:CC 17))]
12878 "TARGET_64BIT && ix86_binary_operator_ok (ROTATERT, SImode, operands)"
12879 "@
0f40f9f7
ZW
12880 ror{l}\t{%2, %k0|%k0, %2}
12881 ror{l}\t{%b2, %k0|%k0, %b2}"
890d52e8 12882 [(set_attr "type" "rotate")
371bc54b
JH
12883 (set_attr "mode" "SI")])
12884
d525dfdf
JH
12885(define_expand "rotrhi3"
12886 [(set (match_operand:HI 0 "nonimmediate_operand" "")
12887 (rotatert:HI (match_operand:HI 1 "nonimmediate_operand" "")
12888 (match_operand:QI 2 "nonmemory_operand" "")))
12889 (clobber (reg:CC 17))]
d9f32422 12890 "TARGET_HIMODE_MATH"
d525dfdf
JH
12891 "ix86_expand_binary_operator (ROTATERT, HImode, operands); DONE;")
12892
8bad7136
JL
12893(define_insn "*rotrhi3_one_bit"
12894 [(set (match_operand:HI 0 "nonimmediate_operand" "=rm")
12895 (rotatert:HI (match_operand:HI 1 "nonimmediate_operand" "0")
12896 (match_operand:QI 2 "const_int_1_operand" "")))
12897 (clobber (reg:CC 17))]
12898 "ix86_binary_operator_ok (ROTATERT, HImode, operands)
495333a6 12899 && (TARGET_SHIFT1 || optimize_size)"
0f40f9f7 12900 "ror{w}\t%0"
890d52e8 12901 [(set_attr "type" "rotate")
8bad7136 12902 (set (attr "length")
3d117b30 12903 (if_then_else (match_operand 0 "register_operand" "")
8bad7136
JL
12904 (const_string "2")
12905 (const_string "*")))])
12906
d525dfdf 12907(define_insn "*rotrhi3"
e075ae69
RH
12908 [(set (match_operand:HI 0 "nonimmediate_operand" "=rm,rm")
12909 (rotatert:HI (match_operand:HI 1 "nonimmediate_operand" "0,0")
12910 (match_operand:QI 2 "nonmemory_operand" "I,c")))
12911 (clobber (reg:CC 17))]
d525dfdf 12912 "ix86_binary_operator_ok (ROTATERT, HImode, operands)"
e075ae69 12913 "@
0f40f9f7
ZW
12914 ror{w}\t{%2, %0|%0, %2}
12915 ror{w}\t{%b2, %0|%0, %b2}"
890d52e8 12916 [(set_attr "type" "rotate")
6ef67412 12917 (set_attr "mode" "HI")])
a199fdd6 12918
d525dfdf
JH
12919(define_expand "rotrqi3"
12920 [(set (match_operand:QI 0 "nonimmediate_operand" "")
12921 (rotatert:QI (match_operand:QI 1 "nonimmediate_operand" "")
12922 (match_operand:QI 2 "nonmemory_operand" "")))
12923 (clobber (reg:CC 17))]
d9f32422 12924 "TARGET_QIMODE_MATH"
d525dfdf
JH
12925 "ix86_expand_binary_operator (ROTATERT, QImode, operands); DONE;")
12926
8bad7136
JL
12927(define_insn "*rotrqi3_1_one_bit"
12928 [(set (match_operand:QI 0 "nonimmediate_operand" "=qm")
12929 (rotatert:QI (match_operand:QI 1 "nonimmediate_operand" "0")
12930 (match_operand:QI 2 "const_int_1_operand" "")))
12931 (clobber (reg:CC 17))]
12932 "ix86_binary_operator_ok (ROTATERT, QImode, operands)
495333a6 12933 && (TARGET_SHIFT1 || optimize_size)"
0f40f9f7 12934 "ror{b}\t%0"
890d52e8 12935 [(set_attr "type" "rotate")
8bad7136 12936 (set (attr "length")
3d117b30 12937 (if_then_else (match_operand 0 "register_operand" "")
8bad7136
JL
12938 (const_string "2")
12939 (const_string "*")))])
12940
2f41793e
JH
12941(define_insn "*rotrqi3_1_one_bit_slp"
12942 [(set (strict_low_part (match_operand:QI 0 "nonimmediate_operand" "+qm"))
1b245ade
JH
12943 (rotatert:QI (match_dup 0)
12944 (match_operand:QI 1 "const_int_1_operand" "")))
2f41793e
JH
12945 (clobber (reg:CC 17))]
12946 "(! TARGET_PARTIAL_REG_STALL || optimize_size)
495333a6 12947 && (TARGET_SHIFT1 || optimize_size)"
2f41793e 12948 "ror{b}\t%0"
1b245ade 12949 [(set_attr "type" "rotate1")
2f41793e
JH
12950 (set (attr "length")
12951 (if_then_else (match_operand 0 "register_operand" "")
12952 (const_string "2")
12953 (const_string "*")))])
12954
d525dfdf 12955(define_insn "*rotrqi3_1"
e075ae69
RH
12956 [(set (match_operand:QI 0 "nonimmediate_operand" "=qm,qm")
12957 (rotatert:QI (match_operand:QI 1 "nonimmediate_operand" "0,0")
12958 (match_operand:QI 2 "nonmemory_operand" "I,c")))
12959 (clobber (reg:CC 17))]
d525dfdf 12960 "ix86_binary_operator_ok (ROTATERT, QImode, operands)"
e075ae69 12961 "@
0f40f9f7
ZW
12962 ror{b}\t{%2, %0|%0, %2}
12963 ror{b}\t{%b2, %0|%0, %b2}"
890d52e8 12964 [(set_attr "type" "rotate")
6ef67412 12965 (set_attr "mode" "QI")])
2f41793e
JH
12966
12967(define_insn "*rotrqi3_1_slp"
12968 [(set (strict_low_part (match_operand:QI 0 "nonimmediate_operand" "+qm,qm"))
1b245ade
JH
12969 (rotatert:QI (match_dup 0)
12970 (match_operand:QI 1 "nonmemory_operand" "I,c")))
2f41793e
JH
12971 (clobber (reg:CC 17))]
12972 "(! TARGET_PARTIAL_REG_STALL || optimize_size)
1b245ade 12973 && (GET_CODE (operands[0]) != MEM || GET_CODE (operands[1]) != MEM)"
2f41793e 12974 "@
1b245ade
JH
12975 ror{b}\t{%1, %0|%0, %1}
12976 ror{b}\t{%b1, %0|%0, %b1}"
12977 [(set_attr "type" "rotate1")
2f41793e 12978 (set_attr "mode" "QI")])
e075ae69
RH
12979\f
12980;; Bit set / bit test instructions
a199fdd6 12981
e075ae69
RH
12982(define_expand "extv"
12983 [(set (match_operand:SI 0 "register_operand" "")
12984 (sign_extract:SI (match_operand:SI 1 "register_operand" "")
12985 (match_operand:SI 2 "immediate_operand" "")
12986 (match_operand:SI 3 "immediate_operand" "")))]
12987 ""
e075ae69
RH
12988{
12989 /* Handle extractions from %ah et al. */
12990 if (INTVAL (operands[2]) != 8 || INTVAL (operands[3]) != 8)
12991 FAIL;
a199fdd6 12992
e075ae69
RH
12993 /* From mips.md: extract_bit_field doesn't verify that our source
12994 matches the predicate, so check it again here. */
12995 if (! register_operand (operands[1], VOIDmode))
12996 FAIL;
0f40f9f7 12997})
a199fdd6 12998
e075ae69
RH
12999(define_expand "extzv"
13000 [(set (match_operand:SI 0 "register_operand" "")
13001 (zero_extract:SI (match_operand 1 "ext_register_operand" "")
13002 (match_operand:SI 2 "immediate_operand" "")
13003 (match_operand:SI 3 "immediate_operand" "")))]
13004 ""
e075ae69
RH
13005{
13006 /* Handle extractions from %ah et al. */
13007 if (INTVAL (operands[2]) != 8 || INTVAL (operands[3]) != 8)
13008 FAIL;
a199fdd6 13009
e075ae69
RH
13010 /* From mips.md: extract_bit_field doesn't verify that our source
13011 matches the predicate, so check it again here. */
13012 if (! register_operand (operands[1], VOIDmode))
13013 FAIL;
0f40f9f7 13014})
a199fdd6 13015
e075ae69
RH
13016(define_expand "insv"
13017 [(set (zero_extract:SI (match_operand 0 "ext_register_operand" "")
13018 (match_operand:SI 1 "immediate_operand" "")
13019 (match_operand:SI 2 "immediate_operand" ""))
13020 (match_operand:SI 3 "register_operand" ""))]
13021 ""
e075ae69
RH
13022{
13023 /* Handle extractions from %ah et al. */
13024 if (INTVAL (operands[1]) != 8 || INTVAL (operands[2]) != 8)
13025 FAIL;
a199fdd6 13026
e075ae69
RH
13027 /* From mips.md: insert_bit_field doesn't verify that our source
13028 matches the predicate, so check it again here. */
13029 if (! register_operand (operands[0], VOIDmode))
13030 FAIL;
0f40f9f7 13031})
e075ae69
RH
13032
13033;; %%% bts, btr, btc, bt.
886c62d1
JVA
13034\f
13035;; Store-flag instructions.
13036
c572e5ba
JVA
13037;; For all sCOND expanders, also expand the compare or test insn that
13038;; generates cc0. Generate an equality comparison if `seq' or `sne'.
13039
e075ae69
RH
13040;; %%% Do the expansion to SImode. If PII, do things the xor+setcc way
13041;; to avoid partial register stalls. Otherwise do things the setcc+movzx
13042;; way, which can later delete the movzx if only QImode is needed.
13043
c572e5ba 13044(define_expand "seq"
b932f770
JH
13045 [(set (match_operand:QI 0 "register_operand" "")
13046 (eq:QI (reg:CC 17) (const_int 0)))]
c572e5ba 13047 ""
3a3677ff 13048 "if (ix86_expand_setcc (EQ, operands[0])) DONE; else FAIL;")
c572e5ba 13049
c572e5ba 13050(define_expand "sne"
b932f770
JH
13051 [(set (match_operand:QI 0 "register_operand" "")
13052 (ne:QI (reg:CC 17) (const_int 0)))]
c572e5ba 13053 ""
3a3677ff 13054 "if (ix86_expand_setcc (NE, operands[0])) DONE; else FAIL;")
c572e5ba 13055
c572e5ba 13056(define_expand "sgt"
b932f770
JH
13057 [(set (match_operand:QI 0 "register_operand" "")
13058 (gt:QI (reg:CC 17) (const_int 0)))]
c572e5ba 13059 ""
3a3677ff 13060 "if (ix86_expand_setcc (GT, operands[0])) DONE; else FAIL;")
c572e5ba 13061
c572e5ba 13062(define_expand "sgtu"
b932f770
JH
13063 [(set (match_operand:QI 0 "register_operand" "")
13064 (gtu:QI (reg:CC 17) (const_int 0)))]
c572e5ba 13065 ""
3a3677ff 13066 "if (ix86_expand_setcc (GTU, operands[0])) DONE; else FAIL;")
c572e5ba 13067
c572e5ba 13068(define_expand "slt"
b932f770
JH
13069 [(set (match_operand:QI 0 "register_operand" "")
13070 (lt:QI (reg:CC 17) (const_int 0)))]
c572e5ba 13071 ""
3a3677ff 13072 "if (ix86_expand_setcc (LT, operands[0])) DONE; else FAIL;")
c572e5ba 13073
c572e5ba 13074(define_expand "sltu"
b932f770
JH
13075 [(set (match_operand:QI 0 "register_operand" "")
13076 (ltu:QI (reg:CC 17) (const_int 0)))]
c572e5ba 13077 ""
3a3677ff 13078 "if (ix86_expand_setcc (LTU, operands[0])) DONE; else FAIL;")
c572e5ba 13079
c572e5ba 13080(define_expand "sge"
b932f770
JH
13081 [(set (match_operand:QI 0 "register_operand" "")
13082 (ge:QI (reg:CC 17) (const_int 0)))]
c572e5ba 13083 ""
3a3677ff 13084 "if (ix86_expand_setcc (GE, operands[0])) DONE; else FAIL;")
c572e5ba 13085
c572e5ba 13086(define_expand "sgeu"
b932f770
JH
13087 [(set (match_operand:QI 0 "register_operand" "")
13088 (geu:QI (reg:CC 17) (const_int 0)))]
c572e5ba 13089 ""
3a3677ff 13090 "if (ix86_expand_setcc (GEU, operands[0])) DONE; else FAIL;")
c572e5ba 13091
c572e5ba 13092(define_expand "sle"
b932f770
JH
13093 [(set (match_operand:QI 0 "register_operand" "")
13094 (le:QI (reg:CC 17) (const_int 0)))]
c572e5ba 13095 ""
3a3677ff 13096 "if (ix86_expand_setcc (LE, operands[0])) DONE; else FAIL;")
c572e5ba 13097
c785c660 13098(define_expand "sleu"
b932f770
JH
13099 [(set (match_operand:QI 0 "register_operand" "")
13100 (leu:QI (reg:CC 17) (const_int 0)))]
c785c660 13101 ""
3a3677ff
RH
13102 "if (ix86_expand_setcc (LEU, operands[0])) DONE; else FAIL;")
13103
13104(define_expand "sunordered"
b932f770
JH
13105 [(set (match_operand:QI 0 "register_operand" "")
13106 (unordered:QI (reg:CC 17) (const_int 0)))]
0644b628 13107 "TARGET_80387 || TARGET_SSE"
3a3677ff
RH
13108 "if (ix86_expand_setcc (UNORDERED, operands[0])) DONE; else FAIL;")
13109
13110(define_expand "sordered"
b932f770
JH
13111 [(set (match_operand:QI 0 "register_operand" "")
13112 (ordered:QI (reg:CC 17) (const_int 0)))]
3a3677ff
RH
13113 "TARGET_80387"
13114 "if (ix86_expand_setcc (ORDERED, operands[0])) DONE; else FAIL;")
13115
13116(define_expand "suneq"
b932f770
JH
13117 [(set (match_operand:QI 0 "register_operand" "")
13118 (uneq:QI (reg:CC 17) (const_int 0)))]
0644b628 13119 "TARGET_80387 || TARGET_SSE"
3a3677ff
RH
13120 "if (ix86_expand_setcc (UNEQ, operands[0])) DONE; else FAIL;")
13121
13122(define_expand "sunge"
b932f770
JH
13123 [(set (match_operand:QI 0 "register_operand" "")
13124 (unge:QI (reg:CC 17) (const_int 0)))]
0644b628 13125 "TARGET_80387 || TARGET_SSE"
3a3677ff
RH
13126 "if (ix86_expand_setcc (UNGE, operands[0])) DONE; else FAIL;")
13127
13128(define_expand "sungt"
b932f770
JH
13129 [(set (match_operand:QI 0 "register_operand" "")
13130 (ungt:QI (reg:CC 17) (const_int 0)))]
0644b628 13131 "TARGET_80387 || TARGET_SSE"
3a3677ff
RH
13132 "if (ix86_expand_setcc (UNGT, operands[0])) DONE; else FAIL;")
13133
13134(define_expand "sunle"
b932f770
JH
13135 [(set (match_operand:QI 0 "register_operand" "")
13136 (unle:QI (reg:CC 17) (const_int 0)))]
0644b628 13137 "TARGET_80387 || TARGET_SSE"
3a3677ff
RH
13138 "if (ix86_expand_setcc (UNLE, operands[0])) DONE; else FAIL;")
13139
13140(define_expand "sunlt"
b932f770
JH
13141 [(set (match_operand:QI 0 "register_operand" "")
13142 (unlt:QI (reg:CC 17) (const_int 0)))]
0644b628 13143 "TARGET_80387 || TARGET_SSE"
3a3677ff
RH
13144 "if (ix86_expand_setcc (UNLT, operands[0])) DONE; else FAIL;")
13145
13146(define_expand "sltgt"
b932f770
JH
13147 [(set (match_operand:QI 0 "register_operand" "")
13148 (ltgt:QI (reg:CC 17) (const_int 0)))]
0644b628 13149 "TARGET_80387 || TARGET_SSE"
3a3677ff 13150 "if (ix86_expand_setcc (LTGT, operands[0])) DONE; else FAIL;")
c785c660 13151
e075ae69 13152(define_insn "*setcc_1"
a269a03c 13153 [(set (match_operand:QI 0 "nonimmediate_operand" "=qm")
9076b9c1 13154 (match_operator:QI 1 "ix86_comparison_operator"
e075ae69
RH
13155 [(reg 17) (const_int 0)]))]
13156 ""
0f40f9f7 13157 "set%C1\t%0"
6ef67412
JH
13158 [(set_attr "type" "setcc")
13159 (set_attr "mode" "QI")])
a269a03c 13160
bd793c65 13161(define_insn "setcc_2"
e075ae69 13162 [(set (strict_low_part (match_operand:QI 0 "nonimmediate_operand" "+qm"))
9076b9c1 13163 (match_operator:QI 1 "ix86_comparison_operator"
e075ae69
RH
13164 [(reg 17) (const_int 0)]))]
13165 ""
0f40f9f7 13166 "set%C1\t%0"
6ef67412
JH
13167 [(set_attr "type" "setcc")
13168 (set_attr "mode" "QI")])
e075ae69 13169
10978207
RH
13170;; In general it is not safe to assume too much about CCmode registers,
13171;; so simplify-rtx stops when it sees a second one. Under certain
13172;; conditions this is safe on x86, so help combine not create
13173;;
13174;; seta %al
13175;; testb %al, %al
13176;; sete %al
13177
13178(define_split
13179 [(set (match_operand:QI 0 "nonimmediate_operand" "")
13180 (ne:QI (match_operator 1 "ix86_comparison_operator"
13181 [(reg 17) (const_int 0)])
13182 (const_int 0)))]
13183 ""
13184 [(set (match_dup 0) (match_dup 1))]
13185{
13186 PUT_MODE (operands[1], QImode);
13187})
13188
13189(define_split
13190 [(set (strict_low_part (match_operand:QI 0 "nonimmediate_operand" ""))
13191 (ne:QI (match_operator 1 "ix86_comparison_operator"
13192 [(reg 17) (const_int 0)])
13193 (const_int 0)))]
13194 ""
13195 [(set (match_dup 0) (match_dup 1))]
13196{
13197 PUT_MODE (operands[1], QImode);
13198})
13199
13200(define_split
13201 [(set (match_operand:QI 0 "nonimmediate_operand" "")
13202 (eq:QI (match_operator 1 "ix86_comparison_operator"
13203 [(reg 17) (const_int 0)])
13204 (const_int 0)))]
13205 ""
13206 [(set (match_dup 0) (match_dup 1))]
13207{
13208 rtx new_op1 = copy_rtx (operands[1]);
13209 operands[1] = new_op1;
13210 PUT_MODE (new_op1, QImode);
13211 PUT_CODE (new_op1, REVERSE_CONDITION (GET_CODE (new_op1),
13212 GET_MODE (XEXP (new_op1, 0))));
13213
13214 /* Make sure that (a) the CCmode we have for the flags is strong
13215 enough for the reversed compare or (b) we have a valid FP compare. */
13216 if (! ix86_comparison_operator (new_op1, VOIDmode))
13217 FAIL;
13218})
13219
13220(define_split
13221 [(set (strict_low_part (match_operand:QI 0 "nonimmediate_operand" ""))
13222 (eq:QI (match_operator 1 "ix86_comparison_operator"
13223 [(reg 17) (const_int 0)])
13224 (const_int 0)))]
13225 ""
13226 [(set (match_dup 0) (match_dup 1))]
13227{
13228 rtx new_op1 = copy_rtx (operands[1]);
13229 operands[1] = new_op1;
13230 PUT_MODE (new_op1, QImode);
13231 PUT_CODE (new_op1, REVERSE_CONDITION (GET_CODE (new_op1),
13232 GET_MODE (XEXP (new_op1, 0))));
13233
13234 /* Make sure that (a) the CCmode we have for the flags is strong
13235 enough for the reversed compare or (b) we have a valid FP compare. */
13236 if (! ix86_comparison_operator (new_op1, VOIDmode))
13237 FAIL;
13238})
13239
a46d1d38
JH
13240;; The SSE store flag instructions saves 0 or 0xffffffff to the result.
13241;; subsequent logical operations are used to imitate conditional moves.
13242;; 0xffffffff is NaN, but not in normalized form, so we can't represent
d1f87653 13243;; it directly. Further holding this value in pseudo register might bring
a46d1d38
JH
13244;; problem in implicit normalization in spill code.
13245;; So we don't define FLOAT_STORE_FLAG_VALUE and create these
13246;; instructions after reload by splitting the conditional move patterns.
13247
13248(define_insn "*sse_setccsf"
13249 [(set (match_operand:SF 0 "register_operand" "=x")
13250 (match_operator:SF 1 "sse_comparison_operator"
13251 [(match_operand:SF 2 "register_operand" "0")
13252 (match_operand:SF 3 "nonimmediate_operand" "xm")]))]
13253 "TARGET_SSE && reload_completed"
0f40f9f7 13254 "cmp%D1ss\t{%3, %0|%0, %3}"
3d34cd91 13255 [(set_attr "type" "ssecmp")
a46d1d38
JH
13256 (set_attr "mode" "SF")])
13257
13258(define_insn "*sse_setccdf"
13259 [(set (match_operand:DF 0 "register_operand" "=Y")
13260 (match_operator:DF 1 "sse_comparison_operator"
13261 [(match_operand:DF 2 "register_operand" "0")
13262 (match_operand:DF 3 "nonimmediate_operand" "Ym")]))]
13263 "TARGET_SSE2 && reload_completed"
0f40f9f7 13264 "cmp%D1sd\t{%3, %0|%0, %3}"
3d34cd91 13265 [(set_attr "type" "ssecmp")
a46d1d38 13266 (set_attr "mode" "DF")])
886c62d1
JVA
13267\f
13268;; Basic conditional jump instructions.
13269;; We ignore the overflow flag for signed branch instructions.
13270
c572e5ba 13271;; For all bCOND expanders, also expand the compare or test insn that
e075ae69 13272;; generates reg 17. Generate an equality comparison if `beq' or `bne'.
c572e5ba
JVA
13273
13274(define_expand "beq"
e075ae69
RH
13275 [(set (pc)
13276 (if_then_else (match_dup 1)
c572e5ba
JVA
13277 (label_ref (match_operand 0 "" ""))
13278 (pc)))]
13279 ""
3a3677ff 13280 "ix86_expand_branch (EQ, operands[0]); DONE;")
c572e5ba 13281
c572e5ba 13282(define_expand "bne"
e075ae69
RH
13283 [(set (pc)
13284 (if_then_else (match_dup 1)
c572e5ba
JVA
13285 (label_ref (match_operand 0 "" ""))
13286 (pc)))]
13287 ""
3a3677ff 13288 "ix86_expand_branch (NE, operands[0]); DONE;")
886c62d1 13289
c572e5ba 13290(define_expand "bgt"
e075ae69
RH
13291 [(set (pc)
13292 (if_then_else (match_dup 1)
c572e5ba
JVA
13293 (label_ref (match_operand 0 "" ""))
13294 (pc)))]
13295 ""
3a3677ff 13296 "ix86_expand_branch (GT, operands[0]); DONE;")
c572e5ba 13297
c572e5ba 13298(define_expand "bgtu"
e075ae69
RH
13299 [(set (pc)
13300 (if_then_else (match_dup 1)
c572e5ba
JVA
13301 (label_ref (match_operand 0 "" ""))
13302 (pc)))]
13303 ""
3a3677ff 13304 "ix86_expand_branch (GTU, operands[0]); DONE;")
886c62d1 13305
886c62d1 13306(define_expand "blt"
e075ae69
RH
13307 [(set (pc)
13308 (if_then_else (match_dup 1)
886c62d1
JVA
13309 (label_ref (match_operand 0 "" ""))
13310 (pc)))]
13311 ""
3a3677ff 13312 "ix86_expand_branch (LT, operands[0]); DONE;")
886c62d1 13313
c572e5ba 13314(define_expand "bltu"
e075ae69
RH
13315 [(set (pc)
13316 (if_then_else (match_dup 1)
c572e5ba
JVA
13317 (label_ref (match_operand 0 "" ""))
13318 (pc)))]
13319 ""
3a3677ff 13320 "ix86_expand_branch (LTU, operands[0]); DONE;")
c572e5ba 13321
c572e5ba 13322(define_expand "bge"
e075ae69
RH
13323 [(set (pc)
13324 (if_then_else (match_dup 1)
c572e5ba
JVA
13325 (label_ref (match_operand 0 "" ""))
13326 (pc)))]
13327 ""
3a3677ff 13328 "ix86_expand_branch (GE, operands[0]); DONE;")
c572e5ba 13329
c572e5ba 13330(define_expand "bgeu"
e075ae69
RH
13331 [(set (pc)
13332 (if_then_else (match_dup 1)
c572e5ba
JVA
13333 (label_ref (match_operand 0 "" ""))
13334 (pc)))]
13335 ""
3a3677ff 13336 "ix86_expand_branch (GEU, operands[0]); DONE;")
886c62d1 13337
886c62d1 13338(define_expand "ble"
e075ae69
RH
13339 [(set (pc)
13340 (if_then_else (match_dup 1)
886c62d1
JVA
13341 (label_ref (match_operand 0 "" ""))
13342 (pc)))]
13343 ""
3a3677ff 13344 "ix86_expand_branch (LE, operands[0]); DONE;")
886c62d1 13345
c572e5ba 13346(define_expand "bleu"
e075ae69
RH
13347 [(set (pc)
13348 (if_then_else (match_dup 1)
c572e5ba
JVA
13349 (label_ref (match_operand 0 "" ""))
13350 (pc)))]
13351 ""
3a3677ff
RH
13352 "ix86_expand_branch (LEU, operands[0]); DONE;")
13353
13354(define_expand "bunordered"
13355 [(set (pc)
13356 (if_then_else (match_dup 1)
13357 (label_ref (match_operand 0 "" ""))
13358 (pc)))]
0644b628 13359 "TARGET_80387 || TARGET_SSE"
3a3677ff
RH
13360 "ix86_expand_branch (UNORDERED, operands[0]); DONE;")
13361
13362(define_expand "bordered"
13363 [(set (pc)
13364 (if_then_else (match_dup 1)
13365 (label_ref (match_operand 0 "" ""))
13366 (pc)))]
0644b628 13367 "TARGET_80387 || TARGET_SSE"
3a3677ff
RH
13368 "ix86_expand_branch (ORDERED, operands[0]); DONE;")
13369
13370(define_expand "buneq"
13371 [(set (pc)
13372 (if_then_else (match_dup 1)
13373 (label_ref (match_operand 0 "" ""))
13374 (pc)))]
0644b628 13375 "TARGET_80387 || TARGET_SSE"
3a3677ff
RH
13376 "ix86_expand_branch (UNEQ, operands[0]); DONE;")
13377
13378(define_expand "bunge"
13379 [(set (pc)
13380 (if_then_else (match_dup 1)
13381 (label_ref (match_operand 0 "" ""))
13382 (pc)))]
0644b628 13383 "TARGET_80387 || TARGET_SSE"
3a3677ff
RH
13384 "ix86_expand_branch (UNGE, operands[0]); DONE;")
13385
13386(define_expand "bungt"
13387 [(set (pc)
13388 (if_then_else (match_dup 1)
13389 (label_ref (match_operand 0 "" ""))
13390 (pc)))]
0644b628 13391 "TARGET_80387 || TARGET_SSE"
3a3677ff
RH
13392 "ix86_expand_branch (UNGT, operands[0]); DONE;")
13393
13394(define_expand "bunle"
13395 [(set (pc)
13396 (if_then_else (match_dup 1)
13397 (label_ref (match_operand 0 "" ""))
13398 (pc)))]
0644b628 13399 "TARGET_80387 || TARGET_SSE"
3a3677ff
RH
13400 "ix86_expand_branch (UNLE, operands[0]); DONE;")
13401
13402(define_expand "bunlt"
13403 [(set (pc)
13404 (if_then_else (match_dup 1)
13405 (label_ref (match_operand 0 "" ""))
13406 (pc)))]
0644b628 13407 "TARGET_80387 || TARGET_SSE"
3a3677ff
RH
13408 "ix86_expand_branch (UNLT, operands[0]); DONE;")
13409
13410(define_expand "bltgt"
13411 [(set (pc)
13412 (if_then_else (match_dup 1)
13413 (label_ref (match_operand 0 "" ""))
13414 (pc)))]
0644b628 13415 "TARGET_80387 || TARGET_SSE"
3a3677ff 13416 "ix86_expand_branch (LTGT, operands[0]); DONE;")
886c62d1 13417
e075ae69
RH
13418(define_insn "*jcc_1"
13419 [(set (pc)
9076b9c1 13420 (if_then_else (match_operator 1 "ix86_comparison_operator"
e075ae69 13421 [(reg 17) (const_int 0)])
6ef67412 13422 (label_ref (match_operand 0 "" ""))
e075ae69
RH
13423 (pc)))]
13424 ""
0f40f9f7 13425 "%+j%C1\t%l0"
e075ae69 13426 [(set_attr "type" "ibr")
c7375e61 13427 (set_attr "modrm" "0")
efcc7037 13428 (set (attr "length")
6ef67412
JH
13429 (if_then_else (and (ge (minus (match_dup 0) (pc))
13430 (const_int -128))
13431 (lt (minus (match_dup 0) (pc))
13432 (const_int 124)))
efcc7037
JH
13433 (const_int 2)
13434 (const_int 6)))])
e075ae69
RH
13435
13436(define_insn "*jcc_2"
13437 [(set (pc)
9076b9c1 13438 (if_then_else (match_operator 1 "ix86_comparison_operator"
e075ae69
RH
13439 [(reg 17) (const_int 0)])
13440 (pc)
6ef67412 13441 (label_ref (match_operand 0 "" ""))))]
e075ae69 13442 ""
0f40f9f7 13443 "%+j%c1\t%l0"
e075ae69 13444 [(set_attr "type" "ibr")
c7375e61 13445 (set_attr "modrm" "0")
efcc7037 13446 (set (attr "length")
6ef67412
JH
13447 (if_then_else (and (ge (minus (match_dup 0) (pc))
13448 (const_int -128))
13449 (lt (minus (match_dup 0) (pc))
13450 (const_int 124)))
efcc7037
JH
13451 (const_int 2)
13452 (const_int 6)))])
e075ae69 13453
592188a5
RH
13454;; In general it is not safe to assume too much about CCmode registers,
13455;; so simplify-rtx stops when it sees a second one. Under certain
13456;; conditions this is safe on x86, so help combine not create
13457;;
13458;; seta %al
13459;; testb %al, %al
13460;; je Lfoo
13461
13462(define_split
13463 [(set (pc)
13464 (if_then_else (ne (match_operator 0 "ix86_comparison_operator"
13465 [(reg 17) (const_int 0)])
13466 (const_int 0))
13467 (label_ref (match_operand 1 "" ""))
13468 (pc)))]
13469 ""
13470 [(set (pc)
13471 (if_then_else (match_dup 0)
13472 (label_ref (match_dup 1))
13473 (pc)))]
13474{
13475 PUT_MODE (operands[0], VOIDmode);
13476})
13477
13478(define_split
13479 [(set (pc)
13480 (if_then_else (eq (match_operator 0 "ix86_comparison_operator"
13481 [(reg 17) (const_int 0)])
13482 (const_int 0))
13483 (label_ref (match_operand 1 "" ""))
13484 (pc)))]
13485 ""
13486 [(set (pc)
13487 (if_then_else (match_dup 0)
13488 (label_ref (match_dup 1))
13489 (pc)))]
13490{
13491 rtx new_op0 = copy_rtx (operands[0]);
13492 operands[0] = new_op0;
13493 PUT_MODE (new_op0, VOIDmode);
13494 PUT_CODE (new_op0, REVERSE_CONDITION (GET_CODE (new_op0),
13495 GET_MODE (XEXP (new_op0, 0))));
13496
13497 /* Make sure that (a) the CCmode we have for the flags is strong
13498 enough for the reversed compare or (b) we have a valid FP compare. */
13499 if (! ix86_comparison_operator (new_op0, VOIDmode))
13500 FAIL;
13501})
13502
3a3677ff
RH
13503;; Define combination compare-and-branch fp compare instructions to use
13504;; during early optimization. Splitting the operation apart early makes
13505;; for bad code when we want to reverse the operation.
13506
13507(define_insn "*fp_jcc_1"
13508 [(set (pc)
13509 (if_then_else (match_operator 0 "comparison_operator"
13510 [(match_operand 1 "register_operand" "f")
13511 (match_operand 2 "register_operand" "f")])
13512 (label_ref (match_operand 3 "" ""))
13513 (pc)))
13514 (clobber (reg:CCFP 18))
13515 (clobber (reg:CCFP 17))]
13516 "TARGET_CMOVE && TARGET_80387
0644b628 13517 && !SSE_FLOAT_MODE_P (GET_MODE (operands[1]))
3a3677ff 13518 && FLOAT_MODE_P (GET_MODE (operands[1]))
03598dea
JH
13519 && GET_MODE (operands[1]) == GET_MODE (operands[2])
13520 && ix86_fp_jump_nontrivial_p (GET_CODE (operands[0]))"
3a3677ff
RH
13521 "#")
13522
0644b628
JH
13523(define_insn "*fp_jcc_1_sse"
13524 [(set (pc)
13525 (if_then_else (match_operator 0 "comparison_operator"
13526 [(match_operand 1 "register_operand" "f#x,x#f")
13527 (match_operand 2 "nonimmediate_operand" "f#x,xm#f")])
13528 (label_ref (match_operand 3 "" ""))
13529 (pc)))
13530 (clobber (reg:CCFP 18))
13531 (clobber (reg:CCFP 17))]
13532 "TARGET_80387
13533 && SSE_FLOAT_MODE_P (GET_MODE (operands[1]))
03598dea
JH
13534 && GET_MODE (operands[1]) == GET_MODE (operands[2])
13535 && ix86_fp_jump_nontrivial_p (GET_CODE (operands[0]))"
0644b628
JH
13536 "#")
13537
13538(define_insn "*fp_jcc_1_sse_only"
13539 [(set (pc)
13540 (if_then_else (match_operator 0 "comparison_operator"
13541 [(match_operand 1 "register_operand" "x")
13542 (match_operand 2 "nonimmediate_operand" "xm")])
13543 (label_ref (match_operand 3 "" ""))
13544 (pc)))
13545 (clobber (reg:CCFP 18))
13546 (clobber (reg:CCFP 17))]
13547 "SSE_FLOAT_MODE_P (GET_MODE (operands[1]))
03598dea
JH
13548 && GET_MODE (operands[1]) == GET_MODE (operands[2])
13549 && ix86_fp_jump_nontrivial_p (GET_CODE (operands[0]))"
0644b628
JH
13550 "#")
13551
3a3677ff
RH
13552(define_insn "*fp_jcc_2"
13553 [(set (pc)
13554 (if_then_else (match_operator 0 "comparison_operator"
13555 [(match_operand 1 "register_operand" "f")
13556 (match_operand 2 "register_operand" "f")])
13557 (pc)
13558 (label_ref (match_operand 3 "" ""))))
13559 (clobber (reg:CCFP 18))
13560 (clobber (reg:CCFP 17))]
13561 "TARGET_CMOVE && TARGET_80387
0644b628 13562 && !SSE_FLOAT_MODE_P (GET_MODE (operands[1]))
3a3677ff 13563 && FLOAT_MODE_P (GET_MODE (operands[1]))
03598dea
JH
13564 && GET_MODE (operands[1]) == GET_MODE (operands[2])
13565 && ix86_fp_jump_nontrivial_p (GET_CODE (operands[0]))"
3a3677ff
RH
13566 "#")
13567
0644b628
JH
13568(define_insn "*fp_jcc_2_sse"
13569 [(set (pc)
13570 (if_then_else (match_operator 0 "comparison_operator"
13571 [(match_operand 1 "register_operand" "f#x,x#f")
13572 (match_operand 2 "nonimmediate_operand" "f#x,xm#f")])
13573 (pc)
13574 (label_ref (match_operand 3 "" ""))))
13575 (clobber (reg:CCFP 18))
13576 (clobber (reg:CCFP 17))]
13577 "TARGET_80387
13578 && SSE_FLOAT_MODE_P (GET_MODE (operands[1]))
03598dea
JH
13579 && GET_MODE (operands[1]) == GET_MODE (operands[2])
13580 && ix86_fp_jump_nontrivial_p (GET_CODE (operands[0]))"
0644b628
JH
13581 "#")
13582
13583(define_insn "*fp_jcc_2_sse_only"
13584 [(set (pc)
13585 (if_then_else (match_operator 0 "comparison_operator"
13586 [(match_operand 1 "register_operand" "x")
13587 (match_operand 2 "nonimmediate_operand" "xm")])
13588 (pc)
13589 (label_ref (match_operand 3 "" ""))))
13590 (clobber (reg:CCFP 18))
13591 (clobber (reg:CCFP 17))]
13592 "SSE_FLOAT_MODE_P (GET_MODE (operands[1]))
03598dea
JH
13593 && GET_MODE (operands[1]) == GET_MODE (operands[2])
13594 && ix86_fp_jump_nontrivial_p (GET_CODE (operands[0]))"
0644b628
JH
13595 "#")
13596
3a3677ff
RH
13597(define_insn "*fp_jcc_3"
13598 [(set (pc)
b1cdafbb 13599 (if_then_else (match_operator 0 "comparison_operator"
3a3677ff
RH
13600 [(match_operand 1 "register_operand" "f")
13601 (match_operand 2 "nonimmediate_operand" "fm")])
13602 (label_ref (match_operand 3 "" ""))
13603 (pc)))
13604 (clobber (reg:CCFP 18))
13605 (clobber (reg:CCFP 17))
13606 (clobber (match_scratch:HI 4 "=a"))]
13607 "TARGET_80387
13608 && (GET_MODE (operands[1]) == SFmode || GET_MODE (operands[1]) == DFmode)
a940d8bd 13609 && GET_MODE (operands[1]) == GET_MODE (operands[2])
b1cdafbb
JH
13610 && !ix86_use_fcomi_compare (GET_CODE (operands[0]))
13611 && SELECT_CC_MODE (GET_CODE (operands[0]),
03598dea
JH
13612 operands[1], operands[2]) == CCFPmode
13613 && ix86_fp_jump_nontrivial_p (GET_CODE (operands[0]))"
3a3677ff
RH
13614 "#")
13615
13616(define_insn "*fp_jcc_4"
13617 [(set (pc)
b1cdafbb 13618 (if_then_else (match_operator 0 "comparison_operator"
3a3677ff
RH
13619 [(match_operand 1 "register_operand" "f")
13620 (match_operand 2 "nonimmediate_operand" "fm")])
13621 (pc)
13622 (label_ref (match_operand 3 "" ""))))
13623 (clobber (reg:CCFP 18))
13624 (clobber (reg:CCFP 17))
13625 (clobber (match_scratch:HI 4 "=a"))]
13626 "TARGET_80387
13627 && (GET_MODE (operands[1]) == SFmode || GET_MODE (operands[1]) == DFmode)
a940d8bd 13628 && GET_MODE (operands[1]) == GET_MODE (operands[2])
b1cdafbb
JH
13629 && !ix86_use_fcomi_compare (GET_CODE (operands[0]))
13630 && SELECT_CC_MODE (GET_CODE (operands[0]),
03598dea
JH
13631 operands[1], operands[2]) == CCFPmode
13632 && ix86_fp_jump_nontrivial_p (GET_CODE (operands[0]))"
3a3677ff
RH
13633 "#")
13634
13635(define_insn "*fp_jcc_5"
13636 [(set (pc)
13637 (if_then_else (match_operator 0 "comparison_operator"
13638 [(match_operand 1 "register_operand" "f")
13639 (match_operand 2 "register_operand" "f")])
13640 (label_ref (match_operand 3 "" ""))
13641 (pc)))
13642 (clobber (reg:CCFP 18))
13643 (clobber (reg:CCFP 17))
13644 (clobber (match_scratch:HI 4 "=a"))]
13645 "TARGET_80387
13646 && FLOAT_MODE_P (GET_MODE (operands[1]))
03598dea
JH
13647 && GET_MODE (operands[1]) == GET_MODE (operands[2])
13648 && ix86_fp_jump_nontrivial_p (GET_CODE (operands[0]))"
3a3677ff
RH
13649 "#")
13650
13651(define_insn "*fp_jcc_6"
13652 [(set (pc)
13653 (if_then_else (match_operator 0 "comparison_operator"
13654 [(match_operand 1 "register_operand" "f")
13655 (match_operand 2 "register_operand" "f")])
13656 (pc)
13657 (label_ref (match_operand 3 "" ""))))
13658 (clobber (reg:CCFP 18))
13659 (clobber (reg:CCFP 17))
13660 (clobber (match_scratch:HI 4 "=a"))]
13661 "TARGET_80387
13662 && FLOAT_MODE_P (GET_MODE (operands[1]))
03598dea
JH
13663 && GET_MODE (operands[1]) == GET_MODE (operands[2])
13664 && ix86_fp_jump_nontrivial_p (GET_CODE (operands[0]))"
3a3677ff
RH
13665 "#")
13666
13667(define_split
13668 [(set (pc)
13669 (if_then_else (match_operator 0 "comparison_operator"
13670 [(match_operand 1 "register_operand" "")
13671 (match_operand 2 "nonimmediate_operand" "")])
13672 (match_operand 3 "" "")
13673 (match_operand 4 "" "")))
13674 (clobber (reg:CCFP 18))
13675 (clobber (reg:CCFP 17))]
13676 "reload_completed"
9e7adcb3 13677 [(const_int 0)]
3a3677ff 13678{
03598dea 13679 ix86_split_fp_branch (GET_CODE (operands[0]), operands[1], operands[2],
9e7adcb3
JH
13680 operands[3], operands[4], NULL_RTX);
13681 DONE;
0f40f9f7 13682})
3a3677ff
RH
13683
13684(define_split
13685 [(set (pc)
13686 (if_then_else (match_operator 0 "comparison_operator"
13687 [(match_operand 1 "register_operand" "")
13688 (match_operand 2 "nonimmediate_operand" "")])
13689 (match_operand 3 "" "")
13690 (match_operand 4 "" "")))
13691 (clobber (reg:CCFP 18))
13692 (clobber (reg:CCFP 17))
13693 (clobber (match_scratch:HI 5 "=a"))]
13694 "reload_completed"
13695 [(set (pc)
13696 (if_then_else (match_dup 6)
13697 (match_dup 3)
13698 (match_dup 4)))]
3a3677ff 13699{
03598dea 13700 ix86_split_fp_branch (GET_CODE (operands[0]), operands[1], operands[2],
9e7adcb3
JH
13701 operands[3], operands[4], operands[5]);
13702 DONE;
0f40f9f7 13703})
886c62d1
JVA
13704\f
13705;; Unconditional and other jump instructions
13706
13707(define_insn "jump"
13708 [(set (pc)
13709 (label_ref (match_operand 0 "" "")))]
13710 ""
0f40f9f7 13711 "jmp\t%l0"
c7375e61 13712 [(set_attr "type" "ibr")
efcc7037
JH
13713 (set (attr "length")
13714 (if_then_else (and (ge (minus (match_dup 0) (pc))
13715 (const_int -128))
13716 (lt (minus (match_dup 0) (pc))
13717 (const_int 124)))
13718 (const_int 2)
13719 (const_int 5)))
c7375e61 13720 (set_attr "modrm" "0")])
886c62d1 13721
14f73b5a
JH
13722(define_expand "indirect_jump"
13723 [(set (pc) (match_operand 0 "nonimmediate_operand" "rm"))]
886c62d1 13724 ""
14f73b5a
JH
13725 "")
13726
13727(define_insn "*indirect_jump"
13728 [(set (pc) (match_operand:SI 0 "nonimmediate_operand" "rm"))]
13729 "!TARGET_64BIT"
13730 "jmp\t%A0"
13731 [(set_attr "type" "ibr")
13732 (set_attr "length_immediate" "0")])
13733
13734(define_insn "*indirect_jump_rtx64"
13735 [(set (pc) (match_operand:DI 0 "nonimmediate_operand" "rm"))]
13736 "TARGET_64BIT"
0f40f9f7 13737 "jmp\t%A0"
6ef67412
JH
13738 [(set_attr "type" "ibr")
13739 (set_attr "length_immediate" "0")])
4801403e 13740
90675921 13741(define_expand "tablejump"
6eb791fc 13742 [(parallel [(set (pc) (match_operand 0 "nonimmediate_operand" "rm"))
90675921
RH
13743 (use (label_ref (match_operand 1 "" "")))])]
13744 ""
13745{
66edd3b4
RH
13746 /* In PIC mode, the table entries are stored GOT (32-bit) or PC (64-bit)
13747 relative. Convert the relative address to an absolute address. */
90675921
RH
13748 if (flag_pic)
13749 {
66edd3b4
RH
13750 rtx op0, op1;
13751 enum rtx_code code;
13752
6eb791fc 13753 if (TARGET_64BIT)
66edd3b4
RH
13754 {
13755 code = PLUS;
13756 op0 = operands[0];
13757 op1 = gen_rtx_LABEL_REF (Pmode, operands[1]);
13758 }
b069de3b 13759 else if (TARGET_MACHO || HAVE_AS_GOTOFF_IN_DATA)
f88c65f7 13760 {
66edd3b4
RH
13761 code = PLUS;
13762 op0 = operands[0];
13763 op1 = pic_offset_table_rtx;
f88c65f7 13764 }
6eb791fc
JH
13765 else
13766 {
66edd3b4
RH
13767 code = MINUS;
13768 op0 = pic_offset_table_rtx;
13769 op1 = operands[0];
6eb791fc 13770 }
66edd3b4 13771
c16576e6 13772 operands[0] = expand_simple_binop (Pmode, code, op0, op1, NULL_RTX, 0,
66edd3b4 13773 OPTAB_DIRECT);
90675921 13774 }
0f40f9f7 13775})
2bb7a0f5 13776
90675921 13777(define_insn "*tablejump_1"
2ae0f82c 13778 [(set (pc) (match_operand:SI 0 "nonimmediate_operand" "rm"))
886c62d1 13779 (use (label_ref (match_operand 1 "" "")))]
14f73b5a
JH
13780 "!TARGET_64BIT"
13781 "jmp\t%A0"
13782 [(set_attr "type" "ibr")
13783 (set_attr "length_immediate" "0")])
13784
13785(define_insn "*tablejump_1_rtx64"
13786 [(set (pc) (match_operand:DI 0 "nonimmediate_operand" "rm"))
13787 (use (label_ref (match_operand 1 "" "")))]
13788 "TARGET_64BIT"
0f40f9f7 13789 "jmp\t%A0"
6ef67412
JH
13790 [(set_attr "type" "ibr")
13791 (set_attr "length_immediate" "0")])
e075ae69
RH
13792\f
13793;; Loop instruction
13794;;
13795;; This is all complicated by the fact that since this is a jump insn
13796;; we must handle our own reloads.
13797
5527bf14
RH
13798(define_expand "doloop_end"
13799 [(use (match_operand 0 "" "")) ; loop pseudo
13800 (use (match_operand 1 "" "")) ; iterations; zero if unknown
13801 (use (match_operand 2 "" "")) ; max iterations
13802 (use (match_operand 3 "" "")) ; loop level
13803 (use (match_operand 4 "" ""))] ; label
1b0c37d7 13804 "!TARGET_64BIT && TARGET_USE_LOOP"
5527bf14
RH
13805 "
13806{
13807 /* Only use cloop on innermost loops. */
13808 if (INTVAL (operands[3]) > 1)
13809 FAIL;
13810 if (GET_MODE (operands[0]) != SImode)
13811 FAIL;
13812 emit_jump_insn (gen_doloop_end_internal (operands[4], operands[0],
13813 operands[0]));
13814 DONE;
13815}")
e075ae69 13816
5527bf14 13817(define_insn "doloop_end_internal"
e075ae69 13818 [(set (pc)
5527bf14 13819 (if_then_else (ne (match_operand:SI 1 "register_operand" "c,?*r,?*r")
e075ae69
RH
13820 (const_int 1))
13821 (label_ref (match_operand 0 "" ""))
13822 (pc)))
5527bf14 13823 (set (match_operand:SI 2 "register_operand" "=1,1,*m*r")
e075ae69
RH
13824 (plus:SI (match_dup 1)
13825 (const_int -1)))
13826 (clobber (match_scratch:SI 3 "=X,X,r"))
13827 (clobber (reg:CC 17))]
1b0c37d7 13828 "!TARGET_64BIT && TARGET_USE_LOOP"
e075ae69
RH
13829{
13830 if (which_alternative != 0)
0f40f9f7 13831 return "#";
e075ae69 13832 if (get_attr_length (insn) == 2)
0f40f9f7 13833 return "%+loop\t%l0";
e075ae69 13834 else
0f40f9f7
ZW
13835 return "dec{l}\t%1\;%+jne\t%l0";
13836}
6ef67412 13837 [(set_attr "ppro_uops" "many")
c7375e61
EB
13838 (set (attr "length")
13839 (if_then_else (and (eq_attr "alternative" "0")
13840 (and (ge (minus (match_dup 0) (pc))
13841 (const_int -128))
13842 (lt (minus (match_dup 0) (pc))
13843 (const_int 124))))
13844 (const_int 2)
13845 (const_int 16)))
efcc7037
JH
13846 ;; We don't know the type before shorten branches. Optimistically expect
13847 ;; the loop instruction to match.
13848 (set (attr "type") (const_string "ibr"))])
e075ae69 13849
e075ae69
RH
13850(define_split
13851 [(set (pc)
13852 (if_then_else (ne (match_operand:SI 1 "register_operand" "")
13853 (const_int 1))
13854 (match_operand 0 "" "")
13855 (pc)))
5527bf14 13856 (set (match_dup 1)
e075ae69
RH
13857 (plus:SI (match_dup 1)
13858 (const_int -1)))
5527bf14 13859 (clobber (match_scratch:SI 2 ""))
e075ae69 13860 (clobber (reg:CC 17))]
1b0c37d7 13861 "!TARGET_64BIT && TARGET_USE_LOOP
5527bf14
RH
13862 && reload_completed
13863 && REGNO (operands[1]) != 2"
13864 [(parallel [(set (reg:CCZ 17)
13865 (compare:CCZ (plus:SI (match_dup 1) (const_int -1))
e075ae69 13866 (const_int 0)))
5527bf14 13867 (set (match_dup 1) (plus:SI (match_dup 1) (const_int -1)))])
16189740 13868 (set (pc) (if_then_else (ne (reg:CCZ 17) (const_int 0))
e075ae69
RH
13869 (match_dup 0)
13870 (pc)))]
13871 "")
13872
13873(define_split
13874 [(set (pc)
13875 (if_then_else (ne (match_operand:SI 1 "register_operand" "")
13876 (const_int 1))
13877 (match_operand 0 "" "")
13878 (pc)))
5527bf14 13879 (set (match_operand:SI 2 "nonimmediate_operand" "")
e075ae69
RH
13880 (plus:SI (match_dup 1)
13881 (const_int -1)))
13882 (clobber (match_scratch:SI 3 ""))
13883 (clobber (reg:CC 17))]
1b0c37d7 13884 "!TARGET_64BIT && TARGET_USE_LOOP
5527bf14
RH
13885 && reload_completed
13886 && (! REG_P (operands[2])
13887 || ! rtx_equal_p (operands[1], operands[2]))"
e075ae69 13888 [(set (match_dup 3) (match_dup 1))
16189740
RH
13889 (parallel [(set (reg:CCZ 17)
13890 (compare:CCZ (plus:SI (match_dup 3) (const_int -1))
13891 (const_int 0)))
e075ae69
RH
13892 (set (match_dup 3) (plus:SI (match_dup 3) (const_int -1)))])
13893 (set (match_dup 2) (match_dup 3))
16189740 13894 (set (pc) (if_then_else (ne (reg:CCZ 17) (const_int 0))
e075ae69
RH
13895 (match_dup 0)
13896 (pc)))]
13897 "")
c50e5bc0
RH
13898
13899;; Convert setcc + movzbl to xor + setcc if operands don't overlap.
13900
13901(define_peephole2
13902 [(set (reg 17) (match_operand 0 "" ""))
13903 (set (match_operand:QI 1 "register_operand" "")
13904 (match_operator:QI 2 "ix86_comparison_operator"
13905 [(reg 17) (const_int 0)]))
13906 (set (match_operand 3 "q_regs_operand" "")
13907 (zero_extend (match_dup 1)))]
646ded90
RH
13908 "(peep2_reg_dead_p (3, operands[1])
13909 || operands_match_p (operands[1], operands[3]))
c50e5bc0 13910 && ! reg_overlap_mentioned_p (operands[3], operands[0])"
646ded90
RH
13911 [(set (match_dup 4) (match_dup 0))
13912 (set (strict_low_part (match_dup 5))
13913 (match_dup 2))]
13914{
13915 operands[4] = gen_rtx_REG (GET_MODE (operands[0]), 17);
13916 operands[5] = gen_rtx_REG (QImode, REGNO (operands[3]));
a8bac9ab 13917 ix86_expand_clear (operands[3]);
646ded90
RH
13918})
13919
13920;; Similar, but match zero_extendhisi2_and, which adds a clobber.
13921
13922(define_peephole2
13923 [(set (reg 17) (match_operand 0 "" ""))
13924 (set (match_operand:QI 1 "register_operand" "")
13925 (match_operator:QI 2 "ix86_comparison_operator"
13926 [(reg 17) (const_int 0)]))
13927 (parallel [(set (match_operand 3 "q_regs_operand" "")
13928 (zero_extend (match_dup 1)))
13929 (clobber (reg:CC 17))])]
13930 "(peep2_reg_dead_p (3, operands[1])
13931 || operands_match_p (operands[1], operands[3]))
13932 && ! reg_overlap_mentioned_p (operands[3], operands[0])"
13933 [(set (match_dup 4) (match_dup 0))
c50e5bc0
RH
13934 (set (strict_low_part (match_dup 5))
13935 (match_dup 2))]
646ded90
RH
13936{
13937 operands[4] = gen_rtx_REG (GET_MODE (operands[0]), 17);
13938 operands[5] = gen_rtx_REG (QImode, REGNO (operands[3]));
a8bac9ab 13939 ix86_expand_clear (operands[3]);
646ded90 13940})
e075ae69
RH
13941\f
13942;; Call instructions.
2bb7a0f5 13943
cbbf65e0
RH
13944;; The predicates normally associated with named expanders are not properly
13945;; checked for calls. This is a bug in the generic code, but it isn't that
13946;; easy to fix. Ignore it for now and be prepared to fix things up.
2bb7a0f5 13947
886c62d1
JVA
13948;; Call subroutine returning no value.
13949
2bb7a0f5 13950(define_expand "call_pop"
cbbf65e0
RH
13951 [(parallel [(call (match_operand:QI 0 "" "")
13952 (match_operand:SI 1 "" ""))
2bb7a0f5
RS
13953 (set (reg:SI 7)
13954 (plus:SI (reg:SI 7)
cbbf65e0 13955 (match_operand:SI 3 "" "")))])]
1e07edd3 13956 "!TARGET_64BIT"
2bb7a0f5 13957{
4977bab6 13958 ix86_expand_call (NULL, operands[0], operands[1], operands[2], operands[3], 0);
0e07aff3 13959 DONE;
0f40f9f7 13960})
2bb7a0f5 13961
94bb5d0c 13962(define_insn "*call_pop_0"
e1ff012c 13963 [(call (mem:QI (match_operand:SI 0 "constant_call_address_operand" ""))
94bb5d0c
RH
13964 (match_operand:SI 1 "" ""))
13965 (set (reg:SI 7) (plus:SI (reg:SI 7)
90d10fb9 13966 (match_operand:SI 2 "immediate_operand" "")))]
1e07edd3 13967 "!TARGET_64BIT"
94bb5d0c
RH
13968{
13969 if (SIBLING_CALL_P (insn))
0f40f9f7 13970 return "jmp\t%P0";
94bb5d0c 13971 else
0f40f9f7
ZW
13972 return "call\t%P0";
13973}
94bb5d0c
RH
13974 [(set_attr "type" "call")])
13975
cbbf65e0 13976(define_insn "*call_pop_1"
e1ff012c 13977 [(call (mem:QI (match_operand:SI 0 "call_insn_operand" "rsm"))
94bb5d0c 13978 (match_operand:SI 1 "" ""))
886c62d1 13979 (set (reg:SI 7) (plus:SI (reg:SI 7)
90d10fb9 13980 (match_operand:SI 2 "immediate_operand" "i")))]
1e07edd3 13981 "!TARGET_64BIT"
886c62d1 13982{
e1ff012c 13983 if (constant_call_address_operand (operands[0], Pmode))
94bb5d0c
RH
13984 {
13985 if (SIBLING_CALL_P (insn))
0f40f9f7 13986 return "jmp\t%P0";
94bb5d0c 13987 else
0f40f9f7 13988 return "call\t%P0";
94bb5d0c 13989 }
94bb5d0c 13990 if (SIBLING_CALL_P (insn))
0f40f9f7 13991 return "jmp\t%A0";
94bb5d0c 13992 else
0f40f9f7
ZW
13993 return "call\t%A0";
13994}
e075ae69 13995 [(set_attr "type" "call")])
886c62d1 13996
2bb7a0f5 13997(define_expand "call"
cbbf65e0 13998 [(call (match_operand:QI 0 "" "")
39d04363
JH
13999 (match_operand 1 "" ""))
14000 (use (match_operand 2 "" ""))]
2bb7a0f5 14001 ""
2bb7a0f5 14002{
4977bab6
ZW
14003 ix86_expand_call (NULL, operands[0], operands[1], operands[2], NULL, 0);
14004 DONE;
14005})
14006
14007(define_expand "sibcall"
14008 [(call (match_operand:QI 0 "" "")
14009 (match_operand 1 "" ""))
14010 (use (match_operand 2 "" ""))]
14011 ""
14012{
14013 ix86_expand_call (NULL, operands[0], operands[1], operands[2], NULL, 1);
0e07aff3 14014 DONE;
0f40f9f7 14015})
2bb7a0f5 14016
94bb5d0c 14017(define_insn "*call_0"
32ee7d1d
JH
14018 [(call (mem:QI (match_operand 0 "constant_call_address_operand" ""))
14019 (match_operand 1 "" ""))]
94bb5d0c 14020 ""
94bb5d0c
RH
14021{
14022 if (SIBLING_CALL_P (insn))
0f40f9f7 14023 return "jmp\t%P0";
94bb5d0c 14024 else
0f40f9f7
ZW
14025 return "call\t%P0";
14026}
94bb5d0c
RH
14027 [(set_attr "type" "call")])
14028
cbbf65e0 14029(define_insn "*call_1"
e1ff012c 14030 [(call (mem:QI (match_operand:SI 0 "call_insn_operand" "rsm"))
32ee7d1d 14031 (match_operand 1 "" ""))]
4977bab6 14032 "!SIBLING_CALL_P (insn) && !TARGET_64BIT"
32ee7d1d
JH
14033{
14034 if (constant_call_address_operand (operands[0], QImode))
4977bab6
ZW
14035 return "call\t%P0";
14036 return "call\t%A0";
14037}
14038 [(set_attr "type" "call")])
14039
14040(define_insn "*sibcall_1"
14041 [(call (mem:QI (match_operand:SI 0 "sibcall_insn_operand" "s,c,d,a"))
14042 (match_operand 1 "" ""))]
14043 "SIBLING_CALL_P (insn) && !TARGET_64BIT"
14044{
14045 if (constant_call_address_operand (operands[0], QImode))
14046 return "jmp\t%P0";
14047 return "jmp\t%A0";
0f40f9f7 14048}
32ee7d1d
JH
14049 [(set_attr "type" "call")])
14050
14051(define_insn "*call_1_rex64"
14052 [(call (mem:QI (match_operand:DI 0 "call_insn_operand" "rsm"))
14053 (match_operand 1 "" ""))]
4977bab6 14054 "!SIBLING_CALL_P (insn) && TARGET_64BIT"
886c62d1 14055{
94bb5d0c 14056 if (constant_call_address_operand (operands[0], QImode))
4977bab6
ZW
14057 return "call\t%P0";
14058 return "call\t%A0";
0f40f9f7 14059}
e075ae69 14060 [(set_attr "type" "call")])
886c62d1 14061
4977bab6
ZW
14062(define_insn "*sibcall_1_rex64"
14063 [(call (mem:QI (match_operand:DI 0 "constant_call_address_operand" ""))
14064 (match_operand 1 "" ""))]
14065 "SIBLING_CALL_P (insn) && TARGET_64BIT"
14066 "jmp\t%P0"
14067 [(set_attr "type" "call")])
14068
14069(define_insn "*sibcall_1_rex64_v"
14070 [(call (mem:QI (reg:DI 40))
14071 (match_operand 0 "" ""))]
14072 "SIBLING_CALL_P (insn) && TARGET_64BIT"
14073 "jmp\t*%%r11"
14074 [(set_attr "type" "call")])
14075
14076
886c62d1 14077;; Call subroutine, returning value in operand 0
886c62d1 14078
2bb7a0f5
RS
14079(define_expand "call_value_pop"
14080 [(parallel [(set (match_operand 0 "" "")
cbbf65e0
RH
14081 (call (match_operand:QI 1 "" "")
14082 (match_operand:SI 2 "" "")))
2bb7a0f5
RS
14083 (set (reg:SI 7)
14084 (plus:SI (reg:SI 7)
cbbf65e0 14085 (match_operand:SI 4 "" "")))])]
1e07edd3 14086 "!TARGET_64BIT"
2bb7a0f5 14087{
0e07aff3 14088 ix86_expand_call (operands[0], operands[1], operands[2],
4977bab6 14089 operands[3], operands[4], 0);
0e07aff3 14090 DONE;
0f40f9f7 14091})
2bb7a0f5 14092
2bb7a0f5
RS
14093(define_expand "call_value"
14094 [(set (match_operand 0 "" "")
cbbf65e0 14095 (call (match_operand:QI 1 "" "")
39d04363
JH
14096 (match_operand:SI 2 "" "")))
14097 (use (match_operand:SI 3 "" ""))]
2bb7a0f5
RS
14098 ;; Operand 2 not used on the i386.
14099 ""
2bb7a0f5 14100{
4977bab6
ZW
14101 ix86_expand_call (operands[0], operands[1], operands[2], operands[3], NULL, 0);
14102 DONE;
14103})
14104
14105(define_expand "sibcall_value"
14106 [(set (match_operand 0 "" "")
14107 (call (match_operand:QI 1 "" "")
14108 (match_operand:SI 2 "" "")))
14109 (use (match_operand:SI 3 "" ""))]
14110 ;; Operand 2 not used on the i386.
14111 ""
14112{
14113 ix86_expand_call (operands[0], operands[1], operands[2], operands[3], NULL, 1);
39d04363 14114 DONE;
0f40f9f7 14115})
2bb7a0f5 14116
b840bfb0
MM
14117;; Call subroutine returning any type.
14118
576182a3 14119(define_expand "untyped_call"
b840bfb0 14120 [(parallel [(call (match_operand 0 "" "")
576182a3 14121 (const_int 0))
b840bfb0 14122 (match_operand 1 "" "")
576182a3
TW
14123 (match_operand 2 "" "")])]
14124 ""
576182a3 14125{
b840bfb0 14126 int i;
576182a3 14127
d8b679b9
RK
14128 /* In order to give reg-stack an easier job in validating two
14129 coprocessor registers as containing a possible return value,
14130 simply pretend the untyped call returns a complex long double
14131 value. */
74775c7a 14132
0e07aff3
RH
14133 ix86_expand_call ((TARGET_FLOAT_RETURNS_IN_80387
14134 ? gen_rtx_REG (XCmode, FIRST_FLOAT_REG) : NULL),
14135 operands[0], const0_rtx, GEN_INT (SSE_REGPARM_MAX - 1),
4977bab6 14136 NULL, 0);
576182a3 14137
b840bfb0 14138 for (i = 0; i < XVECLEN (operands[2], 0); i++)
576182a3 14139 {
b840bfb0
MM
14140 rtx set = XVECEXP (operands[2], 0, i);
14141 emit_move_insn (SET_DEST (set), SET_SRC (set));
576182a3 14142 }
576182a3 14143
b840bfb0
MM
14144 /* The optimizer does not know that the call sets the function value
14145 registers we stored in the result block. We avoid problems by
14146 claiming that all hard registers are used and clobbered at this
14147 point. */
66edd3b4 14148 emit_insn (gen_blockage (const0_rtx));
576182a3
TW
14149
14150 DONE;
0f40f9f7 14151})
e075ae69
RH
14152\f
14153;; Prologue and epilogue instructions
576182a3 14154
b840bfb0
MM
14155;; UNSPEC_VOLATILE is considered to use and clobber all hard registers and
14156;; all of memory. This blocks insns from being moved across this point.
14157
14158(define_insn "blockage"
66edd3b4 14159 [(unspec_volatile [(match_operand 0 "" "")] UNSPECV_BLOCKAGE)]
576182a3 14160 ""
90aec2cf 14161 ""
e075ae69 14162 [(set_attr "length" "0")])
576182a3 14163
886c62d1
JVA
14164;; Insn emitted into the body of a function to return from a function.
14165;; This is only done if the function's epilogue is known to be simple.
182a4620 14166;; See comments for ix86_can_use_return_insn_p in i386.c.
886c62d1 14167
5f3d14e3 14168(define_expand "return"
886c62d1 14169 [(return)]
5f3d14e3 14170 "ix86_can_use_return_insn_p ()"
9a7372d6
RH
14171{
14172 if (current_function_pops_args)
14173 {
14174 rtx popc = GEN_INT (current_function_pops_args);
14175 emit_jump_insn (gen_return_pop_internal (popc));
14176 DONE;
14177 }
0f40f9f7 14178})
5f3d14e3
SC
14179
14180(define_insn "return_internal"
14181 [(return)]
14182 "reload_completed"
90aec2cf 14183 "ret"
6ef67412
JH
14184 [(set_attr "length" "1")
14185 (set_attr "length_immediate" "0")
14186 (set_attr "modrm" "0")])
5f3d14e3 14187
6cd96118
SC
14188(define_insn "return_pop_internal"
14189 [(return)
14190 (use (match_operand:SI 0 "const_int_operand" ""))]
14191 "reload_completed"
0f40f9f7 14192 "ret\t%0"
6ef67412
JH
14193 [(set_attr "length" "3")
14194 (set_attr "length_immediate" "2")
14195 (set_attr "modrm" "0")])
6cd96118 14196
11837777
RH
14197(define_insn "return_indirect_internal"
14198 [(return)
14199 (use (match_operand:SI 0 "register_operand" "r"))]
14200 "reload_completed"
0f40f9f7 14201 "jmp\t%A0"
11837777
RH
14202 [(set_attr "type" "ibr")
14203 (set_attr "length_immediate" "0")])
14204
5f3d14e3
SC
14205(define_insn "nop"
14206 [(const_int 0)]
14207 ""
90aec2cf 14208 "nop"
e075ae69 14209 [(set_attr "length" "1")
6ef67412
JH
14210 (set_attr "length_immediate" "0")
14211 (set_attr "modrm" "0")
e075ae69 14212 (set_attr "ppro_uops" "one")])
5f3d14e3
SC
14213
14214(define_expand "prologue"
14215 [(const_int 1)]
14216 ""
e075ae69 14217 "ix86_expand_prologue (); DONE;")
5f3d14e3 14218
bd09bdeb 14219(define_insn "set_got"
69404d6f 14220 [(set (match_operand:SI 0 "register_operand" "=r")
c8c03509
RH
14221 (unspec:SI [(const_int 0)] UNSPEC_SET_GOT))
14222 (clobber (reg:CC 17))]
1e07edd3 14223 "!TARGET_64BIT"
c8c03509
RH
14224 { return output_set_got (operands[0]); }
14225 [(set_attr "type" "multi")
14226 (set_attr "length" "12")])
5f3d14e3 14227
e075ae69
RH
14228(define_expand "epilogue"
14229 [(const_int 1)]
14230 ""
cbbf65e0
RH
14231 "ix86_expand_epilogue (1); DONE;")
14232
14233(define_expand "sibcall_epilogue"
14234 [(const_int 1)]
14235 ""
14236 "ix86_expand_epilogue (0); DONE;")
e075ae69 14237
1020a5ab
RH
14238(define_expand "eh_return"
14239 [(use (match_operand 0 "register_operand" ""))
14240 (use (match_operand 1 "register_operand" ""))]
14241 ""
1020a5ab
RH
14242{
14243 rtx tmp, sa = operands[0], ra = operands[1];
14244
14245 /* Tricky bit: we write the address of the handler to which we will
14246 be returning into someone else's stack frame, one word below the
14247 stack address we wish to restore. */
14248 tmp = gen_rtx_PLUS (Pmode, arg_pointer_rtx, sa);
14249 tmp = plus_constant (tmp, -UNITS_PER_WORD);
14250 tmp = gen_rtx_MEM (Pmode, tmp);
14251 emit_move_insn (tmp, ra);
14252
d5d6a58b
RH
14253 if (Pmode == SImode)
14254 emit_insn (gen_eh_return_si (sa));
14255 else
14256 emit_insn (gen_eh_return_di (sa));
1020a5ab
RH
14257 emit_barrier ();
14258 DONE;
0f40f9f7 14259})
1020a5ab 14260
d5d6a58b 14261(define_insn_and_split "eh_return_si"
8ee41eaf
RH
14262 [(unspec_volatile [(match_operand:SI 0 "register_operand" "c")]
14263 UNSPECV_EH_RETURN)]
1b0c37d7 14264 "!TARGET_64BIT"
d5d6a58b
RH
14265 "#"
14266 "reload_completed"
14267 [(const_int 1)]
14268 "ix86_expand_epilogue (2); DONE;")
14269
14270(define_insn_and_split "eh_return_di"
8ee41eaf
RH
14271 [(unspec_volatile [(match_operand:DI 0 "register_operand" "c")]
14272 UNSPECV_EH_RETURN)]
1b0c37d7 14273 "TARGET_64BIT"
1020a5ab
RH
14274 "#"
14275 "reload_completed"
14276 [(const_int 1)]
14277 "ix86_expand_epilogue (2); DONE;")
14278
e075ae69 14279(define_insn "leave"
669fe758 14280 [(set (reg:SI 7) (plus:SI (reg:SI 6) (const_int 4)))
6fc5dc67 14281 (set (reg:SI 6) (mem:SI (reg:SI 6)))
f2042df3 14282 (clobber (mem:BLK (scratch)))]
1e07edd3 14283 "!TARGET_64BIT"
e075ae69 14284 "leave"
4977bab6 14285 [(set_attr "type" "leave")])
8362f420
JH
14286
14287(define_insn "leave_rex64"
f283104b 14288 [(set (reg:DI 7) (plus:DI (reg:DI 6) (const_int 8)))
6fc5dc67 14289 (set (reg:DI 6) (mem:DI (reg:DI 6)))
f2042df3 14290 (clobber (mem:BLK (scratch)))]
8362f420
JH
14291 "TARGET_64BIT"
14292 "leave"
4977bab6 14293 [(set_attr "type" "leave")])
e075ae69
RH
14294\f
14295(define_expand "ffssi2"
8acfdd43
RH
14296 [(parallel
14297 [(set (match_operand:SI 0 "register_operand" "")
14298 (ffs:SI (match_operand:SI 1 "nonimmediate_operand" "")))
14299 (clobber (match_scratch:SI 2 ""))
14300 (clobber (reg:CC 17))])]
e075ae69 14301 ""
8acfdd43 14302 "")
e075ae69 14303
8acfdd43
RH
14304(define_insn_and_split "*ffs_cmove"
14305 [(set (match_operand:SI 0 "register_operand" "=r")
14306 (ffs:SI (match_operand:SI 1 "nonimmediate_operand" "rm")))
14307 (clobber (match_scratch:SI 2 "=&r"))
14308 (clobber (reg:CC 17))]
14309 "TARGET_CMOVE"
14310 "#"
14311 "&& reload_completed"
14312 [(set (match_dup 2) (const_int -1))
14313 (parallel [(set (reg:CCZ 17) (compare:CCZ (match_dup 1) (const_int 0)))
14314 (set (match_dup 0) (ctz:SI (match_dup 1)))])
14315 (set (match_dup 0) (if_then_else:SI
14316 (eq (reg:CCZ 17) (const_int 0))
14317 (match_dup 2)
14318 (match_dup 0)))
14319 (parallel [(set (match_dup 0) (plus:SI (match_dup 0) (const_int 1)))
14320 (clobber (reg:CC 17))])]
14321 "")
e0dc26ff 14322
8acfdd43
RH
14323(define_insn_and_split "*ffs_no_cmove"
14324 [(set (match_operand:SI 0 "nonimmediate_operand" "=r")
14325 (ffs:SI (match_operand:SI 1 "nonimmediate_operand" "rm")))
14326 (clobber (match_scratch:SI 2 "=&r"))
14327 (clobber (reg:CC 17))]
14328 ""
14329 "#"
14330 "reload_completed"
14331 [(parallel [(set (match_dup 2) (const_int 0))
14332 (clobber (reg:CC 17))])
14333 (parallel [(set (reg:CCZ 17) (compare:CCZ (match_dup 1) (const_int 0)))
14334 (set (match_dup 0) (ctz:SI (match_dup 1)))])
14335 (set (strict_low_part (match_dup 3))
14336 (eq:QI (reg:CCZ 17) (const_int 0)))
14337 (parallel [(set (match_dup 2) (neg:SI (match_dup 2)))
14338 (clobber (reg:CC 17))])
14339 (parallel [(set (match_dup 0) (ior:SI (match_dup 0) (match_dup 2)))
14340 (clobber (reg:CC 17))])
14341 (parallel [(set (match_dup 0) (plus:SI (match_dup 0) (const_int 1)))
14342 (clobber (reg:CC 17))])]
14343{
14344 operands[3] = gen_lowpart (QImode, operands[2]);
0f40f9f7 14345})
886c62d1 14346
8acfdd43 14347(define_insn "*ffssi_1"
16189740 14348 [(set (reg:CCZ 17)
8acfdd43 14349 (compare:CCZ (match_operand:SI 1 "nonimmediate_operand" "rm")
16189740 14350 (const_int 0)))
e075ae69 14351 (set (match_operand:SI 0 "register_operand" "=r")
8acfdd43
RH
14352 (ctz:SI (match_dup 1)))]
14353 ""
14354 "bsf{l}\t{%1, %0|%0, %1}"
14355 [(set_attr "prefix_0f" "1")
14356 (set_attr "ppro_uops" "few")])
14357
14358(define_insn "ctzsi2"
14359 [(set (match_operand:SI 0 "register_operand" "=r")
14360 (ctz:SI (match_operand:SI 1 "nonimmediate_operand" "rm")))
14361 (clobber (reg:CC 17))]
e075ae69 14362 ""
0f40f9f7 14363 "bsf{l}\t{%1, %0|%0, %1}"
6ef67412 14364 [(set_attr "prefix_0f" "1")
e075ae69
RH
14365 (set_attr "ppro_uops" "few")])
14366
8acfdd43
RH
14367(define_expand "clzsi2"
14368 [(parallel
14369 [(set (match_operand:SI 0 "register_operand" "")
14370 (minus:SI (const_int 31)
14371 (clz:SI (match_operand:SI 1 "nonimmediate_operand" ""))))
14372 (clobber (reg:CC 17))])
14373 (parallel
14374 [(set (match_dup 0) (xor:SI (match_dup 0) (const_int 31)))
14375 (clobber (reg:CC 17))])]
14376 ""
14377 "")
14378
14379(define_insn "*bsr"
14380 [(set (match_operand:SI 0 "register_operand" "=r")
14381 (minus:SI (const_int 31)
14382 (clz:SI (match_operand:SI 1 "nonimmediate_operand" "rm"))))
14383 (clobber (reg:CC 17))]
14384 ""
14385 "bsr{l}\t{%1, %0|%0, %1}"
14386 [(set_attr "prefix_0f" "1")
14387 (set_attr "ppro_uops" "few")])
e075ae69 14388\f
f996902d
RH
14389;; Thread-local storage patterns for ELF.
14390;;
14391;; Note that these code sequences must appear exactly as shown
14392;; in order to allow linker relaxation.
14393
75d38379 14394(define_insn "*tls_global_dynamic_32_gnu"
f996902d
RH
14395 [(set (match_operand:SI 0 "register_operand" "=a")
14396 (unspec:SI [(match_operand:SI 1 "register_operand" "b")
14397 (match_operand:SI 2 "tls_symbolic_operand" "")
14398 (match_operand:SI 3 "call_insn_operand" "")]
14399 UNSPEC_TLS_GD))
14400 (clobber (match_scratch:SI 4 "=d"))
14401 (clobber (match_scratch:SI 5 "=c"))
14402 (clobber (reg:CC 17))]
75d38379 14403 "!TARGET_64BIT && TARGET_GNU_TLS"
f996902d
RH
14404 "lea{l}\t{%a2@TLSGD(,%1,1), %0|%0, %a2@TLSGD[%1*1]}\;call\t%P3"
14405 [(set_attr "type" "multi")
14406 (set_attr "length" "12")])
14407
75d38379 14408(define_insn "*tls_global_dynamic_32_sun"
f996902d
RH
14409 [(set (match_operand:SI 0 "register_operand" "=a")
14410 (unspec:SI [(match_operand:SI 1 "register_operand" "b")
14411 (match_operand:SI 2 "tls_symbolic_operand" "")
14412 (match_operand:SI 3 "call_insn_operand" "")]
14413 UNSPEC_TLS_GD))
14414 (clobber (match_scratch:SI 4 "=d"))
14415 (clobber (match_scratch:SI 5 "=c"))
14416 (clobber (reg:CC 17))]
75d38379 14417 "!TARGET_64BIT && TARGET_SUN_TLS"
f996902d
RH
14418 "lea{l}\t{%a2@DTLNDX(%1), %4|%4, %a2@DTLNDX[%1]}
14419 push{l}\t%4\;call\t%a2@TLSPLT\;pop{l}\t%4\;nop"
14420 [(set_attr "type" "multi")
14421 (set_attr "length" "14")])
14422
75d38379 14423(define_expand "tls_global_dynamic_32"
f996902d
RH
14424 [(parallel [(set (match_operand:SI 0 "register_operand" "")
14425 (unspec:SI
14426 [(match_dup 2)
14427 (match_operand:SI 1 "tls_symbolic_operand" "")
14428 (match_dup 3)]
14429 UNSPEC_TLS_GD))
14430 (clobber (match_scratch:SI 4 ""))
14431 (clobber (match_scratch:SI 5 ""))
14432 (clobber (reg:CC 17))])]
14433 ""
14434{
dce81a1a
JJ
14435 if (flag_pic)
14436 operands[2] = pic_offset_table_rtx;
14437 else
14438 {
14439 operands[2] = gen_reg_rtx (Pmode);
14440 emit_insn (gen_set_got (operands[2]));
14441 }
f996902d
RH
14442 operands[3] = ix86_tls_get_addr ();
14443})
14444
75d38379
JJ
14445(define_insn "*tls_global_dynamic_64"
14446 [(set (match_operand:DI 0 "register_operand" "=a")
14447 (call (mem:QI (match_operand:DI 2 "call_insn_operand" ""))
14448 (match_operand:DI 3 "" "")))
14449 (unspec:DI [(match_operand:DI 1 "tls_symbolic_operand" "")]
14450 UNSPEC_TLS_GD)]
14451 "TARGET_64BIT"
14452 ".byte\t0x66\;lea{q}\t{%a1@TLSGD(%%rip), %%rdi|%%rdi, %a1@TLSGD[%%rip]}\;.word\t0x6666\;rex64\;call\t%P2"
14453 [(set_attr "type" "multi")
14454 (set_attr "length" "16")])
14455
14456(define_expand "tls_global_dynamic_64"
14457 [(parallel [(set (match_operand:DI 0 "register_operand" "")
14458 (call (mem:QI (match_dup 2)) (const_int 0)))
14459 (unspec:DI [(match_operand:DI 1 "tls_symbolic_operand" "")]
14460 UNSPEC_TLS_GD)])]
14461 ""
14462{
14463 operands[2] = ix86_tls_get_addr ();
14464})
14465
14466(define_insn "*tls_local_dynamic_base_32_gnu"
f996902d
RH
14467 [(set (match_operand:SI 0 "register_operand" "=a")
14468 (unspec:SI [(match_operand:SI 1 "register_operand" "b")
14469 (match_operand:SI 2 "call_insn_operand" "")]
14470 UNSPEC_TLS_LD_BASE))
14471 (clobber (match_scratch:SI 3 "=d"))
14472 (clobber (match_scratch:SI 4 "=c"))
14473 (clobber (reg:CC 17))]
75d38379 14474 "!TARGET_64BIT && TARGET_GNU_TLS"
f996902d
RH
14475 "lea{l}\t{%&@TLSLDM(%1), %0|%0, %&@TLSLDM[%1]}\;call\t%P2"
14476 [(set_attr "type" "multi")
14477 (set_attr "length" "11")])
14478
75d38379 14479(define_insn "*tls_local_dynamic_base_32_sun"
f996902d
RH
14480 [(set (match_operand:SI 0 "register_operand" "=a")
14481 (unspec:SI [(match_operand:SI 1 "register_operand" "b")
14482 (match_operand:SI 2 "call_insn_operand" "")]
14483 UNSPEC_TLS_LD_BASE))
14484 (clobber (match_scratch:SI 3 "=d"))
14485 (clobber (match_scratch:SI 4 "=c"))
14486 (clobber (reg:CC 17))]
75d38379 14487 "!TARGET_64BIT && TARGET_SUN_TLS"
f996902d
RH
14488 "lea{l}\t{%&@TMDNX(%1), %3|%3, %&@TMDNX[%1]}
14489 push{l}\t%3\;call\t%&@TLSPLT\;pop{l}\t%3"
14490 [(set_attr "type" "multi")
14491 (set_attr "length" "13")])
14492
75d38379 14493(define_expand "tls_local_dynamic_base_32"
f996902d
RH
14494 [(parallel [(set (match_operand:SI 0 "register_operand" "")
14495 (unspec:SI [(match_dup 1) (match_dup 2)]
14496 UNSPEC_TLS_LD_BASE))
14497 (clobber (match_scratch:SI 3 ""))
14498 (clobber (match_scratch:SI 4 ""))
14499 (clobber (reg:CC 17))])]
14500 ""
14501{
dce81a1a 14502 if (flag_pic)
9785f1d9 14503 operands[1] = pic_offset_table_rtx;
dce81a1a
JJ
14504 else
14505 {
9785f1d9
JJ
14506 operands[1] = gen_reg_rtx (Pmode);
14507 emit_insn (gen_set_got (operands[1]));
dce81a1a 14508 }
f996902d
RH
14509 operands[2] = ix86_tls_get_addr ();
14510})
14511
75d38379
JJ
14512(define_insn "*tls_local_dynamic_base_64"
14513 [(set (match_operand:DI 0 "register_operand" "=a")
14514 (call (mem:QI (match_operand:DI 1 "call_insn_operand" ""))
14515 (match_operand:DI 2 "" "")))
14516 (unspec:DI [(const_int 0)] UNSPEC_TLS_LD_BASE)]
14517 "TARGET_64BIT"
14518 "lea{q}\t{%&@TLSLD(%%rip), %%rdi|%%rdi, %&@TLSLD[%%rip]}\;call\t%P1"
14519 [(set_attr "type" "multi")
14520 (set_attr "length" "12")])
14521
14522(define_expand "tls_local_dynamic_base_64"
14523 [(parallel [(set (match_operand:DI 0 "register_operand" "")
14524 (call (mem:QI (match_dup 1)) (const_int 0)))
14525 (unspec:DI [(const_int 0)] UNSPEC_TLS_LD_BASE)])]
14526 ""
14527{
14528 operands[1] = ix86_tls_get_addr ();
14529})
14530
f996902d
RH
14531;; Local dynamic of a single variable is a lose. Show combine how
14532;; to convert that back to global dynamic.
14533
75d38379 14534(define_insn_and_split "*tls_local_dynamic_32_once"
f996902d
RH
14535 [(set (match_operand:SI 0 "register_operand" "=a")
14536 (plus:SI (unspec:SI [(match_operand:SI 1 "register_operand" "b")
14537 (match_operand:SI 2 "call_insn_operand" "")]
14538 UNSPEC_TLS_LD_BASE)
14539 (const:SI (unspec:SI
14540 [(match_operand:SI 3 "tls_symbolic_operand" "")]
14541 UNSPEC_DTPOFF))))
14542 (clobber (match_scratch:SI 4 "=d"))
14543 (clobber (match_scratch:SI 5 "=c"))
14544 (clobber (reg:CC 17))]
14545 ""
14546 "#"
14547 ""
14548 [(parallel [(set (match_dup 0)
14549 (unspec:SI [(match_dup 1) (match_dup 3) (match_dup 2)]
14550 UNSPEC_TLS_GD))
14551 (clobber (match_dup 4))
14552 (clobber (match_dup 5))
14553 (clobber (reg:CC 17))])]
14554 "")
14555\f
e075ae69
RH
14556;; These patterns match the binary 387 instructions for addM3, subM3,
14557;; mulM3 and divM3. There are three patterns for each of DFmode and
14558;; SFmode. The first is the normal insn, the second the same insn but
14559;; with one operand a conversion, and the third the same insn but with
14560;; the other operand a conversion. The conversion may be SFmode or
14561;; SImode if the target mode DFmode, but only SImode if the target mode
14562;; is SFmode.
14563
caa6ec8d
JH
14564;; Gcc is slightly more smart about handling normal two address instructions
14565;; so use special patterns for add and mull.
965f5423
JH
14566(define_insn "*fop_sf_comm_nosse"
14567 [(set (match_operand:SF 0 "register_operand" "=f")
14568 (match_operator:SF 3 "binary_fp_operator"
aebfea10 14569 [(match_operand:SF 1 "nonimmediate_operand" "%0")
965f5423
JH
14570 (match_operand:SF 2 "nonimmediate_operand" "fm")]))]
14571 "TARGET_80387 && !TARGET_SSE_MATH
aebfea10
JH
14572 && GET_RTX_CLASS (GET_CODE (operands[3])) == 'c'
14573 && (GET_CODE (operands[1]) != MEM || GET_CODE (operands[2]) != MEM)"
965f5423
JH
14574 "* return output_387_binary_op (insn, operands);"
14575 [(set (attr "type")
14576 (if_then_else (match_operand:SF 3 "mult_operator" "")
14577 (const_string "fmul")
14578 (const_string "fop")))
14579 (set_attr "mode" "SF")])
14580
caa6ec8d 14581(define_insn "*fop_sf_comm"
1deaa899 14582 [(set (match_operand:SF 0 "register_operand" "=f#x,x#f")
caa6ec8d 14583 (match_operator:SF 3 "binary_fp_operator"
aebfea10 14584 [(match_operand:SF 1 "nonimmediate_operand" "%0,0")
1deaa899 14585 (match_operand:SF 2 "nonimmediate_operand" "fm#x,xm#f")]))]
965f5423 14586 "TARGET_80387 && TARGET_SSE_MATH && TARGET_MIX_SSE_I387
aebfea10
JH
14587 && GET_RTX_CLASS (GET_CODE (operands[3])) == 'c'
14588 && (GET_CODE (operands[1]) != MEM || GET_CODE (operands[2]) != MEM)"
caa6ec8d
JH
14589 "* return output_387_binary_op (insn, operands);"
14590 [(set (attr "type")
1deaa899 14591 (if_then_else (eq_attr "alternative" "1")
3d34cd91
JH
14592 (if_then_else (match_operand:SF 3 "mult_operator" "")
14593 (const_string "ssemul")
14594 (const_string "sseadd"))
1deaa899
JH
14595 (if_then_else (match_operand:SF 3 "mult_operator" "")
14596 (const_string "fmul")
14597 (const_string "fop"))))
14598 (set_attr "mode" "SF")])
14599
14600(define_insn "*fop_sf_comm_sse"
14601 [(set (match_operand:SF 0 "register_operand" "=x")
14602 (match_operator:SF 3 "binary_fp_operator"
aebfea10 14603 [(match_operand:SF 1 "nonimmediate_operand" "%0")
1deaa899 14604 (match_operand:SF 2 "nonimmediate_operand" "xm")]))]
aebfea10
JH
14605 "TARGET_SSE_MATH && GET_RTX_CLASS (GET_CODE (operands[3])) == 'c'
14606 && (GET_CODE (operands[1]) != MEM || GET_CODE (operands[2]) != MEM)"
1deaa899 14607 "* return output_387_binary_op (insn, operands);"
3d34cd91
JH
14608 [(set (attr "type")
14609 (if_then_else (match_operand:SF 3 "mult_operator" "")
14610 (const_string "ssemul")
14611 (const_string "sseadd")))
6ef67412 14612 (set_attr "mode" "SF")])
caa6ec8d 14613
965f5423
JH
14614(define_insn "*fop_df_comm_nosse"
14615 [(set (match_operand:DF 0 "register_operand" "=f")
14616 (match_operator:DF 3 "binary_fp_operator"
aebfea10 14617 [(match_operand:DF 1 "nonimmediate_operand" "%0")
965f5423
JH
14618 (match_operand:DF 2 "nonimmediate_operand" "fm")]))]
14619 "TARGET_80387 && (!TARGET_SSE2 || !TARGET_SSE_MATH)
aebfea10
JH
14620 && GET_RTX_CLASS (GET_CODE (operands[3])) == 'c'
14621 && (GET_CODE (operands[1]) != MEM || GET_CODE (operands[2]) != MEM)"
965f5423
JH
14622 "* return output_387_binary_op (insn, operands);"
14623 [(set (attr "type")
14624 (if_then_else (match_operand:SF 3 "mult_operator" "")
14625 (const_string "fmul")
14626 (const_string "fop")))
14627 (set_attr "mode" "DF")])
14628
caa6ec8d 14629(define_insn "*fop_df_comm"
1deaa899 14630 [(set (match_operand:DF 0 "register_operand" "=f#Y,Y#f")
caa6ec8d 14631 (match_operator:DF 3 "binary_fp_operator"
aebfea10 14632 [(match_operand:DF 1 "nonimmediate_operand" "%0,0")
1deaa899 14633 (match_operand:DF 2 "nonimmediate_operand" "fm#Y,Ym#f")]))]
965f5423 14634 "TARGET_80387 && TARGET_SSE_MATH && TARGET_SSE2 && TARGET_MIX_SSE_I387
aebfea10
JH
14635 && GET_RTX_CLASS (GET_CODE (operands[3])) == 'c'
14636 && (GET_CODE (operands[1]) != MEM || GET_CODE (operands[2]) != MEM)"
caa6ec8d
JH
14637 "* return output_387_binary_op (insn, operands);"
14638 [(set (attr "type")
1deaa899 14639 (if_then_else (eq_attr "alternative" "1")
3d34cd91
JH
14640 (if_then_else (match_operand:SF 3 "mult_operator" "")
14641 (const_string "ssemul")
14642 (const_string "sseadd"))
1deaa899
JH
14643 (if_then_else (match_operand:SF 3 "mult_operator" "")
14644 (const_string "fmul")
14645 (const_string "fop"))))
14646 (set_attr "mode" "DF")])
14647
14648(define_insn "*fop_df_comm_sse"
14649 [(set (match_operand:DF 0 "register_operand" "=Y")
14650 (match_operator:DF 3 "binary_fp_operator"
aebfea10 14651 [(match_operand:DF 1 "nonimmediate_operand" "%0")
1deaa899 14652 (match_operand:DF 2 "nonimmediate_operand" "Ym")]))]
965f5423 14653 "TARGET_SSE2 && TARGET_SSE_MATH
aebfea10
JH
14654 && GET_RTX_CLASS (GET_CODE (operands[3])) == 'c'
14655 && (GET_CODE (operands[1]) != MEM || GET_CODE (operands[2]) != MEM)"
1deaa899 14656 "* return output_387_binary_op (insn, operands);"
3d34cd91
JH
14657 [(set (attr "type")
14658 (if_then_else (match_operand:SF 3 "mult_operator" "")
14659 (const_string "ssemul")
14660 (const_string "sseadd")))
6ef67412 14661 (set_attr "mode" "DF")])
caa6ec8d
JH
14662
14663(define_insn "*fop_xf_comm"
14664 [(set (match_operand:XF 0 "register_operand" "=f")
14665 (match_operator:XF 3 "binary_fp_operator"
14666 [(match_operand:XF 1 "register_operand" "%0")
14667 (match_operand:XF 2 "register_operand" "f")]))]
1b0c37d7 14668 "!TARGET_64BIT && TARGET_80387
1e07edd3 14669 && GET_RTX_CLASS (GET_CODE (operands[3])) == 'c'"
caa6ec8d
JH
14670 "* return output_387_binary_op (insn, operands);"
14671 [(set (attr "type")
14672 (if_then_else (match_operand:XF 3 "mult_operator" "")
14673 (const_string "fmul")
6ef67412
JH
14674 (const_string "fop")))
14675 (set_attr "mode" "XF")])
caa6ec8d 14676
2b589241
JH
14677(define_insn "*fop_tf_comm"
14678 [(set (match_operand:TF 0 "register_operand" "=f")
14679 (match_operator:TF 3 "binary_fp_operator"
14680 [(match_operand:TF 1 "register_operand" "%0")
14681 (match_operand:TF 2 "register_operand" "f")]))]
14682 "TARGET_80387 && GET_RTX_CLASS (GET_CODE (operands[3])) == 'c'"
14683 "* return output_387_binary_op (insn, operands);"
14684 [(set (attr "type")
14685 (if_then_else (match_operand:TF 3 "mult_operator" "")
14686 (const_string "fmul")
14687 (const_string "fop")))
14688 (set_attr "mode" "XF")])
14689
965f5423
JH
14690(define_insn "*fop_sf_1_nosse"
14691 [(set (match_operand:SF 0 "register_operand" "=f,f")
14692 (match_operator:SF 3 "binary_fp_operator"
14693 [(match_operand:SF 1 "nonimmediate_operand" "0,fm")
14694 (match_operand:SF 2 "nonimmediate_operand" "fm,0")]))]
14695 "TARGET_80387 && !TARGET_SSE_MATH
14696 && GET_RTX_CLASS (GET_CODE (operands[3])) != 'c'
14697 && (GET_CODE (operands[1]) != MEM || GET_CODE (operands[2]) != MEM)"
14698 "* return output_387_binary_op (insn, operands);"
14699 [(set (attr "type")
14700 (cond [(match_operand:SF 3 "mult_operator" "")
14701 (const_string "fmul")
14702 (match_operand:SF 3 "div_operator" "")
14703 (const_string "fdiv")
14704 ]
14705 (const_string "fop")))
14706 (set_attr "mode" "SF")])
14707
e075ae69 14708(define_insn "*fop_sf_1"
1deaa899 14709 [(set (match_operand:SF 0 "register_operand" "=f,f,x")
e075ae69 14710 (match_operator:SF 3 "binary_fp_operator"
1deaa899
JH
14711 [(match_operand:SF 1 "nonimmediate_operand" "0,fm,0")
14712 (match_operand:SF 2 "nonimmediate_operand" "fm,0,xm#f")]))]
965f5423 14713 "TARGET_80387 && TARGET_SSE_MATH && TARGET_MIX_SSE_I387
caa6ec8d 14714 && GET_RTX_CLASS (GET_CODE (operands[3])) != 'c'
f97d9ec3 14715 && (GET_CODE (operands[1]) != MEM || GET_CODE (operands[2]) != MEM)"
e075ae69
RH
14716 "* return output_387_binary_op (insn, operands);"
14717 [(set (attr "type")
3d34cd91
JH
14718 (cond [(and (eq_attr "alternative" "2")
14719 (match_operand:SF 3 "mult_operator" ""))
14720 (const_string "ssemul")
14721 (and (eq_attr "alternative" "2")
14722 (match_operand:SF 3 "div_operator" ""))
14723 (const_string "ssediv")
14724 (eq_attr "alternative" "2")
14725 (const_string "sseadd")
1deaa899 14726 (match_operand:SF 3 "mult_operator" "")
e075ae69
RH
14727 (const_string "fmul")
14728 (match_operand:SF 3 "div_operator" "")
14729 (const_string "fdiv")
14730 ]
6ef67412
JH
14731 (const_string "fop")))
14732 (set_attr "mode" "SF")])
e075ae69 14733
1deaa899
JH
14734(define_insn "*fop_sf_1_sse"
14735 [(set (match_operand:SF 0 "register_operand" "=x")
14736 (match_operator:SF 3 "binary_fp_operator"
14737 [(match_operand:SF 1 "register_operand" "0")
14738 (match_operand:SF 2 "nonimmediate_operand" "xm")]))]
965f5423 14739 "TARGET_SSE_MATH
1deaa899
JH
14740 && GET_RTX_CLASS (GET_CODE (operands[3])) != 'c'"
14741 "* return output_387_binary_op (insn, operands);"
3d34cd91
JH
14742 [(set (attr "type")
14743 (cond [(match_operand:SF 3 "mult_operator" "")
14744 (const_string "ssemul")
14745 (match_operand:SF 3 "div_operator" "")
14746 (const_string "ssediv")
14747 ]
14748 (const_string "sseadd")))
1deaa899
JH
14749 (set_attr "mode" "SF")])
14750
14751;; ??? Add SSE splitters for these!
e075ae69
RH
14752(define_insn "*fop_sf_2"
14753 [(set (match_operand:SF 0 "register_operand" "=f,f")
14754 (match_operator:SF 3 "binary_fp_operator"
14755 [(float:SF (match_operand:SI 1 "nonimmediate_operand" "m,?r"))
14756 (match_operand:SF 2 "register_operand" "0,0")]))]
965f5423 14757 "TARGET_80387 && TARGET_USE_FIOP && !TARGET_SSE_MATH"
e075ae69
RH
14758 "* return which_alternative ? \"#\" : output_387_binary_op (insn, operands);"
14759 [(set (attr "type")
14760 (cond [(match_operand:SF 3 "mult_operator" "")
14761 (const_string "fmul")
14762 (match_operand:SF 3 "div_operator" "")
14763 (const_string "fdiv")
14764 ]
14765 (const_string "fop")))
14766 (set_attr "fp_int_src" "true")
6ef67412
JH
14767 (set_attr "ppro_uops" "many")
14768 (set_attr "mode" "SI")])
e075ae69
RH
14769
14770(define_insn "*fop_sf_3"
14771 [(set (match_operand:SF 0 "register_operand" "=f,f")
14772 (match_operator:SF 3 "binary_fp_operator"
14773 [(match_operand:SF 1 "register_operand" "0,0")
14774 (float:SF (match_operand:SI 2 "nonimmediate_operand" "m,?r"))]))]
965f5423 14775 "TARGET_80387 && TARGET_USE_FIOP && !TARGET_SSE_MATH"
e075ae69
RH
14776 "* return which_alternative ? \"#\" : output_387_binary_op (insn, operands);"
14777 [(set (attr "type")
14778 (cond [(match_operand:SF 3 "mult_operator" "")
14779 (const_string "fmul")
14780 (match_operand:SF 3 "div_operator" "")
14781 (const_string "fdiv")
14782 ]
14783 (const_string "fop")))
14784 (set_attr "fp_int_src" "true")
6ef67412
JH
14785 (set_attr "ppro_uops" "many")
14786 (set_attr "mode" "SI")])
e075ae69 14787
965f5423
JH
14788(define_insn "*fop_df_1_nosse"
14789 [(set (match_operand:DF 0 "register_operand" "=f,f")
14790 (match_operator:DF 3 "binary_fp_operator"
14791 [(match_operand:DF 1 "nonimmediate_operand" "0,fm")
14792 (match_operand:DF 2 "nonimmediate_operand" "fm,0")]))]
14793 "TARGET_80387 && (!TARGET_SSE2 || !TARGET_SSE_MATH)
14794 && GET_RTX_CLASS (GET_CODE (operands[3])) != 'c'
14795 && (GET_CODE (operands[1]) != MEM || GET_CODE (operands[2]) != MEM)"
14796 "* return output_387_binary_op (insn, operands);"
14797 [(set (attr "type")
14798 (cond [(match_operand:DF 3 "mult_operator" "")
14799 (const_string "fmul")
3d34cd91 14800 (match_operand:DF 3 "div_operator" "")
965f5423
JH
14801 (const_string "fdiv")
14802 ]
14803 (const_string "fop")))
14804 (set_attr "mode" "DF")])
14805
14806
e075ae69 14807(define_insn "*fop_df_1"
1deaa899 14808 [(set (match_operand:DF 0 "register_operand" "=f#Y,f#Y,Y#f")
e075ae69 14809 (match_operator:DF 3 "binary_fp_operator"
1deaa899
JH
14810 [(match_operand:DF 1 "nonimmediate_operand" "0,fm,0")
14811 (match_operand:DF 2 "nonimmediate_operand" "fm,0,Ym#f")]))]
965f5423 14812 "TARGET_80387 && TARGET_SSE2 && TARGET_SSE_MATH && TARGET_MIX_SSE_I387
caa6ec8d 14813 && GET_RTX_CLASS (GET_CODE (operands[3])) != 'c'
f97d9ec3 14814 && (GET_CODE (operands[1]) != MEM || GET_CODE (operands[2]) != MEM)"
e075ae69
RH
14815 "* return output_387_binary_op (insn, operands);"
14816 [(set (attr "type")
3d34cd91
JH
14817 (cond [(and (eq_attr "alternative" "2")
14818 (match_operand:SF 3 "mult_operator" ""))
14819 (const_string "ssemul")
14820 (and (eq_attr "alternative" "2")
14821 (match_operand:SF 3 "div_operator" ""))
14822 (const_string "ssediv")
14823 (eq_attr "alternative" "2")
14824 (const_string "sseadd")
1deaa899 14825 (match_operand:DF 3 "mult_operator" "")
e075ae69
RH
14826 (const_string "fmul")
14827 (match_operand:DF 3 "div_operator" "")
14828 (const_string "fdiv")
14829 ]
6ef67412
JH
14830 (const_string "fop")))
14831 (set_attr "mode" "DF")])
e075ae69 14832
1deaa899
JH
14833(define_insn "*fop_df_1_sse"
14834 [(set (match_operand:DF 0 "register_operand" "=Y")
14835 (match_operator:DF 3 "binary_fp_operator"
14836 [(match_operand:DF 1 "register_operand" "0")
14837 (match_operand:DF 2 "nonimmediate_operand" "Ym")]))]
965f5423 14838 "TARGET_SSE2 && TARGET_SSE_MATH
1deaa899
JH
14839 && GET_RTX_CLASS (GET_CODE (operands[3])) != 'c'"
14840 "* return output_387_binary_op (insn, operands);"
3d34cd91
JH
14841 [(set_attr "mode" "DF")
14842 (set (attr "type")
14843 (cond [(match_operand:SF 3 "mult_operator" "")
14844 (const_string "ssemul")
14845 (match_operand:SF 3 "div_operator" "")
14846 (const_string "ssediv")
14847 ]
14848 (const_string "sseadd")))])
1deaa899
JH
14849
14850;; ??? Add SSE splitters for these!
e075ae69
RH
14851(define_insn "*fop_df_2"
14852 [(set (match_operand:DF 0 "register_operand" "=f,f")
14853 (match_operator:DF 3 "binary_fp_operator"
14854 [(float:DF (match_operand:SI 1 "nonimmediate_operand" "m,?r"))
14855 (match_operand:DF 2 "register_operand" "0,0")]))]
965f5423 14856 "TARGET_80387 && TARGET_USE_FIOP && !(TARGET_SSE2 && TARGET_SSE_MATH)"
e075ae69
RH
14857 "* return which_alternative ? \"#\" : output_387_binary_op (insn, operands);"
14858 [(set (attr "type")
14859 (cond [(match_operand:DF 3 "mult_operator" "")
14860 (const_string "fmul")
14861 (match_operand:DF 3 "div_operator" "")
14862 (const_string "fdiv")
14863 ]
14864 (const_string "fop")))
14865 (set_attr "fp_int_src" "true")
6ef67412
JH
14866 (set_attr "ppro_uops" "many")
14867 (set_attr "mode" "SI")])
e075ae69
RH
14868
14869(define_insn "*fop_df_3"
14870 [(set (match_operand:DF 0 "register_operand" "=f,f")
14871 (match_operator:DF 3 "binary_fp_operator"
14872 [(match_operand:DF 1 "register_operand" "0,0")
14873 (float:DF (match_operand:SI 2 "nonimmediate_operand" "m,?r"))]))]
965f5423 14874 "TARGET_80387 && TARGET_USE_FIOP && !(TARGET_SSE2 && TARGET_SSE_MATH)"
e075ae69
RH
14875 "* return which_alternative ? \"#\" : output_387_binary_op (insn, operands);"
14876 [(set (attr "type")
14877 (cond [(match_operand:DF 3 "mult_operator" "")
14878 (const_string "fmul")
14879 (match_operand:DF 3 "div_operator" "")
14880 (const_string "fdiv")
14881 ]
14882 (const_string "fop")))
14883 (set_attr "fp_int_src" "true")
6ef67412
JH
14884 (set_attr "ppro_uops" "many")
14885 (set_attr "mode" "SI")])
e075ae69
RH
14886
14887(define_insn "*fop_df_4"
14888 [(set (match_operand:DF 0 "register_operand" "=f,f")
14889 (match_operator:DF 3 "binary_fp_operator"
14890 [(float_extend:DF (match_operand:SF 1 "nonimmediate_operand" "fm,0"))
14891 (match_operand:DF 2 "register_operand" "0,f")]))]
3987b9db 14892 "TARGET_80387 && (!TARGET_SSE2 || !TARGET_SSE_MATH)
f97d9ec3 14893 && (GET_CODE (operands[1]) != MEM || GET_CODE (operands[2]) != MEM)"
e075ae69
RH
14894 "* return output_387_binary_op (insn, operands);"
14895 [(set (attr "type")
14896 (cond [(match_operand:DF 3 "mult_operator" "")
14897 (const_string "fmul")
14898 (match_operand:DF 3 "div_operator" "")
14899 (const_string "fdiv")
14900 ]
6ef67412
JH
14901 (const_string "fop")))
14902 (set_attr "mode" "SF")])
e075ae69
RH
14903
14904(define_insn "*fop_df_5"
14905 [(set (match_operand:DF 0 "register_operand" "=f,f")
14906 (match_operator:DF 3 "binary_fp_operator"
14907 [(match_operand:DF 1 "register_operand" "0,f")
14908 (float_extend:DF
14909 (match_operand:SF 2 "nonimmediate_operand" "fm,0"))]))]
965f5423 14910 "TARGET_80387 && !(TARGET_SSE2 && TARGET_SSE_MATH)"
e075ae69
RH
14911 "* return output_387_binary_op (insn, operands);"
14912 [(set (attr "type")
14913 (cond [(match_operand:DF 3 "mult_operator" "")
14914 (const_string "fmul")
14915 (match_operand:DF 3 "div_operator" "")
14916 (const_string "fdiv")
14917 ]
6ef67412
JH
14918 (const_string "fop")))
14919 (set_attr "mode" "SF")])
e075ae69 14920
4977bab6
ZW
14921(define_insn "*fop_df_6"
14922 [(set (match_operand:DF 0 "register_operand" "=f,f")
14923 (match_operator:DF 3 "binary_fp_operator"
14924 [(float_extend:DF
14925 (match_operand:SF 1 "register_operand" "0,f"))
14926 (float_extend:DF
14927 (match_operand:SF 2 "nonimmediate_operand" "fm,0"))]))]
14928 "TARGET_80387 && !(TARGET_SSE2 && TARGET_SSE_MATH)"
14929 "* return output_387_binary_op (insn, operands);"
14930 [(set (attr "type")
14931 (cond [(match_operand:DF 3 "mult_operator" "")
14932 (const_string "fmul")
14933 (match_operand:DF 3 "div_operator" "")
14934 (const_string "fdiv")
14935 ]
14936 (const_string "fop")))
14937 (set_attr "mode" "SF")])
14938
e075ae69
RH
14939(define_insn "*fop_xf_1"
14940 [(set (match_operand:XF 0 "register_operand" "=f,f")
14941 (match_operator:XF 3 "binary_fp_operator"
14942 [(match_operand:XF 1 "register_operand" "0,f")
14943 (match_operand:XF 2 "register_operand" "f,0")]))]
1b0c37d7 14944 "!TARGET_64BIT && TARGET_80387
caa6ec8d 14945 && GET_RTX_CLASS (GET_CODE (operands[3])) != 'c'"
e075ae69
RH
14946 "* return output_387_binary_op (insn, operands);"
14947 [(set (attr "type")
ca285e07 14948 (cond [(match_operand:XF 3 "mult_operator" "")
e075ae69 14949 (const_string "fmul")
ca285e07 14950 (match_operand:XF 3 "div_operator" "")
e075ae69
RH
14951 (const_string "fdiv")
14952 ]
6ef67412
JH
14953 (const_string "fop")))
14954 (set_attr "mode" "XF")])
e075ae69 14955
2b589241
JH
14956(define_insn "*fop_tf_1"
14957 [(set (match_operand:TF 0 "register_operand" "=f,f")
14958 (match_operator:TF 3 "binary_fp_operator"
14959 [(match_operand:TF 1 "register_operand" "0,f")
14960 (match_operand:TF 2 "register_operand" "f,0")]))]
14961 "TARGET_80387
14962 && GET_RTX_CLASS (GET_CODE (operands[3])) != 'c'"
14963 "* return output_387_binary_op (insn, operands);"
14964 [(set (attr "type")
14965 (cond [(match_operand:TF 3 "mult_operator" "")
14966 (const_string "fmul")
14967 (match_operand:TF 3 "div_operator" "")
14968 (const_string "fdiv")
14969 ]
14970 (const_string "fop")))
14971 (set_attr "mode" "XF")])
14972
e075ae69
RH
14973(define_insn "*fop_xf_2"
14974 [(set (match_operand:XF 0 "register_operand" "=f,f")
14975 (match_operator:XF 3 "binary_fp_operator"
14976 [(float:XF (match_operand:SI 1 "nonimmediate_operand" "m,?r"))
14977 (match_operand:XF 2 "register_operand" "0,0")]))]
1b0c37d7 14978 "!TARGET_64BIT && TARGET_80387 && TARGET_USE_FIOP"
e075ae69
RH
14979 "* return which_alternative ? \"#\" : output_387_binary_op (insn, operands);"
14980 [(set (attr "type")
ca285e07 14981 (cond [(match_operand:XF 3 "mult_operator" "")
e075ae69 14982 (const_string "fmul")
ca285e07 14983 (match_operand:XF 3 "div_operator" "")
e075ae69
RH
14984 (const_string "fdiv")
14985 ]
14986 (const_string "fop")))
14987 (set_attr "fp_int_src" "true")
6ef67412 14988 (set_attr "mode" "SI")
e075ae69
RH
14989 (set_attr "ppro_uops" "many")])
14990
2b589241
JH
14991(define_insn "*fop_tf_2"
14992 [(set (match_operand:TF 0 "register_operand" "=f,f")
14993 (match_operator:TF 3 "binary_fp_operator"
14994 [(float:TF (match_operand:SI 1 "nonimmediate_operand" "m,?r"))
14995 (match_operand:TF 2 "register_operand" "0,0")]))]
14996 "TARGET_80387 && TARGET_USE_FIOP"
14997 "* return which_alternative ? \"#\" : output_387_binary_op (insn, operands);"
14998 [(set (attr "type")
14999 (cond [(match_operand:TF 3 "mult_operator" "")
15000 (const_string "fmul")
15001 (match_operand:TF 3 "div_operator" "")
15002 (const_string "fdiv")
15003 ]
15004 (const_string "fop")))
15005 (set_attr "fp_int_src" "true")
15006 (set_attr "mode" "SI")
15007 (set_attr "ppro_uops" "many")])
15008
e075ae69
RH
15009(define_insn "*fop_xf_3"
15010 [(set (match_operand:XF 0 "register_operand" "=f,f")
15011 (match_operator:XF 3 "binary_fp_operator"
15012 [(match_operand:XF 1 "register_operand" "0,0")
15013 (float:XF (match_operand:SI 2 "nonimmediate_operand" "m,?r"))]))]
1b0c37d7 15014 "!TARGET_64BIT && TARGET_80387 && TARGET_USE_FIOP"
e075ae69
RH
15015 "* return which_alternative ? \"#\" : output_387_binary_op (insn, operands);"
15016 [(set (attr "type")
ca285e07 15017 (cond [(match_operand:XF 3 "mult_operator" "")
e075ae69 15018 (const_string "fmul")
ca285e07 15019 (match_operand:XF 3 "div_operator" "")
e075ae69
RH
15020 (const_string "fdiv")
15021 ]
15022 (const_string "fop")))
15023 (set_attr "fp_int_src" "true")
6ef67412 15024 (set_attr "mode" "SI")
e075ae69
RH
15025 (set_attr "ppro_uops" "many")])
15026
2b589241
JH
15027(define_insn "*fop_tf_3"
15028 [(set (match_operand:TF 0 "register_operand" "=f,f")
15029 (match_operator:TF 3 "binary_fp_operator"
15030 [(match_operand:TF 1 "register_operand" "0,0")
15031 (float:TF (match_operand:SI 2 "nonimmediate_operand" "m,?r"))]))]
15032 "TARGET_80387 && TARGET_USE_FIOP"
15033 "* return which_alternative ? \"#\" : output_387_binary_op (insn, operands);"
15034 [(set (attr "type")
15035 (cond [(match_operand:TF 3 "mult_operator" "")
15036 (const_string "fmul")
15037 (match_operand:TF 3 "div_operator" "")
15038 (const_string "fdiv")
15039 ]
15040 (const_string "fop")))
15041 (set_attr "fp_int_src" "true")
15042 (set_attr "mode" "SI")
15043 (set_attr "ppro_uops" "many")])
15044
e075ae69
RH
15045(define_insn "*fop_xf_4"
15046 [(set (match_operand:XF 0 "register_operand" "=f,f")
15047 (match_operator:XF 3 "binary_fp_operator"
4977bab6 15048 [(float_extend:XF (match_operand 1 "nonimmediate_operand" "fm,0"))
e075ae69 15049 (match_operand:XF 2 "register_operand" "0,f")]))]
1b0c37d7 15050 "!TARGET_64BIT && TARGET_80387"
e075ae69
RH
15051 "* return output_387_binary_op (insn, operands);"
15052 [(set (attr "type")
ca285e07 15053 (cond [(match_operand:XF 3 "mult_operator" "")
e075ae69 15054 (const_string "fmul")
ca285e07 15055 (match_operand:XF 3 "div_operator" "")
e075ae69
RH
15056 (const_string "fdiv")
15057 ]
6ef67412
JH
15058 (const_string "fop")))
15059 (set_attr "mode" "SF")])
e075ae69 15060
2b589241
JH
15061(define_insn "*fop_tf_4"
15062 [(set (match_operand:TF 0 "register_operand" "=f,f")
15063 (match_operator:TF 3 "binary_fp_operator"
4977bab6 15064 [(float_extend:TF (match_operand 1 "nonimmediate_operand" "fm,0"))
2b589241
JH
15065 (match_operand:TF 2 "register_operand" "0,f")]))]
15066 "TARGET_80387"
15067 "* return output_387_binary_op (insn, operands);"
15068 [(set (attr "type")
15069 (cond [(match_operand:TF 3 "mult_operator" "")
15070 (const_string "fmul")
15071 (match_operand:TF 3 "div_operator" "")
15072 (const_string "fdiv")
15073 ]
15074 (const_string "fop")))
15075 (set_attr "mode" "SF")])
15076
e075ae69
RH
15077(define_insn "*fop_xf_5"
15078 [(set (match_operand:XF 0 "register_operand" "=f,f")
15079 (match_operator:XF 3 "binary_fp_operator"
15080 [(match_operand:XF 1 "register_operand" "0,f")
15081 (float_extend:XF
4977bab6 15082 (match_operand 2 "nonimmediate_operand" "fm,0"))]))]
1b0c37d7 15083 "!TARGET_64BIT && TARGET_80387"
e075ae69
RH
15084 "* return output_387_binary_op (insn, operands);"
15085 [(set (attr "type")
ca285e07 15086 (cond [(match_operand:XF 3 "mult_operator" "")
e075ae69 15087 (const_string "fmul")
ca285e07 15088 (match_operand:XF 3 "div_operator" "")
e075ae69
RH
15089 (const_string "fdiv")
15090 ]
6ef67412
JH
15091 (const_string "fop")))
15092 (set_attr "mode" "SF")])
e075ae69 15093
2b589241
JH
15094(define_insn "*fop_tf_5"
15095 [(set (match_operand:TF 0 "register_operand" "=f,f")
15096 (match_operator:TF 3 "binary_fp_operator"
15097 [(match_operand:TF 1 "register_operand" "0,f")
15098 (float_extend:TF
4977bab6 15099 (match_operand 2 "nonimmediate_operand" "fm,0"))]))]
2b589241
JH
15100 "TARGET_80387"
15101 "* return output_387_binary_op (insn, operands);"
15102 [(set (attr "type")
15103 (cond [(match_operand:TF 3 "mult_operator" "")
15104 (const_string "fmul")
15105 (match_operand:TF 3 "div_operator" "")
15106 (const_string "fdiv")
15107 ]
15108 (const_string "fop")))
15109 (set_attr "mode" "SF")])
15110
e075ae69
RH
15111(define_insn "*fop_xf_6"
15112 [(set (match_operand:XF 0 "register_operand" "=f,f")
15113 (match_operator:XF 3 "binary_fp_operator"
4977bab6
ZW
15114 [(float_extend:XF
15115 (match_operand 1 "register_operand" "0,f"))
e075ae69 15116 (float_extend:XF
4977bab6 15117 (match_operand 2 "nonimmediate_operand" "fm,0"))]))]
1b0c37d7 15118 "!TARGET_64BIT && TARGET_80387"
e075ae69
RH
15119 "* return output_387_binary_op (insn, operands);"
15120 [(set (attr "type")
ca285e07 15121 (cond [(match_operand:XF 3 "mult_operator" "")
e075ae69 15122 (const_string "fmul")
ca285e07 15123 (match_operand:XF 3 "div_operator" "")
e075ae69
RH
15124 (const_string "fdiv")
15125 ]
6ef67412 15126 (const_string "fop")))
4977bab6 15127 (set_attr "mode" "SF")])
e075ae69 15128
4977bab6 15129(define_insn "*fop_tf_6"
2b589241
JH
15130 [(set (match_operand:TF 0 "register_operand" "=f,f")
15131 (match_operator:TF 3 "binary_fp_operator"
4977bab6
ZW
15132 [(float_extend:TF
15133 (match_operand 1 "register_operand" "0,f"))
2b589241 15134 (float_extend:TF
4977bab6 15135 (match_operand 2 "nonimmediate_operand" "fm,0"))]))]
2b589241
JH
15136 "TARGET_80387"
15137 "* return output_387_binary_op (insn, operands);"
15138 [(set (attr "type")
15139 (cond [(match_operand:TF 3 "mult_operator" "")
15140 (const_string "fmul")
15141 (match_operand:TF 3 "div_operator" "")
15142 (const_string "fdiv")
15143 ]
15144 (const_string "fop")))
4977bab6 15145 (set_attr "mode" "SF")])
2b589241 15146
e075ae69
RH
15147(define_split
15148 [(set (match_operand 0 "register_operand" "")
15149 (match_operator 3 "binary_fp_operator"
15150 [(float (match_operand:SI 1 "register_operand" ""))
15151 (match_operand 2 "register_operand" "")]))]
15152 "TARGET_80387 && reload_completed
15153 && FLOAT_MODE_P (GET_MODE (operands[0]))"
4211a8fb 15154 [(const_int 0)]
4211a8fb
JH
15155{
15156 operands[4] = ix86_force_to_memory (GET_MODE (operands[1]), operands[1]);
15157 operands[4] = gen_rtx_FLOAT (GET_MODE (operands[0]), operands[4]);
15158 emit_insn (gen_rtx_SET (VOIDmode, operands[0],
15159 gen_rtx_fmt_ee (GET_CODE (operands[3]),
15160 GET_MODE (operands[3]),
15161 operands[4],
15162 operands[2])));
15163 ix86_free_from_memory (GET_MODE (operands[1]));
15164 DONE;
0f40f9f7 15165})
e075ae69
RH
15166
15167(define_split
15168 [(set (match_operand 0 "register_operand" "")
15169 (match_operator 3 "binary_fp_operator"
15170 [(match_operand 1 "register_operand" "")
15171 (float (match_operand:SI 2 "register_operand" ""))]))]
15172 "TARGET_80387 && reload_completed
15173 && FLOAT_MODE_P (GET_MODE (operands[0]))"
4211a8fb 15174 [(const_int 0)]
4211a8fb
JH
15175{
15176 operands[4] = ix86_force_to_memory (GET_MODE (operands[2]), operands[2]);
15177 operands[4] = gen_rtx_FLOAT (GET_MODE (operands[0]), operands[4]);
15178 emit_insn (gen_rtx_SET (VOIDmode, operands[0],
2b66da3c 15179 gen_rtx_fmt_ee (GET_CODE (operands[3]),
4211a8fb
JH
15180 GET_MODE (operands[3]),
15181 operands[1],
15182 operands[4])));
15183 ix86_free_from_memory (GET_MODE (operands[2]));
15184 DONE;
0f40f9f7 15185})
e075ae69
RH
15186\f
15187;; FPU special functions.
15188
a8083431
JH
15189(define_expand "sqrtsf2"
15190 [(set (match_operand:SF 0 "register_operand" "")
15191 (sqrt:SF (match_operand:SF 1 "nonimmediate_operand" "")))]
abf80f8f 15192 "(! TARGET_NO_FANCY_MATH_387 && TARGET_80387) || TARGET_SSE_MATH"
a8083431 15193{
abf80f8f 15194 if (!TARGET_SSE_MATH)
a8083431 15195 operands[1] = force_reg (SFmode, operands[1]);
0f40f9f7 15196})
a8083431
JH
15197
15198(define_insn "sqrtsf2_1"
ca9a9b12
JH
15199 [(set (match_operand:SF 0 "register_operand" "=f#x,x#f")
15200 (sqrt:SF (match_operand:SF 1 "nonimmediate_operand" "0#x,xm#f")))]
a8083431 15201 "! TARGET_NO_FANCY_MATH_387 && TARGET_80387
abf80f8f 15202 && (TARGET_SSE_MATH && TARGET_MIX_SSE_I387)"
a8083431
JH
15203 "@
15204 fsqrt
0f40f9f7 15205 sqrtss\t{%1, %0|%0, %1}"
a8083431
JH
15206 [(set_attr "type" "fpspc,sse")
15207 (set_attr "mode" "SF,SF")
15208 (set_attr "athlon_decode" "direct,*")])
15209
15210(define_insn "sqrtsf2_1_sse_only"
ca9a9b12
JH
15211 [(set (match_operand:SF 0 "register_operand" "=x")
15212 (sqrt:SF (match_operand:SF 1 "nonimmediate_operand" "xm")))]
abf80f8f 15213 "TARGET_SSE_MATH && (!TARGET_80387 || !TARGET_MIX_SSE_I387)"
0f40f9f7 15214 "sqrtss\t{%1, %0|%0, %1}"
a8083431
JH
15215 [(set_attr "type" "sse")
15216 (set_attr "mode" "SF")
15217 (set_attr "athlon_decode" "*")])
15218
15219(define_insn "sqrtsf2_i387"
e075ae69
RH
15220 [(set (match_operand:SF 0 "register_operand" "=f")
15221 (sqrt:SF (match_operand:SF 1 "register_operand" "0")))]
a8083431 15222 "! TARGET_NO_FANCY_MATH_387 && TARGET_80387
abf80f8f 15223 && !TARGET_SSE_MATH"
e075ae69 15224 "fsqrt"
0b5107cf 15225 [(set_attr "type" "fpspc")
6ef67412 15226 (set_attr "mode" "SF")
0b5107cf 15227 (set_attr "athlon_decode" "direct")])
e075ae69 15228
a8083431
JH
15229(define_expand "sqrtdf2"
15230 [(set (match_operand:DF 0 "register_operand" "")
15231 (sqrt:DF (match_operand:DF 1 "nonimmediate_operand" "")))]
965f5423
JH
15232 "(! TARGET_NO_FANCY_MATH_387 && TARGET_80387)
15233 || (TARGET_SSE2 && TARGET_SSE_MATH)"
a8083431 15234{
965f5423 15235 if (!TARGET_SSE2 || !TARGET_SSE_MATH)
2406cfed 15236 operands[1] = force_reg (DFmode, operands[1]);
0f40f9f7 15237})
a8083431
JH
15238
15239(define_insn "sqrtdf2_1"
15240 [(set (match_operand:DF 0 "register_operand" "=f#Y,Y#f")
15241 (sqrt:DF (match_operand:DF 1 "nonimmediate_operand" "0#Y,Ym#f")))]
15242 "! TARGET_NO_FANCY_MATH_387 && TARGET_80387
965f5423 15243 && (TARGET_SSE2 && TARGET_SSE_MATH && TARGET_MIX_SSE_I387)"
a8083431
JH
15244 "@
15245 fsqrt
0f40f9f7 15246 sqrtsd\t{%1, %0|%0, %1}"
a8083431
JH
15247 [(set_attr "type" "fpspc,sse")
15248 (set_attr "mode" "DF,DF")
15249 (set_attr "athlon_decode" "direct,*")])
15250
15251(define_insn "sqrtdf2_1_sse_only"
15252 [(set (match_operand:DF 0 "register_operand" "=Y")
15253 (sqrt:DF (match_operand:DF 1 "nonimmediate_operand" "Ym")))]
965f5423 15254 "TARGET_SSE2 && TARGET_SSE_MATH && (!TARGET_80387 || !TARGET_MIX_SSE_I387)"
0f40f9f7 15255 "sqrtsd\t{%1, %0|%0, %1}"
a8083431
JH
15256 [(set_attr "type" "sse")
15257 (set_attr "mode" "DF")
15258 (set_attr "athlon_decode" "*")])
15259
15260(define_insn "sqrtdf2_i387"
e075ae69
RH
15261 [(set (match_operand:DF 0 "register_operand" "=f")
15262 (sqrt:DF (match_operand:DF 1 "register_operand" "0")))]
15263 "! TARGET_NO_FANCY_MATH_387 && TARGET_80387
abf80f8f 15264 && (!TARGET_SSE2 || !TARGET_SSE_MATH)"
e075ae69 15265 "fsqrt"
0b5107cf 15266 [(set_attr "type" "fpspc")
6ef67412 15267 (set_attr "mode" "DF")
0b5107cf 15268 (set_attr "athlon_decode" "direct")])
e075ae69 15269
6343a50e 15270(define_insn "*sqrtextendsfdf2"
e075ae69
RH
15271 [(set (match_operand:DF 0 "register_operand" "=f")
15272 (sqrt:DF (float_extend:DF
15273 (match_operand:SF 1 "register_operand" "0"))))]
965f5423
JH
15274 "! TARGET_NO_FANCY_MATH_387 && TARGET_80387
15275 && !(TARGET_SSE2 && TARGET_SSE_MATH)"
e075ae69 15276 "fsqrt"
0b5107cf 15277 [(set_attr "type" "fpspc")
6ef67412 15278 (set_attr "mode" "DF")
0b5107cf 15279 (set_attr "athlon_decode" "direct")])
e075ae69
RH
15280
15281(define_insn "sqrtxf2"
15282 [(set (match_operand:XF 0 "register_operand" "=f")
15283 (sqrt:XF (match_operand:XF 1 "register_operand" "0")))]
1b0c37d7 15284 "!TARGET_64BIT && TARGET_80387 && !TARGET_NO_FANCY_MATH_387
de6c5979 15285 && (TARGET_IEEE_FP || flag_unsafe_math_optimizations) "
e075ae69 15286 "fsqrt"
0b5107cf 15287 [(set_attr "type" "fpspc")
6ef67412 15288 (set_attr "mode" "XF")
0b5107cf 15289 (set_attr "athlon_decode" "direct")])
e075ae69 15290
2b589241
JH
15291(define_insn "sqrttf2"
15292 [(set (match_operand:TF 0 "register_operand" "=f")
15293 (sqrt:TF (match_operand:TF 1 "register_operand" "0")))]
15294 "! TARGET_NO_FANCY_MATH_387 && TARGET_80387
de6c5979 15295 && (TARGET_IEEE_FP || flag_unsafe_math_optimizations) "
2b589241
JH
15296 "fsqrt"
15297 [(set_attr "type" "fpspc")
15298 (set_attr "mode" "XF")
15299 (set_attr "athlon_decode" "direct")])
15300
6343a50e 15301(define_insn "*sqrtextenddfxf2"
e075ae69
RH
15302 [(set (match_operand:XF 0 "register_operand" "=f")
15303 (sqrt:XF (float_extend:XF
15304 (match_operand:DF 1 "register_operand" "0"))))]
30c99a84 15305 "!TARGET_64BIT && TARGET_80387 && !TARGET_NO_FANCY_MATH_387"
e075ae69 15306 "fsqrt"
0b5107cf 15307 [(set_attr "type" "fpspc")
6ef67412 15308 (set_attr "mode" "XF")
0b5107cf 15309 (set_attr "athlon_decode" "direct")])
e075ae69 15310
2b589241
JH
15311(define_insn "*sqrtextenddftf2"
15312 [(set (match_operand:TF 0 "register_operand" "=f")
15313 (sqrt:TF (float_extend:TF
15314 (match_operand:DF 1 "register_operand" "0"))))]
15315 "! TARGET_NO_FANCY_MATH_387 && TARGET_80387"
15316 "fsqrt"
15317 [(set_attr "type" "fpspc")
15318 (set_attr "mode" "XF")
15319 (set_attr "athlon_decode" "direct")])
15320
6343a50e 15321(define_insn "*sqrtextendsfxf2"
e075ae69
RH
15322 [(set (match_operand:XF 0 "register_operand" "=f")
15323 (sqrt:XF (float_extend:XF
15324 (match_operand:SF 1 "register_operand" "0"))))]
30c99a84 15325 "!TARGET_64BIT && TARGET_80387 && !TARGET_NO_FANCY_MATH_387"
e075ae69 15326 "fsqrt"
0b5107cf 15327 [(set_attr "type" "fpspc")
6ef67412 15328 (set_attr "mode" "XF")
0b5107cf 15329 (set_attr "athlon_decode" "direct")])
e075ae69 15330
2b589241
JH
15331(define_insn "*sqrtextendsftf2"
15332 [(set (match_operand:TF 0 "register_operand" "=f")
15333 (sqrt:TF (float_extend:TF
15334 (match_operand:SF 1 "register_operand" "0"))))]
15335 "! TARGET_NO_FANCY_MATH_387 && TARGET_80387"
15336 "fsqrt"
15337 [(set_attr "type" "fpspc")
15338 (set_attr "mode" "XF")
15339 (set_attr "athlon_decode" "direct")])
15340
e075ae69
RH
15341(define_insn "sindf2"
15342 [(set (match_operand:DF 0 "register_operand" "=f")
8ee41eaf 15343 (unspec:DF [(match_operand:DF 1 "register_operand" "0")] UNSPEC_SIN))]
de6c5979
BL
15344 "! TARGET_NO_FANCY_MATH_387 && TARGET_80387
15345 && flag_unsafe_math_optimizations"
e075ae69 15346 "fsin"
6ef67412
JH
15347 [(set_attr "type" "fpspc")
15348 (set_attr "mode" "DF")])
e075ae69
RH
15349
15350(define_insn "sinsf2"
15351 [(set (match_operand:SF 0 "register_operand" "=f")
8ee41eaf 15352 (unspec:SF [(match_operand:SF 1 "register_operand" "0")] UNSPEC_SIN))]
de6c5979
BL
15353 "! TARGET_NO_FANCY_MATH_387 && TARGET_80387
15354 && flag_unsafe_math_optimizations"
e075ae69 15355 "fsin"
6ef67412
JH
15356 [(set_attr "type" "fpspc")
15357 (set_attr "mode" "SF")])
5f3d14e3 15358
6343a50e 15359(define_insn "*sinextendsfdf2"
e075ae69
RH
15360 [(set (match_operand:DF 0 "register_operand" "=f")
15361 (unspec:DF [(float_extend:DF
8ee41eaf
RH
15362 (match_operand:SF 1 "register_operand" "0"))]
15363 UNSPEC_SIN))]
de6c5979
BL
15364 "! TARGET_NO_FANCY_MATH_387 && TARGET_80387
15365 && flag_unsafe_math_optimizations"
e075ae69 15366 "fsin"
6ef67412
JH
15367 [(set_attr "type" "fpspc")
15368 (set_attr "mode" "DF")])
4f9ca067 15369
e075ae69
RH
15370(define_insn "sinxf2"
15371 [(set (match_operand:XF 0 "register_operand" "=f")
8ee41eaf 15372 (unspec:XF [(match_operand:XF 1 "register_operand" "0")] UNSPEC_SIN))]
30c99a84 15373 "!TARGET_64BIT && TARGET_80387 && !TARGET_NO_FANCY_MATH_387
de6c5979 15374 && flag_unsafe_math_optimizations"
e075ae69 15375 "fsin"
6ef67412
JH
15376 [(set_attr "type" "fpspc")
15377 (set_attr "mode" "XF")])
5f3d14e3 15378
2b589241
JH
15379(define_insn "sintf2"
15380 [(set (match_operand:TF 0 "register_operand" "=f")
8ee41eaf 15381 (unspec:TF [(match_operand:TF 1 "register_operand" "0")] UNSPEC_SIN))]
de6c5979
BL
15382 "! TARGET_NO_FANCY_MATH_387 && TARGET_80387
15383 && flag_unsafe_math_optimizations"
2b589241
JH
15384 "fsin"
15385 [(set_attr "type" "fpspc")
15386 (set_attr "mode" "XF")])
15387
e075ae69
RH
15388(define_insn "cosdf2"
15389 [(set (match_operand:DF 0 "register_operand" "=f")
8ee41eaf 15390 (unspec:DF [(match_operand:DF 1 "register_operand" "0")] UNSPEC_COS))]
de6c5979
BL
15391 "! TARGET_NO_FANCY_MATH_387 && TARGET_80387
15392 && flag_unsafe_math_optimizations"
e075ae69 15393 "fcos"
6ef67412
JH
15394 [(set_attr "type" "fpspc")
15395 (set_attr "mode" "DF")])
bca7cce2 15396
e075ae69
RH
15397(define_insn "cossf2"
15398 [(set (match_operand:SF 0 "register_operand" "=f")
8ee41eaf 15399 (unspec:SF [(match_operand:SF 1 "register_operand" "0")] UNSPEC_COS))]
de6c5979
BL
15400 "! TARGET_NO_FANCY_MATH_387 && TARGET_80387
15401 && flag_unsafe_math_optimizations"
e075ae69 15402 "fcos"
6ef67412
JH
15403 [(set_attr "type" "fpspc")
15404 (set_attr "mode" "SF")])
bca7cce2 15405
6343a50e 15406(define_insn "*cosextendsfdf2"
e075ae69
RH
15407 [(set (match_operand:DF 0 "register_operand" "=f")
15408 (unspec:DF [(float_extend:DF
8ee41eaf
RH
15409 (match_operand:SF 1 "register_operand" "0"))]
15410 UNSPEC_COS))]
de6c5979
BL
15411 "! TARGET_NO_FANCY_MATH_387 && TARGET_80387
15412 && flag_unsafe_math_optimizations"
e075ae69 15413 "fcos"
6ef67412
JH
15414 [(set_attr "type" "fpspc")
15415 (set_attr "mode" "DF")])
5f3d14e3 15416
e075ae69
RH
15417(define_insn "cosxf2"
15418 [(set (match_operand:XF 0 "register_operand" "=f")
8ee41eaf 15419 (unspec:XF [(match_operand:XF 1 "register_operand" "0")] UNSPEC_COS))]
9e889775 15420 "!TARGET_64BIT && ! TARGET_NO_FANCY_MATH_387 && TARGET_80387
de6c5979 15421 && flag_unsafe_math_optimizations"
e075ae69 15422 "fcos"
6ef67412
JH
15423 [(set_attr "type" "fpspc")
15424 (set_attr "mode" "XF")])
2b589241
JH
15425
15426(define_insn "costf2"
15427 [(set (match_operand:TF 0 "register_operand" "=f")
8ee41eaf 15428 (unspec:TF [(match_operand:TF 1 "register_operand" "0")] UNSPEC_COS))]
de6c5979
BL
15429 "! TARGET_NO_FANCY_MATH_387 && TARGET_80387
15430 && flag_unsafe_math_optimizations"
2b589241
JH
15431 "fcos"
15432 [(set_attr "type" "fpspc")
15433 (set_attr "mode" "XF")])
1fb54135
RS
15434
15435(define_insn "atan2df3"
15436 [(set (match_operand:DF 0 "register_operand" "=f")
15437 (unspec:DF [(match_operand:DF 2 "register_operand" "0")
15438 (match_operand:DF 1 "register_operand" "u")]
15439 UNSPEC_FPATAN))]
15440 "! TARGET_NO_FANCY_MATH_387 && TARGET_80387
15441 && flag_unsafe_math_optimizations"
15442 "fpatan"
15443 [(set_attr "type" "fpspc")
15444 (set_attr "mode" "DF")])
15445
15446(define_insn "atan2sf3"
15447 [(set (match_operand:SF 0 "register_operand" "=f")
15448 (unspec:SF [(match_operand:SF 2 "register_operand" "0")
15449 (match_operand:SF 1 "register_operand" "u")]
15450 UNSPEC_FPATAN))]
15451 "! TARGET_NO_FANCY_MATH_387 && TARGET_80387
15452 && flag_unsafe_math_optimizations"
15453 "fpatan"
15454 [(set_attr "type" "fpspc")
15455 (set_attr "mode" "SF")])
15456
15457(define_insn "atan2xf3"
15458 [(set (match_operand:XF 0 "register_operand" "=f")
15459 (unspec:XF [(match_operand:XF 2 "register_operand" "0")
15460 (match_operand:XF 1 "register_operand" "u")]
15461 UNSPEC_FPATAN))]
15462 "! TARGET_NO_FANCY_MATH_387 && TARGET_80387
15463 && flag_unsafe_math_optimizations"
15464 "fpatan"
15465 [(set_attr "type" "fpspc")
15466 (set_attr "mode" "XF")])
15467
15468(define_insn "atan2tf3"
15469 [(set (match_operand:TF 0 "register_operand" "=f")
15470 (unspec:TF [(match_operand:TF 2 "register_operand" "0")
15471 (match_operand:TF 1 "register_operand" "u")]
15472 UNSPEC_FPATAN))]
15473 "! TARGET_NO_FANCY_MATH_387 && TARGET_80387
15474 && flag_unsafe_math_optimizations"
15475 "fpatan"
15476 [(set_attr "type" "fpspc")
15477 (set_attr "mode" "XF")])
e075ae69
RH
15478\f
15479;; Block operation instructions
886c62d1 15480
7c7ef435
JH
15481(define_insn "cld"
15482 [(set (reg:SI 19) (const_int 0))]
15483 ""
15484 "cld"
15485 [(set_attr "type" "cld")])
15486
886c62d1 15487(define_expand "movstrsi"
f90800f8
JH
15488 [(use (match_operand:BLK 0 "memory_operand" ""))
15489 (use (match_operand:BLK 1 "memory_operand" ""))
79f05c19 15490 (use (match_operand:SI 2 "nonmemory_operand" ""))
f90800f8 15491 (use (match_operand:SI 3 "const_int_operand" ""))]
886c62d1 15492 ""
886c62d1 15493{
0945b39d
JH
15494 if (ix86_expand_movstr (operands[0], operands[1], operands[2], operands[3]))
15495 DONE;
15496 else
15497 FAIL;
0f40f9f7 15498})
79f05c19 15499
0945b39d
JH
15500(define_expand "movstrdi"
15501 [(use (match_operand:BLK 0 "memory_operand" ""))
15502 (use (match_operand:BLK 1 "memory_operand" ""))
15503 (use (match_operand:DI 2 "nonmemory_operand" ""))
15504 (use (match_operand:DI 3 "const_int_operand" ""))]
15505 "TARGET_64BIT"
0945b39d
JH
15506{
15507 if (ix86_expand_movstr (operands[0], operands[1], operands[2], operands[3]))
15508 DONE;
15509 else
15510 FAIL;
0f40f9f7 15511})
79f05c19 15512
0945b39d
JH
15513;; Most CPUs don't like single string operations
15514;; Handle this case here to simplify previous expander.
79f05c19 15515
0945b39d
JH
15516(define_expand "strmovdi_rex64"
15517 [(set (match_dup 2)
15518 (mem:DI (match_operand:DI 1 "register_operand" "")))
15519 (set (mem:DI (match_operand:DI 0 "register_operand" ""))
15520 (match_dup 2))
15521 (parallel [(set (match_dup 0) (plus:DI (match_dup 0) (const_int 8)))
15522 (clobber (reg:CC 17))])
15523 (parallel [(set (match_dup 1) (plus:DI (match_dup 1) (const_int 8)))
15524 (clobber (reg:CC 17))])]
15525 "TARGET_64BIT"
0945b39d
JH
15526{
15527 if (TARGET_SINGLE_STRINGOP || optimize_size)
79f05c19 15528 {
0945b39d
JH
15529 emit_insn (gen_strmovdi_rex_1 (operands[0], operands[1], operands[0],
15530 operands[1]));
15531 DONE;
79f05c19 15532 }
0945b39d
JH
15533 else
15534 operands[2] = gen_reg_rtx (DImode);
0f40f9f7 15535})
886c62d1 15536
56c0e8fa 15537
79f05c19
JH
15538(define_expand "strmovsi"
15539 [(set (match_dup 2)
15540 (mem:SI (match_operand:SI 1 "register_operand" "")))
15541 (set (mem:SI (match_operand:SI 0 "register_operand" ""))
15542 (match_dup 2))
15543 (parallel [(set (match_dup 0) (plus:SI (match_dup 0) (const_int 4)))
15544 (clobber (reg:CC 17))])
15545 (parallel [(set (match_dup 1) (plus:SI (match_dup 1) (const_int 4)))
15546 (clobber (reg:CC 17))])]
15547 ""
79f05c19 15548{
0945b39d
JH
15549 if (TARGET_64BIT)
15550 {
15551 emit_insn (gen_strmovsi_rex64 (operands[0], operands[1]));
15552 DONE;
15553 }
79f05c19
JH
15554 if (TARGET_SINGLE_STRINGOP || optimize_size)
15555 {
15556 emit_insn (gen_strmovsi_1 (operands[0], operands[1], operands[0],
15557 operands[1]));
15558 DONE;
15559 }
15560 else
15561 operands[2] = gen_reg_rtx (SImode);
0f40f9f7 15562})
79f05c19 15563
0945b39d
JH
15564(define_expand "strmovsi_rex64"
15565 [(set (match_dup 2)
15566 (mem:SI (match_operand:DI 1 "register_operand" "")))
15567 (set (mem:SI (match_operand:DI 0 "register_operand" ""))
15568 (match_dup 2))
15569 (parallel [(set (match_dup 0) (plus:DI (match_dup 0) (const_int 4)))
15570 (clobber (reg:CC 17))])
15571 (parallel [(set (match_dup 1) (plus:DI (match_dup 1) (const_int 4)))
15572 (clobber (reg:CC 17))])]
15573 "TARGET_64BIT"
0945b39d
JH
15574{
15575 if (TARGET_SINGLE_STRINGOP || optimize_size)
15576 {
15577 emit_insn (gen_strmovsi_rex_1 (operands[0], operands[1], operands[0],
15578 operands[1]));
15579 DONE;
15580 }
15581 else
15582 operands[2] = gen_reg_rtx (SImode);
0f40f9f7 15583})
0945b39d 15584
f90800f8
JH
15585(define_expand "strmovhi"
15586 [(set (match_dup 2)
15587 (mem:HI (match_operand:SI 1 "register_operand" "")))
15588 (set (mem:HI (match_operand:SI 0 "register_operand" ""))
15589 (match_dup 2))
15590 (parallel [(set (match_dup 0) (plus:SI (match_dup 0) (const_int 2)))
15591 (clobber (reg:CC 17))])
15592 (parallel [(set (match_dup 1) (plus:SI (match_dup 1) (const_int 2)))
15593 (clobber (reg:CC 17))])]
886c62d1 15594 ""
886c62d1 15595{
0945b39d
JH
15596 if (TARGET_64BIT)
15597 {
15598 emit_insn (gen_strmovhi_rex64 (operands[0], operands[1]));
15599 DONE;
15600 }
f90800f8 15601 if (TARGET_SINGLE_STRINGOP || optimize_size)
886c62d1 15602 {
f90800f8
JH
15603 emit_insn (gen_strmovhi_1 (operands[0], operands[1], operands[0],
15604 operands[1]));
15605 DONE;
15606 }
15607 else
15608 operands[2] = gen_reg_rtx (HImode);
0f40f9f7 15609})
886c62d1 15610
0945b39d
JH
15611(define_expand "strmovhi_rex64"
15612 [(set (match_dup 2)
15613 (mem:HI (match_operand:DI 1 "register_operand" "")))
15614 (set (mem:HI (match_operand:DI 0 "register_operand" ""))
15615 (match_dup 2))
15616 (parallel [(set (match_dup 0) (plus:DI (match_dup 0) (const_int 2)))
15617 (clobber (reg:CC 17))])
15618 (parallel [(set (match_dup 1) (plus:DI (match_dup 1) (const_int 2)))
15619 (clobber (reg:CC 17))])]
15620 "TARGET_64BIT"
0945b39d
JH
15621{
15622 if (TARGET_SINGLE_STRINGOP || optimize_size)
15623 {
15624 emit_insn (gen_strmovhi_rex_1 (operands[0], operands[1], operands[0],
15625 operands[1]));
15626 DONE;
15627 }
15628 else
15629 operands[2] = gen_reg_rtx (HImode);
0f40f9f7 15630})
0945b39d 15631
f90800f8
JH
15632(define_expand "strmovqi"
15633 [(set (match_dup 2)
15634 (mem:QI (match_operand:SI 1 "register_operand" "")))
15635 (set (mem:QI (match_operand:SI 0 "register_operand" ""))
15636 (match_dup 2))
15637 (parallel [(set (match_dup 0) (plus:SI (match_dup 0) (const_int 1)))
15638 (clobber (reg:CC 17))])
15639 (parallel [(set (match_dup 1) (plus:SI (match_dup 1) (const_int 1)))
15640 (clobber (reg:CC 17))])]
15641 ""
f90800f8 15642{
0945b39d
JH
15643 if (TARGET_64BIT)
15644 {
15645 emit_insn (gen_strmovqi_rex64 (operands[0], operands[1]));
15646 DONE;
15647 }
f90800f8
JH
15648 if (TARGET_SINGLE_STRINGOP || optimize_size)
15649 {
15650 emit_insn (gen_strmovqi_1 (operands[0], operands[1], operands[0],
15651 operands[1]));
15652 DONE;
886c62d1 15653 }
f90800f8
JH
15654 else
15655 operands[2] = gen_reg_rtx (QImode);
0f40f9f7 15656})
f90800f8 15657
0945b39d
JH
15658(define_expand "strmovqi_rex64"
15659 [(set (match_dup 2)
15660 (mem:QI (match_operand:DI 1 "register_operand" "")))
15661 (set (mem:QI (match_operand:DI 0 "register_operand" ""))
15662 (match_dup 2))
15663 (parallel [(set (match_dup 0) (plus:DI (match_dup 0) (const_int 1)))
15664 (clobber (reg:CC 17))])
15665 (parallel [(set (match_dup 1) (plus:DI (match_dup 1) (const_int 1)))
15666 (clobber (reg:CC 17))])]
1b0c37d7 15667 "TARGET_64BIT"
0945b39d
JH
15668{
15669 if (TARGET_SINGLE_STRINGOP || optimize_size)
15670 {
15671 emit_insn (gen_strmovqi_rex_1 (operands[0], operands[1], operands[0],
15672 operands[1]));
15673 DONE;
15674 }
15675 else
15676 operands[2] = gen_reg_rtx (QImode);
0f40f9f7 15677})
0945b39d
JH
15678
15679(define_insn "strmovdi_rex_1"
15680 [(set (mem:DI (match_operand:DI 2 "register_operand" "0"))
15681 (mem:DI (match_operand:DI 3 "register_operand" "1")))
15682 (set (match_operand:DI 0 "register_operand" "=D")
15683 (plus:DI (match_dup 2)
15684 (const_int 8)))
15685 (set (match_operand:DI 1 "register_operand" "=S")
15686 (plus:DI (match_dup 3)
15687 (const_int 8)))
15688 (use (reg:SI 19))]
15689 "TARGET_64BIT && (TARGET_SINGLE_STRINGOP || optimize_size)"
15690 "movsq"
15691 [(set_attr "type" "str")
15692 (set_attr "mode" "DI")
15693 (set_attr "memory" "both")])
15694
79f05c19
JH
15695(define_insn "strmovsi_1"
15696 [(set (mem:SI (match_operand:SI 2 "register_operand" "0"))
15697 (mem:SI (match_operand:SI 3 "register_operand" "1")))
15698 (set (match_operand:SI 0 "register_operand" "=D")
b1cdafbb 15699 (plus:SI (match_dup 2)
79f05c19
JH
15700 (const_int 4)))
15701 (set (match_operand:SI 1 "register_operand" "=S")
b1cdafbb 15702 (plus:SI (match_dup 3)
79f05c19
JH
15703 (const_int 4)))
15704 (use (reg:SI 19))]
0945b39d 15705 "!TARGET_64BIT && (TARGET_SINGLE_STRINGOP || optimize_size)"
371bc54b 15706 "{movsl|movsd}"
0945b39d
JH
15707 [(set_attr "type" "str")
15708 (set_attr "mode" "SI")
15709 (set_attr "memory" "both")])
15710
15711(define_insn "strmovsi_rex_1"
15712 [(set (mem:SI (match_operand:DI 2 "register_operand" "0"))
15713 (mem:SI (match_operand:DI 3 "register_operand" "1")))
15714 (set (match_operand:DI 0 "register_operand" "=D")
15715 (plus:DI (match_dup 2)
15716 (const_int 4)))
15717 (set (match_operand:DI 1 "register_operand" "=S")
15718 (plus:DI (match_dup 3)
15719 (const_int 4)))
15720 (use (reg:SI 19))]
15721 "TARGET_64BIT && (TARGET_SINGLE_STRINGOP || optimize_size)"
371bc54b 15722 "{movsl|movsd}"
79f05c19 15723 [(set_attr "type" "str")
6ef67412 15724 (set_attr "mode" "SI")
79f05c19
JH
15725 (set_attr "memory" "both")])
15726
f90800f8
JH
15727(define_insn "strmovhi_1"
15728 [(set (mem:HI (match_operand:SI 2 "register_operand" "0"))
15729 (mem:HI (match_operand:SI 3 "register_operand" "1")))
15730 (set (match_operand:SI 0 "register_operand" "=D")
b1cdafbb 15731 (plus:SI (match_dup 2)
f90800f8
JH
15732 (const_int 2)))
15733 (set (match_operand:SI 1 "register_operand" "=S")
b1cdafbb 15734 (plus:SI (match_dup 3)
f90800f8
JH
15735 (const_int 2)))
15736 (use (reg:SI 19))]
0945b39d
JH
15737 "!TARGET_64BIT && (TARGET_SINGLE_STRINGOP || optimize_size)"
15738 "movsw"
15739 [(set_attr "type" "str")
15740 (set_attr "memory" "both")
15741 (set_attr "mode" "HI")])
15742
15743(define_insn "strmovhi_rex_1"
15744 [(set (mem:HI (match_operand:DI 2 "register_operand" "0"))
15745 (mem:HI (match_operand:DI 3 "register_operand" "1")))
15746 (set (match_operand:DI 0 "register_operand" "=D")
15747 (plus:DI (match_dup 2)
15748 (const_int 2)))
15749 (set (match_operand:DI 1 "register_operand" "=S")
15750 (plus:DI (match_dup 3)
15751 (const_int 2)))
15752 (use (reg:SI 19))]
15753 "TARGET_64BIT && (TARGET_SINGLE_STRINGOP || optimize_size)"
f90800f8
JH
15754 "movsw"
15755 [(set_attr "type" "str")
15756 (set_attr "memory" "both")
6ef67412 15757 (set_attr "mode" "HI")])
f90800f8
JH
15758
15759(define_insn "strmovqi_1"
15760 [(set (mem:QI (match_operand:SI 2 "register_operand" "0"))
15761 (mem:QI (match_operand:SI 3 "register_operand" "1")))
15762 (set (match_operand:SI 0 "register_operand" "=D")
b1cdafbb 15763 (plus:SI (match_dup 2)
f90800f8
JH
15764 (const_int 1)))
15765 (set (match_operand:SI 1 "register_operand" "=S")
b1cdafbb 15766 (plus:SI (match_dup 3)
f90800f8
JH
15767 (const_int 1)))
15768 (use (reg:SI 19))]
0945b39d 15769 "!TARGET_64BIT && (TARGET_SINGLE_STRINGOP || optimize_size)"
f90800f8
JH
15770 "movsb"
15771 [(set_attr "type" "str")
6ef67412
JH
15772 (set_attr "memory" "both")
15773 (set_attr "mode" "QI")])
f90800f8 15774
0945b39d
JH
15775(define_insn "strmovqi_rex_1"
15776 [(set (mem:QI (match_operand:DI 2 "register_operand" "0"))
15777 (mem:QI (match_operand:DI 3 "register_operand" "1")))
15778 (set (match_operand:DI 0 "register_operand" "=D")
15779 (plus:DI (match_dup 2)
15780 (const_int 1)))
15781 (set (match_operand:DI 1 "register_operand" "=S")
15782 (plus:DI (match_dup 3)
15783 (const_int 1)))
15784 (use (reg:SI 19))]
15785 "TARGET_64BIT && (TARGET_SINGLE_STRINGOP || optimize_size)"
15786 "movsb"
15787 [(set_attr "type" "str")
15788 (set_attr "memory" "both")
15789 (set_attr "mode" "QI")])
15790
15791(define_insn "rep_movdi_rex64"
15792 [(set (match_operand:DI 2 "register_operand" "=c") (const_int 0))
15793 (set (match_operand:DI 0 "register_operand" "=D")
15794 (plus:DI (ashift:DI (match_operand:DI 5 "register_operand" "2")
15795 (const_int 3))
15796 (match_operand:DI 3 "register_operand" "0")))
15797 (set (match_operand:DI 1 "register_operand" "=S")
15798 (plus:DI (ashift:DI (match_dup 5) (const_int 3))
15799 (match_operand:DI 4 "register_operand" "1")))
15800 (set (mem:BLK (match_dup 3))
15801 (mem:BLK (match_dup 4)))
15802 (use (match_dup 5))
15803 (use (reg:SI 19))]
15804 "TARGET_64BIT"
8554d9a4 15805 "{rep\;movsq|rep movsq}"
0945b39d
JH
15806 [(set_attr "type" "str")
15807 (set_attr "prefix_rep" "1")
15808 (set_attr "memory" "both")
15809 (set_attr "mode" "DI")])
15810
f90800f8
JH
15811(define_insn "rep_movsi"
15812 [(set (match_operand:SI 2 "register_operand" "=c") (const_int 0))
f90800f8 15813 (set (match_operand:SI 0 "register_operand" "=D")
b1cdafbb
JH
15814 (plus:SI (ashift:SI (match_operand:SI 5 "register_operand" "2")
15815 (const_int 2))
15816 (match_operand:SI 3 "register_operand" "0")))
f90800f8 15817 (set (match_operand:SI 1 "register_operand" "=S")
b1cdafbb
JH
15818 (plus:SI (ashift:SI (match_dup 5) (const_int 2))
15819 (match_operand:SI 4 "register_operand" "1")))
f90800f8
JH
15820 (set (mem:BLK (match_dup 3))
15821 (mem:BLK (match_dup 4)))
b1cdafbb 15822 (use (match_dup 5))
f90800f8 15823 (use (reg:SI 19))]
0945b39d 15824 "!TARGET_64BIT"
8554d9a4 15825 "{rep\;movsl|rep movsd}"
0945b39d
JH
15826 [(set_attr "type" "str")
15827 (set_attr "prefix_rep" "1")
15828 (set_attr "memory" "both")
15829 (set_attr "mode" "SI")])
15830
15831(define_insn "rep_movsi_rex64"
15832 [(set (match_operand:DI 2 "register_operand" "=c") (const_int 0))
15833 (set (match_operand:DI 0 "register_operand" "=D")
15834 (plus:DI (ashift:DI (match_operand:DI 5 "register_operand" "2")
15835 (const_int 2))
15836 (match_operand:DI 3 "register_operand" "0")))
15837 (set (match_operand:DI 1 "register_operand" "=S")
15838 (plus:DI (ashift:DI (match_dup 5) (const_int 2))
15839 (match_operand:DI 4 "register_operand" "1")))
15840 (set (mem:BLK (match_dup 3))
15841 (mem:BLK (match_dup 4)))
15842 (use (match_dup 5))
15843 (use (reg:SI 19))]
15844 "TARGET_64BIT"
8554d9a4 15845 "{rep\;movsl|rep movsd}"
f90800f8 15846 [(set_attr "type" "str")
6ef67412
JH
15847 (set_attr "prefix_rep" "1")
15848 (set_attr "memory" "both")
15849 (set_attr "mode" "SI")])
f90800f8
JH
15850
15851(define_insn "rep_movqi"
15852 [(set (match_operand:SI 2 "register_operand" "=c") (const_int 0))
f90800f8 15853 (set (match_operand:SI 0 "register_operand" "=D")
b1cdafbb
JH
15854 (plus:SI (match_operand:SI 3 "register_operand" "0")
15855 (match_operand:SI 5 "register_operand" "2")))
f90800f8 15856 (set (match_operand:SI 1 "register_operand" "=S")
b1cdafbb 15857 (plus:SI (match_operand:SI 4 "register_operand" "1") (match_dup 5)))
f90800f8
JH
15858 (set (mem:BLK (match_dup 3))
15859 (mem:BLK (match_dup 4)))
b1cdafbb 15860 (use (match_dup 5))
f90800f8 15861 (use (reg:SI 19))]
0945b39d 15862 "!TARGET_64BIT"
8554d9a4 15863 "{rep\;movsb|rep movsb}"
0945b39d
JH
15864 [(set_attr "type" "str")
15865 (set_attr "prefix_rep" "1")
15866 (set_attr "memory" "both")
15867 (set_attr "mode" "SI")])
15868
15869(define_insn "rep_movqi_rex64"
15870 [(set (match_operand:DI 2 "register_operand" "=c") (const_int 0))
15871 (set (match_operand:DI 0 "register_operand" "=D")
15872 (plus:DI (match_operand:DI 3 "register_operand" "0")
15873 (match_operand:DI 5 "register_operand" "2")))
15874 (set (match_operand:DI 1 "register_operand" "=S")
15875 (plus:DI (match_operand:DI 4 "register_operand" "1") (match_dup 5)))
15876 (set (mem:BLK (match_dup 3))
15877 (mem:BLK (match_dup 4)))
15878 (use (match_dup 5))
15879 (use (reg:SI 19))]
15880 "TARGET_64BIT"
8554d9a4 15881 "{rep\;movsb|rep movsb}"
f90800f8 15882 [(set_attr "type" "str")
6ef67412
JH
15883 (set_attr "prefix_rep" "1")
15884 (set_attr "memory" "both")
15885 (set_attr "mode" "SI")])
886c62d1 15886
0ae40045 15887(define_expand "clrstrsi"
e2e52e1b 15888 [(use (match_operand:BLK 0 "memory_operand" ""))
79f05c19 15889 (use (match_operand:SI 1 "nonmemory_operand" ""))
0945b39d 15890 (use (match_operand 2 "const_int_operand" ""))]
0ae40045 15891 ""
0ae40045 15892{
0945b39d
JH
15893 if (ix86_expand_clrstr (operands[0], operands[1], operands[2]))
15894 DONE;
15895 else
15896 FAIL;
0f40f9f7 15897})
e2e52e1b 15898
0945b39d
JH
15899(define_expand "clrstrdi"
15900 [(use (match_operand:BLK 0 "memory_operand" ""))
15901 (use (match_operand:DI 1 "nonmemory_operand" ""))
15902 (use (match_operand 2 "const_int_operand" ""))]
15903 "TARGET_64BIT"
0945b39d
JH
15904{
15905 if (ix86_expand_clrstr (operands[0], operands[1], operands[2]))
15906 DONE;
15907 else
15908 FAIL;
0f40f9f7 15909})
e2e52e1b 15910
0945b39d
JH
15911;; Most CPUs don't like single string operations
15912;; Handle this case here to simplify previous expander.
79f05c19 15913
0945b39d
JH
15914(define_expand "strsetdi_rex64"
15915 [(set (mem:DI (match_operand:DI 0 "register_operand" ""))
15916 (match_operand:DI 1 "register_operand" ""))
15917 (parallel [(set (match_dup 0) (plus:DI (match_dup 0) (const_int 8)))
15918 (clobber (reg:CC 17))])]
15919 "TARGET_64BIT"
0945b39d
JH
15920{
15921 if (TARGET_SINGLE_STRINGOP || optimize_size)
79f05c19 15922 {
0945b39d
JH
15923 emit_insn (gen_strsetdi_rex_1 (operands[0], operands[0], operands[1]));
15924 DONE;
79f05c19 15925 }
0f40f9f7 15926})
e2e52e1b 15927
79f05c19
JH
15928(define_expand "strsetsi"
15929 [(set (mem:SI (match_operand:SI 0 "register_operand" ""))
15930 (match_operand:SI 1 "register_operand" ""))
15931 (parallel [(set (match_dup 0) (plus:SI (match_dup 0) (const_int 4)))
15932 (clobber (reg:CC 17))])]
15933 ""
79f05c19 15934{
0945b39d
JH
15935 if (TARGET_64BIT)
15936 {
15937 emit_insn (gen_strsetsi_rex64 (operands[0], operands[1]));
15938 DONE;
15939 }
15940 else if (TARGET_SINGLE_STRINGOP || optimize_size)
79f05c19
JH
15941 {
15942 emit_insn (gen_strsetsi_1 (operands[0], operands[0], operands[1]));
15943 DONE;
15944 }
0f40f9f7 15945})
79f05c19 15946
0945b39d
JH
15947(define_expand "strsetsi_rex64"
15948 [(set (mem:SI (match_operand:DI 0 "register_operand" ""))
15949 (match_operand:SI 1 "register_operand" ""))
15950 (parallel [(set (match_dup 0) (plus:DI (match_dup 0) (const_int 4)))
15951 (clobber (reg:CC 17))])]
15952 "TARGET_64BIT"
0945b39d
JH
15953{
15954 if (TARGET_SINGLE_STRINGOP || optimize_size)
15955 {
15956 emit_insn (gen_strsetsi_rex_1 (operands[0], operands[0], operands[1]));
15957 DONE;
15958 }
0f40f9f7 15959})
0945b39d 15960
e2e52e1b
JH
15961(define_expand "strsethi"
15962 [(set (mem:HI (match_operand:SI 0 "register_operand" ""))
15963 (match_operand:HI 1 "register_operand" ""))
15964 (parallel [(set (match_dup 0) (plus:SI (match_dup 0) (const_int 2)))
15965 (clobber (reg:CC 17))])]
15966 ""
e2e52e1b 15967{
0945b39d
JH
15968 if (TARGET_64BIT)
15969 {
15970 emit_insn (gen_strsethi_rex64 (operands[0], operands[1]));
15971 DONE;
15972 }
15973 else if (TARGET_SINGLE_STRINGOP || optimize_size)
e2e52e1b
JH
15974 {
15975 emit_insn (gen_strsethi_1 (operands[0], operands[0], operands[1]));
15976 DONE;
15977 }
0f40f9f7 15978})
0ae40045 15979
0945b39d
JH
15980(define_expand "strsethi_rex64"
15981 [(set (mem:HI (match_operand:DI 0 "register_operand" ""))
15982 (match_operand:HI 1 "register_operand" ""))
15983 (parallel [(set (match_dup 0) (plus:DI (match_dup 0) (const_int 2)))
15984 (clobber (reg:CC 17))])]
15985 "TARGET_64BIT"
0945b39d
JH
15986{
15987 if (TARGET_SINGLE_STRINGOP || optimize_size)
15988 {
15989 emit_insn (gen_strsethi_rex_1 (operands[0], operands[0], operands[1]));
15990 DONE;
15991 }
0f40f9f7 15992})
0945b39d 15993
e2e52e1b
JH
15994(define_expand "strsetqi"
15995 [(set (mem:QI (match_operand:SI 0 "register_operand" ""))
15996 (match_operand:QI 1 "register_operand" ""))
15997 (parallel [(set (match_dup 0) (plus:SI (match_dup 0) (const_int 1)))
15998 (clobber (reg:CC 17))])]
15999 ""
e2e52e1b 16000{
0945b39d
JH
16001 if (TARGET_64BIT)
16002 {
16003 emit_insn (gen_strsetqi_rex64 (operands[0], operands[1]));
16004 DONE;
16005 }
16006 else if (TARGET_SINGLE_STRINGOP || optimize_size)
e2e52e1b
JH
16007 {
16008 emit_insn (gen_strsetqi_1 (operands[0], operands[0], operands[1]));
16009 DONE;
16010 }
0f40f9f7 16011})
0ae40045 16012
0945b39d
JH
16013(define_expand "strsetqi_rex64"
16014 [(set (mem:QI (match_operand:DI 0 "register_operand" ""))
16015 (match_operand:QI 1 "register_operand" ""))
16016 (parallel [(set (match_dup 0) (plus:DI (match_dup 0) (const_int 1)))
16017 (clobber (reg:CC 17))])]
16018 "TARGET_64BIT"
0945b39d
JH
16019{
16020 if (TARGET_SINGLE_STRINGOP || optimize_size)
16021 {
16022 emit_insn (gen_strsetqi_rex_1 (operands[0], operands[0], operands[1]));
16023 DONE;
16024 }
0f40f9f7 16025})
0945b39d
JH
16026
16027(define_insn "strsetdi_rex_1"
16028 [(set (mem:SI (match_operand:DI 1 "register_operand" "0"))
16029 (match_operand:SI 2 "register_operand" "a"))
16030 (set (match_operand:DI 0 "register_operand" "=D")
16031 (plus:DI (match_dup 1)
16032 (const_int 8)))
16033 (use (reg:SI 19))]
16034 "TARGET_64BIT && (TARGET_SINGLE_STRINGOP || optimize_size)"
16035 "stosq"
16036 [(set_attr "type" "str")
16037 (set_attr "memory" "store")
16038 (set_attr "mode" "DI")])
16039
79f05c19
JH
16040(define_insn "strsetsi_1"
16041 [(set (mem:SI (match_operand:SI 1 "register_operand" "0"))
16042 (match_operand:SI 2 "register_operand" "a"))
16043 (set (match_operand:SI 0 "register_operand" "=D")
b1cdafbb 16044 (plus:SI (match_dup 1)
79f05c19
JH
16045 (const_int 4)))
16046 (use (reg:SI 19))]
0945b39d 16047 "!TARGET_64BIT && (TARGET_SINGLE_STRINGOP || optimize_size)"
8554d9a4 16048 "{stosl|stosd}"
0945b39d
JH
16049 [(set_attr "type" "str")
16050 (set_attr "memory" "store")
16051 (set_attr "mode" "SI")])
16052
16053(define_insn "strsetsi_rex_1"
16054 [(set (mem:SI (match_operand:DI 1 "register_operand" "0"))
16055 (match_operand:SI 2 "register_operand" "a"))
16056 (set (match_operand:DI 0 "register_operand" "=D")
16057 (plus:DI (match_dup 1)
16058 (const_int 4)))
16059 (use (reg:SI 19))]
16060 "TARGET_64BIT && (TARGET_SINGLE_STRINGOP || optimize_size)"
8554d9a4 16061 "{stosl|stosd}"
79f05c19 16062 [(set_attr "type" "str")
6ef67412
JH
16063 (set_attr "memory" "store")
16064 (set_attr "mode" "SI")])
79f05c19 16065
e2e52e1b
JH
16066(define_insn "strsethi_1"
16067 [(set (mem:HI (match_operand:SI 1 "register_operand" "0"))
16068 (match_operand:HI 2 "register_operand" "a"))
16069 (set (match_operand:SI 0 "register_operand" "=D")
b1cdafbb 16070 (plus:SI (match_dup 1)
e2e52e1b
JH
16071 (const_int 2)))
16072 (use (reg:SI 19))]
0945b39d
JH
16073 "!TARGET_64BIT && (TARGET_SINGLE_STRINGOP || optimize_size)"
16074 "stosw"
16075 [(set_attr "type" "str")
16076 (set_attr "memory" "store")
16077 (set_attr "mode" "HI")])
16078
16079(define_insn "strsethi_rex_1"
16080 [(set (mem:HI (match_operand:DI 1 "register_operand" "0"))
16081 (match_operand:HI 2 "register_operand" "a"))
16082 (set (match_operand:DI 0 "register_operand" "=D")
16083 (plus:DI (match_dup 1)
16084 (const_int 2)))
16085 (use (reg:SI 19))]
16086 "TARGET_64BIT && (TARGET_SINGLE_STRINGOP || optimize_size)"
e2e52e1b
JH
16087 "stosw"
16088 [(set_attr "type" "str")
16089 (set_attr "memory" "store")
6ef67412 16090 (set_attr "mode" "HI")])
e2e52e1b
JH
16091
16092(define_insn "strsetqi_1"
16093 [(set (mem:QI (match_operand:SI 1 "register_operand" "0"))
16094 (match_operand:QI 2 "register_operand" "a"))
16095 (set (match_operand:SI 0 "register_operand" "=D")
b1cdafbb 16096 (plus:SI (match_dup 1)
e2e52e1b
JH
16097 (const_int 1)))
16098 (use (reg:SI 19))]
0945b39d
JH
16099 "!TARGET_64BIT && (TARGET_SINGLE_STRINGOP || optimize_size)"
16100 "stosb"
16101 [(set_attr "type" "str")
16102 (set_attr "memory" "store")
16103 (set_attr "mode" "QI")])
16104
16105(define_insn "strsetqi_rex_1"
16106 [(set (mem:QI (match_operand:DI 1 "register_operand" "0"))
16107 (match_operand:QI 2 "register_operand" "a"))
16108 (set (match_operand:DI 0 "register_operand" "=D")
16109 (plus:DI (match_dup 1)
16110 (const_int 1)))
16111 (use (reg:SI 19))]
16112 "TARGET_64BIT && (TARGET_SINGLE_STRINGOP || optimize_size)"
e2e52e1b
JH
16113 "stosb"
16114 [(set_attr "type" "str")
6ef67412
JH
16115 (set_attr "memory" "store")
16116 (set_attr "mode" "QI")])
e2e52e1b 16117
0945b39d
JH
16118(define_insn "rep_stosdi_rex64"
16119 [(set (match_operand:DI 1 "register_operand" "=c") (const_int 0))
16120 (set (match_operand:DI 0 "register_operand" "=D")
16121 (plus:DI (ashift:DI (match_operand:DI 4 "register_operand" "1")
16122 (const_int 3))
16123 (match_operand:DI 3 "register_operand" "0")))
16124 (set (mem:BLK (match_dup 3))
16125 (const_int 0))
16126 (use (match_operand:DI 2 "register_operand" "a"))
16127 (use (match_dup 4))
16128 (use (reg:SI 19))]
16129 "TARGET_64BIT"
8554d9a4 16130 "{rep\;stosq|rep stosq}"
0945b39d
JH
16131 [(set_attr "type" "str")
16132 (set_attr "prefix_rep" "1")
16133 (set_attr "memory" "store")
16134 (set_attr "mode" "DI")])
16135
e2e52e1b
JH
16136(define_insn "rep_stossi"
16137 [(set (match_operand:SI 1 "register_operand" "=c") (const_int 0))
e2e52e1b 16138 (set (match_operand:SI 0 "register_operand" "=D")
b1cdafbb
JH
16139 (plus:SI (ashift:SI (match_operand:SI 4 "register_operand" "1")
16140 (const_int 2))
16141 (match_operand:SI 3 "register_operand" "0")))
e2e52e1b 16142 (set (mem:BLK (match_dup 3))
0ae40045 16143 (const_int 0))
b1cdafbb
JH
16144 (use (match_operand:SI 2 "register_operand" "a"))
16145 (use (match_dup 4))
e2e52e1b 16146 (use (reg:SI 19))]
0945b39d 16147 "!TARGET_64BIT"
8554d9a4 16148 "{rep\;stosl|rep stosd}"
0945b39d
JH
16149 [(set_attr "type" "str")
16150 (set_attr "prefix_rep" "1")
16151 (set_attr "memory" "store")
16152 (set_attr "mode" "SI")])
16153
16154(define_insn "rep_stossi_rex64"
16155 [(set (match_operand:DI 1 "register_operand" "=c") (const_int 0))
16156 (set (match_operand:DI 0 "register_operand" "=D")
16157 (plus:DI (ashift:DI (match_operand:DI 4 "register_operand" "1")
16158 (const_int 2))
16159 (match_operand:DI 3 "register_operand" "0")))
16160 (set (mem:BLK (match_dup 3))
16161 (const_int 0))
16162 (use (match_operand:SI 2 "register_operand" "a"))
16163 (use (match_dup 4))
16164 (use (reg:SI 19))]
16165 "TARGET_64BIT"
8554d9a4 16166 "{rep\;stosl|rep stosd}"
e2e52e1b 16167 [(set_attr "type" "str")
6ef67412
JH
16168 (set_attr "prefix_rep" "1")
16169 (set_attr "memory" "store")
16170 (set_attr "mode" "SI")])
0ae40045 16171
e2e52e1b
JH
16172(define_insn "rep_stosqi"
16173 [(set (match_operand:SI 1 "register_operand" "=c") (const_int 0))
e2e52e1b 16174 (set (match_operand:SI 0 "register_operand" "=D")
b1cdafbb
JH
16175 (plus:SI (match_operand:SI 3 "register_operand" "0")
16176 (match_operand:SI 4 "register_operand" "1")))
e2e52e1b
JH
16177 (set (mem:BLK (match_dup 3))
16178 (const_int 0))
b1cdafbb
JH
16179 (use (match_operand:QI 2 "register_operand" "a"))
16180 (use (match_dup 4))
e2e52e1b 16181 (use (reg:SI 19))]
0945b39d 16182 "!TARGET_64BIT"
8554d9a4 16183 "{rep\;stosb|rep stosb}"
0945b39d
JH
16184 [(set_attr "type" "str")
16185 (set_attr "prefix_rep" "1")
16186 (set_attr "memory" "store")
16187 (set_attr "mode" "QI")])
16188
16189(define_insn "rep_stosqi_rex64"
16190 [(set (match_operand:DI 1 "register_operand" "=c") (const_int 0))
16191 (set (match_operand:DI 0 "register_operand" "=D")
16192 (plus:DI (match_operand:DI 3 "register_operand" "0")
16193 (match_operand:DI 4 "register_operand" "1")))
16194 (set (mem:BLK (match_dup 3))
16195 (const_int 0))
16196 (use (match_operand:QI 2 "register_operand" "a"))
16197 (use (match_dup 4))
16198 (use (reg:DI 19))]
16199 "TARGET_64BIT"
8554d9a4 16200 "{rep\;stosb|rep stosb}"
e2e52e1b 16201 [(set_attr "type" "str")
6ef67412
JH
16202 (set_attr "prefix_rep" "1")
16203 (set_attr "memory" "store")
16204 (set_attr "mode" "QI")])
0ae40045 16205
886c62d1 16206(define_expand "cmpstrsi"
e075ae69
RH
16207 [(set (match_operand:SI 0 "register_operand" "")
16208 (compare:SI (match_operand:BLK 1 "general_operand" "")
16209 (match_operand:BLK 2 "general_operand" "")))
0945b39d
JH
16210 (use (match_operand 3 "general_operand" ""))
16211 (use (match_operand 4 "immediate_operand" ""))]
886c62d1 16212 ""
886c62d1 16213{
e075ae69
RH
16214 rtx addr1, addr2, out, outlow, count, countreg, align;
16215
d0a5295a
RH
16216 /* Can't use this if the user has appropriated esi or edi. */
16217 if (global_regs[4] || global_regs[5])
16218 FAIL;
16219
e075ae69
RH
16220 out = operands[0];
16221 if (GET_CODE (out) != REG)
16222 out = gen_reg_rtx (SImode);
783cdf65
JVA
16223
16224 addr1 = copy_to_mode_reg (Pmode, XEXP (operands[1], 0));
16225 addr2 = copy_to_mode_reg (Pmode, XEXP (operands[2], 0));
e075ae69
RH
16226
16227 count = operands[3];
d24b3457 16228 countreg = ix86_zero_extend_to_Pmode (count);
e075ae69
RH
16229
16230 /* %%% Iff we are testing strict equality, we can use known alignment
16231 to good advantage. This may be possible with combine, particularly
16232 once cc0 is dead. */
16233 align = operands[4];
783cdf65 16234
7c7ef435 16235 emit_insn (gen_cld ());
e075ae69
RH
16236 if (GET_CODE (count) == CONST_INT)
16237 {
16238 if (INTVAL (count) == 0)
16239 {
16240 emit_move_insn (operands[0], const0_rtx);
16241 DONE;
16242 }
0945b39d
JH
16243 if (TARGET_64BIT)
16244 emit_insn (gen_cmpstrqi_nz_rex_1 (addr1, addr2, countreg, align,
16245 addr1, addr2, countreg));
16246 else
16247 emit_insn (gen_cmpstrqi_nz_1 (addr1, addr2, countreg, align,
16248 addr1, addr2, countreg));
e075ae69
RH
16249 }
16250 else
e2e52e1b 16251 {
0945b39d
JH
16252 if (TARGET_64BIT)
16253 {
16254 emit_insn (gen_cmpdi_1_rex64 (countreg, countreg));
16255 emit_insn (gen_cmpstrqi_rex_1 (addr1, addr2, countreg, align,
16256 addr1, addr2, countreg));
16257 }
16258 else
16259 {
16260 emit_insn (gen_cmpsi_1 (countreg, countreg));
16261 emit_insn (gen_cmpstrqi_1 (addr1, addr2, countreg, align,
16262 addr1, addr2, countreg));
16263 }
e2e52e1b 16264 }
e075ae69
RH
16265
16266 outlow = gen_lowpart (QImode, out);
16267 emit_insn (gen_cmpintqi (outlow));
16268 emit_move_insn (out, gen_rtx_SIGN_EXTEND (SImode, outlow));
783cdf65 16269
e075ae69
RH
16270 if (operands[0] != out)
16271 emit_move_insn (operands[0], out);
783cdf65 16272
e075ae69 16273 DONE;
0f40f9f7 16274})
886c62d1 16275
e075ae69
RH
16276;; Produce a tri-state integer (-1, 0, 1) from condition codes.
16277
16278(define_expand "cmpintqi"
16279 [(set (match_dup 1)
16280 (gtu:QI (reg:CC 17) (const_int 0)))
16281 (set (match_dup 2)
16282 (ltu:QI (reg:CC 17) (const_int 0)))
16283 (parallel [(set (match_operand:QI 0 "register_operand" "")
16284 (minus:QI (match_dup 1)
16285 (match_dup 2)))
16286 (clobber (reg:CC 17))])]
16287 ""
16288 "operands[1] = gen_reg_rtx (QImode);
16289 operands[2] = gen_reg_rtx (QImode);")
16290
f76e3b05
JVA
16291;; memcmp recognizers. The `cmpsb' opcode does nothing if the count is
16292;; zero. Emit extra code to make sure that a zero-length compare is EQ.
56c0e8fa 16293
0945b39d 16294(define_insn "cmpstrqi_nz_1"
e075ae69 16295 [(set (reg:CC 17)
b1cdafbb
JH
16296 (compare:CC (mem:BLK (match_operand:SI 4 "register_operand" "0"))
16297 (mem:BLK (match_operand:SI 5 "register_operand" "1"))))
16298 (use (match_operand:SI 6 "register_operand" "2"))
886c62d1 16299 (use (match_operand:SI 3 "immediate_operand" "i"))
7c7ef435 16300 (use (reg:SI 19))
b1cdafbb
JH
16301 (clobber (match_operand:SI 0 "register_operand" "=S"))
16302 (clobber (match_operand:SI 1 "register_operand" "=D"))
16303 (clobber (match_operand:SI 2 "register_operand" "=c"))]
0945b39d
JH
16304 "!TARGET_64BIT"
16305 "repz{\;| }cmpsb"
16306 [(set_attr "type" "str")
16307 (set_attr "mode" "QI")
16308 (set_attr "prefix_rep" "1")])
16309
16310(define_insn "cmpstrqi_nz_rex_1"
16311 [(set (reg:CC 17)
16312 (compare:CC (mem:BLK (match_operand:DI 4 "register_operand" "0"))
16313 (mem:BLK (match_operand:DI 5 "register_operand" "1"))))
16314 (use (match_operand:DI 6 "register_operand" "2"))
16315 (use (match_operand:SI 3 "immediate_operand" "i"))
16316 (use (reg:SI 19))
16317 (clobber (match_operand:DI 0 "register_operand" "=S"))
16318 (clobber (match_operand:DI 1 "register_operand" "=D"))
16319 (clobber (match_operand:DI 2 "register_operand" "=c"))]
16320 "TARGET_64BIT"
7c7ef435 16321 "repz{\;| }cmpsb"
e2e52e1b 16322 [(set_attr "type" "str")
6ef67412
JH
16323 (set_attr "mode" "QI")
16324 (set_attr "prefix_rep" "1")])
886c62d1 16325
e075ae69 16326;; The same, but the count is not known to not be zero.
886c62d1 16327
0945b39d 16328(define_insn "cmpstrqi_1"
e075ae69 16329 [(set (reg:CC 17)
b1cdafbb 16330 (if_then_else:CC (ne (match_operand:SI 6 "register_operand" "2")
e075ae69 16331 (const_int 0))
2bed3391 16332 (compare:CC (mem:BLK (match_operand:SI 4 "register_operand" "0"))
b1cdafbb 16333 (mem:BLK (match_operand:SI 5 "register_operand" "1")))
e075ae69
RH
16334 (const_int 0)))
16335 (use (match_operand:SI 3 "immediate_operand" "i"))
e2e52e1b 16336 (use (reg:CC 17))
7c7ef435 16337 (use (reg:SI 19))
b1cdafbb
JH
16338 (clobber (match_operand:SI 0 "register_operand" "=S"))
16339 (clobber (match_operand:SI 1 "register_operand" "=D"))
16340 (clobber (match_operand:SI 2 "register_operand" "=c"))]
0945b39d
JH
16341 "!TARGET_64BIT"
16342 "repz{\;| }cmpsb"
16343 [(set_attr "type" "str")
16344 (set_attr "mode" "QI")
16345 (set_attr "prefix_rep" "1")])
16346
16347(define_insn "cmpstrqi_rex_1"
16348 [(set (reg:CC 17)
16349 (if_then_else:CC (ne (match_operand:DI 6 "register_operand" "2")
16350 (const_int 0))
16351 (compare:CC (mem:BLK (match_operand:DI 4 "register_operand" "0"))
16352 (mem:BLK (match_operand:DI 5 "register_operand" "1")))
16353 (const_int 0)))
16354 (use (match_operand:SI 3 "immediate_operand" "i"))
16355 (use (reg:CC 17))
16356 (use (reg:SI 19))
16357 (clobber (match_operand:DI 0 "register_operand" "=S"))
16358 (clobber (match_operand:DI 1 "register_operand" "=D"))
16359 (clobber (match_operand:DI 2 "register_operand" "=c"))]
16360 "TARGET_64BIT"
e2e52e1b
JH
16361 "repz{\;| }cmpsb"
16362 [(set_attr "type" "str")
6ef67412
JH
16363 (set_attr "mode" "QI")
16364 (set_attr "prefix_rep" "1")])
886c62d1 16365
e075ae69
RH
16366(define_expand "strlensi"
16367 [(set (match_operand:SI 0 "register_operand" "")
16368 (unspec:SI [(match_operand:BLK 1 "general_operand" "")
16369 (match_operand:QI 2 "immediate_operand" "")
8ee41eaf 16370 (match_operand 3 "immediate_operand" "")] UNSPEC_SCAS))]
886c62d1 16371 ""
886c62d1 16372{
0945b39d
JH
16373 if (ix86_expand_strlen (operands[0], operands[1], operands[2], operands[3]))
16374 DONE;
16375 else
16376 FAIL;
0f40f9f7 16377})
e075ae69 16378
0945b39d
JH
16379(define_expand "strlendi"
16380 [(set (match_operand:DI 0 "register_operand" "")
16381 (unspec:DI [(match_operand:BLK 1 "general_operand" "")
16382 (match_operand:QI 2 "immediate_operand" "")
8ee41eaf 16383 (match_operand 3 "immediate_operand" "")] UNSPEC_SCAS))]
0945b39d 16384 ""
0945b39d
JH
16385{
16386 if (ix86_expand_strlen (operands[0], operands[1], operands[2], operands[3]))
16387 DONE;
16388 else
16389 FAIL;
0f40f9f7 16390})
19c3fc24 16391
0945b39d 16392(define_insn "strlenqi_1"
e075ae69 16393 [(set (match_operand:SI 0 "register_operand" "=&c")
b1cdafbb 16394 (unspec:SI [(mem:BLK (match_operand:SI 5 "register_operand" "1"))
0945b39d 16395 (match_operand:QI 2 "register_operand" "a")
e075ae69 16396 (match_operand:SI 3 "immediate_operand" "i")
8ee41eaf 16397 (match_operand:SI 4 "register_operand" "0")] UNSPEC_SCAS))
7c7ef435 16398 (use (reg:SI 19))
b1cdafbb 16399 (clobber (match_operand:SI 1 "register_operand" "=D"))
e075ae69 16400 (clobber (reg:CC 17))]
0945b39d
JH
16401 "!TARGET_64BIT"
16402 "repnz{\;| }scasb"
16403 [(set_attr "type" "str")
16404 (set_attr "mode" "QI")
16405 (set_attr "prefix_rep" "1")])
16406
16407(define_insn "strlenqi_rex_1"
16408 [(set (match_operand:DI 0 "register_operand" "=&c")
16409 (unspec:DI [(mem:BLK (match_operand:DI 5 "register_operand" "1"))
16410 (match_operand:QI 2 "register_operand" "a")
16411 (match_operand:DI 3 "immediate_operand" "i")
8ee41eaf 16412 (match_operand:DI 4 "register_operand" "0")] UNSPEC_SCAS))
0945b39d
JH
16413 (use (reg:SI 19))
16414 (clobber (match_operand:DI 1 "register_operand" "=D"))
16415 (clobber (reg:CC 17))]
16416 "TARGET_64BIT"
7c7ef435 16417 "repnz{\;| }scasb"
e2e52e1b 16418 [(set_attr "type" "str")
6ef67412
JH
16419 (set_attr "mode" "QI")
16420 (set_attr "prefix_rep" "1")])
a3e991f2
ZW
16421
16422;; Peephole optimizations to clean up after cmpstr*. This should be
16423;; handled in combine, but it is not currently up to the task.
16424;; When used for their truth value, the cmpstr* expanders generate
16425;; code like this:
16426;;
16427;; repz cmpsb
16428;; seta %al
16429;; setb %dl
16430;; cmpb %al, %dl
16431;; jcc label
16432;;
16433;; The intermediate three instructions are unnecessary.
16434
16435;; This one handles cmpstr*_nz_1...
16436(define_peephole2
16437 [(parallel[
16438 (set (reg:CC 17)
16439 (compare:CC (mem:BLK (match_operand 4 "register_operand" ""))
16440 (mem:BLK (match_operand 5 "register_operand" ""))))
16441 (use (match_operand 6 "register_operand" ""))
16442 (use (match_operand:SI 3 "immediate_operand" ""))
16443 (use (reg:SI 19))
16444 (clobber (match_operand 0 "register_operand" ""))
16445 (clobber (match_operand 1 "register_operand" ""))
16446 (clobber (match_operand 2 "register_operand" ""))])
16447 (set (match_operand:QI 7 "register_operand" "")
16448 (gtu:QI (reg:CC 17) (const_int 0)))
16449 (set (match_operand:QI 8 "register_operand" "")
16450 (ltu:QI (reg:CC 17) (const_int 0)))
16451 (set (reg 17)
16452 (compare (match_dup 7) (match_dup 8)))
16453 ]
244ec848 16454 "peep2_reg_dead_p (4, operands[7]) && peep2_reg_dead_p (4, operands[8])"
a3e991f2
ZW
16455 [(parallel[
16456 (set (reg:CC 17)
16457 (compare:CC (mem:BLK (match_dup 4))
16458 (mem:BLK (match_dup 5))))
16459 (use (match_dup 6))
16460 (use (match_dup 3))
16461 (use (reg:SI 19))
16462 (clobber (match_dup 0))
16463 (clobber (match_dup 1))
244ec848 16464 (clobber (match_dup 2))])]
a3e991f2
ZW
16465 "")
16466
16467;; ...and this one handles cmpstr*_1.
16468(define_peephole2
16469 [(parallel[
16470 (set (reg:CC 17)
16471 (if_then_else:CC (ne (match_operand 6 "register_operand" "")
16472 (const_int 0))
16473 (compare:CC (mem:BLK (match_operand 4 "register_operand" ""))
16474 (mem:BLK (match_operand 5 "register_operand" "")))
16475 (const_int 0)))
16476 (use (match_operand:SI 3 "immediate_operand" ""))
16477 (use (reg:CC 17))
16478 (use (reg:SI 19))
16479 (clobber (match_operand 0 "register_operand" ""))
16480 (clobber (match_operand 1 "register_operand" ""))
16481 (clobber (match_operand 2 "register_operand" ""))])
16482 (set (match_operand:QI 7 "register_operand" "")
16483 (gtu:QI (reg:CC 17) (const_int 0)))
16484 (set (match_operand:QI 8 "register_operand" "")
16485 (ltu:QI (reg:CC 17) (const_int 0)))
16486 (set (reg 17)
16487 (compare (match_dup 7) (match_dup 8)))
16488 ]
244ec848 16489 "peep2_reg_dead_p (4, operands[7]) && peep2_reg_dead_p (4, operands[8])"
a3e991f2
ZW
16490 [(parallel[
16491 (set (reg:CC 17)
16492 (if_then_else:CC (ne (match_dup 6)
16493 (const_int 0))
16494 (compare:CC (mem:BLK (match_dup 4))
16495 (mem:BLK (match_dup 5)))
16496 (const_int 0)))
16497 (use (match_dup 3))
16498 (use (reg:CC 17))
16499 (use (reg:SI 19))
16500 (clobber (match_dup 0))
16501 (clobber (match_dup 1))
244ec848 16502 (clobber (match_dup 2))])]
a3e991f2
ZW
16503 "")
16504
16505
e075ae69
RH
16506\f
16507;; Conditional move instructions.
726e2d54 16508
44cf5b6a 16509(define_expand "movdicc"
885a70fd
JH
16510 [(set (match_operand:DI 0 "register_operand" "")
16511 (if_then_else:DI (match_operand 1 "comparison_operator" "")
44cf5b6a
JH
16512 (match_operand:DI 2 "general_operand" "")
16513 (match_operand:DI 3 "general_operand" "")))]
885a70fd
JH
16514 "TARGET_64BIT"
16515 "if (!ix86_expand_int_movcc (operands)) FAIL; DONE;")
16516
e74061a9 16517(define_insn "x86_movdicc_0_m1_rex64"
885a70fd 16518 [(set (match_operand:DI 0 "register_operand" "=r")
e6e81735 16519 (if_then_else:DI (match_operand 1 "ix86_carry_flag_operator" "")
885a70fd
JH
16520 (const_int -1)
16521 (const_int 0)))
16522 (clobber (reg:CC 17))]
16523 "TARGET_64BIT"
0f40f9f7 16524 "sbb{q}\t%0, %0"
885a70fd
JH
16525 ; Since we don't have the proper number of operands for an alu insn,
16526 ; fill in all the blanks.
16527 [(set_attr "type" "alu")
890d52e8 16528 (set_attr "pent_pair" "pu")
885a70fd
JH
16529 (set_attr "memory" "none")
16530 (set_attr "imm_disp" "false")
16531 (set_attr "mode" "DI")
16532 (set_attr "length_immediate" "0")])
16533
e6e81735 16534(define_insn "movdicc_c_rex64"
885a70fd
JH
16535 [(set (match_operand:DI 0 "register_operand" "=r,r")
16536 (if_then_else:DI (match_operator 1 "ix86_comparison_operator"
16537 [(reg 17) (const_int 0)])
16538 (match_operand:DI 2 "nonimmediate_operand" "rm,0")
16539 (match_operand:DI 3 "nonimmediate_operand" "0,rm")))]
16540 "TARGET_64BIT && TARGET_CMOVE
16541 && (GET_CODE (operands[2]) != MEM || GET_CODE (operands[3]) != MEM)"
16542 "@
048b1c95
JJ
16543 cmov%O2%C1\t{%2, %0|%0, %2}
16544 cmov%O2%c1\t{%3, %0|%0, %3}"
885a70fd
JH
16545 [(set_attr "type" "icmov")
16546 (set_attr "mode" "DI")])
16547
e075ae69 16548(define_expand "movsicc"
6a4a5d95 16549 [(set (match_operand:SI 0 "register_operand" "")
e075ae69
RH
16550 (if_then_else:SI (match_operand 1 "comparison_operator" "")
16551 (match_operand:SI 2 "general_operand" "")
16552 (match_operand:SI 3 "general_operand" "")))]
16553 ""
16554 "if (!ix86_expand_int_movcc (operands)) FAIL; DONE;")
726e2d54 16555
e075ae69
RH
16556;; Data flow gets confused by our desire for `sbbl reg,reg', and clearing
16557;; the register first winds up with `sbbl $0,reg', which is also weird.
16558;; So just document what we're doing explicitly.
16559
16560(define_insn "x86_movsicc_0_m1"
16561 [(set (match_operand:SI 0 "register_operand" "=r")
e6e81735 16562 (if_then_else:SI (match_operand 1 "ix86_carry_flag_operator" "")
e075ae69
RH
16563 (const_int -1)
16564 (const_int 0)))
16565 (clobber (reg:CC 17))]
16566 ""
0f40f9f7 16567 "sbb{l}\t%0, %0"
e075ae69
RH
16568 ; Since we don't have the proper number of operands for an alu insn,
16569 ; fill in all the blanks.
16570 [(set_attr "type" "alu")
890d52e8 16571 (set_attr "pent_pair" "pu")
e075ae69
RH
16572 (set_attr "memory" "none")
16573 (set_attr "imm_disp" "false")
6ef67412
JH
16574 (set_attr "mode" "SI")
16575 (set_attr "length_immediate" "0")])
e075ae69 16576
6343a50e 16577(define_insn "*movsicc_noc"
e075ae69 16578 [(set (match_operand:SI 0 "register_operand" "=r,r")
9076b9c1 16579 (if_then_else:SI (match_operator 1 "ix86_comparison_operator"
e075ae69
RH
16580 [(reg 17) (const_int 0)])
16581 (match_operand:SI 2 "nonimmediate_operand" "rm,0")
16582 (match_operand:SI 3 "nonimmediate_operand" "0,rm")))]
d525dfdf
JH
16583 "TARGET_CMOVE
16584 && (GET_CODE (operands[2]) != MEM || GET_CODE (operands[3]) != MEM)"
e075ae69 16585 "@
048b1c95
JJ
16586 cmov%O2%C1\t{%2, %0|%0, %2}
16587 cmov%O2%c1\t{%3, %0|%0, %3}"
6ef67412
JH
16588 [(set_attr "type" "icmov")
16589 (set_attr "mode" "SI")])
726e2d54 16590
726e2d54
JW
16591(define_expand "movhicc"
16592 [(set (match_operand:HI 0 "register_operand" "")
16593 (if_then_else:HI (match_operand 1 "comparison_operator" "")
4977bab6
ZW
16594 (match_operand:HI 2 "general_operand" "")
16595 (match_operand:HI 3 "general_operand" "")))]
16596 "TARGET_HIMODE_MATH"
e075ae69 16597 "if (!ix86_expand_int_movcc (operands)) FAIL; DONE;")
726e2d54 16598
6343a50e 16599(define_insn "*movhicc_noc"
e075ae69 16600 [(set (match_operand:HI 0 "register_operand" "=r,r")
9076b9c1 16601 (if_then_else:HI (match_operator 1 "ix86_comparison_operator"
e075ae69
RH
16602 [(reg 17) (const_int 0)])
16603 (match_operand:HI 2 "nonimmediate_operand" "rm,0")
16604 (match_operand:HI 3 "nonimmediate_operand" "0,rm")))]
d525dfdf
JH
16605 "TARGET_CMOVE
16606 && (GET_CODE (operands[2]) != MEM || GET_CODE (operands[3]) != MEM)"
e075ae69 16607 "@
048b1c95
JJ
16608 cmov%O2%C1\t{%2, %0|%0, %2}
16609 cmov%O2%c1\t{%3, %0|%0, %3}"
6ef67412
JH
16610 [(set_attr "type" "icmov")
16611 (set_attr "mode" "HI")])
726e2d54 16612
4977bab6
ZW
16613(define_expand "movqicc"
16614 [(set (match_operand:QI 0 "register_operand" "")
16615 (if_then_else:QI (match_operand 1 "comparison_operator" "")
16616 (match_operand:QI 2 "general_operand" "")
16617 (match_operand:QI 3 "general_operand" "")))]
16618 "TARGET_QIMODE_MATH"
16619 "if (!ix86_expand_int_movcc (operands)) FAIL; DONE;")
16620
16621(define_insn_and_split "*movqicc_noc"
16622 [(set (match_operand:QI 0 "register_operand" "=r,r")
16623 (if_then_else:QI (match_operator 1 "ix86_comparison_operator"
16624 [(match_operand 4 "flags_reg_operand" "") (const_int 0)])
16625 (match_operand:QI 2 "register_operand" "r,0")
16626 (match_operand:QI 3 "register_operand" "0,r")))]
16627 "TARGET_CMOVE && !TARGET_PARTIAL_REG_STALL"
16628 "#"
16629 "&& reload_completed"
16630 [(set (match_dup 0)
16631 (if_then_else:SI (match_op_dup 1 [(match_dup 4) (const_int 0)])
16632 (match_dup 2)
16633 (match_dup 3)))]
16634 "operands[0] = gen_lowpart (SImode, operands[0]);
16635 operands[2] = gen_lowpart (SImode, operands[2]);
16636 operands[3] = gen_lowpart (SImode, operands[3]);"
16637 [(set_attr "type" "icmov")
16638 (set_attr "mode" "SI")])
16639
56710e42 16640(define_expand "movsfcc"
726e2d54 16641 [(set (match_operand:SF 0 "register_operand" "")
56710e42 16642 (if_then_else:SF (match_operand 1 "comparison_operator" "")
e5e809f4
JL
16643 (match_operand:SF 2 "register_operand" "")
16644 (match_operand:SF 3 "register_operand" "")))]
726e2d54 16645 "TARGET_CMOVE"
e075ae69 16646 "if (! ix86_expand_fp_movcc (operands)) FAIL; DONE;")
726e2d54 16647
6343a50e 16648(define_insn "*movsfcc_1"
7093c9ea 16649 [(set (match_operand:SF 0 "register_operand" "=f,f,r,r")
e075ae69
RH
16650 (if_then_else:SF (match_operator 1 "fcmov_comparison_operator"
16651 [(reg 17) (const_int 0)])
7093c9ea
JH
16652 (match_operand:SF 2 "nonimmediate_operand" "f,0,rm,0")
16653 (match_operand:SF 3 "nonimmediate_operand" "0,f,0,rm")))]
16654 "TARGET_CMOVE
16655 && (GET_CODE (operands[2]) != MEM || GET_CODE (operands[3]) != MEM)"
e075ae69 16656 "@
0f40f9f7
ZW
16657 fcmov%F1\t{%2, %0|%0, %2}
16658 fcmov%f1\t{%3, %0|%0, %3}
048b1c95
JJ
16659 cmov%O2%C1\t{%2, %0|%0, %2}
16660 cmov%O2%c1\t{%3, %0|%0, %3}"
7093c9ea
JH
16661 [(set_attr "type" "fcmov,fcmov,icmov,icmov")
16662 (set_attr "mode" "SF,SF,SI,SI")])
56710e42
SC
16663
16664(define_expand "movdfcc"
726e2d54 16665 [(set (match_operand:DF 0 "register_operand" "")
56710e42 16666 (if_then_else:DF (match_operand 1 "comparison_operator" "")
e5e809f4
JL
16667 (match_operand:DF 2 "register_operand" "")
16668 (match_operand:DF 3 "register_operand" "")))]
726e2d54 16669 "TARGET_CMOVE"
e075ae69 16670 "if (! ix86_expand_fp_movcc (operands)) FAIL; DONE;")
726e2d54 16671
6343a50e 16672(define_insn "*movdfcc_1"
7093c9ea 16673 [(set (match_operand:DF 0 "register_operand" "=f,f,&r,&r")
e075ae69
RH
16674 (if_then_else:DF (match_operator 1 "fcmov_comparison_operator"
16675 [(reg 17) (const_int 0)])
7093c9ea
JH
16676 (match_operand:DF 2 "nonimmediate_operand" "f,0,rm,0")
16677 (match_operand:DF 3 "nonimmediate_operand" "0,f,0,rm")))]
1b0c37d7 16678 "!TARGET_64BIT && TARGET_CMOVE
7093c9ea 16679 && (GET_CODE (operands[2]) != MEM || GET_CODE (operands[3]) != MEM)"
e075ae69 16680 "@
0f40f9f7
ZW
16681 fcmov%F1\t{%2, %0|%0, %2}
16682 fcmov%f1\t{%3, %0|%0, %3}
7093c9ea
JH
16683 #
16684 #"
16685 [(set_attr "type" "fcmov,fcmov,multi,multi")
6ef67412 16686 (set_attr "mode" "DF")])
56710e42 16687
1e07edd3
JH
16688(define_insn "*movdfcc_1_rex64"
16689 [(set (match_operand:DF 0 "register_operand" "=f,f,&r,&r")
16690 (if_then_else:DF (match_operator 1 "fcmov_comparison_operator"
16691 [(reg 17) (const_int 0)])
16692 (match_operand:DF 2 "nonimmediate_operand" "f,0,rm,0")
16693 (match_operand:DF 3 "nonimmediate_operand" "0,f,0,rm")))]
1b0c37d7 16694 "TARGET_64BIT && TARGET_CMOVE
1e07edd3
JH
16695 && (GET_CODE (operands[2]) != MEM || GET_CODE (operands[3]) != MEM)"
16696 "@
0f40f9f7
ZW
16697 fcmov%F1\t{%2, %0|%0, %2}
16698 fcmov%f1\t{%3, %0|%0, %3}
048b1c95
JJ
16699 cmov%O2%C1\t{%2, %0|%0, %2}
16700 cmov%O2%c1\t{%3, %0|%0, %3}"
1e07edd3
JH
16701 [(set_attr "type" "fcmov,fcmov,icmov,icmov")
16702 (set_attr "mode" "DF")])
16703
7093c9ea 16704(define_split
c3c637e3 16705 [(set (match_operand:DF 0 "register_and_not_any_fp_reg_operand" "")
7093c9ea 16706 (if_then_else:DF (match_operator 1 "fcmov_comparison_operator"
4977bab6 16707 [(match_operand 4 "flags_reg_operand" "") (const_int 0)])
7093c9ea
JH
16708 (match_operand:DF 2 "nonimmediate_operand" "")
16709 (match_operand:DF 3 "nonimmediate_operand" "")))]
c3c637e3 16710 "!TARGET_64BIT && reload_completed"
7093c9ea
JH
16711 [(set (match_dup 2)
16712 (if_then_else:SI (match_op_dup 1 [(match_dup 4) (const_int 0)])
16713 (match_dup 5)
16714 (match_dup 7)))
16715 (set (match_dup 3)
16716 (if_then_else:SI (match_op_dup 1 [(match_dup 4) (const_int 0)])
16717 (match_dup 6)
16718 (match_dup 8)))]
16719 "split_di (operands+2, 1, operands+5, operands+6);
16720 split_di (operands+3, 1, operands+7, operands+8);
16721 split_di (operands, 1, operands+2, operands+3);")
16722
56710e42 16723(define_expand "movxfcc"
726e2d54 16724 [(set (match_operand:XF 0 "register_operand" "")
56710e42 16725 (if_then_else:XF (match_operand 1 "comparison_operator" "")
e5e809f4
JL
16726 (match_operand:XF 2 "register_operand" "")
16727 (match_operand:XF 3 "register_operand" "")))]
1b0c37d7 16728 "!TARGET_64BIT && TARGET_CMOVE"
e075ae69 16729 "if (! ix86_expand_fp_movcc (operands)) FAIL; DONE;")
726e2d54 16730
2b589241
JH
16731(define_expand "movtfcc"
16732 [(set (match_operand:TF 0 "register_operand" "")
16733 (if_then_else:TF (match_operand 1 "comparison_operator" "")
16734 (match_operand:TF 2 "register_operand" "")
16735 (match_operand:TF 3 "register_operand" "")))]
16736 "TARGET_CMOVE"
16737 "if (! ix86_expand_fp_movcc (operands)) FAIL; DONE;")
16738
6343a50e 16739(define_insn "*movxfcc_1"
3aeae608 16740 [(set (match_operand:XF 0 "register_operand" "=f,f")
e075ae69
RH
16741 (if_then_else:XF (match_operator 1 "fcmov_comparison_operator"
16742 [(reg 17) (const_int 0)])
3aeae608
JW
16743 (match_operand:XF 2 "register_operand" "f,0")
16744 (match_operand:XF 3 "register_operand" "0,f")))]
1b0c37d7 16745 "!TARGET_64BIT && TARGET_CMOVE"
e075ae69 16746 "@
0f40f9f7
ZW
16747 fcmov%F1\t{%2, %0|%0, %2}
16748 fcmov%f1\t{%3, %0|%0, %3}"
6ef67412
JH
16749 [(set_attr "type" "fcmov")
16750 (set_attr "mode" "XF")])
2b589241
JH
16751
16752(define_insn "*movtfcc_1"
16753 [(set (match_operand:TF 0 "register_operand" "=f,f")
16754 (if_then_else:TF (match_operator 1 "fcmov_comparison_operator"
16755 [(reg 17) (const_int 0)])
16756 (match_operand:TF 2 "register_operand" "f,0")
16757 (match_operand:TF 3 "register_operand" "0,f")))]
16758 "TARGET_CMOVE"
16759 "@
0f40f9f7
ZW
16760 fcmov%F1\t{%2, %0|%0, %2}
16761 fcmov%f1\t{%3, %0|%0, %3}"
2b589241
JH
16762 [(set_attr "type" "fcmov")
16763 (set_attr "mode" "XF")])
7ada6625
JH
16764
16765(define_expand "minsf3"
16766 [(parallel [
16767 (set (match_operand:SF 0 "register_operand" "")
16768 (if_then_else:SF (lt (match_operand:SF 1 "register_operand" "")
16769 (match_operand:SF 2 "nonimmediate_operand" ""))
16770 (match_dup 1)
16771 (match_dup 2)))
16772 (clobber (reg:CC 17))])]
16773 "TARGET_SSE"
16774 "")
16775
16776(define_insn "*minsf"
16777 [(set (match_operand:SF 0 "register_operand" "=x#f,f#x,f#x")
16778 (if_then_else:SF (lt (match_operand:SF 1 "register_operand" "0,0,f#x")
16779 (match_operand:SF 2 "nonimmediate_operand" "xm#f,f#x,0"))
16780 (match_dup 1)
16781 (match_dup 2)))
16782 (clobber (reg:CC 17))]
16783 "TARGET_SSE && TARGET_IEEE_FP"
16784 "#")
16785
16786(define_insn "*minsf_nonieee"
16787 [(set (match_operand:SF 0 "register_operand" "=x#f,f#x")
558740bf 16788 (if_then_else:SF (lt (match_operand:SF 1 "nonimmediate_operand" "%0,0")
3987b9db 16789 (match_operand:SF 2 "nonimmediate_operand" "xm#f,f#x"))
7ada6625
JH
16790 (match_dup 1)
16791 (match_dup 2)))
16792 (clobber (reg:CC 17))]
558740bf
JH
16793 "TARGET_SSE && !TARGET_IEEE_FP
16794 && (GET_CODE (operands[1]) != MEM || GET_CODE (operands[2]) != MEM)"
7ada6625
JH
16795 "#")
16796
16797(define_split
16798 [(set (match_operand:SF 0 "register_operand" "")
16799 (if_then_else:SF (lt (match_operand:SF 1 "register_operand" "")
16800 (match_operand:SF 2 "nonimmediate_operand" ""))
138b7342
JH
16801 (match_operand:SF 3 "register_operand" "")
16802 (match_operand:SF 4 "nonimmediate_operand" "")))
ef6257cd
JH
16803 (clobber (reg:CC 17))]
16804 "SSE_REG_P (operands[0]) && reload_completed
16805 && ((operands_match_p (operands[1], operands[3])
16806 && operands_match_p (operands[2], operands[4]))
16807 || (operands_match_p (operands[1], operands[4])
16808 && operands_match_p (operands[2], operands[3])))"
7ada6625
JH
16809 [(set (match_dup 0)
16810 (if_then_else:SF (lt (match_dup 1)
16811 (match_dup 2))
16812 (match_dup 1)
16813 (match_dup 2)))])
16814
7b52eede
JH
16815;; Conditional addition patterns
16816(define_expand "addqicc"
16817 [(match_operand:QI 0 "register_operand" "")
16818 (match_operand 1 "comparison_operator" "")
16819 (match_operand:QI 2 "register_operand" "")
16820 (match_operand:QI 3 "const_int_operand" "")]
16821 ""
16822 "if (!ix86_expand_int_addcc (operands)) FAIL; DONE;")
16823
16824(define_expand "addhicc"
16825 [(match_operand:HI 0 "register_operand" "")
16826 (match_operand 1 "comparison_operator" "")
16827 (match_operand:HI 2 "register_operand" "")
16828 (match_operand:HI 3 "const_int_operand" "")]
16829 ""
16830 "if (!ix86_expand_int_addcc (operands)) FAIL; DONE;")
16831
16832(define_expand "addsicc"
16833 [(match_operand:SI 0 "register_operand" "")
16834 (match_operand 1 "comparison_operator" "")
16835 (match_operand:SI 2 "register_operand" "")
16836 (match_operand:SI 3 "const_int_operand" "")]
16837 ""
16838 "if (!ix86_expand_int_addcc (operands)) FAIL; DONE;")
16839
16840(define_expand "adddicc"
16841 [(match_operand:DI 0 "register_operand" "")
16842 (match_operand 1 "comparison_operator" "")
16843 (match_operand:DI 2 "register_operand" "")
16844 (match_operand:DI 3 "const_int_operand" "")]
16845 "TARGET_64BIT"
16846 "if (!ix86_expand_int_addcc (operands)) FAIL; DONE;")
16847
7ada6625 16848;; We can't represent the LT test directly. Do this by swapping the operands.
ef6257cd 16849
7ada6625 16850(define_split
c3c637e3 16851 [(set (match_operand:SF 0 "fp_register_operand" "")
7ada6625
JH
16852 (if_then_else:SF (lt (match_operand:SF 1 "register_operand" "")
16853 (match_operand:SF 2 "register_operand" ""))
14d920c0
JH
16854 (match_operand:SF 3 "register_operand" "")
16855 (match_operand:SF 4 "register_operand" "")))
ef6257cd 16856 (clobber (reg:CC 17))]
c3c637e3 16857 "reload_completed
ef6257cd
JH
16858 && ((operands_match_p (operands[1], operands[3])
16859 && operands_match_p (operands[2], operands[4]))
16860 || (operands_match_p (operands[1], operands[4])
16861 && operands_match_p (operands[2], operands[3])))"
7ada6625
JH
16862 [(set (reg:CCFP 17)
16863 (compare:CCFP (match_dup 2)
16864 (match_dup 1)))
16865 (set (match_dup 0)
16866 (if_then_else:SF (ge (reg:CCFP 17) (const_int 0))
16867 (match_dup 1)
16868 (match_dup 2)))])
16869
16870(define_insn "*minsf_sse"
16871 [(set (match_operand:SF 0 "register_operand" "=x")
16872 (if_then_else:SF (lt (match_operand:SF 1 "register_operand" "0")
16873 (match_operand:SF 2 "nonimmediate_operand" "xm"))
16874 (match_dup 1)
16875 (match_dup 2)))]
16876 "TARGET_SSE && reload_completed"
0f40f9f7 16877 "minss\t{%2, %0|%0, %2}"
7ada6625
JH
16878 [(set_attr "type" "sse")
16879 (set_attr "mode" "SF")])
16880
16881(define_expand "mindf3"
16882 [(parallel [
16883 (set (match_operand:DF 0 "register_operand" "")
16884 (if_then_else:DF (lt (match_operand:DF 1 "register_operand" "")
16885 (match_operand:DF 2 "nonimmediate_operand" ""))
16886 (match_dup 1)
16887 (match_dup 2)))
16888 (clobber (reg:CC 17))])]
965f5423 16889 "TARGET_SSE2 && TARGET_SSE_MATH"
7ada6625
JH
16890 "#")
16891
16892(define_insn "*mindf"
16893 [(set (match_operand:DF 0 "register_operand" "=Y#f,f#Y,f#Y")
16894 (if_then_else:DF (lt (match_operand:DF 1 "register_operand" "0,0,f#Y")
16895 (match_operand:DF 2 "nonimmediate_operand" "Ym#f,f#Y,0"))
16896 (match_dup 1)
16897 (match_dup 2)))
16898 (clobber (reg:CC 17))]
965f5423 16899 "TARGET_SSE2 && TARGET_IEEE_FP && TARGET_SSE_MATH"
7ada6625
JH
16900 "#")
16901
16902(define_insn "*mindf_nonieee"
16903 [(set (match_operand:DF 0 "register_operand" "=Y#f,f#Y")
558740bf 16904 (if_then_else:DF (lt (match_operand:DF 1 "nonimmediate_operand" "%0,0")
3987b9db 16905 (match_operand:DF 2 "nonimmediate_operand" "Ym#f,f#Y"))
7ada6625
JH
16906 (match_dup 1)
16907 (match_dup 2)))
16908 (clobber (reg:CC 17))]
558740bf
JH
16909 "TARGET_SSE2 && TARGET_SSE_MATH && !TARGET_IEEE_FP
16910 && (GET_CODE (operands[1]) != MEM || GET_CODE (operands[2]) != MEM)"
7ada6625
JH
16911 "#")
16912
16913(define_split
16914 [(set (match_operand:DF 0 "register_operand" "")
16915 (if_then_else:DF (lt (match_operand:DF 1 "register_operand" "")
16916 (match_operand:DF 2 "nonimmediate_operand" ""))
ef6257cd
JH
16917 (match_operand:DF 3 "register_operand" "")
16918 (match_operand:DF 4 "nonimmediate_operand" "")))
16919 (clobber (reg:CC 17))]
16920 "SSE_REG_P (operands[0]) && reload_completed
16921 && ((operands_match_p (operands[1], operands[3])
16922 && operands_match_p (operands[2], operands[4]))
16923 || (operands_match_p (operands[1], operands[4])
16924 && operands_match_p (operands[2], operands[3])))"
7ada6625
JH
16925 [(set (match_dup 0)
16926 (if_then_else:DF (lt (match_dup 1)
16927 (match_dup 2))
16928 (match_dup 1)
16929 (match_dup 2)))])
16930
16931;; We can't represent the LT test directly. Do this by swapping the operands.
16932(define_split
c3c637e3 16933 [(set (match_operand:DF 0 "fp_register_operand" "")
7ada6625
JH
16934 (if_then_else:DF (lt (match_operand:DF 1 "register_operand" "")
16935 (match_operand:DF 2 "register_operand" ""))
ef6257cd
JH
16936 (match_operand:DF 3 "register_operand" "")
16937 (match_operand:DF 4 "register_operand" "")))
16938 (clobber (reg:CC 17))]
c3c637e3 16939 "reload_completed
ef6257cd
JH
16940 && ((operands_match_p (operands[1], operands[3])
16941 && operands_match_p (operands[2], operands[4]))
16942 || (operands_match_p (operands[1], operands[4])
16943 && operands_match_p (operands[2], operands[3])))"
7ada6625
JH
16944 [(set (reg:CCFP 17)
16945 (compare:CCFP (match_dup 2)
16946 (match_dup 2)))
16947 (set (match_dup 0)
16948 (if_then_else:DF (ge (reg:CCFP 17) (const_int 0))
16949 (match_dup 1)
16950 (match_dup 2)))])
16951
16952(define_insn "*mindf_sse"
16953 [(set (match_operand:DF 0 "register_operand" "=Y")
16954 (if_then_else:DF (lt (match_operand:DF 1 "register_operand" "0")
16955 (match_operand:DF 2 "nonimmediate_operand" "Ym"))
16956 (match_dup 1)
16957 (match_dup 2)))]
965f5423 16958 "TARGET_SSE2 && TARGET_SSE_MATH && reload_completed"
0f40f9f7 16959 "minsd\t{%2, %0|%0, %2}"
7ada6625
JH
16960 [(set_attr "type" "sse")
16961 (set_attr "mode" "DF")])
16962
16963(define_expand "maxsf3"
16964 [(parallel [
16965 (set (match_operand:SF 0 "register_operand" "")
16966 (if_then_else:SF (gt (match_operand:SF 1 "register_operand" "")
16967 (match_operand:SF 2 "nonimmediate_operand" ""))
16968 (match_dup 1)
16969 (match_dup 2)))
16970 (clobber (reg:CC 17))])]
16971 "TARGET_SSE"
16972 "#")
16973
16974(define_insn "*maxsf"
16975 [(set (match_operand:SF 0 "register_operand" "=x#f,f#x,f#x")
16976 (if_then_else:SF (gt (match_operand:SF 1 "register_operand" "0,0,f#x")
3987b9db 16977 (match_operand:SF 2 "nonimmediate_operand" "xm#f,f#x,0"))
7ada6625
JH
16978 (match_dup 1)
16979 (match_dup 2)))
16980 (clobber (reg:CC 17))]
16981 "TARGET_SSE && TARGET_IEEE_FP"
16982 "#")
16983
16984(define_insn "*maxsf_nonieee"
16985 [(set (match_operand:SF 0 "register_operand" "=x#f,f#x")
558740bf 16986 (if_then_else:SF (gt (match_operand:SF 1 "nonimmediate_operand" "%0,0")
3987b9db 16987 (match_operand:SF 2 "nonimmediate_operand" "xm#f,f#x"))
7ada6625
JH
16988 (match_dup 1)
16989 (match_dup 2)))
16990 (clobber (reg:CC 17))]
558740bf
JH
16991 "TARGET_SSE && !TARGET_IEEE_FP
16992 && (GET_CODE (operands[1]) != MEM || GET_CODE (operands[2]) != MEM)"
7ada6625
JH
16993 "#")
16994
16995(define_split
16996 [(set (match_operand:SF 0 "register_operand" "")
16997 (if_then_else:SF (gt (match_operand:SF 1 "register_operand" "")
16998 (match_operand:SF 2 "nonimmediate_operand" ""))
ef6257cd
JH
16999 (match_operand:SF 3 "register_operand" "")
17000 (match_operand:SF 4 "nonimmediate_operand" "")))
17001 (clobber (reg:CC 17))]
17002 "SSE_REG_P (operands[0]) && reload_completed
17003 && ((operands_match_p (operands[1], operands[3])
17004 && operands_match_p (operands[2], operands[4]))
17005 || (operands_match_p (operands[1], operands[4])
17006 && operands_match_p (operands[2], operands[3])))"
7ada6625
JH
17007 [(set (match_dup 0)
17008 (if_then_else:SF (gt (match_dup 1)
17009 (match_dup 2))
17010 (match_dup 1)
17011 (match_dup 2)))])
17012
17013(define_split
c3c637e3 17014 [(set (match_operand:SF 0 "fp_register_operand" "")
7ada6625
JH
17015 (if_then_else:SF (gt (match_operand:SF 1 "register_operand" "")
17016 (match_operand:SF 2 "register_operand" ""))
ef6257cd
JH
17017 (match_operand:SF 3 "register_operand" "")
17018 (match_operand:SF 4 "register_operand" "")))
17019 (clobber (reg:CC 17))]
c3c637e3 17020 "reload_completed
ef6257cd
JH
17021 && ((operands_match_p (operands[1], operands[3])
17022 && operands_match_p (operands[2], operands[4]))
17023 || (operands_match_p (operands[1], operands[4])
17024 && operands_match_p (operands[2], operands[3])))"
7ada6625
JH
17025 [(set (reg:CCFP 17)
17026 (compare:CCFP (match_dup 1)
17027 (match_dup 2)))
17028 (set (match_dup 0)
17029 (if_then_else:SF (gt (reg:CCFP 17) (const_int 0))
17030 (match_dup 1)
17031 (match_dup 2)))])
17032
17033(define_insn "*maxsf_sse"
17034 [(set (match_operand:SF 0 "register_operand" "=x")
17035 (if_then_else:SF (gt (match_operand:SF 1 "register_operand" "0")
17036 (match_operand:SF 2 "nonimmediate_operand" "xm"))
17037 (match_dup 1)
17038 (match_dup 2)))]
17039 "TARGET_SSE && reload_completed"
0f40f9f7 17040 "maxss\t{%2, %0|%0, %2}"
7ada6625
JH
17041 [(set_attr "type" "sse")
17042 (set_attr "mode" "SF")])
17043
17044(define_expand "maxdf3"
17045 [(parallel [
17046 (set (match_operand:DF 0 "register_operand" "")
17047 (if_then_else:DF (gt (match_operand:DF 1 "register_operand" "")
17048 (match_operand:DF 2 "nonimmediate_operand" ""))
17049 (match_dup 1)
17050 (match_dup 2)))
17051 (clobber (reg:CC 17))])]
965f5423 17052 "TARGET_SSE2 && TARGET_SSE_MATH"
7ada6625
JH
17053 "#")
17054
17055(define_insn "*maxdf"
17056 [(set (match_operand:DF 0 "register_operand" "=Y#f,f#Y,f#Y")
17057 (if_then_else:DF (gt (match_operand:DF 1 "register_operand" "0,0,f#Y")
3987b9db 17058 (match_operand:DF 2 "nonimmediate_operand" "Ym#f,f#Y,0"))
7ada6625
JH
17059 (match_dup 1)
17060 (match_dup 2)))
17061 (clobber (reg:CC 17))]
965f5423 17062 "TARGET_SSE2 && TARGET_SSE_MATH && TARGET_IEEE_FP"
7ada6625
JH
17063 "#")
17064
17065(define_insn "*maxdf_nonieee"
17066 [(set (match_operand:DF 0 "register_operand" "=Y#f,f#Y")
558740bf 17067 (if_then_else:DF (gt (match_operand:DF 1 "nonimmediate_operand" "%0,0")
3987b9db 17068 (match_operand:DF 2 "nonimmediate_operand" "Ym#f,f#Y"))
7ada6625
JH
17069 (match_dup 1)
17070 (match_dup 2)))
17071 (clobber (reg:CC 17))]
558740bf
JH
17072 "TARGET_SSE2 && TARGET_SSE_MATH && !TARGET_IEEE_FP
17073 && (GET_CODE (operands[1]) != MEM || GET_CODE (operands[2]) != MEM)"
7ada6625
JH
17074 "#")
17075
17076(define_split
17077 [(set (match_operand:DF 0 "register_operand" "")
17078 (if_then_else:DF (gt (match_operand:DF 1 "register_operand" "")
17079 (match_operand:DF 2 "nonimmediate_operand" ""))
ef6257cd
JH
17080 (match_operand:DF 3 "register_operand" "")
17081 (match_operand:DF 4 "nonimmediate_operand" "")))
17082 (clobber (reg:CC 17))]
17083 "SSE_REG_P (operands[0]) && reload_completed
17084 && ((operands_match_p (operands[1], operands[3])
17085 && operands_match_p (operands[2], operands[4]))
17086 || (operands_match_p (operands[1], operands[4])
17087 && operands_match_p (operands[2], operands[3])))"
7ada6625
JH
17088 [(set (match_dup 0)
17089 (if_then_else:DF (gt (match_dup 1)
17090 (match_dup 2))
17091 (match_dup 1)
17092 (match_dup 2)))])
17093
17094(define_split
c3c637e3 17095 [(set (match_operand:DF 0 "fp_register_operand" "")
7ada6625
JH
17096 (if_then_else:DF (gt (match_operand:DF 1 "register_operand" "")
17097 (match_operand:DF 2 "register_operand" ""))
ef6257cd
JH
17098 (match_operand:DF 3 "register_operand" "")
17099 (match_operand:DF 4 "register_operand" "")))
17100 (clobber (reg:CC 17))]
c3c637e3 17101 "reload_completed
ef6257cd
JH
17102 && ((operands_match_p (operands[1], operands[3])
17103 && operands_match_p (operands[2], operands[4]))
17104 || (operands_match_p (operands[1], operands[4])
17105 && operands_match_p (operands[2], operands[3])))"
7ada6625
JH
17106 [(set (reg:CCFP 17)
17107 (compare:CCFP (match_dup 1)
17108 (match_dup 2)))
17109 (set (match_dup 0)
17110 (if_then_else:DF (gt (reg:CCFP 17) (const_int 0))
17111 (match_dup 1)
17112 (match_dup 2)))])
17113
17114(define_insn "*maxdf_sse"
17115 [(set (match_operand:DF 0 "register_operand" "=Y")
17116 (if_then_else:DF (gt (match_operand:DF 1 "register_operand" "0")
17117 (match_operand:DF 2 "nonimmediate_operand" "Ym"))
17118 (match_dup 1)
17119 (match_dup 2)))]
965f5423 17120 "TARGET_SSE2 && TARGET_SSE_MATH && reload_completed"
0f40f9f7 17121 "maxsd\t{%2, %0|%0, %2}"
7ada6625
JH
17122 [(set_attr "type" "sse")
17123 (set_attr "mode" "DF")])
e075ae69
RH
17124\f
17125;; Misc patterns (?)
726e2d54 17126
f5143c46 17127;; This pattern exists to put a dependency on all ebp-based memory accesses.
e075ae69
RH
17128;; Otherwise there will be nothing to keep
17129;;
17130;; [(set (reg ebp) (reg esp))]
17131;; [(set (reg esp) (plus (reg esp) (const_int -160000)))
17132;; (clobber (eflags)]
17133;; [(set (mem (plus (reg ebp) (const_int -160000))) (const_int 0))]
17134;;
17135;; in proper program order.
8362f420
JH
17136(define_expand "pro_epilogue_adjust_stack"
17137 [(parallel [(set (match_operand:SI 0 "register_operand" "=r,r")
17138 (plus:SI (match_operand:SI 1 "register_operand" "0,r")
17139 (match_operand:SI 2 "immediate_operand" "i,i")))
f2042df3
RH
17140 (clobber (reg:CC 17))
17141 (clobber (mem:BLK (scratch)))])]
8362f420 17142 ""
8362f420
JH
17143{
17144 if (TARGET_64BIT)
17145 {
f2042df3
RH
17146 emit_insn (gen_pro_epilogue_adjust_stack_rex64
17147 (operands[0], operands[1], operands[2]));
8362f420
JH
17148 DONE;
17149 }
0f40f9f7 17150})
726e2d54 17151
8362f420 17152(define_insn "*pro_epilogue_adjust_stack_1"
1c71e60e
JH
17153 [(set (match_operand:SI 0 "register_operand" "=r,r")
17154 (plus:SI (match_operand:SI 1 "register_operand" "0,r")
17155 (match_operand:SI 2 "immediate_operand" "i,i")))
f2042df3
RH
17156 (clobber (reg:CC 17))
17157 (clobber (mem:BLK (scratch)))]
8362f420 17158 "!TARGET_64BIT"
e075ae69 17159{
1c71e60e 17160 switch (get_attr_type (insn))
e075ae69 17161 {
1c71e60e 17162 case TYPE_IMOV:
0f40f9f7 17163 return "mov{l}\t{%1, %0|%0, %1}";
1c71e60e
JH
17164
17165 case TYPE_ALU:
17166 if (GET_CODE (operands[2]) == CONST_INT
17167 && (INTVAL (operands[2]) == 128
17168 || (INTVAL (operands[2]) < 0
17169 && INTVAL (operands[2]) != -128)))
17170 {
17171 operands[2] = GEN_INT (-INTVAL (operands[2]));
0f40f9f7 17172 return "sub{l}\t{%2, %0|%0, %2}";
1c71e60e 17173 }
0f40f9f7 17174 return "add{l}\t{%2, %0|%0, %2}";
1c71e60e
JH
17175
17176 case TYPE_LEA:
17177 operands[2] = SET_SRC (XVECEXP (PATTERN (insn), 0, 0));
0f40f9f7 17178 return "lea{l}\t{%a2, %0|%0, %a2}";
1c71e60e
JH
17179
17180 default:
17181 abort ();
e075ae69 17182 }
0f40f9f7 17183}
1c71e60e
JH
17184 [(set (attr "type")
17185 (cond [(eq_attr "alternative" "0")
17186 (const_string "alu")
17187 (match_operand:SI 2 "const0_operand" "")
17188 (const_string "imov")
17189 ]
6ef67412
JH
17190 (const_string "lea")))
17191 (set_attr "mode" "SI")])
578b58f5 17192
8362f420
JH
17193(define_insn "pro_epilogue_adjust_stack_rex64"
17194 [(set (match_operand:DI 0 "register_operand" "=r,r")
17195 (plus:DI (match_operand:DI 1 "register_operand" "0,r")
17196 (match_operand:DI 2 "x86_64_immediate_operand" "e,e")))
f2042df3
RH
17197 (clobber (reg:CC 17))
17198 (clobber (mem:BLK (scratch)))]
8362f420 17199 "TARGET_64BIT"
8362f420
JH
17200{
17201 switch (get_attr_type (insn))
17202 {
17203 case TYPE_IMOV:
0f40f9f7 17204 return "mov{q}\t{%1, %0|%0, %1}";
8362f420
JH
17205
17206 case TYPE_ALU:
17207 if (GET_CODE (operands[2]) == CONST_INT
17208 && (INTVAL (operands[2]) == 128
17209 || (INTVAL (operands[2]) < 0
17210 && INTVAL (operands[2]) != -128)))
17211 {
17212 operands[2] = GEN_INT (-INTVAL (operands[2]));
0f40f9f7 17213 return "sub{q}\t{%2, %0|%0, %2}";
8362f420 17214 }
0f40f9f7 17215 return "add{q}\t{%2, %0|%0, %2}";
8362f420
JH
17216
17217 case TYPE_LEA:
17218 operands[2] = SET_SRC (XVECEXP (PATTERN (insn), 0, 0));
0f40f9f7 17219 return "lea{q}\t{%a2, %0|%0, %a2}";
8362f420
JH
17220
17221 default:
17222 abort ();
17223 }
0f40f9f7 17224}
8362f420
JH
17225 [(set (attr "type")
17226 (cond [(eq_attr "alternative" "0")
17227 (const_string "alu")
17228 (match_operand:DI 2 "const0_operand" "")
17229 (const_string "imov")
17230 ]
17231 (const_string "lea")))
17232 (set_attr "mode" "DI")])
17233
17234
d6a7951f 17235;; Placeholder for the conditional moves. This one is split either to SSE
0073023d
JH
17236;; based moves emulation or to usual cmove sequence. Little bit unfortunate
17237;; fact is that compares supported by the cmp??ss instructions are exactly
17238;; swapped of those supported by cmove sequence.
fa9f36a1
JH
17239;; The EQ/NE comparisons also needs bit care, since they are not directly
17240;; supported by i387 comparisons and we do need to emit two conditional moves
17241;; in tandem.
0073023d
JH
17242
17243(define_insn "sse_movsfcc"
17244 [(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")
17245 (if_then_else:SF (match_operator 1 "sse_comparison_operator"
44aefada
JH
17246 [(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")
17247 (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")])
0073023d
JH
17248 (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")
17249 (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")))
bf71a4f8 17250 (clobber (match_scratch:SF 6 "=2,&4,X,X,X,X,X,X,X,X"))
0073023d 17251 (clobber (reg:CC 17))]
fa9f36a1
JH
17252 "TARGET_SSE
17253 && (GET_CODE (operands[2]) != MEM || GET_CODE (operands[3]) != MEM)
4977bab6
ZW
17254 /* Avoid combine from being smart and converting min/max
17255 instruction patterns into conditional moves. */
17256 && ((GET_CODE (operands[1]) != LT && GET_CODE (operands[1]) != GT
17257 && GET_CODE (operands[1]) != UNLE && GET_CODE (operands[1]) != UNGE)
17258 || !rtx_equal_p (operands[4], operands[2])
17259 || !rtx_equal_p (operands[5], operands[3]))
fa9f36a1
JH
17260 && (!TARGET_IEEE_FP
17261 || (GET_CODE (operands[1]) != EQ && GET_CODE (operands[1]) != NE))"
17262 "#")
17263
17264(define_insn "sse_movsfcc_eq"
17265 [(set (match_operand:SF 0 "register_operand" "=&x#rf,x#rf,?f#xr,?f#xr,?r#xf,?r#xf")
44aefada
JH
17266 (if_then_else:SF (eq (match_operand:SF 3 "nonimmediate_operand" "%0#fx,x#fx,f#x,xm#f,f#x,xm#f")
17267 (match_operand:SF 4 "nonimmediate_operand" "xm#f,xm#f,f#x,x#f,f#x,x#f"))
fa9f36a1
JH
17268 (match_operand:SF 1 "nonimmediate_operand" "x#fr,0#fr,0#fx,0#fx,0#rx,0#rx")
17269 (match_operand:SF 2 "nonimmediate_operand" "x#fr,x#fr,f#fx,f#fx,rm#rx,rm#rx")))
f021d6fc 17270 (clobber (match_scratch:SF 5 "=1,&3,X,X,X,X"))
fa9f36a1 17271 (clobber (reg:CC 17))]
0073023d
JH
17272 "TARGET_SSE
17273 && (GET_CODE (operands[2]) != MEM || GET_CODE (operands[3]) != MEM)"
17274 "#")
17275
17276(define_insn "sse_movdfcc"
66b408f2 17277 [(set (match_operand:DF 0 "register_operand" "=&Y#rf,Y#rf,?f#Yr,?f#Yr,?f#Yr,?f#Yr,?r#Yf,?r#Yf,?r#Yf,?r#Yf")
0073023d 17278 (if_then_else:DF (match_operator 1 "sse_comparison_operator"
66b408f2
JJ
17279 [(match_operand:DF 4 "nonimmediate_operand" "0#fY,Y#fY,f#Y,f#Y,Ym#f,Ym#f,f#Y,f#Y,Ym#f,Ym#f")
17280 (match_operand:DF 5 "nonimmediate_operand" "Ym#f,Ym#f,f#Y,f#Y,Y#f,Y#f,f#Y,f#Y,Y#f,Y#f")])
17281 (match_operand:DF 2 "nonimmediate_operand" "Y#fr,0#fr,f#fY,0#fY,f#fY,0#fY,rm#rY,0#rY,rm#rY,0#rY")
17282 (match_operand:DF 3 "nonimmediate_operand" "Y#fr,Y#fr,0#fY,f#fY,0#fY,f#fY,0#fY,rm#rY,0#rY,rm#rY")))
bf71a4f8 17283 (clobber (match_scratch:DF 6 "=2,&4,X,X,X,X,X,X,X,X"))
0073023d
JH
17284 (clobber (reg:CC 17))]
17285 "TARGET_SSE2
fa9f36a1 17286 && (GET_CODE (operands[2]) != MEM || GET_CODE (operands[3]) != MEM)
4977bab6
ZW
17287 /* Avoid combine from being smart and converting min/max
17288 instruction patterns into conditional moves. */
17289 && ((GET_CODE (operands[1]) != LT && GET_CODE (operands[1]) != GT
17290 && GET_CODE (operands[1]) != UNLE && GET_CODE (operands[1]) != UNGE)
17291 || !rtx_equal_p (operands[4], operands[2])
17292 || !rtx_equal_p (operands[5], operands[3]))
fa9f36a1
JH
17293 && (!TARGET_IEEE_FP
17294 || (GET_CODE (operands[1]) != EQ && GET_CODE (operands[1]) != NE))"
17295 "#")
17296
17297(define_insn "sse_movdfcc_eq"
66b408f2
JJ
17298 [(set (match_operand:DF 0 "register_operand" "=&Y#rf,Y#rf,?f#Yr,?f#Yr,?r#Yf,?r#Yf")
17299 (if_then_else:DF (eq (match_operand:DF 3 "nonimmediate_operand" "%0#fY,Y#fY,f#Y,Ym#f,f#Y,Ym#f")
17300 (match_operand:DF 4 "nonimmediate_operand" "Ym#f,Ym#f,f#Y,Y#f,f#Y,Y#f"))
17301 (match_operand:DF 1 "nonimmediate_operand" "Y#fr,0#fr,0#fY,0#fY,0#rY,0#rY")
17302 (match_operand:DF 2 "nonimmediate_operand" "Y#fr,Y#fr,f#fY,f#fY,rm#rY,rm#rY")))
fa9f36a1
JH
17303 (clobber (match_scratch:DF 5 "=1,&3,X,X,X,X"))
17304 (clobber (reg:CC 17))]
17305 "TARGET_SSE
0073023d
JH
17306 && (GET_CODE (operands[2]) != MEM || GET_CODE (operands[3]) != MEM)"
17307 "#")
17308
17309;; For non-sse moves just expand the usual cmove sequence.
17310(define_split
17311 [(set (match_operand 0 "register_operand" "")
17312 (if_then_else (match_operator 1 "comparison_operator"
17313 [(match_operand 4 "nonimmediate_operand" "")
44aefada 17314 (match_operand 5 "register_operand" "")])
0073023d
JH
17315 (match_operand 2 "nonimmediate_operand" "")
17316 (match_operand 3 "nonimmediate_operand" "")))
17317 (clobber (match_operand 6 "" ""))
17318 (clobber (reg:CC 17))]
17319 "!SSE_REG_P (operands[0]) && reload_completed
17320 && VALID_SSE_REG_MODE (GET_MODE (operands[0]))"
17321 [(const_int 0)]
0073023d
JH
17322{
17323 ix86_compare_op0 = operands[5];
17324 ix86_compare_op1 = operands[4];
17325 operands[1] = gen_rtx_fmt_ee (swap_condition (GET_CODE (operands[1])),
17326 VOIDmode, operands[5], operands[4]);
17327 ix86_expand_fp_movcc (operands);
17328 DONE;
0f40f9f7 17329})
0073023d 17330
d1f87653 17331;; Split SSE based conditional move into sequence:
0073023d
JH
17332;; cmpCC op0, op4 - set op0 to 0 or ffffffff depending on the comparison
17333;; and op2, op0 - zero op2 if comparison was false
17334;; nand op0, op3 - load op3 to op0 if comparison was false
9cd10576 17335;; or op2, op0 - get the nonzero one into the result.
0073023d
JH
17336(define_split
17337 [(set (match_operand 0 "register_operand" "")
17338 (if_then_else (match_operator 1 "sse_comparison_operator"
17339 [(match_operand 4 "register_operand" "")
17340 (match_operand 5 "nonimmediate_operand" "")])
17341 (match_operand 2 "register_operand" "")
17342 (match_operand 3 "register_operand" "")))
bf71a4f8 17343 (clobber (match_operand 6 "" ""))
0073023d
JH
17344 (clobber (reg:CC 17))]
17345 "SSE_REG_P (operands[0]) && reload_completed"
17346 [(set (match_dup 4) (match_op_dup 1 [(match_dup 4) (match_dup 5)]))
17347 (set (subreg:TI (match_dup 2) 0) (and:TI (subreg:TI (match_dup 2) 0)
f021d6fc
JH
17348 (subreg:TI (match_dup 4) 0)))
17349 (set (subreg:TI (match_dup 4) 0) (and:TI (not:TI (subreg:TI (match_dup 4) 0))
0073023d
JH
17350 (subreg:TI (match_dup 3) 0)))
17351 (set (subreg:TI (match_dup 0) 0) (ior:TI (subreg:TI (match_dup 6) 0)
17352 (subreg:TI (match_dup 7) 0)))]
0073023d 17353{
4977bab6
ZW
17354 if (GET_MODE (operands[2]) == DFmode
17355 && TARGET_SSE_PARTIAL_REGS && !optimize_size)
17356 {
17357 rtx op = simplify_gen_subreg (V2DFmode, operands[2], DFmode, 0);
17358 emit_insn (gen_sse2_unpcklpd (op, op, op));
17359 op = simplify_gen_subreg (V2DFmode, operands[3], DFmode, 0);
17360 emit_insn (gen_sse2_unpcklpd (op, op, op));
17361 }
4f6ae35d
JJ
17362
17363 /* If op2 == op3, op3 would be clobbered before it is used. */
66b408f2 17364 if (operands_match_p (operands[2], operands[3]))
4f6ae35d
JJ
17365 {
17366 emit_move_insn (operands[0], operands[2]);
17367 DONE;
17368 }
17369
0073023d 17370 PUT_MODE (operands[1], GET_MODE (operands[0]));
f021d6fc 17371 if (operands_match_p (operands[0], operands[4]))
0073023d
JH
17372 operands[6] = operands[4], operands[7] = operands[2];
17373 else
f021d6fc 17374 operands[6] = operands[2], operands[7] = operands[4];
0f40f9f7 17375})
0073023d 17376
d1f87653 17377;; Special case of conditional move we can handle effectively.
0073023d
JH
17378;; Do not brother with the integer/floating point case, since these are
17379;; bot considerably slower, unlike in the generic case.
17380(define_insn "*sse_movsfcc_const0_1"
66b408f2 17381 [(set (match_operand:SF 0 "register_operand" "=&x")
0073023d
JH
17382 (if_then_else:SF (match_operator 1 "sse_comparison_operator"
17383 [(match_operand:SF 4 "register_operand" "0")
17384 (match_operand:SF 5 "nonimmediate_operand" "xm")])
17385 (match_operand:SF 2 "register_operand" "x")
17386 (match_operand:SF 3 "const0_operand" "X")))]
17387 "TARGET_SSE"
17388 "#")
17389
17390(define_insn "*sse_movsfcc_const0_2"
66b408f2 17391 [(set (match_operand:SF 0 "register_operand" "=&x")
0073023d
JH
17392 (if_then_else:SF (match_operator 1 "sse_comparison_operator"
17393 [(match_operand:SF 4 "register_operand" "0")
17394 (match_operand:SF 5 "nonimmediate_operand" "xm")])
adc7fcb8
JH
17395 (match_operand:SF 2 "const0_operand" "X")
17396 (match_operand:SF 3 "register_operand" "x")))]
0073023d
JH
17397 "TARGET_SSE"
17398 "#")
17399
17400(define_insn "*sse_movsfcc_const0_3"
66b408f2 17401 [(set (match_operand:SF 0 "register_operand" "=&x")
0073023d
JH
17402 (if_then_else:SF (match_operator 1 "fcmov_comparison_operator"
17403 [(match_operand:SF 4 "nonimmediate_operand" "xm")
17404 (match_operand:SF 5 "register_operand" "0")])
17405 (match_operand:SF 2 "register_operand" "x")
17406 (match_operand:SF 3 "const0_operand" "X")))]
17407 "TARGET_SSE"
17408 "#")
17409
17410(define_insn "*sse_movsfcc_const0_4"
66b408f2 17411 [(set (match_operand:SF 0 "register_operand" "=&x")
0073023d
JH
17412 (if_then_else:SF (match_operator 1 "fcmov_comparison_operator"
17413 [(match_operand:SF 4 "nonimmediate_operand" "xm")
17414 (match_operand:SF 5 "register_operand" "0")])
adc7fcb8
JH
17415 (match_operand:SF 2 "const0_operand" "X")
17416 (match_operand:SF 3 "register_operand" "x")))]
0073023d
JH
17417 "TARGET_SSE"
17418 "#")
17419
17420(define_insn "*sse_movdfcc_const0_1"
66b408f2
JJ
17421 [(set (match_operand:DF 0 "register_operand" "=&Y")
17422 (if_then_else:DF (match_operator 1 "sse_comparison_operator"
17423 [(match_operand:DF 4 "register_operand" "0")
17424 (match_operand:DF 5 "nonimmediate_operand" "Ym")])
17425 (match_operand:DF 2 "register_operand" "Y")
17426 (match_operand:DF 3 "const0_operand" "X")))]
0073023d
JH
17427 "TARGET_SSE2"
17428 "#")
17429
17430(define_insn "*sse_movdfcc_const0_2"
66b408f2
JJ
17431 [(set (match_operand:DF 0 "register_operand" "=&Y")
17432 (if_then_else:DF (match_operator 1 "sse_comparison_operator"
17433 [(match_operand:DF 4 "register_operand" "0")
17434 (match_operand:DF 5 "nonimmediate_operand" "Ym")])
17435 (match_operand:DF 2 "const0_operand" "X")
17436 (match_operand:DF 3 "register_operand" "Y")))]
0073023d
JH
17437 "TARGET_SSE2"
17438 "#")
17439
17440(define_insn "*sse_movdfcc_const0_3"
66b408f2
JJ
17441 [(set (match_operand:DF 0 "register_operand" "=&Y")
17442 (if_then_else:DF (match_operator 1 "fcmov_comparison_operator"
17443 [(match_operand:DF 4 "nonimmediate_operand" "Ym")
17444 (match_operand:DF 5 "register_operand" "0")])
17445 (match_operand:DF 2 "register_operand" "Y")
17446 (match_operand:DF 3 "const0_operand" "X")))]
0073023d
JH
17447 "TARGET_SSE2"
17448 "#")
17449
17450(define_insn "*sse_movdfcc_const0_4"
66b408f2
JJ
17451 [(set (match_operand:DF 0 "register_operand" "=&Y")
17452 (if_then_else:DF (match_operator 1 "fcmov_comparison_operator"
17453 [(match_operand:DF 4 "nonimmediate_operand" "Ym")
17454 (match_operand:DF 5 "register_operand" "0")])
17455 (match_operand:DF 2 "const0_operand" "X")
17456 (match_operand:DF 3 "register_operand" "Y")))]
0073023d
JH
17457 "TARGET_SSE2"
17458 "#")
17459
17460(define_split
17461 [(set (match_operand 0 "register_operand" "")
17462 (if_then_else (match_operator 1 "comparison_operator"
5794139a 17463 [(match_operand 4 "nonimmediate_operand" "")
0073023d
JH
17464 (match_operand 5 "nonimmediate_operand" "")])
17465 (match_operand 2 "nonmemory_operand" "")
17466 (match_operand 3 "nonmemory_operand" "")))]
17467 "SSE_REG_P (operands[0]) && reload_completed
17468 && (const0_operand (operands[2], GET_MODE (operands[0]))
17469 || const0_operand (operands[3], GET_MODE (operands[0])))"
17470 [(set (match_dup 0) (match_op_dup 1 [(match_dup 0) (match_dup 5)]))
17471 (set (subreg:TI (match_dup 0) 0) (and:TI (match_dup 6)
4977bab6 17472 (match_dup 7)))]
0073023d 17473{
4977bab6
ZW
17474 if (TARGET_SSE_PARTIAL_REGS && !optimize_size
17475 && GET_MODE (operands[2]) == DFmode)
17476 {
17477 if (REG_P (operands[2]))
17478 {
17479 rtx op = simplify_gen_subreg (V2DFmode, operands[2], DFmode, 0);
17480 emit_insn (gen_sse2_unpcklpd (op, op, op));
17481 }
17482 if (REG_P (operands[3]))
17483 {
17484 rtx op = simplify_gen_subreg (V2DFmode, operands[3], DFmode, 0);
17485 emit_insn (gen_sse2_unpcklpd (op, op, op));
17486 }
17487 }
0073023d 17488 PUT_MODE (operands[1], GET_MODE (operands[0]));
5794139a
JH
17489 if (!sse_comparison_operator (operands[1], VOIDmode)
17490 || !rtx_equal_p (operands[0], operands[4]))
0073023d
JH
17491 {
17492 rtx tmp = operands[5];
17493 operands[5] = operands[4];
17494 operands[4] = tmp;
17495 PUT_CODE (operands[1], swap_condition (GET_CODE (operands[1])));
17496 }
5794139a
JH
17497 if (!rtx_equal_p (operands[0], operands[4]))
17498 abort ();
0073023d
JH
17499 if (const0_operand (operands[2], GET_MODE (operands[0])))
17500 {
17501 operands[7] = operands[3];
17502 operands[6] = gen_rtx_NOT (TImode, gen_rtx_SUBREG (TImode, operands[0],
17503 0));
17504 }
17505 else
17506 {
17507 operands[7] = operands[2];
17508 operands[6] = gen_rtx_SUBREG (TImode, operands[0], 0);
17509 }
4977bab6
ZW
17510 operands[7] = simplify_gen_subreg (TImode, operands[7],
17511 GET_MODE (operands[7]), 0);
0f40f9f7 17512})
0073023d 17513
885a70fd
JH
17514(define_expand "allocate_stack_worker"
17515 [(match_operand:SI 0 "register_operand" "")]
17516 "TARGET_STACK_PROBE"
885a70fd
JH
17517{
17518 if (TARGET_64BIT)
17519 emit_insn (gen_allocate_stack_worker_rex64 (operands[0]));
17520 else
17521 emit_insn (gen_allocate_stack_worker_1 (operands[0]));
17522 DONE;
0f40f9f7 17523})
885a70fd
JH
17524
17525(define_insn "allocate_stack_worker_1"
8ee41eaf 17526 [(unspec:SI [(match_operand:SI 0 "register_operand" "a")] UNSPEC_STACK_PROBE)
578b58f5 17527 (set (reg:SI 7) (minus:SI (reg:SI 7) (match_dup 0)))
e075ae69
RH
17528 (clobber (match_dup 0))
17529 (clobber (reg:CC 17))]
1b0c37d7 17530 "!TARGET_64BIT && TARGET_STACK_PROBE"
0f40f9f7 17531 "call\t__alloca"
885a70fd
JH
17532 [(set_attr "type" "multi")
17533 (set_attr "length" "5")])
17534
17535(define_insn "allocate_stack_worker_rex64"
8ee41eaf 17536 [(unspec:DI [(match_operand:DI 0 "register_operand" "a")] UNSPEC_STACK_PROBE)
885a70fd
JH
17537 (set (reg:DI 7) (minus:DI (reg:DI 7) (match_dup 0)))
17538 (clobber (match_dup 0))
17539 (clobber (reg:CC 17))]
1b0c37d7 17540 "TARGET_64BIT && TARGET_STACK_PROBE"
0f40f9f7 17541 "call\t__alloca"
e075ae69
RH
17542 [(set_attr "type" "multi")
17543 (set_attr "length" "5")])
578b58f5
RK
17544
17545(define_expand "allocate_stack"
e075ae69
RH
17546 [(parallel [(set (match_operand:SI 0 "register_operand" "=r")
17547 (minus:SI (reg:SI 7)
17548 (match_operand:SI 1 "general_operand" "")))
17549 (clobber (reg:CC 17))])
17550 (parallel [(set (reg:SI 7)
17551 (minus:SI (reg:SI 7) (match_dup 1)))
17552 (clobber (reg:CC 17))])]
17553 "TARGET_STACK_PROBE"
578b58f5
RK
17554{
17555#ifdef CHECK_STACK_LIMIT
e9a25f70
JL
17556 if (GET_CODE (operands[1]) == CONST_INT
17557 && INTVAL (operands[1]) < CHECK_STACK_LIMIT)
578b58f5 17558 emit_insn (gen_subsi3 (stack_pointer_rtx, stack_pointer_rtx,
e9a25f70 17559 operands[1]));
578b58f5
RK
17560 else
17561#endif
17562 emit_insn (gen_allocate_stack_worker (copy_to_mode_reg (SImode,
e9a25f70 17563 operands[1])));
578b58f5 17564
e9a25f70
JL
17565 emit_move_insn (operands[0], virtual_stack_dynamic_rtx);
17566 DONE;
0f40f9f7 17567})
e31ca113 17568
fb754025
AG
17569(define_expand "builtin_setjmp_receiver"
17570 [(label_ref (match_operand 0 "" ""))]
1b0c37d7 17571 "!TARGET_64BIT && flag_pic"
fb754025 17572{
c8c03509 17573 emit_insn (gen_set_got (pic_offset_table_rtx));
fb754025 17574 DONE;
0f40f9f7 17575})
e9e80858
JH
17576\f
17577;; Avoid redundant prefixes by splitting HImode arithmetic to SImode.
17578
17579(define_split
17580 [(set (match_operand 0 "register_operand" "")
17581 (match_operator 3 "promotable_binary_operator"
17582 [(match_operand 1 "register_operand" "")
2247f6ed 17583 (match_operand 2 "aligned_operand" "")]))
e9e80858
JH
17584 (clobber (reg:CC 17))]
17585 "! TARGET_PARTIAL_REG_STALL && reload_completed
17586 && ((GET_MODE (operands[0]) == HImode
285464d0
JH
17587 && ((!optimize_size && !TARGET_FAST_PREFIX)
17588 || GET_CODE (operands[2]) != CONST_INT
e9e80858
JH
17589 || CONST_OK_FOR_LETTER_P (INTVAL (operands[2]), 'K')))
17590 || (GET_MODE (operands[0]) == QImode
17591 && (TARGET_PROMOTE_QImode || optimize_size)))"
17592 [(parallel [(set (match_dup 0)
17593 (match_op_dup 3 [(match_dup 1) (match_dup 2)]))
17594 (clobber (reg:CC 17))])]
17595 "operands[0] = gen_lowpart (SImode, operands[0]);
17596 operands[1] = gen_lowpart (SImode, operands[1]);
17597 if (GET_CODE (operands[3]) != ASHIFT)
17598 operands[2] = gen_lowpart (SImode, operands[2]);
dbbbbf3b 17599 PUT_MODE (operands[3], SImode);")
e9e80858
JH
17600
17601(define_split
16189740
RH
17602 [(set (reg 17)
17603 (compare (and (match_operand 1 "aligned_operand" "")
17604 (match_operand 2 "const_int_operand" ""))
17605 (const_int 0)))
e9e80858
JH
17606 (set (match_operand 0 "register_operand" "")
17607 (and (match_dup 1) (match_dup 2)))]
17608 "! TARGET_PARTIAL_REG_STALL && reload_completed
16189740 17609 && ix86_match_ccmode (insn, CCNOmode)
e9e80858
JH
17610 && (GET_MODE (operands[0]) == HImode
17611 || (GET_MODE (operands[0]) == QImode
680dd104 17612 /* Ensure that the operand will remain sign extended immediate. */
0d682900 17613 && INTVAL (operands[2]) >= 0
e9e80858
JH
17614 && (TARGET_PROMOTE_QImode || optimize_size)))"
17615 [(parallel [(set (reg:CCNO 17)
17616 (compare:CCNO (and:SI (match_dup 1) (match_dup 2))
17617 (const_int 0)))
17618 (set (match_dup 0)
17619 (and:SI (match_dup 1) (match_dup 2)))])]
d9f0b960 17620 "operands[2]
d8bf17f9
LB
17621 = gen_int_mode (INTVAL (operands[2])
17622 & GET_MODE_MASK (GET_MODE (operands[0])),
17623 SImode);
d9f0b960
RH
17624 operands[0] = gen_lowpart (SImode, operands[0]);
17625 operands[1] = gen_lowpart (SImode, operands[1]);")
e9e80858 17626
0d682900
JH
17627; Don't promote the QImode tests, as i386 don't have encoding of
17628; the test instruction with 32bit sign extended immediate and thus
17629; the code grows.
e9e80858 17630(define_split
16189740 17631 [(set (reg 17)
0d682900
JH
17632 (compare (and (match_operand:HI 0 "aligned_operand" "")
17633 (match_operand:HI 1 "const_int_operand" ""))
16189740 17634 (const_int 0)))]
e9e80858 17635 "! TARGET_PARTIAL_REG_STALL && reload_completed
16189740 17636 && ix86_match_ccmode (insn, CCNOmode)
0d682900 17637 && GET_MODE (operands[0]) == HImode"
e9e80858
JH
17638 [(set (reg:CCNO 17)
17639 (compare:CCNO (and:SI (match_dup 0) (match_dup 1))
17640 (const_int 0)))]
d9f0b960 17641 "operands[1]
d8bf17f9
LB
17642 = gen_int_mode (INTVAL (operands[1])
17643 & GET_MODE_MASK (GET_MODE (operands[0])),
17644 SImode);
d9f0b960 17645 operands[0] = gen_lowpart (SImode, operands[0]);")
e9e80858
JH
17646
17647(define_split
17648 [(set (match_operand 0 "register_operand" "")
17649 (neg (match_operand 1 "register_operand" "")))
17650 (clobber (reg:CC 17))]
17651 "! TARGET_PARTIAL_REG_STALL && reload_completed
17652 && (GET_MODE (operands[0]) == HImode
17653 || (GET_MODE (operands[0]) == QImode
17654 && (TARGET_PROMOTE_QImode || optimize_size)))"
17655 [(parallel [(set (match_dup 0)
17656 (neg:SI (match_dup 1)))
17657 (clobber (reg:CC 17))])]
17658 "operands[0] = gen_lowpart (SImode, operands[0]);
17659 operands[1] = gen_lowpart (SImode, operands[1]);")
17660
17661(define_split
17662 [(set (match_operand 0 "register_operand" "")
17663 (not (match_operand 1 "register_operand" "")))]
17664 "! TARGET_PARTIAL_REG_STALL && reload_completed
17665 && (GET_MODE (operands[0]) == HImode
17666 || (GET_MODE (operands[0]) == QImode
17667 && (TARGET_PROMOTE_QImode || optimize_size)))"
17668 [(set (match_dup 0)
17669 (not:SI (match_dup 1)))]
17670 "operands[0] = gen_lowpart (SImode, operands[0]);
17671 operands[1] = gen_lowpart (SImode, operands[1]);")
17672
17673(define_split
17674 [(set (match_operand 0 "register_operand" "")
17675 (if_then_else (match_operator 1 "comparison_operator"
17676 [(reg 17) (const_int 0)])
17677 (match_operand 2 "register_operand" "")
17678 (match_operand 3 "register_operand" "")))]
17679 "! TARGET_PARTIAL_REG_STALL && TARGET_CMOVE
17680 && (GET_MODE (operands[0]) == HImode
17681 || (GET_MODE (operands[0]) == QImode
17682 && (TARGET_PROMOTE_QImode || optimize_size)))"
17683 [(set (match_dup 0)
17684 (if_then_else:SI (match_dup 1) (match_dup 2) (match_dup 3)))]
17685 "operands[0] = gen_lowpart (SImode, operands[0]);
17686 operands[2] = gen_lowpart (SImode, operands[2]);
17687 operands[3] = gen_lowpart (SImode, operands[3]);")
17688
e075ae69
RH
17689\f
17690;; RTL Peephole optimizations, run before sched2. These primarily look to
17691;; transform a complex memory operation into two memory to register operations.
17692
17693;; Don't push memory operands
17694(define_peephole2
3071fab5
RH
17695 [(set (match_operand:SI 0 "push_operand" "")
17696 (match_operand:SI 1 "memory_operand" ""))
17697 (match_scratch:SI 2 "r")]
e075ae69
RH
17698 "! optimize_size && ! TARGET_PUSH_MEMORY"
17699 [(set (match_dup 2) (match_dup 1))
17700 (set (match_dup 0) (match_dup 2))]
17701 "")
17702
cc2e591b
JH
17703(define_peephole2
17704 [(set (match_operand:DI 0 "push_operand" "")
17705 (match_operand:DI 1 "memory_operand" ""))
17706 (match_scratch:DI 2 "r")]
17707 "! optimize_size && ! TARGET_PUSH_MEMORY"
17708 [(set (match_dup 2) (match_dup 1))
17709 (set (match_dup 0) (match_dup 2))]
17710 "")
17711
e9e80858
JH
17712;; We need to handle SFmode only, because DFmode and XFmode is split to
17713;; SImode pushes.
17714(define_peephole2
17715 [(set (match_operand:SF 0 "push_operand" "")
17716 (match_operand:SF 1 "memory_operand" ""))
17717 (match_scratch:SF 2 "r")]
17718 "! optimize_size && ! TARGET_PUSH_MEMORY"
17719 [(set (match_dup 2) (match_dup 1))
17720 (set (match_dup 0) (match_dup 2))]
17721 "")
17722
e075ae69 17723(define_peephole2
3071fab5
RH
17724 [(set (match_operand:HI 0 "push_operand" "")
17725 (match_operand:HI 1 "memory_operand" ""))
17726 (match_scratch:HI 2 "r")]
e075ae69
RH
17727 "! optimize_size && ! TARGET_PUSH_MEMORY"
17728 [(set (match_dup 2) (match_dup 1))
17729 (set (match_dup 0) (match_dup 2))]
17730 "")
17731
17732(define_peephole2
3071fab5
RH
17733 [(set (match_operand:QI 0 "push_operand" "")
17734 (match_operand:QI 1 "memory_operand" ""))
17735 (match_scratch:QI 2 "q")]
e075ae69
RH
17736 "! optimize_size && ! TARGET_PUSH_MEMORY"
17737 [(set (match_dup 2) (match_dup 1))
17738 (set (match_dup 0) (match_dup 2))]
17739 "")
17740
17741;; Don't move an immediate directly to memory when the instruction
17742;; gets too big.
17743(define_peephole2
17744 [(match_scratch:SI 1 "r")
17745 (set (match_operand:SI 0 "memory_operand" "")
17746 (const_int 0))]
23280139 17747 "! optimize_size
591702de 17748 && ! TARGET_USE_MOV0
23280139
RH
17749 && TARGET_SPLIT_LONG_MOVES
17750 && get_attr_length (insn) >= ix86_cost->large_insn
17751 && peep2_regno_dead_p (0, FLAGS_REG)"
e075ae69
RH
17752 [(parallel [(set (match_dup 1) (const_int 0))
17753 (clobber (reg:CC 17))])
17754 (set (match_dup 0) (match_dup 1))]
17755 "")
17756
17757(define_peephole2
17758 [(match_scratch:HI 1 "r")
17759 (set (match_operand:HI 0 "memory_operand" "")
17760 (const_int 0))]
23280139 17761 "! optimize_size
591702de 17762 && ! TARGET_USE_MOV0
23280139
RH
17763 && TARGET_SPLIT_LONG_MOVES
17764 && get_attr_length (insn) >= ix86_cost->large_insn
17765 && peep2_regno_dead_p (0, FLAGS_REG)"
591702de 17766 [(parallel [(set (match_dup 2) (const_int 0))
e075ae69
RH
17767 (clobber (reg:CC 17))])
17768 (set (match_dup 0) (match_dup 1))]
591702de 17769 "operands[2] = gen_rtx_REG (SImode, true_regnum (operands[1]));")
e075ae69
RH
17770
17771(define_peephole2
17772 [(match_scratch:QI 1 "q")
17773 (set (match_operand:QI 0 "memory_operand" "")
17774 (const_int 0))]
23280139 17775 "! optimize_size
591702de 17776 && ! TARGET_USE_MOV0
23280139
RH
17777 && TARGET_SPLIT_LONG_MOVES
17778 && get_attr_length (insn) >= ix86_cost->large_insn
17779 && peep2_regno_dead_p (0, FLAGS_REG)"
591702de 17780 [(parallel [(set (match_dup 2) (const_int 0))
e075ae69
RH
17781 (clobber (reg:CC 17))])
17782 (set (match_dup 0) (match_dup 1))]
591702de 17783 "operands[2] = gen_rtx_REG (SImode, true_regnum (operands[1]));")
e075ae69
RH
17784
17785(define_peephole2
17786 [(match_scratch:SI 2 "r")
17787 (set (match_operand:SI 0 "memory_operand" "")
17788 (match_operand:SI 1 "immediate_operand" ""))]
23280139
RH
17789 "! optimize_size
17790 && get_attr_length (insn) >= ix86_cost->large_insn
17791 && TARGET_SPLIT_LONG_MOVES"
e075ae69
RH
17792 [(set (match_dup 2) (match_dup 1))
17793 (set (match_dup 0) (match_dup 2))]
17794 "")
17795
17796(define_peephole2
17797 [(match_scratch:HI 2 "r")
17798 (set (match_operand:HI 0 "memory_operand" "")
17799 (match_operand:HI 1 "immediate_operand" ""))]
17800 "! optimize_size && get_attr_length (insn) >= ix86_cost->large_insn
17801 && TARGET_SPLIT_LONG_MOVES"
17802 [(set (match_dup 2) (match_dup 1))
17803 (set (match_dup 0) (match_dup 2))]
17804 "")
17805
17806(define_peephole2
17807 [(match_scratch:QI 2 "q")
17808 (set (match_operand:QI 0 "memory_operand" "")
17809 (match_operand:QI 1 "immediate_operand" ""))]
17810 "! optimize_size && get_attr_length (insn) >= ix86_cost->large_insn
17811 && TARGET_SPLIT_LONG_MOVES"
17812 [(set (match_dup 2) (match_dup 1))
17813 (set (match_dup 0) (match_dup 2))]
17814 "")
17815
17816;; Don't compare memory with zero, load and use a test instead.
17817(define_peephole2
16189740
RH
17818 [(set (reg 17)
17819 (compare (match_operand:SI 0 "memory_operand" "")
17820 (const_int 0)))
3071fab5 17821 (match_scratch:SI 3 "r")]
16189740
RH
17822 "ix86_match_ccmode (insn, CCNOmode) && ! optimize_size"
17823 [(set (match_dup 3) (match_dup 0))
17824 (set (reg:CCNO 17) (compare:CCNO (match_dup 3) (const_int 0)))]
e075ae69
RH
17825 "")
17826
17827;; NOT is not pairable on Pentium, while XOR is, but one byte longer.
17828;; Don't split NOTs with a displacement operand, because resulting XOR
d1f87653 17829;; will not be pairable anyway.
e075ae69
RH
17830;;
17831;; On AMD K6, NOT is vector decoded with memory operand that can not be
17832;; represented using a modRM byte. The XOR replacement is long decoded,
17833;; so this split helps here as well.
17834;;
23280139
RH
17835;; Note: Can't do this as a regular split because we can't get proper
17836;; lifetime information then.
e075ae69
RH
17837
17838(define_peephole2
d5d6a58b
RH
17839 [(set (match_operand:SI 0 "nonimmediate_operand" "")
17840 (not:SI (match_operand:SI 1 "nonimmediate_operand" "")))]
e075ae69 17841 "!optimize_size
23280139 17842 && peep2_regno_dead_p (0, FLAGS_REG)
e075ae69
RH
17843 && ((TARGET_PENTIUM
17844 && (GET_CODE (operands[0]) != MEM
17845 || !memory_displacement_operand (operands[0], SImode)))
17846 || (TARGET_K6 && long_memory_operand (operands[0], SImode)))"
17847 [(parallel [(set (match_dup 0)
17848 (xor:SI (match_dup 1) (const_int -1)))
17849 (clobber (reg:CC 17))])]
17850 "")
17851
17852(define_peephole2
d5d6a58b
RH
17853 [(set (match_operand:HI 0 "nonimmediate_operand" "")
17854 (not:HI (match_operand:HI 1 "nonimmediate_operand" "")))]
e075ae69 17855 "!optimize_size
23280139 17856 && peep2_regno_dead_p (0, FLAGS_REG)
e075ae69
RH
17857 && ((TARGET_PENTIUM
17858 && (GET_CODE (operands[0]) != MEM
17859 || !memory_displacement_operand (operands[0], HImode)))
17860 || (TARGET_K6 && long_memory_operand (operands[0], HImode)))"
17861 [(parallel [(set (match_dup 0)
17862 (xor:HI (match_dup 1) (const_int -1)))
17863 (clobber (reg:CC 17))])]
17864 "")
17865
17866(define_peephole2
d5d6a58b
RH
17867 [(set (match_operand:QI 0 "nonimmediate_operand" "")
17868 (not:QI (match_operand:QI 1 "nonimmediate_operand" "")))]
e075ae69 17869 "!optimize_size
23280139 17870 && peep2_regno_dead_p (0, FLAGS_REG)
e075ae69
RH
17871 && ((TARGET_PENTIUM
17872 && (GET_CODE (operands[0]) != MEM
17873 || !memory_displacement_operand (operands[0], QImode)))
17874 || (TARGET_K6 && long_memory_operand (operands[0], QImode)))"
17875 [(parallel [(set (match_dup 0)
17876 (xor:QI (match_dup 1) (const_int -1)))
17877 (clobber (reg:CC 17))])]
17878 "")
17879
17880;; Non pairable "test imm, reg" instructions can be translated to
17881;; "and imm, reg" if reg dies. The "and" form is also shorter (one
17882;; byte opcode instead of two, have a short form for byte operands),
17883;; so do it for other CPUs as well. Given that the value was dead,
f5143c46 17884;; this should not create any new dependencies. Pass on the sub-word
e075ae69
RH
17885;; versions if we're concerned about partial register stalls.
17886
17887(define_peephole2
16189740
RH
17888 [(set (reg 17)
17889 (compare (and:SI (match_operand:SI 0 "register_operand" "")
17890 (match_operand:SI 1 "immediate_operand" ""))
17891 (const_int 0)))]
17892 "ix86_match_ccmode (insn, CCNOmode)
17893 && (true_regnum (operands[0]) != 0
6c81a490
JH
17894 || (GET_CODE (operands[1]) == CONST_INT
17895 && CONST_OK_FOR_LETTER_P (INTVAL (operands[1]), 'K')))
e075ae69
RH
17896 && find_regno_note (insn, REG_DEAD, true_regnum (operands[0]))"
17897 [(parallel
17898 [(set (reg:CCNO 17)
17899 (compare:CCNO (and:SI (match_dup 0)
17900 (match_dup 1))
17901 (const_int 0)))
17902 (set (match_dup 0)
17903 (and:SI (match_dup 0) (match_dup 1)))])]
17904 "")
17905
e9e80858
JH
17906;; We don't need to handle HImode case, because it will be promoted to SImode
17907;; on ! TARGET_PARTIAL_REG_STALL
e075ae69
RH
17908
17909(define_peephole2
16189740
RH
17910 [(set (reg 17)
17911 (compare (and:QI (match_operand:QI 0 "register_operand" "")
17912 (match_operand:QI 1 "immediate_operand" ""))
17913 (const_int 0)))]
e075ae69 17914 "! TARGET_PARTIAL_REG_STALL
16189740 17915 && ix86_match_ccmode (insn, CCNOmode)
e075ae69
RH
17916 && true_regnum (operands[0]) != 0
17917 && find_regno_note (insn, REG_DEAD, true_regnum (operands[0]))"
17918 [(parallel
17919 [(set (reg:CCNO 17)
17920 (compare:CCNO (and:QI (match_dup 0)
17921 (match_dup 1))
17922 (const_int 0)))
17923 (set (match_dup 0)
17924 (and:QI (match_dup 0) (match_dup 1)))])]
17925 "")
17926
17927(define_peephole2
16189740
RH
17928 [(set (reg 17)
17929 (compare
e075ae69
RH
17930 (and:SI
17931 (zero_extract:SI
3522082b 17932 (match_operand 0 "ext_register_operand" "")
e075ae69
RH
17933 (const_int 8)
17934 (const_int 8))
3522082b 17935 (match_operand 1 "const_int_operand" ""))
e075ae69
RH
17936 (const_int 0)))]
17937 "! TARGET_PARTIAL_REG_STALL
16189740 17938 && ix86_match_ccmode (insn, CCNOmode)
e075ae69
RH
17939 && true_regnum (operands[0]) != 0
17940 && find_regno_note (insn, REG_DEAD, true_regnum (operands[0]))"
17941 [(parallel [(set (reg:CCNO 17)
17942 (compare:CCNO
17943 (and:SI
17944 (zero_extract:SI
17945 (match_dup 0)
17946 (const_int 8)
17947 (const_int 8))
17948 (match_dup 1))
17949 (const_int 0)))
17950 (set (zero_extract:SI (match_dup 0)
17951 (const_int 8)
17952 (const_int 8))
17953 (and:SI
17954 (zero_extract:SI
17955 (match_dup 0)
17956 (const_int 8)
17957 (const_int 8))
17958 (match_dup 1)))])]
17959 "")
17960
17961;; Don't do logical operations with memory inputs.
17962(define_peephole2
17963 [(match_scratch:SI 2 "r")
17964 (parallel [(set (match_operand:SI 0 "register_operand" "")
17965 (match_operator:SI 3 "arith_or_logical_operator"
17966 [(match_dup 0)
17967 (match_operand:SI 1 "memory_operand" "")]))
17968 (clobber (reg:CC 17))])]
17969 "! optimize_size && ! TARGET_READ_MODIFY"
17970 [(set (match_dup 2) (match_dup 1))
17971 (parallel [(set (match_dup 0)
17972 (match_op_dup 3 [(match_dup 0) (match_dup 2)]))
17973 (clobber (reg:CC 17))])]
17974 "")
17975
17976(define_peephole2
17977 [(match_scratch:SI 2 "r")
17978 (parallel [(set (match_operand:SI 0 "register_operand" "")
17979 (match_operator:SI 3 "arith_or_logical_operator"
17980 [(match_operand:SI 1 "memory_operand" "")
17981 (match_dup 0)]))
17982 (clobber (reg:CC 17))])]
17983 "! optimize_size && ! TARGET_READ_MODIFY"
17984 [(set (match_dup 2) (match_dup 1))
17985 (parallel [(set (match_dup 0)
17986 (match_op_dup 3 [(match_dup 2) (match_dup 0)]))
17987 (clobber (reg:CC 17))])]
17988 "")
17989
17990; Don't do logical operations with memory outputs
17991;
17992; These two don't make sense for PPro/PII -- we're expanding a 4-uop
17993; instruction into two 1-uop insns plus a 2-uop insn. That last has
17994; the same decoder scheduling characteristics as the original.
17995
17996(define_peephole2
17997 [(match_scratch:SI 2 "r")
17998 (parallel [(set (match_operand:SI 0 "memory_operand" "")
17999 (match_operator:SI 3 "arith_or_logical_operator"
18000 [(match_dup 0)
18001 (match_operand:SI 1 "nonmemory_operand" "")]))
18002 (clobber (reg:CC 17))])]
18003 "! optimize_size && ! TARGET_READ_MODIFY_WRITE"
18004 [(set (match_dup 2) (match_dup 0))
18005 (parallel [(set (match_dup 2)
18006 (match_op_dup 3 [(match_dup 2) (match_dup 1)]))
18007 (clobber (reg:CC 17))])
18008 (set (match_dup 0) (match_dup 2))]
18009 "")
18010
18011(define_peephole2
18012 [(match_scratch:SI 2 "r")
18013 (parallel [(set (match_operand:SI 0 "memory_operand" "")
18014 (match_operator:SI 3 "arith_or_logical_operator"
18015 [(match_operand:SI 1 "nonmemory_operand" "")
18016 (match_dup 0)]))
18017 (clobber (reg:CC 17))])]
18018 "! optimize_size && ! TARGET_READ_MODIFY_WRITE"
18019 [(set (match_dup 2) (match_dup 0))
18020 (parallel [(set (match_dup 2)
18021 (match_op_dup 3 [(match_dup 1) (match_dup 2)]))
18022 (clobber (reg:CC 17))])
18023 (set (match_dup 0) (match_dup 2))]
18024 "")
18025
18026;; Attempt to always use XOR for zeroing registers.
18027(define_peephole2
18028 [(set (match_operand 0 "register_operand" "")
18029 (const_int 0))]
18030 "(GET_MODE (operands[0]) == QImode
18031 || GET_MODE (operands[0]) == HImode
cc2e591b
JH
18032 || GET_MODE (operands[0]) == SImode
18033 || (GET_MODE (operands[0]) == DImode && TARGET_64BIT))
e075ae69 18034 && (! TARGET_USE_MOV0 || optimize_size)
23280139 18035 && peep2_regno_dead_p (0, FLAGS_REG)"
e075ae69
RH
18036 [(parallel [(set (match_dup 0) (const_int 0))
18037 (clobber (reg:CC 17))])]
cc2e591b
JH
18038 "operands[0] = gen_rtx_REG (GET_MODE (operands[0]) == DImode ? DImode : SImode,
18039 true_regnum (operands[0]));")
d3a923ee 18040
6ef67412
JH
18041(define_peephole2
18042 [(set (strict_low_part (match_operand 0 "register_operand" ""))
18043 (const_int 0))]
18044 "(GET_MODE (operands[0]) == QImode
18045 || GET_MODE (operands[0]) == HImode)
18046 && (! TARGET_USE_MOV0 || optimize_size)
18047 && peep2_regno_dead_p (0, FLAGS_REG)"
18048 [(parallel [(set (strict_low_part (match_dup 0)) (const_int 0))
18049 (clobber (reg:CC 17))])])
18050
e075ae69
RH
18051;; For HI and SI modes, or $-1,reg is smaller than mov $-1,reg.
18052(define_peephole2
591702de 18053 [(set (match_operand 0 "register_operand" "")
e075ae69 18054 (const_int -1))]
591702de 18055 "(GET_MODE (operands[0]) == HImode
cc2e591b
JH
18056 || GET_MODE (operands[0]) == SImode
18057 || (GET_MODE (operands[0]) == DImode && TARGET_64BIT))
591702de 18058 && (optimize_size || TARGET_PENTIUM)
23280139 18059 && peep2_regno_dead_p (0, FLAGS_REG)"
591702de 18060 [(parallel [(set (match_dup 0) (const_int -1))
e075ae69 18061 (clobber (reg:CC 17))])]
cc2e591b
JH
18062 "operands[0] = gen_rtx_REG (GET_MODE (operands[0]) == DImode ? DImode : SImode,
18063 true_regnum (operands[0]));")
1c27d4b2
JH
18064
18065;; Attempt to convert simple leas to adds. These can be created by
18066;; move expanders.
18067(define_peephole2
18068 [(set (match_operand:SI 0 "register_operand" "")
18069 (plus:SI (match_dup 0)
18070 (match_operand:SI 1 "nonmemory_operand" "")))]
23280139 18071 "peep2_regno_dead_p (0, FLAGS_REG)"
1c27d4b2
JH
18072 [(parallel [(set (match_dup 0) (plus:SI (match_dup 0) (match_dup 1)))
18073 (clobber (reg:CC 17))])]
18074 "")
18075
cc2e591b
JH
18076(define_peephole2
18077 [(set (match_operand:SI 0 "register_operand" "")
18078 (subreg:SI (plus:DI (match_operand:DI 1 "register_operand" "")
18079 (match_operand:DI 2 "nonmemory_operand" "")) 0))]
18080 "peep2_regno_dead_p (0, FLAGS_REG) && REGNO (operands[0]) == REGNO (operands[1])"
18081 [(parallel [(set (match_dup 0) (plus:SI (match_dup 0) (match_dup 2)))
18082 (clobber (reg:CC 17))])]
18083 "operands[2] = gen_lowpart (SImode, operands[2]);")
18084
18085(define_peephole2
18086 [(set (match_operand:DI 0 "register_operand" "")
18087 (plus:DI (match_dup 0)
18088 (match_operand:DI 1 "x86_64_general_operand" "")))]
18089 "peep2_regno_dead_p (0, FLAGS_REG)"
18090 [(parallel [(set (match_dup 0) (plus:DI (match_dup 0) (match_dup 1)))
18091 (clobber (reg:CC 17))])]
18092 "")
18093
1c27d4b2
JH
18094(define_peephole2
18095 [(set (match_operand:SI 0 "register_operand" "")
18096 (mult:SI (match_dup 0)
cc2e591b 18097 (match_operand:SI 1 "const_int_operand" "")))]
23280139
RH
18098 "exact_log2 (INTVAL (operands[1])) >= 0
18099 && peep2_regno_dead_p (0, FLAGS_REG)"
1c27d4b2
JH
18100 [(parallel [(set (match_dup 0) (ashift:SI (match_dup 0) (match_dup 2)))
18101 (clobber (reg:CC 17))])]
18102 "operands[2] = GEN_INT (exact_log2 (INTVAL (operands[1])));")
bdeb029c 18103
cc2e591b
JH
18104(define_peephole2
18105 [(set (match_operand:DI 0 "register_operand" "")
18106 (mult:DI (match_dup 0)
18107 (match_operand:DI 1 "const_int_operand" "")))]
18108 "exact_log2 (INTVAL (operands[1])) >= 0
18109 && peep2_regno_dead_p (0, FLAGS_REG)"
18110 [(parallel [(set (match_dup 0) (ashift:DI (match_dup 0) (match_dup 2)))
18111 (clobber (reg:CC 17))])]
18112 "operands[2] = GEN_INT (exact_log2 (INTVAL (operands[1])));")
18113
18114(define_peephole2
18115 [(set (match_operand:SI 0 "register_operand" "")
18116 (subreg:SI (mult:DI (match_operand:DI 1 "register_operand" "")
18117 (match_operand:DI 2 "const_int_operand" "")) 0))]
4c9c9a3d 18118 "exact_log2 (INTVAL (operands[2])) >= 0
cc2e591b
JH
18119 && REGNO (operands[0]) == REGNO (operands[1])
18120 && peep2_regno_dead_p (0, FLAGS_REG)"
18121 [(parallel [(set (match_dup 0) (ashift:SI (match_dup 0) (match_dup 2)))
18122 (clobber (reg:CC 17))])]
18123 "operands[2] = GEN_INT (exact_log2 (INTVAL (operands[2])));")
18124
bdeb029c
JH
18125;; The ESP adjustments can be done by the push and pop instructions. Resulting
18126;; code is shorter, since push is only 1 byte, while add imm, %esp 3 bytes. On
18127;; many CPUs it is also faster, since special hardware to avoid esp
f5143c46 18128;; dependencies is present.
bdeb029c 18129
d6a7951f 18130;; While some of these conversions may be done using splitters, we use peepholes
bdeb029c
JH
18131;; in order to allow combine_stack_adjustments pass to see nonobfuscated RTL.
18132
f5143c46 18133;; Convert prologue esp subtractions to push.
bdeb029c
JH
18134;; We need register to push. In order to keep verify_flow_info happy we have
18135;; two choices
18136;; - use scratch and clobber it in order to avoid dependencies
18137;; - use already live register
18138;; We can't use the second way right now, since there is no reliable way how to
18139;; verify that given register is live. First choice will also most likely in
18140;; fewer dependencies. On the place of esp adjustments it is very likely that
18141;; call clobbered registers are dead. We may want to use base pointer as an
18142;; alternative when no register is available later.
18143
18144(define_peephole2
18145 [(match_scratch:SI 0 "r")
18146 (parallel [(set (reg:SI 7) (plus:SI (reg:SI 7) (const_int -4)))
f2042df3
RH
18147 (clobber (reg:CC 17))
18148 (clobber (mem:BLK (scratch)))])]
bdeb029c
JH
18149 "optimize_size || !TARGET_SUB_ESP_4"
18150 [(clobber (match_dup 0))
18151 (parallel [(set (mem:SI (pre_dec:SI (reg:SI 7))) (match_dup 0))
f2042df3 18152 (clobber (mem:BLK (scratch)))])])
bdeb029c
JH
18153
18154(define_peephole2
18155 [(match_scratch:SI 0 "r")
18156 (parallel [(set (reg:SI 7) (plus:SI (reg:SI 7) (const_int -8)))
f2042df3
RH
18157 (clobber (reg:CC 17))
18158 (clobber (mem:BLK (scratch)))])]
bdeb029c
JH
18159 "optimize_size || !TARGET_SUB_ESP_8"
18160 [(clobber (match_dup 0))
18161 (set (mem:SI (pre_dec:SI (reg:SI 7))) (match_dup 0))
18162 (parallel [(set (mem:SI (pre_dec:SI (reg:SI 7))) (match_dup 0))
f2042df3 18163 (clobber (mem:BLK (scratch)))])])
bdeb029c 18164
f5143c46 18165;; Convert esp subtractions to push.
bdeb029c
JH
18166(define_peephole2
18167 [(match_scratch:SI 0 "r")
18168 (parallel [(set (reg:SI 7) (plus:SI (reg:SI 7) (const_int -4)))
18169 (clobber (reg:CC 17))])]
18170 "optimize_size || !TARGET_SUB_ESP_4"
18171 [(clobber (match_dup 0))
18172 (set (mem:SI (pre_dec:SI (reg:SI 7))) (match_dup 0))])
18173
18174(define_peephole2
18175 [(match_scratch:SI 0 "r")
18176 (parallel [(set (reg:SI 7) (plus:SI (reg:SI 7) (const_int -8)))
18177 (clobber (reg:CC 17))])]
18178 "optimize_size || !TARGET_SUB_ESP_8"
18179 [(clobber (match_dup 0))
18180 (set (mem:SI (pre_dec:SI (reg:SI 7))) (match_dup 0))
18181 (set (mem:SI (pre_dec:SI (reg:SI 7))) (match_dup 0))])
18182
18183;; Convert epilogue deallocator to pop.
18184(define_peephole2
18185 [(match_scratch:SI 0 "r")
18186 (parallel [(set (reg:SI 7) (plus:SI (reg:SI 7) (const_int 4)))
f2042df3
RH
18187 (clobber (reg:CC 17))
18188 (clobber (mem:BLK (scratch)))])]
bdeb029c
JH
18189 "optimize_size || !TARGET_ADD_ESP_4"
18190 [(parallel [(set (match_dup 0) (mem:SI (reg:SI 7)))
18191 (set (reg:SI 7) (plus:SI (reg:SI 7) (const_int 4)))
f2042df3 18192 (clobber (mem:BLK (scratch)))])]
bdeb029c
JH
18193 "")
18194
18195;; Two pops case is tricky, since pop causes dependency on destination register.
18196;; We use two registers if available.
18197(define_peephole2
18198 [(match_scratch:SI 0 "r")
18199 (match_scratch:SI 1 "r")
18200 (parallel [(set (reg:SI 7) (plus:SI (reg:SI 7) (const_int 8)))
f2042df3
RH
18201 (clobber (reg:CC 17))
18202 (clobber (mem:BLK (scratch)))])]
bdeb029c
JH
18203 "optimize_size || !TARGET_ADD_ESP_8"
18204 [(parallel [(set (match_dup 0) (mem:SI (reg:SI 7)))
18205 (set (reg:SI 7) (plus:SI (reg:SI 7) (const_int 4)))
f2042df3 18206 (clobber (mem:BLK (scratch)))])
bdeb029c
JH
18207 (parallel [(set (match_dup 1) (mem:SI (reg:SI 7)))
18208 (set (reg:SI 7) (plus:SI (reg:SI 7) (const_int 4)))])]
18209 "")
18210
18211(define_peephole2
18212 [(match_scratch:SI 0 "r")
18213 (parallel [(set (reg:SI 7) (plus:SI (reg:SI 7) (const_int 8)))
f2042df3
RH
18214 (clobber (reg:CC 17))
18215 (clobber (mem:BLK (scratch)))])]
bdeb029c
JH
18216 "optimize_size"
18217 [(parallel [(set (match_dup 0) (mem:SI (reg:SI 7)))
18218 (set (reg:SI 7) (plus:SI (reg:SI 7) (const_int 4)))
f2042df3 18219 (clobber (mem:BLK (scratch)))])
bdeb029c
JH
18220 (parallel [(set (match_dup 0) (mem:SI (reg:SI 7)))
18221 (set (reg:SI 7) (plus:SI (reg:SI 7) (const_int 4)))])]
18222 "")
18223
18224;; Convert esp additions to pop.
18225(define_peephole2
18226 [(match_scratch:SI 0 "r")
18227 (parallel [(set (reg:SI 7) (plus:SI (reg:SI 7) (const_int 4)))
18228 (clobber (reg:CC 17))])]
18229 ""
18230 [(parallel [(set (match_dup 0) (mem:SI (reg:SI 7)))
18231 (set (reg:SI 7) (plus:SI (reg:SI 7) (const_int 4)))])]
18232 "")
18233
18234;; Two pops case is tricky, since pop causes dependency on destination register.
18235;; We use two registers if available.
18236(define_peephole2
18237 [(match_scratch:SI 0 "r")
18238 (match_scratch:SI 1 "r")
18239 (parallel [(set (reg:SI 7) (plus:SI (reg:SI 7) (const_int 8)))
18240 (clobber (reg:CC 17))])]
18241 ""
18242 [(parallel [(set (match_dup 0) (mem:SI (reg:SI 7)))
18243 (set (reg:SI 7) (plus:SI (reg:SI 7) (const_int 4)))])
18244 (parallel [(set (match_dup 1) (mem:SI (reg:SI 7)))
18245 (set (reg:SI 7) (plus:SI (reg:SI 7) (const_int 4)))])]
18246 "")
18247
18248(define_peephole2
18249 [(match_scratch:SI 0 "r")
18250 (parallel [(set (reg:SI 7) (plus:SI (reg:SI 7) (const_int 8)))
18251 (clobber (reg:CC 17))])]
18252 "optimize_size"
18253 [(parallel [(set (match_dup 0) (mem:SI (reg:SI 7)))
18254 (set (reg:SI 7) (plus:SI (reg:SI 7) (const_int 4)))])
18255 (parallel [(set (match_dup 0) (mem:SI (reg:SI 7)))
18256 (set (reg:SI 7) (plus:SI (reg:SI 7) (const_int 4)))])]
18257 "")
69404d6f 18258\f
9dcbdc7e
JH
18259;; Convert compares with 1 to shorter inc/dec operations when CF is not
18260;; required and register dies.
18261(define_peephole2
18262 [(set (reg 17)
18263 (compare (match_operand:SI 0 "register_operand" "")
18264 (match_operand:SI 1 "incdec_operand" "")))]
18265 "ix86_match_ccmode (insn, CCGCmode)
18266 && find_regno_note (insn, REG_DEAD, true_regnum (operands[0]))"
18267 [(parallel [(set (reg:CCGC 17)
265dab10 18268 (compare:CCGC (match_dup 0)
7e08e190 18269 (match_dup 1)))
9dcbdc7e 18270 (clobber (match_dup 0))])]
7e08e190 18271 "")
9dcbdc7e
JH
18272
18273(define_peephole2
18274 [(set (reg 17)
18275 (compare (match_operand:HI 0 "register_operand" "")
18276 (match_operand:HI 1 "incdec_operand" "")))]
18277 "ix86_match_ccmode (insn, CCGCmode)
18278 && find_regno_note (insn, REG_DEAD, true_regnum (operands[0]))"
18279 [(parallel [(set (reg:CCGC 17)
265dab10 18280 (compare:CCGC (match_dup 0)
7e08e190 18281 (match_dup 1)))
9dcbdc7e 18282 (clobber (match_dup 0))])]
7e08e190 18283 "")
9dcbdc7e
JH
18284
18285(define_peephole2
18286 [(set (reg 17)
18287 (compare (match_operand:QI 0 "register_operand" "")
18288 (match_operand:QI 1 "incdec_operand" "")))]
18289 "ix86_match_ccmode (insn, CCGCmode)
18290 && find_regno_note (insn, REG_DEAD, true_regnum (operands[0]))"
18291 [(parallel [(set (reg:CCGC 17)
265dab10 18292 (compare:CCGC (match_dup 0)
7e08e190 18293 (match_dup 1)))
9dcbdc7e 18294 (clobber (match_dup 0))])]
7e08e190 18295 "")
9dcbdc7e
JH
18296
18297;; Convert compares with 128 to shorter add -128
18298(define_peephole2
18299 [(set (reg 17)
18300 (compare (match_operand:SI 0 "register_operand" "")
18301 (const_int 128)))]
7e08e190 18302 "ix86_match_ccmode (insn, CCGCmode)
9dcbdc7e 18303 && find_regno_note (insn, REG_DEAD, true_regnum (operands[0]))"
7e08e190
JH
18304 [(parallel [(set (reg:CCGC 17)
18305 (compare:CCGC (match_dup 0)
18306 (const_int 128)))
9dcbdc7e
JH
18307 (clobber (match_dup 0))])]
18308 "")
18309
18310(define_peephole2
18311 [(set (reg 17)
18312 (compare (match_operand:HI 0 "register_operand" "")
18313 (const_int 128)))]
7e08e190 18314 "ix86_match_ccmode (insn, CCGCmode)
9dcbdc7e 18315 && find_regno_note (insn, REG_DEAD, true_regnum (operands[0]))"
7e08e190
JH
18316 [(parallel [(set (reg:CCGC 17)
18317 (compare:CCGC (match_dup 0)
18318 (const_int 128)))
9dcbdc7e
JH
18319 (clobber (match_dup 0))])]
18320 "")
18321\f
cc2e591b
JH
18322(define_peephole2
18323 [(match_scratch:DI 0 "r")
18324 (parallel [(set (reg:DI 7) (plus:DI (reg:DI 7) (const_int -8)))
f2042df3
RH
18325 (clobber (reg:CC 17))
18326 (clobber (mem:BLK (scratch)))])]
cc2e591b
JH
18327 "optimize_size || !TARGET_SUB_ESP_4"
18328 [(clobber (match_dup 0))
18329 (parallel [(set (mem:DI (pre_dec:DI (reg:DI 7))) (match_dup 0))
f2042df3 18330 (clobber (mem:BLK (scratch)))])])
cc2e591b
JH
18331
18332(define_peephole2
18333 [(match_scratch:DI 0 "r")
18334 (parallel [(set (reg:DI 7) (plus:DI (reg:DI 7) (const_int -16)))
f2042df3
RH
18335 (clobber (reg:CC 17))
18336 (clobber (mem:BLK (scratch)))])]
cc2e591b
JH
18337 "optimize_size || !TARGET_SUB_ESP_8"
18338 [(clobber (match_dup 0))
18339 (set (mem:DI (pre_dec:DI (reg:DI 7))) (match_dup 0))
18340 (parallel [(set (mem:DI (pre_dec:DI (reg:DI 7))) (match_dup 0))
f2042df3 18341 (clobber (mem:BLK (scratch)))])])
cc2e591b 18342
f5143c46 18343;; Convert esp subtractions to push.
cc2e591b
JH
18344(define_peephole2
18345 [(match_scratch:DI 0 "r")
18346 (parallel [(set (reg:DI 7) (plus:DI (reg:DI 7) (const_int -8)))
18347 (clobber (reg:CC 17))])]
18348 "optimize_size || !TARGET_SUB_ESP_4"
18349 [(clobber (match_dup 0))
18350 (set (mem:DI (pre_dec:DI (reg:DI 7))) (match_dup 0))])
18351
18352(define_peephole2
18353 [(match_scratch:DI 0 "r")
18354 (parallel [(set (reg:DI 7) (plus:DI (reg:DI 7) (const_int -16)))
18355 (clobber (reg:CC 17))])]
18356 "optimize_size || !TARGET_SUB_ESP_8"
18357 [(clobber (match_dup 0))
18358 (set (mem:DI (pre_dec:DI (reg:DI 7))) (match_dup 0))
18359 (set (mem:DI (pre_dec:DI (reg:DI 7))) (match_dup 0))])
18360
18361;; Convert epilogue deallocator to pop.
18362(define_peephole2
18363 [(match_scratch:DI 0 "r")
18364 (parallel [(set (reg:DI 7) (plus:DI (reg:DI 7) (const_int 8)))
f2042df3
RH
18365 (clobber (reg:CC 17))
18366 (clobber (mem:BLK (scratch)))])]
cc2e591b
JH
18367 "optimize_size || !TARGET_ADD_ESP_4"
18368 [(parallel [(set (match_dup 0) (mem:DI (reg:DI 7)))
18369 (set (reg:DI 7) (plus:DI (reg:DI 7) (const_int 8)))
f2042df3 18370 (clobber (mem:BLK (scratch)))])]
cc2e591b
JH
18371 "")
18372
18373;; Two pops case is tricky, since pop causes dependency on destination register.
18374;; We use two registers if available.
18375(define_peephole2
18376 [(match_scratch:DI 0 "r")
18377 (match_scratch:DI 1 "r")
18378 (parallel [(set (reg:DI 7) (plus:DI (reg:DI 7) (const_int 16)))
f2042df3
RH
18379 (clobber (reg:CC 17))
18380 (clobber (mem:BLK (scratch)))])]
cc2e591b
JH
18381 "optimize_size || !TARGET_ADD_ESP_8"
18382 [(parallel [(set (match_dup 0) (mem:DI (reg:DI 7)))
18383 (set (reg:DI 7) (plus:DI (reg:DI 7) (const_int 8)))
f2042df3 18384 (clobber (mem:BLK (scratch)))])
cc2e591b
JH
18385 (parallel [(set (match_dup 1) (mem:DI (reg:DI 7)))
18386 (set (reg:DI 7) (plus:DI (reg:DI 7) (const_int 8)))])]
18387 "")
18388
18389(define_peephole2
18390 [(match_scratch:DI 0 "r")
18391 (parallel [(set (reg:DI 7) (plus:DI (reg:DI 7) (const_int 16)))
f2042df3
RH
18392 (clobber (reg:CC 17))
18393 (clobber (mem:BLK (scratch)))])]
cc2e591b
JH
18394 "optimize_size"
18395 [(parallel [(set (match_dup 0) (mem:DI (reg:DI 7)))
18396 (set (reg:DI 7) (plus:DI (reg:DI 7) (const_int 8)))
f2042df3 18397 (clobber (mem:BLK (scratch)))])
cc2e591b
JH
18398 (parallel [(set (match_dup 0) (mem:DI (reg:DI 7)))
18399 (set (reg:DI 7) (plus:DI (reg:DI 7) (const_int 8)))])]
18400 "")
18401
18402;; Convert esp additions to pop.
18403(define_peephole2
18404 [(match_scratch:DI 0 "r")
18405 (parallel [(set (reg:DI 7) (plus:DI (reg:DI 7) (const_int 8)))
18406 (clobber (reg:CC 17))])]
18407 ""
18408 [(parallel [(set (match_dup 0) (mem:DI (reg:DI 7)))
18409 (set (reg:DI 7) (plus:DI (reg:DI 7) (const_int 8)))])]
18410 "")
18411
18412;; Two pops case is tricky, since pop causes dependency on destination register.
18413;; We use two registers if available.
18414(define_peephole2
18415 [(match_scratch:DI 0 "r")
18416 (match_scratch:DI 1 "r")
18417 (parallel [(set (reg:DI 7) (plus:DI (reg:DI 7) (const_int 16)))
18418 (clobber (reg:CC 17))])]
18419 ""
18420 [(parallel [(set (match_dup 0) (mem:DI (reg:DI 7)))
18421 (set (reg:DI 7) (plus:DI (reg:DI 7) (const_int 8)))])
18422 (parallel [(set (match_dup 1) (mem:DI (reg:DI 7)))
18423 (set (reg:DI 7) (plus:DI (reg:DI 7) (const_int 8)))])]
18424 "")
18425
18426(define_peephole2
18427 [(match_scratch:DI 0 "r")
18428 (parallel [(set (reg:DI 7) (plus:DI (reg:DI 7) (const_int 16)))
18429 (clobber (reg:CC 17))])]
18430 "optimize_size"
18431 [(parallel [(set (match_dup 0) (mem:DI (reg:DI 7)))
18432 (set (reg:DI 7) (plus:DI (reg:DI 7) (const_int 8)))])
18433 (parallel [(set (match_dup 0) (mem:DI (reg:DI 7)))
18434 (set (reg:DI 7) (plus:DI (reg:DI 7) (const_int 8)))])]
18435 "")
18436\f
f56e86bd
JH
18437;; Imul $32bit_imm, mem, reg is vector decoded, while
18438;; imul $32bit_imm, reg, reg is direct decoded.
18439(define_peephole2
18440 [(match_scratch:DI 3 "r")
18441 (parallel [(set (match_operand:DI 0 "register_operand" "")
18442 (mult:DI (match_operand:DI 1 "memory_operand" "")
18443 (match_operand:DI 2 "immediate_operand" "")))
18444 (clobber (reg:CC 17))])]
18445 "TARGET_K8 && !optimize_size
18446 && (GET_CODE (operands[2]) != CONST_INT
18447 || !CONST_OK_FOR_LETTER_P (INTVAL (operands[2]), 'K'))"
18448 [(set (match_dup 3) (match_dup 1))
18449 (parallel [(set (match_dup 0) (mult:DI (match_dup 3) (match_dup 2)))
18450 (clobber (reg:CC 17))])]
18451"")
18452
18453(define_peephole2
18454 [(match_scratch:SI 3 "r")
18455 (parallel [(set (match_operand:SI 0 "register_operand" "")
18456 (mult:SI (match_operand:SI 1 "memory_operand" "")
18457 (match_operand:SI 2 "immediate_operand" "")))
18458 (clobber (reg:CC 17))])]
18459 "TARGET_K8 && !optimize_size
18460 && (GET_CODE (operands[2]) != CONST_INT
18461 || !CONST_OK_FOR_LETTER_P (INTVAL (operands[2]), 'K'))"
18462 [(set (match_dup 3) (match_dup 1))
18463 (parallel [(set (match_dup 0) (mult:SI (match_dup 3) (match_dup 2)))
18464 (clobber (reg:CC 17))])]
18465"")
18466
18467(define_peephole2
18468 [(match_scratch:SI 3 "r")
18469 (parallel [(set (match_operand:DI 0 "register_operand" "")
18470 (zero_extend:DI
18471 (mult:SI (match_operand:SI 1 "memory_operand" "")
18472 (match_operand:SI 2 "immediate_operand" ""))))
18473 (clobber (reg:CC 17))])]
18474 "TARGET_K8 && !optimize_size
18475 && (GET_CODE (operands[2]) != CONST_INT
18476 || !CONST_OK_FOR_LETTER_P (INTVAL (operands[2]), 'K'))"
18477 [(set (match_dup 3) (match_dup 1))
18478 (parallel [(set (match_dup 0) (zero_extend:DI (mult:SI (match_dup 3) (match_dup 2))))
18479 (clobber (reg:CC 17))])]
18480"")
18481
18482;; imul $8/16bit_imm, regmem, reg is vector decoded.
18483;; Convert it into imul reg, reg
18484;; It would be better to force assembler to encode instruction using long
18485;; immediate, but there is apparently no way to do so.
18486(define_peephole2
18487 [(parallel [(set (match_operand:DI 0 "register_operand" "")
18488 (mult:DI (match_operand:DI 1 "nonimmediate_operand" "")
18489 (match_operand:DI 2 "const_int_operand" "")))
18490 (clobber (reg:CC 17))])
18491 (match_scratch:DI 3 "r")]
18492 "TARGET_K8 && !optimize_size
18493 && CONST_OK_FOR_LETTER_P (INTVAL (operands[2]), 'K')"
18494 [(set (match_dup 3) (match_dup 2))
18495 (parallel [(set (match_dup 0) (mult:DI (match_dup 0) (match_dup 3)))
18496 (clobber (reg:CC 17))])]
18497{
18498 if (!rtx_equal_p (operands[0], operands[1]))
18499 emit_move_insn (operands[0], operands[1]);
18500})
18501
18502(define_peephole2
18503 [(parallel [(set (match_operand:SI 0 "register_operand" "")
18504 (mult:SI (match_operand:SI 1 "nonimmediate_operand" "")
18505 (match_operand:SI 2 "const_int_operand" "")))
18506 (clobber (reg:CC 17))])
18507 (match_scratch:SI 3 "r")]
18508 "TARGET_K8 && !optimize_size
18509 && CONST_OK_FOR_LETTER_P (INTVAL (operands[2]), 'K')"
18510 [(set (match_dup 3) (match_dup 2))
18511 (parallel [(set (match_dup 0) (mult:SI (match_dup 0) (match_dup 3)))
18512 (clobber (reg:CC 17))])]
18513{
18514 if (!rtx_equal_p (operands[0], operands[1]))
18515 emit_move_insn (operands[0], operands[1]);
18516})
18517
18518(define_peephole2
18519 [(parallel [(set (match_operand:HI 0 "register_operand" "")
18520 (mult:HI (match_operand:HI 1 "nonimmediate_operand" "")
18521 (match_operand:HI 2 "immediate_operand" "")))
18522 (clobber (reg:CC 17))])
18523 (match_scratch:HI 3 "r")]
18524 "TARGET_K8 && !optimize_size"
18525 [(set (match_dup 3) (match_dup 2))
18526 (parallel [(set (match_dup 0) (mult:HI (match_dup 0) (match_dup 3)))
18527 (clobber (reg:CC 17))])]
18528{
18529 if (!rtx_equal_p (operands[0], operands[1]))
18530 emit_move_insn (operands[0], operands[1]);
18531})
18532\f
69404d6f
RH
18533;; Call-value patterns last so that the wildcard operand does not
18534;; disrupt insn-recog's switch tables.
18535
94bb5d0c
RH
18536(define_insn "*call_value_pop_0"
18537 [(set (match_operand 0 "" "")
e1ff012c 18538 (call (mem:QI (match_operand:SI 1 "constant_call_address_operand" ""))
94bb5d0c
RH
18539 (match_operand:SI 2 "" "")))
18540 (set (reg:SI 7) (plus:SI (reg:SI 7)
90d10fb9 18541 (match_operand:SI 3 "immediate_operand" "")))]
1e07edd3 18542 "!TARGET_64BIT"
94bb5d0c
RH
18543{
18544 if (SIBLING_CALL_P (insn))
0f40f9f7 18545 return "jmp\t%P1";
94bb5d0c 18546 else
0f40f9f7
ZW
18547 return "call\t%P1";
18548}
94bb5d0c
RH
18549 [(set_attr "type" "callv")])
18550
69404d6f
RH
18551(define_insn "*call_value_pop_1"
18552 [(set (match_operand 0 "" "")
e1ff012c 18553 (call (mem:QI (match_operand:SI 1 "call_insn_operand" "rsm"))
94bb5d0c 18554 (match_operand:SI 2 "" "")))
69404d6f 18555 (set (reg:SI 7) (plus:SI (reg:SI 7)
90d10fb9 18556 (match_operand:SI 3 "immediate_operand" "i")))]
1e07edd3 18557 "!TARGET_64BIT"
69404d6f 18558{
94bb5d0c
RH
18559 if (constant_call_address_operand (operands[1], QImode))
18560 {
18561 if (SIBLING_CALL_P (insn))
0f40f9f7 18562 return "jmp\t%P1";
94bb5d0c 18563 else
0f40f9f7 18564 return "call\t%P1";
94bb5d0c 18565 }
94bb5d0c 18566 if (SIBLING_CALL_P (insn))
0f40f9f7 18567 return "jmp\t%A1";
94bb5d0c 18568 else
0f40f9f7
ZW
18569 return "call\t%A1";
18570}
94bb5d0c
RH
18571 [(set_attr "type" "callv")])
18572
18573(define_insn "*call_value_0"
18574 [(set (match_operand 0 "" "")
e1ff012c 18575 (call (mem:QI (match_operand:SI 1 "constant_call_address_operand" ""))
94bb5d0c 18576 (match_operand:SI 2 "" "")))]
32ee7d1d 18577 "!TARGET_64BIT"
32ee7d1d
JH
18578{
18579 if (SIBLING_CALL_P (insn))
0f40f9f7 18580 return "jmp\t%P1";
32ee7d1d 18581 else
0f40f9f7
ZW
18582 return "call\t%P1";
18583}
32ee7d1d
JH
18584 [(set_attr "type" "callv")])
18585
18586(define_insn "*call_value_0_rex64"
18587 [(set (match_operand 0 "" "")
18588 (call (mem:QI (match_operand:DI 1 "constant_call_address_operand" ""))
18589 (match_operand:DI 2 "const_int_operand" "")))]
18590 "TARGET_64BIT"
94bb5d0c
RH
18591{
18592 if (SIBLING_CALL_P (insn))
0f40f9f7 18593 return "jmp\t%P1";
94bb5d0c 18594 else
0f40f9f7
ZW
18595 return "call\t%P1";
18596}
69404d6f
RH
18597 [(set_attr "type" "callv")])
18598
69404d6f
RH
18599(define_insn "*call_value_1"
18600 [(set (match_operand 0 "" "")
e1ff012c 18601 (call (mem:QI (match_operand:SI 1 "call_insn_operand" "rsm"))
94bb5d0c 18602 (match_operand:SI 2 "" "")))]
4977bab6 18603 "!SIBLING_CALL_P (insn) && !TARGET_64BIT"
32ee7d1d
JH
18604{
18605 if (constant_call_address_operand (operands[1], QImode))
4977bab6
ZW
18606 return "call\t%P1";
18607 return "call\t%*%1";
18608}
18609 [(set_attr "type" "callv")])
18610
18611(define_insn "*sibcall_value_1"
18612 [(set (match_operand 0 "" "")
18613 (call (mem:QI (match_operand:SI 1 "sibcall_insn_operand" "s,c,d,a"))
18614 (match_operand:SI 2 "" "")))]
18615 "SIBLING_CALL_P (insn) && !TARGET_64BIT"
18616{
18617 if (constant_call_address_operand (operands[1], QImode))
18618 return "jmp\t%P1";
18619 return "jmp\t%*%1";
0f40f9f7 18620}
32ee7d1d
JH
18621 [(set_attr "type" "callv")])
18622
18623(define_insn "*call_value_1_rex64"
18624 [(set (match_operand 0 "" "")
18625 (call (mem:QI (match_operand:DI 1 "call_insn_operand" "rsm"))
18626 (match_operand:DI 2 "" "")))]
4977bab6 18627 "!SIBLING_CALL_P (insn) && TARGET_64BIT"
69404d6f 18628{
94bb5d0c 18629 if (constant_call_address_operand (operands[1], QImode))
4977bab6
ZW
18630 return "call\t%P1";
18631 return "call\t%A1";
0f40f9f7 18632}
69404d6f 18633 [(set_attr "type" "callv")])
4977bab6
ZW
18634
18635(define_insn "*sibcall_value_1_rex64"
18636 [(set (match_operand 0 "" "")
18637 (call (mem:QI (match_operand:DI 1 "constant_call_address_operand" ""))
18638 (match_operand:DI 2 "" "")))]
18639 "SIBLING_CALL_P (insn) && TARGET_64BIT"
18640 "jmp\t%P1"
18641 [(set_attr "type" "callv")])
18642
18643(define_insn "*sibcall_value_1_rex64_v"
18644 [(set (match_operand 0 "" "")
18645 (call (mem:QI (reg:DI 40))
18646 (match_operand:DI 1 "" "")))]
18647 "SIBLING_CALL_P (insn) && TARGET_64BIT"
18648 "jmp\t*%%r11"
18649 [(set_attr "type" "callv")])
9e3e266c
GM
18650\f
18651(define_insn "trap"
18652 [(trap_if (const_int 1) (const_int 5))]
18653 ""
0f40f9f7 18654 "int\t$5")
9e3e266c
GM
18655
18656;;; ix86 doesn't have conditional trap instructions, but we fake them
18657;;; for the sake of bounds checking. By emitting bounds checks as
18658;;; conditional traps rather than as conditional jumps around
18659;;; unconditional traps we avoid introducing spurious basic-block
18660;;; boundaries and facilitate elimination of redundant checks. In
18661;;; honor of the too-inflexible-for-BPs `bound' instruction, we use
18662;;; interrupt 5.
18663;;;
18664;;; FIXME: Static branch prediction rules for ix86 are such that
18665;;; forward conditional branches predict as untaken. As implemented
18666;;; below, pseudo conditional traps violate that rule. We should use
18667;;; .pushsection/.popsection to place all of the `int 5's in a special
18668;;; section loaded at the end of the text segment and branch forward
18669;;; there on bounds-failure, and then jump back immediately (in case
18670;;; the system chooses to ignore bounds violations, or to report
18671;;; violations and continue execution).
18672
18673(define_expand "conditional_trap"
18674 [(trap_if (match_operator 0 "comparison_operator"
18675 [(match_dup 2) (const_int 0)])
18676 (match_operand 1 "const_int_operand" ""))]
18677 ""
9e3e266c
GM
18678{
18679 emit_insn (gen_rtx_TRAP_IF (VOIDmode,
a1b8572c 18680 ix86_expand_compare (GET_CODE (operands[0]),
df4ae160 18681 NULL, NULL),
9e3e266c
GM
18682 operands[1]));
18683 DONE;
0f40f9f7 18684})
9e3e266c 18685
0f40f9f7 18686(define_insn "*conditional_trap_1"
9e3e266c
GM
18687 [(trap_if (match_operator 0 "comparison_operator"
18688 [(reg 17) (const_int 0)])
18689 (match_operand 1 "const_int_operand" ""))]
18690 ""
9e3e266c
GM
18691{
18692 operands[2] = gen_label_rtx ();
0f40f9f7 18693 output_asm_insn ("j%c0\t%l2\; int\t%1", operands);
4977bab6 18694 (*targetm.asm_out.internal_label) (asm_out_file, "L",
9e3e266c
GM
18695 CODE_LABEL_NUMBER (operands[2]));
18696 RET;
0f40f9f7 18697})
915119a5
BS
18698
18699 ;; Pentium III SIMD instructions.
18700
18701;; Moves for SSE/MMX regs.
18702
18703(define_insn "movv4sf_internal"
fdc4b40b
JH
18704 [(set (match_operand:V4SF 0 "nonimmediate_operand" "=x,x,m")
18705 (match_operand:V4SF 1 "vector_move_operand" "C,xm,x"))]
915119a5 18706 "TARGET_SSE"
fdc4b40b
JH
18707 "@
18708 xorps\t%0, %0
18709 movaps\t{%1, %0|%0, %1}
18710 movaps\t{%1, %0|%0, %1}"
3d34cd91
JH
18711 [(set_attr "type" "ssemov")
18712 (set_attr "mode" "V4SF")])
915119a5 18713
4977bab6
ZW
18714(define_split
18715 [(set (match_operand:V4SF 0 "register_operand" "")
18716 (match_operand:V4SF 1 "zero_extended_scalar_load_operand" ""))]
18717 "TARGET_SSE"
18718 [(set (match_dup 0)
18719 (vec_merge:V4SF
18720 (vec_duplicate:V4SF (match_dup 1))
18721 (match_dup 2)
18722 (const_int 1)))]
18723{
18724 operands[1] = simplify_gen_subreg (SFmode, operands[1], V4SFmode, 0);
18725 operands[2] = CONST0_RTX (V4SFmode);
18726})
18727
915119a5 18728(define_insn "movv4si_internal"
fdc4b40b
JH
18729 [(set (match_operand:V4SI 0 "nonimmediate_operand" "=x,x,m")
18730 (match_operand:V4SI 1 "vector_move_operand" "C,xm,x"))]
915119a5 18731 "TARGET_SSE"
4977bab6 18732{
fdc4b40b
JH
18733 switch (which_alternative)
18734 {
18735 case 0:
18736 if (get_attr_mode (insn) == MODE_V4SF)
18737 return "xorps\t%0, %0";
18738 else
18739 return "pxor\t%0, %0";
18740 case 1:
18741 case 2:
18742 if (get_attr_mode (insn) == MODE_V4SF)
18743 return "movaps\t{%1, %0|%0, %1}";
18744 else
18745 return "movdqa\t{%1, %0|%0, %1}";
18746 default:
18747 abort ();
18748 }
4977bab6 18749}
3d34cd91 18750 [(set_attr "type" "ssemov")
4977bab6 18751 (set (attr "mode")
fdc4b40b 18752 (cond [(eq_attr "alternative" "0,1")
4977bab6
ZW
18753 (if_then_else
18754 (ne (symbol_ref "optimize_size")
18755 (const_int 0))
18756 (const_string "V4SF")
18757 (const_string "TI"))
fdc4b40b 18758 (eq_attr "alternative" "2")
4977bab6
ZW
18759 (if_then_else
18760 (ior (ne (symbol_ref "TARGET_SSE_TYPELESS_STORES")
18761 (const_int 0))
18762 (ne (symbol_ref "optimize_size")
18763 (const_int 0)))
18764 (const_string "V4SF")
18765 (const_string "TI"))]
18766 (const_string "TI")))])
915119a5 18767
1877be45 18768(define_insn "movv2di_internal"
fdc4b40b
JH
18769 [(set (match_operand:V2DI 0 "nonimmediate_operand" "=x,x,m")
18770 (match_operand:V2DI 1 "vector_move_operand" "C,xm,x"))]
4977bab6
ZW
18771 "TARGET_SSE2"
18772{
fdc4b40b
JH
18773 switch (which_alternative)
18774 {
18775 case 0:
18776 if (get_attr_mode (insn) == MODE_V4SF)
18777 return "xorps\t%0, %0";
18778 else
18779 return "pxor\t%0, %0";
18780 case 1:
18781 case 2:
18782 if (get_attr_mode (insn) == MODE_V4SF)
18783 return "movaps\t{%1, %0|%0, %1}";
18784 else
18785 return "movdqa\t{%1, %0|%0, %1}";
18786 default:
18787 abort ();
18788 }
4977bab6 18789}
1877be45 18790 [(set_attr "type" "ssemov")
4977bab6 18791 (set (attr "mode")
fdc4b40b 18792 (cond [(eq_attr "alternative" "0,1")
4977bab6
ZW
18793 (if_then_else
18794 (ne (symbol_ref "optimize_size")
18795 (const_int 0))
18796 (const_string "V4SF")
18797 (const_string "TI"))
fdc4b40b 18798 (eq_attr "alternative" "2")
4977bab6
ZW
18799 (if_then_else
18800 (ior (ne (symbol_ref "TARGET_SSE_TYPELESS_STORES")
18801 (const_int 0))
18802 (ne (symbol_ref "optimize_size")
18803 (const_int 0)))
18804 (const_string "V4SF")
18805 (const_string "TI"))]
18806 (const_string "TI")))])
18807
18808(define_split
18809 [(set (match_operand:V2DF 0 "register_operand" "")
18810 (match_operand:V2DF 1 "zero_extended_scalar_load_operand" ""))]
18811 "TARGET_SSE2"
18812 [(set (match_dup 0)
18813 (vec_merge:V2DF
18814 (vec_duplicate:V2DF (match_dup 1))
18815 (match_dup 2)
18816 (const_int 1)))]
18817{
18818 operands[1] = simplify_gen_subreg (DFmode, operands[1], V2DFmode, 0);
18819 operands[2] = CONST0_RTX (V2DFmode);
18820})
1877be45 18821
915119a5 18822(define_insn "movv8qi_internal"
fdc4b40b
JH
18823 [(set (match_operand:V8QI 0 "nonimmediate_operand" "=y,y,m")
18824 (match_operand:V8QI 1 "vector_move_operand" "C,ym,y"))]
7f0e57bd
JH
18825 "TARGET_MMX
18826 && (GET_CODE (operands[0]) != MEM || GET_CODE (operands[1]) != MEM)"
fdc4b40b
JH
18827 "@
18828 pxor\t%0, %0
18829 movq\t{%1, %0|%0, %1}
18830 movq\t{%1, %0|%0, %1}"
3d34cd91
JH
18831 [(set_attr "type" "mmxmov")
18832 (set_attr "mode" "DI")])
915119a5
BS
18833
18834(define_insn "movv4hi_internal"
fdc4b40b
JH
18835 [(set (match_operand:V4HI 0 "nonimmediate_operand" "=y,y,m")
18836 (match_operand:V4HI 1 "vector_move_operand" "C,ym,y"))]
7f0e57bd
JH
18837 "TARGET_MMX
18838 && (GET_CODE (operands[0]) != MEM || GET_CODE (operands[1]) != MEM)"
fdc4b40b
JH
18839 "@
18840 pxor\t%0, %0
18841 movq\t{%1, %0|%0, %1}
18842 movq\t{%1, %0|%0, %1}"
3d34cd91
JH
18843 [(set_attr "type" "mmxmov")
18844 (set_attr "mode" "DI")])
915119a5
BS
18845
18846(define_insn "movv2si_internal"
fdc4b40b
JH
18847 [(set (match_operand:V2SI 0 "nonimmediate_operand" "=y,y,m")
18848 (match_operand:V2SI 1 "vector_move_operand" "C,ym,y"))]
7f0e57bd
JH
18849 "TARGET_MMX
18850 && (GET_CODE (operands[0]) != MEM || GET_CODE (operands[1]) != MEM)"
fdc4b40b
JH
18851 "@
18852 pxor\t%0, %0
18853 movq\t{%1, %0|%0, %1}
18854 movq\t{%1, %0|%0, %1}"
3d34cd91
JH
18855 [(set_attr "type" "mmxcvt")
18856 (set_attr "mode" "DI")])
915119a5 18857
47f339cf 18858(define_insn "movv2sf_internal"
fdc4b40b
JH
18859 [(set (match_operand:V2SF 0 "nonimmediate_operand" "=y,y,m")
18860 (match_operand:V2SF 1 "vector_move_operand" "C,ym,y"))]
7f0e57bd
JH
18861 "TARGET_3DNOW
18862 && (GET_CODE (operands[0]) != MEM || GET_CODE (operands[1]) != MEM)"
fdc4b40b
JH
18863 "@
18864 pxor\t%0, %0
18865 movq\t{%1, %0|%0, %1}
18866 movq\t{%1, %0|%0, %1}"
3d34cd91
JH
18867 [(set_attr "type" "mmxcvt")
18868 (set_attr "mode" "DI")])
47f339cf 18869
915119a5 18870(define_expand "movti"
7f0e57bd
JH
18871 [(set (match_operand:TI 0 "nonimmediate_operand" "")
18872 (match_operand:TI 1 "nonimmediate_operand" ""))]
44cf5b6a 18873 "TARGET_SSE || TARGET_64BIT"
915119a5 18874{
44cf5b6a 18875 if (TARGET_64BIT)
e37af218
RH
18876 ix86_expand_move (TImode, operands);
18877 else
18878 ix86_expand_vector_move (TImode, operands);
18879 DONE;
0f40f9f7 18880})
915119a5 18881
fbe5eb6d 18882(define_insn "movv2df_internal"
fdc4b40b
JH
18883 [(set (match_operand:V2DF 0 "nonimmediate_operand" "=x,x,m")
18884 (match_operand:V2DF 1 "vector_move_operand" "C,xm,x"))]
7f0e57bd
JH
18885 "TARGET_SSE2
18886 && (GET_CODE (operands[0]) != MEM || GET_CODE (operands[1]) != MEM)"
4977bab6 18887{
fdc4b40b
JH
18888 switch (which_alternative)
18889 {
18890 case 0:
18891 if (get_attr_mode (insn) == MODE_V4SF)
18892 return "xorps\t%0, %0";
18893 else
18894 return "xorpd\t%0, %0";
18895 case 1:
18896 case 2:
18897 if (get_attr_mode (insn) == MODE_V4SF)
18898 return "movaps\t{%1, %0|%0, %1}";
18899 else
18900 return "movapd\t{%1, %0|%0, %1}";
18901 default:
18902 abort ();
18903 }
4977bab6 18904}
3d34cd91 18905 [(set_attr "type" "ssemov")
4977bab6 18906 (set (attr "mode")
fdc4b40b 18907 (cond [(eq_attr "alternative" "0,1")
4977bab6
ZW
18908 (if_then_else
18909 (ne (symbol_ref "optimize_size")
18910 (const_int 0))
18911 (const_string "V4SF")
18912 (const_string "V2DF"))
fdc4b40b 18913 (eq_attr "alternative" "2")
4977bab6
ZW
18914 (if_then_else
18915 (ior (ne (symbol_ref "TARGET_SSE_TYPELESS_STORES")
18916 (const_int 0))
18917 (ne (symbol_ref "optimize_size")
18918 (const_int 0)))
18919 (const_string "V4SF")
18920 (const_string "V2DF"))]
18921 (const_string "V2DF")))])
fbe5eb6d
BS
18922
18923(define_insn "movv8hi_internal"
fdc4b40b
JH
18924 [(set (match_operand:V8HI 0 "nonimmediate_operand" "=x,x,m")
18925 (match_operand:V8HI 1 "vector_move_operand" "C,xm,x"))]
7f0e57bd
JH
18926 "TARGET_SSE2
18927 && (GET_CODE (operands[0]) != MEM || GET_CODE (operands[1]) != MEM)"
4977bab6 18928{
fdc4b40b
JH
18929 switch (which_alternative)
18930 {
18931 case 0:
18932 if (get_attr_mode (insn) == MODE_V4SF)
18933 return "xorps\t%0, %0";
18934 else
18935 return "pxor\t%0, %0";
18936 case 1:
18937 case 2:
18938 if (get_attr_mode (insn) == MODE_V4SF)
18939 return "movaps\t{%1, %0|%0, %1}";
18940 else
18941 return "movdqa\t{%1, %0|%0, %1}";
18942 default:
18943 abort ();
18944 }
4977bab6 18945}
3d34cd91 18946 [(set_attr "type" "ssemov")
4977bab6 18947 (set (attr "mode")
fdc4b40b 18948 (cond [(eq_attr "alternative" "0,1")
4977bab6
ZW
18949 (if_then_else
18950 (ne (symbol_ref "optimize_size")
18951 (const_int 0))
18952 (const_string "V4SF")
18953 (const_string "TI"))
fdc4b40b 18954 (eq_attr "alternative" "2")
4977bab6
ZW
18955 (if_then_else
18956 (ior (ne (symbol_ref "TARGET_SSE_TYPELESS_STORES")
18957 (const_int 0))
18958 (ne (symbol_ref "optimize_size")
18959 (const_int 0)))
18960 (const_string "V4SF")
18961 (const_string "TI"))]
18962 (const_string "TI")))])
fbe5eb6d
BS
18963
18964(define_insn "movv16qi_internal"
fdc4b40b
JH
18965 [(set (match_operand:V16QI 0 "nonimmediate_operand" "=x,x,m")
18966 (match_operand:V16QI 1 "nonimmediate_operand" "C,xm,x"))]
7f0e57bd
JH
18967 "TARGET_SSE2
18968 && (GET_CODE (operands[0]) != MEM || GET_CODE (operands[1]) != MEM)"
4977bab6 18969{
fdc4b40b
JH
18970 switch (which_alternative)
18971 {
18972 case 0:
18973 if (get_attr_mode (insn) == MODE_V4SF)
18974 return "xorps\t%0, %0";
18975 else
18976 return "pxor\t%0, %0";
18977 case 1:
18978 case 2:
18979 if (get_attr_mode (insn) == MODE_V4SF)
18980 return "movaps\t{%1, %0|%0, %1}";
18981 else
18982 return "movdqa\t{%1, %0|%0, %1}";
18983 default:
18984 abort ();
18985 }
4977bab6 18986}
3d34cd91 18987 [(set_attr "type" "ssemov")
4977bab6 18988 (set (attr "mode")
fdc4b40b 18989 (cond [(eq_attr "alternative" "0,1")
4977bab6
ZW
18990 (if_then_else
18991 (ne (symbol_ref "optimize_size")
18992 (const_int 0))
18993 (const_string "V4SF")
18994 (const_string "TI"))
fdc4b40b 18995 (eq_attr "alternative" "2")
4977bab6
ZW
18996 (if_then_else
18997 (ior (ne (symbol_ref "TARGET_SSE_TYPELESS_STORES")
18998 (const_int 0))
18999 (ne (symbol_ref "optimize_size")
19000 (const_int 0)))
19001 (const_string "V4SF")
19002 (const_string "TI"))]
19003 (const_string "TI")))])
fbe5eb6d
BS
19004
19005(define_expand "movv2df"
7f0e57bd
JH
19006 [(set (match_operand:V2DF 0 "nonimmediate_operand" "")
19007 (match_operand:V2DF 1 "nonimmediate_operand" ""))]
fbe5eb6d
BS
19008 "TARGET_SSE2"
19009{
19010 ix86_expand_vector_move (V2DFmode, operands);
19011 DONE;
19012})
19013
19014(define_expand "movv8hi"
7f0e57bd
JH
19015 [(set (match_operand:V8HI 0 "nonimmediate_operand" "")
19016 (match_operand:V8HI 1 "nonimmediate_operand" ""))]
fbe5eb6d
BS
19017 "TARGET_SSE2"
19018{
19019 ix86_expand_vector_move (V8HImode, operands);
19020 DONE;
19021})
19022
19023(define_expand "movv16qi"
7f0e57bd
JH
19024 [(set (match_operand:V16QI 0 "nonimmediate_operand" "")
19025 (match_operand:V16QI 1 "nonimmediate_operand" ""))]
fbe5eb6d
BS
19026 "TARGET_SSE2"
19027{
19028 ix86_expand_vector_move (V16QImode, operands);
19029 DONE;
19030})
19031
915119a5 19032(define_expand "movv4sf"
7f0e57bd
JH
19033 [(set (match_operand:V4SF 0 "nonimmediate_operand" "")
19034 (match_operand:V4SF 1 "nonimmediate_operand" ""))]
915119a5 19035 "TARGET_SSE"
915119a5 19036{
e37af218
RH
19037 ix86_expand_vector_move (V4SFmode, operands);
19038 DONE;
0f40f9f7 19039})
915119a5
BS
19040
19041(define_expand "movv4si"
7f0e57bd
JH
19042 [(set (match_operand:V4SI 0 "nonimmediate_operand" "")
19043 (match_operand:V4SI 1 "nonimmediate_operand" ""))]
1877be45 19044 "TARGET_SSE"
915119a5 19045{
e37af218
RH
19046 ix86_expand_vector_move (V4SImode, operands);
19047 DONE;
0f40f9f7 19048})
915119a5 19049
1877be45 19050(define_expand "movv2di"
7f0e57bd
JH
19051 [(set (match_operand:V2DI 0 "nonimmediate_operand" "")
19052 (match_operand:V2DI 1 "nonimmediate_operand" ""))]
1877be45
JH
19053 "TARGET_SSE"
19054{
19055 ix86_expand_vector_move (V2DImode, operands);
19056 DONE;
19057})
19058
915119a5 19059(define_expand "movv2si"
7f0e57bd
JH
19060 [(set (match_operand:V2SI 0 "nonimmediate_operand" "")
19061 (match_operand:V2SI 1 "nonimmediate_operand" ""))]
915119a5 19062 "TARGET_MMX"
915119a5 19063{
e37af218
RH
19064 ix86_expand_vector_move (V2SImode, operands);
19065 DONE;
0f40f9f7 19066})
915119a5
BS
19067
19068(define_expand "movv4hi"
7f0e57bd
JH
19069 [(set (match_operand:V4HI 0 "nonimmediate_operand" "")
19070 (match_operand:V4HI 1 "nonimmediate_operand" ""))]
915119a5 19071 "TARGET_MMX"
915119a5 19072{
e37af218
RH
19073 ix86_expand_vector_move (V4HImode, operands);
19074 DONE;
0f40f9f7 19075})
915119a5
BS
19076
19077(define_expand "movv8qi"
7f0e57bd
JH
19078 [(set (match_operand:V8QI 0 "nonimmediate_operand" "")
19079 (match_operand:V8QI 1 "nonimmediate_operand" ""))]
915119a5 19080 "TARGET_MMX"
915119a5 19081{
e37af218
RH
19082 ix86_expand_vector_move (V8QImode, operands);
19083 DONE;
0f40f9f7 19084})
915119a5 19085
47f339cf 19086(define_expand "movv2sf"
7f0e57bd
JH
19087 [(set (match_operand:V2SF 0 "nonimmediate_operand" "")
19088 (match_operand:V2SF 1 "nonimmediate_operand" ""))]
47f339cf 19089 "TARGET_3DNOW"
47f339cf 19090{
e37af218
RH
19091 ix86_expand_vector_move (V2SFmode, operands);
19092 DONE;
19093})
47f339cf 19094
7f0e57bd 19095(define_insn "*pushti"
915119a5 19096 [(set (match_operand:TI 0 "push_operand" "=<")
7f0e57bd 19097 (match_operand:TI 1 "register_operand" "x"))]
915119a5 19098 "TARGET_SSE"
7f0e57bd 19099 "#")
915119a5 19100
7f0e57bd 19101(define_insn "*pushv2df"
fbe5eb6d 19102 [(set (match_operand:V2DF 0 "push_operand" "=<")
7f0e57bd
JH
19103 (match_operand:V2DF 1 "register_operand" "x"))]
19104 "TARGET_SSE"
19105 "#")
fbe5eb6d 19106
7f0e57bd 19107(define_insn "*pushv2di"
a00782ed 19108 [(set (match_operand:V2DI 0 "push_operand" "=<")
7f0e57bd 19109 (match_operand:V2DI 1 "register_operand" "x"))]
a00782ed 19110 "TARGET_SSE2"
7f0e57bd 19111 "#")
a00782ed 19112
7f0e57bd 19113(define_insn "*pushv8hi"
fbe5eb6d 19114 [(set (match_operand:V8HI 0 "push_operand" "=<")
7f0e57bd 19115 (match_operand:V8HI 1 "register_operand" "x"))]
fbe5eb6d 19116 "TARGET_SSE2"
7f0e57bd 19117 "#")
fbe5eb6d 19118
7f0e57bd 19119(define_insn "*pushv16qi"
fbe5eb6d 19120 [(set (match_operand:V16QI 0 "push_operand" "=<")
7f0e57bd 19121 (match_operand:V16QI 1 "register_operand" "x"))]
fbe5eb6d 19122 "TARGET_SSE2"
7f0e57bd 19123 "#")
fbe5eb6d 19124
7f0e57bd 19125(define_insn "*pushv4sf"
915119a5 19126 [(set (match_operand:V4SF 0 "push_operand" "=<")
7f0e57bd 19127 (match_operand:V4SF 1 "register_operand" "x"))]
915119a5 19128 "TARGET_SSE"
7f0e57bd 19129 "#")
915119a5 19130
7f0e57bd 19131(define_insn "*pushv4si"
915119a5 19132 [(set (match_operand:V4SI 0 "push_operand" "=<")
7f0e57bd
JH
19133 (match_operand:V4SI 1 "register_operand" "x"))]
19134 "TARGET_SSE2"
19135 "#")
915119a5 19136
7f0e57bd 19137(define_insn "*pushv2si"
915119a5 19138 [(set (match_operand:V2SI 0 "push_operand" "=<")
7f0e57bd 19139 (match_operand:V2SI 1 "register_operand" "y"))]
915119a5 19140 "TARGET_MMX"
7f0e57bd 19141 "#")
915119a5 19142
7f0e57bd 19143(define_insn "*pushv4hi"
915119a5 19144 [(set (match_operand:V4HI 0 "push_operand" "=<")
7f0e57bd 19145 (match_operand:V4HI 1 "register_operand" "y"))]
915119a5 19146 "TARGET_MMX"
7f0e57bd 19147 "#")
915119a5 19148
7f0e57bd 19149(define_insn "*pushv8qi"
915119a5 19150 [(set (match_operand:V8QI 0 "push_operand" "=<")
7f0e57bd 19151 (match_operand:V8QI 1 "register_operand" "y"))]
915119a5 19152 "TARGET_MMX"
7f0e57bd 19153 "#")
915119a5 19154
7f0e57bd 19155(define_insn "*pushv2sf"
47f339cf 19156 [(set (match_operand:V2SF 0 "push_operand" "=<")
7f0e57bd 19157 (match_operand:V2SF 1 "register_operand" "y"))]
47f339cf 19158 "TARGET_3DNOW"
7f0e57bd
JH
19159 "#")
19160
19161(define_split
19162 [(set (match_operand 0 "push_operand" "")
19163 (match_operand 1 "register_operand" ""))]
19164 "!TARGET_64BIT && reload_completed
19165 && (SSE_REG_P (operands[1]) || MMX_REG_P (operands[1]))"
19166 [(set (reg:SI 7) (plus:SI (reg:SI 7) (match_dup 3)))
19167 (set (match_dup 2) (match_dup 1))]
19168 "operands[2] = change_address (operands[0], GET_MODE (operands[0]),
19169 stack_pointer_rtx);
09f26fb5 19170 operands[3] = GEN_INT (-GET_MODE_SIZE (GET_MODE (operands[0])));")
7f0e57bd
JH
19171
19172(define_split
19173 [(set (match_operand 0 "push_operand" "")
19174 (match_operand 1 "register_operand" ""))]
19175 "TARGET_64BIT && reload_completed
19176 && (SSE_REG_P (operands[1]) || MMX_REG_P (operands[1]))"
19177 [(set (reg:DI 7) (plus:DI (reg:DI 7) (match_dup 3)))
19178 (set (match_dup 2) (match_dup 1))]
19179 "operands[2] = change_address (operands[0], GET_MODE (operands[0]),
19180 stack_pointer_rtx);
09f26fb5 19181 operands[3] = GEN_INT (-GET_MODE_SIZE (GET_MODE (operands[0])));")
7f0e57bd 19182
47f339cf 19183
915119a5 19184(define_insn "movti_internal"
e37af218 19185 [(set (match_operand:TI 0 "nonimmediate_operand" "=x,x,m")
fdc4b40b 19186 (match_operand:TI 1 "vector_move_operand" "C,xm,x"))]
7f0e57bd
JH
19187 "TARGET_SSE && !TARGET_64BIT
19188 && (GET_CODE (operands[0]) != MEM || GET_CODE (operands[1]) != MEM)"
4977bab6
ZW
19189{
19190 switch (which_alternative)
19191 {
19192 case 0:
19193 if (get_attr_mode (insn) == MODE_V4SF)
19194 return "xorps\t%0, %0";
19195 else
19196 return "pxor\t%0, %0";
19197 case 1:
19198 case 2:
19199 if (get_attr_mode (insn) == MODE_V4SF)
19200 return "movaps\t{%1, %0|%0, %1}";
19201 else
19202 return "movdqa\t{%1, %0|%0, %1}";
19203 default:
19204 abort ();
19205 }
19206}
3d34cd91 19207 [(set_attr "type" "ssemov,ssemov,ssemov")
4977bab6
ZW
19208 (set (attr "mode")
19209 (cond [(eq_attr "alternative" "0,1")
19210 (if_then_else
19211 (ne (symbol_ref "optimize_size")
19212 (const_int 0))
19213 (const_string "V4SF")
19214 (const_string "TI"))
19215 (eq_attr "alternative" "2")
19216 (if_then_else
19217 (ne (symbol_ref "optimize_size")
19218 (const_int 0))
19219 (const_string "V4SF")
19220 (const_string "TI"))]
19221 (const_string "TI")))])
915119a5 19222
44cf5b6a 19223(define_insn "*movti_rex64"
4977bab6 19224 [(set (match_operand:TI 0 "nonimmediate_operand" "=r,o,x,x,xm")
f0f0d98e 19225 (match_operand:TI 1 "general_operand" "riFo,riF,C,xm,x"))]
44cf5b6a
JH
19226 "TARGET_64BIT
19227 && (GET_CODE (operands[0]) != MEM || GET_CODE (operands[1]) != MEM)"
4977bab6
ZW
19228{
19229 switch (which_alternative)
19230 {
19231 case 0:
19232 case 1:
19233 return "#";
19234 case 2:
19235 if (get_attr_mode (insn) == MODE_V4SF)
19236 return "xorps\t%0, %0";
19237 else
19238 return "pxor\t%0, %0";
19239 case 3:
19240 case 4:
19241 if (get_attr_mode (insn) == MODE_V4SF)
19242 return "movaps\t{%1, %0|%0, %1}";
19243 else
19244 return "movdqa\t{%1, %0|%0, %1}";
19245 default:
19246 abort ();
19247 }
19248}
3d34cd91 19249 [(set_attr "type" "*,*,ssemov,ssemov,ssemov")
4977bab6
ZW
19250 (set (attr "mode")
19251 (cond [(eq_attr "alternative" "2,3")
19252 (if_then_else
19253 (ne (symbol_ref "optimize_size")
19254 (const_int 0))
19255 (const_string "V4SF")
19256 (const_string "TI"))
19257 (eq_attr "alternative" "4")
19258 (if_then_else
19259 (ior (ne (symbol_ref "TARGET_SSE_TYPELESS_STORES")
19260 (const_int 0))
19261 (ne (symbol_ref "optimize_size")
19262 (const_int 0)))
19263 (const_string "V4SF")
19264 (const_string "TI"))]
19265 (const_string "DI")))])
44cf5b6a
JH
19266
19267(define_split
19268 [(set (match_operand:TI 0 "nonimmediate_operand" "")
19269 (match_operand:TI 1 "general_operand" ""))]
4fe8523b
JH
19270 "reload_completed && !SSE_REG_P (operands[0])
19271 && !SSE_REG_P (operands[1])"
44cf5b6a
JH
19272 [(const_int 0)]
19273 "ix86_split_long_move (operands); DONE;")
19274
915119a5
BS
19275;; These two patterns are useful for specifying exactly whether to use
19276;; movaps or movups
19277(define_insn "sse_movaps"
19278 [(set (match_operand:V4SF 0 "nonimmediate_operand" "=x,m")
8ee41eaf
RH
19279 (unspec:V4SF [(match_operand:V4SF 1 "nonimmediate_operand" "xm,x")]
19280 UNSPEC_MOVA))]
7f0e57bd
JH
19281 "TARGET_SSE
19282 && (GET_CODE (operands[0]) != MEM || GET_CODE (operands[1]) != MEM)"
19283 "movaps\t{%1, %0|%0, %1}"
3d34cd91
JH
19284 [(set_attr "type" "ssemov,ssemov")
19285 (set_attr "mode" "V4SF")])
915119a5
BS
19286
19287(define_insn "sse_movups"
19288 [(set (match_operand:V4SF 0 "nonimmediate_operand" "=x,m")
8ee41eaf
RH
19289 (unspec:V4SF [(match_operand:V4SF 1 "nonimmediate_operand" "xm,x")]
19290 UNSPEC_MOVU))]
7f0e57bd
JH
19291 "TARGET_SSE
19292 && (GET_CODE (operands[0]) != MEM || GET_CODE (operands[1]) != MEM)"
19293 "movups\t{%1, %0|%0, %1}"
3d34cd91
JH
19294 [(set_attr "type" "ssecvt,ssecvt")
19295 (set_attr "mode" "V4SF")])
915119a5
BS
19296
19297
19298;; SSE Strange Moves.
19299
19300(define_insn "sse_movmskps"
19301 [(set (match_operand:SI 0 "register_operand" "=r")
8ee41eaf
RH
19302 (unspec:SI [(match_operand:V4SF 1 "register_operand" "x")]
19303 UNSPEC_MOVMSK))]
915119a5 19304 "TARGET_SSE"
0f40f9f7 19305 "movmskps\t{%1, %0|%0, %1}"
3d34cd91
JH
19306 [(set_attr "type" "ssecvt")
19307 (set_attr "mode" "V4SF")])
915119a5
BS
19308
19309(define_insn "mmx_pmovmskb"
19310 [(set (match_operand:SI 0 "register_operand" "=r")
8ee41eaf
RH
19311 (unspec:SI [(match_operand:V8QI 1 "register_operand" "y")]
19312 UNSPEC_MOVMSK))]
47f339cf 19313 "TARGET_SSE || TARGET_3DNOW_A"
0f40f9f7 19314 "pmovmskb\t{%1, %0|%0, %1}"
3d34cd91
JH
19315 [(set_attr "type" "ssecvt")
19316 (set_attr "mode" "V4SF")])
19317
915119a5
BS
19318
19319(define_insn "mmx_maskmovq"
19320 [(set (mem:V8QI (match_operand:SI 0 "register_operand" "D"))
19321 (unspec:V8QI [(match_operand:V8QI 1 "register_operand" "y")
8ee41eaf
RH
19322 (match_operand:V8QI 2 "register_operand" "y")]
19323 UNSPEC_MASKMOV))]
e95d6b23
JH
19324 "(TARGET_SSE || TARGET_3DNOW_A) && !TARGET_64BIT"
19325 ;; @@@ check ordering of operands in intel/nonintel syntax
19326 "maskmovq\t{%2, %1|%1, %2}"
3d34cd91
JH
19327 [(set_attr "type" "mmxcvt")
19328 (set_attr "mode" "DI")])
e95d6b23
JH
19329
19330(define_insn "mmx_maskmovq_rex"
19331 [(set (mem:V8QI (match_operand:DI 0 "register_operand" "D"))
19332 (unspec:V8QI [(match_operand:V8QI 1 "register_operand" "y")
8ee41eaf
RH
19333 (match_operand:V8QI 2 "register_operand" "y")]
19334 UNSPEC_MASKMOV))]
e95d6b23 19335 "(TARGET_SSE || TARGET_3DNOW_A) && TARGET_64BIT"
915119a5 19336 ;; @@@ check ordering of operands in intel/nonintel syntax
0f40f9f7 19337 "maskmovq\t{%2, %1|%1, %2}"
3d34cd91
JH
19338 [(set_attr "type" "mmxcvt")
19339 (set_attr "mode" "DI")])
915119a5
BS
19340
19341(define_insn "sse_movntv4sf"
19342 [(set (match_operand:V4SF 0 "memory_operand" "=m")
8ee41eaf
RH
19343 (unspec:V4SF [(match_operand:V4SF 1 "register_operand" "x")]
19344 UNSPEC_MOVNT))]
915119a5 19345 "TARGET_SSE"
0f40f9f7 19346 "movntps\t{%1, %0|%0, %1}"
3d34cd91
JH
19347 [(set_attr "type" "ssemov")
19348 (set_attr "mode" "V4SF")])
915119a5
BS
19349
19350(define_insn "sse_movntdi"
19351 [(set (match_operand:DI 0 "memory_operand" "=m")
8ee41eaf
RH
19352 (unspec:DI [(match_operand:DI 1 "register_operand" "y")]
19353 UNSPEC_MOVNT))]
47f339cf 19354 "TARGET_SSE || TARGET_3DNOW_A"
0f40f9f7 19355 "movntq\t{%1, %0|%0, %1}"
3d34cd91
JH
19356 [(set_attr "type" "mmxmov")
19357 (set_attr "mode" "DI")])
915119a5
BS
19358
19359(define_insn "sse_movhlps"
19360 [(set (match_operand:V4SF 0 "register_operand" "=x")
19361 (vec_merge:V4SF
19362 (match_operand:V4SF 1 "register_operand" "0")
19363 (vec_select:V4SF (match_operand:V4SF 2 "register_operand" "x")
19364 (parallel [(const_int 2)
19365 (const_int 3)
19366 (const_int 0)
19367 (const_int 1)]))
19368 (const_int 3)))]
19369 "TARGET_SSE"
0f40f9f7 19370 "movhlps\t{%2, %0|%0, %2}"
3d34cd91
JH
19371 [(set_attr "type" "ssecvt")
19372 (set_attr "mode" "V4SF")])
915119a5
BS
19373
19374(define_insn "sse_movlhps"
19375 [(set (match_operand:V4SF 0 "register_operand" "=x")
19376 (vec_merge:V4SF
19377 (match_operand:V4SF 1 "register_operand" "0")
19378 (vec_select:V4SF (match_operand:V4SF 2 "register_operand" "x")
19379 (parallel [(const_int 2)
19380 (const_int 3)
19381 (const_int 0)
19382 (const_int 1)]))
19383 (const_int 12)))]
19384 "TARGET_SSE"
0f40f9f7 19385 "movlhps\t{%2, %0|%0, %2}"
3d34cd91
JH
19386 [(set_attr "type" "ssecvt")
19387 (set_attr "mode" "V4SF")])
915119a5
BS
19388
19389(define_insn "sse_movhps"
19390 [(set (match_operand:V4SF 0 "nonimmediate_operand" "=x,m")
19391 (vec_merge:V4SF
19392 (match_operand:V4SF 1 "nonimmediate_operand" "0,0")
19393 (match_operand:V4SF 2 "nonimmediate_operand" "m,x")
19394 (const_int 12)))]
e37af218
RH
19395 "TARGET_SSE
19396 && (GET_CODE (operands[1]) == MEM || GET_CODE (operands[2]) == MEM)"
0f40f9f7 19397 "movhps\t{%2, %0|%0, %2}"
3d34cd91
JH
19398 [(set_attr "type" "ssecvt")
19399 (set_attr "mode" "V4SF")])
915119a5
BS
19400
19401(define_insn "sse_movlps"
19402 [(set (match_operand:V4SF 0 "nonimmediate_operand" "=x,m")
19403 (vec_merge:V4SF
19404 (match_operand:V4SF 1 "nonimmediate_operand" "0,0")
19405 (match_operand:V4SF 2 "nonimmediate_operand" "m,x")
19406 (const_int 3)))]
e37af218
RH
19407 "TARGET_SSE
19408 && (GET_CODE (operands[1]) == MEM || GET_CODE (operands[2]) == MEM)"
0f40f9f7 19409 "movlps\t{%2, %0|%0, %2}"
3d34cd91
JH
19410 [(set_attr "type" "ssecvt")
19411 (set_attr "mode" "V4SF")])
915119a5 19412
4977bab6
ZW
19413(define_expand "sse_loadss"
19414 [(match_operand:V4SF 0 "register_operand" "")
19415 (match_operand:SF 1 "memory_operand" "")]
19416 "TARGET_SSE"
19417{
19418 emit_insn (gen_sse_loadss_1 (operands[0], operands[1],
19419 CONST0_RTX (V4SFmode)));
19420 DONE;
19421})
19422
19423(define_insn "sse_loadss_1"
915119a5
BS
19424 [(set (match_operand:V4SF 0 "register_operand" "=x")
19425 (vec_merge:V4SF
4977bab6
ZW
19426 (vec_duplicate:V4SF (match_operand:SF 1 "memory_operand" "m"))
19427 (match_operand:V4SF 2 "const0_operand" "X")
915119a5
BS
19428 (const_int 1)))]
19429 "TARGET_SSE"
0f40f9f7 19430 "movss\t{%1, %0|%0, %1}"
3d34cd91
JH
19431 [(set_attr "type" "ssemov")
19432 (set_attr "mode" "SF")])
915119a5
BS
19433
19434(define_insn "sse_movss"
19435 [(set (match_operand:V4SF 0 "register_operand" "=x")
19436 (vec_merge:V4SF
19437 (match_operand:V4SF 1 "register_operand" "0")
19438 (match_operand:V4SF 2 "register_operand" "x")
19439 (const_int 1)))]
19440 "TARGET_SSE"
0f40f9f7 19441 "movss\t{%2, %0|%0, %2}"
3d34cd91
JH
19442 [(set_attr "type" "ssemov")
19443 (set_attr "mode" "SF")])
915119a5
BS
19444
19445(define_insn "sse_storess"
19446 [(set (match_operand:SF 0 "memory_operand" "=m")
19447 (vec_select:SF
19448 (match_operand:V4SF 1 "register_operand" "x")
19449 (parallel [(const_int 0)])))]
19450 "TARGET_SSE"
0f40f9f7 19451 "movss\t{%1, %0|%0, %1}"
3d34cd91
JH
19452 [(set_attr "type" "ssemov")
19453 (set_attr "mode" "SF")])
915119a5
BS
19454
19455(define_insn "sse_shufps"
19456 [(set (match_operand:V4SF 0 "register_operand" "=x")
19457 (unspec:V4SF [(match_operand:V4SF 1 "register_operand" "0")
19458 (match_operand:V4SF 2 "nonimmediate_operand" "xm")
8ee41eaf
RH
19459 (match_operand:SI 3 "immediate_operand" "i")]
19460 UNSPEC_SHUFFLE))]
915119a5
BS
19461 "TARGET_SSE"
19462 ;; @@@ check operand order for intel/nonintel syntax
0f40f9f7 19463 "shufps\t{%3, %2, %0|%0, %2, %3}"
3d34cd91
JH
19464 [(set_attr "type" "ssecvt")
19465 (set_attr "mode" "V4SF")])
915119a5
BS
19466
19467
19468;; SSE arithmetic
19469
19470(define_insn "addv4sf3"
19471 [(set (match_operand:V4SF 0 "register_operand" "=x")
19472 (plus:V4SF (match_operand:V4SF 1 "register_operand" "0")
19473 (match_operand:V4SF 2 "nonimmediate_operand" "xm")))]
19474 "TARGET_SSE"
0f40f9f7 19475 "addps\t{%2, %0|%0, %2}"
3d34cd91
JH
19476 [(set_attr "type" "sseadd")
19477 (set_attr "mode" "V4SF")])
915119a5
BS
19478
19479(define_insn "vmaddv4sf3"
19480 [(set (match_operand:V4SF 0 "register_operand" "=x")
e37af218
RH
19481 (vec_merge:V4SF
19482 (plus:V4SF (match_operand:V4SF 1 "register_operand" "0")
19483 (match_operand:V4SF 2 "nonimmediate_operand" "xm"))
19484 (match_dup 1)
19485 (const_int 1)))]
915119a5 19486 "TARGET_SSE"
0f40f9f7 19487 "addss\t{%2, %0|%0, %2}"
3d34cd91
JH
19488 [(set_attr "type" "sseadd")
19489 (set_attr "mode" "SF")])
915119a5
BS
19490
19491(define_insn "subv4sf3"
19492 [(set (match_operand:V4SF 0 "register_operand" "=x")
19493 (minus:V4SF (match_operand:V4SF 1 "register_operand" "0")
e37af218 19494 (match_operand:V4SF 2 "nonimmediate_operand" "xm")))]
915119a5 19495 "TARGET_SSE"
0f40f9f7 19496 "subps\t{%2, %0|%0, %2}"
3d34cd91
JH
19497 [(set_attr "type" "sseadd")
19498 (set_attr "mode" "V4SF")])
915119a5
BS
19499
19500(define_insn "vmsubv4sf3"
19501 [(set (match_operand:V4SF 0 "register_operand" "=x")
e37af218
RH
19502 (vec_merge:V4SF
19503 (minus:V4SF (match_operand:V4SF 1 "register_operand" "0")
19504 (match_operand:V4SF 2 "nonimmediate_operand" "xm"))
19505 (match_dup 1)
19506 (const_int 1)))]
915119a5 19507 "TARGET_SSE"
0f40f9f7 19508 "subss\t{%2, %0|%0, %2}"
3d34cd91
JH
19509 [(set_attr "type" "sseadd")
19510 (set_attr "mode" "SF")])
915119a5
BS
19511
19512(define_insn "mulv4sf3"
19513 [(set (match_operand:V4SF 0 "register_operand" "=x")
19514 (mult:V4SF (match_operand:V4SF 1 "register_operand" "0")
19515 (match_operand:V4SF 2 "nonimmediate_operand" "xm")))]
19516 "TARGET_SSE"
0f40f9f7 19517 "mulps\t{%2, %0|%0, %2}"
3d34cd91
JH
19518 [(set_attr "type" "ssemul")
19519 (set_attr "mode" "V4SF")])
915119a5
BS
19520
19521(define_insn "vmmulv4sf3"
19522 [(set (match_operand:V4SF 0 "register_operand" "=x")
e37af218
RH
19523 (vec_merge:V4SF
19524 (mult:V4SF (match_operand:V4SF 1 "register_operand" "0")
19525 (match_operand:V4SF 2 "nonimmediate_operand" "xm"))
19526 (match_dup 1)
19527 (const_int 1)))]
915119a5 19528 "TARGET_SSE"
0f40f9f7 19529 "mulss\t{%2, %0|%0, %2}"
3d34cd91
JH
19530 [(set_attr "type" "ssemul")
19531 (set_attr "mode" "SF")])
915119a5
BS
19532
19533(define_insn "divv4sf3"
19534 [(set (match_operand:V4SF 0 "register_operand" "=x")
19535 (div:V4SF (match_operand:V4SF 1 "register_operand" "0")
19536 (match_operand:V4SF 2 "nonimmediate_operand" "xm")))]
19537 "TARGET_SSE"
0f40f9f7 19538 "divps\t{%2, %0|%0, %2}"
3d34cd91
JH
19539 [(set_attr "type" "ssediv")
19540 (set_attr "mode" "V4SF")])
915119a5
BS
19541
19542(define_insn "vmdivv4sf3"
19543 [(set (match_operand:V4SF 0 "register_operand" "=x")
e37af218
RH
19544 (vec_merge:V4SF
19545 (div:V4SF (match_operand:V4SF 1 "register_operand" "0")
19546 (match_operand:V4SF 2 "nonimmediate_operand" "xm"))
19547 (match_dup 1)
19548 (const_int 1)))]
915119a5 19549 "TARGET_SSE"
0f40f9f7 19550 "divss\t{%2, %0|%0, %2}"
3d34cd91
JH
19551 [(set_attr "type" "ssediv")
19552 (set_attr "mode" "SF")])
915119a5
BS
19553
19554
19555;; SSE square root/reciprocal
19556
19557(define_insn "rcpv4sf2"
19558 [(set (match_operand:V4SF 0 "register_operand" "=x")
e37af218 19559 (unspec:V4SF
8ee41eaf 19560 [(match_operand:V4SF 1 "nonimmediate_operand" "xm")] UNSPEC_RCP))]
915119a5 19561 "TARGET_SSE"
0f40f9f7 19562 "rcpps\t{%1, %0|%0, %1}"
3d34cd91
JH
19563 [(set_attr "type" "sse")
19564 (set_attr "mode" "V4SF")])
915119a5
BS
19565
19566(define_insn "vmrcpv4sf2"
19567 [(set (match_operand:V4SF 0 "register_operand" "=x")
e37af218 19568 (vec_merge:V4SF
8ee41eaf
RH
19569 (unspec:V4SF [(match_operand:V4SF 1 "nonimmediate_operand" "xm")]
19570 UNSPEC_RCP)
e37af218
RH
19571 (match_operand:V4SF 2 "register_operand" "0")
19572 (const_int 1)))]
915119a5 19573 "TARGET_SSE"
0f40f9f7 19574 "rcpss\t{%1, %0|%0, %1}"
3d34cd91
JH
19575 [(set_attr "type" "sse")
19576 (set_attr "mode" "SF")])
915119a5
BS
19577
19578(define_insn "rsqrtv4sf2"
19579 [(set (match_operand:V4SF 0 "register_operand" "=x")
e37af218 19580 (unspec:V4SF
8ee41eaf 19581 [(match_operand:V4SF 1 "nonimmediate_operand" "xm")] UNSPEC_RSQRT))]
915119a5 19582 "TARGET_SSE"
0f40f9f7 19583 "rsqrtps\t{%1, %0|%0, %1}"
3d34cd91
JH
19584 [(set_attr "type" "sse")
19585 (set_attr "mode" "V4SF")])
915119a5
BS
19586
19587(define_insn "vmrsqrtv4sf2"
19588 [(set (match_operand:V4SF 0 "register_operand" "=x")
e37af218 19589 (vec_merge:V4SF
8ee41eaf
RH
19590 (unspec:V4SF [(match_operand:V4SF 1 "nonimmediate_operand" "xm")]
19591 UNSPEC_RSQRT)
e37af218
RH
19592 (match_operand:V4SF 2 "register_operand" "0")
19593 (const_int 1)))]
915119a5 19594 "TARGET_SSE"
0f40f9f7 19595 "rsqrtss\t{%1, %0|%0, %1}"
3d34cd91
JH
19596 [(set_attr "type" "sse")
19597 (set_attr "mode" "SF")])
915119a5
BS
19598
19599(define_insn "sqrtv4sf2"
19600 [(set (match_operand:V4SF 0 "register_operand" "=x")
e37af218 19601 (sqrt:V4SF (match_operand:V4SF 1 "nonimmediate_operand" "xm")))]
915119a5 19602 "TARGET_SSE"
0f40f9f7 19603 "sqrtps\t{%1, %0|%0, %1}"
3d34cd91
JH
19604 [(set_attr "type" "sse")
19605 (set_attr "mode" "V4SF")])
915119a5
BS
19606
19607(define_insn "vmsqrtv4sf2"
19608 [(set (match_operand:V4SF 0 "register_operand" "=x")
e37af218
RH
19609 (vec_merge:V4SF
19610 (sqrt:V4SF (match_operand:V4SF 1 "nonimmediate_operand" "xm"))
19611 (match_operand:V4SF 2 "register_operand" "0")
19612 (const_int 1)))]
915119a5 19613 "TARGET_SSE"
0f40f9f7 19614 "sqrtss\t{%1, %0|%0, %1}"
3d34cd91
JH
19615 [(set_attr "type" "sse")
19616 (set_attr "mode" "SF")])
915119a5 19617
915119a5
BS
19618;; SSE logical operations.
19619
1877be45
JH
19620;; SSE defines logical operations on floating point values. This brings
19621;; interesting challenge to RTL representation where logicals are only valid
19622;; on integral types. We deal with this by representing the floating point
19623;; logical as logical on arguments casted to TImode as this is what hardware
19624;; really does. Unfortunately hardware requires the type information to be
d1f87653 19625;; present and thus we must avoid subregs from being simplified and eliminated
1877be45
JH
19626;; in later compilation phases.
19627;;
19628;; We have following variants from each instruction:
19629;; sse_andsf3 - the operation taking V4SF vector operands
19630;; and doing TImode cast on them
19631;; *sse_andsf3_memory - the operation taking one memory operand casted to
d1f87653 19632;; TImode, since backend insist on eliminating casts
1877be45
JH
19633;; on memory operands
19634;; sse_andti3_sf_1 - the operation taking SF scalar operands.
19635;; We can not accept memory operand here as instruction reads
19636;; whole scalar. This is generated only post reload by GCC
19637;; scalar float operations that expands to logicals (fabs)
19638;; sse_andti3_sf_2 - the operation taking SF scalar input and TImode
19639;; memory operand. Eventually combine can be able
d1f87653 19640;; to synthesize these using splitter.
1877be45
JH
19641;; sse2_anddf3, *sse2_anddf3_memory
19642;;
19643;;
915119a5
BS
19644;; These are not called andti3 etc. because we really really don't want
19645;; the compiler to widen DImode ands to TImode ands and then try to move
19646;; into DImode subregs of SSE registers, and them together, and move out
19647;; of DImode subregs again!
1877be45
JH
19648;; SSE1 single precision floating point logical operation
19649(define_expand "sse_andv4sf3"
19650 [(set (subreg:TI (match_operand:V4SF 0 "register_operand" "") 0)
19651 (and:TI (subreg:TI (match_operand:V4SF 1 "register_operand" "") 0)
19652 (subreg:TI (match_operand:V4SF 2 "nonimmediate_operand" "") 0)))]
19653 "TARGET_SSE"
19654 "")
915119a5 19655
1877be45
JH
19656(define_insn "*sse_andv4sf3"
19657 [(set (subreg:TI (match_operand:V4SF 0 "register_operand" "=x") 0)
19658 (and:TI (match_operand:TI 1 "nonimmediate_operand" "%0")
19659 (match_operand:TI 2 "nonimmediate_operand" "xm")))]
19660 "TARGET_SSE
19661 && (GET_CODE (operands[1]) != MEM || GET_CODE (operands[2]) != MEM)"
19662 "andps\t{%2, %0|%0, %2}"
3d34cd91 19663 [(set_attr "type" "sselog")
1877be45 19664 (set_attr "mode" "V4SF")])
c679d048 19665
1877be45
JH
19666(define_insn "*sse_andsf3"
19667 [(set (subreg:TI (match_operand:SF 0 "register_operand" "=x") 0)
19668 (and:TI (match_operand:TI 1 "nonimmediate_operand" "%0")
19669 (match_operand:TI 2 "nonimmediate_operand" "xm")))]
19670 "TARGET_SSE
19671 && (GET_CODE (operands[1]) != MEM || GET_CODE (operands[2]) != MEM)"
19672 "andps\t{%2, %0|%0, %2}"
3d34cd91 19673 [(set_attr "type" "sselog")
1877be45 19674 (set_attr "mode" "V4SF")])
c679d048 19675
1877be45
JH
19676(define_expand "sse_nandv4sf3"
19677 [(set (subreg:TI (match_operand:V4SF 0 "register_operand" "") 0)
19678 (and:TI (not:TI (subreg:TI (match_operand:V4SF 1 "register_operand" "") 0))
19679 (subreg:TI (match_operand:V4SF 2 "nonimmediate_operand" "") 0)))]
c679d048 19680 "TARGET_SSE"
1877be45
JH
19681 "")
19682
19683(define_insn "*sse_nandv4sf3"
19684 [(set (subreg:TI (match_operand:V4SF 0 "register_operand" "=x") 0)
19685 (and:TI (not:TI (match_operand:TI 1 "register_operand" "0"))
19686 (match_operand:TI 2 "nonimmediate_operand" "xm")))]
19687 "TARGET_SSE"
19688 "andnps\t{%2, %0|%0, %2}"
3d34cd91
JH
19689 [(set_attr "type" "sselog")
19690 (set_attr "mode" "V4SF")])
c679d048 19691
1877be45 19692(define_insn "*sse_nandsf3"
c679d048 19693 [(set (subreg:TI (match_operand:SF 0 "register_operand" "=x") 0)
1877be45
JH
19694 (and:TI (not:TI (match_operand:TI 1 "register_operand" "0"))
19695 (match_operand:TI 2 "nonimmediate_operand" "xm")))]
c679d048 19696 "TARGET_SSE"
1877be45 19697 "andnps\t{%2, %0|%0, %2}"
3d34cd91
JH
19698 [(set_attr "type" "sselog")
19699 (set_attr "mode" "V4SF")])
c679d048 19700
1877be45
JH
19701(define_expand "sse_iorv4sf3"
19702 [(set (subreg:TI (match_operand:V4SF 0 "register_operand" "") 0)
19703 (ior:TI (subreg:TI (match_operand:V4SF 1 "register_operand" "") 0)
19704 (subreg:TI (match_operand:V4SF 2 "nonimmediate_operand" "") 0)))]
19705 "TARGET_SSE"
19706 "")
19707
19708(define_insn "*sse_iorv4sf3"
19709 [(set (subreg:TI (match_operand:V4SF 0 "register_operand" "=x") 0)
19710 (ior:TI (match_operand:TI 1 "nonimmediate_operand" "%0")
915119a5 19711 (match_operand:TI 2 "nonimmediate_operand" "xm")))]
1877be45 19712 "TARGET_SSE
558740bf 19713 && (GET_CODE (operands[1]) != MEM || GET_CODE (operands[2]) != MEM)"
1877be45 19714 "orps\t{%2, %0|%0, %2}"
3d34cd91
JH
19715 [(set_attr "type" "sselog")
19716 (set_attr "mode" "V4SF")])
915119a5 19717
1877be45
JH
19718(define_insn "*sse_iorsf3"
19719 [(set (subreg:TI (match_operand:SF 0 "register_operand" "=x") 0)
19720 (ior:TI (match_operand:TI 1 "nonimmediate_operand" "%0")
c679d048 19721 (match_operand:TI 2 "nonimmediate_operand" "xm")))]
1877be45 19722 "TARGET_SSE
558740bf 19723 && (GET_CODE (operands[1]) != MEM || GET_CODE (operands[2]) != MEM)"
1877be45 19724 "orps\t{%2, %0|%0, %2}"
3d34cd91 19725 [(set_attr "type" "sselog")
1877be45 19726 (set_attr "mode" "V4SF")])
c679d048 19727
1877be45
JH
19728(define_expand "sse_xorv4sf3"
19729 [(set (subreg:TI (match_operand:V4SF 0 "register_operand" "") 0)
19730 (xor:TI (subreg:TI (match_operand:V4SF 1 "register_operand" "") 0)
19731 (subreg:TI (match_operand:V4SF 2 "nonimmediate_operand" "") 0)))]
19732 "TARGET_SSE
916b60b7 19733 && (GET_CODE (operands[1]) != MEM || GET_CODE (operands[2]) != MEM)"
1877be45 19734 "")
c679d048 19735
1877be45
JH
19736(define_insn "*sse_xorv4sf3"
19737 [(set (subreg:TI (match_operand:V4SF 0 "register_operand" "=x") 0)
19738 (xor:TI (match_operand:TI 1 "nonimmediate_operand" "%0")
c679d048 19739 (match_operand:TI 2 "nonimmediate_operand" "xm")))]
1877be45
JH
19740 "TARGET_SSE
19741 && (GET_CODE (operands[1]) != MEM || GET_CODE (operands[2]) != MEM)"
19742 "xorps\t{%2, %0|%0, %2}"
3d34cd91
JH
19743 [(set_attr "type" "sselog")
19744 (set_attr "mode" "V4SF")])
c679d048 19745
1877be45
JH
19746(define_insn "*sse_xorsf3"
19747 [(set (subreg:TI (match_operand:SF 0 "register_operand" "=x") 0)
19748 (xor:TI (match_operand:TI 1 "nonimmediate_operand" "%0")
915119a5 19749 (match_operand:TI 2 "nonimmediate_operand" "xm")))]
1877be45
JH
19750 "TARGET_SSE
19751 && (GET_CODE (operands[1]) != MEM || GET_CODE (operands[2]) != MEM)"
19752 "xorps\t{%2, %0|%0, %2}"
3d34cd91
JH
19753 [(set_attr "type" "sselog")
19754 (set_attr "mode" "V4SF")])
915119a5 19755
1877be45
JH
19756;; SSE2 double precision floating point logical operation
19757
19758(define_expand "sse2_andv2df3"
19759 [(set (subreg:TI (match_operand:V2DF 0 "register_operand" "") 0)
19760 (and:TI (subreg:TI (match_operand:V2DF 1 "register_operand" "") 0)
19761 (subreg:TI (match_operand:V2DF 2 "nonimmediate_operand" "") 0)))]
c679d048 19762 "TARGET_SSE2"
1877be45
JH
19763 "")
19764
19765(define_insn "*sse2_andv2df3"
19766 [(set (subreg:TI (match_operand:V2DF 0 "register_operand" "=x") 0)
19767 (and:TI (match_operand:TI 1 "nonimmediate_operand" "%0")
19768 (match_operand:TI 2 "nonimmediate_operand" "xm")))]
19769 "TARGET_SSE2
19770 && (GET_CODE (operands[1]) != MEM || GET_CODE (operands[2]) != MEM)"
19771 "andpd\t{%2, %0|%0, %2}"
5f90a099 19772 [(set_attr "type" "sselog")
1877be45 19773 (set_attr "mode" "V2DF")])
c679d048 19774
1877be45
JH
19775(define_insn "*sse2_andv2df3"
19776 [(set (subreg:TI (match_operand:DF 0 "register_operand" "=x") 0)
19777 (and:TI (match_operand:TI 1 "nonimmediate_operand" "%0")
19778 (match_operand:TI 2 "nonimmediate_operand" "xm")))]
916b60b7
BS
19779 "TARGET_SSE2
19780 && (GET_CODE (operands[1]) != MEM || GET_CODE (operands[2]) != MEM)"
1877be45 19781 "andpd\t{%2, %0|%0, %2}"
5f90a099 19782 [(set_attr "type" "sselog")
1877be45 19783 (set_attr "mode" "V2DF")])
916b60b7 19784
1877be45
JH
19785(define_expand "sse2_nandv2df3"
19786 [(set (subreg:TI (match_operand:V2DF 0 "register_operand" "") 0)
19787 (and:TI (not:TI (subreg:TI (match_operand:V2DF 1 "register_operand" "") 0))
19788 (subreg:TI (match_operand:V2DF 2 "nonimmediate_operand" "") 0)))]
c679d048 19789 "TARGET_SSE2"
1877be45
JH
19790 "")
19791
19792(define_insn "*sse2_nandv2df3"
19793 [(set (subreg:TI (match_operand:V2DF 0 "register_operand" "=x") 0)
19794 (and:TI (not:TI (match_operand:TI 1 "register_operand" "0"))
19795 (match_operand:TI 2 "nonimmediate_operand" "xm")))]
19796 "TARGET_SSE2"
19797 "andnpd\t{%2, %0|%0, %2}"
3d34cd91
JH
19798 [(set_attr "type" "sselog")
19799 (set_attr "mode" "V2DF")])
c679d048 19800
1877be45 19801(define_insn "*sse_nandti3_df"
c679d048 19802 [(set (subreg:TI (match_operand:DF 0 "register_operand" "=Y") 0)
1877be45 19803 (and:TI (not:TI (match_operand:TI 1 "register_operand" "0"))
c679d048
JH
19804 (match_operand:TI 2 "nonimmediate_operand" "Ym")))]
19805 "TARGET_SSE2"
1877be45
JH
19806 "andnpd\t{%2, %0|%0, %2}"
19807 [(set_attr "type" "sselog")
19808 (set_attr "mode" "V2DF")])
19809
19810(define_expand "sse2_iorv2df3"
19811 [(set (subreg:TI (match_operand:V2DF 0 "register_operand" "") 0)
19812 (ior:TI (subreg:TI (match_operand:V2DF 1 "register_operand" "") 0)
19813 (subreg:TI (match_operand:V2DF 2 "nonimmediate_operand" "") 0)))]
19814 "TARGET_SSE2"
19815 "")
19816
19817(define_insn "*sse2_iorv2df3"
19818 [(set (subreg:TI (match_operand:V2DF 0 "register_operand" "=x") 0)
19819 (ior:TI (match_operand:TI 1 "nonimmediate_operand" "%0")
19820 (match_operand:TI 2 "nonimmediate_operand" "xm")))]
19821 "TARGET_SSE2
19822 && (GET_CODE (operands[1]) != MEM || GET_CODE (operands[2]) != MEM)"
0f40f9f7 19823 "orpd\t{%2, %0|%0, %2}"
3d34cd91
JH
19824 [(set_attr "type" "sselog")
19825 (set_attr "mode" "V2DF")])
c679d048 19826
1877be45
JH
19827(define_insn "*sse2_iordf3"
19828 [(set (subreg:TI (match_operand:DF 0 "register_operand" "=x") 0)
19829 (ior:TI (match_operand:TI 1 "nonimmediate_operand" "%0")
19830 (match_operand:TI 2 "nonimmediate_operand" "xm")))]
19831 "TARGET_SSE2
19832 && (GET_CODE (operands[1]) != MEM || GET_CODE (operands[2]) != MEM)"
19833 "orpd\t{%2, %0|%0, %2}"
3d34cd91 19834 [(set_attr "type" "sselog")
1877be45 19835 (set_attr "mode" "V2DF")])
c679d048 19836
1877be45
JH
19837(define_expand "sse2_xorv2df3"
19838 [(set (subreg:TI (match_operand:V2DF 0 "register_operand" "") 0)
19839 (xor:TI (subreg:TI (match_operand:V2DF 1 "nonimmediate_operand" "") 0)
19840 (subreg:TI (match_operand:V2DF 2 "nonimmediate_operand" "") 0)))]
19841 "TARGET_SSE2"
19842 "")
19843
19844(define_insn "*sse2_xorv2df3"
19845 [(set (subreg:TI (match_operand:V2DF 0 "register_operand" "=x") 0)
19846 (xor:TI (match_operand:TI 1 "nonimmediate_operand" "%0")
c679d048 19847 (match_operand:TI 2 "nonimmediate_operand" "xm")))]
1877be45
JH
19848 "TARGET_SSE2
19849 && (GET_CODE (operands[1]) != MEM || GET_CODE (operands[2]) != MEM)"
19850 "xorpd\t{%2, %0|%0, %2}"
3d34cd91 19851 [(set_attr "type" "sselog")
1877be45 19852 (set_attr "mode" "V2DF")])
c679d048 19853
1877be45
JH
19854(define_insn "*sse2_xordf3"
19855 [(set (subreg:TI (match_operand:DF 0 "register_operand" "=x") 0)
19856 (xor:TI (match_operand:TI 1 "nonimmediate_operand" "%0")
c679d048 19857 (match_operand:TI 2 "nonimmediate_operand" "xm")))]
1877be45 19858 "TARGET_SSE2
558740bf 19859 && (GET_CODE (operands[1]) != MEM || GET_CODE (operands[2]) != MEM)"
1877be45 19860 "xorpd\t{%2, %0|%0, %2}"
3d34cd91 19861 [(set_attr "type" "sselog")
1877be45 19862 (set_attr "mode" "V2DF")])
c679d048 19863
1877be45
JH
19864;; SSE2 integral logicals. These patterns must always come after floating
19865;; point ones since we don't want compiler to use integer opcodes on floating
19866;; point SSE values to avoid matching of subregs in the match_operand.
19867(define_insn "*sse2_andti3"
c679d048 19868 [(set (match_operand:TI 0 "register_operand" "=x")
1877be45 19869 (and:TI (match_operand:TI 1 "nonimmediate_operand" "%0")
c679d048 19870 (match_operand:TI 2 "nonimmediate_operand" "xm")))]
558740bf
JH
19871 "TARGET_SSE2
19872 && (GET_CODE (operands[1]) != MEM || GET_CODE (operands[2]) != MEM)"
1877be45 19873 "pand\t{%2, %0|%0, %2}"
3d34cd91
JH
19874 [(set_attr "type" "sselog")
19875 (set_attr "mode" "TI")])
c679d048 19876
1877be45 19877(define_insn "sse2_andv2di3"
916b60b7 19878 [(set (match_operand:V2DI 0 "register_operand" "=x")
1877be45 19879 (and:V2DI (match_operand:V2DI 1 "nonimmediate_operand" "%0")
916b60b7
BS
19880 (match_operand:V2DI 2 "nonimmediate_operand" "xm")))]
19881 "TARGET_SSE2
19882 && (GET_CODE (operands[1]) != MEM || GET_CODE (operands[2]) != MEM)"
1877be45 19883 "pand\t{%2, %0|%0, %2}"
5f90a099
JH
19884 [(set_attr "type" "sselog")
19885 (set_attr "mode" "TI")])
916b60b7 19886
1877be45
JH
19887(define_insn "*sse2_nandti3"
19888 [(set (match_operand:TI 0 "register_operand" "=x")
19889 (and:TI (not:TI (match_operand:TI 1 "register_operand" "0"))
19890 (match_operand:TI 2 "nonimmediate_operand" "xm")))]
c679d048 19891 "TARGET_SSE2"
1877be45 19892 "pandn\t{%2, %0|%0, %2}"
3d34cd91 19893 [(set_attr "type" "sselog")
1877be45 19894 (set_attr "mode" "TI")])
c679d048 19895
1877be45
JH
19896(define_insn "sse2_nandv2di3"
19897 [(set (match_operand:V2DI 0 "register_operand" "=x")
c48d6750 19898 (and:V2DI (not:V2DI (match_operand:V2DI 1 "nonimmediate_operand" "0"))
1877be45
JH
19899 (match_operand:V2DI 2 "nonimmediate_operand" "xm")))]
19900 "TARGET_SSE2
19901 && (GET_CODE (operands[1]) != MEM || GET_CODE (operands[2]) != MEM)"
19902 "pandn\t{%2, %0|%0, %2}"
3d34cd91 19903 [(set_attr "type" "sselog")
1877be45 19904 (set_attr "mode" "TI")])
c679d048 19905
1877be45
JH
19906(define_insn "*sse2_iorti3"
19907 [(set (match_operand:TI 0 "register_operand" "=x")
19908 (ior:TI (match_operand:TI 1 "nonimmediate_operand" "%0")
915119a5 19909 (match_operand:TI 2 "nonimmediate_operand" "xm")))]
1877be45
JH
19910 "TARGET_SSE2
19911 && (GET_CODE (operands[1]) != MEM || GET_CODE (operands[2]) != MEM)"
19912 "por\t{%2, %0|%0, %2}"
3d34cd91 19913 [(set_attr "type" "sselog")
1877be45 19914 (set_attr "mode" "TI")])
915119a5 19915
1877be45
JH
19916(define_insn "sse2_iorv2di3"
19917 [(set (match_operand:V2DI 0 "register_operand" "=x")
19918 (ior:V2DI (match_operand:V2DI 1 "nonimmediate_operand" "%0")
19919 (match_operand:V2DI 2 "nonimmediate_operand" "xm")))]
19920 "TARGET_SSE2
558740bf 19921 && (GET_CODE (operands[1]) != MEM || GET_CODE (operands[2]) != MEM)"
1877be45 19922 "por\t{%2, %0|%0, %2}"
3d34cd91 19923 [(set_attr "type" "sselog")
1877be45 19924 (set_attr "mode" "TI")])
915119a5 19925
1877be45 19926(define_insn "*sse2_xorti3"
c679d048 19927 [(set (match_operand:TI 0 "register_operand" "=x")
558740bf 19928 (xor:TI (match_operand:TI 1 "nonimmediate_operand" "%0")
c679d048 19929 (match_operand:TI 2 "nonimmediate_operand" "xm")))]
558740bf
JH
19930 "TARGET_SSE2
19931 && (GET_CODE (operands[1]) != MEM || GET_CODE (operands[2]) != MEM)"
0f40f9f7 19932 "pxor\t{%2, %0|%0, %2}"
3d34cd91
JH
19933 [(set_attr "type" "sselog")
19934 (set_attr "mode" "TI")])
c679d048 19935
916b60b7
BS
19936(define_insn "sse2_xorv2di3"
19937 [(set (match_operand:V2DI 0 "register_operand" "=x")
19938 (xor:V2DI (match_operand:V2DI 1 "nonimmediate_operand" "%0")
19939 (match_operand:V2DI 2 "nonimmediate_operand" "xm")))]
19940 "TARGET_SSE2
19941 && (GET_CODE (operands[1]) != MEM || GET_CODE (operands[2]) != MEM)"
19942 "pxor\t{%2, %0|%0, %2}"
5f90a099
JH
19943 [(set_attr "type" "sselog")
19944 (set_attr "mode" "TI")])
916b60b7 19945
915119a5
BS
19946;; Use xor, but don't show input operands so they aren't live before
19947;; this insn.
e37af218
RH
19948(define_insn "sse_clrv4sf"
19949 [(set (match_operand:V4SF 0 "register_operand" "=x")
4977bab6 19950 (match_operand:V4SF 1 "const0_operand" "X"))]
915119a5 19951 "TARGET_SSE"
4977bab6
ZW
19952{
19953 if (get_attr_mode (insn) == MODE_TI)
19954 return "pxor\t{%0, %0|%0, %0}";
19955 else
19956 return "xorps\t{%0, %0|%0, %0}";
19957}
3d34cd91 19958 [(set_attr "type" "sselog")
19cba4a0 19959 (set_attr "memory" "none")
4977bab6
ZW
19960 (set (attr "mode")
19961 (if_then_else
19962 (and (and (ne (symbol_ref "TARGET_SSE_LOAD0_BY_PXOR")
19963 (const_int 0))
19964 (ne (symbol_ref "TARGET_SSE2")
19965 (const_int 0)))
19966 (eq (symbol_ref "optimize_size")
19967 (const_int 0)))
19968 (const_string "TI")
19969 (const_string "V4SF")))])
915119a5 19970
48126a97
JH
19971;; Use xor, but don't show input operands so they aren't live before
19972;; this insn.
19973(define_insn "sse_clrv2df"
19974 [(set (match_operand:V2DF 0 "register_operand" "=x")
19975 (unspec:V2DF [(const_int 0)] UNSPEC_NOP))]
19976 "TARGET_SSE2"
19977 "xorpd\t{%0, %0|%0, %0}"
19978 [(set_attr "type" "sselog")
19979 (set_attr "memory" "none")
19980 (set_attr "mode" "V4SF")])
19981
915119a5
BS
19982;; SSE mask-generating compares
19983
19984(define_insn "maskcmpv4sf3"
19985 [(set (match_operand:V4SI 0 "register_operand" "=x")
19986 (match_operator:V4SI 3 "sse_comparison_operator"
e37af218
RH
19987 [(match_operand:V4SF 1 "register_operand" "0")
19988 (match_operand:V4SF 2 "register_operand" "x")]))]
915119a5 19989 "TARGET_SSE"
0f40f9f7 19990 "cmp%D3ps\t{%2, %0|%0, %2}"
3d34cd91
JH
19991 [(set_attr "type" "ssecmp")
19992 (set_attr "mode" "V4SF")])
915119a5
BS
19993
19994(define_insn "maskncmpv4sf3"
19995 [(set (match_operand:V4SI 0 "register_operand" "=x")
19996 (not:V4SI
19997 (match_operator:V4SI 3 "sse_comparison_operator"
e37af218
RH
19998 [(match_operand:V4SF 1 "register_operand" "0")
19999 (match_operand:V4SF 2 "register_operand" "x")])))]
915119a5 20000 "TARGET_SSE"
29628f27
BS
20001{
20002 if (GET_CODE (operands[3]) == UNORDERED)
e37af218
RH
20003 return "cmpordps\t{%2, %0|%0, %2}";
20004 else
20005 return "cmpn%D3ps\t{%2, %0|%0, %2}";
20006}
3d34cd91
JH
20007 [(set_attr "type" "ssecmp")
20008 (set_attr "mode" "V4SF")])
915119a5
BS
20009
20010(define_insn "vmmaskcmpv4sf3"
20011 [(set (match_operand:V4SI 0 "register_operand" "=x")
20012 (vec_merge:V4SI
20013 (match_operator:V4SI 3 "sse_comparison_operator"
e37af218
RH
20014 [(match_operand:V4SF 1 "register_operand" "0")
20015 (match_operand:V4SF 2 "register_operand" "x")])
d9deed68 20016 (subreg:V4SI (match_dup 1) 0)
915119a5
BS
20017 (const_int 1)))]
20018 "TARGET_SSE"
0f40f9f7 20019 "cmp%D3ss\t{%2, %0|%0, %2}"
3d34cd91
JH
20020 [(set_attr "type" "ssecmp")
20021 (set_attr "mode" "SF")])
915119a5
BS
20022
20023(define_insn "vmmaskncmpv4sf3"
20024 [(set (match_operand:V4SI 0 "register_operand" "=x")
20025 (vec_merge:V4SI
20026 (not:V4SI
20027 (match_operator:V4SI 3 "sse_comparison_operator"
e37af218
RH
20028 [(match_operand:V4SF 1 "register_operand" "0")
20029 (match_operand:V4SF 2 "register_operand" "x")]))
915119a5
BS
20030 (subreg:V4SI (match_dup 1) 0)
20031 (const_int 1)))]
20032 "TARGET_SSE"
29628f27
BS
20033{
20034 if (GET_CODE (operands[3]) == UNORDERED)
e37af218
RH
20035 return "cmpordss\t{%2, %0|%0, %2}";
20036 else
20037 return "cmpn%D3ss\t{%2, %0|%0, %2}";
20038}
3d34cd91
JH
20039 [(set_attr "type" "ssecmp")
20040 (set_attr "mode" "SF")])
915119a5
BS
20041
20042(define_insn "sse_comi"
20043 [(set (reg:CCFP 17)
1194ca05
JH
20044 (compare:CCFP (vec_select:SF
20045 (match_operand:V4SF 0 "register_operand" "x")
20046 (parallel [(const_int 0)]))
20047 (vec_select:SF
20048 (match_operand:V4SF 1 "register_operand" "x")
20049 (parallel [(const_int 0)]))))]
915119a5 20050 "TARGET_SSE"
21e1b5f1 20051 "comiss\t{%1, %0|%0, %1}"
26771da7 20052 [(set_attr "type" "ssecomi")
3d34cd91 20053 (set_attr "mode" "SF")])
915119a5
BS
20054
20055(define_insn "sse_ucomi"
20056 [(set (reg:CCFPU 17)
1194ca05
JH
20057 (compare:CCFPU (vec_select:SF
20058 (match_operand:V4SF 0 "register_operand" "x")
20059 (parallel [(const_int 0)]))
20060 (vec_select:SF
20061 (match_operand:V4SF 1 "register_operand" "x")
20062 (parallel [(const_int 0)]))))]
915119a5 20063 "TARGET_SSE"
21e1b5f1 20064 "ucomiss\t{%1, %0|%0, %1}"
26771da7 20065 [(set_attr "type" "ssecomi")
3d34cd91 20066 (set_attr "mode" "SF")])
915119a5
BS
20067
20068
20069;; SSE unpack
20070
20071(define_insn "sse_unpckhps"
20072 [(set (match_operand:V4SF 0 "register_operand" "=x")
20073 (vec_merge:V4SF
20074 (vec_select:V4SF (match_operand:V4SF 1 "register_operand" "0")
20075 (parallel [(const_int 2)
20076 (const_int 0)
20077 (const_int 3)
20078 (const_int 1)]))
21e1b5f1 20079 (vec_select:V4SF (match_operand:V4SF 2 "register_operand" "x")
915119a5
BS
20080 (parallel [(const_int 0)
20081 (const_int 2)
20082 (const_int 1)
20083 (const_int 3)]))
20084 (const_int 5)))]
20085 "TARGET_SSE"
0f40f9f7 20086 "unpckhps\t{%2, %0|%0, %2}"
3d34cd91
JH
20087 [(set_attr "type" "ssecvt")
20088 (set_attr "mode" "V4SF")])
915119a5
BS
20089
20090(define_insn "sse_unpcklps"
20091 [(set (match_operand:V4SF 0 "register_operand" "=x")
20092 (vec_merge:V4SF
20093 (vec_select:V4SF (match_operand:V4SF 1 "register_operand" "0")
20094 (parallel [(const_int 0)
20095 (const_int 2)
20096 (const_int 1)
20097 (const_int 3)]))
21e1b5f1 20098 (vec_select:V4SF (match_operand:V4SF 2 "register_operand" "x")
915119a5
BS
20099 (parallel [(const_int 2)
20100 (const_int 0)
20101 (const_int 3)
20102 (const_int 1)]))
20103 (const_int 5)))]
20104 "TARGET_SSE"
0f40f9f7 20105 "unpcklps\t{%2, %0|%0, %2}"
3d34cd91
JH
20106 [(set_attr "type" "ssecvt")
20107 (set_attr "mode" "V4SF")])
915119a5
BS
20108
20109
20110;; SSE min/max
20111
20112(define_insn "smaxv4sf3"
20113 [(set (match_operand:V4SF 0 "register_operand" "=x")
20114 (smax:V4SF (match_operand:V4SF 1 "register_operand" "0")
20115 (match_operand:V4SF 2 "nonimmediate_operand" "xm")))]
20116 "TARGET_SSE"
0f40f9f7 20117 "maxps\t{%2, %0|%0, %2}"
3d34cd91
JH
20118 [(set_attr "type" "sse")
20119 (set_attr "mode" "V4SF")])
915119a5
BS
20120
20121(define_insn "vmsmaxv4sf3"
20122 [(set (match_operand:V4SF 0 "register_operand" "=x")
e37af218
RH
20123 (vec_merge:V4SF
20124 (smax:V4SF (match_operand:V4SF 1 "register_operand" "0")
20125 (match_operand:V4SF 2 "nonimmediate_operand" "xm"))
20126 (match_dup 1)
20127 (const_int 1)))]
915119a5 20128 "TARGET_SSE"
0f40f9f7 20129 "maxss\t{%2, %0|%0, %2}"
3d34cd91
JH
20130 [(set_attr "type" "sse")
20131 (set_attr "mode" "SF")])
915119a5
BS
20132
20133(define_insn "sminv4sf3"
20134 [(set (match_operand:V4SF 0 "register_operand" "=x")
20135 (smin:V4SF (match_operand:V4SF 1 "register_operand" "0")
20136 (match_operand:V4SF 2 "nonimmediate_operand" "xm")))]
20137 "TARGET_SSE"
0f40f9f7 20138 "minps\t{%2, %0|%0, %2}"
3d34cd91
JH
20139 [(set_attr "type" "sse")
20140 (set_attr "mode" "V4SF")])
915119a5
BS
20141
20142(define_insn "vmsminv4sf3"
20143 [(set (match_operand:V4SF 0 "register_operand" "=x")
e37af218
RH
20144 (vec_merge:V4SF
20145 (smin:V4SF (match_operand:V4SF 1 "register_operand" "0")
20146 (match_operand:V4SF 2 "nonimmediate_operand" "xm"))
20147 (match_dup 1)
20148 (const_int 1)))]
915119a5 20149 "TARGET_SSE"
0f40f9f7 20150 "minss\t{%2, %0|%0, %2}"
3d34cd91
JH
20151 [(set_attr "type" "sse")
20152 (set_attr "mode" "SF")])
915119a5 20153
915119a5
BS
20154;; SSE <-> integer/MMX conversions
20155
20156(define_insn "cvtpi2ps"
20157 [(set (match_operand:V4SF 0 "register_operand" "=x")
e37af218
RH
20158 (vec_merge:V4SF
20159 (match_operand:V4SF 1 "register_operand" "0")
20160 (vec_duplicate:V4SF
20161 (float:V2SF (match_operand:V2SI 2 "nonimmediate_operand" "ym")))
20162 (const_int 12)))]
915119a5 20163 "TARGET_SSE"
0f40f9f7 20164 "cvtpi2ps\t{%2, %0|%0, %2}"
3d34cd91
JH
20165 [(set_attr "type" "ssecvt")
20166 (set_attr "mode" "V4SF")])
915119a5
BS
20167
20168(define_insn "cvtps2pi"
20169 [(set (match_operand:V2SI 0 "register_operand" "=y")
e37af218
RH
20170 (vec_select:V2SI
20171 (fix:V4SI (match_operand:V4SF 1 "nonimmediate_operand" "xm"))
20172 (parallel [(const_int 0) (const_int 1)])))]
915119a5 20173 "TARGET_SSE"
0f40f9f7 20174 "cvtps2pi\t{%1, %0|%0, %1}"
3d34cd91
JH
20175 [(set_attr "type" "ssecvt")
20176 (set_attr "mode" "V4SF")])
915119a5
BS
20177
20178(define_insn "cvttps2pi"
20179 [(set (match_operand:V2SI 0 "register_operand" "=y")
e37af218 20180 (vec_select:V2SI
8ee41eaf
RH
20181 (unspec:V4SI [(match_operand:V4SF 1 "nonimmediate_operand" "xm")]
20182 UNSPEC_FIX)
e37af218 20183 (parallel [(const_int 0) (const_int 1)])))]
915119a5 20184 "TARGET_SSE"
0f40f9f7 20185 "cvttps2pi\t{%1, %0|%0, %1}"
3d34cd91
JH
20186 [(set_attr "type" "ssecvt")
20187 (set_attr "mode" "SF")])
915119a5
BS
20188
20189(define_insn "cvtsi2ss"
f56e86bd 20190 [(set (match_operand:V4SF 0 "register_operand" "=x,x")
e37af218 20191 (vec_merge:V4SF
f56e86bd 20192 (match_operand:V4SF 1 "register_operand" "0,0")
e37af218 20193 (vec_duplicate:V4SF
f56e86bd 20194 (float:SF (match_operand:SI 2 "nonimmediate_operand" "r,rm")))
e37af218 20195 (const_int 14)))]
915119a5 20196 "TARGET_SSE"
0f40f9f7 20197 "cvtsi2ss\t{%2, %0|%0, %2}"
f56e86bd
JH
20198 [(set_attr "type" "sseicvt")
20199 (set_attr "athlon_decode" "vector,double")
3d34cd91 20200 (set_attr "mode" "SF")])
915119a5 20201
4977bab6 20202(define_insn "cvtsi2ssq"
f56e86bd 20203 [(set (match_operand:V4SF 0 "register_operand" "=x,x")
4977bab6 20204 (vec_merge:V4SF
f56e86bd 20205 (match_operand:V4SF 1 "register_operand" "0,0")
4977bab6 20206 (vec_duplicate:V4SF
f56e86bd 20207 (float:SF (match_operand:DI 2 "nonimmediate_operand" "r,rm")))
4977bab6
ZW
20208 (const_int 14)))]
20209 "TARGET_SSE && TARGET_64BIT"
20210 "cvtsi2ssq\t{%2, %0|%0, %2}"
f56e86bd
JH
20211 [(set_attr "type" "sseicvt")
20212 (set_attr "athlon_decode" "vector,double")
4977bab6
ZW
20213 (set_attr "mode" "SF")])
20214
915119a5 20215(define_insn "cvtss2si"
f56e86bd 20216 [(set (match_operand:SI 0 "register_operand" "=r,r")
e37af218 20217 (vec_select:SI
f56e86bd 20218 (fix:V4SI (match_operand:V4SF 1 "nonimmediate_operand" "x,m"))
e37af218 20219 (parallel [(const_int 0)])))]
915119a5 20220 "TARGET_SSE"
0f40f9f7 20221 "cvtss2si\t{%1, %0|%0, %1}"
f56e86bd
JH
20222 [(set_attr "type" "sseicvt")
20223 (set_attr "athlon_decode" "double,vector")
3d34cd91 20224 (set_attr "mode" "SF")])
915119a5
BS
20225
20226(define_insn "cvttss2si"
f56e86bd 20227 [(set (match_operand:SI 0 "register_operand" "=r,r")
e37af218 20228 (vec_select:SI
f56e86bd 20229 (unspec:V4SI [(match_operand:V4SF 1 "nonimmediate_operand" "x,xm")]
8ee41eaf 20230 UNSPEC_FIX)
e37af218 20231 (parallel [(const_int 0)])))]
915119a5 20232 "TARGET_SSE"
0f40f9f7 20233 "cvttss2si\t{%1, %0|%0, %1}"
f56e86bd
JH
20234 [(set_attr "type" "sseicvt")
20235 (set_attr "mode" "SF")
20236 (set_attr "athlon_decode" "double,vector")])
915119a5
BS
20237
20238
20239;; MMX insns
20240
20241;; MMX arithmetic
20242
20243(define_insn "addv8qi3"
20244 [(set (match_operand:V8QI 0 "register_operand" "=y")
20245 (plus:V8QI (match_operand:V8QI 1 "register_operand" "0")
20246 (match_operand:V8QI 2 "nonimmediate_operand" "ym")))]
20247 "TARGET_MMX"
0f40f9f7 20248 "paddb\t{%2, %0|%0, %2}"
3d34cd91
JH
20249 [(set_attr "type" "mmxadd")
20250 (set_attr "mode" "DI")])
915119a5
BS
20251
20252(define_insn "addv4hi3"
20253 [(set (match_operand:V4HI 0 "register_operand" "=y")
20254 (plus:V4HI (match_operand:V4HI 1 "register_operand" "0")
20255 (match_operand:V4HI 2 "nonimmediate_operand" "ym")))]
20256 "TARGET_MMX"
0f40f9f7 20257 "paddw\t{%2, %0|%0, %2}"
3d34cd91
JH
20258 [(set_attr "type" "mmxadd")
20259 (set_attr "mode" "DI")])
915119a5
BS
20260
20261(define_insn "addv2si3"
20262 [(set (match_operand:V2SI 0 "register_operand" "=y")
20263 (plus:V2SI (match_operand:V2SI 1 "register_operand" "0")
20264 (match_operand:V2SI 2 "nonimmediate_operand" "ym")))]
20265 "TARGET_MMX"
0f40f9f7 20266 "paddd\t{%2, %0|%0, %2}"
3d34cd91
JH
20267 [(set_attr "type" "mmxadd")
20268 (set_attr "mode" "DI")])
915119a5
BS
20269
20270(define_insn "ssaddv8qi3"
20271 [(set (match_operand:V8QI 0 "register_operand" "=y")
20272 (ss_plus:V8QI (match_operand:V8QI 1 "register_operand" "0")
20273 (match_operand:V8QI 2 "nonimmediate_operand" "ym")))]
20274 "TARGET_MMX"
0f40f9f7 20275 "paddsb\t{%2, %0|%0, %2}"
3d34cd91
JH
20276 [(set_attr "type" "mmxadd")
20277 (set_attr "mode" "DI")])
915119a5
BS
20278
20279(define_insn "ssaddv4hi3"
20280 [(set (match_operand:V4HI 0 "register_operand" "=y")
20281 (ss_plus:V4HI (match_operand:V4HI 1 "register_operand" "0")
20282 (match_operand:V4HI 2 "nonimmediate_operand" "ym")))]
20283 "TARGET_MMX"
0f40f9f7 20284 "paddsw\t{%2, %0|%0, %2}"
3d34cd91
JH
20285 [(set_attr "type" "mmxadd")
20286 (set_attr "mode" "DI")])
915119a5
BS
20287
20288(define_insn "usaddv8qi3"
20289 [(set (match_operand:V8QI 0 "register_operand" "=y")
20290 (us_plus:V8QI (match_operand:V8QI 1 "register_operand" "0")
20291 (match_operand:V8QI 2 "nonimmediate_operand" "ym")))]
20292 "TARGET_MMX"
0f40f9f7 20293 "paddusb\t{%2, %0|%0, %2}"
3d34cd91
JH
20294 [(set_attr "type" "mmxadd")
20295 (set_attr "mode" "DI")])
915119a5
BS
20296
20297(define_insn "usaddv4hi3"
20298 [(set (match_operand:V4HI 0 "register_operand" "=y")
20299 (us_plus:V4HI (match_operand:V4HI 1 "register_operand" "0")
20300 (match_operand:V4HI 2 "nonimmediate_operand" "ym")))]
20301 "TARGET_MMX"
0f40f9f7 20302 "paddusw\t{%2, %0|%0, %2}"
3d34cd91
JH
20303 [(set_attr "type" "mmxadd")
20304 (set_attr "mode" "DI")])
915119a5
BS
20305
20306(define_insn "subv8qi3"
20307 [(set (match_operand:V8QI 0 "register_operand" "=y")
20308 (minus:V8QI (match_operand:V8QI 1 "register_operand" "0")
20309 (match_operand:V8QI 2 "nonimmediate_operand" "ym")))]
20310 "TARGET_MMX"
0f40f9f7 20311 "psubb\t{%2, %0|%0, %2}"
3d34cd91
JH
20312 [(set_attr "type" "mmxadd")
20313 (set_attr "mode" "DI")])
915119a5
BS
20314
20315(define_insn "subv4hi3"
20316 [(set (match_operand:V4HI 0 "register_operand" "=y")
20317 (minus:V4HI (match_operand:V4HI 1 "register_operand" "0")
20318 (match_operand:V4HI 2 "nonimmediate_operand" "ym")))]
20319 "TARGET_MMX"
0f40f9f7 20320 "psubw\t{%2, %0|%0, %2}"
3d34cd91
JH
20321 [(set_attr "type" "mmxadd")
20322 (set_attr "mode" "DI")])
915119a5
BS
20323
20324(define_insn "subv2si3"
20325 [(set (match_operand:V2SI 0 "register_operand" "=y")
20326 (minus:V2SI (match_operand:V2SI 1 "register_operand" "0")
20327 (match_operand:V2SI 2 "nonimmediate_operand" "ym")))]
20328 "TARGET_MMX"
0f40f9f7 20329 "psubd\t{%2, %0|%0, %2}"
3d34cd91
JH
20330 [(set_attr "type" "mmxadd")
20331 (set_attr "mode" "DI")])
915119a5
BS
20332
20333(define_insn "sssubv8qi3"
20334 [(set (match_operand:V8QI 0 "register_operand" "=y")
20335 (ss_minus:V8QI (match_operand:V8QI 1 "register_operand" "0")
20336 (match_operand:V8QI 2 "nonimmediate_operand" "ym")))]
20337 "TARGET_MMX"
0f40f9f7 20338 "psubsb\t{%2, %0|%0, %2}"
3d34cd91
JH
20339 [(set_attr "type" "mmxadd")
20340 (set_attr "mode" "DI")])
915119a5
BS
20341
20342(define_insn "sssubv4hi3"
20343 [(set (match_operand:V4HI 0 "register_operand" "=y")
20344 (ss_minus:V4HI (match_operand:V4HI 1 "register_operand" "0")
20345 (match_operand:V4HI 2 "nonimmediate_operand" "ym")))]
20346 "TARGET_MMX"
0f40f9f7 20347 "psubsw\t{%2, %0|%0, %2}"
3d34cd91
JH
20348 [(set_attr "type" "mmxadd")
20349 (set_attr "mode" "DI")])
915119a5
BS
20350
20351(define_insn "ussubv8qi3"
20352 [(set (match_operand:V8QI 0 "register_operand" "=y")
20353 (us_minus:V8QI (match_operand:V8QI 1 "register_operand" "0")
20354 (match_operand:V8QI 2 "nonimmediate_operand" "ym")))]
20355 "TARGET_MMX"
0f40f9f7 20356 "psubusb\t{%2, %0|%0, %2}"
3d34cd91
JH
20357 [(set_attr "type" "mmxadd")
20358 (set_attr "mode" "DI")])
915119a5
BS
20359
20360(define_insn "ussubv4hi3"
20361 [(set (match_operand:V4HI 0 "register_operand" "=y")
20362 (us_minus:V4HI (match_operand:V4HI 1 "register_operand" "0")
20363 (match_operand:V4HI 2 "nonimmediate_operand" "ym")))]
20364 "TARGET_MMX"
0f40f9f7 20365 "psubusw\t{%2, %0|%0, %2}"
3d34cd91
JH
20366 [(set_attr "type" "mmxadd")
20367 (set_attr "mode" "DI")])
915119a5
BS
20368
20369(define_insn "mulv4hi3"
20370 [(set (match_operand:V4HI 0 "register_operand" "=y")
20371 (mult:V4HI (match_operand:V4HI 1 "register_operand" "0")
20372 (match_operand:V4HI 2 "nonimmediate_operand" "ym")))]
20373 "TARGET_MMX"
0f40f9f7 20374 "pmullw\t{%2, %0|%0, %2}"
3d34cd91
JH
20375 [(set_attr "type" "mmxmul")
20376 (set_attr "mode" "DI")])
915119a5
BS
20377
20378(define_insn "smulv4hi3_highpart"
20379 [(set (match_operand:V4HI 0 "register_operand" "=y")
20380 (truncate:V4HI
20381 (lshiftrt:V4SI
e37af218
RH
20382 (mult:V4SI (sign_extend:V4SI
20383 (match_operand:V4HI 1 "register_operand" "0"))
20384 (sign_extend:V4SI
20385 (match_operand:V4HI 2 "nonimmediate_operand" "ym")))
915119a5
BS
20386 (const_int 16))))]
20387 "TARGET_MMX"
0f40f9f7 20388 "pmulhw\t{%2, %0|%0, %2}"
3d34cd91
JH
20389 [(set_attr "type" "mmxmul")
20390 (set_attr "mode" "DI")])
915119a5
BS
20391
20392(define_insn "umulv4hi3_highpart"
20393 [(set (match_operand:V4HI 0 "register_operand" "=y")
20394 (truncate:V4HI
20395 (lshiftrt:V4SI
e37af218
RH
20396 (mult:V4SI (zero_extend:V4SI
20397 (match_operand:V4HI 1 "register_operand" "0"))
20398 (zero_extend:V4SI
20399 (match_operand:V4HI 2 "nonimmediate_operand" "ym")))
915119a5 20400 (const_int 16))))]
47f339cf 20401 "TARGET_SSE || TARGET_3DNOW_A"
0f40f9f7 20402 "pmulhuw\t{%2, %0|%0, %2}"
3d34cd91
JH
20403 [(set_attr "type" "mmxmul")
20404 (set_attr "mode" "DI")])
915119a5
BS
20405
20406(define_insn "mmx_pmaddwd"
20407 [(set (match_operand:V2SI 0 "register_operand" "=y")
20408 (plus:V2SI
20409 (mult:V2SI
e37af218
RH
20410 (sign_extend:V2SI
20411 (vec_select:V2HI (match_operand:V4HI 1 "register_operand" "0")
20412 (parallel [(const_int 0) (const_int 2)])))
20413 (sign_extend:V2SI
20414 (vec_select:V2HI (match_operand:V4HI 2 "nonimmediate_operand" "ym")
20415 (parallel [(const_int 0) (const_int 2)]))))
915119a5
BS
20416 (mult:V2SI
20417 (sign_extend:V2SI (vec_select:V2HI (match_dup 1)
20418 (parallel [(const_int 1)
20419 (const_int 3)])))
20420 (sign_extend:V2SI (vec_select:V2HI (match_dup 2)
20421 (parallel [(const_int 1)
20422 (const_int 3)]))))))]
20423 "TARGET_MMX"
0f40f9f7 20424 "pmaddwd\t{%2, %0|%0, %2}"
3d34cd91
JH
20425 [(set_attr "type" "mmxmul")
20426 (set_attr "mode" "DI")])
915119a5
BS
20427
20428
20429;; MMX logical operations
20430;; Note we don't want to declare these as regular iordi3 insns to prevent
20431;; normal code that also wants to use the FPU from getting broken.
20432;; The UNSPECs are there to prevent the combiner from getting overly clever.
20433(define_insn "mmx_iordi3"
20434 [(set (match_operand:DI 0 "register_operand" "=y")
20435 (unspec:DI
20436 [(ior:DI (match_operand:DI 1 "register_operand" "0")
8ee41eaf
RH
20437 (match_operand:DI 2 "nonimmediate_operand" "ym"))]
20438 UNSPEC_NOP))]
915119a5 20439 "TARGET_MMX"
0f40f9f7 20440 "por\t{%2, %0|%0, %2}"
3d34cd91
JH
20441 [(set_attr "type" "mmxadd")
20442 (set_attr "mode" "DI")])
915119a5
BS
20443
20444(define_insn "mmx_xordi3"
20445 [(set (match_operand:DI 0 "register_operand" "=y")
20446 (unspec:DI
20447 [(xor:DI (match_operand:DI 1 "register_operand" "0")
8ee41eaf
RH
20448 (match_operand:DI 2 "nonimmediate_operand" "ym"))]
20449 UNSPEC_NOP))]
915119a5 20450 "TARGET_MMX"
0f40f9f7 20451 "pxor\t{%2, %0|%0, %2}"
3d34cd91
JH
20452 [(set_attr "type" "mmxadd")
20453 (set_attr "mode" "DI")
29628f27 20454 (set_attr "memory" "none")])
915119a5
BS
20455
20456;; Same as pxor, but don't show input operands so that we don't think
20457;; they are live.
20458(define_insn "mmx_clrdi"
20459 [(set (match_operand:DI 0 "register_operand" "=y")
8ee41eaf 20460 (unspec:DI [(const_int 0)] UNSPEC_NOP))]
915119a5 20461 "TARGET_MMX"
0f40f9f7 20462 "pxor\t{%0, %0|%0, %0}"
3d34cd91
JH
20463 [(set_attr "type" "mmxadd")
20464 (set_attr "mode" "DI")
6f1a6c5b 20465 (set_attr "memory" "none")])
915119a5
BS
20466
20467(define_insn "mmx_anddi3"
20468 [(set (match_operand:DI 0 "register_operand" "=y")
20469 (unspec:DI
20470 [(and:DI (match_operand:DI 1 "register_operand" "0")
8ee41eaf
RH
20471 (match_operand:DI 2 "nonimmediate_operand" "ym"))]
20472 UNSPEC_NOP))]
915119a5 20473 "TARGET_MMX"
0f40f9f7 20474 "pand\t{%2, %0|%0, %2}"
3d34cd91
JH
20475 [(set_attr "type" "mmxadd")
20476 (set_attr "mode" "DI")])
915119a5
BS
20477
20478(define_insn "mmx_nanddi3"
20479 [(set (match_operand:DI 0 "register_operand" "=y")
20480 (unspec:DI
20481 [(and:DI (not:DI (match_operand:DI 1 "register_operand" "0"))
8ee41eaf
RH
20482 (match_operand:DI 2 "nonimmediate_operand" "ym"))]
20483 UNSPEC_NOP))]
915119a5 20484 "TARGET_MMX"
0f40f9f7 20485 "pandn\t{%2, %0|%0, %2}"
3d34cd91
JH
20486 [(set_attr "type" "mmxadd")
20487 (set_attr "mode" "DI")])
915119a5
BS
20488
20489
20490;; MMX unsigned averages/sum of absolute differences
20491
20492(define_insn "mmx_uavgv8qi3"
20493 [(set (match_operand:V8QI 0 "register_operand" "=y")
20494 (ashiftrt:V8QI
20495 (plus:V8QI (plus:V8QI
20496 (match_operand:V8QI 1 "register_operand" "0")
20497 (match_operand:V8QI 2 "nonimmediate_operand" "ym"))
69ef87e2
AH
20498 (const_vector:V8QI [(const_int 1)
20499 (const_int 1)
20500 (const_int 1)
20501 (const_int 1)
20502 (const_int 1)
20503 (const_int 1)
20504 (const_int 1)
20505 (const_int 1)]))
915119a5 20506 (const_int 1)))]
47f339cf 20507 "TARGET_SSE || TARGET_3DNOW_A"
0f40f9f7 20508 "pavgb\t{%2, %0|%0, %2}"
3d34cd91
JH
20509 [(set_attr "type" "mmxshft")
20510 (set_attr "mode" "DI")])
915119a5
BS
20511
20512(define_insn "mmx_uavgv4hi3"
20513 [(set (match_operand:V4HI 0 "register_operand" "=y")
20514 (ashiftrt:V4HI
20515 (plus:V4HI (plus:V4HI
20516 (match_operand:V4HI 1 "register_operand" "0")
20517 (match_operand:V4HI 2 "nonimmediate_operand" "ym"))
69ef87e2
AH
20518 (const_vector:V4HI [(const_int 1)
20519 (const_int 1)
20520 (const_int 1)
20521 (const_int 1)]))
915119a5 20522 (const_int 1)))]
47f339cf 20523 "TARGET_SSE || TARGET_3DNOW_A"
0f40f9f7 20524 "pavgw\t{%2, %0|%0, %2}"
3d34cd91
JH
20525 [(set_attr "type" "mmxshft")
20526 (set_attr "mode" "DI")])
915119a5
BS
20527
20528(define_insn "mmx_psadbw"
916b60b7
BS
20529 [(set (match_operand:DI 0 "register_operand" "=y")
20530 (unspec:DI [(match_operand:V8QI 1 "register_operand" "0")
8ee41eaf
RH
20531 (match_operand:V8QI 2 "nonimmediate_operand" "ym")]
20532 UNSPEC_PSADBW))]
47f339cf 20533 "TARGET_SSE || TARGET_3DNOW_A"
0f40f9f7 20534 "psadbw\t{%2, %0|%0, %2}"
3d34cd91
JH
20535 [(set_attr "type" "mmxshft")
20536 (set_attr "mode" "DI")])
915119a5
BS
20537
20538
20539;; MMX insert/extract/shuffle
20540
20541(define_insn "mmx_pinsrw"
20542 [(set (match_operand:V4HI 0 "register_operand" "=y")
20543 (vec_merge:V4HI (match_operand:V4HI 1 "register_operand" "0")
20544 (vec_duplicate:V4HI
20545 (truncate:HI (match_operand:SI 2 "nonimmediate_operand" "rm")))
20546 (match_operand:SI 3 "immediate_operand" "i")))]
47f339cf 20547 "TARGET_SSE || TARGET_3DNOW_A"
0f40f9f7 20548 "pinsrw\t{%3, %2, %0|%0, %2, %3}"
3d34cd91
JH
20549 [(set_attr "type" "mmxcvt")
20550 (set_attr "mode" "DI")])
915119a5
BS
20551
20552(define_insn "mmx_pextrw"
20553 [(set (match_operand:SI 0 "register_operand" "=r")
20554 (zero_extend:SI (vec_select:HI (match_operand:V4HI 1 "register_operand" "y")
20555 (parallel
20556 [(match_operand:SI 2 "immediate_operand" "i")]))))]
47f339cf 20557 "TARGET_SSE || TARGET_3DNOW_A"
0f40f9f7 20558 "pextrw\t{%2, %1, %0|%0, %1, %2}"
3d34cd91
JH
20559 [(set_attr "type" "mmxcvt")
20560 (set_attr "mode" "DI")])
915119a5
BS
20561
20562(define_insn "mmx_pshufw"
20563 [(set (match_operand:V4HI 0 "register_operand" "=y")
20564 (unspec:V4HI [(match_operand:V4HI 1 "register_operand" "0")
8ee41eaf
RH
20565 (match_operand:SI 2 "immediate_operand" "i")]
20566 UNSPEC_SHUFFLE))]
47f339cf 20567 "TARGET_SSE || TARGET_3DNOW_A"
29628f27 20568 "pshufw\t{%2, %1, %0|%0, %1, %2}"
3d34cd91
JH
20569 [(set_attr "type" "mmxcvt")
20570 (set_attr "mode" "DI")])
915119a5
BS
20571
20572
20573;; MMX mask-generating comparisons
20574
20575(define_insn "eqv8qi3"
20576 [(set (match_operand:V8QI 0 "register_operand" "=y")
20577 (eq:V8QI (match_operand:V8QI 1 "register_operand" "0")
20578 (match_operand:V8QI 2 "nonimmediate_operand" "ym")))]
20579 "TARGET_MMX"
0f40f9f7 20580 "pcmpeqb\t{%2, %0|%0, %2}"
3d34cd91
JH
20581 [(set_attr "type" "mmxcmp")
20582 (set_attr "mode" "DI")])
915119a5
BS
20583
20584(define_insn "eqv4hi3"
20585 [(set (match_operand:V4HI 0 "register_operand" "=y")
20586 (eq:V4HI (match_operand:V4HI 1 "register_operand" "0")
20587 (match_operand:V4HI 2 "nonimmediate_operand" "ym")))]
20588 "TARGET_MMX"
0f40f9f7 20589 "pcmpeqw\t{%2, %0|%0, %2}"
3d34cd91
JH
20590 [(set_attr "type" "mmxcmp")
20591 (set_attr "mode" "DI")])
915119a5
BS
20592
20593(define_insn "eqv2si3"
20594 [(set (match_operand:V2SI 0 "register_operand" "=y")
20595 (eq:V2SI (match_operand:V2SI 1 "register_operand" "0")
20596 (match_operand:V2SI 2 "nonimmediate_operand" "ym")))]
20597 "TARGET_MMX"
0f40f9f7 20598 "pcmpeqd\t{%2, %0|%0, %2}"
3d34cd91
JH
20599 [(set_attr "type" "mmxcmp")
20600 (set_attr "mode" "DI")])
915119a5
BS
20601
20602(define_insn "gtv8qi3"
20603 [(set (match_operand:V8QI 0 "register_operand" "=y")
20604 (gt:V8QI (match_operand:V8QI 1 "register_operand" "0")
20605 (match_operand:V8QI 2 "nonimmediate_operand" "ym")))]
20606 "TARGET_MMX"
0f40f9f7 20607 "pcmpgtb\t{%2, %0|%0, %2}"
3d34cd91
JH
20608 [(set_attr "type" "mmxcmp")
20609 (set_attr "mode" "DI")])
915119a5
BS
20610
20611(define_insn "gtv4hi3"
20612 [(set (match_operand:V4HI 0 "register_operand" "=y")
20613 (gt:V4HI (match_operand:V4HI 1 "register_operand" "0")
20614 (match_operand:V4HI 2 "nonimmediate_operand" "ym")))]
20615 "TARGET_MMX"
0f40f9f7 20616 "pcmpgtw\t{%2, %0|%0, %2}"
3d34cd91
JH
20617 [(set_attr "type" "mmxcmp")
20618 (set_attr "mode" "DI")])
915119a5
BS
20619
20620(define_insn "gtv2si3"
20621 [(set (match_operand:V2SI 0 "register_operand" "=y")
20622 (gt:V2SI (match_operand:V2SI 1 "register_operand" "0")
20623 (match_operand:V2SI 2 "nonimmediate_operand" "ym")))]
20624 "TARGET_MMX"
0f40f9f7 20625 "pcmpgtd\t{%2, %0|%0, %2}"
3d34cd91
JH
20626 [(set_attr "type" "mmxcmp")
20627 (set_attr "mode" "DI")])
915119a5
BS
20628
20629
20630;; MMX max/min insns
20631
20632(define_insn "umaxv8qi3"
20633 [(set (match_operand:V8QI 0 "register_operand" "=y")
20634 (umax:V8QI (match_operand:V8QI 1 "register_operand" "0")
20635 (match_operand:V8QI 2 "nonimmediate_operand" "ym")))]
47f339cf 20636 "TARGET_SSE || TARGET_3DNOW_A"
0f40f9f7 20637 "pmaxub\t{%2, %0|%0, %2}"
3d34cd91
JH
20638 [(set_attr "type" "mmxadd")
20639 (set_attr "mode" "DI")])
915119a5
BS
20640
20641(define_insn "smaxv4hi3"
20642 [(set (match_operand:V4HI 0 "register_operand" "=y")
20643 (smax:V4HI (match_operand:V4HI 1 "register_operand" "0")
20644 (match_operand:V4HI 2 "nonimmediate_operand" "ym")))]
47f339cf 20645 "TARGET_SSE || TARGET_3DNOW_A"
0f40f9f7 20646 "pmaxsw\t{%2, %0|%0, %2}"
3d34cd91
JH
20647 [(set_attr "type" "mmxadd")
20648 (set_attr "mode" "DI")])
915119a5
BS
20649
20650(define_insn "uminv8qi3"
20651 [(set (match_operand:V8QI 0 "register_operand" "=y")
20652 (umin:V8QI (match_operand:V8QI 1 "register_operand" "0")
20653 (match_operand:V8QI 2 "nonimmediate_operand" "ym")))]
47f339cf 20654 "TARGET_SSE || TARGET_3DNOW_A"
0f40f9f7 20655 "pminub\t{%2, %0|%0, %2}"
3d34cd91
JH
20656 [(set_attr "type" "mmxadd")
20657 (set_attr "mode" "DI")])
915119a5
BS
20658
20659(define_insn "sminv4hi3"
20660 [(set (match_operand:V4HI 0 "register_operand" "=y")
20661 (smin:V4HI (match_operand:V4HI 1 "register_operand" "0")
20662 (match_operand:V4HI 2 "nonimmediate_operand" "ym")))]
47f339cf 20663 "TARGET_SSE || TARGET_3DNOW_A"
0f40f9f7 20664 "pminsw\t{%2, %0|%0, %2}"
3d34cd91
JH
20665 [(set_attr "type" "mmxadd")
20666 (set_attr "mode" "DI")])
915119a5
BS
20667
20668
20669;; MMX shifts
20670
20671(define_insn "ashrv4hi3"
20672 [(set (match_operand:V4HI 0 "register_operand" "=y")
20673 (ashiftrt:V4HI (match_operand:V4HI 1 "register_operand" "0")
20674 (match_operand:DI 2 "nonmemory_operand" "yi")))]
20675 "TARGET_MMX"
0f40f9f7 20676 "psraw\t{%2, %0|%0, %2}"
3d34cd91
JH
20677 [(set_attr "type" "mmxshft")
20678 (set_attr "mode" "DI")])
915119a5
BS
20679
20680(define_insn "ashrv2si3"
20681 [(set (match_operand:V2SI 0 "register_operand" "=y")
20682 (ashiftrt:V2SI (match_operand:V2SI 1 "register_operand" "0")
20683 (match_operand:DI 2 "nonmemory_operand" "yi")))]
20684 "TARGET_MMX"
0f40f9f7 20685 "psrad\t{%2, %0|%0, %2}"
3d34cd91
JH
20686 [(set_attr "type" "mmxshft")
20687 (set_attr "mode" "DI")])
915119a5
BS
20688
20689(define_insn "lshrv4hi3"
20690 [(set (match_operand:V4HI 0 "register_operand" "=y")
20691 (lshiftrt:V4HI (match_operand:V4HI 1 "register_operand" "0")
20692 (match_operand:DI 2 "nonmemory_operand" "yi")))]
20693 "TARGET_MMX"
0f40f9f7 20694 "psrlw\t{%2, %0|%0, %2}"
3d34cd91
JH
20695 [(set_attr "type" "mmxshft")
20696 (set_attr "mode" "DI")])
915119a5
BS
20697
20698(define_insn "lshrv2si3"
20699 [(set (match_operand:V2SI 0 "register_operand" "=y")
20700 (lshiftrt:V2SI (match_operand:V2SI 1 "register_operand" "0")
20701 (match_operand:DI 2 "nonmemory_operand" "yi")))]
20702 "TARGET_MMX"
0f40f9f7 20703 "psrld\t{%2, %0|%0, %2}"
3d34cd91
JH
20704 [(set_attr "type" "mmxshft")
20705 (set_attr "mode" "DI")])
915119a5
BS
20706
20707;; See logical MMX insns.
20708(define_insn "mmx_lshrdi3"
20709 [(set (match_operand:DI 0 "register_operand" "=y")
2b71bf37
JH
20710 (unspec:DI
20711 [(lshiftrt:DI (match_operand:DI 1 "register_operand" "0")
8ee41eaf
RH
20712 (match_operand:DI 2 "nonmemory_operand" "yi"))]
20713 UNSPEC_NOP))]
915119a5 20714 "TARGET_MMX"
0f40f9f7 20715 "psrlq\t{%2, %0|%0, %2}"
3d34cd91
JH
20716 [(set_attr "type" "mmxshft")
20717 (set_attr "mode" "DI")])
915119a5
BS
20718
20719(define_insn "ashlv4hi3"
20720 [(set (match_operand:V4HI 0 "register_operand" "=y")
20721 (ashift:V4HI (match_operand:V4HI 1 "register_operand" "0")
20722 (match_operand:DI 2 "nonmemory_operand" "yi")))]
20723 "TARGET_MMX"
0f40f9f7 20724 "psllw\t{%2, %0|%0, %2}"
3d34cd91
JH
20725 [(set_attr "type" "mmxshft")
20726 (set_attr "mode" "DI")])
915119a5
BS
20727
20728(define_insn "ashlv2si3"
20729 [(set (match_operand:V2SI 0 "register_operand" "=y")
20730 (ashift:V2SI (match_operand:V2SI 1 "register_operand" "0")
20731 (match_operand:DI 2 "nonmemory_operand" "yi")))]
20732 "TARGET_MMX"
0f40f9f7 20733 "pslld\t{%2, %0|%0, %2}"
3d34cd91
JH
20734 [(set_attr "type" "mmxshft")
20735 (set_attr "mode" "DI")])
915119a5
BS
20736
20737;; See logical MMX insns.
20738(define_insn "mmx_ashldi3"
20739 [(set (match_operand:DI 0 "register_operand" "=y")
2b71bf37
JH
20740 (unspec:DI
20741 [(ashift:DI (match_operand:DI 1 "register_operand" "0")
8ee41eaf
RH
20742 (match_operand:DI 2 "nonmemory_operand" "yi"))]
20743 UNSPEC_NOP))]
915119a5 20744 "TARGET_MMX"
0f40f9f7 20745 "psllq\t{%2, %0|%0, %2}"
3d34cd91
JH
20746 [(set_attr "type" "mmxshft")
20747 (set_attr "mode" "DI")])
915119a5
BS
20748
20749
20750;; MMX pack/unpack insns.
20751
20752(define_insn "mmx_packsswb"
20753 [(set (match_operand:V8QI 0 "register_operand" "=y")
20754 (vec_concat:V8QI
20755 (ss_truncate:V4QI (match_operand:V4HI 1 "register_operand" "0"))
20756 (ss_truncate:V4QI (match_operand:V4HI 2 "register_operand" "y"))))]
20757 "TARGET_MMX"
0f40f9f7 20758 "packsswb\t{%2, %0|%0, %2}"
3d34cd91
JH
20759 [(set_attr "type" "mmxshft")
20760 (set_attr "mode" "DI")])
915119a5
BS
20761
20762(define_insn "mmx_packssdw"
20763 [(set (match_operand:V4HI 0 "register_operand" "=y")
20764 (vec_concat:V4HI
20765 (ss_truncate:V2HI (match_operand:V2SI 1 "register_operand" "0"))
20766 (ss_truncate:V2HI (match_operand:V2SI 2 "register_operand" "y"))))]
20767 "TARGET_MMX"
0f40f9f7 20768 "packssdw\t{%2, %0|%0, %2}"
3d34cd91
JH
20769 [(set_attr "type" "mmxshft")
20770 (set_attr "mode" "DI")])
915119a5
BS
20771
20772(define_insn "mmx_packuswb"
20773 [(set (match_operand:V8QI 0 "register_operand" "=y")
20774 (vec_concat:V8QI
20775 (us_truncate:V4QI (match_operand:V4HI 1 "register_operand" "0"))
20776 (us_truncate:V4QI (match_operand:V4HI 2 "register_operand" "y"))))]
20777 "TARGET_MMX"
0f40f9f7 20778 "packuswb\t{%2, %0|%0, %2}"
3d34cd91
JH
20779 [(set_attr "type" "mmxshft")
20780 (set_attr "mode" "DI")])
915119a5
BS
20781
20782(define_insn "mmx_punpckhbw"
20783 [(set (match_operand:V8QI 0 "register_operand" "=y")
20784 (vec_merge:V8QI
20785 (vec_select:V8QI (match_operand:V8QI 1 "register_operand" "0")
20786 (parallel [(const_int 4)
20787 (const_int 0)
20788 (const_int 5)
20789 (const_int 1)
20790 (const_int 6)
20791 (const_int 2)
20792 (const_int 7)
20793 (const_int 3)]))
20794 (vec_select:V8QI (match_operand:V8QI 2 "register_operand" "y")
20795 (parallel [(const_int 0)
20796 (const_int 4)
20797 (const_int 1)
20798 (const_int 5)
20799 (const_int 2)
20800 (const_int 6)
20801 (const_int 3)
20802 (const_int 7)]))
20803 (const_int 85)))]
20804 "TARGET_MMX"
0f40f9f7 20805 "punpckhbw\t{%2, %0|%0, %2}"
3d34cd91
JH
20806 [(set_attr "type" "mmxcvt")
20807 (set_attr "mode" "DI")])
915119a5
BS
20808
20809(define_insn "mmx_punpckhwd"
20810 [(set (match_operand:V4HI 0 "register_operand" "=y")
20811 (vec_merge:V4HI
20812 (vec_select:V4HI (match_operand:V4HI 1 "register_operand" "0")
20813 (parallel [(const_int 0)
20814 (const_int 2)
20815 (const_int 1)
20816 (const_int 3)]))
20817 (vec_select:V4HI (match_operand:V4HI 2 "register_operand" "y")
20818 (parallel [(const_int 2)
20819 (const_int 0)
20820 (const_int 3)
20821 (const_int 1)]))
20822 (const_int 5)))]
20823 "TARGET_MMX"
0f40f9f7 20824 "punpckhwd\t{%2, %0|%0, %2}"
3d34cd91
JH
20825 [(set_attr "type" "mmxcvt")
20826 (set_attr "mode" "DI")])
915119a5
BS
20827
20828(define_insn "mmx_punpckhdq"
20829 [(set (match_operand:V2SI 0 "register_operand" "=y")
20830 (vec_merge:V2SI
077084dd 20831 (match_operand:V2SI 1 "register_operand" "0")
915119a5
BS
20832 (vec_select:V2SI (match_operand:V2SI 2 "register_operand" "y")
20833 (parallel [(const_int 1)
20834 (const_int 0)]))
20835 (const_int 1)))]
20836 "TARGET_MMX"
0f40f9f7 20837 "punpckhdq\t{%2, %0|%0, %2}"
3d34cd91
JH
20838 [(set_attr "type" "mmxcvt")
20839 (set_attr "mode" "DI")])
915119a5
BS
20840
20841(define_insn "mmx_punpcklbw"
20842 [(set (match_operand:V8QI 0 "register_operand" "=y")
20843 (vec_merge:V8QI
20844 (vec_select:V8QI (match_operand:V8QI 1 "register_operand" "0")
20845 (parallel [(const_int 0)
20846 (const_int 4)
20847 (const_int 1)
20848 (const_int 5)
20849 (const_int 2)
20850 (const_int 6)
20851 (const_int 3)
20852 (const_int 7)]))
20853 (vec_select:V8QI (match_operand:V8QI 2 "register_operand" "y")
20854 (parallel [(const_int 4)
20855 (const_int 0)
20856 (const_int 5)
20857 (const_int 1)
20858 (const_int 6)
20859 (const_int 2)
20860 (const_int 7)
20861 (const_int 3)]))
20862 (const_int 85)))]
20863 "TARGET_MMX"
0f40f9f7 20864 "punpcklbw\t{%2, %0|%0, %2}"
3d34cd91
JH
20865 [(set_attr "type" "mmxcvt")
20866 (set_attr "mode" "DI")])
915119a5
BS
20867
20868(define_insn "mmx_punpcklwd"
20869 [(set (match_operand:V4HI 0 "register_operand" "=y")
20870 (vec_merge:V4HI
20871 (vec_select:V4HI (match_operand:V4HI 1 "register_operand" "0")
20872 (parallel [(const_int 2)
20873 (const_int 0)
20874 (const_int 3)
20875 (const_int 1)]))
20876 (vec_select:V4HI (match_operand:V4HI 2 "register_operand" "y")
20877 (parallel [(const_int 0)
20878 (const_int 2)
20879 (const_int 1)
20880 (const_int 3)]))
20881 (const_int 5)))]
20882 "TARGET_MMX"
0f40f9f7 20883 "punpcklwd\t{%2, %0|%0, %2}"
3d34cd91
JH
20884 [(set_attr "type" "mmxcvt")
20885 (set_attr "mode" "DI")])
915119a5
BS
20886
20887(define_insn "mmx_punpckldq"
20888 [(set (match_operand:V2SI 0 "register_operand" "=y")
20889 (vec_merge:V2SI
20890 (vec_select:V2SI (match_operand:V2SI 1 "register_operand" "0")
20891 (parallel [(const_int 1)
20892 (const_int 0)]))
077084dd 20893 (match_operand:V2SI 2 "register_operand" "y")
915119a5
BS
20894 (const_int 1)))]
20895 "TARGET_MMX"
0f40f9f7 20896 "punpckldq\t{%2, %0|%0, %2}"
3d34cd91
JH
20897 [(set_attr "type" "mmxcvt")
20898 (set_attr "mode" "DI")])
915119a5
BS
20899
20900
20901;; Miscellaneous stuff
20902
20903(define_insn "emms"
8ee41eaf 20904 [(unspec_volatile [(const_int 0)] UNSPECV_EMMS)
915119a5
BS
20905 (clobber (reg:XF 8))
20906 (clobber (reg:XF 9))
20907 (clobber (reg:XF 10))
20908 (clobber (reg:XF 11))
20909 (clobber (reg:XF 12))
20910 (clobber (reg:XF 13))
20911 (clobber (reg:XF 14))
20912 (clobber (reg:XF 15))
915119a5
BS
20913 (clobber (reg:DI 29))
20914 (clobber (reg:DI 30))
20915 (clobber (reg:DI 31))
20916 (clobber (reg:DI 32))
20917 (clobber (reg:DI 33))
bd793c65
BS
20918 (clobber (reg:DI 34))
20919 (clobber (reg:DI 35))
20920 (clobber (reg:DI 36))]
915119a5
BS
20921 "TARGET_MMX"
20922 "emms"
bd793c65
BS
20923 [(set_attr "type" "mmx")
20924 (set_attr "memory" "unknown")])
915119a5
BS
20925
20926(define_insn "ldmxcsr"
8ee41eaf
RH
20927 [(unspec_volatile [(match_operand:SI 0 "memory_operand" "m")]
20928 UNSPECV_LDMXCSR)]
36210500 20929 "TARGET_SSE"
0f40f9f7 20930 "ldmxcsr\t%0"
36210500 20931 [(set_attr "type" "sse")
29628f27 20932 (set_attr "memory" "load")])
915119a5
BS
20933
20934(define_insn "stmxcsr"
20935 [(set (match_operand:SI 0 "memory_operand" "=m")
8ee41eaf 20936 (unspec_volatile:SI [(const_int 0)] UNSPECV_STMXCSR))]
36210500 20937 "TARGET_SSE"
0f40f9f7 20938 "stmxcsr\t%0"
36210500 20939 [(set_attr "type" "sse")
29628f27 20940 (set_attr "memory" "store")])
915119a5
BS
20941
20942(define_expand "sfence"
20943 [(set (match_dup 0)
8ee41eaf 20944 (unspec:BLK [(match_dup 0)] UNSPEC_SFENCE))]
47f339cf 20945 "TARGET_SSE || TARGET_3DNOW_A"
915119a5
BS
20946{
20947 operands[0] = gen_rtx_MEM (BLKmode, gen_rtx_SCRATCH (Pmode));
20948 MEM_VOLATILE_P (operands[0]) = 1;
0f40f9f7 20949})
915119a5
BS
20950
20951(define_insn "*sfence_insn"
20952 [(set (match_operand:BLK 0 "" "")
8ee41eaf 20953 (unspec:BLK [(match_dup 0)] UNSPEC_SFENCE))]
47f339cf 20954 "TARGET_SSE || TARGET_3DNOW_A"
915119a5 20955 "sfence"
bd793c65
BS
20956 [(set_attr "type" "sse")
20957 (set_attr "memory" "unknown")])
915119a5 20958
ad919812
JH
20959(define_expand "sse_prologue_save"
20960 [(parallel [(set (match_operand:BLK 0 "" "")
20961 (unspec:BLK [(reg:DI 21)
20962 (reg:DI 22)
20963 (reg:DI 23)
20964 (reg:DI 24)
20965 (reg:DI 25)
20966 (reg:DI 26)
20967 (reg:DI 27)
8ee41eaf 20968 (reg:DI 28)] UNSPEC_SSE_PROLOGUE_SAVE))
ad919812
JH
20969 (use (match_operand:DI 1 "register_operand" ""))
20970 (use (match_operand:DI 2 "immediate_operand" ""))
20971 (use (label_ref:DI (match_operand 3 "" "")))])]
20972 "TARGET_64BIT"
20973 "")
20974
20975(define_insn "*sse_prologue_save_insn"
20976 [(set (mem:BLK (plus:DI (match_operand:DI 0 "register_operand" "R")
20977 (match_operand:DI 4 "const_int_operand" "n")))
20978 (unspec:BLK [(reg:DI 21)
20979 (reg:DI 22)
20980 (reg:DI 23)
20981 (reg:DI 24)
20982 (reg:DI 25)
20983 (reg:DI 26)
20984 (reg:DI 27)
8ee41eaf 20985 (reg:DI 28)] UNSPEC_SSE_PROLOGUE_SAVE))
ad919812
JH
20986 (use (match_operand:DI 1 "register_operand" "r"))
20987 (use (match_operand:DI 2 "const_int_operand" "i"))
20988 (use (label_ref:DI (match_operand 3 "" "X")))]
20989 "TARGET_64BIT
20990 && INTVAL (operands[4]) + SSE_REGPARM_MAX * 16 - 16 < 128
20991 && INTVAL (operands[4]) + INTVAL (operands[2]) * 16 >= -128"
20992 "*
20993{
20994 int i;
20995 operands[0] = gen_rtx_MEM (Pmode,
20996 gen_rtx_PLUS (Pmode, operands[0], operands[4]));
20997 output_asm_insn (\"jmp\\t%A1\", operands);
20998 for (i = SSE_REGPARM_MAX - 1; i >= INTVAL (operands[2]); i--)
20999 {
21000 operands[4] = adjust_address (operands[0], DImode, i*16);
21001 operands[5] = gen_rtx_REG (TImode, SSE_REGNO (i));
21002 PUT_MODE (operands[4], TImode);
21003 if (GET_CODE (XEXP (operands[0], 0)) != PLUS)
21004 output_asm_insn (\"rex\", operands);
21005 output_asm_insn (\"movaps\\t{%5, %4|%4, %5}\", operands);
21006 }
4977bab6 21007 (*targetm.asm_out.internal_label) (asm_out_file, \"L\",
ad919812
JH
21008 CODE_LABEL_NUMBER (operands[3]));
21009 RET;
21010}
21011 "
21012 [(set_attr "type" "other")
21013 (set_attr "length_immediate" "0")
21014 (set_attr "length_address" "0")
21015 (set_attr "length" "135")
21016 (set_attr "memory" "store")
21017 (set_attr "modrm" "0")
21018 (set_attr "mode" "DI")])
47f339cf
BS
21019
21020;; 3Dnow! instructions
21021
21022(define_insn "addv2sf3"
21023 [(set (match_operand:V2SF 0 "register_operand" "=y")
21024 (plus:V2SF (match_operand:V2SF 1 "register_operand" "0")
21025 (match_operand:V2SF 2 "nonimmediate_operand" "ym")))]
21026 "TARGET_3DNOW"
21027 "pfadd\\t{%2, %0|%0, %2}"
3d34cd91
JH
21028 [(set_attr "type" "mmxadd")
21029 (set_attr "mode" "V2SF")])
47f339cf
BS
21030
21031(define_insn "subv2sf3"
21032 [(set (match_operand:V2SF 0 "register_operand" "=y")
21033 (minus:V2SF (match_operand:V2SF 1 "register_operand" "0")
21034 (match_operand:V2SF 2 "nonimmediate_operand" "ym")))]
21035 "TARGET_3DNOW"
21036 "pfsub\\t{%2, %0|%0, %2}"
3d34cd91
JH
21037 [(set_attr "type" "mmxadd")
21038 (set_attr "mode" "V2SF")])
47f339cf
BS
21039
21040(define_insn "subrv2sf3"
21041 [(set (match_operand:V2SF 0 "register_operand" "=y")
21042 (minus:V2SF (match_operand:V2SF 2 "nonimmediate_operand" "ym")
21043 (match_operand:V2SF 1 "register_operand" "0")))]
21044 "TARGET_3DNOW"
21045 "pfsubr\\t{%2, %0|%0, %2}"
3d34cd91
JH
21046 [(set_attr "type" "mmxadd")
21047 (set_attr "mode" "V2SF")])
47f339cf
BS
21048
21049(define_insn "gtv2sf3"
21050 [(set (match_operand:V2SI 0 "register_operand" "=y")
21051 (gt:V2SI (match_operand:V2SF 1 "register_operand" "0")
21052 (match_operand:V2SF 2 "nonimmediate_operand" "ym")))]
21053 "TARGET_3DNOW"
21054 "pfcmpgt\\t{%2, %0|%0, %2}"
3d34cd91
JH
21055 [(set_attr "type" "mmxcmp")
21056 (set_attr "mode" "V2SF")])
47f339cf
BS
21057
21058(define_insn "gev2sf3"
21059 [(set (match_operand:V2SI 0 "register_operand" "=y")
21060 (ge:V2SI (match_operand:V2SF 1 "register_operand" "0")
21061 (match_operand:V2SF 2 "nonimmediate_operand" "ym")))]
21062 "TARGET_3DNOW"
21063 "pfcmpge\\t{%2, %0|%0, %2}"
3d34cd91
JH
21064 [(set_attr "type" "mmxcmp")
21065 (set_attr "mode" "V2SF")])
47f339cf
BS
21066
21067(define_insn "eqv2sf3"
21068 [(set (match_operand:V2SI 0 "register_operand" "=y")
21069 (eq:V2SI (match_operand:V2SF 1 "register_operand" "0")
21070 (match_operand:V2SF 2 "nonimmediate_operand" "ym")))]
21071 "TARGET_3DNOW"
21072 "pfcmpeq\\t{%2, %0|%0, %2}"
3d34cd91
JH
21073 [(set_attr "type" "mmxcmp")
21074 (set_attr "mode" "V2SF")])
47f339cf
BS
21075
21076(define_insn "pfmaxv2sf3"
21077 [(set (match_operand:V2SF 0 "register_operand" "=y")
21078 (smax:V2SF (match_operand:V2SF 1 "register_operand" "0")
21079 (match_operand:V2SF 2 "nonimmediate_operand" "ym")))]
21080 "TARGET_3DNOW"
21081 "pfmax\\t{%2, %0|%0, %2}"
3d34cd91
JH
21082 [(set_attr "type" "mmxadd")
21083 (set_attr "mode" "V2SF")])
47f339cf
BS
21084
21085(define_insn "pfminv2sf3"
21086 [(set (match_operand:V2SF 0 "register_operand" "=y")
21087 (smin:V2SF (match_operand:V2SF 1 "register_operand" "0")
21088 (match_operand:V2SF 2 "nonimmediate_operand" "ym")))]
21089 "TARGET_3DNOW"
21090 "pfmin\\t{%2, %0|%0, %2}"
3d34cd91
JH
21091 [(set_attr "type" "mmxadd")
21092 (set_attr "mode" "V2SF")])
47f339cf
BS
21093
21094(define_insn "mulv2sf3"
21095 [(set (match_operand:V2SF 0 "register_operand" "=y")
21096 (mult:V2SF (match_operand:V2SF 1 "register_operand" "0")
21097 (match_operand:V2SF 2 "nonimmediate_operand" "ym")))]
21098 "TARGET_3DNOW"
21099 "pfmul\\t{%2, %0|%0, %2}"
3d34cd91
JH
21100 [(set_attr "type" "mmxmul")
21101 (set_attr "mode" "V2SF")])
47f339cf
BS
21102
21103(define_insn "femms"
8ee41eaf 21104 [(unspec_volatile [(const_int 0)] UNSPECV_FEMMS)
47f339cf
BS
21105 (clobber (reg:XF 8))
21106 (clobber (reg:XF 9))
21107 (clobber (reg:XF 10))
21108 (clobber (reg:XF 11))
21109 (clobber (reg:XF 12))
21110 (clobber (reg:XF 13))
21111 (clobber (reg:XF 14))
21112 (clobber (reg:XF 15))
21113 (clobber (reg:DI 29))
21114 (clobber (reg:DI 30))
21115 (clobber (reg:DI 31))
21116 (clobber (reg:DI 32))
21117 (clobber (reg:DI 33))
21118 (clobber (reg:DI 34))
21119 (clobber (reg:DI 35))
21120 (clobber (reg:DI 36))]
21121 "TARGET_3DNOW"
21122 "femms"
d82283d5
GS
21123 [(set_attr "type" "mmx")
21124 (set_attr "memory" "none")])
47f339cf 21125
47f339cf
BS
21126(define_insn "pf2id"
21127 [(set (match_operand:V2SI 0 "register_operand" "=y")
21128 (fix:V2SI (match_operand:V2SF 1 "nonimmediate_operand" "ym")))]
21129 "TARGET_3DNOW"
21130 "pf2id\\t{%1, %0|%0, %1}"
3d34cd91
JH
21131 [(set_attr "type" "mmxcvt")
21132 (set_attr "mode" "V2SF")])
47f339cf
BS
21133
21134(define_insn "pf2iw"
21135 [(set (match_operand:V2SI 0 "register_operand" "=y")
21136 (sign_extend:V2SI
21137 (ss_truncate:V2HI
21138 (fix:V2SI (match_operand:V2SF 1 "nonimmediate_operand" "ym")))))]
21139 "TARGET_3DNOW_A"
21140 "pf2iw\\t{%1, %0|%0, %1}"
3d34cd91
JH
21141 [(set_attr "type" "mmxcvt")
21142 (set_attr "mode" "V2SF")])
47f339cf
BS
21143
21144(define_insn "pfacc"
21145 [(set (match_operand:V2SF 0 "register_operand" "=y")
21146 (vec_concat:V2SF
21147 (plus:SF
21148 (vec_select:SF (match_operand:V2SF 1 "register_operand" "0")
21149 (parallel [(const_int 0)]))
21150 (vec_select:SF (match_dup 1)
21151 (parallel [(const_int 1)])))
21152 (plus:SF
21153 (vec_select:SF (match_operand:V2SF 2 "nonimmediate_operand" "y")
21154 (parallel [(const_int 0)]))
21155 (vec_select:SF (match_dup 2)
21156 (parallel [(const_int 1)])))))]
21157 "TARGET_3DNOW"
21158 "pfacc\\t{%2, %0|%0, %2}"
3d34cd91
JH
21159 [(set_attr "type" "mmxadd")
21160 (set_attr "mode" "V2SF")])
47f339cf
BS
21161
21162(define_insn "pfnacc"
21163 [(set (match_operand:V2SF 0 "register_operand" "=y")
21164 (vec_concat:V2SF
21165 (minus:SF
21166 (vec_select:SF (match_operand:V2SF 1 "register_operand" "0")
21167 (parallel [(const_int 0)]))
21168 (vec_select:SF (match_dup 1)
21169 (parallel [(const_int 1)])))
21170 (minus:SF
21171 (vec_select:SF (match_operand:V2SF 2 "nonimmediate_operand" "y")
21172 (parallel [(const_int 0)]))
21173 (vec_select:SF (match_dup 2)
21174 (parallel [(const_int 1)])))))]
21175 "TARGET_3DNOW_A"
21176 "pfnacc\\t{%2, %0|%0, %2}"
3d34cd91
JH
21177 [(set_attr "type" "mmxadd")
21178 (set_attr "mode" "V2SF")])
47f339cf
BS
21179
21180(define_insn "pfpnacc"
21181 [(set (match_operand:V2SF 0 "register_operand" "=y")
21182 (vec_concat:V2SF
21183 (minus:SF
21184 (vec_select:SF (match_operand:V2SF 1 "register_operand" "0")
21185 (parallel [(const_int 0)]))
21186 (vec_select:SF (match_dup 1)
21187 (parallel [(const_int 1)])))
21188 (plus:SF
21189 (vec_select:SF (match_operand:V2SF 2 "nonimmediate_operand" "y")
21190 (parallel [(const_int 0)]))
21191 (vec_select:SF (match_dup 2)
21192 (parallel [(const_int 1)])))))]
21193 "TARGET_3DNOW_A"
21194 "pfpnacc\\t{%2, %0|%0, %2}"
3d34cd91
JH
21195 [(set_attr "type" "mmxadd")
21196 (set_attr "mode" "V2SF")])
47f339cf
BS
21197
21198(define_insn "pi2fw"
21199 [(set (match_operand:V2SF 0 "register_operand" "=y")
21200 (float:V2SF
21201 (vec_concat:V2SI
21202 (sign_extend:SI
21203 (truncate:HI
21204 (vec_select:SI (match_operand:V2SI 1 "nonimmediate_operand" "ym")
21205 (parallel [(const_int 0)]))))
21206 (sign_extend:SI
21207 (truncate:HI
21208 (vec_select:SI (match_dup 1)
21209 (parallel [(const_int 1)])))))))]
21210 "TARGET_3DNOW_A"
21211 "pi2fw\\t{%1, %0|%0, %1}"
3d34cd91
JH
21212 [(set_attr "type" "mmxcvt")
21213 (set_attr "mode" "V2SF")])
47f339cf
BS
21214
21215(define_insn "floatv2si2"
21216 [(set (match_operand:V2SF 0 "register_operand" "=y")
21217 (float:V2SF (match_operand:V2SI 1 "nonimmediate_operand" "ym")))]
21218 "TARGET_3DNOW"
21219 "pi2fd\\t{%1, %0|%0, %1}"
3d34cd91
JH
21220 [(set_attr "type" "mmxcvt")
21221 (set_attr "mode" "V2SF")])
47f339cf
BS
21222
21223;; This insn is identical to pavgb in operation, but the opcode is
21224;; different. To avoid accidentally matching pavgb, use an unspec.
21225
21226(define_insn "pavgusb"
21227 [(set (match_operand:V8QI 0 "register_operand" "=y")
21228 (unspec:V8QI
21229 [(match_operand:V8QI 1 "register_operand" "0")
8ee41eaf
RH
21230 (match_operand:V8QI 2 "nonimmediate_operand" "ym")]
21231 UNSPEC_PAVGUSB))]
47f339cf
BS
21232 "TARGET_3DNOW"
21233 "pavgusb\\t{%2, %0|%0, %2}"
3d34cd91
JH
21234 [(set_attr "type" "mmxshft")
21235 (set_attr "mode" "TI")])
47f339cf 21236
d1f87653 21237;; 3DNow reciprocal and sqrt
47f339cf
BS
21238
21239(define_insn "pfrcpv2sf2"
21240 [(set (match_operand:V2SF 0 "register_operand" "=y")
8ee41eaf
RH
21241 (unspec:V2SF [(match_operand:V2SF 1 "nonimmediate_operand" "ym")]
21242 UNSPEC_PFRCP))]
47f339cf
BS
21243 "TARGET_3DNOW"
21244 "pfrcp\\t{%1, %0|%0, %1}"
3d34cd91
JH
21245 [(set_attr "type" "mmx")
21246 (set_attr "mode" "TI")])
47f339cf
BS
21247
21248(define_insn "pfrcpit1v2sf3"
21249 [(set (match_operand:V2SF 0 "register_operand" "=y")
21250 (unspec:V2SF [(match_operand:V2SF 1 "register_operand" "0")
8ee41eaf
RH
21251 (match_operand:V2SF 2 "nonimmediate_operand" "ym")]
21252 UNSPEC_PFRCPIT1))]
47f339cf
BS
21253 "TARGET_3DNOW"
21254 "pfrcpit1\\t{%2, %0|%0, %2}"
3d34cd91
JH
21255 [(set_attr "type" "mmx")
21256 (set_attr "mode" "TI")])
47f339cf
BS
21257
21258(define_insn "pfrcpit2v2sf3"
21259 [(set (match_operand:V2SF 0 "register_operand" "=y")
21260 (unspec:V2SF [(match_operand:V2SF 1 "register_operand" "0")
8ee41eaf
RH
21261 (match_operand:V2SF 2 "nonimmediate_operand" "ym")]
21262 UNSPEC_PFRCPIT2))]
47f339cf
BS
21263 "TARGET_3DNOW"
21264 "pfrcpit2\\t{%2, %0|%0, %2}"
3d34cd91
JH
21265 [(set_attr "type" "mmx")
21266 (set_attr "mode" "TI")])
47f339cf
BS
21267
21268(define_insn "pfrsqrtv2sf2"
21269 [(set (match_operand:V2SF 0 "register_operand" "=y")
8ee41eaf
RH
21270 (unspec:V2SF [(match_operand:V2SF 1 "nonimmediate_operand" "ym")]
21271 UNSPEC_PFRSQRT))]
47f339cf 21272 "TARGET_3DNOW"
3d34cd91
JH
21273 "pfrsqrt\\t{%1, %0|%0, %1}"
21274 [(set_attr "type" "mmx")
21275 (set_attr "mode" "TI")])
47f339cf
BS
21276
21277(define_insn "pfrsqit1v2sf3"
21278 [(set (match_operand:V2SF 0 "register_operand" "=y")
21279 (unspec:V2SF [(match_operand:V2SF 1 "register_operand" "0")
8ee41eaf
RH
21280 (match_operand:V2SF 2 "nonimmediate_operand" "ym")]
21281 UNSPEC_PFRSQIT1))]
47f339cf
BS
21282 "TARGET_3DNOW"
21283 "pfrsqit1\\t{%2, %0|%0, %2}"
3d34cd91
JH
21284 [(set_attr "type" "mmx")
21285 (set_attr "mode" "TI")])
47f339cf
BS
21286
21287(define_insn "pmulhrwv4hi3"
21288 [(set (match_operand:V4HI 0 "register_operand" "=y")
21289 (truncate:V4HI
21290 (lshiftrt:V4SI
21291 (plus:V4SI
21292 (mult:V4SI
21293 (sign_extend:V4SI
21294 (match_operand:V4HI 1 "register_operand" "0"))
21295 (sign_extend:V4SI
21296 (match_operand:V4HI 2 "nonimmediate_operand" "ym")))
69ef87e2
AH
21297 (const_vector:V4SI [(const_int 32768)
21298 (const_int 32768)
21299 (const_int 32768)
21300 (const_int 32768)]))
21301 (const_int 16))))]
47f339cf
BS
21302 "TARGET_3DNOW"
21303 "pmulhrw\\t{%2, %0|%0, %2}"
3d34cd91
JH
21304 [(set_attr "type" "mmxmul")
21305 (set_attr "mode" "TI")])
47f339cf
BS
21306
21307(define_insn "pswapdv2si2"
21308 [(set (match_operand:V2SI 0 "register_operand" "=y")
21309 (vec_select:V2SI (match_operand:V2SI 1 "nonimmediate_operand" "ym")
21310 (parallel [(const_int 1) (const_int 0)])))]
21311 "TARGET_3DNOW_A"
21312 "pswapd\\t{%1, %0|%0, %1}"
3d34cd91
JH
21313 [(set_attr "type" "mmxcvt")
21314 (set_attr "mode" "TI")])
47f339cf
BS
21315
21316(define_insn "pswapdv2sf2"
21317 [(set (match_operand:V2SF 0 "register_operand" "=y")
21318 (vec_select:V2SF (match_operand:V2SF 1 "nonimmediate_operand" "ym")
21319 (parallel [(const_int 1) (const_int 0)])))]
21320 "TARGET_3DNOW_A"
21321 "pswapd\\t{%1, %0|%0, %1}"
3d34cd91
JH
21322 [(set_attr "type" "mmxcvt")
21323 (set_attr "mode" "TI")])
e37af218
RH
21324
21325(define_expand "prefetch"
052c96b1 21326 [(prefetch (match_operand 0 "address_operand" "")
e37af218
RH
21327 (match_operand:SI 1 "const_int_operand" "")
21328 (match_operand:SI 2 "const_int_operand" ""))]
21329 "TARGET_PREFETCH_SSE || TARGET_3DNOW"
21330{
21331 int rw = INTVAL (operands[1]);
21332 int locality = INTVAL (operands[2]);
7d378549 21333
e37af218
RH
21334 if (rw != 0 && rw != 1)
21335 abort ();
21336 if (locality < 0 || locality > 3)
21337 abort ();
052c96b1
JH
21338 if (GET_MODE (operands[0]) != Pmode && GET_MODE (operands[0]) != VOIDmode)
21339 abort ();
e37af218
RH
21340
21341 /* Use 3dNOW prefetch in case we are asking for write prefetch not
21342 suported by SSE counterpart or the SSE prefetch is not available
21343 (K6 machines). Otherwise use SSE prefetch as it allows specifying
21344 of locality. */
21345 if (TARGET_3DNOW && (!TARGET_PREFETCH_SSE || rw))
7d378549 21346 operands[2] = GEN_INT (3);
e37af218 21347 else
7d378549 21348 operands[1] = const0_rtx;
e37af218
RH
21349})
21350
21351(define_insn "*prefetch_sse"
e8d52ba0 21352 [(prefetch (match_operand:SI 0 "address_operand" "p")
e37af218
RH
21353 (const_int 0)
21354 (match_operand:SI 1 "const_int_operand" ""))]
052c96b1
JH
21355 "TARGET_PREFETCH_SSE && !TARGET_64BIT"
21356{
21357 static const char * const patterns[4] = {
21358 "prefetchnta\t%a0", "prefetcht2\t%a0", "prefetcht1\t%a0", "prefetcht0\t%a0"
21359 };
21360
21361 int locality = INTVAL (operands[1]);
21362 if (locality < 0 || locality > 3)
21363 abort ();
21364
21365 return patterns[locality];
21366}
21367 [(set_attr "type" "sse")
21368 (set_attr "memory" "none")])
21369
21370(define_insn "*prefetch_sse_rex"
21371 [(prefetch (match_operand:DI 0 "address_operand" "p")
21372 (const_int 0)
21373 (match_operand:SI 1 "const_int_operand" ""))]
21374 "TARGET_PREFETCH_SSE && TARGET_64BIT"
e37af218
RH
21375{
21376 static const char * const patterns[4] = {
21377 "prefetchnta\t%a0", "prefetcht2\t%a0", "prefetcht1\t%a0", "prefetcht0\t%a0"
21378 };
21379
21380 int locality = INTVAL (operands[1]);
21381 if (locality < 0 || locality > 3)
21382 abort ();
21383
21384 return patterns[locality];
21385}
3d34cd91
JH
21386 [(set_attr "type" "sse")
21387 (set_attr "memory" "none")])
e37af218
RH
21388
21389(define_insn "*prefetch_3dnow"
21390 [(prefetch (match_operand:SI 0 "address_operand" "p")
21391 (match_operand:SI 1 "const_int_operand" "n")
7d378549 21392 (const_int 3))]
052c96b1
JH
21393 "TARGET_3DNOW && !TARGET_64BIT"
21394{
21395 if (INTVAL (operands[1]) == 0)
21396 return "prefetch\t%a0";
21397 else
21398 return "prefetchw\t%a0";
21399}
21400 [(set_attr "type" "mmx")
21401 (set_attr "memory" "none")])
21402
21403(define_insn "*prefetch_3dnow_rex"
21404 [(prefetch (match_operand:DI 0 "address_operand" "p")
21405 (match_operand:SI 1 "const_int_operand" "n")
21406 (const_int 3))]
21407 "TARGET_3DNOW && TARGET_64BIT"
e37af218
RH
21408{
21409 if (INTVAL (operands[1]) == 0)
21410 return "prefetch\t%a0";
21411 else
21412 return "prefetchw\t%a0";
21413}
3d34cd91
JH
21414 [(set_attr "type" "mmx")
21415 (set_attr "memory" "none")])
fbe5eb6d
BS
21416
21417;; SSE2 support
21418
21419(define_insn "addv2df3"
21420 [(set (match_operand:V2DF 0 "register_operand" "=x")
21421 (plus:V2DF (match_operand:V2DF 1 "register_operand" "0")
21422 (match_operand:V2DF 2 "nonimmediate_operand" "xm")))]
21423 "TARGET_SSE2"
21424 "addpd\t{%2, %0|%0, %2}"
3d34cd91
JH
21425 [(set_attr "type" "sseadd")
21426 (set_attr "mode" "V2DF")])
fbe5eb6d
BS
21427
21428(define_insn "vmaddv2df3"
21429 [(set (match_operand:V2DF 0 "register_operand" "=x")
21430 (vec_merge:V2DF (plus:V2DF (match_operand:V2DF 1 "register_operand" "0")
21431 (match_operand:V2DF 2 "nonimmediate_operand" "xm"))
21432 (match_dup 1)
21433 (const_int 1)))]
21434 "TARGET_SSE2"
21435 "addsd\t{%2, %0|%0, %2}"
3d34cd91
JH
21436 [(set_attr "type" "sseadd")
21437 (set_attr "mode" "DF")])
fbe5eb6d
BS
21438
21439(define_insn "subv2df3"
21440 [(set (match_operand:V2DF 0 "register_operand" "=x")
21441 (minus:V2DF (match_operand:V2DF 1 "register_operand" "0")
21442 (match_operand:V2DF 2 "nonimmediate_operand" "xm")))]
21443 "TARGET_SSE2"
21444 "subpd\t{%2, %0|%0, %2}"
3d34cd91
JH
21445 [(set_attr "type" "sseadd")
21446 (set_attr "mode" "V2DF")])
fbe5eb6d
BS
21447
21448(define_insn "vmsubv2df3"
21449 [(set (match_operand:V2DF 0 "register_operand" "=x")
21450 (vec_merge:V2DF (minus:V2DF (match_operand:V2DF 1 "register_operand" "0")
21451 (match_operand:V2DF 2 "nonimmediate_operand" "xm"))
21452 (match_dup 1)
21453 (const_int 1)))]
21454 "TARGET_SSE2"
21455 "subsd\t{%2, %0|%0, %2}"
3d34cd91
JH
21456 [(set_attr "type" "sseadd")
21457 (set_attr "mode" "DF")])
fbe5eb6d
BS
21458
21459(define_insn "mulv2df3"
21460 [(set (match_operand:V2DF 0 "register_operand" "=x")
21461 (mult:V2DF (match_operand:V2DF 1 "register_operand" "0")
21462 (match_operand:V2DF 2 "nonimmediate_operand" "xm")))]
21463 "TARGET_SSE2"
21464 "mulpd\t{%2, %0|%0, %2}"
3d34cd91
JH
21465 [(set_attr "type" "ssemul")
21466 (set_attr "mode" "V2DF")])
fbe5eb6d
BS
21467
21468(define_insn "vmmulv2df3"
21469 [(set (match_operand:V2DF 0 "register_operand" "=x")
21470 (vec_merge:V2DF (mult:V2DF (match_operand:V2DF 1 "register_operand" "0")
21471 (match_operand:V2DF 2 "nonimmediate_operand" "xm"))
21472 (match_dup 1)
21473 (const_int 1)))]
21474 "TARGET_SSE2"
21475 "mulsd\t{%2, %0|%0, %2}"
3d34cd91
JH
21476 [(set_attr "type" "ssemul")
21477 (set_attr "mode" "DF")])
fbe5eb6d
BS
21478
21479(define_insn "divv2df3"
21480 [(set (match_operand:V2DF 0 "register_operand" "=x")
21481 (div:V2DF (match_operand:V2DF 1 "register_operand" "0")
21482 (match_operand:V2DF 2 "nonimmediate_operand" "xm")))]
21483 "TARGET_SSE2"
21484 "divpd\t{%2, %0|%0, %2}"
3d34cd91
JH
21485 [(set_attr "type" "ssediv")
21486 (set_attr "mode" "V2DF")])
fbe5eb6d
BS
21487
21488(define_insn "vmdivv2df3"
21489 [(set (match_operand:V2DF 0 "register_operand" "=x")
21490 (vec_merge:V2DF (div:V2DF (match_operand:V2DF 1 "register_operand" "0")
21491 (match_operand:V2DF 2 "nonimmediate_operand" "xm"))
21492 (match_dup 1)
21493 (const_int 1)))]
21494 "TARGET_SSE2"
21495 "divsd\t{%2, %0|%0, %2}"
3d34cd91
JH
21496 [(set_attr "type" "ssediv")
21497 (set_attr "mode" "DF")])
fbe5eb6d
BS
21498
21499;; SSE min/max
21500
21501(define_insn "smaxv2df3"
21502 [(set (match_operand:V2DF 0 "register_operand" "=x")
21503 (smax:V2DF (match_operand:V2DF 1 "register_operand" "0")
21504 (match_operand:V2DF 2 "nonimmediate_operand" "xm")))]
21505 "TARGET_SSE2"
21506 "maxpd\t{%2, %0|%0, %2}"
3d34cd91
JH
21507 [(set_attr "type" "sseadd")
21508 (set_attr "mode" "V2DF")])
fbe5eb6d
BS
21509
21510(define_insn "vmsmaxv2df3"
21511 [(set (match_operand:V2DF 0 "register_operand" "=x")
21512 (vec_merge:V2DF (smax:V2DF (match_operand:V2DF 1 "register_operand" "0")
21513 (match_operand:V2DF 2 "nonimmediate_operand" "xm"))
21514 (match_dup 1)
21515 (const_int 1)))]
21516 "TARGET_SSE2"
21517 "maxsd\t{%2, %0|%0, %2}"
3d34cd91
JH
21518 [(set_attr "type" "sseadd")
21519 (set_attr "mode" "DF")])
fbe5eb6d
BS
21520
21521(define_insn "sminv2df3"
21522 [(set (match_operand:V2DF 0 "register_operand" "=x")
21523 (smin:V2DF (match_operand:V2DF 1 "register_operand" "0")
21524 (match_operand:V2DF 2 "nonimmediate_operand" "xm")))]
21525 "TARGET_SSE2"
21526 "minpd\t{%2, %0|%0, %2}"
3d34cd91
JH
21527 [(set_attr "type" "sseadd")
21528 (set_attr "mode" "V2DF")])
fbe5eb6d
BS
21529
21530(define_insn "vmsminv2df3"
21531 [(set (match_operand:V2DF 0 "register_operand" "=x")
21532 (vec_merge:V2DF (smin:V2DF (match_operand:V2DF 1 "register_operand" "0")
21533 (match_operand:V2DF 2 "nonimmediate_operand" "xm"))
21534 (match_dup 1)
21535 (const_int 1)))]
21536 "TARGET_SSE2"
21537 "minsd\t{%2, %0|%0, %2}"
3d34cd91
JH
21538 [(set_attr "type" "sseadd")
21539 (set_attr "mode" "DF")])
fbe5eb6d
BS
21540;; SSE2 square root. There doesn't appear to be an extension for the
21541;; reciprocal/rsqrt instructions if the Intel manual is to be believed.
21542
21543(define_insn "sqrtv2df2"
21544 [(set (match_operand:V2DF 0 "register_operand" "=x")
21545 (sqrt:V2DF (match_operand:V2DF 1 "register_operand" "xm")))]
21546 "TARGET_SSE2"
21547 "sqrtpd\t{%1, %0|%0, %1}"
3d34cd91
JH
21548 [(set_attr "type" "sse")
21549 (set_attr "mode" "V2DF")])
fbe5eb6d
BS
21550
21551(define_insn "vmsqrtv2df2"
21552 [(set (match_operand:V2DF 0 "register_operand" "=x")
21553 (vec_merge:V2DF (sqrt:V2DF (match_operand:V2DF 1 "register_operand" "xm"))
21554 (match_operand:V2DF 2 "register_operand" "0")
21555 (const_int 1)))]
21556 "TARGET_SSE2"
21557 "sqrtsd\t{%1, %0|%0, %1}"
3d34cd91
JH
21558 [(set_attr "type" "sse")
21559 (set_attr "mode" "SF")])
fbe5eb6d
BS
21560
21561;; SSE mask-generating compares
21562
21563(define_insn "maskcmpv2df3"
21564 [(set (match_operand:V2DI 0 "register_operand" "=x")
21565 (match_operator:V2DI 3 "sse_comparison_operator"
21566 [(match_operand:V2DF 1 "register_operand" "0")
21567 (match_operand:V2DF 2 "nonimmediate_operand" "x")]))]
21568 "TARGET_SSE2"
21569 "cmp%D3pd\t{%2, %0|%0, %2}"
3d34cd91
JH
21570 [(set_attr "type" "ssecmp")
21571 (set_attr "mode" "V2DF")])
fbe5eb6d
BS
21572
21573(define_insn "maskncmpv2df3"
21574 [(set (match_operand:V2DI 0 "register_operand" "=x")
21575 (not:V2DI
21576 (match_operator:V2DI 3 "sse_comparison_operator"
21577 [(match_operand:V2DF 1 "register_operand" "0")
21578 (match_operand:V2DF 2 "nonimmediate_operand" "x")])))]
21579 "TARGET_SSE2"
1194ca05
JH
21580{
21581 if (GET_CODE (operands[3]) == UNORDERED)
21582 return "cmpordps\t{%2, %0|%0, %2}";
21583 else
21584 return "cmpn%D3pd\t{%2, %0|%0, %2}";
21585}
3d34cd91
JH
21586 [(set_attr "type" "ssecmp")
21587 (set_attr "mode" "V2DF")])
fbe5eb6d
BS
21588
21589(define_insn "vmmaskcmpv2df3"
21590 [(set (match_operand:V2DI 0 "register_operand" "=x")
21591 (vec_merge:V2DI
21592 (match_operator:V2DI 3 "sse_comparison_operator"
21593 [(match_operand:V2DF 1 "register_operand" "0")
21594 (match_operand:V2DF 2 "nonimmediate_operand" "x")])
d9deed68 21595 (subreg:V2DI (match_dup 1) 0)
fbe5eb6d
BS
21596 (const_int 1)))]
21597 "TARGET_SSE2"
21598 "cmp%D3sd\t{%2, %0|%0, %2}"
3d34cd91
JH
21599 [(set_attr "type" "ssecmp")
21600 (set_attr "mode" "DF")])
fbe5eb6d
BS
21601
21602(define_insn "vmmaskncmpv2df3"
21603 [(set (match_operand:V2DI 0 "register_operand" "=x")
21604 (vec_merge:V2DI
21605 (not:V2DI
21606 (match_operator:V2DI 3 "sse_comparison_operator"
21607 [(match_operand:V2DF 1 "register_operand" "0")
21608 (match_operand:V2DF 2 "nonimmediate_operand" "x")]))
21609 (subreg:V2DI (match_dup 1) 0)
21610 (const_int 1)))]
21611 "TARGET_SSE2"
1194ca05
JH
21612{
21613 if (GET_CODE (operands[3]) == UNORDERED)
21614 return "cmpordsd\t{%2, %0|%0, %2}";
21615 else
21616 return "cmpn%D3sd\t{%2, %0|%0, %2}";
21617}
3d34cd91
JH
21618 [(set_attr "type" "ssecmp")
21619 (set_attr "mode" "DF")])
fbe5eb6d
BS
21620
21621(define_insn "sse2_comi"
21622 [(set (reg:CCFP 17)
1194ca05
JH
21623 (compare:CCFP (vec_select:DF
21624 (match_operand:V2DF 0 "register_operand" "x")
21625 (parallel [(const_int 0)]))
21626 (vec_select:DF
21627 (match_operand:V2DF 1 "register_operand" "x")
21628 (parallel [(const_int 0)]))))]
fbe5eb6d
BS
21629 "TARGET_SSE2"
21630 "comisd\t{%1, %0|%0, %1}"
26771da7 21631 [(set_attr "type" "ssecomi")
3d34cd91 21632 (set_attr "mode" "DF")])
fbe5eb6d
BS
21633
21634(define_insn "sse2_ucomi"
21635 [(set (reg:CCFPU 17)
1194ca05
JH
21636 (compare:CCFPU (vec_select:DF
21637 (match_operand:V2DF 0 "register_operand" "x")
21638 (parallel [(const_int 0)]))
21639 (vec_select:DF
21640 (match_operand:V2DF 1 "register_operand" "x")
21641 (parallel [(const_int 0)]))))]
fbe5eb6d
BS
21642 "TARGET_SSE2"
21643 "ucomisd\t{%1, %0|%0, %1}"
26771da7 21644 [(set_attr "type" "ssecomi")
3d34cd91 21645 (set_attr "mode" "DF")])
fbe5eb6d
BS
21646
21647;; SSE Strange Moves.
21648
21649(define_insn "sse2_movmskpd"
21650 [(set (match_operand:SI 0 "register_operand" "=r")
8ee41eaf
RH
21651 (unspec:SI [(match_operand:V2DF 1 "register_operand" "x")]
21652 UNSPEC_MOVMSK))]
fbe5eb6d
BS
21653 "TARGET_SSE2"
21654 "movmskpd\t{%1, %0|%0, %1}"
3d34cd91
JH
21655 [(set_attr "type" "ssecvt")
21656 (set_attr "mode" "V2DF")])
fbe5eb6d
BS
21657
21658(define_insn "sse2_pmovmskb"
21659 [(set (match_operand:SI 0 "register_operand" "=r")
8ee41eaf
RH
21660 (unspec:SI [(match_operand:V16QI 1 "register_operand" "x")]
21661 UNSPEC_MOVMSK))]
fbe5eb6d
BS
21662 "TARGET_SSE2"
21663 "pmovmskb\t{%1, %0|%0, %1}"
3d34cd91
JH
21664 [(set_attr "type" "ssecvt")
21665 (set_attr "mode" "V2DF")])
fbe5eb6d
BS
21666
21667(define_insn "sse2_maskmovdqu"
21668 [(set (mem:V16QI (match_operand:SI 0 "register_operand" "D"))
21669 (unspec:V16QI [(match_operand:V16QI 1 "register_operand" "x")
8ee41eaf
RH
21670 (match_operand:V16QI 2 "register_operand" "x")]
21671 UNSPEC_MASKMOV))]
fbe5eb6d
BS
21672 "TARGET_SSE2"
21673 ;; @@@ check ordering of operands in intel/nonintel syntax
21674 "maskmovdqu\t{%2, %1|%1, %2}"
3d34cd91
JH
21675 [(set_attr "type" "ssecvt")
21676 (set_attr "mode" "TI")])
fbe5eb6d 21677
f8ca7923
JH
21678(define_insn "sse2_maskmovdqu_rex64"
21679 [(set (mem:V16QI (match_operand:DI 0 "register_operand" "D"))
21680 (unspec:V16QI [(match_operand:V16QI 1 "register_operand" "x")
21681 (match_operand:V16QI 2 "register_operand" "x")]
21682 UNSPEC_MASKMOV))]
21683 "TARGET_SSE2"
21684 ;; @@@ check ordering of operands in intel/nonintel syntax
21685 "maskmovdqu\t{%2, %1|%1, %2}"
21686 [(set_attr "type" "ssecvt")
21687 (set_attr "mode" "TI")])
21688
fbe5eb6d
BS
21689(define_insn "sse2_movntv2df"
21690 [(set (match_operand:V2DF 0 "memory_operand" "=m")
8ee41eaf
RH
21691 (unspec:V2DF [(match_operand:V2DF 1 "register_operand" "x")]
21692 UNSPEC_MOVNT))]
fbe5eb6d
BS
21693 "TARGET_SSE2"
21694 "movntpd\t{%1, %0|%0, %1}"
3d34cd91
JH
21695 [(set_attr "type" "ssecvt")
21696 (set_attr "mode" "V2DF")])
fbe5eb6d 21697
916b60b7
BS
21698(define_insn "sse2_movntv2di"
21699 [(set (match_operand:V2DI 0 "memory_operand" "=m")
8ee41eaf
RH
21700 (unspec:V2DI [(match_operand:V2DI 1 "register_operand" "x")]
21701 UNSPEC_MOVNT))]
fbe5eb6d
BS
21702 "TARGET_SSE2"
21703 "movntdq\t{%1, %0|%0, %1}"
3d34cd91
JH
21704 [(set_attr "type" "ssecvt")
21705 (set_attr "mode" "TI")])
fbe5eb6d
BS
21706
21707(define_insn "sse2_movntsi"
21708 [(set (match_operand:SI 0 "memory_operand" "=m")
8ee41eaf
RH
21709 (unspec:SI [(match_operand:SI 1 "register_operand" "r")]
21710 UNSPEC_MOVNT))]
fbe5eb6d
BS
21711 "TARGET_SSE2"
21712 "movnti\t{%1, %0|%0, %1}"
3d34cd91
JH
21713 [(set_attr "type" "ssecvt")
21714 (set_attr "mode" "V2DF")])
fbe5eb6d
BS
21715
21716;; SSE <-> integer/MMX conversions
21717
21718;; Conversions between SI and SF
21719
21720(define_insn "cvtdq2ps"
21721 [(set (match_operand:V4SF 0 "register_operand" "=x")
21722 (float:V4SF (match_operand:V4SI 1 "nonimmediate_operand" "xm")))]
21723 "TARGET_SSE2"
21724 "cvtdq2ps\t{%1, %0|%0, %1}"
3d34cd91
JH
21725 [(set_attr "type" "ssecvt")
21726 (set_attr "mode" "V2DF")])
fbe5eb6d
BS
21727
21728(define_insn "cvtps2dq"
21729 [(set (match_operand:V4SI 0 "register_operand" "=x")
21730 (fix:V4SI (match_operand:V4SF 1 "nonimmediate_operand" "xm")))]
21731 "TARGET_SSE2"
21732 "cvtps2dq\t{%1, %0|%0, %1}"
3d34cd91
JH
21733 [(set_attr "type" "ssecvt")
21734 (set_attr "mode" "TI")])
fbe5eb6d
BS
21735
21736(define_insn "cvttps2dq"
21737 [(set (match_operand:V4SI 0 "register_operand" "=x")
8ee41eaf
RH
21738 (unspec:V4SI [(match_operand:V4SF 1 "nonimmediate_operand" "xm")]
21739 UNSPEC_FIX))]
fbe5eb6d
BS
21740 "TARGET_SSE2"
21741 "cvttps2dq\t{%1, %0|%0, %1}"
3d34cd91
JH
21742 [(set_attr "type" "ssecvt")
21743 (set_attr "mode" "TI")])
fbe5eb6d
BS
21744
21745;; Conversions between SI and DF
21746
21747(define_insn "cvtdq2pd"
21748 [(set (match_operand:V2DF 0 "register_operand" "=x")
21749 (float:V2DF (vec_select:V2SI
916b60b7 21750 (match_operand:V4SI 1 "nonimmediate_operand" "xm")
fbe5eb6d
BS
21751 (parallel
21752 [(const_int 0)
21753 (const_int 1)]))))]
21754 "TARGET_SSE2"
21755 "cvtdq2pd\t{%1, %0|%0, %1}"
3d34cd91
JH
21756 [(set_attr "type" "ssecvt")
21757 (set_attr "mode" "V2DF")])
fbe5eb6d
BS
21758
21759(define_insn "cvtpd2dq"
21760 [(set (match_operand:V4SI 0 "register_operand" "=x")
21761 (vec_concat:V4SI
21762 (fix:V2SI (match_operand:V2DF 1 "nonimmediate_operand" "xm"))
21763 (const_vector:V2SI [(const_int 0) (const_int 0)])))]
21764 "TARGET_SSE2"
21765 "cvtpd2dq\t{%1, %0|%0, %1}"
3d34cd91
JH
21766 [(set_attr "type" "ssecvt")
21767 (set_attr "mode" "TI")])
fbe5eb6d
BS
21768
21769(define_insn "cvttpd2dq"
21770 [(set (match_operand:V4SI 0 "register_operand" "=x")
21771 (vec_concat:V4SI
8ee41eaf
RH
21772 (unspec:V2SI [(match_operand:V2DF 1 "nonimmediate_operand" "xm")]
21773 UNSPEC_FIX)
fbe5eb6d
BS
21774 (const_vector:V2SI [(const_int 0) (const_int 0)])))]
21775 "TARGET_SSE2"
21776 "cvttpd2dq\t{%1, %0|%0, %1}"
3d34cd91
JH
21777 [(set_attr "type" "ssecvt")
21778 (set_attr "mode" "TI")])
fbe5eb6d
BS
21779
21780(define_insn "cvtpd2pi"
21781 [(set (match_operand:V2SI 0 "register_operand" "=y")
21782 (fix:V2SI (match_operand:V2DF 1 "nonimmediate_operand" "xm")))]
21783 "TARGET_SSE2"
21784 "cvtpd2pi\t{%1, %0|%0, %1}"
3d34cd91
JH
21785 [(set_attr "type" "ssecvt")
21786 (set_attr "mode" "TI")])
fbe5eb6d
BS
21787
21788(define_insn "cvttpd2pi"
21789 [(set (match_operand:V2SI 0 "register_operand" "=y")
8ee41eaf
RH
21790 (unspec:V2SI [(match_operand:V2DF 1 "nonimmediate_operand" "xm")]
21791 UNSPEC_FIX))]
fbe5eb6d
BS
21792 "TARGET_SSE2"
21793 "cvttpd2pi\t{%1, %0|%0, %1}"
3d34cd91
JH
21794 [(set_attr "type" "ssecvt")
21795 (set_attr "mode" "TI")])
fbe5eb6d
BS
21796
21797(define_insn "cvtpi2pd"
21798 [(set (match_operand:V2DF 0 "register_operand" "=x")
21799 (float:V2DF (match_operand:V2SI 1 "nonimmediate_operand" "ym")))]
21800 "TARGET_SSE2"
21801 "cvtpi2pd\t{%1, %0|%0, %1}"
3d34cd91
JH
21802 [(set_attr "type" "ssecvt")
21803 (set_attr "mode" "TI")])
fbe5eb6d
BS
21804
21805;; Conversions between SI and DF
21806
21807(define_insn "cvtsd2si"
21808 [(set (match_operand:SI 0 "register_operand" "=r")
21809 (fix:SI (vec_select:DF (match_operand:V2DF 1 "register_operand" "xm")
21810 (parallel [(const_int 0)]))))]
21811 "TARGET_SSE2"
21812 "cvtsd2si\t{%1, %0|%0, %1}"
f56e86bd 21813 [(set_attr "type" "sseicvt")
3d34cd91 21814 (set_attr "mode" "SI")])
fbe5eb6d
BS
21815
21816(define_insn "cvttsd2si"
f56e86bd
JH
21817 [(set (match_operand:SI 0 "register_operand" "=r,r")
21818 (unspec:SI [(vec_select:DF (match_operand:V2DF 1 "register_operand" "x,xm")
8ee41eaf 21819 (parallel [(const_int 0)]))] UNSPEC_FIX))]
fbe5eb6d
BS
21820 "TARGET_SSE2"
21821 "cvttsd2si\t{%1, %0|%0, %1}"
f56e86bd
JH
21822 [(set_attr "type" "sseicvt")
21823 (set_attr "mode" "SI")
21824 (set_attr "athlon_decode" "double,vector")])
fbe5eb6d
BS
21825
21826(define_insn "cvtsi2sd"
f56e86bd
JH
21827 [(set (match_operand:V2DF 0 "register_operand" "=x,x")
21828 (vec_merge:V2DF (match_operand:V2DF 1 "register_operand" "0,0")
fbe5eb6d
BS
21829 (vec_duplicate:V2DF
21830 (float:DF
f56e86bd 21831 (match_operand:SI 2 "nonimmediate_operand" "r,rm")))
fbe5eb6d
BS
21832 (const_int 2)))]
21833 "TARGET_SSE2"
680dd104 21834 "cvtsi2sd\t{%2, %0|%0, %2}"
f56e86bd
JH
21835 [(set_attr "type" "sseicvt")
21836 (set_attr "mode" "DF")
21837 (set_attr "athlon_decode" "double,direct")])
fbe5eb6d
BS
21838
21839;; Conversions between SF and DF
21840
21841(define_insn "cvtsd2ss"
f56e86bd
JH
21842 [(set (match_operand:V4SF 0 "register_operand" "=x,x")
21843 (vec_merge:V4SF (match_operand:V4SF 1 "register_operand" "0,0")
fbe5eb6d
BS
21844 (vec_duplicate:V4SF
21845 (float_truncate:V2SF
f56e86bd 21846 (match_operand:V2DF 2 "nonimmediate_operand" "x,xm")))
fbe5eb6d
BS
21847 (const_int 14)))]
21848 "TARGET_SSE2"
21849 "cvtsd2ss\t{%2, %0|%0, %2}"
3d34cd91 21850 [(set_attr "type" "ssecvt")
f56e86bd 21851 (set_attr "athlon_decode" "vector,double")
3d34cd91 21852 (set_attr "mode" "SF")])
fbe5eb6d
BS
21853
21854(define_insn "cvtss2sd"
21855 [(set (match_operand:V2DF 0 "register_operand" "=x")
21856 (vec_merge:V2DF (match_operand:V2DF 1 "register_operand" "0")
21857 (float_extend:V2DF
21858 (vec_select:V2SF
4977bab6 21859 (match_operand:V4SF 2 "nonimmediate_operand" "xm")
fbe5eb6d
BS
21860 (parallel [(const_int 0)
21861 (const_int 1)])))
21862 (const_int 2)))]
21863 "TARGET_SSE2"
21864 "cvtss2sd\t{%2, %0|%0, %2}"
3d34cd91
JH
21865 [(set_attr "type" "ssecvt")
21866 (set_attr "mode" "DF")])
fbe5eb6d
BS
21867
21868(define_insn "cvtpd2ps"
21869 [(set (match_operand:V4SF 0 "register_operand" "=x")
21870 (subreg:V4SF
21871 (vec_concat:V4SI
21872 (subreg:V2SI (float_truncate:V2SF
21873 (match_operand:V2DF 1 "nonimmediate_operand" "xm")) 0)
21874 (const_vector:V2SI [(const_int 0) (const_int 0)])) 0))]
21875 "TARGET_SSE2"
21876 "cvtpd2ps\t{%1, %0|%0, %1}"
3d34cd91
JH
21877 [(set_attr "type" "ssecvt")
21878 (set_attr "mode" "V4SF")])
fbe5eb6d
BS
21879
21880(define_insn "cvtps2pd"
21881 [(set (match_operand:V2DF 0 "register_operand" "=x")
21882 (float_extend:V2DF
21883 (vec_select:V2SF (match_operand:V4SF 1 "nonimmediate_operand" "xm")
21884 (parallel [(const_int 0)
21885 (const_int 1)]))))]
21886 "TARGET_SSE2"
21887 "cvtps2pd\t{%1, %0|%0, %1}"
3d34cd91
JH
21888 [(set_attr "type" "ssecvt")
21889 (set_attr "mode" "V2DF")])
fbe5eb6d
BS
21890
21891;; SSE2 variants of MMX insns
21892
21893;; MMX arithmetic
21894
21895(define_insn "addv16qi3"
21896 [(set (match_operand:V16QI 0 "register_operand" "=x")
21897 (plus:V16QI (match_operand:V16QI 1 "register_operand" "0")
21898 (match_operand:V16QI 2 "nonimmediate_operand" "xm")))]
21899 "TARGET_SSE2"
21900 "paddb\t{%2, %0|%0, %2}"
3d34cd91
JH
21901 [(set_attr "type" "sseiadd")
21902 (set_attr "mode" "TI")])
fbe5eb6d
BS
21903
21904(define_insn "addv8hi3"
21905 [(set (match_operand:V8HI 0 "register_operand" "=x")
21906 (plus:V8HI (match_operand:V8HI 1 "register_operand" "0")
21907 (match_operand:V8HI 2 "nonimmediate_operand" "xm")))]
21908 "TARGET_SSE2"
21909 "paddw\t{%2, %0|%0, %2}"
3d34cd91
JH
21910 [(set_attr "type" "sseiadd")
21911 (set_attr "mode" "TI")])
fbe5eb6d
BS
21912
21913(define_insn "addv4si3"
21914 [(set (match_operand:V4SI 0 "register_operand" "=x")
21915 (plus:V4SI (match_operand:V4SI 1 "register_operand" "0")
21916 (match_operand:V4SI 2 "nonimmediate_operand" "xm")))]
21917 "TARGET_SSE2"
21918 "paddd\t{%2, %0|%0, %2}"
3d34cd91
JH
21919 [(set_attr "type" "sseiadd")
21920 (set_attr "mode" "TI")])
fbe5eb6d
BS
21921
21922(define_insn "addv2di3"
21923 [(set (match_operand:V2DI 0 "register_operand" "=x")
21924 (plus:V2DI (match_operand:V2DI 1 "register_operand" "0")
21925 (match_operand:V2DI 2 "nonimmediate_operand" "xm")))]
21926 "TARGET_SSE2"
21927 "paddq\t{%2, %0|%0, %2}"
3d34cd91
JH
21928 [(set_attr "type" "sseiadd")
21929 (set_attr "mode" "TI")])
fbe5eb6d
BS
21930
21931(define_insn "ssaddv16qi3"
21932 [(set (match_operand:V16QI 0 "register_operand" "=x")
21933 (ss_plus:V16QI (match_operand:V16QI 1 "register_operand" "0")
21934 (match_operand:V16QI 2 "nonimmediate_operand" "xm")))]
21935 "TARGET_SSE2"
21936 "paddsb\t{%2, %0|%0, %2}"
3d34cd91
JH
21937 [(set_attr "type" "sseiadd")
21938 (set_attr "mode" "TI")])
fbe5eb6d
BS
21939
21940(define_insn "ssaddv8hi3"
21941 [(set (match_operand:V8HI 0 "register_operand" "=x")
21942 (ss_plus:V8HI (match_operand:V8HI 1 "register_operand" "0")
21943 (match_operand:V8HI 2 "nonimmediate_operand" "xm")))]
21944 "TARGET_SSE2"
21945 "paddsw\t{%2, %0|%0, %2}"
3d34cd91
JH
21946 [(set_attr "type" "sseiadd")
21947 (set_attr "mode" "TI")])
fbe5eb6d
BS
21948
21949(define_insn "usaddv16qi3"
21950 [(set (match_operand:V16QI 0 "register_operand" "=x")
21951 (us_plus:V16QI (match_operand:V16QI 1 "register_operand" "0")
21952 (match_operand:V16QI 2 "nonimmediate_operand" "xm")))]
21953 "TARGET_SSE2"
21954 "paddusb\t{%2, %0|%0, %2}"
3d34cd91
JH
21955 [(set_attr "type" "sseiadd")
21956 (set_attr "mode" "TI")])
fbe5eb6d
BS
21957
21958(define_insn "usaddv8hi3"
21959 [(set (match_operand:V8HI 0 "register_operand" "=x")
21960 (us_plus:V8HI (match_operand:V8HI 1 "register_operand" "0")
21961 (match_operand:V8HI 2 "nonimmediate_operand" "xm")))]
21962 "TARGET_SSE2"
21963 "paddusw\t{%2, %0|%0, %2}"
3d34cd91
JH
21964 [(set_attr "type" "sseiadd")
21965 (set_attr "mode" "TI")])
fbe5eb6d
BS
21966
21967(define_insn "subv16qi3"
21968 [(set (match_operand:V16QI 0 "register_operand" "=x")
21969 (minus:V16QI (match_operand:V16QI 1 "register_operand" "0")
21970 (match_operand:V16QI 2 "nonimmediate_operand" "xm")))]
21971 "TARGET_SSE2"
21972 "psubb\t{%2, %0|%0, %2}"
3d34cd91
JH
21973 [(set_attr "type" "sseiadd")
21974 (set_attr "mode" "TI")])
fbe5eb6d
BS
21975
21976(define_insn "subv8hi3"
21977 [(set (match_operand:V8HI 0 "register_operand" "=x")
21978 (minus:V8HI (match_operand:V8HI 1 "register_operand" "0")
21979 (match_operand:V8HI 2 "nonimmediate_operand" "xm")))]
21980 "TARGET_SSE2"
21981 "psubw\t{%2, %0|%0, %2}"
3d34cd91
JH
21982 [(set_attr "type" "sseiadd")
21983 (set_attr "mode" "TI")])
fbe5eb6d
BS
21984
21985(define_insn "subv4si3"
21986 [(set (match_operand:V4SI 0 "register_operand" "=x")
21987 (minus:V4SI (match_operand:V4SI 1 "register_operand" "0")
21988 (match_operand:V4SI 2 "nonimmediate_operand" "xm")))]
21989 "TARGET_SSE2"
21990 "psubd\t{%2, %0|%0, %2}"
3d34cd91
JH
21991 [(set_attr "type" "sseiadd")
21992 (set_attr "mode" "TI")])
fbe5eb6d
BS
21993
21994(define_insn "subv2di3"
21995 [(set (match_operand:V2DI 0 "register_operand" "=x")
21996 (minus:V2DI (match_operand:V2DI 1 "register_operand" "0")
21997 (match_operand:V2DI 2 "nonimmediate_operand" "xm")))]
21998 "TARGET_SSE2"
21999 "psubq\t{%2, %0|%0, %2}"
3d34cd91
JH
22000 [(set_attr "type" "sseiadd")
22001 (set_attr "mode" "TI")])
fbe5eb6d
BS
22002
22003(define_insn "sssubv16qi3"
22004 [(set (match_operand:V16QI 0 "register_operand" "=x")
22005 (ss_minus:V16QI (match_operand:V16QI 1 "register_operand" "0")
22006 (match_operand:V16QI 2 "nonimmediate_operand" "xm")))]
22007 "TARGET_SSE2"
22008 "psubsb\t{%2, %0|%0, %2}"
3d34cd91
JH
22009 [(set_attr "type" "sseiadd")
22010 (set_attr "mode" "TI")])
fbe5eb6d
BS
22011
22012(define_insn "sssubv8hi3"
22013 [(set (match_operand:V8HI 0 "register_operand" "=x")
22014 (ss_minus:V8HI (match_operand:V8HI 1 "register_operand" "0")
22015 (match_operand:V8HI 2 "nonimmediate_operand" "xm")))]
22016 "TARGET_SSE2"
22017 "psubsw\t{%2, %0|%0, %2}"
3d34cd91
JH
22018 [(set_attr "type" "sseiadd")
22019 (set_attr "mode" "TI")])
fbe5eb6d
BS
22020
22021(define_insn "ussubv16qi3"
22022 [(set (match_operand:V16QI 0 "register_operand" "=x")
22023 (us_minus:V16QI (match_operand:V16QI 1 "register_operand" "0")
22024 (match_operand:V16QI 2 "nonimmediate_operand" "xm")))]
22025 "TARGET_SSE2"
22026 "psubusb\t{%2, %0|%0, %2}"
3d34cd91
JH
22027 [(set_attr "type" "sseiadd")
22028 (set_attr "mode" "TI")])
fbe5eb6d
BS
22029
22030(define_insn "ussubv8hi3"
22031 [(set (match_operand:V8HI 0 "register_operand" "=x")
22032 (us_minus:V8HI (match_operand:V8HI 1 "register_operand" "0")
22033 (match_operand:V8HI 2 "nonimmediate_operand" "xm")))]
22034 "TARGET_SSE2"
22035 "psubusw\t{%2, %0|%0, %2}"
3d34cd91
JH
22036 [(set_attr "type" "sseiadd")
22037 (set_attr "mode" "TI")])
fbe5eb6d
BS
22038
22039(define_insn "mulv8hi3"
22040 [(set (match_operand:V8HI 0 "register_operand" "=x")
22041 (mult:V8HI (match_operand:V8HI 1 "register_operand" "0")
22042 (match_operand:V8HI 2 "nonimmediate_operand" "xm")))]
22043 "TARGET_SSE2"
22044 "pmullw\t{%2, %0|%0, %2}"
3d34cd91
JH
22045 [(set_attr "type" "sseimul")
22046 (set_attr "mode" "TI")])
fbe5eb6d
BS
22047
22048(define_insn "smulv8hi3_highpart"
22049 [(set (match_operand:V8HI 0 "register_operand" "=x")
22050 (truncate:V8HI
22051 (lshiftrt:V8SI
22052 (mult:V8SI (sign_extend:V8SI (match_operand:V8HI 1 "register_operand" "0"))
22053 (sign_extend:V8SI (match_operand:V8HI 2 "nonimmediate_operand" "xm")))
22054 (const_int 16))))]
22055 "TARGET_SSE2"
22056 "pmulhw\t{%2, %0|%0, %2}"
3d34cd91
JH
22057 [(set_attr "type" "sseimul")
22058 (set_attr "mode" "TI")])
fbe5eb6d
BS
22059
22060(define_insn "umulv8hi3_highpart"
22061 [(set (match_operand:V8HI 0 "register_operand" "=x")
22062 (truncate:V8HI
22063 (lshiftrt:V8SI
22064 (mult:V8SI (zero_extend:V8SI (match_operand:V8HI 1 "register_operand" "0"))
22065 (zero_extend:V8SI (match_operand:V8HI 2 "nonimmediate_operand" "xm")))
22066 (const_int 16))))]
22067 "TARGET_SSE2"
22068 "pmulhuw\t{%2, %0|%0, %2}"
3d34cd91
JH
22069 [(set_attr "type" "sseimul")
22070 (set_attr "mode" "TI")])
fbe5eb6d 22071
fbe5eb6d
BS
22072(define_insn "sse2_umulsidi3"
22073 [(set (match_operand:DI 0 "register_operand" "=y")
916b60b7
BS
22074 (mult:DI (zero_extend:DI (vec_select:SI
22075 (match_operand:V2SI 1 "register_operand" "0")
22076 (parallel [(const_int 0)])))
22077 (zero_extend:DI (vec_select:SI
22078 (match_operand:V2SI 2 "nonimmediate_operand" "ym")
22079 (parallel [(const_int 0)])))))]
fbe5eb6d
BS
22080 "TARGET_SSE2"
22081 "pmuludq\t{%2, %0|%0, %2}"
3d34cd91
JH
22082 [(set_attr "type" "sseimul")
22083 (set_attr "mode" "TI")])
fbe5eb6d
BS
22084
22085(define_insn "sse2_umulv2siv2di3"
680dd104 22086 [(set (match_operand:V2DI 0 "register_operand" "=x")
fbe5eb6d
BS
22087 (mult:V2DI (zero_extend:V2DI
22088 (vec_select:V2SI
22089 (match_operand:V4SI 1 "register_operand" "0")
22090 (parallel [(const_int 0) (const_int 2)])))
22091 (zero_extend:V2DI
22092 (vec_select:V2SI
680dd104 22093 (match_operand:V4SI 2 "nonimmediate_operand" "xm")
fbe5eb6d
BS
22094 (parallel [(const_int 0) (const_int 2)])))))]
22095 "TARGET_SSE2"
22096 "pmuludq\t{%2, %0|%0, %2}"
3d34cd91
JH
22097 [(set_attr "type" "sseimul")
22098 (set_attr "mode" "TI")])
fbe5eb6d
BS
22099
22100(define_insn "sse2_pmaddwd"
22101 [(set (match_operand:V4SI 0 "register_operand" "=x")
22102 (plus:V4SI
22103 (mult:V4SI
22104 (sign_extend:V4SI (vec_select:V4HI (match_operand:V8HI 1 "register_operand" "0")
22105 (parallel [(const_int 0)
22106 (const_int 2)
22107 (const_int 4)
22108 (const_int 6)])))
22109 (sign_extend:V4SI (vec_select:V4HI (match_operand:V8HI 2 "nonimmediate_operand" "xm")
22110 (parallel [(const_int 0)
22111 (const_int 2)
22112 (const_int 4)
22113 (const_int 6)]))))
22114 (mult:V4SI
22115 (sign_extend:V4SI (vec_select:V4HI (match_dup 1)
22116 (parallel [(const_int 1)
22117 (const_int 3)
22118 (const_int 5)
22119 (const_int 7)])))
22120 (sign_extend:V4SI (vec_select:V4HI (match_dup 2)
22121 (parallel [(const_int 1)
22122 (const_int 3)
22123 (const_int 5)
22124 (const_int 7)]))))))]
22125 "TARGET_SSE2"
22126 "pmaddwd\t{%2, %0|%0, %2}"
3d34cd91
JH
22127 [(set_attr "type" "sseiadd")
22128 (set_attr "mode" "TI")])
fbe5eb6d
BS
22129
22130;; Same as pxor, but don't show input operands so that we don't think
22131;; they are live.
22132(define_insn "sse2_clrti"
22133 [(set (match_operand:TI 0 "register_operand" "=x") (const_int 0))]
22134 "TARGET_SSE2"
4977bab6
ZW
22135{
22136 if (get_attr_mode (insn) == MODE_TI)
22137 return "pxor\t%0, %0";
22138 else
22139 return "xorps\t%0, %0";
22140}
22141 [(set_attr "type" "ssemov")
19cba4a0 22142 (set_attr "memory" "none")
4977bab6
ZW
22143 (set (attr "mode")
22144 (if_then_else
22145 (ne (symbol_ref "optimize_size")
22146 (const_int 0))
22147 (const_string "V4SF")
22148 (const_string "TI")))])
fbe5eb6d
BS
22149
22150;; MMX unsigned averages/sum of absolute differences
22151
22152(define_insn "sse2_uavgv16qi3"
22153 [(set (match_operand:V16QI 0 "register_operand" "=x")
22154 (ashiftrt:V16QI
22155 (plus:V16QI (plus:V16QI
22156 (match_operand:V16QI 1 "register_operand" "0")
680dd104 22157 (match_operand:V16QI 2 "nonimmediate_operand" "xm"))
fbe5eb6d
BS
22158 (const_vector:V16QI [(const_int 1) (const_int 1)
22159 (const_int 1) (const_int 1)
22160 (const_int 1) (const_int 1)
22161 (const_int 1) (const_int 1)
22162 (const_int 1) (const_int 1)
22163 (const_int 1) (const_int 1)
22164 (const_int 1) (const_int 1)
22165 (const_int 1) (const_int 1)]))
22166 (const_int 1)))]
22167 "TARGET_SSE2"
22168 "pavgb\t{%2, %0|%0, %2}"
3d34cd91
JH
22169 [(set_attr "type" "sseiadd")
22170 (set_attr "mode" "TI")])
fbe5eb6d
BS
22171
22172(define_insn "sse2_uavgv8hi3"
22173 [(set (match_operand:V8HI 0 "register_operand" "=x")
22174 (ashiftrt:V8HI
22175 (plus:V8HI (plus:V8HI
22176 (match_operand:V8HI 1 "register_operand" "0")
680dd104 22177 (match_operand:V8HI 2 "nonimmediate_operand" "xm"))
fbe5eb6d
BS
22178 (const_vector:V8HI [(const_int 1) (const_int 1)
22179 (const_int 1) (const_int 1)
22180 (const_int 1) (const_int 1)
22181 (const_int 1) (const_int 1)]))
22182 (const_int 1)))]
22183 "TARGET_SSE2"
22184 "pavgw\t{%2, %0|%0, %2}"
3d34cd91
JH
22185 [(set_attr "type" "sseiadd")
22186 (set_attr "mode" "TI")])
fbe5eb6d
BS
22187
22188;; @@@ this isn't the right representation.
22189(define_insn "sse2_psadbw"
916b60b7
BS
22190 [(set (match_operand:V2DI 0 "register_operand" "=x")
22191 (unspec:V2DI [(match_operand:V16QI 1 "register_operand" "0")
680dd104 22192 (match_operand:V16QI 2 "nonimmediate_operand" "xm")]
8ee41eaf 22193 UNSPEC_PSADBW))]
fbe5eb6d
BS
22194 "TARGET_SSE2"
22195 "psadbw\t{%2, %0|%0, %2}"
3d34cd91
JH
22196 [(set_attr "type" "sseiadd")
22197 (set_attr "mode" "TI")])
fbe5eb6d
BS
22198
22199
22200;; MMX insert/extract/shuffle
22201
22202(define_insn "sse2_pinsrw"
22203 [(set (match_operand:V8HI 0 "register_operand" "=x")
22204 (vec_merge:V8HI (match_operand:V8HI 1 "register_operand" "0")
22205 (vec_duplicate:V8HI
d9deed68
JH
22206 (truncate:HI
22207 (match_operand:SI 2 "nonimmediate_operand" "rm")))
fbe5eb6d
BS
22208 (match_operand:SI 3 "immediate_operand" "i")))]
22209 "TARGET_SSE2"
22210 "pinsrw\t{%3, %2, %0|%0, %2, %3}"
3d34cd91
JH
22211 [(set_attr "type" "ssecvt")
22212 (set_attr "mode" "TI")])
fbe5eb6d
BS
22213
22214(define_insn "sse2_pextrw"
22215 [(set (match_operand:SI 0 "register_operand" "=r")
22216 (zero_extend:SI
22217 (vec_select:HI (match_operand:V8HI 1 "register_operand" "x")
22218 (parallel
22219 [(match_operand:SI 2 "immediate_operand" "i")]))))]
22220 "TARGET_SSE2"
22221 "pextrw\t{%2, %1, %0|%0, %1, %2}"
3d34cd91
JH
22222 [(set_attr "type" "ssecvt")
22223 (set_attr "mode" "TI")])
fbe5eb6d
BS
22224
22225(define_insn "sse2_pshufd"
22226 [(set (match_operand:V4SI 0 "register_operand" "=x")
22227 (unspec:V4SI [(match_operand:V4SI 1 "register_operand" "0")
8ee41eaf
RH
22228 (match_operand:SI 2 "immediate_operand" "i")]
22229 UNSPEC_SHUFFLE))]
fbe5eb6d
BS
22230 "TARGET_SSE2"
22231 "pshufd\t{%2, %1, %0|%0, %1, %2}"
3d34cd91
JH
22232 [(set_attr "type" "ssecvt")
22233 (set_attr "mode" "TI")])
fbe5eb6d
BS
22234
22235(define_insn "sse2_pshuflw"
22236 [(set (match_operand:V8HI 0 "register_operand" "=x")
22237 (unspec:V8HI [(match_operand:V8HI 1 "register_operand" "0")
8ee41eaf
RH
22238 (match_operand:SI 2 "immediate_operand" "i")]
22239 UNSPEC_PSHUFLW))]
fbe5eb6d
BS
22240 "TARGET_SSE2"
22241 "pshuflw\t{%2, %1, %0|%0, %1, %2}"
3d34cd91
JH
22242 [(set_attr "type" "ssecvt")
22243 (set_attr "mode" "TI")])
fbe5eb6d
BS
22244
22245(define_insn "sse2_pshufhw"
22246 [(set (match_operand:V8HI 0 "register_operand" "=x")
22247 (unspec:V8HI [(match_operand:V8HI 1 "register_operand" "0")
8ee41eaf
RH
22248 (match_operand:SI 2 "immediate_operand" "i")]
22249 UNSPEC_PSHUFHW))]
fbe5eb6d
BS
22250 "TARGET_SSE2"
22251 "pshufhw\t{%2, %1, %0|%0, %1, %2}"
3d34cd91
JH
22252 [(set_attr "type" "ssecvt")
22253 (set_attr "mode" "TI")])
fbe5eb6d
BS
22254
22255;; MMX mask-generating comparisons
22256
22257(define_insn "eqv16qi3"
22258 [(set (match_operand:V16QI 0 "register_operand" "=x")
22259 (eq:V16QI (match_operand:V16QI 1 "register_operand" "0")
22260 (match_operand:V16QI 2 "nonimmediate_operand" "xm")))]
22261 "TARGET_SSE2"
22262 "pcmpeqb\t{%2, %0|%0, %2}"
3d34cd91
JH
22263 [(set_attr "type" "ssecmp")
22264 (set_attr "mode" "TI")])
fbe5eb6d
BS
22265
22266(define_insn "eqv8hi3"
22267 [(set (match_operand:V8HI 0 "register_operand" "=x")
22268 (eq:V8HI (match_operand:V8HI 1 "register_operand" "0")
22269 (match_operand:V8HI 2 "nonimmediate_operand" "xm")))]
22270 "TARGET_SSE2"
22271 "pcmpeqw\t{%2, %0|%0, %2}"
3d34cd91
JH
22272 [(set_attr "type" "ssecmp")
22273 (set_attr "mode" "TI")])
fbe5eb6d
BS
22274
22275(define_insn "eqv4si3"
22276 [(set (match_operand:V4SI 0 "register_operand" "=x")
22277 (eq:V4SI (match_operand:V4SI 1 "register_operand" "0")
22278 (match_operand:V4SI 2 "nonimmediate_operand" "xm")))]
22279 "TARGET_SSE2"
22280 "pcmpeqd\t{%2, %0|%0, %2}"
3d34cd91
JH
22281 [(set_attr "type" "ssecmp")
22282 (set_attr "mode" "TI")])
fbe5eb6d
BS
22283
22284(define_insn "gtv16qi3"
22285 [(set (match_operand:V16QI 0 "register_operand" "=x")
22286 (gt:V16QI (match_operand:V16QI 1 "register_operand" "0")
22287 (match_operand:V16QI 2 "nonimmediate_operand" "xm")))]
22288 "TARGET_SSE2"
22289 "pcmpgtb\t{%2, %0|%0, %2}"
3d34cd91
JH
22290 [(set_attr "type" "ssecmp")
22291 (set_attr "mode" "TI")])
fbe5eb6d
BS
22292
22293(define_insn "gtv8hi3"
22294 [(set (match_operand:V8HI 0 "register_operand" "=x")
22295 (gt:V8HI (match_operand:V8HI 1 "register_operand" "0")
22296 (match_operand:V8HI 2 "nonimmediate_operand" "xm")))]
22297 "TARGET_SSE2"
22298 "pcmpgtw\t{%2, %0|%0, %2}"
3d34cd91
JH
22299 [(set_attr "type" "ssecmp")
22300 (set_attr "mode" "TI")])
fbe5eb6d
BS
22301
22302(define_insn "gtv4si3"
22303 [(set (match_operand:V4SI 0 "register_operand" "=x")
22304 (gt:V4SI (match_operand:V4SI 1 "register_operand" "0")
22305 (match_operand:V4SI 2 "nonimmediate_operand" "xm")))]
22306 "TARGET_SSE2"
22307 "pcmpgtd\t{%2, %0|%0, %2}"
3d34cd91
JH
22308 [(set_attr "type" "ssecmp")
22309 (set_attr "mode" "TI")])
fbe5eb6d
BS
22310
22311
22312;; MMX max/min insns
22313
22314(define_insn "umaxv16qi3"
22315 [(set (match_operand:V16QI 0 "register_operand" "=x")
22316 (umax:V16QI (match_operand:V16QI 1 "register_operand" "0")
22317 (match_operand:V16QI 2 "nonimmediate_operand" "xm")))]
22318 "TARGET_SSE2"
22319 "pmaxub\t{%2, %0|%0, %2}"
3d34cd91
JH
22320 [(set_attr "type" "sseiadd")
22321 (set_attr "mode" "TI")])
fbe5eb6d
BS
22322
22323(define_insn "smaxv8hi3"
22324 [(set (match_operand:V8HI 0 "register_operand" "=x")
22325 (smax:V8HI (match_operand:V8HI 1 "register_operand" "0")
22326 (match_operand:V8HI 2 "nonimmediate_operand" "xm")))]
22327 "TARGET_SSE2"
22328 "pmaxsw\t{%2, %0|%0, %2}"
3d34cd91
JH
22329 [(set_attr "type" "sseiadd")
22330 (set_attr "mode" "TI")])
fbe5eb6d
BS
22331
22332(define_insn "uminv16qi3"
22333 [(set (match_operand:V16QI 0 "register_operand" "=x")
22334 (umin:V16QI (match_operand:V16QI 1 "register_operand" "0")
22335 (match_operand:V16QI 2 "nonimmediate_operand" "xm")))]
22336 "TARGET_SSE2"
22337 "pminub\t{%2, %0|%0, %2}"
3d34cd91
JH
22338 [(set_attr "type" "sseiadd")
22339 (set_attr "mode" "TI")])
fbe5eb6d
BS
22340
22341(define_insn "sminv8hi3"
22342 [(set (match_operand:V8HI 0 "register_operand" "=x")
22343 (smin:V8HI (match_operand:V8HI 1 "register_operand" "0")
22344 (match_operand:V8HI 2 "nonimmediate_operand" "xm")))]
22345 "TARGET_SSE2"
22346 "pminsw\t{%2, %0|%0, %2}"
3d34cd91
JH
22347 [(set_attr "type" "sseiadd")
22348 (set_attr "mode" "TI")])
fbe5eb6d
BS
22349
22350
22351;; MMX shifts
22352
22353(define_insn "ashrv8hi3"
22354 [(set (match_operand:V8HI 0 "register_operand" "=x")
22355 (ashiftrt:V8HI (match_operand:V8HI 1 "register_operand" "0")
d9deed68 22356 (match_operand:TI 2 "nonmemory_operand" "xi")))]
fbe5eb6d
BS
22357 "TARGET_SSE2"
22358 "psraw\t{%2, %0|%0, %2}"
3d34cd91
JH
22359 [(set_attr "type" "sseishft")
22360 (set_attr "mode" "TI")])
fbe5eb6d
BS
22361
22362(define_insn "ashrv4si3"
22363 [(set (match_operand:V4SI 0 "register_operand" "=x")
22364 (ashiftrt:V4SI (match_operand:V4SI 1 "register_operand" "0")
d9deed68 22365 (match_operand:TI 2 "nonmemory_operand" "xi")))]
fbe5eb6d
BS
22366 "TARGET_SSE2"
22367 "psrad\t{%2, %0|%0, %2}"
3d34cd91
JH
22368 [(set_attr "type" "sseishft")
22369 (set_attr "mode" "TI")])
fbe5eb6d
BS
22370
22371(define_insn "lshrv8hi3"
22372 [(set (match_operand:V8HI 0 "register_operand" "=x")
22373 (lshiftrt:V8HI (match_operand:V8HI 1 "register_operand" "0")
d9deed68 22374 (match_operand:TI 2 "nonmemory_operand" "xi")))]
fbe5eb6d
BS
22375 "TARGET_SSE2"
22376 "psrlw\t{%2, %0|%0, %2}"
3d34cd91
JH
22377 [(set_attr "type" "sseishft")
22378 (set_attr "mode" "TI")])
fbe5eb6d
BS
22379
22380(define_insn "lshrv4si3"
22381 [(set (match_operand:V4SI 0 "register_operand" "=x")
22382 (lshiftrt:V4SI (match_operand:V4SI 1 "register_operand" "0")
d9deed68 22383 (match_operand:TI 2 "nonmemory_operand" "xi")))]
fbe5eb6d
BS
22384 "TARGET_SSE2"
22385 "psrld\t{%2, %0|%0, %2}"
3d34cd91
JH
22386 [(set_attr "type" "sseishft")
22387 (set_attr "mode" "TI")])
fbe5eb6d 22388
916b60b7 22389(define_insn "lshrv2di3"
fbe5eb6d
BS
22390 [(set (match_operand:V2DI 0 "register_operand" "=x")
22391 (lshiftrt:V2DI (match_operand:V2DI 1 "register_operand" "0")
d9deed68 22392 (match_operand:TI 2 "nonmemory_operand" "xi")))]
fbe5eb6d
BS
22393 "TARGET_SSE2"
22394 "psrlq\t{%2, %0|%0, %2}"
3d34cd91
JH
22395 [(set_attr "type" "sseishft")
22396 (set_attr "mode" "TI")])
fbe5eb6d
BS
22397
22398(define_insn "ashlv8hi3"
22399 [(set (match_operand:V8HI 0 "register_operand" "=x")
22400 (ashift:V8HI (match_operand:V8HI 1 "register_operand" "0")
d9deed68 22401 (match_operand:TI 2 "nonmemory_operand" "xi")))]
fbe5eb6d
BS
22402 "TARGET_SSE2"
22403 "psllw\t{%2, %0|%0, %2}"
3d34cd91
JH
22404 [(set_attr "type" "sseishft")
22405 (set_attr "mode" "TI")])
fbe5eb6d
BS
22406
22407(define_insn "ashlv4si3"
22408 [(set (match_operand:V4SI 0 "register_operand" "=x")
22409 (ashift:V4SI (match_operand:V4SI 1 "register_operand" "0")
d9deed68 22410 (match_operand:TI 2 "nonmemory_operand" "xi")))]
916b60b7
BS
22411 "TARGET_SSE2"
22412 "pslld\t{%2, %0|%0, %2}"
5f90a099
JH
22413 [(set_attr "type" "sseishft")
22414 (set_attr "mode" "TI")])
916b60b7
BS
22415
22416(define_insn "ashlv2di3"
22417 [(set (match_operand:V2DI 0 "register_operand" "=x")
22418 (ashift:V2DI (match_operand:V2DI 1 "register_operand" "0")
d9deed68 22419 (match_operand:TI 2 "nonmemory_operand" "xi")))]
916b60b7
BS
22420 "TARGET_SSE2"
22421 "psllq\t{%2, %0|%0, %2}"
5f90a099
JH
22422 [(set_attr "type" "sseishft")
22423 (set_attr "mode" "TI")])
916b60b7
BS
22424
22425(define_insn "ashrv8hi3_ti"
22426 [(set (match_operand:V8HI 0 "register_operand" "=x")
22427 (ashiftrt:V8HI (match_operand:V8HI 1 "register_operand" "0")
22428 (subreg:TI (match_operand:V2DI 2 "nonmemory_operand" "xi") 0)))]
22429 "TARGET_SSE2"
22430 "psraw\t{%2, %0|%0, %2}"
5f90a099
JH
22431 [(set_attr "type" "sseishft")
22432 (set_attr "mode" "TI")])
916b60b7
BS
22433
22434(define_insn "ashrv4si3_ti"
22435 [(set (match_operand:V4SI 0 "register_operand" "=x")
22436 (ashiftrt:V4SI (match_operand:V4SI 1 "register_operand" "0")
22437 (subreg:TI (match_operand:V2DI 2 "nonmemory_operand" "xi") 0)))]
22438 "TARGET_SSE2"
22439 "psrad\t{%2, %0|%0, %2}"
5f90a099
JH
22440 [(set_attr "type" "sseishft")
22441 (set_attr "mode" "TI")])
916b60b7
BS
22442
22443(define_insn "lshrv8hi3_ti"
22444 [(set (match_operand:V8HI 0 "register_operand" "=x")
22445 (lshiftrt:V8HI (match_operand:V8HI 1 "register_operand" "0")
22446 (subreg:TI (match_operand:V2DI 2 "nonmemory_operand" "xi") 0)))]
22447 "TARGET_SSE2"
22448 "psrlw\t{%2, %0|%0, %2}"
5f90a099
JH
22449 [(set_attr "type" "sseishft")
22450 (set_attr "mode" "TI")])
916b60b7
BS
22451
22452(define_insn "lshrv4si3_ti"
22453 [(set (match_operand:V4SI 0 "register_operand" "=x")
22454 (lshiftrt:V4SI (match_operand:V4SI 1 "register_operand" "0")
22455 (subreg:TI (match_operand:V2DI 2 "nonmemory_operand" "xi") 0)))]
22456 "TARGET_SSE2"
22457 "psrld\t{%2, %0|%0, %2}"
5f90a099
JH
22458 [(set_attr "type" "sseishft")
22459 (set_attr "mode" "TI")])
916b60b7
BS
22460
22461(define_insn "lshrv2di3_ti"
22462 [(set (match_operand:V2DI 0 "register_operand" "=x")
22463 (lshiftrt:V2DI (match_operand:V2DI 1 "register_operand" "0")
22464 (subreg:TI (match_operand:V2DI 2 "nonmemory_operand" "xi") 0)))]
22465 "TARGET_SSE2"
22466 "psrlq\t{%2, %0|%0, %2}"
5f90a099
JH
22467 [(set_attr "type" "sseishft")
22468 (set_attr "mode" "TI")])
916b60b7
BS
22469
22470(define_insn "ashlv8hi3_ti"
22471 [(set (match_operand:V8HI 0 "register_operand" "=x")
22472 (ashift:V8HI (match_operand:V8HI 1 "register_operand" "0")
22473 (subreg:TI (match_operand:V2DI 2 "nonmemory_operand" "xi") 0)))]
22474 "TARGET_SSE2"
22475 "psllw\t{%2, %0|%0, %2}"
5f90a099
JH
22476 [(set_attr "type" "sseishft")
22477 (set_attr "mode" "TI")])
916b60b7
BS
22478
22479(define_insn "ashlv4si3_ti"
22480 [(set (match_operand:V4SI 0 "register_operand" "=x")
22481 (ashift:V4SI (match_operand:V4SI 1 "register_operand" "0")
22482 (subreg:TI (match_operand:V2DI 2 "nonmemory_operand" "xi") 0)))]
fbe5eb6d
BS
22483 "TARGET_SSE2"
22484 "pslld\t{%2, %0|%0, %2}"
3d34cd91
JH
22485 [(set_attr "type" "sseishft")
22486 (set_attr "mode" "TI")])
fbe5eb6d 22487
916b60b7 22488(define_insn "ashlv2di3_ti"
fbe5eb6d
BS
22489 [(set (match_operand:V2DI 0 "register_operand" "=x")
22490 (ashift:V2DI (match_operand:V2DI 1 "register_operand" "0")
916b60b7 22491 (subreg:TI (match_operand:V2DI 2 "nonmemory_operand" "xi") 0)))]
fbe5eb6d
BS
22492 "TARGET_SSE2"
22493 "psllq\t{%2, %0|%0, %2}"
3d34cd91
JH
22494 [(set_attr "type" "sseishft")
22495 (set_attr "mode" "TI")])
fbe5eb6d
BS
22496
22497;; See logical MMX insns for the reason for the unspec. Strictly speaking
22498;; we wouldn't need here it since we never generate TImode arithmetic.
22499
22500;; There has to be some kind of prize for the weirdest new instruction...
22501(define_insn "sse2_ashlti3"
22502 [(set (match_operand:TI 0 "register_operand" "=x")
22503 (unspec:TI
22504 [(ashift:TI (match_operand:TI 1 "register_operand" "0")
22505 (mult:SI (match_operand:SI 2 "immediate_operand" "i")
8ee41eaf 22506 (const_int 8)))] UNSPEC_NOP))]
fbe5eb6d
BS
22507 "TARGET_SSE2"
22508 "pslldq\t{%2, %0|%0, %2}"
3d34cd91
JH
22509 [(set_attr "type" "sseishft")
22510 (set_attr "mode" "TI")])
fbe5eb6d
BS
22511
22512(define_insn "sse2_lshrti3"
22513 [(set (match_operand:TI 0 "register_operand" "=x")
22514 (unspec:TI
22515 [(lshiftrt:TI (match_operand:TI 1 "register_operand" "0")
22516 (mult:SI (match_operand:SI 2 "immediate_operand" "i")
8ee41eaf 22517 (const_int 8)))] UNSPEC_NOP))]
fbe5eb6d 22518 "TARGET_SSE2"
680dd104 22519 "psrldq\t{%2, %0|%0, %2}"
3d34cd91
JH
22520 [(set_attr "type" "sseishft")
22521 (set_attr "mode" "TI")])
fbe5eb6d
BS
22522
22523;; SSE unpack
22524
22525(define_insn "sse2_unpckhpd"
22526 [(set (match_operand:V2DF 0 "register_operand" "=x")
22527 (vec_concat:V2DF
26771da7
JH
22528 (vec_select:DF (match_operand:V2DF 1 "register_operand" "0")
22529 (parallel [(const_int 1)]))
22530 (vec_select:DF (match_operand:V2DF 2 "register_operand" "x")
22531 (parallel [(const_int 0)]))))]
fbe5eb6d
BS
22532 "TARGET_SSE2"
22533 "unpckhpd\t{%2, %0|%0, %2}"
3d34cd91
JH
22534 [(set_attr "type" "ssecvt")
22535 (set_attr "mode" "TI")])
fbe5eb6d
BS
22536
22537(define_insn "sse2_unpcklpd"
22538 [(set (match_operand:V2DF 0 "register_operand" "=x")
22539 (vec_concat:V2DF
26771da7
JH
22540 (vec_select:DF (match_operand:V2DF 1 "register_operand" "0")
22541 (parallel [(const_int 0)]))
22542 (vec_select:DF (match_operand:V2DF 2 "register_operand" "x")
22543 (parallel [(const_int 1)]))))]
fbe5eb6d
BS
22544 "TARGET_SSE2"
22545 "unpcklpd\t{%2, %0|%0, %2}"
3d34cd91
JH
22546 [(set_attr "type" "ssecvt")
22547 (set_attr "mode" "TI")])
fbe5eb6d
BS
22548
22549;; MMX pack/unpack insns.
22550
22551(define_insn "sse2_packsswb"
22552 [(set (match_operand:V16QI 0 "register_operand" "=x")
22553 (vec_concat:V16QI
22554 (ss_truncate:V8QI (match_operand:V8HI 1 "register_operand" "0"))
22555 (ss_truncate:V8QI (match_operand:V8HI 2 "register_operand" "x"))))]
22556 "TARGET_SSE2"
22557 "packsswb\t{%2, %0|%0, %2}"
3d34cd91
JH
22558 [(set_attr "type" "ssecvt")
22559 (set_attr "mode" "TI")])
fbe5eb6d
BS
22560
22561(define_insn "sse2_packssdw"
22562 [(set (match_operand:V8HI 0 "register_operand" "=x")
22563 (vec_concat:V8HI
22564 (ss_truncate:V4HI (match_operand:V4SI 1 "register_operand" "0"))
22565 (ss_truncate:V4HI (match_operand:V4SI 2 "register_operand" "x"))))]
22566 "TARGET_SSE2"
22567 "packssdw\t{%2, %0|%0, %2}"
3d34cd91
JH
22568 [(set_attr "type" "ssecvt")
22569 (set_attr "mode" "TI")])
fbe5eb6d
BS
22570
22571(define_insn "sse2_packuswb"
22572 [(set (match_operand:V16QI 0 "register_operand" "=x")
22573 (vec_concat:V16QI
22574 (us_truncate:V8QI (match_operand:V8HI 1 "register_operand" "0"))
22575 (us_truncate:V8QI (match_operand:V8HI 2 "register_operand" "x"))))]
22576 "TARGET_SSE2"
22577 "packuswb\t{%2, %0|%0, %2}"
3d34cd91
JH
22578 [(set_attr "type" "ssecvt")
22579 (set_attr "mode" "TI")])
fbe5eb6d
BS
22580
22581(define_insn "sse2_punpckhbw"
22582 [(set (match_operand:V16QI 0 "register_operand" "=x")
22583 (vec_merge:V16QI
22584 (vec_select:V16QI (match_operand:V16QI 1 "register_operand" "0")
22585 (parallel [(const_int 8) (const_int 0)
22586 (const_int 9) (const_int 1)
22587 (const_int 10) (const_int 2)
22588 (const_int 11) (const_int 3)
22589 (const_int 12) (const_int 4)
22590 (const_int 13) (const_int 5)
22591 (const_int 14) (const_int 6)
22592 (const_int 15) (const_int 7)]))
22593 (vec_select:V16QI (match_operand:V16QI 2 "register_operand" "x")
22594 (parallel [(const_int 0) (const_int 8)
22595 (const_int 1) (const_int 9)
22596 (const_int 2) (const_int 10)
22597 (const_int 3) (const_int 11)
22598 (const_int 4) (const_int 12)
22599 (const_int 5) (const_int 13)
22600 (const_int 6) (const_int 14)
22601 (const_int 7) (const_int 15)]))
22602 (const_int 21845)))]
22603 "TARGET_SSE2"
22604 "punpckhbw\t{%2, %0|%0, %2}"
3d34cd91
JH
22605 [(set_attr "type" "ssecvt")
22606 (set_attr "mode" "TI")])
fbe5eb6d
BS
22607
22608(define_insn "sse2_punpckhwd"
22609 [(set (match_operand:V8HI 0 "register_operand" "=x")
22610 (vec_merge:V8HI
22611 (vec_select:V8HI (match_operand:V8HI 1 "register_operand" "0")
22612 (parallel [(const_int 4) (const_int 0)
22613 (const_int 5) (const_int 1)
22614 (const_int 6) (const_int 2)
22615 (const_int 7) (const_int 3)]))
22616 (vec_select:V8HI (match_operand:V8HI 2 "register_operand" "x")
22617 (parallel [(const_int 0) (const_int 4)
22618 (const_int 1) (const_int 5)
22619 (const_int 2) (const_int 6)
22620 (const_int 3) (const_int 7)]))
22621 (const_int 85)))]
22622 "TARGET_SSE2"
22623 "punpckhwd\t{%2, %0|%0, %2}"
3d34cd91
JH
22624 [(set_attr "type" "ssecvt")
22625 (set_attr "mode" "TI")])
fbe5eb6d
BS
22626
22627(define_insn "sse2_punpckhdq"
22628 [(set (match_operand:V4SI 0 "register_operand" "=x")
22629 (vec_merge:V4SI
22630 (vec_select:V4SI (match_operand:V4SI 1 "register_operand" "0")
22631 (parallel [(const_int 2) (const_int 0)
22632 (const_int 3) (const_int 1)]))
22633 (vec_select:V4SI (match_operand:V4SI 2 "register_operand" "x")
22634 (parallel [(const_int 0) (const_int 2)
22635 (const_int 1) (const_int 3)]))
22636 (const_int 5)))]
22637 "TARGET_SSE2"
22638 "punpckhdq\t{%2, %0|%0, %2}"
3d34cd91
JH
22639 [(set_attr "type" "ssecvt")
22640 (set_attr "mode" "TI")])
fbe5eb6d
BS
22641
22642(define_insn "sse2_punpcklbw"
22643 [(set (match_operand:V16QI 0 "register_operand" "=x")
22644 (vec_merge:V16QI
22645 (vec_select:V16QI (match_operand:V16QI 1 "register_operand" "0")
22646 (parallel [(const_int 0) (const_int 8)
22647 (const_int 1) (const_int 9)
22648 (const_int 2) (const_int 10)
22649 (const_int 3) (const_int 11)
22650 (const_int 4) (const_int 12)
22651 (const_int 5) (const_int 13)
22652 (const_int 6) (const_int 14)
22653 (const_int 7) (const_int 15)]))
22654 (vec_select:V16QI (match_operand:V16QI 2 "register_operand" "x")
22655 (parallel [(const_int 8) (const_int 0)
22656 (const_int 9) (const_int 1)
22657 (const_int 10) (const_int 2)
22658 (const_int 11) (const_int 3)
22659 (const_int 12) (const_int 4)
22660 (const_int 13) (const_int 5)
22661 (const_int 14) (const_int 6)
22662 (const_int 15) (const_int 7)]))
22663 (const_int 21845)))]
22664 "TARGET_SSE2"
22665 "punpcklbw\t{%2, %0|%0, %2}"
3d34cd91
JH
22666 [(set_attr "type" "ssecvt")
22667 (set_attr "mode" "TI")])
fbe5eb6d
BS
22668
22669(define_insn "sse2_punpcklwd"
22670 [(set (match_operand:V8HI 0 "register_operand" "=x")
22671 (vec_merge:V8HI
22672 (vec_select:V8HI (match_operand:V8HI 1 "register_operand" "0")
22673 (parallel [(const_int 0) (const_int 4)
22674 (const_int 1) (const_int 5)
22675 (const_int 2) (const_int 6)
22676 (const_int 3) (const_int 7)]))
22677 (vec_select:V8HI (match_operand:V8HI 2 "register_operand" "x")
22678 (parallel [(const_int 4) (const_int 0)
22679 (const_int 5) (const_int 1)
22680 (const_int 6) (const_int 2)
22681 (const_int 7) (const_int 3)]))
22682 (const_int 85)))]
22683 "TARGET_SSE2"
22684 "punpcklwd\t{%2, %0|%0, %2}"
3d34cd91
JH
22685 [(set_attr "type" "ssecvt")
22686 (set_attr "mode" "TI")])
fbe5eb6d
BS
22687
22688(define_insn "sse2_punpckldq"
22689 [(set (match_operand:V4SI 0 "register_operand" "=x")
22690 (vec_merge:V4SI
22691 (vec_select:V4SI (match_operand:V4SI 1 "register_operand" "0")
22692 (parallel [(const_int 0) (const_int 2)
22693 (const_int 1) (const_int 3)]))
22694 (vec_select:V4SI (match_operand:V4SI 2 "register_operand" "x")
22695 (parallel [(const_int 2) (const_int 0)
22696 (const_int 3) (const_int 1)]))
22697 (const_int 5)))]
22698 "TARGET_SSE2"
22699 "punpckldq\t{%2, %0|%0, %2}"
3d34cd91
JH
22700 [(set_attr "type" "ssecvt")
22701 (set_attr "mode" "TI")])
fbe5eb6d 22702
f02e1358
JH
22703(define_insn "sse2_punpcklqdq"
22704 [(set (match_operand:V2DI 0 "register_operand" "=x")
22705 (vec_merge:V2DI
f02e1358
JH
22706 (vec_select:V2DI (match_operand:V2DI 2 "register_operand" "x")
22707 (parallel [(const_int 1)
22708 (const_int 0)]))
077084dd 22709 (match_operand:V2DI 1 "register_operand" "0")
f02e1358
JH
22710 (const_int 1)))]
22711 "TARGET_SSE2"
22712 "punpcklqdq\t{%2, %0|%0, %2}"
22713 [(set_attr "type" "ssecvt")
22714 (set_attr "mode" "TI")])
077084dd
JH
22715
22716(define_insn "sse2_punpckhqdq"
22717 [(set (match_operand:V2DI 0 "register_operand" "=x")
22718 (vec_merge:V2DI
22719 (match_operand:V2DI 1 "register_operand" "0")
22720 (vec_select:V2DI (match_operand:V2DI 2 "register_operand" "x")
22721 (parallel [(const_int 1)
22722 (const_int 0)]))
22723 (const_int 1)))]
22724 "TARGET_SSE2"
22725 "punpckhqdq\t{%2, %0|%0, %2}"
22726 [(set_attr "type" "ssecvt")
22727 (set_attr "mode" "TI")])
f02e1358 22728
fbe5eb6d
BS
22729;; SSE2 moves
22730
22731(define_insn "sse2_movapd"
22732 [(set (match_operand:V2DF 0 "nonimmediate_operand" "=x,m")
7f0e57bd 22733 (unspec:V2DF [(match_operand:V2DF 1 "nonimmediate_operand" "xm,x")]
8ee41eaf 22734 UNSPEC_MOVA))]
7f0e57bd
JH
22735 "TARGET_SSE2
22736 && (GET_CODE (operands[0]) != MEM || GET_CODE (operands[1]) != MEM)"
22737 "movapd\t{%1, %0|%0, %1}"
3d34cd91
JH
22738 [(set_attr "type" "ssemov")
22739 (set_attr "mode" "V2DF")])
fbe5eb6d
BS
22740
22741(define_insn "sse2_movupd"
22742 [(set (match_operand:V2DF 0 "nonimmediate_operand" "=x,m")
7f0e57bd 22743 (unspec:V2DF [(match_operand:V2DF 1 "nonimmediate_operand" "xm,x")]
8ee41eaf 22744 UNSPEC_MOVU))]
7f0e57bd
JH
22745 "TARGET_SSE2
22746 && (GET_CODE (operands[0]) != MEM || GET_CODE (operands[1]) != MEM)"
22747 "movupd\t{%1, %0|%0, %1}"
3d34cd91
JH
22748 [(set_attr "type" "ssecvt")
22749 (set_attr "mode" "V2DF")])
fbe5eb6d
BS
22750
22751(define_insn "sse2_movdqa"
f02e1358 22752 [(set (match_operand:V16QI 0 "nonimmediate_operand" "=x,m")
7f0e57bd 22753 (unspec:V16QI [(match_operand:V16QI 1 "nonimmediate_operand" "xm,x")]
f02e1358 22754 UNSPEC_MOVA))]
7f0e57bd
JH
22755 "TARGET_SSE2
22756 && (GET_CODE (operands[0]) != MEM || GET_CODE (operands[1]) != MEM)"
22757 "movdqa\t{%1, %0|%0, %1}"
3d34cd91
JH
22758 [(set_attr "type" "ssemov")
22759 (set_attr "mode" "TI")])
fbe5eb6d
BS
22760
22761(define_insn "sse2_movdqu"
f02e1358 22762 [(set (match_operand:V16QI 0 "nonimmediate_operand" "=x,m")
7f0e57bd 22763 (unspec:V16QI [(match_operand:V16QI 1 "nonimmediate_operand" "xm,x")]
f02e1358 22764 UNSPEC_MOVU))]
7f0e57bd
JH
22765 "TARGET_SSE2
22766 && (GET_CODE (operands[0]) != MEM || GET_CODE (operands[1]) != MEM)"
22767 "movdqu\t{%1, %0|%0, %1}"
3d34cd91
JH
22768 [(set_attr "type" "ssecvt")
22769 (set_attr "mode" "TI")])
fbe5eb6d
BS
22770
22771(define_insn "sse2_movdq2q"
f02e1358
JH
22772 [(set (match_operand:DI 0 "nonimmediate_operand" "=m,y")
22773 (vec_select:DI (match_operand:V2DI 1 "register_operand" "x,x")
fbe5eb6d
BS
22774 (parallel [(const_int 0)])))]
22775 "TARGET_SSE2"
f02e1358
JH
22776 "@
22777 movq\t{%1, %0|%0, %1}
22778 movdq2q\t{%1, %0|%0, %1}"
3d34cd91
JH
22779 [(set_attr "type" "ssecvt")
22780 (set_attr "mode" "TI")])
fbe5eb6d
BS
22781
22782(define_insn "sse2_movq2dq"
f02e1358
JH
22783 [(set (match_operand:V2DI 0 "register_operand" "=x,?x")
22784 (vec_concat:V2DI (match_operand:DI 1 "nonimmediate_operand" "m,y")
22785 (const_int 0)))]
fbe5eb6d 22786 "TARGET_SSE2"
f02e1358
JH
22787 "@
22788 movq\t{%1, %0|%0, %1}
22789 movq2dq\t{%1, %0|%0, %1}"
22790 [(set_attr "type" "ssecvt,ssemov")
22791 (set_attr "mode" "TI")])
22792
22793(define_insn "sse2_movq"
22794 [(set (match_operand:V2DI 0 "register_operand" "=x")
22795 (vec_concat:V2DI (vec_select:DI
22796 (match_operand:V2DI 1 "nonimmediate_operand" "xm")
22797 (parallel [(const_int 0)]))
22798 (const_int 0)))]
22799 "TARGET_SSE2"
22800 "movq\t{%1, %0|%0, %1}"
22801 [(set_attr "type" "ssemov")
22802 (set_attr "mode" "TI")])
22803
22804(define_insn "sse2_loadd"
22805 [(set (match_operand:V4SI 0 "register_operand" "=x")
22806 (vec_merge:V4SI
d9deed68 22807 (vec_duplicate:V4SI (match_operand:SI 1 "nonimmediate_operand" "mr"))
f02e1358
JH
22808 (const_vector:V4SI [(const_int 0)
22809 (const_int 0)
22810 (const_int 0)
22811 (const_int 0)])
22812 (const_int 1)))]
22813 "TARGET_SSE2"
22814 "movd\t{%1, %0|%0, %1}"
22815 [(set_attr "type" "ssemov")
22816 (set_attr "mode" "TI")])
22817
22818(define_insn "sse2_stored"
22819 [(set (match_operand:SI 0 "nonimmediate_operand" "=mr")
22820 (vec_select:SI
22821 (match_operand:V4SI 1 "register_operand" "x")
22822 (parallel [(const_int 0)])))]
22823 "TARGET_SSE2"
22824 "movd\t{%1, %0|%0, %1}"
22825 [(set_attr "type" "ssemov")
3d34cd91 22826 (set_attr "mode" "TI")])
fbe5eb6d
BS
22827
22828(define_insn "sse2_movhpd"
22829 [(set (match_operand:V2DF 0 "nonimmediate_operand" "=x,m")
22830 (vec_merge:V2DF
22831 (match_operand:V2DF 1 "nonimmediate_operand" "0,0")
22832 (match_operand:V2DF 2 "nonimmediate_operand" "m,x")
22833 (const_int 2)))]
22834 "TARGET_SSE2 && (GET_CODE (operands[1]) == MEM || GET_CODE (operands[2]) == MEM)"
22835 "movhpd\t{%2, %0|%0, %2}"
3d34cd91
JH
22836 [(set_attr "type" "ssecvt")
22837 (set_attr "mode" "V2DF")])
fbe5eb6d
BS
22838
22839(define_insn "sse2_movlpd"
22840 [(set (match_operand:V2DF 0 "nonimmediate_operand" "=x,m")
22841 (vec_merge:V2DF
22842 (match_operand:V2DF 1 "nonimmediate_operand" "0,0")
22843 (match_operand:V2DF 2 "nonimmediate_operand" "m,x")
22844 (const_int 1)))]
22845 "TARGET_SSE2 && (GET_CODE (operands[1]) == MEM || GET_CODE (operands[2]) == MEM)"
22846 "movlpd\t{%2, %0|%0, %2}"
3d34cd91
JH
22847 [(set_attr "type" "ssecvt")
22848 (set_attr "mode" "V2DF")])
fbe5eb6d 22849
4977bab6
ZW
22850(define_expand "sse2_loadsd"
22851 [(match_operand:V2DF 0 "register_operand" "")
22852 (match_operand:DF 1 "memory_operand" "")]
22853 "TARGET_SSE2"
22854{
22855 emit_insn (gen_sse2_loadsd_1 (operands[0], operands[1],
22856 CONST0_RTX (V2DFmode)));
22857 DONE;
22858})
22859
22860(define_insn "sse2_loadsd_1"
fbe5eb6d
BS
22861 [(set (match_operand:V2DF 0 "register_operand" "=x")
22862 (vec_merge:V2DF
4977bab6
ZW
22863 (vec_duplicate:V2DF (match_operand:DF 1 "memory_operand" "m"))
22864 (match_operand:V2DF 2 "const0_operand" "X")
fbe5eb6d
BS
22865 (const_int 1)))]
22866 "TARGET_SSE2"
22867 "movsd\t{%1, %0|%0, %1}"
3d34cd91
JH
22868 [(set_attr "type" "ssecvt")
22869 (set_attr "mode" "DF")])
fbe5eb6d
BS
22870
22871(define_insn "sse2_movsd"
22872 [(set (match_operand:V2DF 0 "register_operand" "=x")
22873 (vec_merge:V2DF
22874 (match_operand:V2DF 1 "register_operand" "0")
22875 (match_operand:V2DF 2 "register_operand" "x")
22876 (const_int 1)))]
22877 "TARGET_SSE2"
22878 "movsd\t{%2, %0|%0, %2}"
3d34cd91
JH
22879 [(set_attr "type" "ssecvt")
22880 (set_attr "mode" "DF")])
fbe5eb6d
BS
22881
22882(define_insn "sse2_storesd"
22883 [(set (match_operand:DF 0 "memory_operand" "=m")
22884 (vec_select:DF
22885 (match_operand:V2DF 1 "register_operand" "x")
22886 (parallel [(const_int 0)])))]
22887 "TARGET_SSE2"
22888 "movsd\t{%1, %0|%0, %1}"
3d34cd91
JH
22889 [(set_attr "type" "ssecvt")
22890 (set_attr "mode" "DF")])
fbe5eb6d
BS
22891
22892(define_insn "sse2_shufpd"
22893 [(set (match_operand:V2DF 0 "register_operand" "=x")
22894 (unspec:V2DF [(match_operand:V2DF 1 "register_operand" "0")
22895 (match_operand:V2DF 2 "nonimmediate_operand" "xm")
8ee41eaf
RH
22896 (match_operand:SI 3 "immediate_operand" "i")]
22897 UNSPEC_SHUFFLE))]
fbe5eb6d
BS
22898 "TARGET_SSE2"
22899 ;; @@@ check operand order for intel/nonintel syntax
22900 "shufpd\t{%3, %2, %0|%0, %2, %3}"
3d34cd91
JH
22901 [(set_attr "type" "ssecvt")
22902 (set_attr "mode" "V2DF")])
fbe5eb6d
BS
22903
22904(define_insn "sse2_clflush"
1194ca05 22905 [(unspec_volatile [(match_operand 0 "address_operand" "p")]
8ee41eaf 22906 UNSPECV_CLFLUSH)]
fbe5eb6d
BS
22907 "TARGET_SSE2"
22908 "clflush %0"
3d34cd91
JH
22909 [(set_attr "type" "sse")
22910 (set_attr "memory" "unknown")])
fbe5eb6d
BS
22911
22912(define_expand "sse2_mfence"
22913 [(set (match_dup 0)
8ee41eaf 22914 (unspec:BLK [(match_dup 0)] UNSPEC_MFENCE))]
fbe5eb6d
BS
22915 "TARGET_SSE2"
22916{
22917 operands[0] = gen_rtx_MEM (BLKmode, gen_rtx_SCRATCH (Pmode));
22918 MEM_VOLATILE_P (operands[0]) = 1;
22919})
22920
22921(define_insn "*mfence_insn"
22922 [(set (match_operand:BLK 0 "" "")
8ee41eaf 22923 (unspec:BLK [(match_dup 0)] UNSPEC_MFENCE))]
fbe5eb6d
BS
22924 "TARGET_SSE2"
22925 "mfence"
22926 [(set_attr "type" "sse")
22927 (set_attr "memory" "unknown")])
22928
22929(define_expand "sse2_lfence"
22930 [(set (match_dup 0)
8ee41eaf 22931 (unspec:BLK [(match_dup 0)] UNSPEC_LFENCE))]
fbe5eb6d
BS
22932 "TARGET_SSE2"
22933{
22934 operands[0] = gen_rtx_MEM (BLKmode, gen_rtx_SCRATCH (Pmode));
22935 MEM_VOLATILE_P (operands[0]) = 1;
22936})
22937
22938(define_insn "*lfence_insn"
22939 [(set (match_operand:BLK 0 "" "")
8ee41eaf 22940 (unspec:BLK [(match_dup 0)] UNSPEC_LFENCE))]
fbe5eb6d
BS
22941 "TARGET_SSE2"
22942 "lfence"
22943 [(set_attr "type" "sse")
22944 (set_attr "memory" "unknown")])
This page took 5.281523 seconds and 5 git commands to generate.