]>
Commit | Line | Data |
---|---|---|
d2836273 | 1 | ;; GCC machine description for IA-32 and x86-64. |
e03f5d43 | 2 | ;; Copyright (C) 1988, 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002 |
4592bdcb | 3 | ;; Free Software Foundation, Inc. |
886c62d1 | 4 | ;; Mostly by William Schelter. |
d2836273 | 5 | ;; x86_64 support added by Jan Hubicka |
e075ae69 | 6 | ;; |
886c62d1 | 7 | ;; This file is part of GNU CC. |
e075ae69 | 8 | ;; |
886c62d1 JVA |
9 | ;; GNU CC is free software; you can redistribute it and/or modify |
10 | ;; it under the terms of the GNU General Public License as published by | |
11 | ;; the Free Software Foundation; either version 2, or (at your option) | |
12 | ;; any later version. | |
e075ae69 | 13 | ;; |
886c62d1 JVA |
14 | ;; GNU CC is distributed in the hope that it will be useful, |
15 | ;; but WITHOUT ANY WARRANTY; without even the implied warranty of | |
16 | ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
17 | ;; GNU General Public License for more details. | |
e075ae69 | 18 | ;; |
886c62d1 JVA |
19 | ;; You should have received a copy of the GNU General Public License |
20 | ;; along with GNU CC; see the file COPYING. If not, write to | |
3f63df56 | 21 | ;; the Free Software Foundation, 59 Temple Place - Suite 330, |
892a2d68 | 22 | ;; Boston, MA 02111-1307, USA. */ |
e075ae69 | 23 | ;; |
4af3895e JVA |
24 | ;; The original PO technology requires these to be ordered by speed, |
25 | ;; so that assigner will pick the fastest. | |
e075ae69 | 26 | ;; |
4af3895e | 27 | ;; See file "rtl.def" for documentation on define_insn, match_*, et. al. |
e075ae69 | 28 | ;; |
4af3895e JVA |
29 | ;; Macro #define NOTICE_UPDATE_CC in file i386.h handles condition code |
30 | ;; updates for most instructions. | |
e075ae69 | 31 | ;; |
4af3895e JVA |
32 | ;; Macro REG_CLASS_FROM_LETTER in file i386.h defines the register |
33 | ;; constraint letters. | |
e075ae69 RH |
34 | ;; |
35 | ;; The special asm out single letter directives following a '%' are: | |
4af3895e JVA |
36 | ;; 'z' mov%z1 would be movl, movw, or movb depending on the mode of |
37 | ;; operands[1]. | |
38 | ;; 'L' Print the opcode suffix for a 32-bit integer opcode. | |
39 | ;; 'W' Print the opcode suffix for a 16-bit integer opcode. | |
40 | ;; 'B' Print the opcode suffix for an 8-bit integer opcode. | |
4af3895e | 41 | ;; 'Q' Print the opcode suffix for a 64-bit float opcode. |
56710e42 | 42 | ;; 'S' Print the opcode suffix for a 32-bit float opcode. |
b08de47e MM |
43 | ;; 'T' Print the opcode suffix for an 80-bit extended real XFmode float opcode. |
44 | ;; 'J' Print the appropriate jump operand. | |
e075ae69 | 45 | ;; |
4af3895e JVA |
46 | ;; 'b' Print the QImode name of the register for the indicated operand. |
47 | ;; %b0 would print %al if operands[0] is reg 0. | |
48 | ;; 'w' Likewise, print the HImode name of the register. | |
49 | ;; 'k' Likewise, print the SImode name of the register. | |
50 | ;; 'h' Print the QImode name for a "high" register, either ah, bh, ch or dh. | |
51 | ;; 'y' Print "st(0)" instead of "st" as a register. | |
e075ae69 | 52 | ;; |
4af3895e JVA |
53 | ;; UNSPEC usage: |
54 | ;; 0 This is a `scas' operation. The mode of the UNSPEC is always SImode. | |
55 | ;; operand 0 is the memory address to scan. | |
56 | ;; operand 1 is a register containing the value to scan for. The mode | |
57 | ;; of the scas opcode will be the same as the mode of this operand. | |
58 | ;; operand 2 is the known alignment of operand 0. | |
a199fdd6 JVA |
59 | ;; 1 This is a `sin' operation. The mode of the UNSPEC is MODE_FLOAT. |
60 | ;; operand 0 is the argument for `sin'. | |
61 | ;; 2 This is a `cos' operation. The mode of the UNSPEC is MODE_FLOAT. | |
62 | ;; operand 0 is the argument for `cos'. | |
578b58f5 RK |
63 | ;; 3 This is part of a `stack probe' operation. The mode of the UNSPEC is |
64 | ;; always SImode. operand 0 is the size of the stack allocation. | |
47d36400 BS |
65 | ;; 4 This is the source of a fake SET of the frame pointer which is used to |
66 | ;; prevent insns referencing it being scheduled across the initial | |
67 | ;; decrement of the stack pointer. | |
ce193852 | 68 | ;; 5 This is a `bsf' operation. |
91bb873f RH |
69 | ;; 6 This is the @GOT offset of a PIC address. |
70 | ;; 7 This is the @GOTOFF offset of a PIC address. | |
71 | ;; 8 This is a reference to a symbol's @PLT address. | |
e075ae69 RH |
72 | ;; 9 This is an `fnstsw' operation. |
73 | ;; 10 This is a `sahf' operation. | |
74 | ;; 11 This is a `fstcw' operation | |
7e08e190 | 75 | ;; 12 This is behaviour of add when setting carry flag. |
1020a5ab | 76 | ;; 13 This is a `eh_return' placeholder. |
915119a5 BS |
77 | |
78 | ;; For SSE/MMX support: | |
79 | ;; 30 This is `fix', guaranteed to be truncating. | |
80 | ;; 31 This is a `emms' operation. | |
81 | ;; 32 This is a `maskmov' operation. | |
82 | ;; 33 This is a `movmsk' operation. | |
83 | ;; 34 This is a `non-temporal' move. | |
915119a5 BS |
84 | ;; 36 This is used to distinguish COMISS from UCOMISS. |
85 | ;; 37 This is a `ldmxcsr' operation. | |
86 | ;; 38 This is a forced `movaps' instruction (rather than whatever movti does) | |
87 | ;; 39 This is a forced `movups' instruction (rather than whatever movti does) | |
88 | ;; 40 This is a `stmxcsr' operation. | |
89 | ;; 41 This is a `shuffle' operation. | |
90 | ;; 42 This is a `rcp' operation. | |
91 | ;; 43 This is a `rsqsrt' operation. | |
92 | ;; 44 This is a `sfence' operation. | |
93 | ;; 45 This is a noop to prevent excessive combiner cleverness. | |
47f339cf | 94 | ;; 46 This is a `femms' operation. |
47f339cf BS |
95 | ;; 49 This is a 'pavgusb' operation. |
96 | ;; 50 This is a `pfrcp' operation. | |
97 | ;; 51 This is a `pfrcpit1' operation. | |
98 | ;; 52 This is a `pfrcpit2' operation. | |
99 | ;; 53 This is a `pfrsqrt' operation. | |
100 | ;; 54 This is a `pfrsqrit1' operation. | |
915119a5 | 101 | |
6343a50e ZW |
102 | ;; Insns whose names begin with "x86_" are emitted by gen_FOO calls |
103 | ;; from i386.c. | |
104 | ||
1b0c37d7 ZW |
105 | ;; In C guard expressions, put expressions which may be compile-time |
106 | ;; constants first. This allows for better optimization. For | |
107 | ;; example, write "TARGET_64BIT && reload_completed", not | |
108 | ;; "reload_completed && TARGET_64BIT". | |
109 | ||
2ae0f82c | 110 | \f |
e075ae69 RH |
111 | ;; Processor type. This attribute must exactly match the processor_type |
112 | ;; enumeration in i386.h. | |
b4e89e2d | 113 | (define_attr "cpu" "i386,i486,pentium,pentiumpro,k6,athlon,pentium4" |
e075ae69 | 114 | (const (symbol_ref "ix86_cpu"))) |
2ae0f82c | 115 | |
e075ae69 RH |
116 | ;; A basic instruction type. Refinements due to arguments to be |
117 | ;; provided in other attributes. | |
a269a03c | 118 | (define_attr "type" |
22fb740d | 119 | "other,multi,alu1,negnot,alu,icmp,test,imov,imovx,lea,incdec,ishift,imul,idiv,ibr,setcc,push,pop,call,callv,icmov,fmov,fop,fop1,fsgn,fmul,fdiv,fpspc,fcmov,fcmp,fxch,str,cld,sse,mmx,fistp" |
e075ae69 RH |
120 | (const_string "other")) |
121 | ||
6ef67412 | 122 | ;; Main data type used by the insn |
2b04e52b | 123 | (define_attr "mode" "unknown,none,QI,HI,SI,DI,unknownfp,SF,DF,XF,TI" |
6ef67412 JH |
124 | (const_string "unknown")) |
125 | ||
126 | ;; Set for i387 operations. | |
127 | (define_attr "i387" "" | |
22fb740d | 128 | (if_then_else (eq_attr "type" "fmov,fop,fop1,fsgn,fmul,fdiv,fpspc,fcmov,fcmp,fxch,fistp") |
6ef67412 JH |
129 | (const_int 1) |
130 | (const_int 0))) | |
131 | ||
132 | ;; The (bounding maximum) length of an instruction immediate. | |
133 | (define_attr "length_immediate" "" | |
bd793c65 | 134 | (cond [(eq_attr "type" "incdec,setcc,icmov,ibr,str,cld,lea,other,multi,idiv,sse,mmx") |
6ef67412 JH |
135 | (const_int 0) |
136 | (eq_attr "i387" "1") | |
137 | (const_int 0) | |
138 | (eq_attr "type" "alu1,negnot,alu,icmp,imovx,ishift,imul,push,pop") | |
139 | (symbol_ref "ix86_attr_length_immediate_default(insn,1)") | |
140 | (eq_attr "type" "imov,test") | |
141 | (symbol_ref "ix86_attr_length_immediate_default(insn,0)") | |
142 | (eq_attr "type" "call") | |
143 | (if_then_else (match_operand 0 "constant_call_address_operand" "") | |
144 | (const_int 4) | |
145 | (const_int 0)) | |
146 | (eq_attr "type" "callv") | |
147 | (if_then_else (match_operand 1 "constant_call_address_operand" "") | |
148 | (const_int 4) | |
149 | (const_int 0)) | |
150 | (eq_attr "type" "ibr") | |
151 | (if_then_else (and (ge (minus (match_dup 0) (pc)) | |
152 | (const_int -128)) | |
153 | (lt (minus (match_dup 0) (pc)) | |
154 | (const_int 124))) | |
155 | (const_int 1) | |
156 | (const_int 4)) | |
157 | ] | |
158 | (symbol_ref "/* Update immediate_length and other attributes! */ abort(),1"))) | |
e075ae69 | 159 | |
6ef67412 JH |
160 | ;; The (bounding maximum) length of an instruction address. |
161 | (define_attr "length_address" "" | |
162 | (cond [(eq_attr "type" "str,cld,other,multi,fxch") | |
163 | (const_int 0) | |
164 | (and (eq_attr "type" "call") | |
165 | (match_operand 1 "constant_call_address_operand" "")) | |
166 | (const_int 0) | |
167 | (and (eq_attr "type" "callv") | |
168 | (match_operand 1 "constant_call_address_operand" "")) | |
169 | (const_int 0) | |
170 | ] | |
171 | (symbol_ref "ix86_attr_length_address_default (insn)"))) | |
172 | ||
173 | ;; Set when length prefix is used. | |
174 | (define_attr "prefix_data16" "" | |
175 | (if_then_else (eq_attr "mode" "HI") | |
176 | (const_int 1) | |
177 | (const_int 0))) | |
178 | ||
179 | ;; Set when string REP prefix is used. | |
180 | (define_attr "prefix_rep" "" (const_int 0)) | |
181 | ||
182 | ;; Set when 0f opcode prefix is used. | |
183 | (define_attr "prefix_0f" "" | |
bd793c65 | 184 | (if_then_else (eq_attr "type" "imovx,setcc,icmov,sse,mmx") |
6ef67412 JH |
185 | (const_int 1) |
186 | (const_int 0))) | |
187 | ||
188 | ;; Set when modrm byte is used. | |
189 | (define_attr "modrm" "" | |
190 | (cond [(eq_attr "type" "str,cld") | |
191 | (const_int 0) | |
192 | (eq_attr "i387" "1") | |
193 | (const_int 0) | |
e075ae69 RH |
194 | (and (eq_attr "type" "incdec") |
195 | (ior (match_operand:SI 1 "register_operand" "") | |
196 | (match_operand:HI 1 "register_operand" ""))) | |
6ef67412 | 197 | (const_int 0) |
e075ae69 RH |
198 | (and (eq_attr "type" "push") |
199 | (not (match_operand 1 "memory_operand" ""))) | |
6ef67412 | 200 | (const_int 0) |
e075ae69 RH |
201 | (and (eq_attr "type" "pop") |
202 | (not (match_operand 0 "memory_operand" ""))) | |
6ef67412 | 203 | (const_int 0) |
e075ae69 RH |
204 | (and (eq_attr "type" "imov") |
205 | (and (match_operand 0 "register_operand" "") | |
206 | (match_operand 1 "immediate_operand" ""))) | |
6ef67412 | 207 | (const_int 0) |
e075ae69 | 208 | ] |
6ef67412 JH |
209 | (const_int 1))) |
210 | ||
211 | ;; The (bounding maximum) length of an instruction in bytes. | |
22fb740d JH |
212 | ;; ??? fistp is in fact fldcw/fistp/fldcw sequence. Later we may want |
213 | ;; to split it and compute proper length as for other insns. | |
6ef67412 | 214 | (define_attr "length" "" |
22fb740d | 215 | (cond [(eq_attr "type" "other,multi,fistp") |
6ef67412 JH |
216 | (const_int 16) |
217 | ] | |
218 | (plus (plus (attr "modrm") | |
219 | (plus (attr "prefix_0f") | |
220 | (plus (attr "i387") | |
221 | (const_int 1)))) | |
222 | (plus (attr "prefix_rep") | |
223 | (plus (attr "prefix_data16") | |
224 | (plus (attr "length_immediate") | |
225 | (attr "length_address"))))))) | |
e075ae69 RH |
226 | |
227 | ;; The `memory' attribute is `none' if no memory is referenced, `load' or | |
228 | ;; `store' if there is a simple memory reference therein, or `unknown' | |
229 | ;; if the instruction is complex. | |
230 | ||
231 | (define_attr "memory" "none,load,store,both,unknown" | |
7c7ef435 | 232 | (cond [(eq_attr "type" "other,multi,str") |
e075ae69 | 233 | (const_string "unknown") |
7c7ef435 | 234 | (eq_attr "type" "lea,fcmov,fpspc,cld") |
e075ae69 | 235 | (const_string "none") |
22fb740d JH |
236 | (eq_attr "type" "fistp") |
237 | (const_string "both") | |
e075ae69 RH |
238 | (eq_attr "type" "push") |
239 | (if_then_else (match_operand 1 "memory_operand" "") | |
240 | (const_string "both") | |
241 | (const_string "store")) | |
242 | (eq_attr "type" "pop,setcc") | |
243 | (if_then_else (match_operand 0 "memory_operand" "") | |
244 | (const_string "both") | |
245 | (const_string "load")) | |
6ef67412 | 246 | (eq_attr "type" "icmp,test") |
e075ae69 RH |
247 | (if_then_else (ior (match_operand 0 "memory_operand" "") |
248 | (match_operand 1 "memory_operand" "")) | |
249 | (const_string "load") | |
250 | (const_string "none")) | |
251 | (eq_attr "type" "ibr") | |
252 | (if_then_else (match_operand 0 "memory_operand" "") | |
253 | (const_string "load") | |
254 | (const_string "none")) | |
255 | (eq_attr "type" "call") | |
256 | (if_then_else (match_operand 0 "constant_call_address_operand" "") | |
257 | (const_string "none") | |
258 | (const_string "load")) | |
259 | (eq_attr "type" "callv") | |
260 | (if_then_else (match_operand 1 "constant_call_address_operand" "") | |
261 | (const_string "none") | |
262 | (const_string "load")) | |
263 | (and (eq_attr "type" "alu1,negnot") | |
a269a03c | 264 | (match_operand 1 "memory_operand" "")) |
e075ae69 RH |
265 | (const_string "both") |
266 | (and (match_operand 0 "memory_operand" "") | |
267 | (match_operand 1 "memory_operand" "")) | |
268 | (const_string "both") | |
269 | (match_operand 0 "memory_operand" "") | |
270 | (const_string "store") | |
271 | (match_operand 1 "memory_operand" "") | |
272 | (const_string "load") | |
915119a5 | 273 | (and (eq_attr "type" "!icmp,test,alu1,negnot,fop1,fsgn,imov,imovx,fmov,fcmp,sse,mmx") |
e075ae69 RH |
274 | (match_operand 2 "memory_operand" "")) |
275 | (const_string "load") | |
276 | (and (eq_attr "type" "icmov") | |
277 | (match_operand 3 "memory_operand" "")) | |
278 | (const_string "load") | |
279 | ] | |
a269a03c JC |
280 | (const_string "none"))) |
281 | ||
e075ae69 RH |
282 | ;; Indicates if an instruction has both an immediate and a displacement. |
283 | ||
284 | (define_attr "imm_disp" "false,true,unknown" | |
285 | (cond [(eq_attr "type" "other,multi") | |
286 | (const_string "unknown") | |
6ef67412 | 287 | (and (eq_attr "type" "icmp,test,imov") |
e075ae69 RH |
288 | (and (match_operand 0 "memory_displacement_operand" "") |
289 | (match_operand 1 "immediate_operand" ""))) | |
290 | (const_string "true") | |
291 | (and (eq_attr "type" "alu,ishift,imul,idiv") | |
292 | (and (match_operand 0 "memory_displacement_operand" "") | |
293 | (match_operand 2 "immediate_operand" ""))) | |
294 | (const_string "true") | |
295 | ] | |
296 | (const_string "false"))) | |
297 | ||
298 | ;; Indicates if an FP operation has an integer source. | |
299 | ||
300 | (define_attr "fp_int_src" "false,true" | |
301 | (const_string "false")) | |
302 | ||
303 | ;; Describe a user's asm statement. | |
304 | (define_asm_attributes | |
305 | [(set_attr "length" "128") | |
306 | (set_attr "type" "multi")]) | |
307 | \f | |
308 | ;; Pentium Scheduling | |
309 | ;; | |
310 | ;; The Pentium is an in-order core with two integer pipelines. | |
311 | ||
6ef67412 JH |
312 | ;; True for insns that behave like prefixed insns on the Pentium. |
313 | (define_attr "pent_prefix" "false,true" | |
314 | (if_then_else (ior (eq_attr "prefix_0f" "1") | |
315 | (ior (eq_attr "prefix_data16" "1") | |
316 | (eq_attr "prefix_rep" "1"))) | |
317 | (const_string "true") | |
318 | (const_string "false"))) | |
319 | ||
e075ae69 RH |
320 | ;; Categorize how an instruction slots. |
321 | ||
322 | ;; The non-MMX Pentium slots an instruction with prefixes on U pipe only, | |
323 | ;; while MMX Pentium can slot it on either U or V. Model non-MMX Pentium | |
324 | ;; rules, because it results in noticeably better code on non-MMX Pentium | |
325 | ;; and doesn't hurt much on MMX. (Prefixed instructions are not very | |
326 | ;; common, so the scheduler usualy has a non-prefixed insn to pair). | |
327 | ||
328 | (define_attr "pent_pair" "uv,pu,pv,np" | |
329 | (cond [(eq_attr "imm_disp" "true") | |
330 | (const_string "np") | |
6ef67412 JH |
331 | (ior (eq_attr "type" "alu1,alu,imov,icmp,test,lea,incdec") |
332 | (and (eq_attr "type" "pop,push") | |
333 | (eq_attr "memory" "!both"))) | |
334 | (if_then_else (eq_attr "pent_prefix" "true") | |
e075ae69 RH |
335 | (const_string "pu") |
336 | (const_string "uv")) | |
337 | (eq_attr "type" "ibr") | |
338 | (const_string "pv") | |
339 | (and (eq_attr "type" "ishift") | |
340 | (match_operand 2 "const_int_operand" "")) | |
341 | (const_string "pu") | |
e075ae69 RH |
342 | (and (eq_attr "type" "call") |
343 | (match_operand 0 "constant_call_address_operand" "")) | |
344 | (const_string "pv") | |
345 | (and (eq_attr "type" "callv") | |
346 | (match_operand 1 "constant_call_address_operand" "")) | |
347 | (const_string "pv") | |
348 | ] | |
349 | (const_string "np"))) | |
350 | ||
351 | ;; Rough readiness numbers. Fine tuning happens in i386.c. | |
352 | ;; | |
353 | ;; u describes pipe U | |
354 | ;; v describes pipe V | |
355 | ;; uv describes either pipe U or V for those that can issue to either | |
356 | ;; np describes not paring | |
357 | ;; fpu describes fpu | |
358 | ;; fpm describes fp insns of different types are not pipelined. | |
359 | ;; | |
360 | ;; ??? fxch isn't handled; not an issue until sched3 after reg-stack is real. | |
2ae0f82c | 361 | |
e075ae69 RH |
362 | (define_function_unit "pent_np" 1 0 |
363 | (and (eq_attr "cpu" "pentium") | |
364 | (eq_attr "type" "imul")) | |
365 | 11 11) | |
36cf4bcf | 366 | |
e075ae69 RH |
367 | (define_function_unit "pent_mul" 1 1 |
368 | (and (eq_attr "cpu" "pentium") | |
369 | (eq_attr "type" "imul")) | |
370 | 11 11) | |
36cf4bcf | 371 | |
7c7ef435 JH |
372 | ;; Rep movs takes minimally 12 cycles. |
373 | (define_function_unit "pent_np" 1 0 | |
374 | (and (eq_attr "cpu" "pentium") | |
375 | (eq_attr "type" "str")) | |
376 | 12 12) | |
377 | ||
e075ae69 RH |
378 | ; ??? IDIV for SI takes 46 cycles, for HI 30, for QI 22 |
379 | (define_function_unit "pent_np" 1 0 | |
380 | (and (eq_attr "cpu" "pentium") | |
381 | (eq_attr "type" "idiv")) | |
382 | 46 46) | |
383 | ||
384 | ; Fp reg-reg moves takes 1 cycle. Loads takes 1 cycle for SF/DF mode, | |
385 | ; 3 cycles for XFmode. Stores takes 2 cycles for SF/DF and 3 for XF. | |
386 | ; fldz and fld1 takes 2 cycles. Only reg-reg moves are pairable. | |
387 | ; The integer <-> fp conversion is not modeled correctly. Fild behaves | |
388 | ; like normal fp operation and fist takes 6 cycles. | |
389 | ||
390 | (define_function_unit "fpu" 1 0 | |
391 | (and (eq_attr "cpu" "pentium") | |
392 | (and (eq_attr "type" "fmov") | |
2b589241 JH |
393 | (and (eq_attr "memory" "load,store") |
394 | (eq_attr "mode" "XF")))) | |
e075ae69 RH |
395 | 3 3) |
396 | ||
397 | (define_function_unit "pent_np" 1 0 | |
398 | (and (eq_attr "cpu" "pentium") | |
399 | (and (eq_attr "type" "fmov") | |
2b589241 JH |
400 | (and (eq_attr "memory" "load,store") |
401 | (eq_attr "mode" "XF")))) | |
e075ae69 RH |
402 | 3 3) |
403 | ||
404 | (define_function_unit "fpu" 1 0 | |
405 | (and (eq_attr "cpu" "pentium") | |
406 | (and (eq_attr "type" "fmov") | |
407 | (ior (match_operand 1 "immediate_operand" "") | |
408 | (eq_attr "memory" "store")))) | |
409 | 2 2) | |
36cf4bcf | 410 | |
e075ae69 RH |
411 | (define_function_unit "pent_np" 1 0 |
412 | (and (eq_attr "cpu" "pentium") | |
413 | (and (eq_attr "type" "fmov") | |
414 | (ior (match_operand 1 "immediate_operand" "") | |
415 | (eq_attr "memory" "store")))) | |
416 | 2 2) | |
2ae0f82c | 417 | |
7c7ef435 JH |
418 | (define_function_unit "pent_np" 1 0 |
419 | (and (eq_attr "cpu" "pentium") | |
420 | (eq_attr "type" "cld")) | |
421 | 2 2) | |
422 | ||
e075ae69 RH |
423 | (define_function_unit "fpu" 1 0 |
424 | (and (eq_attr "cpu" "pentium") | |
425 | (and (eq_attr "type" "fmov") | |
426 | (eq_attr "memory" "none,load"))) | |
427 | 1 1) | |
428 | ||
429 | ; Read/Modify/Write instructions usually take 3 cycles. | |
430 | (define_function_unit "pent_u" 1 0 | |
431 | (and (eq_attr "cpu" "pentium") | |
432 | (and (eq_attr "type" "alu,alu1,ishift") | |
433 | (and (eq_attr "pent_pair" "pu") | |
434 | (eq_attr "memory" "both")))) | |
435 | 3 3) | |
436 | ||
437 | (define_function_unit "pent_uv" 2 0 | |
438 | (and (eq_attr "cpu" "pentium") | |
439 | (and (eq_attr "type" "alu,alu1,ishift") | |
440 | (and (eq_attr "pent_pair" "!np") | |
441 | (eq_attr "memory" "both")))) | |
442 | 3 3) | |
443 | ||
444 | (define_function_unit "pent_np" 1 0 | |
445 | (and (eq_attr "cpu" "pentium") | |
446 | (and (eq_attr "type" "alu,alu1,negnot,ishift") | |
447 | (and (eq_attr "pent_pair" "np") | |
448 | (eq_attr "memory" "both")))) | |
449 | 3 3) | |
450 | ||
451 | ; Read/Modify or Modify/Write instructions usually take 2 cycles. | |
452 | (define_function_unit "pent_u" 1 0 | |
453 | (and (eq_attr "cpu" "pentium") | |
454 | (and (eq_attr "type" "alu,ishift") | |
455 | (and (eq_attr "pent_pair" "pu") | |
456 | (eq_attr "memory" "load,store")))) | |
457 | 2 2) | |
2ae0f82c | 458 | |
e075ae69 RH |
459 | (define_function_unit "pent_uv" 2 0 |
460 | (and (eq_attr "cpu" "pentium") | |
461 | (and (eq_attr "type" "alu,ishift") | |
462 | (and (eq_attr "pent_pair" "!np") | |
463 | (eq_attr "memory" "load,store")))) | |
464 | 2 2) | |
2ae0f82c | 465 | |
e075ae69 RH |
466 | (define_function_unit "pent_np" 1 0 |
467 | (and (eq_attr "cpu" "pentium") | |
468 | (and (eq_attr "type" "alu,ishift") | |
469 | (and (eq_attr "pent_pair" "np") | |
470 | (eq_attr "memory" "load,store")))) | |
471 | 2 2) | |
36cf4bcf | 472 | |
e075ae69 RH |
473 | ; Insns w/o memory operands and move instructions usually take one cycle. |
474 | (define_function_unit "pent_u" 1 0 | |
475 | (and (eq_attr "cpu" "pentium") | |
476 | (eq_attr "pent_pair" "pu")) | |
477 | 1 1) | |
478 | ||
479 | (define_function_unit "pent_v" 1 0 | |
480 | (and (eq_attr "cpu" "pentium") | |
481 | (eq_attr "pent_pair" "pv")) | |
482 | 1 1) | |
483 | ||
484 | (define_function_unit "pent_uv" 2 0 | |
485 | (and (eq_attr "cpu" "pentium") | |
486 | (eq_attr "pent_pair" "!np")) | |
487 | 1 1) | |
488 | ||
489 | (define_function_unit "pent_np" 1 0 | |
490 | (and (eq_attr "cpu" "pentium") | |
491 | (eq_attr "pent_pair" "np")) | |
492 | 1 1) | |
493 | ||
494 | ; Pairable insns only conflict with other non-pairable insns. | |
495 | (define_function_unit "pent_np" 1 0 | |
496 | (and (eq_attr "cpu" "pentium") | |
497 | (and (eq_attr "type" "alu,alu1,ishift") | |
498 | (and (eq_attr "pent_pair" "!np") | |
499 | (eq_attr "memory" "both")))) | |
500 | 3 3 | |
501 | [(eq_attr "pent_pair" "np")]) | |
502 | ||
503 | (define_function_unit "pent_np" 1 0 | |
504 | (and (eq_attr "cpu" "pentium") | |
505 | (and (eq_attr "type" "alu,alu1,ishift") | |
506 | (and (eq_attr "pent_pair" "!np") | |
507 | (eq_attr "memory" "load,store")))) | |
508 | 2 2 | |
509 | [(eq_attr "pent_pair" "np")]) | |
510 | ||
511 | (define_function_unit "pent_np" 1 0 | |
512 | (and (eq_attr "cpu" "pentium") | |
513 | (eq_attr "pent_pair" "!np")) | |
514 | 1 1 | |
515 | [(eq_attr "pent_pair" "np")]) | |
516 | ||
517 | ; Floating point instructions usually blocks cycle longer when combined with | |
518 | ; integer instructions, because of the inpaired fxch instruction. | |
519 | (define_function_unit "pent_np" 1 0 | |
520 | (and (eq_attr "cpu" "pentium") | |
22fb740d | 521 | (eq_attr "type" "fmov,fop,fop1,fsgn,fmul,fpspc,fcmov,fcmp,fistp")) |
e075ae69 | 522 | 2 2 |
22fb740d | 523 | [(eq_attr "type" "!fmov,fop,fop1,fsgn,fmul,fpspc,fcmov,fcmp,fistp")]) |
e075ae69 RH |
524 | |
525 | (define_function_unit "fpu" 1 0 | |
526 | (and (eq_attr "cpu" "pentium") | |
527 | (eq_attr "type" "fcmp,fxch,fsgn")) | |
528 | 1 1) | |
529 | ||
530 | ; Addition takes 3 cycles; assume other random cruft does as well. | |
531 | ; ??? Trivial fp operations such as fabs or fchs takes only one cycle. | |
532 | (define_function_unit "fpu" 1 0 | |
533 | (and (eq_attr "cpu" "pentium") | |
22fb740d | 534 | (eq_attr "type" "fop,fop1,fistp")) |
e075ae69 RH |
535 | 3 1) |
536 | ||
537 | ; Multiplication takes 3 cycles and is only half pipelined. | |
538 | (define_function_unit "fpu" 1 0 | |
539 | (and (eq_attr "cpu" "pentium") | |
540 | (eq_attr "type" "fmul")) | |
541 | 3 1) | |
542 | ||
543 | (define_function_unit "pent_mul" 1 1 | |
544 | (and (eq_attr "cpu" "pentium") | |
545 | (eq_attr "type" "fmul")) | |
546 | 2 2) | |
36cf4bcf | 547 | |
e075ae69 RH |
548 | ; ??? This is correct only for fdiv and sqrt -- sin/cos take 65-100 cycles. |
549 | ; They can overlap with integer insns. Only the last two cycles can overlap | |
550 | ; with other fp insns. Only fsin/fcos can overlap with multiplies. | |
551 | ; Only last two cycles of fsin/fcos can overlap with other instructions. | |
552 | (define_function_unit "fpu" 1 0 | |
553 | (and (eq_attr "cpu" "pentium") | |
554 | (eq_attr "type" "fdiv")) | |
555 | 39 37) | |
556 | ||
557 | (define_function_unit "pent_mul" 1 1 | |
558 | (and (eq_attr "cpu" "pentium") | |
559 | (eq_attr "type" "fdiv")) | |
560 | 39 39) | |
561 | ||
562 | (define_function_unit "fpu" 1 0 | |
563 | (and (eq_attr "cpu" "pentium") | |
564 | (eq_attr "type" "fpspc")) | |
565 | 70 68) | |
566 | ||
567 | (define_function_unit "pent_mul" 1 1 | |
568 | (and (eq_attr "cpu" "pentium") | |
569 | (eq_attr "type" "fpspc")) | |
570 | 70 70) | |
571 | \f | |
572 | ;; Pentium Pro/PII Scheduling | |
573 | ;; | |
574 | ;; The PPro has an out-of-order core, but the instruction decoders are | |
575 | ;; naturally in-order and asymmetric. We get best performance by scheduling | |
576 | ;; for the decoders, for in doing so we give the oo execution unit the | |
577 | ;; most choices. | |
578 | ||
579 | ;; Categorize how many uops an ia32 instruction evaluates to: | |
580 | ;; one -- an instruction with 1 uop can be decoded by any of the | |
581 | ;; three decoders. | |
582 | ;; few -- an instruction with 1 to 4 uops can be decoded only by | |
583 | ;; decoder 0. | |
584 | ;; many -- a complex instruction may take an unspecified number of | |
585 | ;; cycles to decode in decoder 0. | |
586 | ||
587 | (define_attr "ppro_uops" "one,few,many" | |
7c7ef435 | 588 | (cond [(eq_attr "type" "other,multi,call,callv,fpspc,str") |
e075ae69 | 589 | (const_string "many") |
7c7ef435 | 590 | (eq_attr "type" "icmov,fcmov,str,cld") |
e075ae69 RH |
591 | (const_string "few") |
592 | (eq_attr "type" "imov") | |
593 | (if_then_else (eq_attr "memory" "store,both") | |
594 | (const_string "few") | |
595 | (const_string "one")) | |
596 | (eq_attr "memory" "!none") | |
597 | (const_string "few") | |
598 | ] | |
599 | (const_string "one"))) | |
600 | ||
601 | ;; Rough readiness numbers. Fine tuning happens in i386.c. | |
602 | ;; | |
603 | ;; p0 describes port 0. | |
604 | ;; p01 describes ports 0 and 1 as a pair; alu insns can issue to either. | |
605 | ;; p2 describes port 2 for loads. | |
606 | ;; p34 describes ports 3 and 4 for stores. | |
607 | ;; fpu describes the fpu accessed via port 0. | |
608 | ;; ??? It is less than clear if there are separate fadd and fmul units | |
609 | ;; that could operate in parallel. | |
610 | ;; | |
611 | ;; ??? fxch isn't handled; not an issue until sched3 after reg-stack is real. | |
612 | ||
613 | (define_function_unit "ppro_p0" 1 0 | |
614 | (and (eq_attr "cpu" "pentiumpro") | |
7c7ef435 | 615 | (eq_attr "type" "ishift,lea,ibr,cld")) |
e075ae69 RH |
616 | 1 1) |
617 | ||
618 | (define_function_unit "ppro_p0" 1 0 | |
619 | (and (eq_attr "cpu" "pentiumpro") | |
620 | (eq_attr "type" "imul")) | |
621 | 4 1) | |
622 | ||
623 | ;; ??? Does the divider lock out the pipe while it works, | |
624 | ;; or is there a disconnected unit? | |
625 | (define_function_unit "ppro_p0" 1 0 | |
626 | (and (eq_attr "cpu" "pentiumpro") | |
627 | (eq_attr "type" "idiv")) | |
628 | 17 17) | |
36cf4bcf | 629 | |
e075ae69 RH |
630 | (define_function_unit "ppro_p0" 1 0 |
631 | (and (eq_attr "cpu" "pentiumpro") | |
22fb740d | 632 | (eq_attr "type" "fop,fop1,fsgn,fistp")) |
e075ae69 RH |
633 | 3 1) |
634 | ||
635 | (define_function_unit "ppro_p0" 1 0 | |
636 | (and (eq_attr "cpu" "pentiumpro") | |
637 | (eq_attr "type" "fcmov")) | |
638 | 2 1) | |
639 | ||
640 | (define_function_unit "ppro_p0" 1 0 | |
641 | (and (eq_attr "cpu" "pentiumpro") | |
642 | (eq_attr "type" "fcmp")) | |
643 | 1 1) | |
644 | ||
645 | (define_function_unit "ppro_p0" 1 0 | |
646 | (and (eq_attr "cpu" "pentiumpro") | |
647 | (eq_attr "type" "fmov")) | |
648 | 1 1) | |
649 | ||
650 | (define_function_unit "ppro_p0" 1 0 | |
651 | (and (eq_attr "cpu" "pentiumpro") | |
652 | (eq_attr "type" "fmul")) | |
653 | 5 1) | |
654 | ||
655 | (define_function_unit "ppro_p0" 1 0 | |
656 | (and (eq_attr "cpu" "pentiumpro") | |
657 | (eq_attr "type" "fdiv,fpspc")) | |
658 | 56 1) | |
659 | ||
660 | (define_function_unit "ppro_p01" 2 0 | |
661 | (and (eq_attr "cpu" "pentiumpro") | |
662 | (eq_attr "type" "!imov,fmov")) | |
663 | 1 1) | |
664 | ||
665 | (define_function_unit "ppro_p01" 2 0 | |
666 | (and (and (eq_attr "cpu" "pentiumpro") | |
667 | (eq_attr "type" "imov,fmov")) | |
668 | (eq_attr "memory" "none")) | |
669 | 1 1) | |
670 | ||
671 | (define_function_unit "ppro_p2" 1 0 | |
672 | (and (eq_attr "cpu" "pentiumpro") | |
673 | (ior (eq_attr "type" "pop") | |
674 | (eq_attr "memory" "load,both"))) | |
675 | 3 1) | |
676 | ||
677 | (define_function_unit "ppro_p34" 1 0 | |
678 | (and (eq_attr "cpu" "pentiumpro") | |
679 | (ior (eq_attr "type" "push") | |
680 | (eq_attr "memory" "store,both"))) | |
681 | 1 1) | |
682 | ||
683 | (define_function_unit "fpu" 1 0 | |
684 | (and (eq_attr "cpu" "pentiumpro") | |
22fb740d | 685 | (eq_attr "type" "fop,fop1,fsgn,fmov,fcmp,fcmov,fistp")) |
e075ae69 RH |
686 | 1 1) |
687 | ||
688 | (define_function_unit "fpu" 1 0 | |
689 | (and (eq_attr "cpu" "pentiumpro") | |
690 | (eq_attr "type" "fmul")) | |
691 | 5 2) | |
692 | ||
693 | (define_function_unit "fpu" 1 0 | |
694 | (and (eq_attr "cpu" "pentiumpro") | |
695 | (eq_attr "type" "fdiv,fpspc")) | |
696 | 56 56) | |
697 | ||
698 | ;; imul uses the fpu. ??? does it have the same throughput as fmul? | |
699 | (define_function_unit "fpu" 1 0 | |
700 | (and (eq_attr "cpu" "pentiumpro") | |
701 | (eq_attr "type" "imul")) | |
702 | 4 1) | |
703 | \f | |
704 | ;; AMD K6/K6-2 Scheduling | |
705 | ;; | |
706 | ;; The K6 has similar architecture to PPro. Important difference is, that | |
707 | ;; there are only two decoders and they seems to be much slower than execution | |
708 | ;; units. So we have to pay much more attention to proper decoding for | |
709 | ;; schedulers. We share most of scheduler code for PPro in i386.c | |
710 | ;; | |
711 | ;; The fp unit is not pipelined and do one operation per two cycles including | |
712 | ;; the FXCH. | |
713 | ;; | |
714 | ;; alu describes both ALU units (ALU-X and ALU-Y). | |
715 | ;; alux describes X alu unit | |
716 | ;; fpu describes FPU unit | |
717 | ;; load describes load unit. | |
718 | ;; branch describes branch unit. | |
719 | ;; store decsribes store unit. This unit is not modelled completely and only | |
720 | ;; used to model lea operation. Otherwise it lie outside of the critical | |
721 | ;; path. | |
722 | ;; | |
723 | ;; ??? fxch isn't handled; not an issue until sched3 after reg-stack is real. | |
36cf4bcf | 724 | |
e075ae69 | 725 | ;; The decoder specification is in the PPro section above! |
2ae0f82c | 726 | |
e075ae69 RH |
727 | ;; Shift instructions and certain arithmetic are issued only to X pipe. |
728 | (define_function_unit "k6_alux" 1 0 | |
729 | (and (eq_attr "cpu" "k6") | |
7c7ef435 | 730 | (eq_attr "type" "ishift,alu1,negnot,cld")) |
e075ae69 | 731 | 1 1) |
2ae0f82c | 732 | |
e075ae69 RH |
733 | ;; The QI mode arithmetic is issued to X pipe only. |
734 | (define_function_unit "k6_alux" 1 0 | |
735 | (and (eq_attr "cpu" "k6") | |
6ef67412 | 736 | (and (eq_attr "type" "alu,alu1,negnot,icmp,test,imovx,incdec") |
e075ae69 RH |
737 | (match_operand:QI 0 "general_operand" ""))) |
738 | 1 1) | |
a269a03c | 739 | |
e075ae69 RH |
740 | (define_function_unit "k6_alu" 2 0 |
741 | (and (eq_attr "cpu" "k6") | |
6ef67412 | 742 | (eq_attr "type" "ishift,alu1,negnot,alu,icmp,test,imovx,incdec,setcc,lea")) |
e075ae69 | 743 | 1 1) |
a269a03c | 744 | |
e075ae69 RH |
745 | (define_function_unit "k6_alu" 2 0 |
746 | (and (eq_attr "cpu" "k6") | |
747 | (and (eq_attr "type" "imov") | |
748 | (eq_attr "memory" "none"))) | |
749 | 1 1) | |
a269a03c | 750 | |
e075ae69 | 751 | (define_function_unit "k6_branch" 1 0 |
a269a03c | 752 | (and (eq_attr "cpu" "k6") |
e075ae69 RH |
753 | (eq_attr "type" "call,callv,ibr")) |
754 | 1 1) | |
a269a03c | 755 | |
e075ae69 RH |
756 | ;; Load unit have two cycle latency, but we take care for it in adjust_cost |
757 | (define_function_unit "k6_load" 1 0 | |
a269a03c | 758 | (and (eq_attr "cpu" "k6") |
e075ae69 RH |
759 | (ior (eq_attr "type" "pop") |
760 | (eq_attr "memory" "load,both"))) | |
761 | 1 1) | |
a269a03c | 762 | |
7c7ef435 JH |
763 | (define_function_unit "k6_load" 1 0 |
764 | (and (eq_attr "cpu" "k6") | |
765 | (and (eq_attr "type" "str") | |
766 | (eq_attr "memory" "load,both"))) | |
767 | 10 10) | |
768 | ||
e075ae69 RH |
769 | ;; Lea have two instructions, so latency is probably 2 |
770 | (define_function_unit "k6_store" 1 0 | |
771 | (and (eq_attr "cpu" "k6") | |
772 | (eq_attr "type" "lea")) | |
773 | 2 1) | |
a269a03c | 774 | |
7c7ef435 JH |
775 | (define_function_unit "k6_store" 1 0 |
776 | (and (eq_attr "cpu" "k6") | |
777 | (eq_attr "type" "str")) | |
778 | 10 10) | |
779 | ||
e075ae69 RH |
780 | (define_function_unit "k6_store" 1 0 |
781 | (and (eq_attr "cpu" "k6") | |
782 | (ior (eq_attr "type" "push") | |
783 | (eq_attr "memory" "store,both"))) | |
784 | 1 1) | |
a269a03c | 785 | |
e075ae69 RH |
786 | (define_function_unit "k6_fpu" 1 1 |
787 | (and (eq_attr "cpu" "k6") | |
22fb740d | 788 | (eq_attr "type" "fop,fop1,fmov,fcmp,fistp")) |
e075ae69 | 789 | 2 2) |
a269a03c | 790 | |
e075ae69 RH |
791 | (define_function_unit "k6_fpu" 1 1 |
792 | (and (eq_attr "cpu" "k6") | |
793 | (eq_attr "type" "fmul")) | |
794 | 2 2) | |
a269a03c | 795 | |
e075ae69 RH |
796 | ;; ??? Guess |
797 | (define_function_unit "k6_fpu" 1 1 | |
798 | (and (eq_attr "cpu" "k6") | |
799 | (eq_attr "type" "fdiv,fpspc")) | |
800 | 56 56) | |
a269a03c | 801 | |
e075ae69 RH |
802 | (define_function_unit "k6_alu" 2 0 |
803 | (and (eq_attr "cpu" "k6") | |
804 | (eq_attr "type" "imul")) | |
805 | 2 2) | |
a269a03c | 806 | |
e075ae69 RH |
807 | (define_function_unit "k6_alux" 1 0 |
808 | (and (eq_attr "cpu" "k6") | |
809 | (eq_attr "type" "imul")) | |
810 | 2 2) | |
a269a03c | 811 | |
e075ae69 RH |
812 | ;; ??? Guess |
813 | (define_function_unit "k6_alu" 2 0 | |
814 | (and (eq_attr "cpu" "k6") | |
815 | (eq_attr "type" "idiv")) | |
816 | 17 17) | |
2ae0f82c | 817 | |
e075ae69 RH |
818 | (define_function_unit "k6_alux" 1 0 |
819 | (and (eq_attr "cpu" "k6") | |
820 | (eq_attr "type" "idiv")) | |
821 | 17 17) | |
886c62d1 | 822 | \f |
309ada50 JH |
823 | ;; AMD Athlon Scheduling |
824 | ;; | |
825 | ;; The Athlon does contain three pipelined FP units, three integer units and | |
826 | ;; three address generation units. | |
827 | ;; | |
828 | ;; The predecode logic is determining boundaries of instructions in the 64 | |
829 | ;; byte cache line. So the cache line straddling problem of K6 might be issue | |
830 | ;; here as well, but it is not noted in the documentation. | |
831 | ;; | |
832 | ;; Three DirectPath instructions decoders and only one VectorPath decoder | |
833 | ;; is available. They can decode three DirectPath instructions or one VectorPath | |
834 | ;; instruction per cycle. | |
835 | ;; Decoded macro instructions are then passed to 72 entry instruction control | |
836 | ;; unit, that passes | |
837 | ;; it to the specialized integer (18 entry) and fp (36 entry) schedulers. | |
838 | ;; | |
839 | ;; The load/store queue unit is not attached to the schedulers but | |
cc712abf | 840 | ;; communicates with all the execution units separately instead. |
309ada50 JH |
841 | |
842 | (define_attr "athlon_decode" "direct,vector" | |
0b5107cf | 843 | (cond [(eq_attr "type" "call,imul,idiv,other,multi,fcmov,fpspc,str,pop,cld,fcmov") |
309ada50 JH |
844 | (const_string "vector") |
845 | (and (eq_attr "type" "push") | |
846 | (match_operand 1 "memory_operand" "")) | |
847 | (const_string "vector") | |
848 | (and (eq_attr "type" "fmov") | |
2b589241 JH |
849 | (and (eq_attr "memory" "load,store") |
850 | (eq_attr "mode" "XF"))) | |
309ada50 JH |
851 | (const_string "vector")] |
852 | (const_string "direct"))) | |
853 | ||
854 | (define_function_unit "athlon_vectordec" 1 0 | |
855 | (and (eq_attr "cpu" "athlon") | |
856 | (eq_attr "athlon_decode" "vector")) | |
857 | 1 1) | |
858 | ||
859 | (define_function_unit "athlon_directdec" 3 0 | |
860 | (and (eq_attr "cpu" "athlon") | |
861 | (eq_attr "athlon_decode" "direct")) | |
862 | 1 1) | |
863 | ||
864 | (define_function_unit "athlon_vectordec" 1 0 | |
865 | (and (eq_attr "cpu" "athlon") | |
866 | (eq_attr "athlon_decode" "direct")) | |
867 | 1 1 [(eq_attr "athlon_decode" "vector")]) | |
868 | ||
869 | (define_function_unit "athlon_ieu" 3 0 | |
870 | (and (eq_attr "cpu" "athlon") | |
6ef67412 | 871 | (eq_attr "type" "alu1,negnot,alu,icmp,test,imov,imovx,lea,incdec,ishift,ibr,call,callv,icmov,cld,pop,setcc,push,pop")) |
309ada50 JH |
872 | 1 1) |
873 | ||
7c7ef435 JH |
874 | (define_function_unit "athlon_ieu" 3 0 |
875 | (and (eq_attr "cpu" "athlon") | |
876 | (eq_attr "type" "str")) | |
877 | 15 15) | |
878 | ||
309ada50 JH |
879 | (define_function_unit "athlon_ieu" 3 0 |
880 | (and (eq_attr "cpu" "athlon") | |
881 | (eq_attr "type" "imul")) | |
0b5107cf | 882 | 5 0) |
309ada50 JH |
883 | |
884 | (define_function_unit "athlon_ieu" 3 0 | |
885 | (and (eq_attr "cpu" "athlon") | |
886 | (eq_attr "type" "idiv")) | |
0b5107cf | 887 | 42 0) |
309ada50 JH |
888 | |
889 | (define_function_unit "athlon_muldiv" 1 0 | |
890 | (and (eq_attr "cpu" "athlon") | |
891 | (eq_attr "type" "imul")) | |
892 | 5 0) | |
893 | ||
894 | (define_function_unit "athlon_muldiv" 1 0 | |
895 | (and (eq_attr "cpu" "athlon") | |
896 | (eq_attr "type" "idiv")) | |
0b5107cf | 897 | 42 42) |
309ada50 | 898 | |
0b5107cf | 899 | (define_attr "athlon_fpunits" "none,store,mul,add,muladd,any" |
22fb740d | 900 | (cond [(eq_attr "type" "fop,fop1,fcmp,fistp") |
309ada50 | 901 | (const_string "add") |
0b5107cf | 902 | (eq_attr "type" "fmul,fdiv,fpspc,fsgn,fcmov") |
309ada50 | 903 | (const_string "mul") |
0b5107cf | 904 | (and (eq_attr "type" "fmov") (eq_attr "memory" "store,both")) |
309ada50 | 905 | (const_string "store") |
0b5107cf JH |
906 | (and (eq_attr "type" "fmov") (eq_attr "memory" "load")) |
907 | (const_string "any") | |
309ada50 JH |
908 | (and (eq_attr "type" "fmov") |
909 | (ior (match_operand:SI 1 "register_operand" "") | |
910 | (match_operand 1 "immediate_operand" ""))) | |
911 | (const_string "store") | |
912 | (eq_attr "type" "fmov") | |
0b5107cf | 913 | (const_string "muladd")] |
309ada50 JH |
914 | (const_string "none"))) |
915 | ||
0b5107cf JH |
916 | ;; We use latencies 1 for definitions. This is OK to model colisions |
917 | ;; in execution units. The real latencies are modeled in the "fp" pipeline. | |
918 | ||
919 | ;; fsin, fcos: 96-192 | |
920 | ;; fsincos: 107-211 | |
921 | ;; fsqrt: 19 for SFmode, 27 for DFmode, 35 for XFmode. | |
922 | (define_function_unit "athlon_fp" 3 0 | |
309ada50 | 923 | (and (eq_attr "cpu" "athlon") |
0b5107cf JH |
924 | (eq_attr "type" "fpspc")) |
925 | 100 1) | |
309ada50 | 926 | |
0b5107cf JH |
927 | ;; 16 cycles for SFmode, 20 for DFmode and 24 for XFmode. |
928 | (define_function_unit "athlon_fp" 3 0 | |
309ada50 | 929 | (and (eq_attr "cpu" "athlon") |
0b5107cf JH |
930 | (eq_attr "type" "fdiv")) |
931 | 24 1) | |
932 | ||
933 | (define_function_unit "athlon_fp" 3 0 | |
934 | (and (eq_attr "cpu" "athlon") | |
22fb740d | 935 | (eq_attr "type" "fop,fop1,fmul,fistp")) |
309ada50 JH |
936 | 4 1) |
937 | ||
0b5107cf JH |
938 | ;; XFmode loads are slow. |
939 | ;; XFmode store is slow too (8 cycles), but we don't need to model it, because | |
940 | ;; there are no dependent instructions. | |
941 | ||
942 | (define_function_unit "athlon_fp" 3 0 | |
309ada50 JH |
943 | (and (eq_attr "cpu" "athlon") |
944 | (and (eq_attr "type" "fmov") | |
2b589241 JH |
945 | (and (eq_attr "memory" "load") |
946 | (eq_attr "mode" "XF")))) | |
0b5107cf JH |
947 | 10 1) |
948 | ||
949 | (define_function_unit "athlon_fp" 3 0 | |
950 | (and (eq_attr "cpu" "athlon") | |
951 | (eq_attr "type" "fmov,fsgn")) | |
309ada50 JH |
952 | 2 1) |
953 | ||
0b5107cf JH |
954 | ;; fcmp and ftst instructions |
955 | (define_function_unit "athlon_fp" 3 0 | |
956 | (and (eq_attr "cpu" "athlon") | |
957 | (and (eq_attr "type" "fcmp") | |
958 | (eq_attr "athlon_decode" "direct"))) | |
959 | 3 1) | |
960 | ||
961 | ;; fcmpi instructions. | |
962 | (define_function_unit "athlon_fp" 3 0 | |
963 | (and (eq_attr "cpu" "athlon") | |
964 | (and (eq_attr "type" "fcmp") | |
965 | (eq_attr "athlon_decode" "vector"))) | |
966 | 3 1) | |
967 | ||
968 | (define_function_unit "athlon_fp" 3 0 | |
969 | (and (eq_attr "cpu" "athlon") | |
970 | (eq_attr "type" "fcmov")) | |
971 | 7 1) | |
972 | ||
973 | (define_function_unit "athlon_fp_mul" 1 0 | |
974 | (and (eq_attr "cpu" "athlon") | |
975 | (eq_attr "athlon_fpunits" "mul")) | |
976 | 1 1) | |
977 | ||
978 | (define_function_unit "athlon_fp_add" 1 0 | |
979 | (and (eq_attr "cpu" "athlon") | |
980 | (eq_attr "athlon_fpunits" "add")) | |
981 | 1 1) | |
982 | ||
309ada50 JH |
983 | (define_function_unit "athlon_fp_muladd" 2 0 |
984 | (and (eq_attr "cpu" "athlon") | |
0b5107cf JH |
985 | (eq_attr "athlon_fpunits" "muladd,mul,add")) |
986 | 1 1) | |
309ada50 JH |
987 | |
988 | (define_function_unit "athlon_fp_store" 1 0 | |
989 | (and (eq_attr "cpu" "athlon") | |
0b5107cf | 990 | (eq_attr "athlon_fpunits" "store")) |
309ada50 JH |
991 | 1 1) |
992 | ||
f710504c | 993 | ;; We don't need to model the Address Generation Unit, since we don't model |
0b5107cf JH |
994 | ;; the re-order buffer yet and thus we never schedule more than three operations |
995 | ;; at time. Later we may want to experiment with MD_SCHED macros modeling the | |
996 | ;; decoders independently on the functional units. | |
997 | ||
998 | ;(define_function_unit "athlon_agu" 3 0 | |
999 | ; (and (eq_attr "cpu" "athlon") | |
1000 | ; (and (eq_attr "memory" "!none") | |
1001 | ; (eq_attr "athlon_fpunits" "none"))) | |
1002 | ; 1 1) | |
1003 | ||
1004 | ;; Model load unit to avoid too long sequences of loads. We don't need to | |
1005 | ;; model store queue, since it is hardly going to be bottleneck. | |
1006 | ||
1007 | (define_function_unit "athlon_load" 2 0 | |
309ada50 | 1008 | (and (eq_attr "cpu" "athlon") |
0b5107cf | 1009 | (eq_attr "memory" "load,both")) |
309ada50 JH |
1010 | 1 1) |
1011 | ||
1012 | \f | |
e075ae69 | 1013 | ;; Compare instructions. |
886c62d1 | 1014 | |
e075ae69 | 1015 | ;; All compare insns have expanders that save the operands away without |
c572e5ba | 1016 | ;; actually generating RTL. The bCOND or sCOND (emitted immediately |
e075ae69 | 1017 | ;; after the cmp) will actually emit the cmpM. |
886c62d1 | 1018 | |
e075ae69 RH |
1019 | (define_expand "cmpdi" |
1020 | [(set (reg:CC 17) | |
b9b2c339 | 1021 | (compare:CC (match_operand:DI 0 "nonimmediate_operand" "") |
9b70259d | 1022 | (match_operand:DI 1 "x86_64_general_operand" "")))] |
c572e5ba | 1023 | "" |
c572e5ba | 1024 | { |
b9b2c339 | 1025 | if (GET_CODE (operands[0]) == MEM && GET_CODE (operands[1]) == MEM) |
e075ae69 RH |
1026 | operands[0] = force_reg (DImode, operands[0]); |
1027 | ix86_compare_op0 = operands[0]; | |
1028 | ix86_compare_op1 = operands[1]; | |
c572e5ba | 1029 | DONE; |
0f40f9f7 | 1030 | }) |
c572e5ba | 1031 | |
e075ae69 RH |
1032 | (define_expand "cmpsi" |
1033 | [(set (reg:CC 17) | |
1034 | (compare:CC (match_operand:SI 0 "cmpsi_operand" "") | |
1035 | (match_operand:SI 1 "general_operand" "")))] | |
c572e5ba | 1036 | "" |
c572e5ba | 1037 | { |
b9b2c339 | 1038 | if (GET_CODE (operands[0]) == MEM && GET_CODE (operands[1]) == MEM) |
e075ae69 RH |
1039 | operands[0] = force_reg (SImode, operands[0]); |
1040 | ix86_compare_op0 = operands[0]; | |
1041 | ix86_compare_op1 = operands[1]; | |
c572e5ba | 1042 | DONE; |
0f40f9f7 | 1043 | }) |
c572e5ba | 1044 | |
e075ae69 RH |
1045 | (define_expand "cmphi" |
1046 | [(set (reg:CC 17) | |
b9b2c339 | 1047 | (compare:CC (match_operand:HI 0 "nonimmediate_operand" "") |
e075ae69 | 1048 | (match_operand:HI 1 "general_operand" "")))] |
c572e5ba | 1049 | "" |
c572e5ba | 1050 | { |
b9b2c339 | 1051 | if (GET_CODE (operands[0]) == MEM && GET_CODE (operands[1]) == MEM) |
e075ae69 RH |
1052 | operands[0] = force_reg (HImode, operands[0]); |
1053 | ix86_compare_op0 = operands[0]; | |
1054 | ix86_compare_op1 = operands[1]; | |
c572e5ba | 1055 | DONE; |
0f40f9f7 | 1056 | }) |
c572e5ba | 1057 | |
e075ae69 RH |
1058 | (define_expand "cmpqi" |
1059 | [(set (reg:CC 17) | |
b9b2c339 | 1060 | (compare:CC (match_operand:QI 0 "nonimmediate_operand" "") |
e075ae69 | 1061 | (match_operand:QI 1 "general_operand" "")))] |
d9f32422 | 1062 | "TARGET_QIMODE_MATH" |
c572e5ba | 1063 | { |
b9b2c339 | 1064 | if (GET_CODE (operands[0]) == MEM && GET_CODE (operands[1]) == MEM) |
e075ae69 RH |
1065 | operands[0] = force_reg (QImode, operands[0]); |
1066 | ix86_compare_op0 = operands[0]; | |
1067 | ix86_compare_op1 = operands[1]; | |
c572e5ba | 1068 | DONE; |
0f40f9f7 | 1069 | }) |
886c62d1 | 1070 | |
9b70259d JH |
1071 | (define_insn "cmpdi_ccno_1_rex64" |
1072 | [(set (reg 17) | |
1073 | (compare (match_operand:DI 0 "nonimmediate_operand" "r,?mr") | |
1074 | (match_operand:DI 1 "const0_operand" "n,n")))] | |
1075 | "TARGET_64BIT && ix86_match_ccmode (insn, CCNOmode)" | |
1076 | "@ | |
0f40f9f7 ZW |
1077 | test{q}\t{%0, %0|%0, %0} |
1078 | cmp{q}\t{%1, %0|%0, %1}" | |
9b70259d JH |
1079 | [(set_attr "type" "test,icmp") |
1080 | (set_attr "length_immediate" "0,1") | |
1081 | (set_attr "mode" "DI")]) | |
1082 | ||
1083 | (define_insn "*cmpdi_minus_1_rex64" | |
1084 | [(set (reg 17) | |
1085 | (compare (minus:DI (match_operand:DI 0 "nonimmediate_operand" "rm,r") | |
1086 | (match_operand:DI 1 "x86_64_general_operand" "re,mr")) | |
1087 | (const_int 0)))] | |
1b0c37d7 | 1088 | "TARGET_64BIT && ix86_match_ccmode (insn, CCGOCmode)" |
0f40f9f7 | 1089 | "cmp{q}\t{%1, %0|%0, %1}" |
9b70259d JH |
1090 | [(set_attr "type" "icmp") |
1091 | (set_attr "mode" "DI")]) | |
1092 | ||
1093 | (define_expand "cmpdi_1_rex64" | |
1094 | [(set (reg:CC 17) | |
1095 | (compare:CC (match_operand:DI 0 "nonimmediate_operand" "") | |
1096 | (match_operand:DI 1 "general_operand" "")))] | |
1b0c37d7 | 1097 | "TARGET_64BIT" |
9b70259d JH |
1098 | "") |
1099 | ||
1100 | (define_insn "cmpdi_1_insn_rex64" | |
1101 | [(set (reg 17) | |
1102 | (compare (match_operand:DI 0 "nonimmediate_operand" "mr,r") | |
1103 | (match_operand:DI 1 "x86_64_general_operand" "re,mr")))] | |
1104 | "TARGET_64BIT && ix86_match_ccmode (insn, CCmode)" | |
0f40f9f7 | 1105 | "cmp{q}\t{%1, %0|%0, %1}" |
9b70259d JH |
1106 | [(set_attr "type" "icmp") |
1107 | (set_attr "mode" "DI")]) | |
1108 | ||
1109 | ||
9076b9c1 JH |
1110 | (define_insn "*cmpsi_ccno_1" |
1111 | [(set (reg 17) | |
1112 | (compare (match_operand:SI 0 "nonimmediate_operand" "r,?mr") | |
1113 | (match_operand:SI 1 "const0_operand" "n,n")))] | |
1114 | "ix86_match_ccmode (insn, CCNOmode)" | |
16189740 | 1115 | "@ |
0f40f9f7 ZW |
1116 | test{l}\t{%0, %0|%0, %0} |
1117 | cmp{l}\t{%1, %0|%0, %1}" | |
6ef67412 JH |
1118 | [(set_attr "type" "test,icmp") |
1119 | (set_attr "length_immediate" "0,1") | |
1120 | (set_attr "mode" "SI")]) | |
16189740 | 1121 | |
9076b9c1 JH |
1122 | (define_insn "*cmpsi_minus_1" |
1123 | [(set (reg 17) | |
1124 | (compare (minus:SI (match_operand:SI 0 "nonimmediate_operand" "rm,r") | |
1125 | (match_operand:SI 1 "general_operand" "ri,mr")) | |
1126 | (const_int 0)))] | |
1127 | "ix86_match_ccmode (insn, CCGOCmode)" | |
0f40f9f7 | 1128 | "cmp{l}\t{%1, %0|%0, %1}" |
9076b9c1 | 1129 | [(set_attr "type" "icmp") |
6ef67412 | 1130 | (set_attr "mode" "SI")]) |
886c62d1 | 1131 | |
9076b9c1 | 1132 | (define_expand "cmpsi_1" |
e075ae69 RH |
1133 | [(set (reg:CC 17) |
1134 | (compare:CC (match_operand:SI 0 "nonimmediate_operand" "rm,r") | |
1135 | (match_operand:SI 1 "general_operand" "ri,mr")))] | |
9076b9c1 JH |
1136 | "" |
1137 | "") | |
1138 | ||
1139 | (define_insn "*cmpsi_1_insn" | |
1140 | [(set (reg 17) | |
1141 | (compare (match_operand:SI 0 "nonimmediate_operand" "rm,r") | |
1142 | (match_operand:SI 1 "general_operand" "ri,mr")))] | |
1143 | "(GET_CODE (operands[0]) != MEM || GET_CODE (operands[1]) != MEM) | |
1144 | && ix86_match_ccmode (insn, CCmode)" | |
0f40f9f7 | 1145 | "cmp{l}\t{%1, %0|%0, %1}" |
6ef67412 JH |
1146 | [(set_attr "type" "icmp") |
1147 | (set_attr "mode" "SI")]) | |
886c62d1 | 1148 | |
9076b9c1 | 1149 | (define_insn "*cmphi_ccno_1" |
16189740 RH |
1150 | [(set (reg 17) |
1151 | (compare (match_operand:HI 0 "nonimmediate_operand" "r,?mr") | |
1152 | (match_operand:HI 1 "const0_operand" "n,n")))] | |
1153 | "ix86_match_ccmode (insn, CCNOmode)" | |
e075ae69 | 1154 | "@ |
0f40f9f7 ZW |
1155 | test{w}\t{%0, %0|%0, %0} |
1156 | cmp{w}\t{%1, %0|%0, %1}" | |
6ef67412 JH |
1157 | [(set_attr "type" "test,icmp") |
1158 | (set_attr "length_immediate" "0,1") | |
1159 | (set_attr "mode" "HI")]) | |
886c62d1 | 1160 | |
9076b9c1 JH |
1161 | (define_insn "*cmphi_minus_1" |
1162 | [(set (reg 17) | |
1163 | (compare (minus:HI (match_operand:HI 0 "nonimmediate_operand" "rm,r") | |
1164 | (match_operand:HI 1 "general_operand" "ri,mr")) | |
1165 | (const_int 0)))] | |
1166 | "ix86_match_ccmode (insn, CCGOCmode)" | |
0f40f9f7 | 1167 | "cmp{w}\t{%1, %0|%0, %1}" |
6ef67412 JH |
1168 | [(set_attr "type" "icmp") |
1169 | (set_attr "mode" "HI")]) | |
e075ae69 | 1170 | |
9076b9c1 JH |
1171 | (define_insn "*cmphi_1" |
1172 | [(set (reg 17) | |
1173 | (compare (match_operand:HI 0 "nonimmediate_operand" "rm,r") | |
1174 | (match_operand:HI 1 "general_operand" "ri,mr")))] | |
1175 | "(GET_CODE (operands[0]) != MEM || GET_CODE (operands[1]) != MEM) | |
1176 | && ix86_match_ccmode (insn, CCmode)" | |
0f40f9f7 | 1177 | "cmp{w}\t{%1, %0|%0, %1}" |
9076b9c1 JH |
1178 | [(set_attr "type" "icmp") |
1179 | (set_attr "mode" "HI")]) | |
16189740 RH |
1180 | |
1181 | (define_insn "*cmpqi_ccno_1" | |
9076b9c1 JH |
1182 | [(set (reg 17) |
1183 | (compare (match_operand:QI 0 "nonimmediate_operand" "q,?mq") | |
1184 | (match_operand:QI 1 "const0_operand" "n,n")))] | |
1185 | "ix86_match_ccmode (insn, CCNOmode)" | |
e075ae69 | 1186 | "@ |
0f40f9f7 ZW |
1187 | test{b}\t{%0, %0|%0, %0} |
1188 | cmp{b}\t{$0, %0|%0, 0}" | |
6ef67412 JH |
1189 | [(set_attr "type" "test,icmp") |
1190 | (set_attr "length_immediate" "0,1") | |
1191 | (set_attr "mode" "QI")]) | |
886c62d1 | 1192 | |
16189740 | 1193 | (define_insn "*cmpqi_1" |
9076b9c1 JH |
1194 | [(set (reg 17) |
1195 | (compare (match_operand:QI 0 "nonimmediate_operand" "qm,q") | |
1196 | (match_operand:QI 1 "general_operand" "qi,mq")))] | |
1197 | "(GET_CODE (operands[0]) != MEM || GET_CODE (operands[1]) != MEM) | |
1198 | && ix86_match_ccmode (insn, CCmode)" | |
0f40f9f7 | 1199 | "cmp{b}\t{%1, %0|%0, %1}" |
6ef67412 JH |
1200 | [(set_attr "type" "icmp") |
1201 | (set_attr "mode" "QI")]) | |
e075ae69 | 1202 | |
9076b9c1 JH |
1203 | (define_insn "*cmpqi_minus_1" |
1204 | [(set (reg 17) | |
d70401eb JJ |
1205 | (compare (minus:QI (match_operand:QI 0 "nonimmediate_operand" "qm,q") |
1206 | (match_operand:QI 1 "general_operand" "qi,mq")) | |
9076b9c1 JH |
1207 | (const_int 0)))] |
1208 | "ix86_match_ccmode (insn, CCGOCmode)" | |
0f40f9f7 | 1209 | "cmp{b}\t{%1, %0|%0, %1}" |
9076b9c1 JH |
1210 | [(set_attr "type" "icmp") |
1211 | (set_attr "mode" "QI")]) | |
1212 | ||
e075ae69 | 1213 | (define_insn "*cmpqi_ext_1" |
9076b9c1 JH |
1214 | [(set (reg 17) |
1215 | (compare | |
d2836273 | 1216 | (match_operand:QI 0 "general_operand" "Qm") |
e075ae69 RH |
1217 | (subreg:QI |
1218 | (zero_extract:SI | |
d2836273 | 1219 | (match_operand 1 "ext_register_operand" "Q") |
e075ae69 RH |
1220 | (const_int 8) |
1221 | (const_int 8)) 0)))] | |
d2836273 | 1222 | "!TARGET_64BIT && ix86_match_ccmode (insn, CCmode)" |
0f40f9f7 | 1223 | "cmp{b}\t{%h1, %0|%0, %h1}" |
d2836273 JH |
1224 | [(set_attr "type" "icmp") |
1225 | (set_attr "mode" "QI")]) | |
1226 | ||
1227 | (define_insn "*cmpqi_ext_1_rex64" | |
1228 | [(set (reg 17) | |
1229 | (compare | |
3522082b | 1230 | (match_operand:QI 0 "register_operand" "Q") |
d2836273 JH |
1231 | (subreg:QI |
1232 | (zero_extract:SI | |
1233 | (match_operand 1 "ext_register_operand" "Q") | |
1234 | (const_int 8) | |
1235 | (const_int 8)) 0)))] | |
1236 | "TARGET_64BIT && ix86_match_ccmode (insn, CCmode)" | |
0f40f9f7 | 1237 | "cmp{b}\t{%h1, %0|%0, %h1}" |
6ef67412 JH |
1238 | [(set_attr "type" "icmp") |
1239 | (set_attr "mode" "QI")]) | |
e075ae69 RH |
1240 | |
1241 | (define_insn "*cmpqi_ext_2" | |
16189740 RH |
1242 | [(set (reg 17) |
1243 | (compare | |
e075ae69 RH |
1244 | (subreg:QI |
1245 | (zero_extract:SI | |
d2836273 | 1246 | (match_operand 0 "ext_register_operand" "Q") |
e075ae69 RH |
1247 | (const_int 8) |
1248 | (const_int 8)) 0) | |
1249 | (match_operand:QI 1 "const0_operand" "n")))] | |
16189740 | 1250 | "ix86_match_ccmode (insn, CCNOmode)" |
0f40f9f7 | 1251 | "test{b}\t%h0, %h0" |
6ef67412 JH |
1252 | [(set_attr "type" "test") |
1253 | (set_attr "length_immediate" "0") | |
1254 | (set_attr "mode" "QI")]) | |
e075ae69 | 1255 | |
9076b9c1 | 1256 | (define_expand "cmpqi_ext_3" |
e075ae69 RH |
1257 | [(set (reg:CC 17) |
1258 | (compare:CC | |
1259 | (subreg:QI | |
1260 | (zero_extract:SI | |
d2836273 | 1261 | (match_operand 0 "ext_register_operand" "") |
e075ae69 RH |
1262 | (const_int 8) |
1263 | (const_int 8)) 0) | |
d2836273 | 1264 | (match_operand:QI 1 "general_operand" "")))] |
e075ae69 | 1265 | "" |
9076b9c1 JH |
1266 | "") |
1267 | ||
1268 | (define_insn "cmpqi_ext_3_insn" | |
1269 | [(set (reg 17) | |
1270 | (compare | |
1271 | (subreg:QI | |
1272 | (zero_extract:SI | |
d2836273 | 1273 | (match_operand 0 "ext_register_operand" "Q") |
9076b9c1 JH |
1274 | (const_int 8) |
1275 | (const_int 8)) 0) | |
d2836273 JH |
1276 | (match_operand:QI 1 "general_operand" "Qmn")))] |
1277 | "!TARGET_64BIT && ix86_match_ccmode (insn, CCmode)" | |
0f40f9f7 | 1278 | "cmp{b}\t{%1, %h0|%h0, %1}" |
d2836273 JH |
1279 | [(set_attr "type" "icmp") |
1280 | (set_attr "mode" "QI")]) | |
1281 | ||
1282 | (define_insn "cmpqi_ext_3_insn_rex64" | |
1283 | [(set (reg 17) | |
1284 | (compare | |
1285 | (subreg:QI | |
1286 | (zero_extract:SI | |
1287 | (match_operand 0 "ext_register_operand" "Q") | |
1288 | (const_int 8) | |
1289 | (const_int 8)) 0) | |
1290 | (match_operand:QI 1 "nonmemory_operand" "Qn")))] | |
1291 | "TARGET_64BIT && ix86_match_ccmode (insn, CCmode)" | |
0f40f9f7 | 1292 | "cmp{b}\t{%1, %h0|%h0, %1}" |
6ef67412 JH |
1293 | [(set_attr "type" "icmp") |
1294 | (set_attr "mode" "QI")]) | |
e075ae69 RH |
1295 | |
1296 | (define_insn "*cmpqi_ext_4" | |
9076b9c1 JH |
1297 | [(set (reg 17) |
1298 | (compare | |
e075ae69 RH |
1299 | (subreg:QI |
1300 | (zero_extract:SI | |
d2836273 | 1301 | (match_operand 0 "ext_register_operand" "Q") |
e075ae69 RH |
1302 | (const_int 8) |
1303 | (const_int 8)) 0) | |
1304 | (subreg:QI | |
1305 | (zero_extract:SI | |
d2836273 | 1306 | (match_operand 1 "ext_register_operand" "Q") |
e075ae69 RH |
1307 | (const_int 8) |
1308 | (const_int 8)) 0)))] | |
9076b9c1 | 1309 | "ix86_match_ccmode (insn, CCmode)" |
0f40f9f7 | 1310 | "cmp{b}\t{%h1, %h0|%h0, %h1}" |
6ef67412 JH |
1311 | [(set_attr "type" "icmp") |
1312 | (set_attr "mode" "QI")]) | |
e075ae69 RH |
1313 | |
1314 | ;; These implement float point compares. | |
1315 | ;; %%% See if we can get away with VOIDmode operands on the actual insns, | |
1316 | ;; which would allow mix and match FP modes on the compares. Which is what | |
1317 | ;; the old patterns did, but with many more of them. | |
c572e5ba | 1318 | |
e075ae69 RH |
1319 | (define_expand "cmpxf" |
1320 | [(set (reg:CC 17) | |
1321 | (compare:CC (match_operand:XF 0 "cmp_fp_expander_operand" "") | |
1322 | (match_operand:XF 1 "cmp_fp_expander_operand" "")))] | |
1b0c37d7 | 1323 | "!TARGET_64BIT && TARGET_80387" |
c572e5ba | 1324 | { |
e075ae69 RH |
1325 | ix86_compare_op0 = operands[0]; |
1326 | ix86_compare_op1 = operands[1]; | |
c572e5ba | 1327 | DONE; |
0f40f9f7 | 1328 | }) |
4fb21e90 | 1329 | |
2b589241 JH |
1330 | (define_expand "cmptf" |
1331 | [(set (reg:CC 17) | |
1332 | (compare:CC (match_operand:TF 0 "cmp_fp_expander_operand" "") | |
1333 | (match_operand:TF 1 "cmp_fp_expander_operand" "")))] | |
1334 | "TARGET_80387" | |
2b589241 JH |
1335 | { |
1336 | ix86_compare_op0 = operands[0]; | |
1337 | ix86_compare_op1 = operands[1]; | |
1338 | DONE; | |
0f40f9f7 | 1339 | }) |
2b589241 | 1340 | |
e075ae69 RH |
1341 | (define_expand "cmpdf" |
1342 | [(set (reg:CC 17) | |
1343 | (compare:CC (match_operand:DF 0 "cmp_fp_expander_operand" "") | |
1344 | (match_operand:DF 1 "cmp_fp_expander_operand" "")))] | |
0644b628 | 1345 | "TARGET_80387 || TARGET_SSE2" |
4fb21e90 | 1346 | { |
e075ae69 RH |
1347 | ix86_compare_op0 = operands[0]; |
1348 | ix86_compare_op1 = operands[1]; | |
4fb21e90 | 1349 | DONE; |
0f40f9f7 | 1350 | }) |
886c62d1 | 1351 | |
e075ae69 RH |
1352 | (define_expand "cmpsf" |
1353 | [(set (reg:CC 17) | |
1354 | (compare:CC (match_operand:SF 0 "cmp_fp_expander_operand" "") | |
1355 | (match_operand:SF 1 "cmp_fp_expander_operand" "")))] | |
0644b628 | 1356 | "TARGET_80387 || TARGET_SSE" |
c572e5ba | 1357 | { |
e075ae69 RH |
1358 | ix86_compare_op0 = operands[0]; |
1359 | ix86_compare_op1 = operands[1]; | |
c572e5ba | 1360 | DONE; |
0f40f9f7 | 1361 | }) |
c572e5ba | 1362 | |
e075ae69 RH |
1363 | ;; FP compares, step 1: |
1364 | ;; Set the FP condition codes. | |
1365 | ;; | |
1366 | ;; CCFPmode compare with exceptions | |
1367 | ;; CCFPUmode compare with no exceptions | |
fe4435d9 | 1368 | |
e075ae69 RH |
1369 | ;; %%% It is an unfortunate fact that ftst has no non-popping variant, |
1370 | ;; and that fp moves clobber the condition codes, and that there is | |
1371 | ;; currently no way to describe this fact to reg-stack. So there are | |
1372 | ;; no splitters yet for this. | |
c572e5ba | 1373 | |
e075ae69 RH |
1374 | ;; %%% YIKES! This scheme does not retain a strong connection between |
1375 | ;; the real compare and the ultimate cc0 user, so CC_REVERSE does not | |
1376 | ;; work! Only allow tos/mem with tos in op 0. | |
1377 | ;; | |
1378 | ;; Hmm, of course, this is what the actual _hardware_ does. Perhaps | |
1379 | ;; things aren't as bad as they sound... | |
886c62d1 | 1380 | |
e075ae69 RH |
1381 | (define_insn "*cmpfp_0" |
1382 | [(set (match_operand:HI 0 "register_operand" "=a") | |
1383 | (unspec:HI | |
1384 | [(compare:CCFP (match_operand 1 "register_operand" "f") | |
1385 | (match_operand 2 "const0_operand" "X"))] 9))] | |
1386 | "TARGET_80387 | |
1387 | && FLOAT_MODE_P (GET_MODE (operands[1])) | |
1388 | && GET_MODE (operands[1]) == GET_MODE (operands[2])" | |
c572e5ba | 1389 | { |
e075ae69 | 1390 | if (find_regno_note (insn, REG_DEAD, REGNO (operands[1]))) |
0f40f9f7 | 1391 | return "ftst\;fnstsw\t%0\;fstp\t%y0"; |
e075ae69 | 1392 | else |
0f40f9f7 ZW |
1393 | return "ftst\;fnstsw\t%0"; |
1394 | } | |
6ef67412 JH |
1395 | [(set_attr "type" "multi") |
1396 | (set_attr "mode" "unknownfp")]) | |
c572e5ba | 1397 | |
e075ae69 RH |
1398 | ;; We may not use "#" to split and emit these, since the REG_DEAD notes |
1399 | ;; used to manage the reg stack popping would not be preserved. | |
886c62d1 | 1400 | |
e075ae69 RH |
1401 | (define_insn "*cmpfp_2_sf" |
1402 | [(set (reg:CCFP 18) | |
1403 | (compare:CCFP | |
1404 | (match_operand:SF 0 "register_operand" "f") | |
1405 | (match_operand:SF 1 "nonimmediate_operand" "fm")))] | |
cac58785 | 1406 | "TARGET_80387" |
e075ae69 | 1407 | "* return output_fp_compare (insn, operands, 0, 0);" |
6ef67412 JH |
1408 | [(set_attr "type" "fcmp") |
1409 | (set_attr "mode" "SF")]) | |
4fb21e90 | 1410 | |
6343a50e | 1411 | (define_insn "*cmpfp_2_sf_1" |
e075ae69 RH |
1412 | [(set (match_operand:HI 0 "register_operand" "=a") |
1413 | (unspec:HI | |
1414 | [(compare:CCFP | |
1415 | (match_operand:SF 1 "register_operand" "f") | |
1416 | (match_operand:SF 2 "nonimmediate_operand" "fm"))] 9))] | |
4fb21e90 | 1417 | "TARGET_80387" |
e075ae69 | 1418 | "* return output_fp_compare (insn, operands, 2, 0);" |
6ef67412 JH |
1419 | [(set_attr "type" "fcmp") |
1420 | (set_attr "mode" "SF")]) | |
e075ae69 RH |
1421 | |
1422 | (define_insn "*cmpfp_2_df" | |
1423 | [(set (reg:CCFP 18) | |
1424 | (compare:CCFP | |
1425 | (match_operand:DF 0 "register_operand" "f") | |
1426 | (match_operand:DF 1 "nonimmediate_operand" "fm")))] | |
926b3fae | 1427 | "TARGET_80387" |
e075ae69 | 1428 | "* return output_fp_compare (insn, operands, 0, 0);" |
6ef67412 JH |
1429 | [(set_attr "type" "fcmp") |
1430 | (set_attr "mode" "DF")]) | |
926b3fae | 1431 | |
6343a50e | 1432 | (define_insn "*cmpfp_2_df_1" |
e075ae69 RH |
1433 | [(set (match_operand:HI 0 "register_operand" "=a") |
1434 | (unspec:HI | |
1435 | [(compare:CCFP | |
1436 | (match_operand:DF 1 "register_operand" "f") | |
1437 | (match_operand:DF 2 "nonimmediate_operand" "fm"))] 9))] | |
4fb21e90 | 1438 | "TARGET_80387" |
e075ae69 | 1439 | "* return output_fp_compare (insn, operands, 2, 0);" |
6ef67412 JH |
1440 | [(set_attr "type" "multi") |
1441 | (set_attr "mode" "DF")]) | |
e075ae69 RH |
1442 | |
1443 | (define_insn "*cmpfp_2_xf" | |
1444 | [(set (reg:CCFP 18) | |
1445 | (compare:CCFP | |
1446 | (match_operand:XF 0 "register_operand" "f") | |
1447 | (match_operand:XF 1 "register_operand" "f")))] | |
1b0c37d7 | 1448 | "!TARGET_64BIT && TARGET_80387" |
e075ae69 | 1449 | "* return output_fp_compare (insn, operands, 0, 0);" |
6ef67412 JH |
1450 | [(set_attr "type" "fcmp") |
1451 | (set_attr "mode" "XF")]) | |
9ec36da5 | 1452 | |
2b589241 JH |
1453 | (define_insn "*cmpfp_2_tf" |
1454 | [(set (reg:CCFP 18) | |
1455 | (compare:CCFP | |
1456 | (match_operand:TF 0 "register_operand" "f") | |
1457 | (match_operand:TF 1 "register_operand" "f")))] | |
1458 | "TARGET_80387" | |
1459 | "* return output_fp_compare (insn, operands, 0, 0);" | |
1460 | [(set_attr "type" "fcmp") | |
1461 | (set_attr "mode" "XF")]) | |
1462 | ||
6343a50e | 1463 | (define_insn "*cmpfp_2_xf_1" |
e075ae69 RH |
1464 | [(set (match_operand:HI 0 "register_operand" "=a") |
1465 | (unspec:HI | |
1466 | [(compare:CCFP | |
1467 | (match_operand:XF 1 "register_operand" "f") | |
1468 | (match_operand:XF 2 "register_operand" "f"))] 9))] | |
1b0c37d7 | 1469 | "!TARGET_64BIT && TARGET_80387" |
e075ae69 | 1470 | "* return output_fp_compare (insn, operands, 2, 0);" |
6ef67412 JH |
1471 | [(set_attr "type" "multi") |
1472 | (set_attr "mode" "XF")]) | |
e075ae69 | 1473 | |
2b589241 JH |
1474 | (define_insn "*cmpfp_2_tf_1" |
1475 | [(set (match_operand:HI 0 "register_operand" "=a") | |
1476 | (unspec:HI | |
1477 | [(compare:CCFP | |
1478 | (match_operand:TF 1 "register_operand" "f") | |
1479 | (match_operand:TF 2 "register_operand" "f"))] 9))] | |
1480 | "TARGET_80387" | |
1481 | "* return output_fp_compare (insn, operands, 2, 0);" | |
1482 | [(set_attr "type" "multi") | |
1483 | (set_attr "mode" "XF")]) | |
1484 | ||
e075ae69 RH |
1485 | (define_insn "*cmpfp_2u" |
1486 | [(set (reg:CCFPU 18) | |
1487 | (compare:CCFPU | |
1488 | (match_operand 0 "register_operand" "f") | |
1489 | (match_operand 1 "register_operand" "f")))] | |
1490 | "TARGET_80387 | |
1491 | && FLOAT_MODE_P (GET_MODE (operands[0])) | |
1492 | && GET_MODE (operands[0]) == GET_MODE (operands[1])" | |
1493 | "* return output_fp_compare (insn, operands, 0, 1);" | |
6ef67412 JH |
1494 | [(set_attr "type" "fcmp") |
1495 | (set_attr "mode" "unknownfp")]) | |
4fb21e90 | 1496 | |
6343a50e | 1497 | (define_insn "*cmpfp_2u_1" |
e075ae69 RH |
1498 | [(set (match_operand:HI 0 "register_operand" "=a") |
1499 | (unspec:HI | |
1500 | [(compare:CCFPU | |
1501 | (match_operand 1 "register_operand" "f") | |
1502 | (match_operand 2 "register_operand" "f"))] 9))] | |
08a7baac | 1503 | "TARGET_80387 |
e075ae69 RH |
1504 | && FLOAT_MODE_P (GET_MODE (operands[1])) |
1505 | && GET_MODE (operands[1]) == GET_MODE (operands[2])" | |
1506 | "* return output_fp_compare (insn, operands, 2, 1);" | |
6ef67412 JH |
1507 | [(set_attr "type" "multi") |
1508 | (set_attr "mode" "unknownfp")]) | |
08a7baac | 1509 | |
e075ae69 RH |
1510 | ;; Patterns to match the SImode-in-memory ficom instructions. |
1511 | ;; | |
1512 | ;; %%% Play games with accepting gp registers, as otherwise we have to | |
1513 | ;; force them to memory during rtl generation, which is no good. We | |
1514 | ;; can get rid of this once we teach reload to do memory input reloads | |
1515 | ;; via pushes. | |
1516 | ||
6343a50e | 1517 | (define_insn "*ficom_1" |
e075ae69 RH |
1518 | [(set (reg:CCFP 18) |
1519 | (compare:CCFP | |
1520 | (match_operand 0 "register_operand" "f,f") | |
1521 | (float (match_operand:SI 1 "nonimmediate_operand" "m,?r"))))] | |
1522 | "0 && TARGET_80387 && FLOAT_MODE_P (GET_MODE (operands[0])) | |
1523 | && GET_MODE (XEXP (SET_SRC (PATTERN (insn)), 1)) == GET_MODE (operands[0])" | |
1524 | "#") | |
08a7baac | 1525 | |
e075ae69 RH |
1526 | ;; Split the not-really-implemented gp register case into a |
1527 | ;; push-op-pop sequence. | |
1528 | ;; | |
1529 | ;; %%% This is most efficient, but am I gonna get in trouble | |
1530 | ;; for separating cc0_setter and cc0_user? | |
2bb7a0f5 | 1531 | |
e075ae69 RH |
1532 | (define_split |
1533 | [(set (reg:CCFP 18) | |
1534 | (compare:CCFP | |
1535 | (match_operand:SF 0 "register_operand" "") | |
1536 | (float (match_operand:SI 1 "register_operand" ""))))] | |
1537 | "0 && TARGET_80387 && reload_completed" | |
1538 | [(set (mem:SI (pre_dec:SI (reg:SI 7))) (match_dup 1)) | |
1539 | (set (reg:CCFP 18) (compare:CCFP (match_dup 0) (match_dup 2))) | |
1540 | (parallel [(set (match_dup 1) (mem:SI (reg:SI 7))) | |
1541 | (set (reg:SI 7) (plus:SI (reg:SI 7) (const_int 4)))])] | |
1542 | "operands[2] = gen_rtx_MEM (Pmode, stack_pointer_rtx); | |
1543 | operands[2] = gen_rtx_FLOAT (GET_MODE (operands[0]), operands[2]);") | |
1544 | ||
1545 | ;; FP compares, step 2 | |
1546 | ;; Move the fpsw to ax. | |
1547 | ||
1548 | (define_insn "x86_fnstsw_1" | |
1549 | [(set (match_operand:HI 0 "register_operand" "=a") | |
1550 | (unspec:HI [(reg 18)] 9))] | |
2ae0f82c | 1551 | "TARGET_80387" |
0f40f9f7 | 1552 | "fnstsw\t%0" |
e075ae69 | 1553 | [(set_attr "length" "2") |
6ef67412 JH |
1554 | (set_attr "mode" "SI") |
1555 | (set_attr "i387" "1") | |
e075ae69 RH |
1556 | (set_attr "ppro_uops" "few")]) |
1557 | ||
1558 | ;; FP compares, step 3 | |
1559 | ;; Get ax into flags, general case. | |
1560 | ||
1561 | (define_insn "x86_sahf_1" | |
1562 | [(set (reg:CC 17) | |
1563 | (unspec:CC [(match_operand:HI 0 "register_operand" "a")] 10))] | |
1e07edd3 | 1564 | "!TARGET_64BIT" |
e075ae69 RH |
1565 | "sahf" |
1566 | [(set_attr "length" "1") | |
0b5107cf | 1567 | (set_attr "athlon_decode" "vector") |
6ef67412 | 1568 | (set_attr "mode" "SI") |
e075ae69 RH |
1569 | (set_attr "ppro_uops" "one")]) |
1570 | ||
1571 | ;; Pentium Pro can do steps 1 through 3 in one go. | |
1572 | ||
1573 | (define_insn "*cmpfp_i" | |
1574 | [(set (reg:CCFP 17) | |
1575 | (compare:CCFP (match_operand 0 "register_operand" "f") | |
1576 | (match_operand 1 "register_operand" "f")))] | |
1577 | "TARGET_80387 && TARGET_CMOVE | |
0644b628 | 1578 | && !SSE_FLOAT_MODE_P (GET_MODE (operands[0])) |
e075ae69 RH |
1579 | && FLOAT_MODE_P (GET_MODE (operands[0])) |
1580 | && GET_MODE (operands[0]) == GET_MODE (operands[0])" | |
1581 | "* return output_fp_compare (insn, operands, 1, 0);" | |
309ada50 | 1582 | [(set_attr "type" "fcmp") |
6ef67412 | 1583 | (set_attr "mode" "unknownfp") |
309ada50 | 1584 | (set_attr "athlon_decode" "vector")]) |
e075ae69 | 1585 | |
0644b628 JH |
1586 | (define_insn "*cmpfp_i_sse" |
1587 | [(set (reg:CCFP 17) | |
1588 | (compare:CCFP (match_operand 0 "register_operand" "f#x,x#f") | |
1589 | (match_operand 1 "nonimmediate_operand" "f#x,xm#f")))] | |
1590 | "TARGET_80387 | |
1591 | && SSE_FLOAT_MODE_P (GET_MODE (operands[0])) | |
1592 | && GET_MODE (operands[0]) == GET_MODE (operands[0])" | |
1593 | "* return output_fp_compare (insn, operands, 1, 0);" | |
1594 | [(set_attr "type" "fcmp,sse") | |
1595 | (set_attr "mode" "unknownfp") | |
1596 | (set_attr "athlon_decode" "vector")]) | |
1597 | ||
1598 | (define_insn "*cmpfp_i_sse_only" | |
1599 | [(set (reg:CCFP 17) | |
1600 | (compare:CCFP (match_operand 0 "register_operand" "x") | |
1601 | (match_operand 1 "nonimmediate_operand" "xm")))] | |
1602 | "SSE_FLOAT_MODE_P (GET_MODE (operands[0])) | |
1603 | && GET_MODE (operands[0]) == GET_MODE (operands[0])" | |
1604 | "* return output_fp_compare (insn, operands, 1, 0);" | |
1605 | [(set_attr "type" "sse") | |
1606 | (set_attr "mode" "unknownfp") | |
1607 | (set_attr "athlon_decode" "vector")]) | |
1608 | ||
e075ae69 RH |
1609 | (define_insn "*cmpfp_iu" |
1610 | [(set (reg:CCFPU 17) | |
1611 | (compare:CCFPU (match_operand 0 "register_operand" "f") | |
1612 | (match_operand 1 "register_operand" "f")))] | |
1613 | "TARGET_80387 && TARGET_CMOVE | |
0644b628 | 1614 | && !SSE_FLOAT_MODE_P (GET_MODE (operands[0])) |
e075ae69 RH |
1615 | && FLOAT_MODE_P (GET_MODE (operands[0])) |
1616 | && GET_MODE (operands[0]) == GET_MODE (operands[1])" | |
1617 | "* return output_fp_compare (insn, operands, 1, 1);" | |
309ada50 | 1618 | [(set_attr "type" "fcmp") |
6ef67412 | 1619 | (set_attr "mode" "unknownfp") |
309ada50 | 1620 | (set_attr "athlon_decode" "vector")]) |
0644b628 JH |
1621 | |
1622 | (define_insn "*cmpfp_iu_sse" | |
1623 | [(set (reg:CCFPU 17) | |
1624 | (compare:CCFPU (match_operand 0 "register_operand" "f#x,x#f") | |
1625 | (match_operand 1 "nonimmediate_operand" "f#x,xm#f")))] | |
1626 | "TARGET_80387 | |
1627 | && SSE_FLOAT_MODE_P (GET_MODE (operands[0])) | |
1628 | && GET_MODE (operands[0]) == GET_MODE (operands[1])" | |
1629 | "* return output_fp_compare (insn, operands, 1, 1);" | |
1630 | [(set_attr "type" "fcmp,sse") | |
1631 | (set_attr "mode" "unknownfp") | |
1632 | (set_attr "athlon_decode" "vector")]) | |
1633 | ||
1634 | (define_insn "*cmpfp_iu_sse_only" | |
1635 | [(set (reg:CCFPU 17) | |
1636 | (compare:CCFPU (match_operand 0 "register_operand" "x") | |
1637 | (match_operand 1 "nonimmediate_operand" "xm")))] | |
1638 | "SSE_FLOAT_MODE_P (GET_MODE (operands[0])) | |
1639 | && GET_MODE (operands[0]) == GET_MODE (operands[1])" | |
1640 | "* return output_fp_compare (insn, operands, 1, 1);" | |
1641 | [(set_attr "type" "sse") | |
1642 | (set_attr "mode" "unknownfp") | |
1643 | (set_attr "athlon_decode" "vector")]) | |
e075ae69 RH |
1644 | \f |
1645 | ;; Move instructions. | |
2ae0f82c | 1646 | |
e075ae69 | 1647 | ;; General case of fullword move. |
886c62d1 | 1648 | |
e075ae69 RH |
1649 | (define_expand "movsi" |
1650 | [(set (match_operand:SI 0 "nonimmediate_operand" "") | |
1651 | (match_operand:SI 1 "general_operand" ""))] | |
1652 | "" | |
1653 | "ix86_expand_move (SImode, operands); DONE;") | |
08a7baac | 1654 | |
e075ae69 RH |
1655 | ;; Push/pop instructions. They are separate since autoinc/dec is not a |
1656 | ;; general_operand. | |
1657 | ;; | |
1658 | ;; %%% We don't use a post-inc memory reference because x86 is not a | |
1659 | ;; general AUTO_INC_DEC host, which impacts how it is treated in flow. | |
1660 | ;; Changing this impacts compiler performance on other non-AUTO_INC_DEC | |
1661 | ;; targets without our curiosities, and it is just as easy to represent | |
1662 | ;; this differently. | |
886c62d1 | 1663 | |
a4414093 | 1664 | (define_insn "*pushsi2" |
e075ae69 | 1665 | [(set (match_operand:SI 0 "push_operand" "=<") |
2c5a510c | 1666 | (match_operand:SI 1 "general_no_elim_operand" "ri*m"))] |
0ec259ed | 1667 | "!TARGET_64BIT" |
0f40f9f7 | 1668 | "push{l}\t%1" |
6ef67412 JH |
1669 | [(set_attr "type" "push") |
1670 | (set_attr "mode" "SI")]) | |
4fb21e90 | 1671 | |
0ec259ed JH |
1672 | ;; For 64BIT abi we always round up to 8 bytes. |
1673 | (define_insn "*pushsi2_rex64" | |
1674 | [(set (match_operand:SI 0 "push_operand" "=X") | |
1675 | (match_operand:SI 1 "nonmemory_no_elim_operand" "ri"))] | |
1676 | "TARGET_64BIT" | |
0f40f9f7 | 1677 | "push{q}\t%q1" |
0ec259ed JH |
1678 | [(set_attr "type" "push") |
1679 | (set_attr "mode" "SI")]) | |
1680 | ||
bdeb029c JH |
1681 | (define_insn "*pushsi2_prologue" |
1682 | [(set (match_operand:SI 0 "push_operand" "=<") | |
1683 | (match_operand:SI 1 "general_no_elim_operand" "ri*m")) | |
f2042df3 | 1684 | (clobber (mem:BLK (scratch)))] |
0ec259ed | 1685 | "!TARGET_64BIT" |
0f40f9f7 | 1686 | "push{l}\t%1" |
6ef67412 JH |
1687 | [(set_attr "type" "push") |
1688 | (set_attr "mode" "SI")]) | |
bdeb029c JH |
1689 | |
1690 | (define_insn "*popsi1_epilogue" | |
1691 | [(set (match_operand:SI 0 "nonimmediate_operand" "=r*m") | |
1692 | (mem:SI (reg:SI 7))) | |
1693 | (set (reg:SI 7) | |
1694 | (plus:SI (reg:SI 7) (const_int 4))) | |
f2042df3 | 1695 | (clobber (mem:BLK (scratch)))] |
1e07edd3 | 1696 | "!TARGET_64BIT" |
0f40f9f7 | 1697 | "pop{l}\t%0" |
6ef67412 JH |
1698 | [(set_attr "type" "pop") |
1699 | (set_attr "mode" "SI")]) | |
bdeb029c | 1700 | |
e075ae69 RH |
1701 | (define_insn "popsi1" |
1702 | [(set (match_operand:SI 0 "nonimmediate_operand" "=r*m") | |
1703 | (mem:SI (reg:SI 7))) | |
1704 | (set (reg:SI 7) | |
1705 | (plus:SI (reg:SI 7) (const_int 4)))] | |
1e07edd3 | 1706 | "!TARGET_64BIT" |
0f40f9f7 | 1707 | "pop{l}\t%0" |
6ef67412 JH |
1708 | [(set_attr "type" "pop") |
1709 | (set_attr "mode" "SI")]) | |
c572e5ba | 1710 | |
a8bac9ab | 1711 | (define_insn "*movsi_xor" |
591702de JH |
1712 | [(set (match_operand:SI 0 "register_operand" "=r") |
1713 | (match_operand:SI 1 "const0_operand" "i")) | |
e075ae69 | 1714 | (clobber (reg:CC 17))] |
591702de | 1715 | "reload_completed && (!TARGET_USE_MOV0 || optimize_size)" |
0f40f9f7 | 1716 | "xor{l}\t{%0, %0|%0, %0}" |
591702de | 1717 | [(set_attr "type" "alu1") |
6ef67412 JH |
1718 | (set_attr "mode" "SI") |
1719 | (set_attr "length_immediate" "0")]) | |
591702de JH |
1720 | |
1721 | (define_insn "*movsi_or" | |
1722 | [(set (match_operand:SI 0 "register_operand" "=r") | |
1723 | (match_operand:SI 1 "immediate_operand" "i")) | |
1724 | (clobber (reg:CC 17))] | |
1725 | "reload_completed && GET_CODE (operands[1]) == CONST_INT | |
1726 | && INTVAL (operands[1]) == -1 | |
1727 | && (TARGET_PENTIUM || optimize_size)" | |
c572e5ba | 1728 | { |
591702de | 1729 | operands[1] = constm1_rtx; |
0f40f9f7 ZW |
1730 | return "or{l}\t{%1, %0|%0, %1}"; |
1731 | } | |
591702de | 1732 | [(set_attr "type" "alu1") |
6ef67412 JH |
1733 | (set_attr "mode" "SI") |
1734 | (set_attr "length_immediate" "1")]) | |
e075ae69 | 1735 | |
591702de | 1736 | (define_insn "*movsi_1" |
141e454b JH |
1737 | [(set (match_operand:SI 0 "nonimmediate_operand" "=*a,r,*a,m,!*y,!rm,!*Y,!rm,!*Y") |
1738 | (match_operand:SI 1 "general_operand" "im,rinm,rinm,rin,rm,*y,rm,*Y,*Y"))] | |
e075ae69 | 1739 | "GET_CODE (operands[0]) != MEM || GET_CODE (operands[1]) != MEM" |
886c62d1 | 1740 | { |
e075ae69 | 1741 | switch (get_attr_type (insn)) |
886c62d1 | 1742 | { |
141e454b JH |
1743 | case TYPE_SSE: |
1744 | if (get_attr_mode (insn) == TImode) | |
0f40f9f7 ZW |
1745 | return "movdqa\t{%1, %0|%0, %1}"; |
1746 | return "movd\t{%1, %0|%0, %1}"; | |
141e454b | 1747 | |
915119a5 | 1748 | case TYPE_MMX: |
0f40f9f7 | 1749 | return "movd\t{%1, %0|%0, %1}"; |
915119a5 | 1750 | |
e075ae69 | 1751 | case TYPE_LEA: |
0f40f9f7 | 1752 | return "lea{l}\t{%1, %0|%0, %1}"; |
915119a5 | 1753 | |
e075ae69 RH |
1754 | default: |
1755 | if (flag_pic && SYMBOLIC_CONST (operands[1])) | |
1756 | abort(); | |
0f40f9f7 | 1757 | return "mov{l}\t{%1, %0|%0, %1}"; |
886c62d1 | 1758 | } |
0f40f9f7 | 1759 | } |
e075ae69 | 1760 | [(set (attr "type") |
141e454b | 1761 | (cond [(eq_attr "alternative" "4,5") |
915119a5 | 1762 | (const_string "mmx") |
141e454b JH |
1763 | (eq_attr "alternative" "6,7,8") |
1764 | (const_string "sse") | |
915119a5 | 1765 | (and (ne (symbol_ref "flag_pic") (const_int 0)) |
e075ae69 RH |
1766 | (match_operand:SI 1 "symbolic_operand" "")) |
1767 | (const_string "lea") | |
1768 | ] | |
6ef67412 | 1769 | (const_string "imov"))) |
141e454b JH |
1770 | (set_attr "modrm" "0,*,0,*,*,*,*,*,*") |
1771 | (set_attr "mode" "SI,SI,SI,SI,SI,SI,TI,SI,SI")]) | |
e075ae69 | 1772 | |
0ec259ed JH |
1773 | ;; Stores and loads of ax to arbitary constant address. |
1774 | ;; We fake an second form of instruction to force reload to load address | |
1775 | ;; into register when rax is not available | |
1776 | (define_insn "*movabssi_1_rex64" | |
1777 | [(set (mem:SI (match_operand:DI 0 "x86_64_movabs_operand" "i,r,r")) | |
1778 | (match_operand:SI 1 "nonmemory_operand" "a,er,i"))] | |
1779 | "TARGET_64BIT" | |
1780 | "@ | |
0f40f9f7 ZW |
1781 | movabs{l}\t{%1, %P0|%P0, %1} |
1782 | mov{l}\t{%1, %a0|%a0, %1} | |
1783 | movabs{l}\t{%1, %a0|%a0, %1}" | |
0ec259ed JH |
1784 | [(set_attr "type" "imov") |
1785 | (set_attr "modrm" "0,*,*") | |
1786 | (set_attr "length_address" "8,0,0") | |
1787 | (set_attr "length_immediate" "0,*,*") | |
1788 | (set_attr "memory" "store") | |
1789 | (set_attr "mode" "SI")]) | |
1790 | ||
1791 | (define_insn "*movabssi_2_rex64" | |
1792 | [(set (match_operand:SI 0 "register_operand" "=a,r") | |
1793 | (mem:SI (match_operand:DI 1 "x86_64_movabs_operand" "i,r")))] | |
1794 | "TARGET_64BIT" | |
1795 | "@ | |
0f40f9f7 ZW |
1796 | movabs{l}\t{%P1, %0|%0, %P1} |
1797 | mov{l}\t{%a1, %0|%0, %a1}" | |
0ec259ed JH |
1798 | [(set_attr "type" "imov") |
1799 | (set_attr "modrm" "0,*") | |
1800 | (set_attr "length_address" "8,0") | |
1801 | (set_attr "length_immediate" "0") | |
1802 | (set_attr "memory" "load") | |
1803 | (set_attr "mode" "SI")]) | |
1804 | ||
e075ae69 RH |
1805 | (define_insn "*swapsi" |
1806 | [(set (match_operand:SI 0 "register_operand" "+r") | |
1807 | (match_operand:SI 1 "register_operand" "+r")) | |
1808 | (set (match_dup 1) | |
1809 | (match_dup 0))] | |
2bb7a0f5 | 1810 | "" |
0f40f9f7 | 1811 | "xchg{l}\t%1, %0" |
e075ae69 RH |
1812 | [(set_attr "type" "imov") |
1813 | (set_attr "pent_pair" "np") | |
0b5107cf | 1814 | (set_attr "athlon_decode" "vector") |
6ef67412 JH |
1815 | (set_attr "mode" "SI") |
1816 | (set_attr "modrm" "0") | |
e075ae69 | 1817 | (set_attr "ppro_uops" "few")]) |
886c62d1 | 1818 | |
e075ae69 RH |
1819 | (define_expand "movhi" |
1820 | [(set (match_operand:HI 0 "nonimmediate_operand" "") | |
1821 | (match_operand:HI 1 "general_operand" ""))] | |
ca097615 | 1822 | "" |
e075ae69 | 1823 | "ix86_expand_move (HImode, operands); DONE;") |
2f2a49e8 | 1824 | |
a4414093 | 1825 | (define_insn "*pushhi2" |
e075ae69 | 1826 | [(set (match_operand:HI 0 "push_operand" "=<,<") |
2c5a510c | 1827 | (match_operand:HI 1 "general_no_elim_operand" "n,r*m"))] |
1e07edd3 | 1828 | "!TARGET_64BIT" |
e075ae69 | 1829 | "@ |
0f40f9f7 ZW |
1830 | push{w}\t{|WORD PTR }%1 |
1831 | push{w}\t%1" | |
6ef67412 JH |
1832 | [(set_attr "type" "push") |
1833 | (set_attr "mode" "HI")]) | |
e075ae69 | 1834 | |
b3298882 JH |
1835 | ;; For 64BIT abi we always round up to 8 bytes. |
1836 | (define_insn "*pushhi2_rex64" | |
1837 | [(set (match_operand:HI 0 "push_operand" "=X") | |
1838 | (match_operand:HI 1 "nonmemory_no_elim_operand" "ri"))] | |
1839 | "TARGET_64BIT" | |
0f40f9f7 | 1840 | "push{q}\t%q1" |
b3298882 JH |
1841 | [(set_attr "type" "push") |
1842 | (set_attr "mode" "QI")]) | |
1843 | ||
e075ae69 | 1844 | (define_insn "*movhi_1" |
6ef67412 JH |
1845 | [(set (match_operand:HI 0 "nonimmediate_operand" "=*a,r,r,*a,r,m") |
1846 | (match_operand:HI 1 "general_operand" "i,r,rn,rm,rm,rn"))] | |
e075ae69 | 1847 | "GET_CODE (operands[0]) != MEM || GET_CODE (operands[1]) != MEM" |
886c62d1 | 1848 | { |
e075ae69 | 1849 | switch (get_attr_type (insn)) |
886c62d1 | 1850 | { |
e075ae69 RH |
1851 | case TYPE_IMOVX: |
1852 | /* movzwl is faster than movw on p2 due to partial word stalls, | |
1853 | though not as fast as an aligned movl. */ | |
0f40f9f7 | 1854 | return "movz{wl|x}\t{%1, %k0|%k0, %1}"; |
e075ae69 | 1855 | default: |
6ef67412 | 1856 | if (get_attr_mode (insn) == MODE_SI) |
0f40f9f7 | 1857 | return "mov{l}\t{%k1, %k0|%k0, %k1}"; |
e075ae69 | 1858 | else |
0f40f9f7 | 1859 | return "mov{w}\t{%1, %0|%0, %1}"; |
886c62d1 | 1860 | } |
0f40f9f7 | 1861 | } |
e075ae69 | 1862 | [(set (attr "type") |
6ef67412 | 1863 | (cond [(and (eq_attr "alternative" "0,1") |
0b5107cf JH |
1864 | (ior (eq (symbol_ref "TARGET_PARTIAL_REG_STALL") |
1865 | (const_int 0)) | |
1866 | (eq (symbol_ref "TARGET_HIMODE_MATH") | |
1867 | (const_int 0)))) | |
369e59b1 | 1868 | (const_string "imov") |
6ef67412 | 1869 | (and (eq_attr "alternative" "2,3,4") |
2247f6ed | 1870 | (match_operand:HI 1 "aligned_operand" "")) |
e075ae69 RH |
1871 | (const_string "imov") |
1872 | (and (ne (symbol_ref "TARGET_MOVX") | |
1873 | (const_int 0)) | |
6ef67412 | 1874 | (eq_attr "alternative" "0,1,3,4")) |
e075ae69 RH |
1875 | (const_string "imovx") |
1876 | ] | |
1877 | (const_string "imov"))) | |
6ef67412 | 1878 | (set (attr "mode") |
e075ae69 | 1879 | (cond [(eq_attr "type" "imovx") |
6ef67412 JH |
1880 | (const_string "SI") |
1881 | (and (eq_attr "alternative" "2,3,4") | |
369e59b1 | 1882 | (match_operand:HI 1 "aligned_operand" "")) |
6ef67412 JH |
1883 | (const_string "SI") |
1884 | (and (eq_attr "alternative" "0,1") | |
0b5107cf JH |
1885 | (ior (eq (symbol_ref "TARGET_PARTIAL_REG_STALL") |
1886 | (const_int 0)) | |
1887 | (eq (symbol_ref "TARGET_HIMODE_MATH") | |
1888 | (const_int 0)))) | |
6ef67412 | 1889 | (const_string "SI") |
e075ae69 | 1890 | ] |
6ef67412 JH |
1891 | (const_string "HI"))) |
1892 | (set_attr "modrm" "0,*,*,0,*,*")]) | |
e075ae69 | 1893 | |
0ec259ed JH |
1894 | ;; Stores and loads of ax to arbitary constant address. |
1895 | ;; We fake an second form of instruction to force reload to load address | |
1896 | ;; into register when rax is not available | |
1897 | (define_insn "*movabshi_1_rex64" | |
1898 | [(set (mem:HI (match_operand:DI 0 "x86_64_movabs_operand" "i,r,r")) | |
1899 | (match_operand:HI 1 "nonmemory_operand" "a,er,i"))] | |
1900 | "TARGET_64BIT" | |
1901 | "@ | |
0f40f9f7 ZW |
1902 | movabs{w}\t{%1, %P0|%P0, %1} |
1903 | mov{w}\t{%1, %a0|%a0, %1} | |
1904 | movabs{w}\t{%1, %a0|%a0, %1}" | |
0ec259ed JH |
1905 | [(set_attr "type" "imov") |
1906 | (set_attr "modrm" "0,*,*") | |
1907 | (set_attr "length_address" "8,0,0") | |
1908 | (set_attr "length_immediate" "0,*,*") | |
1909 | (set_attr "memory" "store") | |
1910 | (set_attr "mode" "HI")]) | |
1911 | ||
1912 | (define_insn "*movabshi_2_rex64" | |
1913 | [(set (match_operand:HI 0 "register_operand" "=a,r") | |
1914 | (mem:HI (match_operand:DI 1 "x86_64_movabs_operand" "i,r")))] | |
1915 | "TARGET_64BIT" | |
1916 | "@ | |
0f40f9f7 ZW |
1917 | movabs{w}\t{%P1, %0|%0, %P1} |
1918 | mov{w}\t{%a1, %0|%0, %a1}" | |
0ec259ed JH |
1919 | [(set_attr "type" "imov") |
1920 | (set_attr "modrm" "0,*") | |
1921 | (set_attr "length_address" "8,0") | |
1922 | (set_attr "length_immediate" "0") | |
1923 | (set_attr "memory" "load") | |
1924 | (set_attr "mode" "HI")]) | |
1925 | ||
e075ae69 RH |
1926 | (define_insn "*swaphi_1" |
1927 | [(set (match_operand:HI 0 "register_operand" "+r") | |
1928 | (match_operand:HI 1 "register_operand" "+r")) | |
1929 | (set (match_dup 1) | |
1930 | (match_dup 0))] | |
1931 | "TARGET_PARTIAL_REG_STALL" | |
0f40f9f7 | 1932 | "xchg{w}\t%1, %0" |
e075ae69 RH |
1933 | [(set_attr "type" "imov") |
1934 | (set_attr "pent_pair" "np") | |
6ef67412 JH |
1935 | (set_attr "mode" "HI") |
1936 | (set_attr "modrm" "0") | |
e075ae69 RH |
1937 | (set_attr "ppro_uops" "few")]) |
1938 | ||
1939 | (define_insn "*swaphi_2" | |
1940 | [(set (match_operand:HI 0 "register_operand" "+r") | |
1941 | (match_operand:HI 1 "register_operand" "+r")) | |
1942 | (set (match_dup 1) | |
1943 | (match_dup 0))] | |
1944 | "! TARGET_PARTIAL_REG_STALL" | |
0f40f9f7 | 1945 | "xchg{l}\t%k1, %k0" |
e075ae69 | 1946 | [(set_attr "type" "imov") |
e075ae69 | 1947 | (set_attr "pent_pair" "np") |
6ef67412 JH |
1948 | (set_attr "mode" "SI") |
1949 | (set_attr "modrm" "0") | |
e075ae69 | 1950 | (set_attr "ppro_uops" "few")]) |
886c62d1 | 1951 | |
2f2a49e8 | 1952 | (define_expand "movstricthi" |
e075ae69 | 1953 | [(set (strict_low_part (match_operand:HI 0 "nonimmediate_operand" "")) |
2f2a49e8 | 1954 | (match_operand:HI 1 "general_operand" ""))] |
b9b2c339 | 1955 | "! TARGET_PARTIAL_REG_STALL || optimize_size" |
2f2a49e8 MM |
1956 | { |
1957 | /* Don't generate memory->memory moves, go through a register */ | |
e075ae69 RH |
1958 | if (GET_CODE (operands[0]) == MEM && GET_CODE (operands[1]) == MEM) |
1959 | operands[1] = force_reg (HImode, operands[1]); | |
0f40f9f7 | 1960 | }) |
2f2a49e8 | 1961 | |
e075ae69 | 1962 | (define_insn "*movstricthi_1" |
fc524c1c | 1963 | [(set (strict_low_part (match_operand:HI 0 "nonimmediate_operand" "+rm,r")) |
e075ae69 | 1964 | (match_operand:HI 1 "general_operand" "rn,m"))] |
b9b2c339 | 1965 | "(! TARGET_PARTIAL_REG_STALL || optimize_size) |
e075ae69 | 1966 | && (GET_CODE (operands[0]) != MEM || GET_CODE (operands[1]) != MEM)" |
0f40f9f7 | 1967 | "mov{w}\t{%1, %0|%0, %1}" |
6ef67412 JH |
1968 | [(set_attr "type" "imov") |
1969 | (set_attr "mode" "HI")]) | |
1970 | ||
1971 | (define_insn "*movstricthi_xor" | |
208b0ab1 | 1972 | [(set (strict_low_part (match_operand:HI 0 "register_operand" "+r")) |
6ef67412 JH |
1973 | (match_operand:HI 1 "const0_operand" "i")) |
1974 | (clobber (reg:CC 17))] | |
b9b2c339 JH |
1975 | "reload_completed |
1976 | && ((!TARGET_USE_MOV0 && !TARGET_PARTIAL_REG_STALL) || optimize_size)" | |
0f40f9f7 | 1977 | "xor{w}\t{%0, %0|%0, %0}" |
6ef67412 JH |
1978 | [(set_attr "type" "alu1") |
1979 | (set_attr "mode" "HI") | |
1980 | (set_attr "length_immediate" "0")]) | |
886c62d1 | 1981 | |
2f2a49e8 | 1982 | (define_expand "movqi" |
4cbfbb1b | 1983 | [(set (match_operand:QI 0 "nonimmediate_operand" "") |
2f2a49e8 MM |
1984 | (match_operand:QI 1 "general_operand" ""))] |
1985 | "" | |
e075ae69 RH |
1986 | "ix86_expand_move (QImode, operands); DONE;") |
1987 | ||
7dd4b4a3 JH |
1988 | ;; emit_push_insn when it calls move_by_pieces requires an insn to |
1989 | ;; "push a byte". But actually we use pushw, which has the effect | |
1990 | ;; of rounding the amount pushed up to a halfword. | |
1991 | ||
1992 | (define_insn "*pushqi2" | |
1993 | [(set (match_operand:QI 0 "push_operand" "=X,X") | |
1994 | (match_operand:QI 1 "nonmemory_no_elim_operand" "n,r"))] | |
1995 | "!TARGET_64BIT" | |
1996 | "@ | |
0f40f9f7 ZW |
1997 | push{w}\t{|word ptr }%1 |
1998 | push{w}\t%w1" | |
7dd4b4a3 JH |
1999 | [(set_attr "type" "push") |
2000 | (set_attr "mode" "HI")]) | |
2001 | ||
b3298882 JH |
2002 | ;; For 64BIT abi we always round up to 8 bytes. |
2003 | (define_insn "*pushqi2_rex64" | |
2004 | [(set (match_operand:QI 0 "push_operand" "=X") | |
2005 | (match_operand:QI 1 "nonmemory_no_elim_operand" "ri"))] | |
2006 | "TARGET_64BIT" | |
0f40f9f7 | 2007 | "push{q}\t%q1" |
b3298882 JH |
2008 | [(set_attr "type" "push") |
2009 | (set_attr "mode" "QI")]) | |
2010 | ||
0b5107cf JH |
2011 | ;; Situation is quite tricky about when to choose full sized (SImode) move |
2012 | ;; over QImode moves. For Q_REG -> Q_REG move we use full size only for | |
2013 | ;; partial register dependency machines (such as AMD Athlon), where QImode | |
2014 | ;; moves issue extra dependency and for partial register stalls machines | |
2015 | ;; that don't use QImode patterns (and QImode move cause stall on the next | |
2016 | ;; instruction). | |
2017 | ;; | |
2018 | ;; For loads of Q_REG to NONQ_REG we use full sized moves except for partial | |
2019 | ;; register stall machines with, where we use QImode instructions, since | |
2020 | ;; partial register stall can be caused there. Then we use movzx. | |
e075ae69 | 2021 | (define_insn "*movqi_1" |
0b5107cf JH |
2022 | [(set (match_operand:QI 0 "nonimmediate_operand" "=q,q ,q ,r,r ,?r,m") |
2023 | (match_operand:QI 1 "general_operand" " q,qn,qm,q,rn,qm,qn"))] | |
e075ae69 | 2024 | "GET_CODE (operands[0]) != MEM || GET_CODE (operands[1]) != MEM" |
886c62d1 | 2025 | { |
e075ae69 | 2026 | switch (get_attr_type (insn)) |
b76c90cf | 2027 | { |
e075ae69 | 2028 | case TYPE_IMOVX: |
1a06f5fe | 2029 | if (!ANY_QI_REG_P (operands[1]) && GET_CODE (operands[1]) != MEM) |
e075ae69 | 2030 | abort (); |
0f40f9f7 | 2031 | return "movz{bl|x}\t{%1, %k0|%k0, %1}"; |
e075ae69 | 2032 | default: |
6ef67412 | 2033 | if (get_attr_mode (insn) == MODE_SI) |
0f40f9f7 | 2034 | return "mov{l}\t{%k1, %k0|%k0, %k1}"; |
b76c90cf | 2035 | else |
0f40f9f7 | 2036 | return "mov{b}\t{%1, %0|%0, %1}"; |
b76c90cf | 2037 | } |
0f40f9f7 | 2038 | } |
e075ae69 | 2039 | [(set (attr "type") |
0b5107cf JH |
2040 | (cond [(and (eq_attr "alternative" "3") |
2041 | (ior (eq (symbol_ref "TARGET_PARTIAL_REG_STALL") | |
2042 | (const_int 0)) | |
2043 | (eq (symbol_ref "TARGET_QIMODE_MATH") | |
2044 | (const_int 0)))) | |
2045 | (const_string "imov") | |
2046 | (eq_attr "alternative" "3,5") | |
e075ae69 RH |
2047 | (const_string "imovx") |
2048 | (and (ne (symbol_ref "TARGET_MOVX") | |
2049 | (const_int 0)) | |
0b5107cf | 2050 | (eq_attr "alternative" "2")) |
e075ae69 RH |
2051 | (const_string "imovx") |
2052 | ] | |
2053 | (const_string "imov"))) | |
6ef67412 JH |
2054 | (set (attr "mode") |
2055 | (cond [(eq_attr "alternative" "3,4,5") | |
2056 | (const_string "SI") | |
2057 | (eq_attr "alternative" "6") | |
2058 | (const_string "QI") | |
2059 | (eq_attr "type" "imovx") | |
2060 | (const_string "SI") | |
0b5107cf | 2061 | (and (eq_attr "type" "imov") |
6ef67412 | 2062 | (and (eq_attr "alternative" "0,1,2") |
0b5107cf JH |
2063 | (ne (symbol_ref "TARGET_PARTIAL_REG_DEPENDENCY") |
2064 | (const_int 0)))) | |
6ef67412 | 2065 | (const_string "SI") |
0b5107cf JH |
2066 | ;; Avoid partial register stalls when not using QImode arithmetic |
2067 | (and (eq_attr "type" "imov") | |
6ef67412 | 2068 | (and (eq_attr "alternative" "0,1,2") |
0b5107cf JH |
2069 | (and (ne (symbol_ref "TARGET_PARTIAL_REG_STALL") |
2070 | (const_int 0)) | |
2071 | (eq (symbol_ref "TARGET_QIMODE_MATH") | |
2072 | (const_int 0))))) | |
6ef67412 JH |
2073 | (const_string "SI") |
2074 | ] | |
2075 | (const_string "QI")))]) | |
e075ae69 RH |
2076 | |
2077 | (define_expand "reload_outqi" | |
2078 | [(parallel [(match_operand:QI 0 "" "=m") | |
2079 | (match_operand:QI 1 "register_operand" "r") | |
2080 | (match_operand:QI 2 "register_operand" "=&q")])] | |
2081 | "" | |
e075ae69 RH |
2082 | { |
2083 | rtx op0, op1, op2; | |
2084 | op0 = operands[0]; op1 = operands[1]; op2 = operands[2]; | |
886c62d1 | 2085 | |
e075ae69 RH |
2086 | if (reg_overlap_mentioned_p (op2, op0)) |
2087 | abort (); | |
2088 | if (! q_regs_operand (op1, QImode)) | |
2089 | { | |
2090 | emit_insn (gen_movqi (op2, op1)); | |
2091 | op1 = op2; | |
2092 | } | |
2093 | emit_insn (gen_movqi (op0, op1)); | |
2094 | DONE; | |
0f40f9f7 | 2095 | }) |
886c62d1 | 2096 | |
e075ae69 RH |
2097 | (define_insn "*swapqi" |
2098 | [(set (match_operand:QI 0 "register_operand" "+r") | |
2099 | (match_operand:QI 1 "register_operand" "+r")) | |
2100 | (set (match_dup 1) | |
2101 | (match_dup 0))] | |
2102 | "" | |
0f40f9f7 | 2103 | "xchg{b}\t%1, %0" |
e075ae69 RH |
2104 | [(set_attr "type" "imov") |
2105 | (set_attr "pent_pair" "np") | |
6ef67412 JH |
2106 | (set_attr "mode" "QI") |
2107 | (set_attr "modrm" "0") | |
e075ae69 | 2108 | (set_attr "ppro_uops" "few")]) |
886c62d1 | 2109 | |
2f2a49e8 | 2110 | (define_expand "movstrictqi" |
4cbfbb1b | 2111 | [(set (strict_low_part (match_operand:QI 0 "nonimmediate_operand" "")) |
2f2a49e8 | 2112 | (match_operand:QI 1 "general_operand" ""))] |
e075ae69 | 2113 | "! TARGET_PARTIAL_REG_STALL" |
2f2a49e8 | 2114 | { |
e03f5d43 | 2115 | /* Don't generate memory->memory moves, go through a register. */ |
e075ae69 RH |
2116 | if (GET_CODE (operands[0]) == MEM && GET_CODE (operands[1]) == MEM) |
2117 | operands[1] = force_reg (QImode, operands[1]); | |
0f40f9f7 | 2118 | }) |
2f2a49e8 | 2119 | |
e075ae69 | 2120 | (define_insn "*movstrictqi_1" |
2ae0f82c | 2121 | [(set (strict_low_part (match_operand:QI 0 "nonimmediate_operand" "+qm,q")) |
c0f06344 | 2122 | (match_operand:QI 1 "general_operand" "*qn,m"))] |
e075ae69 RH |
2123 | "! TARGET_PARTIAL_REG_STALL |
2124 | && (GET_CODE (operands[0]) != MEM || GET_CODE (operands[1]) != MEM)" | |
0f40f9f7 | 2125 | "mov{b}\t{%1, %0|%0, %1}" |
6ef67412 JH |
2126 | [(set_attr "type" "imov") |
2127 | (set_attr "mode" "QI")]) | |
2128 | ||
2129 | (define_insn "*movstrictqi_xor" | |
5e6d6bf0 | 2130 | [(set (strict_low_part (match_operand:QI 0 "q_regs_operand" "+q")) |
6ef67412 JH |
2131 | (match_operand:QI 1 "const0_operand" "i")) |
2132 | (clobber (reg:CC 17))] | |
2133 | "reload_completed && (!TARGET_USE_MOV0 || optimize_size)" | |
0f40f9f7 | 2134 | "xor{b}\t{%0, %0|%0, %0}" |
6ef67412 JH |
2135 | [(set_attr "type" "alu1") |
2136 | (set_attr "mode" "QI") | |
2137 | (set_attr "length_immediate" "0")]) | |
e075ae69 RH |
2138 | |
2139 | (define_insn "*movsi_extv_1" | |
d2836273 | 2140 | [(set (match_operand:SI 0 "register_operand" "=R") |
3522082b | 2141 | (sign_extract:SI (match_operand 1 "ext_register_operand" "Q") |
e075ae69 RH |
2142 | (const_int 8) |
2143 | (const_int 8)))] | |
2144 | "" | |
0f40f9f7 | 2145 | "movs{bl|x}\t{%h1, %0|%0, %h1}" |
6ef67412 JH |
2146 | [(set_attr "type" "imovx") |
2147 | (set_attr "mode" "SI")]) | |
e075ae69 RH |
2148 | |
2149 | (define_insn "*movhi_extv_1" | |
d2836273 | 2150 | [(set (match_operand:HI 0 "register_operand" "=R") |
3522082b | 2151 | (sign_extract:HI (match_operand 1 "ext_register_operand" "Q") |
e075ae69 RH |
2152 | (const_int 8) |
2153 | (const_int 8)))] | |
2154 | "" | |
0f40f9f7 | 2155 | "movs{bl|x}\t{%h1, %k0|%k0, %h1}" |
6ef67412 JH |
2156 | [(set_attr "type" "imovx") |
2157 | (set_attr "mode" "SI")]) | |
e075ae69 RH |
2158 | |
2159 | (define_insn "*movqi_extv_1" | |
0ec259ed | 2160 | [(set (match_operand:QI 0 "nonimmediate_operand" "=Qm,?r") |
3522082b | 2161 | (sign_extract:QI (match_operand 1 "ext_register_operand" "Q,Q") |
e075ae69 RH |
2162 | (const_int 8) |
2163 | (const_int 8)))] | |
0ec259ed | 2164 | "!TARGET_64BIT" |
886c62d1 | 2165 | { |
e075ae69 | 2166 | switch (get_attr_type (insn)) |
886c62d1 | 2167 | { |
e075ae69 | 2168 | case TYPE_IMOVX: |
0f40f9f7 | 2169 | return "movs{bl|x}\t{%h1, %k0|%k0, %h1}"; |
e075ae69 | 2170 | default: |
0f40f9f7 | 2171 | return "mov{b}\t{%h1, %0|%0, %h1}"; |
886c62d1 | 2172 | } |
0f40f9f7 | 2173 | } |
e075ae69 RH |
2174 | [(set (attr "type") |
2175 | (if_then_else (and (match_operand:QI 0 "register_operand" "") | |
2176 | (ior (not (match_operand:QI 0 "q_regs_operand" "")) | |
2177 | (ne (symbol_ref "TARGET_MOVX") | |
2178 | (const_int 0)))) | |
2179 | (const_string "imovx") | |
6ef67412 JH |
2180 | (const_string "imov"))) |
2181 | (set (attr "mode") | |
2182 | (if_then_else (eq_attr "type" "imovx") | |
2183 | (const_string "SI") | |
2184 | (const_string "QI")))]) | |
e075ae69 | 2185 | |
0ec259ed JH |
2186 | (define_insn "*movqi_extv_1_rex64" |
2187 | [(set (match_operand:QI 0 "register_operand" "=Q,?R") | |
3522082b | 2188 | (sign_extract:QI (match_operand 1 "ext_register_operand" "Q,Q") |
0ec259ed JH |
2189 | (const_int 8) |
2190 | (const_int 8)))] | |
2191 | "TARGET_64BIT" | |
0ec259ed JH |
2192 | { |
2193 | switch (get_attr_type (insn)) | |
2194 | { | |
2195 | case TYPE_IMOVX: | |
0f40f9f7 | 2196 | return "movs{bl|x}\t{%h1, %k0|%k0, %h1}"; |
0ec259ed | 2197 | default: |
0f40f9f7 | 2198 | return "mov{b}\t{%h1, %0|%0, %h1}"; |
0ec259ed | 2199 | } |
0f40f9f7 | 2200 | } |
0ec259ed JH |
2201 | [(set (attr "type") |
2202 | (if_then_else (and (match_operand:QI 0 "register_operand" "") | |
2203 | (ior (not (match_operand:QI 0 "q_regs_operand" "")) | |
2204 | (ne (symbol_ref "TARGET_MOVX") | |
2205 | (const_int 0)))) | |
2206 | (const_string "imovx") | |
2207 | (const_string "imov"))) | |
2208 | (set (attr "mode") | |
2209 | (if_then_else (eq_attr "type" "imovx") | |
2210 | (const_string "SI") | |
2211 | (const_string "QI")))]) | |
2212 | ||
2213 | ;; Stores and loads of ax to arbitary constant address. | |
2214 | ;; We fake an second form of instruction to force reload to load address | |
2215 | ;; into register when rax is not available | |
2216 | (define_insn "*movabsqi_1_rex64" | |
2217 | [(set (mem:QI (match_operand:DI 0 "x86_64_movabs_operand" "i,r,r")) | |
2218 | (match_operand:QI 1 "nonmemory_operand" "a,er,i"))] | |
2219 | "TARGET_64BIT" | |
2220 | "@ | |
5e2ce672 JH |
2221 | movabs{b}\t{%1, %P0|%P0, %1} |
2222 | mov{b}\t{%1, %a0|%a0, %1} | |
2223 | movabs{b}\t{%1, %a0|%a0, %1}" | |
0ec259ed JH |
2224 | [(set_attr "type" "imov") |
2225 | (set_attr "modrm" "0,*,*") | |
2226 | (set_attr "length_address" "8,0,0") | |
2227 | (set_attr "length_immediate" "0,*,*") | |
2228 | (set_attr "memory" "store") | |
2229 | (set_attr "mode" "QI")]) | |
2230 | ||
2231 | (define_insn "*movabsqi_2_rex64" | |
2232 | [(set (match_operand:QI 0 "register_operand" "=a,r") | |
2233 | (mem:QI (match_operand:DI 1 "x86_64_movabs_operand" "i,r")))] | |
2234 | "TARGET_64BIT" | |
2235 | "@ | |
5e2ce672 JH |
2236 | movabs{b}\t{%P1, %0|%0, %P1} |
2237 | mov{b}\t{%a1, %0|%0, %a1}" | |
0ec259ed JH |
2238 | [(set_attr "type" "imov") |
2239 | (set_attr "modrm" "0,*") | |
2240 | (set_attr "length_address" "8,0") | |
2241 | (set_attr "length_immediate" "0") | |
2242 | (set_attr "memory" "load") | |
2243 | (set_attr "mode" "QI")]) | |
2244 | ||
e075ae69 | 2245 | (define_insn "*movsi_extzv_1" |
d2836273 JH |
2246 | [(set (match_operand:SI 0 "register_operand" "=R") |
2247 | (zero_extract:SI (match_operand 1 "ext_register_operand" "Q") | |
e075ae69 RH |
2248 | (const_int 8) |
2249 | (const_int 8)))] | |
2250 | "" | |
0f40f9f7 | 2251 | "movz{bl|x}\t{%h1, %0|%0, %h1}" |
6ef67412 JH |
2252 | [(set_attr "type" "imovx") |
2253 | (set_attr "mode" "SI")]) | |
886c62d1 | 2254 | |
d2836273 JH |
2255 | (define_insn "*movqi_extzv_2" |
2256 | [(set (match_operand:QI 0 "nonimmediate_operand" "=Qm,?R") | |
2257 | (subreg:QI (zero_extract:SI (match_operand 1 "ext_register_operand" "Q,Q") | |
e075ae69 RH |
2258 | (const_int 8) |
2259 | (const_int 8)) 0))] | |
d2836273 | 2260 | "!TARGET_64BIT" |
f31fce3f | 2261 | { |
e075ae69 | 2262 | switch (get_attr_type (insn)) |
f31fce3f | 2263 | { |
e075ae69 | 2264 | case TYPE_IMOVX: |
0f40f9f7 | 2265 | return "movz{bl|x}\t{%h1, %k0|%k0, %h1}"; |
e075ae69 | 2266 | default: |
0f40f9f7 | 2267 | return "mov{b}\t{%h1, %0|%0, %h1}"; |
e075ae69 | 2268 | } |
0f40f9f7 | 2269 | } |
e075ae69 RH |
2270 | [(set (attr "type") |
2271 | (if_then_else (and (match_operand:QI 0 "register_operand" "") | |
2272 | (ior (not (match_operand:QI 0 "q_regs_operand" "")) | |
2273 | (ne (symbol_ref "TARGET_MOVX") | |
2274 | (const_int 0)))) | |
2275 | (const_string "imovx") | |
6ef67412 JH |
2276 | (const_string "imov"))) |
2277 | (set (attr "mode") | |
2278 | (if_then_else (eq_attr "type" "imovx") | |
2279 | (const_string "SI") | |
2280 | (const_string "QI")))]) | |
e075ae69 | 2281 | |
d2836273 JH |
2282 | (define_insn "*movqi_extzv_2_rex64" |
2283 | [(set (match_operand:QI 0 "register_operand" "=Q,?R") | |
2284 | (subreg:QI (zero_extract:SI (match_operand 1 "ext_register_operand" "Q,Q") | |
2285 | (const_int 8) | |
2286 | (const_int 8)) 0))] | |
2287 | "TARGET_64BIT" | |
d2836273 JH |
2288 | { |
2289 | switch (get_attr_type (insn)) | |
2290 | { | |
2291 | case TYPE_IMOVX: | |
0f40f9f7 | 2292 | return "movz{bl|x}\t{%h1, %k0|%k0, %h1}"; |
d2836273 | 2293 | default: |
0f40f9f7 | 2294 | return "mov{b}\t{%h1, %0|%0, %h1}"; |
d2836273 | 2295 | } |
0f40f9f7 | 2296 | } |
d2836273 JH |
2297 | [(set (attr "type") |
2298 | (if_then_else (ior (not (match_operand:QI 0 "q_regs_operand" "")) | |
2299 | (ne (symbol_ref "TARGET_MOVX") | |
2300 | (const_int 0))) | |
2301 | (const_string "imovx") | |
2302 | (const_string "imov"))) | |
2303 | (set (attr "mode") | |
2304 | (if_then_else (eq_attr "type" "imovx") | |
2305 | (const_string "SI") | |
2306 | (const_string "QI")))]) | |
2307 | ||
7a2e09f4 | 2308 | (define_insn "movsi_insv_1" |
d2836273 | 2309 | [(set (zero_extract:SI (match_operand 0 "ext_register_operand" "+Q") |
e075ae69 RH |
2310 | (const_int 8) |
2311 | (const_int 8)) | |
f47c8646 | 2312 | (match_operand:SI 1 "general_operand" "Qmn"))] |
d2836273 | 2313 | "!TARGET_64BIT" |
0f40f9f7 | 2314 | "mov{b}\t{%b1, %h0|%h0, %b1}" |
d2836273 JH |
2315 | [(set_attr "type" "imov") |
2316 | (set_attr "mode" "QI")]) | |
2317 | ||
2318 | (define_insn "*movsi_insv_1_rex64" | |
2319 | [(set (zero_extract:SI (match_operand 0 "ext_register_operand" "+Q") | |
2320 | (const_int 8) | |
2321 | (const_int 8)) | |
f47c8646 | 2322 | (match_operand:SI 1 "nonmemory_operand" "Qn"))] |
d2836273 | 2323 | "TARGET_64BIT" |
0f40f9f7 | 2324 | "mov{b}\t{%b1, %h0|%h0, %b1}" |
6ef67412 JH |
2325 | [(set_attr "type" "imov") |
2326 | (set_attr "mode" "QI")]) | |
e075ae69 RH |
2327 | |
2328 | (define_insn "*movqi_insv_2" | |
d2836273 | 2329 | [(set (zero_extract:SI (match_operand 0 "ext_register_operand" "+Q") |
e075ae69 RH |
2330 | (const_int 8) |
2331 | (const_int 8)) | |
3522082b | 2332 | (and:SI (lshiftrt:SI (match_operand:SI 1 "register_operand" "Q") |
e075ae69 RH |
2333 | (const_int 8)) |
2334 | (const_int 255)))] | |
2335 | "" | |
0f40f9f7 | 2336 | "mov{b}\t{%h1, %h0|%h0, %h1}" |
6ef67412 JH |
2337 | [(set_attr "type" "imov") |
2338 | (set_attr "mode" "QI")]) | |
f31fce3f | 2339 | |
e075ae69 | 2340 | (define_expand "movdi" |
4cbfbb1b | 2341 | [(set (match_operand:DI 0 "nonimmediate_operand" "") |
e075ae69 RH |
2342 | (match_operand:DI 1 "general_operand" ""))] |
2343 | "" | |
2344 | "ix86_expand_move (DImode, operands); DONE;") | |
f31fce3f | 2345 | |
e075ae69 RH |
2346 | (define_insn "*pushdi" |
2347 | [(set (match_operand:DI 0 "push_operand" "=<") | |
2c5a510c | 2348 | (match_operand:DI 1 "general_no_elim_operand" "riF*m"))] |
1e07edd3 | 2349 | "!TARGET_64BIT" |
e075ae69 | 2350 | "#") |
f31fce3f | 2351 | |
0ec259ed JH |
2352 | (define_insn "pushdi2_rex64" |
2353 | [(set (match_operand:DI 0 "push_operand" "=<,!<") | |
2354 | (match_operand:DI 1 "general_no_elim_operand" "re*m,n"))] | |
2355 | "TARGET_64BIT" | |
2356 | "@ | |
0f40f9f7 | 2357 | push{q}\t%1 |
0ec259ed JH |
2358 | #" |
2359 | [(set_attr "type" "push,multi") | |
2360 | (set_attr "mode" "DI")]) | |
2361 | ||
2362 | ;; Convert impossible pushes of immediate to existing instructions. | |
f5143c46 | 2363 | ;; First try to get scratch register and go through it. In case this |
0ec259ed JH |
2364 | ;; fails, push sign extended lower part first and then overwrite |
2365 | ;; upper part by 32bit move. | |
2366 | (define_peephole2 | |
2367 | [(match_scratch:DI 2 "r") | |
2368 | (set (match_operand:DI 0 "push_operand" "") | |
2369 | (match_operand:DI 1 "immediate_operand" ""))] | |
2370 | "TARGET_64BIT && !symbolic_operand (operands[1], DImode) | |
2371 | && !x86_64_immediate_operand (operands[1], DImode)" | |
2372 | [(set (match_dup 2) (match_dup 1)) | |
2373 | (set (match_dup 0) (match_dup 2))] | |
2374 | "") | |
2375 | ||
2376 | ;; We need to define this as both peepholer and splitter for case | |
2377 | ;; peephole2 pass is not run. | |
2378 | (define_peephole2 | |
2379 | [(set (match_operand:DI 0 "push_operand" "") | |
2380 | (match_operand:DI 1 "immediate_operand" ""))] | |
2381 | "TARGET_64BIT && !symbolic_operand (operands[1], DImode) | |
2382 | && !x86_64_immediate_operand (operands[1], DImode) && 1" | |
2383 | [(set (match_dup 0) (match_dup 1)) | |
2384 | (set (match_dup 2) (match_dup 3))] | |
2385 | "split_di (operands + 1, 1, operands + 2, operands + 3); | |
2386 | operands[1] = gen_lowpart (DImode, operands[2]); | |
2387 | operands[2] = gen_rtx_MEM (SImode, gen_rtx_PLUS (DImode, stack_pointer_rtx, | |
2388 | GEN_INT (4))); | |
2389 | ") | |
2390 | ||
2391 | (define_split | |
2392 | [(set (match_operand:DI 0 "push_operand" "") | |
2393 | (match_operand:DI 1 "immediate_operand" ""))] | |
2394 | "TARGET_64BIT && (flow2_completed || (reload_completed && !flag_peephole2)) | |
2395 | && !symbolic_operand (operands[1], DImode) | |
2396 | && !x86_64_immediate_operand (operands[1], DImode)" | |
2397 | [(set (match_dup 0) (match_dup 1)) | |
2398 | (set (match_dup 2) (match_dup 3))] | |
2399 | "split_di (operands + 1, 1, operands + 2, operands + 3); | |
2400 | operands[1] = gen_lowpart (DImode, operands[2]); | |
2401 | operands[2] = gen_rtx_MEM (SImode, gen_rtx_PLUS (DImode, stack_pointer_rtx, | |
2402 | GEN_INT (4))); | |
2403 | ") | |
2404 | ||
2405 | (define_insn "*pushdi2_prologue_rex64" | |
2406 | [(set (match_operand:DI 0 "push_operand" "=<") | |
2407 | (match_operand:DI 1 "general_no_elim_operand" "re*m")) | |
f2042df3 | 2408 | (clobber (mem:BLK (scratch)))] |
0ec259ed | 2409 | "TARGET_64BIT" |
0f40f9f7 | 2410 | "push{q}\t%1" |
0ec259ed JH |
2411 | [(set_attr "type" "push") |
2412 | (set_attr "mode" "DI")]) | |
2413 | ||
2414 | (define_insn "*popdi1_epilogue_rex64" | |
2415 | [(set (match_operand:DI 0 "nonimmediate_operand" "=r*m") | |
2416 | (mem:DI (reg:DI 7))) | |
2417 | (set (reg:DI 7) | |
2418 | (plus:DI (reg:DI 7) (const_int 8))) | |
f2042df3 | 2419 | (clobber (mem:BLK (scratch)))] |
0ec259ed | 2420 | "TARGET_64BIT" |
0f40f9f7 | 2421 | "pop{q}\t%0" |
0ec259ed JH |
2422 | [(set_attr "type" "pop") |
2423 | (set_attr "mode" "DI")]) | |
2424 | ||
2425 | (define_insn "popdi1" | |
2426 | [(set (match_operand:DI 0 "nonimmediate_operand" "=r*m") | |
2427 | (mem:DI (reg:DI 7))) | |
2428 | (set (reg:DI 7) | |
2429 | (plus:DI (reg:DI 7) (const_int 8)))] | |
2430 | "TARGET_64BIT" | |
0f40f9f7 | 2431 | "pop{q}\t%0" |
0ec259ed JH |
2432 | [(set_attr "type" "pop") |
2433 | (set_attr "mode" "DI")]) | |
2434 | ||
2435 | (define_insn "*movdi_xor_rex64" | |
2436 | [(set (match_operand:DI 0 "register_operand" "=r") | |
2437 | (match_operand:DI 1 "const0_operand" "i")) | |
2438 | (clobber (reg:CC 17))] | |
1b0c37d7 ZW |
2439 | "TARGET_64BIT && (!TARGET_USE_MOV0 || optimize_size) |
2440 | && reload_completed" | |
0f40f9f7 | 2441 | "xor{l}\t{%k0, %k0|%k0, %k0}" |
0ec259ed JH |
2442 | [(set_attr "type" "alu1") |
2443 | (set_attr "mode" "SI") | |
2444 | (set_attr "length_immediate" "0")]) | |
2445 | ||
2446 | (define_insn "*movdi_or_rex64" | |
2447 | [(set (match_operand:DI 0 "register_operand" "=r") | |
2448 | (match_operand:DI 1 "const_int_operand" "i")) | |
2449 | (clobber (reg:CC 17))] | |
1b0c37d7 ZW |
2450 | "TARGET_64BIT && (TARGET_PENTIUM || optimize_size) |
2451 | && reload_completed | |
2452 | && GET_CODE (operands[1]) == CONST_INT | |
2453 | && INTVAL (operands[1]) == -1" | |
0ec259ed JH |
2454 | { |
2455 | operands[1] = constm1_rtx; | |
0f40f9f7 ZW |
2456 | return "or{q}\t{%1, %0|%0, %1}"; |
2457 | } | |
0ec259ed JH |
2458 | [(set_attr "type" "alu1") |
2459 | (set_attr "mode" "DI") | |
2460 | (set_attr "length_immediate" "1")]) | |
2461 | ||
e075ae69 | 2462 | (define_insn "*movdi_2" |
141e454b JH |
2463 | [(set (match_operand:DI 0 "nonimmediate_operand" "=r,o,!m*y,!*y,!m,*Y,!*Y") |
2464 | (match_operand:DI 1 "general_operand" "riFo,riF,*y,m,*Y,*Y,m"))] | |
1e07edd3 JH |
2465 | "!TARGET_64BIT |
2466 | && (GET_CODE (operands[0]) != MEM || GET_CODE (operands[1]) != MEM)" | |
915119a5 BS |
2467 | "@ |
2468 | # | |
2469 | # | |
0f40f9f7 ZW |
2470 | movq\t{%1, %0|%0, %1} |
2471 | movq\t{%1, %0|%0, %1} | |
2472 | movq\t{%1, %0|%0, %1} | |
2473 | movdqa\t{%1, %0|%0, %1} | |
2474 | movq\t{%1, %0|%0, %1}" | |
141e454b JH |
2475 | [(set_attr "type" "*,*,mmx,mmx,sse,sse,sse") |
2476 | (set_attr "mode" "DI,DI,DI,DI,DI,TI,DI")]) | |
dc0f0eb8 | 2477 | |
e075ae69 RH |
2478 | (define_split |
2479 | [(set (match_operand:DI 0 "push_operand" "") | |
2480 | (match_operand:DI 1 "general_operand" ""))] | |
6c12e488 JH |
2481 | "!TARGET_64BIT && reload_completed |
2482 | && (! MMX_REG_P (operands[1]) && !SSE_REG_P (operands[1]))" | |
2450a057 | 2483 | [(const_int 0)] |
26e5b205 | 2484 | "ix86_split_long_move (operands); DONE;") |
f31fce3f | 2485 | |
e075ae69 | 2486 | ;; %%% This multiword shite has got to go. |
e075ae69 | 2487 | (define_split |
c76aab11 | 2488 | [(set (match_operand:DI 0 "nonimmediate_operand" "") |
e075ae69 | 2489 | (match_operand:DI 1 "general_operand" ""))] |
6c12e488 JH |
2490 | "!TARGET_64BIT && reload_completed |
2491 | && (!MMX_REG_P (operands[0]) && !SSE_REG_P (operands[0])) | |
2492 | && (!MMX_REG_P (operands[1]) && !SSE_REG_P (operands[1]))" | |
26e5b205 JH |
2493 | [(const_int 0)] |
2494 | "ix86_split_long_move (operands); DONE;") | |
0ec259ed JH |
2495 | |
2496 | (define_insn "*movdi_1_rex64" | |
141e454b JH |
2497 | [(set (match_operand:DI 0 "nonimmediate_operand" "=r,r,r,mr,!mr,!m*y,!*y,!*Y,!m,!*Y") |
2498 | (match_operand:DI 1 "general_operand" "Z,rem,i,re,n,*y,m,*Y,*Y,*m"))] | |
1b0c37d7 ZW |
2499 | "TARGET_64BIT |
2500 | && (GET_CODE (operands[0]) != MEM || GET_CODE (operands[1]) != MEM)" | |
0ec259ed JH |
2501 | { |
2502 | switch (get_attr_type (insn)) | |
2503 | { | |
2504 | case TYPE_SSE: | |
141e454b JH |
2505 | if (register_operand (operands[0], DImode) |
2506 | && register_operand (operands[1], DImode)) | |
0f40f9f7 | 2507 | return "movdqa\t{%1, %0|%0, %1}"; |
141e454b | 2508 | /* FALLTHRU */ |
0ec259ed | 2509 | case TYPE_MMX: |
0f40f9f7 | 2510 | return "movq\t{%1, %0|%0, %1}"; |
0ec259ed | 2511 | case TYPE_MULTI: |
0f40f9f7 | 2512 | return "#"; |
0ec259ed | 2513 | case TYPE_LEA: |
0f40f9f7 | 2514 | return "lea{q}\t{%a1, %0|%0, %a1}"; |
0ec259ed JH |
2515 | default: |
2516 | if (flag_pic && SYMBOLIC_CONST (operands[1])) | |
2517 | abort (); | |
2518 | if (get_attr_mode (insn) == MODE_SI) | |
0f40f9f7 | 2519 | return "mov{l}\t{%k1, %k0|%k0, %k1}"; |
0ec259ed | 2520 | else if (which_alternative == 2) |
0f40f9f7 | 2521 | return "movabs{q}\t{%1, %0|%0, %1}"; |
0ec259ed | 2522 | else |
0f40f9f7 | 2523 | return "mov{q}\t{%1, %0|%0, %1}"; |
0ec259ed | 2524 | } |
0f40f9f7 | 2525 | } |
0ec259ed JH |
2526 | [(set (attr "type") |
2527 | (cond [(eq_attr "alternative" "5,6") | |
2528 | (const_string "mmx") | |
2529 | (eq_attr "alternative" "7,8") | |
2530 | (const_string "sse") | |
2531 | (eq_attr "alternative" "4") | |
2532 | (const_string "multi") | |
2533 | (and (ne (symbol_ref "flag_pic") (const_int 0)) | |
2534 | (match_operand:DI 1 "symbolic_operand" "")) | |
2535 | (const_string "lea") | |
2536 | ] | |
2537 | (const_string "imov"))) | |
141e454b JH |
2538 | (set_attr "modrm" "*,0,0,*,*,*,*,*,*,*") |
2539 | (set_attr "length_immediate" "*,4,8,*,*,*,*,*,*,*") | |
2540 | (set_attr "mode" "SI,DI,DI,DI,SI,DI,DI,DI,TI,DI")]) | |
0ec259ed JH |
2541 | |
2542 | ;; Stores and loads of ax to arbitary constant address. | |
2543 | ;; We fake an second form of instruction to force reload to load address | |
2544 | ;; into register when rax is not available | |
2545 | (define_insn "*movabsdi_1_rex64" | |
2546 | [(set (mem:DI (match_operand:DI 0 "x86_64_movabs_operand" "i,r,r")) | |
2547 | (match_operand:DI 1 "nonmemory_operand" "a,er,i"))] | |
2548 | "TARGET_64BIT" | |
2549 | "@ | |
0f40f9f7 ZW |
2550 | movabs{q}\t{%1, %P0|%P0, %1} |
2551 | mov{q}\t{%1, %a0|%a0, %1} | |
2552 | movabs{q}\t{%1, %a0|%a0, %1}" | |
0ec259ed JH |
2553 | [(set_attr "type" "imov") |
2554 | (set_attr "modrm" "0,*,*") | |
2555 | (set_attr "length_address" "8,0,0") | |
2556 | (set_attr "length_immediate" "0,*,*") | |
2557 | (set_attr "memory" "store") | |
2558 | (set_attr "mode" "DI")]) | |
2559 | ||
2560 | (define_insn "*movabsdi_2_rex64" | |
2561 | [(set (match_operand:DI 0 "register_operand" "=a,r") | |
2562 | (mem:DI (match_operand:DI 1 "x86_64_movabs_operand" "i,r")))] | |
2563 | "TARGET_64BIT" | |
2564 | "@ | |
0f40f9f7 ZW |
2565 | movabs{q}\t{%P1, %0|%0, %P1} |
2566 | mov{q}\t{%a1, %0|%0, %a1}" | |
0ec259ed JH |
2567 | [(set_attr "type" "imov") |
2568 | (set_attr "modrm" "0,*") | |
2569 | (set_attr "length_address" "8,0") | |
2570 | (set_attr "length_immediate" "0") | |
2571 | (set_attr "memory" "load") | |
2572 | (set_attr "mode" "DI")]) | |
2573 | ||
2574 | ;; Convert impossible stores of immediate to existing instructions. | |
f5143c46 | 2575 | ;; First try to get scratch register and go through it. In case this |
0ec259ed JH |
2576 | ;; fails, move by 32bit parts. |
2577 | (define_peephole2 | |
2578 | [(match_scratch:DI 2 "r") | |
2579 | (set (match_operand:DI 0 "memory_operand" "") | |
2580 | (match_operand:DI 1 "immediate_operand" ""))] | |
2581 | "TARGET_64BIT && !symbolic_operand (operands[1], DImode) | |
2582 | && !x86_64_immediate_operand (operands[1], DImode)" | |
2583 | [(set (match_dup 2) (match_dup 1)) | |
2584 | (set (match_dup 0) (match_dup 2))] | |
2585 | "") | |
2586 | ||
2587 | ;; We need to define this as both peepholer and splitter for case | |
2588 | ;; peephole2 pass is not run. | |
2589 | (define_peephole2 | |
2590 | [(set (match_operand:DI 0 "memory_operand" "") | |
2591 | (match_operand:DI 1 "immediate_operand" ""))] | |
2592 | "TARGET_64BIT && !symbolic_operand (operands[1], DImode) | |
2593 | && !x86_64_immediate_operand (operands[1], DImode) && 1" | |
2594 | [(set (match_dup 2) (match_dup 3)) | |
2595 | (set (match_dup 4) (match_dup 5))] | |
2596 | "split_di (operands, 2, operands + 2, operands + 4);") | |
2597 | ||
2598 | (define_split | |
2599 | [(set (match_operand:DI 0 "memory_operand" "") | |
2600 | (match_operand:DI 1 "immediate_operand" ""))] | |
2601 | "TARGET_64BIT && (flow2_completed || (reload_completed && !flag_peephole2)) | |
2602 | && !symbolic_operand (operands[1], DImode) | |
2603 | && !x86_64_immediate_operand (operands[1], DImode)" | |
2604 | [(set (match_dup 2) (match_dup 3)) | |
2605 | (set (match_dup 4) (match_dup 5))] | |
2606 | "split_di (operands, 2, operands + 2, operands + 4);") | |
2607 | ||
2608 | (define_insn "*swapdi_rex64" | |
2609 | [(set (match_operand:DI 0 "register_operand" "+r") | |
2610 | (match_operand:DI 1 "register_operand" "+r")) | |
2611 | (set (match_dup 1) | |
2612 | (match_dup 0))] | |
2613 | "TARGET_64BIT" | |
0f40f9f7 | 2614 | "xchg{q}\t%1, %0" |
0ec259ed JH |
2615 | [(set_attr "type" "imov") |
2616 | (set_attr "pent_pair" "np") | |
2617 | (set_attr "athlon_decode" "vector") | |
2618 | (set_attr "mode" "DI") | |
2619 | (set_attr "modrm" "0") | |
2620 | (set_attr "ppro_uops" "few")]) | |
2621 | ||
e075ae69 | 2622 | |
0be5d99f | 2623 | (define_expand "movsf" |
4cbfbb1b | 2624 | [(set (match_operand:SF 0 "nonimmediate_operand" "") |
0be5d99f MM |
2625 | (match_operand:SF 1 "general_operand" ""))] |
2626 | "" | |
e075ae69 RH |
2627 | "ix86_expand_move (SFmode, operands); DONE;") |
2628 | ||
2629 | (define_insn "*pushsf" | |
446988df | 2630 | [(set (match_operand:SF 0 "push_operand" "=<,<,<") |
c6e95f34 | 2631 | (match_operand:SF 1 "general_no_elim_operand" "f#rx,rFm#fx,x#rf"))] |
0ec259ed | 2632 | "!TARGET_64BIT" |
0be5d99f | 2633 | { |
e075ae69 | 2634 | switch (which_alternative) |
0be5d99f | 2635 | { |
e075ae69 RH |
2636 | case 0: |
2637 | /* %%% We loose REG_DEAD notes for controling pops if we split late. */ | |
2638 | operands[0] = gen_rtx_MEM (SFmode, stack_pointer_rtx); | |
2639 | operands[2] = stack_pointer_rtx; | |
2640 | operands[3] = GEN_INT (4); | |
2641 | if (find_regno_note (insn, REG_DEAD, REGNO (operands[1]))) | |
0f40f9f7 | 2642 | return "sub{l}\t{%3, %2|%2, %3}\;fstp%z0\t%y0"; |
e075ae69 | 2643 | else |
0f40f9f7 | 2644 | return "sub{l}\t{%3, %2|%2, %3}\;fst%z0\t%y0"; |
0bb6c81b | 2645 | |
e075ae69 | 2646 | case 1: |
0f40f9f7 | 2647 | return "push{l}\t%1"; |
446988df | 2648 | case 2: |
0f40f9f7 | 2649 | return "#"; |
e075ae69 RH |
2650 | |
2651 | default: | |
2652 | abort (); | |
0bb6c81b | 2653 | } |
0f40f9f7 | 2654 | } |
446988df JH |
2655 | [(set_attr "type" "multi,push,multi") |
2656 | (set_attr "mode" "SF,SI,SF")]) | |
0be5d99f | 2657 | |
0ec259ed JH |
2658 | (define_insn "*pushsf_rex64" |
2659 | [(set (match_operand:SF 0 "push_operand" "=X,X,X") | |
2660 | (match_operand:SF 1 "nonmemory_no_elim_operand" "f#rx,rF#fx,x#rf"))] | |
2661 | "TARGET_64BIT" | |
0ec259ed JH |
2662 | { |
2663 | switch (which_alternative) | |
2664 | { | |
2665 | case 0: | |
2666 | /* %%% We loose REG_DEAD notes for controling pops if we split late. */ | |
2667 | operands[0] = gen_rtx_MEM (SFmode, stack_pointer_rtx); | |
2668 | operands[2] = stack_pointer_rtx; | |
2669 | operands[3] = GEN_INT (8); | |
2670 | if (find_regno_note (insn, REG_DEAD, REGNO (operands[1]))) | |
0f40f9f7 | 2671 | return "sub{q}\t{%3, %2|%2, %3}\;fstp%z0\t%y0"; |
0ec259ed | 2672 | else |
0f40f9f7 | 2673 | return "sub{q}\t{%3, %2|%2, %3}\;fst%z0\t%y0"; |
0ec259ed JH |
2674 | |
2675 | case 1: | |
0f40f9f7 | 2676 | return "push{q}\t%q1"; |
0ec259ed JH |
2677 | |
2678 | case 2: | |
0f40f9f7 | 2679 | return "#"; |
0ec259ed JH |
2680 | |
2681 | default: | |
2682 | abort (); | |
2683 | } | |
0f40f9f7 | 2684 | } |
0ec259ed JH |
2685 | [(set_attr "type" "multi,push,multi") |
2686 | (set_attr "mode" "SF,DI,SF")]) | |
2687 | ||
d7a29404 JH |
2688 | (define_split |
2689 | [(set (match_operand:SF 0 "push_operand" "") | |
2690 | (match_operand:SF 1 "memory_operand" ""))] | |
2691 | "reload_completed | |
2692 | && GET_CODE (operands[1]) == MEM | |
2693 | && GET_CODE (XEXP (operands[1], 0)) == SYMBOL_REF | |
2694 | && CONSTANT_POOL_ADDRESS_P (XEXP (operands[1], 0))" | |
2695 | [(set (match_dup 0) | |
2696 | (match_dup 1))] | |
2697 | "operands[1] = get_pool_constant (XEXP (operands[1], 0));") | |
2698 | ||
2699 | ||
e075ae69 RH |
2700 | ;; %%% Kill this when call knows how to work this out. |
2701 | (define_split | |
2702 | [(set (match_operand:SF 0 "push_operand" "") | |
2703 | (match_operand:SF 1 "register_operand" ""))] | |
0ec259ed | 2704 | "!TARGET_64BIT && ANY_FP_REGNO_P (REGNO (operands[1]))" |
e075ae69 RH |
2705 | [(set (reg:SI 7) (plus:SI (reg:SI 7) (const_int -4))) |
2706 | (set (mem:SF (reg:SI 7)) (match_dup 1))]) | |
2707 | ||
0ec259ed JH |
2708 | (define_split |
2709 | [(set (match_operand:SF 0 "push_operand" "") | |
2710 | (match_operand:SF 1 "register_operand" ""))] | |
2711 | "TARGET_64BIT && ANY_FP_REGNO_P (REGNO (operands[1]))" | |
2712 | [(set (reg:DI 7) (plus:DI (reg:DI 7) (const_int -8))) | |
2713 | (set (mem:SF (reg:DI 7)) (match_dup 1))]) | |
2714 | ||
e075ae69 | 2715 | (define_insn "*movsf_1" |
2b04e52b JH |
2716 | [(set (match_operand:SF 0 "nonimmediate_operand" "=f#xr,m,f#xr,r#xf,m,x#rf,x#rf,x#rf,m") |
2717 | (match_operand:SF 1 "general_operand" "fm#rx,f#rx,G,rmF#fx,Fr#fx,H,x,xm#rf,x#rf"))] | |
d7a29404 JH |
2718 | "(GET_CODE (operands[0]) != MEM || GET_CODE (operands[1]) != MEM) |
2719 | && (reload_in_progress || reload_completed | |
3987b9db | 2720 | || (ix86_cmodel == CM_MEDIUM || ix86_cmodel == CM_LARGE) |
d7a29404 JH |
2721 | || GET_CODE (operands[1]) != CONST_DOUBLE |
2722 | || memory_operand (operands[0], SFmode))" | |
886c62d1 | 2723 | { |
e075ae69 | 2724 | switch (which_alternative) |
886c62d1 | 2725 | { |
e075ae69 | 2726 | case 0: |
0c174a68 AB |
2727 | if (REG_P (operands[1]) |
2728 | && find_regno_note (insn, REG_DEAD, REGNO (operands[1]))) | |
0f40f9f7 | 2729 | return "fstp\t%y0"; |
e075ae69 | 2730 | else if (STACK_TOP_P (operands[0])) |
0f40f9f7 | 2731 | return "fld%z1\t%y1"; |
886c62d1 | 2732 | else |
0f40f9f7 | 2733 | return "fst\t%y0"; |
886c62d1 | 2734 | |
e075ae69 RH |
2735 | case 1: |
2736 | if (find_regno_note (insn, REG_DEAD, REGNO (operands[1]))) | |
0f40f9f7 | 2737 | return "fstp%z0\t%y0"; |
886c62d1 | 2738 | else |
0f40f9f7 | 2739 | return "fst%z0\t%y0"; |
886c62d1 | 2740 | |
e075ae69 RH |
2741 | case 2: |
2742 | switch (standard_80387_constant_p (operands[1])) | |
2743 | { | |
2744 | case 1: | |
0f40f9f7 | 2745 | return "fldz"; |
e075ae69 | 2746 | case 2: |
0f40f9f7 | 2747 | return "fld1"; |
e075ae69 RH |
2748 | } |
2749 | abort(); | |
886c62d1 | 2750 | |
e075ae69 RH |
2751 | case 3: |
2752 | case 4: | |
0f40f9f7 | 2753 | return "mov{l}\t{%1, %0|%0, %1}"; |
446988df | 2754 | case 5: |
0f40f9f7 | 2755 | return "pxor\t%0, %0"; |
446988df | 2756 | case 6: |
2b04e52b | 2757 | if (TARGET_PARTIAL_REG_DEPENDENCY) |
0f40f9f7 | 2758 | return "movaps\t{%1, %0|%0, %1}"; |
2b04e52b | 2759 | else |
0f40f9f7 | 2760 | return "movss\t{%1, %0|%0, %1}"; |
2b04e52b JH |
2761 | case 7: |
2762 | case 8: | |
0f40f9f7 | 2763 | return "movss\t{%1, %0|%0, %1}"; |
886c62d1 | 2764 | |
e075ae69 RH |
2765 | default: |
2766 | abort(); | |
2767 | } | |
0f40f9f7 | 2768 | } |
2b04e52b JH |
2769 | [(set_attr "type" "fmov,fmov,fmov,imov,imov,sse,sse,sse,sse") |
2770 | (set_attr "mode" "SF,SF,SF,SI,SI,TI,SF,SF,SF")]) | |
d7a29404 | 2771 | |
a4414093 | 2772 | (define_insn "*swapsf" |
e075ae69 RH |
2773 | [(set (match_operand:SF 0 "register_operand" "+f") |
2774 | (match_operand:SF 1 "register_operand" "+f")) | |
0be5d99f MM |
2775 | (set (match_dup 1) |
2776 | (match_dup 0))] | |
965f5423 | 2777 | "reload_completed || !TARGET_SSE" |
0be5d99f MM |
2778 | { |
2779 | if (STACK_TOP_P (operands[0])) | |
0f40f9f7 | 2780 | return "fxch\t%1"; |
0be5d99f | 2781 | else |
0f40f9f7 ZW |
2782 | return "fxch\t%0"; |
2783 | } | |
6ef67412 JH |
2784 | [(set_attr "type" "fxch") |
2785 | (set_attr "mode" "SF")]) | |
0be5d99f | 2786 | |
e075ae69 | 2787 | (define_expand "movdf" |
4cbfbb1b | 2788 | [(set (match_operand:DF 0 "nonimmediate_operand" "") |
e075ae69 RH |
2789 | (match_operand:DF 1 "general_operand" ""))] |
2790 | "" | |
2791 | "ix86_expand_move (DFmode, operands); DONE;") | |
55953cea | 2792 | |
8fcaaa80 JH |
2793 | ;; Size of pushdf is 3 (for sub) + 2 (for fstp) + memory operand size. |
2794 | ;; Size of pushdf using integer insturctions is 2+2*memory operand size | |
2795 | ;; On the average, pushdf using integers can be still shorter. Allow this | |
2796 | ;; pattern for optimize_size too. | |
2797 | ||
0b5107cf | 2798 | (define_insn "*pushdf_nointeger" |
446988df | 2799 | [(set (match_operand:DF 0 "push_operand" "=<,<,<,<") |
c6e95f34 | 2800 | (match_operand:DF 1 "general_no_elim_operand" "f#Y,Fo#fY,*r#fY,Y#f"))] |
0ec259ed | 2801 | "!TARGET_64BIT && !TARGET_INTEGER_DFMODE_MOVES" |
0b5107cf JH |
2802 | { |
2803 | switch (which_alternative) | |
2804 | { | |
2805 | case 0: | |
2806 | /* %%% We loose REG_DEAD notes for controling pops if we split late. */ | |
2807 | operands[0] = gen_rtx_MEM (DFmode, stack_pointer_rtx); | |
2808 | operands[2] = stack_pointer_rtx; | |
2809 | operands[3] = GEN_INT (8); | |
2810 | if (find_regno_note (insn, REG_DEAD, REGNO (operands[1]))) | |
0f40f9f7 | 2811 | return "sub{l}\t{%3, %2|%2, %3}\;fstp%z0\t%y0"; |
0b5107cf | 2812 | else |
0f40f9f7 | 2813 | return "sub{l}\t{%3, %2|%2, %3}\;fst%z0\t%y0"; |
0b5107cf JH |
2814 | |
2815 | case 1: | |
2816 | case 2: | |
446988df | 2817 | case 3: |
0f40f9f7 | 2818 | return "#"; |
0b5107cf JH |
2819 | |
2820 | default: | |
2821 | abort (); | |
2822 | } | |
0f40f9f7 | 2823 | } |
6ef67412 | 2824 | [(set_attr "type" "multi") |
446988df | 2825 | (set_attr "mode" "DF,SI,SI,DF")]) |
0b5107cf JH |
2826 | |
2827 | (define_insn "*pushdf_integer" | |
446988df JH |
2828 | [(set (match_operand:DF 0 "push_operand" "=<,<,<") |
2829 | (match_operand:DF 1 "general_no_elim_operand" "f#rY,rFo#fY,Y#rf"))] | |
0ec259ed | 2830 | "TARGET_64BIT || TARGET_INTEGER_DFMODE_MOVES" |
f31fce3f | 2831 | { |
e075ae69 | 2832 | switch (which_alternative) |
f31fce3f | 2833 | { |
e075ae69 RH |
2834 | case 0: |
2835 | /* %%% We loose REG_DEAD notes for controling pops if we split late. */ | |
2836 | operands[0] = gen_rtx_MEM (DFmode, stack_pointer_rtx); | |
2837 | operands[2] = stack_pointer_rtx; | |
2838 | operands[3] = GEN_INT (8); | |
0ec259ed JH |
2839 | if (TARGET_64BIT) |
2840 | if (find_regno_note (insn, REG_DEAD, REGNO (operands[1]))) | |
0f40f9f7 | 2841 | return "sub{q}\t{%3, %2|%2, %3}\;fstp%z0\t%y0"; |
0ec259ed | 2842 | else |
0f40f9f7 | 2843 | return "sub{q}\t{%3, %2|%2, %3}\;fst%z0\t%y0"; |
f31fce3f | 2844 | else |
0ec259ed | 2845 | if (find_regno_note (insn, REG_DEAD, REGNO (operands[1]))) |
0f40f9f7 | 2846 | return "sub{l}\t{%3, %2|%2, %3}\;fstp%z0\t%y0"; |
0ec259ed | 2847 | else |
0f40f9f7 | 2848 | return "sub{l}\t{%3, %2|%2, %3}\;fst%z0\t%y0"; |
0ec259ed | 2849 | |
dc0f0eb8 | 2850 | |
e075ae69 | 2851 | case 1: |
446988df | 2852 | case 2: |
0f40f9f7 | 2853 | return "#"; |
dc0f0eb8 | 2854 | |
e075ae69 RH |
2855 | default: |
2856 | abort (); | |
2857 | } | |
0f40f9f7 | 2858 | } |
6ef67412 | 2859 | [(set_attr "type" "multi") |
446988df | 2860 | (set_attr "mode" "DF,SI,DF")]) |
f31fce3f | 2861 | |
e075ae69 | 2862 | ;; %%% Kill this when call knows how to work this out. |
f72b27a5 JH |
2863 | (define_split |
2864 | [(set (match_operand:DF 0 "push_operand" "") | |
e075ae69 | 2865 | (match_operand:DF 1 "register_operand" ""))] |
0ec259ed | 2866 | "!TARGET_64BIT && reload_completed && ANY_FP_REGNO_P (REGNO (operands[1]))" |
e075ae69 RH |
2867 | [(set (reg:SI 7) (plus:SI (reg:SI 7) (const_int -8))) |
2868 | (set (mem:DF (reg:SI 7)) (match_dup 1))] | |
f72b27a5 | 2869 | "") |
f31fce3f | 2870 | |
0ec259ed JH |
2871 | (define_split |
2872 | [(set (match_operand:DF 0 "push_operand" "") | |
2873 | (match_operand:DF 1 "register_operand" ""))] | |
2874 | "TARGET_64BIT && reload_completed && ANY_FP_REGNO_P (REGNO (operands[1]))" | |
2875 | [(set (reg:DI 7) (plus:DI (reg:DI 7) (const_int -8))) | |
2876 | (set (mem:DF (reg:DI 7)) (match_dup 1))] | |
2877 | "") | |
2878 | ||
e075ae69 RH |
2879 | (define_split |
2880 | [(set (match_operand:DF 0 "push_operand" "") | |
0be5d99f | 2881 | (match_operand:DF 1 "general_operand" ""))] |
e075ae69 | 2882 | "reload_completed" |
2450a057 | 2883 | [(const_int 0)] |
26e5b205 | 2884 | "ix86_split_long_move (operands); DONE;") |
0be5d99f | 2885 | |
8fcaaa80 JH |
2886 | ;; Moving is usually shorter when only FP registers are used. This separate |
2887 | ;; movdf pattern avoids the use of integer registers for FP operations | |
2888 | ;; when optimizing for size. | |
2889 | ||
2890 | (define_insn "*movdf_nointeger" | |
2b04e52b JH |
2891 | [(set (match_operand:DF 0 "nonimmediate_operand" "=f#Y,m,f#Y,*r,o,Y#f,Y#f,Y#f,m") |
2892 | (match_operand:DF 1 "general_operand" "fm#Y,f#Y,G,*roF,F*r,H,Y#f,YHm#f,Y#f"))] | |
8fcaaa80 | 2893 | "(GET_CODE (operands[0]) != MEM || GET_CODE (operands[1]) != MEM) |
0b5107cf | 2894 | && (optimize_size || !TARGET_INTEGER_DFMODE_MOVES) |
d7a29404 | 2895 | && (reload_in_progress || reload_completed |
3987b9db | 2896 | || (ix86_cmodel == CM_MEDIUM || ix86_cmodel == CM_LARGE) |
d7a29404 JH |
2897 | || GET_CODE (operands[1]) != CONST_DOUBLE |
2898 | || memory_operand (operands[0], DFmode))" | |
8fcaaa80 JH |
2899 | { |
2900 | switch (which_alternative) | |
2901 | { | |
2902 | case 0: | |
2903 | if (REG_P (operands[1]) | |
2904 | && find_regno_note (insn, REG_DEAD, REGNO (operands[1]))) | |
0f40f9f7 | 2905 | return "fstp\t%y0"; |
8fcaaa80 | 2906 | else if (STACK_TOP_P (operands[0])) |
0f40f9f7 | 2907 | return "fld%z1\t%y1"; |
8fcaaa80 | 2908 | else |
0f40f9f7 | 2909 | return "fst\t%y0"; |
8fcaaa80 JH |
2910 | |
2911 | case 1: | |
2912 | if (find_regno_note (insn, REG_DEAD, REGNO (operands[1]))) | |
0f40f9f7 | 2913 | return "fstp%z0\t%y0"; |
8fcaaa80 | 2914 | else |
0f40f9f7 | 2915 | return "fst%z0\t%y0"; |
8fcaaa80 JH |
2916 | |
2917 | case 2: | |
2918 | switch (standard_80387_constant_p (operands[1])) | |
2919 | { | |
2920 | case 1: | |
0f40f9f7 | 2921 | return "fldz"; |
8fcaaa80 | 2922 | case 2: |
0f40f9f7 | 2923 | return "fld1"; |
8fcaaa80 JH |
2924 | } |
2925 | abort(); | |
2926 | ||
2927 | case 3: | |
2928 | case 4: | |
0f40f9f7 | 2929 | return "#"; |
446988df | 2930 | case 5: |
0f40f9f7 | 2931 | return "pxor\t%0, %0"; |
446988df | 2932 | case 6: |
2b04e52b | 2933 | if (TARGET_PARTIAL_REG_DEPENDENCY) |
0f40f9f7 | 2934 | return "movapd\t{%1, %0|%0, %1}"; |
2b04e52b | 2935 | else |
0f40f9f7 | 2936 | return "movsd\t{%1, %0|%0, %1}"; |
2b04e52b JH |
2937 | case 7: |
2938 | case 8: | |
0f40f9f7 | 2939 | return "movsd\t{%1, %0|%0, %1}"; |
8fcaaa80 JH |
2940 | |
2941 | default: | |
2942 | abort(); | |
2943 | } | |
0f40f9f7 | 2944 | } |
2b04e52b JH |
2945 | [(set_attr "type" "fmov,fmov,fmov,multi,multi,sse,sse,sse,sse") |
2946 | (set_attr "mode" "DF,DF,DF,SI,SI,TI,DF,DF,DF")]) | |
8fcaaa80 JH |
2947 | |
2948 | (define_insn "*movdf_integer" | |
2b04e52b JH |
2949 | [(set (match_operand:DF 0 "nonimmediate_operand" "=f#Yr,m,f#Yr,r#Yf,o,Y#rf,Y#rf,Y#rf,m") |
2950 | (match_operand:DF 1 "general_operand" "fm#Yr,f#Yr,G,roF#Yf,Fr#Yf,H,Y#rf,Ym#rf,Y#rf"))] | |
8fcaaa80 | 2951 | "(GET_CODE (operands[0]) != MEM || GET_CODE (operands[1]) != MEM) |
0b5107cf | 2952 | && !optimize_size && TARGET_INTEGER_DFMODE_MOVES |
d7a29404 | 2953 | && (reload_in_progress || reload_completed |
3987b9db | 2954 | || (ix86_cmodel == CM_MEDIUM || ix86_cmodel == CM_LARGE) |
d7a29404 JH |
2955 | || GET_CODE (operands[1]) != CONST_DOUBLE |
2956 | || memory_operand (operands[0], DFmode))" | |
886c62d1 | 2957 | { |
e075ae69 | 2958 | switch (which_alternative) |
886c62d1 | 2959 | { |
e075ae69 | 2960 | case 0: |
0c174a68 AB |
2961 | if (REG_P (operands[1]) |
2962 | && find_regno_note (insn, REG_DEAD, REGNO (operands[1]))) | |
0f40f9f7 | 2963 | return "fstp\t%y0"; |
e075ae69 | 2964 | else if (STACK_TOP_P (operands[0])) |
0f40f9f7 | 2965 | return "fld%z1\t%y1"; |
886c62d1 | 2966 | else |
0f40f9f7 | 2967 | return "fst\t%y0"; |
886c62d1 | 2968 | |
e075ae69 RH |
2969 | case 1: |
2970 | if (find_regno_note (insn, REG_DEAD, REGNO (operands[1]))) | |
0f40f9f7 | 2971 | return "fstp%z0\t%y0"; |
886c62d1 | 2972 | else |
0f40f9f7 | 2973 | return "fst%z0\t%y0"; |
886c62d1 | 2974 | |
e075ae69 RH |
2975 | case 2: |
2976 | switch (standard_80387_constant_p (operands[1])) | |
2977 | { | |
2978 | case 1: | |
0f40f9f7 | 2979 | return "fldz"; |
e075ae69 | 2980 | case 2: |
0f40f9f7 | 2981 | return "fld1"; |
e075ae69 RH |
2982 | } |
2983 | abort(); | |
886c62d1 | 2984 | |
e075ae69 RH |
2985 | case 3: |
2986 | case 4: | |
0f40f9f7 | 2987 | return "#"; |
886c62d1 | 2988 | |
446988df | 2989 | case 5: |
0f40f9f7 | 2990 | return "pxor\t%0, %0"; |
446988df | 2991 | case 6: |
2b04e52b | 2992 | if (TARGET_PARTIAL_REG_DEPENDENCY) |
0f40f9f7 | 2993 | return "movapd\t{%1, %0|%0, %1}"; |
2b04e52b | 2994 | else |
0f40f9f7 | 2995 | return "movsd\t{%1, %0|%0, %1}"; |
2b04e52b JH |
2996 | case 7: |
2997 | case 8: | |
0f40f9f7 | 2998 | return "movsd\t{%1, %0|%0, %1}"; |
446988df | 2999 | |
e075ae69 RH |
3000 | default: |
3001 | abort(); | |
3002 | } | |
0f40f9f7 | 3003 | } |
2b04e52b JH |
3004 | [(set_attr "type" "fmov,fmov,fmov,multi,multi,sse,sse,sse,sse") |
3005 | (set_attr "mode" "DF,DF,DF,SI,SI,TI,DF,DF,DF")]) | |
2ae0f82c | 3006 | |
e075ae69 RH |
3007 | (define_split |
3008 | [(set (match_operand:DF 0 "nonimmediate_operand" "") | |
3009 | (match_operand:DF 1 "general_operand" ""))] | |
3010 | "reload_completed | |
3011 | && (GET_CODE (operands[0]) != MEM || GET_CODE (operands[1]) != MEM) | |
446988df | 3012 | && ! (ANY_FP_REG_P (operands[0]) || |
e075ae69 | 3013 | (GET_CODE (operands[0]) == SUBREG |
446988df JH |
3014 | && ANY_FP_REG_P (SUBREG_REG (operands[0])))) |
3015 | && ! (ANY_FP_REG_P (operands[1]) || | |
e075ae69 | 3016 | (GET_CODE (operands[1]) == SUBREG |
446988df | 3017 | && ANY_FP_REG_P (SUBREG_REG (operands[1]))))" |
26e5b205 JH |
3018 | [(const_int 0)] |
3019 | "ix86_split_long_move (operands); DONE;") | |
886c62d1 | 3020 | |
a4414093 | 3021 | (define_insn "*swapdf" |
e075ae69 RH |
3022 | [(set (match_operand:DF 0 "register_operand" "+f") |
3023 | (match_operand:DF 1 "register_operand" "+f")) | |
0be5d99f MM |
3024 | (set (match_dup 1) |
3025 | (match_dup 0))] | |
446988df | 3026 | "reload_completed || !TARGET_SSE2" |
0be5d99f MM |
3027 | { |
3028 | if (STACK_TOP_P (operands[0])) | |
0f40f9f7 | 3029 | return "fxch\t%1"; |
0be5d99f | 3030 | else |
0f40f9f7 ZW |
3031 | return "fxch\t%0"; |
3032 | } | |
6ef67412 JH |
3033 | [(set_attr "type" "fxch") |
3034 | (set_attr "mode" "DF")]) | |
e075ae69 RH |
3035 | |
3036 | (define_expand "movxf" | |
4cbfbb1b | 3037 | [(set (match_operand:XF 0 "nonimmediate_operand" "") |
e075ae69 | 3038 | (match_operand:XF 1 "general_operand" ""))] |
1e07edd3 | 3039 | "!TARGET_64BIT" |
e075ae69 | 3040 | "ix86_expand_move (XFmode, operands); DONE;") |
0be5d99f | 3041 | |
2b589241 JH |
3042 | (define_expand "movtf" |
3043 | [(set (match_operand:TF 0 "nonimmediate_operand" "") | |
3044 | (match_operand:TF 1 "general_operand" ""))] | |
3045 | "" | |
3046 | "ix86_expand_move (TFmode, operands); DONE;") | |
3047 | ||
8fcaaa80 JH |
3048 | ;; Size of pushdf is 3 (for sub) + 2 (for fstp) + memory operand size. |
3049 | ;; Size of pushdf using integer insturctions is 3+3*memory operand size | |
3050 | ;; Pushing using integer instructions is longer except for constants | |
3051 | ;; and direct memory references. | |
3052 | ;; (assuming that any given constant is pushed only once, but this ought to be | |
3053 | ;; handled elsewhere). | |
3054 | ||
3055 | (define_insn "*pushxf_nointeger" | |
1e07edd3 | 3056 | [(set (match_operand:XF 0 "push_operand" "=X,X,X") |
2c5a510c | 3057 | (match_operand:XF 1 "general_no_elim_operand" "f,Fo,*r"))] |
1b0c37d7 | 3058 | "!TARGET_64BIT && optimize_size" |
8fcaaa80 JH |
3059 | { |
3060 | switch (which_alternative) | |
3061 | { | |
3062 | case 0: | |
3063 | /* %%% We loose REG_DEAD notes for controling pops if we split late. */ | |
3064 | operands[0] = gen_rtx_MEM (XFmode, stack_pointer_rtx); | |
3065 | operands[2] = stack_pointer_rtx; | |
3066 | operands[3] = GEN_INT (12); | |
3067 | if (find_regno_note (insn, REG_DEAD, REGNO (operands[1]))) | |
0f40f9f7 | 3068 | return "sub{l}\t{%3, %2|%2, %3}\;fstp%z0\t%y0"; |
8fcaaa80 | 3069 | else |
0f40f9f7 | 3070 | return "sub{l}\t{%3, %2|%2, %3}\;fst%z0\t%y0"; |
8fcaaa80 JH |
3071 | |
3072 | case 1: | |
3073 | case 2: | |
0f40f9f7 | 3074 | return "#"; |
8fcaaa80 JH |
3075 | |
3076 | default: | |
3077 | abort (); | |
3078 | } | |
0f40f9f7 | 3079 | } |
6ef67412 JH |
3080 | [(set_attr "type" "multi") |
3081 | (set_attr "mode" "XF,SI,SI")]) | |
8fcaaa80 | 3082 | |
2b589241 JH |
3083 | (define_insn "*pushtf_nointeger" |
3084 | [(set (match_operand:TF 0 "push_operand" "=<,<,<") | |
3085 | (match_operand:TF 1 "general_no_elim_operand" "f,Fo,*r"))] | |
3086 | "optimize_size" | |
2b589241 JH |
3087 | { |
3088 | switch (which_alternative) | |
3089 | { | |
3090 | case 0: | |
3091 | /* %%% We loose REG_DEAD notes for controling pops if we split late. */ | |
3092 | operands[0] = gen_rtx_MEM (XFmode, stack_pointer_rtx); | |
3093 | operands[2] = stack_pointer_rtx; | |
3094 | operands[3] = GEN_INT (16); | |
3095 | if (find_regno_note (insn, REG_DEAD, REGNO (operands[1]))) | |
0f40f9f7 | 3096 | return "sub{l}\t{%3, %2|%2, %3}\;fstp%z0\t%y0"; |
2b589241 | 3097 | else |
0f40f9f7 | 3098 | return "sub{l}\t{%3, %2|%2, %3}\;fst%z0\t%y0"; |
2b589241 JH |
3099 | |
3100 | case 1: | |
3101 | case 2: | |
0f40f9f7 | 3102 | return "#"; |
2b589241 JH |
3103 | |
3104 | default: | |
3105 | abort (); | |
3106 | } | |
0f40f9f7 | 3107 | } |
2b589241 JH |
3108 | [(set_attr "type" "multi") |
3109 | (set_attr "mode" "XF,SI,SI")]) | |
3110 | ||
8fcaaa80 | 3111 | (define_insn "*pushxf_integer" |
2450a057 | 3112 | [(set (match_operand:XF 0 "push_operand" "=<,<") |
1e07edd3 | 3113 | (match_operand:XF 1 "general_no_elim_operand" "f#r,ro#f"))] |
1b0c37d7 | 3114 | "!TARGET_64BIT && !optimize_size" |
f31fce3f | 3115 | { |
8fcaaa80 JH |
3116 | switch (which_alternative) |
3117 | { | |
3118 | case 0: | |
3119 | /* %%% We loose REG_DEAD notes for controling pops if we split late. */ | |
3120 | operands[0] = gen_rtx_MEM (XFmode, stack_pointer_rtx); | |
3121 | operands[2] = stack_pointer_rtx; | |
3122 | operands[3] = GEN_INT (12); | |
3123 | if (find_regno_note (insn, REG_DEAD, REGNO (operands[1]))) | |
0f40f9f7 | 3124 | return "sub{l}\t{%3, %2|%2, %3}\;fstp%z0\t%y0"; |
8fcaaa80 | 3125 | else |
0f40f9f7 | 3126 | return "sub{l}\t{%3, %2|%2, %3}\;fst%z0\t%y0"; |
8fcaaa80 JH |
3127 | |
3128 | case 1: | |
0f40f9f7 | 3129 | return "#"; |
8fcaaa80 JH |
3130 | |
3131 | default: | |
3132 | abort (); | |
3133 | } | |
0f40f9f7 | 3134 | } |
6ef67412 JH |
3135 | [(set_attr "type" "multi") |
3136 | (set_attr "mode" "XF,SI")]) | |
f31fce3f | 3137 | |
2b589241 JH |
3138 | (define_insn "*pushtf_integer" |
3139 | [(set (match_operand:TF 0 "push_operand" "=<,<") | |
3140 | (match_operand:TF 1 "general_no_elim_operand" "f#r,rFo#f"))] | |
3141 | "!optimize_size" | |
2b589241 JH |
3142 | { |
3143 | switch (which_alternative) | |
3144 | { | |
3145 | case 0: | |
3146 | /* %%% We loose REG_DEAD notes for controling pops if we split late. */ | |
3147 | operands[0] = gen_rtx_MEM (XFmode, stack_pointer_rtx); | |
3148 | operands[2] = stack_pointer_rtx; | |
3149 | operands[3] = GEN_INT (16); | |
0ec259ed JH |
3150 | if (TARGET_64BIT) |
3151 | if (find_regno_note (insn, REG_DEAD, REGNO (operands[1]))) | |
0f40f9f7 | 3152 | return "sub{q}\t{%3, %2|%2, %3}\;fstp%z0\t%y0"; |
0ec259ed | 3153 | else |
0f40f9f7 | 3154 | return "sub{q}\t{%3, %2|%2, %3}\;fst%z0\t%y0"; |
2b589241 | 3155 | else |
0ec259ed | 3156 | if (find_regno_note (insn, REG_DEAD, REGNO (operands[1]))) |
0f40f9f7 | 3157 | return "sub{l}\t{%3, %2|%2, %3}\;fstp%z0\t%y0"; |
0ec259ed | 3158 | else |
0f40f9f7 | 3159 | return "sub{l}\t{%3, %2|%2, %3}\;fst%z0\t%y0"; |
2b589241 JH |
3160 | |
3161 | case 1: | |
0f40f9f7 | 3162 | return "#"; |
2b589241 JH |
3163 | |
3164 | default: | |
3165 | abort (); | |
3166 | } | |
0f40f9f7 | 3167 | } |
2b589241 JH |
3168 | [(set_attr "type" "multi") |
3169 | (set_attr "mode" "XF,SI")]) | |
3170 | ||
2450a057 | 3171 | (define_split |
2b589241 JH |
3172 | [(set (match_operand 0 "push_operand" "") |
3173 | (match_operand 1 "general_operand" ""))] | |
2450a057 | 3174 | "reload_completed |
2b589241 JH |
3175 | && (GET_MODE (operands[0]) == XFmode |
3176 | || GET_MODE (operands[0]) == TFmode | |
3177 | || GET_MODE (operands[0]) == DFmode) | |
446988df | 3178 | && (!REG_P (operands[1]) || !ANY_FP_REGNO_P (REGNO (operands[1])))" |
2450a057 | 3179 | [(const_int 0)] |
26e5b205 | 3180 | "ix86_split_long_move (operands); DONE;") |
2450a057 | 3181 | |
f72b27a5 JH |
3182 | (define_split |
3183 | [(set (match_operand:XF 0 "push_operand" "") | |
e075ae69 | 3184 | (match_operand:XF 1 "register_operand" ""))] |
0ec259ed | 3185 | "!TARGET_64BIT && ANY_FP_REGNO_P (REGNO (operands[1]))" |
e075ae69 RH |
3186 | [(set (reg:SI 7) (plus:SI (reg:SI 7) (const_int -12))) |
3187 | (set (mem:XF (reg:SI 7)) (match_dup 1))]) | |
f31fce3f | 3188 | |
2b589241 JH |
3189 | (define_split |
3190 | [(set (match_operand:TF 0 "push_operand" "") | |
3191 | (match_operand:TF 1 "register_operand" ""))] | |
0ec259ed | 3192 | "!TARGET_64BIT && ANY_FP_REGNO_P (REGNO (operands[1]))" |
2b589241 JH |
3193 | [(set (reg:SI 7) (plus:SI (reg:SI 7) (const_int -16))) |
3194 | (set (mem:TF (reg:SI 7)) (match_dup 1))]) | |
3195 | ||
0ec259ed JH |
3196 | (define_split |
3197 | [(set (match_operand:TF 0 "push_operand" "") | |
3198 | (match_operand:TF 1 "register_operand" ""))] | |
3199 | "TARGET_64BIT && ANY_FP_REGNO_P (REGNO (operands[1]))" | |
3200 | [(set (reg:DI 7) (plus:DI (reg:DI 7) (const_int -16))) | |
3201 | (set (mem:TF (reg:DI 7)) (match_dup 1))]) | |
3202 | ||
8fcaaa80 JH |
3203 | ;; Do not use integer registers when optimizing for size |
3204 | (define_insn "*movxf_nointeger" | |
3205 | [(set (match_operand:XF 0 "nonimmediate_operand" "=f,m,f,*r,o") | |
3206 | (match_operand:XF 1 "general_operand" "fm,f,G,*roF,F*r"))] | |
1b0c37d7 | 3207 | "!TARGET_64BIT |
d7a29404 | 3208 | && optimize_size |
1b0c37d7 | 3209 | && (GET_CODE (operands[0]) != MEM || GET_CODE (operands[1]) != MEM) |
d7a29404 JH |
3210 | && (reload_in_progress || reload_completed |
3211 | || GET_CODE (operands[1]) != CONST_DOUBLE | |
3212 | || memory_operand (operands[0], XFmode))" | |
0be5d99f | 3213 | { |
8fcaaa80 JH |
3214 | switch (which_alternative) |
3215 | { | |
3216 | case 0: | |
3217 | if (REG_P (operands[1]) | |
3218 | && find_regno_note (insn, REG_DEAD, REGNO (operands[1]))) | |
0f40f9f7 | 3219 | return "fstp\t%y0"; |
8fcaaa80 | 3220 | else if (STACK_TOP_P (operands[0])) |
0f40f9f7 | 3221 | return "fld%z1\t%y1"; |
8fcaaa80 | 3222 | else |
0f40f9f7 | 3223 | return "fst\t%y0"; |
0be5d99f | 3224 | |
8fcaaa80 JH |
3225 | case 1: |
3226 | /* There is no non-popping store to memory for XFmode. So if | |
3227 | we need one, follow the store with a load. */ | |
3228 | if (! find_regno_note (insn, REG_DEAD, REGNO (operands[1]))) | |
0f40f9f7 | 3229 | return "fstp%z0\t%y0\;fld%z0\t%y0"; |
8fcaaa80 | 3230 | else |
0f40f9f7 | 3231 | return "fstp%z0\t%y0"; |
8fcaaa80 JH |
3232 | |
3233 | case 2: | |
3234 | switch (standard_80387_constant_p (operands[1])) | |
3235 | { | |
3236 | case 1: | |
0f40f9f7 | 3237 | return "fldz"; |
8fcaaa80 | 3238 | case 2: |
0f40f9f7 | 3239 | return "fld1"; |
8fcaaa80 JH |
3240 | } |
3241 | break; | |
3242 | ||
3243 | case 3: case 4: | |
0f40f9f7 | 3244 | return "#"; |
8fcaaa80 JH |
3245 | } |
3246 | abort(); | |
0f40f9f7 | 3247 | } |
6ef67412 JH |
3248 | [(set_attr "type" "fmov,fmov,fmov,multi,multi") |
3249 | (set_attr "mode" "XF,XF,XF,SI,SI")]) | |
8fcaaa80 | 3250 | |
2b589241 JH |
3251 | (define_insn "*movtf_nointeger" |
3252 | [(set (match_operand:TF 0 "nonimmediate_operand" "=f,m,f,*r,o") | |
3253 | (match_operand:TF 1 "general_operand" "fm,f,G,*roF,F*r"))] | |
3254 | "(GET_CODE (operands[0]) != MEM || GET_CODE (operands[1]) != MEM) | |
3255 | && optimize_size | |
3256 | && (reload_in_progress || reload_completed | |
3257 | || GET_CODE (operands[1]) != CONST_DOUBLE | |
3987b9db | 3258 | || (ix86_cmodel == CM_MEDIUM || ix86_cmodel == CM_LARGE) |
2b589241 | 3259 | || memory_operand (operands[0], TFmode))" |
2b589241 JH |
3260 | { |
3261 | switch (which_alternative) | |
3262 | { | |
3263 | case 0: | |
3264 | if (REG_P (operands[1]) | |
3265 | && find_regno_note (insn, REG_DEAD, REGNO (operands[1]))) | |
0f40f9f7 | 3266 | return "fstp\t%y0"; |
2b589241 | 3267 | else if (STACK_TOP_P (operands[0])) |
0f40f9f7 | 3268 | return "fld%z1\t%y1"; |
2b589241 | 3269 | else |
0f40f9f7 | 3270 | return "fst\t%y0"; |
2b589241 JH |
3271 | |
3272 | case 1: | |
3273 | /* There is no non-popping store to memory for XFmode. So if | |
3274 | we need one, follow the store with a load. */ | |
3275 | if (! find_regno_note (insn, REG_DEAD, REGNO (operands[1]))) | |
0f40f9f7 | 3276 | return "fstp%z0\t%y0\;fld%z0\t%y0"; |
2b589241 | 3277 | else |
0f40f9f7 | 3278 | return "fstp%z0\t%y0"; |
2b589241 JH |
3279 | |
3280 | case 2: | |
3281 | switch (standard_80387_constant_p (operands[1])) | |
3282 | { | |
3283 | case 1: | |
0f40f9f7 | 3284 | return "fldz"; |
2b589241 | 3285 | case 2: |
0f40f9f7 | 3286 | return "fld1"; |
2b589241 JH |
3287 | } |
3288 | break; | |
3289 | ||
3290 | case 3: case 4: | |
0f40f9f7 | 3291 | return "#"; |
2b589241 JH |
3292 | } |
3293 | abort(); | |
0f40f9f7 | 3294 | } |
2b589241 JH |
3295 | [(set_attr "type" "fmov,fmov,fmov,multi,multi") |
3296 | (set_attr "mode" "XF,XF,XF,SI,SI")]) | |
3297 | ||
8fcaaa80 JH |
3298 | (define_insn "*movxf_integer" |
3299 | [(set (match_operand:XF 0 "nonimmediate_operand" "=f#r,m,f#r,r#f,o") | |
3300 | (match_operand:XF 1 "general_operand" "fm#r,f#r,G,roF#f,Fr#f"))] | |
1b0c37d7 | 3301 | "!TARGET_64BIT |
d7a29404 | 3302 | && !optimize_size |
1b0c37d7 | 3303 | && (GET_CODE (operands[0]) != MEM || GET_CODE (operands[1]) != MEM) |
d7a29404 JH |
3304 | && (reload_in_progress || reload_completed |
3305 | || GET_CODE (operands[1]) != CONST_DOUBLE | |
3306 | || memory_operand (operands[0], XFmode))" | |
4fb21e90 | 3307 | { |
e075ae69 | 3308 | switch (which_alternative) |
4fb21e90 | 3309 | { |
e075ae69 | 3310 | case 0: |
0c174a68 AB |
3311 | if (REG_P (operands[1]) |
3312 | && find_regno_note (insn, REG_DEAD, REGNO (operands[1]))) | |
0f40f9f7 | 3313 | return "fstp\t%y0"; |
e075ae69 | 3314 | else if (STACK_TOP_P (operands[0])) |
0f40f9f7 | 3315 | return "fld%z1\t%y1"; |
4fb21e90 | 3316 | else |
0f40f9f7 | 3317 | return "fst\t%y0"; |
4fb21e90 | 3318 | |
e075ae69 RH |
3319 | case 1: |
3320 | /* There is no non-popping store to memory for XFmode. So if | |
3321 | we need one, follow the store with a load. */ | |
3322 | if (! find_regno_note (insn, REG_DEAD, REGNO (operands[1]))) | |
0f40f9f7 | 3323 | return "fstp%z0\t%y0\;fld%z0\t%y0"; |
e075ae69 | 3324 | else |
0f40f9f7 | 3325 | return "fstp%z0\t%y0"; |
2f17722a | 3326 | |
e075ae69 RH |
3327 | case 2: |
3328 | switch (standard_80387_constant_p (operands[1])) | |
3329 | { | |
3330 | case 1: | |
0f40f9f7 | 3331 | return "fldz"; |
e075ae69 | 3332 | case 2: |
0f40f9f7 | 3333 | return "fld1"; |
e075ae69 RH |
3334 | } |
3335 | break; | |
467403ca RH |
3336 | |
3337 | case 3: case 4: | |
0f40f9f7 | 3338 | return "#"; |
4fb21e90 | 3339 | } |
e075ae69 | 3340 | abort(); |
0f40f9f7 | 3341 | } |
6ef67412 JH |
3342 | [(set_attr "type" "fmov,fmov,fmov,multi,multi") |
3343 | (set_attr "mode" "XF,XF,XF,SI,SI")]) | |
4fb21e90 | 3344 | |
2b589241 JH |
3345 | (define_insn "*movtf_integer" |
3346 | [(set (match_operand:TF 0 "nonimmediate_operand" "=f#r,m,f#r,r#f,o") | |
3347 | (match_operand:TF 1 "general_operand" "fm#r,f#r,G,roF#f,Fr#f"))] | |
3348 | "(GET_CODE (operands[0]) != MEM || GET_CODE (operands[1]) != MEM) | |
3349 | && !optimize_size | |
3350 | && (reload_in_progress || reload_completed | |
3351 | || GET_CODE (operands[1]) != CONST_DOUBLE | |
3987b9db | 3352 | || (ix86_cmodel == CM_MEDIUM || ix86_cmodel == CM_LARGE) |
2b589241 | 3353 | || memory_operand (operands[0], TFmode))" |
2b589241 JH |
3354 | { |
3355 | switch (which_alternative) | |
3356 | { | |
3357 | case 0: | |
3358 | if (REG_P (operands[1]) | |
3359 | && find_regno_note (insn, REG_DEAD, REGNO (operands[1]))) | |
0f40f9f7 | 3360 | return "fstp\t%y0"; |
2b589241 | 3361 | else if (STACK_TOP_P (operands[0])) |
0f40f9f7 | 3362 | return "fld%z1\t%y1"; |
2b589241 | 3363 | else |
0f40f9f7 | 3364 | return "fst\t%y0"; |
2b589241 JH |
3365 | |
3366 | case 1: | |
3367 | /* There is no non-popping store to memory for XFmode. So if | |
3368 | we need one, follow the store with a load. */ | |
3369 | if (! find_regno_note (insn, REG_DEAD, REGNO (operands[1]))) | |
0f40f9f7 | 3370 | return "fstp%z0\t%y0\;fld%z0\t%y0"; |
2b589241 | 3371 | else |
0f40f9f7 | 3372 | return "fstp%z0\t%y0"; |
2b589241 JH |
3373 | |
3374 | case 2: | |
3375 | switch (standard_80387_constant_p (operands[1])) | |
3376 | { | |
3377 | case 1: | |
0f40f9f7 | 3378 | return "fldz"; |
2b589241 | 3379 | case 2: |
0f40f9f7 | 3380 | return "fld1"; |
2b589241 JH |
3381 | } |
3382 | break; | |
3383 | ||
3384 | case 3: case 4: | |
0f40f9f7 | 3385 | return "#"; |
2b589241 JH |
3386 | } |
3387 | abort(); | |
0f40f9f7 | 3388 | } |
2b589241 JH |
3389 | [(set_attr "type" "fmov,fmov,fmov,multi,multi") |
3390 | (set_attr "mode" "XF,XF,XF,SI,SI")]) | |
3391 | ||
467403ca | 3392 | (define_split |
2b589241 JH |
3393 | [(set (match_operand 0 "nonimmediate_operand" "") |
3394 | (match_operand 1 "general_operand" ""))] | |
2450a057 | 3395 | "reload_completed |
8fcaaa80 | 3396 | && (GET_CODE (operands[0]) != MEM || GET_CODE (operands[1]) != MEM) |
2b589241 | 3397 | && (GET_MODE (operands[0]) == XFmode || GET_MODE (operands[0]) == TFmode) |
446988df | 3398 | && ! (ANY_FP_REG_P (operands[0]) || |
8fcaaa80 | 3399 | (GET_CODE (operands[0]) == SUBREG |
446988df JH |
3400 | && ANY_FP_REG_P (SUBREG_REG (operands[0])))) |
3401 | && ! (ANY_FP_REG_P (operands[1]) || | |
8fcaaa80 | 3402 | (GET_CODE (operands[1]) == SUBREG |
446988df | 3403 | && ANY_FP_REG_P (SUBREG_REG (operands[1]))))" |
26e5b205 JH |
3404 | [(const_int 0)] |
3405 | "ix86_split_long_move (operands); DONE;") | |
467403ca | 3406 | |
d7a29404 | 3407 | (define_split |
2b589241 JH |
3408 | [(set (match_operand 0 "register_operand" "") |
3409 | (match_operand 1 "memory_operand" ""))] | |
d7a29404 JH |
3410 | "reload_completed |
3411 | && GET_CODE (operands[1]) == MEM | |
2b04e52b JH |
3412 | && (GET_MODE (operands[0]) == XFmode || GET_MODE (operands[0]) == TFmode |
3413 | || GET_MODE (operands[0]) == SFmode || GET_MODE (operands[0]) == DFmode) | |
d7a29404 JH |
3414 | && GET_CODE (XEXP (operands[1], 0)) == SYMBOL_REF |
3415 | && CONSTANT_POOL_ADDRESS_P (XEXP (operands[1], 0)) | |
2b04e52b JH |
3416 | && (!(SSE_REG_P (operands[0]) || |
3417 | (GET_CODE (operands[0]) == SUBREG | |
3418 | && SSE_REG_P (SUBREG_REG (operands[0])))) | |
3419 | || standard_sse_constant_p (get_pool_constant (XEXP (operands[1], 0)))) | |
3420 | && (!(FP_REG_P (operands[0]) || | |
3421 | (GET_CODE (operands[0]) == SUBREG | |
3422 | && FP_REG_P (SUBREG_REG (operands[0])))) | |
3423 | || standard_80387_constant_p (get_pool_constant (XEXP (operands[1], 0))))" | |
d7a29404 JH |
3424 | [(set (match_dup 0) |
3425 | (match_dup 1))] | |
3426 | "operands[1] = get_pool_constant (XEXP (operands[1], 0));") | |
3427 | ||
e075ae69 RH |
3428 | (define_insn "swapxf" |
3429 | [(set (match_operand:XF 0 "register_operand" "+f") | |
3430 | (match_operand:XF 1 "register_operand" "+f")) | |
0be5d99f MM |
3431 | (set (match_dup 1) |
3432 | (match_dup 0))] | |
3433 | "" | |
0be5d99f MM |
3434 | { |
3435 | if (STACK_TOP_P (operands[0])) | |
0f40f9f7 | 3436 | return "fxch\t%1"; |
0be5d99f | 3437 | else |
0f40f9f7 ZW |
3438 | return "fxch\t%0"; |
3439 | } | |
0b5107cf | 3440 | [(set_attr "type" "fxch") |
6ef67412 | 3441 | (set_attr "mode" "XF")]) |
2b589241 JH |
3442 | |
3443 | (define_insn "swaptf" | |
3444 | [(set (match_operand:TF 0 "register_operand" "+f") | |
3445 | (match_operand:TF 1 "register_operand" "+f")) | |
3446 | (set (match_dup 1) | |
3447 | (match_dup 0))] | |
3448 | "" | |
2b589241 JH |
3449 | { |
3450 | if (STACK_TOP_P (operands[0])) | |
0f40f9f7 | 3451 | return "fxch\t%1"; |
2b589241 | 3452 | else |
0f40f9f7 ZW |
3453 | return "fxch\t%0"; |
3454 | } | |
2b589241 JH |
3455 | [(set_attr "type" "fxch") |
3456 | (set_attr "mode" "XF")]) | |
886c62d1 | 3457 | \f |
e075ae69 | 3458 | ;; Zero extension instructions |
886c62d1 | 3459 | |
8f7661f2 JH |
3460 | (define_expand "zero_extendhisi2" |
3461 | [(set (match_operand:SI 0 "register_operand" "") | |
3462 | (zero_extend:SI (match_operand:HI 1 "nonimmediate_operand" "")))] | |
d626200a | 3463 | "" |
e075ae69 | 3464 | { |
8f7661f2 | 3465 | if (TARGET_ZERO_EXTEND_WITH_AND && !optimize_size) |
2ae0f82c | 3466 | { |
8f7661f2 JH |
3467 | operands[1] = force_reg (HImode, operands[1]); |
3468 | emit_insn (gen_zero_extendhisi2_and (operands[0], operands[1])); | |
3469 | DONE; | |
2ae0f82c | 3470 | } |
0f40f9f7 | 3471 | }) |
886c62d1 | 3472 | |
8f7661f2 JH |
3473 | (define_insn "zero_extendhisi2_and" |
3474 | [(set (match_operand:SI 0 "register_operand" "=r") | |
3475 | (zero_extend:SI (match_operand:HI 1 "register_operand" "0"))) | |
e075ae69 | 3476 | (clobber (reg:CC 17))] |
8f7661f2 JH |
3477 | "TARGET_ZERO_EXTEND_WITH_AND && !optimize_size" |
3478 | "#" | |
6ef67412 JH |
3479 | [(set_attr "type" "alu1") |
3480 | (set_attr "mode" "SI")]) | |
2ae0f82c SC |
3481 | |
3482 | (define_split | |
3483 | [(set (match_operand:SI 0 "register_operand" "") | |
8f7661f2 | 3484 | (zero_extend:SI (match_operand:HI 1 "register_operand" ""))) |
e075ae69 | 3485 | (clobber (reg:CC 17))] |
8f7661f2 JH |
3486 | "reload_completed && TARGET_ZERO_EXTEND_WITH_AND && !optimize_size" |
3487 | [(parallel [(set (match_dup 0) (and:SI (match_dup 0) (const_int 65535))) | |
e075ae69 | 3488 | (clobber (reg:CC 17))])] |
d626200a JL |
3489 | "") |
3490 | ||
8f7661f2 JH |
3491 | (define_insn "*zero_extendhisi2_movzwl" |
3492 | [(set (match_operand:SI 0 "register_operand" "=r") | |
3493 | (zero_extend:SI (match_operand:HI 1 "nonimmediate_operand" "rm")))] | |
3494 | "!TARGET_ZERO_EXTEND_WITH_AND || optimize_size" | |
0f40f9f7 | 3495 | "movz{wl|x}\t{%1, %0|%0, %1}" |
6ef67412 JH |
3496 | [(set_attr "type" "imovx") |
3497 | (set_attr "mode" "SI")]) | |
8f7661f2 JH |
3498 | |
3499 | (define_expand "zero_extendqihi2" | |
3500 | [(parallel | |
3501 | [(set (match_operand:HI 0 "register_operand" "") | |
3502 | (zero_extend:HI (match_operand:QI 1 "nonimmediate_operand" ""))) | |
3503 | (clobber (reg:CC 17))])] | |
e075ae69 | 3504 | "" |
8f7661f2 JH |
3505 | "") |
3506 | ||
3507 | (define_insn "*zero_extendqihi2_and" | |
3508 | [(set (match_operand:HI 0 "register_operand" "=r,?&q") | |
3509 | (zero_extend:HI (match_operand:QI 1 "nonimmediate_operand" "0,qm"))) | |
3510 | (clobber (reg:CC 17))] | |
3511 | "TARGET_ZERO_EXTEND_WITH_AND && !optimize_size" | |
3512 | "#" | |
6ef67412 JH |
3513 | [(set_attr "type" "alu1") |
3514 | (set_attr "mode" "HI")]) | |
8f7661f2 JH |
3515 | |
3516 | (define_insn "*zero_extendqihi2_movzbw_and" | |
3517 | [(set (match_operand:HI 0 "register_operand" "=r,r") | |
3518 | (zero_extend:HI (match_operand:QI 1 "nonimmediate_operand" "qm,0"))) | |
3519 | (clobber (reg:CC 17))] | |
3520 | "!TARGET_ZERO_EXTEND_WITH_AND || optimize_size" | |
3521 | "#" | |
6ef67412 JH |
3522 | [(set_attr "type" "imovx,alu1") |
3523 | (set_attr "mode" "HI")]) | |
886c62d1 | 3524 | |
8f7661f2 JH |
3525 | (define_insn "*zero_extendqihi2_movzbw" |
3526 | [(set (match_operand:HI 0 "register_operand" "=r") | |
3527 | (zero_extend:HI (match_operand:QI 1 "nonimmediate_operand" "qm")))] | |
1c27d4b2 | 3528 | "(!TARGET_ZERO_EXTEND_WITH_AND || optimize_size) && reload_completed" |
0f40f9f7 | 3529 | "movz{bw|x}\t{%1, %0|%0, %1}" |
6ef67412 JH |
3530 | [(set_attr "type" "imovx") |
3531 | (set_attr "mode" "HI")]) | |
8f7661f2 JH |
3532 | |
3533 | ;; For the movzbw case strip only the clobber | |
2ae0f82c SC |
3534 | (define_split |
3535 | [(set (match_operand:HI 0 "register_operand" "") | |
e075ae69 RH |
3536 | (zero_extend:HI (match_operand:QI 1 "nonimmediate_operand" ""))) |
3537 | (clobber (reg:CC 17))] | |
8f7661f2 JH |
3538 | "reload_completed |
3539 | && (!TARGET_ZERO_EXTEND_WITH_AND || optimize_size) | |
1a06f5fe | 3540 | && (!REG_P (operands[1]) || ANY_QI_REG_P (operands[1]))" |
8f7661f2 JH |
3541 | [(set (match_operand:HI 0 "register_operand" "") |
3542 | (zero_extend:HI (match_operand:QI 1 "nonimmediate_operand" "")))]) | |
2ae0f82c | 3543 | |
8f7661f2 JH |
3544 | ;; When source and destination does not overlap, clear destination |
3545 | ;; first and then do the movb | |
2ae0f82c SC |
3546 | (define_split |
3547 | [(set (match_operand:HI 0 "register_operand" "") | |
8f7661f2 | 3548 | (zero_extend:HI (match_operand:QI 1 "nonimmediate_operand" ""))) |
e075ae69 RH |
3549 | (clobber (reg:CC 17))] |
3550 | "reload_completed | |
1a06f5fe | 3551 | && ANY_QI_REG_P (operands[0]) |
8f7661f2 JH |
3552 | && (TARGET_ZERO_EXTEND_WITH_AND && !optimize_size) |
3553 | && !reg_overlap_mentioned_p (operands[0], operands[1])" | |
3554 | [(set (match_dup 0) (const_int 0)) | |
3555 | (set (strict_low_part (match_dup 2)) (match_dup 1))] | |
3556 | "operands[2] = gen_lowpart (QImode, operands[0]);") | |
2ae0f82c | 3557 | |
8f7661f2 | 3558 | ;; Rest is handled by single and. |
2ae0f82c SC |
3559 | (define_split |
3560 | [(set (match_operand:HI 0 "register_operand" "") | |
e075ae69 RH |
3561 | (zero_extend:HI (match_operand:QI 1 "register_operand" ""))) |
3562 | (clobber (reg:CC 17))] | |
3563 | "reload_completed | |
8f7661f2 JH |
3564 | && true_regnum (operands[0]) == true_regnum (operands[1])" |
3565 | [(parallel [(set (match_dup 0) (and:HI (match_dup 0) (const_int 255))) | |
e075ae69 | 3566 | (clobber (reg:CC 17))])] |
d626200a JL |
3567 | "") |
3568 | ||
8f7661f2 JH |
3569 | (define_expand "zero_extendqisi2" |
3570 | [(parallel | |
3571 | [(set (match_operand:SI 0 "register_operand" "") | |
3572 | (zero_extend:SI (match_operand:QI 1 "nonimmediate_operand" ""))) | |
3573 | (clobber (reg:CC 17))])] | |
e075ae69 | 3574 | "" |
8f7661f2 JH |
3575 | "") |
3576 | ||
3577 | (define_insn "*zero_extendqisi2_and" | |
3578 | [(set (match_operand:SI 0 "register_operand" "=r,?&q") | |
3579 | (zero_extend:SI (match_operand:QI 1 "nonimmediate_operand" "0,qm"))) | |
3580 | (clobber (reg:CC 17))] | |
3581 | "TARGET_ZERO_EXTEND_WITH_AND && !optimize_size" | |
3582 | "#" | |
6ef67412 JH |
3583 | [(set_attr "type" "alu1") |
3584 | (set_attr "mode" "SI")]) | |
8f7661f2 JH |
3585 | |
3586 | (define_insn "*zero_extendqisi2_movzbw_and" | |
3587 | [(set (match_operand:SI 0 "register_operand" "=r,r") | |
3588 | (zero_extend:SI (match_operand:QI 1 "nonimmediate_operand" "qm,0"))) | |
3589 | (clobber (reg:CC 17))] | |
3590 | "!TARGET_ZERO_EXTEND_WITH_AND || optimize_size" | |
3591 | "#" | |
6ef67412 JH |
3592 | [(set_attr "type" "imovx,alu1") |
3593 | (set_attr "mode" "SI")]) | |
2ae0f82c | 3594 | |
8f7661f2 JH |
3595 | (define_insn "*zero_extendqisi2_movzbw" |
3596 | [(set (match_operand:SI 0 "register_operand" "=r") | |
3597 | (zero_extend:SI (match_operand:QI 1 "nonimmediate_operand" "qm")))] | |
3598 | "(!TARGET_ZERO_EXTEND_WITH_AND || optimize_size) && reload_completed" | |
0f40f9f7 | 3599 | "movz{bl|x}\t{%1, %0|%0, %1}" |
6ef67412 JH |
3600 | [(set_attr "type" "imovx") |
3601 | (set_attr "mode" "SI")]) | |
8f7661f2 JH |
3602 | |
3603 | ;; For the movzbl case strip only the clobber | |
3604 | (define_split | |
3605 | [(set (match_operand:SI 0 "register_operand" "") | |
3606 | (zero_extend:SI (match_operand:QI 1 "nonimmediate_operand" ""))) | |
3607 | (clobber (reg:CC 17))] | |
3608 | "reload_completed | |
3609 | && (!TARGET_ZERO_EXTEND_WITH_AND || optimize_size) | |
1a06f5fe | 3610 | && (!REG_P (operands[1]) || ANY_QI_REG_P (operands[1]))" |
8f7661f2 JH |
3611 | [(set (match_dup 0) |
3612 | (zero_extend:SI (match_dup 1)))]) | |
3613 | ||
3614 | ;; When source and destination does not overlap, clear destination | |
3615 | ;; first and then do the movb | |
2ae0f82c SC |
3616 | (define_split |
3617 | [(set (match_operand:SI 0 "register_operand" "") | |
e075ae69 RH |
3618 | (zero_extend:SI (match_operand:QI 1 "nonimmediate_operand" ""))) |
3619 | (clobber (reg:CC 17))] | |
3620 | "reload_completed | |
1a06f5fe JH |
3621 | && ANY_QI_REG_P (operands[0]) |
3622 | && (ANY_QI_REG_P (operands[1]) || GET_CODE (operands[1]) == MEM) | |
8f7661f2 | 3623 | && (TARGET_ZERO_EXTEND_WITH_AND && !optimize_size) |
e075ae69 | 3624 | && !reg_overlap_mentioned_p (operands[0], operands[1])" |
8f7661f2 JH |
3625 | [(set (match_dup 0) (const_int 0)) |
3626 | (set (strict_low_part (match_dup 2)) (match_dup 1))] | |
3627 | "operands[2] = gen_lowpart (QImode, operands[0]);") | |
2ae0f82c | 3628 | |
8f7661f2 | 3629 | ;; Rest is handled by single and. |
2ae0f82c SC |
3630 | (define_split |
3631 | [(set (match_operand:SI 0 "register_operand" "") | |
e075ae69 RH |
3632 | (zero_extend:SI (match_operand:QI 1 "register_operand" ""))) |
3633 | (clobber (reg:CC 17))] | |
3634 | "reload_completed | |
8f7661f2 JH |
3635 | && true_regnum (operands[0]) == true_regnum (operands[1])" |
3636 | [(parallel [(set (match_dup 0) (and:SI (match_dup 0) (const_int 255))) | |
e075ae69 RH |
3637 | (clobber (reg:CC 17))])] |
3638 | "") | |
2ae0f82c | 3639 | |
e075ae69 | 3640 | ;; %%% Kill me once multi-word ops are sane. |
123bf9e3 JH |
3641 | (define_expand "zero_extendsidi2" |
3642 | [(set (match_operand:DI 0 "register_operand" "=r") | |
3643 | (zero_extend:DI (match_operand:SI 1 "nonimmediate_operand" "rm")))] | |
3644 | "" | |
3645 | "if (!TARGET_64BIT) | |
3646 | { | |
3647 | emit_insn (gen_zero_extendsidi2_32 (operands[0], operands[1])); | |
3648 | DONE; | |
3649 | } | |
3650 | ") | |
3651 | ||
3652 | (define_insn "zero_extendsidi2_32" | |
bb62e19a | 3653 | [(set (match_operand:DI 0 "nonimmediate_operand" "=r,?r,?*o") |
123bf9e3 | 3654 | (zero_extend:DI (match_operand:SI 1 "nonimmediate_operand" "0,rm,r"))) |
e075ae69 | 3655 | (clobber (reg:CC 17))] |
123bf9e3 | 3656 | "!TARGET_64BIT" |
6ef67412 JH |
3657 | "#" |
3658 | [(set_attr "mode" "SI")]) | |
2ae0f82c | 3659 | |
123bf9e3 JH |
3660 | (define_insn "zero_extendsidi2_rex64" |
3661 | [(set (match_operand:DI 0 "nonimmediate_operand" "=r,o") | |
3662 | (zero_extend:DI (match_operand:SI 1 "nonimmediate_operand" "rm,0")))] | |
3663 | "TARGET_64BIT" | |
3664 | "@ | |
0f40f9f7 | 3665 | mov\t{%k1, %k0|%k0, %k1} |
123bf9e3 JH |
3666 | #" |
3667 | [(set_attr "type" "imovx,imov") | |
3668 | (set_attr "mode" "SI,DI")]) | |
3669 | ||
3670 | (define_split | |
3671 | [(set (match_operand:DI 0 "memory_operand" "") | |
3672 | (zero_extend:DI (match_dup 0)))] | |
1b0c37d7 | 3673 | "TARGET_64BIT" |
123bf9e3 JH |
3674 | [(set (match_dup 4) (const_int 0))] |
3675 | "split_di (&operands[0], 1, &operands[3], &operands[4]);") | |
3676 | ||
bb62e19a JH |
3677 | (define_split |
3678 | [(set (match_operand:DI 0 "register_operand" "") | |
e075ae69 RH |
3679 | (zero_extend:DI (match_operand:SI 1 "register_operand" ""))) |
3680 | (clobber (reg:CC 17))] | |
1b0c37d7 ZW |
3681 | "!TARGET_64BIT && reload_completed |
3682 | && true_regnum (operands[0]) == true_regnum (operands[1])" | |
591702de | 3683 | [(set (match_dup 4) (const_int 0))] |
bb62e19a JH |
3684 | "split_di (&operands[0], 1, &operands[3], &operands[4]);") |
3685 | ||
3686 | (define_split | |
3687 | [(set (match_operand:DI 0 "nonimmediate_operand" "") | |
e075ae69 RH |
3688 | (zero_extend:DI (match_operand:SI 1 "general_operand" ""))) |
3689 | (clobber (reg:CC 17))] | |
1b0c37d7 | 3690 | "!TARGET_64BIT && reload_completed" |
bb62e19a | 3691 | [(set (match_dup 3) (match_dup 1)) |
591702de | 3692 | (set (match_dup 4) (const_int 0))] |
bb62e19a | 3693 | "split_di (&operands[0], 1, &operands[3], &operands[4]);") |
123bf9e3 JH |
3694 | |
3695 | (define_insn "zero_extendhidi2" | |
3696 | [(set (match_operand:DI 0 "register_operand" "=r,r") | |
3697 | (zero_extend:DI (match_operand:HI 1 "nonimmediate_operand" "r,m")))] | |
3698 | "TARGET_64BIT" | |
3699 | "@ | |
0f40f9f7 ZW |
3700 | movz{wl|x}\t{%1, %k0|%k0, %1} |
3701 | movz{wq|x}\t{%1, %0|%0, %1}" | |
123bf9e3 JH |
3702 | [(set_attr "type" "imovx") |
3703 | (set_attr "mode" "SI,DI")]) | |
3704 | ||
3705 | (define_insn "zero_extendqidi2" | |
3706 | [(set (match_operand:DI 0 "register_operand" "=r,r") | |
3707 | (zero_extend:DI (match_operand:QI 1 "nonimmediate_operand" "Q,m")))] | |
3708 | "TARGET_64BIT" | |
3709 | "@ | |
0f40f9f7 ZW |
3710 | movz{bl|x}\t{%1, %k0|%k0, %1} |
3711 | movz{bq|x}\t{%1, %0|%0, %1}" | |
123bf9e3 JH |
3712 | [(set_attr "type" "imovx") |
3713 | (set_attr "mode" "SI,DI")]) | |
886c62d1 | 3714 | \f |
e075ae69 | 3715 | ;; Sign extension instructions |
886c62d1 | 3716 | |
123bf9e3 JH |
3717 | (define_expand "extendsidi2" |
3718 | [(parallel [(set (match_operand:DI 0 "register_operand" "") | |
3719 | (sign_extend:DI (match_operand:SI 1 "register_operand" ""))) | |
3720 | (clobber (reg:CC 17)) | |
3721 | (clobber (match_scratch:SI 2 ""))])] | |
3722 | "" | |
123bf9e3 JH |
3723 | { |
3724 | if (TARGET_64BIT) | |
3725 | { | |
3726 | emit_insn (gen_extendsidi2_rex64 (operands[0], operands[1])); | |
3727 | DONE; | |
3728 | } | |
0f40f9f7 | 3729 | }) |
123bf9e3 JH |
3730 | |
3731 | (define_insn "*extendsidi2_1" | |
e075ae69 RH |
3732 | [(set (match_operand:DI 0 "nonimmediate_operand" "=*A,r,?r,?*o") |
3733 | (sign_extend:DI (match_operand:SI 1 "register_operand" "0,0,r,r"))) | |
6b29b0e2 JW |
3734 | (clobber (reg:CC 17)) |
3735 | (clobber (match_scratch:SI 2 "=X,X,X,&r"))] | |
123bf9e3 | 3736 | "!TARGET_64BIT" |
724d568a JH |
3737 | "#") |
3738 | ||
123bf9e3 JH |
3739 | (define_insn "extendsidi2_rex64" |
3740 | [(set (match_operand:DI 0 "register_operand" "=*a,r") | |
3741 | (sign_extend:DI (match_operand:SI 1 "nonimmediate_operand" "*0,rm")))] | |
3742 | "TARGET_64BIT" | |
3743 | "@ | |
3744 | {cltq|cdqe} | |
0f40f9f7 | 3745 | movs{lq|x}\t{%1,%0|%0, %1}" |
123bf9e3 JH |
3746 | [(set_attr "type" "imovx") |
3747 | (set_attr "mode" "DI") | |
3748 | (set_attr "prefix_0f" "0") | |
3749 | (set_attr "modrm" "0,1")]) | |
3750 | ||
3751 | (define_insn "extendhidi2" | |
3752 | [(set (match_operand:DI 0 "register_operand" "=r") | |
3753 | (sign_extend:DI (match_operand:HI 1 "nonimmediate_operand" "rm")))] | |
3754 | "TARGET_64BIT" | |
0f40f9f7 | 3755 | "movs{wq|x}\t{%1,%0|%0, %1}" |
123bf9e3 JH |
3756 | [(set_attr "type" "imovx") |
3757 | (set_attr "mode" "DI")]) | |
3758 | ||
3759 | (define_insn "extendqidi2" | |
3760 | [(set (match_operand:DI 0 "register_operand" "=r") | |
3761 | (sign_extend:DI (match_operand:QI 1 "nonimmediate_operand" "qm")))] | |
3762 | "TARGET_64BIT" | |
0f40f9f7 | 3763 | "movs{bq|x}\t{%1,%0|%0, %1}" |
123bf9e3 JH |
3764 | [(set_attr "type" "imovx") |
3765 | (set_attr "mode" "DI")]) | |
3766 | ||
724d568a JH |
3767 | ;; Extend to memory case when source register does die. |
3768 | (define_split | |
3769 | [(set (match_operand:DI 0 "memory_operand" "") | |
3770 | (sign_extend:DI (match_operand:SI 1 "register_operand" ""))) | |
6b29b0e2 JW |
3771 | (clobber (reg:CC 17)) |
3772 | (clobber (match_operand:SI 2 "register_operand" ""))] | |
d7a29404 | 3773 | "(reload_completed |
724d568a JH |
3774 | && dead_or_set_p (insn, operands[1]) |
3775 | && !reg_mentioned_p (operands[1], operands[0]))" | |
3776 | [(set (match_dup 3) (match_dup 1)) | |
e075ae69 RH |
3777 | (parallel [(set (match_dup 1) (ashiftrt:SI (match_dup 1) (const_int 31))) |
3778 | (clobber (reg:CC 17))]) | |
724d568a JH |
3779 | (set (match_dup 4) (match_dup 1))] |
3780 | "split_di (&operands[0], 1, &operands[3], &operands[4]);") | |
3781 | ||
3782 | ;; Extend to memory case when source register does not die. | |
3783 | (define_split | |
3784 | [(set (match_operand:DI 0 "memory_operand" "") | |
3785 | (sign_extend:DI (match_operand:SI 1 "register_operand" ""))) | |
6b29b0e2 JW |
3786 | (clobber (reg:CC 17)) |
3787 | (clobber (match_operand:SI 2 "register_operand" ""))] | |
d7a29404 | 3788 | "reload_completed" |
724d568a | 3789 | [(const_int 0)] |
9c530261 | 3790 | { |
724d568a JH |
3791 | split_di (&operands[0], 1, &operands[3], &operands[4]); |
3792 | ||
3793 | emit_move_insn (operands[3], operands[1]); | |
3794 | ||
3795 | /* Generate a cltd if possible and doing so it profitable. */ | |
3796 | if (true_regnum (operands[1]) == 0 | |
3797 | && true_regnum (operands[2]) == 1 | |
e075ae69 | 3798 | && (optimize_size || TARGET_USE_CLTD)) |
71a247f0 | 3799 | { |
e075ae69 | 3800 | emit_insn (gen_ashrsi3_31 (operands[2], operands[1], GEN_INT (31))); |
724d568a JH |
3801 | } |
3802 | else | |
3803 | { | |
3804 | emit_move_insn (operands[2], operands[1]); | |
e075ae69 | 3805 | emit_insn (gen_ashrsi3_31 (operands[2], operands[2], GEN_INT (31))); |
71a247f0 | 3806 | } |
724d568a JH |
3807 | emit_move_insn (operands[4], operands[2]); |
3808 | DONE; | |
0f40f9f7 | 3809 | }) |
9c530261 | 3810 | |
724d568a JH |
3811 | ;; Extend to register case. Optimize case where source and destination |
3812 | ;; registers match and cases where we can use cltd. | |
3813 | (define_split | |
3814 | [(set (match_operand:DI 0 "register_operand" "") | |
3815 | (sign_extend:DI (match_operand:SI 1 "register_operand" ""))) | |
6b29b0e2 JW |
3816 | (clobber (reg:CC 17)) |
3817 | (clobber (match_scratch:SI 2 ""))] | |
724d568a JH |
3818 | "reload_completed" |
3819 | [(const_int 0)] | |
724d568a JH |
3820 | { |
3821 | split_di (&operands[0], 1, &operands[3], &operands[4]); | |
3822 | ||
3823 | if (true_regnum (operands[3]) != true_regnum (operands[1])) | |
3824 | emit_move_insn (operands[3], operands[1]); | |
9c530261 | 3825 | |
724d568a JH |
3826 | /* Generate a cltd if possible and doing so it profitable. */ |
3827 | if (true_regnum (operands[3]) == 0 | |
e075ae69 | 3828 | && (optimize_size || TARGET_USE_CLTD)) |
724d568a | 3829 | { |
e075ae69 | 3830 | emit_insn (gen_ashrsi3_31 (operands[4], operands[3], GEN_INT (31))); |
724d568a JH |
3831 | DONE; |
3832 | } | |
3833 | ||
3834 | if (true_regnum (operands[4]) != true_regnum (operands[1])) | |
3835 | emit_move_insn (operands[4], operands[1]); | |
3836 | ||
e075ae69 | 3837 | emit_insn (gen_ashrsi3_31 (operands[4], operands[4], GEN_INT (31))); |
724d568a | 3838 | DONE; |
0f40f9f7 | 3839 | }) |
886c62d1 | 3840 | |
886c62d1 | 3841 | (define_insn "extendhisi2" |
e075ae69 RH |
3842 | [(set (match_operand:SI 0 "register_operand" "=*a,r") |
3843 | (sign_extend:SI (match_operand:HI 1 "nonimmediate_operand" "*0,rm")))] | |
886c62d1 | 3844 | "" |
886c62d1 | 3845 | { |
6ef67412 | 3846 | switch (get_attr_prefix_0f (insn)) |
e075ae69 | 3847 | { |
6ef67412 | 3848 | case 0: |
0f40f9f7 | 3849 | return "{cwtl|cwde}"; |
e075ae69 | 3850 | default: |
0f40f9f7 | 3851 | return "movs{wl|x}\t{%1,%0|%0, %1}"; |
e075ae69 | 3852 | } |
0f40f9f7 | 3853 | } |
e075ae69 | 3854 | [(set_attr "type" "imovx") |
6ef67412 JH |
3855 | (set_attr "mode" "SI") |
3856 | (set (attr "prefix_0f") | |
3857 | ;; movsx is short decodable while cwtl is vector decoded. | |
3858 | (if_then_else (and (eq_attr "cpu" "!k6") | |
3859 | (eq_attr "alternative" "0")) | |
3860 | (const_string "0") | |
3861 | (const_string "1"))) | |
3862 | (set (attr "modrm") | |
3863 | (if_then_else (eq_attr "prefix_0f" "0") | |
3864 | (const_string "0") | |
3865 | (const_string "1")))]) | |
886c62d1 | 3866 | |
123bf9e3 JH |
3867 | (define_insn "*extendhisi2_zext" |
3868 | [(set (match_operand:DI 0 "register_operand" "=*a,r") | |
3869 | (zero_extend:DI | |
3870 | (sign_extend:SI (match_operand:HI 1 "nonimmediate_operand" "*0,rm"))))] | |
3871 | "TARGET_64BIT" | |
123bf9e3 JH |
3872 | { |
3873 | switch (get_attr_prefix_0f (insn)) | |
3874 | { | |
3875 | case 0: | |
0f40f9f7 | 3876 | return "{cwtl|cwde}"; |
123bf9e3 | 3877 | default: |
0f40f9f7 | 3878 | return "movs{wl|x}\t{%1,%k0|%k0, %1}"; |
123bf9e3 | 3879 | } |
0f40f9f7 | 3880 | } |
123bf9e3 JH |
3881 | [(set_attr "type" "imovx") |
3882 | (set_attr "mode" "SI") | |
3883 | (set (attr "prefix_0f") | |
3884 | ;; movsx is short decodable while cwtl is vector decoded. | |
3885 | (if_then_else (and (eq_attr "cpu" "!k6") | |
3886 | (eq_attr "alternative" "0")) | |
3887 | (const_string "0") | |
3888 | (const_string "1"))) | |
3889 | (set (attr "modrm") | |
3890 | (if_then_else (eq_attr "prefix_0f" "0") | |
3891 | (const_string "0") | |
3892 | (const_string "1")))]) | |
3893 | ||
886c62d1 | 3894 | (define_insn "extendqihi2" |
e075ae69 RH |
3895 | [(set (match_operand:HI 0 "register_operand" "=*a,r") |
3896 | (sign_extend:HI (match_operand:QI 1 "nonimmediate_operand" "*0,qm")))] | |
886c62d1 | 3897 | "" |
886c62d1 | 3898 | { |
6ef67412 | 3899 | switch (get_attr_prefix_0f (insn)) |
e075ae69 | 3900 | { |
6ef67412 | 3901 | case 0: |
0f40f9f7 | 3902 | return "{cbtw|cbw}"; |
e075ae69 | 3903 | default: |
0f40f9f7 | 3904 | return "movs{bw|x}\t{%1,%0|%0, %1}"; |
e075ae69 | 3905 | } |
0f40f9f7 | 3906 | } |
e075ae69 | 3907 | [(set_attr "type" "imovx") |
6ef67412 JH |
3908 | (set_attr "mode" "HI") |
3909 | (set (attr "prefix_0f") | |
3910 | ;; movsx is short decodable while cwtl is vector decoded. | |
3911 | (if_then_else (and (eq_attr "cpu" "!k6") | |
3912 | (eq_attr "alternative" "0")) | |
3913 | (const_string "0") | |
3914 | (const_string "1"))) | |
3915 | (set (attr "modrm") | |
3916 | (if_then_else (eq_attr "prefix_0f" "0") | |
3917 | (const_string "0") | |
3918 | (const_string "1")))]) | |
886c62d1 JVA |
3919 | |
3920 | (define_insn "extendqisi2" | |
2ae0f82c SC |
3921 | [(set (match_operand:SI 0 "register_operand" "=r") |
3922 | (sign_extend:SI (match_operand:QI 1 "nonimmediate_operand" "qm")))] | |
886c62d1 | 3923 | "" |
0f40f9f7 | 3924 | "movs{bl|x}\t{%1,%0|%0, %1}" |
6ef67412 JH |
3925 | [(set_attr "type" "imovx") |
3926 | (set_attr "mode" "SI")]) | |
123bf9e3 JH |
3927 | |
3928 | (define_insn "*extendqisi2_zext" | |
3929 | [(set (match_operand:DI 0 "register_operand" "=r") | |
3930 | (zero_extend:DI | |
3931 | (sign_extend:SI (match_operand:QI 1 "nonimmediate_operand" "qm"))))] | |
3932 | "TARGET_64BIT" | |
0f40f9f7 | 3933 | "movs{bl|x}\t{%1,%k0|%k0, %1}" |
123bf9e3 JH |
3934 | [(set_attr "type" "imovx") |
3935 | (set_attr "mode" "SI")]) | |
886c62d1 JVA |
3936 | \f |
3937 | ;; Conversions between float and double. | |
3938 | ||
e075ae69 RH |
3939 | ;; These are all no-ops in the model used for the 80387. So just |
3940 | ;; emit moves. | |
6a4a5d95 | 3941 | |
e075ae69 | 3942 | ;; %%% Kill these when call knows how to work out a DFmode push earlier. |
6343a50e | 3943 | (define_insn "*dummy_extendsfdf2" |
e075ae69 | 3944 | [(set (match_operand:DF 0 "push_operand" "=<") |
42a0aa6f | 3945 | (float_extend:DF (match_operand:SF 1 "nonimmediate_operand" "fY")))] |
e075ae69 RH |
3946 | "0" |
3947 | "#") | |
6a4a5d95 JW |
3948 | |
3949 | (define_split | |
e075ae69 RH |
3950 | [(set (match_operand:DF 0 "push_operand" "") |
3951 | (float_extend:DF (match_operand:SF 1 "register_operand" "")))] | |
1b0c37d7 | 3952 | "!TARGET_64BIT && FP_REGNO_P (REGNO (operands[1]))" |
e075ae69 RH |
3953 | [(set (reg:SI 7) (plus:SI (reg:SI 7) (const_int -8))) |
3954 | (set (mem:DF (reg:SI 7)) (float_extend:DF (match_dup 1)))]) | |
0fcad513 | 3955 | |
123bf9e3 JH |
3956 | (define_split |
3957 | [(set (match_operand:DF 0 "push_operand" "") | |
3958 | (float_extend:DF (match_operand:SF 1 "register_operand" "")))] | |
1b0c37d7 | 3959 | "TARGET_64BIT && FP_REGNO_P (REGNO (operands[1]))" |
123bf9e3 JH |
3960 | [(set (reg:DI 7) (plus:DI (reg:DI 7) (const_int -8))) |
3961 | (set (mem:DF (reg:DI 7)) (float_extend:DF (match_dup 1)))]) | |
3962 | ||
6343a50e | 3963 | (define_insn "*dummy_extendsfxf2" |
e075ae69 RH |
3964 | [(set (match_operand:XF 0 "push_operand" "=<") |
3965 | (float_extend:XF (match_operand:SF 1 "nonimmediate_operand" "f")))] | |
3966 | "0" | |
3967 | "#") | |
e4ad1003 JW |
3968 | |
3969 | (define_split | |
e075ae69 RH |
3970 | [(set (match_operand:XF 0 "push_operand" "") |
3971 | (float_extend:XF (match_operand:SF 1 "register_operand" "")))] | |
1b0c37d7 | 3972 | "!TARGET_64BIT && FP_REGNO_P (REGNO (operands[1]))" |
e075ae69 | 3973 | [(set (reg:SI 7) (plus:SI (reg:SI 7) (const_int -12))) |
2b589241 JH |
3974 | (set (mem:XF (reg:SI 7)) (float_extend:XF (match_dup 1)))]) |
3975 | ||
3976 | (define_insn "*dummy_extendsftf2" | |
3977 | [(set (match_operand:TF 0 "push_operand" "=<") | |
3978 | (float_extend:TF (match_operand:SF 1 "nonimmediate_operand" "f")))] | |
3979 | "0" | |
3980 | "#") | |
3981 | ||
3982 | (define_split | |
3983 | [(set (match_operand:TF 0 "push_operand" "") | |
3984 | (float_extend:TF (match_operand:SF 1 "register_operand" "")))] | |
1b0c37d7 | 3985 | "!TARGET_64BIT && FP_REGNO_P (REGNO (operands[1]))" |
2b589241 | 3986 | [(set (reg:SI 7) (plus:SI (reg:SI 7) (const_int -16))) |
123bf9e3 JH |
3987 | (set (mem:TF (reg:SI 7)) (float_extend:TF (match_dup 1)))]) |
3988 | ||
3989 | (define_split | |
3990 | [(set (match_operand:TF 0 "push_operand" "") | |
3991 | (float_extend:TF (match_operand:SF 1 "register_operand" "")))] | |
1b0c37d7 | 3992 | "TARGET_64BIT && FP_REGNO_P (REGNO (operands[1]))" |
123bf9e3 JH |
3993 | [(set (reg:DI 7) (plus:DI (reg:DI 7) (const_int -16))) |
3994 | (set (mem:DF (reg:DI 7)) (float_extend:TF (match_dup 1)))]) | |
4fb21e90 | 3995 | |
6343a50e | 3996 | (define_insn "*dummy_extenddfxf2" |
e075ae69 RH |
3997 | [(set (match_operand:XF 0 "push_operand" "=<") |
3998 | (float_extend:XF (match_operand:DF 1 "nonimmediate_operand" "f")))] | |
3999 | "0" | |
4000 | "#") | |
e4ad1003 JW |
4001 | |
4002 | (define_split | |
e075ae69 RH |
4003 | [(set (match_operand:XF 0 "push_operand" "") |
4004 | (float_extend:XF (match_operand:DF 1 "register_operand" "")))] | |
1b0c37d7 | 4005 | "!TARGET_64BIT && FP_REGNO_P (REGNO (operands[1]))" |
e075ae69 | 4006 | [(set (reg:SI 7) (plus:SI (reg:SI 7) (const_int -12))) |
123bf9e3 | 4007 | (set (mem:DF (reg:SI 7)) (float_extend:XF (match_dup 1)))]) |
2b589241 JH |
4008 | |
4009 | (define_insn "*dummy_extenddftf2" | |
4010 | [(set (match_operand:TF 0 "push_operand" "=<") | |
4011 | (float_extend:TF (match_operand:DF 1 "nonimmediate_operand" "f")))] | |
4012 | "0" | |
4013 | "#") | |
4014 | ||
4015 | (define_split | |
4016 | [(set (match_operand:TF 0 "push_operand" "") | |
4017 | (float_extend:TF (match_operand:DF 1 "register_operand" "")))] | |
1b0c37d7 | 4018 | "!TARGET_64BIT && FP_REGNO_P (REGNO (operands[1]))" |
2b589241 JH |
4019 | [(set (reg:SI 7) (plus:SI (reg:SI 7) (const_int -16))) |
4020 | (set (mem:TF (reg:SI 7)) (float_extend:XF (match_dup 1)))]) | |
4fb21e90 | 4021 | |
123bf9e3 JH |
4022 | (define_split |
4023 | [(set (match_operand:TF 0 "push_operand" "") | |
4024 | (float_extend:TF (match_operand:DF 1 "register_operand" "")))] | |
1b0c37d7 | 4025 | "TARGET_64BIT && FP_REGNO_P (REGNO (operands[1]))" |
123bf9e3 | 4026 | [(set (reg:DI 7) (plus:DI (reg:DI 7) (const_int -16))) |
a2bafd20 | 4027 | (set (mem:TF (reg:DI 7)) (float_extend:TF (match_dup 1)))]) |
123bf9e3 | 4028 | |
f97d9ec3 JH |
4029 | (define_expand "extendsfdf2" |
4030 | [(set (match_operand:DF 0 "nonimmediate_operand" "") | |
4031 | (float_extend:DF (match_operand:SF 1 "nonimmediate_operand" "")))] | |
42a0aa6f | 4032 | "TARGET_80387 || TARGET_SSE2" |
f97d9ec3 JH |
4033 | { |
4034 | if (GET_CODE (operands[0]) == MEM && GET_CODE (operands[1]) == MEM) | |
34289d57 | 4035 | operands[1] = force_reg (SFmode, operands[1]); |
0f40f9f7 | 4036 | }) |
f97d9ec3 JH |
4037 | |
4038 | (define_insn "*extendsfdf2_1" | |
a811cc63 JH |
4039 | [(set (match_operand:DF 0 "nonimmediate_operand" "=f#Y,mf#Y,Y#f") |
4040 | (float_extend:DF (match_operand:SF 1 "nonimmediate_operand" "fm#Y,f#Y,mY#f")))] | |
42a0aa6f | 4041 | "(TARGET_80387 || TARGET_SSE2) |
f97d9ec3 | 4042 | && (GET_CODE (operands[0]) != MEM || GET_CODE (operands[1]) != MEM)" |
4fb21e90 | 4043 | { |
e075ae69 | 4044 | switch (which_alternative) |
4fb21e90 | 4045 | { |
e075ae69 | 4046 | case 0: |
0c174a68 AB |
4047 | if (REG_P (operands[1]) |
4048 | && find_regno_note (insn, REG_DEAD, REGNO (operands[1]))) | |
0f40f9f7 | 4049 | return "fstp\t%y0"; |
e075ae69 | 4050 | else if (STACK_TOP_P (operands[0])) |
0f40f9f7 | 4051 | return "fld%z1\t%y1"; |
e075ae69 | 4052 | else |
0f40f9f7 | 4053 | return "fst\t%y0"; |
886c62d1 | 4054 | |
e075ae69 RH |
4055 | case 1: |
4056 | if (find_regno_note (insn, REG_DEAD, REGNO (operands[1]))) | |
0f40f9f7 | 4057 | return "fstp%z0\t%y0"; |
10195bd8 | 4058 | |
e075ae69 | 4059 | else |
0f40f9f7 | 4060 | return "fst%z0\t%y0"; |
42a0aa6f | 4061 | case 2: |
0f40f9f7 | 4062 | return "cvtss2sd\t{%1, %0|%0, %1}"; |
4fb21e90 | 4063 | |
e075ae69 RH |
4064 | default: |
4065 | abort (); | |
4066 | } | |
0f40f9f7 | 4067 | } |
a811cc63 JH |
4068 | [(set_attr "type" "fmov,fmov,sse") |
4069 | (set_attr "mode" "SF,XF,DF")]) | |
42a0aa6f JH |
4070 | |
4071 | (define_insn "*extendsfdf2_1_sse_only" | |
4072 | [(set (match_operand:DF 0 "register_operand" "=Y") | |
4073 | (float_extend:DF (match_operand:SF 1 "nonimmediate_operand" "mY")))] | |
4074 | "!TARGET_80387 && TARGET_SSE2 | |
4075 | && (GET_CODE (operands[0]) != MEM || GET_CODE (operands[1]) != MEM)" | |
0f40f9f7 | 4076 | "cvtss2sd\t{%1, %0|%0, %1}" |
42a0aa6f JH |
4077 | [(set_attr "type" "sse") |
4078 | (set_attr "mode" "DF")]) | |
e075ae69 | 4079 | |
f97d9ec3 JH |
4080 | (define_expand "extendsfxf2" |
4081 | [(set (match_operand:XF 0 "nonimmediate_operand" "") | |
4082 | (float_extend:XF (match_operand:SF 1 "nonimmediate_operand" "")))] | |
1b0c37d7 | 4083 | "!TARGET_64BIT && TARGET_80387" |
f97d9ec3 JH |
4084 | { |
4085 | if (GET_CODE (operands[0]) == MEM && GET_CODE (operands[1]) == MEM) | |
34289d57 | 4086 | operands[1] = force_reg (SFmode, operands[1]); |
0f40f9f7 | 4087 | }) |
f97d9ec3 JH |
4088 | |
4089 | (define_insn "*extendsfxf2_1" | |
e075ae69 RH |
4090 | [(set (match_operand:XF 0 "nonimmediate_operand" "=f,m") |
4091 | (float_extend:XF (match_operand:SF 1 "nonimmediate_operand" "fm,f")))] | |
1b0c37d7 | 4092 | "!TARGET_64BIT && TARGET_80387 |
f97d9ec3 | 4093 | && (GET_CODE (operands[0]) != MEM || GET_CODE (operands[1]) != MEM)" |
10195bd8 | 4094 | { |
e075ae69 RH |
4095 | switch (which_alternative) |
4096 | { | |
4097 | case 0: | |
0c174a68 AB |
4098 | if (REG_P (operands[1]) |
4099 | && find_regno_note (insn, REG_DEAD, REGNO (operands[1]))) | |
0f40f9f7 | 4100 | return "fstp\t%y0"; |
e075ae69 | 4101 | else if (STACK_TOP_P (operands[0])) |
0f40f9f7 | 4102 | return "fld%z1\t%y1"; |
e075ae69 | 4103 | else |
0f40f9f7 | 4104 | return "fst\t%y0"; |
886c62d1 | 4105 | |
e075ae69 RH |
4106 | case 1: |
4107 | /* There is no non-popping store to memory for XFmode. So if | |
4108 | we need one, follow the store with a load. */ | |
4109 | if (! find_regno_note (insn, REG_DEAD, REGNO (operands[1]))) | |
0f40f9f7 | 4110 | return "fstp%z0\t%y0\n\tfld%z0\t%y0"; |
e075ae69 | 4111 | else |
0f40f9f7 | 4112 | return "fstp%z0\t%y0"; |
886c62d1 | 4113 | |
e075ae69 RH |
4114 | default: |
4115 | abort (); | |
4116 | } | |
0f40f9f7 | 4117 | } |
6ef67412 JH |
4118 | [(set_attr "type" "fmov") |
4119 | (set_attr "mode" "SF,XF")]) | |
886c62d1 | 4120 | |
2b589241 JH |
4121 | (define_expand "extendsftf2" |
4122 | [(set (match_operand:TF 0 "nonimmediate_operand" "") | |
4123 | (float_extend:TF (match_operand:SF 1 "nonimmediate_operand" "")))] | |
4124 | "TARGET_80387" | |
2b589241 JH |
4125 | { |
4126 | if (GET_CODE (operands[0]) == MEM && GET_CODE (operands[1]) == MEM) | |
4127 | operands[1] = force_reg (SFmode, operands[1]); | |
0f40f9f7 | 4128 | }) |
2b589241 JH |
4129 | |
4130 | (define_insn "*extendsftf2_1" | |
4131 | [(set (match_operand:TF 0 "nonimmediate_operand" "=f,m") | |
4132 | (float_extend:TF (match_operand:SF 1 "nonimmediate_operand" "fm,f")))] | |
4133 | "TARGET_80387 | |
4134 | && (GET_CODE (operands[0]) != MEM || GET_CODE (operands[1]) != MEM)" | |
2b589241 JH |
4135 | { |
4136 | switch (which_alternative) | |
4137 | { | |
4138 | case 0: | |
4139 | if (REG_P (operands[1]) | |
4140 | && find_regno_note (insn, REG_DEAD, REGNO (operands[1]))) | |
0f40f9f7 | 4141 | return "fstp\t%y0"; |
2b589241 | 4142 | else if (STACK_TOP_P (operands[0])) |
0f40f9f7 | 4143 | return "fld%z1\t%y1"; |
2b589241 | 4144 | else |
0f40f9f7 | 4145 | return "fst\t%y0"; |
2b589241 JH |
4146 | |
4147 | case 1: | |
4148 | /* There is no non-popping store to memory for XFmode. So if | |
4149 | we need one, follow the store with a load. */ | |
4150 | if (! find_regno_note (insn, REG_DEAD, REGNO (operands[1]))) | |
0f40f9f7 | 4151 | return "fstp%z0\t%y0\n\tfld%z0\t%y0"; |
2b589241 | 4152 | else |
0f40f9f7 | 4153 | return "fstp%z0\t%y0"; |
2b589241 JH |
4154 | |
4155 | default: | |
4156 | abort (); | |
4157 | } | |
0f40f9f7 | 4158 | } |
2b589241 JH |
4159 | [(set_attr "type" "fmov") |
4160 | (set_attr "mode" "SF,XF")]) | |
4161 | ||
f97d9ec3 JH |
4162 | (define_expand "extenddfxf2" |
4163 | [(set (match_operand:XF 0 "nonimmediate_operand" "") | |
4164 | (float_extend:XF (match_operand:DF 1 "nonimmediate_operand" "")))] | |
1b0c37d7 | 4165 | "!TARGET_64BIT && TARGET_80387" |
f97d9ec3 JH |
4166 | { |
4167 | if (GET_CODE (operands[0]) == MEM && GET_CODE (operands[1]) == MEM) | |
34289d57 | 4168 | operands[1] = force_reg (DFmode, operands[1]); |
0f40f9f7 | 4169 | }) |
f97d9ec3 JH |
4170 | |
4171 | (define_insn "*extenddfxf2_1" | |
e075ae69 RH |
4172 | [(set (match_operand:XF 0 "nonimmediate_operand" "=f,m") |
4173 | (float_extend:XF (match_operand:DF 1 "nonimmediate_operand" "fm,f")))] | |
1b0c37d7 | 4174 | "!TARGET_64BIT && TARGET_80387 |
f97d9ec3 | 4175 | && (GET_CODE (operands[0]) != MEM || GET_CODE (operands[1]) != MEM)" |
e075ae69 RH |
4176 | { |
4177 | switch (which_alternative) | |
4178 | { | |
4179 | case 0: | |
0c174a68 AB |
4180 | if (REG_P (operands[1]) |
4181 | && find_regno_note (insn, REG_DEAD, REGNO (operands[1]))) | |
0f40f9f7 | 4182 | return "fstp\t%y0"; |
e075ae69 | 4183 | else if (STACK_TOP_P (operands[0])) |
0f40f9f7 | 4184 | return "fld%z1\t%y1"; |
e075ae69 | 4185 | else |
0f40f9f7 | 4186 | return "fst\t%y0"; |
bc725565 | 4187 | |
e075ae69 RH |
4188 | case 1: |
4189 | /* There is no non-popping store to memory for XFmode. So if | |
4190 | we need one, follow the store with a load. */ | |
4191 | if (! find_regno_note (insn, REG_DEAD, REGNO (operands[1]))) | |
0f40f9f7 | 4192 | return "fstp%z0\t%y0\n\tfld%z0\t%y0"; |
e075ae69 | 4193 | else |
0f40f9f7 | 4194 | return "fstp%z0\t%y0"; |
bc725565 | 4195 | |
e075ae69 RH |
4196 | default: |
4197 | abort (); | |
4198 | } | |
0f40f9f7 | 4199 | } |
6ef67412 JH |
4200 | [(set_attr "type" "fmov") |
4201 | (set_attr "mode" "DF,XF")]) | |
bc725565 | 4202 | |
2b589241 JH |
4203 | (define_expand "extenddftf2" |
4204 | [(set (match_operand:TF 0 "nonimmediate_operand" "") | |
4205 | (float_extend:TF (match_operand:DF 1 "nonimmediate_operand" "")))] | |
4206 | "TARGET_80387" | |
2b589241 JH |
4207 | { |
4208 | if (GET_CODE (operands[0]) == MEM && GET_CODE (operands[1]) == MEM) | |
4209 | operands[1] = force_reg (DFmode, operands[1]); | |
0f40f9f7 | 4210 | }) |
2b589241 JH |
4211 | |
4212 | (define_insn "*extenddftf2_1" | |
4213 | [(set (match_operand:TF 0 "nonimmediate_operand" "=f,m") | |
4214 | (float_extend:TF (match_operand:DF 1 "nonimmediate_operand" "fm,f")))] | |
4215 | "TARGET_80387 | |
4216 | && (GET_CODE (operands[0]) != MEM || GET_CODE (operands[1]) != MEM)" | |
2b589241 JH |
4217 | { |
4218 | switch (which_alternative) | |
4219 | { | |
4220 | case 0: | |
4221 | if (REG_P (operands[1]) | |
4222 | && find_regno_note (insn, REG_DEAD, REGNO (operands[1]))) | |
0f40f9f7 | 4223 | return "fstp\t%y0"; |
2b589241 | 4224 | else if (STACK_TOP_P (operands[0])) |
0f40f9f7 | 4225 | return "fld%z1\t%y1"; |
2b589241 | 4226 | else |
0f40f9f7 | 4227 | return "fst\t%y0"; |
2b589241 JH |
4228 | |
4229 | case 1: | |
4230 | /* There is no non-popping store to memory for XFmode. So if | |
4231 | we need one, follow the store with a load. */ | |
4232 | if (! find_regno_note (insn, REG_DEAD, REGNO (operands[1]))) | |
0f40f9f7 | 4233 | return "fstp%z0\t%y0\n\tfld%z0\t%y0"; |
2b589241 | 4234 | else |
0f40f9f7 | 4235 | return "fstp%z0\t%y0"; |
2b589241 JH |
4236 | |
4237 | default: | |
4238 | abort (); | |
4239 | } | |
0f40f9f7 | 4240 | } |
2b589241 JH |
4241 | [(set_attr "type" "fmov") |
4242 | (set_attr "mode" "DF,XF")]) | |
4243 | ||
e075ae69 RH |
4244 | ;; %%% This seems bad bad news. |
4245 | ;; This cannot output into an f-reg because there is no way to be sure | |
4246 | ;; of truncating in that case. Otherwise this is just like a simple move | |
4247 | ;; insn. So we pretend we can output to a reg in order to get better | |
4248 | ;; register preferencing, but we really use a stack slot. | |
886c62d1 | 4249 | |
e075ae69 RH |
4250 | (define_expand "truncdfsf2" |
4251 | [(parallel [(set (match_operand:SF 0 "nonimmediate_operand" "") | |
4252 | (float_truncate:SF | |
4253 | (match_operand:DF 1 "register_operand" ""))) | |
4254 | (clobber (match_dup 2))])] | |
42a0aa6f JH |
4255 | "TARGET_80387 || TARGET_SSE2" |
4256 | " | |
4257 | if (TARGET_80387) | |
4258 | operands[2] = assign_386_stack_local (SFmode, 0); | |
4259 | else | |
4260 | { | |
4261 | emit_insn (gen_truncdfsf2_sse_only (operands[0], operands[1])); | |
4262 | DONE; | |
4263 | } | |
4264 | ") | |
bc725565 | 4265 | |
e075ae69 | 4266 | (define_insn "*truncdfsf2_1" |
46ed7963 | 4267 | [(set (match_operand:SF 0 "nonimmediate_operand" "=m,?f#rx,?r#fx,?x#rf") |
e075ae69 | 4268 | (float_truncate:SF |
46ed7963 JH |
4269 | (match_operand:DF 1 "register_operand" "f,f,f,f"))) |
4270 | (clobber (match_operand:SF 2 "memory_operand" "=X,m,m,m"))] | |
42a0aa6f | 4271 | "TARGET_80387 && !TARGET_SSE2" |
e075ae69 RH |
4272 | { |
4273 | switch (which_alternative) | |
4274 | { | |
4275 | case 0: | |
4276 | if (find_regno_note (insn, REG_DEAD, REGNO (operands[1]))) | |
0f40f9f7 | 4277 | return "fstp%z0\t%y0"; |
e075ae69 | 4278 | else |
0f40f9f7 | 4279 | return "fst%z0\t%y0"; |
46ed7963 JH |
4280 | default: |
4281 | abort (); | |
e075ae69 | 4282 | } |
0f40f9f7 | 4283 | } |
46ed7963 JH |
4284 | [(set_attr "type" "fmov,multi,multi,multi") |
4285 | (set_attr "mode" "SF,SF,SF,SF")]) | |
42a0aa6f JH |
4286 | |
4287 | (define_insn "*truncdfsf2_1_sse" | |
46ed7963 | 4288 | [(set (match_operand:SF 0 "nonimmediate_operand" "=*!m,?f#rx,?r#fx,?x#rf,Y") |
42a0aa6f | 4289 | (float_truncate:SF |
46ed7963 JH |
4290 | (match_operand:DF 1 "nonimmediate_operand" "f,f,f,f,mY"))) |
4291 | (clobber (match_operand:SF 2 "memory_operand" "=X,m,m,m,X"))] | |
42a0aa6f | 4292 | "TARGET_80387 && TARGET_SSE2" |
42a0aa6f JH |
4293 | { |
4294 | switch (which_alternative) | |
4295 | { | |
4296 | case 0: | |
4297 | if (find_regno_note (insn, REG_DEAD, REGNO (operands[1]))) | |
0f40f9f7 | 4298 | return "fstp%z0\t%y0"; |
42a0aa6f | 4299 | else |
0f40f9f7 | 4300 | return "fst%z0\t%y0"; |
46ed7963 | 4301 | case 4: |
0f40f9f7 | 4302 | return "cvtsd2ss\t{%1, %0|%0, %1}"; |
46ed7963 JH |
4303 | default: |
4304 | abort (); | |
42a0aa6f | 4305 | } |
0f40f9f7 | 4306 | } |
46ed7963 JH |
4307 | [(set_attr "type" "fmov,multi,multi,multi,sse") |
4308 | (set_attr "mode" "SF,SF,SF,SF,DF")]) | |
53b5ce19 | 4309 | |
e075ae69 | 4310 | (define_insn "*truncdfsf2_2" |
79005df5 | 4311 | [(set (match_operand:SF 0 "nonimmediate_operand" "=Y,!m") |
42a0aa6f | 4312 | (float_truncate:SF |
79005df5 JH |
4313 | (match_operand:DF 1 "nonimmediate_operand" "mY,f")))] |
4314 | "TARGET_80387 && TARGET_SSE2 | |
4315 | && (GET_CODE (operands[0]) != MEM || GET_CODE (operands[1]) != MEM)" | |
42a0aa6f JH |
4316 | { |
4317 | switch (which_alternative) | |
4318 | { | |
4319 | case 0: | |
0f40f9f7 | 4320 | return "cvtsd2ss\t{%1, %0|%0, %1}"; |
79005df5 | 4321 | case 1: |
42a0aa6f | 4322 | if (find_regno_note (insn, REG_DEAD, REGNO (operands[1]))) |
0f40f9f7 | 4323 | return "fstp%z0\t%y0"; |
42a0aa6f | 4324 | else |
0f40f9f7 ZW |
4325 | return "fst%z0\t%y0"; |
4326 | default: | |
4327 | abort (); | |
42a0aa6f | 4328 | } |
0f40f9f7 | 4329 | } |
79005df5 JH |
4330 | [(set_attr "type" "sse,fmov") |
4331 | (set_attr "mode" "DF,SF")]) | |
42a0aa6f JH |
4332 | |
4333 | (define_insn "truncdfsf2_3" | |
cc2e591b | 4334 | [(set (match_operand:SF 0 "memory_operand" "=m") |
e075ae69 RH |
4335 | (float_truncate:SF |
4336 | (match_operand:DF 1 "register_operand" "f")))] | |
53b5ce19 | 4337 | "TARGET_80387" |
e075ae69 RH |
4338 | { |
4339 | if (find_regno_note (insn, REG_DEAD, REGNO (operands[1]))) | |
0f40f9f7 | 4340 | return "fstp%z0\t%y0"; |
e075ae69 | 4341 | else |
0f40f9f7 ZW |
4342 | return "fst%z0\t%y0"; |
4343 | } | |
6ef67412 JH |
4344 | [(set_attr "type" "fmov") |
4345 | (set_attr "mode" "SF")]) | |
53b5ce19 | 4346 | |
42a0aa6f JH |
4347 | (define_insn "truncdfsf2_sse_only" |
4348 | [(set (match_operand:SF 0 "register_operand" "=Y") | |
4349 | (float_truncate:SF | |
4350 | (match_operand:DF 1 "nonimmediate_operand" "mY")))] | |
4351 | "!TARGET_80387 && TARGET_SSE2" | |
0f40f9f7 | 4352 | "cvtsd2ss\t{%1, %0|%0, %1}" |
42a0aa6f JH |
4353 | [(set_attr "type" "sse") |
4354 | (set_attr "mode" "DF")]) | |
4355 | ||
53b5ce19 | 4356 | (define_split |
e075ae69 RH |
4357 | [(set (match_operand:SF 0 "memory_operand" "") |
4358 | (float_truncate:SF | |
4359 | (match_operand:DF 1 "register_operand" ""))) | |
4360 | (clobber (match_operand:SF 2 "memory_operand" ""))] | |
4361 | "TARGET_80387" | |
4362 | [(set (match_dup 0) (float_truncate:SF (match_dup 1)))] | |
53b5ce19 JW |
4363 | "") |
4364 | ||
42a0aa6f JH |
4365 | (define_split |
4366 | [(set (match_operand:SF 0 "nonimmediate_operand" "") | |
4367 | (float_truncate:SF | |
4368 | (match_operand:DF 1 "nonimmediate_operand" ""))) | |
4369 | (clobber (match_operand 2 "" ""))] | |
05b432db JH |
4370 | "TARGET_80387 && reload_completed |
4371 | && !FP_REG_P (operands[0]) && !FP_REG_P (operands[1])" | |
42a0aa6f JH |
4372 | [(set (match_dup 0) (float_truncate:SF (match_dup 1)))] |
4373 | "") | |
4374 | ||
53b5ce19 JW |
4375 | (define_split |
4376 | [(set (match_operand:SF 0 "register_operand" "") | |
e075ae69 RH |
4377 | (float_truncate:SF |
4378 | (match_operand:DF 1 "register_operand" ""))) | |
4379 | (clobber (match_operand:SF 2 "memory_operand" ""))] | |
42a0aa6f | 4380 | "TARGET_80387 && reload_completed |
46ed7963 | 4381 | && FP_REG_P (operands[1])" |
e075ae69 RH |
4382 | [(set (match_dup 2) (float_truncate:SF (match_dup 1))) |
4383 | (set (match_dup 0) (match_dup 2))] | |
53b5ce19 JW |
4384 | "") |
4385 | ||
e075ae69 RH |
4386 | (define_expand "truncxfsf2" |
4387 | [(parallel [(set (match_operand:SF 0 "nonimmediate_operand" "") | |
4388 | (float_truncate:SF | |
4389 | (match_operand:XF 1 "register_operand" ""))) | |
4390 | (clobber (match_dup 2))])] | |
1b0c37d7 | 4391 | "!TARGET_64BIT && TARGET_80387" |
e075ae69 | 4392 | "operands[2] = assign_386_stack_local (SFmode, 0);") |
53b5ce19 | 4393 | |
e075ae69 | 4394 | (define_insn "*truncxfsf2_1" |
46ed7963 | 4395 | [(set (match_operand:SF 0 "nonimmediate_operand" "=m,?f#rx,?r#fx,?x#rf") |
e075ae69 | 4396 | (float_truncate:SF |
46ed7963 JH |
4397 | (match_operand:XF 1 "register_operand" "f,f,f,f"))) |
4398 | (clobber (match_operand:SF 2 "memory_operand" "=X,m,m,m"))] | |
1b0c37d7 | 4399 | "!TARGET_64BIT && TARGET_80387" |
e075ae69 RH |
4400 | { |
4401 | switch (which_alternative) | |
4402 | { | |
4403 | case 0: | |
4404 | if (find_regno_note (insn, REG_DEAD, REGNO (operands[1]))) | |
0f40f9f7 | 4405 | return "fstp%z0\t%y0"; |
e075ae69 | 4406 | else |
0f40f9f7 | 4407 | return "fst%z0\t%y0"; |
46ed7963 JH |
4408 | default: |
4409 | abort(); | |
e075ae69 | 4410 | } |
0f40f9f7 | 4411 | } |
46ed7963 | 4412 | [(set_attr "type" "fmov,multi,multi,multi") |
6ef67412 | 4413 | (set_attr "mode" "SF")]) |
886c62d1 | 4414 | |
e075ae69 | 4415 | (define_insn "*truncxfsf2_2" |
dd80b906 | 4416 | [(set (match_operand:SF 0 "memory_operand" "=m") |
e075ae69 RH |
4417 | (float_truncate:SF |
4418 | (match_operand:XF 1 "register_operand" "f")))] | |
1b0c37d7 | 4419 | "!TARGET_64BIT && TARGET_80387" |
e075ae69 RH |
4420 | { |
4421 | if (find_regno_note (insn, REG_DEAD, REGNO (operands[1]))) | |
0f40f9f7 | 4422 | return "fstp%z0\t%y0"; |
e075ae69 | 4423 | else |
0f40f9f7 ZW |
4424 | return "fst%z0\t%y0"; |
4425 | } | |
6ef67412 JH |
4426 | [(set_attr "type" "fmov") |
4427 | (set_attr "mode" "SF")]) | |
bc725565 JW |
4428 | |
4429 | (define_split | |
e075ae69 RH |
4430 | [(set (match_operand:SF 0 "memory_operand" "") |
4431 | (float_truncate:SF | |
4432 | (match_operand:XF 1 "register_operand" ""))) | |
4433 | (clobber (match_operand:SF 2 "memory_operand" ""))] | |
4434 | "TARGET_80387" | |
4435 | [(set (match_dup 0) (float_truncate:SF (match_dup 1)))] | |
886c62d1 JVA |
4436 | "") |
4437 | ||
bc725565 | 4438 | (define_split |
6a4a5d95 | 4439 | [(set (match_operand:SF 0 "register_operand" "") |
e075ae69 RH |
4440 | (float_truncate:SF |
4441 | (match_operand:XF 1 "register_operand" ""))) | |
4442 | (clobber (match_operand:SF 2 "memory_operand" ""))] | |
bc725565 | 4443 | "TARGET_80387 && reload_completed" |
e075ae69 RH |
4444 | [(set (match_dup 2) (float_truncate:SF (match_dup 1))) |
4445 | (set (match_dup 0) (match_dup 2))] | |
886c62d1 JVA |
4446 | "") |
4447 | ||
2b589241 JH |
4448 | (define_expand "trunctfsf2" |
4449 | [(parallel [(set (match_operand:SF 0 "nonimmediate_operand" "") | |
4450 | (float_truncate:SF | |
4451 | (match_operand:TF 1 "register_operand" ""))) | |
4452 | (clobber (match_dup 2))])] | |
4453 | "TARGET_80387" | |
4454 | "operands[2] = assign_386_stack_local (SFmode, 0);") | |
4455 | ||
4456 | (define_insn "*trunctfsf2_1" | |
46ed7963 | 4457 | [(set (match_operand:SF 0 "nonimmediate_operand" "=m,?f#rx,?r#fx,?x#rf") |
2b589241 | 4458 | (float_truncate:SF |
46ed7963 JH |
4459 | (match_operand:TF 1 "register_operand" "f,f,f,f"))) |
4460 | (clobber (match_operand:SF 2 "memory_operand" "=X,m,m,m"))] | |
2b589241 | 4461 | "TARGET_80387" |
2b589241 JH |
4462 | { |
4463 | switch (which_alternative) | |
4464 | { | |
4465 | case 0: | |
4466 | if (find_regno_note (insn, REG_DEAD, REGNO (operands[1]))) | |
0f40f9f7 | 4467 | return "fstp%z0\t%y0"; |
2b589241 | 4468 | else |
0f40f9f7 | 4469 | return "fst%z0\t%y0"; |
46ed7963 JH |
4470 | default: |
4471 | abort(); | |
2b589241 | 4472 | } |
0f40f9f7 | 4473 | } |
46ed7963 | 4474 | [(set_attr "type" "fmov,multi,multi,multi") |
2b589241 JH |
4475 | (set_attr "mode" "SF")]) |
4476 | ||
1e07edd3 | 4477 | (define_insn "*trunctfsf2_2" |
cc2e591b | 4478 | [(set (match_operand:SF 0 "memory_operand" "=m") |
2b589241 JH |
4479 | (float_truncate:SF |
4480 | (match_operand:TF 1 "register_operand" "f")))] | |
4481 | "TARGET_80387" | |
2b589241 JH |
4482 | { |
4483 | if (find_regno_note (insn, REG_DEAD, REGNO (operands[1]))) | |
0f40f9f7 | 4484 | return "fstp%z0\t%y0"; |
2b589241 | 4485 | else |
0f40f9f7 ZW |
4486 | return "fst%z0\t%y0"; |
4487 | } | |
2b589241 JH |
4488 | [(set_attr "type" "fmov") |
4489 | (set_attr "mode" "SF")]) | |
4490 | ||
4491 | (define_split | |
4492 | [(set (match_operand:SF 0 "memory_operand" "") | |
4493 | (float_truncate:SF | |
4494 | (match_operand:TF 1 "register_operand" ""))) | |
4495 | (clobber (match_operand:SF 2 "memory_operand" ""))] | |
4496 | "TARGET_80387" | |
4497 | [(set (match_dup 0) (float_truncate:SF (match_dup 1)))] | |
4498 | "") | |
4499 | ||
4500 | (define_split | |
4501 | [(set (match_operand:SF 0 "register_operand" "") | |
4502 | (float_truncate:SF | |
4503 | (match_operand:TF 1 "register_operand" ""))) | |
4504 | (clobber (match_operand:SF 2 "memory_operand" ""))] | |
4505 | "TARGET_80387 && reload_completed" | |
4506 | [(set (match_dup 2) (float_truncate:SF (match_dup 1))) | |
4507 | (set (match_dup 0) (match_dup 2))] | |
4508 | "") | |
4509 | ||
4510 | ||
e075ae69 RH |
4511 | (define_expand "truncxfdf2" |
4512 | [(parallel [(set (match_operand:DF 0 "nonimmediate_operand" "") | |
4513 | (float_truncate:DF | |
4514 | (match_operand:XF 1 "register_operand" ""))) | |
4515 | (clobber (match_dup 2))])] | |
1b0c37d7 | 4516 | "!TARGET_64BIT && TARGET_80387" |
e075ae69 | 4517 | "operands[2] = assign_386_stack_local (DFmode, 0);") |
bc725565 | 4518 | |
e075ae69 | 4519 | (define_insn "*truncxfdf2_1" |
46ed7963 | 4520 | [(set (match_operand:DF 0 "nonimmediate_operand" "=m,?f#rY,?r#fY,?Y#rf") |
e075ae69 | 4521 | (float_truncate:DF |
46ed7963 JH |
4522 | (match_operand:XF 1 "register_operand" "f,f,f,f"))) |
4523 | (clobber (match_operand:DF 2 "memory_operand" "=X,m,m,m"))] | |
1b0c37d7 | 4524 | "!TARGET_64BIT && TARGET_80387" |
e075ae69 RH |
4525 | { |
4526 | switch (which_alternative) | |
4527 | { | |
4528 | case 0: | |
4529 | if (find_regno_note (insn, REG_DEAD, REGNO (operands[1]))) | |
0f40f9f7 | 4530 | return "fstp%z0\t%y0"; |
e075ae69 | 4531 | else |
0f40f9f7 | 4532 | return "fst%z0\t%y0"; |
46ed7963 JH |
4533 | default: |
4534 | abort(); | |
e075ae69 RH |
4535 | } |
4536 | abort (); | |
0f40f9f7 | 4537 | } |
46ed7963 | 4538 | [(set_attr "type" "fmov,multi,multi,multi") |
6ef67412 | 4539 | (set_attr "mode" "DF")]) |
bc725565 | 4540 | |
e075ae69 RH |
4541 | (define_insn "*truncxfdf2_2" |
4542 | [(set (match_operand:DF 0 "memory_operand" "=m") | |
4543 | (float_truncate:DF | |
4544 | (match_operand:XF 1 "register_operand" "f")))] | |
1b0c37d7 | 4545 | "!TARGET_64BIT && TARGET_80387" |
e075ae69 RH |
4546 | { |
4547 | if (find_regno_note (insn, REG_DEAD, REGNO (operands[1]))) | |
0f40f9f7 | 4548 | return "fstp%z0\t%y0"; |
e075ae69 | 4549 | else |
0f40f9f7 ZW |
4550 | return "fst%z0\t%y0"; |
4551 | } | |
6ef67412 JH |
4552 | [(set_attr "type" "fmov") |
4553 | (set_attr "mode" "DF")]) | |
bc725565 JW |
4554 | |
4555 | (define_split | |
e075ae69 RH |
4556 | [(set (match_operand:DF 0 "memory_operand" "") |
4557 | (float_truncate:DF | |
4558 | (match_operand:XF 1 "register_operand" ""))) | |
4559 | (clobber (match_operand:DF 2 "memory_operand" ""))] | |
ca285e07 JH |
4560 | "TARGET_80387" |
4561 | [(set (match_dup 0) (float_truncate:DF (match_dup 1)))] | |
4fb21e90 JVA |
4562 | "") |
4563 | ||
bc725565 | 4564 | (define_split |
6a4a5d95 | 4565 | [(set (match_operand:DF 0 "register_operand" "") |
e075ae69 RH |
4566 | (float_truncate:DF |
4567 | (match_operand:XF 1 "register_operand" ""))) | |
4568 | (clobber (match_operand:DF 2 "memory_operand" ""))] | |
bc725565 | 4569 | "TARGET_80387 && reload_completed" |
ca285e07 | 4570 | [(set (match_dup 2) (float_truncate:DF (match_dup 1))) |
e075ae69 | 4571 | (set (match_dup 0) (match_dup 2))] |
4fb21e90 | 4572 | "") |
ca285e07 | 4573 | |
2b589241 JH |
4574 | (define_expand "trunctfdf2" |
4575 | [(parallel [(set (match_operand:DF 0 "nonimmediate_operand" "") | |
4576 | (float_truncate:DF | |
4577 | (match_operand:TF 1 "register_operand" ""))) | |
4578 | (clobber (match_dup 2))])] | |
4579 | "TARGET_80387" | |
4580 | "operands[2] = assign_386_stack_local (DFmode, 0);") | |
4581 | ||
4582 | (define_insn "*trunctfdf2_1" | |
46ed7963 | 4583 | [(set (match_operand:DF 0 "nonimmediate_operand" "=m,?f#rY,?r#fY,?Y#rf") |
2b589241 | 4584 | (float_truncate:DF |
46ed7963 JH |
4585 | (match_operand:TF 1 "register_operand" "f,f,f,f"))) |
4586 | (clobber (match_operand:DF 2 "memory_operand" "=X,m,m,m"))] | |
2b589241 | 4587 | "TARGET_80387" |
2b589241 JH |
4588 | { |
4589 | switch (which_alternative) | |
4590 | { | |
4591 | case 0: | |
4592 | if (find_regno_note (insn, REG_DEAD, REGNO (operands[1]))) | |
0f40f9f7 | 4593 | return "fstp%z0\t%y0"; |
2b589241 | 4594 | else |
0f40f9f7 | 4595 | return "fst%z0\t%y0"; |
46ed7963 JH |
4596 | default: |
4597 | abort(); | |
2b589241 JH |
4598 | } |
4599 | abort (); | |
0f40f9f7 | 4600 | } |
46ed7963 | 4601 | [(set_attr "type" "fmov,multi,multi,multi") |
2b589241 JH |
4602 | (set_attr "mode" "DF")]) |
4603 | ||
46ed7963 | 4604 | (define_insn "*trunctfdf2_2" |
2b589241 JH |
4605 | [(set (match_operand:DF 0 "memory_operand" "=m") |
4606 | (float_truncate:DF | |
4607 | (match_operand:TF 1 "register_operand" "f")))] | |
4608 | "TARGET_80387" | |
2b589241 JH |
4609 | { |
4610 | if (find_regno_note (insn, REG_DEAD, REGNO (operands[1]))) | |
0f40f9f7 | 4611 | return "fstp%z0\t%y0"; |
2b589241 | 4612 | else |
0f40f9f7 ZW |
4613 | return "fst%z0\t%y0"; |
4614 | } | |
2b589241 JH |
4615 | [(set_attr "type" "fmov") |
4616 | (set_attr "mode" "DF")]) | |
4617 | ||
4618 | (define_split | |
4619 | [(set (match_operand:DF 0 "memory_operand" "") | |
4620 | (float_truncate:DF | |
4621 | (match_operand:TF 1 "register_operand" ""))) | |
4622 | (clobber (match_operand:DF 2 "memory_operand" ""))] | |
4623 | "TARGET_80387" | |
4624 | [(set (match_dup 0) (float_truncate:DF (match_dup 1)))] | |
4625 | "") | |
4626 | ||
4627 | (define_split | |
4628 | [(set (match_operand:DF 0 "register_operand" "") | |
4629 | (float_truncate:DF | |
4630 | (match_operand:TF 1 "register_operand" ""))) | |
4631 | (clobber (match_operand:DF 2 "memory_operand" ""))] | |
4632 | "TARGET_80387 && reload_completed" | |
4633 | [(set (match_dup 2) (float_truncate:DF (match_dup 1))) | |
4634 | (set (match_dup 0) (match_dup 2))] | |
4635 | "") | |
4636 | ||
e075ae69 RH |
4637 | \f |
4638 | ;; %%% Break up all these bad boys. | |
4fb21e90 | 4639 | |
e075ae69 RH |
4640 | ;; Signed conversion to DImode. |
4641 | ||
2b589241 | 4642 | (define_expand "fix_truncxfdi2" |
22fb740d JH |
4643 | [(set (match_operand:DI 0 "nonimmediate_operand" "") |
4644 | (fix:DI (match_operand:XF 1 "register_operand" "")))] | |
1b0c37d7 | 4645 | "!TARGET_64BIT && TARGET_80387" |
22fb740d | 4646 | "") |
2b589241 JH |
4647 | |
4648 | (define_expand "fix_trunctfdi2" | |
22fb740d JH |
4649 | [(set (match_operand:DI 0 "nonimmediate_operand" "") |
4650 | (fix:DI (match_operand:TF 1 "register_operand" "")))] | |
bc725565 | 4651 | "TARGET_80387" |
22fb740d | 4652 | "") |
bc725565 | 4653 | |
e075ae69 | 4654 | (define_expand "fix_truncdfdi2" |
22fb740d JH |
4655 | [(set (match_operand:DI 0 "nonimmediate_operand" "") |
4656 | (fix:DI (match_operand:DF 1 "register_operand" "")))] | |
46ed7963 | 4657 | "TARGET_80387 || (TARGET_SSE2 && TARGET_64BIT)" |
46ed7963 | 4658 | { |
1b0c37d7 | 4659 | if (TARGET_64BIT && TARGET_SSE2) |
46ed7963 JH |
4660 | { |
4661 | rtx out = REG_P (operands[0]) ? operands[0] : gen_reg_rtx (DImode); | |
4662 | emit_insn (gen_fix_truncdfdi_sse (out, operands[1])); | |
4663 | if (out != operands[0]) | |
4664 | emit_move_insn (operands[0], out); | |
4665 | DONE; | |
4666 | } | |
0f40f9f7 | 4667 | }) |
53b5ce19 | 4668 | |
e075ae69 | 4669 | (define_expand "fix_truncsfdi2" |
22fb740d JH |
4670 | [(set (match_operand:DI 0 "nonimmediate_operand" "") |
4671 | (fix:DI (match_operand:SF 1 "register_operand" "")))] | |
46ed7963 | 4672 | "TARGET_80387 || (TARGET_SSE && TARGET_64BIT)" |
46ed7963 | 4673 | { |
22fb740d | 4674 | if (TARGET_SSE && TARGET_64BIT) |
46ed7963 JH |
4675 | { |
4676 | rtx out = REG_P (operands[0]) ? operands[0] : gen_reg_rtx (DImode); | |
4677 | emit_insn (gen_fix_truncsfdi_sse (out, operands[1])); | |
4678 | if (out != operands[0]) | |
4679 | emit_move_insn (operands[0], out); | |
4680 | DONE; | |
4681 | } | |
0f40f9f7 | 4682 | }) |
e075ae69 | 4683 | |
22fb740d JH |
4684 | ;; See the comments in i386.h near OPTIMIZE_MODE_SWITCHING for the description |
4685 | ;; of the machinery. | |
4686 | (define_insn_and_split "*fix_truncdi_1" | |
4687 | [(set (match_operand:DI 0 "nonimmediate_operand" "=m,?r") | |
4688 | (fix:DI (match_operand 1 "register_operand" "f,f")))] | |
4689 | "TARGET_80387 && FLOAT_MODE_P (GET_MODE (operands[1])) | |
4690 | && !reload_completed && !reload_in_progress | |
4691 | && (!SSE_FLOAT_MODE_P (GET_MODE (operands[1])) || !TARGET_64BIT)" | |
4692 | "#" | |
14f73b5a | 4693 | "&& 1" |
22fb740d JH |
4694 | [(const_int 0)] |
4695 | { | |
4696 | operands[2] = assign_386_stack_local (HImode, 1); | |
4697 | operands[3] = assign_386_stack_local (HImode, 2); | |
4698 | if (memory_operand (operands[0], VOIDmode)) | |
4699 | emit_insn (gen_fix_truncdi_memory (operands[0], operands[1], | |
4700 | operands[2], operands[3])); | |
4701 | else | |
4702 | { | |
4703 | operands[4] = assign_386_stack_local (DImode, 0); | |
4704 | emit_insn (gen_fix_truncdi_nomemory (operands[0], operands[1], | |
4705 | operands[2], operands[3], | |
4706 | operands[4])); | |
4707 | } | |
4708 | DONE; | |
4709 | } | |
4710 | [(set_attr "type" "fistp")]) | |
4711 | ||
4712 | (define_insn "fix_truncdi_nomemory" | |
c76aab11 | 4713 | [(set (match_operand:DI 0 "nonimmediate_operand" "=m,?r") |
e075ae69 | 4714 | (fix:DI (match_operand 1 "register_operand" "f,f"))) |
7a2e09f4 JH |
4715 | (use (match_operand:HI 2 "memory_operand" "m,m")) |
4716 | (use (match_operand:HI 3 "memory_operand" "m,m")) | |
4717 | (clobber (match_operand:DI 4 "memory_operand" "=m,m")) | |
22fb740d | 4718 | (clobber (match_scratch:DF 5 "=&1f,&1f"))] |
46ed7963 | 4719 | "TARGET_80387 && FLOAT_MODE_P (GET_MODE (operands[1])) |
22fb740d JH |
4720 | && (!SSE_FLOAT_MODE_P (GET_MODE (operands[1])) || !TARGET_64BIT)" |
4721 | "#" | |
4722 | [(set_attr "type" "fistp")]) | |
4723 | ||
4724 | (define_insn "fix_truncdi_memory" | |
4725 | [(set (match_operand:DI 0 "memory_operand" "=m") | |
4726 | (fix:DI (match_operand 1 "register_operand" "f"))) | |
4727 | (use (match_operand:HI 2 "memory_operand" "m")) | |
4728 | (use (match_operand:HI 3 "memory_operand" "m")) | |
4729 | (clobber (match_scratch:DF 4 "=&1f"))] | |
4730 | "TARGET_80387 && FLOAT_MODE_P (GET_MODE (operands[1])) | |
4731 | && (!SSE_FLOAT_MODE_P (GET_MODE (operands[1])) || !TARGET_64BIT)" | |
4732 | "* operands[5] = operands[4]; return output_fix_trunc (insn, operands);" | |
4733 | [(set_attr "type" "fistp")]) | |
53b5ce19 | 4734 | |
e075ae69 RH |
4735 | (define_split |
4736 | [(set (match_operand:DI 0 "register_operand" "") | |
4737 | (fix:DI (match_operand 1 "register_operand" ""))) | |
7a2e09f4 JH |
4738 | (use (match_operand:HI 2 "memory_operand" "")) |
4739 | (use (match_operand:HI 3 "memory_operand" "")) | |
4740 | (clobber (match_operand:DI 4 "memory_operand" "")) | |
a05924f9 | 4741 | (clobber (match_scratch 5 ""))] |
7a2e09f4 JH |
4742 | "reload_completed" |
4743 | [(parallel [(set (match_dup 4) (fix:DI (match_dup 1))) | |
4744 | (use (match_dup 2)) | |
4745 | (use (match_dup 3)) | |
e075ae69 | 4746 | (clobber (match_dup 5))]) |
7a2e09f4 | 4747 | (set (match_dup 0) (match_dup 4))] |
53b5ce19 JW |
4748 | "") |
4749 | ||
22fb740d JH |
4750 | (define_split |
4751 | [(set (match_operand:DI 0 "memory_operand" "") | |
4752 | (fix:DI (match_operand 1 "register_operand" ""))) | |
4753 | (use (match_operand:HI 2 "memory_operand" "")) | |
4754 | (use (match_operand:HI 3 "memory_operand" "")) | |
4755 | (clobber (match_operand:DI 4 "memory_operand" "")) | |
4756 | (clobber (match_scratch 5 ""))] | |
4757 | "reload_completed" | |
4758 | [(parallel [(set (match_dup 0) (fix:DI (match_dup 1))) | |
4759 | (use (match_dup 2)) | |
4760 | (use (match_dup 3)) | |
4761 | (clobber (match_dup 5))])] | |
4762 | "") | |
4763 | ||
46ed7963 JH |
4764 | ;; When SSE available, it is always faster to use it! |
4765 | (define_insn "fix_truncsfdi_sse" | |
4766 | [(set (match_operand:DI 0 "register_operand" "=r") | |
4767 | (fix:DI (match_operand:SF 1 "nonimmediate_operand" "xm")))] | |
1b0c37d7 | 4768 | "TARGET_64BIT && TARGET_SSE" |
0f40f9f7 | 4769 | "cvttss2si{q}\t{%1, %0|%0, %1}" |
46ed7963 JH |
4770 | [(set_attr "type" "sse")]) |
4771 | ||
4772 | (define_insn "fix_truncdfdi_sse" | |
4773 | [(set (match_operand:DI 0 "register_operand" "=r") | |
4774 | (fix:DI (match_operand:DF 1 "nonimmediate_operand" "Ym")))] | |
1b0c37d7 | 4775 | "TARGET_64BIT && TARGET_SSE2" |
0f40f9f7 | 4776 | "cvttsd2si{q}\t{%1, %0|%0, %1}" |
46ed7963 JH |
4777 | [(set_attr "type" "sse")]) |
4778 | ||
e075ae69 | 4779 | ;; Signed conversion to SImode. |
53b5ce19 | 4780 | |
e075ae69 | 4781 | (define_expand "fix_truncxfsi2" |
22fb740d JH |
4782 | [(set (match_operand:SI 0 "nonimmediate_operand" "") |
4783 | (fix:SI (match_operand:XF 1 "register_operand" "")))] | |
1b0c37d7 | 4784 | "!TARGET_64BIT && TARGET_80387" |
22fb740d | 4785 | "") |
53b5ce19 | 4786 | |
2b589241 | 4787 | (define_expand "fix_trunctfsi2" |
22fb740d JH |
4788 | [(set (match_operand:SI 0 "nonimmediate_operand" "") |
4789 | (fix:SI (match_operand:TF 1 "register_operand" "")))] | |
2b589241 | 4790 | "TARGET_80387" |
22fb740d | 4791 | "") |
2b589241 | 4792 | |
e075ae69 | 4793 | (define_expand "fix_truncdfsi2" |
22fb740d JH |
4794 | [(set (match_operand:SI 0 "nonimmediate_operand" "") |
4795 | (fix:SI (match_operand:DF 1 "register_operand" "")))] | |
42a0aa6f | 4796 | "TARGET_80387 || TARGET_SSE2" |
42a0aa6f JH |
4797 | { |
4798 | if (TARGET_SSE2) | |
4799 | { | |
ca9a9b12 | 4800 | rtx out = REG_P (operands[0]) ? operands[0] : gen_reg_rtx (SImode); |
b1675dbd JH |
4801 | emit_insn (gen_fix_truncdfsi_sse (out, operands[1])); |
4802 | if (out != operands[0]) | |
4803 | emit_move_insn (operands[0], out); | |
42a0aa6f JH |
4804 | DONE; |
4805 | } | |
0f40f9f7 | 4806 | }) |
886c62d1 | 4807 | |
e075ae69 | 4808 | (define_expand "fix_truncsfsi2" |
22fb740d JH |
4809 | [(set (match_operand:SI 0 "nonimmediate_operand" "") |
4810 | (fix:SI (match_operand:SF 1 "register_operand" "")))] | |
42a0aa6f | 4811 | "TARGET_80387 || TARGET_SSE" |
42a0aa6f | 4812 | { |
22fb740d | 4813 | if (TARGET_SSE) |
42a0aa6f | 4814 | { |
ca9a9b12 | 4815 | rtx out = REG_P (operands[0]) ? operands[0] : gen_reg_rtx (SImode); |
46ed7963 | 4816 | emit_insn (gen_fix_truncsfsi_sse (out, operands[1])); |
b1675dbd JH |
4817 | if (out != operands[0]) |
4818 | emit_move_insn (operands[0], out); | |
42a0aa6f JH |
4819 | DONE; |
4820 | } | |
0f40f9f7 | 4821 | }) |
e075ae69 | 4822 | |
22fb740d JH |
4823 | ;; See the comments in i386.h near OPTIMIZE_MODE_SWITCHING for the description |
4824 | ;; of the machinery. | |
4825 | (define_insn_and_split "*fix_truncsi_1" | |
4826 | [(set (match_operand:SI 0 "nonimmediate_operand" "=m,?r") | |
4827 | (fix:SI (match_operand 1 "register_operand" "f,f")))] | |
4828 | "TARGET_80387 && FLOAT_MODE_P (GET_MODE (operands[1])) | |
4829 | && !reload_completed && !reload_in_progress | |
4830 | && !SSE_FLOAT_MODE_P (GET_MODE (operands[1]))" | |
4831 | "#" | |
ab75d1f1 | 4832 | "&& 1" |
22fb740d JH |
4833 | [(const_int 0)] |
4834 | { | |
4835 | operands[2] = assign_386_stack_local (HImode, 1); | |
4836 | operands[3] = assign_386_stack_local (HImode, 2); | |
4837 | if (memory_operand (operands[0], VOIDmode)) | |
4838 | emit_insn (gen_fix_truncsi_memory (operands[0], operands[1], | |
4839 | operands[2], operands[3])); | |
4840 | else | |
4841 | { | |
4842 | operands[4] = assign_386_stack_local (SImode, 0); | |
4843 | emit_insn (gen_fix_truncsi_nomemory (operands[0], operands[1], | |
4844 | operands[2], operands[3], | |
4845 | operands[4])); | |
4846 | } | |
4847 | DONE; | |
4848 | } | |
4849 | [(set_attr "type" "fistp")]) | |
4850 | ||
4851 | (define_insn "fix_truncsi_nomemory" | |
c76aab11 | 4852 | [(set (match_operand:SI 0 "nonimmediate_operand" "=m,?r") |
e075ae69 | 4853 | (fix:SI (match_operand 1 "register_operand" "f,f"))) |
7a2e09f4 JH |
4854 | (use (match_operand:HI 2 "memory_operand" "m,m")) |
4855 | (use (match_operand:HI 3 "memory_operand" "m,m")) | |
4856 | (clobber (match_operand:SI 4 "memory_operand" "=m,m"))] | |
42a0aa6f | 4857 | "TARGET_80387 && FLOAT_MODE_P (GET_MODE (operands[1])) |
22fb740d JH |
4858 | && !SSE_FLOAT_MODE_P (GET_MODE (operands[1]))" |
4859 | "#" | |
4860 | [(set_attr "type" "fistp")]) | |
4861 | ||
4862 | (define_insn "fix_truncsi_memory" | |
4863 | [(set (match_operand:SI 0 "memory_operand" "=m") | |
4864 | (fix:SI (match_operand 1 "register_operand" "f"))) | |
4865 | (use (match_operand:HI 2 "memory_operand" "m")) | |
4866 | (use (match_operand:HI 3 "memory_operand" "m"))] | |
4867 | "TARGET_80387 && FLOAT_MODE_P (GET_MODE (operands[1])) | |
4868 | && !SSE_FLOAT_MODE_P (GET_MODE (operands[1]))" | |
e075ae69 | 4869 | "* return output_fix_trunc (insn, operands);" |
22fb740d | 4870 | [(set_attr "type" "fistp")]) |
bc725565 | 4871 | |
42a0aa6f JH |
4872 | ;; When SSE available, it is always faster to use it! |
4873 | (define_insn "fix_truncsfsi_sse" | |
4874 | [(set (match_operand:SI 0 "register_operand" "=r") | |
4875 | (fix:SI (match_operand:SF 1 "nonimmediate_operand" "xm")))] | |
4876 | "TARGET_SSE" | |
0f40f9f7 | 4877 | "cvttss2si\t{%1, %0|%0, %1}" |
42a0aa6f JH |
4878 | [(set_attr "type" "sse")]) |
4879 | ||
4880 | (define_insn "fix_truncdfsi_sse" | |
4881 | [(set (match_operand:SI 0 "register_operand" "=r") | |
4882 | (fix:SI (match_operand:DF 1 "nonimmediate_operand" "Ym")))] | |
4883 | "TARGET_SSE2" | |
0f40f9f7 | 4884 | "cvttsd2si\t{%1, %0|%0, %1}" |
42a0aa6f JH |
4885 | [(set_attr "type" "sse")]) |
4886 | ||
e075ae69 RH |
4887 | (define_split |
4888 | [(set (match_operand:SI 0 "register_operand" "") | |
4889 | (fix:SI (match_operand 1 "register_operand" ""))) | |
7a2e09f4 JH |
4890 | (use (match_operand:HI 2 "memory_operand" "")) |
4891 | (use (match_operand:HI 3 "memory_operand" "")) | |
4892 | (clobber (match_operand:SI 4 "memory_operand" ""))] | |
e075ae69 | 4893 | "reload_completed" |
7a2e09f4 JH |
4894 | [(parallel [(set (match_dup 4) (fix:SI (match_dup 1))) |
4895 | (use (match_dup 2)) | |
22fb740d | 4896 | (use (match_dup 3))]) |
7a2e09f4 | 4897 | (set (match_dup 0) (match_dup 4))] |
bc725565 | 4898 | "") |
4fb21e90 | 4899 | |
22fb740d JH |
4900 | (define_split |
4901 | [(set (match_operand:SI 0 "memory_operand" "") | |
4902 | (fix:SI (match_operand 1 "register_operand" ""))) | |
4903 | (use (match_operand:HI 2 "memory_operand" "")) | |
4904 | (use (match_operand:HI 3 "memory_operand" "")) | |
4905 | (clobber (match_operand:SI 4 "memory_operand" ""))] | |
4906 | "reload_completed" | |
4907 | [(parallel [(set (match_dup 0) (fix:SI (match_dup 1))) | |
4908 | (use (match_dup 2)) | |
4909 | (use (match_dup 3))])] | |
4910 | "") | |
4911 | ||
46d21d2c JW |
4912 | ;; Signed conversion to HImode. |
4913 | ||
4914 | (define_expand "fix_truncxfhi2" | |
22fb740d JH |
4915 | [(set (match_operand:HI 0 "nonimmediate_operand" "") |
4916 | (fix:HI (match_operand:XF 1 "register_operand" "")))] | |
1b0c37d7 | 4917 | "!TARGET_64BIT && TARGET_80387" |
22fb740d | 4918 | "") |
46d21d2c | 4919 | |
2b589241 | 4920 | (define_expand "fix_trunctfhi2" |
22fb740d JH |
4921 | [(set (match_operand:HI 0 "nonimmediate_operand" "") |
4922 | (fix:HI (match_operand:TF 1 "register_operand" "")))] | |
2b589241 | 4923 | "TARGET_80387" |
22fb740d | 4924 | "") |
2b589241 | 4925 | |
46d21d2c | 4926 | (define_expand "fix_truncdfhi2" |
22fb740d JH |
4927 | [(set (match_operand:HI 0 "nonimmediate_operand" "") |
4928 | (fix:HI (match_operand:DF 1 "register_operand" "")))] | |
42a0aa6f | 4929 | "TARGET_80387 && !TARGET_SSE2" |
22fb740d | 4930 | "") |
46d21d2c JW |
4931 | |
4932 | (define_expand "fix_truncsfhi2" | |
22fb740d JH |
4933 | [(set (match_operand:HI 0 "nonimmediate_operand" "") |
4934 | (fix:HI (match_operand:SF 1 "register_operand" "")))] | |
42a0aa6f | 4935 | "TARGET_80387 && !TARGET_SSE" |
22fb740d JH |
4936 | "") |
4937 | ||
4938 | ;; See the comments in i386.h near OPTIMIZE_MODE_SWITCHING for the description | |
4939 | ;; of the machinery. | |
4940 | (define_insn_and_split "*fix_trunchi_1" | |
4941 | [(set (match_operand:HI 0 "nonimmediate_operand" "=m,?r") | |
4942 | (fix:HI (match_operand 1 "register_operand" "f,f")))] | |
4943 | "TARGET_80387 && FLOAT_MODE_P (GET_MODE (operands[1])) | |
4944 | && !reload_completed && !reload_in_progress | |
4945 | && !SSE_FLOAT_MODE_P (GET_MODE (operands[1]))" | |
4946 | "#" | |
4947 | "" | |
4948 | [(const_int 0)] | |
4949 | { | |
4950 | operands[2] = assign_386_stack_local (HImode, 1); | |
4951 | operands[3] = assign_386_stack_local (HImode, 2); | |
4952 | if (memory_operand (operands[0], VOIDmode)) | |
4953 | emit_insn (gen_fix_trunchi_memory (operands[0], operands[1], | |
4954 | operands[2], operands[3])); | |
4955 | else | |
4956 | { | |
4957 | operands[4] = assign_386_stack_local (HImode, 0); | |
4958 | emit_insn (gen_fix_trunchi_nomemory (operands[0], operands[1], | |
4959 | operands[2], operands[3], | |
4960 | operands[4])); | |
4961 | } | |
4962 | DONE; | |
4963 | } | |
4964 | [(set_attr "type" "fistp")]) | |
46d21d2c | 4965 | |
22fb740d | 4966 | (define_insn "fix_trunchi_nomemory" |
46d21d2c JW |
4967 | [(set (match_operand:HI 0 "nonimmediate_operand" "=m,?r") |
4968 | (fix:HI (match_operand 1 "register_operand" "f,f"))) | |
7a2e09f4 JH |
4969 | (use (match_operand:HI 2 "memory_operand" "m,m")) |
4970 | (use (match_operand:HI 3 "memory_operand" "m,m")) | |
4971 | (clobber (match_operand:HI 4 "memory_operand" "=m,m"))] | |
42a0aa6f | 4972 | "TARGET_80387 && FLOAT_MODE_P (GET_MODE (operands[1])) |
22fb740d JH |
4973 | && !SSE_FLOAT_MODE_P (GET_MODE (operands[1]))" |
4974 | "#" | |
4975 | [(set_attr "type" "fistp")]) | |
4976 | ||
4977 | (define_insn "fix_trunchi_memory" | |
4978 | [(set (match_operand:HI 0 "memory_operand" "=m") | |
4979 | (fix:HI (match_operand 1 "register_operand" "f"))) | |
4980 | (use (match_operand:HI 2 "memory_operand" "m")) | |
4981 | (use (match_operand:HI 3 "memory_operand" "m"))] | |
4982 | "TARGET_80387 && FLOAT_MODE_P (GET_MODE (operands[1])) | |
4983 | && !SSE_FLOAT_MODE_P (GET_MODE (operands[1]))" | |
46d21d2c | 4984 | "* return output_fix_trunc (insn, operands);" |
22fb740d JH |
4985 | [(set_attr "type" "fistp")]) |
4986 | ||
4987 | (define_split | |
4988 | [(set (match_operand:HI 0 "memory_operand" "") | |
4989 | (fix:HI (match_operand 1 "register_operand" ""))) | |
4990 | (use (match_operand:HI 2 "memory_operand" "")) | |
4991 | (use (match_operand:HI 3 "memory_operand" "")) | |
4992 | (clobber (match_operand:HI 4 "memory_operand" ""))] | |
4993 | "reload_completed" | |
4994 | [(parallel [(set (match_dup 0) (fix:HI (match_dup 1))) | |
4995 | (use (match_dup 2)) | |
4996 | (use (match_dup 3))])] | |
4997 | "") | |
46d21d2c JW |
4998 | |
4999 | (define_split | |
5000 | [(set (match_operand:HI 0 "register_operand" "") | |
5001 | (fix:HI (match_operand 1 "register_operand" ""))) | |
7a2e09f4 JH |
5002 | (use (match_operand:HI 2 "memory_operand" "")) |
5003 | (use (match_operand:HI 3 "memory_operand" "")) | |
5004 | (clobber (match_operand:HI 4 "memory_operand" ""))] | |
46d21d2c | 5005 | "reload_completed" |
7a2e09f4 JH |
5006 | [(parallel [(set (match_dup 4) (fix:HI (match_dup 1))) |
5007 | (use (match_dup 2)) | |
5008 | (use (match_dup 3)) | |
46d21d2c | 5009 | (clobber (match_dup 4))]) |
7a2e09f4 | 5010 | (set (match_dup 0) (match_dup 4))] |
46d21d2c JW |
5011 | "") |
5012 | ||
e075ae69 RH |
5013 | ;; %% Not used yet. |
5014 | (define_insn "x86_fnstcw_1" | |
c76aab11 RH |
5015 | [(set (match_operand:HI 0 "memory_operand" "=m") |
5016 | (unspec:HI [(reg:HI 18)] 11))] | |
e1f998ad | 5017 | "TARGET_80387" |
0f40f9f7 | 5018 | "fnstcw\t%0" |
6ef67412 JH |
5019 | [(set_attr "length" "2") |
5020 | (set_attr "mode" "HI") | |
5021 | (set_attr "i387" "1") | |
e075ae69 | 5022 | (set_attr "ppro_uops" "few")]) |
bc725565 | 5023 | |
e075ae69 RH |
5024 | (define_insn "x86_fldcw_1" |
5025 | [(set (reg:HI 18) | |
c76aab11 | 5026 | (unspec:HI [(match_operand:HI 0 "memory_operand" "m")] 12))] |
bc725565 | 5027 | "TARGET_80387" |
0f40f9f7 | 5028 | "fldcw\t%0" |
6ef67412 JH |
5029 | [(set_attr "length" "2") |
5030 | (set_attr "mode" "HI") | |
5031 | (set_attr "i387" "1") | |
0b5107cf | 5032 | (set_attr "athlon_decode" "vector") |
e075ae69 RH |
5033 | (set_attr "ppro_uops" "few")]) |
5034 | \f | |
5035 | ;; Conversion between fixed point and floating point. | |
886c62d1 | 5036 | |
e075ae69 RH |
5037 | ;; Even though we only accept memory inputs, the backend _really_ |
5038 | ;; wants to be able to do this between registers. | |
5039 | ||
155d8a47 JW |
5040 | (define_insn "floathisf2" |
5041 | [(set (match_operand:SF 0 "register_operand" "=f,f") | |
5042 | (float:SF (match_operand:HI 1 "nonimmediate_operand" "m,r")))] | |
42a0aa6f | 5043 | "TARGET_80387 && !TARGET_SSE" |
155d8a47 | 5044 | "@ |
0f40f9f7 | 5045 | fild%z1\t%1 |
155d8a47 JW |
5046 | #" |
5047 | [(set_attr "type" "fmov,multi") | |
6ef67412 | 5048 | (set_attr "mode" "SF") |
155d8a47 JW |
5049 | (set_attr "fp_int_src" "true")]) |
5050 | ||
42a0aa6f JH |
5051 | (define_expand "floatsisf2" |
5052 | [(set (match_operand:SF 0 "register_operand" "") | |
5053 | (float:SF (match_operand:SI 1 "nonimmediate_operand" "")))] | |
5054 | "TARGET_SSE || TARGET_80387" | |
5055 | "") | |
5056 | ||
5057 | (define_insn "*floatsisf2_i387" | |
5058 | [(set (match_operand:SF 0 "register_operand" "=f,?f,x") | |
5059 | (float:SF (match_operand:SI 1 "nonimmediate_operand" "m,r,mr")))] | |
5060 | "TARGET_80387 && (!TARGET_SSE || TARGET_MIX_SSE_I387)" | |
e075ae69 | 5061 | "@ |
0f40f9f7 | 5062 | fild%z1\t%1 |
42a0aa6f | 5063 | # |
0f40f9f7 | 5064 | cvtsi2ss\t{%1, %0|%0, %1}" |
42a0aa6f JH |
5065 | [(set_attr "type" "fmov,multi,sse") |
5066 | (set_attr "mode" "SF") | |
5067 | (set_attr "fp_int_src" "true")]) | |
5068 | ||
5069 | (define_insn "*floatsisf2_sse" | |
5070 | [(set (match_operand:SF 0 "register_operand" "=x") | |
5071 | (float:SF (match_operand:SI 1 "nonimmediate_operand" "mr")))] | |
46ed7963 | 5072 | "TARGET_SSE" |
0f40f9f7 | 5073 | "cvtsi2ss\t{%1, %0|%0, %1}" |
42a0aa6f | 5074 | [(set_attr "type" "sse") |
6ef67412 | 5075 | (set_attr "mode" "SF") |
e075ae69 | 5076 | (set_attr "fp_int_src" "true")]) |
bc725565 | 5077 | |
46ed7963 JH |
5078 | (define_expand "floatdisf2" |
5079 | [(set (match_operand:SF 0 "register_operand" "") | |
5080 | (float:SF (match_operand:DI 1 "nonimmediate_operand" "")))] | |
1b0c37d7 | 5081 | "(TARGET_64BIT && TARGET_SSE) || TARGET_80387" |
46ed7963 JH |
5082 | "") |
5083 | ||
ef6257cd JH |
5084 | (define_insn "*floatdisf2_i387_only" |
5085 | [(set (match_operand:SF 0 "register_operand" "=f,?f") | |
5086 | (float:SF (match_operand:DI 1 "nonimmediate_operand" "m,r")))] | |
5087 | "TARGET_80387 && (!TARGET_SSE || !TARGET_64BIT || TARGET_MIX_SSE_I387)" | |
5088 | "@ | |
0f40f9f7 | 5089 | fild%z1\t%1 |
ef6257cd JH |
5090 | #" |
5091 | [(set_attr "type" "fmov,multi") | |
5092 | (set_attr "mode" "SF") | |
5093 | (set_attr "fp_int_src" "true")]) | |
5094 | ||
46ed7963 JH |
5095 | (define_insn "*floatdisf2_i387" |
5096 | [(set (match_operand:SF 0 "register_operand" "=f,?f,x") | |
5097 | (float:SF (match_operand:DI 1 "nonimmediate_operand" "m,r,mr")))] | |
1b0c37d7 | 5098 | "TARGET_64BIT && TARGET_80387 && (!TARGET_SSE || TARGET_MIX_SSE_I387)" |
e075ae69 | 5099 | "@ |
0f40f9f7 | 5100 | fild%z1\t%1 |
46ed7963 | 5101 | # |
0f40f9f7 | 5102 | cvtsi2ss{q}\t{%1, %0|%0, %1}" |
46ed7963 JH |
5103 | [(set_attr "type" "fmov,multi,sse") |
5104 | (set_attr "mode" "SF") | |
5105 | (set_attr "fp_int_src" "true")]) | |
5106 | ||
5107 | (define_insn "*floatdisf2_sse" | |
5108 | [(set (match_operand:SF 0 "register_operand" "=x") | |
5109 | (float:SF (match_operand:DI 1 "nonimmediate_operand" "mr")))] | |
1b0c37d7 | 5110 | "TARGET_64BIT && TARGET_SSE" |
0f40f9f7 | 5111 | "cvtsi2ss{q}\t{%1, %0|%0, %1}" |
46ed7963 | 5112 | [(set_attr "type" "sse") |
6ef67412 | 5113 | (set_attr "mode" "SF") |
e075ae69 | 5114 | (set_attr "fp_int_src" "true")]) |
bc725565 | 5115 | |
155d8a47 JW |
5116 | (define_insn "floathidf2" |
5117 | [(set (match_operand:DF 0 "register_operand" "=f,f") | |
5118 | (float:DF (match_operand:HI 1 "nonimmediate_operand" "m,r")))] | |
42a0aa6f | 5119 | "TARGET_80387 && !TARGET_SSE2" |
155d8a47 | 5120 | "@ |
0f40f9f7 | 5121 | fild%z1\t%1 |
155d8a47 JW |
5122 | #" |
5123 | [(set_attr "type" "fmov,multi") | |
6ef67412 | 5124 | (set_attr "mode" "DF") |
155d8a47 JW |
5125 | (set_attr "fp_int_src" "true")]) |
5126 | ||
42a0aa6f JH |
5127 | (define_expand "floatsidf2" |
5128 | [(set (match_operand:DF 0 "register_operand" "") | |
5129 | (float:DF (match_operand:SI 1 "nonimmediate_operand" "")))] | |
5130 | "" | |
5131 | "") | |
5132 | ||
5133 | (define_insn "*floatsidf2_i387" | |
5134 | [(set (match_operand:DF 0 "register_operand" "=f,?f,Y") | |
5135 | (float:DF (match_operand:SI 1 "nonimmediate_operand" "m,r,mr")))] | |
5136 | "TARGET_80387 && (!TARGET_SSE2 || TARGET_MIX_SSE_I387)" | |
e075ae69 | 5137 | "@ |
0f40f9f7 | 5138 | fild%z1\t%1 |
42a0aa6f | 5139 | # |
0f40f9f7 | 5140 | cvtsi2sd\t{%1, %0|%0, %1}" |
42a0aa6f JH |
5141 | [(set_attr "type" "fmov,multi,sse") |
5142 | (set_attr "mode" "DF") | |
5143 | (set_attr "fp_int_src" "true")]) | |
5144 | ||
5145 | (define_insn "*floatsidf2_sse" | |
5146 | [(set (match_operand:DF 0 "register_operand" "=Y") | |
5147 | (float:DF (match_operand:SI 1 "nonimmediate_operand" "mr")))] | |
5148 | "TARGET_SSE2" | |
0f40f9f7 | 5149 | "cvtsi2sd\t{%1, %0|%0, %1}" |
42a0aa6f | 5150 | [(set_attr "type" "sse") |
6ef67412 | 5151 | (set_attr "mode" "DF") |
e075ae69 | 5152 | (set_attr "fp_int_src" "true")]) |
e1f998ad | 5153 | |
46ed7963 JH |
5154 | (define_expand "floatdidf2" |
5155 | [(set (match_operand:DF 0 "register_operand" "") | |
5156 | (float:DF (match_operand:DI 1 "nonimmediate_operand" "")))] | |
1b0c37d7 | 5157 | "(TARGET_64BIT && TARGET_SSE2) || TARGET_80387" |
46ed7963 JH |
5158 | "") |
5159 | ||
ef6257cd JH |
5160 | (define_insn "*floatdidf2_i387_only" |
5161 | [(set (match_operand:DF 0 "register_operand" "=f,?f") | |
5162 | (float:DF (match_operand:DI 1 "nonimmediate_operand" "m,r")))] | |
5163 | "TARGET_80387 && (!TARGET_SSE2 || !TARGET_64BIT)" | |
5164 | "@ | |
0f40f9f7 | 5165 | fild%z1\t%1 |
ef6257cd JH |
5166 | #" |
5167 | [(set_attr "type" "fmov,multi") | |
5168 | (set_attr "mode" "DF") | |
5169 | (set_attr "fp_int_src" "true")]) | |
5170 | ||
46ed7963 JH |
5171 | (define_insn "*floatdidf2_i387" |
5172 | [(set (match_operand:DF 0 "register_operand" "=f,?f,Y") | |
5173 | (float:DF (match_operand:DI 1 "nonimmediate_operand" "m,r,mr")))] | |
1b0c37d7 | 5174 | "TARGET_64BIT && TARGET_80387 && (!TARGET_SSE2 || TARGET_MIX_SSE_I387)" |
e075ae69 | 5175 | "@ |
0f40f9f7 | 5176 | fild%z1\t%1 |
46ed7963 | 5177 | # |
0f40f9f7 | 5178 | cvtsi2sd{q}\t{%1, %0|%0, %1}" |
46ed7963 JH |
5179 | [(set_attr "type" "fmov,multi,sse") |
5180 | (set_attr "mode" "DF") | |
5181 | (set_attr "fp_int_src" "true")]) | |
5182 | ||
5183 | (define_insn "*floatdidf2_sse" | |
5184 | [(set (match_operand:DF 0 "register_operand" "=Y") | |
5185 | (float:DF (match_operand:DI 1 "nonimmediate_operand" "mr")))] | |
5186 | "TARGET_SSE2" | |
0f40f9f7 | 5187 | "cvtsi2sd{q}\t{%1, %0|%0, %1}" |
46ed7963 | 5188 | [(set_attr "type" "sse") |
6ef67412 | 5189 | (set_attr "mode" "DF") |
e075ae69 | 5190 | (set_attr "fp_int_src" "true")]) |
bc725565 | 5191 | |
155d8a47 JW |
5192 | (define_insn "floathixf2" |
5193 | [(set (match_operand:XF 0 "register_operand" "=f,f") | |
5194 | (float:XF (match_operand:HI 1 "nonimmediate_operand" "m,r")))] | |
1b0c37d7 | 5195 | "!TARGET_64BIT && TARGET_80387" |
155d8a47 | 5196 | "@ |
0f40f9f7 | 5197 | fild%z1\t%1 |
155d8a47 JW |
5198 | #" |
5199 | [(set_attr "type" "fmov,multi") | |
6ef67412 | 5200 | (set_attr "mode" "XF") |
155d8a47 JW |
5201 | (set_attr "fp_int_src" "true")]) |
5202 | ||
2b589241 JH |
5203 | (define_insn "floathitf2" |
5204 | [(set (match_operand:TF 0 "register_operand" "=f,f") | |
5205 | (float:TF (match_operand:HI 1 "nonimmediate_operand" "m,r")))] | |
5206 | "TARGET_80387" | |
5207 | "@ | |
0f40f9f7 | 5208 | fild%z1\t%1 |
2b589241 JH |
5209 | #" |
5210 | [(set_attr "type" "fmov,multi") | |
5211 | (set_attr "mode" "XF") | |
5212 | (set_attr "fp_int_src" "true")]) | |
5213 | ||
e075ae69 RH |
5214 | (define_insn "floatsixf2" |
5215 | [(set (match_operand:XF 0 "register_operand" "=f,f") | |
5216 | (float:XF (match_operand:SI 1 "nonimmediate_operand" "m,r")))] | |
1b0c37d7 | 5217 | "!TARGET_64BIT && TARGET_80387" |
e075ae69 | 5218 | "@ |
0f40f9f7 | 5219 | fild%z1\t%1 |
e075ae69 RH |
5220 | #" |
5221 | [(set_attr "type" "fmov,multi") | |
6ef67412 | 5222 | (set_attr "mode" "XF") |
e075ae69 | 5223 | (set_attr "fp_int_src" "true")]) |
53b5ce19 | 5224 | |
2b589241 JH |
5225 | (define_insn "floatsitf2" |
5226 | [(set (match_operand:TF 0 "register_operand" "=f,f") | |
5227 | (float:TF (match_operand:SI 1 "nonimmediate_operand" "m,r")))] | |
5228 | "TARGET_80387" | |
5229 | "@ | |
0f40f9f7 | 5230 | fild%z1\t%1 |
2b589241 JH |
5231 | #" |
5232 | [(set_attr "type" "fmov,multi") | |
5233 | (set_attr "mode" "XF") | |
5234 | (set_attr "fp_int_src" "true")]) | |
5235 | ||
e075ae69 | 5236 | (define_insn "floatdixf2" |
53b5ce19 | 5237 | [(set (match_operand:XF 0 "register_operand" "=f,f") |
e075ae69 | 5238 | (float:XF (match_operand:DI 1 "nonimmediate_operand" "m,r")))] |
1b0c37d7 | 5239 | "!TARGET_64BIT && TARGET_80387" |
e075ae69 | 5240 | "@ |
0f40f9f7 | 5241 | fild%z1\t%1 |
e075ae69 RH |
5242 | #" |
5243 | [(set_attr "type" "fmov,multi") | |
6ef67412 | 5244 | (set_attr "mode" "XF") |
e075ae69 | 5245 | (set_attr "fp_int_src" "true")]) |
53b5ce19 | 5246 | |
2b589241 JH |
5247 | (define_insn "floatditf2" |
5248 | [(set (match_operand:TF 0 "register_operand" "=f,f") | |
5249 | (float:TF (match_operand:DI 1 "nonimmediate_operand" "m,r")))] | |
5250 | "TARGET_80387" | |
5251 | "@ | |
0f40f9f7 | 5252 | fild%z1\t%1 |
2b589241 JH |
5253 | #" |
5254 | [(set_attr "type" "fmov,multi") | |
5255 | (set_attr "mode" "XF") | |
5256 | (set_attr "fp_int_src" "true")]) | |
5257 | ||
e075ae69 | 5258 | ;; %%% Kill these when reload knows how to do it. |
155d8a47 JW |
5259 | (define_split |
5260 | [(set (match_operand 0 "register_operand" "") | |
4211a8fb | 5261 | (float (match_operand 1 "register_operand" "")))] |
bf71a4f8 JH |
5262 | "reload_completed && FLOAT_MODE_P (GET_MODE (operands[0])) |
5263 | && FP_REG_P (operands[0])" | |
4211a8fb | 5264 | [(const_int 0)] |
4211a8fb JH |
5265 | { |
5266 | operands[2] = ix86_force_to_memory (GET_MODE (operands[1]), operands[1]); | |
5267 | operands[2] = gen_rtx_FLOAT (GET_MODE (operands[0]), operands[2]); | |
5268 | emit_insn (gen_rtx_SET (VOIDmode, operands[0], operands[2])); | |
5269 | ix86_free_from_memory (GET_MODE (operands[1])); | |
5270 | DONE; | |
0f40f9f7 | 5271 | }) |
e075ae69 RH |
5272 | \f |
5273 | ;; Add instructions | |
53b5ce19 | 5274 | |
e075ae69 RH |
5275 | ;; %%% splits for addsidi3 |
5276 | ; [(set (match_operand:DI 0 "nonimmediate_operand" "") | |
5277 | ; (plus:DI (match_operand:DI 1 "general_operand" "") | |
5278 | ; (zero_extend:DI (match_operand:SI 2 "general_operand" ""))))] | |
e1f998ad | 5279 | |
9b70259d JH |
5280 | (define_expand "adddi3" |
5281 | [(set (match_operand:DI 0 "nonimmediate_operand" "") | |
5282 | (plus:DI (match_operand:DI 1 "nonimmediate_operand" "") | |
5283 | (match_operand:DI 2 "x86_64_general_operand" ""))) | |
5284 | (clobber (reg:CC 17))] | |
5285 | "" | |
5286 | "ix86_expand_binary_operator (PLUS, DImode, operands); DONE;") | |
5287 | ||
5288 | (define_insn "*adddi3_1" | |
e075ae69 RH |
5289 | [(set (match_operand:DI 0 "nonimmediate_operand" "=r,o") |
5290 | (plus:DI (match_operand:DI 1 "nonimmediate_operand" "%0,0") | |
5291 | (match_operand:DI 2 "general_operand" "roiF,riF"))) | |
5292 | (clobber (reg:CC 17))] | |
9b70259d | 5293 | "!TARGET_64BIT" |
bc725565 JW |
5294 | "#") |
5295 | ||
5296 | (define_split | |
e075ae69 | 5297 | [(set (match_operand:DI 0 "nonimmediate_operand" "") |
4cbfbb1b | 5298 | (plus:DI (match_operand:DI 1 "nonimmediate_operand" "") |
e075ae69 RH |
5299 | (match_operand:DI 2 "general_operand" ""))) |
5300 | (clobber (reg:CC 17))] | |
1b0c37d7 | 5301 | "!TARGET_64BIT && reload_completed" |
7e08e190 | 5302 | [(parallel [(set (reg:CC 17) (unspec:CC [(match_dup 1) (match_dup 2)] 12)) |
e075ae69 RH |
5303 | (set (match_dup 0) (plus:SI (match_dup 1) (match_dup 2)))]) |
5304 | (parallel [(set (match_dup 3) | |
7e08e190 | 5305 | (plus:SI (plus:SI (ltu:SI (reg:CC 17) (const_int 0)) |
9dcbdc7e JH |
5306 | (match_dup 4)) |
5307 | (match_dup 5))) | |
e075ae69 RH |
5308 | (clobber (reg:CC 17))])] |
5309 | "split_di (operands+0, 1, operands+0, operands+3); | |
5310 | split_di (operands+1, 1, operands+1, operands+4); | |
5311 | split_di (operands+2, 1, operands+2, operands+5);") | |
5312 | ||
9b70259d JH |
5313 | (define_insn "*adddi3_carry_rex64" |
5314 | [(set (match_operand:DI 0 "nonimmediate_operand" "=rm,r") | |
5315 | (plus:DI (plus:DI (ltu:DI (reg:CC 17) (const_int 0)) | |
5316 | (match_operand:DI 1 "nonimmediate_operand" "%0,0")) | |
5317 | (match_operand:DI 2 "x86_64_general_operand" "re,rm"))) | |
5318 | (clobber (reg:CC 17))] | |
1b0c37d7 | 5319 | "TARGET_64BIT && ix86_binary_operator_ok (PLUS, DImode, operands)" |
0f40f9f7 | 5320 | "adc{q}\t{%2, %0|%0, %2}" |
9b70259d JH |
5321 | [(set_attr "type" "alu") |
5322 | (set_attr "pent_pair" "pu") | |
5323 | (set_attr "mode" "DI") | |
5324 | (set_attr "ppro_uops" "few")]) | |
5325 | ||
5326 | (define_insn "*adddi3_cc_rex64" | |
5327 | [(set (reg:CC 17) (unspec:CC [(match_operand:DI 1 "nonimmediate_operand" "%0,0") | |
5328 | (match_operand:DI 2 "x86_64_general_operand" "re,rm")] 12)) | |
5329 | (set (match_operand:DI 0 "nonimmediate_operand" "=rm,r") | |
5330 | (plus:DI (match_dup 1) (match_dup 2)))] | |
5331 | "TARGET_64BIT && ix86_binary_operator_ok (PLUS, DImode, operands)" | |
0f40f9f7 | 5332 | "add{q}\t{%2, %0|%0, %2}" |
9b70259d JH |
5333 | [(set_attr "type" "alu") |
5334 | (set_attr "mode" "DI")]) | |
5335 | ||
7abd4e00 | 5336 | (define_insn "*addsi3_carry" |
e075ae69 | 5337 | [(set (match_operand:SI 0 "nonimmediate_operand" "=rm,r") |
9dcbdc7e JH |
5338 | (plus:SI (plus:SI (ltu:SI (reg:CC 17) (const_int 0)) |
5339 | (match_operand:SI 1 "nonimmediate_operand" "%0,0")) | |
5340 | (match_operand:SI 2 "general_operand" "ri,rm"))) | |
e075ae69 | 5341 | (clobber (reg:CC 17))] |
d525dfdf | 5342 | "ix86_binary_operator_ok (PLUS, SImode, operands)" |
0f40f9f7 | 5343 | "adc{l}\t{%2, %0|%0, %2}" |
e075ae69 RH |
5344 | [(set_attr "type" "alu") |
5345 | (set_attr "pent_pair" "pu") | |
6ef67412 | 5346 | (set_attr "mode" "SI") |
e075ae69 | 5347 | (set_attr "ppro_uops" "few")]) |
4fb21e90 | 5348 | |
9b70259d JH |
5349 | (define_insn "*addsi3_carry_zext" |
5350 | [(set (match_operand:DI 0 "register_operand" "=r") | |
5351 | (zero_extend:DI | |
5352 | (plus:SI (plus:SI (ltu:SI (reg:CC 17) (const_int 0)) | |
5353 | (match_operand:SI 1 "nonimmediate_operand" "%0")) | |
5354 | (match_operand:SI 2 "general_operand" "rim")))) | |
5355 | (clobber (reg:CC 17))] | |
5356 | "TARGET_64BIT && ix86_binary_operator_ok (PLUS, SImode, operands)" | |
0f40f9f7 | 5357 | "adc{l}\t{%2, %k0|%k0, %2}" |
9b70259d JH |
5358 | [(set_attr "type" "alu") |
5359 | (set_attr "pent_pair" "pu") | |
5360 | (set_attr "mode" "SI") | |
5361 | (set_attr "ppro_uops" "few")]) | |
5362 | ||
7e08e190 JH |
5363 | (define_insn "*addsi3_cc" |
5364 | [(set (reg:CC 17) (unspec:CC [(match_operand:SI 1 "nonimmediate_operand" "%0,0") | |
5365 | (match_operand:SI 2 "general_operand" "ri,rm")] 12)) | |
5366 | (set (match_operand:SI 0 "nonimmediate_operand" "=rm,r") | |
5367 | (plus:SI (match_dup 1) (match_dup 2)))] | |
265dab10 | 5368 | "ix86_binary_operator_ok (PLUS, SImode, operands)" |
0f40f9f7 | 5369 | "add{l}\t{%2, %0|%0, %2}" |
265dab10 | 5370 | [(set_attr "type" "alu") |
7e08e190 JH |
5371 | (set_attr "mode" "SI")]) |
5372 | ||
5373 | (define_insn "addqi3_cc" | |
5374 | [(set (reg:CC 17) (unspec:CC [(match_operand:QI 1 "nonimmediate_operand" "%0,0") | |
5375 | (match_operand:QI 2 "general_operand" "qi,qm")] 12)) | |
5376 | (set (match_operand:QI 0 "nonimmediate_operand" "=qm,q") | |
5377 | (plus:QI (match_dup 1) (match_dup 2)))] | |
5378 | "ix86_binary_operator_ok (PLUS, QImode, operands)" | |
0f40f9f7 | 5379 | "add{b}\t{%2, %0|%0, %2}" |
7e08e190 JH |
5380 | [(set_attr "type" "alu") |
5381 | (set_attr "mode" "QI")]) | |
265dab10 | 5382 | |
e075ae69 RH |
5383 | (define_expand "addsi3" |
5384 | [(parallel [(set (match_operand:SI 0 "nonimmediate_operand" "") | |
5385 | (plus:SI (match_operand:SI 1 "nonimmediate_operand" "") | |
5386 | (match_operand:SI 2 "general_operand" ""))) | |
5387 | (clobber (reg:CC 17))])] | |
5388 | "" | |
5389 | "ix86_expand_binary_operator (PLUS, SImode, operands); DONE;") | |
886c62d1 | 5390 | |
ac62a60e | 5391 | (define_insn "*lea_1" |
e075ae69 | 5392 | [(set (match_operand:SI 0 "register_operand" "=r") |
ad678cb0 | 5393 | (match_operand:SI 1 "address_operand" "p"))] |
ac62a60e | 5394 | "!TARGET_64BIT" |
0f40f9f7 | 5395 | "lea{l}\t{%a1, %0|%0, %a1}" |
6ef67412 JH |
5396 | [(set_attr "type" "lea") |
5397 | (set_attr "mode" "SI")]) | |
2ae0f82c | 5398 | |
ac62a60e JH |
5399 | (define_insn "*lea_1_rex64" |
5400 | [(set (match_operand:SI 0 "register_operand" "=r") | |
5401 | (subreg:SI (match_operand:DI 1 "address_operand" "p") 0))] | |
5402 | "TARGET_64BIT" | |
0f40f9f7 | 5403 | "lea{l}\t{%a1, %0|%0, %a1}" |
ac62a60e JH |
5404 | [(set_attr "type" "lea") |
5405 | (set_attr "mode" "SI")]) | |
5406 | ||
5407 | (define_insn "*lea_1_zext" | |
5408 | [(set (match_operand:DI 0 "register_operand" "=r") | |
5409 | (zero_extend:DI (subreg:SI (match_operand:DI 1 "address_operand" "p") 0)))] | |
d4f33f6c | 5410 | "TARGET_64BIT" |
0f40f9f7 | 5411 | "lea{l}\t{%a1, %k0|%k0, %a1}" |
ac62a60e JH |
5412 | [(set_attr "type" "lea") |
5413 | (set_attr "mode" "SI")]) | |
5414 | ||
5415 | (define_insn "*lea_2_rex64" | |
5416 | [(set (match_operand:DI 0 "register_operand" "=r") | |
5417 | (match_operand:DI 1 "address_operand" "p"))] | |
5418 | "TARGET_64BIT" | |
0f40f9f7 | 5419 | "lea{q}\t{%a1, %0|%0, %a1}" |
ac62a60e JH |
5420 | [(set_attr "type" "lea") |
5421 | (set_attr "mode" "DI")]) | |
5422 | ||
58787064 JH |
5423 | ;; The lea patterns for non-Pmodes needs to be matched by several |
5424 | ;; insns converted to real lea by splitters. | |
5425 | ||
5426 | (define_insn_and_split "*lea_general_1" | |
5427 | [(set (match_operand 0 "register_operand" "=r") | |
5428 | (plus (plus (match_operand 1 "register_operand" "r") | |
5429 | (match_operand 2 "register_operand" "r")) | |
5430 | (match_operand 3 "immediate_operand" "i")))] | |
ac62a60e JH |
5431 | "(GET_MODE (operands[0]) == QImode || GET_MODE (operands[0]) == HImode |
5432 | || (TARGET_64BIT && GET_MODE (operands[0]) == SImode)) | |
58787064 JH |
5433 | && (!TARGET_PARTIAL_REG_STALL || optimize_size) |
5434 | && GET_MODE (operands[0]) == GET_MODE (operands[1]) | |
5435 | && GET_MODE (operands[0]) == GET_MODE (operands[2]) | |
5436 | && (GET_MODE (operands[0]) == GET_MODE (operands[3]) | |
5437 | || GET_MODE (operands[3]) == VOIDmode)" | |
5438 | "#" | |
cb694d2c | 5439 | "&& reload_completed" |
58787064 | 5440 | [(const_int 0)] |
58787064 JH |
5441 | { |
5442 | rtx pat; | |
5443 | operands[0] = gen_lowpart (SImode, operands[0]); | |
5444 | operands[1] = gen_lowpart (Pmode, operands[1]); | |
5445 | operands[2] = gen_lowpart (Pmode, operands[2]); | |
5446 | operands[3] = gen_lowpart (Pmode, operands[3]); | |
5447 | pat = gen_rtx_PLUS (Pmode, gen_rtx_PLUS (Pmode, operands[1], operands[2]), | |
5448 | operands[3]); | |
5449 | if (Pmode != SImode) | |
5450 | pat = gen_rtx_SUBREG (SImode, pat, 0); | |
5451 | emit_insn (gen_rtx_SET (VOIDmode, operands[0], pat)); | |
5452 | DONE; | |
0f40f9f7 | 5453 | } |
58787064 JH |
5454 | [(set_attr "type" "lea") |
5455 | (set_attr "mode" "SI")]) | |
5456 | ||
ac62a60e JH |
5457 | (define_insn_and_split "*lea_general_1_zext" |
5458 | [(set (match_operand:DI 0 "register_operand" "=r") | |
5459 | (zero_extend:DI | |
5460 | (plus:SI (plus:SI (match_operand:SI 1 "register_operand" "r") | |
5461 | (match_operand:SI 2 "register_operand" "r")) | |
5462 | (match_operand:SI 3 "immediate_operand" "i"))))] | |
5463 | "TARGET_64BIT" | |
5464 | "#" | |
5465 | "&& reload_completed" | |
5466 | [(set (match_dup 0) | |
5467 | (zero_extend:DI (subreg:SI (plus:DI (plus:DI (match_dup 1) | |
5468 | (match_dup 2)) | |
5469 | (match_dup 3)) 0)))] | |
ac62a60e JH |
5470 | { |
5471 | operands[1] = gen_lowpart (Pmode, operands[1]); | |
5472 | operands[2] = gen_lowpart (Pmode, operands[2]); | |
5473 | operands[3] = gen_lowpart (Pmode, operands[3]); | |
0f40f9f7 | 5474 | } |
ac62a60e JH |
5475 | [(set_attr "type" "lea") |
5476 | (set_attr "mode" "SI")]) | |
5477 | ||
58787064 JH |
5478 | (define_insn_and_split "*lea_general_2" |
5479 | [(set (match_operand 0 "register_operand" "=r") | |
5480 | (plus (mult (match_operand 1 "register_operand" "r") | |
5481 | (match_operand 2 "const248_operand" "i")) | |
5482 | (match_operand 3 "nonmemory_operand" "ri")))] | |
ac62a60e JH |
5483 | "(GET_MODE (operands[0]) == QImode || GET_MODE (operands[0]) == HImode |
5484 | || (TARGET_64BIT && GET_MODE (operands[0]) == SImode)) | |
58787064 JH |
5485 | && (!TARGET_PARTIAL_REG_STALL || optimize_size) |
5486 | && GET_MODE (operands[0]) == GET_MODE (operands[1]) | |
5487 | && (GET_MODE (operands[0]) == GET_MODE (operands[3]) | |
5488 | || GET_MODE (operands[3]) == VOIDmode)" | |
5489 | "#" | |
cb694d2c | 5490 | "&& reload_completed" |
58787064 | 5491 | [(const_int 0)] |
58787064 JH |
5492 | { |
5493 | rtx pat; | |
5494 | operands[0] = gen_lowpart (SImode, operands[0]); | |
5495 | operands[1] = gen_lowpart (Pmode, operands[1]); | |
5496 | operands[3] = gen_lowpart (Pmode, operands[3]); | |
5497 | pat = gen_rtx_PLUS (Pmode, gen_rtx_MULT (Pmode, operands[1], operands[2]), | |
5498 | operands[3]); | |
5499 | if (Pmode != SImode) | |
5500 | pat = gen_rtx_SUBREG (SImode, pat, 0); | |
5501 | emit_insn (gen_rtx_SET (VOIDmode, operands[0], pat)); | |
5502 | DONE; | |
0f40f9f7 | 5503 | } |
58787064 JH |
5504 | [(set_attr "type" "lea") |
5505 | (set_attr "mode" "SI")]) | |
5506 | ||
ac62a60e JH |
5507 | (define_insn_and_split "*lea_general_2_zext" |
5508 | [(set (match_operand:DI 0 "register_operand" "=r") | |
5509 | (zero_extend:DI | |
5510 | (plus:SI (mult:SI (match_operand:SI 1 "register_operand" "r") | |
5511 | (match_operand:SI 2 "const248_operand" "n")) | |
5512 | (match_operand:SI 3 "nonmemory_operand" "ri"))))] | |
5513 | "TARGET_64BIT" | |
5514 | "#" | |
5515 | "&& reload_completed" | |
5516 | [(set (match_dup 0) | |
5517 | (zero_extend:DI (subreg:SI (plus:DI (mult:DI (match_dup 1) | |
5518 | (match_dup 2)) | |
5519 | (match_dup 3)) 0)))] | |
ac62a60e JH |
5520 | { |
5521 | operands[1] = gen_lowpart (Pmode, operands[1]); | |
5522 | operands[3] = gen_lowpart (Pmode, operands[3]); | |
0f40f9f7 | 5523 | } |
ac62a60e JH |
5524 | [(set_attr "type" "lea") |
5525 | (set_attr "mode" "SI")]) | |
5526 | ||
58787064 JH |
5527 | (define_insn_and_split "*lea_general_3" |
5528 | [(set (match_operand 0 "register_operand" "=r") | |
5529 | (plus (plus (mult (match_operand 1 "register_operand" "r") | |
5530 | (match_operand 2 "const248_operand" "i")) | |
5531 | (match_operand 3 "register_operand" "r")) | |
5532 | (match_operand 4 "immediate_operand" "i")))] | |
ac62a60e JH |
5533 | "(GET_MODE (operands[0]) == QImode || GET_MODE (operands[0]) == HImode |
5534 | || (TARGET_64BIT && GET_MODE (operands[0]) == SImode)) | |
58787064 JH |
5535 | && (!TARGET_PARTIAL_REG_STALL || optimize_size) |
5536 | && GET_MODE (operands[0]) == GET_MODE (operands[1]) | |
5537 | && GET_MODE (operands[0]) == GET_MODE (operands[3])" | |
5538 | "#" | |
cb694d2c | 5539 | "&& reload_completed" |
58787064 | 5540 | [(const_int 0)] |
58787064 JH |
5541 | { |
5542 | rtx pat; | |
5543 | operands[0] = gen_lowpart (SImode, operands[0]); | |
5544 | operands[1] = gen_lowpart (Pmode, operands[1]); | |
5545 | operands[3] = gen_lowpart (Pmode, operands[3]); | |
5546 | operands[4] = gen_lowpart (Pmode, operands[4]); | |
5547 | pat = gen_rtx_PLUS (Pmode, | |
5548 | gen_rtx_PLUS (Pmode, gen_rtx_MULT (Pmode, operands[1], | |
5549 | operands[2]), | |
5550 | operands[3]), | |
5551 | operands[4]); | |
5552 | if (Pmode != SImode) | |
5553 | pat = gen_rtx_SUBREG (SImode, pat, 0); | |
5554 | emit_insn (gen_rtx_SET (VOIDmode, operands[0], pat)); | |
5555 | DONE; | |
0f40f9f7 | 5556 | } |
58787064 JH |
5557 | [(set_attr "type" "lea") |
5558 | (set_attr "mode" "SI")]) | |
5559 | ||
ac62a60e JH |
5560 | (define_insn_and_split "*lea_general_3_zext" |
5561 | [(set (match_operand:DI 0 "register_operand" "=r") | |
5562 | (zero_extend:DI | |
5563 | (plus:SI (plus:SI (mult:SI (match_operand:SI 1 "register_operand" "r") | |
5564 | (match_operand:SI 2 "const248_operand" "n")) | |
5565 | (match_operand:SI 3 "register_operand" "r")) | |
5566 | (match_operand:SI 4 "immediate_operand" "i"))))] | |
5567 | "TARGET_64BIT" | |
5568 | "#" | |
5569 | "&& reload_completed" | |
5570 | [(set (match_dup 0) | |
5571 | (zero_extend:DI (subreg:SI (plus:DI (plus:DI (mult:DI (match_dup 1) | |
5572 | (match_dup 2)) | |
5573 | (match_dup 3)) | |
5574 | (match_dup 4)) 0)))] | |
ac62a60e JH |
5575 | { |
5576 | operands[1] = gen_lowpart (Pmode, operands[1]); | |
5577 | operands[3] = gen_lowpart (Pmode, operands[3]); | |
5578 | operands[4] = gen_lowpart (Pmode, operands[4]); | |
0f40f9f7 | 5579 | } |
ac62a60e JH |
5580 | [(set_attr "type" "lea") |
5581 | (set_attr "mode" "SI")]) | |
5582 | ||
9b70259d JH |
5583 | (define_insn "*adddi_1_rex64" |
5584 | [(set (match_operand:DI 0 "nonimmediate_operand" "=r,rm,r") | |
5585 | (plus:DI (match_operand:DI 1 "nonimmediate_operand" "%0,0,r") | |
5586 | (match_operand:DI 2 "x86_64_general_operand" "rme,re,re"))) | |
e075ae69 | 5587 | (clobber (reg:CC 17))] |
9b70259d | 5588 | "TARGET_64BIT && ix86_binary_operator_ok (PLUS, DImode, operands)" |
2ae0f82c | 5589 | { |
e075ae69 | 5590 | switch (get_attr_type (insn)) |
2ae0f82c | 5591 | { |
e075ae69 RH |
5592 | case TYPE_LEA: |
5593 | operands[2] = SET_SRC (XVECEXP (PATTERN (insn), 0, 0)); | |
0f40f9f7 | 5594 | return "lea{q}\t{%a2, %0|%0, %a2}"; |
2ae0f82c | 5595 | |
e075ae69 RH |
5596 | case TYPE_INCDEC: |
5597 | if (! rtx_equal_p (operands[0], operands[1])) | |
5598 | abort (); | |
5599 | if (operands[2] == const1_rtx) | |
0f40f9f7 | 5600 | return "inc{q}\t%0"; |
e075ae69 | 5601 | else if (operands[2] == constm1_rtx) |
0f40f9f7 | 5602 | return "dec{q}\t%0"; |
2ae0f82c | 5603 | else |
9b70259d | 5604 | abort (); |
2ae0f82c | 5605 | |
e075ae69 RH |
5606 | default: |
5607 | if (! rtx_equal_p (operands[0], operands[1])) | |
5608 | abort (); | |
2ae0f82c | 5609 | |
e075ae69 RH |
5610 | /* Make things pretty and `subl $4,%eax' rather than `addl $-4, %eax'. |
5611 | Exceptions: -128 encodes smaller than 128, so swap sign and op. */ | |
5612 | if (GET_CODE (operands[2]) == CONST_INT | |
ef6257cd | 5613 | /* Avoid overflows. */ |
0f40f9f7 | 5614 | && ((INTVAL (operands[2]) & ((((unsigned int) 1) << 31) - 1))) |
e075ae69 RH |
5615 | && (INTVAL (operands[2]) == 128 |
5616 | || (INTVAL (operands[2]) < 0 | |
5617 | && INTVAL (operands[2]) != -128))) | |
5618 | { | |
5619 | operands[2] = GEN_INT (-INTVAL (operands[2])); | |
0f40f9f7 | 5620 | return "sub{q}\t{%2, %0|%0, %2}"; |
e075ae69 | 5621 | } |
0f40f9f7 | 5622 | return "add{q}\t{%2, %0|%0, %2}"; |
e075ae69 | 5623 | } |
0f40f9f7 | 5624 | } |
e075ae69 RH |
5625 | [(set (attr "type") |
5626 | (cond [(eq_attr "alternative" "2") | |
5627 | (const_string "lea") | |
5628 | ; Current assemblers are broken and do not allow @GOTOFF in | |
5629 | ; ought but a memory context. | |
9b70259d | 5630 | (match_operand:DI 2 "pic_symbolic_operand" "") |
e075ae69 | 5631 | (const_string "lea") |
9b70259d | 5632 | (match_operand:DI 2 "incdec_operand" "") |
e075ae69 RH |
5633 | (const_string "incdec") |
5634 | ] | |
6ef67412 | 5635 | (const_string "alu"))) |
9b70259d | 5636 | (set_attr "mode" "DI")]) |
e075ae69 | 5637 | |
1c27d4b2 JH |
5638 | ;; Convert lea to the lea pattern to avoid flags dependency. |
5639 | (define_split | |
9b70259d JH |
5640 | [(set (match_operand:DI 0 "register_operand" "") |
5641 | (plus:DI (match_operand:DI 1 "register_operand" "") | |
5642 | (match_operand:DI 2 "x86_64_nonmemory_operand" ""))) | |
1c27d4b2 | 5643 | (clobber (reg:CC 17))] |
1b0c37d7 | 5644 | "TARGET_64BIT && reload_completed |
abe24fb3 | 5645 | && true_regnum (operands[0]) != true_regnum (operands[1])" |
9b70259d JH |
5646 | [(set (match_dup 0) |
5647 | (plus:DI (match_dup 1) | |
5648 | (match_dup 2)))] | |
5649 | "") | |
1c27d4b2 | 5650 | |
9b70259d | 5651 | (define_insn "*adddi_2_rex64" |
16189740 RH |
5652 | [(set (reg 17) |
5653 | (compare | |
9b70259d JH |
5654 | (plus:DI (match_operand:DI 1 "nonimmediate_operand" "%0,0") |
5655 | (match_operand:DI 2 "x86_64_general_operand" "rme,re")) | |
e075ae69 | 5656 | (const_int 0))) |
9b70259d JH |
5657 | (set (match_operand:DI 0 "nonimmediate_operand" "=r,rm") |
5658 | (plus:DI (match_dup 1) (match_dup 2)))] | |
5659 | "TARGET_64BIT && ix86_match_ccmode (insn, CCGOCmode) | |
5660 | && ix86_binary_operator_ok (PLUS, DImode, operands) | |
e075ae69 | 5661 | /* Current assemblers are broken and do not allow @GOTOFF in |
892a2d68 | 5662 | ought but a memory context. */ |
e075ae69 | 5663 | && ! pic_symbolic_operand (operands[2], VOIDmode)" |
886c62d1 | 5664 | { |
e075ae69 | 5665 | switch (get_attr_type (insn)) |
96f218bb | 5666 | { |
e075ae69 RH |
5667 | case TYPE_INCDEC: |
5668 | if (! rtx_equal_p (operands[0], operands[1])) | |
5669 | abort (); | |
5670 | if (operands[2] == const1_rtx) | |
0f40f9f7 | 5671 | return "inc{q}\t%0"; |
e075ae69 | 5672 | else if (operands[2] == constm1_rtx) |
0f40f9f7 | 5673 | return "dec{q}\t%0"; |
96f218bb | 5674 | else |
9b70259d | 5675 | abort (); |
96f218bb | 5676 | |
e075ae69 RH |
5677 | default: |
5678 | if (! rtx_equal_p (operands[0], operands[1])) | |
5679 | abort (); | |
9b70259d JH |
5680 | /* ???? We ought to handle there the 32bit case too |
5681 | - do we need new constrant? */ | |
e075ae69 RH |
5682 | /* Make things pretty and `subl $4,%eax' rather than `addl $-4, %eax'. |
5683 | Exceptions: -128 encodes smaller than 128, so swap sign and op. */ | |
5684 | if (GET_CODE (operands[2]) == CONST_INT | |
ef6257cd | 5685 | /* Avoid overflows. */ |
0f40f9f7 | 5686 | && ((INTVAL (operands[2]) & ((((unsigned int) 1) << 31) - 1))) |
e075ae69 RH |
5687 | && (INTVAL (operands[2]) == 128 |
5688 | || (INTVAL (operands[2]) < 0 | |
5689 | && INTVAL (operands[2]) != -128))) | |
5690 | { | |
5691 | operands[2] = GEN_INT (-INTVAL (operands[2])); | |
0f40f9f7 | 5692 | return "sub{q}\t{%2, %0|%0, %2}"; |
e075ae69 | 5693 | } |
0f40f9f7 | 5694 | return "add{q}\t{%2, %0|%0, %2}"; |
9c530261 | 5695 | } |
0f40f9f7 | 5696 | } |
e075ae69 | 5697 | [(set (attr "type") |
9b70259d | 5698 | (if_then_else (match_operand:DI 2 "incdec_operand" "") |
e075ae69 | 5699 | (const_string "incdec") |
6ef67412 | 5700 | (const_string "alu"))) |
9b70259d | 5701 | (set_attr "mode" "DI")]) |
e075ae69 | 5702 | |
e74061a9 | 5703 | (define_insn "*adddi_3_rex64" |
d90ffc8d | 5704 | [(set (reg 17) |
9b70259d JH |
5705 | (compare (neg:DI (match_operand:DI 2 "x86_64_general_operand" "rme")) |
5706 | (match_operand:DI 1 "x86_64_general_operand" "%0"))) | |
5707 | (clobber (match_scratch:DI 0 "=r"))] | |
e74061a9 JH |
5708 | "TARGET_64BIT |
5709 | && ix86_match_ccmode (insn, CCZmode) | |
d90ffc8d JH |
5710 | && (GET_CODE (operands[1]) != MEM || GET_CODE (operands[2]) != MEM) |
5711 | /* Current assemblers are broken and do not allow @GOTOFF in | |
892a2d68 | 5712 | ought but a memory context. */ |
d90ffc8d | 5713 | && ! pic_symbolic_operand (operands[2], VOIDmode)" |
d90ffc8d JH |
5714 | { |
5715 | switch (get_attr_type (insn)) | |
5716 | { | |
5717 | case TYPE_INCDEC: | |
5718 | if (! rtx_equal_p (operands[0], operands[1])) | |
5719 | abort (); | |
5720 | if (operands[2] == const1_rtx) | |
0f40f9f7 | 5721 | return "inc{q}\t%0"; |
d90ffc8d | 5722 | else if (operands[2] == constm1_rtx) |
0f40f9f7 | 5723 | return "dec{q}\t%0"; |
d90ffc8d | 5724 | else |
9b70259d | 5725 | abort (); |
d90ffc8d JH |
5726 | |
5727 | default: | |
5728 | if (! rtx_equal_p (operands[0], operands[1])) | |
5729 | abort (); | |
9b70259d JH |
5730 | /* ???? We ought to handle there the 32bit case too |
5731 | - do we need new constrant? */ | |
d90ffc8d JH |
5732 | /* Make things pretty and `subl $4,%eax' rather than `addl $-4, %eax'. |
5733 | Exceptions: -128 encodes smaller than 128, so swap sign and op. */ | |
5734 | if (GET_CODE (operands[2]) == CONST_INT | |
ef6257cd | 5735 | /* Avoid overflows. */ |
0f40f9f7 | 5736 | && ((INTVAL (operands[2]) & ((((unsigned int) 1) << 31) - 1))) |
d90ffc8d JH |
5737 | && (INTVAL (operands[2]) == 128 |
5738 | || (INTVAL (operands[2]) < 0 | |
5739 | && INTVAL (operands[2]) != -128))) | |
5740 | { | |
5741 | operands[2] = GEN_INT (-INTVAL (operands[2])); | |
0f40f9f7 | 5742 | return "sub{q}\t{%2, %0|%0, %2}"; |
d90ffc8d | 5743 | } |
0f40f9f7 | 5744 | return "add{q}\t{%2, %0|%0, %2}"; |
d90ffc8d | 5745 | } |
0f40f9f7 | 5746 | } |
d90ffc8d | 5747 | [(set (attr "type") |
9b70259d | 5748 | (if_then_else (match_operand:DI 2 "incdec_operand" "") |
d90ffc8d JH |
5749 | (const_string "incdec") |
5750 | (const_string "alu"))) | |
9b70259d | 5751 | (set_attr "mode" "DI")]) |
d90ffc8d | 5752 | |
9b70259d | 5753 | ; For comparisons against 1, -1 and 128, we may generate better code |
7e08e190 JH |
5754 | ; by converting cmp to add, inc or dec as done by peephole2. This pattern |
5755 | ; is matched then. We can't accept general immediate, because for | |
5756 | ; case of overflows, the result is messed up. | |
9b70259d | 5757 | ; This pattern also don't hold of 0x8000000000000000, since the value overflows |
7e08e190 | 5758 | ; when negated. |
d6a7951f | 5759 | ; Also carry flag is reversed compared to cmp, so this conversion is valid |
7e08e190 | 5760 | ; only for comparisons not depending on it. |
e74061a9 | 5761 | (define_insn "*adddi_4_rex64" |
9076b9c1 | 5762 | [(set (reg 17) |
9b70259d JH |
5763 | (compare (match_operand:DI 1 "nonimmediate_operand" "0") |
5764 | (match_operand:DI 2 "x86_64_immediate_operand" "e"))) | |
5765 | (clobber (match_scratch:DI 0 "=rm"))] | |
e74061a9 JH |
5766 | "TARGET_64BIT |
5767 | && ix86_match_ccmode (insn, CCGCmode)" | |
7e08e190 JH |
5768 | { |
5769 | switch (get_attr_type (insn)) | |
5770 | { | |
5771 | case TYPE_INCDEC: | |
5772 | if (operands[2] == constm1_rtx) | |
0f40f9f7 | 5773 | return "inc{q}\t%0"; |
7e08e190 | 5774 | else if (operands[2] == const1_rtx) |
0f40f9f7 | 5775 | return "dec{q}\t%0"; |
7e08e190 JH |
5776 | else |
5777 | abort(); | |
e075ae69 | 5778 | |
7e08e190 JH |
5779 | default: |
5780 | if (! rtx_equal_p (operands[0], operands[1])) | |
5781 | abort (); | |
5782 | /* Make things pretty and `subl $4,%eax' rather than `addl $-4, %eax'. | |
5783 | Exceptions: -128 encodes smaller than 128, so swap sign and op. */ | |
5784 | if ((INTVAL (operands[2]) == -128 | |
5785 | || (INTVAL (operands[2]) > 0 | |
ef6257cd JH |
5786 | && INTVAL (operands[2]) != 128)) |
5787 | /* Avoid overflows. */ | |
0f40f9f7 ZW |
5788 | && ((INTVAL (operands[2]) & ((((unsigned int) 1) << 31) - 1)))) |
5789 | return "sub{q}\t{%2, %0|%0, %2}"; | |
7e08e190 | 5790 | operands[2] = GEN_INT (-INTVAL (operands[2])); |
0f40f9f7 | 5791 | return "add{q}\t{%2, %0|%0, %2}"; |
7e08e190 | 5792 | } |
0f40f9f7 | 5793 | } |
7e08e190 | 5794 | [(set (attr "type") |
9b70259d | 5795 | (if_then_else (match_operand:DI 2 "incdec_operand" "") |
7e08e190 JH |
5796 | (const_string "incdec") |
5797 | (const_string "alu"))) | |
9b70259d | 5798 | (set_attr "mode" "DI")]) |
d90ffc8d | 5799 | |
e74061a9 | 5800 | (define_insn "*adddi_5_rex64" |
9076b9c1 JH |
5801 | [(set (reg 17) |
5802 | (compare | |
9b70259d JH |
5803 | (plus:DI (match_operand:DI 1 "nonimmediate_operand" "%0") |
5804 | (match_operand:DI 2 "x86_64_general_operand" "rme")) | |
9076b9c1 | 5805 | (const_int 0))) |
9b70259d | 5806 | (clobber (match_scratch:DI 0 "=r"))] |
e74061a9 JH |
5807 | "TARGET_64BIT |
5808 | && ix86_match_ccmode (insn, CCGOCmode) | |
9076b9c1 JH |
5809 | && (GET_CODE (operands[1]) != MEM || GET_CODE (operands[2]) != MEM) |
5810 | /* Current assemblers are broken and do not allow @GOTOFF in | |
892a2d68 | 5811 | ought but a memory context. */ |
9076b9c1 | 5812 | && ! pic_symbolic_operand (operands[2], VOIDmode)" |
9076b9c1 JH |
5813 | { |
5814 | switch (get_attr_type (insn)) | |
5815 | { | |
5816 | case TYPE_INCDEC: | |
5817 | if (! rtx_equal_p (operands[0], operands[1])) | |
5818 | abort (); | |
5819 | if (operands[2] == const1_rtx) | |
0f40f9f7 | 5820 | return "inc{q}\t%0"; |
9076b9c1 | 5821 | else if (operands[2] == constm1_rtx) |
0f40f9f7 | 5822 | return "dec{q}\t%0"; |
9076b9c1 JH |
5823 | else |
5824 | abort(); | |
5825 | ||
5826 | default: | |
5827 | if (! rtx_equal_p (operands[0], operands[1])) | |
5828 | abort (); | |
5829 | /* Make things pretty and `subl $4,%eax' rather than `addl $-4, %eax'. | |
5830 | Exceptions: -128 encodes smaller than 128, so swap sign and op. */ | |
5831 | if (GET_CODE (operands[2]) == CONST_INT | |
ef6257cd | 5832 | /* Avoid overflows. */ |
0f40f9f7 | 5833 | && ((INTVAL (operands[2]) & ((((unsigned int) 1) << 31) - 1))) |
9076b9c1 JH |
5834 | && (INTVAL (operands[2]) == 128 |
5835 | || (INTVAL (operands[2]) < 0 | |
5836 | && INTVAL (operands[2]) != -128))) | |
5837 | { | |
5838 | operands[2] = GEN_INT (-INTVAL (operands[2])); | |
0f40f9f7 | 5839 | return "sub{q}\t{%2, %0|%0, %2}"; |
9076b9c1 | 5840 | } |
0f40f9f7 | 5841 | return "add{q}\t{%2, %0|%0, %2}"; |
9076b9c1 | 5842 | } |
0f40f9f7 | 5843 | } |
9076b9c1 | 5844 | [(set (attr "type") |
9b70259d | 5845 | (if_then_else (match_operand:DI 2 "incdec_operand" "") |
9076b9c1 JH |
5846 | (const_string "incdec") |
5847 | (const_string "alu"))) | |
9b70259d | 5848 | (set_attr "mode" "DI")]) |
2ae0f82c | 5849 | |
e075ae69 | 5850 | |
9b70259d JH |
5851 | (define_insn "*addsi_1" |
5852 | [(set (match_operand:SI 0 "nonimmediate_operand" "=r,rm,r") | |
5853 | (plus:SI (match_operand:SI 1 "nonimmediate_operand" "%0,0,r") | |
5854 | (match_operand:SI 2 "general_operand" "rmni,rni,rni"))) | |
58787064 | 5855 | (clobber (reg:CC 17))] |
9b70259d | 5856 | "ix86_binary_operator_ok (PLUS, SImode, operands)" |
58787064 JH |
5857 | { |
5858 | switch (get_attr_type (insn)) | |
5859 | { | |
5860 | case TYPE_LEA: | |
9b70259d | 5861 | operands[2] = SET_SRC (XVECEXP (PATTERN (insn), 0, 0)); |
0f40f9f7 | 5862 | return "lea{l}\t{%a2, %0|%0, %a2}"; |
9b70259d | 5863 | |
58787064 | 5864 | case TYPE_INCDEC: |
9b70259d JH |
5865 | if (! rtx_equal_p (operands[0], operands[1])) |
5866 | abort (); | |
58787064 | 5867 | if (operands[2] == const1_rtx) |
0f40f9f7 | 5868 | return "inc{l}\t%0"; |
9b70259d | 5869 | else if (operands[2] == constm1_rtx) |
0f40f9f7 | 5870 | return "dec{l}\t%0"; |
9b70259d JH |
5871 | else |
5872 | abort(); | |
58787064 JH |
5873 | |
5874 | default: | |
9b70259d JH |
5875 | if (! rtx_equal_p (operands[0], operands[1])) |
5876 | abort (); | |
5877 | ||
58787064 JH |
5878 | /* Make things pretty and `subl $4,%eax' rather than `addl $-4, %eax'. |
5879 | Exceptions: -128 encodes smaller than 128, so swap sign and op. */ | |
5880 | if (GET_CODE (operands[2]) == CONST_INT | |
5881 | && (INTVAL (operands[2]) == 128 | |
5882 | || (INTVAL (operands[2]) < 0 | |
5883 | && INTVAL (operands[2]) != -128))) | |
9b70259d JH |
5884 | { |
5885 | operands[2] = GEN_INT (-INTVAL (operands[2])); | |
0f40f9f7 | 5886 | return "sub{l}\t{%2, %0|%0, %2}"; |
9b70259d | 5887 | } |
0f40f9f7 | 5888 | return "add{l}\t{%2, %0|%0, %2}"; |
58787064 | 5889 | } |
0f40f9f7 | 5890 | } |
58787064 | 5891 | [(set (attr "type") |
9b70259d JH |
5892 | (cond [(eq_attr "alternative" "2") |
5893 | (const_string "lea") | |
5894 | ; Current assemblers are broken and do not allow @GOTOFF in | |
5895 | ; ought but a memory context. | |
5896 | (match_operand:SI 2 "pic_symbolic_operand" "") | |
5897 | (const_string "lea") | |
5898 | (match_operand:SI 2 "incdec_operand" "") | |
5899 | (const_string "incdec") | |
5900 | ] | |
5901 | (const_string "alu"))) | |
5902 | (set_attr "mode" "SI")]) | |
58787064 | 5903 | |
9b70259d JH |
5904 | ;; Convert lea to the lea pattern to avoid flags dependency. |
5905 | (define_split | |
5906 | [(set (match_operand 0 "register_operand" "") | |
5907 | (plus (match_operand 1 "register_operand" "") | |
5908 | (match_operand 2 "nonmemory_operand" ""))) | |
e075ae69 | 5909 | (clobber (reg:CC 17))] |
9b70259d JH |
5910 | "reload_completed |
5911 | && true_regnum (operands[0]) != true_regnum (operands[1])" | |
5912 | [(const_int 0)] | |
9b70259d JH |
5913 | { |
5914 | rtx pat; | |
5915 | /* In -fPIC mode the constructs like (const (unspec [symbol_ref])) | |
5916 | may confuse gen_lowpart. */ | |
5917 | if (GET_MODE (operands[0]) != Pmode) | |
5918 | { | |
5919 | operands[1] = gen_lowpart (Pmode, operands[1]); | |
5920 | operands[2] = gen_lowpart (Pmode, operands[2]); | |
5921 | } | |
5922 | operands[0] = gen_lowpart (SImode, operands[0]); | |
5923 | pat = gen_rtx_PLUS (Pmode, operands[1], operands[2]); | |
5924 | if (Pmode != SImode) | |
5925 | pat = gen_rtx_SUBREG (SImode, pat, 0); | |
5926 | emit_insn (gen_rtx_SET (VOIDmode, operands[0], pat)); | |
5927 | DONE; | |
0f40f9f7 | 5928 | }) |
9b70259d JH |
5929 | |
5930 | ;; It may seem that nonimmediate operand is proper one for operand 1. | |
5931 | ;; The addsi_1 pattern allows nonimmediate operand at that place and | |
5932 | ;; we take care in ix86_binary_operator_ok to not allow two memory | |
5933 | ;; operands so proper swapping will be done in reload. This allow | |
5934 | ;; patterns constructed from addsi_1 to match. | |
5935 | (define_insn "addsi_1_zext" | |
5936 | [(set (match_operand:DI 0 "register_operand" "=r,r") | |
5937 | (zero_extend:DI | |
5938 | (plus:SI (match_operand:SI 1 "nonimmediate_operand" "%0,r") | |
5939 | (match_operand:SI 2 "general_operand" "rmni,rni")))) | |
5940 | (clobber (reg:CC 17))] | |
5941 | "TARGET_64BIT && ix86_binary_operator_ok (PLUS, SImode, operands)" | |
886c62d1 | 5942 | { |
e075ae69 | 5943 | switch (get_attr_type (insn)) |
7c802a40 | 5944 | { |
9b70259d JH |
5945 | case TYPE_LEA: |
5946 | operands[2] = SET_SRC (XVECEXP (PATTERN (insn), 0, 0)); | |
0f40f9f7 | 5947 | return "lea{l}\t{%a2, %k0|%k0, %a2}"; |
9b70259d | 5948 | |
e075ae69 RH |
5949 | case TYPE_INCDEC: |
5950 | if (operands[2] == const1_rtx) | |
0f40f9f7 | 5951 | return "inc{l}\t%k0"; |
9b70259d | 5952 | else if (operands[2] == constm1_rtx) |
0f40f9f7 | 5953 | return "dec{l}\t%k0"; |
9b70259d JH |
5954 | else |
5955 | abort(); | |
5956 | ||
5957 | default: | |
5958 | /* Make things pretty and `subl $4,%eax' rather than `addl $-4, %eax'. | |
5959 | Exceptions: -128 encodes smaller than 128, so swap sign and op. */ | |
5960 | if (GET_CODE (operands[2]) == CONST_INT | |
5961 | && (INTVAL (operands[2]) == 128 | |
5962 | || (INTVAL (operands[2]) < 0 | |
5963 | && INTVAL (operands[2]) != -128))) | |
5964 | { | |
5965 | operands[2] = GEN_INT (-INTVAL (operands[2])); | |
0f40f9f7 | 5966 | return "sub{l}\t{%2, %k0|%k0, %2}"; |
9b70259d | 5967 | } |
0f40f9f7 | 5968 | return "add{l}\t{%2, %k0|%k0, %2}"; |
9b70259d | 5969 | } |
0f40f9f7 | 5970 | } |
9b70259d JH |
5971 | [(set (attr "type") |
5972 | (cond [(eq_attr "alternative" "1") | |
5973 | (const_string "lea") | |
5974 | ; Current assemblers are broken and do not allow @GOTOFF in | |
5975 | ; ought but a memory context. | |
5976 | (match_operand:SI 2 "pic_symbolic_operand" "") | |
5977 | (const_string "lea") | |
5978 | (match_operand:SI 2 "incdec_operand" "") | |
5979 | (const_string "incdec") | |
5980 | ] | |
5981 | (const_string "alu"))) | |
5982 | (set_attr "mode" "SI")]) | |
5983 | ||
5984 | ;; Convert lea to the lea pattern to avoid flags dependency. | |
5985 | (define_split | |
5986 | [(set (match_operand:DI 0 "register_operand" "") | |
5987 | (zero_extend:DI | |
5988 | (plus:SI (match_operand:SI 1 "register_operand" "") | |
5989 | (match_operand:SI 2 "nonmemory_operand" "")))) | |
5990 | (clobber (reg:CC 17))] | |
5991 | "reload_completed | |
5992 | && true_regnum (operands[0]) != true_regnum (operands[1])" | |
5993 | [(set (match_dup 0) | |
5994 | (zero_extend:DI (subreg:SI (plus:DI (match_dup 1) (match_dup 2)) 0)))] | |
9b70259d JH |
5995 | { |
5996 | operands[1] = gen_lowpart (Pmode, operands[1]); | |
5997 | operands[2] = gen_lowpart (Pmode, operands[2]); | |
0f40f9f7 | 5998 | }) |
9b70259d JH |
5999 | |
6000 | (define_insn "*addsi_2" | |
6001 | [(set (reg 17) | |
6002 | (compare | |
6003 | (plus:SI (match_operand:SI 1 "nonimmediate_operand" "%0,0") | |
6004 | (match_operand:SI 2 "general_operand" "rmni,rni")) | |
6005 | (const_int 0))) | |
6006 | (set (match_operand:SI 0 "nonimmediate_operand" "=r,rm") | |
6007 | (plus:SI (match_dup 1) (match_dup 2)))] | |
6008 | "ix86_match_ccmode (insn, CCGOCmode) | |
6009 | && ix86_binary_operator_ok (PLUS, SImode, operands) | |
6010 | /* Current assemblers are broken and do not allow @GOTOFF in | |
892a2d68 | 6011 | ought but a memory context. */ |
9b70259d | 6012 | && ! pic_symbolic_operand (operands[2], VOIDmode)" |
9b70259d JH |
6013 | { |
6014 | switch (get_attr_type (insn)) | |
6015 | { | |
6016 | case TYPE_INCDEC: | |
6017 | if (! rtx_equal_p (operands[0], operands[1])) | |
6018 | abort (); | |
6019 | if (operands[2] == const1_rtx) | |
0f40f9f7 | 6020 | return "inc{l}\t%0"; |
9b70259d | 6021 | else if (operands[2] == constm1_rtx) |
0f40f9f7 | 6022 | return "dec{l}\t%0"; |
9b70259d JH |
6023 | else |
6024 | abort(); | |
6025 | ||
6026 | default: | |
6027 | if (! rtx_equal_p (operands[0], operands[1])) | |
6028 | abort (); | |
6029 | /* Make things pretty and `subl $4,%eax' rather than `addl $-4, %eax'. | |
6030 | Exceptions: -128 encodes smaller than 128, so swap sign and op. */ | |
6031 | if (GET_CODE (operands[2]) == CONST_INT | |
6032 | && (INTVAL (operands[2]) == 128 | |
6033 | || (INTVAL (operands[2]) < 0 | |
6034 | && INTVAL (operands[2]) != -128))) | |
6035 | { | |
6036 | operands[2] = GEN_INT (-INTVAL (operands[2])); | |
0f40f9f7 | 6037 | return "sub{l}\t{%2, %0|%0, %2}"; |
9b70259d | 6038 | } |
0f40f9f7 | 6039 | return "add{l}\t{%2, %0|%0, %2}"; |
9b70259d | 6040 | } |
0f40f9f7 | 6041 | } |
9b70259d JH |
6042 | [(set (attr "type") |
6043 | (if_then_else (match_operand:SI 2 "incdec_operand" "") | |
6044 | (const_string "incdec") | |
6045 | (const_string "alu"))) | |
6046 | (set_attr "mode" "SI")]) | |
6047 | ||
6048 | ;; See comment for addsi_1_zext why we do use nonimmediate_operand | |
6049 | (define_insn "*addsi_2_zext" | |
6050 | [(set (reg 17) | |
6051 | (compare | |
6052 | (plus:SI (match_operand:SI 1 "nonimmediate_operand" "%0") | |
6053 | (match_operand:SI 2 "general_operand" "rmni")) | |
6054 | (const_int 0))) | |
6055 | (set (match_operand:DI 0 "register_operand" "=r") | |
6056 | (zero_extend:DI (plus:SI (match_dup 1) (match_dup 2))))] | |
6057 | "TARGET_64BIT && ix86_match_ccmode (insn, CCGOCmode) | |
6058 | && ix86_binary_operator_ok (PLUS, SImode, operands) | |
6059 | /* Current assemblers are broken and do not allow @GOTOFF in | |
892a2d68 | 6060 | ought but a memory context. */ |
9b70259d | 6061 | && ! pic_symbolic_operand (operands[2], VOIDmode)" |
9b70259d JH |
6062 | { |
6063 | switch (get_attr_type (insn)) | |
6064 | { | |
6065 | case TYPE_INCDEC: | |
6066 | if (operands[2] == const1_rtx) | |
0f40f9f7 | 6067 | return "inc{l}\t%k0"; |
9b70259d | 6068 | else if (operands[2] == constm1_rtx) |
0f40f9f7 | 6069 | return "dec{l}\t%k0"; |
9b70259d JH |
6070 | else |
6071 | abort(); | |
6072 | ||
6073 | default: | |
6074 | /* Make things pretty and `subl $4,%eax' rather than `addl $-4, %eax'. | |
6075 | Exceptions: -128 encodes smaller than 128, so swap sign and op. */ | |
6076 | if (GET_CODE (operands[2]) == CONST_INT | |
6077 | && (INTVAL (operands[2]) == 128 | |
6078 | || (INTVAL (operands[2]) < 0 | |
6079 | && INTVAL (operands[2]) != -128))) | |
6080 | { | |
6081 | operands[2] = GEN_INT (-INTVAL (operands[2])); | |
0f40f9f7 | 6082 | return "sub{l}\t{%2, %k0|%k0, %2}"; |
9b70259d | 6083 | } |
0f40f9f7 | 6084 | return "add{l}\t{%2, %k0|%k0, %2}"; |
9b70259d | 6085 | } |
0f40f9f7 | 6086 | } |
9b70259d JH |
6087 | [(set (attr "type") |
6088 | (if_then_else (match_operand:SI 2 "incdec_operand" "") | |
6089 | (const_string "incdec") | |
6090 | (const_string "alu"))) | |
6091 | (set_attr "mode" "SI")]) | |
6092 | ||
6093 | (define_insn "*addsi_3" | |
6094 | [(set (reg 17) | |
6095 | (compare (neg:SI (match_operand:SI 2 "general_operand" "rmni")) | |
6096 | (match_operand:SI 1 "nonimmediate_operand" "%0"))) | |
6097 | (clobber (match_scratch:SI 0 "=r"))] | |
6098 | "ix86_match_ccmode (insn, CCZmode) | |
6099 | && (GET_CODE (operands[1]) != MEM || GET_CODE (operands[2]) != MEM) | |
6100 | /* Current assemblers are broken and do not allow @GOTOFF in | |
892a2d68 | 6101 | ought but a memory context. */ |
9b70259d | 6102 | && ! pic_symbolic_operand (operands[2], VOIDmode)" |
9b70259d JH |
6103 | { |
6104 | switch (get_attr_type (insn)) | |
6105 | { | |
6106 | case TYPE_INCDEC: | |
6107 | if (! rtx_equal_p (operands[0], operands[1])) | |
6108 | abort (); | |
6109 | if (operands[2] == const1_rtx) | |
0f40f9f7 | 6110 | return "inc{l}\t%0"; |
9b70259d | 6111 | else if (operands[2] == constm1_rtx) |
0f40f9f7 | 6112 | return "dec{l}\t%0"; |
9b70259d JH |
6113 | else |
6114 | abort(); | |
6115 | ||
6116 | default: | |
6117 | if (! rtx_equal_p (operands[0], operands[1])) | |
6118 | abort (); | |
6119 | /* Make things pretty and `subl $4,%eax' rather than `addl $-4, %eax'. | |
6120 | Exceptions: -128 encodes smaller than 128, so swap sign and op. */ | |
6121 | if (GET_CODE (operands[2]) == CONST_INT | |
6122 | && (INTVAL (operands[2]) == 128 | |
6123 | || (INTVAL (operands[2]) < 0 | |
6124 | && INTVAL (operands[2]) != -128))) | |
6125 | { | |
6126 | operands[2] = GEN_INT (-INTVAL (operands[2])); | |
0f40f9f7 | 6127 | return "sub{l}\t{%2, %0|%0, %2}"; |
9b70259d | 6128 | } |
0f40f9f7 | 6129 | return "add{l}\t{%2, %0|%0, %2}"; |
9b70259d | 6130 | } |
0f40f9f7 | 6131 | } |
9b70259d JH |
6132 | [(set (attr "type") |
6133 | (if_then_else (match_operand:SI 2 "incdec_operand" "") | |
6134 | (const_string "incdec") | |
6135 | (const_string "alu"))) | |
6136 | (set_attr "mode" "SI")]) | |
6137 | ||
6138 | ;; See comment for addsi_1_zext why we do use nonimmediate_operand | |
6139 | (define_insn "*addsi_3_zext" | |
6140 | [(set (reg 17) | |
6141 | (compare (neg:SI (match_operand:SI 2 "general_operand" "rmni")) | |
6142 | (match_operand:SI 1 "nonimmediate_operand" "%0"))) | |
6143 | (set (match_operand:DI 0 "register_operand" "=r") | |
6144 | (zero_extend:DI (plus:SI (match_dup 1) (match_dup 2))))] | |
6145 | "TARGET_64BIT && ix86_match_ccmode (insn, CCZmode) | |
6146 | && ix86_binary_operator_ok (PLUS, SImode, operands) | |
6147 | /* Current assemblers are broken and do not allow @GOTOFF in | |
892a2d68 | 6148 | ought but a memory context. */ |
9b70259d | 6149 | && ! pic_symbolic_operand (operands[2], VOIDmode)" |
9b70259d JH |
6150 | { |
6151 | switch (get_attr_type (insn)) | |
6152 | { | |
6153 | case TYPE_INCDEC: | |
6154 | if (operands[2] == const1_rtx) | |
0f40f9f7 | 6155 | return "inc{l}\t%k0"; |
9b70259d | 6156 | else if (operands[2] == constm1_rtx) |
0f40f9f7 | 6157 | return "dec{l}\t%k0"; |
9b70259d JH |
6158 | else |
6159 | abort(); | |
6160 | ||
6161 | default: | |
6162 | /* Make things pretty and `subl $4,%eax' rather than `addl $-4, %eax'. | |
6163 | Exceptions: -128 encodes smaller than 128, so swap sign and op. */ | |
6164 | if (GET_CODE (operands[2]) == CONST_INT | |
6165 | && (INTVAL (operands[2]) == 128 | |
6166 | || (INTVAL (operands[2]) < 0 | |
6167 | && INTVAL (operands[2]) != -128))) | |
6168 | { | |
6169 | operands[2] = GEN_INT (-INTVAL (operands[2])); | |
0f40f9f7 | 6170 | return "sub{l}\t{%2, %k0|%k0, %2}"; |
9b70259d | 6171 | } |
0f40f9f7 | 6172 | return "add{l}\t{%2, %k0|%k0, %2}"; |
9b70259d | 6173 | } |
0f40f9f7 | 6174 | } |
9b70259d JH |
6175 | [(set (attr "type") |
6176 | (if_then_else (match_operand:SI 2 "incdec_operand" "") | |
6177 | (const_string "incdec") | |
6178 | (const_string "alu"))) | |
6179 | (set_attr "mode" "SI")]) | |
6180 | ||
6181 | ; For comparisons agains 1, -1 and 128, we may generate better code | |
6182 | ; by converting cmp to add, inc or dec as done by peephole2. This pattern | |
6183 | ; is matched then. We can't accept general immediate, because for | |
6184 | ; case of overflows, the result is messed up. | |
6185 | ; This pattern also don't hold of 0x80000000, since the value overflows | |
6186 | ; when negated. | |
d6a7951f | 6187 | ; Also carry flag is reversed compared to cmp, so this conversion is valid |
9b70259d JH |
6188 | ; only for comparisons not depending on it. |
6189 | (define_insn "*addsi_4" | |
6190 | [(set (reg 17) | |
6191 | (compare (match_operand:SI 1 "nonimmediate_operand" "0") | |
6192 | (match_operand:SI 2 "const_int_operand" "n"))) | |
6193 | (clobber (match_scratch:SI 0 "=rm"))] | |
6194 | "ix86_match_ccmode (insn, CCGCmode) | |
6195 | && (INTVAL (operands[2]) & 0xffffffff) != 0x80000000" | |
9b70259d JH |
6196 | { |
6197 | switch (get_attr_type (insn)) | |
6198 | { | |
6199 | case TYPE_INCDEC: | |
6200 | if (operands[2] == constm1_rtx) | |
0f40f9f7 | 6201 | return "inc{l}\t%0"; |
9b70259d | 6202 | else if (operands[2] == const1_rtx) |
0f40f9f7 | 6203 | return "dec{l}\t%0"; |
9b70259d JH |
6204 | else |
6205 | abort(); | |
6206 | ||
6207 | default: | |
6208 | if (! rtx_equal_p (operands[0], operands[1])) | |
6209 | abort (); | |
6210 | /* Make things pretty and `subl $4,%eax' rather than `addl $-4, %eax'. | |
6211 | Exceptions: -128 encodes smaller than 128, so swap sign and op. */ | |
6212 | if ((INTVAL (operands[2]) == -128 | |
6213 | || (INTVAL (operands[2]) > 0 | |
6214 | && INTVAL (operands[2]) != 128))) | |
0f40f9f7 | 6215 | return "sub{l}\t{%2, %0|%0, %2}"; |
9b70259d | 6216 | operands[2] = GEN_INT (-INTVAL (operands[2])); |
0f40f9f7 | 6217 | return "add{l}\t{%2, %0|%0, %2}"; |
9b70259d | 6218 | } |
0f40f9f7 | 6219 | } |
9b70259d JH |
6220 | [(set (attr "type") |
6221 | (if_then_else (match_operand:SI 2 "incdec_operand" "") | |
6222 | (const_string "incdec") | |
6223 | (const_string "alu"))) | |
6224 | (set_attr "mode" "SI")]) | |
6225 | ||
6226 | (define_insn "*addsi_5" | |
6227 | [(set (reg 17) | |
6228 | (compare | |
6229 | (plus:SI (match_operand:SI 1 "nonimmediate_operand" "%0") | |
6230 | (match_operand:SI 2 "general_operand" "rmni")) | |
6231 | (const_int 0))) | |
6232 | (clobber (match_scratch:SI 0 "=r"))] | |
6233 | "ix86_match_ccmode (insn, CCGOCmode) | |
6234 | && (GET_CODE (operands[1]) != MEM || GET_CODE (operands[2]) != MEM) | |
6235 | /* Current assemblers are broken and do not allow @GOTOFF in | |
892a2d68 | 6236 | ought but a memory context. */ |
9b70259d | 6237 | && ! pic_symbolic_operand (operands[2], VOIDmode)" |
9b70259d JH |
6238 | { |
6239 | switch (get_attr_type (insn)) | |
6240 | { | |
6241 | case TYPE_INCDEC: | |
6242 | if (! rtx_equal_p (operands[0], operands[1])) | |
6243 | abort (); | |
6244 | if (operands[2] == const1_rtx) | |
0f40f9f7 | 6245 | return "inc{l}\t%0"; |
9b70259d | 6246 | else if (operands[2] == constm1_rtx) |
0f40f9f7 | 6247 | return "dec{l}\t%0"; |
9b70259d JH |
6248 | else |
6249 | abort(); | |
6250 | ||
6251 | default: | |
6252 | if (! rtx_equal_p (operands[0], operands[1])) | |
6253 | abort (); | |
6254 | /* Make things pretty and `subl $4,%eax' rather than `addl $-4, %eax'. | |
6255 | Exceptions: -128 encodes smaller than 128, so swap sign and op. */ | |
6256 | if (GET_CODE (operands[2]) == CONST_INT | |
6257 | && (INTVAL (operands[2]) == 128 | |
6258 | || (INTVAL (operands[2]) < 0 | |
6259 | && INTVAL (operands[2]) != -128))) | |
6260 | { | |
6261 | operands[2] = GEN_INT (-INTVAL (operands[2])); | |
0f40f9f7 | 6262 | return "sub{l}\t{%2, %0|%0, %2}"; |
9b70259d | 6263 | } |
0f40f9f7 | 6264 | return "add{l}\t{%2, %0|%0, %2}"; |
9b70259d | 6265 | } |
0f40f9f7 | 6266 | } |
9b70259d JH |
6267 | [(set (attr "type") |
6268 | (if_then_else (match_operand:SI 2 "incdec_operand" "") | |
6269 | (const_string "incdec") | |
6270 | (const_string "alu"))) | |
6271 | (set_attr "mode" "SI")]) | |
6272 | ||
6273 | (define_expand "addhi3" | |
6274 | [(parallel [(set (match_operand:HI 0 "nonimmediate_operand" "") | |
6275 | (plus:HI (match_operand:HI 1 "nonimmediate_operand" "") | |
6276 | (match_operand:HI 2 "general_operand" ""))) | |
6277 | (clobber (reg:CC 17))])] | |
6278 | "TARGET_HIMODE_MATH" | |
6279 | "ix86_expand_binary_operator (PLUS, HImode, operands); DONE;") | |
6280 | ||
6281 | ;; %%% After Dave's SUBREG_BYTE stuff goes in, re-enable incb %ah | |
6282 | ;; type optimizations enabled by define-splits. This is not important | |
6283 | ;; for PII, and in fact harmful because of partial register stalls. | |
6284 | ||
6285 | (define_insn "*addhi_1_lea" | |
6286 | [(set (match_operand:HI 0 "nonimmediate_operand" "=rm,r,r") | |
6287 | (plus:HI (match_operand:HI 1 "nonimmediate_operand" "%0,0,r") | |
6288 | (match_operand:HI 2 "general_operand" "ri,rm,rni"))) | |
6289 | (clobber (reg:CC 17))] | |
6290 | "!TARGET_PARTIAL_REG_STALL | |
6291 | && ix86_binary_operator_ok (PLUS, HImode, operands)" | |
9b70259d JH |
6292 | { |
6293 | switch (get_attr_type (insn)) | |
6294 | { | |
6295 | case TYPE_LEA: | |
0f40f9f7 | 6296 | return "#"; |
9b70259d JH |
6297 | case TYPE_INCDEC: |
6298 | if (operands[2] == const1_rtx) | |
0f40f9f7 | 6299 | return "inc{w}\t%0"; |
9b70259d JH |
6300 | else if (operands[2] == constm1_rtx |
6301 | || (GET_CODE (operands[2]) == CONST_INT | |
6302 | && INTVAL (operands[2]) == 65535)) | |
0f40f9f7 | 6303 | return "dec{w}\t%0"; |
9b70259d JH |
6304 | abort(); |
6305 | ||
6306 | default: | |
6307 | /* Make things pretty and `subl $4,%eax' rather than `addl $-4, %eax'. | |
6308 | Exceptions: -128 encodes smaller than 128, so swap sign and op. */ | |
6309 | if (GET_CODE (operands[2]) == CONST_INT | |
6310 | && (INTVAL (operands[2]) == 128 | |
6311 | || (INTVAL (operands[2]) < 0 | |
6312 | && INTVAL (operands[2]) != -128))) | |
6313 | { | |
6314 | operands[2] = GEN_INT (-INTVAL (operands[2])); | |
0f40f9f7 | 6315 | return "sub{w}\t{%2, %0|%0, %2}"; |
9b70259d | 6316 | } |
0f40f9f7 | 6317 | return "add{w}\t{%2, %0|%0, %2}"; |
9b70259d | 6318 | } |
0f40f9f7 | 6319 | } |
9b70259d JH |
6320 | [(set (attr "type") |
6321 | (if_then_else (eq_attr "alternative" "2") | |
6322 | (const_string "lea") | |
6323 | (if_then_else (match_operand:HI 2 "incdec_operand" "") | |
6324 | (const_string "incdec") | |
6325 | (const_string "alu")))) | |
6326 | (set_attr "mode" "HI,HI,SI")]) | |
6327 | ||
6328 | (define_insn "*addhi_1" | |
6329 | [(set (match_operand:HI 0 "nonimmediate_operand" "=rm,r") | |
6330 | (plus:HI (match_operand:HI 1 "nonimmediate_operand" "%0,0") | |
6331 | (match_operand:HI 2 "general_operand" "ri,rm"))) | |
6332 | (clobber (reg:CC 17))] | |
6333 | "TARGET_PARTIAL_REG_STALL | |
6334 | && ix86_binary_operator_ok (PLUS, HImode, operands)" | |
9b70259d JH |
6335 | { |
6336 | switch (get_attr_type (insn)) | |
6337 | { | |
6338 | case TYPE_INCDEC: | |
6339 | if (operands[2] == const1_rtx) | |
0f40f9f7 | 6340 | return "inc{w}\t%0"; |
9b70259d JH |
6341 | else if (operands[2] == constm1_rtx |
6342 | || (GET_CODE (operands[2]) == CONST_INT | |
6343 | && INTVAL (operands[2]) == 65535)) | |
0f40f9f7 | 6344 | return "dec{w}\t%0"; |
e075ae69 | 6345 | abort(); |
7c802a40 | 6346 | |
e075ae69 RH |
6347 | default: |
6348 | /* Make things pretty and `subl $4,%eax' rather than `addl $-4, %eax'. | |
6349 | Exceptions: -128 encodes smaller than 128, so swap sign and op. */ | |
6350 | if (GET_CODE (operands[2]) == CONST_INT | |
6351 | && (INTVAL (operands[2]) == 128 | |
6352 | || (INTVAL (operands[2]) < 0 | |
6353 | && INTVAL (operands[2]) != -128))) | |
6354 | { | |
6355 | operands[2] = GEN_INT (-INTVAL (operands[2])); | |
0f40f9f7 | 6356 | return "sub{w}\t{%2, %0|%0, %2}"; |
e075ae69 | 6357 | } |
0f40f9f7 | 6358 | return "add{w}\t{%2, %0|%0, %2}"; |
7c802a40 | 6359 | } |
0f40f9f7 | 6360 | } |
e075ae69 RH |
6361 | [(set (attr "type") |
6362 | (if_then_else (match_operand:HI 2 "incdec_operand" "") | |
6363 | (const_string "incdec") | |
6ef67412 JH |
6364 | (const_string "alu"))) |
6365 | (set_attr "mode" "HI")]) | |
7c802a40 | 6366 | |
e075ae69 | 6367 | (define_insn "*addhi_2" |
16189740 RH |
6368 | [(set (reg 17) |
6369 | (compare | |
e075ae69 RH |
6370 | (plus:HI (match_operand:HI 1 "nonimmediate_operand" "%0,0") |
6371 | (match_operand:HI 2 "general_operand" "rmni,rni")) | |
6372 | (const_int 0))) | |
6373 | (set (match_operand:HI 0 "nonimmediate_operand" "=r,rm") | |
6374 | (plus:HI (match_dup 1) (match_dup 2)))] | |
9076b9c1 | 6375 | "ix86_match_ccmode (insn, CCGOCmode) |
16189740 | 6376 | && ix86_binary_operator_ok (PLUS, HImode, operands)" |
e075ae69 RH |
6377 | { |
6378 | switch (get_attr_type (insn)) | |
b980bec0 | 6379 | { |
e075ae69 RH |
6380 | case TYPE_INCDEC: |
6381 | if (operands[2] == const1_rtx) | |
0f40f9f7 | 6382 | return "inc{w}\t%0"; |
e075ae69 RH |
6383 | else if (operands[2] == constm1_rtx |
6384 | || (GET_CODE (operands[2]) == CONST_INT | |
6385 | && INTVAL (operands[2]) == 65535)) | |
0f40f9f7 | 6386 | return "dec{w}\t%0"; |
e075ae69 | 6387 | abort(); |
b980bec0 | 6388 | |
e075ae69 RH |
6389 | default: |
6390 | /* Make things pretty and `subl $4,%eax' rather than `addl $-4, %eax'. | |
6391 | Exceptions: -128 encodes smaller than 128, so swap sign and op. */ | |
6392 | if (GET_CODE (operands[2]) == CONST_INT | |
6393 | && (INTVAL (operands[2]) == 128 | |
6394 | || (INTVAL (operands[2]) < 0 | |
6395 | && INTVAL (operands[2]) != -128))) | |
6396 | { | |
6397 | operands[2] = GEN_INT (-INTVAL (operands[2])); | |
0f40f9f7 | 6398 | return "sub{w}\t{%2, %0|%0, %2}"; |
e075ae69 | 6399 | } |
0f40f9f7 | 6400 | return "add{w}\t{%2, %0|%0, %2}"; |
b980bec0 | 6401 | } |
0f40f9f7 | 6402 | } |
e075ae69 RH |
6403 | [(set (attr "type") |
6404 | (if_then_else (match_operand:HI 2 "incdec_operand" "") | |
6405 | (const_string "incdec") | |
6ef67412 JH |
6406 | (const_string "alu"))) |
6407 | (set_attr "mode" "HI")]) | |
e075ae69 RH |
6408 | |
6409 | (define_insn "*addhi_3" | |
d90ffc8d | 6410 | [(set (reg 17) |
7e08e190 JH |
6411 | (compare (neg:HI (match_operand:HI 2 "general_operand" "rmni")) |
6412 | (match_operand:HI 1 "nonimmediate_operand" "%0"))) | |
d90ffc8d | 6413 | (clobber (match_scratch:HI 0 "=r"))] |
7e08e190 | 6414 | "ix86_match_ccmode (insn, CCZmode) |
d90ffc8d | 6415 | && (GET_CODE (operands[1]) != MEM || GET_CODE (operands[2]) != MEM)" |
d90ffc8d JH |
6416 | { |
6417 | switch (get_attr_type (insn)) | |
6418 | { | |
6419 | case TYPE_INCDEC: | |
6420 | if (operands[2] == const1_rtx) | |
0f40f9f7 | 6421 | return "inc{w}\t%0"; |
d90ffc8d JH |
6422 | else if (operands[2] == constm1_rtx |
6423 | || (GET_CODE (operands[2]) == CONST_INT | |
6424 | && INTVAL (operands[2]) == 65535)) | |
0f40f9f7 | 6425 | return "dec{w}\t%0"; |
d90ffc8d JH |
6426 | abort(); |
6427 | ||
6428 | default: | |
6429 | /* Make things pretty and `subl $4,%eax' rather than `addl $-4, %eax'. | |
6430 | Exceptions: -128 encodes smaller than 128, so swap sign and op. */ | |
6431 | if (GET_CODE (operands[2]) == CONST_INT | |
6432 | && (INTVAL (operands[2]) == 128 | |
6433 | || (INTVAL (operands[2]) < 0 | |
6434 | && INTVAL (operands[2]) != -128))) | |
6435 | { | |
6436 | operands[2] = GEN_INT (-INTVAL (operands[2])); | |
0f40f9f7 | 6437 | return "sub{w}\t{%2, %0|%0, %2}"; |
d90ffc8d | 6438 | } |
0f40f9f7 | 6439 | return "add{w}\t{%2, %0|%0, %2}"; |
d90ffc8d | 6440 | } |
0f40f9f7 | 6441 | } |
d90ffc8d JH |
6442 | [(set (attr "type") |
6443 | (if_then_else (match_operand:HI 2 "incdec_operand" "") | |
6444 | (const_string "incdec") | |
6445 | (const_string "alu"))) | |
6446 | (set_attr "mode" "HI")]) | |
6447 | ||
7e08e190 | 6448 | ; See comments above addsi_3_imm for details. |
d90ffc8d | 6449 | (define_insn "*addhi_4" |
9076b9c1 | 6450 | [(set (reg 17) |
7e08e190 JH |
6451 | (compare (match_operand:HI 1 "nonimmediate_operand" "0") |
6452 | (match_operand:HI 2 "const_int_operand" "n"))) | |
6453 | (clobber (match_scratch:HI 0 "=rm"))] | |
6454 | "ix86_match_ccmode (insn, CCGCmode) | |
6455 | && (INTVAL (operands[2]) & 0xffff) != 0x8000" | |
7e08e190 JH |
6456 | { |
6457 | switch (get_attr_type (insn)) | |
6458 | { | |
6459 | case TYPE_INCDEC: | |
6460 | if (operands[2] == constm1_rtx | |
6461 | || (GET_CODE (operands[2]) == CONST_INT | |
6462 | && INTVAL (operands[2]) == 65535)) | |
0f40f9f7 | 6463 | return "inc{w}\t%0"; |
7e08e190 | 6464 | else if (operands[2] == const1_rtx) |
0f40f9f7 | 6465 | return "dec{w}\t%0"; |
7e08e190 JH |
6466 | else |
6467 | abort(); | |
6468 | ||
6469 | default: | |
6470 | if (! rtx_equal_p (operands[0], operands[1])) | |
6471 | abort (); | |
6472 | /* Make things pretty and `subl $4,%eax' rather than `addl $-4, %eax'. | |
6473 | Exceptions: -128 encodes smaller than 128, so swap sign and op. */ | |
6474 | if ((INTVAL (operands[2]) == -128 | |
6475 | || (INTVAL (operands[2]) > 0 | |
6476 | && INTVAL (operands[2]) != 128))) | |
0f40f9f7 | 6477 | return "sub{w}\t{%2, %0|%0, %2}"; |
7e08e190 | 6478 | operands[2] = GEN_INT (-INTVAL (operands[2])); |
0f40f9f7 | 6479 | return "add{w}\t{%2, %0|%0, %2}"; |
7e08e190 | 6480 | } |
0f40f9f7 | 6481 | } |
7e08e190 JH |
6482 | [(set (attr "type") |
6483 | (if_then_else (match_operand:HI 2 "incdec_operand" "") | |
6484 | (const_string "incdec") | |
6485 | (const_string "alu"))) | |
6486 | (set_attr "mode" "SI")]) | |
b980bec0 | 6487 | |
d90ffc8d | 6488 | |
7e08e190 | 6489 | (define_insn "*addhi_5" |
9076b9c1 JH |
6490 | [(set (reg 17) |
6491 | (compare | |
6492 | (plus:HI (match_operand:HI 1 "nonimmediate_operand" "%0") | |
6493 | (match_operand:HI 2 "general_operand" "rmni")) | |
6494 | (const_int 0))) | |
6495 | (clobber (match_scratch:HI 0 "=r"))] | |
6496 | "ix86_match_ccmode (insn, CCGOCmode) | |
6497 | && (GET_CODE (operands[1]) != MEM || GET_CODE (operands[2]) != MEM)" | |
9076b9c1 JH |
6498 | { |
6499 | switch (get_attr_type (insn)) | |
6500 | { | |
6501 | case TYPE_INCDEC: | |
6502 | if (operands[2] == const1_rtx) | |
0f40f9f7 | 6503 | return "inc{w}\t%0"; |
9076b9c1 JH |
6504 | else if (operands[2] == constm1_rtx |
6505 | || (GET_CODE (operands[2]) == CONST_INT | |
6506 | && INTVAL (operands[2]) == 65535)) | |
0f40f9f7 | 6507 | return "dec{w}\t%0"; |
9076b9c1 JH |
6508 | abort(); |
6509 | ||
6510 | default: | |
6511 | /* Make things pretty and `subl $4,%eax' rather than `addl $-4, %eax'. | |
6512 | Exceptions: -128 encodes smaller than 128, so swap sign and op. */ | |
6513 | if (GET_CODE (operands[2]) == CONST_INT | |
6514 | && (INTVAL (operands[2]) == 128 | |
6515 | || (INTVAL (operands[2]) < 0 | |
6516 | && INTVAL (operands[2]) != -128))) | |
6517 | { | |
6518 | operands[2] = GEN_INT (-INTVAL (operands[2])); | |
0f40f9f7 | 6519 | return "sub{w}\t{%2, %0|%0, %2}"; |
9076b9c1 | 6520 | } |
0f40f9f7 | 6521 | return "add{w}\t{%2, %0|%0, %2}"; |
9076b9c1 | 6522 | } |
0f40f9f7 | 6523 | } |
9076b9c1 JH |
6524 | [(set (attr "type") |
6525 | (if_then_else (match_operand:HI 2 "incdec_operand" "") | |
6526 | (const_string "incdec") | |
6527 | (const_string "alu"))) | |
6528 | (set_attr "mode" "HI")]) | |
6529 | ||
e075ae69 | 6530 | (define_expand "addqi3" |
4cbfbb1b JH |
6531 | [(parallel [(set (match_operand:QI 0 "nonimmediate_operand" "") |
6532 | (plus:QI (match_operand:QI 1 "nonimmediate_operand" "") | |
e075ae69 RH |
6533 | (match_operand:QI 2 "general_operand" ""))) |
6534 | (clobber (reg:CC 17))])] | |
d9f32422 | 6535 | "TARGET_QIMODE_MATH" |
e075ae69 RH |
6536 | "ix86_expand_binary_operator (PLUS, QImode, operands); DONE;") |
6537 | ||
6538 | ;; %%% Potential partial reg stall on alternative 2. What to do? | |
58787064 JH |
6539 | (define_insn "*addqi_1_lea" |
6540 | [(set (match_operand:QI 0 "nonimmediate_operand" "=qm,q,r,r") | |
6541 | (plus:QI (match_operand:QI 1 "nonimmediate_operand" "%0,0,0,r") | |
6542 | (match_operand:QI 2 "general_operand" "qn,qmn,rn,rn"))) | |
6543 | (clobber (reg:CC 17))] | |
6544 | "!TARGET_PARTIAL_REG_STALL | |
6545 | && ix86_binary_operator_ok (PLUS, QImode, operands)" | |
58787064 JH |
6546 | { |
6547 | int widen = (which_alternative == 2); | |
6548 | switch (get_attr_type (insn)) | |
6549 | { | |
6550 | case TYPE_LEA: | |
0f40f9f7 | 6551 | return "#"; |
58787064 JH |
6552 | case TYPE_INCDEC: |
6553 | if (operands[2] == const1_rtx) | |
0f40f9f7 | 6554 | return widen ? "inc{l}\t%k0" : "inc{b}\t%0"; |
58787064 JH |
6555 | else if (operands[2] == constm1_rtx |
6556 | || (GET_CODE (operands[2]) == CONST_INT | |
6557 | && INTVAL (operands[2]) == 255)) | |
0f40f9f7 | 6558 | return widen ? "dec{l}\t%k0" : "dec{b}\t%0"; |
58787064 JH |
6559 | abort(); |
6560 | ||
6561 | default: | |
6562 | /* Make things pretty and `subl $4,%eax' rather than `addl $-4, %eax'. | |
6563 | Exceptions: -128 encodes smaller than 128, so swap sign and op. */ | |
6564 | if (GET_CODE (operands[2]) == CONST_INT | |
6565 | && (INTVAL (operands[2]) == 128 | |
6566 | || (INTVAL (operands[2]) < 0 | |
6567 | && INTVAL (operands[2]) != -128))) | |
6568 | { | |
6569 | operands[2] = GEN_INT (-INTVAL (operands[2])); | |
6570 | if (widen) | |
0f40f9f7 | 6571 | return "sub{l}\t{%2, %k0|%k0, %2}"; |
58787064 | 6572 | else |
0f40f9f7 | 6573 | return "sub{b}\t{%2, %0|%0, %2}"; |
58787064 JH |
6574 | } |
6575 | if (widen) | |
0f40f9f7 | 6576 | return "add{l}\t{%k2, %k0|%k0, %k2}"; |
58787064 | 6577 | else |
0f40f9f7 | 6578 | return "add{b}\t{%2, %0|%0, %2}"; |
58787064 | 6579 | } |
0f40f9f7 | 6580 | } |
58787064 JH |
6581 | [(set (attr "type") |
6582 | (if_then_else (eq_attr "alternative" "3") | |
6583 | (const_string "lea") | |
adc88131 | 6584 | (if_then_else (match_operand:QI 2 "incdec_operand" "") |
58787064 JH |
6585 | (const_string "incdec") |
6586 | (const_string "alu")))) | |
adc88131 | 6587 | (set_attr "mode" "QI,QI,SI,SI")]) |
58787064 | 6588 | |
e075ae69 | 6589 | (define_insn "*addqi_1" |
7c6b971d | 6590 | [(set (match_operand:QI 0 "nonimmediate_operand" "=qm,q,r") |
e075ae69 | 6591 | (plus:QI (match_operand:QI 1 "nonimmediate_operand" "%0,0,0") |
7c6b971d | 6592 | (match_operand:QI 2 "general_operand" "qn,qmn,rn"))) |
e075ae69 | 6593 | (clobber (reg:CC 17))] |
58787064 JH |
6594 | "TARGET_PARTIAL_REG_STALL |
6595 | && ix86_binary_operator_ok (PLUS, QImode, operands)" | |
e075ae69 RH |
6596 | { |
6597 | int widen = (which_alternative == 2); | |
6598 | switch (get_attr_type (insn)) | |
5bc7cd8e | 6599 | { |
e075ae69 RH |
6600 | case TYPE_INCDEC: |
6601 | if (operands[2] == const1_rtx) | |
0f40f9f7 | 6602 | return widen ? "inc{l}\t%k0" : "inc{b}\t%0"; |
e075ae69 RH |
6603 | else if (operands[2] == constm1_rtx |
6604 | || (GET_CODE (operands[2]) == CONST_INT | |
6605 | && INTVAL (operands[2]) == 255)) | |
0f40f9f7 | 6606 | return widen ? "dec{l}\t%k0" : "dec{b}\t%0"; |
e075ae69 | 6607 | abort(); |
5bc7cd8e | 6608 | |
e075ae69 RH |
6609 | default: |
6610 | /* Make things pretty and `subl $4,%eax' rather than `addl $-4, %eax'. | |
6611 | Exceptions: -128 encodes smaller than 128, so swap sign and op. */ | |
6612 | if (GET_CODE (operands[2]) == CONST_INT | |
6613 | && (INTVAL (operands[2]) == 128 | |
6614 | || (INTVAL (operands[2]) < 0 | |
6615 | && INTVAL (operands[2]) != -128))) | |
5bc7cd8e | 6616 | { |
e075ae69 RH |
6617 | operands[2] = GEN_INT (-INTVAL (operands[2])); |
6618 | if (widen) | |
0f40f9f7 | 6619 | return "sub{l}\t{%2, %k0|%k0, %2}"; |
e075ae69 | 6620 | else |
0f40f9f7 | 6621 | return "sub{b}\t{%2, %0|%0, %2}"; |
5bc7cd8e | 6622 | } |
e075ae69 | 6623 | if (widen) |
0f40f9f7 | 6624 | return "add{l}\t{%k2, %k0|%k0, %k2}"; |
e075ae69 | 6625 | else |
0f40f9f7 | 6626 | return "add{b}\t{%2, %0|%0, %2}"; |
5bc7cd8e | 6627 | } |
0f40f9f7 | 6628 | } |
e075ae69 RH |
6629 | [(set (attr "type") |
6630 | (if_then_else (match_operand:QI 2 "incdec_operand" "") | |
6631 | (const_string "incdec") | |
6ef67412 JH |
6632 | (const_string "alu"))) |
6633 | (set_attr "mode" "QI,QI,SI")]) | |
e075ae69 RH |
6634 | |
6635 | (define_insn "*addqi_2" | |
16189740 RH |
6636 | [(set (reg 17) |
6637 | (compare | |
e075ae69 RH |
6638 | (plus:QI (match_operand:QI 1 "nonimmediate_operand" "%0,0") |
6639 | (match_operand:QI 2 "general_operand" "qmni,qni")) | |
6640 | (const_int 0))) | |
6641 | (set (match_operand:QI 0 "nonimmediate_operand" "=q,qm") | |
6642 | (plus:QI (match_dup 1) (match_dup 2)))] | |
9076b9c1 | 6643 | "ix86_match_ccmode (insn, CCGOCmode) |
16189740 | 6644 | && ix86_binary_operator_ok (PLUS, QImode, operands)" |
e075ae69 RH |
6645 | { |
6646 | switch (get_attr_type (insn)) | |
6647 | { | |
6648 | case TYPE_INCDEC: | |
6649 | if (operands[2] == const1_rtx) | |
0f40f9f7 | 6650 | return "inc{b}\t%0"; |
e075ae69 RH |
6651 | else if (operands[2] == constm1_rtx |
6652 | || (GET_CODE (operands[2]) == CONST_INT | |
6653 | && INTVAL (operands[2]) == 255)) | |
0f40f9f7 | 6654 | return "dec{b}\t%0"; |
e075ae69 | 6655 | abort(); |
5bc7cd8e | 6656 | |
e075ae69 RH |
6657 | default: |
6658 | /* Make things pretty and `subb $4,%al' rather than `addb $-4, %al'. */ | |
6659 | if (GET_CODE (operands[2]) == CONST_INT | |
6660 | && INTVAL (operands[2]) < 0) | |
6661 | { | |
6662 | operands[2] = GEN_INT (-INTVAL (operands[2])); | |
0f40f9f7 | 6663 | return "sub{b}\t{%2, %0|%0, %2}"; |
e075ae69 | 6664 | } |
0f40f9f7 | 6665 | return "add{b}\t{%2, %0|%0, %2}"; |
e075ae69 | 6666 | } |
0f40f9f7 | 6667 | } |
e075ae69 RH |
6668 | [(set (attr "type") |
6669 | (if_then_else (match_operand:QI 2 "incdec_operand" "") | |
6670 | (const_string "incdec") | |
6ef67412 JH |
6671 | (const_string "alu"))) |
6672 | (set_attr "mode" "QI")]) | |
e075ae69 RH |
6673 | |
6674 | (define_insn "*addqi_3" | |
d90ffc8d | 6675 | [(set (reg 17) |
7e08e190 JH |
6676 | (compare (neg:QI (match_operand:QI 2 "general_operand" "qmni")) |
6677 | (match_operand:QI 1 "nonimmediate_operand" "%0"))) | |
6678 | (clobber (match_scratch:QI 0 "=q"))] | |
6679 | "ix86_match_ccmode (insn, CCZmode) | |
d90ffc8d | 6680 | && (GET_CODE (operands[1]) != MEM || GET_CODE (operands[2]) != MEM)" |
d90ffc8d JH |
6681 | { |
6682 | switch (get_attr_type (insn)) | |
6683 | { | |
6684 | case TYPE_INCDEC: | |
6685 | if (operands[2] == const1_rtx) | |
0f40f9f7 | 6686 | return "inc{b}\t%0"; |
d90ffc8d JH |
6687 | else if (operands[2] == constm1_rtx |
6688 | || (GET_CODE (operands[2]) == CONST_INT | |
6689 | && INTVAL (operands[2]) == 255)) | |
0f40f9f7 | 6690 | return "dec{b}\t%0"; |
d90ffc8d JH |
6691 | abort(); |
6692 | ||
6693 | default: | |
6694 | /* Make things pretty and `subb $4,%al' rather than `addb $-4, %al'. */ | |
6695 | if (GET_CODE (operands[2]) == CONST_INT | |
6696 | && INTVAL (operands[2]) < 0) | |
6697 | { | |
6698 | operands[2] = GEN_INT (-INTVAL (operands[2])); | |
0f40f9f7 | 6699 | return "sub{b}\t{%2, %0|%0, %2}"; |
d90ffc8d | 6700 | } |
0f40f9f7 | 6701 | return "add{b}\t{%2, %0|%0, %2}"; |
d90ffc8d | 6702 | } |
0f40f9f7 | 6703 | } |
d90ffc8d JH |
6704 | [(set (attr "type") |
6705 | (if_then_else (match_operand:QI 2 "incdec_operand" "") | |
6706 | (const_string "incdec") | |
6707 | (const_string "alu"))) | |
6708 | (set_attr "mode" "QI")]) | |
6709 | ||
7e08e190 | 6710 | ; See comments above addsi_3_imm for details. |
d90ffc8d | 6711 | (define_insn "*addqi_4" |
9076b9c1 | 6712 | [(set (reg 17) |
7e08e190 JH |
6713 | (compare (match_operand:QI 1 "nonimmediate_operand" "0") |
6714 | (match_operand:QI 2 "const_int_operand" "n"))) | |
6715 | (clobber (match_scratch:QI 0 "=qm"))] | |
6716 | "ix86_match_ccmode (insn, CCGCmode) | |
6717 | && (INTVAL (operands[2]) & 0xff) != 0x80" | |
7e08e190 JH |
6718 | { |
6719 | switch (get_attr_type (insn)) | |
6720 | { | |
6721 | case TYPE_INCDEC: | |
6722 | if (operands[2] == constm1_rtx | |
6723 | || (GET_CODE (operands[2]) == CONST_INT | |
6724 | && INTVAL (operands[2]) == 255)) | |
0f40f9f7 | 6725 | return "inc{b}\t%0"; |
7e08e190 | 6726 | else if (operands[2] == const1_rtx) |
0f40f9f7 | 6727 | return "dec{b}\t%0"; |
7e08e190 JH |
6728 | else |
6729 | abort(); | |
6730 | ||
6731 | default: | |
6732 | if (! rtx_equal_p (operands[0], operands[1])) | |
6733 | abort (); | |
6734 | if (INTVAL (operands[2]) < 0) | |
6735 | { | |
6736 | operands[2] = GEN_INT (-INTVAL (operands[2])); | |
0f40f9f7 | 6737 | return "add{b}\t{%2, %0|%0, %2}"; |
7e08e190 | 6738 | } |
0f40f9f7 | 6739 | return "sub{b}\t{%2, %0|%0, %2}"; |
7e08e190 | 6740 | } |
0f40f9f7 | 6741 | } |
7e08e190 JH |
6742 | [(set (attr "type") |
6743 | (if_then_else (match_operand:HI 2 "incdec_operand" "") | |
6744 | (const_string "incdec") | |
6745 | (const_string "alu"))) | |
6ef67412 | 6746 | (set_attr "mode" "QI")]) |
886c62d1 | 6747 | |
9dcbdc7e | 6748 | |
d90ffc8d | 6749 | (define_insn "*addqi_5" |
9076b9c1 JH |
6750 | [(set (reg 17) |
6751 | (compare | |
6752 | (plus:QI (match_operand:QI 1 "nonimmediate_operand" "%0") | |
6753 | (match_operand:QI 2 "general_operand" "qmni")) | |
6754 | (const_int 0))) | |
7e08e190 | 6755 | (clobber (match_scratch:QI 0 "=q"))] |
9076b9c1 JH |
6756 | "ix86_match_ccmode (insn, CCGOCmode) |
6757 | && (GET_CODE (operands[1]) != MEM || GET_CODE (operands[2]) != MEM)" | |
9076b9c1 JH |
6758 | { |
6759 | switch (get_attr_type (insn)) | |
6760 | { | |
6761 | case TYPE_INCDEC: | |
6762 | if (operands[2] == const1_rtx) | |
0f40f9f7 | 6763 | return "inc{b}\t%0"; |
9076b9c1 JH |
6764 | else if (operands[2] == constm1_rtx |
6765 | || (GET_CODE (operands[2]) == CONST_INT | |
6766 | && INTVAL (operands[2]) == 255)) | |
0f40f9f7 | 6767 | return "dec{b}\t%0"; |
9076b9c1 JH |
6768 | abort(); |
6769 | ||
6770 | default: | |
6771 | /* Make things pretty and `subb $4,%al' rather than `addb $-4, %al'. */ | |
6772 | if (GET_CODE (operands[2]) == CONST_INT | |
6773 | && INTVAL (operands[2]) < 0) | |
6774 | { | |
6775 | operands[2] = GEN_INT (-INTVAL (operands[2])); | |
0f40f9f7 | 6776 | return "sub{b}\t{%2, %0|%0, %2}"; |
9076b9c1 | 6777 | } |
0f40f9f7 | 6778 | return "add{b}\t{%2, %0|%0, %2}"; |
9076b9c1 | 6779 | } |
0f40f9f7 | 6780 | } |
9076b9c1 JH |
6781 | [(set (attr "type") |
6782 | (if_then_else (match_operand:QI 2 "incdec_operand" "") | |
6783 | (const_string "incdec") | |
6784 | (const_string "alu"))) | |
6785 | (set_attr "mode" "QI")]) | |
6786 | ||
e075ae69 RH |
6787 | |
6788 | (define_insn "addqi_ext_1" | |
3522082b | 6789 | [(set (zero_extract:SI (match_operand 0 "ext_register_operand" "=Q") |
e075ae69 RH |
6790 | (const_int 8) |
6791 | (const_int 8)) | |
6792 | (plus:SI | |
6793 | (zero_extract:SI | |
6794 | (match_operand 1 "ext_register_operand" "0") | |
6795 | (const_int 8) | |
6796 | (const_int 8)) | |
3522082b | 6797 | (match_operand:QI 2 "general_operand" "Qmn"))) |
e075ae69 | 6798 | (clobber (reg:CC 17))] |
d2836273 | 6799 | "!TARGET_64BIT" |
d2836273 JH |
6800 | { |
6801 | switch (get_attr_type (insn)) | |
6802 | { | |
6803 | case TYPE_INCDEC: | |
6804 | if (operands[2] == const1_rtx) | |
0f40f9f7 | 6805 | return "inc{b}\t%h0"; |
d2836273 JH |
6806 | else if (operands[2] == constm1_rtx |
6807 | || (GET_CODE (operands[2]) == CONST_INT | |
6808 | && INTVAL (operands[2]) == 255)) | |
0f40f9f7 | 6809 | return "dec{b}\t%h0"; |
d2836273 JH |
6810 | abort(); |
6811 | ||
6812 | default: | |
0f40f9f7 | 6813 | return "add{b}\t{%2, %h0|%h0, %2}"; |
d2836273 | 6814 | } |
0f40f9f7 | 6815 | } |
d2836273 JH |
6816 | [(set (attr "type") |
6817 | (if_then_else (match_operand:QI 2 "incdec_operand" "") | |
6818 | (const_string "incdec") | |
6819 | (const_string "alu"))) | |
6820 | (set_attr "mode" "QI")]) | |
6821 | ||
6822 | (define_insn "*addqi_ext_1_rex64" | |
6823 | [(set (zero_extract:SI (match_operand 0 "ext_register_operand" "=Q") | |
6824 | (const_int 8) | |
6825 | (const_int 8)) | |
6826 | (plus:SI | |
6827 | (zero_extract:SI | |
6828 | (match_operand 1 "ext_register_operand" "0") | |
6829 | (const_int 8) | |
6830 | (const_int 8)) | |
6831 | (match_operand:QI 2 "nonmemory_operand" "Qn"))) | |
6832 | (clobber (reg:CC 17))] | |
6833 | "TARGET_64BIT" | |
e075ae69 RH |
6834 | { |
6835 | switch (get_attr_type (insn)) | |
6836 | { | |
6837 | case TYPE_INCDEC: | |
6838 | if (operands[2] == const1_rtx) | |
0f40f9f7 | 6839 | return "inc{b}\t%h0"; |
e075ae69 RH |
6840 | else if (operands[2] == constm1_rtx |
6841 | || (GET_CODE (operands[2]) == CONST_INT | |
6842 | && INTVAL (operands[2]) == 255)) | |
0f40f9f7 | 6843 | return "dec{b}\t%h0"; |
e075ae69 | 6844 | abort(); |
886c62d1 | 6845 | |
e075ae69 | 6846 | default: |
0f40f9f7 | 6847 | return "add{b}\t{%2, %h0|%h0, %2}"; |
e075ae69 | 6848 | } |
0f40f9f7 | 6849 | } |
e075ae69 RH |
6850 | [(set (attr "type") |
6851 | (if_then_else (match_operand:QI 2 "incdec_operand" "") | |
6852 | (const_string "incdec") | |
6ef67412 JH |
6853 | (const_string "alu"))) |
6854 | (set_attr "mode" "QI")]) | |
e075ae69 RH |
6855 | |
6856 | (define_insn "*addqi_ext_2" | |
d2836273 | 6857 | [(set (zero_extract:SI (match_operand 0 "ext_register_operand" "=Q") |
e075ae69 RH |
6858 | (const_int 8) |
6859 | (const_int 8)) | |
6860 | (plus:SI | |
6861 | (zero_extract:SI | |
6862 | (match_operand 1 "ext_register_operand" "%0") | |
6863 | (const_int 8) | |
6864 | (const_int 8)) | |
6865 | (zero_extract:SI | |
d2836273 | 6866 | (match_operand 2 "ext_register_operand" "Q") |
e075ae69 RH |
6867 | (const_int 8) |
6868 | (const_int 8)))) | |
6869 | (clobber (reg:CC 17))] | |
6870 | "" | |
0f40f9f7 | 6871 | "add{b}\t{%h2, %h0|%h0, %h2}" |
6ef67412 JH |
6872 | [(set_attr "type" "alu") |
6873 | (set_attr "mode" "QI")]) | |
886c62d1 | 6874 | |
886c62d1 JVA |
6875 | ;; The patterns that match these are at the end of this file. |
6876 | ||
4fb21e90 JVA |
6877 | (define_expand "addxf3" |
6878 | [(set (match_operand:XF 0 "register_operand" "") | |
2ae0f82c SC |
6879 | (plus:XF (match_operand:XF 1 "register_operand" "") |
6880 | (match_operand:XF 2 "register_operand" "")))] | |
1b0c37d7 | 6881 | "!TARGET_64BIT && TARGET_80387" |
4fb21e90 JVA |
6882 | "") |
6883 | ||
2b589241 JH |
6884 | (define_expand "addtf3" |
6885 | [(set (match_operand:TF 0 "register_operand" "") | |
6886 | (plus:TF (match_operand:TF 1 "register_operand" "") | |
6887 | (match_operand:TF 2 "register_operand" "")))] | |
6888 | "TARGET_80387" | |
6889 | "") | |
6890 | ||
886c62d1 JVA |
6891 | (define_expand "adddf3" |
6892 | [(set (match_operand:DF 0 "register_operand" "") | |
06a964de | 6893 | (plus:DF (match_operand:DF 1 "register_operand" "") |
886c62d1 | 6894 | (match_operand:DF 2 "nonimmediate_operand" "")))] |
965f5423 | 6895 | "TARGET_80387 || (TARGET_SSE2 && TARGET_SSE_MATH)" |
886c62d1 JVA |
6896 | "") |
6897 | ||
6898 | (define_expand "addsf3" | |
6899 | [(set (match_operand:SF 0 "register_operand" "") | |
06a964de | 6900 | (plus:SF (match_operand:SF 1 "register_operand" "") |
886c62d1 | 6901 | (match_operand:SF 2 "nonimmediate_operand" "")))] |
965f5423 | 6902 | "TARGET_80387 || TARGET_SSE_MATH" |
886c62d1 JVA |
6903 | "") |
6904 | \f | |
e075ae69 | 6905 | ;; Subtract instructions |
a269a03c | 6906 | |
e075ae69 | 6907 | ;; %%% splits for subsidi3 |
2ae0f82c | 6908 | |
9b70259d JH |
6909 | (define_expand "subdi3" |
6910 | [(parallel [(set (match_operand:DI 0 "nonimmediate_operand" "") | |
6911 | (minus:DI (match_operand:DI 1 "nonimmediate_operand" "") | |
6912 | (match_operand:DI 2 "x86_64_general_operand" ""))) | |
6913 | (clobber (reg:CC 17))])] | |
6914 | "" | |
6915 | "ix86_expand_binary_operator (MINUS, DImode, operands); DONE;") | |
6916 | ||
6917 | (define_insn "*subdi3_1" | |
e075ae69 | 6918 | [(set (match_operand:DI 0 "nonimmediate_operand" "=r,o") |
4cbfbb1b | 6919 | (minus:DI (match_operand:DI 1 "nonimmediate_operand" "0,0") |
e075ae69 RH |
6920 | (match_operand:DI 2 "general_operand" "roiF,riF"))) |
6921 | (clobber (reg:CC 17))] | |
9b70259d | 6922 | "!TARGET_64BIT" |
e075ae69 | 6923 | "#") |
9c530261 | 6924 | |
e075ae69 RH |
6925 | (define_split |
6926 | [(set (match_operand:DI 0 "nonimmediate_operand" "") | |
4cbfbb1b | 6927 | (minus:DI (match_operand:DI 1 "nonimmediate_operand" "") |
e075ae69 RH |
6928 | (match_operand:DI 2 "general_operand" ""))) |
6929 | (clobber (reg:CC 17))] | |
1b0c37d7 | 6930 | "!TARGET_64BIT && reload_completed" |
9dcbdc7e | 6931 | [(parallel [(set (reg:CC 17) (compare:CC (match_dup 1) (match_dup 2))) |
e075ae69 RH |
6932 | (set (match_dup 0) (minus:SI (match_dup 1) (match_dup 2)))]) |
6933 | (parallel [(set (match_dup 3) | |
6934 | (minus:SI (match_dup 4) | |
9dcbdc7e JH |
6935 | (plus:SI (ltu:SI (reg:CC 17) (const_int 0)) |
6936 | (match_dup 5)))) | |
e075ae69 RH |
6937 | (clobber (reg:CC 17))])] |
6938 | "split_di (operands+0, 1, operands+0, operands+3); | |
6939 | split_di (operands+1, 1, operands+1, operands+4); | |
6940 | split_di (operands+2, 1, operands+2, operands+5);") | |
6941 | ||
9b70259d JH |
6942 | (define_insn "subdi3_carry_rex64" |
6943 | [(set (match_operand:DI 0 "nonimmediate_operand" "=rm,r") | |
6944 | (minus:DI (match_operand:DI 1 "nonimmediate_operand" "0,0") | |
6945 | (plus:DI (ltu:DI (reg:CC 17) (const_int 0)) | |
6946 | (match_operand:DI 2 "x86_64_general_operand" "re,rm")))) | |
6947 | (clobber (reg:CC 17))] | |
1b0c37d7 | 6948 | "TARGET_64BIT && ix86_binary_operator_ok (MINUS, DImode, operands)" |
0f40f9f7 | 6949 | "sbb{q}\t{%2, %0|%0, %2}" |
9b70259d JH |
6950 | [(set_attr "type" "alu") |
6951 | (set_attr "pent_pair" "pu") | |
6952 | (set_attr "ppro_uops" "few") | |
6953 | (set_attr "mode" "DI")]) | |
6954 | ||
6955 | (define_insn "*subdi_1_rex64" | |
6956 | [(set (match_operand:DI 0 "nonimmediate_operand" "=rm,r") | |
6957 | (minus:DI (match_operand:DI 1 "nonimmediate_operand" "0,0") | |
6958 | (match_operand:DI 2 "x86_64_general_operand" "re,rm"))) | |
6959 | (clobber (reg:CC 17))] | |
6960 | "TARGET_64BIT && ix86_binary_operator_ok (MINUS, DImode, operands)" | |
0f40f9f7 | 6961 | "sub{q}\t{%2, %0|%0, %2}" |
9b70259d JH |
6962 | [(set_attr "type" "alu") |
6963 | (set_attr "mode" "DI")]) | |
6964 | ||
6965 | (define_insn "*subdi_2_rex64" | |
6966 | [(set (reg 17) | |
6967 | (compare | |
6968 | (minus:DI (match_operand:DI 1 "nonimmediate_operand" "0,0") | |
6969 | (match_operand:DI 2 "x86_64_general_operand" "re,rm")) | |
6970 | (const_int 0))) | |
6971 | (set (match_operand:DI 0 "nonimmediate_operand" "=rm,r") | |
6972 | (minus:DI (match_dup 1) (match_dup 2)))] | |
6973 | "TARGET_64BIT && ix86_match_ccmode (insn, CCGOCmode) | |
6974 | && ix86_binary_operator_ok (MINUS, DImode, operands)" | |
0f40f9f7 | 6975 | "sub{q}\t{%2, %0|%0, %2}" |
9b70259d JH |
6976 | [(set_attr "type" "alu") |
6977 | (set_attr "mode" "DI")]) | |
6978 | ||
6979 | (define_insn "*subdi_3_rex63" | |
6980 | [(set (reg 17) | |
6981 | (compare (match_operand:DI 1 "nonimmediate_operand" "0,0") | |
6982 | (match_operand:DI 2 "x86_64_general_operand" "re,rm"))) | |
6983 | (set (match_operand:DI 0 "nonimmediate_operand" "=rm,r") | |
6984 | (minus:DI (match_dup 1) (match_dup 2)))] | |
6985 | "TARGET_64BIT && ix86_match_ccmode (insn, CCmode) | |
6986 | && ix86_binary_operator_ok (MINUS, SImode, operands)" | |
0f40f9f7 | 6987 | "sub{q}\t{%2, %0|%0, %2}" |
9b70259d JH |
6988 | [(set_attr "type" "alu") |
6989 | (set_attr "mode" "DI")]) | |
6990 | ||
6991 | ||
7e08e190 | 6992 | (define_insn "subsi3_carry" |
e075ae69 RH |
6993 | [(set (match_operand:SI 0 "nonimmediate_operand" "=rm,r") |
6994 | (minus:SI (match_operand:SI 1 "nonimmediate_operand" "0,0") | |
9dcbdc7e JH |
6995 | (plus:SI (ltu:SI (reg:CC 17) (const_int 0)) |
6996 | (match_operand:SI 2 "general_operand" "ri,rm")))) | |
e075ae69 | 6997 | (clobber (reg:CC 17))] |
d525dfdf | 6998 | "ix86_binary_operator_ok (MINUS, SImode, operands)" |
0f40f9f7 | 6999 | "sbb{l}\t{%2, %0|%0, %2}" |
e075ae69 RH |
7000 | [(set_attr "type" "alu") |
7001 | (set_attr "pent_pair" "pu") | |
6ef67412 JH |
7002 | (set_attr "ppro_uops" "few") |
7003 | (set_attr "mode" "SI")]) | |
886c62d1 | 7004 | |
9b70259d JH |
7005 | (define_insn "subsi3_carry_zext" |
7006 | [(set (match_operand:DI 0 "register_operand" "=rm,r") | |
7007 | (zero_extend:DI | |
7008 | (minus:SI (match_operand:SI 1 "register_operand" "0,0") | |
7009 | (plus:SI (ltu:SI (reg:CC 17) (const_int 0)) | |
7010 | (match_operand:SI 2 "general_operand" "ri,rm"))))) | |
7011 | (clobber (reg:CC 17))] | |
7012 | "TARGET_64BIT && ix86_binary_operator_ok (MINUS, SImode, operands)" | |
0f40f9f7 | 7013 | "sbb{l}\t{%2, %k0|%k0, %2}" |
9b70259d JH |
7014 | [(set_attr "type" "alu") |
7015 | (set_attr "pent_pair" "pu") | |
7016 | (set_attr "ppro_uops" "few") | |
7017 | (set_attr "mode" "SI")]) | |
7018 | ||
2ae0f82c | 7019 | (define_expand "subsi3" |
e075ae69 RH |
7020 | [(parallel [(set (match_operand:SI 0 "nonimmediate_operand" "") |
7021 | (minus:SI (match_operand:SI 1 "nonimmediate_operand" "") | |
7022 | (match_operand:SI 2 "general_operand" ""))) | |
7023 | (clobber (reg:CC 17))])] | |
886c62d1 | 7024 | "" |
e075ae69 | 7025 | "ix86_expand_binary_operator (MINUS, SImode, operands); DONE;") |
2ae0f82c | 7026 | |
e075ae69 | 7027 | (define_insn "*subsi_1" |
2ae0f82c SC |
7028 | [(set (match_operand:SI 0 "nonimmediate_operand" "=rm,r") |
7029 | (minus:SI (match_operand:SI 1 "nonimmediate_operand" "0,0") | |
e075ae69 RH |
7030 | (match_operand:SI 2 "general_operand" "ri,rm"))) |
7031 | (clobber (reg:CC 17))] | |
7032 | "ix86_binary_operator_ok (MINUS, SImode, operands)" | |
0f40f9f7 | 7033 | "sub{l}\t{%2, %0|%0, %2}" |
6ef67412 JH |
7034 | [(set_attr "type" "alu") |
7035 | (set_attr "mode" "SI")]) | |
e075ae69 | 7036 | |
9b70259d JH |
7037 | (define_insn "*subsi_1_zext" |
7038 | [(set (match_operand:DI 0 "register_operand" "=r") | |
7039 | (zero_extend:DI | |
7040 | (minus:SI (match_operand:SI 1 "register_operand" "0") | |
7041 | (match_operand:SI 2 "general_operand" "rim")))) | |
7042 | (clobber (reg:CC 17))] | |
7043 | "TARGET_64BIT && ix86_binary_operator_ok (MINUS, SImode, operands)" | |
0f40f9f7 | 7044 | "sub{l}\t{%2, %k0|%k0, %2}" |
9b70259d JH |
7045 | [(set_attr "type" "alu") |
7046 | (set_attr "mode" "SI")]) | |
7047 | ||
e075ae69 | 7048 | (define_insn "*subsi_2" |
16189740 RH |
7049 | [(set (reg 17) |
7050 | (compare | |
e075ae69 RH |
7051 | (minus:SI (match_operand:SI 1 "nonimmediate_operand" "0,0") |
7052 | (match_operand:SI 2 "general_operand" "ri,rm")) | |
7053 | (const_int 0))) | |
7054 | (set (match_operand:SI 0 "nonimmediate_operand" "=rm,r") | |
7055 | (minus:SI (match_dup 1) (match_dup 2)))] | |
9076b9c1 | 7056 | "ix86_match_ccmode (insn, CCGOCmode) |
d90ffc8d | 7057 | && ix86_binary_operator_ok (MINUS, SImode, operands)" |
0f40f9f7 | 7058 | "sub{l}\t{%2, %0|%0, %2}" |
d90ffc8d JH |
7059 | [(set_attr "type" "alu") |
7060 | (set_attr "mode" "SI")]) | |
7061 | ||
9b70259d JH |
7062 | (define_insn "*subsi_2_zext" |
7063 | [(set (reg 17) | |
7064 | (compare | |
7065 | (minus:SI (match_operand:SI 1 "register_operand" "0") | |
7066 | (match_operand:SI 2 "general_operand" "rim")) | |
7067 | (const_int 0))) | |
7068 | (set (match_operand:DI 0 "register_operand" "=r") | |
7069 | (zero_extend:DI | |
7070 | (minus:SI (match_dup 1) | |
7071 | (match_dup 2))))] | |
7072 | "TARGET_64BIT && ix86_match_ccmode (insn, CCGOCmode) | |
7073 | && ix86_binary_operator_ok (MINUS, SImode, operands)" | |
0f40f9f7 | 7074 | "sub{l}\t{%2, %k0|%k0, %2}" |
9b70259d JH |
7075 | [(set_attr "type" "alu") |
7076 | (set_attr "mode" "SI")]) | |
7077 | ||
d90ffc8d JH |
7078 | (define_insn "*subsi_3" |
7079 | [(set (reg 17) | |
7080 | (compare (match_operand:SI 1 "nonimmediate_operand" "0,0") | |
7081 | (match_operand:SI 2 "general_operand" "ri,rm"))) | |
7082 | (set (match_operand:SI 0 "nonimmediate_operand" "=rm,r") | |
7083 | (minus:SI (match_dup 1) (match_dup 2)))] | |
16189740 RH |
7084 | "ix86_match_ccmode (insn, CCmode) |
7085 | && ix86_binary_operator_ok (MINUS, SImode, operands)" | |
0f40f9f7 | 7086 | "sub{l}\t{%2, %0|%0, %2}" |
6ef67412 JH |
7087 | [(set_attr "type" "alu") |
7088 | (set_attr "mode" "SI")]) | |
886c62d1 | 7089 | |
9b70259d JH |
7090 | (define_insn "*subsi_3_zext" |
7091 | [(set (reg 17) | |
7092 | (compare (match_operand:SI 1 "nonimmediate_operand" "0") | |
7093 | (match_operand:SI 2 "general_operand" "rim"))) | |
7094 | (set (match_operand:DI 0 "register_operand" "=r") | |
7095 | (zero_extend:DI | |
7096 | (minus:SI (match_dup 1) | |
7097 | (match_dup 2))))] | |
8362f420 | 7098 | "TARGET_64BIT && ix86_match_ccmode (insn, CCmode) |
9b70259d | 7099 | && ix86_binary_operator_ok (MINUS, SImode, operands)" |
0f40f9f7 | 7100 | "sub{q}\t{%2, %0|%0, %2}" |
9b70259d JH |
7101 | [(set_attr "type" "alu") |
7102 | (set_attr "mode" "DI")]) | |
7103 | ||
2ae0f82c | 7104 | (define_expand "subhi3" |
4cbfbb1b | 7105 | [(parallel [(set (match_operand:HI 0 "nonimmediate_operand" "") |
e075ae69 RH |
7106 | (minus:HI (match_operand:HI 1 "nonimmediate_operand" "") |
7107 | (match_operand:HI 2 "general_operand" ""))) | |
7108 | (clobber (reg:CC 17))])] | |
d9f32422 | 7109 | "TARGET_HIMODE_MATH" |
e075ae69 | 7110 | "ix86_expand_binary_operator (MINUS, HImode, operands); DONE;") |
2ae0f82c | 7111 | |
e075ae69 | 7112 | (define_insn "*subhi_1" |
2ae0f82c | 7113 | [(set (match_operand:HI 0 "nonimmediate_operand" "=rm,r") |
87fd1847 | 7114 | (minus:HI (match_operand:HI 1 "nonimmediate_operand" "0,0") |
e075ae69 RH |
7115 | (match_operand:HI 2 "general_operand" "ri,rm"))) |
7116 | (clobber (reg:CC 17))] | |
2ae0f82c | 7117 | "ix86_binary_operator_ok (MINUS, HImode, operands)" |
0f40f9f7 | 7118 | "sub{w}\t{%2, %0|%0, %2}" |
6ef67412 JH |
7119 | [(set_attr "type" "alu") |
7120 | (set_attr "mode" "HI")]) | |
e075ae69 RH |
7121 | |
7122 | (define_insn "*subhi_2" | |
16189740 RH |
7123 | [(set (reg 17) |
7124 | (compare | |
e075ae69 RH |
7125 | (minus:HI (match_operand:HI 1 "nonimmediate_operand" "0,0") |
7126 | (match_operand:HI 2 "general_operand" "ri,rm")) | |
7127 | (const_int 0))) | |
7128 | (set (match_operand:HI 0 "nonimmediate_operand" "=rm,r") | |
7129 | (minus:HI (match_dup 1) (match_dup 2)))] | |
9076b9c1 | 7130 | "ix86_match_ccmode (insn, CCGOCmode) |
d90ffc8d | 7131 | && ix86_binary_operator_ok (MINUS, HImode, operands)" |
0f40f9f7 | 7132 | "sub{w}\t{%2, %0|%0, %2}" |
d90ffc8d JH |
7133 | [(set_attr "type" "alu") |
7134 | (set_attr "mode" "HI")]) | |
7135 | ||
7136 | (define_insn "*subhi_3" | |
7137 | [(set (reg 17) | |
7138 | (compare (match_operand:HI 1 "nonimmediate_operand" "0,0") | |
7139 | (match_operand:HI 2 "general_operand" "ri,rm"))) | |
7140 | (set (match_operand:HI 0 "nonimmediate_operand" "=rm,r") | |
7141 | (minus:HI (match_dup 1) (match_dup 2)))] | |
16189740 RH |
7142 | "ix86_match_ccmode (insn, CCmode) |
7143 | && ix86_binary_operator_ok (MINUS, HImode, operands)" | |
0f40f9f7 | 7144 | "sub{w}\t{%2, %0|%0, %2}" |
6ef67412 JH |
7145 | [(set_attr "type" "alu") |
7146 | (set_attr "mode" "HI")]) | |
886c62d1 | 7147 | |
2ae0f82c | 7148 | (define_expand "subqi3" |
4cbfbb1b JH |
7149 | [(parallel [(set (match_operand:QI 0 "nonimmediate_operand" "") |
7150 | (minus:QI (match_operand:QI 1 "nonimmediate_operand" "") | |
e075ae69 RH |
7151 | (match_operand:QI 2 "general_operand" ""))) |
7152 | (clobber (reg:CC 17))])] | |
d9f32422 | 7153 | "TARGET_QIMODE_MATH" |
e075ae69 | 7154 | "ix86_expand_binary_operator (MINUS, QImode, operands); DONE;") |
2ae0f82c | 7155 | |
e075ae69 | 7156 | (define_insn "*subqi_1" |
2ae0f82c SC |
7157 | [(set (match_operand:QI 0 "nonimmediate_operand" "=qm,q") |
7158 | (minus:QI (match_operand:QI 1 "nonimmediate_operand" "0,0") | |
e075ae69 RH |
7159 | (match_operand:QI 2 "general_operand" "qn,qmn"))) |
7160 | (clobber (reg:CC 17))] | |
7161 | "ix86_binary_operator_ok (MINUS, QImode, operands)" | |
0f40f9f7 | 7162 | "sub{b}\t{%2, %0|%0, %2}" |
6ef67412 JH |
7163 | [(set_attr "type" "alu") |
7164 | (set_attr "mode" "QI")]) | |
e075ae69 RH |
7165 | |
7166 | (define_insn "*subqi_2" | |
16189740 RH |
7167 | [(set (reg 17) |
7168 | (compare | |
e075ae69 RH |
7169 | (minus:QI (match_operand:QI 1 "nonimmediate_operand" "0,0") |
7170 | (match_operand:QI 2 "general_operand" "qi,qm")) | |
7171 | (const_int 0))) | |
7172 | (set (match_operand:HI 0 "nonimmediate_operand" "=qm,q") | |
7173 | (minus:HI (match_dup 1) (match_dup 2)))] | |
9076b9c1 | 7174 | "ix86_match_ccmode (insn, CCGOCmode) |
d90ffc8d | 7175 | && ix86_binary_operator_ok (MINUS, QImode, operands)" |
0f40f9f7 | 7176 | "sub{b}\t{%2, %0|%0, %2}" |
d90ffc8d JH |
7177 | [(set_attr "type" "alu") |
7178 | (set_attr "mode" "QI")]) | |
7179 | ||
7180 | (define_insn "*subqi_3" | |
7181 | [(set (reg 17) | |
7182 | (compare (match_operand:QI 1 "nonimmediate_operand" "0,0") | |
7183 | (match_operand:QI 2 "general_operand" "qi,qm"))) | |
7184 | (set (match_operand:HI 0 "nonimmediate_operand" "=qm,q") | |
7185 | (minus:HI (match_dup 1) (match_dup 2)))] | |
16189740 RH |
7186 | "ix86_match_ccmode (insn, CCmode) |
7187 | && ix86_binary_operator_ok (MINUS, QImode, operands)" | |
0f40f9f7 | 7188 | "sub{b}\t{%2, %0|%0, %2}" |
6ef67412 JH |
7189 | [(set_attr "type" "alu") |
7190 | (set_attr "mode" "QI")]) | |
2ae0f82c | 7191 | |
886c62d1 JVA |
7192 | ;; The patterns that match these are at the end of this file. |
7193 | ||
4fb21e90 JVA |
7194 | (define_expand "subxf3" |
7195 | [(set (match_operand:XF 0 "register_operand" "") | |
2ae0f82c SC |
7196 | (minus:XF (match_operand:XF 1 "register_operand" "") |
7197 | (match_operand:XF 2 "register_operand" "")))] | |
1b0c37d7 | 7198 | "!TARGET_64BIT && TARGET_80387" |
4fb21e90 JVA |
7199 | "") |
7200 | ||
2b589241 JH |
7201 | (define_expand "subtf3" |
7202 | [(set (match_operand:TF 0 "register_operand" "") | |
7203 | (minus:TF (match_operand:TF 1 "register_operand" "") | |
7204 | (match_operand:TF 2 "register_operand" "")))] | |
7205 | "TARGET_80387" | |
7206 | "") | |
7207 | ||
886c62d1 JVA |
7208 | (define_expand "subdf3" |
7209 | [(set (match_operand:DF 0 "register_operand" "") | |
06a964de | 7210 | (minus:DF (match_operand:DF 1 "register_operand" "") |
886c62d1 | 7211 | (match_operand:DF 2 "nonimmediate_operand" "")))] |
965f5423 | 7212 | "TARGET_80387 || (TARGET_SSE2 && TARGET_SSE_MATH)" |
886c62d1 JVA |
7213 | "") |
7214 | ||
7215 | (define_expand "subsf3" | |
7216 | [(set (match_operand:SF 0 "register_operand" "") | |
06a964de | 7217 | (minus:SF (match_operand:SF 1 "register_operand" "") |
886c62d1 | 7218 | (match_operand:SF 2 "nonimmediate_operand" "")))] |
965f5423 | 7219 | "TARGET_80387 || TARGET_SSE_MATH" |
886c62d1 JVA |
7220 | "") |
7221 | \f | |
e075ae69 | 7222 | ;; Multiply instructions |
886c62d1 | 7223 | |
9b70259d JH |
7224 | (define_expand "muldi3" |
7225 | [(parallel [(set (match_operand:DI 0 "register_operand" "") | |
7226 | (mult:DI (match_operand:DI 1 "register_operand" "") | |
7227 | (match_operand:DI 2 "x86_64_general_operand" ""))) | |
7228 | (clobber (reg:CC 17))])] | |
7229 | "TARGET_64BIT" | |
7230 | "") | |
7231 | ||
7232 | (define_insn "*muldi3_1_rex64" | |
7233 | [(set (match_operand:DI 0 "register_operand" "=r,r,r") | |
7234 | (mult:DI (match_operand:DI 1 "nonimmediate_operand" "%rm,0,0") | |
7235 | (match_operand:DI 2 "x86_64_general_operand" "K,e,mr"))) | |
7236 | (clobber (reg:CC 17))] | |
1b0c37d7 ZW |
7237 | "TARGET_64BIT |
7238 | && (GET_CODE (operands[1]) != MEM || GET_CODE (operands[2]) != MEM)" | |
9b70259d | 7239 | "@ |
0f40f9f7 ZW |
7240 | imul{q}\t{%2, %1, %0|%0, %1, %2} |
7241 | imul{q}\t{%2, %1, %0|%0, %1, %2} | |
7242 | imul{q}\t{%2, %0|%0, %2}" | |
9b70259d JH |
7243 | [(set_attr "type" "imul") |
7244 | (set_attr "prefix_0f" "0,0,1") | |
7245 | (set_attr "mode" "DI")]) | |
7246 | ||
d525dfdf JH |
7247 | (define_expand "mulsi3" |
7248 | [(parallel [(set (match_operand:SI 0 "register_operand" "") | |
7249 | (mult:SI (match_operand:SI 1 "register_operand" "") | |
7250 | (match_operand:SI 2 "general_operand" ""))) | |
7251 | (clobber (reg:CC 17))])] | |
7252 | "" | |
7253 | "") | |
7254 | ||
7255 | (define_insn "*mulsi3_1" | |
e075ae69 RH |
7256 | [(set (match_operand:SI 0 "register_operand" "=r,r,r") |
7257 | (mult:SI (match_operand:SI 1 "nonimmediate_operand" "%rm,0,0") | |
7258 | (match_operand:SI 2 "general_operand" "K,i,mr"))) | |
7259 | (clobber (reg:CC 17))] | |
d525dfdf | 7260 | "GET_CODE (operands[1]) != MEM || GET_CODE (operands[2]) != MEM" |
20819a09 MM |
7261 | ; For the {r,0,i} alternative (i.e., register <- register * immediate), |
7262 | ; there are two ways of writing the exact same machine instruction | |
7263 | ; in assembly language. One, for example, is: | |
7264 | ; | |
7265 | ; imul $12, %eax | |
7266 | ; | |
7267 | ; while the other is: | |
7268 | ; | |
7269 | ; imul $12, %eax, %eax | |
7270 | ; | |
7271 | ; The first is simply short-hand for the latter. But, some assemblers, | |
7272 | ; like the SCO OSR5 COFF assembler, don't handle the first form. | |
e075ae69 | 7273 | "@ |
0f40f9f7 ZW |
7274 | imul{l}\t{%2, %1, %0|%0, %1, %2} |
7275 | imul{l}\t{%2, %1, %0|%0, %1, %2} | |
7276 | imul{l}\t{%2, %0|%0, %2}" | |
e075ae69 | 7277 | [(set_attr "type" "imul") |
6ef67412 JH |
7278 | (set_attr "prefix_0f" "0,0,1") |
7279 | (set_attr "mode" "SI")]) | |
886c62d1 | 7280 | |
9b70259d JH |
7281 | (define_insn "*mulsi3_1_zext" |
7282 | [(set (match_operand:DI 0 "register_operand" "=r,r,r") | |
7283 | (zero_extend:DI | |
7284 | (mult:SI (match_operand:SI 1 "nonimmediate_operand" "%rm,0,0") | |
7285 | (match_operand:SI 2 "general_operand" "K,i,mr")))) | |
7286 | (clobber (reg:CC 17))] | |
7287 | "TARGET_64BIT | |
7288 | && (GET_CODE (operands[1]) != MEM || GET_CODE (operands[2]) != MEM)" | |
7289 | ; For the {r,0,i} alternative (i.e., register <- register * immediate), | |
7290 | ; there are two ways of writing the exact same machine instruction | |
7291 | ; in assembly language. One, for example, is: | |
7292 | ; | |
7293 | ; imul $12, %eax | |
7294 | ; | |
7295 | ; while the other is: | |
7296 | ; | |
7297 | ; imul $12, %eax, %eax | |
7298 | ; | |
7299 | ; The first is simply short-hand for the latter. But, some assemblers, | |
7300 | ; like the SCO OSR5 COFF assembler, don't handle the first form. | |
7301 | "@ | |
0f40f9f7 ZW |
7302 | imul{l}\t{%2, %1, %k0|%k0, %1, %2} |
7303 | imul{l}\t{%2, %1, %k0|%k0, %1, %2} | |
7304 | imul{l}\t{%2, %k0|%k0, %2}" | |
9b70259d JH |
7305 | [(set_attr "type" "imul") |
7306 | (set_attr "prefix_0f" "0,0,1") | |
7307 | (set_attr "mode" "SI")]) | |
7308 | ||
d525dfdf JH |
7309 | (define_expand "mulhi3" |
7310 | [(parallel [(set (match_operand:HI 0 "register_operand" "") | |
7311 | (mult:HI (match_operand:HI 1 "register_operand" "") | |
7312 | (match_operand:HI 2 "general_operand" ""))) | |
7313 | (clobber (reg:CC 17))])] | |
d9f32422 | 7314 | "TARGET_HIMODE_MATH" |
d525dfdf JH |
7315 | "") |
7316 | ||
7317 | (define_insn "*mulhi3_1" | |
6ef67412 JH |
7318 | [(set (match_operand:HI 0 "register_operand" "=r,r,r") |
7319 | (mult:HI (match_operand:HI 1 "nonimmediate_operand" "%rm,0,0") | |
7320 | (match_operand:HI 2 "general_operand" "K,i,mr"))) | |
e075ae69 | 7321 | (clobber (reg:CC 17))] |
d525dfdf | 7322 | "GET_CODE (operands[1]) != MEM || GET_CODE (operands[2]) != MEM" |
e075ae69 RH |
7323 | ; %%% There was a note about "Assembler has weird restrictions", |
7324 | ; concerning alternative 1 when op1 == op0. True? | |
7325 | "@ | |
0f40f9f7 ZW |
7326 | imul{w}\t{%2, %1, %0|%0, %1, %2} |
7327 | imul{w}\t{%2, %1, %0|%0, %1, %2} | |
7328 | imul{w}\t{%2, %0|%0, %2}" | |
6ef67412 JH |
7329 | [(set_attr "type" "imul") |
7330 | (set_attr "prefix_0f" "0,0,1") | |
7331 | (set_attr "mode" "HI")]) | |
886c62d1 | 7332 | |
765a46f9 JH |
7333 | (define_insn "mulqi3" |
7334 | [(set (match_operand:QI 0 "register_operand" "=a") | |
7335 | (mult:QI (match_operand:QI 1 "register_operand" "%0") | |
7336 | (match_operand:QI 2 "nonimmediate_operand" "qm"))) | |
7337 | (clobber (reg:CC 17))] | |
d9f32422 | 7338 | "TARGET_QIMODE_MATH" |
0f40f9f7 | 7339 | "mul{b}\t%2" |
6ef67412 JH |
7340 | [(set_attr "type" "imul") |
7341 | (set_attr "length_immediate" "0") | |
7342 | (set_attr "mode" "QI")]) | |
765a46f9 | 7343 | |
4b71cd6e | 7344 | (define_insn "umulqihi3" |
2ae0f82c SC |
7345 | [(set (match_operand:HI 0 "register_operand" "=a") |
7346 | (mult:HI (zero_extend:HI (match_operand:QI 1 "register_operand" "%0")) | |
e075ae69 RH |
7347 | (zero_extend:HI (match_operand:QI 2 "nonimmediate_operand" "qm")))) |
7348 | (clobber (reg:CC 17))] | |
d9f32422 | 7349 | "TARGET_QIMODE_MATH" |
0f40f9f7 | 7350 | "mul{b}\t%2" |
6ef67412 JH |
7351 | [(set_attr "type" "imul") |
7352 | (set_attr "length_immediate" "0") | |
7353 | (set_attr "mode" "QI")]) | |
886c62d1 | 7354 | |
4b71cd6e | 7355 | (define_insn "mulqihi3" |
2ae0f82c SC |
7356 | [(set (match_operand:HI 0 "register_operand" "=a") |
7357 | (mult:HI (sign_extend:HI (match_operand:QI 1 "register_operand" "%0")) | |
e075ae69 RH |
7358 | (sign_extend:HI (match_operand:QI 2 "nonimmediate_operand" "qm")))) |
7359 | (clobber (reg:CC 17))] | |
d9f32422 | 7360 | "TARGET_QIMODE_MATH" |
0f40f9f7 | 7361 | "imul{b}\t%2" |
6ef67412 JH |
7362 | [(set_attr "type" "imul") |
7363 | (set_attr "length_immediate" "0") | |
7364 | (set_attr "mode" "QI")]) | |
4b71cd6e | 7365 | |
9b70259d JH |
7366 | (define_insn "umulditi3" |
7367 | [(set (match_operand:TI 0 "register_operand" "=A") | |
7368 | (mult:TI (zero_extend:TI (match_operand:DI 1 "register_operand" "%0")) | |
7369 | (zero_extend:TI (match_operand:DI 2 "nonimmediate_operand" "rm")))) | |
1e07edd3 | 7370 | (clobber (reg:CC 17))] |
9b70259d | 7371 | "TARGET_64BIT" |
0f40f9f7 | 7372 | "mul{q}\t%2" |
1e07edd3 JH |
7373 | [(set_attr "type" "imul") |
7374 | (set_attr "ppro_uops" "few") | |
7375 | (set_attr "length_immediate" "0") | |
9b70259d | 7376 | (set_attr "mode" "DI")]) |
1e07edd3 JH |
7377 | |
7378 | ;; We can't use this pattern in 64bit mode, since it results in two separate 32bit registers | |
4b71cd6e MM |
7379 | (define_insn "umulsidi3" |
7380 | [(set (match_operand:DI 0 "register_operand" "=A") | |
7381 | (mult:DI (zero_extend:DI (match_operand:SI 1 "register_operand" "%0")) | |
e075ae69 RH |
7382 | (zero_extend:DI (match_operand:SI 2 "nonimmediate_operand" "rm")))) |
7383 | (clobber (reg:CC 17))] | |
1e07edd3 | 7384 | "!TARGET_64BIT" |
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") | |
7389 | (set_attr "mode" "SI")]) | |
4b71cd6e | 7390 | |
9b70259d JH |
7391 | (define_insn "mulditi3" |
7392 | [(set (match_operand:TI 0 "register_operand" "=A") | |
7393 | (mult:TI (sign_extend:TI (match_operand:DI 1 "register_operand" "%0")) | |
7394 | (sign_extend:TI (match_operand:DI 2 "nonimmediate_operand" "rm")))) | |
7395 | (clobber (reg:CC 17))] | |
7396 | "TARGET_64BIT" | |
0f40f9f7 | 7397 | "imul{q}\t%2" |
9b70259d JH |
7398 | [(set_attr "type" "imul") |
7399 | (set_attr "length_immediate" "0") | |
7400 | (set_attr "mode" "DI")]) | |
7401 | ||
4b71cd6e MM |
7402 | (define_insn "mulsidi3" |
7403 | [(set (match_operand:DI 0 "register_operand" "=A") | |
7404 | (mult:DI (sign_extend:DI (match_operand:SI 1 "register_operand" "%0")) | |
e075ae69 RH |
7405 | (sign_extend:DI (match_operand:SI 2 "nonimmediate_operand" "rm")))) |
7406 | (clobber (reg:CC 17))] | |
1e07edd3 | 7407 | "!TARGET_64BIT" |
0f40f9f7 | 7408 | "imul{l}\t%2" |
6ef67412 JH |
7409 | [(set_attr "type" "imul") |
7410 | (set_attr "length_immediate" "0") | |
7411 | (set_attr "mode" "SI")]) | |
2f2a49e8 | 7412 | |
9b70259d JH |
7413 | (define_insn "*umuldi3_highpart_rex64" |
7414 | [(set (match_operand:DI 0 "register_operand" "=d") | |
7415 | (truncate:DI | |
7416 | (lshiftrt:TI | |
7417 | (mult:TI (zero_extend:TI | |
7418 | (match_operand:DI 1 "register_operand" "%a")) | |
7419 | (zero_extend:TI | |
7420 | (match_operand:DI 2 "nonimmediate_operand" "rm"))) | |
7421 | (const_int 64)))) | |
7422 | (clobber (match_scratch:DI 3 "=a")) | |
7423 | (clobber (reg:CC 17))] | |
7424 | "TARGET_64BIT" | |
0f40f9f7 | 7425 | "mul{q}\t%2" |
9b70259d JH |
7426 | [(set_attr "type" "imul") |
7427 | (set_attr "ppro_uops" "few") | |
7428 | (set_attr "length_immediate" "0") | |
7429 | (set_attr "mode" "DI")]) | |
7430 | ||
34c659e2 | 7431 | (define_insn "umulsi3_highpart" |
2f2a49e8 | 7432 | [(set (match_operand:SI 0 "register_operand" "=d") |
e075ae69 RH |
7433 | (truncate:SI |
7434 | (lshiftrt:DI | |
7435 | (mult:DI (zero_extend:DI | |
7436 | (match_operand:SI 1 "register_operand" "%a")) | |
7437 | (zero_extend:DI | |
7438 | (match_operand:SI 2 "nonimmediate_operand" "rm"))) | |
7439 | (const_int 32)))) | |
7440 | (clobber (match_scratch:SI 3 "=a")) | |
7441 | (clobber (reg:CC 17))] | |
32ee7d1d | 7442 | "" |
0f40f9f7 | 7443 | "mul{l}\t%2" |
32ee7d1d JH |
7444 | [(set_attr "type" "imul") |
7445 | (set_attr "ppro_uops" "few") | |
7446 | (set_attr "length_immediate" "0") | |
7447 | (set_attr "mode" "SI")]) | |
7448 | ||
7449 | (define_insn "*umulsi3_highpart_zext" | |
7450 | [(set (match_operand:DI 0 "register_operand" "=d") | |
7451 | (zero_extend:DI (truncate:SI | |
7452 | (lshiftrt:DI | |
7453 | (mult:DI (zero_extend:DI | |
7454 | (match_operand:SI 1 "register_operand" "%a")) | |
7455 | (zero_extend:DI | |
7456 | (match_operand:SI 2 "nonimmediate_operand" "rm"))) | |
7457 | (const_int 32))))) | |
7458 | (clobber (match_scratch:SI 3 "=a")) | |
7459 | (clobber (reg:CC 17))] | |
7460 | "TARGET_64BIT" | |
0f40f9f7 | 7461 | "mul{l}\t%2" |
e075ae69 | 7462 | [(set_attr "type" "imul") |
6ef67412 JH |
7463 | (set_attr "ppro_uops" "few") |
7464 | (set_attr "length_immediate" "0") | |
7465 | (set_attr "mode" "SI")]) | |
2f2a49e8 | 7466 | |
9b70259d JH |
7467 | (define_insn "*smuldi3_highpart_rex64" |
7468 | [(set (match_operand:DI 0 "register_operand" "=d") | |
7469 | (truncate:DI | |
7470 | (lshiftrt:TI | |
7471 | (mult:TI (sign_extend:TI | |
7472 | (match_operand:DI 1 "register_operand" "%a")) | |
7473 | (sign_extend:TI | |
7474 | (match_operand:DI 2 "nonimmediate_operand" "rm"))) | |
7475 | (const_int 64)))) | |
7476 | (clobber (match_scratch:DI 3 "=a")) | |
7477 | (clobber (reg:CC 17))] | |
7478 | "TARGET_64BIT" | |
0f40f9f7 | 7479 | "imul{q}\t%2" |
9b70259d JH |
7480 | [(set_attr "type" "imul") |
7481 | (set_attr "ppro_uops" "few") | |
7482 | (set_attr "mode" "DI")]) | |
7483 | ||
34c659e2 | 7484 | (define_insn "smulsi3_highpart" |
2f2a49e8 | 7485 | [(set (match_operand:SI 0 "register_operand" "=d") |
e075ae69 RH |
7486 | (truncate:SI |
7487 | (lshiftrt:DI | |
7488 | (mult:DI (sign_extend:DI | |
7489 | (match_operand:SI 1 "register_operand" "%a")) | |
7490 | (sign_extend:DI | |
7491 | (match_operand:SI 2 "nonimmediate_operand" "rm"))) | |
7492 | (const_int 32)))) | |
7493 | (clobber (match_scratch:SI 3 "=a")) | |
7494 | (clobber (reg:CC 17))] | |
7495 | "" | |
0f40f9f7 | 7496 | "imul{l}\t%2" |
e075ae69 | 7497 | [(set_attr "type" "imul") |
6ef67412 JH |
7498 | (set_attr "ppro_uops" "few") |
7499 | (set_attr "mode" "SI")]) | |
4b71cd6e | 7500 | |
9b70259d JH |
7501 | (define_insn "*smulsi3_highpart_zext" |
7502 | [(set (match_operand:DI 0 "register_operand" "=d") | |
7503 | (zero_extend:DI (truncate:SI | |
7504 | (lshiftrt:DI | |
7505 | (mult:DI (sign_extend:DI | |
7506 | (match_operand:SI 1 "register_operand" "%a")) | |
7507 | (sign_extend:DI | |
7508 | (match_operand:SI 2 "nonimmediate_operand" "rm"))) | |
7509 | (const_int 32))))) | |
7510 | (clobber (match_scratch:SI 3 "=a")) | |
7511 | (clobber (reg:CC 17))] | |
7512 | "TARGET_64BIT" | |
0f40f9f7 | 7513 | "imul{l}\t%2" |
9b70259d JH |
7514 | [(set_attr "type" "imul") |
7515 | (set_attr "ppro_uops" "few") | |
7516 | (set_attr "mode" "SI")]) | |
7517 | ||
886c62d1 JVA |
7518 | ;; The patterns that match these are at the end of this file. |
7519 | ||
4fb21e90 JVA |
7520 | (define_expand "mulxf3" |
7521 | [(set (match_operand:XF 0 "register_operand" "") | |
2ae0f82c SC |
7522 | (mult:XF (match_operand:XF 1 "register_operand" "") |
7523 | (match_operand:XF 2 "register_operand" "")))] | |
1b0c37d7 | 7524 | "!TARGET_64BIT && TARGET_80387" |
4fb21e90 JVA |
7525 | "") |
7526 | ||
2b589241 JH |
7527 | (define_expand "multf3" |
7528 | [(set (match_operand:TF 0 "register_operand" "") | |
7529 | (mult:TF (match_operand:TF 1 "register_operand" "") | |
7530 | (match_operand:TF 2 "register_operand" "")))] | |
7531 | "TARGET_80387" | |
7532 | "") | |
7533 | ||
886c62d1 JVA |
7534 | (define_expand "muldf3" |
7535 | [(set (match_operand:DF 0 "register_operand" "") | |
2ae0f82c | 7536 | (mult:DF (match_operand:DF 1 "register_operand" "") |
886c62d1 | 7537 | (match_operand:DF 2 "nonimmediate_operand" "")))] |
965f5423 | 7538 | "TARGET_80387 || (TARGET_SSE2 && TARGET_SSE_MATH)" |
886c62d1 JVA |
7539 | "") |
7540 | ||
7541 | (define_expand "mulsf3" | |
7542 | [(set (match_operand:SF 0 "register_operand" "") | |
2ae0f82c | 7543 | (mult:SF (match_operand:SF 1 "register_operand" "") |
886c62d1 | 7544 | (match_operand:SF 2 "nonimmediate_operand" "")))] |
965f5423 | 7545 | "TARGET_80387 || TARGET_SSE_MATH" |
886c62d1 JVA |
7546 | "") |
7547 | \f | |
e075ae69 | 7548 | ;; Divide instructions |
886c62d1 JVA |
7549 | |
7550 | (define_insn "divqi3" | |
2ae0f82c SC |
7551 | [(set (match_operand:QI 0 "register_operand" "=a") |
7552 | (div:QI (match_operand:HI 1 "register_operand" "0") | |
e075ae69 RH |
7553 | (match_operand:QI 2 "nonimmediate_operand" "qm"))) |
7554 | (clobber (reg:CC 17))] | |
d9f32422 | 7555 | "TARGET_QIMODE_MATH" |
0f40f9f7 | 7556 | "idiv{b}\t%2" |
e075ae69 | 7557 | [(set_attr "type" "idiv") |
6ef67412 | 7558 | (set_attr "mode" "QI") |
e075ae69 | 7559 | (set_attr "ppro_uops" "few")]) |
886c62d1 JVA |
7560 | |
7561 | (define_insn "udivqi3" | |
2ae0f82c SC |
7562 | [(set (match_operand:QI 0 "register_operand" "=a") |
7563 | (udiv:QI (match_operand:HI 1 "register_operand" "0") | |
e075ae69 RH |
7564 | (match_operand:QI 2 "nonimmediate_operand" "qm"))) |
7565 | (clobber (reg:CC 17))] | |
d9f32422 | 7566 | "TARGET_QIMODE_MATH" |
0f40f9f7 | 7567 | "div{b}\t%2" |
e075ae69 | 7568 | [(set_attr "type" "idiv") |
6ef67412 | 7569 | (set_attr "mode" "QI") |
e075ae69 | 7570 | (set_attr "ppro_uops" "few")]) |
886c62d1 JVA |
7571 | |
7572 | ;; The patterns that match these are at the end of this file. | |
7573 | ||
4fb21e90 JVA |
7574 | (define_expand "divxf3" |
7575 | [(set (match_operand:XF 0 "register_operand" "") | |
2ae0f82c SC |
7576 | (div:XF (match_operand:XF 1 "register_operand" "") |
7577 | (match_operand:XF 2 "register_operand" "")))] | |
1b0c37d7 | 7578 | "!TARGET_64BIT && TARGET_80387" |
886c62d1 JVA |
7579 | "") |
7580 | ||
2b589241 JH |
7581 | (define_expand "divtf3" |
7582 | [(set (match_operand:TF 0 "register_operand" "") | |
7583 | (div:TF (match_operand:TF 1 "register_operand" "") | |
7584 | (match_operand:TF 2 "register_operand" "")))] | |
7585 | "TARGET_80387" | |
7586 | "") | |
7587 | ||
a78cb986 SC |
7588 | (define_expand "divdf3" |
7589 | [(set (match_operand:DF 0 "register_operand" "") | |
7590 | (div:DF (match_operand:DF 1 "register_operand" "") | |
7591 | (match_operand:DF 2 "nonimmediate_operand" "")))] | |
965f5423 | 7592 | "TARGET_80387 || (TARGET_SSE2 && TARGET_SSE_MATH)" |
a78cb986 SC |
7593 | "") |
7594 | ||
886c62d1 JVA |
7595 | (define_expand "divsf3" |
7596 | [(set (match_operand:SF 0 "register_operand" "") | |
2ae0f82c | 7597 | (div:SF (match_operand:SF 1 "register_operand" "") |
886c62d1 | 7598 | (match_operand:SF 2 "nonimmediate_operand" "")))] |
965f5423 | 7599 | "TARGET_80387 || TARGET_SSE_MATH" |
886c62d1 JVA |
7600 | "") |
7601 | \f | |
7602 | ;; Remainder instructions. | |
9b70259d JH |
7603 | |
7604 | (define_expand "divmoddi4" | |
7605 | [(parallel [(set (match_operand:DI 0 "register_operand" "") | |
7606 | (div:DI (match_operand:DI 1 "register_operand" "") | |
7607 | (match_operand:DI 2 "nonimmediate_operand" ""))) | |
7608 | (set (match_operand:DI 3 "register_operand" "") | |
7609 | (mod:DI (match_dup 1) (match_dup 2))) | |
7610 | (clobber (reg:CC 17))])] | |
7611 | "TARGET_64BIT" | |
7612 | "") | |
7613 | ||
7614 | ;; Allow to come the parameter in eax or edx to avoid extra moves. | |
7615 | ;; Penalize eax case sligthly because it results in worse scheduling | |
7616 | ;; of code. | |
7617 | (define_insn "*divmoddi4_nocltd_rex64" | |
7618 | [(set (match_operand:DI 0 "register_operand" "=&a,?a") | |
7619 | (div:DI (match_operand:DI 2 "register_operand" "1,0") | |
7620 | (match_operand:DI 3 "nonimmediate_operand" "rm,rm"))) | |
7621 | (set (match_operand:DI 1 "register_operand" "=&d,&d") | |
7622 | (mod:DI (match_dup 2) (match_dup 3))) | |
7623 | (clobber (reg:CC 17))] | |
7624 | "TARGET_64BIT && !optimize_size && !TARGET_USE_CLTD" | |
7625 | "#" | |
7626 | [(set_attr "type" "multi")]) | |
7627 | ||
7628 | (define_insn "*divmoddi4_cltd_rex64" | |
7629 | [(set (match_operand:DI 0 "register_operand" "=a") | |
7630 | (div:DI (match_operand:DI 2 "register_operand" "a") | |
7631 | (match_operand:DI 3 "nonimmediate_operand" "rm"))) | |
7632 | (set (match_operand:DI 1 "register_operand" "=&d") | |
7633 | (mod:DI (match_dup 2) (match_dup 3))) | |
7634 | (clobber (reg:CC 17))] | |
7635 | "TARGET_64BIT && (optimize_size || TARGET_USE_CLTD)" | |
7636 | "#" | |
7637 | [(set_attr "type" "multi")]) | |
7638 | ||
7639 | (define_insn "*divmoddi_noext_rex64" | |
7640 | [(set (match_operand:DI 0 "register_operand" "=a") | |
7641 | (div:DI (match_operand:DI 1 "register_operand" "0") | |
7642 | (match_operand:DI 2 "nonimmediate_operand" "rm"))) | |
7643 | (set (match_operand:DI 3 "register_operand" "=d") | |
7644 | (mod:DI (match_dup 1) (match_dup 2))) | |
7645 | (use (match_operand:DI 4 "register_operand" "3")) | |
7646 | (clobber (reg:CC 17))] | |
7647 | "TARGET_64BIT" | |
0f40f9f7 | 7648 | "idiv{q}\t%2" |
9b70259d JH |
7649 | [(set_attr "type" "idiv") |
7650 | (set_attr "mode" "DI") | |
7651 | (set_attr "ppro_uops" "few")]) | |
7652 | ||
7653 | (define_split | |
7654 | [(set (match_operand:DI 0 "register_operand" "") | |
7655 | (div:DI (match_operand:DI 1 "register_operand" "") | |
7656 | (match_operand:DI 2 "nonimmediate_operand" ""))) | |
7657 | (set (match_operand:DI 3 "register_operand" "") | |
7658 | (mod:DI (match_dup 1) (match_dup 2))) | |
7659 | (clobber (reg:CC 17))] | |
7660 | "TARGET_64BIT && reload_completed" | |
7661 | [(parallel [(set (match_dup 3) | |
7662 | (ashiftrt:DI (match_dup 4) (const_int 63))) | |
7663 | (clobber (reg:CC 17))]) | |
7664 | (parallel [(set (match_dup 0) | |
7665 | (div:DI (reg:DI 0) (match_dup 2))) | |
7666 | (set (match_dup 3) | |
7667 | (mod:DI (reg:DI 0) (match_dup 2))) | |
7668 | (use (match_dup 3)) | |
7669 | (clobber (reg:CC 17))])] | |
9b70259d JH |
7670 | { |
7671 | /* Avoid use of cltd in favour of a mov+shift. */ | |
7672 | if (!TARGET_USE_CLTD && !optimize_size) | |
7673 | { | |
7674 | if (true_regnum (operands[1])) | |
7675 | emit_move_insn (operands[0], operands[1]); | |
7676 | else | |
7677 | emit_move_insn (operands[3], operands[1]); | |
7678 | operands[4] = operands[3]; | |
7679 | } | |
7680 | else | |
7681 | { | |
7682 | if (true_regnum (operands[1])) | |
7683 | abort(); | |
7684 | operands[4] = operands[1]; | |
7685 | } | |
0f40f9f7 | 7686 | }) |
9b70259d JH |
7687 | |
7688 | ||
40745eec JH |
7689 | (define_expand "divmodsi4" |
7690 | [(parallel [(set (match_operand:SI 0 "register_operand" "") | |
7691 | (div:SI (match_operand:SI 1 "register_operand" "") | |
7692 | (match_operand:SI 2 "nonimmediate_operand" ""))) | |
7693 | (set (match_operand:SI 3 "register_operand" "") | |
7694 | (mod:SI (match_dup 1) (match_dup 2))) | |
7695 | (clobber (reg:CC 17))])] | |
7696 | "" | |
7697 | "") | |
7698 | ||
7699 | ;; Allow to come the parameter in eax or edx to avoid extra moves. | |
7700 | ;; Penalize eax case sligthly because it results in worse scheduling | |
7701 | ;; of code. | |
7702 | (define_insn "*divmodsi4_nocltd" | |
7703 | [(set (match_operand:SI 0 "register_operand" "=&a,?a") | |
7704 | (div:SI (match_operand:SI 2 "register_operand" "1,0") | |
7705 | (match_operand:SI 3 "nonimmediate_operand" "rm,rm"))) | |
7706 | (set (match_operand:SI 1 "register_operand" "=&d,&d") | |
7707 | (mod:SI (match_dup 2) (match_dup 3))) | |
7708 | (clobber (reg:CC 17))] | |
7709 | "!optimize_size && !TARGET_USE_CLTD" | |
7710 | "#" | |
7711 | [(set_attr "type" "multi")]) | |
886c62d1 | 7712 | |
40745eec | 7713 | (define_insn "*divmodsi4_cltd" |
2bb7a0f5 | 7714 | [(set (match_operand:SI 0 "register_operand" "=a") |
40745eec JH |
7715 | (div:SI (match_operand:SI 2 "register_operand" "a") |
7716 | (match_operand:SI 3 "nonimmediate_operand" "rm"))) | |
7717 | (set (match_operand:SI 1 "register_operand" "=&d") | |
7718 | (mod:SI (match_dup 2) (match_dup 3))) | |
e075ae69 | 7719 | (clobber (reg:CC 17))] |
40745eec JH |
7720 | "optimize_size || TARGET_USE_CLTD" |
7721 | "#" | |
e075ae69 RH |
7722 | [(set_attr "type" "multi")]) |
7723 | ||
6343a50e | 7724 | (define_insn "*divmodsi_noext" |
e075ae69 | 7725 | [(set (match_operand:SI 0 "register_operand" "=a") |
40745eec | 7726 | (div:SI (match_operand:SI 1 "register_operand" "0") |
e075ae69 RH |
7727 | (match_operand:SI 2 "nonimmediate_operand" "rm"))) |
7728 | (set (match_operand:SI 3 "register_operand" "=d") | |
7729 | (mod:SI (match_dup 1) (match_dup 2))) | |
40745eec | 7730 | (use (match_operand:SI 4 "register_operand" "3")) |
e075ae69 RH |
7731 | (clobber (reg:CC 17))] |
7732 | "" | |
0f40f9f7 | 7733 | "idiv{l}\t%2" |
e075ae69 | 7734 | [(set_attr "type" "idiv") |
6ef67412 | 7735 | (set_attr "mode" "SI") |
e075ae69 RH |
7736 | (set_attr "ppro_uops" "few")]) |
7737 | ||
7738 | (define_split | |
7739 | [(set (match_operand:SI 0 "register_operand" "") | |
7740 | (div:SI (match_operand:SI 1 "register_operand" "") | |
7741 | (match_operand:SI 2 "nonimmediate_operand" ""))) | |
7742 | (set (match_operand:SI 3 "register_operand" "") | |
7743 | (mod:SI (match_dup 1) (match_dup 2))) | |
7744 | (clobber (reg:CC 17))] | |
7745 | "reload_completed" | |
7746 | [(parallel [(set (match_dup 3) | |
7747 | (ashiftrt:SI (match_dup 4) (const_int 31))) | |
7748 | (clobber (reg:CC 17))]) | |
7749 | (parallel [(set (match_dup 0) | |
40745eec | 7750 | (div:SI (reg:SI 0) (match_dup 2))) |
e075ae69 | 7751 | (set (match_dup 3) |
40745eec | 7752 | (mod:SI (reg:SI 0) (match_dup 2))) |
e075ae69 RH |
7753 | (use (match_dup 3)) |
7754 | (clobber (reg:CC 17))])] | |
886c62d1 | 7755 | { |
e075ae69 | 7756 | /* Avoid use of cltd in favour of a mov+shift. */ |
40745eec | 7757 | if (!TARGET_USE_CLTD && !optimize_size) |
e075ae69 | 7758 | { |
40745eec JH |
7759 | if (true_regnum (operands[1])) |
7760 | emit_move_insn (operands[0], operands[1]); | |
7761 | else | |
7762 | emit_move_insn (operands[3], operands[1]); | |
e075ae69 RH |
7763 | operands[4] = operands[3]; |
7764 | } | |
7765 | else | |
40745eec JH |
7766 | { |
7767 | if (true_regnum (operands[1])) | |
7768 | abort(); | |
7769 | operands[4] = operands[1]; | |
7770 | } | |
0f40f9f7 | 7771 | }) |
e075ae69 | 7772 | ;; %%% Split me. |
886c62d1 | 7773 | (define_insn "divmodhi4" |
2bb7a0f5 RS |
7774 | [(set (match_operand:HI 0 "register_operand" "=a") |
7775 | (div:HI (match_operand:HI 1 "register_operand" "0") | |
2ae0f82c | 7776 | (match_operand:HI 2 "nonimmediate_operand" "rm"))) |
2bb7a0f5 | 7777 | (set (match_operand:HI 3 "register_operand" "=&d") |
e075ae69 RH |
7778 | (mod:HI (match_dup 1) (match_dup 2))) |
7779 | (clobber (reg:CC 17))] | |
d9f32422 | 7780 | "TARGET_HIMODE_MATH" |
0f40f9f7 | 7781 | "cwtd\;idiv{w}\t%2" |
6ef67412 JH |
7782 | [(set_attr "type" "multi") |
7783 | (set_attr "length_immediate" "0") | |
7784 | (set_attr "mode" "SI")]) | |
886c62d1 | 7785 | |
9b70259d JH |
7786 | (define_insn "udivmoddi4" |
7787 | [(set (match_operand:DI 0 "register_operand" "=a") | |
7788 | (udiv:DI (match_operand:DI 1 "register_operand" "0") | |
7789 | (match_operand:DI 2 "nonimmediate_operand" "rm"))) | |
7790 | (set (match_operand:DI 3 "register_operand" "=&d") | |
7791 | (umod:DI (match_dup 1) (match_dup 2))) | |
7792 | (clobber (reg:CC 17))] | |
7793 | "TARGET_64BIT" | |
0f40f9f7 | 7794 | "xor{q}\t%3, %3\;div{q}\t%2" |
9b70259d JH |
7795 | [(set_attr "type" "multi") |
7796 | (set_attr "length_immediate" "0") | |
7797 | (set_attr "mode" "DI")]) | |
7798 | ||
7799 | (define_insn "*udivmoddi4_noext" | |
7800 | [(set (match_operand:DI 0 "register_operand" "=a") | |
7801 | (udiv:DI (match_operand:DI 1 "register_operand" "0") | |
7802 | (match_operand:DI 2 "nonimmediate_operand" "rm"))) | |
7803 | (set (match_operand:DI 3 "register_operand" "=d") | |
7804 | (umod:DI (match_dup 1) (match_dup 2))) | |
7805 | (use (match_dup 3)) | |
7806 | (clobber (reg:CC 17))] | |
7807 | "TARGET_64BIT" | |
0f40f9f7 | 7808 | "div{q}\t%2" |
9b70259d JH |
7809 | [(set_attr "type" "idiv") |
7810 | (set_attr "ppro_uops" "few") | |
7811 | (set_attr "mode" "DI")]) | |
7812 | ||
7813 | (define_split | |
7814 | [(set (match_operand:DI 0 "register_operand" "") | |
7815 | (udiv:DI (match_operand:DI 1 "register_operand" "") | |
7816 | (match_operand:DI 2 "nonimmediate_operand" ""))) | |
7817 | (set (match_operand:DI 3 "register_operand" "") | |
7818 | (umod:DI (match_dup 1) (match_dup 2))) | |
7819 | (clobber (reg:CC 17))] | |
1b0c37d7 | 7820 | "TARGET_64BIT && reload_completed" |
9b70259d JH |
7821 | [(set (match_dup 3) (const_int 0)) |
7822 | (parallel [(set (match_dup 0) | |
7823 | (udiv:DI (match_dup 1) (match_dup 2))) | |
7824 | (set (match_dup 3) | |
7825 | (umod:DI (match_dup 1) (match_dup 2))) | |
7826 | (use (match_dup 3)) | |
7827 | (clobber (reg:CC 17))])] | |
7828 | "") | |
7829 | ||
886c62d1 | 7830 | (define_insn "udivmodsi4" |
2bb7a0f5 RS |
7831 | [(set (match_operand:SI 0 "register_operand" "=a") |
7832 | (udiv:SI (match_operand:SI 1 "register_operand" "0") | |
2ae0f82c | 7833 | (match_operand:SI 2 "nonimmediate_operand" "rm"))) |
2bb7a0f5 | 7834 | (set (match_operand:SI 3 "register_operand" "=&d") |
e075ae69 RH |
7835 | (umod:SI (match_dup 1) (match_dup 2))) |
7836 | (clobber (reg:CC 17))] | |
886c62d1 | 7837 | "" |
0f40f9f7 | 7838 | "xor{l}\t%3, %3\;div{l}\t%2" |
6ef67412 JH |
7839 | [(set_attr "type" "multi") |
7840 | (set_attr "length_immediate" "0") | |
7841 | (set_attr "mode" "SI")]) | |
886c62d1 | 7842 | |
6343a50e | 7843 | (define_insn "*udivmodsi4_noext" |
2bb7a0f5 | 7844 | [(set (match_operand:SI 0 "register_operand" "=a") |
e075ae69 | 7845 | (udiv:SI (match_operand:SI 1 "register_operand" "0") |
2ae0f82c | 7846 | (match_operand:SI 2 "nonimmediate_operand" "rm"))) |
2bb7a0f5 | 7847 | (set (match_operand:SI 3 "register_operand" "=d") |
e075ae69 RH |
7848 | (umod:SI (match_dup 1) (match_dup 2))) |
7849 | (use (match_dup 3)) | |
7850 | (clobber (reg:CC 17))] | |
886c62d1 | 7851 | "" |
0f40f9f7 | 7852 | "div{l}\t%2" |
e075ae69 | 7853 | [(set_attr "type" "idiv") |
6ef67412 JH |
7854 | (set_attr "ppro_uops" "few") |
7855 | (set_attr "mode" "SI")]) | |
886c62d1 | 7856 | |
e075ae69 RH |
7857 | (define_split |
7858 | [(set (match_operand:SI 0 "register_operand" "") | |
7859 | (udiv:SI (match_operand:SI 1 "register_operand" "") | |
7860 | (match_operand:SI 2 "nonimmediate_operand" ""))) | |
7861 | (set (match_operand:SI 3 "register_operand" "") | |
7862 | (umod:SI (match_dup 1) (match_dup 2))) | |
7863 | (clobber (reg:CC 17))] | |
7864 | "reload_completed" | |
591702de | 7865 | [(set (match_dup 3) (const_int 0)) |
e075ae69 RH |
7866 | (parallel [(set (match_dup 0) |
7867 | (udiv:SI (match_dup 1) (match_dup 2))) | |
7868 | (set (match_dup 3) | |
7869 | (umod:SI (match_dup 1) (match_dup 2))) | |
7870 | (use (match_dup 3)) | |
7871 | (clobber (reg:CC 17))])] | |
7872 | "") | |
886c62d1 | 7873 | |
e075ae69 | 7874 | (define_expand "udivmodhi4" |
591702de | 7875 | [(set (match_dup 4) (const_int 0)) |
40745eec JH |
7876 | (parallel [(set (match_operand:HI 0 "register_operand" "") |
7877 | (udiv:HI (match_operand:HI 1 "register_operand" "") | |
7878 | (match_operand:HI 2 "nonimmediate_operand" ""))) | |
7879 | (set (match_operand:HI 3 "register_operand" "") | |
e075ae69 RH |
7880 | (umod:HI (match_dup 1) (match_dup 2))) |
7881 | (use (match_dup 4)) | |
7882 | (clobber (reg:CC 17))])] | |
d9f32422 | 7883 | "TARGET_HIMODE_MATH" |
e075ae69 | 7884 | "operands[4] = gen_reg_rtx (HImode);") |
886c62d1 | 7885 | |
6343a50e | 7886 | (define_insn "*udivmodhi_noext" |
e075ae69 RH |
7887 | [(set (match_operand:HI 0 "register_operand" "=a") |
7888 | (udiv:HI (match_operand:HI 1 "register_operand" "0") | |
7889 | (match_operand:HI 2 "nonimmediate_operand" "rm"))) | |
7890 | (set (match_operand:HI 3 "register_operand" "=d") | |
7891 | (umod:HI (match_dup 1) (match_dup 2))) | |
7892 | (use (match_operand:HI 4 "register_operand" "3")) | |
7893 | (clobber (reg:CC 17))] | |
7894 | "" | |
0f40f9f7 | 7895 | "div{w}\t%2" |
e075ae69 | 7896 | [(set_attr "type" "idiv") |
6ef67412 | 7897 | (set_attr "mode" "HI") |
e075ae69 RH |
7898 | (set_attr "ppro_uops" "few")]) |
7899 | ||
7900 | ;; We can not use div/idiv for double division, because it causes | |
7901 | ;; "division by zero" on the overflow and that's not what we expect | |
7902 | ;; from truncate. Because true (non truncating) double division is | |
7903 | ;; never generated, we can't create this insn anyway. | |
7904 | ; | |
7905 | ;(define_insn "" | |
7906 | ; [(set (match_operand:SI 0 "register_operand" "=a") | |
7907 | ; (truncate:SI | |
7908 | ; (udiv:DI (match_operand:DI 1 "register_operand" "A") | |
7909 | ; (zero_extend:DI | |
7910 | ; (match_operand:SI 2 "nonimmediate_operand" "rm"))))) | |
7911 | ; (set (match_operand:SI 3 "register_operand" "=d") | |
7912 | ; (truncate:SI | |
7913 | ; (umod:DI (match_dup 1) (zero_extend:DI (match_dup 2))))) | |
7914 | ; (clobber (reg:CC 17))] | |
7915 | ; "" | |
0f40f9f7 | 7916 | ; "div{l}\t{%2, %0|%0, %2}" |
e075ae69 RH |
7917 | ; [(set_attr "type" "idiv") |
7918 | ; (set_attr "ppro_uops" "few")]) | |
886c62d1 | 7919 | \f |
e075ae69 RH |
7920 | ;;- Logical AND instructions |
7921 | ||
7922 | ;; On Pentium, "test imm, reg" is pairable only with eax, ax, and al. | |
7923 | ;; Note that this excludes ah. | |
7924 | ||
9b70259d JH |
7925 | (define_insn "*testdi_1_rex64" |
7926 | [(set (reg 17) | |
7927 | (compare | |
7928 | (and:DI (match_operand:DI 0 "nonimmediate_operand" "%*a,r,*a,r,rm") | |
7929 | (match_operand:DI 1 "x86_64_szext_nonmemory_operand" "Z,Z,e,e,re")) | |
7930 | (const_int 0)))] | |
7931 | "TARGET_64BIT && ix86_match_ccmode (insn, CCNOmode)" | |
7932 | "@ | |
0f40f9f7 ZW |
7933 | test{l}\t{%k1, %k0|%k0, %k1} |
7934 | test{l}\t{%k1, %k0|%k0, %k1} | |
7935 | test{q}\t{%1, %0|%0, %1} | |
7936 | test{q}\t{%1, %0|%0, %1} | |
7937 | test{q}\t{%1, %0|%0, %1}" | |
9b70259d JH |
7938 | [(set_attr "type" "test") |
7939 | (set_attr "modrm" "0,1,0,1,1") | |
7940 | (set_attr "mode" "SI,SI,DI,DI,DI") | |
7941 | (set_attr "pent_pair" "uv,np,uv,np,uv")]) | |
9076b9c1 JH |
7942 | |
7943 | (define_insn "testsi_1" | |
7944 | [(set (reg 17) | |
7945 | (compare | |
16189740 RH |
7946 | (and:SI (match_operand:SI 0 "nonimmediate_operand" "%*a,r,rm") |
7947 | (match_operand:SI 1 "nonmemory_operand" "in,in,rin")) | |
7948 | (const_int 0)))] | |
9076b9c1 | 7949 | "ix86_match_ccmode (insn, CCNOmode)" |
0f40f9f7 | 7950 | "test{l}\t{%1, %0|%0, %1}" |
6ef67412 JH |
7951 | [(set_attr "type" "test") |
7952 | (set_attr "modrm" "0,1,1") | |
7953 | (set_attr "mode" "SI") | |
e075ae69 RH |
7954 | (set_attr "pent_pair" "uv,np,uv")]) |
7955 | ||
9076b9c1 | 7956 | (define_expand "testsi_ccno_1" |
e075ae69 | 7957 | [(set (reg:CCNO 17) |
16189740 | 7958 | (compare:CCNO |
9076b9c1 JH |
7959 | (and:SI (match_operand:SI 0 "nonimmediate_operand" "") |
7960 | (match_operand:SI 1 "nonmemory_operand" "")) | |
16189740 | 7961 | (const_int 0)))] |
a1cbdd7f | 7962 | "" |
9076b9c1 | 7963 | "") |
16189740 RH |
7964 | |
7965 | (define_insn "*testhi_1" | |
7966 | [(set (reg 17) | |
7967 | (compare (and:HI (match_operand:HI 0 "nonimmediate_operand" "%*a,r,rm") | |
7968 | (match_operand:HI 1 "nonmemory_operand" "n,n,rn")) | |
7969 | (const_int 0)))] | |
7970 | "ix86_match_ccmode (insn, CCNOmode)" | |
0f40f9f7 | 7971 | "test{w}\t{%1, %0|%0, %1}" |
6ef67412 JH |
7972 | [(set_attr "type" "test") |
7973 | (set_attr "modrm" "0,1,1") | |
7974 | (set_attr "mode" "HI") | |
e075ae69 RH |
7975 | (set_attr "pent_pair" "uv,np,uv")]) |
7976 | ||
9076b9c1 | 7977 | (define_expand "testqi_ccz_1" |
16189740 | 7978 | [(set (reg:CCZ 17) |
9076b9c1 JH |
7979 | (compare:CCZ (and:QI (match_operand:QI 0 "nonimmediate_operand" "") |
7980 | (match_operand:QI 1 "nonmemory_operand" "")) | |
7981 | (const_int 0)))] | |
16189740 | 7982 | "" |
9076b9c1 | 7983 | "") |
16189740 | 7984 | |
9076b9c1 JH |
7985 | (define_insn "*testqi_1" |
7986 | [(set (reg 17) | |
7987 | (compare (and:QI (match_operand:QI 0 "nonimmediate_operand" "%*a,q,qm,r") | |
7988 | (match_operand:QI 1 "nonmemory_operand" "n,n,qn,n")) | |
7989 | (const_int 0)))] | |
7990 | "ix86_match_ccmode (insn, CCNOmode)" | |
adc88131 JJ |
7991 | { |
7992 | if (which_alternative == 3) | |
7993 | { | |
7994 | if (GET_CODE (operands[1]) == CONST_INT | |
7995 | && (INTVAL (operands[1]) & 0xffffff00)) | |
7996 | operands[1] = GEN_INT (INTVAL (operands[1]) & 0xff); | |
0f40f9f7 | 7997 | return "test{l}\t{%1, %k0|%k0, %1}"; |
adc88131 | 7998 | } |
0f40f9f7 ZW |
7999 | return "test{b}\t{%1, %0|%0, %1}"; |
8000 | } | |
6ef67412 JH |
8001 | [(set_attr "type" "test") |
8002 | (set_attr "modrm" "0,1,1,1") | |
8003 | (set_attr "mode" "QI,QI,QI,SI") | |
8004 | (set_attr "pent_pair" "uv,np,uv,np")]) | |
e075ae69 | 8005 | |
9076b9c1 JH |
8006 | (define_expand "testqi_ext_ccno_0" |
8007 | [(set (reg:CCNO 17) | |
8008 | (compare:CCNO | |
16189740 RH |
8009 | (and:SI |
8010 | (zero_extract:SI | |
9076b9c1 | 8011 | (match_operand 0 "ext_register_operand" "") |
16189740 RH |
8012 | (const_int 8) |
8013 | (const_int 8)) | |
9076b9c1 | 8014 | (match_operand 1 "const_int_operand" "")) |
16189740 | 8015 | (const_int 0)))] |
9076b9c1 JH |
8016 | "" |
8017 | "") | |
e075ae69 | 8018 | |
9076b9c1 JH |
8019 | (define_insn "*testqi_ext_0" |
8020 | [(set (reg 17) | |
8021 | (compare | |
e075ae69 RH |
8022 | (and:SI |
8023 | (zero_extract:SI | |
d2836273 | 8024 | (match_operand 0 "ext_register_operand" "Q") |
e075ae69 RH |
8025 | (const_int 8) |
8026 | (const_int 8)) | |
8027 | (match_operand 1 "const_int_operand" "n")) | |
8028 | (const_int 0)))] | |
9076b9c1 JH |
8029 | "(unsigned HOST_WIDE_INT) INTVAL (operands[1]) <= 0xff |
8030 | && ix86_match_ccmode (insn, CCNOmode)" | |
0f40f9f7 | 8031 | "test{b}\t{%1, %h0|%h0, %1}" |
6ef67412 JH |
8032 | [(set_attr "type" "test") |
8033 | (set_attr "mode" "QI") | |
8034 | (set_attr "length_immediate" "1") | |
e075ae69 RH |
8035 | (set_attr "pent_pair" "np")]) |
8036 | ||
8037 | (define_insn "*testqi_ext_1" | |
16189740 RH |
8038 | [(set (reg 17) |
8039 | (compare | |
e075ae69 RH |
8040 | (and:SI |
8041 | (zero_extract:SI | |
d2836273 | 8042 | (match_operand 0 "ext_register_operand" "Q") |
e075ae69 RH |
8043 | (const_int 8) |
8044 | (const_int 8)) | |
8045 | (zero_extend:SI | |
d2836273 | 8046 | (match_operand:QI 1 "nonimmediate_operand" "Qm"))) |
e075ae69 | 8047 | (const_int 0)))] |
d2836273 | 8048 | "!TARGET_64BIT && ix86_match_ccmode (insn, CCNOmode)" |
0f40f9f7 | 8049 | "test{b}\t{%1, %h0|%h0, %1}" |
d2836273 JH |
8050 | [(set_attr "type" "test") |
8051 | (set_attr "mode" "QI")]) | |
8052 | ||
8053 | (define_insn "*testqi_ext_1_rex64" | |
8054 | [(set (reg 17) | |
8055 | (compare | |
8056 | (and:SI | |
8057 | (zero_extract:SI | |
8058 | (match_operand 0 "ext_register_operand" "Q") | |
8059 | (const_int 8) | |
8060 | (const_int 8)) | |
8061 | (zero_extend:SI | |
3522082b | 8062 | (match_operand:QI 1 "register_operand" "Q"))) |
d2836273 JH |
8063 | (const_int 0)))] |
8064 | "TARGET_64BIT && ix86_match_ccmode (insn, CCNOmode)" | |
0f40f9f7 | 8065 | "test{b}\t{%1, %h0|%h0, %1}" |
6ef67412 JH |
8066 | [(set_attr "type" "test") |
8067 | (set_attr "mode" "QI")]) | |
e075ae69 RH |
8068 | |
8069 | (define_insn "*testqi_ext_2" | |
16189740 RH |
8070 | [(set (reg 17) |
8071 | (compare | |
e075ae69 RH |
8072 | (and:SI |
8073 | (zero_extract:SI | |
d2836273 | 8074 | (match_operand 0 "ext_register_operand" "Q") |
e075ae69 RH |
8075 | (const_int 8) |
8076 | (const_int 8)) | |
8077 | (zero_extract:SI | |
d2836273 | 8078 | (match_operand 1 "ext_register_operand" "Q") |
e075ae69 RH |
8079 | (const_int 8) |
8080 | (const_int 8))) | |
8081 | (const_int 0)))] | |
16189740 | 8082 | "ix86_match_ccmode (insn, CCNOmode)" |
0f40f9f7 | 8083 | "test{b}\t{%h1, %h0|%h0, %h1}" |
6ef67412 JH |
8084 | [(set_attr "type" "test") |
8085 | (set_attr "mode" "QI")]) | |
e075ae69 RH |
8086 | |
8087 | ;; Combine likes to form bit extractions for some tests. Humor it. | |
6343a50e | 8088 | (define_insn "*testqi_ext_3" |
16189740 RH |
8089 | [(set (reg 17) |
8090 | (compare (zero_extract:SI | |
8091 | (match_operand 0 "nonimmediate_operand" "rm") | |
8092 | (match_operand:SI 1 "const_int_operand" "") | |
8093 | (match_operand:SI 2 "const_int_operand" "")) | |
8094 | (const_int 0)))] | |
8095 | "ix86_match_ccmode (insn, CCNOmode) | |
8096 | && (GET_MODE (operands[0]) == SImode | |
9b70259d JH |
8097 | || (TARGET_64BIT && GET_MODE (operands[0]) == DImode) |
8098 | || GET_MODE (operands[0]) == HImode | |
8099 | || GET_MODE (operands[0]) == QImode)" | |
8100 | "#") | |
8101 | ||
8102 | (define_insn "*testqi_ext_3_rex64" | |
8103 | [(set (reg 17) | |
8104 | (compare (zero_extract:DI | |
8105 | (match_operand 0 "nonimmediate_operand" "rm") | |
8106 | (match_operand:DI 1 "const_int_operand" "") | |
8107 | (match_operand:DI 2 "const_int_operand" "")) | |
8108 | (const_int 0)))] | |
1b0c37d7 ZW |
8109 | "TARGET_64BIT |
8110 | && ix86_match_ccmode (insn, CCNOmode) | |
f5143c46 | 8111 | /* The code below cannot deal with constants outside HOST_WIDE_INT. */ |
44cf5b6a JH |
8112 | && INTVAL (operands[1]) + INTVAL (operands[2]) < HOST_BITS_PER_WIDE_INT |
8113 | /* Ensure that resulting mask is zero or sign extended operand. */ | |
8114 | && (INTVAL (operands[1]) + INTVAL (operands[2]) <= 32 | |
8115 | || (INTVAL (operands[1]) + INTVAL (operands[2]) == 64 | |
8116 | && INTVAL (operands[1]) > 32)) | |
9b70259d JH |
8117 | && (GET_MODE (operands[0]) == SImode |
8118 | || GET_MODE (operands[0]) == DImode | |
16189740 RH |
8119 | || GET_MODE (operands[0]) == HImode |
8120 | || GET_MODE (operands[0]) == QImode)" | |
e075ae69 | 8121 | "#") |
4fce8e83 | 8122 | |
e075ae69 | 8123 | (define_split |
16189740 | 8124 | [(set (reg 17) |
9b70259d | 8125 | (compare (zero_extract |
d5d6a58b | 8126 | (match_operand 0 "nonimmediate_operand" "") |
9b70259d JH |
8127 | (match_operand 1 "const_int_operand" "") |
8128 | (match_operand 2 "const_int_operand" "")) | |
16189740 RH |
8129 | (const_int 0)))] |
8130 | "ix86_match_ccmode (insn, CCNOmode)" | |
e075ae69 | 8131 | [(set (reg:CCNO 17) (compare:CCNO (match_dup 3) (const_int 0)))] |
e075ae69 RH |
8132 | { |
8133 | HOST_WIDE_INT len = INTVAL (operands[1]); | |
8134 | HOST_WIDE_INT pos = INTVAL (operands[2]); | |
8135 | HOST_WIDE_INT mask; | |
592188a5 | 8136 | enum machine_mode mode, submode; |
886c62d1 | 8137 | |
e075ae69 RH |
8138 | mode = GET_MODE (operands[0]); |
8139 | if (GET_CODE (operands[0]) == MEM) | |
5bc7cd8e | 8140 | { |
e075ae69 RH |
8141 | /* ??? Combine likes to put non-volatile mem extractions in QImode |
8142 | no matter the size of the test. So find a mode that works. */ | |
8143 | if (! MEM_VOLATILE_P (operands[0])) | |
8144 | { | |
8145 | mode = smallest_mode_for_size (pos + len, MODE_INT); | |
f4ef873c | 8146 | operands[0] = adjust_address (operands[0], mode, 0); |
e075ae69 | 8147 | } |
5bc7cd8e | 8148 | } |
592188a5 RH |
8149 | else if (GET_CODE (operands[0]) == SUBREG |
8150 | && (submode = GET_MODE (SUBREG_REG (operands[0])), | |
8151 | GET_MODE_BITSIZE (mode) > GET_MODE_BITSIZE (submode)) | |
8152 | && pos + len <= GET_MODE_BITSIZE (submode)) | |
8153 | { | |
8154 | /* Narrow a paradoxical subreg to prevent partial register stalls. */ | |
8155 | mode = submode; | |
8156 | operands[0] = SUBREG_REG (operands[0]); | |
8157 | } | |
e075ae69 | 8158 | else if (mode == HImode && pos + len <= 8) |
5bc7cd8e | 8159 | { |
e075ae69 RH |
8160 | /* Small HImode tests can be converted to QImode. */ |
8161 | mode = QImode; | |
8162 | operands[0] = gen_lowpart (QImode, operands[0]); | |
5bc7cd8e SC |
8163 | } |
8164 | ||
e075ae69 RH |
8165 | mask = ((HOST_WIDE_INT)1 << (pos + len)) - 1; |
8166 | mask &= ~(((HOST_WIDE_INT)1 << pos) - 1); | |
886c62d1 | 8167 | |
383252a7 AO |
8168 | operands[3] = gen_rtx_AND (mode, operands[0], |
8169 | GEN_INT (trunc_int_for_mode (mask, mode))); | |
0f40f9f7 | 8170 | }) |
886c62d1 | 8171 | |
e075ae69 RH |
8172 | ;; %%% This used to optimize known byte-wide and operations to memory, |
8173 | ;; and sometimes to QImode registers. If this is considered useful, | |
8174 | ;; it should be done with splitters. | |
8175 | ||
9b70259d JH |
8176 | (define_expand "anddi3" |
8177 | [(set (match_operand:DI 0 "nonimmediate_operand" "") | |
8178 | (and:DI (match_operand:DI 1 "nonimmediate_operand" "") | |
8179 | (match_operand:DI 2 "x86_64_szext_general_operand" ""))) | |
8180 | (clobber (reg:CC 17))] | |
8181 | "TARGET_64BIT" | |
8182 | "ix86_expand_binary_operator (AND, DImode, operands); DONE;") | |
8183 | ||
8184 | (define_insn "*anddi_1_rex64" | |
8185 | [(set (match_operand:DI 0 "nonimmediate_operand" "=r,rm,r,r") | |
8186 | (and:DI (match_operand:DI 1 "nonimmediate_operand" "%0,0,0,qm") | |
8187 | (match_operand:DI 2 "x86_64_szext_general_operand" "Z,re,rm,L"))) | |
8188 | (clobber (reg:CC 17))] | |
8189 | "TARGET_64BIT && ix86_binary_operator_ok (AND, DImode, operands)" | |
9b70259d JH |
8190 | { |
8191 | switch (get_attr_type (insn)) | |
8192 | { | |
8193 | case TYPE_IMOVX: | |
8194 | { | |
8195 | enum machine_mode mode; | |
8196 | ||
8197 | if (GET_CODE (operands[2]) != CONST_INT) | |
8198 | abort (); | |
8199 | if (INTVAL (operands[2]) == 0xff) | |
8200 | mode = QImode; | |
8201 | else if (INTVAL (operands[2]) == 0xffff) | |
8202 | mode = HImode; | |
8203 | else | |
8204 | abort (); | |
8205 | ||
8206 | operands[1] = gen_lowpart (mode, operands[1]); | |
8207 | if (mode == QImode) | |
0f40f9f7 | 8208 | return "movz{bq|x}\t{%1,%0|%0, %1}"; |
9b70259d | 8209 | else |
0f40f9f7 | 8210 | return "movz{wq|x}\t{%1,%0|%0, %1}"; |
9b70259d JH |
8211 | } |
8212 | ||
8213 | default: | |
8214 | if (! rtx_equal_p (operands[0], operands[1])) | |
8215 | abort (); | |
8216 | if (get_attr_mode (insn) == MODE_SI) | |
0f40f9f7 | 8217 | return "and{l}\t{%k2, %k0|%k0, %k2}"; |
9b70259d | 8218 | else |
0f40f9f7 | 8219 | return "and{q}\t{%2, %0|%0, %2}"; |
9b70259d | 8220 | } |
0f40f9f7 | 8221 | } |
9b70259d JH |
8222 | [(set_attr "type" "alu,alu,alu,imovx") |
8223 | (set_attr "length_immediate" "*,*,*,0") | |
8224 | (set_attr "mode" "SI,DI,DI,DI")]) | |
8225 | ||
8226 | (define_insn "*anddi_2" | |
8227 | [(set (reg 17) | |
8228 | (compare (and:DI (match_operand:DI 1 "nonimmediate_operand" "%0,0,0") | |
8229 | (match_operand:DI 2 "x86_64_szext_general_operand" "Z,rem,re")) | |
8230 | (const_int 0))) | |
8231 | (set (match_operand:DI 0 "nonimmediate_operand" "=r,r,rm") | |
8232 | (and:DI (match_dup 1) (match_dup 2)))] | |
8233 | "TARGET_64BIT && ix86_match_ccmode (insn, CCNOmode) | |
8234 | && ix86_binary_operator_ok (AND, DImode, operands)" | |
8235 | "@ | |
0f40f9f7 ZW |
8236 | and{l}\t{%k2, %k0|%k0, %k2} |
8237 | and{q}\t{%2, %0|%0, %2} | |
8238 | and{q}\t{%2, %0|%0, %2}" | |
9b70259d JH |
8239 | [(set_attr "type" "alu") |
8240 | (set_attr "mode" "SI,DI,DI")]) | |
8241 | ||
e075ae69 RH |
8242 | (define_expand "andsi3" |
8243 | [(set (match_operand:SI 0 "nonimmediate_operand" "") | |
8244 | (and:SI (match_operand:SI 1 "nonimmediate_operand" "") | |
8245 | (match_operand:SI 2 "general_operand" ""))) | |
8246 | (clobber (reg:CC 17))] | |
8247 | "" | |
8248 | "ix86_expand_binary_operator (AND, SImode, operands); DONE;") | |
8249 | ||
8250 | (define_insn "*andsi_1" | |
8251 | [(set (match_operand:SI 0 "nonimmediate_operand" "=rm,r,r") | |
8252 | (and:SI (match_operand:SI 1 "nonimmediate_operand" "%0,0,qm") | |
8253 | (match_operand:SI 2 "general_operand" "ri,rm,L"))) | |
8254 | (clobber (reg:CC 17))] | |
8255 | "ix86_binary_operator_ok (AND, SImode, operands)" | |
886c62d1 | 8256 | { |
e075ae69 | 8257 | switch (get_attr_type (insn)) |
886c62d1 | 8258 | { |
e075ae69 RH |
8259 | case TYPE_IMOVX: |
8260 | { | |
8261 | enum machine_mode mode; | |
5bc7cd8e | 8262 | |
e075ae69 RH |
8263 | if (GET_CODE (operands[2]) != CONST_INT) |
8264 | abort (); | |
8265 | if (INTVAL (operands[2]) == 0xff) | |
8266 | mode = QImode; | |
8267 | else if (INTVAL (operands[2]) == 0xffff) | |
8268 | mode = HImode; | |
8269 | else | |
8270 | abort (); | |
8271 | ||
8272 | operands[1] = gen_lowpart (mode, operands[1]); | |
8273 | if (mode == QImode) | |
0f40f9f7 | 8274 | return "movz{bl|x}\t{%1,%0|%0, %1}"; |
e075ae69 | 8275 | else |
0f40f9f7 | 8276 | return "movz{wl|x}\t{%1,%0|%0, %1}"; |
e075ae69 | 8277 | } |
5bc7cd8e | 8278 | |
e075ae69 RH |
8279 | default: |
8280 | if (! rtx_equal_p (operands[0], operands[1])) | |
8281 | abort (); | |
0f40f9f7 | 8282 | return "and{l}\t{%2, %0|%0, %2}"; |
886c62d1 | 8283 | } |
0f40f9f7 | 8284 | } |
6ef67412 JH |
8285 | [(set_attr "type" "alu,alu,imovx") |
8286 | (set_attr "length_immediate" "*,*,0") | |
8287 | (set_attr "mode" "SI")]) | |
8288 | ||
8289 | (define_split | |
05b432db | 8290 | [(set (match_operand 0 "register_operand" "") |
9b70259d JH |
8291 | (and (match_dup 0) |
8292 | (const_int -65536))) | |
6ef67412 | 8293 | (clobber (reg:CC 17))] |
3522082b | 8294 | "optimize_size" |
6ef67412 JH |
8295 | [(set (strict_low_part (match_dup 1)) (const_int 0))] |
8296 | "operands[1] = gen_lowpart (HImode, operands[0]);") | |
8297 | ||
8298 | (define_split | |
3522082b | 8299 | [(set (match_operand 0 "ext_register_operand" "") |
5e1a2fc7 | 8300 | (and (match_dup 0) |
9b70259d | 8301 | (const_int -256))) |
6ef67412 | 8302 | (clobber (reg:CC 17))] |
05b432db | 8303 | "(optimize_size || !TARGET_PARTIAL_REG_STALL) && reload_completed" |
6ef67412 JH |
8304 | [(set (strict_low_part (match_dup 1)) (const_int 0))] |
8305 | "operands[1] = gen_lowpart (QImode, operands[0]);") | |
8306 | ||
8307 | (define_split | |
3522082b | 8308 | [(set (match_operand 0 "ext_register_operand" "") |
6ef67412 JH |
8309 | (and (match_dup 0) |
8310 | (const_int -65281))) | |
8311 | (clobber (reg:CC 17))] | |
05b432db | 8312 | "(optimize_size || !TARGET_PARTIAL_REG_STALL) && reload_completed" |
6ef67412 JH |
8313 | [(parallel [(set (zero_extract:SI (match_dup 0) |
8314 | (const_int 8) | |
8315 | (const_int 8)) | |
8316 | (xor:SI | |
8317 | (zero_extract:SI (match_dup 0) | |
8318 | (const_int 8) | |
8319 | (const_int 8)) | |
8320 | (zero_extract:SI (match_dup 0) | |
8321 | (const_int 8) | |
8322 | (const_int 8)))) | |
8323 | (clobber (reg:CC 17))])] | |
8324 | "operands[0] = gen_lowpart (SImode, operands[0]);") | |
e075ae69 | 8325 | |
9b70259d JH |
8326 | ;; See comment for addsi_1_zext why we do use nonimmediate_operand |
8327 | (define_insn "*andsi_1_zext" | |
8328 | [(set (match_operand:DI 0 "register_operand" "=r") | |
8329 | (zero_extend:DI | |
8330 | (and:SI (match_operand:SI 1 "nonimmediate_operand" "%0") | |
8331 | (match_operand:SI 2 "general_operand" "rim")))) | |
8332 | (clobber (reg:CC 17))] | |
8333 | "TARGET_64BIT && ix86_binary_operator_ok (AND, SImode, operands)" | |
0f40f9f7 | 8334 | "and{l}\t{%2, %k0|%k0, %2}" |
9b70259d JH |
8335 | [(set_attr "type" "alu") |
8336 | (set_attr "mode" "SI")]) | |
8337 | ||
e075ae69 | 8338 | (define_insn "*andsi_2" |
16189740 RH |
8339 | [(set (reg 17) |
8340 | (compare (and:SI (match_operand:SI 1 "nonimmediate_operand" "%0,0") | |
8341 | (match_operand:SI 2 "general_operand" "rim,ri")) | |
8342 | (const_int 0))) | |
e075ae69 RH |
8343 | (set (match_operand:SI 0 "nonimmediate_operand" "=r,rm") |
8344 | (and:SI (match_dup 1) (match_dup 2)))] | |
16189740 RH |
8345 | "ix86_match_ccmode (insn, CCNOmode) |
8346 | && ix86_binary_operator_ok (AND, SImode, operands)" | |
0f40f9f7 | 8347 | "and{l}\t{%2, %0|%0, %2}" |
6ef67412 JH |
8348 | [(set_attr "type" "alu") |
8349 | (set_attr "mode" "SI")]) | |
e075ae69 | 8350 | |
9b70259d JH |
8351 | ;; See comment for addsi_1_zext why we do use nonimmediate_operand |
8352 | (define_insn "*andsi_2_zext" | |
8353 | [(set (reg 17) | |
8354 | (compare (and:SI (match_operand:SI 1 "nonimmediate_operand" "%0") | |
8355 | (match_operand:SI 2 "general_operand" "rim")) | |
8356 | (const_int 0))) | |
8357 | (set (match_operand:DI 0 "register_operand" "=r") | |
8358 | (zero_extend:DI (and:SI (match_dup 1) (match_dup 2))))] | |
8359 | "TARGET_64BIT && ix86_match_ccmode (insn, CCNOmode) | |
8360 | && ix86_binary_operator_ok (AND, SImode, operands)" | |
0f40f9f7 | 8361 | "and{l}\t{%2, %k0|%k0, %2}" |
9b70259d JH |
8362 | [(set_attr "type" "alu") |
8363 | (set_attr "mode" "SI")]) | |
8364 | ||
e075ae69 RH |
8365 | (define_expand "andhi3" |
8366 | [(set (match_operand:HI 0 "nonimmediate_operand" "") | |
8367 | (and:HI (match_operand:HI 1 "nonimmediate_operand" "") | |
8368 | (match_operand:HI 2 "general_operand" ""))) | |
8369 | (clobber (reg:CC 17))] | |
d9f32422 | 8370 | "TARGET_HIMODE_MATH" |
e075ae69 RH |
8371 | "ix86_expand_binary_operator (AND, HImode, operands); DONE;") |
8372 | ||
8373 | (define_insn "*andhi_1" | |
8374 | [(set (match_operand:HI 0 "nonimmediate_operand" "=rm,r,r") | |
8375 | (and:HI (match_operand:HI 1 "nonimmediate_operand" "%0,0,qm") | |
8376 | (match_operand:HI 2 "general_operand" "ri,rm,L"))) | |
8377 | (clobber (reg:CC 17))] | |
8378 | "ix86_binary_operator_ok (AND, HImode, operands)" | |
886c62d1 | 8379 | { |
e075ae69 | 8380 | switch (get_attr_type (insn)) |
886c62d1 | 8381 | { |
e075ae69 RH |
8382 | case TYPE_IMOVX: |
8383 | if (GET_CODE (operands[2]) != CONST_INT) | |
8384 | abort (); | |
8385 | if (INTVAL (operands[2]) == 0xff) | |
0f40f9f7 | 8386 | return "movz{bl|x}\t{%b1, %k0|%k0, %b1}"; |
e075ae69 | 8387 | abort (); |
886c62d1 | 8388 | |
e075ae69 RH |
8389 | default: |
8390 | if (! rtx_equal_p (operands[0], operands[1])) | |
8391 | abort (); | |
886c62d1 | 8392 | |
0f40f9f7 | 8393 | return "and{w}\t{%2, %0|%0, %2}"; |
5bc7cd8e | 8394 | } |
0f40f9f7 | 8395 | } |
6ef67412 JH |
8396 | [(set_attr "type" "alu,alu,imovx") |
8397 | (set_attr "length_immediate" "*,*,0") | |
8398 | (set_attr "mode" "HI,HI,SI")]) | |
5bc7cd8e | 8399 | |
e075ae69 | 8400 | (define_insn "*andhi_2" |
16189740 RH |
8401 | [(set (reg 17) |
8402 | (compare (and:HI (match_operand:HI 1 "nonimmediate_operand" "%0,0") | |
8403 | (match_operand:HI 2 "general_operand" "rim,ri")) | |
8404 | (const_int 0))) | |
e075ae69 RH |
8405 | (set (match_operand:HI 0 "nonimmediate_operand" "=r,rm") |
8406 | (and:HI (match_dup 1) (match_dup 2)))] | |
16189740 RH |
8407 | "ix86_match_ccmode (insn, CCNOmode) |
8408 | && ix86_binary_operator_ok (AND, HImode, operands)" | |
0f40f9f7 | 8409 | "and{w}\t{%2, %0|%0, %2}" |
6ef67412 JH |
8410 | [(set_attr "type" "alu") |
8411 | (set_attr "mode" "HI")]) | |
5bc7cd8e | 8412 | |
e075ae69 RH |
8413 | (define_expand "andqi3" |
8414 | [(set (match_operand:QI 0 "nonimmediate_operand" "") | |
8415 | (and:QI (match_operand:QI 1 "nonimmediate_operand" "") | |
8416 | (match_operand:QI 2 "general_operand" ""))) | |
8417 | (clobber (reg:CC 17))] | |
d9f32422 | 8418 | "TARGET_QIMODE_MATH" |
e075ae69 RH |
8419 | "ix86_expand_binary_operator (AND, QImode, operands); DONE;") |
8420 | ||
8421 | ;; %%% Potential partial reg stall on alternative 2. What to do? | |
8422 | (define_insn "*andqi_1" | |
7c6b971d | 8423 | [(set (match_operand:QI 0 "nonimmediate_operand" "=qm,q,r") |
e075ae69 | 8424 | (and:QI (match_operand:QI 1 "nonimmediate_operand" "%0,0,0") |
7c6b971d | 8425 | (match_operand:QI 2 "general_operand" "qi,qmi,ri"))) |
e075ae69 RH |
8426 | (clobber (reg:CC 17))] |
8427 | "ix86_binary_operator_ok (AND, QImode, operands)" | |
8428 | "@ | |
0f40f9f7 ZW |
8429 | and{b}\t{%2, %0|%0, %2} |
8430 | and{b}\t{%2, %0|%0, %2} | |
8431 | and{l}\t{%k2, %k0|%k0, %k2}" | |
6ef67412 JH |
8432 | [(set_attr "type" "alu") |
8433 | (set_attr "mode" "QI,QI,SI")]) | |
e075ae69 | 8434 | |
a1b8572c JH |
8435 | (define_insn "*andqi_1_slp" |
8436 | [(set (strict_low_part (match_operand:QI 0 "nonimmediate_operand" "+qm,q")) | |
8437 | (and:QI (match_dup 0) | |
8438 | (match_operand:QI 1 "general_operand" "qi,qmi"))) | |
8439 | (clobber (reg:CC 17))] | |
8440 | "" | |
0f40f9f7 | 8441 | "and{b}\t{%1, %0|%0, %1}" |
a1b8572c JH |
8442 | [(set_attr "type" "alu1") |
8443 | (set_attr "mode" "QI")]) | |
8444 | ||
e075ae69 | 8445 | (define_insn "*andqi_2" |
16189740 RH |
8446 | [(set (reg 17) |
8447 | (compare (and:QI | |
8448 | (match_operand:QI 1 "nonimmediate_operand" "%0,0,0") | |
8449 | (match_operand:QI 2 "general_operand" "qim,qi,i")) | |
8450 | (const_int 0))) | |
e075ae69 RH |
8451 | (set (match_operand:QI 0 "nonimmediate_operand" "=q,qm,*r") |
8452 | (and:QI (match_dup 1) (match_dup 2)))] | |
16189740 RH |
8453 | "ix86_match_ccmode (insn, CCNOmode) |
8454 | && ix86_binary_operator_ok (AND, QImode, operands)" | |
adc88131 JJ |
8455 | { |
8456 | if (which_alternative == 2) | |
8457 | { | |
8458 | if (GET_CODE (operands[2]) == CONST_INT | |
8459 | && (INTVAL (operands[2]) & 0xffffff00)) | |
8460 | operands[2] = GEN_INT (INTVAL (operands[2]) & 0xff); | |
0f40f9f7 | 8461 | return "and{l}\t{%2, %k0|%k0, %2}"; |
adc88131 | 8462 | } |
0f40f9f7 ZW |
8463 | return "and{b}\t{%2, %0|%0, %2}"; |
8464 | } | |
6ef67412 JH |
8465 | [(set_attr "type" "alu") |
8466 | (set_attr "mode" "QI,QI,SI")]) | |
e075ae69 | 8467 | |
a1b8572c JH |
8468 | (define_insn "*andqi_2_slp" |
8469 | [(set (reg 17) | |
8470 | (compare (and:QI | |
8471 | (match_operand:QI 0 "nonimmediate_operand" "+q,qm") | |
8472 | (match_operand:QI 1 "nonimmediate_operand" "qmi,qi")) | |
8473 | (const_int 0))) | |
8474 | (set (strict_low_part (match_dup 0)) | |
8475 | (and:QI (match_dup 0) (match_dup 1)))] | |
8476 | "ix86_match_ccmode (insn, CCNOmode)" | |
0f40f9f7 | 8477 | "and{b}\t{%1, %0|%0, %1}" |
a1b8572c JH |
8478 | [(set_attr "type" "alu1") |
8479 | (set_attr "mode" "QI")]) | |
8480 | ||
e075ae69 RH |
8481 | ;; ??? A bug in recog prevents it from recognizing a const_int as an |
8482 | ;; operand to zero_extend in andqi_ext_1. It was checking explicitly | |
8483 | ;; for a QImode operand, which of course failed. | |
8484 | ||
8485 | (define_insn "andqi_ext_0" | |
d2836273 | 8486 | [(set (zero_extract:SI (match_operand 0 "ext_register_operand" "=Q") |
e075ae69 RH |
8487 | (const_int 8) |
8488 | (const_int 8)) | |
8489 | (and:SI | |
8490 | (zero_extract:SI | |
8491 | (match_operand 1 "ext_register_operand" "0") | |
8492 | (const_int 8) | |
8493 | (const_int 8)) | |
8494 | (match_operand 2 "const_int_operand" "n"))) | |
8495 | (clobber (reg:CC 17))] | |
8496 | "(unsigned HOST_WIDE_INT)INTVAL (operands[2]) <= 0xff" | |
0f40f9f7 | 8497 | "and{b}\t{%2, %h0|%h0, %2}" |
6ef67412 JH |
8498 | [(set_attr "type" "alu") |
8499 | (set_attr "length_immediate" "1") | |
8500 | (set_attr "mode" "QI")]) | |
e075ae69 RH |
8501 | |
8502 | ;; Generated by peephole translating test to and. This shows up | |
8503 | ;; often in fp comparisons. | |
8504 | ||
8505 | (define_insn "*andqi_ext_0_cc" | |
16189740 RH |
8506 | [(set (reg 17) |
8507 | (compare | |
e075ae69 RH |
8508 | (and:SI |
8509 | (zero_extract:SI | |
084e679a | 8510 | (match_operand 1 "ext_register_operand" "0") |
3522082b | 8511 | (const_int 8) |
e075ae69 RH |
8512 | (const_int 8)) |
8513 | (match_operand 2 "const_int_operand" "n")) | |
8514 | (const_int 0))) | |
d2836273 | 8515 | (set (zero_extract:SI (match_operand 0 "ext_register_operand" "=Q") |
e075ae69 RH |
8516 | (const_int 8) |
8517 | (const_int 8)) | |
8518 | (and:SI | |
8519 | (zero_extract:SI | |
8520 | (match_dup 1) | |
8521 | (const_int 8) | |
8522 | (const_int 8)) | |
8523 | (match_dup 2)))] | |
16189740 RH |
8524 | "ix86_match_ccmode (insn, CCNOmode) |
8525 | && (unsigned HOST_WIDE_INT)INTVAL (operands[2]) <= 0xff" | |
0f40f9f7 | 8526 | "and{b}\t{%2, %h0|%h0, %2}" |
6ef67412 JH |
8527 | [(set_attr "type" "alu") |
8528 | (set_attr "length_immediate" "1") | |
8529 | (set_attr "mode" "QI")]) | |
e075ae69 RH |
8530 | |
8531 | (define_insn "*andqi_ext_1" | |
d2836273 | 8532 | [(set (zero_extract:SI (match_operand 0 "ext_register_operand" "=Q") |
e075ae69 RH |
8533 | (const_int 8) |
8534 | (const_int 8)) | |
8535 | (and:SI | |
8536 | (zero_extract:SI | |
8537 | (match_operand 1 "ext_register_operand" "0") | |
8538 | (const_int 8) | |
8539 | (const_int 8)) | |
8540 | (zero_extend:SI | |
d2836273 | 8541 | (match_operand:QI 2 "general_operand" "Qm")))) |
e075ae69 | 8542 | (clobber (reg:CC 17))] |
d2836273 | 8543 | "!TARGET_64BIT" |
0f40f9f7 | 8544 | "and{b}\t{%2, %h0|%h0, %2}" |
d2836273 JH |
8545 | [(set_attr "type" "alu") |
8546 | (set_attr "length_immediate" "0") | |
8547 | (set_attr "mode" "QI")]) | |
8548 | ||
8549 | (define_insn "*andqi_ext_1_rex64" | |
8550 | [(set (zero_extract:SI (match_operand 0 "ext_register_operand" "=Q") | |
8551 | (const_int 8) | |
8552 | (const_int 8)) | |
8553 | (and:SI | |
8554 | (zero_extract:SI | |
8555 | (match_operand 1 "ext_register_operand" "0") | |
8556 | (const_int 8) | |
8557 | (const_int 8)) | |
8558 | (zero_extend:SI | |
3522082b | 8559 | (match_operand 2 "ext_register_operand" "Q")))) |
d2836273 JH |
8560 | (clobber (reg:CC 17))] |
8561 | "TARGET_64BIT" | |
0f40f9f7 | 8562 | "and{b}\t{%2, %h0|%h0, %2}" |
6ef67412 JH |
8563 | [(set_attr "type" "alu") |
8564 | (set_attr "length_immediate" "0") | |
8565 | (set_attr "mode" "QI")]) | |
e075ae69 RH |
8566 | |
8567 | (define_insn "*andqi_ext_2" | |
d2836273 | 8568 | [(set (zero_extract:SI (match_operand 0 "ext_register_operand" "=Q") |
e075ae69 RH |
8569 | (const_int 8) |
8570 | (const_int 8)) | |
8571 | (and:SI | |
8572 | (zero_extract:SI | |
8573 | (match_operand 1 "ext_register_operand" "%0") | |
8574 | (const_int 8) | |
8575 | (const_int 8)) | |
8576 | (zero_extract:SI | |
d2836273 | 8577 | (match_operand 2 "ext_register_operand" "Q") |
e075ae69 RH |
8578 | (const_int 8) |
8579 | (const_int 8)))) | |
8580 | (clobber (reg:CC 17))] | |
8581 | "" | |
0f40f9f7 | 8582 | "and{b}\t{%h2, %h0|%h0, %h2}" |
6ef67412 JH |
8583 | [(set_attr "type" "alu") |
8584 | (set_attr "length_immediate" "0") | |
8585 | (set_attr "mode" "QI")]) | |
886c62d1 | 8586 | \f |
e075ae69 | 8587 | ;; Logical inclusive OR instructions |
57dbca5e | 8588 | |
e075ae69 RH |
8589 | ;; %%% This used to optimize known byte-wide and operations to memory. |
8590 | ;; If this is considered useful, it should be done with splitters. | |
8591 | ||
9b70259d JH |
8592 | (define_expand "iordi3" |
8593 | [(set (match_operand:DI 0 "nonimmediate_operand" "") | |
8594 | (ior:DI (match_operand:DI 1 "nonimmediate_operand" "") | |
8595 | (match_operand:DI 2 "x86_64_general_operand" ""))) | |
8596 | (clobber (reg:CC 17))] | |
8597 | "TARGET_64BIT" | |
8598 | "ix86_expand_binary_operator (IOR, DImode, operands); DONE;") | |
8599 | ||
8600 | (define_insn "*iordi_1_rex64" | |
8601 | [(set (match_operand:DI 0 "nonimmediate_operand" "=rm,r") | |
8602 | (ior:DI (match_operand:DI 1 "nonimmediate_operand" "%0,0") | |
8603 | (match_operand:DI 2 "x86_64_general_operand" "re,rme"))) | |
8604 | (clobber (reg:CC 17))] | |
8605 | "TARGET_64BIT | |
8606 | && ix86_binary_operator_ok (IOR, DImode, operands)" | |
0f40f9f7 | 8607 | "or{q}\t{%2, %0|%0, %2}" |
9b70259d JH |
8608 | [(set_attr "type" "alu") |
8609 | (set_attr "mode" "DI")]) | |
8610 | ||
8611 | (define_insn "*iordi_2_rex64" | |
8612 | [(set (reg 17) | |
8613 | (compare (ior:DI (match_operand:DI 1 "nonimmediate_operand" "%0,0") | |
8614 | (match_operand:DI 2 "x86_64_general_operand" "rem,re")) | |
8615 | (const_int 0))) | |
8616 | (set (match_operand:DI 0 "nonimmediate_operand" "=r,rm") | |
8617 | (ior:DI (match_dup 1) (match_dup 2)))] | |
8618 | "TARGET_64BIT | |
8619 | && ix86_match_ccmode (insn, CCNOmode) | |
8620 | && ix86_binary_operator_ok (IOR, DImode, operands)" | |
0f40f9f7 | 8621 | "or{q}\t{%2, %0|%0, %2}" |
9b70259d JH |
8622 | [(set_attr "type" "alu") |
8623 | (set_attr "mode" "DI")]) | |
8624 | ||
8625 | (define_insn "*iordi_3_rex64" | |
8626 | [(set (reg 17) | |
8627 | (compare (ior:DI (match_operand:DI 1 "nonimmediate_operand" "%0") | |
8628 | (match_operand:DI 2 "x86_64_general_operand" "rem")) | |
8629 | (const_int 0))) | |
8630 | (clobber (match_scratch:DI 0 "=r"))] | |
8631 | "TARGET_64BIT | |
8632 | && ix86_match_ccmode (insn, CCNOmode) | |
8633 | && ix86_binary_operator_ok (IOR, DImode, operands)" | |
0f40f9f7 | 8634 | "or{q}\t{%2, %0|%0, %2}" |
9b70259d JH |
8635 | [(set_attr "type" "alu") |
8636 | (set_attr "mode" "DI")]) | |
8637 | ||
8638 | ||
e075ae69 RH |
8639 | (define_expand "iorsi3" |
8640 | [(set (match_operand:SI 0 "nonimmediate_operand" "") | |
8641 | (ior:SI (match_operand:SI 1 "nonimmediate_operand" "") | |
8642 | (match_operand:SI 2 "general_operand" ""))) | |
8643 | (clobber (reg:CC 17))] | |
57dbca5e | 8644 | "" |
e075ae69 RH |
8645 | "ix86_expand_binary_operator (IOR, SImode, operands); DONE;") |
8646 | ||
8647 | (define_insn "*iorsi_1" | |
8648 | [(set (match_operand:SI 0 "nonimmediate_operand" "=rm,r") | |
8649 | (ior:SI (match_operand:SI 1 "nonimmediate_operand" "%0,0") | |
8650 | (match_operand:SI 2 "general_operand" "ri,rmi"))) | |
8651 | (clobber (reg:CC 17))] | |
8652 | "ix86_binary_operator_ok (IOR, SImode, operands)" | |
0f40f9f7 | 8653 | "or{l}\t{%2, %0|%0, %2}" |
6ef67412 JH |
8654 | [(set_attr "type" "alu") |
8655 | (set_attr "mode" "SI")]) | |
e075ae69 | 8656 | |
9b70259d JH |
8657 | ;; See comment for addsi_1_zext why we do use nonimmediate_operand |
8658 | (define_insn "*iorsi_1_zext" | |
8659 | [(set (match_operand:DI 0 "register_operand" "=rm") | |
8660 | (zero_extend:DI | |
8661 | (ior:SI (match_operand:SI 1 "nonimmediate_operand" "%0") | |
8662 | (match_operand:SI 2 "general_operand" "rim")))) | |
8663 | (clobber (reg:CC 17))] | |
8664 | "TARGET_64BIT && ix86_binary_operator_ok (IOR, SImode, operands)" | |
0f40f9f7 | 8665 | "or{l}\t{%2, %k0|%k0, %2}" |
9b70259d JH |
8666 | [(set_attr "type" "alu") |
8667 | (set_attr "mode" "SI")]) | |
8668 | ||
8669 | (define_insn "*iorsi_1_zext_imm" | |
8670 | [(set (match_operand:DI 0 "register_operand" "=rm") | |
8671 | (ior:DI (zero_extend:DI (match_operand:SI 1 "register_operand" "%0")) | |
8672 | (match_operand:DI 2 "x86_64_zext_immediate_operand" "Z"))) | |
8673 | (clobber (reg:CC 17))] | |
8674 | "TARGET_64BIT" | |
0f40f9f7 | 8675 | "or{l}\t{%2, %k0|%k0, %2}" |
9b70259d JH |
8676 | [(set_attr "type" "alu") |
8677 | (set_attr "mode" "SI")]) | |
8678 | ||
e075ae69 | 8679 | (define_insn "*iorsi_2" |
16189740 RH |
8680 | [(set (reg 17) |
8681 | (compare (ior:SI (match_operand:SI 1 "nonimmediate_operand" "%0,0") | |
8682 | (match_operand:SI 2 "general_operand" "rim,ri")) | |
8683 | (const_int 0))) | |
e075ae69 RH |
8684 | (set (match_operand:SI 0 "nonimmediate_operand" "=r,rm") |
8685 | (ior:SI (match_dup 1) (match_dup 2)))] | |
16189740 RH |
8686 | "ix86_match_ccmode (insn, CCNOmode) |
8687 | && ix86_binary_operator_ok (IOR, SImode, operands)" | |
0f40f9f7 | 8688 | "or{l}\t{%2, %0|%0, %2}" |
6ef67412 JH |
8689 | [(set_attr "type" "alu") |
8690 | (set_attr "mode" "SI")]) | |
e075ae69 | 8691 | |
9b70259d JH |
8692 | ;; See comment for addsi_1_zext why we do use nonimmediate_operand |
8693 | ;; ??? Special case for immediate operand is missing - it is tricky. | |
8694 | (define_insn "*iorsi_2_zext" | |
8695 | [(set (reg 17) | |
8696 | (compare (ior:SI (match_operand:SI 1 "nonimmediate_operand" "%0") | |
8697 | (match_operand:SI 2 "general_operand" "rim")) | |
8698 | (const_int 0))) | |
8699 | (set (match_operand:DI 0 "register_operand" "=r") | |
8700 | (zero_extend:DI (ior:SI (match_dup 1) (match_dup 2))))] | |
8701 | "TARGET_64BIT && ix86_match_ccmode (insn, CCNOmode) | |
8702 | && ix86_binary_operator_ok (IOR, SImode, operands)" | |
0f40f9f7 | 8703 | "or{l}\t{%2, %k0|%k0, %2}" |
9b70259d JH |
8704 | [(set_attr "type" "alu") |
8705 | (set_attr "mode" "SI")]) | |
8706 | ||
8707 | (define_insn "*iorsi_2_zext_imm" | |
8708 | [(set (reg 17) | |
8709 | (compare (ior:SI (match_operand:SI 1 "nonimmediate_operand" "%0") | |
8710 | (match_operand 2 "x86_64_zext_immediate_operand" "Z")) | |
8711 | (const_int 0))) | |
8712 | (set (match_operand:DI 0 "register_operand" "=r") | |
8713 | (ior:DI (zero_extend:DI (match_dup 1)) (match_dup 2)))] | |
8714 | "TARGET_64BIT && ix86_match_ccmode (insn, CCNOmode) | |
8715 | && ix86_binary_operator_ok (IOR, SImode, operands)" | |
0f40f9f7 | 8716 | "or{l}\t{%2, %k0|%k0, %2}" |
9b70259d JH |
8717 | [(set_attr "type" "alu") |
8718 | (set_attr "mode" "SI")]) | |
8719 | ||
d90ffc8d JH |
8720 | (define_insn "*iorsi_3" |
8721 | [(set (reg 17) | |
8722 | (compare (ior:SI (match_operand:SI 1 "nonimmediate_operand" "%0") | |
8723 | (match_operand:SI 2 "general_operand" "rim")) | |
8724 | (const_int 0))) | |
8725 | (clobber (match_scratch:SI 0 "=r"))] | |
8726 | "ix86_match_ccmode (insn, CCNOmode) | |
8727 | && (GET_CODE (operands[1]) != MEM || GET_CODE (operands[2]) != MEM)" | |
0f40f9f7 | 8728 | "or{l}\t{%2, %0|%0, %2}" |
d90ffc8d JH |
8729 | [(set_attr "type" "alu") |
8730 | (set_attr "mode" "SI")]) | |
8731 | ||
e075ae69 RH |
8732 | (define_expand "iorhi3" |
8733 | [(set (match_operand:HI 0 "nonimmediate_operand" "") | |
8734 | (ior:HI (match_operand:HI 1 "nonimmediate_operand" "") | |
8735 | (match_operand:HI 2 "general_operand" ""))) | |
8736 | (clobber (reg:CC 17))] | |
d9f32422 | 8737 | "TARGET_HIMODE_MATH" |
e075ae69 RH |
8738 | "ix86_expand_binary_operator (IOR, HImode, operands); DONE;") |
8739 | ||
8740 | (define_insn "*iorhi_1" | |
8741 | [(set (match_operand:HI 0 "nonimmediate_operand" "=r,m") | |
8742 | (ior:HI (match_operand:HI 1 "nonimmediate_operand" "%0,0") | |
8743 | (match_operand:HI 2 "general_operand" "rmi,ri"))) | |
8744 | (clobber (reg:CC 17))] | |
8745 | "ix86_binary_operator_ok (IOR, HImode, operands)" | |
0f40f9f7 | 8746 | "or{w}\t{%2, %0|%0, %2}" |
6ef67412 JH |
8747 | [(set_attr "type" "alu") |
8748 | (set_attr "mode" "HI")]) | |
e075ae69 | 8749 | |
e075ae69 | 8750 | (define_insn "*iorhi_2" |
16189740 RH |
8751 | [(set (reg 17) |
8752 | (compare (ior:HI (match_operand:HI 1 "nonimmediate_operand" "%0,0") | |
8753 | (match_operand:HI 2 "general_operand" "rim,ri")) | |
8754 | (const_int 0))) | |
e075ae69 RH |
8755 | (set (match_operand:HI 0 "nonimmediate_operand" "=r,rm") |
8756 | (ior:HI (match_dup 1) (match_dup 2)))] | |
16189740 RH |
8757 | "ix86_match_ccmode (insn, CCNOmode) |
8758 | && ix86_binary_operator_ok (IOR, HImode, operands)" | |
0f40f9f7 | 8759 | "or{w}\t{%2, %0|%0, %2}" |
6ef67412 JH |
8760 | [(set_attr "type" "alu") |
8761 | (set_attr "mode" "HI")]) | |
e075ae69 | 8762 | |
d90ffc8d JH |
8763 | (define_insn "*iorhi_3" |
8764 | [(set (reg 17) | |
8765 | (compare (ior:HI (match_operand:HI 1 "nonimmediate_operand" "%0") | |
8766 | (match_operand:HI 2 "general_operand" "rim")) | |
8767 | (const_int 0))) | |
8768 | (clobber (match_scratch:HI 0 "=r"))] | |
8769 | "ix86_match_ccmode (insn, CCNOmode) | |
8770 | && (GET_CODE (operands[1]) != MEM || GET_CODE (operands[2]) != MEM)" | |
0f40f9f7 | 8771 | "or{w}\t{%2, %0|%0, %2}" |
d90ffc8d JH |
8772 | [(set_attr "type" "alu") |
8773 | (set_attr "mode" "HI")]) | |
8774 | ||
e075ae69 RH |
8775 | (define_expand "iorqi3" |
8776 | [(set (match_operand:QI 0 "nonimmediate_operand" "") | |
8777 | (ior:QI (match_operand:QI 1 "nonimmediate_operand" "") | |
8778 | (match_operand:QI 2 "general_operand" ""))) | |
8779 | (clobber (reg:CC 17))] | |
d9f32422 | 8780 | "TARGET_QIMODE_MATH" |
e075ae69 RH |
8781 | "ix86_expand_binary_operator (IOR, QImode, operands); DONE;") |
8782 | ||
8783 | ;; %%% Potential partial reg stall on alternative 2. What to do? | |
8784 | (define_insn "*iorqi_1" | |
7c6b971d | 8785 | [(set (match_operand:QI 0 "nonimmediate_operand" "=q,m,r") |
e075ae69 | 8786 | (ior:QI (match_operand:QI 1 "nonimmediate_operand" "%0,0,0") |
7c6b971d | 8787 | (match_operand:QI 2 "general_operand" "qmi,qi,ri"))) |
e075ae69 RH |
8788 | (clobber (reg:CC 17))] |
8789 | "ix86_binary_operator_ok (IOR, QImode, operands)" | |
8790 | "@ | |
0f40f9f7 ZW |
8791 | or{b}\t{%2, %0|%0, %2} |
8792 | or{b}\t{%2, %0|%0, %2} | |
8793 | or{l}\t{%k2, %k0|%k0, %k2}" | |
6ef67412 | 8794 | [(set_attr "type" "alu") |
a1b8572c JH |
8795 | (set_attr "mode" "QI,QI,SI")]) |
8796 | ||
8797 | (define_insn "*iorqi_1_slp" | |
8798 | [(set (strict_low_part (match_operand:QI 0 "nonimmediate_operand" "+q,m")) | |
8799 | (ior:QI (match_dup 0) | |
8800 | (match_operand:QI 1 "general_operand" "qmi,qi"))) | |
8801 | (clobber (reg:CC 17))] | |
8802 | "" | |
0f40f9f7 | 8803 | "or{b}\t{%1, %0|%0, %1}" |
a1b8572c | 8804 | [(set_attr "type" "alu1") |
6ef67412 | 8805 | (set_attr "mode" "QI")]) |
e075ae69 RH |
8806 | |
8807 | (define_insn "*iorqi_2" | |
16189740 RH |
8808 | [(set (reg 17) |
8809 | (compare (ior:QI (match_operand:QI 1 "nonimmediate_operand" "%0,0") | |
8810 | (match_operand:QI 2 "general_operand" "qim,qi")) | |
8811 | (const_int 0))) | |
e075ae69 RH |
8812 | (set (match_operand:QI 0 "nonimmediate_operand" "=q,qm") |
8813 | (ior:QI (match_dup 1) (match_dup 2)))] | |
16189740 RH |
8814 | "ix86_match_ccmode (insn, CCNOmode) |
8815 | && ix86_binary_operator_ok (IOR, QImode, operands)" | |
0f40f9f7 | 8816 | "or{b}\t{%2, %0|%0, %2}" |
6ef67412 JH |
8817 | [(set_attr "type" "alu") |
8818 | (set_attr "mode" "QI")]) | |
d90ffc8d | 8819 | |
a1b8572c JH |
8820 | (define_insn "*iorqi_2_slp" |
8821 | [(set (reg 17) | |
8822 | (compare (ior:QI (match_operand:QI 0 "nonimmediate_operand" "+q,qm") | |
8823 | (match_operand:QI 1 "general_operand" "qim,qi")) | |
8824 | (const_int 0))) | |
8825 | (set (strict_low_part (match_dup 0)) | |
8826 | (ior:QI (match_dup 0) (match_dup 1)))] | |
8827 | "ix86_match_ccmode (insn, CCNOmode)" | |
0f40f9f7 | 8828 | "or{b}\t{%1, %0|%0, %1}" |
a1b8572c JH |
8829 | [(set_attr "type" "alu1") |
8830 | (set_attr "mode" "QI")]) | |
8831 | ||
d90ffc8d JH |
8832 | (define_insn "*iorqi_3" |
8833 | [(set (reg 17) | |
8834 | (compare (ior:QI (match_operand:QI 1 "nonimmediate_operand" "%0") | |
8835 | (match_operand:QI 2 "general_operand" "qim")) | |
8836 | (const_int 0))) | |
7e08e190 | 8837 | (clobber (match_scratch:QI 0 "=q"))] |
d90ffc8d JH |
8838 | "ix86_match_ccmode (insn, CCNOmode) |
8839 | && (GET_CODE (operands[1]) != MEM || GET_CODE (operands[2]) != MEM)" | |
0f40f9f7 | 8840 | "or{b}\t{%2, %0|%0, %2}" |
d90ffc8d JH |
8841 | [(set_attr "type" "alu") |
8842 | (set_attr "mode" "QI")]) | |
8843 | ||
e075ae69 RH |
8844 | \f |
8845 | ;; Logical XOR instructions | |
a269a03c | 8846 | |
e075ae69 RH |
8847 | ;; %%% This used to optimize known byte-wide and operations to memory. |
8848 | ;; If this is considered useful, it should be done with splitters. | |
57dbca5e | 8849 | |
9b70259d JH |
8850 | (define_expand "xordi3" |
8851 | [(set (match_operand:DI 0 "nonimmediate_operand" "") | |
8852 | (xor:DI (match_operand:DI 1 "nonimmediate_operand" "") | |
8853 | (match_operand:DI 2 "x86_64_general_operand" ""))) | |
8854 | (clobber (reg:CC 17))] | |
8855 | "TARGET_64BIT" | |
8856 | "ix86_expand_binary_operator (XOR, DImode, operands); DONE;") | |
8857 | ||
8858 | (define_insn "*xordi_1_rex64" | |
8859 | [(set (match_operand:DI 0 "nonimmediate_operand" "=rm,r") | |
8860 | (xor:DI (match_operand:DI 1 "nonimmediate_operand" "%0,0") | |
8861 | (match_operand:DI 2 "x86_64_general_operand" "re,rm"))) | |
8862 | (clobber (reg:CC 17))] | |
8863 | "TARGET_64BIT | |
8864 | && ix86_binary_operator_ok (XOR, DImode, operands)" | |
8865 | "@ | |
0f40f9f7 ZW |
8866 | xor{q}\t{%2, %0|%0, %2} |
8867 | xor{q}\t{%2, %0|%0, %2}" | |
9b70259d JH |
8868 | [(set_attr "type" "alu") |
8869 | (set_attr "mode" "DI,DI")]) | |
8870 | ||
8871 | (define_insn "*xordi_2_rex64" | |
8872 | [(set (reg 17) | |
8873 | (compare (xor:DI (match_operand:DI 1 "nonimmediate_operand" "%0,0") | |
8874 | (match_operand:DI 2 "x86_64_general_operand" "rem,re")) | |
8875 | (const_int 0))) | |
8876 | (set (match_operand:DI 0 "nonimmediate_operand" "=r,rm") | |
8877 | (xor:DI (match_dup 1) (match_dup 2)))] | |
8878 | "TARGET_64BIT | |
8879 | && ix86_match_ccmode (insn, CCNOmode) | |
8880 | && ix86_binary_operator_ok (XOR, DImode, operands)" | |
8881 | "@ | |
0f40f9f7 ZW |
8882 | xor{q}\t{%2, %0|%0, %2} |
8883 | xor{q}\t{%2, %0|%0, %2}" | |
9b70259d JH |
8884 | [(set_attr "type" "alu") |
8885 | (set_attr "mode" "DI,DI")]) | |
8886 | ||
8887 | (define_insn "*xordi_3_rex64" | |
8888 | [(set (reg 17) | |
8889 | (compare (xor:DI (match_operand:DI 1 "nonimmediate_operand" "%0") | |
8890 | (match_operand:DI 2 "x86_64_general_operand" "rem")) | |
8891 | (const_int 0))) | |
8892 | (clobber (match_scratch:DI 0 "=r"))] | |
8893 | "TARGET_64BIT | |
8894 | && ix86_match_ccmode (insn, CCNOmode) | |
8895 | && ix86_binary_operator_ok (XOR, DImode, operands)" | |
0f40f9f7 | 8896 | "xor{q}\t{%2, %0|%0, %2}" |
9b70259d JH |
8897 | [(set_attr "type" "alu") |
8898 | (set_attr "mode" "DI")]) | |
8899 | ||
e075ae69 RH |
8900 | (define_expand "xorsi3" |
8901 | [(set (match_operand:SI 0 "nonimmediate_operand" "") | |
8902 | (xor:SI (match_operand:SI 1 "nonimmediate_operand" "") | |
8903 | (match_operand:SI 2 "general_operand" ""))) | |
8904 | (clobber (reg:CC 17))] | |
57dbca5e | 8905 | "" |
e075ae69 | 8906 | "ix86_expand_binary_operator (XOR, SImode, operands); DONE;") |
a269a03c | 8907 | |
e075ae69 RH |
8908 | (define_insn "*xorsi_1" |
8909 | [(set (match_operand:SI 0 "nonimmediate_operand" "=rm,r") | |
8910 | (xor:SI (match_operand:SI 1 "nonimmediate_operand" "%0,0") | |
8911 | (match_operand:SI 2 "general_operand" "ri,rm"))) | |
8912 | (clobber (reg:CC 17))] | |
8913 | "ix86_binary_operator_ok (XOR, SImode, operands)" | |
0f40f9f7 | 8914 | "xor{l}\t{%2, %0|%0, %2}" |
6ef67412 JH |
8915 | [(set_attr "type" "alu") |
8916 | (set_attr "mode" "SI")]) | |
e075ae69 | 8917 | |
9b70259d JH |
8918 | ;; See comment for addsi_1_zext why we do use nonimmediate_operand |
8919 | ;; Add speccase for immediates | |
8920 | (define_insn "*xorsi_1_zext" | |
8921 | [(set (match_operand:DI 0 "register_operand" "=r") | |
8922 | (zero_extend:DI | |
8923 | (xor:SI (match_operand:SI 1 "nonimmediate_operand" "%0") | |
8924 | (match_operand:SI 2 "general_operand" "rim")))) | |
8925 | (clobber (reg:CC 17))] | |
8926 | "TARGET_64BIT && ix86_binary_operator_ok (XOR, SImode, operands)" | |
0f40f9f7 | 8927 | "xor{l}\t{%2, %k0|%k0, %2}" |
9b70259d JH |
8928 | [(set_attr "type" "alu") |
8929 | (set_attr "mode" "SI")]) | |
8930 | ||
8931 | (define_insn "*xorsi_1_zext_imm" | |
8932 | [(set (match_operand:DI 0 "register_operand" "=r") | |
8933 | (xor:DI (zero_extend:DI (match_operand:SI 1 "register_operand" "%0")) | |
8934 | (match_operand:DI 2 "x86_64_zext_immediate_operand" "Z"))) | |
8935 | (clobber (reg:CC 17))] | |
8936 | "TARGET_64BIT && ix86_binary_operator_ok (XOR, SImode, operands)" | |
0f40f9f7 | 8937 | "xor{l}\t{%2, %k0|%k0, %2}" |
9b70259d JH |
8938 | [(set_attr "type" "alu") |
8939 | (set_attr "mode" "SI")]) | |
8940 | ||
e075ae69 | 8941 | (define_insn "*xorsi_2" |
16189740 RH |
8942 | [(set (reg 17) |
8943 | (compare (xor:SI (match_operand:SI 1 "nonimmediate_operand" "%0,0") | |
8944 | (match_operand:SI 2 "general_operand" "rim,ri")) | |
8945 | (const_int 0))) | |
e075ae69 RH |
8946 | (set (match_operand:SI 0 "nonimmediate_operand" "=r,rm") |
8947 | (xor:SI (match_dup 1) (match_dup 2)))] | |
16189740 RH |
8948 | "ix86_match_ccmode (insn, CCNOmode) |
8949 | && ix86_binary_operator_ok (XOR, SImode, operands)" | |
0f40f9f7 | 8950 | "xor{l}\t{%2, %0|%0, %2}" |
6ef67412 JH |
8951 | [(set_attr "type" "alu") |
8952 | (set_attr "mode" "SI")]) | |
e075ae69 | 8953 | |
9b70259d JH |
8954 | ;; See comment for addsi_1_zext why we do use nonimmediate_operand |
8955 | ;; ??? Special case for immediate operand is missing - it is tricky. | |
8956 | (define_insn "*xorsi_2_zext" | |
8957 | [(set (reg 17) | |
8958 | (compare (xor:SI (match_operand:SI 1 "nonimmediate_operand" "%0") | |
8959 | (match_operand:SI 2 "general_operand" "rim")) | |
8960 | (const_int 0))) | |
8961 | (set (match_operand:DI 0 "register_operand" "=r") | |
8962 | (zero_extend:DI (xor:SI (match_dup 1) (match_dup 2))))] | |
8963 | "TARGET_64BIT && ix86_match_ccmode (insn, CCNOmode) | |
8964 | && ix86_binary_operator_ok (XOR, SImode, operands)" | |
0f40f9f7 | 8965 | "xor{l}\t{%2, %k0|%k0, %2}" |
9b70259d JH |
8966 | [(set_attr "type" "alu") |
8967 | (set_attr "mode" "SI")]) | |
8968 | ||
8969 | (define_insn "*xorsi_2_zext_imm" | |
8970 | [(set (reg 17) | |
8971 | (compare (xor:SI (match_operand:SI 1 "nonimmediate_operand" "%0") | |
8972 | (match_operand 2 "x86_64_zext_immediate_operand" "Z")) | |
8973 | (const_int 0))) | |
8974 | (set (match_operand:DI 0 "register_operand" "=r") | |
8975 | (xor:DI (zero_extend:DI (match_dup 1)) (match_dup 2)))] | |
8976 | "TARGET_64BIT && ix86_match_ccmode (insn, CCNOmode) | |
8977 | && ix86_binary_operator_ok (XOR, SImode, operands)" | |
0f40f9f7 | 8978 | "xor{l}\t{%2, %k0|%k0, %2}" |
9b70259d JH |
8979 | [(set_attr "type" "alu") |
8980 | (set_attr "mode" "SI")]) | |
8981 | ||
d90ffc8d JH |
8982 | (define_insn "*xorsi_3" |
8983 | [(set (reg 17) | |
8984 | (compare (xor:SI (match_operand:SI 1 "nonimmediate_operand" "%0") | |
8985 | (match_operand:SI 2 "general_operand" "rim")) | |
8986 | (const_int 0))) | |
8987 | (clobber (match_scratch:SI 0 "=r"))] | |
8988 | "ix86_match_ccmode (insn, CCNOmode) | |
8989 | && (GET_CODE (operands[1]) != MEM || GET_CODE (operands[2]) != MEM)" | |
0f40f9f7 | 8990 | "xor{l}\t{%2, %0|%0, %2}" |
d90ffc8d JH |
8991 | [(set_attr "type" "alu") |
8992 | (set_attr "mode" "SI")]) | |
8993 | ||
e075ae69 RH |
8994 | (define_expand "xorhi3" |
8995 | [(set (match_operand:HI 0 "nonimmediate_operand" "") | |
8996 | (xor:HI (match_operand:HI 1 "nonimmediate_operand" "") | |
8997 | (match_operand:HI 2 "general_operand" ""))) | |
8998 | (clobber (reg:CC 17))] | |
d9f32422 | 8999 | "TARGET_HIMODE_MATH" |
e075ae69 RH |
9000 | "ix86_expand_binary_operator (XOR, HImode, operands); DONE;") |
9001 | ||
9002 | (define_insn "*xorhi_1" | |
9003 | [(set (match_operand:HI 0 "nonimmediate_operand" "=r,m") | |
9004 | (xor:HI (match_operand:HI 1 "nonimmediate_operand" "%0,0") | |
9005 | (match_operand:HI 2 "general_operand" "rmi,ri"))) | |
9006 | (clobber (reg:CC 17))] | |
9007 | "ix86_binary_operator_ok (XOR, HImode, operands)" | |
0f40f9f7 | 9008 | "xor{w}\t{%2, %0|%0, %2}" |
6ef67412 JH |
9009 | [(set_attr "type" "alu") |
9010 | (set_attr "mode" "HI")]) | |
57dbca5e | 9011 | |
e075ae69 | 9012 | (define_insn "*xorhi_2" |
16189740 RH |
9013 | [(set (reg 17) |
9014 | (compare (xor:HI (match_operand:HI 1 "nonimmediate_operand" "%0,0") | |
9015 | (match_operand:HI 2 "general_operand" "rim,ri")) | |
9016 | (const_int 0))) | |
e075ae69 RH |
9017 | (set (match_operand:HI 0 "nonimmediate_operand" "=r,rm") |
9018 | (xor:HI (match_dup 1) (match_dup 2)))] | |
16189740 RH |
9019 | "ix86_match_ccmode (insn, CCNOmode) |
9020 | && ix86_binary_operator_ok (XOR, HImode, operands)" | |
0f40f9f7 | 9021 | "xor{w}\t{%2, %0|%0, %2}" |
6ef67412 JH |
9022 | [(set_attr "type" "alu") |
9023 | (set_attr "mode" "HI")]) | |
e075ae69 | 9024 | |
d90ffc8d JH |
9025 | (define_insn "*xorhi_3" |
9026 | [(set (reg 17) | |
9027 | (compare (xor:HI (match_operand:HI 1 "nonimmediate_operand" "%0") | |
9028 | (match_operand:HI 2 "general_operand" "rim")) | |
9029 | (const_int 0))) | |
9030 | (clobber (match_scratch:HI 0 "=r"))] | |
9031 | "ix86_match_ccmode (insn, CCNOmode) | |
9032 | && (GET_CODE (operands[1]) != MEM || GET_CODE (operands[2]) != MEM)" | |
0f40f9f7 | 9033 | "xor{w}\t{%2, %0|%0, %2}" |
d90ffc8d JH |
9034 | [(set_attr "type" "alu") |
9035 | (set_attr "mode" "HI")]) | |
9036 | ||
e075ae69 RH |
9037 | (define_expand "xorqi3" |
9038 | [(set (match_operand:QI 0 "nonimmediate_operand" "") | |
9039 | (xor:QI (match_operand:QI 1 "nonimmediate_operand" "") | |
9040 | (match_operand:QI 2 "general_operand" ""))) | |
9041 | (clobber (reg:CC 17))] | |
d9f32422 | 9042 | "TARGET_QIMODE_MATH" |
e075ae69 RH |
9043 | "ix86_expand_binary_operator (XOR, QImode, operands); DONE;") |
9044 | ||
9045 | ;; %%% Potential partial reg stall on alternative 2. What to do? | |
9046 | (define_insn "*xorqi_1" | |
7c6b971d | 9047 | [(set (match_operand:QI 0 "nonimmediate_operand" "=q,m,r") |
e075ae69 | 9048 | (xor:QI (match_operand:QI 1 "nonimmediate_operand" "%0,0,0") |
7c6b971d | 9049 | (match_operand:QI 2 "general_operand" "qmi,qi,ri"))) |
e075ae69 RH |
9050 | (clobber (reg:CC 17))] |
9051 | "ix86_binary_operator_ok (XOR, QImode, operands)" | |
9052 | "@ | |
0f40f9f7 ZW |
9053 | xor{b}\t{%2, %0|%0, %2} |
9054 | xor{b}\t{%2, %0|%0, %2} | |
9055 | xor{l}\t{%k2, %k0|%k0, %k2}" | |
6ef67412 JH |
9056 | [(set_attr "type" "alu") |
9057 | (set_attr "mode" "QI,QI,SI")]) | |
9058 | ||
a4414093 | 9059 | (define_insn "*xorqi_ext_1" |
d2836273 | 9060 | [(set (zero_extract:SI (match_operand 0 "ext_register_operand" "=Q") |
6ef67412 JH |
9061 | (const_int 8) |
9062 | (const_int 8)) | |
9063 | (xor:SI | |
9064 | (zero_extract:SI (match_operand 1 "ext_register_operand" "0") | |
9065 | (const_int 8) | |
9066 | (const_int 8)) | |
d2836273 | 9067 | (zero_extract:SI (match_operand 2 "ext_register_operand" "Q") |
6ef67412 JH |
9068 | (const_int 8) |
9069 | (const_int 8)))) | |
9070 | (clobber (reg:CC 17))] | |
9071 | "" | |
0f40f9f7 | 9072 | "xor{b}\t{%h2, %h0|%h0, %h2}" |
6ef67412 JH |
9073 | [(set_attr "type" "alu") |
9074 | (set_attr "length_immediate" "0") | |
9075 | (set_attr "mode" "QI")]) | |
e075ae69 | 9076 | |
7abd4e00 | 9077 | (define_insn "*xorqi_cc_1" |
16189740 RH |
9078 | [(set (reg 17) |
9079 | (compare | |
e075ae69 RH |
9080 | (xor:QI (match_operand:QI 1 "nonimmediate_operand" "%0,0") |
9081 | (match_operand:QI 2 "general_operand" "qim,qi")) | |
9082 | (const_int 0))) | |
9083 | (set (match_operand:QI 0 "nonimmediate_operand" "=q,qm") | |
9084 | (xor:QI (match_dup 1) (match_dup 2)))] | |
16189740 RH |
9085 | "ix86_match_ccmode (insn, CCNOmode) |
9086 | && ix86_binary_operator_ok (XOR, QImode, operands)" | |
0f40f9f7 | 9087 | "xor{b}\t{%2, %0|%0, %2}" |
6ef67412 JH |
9088 | [(set_attr "type" "alu") |
9089 | (set_attr "mode" "QI")]) | |
e075ae69 | 9090 | |
d90ffc8d JH |
9091 | (define_insn "*xorqi_cc_2" |
9092 | [(set (reg 17) | |
9093 | (compare | |
9094 | (xor:QI (match_operand:QI 1 "nonimmediate_operand" "%0") | |
9095 | (match_operand:QI 2 "general_operand" "qim")) | |
9096 | (const_int 0))) | |
7e08e190 | 9097 | (clobber (match_scratch:QI 0 "=q"))] |
d90ffc8d JH |
9098 | "ix86_match_ccmode (insn, CCNOmode) |
9099 | && (GET_CODE (operands[1]) != MEM || GET_CODE (operands[2]) != MEM)" | |
0f40f9f7 | 9100 | "xor{b}\t{%2, %0|%0, %2}" |
d90ffc8d JH |
9101 | [(set_attr "type" "alu") |
9102 | (set_attr "mode" "QI")]) | |
9103 | ||
9076b9c1 JH |
9104 | (define_insn "*xorqi_cc_ext_1" |
9105 | [(set (reg 17) | |
9106 | (compare | |
e075ae69 RH |
9107 | (xor:SI |
9108 | (zero_extract:SI | |
9109 | (match_operand 1 "ext_register_operand" "0") | |
9110 | (const_int 8) | |
9111 | (const_int 8)) | |
9112 | (match_operand:QI 2 "general_operand" "qmn")) | |
9113 | (const_int 0))) | |
9114 | (set (zero_extract:SI (match_operand 0 "ext_register_operand" "=q") | |
9115 | (const_int 8) | |
9116 | (const_int 8)) | |
9117 | (xor:SI | |
9118 | (zero_extract:SI (match_dup 1) (const_int 8) (const_int 8)) | |
9119 | (match_dup 2)))] | |
d2836273 | 9120 | "!TARGET_64BIT && ix86_match_ccmode (insn, CCNOmode)" |
0f40f9f7 | 9121 | "xor{b}\t{%2, %h0|%h0, %2}" |
d2836273 JH |
9122 | [(set_attr "type" "alu") |
9123 | (set_attr "mode" "QI")]) | |
9124 | ||
9125 | (define_insn "*xorqi_cc_ext_1_rex64" | |
9126 | [(set (reg 17) | |
9127 | (compare | |
9128 | (xor:SI | |
9129 | (zero_extract:SI | |
9130 | (match_operand 1 "ext_register_operand" "0") | |
9131 | (const_int 8) | |
9132 | (const_int 8)) | |
9133 | (match_operand:QI 2 "nonmemory_operand" "Qn")) | |
9134 | (const_int 0))) | |
9135 | (set (zero_extract:SI (match_operand 0 "ext_register_operand" "=Q") | |
9136 | (const_int 8) | |
9137 | (const_int 8)) | |
9138 | (xor:SI | |
9139 | (zero_extract:SI (match_dup 1) (const_int 8) (const_int 8)) | |
9140 | (match_dup 2)))] | |
9141 | "TARGET_64BIT && ix86_match_ccmode (insn, CCNOmode)" | |
0f40f9f7 | 9142 | "xor{b}\t{%2, %h0|%h0, %2}" |
6ef67412 JH |
9143 | [(set_attr "type" "alu") |
9144 | (set_attr "mode" "QI")]) | |
9076b9c1 JH |
9145 | |
9146 | (define_expand "xorqi_cc_ext_1" | |
9147 | [(parallel [ | |
9148 | (set (reg:CCNO 17) | |
9149 | (compare:CCNO | |
9150 | (xor:SI | |
9151 | (zero_extract:SI | |
9152 | (match_operand 1 "ext_register_operand" "") | |
9153 | (const_int 8) | |
9154 | (const_int 8)) | |
9155 | (match_operand:QI 2 "general_operand" "")) | |
9156 | (const_int 0))) | |
9157 | (set (zero_extract:SI (match_operand 0 "ext_register_operand" "") | |
9158 | (const_int 8) | |
9159 | (const_int 8)) | |
9160 | (xor:SI | |
9161 | (zero_extract:SI (match_dup 1) (const_int 8) (const_int 8)) | |
9162 | (match_dup 2)))])] | |
9163 | "" | |
9164 | "") | |
e075ae69 RH |
9165 | \f |
9166 | ;; Negation instructions | |
57dbca5e | 9167 | |
06a964de JH |
9168 | (define_expand "negdi2" |
9169 | [(parallel [(set (match_operand:DI 0 "nonimmediate_operand" "") | |
2756c3d8 | 9170 | (neg:DI (match_operand:DI 1 "nonimmediate_operand" ""))) |
06a964de JH |
9171 | (clobber (reg:CC 17))])] |
9172 | "" | |
9173 | "ix86_expand_unary_operator (NEG, DImode, operands); DONE;") | |
9174 | ||
9175 | (define_insn "*negdi2_1" | |
e075ae69 RH |
9176 | [(set (match_operand:DI 0 "nonimmediate_operand" "=ro") |
9177 | (neg:DI (match_operand:DI 1 "general_operand" "0"))) | |
9178 | (clobber (reg:CC 17))] | |
d2836273 JH |
9179 | "!TARGET_64BIT |
9180 | && ix86_unary_operator_ok (NEG, DImode, operands)" | |
e075ae69 | 9181 | "#") |
886c62d1 | 9182 | |
e075ae69 RH |
9183 | (define_split |
9184 | [(set (match_operand:DI 0 "nonimmediate_operand" "") | |
9185 | (neg:DI (match_operand:DI 1 "general_operand" ""))) | |
9186 | (clobber (reg:CC 17))] | |
1b0c37d7 | 9187 | "!TARGET_64BIT && reload_completed" |
e075ae69 | 9188 | [(parallel |
16189740 RH |
9189 | [(set (reg:CCZ 17) |
9190 | (compare:CCZ (neg:SI (match_dup 2)) (const_int 0))) | |
e075ae69 RH |
9191 | (set (match_dup 0) (neg:SI (match_dup 2)))]) |
9192 | (parallel | |
9193 | [(set (match_dup 1) | |
7e08e190 | 9194 | (plus:SI (plus:SI (ltu:SI (reg:CC 17) (const_int 0)) |
9dcbdc7e JH |
9195 | (match_dup 3)) |
9196 | (const_int 0))) | |
e075ae69 RH |
9197 | (clobber (reg:CC 17))]) |
9198 | (parallel | |
9199 | [(set (match_dup 1) | |
9200 | (neg:SI (match_dup 1))) | |
9201 | (clobber (reg:CC 17))])] | |
9202 | "split_di (operands+1, 1, operands+2, operands+3); | |
9203 | split_di (operands+0, 1, operands+0, operands+1);") | |
886c62d1 | 9204 | |
9b70259d JH |
9205 | (define_insn "*negdi2_1_rex64" |
9206 | [(set (match_operand:DI 0 "nonimmediate_operand" "=rm") | |
9207 | (neg:DI (match_operand:DI 1 "nonimmediate_operand" "0"))) | |
9208 | (clobber (reg:CC 17))] | |
9209 | "TARGET_64BIT && ix86_unary_operator_ok (NEG, DImode, operands)" | |
0f40f9f7 | 9210 | "neg{q}\t%0" |
9b70259d JH |
9211 | [(set_attr "type" "negnot") |
9212 | (set_attr "mode" "DI")]) | |
9213 | ||
9214 | ;; The problem with neg is that it does not perform (compare x 0), | |
9215 | ;; it really performs (compare 0 x), which leaves us with the zero | |
9216 | ;; flag being the only useful item. | |
9217 | ||
9218 | (define_insn "*negdi2_cmpz_rex64" | |
9219 | [(set (reg:CCZ 17) | |
9220 | (compare:CCZ (neg:DI (match_operand:DI 1 "nonimmediate_operand" "0")) | |
9221 | (const_int 0))) | |
9222 | (set (match_operand:DI 0 "nonimmediate_operand" "=rm") | |
9223 | (neg:DI (match_dup 1)))] | |
9224 | "TARGET_64BIT && ix86_unary_operator_ok (NEG, DImode, operands)" | |
0f40f9f7 | 9225 | "neg{q}\t%0" |
9b70259d JH |
9226 | [(set_attr "type" "negnot") |
9227 | (set_attr "mode" "DI")]) | |
9228 | ||
9229 | ||
06a964de JH |
9230 | (define_expand "negsi2" |
9231 | [(parallel [(set (match_operand:SI 0 "nonimmediate_operand" "") | |
2756c3d8 | 9232 | (neg:SI (match_operand:SI 1 "nonimmediate_operand" ""))) |
06a964de JH |
9233 | (clobber (reg:CC 17))])] |
9234 | "" | |
9235 | "ix86_expand_unary_operator (NEG, SImode, operands); DONE;") | |
9236 | ||
9237 | (define_insn "*negsi2_1" | |
2ae0f82c | 9238 | [(set (match_operand:SI 0 "nonimmediate_operand" "=rm") |
e075ae69 RH |
9239 | (neg:SI (match_operand:SI 1 "nonimmediate_operand" "0"))) |
9240 | (clobber (reg:CC 17))] | |
06a964de | 9241 | "ix86_unary_operator_ok (NEG, SImode, operands)" |
0f40f9f7 | 9242 | "neg{l}\t%0" |
6ef67412 JH |
9243 | [(set_attr "type" "negnot") |
9244 | (set_attr "mode" "SI")]) | |
e075ae69 | 9245 | |
9b70259d JH |
9246 | ;; Combine is quite creative about this pattern. |
9247 | (define_insn "*negsi2_1_zext" | |
9248 | [(set (match_operand:DI 0 "register_operand" "=r") | |
9249 | (lshiftrt:DI (neg:DI (ashift:DI (match_operand:DI 1 "register_operand" "0") | |
9250 | (const_int 32))) | |
9251 | (const_int 32))) | |
9252 | (clobber (reg:CC 17))] | |
9253 | "TARGET_64BIT && ix86_unary_operator_ok (NEG, SImode, operands)" | |
0f40f9f7 | 9254 | "neg{l}\t%k0" |
9b70259d JH |
9255 | [(set_attr "type" "negnot") |
9256 | (set_attr "mode" "SI")]) | |
9257 | ||
16189740 RH |
9258 | ;; The problem with neg is that it does not perform (compare x 0), |
9259 | ;; it really performs (compare 0 x), which leaves us with the zero | |
9260 | ;; flag being the only useful item. | |
e075ae69 | 9261 | |
16189740 RH |
9262 | (define_insn "*negsi2_cmpz" |
9263 | [(set (reg:CCZ 17) | |
9264 | (compare:CCZ (neg:SI (match_operand:SI 1 "nonimmediate_operand" "0")) | |
9265 | (const_int 0))) | |
e075ae69 RH |
9266 | (set (match_operand:SI 0 "nonimmediate_operand" "=rm") |
9267 | (neg:SI (match_dup 1)))] | |
06a964de | 9268 | "ix86_unary_operator_ok (NEG, SImode, operands)" |
0f40f9f7 | 9269 | "neg{l}\t%0" |
6ef67412 JH |
9270 | [(set_attr "type" "negnot") |
9271 | (set_attr "mode" "SI")]) | |
886c62d1 | 9272 | |
9b70259d JH |
9273 | (define_insn "*negsi2_cmpz_zext" |
9274 | [(set (reg:CCZ 17) | |
9275 | (compare:CCZ (lshiftrt:DI | |
9276 | (neg:DI (ashift:DI | |
9277 | (match_operand:DI 1 "register_operand" "0") | |
9278 | (const_int 32))) | |
9279 | (const_int 32)) | |
9280 | (const_int 0))) | |
9281 | (set (match_operand:DI 0 "register_operand" "=r") | |
9282 | (lshiftrt:DI (neg:DI (ashift:DI (match_dup 1) | |
9283 | (const_int 32))) | |
9284 | (const_int 32)))] | |
9285 | "TARGET_64BIT && ix86_unary_operator_ok (NEG, SImode, operands)" | |
0f40f9f7 | 9286 | "neg{l}\t%k0" |
9b70259d JH |
9287 | [(set_attr "type" "negnot") |
9288 | (set_attr "mode" "SI")]) | |
9289 | ||
06a964de JH |
9290 | (define_expand "neghi2" |
9291 | [(parallel [(set (match_operand:HI 0 "nonimmediate_operand" "") | |
2756c3d8 | 9292 | (neg:HI (match_operand:HI 1 "nonimmediate_operand" ""))) |
06a964de | 9293 | (clobber (reg:CC 17))])] |
d9f32422 | 9294 | "TARGET_HIMODE_MATH" |
06a964de JH |
9295 | "ix86_expand_unary_operator (NEG, HImode, operands); DONE;") |
9296 | ||
9297 | (define_insn "*neghi2_1" | |
2ae0f82c | 9298 | [(set (match_operand:HI 0 "nonimmediate_operand" "=rm") |
e075ae69 RH |
9299 | (neg:HI (match_operand:HI 1 "nonimmediate_operand" "0"))) |
9300 | (clobber (reg:CC 17))] | |
06a964de | 9301 | "ix86_unary_operator_ok (NEG, HImode, operands)" |
0f40f9f7 | 9302 | "neg{w}\t%0" |
6ef67412 JH |
9303 | [(set_attr "type" "negnot") |
9304 | (set_attr "mode" "HI")]) | |
e075ae69 | 9305 | |
16189740 RH |
9306 | (define_insn "*neghi2_cmpz" |
9307 | [(set (reg:CCZ 17) | |
9308 | (compare:CCZ (neg:HI (match_operand:HI 1 "nonimmediate_operand" "0")) | |
9309 | (const_int 0))) | |
e075ae69 RH |
9310 | (set (match_operand:HI 0 "nonimmediate_operand" "=rm") |
9311 | (neg:HI (match_dup 1)))] | |
06a964de | 9312 | "ix86_unary_operator_ok (NEG, HImode, operands)" |
0f40f9f7 | 9313 | "neg{w}\t%0" |
6ef67412 JH |
9314 | [(set_attr "type" "negnot") |
9315 | (set_attr "mode" "HI")]) | |
886c62d1 | 9316 | |
06a964de JH |
9317 | (define_expand "negqi2" |
9318 | [(parallel [(set (match_operand:QI 0 "nonimmediate_operand" "") | |
2756c3d8 | 9319 | (neg:QI (match_operand:QI 1 "nonimmediate_operand" ""))) |
06a964de | 9320 | (clobber (reg:CC 17))])] |
d9f32422 | 9321 | "TARGET_QIMODE_MATH" |
06a964de JH |
9322 | "ix86_expand_unary_operator (NEG, QImode, operands); DONE;") |
9323 | ||
9324 | (define_insn "*negqi2_1" | |
2ae0f82c | 9325 | [(set (match_operand:QI 0 "nonimmediate_operand" "=qm") |
e075ae69 RH |
9326 | (neg:QI (match_operand:QI 1 "nonimmediate_operand" "0"))) |
9327 | (clobber (reg:CC 17))] | |
06a964de | 9328 | "ix86_unary_operator_ok (NEG, QImode, operands)" |
0f40f9f7 | 9329 | "neg{b}\t%0" |
6ef67412 JH |
9330 | [(set_attr "type" "negnot") |
9331 | (set_attr "mode" "QI")]) | |
e075ae69 | 9332 | |
16189740 RH |
9333 | (define_insn "*negqi2_cmpz" |
9334 | [(set (reg:CCZ 17) | |
9335 | (compare:CCZ (neg:QI (match_operand:QI 1 "nonimmediate_operand" "0")) | |
9336 | (const_int 0))) | |
e075ae69 RH |
9337 | (set (match_operand:QI 0 "nonimmediate_operand" "=qm") |
9338 | (neg:QI (match_dup 1)))] | |
06a964de | 9339 | "ix86_unary_operator_ok (NEG, QImode, operands)" |
0f40f9f7 | 9340 | "neg{b}\t%0" |
6ef67412 JH |
9341 | [(set_attr "type" "negnot") |
9342 | (set_attr "mode" "QI")]) | |
886c62d1 | 9343 | |
06a964de | 9344 | ;; Changing of sign for FP values is doable using integer unit too. |
1ce485ec | 9345 | |
06a964de JH |
9346 | (define_expand "negsf2" |
9347 | [(parallel [(set (match_operand:SF 0 "nonimmediate_operand" "") | |
2756c3d8 | 9348 | (neg:SF (match_operand:SF 1 "nonimmediate_operand" ""))) |
06a964de JH |
9349 | (clobber (reg:CC 17))])] |
9350 | "TARGET_80387" | |
b3298882 JH |
9351 | "if (TARGET_SSE) |
9352 | { | |
9353 | /* In case operand is in memory, we will not use SSE. */ | |
9354 | if (memory_operand (operands[0], VOIDmode) | |
9355 | && rtx_equal_p (operands[0], operands[1])) | |
9356 | emit_insn (gen_negsf2_memory (operands[0], operands[1])); | |
9357 | else | |
9358 | { | |
9359 | /* Using SSE is tricky, since we need bitwise negation of -0 | |
9360 | in register. */ | |
9361 | rtx reg = gen_reg_rtx (SFmode); | |
141e454b JH |
9362 | rtx dest = operands[0]; |
9363 | ||
9364 | operands[1] = force_reg (SFmode, operands[1]); | |
9365 | operands[0] = force_reg (SFmode, operands[0]); | |
b3298882 JH |
9366 | emit_move_insn (reg, |
9367 | gen_lowpart (SFmode, | |
141e454b JH |
9368 | GEN_INT (trunc_int_for_mode (0x80000000, |
9369 | SImode)))); | |
b3298882 | 9370 | emit_insn (gen_negsf2_ifs (operands[0], operands[1], reg)); |
141e454b JH |
9371 | if (dest != operands[0]) |
9372 | emit_move_insn (dest, operands[0]); | |
b3298882 JH |
9373 | } |
9374 | DONE; | |
9375 | } | |
9376 | ix86_expand_unary_operator (NEG, SFmode, operands); DONE;") | |
9377 | ||
9378 | (define_insn "negsf2_memory" | |
9379 | [(set (match_operand:SF 0 "memory_operand" "=m") | |
9380 | (neg:SF (match_operand:SF 1 "memory_operand" "0"))) | |
9381 | (clobber (reg:CC 17))] | |
9382 | "ix86_unary_operator_ok (NEG, SFmode, operands)" | |
9383 | "#") | |
9384 | ||
9385 | (define_insn "negsf2_ifs" | |
141e454b | 9386 | [(set (match_operand:SF 0 "nonimmediate_operand" "=x#fr,x#fr,f#xr,rm#xf") |
b3298882 | 9387 | (neg:SF (match_operand:SF 1 "nonimmediate_operand" "0,x#fr,0,0"))) |
141e454b | 9388 | (use (match_operand:SF 2 "nonmemory_operand" "x,0#x,*g#x,*g#x")) |
b3298882 | 9389 | (clobber (reg:CC 17))] |
141e454b JH |
9390 | "TARGET_SSE |
9391 | && (reload_in_progress || reload_completed | |
9392 | || (register_operand (operands[0], VOIDmode) | |
9393 | && register_operand (operands[1], VOIDmode)))" | |
b3298882 JH |
9394 | "#") |
9395 | ||
9396 | (define_split | |
9397 | [(set (match_operand:SF 0 "memory_operand" "") | |
9398 | (neg:SF (match_operand:SF 1 "memory_operand" ""))) | |
9399 | (use (match_operand:SF 2 "" "")) | |
9400 | (clobber (reg:CC 17))] | |
9401 | "" | |
9402 | [(parallel [(set (match_dup 0) | |
9403 | (neg:SF (match_dup 1))) | |
9404 | (clobber (reg:CC 17))])]) | |
9405 | ||
9406 | (define_split | |
9407 | [(set (match_operand:SF 0 "register_operand" "") | |
9408 | (neg:SF (match_operand:SF 1 "register_operand" ""))) | |
9409 | (use (match_operand:SF 2 "" "")) | |
9410 | (clobber (reg:CC 17))] | |
9411 | "reload_completed && !SSE_REG_P (operands[0])" | |
9412 | [(parallel [(set (match_dup 0) | |
9413 | (neg:SF (match_dup 1))) | |
9414 | (clobber (reg:CC 17))])]) | |
9415 | ||
9416 | (define_split | |
9417 | [(set (match_operand:SF 0 "register_operand" "") | |
9418 | (neg:SF (match_operand:SF 1 "register_operand" ""))) | |
9419 | (use (match_operand:SF 2 "register_operand" "")) | |
9420 | (clobber (reg:CC 17))] | |
9421 | "reload_completed && SSE_REG_P (operands[0])" | |
9422 | [(set (subreg:TI (match_dup 0) 0) | |
9423 | (xor:TI (subreg:TI (match_dup 1) 0) | |
9424 | (subreg:TI (match_dup 2) 0)))] | |
b3298882 JH |
9425 | { |
9426 | if (operands_match_p (operands[0], operands[2])) | |
9427 | { | |
9428 | rtx tmp; | |
9429 | tmp = operands[1]; | |
9430 | operands[1] = operands[2]; | |
9431 | operands[2] = tmp; | |
9432 | } | |
0f40f9f7 | 9433 | }) |
b3298882 | 9434 | |
06a964de | 9435 | |
e20440c1 JH |
9436 | ;; Keep 'f' and 'r' in separate alternatives to avoid reload problems |
9437 | ;; because of secondary memory needed to reload from class FLOAT_INT_REGS | |
9438 | ;; to itself. | |
06a964de | 9439 | (define_insn "*negsf2_if" |
e20440c1 JH |
9440 | [(set (match_operand:SF 0 "nonimmediate_operand" "=f#r,rm#f") |
9441 | (neg:SF (match_operand:SF 1 "nonimmediate_operand" "0,0"))) | |
1ce485ec | 9442 | (clobber (reg:CC 17))] |
b3298882 JH |
9443 | "TARGET_80387 && !TARGET_SSE |
9444 | && ix86_unary_operator_ok (NEG, SFmode, operands)" | |
1ce485ec JH |
9445 | "#") |
9446 | ||
9447 | (define_split | |
9448 | [(set (match_operand:SF 0 "register_operand" "") | |
9449 | (neg:SF (match_operand:SF 1 "register_operand" ""))) | |
9450 | (clobber (reg:CC 17))] | |
9451 | "TARGET_80387 && FP_REGNO_P (REGNO (operands[0])) && reload_completed" | |
9452 | [(set (match_dup 0) | |
9453 | (neg:SF (match_dup 1)))] | |
9454 | "") | |
9455 | ||
9456 | (define_split | |
9457 | [(set (match_operand:SF 0 "register_operand" "") | |
9458 | (neg:SF (match_operand:SF 1 "register_operand" ""))) | |
9459 | (clobber (reg:CC 17))] | |
9460 | "TARGET_80387 && reload_completed && !FP_REGNO_P (REGNO (operands[0]))" | |
9461 | [(parallel [(set (match_dup 0) (xor:SI (match_dup 0) (match_dup 1))) | |
9462 | (clobber (reg:CC 17))])] | |
383252a7 | 9463 | "operands[1] = GEN_INT (trunc_int_for_mode (0x80000000, SImode)); |
1ce485ec JH |
9464 | operands[0] = gen_rtx_REG (SImode, REGNO (operands[0]));") |
9465 | ||
9466 | (define_split | |
9467 | [(set (match_operand 0 "memory_operand" "") | |
9468 | (neg (match_operand 1 "memory_operand" ""))) | |
9469 | (clobber (reg:CC 17))] | |
9470 | "TARGET_80387 && reload_completed && FLOAT_MODE_P (GET_MODE (operands[0]))" | |
9471 | [(parallel [(set (match_dup 0) (xor:QI (match_dup 0) (match_dup 1))) | |
9472 | (clobber (reg:CC 17))])] | |
1ce485ec JH |
9473 | { |
9474 | int size = GET_MODE_SIZE (GET_MODE (operands[1])); | |
9475 | ||
b3298882 JH |
9476 | /* XFmode's size is 12, TFmode 16, but only 10 bytes are used. */ |
9477 | if (size >= 12) | |
1ce485ec | 9478 | size = 10; |
b72f00af | 9479 | operands[0] = adjust_address (operands[0], QImode, size - 1); |
383252a7 | 9480 | operands[1] = GEN_INT (trunc_int_for_mode (0x80, QImode)); |
0f40f9f7 | 9481 | }) |
1ce485ec | 9482 | |
06a964de JH |
9483 | (define_expand "negdf2" |
9484 | [(parallel [(set (match_operand:DF 0 "nonimmediate_operand" "") | |
2756c3d8 | 9485 | (neg:DF (match_operand:DF 1 "nonimmediate_operand" ""))) |
06a964de JH |
9486 | (clobber (reg:CC 17))])] |
9487 | "TARGET_80387" | |
141e454b | 9488 | "if (TARGET_SSE2) |
b3298882 JH |
9489 | { |
9490 | /* In case operand is in memory, we will not use SSE. */ | |
9491 | if (memory_operand (operands[0], VOIDmode) | |
9492 | && rtx_equal_p (operands[0], operands[1])) | |
9493 | emit_insn (gen_negdf2_memory (operands[0], operands[1])); | |
9494 | else | |
9495 | { | |
9496 | /* Using SSE is tricky, since we need bitwise negation of -0 | |
9497 | in register. */ | |
9498 | rtx reg = gen_reg_rtx (DFmode); | |
9499 | #if HOST_BITS_PER_WIDE_INT >= 64 | |
141e454b JH |
9500 | rtx imm = GEN_INT (trunc_int_for_mode(((HOST_WIDE_INT)1) << 63, |
9501 | DImode)); | |
b3298882 JH |
9502 | #else |
9503 | rtx imm = immed_double_const (0, 0x80000000, DImode); | |
9504 | #endif | |
141e454b JH |
9505 | rtx dest = operands[0]; |
9506 | ||
9507 | operands[1] = force_reg (DFmode, operands[1]); | |
9508 | operands[0] = force_reg (DFmode, operands[0]); | |
b3298882 JH |
9509 | emit_move_insn (reg, gen_lowpart (DFmode, imm)); |
9510 | emit_insn (gen_negdf2_ifs (operands[0], operands[1], reg)); | |
141e454b JH |
9511 | if (dest != operands[0]) |
9512 | emit_move_insn (dest, operands[0]); | |
b3298882 JH |
9513 | } |
9514 | DONE; | |
9515 | } | |
9516 | ix86_expand_unary_operator (NEG, DFmode, operands); DONE;") | |
9517 | ||
9518 | (define_insn "negdf2_memory" | |
9519 | [(set (match_operand:DF 0 "memory_operand" "=m") | |
9520 | (neg:DF (match_operand:DF 1 "memory_operand" "0"))) | |
9521 | (clobber (reg:CC 17))] | |
9522 | "ix86_unary_operator_ok (NEG, DFmode, operands)" | |
9523 | "#") | |
9524 | ||
9525 | (define_insn "negdf2_ifs" | |
141e454b JH |
9526 | [(set (match_operand:DF 0 "nonimmediate_operand" "=Y#fr,Y#fr,f#Yr,rm#Yf") |
9527 | (neg:DF (match_operand:DF 1 "nonimmediate_operand" "0,Y#fr,0,0"))) | |
9528 | (use (match_operand:DF 2 "nonmemory_operand" "Y,0,*g#Y,*g#Y")) | |
b3298882 | 9529 | (clobber (reg:CC 17))] |
1b0c37d7 | 9530 | "!TARGET_64BIT && TARGET_SSE2 |
141e454b JH |
9531 | && (reload_in_progress || reload_completed |
9532 | || (register_operand (operands[0], VOIDmode) | |
9533 | && register_operand (operands[1], VOIDmode)))" | |
9534 | "#") | |
9535 | ||
9536 | (define_insn "*negdf2_ifs_rex64" | |
9537 | [(set (match_operand:DF 0 "nonimmediate_operand" "=Y#fr,Y#fr,fm#Yr,r#Yf") | |
9538 | (neg:DF (match_operand:DF 1 "nonimmediate_operand" "0,Y#fr,0,0"))) | |
9539 | (use (match_operand:DF 2 "general_operand" "Y,0,*g#Yr,*rm")) | |
9540 | (clobber (reg:CC 17))] | |
1b0c37d7 | 9541 | "TARGET_64BIT && TARGET_SSE2 |
141e454b JH |
9542 | && (reload_in_progress || reload_completed |
9543 | || (register_operand (operands[0], VOIDmode) | |
9544 | && register_operand (operands[1], VOIDmode)))" | |
b3298882 JH |
9545 | "#") |
9546 | ||
9547 | (define_split | |
9548 | [(set (match_operand:DF 0 "memory_operand" "") | |
9549 | (neg:DF (match_operand:DF 1 "memory_operand" ""))) | |
9550 | (use (match_operand:DF 2 "" "")) | |
9551 | (clobber (reg:CC 17))] | |
9552 | "" | |
9553 | [(parallel [(set (match_dup 0) | |
9554 | (neg:DF (match_dup 1))) | |
9555 | (clobber (reg:CC 17))])]) | |
9556 | ||
9557 | (define_split | |
9558 | [(set (match_operand:DF 0 "register_operand" "") | |
9559 | (neg:DF (match_operand:DF 1 "register_operand" ""))) | |
9560 | (use (match_operand:DF 2 "" "")) | |
9561 | (clobber (reg:CC 17))] | |
141e454b JH |
9562 | "reload_completed && !SSE_REG_P (operands[0]) |
9563 | && (!TARGET_64BIT || FP_REG_P (operands[0]))" | |
b3298882 JH |
9564 | [(parallel [(set (match_dup 0) |
9565 | (neg:DF (match_dup 1))) | |
9566 | (clobber (reg:CC 17))])]) | |
9567 | ||
141e454b JH |
9568 | (define_split |
9569 | [(set (match_operand:DF 0 "register_operand" "") | |
9570 | (neg:DF (match_operand:DF 1 "register_operand" ""))) | |
9571 | (use (match_operand:DF 2 "" "")) | |
9572 | (clobber (reg:CC 17))] | |
1b0c37d7 | 9573 | "TARGET_64BIT && reload_completed && GENERAL_REG_P (operands[0])" |
141e454b JH |
9574 | [(parallel [(set (match_dup 0) |
9575 | (xor:DI (match_dup 1) (match_dup 2))) | |
9576 | (clobber (reg:CC 17))])] | |
9577 | "operands[0] = gen_lowpart (DImode, operands[0]); | |
9578 | operands[1] = gen_lowpart (DImode, operands[1]); | |
9579 | operands[2] = gen_lowpart (DImode, operands[2]);") | |
9580 | ||
b3298882 JH |
9581 | (define_split |
9582 | [(set (match_operand:DF 0 "register_operand" "") | |
9583 | (neg:DF (match_operand:DF 1 "register_operand" ""))) | |
9584 | (use (match_operand:DF 2 "register_operand" "")) | |
9585 | (clobber (reg:CC 17))] | |
9586 | "reload_completed && SSE_REG_P (operands[0])" | |
9587 | [(set (subreg:TI (match_dup 0) 0) | |
9588 | (xor:TI (subreg:TI (match_dup 1) 0) | |
9589 | (subreg:TI (match_dup 2) 0)))] | |
b3298882 JH |
9590 | { |
9591 | if (operands_match_p (operands[0], operands[2])) | |
9592 | { | |
9593 | rtx tmp; | |
9594 | tmp = operands[1]; | |
9595 | operands[1] = operands[2]; | |
9596 | operands[2] = tmp; | |
9597 | } | |
0f40f9f7 | 9598 | }) |
06a964de | 9599 | |
e20440c1 JH |
9600 | ;; Keep 'f' and 'r' in separate alternatives to avoid reload problems |
9601 | ;; because of secondary memory needed to reload from class FLOAT_INT_REGS | |
9602 | ;; to itself. | |
06a964de | 9603 | (define_insn "*negdf2_if" |
e20440c1 JH |
9604 | [(set (match_operand:DF 0 "nonimmediate_operand" "=f#r,rm#f") |
9605 | (neg:DF (match_operand:DF 1 "nonimmediate_operand" "0,0"))) | |
1ce485ec | 9606 | (clobber (reg:CC 17))] |
1b0c37d7 | 9607 | "!TARGET_64BIT && TARGET_80387 |
141e454b JH |
9608 | && ix86_unary_operator_ok (NEG, DFmode, operands)" |
9609 | "#") | |
9610 | ||
9611 | ;; FIXME: We should to allow integer registers here. Problem is that | |
9612 | ;; we need another scratch register to get constant from. | |
9613 | ;; Forcing constant to mem if no register available in peep2 should be | |
9614 | ;; safe even for PIC mode, because of RIP relative addressing. | |
9615 | (define_insn "*negdf2_if_rex64" | |
9616 | [(set (match_operand:DF 0 "nonimmediate_operand" "=f,mf") | |
9617 | (neg:DF (match_operand:DF 1 "nonimmediate_operand" "0,0"))) | |
9618 | (clobber (reg:CC 17))] | |
1b0c37d7 | 9619 | "TARGET_64BIT && TARGET_80387 |
141e454b | 9620 | && ix86_unary_operator_ok (NEG, DFmode, operands)" |
1ce485ec JH |
9621 | "#") |
9622 | ||
9623 | (define_split | |
9624 | [(set (match_operand:DF 0 "register_operand" "") | |
9625 | (neg:DF (match_operand:DF 1 "register_operand" ""))) | |
9626 | (clobber (reg:CC 17))] | |
9627 | "TARGET_80387 && FP_REGNO_P (REGNO (operands[0])) && reload_completed" | |
9628 | [(set (match_dup 0) | |
9629 | (neg:DF (match_dup 1)))] | |
9630 | "") | |
9631 | ||
9632 | (define_split | |
9633 | [(set (match_operand:DF 0 "register_operand" "") | |
9634 | (neg:DF (match_operand:DF 1 "register_operand" ""))) | |
9635 | (clobber (reg:CC 17))] | |
1b0c37d7 ZW |
9636 | "!TARGET_64BIT && TARGET_80387 && reload_completed |
9637 | && !FP_REGNO_P (REGNO (operands[0]))" | |
1ce485ec JH |
9638 | [(parallel [(set (match_dup 3) (xor:SI (match_dup 3) (match_dup 4))) |
9639 | (clobber (reg:CC 17))])] | |
383252a7 | 9640 | "operands[4] = GEN_INT (trunc_int_for_mode (0x80000000, SImode)); |
1ce485ec JH |
9641 | split_di (operands+0, 1, operands+2, operands+3);") |
9642 | ||
06a964de JH |
9643 | (define_expand "negxf2" |
9644 | [(parallel [(set (match_operand:XF 0 "nonimmediate_operand" "") | |
2756c3d8 | 9645 | (neg:XF (match_operand:XF 1 "nonimmediate_operand" ""))) |
06a964de | 9646 | (clobber (reg:CC 17))])] |
1b0c37d7 | 9647 | "!TARGET_64BIT && TARGET_80387" |
06a964de JH |
9648 | "ix86_expand_unary_operator (NEG, XFmode, operands); DONE;") |
9649 | ||
2b589241 JH |
9650 | (define_expand "negtf2" |
9651 | [(parallel [(set (match_operand:TF 0 "nonimmediate_operand" "") | |
9652 | (neg:TF (match_operand:TF 1 "nonimmediate_operand" ""))) | |
9653 | (clobber (reg:CC 17))])] | |
9654 | "TARGET_80387" | |
9655 | "ix86_expand_unary_operator (NEG, TFmode, operands); DONE;") | |
9656 | ||
e20440c1 JH |
9657 | ;; Keep 'f' and 'r' in separate alternatives to avoid reload problems |
9658 | ;; because of secondary memory needed to reload from class FLOAT_INT_REGS | |
9659 | ;; to itself. | |
06a964de | 9660 | (define_insn "*negxf2_if" |
e20440c1 JH |
9661 | [(set (match_operand:XF 0 "nonimmediate_operand" "=f#r,rm#f") |
9662 | (neg:XF (match_operand:XF 1 "nonimmediate_operand" "0,0"))) | |
1ce485ec | 9663 | (clobber (reg:CC 17))] |
1b0c37d7 | 9664 | "!TARGET_64BIT && TARGET_80387 |
1e07edd3 | 9665 | && ix86_unary_operator_ok (NEG, XFmode, operands)" |
1ce485ec JH |
9666 | "#") |
9667 | ||
9668 | (define_split | |
9669 | [(set (match_operand:XF 0 "register_operand" "") | |
9670 | (neg:XF (match_operand:XF 1 "register_operand" ""))) | |
9671 | (clobber (reg:CC 17))] | |
9672 | "TARGET_80387 && FP_REGNO_P (REGNO (operands[0])) && reload_completed" | |
9673 | [(set (match_dup 0) | |
9674 | (neg:XF (match_dup 1)))] | |
9675 | "") | |
9676 | ||
9677 | (define_split | |
9678 | [(set (match_operand:XF 0 "register_operand" "") | |
9679 | (neg:XF (match_operand:XF 1 "register_operand" ""))) | |
9680 | (clobber (reg:CC 17))] | |
9681 | "TARGET_80387 && reload_completed && !FP_REGNO_P (REGNO (operands[0]))" | |
9682 | [(parallel [(set (match_dup 0) (xor:SI (match_dup 0) (match_dup 1))) | |
9683 | (clobber (reg:CC 17))])] | |
9684 | "operands[1] = GEN_INT (0x8000); | |
141e454b JH |
9685 | operands[0] = gen_rtx_REG (SImode, |
9686 | true_regnum (operands[0]) + (TARGET_64BIT ? 1 : 2));") | |
1ce485ec | 9687 | |
2b589241 JH |
9688 | ;; Keep 'f' and 'r' in separate alternatives to avoid reload problems |
9689 | ;; because of secondary memory needed to reload from class FLOAT_INT_REGS | |
9690 | ;; to itself. | |
9691 | (define_insn "*negtf2_if" | |
9692 | [(set (match_operand:TF 0 "nonimmediate_operand" "=f#r,rm#f") | |
9693 | (neg:TF (match_operand:TF 1 "nonimmediate_operand" "0,0"))) | |
9694 | (clobber (reg:CC 17))] | |
9695 | "TARGET_80387 && ix86_unary_operator_ok (NEG, TFmode, operands)" | |
9696 | "#") | |
9697 | ||
9698 | (define_split | |
9699 | [(set (match_operand:TF 0 "register_operand" "") | |
9700 | (neg:TF (match_operand:TF 1 "register_operand" ""))) | |
9701 | (clobber (reg:CC 17))] | |
9702 | "TARGET_80387 && FP_REGNO_P (REGNO (operands[0])) && reload_completed" | |
9703 | [(set (match_dup 0) | |
9704 | (neg:TF (match_dup 1)))] | |
9705 | "") | |
9706 | ||
9707 | (define_split | |
9708 | [(set (match_operand:TF 0 "register_operand" "") | |
9709 | (neg:TF (match_operand:TF 1 "register_operand" ""))) | |
9710 | (clobber (reg:CC 17))] | |
9711 | "TARGET_80387 && reload_completed && !FP_REGNO_P (REGNO (operands[0]))" | |
9712 | [(parallel [(set (match_dup 0) (xor:SI (match_dup 0) (match_dup 1))) | |
9713 | (clobber (reg:CC 17))])] | |
9714 | "operands[1] = GEN_INT (0x8000); | |
141e454b JH |
9715 | operands[0] = gen_rtx_REG (SImode, |
9716 | true_regnum (operands[0]) + (TARGET_64BIT ? 1 : 2));") | |
2b589241 | 9717 | |
1ce485ec JH |
9718 | ;; Conditionize these after reload. If they matches before reload, we |
9719 | ;; lose the clobber and ability to use integer instructions. | |
9720 | ||
9721 | (define_insn "*negsf2_1" | |
886c62d1 | 9722 | [(set (match_operand:SF 0 "register_operand" "=f") |
2ae0f82c | 9723 | (neg:SF (match_operand:SF 1 "register_operand" "0")))] |
1ce485ec | 9724 | "TARGET_80387 && reload_completed" |
10195bd8 | 9725 | "fchs" |
e075ae69 | 9726 | [(set_attr "type" "fsgn") |
6ef67412 | 9727 | (set_attr "mode" "SF") |
e075ae69 | 9728 | (set_attr "ppro_uops" "few")]) |
886c62d1 | 9729 | |
1ce485ec | 9730 | (define_insn "*negdf2_1" |
886c62d1 | 9731 | [(set (match_operand:DF 0 "register_operand" "=f") |
2ae0f82c | 9732 | (neg:DF (match_operand:DF 1 "register_operand" "0")))] |
1ce485ec | 9733 | "TARGET_80387 && reload_completed" |
10195bd8 | 9734 | "fchs" |
e075ae69 | 9735 | [(set_attr "type" "fsgn") |
6ef67412 | 9736 | (set_attr "mode" "DF") |
e075ae69 | 9737 | (set_attr "ppro_uops" "few")]) |
886c62d1 | 9738 | |
6343a50e | 9739 | (define_insn "*negextendsfdf2" |
886c62d1 | 9740 | [(set (match_operand:DF 0 "register_operand" "=f") |
e075ae69 RH |
9741 | (neg:DF (float_extend:DF |
9742 | (match_operand:SF 1 "register_operand" "0"))))] | |
886c62d1 | 9743 | "TARGET_80387" |
10195bd8 | 9744 | "fchs" |
e075ae69 | 9745 | [(set_attr "type" "fsgn") |
6ef67412 | 9746 | (set_attr "mode" "DF") |
e075ae69 | 9747 | (set_attr "ppro_uops" "few")]) |
4fb21e90 | 9748 | |
1ce485ec | 9749 | (define_insn "*negxf2_1" |
4fb21e90 | 9750 | [(set (match_operand:XF 0 "register_operand" "=f") |
2ae0f82c | 9751 | (neg:XF (match_operand:XF 1 "register_operand" "0")))] |
1b0c37d7 | 9752 | "!TARGET_64BIT && TARGET_80387 && reload_completed" |
10195bd8 | 9753 | "fchs" |
e075ae69 | 9754 | [(set_attr "type" "fsgn") |
6ef67412 | 9755 | (set_attr "mode" "XF") |
e075ae69 RH |
9756 | (set_attr "ppro_uops" "few")]) |
9757 | ||
6343a50e | 9758 | (define_insn "*negextenddfxf2" |
e075ae69 RH |
9759 | [(set (match_operand:XF 0 "register_operand" "=f") |
9760 | (neg:XF (float_extend:XF | |
9761 | (match_operand:DF 1 "register_operand" "0"))))] | |
1b0c37d7 | 9762 | "!TARGET_64BIT && TARGET_80387" |
e075ae69 RH |
9763 | "fchs" |
9764 | [(set_attr "type" "fsgn") | |
6ef67412 | 9765 | (set_attr "mode" "XF") |
e075ae69 | 9766 | (set_attr "ppro_uops" "few")]) |
4fb21e90 | 9767 | |
6343a50e | 9768 | (define_insn "*negextendsfxf2" |
4fb21e90 | 9769 | [(set (match_operand:XF 0 "register_operand" "=f") |
e075ae69 RH |
9770 | (neg:XF (float_extend:XF |
9771 | (match_operand:SF 1 "register_operand" "0"))))] | |
1b0c37d7 | 9772 | "!TARGET_64BIT && TARGET_80387" |
10195bd8 | 9773 | "fchs" |
e075ae69 | 9774 | [(set_attr "type" "fsgn") |
6ef67412 | 9775 | (set_attr "mode" "XF") |
e075ae69 | 9776 | (set_attr "ppro_uops" "few")]) |
2b589241 JH |
9777 | |
9778 | (define_insn "*negtf2_1" | |
9779 | [(set (match_operand:TF 0 "register_operand" "=f") | |
9780 | (neg:TF (match_operand:TF 1 "register_operand" "0")))] | |
9781 | "TARGET_80387 && reload_completed" | |
9782 | "fchs" | |
9783 | [(set_attr "type" "fsgn") | |
9784 | (set_attr "mode" "XF") | |
9785 | (set_attr "ppro_uops" "few")]) | |
9786 | ||
9787 | (define_insn "*negextenddftf2" | |
9788 | [(set (match_operand:TF 0 "register_operand" "=f") | |
9789 | (neg:TF (float_extend:TF | |
9790 | (match_operand:DF 1 "register_operand" "0"))))] | |
9791 | "TARGET_80387" | |
9792 | "fchs" | |
9793 | [(set_attr "type" "fsgn") | |
9794 | (set_attr "mode" "XF") | |
9795 | (set_attr "ppro_uops" "few")]) | |
9796 | ||
9797 | (define_insn "*negextendsftf2" | |
9798 | [(set (match_operand:TF 0 "register_operand" "=f") | |
9799 | (neg:TF (float_extend:TF | |
9800 | (match_operand:SF 1 "register_operand" "0"))))] | |
9801 | "TARGET_80387" | |
9802 | "fchs" | |
9803 | [(set_attr "type" "fsgn") | |
9804 | (set_attr "mode" "XF") | |
9805 | (set_attr "ppro_uops" "few")]) | |
886c62d1 JVA |
9806 | \f |
9807 | ;; Absolute value instructions | |
9808 | ||
06a964de JH |
9809 | (define_expand "abssf2" |
9810 | [(parallel [(set (match_operand:SF 0 "nonimmediate_operand" "") | |
2756c3d8 | 9811 | (neg:SF (match_operand:SF 1 "nonimmediate_operand" ""))) |
06a964de JH |
9812 | (clobber (reg:CC 17))])] |
9813 | "TARGET_80387" | |
ca29d1dc JH |
9814 | "if (TARGET_SSE) |
9815 | { | |
9816 | /* In case operand is in memory, we will not use SSE. */ | |
9817 | if (memory_operand (operands[0], VOIDmode) | |
9818 | && rtx_equal_p (operands[0], operands[1])) | |
9819 | emit_insn (gen_abssf2_memory (operands[0], operands[1])); | |
9820 | else | |
9821 | { | |
9822 | /* Using SSE is tricky, since we need bitwise negation of -0 | |
9823 | in register. */ | |
9824 | rtx reg = gen_reg_rtx (SFmode); | |
141e454b JH |
9825 | rtx dest = operands[0]; |
9826 | ||
9827 | operands[1] = force_reg (SFmode, operands[1]); | |
9828 | operands[0] = force_reg (SFmode, operands[0]); | |
9829 | emit_move_insn (reg, | |
9830 | gen_lowpart (SFmode, | |
9831 | GEN_INT (trunc_int_for_mode (0x80000000, | |
9832 | SImode)))); | |
ca29d1dc | 9833 | emit_insn (gen_abssf2_ifs (operands[0], operands[1], reg)); |
141e454b JH |
9834 | if (dest != operands[0]) |
9835 | emit_move_insn (dest, operands[0]); | |
ca29d1dc JH |
9836 | } |
9837 | DONE; | |
9838 | } | |
9839 | ix86_expand_unary_operator (ABS, SFmode, operands); DONE;") | |
9840 | ||
9841 | (define_insn "abssf2_memory" | |
9842 | [(set (match_operand:SF 0 "memory_operand" "=m") | |
9843 | (abs:SF (match_operand:SF 1 "memory_operand" "0"))) | |
9844 | (clobber (reg:CC 17))] | |
9845 | "ix86_unary_operator_ok (ABS, SFmode, operands)" | |
9846 | "#") | |
9847 | ||
9848 | (define_insn "abssf2_ifs" | |
141e454b | 9849 | [(set (match_operand:SF 0 "nonimmediate_operand" "=x#fr,f#xr,rm#xf") |
ca29d1dc | 9850 | (abs:SF (match_operand:SF 1 "nonimmediate_operand" "x,0,0"))) |
141e454b | 9851 | (use (match_operand:SF 2 "nonmemory_operand" "*0#x,*g#x,*g#x")) |
ca29d1dc | 9852 | (clobber (reg:CC 17))] |
141e454b JH |
9853 | "TARGET_SSE |
9854 | && (reload_in_progress || reload_completed | |
9855 | || (register_operand (operands[0], VOIDmode) | |
9856 | && register_operand (operands[1], VOIDmode)))" | |
ca29d1dc JH |
9857 | "#") |
9858 | ||
9859 | (define_split | |
9860 | [(set (match_operand:SF 0 "memory_operand" "") | |
9861 | (abs:SF (match_operand:SF 1 "memory_operand" ""))) | |
9862 | (use (match_operand:SF 2 "" "")) | |
9863 | (clobber (reg:CC 17))] | |
9864 | "" | |
9865 | [(parallel [(set (match_dup 0) | |
9866 | (abs:SF (match_dup 1))) | |
9867 | (clobber (reg:CC 17))])]) | |
9868 | ||
9869 | (define_split | |
9870 | [(set (match_operand:SF 0 "register_operand" "") | |
9871 | (abs:SF (match_operand:SF 1 "register_operand" ""))) | |
9872 | (use (match_operand:SF 2 "" "")) | |
9873 | (clobber (reg:CC 17))] | |
9874 | "reload_completed && !SSE_REG_P (operands[0])" | |
9875 | [(parallel [(set (match_dup 0) | |
9876 | (abs:SF (match_dup 1))) | |
9877 | (clobber (reg:CC 17))])]) | |
9878 | ||
9879 | (define_split | |
9880 | [(set (match_operand:SF 0 "register_operand" "") | |
9881 | (abs:SF (match_operand:SF 1 "register_operand" ""))) | |
9882 | (use (match_operand:SF 2 "register_operand" "")) | |
9883 | (clobber (reg:CC 17))] | |
9884 | "reload_completed && SSE_REG_P (operands[0])" | |
9885 | [(set (subreg:TI (match_dup 0) 0) | |
9886 | (and:TI (not:TI (subreg:TI (match_dup 2) 0)) | |
9887 | (subreg:TI (match_dup 1) 0)))]) | |
06a964de | 9888 | |
e20440c1 JH |
9889 | ;; Keep 'f' and 'r' in separate alternatives to avoid reload problems |
9890 | ;; because of secondary memory needed to reload from class FLOAT_INT_REGS | |
9891 | ;; to itself. | |
06a964de | 9892 | (define_insn "*abssf2_if" |
e20440c1 JH |
9893 | [(set (match_operand:SF 0 "nonimmediate_operand" "=f#r,rm#f") |
9894 | (abs:SF (match_operand:SF 1 "nonimmediate_operand" "0,0"))) | |
1ce485ec | 9895 | (clobber (reg:CC 17))] |
ca29d1dc | 9896 | "TARGET_80387 && ix86_unary_operator_ok (ABS, SFmode, operands) && !TARGET_SSE" |
1ce485ec JH |
9897 | "#") |
9898 | ||
9899 | (define_split | |
9900 | [(set (match_operand:SF 0 "register_operand" "") | |
9901 | (abs:SF (match_operand:SF 1 "register_operand" ""))) | |
9902 | (clobber (reg:CC 17))] | |
9903 | "TARGET_80387 && FP_REGNO_P (REGNO (operands[0]))" | |
9904 | [(set (match_dup 0) | |
9905 | (abs:SF (match_dup 1)))] | |
9906 | "") | |
9907 | ||
9908 | (define_split | |
9909 | [(set (match_operand:SF 0 "register_operand" "") | |
9910 | (abs:SF (match_operand:SF 1 "register_operand" ""))) | |
9911 | (clobber (reg:CC 17))] | |
9912 | "TARGET_80387 && reload_completed && !FP_REGNO_P (REGNO (operands[0]))" | |
9913 | [(parallel [(set (match_dup 0) (and:SI (match_dup 0) (match_dup 1))) | |
9914 | (clobber (reg:CC 17))])] | |
383252a7 | 9915 | "operands[1] = GEN_INT (trunc_int_for_mode (~0x80000000, SImode)); |
1ce485ec JH |
9916 | operands[0] = gen_rtx_REG (SImode, REGNO (operands[0]));") |
9917 | ||
9918 | (define_split | |
9919 | [(set (match_operand 0 "memory_operand" "") | |
9920 | (abs (match_operand 1 "memory_operand" ""))) | |
9921 | (clobber (reg:CC 17))] | |
9922 | "TARGET_80387 && reload_completed && FLOAT_MODE_P (GET_MODE (operands[0]))" | |
9923 | [(parallel [(set (match_dup 0) (and:QI (match_dup 0) (match_dup 1))) | |
9924 | (clobber (reg:CC 17))])] | |
1ce485ec JH |
9925 | { |
9926 | int size = GET_MODE_SIZE (GET_MODE (operands[1])); | |
9927 | ||
b3298882 JH |
9928 | /* XFmode's size is 12, TFmode 16, but only 10 bytes are used. */ |
9929 | if (size >= 12) | |
1ce485ec | 9930 | size = 10; |
b72f00af | 9931 | operands[0] = adjust_address (operands[0], QImode, size - 1); |
383252a7 | 9932 | operands[1] = GEN_INT (trunc_int_for_mode (~0x80, QImode)); |
0f40f9f7 | 9933 | }) |
1ce485ec | 9934 | |
06a964de JH |
9935 | (define_expand "absdf2" |
9936 | [(parallel [(set (match_operand:DF 0 "nonimmediate_operand" "") | |
2756c3d8 | 9937 | (neg:DF (match_operand:DF 1 "nonimmediate_operand" ""))) |
06a964de | 9938 | (clobber (reg:CC 17))])] |
1ce485ec | 9939 | "TARGET_80387" |
ca29d1dc JH |
9940 | "if (TARGET_SSE2) |
9941 | { | |
9942 | /* In case operand is in memory, we will not use SSE. */ | |
9943 | if (memory_operand (operands[0], VOIDmode) | |
9944 | && rtx_equal_p (operands[0], operands[1])) | |
9945 | emit_insn (gen_absdf2_memory (operands[0], operands[1])); | |
9946 | else | |
9947 | { | |
9948 | /* Using SSE is tricky, since we need bitwise negation of -0 | |
9949 | in register. */ | |
9950 | rtx reg = gen_reg_rtx (DFmode); | |
9951 | #if HOST_BITS_PER_WIDE_INT >= 64 | |
141e454b JH |
9952 | rtx imm = GEN_INT (trunc_int_for_mode(((HOST_WIDE_INT)1) << 63, |
9953 | DImode)); | |
ca29d1dc JH |
9954 | #else |
9955 | rtx imm = immed_double_const (0, 0x80000000, DImode); | |
9956 | #endif | |
141e454b JH |
9957 | rtx dest = operands[0]; |
9958 | ||
9959 | operands[1] = force_reg (DFmode, operands[1]); | |
9960 | operands[0] = force_reg (DFmode, operands[0]); | |
ca29d1dc JH |
9961 | emit_move_insn (reg, gen_lowpart (DFmode, imm)); |
9962 | emit_insn (gen_absdf2_ifs (operands[0], operands[1], reg)); | |
141e454b JH |
9963 | if (dest != operands[0]) |
9964 | emit_move_insn (dest, operands[0]); | |
ca29d1dc JH |
9965 | } |
9966 | DONE; | |
9967 | } | |
9968 | ix86_expand_unary_operator (ABS, DFmode, operands); DONE;") | |
9969 | ||
9970 | (define_insn "absdf2_memory" | |
9971 | [(set (match_operand:DF 0 "memory_operand" "=m") | |
9972 | (abs:DF (match_operand:DF 1 "memory_operand" "0"))) | |
9973 | (clobber (reg:CC 17))] | |
9974 | "ix86_unary_operator_ok (ABS, DFmode, operands)" | |
9975 | "#") | |
9976 | ||
9977 | (define_insn "absdf2_ifs" | |
141e454b | 9978 | [(set (match_operand:DF 0 "nonimmediate_operand" "=Y#fr,mf#Yr,mr#Yf") |
ca29d1dc | 9979 | (abs:DF (match_operand:DF 1 "nonimmediate_operand" "Y,0,0"))) |
141e454b | 9980 | (use (match_operand:DF 2 "nonmemory_operand" "*0#Y,*g#Y,*g#Y")) |
ca29d1dc | 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 "*absdf2_ifs_rex64" | |
9989 | [(set (match_operand:DF 0 "nonimmediate_operand" "=Y#fr,mf#Yr") | |
9990 | (abs:DF (match_operand:DF 1 "nonimmediate_operand" "Y,0"))) | |
9991 | (use (match_operand:DF 2 "nonmemory_operand" "*0#Y,*g#Y")) | |
9992 | (clobber (reg:CC 17))] | |
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)))" | |
ca29d1dc JH |
9997 | "#") |
9998 | ||
9999 | (define_split | |
10000 | [(set (match_operand:DF 0 "memory_operand" "") | |
10001 | (abs:DF (match_operand:DF 1 "memory_operand" ""))) | |
10002 | (use (match_operand:DF 2 "" "")) | |
10003 | (clobber (reg:CC 17))] | |
10004 | "" | |
10005 | [(parallel [(set (match_dup 0) | |
10006 | (abs:DF (match_dup 1))) | |
10007 | (clobber (reg:CC 17))])]) | |
10008 | ||
10009 | (define_split | |
10010 | [(set (match_operand:DF 0 "register_operand" "") | |
10011 | (abs:DF (match_operand:DF 1 "register_operand" ""))) | |
10012 | (use (match_operand:DF 2 "" "")) | |
10013 | (clobber (reg:CC 17))] | |
10014 | "reload_completed && !SSE_REG_P (operands[0])" | |
10015 | [(parallel [(set (match_dup 0) | |
10016 | (abs:DF (match_dup 1))) | |
10017 | (clobber (reg:CC 17))])]) | |
10018 | ||
10019 | (define_split | |
10020 | [(set (match_operand:DF 0 "register_operand" "") | |
10021 | (abs:DF (match_operand:DF 1 "register_operand" ""))) | |
10022 | (use (match_operand:DF 2 "register_operand" "")) | |
10023 | (clobber (reg:CC 17))] | |
10024 | "reload_completed && SSE_REG_P (operands[0])" | |
10025 | [(set (subreg:TI (match_dup 0) 0) | |
10026 | (and:TI (not:TI (subreg:TI (match_dup 2) 0)) | |
10027 | (subreg:TI (match_dup 1) 0)))]) | |
10028 | ||
06a964de | 10029 | |
e20440c1 JH |
10030 | ;; Keep 'f' and 'r' in separate alternatives to avoid reload problems |
10031 | ;; because of secondary memory needed to reload from class FLOAT_INT_REGS | |
10032 | ;; to itself. | |
06a964de | 10033 | (define_insn "*absdf2_if" |
e20440c1 JH |
10034 | [(set (match_operand:DF 0 "nonimmediate_operand" "=f#r,rm#f") |
10035 | (abs:DF (match_operand:DF 1 "nonimmediate_operand" "0,0"))) | |
06a964de | 10036 | (clobber (reg:CC 17))] |
1b0c37d7 | 10037 | "!TARGET_64BIT && TARGET_80387 |
141e454b JH |
10038 | && ix86_unary_operator_ok (ABS, DFmode, operands)" |
10039 | "#") | |
10040 | ||
10041 | ;; FIXME: We should to allow integer registers here. Problem is that | |
10042 | ;; we need another scratch register to get constant from. | |
10043 | ;; Forcing constant to mem if no register available in peep2 should be | |
10044 | ;; safe even for PIC mode, because of RIP relative addressing. | |
10045 | (define_insn "*absdf2_if_rex64" | |
10046 | [(set (match_operand:DF 0 "nonimmediate_operand" "=f,mf") | |
10047 | (abs:DF (match_operand:DF 1 "nonimmediate_operand" "0,0"))) | |
10048 | (clobber (reg:CC 17))] | |
1b0c37d7 | 10049 | "TARGET_64BIT && TARGET_80387 |
141e454b | 10050 | && ix86_unary_operator_ok (ABS, DFmode, operands)" |
1ce485ec JH |
10051 | "#") |
10052 | ||
10053 | (define_split | |
10054 | [(set (match_operand:DF 0 "register_operand" "") | |
10055 | (abs:DF (match_operand:DF 1 "register_operand" ""))) | |
10056 | (clobber (reg:CC 17))] | |
10057 | "TARGET_80387 && FP_REGNO_P (REGNO (operands[0])) && reload_completed" | |
10058 | [(set (match_dup 0) | |
10059 | (abs:DF (match_dup 1)))] | |
10060 | "") | |
10061 | ||
10062 | (define_split | |
10063 | [(set (match_operand:DF 0 "register_operand" "") | |
10064 | (abs:DF (match_operand:DF 1 "register_operand" ""))) | |
10065 | (clobber (reg:CC 17))] | |
1b0c37d7 ZW |
10066 | "!TARGET_64BIT && TARGET_80387 && reload_completed && |
10067 | !FP_REGNO_P (REGNO (operands[0]))" | |
1ce485ec JH |
10068 | [(parallel [(set (match_dup 3) (and:SI (match_dup 3) (match_dup 4))) |
10069 | (clobber (reg:CC 17))])] | |
383252a7 | 10070 | "operands[4] = GEN_INT (trunc_int_for_mode (~0x80000000, SImode)); |
1ce485ec JH |
10071 | split_di (operands+0, 1, operands+2, operands+3);") |
10072 | ||
06a964de JH |
10073 | (define_expand "absxf2" |
10074 | [(parallel [(set (match_operand:XF 0 "nonimmediate_operand" "") | |
2756c3d8 | 10075 | (neg:XF (match_operand:XF 1 "nonimmediate_operand" ""))) |
06a964de | 10076 | (clobber (reg:CC 17))])] |
1b0c37d7 | 10077 | "!TARGET_64BIT && TARGET_80387" |
06a964de JH |
10078 | "ix86_expand_unary_operator (ABS, XFmode, operands); DONE;") |
10079 | ||
2b589241 JH |
10080 | (define_expand "abstf2" |
10081 | [(parallel [(set (match_operand:TF 0 "nonimmediate_operand" "") | |
10082 | (neg:TF (match_operand:TF 1 "nonimmediate_operand" ""))) | |
10083 | (clobber (reg:CC 17))])] | |
10084 | "TARGET_80387" | |
10085 | "ix86_expand_unary_operator (ABS, TFmode, operands); DONE;") | |
10086 | ||
e20440c1 JH |
10087 | ;; Keep 'f' and 'r' in separate alternatives to avoid reload problems |
10088 | ;; because of secondary memory needed to reload from class FLOAT_INT_REGS | |
10089 | ;; to itself. | |
06a964de | 10090 | (define_insn "*absxf2_if" |
e20440c1 JH |
10091 | [(set (match_operand:XF 0 "nonimmediate_operand" "=f#r,rm#f") |
10092 | (abs:XF (match_operand:XF 1 "nonimmediate_operand" "0,0"))) | |
1ce485ec | 10093 | (clobber (reg:CC 17))] |
1b0c37d7 | 10094 | "!TARGET_64BIT && TARGET_80387 |
1e07edd3 | 10095 | && ix86_unary_operator_ok (ABS, XFmode, operands)" |
1ce485ec JH |
10096 | "#") |
10097 | ||
10098 | (define_split | |
10099 | [(set (match_operand:XF 0 "register_operand" "") | |
10100 | (abs:XF (match_operand:XF 1 "register_operand" ""))) | |
10101 | (clobber (reg:CC 17))] | |
10102 | "TARGET_80387 && FP_REGNO_P (REGNO (operands[0])) && reload_completed" | |
10103 | [(set (match_dup 0) | |
10104 | (abs:XF (match_dup 1)))] | |
10105 | "") | |
10106 | ||
10107 | (define_split | |
10108 | [(set (match_operand:XF 0 "register_operand" "") | |
10109 | (abs:XF (match_operand:XF 1 "register_operand" ""))) | |
10110 | (clobber (reg:CC 17))] | |
10111 | "TARGET_80387 && reload_completed && !FP_REGNO_P (REGNO (operands[0]))" | |
10112 | [(parallel [(set (match_dup 0) (and:SI (match_dup 0) (match_dup 1))) | |
10113 | (clobber (reg:CC 17))])] | |
141e454b JH |
10114 | "operands[1] = GEN_INT (~0x8000); |
10115 | operands[0] = gen_rtx_REG (SImode, | |
10116 | true_regnum (operands[0]) + (TARGET_64BIT ? 1 : 2));") | |
1ce485ec | 10117 | |
2b589241 JH |
10118 | (define_insn "*abstf2_if" |
10119 | [(set (match_operand:TF 0 "nonimmediate_operand" "=f#r,rm#f") | |
10120 | (abs:TF (match_operand:TF 1 "nonimmediate_operand" "0,0"))) | |
10121 | (clobber (reg:CC 17))] | |
10122 | "TARGET_80387 && ix86_unary_operator_ok (ABS, TFmode, operands)" | |
10123 | "#") | |
10124 | ||
10125 | (define_split | |
10126 | [(set (match_operand:TF 0 "register_operand" "") | |
10127 | (abs:TF (match_operand:TF 1 "register_operand" ""))) | |
10128 | (clobber (reg:CC 17))] | |
10129 | "TARGET_80387 && FP_REGNO_P (REGNO (operands[0])) && reload_completed" | |
10130 | [(set (match_dup 0) | |
10131 | (abs:TF (match_dup 1)))] | |
10132 | "") | |
10133 | ||
10134 | (define_split | |
10135 | [(set (match_operand:TF 0 "register_operand" "") | |
10136 | (abs:TF (match_operand:TF 1 "register_operand" ""))) | |
10137 | (clobber (reg:CC 17))] | |
10138 | "TARGET_80387 && reload_completed && !FP_REGNO_P (REGNO (operands[0]))" | |
10139 | [(parallel [(set (match_dup 0) (and:SI (match_dup 0) (match_dup 1))) | |
10140 | (clobber (reg:CC 17))])] | |
141e454b JH |
10141 | "operands[1] = GEN_INT (~0x8000); |
10142 | operands[0] = gen_rtx_REG (SImode, | |
10143 | true_regnum (operands[0]) + (TARGET_64BIT ? 1 : 2));") | |
2b589241 | 10144 | |
1ce485ec | 10145 | (define_insn "*abssf2_1" |
886c62d1 | 10146 | [(set (match_operand:SF 0 "register_operand" "=f") |
2ae0f82c | 10147 | (abs:SF (match_operand:SF 1 "register_operand" "0")))] |
1ce485ec | 10148 | "TARGET_80387 && reload_completed" |
2ae0f82c | 10149 | "fabs" |
6ef67412 JH |
10150 | [(set_attr "type" "fsgn") |
10151 | (set_attr "mode" "SF")]) | |
886c62d1 | 10152 | |
1ce485ec | 10153 | (define_insn "*absdf2_1" |
886c62d1 | 10154 | [(set (match_operand:DF 0 "register_operand" "=f") |
2ae0f82c | 10155 | (abs:DF (match_operand:DF 1 "register_operand" "0")))] |
1ce485ec | 10156 | "TARGET_80387 && reload_completed" |
2ae0f82c | 10157 | "fabs" |
6ef67412 JH |
10158 | [(set_attr "type" "fsgn") |
10159 | (set_attr "mode" "DF")]) | |
886c62d1 | 10160 | |
6343a50e | 10161 | (define_insn "*absextendsfdf2" |
886c62d1 | 10162 | [(set (match_operand:DF 0 "register_operand" "=f") |
e075ae69 RH |
10163 | (abs:DF (float_extend:DF |
10164 | (match_operand:SF 1 "register_operand" "0"))))] | |
886c62d1 | 10165 | "TARGET_80387" |
2ae0f82c | 10166 | "fabs" |
6ef67412 JH |
10167 | [(set_attr "type" "fsgn") |
10168 | (set_attr "mode" "DF")]) | |
886c62d1 | 10169 | |
1ce485ec | 10170 | (define_insn "*absxf2_1" |
4fb21e90 | 10171 | [(set (match_operand:XF 0 "register_operand" "=f") |
2ae0f82c | 10172 | (abs:XF (match_operand:XF 1 "register_operand" "0")))] |
1b0c37d7 | 10173 | "!TARGET_64BIT && TARGET_80387 && reload_completed" |
2ae0f82c | 10174 | "fabs" |
6ef67412 JH |
10175 | [(set_attr "type" "fsgn") |
10176 | (set_attr "mode" "DF")]) | |
4fb21e90 | 10177 | |
6343a50e | 10178 | (define_insn "*absextenddfxf2" |
4fb21e90 | 10179 | [(set (match_operand:XF 0 "register_operand" "=f") |
e075ae69 RH |
10180 | (abs:XF (float_extend:XF |
10181 | (match_operand:DF 1 "register_operand" "0"))))] | |
1b0c37d7 | 10182 | "!TARGET_64BIT && TARGET_80387" |
2ae0f82c | 10183 | "fabs" |
6ef67412 JH |
10184 | [(set_attr "type" "fsgn") |
10185 | (set_attr "mode" "XF")]) | |
a199fdd6 | 10186 | |
6343a50e | 10187 | (define_insn "*absextendsfxf2" |
58733f96 | 10188 | [(set (match_operand:XF 0 "register_operand" "=f") |
e075ae69 RH |
10189 | (abs:XF (float_extend:XF |
10190 | (match_operand:SF 1 "register_operand" "0"))))] | |
1b0c37d7 | 10191 | "!TARGET_64BIT && TARGET_80387" |
e075ae69 | 10192 | "fabs" |
6ef67412 JH |
10193 | [(set_attr "type" "fsgn") |
10194 | (set_attr "mode" "XF")]) | |
2b589241 JH |
10195 | |
10196 | (define_insn "*abstf2_1" | |
10197 | [(set (match_operand:TF 0 "register_operand" "=f") | |
10198 | (abs:TF (match_operand:TF 1 "register_operand" "0")))] | |
10199 | "TARGET_80387 && reload_completed" | |
10200 | "fabs" | |
10201 | [(set_attr "type" "fsgn") | |
10202 | (set_attr "mode" "DF")]) | |
10203 | ||
10204 | (define_insn "*absextenddftf2" | |
10205 | [(set (match_operand:TF 0 "register_operand" "=f") | |
10206 | (abs:TF (float_extend:TF | |
10207 | (match_operand:DF 1 "register_operand" "0"))))] | |
10208 | "TARGET_80387" | |
10209 | "fabs" | |
10210 | [(set_attr "type" "fsgn") | |
10211 | (set_attr "mode" "XF")]) | |
10212 | ||
10213 | (define_insn "*absextendsftf2" | |
10214 | [(set (match_operand:TF 0 "register_operand" "=f") | |
10215 | (abs:TF (float_extend:TF | |
10216 | (match_operand:SF 1 "register_operand" "0"))))] | |
10217 | "TARGET_80387" | |
10218 | "fabs" | |
10219 | [(set_attr "type" "fsgn") | |
10220 | (set_attr "mode" "XF")]) | |
886c62d1 | 10221 | \f |
e075ae69 | 10222 | ;; One complement instructions |
886c62d1 | 10223 | |
9b70259d JH |
10224 | (define_expand "one_cmpldi2" |
10225 | [(set (match_operand:DI 0 "nonimmediate_operand" "") | |
10226 | (not:DI (match_operand:DI 1 "nonimmediate_operand" "")))] | |
10227 | "TARGET_64BIT" | |
10228 | "ix86_expand_unary_operator (NOT, DImode, operands); DONE;") | |
10229 | ||
10230 | (define_insn "*one_cmpldi2_1_rex64" | |
10231 | [(set (match_operand:DI 0 "nonimmediate_operand" "=rm") | |
10232 | (not:DI (match_operand:DI 1 "nonimmediate_operand" "0")))] | |
10233 | "TARGET_64BIT && ix86_unary_operator_ok (NOT, DImode, operands)" | |
0f40f9f7 | 10234 | "not{q}\t%0" |
9b70259d JH |
10235 | [(set_attr "type" "negnot") |
10236 | (set_attr "mode" "DI")]) | |
10237 | ||
10238 | (define_insn "*one_cmpldi2_2_rex64" | |
10239 | [(set (reg 17) | |
10240 | (compare (not:DI (match_operand:DI 1 "nonimmediate_operand" "0")) | |
10241 | (const_int 0))) | |
10242 | (set (match_operand:DI 0 "nonimmediate_operand" "=rm") | |
10243 | (not:DI (match_dup 1)))] | |
10244 | "TARGET_64BIT && ix86_match_ccmode (insn, CCNOmode) | |
10245 | && ix86_unary_operator_ok (NOT, DImode, operands)" | |
10246 | "#" | |
10247 | [(set_attr "type" "alu1") | |
10248 | (set_attr "mode" "DI")]) | |
10249 | ||
10250 | (define_split | |
10251 | [(set (reg 17) | |
10252 | (compare (not:DI (match_operand:DI 1 "nonimmediate_operand" "")) | |
10253 | (const_int 0))) | |
10254 | (set (match_operand:DI 0 "nonimmediate_operand" "") | |
10255 | (not:DI (match_dup 1)))] | |
10256 | "TARGET_64BIT && ix86_match_ccmode (insn, CCNOmode)" | |
10257 | [(parallel [(set (reg:CCNO 17) | |
10258 | (compare:CCNO (xor:DI (match_dup 1) (const_int -1)) | |
10259 | (const_int 0))) | |
10260 | (set (match_dup 0) | |
10261 | (xor:DI (match_dup 1) (const_int -1)))])] | |
10262 | "") | |
10263 | ||
06a964de | 10264 | (define_expand "one_cmplsi2" |
a1cbdd7f JH |
10265 | [(set (match_operand:SI 0 "nonimmediate_operand" "") |
10266 | (not:SI (match_operand:SI 1 "nonimmediate_operand" "")))] | |
06a964de JH |
10267 | "" |
10268 | "ix86_expand_unary_operator (NOT, SImode, operands); DONE;") | |
10269 | ||
10270 | (define_insn "*one_cmplsi2_1" | |
2ae0f82c SC |
10271 | [(set (match_operand:SI 0 "nonimmediate_operand" "=rm") |
10272 | (not:SI (match_operand:SI 1 "nonimmediate_operand" "0")))] | |
a1cbdd7f | 10273 | "ix86_unary_operator_ok (NOT, SImode, operands)" |
0f40f9f7 | 10274 | "not{l}\t%0" |
6ef67412 JH |
10275 | [(set_attr "type" "negnot") |
10276 | (set_attr "mode" "SI")]) | |
bb524860 | 10277 | |
9b70259d JH |
10278 | ;; ??? Currently never generated - xor is used instead. |
10279 | (define_insn "*one_cmplsi2_1_zext" | |
10280 | [(set (match_operand:DI 0 "register_operand" "=r") | |
10281 | (zero_extend:DI (not:SI (match_operand:SI 1 "register_operand" "0"))))] | |
10282 | "TARGET_64BIT && ix86_unary_operator_ok (NOT, SImode, operands)" | |
0f40f9f7 | 10283 | "not{l}\t%k0" |
9b70259d JH |
10284 | [(set_attr "type" "negnot") |
10285 | (set_attr "mode" "SI")]) | |
10286 | ||
06a964de | 10287 | (define_insn "*one_cmplsi2_2" |
16189740 RH |
10288 | [(set (reg 17) |
10289 | (compare (not:SI (match_operand:SI 1 "nonimmediate_operand" "0")) | |
10290 | (const_int 0))) | |
e075ae69 RH |
10291 | (set (match_operand:SI 0 "nonimmediate_operand" "=rm") |
10292 | (not:SI (match_dup 1)))] | |
16189740 RH |
10293 | "ix86_match_ccmode (insn, CCNOmode) |
10294 | && ix86_unary_operator_ok (NOT, SImode, operands)" | |
e075ae69 | 10295 | "#" |
6ef67412 JH |
10296 | [(set_attr "type" "alu1") |
10297 | (set_attr "mode" "SI")]) | |
e075ae69 RH |
10298 | |
10299 | (define_split | |
16189740 RH |
10300 | [(set (reg 17) |
10301 | (compare (not:SI (match_operand:SI 1 "nonimmediate_operand" "")) | |
10302 | (const_int 0))) | |
e075ae69 RH |
10303 | (set (match_operand:SI 0 "nonimmediate_operand" "") |
10304 | (not:SI (match_dup 1)))] | |
16189740 | 10305 | "ix86_match_ccmode (insn, CCNOmode)" |
e075ae69 RH |
10306 | [(parallel [(set (reg:CCNO 17) |
10307 | (compare:CCNO (xor:SI (match_dup 1) (const_int -1)) | |
10308 | (const_int 0))) | |
10309 | (set (match_dup 0) | |
10310 | (xor:SI (match_dup 1) (const_int -1)))])] | |
10311 | "") | |
886c62d1 | 10312 | |
9b70259d JH |
10313 | ;; ??? Currently never generated - xor is used instead. |
10314 | (define_insn "*one_cmplsi2_2_zext" | |
10315 | [(set (reg 17) | |
10316 | (compare (not:SI (match_operand:SI 1 "register_operand" "0")) | |
10317 | (const_int 0))) | |
10318 | (set (match_operand:DI 0 "register_operand" "=r") | |
10319 | (zero_extend:DI (not:SI (match_dup 1))))] | |
10320 | "TARGET_64BIT && ix86_match_ccmode (insn, CCNOmode) | |
10321 | && ix86_unary_operator_ok (NOT, SImode, operands)" | |
10322 | "#" | |
10323 | [(set_attr "type" "alu1") | |
10324 | (set_attr "mode" "SI")]) | |
10325 | ||
10326 | (define_split | |
10327 | [(set (reg 17) | |
10328 | (compare (not:SI (match_operand:SI 1 "register_operand" "")) | |
10329 | (const_int 0))) | |
10330 | (set (match_operand:DI 0 "register_operand" "") | |
10331 | (zero_extend:DI (not:SI (match_dup 1))))] | |
10332 | "ix86_match_ccmode (insn, CCNOmode)" | |
10333 | [(parallel [(set (reg:CCNO 17) | |
10334 | (compare:CCNO (xor:SI (match_dup 1) (const_int -1)) | |
10335 | (const_int 0))) | |
10336 | (set (match_dup 0) | |
10337 | (zero_extend:DI (xor:SI (match_dup 1) (const_int -1))))])] | |
10338 | "") | |
10339 | ||
06a964de | 10340 | (define_expand "one_cmplhi2" |
a1cbdd7f JH |
10341 | [(set (match_operand:HI 0 "nonimmediate_operand" "") |
10342 | (not:HI (match_operand:HI 1 "nonimmediate_operand" "")))] | |
d9f32422 | 10343 | "TARGET_HIMODE_MATH" |
06a964de JH |
10344 | "ix86_expand_unary_operator (NOT, HImode, operands); DONE;") |
10345 | ||
10346 | (define_insn "*one_cmplhi2_1" | |
2ae0f82c SC |
10347 | [(set (match_operand:HI 0 "nonimmediate_operand" "=rm") |
10348 | (not:HI (match_operand:HI 1 "nonimmediate_operand" "0")))] | |
a1cbdd7f | 10349 | "ix86_unary_operator_ok (NOT, HImode, operands)" |
0f40f9f7 | 10350 | "not{w}\t%0" |
6ef67412 JH |
10351 | [(set_attr "type" "negnot") |
10352 | (set_attr "mode" "HI")]) | |
bb524860 | 10353 | |
06a964de | 10354 | (define_insn "*one_cmplhi2_2" |
16189740 RH |
10355 | [(set (reg 17) |
10356 | (compare (not:HI (match_operand:HI 1 "nonimmediate_operand" "0")) | |
10357 | (const_int 0))) | |
e075ae69 RH |
10358 | (set (match_operand:HI 0 "nonimmediate_operand" "=rm") |
10359 | (not:HI (match_dup 1)))] | |
16189740 RH |
10360 | "ix86_match_ccmode (insn, CCNOmode) |
10361 | && ix86_unary_operator_ok (NEG, HImode, operands)" | |
e075ae69 | 10362 | "#" |
6ef67412 JH |
10363 | [(set_attr "type" "alu1") |
10364 | (set_attr "mode" "HI")]) | |
e075ae69 RH |
10365 | |
10366 | (define_split | |
16189740 RH |
10367 | [(set (reg 17) |
10368 | (compare (not:HI (match_operand:HI 1 "nonimmediate_operand" "")) | |
10369 | (const_int 0))) | |
e075ae69 RH |
10370 | (set (match_operand:HI 0 "nonimmediate_operand" "") |
10371 | (not:HI (match_dup 1)))] | |
16189740 | 10372 | "ix86_match_ccmode (insn, CCNOmode)" |
e075ae69 RH |
10373 | [(parallel [(set (reg:CCNO 17) |
10374 | (compare:CCNO (xor:HI (match_dup 1) (const_int -1)) | |
10375 | (const_int 0))) | |
10376 | (set (match_dup 0) | |
10377 | (xor:HI (match_dup 1) (const_int -1)))])] | |
10378 | "") | |
886c62d1 | 10379 | |
e075ae69 | 10380 | ;; %%% Potential partial reg stall on alternative 1. What to do? |
06a964de | 10381 | (define_expand "one_cmplqi2" |
a1cbdd7f JH |
10382 | [(set (match_operand:QI 0 "nonimmediate_operand" "") |
10383 | (not:QI (match_operand:QI 1 "nonimmediate_operand" "")))] | |
d9f32422 | 10384 | "TARGET_QIMODE_MATH" |
06a964de JH |
10385 | "ix86_expand_unary_operator (NOT, QImode, operands); DONE;") |
10386 | ||
10387 | (define_insn "*one_cmplqi2_1" | |
7c6b971d | 10388 | [(set (match_operand:QI 0 "nonimmediate_operand" "=qm,r") |
e075ae69 | 10389 | (not:QI (match_operand:QI 1 "nonimmediate_operand" "0,0")))] |
a1cbdd7f | 10390 | "ix86_unary_operator_ok (NOT, QImode, operands)" |
e075ae69 | 10391 | "@ |
0f40f9f7 ZW |
10392 | not{b}\t%0 |
10393 | not{l}\t%k0" | |
6ef67412 JH |
10394 | [(set_attr "type" "negnot") |
10395 | (set_attr "mode" "QI,SI")]) | |
bb524860 | 10396 | |
06a964de | 10397 | (define_insn "*one_cmplqi2_2" |
16189740 RH |
10398 | [(set (reg 17) |
10399 | (compare (not:QI (match_operand:QI 1 "nonimmediate_operand" "0")) | |
10400 | (const_int 0))) | |
e075ae69 RH |
10401 | (set (match_operand:QI 0 "nonimmediate_operand" "=qm") |
10402 | (not:QI (match_dup 1)))] | |
16189740 RH |
10403 | "ix86_match_ccmode (insn, CCNOmode) |
10404 | && ix86_unary_operator_ok (NOT, QImode, operands)" | |
e075ae69 | 10405 | "#" |
6ef67412 JH |
10406 | [(set_attr "type" "alu1") |
10407 | (set_attr "mode" "QI")]) | |
e075ae69 RH |
10408 | |
10409 | (define_split | |
16189740 RH |
10410 | [(set (reg 17) |
10411 | (compare (not:QI (match_operand:QI 1 "nonimmediate_operand" "")) | |
10412 | (const_int 0))) | |
e075ae69 RH |
10413 | (set (match_operand:QI 0 "nonimmediate_operand" "") |
10414 | (not:QI (match_dup 1)))] | |
16189740 | 10415 | "ix86_match_ccmode (insn, CCNOmode)" |
e075ae69 RH |
10416 | [(parallel [(set (reg:CCNO 17) |
10417 | (compare:CCNO (xor:QI (match_dup 1) (const_int -1)) | |
10418 | (const_int 0))) | |
10419 | (set (match_dup 0) | |
10420 | (xor:QI (match_dup 1) (const_int -1)))])] | |
10421 | "") | |
886c62d1 | 10422 | \f |
e075ae69 | 10423 | ;; Arithmetic shift instructions |
886c62d1 JVA |
10424 | |
10425 | ;; DImode shifts are implemented using the i386 "shift double" opcode, | |
10426 | ;; which is written as "sh[lr]d[lw] imm,reg,reg/mem". If the shift count | |
10427 | ;; is variable, then the count is in %cl and the "imm" operand is dropped | |
10428 | ;; from the assembler input. | |
e075ae69 | 10429 | ;; |
886c62d1 JVA |
10430 | ;; This instruction shifts the target reg/mem as usual, but instead of |
10431 | ;; shifting in zeros, bits are shifted in from reg operand. If the insn | |
10432 | ;; is a left shift double, bits are taken from the high order bits of | |
10433 | ;; reg, else if the insn is a shift right double, bits are taken from the | |
10434 | ;; low order bits of reg. So if %eax is "1234" and %edx is "5678", | |
10435 | ;; "shldl $8,%edx,%eax" leaves %edx unchanged and sets %eax to "2345". | |
e075ae69 | 10436 | ;; |
886c62d1 JVA |
10437 | ;; Since sh[lr]d does not change the `reg' operand, that is done |
10438 | ;; separately, making all shifts emit pairs of shift double and normal | |
10439 | ;; shift. Since sh[lr]d does not shift more than 31 bits, and we wish to | |
10440 | ;; support a 63 bit shift, each shift where the count is in a reg expands | |
f58acb67 | 10441 | ;; to a pair of shifts, a branch, a shift by 32 and a label. |
e075ae69 | 10442 | ;; |
886c62d1 JVA |
10443 | ;; If the shift count is a constant, we need never emit more than one |
10444 | ;; shift pair, instead using moves and sign extension for counts greater | |
10445 | ;; than 31. | |
10446 | ||
56c0e8fa | 10447 | (define_expand "ashldi3" |
371bc54b JH |
10448 | [(parallel [(set (match_operand:DI 0 "shiftdi_operand" "") |
10449 | (ashift:DI (match_operand:DI 1 "shiftdi_operand" "") | |
3d117b30 | 10450 | (match_operand:QI 2 "nonmemory_operand" ""))) |
e075ae69 | 10451 | (clobber (reg:CC 17))])] |
56c0e8fa | 10452 | "" |
56c0e8fa | 10453 | { |
3d117b30 | 10454 | if (!TARGET_64BIT && TARGET_CMOVE && ! immediate_operand (operands[2], QImode)) |
56c0e8fa | 10455 | { |
e075ae69 RH |
10456 | emit_insn (gen_ashldi3_1 (operands[0], operands[1], operands[2])); |
10457 | DONE; | |
56c0e8fa | 10458 | } |
371bc54b JH |
10459 | ix86_expand_binary_operator (ASHIFT, DImode, operands); |
10460 | DONE; | |
0f40f9f7 | 10461 | }) |
56c0e8fa | 10462 | |
371bc54b JH |
10463 | (define_insn "*ashldi3_1_rex64" |
10464 | [(set (match_operand:DI 0 "nonimmediate_operand" "=rm,r") | |
10465 | (ashift:DI (match_operand:DI 1 "nonimmediate_operand" "0,r") | |
7c17f553 | 10466 | (match_operand:QI 2 "nonmemory_operand" "cJ,M"))) |
371bc54b JH |
10467 | (clobber (reg:CC 17))] |
10468 | "TARGET_64BIT && ix86_binary_operator_ok (ASHIFT, DImode, operands)" | |
371bc54b JH |
10469 | { |
10470 | switch (get_attr_type (insn)) | |
10471 | { | |
10472 | case TYPE_ALU: | |
10473 | if (operands[2] != const1_rtx) | |
10474 | abort (); | |
10475 | if (!rtx_equal_p (operands[0], operands[1])) | |
10476 | abort (); | |
0f40f9f7 | 10477 | return "add{q}\t{%0, %0|%0, %0}"; |
371bc54b JH |
10478 | |
10479 | case TYPE_LEA: | |
10480 | if (GET_CODE (operands[2]) != CONST_INT | |
10481 | || (unsigned HOST_WIDE_INT) INTVAL (operands[2]) > 3) | |
10482 | abort (); | |
10483 | operands[1] = gen_rtx_MULT (DImode, operands[1], | |
10484 | GEN_INT (1 << INTVAL (operands[2]))); | |
0f40f9f7 | 10485 | return "lea{q}\t{%a1, %0|%0, %a1}"; |
371bc54b JH |
10486 | |
10487 | default: | |
10488 | if (REG_P (operands[2])) | |
0f40f9f7 | 10489 | return "sal{q}\t{%b2, %0|%0, %b2}"; |
371bc54b JH |
10490 | else if (GET_CODE (operands[2]) == CONST_INT |
10491 | && INTVAL (operands[2]) == 1 | |
10492 | && (TARGET_PENTIUM || TARGET_PENTIUMPRO)) | |
0f40f9f7 | 10493 | return "sal{q}\t%0"; |
371bc54b | 10494 | else |
0f40f9f7 | 10495 | return "sal{q}\t{%2, %0|%0, %2}"; |
371bc54b | 10496 | } |
0f40f9f7 | 10497 | } |
371bc54b JH |
10498 | [(set (attr "type") |
10499 | (cond [(eq_attr "alternative" "1") | |
10500 | (const_string "lea") | |
10501 | (and (and (ne (symbol_ref "TARGET_DOUBLE_WITH_ADD") | |
10502 | (const_int 0)) | |
10503 | (match_operand 0 "register_operand" "")) | |
10504 | (match_operand 2 "const1_operand" "")) | |
10505 | (const_string "alu") | |
10506 | ] | |
10507 | (const_string "ishift"))) | |
10508 | (set_attr "mode" "DI")]) | |
10509 | ||
10510 | ;; Convert lea to the lea pattern to avoid flags dependency. | |
10511 | (define_split | |
10512 | [(set (match_operand:DI 0 "register_operand" "") | |
10513 | (ashift:DI (match_operand:DI 1 "register_operand" "") | |
10514 | (match_operand:QI 2 "immediate_operand" ""))) | |
10515 | (clobber (reg:CC 17))] | |
1b0c37d7 | 10516 | "TARGET_64BIT && reload_completed |
371bc54b JH |
10517 | && true_regnum (operands[0]) != true_regnum (operands[1])" |
10518 | [(set (match_dup 0) | |
10519 | (mult:DI (match_dup 1) | |
10520 | (match_dup 2)))] | |
383252a7 AO |
10521 | "operands[2] = GEN_INT (trunc_int_for_mode (1 << INTVAL (operands[2]), |
10522 | DImode));") | |
371bc54b JH |
10523 | |
10524 | ;; This pattern can't accept a variable shift count, since shifts by | |
10525 | ;; zero don't affect the flags. We assume that shifts by constant | |
10526 | ;; zero are optimized away. | |
10527 | (define_insn "*ashldi3_cmp_rex64" | |
10528 | [(set (reg 17) | |
10529 | (compare | |
10530 | (ashift:DI (match_operand:DI 1 "nonimmediate_operand" "0") | |
10531 | (match_operand:QI 2 "immediate_operand" "e")) | |
10532 | (const_int 0))) | |
10533 | (set (match_operand:DI 0 "nonimmediate_operand" "=rm") | |
10534 | (ashift:DI (match_dup 1) (match_dup 2)))] | |
10535 | "TARGET_64BIT && ix86_match_ccmode (insn, CCGOCmode) | |
10536 | && ix86_binary_operator_ok (ASHIFT, DImode, operands)" | |
371bc54b JH |
10537 | { |
10538 | switch (get_attr_type (insn)) | |
10539 | { | |
10540 | case TYPE_ALU: | |
10541 | if (operands[2] != const1_rtx) | |
10542 | abort (); | |
0f40f9f7 | 10543 | return "add{q}\t{%0, %0|%0, %0}"; |
371bc54b JH |
10544 | |
10545 | default: | |
10546 | if (REG_P (operands[2])) | |
0f40f9f7 | 10547 | return "sal{q}\t{%b2, %0|%0, %b2}"; |
371bc54b JH |
10548 | else if (GET_CODE (operands[2]) == CONST_INT |
10549 | && INTVAL (operands[2]) == 1 | |
10550 | && (TARGET_PENTIUM || TARGET_PENTIUMPRO)) | |
0f40f9f7 | 10551 | return "sal{q}\t%0"; |
371bc54b | 10552 | else |
0f40f9f7 | 10553 | return "sal{q}\t{%2, %0|%0, %2}"; |
371bc54b | 10554 | } |
0f40f9f7 | 10555 | } |
371bc54b JH |
10556 | [(set (attr "type") |
10557 | (cond [(and (and (ne (symbol_ref "TARGET_DOUBLE_WITH_ADD") | |
10558 | (const_int 0)) | |
10559 | (match_operand 0 "register_operand" "")) | |
10560 | (match_operand 2 "const1_operand" "")) | |
10561 | (const_string "alu") | |
10562 | ] | |
10563 | (const_string "ishift"))) | |
10564 | (set_attr "mode" "DI")]) | |
10565 | ||
e075ae69 RH |
10566 | (define_insn "ashldi3_1" |
10567 | [(set (match_operand:DI 0 "register_operand" "=r") | |
56c0e8fa | 10568 | (ashift:DI (match_operand:DI 1 "register_operand" "0") |
e075ae69 RH |
10569 | (match_operand:QI 2 "nonmemory_operand" "Jc"))) |
10570 | (clobber (match_scratch:SI 3 "=&r")) | |
10571 | (clobber (reg:CC 17))] | |
371bc54b | 10572 | "!TARGET_64BIT && TARGET_CMOVE" |
e075ae69 RH |
10573 | "#" |
10574 | [(set_attr "type" "multi")]) | |
886c62d1 | 10575 | |
e075ae69 RH |
10576 | (define_insn "*ashldi3_2" |
10577 | [(set (match_operand:DI 0 "register_operand" "=r") | |
56c0e8fa | 10578 | (ashift:DI (match_operand:DI 1 "register_operand" "0") |
e075ae69 RH |
10579 | (match_operand:QI 2 "nonmemory_operand" "Jc"))) |
10580 | (clobber (reg:CC 17))] | |
371bc54b | 10581 | "!TARGET_64BIT" |
e075ae69 RH |
10582 | "#" |
10583 | [(set_attr "type" "multi")]) | |
886c62d1 | 10584 | |
e075ae69 RH |
10585 | (define_split |
10586 | [(set (match_operand:DI 0 "register_operand" "") | |
10587 | (ashift:DI (match_operand:DI 1 "register_operand" "") | |
10588 | (match_operand:QI 2 "nonmemory_operand" ""))) | |
10589 | (clobber (match_scratch:SI 3 "")) | |
10590 | (clobber (reg:CC 17))] | |
371bc54b | 10591 | "!TARGET_64BIT && TARGET_CMOVE && reload_completed" |
e075ae69 RH |
10592 | [(const_int 0)] |
10593 | "ix86_split_ashldi (operands, operands[3]); DONE;") | |
47f59fd4 | 10594 | |
e075ae69 RH |
10595 | (define_split |
10596 | [(set (match_operand:DI 0 "register_operand" "") | |
10597 | (ashift:DI (match_operand:DI 1 "register_operand" "") | |
10598 | (match_operand:QI 2 "nonmemory_operand" ""))) | |
10599 | (clobber (reg:CC 17))] | |
371bc54b | 10600 | "!TARGET_64BIT && reload_completed" |
e075ae69 RH |
10601 | [(const_int 0)] |
10602 | "ix86_split_ashldi (operands, NULL_RTX); DONE;") | |
6ec6d558 | 10603 | |
e075ae69 RH |
10604 | (define_insn "x86_shld_1" |
10605 | [(set (match_operand:SI 0 "nonimmediate_operand" "+r*m,r*m") | |
10606 | (ior:SI (ashift:SI (match_dup 0) | |
10607 | (match_operand:QI 2 "nonmemory_operand" "I,c")) | |
10608 | (lshiftrt:SI (match_operand:SI 1 "register_operand" "r,r") | |
10609 | (minus:QI (const_int 32) (match_dup 2))))) | |
10610 | (clobber (reg:CC 17))] | |
6ec6d558 | 10611 | "" |
e075ae69 | 10612 | "@ |
0f40f9f7 ZW |
10613 | shld{l}\t{%2, %1, %0|%0, %1, %2} |
10614 | shld{l}\t{%s2%1, %0|%0, %1, %2}" | |
e075ae69 | 10615 | [(set_attr "type" "ishift") |
6ef67412 JH |
10616 | (set_attr "prefix_0f" "1") |
10617 | (set_attr "mode" "SI") | |
e075ae69 | 10618 | (set_attr "pent_pair" "np") |
309ada50 | 10619 | (set_attr "athlon_decode" "vector") |
e075ae69 RH |
10620 | (set_attr "ppro_uops" "few")]) |
10621 | ||
10622 | (define_expand "x86_shift_adj_1" | |
16189740 RH |
10623 | [(set (reg:CCZ 17) |
10624 | (compare:CCZ (and:QI (match_operand:QI 2 "register_operand" "") | |
10625 | (const_int 32)) | |
10626 | (const_int 0))) | |
e075ae69 | 10627 | (set (match_operand:SI 0 "register_operand" "") |
16189740 | 10628 | (if_then_else:SI (ne (reg:CCZ 17) (const_int 0)) |
e075ae69 RH |
10629 | (match_operand:SI 1 "register_operand" "") |
10630 | (match_dup 0))) | |
10631 | (set (match_dup 1) | |
16189740 | 10632 | (if_then_else:SI (ne (reg:CCZ 17) (const_int 0)) |
e075ae69 RH |
10633 | (match_operand:SI 3 "register_operand" "r") |
10634 | (match_dup 1)))] | |
10635 | "TARGET_CMOVE" | |
6ec6d558 JH |
10636 | "") |
10637 | ||
e075ae69 RH |
10638 | (define_expand "x86_shift_adj_2" |
10639 | [(use (match_operand:SI 0 "register_operand" "")) | |
10640 | (use (match_operand:SI 1 "register_operand" "")) | |
10641 | (use (match_operand:QI 2 "register_operand" ""))] | |
886c62d1 | 10642 | "" |
e075ae69 RH |
10643 | { |
10644 | rtx label = gen_label_rtx (); | |
10645 | rtx tmp; | |
886c62d1 | 10646 | |
16189740 | 10647 | emit_insn (gen_testqi_ccz_1 (operands[2], GEN_INT (32))); |
886c62d1 | 10648 | |
16189740 | 10649 | tmp = gen_rtx_REG (CCZmode, FLAGS_REG); |
e075ae69 RH |
10650 | tmp = gen_rtx_EQ (VOIDmode, tmp, const0_rtx); |
10651 | tmp = gen_rtx_IF_THEN_ELSE (VOIDmode, tmp, | |
10652 | gen_rtx_LABEL_REF (VOIDmode, label), | |
10653 | pc_rtx); | |
10654 | tmp = emit_jump_insn (gen_rtx_SET (VOIDmode, pc_rtx, tmp)); | |
10655 | JUMP_LABEL (tmp) = label; | |
886c62d1 | 10656 | |
e075ae69 RH |
10657 | emit_move_insn (operands[0], operands[1]); |
10658 | emit_move_insn (operands[1], const0_rtx); | |
886c62d1 | 10659 | |
e075ae69 RH |
10660 | emit_label (label); |
10661 | LABEL_NUSES (label) = 1; | |
56c0e8fa JVA |
10662 | |
10663 | DONE; | |
0f40f9f7 | 10664 | }) |
56c0e8fa | 10665 | |
d525dfdf JH |
10666 | (define_expand "ashlsi3" |
10667 | [(set (match_operand:SI 0 "nonimmediate_operand" "") | |
10668 | (ashift:SI (match_operand:SI 1 "nonimmediate_operand" "") | |
10669 | (match_operand:QI 2 "nonmemory_operand" ""))) | |
10670 | (clobber (reg:CC 17))] | |
10671 | "" | |
10672 | "ix86_expand_binary_operator (ASHIFT, SImode, operands); DONE;") | |
10673 | ||
10674 | (define_insn "*ashlsi3_1" | |
e075ae69 RH |
10675 | [(set (match_operand:SI 0 "nonimmediate_operand" "=rm,r") |
10676 | (ashift:SI (match_operand:SI 1 "nonimmediate_operand" "0,r") | |
10677 | (match_operand:QI 2 "nonmemory_operand" "cI,M"))) | |
10678 | (clobber (reg:CC 17))] | |
d525dfdf | 10679 | "ix86_binary_operator_ok (ASHIFT, SImode, operands)" |
2ae0f82c | 10680 | { |
e075ae69 RH |
10681 | switch (get_attr_type (insn)) |
10682 | { | |
10683 | case TYPE_ALU: | |
10684 | if (operands[2] != const1_rtx) | |
10685 | abort (); | |
10686 | if (!rtx_equal_p (operands[0], operands[1])) | |
10687 | abort (); | |
0f40f9f7 | 10688 | return "add{l}\t{%0, %0|%0, %0}"; |
2ae0f82c | 10689 | |
e075ae69 | 10690 | case TYPE_LEA: |
0f40f9f7 | 10691 | return "#"; |
2ae0f82c | 10692 | |
e075ae69 RH |
10693 | default: |
10694 | if (REG_P (operands[2])) | |
0f40f9f7 | 10695 | return "sal{l}\t{%b2, %0|%0, %b2}"; |
8bad7136 JL |
10696 | else if (GET_CODE (operands[2]) == CONST_INT |
10697 | && INTVAL (operands[2]) == 1 | |
10698 | && (TARGET_PENTIUM || TARGET_PENTIUMPRO)) | |
0f40f9f7 | 10699 | return "sal{l}\t%0"; |
e075ae69 | 10700 | else |
0f40f9f7 | 10701 | return "sal{l}\t{%2, %0|%0, %2}"; |
e075ae69 | 10702 | } |
0f40f9f7 | 10703 | } |
e075ae69 RH |
10704 | [(set (attr "type") |
10705 | (cond [(eq_attr "alternative" "1") | |
10706 | (const_string "lea") | |
10707 | (and (and (ne (symbol_ref "TARGET_DOUBLE_WITH_ADD") | |
10708 | (const_int 0)) | |
10709 | (match_operand 0 "register_operand" "")) | |
10710 | (match_operand 2 "const1_operand" "")) | |
10711 | (const_string "alu") | |
10712 | ] | |
6ef67412 JH |
10713 | (const_string "ishift"))) |
10714 | (set_attr "mode" "SI")]) | |
e075ae69 | 10715 | |
1c27d4b2 JH |
10716 | ;; Convert lea to the lea pattern to avoid flags dependency. |
10717 | (define_split | |
58787064 JH |
10718 | [(set (match_operand 0 "register_operand" "") |
10719 | (ashift (match_operand 1 "register_operand" "") | |
ca4ae08d | 10720 | (match_operand:QI 2 "const_int_operand" ""))) |
1c27d4b2 | 10721 | (clobber (reg:CC 17))] |
abe24fb3 JH |
10722 | "reload_completed |
10723 | && true_regnum (operands[0]) != true_regnum (operands[1])" | |
58787064 | 10724 | [(const_int 0)] |
58787064 JH |
10725 | { |
10726 | rtx pat; | |
10727 | operands[0] = gen_lowpart (SImode, operands[0]); | |
10728 | operands[1] = gen_lowpart (Pmode, operands[1]); | |
383252a7 AO |
10729 | operands[2] = GEN_INT (trunc_int_for_mode (1 << INTVAL (operands[2]), |
10730 | Pmode)); | |
58787064 JH |
10731 | pat = gen_rtx_MULT (Pmode, operands[1], operands[2]); |
10732 | if (Pmode != SImode) | |
10733 | pat = gen_rtx_SUBREG (SImode, pat, 0); | |
10734 | emit_insn (gen_rtx_SET (VOIDmode, operands[0], pat)); | |
10735 | DONE; | |
0f40f9f7 | 10736 | }) |
1c27d4b2 | 10737 | |
371bc54b JH |
10738 | (define_insn "*ashlsi3_1_zext" |
10739 | [(set (match_operand:DI 0 "register_operand" "=r,r") | |
10740 | (zero_extend:DI (ashift:SI (match_operand:SI 1 "register_operand" "0,r") | |
10741 | (match_operand:QI 2 "nonmemory_operand" "cI,M")))) | |
10742 | (clobber (reg:CC 17))] | |
1b0c37d7 | 10743 | "TARGET_64BIT && ix86_binary_operator_ok (ASHIFT, SImode, operands)" |
371bc54b JH |
10744 | { |
10745 | switch (get_attr_type (insn)) | |
10746 | { | |
10747 | case TYPE_ALU: | |
10748 | if (operands[2] != const1_rtx) | |
10749 | abort (); | |
0f40f9f7 | 10750 | return "add{l}\t{%k0, %k0|%k0, %k0}"; |
371bc54b JH |
10751 | |
10752 | case TYPE_LEA: | |
0f40f9f7 | 10753 | return "#"; |
371bc54b JH |
10754 | |
10755 | default: | |
10756 | if (REG_P (operands[2])) | |
0f40f9f7 | 10757 | return "sal{l}\t{%b2, %k0|%k0, %b2}"; |
371bc54b JH |
10758 | else if (GET_CODE (operands[2]) == CONST_INT |
10759 | && INTVAL (operands[2]) == 1 | |
10760 | && (TARGET_PENTIUM || TARGET_PENTIUMPRO)) | |
0f40f9f7 | 10761 | return "sal{l}\t%k0"; |
371bc54b | 10762 | else |
0f40f9f7 | 10763 | return "sal{l}\t{%2, %k0|%k0, %2}"; |
371bc54b | 10764 | } |
0f40f9f7 | 10765 | } |
371bc54b JH |
10766 | [(set (attr "type") |
10767 | (cond [(eq_attr "alternative" "1") | |
10768 | (const_string "lea") | |
10769 | (and (ne (symbol_ref "TARGET_DOUBLE_WITH_ADD") | |
10770 | (const_int 0)) | |
10771 | (match_operand 2 "const1_operand" "")) | |
10772 | (const_string "alu") | |
10773 | ] | |
10774 | (const_string "ishift"))) | |
10775 | (set_attr "mode" "SI")]) | |
10776 | ||
10777 | ;; Convert lea to the lea pattern to avoid flags dependency. | |
10778 | (define_split | |
10779 | [(set (match_operand:DI 0 "register_operand" "") | |
10780 | (zero_extend:DI (ashift (match_operand 1 "register_operand" "") | |
10781 | (match_operand:QI 2 "const_int_operand" "")))) | |
10782 | (clobber (reg:CC 17))] | |
10783 | "reload_completed | |
10784 | && true_regnum (operands[0]) != true_regnum (operands[1])" | |
10785 | [(set (match_dup 0) (zero_extend:DI (subreg:SI (mult:SI (match_dup 1) (match_dup 2)) 0)))] | |
371bc54b JH |
10786 | { |
10787 | operands[1] = gen_lowpart (Pmode, operands[1]); | |
383252a7 AO |
10788 | operands[2] = GEN_INT (trunc_int_for_mode (1 << INTVAL (operands[2]), |
10789 | Pmode)); | |
0f40f9f7 | 10790 | }) |
371bc54b | 10791 | |
28cefcd2 BS |
10792 | ;; This pattern can't accept a variable shift count, since shifts by |
10793 | ;; zero don't affect the flags. We assume that shifts by constant | |
10794 | ;; zero are optimized away. | |
2c873473 | 10795 | (define_insn "*ashlsi3_cmp" |
16189740 RH |
10796 | [(set (reg 17) |
10797 | (compare | |
e075ae69 | 10798 | (ashift:SI (match_operand:SI 1 "nonimmediate_operand" "0") |
28cefcd2 | 10799 | (match_operand:QI 2 "immediate_operand" "I")) |
e075ae69 RH |
10800 | (const_int 0))) |
10801 | (set (match_operand:SI 0 "nonimmediate_operand" "=rm") | |
10802 | (ashift:SI (match_dup 1) (match_dup 2)))] | |
9076b9c1 | 10803 | "ix86_match_ccmode (insn, CCGOCmode) |
16189740 | 10804 | && ix86_binary_operator_ok (ASHIFT, SImode, operands)" |
886c62d1 | 10805 | { |
e075ae69 | 10806 | switch (get_attr_type (insn)) |
886c62d1 | 10807 | { |
e075ae69 RH |
10808 | case TYPE_ALU: |
10809 | if (operands[2] != const1_rtx) | |
10810 | abort (); | |
0f40f9f7 | 10811 | return "add{l}\t{%0, %0|%0, %0}"; |
886c62d1 | 10812 | |
e075ae69 RH |
10813 | default: |
10814 | if (REG_P (operands[2])) | |
0f40f9f7 | 10815 | return "sal{l}\t{%b2, %0|%0, %b2}"; |
8bad7136 JL |
10816 | else if (GET_CODE (operands[2]) == CONST_INT |
10817 | && INTVAL (operands[2]) == 1 | |
10818 | && (TARGET_PENTIUM || TARGET_PENTIUMPRO)) | |
0f40f9f7 | 10819 | return "sal{l}\t%0"; |
e075ae69 | 10820 | else |
0f40f9f7 | 10821 | return "sal{l}\t{%2, %0|%0, %2}"; |
56c0e8fa | 10822 | } |
0f40f9f7 | 10823 | } |
e075ae69 RH |
10824 | [(set (attr "type") |
10825 | (cond [(and (and (ne (symbol_ref "TARGET_DOUBLE_WITH_ADD") | |
10826 | (const_int 0)) | |
10827 | (match_operand 0 "register_operand" "")) | |
10828 | (match_operand 2 "const1_operand" "")) | |
10829 | (const_string "alu") | |
10830 | ] | |
6ef67412 JH |
10831 | (const_string "ishift"))) |
10832 | (set_attr "mode" "SI")]) | |
e075ae69 | 10833 | |
371bc54b JH |
10834 | (define_insn "*ashlsi3_cmp_zext" |
10835 | [(set (reg 17) | |
10836 | (compare | |
10837 | (ashift:SI (match_operand:SI 1 "register_operand" "0") | |
10838 | (match_operand:QI 2 "immediate_operand" "I")) | |
10839 | (const_int 0))) | |
10840 | (set (match_operand:DI 0 "register_operand" "=r") | |
10841 | (zero_extend:DI (ashift:SI (match_dup 1) (match_dup 2))))] | |
10842 | "TARGET_64BIT && ix86_match_ccmode (insn, CCGOCmode) | |
10843 | && ix86_binary_operator_ok (ASHIFT, SImode, operands)" | |
371bc54b JH |
10844 | { |
10845 | switch (get_attr_type (insn)) | |
10846 | { | |
10847 | case TYPE_ALU: | |
10848 | if (operands[2] != const1_rtx) | |
10849 | abort (); | |
0f40f9f7 | 10850 | return "add{l}\t{%k0, %k0|%k0, %k0}"; |
371bc54b JH |
10851 | |
10852 | default: | |
10853 | if (REG_P (operands[2])) | |
0f40f9f7 | 10854 | return "sal{l}\t{%b2, %k0|%k0, %b2}"; |
371bc54b JH |
10855 | else if (GET_CODE (operands[2]) == CONST_INT |
10856 | && INTVAL (operands[2]) == 1 | |
10857 | && (TARGET_PENTIUM || TARGET_PENTIUMPRO)) | |
0f40f9f7 | 10858 | return "sal{l}\t%k0"; |
371bc54b | 10859 | else |
0f40f9f7 | 10860 | return "sal{l}\t{%2, %k0|%k0, %2}"; |
371bc54b | 10861 | } |
0f40f9f7 | 10862 | } |
371bc54b JH |
10863 | [(set (attr "type") |
10864 | (cond [(and (ne (symbol_ref "TARGET_DOUBLE_WITH_ADD") | |
10865 | (const_int 0)) | |
10866 | (match_operand 2 "const1_operand" "")) | |
10867 | (const_string "alu") | |
10868 | ] | |
10869 | (const_string "ishift"))) | |
10870 | (set_attr "mode" "SI")]) | |
10871 | ||
d525dfdf JH |
10872 | (define_expand "ashlhi3" |
10873 | [(set (match_operand:HI 0 "nonimmediate_operand" "") | |
10874 | (ashift:HI (match_operand:HI 1 "nonimmediate_operand" "") | |
10875 | (match_operand:QI 2 "nonmemory_operand" ""))) | |
10876 | (clobber (reg:CC 17))] | |
d9f32422 | 10877 | "TARGET_HIMODE_MATH" |
d525dfdf JH |
10878 | "ix86_expand_binary_operator (ASHIFT, HImode, operands); DONE;") |
10879 | ||
58787064 JH |
10880 | (define_insn "*ashlhi3_1_lea" |
10881 | [(set (match_operand:HI 0 "nonimmediate_operand" "=rm,r") | |
10882 | (ashift:HI (match_operand:HI 1 "nonimmediate_operand" "0,r") | |
10883 | (match_operand:QI 2 "nonmemory_operand" "cI,M"))) | |
10884 | (clobber (reg:CC 17))] | |
10885 | "!TARGET_PARTIAL_REG_STALL | |
10886 | && ix86_binary_operator_ok (ASHIFT, HImode, operands)" | |
58787064 JH |
10887 | { |
10888 | switch (get_attr_type (insn)) | |
10889 | { | |
10890 | case TYPE_LEA: | |
0f40f9f7 | 10891 | return "#"; |
58787064 JH |
10892 | case TYPE_ALU: |
10893 | if (operands[2] != const1_rtx) | |
10894 | abort (); | |
0f40f9f7 | 10895 | return "add{w}\t{%0, %0|%0, %0}"; |
58787064 JH |
10896 | |
10897 | default: | |
10898 | if (REG_P (operands[2])) | |
0f40f9f7 | 10899 | return "sal{w}\t{%b2, %0|%0, %b2}"; |
58787064 JH |
10900 | else if (GET_CODE (operands[2]) == CONST_INT |
10901 | && INTVAL (operands[2]) == 1 | |
10902 | && (TARGET_PENTIUM || TARGET_PENTIUMPRO)) | |
0f40f9f7 | 10903 | return "sal{w}\t%0"; |
58787064 | 10904 | else |
0f40f9f7 | 10905 | return "sal{w}\t{%2, %0|%0, %2}"; |
58787064 | 10906 | } |
0f40f9f7 | 10907 | } |
58787064 JH |
10908 | [(set (attr "type") |
10909 | (cond [(eq_attr "alternative" "1") | |
10910 | (const_string "lea") | |
10911 | (and (and (ne (symbol_ref "TARGET_DOUBLE_WITH_ADD") | |
10912 | (const_int 0)) | |
10913 | (match_operand 0 "register_operand" "")) | |
10914 | (match_operand 2 "const1_operand" "")) | |
10915 | (const_string "alu") | |
10916 | ] | |
10917 | (const_string "ishift"))) | |
10918 | (set_attr "mode" "HI,SI")]) | |
10919 | ||
d525dfdf | 10920 | (define_insn "*ashlhi3_1" |
e075ae69 RH |
10921 | [(set (match_operand:HI 0 "nonimmediate_operand" "=rm") |
10922 | (ashift:HI (match_operand:HI 1 "nonimmediate_operand" "0") | |
10923 | (match_operand:QI 2 "nonmemory_operand" "cI"))) | |
10924 | (clobber (reg:CC 17))] | |
58787064 JH |
10925 | "TARGET_PARTIAL_REG_STALL |
10926 | && ix86_binary_operator_ok (ASHIFT, HImode, operands)" | |
56c0e8fa | 10927 | { |
e075ae69 RH |
10928 | switch (get_attr_type (insn)) |
10929 | { | |
10930 | case TYPE_ALU: | |
10931 | if (operands[2] != const1_rtx) | |
10932 | abort (); | |
0f40f9f7 | 10933 | return "add{w}\t{%0, %0|%0, %0}"; |
886c62d1 | 10934 | |
e075ae69 RH |
10935 | default: |
10936 | if (REG_P (operands[2])) | |
0f40f9f7 | 10937 | return "sal{w}\t{%b2, %0|%0, %b2}"; |
8bad7136 JL |
10938 | else if (GET_CODE (operands[2]) == CONST_INT |
10939 | && INTVAL (operands[2]) == 1 | |
10940 | && (TARGET_PENTIUM || TARGET_PENTIUMPRO)) | |
0f40f9f7 | 10941 | return "sal{w}\t%0"; |
e075ae69 | 10942 | else |
0f40f9f7 | 10943 | return "sal{w}\t{%2, %0|%0, %2}"; |
e075ae69 | 10944 | } |
0f40f9f7 | 10945 | } |
e075ae69 RH |
10946 | [(set (attr "type") |
10947 | (cond [(and (and (ne (symbol_ref "TARGET_DOUBLE_WITH_ADD") | |
10948 | (const_int 0)) | |
10949 | (match_operand 0 "register_operand" "")) | |
10950 | (match_operand 2 "const1_operand" "")) | |
10951 | (const_string "alu") | |
10952 | ] | |
6ef67412 JH |
10953 | (const_string "ishift"))) |
10954 | (set_attr "mode" "HI")]) | |
bb62e19a | 10955 | |
28cefcd2 BS |
10956 | ;; This pattern can't accept a variable shift count, since shifts by |
10957 | ;; zero don't affect the flags. We assume that shifts by constant | |
10958 | ;; zero are optimized away. | |
2c873473 | 10959 | (define_insn "*ashlhi3_cmp" |
16189740 RH |
10960 | [(set (reg 17) |
10961 | (compare | |
e075ae69 | 10962 | (ashift:HI (match_operand:HI 1 "nonimmediate_operand" "0") |
28cefcd2 | 10963 | (match_operand:QI 2 "immediate_operand" "I")) |
e075ae69 RH |
10964 | (const_int 0))) |
10965 | (set (match_operand:HI 0 "nonimmediate_operand" "=rm") | |
10966 | (ashift:HI (match_dup 1) (match_dup 2)))] | |
9076b9c1 | 10967 | "ix86_match_ccmode (insn, CCGOCmode) |
16189740 | 10968 | && ix86_binary_operator_ok (ASHIFT, HImode, operands)" |
886c62d1 | 10969 | { |
e075ae69 RH |
10970 | switch (get_attr_type (insn)) |
10971 | { | |
10972 | case TYPE_ALU: | |
10973 | if (operands[2] != const1_rtx) | |
10974 | abort (); | |
0f40f9f7 | 10975 | return "add{w}\t{%0, %0|%0, %0}"; |
886c62d1 | 10976 | |
e075ae69 RH |
10977 | default: |
10978 | if (REG_P (operands[2])) | |
0f40f9f7 | 10979 | return "sal{w}\t{%b2, %0|%0, %b2}"; |
8bad7136 JL |
10980 | else if (GET_CODE (operands[2]) == CONST_INT |
10981 | && INTVAL (operands[2]) == 1 | |
10982 | && (TARGET_PENTIUM || TARGET_PENTIUMPRO)) | |
0f40f9f7 | 10983 | return "sal{w}\t%0"; |
e075ae69 | 10984 | else |
0f40f9f7 | 10985 | return "sal{w}\t{%2, %0|%0, %2}"; |
e075ae69 | 10986 | } |
0f40f9f7 | 10987 | } |
e075ae69 RH |
10988 | [(set (attr "type") |
10989 | (cond [(and (and (ne (symbol_ref "TARGET_DOUBLE_WITH_ADD") | |
10990 | (const_int 0)) | |
10991 | (match_operand 0 "register_operand" "")) | |
10992 | (match_operand 2 "const1_operand" "")) | |
10993 | (const_string "alu") | |
10994 | ] | |
6ef67412 JH |
10995 | (const_string "ishift"))) |
10996 | (set_attr "mode" "HI")]) | |
e075ae69 | 10997 | |
d525dfdf JH |
10998 | (define_expand "ashlqi3" |
10999 | [(set (match_operand:QI 0 "nonimmediate_operand" "") | |
11000 | (ashift:QI (match_operand:QI 1 "nonimmediate_operand" "") | |
11001 | (match_operand:QI 2 "nonmemory_operand" ""))) | |
11002 | (clobber (reg:CC 17))] | |
d9f32422 | 11003 | "TARGET_QIMODE_MATH" |
d525dfdf JH |
11004 | "ix86_expand_binary_operator (ASHIFT, QImode, operands); DONE;") |
11005 | ||
e075ae69 | 11006 | ;; %%% Potential partial reg stall on alternative 2. What to do? |
58787064 JH |
11007 | |
11008 | (define_insn "*ashlqi3_1_lea" | |
11009 | [(set (match_operand:QI 0 "nonimmediate_operand" "=qm,r,r") | |
11010 | (ashift:QI (match_operand:QI 1 "nonimmediate_operand" "0,0,r") | |
91f9a498 | 11011 | (match_operand:QI 2 "nonmemory_operand" "cI,cI,M"))) |
58787064 JH |
11012 | (clobber (reg:CC 17))] |
11013 | "!TARGET_PARTIAL_REG_STALL | |
11014 | && ix86_binary_operator_ok (ASHIFT, QImode, operands)" | |
58787064 JH |
11015 | { |
11016 | switch (get_attr_type (insn)) | |
11017 | { | |
11018 | case TYPE_LEA: | |
0f40f9f7 | 11019 | return "#"; |
58787064 JH |
11020 | case TYPE_ALU: |
11021 | if (operands[2] != const1_rtx) | |
11022 | abort (); | |
1a06f5fe | 11023 | if (REG_P (operands[1]) && !ANY_QI_REG_P (operands[1])) |
0f40f9f7 | 11024 | return "add{l}\t{%k0, %k0|%k0, %k0}"; |
58787064 | 11025 | else |
0f40f9f7 | 11026 | return "add{b}\t{%0, %0|%0, %0}"; |
58787064 JH |
11027 | |
11028 | default: | |
11029 | if (REG_P (operands[2])) | |
11030 | { | |
11031 | if (get_attr_mode (insn) == MODE_SI) | |
0f40f9f7 | 11032 | return "sal{l}\t{%b2, %k0|%k0, %b2}"; |
58787064 | 11033 | else |
0f40f9f7 | 11034 | return "sal{b}\t{%b2, %0|%0, %b2}"; |
58787064 JH |
11035 | } |
11036 | else if (GET_CODE (operands[2]) == CONST_INT | |
11037 | && INTVAL (operands[2]) == 1 | |
11038 | && (TARGET_PENTIUM || TARGET_PENTIUMPRO)) | |
11039 | { | |
11040 | if (get_attr_mode (insn) == MODE_SI) | |
0f40f9f7 | 11041 | return "sal{l}\t%0"; |
58787064 | 11042 | else |
0f40f9f7 | 11043 | return "sal{b}\t%0"; |
58787064 JH |
11044 | } |
11045 | else | |
11046 | { | |
11047 | if (get_attr_mode (insn) == MODE_SI) | |
0f40f9f7 | 11048 | return "sal{l}\t{%2, %k0|%k0, %2}"; |
58787064 | 11049 | else |
0f40f9f7 | 11050 | return "sal{b}\t{%2, %0|%0, %2}"; |
58787064 JH |
11051 | } |
11052 | } | |
0f40f9f7 | 11053 | } |
58787064 JH |
11054 | [(set (attr "type") |
11055 | (cond [(eq_attr "alternative" "2") | |
11056 | (const_string "lea") | |
11057 | (and (and (ne (symbol_ref "TARGET_DOUBLE_WITH_ADD") | |
11058 | (const_int 0)) | |
11059 | (match_operand 0 "register_operand" "")) | |
11060 | (match_operand 2 "const1_operand" "")) | |
11061 | (const_string "alu") | |
11062 | ] | |
11063 | (const_string "ishift"))) | |
11064 | (set_attr "mode" "QI,SI,SI")]) | |
11065 | ||
d525dfdf JH |
11066 | (define_insn "*ashlqi3_1" |
11067 | [(set (match_operand:QI 0 "nonimmediate_operand" "=qm,r") | |
e075ae69 RH |
11068 | (ashift:QI (match_operand:QI 1 "nonimmediate_operand" "0,0") |
11069 | (match_operand:QI 2 "nonmemory_operand" "cI,cI"))) | |
11070 | (clobber (reg:CC 17))] | |
58787064 JH |
11071 | "TARGET_PARTIAL_REG_STALL |
11072 | && ix86_binary_operator_ok (ASHIFT, QImode, operands)" | |
886c62d1 | 11073 | { |
e075ae69 RH |
11074 | switch (get_attr_type (insn)) |
11075 | { | |
11076 | case TYPE_ALU: | |
11077 | if (operands[2] != const1_rtx) | |
11078 | abort (); | |
1a06f5fe | 11079 | if (REG_P (operands[1]) && !ANY_QI_REG_P (operands[1])) |
0f40f9f7 | 11080 | return "add{l}\t{%k0, %k0|%k0, %k0}"; |
e075ae69 | 11081 | else |
0f40f9f7 | 11082 | return "add{b}\t{%0, %0|%0, %0}"; |
886c62d1 | 11083 | |
e075ae69 RH |
11084 | default: |
11085 | if (REG_P (operands[2])) | |
11086 | { | |
1a06f5fe | 11087 | if (get_attr_mode (insn) == MODE_SI) |
0f40f9f7 | 11088 | return "sal{l}\t{%b2, %k0|%k0, %b2}"; |
e075ae69 | 11089 | else |
0f40f9f7 | 11090 | return "sal{b}\t{%b2, %0|%0, %b2}"; |
e075ae69 | 11091 | } |
8bad7136 JL |
11092 | else if (GET_CODE (operands[2]) == CONST_INT |
11093 | && INTVAL (operands[2]) == 1 | |
11094 | && (TARGET_PENTIUM || TARGET_PENTIUMPRO)) | |
11095 | { | |
1a06f5fe | 11096 | if (get_attr_mode (insn) == MODE_SI) |
0f40f9f7 | 11097 | return "sal{l}\t%0"; |
8bad7136 | 11098 | else |
0f40f9f7 | 11099 | return "sal{b}\t%0"; |
8bad7136 | 11100 | } |
e075ae69 RH |
11101 | else |
11102 | { | |
1a06f5fe | 11103 | if (get_attr_mode (insn) == MODE_SI) |
0f40f9f7 | 11104 | return "sal{l}\t{%2, %k0|%k0, %2}"; |
e075ae69 | 11105 | else |
0f40f9f7 | 11106 | return "sal{b}\t{%2, %0|%0, %2}"; |
e075ae69 RH |
11107 | } |
11108 | } | |
0f40f9f7 | 11109 | } |
e075ae69 RH |
11110 | [(set (attr "type") |
11111 | (cond [(and (and (ne (symbol_ref "TARGET_DOUBLE_WITH_ADD") | |
11112 | (const_int 0)) | |
11113 | (match_operand 0 "register_operand" "")) | |
11114 | (match_operand 2 "const1_operand" "")) | |
11115 | (const_string "alu") | |
11116 | ] | |
6ef67412 JH |
11117 | (const_string "ishift"))) |
11118 | (set_attr "mode" "QI,SI")]) | |
e075ae69 | 11119 | |
28cefcd2 BS |
11120 | ;; This pattern can't accept a variable shift count, since shifts by |
11121 | ;; zero don't affect the flags. We assume that shifts by constant | |
11122 | ;; zero are optimized away. | |
2c873473 | 11123 | (define_insn "*ashlqi3_cmp" |
16189740 RH |
11124 | [(set (reg 17) |
11125 | (compare | |
e075ae69 | 11126 | (ashift:QI (match_operand:QI 1 "nonimmediate_operand" "0") |
28cefcd2 | 11127 | (match_operand:QI 2 "immediate_operand" "I")) |
e075ae69 RH |
11128 | (const_int 0))) |
11129 | (set (match_operand:QI 0 "nonimmediate_operand" "=qm") | |
11130 | (ashift:QI (match_dup 1) (match_dup 2)))] | |
9076b9c1 | 11131 | "ix86_match_ccmode (insn, CCGOCmode) |
16189740 | 11132 | && ix86_binary_operator_ok (ASHIFT, QImode, operands)" |
886c62d1 | 11133 | { |
e075ae69 RH |
11134 | switch (get_attr_type (insn)) |
11135 | { | |
11136 | case TYPE_ALU: | |
11137 | if (operands[2] != const1_rtx) | |
11138 | abort (); | |
0f40f9f7 | 11139 | return "add{b}\t{%0, %0|%0, %0}"; |
e075ae69 RH |
11140 | |
11141 | default: | |
11142 | if (REG_P (operands[2])) | |
0f40f9f7 | 11143 | return "sal{b}\t{%b2, %0|%0, %b2}"; |
8bad7136 JL |
11144 | else if (GET_CODE (operands[2]) == CONST_INT |
11145 | && INTVAL (operands[2]) == 1 | |
11146 | && (TARGET_PENTIUM || TARGET_PENTIUMPRO)) | |
0f40f9f7 | 11147 | return "sal{b}\t%0"; |
e075ae69 | 11148 | else |
0f40f9f7 | 11149 | return "sal{b}\t{%2, %0|%0, %2}"; |
e075ae69 | 11150 | } |
0f40f9f7 | 11151 | } |
e075ae69 RH |
11152 | [(set (attr "type") |
11153 | (cond [(and (and (ne (symbol_ref "TARGET_DOUBLE_WITH_ADD") | |
11154 | (const_int 0)) | |
11155 | (match_operand 0 "register_operand" "")) | |
11156 | (match_operand 2 "const1_operand" "")) | |
11157 | (const_string "alu") | |
11158 | ] | |
6ef67412 JH |
11159 | (const_string "ishift"))) |
11160 | (set_attr "mode" "QI")]) | |
886c62d1 JVA |
11161 | |
11162 | ;; See comment above `ashldi3' about how this works. | |
11163 | ||
e075ae69 | 11164 | (define_expand "ashrdi3" |
371bc54b JH |
11165 | [(parallel [(set (match_operand:DI 0 "shiftdi_operand" "") |
11166 | (ashiftrt:DI (match_operand:DI 1 "shiftdi_operand" "") | |
11167 | (match_operand:QI 2 "nonmemory_operand" ""))) | |
e075ae69 | 11168 | (clobber (reg:CC 17))])] |
56c0e8fa | 11169 | "" |
56c0e8fa | 11170 | { |
371bc54b | 11171 | if (!TARGET_64BIT && TARGET_CMOVE && ! immediate_operand (operands[2], QImode)) |
56c0e8fa | 11172 | { |
e075ae69 RH |
11173 | emit_insn (gen_ashrdi3_1 (operands[0], operands[1], operands[2])); |
11174 | DONE; | |
56c0e8fa | 11175 | } |
371bc54b JH |
11176 | ix86_expand_binary_operator (ASHIFTRT, DImode, operands); |
11177 | DONE; | |
0f40f9f7 | 11178 | }) |
2ae0f82c | 11179 | |
371bc54b JH |
11180 | (define_insn "ashrdi3_63_rex64" |
11181 | [(set (match_operand:DI 0 "nonimmediate_operand" "=*d,rm") | |
11182 | (ashiftrt:DI (match_operand:DI 1 "nonimmediate_operand" "*a,0") | |
11183 | (match_operand:DI 2 "const_int_operand" "i,i"))) | |
11184 | (clobber (reg:CC 17))] | |
11185 | "TARGET_64BIT && INTVAL (operands[2]) == 63 && (TARGET_USE_CLTD || optimize_size) | |
11186 | && ix86_binary_operator_ok (ASHIFTRT, DImode, operands)" | |
11187 | "@ | |
11188 | {cqto|cqo} | |
0f40f9f7 | 11189 | sar{q}\t{%2, %0|%0, %2}" |
371bc54b JH |
11190 | [(set_attr "type" "imovx,ishift") |
11191 | (set_attr "prefix_0f" "0,*") | |
11192 | (set_attr "length_immediate" "0,*") | |
11193 | (set_attr "modrm" "0,1") | |
11194 | (set_attr "mode" "DI")]) | |
11195 | ||
11196 | (define_insn "*ashrdi3_1_one_bit_rex64" | |
11197 | [(set (match_operand:DI 0 "nonimmediate_operand" "=rm") | |
11198 | (ashiftrt:DI (match_operand:DI 1 "nonimmediate_operand" "0") | |
11199 | (match_operand:QI 2 "const_int_1_operand" ""))) | |
11200 | (clobber (reg:CC 17))] | |
11201 | "TARGET_64BIT && ix86_binary_operator_ok (ASHIFTRT, DImode, operands) | |
11202 | && (TARGET_PENTIUM || TARGET_PENTIUMPRO)" | |
0f40f9f7 | 11203 | "sar{q}\t%0" |
371bc54b JH |
11204 | [(set_attr "type" "ishift") |
11205 | (set (attr "length") | |
11206 | (if_then_else (match_operand:DI 0 "register_operand" "") | |
11207 | (const_string "2") | |
11208 | (const_string "*")))]) | |
11209 | ||
11210 | (define_insn "*ashrdi3_1_rex64" | |
11211 | [(set (match_operand:DI 0 "nonimmediate_operand" "=rm,rm") | |
11212 | (ashiftrt:DI (match_operand:DI 1 "nonimmediate_operand" "0,0") | |
7c17f553 | 11213 | (match_operand:QI 2 "nonmemory_operand" "J,c"))) |
371bc54b JH |
11214 | (clobber (reg:CC 17))] |
11215 | "TARGET_64BIT && ix86_binary_operator_ok (ASHIFTRT, DImode, operands)" | |
11216 | "@ | |
0f40f9f7 ZW |
11217 | sar{q}\t{%2, %0|%0, %2} |
11218 | sar{q}\t{%b2, %0|%0, %b2}" | |
371bc54b JH |
11219 | [(set_attr "type" "ishift") |
11220 | (set_attr "mode" "DI")]) | |
11221 | ||
11222 | ;; This pattern can't accept a variable shift count, since shifts by | |
11223 | ;; zero don't affect the flags. We assume that shifts by constant | |
11224 | ;; zero are optimized away. | |
11225 | (define_insn "*ashrdi3_one_bit_cmp_rex64" | |
11226 | [(set (reg 17) | |
11227 | (compare | |
11228 | (ashiftrt:DI (match_operand:DI 1 "nonimmediate_operand" "0") | |
11229 | (match_operand:QI 2 "const_int_1_operand" "")) | |
11230 | (const_int 0))) | |
11231 | (set (match_operand:DI 0 "nonimmediate_operand" "=rm") | |
11232 | (ashiftrt:DI (match_dup 1) (match_dup 2)))] | |
11233 | "TARGET_64BIT && ix86_match_ccmode (insn, CCGOCmode) | |
11234 | && (TARGET_PENTIUM || TARGET_PENTIUMPRO) | |
11235 | && ix86_binary_operator_ok (ASHIFTRT, DImode, operands)" | |
0f40f9f7 | 11236 | "sar{q}\t%0" |
371bc54b JH |
11237 | [(set_attr "type" "ishift") |
11238 | (set (attr "length") | |
11239 | (if_then_else (match_operand:DI 0 "register_operand" "") | |
11240 | (const_string "2") | |
11241 | (const_string "*")))]) | |
11242 | ||
11243 | ;; This pattern can't accept a variable shift count, since shifts by | |
11244 | ;; zero don't affect the flags. We assume that shifts by constant | |
11245 | ;; zero are optimized away. | |
11246 | (define_insn "*ashrdi3_cmp_rex64" | |
11247 | [(set (reg 17) | |
11248 | (compare | |
11249 | (ashiftrt:DI (match_operand:DI 1 "nonimmediate_operand" "0") | |
11250 | (match_operand:QI 2 "const_int_operand" "n")) | |
11251 | (const_int 0))) | |
11252 | (set (match_operand:DI 0 "nonimmediate_operand" "=rm") | |
11253 | (ashiftrt:DI (match_dup 1) (match_dup 2)))] | |
11254 | "TARGET_64BIT && ix86_match_ccmode (insn, CCGOCmode) | |
11255 | && ix86_binary_operator_ok (ASHIFTRT, DImode, operands)" | |
0f40f9f7 | 11256 | "sar{q}\t{%2, %0|%0, %2}" |
371bc54b JH |
11257 | [(set_attr "type" "ishift") |
11258 | (set_attr "mode" "DI")]) | |
11259 | ||
11260 | ||
e075ae69 RH |
11261 | (define_insn "ashrdi3_1" |
11262 | [(set (match_operand:DI 0 "register_operand" "=r") | |
11263 | (ashiftrt:DI (match_operand:DI 1 "register_operand" "0") | |
11264 | (match_operand:QI 2 "nonmemory_operand" "Jc"))) | |
11265 | (clobber (match_scratch:SI 3 "=&r")) | |
11266 | (clobber (reg:CC 17))] | |
371bc54b | 11267 | "!TARGET_64BIT && TARGET_CMOVE" |
e075ae69 RH |
11268 | "#" |
11269 | [(set_attr "type" "multi")]) | |
886c62d1 | 11270 | |
e075ae69 RH |
11271 | (define_insn "*ashrdi3_2" |
11272 | [(set (match_operand:DI 0 "register_operand" "=r") | |
11273 | (ashiftrt:DI (match_operand:DI 1 "register_operand" "0") | |
11274 | (match_operand:QI 2 "nonmemory_operand" "Jc"))) | |
11275 | (clobber (reg:CC 17))] | |
371bc54b | 11276 | "!TARGET_64BIT" |
e075ae69 RH |
11277 | "#" |
11278 | [(set_attr "type" "multi")]) | |
886c62d1 | 11279 | |
e075ae69 RH |
11280 | (define_split |
11281 | [(set (match_operand:DI 0 "register_operand" "") | |
11282 | (ashiftrt:DI (match_operand:DI 1 "register_operand" "") | |
11283 | (match_operand:QI 2 "nonmemory_operand" ""))) | |
11284 | (clobber (match_scratch:SI 3 "")) | |
11285 | (clobber (reg:CC 17))] | |
371bc54b | 11286 | "!TARGET_64BIT && TARGET_CMOVE && reload_completed" |
e075ae69 RH |
11287 | [(const_int 0)] |
11288 | "ix86_split_ashrdi (operands, operands[3]); DONE;") | |
886c62d1 | 11289 | |
e075ae69 RH |
11290 | (define_split |
11291 | [(set (match_operand:DI 0 "register_operand" "") | |
11292 | (ashiftrt:DI (match_operand:DI 1 "register_operand" "") | |
11293 | (match_operand:QI 2 "nonmemory_operand" ""))) | |
11294 | (clobber (reg:CC 17))] | |
371bc54b | 11295 | "!TARGET_64BIT && reload_completed" |
e075ae69 RH |
11296 | [(const_int 0)] |
11297 | "ix86_split_ashrdi (operands, NULL_RTX); DONE;") | |
886c62d1 | 11298 | |
e075ae69 RH |
11299 | (define_insn "x86_shrd_1" |
11300 | [(set (match_operand:SI 0 "nonimmediate_operand" "+r*m,r*m") | |
11301 | (ior:SI (ashiftrt:SI (match_dup 0) | |
11302 | (match_operand:QI 2 "nonmemory_operand" "I,c")) | |
11303 | (ashift:SI (match_operand:SI 1 "register_operand" "r,r") | |
11304 | (minus:QI (const_int 32) (match_dup 2))))) | |
11305 | (clobber (reg:CC 17))] | |
886c62d1 | 11306 | "" |
e075ae69 | 11307 | "@ |
0f40f9f7 ZW |
11308 | shrd{l}\t{%2, %1, %0|%0, %1, %2} |
11309 | shrd{l}\t{%s2%1, %0|%0, %1, %2}" | |
e075ae69 | 11310 | [(set_attr "type" "ishift") |
6ef67412 | 11311 | (set_attr "prefix_0f" "1") |
e075ae69 | 11312 | (set_attr "pent_pair" "np") |
6ef67412 JH |
11313 | (set_attr "ppro_uops" "few") |
11314 | (set_attr "mode" "SI")]) | |
e075ae69 RH |
11315 | |
11316 | (define_expand "x86_shift_adj_3" | |
11317 | [(use (match_operand:SI 0 "register_operand" "")) | |
11318 | (use (match_operand:SI 1 "register_operand" "")) | |
11319 | (use (match_operand:QI 2 "register_operand" ""))] | |
11320 | "" | |
886c62d1 | 11321 | { |
e075ae69 RH |
11322 | rtx label = gen_label_rtx (); |
11323 | rtx tmp; | |
11324 | ||
16189740 | 11325 | emit_insn (gen_testqi_ccz_1 (operands[2], GEN_INT (32))); |
e075ae69 | 11326 | |
16189740 | 11327 | tmp = gen_rtx_REG (CCZmode, FLAGS_REG); |
e075ae69 RH |
11328 | tmp = gen_rtx_EQ (VOIDmode, tmp, const0_rtx); |
11329 | tmp = gen_rtx_IF_THEN_ELSE (VOIDmode, tmp, | |
11330 | gen_rtx_LABEL_REF (VOIDmode, label), | |
11331 | pc_rtx); | |
11332 | tmp = emit_jump_insn (gen_rtx_SET (VOIDmode, pc_rtx, tmp)); | |
11333 | JUMP_LABEL (tmp) = label; | |
11334 | ||
11335 | emit_move_insn (operands[0], operands[1]); | |
11336 | emit_insn (gen_ashrsi3_31 (operands[1], operands[1], GEN_INT (31))); | |
11337 | ||
11338 | emit_label (label); | |
11339 | LABEL_NUSES (label) = 1; | |
11340 | ||
11341 | DONE; | |
0f40f9f7 | 11342 | }) |
886c62d1 | 11343 | |
e075ae69 RH |
11344 | (define_insn "ashrsi3_31" |
11345 | [(set (match_operand:SI 0 "nonimmediate_operand" "=*d,rm") | |
11346 | (ashiftrt:SI (match_operand:SI 1 "nonimmediate_operand" "*a,0") | |
11347 | (match_operand:SI 2 "const_int_operand" "i,i"))) | |
11348 | (clobber (reg:CC 17))] | |
d525dfdf JH |
11349 | "INTVAL (operands[2]) == 31 && (TARGET_USE_CLTD || optimize_size) |
11350 | && ix86_binary_operator_ok (ASHIFTRT, SImode, operands)" | |
e075ae69 RH |
11351 | "@ |
11352 | {cltd|cdq} | |
0f40f9f7 | 11353 | sar{l}\t{%2, %0|%0, %2}" |
6ef67412 JH |
11354 | [(set_attr "type" "imovx,ishift") |
11355 | (set_attr "prefix_0f" "0,*") | |
11356 | (set_attr "length_immediate" "0,*") | |
11357 | (set_attr "modrm" "0,1") | |
11358 | (set_attr "mode" "SI")]) | |
e075ae69 | 11359 | |
371bc54b JH |
11360 | (define_insn "*ashrsi3_31_zext" |
11361 | [(set (match_operand:DI 0 "register_operand" "=*d,r") | |
11362 | (zero_extend:DI (ashiftrt:SI (match_operand:SI 1 "register_operand" "*a,0") | |
11363 | (match_operand:SI 2 "const_int_operand" "i,i")))) | |
11364 | (clobber (reg:CC 17))] | |
1b0c37d7 ZW |
11365 | "TARGET_64BIT && (TARGET_USE_CLTD || optimize_size) |
11366 | && INTVAL (operands[2]) == 31 | |
11367 | && ix86_binary_operator_ok (ASHIFTRT, SImode, operands)" | |
371bc54b JH |
11368 | "@ |
11369 | {cltd|cdq} | |
0f40f9f7 | 11370 | sar{l}\t{%2, %k0|%k0, %2}" |
371bc54b JH |
11371 | [(set_attr "type" "imovx,ishift") |
11372 | (set_attr "prefix_0f" "0,*") | |
11373 | (set_attr "length_immediate" "0,*") | |
11374 | (set_attr "modrm" "0,1") | |
11375 | (set_attr "mode" "SI")]) | |
11376 | ||
d525dfdf JH |
11377 | (define_expand "ashrsi3" |
11378 | [(set (match_operand:SI 0 "nonimmediate_operand" "") | |
155d8a47 | 11379 | (ashiftrt:SI (match_operand:SI 1 "nonimmediate_operand" "") |
d525dfdf JH |
11380 | (match_operand:QI 2 "nonmemory_operand" ""))) |
11381 | (clobber (reg:CC 17))] | |
11382 | "" | |
11383 | "ix86_expand_binary_operator (ASHIFTRT, SImode, operands); DONE;") | |
11384 | ||
8bad7136 JL |
11385 | (define_insn "*ashrsi3_1_one_bit" |
11386 | [(set (match_operand:SI 0 "nonimmediate_operand" "=rm") | |
11387 | (ashiftrt:SI (match_operand:SI 1 "nonimmediate_operand" "0") | |
11388 | (match_operand:QI 2 "const_int_1_operand" ""))) | |
11389 | (clobber (reg:CC 17))] | |
11390 | "ix86_binary_operator_ok (ASHIFTRT, SImode, operands) | |
11391 | && (TARGET_PENTIUM || TARGET_PENTIUMPRO)" | |
0f40f9f7 | 11392 | "sar{l}\t%0" |
8bad7136 JL |
11393 | [(set_attr "type" "ishift") |
11394 | (set (attr "length") | |
11395 | (if_then_else (match_operand:SI 0 "register_operand" "") | |
11396 | (const_string "2") | |
11397 | (const_string "*")))]) | |
11398 | ||
371bc54b JH |
11399 | (define_insn "*ashrsi3_1_one_bit_zext" |
11400 | [(set (match_operand:DI 0 "register_operand" "=r") | |
11401 | (zero_extend:DI (ashiftrt:SI (match_operand:SI 1 "register_operand" "0") | |
11402 | (match_operand:QI 2 "const_int_1_operand" "")))) | |
11403 | (clobber (reg:CC 17))] | |
11404 | "TARGET_64BIT && ix86_binary_operator_ok (ASHIFTRT, SImode, operands) | |
11405 | && (TARGET_PENTIUM || TARGET_PENTIUMPRO)" | |
0f40f9f7 | 11406 | "sar{l}\t%k0" |
371bc54b JH |
11407 | [(set_attr "type" "ishift") |
11408 | (set_attr "length" "2")]) | |
11409 | ||
d525dfdf | 11410 | (define_insn "*ashrsi3_1" |
e075ae69 RH |
11411 | [(set (match_operand:SI 0 "nonimmediate_operand" "=rm,rm") |
11412 | (ashiftrt:SI (match_operand:SI 1 "nonimmediate_operand" "0,0") | |
11413 | (match_operand:QI 2 "nonmemory_operand" "I,c"))) | |
11414 | (clobber (reg:CC 17))] | |
d525dfdf | 11415 | "ix86_binary_operator_ok (ASHIFTRT, SImode, operands)" |
e075ae69 | 11416 | "@ |
0f40f9f7 ZW |
11417 | sar{l}\t{%2, %0|%0, %2} |
11418 | sar{l}\t{%b2, %0|%0, %b2}" | |
6ef67412 JH |
11419 | [(set_attr "type" "ishift") |
11420 | (set_attr "mode" "SI")]) | |
886c62d1 | 11421 | |
371bc54b JH |
11422 | (define_insn "*ashrsi3_1_zext" |
11423 | [(set (match_operand:DI 0 "register_operand" "=r,r") | |
11424 | (zero_extend:DI (ashiftrt:SI (match_operand:SI 1 "register_operand" "0,0") | |
11425 | (match_operand:QI 2 "nonmemory_operand" "I,c")))) | |
11426 | (clobber (reg:CC 17))] | |
11427 | "TARGET_64BIT && ix86_binary_operator_ok (ASHIFTRT, SImode, operands)" | |
11428 | "@ | |
0f40f9f7 ZW |
11429 | sar{l}\t{%2, %k0|%k0, %2} |
11430 | sar{l}\t{%b2, %k0|%k0, %b2}" | |
371bc54b JH |
11431 | [(set_attr "type" "ishift") |
11432 | (set_attr "mode" "SI")]) | |
11433 | ||
8bad7136 JL |
11434 | ;; This pattern can't accept a variable shift count, since shifts by |
11435 | ;; zero don't affect the flags. We assume that shifts by constant | |
11436 | ;; zero are optimized away. | |
2c873473 | 11437 | (define_insn "*ashrsi3_one_bit_cmp" |
8bad7136 JL |
11438 | [(set (reg 17) |
11439 | (compare | |
11440 | (ashiftrt:SI (match_operand:SI 1 "nonimmediate_operand" "0") | |
11441 | (match_operand:QI 2 "const_int_1_operand" "")) | |
11442 | (const_int 0))) | |
11443 | (set (match_operand:SI 0 "nonimmediate_operand" "=rm") | |
11444 | (ashiftrt:SI (match_dup 1) (match_dup 2)))] | |
2c873473 | 11445 | "ix86_match_ccmode (insn, CCGOCmode) |
8bad7136 JL |
11446 | && (TARGET_PENTIUM || TARGET_PENTIUMPRO) |
11447 | && ix86_binary_operator_ok (ASHIFTRT, SImode, operands)" | |
0f40f9f7 | 11448 | "sar{l}\t%0" |
8bad7136 JL |
11449 | [(set_attr "type" "ishift") |
11450 | (set (attr "length") | |
11451 | (if_then_else (match_operand:SI 0 "register_operand" "") | |
11452 | (const_string "2") | |
11453 | (const_string "*")))]) | |
11454 | ||
371bc54b JH |
11455 | (define_insn "*ashrsi3_one_bit_cmp_zext" |
11456 | [(set (reg 17) | |
11457 | (compare | |
11458 | (ashiftrt:SI (match_operand:SI 1 "register_operand" "0") | |
11459 | (match_operand:QI 2 "const_int_1_operand" "")) | |
11460 | (const_int 0))) | |
11461 | (set (match_operand:DI 0 "register_operand" "=r") | |
11462 | (zero_extend:DI (ashiftrt:SI (match_dup 1) (match_dup 2))))] | |
11463 | "TARGET_64BIT && ix86_match_ccmode (insn, CCmode) | |
11464 | && (TARGET_PENTIUM || TARGET_PENTIUMPRO) | |
11465 | && ix86_binary_operator_ok (ASHIFTRT, SImode, operands)" | |
0f40f9f7 | 11466 | "sar{l}\t%k0" |
371bc54b JH |
11467 | [(set_attr "type" "ishift") |
11468 | (set_attr "length" "2")]) | |
11469 | ||
28cefcd2 BS |
11470 | ;; This pattern can't accept a variable shift count, since shifts by |
11471 | ;; zero don't affect the flags. We assume that shifts by constant | |
11472 | ;; zero are optimized away. | |
2c873473 | 11473 | (define_insn "*ashrsi3_cmp" |
16189740 RH |
11474 | [(set (reg 17) |
11475 | (compare | |
28cefcd2 BS |
11476 | (ashiftrt:SI (match_operand:SI 1 "nonimmediate_operand" "0") |
11477 | (match_operand:QI 2 "immediate_operand" "I")) | |
e075ae69 | 11478 | (const_int 0))) |
28cefcd2 | 11479 | (set (match_operand:SI 0 "nonimmediate_operand" "=rm") |
e075ae69 | 11480 | (ashiftrt:SI (match_dup 1) (match_dup 2)))] |
2c873473 | 11481 | "ix86_match_ccmode (insn, CCGOCmode) |
16189740 | 11482 | && ix86_binary_operator_ok (ASHIFTRT, SImode, operands)" |
0f40f9f7 | 11483 | "sar{l}\t{%2, %0|%0, %2}" |
6ef67412 JH |
11484 | [(set_attr "type" "ishift") |
11485 | (set_attr "mode" "SI")]) | |
886c62d1 | 11486 | |
371bc54b JH |
11487 | (define_insn "*ashrsi3_cmp_zext" |
11488 | [(set (reg 17) | |
11489 | (compare | |
11490 | (ashiftrt:SI (match_operand:SI 1 "register_operand" "0") | |
11491 | (match_operand:QI 2 "immediate_operand" "I")) | |
11492 | (const_int 0))) | |
11493 | (set (match_operand:DI 0 "register_operand" "=r") | |
11494 | (zero_extend:DI (ashiftrt:SI (match_dup 1) (match_dup 2))))] | |
11495 | "TARGET_64BIT && ix86_match_ccmode (insn, CCGOCmode) | |
11496 | && ix86_binary_operator_ok (ASHIFTRT, SImode, operands)" | |
0f40f9f7 | 11497 | "sar{l}\t{%2, %k0|%k0, %2}" |
371bc54b JH |
11498 | [(set_attr "type" "ishift") |
11499 | (set_attr "mode" "SI")]) | |
11500 | ||
d525dfdf JH |
11501 | (define_expand "ashrhi3" |
11502 | [(set (match_operand:HI 0 "nonimmediate_operand" "") | |
155d8a47 | 11503 | (ashiftrt:HI (match_operand:HI 1 "nonimmediate_operand" "") |
d525dfdf JH |
11504 | (match_operand:QI 2 "nonmemory_operand" ""))) |
11505 | (clobber (reg:CC 17))] | |
d9f32422 | 11506 | "TARGET_HIMODE_MATH" |
d525dfdf JH |
11507 | "ix86_expand_binary_operator (ASHIFTRT, HImode, operands); DONE;") |
11508 | ||
8bad7136 JL |
11509 | (define_insn "*ashrhi3_1_one_bit" |
11510 | [(set (match_operand:HI 0 "nonimmediate_operand" "=rm") | |
11511 | (ashiftrt:HI (match_operand:HI 1 "nonimmediate_operand" "0") | |
11512 | (match_operand:QI 2 "const_int_1_operand" ""))) | |
11513 | (clobber (reg:CC 17))] | |
11514 | "ix86_binary_operator_ok (ASHIFTRT, HImode, operands) | |
11515 | && (TARGET_PENTIUM || TARGET_PENTIUMPRO)" | |
0f40f9f7 | 11516 | "sar{w}\t%0" |
8bad7136 JL |
11517 | [(set_attr "type" "ishift") |
11518 | (set (attr "length") | |
3d117b30 | 11519 | (if_then_else (match_operand 0 "register_operand" "") |
8bad7136 JL |
11520 | (const_string "2") |
11521 | (const_string "*")))]) | |
11522 | ||
d525dfdf | 11523 | (define_insn "*ashrhi3_1" |
e075ae69 RH |
11524 | [(set (match_operand:HI 0 "nonimmediate_operand" "=rm,rm") |
11525 | (ashiftrt:HI (match_operand:HI 1 "nonimmediate_operand" "0,0") | |
11526 | (match_operand:QI 2 "nonmemory_operand" "I,c"))) | |
11527 | (clobber (reg:CC 17))] | |
d525dfdf | 11528 | "ix86_binary_operator_ok (ASHIFTRT, HImode, operands)" |
e075ae69 | 11529 | "@ |
0f40f9f7 ZW |
11530 | sar{w}\t{%2, %0|%0, %2} |
11531 | sar{w}\t{%b2, %0|%0, %b2}" | |
6ef67412 JH |
11532 | [(set_attr "type" "ishift") |
11533 | (set_attr "mode" "HI")]) | |
886c62d1 | 11534 | |
8bad7136 JL |
11535 | ;; This pattern can't accept a variable shift count, since shifts by |
11536 | ;; zero don't affect the flags. We assume that shifts by constant | |
11537 | ;; zero are optimized away. | |
2c873473 | 11538 | (define_insn "*ashrhi3_one_bit_cmp" |
8bad7136 JL |
11539 | [(set (reg 17) |
11540 | (compare | |
11541 | (ashiftrt:HI (match_operand:HI 1 "nonimmediate_operand" "0") | |
11542 | (match_operand:QI 2 "const_int_1_operand" "")) | |
11543 | (const_int 0))) | |
11544 | (set (match_operand:HI 0 "nonimmediate_operand" "=rm") | |
11545 | (ashiftrt:HI (match_dup 1) (match_dup 2)))] | |
2c873473 | 11546 | "ix86_match_ccmode (insn, CCGOCmode) |
8bad7136 JL |
11547 | && (TARGET_PENTIUM || TARGET_PENTIUMPRO) |
11548 | && ix86_binary_operator_ok (ASHIFTRT, HImode, operands)" | |
0f40f9f7 | 11549 | "sar{w}\t%0" |
8bad7136 JL |
11550 | [(set_attr "type" "ishift") |
11551 | (set (attr "length") | |
3d117b30 | 11552 | (if_then_else (match_operand 0 "register_operand" "") |
8bad7136 JL |
11553 | (const_string "2") |
11554 | (const_string "*")))]) | |
11555 | ||
28cefcd2 BS |
11556 | ;; This pattern can't accept a variable shift count, since shifts by |
11557 | ;; zero don't affect the flags. We assume that shifts by constant | |
11558 | ;; zero are optimized away. | |
2c873473 | 11559 | (define_insn "*ashrhi3_cmp" |
16189740 RH |
11560 | [(set (reg 17) |
11561 | (compare | |
28cefcd2 BS |
11562 | (ashiftrt:HI (match_operand:HI 1 "nonimmediate_operand" "0") |
11563 | (match_operand:QI 2 "immediate_operand" "I")) | |
e075ae69 | 11564 | (const_int 0))) |
28cefcd2 | 11565 | (set (match_operand:HI 0 "nonimmediate_operand" "=rm") |
e075ae69 | 11566 | (ashiftrt:HI (match_dup 1) (match_dup 2)))] |
2c873473 | 11567 | "ix86_match_ccmode (insn, CCGOCmode) |
16189740 | 11568 | && ix86_binary_operator_ok (ASHIFTRT, HImode, operands)" |
0f40f9f7 | 11569 | "sar{w}\t{%2, %0|%0, %2}" |
6ef67412 JH |
11570 | [(set_attr "type" "ishift") |
11571 | (set_attr "mode" "HI")]) | |
886c62d1 | 11572 | |
d525dfdf JH |
11573 | (define_expand "ashrqi3" |
11574 | [(set (match_operand:QI 0 "nonimmediate_operand" "") | |
155d8a47 | 11575 | (ashiftrt:QI (match_operand:QI 1 "nonimmediate_operand" "") |
d525dfdf JH |
11576 | (match_operand:QI 2 "nonmemory_operand" ""))) |
11577 | (clobber (reg:CC 17))] | |
d9f32422 | 11578 | "TARGET_QIMODE_MATH" |
d525dfdf JH |
11579 | "ix86_expand_binary_operator (ASHIFTRT, QImode, operands); DONE;") |
11580 | ||
8bad7136 JL |
11581 | (define_insn "*ashrqi3_1_one_bit" |
11582 | [(set (match_operand:QI 0 "nonimmediate_operand" "=qm") | |
11583 | (ashiftrt:QI (match_operand:QI 1 "nonimmediate_operand" "0") | |
11584 | (match_operand:QI 2 "const_int_1_operand" ""))) | |
11585 | (clobber (reg:CC 17))] | |
11586 | "ix86_binary_operator_ok (ASHIFTRT, QImode, operands) | |
11587 | && (TARGET_PENTIUM || TARGET_PENTIUMPRO)" | |
0f40f9f7 | 11588 | "sar{b}\t%0" |
8bad7136 JL |
11589 | [(set_attr "type" "ishift") |
11590 | (set (attr "length") | |
3d117b30 | 11591 | (if_then_else (match_operand 0 "register_operand" "") |
8bad7136 JL |
11592 | (const_string "2") |
11593 | (const_string "*")))]) | |
11594 | ||
d525dfdf | 11595 | (define_insn "*ashrqi3_1" |
e075ae69 RH |
11596 | [(set (match_operand:QI 0 "nonimmediate_operand" "=qm,qm") |
11597 | (ashiftrt:QI (match_operand:QI 1 "nonimmediate_operand" "0,0") | |
11598 | (match_operand:QI 2 "nonmemory_operand" "I,c"))) | |
11599 | (clobber (reg:CC 17))] | |
d525dfdf | 11600 | "ix86_binary_operator_ok (ASHIFTRT, QImode, operands)" |
e075ae69 | 11601 | "@ |
0f40f9f7 ZW |
11602 | sar{b}\t{%2, %0|%0, %2} |
11603 | sar{b}\t{%b2, %0|%0, %b2}" | |
6ef67412 JH |
11604 | [(set_attr "type" "ishift") |
11605 | (set_attr "mode" "QI")]) | |
886c62d1 | 11606 | |
8bad7136 JL |
11607 | ;; This pattern can't accept a variable shift count, since shifts by |
11608 | ;; zero don't affect the flags. We assume that shifts by constant | |
11609 | ;; zero are optimized away. | |
2c873473 | 11610 | (define_insn "*ashrqi3_one_bit_cmp" |
8bad7136 JL |
11611 | [(set (reg 17) |
11612 | (compare | |
11613 | (ashiftrt:QI (match_operand:QI 1 "nonimmediate_operand" "0") | |
11614 | (match_operand:QI 2 "const_int_1_operand" "I")) | |
11615 | (const_int 0))) | |
11616 | (set (match_operand:QI 0 "nonimmediate_operand" "=rm") | |
11617 | (ashiftrt:QI (match_dup 1) (match_dup 2)))] | |
2c873473 | 11618 | "ix86_match_ccmode (insn, CCGOCmode) |
8bad7136 JL |
11619 | && (TARGET_PENTIUM || TARGET_PENTIUMPRO) |
11620 | && ix86_binary_operator_ok (ASHIFTRT, QImode, operands)" | |
0f40f9f7 | 11621 | "sar{b}\t%0" |
8bad7136 JL |
11622 | [(set_attr "type" "ishift") |
11623 | (set (attr "length") | |
3d117b30 | 11624 | (if_then_else (match_operand 0 "register_operand" "") |
8bad7136 JL |
11625 | (const_string "2") |
11626 | (const_string "*")))]) | |
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 "*ashrqi3_cmp" |
16189740 RH |
11632 | [(set (reg 17) |
11633 | (compare | |
28cefcd2 BS |
11634 | (ashiftrt:QI (match_operand:QI 1 "nonimmediate_operand" "0") |
11635 | (match_operand:QI 2 "immediate_operand" "I")) | |
e075ae69 | 11636 | (const_int 0))) |
28cefcd2 | 11637 | (set (match_operand:QI 0 "nonimmediate_operand" "=rm") |
e075ae69 | 11638 | (ashiftrt:QI (match_dup 1) (match_dup 2)))] |
2c873473 | 11639 | "ix86_match_ccmode (insn, CCGOCmode) |
16189740 | 11640 | && ix86_binary_operator_ok (ASHIFTRT, QImode, operands)" |
0f40f9f7 | 11641 | "sar{b}\t{%2, %0|%0, %2}" |
6ef67412 JH |
11642 | [(set_attr "type" "ishift") |
11643 | (set_attr "mode" "QI")]) | |
886c62d1 | 11644 | \f |
e075ae69 RH |
11645 | ;; Logical shift instructions |
11646 | ||
11647 | ;; See comment above `ashldi3' about how this works. | |
11648 | ||
11649 | (define_expand "lshrdi3" | |
371bc54b JH |
11650 | [(parallel [(set (match_operand:DI 0 "shiftdi_operand" "") |
11651 | (lshiftrt:DI (match_operand:DI 1 "shiftdi_operand" "") | |
11652 | (match_operand:QI 2 "nonmemory_operand" ""))) | |
e075ae69 | 11653 | (clobber (reg:CC 17))])] |
886c62d1 | 11654 | "" |
886c62d1 | 11655 | { |
371bc54b | 11656 | if (!TARGET_64BIT && TARGET_CMOVE && ! immediate_operand (operands[2], QImode)) |
886c62d1 | 11657 | { |
e075ae69 RH |
11658 | emit_insn (gen_lshrdi3_1 (operands[0], operands[1], operands[2])); |
11659 | DONE; | |
886c62d1 | 11660 | } |
371bc54b JH |
11661 | ix86_expand_binary_operator (LSHIFTRT, DImode, operands); |
11662 | DONE; | |
0f40f9f7 | 11663 | }) |
886c62d1 | 11664 | |
371bc54b JH |
11665 | (define_insn "*lshrdi3_1_one_bit_rex64" |
11666 | [(set (match_operand:DI 0 "nonimmediate_operand" "=rm") | |
11667 | (lshiftrt:DI (match_operand:DI 1 "nonimmediate_operand" "0") | |
11668 | (match_operand:QI 2 "const_int_1_operand" ""))) | |
11669 | (clobber (reg:CC 17))] | |
11670 | "TARGET_64BIT && ix86_binary_operator_ok (LSHIFTRT, HImode, operands) | |
11671 | && (TARGET_PENTIUM || TARGET_PENTIUMPRO)" | |
0f40f9f7 | 11672 | "shr{q}\t%0" |
371bc54b JH |
11673 | [(set_attr "type" "ishift") |
11674 | (set (attr "length") | |
11675 | (if_then_else (match_operand:DI 0 "register_operand" "") | |
11676 | (const_string "2") | |
11677 | (const_string "*")))]) | |
11678 | ||
11679 | (define_insn "*lshrdi3_1_rex64" | |
11680 | [(set (match_operand:DI 0 "nonimmediate_operand" "=rm,rm") | |
11681 | (lshiftrt:DI (match_operand:DI 1 "nonimmediate_operand" "0,0") | |
11682 | (match_operand:QI 2 "nonmemory_operand" "J,c"))) | |
11683 | (clobber (reg:CC 17))] | |
11684 | "TARGET_64BIT && ix86_binary_operator_ok (LSHIFTRT, HImode, operands)" | |
11685 | "@ | |
0f40f9f7 ZW |
11686 | shr{q}\t{%2, %0|%0, %2} |
11687 | shr{q}\t{%b2, %0|%0, %b2}" | |
371bc54b JH |
11688 | [(set_attr "type" "ishift") |
11689 | (set_attr "mode" "DI")]) | |
11690 | ||
11691 | ;; This pattern can't accept a variable shift count, since shifts by | |
11692 | ;; zero don't affect the flags. We assume that shifts by constant | |
11693 | ;; zero are optimized away. | |
11694 | (define_insn "*lshrdi3_cmp_one_bit_rex64" | |
11695 | [(set (reg 17) | |
11696 | (compare | |
11697 | (lshiftrt:DI (match_operand:DI 1 "nonimmediate_operand" "0") | |
11698 | (match_operand:QI 2 "const_int_1_operand" "")) | |
11699 | (const_int 0))) | |
11700 | (set (match_operand:DI 0 "nonimmediate_operand" "=rm") | |
11701 | (lshiftrt:DI (match_dup 1) (match_dup 2)))] | |
11702 | "TARGET_64BIT && ix86_match_ccmode (insn, CCGOCmode) | |
11703 | && (TARGET_PENTIUM || TARGET_PENTIUMPRO) | |
11704 | && ix86_binary_operator_ok (LSHIFTRT, HImode, operands)" | |
0f40f9f7 | 11705 | "shr{q}\t%0" |
371bc54b JH |
11706 | [(set_attr "type" "ishift") |
11707 | (set (attr "length") | |
11708 | (if_then_else (match_operand:DI 0 "register_operand" "") | |
11709 | (const_string "2") | |
11710 | (const_string "*")))]) | |
11711 | ||
11712 | ;; This pattern can't accept a variable shift count, since shifts by | |
11713 | ;; zero don't affect the flags. We assume that shifts by constant | |
11714 | ;; zero are optimized away. | |
11715 | (define_insn "*lshrdi3_cmp_rex64" | |
11716 | [(set (reg 17) | |
11717 | (compare | |
11718 | (lshiftrt:DI (match_operand:DI 1 "nonimmediate_operand" "0") | |
11719 | (match_operand:QI 2 "const_int_operand" "e")) | |
11720 | (const_int 0))) | |
11721 | (set (match_operand:DI 0 "nonimmediate_operand" "=rm") | |
11722 | (lshiftrt:DI (match_dup 1) (match_dup 2)))] | |
11723 | "TARGET_64BIT && ix86_match_ccmode (insn, CCGOCmode) | |
11724 | && ix86_binary_operator_ok (LSHIFTRT, HImode, operands)" | |
0f40f9f7 | 11725 | "shr{q}\t{%2, %0|%0, %2}" |
371bc54b JH |
11726 | [(set_attr "type" "ishift") |
11727 | (set_attr "mode" "DI")]) | |
11728 | ||
e075ae69 RH |
11729 | (define_insn "lshrdi3_1" |
11730 | [(set (match_operand:DI 0 "register_operand" "=r") | |
11731 | (lshiftrt:DI (match_operand:DI 1 "register_operand" "0") | |
11732 | (match_operand:QI 2 "nonmemory_operand" "Jc"))) | |
11733 | (clobber (match_scratch:SI 3 "=&r")) | |
11734 | (clobber (reg:CC 17))] | |
1e07edd3 | 11735 | "!TARGET_64BIT && TARGET_CMOVE" |
e075ae69 RH |
11736 | "#" |
11737 | [(set_attr "type" "multi")]) | |
886c62d1 | 11738 | |
e075ae69 RH |
11739 | (define_insn "*lshrdi3_2" |
11740 | [(set (match_operand:DI 0 "register_operand" "=r") | |
11741 | (lshiftrt:DI (match_operand:DI 1 "register_operand" "0") | |
11742 | (match_operand:QI 2 "nonmemory_operand" "Jc"))) | |
11743 | (clobber (reg:CC 17))] | |
1e07edd3 | 11744 | "!TARGET_64BIT" |
e075ae69 RH |
11745 | "#" |
11746 | [(set_attr "type" "multi")]) | |
886c62d1 | 11747 | |
e075ae69 RH |
11748 | (define_split |
11749 | [(set (match_operand:DI 0 "register_operand" "") | |
11750 | (lshiftrt:DI (match_operand:DI 1 "register_operand" "") | |
11751 | (match_operand:QI 2 "nonmemory_operand" ""))) | |
11752 | (clobber (match_scratch:SI 3 "")) | |
11753 | (clobber (reg:CC 17))] | |
1e07edd3 | 11754 | "!TARGET_64BIT && TARGET_CMOVE && reload_completed" |
e075ae69 RH |
11755 | [(const_int 0)] |
11756 | "ix86_split_lshrdi (operands, operands[3]); DONE;") | |
886c62d1 | 11757 | |
e075ae69 RH |
11758 | (define_split |
11759 | [(set (match_operand:DI 0 "register_operand" "") | |
11760 | (lshiftrt:DI (match_operand:DI 1 "register_operand" "") | |
11761 | (match_operand:QI 2 "nonmemory_operand" ""))) | |
11762 | (clobber (reg:CC 17))] | |
1e07edd3 | 11763 | "!TARGET_64BIT && reload_completed" |
e075ae69 RH |
11764 | [(const_int 0)] |
11765 | "ix86_split_lshrdi (operands, NULL_RTX); DONE;") | |
886c62d1 | 11766 | |
d525dfdf JH |
11767 | (define_expand "lshrsi3" |
11768 | [(set (match_operand:SI 0 "nonimmediate_operand" "") | |
11769 | (lshiftrt:SI (match_operand:SI 1 "nonimmediate_operand" "") | |
11770 | (match_operand:QI 2 "nonmemory_operand" ""))) | |
11771 | (clobber (reg:CC 17))] | |
11772 | "" | |
11773 | "ix86_expand_binary_operator (LSHIFTRT, SImode, operands); DONE;") | |
11774 | ||
8bad7136 JL |
11775 | (define_insn "*lshrsi3_1_one_bit" |
11776 | [(set (match_operand:SI 0 "nonimmediate_operand" "=rm") | |
11777 | (lshiftrt:SI (match_operand:SI 1 "nonimmediate_operand" "0") | |
11778 | (match_operand:QI 2 "const_int_1_operand" ""))) | |
11779 | (clobber (reg:CC 17))] | |
11780 | "ix86_binary_operator_ok (LSHIFTRT, HImode, operands) | |
11781 | && (TARGET_PENTIUM || TARGET_PENTIUMPRO)" | |
0f40f9f7 | 11782 | "shr{l}\t%0" |
8bad7136 JL |
11783 | [(set_attr "type" "ishift") |
11784 | (set (attr "length") | |
11785 | (if_then_else (match_operand:SI 0 "register_operand" "") | |
11786 | (const_string "2") | |
11787 | (const_string "*")))]) | |
11788 | ||
371bc54b JH |
11789 | (define_insn "*lshrsi3_1_one_bit_zext" |
11790 | [(set (match_operand:DI 0 "register_operand" "=r") | |
11791 | (lshiftrt:DI (zero_extend:DI (match_operand:SI 1 "register_operand" "0")) | |
11792 | (match_operand:QI 2 "const_int_1_operand" ""))) | |
11793 | (clobber (reg:CC 17))] | |
11794 | "TARGET_64BIT && ix86_binary_operator_ok (LSHIFTRT, HImode, operands) | |
11795 | && (TARGET_PENTIUM || TARGET_PENTIUMPRO)" | |
0f40f9f7 | 11796 | "shr{l}\t%k0" |
371bc54b JH |
11797 | [(set_attr "type" "ishift") |
11798 | (set_attr "length" "2")]) | |
11799 | ||
d525dfdf | 11800 | (define_insn "*lshrsi3_1" |
e075ae69 RH |
11801 | [(set (match_operand:SI 0 "nonimmediate_operand" "=rm,rm") |
11802 | (lshiftrt:SI (match_operand:SI 1 "nonimmediate_operand" "0,0") | |
11803 | (match_operand:QI 2 "nonmemory_operand" "I,c"))) | |
11804 | (clobber (reg:CC 17))] | |
d525dfdf | 11805 | "ix86_binary_operator_ok (LSHIFTRT, HImode, operands)" |
e075ae69 | 11806 | "@ |
0f40f9f7 ZW |
11807 | shr{l}\t{%2, %0|%0, %2} |
11808 | shr{l}\t{%b2, %0|%0, %b2}" | |
6ef67412 JH |
11809 | [(set_attr "type" "ishift") |
11810 | (set_attr "mode" "SI")]) | |
886c62d1 | 11811 | |
371bc54b JH |
11812 | (define_insn "*lshrsi3_1_zext" |
11813 | [(set (match_operand:DI 0 "register_operand" "=r,r") | |
11814 | (zero_extend:DI | |
11815 | (lshiftrt:SI (match_operand:SI 1 "nonimmediate_operand" "0,0") | |
11816 | (match_operand:QI 2 "nonmemory_operand" "I,c")))) | |
11817 | (clobber (reg:CC 17))] | |
11818 | "TARGET_64BIT && ix86_binary_operator_ok (LSHIFTRT, HImode, operands)" | |
11819 | "@ | |
0f40f9f7 ZW |
11820 | shr{l}\t{%2, %k0|%k0, %2} |
11821 | shr{l}\t{%b2, %k0|%k0, %b2}" | |
371bc54b JH |
11822 | [(set_attr "type" "ishift") |
11823 | (set_attr "mode" "SI")]) | |
11824 | ||
8bad7136 JL |
11825 | ;; This pattern can't accept a variable shift count, since shifts by |
11826 | ;; zero don't affect the flags. We assume that shifts by constant | |
11827 | ;; zero are optimized away. | |
2c873473 | 11828 | (define_insn "*lshrsi3_one_bit_cmp" |
8bad7136 JL |
11829 | [(set (reg 17) |
11830 | (compare | |
11831 | (lshiftrt:SI (match_operand:SI 1 "nonimmediate_operand" "0") | |
11832 | (match_operand:QI 2 "const_int_1_operand" "")) | |
11833 | (const_int 0))) | |
11834 | (set (match_operand:SI 0 "nonimmediate_operand" "=rm") | |
11835 | (lshiftrt:SI (match_dup 1) (match_dup 2)))] | |
9076b9c1 | 11836 | "ix86_match_ccmode (insn, CCGOCmode) |
8bad7136 JL |
11837 | && (TARGET_PENTIUM || TARGET_PENTIUMPRO) |
11838 | && ix86_binary_operator_ok (LSHIFTRT, HImode, operands)" | |
0f40f9f7 | 11839 | "shr{l}\t%0" |
8bad7136 JL |
11840 | [(set_attr "type" "ishift") |
11841 | (set (attr "length") | |
11842 | (if_then_else (match_operand:SI 0 "register_operand" "") | |
11843 | (const_string "2") | |
11844 | (const_string "*")))]) | |
11845 | ||
371bc54b JH |
11846 | (define_insn "*lshrsi3_cmp_one_bit_zext" |
11847 | [(set (reg 17) | |
11848 | (compare | |
11849 | (lshiftrt:SI (match_operand:SI 1 "register_operand" "0") | |
11850 | (match_operand:QI 2 "const_int_1_operand" "")) | |
11851 | (const_int 0))) | |
11852 | (set (match_operand:DI 0 "register_operand" "=r") | |
11853 | (lshiftrt:DI (zero_extend:DI (match_dup 1)) (match_dup 2)))] | |
11854 | "TARGET_64BIT && ix86_match_ccmode (insn, CCGOCmode) | |
11855 | && (TARGET_PENTIUM || TARGET_PENTIUMPRO) | |
11856 | && ix86_binary_operator_ok (LSHIFTRT, HImode, operands)" | |
0f40f9f7 | 11857 | "shr{l}\t%k0" |
371bc54b JH |
11858 | [(set_attr "type" "ishift") |
11859 | (set_attr "length" "2")]) | |
11860 | ||
28cefcd2 BS |
11861 | ;; This pattern can't accept a variable shift count, since shifts by |
11862 | ;; zero don't affect the flags. We assume that shifts by constant | |
11863 | ;; zero are optimized away. | |
2c873473 | 11864 | (define_insn "*lshrsi3_cmp" |
16189740 RH |
11865 | [(set (reg 17) |
11866 | (compare | |
28cefcd2 BS |
11867 | (lshiftrt:SI (match_operand:SI 1 "nonimmediate_operand" "0") |
11868 | (match_operand:QI 2 "immediate_operand" "I")) | |
e075ae69 | 11869 | (const_int 0))) |
28cefcd2 | 11870 | (set (match_operand:SI 0 "nonimmediate_operand" "=rm") |
e075ae69 | 11871 | (lshiftrt:SI (match_dup 1) (match_dup 2)))] |
9076b9c1 | 11872 | "ix86_match_ccmode (insn, CCGOCmode) |
16189740 | 11873 | && ix86_binary_operator_ok (LSHIFTRT, HImode, operands)" |
0f40f9f7 | 11874 | "shr{l}\t{%2, %0|%0, %2}" |
6ef67412 JH |
11875 | [(set_attr "type" "ishift") |
11876 | (set_attr "mode" "SI")]) | |
886c62d1 | 11877 | |
371bc54b JH |
11878 | (define_insn "*lshrsi3_cmp_zext" |
11879 | [(set (reg 17) | |
11880 | (compare | |
11881 | (lshiftrt:SI (match_operand:SI 1 "register_operand" "0") | |
11882 | (match_operand:QI 2 "immediate_operand" "I")) | |
11883 | (const_int 0))) | |
11884 | (set (match_operand:DI 0 "register_operand" "=r") | |
11885 | (lshiftrt:DI (zero_extend:DI (match_dup 1)) (match_dup 2)))] | |
11886 | "TARGET_64BIT && ix86_match_ccmode (insn, CCGOCmode) | |
11887 | && ix86_binary_operator_ok (LSHIFTRT, HImode, operands)" | |
0f40f9f7 | 11888 | "shr{l}\t{%2, %k0|%k0, %2}" |
371bc54b JH |
11889 | [(set_attr "type" "ishift") |
11890 | (set_attr "mode" "SI")]) | |
11891 | ||
d525dfdf JH |
11892 | (define_expand "lshrhi3" |
11893 | [(set (match_operand:HI 0 "nonimmediate_operand" "") | |
11894 | (lshiftrt:HI (match_operand:HI 1 "nonimmediate_operand" "") | |
11895 | (match_operand:QI 2 "nonmemory_operand" ""))) | |
11896 | (clobber (reg:CC 17))] | |
d9f32422 | 11897 | "TARGET_HIMODE_MATH" |
d525dfdf JH |
11898 | "ix86_expand_binary_operator (LSHIFTRT, HImode, operands); DONE;") |
11899 | ||
8bad7136 JL |
11900 | (define_insn "*lshrhi3_1_one_bit" |
11901 | [(set (match_operand:HI 0 "nonimmediate_operand" "=rm") | |
11902 | (lshiftrt:HI (match_operand:HI 1 "nonimmediate_operand" "0") | |
11903 | (match_operand:QI 2 "const_int_1_operand" ""))) | |
11904 | (clobber (reg:CC 17))] | |
11905 | "ix86_binary_operator_ok (LSHIFTRT, HImode, operands) | |
11906 | && (TARGET_PENTIUM || TARGET_PENTIUMPRO)" | |
0f40f9f7 | 11907 | "shr{w}\t%0" |
8bad7136 JL |
11908 | [(set_attr "type" "ishift") |
11909 | (set (attr "length") | |
3d117b30 | 11910 | (if_then_else (match_operand 0 "register_operand" "") |
8bad7136 JL |
11911 | (const_string "2") |
11912 | (const_string "*")))]) | |
11913 | ||
d525dfdf | 11914 | (define_insn "*lshrhi3_1" |
e075ae69 RH |
11915 | [(set (match_operand:HI 0 "nonimmediate_operand" "=rm,rm") |
11916 | (lshiftrt:HI (match_operand:HI 1 "nonimmediate_operand" "0,0") | |
11917 | (match_operand:QI 2 "nonmemory_operand" "I,c"))) | |
11918 | (clobber (reg:CC 17))] | |
d525dfdf | 11919 | "ix86_binary_operator_ok (LSHIFTRT, HImode, operands)" |
e075ae69 | 11920 | "@ |
0f40f9f7 ZW |
11921 | shr{w}\t{%2, %0|%0, %2} |
11922 | shr{w}\t{%b2, %0|%0, %b2}" | |
6ef67412 JH |
11923 | [(set_attr "type" "ishift") |
11924 | (set_attr "mode" "HI")]) | |
886c62d1 | 11925 | |
8bad7136 JL |
11926 | ;; This pattern can't accept a variable shift count, since shifts by |
11927 | ;; zero don't affect the flags. We assume that shifts by constant | |
11928 | ;; zero are optimized away. | |
2c873473 | 11929 | (define_insn "*lshrhi3_one_bit_cmp" |
8bad7136 JL |
11930 | [(set (reg 17) |
11931 | (compare | |
11932 | (lshiftrt:HI (match_operand:HI 1 "nonimmediate_operand" "0") | |
11933 | (match_operand:QI 2 "const_int_1_operand" "")) | |
11934 | (const_int 0))) | |
11935 | (set (match_operand:HI 0 "nonimmediate_operand" "=rm") | |
11936 | (lshiftrt:HI (match_dup 1) (match_dup 2)))] | |
9076b9c1 | 11937 | "ix86_match_ccmode (insn, CCGOCmode) |
8bad7136 JL |
11938 | && (TARGET_PENTIUM || TARGET_PENTIUMPRO) |
11939 | && ix86_binary_operator_ok (LSHIFTRT, HImode, operands)" | |
0f40f9f7 | 11940 | "shr{w}\t%0" |
8bad7136 JL |
11941 | [(set_attr "type" "ishift") |
11942 | (set (attr "length") | |
11943 | (if_then_else (match_operand:SI 0 "register_operand" "") | |
11944 | (const_string "2") | |
11945 | (const_string "*")))]) | |
11946 | ||
28cefcd2 BS |
11947 | ;; This pattern can't accept a variable shift count, since shifts by |
11948 | ;; zero don't affect the flags. We assume that shifts by constant | |
11949 | ;; zero are optimized away. | |
2c873473 | 11950 | (define_insn "*lshrhi3_cmp" |
16189740 RH |
11951 | [(set (reg 17) |
11952 | (compare | |
28cefcd2 BS |
11953 | (lshiftrt:HI (match_operand:HI 1 "nonimmediate_operand" "0") |
11954 | (match_operand:QI 2 "immediate_operand" "I")) | |
e075ae69 | 11955 | (const_int 0))) |
28cefcd2 | 11956 | (set (match_operand:HI 0 "nonimmediate_operand" "=rm") |
e075ae69 | 11957 | (lshiftrt:HI (match_dup 1) (match_dup 2)))] |
9076b9c1 | 11958 | "ix86_match_ccmode (insn, CCGOCmode) |
16189740 | 11959 | && ix86_binary_operator_ok (LSHIFTRT, HImode, operands)" |
0f40f9f7 | 11960 | "shr{w}\t{%2, %0|%0, %2}" |
6ef67412 JH |
11961 | [(set_attr "type" "ishift") |
11962 | (set_attr "mode" "HI")]) | |
886c62d1 | 11963 | |
d525dfdf JH |
11964 | (define_expand "lshrqi3" |
11965 | [(set (match_operand:QI 0 "nonimmediate_operand" "") | |
11966 | (lshiftrt:QI (match_operand:QI 1 "nonimmediate_operand" "") | |
11967 | (match_operand:QI 2 "nonmemory_operand" ""))) | |
11968 | (clobber (reg:CC 17))] | |
d9f32422 | 11969 | "TARGET_QIMODE_MATH" |
d525dfdf JH |
11970 | "ix86_expand_binary_operator (LSHIFTRT, QImode, operands); DONE;") |
11971 | ||
8bad7136 JL |
11972 | (define_insn "*lshrqi3_1_one_bit" |
11973 | [(set (match_operand:QI 0 "nonimmediate_operand" "=qm") | |
11974 | (lshiftrt:QI (match_operand:QI 1 "nonimmediate_operand" "0") | |
11975 | (match_operand:QI 2 "const_int_1_operand" ""))) | |
11976 | (clobber (reg:CC 17))] | |
11977 | "ix86_binary_operator_ok (LSHIFTRT, QImode, operands) | |
11978 | && (TARGET_PENTIUM || TARGET_PENTIUMPRO)" | |
0f40f9f7 | 11979 | "shr{b}\t%0" |
8bad7136 JL |
11980 | [(set_attr "type" "ishift") |
11981 | (set (attr "length") | |
3d117b30 | 11982 | (if_then_else (match_operand 0 "register_operand" "") |
8bad7136 JL |
11983 | (const_string "2") |
11984 | (const_string "*")))]) | |
11985 | ||
d525dfdf | 11986 | (define_insn "*lshrqi3_1" |
e075ae69 RH |
11987 | [(set (match_operand:QI 0 "nonimmediate_operand" "=qm,qm") |
11988 | (lshiftrt:QI (match_operand:QI 1 "nonimmediate_operand" "0,0") | |
11989 | (match_operand:QI 2 "nonmemory_operand" "I,c"))) | |
11990 | (clobber (reg:CC 17))] | |
d525dfdf | 11991 | "ix86_binary_operator_ok (LSHIFTRT, QImode, operands)" |
e075ae69 | 11992 | "@ |
0f40f9f7 ZW |
11993 | shr{b}\t{%2, %0|%0, %2} |
11994 | shr{b}\t{%b2, %0|%0, %b2}" | |
6ef67412 JH |
11995 | [(set_attr "type" "ishift") |
11996 | (set_attr "mode" "QI")]) | |
886c62d1 | 11997 | |
8bad7136 JL |
11998 | ;; This pattern can't accept a variable shift count, since shifts by |
11999 | ;; zero don't affect the flags. We assume that shifts by constant | |
12000 | ;; zero are optimized away. | |
2c873473 | 12001 | (define_insn "*lshrqi2_one_bit_cmp" |
8bad7136 JL |
12002 | [(set (reg 17) |
12003 | (compare | |
12004 | (lshiftrt:QI (match_operand:QI 1 "nonimmediate_operand" "0") | |
12005 | (match_operand:QI 2 "const_int_1_operand" "")) | |
12006 | (const_int 0))) | |
12007 | (set (match_operand:QI 0 "nonimmediate_operand" "=qm") | |
12008 | (lshiftrt:QI (match_dup 1) (match_dup 2)))] | |
9076b9c1 | 12009 | "ix86_match_ccmode (insn, CCGOCmode) |
8bad7136 JL |
12010 | && (TARGET_PENTIUM || TARGET_PENTIUMPRO) |
12011 | && ix86_binary_operator_ok (LSHIFTRT, QImode, operands)" | |
0f40f9f7 | 12012 | "shr{b}\t%0" |
8bad7136 JL |
12013 | [(set_attr "type" "ishift") |
12014 | (set (attr "length") | |
12015 | (if_then_else (match_operand:SI 0 "register_operand" "") | |
12016 | (const_string "2") | |
12017 | (const_string "*")))]) | |
12018 | ||
28cefcd2 BS |
12019 | ;; This pattern can't accept a variable shift count, since shifts by |
12020 | ;; zero don't affect the flags. We assume that shifts by constant | |
12021 | ;; zero are optimized away. | |
2c873473 | 12022 | (define_insn "*lshrqi2_cmp" |
16189740 RH |
12023 | [(set (reg 17) |
12024 | (compare | |
28cefcd2 BS |
12025 | (lshiftrt:QI (match_operand:QI 1 "nonimmediate_operand" "0") |
12026 | (match_operand:QI 2 "immediate_operand" "I")) | |
e075ae69 | 12027 | (const_int 0))) |
122ddbf9 | 12028 | (set (match_operand:QI 0 "nonimmediate_operand" "=qm") |
e075ae69 | 12029 | (lshiftrt:QI (match_dup 1) (match_dup 2)))] |
9076b9c1 | 12030 | "ix86_match_ccmode (insn, CCGOCmode) |
16189740 | 12031 | && ix86_binary_operator_ok (LSHIFTRT, QImode, operands)" |
0f40f9f7 | 12032 | "shr{b}\t{%2, %0|%0, %2}" |
6ef67412 JH |
12033 | [(set_attr "type" "ishift") |
12034 | (set_attr "mode" "QI")]) | |
886c62d1 | 12035 | \f |
e075ae69 | 12036 | ;; Rotate instructions |
886c62d1 | 12037 | |
371bc54b JH |
12038 | (define_expand "rotldi3" |
12039 | [(set (match_operand:DI 0 "nonimmediate_operand" "") | |
12040 | (rotate:DI (match_operand:DI 1 "nonimmediate_operand" "") | |
12041 | (match_operand:QI 2 "nonmemory_operand" ""))) | |
12042 | (clobber (reg:CC 17))] | |
12043 | "TARGET_64BIT" | |
12044 | "ix86_expand_binary_operator (ROTATE, DImode, operands); DONE;") | |
12045 | ||
12046 | (define_insn "*rotlsi3_1_one_bit_rex64" | |
12047 | [(set (match_operand:DI 0 "nonimmediate_operand" "=rm") | |
12048 | (rotate:DI (match_operand:DI 1 "nonimmediate_operand" "0") | |
12049 | (match_operand:QI 2 "const_int_1_operand" ""))) | |
12050 | (clobber (reg:CC 17))] | |
12051 | "TARGET_64BIT && ix86_binary_operator_ok (ROTATE, DImode, operands) | |
12052 | && (TARGET_PENTIUM || TARGET_PENTIUMPRO)" | |
0f40f9f7 | 12053 | "rol{q}\t%0" |
371bc54b JH |
12054 | [(set_attr "type" "ishift") |
12055 | (set (attr "length") | |
12056 | (if_then_else (match_operand:DI 0 "register_operand" "") | |
12057 | (const_string "2") | |
12058 | (const_string "*")))]) | |
12059 | ||
12060 | (define_insn "*rotldi3_1_rex64" | |
12061 | [(set (match_operand:DI 0 "nonimmediate_operand" "=rm,rm") | |
12062 | (rotate:DI (match_operand:DI 1 "nonimmediate_operand" "0,0") | |
12063 | (match_operand:QI 2 "nonmemory_operand" "e,c"))) | |
12064 | (clobber (reg:CC 17))] | |
12065 | "TARGET_64BIT && ix86_binary_operator_ok (ROTATE, DImode, operands)" | |
12066 | "@ | |
0f40f9f7 ZW |
12067 | rol{q}\t{%2, %0|%0, %2} |
12068 | rol{q}\t{%b2, %0|%0, %b2}" | |
371bc54b JH |
12069 | [(set_attr "type" "ishift") |
12070 | (set_attr "mode" "DI")]) | |
12071 | ||
d525dfdf JH |
12072 | (define_expand "rotlsi3" |
12073 | [(set (match_operand:SI 0 "nonimmediate_operand" "") | |
12074 | (rotate:SI (match_operand:SI 1 "nonimmediate_operand" "") | |
12075 | (match_operand:QI 2 "nonmemory_operand" ""))) | |
12076 | (clobber (reg:CC 17))] | |
12077 | "" | |
12078 | "ix86_expand_binary_operator (ROTATE, SImode, operands); DONE;") | |
12079 | ||
8bad7136 JL |
12080 | (define_insn "*rotlsi3_1_one_bit" |
12081 | [(set (match_operand:SI 0 "nonimmediate_operand" "=rm") | |
12082 | (rotate:SI (match_operand:SI 1 "nonimmediate_operand" "0") | |
12083 | (match_operand:QI 2 "const_int_1_operand" ""))) | |
12084 | (clobber (reg:CC 17))] | |
12085 | "ix86_binary_operator_ok (ROTATE, SImode, operands) | |
12086 | && (TARGET_PENTIUM || TARGET_PENTIUMPRO)" | |
0f40f9f7 | 12087 | "rol{l}\t%0" |
8bad7136 JL |
12088 | [(set_attr "type" "ishift") |
12089 | (set (attr "length") | |
12090 | (if_then_else (match_operand:SI 0 "register_operand" "") | |
12091 | (const_string "2") | |
12092 | (const_string "*")))]) | |
12093 | ||
371bc54b JH |
12094 | (define_insn "*rotlsi3_1_one_bit_zext" |
12095 | [(set (match_operand:DI 0 "register_operand" "=r") | |
12096 | (zero_extend:DI | |
12097 | (rotate:SI (match_operand:SI 1 "register_operand" "0") | |
12098 | (match_operand:QI 2 "const_int_1_operand" "")))) | |
12099 | (clobber (reg:CC 17))] | |
12100 | "TARGET_64BIT && ix86_binary_operator_ok (ROTATE, SImode, operands) | |
12101 | && (TARGET_PENTIUM || TARGET_PENTIUMPRO)" | |
0f40f9f7 | 12102 | "rol{l}\t%k0" |
371bc54b JH |
12103 | [(set_attr "type" "ishift") |
12104 | (set_attr "length" "2")]) | |
12105 | ||
d525dfdf | 12106 | (define_insn "*rotlsi3_1" |
e075ae69 RH |
12107 | [(set (match_operand:SI 0 "nonimmediate_operand" "=rm,rm") |
12108 | (rotate:SI (match_operand:SI 1 "nonimmediate_operand" "0,0") | |
12109 | (match_operand:QI 2 "nonmemory_operand" "I,c"))) | |
12110 | (clobber (reg:CC 17))] | |
d525dfdf | 12111 | "ix86_binary_operator_ok (ROTATE, SImode, operands)" |
e075ae69 | 12112 | "@ |
0f40f9f7 ZW |
12113 | rol{l}\t{%2, %0|%0, %2} |
12114 | rol{l}\t{%b2, %0|%0, %b2}" | |
6ef67412 JH |
12115 | [(set_attr "type" "ishift") |
12116 | (set_attr "mode" "SI")]) | |
b4ac57ab | 12117 | |
371bc54b JH |
12118 | (define_insn "*rotlsi3_1_zext" |
12119 | [(set (match_operand:DI 0 "register_operand" "=r,r") | |
12120 | (zero_extend:DI | |
12121 | (rotate:SI (match_operand:SI 1 "register_operand" "0,0") | |
12122 | (match_operand:QI 2 "nonmemory_operand" "I,c")))) | |
12123 | (clobber (reg:CC 17))] | |
12124 | "TARGET_64BIT && ix86_binary_operator_ok (ROTATE, SImode, operands)" | |
12125 | "@ | |
0f40f9f7 ZW |
12126 | rol{l}\t{%2, %k0|%k0, %2} |
12127 | rol{l}\t{%b2, %k0|%k0, %b2}" | |
371bc54b JH |
12128 | [(set_attr "type" "ishift") |
12129 | (set_attr "mode" "SI")]) | |
12130 | ||
d525dfdf JH |
12131 | (define_expand "rotlhi3" |
12132 | [(set (match_operand:HI 0 "nonimmediate_operand" "") | |
12133 | (rotate:HI (match_operand:HI 1 "nonimmediate_operand" "") | |
12134 | (match_operand:QI 2 "nonmemory_operand" ""))) | |
12135 | (clobber (reg:CC 17))] | |
d9f32422 | 12136 | "TARGET_HIMODE_MATH" |
d525dfdf JH |
12137 | "ix86_expand_binary_operator (ROTATE, HImode, operands); DONE;") |
12138 | ||
8bad7136 JL |
12139 | (define_insn "*rotlhi3_1_one_bit" |
12140 | [(set (match_operand:HI 0 "nonimmediate_operand" "=rm") | |
12141 | (rotate:HI (match_operand:HI 1 "nonimmediate_operand" "0") | |
12142 | (match_operand:QI 2 "const_int_1_operand" ""))) | |
12143 | (clobber (reg:CC 17))] | |
12144 | "ix86_binary_operator_ok (ROTATE, HImode, operands) | |
12145 | && (TARGET_PENTIUM || TARGET_PENTIUMPRO)" | |
0f40f9f7 | 12146 | "rol{w}\t%0" |
8bad7136 JL |
12147 | [(set_attr "type" "ishift") |
12148 | (set (attr "length") | |
3d117b30 | 12149 | (if_then_else (match_operand 0 "register_operand" "") |
8bad7136 JL |
12150 | (const_string "2") |
12151 | (const_string "*")))]) | |
12152 | ||
d525dfdf | 12153 | (define_insn "*rotlhi3_1" |
e075ae69 RH |
12154 | [(set (match_operand:HI 0 "nonimmediate_operand" "=rm,rm") |
12155 | (rotate:HI (match_operand:HI 1 "nonimmediate_operand" "0,0") | |
12156 | (match_operand:QI 2 "nonmemory_operand" "I,c"))) | |
12157 | (clobber (reg:CC 17))] | |
d525dfdf | 12158 | "ix86_binary_operator_ok (ROTATE, HImode, operands)" |
e075ae69 | 12159 | "@ |
0f40f9f7 ZW |
12160 | rol{w}\t{%2, %0|%0, %2} |
12161 | rol{w}\t{%b2, %0|%0, %b2}" | |
6ef67412 JH |
12162 | [(set_attr "type" "ishift") |
12163 | (set_attr "mode" "HI")]) | |
47af5d50 | 12164 | |
d525dfdf JH |
12165 | (define_expand "rotlqi3" |
12166 | [(set (match_operand:QI 0 "nonimmediate_operand" "") | |
12167 | (rotate:QI (match_operand:QI 1 "nonimmediate_operand" "") | |
12168 | (match_operand:QI 2 "nonmemory_operand" ""))) | |
12169 | (clobber (reg:CC 17))] | |
d9f32422 | 12170 | "TARGET_QIMODE_MATH" |
d525dfdf JH |
12171 | "ix86_expand_binary_operator (ROTATE, QImode, operands); DONE;") |
12172 | ||
8bad7136 JL |
12173 | (define_insn "*rotlqi3_1_one_bit" |
12174 | [(set (match_operand:QI 0 "nonimmediate_operand" "=qm") | |
12175 | (rotate:QI (match_operand:QI 1 "nonimmediate_operand" "0") | |
12176 | (match_operand:QI 2 "const_int_1_operand" ""))) | |
12177 | (clobber (reg:CC 17))] | |
12178 | "ix86_binary_operator_ok (ROTATE, QImode, operands) | |
12179 | && (TARGET_PENTIUM || TARGET_PENTIUMPRO)" | |
0f40f9f7 | 12180 | "rol{b}\t%0" |
8bad7136 JL |
12181 | [(set_attr "type" "ishift") |
12182 | (set (attr "length") | |
3d117b30 | 12183 | (if_then_else (match_operand 0 "register_operand" "") |
8bad7136 JL |
12184 | (const_string "2") |
12185 | (const_string "*")))]) | |
12186 | ||
d525dfdf | 12187 | (define_insn "*rotlqi3_1" |
e075ae69 RH |
12188 | [(set (match_operand:QI 0 "nonimmediate_operand" "=qm,qm") |
12189 | (rotate:QI (match_operand:QI 1 "nonimmediate_operand" "0,0") | |
12190 | (match_operand:QI 2 "nonmemory_operand" "I,c"))) | |
12191 | (clobber (reg:CC 17))] | |
d525dfdf | 12192 | "ix86_binary_operator_ok (ROTATE, QImode, operands)" |
e075ae69 | 12193 | "@ |
0f40f9f7 ZW |
12194 | rol{b}\t{%2, %0|%0, %2} |
12195 | rol{b}\t{%b2, %0|%0, %b2}" | |
6ef67412 JH |
12196 | [(set_attr "type" "ishift") |
12197 | (set_attr "mode" "QI")]) | |
47af5d50 | 12198 | |
371bc54b JH |
12199 | (define_expand "rotrdi3" |
12200 | [(set (match_operand:DI 0 "nonimmediate_operand" "") | |
12201 | (rotatert:DI (match_operand:DI 1 "nonimmediate_operand" "") | |
12202 | (match_operand:QI 2 "nonmemory_operand" ""))) | |
12203 | (clobber (reg:CC 17))] | |
12204 | "TARGET_64BIT" | |
12205 | "ix86_expand_binary_operator (ROTATERT, DImode, operands); DONE;") | |
12206 | ||
12207 | (define_insn "*rotrdi3_1_one_bit_rex64" | |
12208 | [(set (match_operand:DI 0 "nonimmediate_operand" "=rm") | |
12209 | (rotatert:DI (match_operand:DI 1 "nonimmediate_operand" "0") | |
12210 | (match_operand:QI 2 "const_int_1_operand" ""))) | |
12211 | (clobber (reg:CC 17))] | |
12212 | "TARGET_64BIT && ix86_binary_operator_ok (ROTATERT, DImode, operands) | |
12213 | && (TARGET_PENTIUM || TARGET_PENTIUMPRO)" | |
0f40f9f7 | 12214 | "ror{q}\t%0" |
371bc54b JH |
12215 | [(set_attr "type" "ishift") |
12216 | (set (attr "length") | |
12217 | (if_then_else (match_operand:DI 0 "register_operand" "") | |
12218 | (const_string "2") | |
12219 | (const_string "*")))]) | |
12220 | ||
12221 | (define_insn "*rotrdi3_1_rex64" | |
12222 | [(set (match_operand:DI 0 "nonimmediate_operand" "=rm,rm") | |
12223 | (rotatert:DI (match_operand:DI 1 "nonimmediate_operand" "0,0") | |
12224 | (match_operand:QI 2 "nonmemory_operand" "J,c"))) | |
12225 | (clobber (reg:CC 17))] | |
12226 | "TARGET_64BIT && ix86_binary_operator_ok (ROTATERT, DImode, operands)" | |
12227 | "@ | |
0f40f9f7 ZW |
12228 | ror{q}\t{%2, %0|%0, %2} |
12229 | ror{q}\t{%b2, %0|%0, %b2}" | |
371bc54b JH |
12230 | [(set_attr "type" "ishift") |
12231 | (set_attr "mode" "DI")]) | |
12232 | ||
d525dfdf JH |
12233 | (define_expand "rotrsi3" |
12234 | [(set (match_operand:SI 0 "nonimmediate_operand" "") | |
12235 | (rotatert:SI (match_operand:SI 1 "nonimmediate_operand" "") | |
12236 | (match_operand:QI 2 "nonmemory_operand" ""))) | |
12237 | (clobber (reg:CC 17))] | |
12238 | "" | |
12239 | "ix86_expand_binary_operator (ROTATERT, SImode, operands); DONE;") | |
12240 | ||
8bad7136 JL |
12241 | (define_insn "*rotrsi3_1_one_bit" |
12242 | [(set (match_operand:SI 0 "nonimmediate_operand" "=rm") | |
12243 | (rotatert:SI (match_operand:SI 1 "nonimmediate_operand" "0") | |
12244 | (match_operand:QI 2 "const_int_1_operand" ""))) | |
12245 | (clobber (reg:CC 17))] | |
12246 | "ix86_binary_operator_ok (ROTATERT, SImode, operands) | |
12247 | && (TARGET_PENTIUM || TARGET_PENTIUMPRO)" | |
0f40f9f7 | 12248 | "ror{l}\t%0" |
8bad7136 JL |
12249 | [(set_attr "type" "ishift") |
12250 | (set (attr "length") | |
12251 | (if_then_else (match_operand:SI 0 "register_operand" "") | |
12252 | (const_string "2") | |
12253 | (const_string "*")))]) | |
12254 | ||
371bc54b JH |
12255 | (define_insn "*rotrsi3_1_one_bit_zext" |
12256 | [(set (match_operand:DI 0 "register_operand" "=r") | |
12257 | (zero_extend:DI | |
12258 | (rotatert:SI (match_operand:SI 1 "register_operand" "0") | |
12259 | (match_operand:QI 2 "const_int_1_operand" "")))) | |
12260 | (clobber (reg:CC 17))] | |
12261 | "TARGET_64BIT && ix86_binary_operator_ok (ROTATERT, SImode, operands) | |
12262 | && (TARGET_PENTIUM || TARGET_PENTIUMPRO)" | |
0f40f9f7 | 12263 | "ror{l}\t%k0" |
371bc54b JH |
12264 | [(set_attr "type" "ishift") |
12265 | (set (attr "length") | |
12266 | (if_then_else (match_operand:SI 0 "register_operand" "") | |
12267 | (const_string "2") | |
12268 | (const_string "*")))]) | |
12269 | ||
d525dfdf | 12270 | (define_insn "*rotrsi3_1" |
e075ae69 RH |
12271 | [(set (match_operand:SI 0 "nonimmediate_operand" "=rm,rm") |
12272 | (rotatert:SI (match_operand:SI 1 "nonimmediate_operand" "0,0") | |
12273 | (match_operand:QI 2 "nonmemory_operand" "I,c"))) | |
12274 | (clobber (reg:CC 17))] | |
d525dfdf | 12275 | "ix86_binary_operator_ok (ROTATERT, SImode, operands)" |
e075ae69 | 12276 | "@ |
0f40f9f7 ZW |
12277 | ror{l}\t{%2, %0|%0, %2} |
12278 | ror{l}\t{%b2, %0|%0, %b2}" | |
6ef67412 JH |
12279 | [(set_attr "type" "ishift") |
12280 | (set_attr "mode" "SI")]) | |
47af5d50 | 12281 | |
371bc54b JH |
12282 | (define_insn "*rotrsi3_1_zext" |
12283 | [(set (match_operand:DI 0 "register_operand" "=r,r") | |
12284 | (zero_extend:DI | |
12285 | (rotatert:SI (match_operand:SI 1 "register_operand" "0,0") | |
12286 | (match_operand:QI 2 "nonmemory_operand" "I,c")))) | |
12287 | (clobber (reg:CC 17))] | |
12288 | "TARGET_64BIT && ix86_binary_operator_ok (ROTATERT, SImode, operands)" | |
12289 | "@ | |
0f40f9f7 ZW |
12290 | ror{l}\t{%2, %k0|%k0, %2} |
12291 | ror{l}\t{%b2, %k0|%k0, %b2}" | |
371bc54b JH |
12292 | [(set_attr "type" "ishift") |
12293 | (set_attr "mode" "SI")]) | |
12294 | ||
d525dfdf JH |
12295 | (define_expand "rotrhi3" |
12296 | [(set (match_operand:HI 0 "nonimmediate_operand" "") | |
12297 | (rotatert:HI (match_operand:HI 1 "nonimmediate_operand" "") | |
12298 | (match_operand:QI 2 "nonmemory_operand" ""))) | |
12299 | (clobber (reg:CC 17))] | |
d9f32422 | 12300 | "TARGET_HIMODE_MATH" |
d525dfdf JH |
12301 | "ix86_expand_binary_operator (ROTATERT, HImode, operands); DONE;") |
12302 | ||
8bad7136 JL |
12303 | (define_insn "*rotrhi3_one_bit" |
12304 | [(set (match_operand:HI 0 "nonimmediate_operand" "=rm") | |
12305 | (rotatert:HI (match_operand:HI 1 "nonimmediate_operand" "0") | |
12306 | (match_operand:QI 2 "const_int_1_operand" ""))) | |
12307 | (clobber (reg:CC 17))] | |
12308 | "ix86_binary_operator_ok (ROTATERT, HImode, operands) | |
12309 | && (TARGET_PENTIUM || TARGET_PENTIUMPRO)" | |
0f40f9f7 | 12310 | "ror{w}\t%0" |
8bad7136 JL |
12311 | [(set_attr "type" "ishift") |
12312 | (set (attr "length") | |
3d117b30 | 12313 | (if_then_else (match_operand 0 "register_operand" "") |
8bad7136 JL |
12314 | (const_string "2") |
12315 | (const_string "*")))]) | |
12316 | ||
d525dfdf | 12317 | (define_insn "*rotrhi3" |
e075ae69 RH |
12318 | [(set (match_operand:HI 0 "nonimmediate_operand" "=rm,rm") |
12319 | (rotatert:HI (match_operand:HI 1 "nonimmediate_operand" "0,0") | |
12320 | (match_operand:QI 2 "nonmemory_operand" "I,c"))) | |
12321 | (clobber (reg:CC 17))] | |
d525dfdf | 12322 | "ix86_binary_operator_ok (ROTATERT, HImode, operands)" |
e075ae69 | 12323 | "@ |
0f40f9f7 ZW |
12324 | ror{w}\t{%2, %0|%0, %2} |
12325 | ror{w}\t{%b2, %0|%0, %b2}" | |
6ef67412 JH |
12326 | [(set_attr "type" "ishift") |
12327 | (set_attr "mode" "HI")]) | |
a199fdd6 | 12328 | |
d525dfdf JH |
12329 | (define_expand "rotrqi3" |
12330 | [(set (match_operand:QI 0 "nonimmediate_operand" "") | |
12331 | (rotatert:QI (match_operand:QI 1 "nonimmediate_operand" "") | |
12332 | (match_operand:QI 2 "nonmemory_operand" ""))) | |
12333 | (clobber (reg:CC 17))] | |
d9f32422 | 12334 | "TARGET_QIMODE_MATH" |
d525dfdf JH |
12335 | "ix86_expand_binary_operator (ROTATERT, QImode, operands); DONE;") |
12336 | ||
8bad7136 JL |
12337 | (define_insn "*rotrqi3_1_one_bit" |
12338 | [(set (match_operand:QI 0 "nonimmediate_operand" "=qm") | |
12339 | (rotatert:QI (match_operand:QI 1 "nonimmediate_operand" "0") | |
12340 | (match_operand:QI 2 "const_int_1_operand" ""))) | |
12341 | (clobber (reg:CC 17))] | |
12342 | "ix86_binary_operator_ok (ROTATERT, QImode, operands) | |
12343 | && (TARGET_PENTIUM || TARGET_PENTIUMPRO)" | |
0f40f9f7 | 12344 | "ror{b}\t%0" |
8bad7136 JL |
12345 | [(set_attr "type" "ishift") |
12346 | (set (attr "length") | |
3d117b30 | 12347 | (if_then_else (match_operand 0 "register_operand" "") |
8bad7136 JL |
12348 | (const_string "2") |
12349 | (const_string "*")))]) | |
12350 | ||
d525dfdf | 12351 | (define_insn "*rotrqi3_1" |
e075ae69 RH |
12352 | [(set (match_operand:QI 0 "nonimmediate_operand" "=qm,qm") |
12353 | (rotatert:QI (match_operand:QI 1 "nonimmediate_operand" "0,0") | |
12354 | (match_operand:QI 2 "nonmemory_operand" "I,c"))) | |
12355 | (clobber (reg:CC 17))] | |
d525dfdf | 12356 | "ix86_binary_operator_ok (ROTATERT, QImode, operands)" |
e075ae69 | 12357 | "@ |
0f40f9f7 ZW |
12358 | ror{b}\t{%2, %0|%0, %2} |
12359 | ror{b}\t{%b2, %0|%0, %b2}" | |
6ef67412 JH |
12360 | [(set_attr "type" "ishift") |
12361 | (set_attr "mode" "QI")]) | |
e075ae69 RH |
12362 | \f |
12363 | ;; Bit set / bit test instructions | |
a199fdd6 | 12364 | |
e075ae69 RH |
12365 | (define_expand "extv" |
12366 | [(set (match_operand:SI 0 "register_operand" "") | |
12367 | (sign_extract:SI (match_operand:SI 1 "register_operand" "") | |
12368 | (match_operand:SI 2 "immediate_operand" "") | |
12369 | (match_operand:SI 3 "immediate_operand" "")))] | |
12370 | "" | |
e075ae69 RH |
12371 | { |
12372 | /* Handle extractions from %ah et al. */ | |
12373 | if (INTVAL (operands[2]) != 8 || INTVAL (operands[3]) != 8) | |
12374 | FAIL; | |
a199fdd6 | 12375 | |
e075ae69 RH |
12376 | /* From mips.md: extract_bit_field doesn't verify that our source |
12377 | matches the predicate, so check it again here. */ | |
12378 | if (! register_operand (operands[1], VOIDmode)) | |
12379 | FAIL; | |
0f40f9f7 | 12380 | }) |
a199fdd6 | 12381 | |
e075ae69 RH |
12382 | (define_expand "extzv" |
12383 | [(set (match_operand:SI 0 "register_operand" "") | |
12384 | (zero_extract:SI (match_operand 1 "ext_register_operand" "") | |
12385 | (match_operand:SI 2 "immediate_operand" "") | |
12386 | (match_operand:SI 3 "immediate_operand" "")))] | |
12387 | "" | |
e075ae69 RH |
12388 | { |
12389 | /* Handle extractions from %ah et al. */ | |
12390 | if (INTVAL (operands[2]) != 8 || INTVAL (operands[3]) != 8) | |
12391 | FAIL; | |
a199fdd6 | 12392 | |
e075ae69 RH |
12393 | /* From mips.md: extract_bit_field doesn't verify that our source |
12394 | matches the predicate, so check it again here. */ | |
12395 | if (! register_operand (operands[1], VOIDmode)) | |
12396 | FAIL; | |
0f40f9f7 | 12397 | }) |
a199fdd6 | 12398 | |
e075ae69 RH |
12399 | (define_expand "insv" |
12400 | [(set (zero_extract:SI (match_operand 0 "ext_register_operand" "") | |
12401 | (match_operand:SI 1 "immediate_operand" "") | |
12402 | (match_operand:SI 2 "immediate_operand" "")) | |
12403 | (match_operand:SI 3 "register_operand" ""))] | |
12404 | "" | |
e075ae69 RH |
12405 | { |
12406 | /* Handle extractions from %ah et al. */ | |
12407 | if (INTVAL (operands[1]) != 8 || INTVAL (operands[2]) != 8) | |
12408 | FAIL; | |
a199fdd6 | 12409 | |
e075ae69 RH |
12410 | /* From mips.md: insert_bit_field doesn't verify that our source |
12411 | matches the predicate, so check it again here. */ | |
12412 | if (! register_operand (operands[0], VOIDmode)) | |
12413 | FAIL; | |
0f40f9f7 | 12414 | }) |
e075ae69 RH |
12415 | |
12416 | ;; %%% bts, btr, btc, bt. | |
886c62d1 JVA |
12417 | \f |
12418 | ;; Store-flag instructions. | |
12419 | ||
c572e5ba JVA |
12420 | ;; For all sCOND expanders, also expand the compare or test insn that |
12421 | ;; generates cc0. Generate an equality comparison if `seq' or `sne'. | |
12422 | ||
e075ae69 RH |
12423 | ;; %%% Do the expansion to SImode. If PII, do things the xor+setcc way |
12424 | ;; to avoid partial register stalls. Otherwise do things the setcc+movzx | |
12425 | ;; way, which can later delete the movzx if only QImode is needed. | |
12426 | ||
c572e5ba | 12427 | (define_expand "seq" |
b932f770 JH |
12428 | [(set (match_operand:QI 0 "register_operand" "") |
12429 | (eq:QI (reg:CC 17) (const_int 0)))] | |
c572e5ba | 12430 | "" |
3a3677ff | 12431 | "if (ix86_expand_setcc (EQ, operands[0])) DONE; else FAIL;") |
c572e5ba | 12432 | |
c572e5ba | 12433 | (define_expand "sne" |
b932f770 JH |
12434 | [(set (match_operand:QI 0 "register_operand" "") |
12435 | (ne:QI (reg:CC 17) (const_int 0)))] | |
c572e5ba | 12436 | "" |
3a3677ff | 12437 | "if (ix86_expand_setcc (NE, operands[0])) DONE; else FAIL;") |
c572e5ba | 12438 | |
c572e5ba | 12439 | (define_expand "sgt" |
b932f770 JH |
12440 | [(set (match_operand:QI 0 "register_operand" "") |
12441 | (gt:QI (reg:CC 17) (const_int 0)))] | |
c572e5ba | 12442 | "" |
3a3677ff | 12443 | "if (ix86_expand_setcc (GT, operands[0])) DONE; else FAIL;") |
c572e5ba | 12444 | |
c572e5ba | 12445 | (define_expand "sgtu" |
b932f770 JH |
12446 | [(set (match_operand:QI 0 "register_operand" "") |
12447 | (gtu:QI (reg:CC 17) (const_int 0)))] | |
c572e5ba | 12448 | "" |
3a3677ff | 12449 | "if (ix86_expand_setcc (GTU, operands[0])) DONE; else FAIL;") |
c572e5ba | 12450 | |
c572e5ba | 12451 | (define_expand "slt" |
b932f770 JH |
12452 | [(set (match_operand:QI 0 "register_operand" "") |
12453 | (lt:QI (reg:CC 17) (const_int 0)))] | |
c572e5ba | 12454 | "" |
3a3677ff | 12455 | "if (ix86_expand_setcc (LT, operands[0])) DONE; else FAIL;") |
c572e5ba | 12456 | |
c572e5ba | 12457 | (define_expand "sltu" |
b932f770 JH |
12458 | [(set (match_operand:QI 0 "register_operand" "") |
12459 | (ltu:QI (reg:CC 17) (const_int 0)))] | |
c572e5ba | 12460 | "" |
3a3677ff | 12461 | "if (ix86_expand_setcc (LTU, operands[0])) DONE; else FAIL;") |
c572e5ba | 12462 | |
c572e5ba | 12463 | (define_expand "sge" |
b932f770 JH |
12464 | [(set (match_operand:QI 0 "register_operand" "") |
12465 | (ge:QI (reg:CC 17) (const_int 0)))] | |
c572e5ba | 12466 | "" |
3a3677ff | 12467 | "if (ix86_expand_setcc (GE, operands[0])) DONE; else FAIL;") |
c572e5ba | 12468 | |
c572e5ba | 12469 | (define_expand "sgeu" |
b932f770 JH |
12470 | [(set (match_operand:QI 0 "register_operand" "") |
12471 | (geu:QI (reg:CC 17) (const_int 0)))] | |
c572e5ba | 12472 | "" |
3a3677ff | 12473 | "if (ix86_expand_setcc (GEU, operands[0])) DONE; else FAIL;") |
c572e5ba | 12474 | |
c572e5ba | 12475 | (define_expand "sle" |
b932f770 JH |
12476 | [(set (match_operand:QI 0 "register_operand" "") |
12477 | (le:QI (reg:CC 17) (const_int 0)))] | |
c572e5ba | 12478 | "" |
3a3677ff | 12479 | "if (ix86_expand_setcc (LE, operands[0])) DONE; else FAIL;") |
c572e5ba | 12480 | |
c785c660 | 12481 | (define_expand "sleu" |
b932f770 JH |
12482 | [(set (match_operand:QI 0 "register_operand" "") |
12483 | (leu:QI (reg:CC 17) (const_int 0)))] | |
c785c660 | 12484 | "" |
3a3677ff RH |
12485 | "if (ix86_expand_setcc (LEU, operands[0])) DONE; else FAIL;") |
12486 | ||
12487 | (define_expand "sunordered" | |
b932f770 JH |
12488 | [(set (match_operand:QI 0 "register_operand" "") |
12489 | (unordered:QI (reg:CC 17) (const_int 0)))] | |
0644b628 | 12490 | "TARGET_80387 || TARGET_SSE" |
3a3677ff RH |
12491 | "if (ix86_expand_setcc (UNORDERED, operands[0])) DONE; else FAIL;") |
12492 | ||
12493 | (define_expand "sordered" | |
b932f770 JH |
12494 | [(set (match_operand:QI 0 "register_operand" "") |
12495 | (ordered:QI (reg:CC 17) (const_int 0)))] | |
3a3677ff RH |
12496 | "TARGET_80387" |
12497 | "if (ix86_expand_setcc (ORDERED, operands[0])) DONE; else FAIL;") | |
12498 | ||
12499 | (define_expand "suneq" | |
b932f770 JH |
12500 | [(set (match_operand:QI 0 "register_operand" "") |
12501 | (uneq:QI (reg:CC 17) (const_int 0)))] | |
0644b628 | 12502 | "TARGET_80387 || TARGET_SSE" |
3a3677ff RH |
12503 | "if (ix86_expand_setcc (UNEQ, operands[0])) DONE; else FAIL;") |
12504 | ||
12505 | (define_expand "sunge" | |
b932f770 JH |
12506 | [(set (match_operand:QI 0 "register_operand" "") |
12507 | (unge:QI (reg:CC 17) (const_int 0)))] | |
0644b628 | 12508 | "TARGET_80387 || TARGET_SSE" |
3a3677ff RH |
12509 | "if (ix86_expand_setcc (UNGE, operands[0])) DONE; else FAIL;") |
12510 | ||
12511 | (define_expand "sungt" | |
b932f770 JH |
12512 | [(set (match_operand:QI 0 "register_operand" "") |
12513 | (ungt:QI (reg:CC 17) (const_int 0)))] | |
0644b628 | 12514 | "TARGET_80387 || TARGET_SSE" |
3a3677ff RH |
12515 | "if (ix86_expand_setcc (UNGT, operands[0])) DONE; else FAIL;") |
12516 | ||
12517 | (define_expand "sunle" | |
b932f770 JH |
12518 | [(set (match_operand:QI 0 "register_operand" "") |
12519 | (unle:QI (reg:CC 17) (const_int 0)))] | |
0644b628 | 12520 | "TARGET_80387 || TARGET_SSE" |
3a3677ff RH |
12521 | "if (ix86_expand_setcc (UNLE, operands[0])) DONE; else FAIL;") |
12522 | ||
12523 | (define_expand "sunlt" | |
b932f770 JH |
12524 | [(set (match_operand:QI 0 "register_operand" "") |
12525 | (unlt:QI (reg:CC 17) (const_int 0)))] | |
0644b628 | 12526 | "TARGET_80387 || TARGET_SSE" |
3a3677ff RH |
12527 | "if (ix86_expand_setcc (UNLT, operands[0])) DONE; else FAIL;") |
12528 | ||
12529 | (define_expand "sltgt" | |
b932f770 JH |
12530 | [(set (match_operand:QI 0 "register_operand" "") |
12531 | (ltgt:QI (reg:CC 17) (const_int 0)))] | |
0644b628 | 12532 | "TARGET_80387 || TARGET_SSE" |
3a3677ff | 12533 | "if (ix86_expand_setcc (LTGT, operands[0])) DONE; else FAIL;") |
c785c660 | 12534 | |
e075ae69 | 12535 | (define_insn "*setcc_1" |
a269a03c | 12536 | [(set (match_operand:QI 0 "nonimmediate_operand" "=qm") |
9076b9c1 | 12537 | (match_operator:QI 1 "ix86_comparison_operator" |
e075ae69 RH |
12538 | [(reg 17) (const_int 0)]))] |
12539 | "" | |
0f40f9f7 | 12540 | "set%C1\t%0" |
6ef67412 JH |
12541 | [(set_attr "type" "setcc") |
12542 | (set_attr "mode" "QI")]) | |
a269a03c | 12543 | |
bd793c65 | 12544 | (define_insn "setcc_2" |
e075ae69 | 12545 | [(set (strict_low_part (match_operand:QI 0 "nonimmediate_operand" "+qm")) |
9076b9c1 | 12546 | (match_operator:QI 1 "ix86_comparison_operator" |
e075ae69 RH |
12547 | [(reg 17) (const_int 0)]))] |
12548 | "" | |
0f40f9f7 | 12549 | "set%C1\t%0" |
6ef67412 JH |
12550 | [(set_attr "type" "setcc") |
12551 | (set_attr "mode" "QI")]) | |
e075ae69 | 12552 | |
10978207 RH |
12553 | ;; In general it is not safe to assume too much about CCmode registers, |
12554 | ;; so simplify-rtx stops when it sees a second one. Under certain | |
12555 | ;; conditions this is safe on x86, so help combine not create | |
12556 | ;; | |
12557 | ;; seta %al | |
12558 | ;; testb %al, %al | |
12559 | ;; sete %al | |
12560 | ||
12561 | (define_split | |
12562 | [(set (match_operand:QI 0 "nonimmediate_operand" "") | |
12563 | (ne:QI (match_operator 1 "ix86_comparison_operator" | |
12564 | [(reg 17) (const_int 0)]) | |
12565 | (const_int 0)))] | |
12566 | "" | |
12567 | [(set (match_dup 0) (match_dup 1))] | |
12568 | { | |
12569 | PUT_MODE (operands[1], QImode); | |
12570 | }) | |
12571 | ||
12572 | (define_split | |
12573 | [(set (strict_low_part (match_operand:QI 0 "nonimmediate_operand" "")) | |
12574 | (ne:QI (match_operator 1 "ix86_comparison_operator" | |
12575 | [(reg 17) (const_int 0)]) | |
12576 | (const_int 0)))] | |
12577 | "" | |
12578 | [(set (match_dup 0) (match_dup 1))] | |
12579 | { | |
12580 | PUT_MODE (operands[1], QImode); | |
12581 | }) | |
12582 | ||
12583 | (define_split | |
12584 | [(set (match_operand:QI 0 "nonimmediate_operand" "") | |
12585 | (eq:QI (match_operator 1 "ix86_comparison_operator" | |
12586 | [(reg 17) (const_int 0)]) | |
12587 | (const_int 0)))] | |
12588 | "" | |
12589 | [(set (match_dup 0) (match_dup 1))] | |
12590 | { | |
12591 | rtx new_op1 = copy_rtx (operands[1]); | |
12592 | operands[1] = new_op1; | |
12593 | PUT_MODE (new_op1, QImode); | |
12594 | PUT_CODE (new_op1, REVERSE_CONDITION (GET_CODE (new_op1), | |
12595 | GET_MODE (XEXP (new_op1, 0)))); | |
12596 | ||
12597 | /* Make sure that (a) the CCmode we have for the flags is strong | |
12598 | enough for the reversed compare or (b) we have a valid FP compare. */ | |
12599 | if (! ix86_comparison_operator (new_op1, VOIDmode)) | |
12600 | FAIL; | |
12601 | }) | |
12602 | ||
12603 | (define_split | |
12604 | [(set (strict_low_part (match_operand:QI 0 "nonimmediate_operand" "")) | |
12605 | (eq:QI (match_operator 1 "ix86_comparison_operator" | |
12606 | [(reg 17) (const_int 0)]) | |
12607 | (const_int 0)))] | |
12608 | "" | |
12609 | [(set (match_dup 0) (match_dup 1))] | |
12610 | { | |
12611 | rtx new_op1 = copy_rtx (operands[1]); | |
12612 | operands[1] = new_op1; | |
12613 | PUT_MODE (new_op1, QImode); | |
12614 | PUT_CODE (new_op1, REVERSE_CONDITION (GET_CODE (new_op1), | |
12615 | GET_MODE (XEXP (new_op1, 0)))); | |
12616 | ||
12617 | /* Make sure that (a) the CCmode we have for the flags is strong | |
12618 | enough for the reversed compare or (b) we have a valid FP compare. */ | |
12619 | if (! ix86_comparison_operator (new_op1, VOIDmode)) | |
12620 | FAIL; | |
12621 | }) | |
12622 | ||
a46d1d38 JH |
12623 | ;; The SSE store flag instructions saves 0 or 0xffffffff to the result. |
12624 | ;; subsequent logical operations are used to imitate conditional moves. | |
12625 | ;; 0xffffffff is NaN, but not in normalized form, so we can't represent | |
12626 | ;; it directly. Futher holding this value in pseudo register might bring | |
12627 | ;; problem in implicit normalization in spill code. | |
12628 | ;; So we don't define FLOAT_STORE_FLAG_VALUE and create these | |
12629 | ;; instructions after reload by splitting the conditional move patterns. | |
12630 | ||
12631 | (define_insn "*sse_setccsf" | |
12632 | [(set (match_operand:SF 0 "register_operand" "=x") | |
12633 | (match_operator:SF 1 "sse_comparison_operator" | |
12634 | [(match_operand:SF 2 "register_operand" "0") | |
12635 | (match_operand:SF 3 "nonimmediate_operand" "xm")]))] | |
12636 | "TARGET_SSE && reload_completed" | |
0f40f9f7 | 12637 | "cmp%D1ss\t{%3, %0|%0, %3}" |
a46d1d38 JH |
12638 | [(set_attr "type" "sse") |
12639 | (set_attr "mode" "SF")]) | |
12640 | ||
12641 | (define_insn "*sse_setccdf" | |
12642 | [(set (match_operand:DF 0 "register_operand" "=Y") | |
12643 | (match_operator:DF 1 "sse_comparison_operator" | |
12644 | [(match_operand:DF 2 "register_operand" "0") | |
12645 | (match_operand:DF 3 "nonimmediate_operand" "Ym")]))] | |
12646 | "TARGET_SSE2 && reload_completed" | |
0f40f9f7 | 12647 | "cmp%D1sd\t{%3, %0|%0, %3}" |
a46d1d38 JH |
12648 | [(set_attr "type" "sse") |
12649 | (set_attr "mode" "DF")]) | |
886c62d1 JVA |
12650 | \f |
12651 | ;; Basic conditional jump instructions. | |
12652 | ;; We ignore the overflow flag for signed branch instructions. | |
12653 | ||
c572e5ba | 12654 | ;; For all bCOND expanders, also expand the compare or test insn that |
e075ae69 | 12655 | ;; generates reg 17. Generate an equality comparison if `beq' or `bne'. |
c572e5ba JVA |
12656 | |
12657 | (define_expand "beq" | |
e075ae69 RH |
12658 | [(set (pc) |
12659 | (if_then_else (match_dup 1) | |
c572e5ba JVA |
12660 | (label_ref (match_operand 0 "" "")) |
12661 | (pc)))] | |
12662 | "" | |
3a3677ff | 12663 | "ix86_expand_branch (EQ, operands[0]); DONE;") |
c572e5ba | 12664 | |
c572e5ba | 12665 | (define_expand "bne" |
e075ae69 RH |
12666 | [(set (pc) |
12667 | (if_then_else (match_dup 1) | |
c572e5ba JVA |
12668 | (label_ref (match_operand 0 "" "")) |
12669 | (pc)))] | |
12670 | "" | |
3a3677ff | 12671 | "ix86_expand_branch (NE, operands[0]); DONE;") |
886c62d1 | 12672 | |
c572e5ba | 12673 | (define_expand "bgt" |
e075ae69 RH |
12674 | [(set (pc) |
12675 | (if_then_else (match_dup 1) | |
c572e5ba JVA |
12676 | (label_ref (match_operand 0 "" "")) |
12677 | (pc)))] | |
12678 | "" | |
3a3677ff | 12679 | "ix86_expand_branch (GT, operands[0]); DONE;") |
c572e5ba | 12680 | |
c572e5ba | 12681 | (define_expand "bgtu" |
e075ae69 RH |
12682 | [(set (pc) |
12683 | (if_then_else (match_dup 1) | |
c572e5ba JVA |
12684 | (label_ref (match_operand 0 "" "")) |
12685 | (pc)))] | |
12686 | "" | |
3a3677ff | 12687 | "ix86_expand_branch (GTU, operands[0]); DONE;") |
886c62d1 | 12688 | |
886c62d1 | 12689 | (define_expand "blt" |
e075ae69 RH |
12690 | [(set (pc) |
12691 | (if_then_else (match_dup 1) | |
886c62d1 JVA |
12692 | (label_ref (match_operand 0 "" "")) |
12693 | (pc)))] | |
12694 | "" | |
3a3677ff | 12695 | "ix86_expand_branch (LT, operands[0]); DONE;") |
886c62d1 | 12696 | |
c572e5ba | 12697 | (define_expand "bltu" |
e075ae69 RH |
12698 | [(set (pc) |
12699 | (if_then_else (match_dup 1) | |
c572e5ba JVA |
12700 | (label_ref (match_operand 0 "" "")) |
12701 | (pc)))] | |
12702 | "" | |
3a3677ff | 12703 | "ix86_expand_branch (LTU, operands[0]); DONE;") |
c572e5ba | 12704 | |
c572e5ba | 12705 | (define_expand "bge" |
e075ae69 RH |
12706 | [(set (pc) |
12707 | (if_then_else (match_dup 1) | |
c572e5ba JVA |
12708 | (label_ref (match_operand 0 "" "")) |
12709 | (pc)))] | |
12710 | "" | |
3a3677ff | 12711 | "ix86_expand_branch (GE, operands[0]); DONE;") |
c572e5ba | 12712 | |
c572e5ba | 12713 | (define_expand "bgeu" |
e075ae69 RH |
12714 | [(set (pc) |
12715 | (if_then_else (match_dup 1) | |
c572e5ba JVA |
12716 | (label_ref (match_operand 0 "" "")) |
12717 | (pc)))] | |
12718 | "" | |
3a3677ff | 12719 | "ix86_expand_branch (GEU, operands[0]); DONE;") |
886c62d1 | 12720 | |
886c62d1 | 12721 | (define_expand "ble" |
e075ae69 RH |
12722 | [(set (pc) |
12723 | (if_then_else (match_dup 1) | |
886c62d1 JVA |
12724 | (label_ref (match_operand 0 "" "")) |
12725 | (pc)))] | |
12726 | "" | |
3a3677ff | 12727 | "ix86_expand_branch (LE, operands[0]); DONE;") |
886c62d1 | 12728 | |
c572e5ba | 12729 | (define_expand "bleu" |
e075ae69 RH |
12730 | [(set (pc) |
12731 | (if_then_else (match_dup 1) | |
c572e5ba JVA |
12732 | (label_ref (match_operand 0 "" "")) |
12733 | (pc)))] | |
12734 | "" | |
3a3677ff RH |
12735 | "ix86_expand_branch (LEU, operands[0]); DONE;") |
12736 | ||
12737 | (define_expand "bunordered" | |
12738 | [(set (pc) | |
12739 | (if_then_else (match_dup 1) | |
12740 | (label_ref (match_operand 0 "" "")) | |
12741 | (pc)))] | |
0644b628 | 12742 | "TARGET_80387 || TARGET_SSE" |
3a3677ff RH |
12743 | "ix86_expand_branch (UNORDERED, operands[0]); DONE;") |
12744 | ||
12745 | (define_expand "bordered" | |
12746 | [(set (pc) | |
12747 | (if_then_else (match_dup 1) | |
12748 | (label_ref (match_operand 0 "" "")) | |
12749 | (pc)))] | |
0644b628 | 12750 | "TARGET_80387 || TARGET_SSE" |
3a3677ff RH |
12751 | "ix86_expand_branch (ORDERED, operands[0]); DONE;") |
12752 | ||
12753 | (define_expand "buneq" | |
12754 | [(set (pc) | |
12755 | (if_then_else (match_dup 1) | |
12756 | (label_ref (match_operand 0 "" "")) | |
12757 | (pc)))] | |
0644b628 | 12758 | "TARGET_80387 || TARGET_SSE" |
3a3677ff RH |
12759 | "ix86_expand_branch (UNEQ, operands[0]); DONE;") |
12760 | ||
12761 | (define_expand "bunge" | |
12762 | [(set (pc) | |
12763 | (if_then_else (match_dup 1) | |
12764 | (label_ref (match_operand 0 "" "")) | |
12765 | (pc)))] | |
0644b628 | 12766 | "TARGET_80387 || TARGET_SSE" |
3a3677ff RH |
12767 | "ix86_expand_branch (UNGE, operands[0]); DONE;") |
12768 | ||
12769 | (define_expand "bungt" | |
12770 | [(set (pc) | |
12771 | (if_then_else (match_dup 1) | |
12772 | (label_ref (match_operand 0 "" "")) | |
12773 | (pc)))] | |
0644b628 | 12774 | "TARGET_80387 || TARGET_SSE" |
3a3677ff RH |
12775 | "ix86_expand_branch (UNGT, operands[0]); DONE;") |
12776 | ||
12777 | (define_expand "bunle" | |
12778 | [(set (pc) | |
12779 | (if_then_else (match_dup 1) | |
12780 | (label_ref (match_operand 0 "" "")) | |
12781 | (pc)))] | |
0644b628 | 12782 | "TARGET_80387 || TARGET_SSE" |
3a3677ff RH |
12783 | "ix86_expand_branch (UNLE, operands[0]); DONE;") |
12784 | ||
12785 | (define_expand "bunlt" | |
12786 | [(set (pc) | |
12787 | (if_then_else (match_dup 1) | |
12788 | (label_ref (match_operand 0 "" "")) | |
12789 | (pc)))] | |
0644b628 | 12790 | "TARGET_80387 || TARGET_SSE" |
3a3677ff RH |
12791 | "ix86_expand_branch (UNLT, operands[0]); DONE;") |
12792 | ||
12793 | (define_expand "bltgt" | |
12794 | [(set (pc) | |
12795 | (if_then_else (match_dup 1) | |
12796 | (label_ref (match_operand 0 "" "")) | |
12797 | (pc)))] | |
0644b628 | 12798 | "TARGET_80387 || TARGET_SSE" |
3a3677ff | 12799 | "ix86_expand_branch (LTGT, operands[0]); DONE;") |
886c62d1 | 12800 | |
e075ae69 RH |
12801 | (define_insn "*jcc_1" |
12802 | [(set (pc) | |
9076b9c1 | 12803 | (if_then_else (match_operator 1 "ix86_comparison_operator" |
e075ae69 | 12804 | [(reg 17) (const_int 0)]) |
6ef67412 | 12805 | (label_ref (match_operand 0 "" "")) |
e075ae69 RH |
12806 | (pc)))] |
12807 | "" | |
0f40f9f7 | 12808 | "%+j%C1\t%l0" |
e075ae69 | 12809 | [(set_attr "type" "ibr") |
6ef67412 JH |
12810 | (set (attr "prefix_0f") |
12811 | (if_then_else (and (ge (minus (match_dup 0) (pc)) | |
12812 | (const_int -128)) | |
12813 | (lt (minus (match_dup 0) (pc)) | |
12814 | (const_int 124))) | |
12815 | (const_int 0) | |
12816 | (const_int 1)))]) | |
e075ae69 RH |
12817 | |
12818 | (define_insn "*jcc_2" | |
12819 | [(set (pc) | |
9076b9c1 | 12820 | (if_then_else (match_operator 1 "ix86_comparison_operator" |
e075ae69 RH |
12821 | [(reg 17) (const_int 0)]) |
12822 | (pc) | |
6ef67412 | 12823 | (label_ref (match_operand 0 "" ""))))] |
e075ae69 | 12824 | "" |
0f40f9f7 | 12825 | "%+j%c1\t%l0" |
e075ae69 | 12826 | [(set_attr "type" "ibr") |
6ef67412 JH |
12827 | (set (attr "prefix_0f") |
12828 | (if_then_else (and (ge (minus (match_dup 0) (pc)) | |
12829 | (const_int -128)) | |
12830 | (lt (minus (match_dup 0) (pc)) | |
12831 | (const_int 124))) | |
12832 | (const_int 0) | |
12833 | (const_int 1)))]) | |
e075ae69 | 12834 | |
592188a5 RH |
12835 | ;; In general it is not safe to assume too much about CCmode registers, |
12836 | ;; so simplify-rtx stops when it sees a second one. Under certain | |
12837 | ;; conditions this is safe on x86, so help combine not create | |
12838 | ;; | |
12839 | ;; seta %al | |
12840 | ;; testb %al, %al | |
12841 | ;; je Lfoo | |
12842 | ||
12843 | (define_split | |
12844 | [(set (pc) | |
12845 | (if_then_else (ne (match_operator 0 "ix86_comparison_operator" | |
12846 | [(reg 17) (const_int 0)]) | |
12847 | (const_int 0)) | |
12848 | (label_ref (match_operand 1 "" "")) | |
12849 | (pc)))] | |
12850 | "" | |
12851 | [(set (pc) | |
12852 | (if_then_else (match_dup 0) | |
12853 | (label_ref (match_dup 1)) | |
12854 | (pc)))] | |
12855 | { | |
12856 | PUT_MODE (operands[0], VOIDmode); | |
12857 | }) | |
12858 | ||
12859 | (define_split | |
12860 | [(set (pc) | |
12861 | (if_then_else (eq (match_operator 0 "ix86_comparison_operator" | |
12862 | [(reg 17) (const_int 0)]) | |
12863 | (const_int 0)) | |
12864 | (label_ref (match_operand 1 "" "")) | |
12865 | (pc)))] | |
12866 | "" | |
12867 | [(set (pc) | |
12868 | (if_then_else (match_dup 0) | |
12869 | (label_ref (match_dup 1)) | |
12870 | (pc)))] | |
12871 | { | |
12872 | rtx new_op0 = copy_rtx (operands[0]); | |
12873 | operands[0] = new_op0; | |
12874 | PUT_MODE (new_op0, VOIDmode); | |
12875 | PUT_CODE (new_op0, REVERSE_CONDITION (GET_CODE (new_op0), | |
12876 | GET_MODE (XEXP (new_op0, 0)))); | |
12877 | ||
12878 | /* Make sure that (a) the CCmode we have for the flags is strong | |
12879 | enough for the reversed compare or (b) we have a valid FP compare. */ | |
12880 | if (! ix86_comparison_operator (new_op0, VOIDmode)) | |
12881 | FAIL; | |
12882 | }) | |
12883 | ||
3a3677ff RH |
12884 | ;; Define combination compare-and-branch fp compare instructions to use |
12885 | ;; during early optimization. Splitting the operation apart early makes | |
12886 | ;; for bad code when we want to reverse the operation. | |
12887 | ||
12888 | (define_insn "*fp_jcc_1" | |
12889 | [(set (pc) | |
12890 | (if_then_else (match_operator 0 "comparison_operator" | |
12891 | [(match_operand 1 "register_operand" "f") | |
12892 | (match_operand 2 "register_operand" "f")]) | |
12893 | (label_ref (match_operand 3 "" "")) | |
12894 | (pc))) | |
12895 | (clobber (reg:CCFP 18)) | |
12896 | (clobber (reg:CCFP 17))] | |
12897 | "TARGET_CMOVE && TARGET_80387 | |
0644b628 | 12898 | && !SSE_FLOAT_MODE_P (GET_MODE (operands[1])) |
3a3677ff | 12899 | && FLOAT_MODE_P (GET_MODE (operands[1])) |
03598dea JH |
12900 | && GET_MODE (operands[1]) == GET_MODE (operands[2]) |
12901 | && ix86_fp_jump_nontrivial_p (GET_CODE (operands[0]))" | |
3a3677ff RH |
12902 | "#") |
12903 | ||
0644b628 JH |
12904 | (define_insn "*fp_jcc_1_sse" |
12905 | [(set (pc) | |
12906 | (if_then_else (match_operator 0 "comparison_operator" | |
12907 | [(match_operand 1 "register_operand" "f#x,x#f") | |
12908 | (match_operand 2 "nonimmediate_operand" "f#x,xm#f")]) | |
12909 | (label_ref (match_operand 3 "" "")) | |
12910 | (pc))) | |
12911 | (clobber (reg:CCFP 18)) | |
12912 | (clobber (reg:CCFP 17))] | |
12913 | "TARGET_80387 | |
12914 | && SSE_FLOAT_MODE_P (GET_MODE (operands[1])) | |
03598dea JH |
12915 | && GET_MODE (operands[1]) == GET_MODE (operands[2]) |
12916 | && ix86_fp_jump_nontrivial_p (GET_CODE (operands[0]))" | |
0644b628 JH |
12917 | "#") |
12918 | ||
12919 | (define_insn "*fp_jcc_1_sse_only" | |
12920 | [(set (pc) | |
12921 | (if_then_else (match_operator 0 "comparison_operator" | |
12922 | [(match_operand 1 "register_operand" "x") | |
12923 | (match_operand 2 "nonimmediate_operand" "xm")]) | |
12924 | (label_ref (match_operand 3 "" "")) | |
12925 | (pc))) | |
12926 | (clobber (reg:CCFP 18)) | |
12927 | (clobber (reg:CCFP 17))] | |
12928 | "SSE_FLOAT_MODE_P (GET_MODE (operands[1])) | |
03598dea JH |
12929 | && GET_MODE (operands[1]) == GET_MODE (operands[2]) |
12930 | && ix86_fp_jump_nontrivial_p (GET_CODE (operands[0]))" | |
0644b628 JH |
12931 | "#") |
12932 | ||
3a3677ff RH |
12933 | (define_insn "*fp_jcc_2" |
12934 | [(set (pc) | |
12935 | (if_then_else (match_operator 0 "comparison_operator" | |
12936 | [(match_operand 1 "register_operand" "f") | |
12937 | (match_operand 2 "register_operand" "f")]) | |
12938 | (pc) | |
12939 | (label_ref (match_operand 3 "" "")))) | |
12940 | (clobber (reg:CCFP 18)) | |
12941 | (clobber (reg:CCFP 17))] | |
12942 | "TARGET_CMOVE && TARGET_80387 | |
0644b628 | 12943 | && !SSE_FLOAT_MODE_P (GET_MODE (operands[1])) |
3a3677ff | 12944 | && FLOAT_MODE_P (GET_MODE (operands[1])) |
03598dea JH |
12945 | && GET_MODE (operands[1]) == GET_MODE (operands[2]) |
12946 | && ix86_fp_jump_nontrivial_p (GET_CODE (operands[0]))" | |
3a3677ff RH |
12947 | "#") |
12948 | ||
0644b628 JH |
12949 | (define_insn "*fp_jcc_2_sse" |
12950 | [(set (pc) | |
12951 | (if_then_else (match_operator 0 "comparison_operator" | |
12952 | [(match_operand 1 "register_operand" "f#x,x#f") | |
12953 | (match_operand 2 "nonimmediate_operand" "f#x,xm#f")]) | |
12954 | (pc) | |
12955 | (label_ref (match_operand 3 "" "")))) | |
12956 | (clobber (reg:CCFP 18)) | |
12957 | (clobber (reg:CCFP 17))] | |
12958 | "TARGET_80387 | |
12959 | && SSE_FLOAT_MODE_P (GET_MODE (operands[1])) | |
03598dea JH |
12960 | && GET_MODE (operands[1]) == GET_MODE (operands[2]) |
12961 | && ix86_fp_jump_nontrivial_p (GET_CODE (operands[0]))" | |
0644b628 JH |
12962 | "#") |
12963 | ||
12964 | (define_insn "*fp_jcc_2_sse_only" | |
12965 | [(set (pc) | |
12966 | (if_then_else (match_operator 0 "comparison_operator" | |
12967 | [(match_operand 1 "register_operand" "x") | |
12968 | (match_operand 2 "nonimmediate_operand" "xm")]) | |
12969 | (pc) | |
12970 | (label_ref (match_operand 3 "" "")))) | |
12971 | (clobber (reg:CCFP 18)) | |
12972 | (clobber (reg:CCFP 17))] | |
12973 | "SSE_FLOAT_MODE_P (GET_MODE (operands[1])) | |
03598dea JH |
12974 | && GET_MODE (operands[1]) == GET_MODE (operands[2]) |
12975 | && ix86_fp_jump_nontrivial_p (GET_CODE (operands[0]))" | |
0644b628 JH |
12976 | "#") |
12977 | ||
3a3677ff RH |
12978 | (define_insn "*fp_jcc_3" |
12979 | [(set (pc) | |
b1cdafbb | 12980 | (if_then_else (match_operator 0 "comparison_operator" |
3a3677ff RH |
12981 | [(match_operand 1 "register_operand" "f") |
12982 | (match_operand 2 "nonimmediate_operand" "fm")]) | |
12983 | (label_ref (match_operand 3 "" "")) | |
12984 | (pc))) | |
12985 | (clobber (reg:CCFP 18)) | |
12986 | (clobber (reg:CCFP 17)) | |
12987 | (clobber (match_scratch:HI 4 "=a"))] | |
12988 | "TARGET_80387 | |
12989 | && (GET_MODE (operands[1]) == SFmode || GET_MODE (operands[1]) == DFmode) | |
a940d8bd | 12990 | && GET_MODE (operands[1]) == GET_MODE (operands[2]) |
b1cdafbb JH |
12991 | && !ix86_use_fcomi_compare (GET_CODE (operands[0])) |
12992 | && SELECT_CC_MODE (GET_CODE (operands[0]), | |
03598dea JH |
12993 | operands[1], operands[2]) == CCFPmode |
12994 | && ix86_fp_jump_nontrivial_p (GET_CODE (operands[0]))" | |
3a3677ff RH |
12995 | "#") |
12996 | ||
12997 | (define_insn "*fp_jcc_4" | |
12998 | [(set (pc) | |
b1cdafbb | 12999 | (if_then_else (match_operator 0 "comparison_operator" |
3a3677ff RH |
13000 | [(match_operand 1 "register_operand" "f") |
13001 | (match_operand 2 "nonimmediate_operand" "fm")]) | |
13002 | (pc) | |
13003 | (label_ref (match_operand 3 "" "")))) | |
13004 | (clobber (reg:CCFP 18)) | |
13005 | (clobber (reg:CCFP 17)) | |
13006 | (clobber (match_scratch:HI 4 "=a"))] | |
13007 | "TARGET_80387 | |
13008 | && (GET_MODE (operands[1]) == SFmode || GET_MODE (operands[1]) == DFmode) | |
a940d8bd | 13009 | && GET_MODE (operands[1]) == GET_MODE (operands[2]) |
b1cdafbb JH |
13010 | && !ix86_use_fcomi_compare (GET_CODE (operands[0])) |
13011 | && SELECT_CC_MODE (GET_CODE (operands[0]), | |
03598dea JH |
13012 | operands[1], operands[2]) == CCFPmode |
13013 | && ix86_fp_jump_nontrivial_p (GET_CODE (operands[0]))" | |
3a3677ff RH |
13014 | "#") |
13015 | ||
13016 | (define_insn "*fp_jcc_5" | |
13017 | [(set (pc) | |
13018 | (if_then_else (match_operator 0 "comparison_operator" | |
13019 | [(match_operand 1 "register_operand" "f") | |
13020 | (match_operand 2 "register_operand" "f")]) | |
13021 | (label_ref (match_operand 3 "" "")) | |
13022 | (pc))) | |
13023 | (clobber (reg:CCFP 18)) | |
13024 | (clobber (reg:CCFP 17)) | |
13025 | (clobber (match_scratch:HI 4 "=a"))] | |
13026 | "TARGET_80387 | |
13027 | && FLOAT_MODE_P (GET_MODE (operands[1])) | |
03598dea JH |
13028 | && GET_MODE (operands[1]) == GET_MODE (operands[2]) |
13029 | && ix86_fp_jump_nontrivial_p (GET_CODE (operands[0]))" | |
3a3677ff RH |
13030 | "#") |
13031 | ||
13032 | (define_insn "*fp_jcc_6" | |
13033 | [(set (pc) | |
13034 | (if_then_else (match_operator 0 "comparison_operator" | |
13035 | [(match_operand 1 "register_operand" "f") | |
13036 | (match_operand 2 "register_operand" "f")]) | |
13037 | (pc) | |
13038 | (label_ref (match_operand 3 "" "")))) | |
13039 | (clobber (reg:CCFP 18)) | |
13040 | (clobber (reg:CCFP 17)) | |
13041 | (clobber (match_scratch:HI 4 "=a"))] | |
13042 | "TARGET_80387 | |
13043 | && FLOAT_MODE_P (GET_MODE (operands[1])) | |
03598dea JH |
13044 | && GET_MODE (operands[1]) == GET_MODE (operands[2]) |
13045 | && ix86_fp_jump_nontrivial_p (GET_CODE (operands[0]))" | |
3a3677ff RH |
13046 | "#") |
13047 | ||
13048 | (define_split | |
13049 | [(set (pc) | |
13050 | (if_then_else (match_operator 0 "comparison_operator" | |
13051 | [(match_operand 1 "register_operand" "") | |
13052 | (match_operand 2 "nonimmediate_operand" "")]) | |
13053 | (match_operand 3 "" "") | |
13054 | (match_operand 4 "" ""))) | |
13055 | (clobber (reg:CCFP 18)) | |
13056 | (clobber (reg:CCFP 17))] | |
13057 | "reload_completed" | |
9e7adcb3 | 13058 | [(const_int 0)] |
3a3677ff | 13059 | { |
03598dea | 13060 | ix86_split_fp_branch (GET_CODE (operands[0]), operands[1], operands[2], |
9e7adcb3 JH |
13061 | operands[3], operands[4], NULL_RTX); |
13062 | DONE; | |
0f40f9f7 | 13063 | }) |
3a3677ff RH |
13064 | |
13065 | (define_split | |
13066 | [(set (pc) | |
13067 | (if_then_else (match_operator 0 "comparison_operator" | |
13068 | [(match_operand 1 "register_operand" "") | |
13069 | (match_operand 2 "nonimmediate_operand" "")]) | |
13070 | (match_operand 3 "" "") | |
13071 | (match_operand 4 "" ""))) | |
13072 | (clobber (reg:CCFP 18)) | |
13073 | (clobber (reg:CCFP 17)) | |
13074 | (clobber (match_scratch:HI 5 "=a"))] | |
13075 | "reload_completed" | |
13076 | [(set (pc) | |
13077 | (if_then_else (match_dup 6) | |
13078 | (match_dup 3) | |
13079 | (match_dup 4)))] | |
3a3677ff | 13080 | { |
03598dea | 13081 | ix86_split_fp_branch (GET_CODE (operands[0]), operands[1], operands[2], |
9e7adcb3 JH |
13082 | operands[3], operands[4], operands[5]); |
13083 | DONE; | |
0f40f9f7 | 13084 | }) |
886c62d1 JVA |
13085 | \f |
13086 | ;; Unconditional and other jump instructions | |
13087 | ||
13088 | (define_insn "jump" | |
13089 | [(set (pc) | |
13090 | (label_ref (match_operand 0 "" "")))] | |
13091 | "" | |
0f40f9f7 | 13092 | "jmp\t%l0" |
6ef67412 | 13093 | [(set_attr "type" "ibr")]) |
886c62d1 | 13094 | |
14f73b5a JH |
13095 | (define_expand "indirect_jump" |
13096 | [(set (pc) (match_operand 0 "nonimmediate_operand" "rm"))] | |
886c62d1 | 13097 | "" |
14f73b5a JH |
13098 | "") |
13099 | ||
13100 | (define_insn "*indirect_jump" | |
13101 | [(set (pc) (match_operand:SI 0 "nonimmediate_operand" "rm"))] | |
13102 | "!TARGET_64BIT" | |
13103 | "jmp\t%A0" | |
13104 | [(set_attr "type" "ibr") | |
13105 | (set_attr "length_immediate" "0")]) | |
13106 | ||
13107 | (define_insn "*indirect_jump_rtx64" | |
13108 | [(set (pc) (match_operand:DI 0 "nonimmediate_operand" "rm"))] | |
13109 | "TARGET_64BIT" | |
0f40f9f7 | 13110 | "jmp\t%A0" |
6ef67412 JH |
13111 | [(set_attr "type" "ibr") |
13112 | (set_attr "length_immediate" "0")]) | |
4801403e | 13113 | |
90675921 | 13114 | (define_expand "tablejump" |
6eb791fc | 13115 | [(parallel [(set (pc) (match_operand 0 "nonimmediate_operand" "rm")) |
90675921 RH |
13116 | (use (label_ref (match_operand 1 "" "")))])] |
13117 | "" | |
13118 | { | |
13119 | /* In PIC mode, the table entries are stored GOT-relative. Convert | |
13120 | the relative address to an absolute address. */ | |
13121 | if (flag_pic) | |
13122 | { | |
6eb791fc JH |
13123 | if (TARGET_64BIT) |
13124 | operands[0] = expand_simple_binop (Pmode, PLUS, operands[0], | |
44cf5b6a JH |
13125 | gen_rtx_LABEL_REF (Pmode, operands[1]), |
13126 | NULL_RTX, 0, | |
6eb791fc | 13127 | OPTAB_DIRECT); |
f88c65f7 RH |
13128 | else if (HAVE_AS_GOTOFF_IN_DATA) |
13129 | { | |
13130 | operands[0] = expand_simple_binop (Pmode, PLUS, operands[0], | |
13131 | pic_offset_table_rtx, NULL_RTX, | |
13132 | 1, OPTAB_DIRECT); | |
13133 | current_function_uses_pic_offset_table = 1; | |
13134 | } | |
6eb791fc JH |
13135 | else |
13136 | { | |
13137 | operands[0] = expand_simple_binop (Pmode, MINUS, pic_offset_table_rtx, | |
13138 | operands[0], NULL_RTX, 1, | |
13139 | OPTAB_DIRECT); | |
13140 | current_function_uses_pic_offset_table = 1; | |
13141 | } | |
90675921 | 13142 | } |
0f40f9f7 | 13143 | }) |
2bb7a0f5 | 13144 | |
90675921 | 13145 | (define_insn "*tablejump_1" |
2ae0f82c | 13146 | [(set (pc) (match_operand:SI 0 "nonimmediate_operand" "rm")) |
886c62d1 | 13147 | (use (label_ref (match_operand 1 "" "")))] |
14f73b5a JH |
13148 | "!TARGET_64BIT" |
13149 | "jmp\t%A0" | |
13150 | [(set_attr "type" "ibr") | |
13151 | (set_attr "length_immediate" "0")]) | |
13152 | ||
13153 | (define_insn "*tablejump_1_rtx64" | |
13154 | [(set (pc) (match_operand:DI 0 "nonimmediate_operand" "rm")) | |
13155 | (use (label_ref (match_operand 1 "" "")))] | |
13156 | "TARGET_64BIT" | |
0f40f9f7 | 13157 | "jmp\t%A0" |
6ef67412 JH |
13158 | [(set_attr "type" "ibr") |
13159 | (set_attr "length_immediate" "0")]) | |
e075ae69 RH |
13160 | \f |
13161 | ;; Loop instruction | |
13162 | ;; | |
13163 | ;; This is all complicated by the fact that since this is a jump insn | |
13164 | ;; we must handle our own reloads. | |
13165 | ||
5527bf14 RH |
13166 | (define_expand "doloop_end" |
13167 | [(use (match_operand 0 "" "")) ; loop pseudo | |
13168 | (use (match_operand 1 "" "")) ; iterations; zero if unknown | |
13169 | (use (match_operand 2 "" "")) ; max iterations | |
13170 | (use (match_operand 3 "" "")) ; loop level | |
13171 | (use (match_operand 4 "" ""))] ; label | |
1b0c37d7 | 13172 | "!TARGET_64BIT && TARGET_USE_LOOP" |
5527bf14 RH |
13173 | " |
13174 | { | |
13175 | /* Only use cloop on innermost loops. */ | |
13176 | if (INTVAL (operands[3]) > 1) | |
13177 | FAIL; | |
13178 | if (GET_MODE (operands[0]) != SImode) | |
13179 | FAIL; | |
13180 | emit_jump_insn (gen_doloop_end_internal (operands[4], operands[0], | |
13181 | operands[0])); | |
13182 | DONE; | |
13183 | }") | |
e075ae69 | 13184 | |
5527bf14 | 13185 | (define_insn "doloop_end_internal" |
e075ae69 | 13186 | [(set (pc) |
5527bf14 | 13187 | (if_then_else (ne (match_operand:SI 1 "register_operand" "c,?*r,?*r") |
e075ae69 RH |
13188 | (const_int 1)) |
13189 | (label_ref (match_operand 0 "" "")) | |
13190 | (pc))) | |
5527bf14 | 13191 | (set (match_operand:SI 2 "register_operand" "=1,1,*m*r") |
e075ae69 RH |
13192 | (plus:SI (match_dup 1) |
13193 | (const_int -1))) | |
13194 | (clobber (match_scratch:SI 3 "=X,X,r")) | |
13195 | (clobber (reg:CC 17))] | |
1b0c37d7 | 13196 | "!TARGET_64BIT && TARGET_USE_LOOP" |
e075ae69 RH |
13197 | { |
13198 | if (which_alternative != 0) | |
0f40f9f7 | 13199 | return "#"; |
e075ae69 | 13200 | if (get_attr_length (insn) == 2) |
0f40f9f7 | 13201 | return "%+loop\t%l0"; |
e075ae69 | 13202 | else |
0f40f9f7 ZW |
13203 | return "dec{l}\t%1\;%+jne\t%l0"; |
13204 | } | |
6ef67412 JH |
13205 | [(set_attr "ppro_uops" "many") |
13206 | (set (attr "type") | |
e075ae69 RH |
13207 | (if_then_else (and (eq_attr "alternative" "0") |
13208 | (and (ge (minus (match_dup 0) (pc)) | |
13209 | (const_int -128)) | |
13210 | (lt (minus (match_dup 0) (pc)) | |
13211 | (const_int 124)))) | |
6ef67412 JH |
13212 | (const_string "ibr") |
13213 | (const_string "multi")))]) | |
e075ae69 | 13214 | |
e075ae69 RH |
13215 | (define_split |
13216 | [(set (pc) | |
13217 | (if_then_else (ne (match_operand:SI 1 "register_operand" "") | |
13218 | (const_int 1)) | |
13219 | (match_operand 0 "" "") | |
13220 | (pc))) | |
5527bf14 | 13221 | (set (match_dup 1) |
e075ae69 RH |
13222 | (plus:SI (match_dup 1) |
13223 | (const_int -1))) | |
5527bf14 | 13224 | (clobber (match_scratch:SI 2 "")) |
e075ae69 | 13225 | (clobber (reg:CC 17))] |
1b0c37d7 | 13226 | "!TARGET_64BIT && TARGET_USE_LOOP |
5527bf14 RH |
13227 | && reload_completed |
13228 | && REGNO (operands[1]) != 2" | |
13229 | [(parallel [(set (reg:CCZ 17) | |
13230 | (compare:CCZ (plus:SI (match_dup 1) (const_int -1)) | |
e075ae69 | 13231 | (const_int 0))) |
5527bf14 | 13232 | (set (match_dup 1) (plus:SI (match_dup 1) (const_int -1)))]) |
16189740 | 13233 | (set (pc) (if_then_else (ne (reg:CCZ 17) (const_int 0)) |
e075ae69 RH |
13234 | (match_dup 0) |
13235 | (pc)))] | |
13236 | "") | |
13237 | ||
13238 | (define_split | |
13239 | [(set (pc) | |
13240 | (if_then_else (ne (match_operand:SI 1 "register_operand" "") | |
13241 | (const_int 1)) | |
13242 | (match_operand 0 "" "") | |
13243 | (pc))) | |
5527bf14 | 13244 | (set (match_operand:SI 2 "nonimmediate_operand" "") |
e075ae69 RH |
13245 | (plus:SI (match_dup 1) |
13246 | (const_int -1))) | |
13247 | (clobber (match_scratch:SI 3 "")) | |
13248 | (clobber (reg:CC 17))] | |
1b0c37d7 | 13249 | "!TARGET_64BIT && TARGET_USE_LOOP |
5527bf14 RH |
13250 | && reload_completed |
13251 | && (! REG_P (operands[2]) | |
13252 | || ! rtx_equal_p (operands[1], operands[2]))" | |
e075ae69 | 13253 | [(set (match_dup 3) (match_dup 1)) |
16189740 RH |
13254 | (parallel [(set (reg:CCZ 17) |
13255 | (compare:CCZ (plus:SI (match_dup 3) (const_int -1)) | |
13256 | (const_int 0))) | |
e075ae69 RH |
13257 | (set (match_dup 3) (plus:SI (match_dup 3) (const_int -1)))]) |
13258 | (set (match_dup 2) (match_dup 3)) | |
16189740 | 13259 | (set (pc) (if_then_else (ne (reg:CCZ 17) (const_int 0)) |
e075ae69 RH |
13260 | (match_dup 0) |
13261 | (pc)))] | |
13262 | "") | |
c50e5bc0 RH |
13263 | |
13264 | ;; Convert setcc + movzbl to xor + setcc if operands don't overlap. | |
13265 | ||
13266 | (define_peephole2 | |
13267 | [(set (reg 17) (match_operand 0 "" "")) | |
13268 | (set (match_operand:QI 1 "register_operand" "") | |
13269 | (match_operator:QI 2 "ix86_comparison_operator" | |
13270 | [(reg 17) (const_int 0)])) | |
13271 | (set (match_operand 3 "q_regs_operand" "") | |
13272 | (zero_extend (match_dup 1)))] | |
646ded90 RH |
13273 | "(peep2_reg_dead_p (3, operands[1]) |
13274 | || operands_match_p (operands[1], operands[3])) | |
c50e5bc0 | 13275 | && ! reg_overlap_mentioned_p (operands[3], operands[0])" |
646ded90 RH |
13276 | [(set (match_dup 4) (match_dup 0)) |
13277 | (set (strict_low_part (match_dup 5)) | |
13278 | (match_dup 2))] | |
13279 | { | |
13280 | operands[4] = gen_rtx_REG (GET_MODE (operands[0]), 17); | |
13281 | operands[5] = gen_rtx_REG (QImode, REGNO (operands[3])); | |
a8bac9ab | 13282 | ix86_expand_clear (operands[3]); |
646ded90 RH |
13283 | }) |
13284 | ||
13285 | ;; Similar, but match zero_extendhisi2_and, which adds a clobber. | |
13286 | ||
13287 | (define_peephole2 | |
13288 | [(set (reg 17) (match_operand 0 "" "")) | |
13289 | (set (match_operand:QI 1 "register_operand" "") | |
13290 | (match_operator:QI 2 "ix86_comparison_operator" | |
13291 | [(reg 17) (const_int 0)])) | |
13292 | (parallel [(set (match_operand 3 "q_regs_operand" "") | |
13293 | (zero_extend (match_dup 1))) | |
13294 | (clobber (reg:CC 17))])] | |
13295 | "(peep2_reg_dead_p (3, operands[1]) | |
13296 | || operands_match_p (operands[1], operands[3])) | |
13297 | && ! reg_overlap_mentioned_p (operands[3], operands[0])" | |
13298 | [(set (match_dup 4) (match_dup 0)) | |
c50e5bc0 RH |
13299 | (set (strict_low_part (match_dup 5)) |
13300 | (match_dup 2))] | |
646ded90 RH |
13301 | { |
13302 | operands[4] = gen_rtx_REG (GET_MODE (operands[0]), 17); | |
13303 | operands[5] = gen_rtx_REG (QImode, REGNO (operands[3])); | |
a8bac9ab | 13304 | ix86_expand_clear (operands[3]); |
646ded90 | 13305 | }) |
e075ae69 RH |
13306 | \f |
13307 | ;; Call instructions. | |
2bb7a0f5 | 13308 | |
cbbf65e0 RH |
13309 | ;; The predicates normally associated with named expanders are not properly |
13310 | ;; checked for calls. This is a bug in the generic code, but it isn't that | |
13311 | ;; easy to fix. Ignore it for now and be prepared to fix things up. | |
2bb7a0f5 | 13312 | |
886c62d1 JVA |
13313 | ;; Call subroutine returning no value. |
13314 | ||
2bb7a0f5 | 13315 | (define_expand "call_pop" |
cbbf65e0 RH |
13316 | [(parallel [(call (match_operand:QI 0 "" "") |
13317 | (match_operand:SI 1 "" "")) | |
2bb7a0f5 RS |
13318 | (set (reg:SI 7) |
13319 | (plus:SI (reg:SI 7) | |
cbbf65e0 | 13320 | (match_operand:SI 3 "" "")))])] |
1e07edd3 | 13321 | "!TARGET_64BIT" |
2bb7a0f5 | 13322 | { |
35e2d030 RH |
13323 | if (operands[3] == const0_rtx) |
13324 | { | |
32ee7d1d | 13325 | emit_insn (gen_call (operands[0], operands[1], constm1_rtx)); |
35e2d030 RH |
13326 | DONE; |
13327 | } | |
b848ded1 JH |
13328 | /* Static functions and indirect calls don't need |
13329 | current_function_uses_pic_offset_table. */ | |
13330 | if (flag_pic | |
2a4bbffa RH |
13331 | && GET_CODE (XEXP (operands[0], 0)) == SYMBOL_REF |
13332 | && ! SYMBOL_REF_FLAG (XEXP (operands[0], 0))) | |
2bb7a0f5 | 13333 | current_function_uses_pic_offset_table = 1; |
e1ff012c | 13334 | if (! call_insn_operand (XEXP (operands[0], 0), Pmode)) |
cbbf65e0 | 13335 | XEXP (operands[0], 0) = copy_to_mode_reg (Pmode, XEXP (operands[0], 0)); |
1e07edd3 JH |
13336 | if (TARGET_64BIT) |
13337 | abort(); | |
0f40f9f7 | 13338 | }) |
2bb7a0f5 | 13339 | |
94bb5d0c | 13340 | (define_insn "*call_pop_0" |
e1ff012c | 13341 | [(call (mem:QI (match_operand:SI 0 "constant_call_address_operand" "")) |
94bb5d0c RH |
13342 | (match_operand:SI 1 "" "")) |
13343 | (set (reg:SI 7) (plus:SI (reg:SI 7) | |
90d10fb9 | 13344 | (match_operand:SI 2 "immediate_operand" "")))] |
1e07edd3 | 13345 | "!TARGET_64BIT" |
94bb5d0c RH |
13346 | { |
13347 | if (SIBLING_CALL_P (insn)) | |
0f40f9f7 | 13348 | return "jmp\t%P0"; |
94bb5d0c | 13349 | else |
0f40f9f7 ZW |
13350 | return "call\t%P0"; |
13351 | } | |
94bb5d0c RH |
13352 | [(set_attr "type" "call")]) |
13353 | ||
cbbf65e0 | 13354 | (define_insn "*call_pop_1" |
e1ff012c | 13355 | [(call (mem:QI (match_operand:SI 0 "call_insn_operand" "rsm")) |
94bb5d0c | 13356 | (match_operand:SI 1 "" "")) |
886c62d1 | 13357 | (set (reg:SI 7) (plus:SI (reg:SI 7) |
90d10fb9 | 13358 | (match_operand:SI 2 "immediate_operand" "i")))] |
1e07edd3 | 13359 | "!TARGET_64BIT" |
886c62d1 | 13360 | { |
e1ff012c | 13361 | if (constant_call_address_operand (operands[0], Pmode)) |
94bb5d0c RH |
13362 | { |
13363 | if (SIBLING_CALL_P (insn)) | |
0f40f9f7 | 13364 | return "jmp\t%P0"; |
94bb5d0c | 13365 | else |
0f40f9f7 | 13366 | return "call\t%P0"; |
94bb5d0c | 13367 | } |
94bb5d0c | 13368 | if (SIBLING_CALL_P (insn)) |
0f40f9f7 | 13369 | return "jmp\t%A0"; |
94bb5d0c | 13370 | else |
0f40f9f7 ZW |
13371 | return "call\t%A0"; |
13372 | } | |
e075ae69 | 13373 | [(set_attr "type" "call")]) |
886c62d1 | 13374 | |
2bb7a0f5 | 13375 | (define_expand "call" |
cbbf65e0 | 13376 | [(call (match_operand:QI 0 "" "") |
39d04363 JH |
13377 | (match_operand 1 "" "")) |
13378 | (use (match_operand 2 "" ""))] | |
2bb7a0f5 RS |
13379 | ;; Operand 1 not used on the i386. |
13380 | "" | |
2bb7a0f5 | 13381 | { |
39d04363 | 13382 | rtx insn; |
b848ded1 JH |
13383 | /* Static functions and indirect calls don't need |
13384 | current_function_uses_pic_offset_table. */ | |
13385 | if (flag_pic | |
2a4bbffa RH |
13386 | && GET_CODE (XEXP (operands[0], 0)) == SYMBOL_REF |
13387 | && ! SYMBOL_REF_FLAG (XEXP (operands[0], 0))) | |
2bb7a0f5 | 13388 | current_function_uses_pic_offset_table = 1; |
32ee7d1d | 13389 | |
e1ff012c | 13390 | if (! call_insn_operand (XEXP (operands[0], 0), Pmode)) |
cbbf65e0 | 13391 | XEXP (operands[0], 0) = copy_to_mode_reg (Pmode, XEXP (operands[0], 0)); |
32ee7d1d JH |
13392 | if (TARGET_64BIT && INTVAL (operands[2]) >= 0) |
13393 | { | |
32ee7d1d JH |
13394 | rtx reg = gen_rtx_REG (QImode, 0); |
13395 | emit_move_insn (reg, operands[2]); | |
39d04363 | 13396 | insn = emit_call_insn (gen_call_exp (operands[0], operands[1])); |
32ee7d1d JH |
13397 | use_reg (&CALL_INSN_FUNCTION_USAGE (insn), reg); |
13398 | DONE; | |
13399 | } | |
39d04363 JH |
13400 | insn = emit_call_insn (gen_call_exp (operands[0], operands[1])); |
13401 | DONE; | |
0f40f9f7 | 13402 | }) |
2bb7a0f5 | 13403 | |
32ee7d1d JH |
13404 | (define_expand "call_exp" |
13405 | [(call (match_operand:QI 0 "" "") | |
13406 | (match_operand 1 "" ""))] | |
13407 | "" | |
13408 | "") | |
13409 | ||
94bb5d0c | 13410 | (define_insn "*call_0" |
32ee7d1d JH |
13411 | [(call (mem:QI (match_operand 0 "constant_call_address_operand" "")) |
13412 | (match_operand 1 "" ""))] | |
94bb5d0c | 13413 | "" |
94bb5d0c RH |
13414 | { |
13415 | if (SIBLING_CALL_P (insn)) | |
0f40f9f7 | 13416 | return "jmp\t%P0"; |
94bb5d0c | 13417 | else |
0f40f9f7 ZW |
13418 | return "call\t%P0"; |
13419 | } | |
94bb5d0c RH |
13420 | [(set_attr "type" "call")]) |
13421 | ||
cbbf65e0 | 13422 | (define_insn "*call_1" |
e1ff012c | 13423 | [(call (mem:QI (match_operand:SI 0 "call_insn_operand" "rsm")) |
32ee7d1d | 13424 | (match_operand 1 "" ""))] |
ac62a60e | 13425 | "!TARGET_64BIT" |
32ee7d1d JH |
13426 | { |
13427 | if (constant_call_address_operand (operands[0], QImode)) | |
13428 | { | |
13429 | if (SIBLING_CALL_P (insn)) | |
0f40f9f7 | 13430 | return "jmp\t%P0"; |
32ee7d1d | 13431 | else |
0f40f9f7 | 13432 | return "call\t%P0"; |
32ee7d1d JH |
13433 | } |
13434 | if (SIBLING_CALL_P (insn)) | |
0f40f9f7 | 13435 | return "jmp\t%A0"; |
32ee7d1d | 13436 | else |
0f40f9f7 ZW |
13437 | return "call\t%A0"; |
13438 | } | |
32ee7d1d JH |
13439 | [(set_attr "type" "call")]) |
13440 | ||
13441 | (define_insn "*call_1_rex64" | |
13442 | [(call (mem:QI (match_operand:DI 0 "call_insn_operand" "rsm")) | |
13443 | (match_operand 1 "" ""))] | |
ac62a60e | 13444 | "TARGET_64BIT" |
886c62d1 | 13445 | { |
94bb5d0c | 13446 | if (constant_call_address_operand (operands[0], QImode)) |
cbbf65e0 RH |
13447 | { |
13448 | if (SIBLING_CALL_P (insn)) | |
0f40f9f7 | 13449 | return "jmp\t%P0"; |
cbbf65e0 | 13450 | else |
0f40f9f7 | 13451 | return "call\t%P0"; |
cbbf65e0 | 13452 | } |
cbbf65e0 | 13453 | if (SIBLING_CALL_P (insn)) |
0f40f9f7 | 13454 | return "jmp\t%A0"; |
cbbf65e0 | 13455 | else |
0f40f9f7 ZW |
13456 | return "call\t%A0"; |
13457 | } | |
e075ae69 | 13458 | [(set_attr "type" "call")]) |
886c62d1 JVA |
13459 | |
13460 | ;; Call subroutine, returning value in operand 0 | |
13461 | ;; (which must be a hard register). | |
13462 | ||
2bb7a0f5 RS |
13463 | (define_expand "call_value_pop" |
13464 | [(parallel [(set (match_operand 0 "" "") | |
cbbf65e0 RH |
13465 | (call (match_operand:QI 1 "" "") |
13466 | (match_operand:SI 2 "" ""))) | |
2bb7a0f5 RS |
13467 | (set (reg:SI 7) |
13468 | (plus:SI (reg:SI 7) | |
cbbf65e0 | 13469 | (match_operand:SI 4 "" "")))])] |
1e07edd3 | 13470 | "!TARGET_64BIT" |
2bb7a0f5 | 13471 | { |
35e2d030 RH |
13472 | if (operands[4] == const0_rtx) |
13473 | { | |
32ee7d1d JH |
13474 | emit_insn (gen_call_value (operands[0], operands[1], operands[2], |
13475 | constm1_rtx)); | |
35e2d030 RH |
13476 | DONE; |
13477 | } | |
b848ded1 JH |
13478 | /* Static functions and indirect calls don't need |
13479 | current_function_uses_pic_offset_table. */ | |
13480 | if (flag_pic | |
2a4bbffa RH |
13481 | && GET_CODE (XEXP (operands[1], 0)) == SYMBOL_REF |
13482 | && ! SYMBOL_REF_FLAG (XEXP (operands[1], 0))) | |
2bb7a0f5 | 13483 | current_function_uses_pic_offset_table = 1; |
e1ff012c | 13484 | if (! call_insn_operand (XEXP (operands[1], 0), Pmode)) |
cbbf65e0 | 13485 | XEXP (operands[1], 0) = copy_to_mode_reg (Pmode, XEXP (operands[1], 0)); |
0f40f9f7 | 13486 | }) |
2bb7a0f5 | 13487 | |
2bb7a0f5 RS |
13488 | (define_expand "call_value" |
13489 | [(set (match_operand 0 "" "") | |
cbbf65e0 | 13490 | (call (match_operand:QI 1 "" "") |
39d04363 JH |
13491 | (match_operand:SI 2 "" ""))) |
13492 | (use (match_operand:SI 3 "" ""))] | |
2bb7a0f5 RS |
13493 | ;; Operand 2 not used on the i386. |
13494 | "" | |
2bb7a0f5 | 13495 | { |
39d04363 | 13496 | rtx insn; |
b848ded1 JH |
13497 | /* Static functions and indirect calls don't need |
13498 | current_function_uses_pic_offset_table. */ | |
13499 | if (flag_pic | |
2a4bbffa RH |
13500 | && GET_CODE (XEXP (operands[1], 0)) == SYMBOL_REF |
13501 | && ! SYMBOL_REF_FLAG (XEXP (operands[1], 0))) | |
2bb7a0f5 | 13502 | current_function_uses_pic_offset_table = 1; |
e1ff012c | 13503 | if (! call_insn_operand (XEXP (operands[1], 0), Pmode)) |
cbbf65e0 | 13504 | XEXP (operands[1], 0) = copy_to_mode_reg (Pmode, XEXP (operands[1], 0)); |
32ee7d1d JH |
13505 | if (TARGET_64BIT && INTVAL (operands[3]) >= 0) |
13506 | { | |
32ee7d1d JH |
13507 | rtx reg = gen_rtx_REG (QImode, 0); |
13508 | emit_move_insn (reg, operands[3]); | |
13509 | insn = emit_call_insn (gen_call_value_exp (operands[0], operands[1], | |
39d04363 | 13510 | operands[2])); |
32ee7d1d JH |
13511 | use_reg (&CALL_INSN_FUNCTION_USAGE (insn), reg); |
13512 | DONE; | |
13513 | } | |
39d04363 JH |
13514 | insn = emit_call_insn (gen_call_value_exp (operands[0], operands[1], |
13515 | operands[2])); | |
13516 | DONE; | |
0f40f9f7 | 13517 | }) |
2bb7a0f5 | 13518 | |
32ee7d1d JH |
13519 | (define_expand "call_value_exp" |
13520 | [(set (match_operand 0 "" "") | |
13521 | (call (match_operand:QI 1 "" "") | |
13522 | (match_operand:SI 2 "" "")))] | |
13523 | "" | |
13524 | "") | |
13525 | ||
b840bfb0 MM |
13526 | ;; Call subroutine returning any type. |
13527 | ||
576182a3 | 13528 | (define_expand "untyped_call" |
b840bfb0 | 13529 | [(parallel [(call (match_operand 0 "" "") |
576182a3 | 13530 | (const_int 0)) |
b840bfb0 | 13531 | (match_operand 1 "" "") |
576182a3 TW |
13532 | (match_operand 2 "" "")])] |
13533 | "" | |
576182a3 | 13534 | { |
b840bfb0 | 13535 | int i; |
576182a3 | 13536 | |
d8b679b9 RK |
13537 | /* In order to give reg-stack an easier job in validating two |
13538 | coprocessor registers as containing a possible return value, | |
13539 | simply pretend the untyped call returns a complex long double | |
13540 | value. */ | |
74775c7a | 13541 | |
d8b679b9 | 13542 | emit_call_insn (TARGET_80387 |
f64cecad | 13543 | ? gen_call_value (gen_rtx_REG (XCmode, FIRST_FLOAT_REG), |
32ee7d1d JH |
13544 | operands[0], const0_rtx, |
13545 | GEN_INT (SSE_REGPARM_MAX - 1)) | |
13546 | : gen_call (operands[0], const0_rtx, | |
13547 | GEN_INT (SSE_REGPARM_MAX - 1))); | |
576182a3 | 13548 | |
b840bfb0 | 13549 | for (i = 0; i < XVECLEN (operands[2], 0); i++) |
576182a3 | 13550 | { |
b840bfb0 MM |
13551 | rtx set = XVECEXP (operands[2], 0, i); |
13552 | emit_move_insn (SET_DEST (set), SET_SRC (set)); | |
576182a3 | 13553 | } |
576182a3 | 13554 | |
b840bfb0 MM |
13555 | /* The optimizer does not know that the call sets the function value |
13556 | registers we stored in the result block. We avoid problems by | |
13557 | claiming that all hard registers are used and clobbered at this | |
13558 | point. */ | |
13559 | emit_insn (gen_blockage ()); | |
576182a3 TW |
13560 | |
13561 | DONE; | |
0f40f9f7 | 13562 | }) |
e075ae69 RH |
13563 | \f |
13564 | ;; Prologue and epilogue instructions | |
576182a3 | 13565 | |
b840bfb0 MM |
13566 | ;; UNSPEC_VOLATILE is considered to use and clobber all hard registers and |
13567 | ;; all of memory. This blocks insns from being moved across this point. | |
13568 | ||
13569 | (define_insn "blockage" | |
13570 | [(unspec_volatile [(const_int 0)] 0)] | |
576182a3 | 13571 | "" |
90aec2cf | 13572 | "" |
e075ae69 | 13573 | [(set_attr "length" "0")]) |
576182a3 | 13574 | |
886c62d1 JVA |
13575 | ;; Insn emitted into the body of a function to return from a function. |
13576 | ;; This is only done if the function's epilogue is known to be simple. | |
182a4620 | 13577 | ;; See comments for ix86_can_use_return_insn_p in i386.c. |
886c62d1 | 13578 | |
5f3d14e3 | 13579 | (define_expand "return" |
886c62d1 | 13580 | [(return)] |
5f3d14e3 | 13581 | "ix86_can_use_return_insn_p ()" |
9a7372d6 RH |
13582 | { |
13583 | if (current_function_pops_args) | |
13584 | { | |
13585 | rtx popc = GEN_INT (current_function_pops_args); | |
13586 | emit_jump_insn (gen_return_pop_internal (popc)); | |
13587 | DONE; | |
13588 | } | |
0f40f9f7 | 13589 | }) |
5f3d14e3 SC |
13590 | |
13591 | (define_insn "return_internal" | |
13592 | [(return)] | |
13593 | "reload_completed" | |
90aec2cf | 13594 | "ret" |
6ef67412 JH |
13595 | [(set_attr "length" "1") |
13596 | (set_attr "length_immediate" "0") | |
13597 | (set_attr "modrm" "0")]) | |
5f3d14e3 | 13598 | |
6cd96118 SC |
13599 | (define_insn "return_pop_internal" |
13600 | [(return) | |
13601 | (use (match_operand:SI 0 "const_int_operand" ""))] | |
13602 | "reload_completed" | |
0f40f9f7 | 13603 | "ret\t%0" |
6ef67412 JH |
13604 | [(set_attr "length" "3") |
13605 | (set_attr "length_immediate" "2") | |
13606 | (set_attr "modrm" "0")]) | |
6cd96118 | 13607 | |
11837777 RH |
13608 | (define_insn "return_indirect_internal" |
13609 | [(return) | |
13610 | (use (match_operand:SI 0 "register_operand" "r"))] | |
13611 | "reload_completed" | |
0f40f9f7 | 13612 | "jmp\t%A0" |
11837777 RH |
13613 | [(set_attr "type" "ibr") |
13614 | (set_attr "length_immediate" "0")]) | |
13615 | ||
5f3d14e3 SC |
13616 | (define_insn "nop" |
13617 | [(const_int 0)] | |
13618 | "" | |
90aec2cf | 13619 | "nop" |
e075ae69 | 13620 | [(set_attr "length" "1") |
6ef67412 JH |
13621 | (set_attr "length_immediate" "0") |
13622 | (set_attr "modrm" "0") | |
e075ae69 | 13623 | (set_attr "ppro_uops" "one")]) |
5f3d14e3 SC |
13624 | |
13625 | (define_expand "prologue" | |
13626 | [(const_int 1)] | |
13627 | "" | |
e075ae69 | 13628 | "ix86_expand_prologue (); DONE;") |
5f3d14e3 | 13629 | |
e075ae69 | 13630 | (define_insn "prologue_set_got" |
69404d6f | 13631 | [(set (match_operand:SI 0 "register_operand" "=r") |
c76aab11 | 13632 | (unspec_volatile:SI |
e075ae69 RH |
13633 | [(plus:SI (match_dup 0) |
13634 | (plus:SI (match_operand:SI 1 "symbolic_operand" "") | |
13635 | (minus:SI (pc) (match_operand 2 "" ""))))] 1)) | |
13636 | (clobber (reg:CC 17))] | |
32ee7d1d | 13637 | "!TARGET_64BIT" |
47d36400 | 13638 | { |
e075ae69 RH |
13639 | if (GET_CODE (operands[2]) == LABEL_REF) |
13640 | operands[2] = XEXP (operands[2], 0); | |
13641 | if (TARGET_DEEP_BRANCH_PREDICTION) | |
0f40f9f7 | 13642 | return "add{l}\t{%1, %0|%0, %1}"; |
e075ae69 | 13643 | else |
0f40f9f7 ZW |
13644 | return "add{l}\t{%1+[.-%X2], %0|%0, %a1+(.-%X2)}"; |
13645 | } | |
6ef67412 | 13646 | [(set_attr "type" "alu") |
d731a1da JH |
13647 | ; Since this insn may have two constant operands, we must set the |
13648 | ; length manually. | |
13649 | (set_attr "length_immediate" "4") | |
6ef67412 | 13650 | (set_attr "mode" "SI")]) |
47d36400 | 13651 | |
e075ae69 | 13652 | (define_insn "prologue_get_pc" |
69404d6f | 13653 | [(set (match_operand:SI 0 "register_operand" "=r") |
c76aab11 | 13654 | (unspec_volatile:SI [(plus:SI (pc) (match_operand 1 "" ""))] 2))] |
1e07edd3 | 13655 | "!TARGET_64BIT" |
886c62d1 | 13656 | { |
e075ae69 RH |
13657 | if (GET_CODE (operands[1]) == LABEL_REF) |
13658 | operands[1] = XEXP (operands[1], 0); | |
0f40f9f7 | 13659 | output_asm_insn ("call\t%X1", operands); |
e075ae69 RH |
13660 | if (! TARGET_DEEP_BRANCH_PREDICTION) |
13661 | { | |
0f40f9f7 | 13662 | ASM_OUTPUT_INTERNAL_LABEL (asm_out_file, "L", |
e075ae69 RH |
13663 | CODE_LABEL_NUMBER (operands[1])); |
13664 | } | |
13665 | RET; | |
0f40f9f7 | 13666 | } |
e075ae69 | 13667 | [(set_attr "type" "multi")]) |
5f3d14e3 | 13668 | |
e075ae69 RH |
13669 | (define_expand "epilogue" |
13670 | [(const_int 1)] | |
13671 | "" | |
cbbf65e0 RH |
13672 | "ix86_expand_epilogue (1); DONE;") |
13673 | ||
13674 | (define_expand "sibcall_epilogue" | |
13675 | [(const_int 1)] | |
13676 | "" | |
13677 | "ix86_expand_epilogue (0); DONE;") | |
e075ae69 | 13678 | |
1020a5ab RH |
13679 | (define_expand "eh_return" |
13680 | [(use (match_operand 0 "register_operand" "")) | |
13681 | (use (match_operand 1 "register_operand" ""))] | |
13682 | "" | |
1020a5ab RH |
13683 | { |
13684 | rtx tmp, sa = operands[0], ra = operands[1]; | |
13685 | ||
13686 | /* Tricky bit: we write the address of the handler to which we will | |
13687 | be returning into someone else's stack frame, one word below the | |
13688 | stack address we wish to restore. */ | |
13689 | tmp = gen_rtx_PLUS (Pmode, arg_pointer_rtx, sa); | |
13690 | tmp = plus_constant (tmp, -UNITS_PER_WORD); | |
13691 | tmp = gen_rtx_MEM (Pmode, tmp); | |
13692 | emit_move_insn (tmp, ra); | |
13693 | ||
d5d6a58b RH |
13694 | if (Pmode == SImode) |
13695 | emit_insn (gen_eh_return_si (sa)); | |
13696 | else | |
13697 | emit_insn (gen_eh_return_di (sa)); | |
1020a5ab RH |
13698 | emit_barrier (); |
13699 | DONE; | |
0f40f9f7 | 13700 | }) |
1020a5ab | 13701 | |
d5d6a58b RH |
13702 | (define_insn_and_split "eh_return_si" |
13703 | [(unspec_volatile [(match_operand:SI 0 "register_operand" "c")] 13)] | |
1b0c37d7 | 13704 | "!TARGET_64BIT" |
d5d6a58b RH |
13705 | "#" |
13706 | "reload_completed" | |
13707 | [(const_int 1)] | |
13708 | "ix86_expand_epilogue (2); DONE;") | |
13709 | ||
13710 | (define_insn_and_split "eh_return_di" | |
13711 | [(unspec_volatile [(match_operand:DI 0 "register_operand" "c")] 13)] | |
1b0c37d7 | 13712 | "TARGET_64BIT" |
1020a5ab RH |
13713 | "#" |
13714 | "reload_completed" | |
13715 | [(const_int 1)] | |
13716 | "ix86_expand_epilogue (2); DONE;") | |
13717 | ||
e075ae69 | 13718 | (define_insn "leave" |
669fe758 | 13719 | [(set (reg:SI 7) (plus:SI (reg:SI 6) (const_int 4))) |
6fc5dc67 | 13720 | (set (reg:SI 6) (mem:SI (reg:SI 6))) |
f2042df3 | 13721 | (clobber (mem:BLK (scratch)))] |
1e07edd3 | 13722 | "!TARGET_64BIT" |
e075ae69 | 13723 | "leave" |
6ef67412 JH |
13724 | [(set_attr "length_immediate" "0") |
13725 | (set_attr "length" "1") | |
13726 | (set_attr "modrm" "0") | |
13727 | (set_attr "modrm" "0") | |
0b5107cf | 13728 | (set_attr "athlon_decode" "vector") |
e075ae69 | 13729 | (set_attr "ppro_uops" "few")]) |
8362f420 JH |
13730 | |
13731 | (define_insn "leave_rex64" | |
f283104b | 13732 | [(set (reg:DI 7) (plus:DI (reg:DI 6) (const_int 8))) |
6fc5dc67 | 13733 | (set (reg:DI 6) (mem:DI (reg:DI 6))) |
f2042df3 | 13734 | (clobber (mem:BLK (scratch)))] |
8362f420 JH |
13735 | "TARGET_64BIT" |
13736 | "leave" | |
13737 | [(set_attr "length_immediate" "0") | |
13738 | (set_attr "length" "1") | |
13739 | (set_attr "modrm" "0") | |
13740 | (set_attr "modrm" "0") | |
13741 | (set_attr "athlon_decode" "vector") | |
13742 | (set_attr "ppro_uops" "few")]) | |
e075ae69 RH |
13743 | \f |
13744 | (define_expand "ffssi2" | |
4cbfbb1b | 13745 | [(set (match_operand:SI 0 "nonimmediate_operand" "") |
e075ae69 RH |
13746 | (ffs:SI (match_operand:SI 1 "general_operand" "")))] |
13747 | "" | |
e075ae69 RH |
13748 | { |
13749 | rtx out = gen_reg_rtx (SImode), tmp = gen_reg_rtx (SImode); | |
13750 | rtx in = operands[1]; | |
13751 | ||
13752 | if (TARGET_CMOVE) | |
5f3d14e3 | 13753 | { |
e075ae69 RH |
13754 | emit_move_insn (tmp, constm1_rtx); |
13755 | emit_insn (gen_ffssi_1 (out, in)); | |
13756 | emit_insn (gen_rtx_SET (VOIDmode, out, | |
13757 | gen_rtx_IF_THEN_ELSE (SImode, | |
16189740 | 13758 | gen_rtx_EQ (VOIDmode, gen_rtx_REG (CCZmode, FLAGS_REG), |
e075ae69 RH |
13759 | const0_rtx), |
13760 | tmp, | |
13761 | out))); | |
e0dc26ff JH |
13762 | emit_insn (gen_addsi3 (out, out, const1_rtx)); |
13763 | emit_move_insn (operands[0], out); | |
13764 | } | |
13765 | ||
16189740 RH |
13766 | /* Pentium bsf instruction is extremly slow. The following code is |
13767 | recommended by the Intel Optimizing Manual as a reasonable replacement: | |
e0dc26ff JH |
13768 | TEST EAX,EAX |
13769 | JZ SHORT BS2 | |
13770 | XOR ECX,ECX | |
13771 | MOV DWORD PTR [TEMP+4],ECX | |
13772 | SUB ECX,EAX | |
13773 | AND EAX,ECX | |
13774 | MOV DWORD PTR [TEMP],EAX | |
13775 | FILD QWORD PTR [TEMP] | |
13776 | FSTP QWORD PTR [TEMP] | |
13777 | WAIT ; WAIT only needed for compatibility with | |
13778 | ; earlier processors | |
13779 | MOV ECX, DWORD PTR [TEMP+4] | |
13780 | SHR ECX,20 | |
13781 | SUB ECX,3FFH | |
13782 | TEST EAX,EAX ; clear zero flag | |
13783 | BS2: | |
13784 | Following piece of code expand ffs to similar beast. | |
13785 | */ | |
13786 | ||
13787 | else if (TARGET_PENTIUM && !optimize_size && TARGET_80387) | |
13788 | { | |
13789 | rtx label = gen_label_rtx (); | |
13790 | rtx lo, hi; | |
13791 | rtx mem = assign_386_stack_local (DImode, 0); | |
13792 | rtx fptmp = gen_reg_rtx (DFmode); | |
13793 | split_di (&mem, 1, &lo, &hi); | |
13794 | ||
13795 | emit_move_insn (out, const0_rtx); | |
13796 | ||
e790b36a | 13797 | emit_cmp_and_jump_insns (in, const0_rtx, EQ, 0, SImode, 1, label); |
e0dc26ff JH |
13798 | |
13799 | emit_move_insn (hi, out); | |
13800 | emit_insn (gen_subsi3 (out, out, in)); | |
13801 | emit_insn (gen_andsi3 (out, out, in)); | |
13802 | emit_move_insn (lo, out); | |
13803 | emit_insn (gen_floatdidf2 (fptmp,mem)); | |
13804 | emit_move_insn (gen_rtx_MEM (DFmode, XEXP (mem, 0)), fptmp); | |
13805 | emit_move_insn (out, hi); | |
13806 | emit_insn (gen_lshrsi3 (out, out, GEN_INT (20))); | |
16189740 | 13807 | emit_insn (gen_subsi3 (out, out, GEN_INT (0x3ff - 1))); |
e0dc26ff JH |
13808 | |
13809 | emit_label (label); | |
13810 | LABEL_NUSES (label) = 1; | |
13811 | ||
13812 | emit_move_insn (operands[0], out); | |
5f3d14e3 | 13813 | } |
e075ae69 | 13814 | else |
5f3d14e3 | 13815 | { |
e075ae69 RH |
13816 | emit_move_insn (tmp, const0_rtx); |
13817 | emit_insn (gen_ffssi_1 (out, in)); | |
13818 | emit_insn (gen_rtx_SET (VOIDmode, | |
13819 | gen_rtx_STRICT_LOW_PART (VOIDmode, gen_lowpart (QImode, tmp)), | |
16189740 | 13820 | gen_rtx_EQ (QImode, gen_rtx_REG (CCZmode, FLAGS_REG), |
e075ae69 RH |
13821 | const0_rtx))); |
13822 | emit_insn (gen_negsi2 (tmp, tmp)); | |
13823 | emit_insn (gen_iorsi3 (out, out, tmp)); | |
e0dc26ff JH |
13824 | emit_insn (gen_addsi3 (out, out, const1_rtx)); |
13825 | emit_move_insn (operands[0], out); | |
e075ae69 | 13826 | } |
e075ae69 | 13827 | DONE; |
0f40f9f7 | 13828 | }) |
886c62d1 | 13829 | |
e075ae69 | 13830 | (define_insn "ffssi_1" |
16189740 RH |
13831 | [(set (reg:CCZ 17) |
13832 | (compare:CCZ (match_operand:SI 1 "nonimmediate_operand" "rm") | |
13833 | (const_int 0))) | |
e075ae69 RH |
13834 | (set (match_operand:SI 0 "register_operand" "=r") |
13835 | (unspec:SI [(match_dup 1)] 5))] | |
13836 | "" | |
0f40f9f7 | 13837 | "bsf{l}\t{%1, %0|%0, %1}" |
6ef67412 | 13838 | [(set_attr "prefix_0f" "1") |
e075ae69 RH |
13839 | (set_attr "ppro_uops" "few")]) |
13840 | ||
13841 | ;; ffshi2 is not useful -- 4 word prefix ops are needed, which is larger | |
13842 | ;; and slower than the two-byte movzx insn needed to do the work in SImode. | |
13843 | \f | |
13844 | ;; These patterns match the binary 387 instructions for addM3, subM3, | |
13845 | ;; mulM3 and divM3. There are three patterns for each of DFmode and | |
13846 | ;; SFmode. The first is the normal insn, the second the same insn but | |
13847 | ;; with one operand a conversion, and the third the same insn but with | |
13848 | ;; the other operand a conversion. The conversion may be SFmode or | |
13849 | ;; SImode if the target mode DFmode, but only SImode if the target mode | |
13850 | ;; is SFmode. | |
13851 | ||
caa6ec8d JH |
13852 | ;; Gcc is slightly more smart about handling normal two address instructions |
13853 | ;; so use special patterns for add and mull. | |
965f5423 JH |
13854 | (define_insn "*fop_sf_comm_nosse" |
13855 | [(set (match_operand:SF 0 "register_operand" "=f") | |
13856 | (match_operator:SF 3 "binary_fp_operator" | |
13857 | [(match_operand:SF 1 "register_operand" "%0") | |
13858 | (match_operand:SF 2 "nonimmediate_operand" "fm")]))] | |
13859 | "TARGET_80387 && !TARGET_SSE_MATH | |
13860 | && GET_RTX_CLASS (GET_CODE (operands[3])) == 'c'" | |
13861 | "* return output_387_binary_op (insn, operands);" | |
13862 | [(set (attr "type") | |
13863 | (if_then_else (match_operand:SF 3 "mult_operator" "") | |
13864 | (const_string "fmul") | |
13865 | (const_string "fop"))) | |
13866 | (set_attr "mode" "SF")]) | |
13867 | ||
caa6ec8d | 13868 | (define_insn "*fop_sf_comm" |
1deaa899 | 13869 | [(set (match_operand:SF 0 "register_operand" "=f#x,x#f") |
caa6ec8d | 13870 | (match_operator:SF 3 "binary_fp_operator" |
1deaa899 JH |
13871 | [(match_operand:SF 1 "register_operand" "%0,0") |
13872 | (match_operand:SF 2 "nonimmediate_operand" "fm#x,xm#f")]))] | |
965f5423 | 13873 | "TARGET_80387 && TARGET_SSE_MATH && TARGET_MIX_SSE_I387 |
1deaa899 | 13874 | && GET_RTX_CLASS (GET_CODE (operands[3])) == 'c'" |
caa6ec8d JH |
13875 | "* return output_387_binary_op (insn, operands);" |
13876 | [(set (attr "type") | |
1deaa899 JH |
13877 | (if_then_else (eq_attr "alternative" "1") |
13878 | (const_string "sse") | |
13879 | (if_then_else (match_operand:SF 3 "mult_operator" "") | |
13880 | (const_string "fmul") | |
13881 | (const_string "fop")))) | |
13882 | (set_attr "mode" "SF")]) | |
13883 | ||
13884 | (define_insn "*fop_sf_comm_sse" | |
13885 | [(set (match_operand:SF 0 "register_operand" "=x") | |
13886 | (match_operator:SF 3 "binary_fp_operator" | |
13887 | [(match_operand:SF 1 "register_operand" "%0") | |
13888 | (match_operand:SF 2 "nonimmediate_operand" "xm")]))] | |
965f5423 | 13889 | "TARGET_SSE_MATH && GET_RTX_CLASS (GET_CODE (operands[3])) == 'c'" |
1deaa899 JH |
13890 | "* return output_387_binary_op (insn, operands);" |
13891 | [(set_attr "type" "sse") | |
6ef67412 | 13892 | (set_attr "mode" "SF")]) |
caa6ec8d | 13893 | |
965f5423 JH |
13894 | (define_insn "*fop_df_comm_nosse" |
13895 | [(set (match_operand:DF 0 "register_operand" "=f") | |
13896 | (match_operator:DF 3 "binary_fp_operator" | |
13897 | [(match_operand:DF 1 "register_operand" "%0") | |
13898 | (match_operand:DF 2 "nonimmediate_operand" "fm")]))] | |
13899 | "TARGET_80387 && (!TARGET_SSE2 || !TARGET_SSE_MATH) | |
13900 | && GET_RTX_CLASS (GET_CODE (operands[3])) == 'c'" | |
13901 | "* return output_387_binary_op (insn, operands);" | |
13902 | [(set (attr "type") | |
13903 | (if_then_else (match_operand:SF 3 "mult_operator" "") | |
13904 | (const_string "fmul") | |
13905 | (const_string "fop"))) | |
13906 | (set_attr "mode" "DF")]) | |
13907 | ||
caa6ec8d | 13908 | (define_insn "*fop_df_comm" |
1deaa899 | 13909 | [(set (match_operand:DF 0 "register_operand" "=f#Y,Y#f") |
caa6ec8d | 13910 | (match_operator:DF 3 "binary_fp_operator" |
1deaa899 JH |
13911 | [(match_operand:DF 1 "register_operand" "%0,0") |
13912 | (match_operand:DF 2 "nonimmediate_operand" "fm#Y,Ym#f")]))] | |
965f5423 | 13913 | "TARGET_80387 && TARGET_SSE_MATH && TARGET_SSE2 && TARGET_MIX_SSE_I387 |
1deaa899 | 13914 | && GET_RTX_CLASS (GET_CODE (operands[3])) == 'c'" |
caa6ec8d JH |
13915 | "* return output_387_binary_op (insn, operands);" |
13916 | [(set (attr "type") | |
1deaa899 JH |
13917 | (if_then_else (eq_attr "alternative" "1") |
13918 | (const_string "sse") | |
13919 | (if_then_else (match_operand:SF 3 "mult_operator" "") | |
13920 | (const_string "fmul") | |
13921 | (const_string "fop")))) | |
13922 | (set_attr "mode" "DF")]) | |
13923 | ||
13924 | (define_insn "*fop_df_comm_sse" | |
13925 | [(set (match_operand:DF 0 "register_operand" "=Y") | |
13926 | (match_operator:DF 3 "binary_fp_operator" | |
13927 | [(match_operand:DF 1 "register_operand" "%0") | |
13928 | (match_operand:DF 2 "nonimmediate_operand" "Ym")]))] | |
965f5423 | 13929 | "TARGET_SSE2 && TARGET_SSE_MATH |
1deaa899 JH |
13930 | && GET_RTX_CLASS (GET_CODE (operands[3])) == 'c'" |
13931 | "* return output_387_binary_op (insn, operands);" | |
13932 | [(set_attr "type" "sse") | |
6ef67412 | 13933 | (set_attr "mode" "DF")]) |
caa6ec8d JH |
13934 | |
13935 | (define_insn "*fop_xf_comm" | |
13936 | [(set (match_operand:XF 0 "register_operand" "=f") | |
13937 | (match_operator:XF 3 "binary_fp_operator" | |
13938 | [(match_operand:XF 1 "register_operand" "%0") | |
13939 | (match_operand:XF 2 "register_operand" "f")]))] | |
1b0c37d7 | 13940 | "!TARGET_64BIT && TARGET_80387 |
1e07edd3 | 13941 | && GET_RTX_CLASS (GET_CODE (operands[3])) == 'c'" |
caa6ec8d JH |
13942 | "* return output_387_binary_op (insn, operands);" |
13943 | [(set (attr "type") | |
13944 | (if_then_else (match_operand:XF 3 "mult_operator" "") | |
13945 | (const_string "fmul") | |
6ef67412 JH |
13946 | (const_string "fop"))) |
13947 | (set_attr "mode" "XF")]) | |
caa6ec8d | 13948 | |
2b589241 JH |
13949 | (define_insn "*fop_tf_comm" |
13950 | [(set (match_operand:TF 0 "register_operand" "=f") | |
13951 | (match_operator:TF 3 "binary_fp_operator" | |
13952 | [(match_operand:TF 1 "register_operand" "%0") | |
13953 | (match_operand:TF 2 "register_operand" "f")]))] | |
13954 | "TARGET_80387 && GET_RTX_CLASS (GET_CODE (operands[3])) == 'c'" | |
13955 | "* return output_387_binary_op (insn, operands);" | |
13956 | [(set (attr "type") | |
13957 | (if_then_else (match_operand:TF 3 "mult_operator" "") | |
13958 | (const_string "fmul") | |
13959 | (const_string "fop"))) | |
13960 | (set_attr "mode" "XF")]) | |
13961 | ||
965f5423 JH |
13962 | (define_insn "*fop_sf_1_nosse" |
13963 | [(set (match_operand:SF 0 "register_operand" "=f,f") | |
13964 | (match_operator:SF 3 "binary_fp_operator" | |
13965 | [(match_operand:SF 1 "nonimmediate_operand" "0,fm") | |
13966 | (match_operand:SF 2 "nonimmediate_operand" "fm,0")]))] | |
13967 | "TARGET_80387 && !TARGET_SSE_MATH | |
13968 | && GET_RTX_CLASS (GET_CODE (operands[3])) != 'c' | |
13969 | && (GET_CODE (operands[1]) != MEM || GET_CODE (operands[2]) != MEM)" | |
13970 | "* return output_387_binary_op (insn, operands);" | |
13971 | [(set (attr "type") | |
13972 | (cond [(match_operand:SF 3 "mult_operator" "") | |
13973 | (const_string "fmul") | |
13974 | (match_operand:SF 3 "div_operator" "") | |
13975 | (const_string "fdiv") | |
13976 | ] | |
13977 | (const_string "fop"))) | |
13978 | (set_attr "mode" "SF")]) | |
13979 | ||
e075ae69 | 13980 | (define_insn "*fop_sf_1" |
1deaa899 | 13981 | [(set (match_operand:SF 0 "register_operand" "=f,f,x") |
e075ae69 | 13982 | (match_operator:SF 3 "binary_fp_operator" |
1deaa899 JH |
13983 | [(match_operand:SF 1 "nonimmediate_operand" "0,fm,0") |
13984 | (match_operand:SF 2 "nonimmediate_operand" "fm,0,xm#f")]))] | |
965f5423 | 13985 | "TARGET_80387 && TARGET_SSE_MATH && TARGET_MIX_SSE_I387 |
caa6ec8d | 13986 | && GET_RTX_CLASS (GET_CODE (operands[3])) != 'c' |
f97d9ec3 | 13987 | && (GET_CODE (operands[1]) != MEM || GET_CODE (operands[2]) != MEM)" |
e075ae69 RH |
13988 | "* return output_387_binary_op (insn, operands);" |
13989 | [(set (attr "type") | |
1deaa899 JH |
13990 | (cond [(eq_attr "alternative" "2") |
13991 | (const_string "sse") | |
13992 | (match_operand:SF 3 "mult_operator" "") | |
e075ae69 RH |
13993 | (const_string "fmul") |
13994 | (match_operand:SF 3 "div_operator" "") | |
13995 | (const_string "fdiv") | |
13996 | ] | |
6ef67412 JH |
13997 | (const_string "fop"))) |
13998 | (set_attr "mode" "SF")]) | |
e075ae69 | 13999 | |
1deaa899 JH |
14000 | (define_insn "*fop_sf_1_sse" |
14001 | [(set (match_operand:SF 0 "register_operand" "=x") | |
14002 | (match_operator:SF 3 "binary_fp_operator" | |
14003 | [(match_operand:SF 1 "register_operand" "0") | |
14004 | (match_operand:SF 2 "nonimmediate_operand" "xm")]))] | |
965f5423 | 14005 | "TARGET_SSE_MATH |
1deaa899 JH |
14006 | && GET_RTX_CLASS (GET_CODE (operands[3])) != 'c'" |
14007 | "* return output_387_binary_op (insn, operands);" | |
14008 | [(set_attr "type" "sse") | |
14009 | (set_attr "mode" "SF")]) | |
14010 | ||
14011 | ;; ??? Add SSE splitters for these! | |
e075ae69 RH |
14012 | (define_insn "*fop_sf_2" |
14013 | [(set (match_operand:SF 0 "register_operand" "=f,f") | |
14014 | (match_operator:SF 3 "binary_fp_operator" | |
14015 | [(float:SF (match_operand:SI 1 "nonimmediate_operand" "m,?r")) | |
14016 | (match_operand:SF 2 "register_operand" "0,0")]))] | |
965f5423 | 14017 | "TARGET_80387 && TARGET_USE_FIOP && !TARGET_SSE_MATH" |
e075ae69 RH |
14018 | "* return which_alternative ? \"#\" : output_387_binary_op (insn, operands);" |
14019 | [(set (attr "type") | |
14020 | (cond [(match_operand:SF 3 "mult_operator" "") | |
14021 | (const_string "fmul") | |
14022 | (match_operand:SF 3 "div_operator" "") | |
14023 | (const_string "fdiv") | |
14024 | ] | |
14025 | (const_string "fop"))) | |
14026 | (set_attr "fp_int_src" "true") | |
6ef67412 JH |
14027 | (set_attr "ppro_uops" "many") |
14028 | (set_attr "mode" "SI")]) | |
e075ae69 RH |
14029 | |
14030 | (define_insn "*fop_sf_3" | |
14031 | [(set (match_operand:SF 0 "register_operand" "=f,f") | |
14032 | (match_operator:SF 3 "binary_fp_operator" | |
14033 | [(match_operand:SF 1 "register_operand" "0,0") | |
14034 | (float:SF (match_operand:SI 2 "nonimmediate_operand" "m,?r"))]))] | |
965f5423 | 14035 | "TARGET_80387 && TARGET_USE_FIOP && !TARGET_SSE_MATH" |
e075ae69 RH |
14036 | "* return which_alternative ? \"#\" : output_387_binary_op (insn, operands);" |
14037 | [(set (attr "type") | |
14038 | (cond [(match_operand:SF 3 "mult_operator" "") | |
14039 | (const_string "fmul") | |
14040 | (match_operand:SF 3 "div_operator" "") | |
14041 | (const_string "fdiv") | |
14042 | ] | |
14043 | (const_string "fop"))) | |
14044 | (set_attr "fp_int_src" "true") | |
6ef67412 JH |
14045 | (set_attr "ppro_uops" "many") |
14046 | (set_attr "mode" "SI")]) | |
e075ae69 | 14047 | |
965f5423 JH |
14048 | (define_insn "*fop_df_1_nosse" |
14049 | [(set (match_operand:DF 0 "register_operand" "=f,f") | |
14050 | (match_operator:DF 3 "binary_fp_operator" | |
14051 | [(match_operand:DF 1 "nonimmediate_operand" "0,fm") | |
14052 | (match_operand:DF 2 "nonimmediate_operand" "fm,0")]))] | |
14053 | "TARGET_80387 && (!TARGET_SSE2 || !TARGET_SSE_MATH) | |
14054 | && GET_RTX_CLASS (GET_CODE (operands[3])) != 'c' | |
14055 | && (GET_CODE (operands[1]) != MEM || GET_CODE (operands[2]) != MEM)" | |
14056 | "* return output_387_binary_op (insn, operands);" | |
14057 | [(set (attr "type") | |
14058 | (cond [(match_operand:DF 3 "mult_operator" "") | |
14059 | (const_string "fmul") | |
14060 | (match_operand:DF 3 "div_operator" "") | |
14061 | (const_string "fdiv") | |
14062 | ] | |
14063 | (const_string "fop"))) | |
14064 | (set_attr "mode" "DF")]) | |
14065 | ||
14066 | ||
e075ae69 | 14067 | (define_insn "*fop_df_1" |
1deaa899 | 14068 | [(set (match_operand:DF 0 "register_operand" "=f#Y,f#Y,Y#f") |
e075ae69 | 14069 | (match_operator:DF 3 "binary_fp_operator" |
1deaa899 JH |
14070 | [(match_operand:DF 1 "nonimmediate_operand" "0,fm,0") |
14071 | (match_operand:DF 2 "nonimmediate_operand" "fm,0,Ym#f")]))] | |
965f5423 | 14072 | "TARGET_80387 && TARGET_SSE2 && TARGET_SSE_MATH && TARGET_MIX_SSE_I387 |
caa6ec8d | 14073 | && GET_RTX_CLASS (GET_CODE (operands[3])) != 'c' |
f97d9ec3 | 14074 | && (GET_CODE (operands[1]) != MEM || GET_CODE (operands[2]) != MEM)" |
e075ae69 RH |
14075 | "* return output_387_binary_op (insn, operands);" |
14076 | [(set (attr "type") | |
1deaa899 JH |
14077 | (cond [(eq_attr "alternative" "2") |
14078 | (const_string "sse") | |
14079 | (match_operand:DF 3 "mult_operator" "") | |
e075ae69 RH |
14080 | (const_string "fmul") |
14081 | (match_operand:DF 3 "div_operator" "") | |
14082 | (const_string "fdiv") | |
14083 | ] | |
6ef67412 JH |
14084 | (const_string "fop"))) |
14085 | (set_attr "mode" "DF")]) | |
e075ae69 | 14086 | |
1deaa899 JH |
14087 | (define_insn "*fop_df_1_sse" |
14088 | [(set (match_operand:DF 0 "register_operand" "=Y") | |
14089 | (match_operator:DF 3 "binary_fp_operator" | |
14090 | [(match_operand:DF 1 "register_operand" "0") | |
14091 | (match_operand:DF 2 "nonimmediate_operand" "Ym")]))] | |
965f5423 | 14092 | "TARGET_SSE2 && TARGET_SSE_MATH |
1deaa899 JH |
14093 | && GET_RTX_CLASS (GET_CODE (operands[3])) != 'c'" |
14094 | "* return output_387_binary_op (insn, operands);" | |
14095 | [(set_attr "type" "sse")]) | |
14096 | ||
14097 | ;; ??? Add SSE splitters for these! | |
e075ae69 RH |
14098 | (define_insn "*fop_df_2" |
14099 | [(set (match_operand:DF 0 "register_operand" "=f,f") | |
14100 | (match_operator:DF 3 "binary_fp_operator" | |
14101 | [(float:DF (match_operand:SI 1 "nonimmediate_operand" "m,?r")) | |
14102 | (match_operand:DF 2 "register_operand" "0,0")]))] | |
965f5423 | 14103 | "TARGET_80387 && TARGET_USE_FIOP && !(TARGET_SSE2 && TARGET_SSE_MATH)" |
e075ae69 RH |
14104 | "* return which_alternative ? \"#\" : output_387_binary_op (insn, operands);" |
14105 | [(set (attr "type") | |
14106 | (cond [(match_operand:DF 3 "mult_operator" "") | |
14107 | (const_string "fmul") | |
14108 | (match_operand:DF 3 "div_operator" "") | |
14109 | (const_string "fdiv") | |
14110 | ] | |
14111 | (const_string "fop"))) | |
14112 | (set_attr "fp_int_src" "true") | |
6ef67412 JH |
14113 | (set_attr "ppro_uops" "many") |
14114 | (set_attr "mode" "SI")]) | |
e075ae69 RH |
14115 | |
14116 | (define_insn "*fop_df_3" | |
14117 | [(set (match_operand:DF 0 "register_operand" "=f,f") | |
14118 | (match_operator:DF 3 "binary_fp_operator" | |
14119 | [(match_operand:DF 1 "register_operand" "0,0") | |
14120 | (float:DF (match_operand:SI 2 "nonimmediate_operand" "m,?r"))]))] | |
965f5423 | 14121 | "TARGET_80387 && TARGET_USE_FIOP && !(TARGET_SSE2 && TARGET_SSE_MATH)" |
e075ae69 RH |
14122 | "* return which_alternative ? \"#\" : output_387_binary_op (insn, operands);" |
14123 | [(set (attr "type") | |
14124 | (cond [(match_operand:DF 3 "mult_operator" "") | |
14125 | (const_string "fmul") | |
14126 | (match_operand:DF 3 "div_operator" "") | |
14127 | (const_string "fdiv") | |
14128 | ] | |
14129 | (const_string "fop"))) | |
14130 | (set_attr "fp_int_src" "true") | |
6ef67412 JH |
14131 | (set_attr "ppro_uops" "many") |
14132 | (set_attr "mode" "SI")]) | |
e075ae69 RH |
14133 | |
14134 | (define_insn "*fop_df_4" | |
14135 | [(set (match_operand:DF 0 "register_operand" "=f,f") | |
14136 | (match_operator:DF 3 "binary_fp_operator" | |
14137 | [(float_extend:DF (match_operand:SF 1 "nonimmediate_operand" "fm,0")) | |
14138 | (match_operand:DF 2 "register_operand" "0,f")]))] | |
3987b9db | 14139 | "TARGET_80387 && (!TARGET_SSE2 || !TARGET_SSE_MATH) |
f97d9ec3 | 14140 | && (GET_CODE (operands[1]) != MEM || GET_CODE (operands[2]) != MEM)" |
e075ae69 RH |
14141 | "* return output_387_binary_op (insn, operands);" |
14142 | [(set (attr "type") | |
14143 | (cond [(match_operand:DF 3 "mult_operator" "") | |
14144 | (const_string "fmul") | |
14145 | (match_operand:DF 3 "div_operator" "") | |
14146 | (const_string "fdiv") | |
14147 | ] | |
6ef67412 JH |
14148 | (const_string "fop"))) |
14149 | (set_attr "mode" "SF")]) | |
e075ae69 RH |
14150 | |
14151 | (define_insn "*fop_df_5" | |
14152 | [(set (match_operand:DF 0 "register_operand" "=f,f") | |
14153 | (match_operator:DF 3 "binary_fp_operator" | |
14154 | [(match_operand:DF 1 "register_operand" "0,f") | |
14155 | (float_extend:DF | |
14156 | (match_operand:SF 2 "nonimmediate_operand" "fm,0"))]))] | |
965f5423 | 14157 | "TARGET_80387 && !(TARGET_SSE2 && TARGET_SSE_MATH)" |
e075ae69 RH |
14158 | "* return output_387_binary_op (insn, operands);" |
14159 | [(set (attr "type") | |
14160 | (cond [(match_operand:DF 3 "mult_operator" "") | |
14161 | (const_string "fmul") | |
14162 | (match_operand:DF 3 "div_operator" "") | |
14163 | (const_string "fdiv") | |
14164 | ] | |
6ef67412 JH |
14165 | (const_string "fop"))) |
14166 | (set_attr "mode" "SF")]) | |
e075ae69 RH |
14167 | |
14168 | (define_insn "*fop_xf_1" | |
14169 | [(set (match_operand:XF 0 "register_operand" "=f,f") | |
14170 | (match_operator:XF 3 "binary_fp_operator" | |
14171 | [(match_operand:XF 1 "register_operand" "0,f") | |
14172 | (match_operand:XF 2 "register_operand" "f,0")]))] | |
1b0c37d7 | 14173 | "!TARGET_64BIT && TARGET_80387 |
caa6ec8d | 14174 | && GET_RTX_CLASS (GET_CODE (operands[3])) != 'c'" |
e075ae69 RH |
14175 | "* return output_387_binary_op (insn, operands);" |
14176 | [(set (attr "type") | |
ca285e07 | 14177 | (cond [(match_operand:XF 3 "mult_operator" "") |
e075ae69 | 14178 | (const_string "fmul") |
ca285e07 | 14179 | (match_operand:XF 3 "div_operator" "") |
e075ae69 RH |
14180 | (const_string "fdiv") |
14181 | ] | |
6ef67412 JH |
14182 | (const_string "fop"))) |
14183 | (set_attr "mode" "XF")]) | |
e075ae69 | 14184 | |
2b589241 JH |
14185 | (define_insn "*fop_tf_1" |
14186 | [(set (match_operand:TF 0 "register_operand" "=f,f") | |
14187 | (match_operator:TF 3 "binary_fp_operator" | |
14188 | [(match_operand:TF 1 "register_operand" "0,f") | |
14189 | (match_operand:TF 2 "register_operand" "f,0")]))] | |
14190 | "TARGET_80387 | |
14191 | && GET_RTX_CLASS (GET_CODE (operands[3])) != 'c'" | |
14192 | "* return output_387_binary_op (insn, operands);" | |
14193 | [(set (attr "type") | |
14194 | (cond [(match_operand:TF 3 "mult_operator" "") | |
14195 | (const_string "fmul") | |
14196 | (match_operand:TF 3 "div_operator" "") | |
14197 | (const_string "fdiv") | |
14198 | ] | |
14199 | (const_string "fop"))) | |
14200 | (set_attr "mode" "XF")]) | |
14201 | ||
e075ae69 RH |
14202 | (define_insn "*fop_xf_2" |
14203 | [(set (match_operand:XF 0 "register_operand" "=f,f") | |
14204 | (match_operator:XF 3 "binary_fp_operator" | |
14205 | [(float:XF (match_operand:SI 1 "nonimmediate_operand" "m,?r")) | |
14206 | (match_operand:XF 2 "register_operand" "0,0")]))] | |
1b0c37d7 | 14207 | "!TARGET_64BIT && TARGET_80387 && TARGET_USE_FIOP" |
e075ae69 RH |
14208 | "* return which_alternative ? \"#\" : output_387_binary_op (insn, operands);" |
14209 | [(set (attr "type") | |
ca285e07 | 14210 | (cond [(match_operand:XF 3 "mult_operator" "") |
e075ae69 | 14211 | (const_string "fmul") |
ca285e07 | 14212 | (match_operand:XF 3 "div_operator" "") |
e075ae69 RH |
14213 | (const_string "fdiv") |
14214 | ] | |
14215 | (const_string "fop"))) | |
14216 | (set_attr "fp_int_src" "true") | |
6ef67412 | 14217 | (set_attr "mode" "SI") |
e075ae69 RH |
14218 | (set_attr "ppro_uops" "many")]) |
14219 | ||
2b589241 JH |
14220 | (define_insn "*fop_tf_2" |
14221 | [(set (match_operand:TF 0 "register_operand" "=f,f") | |
14222 | (match_operator:TF 3 "binary_fp_operator" | |
14223 | [(float:TF (match_operand:SI 1 "nonimmediate_operand" "m,?r")) | |
14224 | (match_operand:TF 2 "register_operand" "0,0")]))] | |
14225 | "TARGET_80387 && TARGET_USE_FIOP" | |
14226 | "* return which_alternative ? \"#\" : output_387_binary_op (insn, operands);" | |
14227 | [(set (attr "type") | |
14228 | (cond [(match_operand:TF 3 "mult_operator" "") | |
14229 | (const_string "fmul") | |
14230 | (match_operand:TF 3 "div_operator" "") | |
14231 | (const_string "fdiv") | |
14232 | ] | |
14233 | (const_string "fop"))) | |
14234 | (set_attr "fp_int_src" "true") | |
14235 | (set_attr "mode" "SI") | |
14236 | (set_attr "ppro_uops" "many")]) | |
14237 | ||
e075ae69 RH |
14238 | (define_insn "*fop_xf_3" |
14239 | [(set (match_operand:XF 0 "register_operand" "=f,f") | |
14240 | (match_operator:XF 3 "binary_fp_operator" | |
14241 | [(match_operand:XF 1 "register_operand" "0,0") | |
14242 | (float:XF (match_operand:SI 2 "nonimmediate_operand" "m,?r"))]))] | |
1b0c37d7 | 14243 | "!TARGET_64BIT && TARGET_80387 && TARGET_USE_FIOP" |
e075ae69 RH |
14244 | "* return which_alternative ? \"#\" : output_387_binary_op (insn, operands);" |
14245 | [(set (attr "type") | |
ca285e07 | 14246 | (cond [(match_operand:XF 3 "mult_operator" "") |
e075ae69 | 14247 | (const_string "fmul") |
ca285e07 | 14248 | (match_operand:XF 3 "div_operator" "") |
e075ae69 RH |
14249 | (const_string "fdiv") |
14250 | ] | |
14251 | (const_string "fop"))) | |
14252 | (set_attr "fp_int_src" "true") | |
6ef67412 | 14253 | (set_attr "mode" "SI") |
e075ae69 RH |
14254 | (set_attr "ppro_uops" "many")]) |
14255 | ||
2b589241 JH |
14256 | (define_insn "*fop_tf_3" |
14257 | [(set (match_operand:TF 0 "register_operand" "=f,f") | |
14258 | (match_operator:TF 3 "binary_fp_operator" | |
14259 | [(match_operand:TF 1 "register_operand" "0,0") | |
14260 | (float:TF (match_operand:SI 2 "nonimmediate_operand" "m,?r"))]))] | |
14261 | "TARGET_80387 && TARGET_USE_FIOP" | |
14262 | "* return which_alternative ? \"#\" : output_387_binary_op (insn, operands);" | |
14263 | [(set (attr "type") | |
14264 | (cond [(match_operand:TF 3 "mult_operator" "") | |
14265 | (const_string "fmul") | |
14266 | (match_operand:TF 3 "div_operator" "") | |
14267 | (const_string "fdiv") | |
14268 | ] | |
14269 | (const_string "fop"))) | |
14270 | (set_attr "fp_int_src" "true") | |
14271 | (set_attr "mode" "SI") | |
14272 | (set_attr "ppro_uops" "many")]) | |
14273 | ||
e075ae69 RH |
14274 | (define_insn "*fop_xf_4" |
14275 | [(set (match_operand:XF 0 "register_operand" "=f,f") | |
14276 | (match_operator:XF 3 "binary_fp_operator" | |
14277 | [(float_extend:XF (match_operand:SF 1 "nonimmediate_operand" "fm,0")) | |
14278 | (match_operand:XF 2 "register_operand" "0,f")]))] | |
1b0c37d7 | 14279 | "!TARGET_64BIT && TARGET_80387" |
e075ae69 RH |
14280 | "* return output_387_binary_op (insn, operands);" |
14281 | [(set (attr "type") | |
ca285e07 | 14282 | (cond [(match_operand:XF 3 "mult_operator" "") |
e075ae69 | 14283 | (const_string "fmul") |
ca285e07 | 14284 | (match_operand:XF 3 "div_operator" "") |
e075ae69 RH |
14285 | (const_string "fdiv") |
14286 | ] | |
6ef67412 JH |
14287 | (const_string "fop"))) |
14288 | (set_attr "mode" "SF")]) | |
e075ae69 | 14289 | |
2b589241 JH |
14290 | (define_insn "*fop_tf_4" |
14291 | [(set (match_operand:TF 0 "register_operand" "=f,f") | |
14292 | (match_operator:TF 3 "binary_fp_operator" | |
14293 | [(float_extend:TF (match_operand:SF 1 "nonimmediate_operand" "fm,0")) | |
14294 | (match_operand:TF 2 "register_operand" "0,f")]))] | |
14295 | "TARGET_80387" | |
14296 | "* return output_387_binary_op (insn, operands);" | |
14297 | [(set (attr "type") | |
14298 | (cond [(match_operand:TF 3 "mult_operator" "") | |
14299 | (const_string "fmul") | |
14300 | (match_operand:TF 3 "div_operator" "") | |
14301 | (const_string "fdiv") | |
14302 | ] | |
14303 | (const_string "fop"))) | |
14304 | (set_attr "mode" "SF")]) | |
14305 | ||
e075ae69 RH |
14306 | (define_insn "*fop_xf_5" |
14307 | [(set (match_operand:XF 0 "register_operand" "=f,f") | |
14308 | (match_operator:XF 3 "binary_fp_operator" | |
14309 | [(match_operand:XF 1 "register_operand" "0,f") | |
14310 | (float_extend:XF | |
14311 | (match_operand:SF 2 "nonimmediate_operand" "fm,0"))]))] | |
1b0c37d7 | 14312 | "!TARGET_64BIT && TARGET_80387" |
e075ae69 RH |
14313 | "* return output_387_binary_op (insn, operands);" |
14314 | [(set (attr "type") | |
ca285e07 | 14315 | (cond [(match_operand:XF 3 "mult_operator" "") |
e075ae69 | 14316 | (const_string "fmul") |
ca285e07 | 14317 | (match_operand:XF 3 "div_operator" "") |
e075ae69 RH |
14318 | (const_string "fdiv") |
14319 | ] | |
6ef67412 JH |
14320 | (const_string "fop"))) |
14321 | (set_attr "mode" "SF")]) | |
e075ae69 | 14322 | |
2b589241 JH |
14323 | (define_insn "*fop_tf_5" |
14324 | [(set (match_operand:TF 0 "register_operand" "=f,f") | |
14325 | (match_operator:TF 3 "binary_fp_operator" | |
14326 | [(match_operand:TF 1 "register_operand" "0,f") | |
14327 | (float_extend:TF | |
14328 | (match_operand:SF 2 "nonimmediate_operand" "fm,0"))]))] | |
14329 | "TARGET_80387" | |
14330 | "* return output_387_binary_op (insn, operands);" | |
14331 | [(set (attr "type") | |
14332 | (cond [(match_operand:TF 3 "mult_operator" "") | |
14333 | (const_string "fmul") | |
14334 | (match_operand:TF 3 "div_operator" "") | |
14335 | (const_string "fdiv") | |
14336 | ] | |
14337 | (const_string "fop"))) | |
14338 | (set_attr "mode" "SF")]) | |
14339 | ||
e075ae69 RH |
14340 | (define_insn "*fop_xf_6" |
14341 | [(set (match_operand:XF 0 "register_operand" "=f,f") | |
14342 | (match_operator:XF 3 "binary_fp_operator" | |
14343 | [(float_extend:XF (match_operand:DF 1 "nonimmediate_operand" "fm,0")) | |
14344 | (match_operand:XF 2 "register_operand" "0,f")]))] | |
1b0c37d7 | 14345 | "!TARGET_64BIT && TARGET_80387" |
e075ae69 RH |
14346 | "* return output_387_binary_op (insn, operands);" |
14347 | [(set (attr "type") | |
ca285e07 | 14348 | (cond [(match_operand:XF 3 "mult_operator" "") |
e075ae69 | 14349 | (const_string "fmul") |
ca285e07 | 14350 | (match_operand:XF 3 "div_operator" "") |
e075ae69 RH |
14351 | (const_string "fdiv") |
14352 | ] | |
6ef67412 JH |
14353 | (const_string "fop"))) |
14354 | (set_attr "mode" "DF")]) | |
e075ae69 | 14355 | |
2b589241 JH |
14356 | (define_insn "*fop_tf_6" |
14357 | [(set (match_operand:TF 0 "register_operand" "=f,f") | |
14358 | (match_operator:TF 3 "binary_fp_operator" | |
14359 | [(float_extend:TF (match_operand:DF 1 "nonimmediate_operand" "fm,0")) | |
14360 | (match_operand:TF 2 "register_operand" "0,f")]))] | |
14361 | "TARGET_80387" | |
14362 | "* return output_387_binary_op (insn, operands);" | |
14363 | [(set (attr "type") | |
14364 | (cond [(match_operand:TF 3 "mult_operator" "") | |
14365 | (const_string "fmul") | |
14366 | (match_operand:TF 3 "div_operator" "") | |
14367 | (const_string "fdiv") | |
14368 | ] | |
14369 | (const_string "fop"))) | |
14370 | (set_attr "mode" "DF")]) | |
14371 | ||
e075ae69 RH |
14372 | (define_insn "*fop_xf_7" |
14373 | [(set (match_operand:XF 0 "register_operand" "=f,f") | |
14374 | (match_operator:XF 3 "binary_fp_operator" | |
14375 | [(match_operand:XF 1 "register_operand" "0,f") | |
14376 | (float_extend:XF | |
14377 | (match_operand:DF 2 "nonimmediate_operand" "fm,0"))]))] | |
1b0c37d7 | 14378 | "!TARGET_64BIT && TARGET_80387" |
e075ae69 RH |
14379 | "* return output_387_binary_op (insn, operands);" |
14380 | [(set (attr "type") | |
ca285e07 | 14381 | (cond [(match_operand:XF 3 "mult_operator" "") |
e075ae69 | 14382 | (const_string "fmul") |
ca285e07 | 14383 | (match_operand:XF 3 "div_operator" "") |
e075ae69 RH |
14384 | (const_string "fdiv") |
14385 | ] | |
6ef67412 JH |
14386 | (const_string "fop"))) |
14387 | (set_attr "mode" "DF")]) | |
e075ae69 | 14388 | |
2b589241 JH |
14389 | (define_insn "*fop_tf_7" |
14390 | [(set (match_operand:TF 0 "register_operand" "=f,f") | |
14391 | (match_operator:TF 3 "binary_fp_operator" | |
14392 | [(match_operand:TF 1 "register_operand" "0,f") | |
14393 | (float_extend:TF | |
14394 | (match_operand:DF 2 "nonimmediate_operand" "fm,0"))]))] | |
14395 | "TARGET_80387" | |
14396 | "* return output_387_binary_op (insn, operands);" | |
14397 | [(set (attr "type") | |
14398 | (cond [(match_operand:TF 3 "mult_operator" "") | |
14399 | (const_string "fmul") | |
14400 | (match_operand:TF 3 "div_operator" "") | |
14401 | (const_string "fdiv") | |
14402 | ] | |
14403 | (const_string "fop"))) | |
14404 | (set_attr "mode" "DF")]) | |
14405 | ||
e075ae69 RH |
14406 | (define_split |
14407 | [(set (match_operand 0 "register_operand" "") | |
14408 | (match_operator 3 "binary_fp_operator" | |
14409 | [(float (match_operand:SI 1 "register_operand" "")) | |
14410 | (match_operand 2 "register_operand" "")]))] | |
14411 | "TARGET_80387 && reload_completed | |
14412 | && FLOAT_MODE_P (GET_MODE (operands[0]))" | |
4211a8fb | 14413 | [(const_int 0)] |
4211a8fb JH |
14414 | { |
14415 | operands[4] = ix86_force_to_memory (GET_MODE (operands[1]), operands[1]); | |
14416 | operands[4] = gen_rtx_FLOAT (GET_MODE (operands[0]), operands[4]); | |
14417 | emit_insn (gen_rtx_SET (VOIDmode, operands[0], | |
14418 | gen_rtx_fmt_ee (GET_CODE (operands[3]), | |
14419 | GET_MODE (operands[3]), | |
14420 | operands[4], | |
14421 | operands[2]))); | |
14422 | ix86_free_from_memory (GET_MODE (operands[1])); | |
14423 | DONE; | |
0f40f9f7 | 14424 | }) |
e075ae69 RH |
14425 | |
14426 | (define_split | |
14427 | [(set (match_operand 0 "register_operand" "") | |
14428 | (match_operator 3 "binary_fp_operator" | |
14429 | [(match_operand 1 "register_operand" "") | |
14430 | (float (match_operand:SI 2 "register_operand" ""))]))] | |
14431 | "TARGET_80387 && reload_completed | |
14432 | && FLOAT_MODE_P (GET_MODE (operands[0]))" | |
4211a8fb | 14433 | [(const_int 0)] |
4211a8fb JH |
14434 | { |
14435 | operands[4] = ix86_force_to_memory (GET_MODE (operands[2]), operands[2]); | |
14436 | operands[4] = gen_rtx_FLOAT (GET_MODE (operands[0]), operands[4]); | |
14437 | emit_insn (gen_rtx_SET (VOIDmode, operands[0], | |
2b66da3c | 14438 | gen_rtx_fmt_ee (GET_CODE (operands[3]), |
4211a8fb JH |
14439 | GET_MODE (operands[3]), |
14440 | operands[1], | |
14441 | operands[4]))); | |
14442 | ix86_free_from_memory (GET_MODE (operands[2])); | |
14443 | DONE; | |
0f40f9f7 | 14444 | }) |
e075ae69 RH |
14445 | \f |
14446 | ;; FPU special functions. | |
14447 | ||
a8083431 JH |
14448 | (define_expand "sqrtsf2" |
14449 | [(set (match_operand:SF 0 "register_operand" "") | |
14450 | (sqrt:SF (match_operand:SF 1 "nonimmediate_operand" "")))] | |
abf80f8f | 14451 | "(! TARGET_NO_FANCY_MATH_387 && TARGET_80387) || TARGET_SSE_MATH" |
a8083431 | 14452 | { |
abf80f8f | 14453 | if (!TARGET_SSE_MATH) |
a8083431 | 14454 | operands[1] = force_reg (SFmode, operands[1]); |
0f40f9f7 | 14455 | }) |
a8083431 JH |
14456 | |
14457 | (define_insn "sqrtsf2_1" | |
ca9a9b12 JH |
14458 | [(set (match_operand:SF 0 "register_operand" "=f#x,x#f") |
14459 | (sqrt:SF (match_operand:SF 1 "nonimmediate_operand" "0#x,xm#f")))] | |
a8083431 | 14460 | "! TARGET_NO_FANCY_MATH_387 && TARGET_80387 |
abf80f8f | 14461 | && (TARGET_SSE_MATH && TARGET_MIX_SSE_I387)" |
a8083431 JH |
14462 | "@ |
14463 | fsqrt | |
0f40f9f7 | 14464 | sqrtss\t{%1, %0|%0, %1}" |
a8083431 JH |
14465 | [(set_attr "type" "fpspc,sse") |
14466 | (set_attr "mode" "SF,SF") | |
14467 | (set_attr "athlon_decode" "direct,*")]) | |
14468 | ||
14469 | (define_insn "sqrtsf2_1_sse_only" | |
ca9a9b12 JH |
14470 | [(set (match_operand:SF 0 "register_operand" "=x") |
14471 | (sqrt:SF (match_operand:SF 1 "nonimmediate_operand" "xm")))] | |
abf80f8f | 14472 | "TARGET_SSE_MATH && (!TARGET_80387 || !TARGET_MIX_SSE_I387)" |
0f40f9f7 | 14473 | "sqrtss\t{%1, %0|%0, %1}" |
a8083431 JH |
14474 | [(set_attr "type" "sse") |
14475 | (set_attr "mode" "SF") | |
14476 | (set_attr "athlon_decode" "*")]) | |
14477 | ||
14478 | (define_insn "sqrtsf2_i387" | |
e075ae69 RH |
14479 | [(set (match_operand:SF 0 "register_operand" "=f") |
14480 | (sqrt:SF (match_operand:SF 1 "register_operand" "0")))] | |
a8083431 | 14481 | "! TARGET_NO_FANCY_MATH_387 && TARGET_80387 |
abf80f8f | 14482 | && !TARGET_SSE_MATH" |
e075ae69 | 14483 | "fsqrt" |
0b5107cf | 14484 | [(set_attr "type" "fpspc") |
6ef67412 | 14485 | (set_attr "mode" "SF") |
0b5107cf | 14486 | (set_attr "athlon_decode" "direct")]) |
e075ae69 | 14487 | |
a8083431 JH |
14488 | (define_expand "sqrtdf2" |
14489 | [(set (match_operand:DF 0 "register_operand" "") | |
14490 | (sqrt:DF (match_operand:DF 1 "nonimmediate_operand" "")))] | |
965f5423 JH |
14491 | "(! TARGET_NO_FANCY_MATH_387 && TARGET_80387) |
14492 | || (TARGET_SSE2 && TARGET_SSE_MATH)" | |
a8083431 | 14493 | { |
965f5423 | 14494 | if (!TARGET_SSE2 || !TARGET_SSE_MATH) |
2406cfed | 14495 | operands[1] = force_reg (DFmode, operands[1]); |
0f40f9f7 | 14496 | }) |
a8083431 JH |
14497 | |
14498 | (define_insn "sqrtdf2_1" | |
14499 | [(set (match_operand:DF 0 "register_operand" "=f#Y,Y#f") | |
14500 | (sqrt:DF (match_operand:DF 1 "nonimmediate_operand" "0#Y,Ym#f")))] | |
14501 | "! TARGET_NO_FANCY_MATH_387 && TARGET_80387 | |
965f5423 | 14502 | && (TARGET_SSE2 && TARGET_SSE_MATH && TARGET_MIX_SSE_I387)" |
a8083431 JH |
14503 | "@ |
14504 | fsqrt | |
0f40f9f7 | 14505 | sqrtsd\t{%1, %0|%0, %1}" |
a8083431 JH |
14506 | [(set_attr "type" "fpspc,sse") |
14507 | (set_attr "mode" "DF,DF") | |
14508 | (set_attr "athlon_decode" "direct,*")]) | |
14509 | ||
14510 | (define_insn "sqrtdf2_1_sse_only" | |
14511 | [(set (match_operand:DF 0 "register_operand" "=Y") | |
14512 | (sqrt:DF (match_operand:DF 1 "nonimmediate_operand" "Ym")))] | |
965f5423 | 14513 | "TARGET_SSE2 && TARGET_SSE_MATH && (!TARGET_80387 || !TARGET_MIX_SSE_I387)" |
0f40f9f7 | 14514 | "sqrtsd\t{%1, %0|%0, %1}" |
a8083431 JH |
14515 | [(set_attr "type" "sse") |
14516 | (set_attr "mode" "DF") | |
14517 | (set_attr "athlon_decode" "*")]) | |
14518 | ||
14519 | (define_insn "sqrtdf2_i387" | |
e075ae69 RH |
14520 | [(set (match_operand:DF 0 "register_operand" "=f") |
14521 | (sqrt:DF (match_operand:DF 1 "register_operand" "0")))] | |
14522 | "! TARGET_NO_FANCY_MATH_387 && TARGET_80387 | |
abf80f8f | 14523 | && (!TARGET_SSE2 || !TARGET_SSE_MATH)" |
e075ae69 | 14524 | "fsqrt" |
0b5107cf | 14525 | [(set_attr "type" "fpspc") |
6ef67412 | 14526 | (set_attr "mode" "DF") |
0b5107cf | 14527 | (set_attr "athlon_decode" "direct")]) |
e075ae69 | 14528 | |
6343a50e | 14529 | (define_insn "*sqrtextendsfdf2" |
e075ae69 RH |
14530 | [(set (match_operand:DF 0 "register_operand" "=f") |
14531 | (sqrt:DF (float_extend:DF | |
14532 | (match_operand:SF 1 "register_operand" "0"))))] | |
965f5423 JH |
14533 | "! TARGET_NO_FANCY_MATH_387 && TARGET_80387 |
14534 | && !(TARGET_SSE2 && TARGET_SSE_MATH)" | |
e075ae69 | 14535 | "fsqrt" |
0b5107cf | 14536 | [(set_attr "type" "fpspc") |
6ef67412 | 14537 | (set_attr "mode" "DF") |
0b5107cf | 14538 | (set_attr "athlon_decode" "direct")]) |
e075ae69 RH |
14539 | |
14540 | (define_insn "sqrtxf2" | |
14541 | [(set (match_operand:XF 0 "register_operand" "=f") | |
14542 | (sqrt:XF (match_operand:XF 1 "register_operand" "0")))] | |
1b0c37d7 | 14543 | "!TARGET_64BIT && TARGET_80387 && !TARGET_NO_FANCY_MATH_387 |
de6c5979 | 14544 | && (TARGET_IEEE_FP || flag_unsafe_math_optimizations) " |
e075ae69 | 14545 | "fsqrt" |
0b5107cf | 14546 | [(set_attr "type" "fpspc") |
6ef67412 | 14547 | (set_attr "mode" "XF") |
0b5107cf | 14548 | (set_attr "athlon_decode" "direct")]) |
e075ae69 | 14549 | |
2b589241 JH |
14550 | (define_insn "sqrttf2" |
14551 | [(set (match_operand:TF 0 "register_operand" "=f") | |
14552 | (sqrt:TF (match_operand:TF 1 "register_operand" "0")))] | |
14553 | "! TARGET_NO_FANCY_MATH_387 && TARGET_80387 | |
de6c5979 | 14554 | && (TARGET_IEEE_FP || flag_unsafe_math_optimizations) " |
2b589241 JH |
14555 | "fsqrt" |
14556 | [(set_attr "type" "fpspc") | |
14557 | (set_attr "mode" "XF") | |
14558 | (set_attr "athlon_decode" "direct")]) | |
14559 | ||
6343a50e | 14560 | (define_insn "*sqrtextenddfxf2" |
e075ae69 RH |
14561 | [(set (match_operand:XF 0 "register_operand" "=f") |
14562 | (sqrt:XF (float_extend:XF | |
14563 | (match_operand:DF 1 "register_operand" "0"))))] | |
1b0c37d7 | 14564 | "!TARGET_64BIT && TARGET_80387 && TARGET_NO_FANCY_MATH_387" |
e075ae69 | 14565 | "fsqrt" |
0b5107cf | 14566 | [(set_attr "type" "fpspc") |
6ef67412 | 14567 | (set_attr "mode" "XF") |
0b5107cf | 14568 | (set_attr "athlon_decode" "direct")]) |
e075ae69 | 14569 | |
2b589241 JH |
14570 | (define_insn "*sqrtextenddftf2" |
14571 | [(set (match_operand:TF 0 "register_operand" "=f") | |
14572 | (sqrt:TF (float_extend:TF | |
14573 | (match_operand:DF 1 "register_operand" "0"))))] | |
14574 | "! TARGET_NO_FANCY_MATH_387 && TARGET_80387" | |
14575 | "fsqrt" | |
14576 | [(set_attr "type" "fpspc") | |
14577 | (set_attr "mode" "XF") | |
14578 | (set_attr "athlon_decode" "direct")]) | |
14579 | ||
6343a50e | 14580 | (define_insn "*sqrtextendsfxf2" |
e075ae69 RH |
14581 | [(set (match_operand:XF 0 "register_operand" "=f") |
14582 | (sqrt:XF (float_extend:XF | |
14583 | (match_operand:SF 1 "register_operand" "0"))))] | |
1b0c37d7 | 14584 | "!TARGET_64BIT && TARGET_80387 && TARGET_NO_FANCY_MATH_387" |
e075ae69 | 14585 | "fsqrt" |
0b5107cf | 14586 | [(set_attr "type" "fpspc") |
6ef67412 | 14587 | (set_attr "mode" "XF") |
0b5107cf | 14588 | (set_attr "athlon_decode" "direct")]) |
e075ae69 | 14589 | |
2b589241 JH |
14590 | (define_insn "*sqrtextendsftf2" |
14591 | [(set (match_operand:TF 0 "register_operand" "=f") | |
14592 | (sqrt:TF (float_extend:TF | |
14593 | (match_operand:SF 1 "register_operand" "0"))))] | |
14594 | "! TARGET_NO_FANCY_MATH_387 && TARGET_80387" | |
14595 | "fsqrt" | |
14596 | [(set_attr "type" "fpspc") | |
14597 | (set_attr "mode" "XF") | |
14598 | (set_attr "athlon_decode" "direct")]) | |
14599 | ||
e075ae69 RH |
14600 | (define_insn "sindf2" |
14601 | [(set (match_operand:DF 0 "register_operand" "=f") | |
14602 | (unspec:DF [(match_operand:DF 1 "register_operand" "0")] 1))] | |
de6c5979 BL |
14603 | "! TARGET_NO_FANCY_MATH_387 && TARGET_80387 |
14604 | && flag_unsafe_math_optimizations" | |
e075ae69 | 14605 | "fsin" |
6ef67412 JH |
14606 | [(set_attr "type" "fpspc") |
14607 | (set_attr "mode" "DF")]) | |
e075ae69 RH |
14608 | |
14609 | (define_insn "sinsf2" | |
14610 | [(set (match_operand:SF 0 "register_operand" "=f") | |
14611 | (unspec:SF [(match_operand:SF 1 "register_operand" "0")] 1))] | |
de6c5979 BL |
14612 | "! TARGET_NO_FANCY_MATH_387 && TARGET_80387 |
14613 | && flag_unsafe_math_optimizations" | |
e075ae69 | 14614 | "fsin" |
6ef67412 JH |
14615 | [(set_attr "type" "fpspc") |
14616 | (set_attr "mode" "SF")]) | |
5f3d14e3 | 14617 | |
6343a50e | 14618 | (define_insn "*sinextendsfdf2" |
e075ae69 RH |
14619 | [(set (match_operand:DF 0 "register_operand" "=f") |
14620 | (unspec:DF [(float_extend:DF | |
14621 | (match_operand:SF 1 "register_operand" "0"))] 1))] | |
de6c5979 BL |
14622 | "! TARGET_NO_FANCY_MATH_387 && TARGET_80387 |
14623 | && flag_unsafe_math_optimizations" | |
e075ae69 | 14624 | "fsin" |
6ef67412 JH |
14625 | [(set_attr "type" "fpspc") |
14626 | (set_attr "mode" "DF")]) | |
4f9ca067 | 14627 | |
e075ae69 RH |
14628 | (define_insn "sinxf2" |
14629 | [(set (match_operand:XF 0 "register_operand" "=f") | |
14630 | (unspec:XF [(match_operand:XF 1 "register_operand" "0")] 1))] | |
1b0c37d7 | 14631 | "!TARGET_64BIT && TARGET_80387 && TARGET_NO_FANCY_MATH_387 |
de6c5979 | 14632 | && flag_unsafe_math_optimizations" |
e075ae69 | 14633 | "fsin" |
6ef67412 JH |
14634 | [(set_attr "type" "fpspc") |
14635 | (set_attr "mode" "XF")]) | |
5f3d14e3 | 14636 | |
2b589241 JH |
14637 | (define_insn "sintf2" |
14638 | [(set (match_operand:TF 0 "register_operand" "=f") | |
14639 | (unspec:TF [(match_operand:TF 1 "register_operand" "0")] 1))] | |
de6c5979 BL |
14640 | "! TARGET_NO_FANCY_MATH_387 && TARGET_80387 |
14641 | && flag_unsafe_math_optimizations" | |
2b589241 JH |
14642 | "fsin" |
14643 | [(set_attr "type" "fpspc") | |
14644 | (set_attr "mode" "XF")]) | |
14645 | ||
e075ae69 RH |
14646 | (define_insn "cosdf2" |
14647 | [(set (match_operand:DF 0 "register_operand" "=f") | |
14648 | (unspec:DF [(match_operand:DF 1 "register_operand" "0")] 2))] | |
de6c5979 BL |
14649 | "! TARGET_NO_FANCY_MATH_387 && TARGET_80387 |
14650 | && flag_unsafe_math_optimizations" | |
e075ae69 | 14651 | "fcos" |
6ef67412 JH |
14652 | [(set_attr "type" "fpspc") |
14653 | (set_attr "mode" "DF")]) | |
bca7cce2 | 14654 | |
e075ae69 RH |
14655 | (define_insn "cossf2" |
14656 | [(set (match_operand:SF 0 "register_operand" "=f") | |
14657 | (unspec:SF [(match_operand:SF 1 "register_operand" "0")] 2))] | |
de6c5979 BL |
14658 | "! TARGET_NO_FANCY_MATH_387 && TARGET_80387 |
14659 | && flag_unsafe_math_optimizations" | |
e075ae69 | 14660 | "fcos" |
6ef67412 JH |
14661 | [(set_attr "type" "fpspc") |
14662 | (set_attr "mode" "SF")]) | |
bca7cce2 | 14663 | |
6343a50e | 14664 | (define_insn "*cosextendsfdf2" |
e075ae69 RH |
14665 | [(set (match_operand:DF 0 "register_operand" "=f") |
14666 | (unspec:DF [(float_extend:DF | |
14667 | (match_operand:SF 1 "register_operand" "0"))] 2))] | |
de6c5979 BL |
14668 | "! TARGET_NO_FANCY_MATH_387 && TARGET_80387 |
14669 | && flag_unsafe_math_optimizations" | |
e075ae69 | 14670 | "fcos" |
6ef67412 JH |
14671 | [(set_attr "type" "fpspc") |
14672 | (set_attr "mode" "DF")]) | |
5f3d14e3 | 14673 | |
e075ae69 RH |
14674 | (define_insn "cosxf2" |
14675 | [(set (match_operand:XF 0 "register_operand" "=f") | |
14676 | (unspec:XF [(match_operand:XF 1 "register_operand" "0")] 2))] | |
1e07edd3 | 14677 | "! TARGET_NO_FANCY_MATH_387 && TARGET_80387 |
de6c5979 | 14678 | && flag_unsafe_math_optimizations" |
e075ae69 | 14679 | "fcos" |
6ef67412 JH |
14680 | [(set_attr "type" "fpspc") |
14681 | (set_attr "mode" "XF")]) | |
2b589241 JH |
14682 | |
14683 | (define_insn "costf2" | |
14684 | [(set (match_operand:TF 0 "register_operand" "=f") | |
14685 | (unspec:TF [(match_operand:TF 1 "register_operand" "0")] 2))] | |
de6c5979 BL |
14686 | "! TARGET_NO_FANCY_MATH_387 && TARGET_80387 |
14687 | && flag_unsafe_math_optimizations" | |
2b589241 JH |
14688 | "fcos" |
14689 | [(set_attr "type" "fpspc") | |
14690 | (set_attr "mode" "XF")]) | |
e075ae69 RH |
14691 | \f |
14692 | ;; Block operation instructions | |
886c62d1 | 14693 | |
7c7ef435 JH |
14694 | (define_insn "cld" |
14695 | [(set (reg:SI 19) (const_int 0))] | |
14696 | "" | |
14697 | "cld" | |
14698 | [(set_attr "type" "cld")]) | |
14699 | ||
886c62d1 | 14700 | (define_expand "movstrsi" |
f90800f8 JH |
14701 | [(use (match_operand:BLK 0 "memory_operand" "")) |
14702 | (use (match_operand:BLK 1 "memory_operand" "")) | |
79f05c19 | 14703 | (use (match_operand:SI 2 "nonmemory_operand" "")) |
f90800f8 | 14704 | (use (match_operand:SI 3 "const_int_operand" ""))] |
886c62d1 | 14705 | "" |
886c62d1 | 14706 | { |
0945b39d JH |
14707 | if (ix86_expand_movstr (operands[0], operands[1], operands[2], operands[3])) |
14708 | DONE; | |
14709 | else | |
14710 | FAIL; | |
0f40f9f7 | 14711 | }) |
79f05c19 | 14712 | |
0945b39d JH |
14713 | (define_expand "movstrdi" |
14714 | [(use (match_operand:BLK 0 "memory_operand" "")) | |
14715 | (use (match_operand:BLK 1 "memory_operand" "")) | |
14716 | (use (match_operand:DI 2 "nonmemory_operand" "")) | |
14717 | (use (match_operand:DI 3 "const_int_operand" ""))] | |
14718 | "TARGET_64BIT" | |
0945b39d JH |
14719 | { |
14720 | if (ix86_expand_movstr (operands[0], operands[1], operands[2], operands[3])) | |
14721 | DONE; | |
14722 | else | |
14723 | FAIL; | |
0f40f9f7 | 14724 | }) |
79f05c19 | 14725 | |
0945b39d JH |
14726 | ;; Most CPUs don't like single string operations |
14727 | ;; Handle this case here to simplify previous expander. | |
79f05c19 | 14728 | |
0945b39d JH |
14729 | (define_expand "strmovdi_rex64" |
14730 | [(set (match_dup 2) | |
14731 | (mem:DI (match_operand:DI 1 "register_operand" ""))) | |
14732 | (set (mem:DI (match_operand:DI 0 "register_operand" "")) | |
14733 | (match_dup 2)) | |
14734 | (parallel [(set (match_dup 0) (plus:DI (match_dup 0) (const_int 8))) | |
14735 | (clobber (reg:CC 17))]) | |
14736 | (parallel [(set (match_dup 1) (plus:DI (match_dup 1) (const_int 8))) | |
14737 | (clobber (reg:CC 17))])] | |
14738 | "TARGET_64BIT" | |
0945b39d JH |
14739 | { |
14740 | if (TARGET_SINGLE_STRINGOP || optimize_size) | |
79f05c19 | 14741 | { |
0945b39d JH |
14742 | emit_insn (gen_strmovdi_rex_1 (operands[0], operands[1], operands[0], |
14743 | operands[1])); | |
14744 | DONE; | |
79f05c19 | 14745 | } |
0945b39d JH |
14746 | else |
14747 | operands[2] = gen_reg_rtx (DImode); | |
0f40f9f7 | 14748 | }) |
886c62d1 | 14749 | |
56c0e8fa | 14750 | |
79f05c19 JH |
14751 | (define_expand "strmovsi" |
14752 | [(set (match_dup 2) | |
14753 | (mem:SI (match_operand:SI 1 "register_operand" ""))) | |
14754 | (set (mem:SI (match_operand:SI 0 "register_operand" "")) | |
14755 | (match_dup 2)) | |
14756 | (parallel [(set (match_dup 0) (plus:SI (match_dup 0) (const_int 4))) | |
14757 | (clobber (reg:CC 17))]) | |
14758 | (parallel [(set (match_dup 1) (plus:SI (match_dup 1) (const_int 4))) | |
14759 | (clobber (reg:CC 17))])] | |
14760 | "" | |
79f05c19 | 14761 | { |
0945b39d JH |
14762 | if (TARGET_64BIT) |
14763 | { | |
14764 | emit_insn (gen_strmovsi_rex64 (operands[0], operands[1])); | |
14765 | DONE; | |
14766 | } | |
79f05c19 JH |
14767 | if (TARGET_SINGLE_STRINGOP || optimize_size) |
14768 | { | |
14769 | emit_insn (gen_strmovsi_1 (operands[0], operands[1], operands[0], | |
14770 | operands[1])); | |
14771 | DONE; | |
14772 | } | |
14773 | else | |
14774 | operands[2] = gen_reg_rtx (SImode); | |
0f40f9f7 | 14775 | }) |
79f05c19 | 14776 | |
0945b39d JH |
14777 | (define_expand "strmovsi_rex64" |
14778 | [(set (match_dup 2) | |
14779 | (mem:SI (match_operand:DI 1 "register_operand" ""))) | |
14780 | (set (mem:SI (match_operand:DI 0 "register_operand" "")) | |
14781 | (match_dup 2)) | |
14782 | (parallel [(set (match_dup 0) (plus:DI (match_dup 0) (const_int 4))) | |
14783 | (clobber (reg:CC 17))]) | |
14784 | (parallel [(set (match_dup 1) (plus:DI (match_dup 1) (const_int 4))) | |
14785 | (clobber (reg:CC 17))])] | |
14786 | "TARGET_64BIT" | |
0945b39d JH |
14787 | { |
14788 | if (TARGET_SINGLE_STRINGOP || optimize_size) | |
14789 | { | |
14790 | emit_insn (gen_strmovsi_rex_1 (operands[0], operands[1], operands[0], | |
14791 | operands[1])); | |
14792 | DONE; | |
14793 | } | |
14794 | else | |
14795 | operands[2] = gen_reg_rtx (SImode); | |
0f40f9f7 | 14796 | }) |
0945b39d | 14797 | |
f90800f8 JH |
14798 | (define_expand "strmovhi" |
14799 | [(set (match_dup 2) | |
14800 | (mem:HI (match_operand:SI 1 "register_operand" ""))) | |
14801 | (set (mem:HI (match_operand:SI 0 "register_operand" "")) | |
14802 | (match_dup 2)) | |
14803 | (parallel [(set (match_dup 0) (plus:SI (match_dup 0) (const_int 2))) | |
14804 | (clobber (reg:CC 17))]) | |
14805 | (parallel [(set (match_dup 1) (plus:SI (match_dup 1) (const_int 2))) | |
14806 | (clobber (reg:CC 17))])] | |
886c62d1 | 14807 | "" |
886c62d1 | 14808 | { |
0945b39d JH |
14809 | if (TARGET_64BIT) |
14810 | { | |
14811 | emit_insn (gen_strmovhi_rex64 (operands[0], operands[1])); | |
14812 | DONE; | |
14813 | } | |
f90800f8 | 14814 | if (TARGET_SINGLE_STRINGOP || optimize_size) |
886c62d1 | 14815 | { |
f90800f8 JH |
14816 | emit_insn (gen_strmovhi_1 (operands[0], operands[1], operands[0], |
14817 | operands[1])); | |
14818 | DONE; | |
14819 | } | |
14820 | else | |
14821 | operands[2] = gen_reg_rtx (HImode); | |
0f40f9f7 | 14822 | }) |
886c62d1 | 14823 | |
0945b39d JH |
14824 | (define_expand "strmovhi_rex64" |
14825 | [(set (match_dup 2) | |
14826 | (mem:HI (match_operand:DI 1 "register_operand" ""))) | |
14827 | (set (mem:HI (match_operand:DI 0 "register_operand" "")) | |
14828 | (match_dup 2)) | |
14829 | (parallel [(set (match_dup 0) (plus:DI (match_dup 0) (const_int 2))) | |
14830 | (clobber (reg:CC 17))]) | |
14831 | (parallel [(set (match_dup 1) (plus:DI (match_dup 1) (const_int 2))) | |
14832 | (clobber (reg:CC 17))])] | |
14833 | "TARGET_64BIT" | |
0945b39d JH |
14834 | { |
14835 | if (TARGET_SINGLE_STRINGOP || optimize_size) | |
14836 | { | |
14837 | emit_insn (gen_strmovhi_rex_1 (operands[0], operands[1], operands[0], | |
14838 | operands[1])); | |
14839 | DONE; | |
14840 | } | |
14841 | else | |
14842 | operands[2] = gen_reg_rtx (HImode); | |
0f40f9f7 | 14843 | }) |
0945b39d | 14844 | |
f90800f8 JH |
14845 | (define_expand "strmovqi" |
14846 | [(set (match_dup 2) | |
14847 | (mem:QI (match_operand:SI 1 "register_operand" ""))) | |
14848 | (set (mem:QI (match_operand:SI 0 "register_operand" "")) | |
14849 | (match_dup 2)) | |
14850 | (parallel [(set (match_dup 0) (plus:SI (match_dup 0) (const_int 1))) | |
14851 | (clobber (reg:CC 17))]) | |
14852 | (parallel [(set (match_dup 1) (plus:SI (match_dup 1) (const_int 1))) | |
14853 | (clobber (reg:CC 17))])] | |
14854 | "" | |
f90800f8 | 14855 | { |
0945b39d JH |
14856 | if (TARGET_64BIT) |
14857 | { | |
14858 | emit_insn (gen_strmovqi_rex64 (operands[0], operands[1])); | |
14859 | DONE; | |
14860 | } | |
f90800f8 JH |
14861 | if (TARGET_SINGLE_STRINGOP || optimize_size) |
14862 | { | |
14863 | emit_insn (gen_strmovqi_1 (operands[0], operands[1], operands[0], | |
14864 | operands[1])); | |
14865 | DONE; | |
886c62d1 | 14866 | } |
f90800f8 JH |
14867 | else |
14868 | operands[2] = gen_reg_rtx (QImode); | |
0f40f9f7 | 14869 | }) |
f90800f8 | 14870 | |
0945b39d JH |
14871 | (define_expand "strmovqi_rex64" |
14872 | [(set (match_dup 2) | |
14873 | (mem:QI (match_operand:DI 1 "register_operand" ""))) | |
14874 | (set (mem:QI (match_operand:DI 0 "register_operand" "")) | |
14875 | (match_dup 2)) | |
14876 | (parallel [(set (match_dup 0) (plus:DI (match_dup 0) (const_int 1))) | |
14877 | (clobber (reg:CC 17))]) | |
14878 | (parallel [(set (match_dup 1) (plus:DI (match_dup 1) (const_int 1))) | |
14879 | (clobber (reg:CC 17))])] | |
1b0c37d7 | 14880 | "TARGET_64BIT" |
0945b39d JH |
14881 | { |
14882 | if (TARGET_SINGLE_STRINGOP || optimize_size) | |
14883 | { | |
14884 | emit_insn (gen_strmovqi_rex_1 (operands[0], operands[1], operands[0], | |
14885 | operands[1])); | |
14886 | DONE; | |
14887 | } | |
14888 | else | |
14889 | operands[2] = gen_reg_rtx (QImode); | |
0f40f9f7 | 14890 | }) |
0945b39d JH |
14891 | |
14892 | (define_insn "strmovdi_rex_1" | |
14893 | [(set (mem:DI (match_operand:DI 2 "register_operand" "0")) | |
14894 | (mem:DI (match_operand:DI 3 "register_operand" "1"))) | |
14895 | (set (match_operand:DI 0 "register_operand" "=D") | |
14896 | (plus:DI (match_dup 2) | |
14897 | (const_int 8))) | |
14898 | (set (match_operand:DI 1 "register_operand" "=S") | |
14899 | (plus:DI (match_dup 3) | |
14900 | (const_int 8))) | |
14901 | (use (reg:SI 19))] | |
14902 | "TARGET_64BIT && (TARGET_SINGLE_STRINGOP || optimize_size)" | |
14903 | "movsq" | |
14904 | [(set_attr "type" "str") | |
14905 | (set_attr "mode" "DI") | |
14906 | (set_attr "memory" "both")]) | |
14907 | ||
79f05c19 JH |
14908 | (define_insn "strmovsi_1" |
14909 | [(set (mem:SI (match_operand:SI 2 "register_operand" "0")) | |
14910 | (mem:SI (match_operand:SI 3 "register_operand" "1"))) | |
14911 | (set (match_operand:SI 0 "register_operand" "=D") | |
b1cdafbb | 14912 | (plus:SI (match_dup 2) |
79f05c19 JH |
14913 | (const_int 4))) |
14914 | (set (match_operand:SI 1 "register_operand" "=S") | |
b1cdafbb | 14915 | (plus:SI (match_dup 3) |
79f05c19 JH |
14916 | (const_int 4))) |
14917 | (use (reg:SI 19))] | |
0945b39d | 14918 | "!TARGET_64BIT && (TARGET_SINGLE_STRINGOP || optimize_size)" |
371bc54b | 14919 | "{movsl|movsd}" |
0945b39d JH |
14920 | [(set_attr "type" "str") |
14921 | (set_attr "mode" "SI") | |
14922 | (set_attr "memory" "both")]) | |
14923 | ||
14924 | (define_insn "strmovsi_rex_1" | |
14925 | [(set (mem:SI (match_operand:DI 2 "register_operand" "0")) | |
14926 | (mem:SI (match_operand:DI 3 "register_operand" "1"))) | |
14927 | (set (match_operand:DI 0 "register_operand" "=D") | |
14928 | (plus:DI (match_dup 2) | |
14929 | (const_int 4))) | |
14930 | (set (match_operand:DI 1 "register_operand" "=S") | |
14931 | (plus:DI (match_dup 3) | |
14932 | (const_int 4))) | |
14933 | (use (reg:SI 19))] | |
14934 | "TARGET_64BIT && (TARGET_SINGLE_STRINGOP || optimize_size)" | |
371bc54b | 14935 | "{movsl|movsd}" |
79f05c19 | 14936 | [(set_attr "type" "str") |
6ef67412 | 14937 | (set_attr "mode" "SI") |
79f05c19 JH |
14938 | (set_attr "memory" "both")]) |
14939 | ||
f90800f8 JH |
14940 | (define_insn "strmovhi_1" |
14941 | [(set (mem:HI (match_operand:SI 2 "register_operand" "0")) | |
14942 | (mem:HI (match_operand:SI 3 "register_operand" "1"))) | |
14943 | (set (match_operand:SI 0 "register_operand" "=D") | |
b1cdafbb | 14944 | (plus:SI (match_dup 2) |
f90800f8 JH |
14945 | (const_int 2))) |
14946 | (set (match_operand:SI 1 "register_operand" "=S") | |
b1cdafbb | 14947 | (plus:SI (match_dup 3) |
f90800f8 JH |
14948 | (const_int 2))) |
14949 | (use (reg:SI 19))] | |
0945b39d JH |
14950 | "!TARGET_64BIT && (TARGET_SINGLE_STRINGOP || optimize_size)" |
14951 | "movsw" | |
14952 | [(set_attr "type" "str") | |
14953 | (set_attr "memory" "both") | |
14954 | (set_attr "mode" "HI")]) | |
14955 | ||
14956 | (define_insn "strmovhi_rex_1" | |
14957 | [(set (mem:HI (match_operand:DI 2 "register_operand" "0")) | |
14958 | (mem:HI (match_operand:DI 3 "register_operand" "1"))) | |
14959 | (set (match_operand:DI 0 "register_operand" "=D") | |
14960 | (plus:DI (match_dup 2) | |
14961 | (const_int 2))) | |
14962 | (set (match_operand:DI 1 "register_operand" "=S") | |
14963 | (plus:DI (match_dup 3) | |
14964 | (const_int 2))) | |
14965 | (use (reg:SI 19))] | |
14966 | "TARGET_64BIT && (TARGET_SINGLE_STRINGOP || optimize_size)" | |
f90800f8 JH |
14967 | "movsw" |
14968 | [(set_attr "type" "str") | |
14969 | (set_attr "memory" "both") | |
6ef67412 | 14970 | (set_attr "mode" "HI")]) |
f90800f8 JH |
14971 | |
14972 | (define_insn "strmovqi_1" | |
14973 | [(set (mem:QI (match_operand:SI 2 "register_operand" "0")) | |
14974 | (mem:QI (match_operand:SI 3 "register_operand" "1"))) | |
14975 | (set (match_operand:SI 0 "register_operand" "=D") | |
b1cdafbb | 14976 | (plus:SI (match_dup 2) |
f90800f8 JH |
14977 | (const_int 1))) |
14978 | (set (match_operand:SI 1 "register_operand" "=S") | |
b1cdafbb | 14979 | (plus:SI (match_dup 3) |
f90800f8 JH |
14980 | (const_int 1))) |
14981 | (use (reg:SI 19))] | |
0945b39d | 14982 | "!TARGET_64BIT && (TARGET_SINGLE_STRINGOP || optimize_size)" |
f90800f8 JH |
14983 | "movsb" |
14984 | [(set_attr "type" "str") | |
6ef67412 JH |
14985 | (set_attr "memory" "both") |
14986 | (set_attr "mode" "QI")]) | |
f90800f8 | 14987 | |
0945b39d JH |
14988 | (define_insn "strmovqi_rex_1" |
14989 | [(set (mem:QI (match_operand:DI 2 "register_operand" "0")) | |
14990 | (mem:QI (match_operand:DI 3 "register_operand" "1"))) | |
14991 | (set (match_operand:DI 0 "register_operand" "=D") | |
14992 | (plus:DI (match_dup 2) | |
14993 | (const_int 1))) | |
14994 | (set (match_operand:DI 1 "register_operand" "=S") | |
14995 | (plus:DI (match_dup 3) | |
14996 | (const_int 1))) | |
14997 | (use (reg:SI 19))] | |
14998 | "TARGET_64BIT && (TARGET_SINGLE_STRINGOP || optimize_size)" | |
14999 | "movsb" | |
15000 | [(set_attr "type" "str") | |
15001 | (set_attr "memory" "both") | |
15002 | (set_attr "mode" "QI")]) | |
15003 | ||
15004 | (define_insn "rep_movdi_rex64" | |
15005 | [(set (match_operand:DI 2 "register_operand" "=c") (const_int 0)) | |
15006 | (set (match_operand:DI 0 "register_operand" "=D") | |
15007 | (plus:DI (ashift:DI (match_operand:DI 5 "register_operand" "2") | |
15008 | (const_int 3)) | |
15009 | (match_operand:DI 3 "register_operand" "0"))) | |
15010 | (set (match_operand:DI 1 "register_operand" "=S") | |
15011 | (plus:DI (ashift:DI (match_dup 5) (const_int 3)) | |
15012 | (match_operand:DI 4 "register_operand" "1"))) | |
15013 | (set (mem:BLK (match_dup 3)) | |
15014 | (mem:BLK (match_dup 4))) | |
15015 | (use (match_dup 5)) | |
15016 | (use (reg:SI 19))] | |
15017 | "TARGET_64BIT" | |
8554d9a4 | 15018 | "{rep\;movsq|rep movsq}" |
0945b39d JH |
15019 | [(set_attr "type" "str") |
15020 | (set_attr "prefix_rep" "1") | |
15021 | (set_attr "memory" "both") | |
15022 | (set_attr "mode" "DI")]) | |
15023 | ||
f90800f8 JH |
15024 | (define_insn "rep_movsi" |
15025 | [(set (match_operand:SI 2 "register_operand" "=c") (const_int 0)) | |
f90800f8 | 15026 | (set (match_operand:SI 0 "register_operand" "=D") |
b1cdafbb JH |
15027 | (plus:SI (ashift:SI (match_operand:SI 5 "register_operand" "2") |
15028 | (const_int 2)) | |
15029 | (match_operand:SI 3 "register_operand" "0"))) | |
f90800f8 | 15030 | (set (match_operand:SI 1 "register_operand" "=S") |
b1cdafbb JH |
15031 | (plus:SI (ashift:SI (match_dup 5) (const_int 2)) |
15032 | (match_operand:SI 4 "register_operand" "1"))) | |
f90800f8 JH |
15033 | (set (mem:BLK (match_dup 3)) |
15034 | (mem:BLK (match_dup 4))) | |
b1cdafbb | 15035 | (use (match_dup 5)) |
f90800f8 | 15036 | (use (reg:SI 19))] |
0945b39d | 15037 | "!TARGET_64BIT" |
8554d9a4 | 15038 | "{rep\;movsl|rep movsd}" |
0945b39d JH |
15039 | [(set_attr "type" "str") |
15040 | (set_attr "prefix_rep" "1") | |
15041 | (set_attr "memory" "both") | |
15042 | (set_attr "mode" "SI")]) | |
15043 | ||
15044 | (define_insn "rep_movsi_rex64" | |
15045 | [(set (match_operand:DI 2 "register_operand" "=c") (const_int 0)) | |
15046 | (set (match_operand:DI 0 "register_operand" "=D") | |
15047 | (plus:DI (ashift:DI (match_operand:DI 5 "register_operand" "2") | |
15048 | (const_int 2)) | |
15049 | (match_operand:DI 3 "register_operand" "0"))) | |
15050 | (set (match_operand:DI 1 "register_operand" "=S") | |
15051 | (plus:DI (ashift:DI (match_dup 5) (const_int 2)) | |
15052 | (match_operand:DI 4 "register_operand" "1"))) | |
15053 | (set (mem:BLK (match_dup 3)) | |
15054 | (mem:BLK (match_dup 4))) | |
15055 | (use (match_dup 5)) | |
15056 | (use (reg:SI 19))] | |
15057 | "TARGET_64BIT" | |
8554d9a4 | 15058 | "{rep\;movsl|rep movsd}" |
f90800f8 | 15059 | [(set_attr "type" "str") |
6ef67412 JH |
15060 | (set_attr "prefix_rep" "1") |
15061 | (set_attr "memory" "both") | |
15062 | (set_attr "mode" "SI")]) | |
f90800f8 JH |
15063 | |
15064 | (define_insn "rep_movqi" | |
15065 | [(set (match_operand:SI 2 "register_operand" "=c") (const_int 0)) | |
f90800f8 | 15066 | (set (match_operand:SI 0 "register_operand" "=D") |
b1cdafbb JH |
15067 | (plus:SI (match_operand:SI 3 "register_operand" "0") |
15068 | (match_operand:SI 5 "register_operand" "2"))) | |
f90800f8 | 15069 | (set (match_operand:SI 1 "register_operand" "=S") |
b1cdafbb | 15070 | (plus:SI (match_operand:SI 4 "register_operand" "1") (match_dup 5))) |
f90800f8 JH |
15071 | (set (mem:BLK (match_dup 3)) |
15072 | (mem:BLK (match_dup 4))) | |
b1cdafbb | 15073 | (use (match_dup 5)) |
f90800f8 | 15074 | (use (reg:SI 19))] |
0945b39d | 15075 | "!TARGET_64BIT" |
8554d9a4 | 15076 | "{rep\;movsb|rep movsb}" |
0945b39d JH |
15077 | [(set_attr "type" "str") |
15078 | (set_attr "prefix_rep" "1") | |
15079 | (set_attr "memory" "both") | |
15080 | (set_attr "mode" "SI")]) | |
15081 | ||
15082 | (define_insn "rep_movqi_rex64" | |
15083 | [(set (match_operand:DI 2 "register_operand" "=c") (const_int 0)) | |
15084 | (set (match_operand:DI 0 "register_operand" "=D") | |
15085 | (plus:DI (match_operand:DI 3 "register_operand" "0") | |
15086 | (match_operand:DI 5 "register_operand" "2"))) | |
15087 | (set (match_operand:DI 1 "register_operand" "=S") | |
15088 | (plus:DI (match_operand:DI 4 "register_operand" "1") (match_dup 5))) | |
15089 | (set (mem:BLK (match_dup 3)) | |
15090 | (mem:BLK (match_dup 4))) | |
15091 | (use (match_dup 5)) | |
15092 | (use (reg:SI 19))] | |
15093 | "TARGET_64BIT" | |
8554d9a4 | 15094 | "{rep\;movsb|rep movsb}" |
f90800f8 | 15095 | [(set_attr "type" "str") |
6ef67412 JH |
15096 | (set_attr "prefix_rep" "1") |
15097 | (set_attr "memory" "both") | |
15098 | (set_attr "mode" "SI")]) | |
886c62d1 | 15099 | |
0ae40045 | 15100 | (define_expand "clrstrsi" |
e2e52e1b | 15101 | [(use (match_operand:BLK 0 "memory_operand" "")) |
79f05c19 | 15102 | (use (match_operand:SI 1 "nonmemory_operand" "")) |
0945b39d | 15103 | (use (match_operand 2 "const_int_operand" ""))] |
0ae40045 | 15104 | "" |
0ae40045 | 15105 | { |
0945b39d JH |
15106 | if (ix86_expand_clrstr (operands[0], operands[1], operands[2])) |
15107 | DONE; | |
15108 | else | |
15109 | FAIL; | |
0f40f9f7 | 15110 | }) |
e2e52e1b | 15111 | |
0945b39d JH |
15112 | (define_expand "clrstrdi" |
15113 | [(use (match_operand:BLK 0 "memory_operand" "")) | |
15114 | (use (match_operand:DI 1 "nonmemory_operand" "")) | |
15115 | (use (match_operand 2 "const_int_operand" ""))] | |
15116 | "TARGET_64BIT" | |
0945b39d JH |
15117 | { |
15118 | if (ix86_expand_clrstr (operands[0], operands[1], operands[2])) | |
15119 | DONE; | |
15120 | else | |
15121 | FAIL; | |
0f40f9f7 | 15122 | }) |
e2e52e1b | 15123 | |
0945b39d JH |
15124 | ;; Most CPUs don't like single string operations |
15125 | ;; Handle this case here to simplify previous expander. | |
79f05c19 | 15126 | |
0945b39d JH |
15127 | (define_expand "strsetdi_rex64" |
15128 | [(set (mem:DI (match_operand:DI 0 "register_operand" "")) | |
15129 | (match_operand:DI 1 "register_operand" "")) | |
15130 | (parallel [(set (match_dup 0) (plus:DI (match_dup 0) (const_int 8))) | |
15131 | (clobber (reg:CC 17))])] | |
15132 | "TARGET_64BIT" | |
0945b39d JH |
15133 | { |
15134 | if (TARGET_SINGLE_STRINGOP || optimize_size) | |
79f05c19 | 15135 | { |
0945b39d JH |
15136 | emit_insn (gen_strsetdi_rex_1 (operands[0], operands[0], operands[1])); |
15137 | DONE; | |
79f05c19 | 15138 | } |
0f40f9f7 | 15139 | }) |
e2e52e1b | 15140 | |
79f05c19 JH |
15141 | (define_expand "strsetsi" |
15142 | [(set (mem:SI (match_operand:SI 0 "register_operand" "")) | |
15143 | (match_operand:SI 1 "register_operand" "")) | |
15144 | (parallel [(set (match_dup 0) (plus:SI (match_dup 0) (const_int 4))) | |
15145 | (clobber (reg:CC 17))])] | |
15146 | "" | |
79f05c19 | 15147 | { |
0945b39d JH |
15148 | if (TARGET_64BIT) |
15149 | { | |
15150 | emit_insn (gen_strsetsi_rex64 (operands[0], operands[1])); | |
15151 | DONE; | |
15152 | } | |
15153 | else if (TARGET_SINGLE_STRINGOP || optimize_size) | |
79f05c19 JH |
15154 | { |
15155 | emit_insn (gen_strsetsi_1 (operands[0], operands[0], operands[1])); | |
15156 | DONE; | |
15157 | } | |
0f40f9f7 | 15158 | }) |
79f05c19 | 15159 | |
0945b39d JH |
15160 | (define_expand "strsetsi_rex64" |
15161 | [(set (mem:SI (match_operand:DI 0 "register_operand" "")) | |
15162 | (match_operand:SI 1 "register_operand" "")) | |
15163 | (parallel [(set (match_dup 0) (plus:DI (match_dup 0) (const_int 4))) | |
15164 | (clobber (reg:CC 17))])] | |
15165 | "TARGET_64BIT" | |
0945b39d JH |
15166 | { |
15167 | if (TARGET_SINGLE_STRINGOP || optimize_size) | |
15168 | { | |
15169 | emit_insn (gen_strsetsi_rex_1 (operands[0], operands[0], operands[1])); | |
15170 | DONE; | |
15171 | } | |
0f40f9f7 | 15172 | }) |
0945b39d | 15173 | |
e2e52e1b JH |
15174 | (define_expand "strsethi" |
15175 | [(set (mem:HI (match_operand:SI 0 "register_operand" "")) | |
15176 | (match_operand:HI 1 "register_operand" "")) | |
15177 | (parallel [(set (match_dup 0) (plus:SI (match_dup 0) (const_int 2))) | |
15178 | (clobber (reg:CC 17))])] | |
15179 | "" | |
e2e52e1b | 15180 | { |
0945b39d JH |
15181 | if (TARGET_64BIT) |
15182 | { | |
15183 | emit_insn (gen_strsethi_rex64 (operands[0], operands[1])); | |
15184 | DONE; | |
15185 | } | |
15186 | else if (TARGET_SINGLE_STRINGOP || optimize_size) | |
e2e52e1b JH |
15187 | { |
15188 | emit_insn (gen_strsethi_1 (operands[0], operands[0], operands[1])); | |
15189 | DONE; | |
15190 | } | |
0f40f9f7 | 15191 | }) |
0ae40045 | 15192 | |
0945b39d JH |
15193 | (define_expand "strsethi_rex64" |
15194 | [(set (mem:HI (match_operand:DI 0 "register_operand" "")) | |
15195 | (match_operand:HI 1 "register_operand" "")) | |
15196 | (parallel [(set (match_dup 0) (plus:DI (match_dup 0) (const_int 2))) | |
15197 | (clobber (reg:CC 17))])] | |
15198 | "TARGET_64BIT" | |
0945b39d JH |
15199 | { |
15200 | if (TARGET_SINGLE_STRINGOP || optimize_size) | |
15201 | { | |
15202 | emit_insn (gen_strsethi_rex_1 (operands[0], operands[0], operands[1])); | |
15203 | DONE; | |
15204 | } | |
0f40f9f7 | 15205 | }) |
0945b39d | 15206 | |
e2e52e1b JH |
15207 | (define_expand "strsetqi" |
15208 | [(set (mem:QI (match_operand:SI 0 "register_operand" "")) | |
15209 | (match_operand:QI 1 "register_operand" "")) | |
15210 | (parallel [(set (match_dup 0) (plus:SI (match_dup 0) (const_int 1))) | |
15211 | (clobber (reg:CC 17))])] | |
15212 | "" | |
e2e52e1b | 15213 | { |
0945b39d JH |
15214 | if (TARGET_64BIT) |
15215 | { | |
15216 | emit_insn (gen_strsetqi_rex64 (operands[0], operands[1])); | |
15217 | DONE; | |
15218 | } | |
15219 | else if (TARGET_SINGLE_STRINGOP || optimize_size) | |
e2e52e1b JH |
15220 | { |
15221 | emit_insn (gen_strsetqi_1 (operands[0], operands[0], operands[1])); | |
15222 | DONE; | |
15223 | } | |
0f40f9f7 | 15224 | }) |
0ae40045 | 15225 | |
0945b39d JH |
15226 | (define_expand "strsetqi_rex64" |
15227 | [(set (mem:QI (match_operand:DI 0 "register_operand" "")) | |
15228 | (match_operand:QI 1 "register_operand" "")) | |
15229 | (parallel [(set (match_dup 0) (plus:DI (match_dup 0) (const_int 1))) | |
15230 | (clobber (reg:CC 17))])] | |
15231 | "TARGET_64BIT" | |
0945b39d JH |
15232 | { |
15233 | if (TARGET_SINGLE_STRINGOP || optimize_size) | |
15234 | { | |
15235 | emit_insn (gen_strsetqi_rex_1 (operands[0], operands[0], operands[1])); | |
15236 | DONE; | |
15237 | } | |
0f40f9f7 | 15238 | }) |
0945b39d JH |
15239 | |
15240 | (define_insn "strsetdi_rex_1" | |
15241 | [(set (mem:SI (match_operand:DI 1 "register_operand" "0")) | |
15242 | (match_operand:SI 2 "register_operand" "a")) | |
15243 | (set (match_operand:DI 0 "register_operand" "=D") | |
15244 | (plus:DI (match_dup 1) | |
15245 | (const_int 8))) | |
15246 | (use (reg:SI 19))] | |
15247 | "TARGET_64BIT && (TARGET_SINGLE_STRINGOP || optimize_size)" | |
15248 | "stosq" | |
15249 | [(set_attr "type" "str") | |
15250 | (set_attr "memory" "store") | |
15251 | (set_attr "mode" "DI")]) | |
15252 | ||
79f05c19 JH |
15253 | (define_insn "strsetsi_1" |
15254 | [(set (mem:SI (match_operand:SI 1 "register_operand" "0")) | |
15255 | (match_operand:SI 2 "register_operand" "a")) | |
15256 | (set (match_operand:SI 0 "register_operand" "=D") | |
b1cdafbb | 15257 | (plus:SI (match_dup 1) |
79f05c19 JH |
15258 | (const_int 4))) |
15259 | (use (reg:SI 19))] | |
0945b39d | 15260 | "!TARGET_64BIT && (TARGET_SINGLE_STRINGOP || optimize_size)" |
8554d9a4 | 15261 | "{stosl|stosd}" |
0945b39d JH |
15262 | [(set_attr "type" "str") |
15263 | (set_attr "memory" "store") | |
15264 | (set_attr "mode" "SI")]) | |
15265 | ||
15266 | (define_insn "strsetsi_rex_1" | |
15267 | [(set (mem:SI (match_operand:DI 1 "register_operand" "0")) | |
15268 | (match_operand:SI 2 "register_operand" "a")) | |
15269 | (set (match_operand:DI 0 "register_operand" "=D") | |
15270 | (plus:DI (match_dup 1) | |
15271 | (const_int 4))) | |
15272 | (use (reg:SI 19))] | |
15273 | "TARGET_64BIT && (TARGET_SINGLE_STRINGOP || optimize_size)" | |
8554d9a4 | 15274 | "{stosl|stosd}" |
79f05c19 | 15275 | [(set_attr "type" "str") |
6ef67412 JH |
15276 | (set_attr "memory" "store") |
15277 | (set_attr "mode" "SI")]) | |
79f05c19 | 15278 | |
e2e52e1b JH |
15279 | (define_insn "strsethi_1" |
15280 | [(set (mem:HI (match_operand:SI 1 "register_operand" "0")) | |
15281 | (match_operand:HI 2 "register_operand" "a")) | |
15282 | (set (match_operand:SI 0 "register_operand" "=D") | |
b1cdafbb | 15283 | (plus:SI (match_dup 1) |
e2e52e1b JH |
15284 | (const_int 2))) |
15285 | (use (reg:SI 19))] | |
0945b39d JH |
15286 | "!TARGET_64BIT && (TARGET_SINGLE_STRINGOP || optimize_size)" |
15287 | "stosw" | |
15288 | [(set_attr "type" "str") | |
15289 | (set_attr "memory" "store") | |
15290 | (set_attr "mode" "HI")]) | |
15291 | ||
15292 | (define_insn "strsethi_rex_1" | |
15293 | [(set (mem:HI (match_operand:DI 1 "register_operand" "0")) | |
15294 | (match_operand:HI 2 "register_operand" "a")) | |
15295 | (set (match_operand:DI 0 "register_operand" "=D") | |
15296 | (plus:DI (match_dup 1) | |
15297 | (const_int 2))) | |
15298 | (use (reg:SI 19))] | |
15299 | "TARGET_64BIT && (TARGET_SINGLE_STRINGOP || optimize_size)" | |
e2e52e1b JH |
15300 | "stosw" |
15301 | [(set_attr "type" "str") | |
15302 | (set_attr "memory" "store") | |
6ef67412 | 15303 | (set_attr "mode" "HI")]) |
e2e52e1b JH |
15304 | |
15305 | (define_insn "strsetqi_1" | |
15306 | [(set (mem:QI (match_operand:SI 1 "register_operand" "0")) | |
15307 | (match_operand:QI 2 "register_operand" "a")) | |
15308 | (set (match_operand:SI 0 "register_operand" "=D") | |
b1cdafbb | 15309 | (plus:SI (match_dup 1) |
e2e52e1b JH |
15310 | (const_int 1))) |
15311 | (use (reg:SI 19))] | |
0945b39d JH |
15312 | "!TARGET_64BIT && (TARGET_SINGLE_STRINGOP || optimize_size)" |
15313 | "stosb" | |
15314 | [(set_attr "type" "str") | |
15315 | (set_attr "memory" "store") | |
15316 | (set_attr "mode" "QI")]) | |
15317 | ||
15318 | (define_insn "strsetqi_rex_1" | |
15319 | [(set (mem:QI (match_operand:DI 1 "register_operand" "0")) | |
15320 | (match_operand:QI 2 "register_operand" "a")) | |
15321 | (set (match_operand:DI 0 "register_operand" "=D") | |
15322 | (plus:DI (match_dup 1) | |
15323 | (const_int 1))) | |
15324 | (use (reg:SI 19))] | |
15325 | "TARGET_64BIT && (TARGET_SINGLE_STRINGOP || optimize_size)" | |
e2e52e1b JH |
15326 | "stosb" |
15327 | [(set_attr "type" "str") | |
6ef67412 JH |
15328 | (set_attr "memory" "store") |
15329 | (set_attr "mode" "QI")]) | |
e2e52e1b | 15330 | |
0945b39d JH |
15331 | (define_insn "rep_stosdi_rex64" |
15332 | [(set (match_operand:DI 1 "register_operand" "=c") (const_int 0)) | |
15333 | (set (match_operand:DI 0 "register_operand" "=D") | |
15334 | (plus:DI (ashift:DI (match_operand:DI 4 "register_operand" "1") | |
15335 | (const_int 3)) | |
15336 | (match_operand:DI 3 "register_operand" "0"))) | |
15337 | (set (mem:BLK (match_dup 3)) | |
15338 | (const_int 0)) | |
15339 | (use (match_operand:DI 2 "register_operand" "a")) | |
15340 | (use (match_dup 4)) | |
15341 | (use (reg:SI 19))] | |
15342 | "TARGET_64BIT" | |
8554d9a4 | 15343 | "{rep\;stosq|rep stosq}" |
0945b39d JH |
15344 | [(set_attr "type" "str") |
15345 | (set_attr "prefix_rep" "1") | |
15346 | (set_attr "memory" "store") | |
15347 | (set_attr "mode" "DI")]) | |
15348 | ||
e2e52e1b JH |
15349 | (define_insn "rep_stossi" |
15350 | [(set (match_operand:SI 1 "register_operand" "=c") (const_int 0)) | |
e2e52e1b | 15351 | (set (match_operand:SI 0 "register_operand" "=D") |
b1cdafbb JH |
15352 | (plus:SI (ashift:SI (match_operand:SI 4 "register_operand" "1") |
15353 | (const_int 2)) | |
15354 | (match_operand:SI 3 "register_operand" "0"))) | |
e2e52e1b | 15355 | (set (mem:BLK (match_dup 3)) |
0ae40045 | 15356 | (const_int 0)) |
b1cdafbb JH |
15357 | (use (match_operand:SI 2 "register_operand" "a")) |
15358 | (use (match_dup 4)) | |
e2e52e1b | 15359 | (use (reg:SI 19))] |
0945b39d | 15360 | "!TARGET_64BIT" |
8554d9a4 | 15361 | "{rep\;stosl|rep stosd}" |
0945b39d JH |
15362 | [(set_attr "type" "str") |
15363 | (set_attr "prefix_rep" "1") | |
15364 | (set_attr "memory" "store") | |
15365 | (set_attr "mode" "SI")]) | |
15366 | ||
15367 | (define_insn "rep_stossi_rex64" | |
15368 | [(set (match_operand:DI 1 "register_operand" "=c") (const_int 0)) | |
15369 | (set (match_operand:DI 0 "register_operand" "=D") | |
15370 | (plus:DI (ashift:DI (match_operand:DI 4 "register_operand" "1") | |
15371 | (const_int 2)) | |
15372 | (match_operand:DI 3 "register_operand" "0"))) | |
15373 | (set (mem:BLK (match_dup 3)) | |
15374 | (const_int 0)) | |
15375 | (use (match_operand:SI 2 "register_operand" "a")) | |
15376 | (use (match_dup 4)) | |
15377 | (use (reg:SI 19))] | |
15378 | "TARGET_64BIT" | |
8554d9a4 | 15379 | "{rep\;stosl|rep stosd}" |
e2e52e1b | 15380 | [(set_attr "type" "str") |
6ef67412 JH |
15381 | (set_attr "prefix_rep" "1") |
15382 | (set_attr "memory" "store") | |
15383 | (set_attr "mode" "SI")]) | |
0ae40045 | 15384 | |
e2e52e1b JH |
15385 | (define_insn "rep_stosqi" |
15386 | [(set (match_operand:SI 1 "register_operand" "=c") (const_int 0)) | |
e2e52e1b | 15387 | (set (match_operand:SI 0 "register_operand" "=D") |
b1cdafbb JH |
15388 | (plus:SI (match_operand:SI 3 "register_operand" "0") |
15389 | (match_operand:SI 4 "register_operand" "1"))) | |
e2e52e1b JH |
15390 | (set (mem:BLK (match_dup 3)) |
15391 | (const_int 0)) | |
b1cdafbb JH |
15392 | (use (match_operand:QI 2 "register_operand" "a")) |
15393 | (use (match_dup 4)) | |
e2e52e1b | 15394 | (use (reg:SI 19))] |
0945b39d | 15395 | "!TARGET_64BIT" |
8554d9a4 | 15396 | "{rep\;stosb|rep stosb}" |
0945b39d JH |
15397 | [(set_attr "type" "str") |
15398 | (set_attr "prefix_rep" "1") | |
15399 | (set_attr "memory" "store") | |
15400 | (set_attr "mode" "QI")]) | |
15401 | ||
15402 | (define_insn "rep_stosqi_rex64" | |
15403 | [(set (match_operand:DI 1 "register_operand" "=c") (const_int 0)) | |
15404 | (set (match_operand:DI 0 "register_operand" "=D") | |
15405 | (plus:DI (match_operand:DI 3 "register_operand" "0") | |
15406 | (match_operand:DI 4 "register_operand" "1"))) | |
15407 | (set (mem:BLK (match_dup 3)) | |
15408 | (const_int 0)) | |
15409 | (use (match_operand:QI 2 "register_operand" "a")) | |
15410 | (use (match_dup 4)) | |
15411 | (use (reg:DI 19))] | |
15412 | "TARGET_64BIT" | |
8554d9a4 | 15413 | "{rep\;stosb|rep stosb}" |
e2e52e1b | 15414 | [(set_attr "type" "str") |
6ef67412 JH |
15415 | (set_attr "prefix_rep" "1") |
15416 | (set_attr "memory" "store") | |
15417 | (set_attr "mode" "QI")]) | |
0ae40045 | 15418 | |
886c62d1 | 15419 | (define_expand "cmpstrsi" |
e075ae69 RH |
15420 | [(set (match_operand:SI 0 "register_operand" "") |
15421 | (compare:SI (match_operand:BLK 1 "general_operand" "") | |
15422 | (match_operand:BLK 2 "general_operand" ""))) | |
0945b39d JH |
15423 | (use (match_operand 3 "general_operand" "")) |
15424 | (use (match_operand 4 "immediate_operand" ""))] | |
886c62d1 | 15425 | "" |
886c62d1 | 15426 | { |
e075ae69 RH |
15427 | rtx addr1, addr2, out, outlow, count, countreg, align; |
15428 | ||
15429 | out = operands[0]; | |
15430 | if (GET_CODE (out) != REG) | |
15431 | out = gen_reg_rtx (SImode); | |
783cdf65 JVA |
15432 | |
15433 | addr1 = copy_to_mode_reg (Pmode, XEXP (operands[1], 0)); | |
15434 | addr2 = copy_to_mode_reg (Pmode, XEXP (operands[2], 0)); | |
e075ae69 RH |
15435 | |
15436 | count = operands[3]; | |
d24b3457 | 15437 | countreg = ix86_zero_extend_to_Pmode (count); |
e075ae69 RH |
15438 | |
15439 | /* %%% Iff we are testing strict equality, we can use known alignment | |
15440 | to good advantage. This may be possible with combine, particularly | |
15441 | once cc0 is dead. */ | |
15442 | align = operands[4]; | |
783cdf65 | 15443 | |
7c7ef435 | 15444 | emit_insn (gen_cld ()); |
e075ae69 RH |
15445 | if (GET_CODE (count) == CONST_INT) |
15446 | { | |
15447 | if (INTVAL (count) == 0) | |
15448 | { | |
15449 | emit_move_insn (operands[0], const0_rtx); | |
15450 | DONE; | |
15451 | } | |
0945b39d JH |
15452 | if (TARGET_64BIT) |
15453 | emit_insn (gen_cmpstrqi_nz_rex_1 (addr1, addr2, countreg, align, | |
15454 | addr1, addr2, countreg)); | |
15455 | else | |
15456 | emit_insn (gen_cmpstrqi_nz_1 (addr1, addr2, countreg, align, | |
15457 | addr1, addr2, countreg)); | |
e075ae69 RH |
15458 | } |
15459 | else | |
e2e52e1b | 15460 | { |
0945b39d JH |
15461 | if (TARGET_64BIT) |
15462 | { | |
15463 | emit_insn (gen_cmpdi_1_rex64 (countreg, countreg)); | |
15464 | emit_insn (gen_cmpstrqi_rex_1 (addr1, addr2, countreg, align, | |
15465 | addr1, addr2, countreg)); | |
15466 | } | |
15467 | else | |
15468 | { | |
15469 | emit_insn (gen_cmpsi_1 (countreg, countreg)); | |
15470 | emit_insn (gen_cmpstrqi_1 (addr1, addr2, countreg, align, | |
15471 | addr1, addr2, countreg)); | |
15472 | } | |
e2e52e1b | 15473 | } |
e075ae69 RH |
15474 | |
15475 | outlow = gen_lowpart (QImode, out); | |
15476 | emit_insn (gen_cmpintqi (outlow)); | |
15477 | emit_move_insn (out, gen_rtx_SIGN_EXTEND (SImode, outlow)); | |
783cdf65 | 15478 | |
e075ae69 RH |
15479 | if (operands[0] != out) |
15480 | emit_move_insn (operands[0], out); | |
783cdf65 | 15481 | |
e075ae69 | 15482 | DONE; |
0f40f9f7 | 15483 | }) |
886c62d1 | 15484 | |
e075ae69 RH |
15485 | ;; Produce a tri-state integer (-1, 0, 1) from condition codes. |
15486 | ||
15487 | (define_expand "cmpintqi" | |
15488 | [(set (match_dup 1) | |
15489 | (gtu:QI (reg:CC 17) (const_int 0))) | |
15490 | (set (match_dup 2) | |
15491 | (ltu:QI (reg:CC 17) (const_int 0))) | |
15492 | (parallel [(set (match_operand:QI 0 "register_operand" "") | |
15493 | (minus:QI (match_dup 1) | |
15494 | (match_dup 2))) | |
15495 | (clobber (reg:CC 17))])] | |
15496 | "" | |
15497 | "operands[1] = gen_reg_rtx (QImode); | |
15498 | operands[2] = gen_reg_rtx (QImode);") | |
15499 | ||
f76e3b05 JVA |
15500 | ;; memcmp recognizers. The `cmpsb' opcode does nothing if the count is |
15501 | ;; zero. Emit extra code to make sure that a zero-length compare is EQ. | |
56c0e8fa | 15502 | |
0945b39d | 15503 | (define_insn "cmpstrqi_nz_1" |
e075ae69 | 15504 | [(set (reg:CC 17) |
b1cdafbb JH |
15505 | (compare:CC (mem:BLK (match_operand:SI 4 "register_operand" "0")) |
15506 | (mem:BLK (match_operand:SI 5 "register_operand" "1")))) | |
15507 | (use (match_operand:SI 6 "register_operand" "2")) | |
886c62d1 | 15508 | (use (match_operand:SI 3 "immediate_operand" "i")) |
7c7ef435 | 15509 | (use (reg:SI 19)) |
b1cdafbb JH |
15510 | (clobber (match_operand:SI 0 "register_operand" "=S")) |
15511 | (clobber (match_operand:SI 1 "register_operand" "=D")) | |
15512 | (clobber (match_operand:SI 2 "register_operand" "=c"))] | |
0945b39d JH |
15513 | "!TARGET_64BIT" |
15514 | "repz{\;| }cmpsb" | |
15515 | [(set_attr "type" "str") | |
15516 | (set_attr "mode" "QI") | |
15517 | (set_attr "prefix_rep" "1")]) | |
15518 | ||
15519 | (define_insn "cmpstrqi_nz_rex_1" | |
15520 | [(set (reg:CC 17) | |
15521 | (compare:CC (mem:BLK (match_operand:DI 4 "register_operand" "0")) | |
15522 | (mem:BLK (match_operand:DI 5 "register_operand" "1")))) | |
15523 | (use (match_operand:DI 6 "register_operand" "2")) | |
15524 | (use (match_operand:SI 3 "immediate_operand" "i")) | |
15525 | (use (reg:SI 19)) | |
15526 | (clobber (match_operand:DI 0 "register_operand" "=S")) | |
15527 | (clobber (match_operand:DI 1 "register_operand" "=D")) | |
15528 | (clobber (match_operand:DI 2 "register_operand" "=c"))] | |
15529 | "TARGET_64BIT" | |
7c7ef435 | 15530 | "repz{\;| }cmpsb" |
e2e52e1b | 15531 | [(set_attr "type" "str") |
6ef67412 JH |
15532 | (set_attr "mode" "QI") |
15533 | (set_attr "prefix_rep" "1")]) | |
886c62d1 | 15534 | |
e075ae69 | 15535 | ;; The same, but the count is not known to not be zero. |
886c62d1 | 15536 | |
0945b39d | 15537 | (define_insn "cmpstrqi_1" |
e075ae69 | 15538 | [(set (reg:CC 17) |
b1cdafbb | 15539 | (if_then_else:CC (ne (match_operand:SI 6 "register_operand" "2") |
e075ae69 | 15540 | (const_int 0)) |
2bed3391 | 15541 | (compare:CC (mem:BLK (match_operand:SI 4 "register_operand" "0")) |
b1cdafbb | 15542 | (mem:BLK (match_operand:SI 5 "register_operand" "1"))) |
e075ae69 RH |
15543 | (const_int 0))) |
15544 | (use (match_operand:SI 3 "immediate_operand" "i")) | |
e2e52e1b | 15545 | (use (reg:CC 17)) |
7c7ef435 | 15546 | (use (reg:SI 19)) |
b1cdafbb JH |
15547 | (clobber (match_operand:SI 0 "register_operand" "=S")) |
15548 | (clobber (match_operand:SI 1 "register_operand" "=D")) | |
15549 | (clobber (match_operand:SI 2 "register_operand" "=c"))] | |
0945b39d JH |
15550 | "!TARGET_64BIT" |
15551 | "repz{\;| }cmpsb" | |
15552 | [(set_attr "type" "str") | |
15553 | (set_attr "mode" "QI") | |
15554 | (set_attr "prefix_rep" "1")]) | |
15555 | ||
15556 | (define_insn "cmpstrqi_rex_1" | |
15557 | [(set (reg:CC 17) | |
15558 | (if_then_else:CC (ne (match_operand:DI 6 "register_operand" "2") | |
15559 | (const_int 0)) | |
15560 | (compare:CC (mem:BLK (match_operand:DI 4 "register_operand" "0")) | |
15561 | (mem:BLK (match_operand:DI 5 "register_operand" "1"))) | |
15562 | (const_int 0))) | |
15563 | (use (match_operand:SI 3 "immediate_operand" "i")) | |
15564 | (use (reg:CC 17)) | |
15565 | (use (reg:SI 19)) | |
15566 | (clobber (match_operand:DI 0 "register_operand" "=S")) | |
15567 | (clobber (match_operand:DI 1 "register_operand" "=D")) | |
15568 | (clobber (match_operand:DI 2 "register_operand" "=c"))] | |
15569 | "TARGET_64BIT" | |
e2e52e1b JH |
15570 | "repz{\;| }cmpsb" |
15571 | [(set_attr "type" "str") | |
6ef67412 JH |
15572 | (set_attr "mode" "QI") |
15573 | (set_attr "prefix_rep" "1")]) | |
886c62d1 | 15574 | |
e075ae69 RH |
15575 | (define_expand "strlensi" |
15576 | [(set (match_operand:SI 0 "register_operand" "") | |
15577 | (unspec:SI [(match_operand:BLK 1 "general_operand" "") | |
15578 | (match_operand:QI 2 "immediate_operand" "") | |
0945b39d | 15579 | (match_operand 3 "immediate_operand" "")] 0))] |
886c62d1 | 15580 | "" |
886c62d1 | 15581 | { |
0945b39d JH |
15582 | if (ix86_expand_strlen (operands[0], operands[1], operands[2], operands[3])) |
15583 | DONE; | |
15584 | else | |
15585 | FAIL; | |
0f40f9f7 | 15586 | }) |
e075ae69 | 15587 | |
0945b39d JH |
15588 | (define_expand "strlendi" |
15589 | [(set (match_operand:DI 0 "register_operand" "") | |
15590 | (unspec:DI [(match_operand:BLK 1 "general_operand" "") | |
15591 | (match_operand:QI 2 "immediate_operand" "") | |
15592 | (match_operand 3 "immediate_operand" "")] 0))] | |
15593 | "" | |
0945b39d JH |
15594 | { |
15595 | if (ix86_expand_strlen (operands[0], operands[1], operands[2], operands[3])) | |
15596 | DONE; | |
15597 | else | |
15598 | FAIL; | |
0f40f9f7 | 15599 | }) |
19c3fc24 | 15600 | |
0945b39d | 15601 | (define_insn "strlenqi_1" |
e075ae69 | 15602 | [(set (match_operand:SI 0 "register_operand" "=&c") |
b1cdafbb | 15603 | (unspec:SI [(mem:BLK (match_operand:SI 5 "register_operand" "1")) |
0945b39d | 15604 | (match_operand:QI 2 "register_operand" "a") |
e075ae69 | 15605 | (match_operand:SI 3 "immediate_operand" "i") |
0945b39d | 15606 | (match_operand:SI 4 "register_operand" "0")] 0)) |
7c7ef435 | 15607 | (use (reg:SI 19)) |
b1cdafbb | 15608 | (clobber (match_operand:SI 1 "register_operand" "=D")) |
e075ae69 | 15609 | (clobber (reg:CC 17))] |
0945b39d JH |
15610 | "!TARGET_64BIT" |
15611 | "repnz{\;| }scasb" | |
15612 | [(set_attr "type" "str") | |
15613 | (set_attr "mode" "QI") | |
15614 | (set_attr "prefix_rep" "1")]) | |
15615 | ||
15616 | (define_insn "strlenqi_rex_1" | |
15617 | [(set (match_operand:DI 0 "register_operand" "=&c") | |
15618 | (unspec:DI [(mem:BLK (match_operand:DI 5 "register_operand" "1")) | |
15619 | (match_operand:QI 2 "register_operand" "a") | |
15620 | (match_operand:DI 3 "immediate_operand" "i") | |
15621 | (match_operand:DI 4 "register_operand" "0")] 0)) | |
15622 | (use (reg:SI 19)) | |
15623 | (clobber (match_operand:DI 1 "register_operand" "=D")) | |
15624 | (clobber (reg:CC 17))] | |
15625 | "TARGET_64BIT" | |
7c7ef435 | 15626 | "repnz{\;| }scasb" |
e2e52e1b | 15627 | [(set_attr "type" "str") |
6ef67412 JH |
15628 | (set_attr "mode" "QI") |
15629 | (set_attr "prefix_rep" "1")]) | |
a3e991f2 ZW |
15630 | |
15631 | ;; Peephole optimizations to clean up after cmpstr*. This should be | |
15632 | ;; handled in combine, but it is not currently up to the task. | |
15633 | ;; When used for their truth value, the cmpstr* expanders generate | |
15634 | ;; code like this: | |
15635 | ;; | |
15636 | ;; repz cmpsb | |
15637 | ;; seta %al | |
15638 | ;; setb %dl | |
15639 | ;; cmpb %al, %dl | |
15640 | ;; jcc label | |
15641 | ;; | |
15642 | ;; The intermediate three instructions are unnecessary. | |
15643 | ||
15644 | ;; This one handles cmpstr*_nz_1... | |
15645 | (define_peephole2 | |
15646 | [(parallel[ | |
15647 | (set (reg:CC 17) | |
15648 | (compare:CC (mem:BLK (match_operand 4 "register_operand" "")) | |
15649 | (mem:BLK (match_operand 5 "register_operand" "")))) | |
15650 | (use (match_operand 6 "register_operand" "")) | |
15651 | (use (match_operand:SI 3 "immediate_operand" "")) | |
15652 | (use (reg:SI 19)) | |
15653 | (clobber (match_operand 0 "register_operand" "")) | |
15654 | (clobber (match_operand 1 "register_operand" "")) | |
15655 | (clobber (match_operand 2 "register_operand" ""))]) | |
15656 | (set (match_operand:QI 7 "register_operand" "") | |
15657 | (gtu:QI (reg:CC 17) (const_int 0))) | |
15658 | (set (match_operand:QI 8 "register_operand" "") | |
15659 | (ltu:QI (reg:CC 17) (const_int 0))) | |
15660 | (set (reg 17) | |
15661 | (compare (match_dup 7) (match_dup 8))) | |
15662 | ] | |
244ec848 | 15663 | "peep2_reg_dead_p (4, operands[7]) && peep2_reg_dead_p (4, operands[8])" |
a3e991f2 ZW |
15664 | [(parallel[ |
15665 | (set (reg:CC 17) | |
15666 | (compare:CC (mem:BLK (match_dup 4)) | |
15667 | (mem:BLK (match_dup 5)))) | |
15668 | (use (match_dup 6)) | |
15669 | (use (match_dup 3)) | |
15670 | (use (reg:SI 19)) | |
15671 | (clobber (match_dup 0)) | |
15672 | (clobber (match_dup 1)) | |
244ec848 | 15673 | (clobber (match_dup 2))])] |
a3e991f2 ZW |
15674 | "") |
15675 | ||
15676 | ;; ...and this one handles cmpstr*_1. | |
15677 | (define_peephole2 | |
15678 | [(parallel[ | |
15679 | (set (reg:CC 17) | |
15680 | (if_then_else:CC (ne (match_operand 6 "register_operand" "") | |
15681 | (const_int 0)) | |
15682 | (compare:CC (mem:BLK (match_operand 4 "register_operand" "")) | |
15683 | (mem:BLK (match_operand 5 "register_operand" ""))) | |
15684 | (const_int 0))) | |
15685 | (use (match_operand:SI 3 "immediate_operand" "")) | |
15686 | (use (reg:CC 17)) | |
15687 | (use (reg:SI 19)) | |
15688 | (clobber (match_operand 0 "register_operand" "")) | |
15689 | (clobber (match_operand 1 "register_operand" "")) | |
15690 | (clobber (match_operand 2 "register_operand" ""))]) | |
15691 | (set (match_operand:QI 7 "register_operand" "") | |
15692 | (gtu:QI (reg:CC 17) (const_int 0))) | |
15693 | (set (match_operand:QI 8 "register_operand" "") | |
15694 | (ltu:QI (reg:CC 17) (const_int 0))) | |
15695 | (set (reg 17) | |
15696 | (compare (match_dup 7) (match_dup 8))) | |
15697 | ] | |
244ec848 | 15698 | "peep2_reg_dead_p (4, operands[7]) && peep2_reg_dead_p (4, operands[8])" |
a3e991f2 ZW |
15699 | [(parallel[ |
15700 | (set (reg:CC 17) | |
15701 | (if_then_else:CC (ne (match_dup 6) | |
15702 | (const_int 0)) | |
15703 | (compare:CC (mem:BLK (match_dup 4)) | |
15704 | (mem:BLK (match_dup 5))) | |
15705 | (const_int 0))) | |
15706 | (use (match_dup 3)) | |
15707 | (use (reg:CC 17)) | |
15708 | (use (reg:SI 19)) | |
15709 | (clobber (match_dup 0)) | |
15710 | (clobber (match_dup 1)) | |
244ec848 | 15711 | (clobber (match_dup 2))])] |
a3e991f2 ZW |
15712 | "") |
15713 | ||
15714 | ||
e075ae69 RH |
15715 | \f |
15716 | ;; Conditional move instructions. | |
726e2d54 | 15717 | |
44cf5b6a | 15718 | (define_expand "movdicc" |
885a70fd JH |
15719 | [(set (match_operand:DI 0 "register_operand" "") |
15720 | (if_then_else:DI (match_operand 1 "comparison_operator" "") | |
44cf5b6a JH |
15721 | (match_operand:DI 2 "general_operand" "") |
15722 | (match_operand:DI 3 "general_operand" "")))] | |
885a70fd JH |
15723 | "TARGET_64BIT" |
15724 | "if (!ix86_expand_int_movcc (operands)) FAIL; DONE;") | |
15725 | ||
e74061a9 | 15726 | (define_insn "x86_movdicc_0_m1_rex64" |
885a70fd JH |
15727 | [(set (match_operand:DI 0 "register_operand" "=r") |
15728 | (if_then_else:DI (ltu (reg:CC 17) (const_int 0)) | |
15729 | (const_int -1) | |
15730 | (const_int 0))) | |
15731 | (clobber (reg:CC 17))] | |
15732 | "TARGET_64BIT" | |
0f40f9f7 | 15733 | "sbb{q}\t%0, %0" |
885a70fd JH |
15734 | ; Since we don't have the proper number of operands for an alu insn, |
15735 | ; fill in all the blanks. | |
15736 | [(set_attr "type" "alu") | |
15737 | (set_attr "memory" "none") | |
15738 | (set_attr "imm_disp" "false") | |
15739 | (set_attr "mode" "DI") | |
15740 | (set_attr "length_immediate" "0")]) | |
15741 | ||
15742 | (define_insn "*movdicc_c_rex64" | |
15743 | [(set (match_operand:DI 0 "register_operand" "=r,r") | |
15744 | (if_then_else:DI (match_operator 1 "ix86_comparison_operator" | |
15745 | [(reg 17) (const_int 0)]) | |
15746 | (match_operand:DI 2 "nonimmediate_operand" "rm,0") | |
15747 | (match_operand:DI 3 "nonimmediate_operand" "0,rm")))] | |
15748 | "TARGET_64BIT && TARGET_CMOVE | |
15749 | && (GET_CODE (operands[2]) != MEM || GET_CODE (operands[3]) != MEM)" | |
15750 | "@ | |
0f40f9f7 ZW |
15751 | cmov%C1\t{%2, %0|%0, %2} |
15752 | cmov%c1\t{%3, %0|%0, %3}" | |
885a70fd JH |
15753 | [(set_attr "type" "icmov") |
15754 | (set_attr "mode" "DI")]) | |
15755 | ||
e075ae69 | 15756 | (define_expand "movsicc" |
6a4a5d95 | 15757 | [(set (match_operand:SI 0 "register_operand" "") |
e075ae69 RH |
15758 | (if_then_else:SI (match_operand 1 "comparison_operator" "") |
15759 | (match_operand:SI 2 "general_operand" "") | |
15760 | (match_operand:SI 3 "general_operand" "")))] | |
15761 | "" | |
15762 | "if (!ix86_expand_int_movcc (operands)) FAIL; DONE;") | |
726e2d54 | 15763 | |
e075ae69 RH |
15764 | ;; Data flow gets confused by our desire for `sbbl reg,reg', and clearing |
15765 | ;; the register first winds up with `sbbl $0,reg', which is also weird. | |
15766 | ;; So just document what we're doing explicitly. | |
15767 | ||
15768 | (define_insn "x86_movsicc_0_m1" | |
15769 | [(set (match_operand:SI 0 "register_operand" "=r") | |
15770 | (if_then_else:SI (ltu (reg:CC 17) (const_int 0)) | |
15771 | (const_int -1) | |
15772 | (const_int 0))) | |
15773 | (clobber (reg:CC 17))] | |
15774 | "" | |
0f40f9f7 | 15775 | "sbb{l}\t%0, %0" |
e075ae69 RH |
15776 | ; Since we don't have the proper number of operands for an alu insn, |
15777 | ; fill in all the blanks. | |
15778 | [(set_attr "type" "alu") | |
15779 | (set_attr "memory" "none") | |
15780 | (set_attr "imm_disp" "false") | |
6ef67412 JH |
15781 | (set_attr "mode" "SI") |
15782 | (set_attr "length_immediate" "0")]) | |
e075ae69 | 15783 | |
6343a50e | 15784 | (define_insn "*movsicc_noc" |
e075ae69 | 15785 | [(set (match_operand:SI 0 "register_operand" "=r,r") |
9076b9c1 | 15786 | (if_then_else:SI (match_operator 1 "ix86_comparison_operator" |
e075ae69 RH |
15787 | [(reg 17) (const_int 0)]) |
15788 | (match_operand:SI 2 "nonimmediate_operand" "rm,0") | |
15789 | (match_operand:SI 3 "nonimmediate_operand" "0,rm")))] | |
d525dfdf JH |
15790 | "TARGET_CMOVE |
15791 | && (GET_CODE (operands[2]) != MEM || GET_CODE (operands[3]) != MEM)" | |
e075ae69 | 15792 | "@ |
0f40f9f7 ZW |
15793 | cmov%C1\t{%2, %0|%0, %2} |
15794 | cmov%c1\t{%3, %0|%0, %3}" | |
6ef67412 JH |
15795 | [(set_attr "type" "icmov") |
15796 | (set_attr "mode" "SI")]) | |
726e2d54 | 15797 | |
726e2d54 JW |
15798 | (define_expand "movhicc" |
15799 | [(set (match_operand:HI 0 "register_operand" "") | |
15800 | (if_then_else:HI (match_operand 1 "comparison_operator" "") | |
15801 | (match_operand:HI 2 "nonimmediate_operand" "") | |
15802 | (match_operand:HI 3 "nonimmediate_operand" "")))] | |
d9f32422 | 15803 | "TARGET_CMOVE && TARGET_HIMODE_MATH" |
e075ae69 | 15804 | "if (!ix86_expand_int_movcc (operands)) FAIL; DONE;") |
726e2d54 | 15805 | |
6343a50e | 15806 | (define_insn "*movhicc_noc" |
e075ae69 | 15807 | [(set (match_operand:HI 0 "register_operand" "=r,r") |
9076b9c1 | 15808 | (if_then_else:HI (match_operator 1 "ix86_comparison_operator" |
e075ae69 RH |
15809 | [(reg 17) (const_int 0)]) |
15810 | (match_operand:HI 2 "nonimmediate_operand" "rm,0") | |
15811 | (match_operand:HI 3 "nonimmediate_operand" "0,rm")))] | |
d525dfdf JH |
15812 | "TARGET_CMOVE |
15813 | && (GET_CODE (operands[2]) != MEM || GET_CODE (operands[3]) != MEM)" | |
e075ae69 | 15814 | "@ |
0f40f9f7 ZW |
15815 | cmov%C1\t{%2, %0|%0, %2} |
15816 | cmov%c1\t{%3, %0|%0, %3}" | |
6ef67412 JH |
15817 | [(set_attr "type" "icmov") |
15818 | (set_attr "mode" "HI")]) | |
726e2d54 | 15819 | |
56710e42 | 15820 | (define_expand "movsfcc" |
726e2d54 | 15821 | [(set (match_operand:SF 0 "register_operand" "") |
56710e42 | 15822 | (if_then_else:SF (match_operand 1 "comparison_operator" "") |
e5e809f4 JL |
15823 | (match_operand:SF 2 "register_operand" "") |
15824 | (match_operand:SF 3 "register_operand" "")))] | |
726e2d54 | 15825 | "TARGET_CMOVE" |
e075ae69 | 15826 | "if (! ix86_expand_fp_movcc (operands)) FAIL; DONE;") |
726e2d54 | 15827 | |
6343a50e | 15828 | (define_insn "*movsfcc_1" |
7093c9ea | 15829 | [(set (match_operand:SF 0 "register_operand" "=f,f,r,r") |
e075ae69 RH |
15830 | (if_then_else:SF (match_operator 1 "fcmov_comparison_operator" |
15831 | [(reg 17) (const_int 0)]) | |
7093c9ea JH |
15832 | (match_operand:SF 2 "nonimmediate_operand" "f,0,rm,0") |
15833 | (match_operand:SF 3 "nonimmediate_operand" "0,f,0,rm")))] | |
15834 | "TARGET_CMOVE | |
15835 | && (GET_CODE (operands[2]) != MEM || GET_CODE (operands[3]) != MEM)" | |
e075ae69 | 15836 | "@ |
0f40f9f7 ZW |
15837 | fcmov%F1\t{%2, %0|%0, %2} |
15838 | fcmov%f1\t{%3, %0|%0, %3} | |
15839 | cmov%C1\t{%2, %0|%0, %2} | |
15840 | cmov%c1\t{%3, %0|%0, %3}" | |
7093c9ea JH |
15841 | [(set_attr "type" "fcmov,fcmov,icmov,icmov") |
15842 | (set_attr "mode" "SF,SF,SI,SI")]) | |
56710e42 SC |
15843 | |
15844 | (define_expand "movdfcc" | |
726e2d54 | 15845 | [(set (match_operand:DF 0 "register_operand" "") |
56710e42 | 15846 | (if_then_else:DF (match_operand 1 "comparison_operator" "") |
e5e809f4 JL |
15847 | (match_operand:DF 2 "register_operand" "") |
15848 | (match_operand:DF 3 "register_operand" "")))] | |
726e2d54 | 15849 | "TARGET_CMOVE" |
e075ae69 | 15850 | "if (! ix86_expand_fp_movcc (operands)) FAIL; DONE;") |
726e2d54 | 15851 | |
6343a50e | 15852 | (define_insn "*movdfcc_1" |
7093c9ea | 15853 | [(set (match_operand:DF 0 "register_operand" "=f,f,&r,&r") |
e075ae69 RH |
15854 | (if_then_else:DF (match_operator 1 "fcmov_comparison_operator" |
15855 | [(reg 17) (const_int 0)]) | |
7093c9ea JH |
15856 | (match_operand:DF 2 "nonimmediate_operand" "f,0,rm,0") |
15857 | (match_operand:DF 3 "nonimmediate_operand" "0,f,0,rm")))] | |
1b0c37d7 | 15858 | "!TARGET_64BIT && TARGET_CMOVE |
7093c9ea | 15859 | && (GET_CODE (operands[2]) != MEM || GET_CODE (operands[3]) != MEM)" |
e075ae69 | 15860 | "@ |
0f40f9f7 ZW |
15861 | fcmov%F1\t{%2, %0|%0, %2} |
15862 | fcmov%f1\t{%3, %0|%0, %3} | |
7093c9ea JH |
15863 | # |
15864 | #" | |
15865 | [(set_attr "type" "fcmov,fcmov,multi,multi") | |
6ef67412 | 15866 | (set_attr "mode" "DF")]) |
56710e42 | 15867 | |
1e07edd3 JH |
15868 | (define_insn "*movdfcc_1_rex64" |
15869 | [(set (match_operand:DF 0 "register_operand" "=f,f,&r,&r") | |
15870 | (if_then_else:DF (match_operator 1 "fcmov_comparison_operator" | |
15871 | [(reg 17) (const_int 0)]) | |
15872 | (match_operand:DF 2 "nonimmediate_operand" "f,0,rm,0") | |
15873 | (match_operand:DF 3 "nonimmediate_operand" "0,f,0,rm")))] | |
1b0c37d7 | 15874 | "TARGET_64BIT && TARGET_CMOVE |
1e07edd3 JH |
15875 | && (GET_CODE (operands[2]) != MEM || GET_CODE (operands[3]) != MEM)" |
15876 | "@ | |
0f40f9f7 ZW |
15877 | fcmov%F1\t{%2, %0|%0, %2} |
15878 | fcmov%f1\t{%3, %0|%0, %3} | |
15879 | cmov%C1\t{%2, %0|%0, %2} | |
15880 | cmov%c1\t{%3, %0|%0, %3}" | |
1e07edd3 JH |
15881 | [(set_attr "type" "fcmov,fcmov,icmov,icmov") |
15882 | (set_attr "mode" "DF")]) | |
15883 | ||
7093c9ea JH |
15884 | (define_split |
15885 | [(set (match_operand:DF 0 "register_operand" "") | |
15886 | (if_then_else:DF (match_operator 1 "fcmov_comparison_operator" | |
15887 | [(match_operand 4 "" "") (const_int 0)]) | |
15888 | (match_operand:DF 2 "nonimmediate_operand" "") | |
15889 | (match_operand:DF 3 "nonimmediate_operand" "")))] | |
1b0c37d7 | 15890 | "!TARGET_64BIT && !ANY_FP_REG_P (operands[0]) && reload_completed" |
7093c9ea JH |
15891 | [(set (match_dup 2) |
15892 | (if_then_else:SI (match_op_dup 1 [(match_dup 4) (const_int 0)]) | |
15893 | (match_dup 5) | |
15894 | (match_dup 7))) | |
15895 | (set (match_dup 3) | |
15896 | (if_then_else:SI (match_op_dup 1 [(match_dup 4) (const_int 0)]) | |
15897 | (match_dup 6) | |
15898 | (match_dup 8)))] | |
15899 | "split_di (operands+2, 1, operands+5, operands+6); | |
15900 | split_di (operands+3, 1, operands+7, operands+8); | |
15901 | split_di (operands, 1, operands+2, operands+3);") | |
15902 | ||
56710e42 | 15903 | (define_expand "movxfcc" |
726e2d54 | 15904 | [(set (match_operand:XF 0 "register_operand" "") |
56710e42 | 15905 | (if_then_else:XF (match_operand 1 "comparison_operator" "") |
e5e809f4 JL |
15906 | (match_operand:XF 2 "register_operand" "") |
15907 | (match_operand:XF 3 "register_operand" "")))] | |
1b0c37d7 | 15908 | "!TARGET_64BIT && TARGET_CMOVE" |
e075ae69 | 15909 | "if (! ix86_expand_fp_movcc (operands)) FAIL; DONE;") |
726e2d54 | 15910 | |
2b589241 JH |
15911 | (define_expand "movtfcc" |
15912 | [(set (match_operand:TF 0 "register_operand" "") | |
15913 | (if_then_else:TF (match_operand 1 "comparison_operator" "") | |
15914 | (match_operand:TF 2 "register_operand" "") | |
15915 | (match_operand:TF 3 "register_operand" "")))] | |
15916 | "TARGET_CMOVE" | |
15917 | "if (! ix86_expand_fp_movcc (operands)) FAIL; DONE;") | |
15918 | ||
6343a50e | 15919 | (define_insn "*movxfcc_1" |
3aeae608 | 15920 | [(set (match_operand:XF 0 "register_operand" "=f,f") |
e075ae69 RH |
15921 | (if_then_else:XF (match_operator 1 "fcmov_comparison_operator" |
15922 | [(reg 17) (const_int 0)]) | |
3aeae608 JW |
15923 | (match_operand:XF 2 "register_operand" "f,0") |
15924 | (match_operand:XF 3 "register_operand" "0,f")))] | |
1b0c37d7 | 15925 | "!TARGET_64BIT && TARGET_CMOVE" |
e075ae69 | 15926 | "@ |
0f40f9f7 ZW |
15927 | fcmov%F1\t{%2, %0|%0, %2} |
15928 | fcmov%f1\t{%3, %0|%0, %3}" | |
6ef67412 JH |
15929 | [(set_attr "type" "fcmov") |
15930 | (set_attr "mode" "XF")]) | |
2b589241 JH |
15931 | |
15932 | (define_insn "*movtfcc_1" | |
15933 | [(set (match_operand:TF 0 "register_operand" "=f,f") | |
15934 | (if_then_else:TF (match_operator 1 "fcmov_comparison_operator" | |
15935 | [(reg 17) (const_int 0)]) | |
15936 | (match_operand:TF 2 "register_operand" "f,0") | |
15937 | (match_operand:TF 3 "register_operand" "0,f")))] | |
15938 | "TARGET_CMOVE" | |
15939 | "@ | |
0f40f9f7 ZW |
15940 | fcmov%F1\t{%2, %0|%0, %2} |
15941 | fcmov%f1\t{%3, %0|%0, %3}" | |
2b589241 JH |
15942 | [(set_attr "type" "fcmov") |
15943 | (set_attr "mode" "XF")]) | |
7ada6625 JH |
15944 | |
15945 | (define_expand "minsf3" | |
15946 | [(parallel [ | |
15947 | (set (match_operand:SF 0 "register_operand" "") | |
15948 | (if_then_else:SF (lt (match_operand:SF 1 "register_operand" "") | |
15949 | (match_operand:SF 2 "nonimmediate_operand" "")) | |
15950 | (match_dup 1) | |
15951 | (match_dup 2))) | |
15952 | (clobber (reg:CC 17))])] | |
15953 | "TARGET_SSE" | |
15954 | "") | |
15955 | ||
15956 | (define_insn "*minsf" | |
15957 | [(set (match_operand:SF 0 "register_operand" "=x#f,f#x,f#x") | |
15958 | (if_then_else:SF (lt (match_operand:SF 1 "register_operand" "0,0,f#x") | |
15959 | (match_operand:SF 2 "nonimmediate_operand" "xm#f,f#x,0")) | |
15960 | (match_dup 1) | |
15961 | (match_dup 2))) | |
15962 | (clobber (reg:CC 17))] | |
15963 | "TARGET_SSE && TARGET_IEEE_FP" | |
15964 | "#") | |
15965 | ||
15966 | (define_insn "*minsf_nonieee" | |
15967 | [(set (match_operand:SF 0 "register_operand" "=x#f,f#x") | |
15968 | (if_then_else:SF (lt (match_operand:SF 1 "register_operand" "%0,0") | |
3987b9db | 15969 | (match_operand:SF 2 "nonimmediate_operand" "xm#f,f#x")) |
7ada6625 JH |
15970 | (match_dup 1) |
15971 | (match_dup 2))) | |
15972 | (clobber (reg:CC 17))] | |
15973 | "TARGET_SSE && !TARGET_IEEE_FP" | |
15974 | "#") | |
15975 | ||
15976 | (define_split | |
15977 | [(set (match_operand:SF 0 "register_operand" "") | |
15978 | (if_then_else:SF (lt (match_operand:SF 1 "register_operand" "") | |
15979 | (match_operand:SF 2 "nonimmediate_operand" "")) | |
138b7342 JH |
15980 | (match_operand:SF 3 "register_operand" "") |
15981 | (match_operand:SF 4 "nonimmediate_operand" ""))) | |
ef6257cd JH |
15982 | (clobber (reg:CC 17))] |
15983 | "SSE_REG_P (operands[0]) && reload_completed | |
15984 | && ((operands_match_p (operands[1], operands[3]) | |
15985 | && operands_match_p (operands[2], operands[4])) | |
15986 | || (operands_match_p (operands[1], operands[4]) | |
15987 | && operands_match_p (operands[2], operands[3])))" | |
7ada6625 JH |
15988 | [(set (match_dup 0) |
15989 | (if_then_else:SF (lt (match_dup 1) | |
15990 | (match_dup 2)) | |
15991 | (match_dup 1) | |
15992 | (match_dup 2)))]) | |
15993 | ||
15994 | ;; We can't represent the LT test directly. Do this by swapping the operands. | |
ef6257cd | 15995 | |
7ada6625 JH |
15996 | (define_split |
15997 | [(set (match_operand:SF 0 "register_operand" "") | |
15998 | (if_then_else:SF (lt (match_operand:SF 1 "register_operand" "") | |
15999 | (match_operand:SF 2 "register_operand" "")) | |
ef6257cd JH |
16000 | (match_operand:DF 3 "register_operand" "") |
16001 | (match_operand:DF 4 "register_operand" ""))) | |
16002 | (clobber (reg:CC 17))] | |
16003 | "FP_REG_P (operands[0]) && reload_completed | |
16004 | && ((operands_match_p (operands[1], operands[3]) | |
16005 | && operands_match_p (operands[2], operands[4])) | |
16006 | || (operands_match_p (operands[1], operands[4]) | |
16007 | && operands_match_p (operands[2], operands[3])))" | |
7ada6625 JH |
16008 | [(set (reg:CCFP 17) |
16009 | (compare:CCFP (match_dup 2) | |
16010 | (match_dup 1))) | |
16011 | (set (match_dup 0) | |
16012 | (if_then_else:SF (ge (reg:CCFP 17) (const_int 0)) | |
16013 | (match_dup 1) | |
16014 | (match_dup 2)))]) | |
16015 | ||
16016 | (define_insn "*minsf_sse" | |
16017 | [(set (match_operand:SF 0 "register_operand" "=x") | |
16018 | (if_then_else:SF (lt (match_operand:SF 1 "register_operand" "0") | |
16019 | (match_operand:SF 2 "nonimmediate_operand" "xm")) | |
16020 | (match_dup 1) | |
16021 | (match_dup 2)))] | |
16022 | "TARGET_SSE && reload_completed" | |
0f40f9f7 | 16023 | "minss\t{%2, %0|%0, %2}" |
7ada6625 JH |
16024 | [(set_attr "type" "sse") |
16025 | (set_attr "mode" "SF")]) | |
16026 | ||
16027 | (define_expand "mindf3" | |
16028 | [(parallel [ | |
16029 | (set (match_operand:DF 0 "register_operand" "") | |
16030 | (if_then_else:DF (lt (match_operand:DF 1 "register_operand" "") | |
16031 | (match_operand:DF 2 "nonimmediate_operand" "")) | |
16032 | (match_dup 1) | |
16033 | (match_dup 2))) | |
16034 | (clobber (reg:CC 17))])] | |
965f5423 | 16035 | "TARGET_SSE2 && TARGET_SSE_MATH" |
7ada6625 JH |
16036 | "#") |
16037 | ||
16038 | (define_insn "*mindf" | |
16039 | [(set (match_operand:DF 0 "register_operand" "=Y#f,f#Y,f#Y") | |
16040 | (if_then_else:DF (lt (match_operand:DF 1 "register_operand" "0,0,f#Y") | |
16041 | (match_operand:DF 2 "nonimmediate_operand" "Ym#f,f#Y,0")) | |
16042 | (match_dup 1) | |
16043 | (match_dup 2))) | |
16044 | (clobber (reg:CC 17))] | |
965f5423 | 16045 | "TARGET_SSE2 && TARGET_IEEE_FP && TARGET_SSE_MATH" |
7ada6625 JH |
16046 | "#") |
16047 | ||
16048 | (define_insn "*mindf_nonieee" | |
16049 | [(set (match_operand:DF 0 "register_operand" "=Y#f,f#Y") | |
16050 | (if_then_else:DF (lt (match_operand:DF 1 "register_operand" "%0,0") | |
3987b9db | 16051 | (match_operand:DF 2 "nonimmediate_operand" "Ym#f,f#Y")) |
7ada6625 JH |
16052 | (match_dup 1) |
16053 | (match_dup 2))) | |
16054 | (clobber (reg:CC 17))] | |
965f5423 | 16055 | "TARGET_SSE2 && TARGET_SSE_MATH && !TARGET_IEEE_FP" |
7ada6625 JH |
16056 | "#") |
16057 | ||
16058 | (define_split | |
16059 | [(set (match_operand:DF 0 "register_operand" "") | |
16060 | (if_then_else:DF (lt (match_operand:DF 1 "register_operand" "") | |
16061 | (match_operand:DF 2 "nonimmediate_operand" "")) | |
ef6257cd JH |
16062 | (match_operand:DF 3 "register_operand" "") |
16063 | (match_operand:DF 4 "nonimmediate_operand" ""))) | |
16064 | (clobber (reg:CC 17))] | |
16065 | "SSE_REG_P (operands[0]) && reload_completed | |
16066 | && ((operands_match_p (operands[1], operands[3]) | |
16067 | && operands_match_p (operands[2], operands[4])) | |
16068 | || (operands_match_p (operands[1], operands[4]) | |
16069 | && operands_match_p (operands[2], operands[3])))" | |
7ada6625 JH |
16070 | [(set (match_dup 0) |
16071 | (if_then_else:DF (lt (match_dup 1) | |
16072 | (match_dup 2)) | |
16073 | (match_dup 1) | |
16074 | (match_dup 2)))]) | |
16075 | ||
16076 | ;; We can't represent the LT test directly. Do this by swapping the operands. | |
16077 | (define_split | |
16078 | [(set (match_operand:DF 0 "register_operand" "") | |
16079 | (if_then_else:DF (lt (match_operand:DF 1 "register_operand" "") | |
16080 | (match_operand:DF 2 "register_operand" "")) | |
ef6257cd JH |
16081 | (match_operand:DF 3 "register_operand" "") |
16082 | (match_operand:DF 4 "register_operand" ""))) | |
16083 | (clobber (reg:CC 17))] | |
16084 | "FP_REG_P (operands[0]) && reload_completed | |
16085 | && ((operands_match_p (operands[1], operands[3]) | |
16086 | && operands_match_p (operands[2], operands[4])) | |
16087 | || (operands_match_p (operands[1], operands[4]) | |
16088 | && operands_match_p (operands[2], operands[3])))" | |
7ada6625 JH |
16089 | [(set (reg:CCFP 17) |
16090 | (compare:CCFP (match_dup 2) | |
16091 | (match_dup 2))) | |
16092 | (set (match_dup 0) | |
16093 | (if_then_else:DF (ge (reg:CCFP 17) (const_int 0)) | |
16094 | (match_dup 1) | |
16095 | (match_dup 2)))]) | |
16096 | ||
16097 | (define_insn "*mindf_sse" | |
16098 | [(set (match_operand:DF 0 "register_operand" "=Y") | |
16099 | (if_then_else:DF (lt (match_operand:DF 1 "register_operand" "0") | |
16100 | (match_operand:DF 2 "nonimmediate_operand" "Ym")) | |
16101 | (match_dup 1) | |
16102 | (match_dup 2)))] | |
965f5423 | 16103 | "TARGET_SSE2 && TARGET_SSE_MATH && reload_completed" |
0f40f9f7 | 16104 | "minsd\t{%2, %0|%0, %2}" |
7ada6625 JH |
16105 | [(set_attr "type" "sse") |
16106 | (set_attr "mode" "DF")]) | |
16107 | ||
16108 | (define_expand "maxsf3" | |
16109 | [(parallel [ | |
16110 | (set (match_operand:SF 0 "register_operand" "") | |
16111 | (if_then_else:SF (gt (match_operand:SF 1 "register_operand" "") | |
16112 | (match_operand:SF 2 "nonimmediate_operand" "")) | |
16113 | (match_dup 1) | |
16114 | (match_dup 2))) | |
16115 | (clobber (reg:CC 17))])] | |
16116 | "TARGET_SSE" | |
16117 | "#") | |
16118 | ||
16119 | (define_insn "*maxsf" | |
16120 | [(set (match_operand:SF 0 "register_operand" "=x#f,f#x,f#x") | |
16121 | (if_then_else:SF (gt (match_operand:SF 1 "register_operand" "0,0,f#x") | |
3987b9db | 16122 | (match_operand:SF 2 "nonimmediate_operand" "xm#f,f#x,0")) |
7ada6625 JH |
16123 | (match_dup 1) |
16124 | (match_dup 2))) | |
16125 | (clobber (reg:CC 17))] | |
16126 | "TARGET_SSE && TARGET_IEEE_FP" | |
16127 | "#") | |
16128 | ||
16129 | (define_insn "*maxsf_nonieee" | |
16130 | [(set (match_operand:SF 0 "register_operand" "=x#f,f#x") | |
16131 | (if_then_else:SF (gt (match_operand:SF 1 "register_operand" "%0,0") | |
3987b9db | 16132 | (match_operand:SF 2 "nonimmediate_operand" "xm#f,f#x")) |
7ada6625 JH |
16133 | (match_dup 1) |
16134 | (match_dup 2))) | |
16135 | (clobber (reg:CC 17))] | |
16136 | "TARGET_SSE && !TARGET_IEEE_FP" | |
16137 | "#") | |
16138 | ||
16139 | (define_split | |
16140 | [(set (match_operand:SF 0 "register_operand" "") | |
16141 | (if_then_else:SF (gt (match_operand:SF 1 "register_operand" "") | |
16142 | (match_operand:SF 2 "nonimmediate_operand" "")) | |
ef6257cd JH |
16143 | (match_operand:SF 3 "register_operand" "") |
16144 | (match_operand:SF 4 "nonimmediate_operand" ""))) | |
16145 | (clobber (reg:CC 17))] | |
16146 | "SSE_REG_P (operands[0]) && reload_completed | |
16147 | && ((operands_match_p (operands[1], operands[3]) | |
16148 | && operands_match_p (operands[2], operands[4])) | |
16149 | || (operands_match_p (operands[1], operands[4]) | |
16150 | && operands_match_p (operands[2], operands[3])))" | |
7ada6625 JH |
16151 | [(set (match_dup 0) |
16152 | (if_then_else:SF (gt (match_dup 1) | |
16153 | (match_dup 2)) | |
16154 | (match_dup 1) | |
16155 | (match_dup 2)))]) | |
16156 | ||
16157 | (define_split | |
16158 | [(set (match_operand:SF 0 "register_operand" "") | |
16159 | (if_then_else:SF (gt (match_operand:SF 1 "register_operand" "") | |
16160 | (match_operand:SF 2 "register_operand" "")) | |
ef6257cd JH |
16161 | (match_operand:SF 3 "register_operand" "") |
16162 | (match_operand:SF 4 "register_operand" ""))) | |
16163 | (clobber (reg:CC 17))] | |
16164 | "FP_REG_P (operands[0]) && reload_completed | |
16165 | && ((operands_match_p (operands[1], operands[3]) | |
16166 | && operands_match_p (operands[2], operands[4])) | |
16167 | || (operands_match_p (operands[1], operands[4]) | |
16168 | && operands_match_p (operands[2], operands[3])))" | |
7ada6625 JH |
16169 | [(set (reg:CCFP 17) |
16170 | (compare:CCFP (match_dup 1) | |
16171 | (match_dup 2))) | |
16172 | (set (match_dup 0) | |
16173 | (if_then_else:SF (gt (reg:CCFP 17) (const_int 0)) | |
16174 | (match_dup 1) | |
16175 | (match_dup 2)))]) | |
16176 | ||
16177 | (define_insn "*maxsf_sse" | |
16178 | [(set (match_operand:SF 0 "register_operand" "=x") | |
16179 | (if_then_else:SF (gt (match_operand:SF 1 "register_operand" "0") | |
16180 | (match_operand:SF 2 "nonimmediate_operand" "xm")) | |
16181 | (match_dup 1) | |
16182 | (match_dup 2)))] | |
16183 | "TARGET_SSE && reload_completed" | |
0f40f9f7 | 16184 | "maxss\t{%2, %0|%0, %2}" |
7ada6625 JH |
16185 | [(set_attr "type" "sse") |
16186 | (set_attr "mode" "SF")]) | |
16187 | ||
16188 | (define_expand "maxdf3" | |
16189 | [(parallel [ | |
16190 | (set (match_operand:DF 0 "register_operand" "") | |
16191 | (if_then_else:DF (gt (match_operand:DF 1 "register_operand" "") | |
16192 | (match_operand:DF 2 "nonimmediate_operand" "")) | |
16193 | (match_dup 1) | |
16194 | (match_dup 2))) | |
16195 | (clobber (reg:CC 17))])] | |
965f5423 | 16196 | "TARGET_SSE2 && TARGET_SSE_MATH" |
7ada6625 JH |
16197 | "#") |
16198 | ||
16199 | (define_insn "*maxdf" | |
16200 | [(set (match_operand:DF 0 "register_operand" "=Y#f,f#Y,f#Y") | |
16201 | (if_then_else:DF (gt (match_operand:DF 1 "register_operand" "0,0,f#Y") | |
3987b9db | 16202 | (match_operand:DF 2 "nonimmediate_operand" "Ym#f,f#Y,0")) |
7ada6625 JH |
16203 | (match_dup 1) |
16204 | (match_dup 2))) | |
16205 | (clobber (reg:CC 17))] | |
965f5423 | 16206 | "TARGET_SSE2 && TARGET_SSE_MATH && TARGET_IEEE_FP" |
7ada6625 JH |
16207 | "#") |
16208 | ||
16209 | (define_insn "*maxdf_nonieee" | |
16210 | [(set (match_operand:DF 0 "register_operand" "=Y#f,f#Y") | |
16211 | (if_then_else:DF (gt (match_operand:DF 1 "register_operand" "%0,0") | |
3987b9db | 16212 | (match_operand:DF 2 "nonimmediate_operand" "Ym#f,f#Y")) |
7ada6625 JH |
16213 | (match_dup 1) |
16214 | (match_dup 2))) | |
16215 | (clobber (reg:CC 17))] | |
965f5423 | 16216 | "TARGET_SSE2 && TARGET_SSE_MATH && !TARGET_IEEE_FP" |
7ada6625 JH |
16217 | "#") |
16218 | ||
16219 | (define_split | |
16220 | [(set (match_operand:DF 0 "register_operand" "") | |
16221 | (if_then_else:DF (gt (match_operand:DF 1 "register_operand" "") | |
16222 | (match_operand:DF 2 "nonimmediate_operand" "")) | |
ef6257cd JH |
16223 | (match_operand:DF 3 "register_operand" "") |
16224 | (match_operand:DF 4 "nonimmediate_operand" ""))) | |
16225 | (clobber (reg:CC 17))] | |
16226 | "SSE_REG_P (operands[0]) && reload_completed | |
16227 | && ((operands_match_p (operands[1], operands[3]) | |
16228 | && operands_match_p (operands[2], operands[4])) | |
16229 | || (operands_match_p (operands[1], operands[4]) | |
16230 | && operands_match_p (operands[2], operands[3])))" | |
7ada6625 JH |
16231 | [(set (match_dup 0) |
16232 | (if_then_else:DF (gt (match_dup 1) | |
16233 | (match_dup 2)) | |
16234 | (match_dup 1) | |
16235 | (match_dup 2)))]) | |
16236 | ||
16237 | (define_split | |
16238 | [(set (match_operand:DF 0 "register_operand" "") | |
16239 | (if_then_else:DF (gt (match_operand:DF 1 "register_operand" "") | |
16240 | (match_operand:DF 2 "register_operand" "")) | |
ef6257cd JH |
16241 | (match_operand:DF 3 "register_operand" "") |
16242 | (match_operand:DF 4 "register_operand" ""))) | |
16243 | (clobber (reg:CC 17))] | |
16244 | "FP_REG_P (operands[0]) && reload_completed | |
16245 | && ((operands_match_p (operands[1], operands[3]) | |
16246 | && operands_match_p (operands[2], operands[4])) | |
16247 | || (operands_match_p (operands[1], operands[4]) | |
16248 | && operands_match_p (operands[2], operands[3])))" | |
7ada6625 JH |
16249 | [(set (reg:CCFP 17) |
16250 | (compare:CCFP (match_dup 1) | |
16251 | (match_dup 2))) | |
16252 | (set (match_dup 0) | |
16253 | (if_then_else:DF (gt (reg:CCFP 17) (const_int 0)) | |
16254 | (match_dup 1) | |
16255 | (match_dup 2)))]) | |
16256 | ||
16257 | (define_insn "*maxdf_sse" | |
16258 | [(set (match_operand:DF 0 "register_operand" "=Y") | |
16259 | (if_then_else:DF (gt (match_operand:DF 1 "register_operand" "0") | |
16260 | (match_operand:DF 2 "nonimmediate_operand" "Ym")) | |
16261 | (match_dup 1) | |
16262 | (match_dup 2)))] | |
965f5423 | 16263 | "TARGET_SSE2 && TARGET_SSE_MATH && reload_completed" |
0f40f9f7 | 16264 | "maxsd\t{%2, %0|%0, %2}" |
7ada6625 JH |
16265 | [(set_attr "type" "sse") |
16266 | (set_attr "mode" "DF")]) | |
e075ae69 RH |
16267 | \f |
16268 | ;; Misc patterns (?) | |
726e2d54 | 16269 | |
f5143c46 | 16270 | ;; This pattern exists to put a dependency on all ebp-based memory accesses. |
e075ae69 RH |
16271 | ;; Otherwise there will be nothing to keep |
16272 | ;; | |
16273 | ;; [(set (reg ebp) (reg esp))] | |
16274 | ;; [(set (reg esp) (plus (reg esp) (const_int -160000))) | |
16275 | ;; (clobber (eflags)] | |
16276 | ;; [(set (mem (plus (reg ebp) (const_int -160000))) (const_int 0))] | |
16277 | ;; | |
16278 | ;; in proper program order. | |
8362f420 JH |
16279 | (define_expand "pro_epilogue_adjust_stack" |
16280 | [(parallel [(set (match_operand:SI 0 "register_operand" "=r,r") | |
16281 | (plus:SI (match_operand:SI 1 "register_operand" "0,r") | |
16282 | (match_operand:SI 2 "immediate_operand" "i,i"))) | |
f2042df3 RH |
16283 | (clobber (reg:CC 17)) |
16284 | (clobber (mem:BLK (scratch)))])] | |
8362f420 | 16285 | "" |
8362f420 JH |
16286 | { |
16287 | if (TARGET_64BIT) | |
16288 | { | |
f2042df3 RH |
16289 | emit_insn (gen_pro_epilogue_adjust_stack_rex64 |
16290 | (operands[0], operands[1], operands[2])); | |
8362f420 JH |
16291 | DONE; |
16292 | } | |
0f40f9f7 | 16293 | }) |
726e2d54 | 16294 | |
8362f420 | 16295 | (define_insn "*pro_epilogue_adjust_stack_1" |
1c71e60e JH |
16296 | [(set (match_operand:SI 0 "register_operand" "=r,r") |
16297 | (plus:SI (match_operand:SI 1 "register_operand" "0,r") | |
16298 | (match_operand:SI 2 "immediate_operand" "i,i"))) | |
f2042df3 RH |
16299 | (clobber (reg:CC 17)) |
16300 | (clobber (mem:BLK (scratch)))] | |
8362f420 | 16301 | "!TARGET_64BIT" |
e075ae69 | 16302 | { |
1c71e60e | 16303 | switch (get_attr_type (insn)) |
e075ae69 | 16304 | { |
1c71e60e | 16305 | case TYPE_IMOV: |
0f40f9f7 | 16306 | return "mov{l}\t{%1, %0|%0, %1}"; |
1c71e60e JH |
16307 | |
16308 | case TYPE_ALU: | |
16309 | if (GET_CODE (operands[2]) == CONST_INT | |
16310 | && (INTVAL (operands[2]) == 128 | |
16311 | || (INTVAL (operands[2]) < 0 | |
16312 | && INTVAL (operands[2]) != -128))) | |
16313 | { | |
16314 | operands[2] = GEN_INT (-INTVAL (operands[2])); | |
0f40f9f7 | 16315 | return "sub{l}\t{%2, %0|%0, %2}"; |
1c71e60e | 16316 | } |
0f40f9f7 | 16317 | return "add{l}\t{%2, %0|%0, %2}"; |
1c71e60e JH |
16318 | |
16319 | case TYPE_LEA: | |
16320 | operands[2] = SET_SRC (XVECEXP (PATTERN (insn), 0, 0)); | |
0f40f9f7 | 16321 | return "lea{l}\t{%a2, %0|%0, %a2}"; |
1c71e60e JH |
16322 | |
16323 | default: | |
16324 | abort (); | |
e075ae69 | 16325 | } |
0f40f9f7 | 16326 | } |
1c71e60e JH |
16327 | [(set (attr "type") |
16328 | (cond [(eq_attr "alternative" "0") | |
16329 | (const_string "alu") | |
16330 | (match_operand:SI 2 "const0_operand" "") | |
16331 | (const_string "imov") | |
16332 | ] | |
6ef67412 JH |
16333 | (const_string "lea"))) |
16334 | (set_attr "mode" "SI")]) | |
578b58f5 | 16335 | |
8362f420 JH |
16336 | (define_insn "pro_epilogue_adjust_stack_rex64" |
16337 | [(set (match_operand:DI 0 "register_operand" "=r,r") | |
16338 | (plus:DI (match_operand:DI 1 "register_operand" "0,r") | |
16339 | (match_operand:DI 2 "x86_64_immediate_operand" "e,e"))) | |
f2042df3 RH |
16340 | (clobber (reg:CC 17)) |
16341 | (clobber (mem:BLK (scratch)))] | |
8362f420 | 16342 | "TARGET_64BIT" |
8362f420 JH |
16343 | { |
16344 | switch (get_attr_type (insn)) | |
16345 | { | |
16346 | case TYPE_IMOV: | |
0f40f9f7 | 16347 | return "mov{q}\t{%1, %0|%0, %1}"; |
8362f420 JH |
16348 | |
16349 | case TYPE_ALU: | |
16350 | if (GET_CODE (operands[2]) == CONST_INT | |
16351 | && (INTVAL (operands[2]) == 128 | |
16352 | || (INTVAL (operands[2]) < 0 | |
16353 | && INTVAL (operands[2]) != -128))) | |
16354 | { | |
16355 | operands[2] = GEN_INT (-INTVAL (operands[2])); | |
0f40f9f7 | 16356 | return "sub{q}\t{%2, %0|%0, %2}"; |
8362f420 | 16357 | } |
0f40f9f7 | 16358 | return "add{q}\t{%2, %0|%0, %2}"; |
8362f420 JH |
16359 | |
16360 | case TYPE_LEA: | |
16361 | operands[2] = SET_SRC (XVECEXP (PATTERN (insn), 0, 0)); | |
0f40f9f7 | 16362 | return "lea{q}\t{%a2, %0|%0, %a2}"; |
8362f420 JH |
16363 | |
16364 | default: | |
16365 | abort (); | |
16366 | } | |
0f40f9f7 | 16367 | } |
8362f420 JH |
16368 | [(set (attr "type") |
16369 | (cond [(eq_attr "alternative" "0") | |
16370 | (const_string "alu") | |
16371 | (match_operand:DI 2 "const0_operand" "") | |
16372 | (const_string "imov") | |
16373 | ] | |
16374 | (const_string "lea"))) | |
16375 | (set_attr "mode" "DI")]) | |
16376 | ||
16377 | ||
d6a7951f | 16378 | ;; Placeholder for the conditional moves. This one is split either to SSE |
0073023d JH |
16379 | ;; based moves emulation or to usual cmove sequence. Little bit unfortunate |
16380 | ;; fact is that compares supported by the cmp??ss instructions are exactly | |
16381 | ;; swapped of those supported by cmove sequence. | |
fa9f36a1 JH |
16382 | ;; The EQ/NE comparisons also needs bit care, since they are not directly |
16383 | ;; supported by i387 comparisons and we do need to emit two conditional moves | |
16384 | ;; in tandem. | |
0073023d JH |
16385 | |
16386 | (define_insn "sse_movsfcc" | |
16387 | [(set (match_operand:SF 0 "register_operand" "=&x#rf,x#rf,?f#xr,?f#xr,?f#xr,?f#xr,?r#xf,?r#xf,?r#xf,?r#xf") | |
16388 | (if_then_else:SF (match_operator 1 "sse_comparison_operator" | |
16389 | [(match_operand:SF 4 "nonimmediate_operand" "0#fx,x#fx,f#x,f#x,xm#f,xm#f,f#x,f#x,xm#f,xm#f") | |
16390 | (match_operand:SF 5 "nonimmediate_operand" "xm#f,xm#f,f#x,f#x,x#f,x#f,f#x,f#x,x#f,x#f")]) | |
16391 | (match_operand:SF 2 "nonimmediate_operand" "x#fr,0#fr,f#fx,0#fx,f#fx,0#fx,rm#rx,0#rx,rm#rx,0#rx") | |
16392 | (match_operand:SF 3 "nonimmediate_operand" "x#fr,x#fr,0#fx,f#fx,0#fx,f#fx,0#fx,rm#rx,0#rx,rm#rx"))) | |
bf71a4f8 | 16393 | (clobber (match_scratch:SF 6 "=2,&4,X,X,X,X,X,X,X,X")) |
0073023d | 16394 | (clobber (reg:CC 17))] |
fa9f36a1 JH |
16395 | "TARGET_SSE |
16396 | && (GET_CODE (operands[2]) != MEM || GET_CODE (operands[3]) != MEM) | |
16397 | && (!TARGET_IEEE_FP | |
16398 | || (GET_CODE (operands[1]) != EQ && GET_CODE (operands[1]) != NE))" | |
16399 | "#") | |
16400 | ||
16401 | (define_insn "sse_movsfcc_eq" | |
16402 | [(set (match_operand:SF 0 "register_operand" "=&x#rf,x#rf,?f#xr,?f#xr,?r#xf,?r#xf") | |
16403 | (if_then_else:SF (eq (match_operand:SF 3 "nonimmediate_operand" "%0#fx,x#fx,f#x,xm#f,f#x,xm#f") | |
16404 | (match_operand:SF 4 "nonimmediate_operand" "xm#f,xm#f,f#x,x#f,f#x,x#f")) | |
16405 | (match_operand:SF 1 "nonimmediate_operand" "x#fr,0#fr,0#fx,0#fx,0#rx,0#rx") | |
16406 | (match_operand:SF 2 "nonimmediate_operand" "x#fr,x#fr,f#fx,f#fx,rm#rx,rm#rx"))) | |
f021d6fc | 16407 | (clobber (match_scratch:SF 5 "=1,&3,X,X,X,X")) |
fa9f36a1 | 16408 | (clobber (reg:CC 17))] |
0073023d JH |
16409 | "TARGET_SSE |
16410 | && (GET_CODE (operands[2]) != MEM || GET_CODE (operands[3]) != MEM)" | |
16411 | "#") | |
16412 | ||
16413 | (define_insn "sse_movdfcc" | |
16414 | [(set (match_operand:DF 0 "register_operand" "=&x#rf,x#rf,?f#xr,?f#xr,?f#xr,?f#xr,?r#xf,?r#xf,?r#xf,?r#xf") | |
16415 | (if_then_else:DF (match_operator 1 "sse_comparison_operator" | |
16416 | [(match_operand:DF 4 "nonimmediate_operand" "0#fx,x#fx,f#x,f#x,xm#f,xm#f,f#x,f#x,xm#f,xm#f") | |
16417 | (match_operand:DF 5 "nonimmediate_operand" "xm#f,xm#f,f#x,f#x,x#f,x#f,f#x,f#x,x#f,x#f")]) | |
16418 | (match_operand:DF 2 "nonimmediate_operand" "x#fr,0#fr,f#fx,0#fx,f#fx,0#fx,rm#rx,0#rx,rm#rx,0#rx") | |
16419 | (match_operand:DF 3 "nonimmediate_operand" "x#fr,x#fr,0#fx,f#fx,0#fx,f#fx,0#fx,rm#rx,0#rx,rm#rx"))) | |
bf71a4f8 | 16420 | (clobber (match_scratch:DF 6 "=2,&4,X,X,X,X,X,X,X,X")) |
0073023d JH |
16421 | (clobber (reg:CC 17))] |
16422 | "TARGET_SSE2 | |
fa9f36a1 JH |
16423 | && (GET_CODE (operands[2]) != MEM || GET_CODE (operands[3]) != MEM) |
16424 | && (!TARGET_IEEE_FP | |
16425 | || (GET_CODE (operands[1]) != EQ && GET_CODE (operands[1]) != NE))" | |
16426 | "#") | |
16427 | ||
16428 | (define_insn "sse_movdfcc_eq" | |
16429 | [(set (match_operand:DF 0 "register_operand" "=&x#rf,x#rf,?f#xr,?f#xr,?r#xf,?r#xf") | |
16430 | (if_then_else:DF (eq (match_operand:DF 3 "nonimmediate_operand" "%0#fx,x#fx,f#x,xm#f,f#x,xm#f") | |
16431 | (match_operand:DF 4 "nonimmediate_operand" "xm#f,xm#f,f#x,x#f,f#x,x#f")) | |
16432 | (match_operand:DF 1 "nonimmediate_operand" "x#fr,0#fr,0#fx,0#fx,0#rx,0#rx") | |
16433 | (match_operand:DF 2 "nonimmediate_operand" "x#fr,x#fr,f#fx,f#fx,rm#rx,rm#rx"))) | |
16434 | (clobber (match_scratch:DF 5 "=1,&3,X,X,X,X")) | |
16435 | (clobber (reg:CC 17))] | |
16436 | "TARGET_SSE | |
0073023d JH |
16437 | && (GET_CODE (operands[2]) != MEM || GET_CODE (operands[3]) != MEM)" |
16438 | "#") | |
16439 | ||
16440 | ;; For non-sse moves just expand the usual cmove sequence. | |
16441 | (define_split | |
16442 | [(set (match_operand 0 "register_operand" "") | |
16443 | (if_then_else (match_operator 1 "comparison_operator" | |
16444 | [(match_operand 4 "nonimmediate_operand" "") | |
16445 | (match_operand 5 "register_operand" "")]) | |
16446 | (match_operand 2 "nonimmediate_operand" "") | |
16447 | (match_operand 3 "nonimmediate_operand" ""))) | |
16448 | (clobber (match_operand 6 "" "")) | |
16449 | (clobber (reg:CC 17))] | |
16450 | "!SSE_REG_P (operands[0]) && reload_completed | |
16451 | && VALID_SSE_REG_MODE (GET_MODE (operands[0]))" | |
16452 | [(const_int 0)] | |
0073023d JH |
16453 | { |
16454 | ix86_compare_op0 = operands[5]; | |
16455 | ix86_compare_op1 = operands[4]; | |
16456 | operands[1] = gen_rtx_fmt_ee (swap_condition (GET_CODE (operands[1])), | |
16457 | VOIDmode, operands[5], operands[4]); | |
16458 | ix86_expand_fp_movcc (operands); | |
16459 | DONE; | |
0f40f9f7 | 16460 | }) |
0073023d JH |
16461 | |
16462 | ;; Split SSE based conditional move into seqence: | |
16463 | ;; cmpCC op0, op4 - set op0 to 0 or ffffffff depending on the comparison | |
16464 | ;; and op2, op0 - zero op2 if comparison was false | |
16465 | ;; nand op0, op3 - load op3 to op0 if comparison was false | |
16466 | ;; or op2, op0 - get the non-zero one into the result. | |
16467 | (define_split | |
16468 | [(set (match_operand 0 "register_operand" "") | |
16469 | (if_then_else (match_operator 1 "sse_comparison_operator" | |
16470 | [(match_operand 4 "register_operand" "") | |
16471 | (match_operand 5 "nonimmediate_operand" "")]) | |
16472 | (match_operand 2 "register_operand" "") | |
16473 | (match_operand 3 "register_operand" ""))) | |
bf71a4f8 | 16474 | (clobber (match_operand 6 "" "")) |
0073023d JH |
16475 | (clobber (reg:CC 17))] |
16476 | "SSE_REG_P (operands[0]) && reload_completed" | |
16477 | [(set (match_dup 4) (match_op_dup 1 [(match_dup 4) (match_dup 5)])) | |
16478 | (set (subreg:TI (match_dup 2) 0) (and:TI (subreg:TI (match_dup 2) 0) | |
f021d6fc JH |
16479 | (subreg:TI (match_dup 4) 0))) |
16480 | (set (subreg:TI (match_dup 4) 0) (and:TI (not:TI (subreg:TI (match_dup 4) 0)) | |
0073023d JH |
16481 | (subreg:TI (match_dup 3) 0))) |
16482 | (set (subreg:TI (match_dup 0) 0) (ior:TI (subreg:TI (match_dup 6) 0) | |
16483 | (subreg:TI (match_dup 7) 0)))] | |
0073023d JH |
16484 | { |
16485 | PUT_MODE (operands[1], GET_MODE (operands[0])); | |
f021d6fc | 16486 | if (operands_match_p (operands[0], operands[4])) |
0073023d JH |
16487 | operands[6] = operands[4], operands[7] = operands[2]; |
16488 | else | |
f021d6fc | 16489 | operands[6] = operands[2], operands[7] = operands[4]; |
0f40f9f7 | 16490 | }) |
0073023d JH |
16491 | |
16492 | ;; Special case of conditional move we can handle effectivly. | |
16493 | ;; Do not brother with the integer/floating point case, since these are | |
16494 | ;; bot considerably slower, unlike in the generic case. | |
16495 | (define_insn "*sse_movsfcc_const0_1" | |
16496 | [(set (match_operand:SF 0 "register_operand" "=x") | |
16497 | (if_then_else:SF (match_operator 1 "sse_comparison_operator" | |
16498 | [(match_operand:SF 4 "register_operand" "0") | |
16499 | (match_operand:SF 5 "nonimmediate_operand" "xm")]) | |
16500 | (match_operand:SF 2 "register_operand" "x") | |
16501 | (match_operand:SF 3 "const0_operand" "X")))] | |
16502 | "TARGET_SSE" | |
16503 | "#") | |
16504 | ||
16505 | (define_insn "*sse_movsfcc_const0_2" | |
16506 | [(set (match_operand:SF 0 "register_operand" "=x") | |
16507 | (if_then_else:SF (match_operator 1 "sse_comparison_operator" | |
16508 | [(match_operand:SF 4 "register_operand" "0") | |
16509 | (match_operand:SF 5 "nonimmediate_operand" "xm")]) | |
adc7fcb8 JH |
16510 | (match_operand:SF 2 "const0_operand" "X") |
16511 | (match_operand:SF 3 "register_operand" "x")))] | |
0073023d JH |
16512 | "TARGET_SSE" |
16513 | "#") | |
16514 | ||
16515 | (define_insn "*sse_movsfcc_const0_3" | |
16516 | [(set (match_operand:SF 0 "register_operand" "=x") | |
16517 | (if_then_else:SF (match_operator 1 "fcmov_comparison_operator" | |
16518 | [(match_operand:SF 4 "nonimmediate_operand" "xm") | |
16519 | (match_operand:SF 5 "register_operand" "0")]) | |
16520 | (match_operand:SF 2 "register_operand" "x") | |
16521 | (match_operand:SF 3 "const0_operand" "X")))] | |
16522 | "TARGET_SSE" | |
16523 | "#") | |
16524 | ||
16525 | (define_insn "*sse_movsfcc_const0_4" | |
16526 | [(set (match_operand:SF 0 "register_operand" "=x") | |
16527 | (if_then_else:SF (match_operator 1 "fcmov_comparison_operator" | |
16528 | [(match_operand:SF 4 "nonimmediate_operand" "xm") | |
16529 | (match_operand:SF 5 "register_operand" "0")]) | |
adc7fcb8 JH |
16530 | (match_operand:SF 2 "const0_operand" "X") |
16531 | (match_operand:SF 3 "register_operand" "x")))] | |
0073023d JH |
16532 | "TARGET_SSE" |
16533 | "#") | |
16534 | ||
16535 | (define_insn "*sse_movdfcc_const0_1" | |
16536 | [(set (match_operand:SF 0 "register_operand" "=x") | |
16537 | (if_then_else:SF (match_operator 1 "sse_comparison_operator" | |
16538 | [(match_operand:SF 4 "register_operand" "0") | |
16539 | (match_operand:SF 5 "nonimmediate_operand" "xm")]) | |
16540 | (match_operand:SF 2 "register_operand" "x") | |
16541 | (match_operand:SF 3 "const0_operand" "X")))] | |
16542 | "TARGET_SSE2" | |
16543 | "#") | |
16544 | ||
16545 | (define_insn "*sse_movdfcc_const0_2" | |
16546 | [(set (match_operand:SF 0 "register_operand" "=x") | |
16547 | (if_then_else:SF (match_operator 1 "sse_comparison_operator" | |
16548 | [(match_operand:SF 4 "register_operand" "0") | |
16549 | (match_operand:SF 5 "nonimmediate_operand" "xm")]) | |
adc7fcb8 JH |
16550 | (match_operand:SF 2 "const0_operand" "X") |
16551 | (match_operand:SF 3 "register_operand" "x")))] | |
0073023d JH |
16552 | "TARGET_SSE2" |
16553 | "#") | |
16554 | ||
16555 | (define_insn "*sse_movdfcc_const0_3" | |
16556 | [(set (match_operand:SF 0 "register_operand" "=x") | |
16557 | (if_then_else:SF (match_operator 1 "fcmov_comparison_operator" | |
16558 | [(match_operand:SF 4 "nonimmediate_operand" "xm") | |
16559 | (match_operand:SF 5 "register_operand" "0")]) | |
16560 | (match_operand:SF 2 "register_operand" "x") | |
16561 | (match_operand:SF 3 "const0_operand" "X")))] | |
16562 | "TARGET_SSE2" | |
16563 | "#") | |
16564 | ||
16565 | (define_insn "*sse_movdfcc_const0_4" | |
16566 | [(set (match_operand:SF 0 "register_operand" "=x") | |
16567 | (if_then_else:SF (match_operator 1 "fcmov_comparison_operator" | |
16568 | [(match_operand:SF 4 "nonimmediate_operand" "xm") | |
16569 | (match_operand:SF 5 "register_operand" "0")]) | |
adc7fcb8 JH |
16570 | (match_operand:SF 2 "const0_operand" "X") |
16571 | (match_operand:SF 3 "register_operand" "x")))] | |
0073023d JH |
16572 | "TARGET_SSE2" |
16573 | "#") | |
16574 | ||
16575 | (define_split | |
16576 | [(set (match_operand 0 "register_operand" "") | |
16577 | (if_then_else (match_operator 1 "comparison_operator" | |
16578 | [(match_operand 4 "register_operand" "") | |
16579 | (match_operand 5 "nonimmediate_operand" "")]) | |
16580 | (match_operand 2 "nonmemory_operand" "") | |
16581 | (match_operand 3 "nonmemory_operand" "")))] | |
16582 | "SSE_REG_P (operands[0]) && reload_completed | |
16583 | && (const0_operand (operands[2], GET_MODE (operands[0])) | |
16584 | || const0_operand (operands[3], GET_MODE (operands[0])))" | |
16585 | [(set (match_dup 0) (match_op_dup 1 [(match_dup 0) (match_dup 5)])) | |
16586 | (set (subreg:TI (match_dup 0) 0) (and:TI (match_dup 6) | |
16587 | (subreg:TI (match_dup 7) 0)))] | |
0073023d JH |
16588 | { |
16589 | PUT_MODE (operands[1], GET_MODE (operands[0])); | |
16590 | if (!sse_comparison_operator (operands[1], VOIDmode)) | |
16591 | { | |
16592 | rtx tmp = operands[5]; | |
16593 | operands[5] = operands[4]; | |
16594 | operands[4] = tmp; | |
16595 | PUT_CODE (operands[1], swap_condition (GET_CODE (operands[1]))); | |
16596 | } | |
16597 | if (const0_operand (operands[2], GET_MODE (operands[0]))) | |
16598 | { | |
16599 | operands[7] = operands[3]; | |
16600 | operands[6] = gen_rtx_NOT (TImode, gen_rtx_SUBREG (TImode, operands[0], | |
16601 | 0)); | |
16602 | } | |
16603 | else | |
16604 | { | |
16605 | operands[7] = operands[2]; | |
16606 | operands[6] = gen_rtx_SUBREG (TImode, operands[0], 0); | |
16607 | } | |
0f40f9f7 | 16608 | }) |
0073023d | 16609 | |
885a70fd JH |
16610 | (define_expand "allocate_stack_worker" |
16611 | [(match_operand:SI 0 "register_operand" "")] | |
16612 | "TARGET_STACK_PROBE" | |
885a70fd JH |
16613 | { |
16614 | if (TARGET_64BIT) | |
16615 | emit_insn (gen_allocate_stack_worker_rex64 (operands[0])); | |
16616 | else | |
16617 | emit_insn (gen_allocate_stack_worker_1 (operands[0])); | |
16618 | DONE; | |
0f40f9f7 | 16619 | }) |
885a70fd JH |
16620 | |
16621 | (define_insn "allocate_stack_worker_1" | |
578b58f5 RK |
16622 | [(unspec:SI [(match_operand:SI 0 "register_operand" "a")] 3) |
16623 | (set (reg:SI 7) (minus:SI (reg:SI 7) (match_dup 0))) | |
e075ae69 RH |
16624 | (clobber (match_dup 0)) |
16625 | (clobber (reg:CC 17))] | |
1b0c37d7 | 16626 | "!TARGET_64BIT && TARGET_STACK_PROBE" |
0f40f9f7 | 16627 | "call\t__alloca" |
885a70fd JH |
16628 | [(set_attr "type" "multi") |
16629 | (set_attr "length" "5")]) | |
16630 | ||
16631 | (define_insn "allocate_stack_worker_rex64" | |
16632 | [(unspec:DI [(match_operand:DI 0 "register_operand" "a")] 3) | |
16633 | (set (reg:DI 7) (minus:DI (reg:DI 7) (match_dup 0))) | |
16634 | (clobber (match_dup 0)) | |
16635 | (clobber (reg:CC 17))] | |
1b0c37d7 | 16636 | "TARGET_64BIT && TARGET_STACK_PROBE" |
0f40f9f7 | 16637 | "call\t__alloca" |
e075ae69 RH |
16638 | [(set_attr "type" "multi") |
16639 | (set_attr "length" "5")]) | |
578b58f5 RK |
16640 | |
16641 | (define_expand "allocate_stack" | |
e075ae69 RH |
16642 | [(parallel [(set (match_operand:SI 0 "register_operand" "=r") |
16643 | (minus:SI (reg:SI 7) | |
16644 | (match_operand:SI 1 "general_operand" ""))) | |
16645 | (clobber (reg:CC 17))]) | |
16646 | (parallel [(set (reg:SI 7) | |
16647 | (minus:SI (reg:SI 7) (match_dup 1))) | |
16648 | (clobber (reg:CC 17))])] | |
16649 | "TARGET_STACK_PROBE" | |
578b58f5 RK |
16650 | { |
16651 | #ifdef CHECK_STACK_LIMIT | |
e9a25f70 JL |
16652 | if (GET_CODE (operands[1]) == CONST_INT |
16653 | && INTVAL (operands[1]) < CHECK_STACK_LIMIT) | |
578b58f5 | 16654 | emit_insn (gen_subsi3 (stack_pointer_rtx, stack_pointer_rtx, |
e9a25f70 | 16655 | operands[1])); |
578b58f5 RK |
16656 | else |
16657 | #endif | |
16658 | emit_insn (gen_allocate_stack_worker (copy_to_mode_reg (SImode, | |
e9a25f70 | 16659 | operands[1]))); |
578b58f5 | 16660 | |
e9a25f70 JL |
16661 | emit_move_insn (operands[0], virtual_stack_dynamic_rtx); |
16662 | DONE; | |
0f40f9f7 | 16663 | }) |
e31ca113 | 16664 | |
fb754025 AG |
16665 | (define_expand "builtin_setjmp_receiver" |
16666 | [(label_ref (match_operand 0 "" ""))] | |
1b0c37d7 | 16667 | "!TARGET_64BIT && flag_pic" |
fb754025 AG |
16668 | { |
16669 | load_pic_register (); | |
16670 | DONE; | |
0f40f9f7 | 16671 | }) |
e9e80858 JH |
16672 | \f |
16673 | ;; Avoid redundant prefixes by splitting HImode arithmetic to SImode. | |
16674 | ||
16675 | (define_split | |
16676 | [(set (match_operand 0 "register_operand" "") | |
16677 | (match_operator 3 "promotable_binary_operator" | |
16678 | [(match_operand 1 "register_operand" "") | |
2247f6ed | 16679 | (match_operand 2 "aligned_operand" "")])) |
e9e80858 JH |
16680 | (clobber (reg:CC 17))] |
16681 | "! TARGET_PARTIAL_REG_STALL && reload_completed | |
16682 | && ((GET_MODE (operands[0]) == HImode | |
16683 | && (!optimize_size || GET_CODE (operands[2]) != CONST_INT | |
16684 | || CONST_OK_FOR_LETTER_P (INTVAL (operands[2]), 'K'))) | |
16685 | || (GET_MODE (operands[0]) == QImode | |
16686 | && (TARGET_PROMOTE_QImode || optimize_size)))" | |
16687 | [(parallel [(set (match_dup 0) | |
16688 | (match_op_dup 3 [(match_dup 1) (match_dup 2)])) | |
16689 | (clobber (reg:CC 17))])] | |
16690 | "operands[0] = gen_lowpart (SImode, operands[0]); | |
16691 | operands[1] = gen_lowpart (SImode, operands[1]); | |
16692 | if (GET_CODE (operands[3]) != ASHIFT) | |
16693 | operands[2] = gen_lowpart (SImode, operands[2]); | |
dbbbbf3b | 16694 | PUT_MODE (operands[3], SImode);") |
e9e80858 JH |
16695 | |
16696 | (define_split | |
16189740 RH |
16697 | [(set (reg 17) |
16698 | (compare (and (match_operand 1 "aligned_operand" "") | |
16699 | (match_operand 2 "const_int_operand" "")) | |
16700 | (const_int 0))) | |
e9e80858 JH |
16701 | (set (match_operand 0 "register_operand" "") |
16702 | (and (match_dup 1) (match_dup 2)))] | |
16703 | "! TARGET_PARTIAL_REG_STALL && reload_completed | |
16189740 | 16704 | && ix86_match_ccmode (insn, CCNOmode) |
e9e80858 JH |
16705 | && (GET_MODE (operands[0]) == HImode |
16706 | || (GET_MODE (operands[0]) == QImode | |
16707 | && (TARGET_PROMOTE_QImode || optimize_size)))" | |
16708 | [(parallel [(set (reg:CCNO 17) | |
16709 | (compare:CCNO (and:SI (match_dup 1) (match_dup 2)) | |
16710 | (const_int 0))) | |
16711 | (set (match_dup 0) | |
16712 | (and:SI (match_dup 1) (match_dup 2)))])] | |
d9f0b960 | 16713 | "operands[2] |
383252a7 AO |
16714 | = GEN_INT (trunc_int_for_mode (INTVAL (operands[2]) |
16715 | & GET_MODE_MASK (GET_MODE (operands[0])), | |
16716 | SImode)); | |
d9f0b960 RH |
16717 | operands[0] = gen_lowpart (SImode, operands[0]); |
16718 | operands[1] = gen_lowpart (SImode, operands[1]);") | |
e9e80858 JH |
16719 | |
16720 | (define_split | |
16189740 RH |
16721 | [(set (reg 17) |
16722 | (compare (and (match_operand 0 "aligned_operand" "") | |
16723 | (match_operand 1 "const_int_operand" "")) | |
16724 | (const_int 0)))] | |
e9e80858 | 16725 | "! TARGET_PARTIAL_REG_STALL && reload_completed |
16189740 | 16726 | && ix86_match_ccmode (insn, CCNOmode) |
e9e80858 JH |
16727 | && (GET_MODE (operands[0]) == HImode |
16728 | || (GET_MODE (operands[0]) == QImode | |
16729 | && (TARGET_PROMOTE_QImode || optimize_size)))" | |
16730 | [(set (reg:CCNO 17) | |
16731 | (compare:CCNO (and:SI (match_dup 0) (match_dup 1)) | |
16732 | (const_int 0)))] | |
d9f0b960 | 16733 | "operands[1] |
383252a7 AO |
16734 | = GEN_INT (trunc_int_for_mode (INTVAL (operands[1]) |
16735 | & GET_MODE_MASK (GET_MODE (operands[0])), | |
16736 | SImode)); | |
d9f0b960 | 16737 | operands[0] = gen_lowpart (SImode, operands[0]);") |
e9e80858 JH |
16738 | |
16739 | (define_split | |
16740 | [(set (match_operand 0 "register_operand" "") | |
16741 | (neg (match_operand 1 "register_operand" ""))) | |
16742 | (clobber (reg:CC 17))] | |
16743 | "! TARGET_PARTIAL_REG_STALL && reload_completed | |
16744 | && (GET_MODE (operands[0]) == HImode | |
16745 | || (GET_MODE (operands[0]) == QImode | |
16746 | && (TARGET_PROMOTE_QImode || optimize_size)))" | |
16747 | [(parallel [(set (match_dup 0) | |
16748 | (neg:SI (match_dup 1))) | |
16749 | (clobber (reg:CC 17))])] | |
16750 | "operands[0] = gen_lowpart (SImode, operands[0]); | |
16751 | operands[1] = gen_lowpart (SImode, operands[1]);") | |
16752 | ||
16753 | (define_split | |
16754 | [(set (match_operand 0 "register_operand" "") | |
16755 | (not (match_operand 1 "register_operand" "")))] | |
16756 | "! TARGET_PARTIAL_REG_STALL && reload_completed | |
16757 | && (GET_MODE (operands[0]) == HImode | |
16758 | || (GET_MODE (operands[0]) == QImode | |
16759 | && (TARGET_PROMOTE_QImode || optimize_size)))" | |
16760 | [(set (match_dup 0) | |
16761 | (not:SI (match_dup 1)))] | |
16762 | "operands[0] = gen_lowpart (SImode, operands[0]); | |
16763 | operands[1] = gen_lowpart (SImode, operands[1]);") | |
16764 | ||
16765 | (define_split | |
16766 | [(set (match_operand 0 "register_operand" "") | |
16767 | (if_then_else (match_operator 1 "comparison_operator" | |
16768 | [(reg 17) (const_int 0)]) | |
16769 | (match_operand 2 "register_operand" "") | |
16770 | (match_operand 3 "register_operand" "")))] | |
16771 | "! TARGET_PARTIAL_REG_STALL && TARGET_CMOVE | |
16772 | && (GET_MODE (operands[0]) == HImode | |
16773 | || (GET_MODE (operands[0]) == QImode | |
16774 | && (TARGET_PROMOTE_QImode || optimize_size)))" | |
16775 | [(set (match_dup 0) | |
16776 | (if_then_else:SI (match_dup 1) (match_dup 2) (match_dup 3)))] | |
16777 | "operands[0] = gen_lowpart (SImode, operands[0]); | |
16778 | operands[2] = gen_lowpart (SImode, operands[2]); | |
16779 | operands[3] = gen_lowpart (SImode, operands[3]);") | |
16780 | ||
e075ae69 RH |
16781 | \f |
16782 | ;; RTL Peephole optimizations, run before sched2. These primarily look to | |
16783 | ;; transform a complex memory operation into two memory to register operations. | |
16784 | ||
16785 | ;; Don't push memory operands | |
16786 | (define_peephole2 | |
3071fab5 RH |
16787 | [(set (match_operand:SI 0 "push_operand" "") |
16788 | (match_operand:SI 1 "memory_operand" "")) | |
16789 | (match_scratch:SI 2 "r")] | |
e075ae69 RH |
16790 | "! optimize_size && ! TARGET_PUSH_MEMORY" |
16791 | [(set (match_dup 2) (match_dup 1)) | |
16792 | (set (match_dup 0) (match_dup 2))] | |
16793 | "") | |
16794 | ||
cc2e591b JH |
16795 | (define_peephole2 |
16796 | [(set (match_operand:DI 0 "push_operand" "") | |
16797 | (match_operand:DI 1 "memory_operand" "")) | |
16798 | (match_scratch:DI 2 "r")] | |
16799 | "! optimize_size && ! TARGET_PUSH_MEMORY" | |
16800 | [(set (match_dup 2) (match_dup 1)) | |
16801 | (set (match_dup 0) (match_dup 2))] | |
16802 | "") | |
16803 | ||
e9e80858 JH |
16804 | ;; We need to handle SFmode only, because DFmode and XFmode is split to |
16805 | ;; SImode pushes. | |
16806 | (define_peephole2 | |
16807 | [(set (match_operand:SF 0 "push_operand" "") | |
16808 | (match_operand:SF 1 "memory_operand" "")) | |
16809 | (match_scratch:SF 2 "r")] | |
16810 | "! optimize_size && ! TARGET_PUSH_MEMORY" | |
16811 | [(set (match_dup 2) (match_dup 1)) | |
16812 | (set (match_dup 0) (match_dup 2))] | |
16813 | "") | |
16814 | ||
e075ae69 | 16815 | (define_peephole2 |
3071fab5 RH |
16816 | [(set (match_operand:HI 0 "push_operand" "") |
16817 | (match_operand:HI 1 "memory_operand" "")) | |
16818 | (match_scratch:HI 2 "r")] | |
e075ae69 RH |
16819 | "! optimize_size && ! TARGET_PUSH_MEMORY" |
16820 | [(set (match_dup 2) (match_dup 1)) | |
16821 | (set (match_dup 0) (match_dup 2))] | |
16822 | "") | |
16823 | ||
16824 | (define_peephole2 | |
3071fab5 RH |
16825 | [(set (match_operand:QI 0 "push_operand" "") |
16826 | (match_operand:QI 1 "memory_operand" "")) | |
16827 | (match_scratch:QI 2 "q")] | |
e075ae69 RH |
16828 | "! optimize_size && ! TARGET_PUSH_MEMORY" |
16829 | [(set (match_dup 2) (match_dup 1)) | |
16830 | (set (match_dup 0) (match_dup 2))] | |
16831 | "") | |
16832 | ||
16833 | ;; Don't move an immediate directly to memory when the instruction | |
16834 | ;; gets too big. | |
16835 | (define_peephole2 | |
16836 | [(match_scratch:SI 1 "r") | |
16837 | (set (match_operand:SI 0 "memory_operand" "") | |
16838 | (const_int 0))] | |
23280139 | 16839 | "! optimize_size |
591702de | 16840 | && ! TARGET_USE_MOV0 |
23280139 RH |
16841 | && TARGET_SPLIT_LONG_MOVES |
16842 | && get_attr_length (insn) >= ix86_cost->large_insn | |
16843 | && peep2_regno_dead_p (0, FLAGS_REG)" | |
e075ae69 RH |
16844 | [(parallel [(set (match_dup 1) (const_int 0)) |
16845 | (clobber (reg:CC 17))]) | |
16846 | (set (match_dup 0) (match_dup 1))] | |
16847 | "") | |
16848 | ||
16849 | (define_peephole2 | |
16850 | [(match_scratch:HI 1 "r") | |
16851 | (set (match_operand:HI 0 "memory_operand" "") | |
16852 | (const_int 0))] | |
23280139 | 16853 | "! optimize_size |
591702de | 16854 | && ! TARGET_USE_MOV0 |
23280139 RH |
16855 | && TARGET_SPLIT_LONG_MOVES |
16856 | && get_attr_length (insn) >= ix86_cost->large_insn | |
16857 | && peep2_regno_dead_p (0, FLAGS_REG)" | |
591702de | 16858 | [(parallel [(set (match_dup 2) (const_int 0)) |
e075ae69 RH |
16859 | (clobber (reg:CC 17))]) |
16860 | (set (match_dup 0) (match_dup 1))] | |
591702de | 16861 | "operands[2] = gen_rtx_REG (SImode, true_regnum (operands[1]));") |
e075ae69 RH |
16862 | |
16863 | (define_peephole2 | |
16864 | [(match_scratch:QI 1 "q") | |
16865 | (set (match_operand:QI 0 "memory_operand" "") | |
16866 | (const_int 0))] | |
23280139 | 16867 | "! optimize_size |
591702de | 16868 | && ! TARGET_USE_MOV0 |
23280139 RH |
16869 | && TARGET_SPLIT_LONG_MOVES |
16870 | && get_attr_length (insn) >= ix86_cost->large_insn | |
16871 | && peep2_regno_dead_p (0, FLAGS_REG)" | |
591702de | 16872 | [(parallel [(set (match_dup 2) (const_int 0)) |
e075ae69 RH |
16873 | (clobber (reg:CC 17))]) |
16874 | (set (match_dup 0) (match_dup 1))] | |
591702de | 16875 | "operands[2] = gen_rtx_REG (SImode, true_regnum (operands[1]));") |
e075ae69 RH |
16876 | |
16877 | (define_peephole2 | |
16878 | [(match_scratch:SI 2 "r") | |
16879 | (set (match_operand:SI 0 "memory_operand" "") | |
16880 | (match_operand:SI 1 "immediate_operand" ""))] | |
23280139 RH |
16881 | "! optimize_size |
16882 | && get_attr_length (insn) >= ix86_cost->large_insn | |
16883 | && TARGET_SPLIT_LONG_MOVES" | |
e075ae69 RH |
16884 | [(set (match_dup 2) (match_dup 1)) |
16885 | (set (match_dup 0) (match_dup 2))] | |
16886 | "") | |
16887 | ||
16888 | (define_peephole2 | |
16889 | [(match_scratch:HI 2 "r") | |
16890 | (set (match_operand:HI 0 "memory_operand" "") | |
16891 | (match_operand:HI 1 "immediate_operand" ""))] | |
16892 | "! optimize_size && get_attr_length (insn) >= ix86_cost->large_insn | |
16893 | && TARGET_SPLIT_LONG_MOVES" | |
16894 | [(set (match_dup 2) (match_dup 1)) | |
16895 | (set (match_dup 0) (match_dup 2))] | |
16896 | "") | |
16897 | ||
16898 | (define_peephole2 | |
16899 | [(match_scratch:QI 2 "q") | |
16900 | (set (match_operand:QI 0 "memory_operand" "") | |
16901 | (match_operand:QI 1 "immediate_operand" ""))] | |
16902 | "! optimize_size && get_attr_length (insn) >= ix86_cost->large_insn | |
16903 | && TARGET_SPLIT_LONG_MOVES" | |
16904 | [(set (match_dup 2) (match_dup 1)) | |
16905 | (set (match_dup 0) (match_dup 2))] | |
16906 | "") | |
16907 | ||
16908 | ;; Don't compare memory with zero, load and use a test instead. | |
16909 | (define_peephole2 | |
16189740 RH |
16910 | [(set (reg 17) |
16911 | (compare (match_operand:SI 0 "memory_operand" "") | |
16912 | (const_int 0))) | |
3071fab5 | 16913 | (match_scratch:SI 3 "r")] |
16189740 RH |
16914 | "ix86_match_ccmode (insn, CCNOmode) && ! optimize_size" |
16915 | [(set (match_dup 3) (match_dup 0)) | |
16916 | (set (reg:CCNO 17) (compare:CCNO (match_dup 3) (const_int 0)))] | |
e075ae69 RH |
16917 | "") |
16918 | ||
16919 | ;; NOT is not pairable on Pentium, while XOR is, but one byte longer. | |
16920 | ;; Don't split NOTs with a displacement operand, because resulting XOR | |
16921 | ;; will not be pariable anyway. | |
16922 | ;; | |
16923 | ;; On AMD K6, NOT is vector decoded with memory operand that can not be | |
16924 | ;; represented using a modRM byte. The XOR replacement is long decoded, | |
16925 | ;; so this split helps here as well. | |
16926 | ;; | |
23280139 RH |
16927 | ;; Note: Can't do this as a regular split because we can't get proper |
16928 | ;; lifetime information then. | |
e075ae69 RH |
16929 | |
16930 | (define_peephole2 | |
d5d6a58b RH |
16931 | [(set (match_operand:SI 0 "nonimmediate_operand" "") |
16932 | (not:SI (match_operand:SI 1 "nonimmediate_operand" "")))] | |
e075ae69 | 16933 | "!optimize_size |
23280139 | 16934 | && peep2_regno_dead_p (0, FLAGS_REG) |
e075ae69 RH |
16935 | && ((TARGET_PENTIUM |
16936 | && (GET_CODE (operands[0]) != MEM | |
16937 | || !memory_displacement_operand (operands[0], SImode))) | |
16938 | || (TARGET_K6 && long_memory_operand (operands[0], SImode)))" | |
16939 | [(parallel [(set (match_dup 0) | |
16940 | (xor:SI (match_dup 1) (const_int -1))) | |
16941 | (clobber (reg:CC 17))])] | |
16942 | "") | |
16943 | ||
16944 | (define_peephole2 | |
d5d6a58b RH |
16945 | [(set (match_operand:HI 0 "nonimmediate_operand" "") |
16946 | (not:HI (match_operand:HI 1 "nonimmediate_operand" "")))] | |
e075ae69 | 16947 | "!optimize_size |
23280139 | 16948 | && peep2_regno_dead_p (0, FLAGS_REG) |
e075ae69 RH |
16949 | && ((TARGET_PENTIUM |
16950 | && (GET_CODE (operands[0]) != MEM | |
16951 | || !memory_displacement_operand (operands[0], HImode))) | |
16952 | || (TARGET_K6 && long_memory_operand (operands[0], HImode)))" | |
16953 | [(parallel [(set (match_dup 0) | |
16954 | (xor:HI (match_dup 1) (const_int -1))) | |
16955 | (clobber (reg:CC 17))])] | |
16956 | "") | |
16957 | ||
16958 | (define_peephole2 | |
d5d6a58b RH |
16959 | [(set (match_operand:QI 0 "nonimmediate_operand" "") |
16960 | (not:QI (match_operand:QI 1 "nonimmediate_operand" "")))] | |
e075ae69 | 16961 | "!optimize_size |
23280139 | 16962 | && peep2_regno_dead_p (0, FLAGS_REG) |
e075ae69 RH |
16963 | && ((TARGET_PENTIUM |
16964 | && (GET_CODE (operands[0]) != MEM | |
16965 | || !memory_displacement_operand (operands[0], QImode))) | |
16966 | || (TARGET_K6 && long_memory_operand (operands[0], QImode)))" | |
16967 | [(parallel [(set (match_dup 0) | |
16968 | (xor:QI (match_dup 1) (const_int -1))) | |
16969 | (clobber (reg:CC 17))])] | |
16970 | "") | |
16971 | ||
16972 | ;; Non pairable "test imm, reg" instructions can be translated to | |
16973 | ;; "and imm, reg" if reg dies. The "and" form is also shorter (one | |
16974 | ;; byte opcode instead of two, have a short form for byte operands), | |
16975 | ;; so do it for other CPUs as well. Given that the value was dead, | |
f5143c46 | 16976 | ;; this should not create any new dependencies. Pass on the sub-word |
e075ae69 RH |
16977 | ;; versions if we're concerned about partial register stalls. |
16978 | ||
16979 | (define_peephole2 | |
16189740 RH |
16980 | [(set (reg 17) |
16981 | (compare (and:SI (match_operand:SI 0 "register_operand" "") | |
16982 | (match_operand:SI 1 "immediate_operand" "")) | |
16983 | (const_int 0)))] | |
16984 | "ix86_match_ccmode (insn, CCNOmode) | |
16985 | && (true_regnum (operands[0]) != 0 | |
16986 | || CONST_OK_FOR_LETTER_P (INTVAL (operands[1]), 'K')) | |
e075ae69 RH |
16987 | && find_regno_note (insn, REG_DEAD, true_regnum (operands[0]))" |
16988 | [(parallel | |
16989 | [(set (reg:CCNO 17) | |
16990 | (compare:CCNO (and:SI (match_dup 0) | |
16991 | (match_dup 1)) | |
16992 | (const_int 0))) | |
16993 | (set (match_dup 0) | |
16994 | (and:SI (match_dup 0) (match_dup 1)))])] | |
16995 | "") | |
16996 | ||
e9e80858 JH |
16997 | ;; We don't need to handle HImode case, because it will be promoted to SImode |
16998 | ;; on ! TARGET_PARTIAL_REG_STALL | |
e075ae69 RH |
16999 | |
17000 | (define_peephole2 | |
16189740 RH |
17001 | [(set (reg 17) |
17002 | (compare (and:QI (match_operand:QI 0 "register_operand" "") | |
17003 | (match_operand:QI 1 "immediate_operand" "")) | |
17004 | (const_int 0)))] | |
e075ae69 | 17005 | "! TARGET_PARTIAL_REG_STALL |
16189740 | 17006 | && ix86_match_ccmode (insn, CCNOmode) |
e075ae69 RH |
17007 | && true_regnum (operands[0]) != 0 |
17008 | && find_regno_note (insn, REG_DEAD, true_regnum (operands[0]))" | |
17009 | [(parallel | |
17010 | [(set (reg:CCNO 17) | |
17011 | (compare:CCNO (and:QI (match_dup 0) | |
17012 | (match_dup 1)) | |
17013 | (const_int 0))) | |
17014 | (set (match_dup 0) | |
17015 | (and:QI (match_dup 0) (match_dup 1)))])] | |
17016 | "") | |
17017 | ||
17018 | (define_peephole2 | |
16189740 RH |
17019 | [(set (reg 17) |
17020 | (compare | |
e075ae69 RH |
17021 | (and:SI |
17022 | (zero_extract:SI | |
3522082b | 17023 | (match_operand 0 "ext_register_operand" "") |
e075ae69 RH |
17024 | (const_int 8) |
17025 | (const_int 8)) | |
3522082b | 17026 | (match_operand 1 "const_int_operand" "")) |
e075ae69 RH |
17027 | (const_int 0)))] |
17028 | "! TARGET_PARTIAL_REG_STALL | |
16189740 | 17029 | && ix86_match_ccmode (insn, CCNOmode) |
e075ae69 RH |
17030 | && true_regnum (operands[0]) != 0 |
17031 | && find_regno_note (insn, REG_DEAD, true_regnum (operands[0]))" | |
17032 | [(parallel [(set (reg:CCNO 17) | |
17033 | (compare:CCNO | |
17034 | (and:SI | |
17035 | (zero_extract:SI | |
17036 | (match_dup 0) | |
17037 | (const_int 8) | |
17038 | (const_int 8)) | |
17039 | (match_dup 1)) | |
17040 | (const_int 0))) | |
17041 | (set (zero_extract:SI (match_dup 0) | |
17042 | (const_int 8) | |
17043 | (const_int 8)) | |
17044 | (and:SI | |
17045 | (zero_extract:SI | |
17046 | (match_dup 0) | |
17047 | (const_int 8) | |
17048 | (const_int 8)) | |
17049 | (match_dup 1)))])] | |
17050 | "") | |
17051 | ||
17052 | ;; Don't do logical operations with memory inputs. | |
17053 | (define_peephole2 | |
17054 | [(match_scratch:SI 2 "r") | |
17055 | (parallel [(set (match_operand:SI 0 "register_operand" "") | |
17056 | (match_operator:SI 3 "arith_or_logical_operator" | |
17057 | [(match_dup 0) | |
17058 | (match_operand:SI 1 "memory_operand" "")])) | |
17059 | (clobber (reg:CC 17))])] | |
17060 | "! optimize_size && ! TARGET_READ_MODIFY" | |
17061 | [(set (match_dup 2) (match_dup 1)) | |
17062 | (parallel [(set (match_dup 0) | |
17063 | (match_op_dup 3 [(match_dup 0) (match_dup 2)])) | |
17064 | (clobber (reg:CC 17))])] | |
17065 | "") | |
17066 | ||
17067 | (define_peephole2 | |
17068 | [(match_scratch:SI 2 "r") | |
17069 | (parallel [(set (match_operand:SI 0 "register_operand" "") | |
17070 | (match_operator:SI 3 "arith_or_logical_operator" | |
17071 | [(match_operand:SI 1 "memory_operand" "") | |
17072 | (match_dup 0)])) | |
17073 | (clobber (reg:CC 17))])] | |
17074 | "! optimize_size && ! TARGET_READ_MODIFY" | |
17075 | [(set (match_dup 2) (match_dup 1)) | |
17076 | (parallel [(set (match_dup 0) | |
17077 | (match_op_dup 3 [(match_dup 2) (match_dup 0)])) | |
17078 | (clobber (reg:CC 17))])] | |
17079 | "") | |
17080 | ||
17081 | ; Don't do logical operations with memory outputs | |
17082 | ; | |
17083 | ; These two don't make sense for PPro/PII -- we're expanding a 4-uop | |
17084 | ; instruction into two 1-uop insns plus a 2-uop insn. That last has | |
17085 | ; the same decoder scheduling characteristics as the original. | |
17086 | ||
17087 | (define_peephole2 | |
17088 | [(match_scratch:SI 2 "r") | |
17089 | (parallel [(set (match_operand:SI 0 "memory_operand" "") | |
17090 | (match_operator:SI 3 "arith_or_logical_operator" | |
17091 | [(match_dup 0) | |
17092 | (match_operand:SI 1 "nonmemory_operand" "")])) | |
17093 | (clobber (reg:CC 17))])] | |
17094 | "! optimize_size && ! TARGET_READ_MODIFY_WRITE" | |
17095 | [(set (match_dup 2) (match_dup 0)) | |
17096 | (parallel [(set (match_dup 2) | |
17097 | (match_op_dup 3 [(match_dup 2) (match_dup 1)])) | |
17098 | (clobber (reg:CC 17))]) | |
17099 | (set (match_dup 0) (match_dup 2))] | |
17100 | "") | |
17101 | ||
17102 | (define_peephole2 | |
17103 | [(match_scratch:SI 2 "r") | |
17104 | (parallel [(set (match_operand:SI 0 "memory_operand" "") | |
17105 | (match_operator:SI 3 "arith_or_logical_operator" | |
17106 | [(match_operand:SI 1 "nonmemory_operand" "") | |
17107 | (match_dup 0)])) | |
17108 | (clobber (reg:CC 17))])] | |
17109 | "! optimize_size && ! TARGET_READ_MODIFY_WRITE" | |
17110 | [(set (match_dup 2) (match_dup 0)) | |
17111 | (parallel [(set (match_dup 2) | |
17112 | (match_op_dup 3 [(match_dup 1) (match_dup 2)])) | |
17113 | (clobber (reg:CC 17))]) | |
17114 | (set (match_dup 0) (match_dup 2))] | |
17115 | "") | |
17116 | ||
17117 | ;; Attempt to always use XOR for zeroing registers. | |
17118 | (define_peephole2 | |
17119 | [(set (match_operand 0 "register_operand" "") | |
17120 | (const_int 0))] | |
17121 | "(GET_MODE (operands[0]) == QImode | |
17122 | || GET_MODE (operands[0]) == HImode | |
cc2e591b JH |
17123 | || GET_MODE (operands[0]) == SImode |
17124 | || (GET_MODE (operands[0]) == DImode && TARGET_64BIT)) | |
e075ae69 | 17125 | && (! TARGET_USE_MOV0 || optimize_size) |
23280139 | 17126 | && peep2_regno_dead_p (0, FLAGS_REG)" |
e075ae69 RH |
17127 | [(parallel [(set (match_dup 0) (const_int 0)) |
17128 | (clobber (reg:CC 17))])] | |
cc2e591b JH |
17129 | "operands[0] = gen_rtx_REG (GET_MODE (operands[0]) == DImode ? DImode : SImode, |
17130 | true_regnum (operands[0]));") | |
d3a923ee | 17131 | |
6ef67412 JH |
17132 | (define_peephole2 |
17133 | [(set (strict_low_part (match_operand 0 "register_operand" "")) | |
17134 | (const_int 0))] | |
17135 | "(GET_MODE (operands[0]) == QImode | |
17136 | || GET_MODE (operands[0]) == HImode) | |
17137 | && (! TARGET_USE_MOV0 || optimize_size) | |
17138 | && peep2_regno_dead_p (0, FLAGS_REG)" | |
17139 | [(parallel [(set (strict_low_part (match_dup 0)) (const_int 0)) | |
17140 | (clobber (reg:CC 17))])]) | |
17141 | ||
e075ae69 RH |
17142 | ;; For HI and SI modes, or $-1,reg is smaller than mov $-1,reg. |
17143 | (define_peephole2 | |
591702de | 17144 | [(set (match_operand 0 "register_operand" "") |
e075ae69 | 17145 | (const_int -1))] |
591702de | 17146 | "(GET_MODE (operands[0]) == HImode |
cc2e591b JH |
17147 | || GET_MODE (operands[0]) == SImode |
17148 | || (GET_MODE (operands[0]) == DImode && TARGET_64BIT)) | |
591702de | 17149 | && (optimize_size || TARGET_PENTIUM) |
23280139 | 17150 | && peep2_regno_dead_p (0, FLAGS_REG)" |
591702de | 17151 | [(parallel [(set (match_dup 0) (const_int -1)) |
e075ae69 | 17152 | (clobber (reg:CC 17))])] |
cc2e591b JH |
17153 | "operands[0] = gen_rtx_REG (GET_MODE (operands[0]) == DImode ? DImode : SImode, |
17154 | true_regnum (operands[0]));") | |
1c27d4b2 JH |
17155 | |
17156 | ;; Attempt to convert simple leas to adds. These can be created by | |
17157 | ;; move expanders. | |
17158 | (define_peephole2 | |
17159 | [(set (match_operand:SI 0 "register_operand" "") | |
17160 | (plus:SI (match_dup 0) | |
17161 | (match_operand:SI 1 "nonmemory_operand" "")))] | |
23280139 | 17162 | "peep2_regno_dead_p (0, FLAGS_REG)" |
1c27d4b2 JH |
17163 | [(parallel [(set (match_dup 0) (plus:SI (match_dup 0) (match_dup 1))) |
17164 | (clobber (reg:CC 17))])] | |
17165 | "") | |
17166 | ||
cc2e591b JH |
17167 | (define_peephole2 |
17168 | [(set (match_operand:SI 0 "register_operand" "") | |
17169 | (subreg:SI (plus:DI (match_operand:DI 1 "register_operand" "") | |
17170 | (match_operand:DI 2 "nonmemory_operand" "")) 0))] | |
17171 | "peep2_regno_dead_p (0, FLAGS_REG) && REGNO (operands[0]) == REGNO (operands[1])" | |
17172 | [(parallel [(set (match_dup 0) (plus:SI (match_dup 0) (match_dup 2))) | |
17173 | (clobber (reg:CC 17))])] | |
17174 | "operands[2] = gen_lowpart (SImode, operands[2]);") | |
17175 | ||
17176 | (define_peephole2 | |
17177 | [(set (match_operand:DI 0 "register_operand" "") | |
17178 | (plus:DI (match_dup 0) | |
17179 | (match_operand:DI 1 "x86_64_general_operand" "")))] | |
17180 | "peep2_regno_dead_p (0, FLAGS_REG)" | |
17181 | [(parallel [(set (match_dup 0) (plus:DI (match_dup 0) (match_dup 1))) | |
17182 | (clobber (reg:CC 17))])] | |
17183 | "") | |
17184 | ||
1c27d4b2 JH |
17185 | (define_peephole2 |
17186 | [(set (match_operand:SI 0 "register_operand" "") | |
17187 | (mult:SI (match_dup 0) | |
cc2e591b | 17188 | (match_operand:SI 1 "const_int_operand" "")))] |
23280139 RH |
17189 | "exact_log2 (INTVAL (operands[1])) >= 0 |
17190 | && peep2_regno_dead_p (0, FLAGS_REG)" | |
1c27d4b2 JH |
17191 | [(parallel [(set (match_dup 0) (ashift:SI (match_dup 0) (match_dup 2))) |
17192 | (clobber (reg:CC 17))])] | |
17193 | "operands[2] = GEN_INT (exact_log2 (INTVAL (operands[1])));") | |
bdeb029c | 17194 | |
cc2e591b JH |
17195 | (define_peephole2 |
17196 | [(set (match_operand:DI 0 "register_operand" "") | |
17197 | (mult:DI (match_dup 0) | |
17198 | (match_operand:DI 1 "const_int_operand" "")))] | |
17199 | "exact_log2 (INTVAL (operands[1])) >= 0 | |
17200 | && peep2_regno_dead_p (0, FLAGS_REG)" | |
17201 | [(parallel [(set (match_dup 0) (ashift:DI (match_dup 0) (match_dup 2))) | |
17202 | (clobber (reg:CC 17))])] | |
17203 | "operands[2] = GEN_INT (exact_log2 (INTVAL (operands[1])));") | |
17204 | ||
17205 | (define_peephole2 | |
17206 | [(set (match_operand:SI 0 "register_operand" "") | |
17207 | (subreg:SI (mult:DI (match_operand:DI 1 "register_operand" "") | |
17208 | (match_operand:DI 2 "const_int_operand" "")) 0))] | |
17209 | "exact_log2 (INTVAL (operands[1])) >= 0 | |
17210 | && REGNO (operands[0]) == REGNO (operands[1]) | |
17211 | && peep2_regno_dead_p (0, FLAGS_REG)" | |
17212 | [(parallel [(set (match_dup 0) (ashift:SI (match_dup 0) (match_dup 2))) | |
17213 | (clobber (reg:CC 17))])] | |
17214 | "operands[2] = GEN_INT (exact_log2 (INTVAL (operands[2])));") | |
17215 | ||
bdeb029c JH |
17216 | ;; The ESP adjustments can be done by the push and pop instructions. Resulting |
17217 | ;; code is shorter, since push is only 1 byte, while add imm, %esp 3 bytes. On | |
17218 | ;; many CPUs it is also faster, since special hardware to avoid esp | |
f5143c46 | 17219 | ;; dependencies is present. |
bdeb029c | 17220 | |
d6a7951f | 17221 | ;; While some of these conversions may be done using splitters, we use peepholes |
bdeb029c JH |
17222 | ;; in order to allow combine_stack_adjustments pass to see nonobfuscated RTL. |
17223 | ||
f5143c46 | 17224 | ;; Convert prologue esp subtractions to push. |
bdeb029c JH |
17225 | ;; We need register to push. In order to keep verify_flow_info happy we have |
17226 | ;; two choices | |
17227 | ;; - use scratch and clobber it in order to avoid dependencies | |
17228 | ;; - use already live register | |
17229 | ;; We can't use the second way right now, since there is no reliable way how to | |
17230 | ;; verify that given register is live. First choice will also most likely in | |
17231 | ;; fewer dependencies. On the place of esp adjustments it is very likely that | |
17232 | ;; call clobbered registers are dead. We may want to use base pointer as an | |
17233 | ;; alternative when no register is available later. | |
17234 | ||
17235 | (define_peephole2 | |
17236 | [(match_scratch:SI 0 "r") | |
17237 | (parallel [(set (reg:SI 7) (plus:SI (reg:SI 7) (const_int -4))) | |
f2042df3 RH |
17238 | (clobber (reg:CC 17)) |
17239 | (clobber (mem:BLK (scratch)))])] | |
bdeb029c JH |
17240 | "optimize_size || !TARGET_SUB_ESP_4" |
17241 | [(clobber (match_dup 0)) | |
17242 | (parallel [(set (mem:SI (pre_dec:SI (reg:SI 7))) (match_dup 0)) | |
f2042df3 | 17243 | (clobber (mem:BLK (scratch)))])]) |
bdeb029c JH |
17244 | |
17245 | (define_peephole2 | |
17246 | [(match_scratch:SI 0 "r") | |
17247 | (parallel [(set (reg:SI 7) (plus:SI (reg:SI 7) (const_int -8))) | |
f2042df3 RH |
17248 | (clobber (reg:CC 17)) |
17249 | (clobber (mem:BLK (scratch)))])] | |
bdeb029c JH |
17250 | "optimize_size || !TARGET_SUB_ESP_8" |
17251 | [(clobber (match_dup 0)) | |
17252 | (set (mem:SI (pre_dec:SI (reg:SI 7))) (match_dup 0)) | |
17253 | (parallel [(set (mem:SI (pre_dec:SI (reg:SI 7))) (match_dup 0)) | |
f2042df3 | 17254 | (clobber (mem:BLK (scratch)))])]) |
bdeb029c | 17255 | |
f5143c46 | 17256 | ;; Convert esp subtractions to push. |
bdeb029c JH |
17257 | (define_peephole2 |
17258 | [(match_scratch:SI 0 "r") | |
17259 | (parallel [(set (reg:SI 7) (plus:SI (reg:SI 7) (const_int -4))) | |
17260 | (clobber (reg:CC 17))])] | |
17261 | "optimize_size || !TARGET_SUB_ESP_4" | |
17262 | [(clobber (match_dup 0)) | |
17263 | (set (mem:SI (pre_dec:SI (reg:SI 7))) (match_dup 0))]) | |
17264 | ||
17265 | (define_peephole2 | |
17266 | [(match_scratch:SI 0 "r") | |
17267 | (parallel [(set (reg:SI 7) (plus:SI (reg:SI 7) (const_int -8))) | |
17268 | (clobber (reg:CC 17))])] | |
17269 | "optimize_size || !TARGET_SUB_ESP_8" | |
17270 | [(clobber (match_dup 0)) | |
17271 | (set (mem:SI (pre_dec:SI (reg:SI 7))) (match_dup 0)) | |
17272 | (set (mem:SI (pre_dec:SI (reg:SI 7))) (match_dup 0))]) | |
17273 | ||
17274 | ;; Convert epilogue deallocator to pop. | |
17275 | (define_peephole2 | |
17276 | [(match_scratch:SI 0 "r") | |
17277 | (parallel [(set (reg:SI 7) (plus:SI (reg:SI 7) (const_int 4))) | |
f2042df3 RH |
17278 | (clobber (reg:CC 17)) |
17279 | (clobber (mem:BLK (scratch)))])] | |
bdeb029c JH |
17280 | "optimize_size || !TARGET_ADD_ESP_4" |
17281 | [(parallel [(set (match_dup 0) (mem:SI (reg:SI 7))) | |
17282 | (set (reg:SI 7) (plus:SI (reg:SI 7) (const_int 4))) | |
f2042df3 | 17283 | (clobber (mem:BLK (scratch)))])] |
bdeb029c JH |
17284 | "") |
17285 | ||
17286 | ;; Two pops case is tricky, since pop causes dependency on destination register. | |
17287 | ;; We use two registers if available. | |
17288 | (define_peephole2 | |
17289 | [(match_scratch:SI 0 "r") | |
17290 | (match_scratch:SI 1 "r") | |
17291 | (parallel [(set (reg:SI 7) (plus:SI (reg:SI 7) (const_int 8))) | |
f2042df3 RH |
17292 | (clobber (reg:CC 17)) |
17293 | (clobber (mem:BLK (scratch)))])] | |
bdeb029c JH |
17294 | "optimize_size || !TARGET_ADD_ESP_8" |
17295 | [(parallel [(set (match_dup 0) (mem:SI (reg:SI 7))) | |
17296 | (set (reg:SI 7) (plus:SI (reg:SI 7) (const_int 4))) | |
f2042df3 | 17297 | (clobber (mem:BLK (scratch)))]) |
bdeb029c JH |
17298 | (parallel [(set (match_dup 1) (mem:SI (reg:SI 7))) |
17299 | (set (reg:SI 7) (plus:SI (reg:SI 7) (const_int 4)))])] | |
17300 | "") | |
17301 | ||
17302 | (define_peephole2 | |
17303 | [(match_scratch:SI 0 "r") | |
17304 | (parallel [(set (reg:SI 7) (plus:SI (reg:SI 7) (const_int 8))) | |
f2042df3 RH |
17305 | (clobber (reg:CC 17)) |
17306 | (clobber (mem:BLK (scratch)))])] | |
bdeb029c JH |
17307 | "optimize_size" |
17308 | [(parallel [(set (match_dup 0) (mem:SI (reg:SI 7))) | |
17309 | (set (reg:SI 7) (plus:SI (reg:SI 7) (const_int 4))) | |
f2042df3 | 17310 | (clobber (mem:BLK (scratch)))]) |
bdeb029c JH |
17311 | (parallel [(set (match_dup 0) (mem:SI (reg:SI 7))) |
17312 | (set (reg:SI 7) (plus:SI (reg:SI 7) (const_int 4)))])] | |
17313 | "") | |
17314 | ||
17315 | ;; Convert esp additions to pop. | |
17316 | (define_peephole2 | |
17317 | [(match_scratch:SI 0 "r") | |
17318 | (parallel [(set (reg:SI 7) (plus:SI (reg:SI 7) (const_int 4))) | |
17319 | (clobber (reg:CC 17))])] | |
17320 | "" | |
17321 | [(parallel [(set (match_dup 0) (mem:SI (reg:SI 7))) | |
17322 | (set (reg:SI 7) (plus:SI (reg:SI 7) (const_int 4)))])] | |
17323 | "") | |
17324 | ||
17325 | ;; Two pops case is tricky, since pop causes dependency on destination register. | |
17326 | ;; We use two registers if available. | |
17327 | (define_peephole2 | |
17328 | [(match_scratch:SI 0 "r") | |
17329 | (match_scratch:SI 1 "r") | |
17330 | (parallel [(set (reg:SI 7) (plus:SI (reg:SI 7) (const_int 8))) | |
17331 | (clobber (reg:CC 17))])] | |
17332 | "" | |
17333 | [(parallel [(set (match_dup 0) (mem:SI (reg:SI 7))) | |
17334 | (set (reg:SI 7) (plus:SI (reg:SI 7) (const_int 4)))]) | |
17335 | (parallel [(set (match_dup 1) (mem:SI (reg:SI 7))) | |
17336 | (set (reg:SI 7) (plus:SI (reg:SI 7) (const_int 4)))])] | |
17337 | "") | |
17338 | ||
17339 | (define_peephole2 | |
17340 | [(match_scratch:SI 0 "r") | |
17341 | (parallel [(set (reg:SI 7) (plus:SI (reg:SI 7) (const_int 8))) | |
17342 | (clobber (reg:CC 17))])] | |
17343 | "optimize_size" | |
17344 | [(parallel [(set (match_dup 0) (mem:SI (reg:SI 7))) | |
17345 | (set (reg:SI 7) (plus:SI (reg:SI 7) (const_int 4)))]) | |
17346 | (parallel [(set (match_dup 0) (mem:SI (reg:SI 7))) | |
17347 | (set (reg:SI 7) (plus:SI (reg:SI 7) (const_int 4)))])] | |
17348 | "") | |
69404d6f | 17349 | \f |
9dcbdc7e JH |
17350 | ;; Convert compares with 1 to shorter inc/dec operations when CF is not |
17351 | ;; required and register dies. | |
17352 | (define_peephole2 | |
17353 | [(set (reg 17) | |
17354 | (compare (match_operand:SI 0 "register_operand" "") | |
17355 | (match_operand:SI 1 "incdec_operand" "")))] | |
17356 | "ix86_match_ccmode (insn, CCGCmode) | |
17357 | && find_regno_note (insn, REG_DEAD, true_regnum (operands[0]))" | |
17358 | [(parallel [(set (reg:CCGC 17) | |
265dab10 | 17359 | (compare:CCGC (match_dup 0) |
7e08e190 | 17360 | (match_dup 1))) |
9dcbdc7e | 17361 | (clobber (match_dup 0))])] |
7e08e190 | 17362 | "") |
9dcbdc7e JH |
17363 | |
17364 | (define_peephole2 | |
17365 | [(set (reg 17) | |
17366 | (compare (match_operand:HI 0 "register_operand" "") | |
17367 | (match_operand:HI 1 "incdec_operand" "")))] | |
17368 | "ix86_match_ccmode (insn, CCGCmode) | |
17369 | && find_regno_note (insn, REG_DEAD, true_regnum (operands[0]))" | |
17370 | [(parallel [(set (reg:CCGC 17) | |
265dab10 | 17371 | (compare:CCGC (match_dup 0) |
7e08e190 | 17372 | (match_dup 1))) |
9dcbdc7e | 17373 | (clobber (match_dup 0))])] |
7e08e190 | 17374 | "") |
9dcbdc7e JH |
17375 | |
17376 | (define_peephole2 | |
17377 | [(set (reg 17) | |
17378 | (compare (match_operand:QI 0 "register_operand" "") | |
17379 | (match_operand:QI 1 "incdec_operand" "")))] | |
17380 | "ix86_match_ccmode (insn, CCGCmode) | |
17381 | && find_regno_note (insn, REG_DEAD, true_regnum (operands[0]))" | |
17382 | [(parallel [(set (reg:CCGC 17) | |
265dab10 | 17383 | (compare:CCGC (match_dup 0) |
7e08e190 | 17384 | (match_dup 1))) |
9dcbdc7e | 17385 | (clobber (match_dup 0))])] |
7e08e190 | 17386 | "") |
9dcbdc7e JH |
17387 | |
17388 | ;; Convert compares with 128 to shorter add -128 | |
17389 | (define_peephole2 | |
17390 | [(set (reg 17) | |
17391 | (compare (match_operand:SI 0 "register_operand" "") | |
17392 | (const_int 128)))] | |
7e08e190 | 17393 | "ix86_match_ccmode (insn, CCGCmode) |
9dcbdc7e | 17394 | && find_regno_note (insn, REG_DEAD, true_regnum (operands[0]))" |
7e08e190 JH |
17395 | [(parallel [(set (reg:CCGC 17) |
17396 | (compare:CCGC (match_dup 0) | |
17397 | (const_int 128))) | |
9dcbdc7e JH |
17398 | (clobber (match_dup 0))])] |
17399 | "") | |
17400 | ||
17401 | (define_peephole2 | |
17402 | [(set (reg 17) | |
17403 | (compare (match_operand:HI 0 "register_operand" "") | |
17404 | (const_int 128)))] | |
7e08e190 | 17405 | "ix86_match_ccmode (insn, CCGCmode) |
9dcbdc7e | 17406 | && find_regno_note (insn, REG_DEAD, true_regnum (operands[0]))" |
7e08e190 JH |
17407 | [(parallel [(set (reg:CCGC 17) |
17408 | (compare:CCGC (match_dup 0) | |
17409 | (const_int 128))) | |
9dcbdc7e JH |
17410 | (clobber (match_dup 0))])] |
17411 | "") | |
17412 | \f | |
cc2e591b JH |
17413 | (define_peephole2 |
17414 | [(match_scratch:DI 0 "r") | |
17415 | (parallel [(set (reg:DI 7) (plus:DI (reg:DI 7) (const_int -8))) | |
f2042df3 RH |
17416 | (clobber (reg:CC 17)) |
17417 | (clobber (mem:BLK (scratch)))])] | |
cc2e591b JH |
17418 | "optimize_size || !TARGET_SUB_ESP_4" |
17419 | [(clobber (match_dup 0)) | |
17420 | (parallel [(set (mem:DI (pre_dec:DI (reg:DI 7))) (match_dup 0)) | |
f2042df3 | 17421 | (clobber (mem:BLK (scratch)))])]) |
cc2e591b JH |
17422 | |
17423 | (define_peephole2 | |
17424 | [(match_scratch:DI 0 "r") | |
17425 | (parallel [(set (reg:DI 7) (plus:DI (reg:DI 7) (const_int -16))) | |
f2042df3 RH |
17426 | (clobber (reg:CC 17)) |
17427 | (clobber (mem:BLK (scratch)))])] | |
cc2e591b JH |
17428 | "optimize_size || !TARGET_SUB_ESP_8" |
17429 | [(clobber (match_dup 0)) | |
17430 | (set (mem:DI (pre_dec:DI (reg:DI 7))) (match_dup 0)) | |
17431 | (parallel [(set (mem:DI (pre_dec:DI (reg:DI 7))) (match_dup 0)) | |
f2042df3 | 17432 | (clobber (mem:BLK (scratch)))])]) |
cc2e591b | 17433 | |
f5143c46 | 17434 | ;; Convert esp subtractions to push. |
cc2e591b JH |
17435 | (define_peephole2 |
17436 | [(match_scratch:DI 0 "r") | |
17437 | (parallel [(set (reg:DI 7) (plus:DI (reg:DI 7) (const_int -8))) | |
17438 | (clobber (reg:CC 17))])] | |
17439 | "optimize_size || !TARGET_SUB_ESP_4" | |
17440 | [(clobber (match_dup 0)) | |
17441 | (set (mem:DI (pre_dec:DI (reg:DI 7))) (match_dup 0))]) | |
17442 | ||
17443 | (define_peephole2 | |
17444 | [(match_scratch:DI 0 "r") | |
17445 | (parallel [(set (reg:DI 7) (plus:DI (reg:DI 7) (const_int -16))) | |
17446 | (clobber (reg:CC 17))])] | |
17447 | "optimize_size || !TARGET_SUB_ESP_8" | |
17448 | [(clobber (match_dup 0)) | |
17449 | (set (mem:DI (pre_dec:DI (reg:DI 7))) (match_dup 0)) | |
17450 | (set (mem:DI (pre_dec:DI (reg:DI 7))) (match_dup 0))]) | |
17451 | ||
17452 | ;; Convert epilogue deallocator to pop. | |
17453 | (define_peephole2 | |
17454 | [(match_scratch:DI 0 "r") | |
17455 | (parallel [(set (reg:DI 7) (plus:DI (reg:DI 7) (const_int 8))) | |
f2042df3 RH |
17456 | (clobber (reg:CC 17)) |
17457 | (clobber (mem:BLK (scratch)))])] | |
cc2e591b JH |
17458 | "optimize_size || !TARGET_ADD_ESP_4" |
17459 | [(parallel [(set (match_dup 0) (mem:DI (reg:DI 7))) | |
17460 | (set (reg:DI 7) (plus:DI (reg:DI 7) (const_int 8))) | |
f2042df3 | 17461 | (clobber (mem:BLK (scratch)))])] |
cc2e591b JH |
17462 | "") |
17463 | ||
17464 | ;; Two pops case is tricky, since pop causes dependency on destination register. | |
17465 | ;; We use two registers if available. | |
17466 | (define_peephole2 | |
17467 | [(match_scratch:DI 0 "r") | |
17468 | (match_scratch:DI 1 "r") | |
17469 | (parallel [(set (reg:DI 7) (plus:DI (reg:DI 7) (const_int 16))) | |
f2042df3 RH |
17470 | (clobber (reg:CC 17)) |
17471 | (clobber (mem:BLK (scratch)))])] | |
cc2e591b JH |
17472 | "optimize_size || !TARGET_ADD_ESP_8" |
17473 | [(parallel [(set (match_dup 0) (mem:DI (reg:DI 7))) | |
17474 | (set (reg:DI 7) (plus:DI (reg:DI 7) (const_int 8))) | |
f2042df3 | 17475 | (clobber (mem:BLK (scratch)))]) |
cc2e591b JH |
17476 | (parallel [(set (match_dup 1) (mem:DI (reg:DI 7))) |
17477 | (set (reg:DI 7) (plus:DI (reg:DI 7) (const_int 8)))])] | |
17478 | "") | |
17479 | ||
17480 | (define_peephole2 | |
17481 | [(match_scratch:DI 0 "r") | |
17482 | (parallel [(set (reg:DI 7) (plus:DI (reg:DI 7) (const_int 16))) | |
f2042df3 RH |
17483 | (clobber (reg:CC 17)) |
17484 | (clobber (mem:BLK (scratch)))])] | |
cc2e591b JH |
17485 | "optimize_size" |
17486 | [(parallel [(set (match_dup 0) (mem:DI (reg:DI 7))) | |
17487 | (set (reg:DI 7) (plus:DI (reg:DI 7) (const_int 8))) | |
f2042df3 | 17488 | (clobber (mem:BLK (scratch)))]) |
cc2e591b JH |
17489 | (parallel [(set (match_dup 0) (mem:DI (reg:DI 7))) |
17490 | (set (reg:DI 7) (plus:DI (reg:DI 7) (const_int 8)))])] | |
17491 | "") | |
17492 | ||
17493 | ;; Convert esp additions to pop. | |
17494 | (define_peephole2 | |
17495 | [(match_scratch:DI 0 "r") | |
17496 | (parallel [(set (reg:DI 7) (plus:DI (reg:DI 7) (const_int 8))) | |
17497 | (clobber (reg:CC 17))])] | |
17498 | "" | |
17499 | [(parallel [(set (match_dup 0) (mem:DI (reg:DI 7))) | |
17500 | (set (reg:DI 7) (plus:DI (reg:DI 7) (const_int 8)))])] | |
17501 | "") | |
17502 | ||
17503 | ;; Two pops case is tricky, since pop causes dependency on destination register. | |
17504 | ;; We use two registers if available. | |
17505 | (define_peephole2 | |
17506 | [(match_scratch:DI 0 "r") | |
17507 | (match_scratch:DI 1 "r") | |
17508 | (parallel [(set (reg:DI 7) (plus:DI (reg:DI 7) (const_int 16))) | |
17509 | (clobber (reg:CC 17))])] | |
17510 | "" | |
17511 | [(parallel [(set (match_dup 0) (mem:DI (reg:DI 7))) | |
17512 | (set (reg:DI 7) (plus:DI (reg:DI 7) (const_int 8)))]) | |
17513 | (parallel [(set (match_dup 1) (mem:DI (reg:DI 7))) | |
17514 | (set (reg:DI 7) (plus:DI (reg:DI 7) (const_int 8)))])] | |
17515 | "") | |
17516 | ||
17517 | (define_peephole2 | |
17518 | [(match_scratch:DI 0 "r") | |
17519 | (parallel [(set (reg:DI 7) (plus:DI (reg:DI 7) (const_int 16))) | |
17520 | (clobber (reg:CC 17))])] | |
17521 | "optimize_size" | |
17522 | [(parallel [(set (match_dup 0) (mem:DI (reg:DI 7))) | |
17523 | (set (reg:DI 7) (plus:DI (reg:DI 7) (const_int 8)))]) | |
17524 | (parallel [(set (match_dup 0) (mem:DI (reg:DI 7))) | |
17525 | (set (reg:DI 7) (plus:DI (reg:DI 7) (const_int 8)))])] | |
17526 | "") | |
17527 | \f | |
69404d6f RH |
17528 | ;; Call-value patterns last so that the wildcard operand does not |
17529 | ;; disrupt insn-recog's switch tables. | |
17530 | ||
94bb5d0c RH |
17531 | (define_insn "*call_value_pop_0" |
17532 | [(set (match_operand 0 "" "") | |
e1ff012c | 17533 | (call (mem:QI (match_operand:SI 1 "constant_call_address_operand" "")) |
94bb5d0c RH |
17534 | (match_operand:SI 2 "" ""))) |
17535 | (set (reg:SI 7) (plus:SI (reg:SI 7) | |
90d10fb9 | 17536 | (match_operand:SI 3 "immediate_operand" "")))] |
1e07edd3 | 17537 | "!TARGET_64BIT" |
94bb5d0c RH |
17538 | { |
17539 | if (SIBLING_CALL_P (insn)) | |
0f40f9f7 | 17540 | return "jmp\t%P1"; |
94bb5d0c | 17541 | else |
0f40f9f7 ZW |
17542 | return "call\t%P1"; |
17543 | } | |
94bb5d0c RH |
17544 | [(set_attr "type" "callv")]) |
17545 | ||
69404d6f RH |
17546 | (define_insn "*call_value_pop_1" |
17547 | [(set (match_operand 0 "" "") | |
e1ff012c | 17548 | (call (mem:QI (match_operand:SI 1 "call_insn_operand" "rsm")) |
94bb5d0c | 17549 | (match_operand:SI 2 "" ""))) |
69404d6f | 17550 | (set (reg:SI 7) (plus:SI (reg:SI 7) |
90d10fb9 | 17551 | (match_operand:SI 3 "immediate_operand" "i")))] |
1e07edd3 | 17552 | "!TARGET_64BIT" |
69404d6f | 17553 | { |
94bb5d0c RH |
17554 | if (constant_call_address_operand (operands[1], QImode)) |
17555 | { | |
17556 | if (SIBLING_CALL_P (insn)) | |
0f40f9f7 | 17557 | return "jmp\t%P1"; |
94bb5d0c | 17558 | else |
0f40f9f7 | 17559 | return "call\t%P1"; |
94bb5d0c | 17560 | } |
94bb5d0c | 17561 | if (SIBLING_CALL_P (insn)) |
0f40f9f7 | 17562 | return "jmp\t%A1"; |
94bb5d0c | 17563 | else |
0f40f9f7 ZW |
17564 | return "call\t%A1"; |
17565 | } | |
94bb5d0c RH |
17566 | [(set_attr "type" "callv")]) |
17567 | ||
17568 | (define_insn "*call_value_0" | |
17569 | [(set (match_operand 0 "" "") | |
e1ff012c | 17570 | (call (mem:QI (match_operand:SI 1 "constant_call_address_operand" "")) |
94bb5d0c | 17571 | (match_operand:SI 2 "" "")))] |
32ee7d1d | 17572 | "!TARGET_64BIT" |
32ee7d1d JH |
17573 | { |
17574 | if (SIBLING_CALL_P (insn)) | |
0f40f9f7 | 17575 | return "jmp\t%P1"; |
32ee7d1d | 17576 | else |
0f40f9f7 ZW |
17577 | return "call\t%P1"; |
17578 | } | |
32ee7d1d JH |
17579 | [(set_attr "type" "callv")]) |
17580 | ||
17581 | (define_insn "*call_value_0_rex64" | |
17582 | [(set (match_operand 0 "" "") | |
17583 | (call (mem:QI (match_operand:DI 1 "constant_call_address_operand" "")) | |
17584 | (match_operand:DI 2 "const_int_operand" "")))] | |
17585 | "TARGET_64BIT" | |
94bb5d0c RH |
17586 | { |
17587 | if (SIBLING_CALL_P (insn)) | |
0f40f9f7 | 17588 | return "jmp\t%P1"; |
94bb5d0c | 17589 | else |
0f40f9f7 ZW |
17590 | return "call\t%P1"; |
17591 | } | |
69404d6f RH |
17592 | [(set_attr "type" "callv")]) |
17593 | ||
69404d6f RH |
17594 | (define_insn "*call_value_1" |
17595 | [(set (match_operand 0 "" "") | |
e1ff012c | 17596 | (call (mem:QI (match_operand:SI 1 "call_insn_operand" "rsm")) |
94bb5d0c | 17597 | (match_operand:SI 2 "" "")))] |
32ee7d1d | 17598 | "!TARGET_64BIT" |
32ee7d1d JH |
17599 | { |
17600 | if (constant_call_address_operand (operands[1], QImode)) | |
17601 | { | |
17602 | if (SIBLING_CALL_P (insn)) | |
0f40f9f7 | 17603 | return "jmp\t%P1"; |
32ee7d1d | 17604 | else |
0f40f9f7 | 17605 | return "call\t%P1"; |
32ee7d1d JH |
17606 | } |
17607 | if (SIBLING_CALL_P (insn)) | |
0f40f9f7 | 17608 | return "jmp\t%*%1"; |
32ee7d1d | 17609 | else |
0f40f9f7 ZW |
17610 | return "call\t%*%1"; |
17611 | } | |
32ee7d1d JH |
17612 | [(set_attr "type" "callv")]) |
17613 | ||
17614 | (define_insn "*call_value_1_rex64" | |
17615 | [(set (match_operand 0 "" "") | |
17616 | (call (mem:QI (match_operand:DI 1 "call_insn_operand" "rsm")) | |
17617 | (match_operand:DI 2 "" "")))] | |
17618 | "TARGET_64BIT" | |
69404d6f | 17619 | { |
94bb5d0c | 17620 | if (constant_call_address_operand (operands[1], QImode)) |
cbbf65e0 RH |
17621 | { |
17622 | if (SIBLING_CALL_P (insn)) | |
0f40f9f7 | 17623 | return "jmp\t%P1"; |
cbbf65e0 | 17624 | else |
0f40f9f7 | 17625 | return "call\t%P1"; |
cbbf65e0 | 17626 | } |
cbbf65e0 | 17627 | if (SIBLING_CALL_P (insn)) |
0f40f9f7 | 17628 | return "jmp\t%A1"; |
cbbf65e0 | 17629 | else |
0f40f9f7 ZW |
17630 | return "call\t%A1"; |
17631 | } | |
69404d6f | 17632 | [(set_attr "type" "callv")]) |
9e3e266c GM |
17633 | \f |
17634 | (define_insn "trap" | |
17635 | [(trap_if (const_int 1) (const_int 5))] | |
17636 | "" | |
0f40f9f7 | 17637 | "int\t$5") |
9e3e266c GM |
17638 | |
17639 | ;;; ix86 doesn't have conditional trap instructions, but we fake them | |
17640 | ;;; for the sake of bounds checking. By emitting bounds checks as | |
17641 | ;;; conditional traps rather than as conditional jumps around | |
17642 | ;;; unconditional traps we avoid introducing spurious basic-block | |
17643 | ;;; boundaries and facilitate elimination of redundant checks. In | |
17644 | ;;; honor of the too-inflexible-for-BPs `bound' instruction, we use | |
17645 | ;;; interrupt 5. | |
17646 | ;;; | |
17647 | ;;; FIXME: Static branch prediction rules for ix86 are such that | |
17648 | ;;; forward conditional branches predict as untaken. As implemented | |
17649 | ;;; below, pseudo conditional traps violate that rule. We should use | |
17650 | ;;; .pushsection/.popsection to place all of the `int 5's in a special | |
17651 | ;;; section loaded at the end of the text segment and branch forward | |
17652 | ;;; there on bounds-failure, and then jump back immediately (in case | |
17653 | ;;; the system chooses to ignore bounds violations, or to report | |
17654 | ;;; violations and continue execution). | |
17655 | ||
17656 | (define_expand "conditional_trap" | |
17657 | [(trap_if (match_operator 0 "comparison_operator" | |
17658 | [(match_dup 2) (const_int 0)]) | |
17659 | (match_operand 1 "const_int_operand" ""))] | |
17660 | "" | |
9e3e266c GM |
17661 | { |
17662 | emit_insn (gen_rtx_TRAP_IF (VOIDmode, | |
a1b8572c | 17663 | ix86_expand_compare (GET_CODE (operands[0]), |
df4ae160 | 17664 | NULL, NULL), |
9e3e266c GM |
17665 | operands[1])); |
17666 | DONE; | |
0f40f9f7 | 17667 | }) |
9e3e266c | 17668 | |
0f40f9f7 | 17669 | (define_insn "*conditional_trap_1" |
9e3e266c GM |
17670 | [(trap_if (match_operator 0 "comparison_operator" |
17671 | [(reg 17) (const_int 0)]) | |
17672 | (match_operand 1 "const_int_operand" ""))] | |
17673 | "" | |
9e3e266c GM |
17674 | { |
17675 | operands[2] = gen_label_rtx (); | |
0f40f9f7 ZW |
17676 | output_asm_insn ("j%c0\t%l2\; int\t%1", operands); |
17677 | ASM_OUTPUT_INTERNAL_LABEL (asm_out_file, "L", | |
9e3e266c GM |
17678 | CODE_LABEL_NUMBER (operands[2])); |
17679 | RET; | |
0f40f9f7 | 17680 | }) |
915119a5 BS |
17681 | |
17682 | ;; Pentium III SIMD instructions. | |
17683 | ||
17684 | ;; Moves for SSE/MMX regs. | |
17685 | ||
17686 | (define_insn "movv4sf_internal" | |
17687 | [(set (match_operand:V4SF 0 "nonimmediate_operand" "=x,m") | |
e37af218 | 17688 | (match_operand:V4SF 1 "nonimmediate_operand" "xm,x"))] |
915119a5 BS |
17689 | "TARGET_SSE" |
17690 | ;; @@@ let's try to use movaps here. | |
0f40f9f7 | 17691 | "movaps\t{%1, %0|%0, %1}" |
915119a5 BS |
17692 | [(set_attr "type" "sse")]) |
17693 | ||
17694 | (define_insn "movv4si_internal" | |
17695 | [(set (match_operand:V4SI 0 "nonimmediate_operand" "=x,m") | |
e37af218 | 17696 | (match_operand:V4SI 1 "nonimmediate_operand" "xm,x"))] |
915119a5 BS |
17697 | "TARGET_SSE" |
17698 | ;; @@@ let's try to use movaps here. | |
0f40f9f7 | 17699 | "movaps\t{%1, %0|%0, %1}" |
915119a5 BS |
17700 | [(set_attr "type" "sse")]) |
17701 | ||
17702 | (define_insn "movv8qi_internal" | |
17703 | [(set (match_operand:V8QI 0 "nonimmediate_operand" "=y,m") | |
e37af218 | 17704 | (match_operand:V8QI 1 "nonimmediate_operand" "ym,y"))] |
915119a5 | 17705 | "TARGET_MMX" |
0f40f9f7 | 17706 | "movq\t{%1, %0|%0, %1}" |
915119a5 BS |
17707 | [(set_attr "type" "mmx")]) |
17708 | ||
17709 | (define_insn "movv4hi_internal" | |
17710 | [(set (match_operand:V4HI 0 "nonimmediate_operand" "=y,m") | |
e37af218 | 17711 | (match_operand:V4HI 1 "nonimmediate_operand" "ym,y"))] |
915119a5 | 17712 | "TARGET_MMX" |
0f40f9f7 | 17713 | "movq\t{%1, %0|%0, %1}" |
915119a5 BS |
17714 | [(set_attr "type" "mmx")]) |
17715 | ||
17716 | (define_insn "movv2si_internal" | |
17717 | [(set (match_operand:V2SI 0 "nonimmediate_operand" "=y,m") | |
e37af218 | 17718 | (match_operand:V2SI 1 "nonimmediate_operand" "ym,y"))] |
915119a5 | 17719 | "TARGET_MMX" |
0f40f9f7 | 17720 | "movq\t{%1, %0|%0, %1}" |
915119a5 BS |
17721 | [(set_attr "type" "mmx")]) |
17722 | ||
47f339cf BS |
17723 | (define_insn "movv2sf_internal" |
17724 | [(set (match_operand:V2SF 0 "nonimmediate_operand" "=y,m") | |
e37af218 | 17725 | (match_operand:V2SF 1 "nonimmediate_operand" "ym,y"))] |
47f339cf BS |
17726 | "TARGET_3DNOW" |
17727 | "movq\\t{%1, %0|%0, %1}" | |
17728 | [(set_attr "type" "mmx")]) | |
17729 | ||
915119a5 BS |
17730 | (define_expand "movti" |
17731 | [(set (match_operand:TI 0 "general_operand" "") | |
17732 | (match_operand:TI 1 "general_operand" ""))] | |
44cf5b6a | 17733 | "TARGET_SSE || TARGET_64BIT" |
915119a5 | 17734 | { |
44cf5b6a | 17735 | if (TARGET_64BIT) |
e37af218 RH |
17736 | ix86_expand_move (TImode, operands); |
17737 | else | |
17738 | ix86_expand_vector_move (TImode, operands); | |
17739 | DONE; | |
0f40f9f7 | 17740 | }) |
915119a5 BS |
17741 | |
17742 | (define_expand "movv4sf" | |
17743 | [(set (match_operand:V4SF 0 "general_operand" "") | |
17744 | (match_operand:V4SF 1 "general_operand" ""))] | |
17745 | "TARGET_SSE" | |
915119a5 | 17746 | { |
e37af218 RH |
17747 | ix86_expand_vector_move (V4SFmode, operands); |
17748 | DONE; | |
0f40f9f7 | 17749 | }) |
915119a5 BS |
17750 | |
17751 | (define_expand "movv4si" | |
17752 | [(set (match_operand:V4SI 0 "general_operand" "") | |
17753 | (match_operand:V4SI 1 "general_operand" ""))] | |
17754 | "TARGET_MMX" | |
915119a5 | 17755 | { |
e37af218 RH |
17756 | ix86_expand_vector_move (V4SImode, operands); |
17757 | DONE; | |
0f40f9f7 | 17758 | }) |
915119a5 BS |
17759 | |
17760 | (define_expand "movv2si" | |
17761 | [(set (match_operand:V2SI 0 "general_operand" "") | |
17762 | (match_operand:V2SI 1 "general_operand" ""))] | |
17763 | "TARGET_MMX" | |
915119a5 | 17764 | { |
e37af218 RH |
17765 | ix86_expand_vector_move (V2SImode, operands); |
17766 | DONE; | |
0f40f9f7 | 17767 | }) |
915119a5 BS |
17768 | |
17769 | (define_expand "movv4hi" | |
17770 | [(set (match_operand:V4HI 0 "general_operand" "") | |
17771 | (match_operand:V4HI 1 "general_operand" ""))] | |
17772 | "TARGET_MMX" | |
915119a5 | 17773 | { |
e37af218 RH |
17774 | ix86_expand_vector_move (V4HImode, operands); |
17775 | DONE; | |
0f40f9f7 | 17776 | }) |
915119a5 BS |
17777 | |
17778 | (define_expand "movv8qi" | |
17779 | [(set (match_operand:V8QI 0 "general_operand" "") | |
17780 | (match_operand:V8QI 1 "general_operand" ""))] | |
17781 | "TARGET_MMX" | |
915119a5 | 17782 | { |
e37af218 RH |
17783 | ix86_expand_vector_move (V8QImode, operands); |
17784 | DONE; | |
0f40f9f7 | 17785 | }) |
915119a5 | 17786 | |
47f339cf BS |
17787 | (define_expand "movv2sf" |
17788 | [(set (match_operand:V2SF 0 "general_operand" "") | |
17789 | (match_operand:V2SF 1 "general_operand" ""))] | |
17790 | "TARGET_3DNOW" | |
47f339cf | 17791 | { |
e37af218 RH |
17792 | ix86_expand_vector_move (V2SFmode, operands); |
17793 | DONE; | |
17794 | }) | |
47f339cf | 17795 | |
915119a5 BS |
17796 | (define_insn_and_split "*pushti" |
17797 | [(set (match_operand:TI 0 "push_operand" "=<") | |
17798 | (match_operand:TI 1 "nonmemory_operand" "x"))] | |
17799 | "TARGET_SSE" | |
17800 | "#" | |
17801 | "" | |
17802 | [(set (reg:SI 7) (plus:SI (reg:SI 7) (const_int -16))) | |
17803 | (set (mem:TI (reg:SI 7)) (match_dup 1))] | |
17804 | "" | |
17805 | [(set_attr "type" "sse")]) | |
17806 | ||
17807 | (define_insn_and_split "*pushv4sf" | |
17808 | [(set (match_operand:V4SF 0 "push_operand" "=<") | |
17809 | (match_operand:V4SF 1 "nonmemory_operand" "x"))] | |
17810 | "TARGET_SSE" | |
17811 | "#" | |
17812 | "" | |
17813 | [(set (reg:SI 7) (plus:SI (reg:SI 7) (const_int -16))) | |
17814 | (set (mem:V4SF (reg:SI 7)) (match_dup 1))] | |
17815 | "" | |
17816 | [(set_attr "type" "sse")]) | |
17817 | ||
17818 | (define_insn_and_split "*pushv4si" | |
17819 | [(set (match_operand:V4SI 0 "push_operand" "=<") | |
17820 | (match_operand:V4SI 1 "nonmemory_operand" "x"))] | |
17821 | "TARGET_SSE" | |
17822 | "#" | |
17823 | "" | |
17824 | [(set (reg:SI 7) (plus:SI (reg:SI 7) (const_int -16))) | |
17825 | (set (mem:V4SI (reg:SI 7)) (match_dup 1))] | |
17826 | "" | |
17827 | [(set_attr "type" "sse")]) | |
17828 | ||
17829 | (define_insn_and_split "*pushv2si" | |
17830 | [(set (match_operand:V2SI 0 "push_operand" "=<") | |
17831 | (match_operand:V2SI 1 "nonmemory_operand" "y"))] | |
17832 | "TARGET_MMX" | |
17833 | "#" | |
17834 | "" | |
17835 | [(set (reg:SI 7) (plus:SI (reg:SI 7) (const_int -8))) | |
17836 | (set (mem:V2SI (reg:SI 7)) (match_dup 1))] | |
17837 | "" | |
17838 | [(set_attr "type" "mmx")]) | |
17839 | ||
17840 | (define_insn_and_split "*pushv4hi" | |
17841 | [(set (match_operand:V4HI 0 "push_operand" "=<") | |
17842 | (match_operand:V4HI 1 "nonmemory_operand" "y"))] | |
17843 | "TARGET_MMX" | |
17844 | "#" | |
17845 | "" | |
17846 | [(set (reg:SI 7) (plus:SI (reg:SI 7) (const_int -8))) | |
17847 | (set (mem:V4HI (reg:SI 7)) (match_dup 1))] | |
17848 | "" | |
17849 | [(set_attr "type" "mmx")]) | |
17850 | ||
17851 | (define_insn_and_split "*pushv8qi" | |
17852 | [(set (match_operand:V8QI 0 "push_operand" "=<") | |
17853 | (match_operand:V8QI 1 "nonmemory_operand" "y"))] | |
17854 | "TARGET_MMX" | |
17855 | "#" | |
17856 | "" | |
17857 | [(set (reg:SI 7) (plus:SI (reg:SI 7) (const_int -8))) | |
17858 | (set (mem:V8QI (reg:SI 7)) (match_dup 1))] | |
17859 | "" | |
17860 | [(set_attr "type" "mmx")]) | |
17861 | ||
47f339cf BS |
17862 | (define_insn_and_split "*pushv2sf" |
17863 | [(set (match_operand:V2SF 0 "push_operand" "=<") | |
17864 | (match_operand:V2SF 1 "nonmemory_operand" "y"))] | |
17865 | "TARGET_3DNOW" | |
17866 | "#" | |
17867 | "" | |
17868 | [(set (reg:SI 7) (plus:SI (reg:SI 7) (const_int -8))) | |
17869 | (set (mem:V2SF (reg:SI 7)) (match_dup 1))] | |
17870 | "" | |
17871 | [(set_attr "type" "mmx")]) | |
17872 | ||
915119a5 | 17873 | (define_insn "movti_internal" |
e37af218 RH |
17874 | [(set (match_operand:TI 0 "nonimmediate_operand" "=x,x,m") |
17875 | (match_operand:TI 1 "general_operand" "O,xm,x"))] | |
44cf5b6a | 17876 | "TARGET_SSE && !TARGET_64BIT" |
915119a5 | 17877 | "@ |
e37af218 | 17878 | xorps\t%0, %0 |
0f40f9f7 ZW |
17879 | movaps\t{%1, %0|%0, %1} |
17880 | movaps\t{%1, %0|%0, %1}" | |
915119a5 BS |
17881 | [(set_attr "type" "sse")]) |
17882 | ||
44cf5b6a | 17883 | (define_insn "*movti_rex64" |
e37af218 RH |
17884 | [(set (match_operand:TI 0 "nonimmediate_operand" "=r,o,x,mx,x") |
17885 | (match_operand:TI 1 "general_operand" "riFo,riF,O,x,m"))] | |
44cf5b6a JH |
17886 | "TARGET_64BIT |
17887 | && (GET_CODE (operands[0]) != MEM || GET_CODE (operands[1]) != MEM)" | |
17888 | "@ | |
17889 | # | |
17890 | # | |
e37af218 | 17891 | xorps\t%0, %0 |
44cf5b6a JH |
17892 | movaps\\t{%1, %0|%0, %1} |
17893 | movaps\\t{%1, %0|%0, %1}" | |
e37af218 | 17894 | [(set_attr "type" "*,*,sse,sse,sse") |
44cf5b6a JH |
17895 | (set_attr "mode" "TI")]) |
17896 | ||
17897 | (define_split | |
17898 | [(set (match_operand:TI 0 "nonimmediate_operand" "") | |
17899 | (match_operand:TI 1 "general_operand" ""))] | |
4fe8523b JH |
17900 | "reload_completed && !SSE_REG_P (operands[0]) |
17901 | && !SSE_REG_P (operands[1])" | |
44cf5b6a JH |
17902 | [(const_int 0)] |
17903 | "ix86_split_long_move (operands); DONE;") | |
17904 | ||
915119a5 BS |
17905 | ;; These two patterns are useful for specifying exactly whether to use |
17906 | ;; movaps or movups | |
17907 | (define_insn "sse_movaps" | |
17908 | [(set (match_operand:V4SF 0 "nonimmediate_operand" "=x,m") | |
e37af218 RH |
17909 | (unspec:V4SF |
17910 | [(match_operand:V4SF 1 "nonimmediate_operand" "xm,x")] 38))] | |
915119a5 BS |
17911 | "TARGET_SSE" |
17912 | "@ | |
0f40f9f7 ZW |
17913 | movaps\t{%1, %0|%0, %1} |
17914 | movaps\t{%1, %0|%0, %1}" | |
915119a5 BS |
17915 | [(set_attr "type" "sse")]) |
17916 | ||
17917 | (define_insn "sse_movups" | |
17918 | [(set (match_operand:V4SF 0 "nonimmediate_operand" "=x,m") | |
e37af218 RH |
17919 | (unspec:V4SF |
17920 | [(match_operand:V4SF 1 "nonimmediate_operand" "xm,x")] 39))] | |
915119a5 BS |
17921 | "TARGET_SSE" |
17922 | "@ | |
0f40f9f7 ZW |
17923 | movups\t{%1, %0|%0, %1} |
17924 | movups\t{%1, %0|%0, %1}" | |
915119a5 BS |
17925 | [(set_attr "type" "sse")]) |
17926 | ||
17927 | ||
17928 | ;; SSE Strange Moves. | |
17929 | ||
17930 | (define_insn "sse_movmskps" | |
17931 | [(set (match_operand:SI 0 "register_operand" "=r") | |
17932 | (unspec:SI [(match_operand:V4SF 1 "register_operand" "x")] 33))] | |
17933 | "TARGET_SSE" | |
0f40f9f7 | 17934 | "movmskps\t{%1, %0|%0, %1}" |
915119a5 BS |
17935 | [(set_attr "type" "sse")]) |
17936 | ||
17937 | (define_insn "mmx_pmovmskb" | |
17938 | [(set (match_operand:SI 0 "register_operand" "=r") | |
17939 | (unspec:SI [(match_operand:V8QI 1 "register_operand" "y")] 33))] | |
47f339cf | 17940 | "TARGET_SSE || TARGET_3DNOW_A" |
0f40f9f7 | 17941 | "pmovmskb\t{%1, %0|%0, %1}" |
915119a5 BS |
17942 | [(set_attr "type" "sse")]) |
17943 | ||
17944 | (define_insn "mmx_maskmovq" | |
17945 | [(set (mem:V8QI (match_operand:SI 0 "register_operand" "D")) | |
17946 | (unspec:V8QI [(match_operand:V8QI 1 "register_operand" "y") | |
17947 | (match_operand:V8QI 2 "register_operand" "y")] 32))] | |
47f339cf | 17948 | "TARGET_SSE || TARGET_3DNOW_A" |
915119a5 | 17949 | ;; @@@ check ordering of operands in intel/nonintel syntax |
0f40f9f7 | 17950 | "maskmovq\t{%2, %1|%1, %2}" |
915119a5 BS |
17951 | [(set_attr "type" "sse")]) |
17952 | ||
17953 | (define_insn "sse_movntv4sf" | |
17954 | [(set (match_operand:V4SF 0 "memory_operand" "=m") | |
17955 | (unspec:V4SF [(match_operand:V4SF 1 "register_operand" "x")] 34))] | |
17956 | "TARGET_SSE" | |
0f40f9f7 | 17957 | "movntps\t{%1, %0|%0, %1}" |
915119a5 BS |
17958 | [(set_attr "type" "sse")]) |
17959 | ||
17960 | (define_insn "sse_movntdi" | |
17961 | [(set (match_operand:DI 0 "memory_operand" "=m") | |
332316cd | 17962 | (unspec:DI [(match_operand:DI 1 "register_operand" "y")] 34))] |
47f339cf | 17963 | "TARGET_SSE || TARGET_3DNOW_A" |
0f40f9f7 | 17964 | "movntq\t{%1, %0|%0, %1}" |
915119a5 BS |
17965 | [(set_attr "type" "sse")]) |
17966 | ||
17967 | (define_insn "sse_movhlps" | |
17968 | [(set (match_operand:V4SF 0 "register_operand" "=x") | |
17969 | (vec_merge:V4SF | |
17970 | (match_operand:V4SF 1 "register_operand" "0") | |
17971 | (vec_select:V4SF (match_operand:V4SF 2 "register_operand" "x") | |
17972 | (parallel [(const_int 2) | |
17973 | (const_int 3) | |
17974 | (const_int 0) | |
17975 | (const_int 1)])) | |
17976 | (const_int 3)))] | |
17977 | "TARGET_SSE" | |
0f40f9f7 | 17978 | "movhlps\t{%2, %0|%0, %2}" |
915119a5 BS |
17979 | [(set_attr "type" "sse")]) |
17980 | ||
17981 | (define_insn "sse_movlhps" | |
17982 | [(set (match_operand:V4SF 0 "register_operand" "=x") | |
17983 | (vec_merge:V4SF | |
17984 | (match_operand:V4SF 1 "register_operand" "0") | |
17985 | (vec_select:V4SF (match_operand:V4SF 2 "register_operand" "x") | |
17986 | (parallel [(const_int 2) | |
17987 | (const_int 3) | |
17988 | (const_int 0) | |
17989 | (const_int 1)])) | |
17990 | (const_int 12)))] | |
17991 | "TARGET_SSE" | |
0f40f9f7 | 17992 | "movlhps\t{%2, %0|%0, %2}" |
915119a5 BS |
17993 | [(set_attr "type" "sse")]) |
17994 | ||
17995 | (define_insn "sse_movhps" | |
17996 | [(set (match_operand:V4SF 0 "nonimmediate_operand" "=x,m") | |
17997 | (vec_merge:V4SF | |
17998 | (match_operand:V4SF 1 "nonimmediate_operand" "0,0") | |
17999 | (match_operand:V4SF 2 "nonimmediate_operand" "m,x") | |
18000 | (const_int 12)))] | |
e37af218 RH |
18001 | "TARGET_SSE |
18002 | && (GET_CODE (operands[1]) == MEM || GET_CODE (operands[2]) == MEM)" | |
0f40f9f7 | 18003 | "movhps\t{%2, %0|%0, %2}" |
915119a5 BS |
18004 | [(set_attr "type" "sse")]) |
18005 | ||
18006 | (define_insn "sse_movlps" | |
18007 | [(set (match_operand:V4SF 0 "nonimmediate_operand" "=x,m") | |
18008 | (vec_merge:V4SF | |
18009 | (match_operand:V4SF 1 "nonimmediate_operand" "0,0") | |
18010 | (match_operand:V4SF 2 "nonimmediate_operand" "m,x") | |
18011 | (const_int 3)))] | |
e37af218 RH |
18012 | "TARGET_SSE |
18013 | && (GET_CODE (operands[1]) == MEM || GET_CODE (operands[2]) == MEM)" | |
0f40f9f7 | 18014 | "movlps\t{%2, %0|%0, %2}" |
915119a5 BS |
18015 | [(set_attr "type" "sse")]) |
18016 | ||
18017 | (define_insn "sse_loadss" | |
18018 | [(set (match_operand:V4SF 0 "register_operand" "=x") | |
18019 | (vec_merge:V4SF | |
18020 | (match_operand:V4SF 1 "memory_operand" "m") | |
18021 | (vec_duplicate:V4SF (float:SF (const_int 0))) | |
18022 | (const_int 1)))] | |
18023 | "TARGET_SSE" | |
0f40f9f7 | 18024 | "movss\t{%1, %0|%0, %1}" |
915119a5 BS |
18025 | [(set_attr "type" "sse")]) |
18026 | ||
18027 | (define_insn "sse_movss" | |
18028 | [(set (match_operand:V4SF 0 "register_operand" "=x") | |
18029 | (vec_merge:V4SF | |
18030 | (match_operand:V4SF 1 "register_operand" "0") | |
18031 | (match_operand:V4SF 2 "register_operand" "x") | |
18032 | (const_int 1)))] | |
18033 | "TARGET_SSE" | |
0f40f9f7 | 18034 | "movss\t{%2, %0|%0, %2}" |
915119a5 BS |
18035 | [(set_attr "type" "sse")]) |
18036 | ||
18037 | (define_insn "sse_storess" | |
18038 | [(set (match_operand:SF 0 "memory_operand" "=m") | |
18039 | (vec_select:SF | |
18040 | (match_operand:V4SF 1 "register_operand" "x") | |
18041 | (parallel [(const_int 0)])))] | |
18042 | "TARGET_SSE" | |
0f40f9f7 | 18043 | "movss\t{%1, %0|%0, %1}" |
915119a5 BS |
18044 | [(set_attr "type" "sse")]) |
18045 | ||
18046 | (define_insn "sse_shufps" | |
18047 | [(set (match_operand:V4SF 0 "register_operand" "=x") | |
18048 | (unspec:V4SF [(match_operand:V4SF 1 "register_operand" "0") | |
18049 | (match_operand:V4SF 2 "nonimmediate_operand" "xm") | |
18050 | (match_operand:SI 3 "immediate_operand" "i")] 41))] | |
18051 | "TARGET_SSE" | |
18052 | ;; @@@ check operand order for intel/nonintel syntax | |
0f40f9f7 | 18053 | "shufps\t{%3, %2, %0|%0, %2, %3}" |
915119a5 BS |
18054 | [(set_attr "type" "sse")]) |
18055 | ||
18056 | ||
18057 | ;; SSE arithmetic | |
18058 | ||
18059 | (define_insn "addv4sf3" | |
18060 | [(set (match_operand:V4SF 0 "register_operand" "=x") | |
18061 | (plus:V4SF (match_operand:V4SF 1 "register_operand" "0") | |
18062 | (match_operand:V4SF 2 "nonimmediate_operand" "xm")))] | |
18063 | "TARGET_SSE" | |
0f40f9f7 | 18064 | "addps\t{%2, %0|%0, %2}" |
915119a5 BS |
18065 | [(set_attr "type" "sse")]) |
18066 | ||
18067 | (define_insn "vmaddv4sf3" | |
18068 | [(set (match_operand:V4SF 0 "register_operand" "=x") | |
e37af218 RH |
18069 | (vec_merge:V4SF |
18070 | (plus:V4SF (match_operand:V4SF 1 "register_operand" "0") | |
18071 | (match_operand:V4SF 2 "nonimmediate_operand" "xm")) | |
18072 | (match_dup 1) | |
18073 | (const_int 1)))] | |
915119a5 | 18074 | "TARGET_SSE" |
0f40f9f7 | 18075 | "addss\t{%2, %0|%0, %2}" |
915119a5 BS |
18076 | [(set_attr "type" "sse")]) |
18077 | ||
18078 | (define_insn "subv4sf3" | |
18079 | [(set (match_operand:V4SF 0 "register_operand" "=x") | |
18080 | (minus:V4SF (match_operand:V4SF 1 "register_operand" "0") | |
e37af218 | 18081 | (match_operand:V4SF 2 "nonimmediate_operand" "xm")))] |
915119a5 | 18082 | "TARGET_SSE" |
0f40f9f7 | 18083 | "subps\t{%2, %0|%0, %2}" |
915119a5 BS |
18084 | [(set_attr "type" "sse")]) |
18085 | ||
18086 | (define_insn "vmsubv4sf3" | |
18087 | [(set (match_operand:V4SF 0 "register_operand" "=x") | |
e37af218 RH |
18088 | (vec_merge:V4SF |
18089 | (minus:V4SF (match_operand:V4SF 1 "register_operand" "0") | |
18090 | (match_operand:V4SF 2 "nonimmediate_operand" "xm")) | |
18091 | (match_dup 1) | |
18092 | (const_int 1)))] | |
915119a5 | 18093 | "TARGET_SSE" |
0f40f9f7 | 18094 | "subss\t{%2, %0|%0, %2}" |
915119a5 BS |
18095 | [(set_attr "type" "sse")]) |
18096 | ||
18097 | (define_insn "mulv4sf3" | |
18098 | [(set (match_operand:V4SF 0 "register_operand" "=x") | |
18099 | (mult:V4SF (match_operand:V4SF 1 "register_operand" "0") | |
18100 | (match_operand:V4SF 2 "nonimmediate_operand" "xm")))] | |
18101 | "TARGET_SSE" | |
0f40f9f7 | 18102 | "mulps\t{%2, %0|%0, %2}" |
915119a5 BS |
18103 | [(set_attr "type" "sse")]) |
18104 | ||
18105 | (define_insn "vmmulv4sf3" | |
18106 | [(set (match_operand:V4SF 0 "register_operand" "=x") | |
e37af218 RH |
18107 | (vec_merge:V4SF |
18108 | (mult:V4SF (match_operand:V4SF 1 "register_operand" "0") | |
18109 | (match_operand:V4SF 2 "nonimmediate_operand" "xm")) | |
18110 | (match_dup 1) | |
18111 | (const_int 1)))] | |
915119a5 | 18112 | "TARGET_SSE" |
0f40f9f7 | 18113 | "mulss\t{%2, %0|%0, %2}" |
915119a5 BS |
18114 | [(set_attr "type" "sse")]) |
18115 | ||
18116 | (define_insn "divv4sf3" | |
18117 | [(set (match_operand:V4SF 0 "register_operand" "=x") | |
18118 | (div:V4SF (match_operand:V4SF 1 "register_operand" "0") | |
18119 | (match_operand:V4SF 2 "nonimmediate_operand" "xm")))] | |
18120 | "TARGET_SSE" | |
0f40f9f7 | 18121 | "divps\t{%2, %0|%0, %2}" |
915119a5 BS |
18122 | [(set_attr "type" "sse")]) |
18123 | ||
18124 | (define_insn "vmdivv4sf3" | |
18125 | [(set (match_operand:V4SF 0 "register_operand" "=x") | |
e37af218 RH |
18126 | (vec_merge:V4SF |
18127 | (div:V4SF (match_operand:V4SF 1 "register_operand" "0") | |
18128 | (match_operand:V4SF 2 "nonimmediate_operand" "xm")) | |
18129 | (match_dup 1) | |
18130 | (const_int 1)))] | |
915119a5 | 18131 | "TARGET_SSE" |
0f40f9f7 | 18132 | "divss\t{%2, %0|%0, %2}" |
915119a5 BS |
18133 | [(set_attr "type" "sse")]) |
18134 | ||
18135 | ||
18136 | ;; SSE square root/reciprocal | |
18137 | ||
18138 | (define_insn "rcpv4sf2" | |
18139 | [(set (match_operand:V4SF 0 "register_operand" "=x") | |
e37af218 RH |
18140 | (unspec:V4SF |
18141 | [(match_operand:V4SF 1 "nonimmediate_operand" "xm")] 42))] | |
915119a5 | 18142 | "TARGET_SSE" |
0f40f9f7 | 18143 | "rcpps\t{%1, %0|%0, %1}" |
915119a5 BS |
18144 | [(set_attr "type" "sse")]) |
18145 | ||
18146 | (define_insn "vmrcpv4sf2" | |
18147 | [(set (match_operand:V4SF 0 "register_operand" "=x") | |
e37af218 RH |
18148 | (vec_merge:V4SF |
18149 | (unspec:V4SF [(match_operand:V4SF 1 "nonimmediate_operand" "xm")] 42) | |
18150 | (match_operand:V4SF 2 "register_operand" "0") | |
18151 | (const_int 1)))] | |
915119a5 | 18152 | "TARGET_SSE" |
0f40f9f7 | 18153 | "rcpss\t{%1, %0|%0, %1}" |
915119a5 BS |
18154 | [(set_attr "type" "sse")]) |
18155 | ||
18156 | (define_insn "rsqrtv4sf2" | |
18157 | [(set (match_operand:V4SF 0 "register_operand" "=x") | |
e37af218 RH |
18158 | (unspec:V4SF |
18159 | [(match_operand:V4SF 1 "nonimmediate_operand" "xm")] 43))] | |
915119a5 | 18160 | "TARGET_SSE" |
0f40f9f7 | 18161 | "rsqrtps\t{%1, %0|%0, %1}" |
915119a5 BS |
18162 | [(set_attr "type" "sse")]) |
18163 | ||
18164 | (define_insn "vmrsqrtv4sf2" | |
18165 | [(set (match_operand:V4SF 0 "register_operand" "=x") | |
e37af218 RH |
18166 | (vec_merge:V4SF |
18167 | (unspec:V4SF [(match_operand:V4SF 1 "nonimmediate_operand" "xm")] 43) | |
18168 | (match_operand:V4SF 2 "register_operand" "0") | |
18169 | (const_int 1)))] | |
915119a5 | 18170 | "TARGET_SSE" |
0f40f9f7 | 18171 | "rsqrtss\t{%1, %0|%0, %1}" |
915119a5 BS |
18172 | [(set_attr "type" "sse")]) |
18173 | ||
18174 | (define_insn "sqrtv4sf2" | |
18175 | [(set (match_operand:V4SF 0 "register_operand" "=x") | |
e37af218 | 18176 | (sqrt:V4SF (match_operand:V4SF 1 "nonimmediate_operand" "xm")))] |
915119a5 | 18177 | "TARGET_SSE" |
0f40f9f7 | 18178 | "sqrtps\t{%1, %0|%0, %1}" |
915119a5 BS |
18179 | [(set_attr "type" "sse")]) |
18180 | ||
18181 | (define_insn "vmsqrtv4sf2" | |
18182 | [(set (match_operand:V4SF 0 "register_operand" "=x") | |
e37af218 RH |
18183 | (vec_merge:V4SF |
18184 | (sqrt:V4SF (match_operand:V4SF 1 "nonimmediate_operand" "xm")) | |
18185 | (match_operand:V4SF 2 "register_operand" "0") | |
18186 | (const_int 1)))] | |
915119a5 | 18187 | "TARGET_SSE" |
0f40f9f7 | 18188 | "sqrtss\t{%1, %0|%0, %1}" |
915119a5 BS |
18189 | [(set_attr "type" "sse")]) |
18190 | ||
915119a5 BS |
18191 | ;; SSE logical operations. |
18192 | ||
18193 | ;; These are not called andti3 etc. because we really really don't want | |
18194 | ;; the compiler to widen DImode ands to TImode ands and then try to move | |
18195 | ;; into DImode subregs of SSE registers, and them together, and move out | |
18196 | ;; of DImode subregs again! | |
18197 | ||
c679d048 JH |
18198 | (define_insn "*sse_andti3_df_1" |
18199 | [(set (subreg:TI (match_operand:DF 0 "register_operand" "=Y") 0) | |
18200 | (and:TI (subreg:TI (match_operand:DF 1 "register_operand" "%0") 0) | |
18201 | (subreg:TI (match_operand:DF 2 "register_operand" "Y") 0)))] | |
18202 | "TARGET_SSE2" | |
0f40f9f7 | 18203 | "andpd\t{%2, %0|%0, %2}" |
c679d048 JH |
18204 | [(set_attr "type" "sse")]) |
18205 | ||
18206 | (define_insn "*sse_andti3_df_2" | |
18207 | [(set (subreg:TI (match_operand:DF 0 "register_operand" "=Y") 0) | |
18208 | (and:TI (subreg:TI (match_operand:DF 1 "register_operand" "0") 0) | |
18209 | (match_operand:TI 2 "nonimmediate_operand" "Ym")))] | |
18210 | "TARGET_SSE2" | |
0f40f9f7 | 18211 | "andpd\t{%2, %0|%0, %2}" |
c679d048 JH |
18212 | [(set_attr "type" "sse")]) |
18213 | ||
18214 | (define_insn "*sse_andti3_sf_1" | |
18215 | [(set (subreg:TI (match_operand:SF 0 "register_operand" "=x") 0) | |
18216 | (and:TI (subreg:TI (match_operand:SF 1 "register_operand" "%0") 0) | |
18217 | (subreg:TI (match_operand:SF 2 "register_operand" "x") 0)))] | |
18218 | "TARGET_SSE" | |
0f40f9f7 | 18219 | "andps\t{%2, %0|%0, %2}" |
c679d048 JH |
18220 | [(set_attr "type" "sse")]) |
18221 | ||
18222 | (define_insn "*sse_andti3_sf_2" | |
18223 | [(set (subreg:TI (match_operand:SF 0 "register_operand" "=x") 0) | |
18224 | (and:TI (subreg:TI (match_operand:SF 1 "register_operand" "0") 0) | |
18225 | (match_operand:TI 2 "nonimmediate_operand" "xm")))] | |
18226 | "TARGET_SSE" | |
0f40f9f7 | 18227 | "andps\t{%2, %0|%0, %2}" |
c679d048 JH |
18228 | [(set_attr "type" "sse")]) |
18229 | ||
915119a5 BS |
18230 | (define_insn "sse_andti3" |
18231 | [(set (match_operand:TI 0 "register_operand" "=x") | |
c679d048 | 18232 | (and:TI (match_operand:TI 1 "register_operand" "%0") |
915119a5 | 18233 | (match_operand:TI 2 "nonimmediate_operand" "xm")))] |
c679d048 | 18234 | "TARGET_SSE && !TARGET_SSE2" |
0f40f9f7 | 18235 | "andps\t{%2, %0|%0, %2}" |
915119a5 BS |
18236 | [(set_attr "type" "sse")]) |
18237 | ||
c679d048 JH |
18238 | (define_insn "*sse_andti3_sse2" |
18239 | [(set (match_operand:TI 0 "register_operand" "=x") | |
18240 | (and:TI (match_operand:TI 1 "register_operand" "%0") | |
18241 | (match_operand:TI 2 "nonimmediate_operand" "xm")))] | |
18242 | "TARGET_SSE2" | |
0f40f9f7 | 18243 | "pand\t{%2, %0|%0, %2}" |
c679d048 JH |
18244 | [(set_attr "type" "sse")]) |
18245 | ||
18246 | (define_insn "*sse_nandti3_df" | |
18247 | [(set (subreg:TI (match_operand:DF 0 "register_operand" "=Y") 0) | |
18248 | (and:TI (not:TI (subreg:TI (match_operand:DF 1 "register_operand" "0") 0)) | |
18249 | (match_operand:TI 2 "nonimmediate_operand" "Ym")))] | |
18250 | "TARGET_SSE2" | |
0f40f9f7 | 18251 | "andnpd\t{%2, %0|%0, %2}" |
c679d048 JH |
18252 | [(set_attr "type" "sse")]) |
18253 | ||
18254 | (define_insn "*sse_nandti3_sf" | |
18255 | [(set (subreg:TI (match_operand:SF 0 "register_operand" "=x") 0) | |
18256 | (and:TI (not:TI (subreg:TI (match_operand:SF 1 "register_operand" "0") 0)) | |
18257 | (match_operand:TI 2 "nonimmediate_operand" "xm")))] | |
18258 | "TARGET_SSE" | |
0f40f9f7 | 18259 | "andnps\t{%2, %0|%0, %2}" |
c679d048 JH |
18260 | [(set_attr "type" "sse")]) |
18261 | ||
915119a5 BS |
18262 | (define_insn "sse_nandti3" |
18263 | [(set (match_operand:TI 0 "register_operand" "=x") | |
18264 | (and:TI (not:TI (match_operand:TI 1 "register_operand" "0")) | |
18265 | (match_operand:TI 2 "nonimmediate_operand" "xm")))] | |
c679d048 | 18266 | "TARGET_SSE && !TARGET_SSE2" |
0f40f9f7 | 18267 | "andnps\t{%2, %0|%0, %2}" |
915119a5 BS |
18268 | [(set_attr "type" "sse")]) |
18269 | ||
c679d048 JH |
18270 | (define_insn "*sse_nandti3_sse2" |
18271 | [(set (match_operand:TI 0 "register_operand" "=x") | |
18272 | (and:TI (not:TI (match_operand:TI 1 "register_operand" "0")) | |
18273 | (match_operand:TI 2 "nonimmediate_operand" "xm")))] | |
18274 | "TARGET_SSE2" | |
0f40f9f7 | 18275 | "pnand\t{%2, %0|%0, %2}" |
c679d048 JH |
18276 | [(set_attr "type" "sse")]) |
18277 | ||
18278 | (define_insn "*sse_iorti3_df_1" | |
18279 | [(set (subreg:TI (match_operand:DF 0 "register_operand" "=Y") 0) | |
18280 | (ior:TI (subreg:TI (match_operand:DF 1 "register_operand" "%0") 0) | |
18281 | (subreg:TI (match_operand:DF 2 "register_operand" "Y") 0)))] | |
18282 | "TARGET_SSE2" | |
0f40f9f7 | 18283 | "orpd\t{%2, %0|%0, %2}" |
c679d048 JH |
18284 | [(set_attr "type" "sse")]) |
18285 | ||
18286 | (define_insn "*sse_iorti3_df_2" | |
18287 | [(set (subreg:TI (match_operand:DF 0 "register_operand" "=Y") 0) | |
18288 | (ior:TI (subreg:TI (match_operand:DF 1 "register_operand" "0") 0) | |
18289 | (match_operand:TI 2 "nonimmediate_operand" "Ym")))] | |
18290 | "TARGET_SSE2" | |
0f40f9f7 | 18291 | "orpd\t{%2, %0|%0, %2}" |
c679d048 JH |
18292 | [(set_attr "type" "sse")]) |
18293 | ||
18294 | (define_insn "*sse_iorti3_sf_1" | |
18295 | [(set (subreg:TI (match_operand:SF 0 "register_operand" "=x") 0) | |
18296 | (ior:TI (subreg:TI (match_operand:SF 1 "register_operand" "%0") 0) | |
18297 | (subreg:TI (match_operand:SF 2 "register_operand" "x") 0)))] | |
18298 | "TARGET_SSE" | |
0f40f9f7 | 18299 | "orps\t{%2, %0|%0, %2}" |
c679d048 JH |
18300 | [(set_attr "type" "sse")]) |
18301 | ||
18302 | (define_insn "*sse_iorti3_sf_2" | |
18303 | [(set (subreg:TI (match_operand:SF 0 "register_operand" "=x") 0) | |
18304 | (ior:TI (subreg:TI (match_operand:SF 1 "register_operand" "0") 0) | |
18305 | (match_operand:TI 2 "nonimmediate_operand" "xm")))] | |
18306 | "TARGET_SSE" | |
0f40f9f7 | 18307 | "orps\t{%2, %0|%0, %2}" |
c679d048 JH |
18308 | [(set_attr "type" "sse")]) |
18309 | ||
915119a5 BS |
18310 | (define_insn "sse_iorti3" |
18311 | [(set (match_operand:TI 0 "register_operand" "=x") | |
c679d048 JH |
18312 | (ior:TI (match_operand:TI 1 "register_operand" "%0") |
18313 | (match_operand:TI 2 "nonimmediate_operand" "xm")))] | |
18314 | "TARGET_SSE && !TARGET_SSE2" | |
0f40f9f7 | 18315 | "orps\t{%2, %0|%0, %2}" |
c679d048 JH |
18316 | [(set_attr "type" "sse")]) |
18317 | ||
18318 | (define_insn "*sse_iorti3_sse2" | |
18319 | [(set (match_operand:TI 0 "register_operand" "=x") | |
18320 | (ior:TI (match_operand:TI 1 "register_operand" "%0") | |
18321 | (match_operand:TI 2 "nonimmediate_operand" "xm")))] | |
18322 | "TARGET_SSE2" | |
0f40f9f7 | 18323 | "por\t{%2, %0|%0, %2}" |
c679d048 JH |
18324 | [(set_attr "type" "sse")]) |
18325 | ||
18326 | (define_insn "*sse_xorti3_df_1" | |
18327 | [(set (subreg:TI (match_operand:DF 0 "register_operand" "=Y") 0) | |
18328 | (xor:TI (subreg:TI (match_operand:DF 1 "register_operand" "%0") 0) | |
18329 | (subreg:TI (match_operand:DF 2 "register_operand" "Y") 0)))] | |
18330 | "TARGET_SSE2" | |
0f40f9f7 | 18331 | "xorpd\t{%2, %0|%0, %2}" |
c679d048 JH |
18332 | [(set_attr "type" "sse")]) |
18333 | ||
18334 | (define_insn "*sse_xorti3_df_2" | |
18335 | [(set (subreg:TI (match_operand:DF 0 "register_operand" "=Y") 0) | |
18336 | (xor:TI (subreg:TI (match_operand:DF 1 "register_operand" "0") 0) | |
18337 | (match_operand:TI 2 "nonimmediate_operand" "Ym")))] | |
18338 | "TARGET_SSE2" | |
0f40f9f7 | 18339 | "xorpd\t{%2, %0|%0, %2}" |
c679d048 JH |
18340 | [(set_attr "type" "sse")]) |
18341 | ||
18342 | (define_insn "*sse_xorti3_sf_1" | |
18343 | [(set (subreg:TI (match_operand:SF 0 "register_operand" "=x") 0) | |
18344 | (xor:TI (subreg:TI (match_operand:SF 1 "register_operand" "%0") 0) | |
18345 | (subreg:TI (match_operand:SF 2 "register_operand" "x") 0)))] | |
18346 | "TARGET_SSE" | |
0f40f9f7 | 18347 | "xorps\t{%2, %0|%0, %2}" |
c679d048 JH |
18348 | [(set_attr "type" "sse")]) |
18349 | ||
18350 | (define_insn "*sse_xorti3_sf_2" | |
18351 | [(set (subreg:TI (match_operand:SF 0 "register_operand" "=x") 0) | |
18352 | (xor:TI (subreg:TI (match_operand:SF 1 "register_operand" "0") 0) | |
915119a5 BS |
18353 | (match_operand:TI 2 "nonimmediate_operand" "xm")))] |
18354 | "TARGET_SSE" | |
0f40f9f7 | 18355 | "xorps\t{%2, %0|%0, %2}" |
915119a5 BS |
18356 | [(set_attr "type" "sse")]) |
18357 | ||
18358 | (define_insn "sse_xorti3" | |
18359 | [(set (match_operand:TI 0 "register_operand" "=x") | |
c679d048 | 18360 | (xor:TI (match_operand:TI 1 "register_operand" "%0") |
915119a5 | 18361 | (match_operand:TI 2 "nonimmediate_operand" "xm")))] |
c679d048 | 18362 | "TARGET_SSE && !TARGET_SSE2" |
0f40f9f7 | 18363 | "xorps\t{%2, %0|%0, %2}" |
915119a5 BS |
18364 | [(set_attr "type" "sse")]) |
18365 | ||
c679d048 JH |
18366 | (define_insn "*sse_xorti3_sse2" |
18367 | [(set (match_operand:TI 0 "register_operand" "=x") | |
18368 | (xor:TI (match_operand:TI 1 "register_operand" "%0") | |
18369 | (match_operand:TI 2 "nonimmediate_operand" "xm")))] | |
18370 | "TARGET_SSE2" | |
0f40f9f7 | 18371 | "pxor\t{%2, %0|%0, %2}" |
c679d048 JH |
18372 | [(set_attr "type" "sse")]) |
18373 | ||
915119a5 BS |
18374 | ;; Use xor, but don't show input operands so they aren't live before |
18375 | ;; this insn. | |
e37af218 RH |
18376 | (define_insn "sse_clrv4sf" |
18377 | [(set (match_operand:V4SF 0 "register_operand" "=x") | |
18378 | (unspec:V4SF [(const_int 0)] 45))] | |
915119a5 | 18379 | "TARGET_SSE" |
0f40f9f7 | 18380 | "xorps\t{%0, %0|%0, %0}" |
29628f27 BS |
18381 | [(set_attr "type" "sse") |
18382 | (set_attr "memory" "none")]) | |
915119a5 BS |
18383 | |
18384 | ;; SSE mask-generating compares | |
18385 | ||
18386 | (define_insn "maskcmpv4sf3" | |
18387 | [(set (match_operand:V4SI 0 "register_operand" "=x") | |
18388 | (match_operator:V4SI 3 "sse_comparison_operator" | |
e37af218 RH |
18389 | [(match_operand:V4SF 1 "register_operand" "0") |
18390 | (match_operand:V4SF 2 "register_operand" "x")]))] | |
915119a5 | 18391 | "TARGET_SSE" |
0f40f9f7 | 18392 | "cmp%D3ps\t{%2, %0|%0, %2}" |
915119a5 BS |
18393 | [(set_attr "type" "sse")]) |
18394 | ||
18395 | (define_insn "maskncmpv4sf3" | |
18396 | [(set (match_operand:V4SI 0 "register_operand" "=x") | |
18397 | (not:V4SI | |
18398 | (match_operator:V4SI 3 "sse_comparison_operator" | |
e37af218 RH |
18399 | [(match_operand:V4SF 1 "register_operand" "0") |
18400 | (match_operand:V4SF 2 "register_operand" "x")])))] | |
915119a5 | 18401 | "TARGET_SSE" |
29628f27 BS |
18402 | { |
18403 | if (GET_CODE (operands[3]) == UNORDERED) | |
e37af218 RH |
18404 | return "cmpordps\t{%2, %0|%0, %2}"; |
18405 | else | |
18406 | return "cmpn%D3ps\t{%2, %0|%0, %2}"; | |
18407 | } | |
915119a5 BS |
18408 | [(set_attr "type" "sse")]) |
18409 | ||
18410 | (define_insn "vmmaskcmpv4sf3" | |
18411 | [(set (match_operand:V4SI 0 "register_operand" "=x") | |
18412 | (vec_merge:V4SI | |
18413 | (match_operator:V4SI 3 "sse_comparison_operator" | |
e37af218 RH |
18414 | [(match_operand:V4SF 1 "register_operand" "0") |
18415 | (match_operand:V4SF 2 "register_operand" "x")]) | |
915119a5 BS |
18416 | (match_dup 1) |
18417 | (const_int 1)))] | |
18418 | "TARGET_SSE" | |
0f40f9f7 | 18419 | "cmp%D3ss\t{%2, %0|%0, %2}" |
915119a5 BS |
18420 | [(set_attr "type" "sse")]) |
18421 | ||
18422 | (define_insn "vmmaskncmpv4sf3" | |
18423 | [(set (match_operand:V4SI 0 "register_operand" "=x") | |
18424 | (vec_merge:V4SI | |
18425 | (not:V4SI | |
18426 | (match_operator:V4SI 3 "sse_comparison_operator" | |
e37af218 RH |
18427 | [(match_operand:V4SF 1 "register_operand" "0") |
18428 | (match_operand:V4SF 2 "register_operand" "x")])) | |
915119a5 BS |
18429 | (subreg:V4SI (match_dup 1) 0) |
18430 | (const_int 1)))] | |
18431 | "TARGET_SSE" | |
29628f27 BS |
18432 | { |
18433 | if (GET_CODE (operands[3]) == UNORDERED) | |
e37af218 RH |
18434 | return "cmpordss\t{%2, %0|%0, %2}"; |
18435 | else | |
18436 | return "cmpn%D3ss\t{%2, %0|%0, %2}"; | |
18437 | } | |
915119a5 BS |
18438 | [(set_attr "type" "sse")]) |
18439 | ||
18440 | (define_insn "sse_comi" | |
18441 | [(set (reg:CCFP 17) | |
18442 | (match_operator:CCFP 2 "sse_comparison_operator" | |
18443 | [(vec_select:SF | |
18444 | (match_operand:V4SF 0 "register_operand" "x") | |
18445 | (parallel [(const_int 0)])) | |
18446 | (vec_select:SF | |
18447 | (match_operand:V4SF 1 "register_operand" "x") | |
18448 | (parallel [(const_int 0)]))]))] | |
18449 | "TARGET_SSE" | |
21e1b5f1 | 18450 | "comiss\t{%1, %0|%0, %1}" |
915119a5 BS |
18451 | [(set_attr "type" "sse")]) |
18452 | ||
18453 | (define_insn "sse_ucomi" | |
18454 | [(set (reg:CCFPU 17) | |
18455 | (match_operator:CCFPU 2 "sse_comparison_operator" | |
18456 | [(vec_select:SF | |
18457 | (match_operand:V4SF 0 "register_operand" "x") | |
18458 | (parallel [(const_int 0)])) | |
18459 | (vec_select:SF | |
18460 | (match_operand:V4SF 1 "register_operand" "x") | |
18461 | (parallel [(const_int 0)]))]))] | |
18462 | "TARGET_SSE" | |
21e1b5f1 | 18463 | "ucomiss\t{%1, %0|%0, %1}" |
915119a5 BS |
18464 | [(set_attr "type" "sse")]) |
18465 | ||
18466 | ||
18467 | ;; SSE unpack | |
18468 | ||
18469 | (define_insn "sse_unpckhps" | |
18470 | [(set (match_operand:V4SF 0 "register_operand" "=x") | |
18471 | (vec_merge:V4SF | |
18472 | (vec_select:V4SF (match_operand:V4SF 1 "register_operand" "0") | |
18473 | (parallel [(const_int 2) | |
18474 | (const_int 0) | |
18475 | (const_int 3) | |
18476 | (const_int 1)])) | |
21e1b5f1 | 18477 | (vec_select:V4SF (match_operand:V4SF 2 "register_operand" "x") |
915119a5 BS |
18478 | (parallel [(const_int 0) |
18479 | (const_int 2) | |
18480 | (const_int 1) | |
18481 | (const_int 3)])) | |
18482 | (const_int 5)))] | |
18483 | "TARGET_SSE" | |
0f40f9f7 | 18484 | "unpckhps\t{%2, %0|%0, %2}" |
915119a5 BS |
18485 | [(set_attr "type" "sse")]) |
18486 | ||
18487 | (define_insn "sse_unpcklps" | |
18488 | [(set (match_operand:V4SF 0 "register_operand" "=x") | |
18489 | (vec_merge:V4SF | |
18490 | (vec_select:V4SF (match_operand:V4SF 1 "register_operand" "0") | |
18491 | (parallel [(const_int 0) | |
18492 | (const_int 2) | |
18493 | (const_int 1) | |
18494 | (const_int 3)])) | |
21e1b5f1 | 18495 | (vec_select:V4SF (match_operand:V4SF 2 "register_operand" "x") |
915119a5 BS |
18496 | (parallel [(const_int 2) |
18497 | (const_int 0) | |
18498 | (const_int 3) | |
18499 | (const_int 1)])) | |
18500 | (const_int 5)))] | |
18501 | "TARGET_SSE" | |
0f40f9f7 | 18502 | "unpcklps\t{%2, %0|%0, %2}" |
915119a5 BS |
18503 | [(set_attr "type" "sse")]) |
18504 | ||
18505 | ||
18506 | ;; SSE min/max | |
18507 | ||
18508 | (define_insn "smaxv4sf3" | |
18509 | [(set (match_operand:V4SF 0 "register_operand" "=x") | |
18510 | (smax:V4SF (match_operand:V4SF 1 "register_operand" "0") | |
18511 | (match_operand:V4SF 2 "nonimmediate_operand" "xm")))] | |
18512 | "TARGET_SSE" | |
0f40f9f7 | 18513 | "maxps\t{%2, %0|%0, %2}" |
915119a5 BS |
18514 | [(set_attr "type" "sse")]) |
18515 | ||
18516 | (define_insn "vmsmaxv4sf3" | |
18517 | [(set (match_operand:V4SF 0 "register_operand" "=x") | |
e37af218 RH |
18518 | (vec_merge:V4SF |
18519 | (smax:V4SF (match_operand:V4SF 1 "register_operand" "0") | |
18520 | (match_operand:V4SF 2 "nonimmediate_operand" "xm")) | |
18521 | (match_dup 1) | |
18522 | (const_int 1)))] | |
915119a5 | 18523 | "TARGET_SSE" |
0f40f9f7 | 18524 | "maxss\t{%2, %0|%0, %2}" |
915119a5 BS |
18525 | [(set_attr "type" "sse")]) |
18526 | ||
18527 | (define_insn "sminv4sf3" | |
18528 | [(set (match_operand:V4SF 0 "register_operand" "=x") | |
18529 | (smin:V4SF (match_operand:V4SF 1 "register_operand" "0") | |
18530 | (match_operand:V4SF 2 "nonimmediate_operand" "xm")))] | |
18531 | "TARGET_SSE" | |
0f40f9f7 | 18532 | "minps\t{%2, %0|%0, %2}" |
915119a5 BS |
18533 | [(set_attr "type" "sse")]) |
18534 | ||
18535 | (define_insn "vmsminv4sf3" | |
18536 | [(set (match_operand:V4SF 0 "register_operand" "=x") | |
e37af218 RH |
18537 | (vec_merge:V4SF |
18538 | (smin:V4SF (match_operand:V4SF 1 "register_operand" "0") | |
18539 | (match_operand:V4SF 2 "nonimmediate_operand" "xm")) | |
18540 | (match_dup 1) | |
18541 | (const_int 1)))] | |
915119a5 | 18542 | "TARGET_SSE" |
0f40f9f7 | 18543 | "minss\t{%2, %0|%0, %2}" |
915119a5 BS |
18544 | [(set_attr "type" "sse")]) |
18545 | ||
18546 | ||
18547 | ;; SSE <-> integer/MMX conversions | |
18548 | ||
18549 | (define_insn "cvtpi2ps" | |
18550 | [(set (match_operand:V4SF 0 "register_operand" "=x") | |
e37af218 RH |
18551 | (vec_merge:V4SF |
18552 | (match_operand:V4SF 1 "register_operand" "0") | |
18553 | (vec_duplicate:V4SF | |
18554 | (float:V2SF (match_operand:V2SI 2 "nonimmediate_operand" "ym"))) | |
18555 | (const_int 12)))] | |
915119a5 | 18556 | "TARGET_SSE" |
0f40f9f7 | 18557 | "cvtpi2ps\t{%2, %0|%0, %2}" |
915119a5 BS |
18558 | [(set_attr "type" "sse")]) |
18559 | ||
18560 | (define_insn "cvtps2pi" | |
18561 | [(set (match_operand:V2SI 0 "register_operand" "=y") | |
e37af218 RH |
18562 | (vec_select:V2SI |
18563 | (fix:V4SI (match_operand:V4SF 1 "nonimmediate_operand" "xm")) | |
18564 | (parallel [(const_int 0) (const_int 1)])))] | |
915119a5 | 18565 | "TARGET_SSE" |
0f40f9f7 | 18566 | "cvtps2pi\t{%1, %0|%0, %1}" |
915119a5 BS |
18567 | [(set_attr "type" "sse")]) |
18568 | ||
18569 | (define_insn "cvttps2pi" | |
18570 | [(set (match_operand:V2SI 0 "register_operand" "=y") | |
e37af218 RH |
18571 | (vec_select:V2SI |
18572 | (unspec:V4SI [(match_operand:V4SF 1 "nonimmediate_operand" "xm")] 30) | |
18573 | (parallel [(const_int 0) (const_int 1)])))] | |
915119a5 | 18574 | "TARGET_SSE" |
0f40f9f7 | 18575 | "cvttps2pi\t{%1, %0|%0, %1}" |
915119a5 BS |
18576 | [(set_attr "type" "sse")]) |
18577 | ||
18578 | (define_insn "cvtsi2ss" | |
18579 | [(set (match_operand:V4SF 0 "register_operand" "=x") | |
e37af218 RH |
18580 | (vec_merge:V4SF |
18581 | (match_operand:V4SF 1 "register_operand" "0") | |
18582 | (vec_duplicate:V4SF | |
18583 | (float:SF (match_operand:SI 2 "nonimmediate_operand" "rm"))) | |
18584 | (const_int 14)))] | |
915119a5 | 18585 | "TARGET_SSE" |
0f40f9f7 | 18586 | "cvtsi2ss\t{%2, %0|%0, %2}" |
915119a5 BS |
18587 | [(set_attr "type" "sse")]) |
18588 | ||
18589 | (define_insn "cvtss2si" | |
21e1b5f1 | 18590 | [(set (match_operand:SI 0 "register_operand" "=r") |
e37af218 RH |
18591 | (vec_select:SI |
18592 | (fix:V4SI (match_operand:V4SF 1 "nonimmediate_operand" "xm")) | |
18593 | (parallel [(const_int 0)])))] | |
915119a5 | 18594 | "TARGET_SSE" |
0f40f9f7 | 18595 | "cvtss2si\t{%1, %0|%0, %1}" |
915119a5 BS |
18596 | [(set_attr "type" "sse")]) |
18597 | ||
18598 | (define_insn "cvttss2si" | |
21e1b5f1 | 18599 | [(set (match_operand:SI 0 "register_operand" "=r") |
e37af218 RH |
18600 | (vec_select:SI |
18601 | (unspec:V4SI [(match_operand:V4SF 1 "nonimmediate_operand" "xm")] 30) | |
18602 | (parallel [(const_int 0)])))] | |
915119a5 | 18603 | "TARGET_SSE" |
0f40f9f7 | 18604 | "cvttss2si\t{%1, %0|%0, %1}" |
915119a5 BS |
18605 | [(set_attr "type" "sse")]) |
18606 | ||
18607 | ||
18608 | ;; MMX insns | |
18609 | ||
18610 | ;; MMX arithmetic | |
18611 | ||
18612 | (define_insn "addv8qi3" | |
18613 | [(set (match_operand:V8QI 0 "register_operand" "=y") | |
18614 | (plus:V8QI (match_operand:V8QI 1 "register_operand" "0") | |
18615 | (match_operand:V8QI 2 "nonimmediate_operand" "ym")))] | |
18616 | "TARGET_MMX" | |
0f40f9f7 | 18617 | "paddb\t{%2, %0|%0, %2}" |
915119a5 BS |
18618 | [(set_attr "type" "mmx")]) |
18619 | ||
18620 | (define_insn "addv4hi3" | |
18621 | [(set (match_operand:V4HI 0 "register_operand" "=y") | |
18622 | (plus:V4HI (match_operand:V4HI 1 "register_operand" "0") | |
18623 | (match_operand:V4HI 2 "nonimmediate_operand" "ym")))] | |
18624 | "TARGET_MMX" | |
0f40f9f7 | 18625 | "paddw\t{%2, %0|%0, %2}" |
915119a5 BS |
18626 | [(set_attr "type" "mmx")]) |
18627 | ||
18628 | (define_insn "addv2si3" | |
18629 | [(set (match_operand:V2SI 0 "register_operand" "=y") | |
18630 | (plus:V2SI (match_operand:V2SI 1 "register_operand" "0") | |
18631 | (match_operand:V2SI 2 "nonimmediate_operand" "ym")))] | |
18632 | "TARGET_MMX" | |
0f40f9f7 | 18633 | "paddd\t{%2, %0|%0, %2}" |
915119a5 BS |
18634 | [(set_attr "type" "mmx")]) |
18635 | ||
18636 | (define_insn "ssaddv8qi3" | |
18637 | [(set (match_operand:V8QI 0 "register_operand" "=y") | |
18638 | (ss_plus:V8QI (match_operand:V8QI 1 "register_operand" "0") | |
18639 | (match_operand:V8QI 2 "nonimmediate_operand" "ym")))] | |
18640 | "TARGET_MMX" | |
0f40f9f7 | 18641 | "paddsb\t{%2, %0|%0, %2}" |
915119a5 BS |
18642 | [(set_attr "type" "mmx")]) |
18643 | ||
18644 | (define_insn "ssaddv4hi3" | |
18645 | [(set (match_operand:V4HI 0 "register_operand" "=y") | |
18646 | (ss_plus:V4HI (match_operand:V4HI 1 "register_operand" "0") | |
18647 | (match_operand:V4HI 2 "nonimmediate_operand" "ym")))] | |
18648 | "TARGET_MMX" | |
0f40f9f7 | 18649 | "paddsw\t{%2, %0|%0, %2}" |
915119a5 BS |
18650 | [(set_attr "type" "mmx")]) |
18651 | ||
18652 | (define_insn "usaddv8qi3" | |
18653 | [(set (match_operand:V8QI 0 "register_operand" "=y") | |
18654 | (us_plus:V8QI (match_operand:V8QI 1 "register_operand" "0") | |
18655 | (match_operand:V8QI 2 "nonimmediate_operand" "ym")))] | |
18656 | "TARGET_MMX" | |
0f40f9f7 | 18657 | "paddusb\t{%2, %0|%0, %2}" |
915119a5 BS |
18658 | [(set_attr "type" "mmx")]) |
18659 | ||
18660 | (define_insn "usaddv4hi3" | |
18661 | [(set (match_operand:V4HI 0 "register_operand" "=y") | |
18662 | (us_plus:V4HI (match_operand:V4HI 1 "register_operand" "0") | |
18663 | (match_operand:V4HI 2 "nonimmediate_operand" "ym")))] | |
18664 | "TARGET_MMX" | |
0f40f9f7 | 18665 | "paddusw\t{%2, %0|%0, %2}" |
915119a5 BS |
18666 | [(set_attr "type" "mmx")]) |
18667 | ||
18668 | (define_insn "subv8qi3" | |
18669 | [(set (match_operand:V8QI 0 "register_operand" "=y") | |
18670 | (minus:V8QI (match_operand:V8QI 1 "register_operand" "0") | |
18671 | (match_operand:V8QI 2 "nonimmediate_operand" "ym")))] | |
18672 | "TARGET_MMX" | |
0f40f9f7 | 18673 | "psubb\t{%2, %0|%0, %2}" |
915119a5 BS |
18674 | [(set_attr "type" "mmx")]) |
18675 | ||
18676 | (define_insn "subv4hi3" | |
18677 | [(set (match_operand:V4HI 0 "register_operand" "=y") | |
18678 | (minus:V4HI (match_operand:V4HI 1 "register_operand" "0") | |
18679 | (match_operand:V4HI 2 "nonimmediate_operand" "ym")))] | |
18680 | "TARGET_MMX" | |
0f40f9f7 | 18681 | "psubw\t{%2, %0|%0, %2}" |
915119a5 BS |
18682 | [(set_attr "type" "mmx")]) |
18683 | ||
18684 | (define_insn "subv2si3" | |
18685 | [(set (match_operand:V2SI 0 "register_operand" "=y") | |
18686 | (minus:V2SI (match_operand:V2SI 1 "register_operand" "0") | |
18687 | (match_operand:V2SI 2 "nonimmediate_operand" "ym")))] | |
18688 | "TARGET_MMX" | |
0f40f9f7 | 18689 | "psubd\t{%2, %0|%0, %2}" |
915119a5 BS |
18690 | [(set_attr "type" "mmx")]) |
18691 | ||
18692 | (define_insn "sssubv8qi3" | |
18693 | [(set (match_operand:V8QI 0 "register_operand" "=y") | |
18694 | (ss_minus:V8QI (match_operand:V8QI 1 "register_operand" "0") | |
18695 | (match_operand:V8QI 2 "nonimmediate_operand" "ym")))] | |
18696 | "TARGET_MMX" | |
0f40f9f7 | 18697 | "psubsb\t{%2, %0|%0, %2}" |
915119a5 BS |
18698 | [(set_attr "type" "mmx")]) |
18699 | ||
18700 | (define_insn "sssubv4hi3" | |
18701 | [(set (match_operand:V4HI 0 "register_operand" "=y") | |
18702 | (ss_minus:V4HI (match_operand:V4HI 1 "register_operand" "0") | |
18703 | (match_operand:V4HI 2 "nonimmediate_operand" "ym")))] | |
18704 | "TARGET_MMX" | |
0f40f9f7 | 18705 | "psubsw\t{%2, %0|%0, %2}" |
915119a5 BS |
18706 | [(set_attr "type" "mmx")]) |
18707 | ||
18708 | (define_insn "ussubv8qi3" | |
18709 | [(set (match_operand:V8QI 0 "register_operand" "=y") | |
18710 | (us_minus:V8QI (match_operand:V8QI 1 "register_operand" "0") | |
18711 | (match_operand:V8QI 2 "nonimmediate_operand" "ym")))] | |
18712 | "TARGET_MMX" | |
0f40f9f7 | 18713 | "psubusb\t{%2, %0|%0, %2}" |
915119a5 BS |
18714 | [(set_attr "type" "mmx")]) |
18715 | ||
18716 | (define_insn "ussubv4hi3" | |
18717 | [(set (match_operand:V4HI 0 "register_operand" "=y") | |
18718 | (us_minus:V4HI (match_operand:V4HI 1 "register_operand" "0") | |
18719 | (match_operand:V4HI 2 "nonimmediate_operand" "ym")))] | |
18720 | "TARGET_MMX" | |
0f40f9f7 | 18721 | "psubusw\t{%2, %0|%0, %2}" |
915119a5 BS |
18722 | [(set_attr "type" "mmx")]) |
18723 | ||
18724 | (define_insn "mulv4hi3" | |
18725 | [(set (match_operand:V4HI 0 "register_operand" "=y") | |
18726 | (mult:V4HI (match_operand:V4HI 1 "register_operand" "0") | |
18727 | (match_operand:V4HI 2 "nonimmediate_operand" "ym")))] | |
18728 | "TARGET_MMX" | |
0f40f9f7 | 18729 | "pmullw\t{%2, %0|%0, %2}" |
915119a5 BS |
18730 | [(set_attr "type" "mmx")]) |
18731 | ||
18732 | (define_insn "smulv4hi3_highpart" | |
18733 | [(set (match_operand:V4HI 0 "register_operand" "=y") | |
18734 | (truncate:V4HI | |
18735 | (lshiftrt:V4SI | |
e37af218 RH |
18736 | (mult:V4SI (sign_extend:V4SI |
18737 | (match_operand:V4HI 1 "register_operand" "0")) | |
18738 | (sign_extend:V4SI | |
18739 | (match_operand:V4HI 2 "nonimmediate_operand" "ym"))) | |
915119a5 BS |
18740 | (const_int 16))))] |
18741 | "TARGET_MMX" | |
0f40f9f7 | 18742 | "pmulhw\t{%2, %0|%0, %2}" |
915119a5 BS |
18743 | [(set_attr "type" "mmx")]) |
18744 | ||
18745 | (define_insn "umulv4hi3_highpart" | |
18746 | [(set (match_operand:V4HI 0 "register_operand" "=y") | |
18747 | (truncate:V4HI | |
18748 | (lshiftrt:V4SI | |
e37af218 RH |
18749 | (mult:V4SI (zero_extend:V4SI |
18750 | (match_operand:V4HI 1 "register_operand" "0")) | |
18751 | (zero_extend:V4SI | |
18752 | (match_operand:V4HI 2 "nonimmediate_operand" "ym"))) | |
915119a5 | 18753 | (const_int 16))))] |
47f339cf | 18754 | "TARGET_SSE || TARGET_3DNOW_A" |
0f40f9f7 | 18755 | "pmulhuw\t{%2, %0|%0, %2}" |
915119a5 BS |
18756 | [(set_attr "type" "mmx")]) |
18757 | ||
18758 | (define_insn "mmx_pmaddwd" | |
18759 | [(set (match_operand:V2SI 0 "register_operand" "=y") | |
18760 | (plus:V2SI | |
18761 | (mult:V2SI | |
e37af218 RH |
18762 | (sign_extend:V2SI |
18763 | (vec_select:V2HI (match_operand:V4HI 1 "register_operand" "0") | |
18764 | (parallel [(const_int 0) (const_int 2)]))) | |
18765 | (sign_extend:V2SI | |
18766 | (vec_select:V2HI (match_operand:V4HI 2 "nonimmediate_operand" "ym") | |
18767 | (parallel [(const_int 0) (const_int 2)])))) | |
915119a5 BS |
18768 | (mult:V2SI |
18769 | (sign_extend:V2SI (vec_select:V2HI (match_dup 1) | |
18770 | (parallel [(const_int 1) | |
18771 | (const_int 3)]))) | |
18772 | (sign_extend:V2SI (vec_select:V2HI (match_dup 2) | |
18773 | (parallel [(const_int 1) | |
18774 | (const_int 3)]))))))] | |
18775 | "TARGET_MMX" | |
0f40f9f7 | 18776 | "pmaddwd\t{%2, %0|%0, %2}" |
915119a5 BS |
18777 | [(set_attr "type" "mmx")]) |
18778 | ||
18779 | ||
18780 | ;; MMX logical operations | |
18781 | ;; Note we don't want to declare these as regular iordi3 insns to prevent | |
18782 | ;; normal code that also wants to use the FPU from getting broken. | |
18783 | ;; The UNSPECs are there to prevent the combiner from getting overly clever. | |
18784 | (define_insn "mmx_iordi3" | |
18785 | [(set (match_operand:DI 0 "register_operand" "=y") | |
18786 | (unspec:DI | |
18787 | [(ior:DI (match_operand:DI 1 "register_operand" "0") | |
18788 | (match_operand:DI 2 "nonimmediate_operand" "ym"))] 45))] | |
18789 | "TARGET_MMX" | |
0f40f9f7 | 18790 | "por\t{%2, %0|%0, %2}" |
915119a5 BS |
18791 | [(set_attr "type" "mmx")]) |
18792 | ||
18793 | (define_insn "mmx_xordi3" | |
18794 | [(set (match_operand:DI 0 "register_operand" "=y") | |
18795 | (unspec:DI | |
18796 | [(xor:DI (match_operand:DI 1 "register_operand" "0") | |
18797 | (match_operand:DI 2 "nonimmediate_operand" "ym"))] 45))] | |
18798 | "TARGET_MMX" | |
0f40f9f7 | 18799 | "pxor\t{%2, %0|%0, %2}" |
29628f27 BS |
18800 | [(set_attr "type" "mmx") |
18801 | (set_attr "memory" "none")]) | |
915119a5 BS |
18802 | |
18803 | ;; Same as pxor, but don't show input operands so that we don't think | |
18804 | ;; they are live. | |
18805 | (define_insn "mmx_clrdi" | |
18806 | [(set (match_operand:DI 0 "register_operand" "=y") | |
18807 | (unspec:DI [(const_int 0)] 45))] | |
18808 | "TARGET_MMX" | |
0f40f9f7 | 18809 | "pxor\t{%0, %0|%0, %0}" |
6f1a6c5b RH |
18810 | [(set_attr "type" "mmx") |
18811 | (set_attr "memory" "none")]) | |
915119a5 BS |
18812 | |
18813 | (define_insn "mmx_anddi3" | |
18814 | [(set (match_operand:DI 0 "register_operand" "=y") | |
18815 | (unspec:DI | |
18816 | [(and:DI (match_operand:DI 1 "register_operand" "0") | |
18817 | (match_operand:DI 2 "nonimmediate_operand" "ym"))] 45))] | |
18818 | "TARGET_MMX" | |
0f40f9f7 | 18819 | "pand\t{%2, %0|%0, %2}" |
915119a5 BS |
18820 | [(set_attr "type" "mmx")]) |
18821 | ||
18822 | (define_insn "mmx_nanddi3" | |
18823 | [(set (match_operand:DI 0 "register_operand" "=y") | |
18824 | (unspec:DI | |
18825 | [(and:DI (not:DI (match_operand:DI 1 "register_operand" "0")) | |
18826 | (match_operand:DI 2 "nonimmediate_operand" "ym"))] 45))] | |
18827 | "TARGET_MMX" | |
0f40f9f7 | 18828 | "pandn\t{%2, %0|%0, %2}" |
915119a5 BS |
18829 | [(set_attr "type" "mmx")]) |
18830 | ||
18831 | ||
18832 | ;; MMX unsigned averages/sum of absolute differences | |
18833 | ||
18834 | (define_insn "mmx_uavgv8qi3" | |
18835 | [(set (match_operand:V8QI 0 "register_operand" "=y") | |
18836 | (ashiftrt:V8QI | |
18837 | (plus:V8QI (plus:V8QI | |
18838 | (match_operand:V8QI 1 "register_operand" "0") | |
18839 | (match_operand:V8QI 2 "nonimmediate_operand" "ym")) | |
18840 | (vec_const:V8QI (parallel [(const_int 1) | |
18841 | (const_int 1) | |
18842 | (const_int 1) | |
18843 | (const_int 1) | |
18844 | (const_int 1) | |
18845 | (const_int 1) | |
18846 | (const_int 1) | |
18847 | (const_int 1)]))) | |
18848 | (const_int 1)))] | |
47f339cf | 18849 | "TARGET_SSE || TARGET_3DNOW_A" |
0f40f9f7 | 18850 | "pavgb\t{%2, %0|%0, %2}" |
915119a5 BS |
18851 | [(set_attr "type" "sse")]) |
18852 | ||
18853 | (define_insn "mmx_uavgv4hi3" | |
18854 | [(set (match_operand:V4HI 0 "register_operand" "=y") | |
18855 | (ashiftrt:V4HI | |
18856 | (plus:V4HI (plus:V4HI | |
18857 | (match_operand:V4HI 1 "register_operand" "0") | |
18858 | (match_operand:V4HI 2 "nonimmediate_operand" "ym")) | |
18859 | (vec_const:V4HI (parallel [(const_int 1) | |
18860 | (const_int 1) | |
18861 | (const_int 1) | |
18862 | (const_int 1)]))) | |
18863 | (const_int 1)))] | |
47f339cf | 18864 | "TARGET_SSE || TARGET_3DNOW_A" |
0f40f9f7 | 18865 | "pavgw\t{%2, %0|%0, %2}" |
915119a5 BS |
18866 | [(set_attr "type" "sse")]) |
18867 | ||
18868 | (define_insn "mmx_psadbw" | |
18869 | [(set (match_operand:V8QI 0 "register_operand" "=y") | |
332316cd BS |
18870 | (abs:V8QI (minus:V8QI (match_operand:V8QI 1 "register_operand" "0") |
18871 | (match_operand:V8QI 2 "nonimmediate_operand" "ym"))))] | |
47f339cf | 18872 | "TARGET_SSE || TARGET_3DNOW_A" |
0f40f9f7 | 18873 | "psadbw\t{%2, %0|%0, %2}" |
915119a5 BS |
18874 | [(set_attr "type" "sse")]) |
18875 | ||
18876 | ||
18877 | ;; MMX insert/extract/shuffle | |
18878 | ||
18879 | (define_insn "mmx_pinsrw" | |
18880 | [(set (match_operand:V4HI 0 "register_operand" "=y") | |
18881 | (vec_merge:V4HI (match_operand:V4HI 1 "register_operand" "0") | |
18882 | (vec_duplicate:V4HI | |
18883 | (truncate:HI (match_operand:SI 2 "nonimmediate_operand" "rm"))) | |
18884 | (match_operand:SI 3 "immediate_operand" "i")))] | |
47f339cf | 18885 | "TARGET_SSE || TARGET_3DNOW_A" |
0f40f9f7 | 18886 | "pinsrw\t{%3, %2, %0|%0, %2, %3}" |
915119a5 BS |
18887 | [(set_attr "type" "sse")]) |
18888 | ||
18889 | (define_insn "mmx_pextrw" | |
18890 | [(set (match_operand:SI 0 "register_operand" "=r") | |
18891 | (zero_extend:SI (vec_select:HI (match_operand:V4HI 1 "register_operand" "y") | |
18892 | (parallel | |
18893 | [(match_operand:SI 2 "immediate_operand" "i")]))))] | |
47f339cf | 18894 | "TARGET_SSE || TARGET_3DNOW_A" |
0f40f9f7 | 18895 | "pextrw\t{%2, %1, %0|%0, %1, %2}" |
915119a5 BS |
18896 | [(set_attr "type" "sse")]) |
18897 | ||
18898 | (define_insn "mmx_pshufw" | |
18899 | [(set (match_operand:V4HI 0 "register_operand" "=y") | |
18900 | (unspec:V4HI [(match_operand:V4HI 1 "register_operand" "0") | |
29628f27 | 18901 | (match_operand:SI 2 "immediate_operand" "i")] 41))] |
47f339cf | 18902 | "TARGET_SSE || TARGET_3DNOW_A" |
29628f27 | 18903 | "pshufw\t{%2, %1, %0|%0, %1, %2}" |
915119a5 BS |
18904 | [(set_attr "type" "sse")]) |
18905 | ||
18906 | ||
18907 | ;; MMX mask-generating comparisons | |
18908 | ||
18909 | (define_insn "eqv8qi3" | |
18910 | [(set (match_operand:V8QI 0 "register_operand" "=y") | |
18911 | (eq:V8QI (match_operand:V8QI 1 "register_operand" "0") | |
18912 | (match_operand:V8QI 2 "nonimmediate_operand" "ym")))] | |
18913 | "TARGET_MMX" | |
0f40f9f7 | 18914 | "pcmpeqb\t{%2, %0|%0, %2}" |
915119a5 BS |
18915 | [(set_attr "type" "mmx")]) |
18916 | ||
18917 | (define_insn "eqv4hi3" | |
18918 | [(set (match_operand:V4HI 0 "register_operand" "=y") | |
18919 | (eq:V4HI (match_operand:V4HI 1 "register_operand" "0") | |
18920 | (match_operand:V4HI 2 "nonimmediate_operand" "ym")))] | |
18921 | "TARGET_MMX" | |
0f40f9f7 | 18922 | "pcmpeqw\t{%2, %0|%0, %2}" |
915119a5 BS |
18923 | [(set_attr "type" "mmx")]) |
18924 | ||
18925 | (define_insn "eqv2si3" | |
18926 | [(set (match_operand:V2SI 0 "register_operand" "=y") | |
18927 | (eq:V2SI (match_operand:V2SI 1 "register_operand" "0") | |
18928 | (match_operand:V2SI 2 "nonimmediate_operand" "ym")))] | |
18929 | "TARGET_MMX" | |
0f40f9f7 | 18930 | "pcmpeqd\t{%2, %0|%0, %2}" |
915119a5 BS |
18931 | [(set_attr "type" "mmx")]) |
18932 | ||
18933 | (define_insn "gtv8qi3" | |
18934 | [(set (match_operand:V8QI 0 "register_operand" "=y") | |
18935 | (gt:V8QI (match_operand:V8QI 1 "register_operand" "0") | |
18936 | (match_operand:V8QI 2 "nonimmediate_operand" "ym")))] | |
18937 | "TARGET_MMX" | |
0f40f9f7 | 18938 | "pcmpgtb\t{%2, %0|%0, %2}" |
915119a5 BS |
18939 | [(set_attr "type" "mmx")]) |
18940 | ||
18941 | (define_insn "gtv4hi3" | |
18942 | [(set (match_operand:V4HI 0 "register_operand" "=y") | |
18943 | (gt:V4HI (match_operand:V4HI 1 "register_operand" "0") | |
18944 | (match_operand:V4HI 2 "nonimmediate_operand" "ym")))] | |
18945 | "TARGET_MMX" | |
0f40f9f7 | 18946 | "pcmpgtw\t{%2, %0|%0, %2}" |
915119a5 BS |
18947 | [(set_attr "type" "mmx")]) |
18948 | ||
18949 | (define_insn "gtv2si3" | |
18950 | [(set (match_operand:V2SI 0 "register_operand" "=y") | |
18951 | (gt:V2SI (match_operand:V2SI 1 "register_operand" "0") | |
18952 | (match_operand:V2SI 2 "nonimmediate_operand" "ym")))] | |
18953 | "TARGET_MMX" | |
0f40f9f7 | 18954 | "pcmpgtd\t{%2, %0|%0, %2}" |
915119a5 BS |
18955 | [(set_attr "type" "mmx")]) |
18956 | ||
18957 | ||
18958 | ;; MMX max/min insns | |
18959 | ||
18960 | (define_insn "umaxv8qi3" | |
18961 | [(set (match_operand:V8QI 0 "register_operand" "=y") | |
18962 | (umax:V8QI (match_operand:V8QI 1 "register_operand" "0") | |
18963 | (match_operand:V8QI 2 "nonimmediate_operand" "ym")))] | |
47f339cf | 18964 | "TARGET_SSE || TARGET_3DNOW_A" |
0f40f9f7 | 18965 | "pmaxub\t{%2, %0|%0, %2}" |
915119a5 BS |
18966 | [(set_attr "type" "sse")]) |
18967 | ||
18968 | (define_insn "smaxv4hi3" | |
18969 | [(set (match_operand:V4HI 0 "register_operand" "=y") | |
18970 | (smax:V4HI (match_operand:V4HI 1 "register_operand" "0") | |
18971 | (match_operand:V4HI 2 "nonimmediate_operand" "ym")))] | |
47f339cf | 18972 | "TARGET_SSE || TARGET_3DNOW_A" |
0f40f9f7 | 18973 | "pmaxsw\t{%2, %0|%0, %2}" |
915119a5 BS |
18974 | [(set_attr "type" "sse")]) |
18975 | ||
18976 | (define_insn "uminv8qi3" | |
18977 | [(set (match_operand:V8QI 0 "register_operand" "=y") | |
18978 | (umin:V8QI (match_operand:V8QI 1 "register_operand" "0") | |
18979 | (match_operand:V8QI 2 "nonimmediate_operand" "ym")))] | |
47f339cf | 18980 | "TARGET_SSE || TARGET_3DNOW_A" |
0f40f9f7 | 18981 | "pminub\t{%2, %0|%0, %2}" |
915119a5 BS |
18982 | [(set_attr "type" "sse")]) |
18983 | ||
18984 | (define_insn "sminv4hi3" | |
18985 | [(set (match_operand:V4HI 0 "register_operand" "=y") | |
18986 | (smin:V4HI (match_operand:V4HI 1 "register_operand" "0") | |
18987 | (match_operand:V4HI 2 "nonimmediate_operand" "ym")))] | |
47f339cf | 18988 | "TARGET_SSE || TARGET_3DNOW_A" |
0f40f9f7 | 18989 | "pminsw\t{%2, %0|%0, %2}" |
915119a5 BS |
18990 | [(set_attr "type" "sse")]) |
18991 | ||
18992 | ||
18993 | ;; MMX shifts | |
18994 | ||
18995 | (define_insn "ashrv4hi3" | |
18996 | [(set (match_operand:V4HI 0 "register_operand" "=y") | |
18997 | (ashiftrt:V4HI (match_operand:V4HI 1 "register_operand" "0") | |
18998 | (match_operand:DI 2 "nonmemory_operand" "yi")))] | |
18999 | "TARGET_MMX" | |
0f40f9f7 | 19000 | "psraw\t{%2, %0|%0, %2}" |
915119a5 BS |
19001 | [(set_attr "type" "mmx")]) |
19002 | ||
19003 | (define_insn "ashrv2si3" | |
19004 | [(set (match_operand:V2SI 0 "register_operand" "=y") | |
19005 | (ashiftrt:V2SI (match_operand:V2SI 1 "register_operand" "0") | |
19006 | (match_operand:DI 2 "nonmemory_operand" "yi")))] | |
19007 | "TARGET_MMX" | |
0f40f9f7 | 19008 | "psrad\t{%2, %0|%0, %2}" |
915119a5 BS |
19009 | [(set_attr "type" "mmx")]) |
19010 | ||
19011 | (define_insn "lshrv4hi3" | |
19012 | [(set (match_operand:V4HI 0 "register_operand" "=y") | |
19013 | (lshiftrt:V4HI (match_operand:V4HI 1 "register_operand" "0") | |
19014 | (match_operand:DI 2 "nonmemory_operand" "yi")))] | |
19015 | "TARGET_MMX" | |
0f40f9f7 | 19016 | "psrlw\t{%2, %0|%0, %2}" |
915119a5 BS |
19017 | [(set_attr "type" "mmx")]) |
19018 | ||
19019 | (define_insn "lshrv2si3" | |
19020 | [(set (match_operand:V2SI 0 "register_operand" "=y") | |
19021 | (lshiftrt:V2SI (match_operand:V2SI 1 "register_operand" "0") | |
19022 | (match_operand:DI 2 "nonmemory_operand" "yi")))] | |
19023 | "TARGET_MMX" | |
0f40f9f7 | 19024 | "psrld\t{%2, %0|%0, %2}" |
915119a5 BS |
19025 | [(set_attr "type" "mmx")]) |
19026 | ||
19027 | ;; See logical MMX insns. | |
19028 | (define_insn "mmx_lshrdi3" | |
19029 | [(set (match_operand:DI 0 "register_operand" "=y") | |
2b71bf37 JH |
19030 | (unspec:DI |
19031 | [(lshiftrt:DI (match_operand:DI 1 "register_operand" "0") | |
19032 | (match_operand:DI 2 "nonmemory_operand" "yi"))] 45))] | |
915119a5 | 19033 | "TARGET_MMX" |
0f40f9f7 | 19034 | "psrlq\t{%2, %0|%0, %2}" |
915119a5 BS |
19035 | [(set_attr "type" "mmx")]) |
19036 | ||
19037 | (define_insn "ashlv4hi3" | |
19038 | [(set (match_operand:V4HI 0 "register_operand" "=y") | |
19039 | (ashift:V4HI (match_operand:V4HI 1 "register_operand" "0") | |
19040 | (match_operand:DI 2 "nonmemory_operand" "yi")))] | |
19041 | "TARGET_MMX" | |
0f40f9f7 | 19042 | "psllw\t{%2, %0|%0, %2}" |
915119a5 BS |
19043 | [(set_attr "type" "mmx")]) |
19044 | ||
19045 | (define_insn "ashlv2si3" | |
19046 | [(set (match_operand:V2SI 0 "register_operand" "=y") | |
19047 | (ashift:V2SI (match_operand:V2SI 1 "register_operand" "0") | |
19048 | (match_operand:DI 2 "nonmemory_operand" "yi")))] | |
19049 | "TARGET_MMX" | |
0f40f9f7 | 19050 | "pslld\t{%2, %0|%0, %2}" |
915119a5 BS |
19051 | [(set_attr "type" "mmx")]) |
19052 | ||
19053 | ;; See logical MMX insns. | |
19054 | (define_insn "mmx_ashldi3" | |
19055 | [(set (match_operand:DI 0 "register_operand" "=y") | |
2b71bf37 JH |
19056 | (unspec:DI |
19057 | [(ashift:DI (match_operand:DI 1 "register_operand" "0") | |
19058 | (match_operand:DI 2 "nonmemory_operand" "yi"))] 45))] | |
915119a5 | 19059 | "TARGET_MMX" |
0f40f9f7 | 19060 | "psllq\t{%2, %0|%0, %2}" |
915119a5 BS |
19061 | [(set_attr "type" "mmx")]) |
19062 | ||
19063 | ||
19064 | ;; MMX pack/unpack insns. | |
19065 | ||
19066 | (define_insn "mmx_packsswb" | |
19067 | [(set (match_operand:V8QI 0 "register_operand" "=y") | |
19068 | (vec_concat:V8QI | |
19069 | (ss_truncate:V4QI (match_operand:V4HI 1 "register_operand" "0")) | |
19070 | (ss_truncate:V4QI (match_operand:V4HI 2 "register_operand" "y"))))] | |
19071 | "TARGET_MMX" | |
0f40f9f7 | 19072 | "packsswb\t{%2, %0|%0, %2}" |
915119a5 BS |
19073 | [(set_attr "type" "mmx")]) |
19074 | ||
19075 | (define_insn "mmx_packssdw" | |
19076 | [(set (match_operand:V4HI 0 "register_operand" "=y") | |
19077 | (vec_concat:V4HI | |
19078 | (ss_truncate:V2HI (match_operand:V2SI 1 "register_operand" "0")) | |
19079 | (ss_truncate:V2HI (match_operand:V2SI 2 "register_operand" "y"))))] | |
19080 | "TARGET_MMX" | |
0f40f9f7 | 19081 | "packssdw\t{%2, %0|%0, %2}" |
915119a5 BS |
19082 | [(set_attr "type" "mmx")]) |
19083 | ||
19084 | (define_insn "mmx_packuswb" | |
19085 | [(set (match_operand:V8QI 0 "register_operand" "=y") | |
19086 | (vec_concat:V8QI | |
19087 | (us_truncate:V4QI (match_operand:V4HI 1 "register_operand" "0")) | |
19088 | (us_truncate:V4QI (match_operand:V4HI 2 "register_operand" "y"))))] | |
19089 | "TARGET_MMX" | |
0f40f9f7 | 19090 | "packuswb\t{%2, %0|%0, %2}" |
915119a5 BS |
19091 | [(set_attr "type" "mmx")]) |
19092 | ||
19093 | (define_insn "mmx_punpckhbw" | |
19094 | [(set (match_operand:V8QI 0 "register_operand" "=y") | |
19095 | (vec_merge:V8QI | |
19096 | (vec_select:V8QI (match_operand:V8QI 1 "register_operand" "0") | |
19097 | (parallel [(const_int 4) | |
19098 | (const_int 0) | |
19099 | (const_int 5) | |
19100 | (const_int 1) | |
19101 | (const_int 6) | |
19102 | (const_int 2) | |
19103 | (const_int 7) | |
19104 | (const_int 3)])) | |
19105 | (vec_select:V8QI (match_operand:V8QI 2 "register_operand" "y") | |
19106 | (parallel [(const_int 0) | |
19107 | (const_int 4) | |
19108 | (const_int 1) | |
19109 | (const_int 5) | |
19110 | (const_int 2) | |
19111 | (const_int 6) | |
19112 | (const_int 3) | |
19113 | (const_int 7)])) | |
19114 | (const_int 85)))] | |
19115 | "TARGET_MMX" | |
0f40f9f7 | 19116 | "punpckhbw\t{%2, %0|%0, %2}" |
915119a5 BS |
19117 | [(set_attr "type" "mmx")]) |
19118 | ||
19119 | (define_insn "mmx_punpckhwd" | |
19120 | [(set (match_operand:V4HI 0 "register_operand" "=y") | |
19121 | (vec_merge:V4HI | |
19122 | (vec_select:V4HI (match_operand:V4HI 1 "register_operand" "0") | |
19123 | (parallel [(const_int 0) | |
19124 | (const_int 2) | |
19125 | (const_int 1) | |
19126 | (const_int 3)])) | |
19127 | (vec_select:V4HI (match_operand:V4HI 2 "register_operand" "y") | |
19128 | (parallel [(const_int 2) | |
19129 | (const_int 0) | |
19130 | (const_int 3) | |
19131 | (const_int 1)])) | |
19132 | (const_int 5)))] | |
19133 | "TARGET_MMX" | |
0f40f9f7 | 19134 | "punpckhwd\t{%2, %0|%0, %2}" |
915119a5 BS |
19135 | [(set_attr "type" "mmx")]) |
19136 | ||
19137 | (define_insn "mmx_punpckhdq" | |
19138 | [(set (match_operand:V2SI 0 "register_operand" "=y") | |
19139 | (vec_merge:V2SI | |
19140 | (vec_select:V2SI (match_operand:V2SI 1 "register_operand" "0") | |
19141 | (parallel [(const_int 0) | |
19142 | (const_int 1)])) | |
19143 | (vec_select:V2SI (match_operand:V2SI 2 "register_operand" "y") | |
19144 | (parallel [(const_int 1) | |
19145 | (const_int 0)])) | |
19146 | (const_int 1)))] | |
19147 | "TARGET_MMX" | |
0f40f9f7 | 19148 | "punpckhdq\t{%2, %0|%0, %2}" |
915119a5 BS |
19149 | [(set_attr "type" "mmx")]) |
19150 | ||
19151 | (define_insn "mmx_punpcklbw" | |
19152 | [(set (match_operand:V8QI 0 "register_operand" "=y") | |
19153 | (vec_merge:V8QI | |
19154 | (vec_select:V8QI (match_operand:V8QI 1 "register_operand" "0") | |
19155 | (parallel [(const_int 0) | |
19156 | (const_int 4) | |
19157 | (const_int 1) | |
19158 | (const_int 5) | |
19159 | (const_int 2) | |
19160 | (const_int 6) | |
19161 | (const_int 3) | |
19162 | (const_int 7)])) | |
19163 | (vec_select:V8QI (match_operand:V8QI 2 "register_operand" "y") | |
19164 | (parallel [(const_int 4) | |
19165 | (const_int 0) | |
19166 | (const_int 5) | |
19167 | (const_int 1) | |
19168 | (const_int 6) | |
19169 | (const_int 2) | |
19170 | (const_int 7) | |
19171 | (const_int 3)])) | |
19172 | (const_int 85)))] | |
19173 | "TARGET_MMX" | |
0f40f9f7 | 19174 | "punpcklbw\t{%2, %0|%0, %2}" |
915119a5 BS |
19175 | [(set_attr "type" "mmx")]) |
19176 | ||
19177 | (define_insn "mmx_punpcklwd" | |
19178 | [(set (match_operand:V4HI 0 "register_operand" "=y") | |
19179 | (vec_merge:V4HI | |
19180 | (vec_select:V4HI (match_operand:V4HI 1 "register_operand" "0") | |
19181 | (parallel [(const_int 2) | |
19182 | (const_int 0) | |
19183 | (const_int 3) | |
19184 | (const_int 1)])) | |
19185 | (vec_select:V4HI (match_operand:V4HI 2 "register_operand" "y") | |
19186 | (parallel [(const_int 0) | |
19187 | (const_int 2) | |
19188 | (const_int 1) | |
19189 | (const_int 3)])) | |
19190 | (const_int 5)))] | |
19191 | "TARGET_MMX" | |
0f40f9f7 | 19192 | "punpcklwd\t{%2, %0|%0, %2}" |
915119a5 BS |
19193 | [(set_attr "type" "mmx")]) |
19194 | ||
19195 | (define_insn "mmx_punpckldq" | |
19196 | [(set (match_operand:V2SI 0 "register_operand" "=y") | |
19197 | (vec_merge:V2SI | |
19198 | (vec_select:V2SI (match_operand:V2SI 1 "register_operand" "0") | |
19199 | (parallel [(const_int 1) | |
19200 | (const_int 0)])) | |
19201 | (vec_select:V2SI (match_operand:V2SI 2 "register_operand" "y") | |
19202 | (parallel [(const_int 0) | |
19203 | (const_int 1)])) | |
19204 | (const_int 1)))] | |
19205 | "TARGET_MMX" | |
0f40f9f7 | 19206 | "punpckldq\t{%2, %0|%0, %2}" |
915119a5 BS |
19207 | [(set_attr "type" "mmx")]) |
19208 | ||
19209 | ||
19210 | ;; Miscellaneous stuff | |
19211 | ||
19212 | (define_insn "emms" | |
19213 | [(unspec_volatile [(const_int 0)] 31) | |
19214 | (clobber (reg:XF 8)) | |
19215 | (clobber (reg:XF 9)) | |
19216 | (clobber (reg:XF 10)) | |
19217 | (clobber (reg:XF 11)) | |
19218 | (clobber (reg:XF 12)) | |
19219 | (clobber (reg:XF 13)) | |
19220 | (clobber (reg:XF 14)) | |
19221 | (clobber (reg:XF 15)) | |
915119a5 BS |
19222 | (clobber (reg:DI 29)) |
19223 | (clobber (reg:DI 30)) | |
19224 | (clobber (reg:DI 31)) | |
19225 | (clobber (reg:DI 32)) | |
19226 | (clobber (reg:DI 33)) | |
bd793c65 BS |
19227 | (clobber (reg:DI 34)) |
19228 | (clobber (reg:DI 35)) | |
19229 | (clobber (reg:DI 36))] | |
915119a5 BS |
19230 | "TARGET_MMX" |
19231 | "emms" | |
bd793c65 BS |
19232 | [(set_attr "type" "mmx") |
19233 | (set_attr "memory" "unknown")]) | |
915119a5 BS |
19234 | |
19235 | (define_insn "ldmxcsr" | |
19236 | [(unspec_volatile [(match_operand:SI 0 "memory_operand" "m")] 37)] | |
19237 | "TARGET_MMX" | |
0f40f9f7 | 19238 | "ldmxcsr\t%0" |
29628f27 BS |
19239 | [(set_attr "type" "mmx") |
19240 | (set_attr "memory" "load")]) | |
915119a5 BS |
19241 | |
19242 | (define_insn "stmxcsr" | |
19243 | [(set (match_operand:SI 0 "memory_operand" "=m") | |
19244 | (unspec_volatile:SI [(const_int 0)] 40))] | |
19245 | "TARGET_MMX" | |
0f40f9f7 | 19246 | "stmxcsr\t%0" |
29628f27 BS |
19247 | [(set_attr "type" "mmx") |
19248 | (set_attr "memory" "store")]) | |
915119a5 BS |
19249 | |
19250 | (define_expand "sfence" | |
19251 | [(set (match_dup 0) | |
19252 | (unspec:BLK [(match_dup 0)] 44))] | |
47f339cf | 19253 | "TARGET_SSE || TARGET_3DNOW_A" |
915119a5 BS |
19254 | { |
19255 | operands[0] = gen_rtx_MEM (BLKmode, gen_rtx_SCRATCH (Pmode)); | |
19256 | MEM_VOLATILE_P (operands[0]) = 1; | |
0f40f9f7 | 19257 | }) |
915119a5 BS |
19258 | |
19259 | (define_insn "*sfence_insn" | |
19260 | [(set (match_operand:BLK 0 "" "") | |
19261 | (unspec:BLK [(match_dup 0)] 44))] | |
47f339cf | 19262 | "TARGET_SSE || TARGET_3DNOW_A" |
915119a5 | 19263 | "sfence" |
bd793c65 BS |
19264 | [(set_attr "type" "sse") |
19265 | (set_attr "memory" "unknown")]) | |
915119a5 | 19266 | |
ad919812 JH |
19267 | (define_expand "sse_prologue_save" |
19268 | [(parallel [(set (match_operand:BLK 0 "" "") | |
19269 | (unspec:BLK [(reg:DI 21) | |
19270 | (reg:DI 22) | |
19271 | (reg:DI 23) | |
19272 | (reg:DI 24) | |
19273 | (reg:DI 25) | |
19274 | (reg:DI 26) | |
19275 | (reg:DI 27) | |
19276 | (reg:DI 28)] 13)) | |
19277 | (use (match_operand:DI 1 "register_operand" "")) | |
19278 | (use (match_operand:DI 2 "immediate_operand" "")) | |
19279 | (use (label_ref:DI (match_operand 3 "" "")))])] | |
19280 | "TARGET_64BIT" | |
19281 | "") | |
19282 | ||
19283 | (define_insn "*sse_prologue_save_insn" | |
19284 | [(set (mem:BLK (plus:DI (match_operand:DI 0 "register_operand" "R") | |
19285 | (match_operand:DI 4 "const_int_operand" "n"))) | |
19286 | (unspec:BLK [(reg:DI 21) | |
19287 | (reg:DI 22) | |
19288 | (reg:DI 23) | |
19289 | (reg:DI 24) | |
19290 | (reg:DI 25) | |
19291 | (reg:DI 26) | |
19292 | (reg:DI 27) | |
19293 | (reg:DI 28)] 13)) | |
19294 | (use (match_operand:DI 1 "register_operand" "r")) | |
19295 | (use (match_operand:DI 2 "const_int_operand" "i")) | |
19296 | (use (label_ref:DI (match_operand 3 "" "X")))] | |
19297 | "TARGET_64BIT | |
19298 | && INTVAL (operands[4]) + SSE_REGPARM_MAX * 16 - 16 < 128 | |
19299 | && INTVAL (operands[4]) + INTVAL (operands[2]) * 16 >= -128" | |
19300 | "* | |
19301 | { | |
19302 | int i; | |
19303 | operands[0] = gen_rtx_MEM (Pmode, | |
19304 | gen_rtx_PLUS (Pmode, operands[0], operands[4])); | |
19305 | output_asm_insn (\"jmp\\t%A1\", operands); | |
19306 | for (i = SSE_REGPARM_MAX - 1; i >= INTVAL (operands[2]); i--) | |
19307 | { | |
19308 | operands[4] = adjust_address (operands[0], DImode, i*16); | |
19309 | operands[5] = gen_rtx_REG (TImode, SSE_REGNO (i)); | |
19310 | PUT_MODE (operands[4], TImode); | |
19311 | if (GET_CODE (XEXP (operands[0], 0)) != PLUS) | |
19312 | output_asm_insn (\"rex\", operands); | |
19313 | output_asm_insn (\"movaps\\t{%5, %4|%4, %5}\", operands); | |
19314 | } | |
19315 | ASM_OUTPUT_INTERNAL_LABEL (asm_out_file, \"L\", | |
19316 | CODE_LABEL_NUMBER (operands[3])); | |
19317 | RET; | |
19318 | } | |
19319 | " | |
19320 | [(set_attr "type" "other") | |
19321 | (set_attr "length_immediate" "0") | |
19322 | (set_attr "length_address" "0") | |
19323 | (set_attr "length" "135") | |
19324 | (set_attr "memory" "store") | |
19325 | (set_attr "modrm" "0") | |
19326 | (set_attr "mode" "DI")]) | |
47f339cf BS |
19327 | |
19328 | ;; 3Dnow! instructions | |
19329 | ||
19330 | (define_insn "addv2sf3" | |
19331 | [(set (match_operand:V2SF 0 "register_operand" "=y") | |
19332 | (plus:V2SF (match_operand:V2SF 1 "register_operand" "0") | |
19333 | (match_operand:V2SF 2 "nonimmediate_operand" "ym")))] | |
19334 | "TARGET_3DNOW" | |
19335 | "pfadd\\t{%2, %0|%0, %2}" | |
19336 | [(set_attr "type" "mmx")]) | |
19337 | ||
19338 | (define_insn "subv2sf3" | |
19339 | [(set (match_operand:V2SF 0 "register_operand" "=y") | |
19340 | (minus:V2SF (match_operand:V2SF 1 "register_operand" "0") | |
19341 | (match_operand:V2SF 2 "nonimmediate_operand" "ym")))] | |
19342 | "TARGET_3DNOW" | |
19343 | "pfsub\\t{%2, %0|%0, %2}" | |
19344 | [(set_attr "type" "mmx")]) | |
19345 | ||
19346 | (define_insn "subrv2sf3" | |
19347 | [(set (match_operand:V2SF 0 "register_operand" "=y") | |
19348 | (minus:V2SF (match_operand:V2SF 2 "nonimmediate_operand" "ym") | |
19349 | (match_operand:V2SF 1 "register_operand" "0")))] | |
19350 | "TARGET_3DNOW" | |
19351 | "pfsubr\\t{%2, %0|%0, %2}" | |
19352 | [(set_attr "type" "mmx")]) | |
19353 | ||
19354 | (define_insn "gtv2sf3" | |
19355 | [(set (match_operand:V2SI 0 "register_operand" "=y") | |
19356 | (gt:V2SI (match_operand:V2SF 1 "register_operand" "0") | |
19357 | (match_operand:V2SF 2 "nonimmediate_operand" "ym")))] | |
19358 | "TARGET_3DNOW" | |
19359 | "pfcmpgt\\t{%2, %0|%0, %2}" | |
19360 | [(set_attr "type" "mmx")]) | |
19361 | ||
19362 | (define_insn "gev2sf3" | |
19363 | [(set (match_operand:V2SI 0 "register_operand" "=y") | |
19364 | (ge:V2SI (match_operand:V2SF 1 "register_operand" "0") | |
19365 | (match_operand:V2SF 2 "nonimmediate_operand" "ym")))] | |
19366 | "TARGET_3DNOW" | |
19367 | "pfcmpge\\t{%2, %0|%0, %2}" | |
19368 | [(set_attr "type" "mmx")]) | |
19369 | ||
19370 | (define_insn "eqv2sf3" | |
19371 | [(set (match_operand:V2SI 0 "register_operand" "=y") | |
19372 | (eq:V2SI (match_operand:V2SF 1 "register_operand" "0") | |
19373 | (match_operand:V2SF 2 "nonimmediate_operand" "ym")))] | |
19374 | "TARGET_3DNOW" | |
19375 | "pfcmpeq\\t{%2, %0|%0, %2}" | |
19376 | [(set_attr "type" "mmx")]) | |
19377 | ||
19378 | (define_insn "pfmaxv2sf3" | |
19379 | [(set (match_operand:V2SF 0 "register_operand" "=y") | |
19380 | (smax:V2SF (match_operand:V2SF 1 "register_operand" "0") | |
19381 | (match_operand:V2SF 2 "nonimmediate_operand" "ym")))] | |
19382 | "TARGET_3DNOW" | |
19383 | "pfmax\\t{%2, %0|%0, %2}" | |
19384 | [(set_attr "type" "mmx")]) | |
19385 | ||
19386 | (define_insn "pfminv2sf3" | |
19387 | [(set (match_operand:V2SF 0 "register_operand" "=y") | |
19388 | (smin:V2SF (match_operand:V2SF 1 "register_operand" "0") | |
19389 | (match_operand:V2SF 2 "nonimmediate_operand" "ym")))] | |
19390 | "TARGET_3DNOW" | |
19391 | "pfmin\\t{%2, %0|%0, %2}" | |
19392 | [(set_attr "type" "mmx")]) | |
19393 | ||
19394 | (define_insn "mulv2sf3" | |
19395 | [(set (match_operand:V2SF 0 "register_operand" "=y") | |
19396 | (mult:V2SF (match_operand:V2SF 1 "register_operand" "0") | |
19397 | (match_operand:V2SF 2 "nonimmediate_operand" "ym")))] | |
19398 | "TARGET_3DNOW" | |
19399 | "pfmul\\t{%2, %0|%0, %2}" | |
19400 | [(set_attr "type" "mmx")]) | |
19401 | ||
19402 | (define_insn "femms" | |
19403 | [(unspec_volatile [(const_int 0)] 46) | |
19404 | (clobber (reg:XF 8)) | |
19405 | (clobber (reg:XF 9)) | |
19406 | (clobber (reg:XF 10)) | |
19407 | (clobber (reg:XF 11)) | |
19408 | (clobber (reg:XF 12)) | |
19409 | (clobber (reg:XF 13)) | |
19410 | (clobber (reg:XF 14)) | |
19411 | (clobber (reg:XF 15)) | |
19412 | (clobber (reg:DI 29)) | |
19413 | (clobber (reg:DI 30)) | |
19414 | (clobber (reg:DI 31)) | |
19415 | (clobber (reg:DI 32)) | |
19416 | (clobber (reg:DI 33)) | |
19417 | (clobber (reg:DI 34)) | |
19418 | (clobber (reg:DI 35)) | |
19419 | (clobber (reg:DI 36))] | |
19420 | "TARGET_3DNOW" | |
19421 | "femms" | |
19422 | [(set_attr "type" "mmx")]) | |
19423 | ||
47f339cf BS |
19424 | (define_insn "pf2id" |
19425 | [(set (match_operand:V2SI 0 "register_operand" "=y") | |
19426 | (fix:V2SI (match_operand:V2SF 1 "nonimmediate_operand" "ym")))] | |
19427 | "TARGET_3DNOW" | |
19428 | "pf2id\\t{%1, %0|%0, %1}" | |
19429 | [(set_attr "type" "mmx")]) | |
19430 | ||
19431 | (define_insn "pf2iw" | |
19432 | [(set (match_operand:V2SI 0 "register_operand" "=y") | |
19433 | (sign_extend:V2SI | |
19434 | (ss_truncate:V2HI | |
19435 | (fix:V2SI (match_operand:V2SF 1 "nonimmediate_operand" "ym")))))] | |
19436 | "TARGET_3DNOW_A" | |
19437 | "pf2iw\\t{%1, %0|%0, %1}" | |
19438 | [(set_attr "type" "mmx")]) | |
19439 | ||
19440 | (define_insn "pfacc" | |
19441 | [(set (match_operand:V2SF 0 "register_operand" "=y") | |
19442 | (vec_concat:V2SF | |
19443 | (plus:SF | |
19444 | (vec_select:SF (match_operand:V2SF 1 "register_operand" "0") | |
19445 | (parallel [(const_int 0)])) | |
19446 | (vec_select:SF (match_dup 1) | |
19447 | (parallel [(const_int 1)]))) | |
19448 | (plus:SF | |
19449 | (vec_select:SF (match_operand:V2SF 2 "nonimmediate_operand" "y") | |
19450 | (parallel [(const_int 0)])) | |
19451 | (vec_select:SF (match_dup 2) | |
19452 | (parallel [(const_int 1)])))))] | |
19453 | "TARGET_3DNOW" | |
19454 | "pfacc\\t{%2, %0|%0, %2}" | |
19455 | [(set_attr "type" "mmx")]) | |
19456 | ||
19457 | (define_insn "pfnacc" | |
19458 | [(set (match_operand:V2SF 0 "register_operand" "=y") | |
19459 | (vec_concat:V2SF | |
19460 | (minus:SF | |
19461 | (vec_select:SF (match_operand:V2SF 1 "register_operand" "0") | |
19462 | (parallel [(const_int 0)])) | |
19463 | (vec_select:SF (match_dup 1) | |
19464 | (parallel [(const_int 1)]))) | |
19465 | (minus:SF | |
19466 | (vec_select:SF (match_operand:V2SF 2 "nonimmediate_operand" "y") | |
19467 | (parallel [(const_int 0)])) | |
19468 | (vec_select:SF (match_dup 2) | |
19469 | (parallel [(const_int 1)])))))] | |
19470 | "TARGET_3DNOW_A" | |
19471 | "pfnacc\\t{%2, %0|%0, %2}" | |
19472 | [(set_attr "type" "mmx")]) | |
19473 | ||
19474 | (define_insn "pfpnacc" | |
19475 | [(set (match_operand:V2SF 0 "register_operand" "=y") | |
19476 | (vec_concat:V2SF | |
19477 | (minus:SF | |
19478 | (vec_select:SF (match_operand:V2SF 1 "register_operand" "0") | |
19479 | (parallel [(const_int 0)])) | |
19480 | (vec_select:SF (match_dup 1) | |
19481 | (parallel [(const_int 1)]))) | |
19482 | (plus:SF | |
19483 | (vec_select:SF (match_operand:V2SF 2 "nonimmediate_operand" "y") | |
19484 | (parallel [(const_int 0)])) | |
19485 | (vec_select:SF (match_dup 2) | |
19486 | (parallel [(const_int 1)])))))] | |
19487 | "TARGET_3DNOW_A" | |
19488 | "pfpnacc\\t{%2, %0|%0, %2}" | |
19489 | [(set_attr "type" "mmx")]) | |
19490 | ||
19491 | (define_insn "pi2fw" | |
19492 | [(set (match_operand:V2SF 0 "register_operand" "=y") | |
19493 | (float:V2SF | |
19494 | (vec_concat:V2SI | |
19495 | (sign_extend:SI | |
19496 | (truncate:HI | |
19497 | (vec_select:SI (match_operand:V2SI 1 "nonimmediate_operand" "ym") | |
19498 | (parallel [(const_int 0)])))) | |
19499 | (sign_extend:SI | |
19500 | (truncate:HI | |
19501 | (vec_select:SI (match_dup 1) | |
19502 | (parallel [(const_int 1)])))))))] | |
19503 | "TARGET_3DNOW_A" | |
19504 | "pi2fw\\t{%1, %0|%0, %1}" | |
19505 | [(set_attr "type" "mmx")]) | |
19506 | ||
19507 | (define_insn "floatv2si2" | |
19508 | [(set (match_operand:V2SF 0 "register_operand" "=y") | |
19509 | (float:V2SF (match_operand:V2SI 1 "nonimmediate_operand" "ym")))] | |
19510 | "TARGET_3DNOW" | |
19511 | "pi2fd\\t{%1, %0|%0, %1}" | |
19512 | [(set_attr "type" "mmx")]) | |
19513 | ||
19514 | ;; This insn is identical to pavgb in operation, but the opcode is | |
19515 | ;; different. To avoid accidentally matching pavgb, use an unspec. | |
19516 | ||
19517 | (define_insn "pavgusb" | |
19518 | [(set (match_operand:V8QI 0 "register_operand" "=y") | |
19519 | (unspec:V8QI | |
19520 | [(match_operand:V8QI 1 "register_operand" "0") | |
19521 | (match_operand:V8QI 2 "nonimmediate_operand" "ym")] 49))] | |
19522 | "TARGET_3DNOW" | |
19523 | "pavgusb\\t{%2, %0|%0, %2}" | |
19524 | [(set_attr "type" "mmx")]) | |
19525 | ||
19526 | ;; 3DNow reciprical and sqrt | |
19527 | ||
19528 | (define_insn "pfrcpv2sf2" | |
19529 | [(set (match_operand:V2SF 0 "register_operand" "=y") | |
19530 | (unspec:V2SF [(match_operand:V2SF 1 "nonimmediate_operand" "ym")] 50))] | |
19531 | "TARGET_3DNOW" | |
19532 | "pfrcp\\t{%1, %0|%0, %1}" | |
19533 | [(set_attr "type" "mmx")]) | |
19534 | ||
19535 | (define_insn "pfrcpit1v2sf3" | |
19536 | [(set (match_operand:V2SF 0 "register_operand" "=y") | |
19537 | (unspec:V2SF [(match_operand:V2SF 1 "register_operand" "0") | |
19538 | (match_operand:V2SF 2 "nonimmediate_operand" "ym")] 51))] | |
19539 | "TARGET_3DNOW" | |
19540 | "pfrcpit1\\t{%2, %0|%0, %2}" | |
19541 | [(set_attr "type" "mmx")]) | |
19542 | ||
19543 | (define_insn "pfrcpit2v2sf3" | |
19544 | [(set (match_operand:V2SF 0 "register_operand" "=y") | |
19545 | (unspec:V2SF [(match_operand:V2SF 1 "register_operand" "0") | |
19546 | (match_operand:V2SF 2 "nonimmediate_operand" "ym")] 52))] | |
19547 | "TARGET_3DNOW" | |
19548 | "pfrcpit2\\t{%2, %0|%0, %2}" | |
19549 | [(set_attr "type" "mmx")]) | |
19550 | ||
19551 | (define_insn "pfrsqrtv2sf2" | |
19552 | [(set (match_operand:V2SF 0 "register_operand" "=y") | |
19553 | (unspec:V2SF [(match_operand:V2SF 1 "nonimmediate_operand" "ym")] 53))] | |
19554 | "TARGET_3DNOW" | |
19555 | "pfrsqrt\\t{%1, %0|%0, %1}" | |
19556 | [(set_attr "type" "mmx")]) | |
19557 | ||
19558 | (define_insn "pfrsqit1v2sf3" | |
19559 | [(set (match_operand:V2SF 0 "register_operand" "=y") | |
19560 | (unspec:V2SF [(match_operand:V2SF 1 "register_operand" "0") | |
19561 | (match_operand:V2SF 2 "nonimmediate_operand" "ym")] 54))] | |
19562 | "TARGET_3DNOW" | |
19563 | "pfrsqit1\\t{%2, %0|%0, %2}" | |
19564 | [(set_attr "type" "mmx")]) | |
19565 | ||
19566 | (define_insn "pmulhrwv4hi3" | |
19567 | [(set (match_operand:V4HI 0 "register_operand" "=y") | |
19568 | (truncate:V4HI | |
19569 | (lshiftrt:V4SI | |
19570 | (plus:V4SI | |
19571 | (mult:V4SI | |
19572 | (sign_extend:V4SI | |
19573 | (match_operand:V4HI 1 "register_operand" "0")) | |
19574 | (sign_extend:V4SI | |
19575 | (match_operand:V4HI 2 "nonimmediate_operand" "ym"))) | |
19576 | (vec_const:V4SI | |
53c98b1f DD |
19577 | (parallel [(const_int 32768) |
19578 | (const_int 32768) | |
19579 | (const_int 32768) | |
19580 | (const_int 32768)]))) | |
47f339cf BS |
19581 | (const_int 16))))] |
19582 | "TARGET_3DNOW" | |
19583 | "pmulhrw\\t{%2, %0|%0, %2}" | |
19584 | [(set_attr "type" "mmx")]) | |
19585 | ||
19586 | (define_insn "pswapdv2si2" | |
19587 | [(set (match_operand:V2SI 0 "register_operand" "=y") | |
19588 | (vec_select:V2SI (match_operand:V2SI 1 "nonimmediate_operand" "ym") | |
19589 | (parallel [(const_int 1) (const_int 0)])))] | |
19590 | "TARGET_3DNOW_A" | |
19591 | "pswapd\\t{%1, %0|%0, %1}" | |
19592 | [(set_attr "type" "mmx")]) | |
19593 | ||
19594 | (define_insn "pswapdv2sf2" | |
19595 | [(set (match_operand:V2SF 0 "register_operand" "=y") | |
19596 | (vec_select:V2SF (match_operand:V2SF 1 "nonimmediate_operand" "ym") | |
19597 | (parallel [(const_int 1) (const_int 0)])))] | |
19598 | "TARGET_3DNOW_A" | |
19599 | "pswapd\\t{%1, %0|%0, %1}" | |
19600 | [(set_attr "type" "mmx")]) | |
e37af218 RH |
19601 | |
19602 | (define_expand "prefetch" | |
19603 | [(prefetch (match_operand:SI 0 "address_operand" "") | |
19604 | (match_operand:SI 1 "const_int_operand" "") | |
19605 | (match_operand:SI 2 "const_int_operand" ""))] | |
19606 | "TARGET_PREFETCH_SSE || TARGET_3DNOW" | |
19607 | { | |
19608 | int rw = INTVAL (operands[1]); | |
19609 | int locality = INTVAL (operands[2]); | |
7d378549 | 19610 | |
e37af218 RH |
19611 | if (rw != 0 && rw != 1) |
19612 | abort (); | |
19613 | if (locality < 0 || locality > 3) | |
19614 | abort (); | |
19615 | ||
19616 | /* Use 3dNOW prefetch in case we are asking for write prefetch not | |
19617 | suported by SSE counterpart or the SSE prefetch is not available | |
19618 | (K6 machines). Otherwise use SSE prefetch as it allows specifying | |
19619 | of locality. */ | |
19620 | if (TARGET_3DNOW && (!TARGET_PREFETCH_SSE || rw)) | |
7d378549 | 19621 | operands[2] = GEN_INT (3); |
e37af218 | 19622 | else |
7d378549 | 19623 | operands[1] = const0_rtx; |
e37af218 RH |
19624 | }) |
19625 | ||
19626 | (define_insn "*prefetch_sse" | |
19627 | [(prefetch (match_operand:SI 0 "address_operand" "") | |
19628 | (const_int 0) | |
19629 | (match_operand:SI 1 "const_int_operand" ""))] | |
19630 | "TARGET_PREFETCH_SSE" | |
19631 | { | |
19632 | static const char * const patterns[4] = { | |
19633 | "prefetchnta\t%a0", "prefetcht2\t%a0", "prefetcht1\t%a0", "prefetcht0\t%a0" | |
19634 | }; | |
19635 | ||
19636 | int locality = INTVAL (operands[1]); | |
19637 | if (locality < 0 || locality > 3) | |
19638 | abort (); | |
19639 | ||
19640 | return patterns[locality]; | |
19641 | } | |
19642 | [(set_attr "type" "sse")]) | |
19643 | ||
19644 | (define_insn "*prefetch_3dnow" | |
19645 | [(prefetch (match_operand:SI 0 "address_operand" "p") | |
19646 | (match_operand:SI 1 "const_int_operand" "n") | |
7d378549 | 19647 | (const_int 3))] |
e37af218 RH |
19648 | "TARGET_3DNOW" |
19649 | { | |
19650 | if (INTVAL (operands[1]) == 0) | |
19651 | return "prefetch\t%a0"; | |
19652 | else | |
19653 | return "prefetchw\t%a0"; | |
19654 | } | |
19655 | [(set_attr "type" "mmx")]) |