]> git.ipfire.org Git - thirdparty/gcc.git/blob - gcc/config/rs6000/rs6000.md
a51c81ccab3d2eb18f067ea1af7d4d3c08bf3c4d
[thirdparty/gcc.git] / gcc / config / rs6000 / rs6000.md
1 ;; Machine description for IBM RISC System 6000 (POWER) for GNU C compiler
2 ;; Copyright (C) 1990, 1991, 1992, 1993, 1994, 1995, 1996, 1997, 1998,
3 ;; 1999, 2000, 2001, 2002, 2003 Free Software Foundation, Inc.
4 ;; Contributed by Richard Kenner (kenner@vlsi1.ultra.nyu.edu)
5
6 ;; This file is part of GNU CC.
7
8 ;; GNU CC is free software; you can redistribute it and/or modify
9 ;; it under the terms of the GNU General Public License as published by
10 ;; the Free Software Foundation; either version 2, or (at your option)
11 ;; any later version.
12
13 ;; GNU CC is distributed in the hope that it will be useful,
14 ;; but WITHOUT ANY WARRANTY; without even the implied warranty of
15 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 ;; GNU General Public License for more details.
17
18 ;; You should have received a copy of the GNU General Public License
19 ;; along with GNU CC; see the file COPYING. If not, write to
20 ;; the Free Software Foundation, 59 Temple Place - Suite 330,
21 ;; Boston, MA 02111-1307, USA.
22
23 ;;- See file "rtl.def" for documentation on define_insn, match_*, et. al.
24
25 ;; `unspec' values used in rs6000.md:
26 ;; Number Use
27 ;; 0 frsp for POWER machines
28 ;; 0/v blockage
29 ;; 5 used to tie the stack contents and the stack pointer
30 ;; 6 address of a word pointing to the TOC
31 ;; 7 address of the TOC (more-or-less)
32 ;; 8 movsi_got
33 ;; 9/v eh_reg_restore
34 ;; 10 fctiwz
35 ;; 15 load_macho_picbase
36 ;; 16 macho_correct_pic
37 ;; 19 movesi_from_cr
38 ;; 20 movsi_to_cr
39 \f
40 ;; Define an insn type attribute. This is used in function unit delay
41 ;; computations.
42 (define_attr "type" "integer,load,load_ext,load_ext_u,load_ext_ux,load_ux,load_u,store,store_ux,store_u,fpload,fpload_ux,fpload_u,fpstore,fpstore_ux,fpstore_u,vecload,vecstore,imul,imul2,imul3,lmul,idiv,ldiv,branch,cmp,fast_compare,compare,delayed_compare,imul_compare,lmul_compare,fpcompare,cr_logical,delayed_cr,mfcr,mtcr,mtjmpr,fp,fpsimple,dmul,sdiv,ddiv,ssqrt,dsqrt,jmpreg,brinc,vecsimple,veccomplex,vecdiv,veccmp,veccmpsimple,vecperm,vecfloat,vecfdiv"
43 (const_string "integer"))
44
45 ;; Length (in bytes).
46 ; '(pc)' in the following doesn't include the instruction itself; it is
47 ; calculated as if the instruction had zero size.
48 (define_attr "length" ""
49 (if_then_else (eq_attr "type" "branch")
50 (if_then_else (and (ge (minus (match_dup 0) (pc))
51 (const_int -32768))
52 (lt (minus (match_dup 0) (pc))
53 (const_int 32764)))
54 (const_int 4)
55 (const_int 8))
56 (const_int 4)))
57
58 ;; Processor type -- this attribute must exactly match the processor_type
59 ;; enumeration in rs6000.h.
60
61 (define_attr "cpu" "rios1,rios2,rs64a,mpccore,ppc403,ppc405,ppc440,ppc601,ppc603,ppc604,ppc604e,ppc620,ppc630,ppc750,ppc7400,ppc7450,ppc8540,power4"
62 (const (symbol_ref "rs6000_cpu_attr")))
63
64 (automata_option "ndfa")
65
66 (include "rios1.md")
67 (include "rios2.md")
68 (include "rs64.md")
69 (include "mpc.md")
70 (include "40x.md")
71 (include "603.md")
72 (include "6xx.md")
73 (include "7xx.md")
74 (include "7450.md")
75 (include "8540.md")
76 (include "power4.md")
77
78 \f
79 ;; Start with fixed-point load and store insns. Here we put only the more
80 ;; complex forms. Basic data transfer is done later.
81
82 (define_expand "zero_extendqidi2"
83 [(set (match_operand:DI 0 "gpc_reg_operand" "")
84 (zero_extend:DI (match_operand:QI 1 "gpc_reg_operand" "")))]
85 "TARGET_POWERPC64"
86 "")
87
88 (define_insn ""
89 [(set (match_operand:DI 0 "gpc_reg_operand" "=r,r")
90 (zero_extend:DI (match_operand:QI 1 "reg_or_mem_operand" "m,r")))]
91 "TARGET_POWERPC64"
92 "@
93 lbz%U1%X1 %0,%1
94 rldicl %0,%1,0,56"
95 [(set_attr "type" "load,*")])
96
97 (define_insn ""
98 [(set (match_operand:CC 0 "cc_reg_operand" "=x,?y")
99 (compare:CC (zero_extend:DI (match_operand:QI 1 "gpc_reg_operand" "r,r"))
100 (const_int 0)))
101 (clobber (match_scratch:DI 2 "=r,r"))]
102 "TARGET_POWERPC64"
103 "@
104 rldicl. %2,%1,0,56
105 #"
106 [(set_attr "type" "compare")
107 (set_attr "length" "4,8")])
108
109 (define_split
110 [(set (match_operand:CC 0 "cc_reg_not_cr0_operand" "")
111 (compare:CC (zero_extend:DI (match_operand:QI 1 "gpc_reg_operand" ""))
112 (const_int 0)))
113 (clobber (match_scratch:DI 2 ""))]
114 "TARGET_POWERPC64 && reload_completed"
115 [(set (match_dup 2)
116 (zero_extend:DI (match_dup 1)))
117 (set (match_dup 0)
118 (compare:CC (match_dup 2)
119 (const_int 0)))]
120 "")
121
122 (define_insn ""
123 [(set (match_operand:CC 2 "cc_reg_operand" "=x,?y")
124 (compare:CC (zero_extend:DI (match_operand:QI 1 "gpc_reg_operand" "r,r"))
125 (const_int 0)))
126 (set (match_operand:DI 0 "gpc_reg_operand" "=r,r")
127 (zero_extend:DI (match_dup 1)))]
128 "TARGET_POWERPC64"
129 "@
130 rldicl. %0,%1,0,56
131 #"
132 [(set_attr "type" "compare")
133 (set_attr "length" "4,8")])
134
135 (define_split
136 [(set (match_operand:CC 2 "cc_reg_not_cr0_operand" "")
137 (compare:CC (zero_extend:DI (match_operand:QI 1 "gpc_reg_operand" ""))
138 (const_int 0)))
139 (set (match_operand:DI 0 "gpc_reg_operand" "")
140 (zero_extend:DI (match_dup 1)))]
141 "TARGET_POWERPC64 && reload_completed"
142 [(set (match_dup 0)
143 (zero_extend:DI (match_dup 1)))
144 (set (match_dup 2)
145 (compare:CC (match_dup 0)
146 (const_int 0)))]
147 "")
148
149 (define_insn "extendqidi2"
150 [(set (match_operand:DI 0 "gpc_reg_operand" "=r")
151 (sign_extend:DI (match_operand:QI 1 "gpc_reg_operand" "r")))]
152 "TARGET_POWERPC64"
153 "extsb %0,%1")
154
155 (define_insn ""
156 [(set (match_operand:CC 0 "cc_reg_operand" "=x,?y")
157 (compare:CC (sign_extend:DI (match_operand:QI 1 "gpc_reg_operand" "r,r"))
158 (const_int 0)))
159 (clobber (match_scratch:DI 2 "=r,r"))]
160 "TARGET_POWERPC64"
161 "@
162 extsb. %2,%1
163 #"
164 [(set_attr "type" "compare")
165 (set_attr "length" "4,8")])
166
167 (define_split
168 [(set (match_operand:CC 0 "cc_reg_not_cr0_operand" "")
169 (compare:CC (sign_extend:DI (match_operand:QI 1 "gpc_reg_operand" ""))
170 (const_int 0)))
171 (clobber (match_scratch:DI 2 ""))]
172 "TARGET_POWERPC64 && reload_completed"
173 [(set (match_dup 2)
174 (sign_extend:DI (match_dup 1)))
175 (set (match_dup 0)
176 (compare:CC (match_dup 2)
177 (const_int 0)))]
178 "")
179
180 (define_insn ""
181 [(set (match_operand:CC 2 "cc_reg_operand" "=x,?y")
182 (compare:CC (sign_extend:DI (match_operand:QI 1 "gpc_reg_operand" "r,r"))
183 (const_int 0)))
184 (set (match_operand:DI 0 "gpc_reg_operand" "=r,r")
185 (sign_extend:DI (match_dup 1)))]
186 "TARGET_POWERPC64"
187 "@
188 extsb. %0,%1
189 #"
190 [(set_attr "type" "compare")
191 (set_attr "length" "4,8")])
192
193 (define_split
194 [(set (match_operand:CC 2 "cc_reg_not_cr0_operand" "")
195 (compare:CC (sign_extend:DI (match_operand:QI 1 "gpc_reg_operand" ""))
196 (const_int 0)))
197 (set (match_operand:DI 0 "gpc_reg_operand" "")
198 (sign_extend:DI (match_dup 1)))]
199 "TARGET_POWERPC64 && reload_completed"
200 [(set (match_dup 0)
201 (sign_extend:DI (match_dup 1)))
202 (set (match_dup 2)
203 (compare:CC (match_dup 0)
204 (const_int 0)))]
205 "")
206
207 (define_expand "zero_extendhidi2"
208 [(set (match_operand:DI 0 "gpc_reg_operand" "")
209 (zero_extend:DI (match_operand:HI 1 "gpc_reg_operand" "")))]
210 "TARGET_POWERPC64"
211 "")
212
213 (define_insn ""
214 [(set (match_operand:DI 0 "gpc_reg_operand" "=r,r")
215 (zero_extend:DI (match_operand:HI 1 "reg_or_mem_operand" "m,r")))]
216 "TARGET_POWERPC64"
217 "@
218 lhz%U1%X1 %0,%1
219 rldicl %0,%1,0,48"
220 [(set_attr "type" "load,*")])
221
222 (define_insn ""
223 [(set (match_operand:CC 0 "cc_reg_operand" "=x,?y")
224 (compare:CC (zero_extend:DI (match_operand:HI 1 "gpc_reg_operand" "r,r"))
225 (const_int 0)))
226 (clobber (match_scratch:DI 2 "=r,r"))]
227 "TARGET_POWERPC64"
228 "@
229 rldicl. %2,%1,0,48
230 #"
231 [(set_attr "type" "compare")
232 (set_attr "length" "4,8")])
233
234 (define_split
235 [(set (match_operand:CC 0 "cc_reg_not_cr0_operand" "")
236 (compare:CC (zero_extend:DI (match_operand:HI 1 "gpc_reg_operand" ""))
237 (const_int 0)))
238 (clobber (match_scratch:DI 2 ""))]
239 "TARGET_POWERPC64 && reload_completed"
240 [(set (match_dup 2)
241 (zero_extend:DI (match_dup 1)))
242 (set (match_dup 0)
243 (compare:CC (match_dup 2)
244 (const_int 0)))]
245 "")
246
247 (define_insn ""
248 [(set (match_operand:CC 2 "cc_reg_operand" "=x,?y")
249 (compare:CC (zero_extend:DI (match_operand:HI 1 "gpc_reg_operand" "r,r"))
250 (const_int 0)))
251 (set (match_operand:DI 0 "gpc_reg_operand" "=r,r")
252 (zero_extend:DI (match_dup 1)))]
253 "TARGET_POWERPC64"
254 "@
255 rldicl. %0,%1,0,48
256 #"
257 [(set_attr "type" "compare")
258 (set_attr "length" "4,8")])
259
260 (define_split
261 [(set (match_operand:CC 2 "cc_reg_not_cr0_operand" "")
262 (compare:CC (zero_extend:DI (match_operand:HI 1 "gpc_reg_operand" ""))
263 (const_int 0)))
264 (set (match_operand:DI 0 "gpc_reg_operand" "")
265 (zero_extend:DI (match_dup 1)))]
266 "TARGET_POWERPC64 && reload_completed"
267 [(set (match_dup 0)
268 (zero_extend:DI (match_dup 1)))
269 (set (match_dup 2)
270 (compare:CC (match_dup 0)
271 (const_int 0)))]
272 "")
273
274 (define_expand "extendhidi2"
275 [(set (match_operand:DI 0 "gpc_reg_operand" "")
276 (sign_extend:DI (match_operand:HI 1 "gpc_reg_operand" "")))]
277 "TARGET_POWERPC64"
278 "")
279
280 (define_insn ""
281 [(set (match_operand:DI 0 "gpc_reg_operand" "=r,r")
282 (sign_extend:DI (match_operand:HI 1 "reg_or_mem_operand" "m,r")))]
283 "TARGET_POWERPC64"
284 "@
285 lha%U1%X1 %0,%1
286 extsh %0,%1"
287 [(set_attr "type" "load_ext,*")])
288
289 (define_insn ""
290 [(set (match_operand:CC 0 "cc_reg_operand" "=x,?y")
291 (compare:CC (sign_extend:DI (match_operand:HI 1 "gpc_reg_operand" "r,r"))
292 (const_int 0)))
293 (clobber (match_scratch:DI 2 "=r,r"))]
294 "TARGET_POWERPC64"
295 "@
296 extsh. %2,%1
297 #"
298 [(set_attr "type" "compare")
299 (set_attr "length" "4,8")])
300
301 (define_split
302 [(set (match_operand:CC 0 "cc_reg_not_cr0_operand" "")
303 (compare:CC (sign_extend:DI (match_operand:HI 1 "gpc_reg_operand" ""))
304 (const_int 0)))
305 (clobber (match_scratch:DI 2 ""))]
306 "TARGET_POWERPC64 && reload_completed"
307 [(set (match_dup 2)
308 (sign_extend:DI (match_dup 1)))
309 (set (match_dup 0)
310 (compare:CC (match_dup 2)
311 (const_int 0)))]
312 "")
313
314 (define_insn ""
315 [(set (match_operand:CC 2 "cc_reg_operand" "=x,?y")
316 (compare:CC (sign_extend:DI (match_operand:HI 1 "gpc_reg_operand" "r,r"))
317 (const_int 0)))
318 (set (match_operand:DI 0 "gpc_reg_operand" "=r,r")
319 (sign_extend:DI (match_dup 1)))]
320 "TARGET_POWERPC64"
321 "@
322 extsh. %0,%1
323 #"
324 [(set_attr "type" "compare")
325 (set_attr "length" "4,8")])
326
327 (define_split
328 [(set (match_operand:CC 2 "cc_reg_not_cr0_operand" "")
329 (compare:CC (sign_extend:DI (match_operand:HI 1 "gpc_reg_operand" ""))
330 (const_int 0)))
331 (set (match_operand:DI 0 "gpc_reg_operand" "")
332 (sign_extend:DI (match_dup 1)))]
333 "TARGET_POWERPC64 && reload_completed"
334 [(set (match_dup 0)
335 (sign_extend:DI (match_dup 1)))
336 (set (match_dup 2)
337 (compare:CC (match_dup 0)
338 (const_int 0)))]
339 "")
340
341 (define_expand "zero_extendsidi2"
342 [(set (match_operand:DI 0 "gpc_reg_operand" "")
343 (zero_extend:DI (match_operand:SI 1 "gpc_reg_operand" "")))]
344 "TARGET_POWERPC64"
345 "")
346
347 (define_insn ""
348 [(set (match_operand:DI 0 "gpc_reg_operand" "=r,r")
349 (zero_extend:DI (match_operand:SI 1 "reg_or_mem_operand" "m,r")))]
350 "TARGET_POWERPC64"
351 "@
352 lwz%U1%X1 %0,%1
353 rldicl %0,%1,0,32"
354 [(set_attr "type" "load,*")])
355
356 (define_insn ""
357 [(set (match_operand:CC 0 "cc_reg_operand" "=x,?y")
358 (compare:CC (zero_extend:DI (match_operand:SI 1 "gpc_reg_operand" "r,r"))
359 (const_int 0)))
360 (clobber (match_scratch:DI 2 "=r,r"))]
361 "TARGET_POWERPC64"
362 "@
363 rldicl. %2,%1,0,32
364 #"
365 [(set_attr "type" "compare")
366 (set_attr "length" "4,8")])
367
368 (define_split
369 [(set (match_operand:CC 0 "cc_reg_not_cr0_operand" "")
370 (compare:CC (zero_extend:DI (match_operand:SI 1 "gpc_reg_operand" ""))
371 (const_int 0)))
372 (clobber (match_scratch:DI 2 ""))]
373 "TARGET_POWERPC64 && reload_completed"
374 [(set (match_dup 2)
375 (zero_extend:DI (match_dup 1)))
376 (set (match_dup 0)
377 (compare:CC (match_dup 2)
378 (const_int 0)))]
379 "")
380
381 (define_insn ""
382 [(set (match_operand:CC 2 "cc_reg_operand" "=x,?y")
383 (compare:CC (zero_extend:DI (match_operand:SI 1 "gpc_reg_operand" "r,r"))
384 (const_int 0)))
385 (set (match_operand:DI 0 "gpc_reg_operand" "=r,r")
386 (zero_extend:DI (match_dup 1)))]
387 "TARGET_POWERPC64"
388 "@
389 rldicl. %0,%1,0,32
390 #"
391 [(set_attr "type" "compare")
392 (set_attr "length" "4,8")])
393
394 (define_split
395 [(set (match_operand:CC 2 "cc_reg_not_cr0_operand" "")
396 (compare:CC (zero_extend:DI (match_operand:SI 1 "gpc_reg_operand" ""))
397 (const_int 0)))
398 (set (match_operand:DI 0 "gpc_reg_operand" "")
399 (zero_extend:DI (match_dup 1)))]
400 "TARGET_POWERPC64 && reload_completed"
401 [(set (match_dup 0)
402 (zero_extend:DI (match_dup 1)))
403 (set (match_dup 2)
404 (compare:CC (match_dup 0)
405 (const_int 0)))]
406 "")
407
408 (define_expand "extendsidi2"
409 [(set (match_operand:DI 0 "gpc_reg_operand" "")
410 (sign_extend:DI (match_operand:SI 1 "gpc_reg_operand" "")))]
411 "TARGET_POWERPC64"
412 "")
413
414 (define_insn ""
415 [(set (match_operand:DI 0 "gpc_reg_operand" "=r,r")
416 (sign_extend:DI (match_operand:SI 1 "lwa_operand" "m,r")))]
417 "TARGET_POWERPC64"
418 "@
419 lwa%U1%X1 %0,%1
420 extsw %0,%1"
421 [(set_attr "type" "load_ext,*")])
422
423 (define_insn ""
424 [(set (match_operand:CC 0 "cc_reg_operand" "=x,?y")
425 (compare:CC (sign_extend:DI (match_operand:SI 1 "gpc_reg_operand" "r,r"))
426 (const_int 0)))
427 (clobber (match_scratch:DI 2 "=r,r"))]
428 "TARGET_POWERPC64"
429 "@
430 extsw. %2,%1
431 #"
432 [(set_attr "type" "compare")
433 (set_attr "length" "4,8")])
434
435 (define_split
436 [(set (match_operand:CC 0 "cc_reg_not_cr0_operand" "")
437 (compare:CC (sign_extend:DI (match_operand:SI 1 "gpc_reg_operand" ""))
438 (const_int 0)))
439 (clobber (match_scratch:DI 2 ""))]
440 "TARGET_POWERPC64 && reload_completed"
441 [(set (match_dup 2)
442 (sign_extend:DI (match_dup 1)))
443 (set (match_dup 0)
444 (compare:CC (match_dup 2)
445 (const_int 0)))]
446 "")
447
448 (define_insn ""
449 [(set (match_operand:CC 2 "cc_reg_operand" "=x,?y")
450 (compare:CC (sign_extend:DI (match_operand:SI 1 "gpc_reg_operand" "r,r"))
451 (const_int 0)))
452 (set (match_operand:DI 0 "gpc_reg_operand" "=r,r")
453 (sign_extend:DI (match_dup 1)))]
454 "TARGET_POWERPC64"
455 "@
456 extsw. %0,%1
457 #"
458 [(set_attr "type" "compare")
459 (set_attr "length" "4,8")])
460
461 (define_split
462 [(set (match_operand:CC 2 "cc_reg_not_cr0_operand" "")
463 (compare:CC (sign_extend:DI (match_operand:SI 1 "gpc_reg_operand" ""))
464 (const_int 0)))
465 (set (match_operand:DI 0 "gpc_reg_operand" "")
466 (sign_extend:DI (match_dup 1)))]
467 "TARGET_POWERPC64 && reload_completed"
468 [(set (match_dup 0)
469 (sign_extend:DI (match_dup 1)))
470 (set (match_dup 2)
471 (compare:CC (match_dup 0)
472 (const_int 0)))]
473 "")
474
475 (define_expand "zero_extendqisi2"
476 [(set (match_operand:SI 0 "gpc_reg_operand" "")
477 (zero_extend:SI (match_operand:QI 1 "gpc_reg_operand" "")))]
478 ""
479 "")
480
481 (define_insn ""
482 [(set (match_operand:SI 0 "gpc_reg_operand" "=r,r")
483 (zero_extend:SI (match_operand:QI 1 "reg_or_mem_operand" "m,r")))]
484 ""
485 "@
486 lbz%U1%X1 %0,%1
487 {rlinm|rlwinm} %0,%1,0,0xff"
488 [(set_attr "type" "load,*")])
489
490 (define_insn ""
491 [(set (match_operand:CC 0 "cc_reg_operand" "=x,?y")
492 (compare:CC (zero_extend:SI (match_operand:QI 1 "gpc_reg_operand" "r,r"))
493 (const_int 0)))
494 (clobber (match_scratch:SI 2 "=r,r"))]
495 ""
496 "@
497 {andil.|andi.} %2,%1,0xff
498 #"
499 [(set_attr "type" "compare")
500 (set_attr "length" "4,8")])
501
502 (define_split
503 [(set (match_operand:CC 0 "cc_reg_not_cr0_operand" "")
504 (compare:CC (zero_extend:SI (match_operand:QI 1 "gpc_reg_operand" ""))
505 (const_int 0)))
506 (clobber (match_scratch:SI 2 ""))]
507 "reload_completed"
508 [(set (match_dup 2)
509 (zero_extend:SI (match_dup 1)))
510 (set (match_dup 0)
511 (compare:CC (match_dup 2)
512 (const_int 0)))]
513 "")
514
515 (define_insn ""
516 [(set (match_operand:CC 2 "cc_reg_operand" "=x,?y")
517 (compare:CC (zero_extend:SI (match_operand:QI 1 "gpc_reg_operand" "r,r"))
518 (const_int 0)))
519 (set (match_operand:SI 0 "gpc_reg_operand" "=r,r")
520 (zero_extend:SI (match_dup 1)))]
521 ""
522 "@
523 {andil.|andi.} %0,%1,0xff
524 #"
525 [(set_attr "type" "compare")
526 (set_attr "length" "4,8")])
527
528 (define_split
529 [(set (match_operand:CC 2 "cc_reg_not_cr0_operand" "")
530 (compare:CC (zero_extend:SI (match_operand:QI 1 "gpc_reg_operand" ""))
531 (const_int 0)))
532 (set (match_operand:SI 0 "gpc_reg_operand" "")
533 (zero_extend:SI (match_dup 1)))]
534 "reload_completed"
535 [(set (match_dup 0)
536 (zero_extend:SI (match_dup 1)))
537 (set (match_dup 2)
538 (compare:CC (match_dup 0)
539 (const_int 0)))]
540 "")
541
542 (define_expand "extendqisi2"
543 [(use (match_operand:SI 0 "gpc_reg_operand" ""))
544 (use (match_operand:QI 1 "gpc_reg_operand" ""))]
545 ""
546 "
547 {
548 if (TARGET_POWERPC)
549 emit_insn (gen_extendqisi2_ppc (operands[0], operands[1]));
550 else if (TARGET_POWER)
551 emit_insn (gen_extendqisi2_power (operands[0], operands[1]));
552 else
553 emit_insn (gen_extendqisi2_no_power (operands[0], operands[1]));
554 DONE;
555 }")
556
557 (define_insn "extendqisi2_ppc"
558 [(set (match_operand:SI 0 "gpc_reg_operand" "=r")
559 (sign_extend:SI (match_operand:QI 1 "gpc_reg_operand" "r")))]
560 "TARGET_POWERPC"
561 "extsb %0,%1")
562
563 (define_insn ""
564 [(set (match_operand:CC 0 "cc_reg_operand" "=x,?y")
565 (compare:CC (sign_extend:SI (match_operand:QI 1 "gpc_reg_operand" "r,r"))
566 (const_int 0)))
567 (clobber (match_scratch:SI 2 "=r,r"))]
568 "TARGET_POWERPC"
569 "@
570 extsb. %2,%1
571 #"
572 [(set_attr "type" "compare")
573 (set_attr "length" "4,8")])
574
575 (define_split
576 [(set (match_operand:CC 0 "cc_reg_not_cr0_operand" "")
577 (compare:CC (sign_extend:SI (match_operand:QI 1 "gpc_reg_operand" ""))
578 (const_int 0)))
579 (clobber (match_scratch:SI 2 ""))]
580 "TARGET_POWERPC && reload_completed"
581 [(set (match_dup 2)
582 (sign_extend:SI (match_dup 1)))
583 (set (match_dup 0)
584 (compare:CC (match_dup 2)
585 (const_int 0)))]
586 "")
587
588 (define_insn ""
589 [(set (match_operand:CC 2 "cc_reg_operand" "=x,?y")
590 (compare:CC (sign_extend:SI (match_operand:QI 1 "gpc_reg_operand" "r,r"))
591 (const_int 0)))
592 (set (match_operand:SI 0 "gpc_reg_operand" "=r,r")
593 (sign_extend:SI (match_dup 1)))]
594 "TARGET_POWERPC"
595 "@
596 extsb. %0,%1
597 #"
598 [(set_attr "type" "compare")
599 (set_attr "length" "4,8")])
600
601 (define_split
602 [(set (match_operand:CC 2 "cc_reg_not_cr0_operand" "")
603 (compare:CC (sign_extend:SI (match_operand:QI 1 "gpc_reg_operand" ""))
604 (const_int 0)))
605 (set (match_operand:SI 0 "gpc_reg_operand" "")
606 (sign_extend:SI (match_dup 1)))]
607 "TARGET_POWERPC && reload_completed"
608 [(set (match_dup 0)
609 (sign_extend:SI (match_dup 1)))
610 (set (match_dup 2)
611 (compare:CC (match_dup 0)
612 (const_int 0)))]
613 "")
614
615 (define_expand "extendqisi2_power"
616 [(parallel [(set (match_dup 2)
617 (ashift:SI (match_operand:QI 1 "gpc_reg_operand" "")
618 (const_int 24)))
619 (clobber (scratch:SI))])
620 (parallel [(set (match_operand:SI 0 "gpc_reg_operand" "")
621 (ashiftrt:SI (match_dup 2)
622 (const_int 24)))
623 (clobber (scratch:SI))])]
624 "TARGET_POWER"
625 "
626 { operands[1] = gen_lowpart (SImode, operands[1]);
627 operands[2] = gen_reg_rtx (SImode); }")
628
629 (define_expand "extendqisi2_no_power"
630 [(set (match_dup 2)
631 (ashift:SI (match_operand:QI 1 "gpc_reg_operand" "")
632 (const_int 24)))
633 (set (match_operand:SI 0 "gpc_reg_operand" "")
634 (ashiftrt:SI (match_dup 2)
635 (const_int 24)))]
636 "! TARGET_POWER && ! TARGET_POWERPC"
637 "
638 { operands[1] = gen_lowpart (SImode, operands[1]);
639 operands[2] = gen_reg_rtx (SImode); }")
640
641 (define_expand "zero_extendqihi2"
642 [(set (match_operand:HI 0 "gpc_reg_operand" "")
643 (zero_extend:HI (match_operand:QI 1 "gpc_reg_operand" "")))]
644 ""
645 "")
646
647 (define_insn ""
648 [(set (match_operand:HI 0 "gpc_reg_operand" "=r,r")
649 (zero_extend:HI (match_operand:QI 1 "reg_or_mem_operand" "m,r")))]
650 ""
651 "@
652 lbz%U1%X1 %0,%1
653 {rlinm|rlwinm} %0,%1,0,0xff"
654 [(set_attr "type" "load,*")])
655
656 (define_insn ""
657 [(set (match_operand:CC 0 "cc_reg_operand" "=x,?y")
658 (compare:CC (zero_extend:HI (match_operand:QI 1 "gpc_reg_operand" "r,r"))
659 (const_int 0)))
660 (clobber (match_scratch:HI 2 "=r,r"))]
661 ""
662 "@
663 {andil.|andi.} %2,%1,0xff
664 #"
665 [(set_attr "type" "compare")
666 (set_attr "length" "4,8")])
667
668 (define_split
669 [(set (match_operand:CC 0 "cc_reg_not_cr0_operand" "")
670 (compare:CC (zero_extend:HI (match_operand:QI 1 "gpc_reg_operand" ""))
671 (const_int 0)))
672 (clobber (match_scratch:HI 2 ""))]
673 "reload_completed"
674 [(set (match_dup 2)
675 (zero_extend:HI (match_dup 1)))
676 (set (match_dup 0)
677 (compare:CC (match_dup 2)
678 (const_int 0)))]
679 "")
680
681 (define_insn ""
682 [(set (match_operand:CC 2 "cc_reg_operand" "=x,?y")
683 (compare:CC (zero_extend:HI (match_operand:QI 1 "gpc_reg_operand" "r,r"))
684 (const_int 0)))
685 (set (match_operand:HI 0 "gpc_reg_operand" "=r,r")
686 (zero_extend:HI (match_dup 1)))]
687 ""
688 "@
689 {andil.|andi.} %0,%1,0xff
690 #"
691 [(set_attr "type" "compare")
692 (set_attr "length" "4,8")])
693
694 (define_split
695 [(set (match_operand:CC 2 "cc_reg_not_cr0_operand" "")
696 (compare:CC (zero_extend:HI (match_operand:QI 1 "gpc_reg_operand" ""))
697 (const_int 0)))
698 (set (match_operand:HI 0 "gpc_reg_operand" "")
699 (zero_extend:HI (match_dup 1)))]
700 "reload_completed"
701 [(set (match_dup 0)
702 (zero_extend:HI (match_dup 1)))
703 (set (match_dup 2)
704 (compare:CC (match_dup 0)
705 (const_int 0)))]
706 "")
707
708 (define_expand "extendqihi2"
709 [(use (match_operand:HI 0 "gpc_reg_operand" ""))
710 (use (match_operand:QI 1 "gpc_reg_operand" ""))]
711 ""
712 "
713 {
714 if (TARGET_POWERPC)
715 emit_insn (gen_extendqihi2_ppc (operands[0], operands[1]));
716 else if (TARGET_POWER)
717 emit_insn (gen_extendqihi2_power (operands[0], operands[1]));
718 else
719 emit_insn (gen_extendqihi2_no_power (operands[0], operands[1]));
720 DONE;
721 }")
722
723 (define_insn "extendqihi2_ppc"
724 [(set (match_operand:HI 0 "gpc_reg_operand" "=r")
725 (sign_extend:HI (match_operand:QI 1 "gpc_reg_operand" "r")))]
726 "TARGET_POWERPC"
727 "extsb %0,%1")
728
729 (define_insn ""
730 [(set (match_operand:CC 0 "cc_reg_operand" "=x,?y")
731 (compare:CC (sign_extend:HI (match_operand:QI 1 "gpc_reg_operand" "r,r"))
732 (const_int 0)))
733 (clobber (match_scratch:HI 2 "=r,r"))]
734 "TARGET_POWERPC"
735 "@
736 extsb. %2,%1
737 #"
738 [(set_attr "type" "compare")
739 (set_attr "length" "4,8")])
740
741 (define_split
742 [(set (match_operand:CC 0 "cc_reg_not_cr0_operand" "")
743 (compare:CC (sign_extend:HI (match_operand:QI 1 "gpc_reg_operand" ""))
744 (const_int 0)))
745 (clobber (match_scratch:HI 2 ""))]
746 "TARGET_POWERPC && reload_completed"
747 [(set (match_dup 2)
748 (sign_extend:HI (match_dup 1)))
749 (set (match_dup 0)
750 (compare:CC (match_dup 2)
751 (const_int 0)))]
752 "")
753
754 (define_insn ""
755 [(set (match_operand:CC 2 "cc_reg_operand" "=x,?y")
756 (compare:CC (sign_extend:HI (match_operand:QI 1 "gpc_reg_operand" "r,r"))
757 (const_int 0)))
758 (set (match_operand:HI 0 "gpc_reg_operand" "=r,r")
759 (sign_extend:HI (match_dup 1)))]
760 "TARGET_POWERPC"
761 "@
762 extsb. %0,%1
763 #"
764 [(set_attr "type" "compare")
765 (set_attr "length" "4,8")])
766
767 (define_split
768 [(set (match_operand:CC 2 "cc_reg_not_cr0_operand" "")
769 (compare:CC (sign_extend:HI (match_operand:QI 1 "gpc_reg_operand" ""))
770 (const_int 0)))
771 (set (match_operand:HI 0 "gpc_reg_operand" "")
772 (sign_extend:HI (match_dup 1)))]
773 "TARGET_POWERPC && reload_completed"
774 [(set (match_dup 0)
775 (sign_extend:HI (match_dup 1)))
776 (set (match_dup 2)
777 (compare:CC (match_dup 0)
778 (const_int 0)))]
779 "")
780
781 (define_expand "extendqihi2_power"
782 [(parallel [(set (match_dup 2)
783 (ashift:SI (match_operand:QI 1 "gpc_reg_operand" "")
784 (const_int 24)))
785 (clobber (scratch:SI))])
786 (parallel [(set (match_operand:HI 0 "gpc_reg_operand" "")
787 (ashiftrt:SI (match_dup 2)
788 (const_int 24)))
789 (clobber (scratch:SI))])]
790 "TARGET_POWER"
791 "
792 { operands[0] = gen_lowpart (SImode, operands[0]);
793 operands[1] = gen_lowpart (SImode, operands[1]);
794 operands[2] = gen_reg_rtx (SImode); }")
795
796 (define_expand "extendqihi2_no_power"
797 [(set (match_dup 2)
798 (ashift:SI (match_operand:QI 1 "gpc_reg_operand" "")
799 (const_int 24)))
800 (set (match_operand:HI 0 "gpc_reg_operand" "")
801 (ashiftrt:SI (match_dup 2)
802 (const_int 24)))]
803 "! TARGET_POWER && ! TARGET_POWERPC"
804 "
805 { operands[0] = gen_lowpart (SImode, operands[0]);
806 operands[1] = gen_lowpart (SImode, operands[1]);
807 operands[2] = gen_reg_rtx (SImode); }")
808
809 (define_expand "zero_extendhisi2"
810 [(set (match_operand:SI 0 "gpc_reg_operand" "")
811 (zero_extend:SI (match_operand:HI 1 "gpc_reg_operand" "")))]
812 ""
813 "")
814
815 (define_insn ""
816 [(set (match_operand:SI 0 "gpc_reg_operand" "=r,r")
817 (zero_extend:SI (match_operand:HI 1 "reg_or_mem_operand" "m,r")))]
818 ""
819 "@
820 lhz%U1%X1 %0,%1
821 {rlinm|rlwinm} %0,%1,0,0xffff"
822 [(set_attr "type" "load,*")])
823
824 (define_insn ""
825 [(set (match_operand:CC 0 "cc_reg_operand" "=x,?y")
826 (compare:CC (zero_extend:SI (match_operand:HI 1 "gpc_reg_operand" "r,r"))
827 (const_int 0)))
828 (clobber (match_scratch:SI 2 "=r,r"))]
829 ""
830 "@
831 {andil.|andi.} %2,%1,0xffff
832 #"
833 [(set_attr "type" "compare")
834 (set_attr "length" "4,8")])
835
836 (define_split
837 [(set (match_operand:CC 0 "cc_reg_not_cr0_operand" "")
838 (compare:CC (zero_extend:SI (match_operand:HI 1 "gpc_reg_operand" ""))
839 (const_int 0)))
840 (clobber (match_scratch:SI 2 ""))]
841 "reload_completed"
842 [(set (match_dup 2)
843 (zero_extend:SI (match_dup 1)))
844 (set (match_dup 0)
845 (compare:CC (match_dup 2)
846 (const_int 0)))]
847 "")
848
849 (define_insn ""
850 [(set (match_operand:CC 2 "cc_reg_operand" "=x,?y")
851 (compare:CC (zero_extend:SI (match_operand:HI 1 "gpc_reg_operand" "r,r"))
852 (const_int 0)))
853 (set (match_operand:SI 0 "gpc_reg_operand" "=r,r")
854 (zero_extend:SI (match_dup 1)))]
855 ""
856 "@
857 {andil.|andi.} %0,%1,0xffff
858 #"
859 [(set_attr "type" "compare")
860 (set_attr "length" "4,8")])
861
862 (define_split
863 [(set (match_operand:CC 2 "cc_reg_not_cr0_operand" "")
864 (compare:CC (zero_extend:SI (match_operand:HI 1 "gpc_reg_operand" ""))
865 (const_int 0)))
866 (set (match_operand:SI 0 "gpc_reg_operand" "")
867 (zero_extend:SI (match_dup 1)))]
868 "reload_completed"
869 [(set (match_dup 0)
870 (zero_extend:SI (match_dup 1)))
871 (set (match_dup 2)
872 (compare:CC (match_dup 0)
873 (const_int 0)))]
874 "")
875
876 (define_expand "extendhisi2"
877 [(set (match_operand:SI 0 "gpc_reg_operand" "")
878 (sign_extend:SI (match_operand:HI 1 "gpc_reg_operand" "")))]
879 ""
880 "")
881
882 (define_insn ""
883 [(set (match_operand:SI 0 "gpc_reg_operand" "=r,r")
884 (sign_extend:SI (match_operand:HI 1 "reg_or_mem_operand" "m,r")))]
885 ""
886 "@
887 lha%U1%X1 %0,%1
888 {exts|extsh} %0,%1"
889 [(set_attr "type" "load_ext,*")])
890
891 (define_insn ""
892 [(set (match_operand:CC 0 "cc_reg_operand" "=x,?y")
893 (compare:CC (sign_extend:SI (match_operand:HI 1 "gpc_reg_operand" "r,r"))
894 (const_int 0)))
895 (clobber (match_scratch:SI 2 "=r,r"))]
896 ""
897 "@
898 {exts.|extsh.} %2,%1
899 #"
900 [(set_attr "type" "compare")
901 (set_attr "length" "4,8")])
902
903 (define_split
904 [(set (match_operand:CC 0 "cc_reg_not_cr0_operand" "")
905 (compare:CC (sign_extend:SI (match_operand:HI 1 "gpc_reg_operand" ""))
906 (const_int 0)))
907 (clobber (match_scratch:SI 2 ""))]
908 "reload_completed"
909 [(set (match_dup 2)
910 (sign_extend:SI (match_dup 1)))
911 (set (match_dup 0)
912 (compare:CC (match_dup 2)
913 (const_int 0)))]
914 "")
915
916 (define_insn ""
917 [(set (match_operand:CC 2 "cc_reg_operand" "=x,?y")
918 (compare:CC (sign_extend:SI (match_operand:HI 1 "gpc_reg_operand" "r,r"))
919 (const_int 0)))
920 (set (match_operand:SI 0 "gpc_reg_operand" "=r,r")
921 (sign_extend:SI (match_dup 1)))]
922 ""
923 "@
924 {exts.|extsh.} %0,%1
925 #"
926 [(set_attr "type" "compare")
927 (set_attr "length" "4,8")])
928 \f
929 (define_split
930 [(set (match_operand:CC 2 "cc_reg_not_cr0_operand" "")
931 (compare:CC (sign_extend:SI (match_operand:HI 1 "gpc_reg_operand" ""))
932 (const_int 0)))
933 (set (match_operand:SI 0 "gpc_reg_operand" "")
934 (sign_extend:SI (match_dup 1)))]
935 "reload_completed"
936 [(set (match_dup 0)
937 (sign_extend:SI (match_dup 1)))
938 (set (match_dup 2)
939 (compare:CC (match_dup 0)
940 (const_int 0)))]
941 "")
942
943 ;; Fixed-point arithmetic insns.
944
945 ;; Discourage ai/addic because of carry but provide it in an alternative
946 ;; allowing register zero as source.
947 (define_expand "addsi3"
948 [(set (match_operand:SI 0 "gpc_reg_operand" "")
949 (plus:SI (match_operand:SI 1 "gpc_reg_operand" "")
950 (match_operand:SI 2 "reg_or_arith_cint_operand" "")))]
951 ""
952 "
953 {
954 if (GET_CODE (operands[2]) == CONST_INT
955 && ! add_operand (operands[2], SImode))
956 {
957 rtx tmp = ((no_new_pseudos || rtx_equal_p (operands[0], operands[1]))
958 ? operands[0] : gen_reg_rtx (SImode));
959
960 HOST_WIDE_INT val = INTVAL (operands[2]);
961 HOST_WIDE_INT low = ((val & 0xffff) ^ 0x8000) - 0x8000;
962 HOST_WIDE_INT rest = trunc_int_for_mode (val - low, SImode);
963
964 /* The ordering here is important for the prolog expander.
965 When space is allocated from the stack, adding 'low' first may
966 produce a temporary deallocation (which would be bad). */
967 emit_insn (gen_addsi3 (tmp, operands[1], GEN_INT (rest)));
968 emit_insn (gen_addsi3 (operands[0], tmp, GEN_INT (low)));
969 DONE;
970 }
971 }")
972
973 (define_insn "*addsi3_internal1"
974 [(set (match_operand:SI 0 "gpc_reg_operand" "=r,r,?r,r")
975 (plus:SI (match_operand:SI 1 "gpc_reg_operand" "%r,b,r,b")
976 (match_operand:SI 2 "add_operand" "r,I,I,L")))]
977 ""
978 "@
979 {cax|add} %0,%1,%2
980 {cal %0,%2(%1)|addi %0,%1,%2}
981 {ai|addic} %0,%1,%2
982 {cau|addis} %0,%1,%v2"
983 [(set_attr "length" "4,4,4,4")])
984
985 (define_insn "addsi3_high"
986 [(set (match_operand:SI 0 "gpc_reg_operand" "=b")
987 (plus:SI (match_operand:SI 1 "gpc_reg_operand" "b")
988 (high:SI (match_operand 2 "" ""))))]
989 "TARGET_MACHO && !TARGET_64BIT"
990 "{cau|addis} %0,%1,ha16(%2)"
991 [(set_attr "length" "4")])
992
993 (define_insn "*addsi3_internal2"
994 [(set (match_operand:CC 0 "cc_reg_operand" "=x,x,?y,?y")
995 (compare:CC (plus:SI (match_operand:SI 1 "gpc_reg_operand" "%r,r,r,r")
996 (match_operand:SI 2 "reg_or_short_operand" "r,I,r,I"))
997 (const_int 0)))
998 (clobber (match_scratch:SI 3 "=r,r,r,r"))]
999 "! TARGET_POWERPC64"
1000 "@
1001 {cax.|add.} %3,%1,%2
1002 {ai.|addic.} %3,%1,%2
1003 #
1004 #"
1005 [(set_attr "type" "fast_compare,compare,compare,compare")
1006 (set_attr "length" "4,4,8,8")])
1007
1008 (define_split
1009 [(set (match_operand:CC 0 "cc_reg_not_cr0_operand" "")
1010 (compare:CC (plus:SI (match_operand:SI 1 "gpc_reg_operand" "")
1011 (match_operand:SI 2 "reg_or_short_operand" ""))
1012 (const_int 0)))
1013 (clobber (match_scratch:SI 3 ""))]
1014 "! TARGET_POWERPC64 && reload_completed"
1015 [(set (match_dup 3)
1016 (plus:SI (match_dup 1)
1017 (match_dup 2)))
1018 (set (match_dup 0)
1019 (compare:CC (match_dup 3)
1020 (const_int 0)))]
1021 "")
1022
1023 (define_insn "*addsi3_internal3"
1024 [(set (match_operand:CC 3 "cc_reg_operand" "=x,x,?y,?y")
1025 (compare:CC (plus:SI (match_operand:SI 1 "gpc_reg_operand" "%r,r,r,r")
1026 (match_operand:SI 2 "reg_or_short_operand" "r,I,r,I"))
1027 (const_int 0)))
1028 (set (match_operand:SI 0 "gpc_reg_operand" "=r,r,r,r")
1029 (plus:SI (match_dup 1)
1030 (match_dup 2)))]
1031 "! TARGET_POWERPC64"
1032 "@
1033 {cax.|add.} %0,%1,%2
1034 {ai.|addic.} %0,%1,%2
1035 #
1036 #"
1037 [(set_attr "type" "fast_compare,compare,compare,compare")
1038 (set_attr "length" "4,4,8,8")])
1039
1040 (define_split
1041 [(set (match_operand:CC 3 "cc_reg_not_cr0_operand" "")
1042 (compare:CC (plus:SI (match_operand:SI 1 "gpc_reg_operand" "")
1043 (match_operand:SI 2 "reg_or_short_operand" ""))
1044 (const_int 0)))
1045 (set (match_operand:SI 0 "gpc_reg_operand" "")
1046 (plus:SI (match_dup 1) (match_dup 2)))]
1047 "! TARGET_POWERPC64 && reload_completed"
1048 [(set (match_dup 0)
1049 (plus:SI (match_dup 1)
1050 (match_dup 2)))
1051 (set (match_dup 3)
1052 (compare:CC (match_dup 0)
1053 (const_int 0)))]
1054 "")
1055
1056 ;; Split an add that we can't do in one insn into two insns, each of which
1057 ;; does one 16-bit part. This is used by combine. Note that the low-order
1058 ;; add should be last in case the result gets used in an address.
1059
1060 (define_split
1061 [(set (match_operand:SI 0 "gpc_reg_operand" "")
1062 (plus:SI (match_operand:SI 1 "gpc_reg_operand" "")
1063 (match_operand:SI 2 "non_add_cint_operand" "")))]
1064 ""
1065 [(set (match_dup 0) (plus:SI (match_dup 1) (match_dup 3)))
1066 (set (match_dup 0) (plus:SI (match_dup 0) (match_dup 4)))]
1067 "
1068 {
1069 HOST_WIDE_INT val = INTVAL (operands[2]);
1070 HOST_WIDE_INT low = ((val & 0xffff) ^ 0x8000) - 0x8000;
1071 HOST_WIDE_INT rest = trunc_int_for_mode (val - low, SImode);
1072
1073 operands[3] = GEN_INT (rest);
1074 operands[4] = GEN_INT (low);
1075 }")
1076
1077 (define_insn "one_cmplsi2"
1078 [(set (match_operand:SI 0 "gpc_reg_operand" "=r")
1079 (not:SI (match_operand:SI 1 "gpc_reg_operand" "r")))]
1080 ""
1081 "nor %0,%1,%1")
1082
1083 (define_insn ""
1084 [(set (match_operand:CC 0 "cc_reg_operand" "=x,?y")
1085 (compare:CC (not:SI (match_operand:SI 1 "gpc_reg_operand" "r,r"))
1086 (const_int 0)))
1087 (clobber (match_scratch:SI 2 "=r,r"))]
1088 "! TARGET_POWERPC64"
1089 "@
1090 nor. %2,%1,%1
1091 #"
1092 [(set_attr "type" "compare")
1093 (set_attr "length" "4,8")])
1094
1095 (define_split
1096 [(set (match_operand:CC 0 "cc_reg_not_cr0_operand" "")
1097 (compare:CC (not:SI (match_operand:SI 1 "gpc_reg_operand" ""))
1098 (const_int 0)))
1099 (clobber (match_scratch:SI 2 ""))]
1100 "! TARGET_POWERPC64 && reload_completed"
1101 [(set (match_dup 2)
1102 (not:SI (match_dup 1)))
1103 (set (match_dup 0)
1104 (compare:CC (match_dup 2)
1105 (const_int 0)))]
1106 "")
1107
1108 (define_insn ""
1109 [(set (match_operand:CC 2 "cc_reg_operand" "=x,?y")
1110 (compare:CC (not:SI (match_operand:SI 1 "gpc_reg_operand" "r,r"))
1111 (const_int 0)))
1112 (set (match_operand:SI 0 "gpc_reg_operand" "=r,r")
1113 (not:SI (match_dup 1)))]
1114 "! TARGET_POWERPC64"
1115 "@
1116 nor. %0,%1,%1
1117 #"
1118 [(set_attr "type" "compare")
1119 (set_attr "length" "4,8")])
1120
1121 (define_split
1122 [(set (match_operand:CC 2 "cc_reg_not_cr0_operand" "")
1123 (compare:CC (not:SI (match_operand:SI 1 "gpc_reg_operand" ""))
1124 (const_int 0)))
1125 (set (match_operand:SI 0 "gpc_reg_operand" "")
1126 (not:SI (match_dup 1)))]
1127 "! TARGET_POWERPC64 && reload_completed"
1128 [(set (match_dup 0)
1129 (not:SI (match_dup 1)))
1130 (set (match_dup 2)
1131 (compare:CC (match_dup 0)
1132 (const_int 0)))]
1133 "")
1134
1135 (define_insn ""
1136 [(set (match_operand:SI 0 "gpc_reg_operand" "=r")
1137 (minus:SI (match_operand:SI 1 "reg_or_short_operand" "rI")
1138 (match_operand:SI 2 "gpc_reg_operand" "r")))]
1139 "! TARGET_POWERPC"
1140 "{sf%I1|subf%I1c} %0,%2,%1")
1141
1142 (define_insn ""
1143 [(set (match_operand:SI 0 "gpc_reg_operand" "=r,r")
1144 (minus:SI (match_operand:SI 1 "reg_or_short_operand" "r,I")
1145 (match_operand:SI 2 "gpc_reg_operand" "r,r")))]
1146 "TARGET_POWERPC"
1147 "@
1148 subf %0,%2,%1
1149 subfic %0,%2,%1")
1150
1151 (define_insn ""
1152 [(set (match_operand:CC 0 "cc_reg_operand" "=x,?y")
1153 (compare:CC (minus:SI (match_operand:SI 1 "gpc_reg_operand" "r,r")
1154 (match_operand:SI 2 "gpc_reg_operand" "r,r"))
1155 (const_int 0)))
1156 (clobber (match_scratch:SI 3 "=r,r"))]
1157 "! TARGET_POWERPC"
1158 "@
1159 {sf.|subfc.} %3,%2,%1
1160 #"
1161 [(set_attr "type" "compare")
1162 (set_attr "length" "4,8")])
1163
1164 (define_insn ""
1165 [(set (match_operand:CC 0 "cc_reg_operand" "=x,?y")
1166 (compare:CC (minus:SI (match_operand:SI 1 "gpc_reg_operand" "r,r")
1167 (match_operand:SI 2 "gpc_reg_operand" "r,r"))
1168 (const_int 0)))
1169 (clobber (match_scratch:SI 3 "=r,r"))]
1170 "TARGET_POWERPC && ! TARGET_POWERPC64"
1171 "@
1172 subf. %3,%2,%1
1173 #"
1174 [(set_attr "type" "fast_compare")
1175 (set_attr "length" "4,8")])
1176
1177 (define_split
1178 [(set (match_operand:CC 0 "cc_reg_not_cr0_operand" "")
1179 (compare:CC (minus:SI (match_operand:SI 1 "gpc_reg_operand" "")
1180 (match_operand:SI 2 "gpc_reg_operand" ""))
1181 (const_int 0)))
1182 (clobber (match_scratch:SI 3 ""))]
1183 "! TARGET_POWERPC64 && reload_completed"
1184 [(set (match_dup 3)
1185 (minus:SI (match_dup 1)
1186 (match_dup 2)))
1187 (set (match_dup 0)
1188 (compare:CC (match_dup 3)
1189 (const_int 0)))]
1190 "")
1191
1192 (define_insn ""
1193 [(set (match_operand:CC 3 "cc_reg_operand" "=x,?y")
1194 (compare:CC (minus:SI (match_operand:SI 1 "gpc_reg_operand" "r,r")
1195 (match_operand:SI 2 "gpc_reg_operand" "r,r"))
1196 (const_int 0)))
1197 (set (match_operand:SI 0 "gpc_reg_operand" "=r,r")
1198 (minus:SI (match_dup 1) (match_dup 2)))]
1199 "! TARGET_POWERPC"
1200 "@
1201 {sf.|subfc.} %0,%2,%1
1202 #"
1203 [(set_attr "type" "compare")
1204 (set_attr "length" "4,8")])
1205
1206 (define_insn ""
1207 [(set (match_operand:CC 3 "cc_reg_operand" "=x,?y")
1208 (compare:CC (minus:SI (match_operand:SI 1 "gpc_reg_operand" "r,r")
1209 (match_operand:SI 2 "gpc_reg_operand" "r,r"))
1210 (const_int 0)))
1211 (set (match_operand:SI 0 "gpc_reg_operand" "=r,r")
1212 (minus:SI (match_dup 1)
1213 (match_dup 2)))]
1214 "TARGET_POWERPC && ! TARGET_POWERPC64"
1215 "@
1216 subf. %0,%2,%1
1217 #"
1218 [(set_attr "type" "fast_compare")
1219 (set_attr "length" "4,8")])
1220
1221 (define_split
1222 [(set (match_operand:CC 3 "cc_reg_not_cr0_operand" "")
1223 (compare:CC (minus:SI (match_operand:SI 1 "gpc_reg_operand" "")
1224 (match_operand:SI 2 "gpc_reg_operand" ""))
1225 (const_int 0)))
1226 (set (match_operand:SI 0 "gpc_reg_operand" "")
1227 (minus:SI (match_dup 1)
1228 (match_dup 2)))]
1229 "! TARGET_POWERPC64 && reload_completed"
1230 [(set (match_dup 0)
1231 (minus:SI (match_dup 1)
1232 (match_dup 2)))
1233 (set (match_dup 3)
1234 (compare:CC (match_dup 0)
1235 (const_int 0)))]
1236 "")
1237
1238 (define_expand "subsi3"
1239 [(set (match_operand:SI 0 "gpc_reg_operand" "")
1240 (minus:SI (match_operand:SI 1 "reg_or_short_operand" "")
1241 (match_operand:SI 2 "reg_or_arith_cint_operand" "")))]
1242 ""
1243 "
1244 {
1245 if (GET_CODE (operands[2]) == CONST_INT)
1246 {
1247 emit_insn (gen_addsi3 (operands[0], operands[1],
1248 negate_rtx (SImode, operands[2])));
1249 DONE;
1250 }
1251 }")
1252
1253 ;; For SMIN, SMAX, UMIN, and UMAX, we use DEFINE_EXPAND's that involve a doz[i]
1254 ;; instruction and some auxiliary computations. Then we just have a single
1255 ;; DEFINE_INSN for doz[i] and the define_splits to make them if made by
1256 ;; combine.
1257
1258 (define_expand "sminsi3"
1259 [(set (match_dup 3)
1260 (if_then_else:SI (gt:SI (match_operand:SI 1 "gpc_reg_operand" "")
1261 (match_operand:SI 2 "reg_or_short_operand" ""))
1262 (const_int 0)
1263 (minus:SI (match_dup 2) (match_dup 1))))
1264 (set (match_operand:SI 0 "gpc_reg_operand" "")
1265 (minus:SI (match_dup 2) (match_dup 3)))]
1266 "TARGET_POWER || TARGET_ISEL"
1267 "
1268 {
1269 if (TARGET_ISEL)
1270 {
1271 operands[2] = force_reg (SImode, operands[2]);
1272 rs6000_emit_minmax (operands[0], SMIN, operands[1], operands[2]);
1273 DONE;
1274 }
1275
1276 operands[3] = gen_reg_rtx (SImode);
1277 }")
1278
1279 (define_split
1280 [(set (match_operand:SI 0 "gpc_reg_operand" "")
1281 (smin:SI (match_operand:SI 1 "gpc_reg_operand" "")
1282 (match_operand:SI 2 "reg_or_short_operand" "")))
1283 (clobber (match_operand:SI 3 "gpc_reg_operand" ""))]
1284 "TARGET_POWER"
1285 [(set (match_dup 3)
1286 (if_then_else:SI (gt:SI (match_dup 1) (match_dup 2))
1287 (const_int 0)
1288 (minus:SI (match_dup 2) (match_dup 1))))
1289 (set (match_dup 0) (minus:SI (match_dup 2) (match_dup 3)))]
1290 "")
1291
1292 (define_expand "smaxsi3"
1293 [(set (match_dup 3)
1294 (if_then_else:SI (gt:SI (match_operand:SI 1 "gpc_reg_operand" "")
1295 (match_operand:SI 2 "reg_or_short_operand" ""))
1296 (const_int 0)
1297 (minus:SI (match_dup 2) (match_dup 1))))
1298 (set (match_operand:SI 0 "gpc_reg_operand" "")
1299 (plus:SI (match_dup 3) (match_dup 1)))]
1300 "TARGET_POWER || TARGET_ISEL"
1301 "
1302 {
1303 if (TARGET_ISEL)
1304 {
1305 operands[2] = force_reg (SImode, operands[2]);
1306 rs6000_emit_minmax (operands[0], SMAX, operands[1], operands[2]);
1307 DONE;
1308 }
1309 operands[3] = gen_reg_rtx (SImode);
1310 }")
1311
1312 (define_split
1313 [(set (match_operand:SI 0 "gpc_reg_operand" "")
1314 (smax:SI (match_operand:SI 1 "gpc_reg_operand" "")
1315 (match_operand:SI 2 "reg_or_short_operand" "")))
1316 (clobber (match_operand:SI 3 "gpc_reg_operand" ""))]
1317 "TARGET_POWER"
1318 [(set (match_dup 3)
1319 (if_then_else:SI (gt:SI (match_dup 1) (match_dup 2))
1320 (const_int 0)
1321 (minus:SI (match_dup 2) (match_dup 1))))
1322 (set (match_dup 0) (plus:SI (match_dup 3) (match_dup 1)))]
1323 "")
1324
1325 (define_expand "uminsi3"
1326 [(set (match_dup 3) (xor:SI (match_operand:SI 1 "gpc_reg_operand" "")
1327 (match_dup 5)))
1328 (set (match_dup 4) (xor:SI (match_operand:SI 2 "gpc_reg_operand" "")
1329 (match_dup 5)))
1330 (set (match_dup 3) (if_then_else:SI (gt (match_dup 3) (match_dup 4))
1331 (const_int 0)
1332 (minus:SI (match_dup 4) (match_dup 3))))
1333 (set (match_operand:SI 0 "gpc_reg_operand" "")
1334 (minus:SI (match_dup 2) (match_dup 3)))]
1335 "TARGET_POWER || TARGET_ISEL"
1336 "
1337 {
1338 if (TARGET_ISEL)
1339 {
1340 rs6000_emit_minmax (operands[0], UMIN, operands[1], operands[2]);
1341 DONE;
1342 }
1343 operands[3] = gen_reg_rtx (SImode);
1344 operands[4] = gen_reg_rtx (SImode);
1345 operands[5] = GEN_INT (-2147483647 - 1);
1346 }")
1347
1348 (define_expand "umaxsi3"
1349 [(set (match_dup 3) (xor:SI (match_operand:SI 1 "gpc_reg_operand" "")
1350 (match_dup 5)))
1351 (set (match_dup 4) (xor:SI (match_operand:SI 2 "gpc_reg_operand" "")
1352 (match_dup 5)))
1353 (set (match_dup 3) (if_then_else:SI (gt (match_dup 3) (match_dup 4))
1354 (const_int 0)
1355 (minus:SI (match_dup 4) (match_dup 3))))
1356 (set (match_operand:SI 0 "gpc_reg_operand" "")
1357 (plus:SI (match_dup 3) (match_dup 1)))]
1358 "TARGET_POWER || TARGET_ISEL"
1359 "
1360 {
1361 if (TARGET_ISEL)
1362 {
1363 rs6000_emit_minmax (operands[0], UMAX, operands[1], operands[2]);
1364 DONE;
1365 }
1366 operands[3] = gen_reg_rtx (SImode);
1367 operands[4] = gen_reg_rtx (SImode);
1368 operands[5] = GEN_INT (-2147483647 - 1);
1369 }")
1370
1371 (define_insn ""
1372 [(set (match_operand:SI 0 "gpc_reg_operand" "=r")
1373 (if_then_else:SI (gt (match_operand:SI 1 "gpc_reg_operand" "r")
1374 (match_operand:SI 2 "reg_or_short_operand" "rI"))
1375 (const_int 0)
1376 (minus:SI (match_dup 2) (match_dup 1))))]
1377 "TARGET_POWER"
1378 "doz%I2 %0,%1,%2")
1379
1380 (define_insn ""
1381 [(set (match_operand:CC 0 "cc_reg_operand" "=x,?y")
1382 (compare:CC
1383 (if_then_else:SI (gt (match_operand:SI 1 "gpc_reg_operand" "r,r")
1384 (match_operand:SI 2 "reg_or_short_operand" "rI,rI"))
1385 (const_int 0)
1386 (minus:SI (match_dup 2) (match_dup 1)))
1387 (const_int 0)))
1388 (clobber (match_scratch:SI 3 "=r,r"))]
1389 "TARGET_POWER"
1390 "@
1391 doz%I2. %3,%1,%2
1392 #"
1393 [(set_attr "type" "delayed_compare")
1394 (set_attr "length" "4,8")])
1395
1396 (define_split
1397 [(set (match_operand:CC 0 "cc_reg_not_cr0_operand" "")
1398 (compare:CC
1399 (if_then_else:SI (gt (match_operand:SI 1 "gpc_reg_operand" "")
1400 (match_operand:SI 2 "reg_or_short_operand" ""))
1401 (const_int 0)
1402 (minus:SI (match_dup 2) (match_dup 1)))
1403 (const_int 0)))
1404 (clobber (match_scratch:SI 3 ""))]
1405 "TARGET_POWER && reload_completed"
1406 [(set (match_dup 3)
1407 (if_then_else:SI (gt (match_dup 1) (match_dup 2))
1408 (const_int 0)
1409 (minus:SI (match_dup 2) (match_dup 1))))
1410 (set (match_dup 0)
1411 (compare:CC (match_dup 3)
1412 (const_int 0)))]
1413 "")
1414
1415 (define_insn ""
1416 [(set (match_operand:CC 3 "cc_reg_operand" "=x,?y")
1417 (compare:CC
1418 (if_then_else:SI (gt (match_operand:SI 1 "gpc_reg_operand" "r,r")
1419 (match_operand:SI 2 "reg_or_short_operand" "rI,rI"))
1420 (const_int 0)
1421 (minus:SI (match_dup 2) (match_dup 1)))
1422 (const_int 0)))
1423 (set (match_operand:SI 0 "gpc_reg_operand" "=r,r")
1424 (if_then_else:SI (gt (match_dup 1) (match_dup 2))
1425 (const_int 0)
1426 (minus:SI (match_dup 2) (match_dup 1))))]
1427 "TARGET_POWER"
1428 "@
1429 doz%I2. %0,%1,%2
1430 #"
1431 [(set_attr "type" "delayed_compare")
1432 (set_attr "length" "4,8")])
1433
1434 (define_split
1435 [(set (match_operand:CC 3 "cc_reg_not_cr0_operand" "")
1436 (compare:CC
1437 (if_then_else:SI (gt (match_operand:SI 1 "gpc_reg_operand" "")
1438 (match_operand:SI 2 "reg_or_short_operand" ""))
1439 (const_int 0)
1440 (minus:SI (match_dup 2) (match_dup 1)))
1441 (const_int 0)))
1442 (set (match_operand:SI 0 "gpc_reg_operand" "")
1443 (if_then_else:SI (gt (match_dup 1) (match_dup 2))
1444 (const_int 0)
1445 (minus:SI (match_dup 2) (match_dup 1))))]
1446 "TARGET_POWER && reload_completed"
1447 [(set (match_dup 0)
1448 (if_then_else:SI (gt (match_dup 1) (match_dup 2))
1449 (const_int 0)
1450 (minus:SI (match_dup 2) (match_dup 1))))
1451 (set (match_dup 3)
1452 (compare:CC (match_dup 0)
1453 (const_int 0)))]
1454 "")
1455
1456 ;; We don't need abs with condition code because such comparisons should
1457 ;; never be done.
1458 (define_expand "abssi2"
1459 [(set (match_operand:SI 0 "gpc_reg_operand" "")
1460 (abs:SI (match_operand:SI 1 "gpc_reg_operand" "")))]
1461 ""
1462 "
1463 {
1464 if (TARGET_ISEL)
1465 {
1466 emit_insn (gen_abssi2_isel (operands[0], operands[1]));
1467 DONE;
1468 }
1469 else if (! TARGET_POWER)
1470 {
1471 emit_insn (gen_abssi2_nopower (operands[0], operands[1]));
1472 DONE;
1473 }
1474 }")
1475
1476 (define_insn "*abssi2_power"
1477 [(set (match_operand:SI 0 "gpc_reg_operand" "=r")
1478 (abs:SI (match_operand:SI 1 "gpc_reg_operand" "r")))]
1479 "TARGET_POWER"
1480 "abs %0,%1")
1481
1482 (define_insn_and_split "abssi2_isel"
1483 [(set (match_operand:SI 0 "gpc_reg_operand" "=r")
1484 (abs:SI (match_operand:SI 1 "gpc_reg_operand" "b")))
1485 (clobber (match_scratch:SI 2 "=b"))
1486 (clobber (match_scratch:CC 3 "=y"))]
1487 "TARGET_ISEL"
1488 "#"
1489 "&& reload_completed"
1490 [(set (match_dup 2) (neg:SI (match_dup 1)))
1491 (set (match_dup 3)
1492 (compare:CC (match_dup 1)
1493 (const_int 0)))
1494 (set (match_dup 0)
1495 (if_then_else:SI (ge (match_dup 3)
1496 (const_int 0))
1497 (match_dup 1)
1498 (match_dup 2)))]
1499 "")
1500
1501 (define_insn_and_split "abssi2_nopower"
1502 [(set (match_operand:SI 0 "gpc_reg_operand" "=&r,r")
1503 (abs:SI (match_operand:SI 1 "gpc_reg_operand" "r,0")))
1504 (clobber (match_scratch:SI 2 "=&r,&r"))]
1505 "! TARGET_POWER && ! TARGET_ISEL"
1506 "#"
1507 "&& reload_completed"
1508 [(set (match_dup 2) (ashiftrt:SI (match_dup 1) (const_int 31)))
1509 (set (match_dup 0) (xor:SI (match_dup 2) (match_dup 1)))
1510 (set (match_dup 0) (minus:SI (match_dup 0) (match_dup 2)))]
1511 "")
1512
1513 (define_insn "*nabs_power"
1514 [(set (match_operand:SI 0 "gpc_reg_operand" "=r")
1515 (neg:SI (abs:SI (match_operand:SI 1 "gpc_reg_operand" "r"))))]
1516 "TARGET_POWER"
1517 "nabs %0,%1")
1518
1519 (define_insn_and_split "*nabs_nopower"
1520 [(set (match_operand:SI 0 "gpc_reg_operand" "=&r,r")
1521 (neg:SI (abs:SI (match_operand:SI 1 "gpc_reg_operand" "r,0"))))
1522 (clobber (match_scratch:SI 2 "=&r,&r"))]
1523 "! TARGET_POWER"
1524 "#"
1525 "&& reload_completed"
1526 [(set (match_dup 2) (ashiftrt:SI (match_dup 1) (const_int 31)))
1527 (set (match_dup 0) (xor:SI (match_dup 2) (match_dup 1)))
1528 (set (match_dup 0) (minus:SI (match_dup 2) (match_dup 0)))]
1529 "")
1530
1531 (define_insn "negsi2"
1532 [(set (match_operand:SI 0 "gpc_reg_operand" "=r")
1533 (neg:SI (match_operand:SI 1 "gpc_reg_operand" "r")))]
1534 ""
1535 "neg %0,%1")
1536
1537 (define_insn ""
1538 [(set (match_operand:CC 0 "cc_reg_operand" "=x,?y")
1539 (compare:CC (neg:SI (match_operand:SI 1 "gpc_reg_operand" "r,r"))
1540 (const_int 0)))
1541 (clobber (match_scratch:SI 2 "=r,r"))]
1542 "! TARGET_POWERPC64"
1543 "@
1544 neg. %2,%1
1545 #"
1546 [(set_attr "type" "fast_compare")
1547 (set_attr "length" "4,8")])
1548
1549 (define_split
1550 [(set (match_operand:CC 0 "cc_reg_not_cr0_operand" "")
1551 (compare:CC (neg:SI (match_operand:SI 1 "gpc_reg_operand" ""))
1552 (const_int 0)))
1553 (clobber (match_scratch:SI 2 ""))]
1554 "! TARGET_POWERPC64 && reload_completed"
1555 [(set (match_dup 2)
1556 (neg:SI (match_dup 1)))
1557 (set (match_dup 0)
1558 (compare:CC (match_dup 2)
1559 (const_int 0)))]
1560 "")
1561
1562 (define_insn ""
1563 [(set (match_operand:CC 2 "cc_reg_operand" "=x,?y")
1564 (compare:CC (neg:SI (match_operand:SI 1 "gpc_reg_operand" "r,r"))
1565 (const_int 0)))
1566 (set (match_operand:SI 0 "gpc_reg_operand" "=r,r")
1567 (neg:SI (match_dup 1)))]
1568 "! TARGET_POWERPC64"
1569 "@
1570 neg. %0,%1
1571 #"
1572 [(set_attr "type" "fast_compare")
1573 (set_attr "length" "4,8")])
1574
1575 (define_split
1576 [(set (match_operand:CC 2 "cc_reg_not_cr0_operand" "")
1577 (compare:CC (neg:SI (match_operand:SI 1 "gpc_reg_operand" ""))
1578 (const_int 0)))
1579 (set (match_operand:SI 0 "gpc_reg_operand" "")
1580 (neg:SI (match_dup 1)))]
1581 "! TARGET_POWERPC64 && reload_completed"
1582 [(set (match_dup 0)
1583 (neg:SI (match_dup 1)))
1584 (set (match_dup 2)
1585 (compare:CC (match_dup 0)
1586 (const_int 0)))]
1587 "")
1588
1589 (define_insn "clzsi2"
1590 [(set (match_operand:SI 0 "gpc_reg_operand" "=r")
1591 (clz:SI (match_operand:SI 1 "gpc_reg_operand" "r")))]
1592 ""
1593 "{cntlz|cntlzw} %0,%1")
1594
1595 (define_expand "ctzsi2"
1596 [(set (match_dup 2)
1597 (neg:SI (match_operand:SI 1 "gpc_reg_operand" "r")))
1598 (parallel [(set (match_dup 3) (and:SI (match_dup 1)
1599 (match_dup 2)))
1600 (clobber (scratch:CC))])
1601 (set (match_dup 4) (clz:SI (match_dup 3)))
1602 (set (match_operand:SI 0 "gpc_reg_operand" "=r")
1603 (minus:SI (const_int 31) (match_dup 4)))]
1604 ""
1605 {
1606 operands[2] = gen_reg_rtx (SImode);
1607 operands[3] = gen_reg_rtx (SImode);
1608 operands[4] = gen_reg_rtx (SImode);
1609 })
1610
1611 (define_expand "ffssi2"
1612 [(set (match_dup 2)
1613 (neg:SI (match_operand:SI 1 "gpc_reg_operand" "r")))
1614 (parallel [(set (match_dup 3) (and:SI (match_dup 1)
1615 (match_dup 2)))
1616 (clobber (scratch:CC))])
1617 (set (match_dup 4) (clz:SI (match_dup 3)))
1618 (set (match_operand:SI 0 "gpc_reg_operand" "=r")
1619 (minus:SI (const_int 32) (match_dup 4)))]
1620 ""
1621 {
1622 operands[2] = gen_reg_rtx (SImode);
1623 operands[3] = gen_reg_rtx (SImode);
1624 operands[4] = gen_reg_rtx (SImode);
1625 })
1626
1627 (define_expand "mulsi3"
1628 [(use (match_operand:SI 0 "gpc_reg_operand" ""))
1629 (use (match_operand:SI 1 "gpc_reg_operand" ""))
1630 (use (match_operand:SI 2 "reg_or_short_operand" ""))]
1631 ""
1632 "
1633 {
1634 if (TARGET_POWER)
1635 emit_insn (gen_mulsi3_mq (operands[0], operands[1], operands[2]));
1636 else
1637 emit_insn (gen_mulsi3_no_mq (operands[0], operands[1], operands[2]));
1638 DONE;
1639 }")
1640
1641 (define_insn "mulsi3_mq"
1642 [(set (match_operand:SI 0 "gpc_reg_operand" "=r,r")
1643 (mult:SI (match_operand:SI 1 "gpc_reg_operand" "%r,r")
1644 (match_operand:SI 2 "reg_or_short_operand" "r,I")))
1645 (clobber (match_scratch:SI 3 "=q,q"))]
1646 "TARGET_POWER"
1647 "@
1648 {muls|mullw} %0,%1,%2
1649 {muli|mulli} %0,%1,%2"
1650 [(set (attr "type")
1651 (cond [(match_operand:SI 2 "s8bit_cint_operand" "")
1652 (const_string "imul3")
1653 (match_operand:SI 2 "short_cint_operand" "")
1654 (const_string "imul2")]
1655 (const_string "imul")))])
1656
1657 (define_insn "mulsi3_no_mq"
1658 [(set (match_operand:SI 0 "gpc_reg_operand" "=r,r")
1659 (mult:SI (match_operand:SI 1 "gpc_reg_operand" "%r,r")
1660 (match_operand:SI 2 "reg_or_short_operand" "r,I")))]
1661 "! TARGET_POWER"
1662 "@
1663 {muls|mullw} %0,%1,%2
1664 {muli|mulli} %0,%1,%2"
1665 [(set (attr "type")
1666 (cond [(match_operand:SI 2 "s8bit_cint_operand" "")
1667 (const_string "imul3")
1668 (match_operand:SI 2 "short_cint_operand" "")
1669 (const_string "imul2")]
1670 (const_string "imul")))])
1671
1672 (define_insn "*mulsi3_mq_internal1"
1673 [(set (match_operand:CC 0 "cc_reg_operand" "=x,?y")
1674 (compare:CC (mult:SI (match_operand:SI 1 "gpc_reg_operand" "%r,r")
1675 (match_operand:SI 2 "gpc_reg_operand" "r,r"))
1676 (const_int 0)))
1677 (clobber (match_scratch:SI 3 "=r,r"))
1678 (clobber (match_scratch:SI 4 "=q,q"))]
1679 "TARGET_POWER"
1680 "@
1681 {muls.|mullw.} %3,%1,%2
1682 #"
1683 [(set_attr "type" "imul_compare")
1684 (set_attr "length" "4,8")])
1685
1686 (define_split
1687 [(set (match_operand:CC 0 "cc_reg_not_cr0_operand" "")
1688 (compare:CC (mult:SI (match_operand:SI 1 "gpc_reg_operand" "")
1689 (match_operand:SI 2 "gpc_reg_operand" ""))
1690 (const_int 0)))
1691 (clobber (match_scratch:SI 3 ""))
1692 (clobber (match_scratch:SI 4 ""))]
1693 "TARGET_POWER && reload_completed"
1694 [(parallel [(set (match_dup 3)
1695 (mult:SI (match_dup 1) (match_dup 2)))
1696 (clobber (match_dup 4))])
1697 (set (match_dup 0)
1698 (compare:CC (match_dup 3)
1699 (const_int 0)))]
1700 "")
1701
1702 (define_insn "*mulsi3_no_mq_internal1"
1703 [(set (match_operand:CC 0 "cc_reg_operand" "=x,?y")
1704 (compare:CC (mult:SI (match_operand:SI 1 "gpc_reg_operand" "%r,r")
1705 (match_operand:SI 2 "gpc_reg_operand" "r,r"))
1706 (const_int 0)))
1707 (clobber (match_scratch:SI 3 "=r,r"))]
1708 "! TARGET_POWER"
1709 "@
1710 {muls.|mullw.} %3,%1,%2
1711 #"
1712 [(set_attr "type" "imul_compare")
1713 (set_attr "length" "4,8")])
1714
1715 (define_split
1716 [(set (match_operand:CC 0 "cc_reg_not_cr0_operand" "")
1717 (compare:CC (mult:SI (match_operand:SI 1 "gpc_reg_operand" "")
1718 (match_operand:SI 2 "gpc_reg_operand" ""))
1719 (const_int 0)))
1720 (clobber (match_scratch:SI 3 ""))]
1721 "! TARGET_POWER && reload_completed"
1722 [(set (match_dup 3)
1723 (mult:SI (match_dup 1) (match_dup 2)))
1724 (set (match_dup 0)
1725 (compare:CC (match_dup 3)
1726 (const_int 0)))]
1727 "")
1728
1729 (define_insn "*mulsi3_mq_internal2"
1730 [(set (match_operand:CC 3 "cc_reg_operand" "=x,?y")
1731 (compare:CC (mult:SI (match_operand:SI 1 "gpc_reg_operand" "%r,r")
1732 (match_operand:SI 2 "gpc_reg_operand" "r,r"))
1733 (const_int 0)))
1734 (set (match_operand:SI 0 "gpc_reg_operand" "=r,r")
1735 (mult:SI (match_dup 1) (match_dup 2)))
1736 (clobber (match_scratch:SI 4 "=q,q"))]
1737 "TARGET_POWER"
1738 "@
1739 {muls.|mullw.} %0,%1,%2
1740 #"
1741 [(set_attr "type" "imul_compare")
1742 (set_attr "length" "4,8")])
1743
1744 (define_split
1745 [(set (match_operand:CC 3 "cc_reg_not_cr0_operand" "")
1746 (compare:CC (mult:SI (match_operand:SI 1 "gpc_reg_operand" "")
1747 (match_operand:SI 2 "gpc_reg_operand" ""))
1748 (const_int 0)))
1749 (set (match_operand:SI 0 "gpc_reg_operand" "")
1750 (mult:SI (match_dup 1) (match_dup 2)))
1751 (clobber (match_scratch:SI 4 ""))]
1752 "TARGET_POWER && reload_completed"
1753 [(parallel [(set (match_dup 0)
1754 (mult:SI (match_dup 1) (match_dup 2)))
1755 (clobber (match_dup 4))])
1756 (set (match_dup 3)
1757 (compare:CC (match_dup 0)
1758 (const_int 0)))]
1759 "")
1760
1761 (define_insn "*mulsi3_no_mq_internal2"
1762 [(set (match_operand:CC 3 "cc_reg_operand" "=x,?y")
1763 (compare:CC (mult:SI (match_operand:SI 1 "gpc_reg_operand" "%r,r")
1764 (match_operand:SI 2 "gpc_reg_operand" "r,r"))
1765 (const_int 0)))
1766 (set (match_operand:SI 0 "gpc_reg_operand" "=r,r")
1767 (mult:SI (match_dup 1) (match_dup 2)))]
1768 "! TARGET_POWER"
1769 "@
1770 {muls.|mullw.} %0,%1,%2
1771 #"
1772 [(set_attr "type" "imul_compare")
1773 (set_attr "length" "4,8")])
1774
1775 (define_split
1776 [(set (match_operand:CC 3 "cc_reg_not_cr0_operand" "")
1777 (compare:CC (mult:SI (match_operand:SI 1 "gpc_reg_operand" "")
1778 (match_operand:SI 2 "gpc_reg_operand" ""))
1779 (const_int 0)))
1780 (set (match_operand:SI 0 "gpc_reg_operand" "")
1781 (mult:SI (match_dup 1) (match_dup 2)))]
1782 "! TARGET_POWER && reload_completed"
1783 [(set (match_dup 0)
1784 (mult:SI (match_dup 1) (match_dup 2)))
1785 (set (match_dup 3)
1786 (compare:CC (match_dup 0)
1787 (const_int 0)))]
1788 "")
1789
1790 ;; Operand 1 is divided by operand 2; quotient goes to operand
1791 ;; 0 and remainder to operand 3.
1792 ;; ??? At some point, see what, if anything, we can do about if (x % y == 0).
1793
1794 (define_expand "divmodsi4"
1795 [(parallel [(set (match_operand:SI 0 "gpc_reg_operand" "")
1796 (div:SI (match_operand:SI 1 "gpc_reg_operand" "")
1797 (match_operand:SI 2 "gpc_reg_operand" "")))
1798 (set (match_operand:SI 3 "register_operand" "")
1799 (mod:SI (match_dup 1) (match_dup 2)))])]
1800 "TARGET_POWER || (! TARGET_POWER && ! TARGET_POWERPC)"
1801 "
1802 {
1803 if (! TARGET_POWER && ! TARGET_POWERPC)
1804 {
1805 emit_move_insn (gen_rtx_REG (SImode, 3), operands[1]);
1806 emit_move_insn (gen_rtx_REG (SImode, 4), operands[2]);
1807 emit_insn (gen_divss_call ());
1808 emit_move_insn (operands[0], gen_rtx_REG (SImode, 3));
1809 emit_move_insn (operands[3], gen_rtx_REG (SImode, 4));
1810 DONE;
1811 }
1812 }")
1813
1814 (define_insn "*divmodsi4_internal"
1815 [(set (match_operand:SI 0 "gpc_reg_operand" "=r")
1816 (div:SI (match_operand:SI 1 "gpc_reg_operand" "r")
1817 (match_operand:SI 2 "gpc_reg_operand" "r")))
1818 (set (match_operand:SI 3 "register_operand" "=q")
1819 (mod:SI (match_dup 1) (match_dup 2)))]
1820 "TARGET_POWER"
1821 "divs %0,%1,%2"
1822 [(set_attr "type" "idiv")])
1823
1824 (define_expand "udivsi3"
1825 [(set (match_operand:SI 0 "gpc_reg_operand" "")
1826 (udiv:SI (match_operand:SI 1 "gpc_reg_operand" "")
1827 (match_operand:SI 2 "gpc_reg_operand" "")))]
1828 "TARGET_POWERPC || (! TARGET_POWER && ! TARGET_POWERPC)"
1829 "
1830 {
1831 if (! TARGET_POWER && ! TARGET_POWERPC)
1832 {
1833 emit_move_insn (gen_rtx_REG (SImode, 3), operands[1]);
1834 emit_move_insn (gen_rtx_REG (SImode, 4), operands[2]);
1835 emit_insn (gen_quous_call ());
1836 emit_move_insn (operands[0], gen_rtx_REG (SImode, 3));
1837 DONE;
1838 }
1839 else if (TARGET_POWER)
1840 {
1841 emit_insn (gen_udivsi3_mq (operands[0], operands[1], operands[2]));
1842 DONE;
1843 }
1844 }")
1845
1846 (define_insn "udivsi3_mq"
1847 [(set (match_operand:SI 0 "gpc_reg_operand" "=r")
1848 (udiv:SI (match_operand:SI 1 "gpc_reg_operand" "r")
1849 (match_operand:SI 2 "gpc_reg_operand" "r")))
1850 (clobber (match_scratch:SI 3 "=q"))]
1851 "TARGET_POWERPC && TARGET_POWER"
1852 "divwu %0,%1,%2"
1853 [(set_attr "type" "idiv")])
1854
1855 (define_insn "*udivsi3_no_mq"
1856 [(set (match_operand:SI 0 "gpc_reg_operand" "=r")
1857 (udiv:SI (match_operand:SI 1 "gpc_reg_operand" "r")
1858 (match_operand:SI 2 "gpc_reg_operand" "r")))]
1859 "TARGET_POWERPC && ! TARGET_POWER"
1860 "divwu %0,%1,%2"
1861 [(set_attr "type" "idiv")])
1862
1863 ;; For powers of two we can do srai/aze for divide and then adjust for
1864 ;; modulus. If it isn't a power of two, FAIL on POWER so divmodsi4 will be
1865 ;; used; for PowerPC, force operands into register and do a normal divide;
1866 ;; for AIX common-mode, use quoss call on register operands.
1867 (define_expand "divsi3"
1868 [(set (match_operand:SI 0 "gpc_reg_operand" "")
1869 (div:SI (match_operand:SI 1 "gpc_reg_operand" "")
1870 (match_operand:SI 2 "reg_or_cint_operand" "")))]
1871 ""
1872 "
1873 {
1874 if (GET_CODE (operands[2]) == CONST_INT
1875 && INTVAL (operands[2]) > 0
1876 && exact_log2 (INTVAL (operands[2])) >= 0)
1877 ;
1878 else if (TARGET_POWERPC)
1879 {
1880 operands[2] = force_reg (SImode, operands[2]);
1881 if (TARGET_POWER)
1882 {
1883 emit_insn (gen_divsi3_mq (operands[0], operands[1], operands[2]));
1884 DONE;
1885 }
1886 }
1887 else if (TARGET_POWER)
1888 FAIL;
1889 else
1890 {
1891 emit_move_insn (gen_rtx_REG (SImode, 3), operands[1]);
1892 emit_move_insn (gen_rtx_REG (SImode, 4), operands[2]);
1893 emit_insn (gen_quoss_call ());
1894 emit_move_insn (operands[0], gen_rtx_REG (SImode, 3));
1895 DONE;
1896 }
1897 }")
1898
1899 (define_insn "divsi3_mq"
1900 [(set (match_operand:SI 0 "gpc_reg_operand" "=r")
1901 (div:SI (match_operand:SI 1 "gpc_reg_operand" "r")
1902 (match_operand:SI 2 "gpc_reg_operand" "r")))
1903 (clobber (match_scratch:SI 3 "=q"))]
1904 "TARGET_POWERPC && TARGET_POWER"
1905 "divw %0,%1,%2"
1906 [(set_attr "type" "idiv")])
1907
1908 (define_insn "*divsi3_no_mq"
1909 [(set (match_operand:SI 0 "gpc_reg_operand" "=r")
1910 (div:SI (match_operand:SI 1 "gpc_reg_operand" "r")
1911 (match_operand:SI 2 "gpc_reg_operand" "r")))]
1912 "TARGET_POWERPC && ! TARGET_POWER"
1913 "divw %0,%1,%2"
1914 [(set_attr "type" "idiv")])
1915
1916 (define_expand "modsi3"
1917 [(use (match_operand:SI 0 "gpc_reg_operand" ""))
1918 (use (match_operand:SI 1 "gpc_reg_operand" ""))
1919 (use (match_operand:SI 2 "reg_or_cint_operand" ""))]
1920 ""
1921 "
1922 {
1923 int i;
1924 rtx temp1;
1925 rtx temp2;
1926
1927 if (GET_CODE (operands[2]) != CONST_INT
1928 || INTVAL (operands[2]) <= 0
1929 || (i = exact_log2 (INTVAL (operands[2]))) < 0)
1930 FAIL;
1931
1932 temp1 = gen_reg_rtx (SImode);
1933 temp2 = gen_reg_rtx (SImode);
1934
1935 emit_insn (gen_divsi3 (temp1, operands[1], operands[2]));
1936 emit_insn (gen_ashlsi3 (temp2, temp1, GEN_INT (i)));
1937 emit_insn (gen_subsi3 (operands[0], operands[1], temp2));
1938 DONE;
1939 }")
1940
1941 (define_insn ""
1942 [(set (match_operand:SI 0 "gpc_reg_operand" "=r")
1943 (div:SI (match_operand:SI 1 "gpc_reg_operand" "r")
1944 (match_operand:SI 2 "exact_log2_cint_operand" "N")))]
1945 ""
1946 "{srai|srawi} %0,%1,%p2\;{aze|addze} %0,%0"
1947 [(set_attr "length" "8")])
1948
1949 (define_insn ""
1950 [(set (match_operand:CC 0 "cc_reg_operand" "=x,?y")
1951 (compare:CC (div:SI (match_operand:SI 1 "gpc_reg_operand" "r,r")
1952 (match_operand:SI 2 "exact_log2_cint_operand" "N,N"))
1953 (const_int 0)))
1954 (clobber (match_scratch:SI 3 "=r,r"))]
1955 ""
1956 "@
1957 {srai|srawi} %3,%1,%p2\;{aze.|addze.} %3,%3
1958 #"
1959 [(set_attr "type" "compare")
1960 (set_attr "length" "8,12")])
1961
1962 (define_split
1963 [(set (match_operand:CC 0 "cc_reg_not_cr0_operand" "")
1964 (compare:CC (div:SI (match_operand:SI 1 "gpc_reg_operand" "")
1965 (match_operand:SI 2 "exact_log2_cint_operand" ""))
1966 (const_int 0)))
1967 (clobber (match_scratch:SI 3 ""))]
1968 "reload_completed"
1969 [(set (match_dup 3)
1970 (div:SI (match_dup 1) (match_dup 2)))
1971 (set (match_dup 0)
1972 (compare:CC (match_dup 3)
1973 (const_int 0)))]
1974 "")
1975
1976 (define_insn ""
1977 [(set (match_operand:CC 3 "cc_reg_operand" "=x,?y")
1978 (compare:CC (div:SI (match_operand:SI 1 "gpc_reg_operand" "r,r")
1979 (match_operand:SI 2 "exact_log2_cint_operand" "N,N"))
1980 (const_int 0)))
1981 (set (match_operand:SI 0 "gpc_reg_operand" "=r,r")
1982 (div:SI (match_dup 1) (match_dup 2)))]
1983 ""
1984 "@
1985 {srai|srawi} %0,%1,%p2\;{aze.|addze.} %0,%0
1986 #"
1987 [(set_attr "type" "compare")
1988 (set_attr "length" "8,12")])
1989
1990 (define_split
1991 [(set (match_operand:CC 3 "cc_reg_not_cr0_operand" "")
1992 (compare:CC (div:SI (match_operand:SI 1 "gpc_reg_operand" "")
1993 (match_operand:SI 2 "exact_log2_cint_operand" ""))
1994 (const_int 0)))
1995 (set (match_operand:SI 0 "gpc_reg_operand" "")
1996 (div:SI (match_dup 1) (match_dup 2)))]
1997 "reload_completed"
1998 [(set (match_dup 0)
1999 (div:SI (match_dup 1) (match_dup 2)))
2000 (set (match_dup 3)
2001 (compare:CC (match_dup 0)
2002 (const_int 0)))]
2003 "")
2004
2005 (define_insn ""
2006 [(set (match_operand:SI 0 "gpc_reg_operand" "=r")
2007 (udiv:SI
2008 (plus:DI (ashift:DI
2009 (zero_extend:DI (match_operand:SI 1 "gpc_reg_operand" "r"))
2010 (const_int 32))
2011 (zero_extend:DI (match_operand:SI 4 "register_operand" "2")))
2012 (match_operand:SI 3 "gpc_reg_operand" "r")))
2013 (set (match_operand:SI 2 "register_operand" "=*q")
2014 (umod:SI
2015 (plus:DI (ashift:DI
2016 (zero_extend:DI (match_dup 1)) (const_int 32))
2017 (zero_extend:DI (match_dup 4)))
2018 (match_dup 3)))]
2019 "TARGET_POWER"
2020 "div %0,%1,%3"
2021 [(set_attr "type" "idiv")])
2022
2023 ;; To do unsigned divide we handle the cases of the divisor looking like a
2024 ;; negative number. If it is a constant that is less than 2**31, we don't
2025 ;; have to worry about the branches. So make a few subroutines here.
2026 ;;
2027 ;; First comes the normal case.
2028 (define_expand "udivmodsi4_normal"
2029 [(set (match_dup 4) (const_int 0))
2030 (parallel [(set (match_operand:SI 0 "" "")
2031 (udiv:SI (plus:DI (ashift:DI (zero_extend:DI (match_dup 4))
2032 (const_int 32))
2033 (zero_extend:DI (match_operand:SI 1 "" "")))
2034 (match_operand:SI 2 "" "")))
2035 (set (match_operand:SI 3 "" "")
2036 (umod:SI (plus:DI (ashift:DI (zero_extend:DI (match_dup 4))
2037 (const_int 32))
2038 (zero_extend:DI (match_dup 1)))
2039 (match_dup 2)))])]
2040 "TARGET_POWER"
2041 "
2042 { operands[4] = gen_reg_rtx (SImode); }")
2043
2044 ;; This handles the branches.
2045 (define_expand "udivmodsi4_tests"
2046 [(set (match_operand:SI 0 "" "") (const_int 0))
2047 (set (match_operand:SI 3 "" "") (match_operand:SI 1 "" ""))
2048 (set (match_dup 5) (compare:CCUNS (match_dup 1) (match_operand:SI 2 "" "")))
2049 (set (pc) (if_then_else (ltu (match_dup 5) (const_int 0))
2050 (label_ref (match_operand:SI 4 "" "")) (pc)))
2051 (set (match_dup 0) (const_int 1))
2052 (set (match_dup 3) (minus:SI (match_dup 1) (match_dup 2)))
2053 (set (match_dup 6) (compare:CC (match_dup 2) (const_int 0)))
2054 (set (pc) (if_then_else (lt (match_dup 6) (const_int 0))
2055 (label_ref (match_dup 4)) (pc)))]
2056 "TARGET_POWER"
2057 "
2058 { operands[5] = gen_reg_rtx (CCUNSmode);
2059 operands[6] = gen_reg_rtx (CCmode);
2060 }")
2061
2062 (define_expand "udivmodsi4"
2063 [(parallel [(set (match_operand:SI 0 "gpc_reg_operand" "")
2064 (udiv:SI (match_operand:SI 1 "gpc_reg_operand" "")
2065 (match_operand:SI 2 "reg_or_cint_operand" "")))
2066 (set (match_operand:SI 3 "gpc_reg_operand" "")
2067 (umod:SI (match_dup 1) (match_dup 2)))])]
2068 ""
2069 "
2070 {
2071 rtx label = 0;
2072
2073 if (! TARGET_POWER)
2074 {
2075 if (! TARGET_POWERPC)
2076 {
2077 emit_move_insn (gen_rtx_REG (SImode, 3), operands[1]);
2078 emit_move_insn (gen_rtx_REG (SImode, 4), operands[2]);
2079 emit_insn (gen_divus_call ());
2080 emit_move_insn (operands[0], gen_rtx_REG (SImode, 3));
2081 emit_move_insn (operands[3], gen_rtx_REG (SImode, 4));
2082 DONE;
2083 }
2084 else
2085 FAIL;
2086 }
2087
2088 if (GET_CODE (operands[2]) != CONST_INT || INTVAL (operands[2]) < 0)
2089 {
2090 operands[2] = force_reg (SImode, operands[2]);
2091 label = gen_label_rtx ();
2092 emit (gen_udivmodsi4_tests (operands[0], operands[1], operands[2],
2093 operands[3], label));
2094 }
2095 else
2096 operands[2] = force_reg (SImode, operands[2]);
2097
2098 emit (gen_udivmodsi4_normal (operands[0], operands[1], operands[2],
2099 operands[3]));
2100 if (label)
2101 emit_label (label);
2102
2103 DONE;
2104 }")
2105
2106 ;; AIX architecture-independent common-mode multiply (DImode),
2107 ;; divide/modulus, and quotient subroutine calls. Input operands in R3 and
2108 ;; R4; results in R3 and sometimes R4; link register always clobbered by bla
2109 ;; instruction; R0 sometimes clobbered; also, MQ sometimes clobbered but
2110 ;; assumed unused if generating common-mode, so ignore.
2111 (define_insn "mulh_call"
2112 [(set (reg:SI 3)
2113 (truncate:SI
2114 (lshiftrt:DI (mult:DI (sign_extend:DI (reg:SI 3))
2115 (sign_extend:DI (reg:SI 4)))
2116 (const_int 32))))
2117 (clobber (match_scratch:SI 0 "=l"))]
2118 "! TARGET_POWER && ! TARGET_POWERPC"
2119 "bla __mulh"
2120 [(set_attr "type" "imul")])
2121
2122 (define_insn "mull_call"
2123 [(set (reg:DI 3)
2124 (mult:DI (sign_extend:DI (reg:SI 3))
2125 (sign_extend:DI (reg:SI 4))))
2126 (clobber (match_scratch:SI 0 "=l"))
2127 (clobber (reg:SI 0))]
2128 "! TARGET_POWER && ! TARGET_POWERPC"
2129 "bla __mull"
2130 [(set_attr "type" "imul")])
2131
2132 (define_insn "divss_call"
2133 [(set (reg:SI 3)
2134 (div:SI (reg:SI 3) (reg:SI 4)))
2135 (set (reg:SI 4)
2136 (mod:SI (reg:SI 3) (reg:SI 4)))
2137 (clobber (match_scratch:SI 0 "=l"))
2138 (clobber (reg:SI 0))]
2139 "! TARGET_POWER && ! TARGET_POWERPC"
2140 "bla __divss"
2141 [(set_attr "type" "idiv")])
2142
2143 (define_insn "divus_call"
2144 [(set (reg:SI 3)
2145 (udiv:SI (reg:SI 3) (reg:SI 4)))
2146 (set (reg:SI 4)
2147 (umod:SI (reg:SI 3) (reg:SI 4)))
2148 (clobber (match_scratch:SI 0 "=l"))
2149 (clobber (reg:SI 0))
2150 (clobber (match_scratch:CC 1 "=x"))
2151 (clobber (reg:CC 69))]
2152 "! TARGET_POWER && ! TARGET_POWERPC"
2153 "bla __divus"
2154 [(set_attr "type" "idiv")])
2155
2156 (define_insn "quoss_call"
2157 [(set (reg:SI 3)
2158 (div:SI (reg:SI 3) (reg:SI 4)))
2159 (clobber (match_scratch:SI 0 "=l"))]
2160 "! TARGET_POWER && ! TARGET_POWERPC"
2161 "bla __quoss"
2162 [(set_attr "type" "idiv")])
2163
2164 (define_insn "quous_call"
2165 [(set (reg:SI 3)
2166 (udiv:SI (reg:SI 3) (reg:SI 4)))
2167 (clobber (match_scratch:SI 0 "=l"))
2168 (clobber (reg:SI 0))
2169 (clobber (match_scratch:CC 1 "=x"))
2170 (clobber (reg:CC 69))]
2171 "! TARGET_POWER && ! TARGET_POWERPC"
2172 "bla __quous"
2173 [(set_attr "type" "idiv")])
2174 \f
2175 ;; Logical instructions
2176 ;; The logical instructions are mostly combined by using match_operator,
2177 ;; but the plain AND insns are somewhat different because there is no
2178 ;; plain 'andi' (only 'andi.'), no plain 'andis', and there are all
2179 ;; those rotate-and-mask operations. Thus, the AND insns come first.
2180
2181 (define_insn "andsi3"
2182 [(set (match_operand:SI 0 "gpc_reg_operand" "=r,r,r,r")
2183 (and:SI (match_operand:SI 1 "gpc_reg_operand" "%r,r,r,r")
2184 (match_operand:SI 2 "and_operand" "?r,T,K,L")))
2185 (clobber (match_scratch:CC 3 "=X,X,x,x"))]
2186 ""
2187 "@
2188 and %0,%1,%2
2189 {rlinm|rlwinm} %0,%1,0,%m2,%M2
2190 {andil.|andi.} %0,%1,%b2
2191 {andiu.|andis.} %0,%1,%u2")
2192
2193 ;; Note to set cr's other than cr0 we do the and immediate and then
2194 ;; the test again -- this avoids a mfcr which on the higher end
2195 ;; machines causes an execution serialization
2196
2197 (define_insn "*andsi3_internal2"
2198 [(set (match_operand:CC 0 "cc_reg_operand" "=x,x,x,x,?y,??y,??y,?y")
2199 (compare:CC (and:SI (match_operand:SI 1 "gpc_reg_operand" "%r,r,r,r,r,r,r,r")
2200 (match_operand:SI 2 "and_operand" "r,K,L,T,r,K,L,T"))
2201 (const_int 0)))
2202 (clobber (match_scratch:SI 3 "=r,r,r,r,r,r,r,r"))
2203 (clobber (match_scratch:CC 4 "=X,X,X,X,X,x,x,X"))]
2204 "! TARGET_POWERPC64"
2205 "@
2206 and. %3,%1,%2
2207 {andil.|andi.} %3,%1,%b2
2208 {andiu.|andis.} %3,%1,%u2
2209 {rlinm.|rlwinm.} %3,%1,0,%m2,%M2
2210 #
2211 #
2212 #
2213 #"
2214 [(set_attr "type" "compare,compare,compare,delayed_compare,compare,compare,compare,compare")
2215 (set_attr "length" "4,4,4,4,8,8,8,8")])
2216
2217 (define_insn "*andsi3_internal3"
2218 [(set (match_operand:CC 0 "cc_reg_operand" "=x,x,x,x,?y,??y,??y,?y")
2219 (compare:CC (and:SI (match_operand:SI 1 "gpc_reg_operand" "%r,r,r,r,r,r,r,r")
2220 (match_operand:SI 2 "and_operand" "r,K,L,T,r,K,L,T"))
2221 (const_int 0)))
2222 (clobber (match_scratch:SI 3 "=r,r,r,r,r,r,r,r"))
2223 (clobber (match_scratch:CC 4 "=X,X,X,X,X,x,x,X"))]
2224 "TARGET_POWERPC64"
2225 "@
2226 #
2227 {andil.|andi.} %3,%1,%b2
2228 {andiu.|andis.} %3,%1,%u2
2229 {rlinm.|rlwinm.} %3,%1,0,%m2,%M2
2230 #
2231 #
2232 #
2233 #"
2234 [(set_attr "type" "compare,compare,compare,delayed_compare,compare,compare,compare,compare")
2235 (set_attr "length" "8,4,4,4,8,8,8,8")])
2236
2237 (define_split
2238 [(set (match_operand:CC 0 "cc_reg_not_cr0_operand" "")
2239 (compare:CC (and:SI (match_operand:SI 1 "gpc_reg_operand" "")
2240 (match_operand:SI 2 "and_operand" ""))
2241 (const_int 0)))
2242 (clobber (match_scratch:SI 3 ""))
2243 (clobber (match_scratch:CC 4 ""))]
2244 "reload_completed"
2245 [(parallel [(set (match_dup 3)
2246 (and:SI (match_dup 1)
2247 (match_dup 2)))
2248 (clobber (match_dup 4))])
2249 (set (match_dup 0)
2250 (compare:CC (match_dup 3)
2251 (const_int 0)))]
2252 "")
2253
2254 ;; We don't have a 32 bit "and. rt,ra,rb" for ppc64. cr is set from the
2255 ;; whole 64 bit reg, and we don't know what is in the high 32 bits.
2256
2257 (define_split
2258 [(set (match_operand:CC 0 "cc_reg_operand" "")
2259 (compare:CC (and:SI (match_operand:SI 1 "gpc_reg_operand" "")
2260 (match_operand:SI 2 "gpc_reg_operand" ""))
2261 (const_int 0)))
2262 (clobber (match_scratch:SI 3 ""))
2263 (clobber (match_scratch:CC 4 ""))]
2264 "TARGET_POWERPC64 && reload_completed"
2265 [(parallel [(set (match_dup 3)
2266 (and:SI (match_dup 1)
2267 (match_dup 2)))
2268 (clobber (match_dup 4))])
2269 (set (match_dup 0)
2270 (compare:CC (match_dup 3)
2271 (const_int 0)))]
2272 "")
2273
2274 (define_insn "*andsi3_internal4"
2275 [(set (match_operand:CC 3 "cc_reg_operand" "=x,x,x,x,?y,??y,??y,?y")
2276 (compare:CC (and:SI (match_operand:SI 1 "gpc_reg_operand" "%r,r,r,r,r,r,r,r")
2277 (match_operand:SI 2 "and_operand" "r,K,L,T,r,K,L,T"))
2278 (const_int 0)))
2279 (set (match_operand:SI 0 "gpc_reg_operand" "=r,r,r,r,r,r,r,r")
2280 (and:SI (match_dup 1)
2281 (match_dup 2)))
2282 (clobber (match_scratch:CC 4 "=X,X,X,X,X,x,x,X"))]
2283 "! TARGET_POWERPC64"
2284 "@
2285 and. %0,%1,%2
2286 {andil.|andi.} %0,%1,%b2
2287 {andiu.|andis.} %0,%1,%u2
2288 {rlinm.|rlwinm.} %0,%1,0,%m2,%M2
2289 #
2290 #
2291 #
2292 #"
2293 [(set_attr "type" "compare,compare,compare,delayed_compare,compare,compare,compare,compare")
2294 (set_attr "length" "4,4,4,4,8,8,8,8")])
2295
2296 (define_insn "*andsi3_internal5"
2297 [(set (match_operand:CC 3 "cc_reg_operand" "=x,x,x,x,?y,??y,??y,?y")
2298 (compare:CC (and:SI (match_operand:SI 1 "gpc_reg_operand" "%r,r,r,r,r,r,r,r")
2299 (match_operand:SI 2 "and_operand" "r,K,L,T,r,K,L,T"))
2300 (const_int 0)))
2301 (set (match_operand:SI 0 "gpc_reg_operand" "=r,r,r,r,r,r,r,r")
2302 (and:SI (match_dup 1)
2303 (match_dup 2)))
2304 (clobber (match_scratch:CC 4 "=X,X,X,X,X,x,x,X"))]
2305 "TARGET_POWERPC64"
2306 "@
2307 #
2308 {andil.|andi.} %0,%1,%b2
2309 {andiu.|andis.} %0,%1,%u2
2310 {rlinm.|rlwinm.} %0,%1,0,%m2,%M2
2311 #
2312 #
2313 #
2314 #"
2315 [(set_attr "type" "compare,compare,compare,delayed_compare,compare,compare,compare,compare")
2316 (set_attr "length" "8,4,4,4,8,8,8,8")])
2317
2318 (define_split
2319 [(set (match_operand:CC 3 "cc_reg_not_cr0_operand" "")
2320 (compare:CC (and:SI (match_operand:SI 1 "gpc_reg_operand" "")
2321 (match_operand:SI 2 "and_operand" ""))
2322 (const_int 0)))
2323 (set (match_operand:SI 0 "gpc_reg_operand" "")
2324 (and:SI (match_dup 1)
2325 (match_dup 2)))
2326 (clobber (match_scratch:CC 4 ""))]
2327 "reload_completed"
2328 [(parallel [(set (match_dup 0)
2329 (and:SI (match_dup 1)
2330 (match_dup 2)))
2331 (clobber (match_dup 4))])
2332 (set (match_dup 3)
2333 (compare:CC (match_dup 0)
2334 (const_int 0)))]
2335 "")
2336
2337 (define_split
2338 [(set (match_operand:CC 3 "cc_reg_operand" "")
2339 (compare:CC (and:SI (match_operand:SI 1 "gpc_reg_operand" "")
2340 (match_operand:SI 2 "gpc_reg_operand" ""))
2341 (const_int 0)))
2342 (set (match_operand:SI 0 "gpc_reg_operand" "")
2343 (and:SI (match_dup 1)
2344 (match_dup 2)))
2345 (clobber (match_scratch:CC 4 ""))]
2346 "TARGET_POWERPC64 && reload_completed"
2347 [(parallel [(set (match_dup 0)
2348 (and:SI (match_dup 1)
2349 (match_dup 2)))
2350 (clobber (match_dup 4))])
2351 (set (match_dup 3)
2352 (compare:CC (match_dup 0)
2353 (const_int 0)))]
2354 "")
2355
2356 ;; Handle the PowerPC64 rlwinm corner case
2357
2358 (define_insn_and_split "*andsi3_internal6"
2359 [(set (match_operand:SI 0 "gpc_reg_operand" "=r")
2360 (and:SI (match_operand:SI 1 "gpc_reg_operand" "r")
2361 (match_operand:SI 2 "mask_operand_wrap" "i")))]
2362 "TARGET_POWERPC64"
2363 "#"
2364 "TARGET_POWERPC64"
2365 [(set (match_dup 0)
2366 (and:SI (rotate:SI (match_dup 1) (match_dup 3))
2367 (match_dup 4)))
2368 (set (match_dup 0)
2369 (rotate:SI (match_dup 0) (match_dup 5)))]
2370 "
2371 {
2372 int mb = extract_MB (operands[2]);
2373 int me = extract_ME (operands[2]);
2374 operands[3] = GEN_INT (me + 1);
2375 operands[5] = GEN_INT (32 - (me + 1));
2376 operands[4] = GEN_INT (~((HOST_WIDE_INT) -1 << (33 + me - mb)));
2377 }"
2378 [(set_attr "length" "8")])
2379
2380 (define_insn_and_split "*andsi3_internal7"
2381 [(set (match_operand:CC 2 "cc_reg_operand" "=x,?y")
2382 (compare:CC (and:SI (match_operand:SI 0 "gpc_reg_operand" "r,r")
2383 (match_operand:SI 1 "mask_operand_wrap" "i,i"))
2384 (const_int 0)))
2385 (clobber (match_scratch:SI 3 "=r,r"))]
2386 "TARGET_POWERPC64"
2387 "#"
2388 "TARGET_POWERPC64"
2389 [(parallel [(set (match_dup 2)
2390 (compare:CC (and:SI (rotate:SI (match_dup 0) (match_dup 4))
2391 (match_dup 5))
2392 (const_int 0)))
2393 (clobber (match_dup 3))])]
2394 "
2395 {
2396 int mb = extract_MB (operands[1]);
2397 int me = extract_ME (operands[1]);
2398 operands[4] = GEN_INT (me + 1);
2399 operands[5] = GEN_INT (~((HOST_WIDE_INT) -1 << (33 + me - mb)));
2400 }"
2401 [(set_attr "type" "delayed_compare,compare")
2402 (set_attr "length" "4,8")])
2403
2404 (define_insn_and_split "*andsi3_internal8"
2405 [(set (match_operand:CC 3 "cc_reg_operand" "=x,??y")
2406 (compare:CC (and:SI (match_operand:SI 1 "gpc_reg_operand" "r,r")
2407 (match_operand:SI 2 "mask_operand_wrap" "i,i"))
2408 (const_int 0)))
2409 (set (match_operand:SI 0 "gpc_reg_operand" "=r,r")
2410 (and:SI (match_dup 1)
2411 (match_dup 2)))]
2412 "TARGET_POWERPC64"
2413 "#"
2414 "TARGET_POWERPC64"
2415 [(parallel [(set (match_dup 3)
2416 (compare:CC (and:SI (rotate:SI (match_dup 1) (match_dup 4))
2417 (match_dup 5))
2418 (const_int 0)))
2419 (set (match_dup 0)
2420 (and:SI (rotate:SI (match_dup 1) (match_dup 4))
2421 (match_dup 5)))])
2422 (set (match_dup 0)
2423 (rotate:SI (match_dup 0) (match_dup 6)))]
2424 "
2425 {
2426 int mb = extract_MB (operands[2]);
2427 int me = extract_ME (operands[2]);
2428 operands[4] = GEN_INT (me + 1);
2429 operands[6] = GEN_INT (32 - (me + 1));
2430 operands[5] = GEN_INT (~((HOST_WIDE_INT) -1 << (33 + me - mb)));
2431 }"
2432 [(set_attr "type" "delayed_compare,compare")
2433 (set_attr "length" "8,12")])
2434
2435 (define_expand "iorsi3"
2436 [(set (match_operand:SI 0 "gpc_reg_operand" "")
2437 (ior:SI (match_operand:SI 1 "gpc_reg_operand" "")
2438 (match_operand:SI 2 "reg_or_logical_cint_operand" "")))]
2439 ""
2440 "
2441 {
2442 if (GET_CODE (operands[2]) == CONST_INT
2443 && ! logical_operand (operands[2], SImode))
2444 {
2445 HOST_WIDE_INT value = INTVAL (operands[2]);
2446 rtx tmp = ((no_new_pseudos || rtx_equal_p (operands[0], operands[1]))
2447 ? operands[0] : gen_reg_rtx (SImode));
2448
2449 emit_insn (gen_iorsi3 (tmp, operands[1],
2450 GEN_INT (value & (~ (HOST_WIDE_INT) 0xffff))));
2451 emit_insn (gen_iorsi3 (operands[0], tmp, GEN_INT (value & 0xffff)));
2452 DONE;
2453 }
2454 }")
2455
2456 (define_expand "xorsi3"
2457 [(set (match_operand:SI 0 "gpc_reg_operand" "")
2458 (xor:SI (match_operand:SI 1 "gpc_reg_operand" "")
2459 (match_operand:SI 2 "reg_or_logical_cint_operand" "")))]
2460 ""
2461 "
2462 {
2463 if (GET_CODE (operands[2]) == CONST_INT
2464 && ! logical_operand (operands[2], SImode))
2465 {
2466 HOST_WIDE_INT value = INTVAL (operands[2]);
2467 rtx tmp = ((no_new_pseudos || rtx_equal_p (operands[0], operands[1]))
2468 ? operands[0] : gen_reg_rtx (SImode));
2469
2470 emit_insn (gen_xorsi3 (tmp, operands[1],
2471 GEN_INT (value & (~ (HOST_WIDE_INT) 0xffff))));
2472 emit_insn (gen_xorsi3 (operands[0], tmp, GEN_INT (value & 0xffff)));
2473 DONE;
2474 }
2475 }")
2476
2477 (define_insn "*boolsi3_internal1"
2478 [(set (match_operand:SI 0 "gpc_reg_operand" "=r,r,r")
2479 (match_operator:SI 3 "boolean_or_operator"
2480 [(match_operand:SI 1 "gpc_reg_operand" "%r,r,r")
2481 (match_operand:SI 2 "logical_operand" "r,K,L")]))]
2482 ""
2483 "@
2484 %q3 %0,%1,%2
2485 {%q3il|%q3i} %0,%1,%b2
2486 {%q3iu|%q3is} %0,%1,%u2")
2487
2488 (define_insn "*boolsi3_internal2"
2489 [(set (match_operand:CC 0 "cc_reg_operand" "=x,?y")
2490 (compare:CC (match_operator:SI 4 "boolean_or_operator"
2491 [(match_operand:SI 1 "gpc_reg_operand" "%r,r")
2492 (match_operand:SI 2 "gpc_reg_operand" "r,r")])
2493 (const_int 0)))
2494 (clobber (match_scratch:SI 3 "=r,r"))]
2495 "! TARGET_POWERPC64"
2496 "@
2497 %q4. %3,%1,%2
2498 #"
2499 [(set_attr "type" "compare")
2500 (set_attr "length" "4,8")])
2501
2502 (define_split
2503 [(set (match_operand:CC 0 "cc_reg_not_cr0_operand" "")
2504 (compare:CC (match_operator:SI 4 "boolean_operator"
2505 [(match_operand:SI 1 "gpc_reg_operand" "")
2506 (match_operand:SI 2 "gpc_reg_operand" "")])
2507 (const_int 0)))
2508 (clobber (match_scratch:SI 3 ""))]
2509 "! TARGET_POWERPC64 && reload_completed"
2510 [(set (match_dup 3) (match_dup 4))
2511 (set (match_dup 0)
2512 (compare:CC (match_dup 3)
2513 (const_int 0)))]
2514 "")
2515
2516 (define_insn "*boolsi3_internal3"
2517 [(set (match_operand:CC 3 "cc_reg_operand" "=x,?y")
2518 (compare:CC (match_operator:SI 4 "boolean_operator"
2519 [(match_operand:SI 1 "gpc_reg_operand" "%r,r")
2520 (match_operand:SI 2 "gpc_reg_operand" "r,r")])
2521 (const_int 0)))
2522 (set (match_operand:SI 0 "gpc_reg_operand" "=r,r")
2523 (match_dup 4))]
2524 "! TARGET_POWERPC64"
2525 "@
2526 %q4. %0,%1,%2
2527 #"
2528 [(set_attr "type" "compare")
2529 (set_attr "length" "4,8")])
2530
2531 (define_split
2532 [(set (match_operand:CC 3 "cc_reg_not_cr0_operand" "")
2533 (compare:CC (match_operator:SI 4 "boolean_operator"
2534 [(match_operand:SI 1 "gpc_reg_operand" "")
2535 (match_operand:SI 2 "gpc_reg_operand" "")])
2536 (const_int 0)))
2537 (set (match_operand:SI 0 "gpc_reg_operand" "")
2538 (match_dup 4))]
2539 "! TARGET_POWERPC64 && reload_completed"
2540 [(set (match_dup 0) (match_dup 4))
2541 (set (match_dup 3)
2542 (compare:CC (match_dup 0)
2543 (const_int 0)))]
2544 "")
2545
2546 ;; Split a logical operation that we can't do in one insn into two insns,
2547 ;; each of which does one 16-bit part. This is used by combine.
2548
2549 (define_split
2550 [(set (match_operand:SI 0 "gpc_reg_operand" "")
2551 (match_operator:SI 3 "boolean_or_operator"
2552 [(match_operand:SI 1 "gpc_reg_operand" "")
2553 (match_operand:SI 2 "non_logical_cint_operand" "")]))]
2554 ""
2555 [(set (match_dup 0) (match_dup 4))
2556 (set (match_dup 0) (match_dup 5))]
2557 "
2558 {
2559 rtx i;
2560 i = GEN_INT (INTVAL (operands[2]) & (~ (HOST_WIDE_INT) 0xffff));
2561 operands[4] = gen_rtx (GET_CODE (operands[3]), SImode,
2562 operands[1], i);
2563 i = GEN_INT (INTVAL (operands[2]) & 0xffff);
2564 operands[5] = gen_rtx (GET_CODE (operands[3]), SImode,
2565 operands[0], i);
2566 }")
2567
2568 (define_insn "*boolcsi3_internal1"
2569 [(set (match_operand:SI 0 "gpc_reg_operand" "=r")
2570 (match_operator:SI 3 "boolean_operator"
2571 [(not:SI (match_operand:SI 1 "gpc_reg_operand" "r"))
2572 (match_operand:SI 2 "gpc_reg_operand" "r")]))]
2573 ""
2574 "%q3 %0,%2,%1")
2575
2576 (define_insn "*boolcsi3_internal2"
2577 [(set (match_operand:CC 0 "cc_reg_operand" "=x,?y")
2578 (compare:CC (match_operator:SI 4 "boolean_operator"
2579 [(not:SI (match_operand:SI 1 "gpc_reg_operand" "r,r"))
2580 (match_operand:SI 2 "gpc_reg_operand" "r,r")])
2581 (const_int 0)))
2582 (clobber (match_scratch:SI 3 "=r,r"))]
2583 "! TARGET_POWERPC64"
2584 "@
2585 %q4. %3,%2,%1
2586 #"
2587 [(set_attr "type" "compare")
2588 (set_attr "length" "4,8")])
2589
2590 (define_split
2591 [(set (match_operand:CC 0 "cc_reg_not_cr0_operand" "")
2592 (compare:CC (match_operator:SI 4 "boolean_operator"
2593 [(not:SI (match_operand:SI 1 "gpc_reg_operand" ""))
2594 (match_operand:SI 2 "gpc_reg_operand" "")])
2595 (const_int 0)))
2596 (clobber (match_scratch:SI 3 ""))]
2597 "! TARGET_POWERPC64 && reload_completed"
2598 [(set (match_dup 3) (match_dup 4))
2599 (set (match_dup 0)
2600 (compare:CC (match_dup 3)
2601 (const_int 0)))]
2602 "")
2603
2604 (define_insn "*boolcsi3_internal3"
2605 [(set (match_operand:CC 3 "cc_reg_operand" "=x,?y")
2606 (compare:CC (match_operator:SI 4 "boolean_operator"
2607 [(not:SI (match_operand:SI 1 "gpc_reg_operand" "%r,r"))
2608 (match_operand:SI 2 "gpc_reg_operand" "r,r")])
2609 (const_int 0)))
2610 (set (match_operand:SI 0 "gpc_reg_operand" "=r,r")
2611 (match_dup 4))]
2612 "! TARGET_POWERPC64"
2613 "@
2614 %q4. %0,%2,%1
2615 #"
2616 [(set_attr "type" "compare")
2617 (set_attr "length" "4,8")])
2618
2619 (define_split
2620 [(set (match_operand:CC 3 "cc_reg_not_cr0_operand" "")
2621 (compare:CC (match_operator:SI 4 "boolean_operator"
2622 [(not:SI (match_operand:SI 1 "gpc_reg_operand" ""))
2623 (match_operand:SI 2 "gpc_reg_operand" "")])
2624 (const_int 0)))
2625 (set (match_operand:SI 0 "gpc_reg_operand" "")
2626 (match_dup 4))]
2627 "! TARGET_POWERPC64 && reload_completed"
2628 [(set (match_dup 0) (match_dup 4))
2629 (set (match_dup 3)
2630 (compare:CC (match_dup 0)
2631 (const_int 0)))]
2632 "")
2633
2634 (define_insn "*boolccsi3_internal1"
2635 [(set (match_operand:SI 0 "gpc_reg_operand" "=r")
2636 (match_operator:SI 3 "boolean_operator"
2637 [(not:SI (match_operand:SI 1 "gpc_reg_operand" "r"))
2638 (not:SI (match_operand:SI 2 "gpc_reg_operand" "r"))]))]
2639 ""
2640 "%q3 %0,%1,%2")
2641
2642 (define_insn "*boolccsi3_internal2"
2643 [(set (match_operand:CC 0 "cc_reg_operand" "=x,?y")
2644 (compare:CC (match_operator:SI 4 "boolean_operator"
2645 [(not:SI (match_operand:SI 1 "gpc_reg_operand" "r,r"))
2646 (not:SI (match_operand:SI 2 "gpc_reg_operand" "r,r"))])
2647 (const_int 0)))
2648 (clobber (match_scratch:SI 3 "=r,r"))]
2649 "! TARGET_POWERPC64"
2650 "@
2651 %q4. %3,%1,%2
2652 #"
2653 [(set_attr "type" "compare")
2654 (set_attr "length" "4,8")])
2655
2656 (define_split
2657 [(set (match_operand:CC 0 "cc_reg_not_cr0_operand" "")
2658 (compare:CC (match_operator:SI 4 "boolean_operator"
2659 [(not:SI (match_operand:SI 1 "gpc_reg_operand" ""))
2660 (not:SI (match_operand:SI 2 "gpc_reg_operand" ""))])
2661 (const_int 0)))
2662 (clobber (match_scratch:SI 3 ""))]
2663 "! TARGET_POWERPC64 && reload_completed"
2664 [(set (match_dup 3) (match_dup 4))
2665 (set (match_dup 0)
2666 (compare:CC (match_dup 3)
2667 (const_int 0)))]
2668 "")
2669
2670 (define_insn "*boolccsi3_internal3"
2671 [(set (match_operand:CC 3 "cc_reg_operand" "=x,?y")
2672 (compare:CC (match_operator:SI 4 "boolean_operator"
2673 [(not:SI (match_operand:SI 1 "gpc_reg_operand" "%r,r"))
2674 (not:SI (match_operand:SI 2 "gpc_reg_operand" "r,r"))])
2675 (const_int 0)))
2676 (set (match_operand:SI 0 "gpc_reg_operand" "=r,r")
2677 (match_dup 4))]
2678 "! TARGET_POWERPC64"
2679 "@
2680 %q4. %0,%1,%2
2681 #"
2682 [(set_attr "type" "compare")
2683 (set_attr "length" "4,8")])
2684
2685 (define_split
2686 [(set (match_operand:CC 3 "cc_reg_not_cr0_operand" "")
2687 (compare:CC (match_operator:SI 4 "boolean_operator"
2688 [(not:SI (match_operand:SI 1 "gpc_reg_operand" ""))
2689 (not:SI (match_operand:SI 2 "gpc_reg_operand" ""))])
2690 (const_int 0)))
2691 (set (match_operand:SI 0 "gpc_reg_operand" "")
2692 (match_dup 4))]
2693 "! TARGET_POWERPC64 && reload_completed"
2694 [(set (match_dup 0) (match_dup 4))
2695 (set (match_dup 3)
2696 (compare:CC (match_dup 0)
2697 (const_int 0)))]
2698 "")
2699
2700 ;; maskir insn. We need four forms because things might be in arbitrary
2701 ;; orders. Don't define forms that only set CR fields because these
2702 ;; would modify an input register.
2703
2704 (define_insn "*maskir_internal1"
2705 [(set (match_operand:SI 0 "gpc_reg_operand" "=r")
2706 (ior:SI (and:SI (not:SI (match_operand:SI 2 "gpc_reg_operand" "r"))
2707 (match_operand:SI 1 "gpc_reg_operand" "0"))
2708 (and:SI (match_dup 2)
2709 (match_operand:SI 3 "gpc_reg_operand" "r"))))]
2710 "TARGET_POWER"
2711 "maskir %0,%3,%2")
2712
2713 (define_insn "*maskir_internal2"
2714 [(set (match_operand:SI 0 "gpc_reg_operand" "=r")
2715 (ior:SI (and:SI (not:SI (match_operand:SI 2 "gpc_reg_operand" "r"))
2716 (match_operand:SI 1 "gpc_reg_operand" "0"))
2717 (and:SI (match_operand:SI 3 "gpc_reg_operand" "r")
2718 (match_dup 2))))]
2719 "TARGET_POWER"
2720 "maskir %0,%3,%2")
2721
2722 (define_insn "*maskir_internal3"
2723 [(set (match_operand:SI 0 "gpc_reg_operand" "=r")
2724 (ior:SI (and:SI (match_operand:SI 2 "gpc_reg_operand" "r")
2725 (match_operand:SI 3 "gpc_reg_operand" "r"))
2726 (and:SI (not:SI (match_dup 2))
2727 (match_operand:SI 1 "gpc_reg_operand" "0"))))]
2728 "TARGET_POWER"
2729 "maskir %0,%3,%2")
2730
2731 (define_insn "*maskir_internal4"
2732 [(set (match_operand:SI 0 "gpc_reg_operand" "=r")
2733 (ior:SI (and:SI (match_operand:SI 3 "gpc_reg_operand" "r")
2734 (match_operand:SI 2 "gpc_reg_operand" "r"))
2735 (and:SI (not:SI (match_dup 2))
2736 (match_operand:SI 1 "gpc_reg_operand" "0"))))]
2737 "TARGET_POWER"
2738 "maskir %0,%3,%2")
2739
2740 (define_insn "*maskir_internal5"
2741 [(set (match_operand:CC 4 "cc_reg_operand" "=x,?y")
2742 (compare:CC
2743 (ior:SI (and:SI (not:SI (match_operand:SI 2 "gpc_reg_operand" "r,r"))
2744 (match_operand:SI 1 "gpc_reg_operand" "0,0"))
2745 (and:SI (match_dup 2)
2746 (match_operand:SI 3 "gpc_reg_operand" "r,r")))
2747 (const_int 0)))
2748 (set (match_operand:SI 0 "gpc_reg_operand" "=r,r")
2749 (ior:SI (and:SI (not:SI (match_dup 2)) (match_dup 1))
2750 (and:SI (match_dup 2) (match_dup 3))))]
2751 "TARGET_POWER"
2752 "@
2753 maskir. %0,%3,%2
2754 #"
2755 [(set_attr "type" "compare")
2756 (set_attr "length" "4,8")])
2757
2758 (define_split
2759 [(set (match_operand:CC 4 "cc_reg_not_cr0_operand" "")
2760 (compare:CC
2761 (ior:SI (and:SI (not:SI (match_operand:SI 2 "gpc_reg_operand" ""))
2762 (match_operand:SI 1 "gpc_reg_operand" ""))
2763 (and:SI (match_dup 2)
2764 (match_operand:SI 3 "gpc_reg_operand" "")))
2765 (const_int 0)))
2766 (set (match_operand:SI 0 "gpc_reg_operand" "")
2767 (ior:SI (and:SI (not:SI (match_dup 2)) (match_dup 1))
2768 (and:SI (match_dup 2) (match_dup 3))))]
2769 "TARGET_POWER && reload_completed"
2770 [(set (match_dup 0)
2771 (ior:SI (and:SI (not:SI (match_dup 2)) (match_dup 1))
2772 (and:SI (match_dup 2) (match_dup 3))))
2773 (set (match_dup 4)
2774 (compare:CC (match_dup 0)
2775 (const_int 0)))]
2776 "")
2777
2778 (define_insn "*maskir_internal6"
2779 [(set (match_operand:CC 4 "cc_reg_operand" "=x,?y")
2780 (compare:CC
2781 (ior:SI (and:SI (not:SI (match_operand:SI 2 "gpc_reg_operand" "r,r"))
2782 (match_operand:SI 1 "gpc_reg_operand" "0,0"))
2783 (and:SI (match_operand:SI 3 "gpc_reg_operand" "r,r")
2784 (match_dup 2)))
2785 (const_int 0)))
2786 (set (match_operand:SI 0 "gpc_reg_operand" "=r,r")
2787 (ior:SI (and:SI (not:SI (match_dup 2)) (match_dup 1))
2788 (and:SI (match_dup 3) (match_dup 2))))]
2789 "TARGET_POWER"
2790 "@
2791 maskir. %0,%3,%2
2792 #"
2793 [(set_attr "type" "compare")
2794 (set_attr "length" "4,8")])
2795
2796 (define_split
2797 [(set (match_operand:CC 4 "cc_reg_not_cr0_operand" "")
2798 (compare:CC
2799 (ior:SI (and:SI (not:SI (match_operand:SI 2 "gpc_reg_operand" ""))
2800 (match_operand:SI 1 "gpc_reg_operand" ""))
2801 (and:SI (match_operand:SI 3 "gpc_reg_operand" "")
2802 (match_dup 2)))
2803 (const_int 0)))
2804 (set (match_operand:SI 0 "gpc_reg_operand" "")
2805 (ior:SI (and:SI (not:SI (match_dup 2)) (match_dup 1))
2806 (and:SI (match_dup 3) (match_dup 2))))]
2807 "TARGET_POWER && reload_completed"
2808 [(set (match_dup 0)
2809 (ior:SI (and:SI (not:SI (match_dup 2)) (match_dup 1))
2810 (and:SI (match_dup 3) (match_dup 2))))
2811 (set (match_dup 4)
2812 (compare:CC (match_dup 0)
2813 (const_int 0)))]
2814 "")
2815
2816 (define_insn "*maskir_internal7"
2817 [(set (match_operand:CC 4 "cc_reg_operand" "=x,?y")
2818 (compare:CC
2819 (ior:SI (and:SI (match_operand:SI 2 "gpc_reg_operand" "r,r")
2820 (match_operand:SI 3 "gpc_reg_operand" "r,r"))
2821 (and:SI (not:SI (match_dup 2))
2822 (match_operand:SI 1 "gpc_reg_operand" "0,0")))
2823 (const_int 0)))
2824 (set (match_operand:SI 0 "gpc_reg_operand" "=r,r")
2825 (ior:SI (and:SI (match_dup 2) (match_dup 3))
2826 (and:SI (not:SI (match_dup 2)) (match_dup 1))))]
2827 "TARGET_POWER"
2828 "@
2829 maskir. %0,%3,%2
2830 #"
2831 [(set_attr "type" "compare")
2832 (set_attr "length" "4,8")])
2833
2834 (define_split
2835 [(set (match_operand:CC 4 "cc_reg_not_cr0_operand" "")
2836 (compare:CC
2837 (ior:SI (and:SI (match_operand:SI 2 "gpc_reg_operand" "")
2838 (match_operand:SI 3 "gpc_reg_operand" ""))
2839 (and:SI (not:SI (match_dup 2))
2840 (match_operand:SI 1 "gpc_reg_operand" "")))
2841 (const_int 0)))
2842 (set (match_operand:SI 0 "gpc_reg_operand" "")
2843 (ior:SI (and:SI (match_dup 2) (match_dup 3))
2844 (and:SI (not:SI (match_dup 2)) (match_dup 1))))]
2845 "TARGET_POWER && reload_completed"
2846 [(set (match_dup 0)
2847 (ior:SI (and:SI (match_dup 2) (match_dup 3))
2848 (and:SI (not:SI (match_dup 2)) (match_dup 1))))
2849 (set (match_dup 4)
2850 (compare:CC (match_dup 0)
2851 (const_int 0)))]
2852 "")
2853
2854 (define_insn "*maskir_internal8"
2855 [(set (match_operand:CC 4 "cc_reg_operand" "=x,?y")
2856 (compare:CC
2857 (ior:SI (and:SI (match_operand:SI 3 "gpc_reg_operand" "r,r")
2858 (match_operand:SI 2 "gpc_reg_operand" "r,r"))
2859 (and:SI (not:SI (match_dup 2))
2860 (match_operand:SI 1 "gpc_reg_operand" "0,0")))
2861 (const_int 0)))
2862 (set (match_operand:SI 0 "gpc_reg_operand" "=r,r")
2863 (ior:SI (and:SI (match_dup 3) (match_dup 2))
2864 (and:SI (not:SI (match_dup 2)) (match_dup 1))))]
2865 "TARGET_POWER"
2866 "@
2867 maskir. %0,%3,%2
2868 #"
2869 [(set_attr "type" "compare")
2870 (set_attr "length" "4,8")])
2871
2872 (define_split
2873 [(set (match_operand:CC 4 "cc_reg_not_cr0_operand" "")
2874 (compare:CC
2875 (ior:SI (and:SI (match_operand:SI 3 "gpc_reg_operand" "")
2876 (match_operand:SI 2 "gpc_reg_operand" ""))
2877 (and:SI (not:SI (match_dup 2))
2878 (match_operand:SI 1 "gpc_reg_operand" "")))
2879 (const_int 0)))
2880 (set (match_operand:SI 0 "gpc_reg_operand" "")
2881 (ior:SI (and:SI (match_dup 3) (match_dup 2))
2882 (and:SI (not:SI (match_dup 2)) (match_dup 1))))]
2883 "TARGET_POWER && reload_completed"
2884 [(set (match_dup 0)
2885 (ior:SI (and:SI (match_dup 3) (match_dup 2))
2886 (and:SI (not:SI (match_dup 2)) (match_dup 1))))
2887 (set (match_dup 4)
2888 (compare:CC (match_dup 0)
2889 (const_int 0)))]
2890 "")
2891 \f
2892 ;; Rotate and shift insns, in all their variants. These support shifts,
2893 ;; field inserts and extracts, and various combinations thereof.
2894 (define_expand "insv"
2895 [(set (zero_extract (match_operand 0 "gpc_reg_operand" "")
2896 (match_operand:SI 1 "const_int_operand" "")
2897 (match_operand:SI 2 "const_int_operand" ""))
2898 (match_operand 3 "gpc_reg_operand" ""))]
2899 ""
2900 "
2901 {
2902 /* Do not handle 16/8 bit structures that fit in HI/QI modes directly, since
2903 the (SUBREG:SI (REG:HI xxx)) that is otherwise generated can confuse the
2904 compiler if the address of the structure is taken later. */
2905 if (GET_CODE (operands[0]) == SUBREG
2906 && (GET_MODE_SIZE (GET_MODE (SUBREG_REG (operands[0]))) < UNITS_PER_WORD))
2907 FAIL;
2908
2909 if (TARGET_POWERPC64 && GET_MODE (operands[0]) == DImode)
2910 emit_insn (gen_insvdi (operands[0], operands[1], operands[2], operands[3]));
2911 else
2912 emit_insn (gen_insvsi (operands[0], operands[1], operands[2], operands[3]));
2913 DONE;
2914 }")
2915
2916 (define_insn "insvsi"
2917 [(set (zero_extract:SI (match_operand:SI 0 "gpc_reg_operand" "+r")
2918 (match_operand:SI 1 "const_int_operand" "i")
2919 (match_operand:SI 2 "const_int_operand" "i"))
2920 (match_operand:SI 3 "gpc_reg_operand" "r"))]
2921 ""
2922 "*
2923 {
2924 int start = INTVAL (operands[2]) & 31;
2925 int size = INTVAL (operands[1]) & 31;
2926
2927 operands[4] = GEN_INT (32 - start - size);
2928 operands[1] = GEN_INT (start + size - 1);
2929 return \"{rlimi|rlwimi} %0,%3,%h4,%h2,%h1\";
2930 }")
2931
2932 (define_insn "*insvsi_internal1"
2933 [(set (zero_extract:SI (match_operand:SI 0 "gpc_reg_operand" "+r")
2934 (match_operand:SI 1 "const_int_operand" "i")
2935 (match_operand:SI 2 "const_int_operand" "i"))
2936 (ashift:SI (match_operand:SI 3 "gpc_reg_operand" "r")
2937 (match_operand:SI 4 "const_int_operand" "i")))]
2938 "(32 - (INTVAL (operands[4]) & 31)) >= INTVAL (operands[1])"
2939 "*
2940 {
2941 int shift = INTVAL (operands[4]) & 31;
2942 int start = INTVAL (operands[2]) & 31;
2943 int size = INTVAL (operands[1]) & 31;
2944
2945 operands[4] = GEN_INT (shift - start - size);
2946 operands[1] = GEN_INT (start + size - 1);
2947 return \"{rlimi|rlwimi} %0,%3,%h4,%h2,%h1\";
2948 }")
2949
2950 (define_insn "*insvsi_internal2"
2951 [(set (zero_extract:SI (match_operand:SI 0 "gpc_reg_operand" "+r")
2952 (match_operand:SI 1 "const_int_operand" "i")
2953 (match_operand:SI 2 "const_int_operand" "i"))
2954 (ashiftrt:SI (match_operand:SI 3 "gpc_reg_operand" "r")
2955 (match_operand:SI 4 "const_int_operand" "i")))]
2956 "(32 - (INTVAL (operands[4]) & 31)) >= INTVAL (operands[1])"
2957 "*
2958 {
2959 int shift = INTVAL (operands[4]) & 31;
2960 int start = INTVAL (operands[2]) & 31;
2961 int size = INTVAL (operands[1]) & 31;
2962
2963 operands[4] = GEN_INT (32 - shift - start - size);
2964 operands[1] = GEN_INT (start + size - 1);
2965 return \"{rlimi|rlwimi} %0,%3,%h4,%h2,%h1\";
2966 }")
2967
2968 (define_insn "*insvsi_internal3"
2969 [(set (zero_extract:SI (match_operand:SI 0 "gpc_reg_operand" "+r")
2970 (match_operand:SI 1 "const_int_operand" "i")
2971 (match_operand:SI 2 "const_int_operand" "i"))
2972 (lshiftrt:SI (match_operand:SI 3 "gpc_reg_operand" "r")
2973 (match_operand:SI 4 "const_int_operand" "i")))]
2974 "(32 - (INTVAL (operands[4]) & 31)) >= INTVAL (operands[1])"
2975 "*
2976 {
2977 int shift = INTVAL (operands[4]) & 31;
2978 int start = INTVAL (operands[2]) & 31;
2979 int size = INTVAL (operands[1]) & 31;
2980
2981 operands[4] = GEN_INT (32 - shift - start - size);
2982 operands[1] = GEN_INT (start + size - 1);
2983 return \"{rlimi|rlwimi} %0,%3,%h4,%h2,%h1\";
2984 }")
2985
2986 (define_insn "*insvsi_internal4"
2987 [(set (zero_extract:SI (match_operand:SI 0 "gpc_reg_operand" "+r")
2988 (match_operand:SI 1 "const_int_operand" "i")
2989 (match_operand:SI 2 "const_int_operand" "i"))
2990 (zero_extract:SI (match_operand:SI 3 "gpc_reg_operand" "r")
2991 (match_operand:SI 4 "const_int_operand" "i")
2992 (match_operand:SI 5 "const_int_operand" "i")))]
2993 "INTVAL (operands[4]) >= INTVAL (operands[1])"
2994 "*
2995 {
2996 int extract_start = INTVAL (operands[5]) & 31;
2997 int extract_size = INTVAL (operands[4]) & 31;
2998 int insert_start = INTVAL (operands[2]) & 31;
2999 int insert_size = INTVAL (operands[1]) & 31;
3000
3001 /* Align extract field with insert field */
3002 operands[5] = GEN_INT (extract_start + extract_size - insert_start - insert_size);
3003 operands[1] = GEN_INT (insert_start + insert_size - 1);
3004 return \"{rlimi|rlwimi} %0,%3,%h5,%h2,%h1\";
3005 }")
3006
3007 (define_insn "insvdi"
3008 [(set (zero_extract:DI (match_operand:DI 0 "gpc_reg_operand" "+r")
3009 (match_operand:SI 1 "const_int_operand" "i")
3010 (match_operand:SI 2 "const_int_operand" "i"))
3011 (match_operand:DI 3 "gpc_reg_operand" "r"))]
3012 "TARGET_POWERPC64"
3013 "*
3014 {
3015 int start = INTVAL (operands[2]) & 63;
3016 int size = INTVAL (operands[1]) & 63;
3017
3018 operands[1] = GEN_INT (64 - start - size);
3019 return \"rldimi %0,%3,%H1,%H2\";
3020 }")
3021
3022 (define_expand "extzv"
3023 [(set (match_operand 0 "gpc_reg_operand" "")
3024 (zero_extract (match_operand 1 "gpc_reg_operand" "")
3025 (match_operand:SI 2 "const_int_operand" "")
3026 (match_operand:SI 3 "const_int_operand" "")))]
3027 ""
3028 "
3029 {
3030 /* Do not handle 16/8 bit structures that fit in HI/QI modes directly, since
3031 the (SUBREG:SI (REG:HI xxx)) that is otherwise generated can confuse the
3032 compiler if the address of the structure is taken later. */
3033 if (GET_CODE (operands[0]) == SUBREG
3034 && (GET_MODE_SIZE (GET_MODE (SUBREG_REG (operands[0]))) < UNITS_PER_WORD))
3035 FAIL;
3036
3037 if (TARGET_POWERPC64 && GET_MODE (operands[1]) == DImode)
3038 emit_insn (gen_extzvdi (operands[0], operands[1], operands[2], operands[3]));
3039 else
3040 emit_insn (gen_extzvsi (operands[0], operands[1], operands[2], operands[3]));
3041 DONE;
3042 }")
3043
3044 (define_insn "extzvsi"
3045 [(set (match_operand:SI 0 "gpc_reg_operand" "=r")
3046 (zero_extract:SI (match_operand:SI 1 "gpc_reg_operand" "r")
3047 (match_operand:SI 2 "const_int_operand" "i")
3048 (match_operand:SI 3 "const_int_operand" "i")))]
3049 ""
3050 "*
3051 {
3052 int start = INTVAL (operands[3]) & 31;
3053 int size = INTVAL (operands[2]) & 31;
3054
3055 if (start + size >= 32)
3056 operands[3] = const0_rtx;
3057 else
3058 operands[3] = GEN_INT (start + size);
3059 return \"{rlinm|rlwinm} %0,%1,%3,%s2,31\";
3060 }")
3061
3062 (define_insn "*extzvsi_internal1"
3063 [(set (match_operand:CC 0 "cc_reg_operand" "=x,?y")
3064 (compare:CC (zero_extract:SI (match_operand:SI 1 "gpc_reg_operand" "r,r")
3065 (match_operand:SI 2 "const_int_operand" "i,i")
3066 (match_operand:SI 3 "const_int_operand" "i,i"))
3067 (const_int 0)))
3068 (clobber (match_scratch:SI 4 "=r,r"))]
3069 ""
3070 "*
3071 {
3072 int start = INTVAL (operands[3]) & 31;
3073 int size = INTVAL (operands[2]) & 31;
3074
3075 /* Force split for non-cc0 compare. */
3076 if (which_alternative == 1)
3077 return \"#\";
3078
3079 /* If the bit-field being tested fits in the upper or lower half of a
3080 word, it is possible to use andiu. or andil. to test it. This is
3081 useful because the condition register set-use delay is smaller for
3082 andi[ul]. than for rlinm. This doesn't work when the starting bit
3083 position is 0 because the LT and GT bits may be set wrong. */
3084
3085 if ((start > 0 && start + size <= 16) || start >= 16)
3086 {
3087 operands[3] = GEN_INT (((1 << (16 - (start & 15)))
3088 - (1 << (16 - (start & 15) - size))));
3089 if (start < 16)
3090 return \"{andiu.|andis.} %4,%1,%3\";
3091 else
3092 return \"{andil.|andi.} %4,%1,%3\";
3093 }
3094
3095 if (start + size >= 32)
3096 operands[3] = const0_rtx;
3097 else
3098 operands[3] = GEN_INT (start + size);
3099 return \"{rlinm.|rlwinm.} %4,%1,%3,%s2,31\";
3100 }"
3101 [(set_attr "type" "compare")
3102 (set_attr "length" "4,8")])
3103
3104 (define_split
3105 [(set (match_operand:CC 0 "cc_reg_not_cr0_operand" "")
3106 (compare:CC (zero_extract:SI (match_operand:SI 1 "gpc_reg_operand" "")
3107 (match_operand:SI 2 "const_int_operand" "")
3108 (match_operand:SI 3 "const_int_operand" ""))
3109 (const_int 0)))
3110 (clobber (match_scratch:SI 4 ""))]
3111 "reload_completed"
3112 [(set (match_dup 4)
3113 (zero_extract:SI (match_dup 1) (match_dup 2)
3114 (match_dup 3)))
3115 (set (match_dup 0)
3116 (compare:CC (match_dup 4)
3117 (const_int 0)))]
3118 "")
3119
3120 (define_insn "*extzvsi_internal2"
3121 [(set (match_operand:CC 4 "cc_reg_operand" "=x,?y")
3122 (compare:CC (zero_extract:SI (match_operand:SI 1 "gpc_reg_operand" "r,r")
3123 (match_operand:SI 2 "const_int_operand" "i,i")
3124 (match_operand:SI 3 "const_int_operand" "i,i"))
3125 (const_int 0)))
3126 (set (match_operand:SI 0 "gpc_reg_operand" "=r,r")
3127 (zero_extract:SI (match_dup 1) (match_dup 2) (match_dup 3)))]
3128 ""
3129 "*
3130 {
3131 int start = INTVAL (operands[3]) & 31;
3132 int size = INTVAL (operands[2]) & 31;
3133
3134 /* Force split for non-cc0 compare. */
3135 if (which_alternative == 1)
3136 return \"#\";
3137
3138 /* Since we are using the output value, we can't ignore any need for
3139 a shift. The bit-field must end at the LSB. */
3140 if (start >= 16 && start + size == 32)
3141 {
3142 operands[3] = GEN_INT ((1 << size) - 1);
3143 return \"{andil.|andi.} %0,%1,%3\";
3144 }
3145
3146 if (start + size >= 32)
3147 operands[3] = const0_rtx;
3148 else
3149 operands[3] = GEN_INT (start + size);
3150 return \"{rlinm.|rlwinm.} %0,%1,%3,%s2,31\";
3151 }"
3152 [(set_attr "type" "compare")
3153 (set_attr "length" "4,8")])
3154
3155 (define_split
3156 [(set (match_operand:CC 4 "cc_reg_not_cr0_operand" "")
3157 (compare:CC (zero_extract:SI (match_operand:SI 1 "gpc_reg_operand" "")
3158 (match_operand:SI 2 "const_int_operand" "")
3159 (match_operand:SI 3 "const_int_operand" ""))
3160 (const_int 0)))
3161 (set (match_operand:SI 0 "gpc_reg_operand" "")
3162 (zero_extract:SI (match_dup 1) (match_dup 2) (match_dup 3)))]
3163 "reload_completed"
3164 [(set (match_dup 0)
3165 (zero_extract:SI (match_dup 1) (match_dup 2) (match_dup 3)))
3166 (set (match_dup 4)
3167 (compare:CC (match_dup 0)
3168 (const_int 0)))]
3169 "")
3170
3171 (define_insn "extzvdi"
3172 [(set (match_operand:DI 0 "gpc_reg_operand" "=r")
3173 (zero_extract:DI (match_operand:DI 1 "gpc_reg_operand" "r")
3174 (match_operand:SI 2 "const_int_operand" "i")
3175 (match_operand:SI 3 "const_int_operand" "i")))]
3176 "TARGET_POWERPC64"
3177 "*
3178 {
3179 int start = INTVAL (operands[3]) & 63;
3180 int size = INTVAL (operands[2]) & 63;
3181
3182 if (start + size >= 64)
3183 operands[3] = const0_rtx;
3184 else
3185 operands[3] = GEN_INT (start + size);
3186 operands[2] = GEN_INT (64 - size);
3187 return \"rldicl %0,%1,%3,%2\";
3188 }")
3189
3190 (define_insn "*extzvdi_internal1"
3191 [(set (match_operand:CC 0 "gpc_reg_operand" "=x")
3192 (compare:CC (zero_extract:DI (match_operand:DI 1 "gpc_reg_operand" "r")
3193 (match_operand:SI 2 "const_int_operand" "i")
3194 (match_operand:SI 3 "const_int_operand" "i"))
3195 (const_int 0)))
3196 (clobber (match_scratch:DI 4 "=r"))]
3197 "TARGET_POWERPC64"
3198 "*
3199 {
3200 int start = INTVAL (operands[3]) & 63;
3201 int size = INTVAL (operands[2]) & 63;
3202
3203 if (start + size >= 64)
3204 operands[3] = const0_rtx;
3205 else
3206 operands[3] = GEN_INT (start + size);
3207 operands[2] = GEN_INT (64 - size);
3208 return \"rldicl. %4,%1,%3,%2\";
3209 }")
3210
3211 (define_insn "*extzvdi_internal2"
3212 [(set (match_operand:CC 4 "gpc_reg_operand" "=x")
3213 (compare:CC (zero_extract:DI (match_operand:DI 1 "gpc_reg_operand" "r")
3214 (match_operand:SI 2 "const_int_operand" "i")
3215 (match_operand:SI 3 "const_int_operand" "i"))
3216 (const_int 0)))
3217 (set (match_operand:DI 0 "gpc_reg_operand" "=r")
3218 (zero_extract:DI (match_dup 1) (match_dup 2) (match_dup 3)))]
3219 "TARGET_POWERPC64"
3220 "*
3221 {
3222 int start = INTVAL (operands[3]) & 63;
3223 int size = INTVAL (operands[2]) & 63;
3224
3225 if (start + size >= 64)
3226 operands[3] = const0_rtx;
3227 else
3228 operands[3] = GEN_INT (start + size);
3229 operands[2] = GEN_INT (64 - size);
3230 return \"rldicl. %0,%1,%3,%2\";
3231 }")
3232
3233 (define_insn "rotlsi3"
3234 [(set (match_operand:SI 0 "gpc_reg_operand" "=r")
3235 (rotate:SI (match_operand:SI 1 "gpc_reg_operand" "r")
3236 (match_operand:SI 2 "reg_or_cint_operand" "ri")))]
3237 ""
3238 "{rl%I2nm|rlw%I2nm} %0,%1,%h2,0xffffffff")
3239
3240 (define_insn "*rotlsi3_internal2"
3241 [(set (match_operand:CC 0 "cc_reg_operand" "=x,?y")
3242 (compare:CC (rotate:SI (match_operand:SI 1 "gpc_reg_operand" "r,r")
3243 (match_operand:SI 2 "reg_or_cint_operand" "ri,ri"))
3244 (const_int 0)))
3245 (clobber (match_scratch:SI 3 "=r,r"))]
3246 ""
3247 "@
3248 {rl%I2nm.|rlw%I2nm.} %3,%1,%h2,0xffffffff
3249 #"
3250 [(set_attr "type" "delayed_compare")
3251 (set_attr "length" "4,8")])
3252
3253 (define_split
3254 [(set (match_operand:CC 0 "cc_reg_not_cr0_operand" "")
3255 (compare:CC (rotate:SI (match_operand:SI 1 "gpc_reg_operand" "")
3256 (match_operand:SI 2 "reg_or_cint_operand" ""))
3257 (const_int 0)))
3258 (clobber (match_scratch:SI 3 ""))]
3259 "reload_completed"
3260 [(set (match_dup 3)
3261 (rotate:SI (match_dup 1) (match_dup 2)))
3262 (set (match_dup 0)
3263 (compare:CC (match_dup 3)
3264 (const_int 0)))]
3265 "")
3266
3267 (define_insn "*rotlsi3_internal3"
3268 [(set (match_operand:CC 3 "cc_reg_operand" "=x,?y")
3269 (compare:CC (rotate:SI (match_operand:SI 1 "gpc_reg_operand" "r,r")
3270 (match_operand:SI 2 "reg_or_cint_operand" "ri,ri"))
3271 (const_int 0)))
3272 (set (match_operand:SI 0 "gpc_reg_operand" "=r,r")
3273 (rotate:SI (match_dup 1) (match_dup 2)))]
3274 ""
3275 "@
3276 {rl%I2nm.|rlw%I2nm.} %0,%1,%h2,0xffffffff
3277 #"
3278 [(set_attr "type" "delayed_compare")
3279 (set_attr "length" "4,8")])
3280
3281 (define_split
3282 [(set (match_operand:CC 3 "cc_reg_not_cr0_operand" "")
3283 (compare:CC (rotate:SI (match_operand:SI 1 "gpc_reg_operand" "")
3284 (match_operand:SI 2 "reg_or_cint_operand" ""))
3285 (const_int 0)))
3286 (set (match_operand:SI 0 "gpc_reg_operand" "")
3287 (rotate:SI (match_dup 1) (match_dup 2)))]
3288 "reload_completed"
3289 [(set (match_dup 0)
3290 (rotate:SI (match_dup 1) (match_dup 2)))
3291 (set (match_dup 3)
3292 (compare:CC (match_dup 0)
3293 (const_int 0)))]
3294 "")
3295
3296 (define_insn "*rotlsi3_internal4"
3297 [(set (match_operand:SI 0 "gpc_reg_operand" "=r")
3298 (and:SI (rotate:SI (match_operand:SI 1 "gpc_reg_operand" "r")
3299 (match_operand:SI 2 "reg_or_cint_operand" "ri"))
3300 (match_operand:SI 3 "mask_operand" "n")))]
3301 ""
3302 "{rl%I2nm|rlw%I2nm} %0,%1,%h2,%m3,%M3")
3303
3304 (define_insn "*rotlsi3_internal5"
3305 [(set (match_operand:CC 0 "cc_reg_operand" "=x,?y")
3306 (compare:CC (and:SI
3307 (rotate:SI (match_operand:SI 1 "gpc_reg_operand" "r,r")
3308 (match_operand:SI 2 "reg_or_cint_operand" "ri,ri"))
3309 (match_operand:SI 3 "mask_operand" "n,n"))
3310 (const_int 0)))
3311 (clobber (match_scratch:SI 4 "=r,r"))]
3312 ""
3313 "@
3314 {rl%I2nm.|rlw%I2nm.} %4,%1,%h2,%m3,%M3
3315 #"
3316 [(set_attr "type" "delayed_compare")
3317 (set_attr "length" "4,8")])
3318
3319 (define_split
3320 [(set (match_operand:CC 0 "cc_reg_not_cr0_operand" "")
3321 (compare:CC (and:SI
3322 (rotate:SI (match_operand:SI 1 "gpc_reg_operand" "")
3323 (match_operand:SI 2 "reg_or_cint_operand" ""))
3324 (match_operand:SI 3 "mask_operand" ""))
3325 (const_int 0)))
3326 (clobber (match_scratch:SI 4 ""))]
3327 "reload_completed"
3328 [(set (match_dup 4)
3329 (and:SI (rotate:SI (match_dup 1)
3330 (match_dup 2))
3331 (match_dup 3)))
3332 (set (match_dup 0)
3333 (compare:CC (match_dup 4)
3334 (const_int 0)))]
3335 "")
3336
3337 (define_insn "*rotlsi3_internal6"
3338 [(set (match_operand:CC 4 "cc_reg_operand" "=x,?y")
3339 (compare:CC (and:SI
3340 (rotate:SI (match_operand:SI 1 "gpc_reg_operand" "r,r")
3341 (match_operand:SI 2 "reg_or_cint_operand" "ri,ri"))
3342 (match_operand:SI 3 "mask_operand" "n,n"))
3343 (const_int 0)))
3344 (set (match_operand:SI 0 "gpc_reg_operand" "=r,r")
3345 (and:SI (rotate:SI (match_dup 1) (match_dup 2)) (match_dup 3)))]
3346 ""
3347 "@
3348 {rl%I2nm.|rlw%I2nm.} %0,%1,%h2,%m3,%M3
3349 #"
3350 [(set_attr "type" "delayed_compare")
3351 (set_attr "length" "4,8")])
3352
3353 (define_split
3354 [(set (match_operand:CC 4 "cc_reg_not_cr0_operand" "")
3355 (compare:CC (and:SI
3356 (rotate:SI (match_operand:SI 1 "gpc_reg_operand" "")
3357 (match_operand:SI 2 "reg_or_cint_operand" ""))
3358 (match_operand:SI 3 "mask_operand" ""))
3359 (const_int 0)))
3360 (set (match_operand:SI 0 "gpc_reg_operand" "")
3361 (and:SI (rotate:SI (match_dup 1) (match_dup 2)) (match_dup 3)))]
3362 "reload_completed"
3363 [(set (match_dup 0)
3364 (and:SI (rotate:SI (match_dup 1) (match_dup 2)) (match_dup 3)))
3365 (set (match_dup 4)
3366 (compare:CC (match_dup 0)
3367 (const_int 0)))]
3368 "")
3369
3370 (define_insn "*rotlsi3_internal7"
3371 [(set (match_operand:SI 0 "gpc_reg_operand" "=r")
3372 (zero_extend:SI
3373 (subreg:QI
3374 (rotate:SI (match_operand:SI 1 "gpc_reg_operand" "r")
3375 (match_operand:SI 2 "reg_or_cint_operand" "ri")) 0)))]
3376 ""
3377 "{rl%I2nm|rlw%I2nm} %0,%1,%h2,0xff")
3378
3379 (define_insn "*rotlsi3_internal8"
3380 [(set (match_operand:CC 0 "cc_reg_operand" "=x,?y")
3381 (compare:CC (zero_extend:SI
3382 (subreg:QI
3383 (rotate:SI (match_operand:SI 1 "gpc_reg_operand" "r,r")
3384 (match_operand:SI 2 "reg_or_cint_operand" "ri,ri")) 0))
3385 (const_int 0)))
3386 (clobber (match_scratch:SI 3 "=r,r"))]
3387 ""
3388 "@
3389 {rl%I2nm.|rlw%I2nm.} %3,%1,%h2,0xff
3390 #"
3391 [(set_attr "type" "delayed_compare")
3392 (set_attr "length" "4,8")])
3393
3394 (define_split
3395 [(set (match_operand:CC 0 "cc_reg_not_cr0_operand" "")
3396 (compare:CC (zero_extend:SI
3397 (subreg:QI
3398 (rotate:SI (match_operand:SI 1 "gpc_reg_operand" "")
3399 (match_operand:SI 2 "reg_or_cint_operand" "")) 0))
3400 (const_int 0)))
3401 (clobber (match_scratch:SI 3 ""))]
3402 "reload_completed"
3403 [(set (match_dup 3)
3404 (zero_extend:SI (subreg:QI
3405 (rotate:SI (match_dup 1)
3406 (match_dup 2)) 0)))
3407 (set (match_dup 0)
3408 (compare:CC (match_dup 3)
3409 (const_int 0)))]
3410 "")
3411
3412 (define_insn "*rotlsi3_internal9"
3413 [(set (match_operand:CC 3 "cc_reg_operand" "=x,?y")
3414 (compare:CC (zero_extend:SI
3415 (subreg:QI
3416 (rotate:SI (match_operand:SI 1 "gpc_reg_operand" "r,r")
3417 (match_operand:SI 2 "reg_or_cint_operand" "ri,ri")) 0))
3418 (const_int 0)))
3419 (set (match_operand:SI 0 "gpc_reg_operand" "=r,r")
3420 (zero_extend:SI (subreg:QI (rotate:SI (match_dup 1) (match_dup 2)) 0)))]
3421 ""
3422 "@
3423 {rl%I2nm.|rlw%I2nm.} %0,%1,%h2,0xff
3424 #"
3425 [(set_attr "type" "delayed_compare")
3426 (set_attr "length" "4,8")])
3427
3428 (define_split
3429 [(set (match_operand:CC 3 "cc_reg_not_cr0_operand" "")
3430 (compare:CC (zero_extend:SI
3431 (subreg:QI
3432 (rotate:SI (match_operand:SI 1 "gpc_reg_operand" "")
3433 (match_operand:SI 2 "reg_or_cint_operand" "")) 0))
3434 (const_int 0)))
3435 (set (match_operand:SI 0 "gpc_reg_operand" "")
3436 (zero_extend:SI (subreg:QI (rotate:SI (match_dup 1) (match_dup 2)) 0)))]
3437 "reload_completed"
3438 [(set (match_dup 0)
3439 (zero_extend:SI (subreg:QI (rotate:SI (match_dup 1) (match_dup 2)) 0)))
3440 (set (match_dup 3)
3441 (compare:CC (match_dup 0)
3442 (const_int 0)))]
3443 "")
3444
3445 (define_insn "*rotlsi3_internal10"
3446 [(set (match_operand:SI 0 "gpc_reg_operand" "=r")
3447 (zero_extend:SI
3448 (subreg:HI
3449 (rotate:SI (match_operand:SI 1 "gpc_reg_operand" "r")
3450 (match_operand:SI 2 "reg_or_cint_operand" "ri")) 0)))]
3451 ""
3452 "{rl%I2nm|rlw%I2nm} %0,%1,%h2,0xffff")
3453
3454 (define_insn "*rotlsi3_internal11"
3455 [(set (match_operand:CC 0 "cc_reg_operand" "=x,?y")
3456 (compare:CC (zero_extend:SI
3457 (subreg:HI
3458 (rotate:SI (match_operand:SI 1 "gpc_reg_operand" "r,r")
3459 (match_operand:SI 2 "reg_or_cint_operand" "ri,ri")) 0))
3460 (const_int 0)))
3461 (clobber (match_scratch:SI 3 "=r,r"))]
3462 ""
3463 "@
3464 {rl%I2nm.|rlw%I2nm.} %3,%1,%h2,0xffff
3465 #"
3466 [(set_attr "type" "delayed_compare")
3467 (set_attr "length" "4,8")])
3468
3469 (define_split
3470 [(set (match_operand:CC 0 "cc_reg_not_cr0_operand" "")
3471 (compare:CC (zero_extend:SI
3472 (subreg:HI
3473 (rotate:SI (match_operand:SI 1 "gpc_reg_operand" "")
3474 (match_operand:SI 2 "reg_or_cint_operand" "")) 0))
3475 (const_int 0)))
3476 (clobber (match_scratch:SI 3 ""))]
3477 "reload_completed"
3478 [(set (match_dup 3)
3479 (zero_extend:SI (subreg:HI
3480 (rotate:SI (match_dup 1)
3481 (match_dup 2)) 0)))
3482 (set (match_dup 0)
3483 (compare:CC (match_dup 3)
3484 (const_int 0)))]
3485 "")
3486
3487 (define_insn "*rotlsi3_internal12"
3488 [(set (match_operand:CC 3 "cc_reg_operand" "=x,?y")
3489 (compare:CC (zero_extend:SI
3490 (subreg:HI
3491 (rotate:SI (match_operand:SI 1 "gpc_reg_operand" "r,r")
3492 (match_operand:SI 2 "reg_or_cint_operand" "ri,ri")) 0))
3493 (const_int 0)))
3494 (set (match_operand:SI 0 "gpc_reg_operand" "=r,r")
3495 (zero_extend:SI (subreg:HI (rotate:SI (match_dup 1) (match_dup 2)) 0)))]
3496 ""
3497 "@
3498 {rl%I2nm.|rlw%I2nm.} %0,%1,%h2,0xffff
3499 #"
3500 [(set_attr "type" "delayed_compare")
3501 (set_attr "length" "4,8")])
3502
3503 (define_split
3504 [(set (match_operand:CC 3 "cc_reg_not_cr0_operand" "")
3505 (compare:CC (zero_extend:SI
3506 (subreg:HI
3507 (rotate:SI (match_operand:SI 1 "gpc_reg_operand" "")
3508 (match_operand:SI 2 "reg_or_cint_operand" "")) 0))
3509 (const_int 0)))
3510 (set (match_operand:SI 0 "gpc_reg_operand" "")
3511 (zero_extend:SI (subreg:HI (rotate:SI (match_dup 1) (match_dup 2)) 0)))]
3512 "reload_completed"
3513 [(set (match_dup 0)
3514 (zero_extend:SI (subreg:HI (rotate:SI (match_dup 1) (match_dup 2)) 0)))
3515 (set (match_dup 3)
3516 (compare:CC (match_dup 0)
3517 (const_int 0)))]
3518 "")
3519
3520 ;; Note that we use "sle." instead of "sl." so that we can set
3521 ;; SHIFT_COUNT_TRUNCATED.
3522
3523 (define_expand "ashlsi3"
3524 [(use (match_operand:SI 0 "gpc_reg_operand" ""))
3525 (use (match_operand:SI 1 "gpc_reg_operand" ""))
3526 (use (match_operand:SI 2 "reg_or_cint_operand" ""))]
3527 ""
3528 "
3529 {
3530 if (TARGET_POWER)
3531 emit_insn (gen_ashlsi3_power (operands[0], operands[1], operands[2]));
3532 else
3533 emit_insn (gen_ashlsi3_no_power (operands[0], operands[1], operands[2]));
3534 DONE;
3535 }")
3536
3537 (define_insn "ashlsi3_power"
3538 [(set (match_operand:SI 0 "gpc_reg_operand" "=r,r")
3539 (ashift:SI (match_operand:SI 1 "gpc_reg_operand" "r,r")
3540 (match_operand:SI 2 "reg_or_cint_operand" "r,i")))
3541 (clobber (match_scratch:SI 3 "=q,X"))]
3542 "TARGET_POWER"
3543 "@
3544 sle %0,%1,%2
3545 {sli|slwi} %0,%1,%h2")
3546
3547 (define_insn "ashlsi3_no_power"
3548 [(set (match_operand:SI 0 "gpc_reg_operand" "=r")
3549 (ashift:SI (match_operand:SI 1 "gpc_reg_operand" "r")
3550 (match_operand:SI 2 "reg_or_cint_operand" "ri")))]
3551 "! TARGET_POWER"
3552 "{sl|slw}%I2 %0,%1,%h2")
3553
3554 (define_insn ""
3555 [(set (match_operand:CC 0 "cc_reg_operand" "=x,x,?y,?y")
3556 (compare:CC (ashift:SI (match_operand:SI 1 "gpc_reg_operand" "r,r,r,r")
3557 (match_operand:SI 2 "reg_or_cint_operand" "r,i,r,i"))
3558 (const_int 0)))
3559 (clobber (match_scratch:SI 3 "=r,r,r,r"))
3560 (clobber (match_scratch:SI 4 "=q,X,q,X"))]
3561 "TARGET_POWER"
3562 "@
3563 sle. %3,%1,%2
3564 {sli.|slwi.} %3,%1,%h2
3565 #
3566 #"
3567 [(set_attr "type" "delayed_compare")
3568 (set_attr "length" "4,4,8,8")])
3569
3570 (define_split
3571 [(set (match_operand:CC 0 "cc_reg_not_cr0_operand" "")
3572 (compare:CC (ashift:SI (match_operand:SI 1 "gpc_reg_operand" "")
3573 (match_operand:SI 2 "reg_or_cint_operand" ""))
3574 (const_int 0)))
3575 (clobber (match_scratch:SI 3 ""))
3576 (clobber (match_scratch:SI 4 ""))]
3577 "TARGET_POWER && reload_completed"
3578 [(parallel [(set (match_dup 3)
3579 (ashift:SI (match_dup 1) (match_dup 2)))
3580 (clobber (match_dup 4))])
3581 (set (match_dup 0)
3582 (compare:CC (match_dup 3)
3583 (const_int 0)))]
3584 "")
3585
3586 (define_insn ""
3587 [(set (match_operand:CC 0 "cc_reg_operand" "=x,?y")
3588 (compare:CC (ashift:SI (match_operand:SI 1 "gpc_reg_operand" "r,r")
3589 (match_operand:SI 2 "reg_or_cint_operand" "ri,ri"))
3590 (const_int 0)))
3591 (clobber (match_scratch:SI 3 "=r,r"))]
3592 "! TARGET_POWER && ! TARGET_POWERPC64"
3593 "@
3594 {sl|slw}%I2. %3,%1,%h2
3595 #"
3596 [(set_attr "type" "delayed_compare")
3597 (set_attr "length" "4,8")])
3598
3599 (define_split
3600 [(set (match_operand:CC 0 "cc_reg_not_cr0_operand" "")
3601 (compare:CC (ashift:SI (match_operand:SI 1 "gpc_reg_operand" "")
3602 (match_operand:SI 2 "reg_or_cint_operand" ""))
3603 (const_int 0)))
3604 (clobber (match_scratch:SI 3 ""))]
3605 "! TARGET_POWER && ! TARGET_POWERPC64 && reload_completed"
3606 [(set (match_dup 3)
3607 (ashift:SI (match_dup 1) (match_dup 2)))
3608 (set (match_dup 0)
3609 (compare:CC (match_dup 3)
3610 (const_int 0)))]
3611 "")
3612
3613 (define_insn ""
3614 [(set (match_operand:CC 3 "cc_reg_operand" "=x,x,?y,?y")
3615 (compare:CC (ashift:SI (match_operand:SI 1 "gpc_reg_operand" "r,r,r,r")
3616 (match_operand:SI 2 "reg_or_cint_operand" "r,i,r,i"))
3617 (const_int 0)))
3618 (set (match_operand:SI 0 "gpc_reg_operand" "=r,r,r,r")
3619 (ashift:SI (match_dup 1) (match_dup 2)))
3620 (clobber (match_scratch:SI 4 "=q,X,q,X"))]
3621 "TARGET_POWER"
3622 "@
3623 sle. %0,%1,%2
3624 {sli.|slwi.} %0,%1,%h2
3625 #
3626 #"
3627 [(set_attr "type" "delayed_compare")
3628 (set_attr "length" "4,4,8,8")])
3629
3630 (define_split
3631 [(set (match_operand:CC 3 "cc_reg_not_cr0_operand" "")
3632 (compare:CC (ashift:SI (match_operand:SI 1 "gpc_reg_operand" "")
3633 (match_operand:SI 2 "reg_or_cint_operand" ""))
3634 (const_int 0)))
3635 (set (match_operand:SI 0 "gpc_reg_operand" "")
3636 (ashift:SI (match_dup 1) (match_dup 2)))
3637 (clobber (match_scratch:SI 4 ""))]
3638 "TARGET_POWER && reload_completed"
3639 [(parallel [(set (match_dup 0)
3640 (ashift:SI (match_dup 1) (match_dup 2)))
3641 (clobber (match_dup 4))])
3642 (set (match_dup 3)
3643 (compare:CC (match_dup 0)
3644 (const_int 0)))]
3645 "")
3646
3647 (define_insn ""
3648 [(set (match_operand:CC 3 "cc_reg_operand" "=x,?y")
3649 (compare:CC (ashift:SI (match_operand:SI 1 "gpc_reg_operand" "r,r")
3650 (match_operand:SI 2 "reg_or_cint_operand" "ri,ri"))
3651 (const_int 0)))
3652 (set (match_operand:SI 0 "gpc_reg_operand" "=r,r")
3653 (ashift:SI (match_dup 1) (match_dup 2)))]
3654 "! TARGET_POWER && ! TARGET_POWERPC64"
3655 "@
3656 {sl|slw}%I2. %0,%1,%h2
3657 #"
3658 [(set_attr "type" "delayed_compare")
3659 (set_attr "length" "4,8")])
3660
3661 (define_split
3662 [(set (match_operand:CC 3 "cc_reg_not_cr0_operand" "")
3663 (compare:CC (ashift:SI (match_operand:SI 1 "gpc_reg_operand" "")
3664 (match_operand:SI 2 "reg_or_cint_operand" ""))
3665 (const_int 0)))
3666 (set (match_operand:SI 0 "gpc_reg_operand" "")
3667 (ashift:SI (match_dup 1) (match_dup 2)))]
3668 "! TARGET_POWER && ! TARGET_POWERPC64 && reload_completed"
3669 [(set (match_dup 0)
3670 (ashift:SI (match_dup 1) (match_dup 2)))
3671 (set (match_dup 3)
3672 (compare:CC (match_dup 0)
3673 (const_int 0)))]
3674 "")
3675
3676 (define_insn ""
3677 [(set (match_operand:SI 0 "gpc_reg_operand" "=r")
3678 (and:SI (ashift:SI (match_operand:SI 1 "gpc_reg_operand" "r")
3679 (match_operand:SI 2 "const_int_operand" "i"))
3680 (match_operand:SI 3 "mask_operand" "n")))]
3681 "includes_lshift_p (operands[2], operands[3])"
3682 "{rlinm|rlwinm} %0,%1,%h2,%m3,%M3")
3683
3684 (define_insn ""
3685 [(set (match_operand:CC 0 "cc_reg_operand" "=x,?y")
3686 (compare:CC
3687 (and:SI (ashift:SI (match_operand:SI 1 "gpc_reg_operand" "r,r")
3688 (match_operand:SI 2 "const_int_operand" "i,i"))
3689 (match_operand:SI 3 "mask_operand" "n,n"))
3690 (const_int 0)))
3691 (clobber (match_scratch:SI 4 "=r,r"))]
3692 "includes_lshift_p (operands[2], operands[3])"
3693 "@
3694 {rlinm.|rlwinm.} %4,%1,%h2,%m3,%M3
3695 #"
3696 [(set_attr "type" "delayed_compare")
3697 (set_attr "length" "4,8")])
3698
3699 (define_split
3700 [(set (match_operand:CC 0 "cc_reg_not_cr0_operand" "")
3701 (compare:CC
3702 (and:SI (ashift:SI (match_operand:SI 1 "gpc_reg_operand" "")
3703 (match_operand:SI 2 "const_int_operand" ""))
3704 (match_operand:SI 3 "mask_operand" ""))
3705 (const_int 0)))
3706 (clobber (match_scratch:SI 4 ""))]
3707 "includes_lshift_p (operands[2], operands[3]) && reload_completed"
3708 [(set (match_dup 4)
3709 (and:SI (ashift:SI (match_dup 1) (match_dup 2))
3710 (match_dup 3)))
3711 (set (match_dup 0)
3712 (compare:CC (match_dup 4)
3713 (const_int 0)))]
3714 "")
3715
3716 (define_insn ""
3717 [(set (match_operand:CC 4 "cc_reg_operand" "=x,?y")
3718 (compare:CC
3719 (and:SI (ashift:SI (match_operand:SI 1 "gpc_reg_operand" "r,r")
3720 (match_operand:SI 2 "const_int_operand" "i,i"))
3721 (match_operand:SI 3 "mask_operand" "n,n"))
3722 (const_int 0)))
3723 (set (match_operand:SI 0 "gpc_reg_operand" "=r,r")
3724 (and:SI (ashift:SI (match_dup 1) (match_dup 2)) (match_dup 3)))]
3725 "includes_lshift_p (operands[2], operands[3])"
3726 "@
3727 {rlinm.|rlwinm.} %0,%1,%h2,%m3,%M3
3728 #"
3729 [(set_attr "type" "delayed_compare")
3730 (set_attr "length" "4,8")])
3731
3732 (define_split
3733 [(set (match_operand:CC 4 "cc_reg_not_cr0_operand" "")
3734 (compare:CC
3735 (and:SI (ashift:SI (match_operand:SI 1 "gpc_reg_operand" "")
3736 (match_operand:SI 2 "const_int_operand" ""))
3737 (match_operand:SI 3 "mask_operand" ""))
3738 (const_int 0)))
3739 (set (match_operand:SI 0 "gpc_reg_operand" "")
3740 (and:SI (ashift:SI (match_dup 1) (match_dup 2)) (match_dup 3)))]
3741 "includes_lshift_p (operands[2], operands[3]) && reload_completed"
3742 [(set (match_dup 0)
3743 (and:SI (ashift:SI (match_dup 1) (match_dup 2)) (match_dup 3)))
3744 (set (match_dup 4)
3745 (compare:CC (match_dup 0)
3746 (const_int 0)))]
3747 "")
3748
3749 ;; The AIX assembler mis-handles "sri x,x,0", so write that case as
3750 ;; "sli x,x,0".
3751 (define_expand "lshrsi3"
3752 [(use (match_operand:SI 0 "gpc_reg_operand" ""))
3753 (use (match_operand:SI 1 "gpc_reg_operand" ""))
3754 (use (match_operand:SI 2 "reg_or_cint_operand" ""))]
3755 ""
3756 "
3757 {
3758 if (TARGET_POWER)
3759 emit_insn (gen_lshrsi3_power (operands[0], operands[1], operands[2]));
3760 else
3761 emit_insn (gen_lshrsi3_no_power (operands[0], operands[1], operands[2]));
3762 DONE;
3763 }")
3764
3765 (define_insn "lshrsi3_power"
3766 [(set (match_operand:SI 0 "gpc_reg_operand" "=r,r,r")
3767 (lshiftrt:SI (match_operand:SI 1 "gpc_reg_operand" "r,r,r")
3768 (match_operand:SI 2 "reg_or_cint_operand" "r,O,i")))
3769 (clobber (match_scratch:SI 3 "=q,X,X"))]
3770 "TARGET_POWER"
3771 "@
3772 sre %0,%1,%2
3773 mr %0,%1
3774 {s%A2i|s%A2wi} %0,%1,%h2")
3775
3776 (define_insn "lshrsi3_no_power"
3777 [(set (match_operand:SI 0 "gpc_reg_operand" "=r,r")
3778 (lshiftrt:SI (match_operand:SI 1 "gpc_reg_operand" "r,r")
3779 (match_operand:SI 2 "reg_or_cint_operand" "O,ri")))]
3780 "! TARGET_POWER"
3781 "@
3782 mr %0,%1
3783 {sr|srw}%I2 %0,%1,%h2")
3784
3785 (define_insn ""
3786 [(set (match_operand:CC 0 "cc_reg_operand" "=x,x,x,?y,?y,?y")
3787 (compare:CC (lshiftrt:SI (match_operand:SI 1 "gpc_reg_operand" "r,r,r,r,r,r")
3788 (match_operand:SI 2 "reg_or_cint_operand" "r,O,i,r,O,i"))
3789 (const_int 0)))
3790 (clobber (match_scratch:SI 3 "=r,X,r,r,X,r"))
3791 (clobber (match_scratch:SI 4 "=q,X,X,q,X,X"))]
3792 "TARGET_POWER"
3793 "@
3794 sre. %3,%1,%2
3795 mr. %1,%1
3796 {s%A2i.|s%A2wi.} %3,%1,%h2
3797 #
3798 #
3799 #"
3800 [(set_attr "type" "delayed_compare")
3801 (set_attr "length" "4,4,4,8,8,8")])
3802
3803 (define_split
3804 [(set (match_operand:CC 0 "cc_reg_not_cr0_operand" "")
3805 (compare:CC (lshiftrt:SI (match_operand:SI 1 "gpc_reg_operand" "")
3806 (match_operand:SI 2 "reg_or_cint_operand" ""))
3807 (const_int 0)))
3808 (clobber (match_scratch:SI 3 ""))
3809 (clobber (match_scratch:SI 4 ""))]
3810 "TARGET_POWER && reload_completed"
3811 [(parallel [(set (match_dup 3)
3812 (lshiftrt:SI (match_dup 1) (match_dup 2)))
3813 (clobber (match_dup 4))])
3814 (set (match_dup 0)
3815 (compare:CC (match_dup 3)
3816 (const_int 0)))]
3817 "")
3818
3819 (define_insn ""
3820 [(set (match_operand:CC 0 "cc_reg_operand" "=x,x,?y,?y")
3821 (compare:CC (lshiftrt:SI (match_operand:SI 1 "gpc_reg_operand" "r,r,r,r")
3822 (match_operand:SI 2 "reg_or_cint_operand" "O,ri,O,ri"))
3823 (const_int 0)))
3824 (clobber (match_scratch:SI 3 "=X,r,X,r"))]
3825 "! TARGET_POWER && ! TARGET_POWERPC64"
3826 "@
3827 mr. %1,%1
3828 {sr|srw}%I2. %3,%1,%h2
3829 #
3830 #"
3831 [(set_attr "type" "delayed_compare")
3832 (set_attr "length" "4,4,8,8")])
3833
3834 (define_split
3835 [(set (match_operand:CC 0 "cc_reg_not_cr0_operand" "")
3836 (compare:CC (lshiftrt:SI (match_operand:SI 1 "gpc_reg_operand" "")
3837 (match_operand:SI 2 "reg_or_cint_operand" ""))
3838 (const_int 0)))
3839 (clobber (match_scratch:SI 3 ""))]
3840 "! TARGET_POWER && ! TARGET_POWERPC64 && reload_completed"
3841 [(set (match_dup 3)
3842 (lshiftrt:SI (match_dup 1) (match_dup 2)))
3843 (set (match_dup 0)
3844 (compare:CC (match_dup 3)
3845 (const_int 0)))]
3846 "")
3847
3848 (define_insn ""
3849 [(set (match_operand:CC 3 "cc_reg_operand" "=x,x,x,?y,?y,?y")
3850 (compare:CC (lshiftrt:SI (match_operand:SI 1 "gpc_reg_operand" "r,r,r,r,r,r")
3851 (match_operand:SI 2 "reg_or_cint_operand" "r,O,i,r,O,i"))
3852 (const_int 0)))
3853 (set (match_operand:SI 0 "gpc_reg_operand" "=r,r,r,r,r,r")
3854 (lshiftrt:SI (match_dup 1) (match_dup 2)))
3855 (clobber (match_scratch:SI 4 "=q,X,X,q,X,X"))]
3856 "TARGET_POWER"
3857 "@
3858 sre. %0,%1,%2
3859 mr. %0,%1
3860 {s%A2i.|s%A2wi.} %0,%1,%h2
3861 #
3862 #
3863 #"
3864 [(set_attr "type" "delayed_compare")
3865 (set_attr "length" "4,4,4,8,8,8")])
3866
3867 (define_split
3868 [(set (match_operand:CC 3 "cc_reg_not_cr0_operand" "")
3869 (compare:CC (lshiftrt:SI (match_operand:SI 1 "gpc_reg_operand" "")
3870 (match_operand:SI 2 "reg_or_cint_operand" ""))
3871 (const_int 0)))
3872 (set (match_operand:SI 0 "gpc_reg_operand" "")
3873 (lshiftrt:SI (match_dup 1) (match_dup 2)))
3874 (clobber (match_scratch:SI 4 ""))]
3875 "TARGET_POWER && reload_completed"
3876 [(parallel [(set (match_dup 0)
3877 (lshiftrt:SI (match_dup 1) (match_dup 2)))
3878 (clobber (match_dup 4))])
3879 (set (match_dup 3)
3880 (compare:CC (match_dup 0)
3881 (const_int 0)))]
3882 "")
3883
3884 (define_insn ""
3885 [(set (match_operand:CC 3 "cc_reg_operand" "=x,x,?y,?y")
3886 (compare:CC (lshiftrt:SI (match_operand:SI 1 "gpc_reg_operand" "r,r,r,r")
3887 (match_operand:SI 2 "reg_or_cint_operand" "O,ri,O,ri"))
3888 (const_int 0)))
3889 (set (match_operand:SI 0 "gpc_reg_operand" "=r,r,r,r")
3890 (lshiftrt:SI (match_dup 1) (match_dup 2)))]
3891 "! TARGET_POWER && ! TARGET_POWERPC64"
3892 "@
3893 mr. %0,%1
3894 {sr|srw}%I2. %0,%1,%h2
3895 #
3896 #"
3897 [(set_attr "type" "delayed_compare")
3898 (set_attr "length" "4,4,8,8")])
3899
3900 (define_split
3901 [(set (match_operand:CC 3 "cc_reg_not_cr0_operand" "")
3902 (compare:CC (lshiftrt:SI (match_operand:SI 1 "gpc_reg_operand" "")
3903 (match_operand:SI 2 "reg_or_cint_operand" ""))
3904 (const_int 0)))
3905 (set (match_operand:SI 0 "gpc_reg_operand" "")
3906 (lshiftrt:SI (match_dup 1) (match_dup 2)))]
3907 "! TARGET_POWER && ! TARGET_POWERPC64 && reload_completed"
3908 [(set (match_dup 0)
3909 (lshiftrt:SI (match_dup 1) (match_dup 2)))
3910 (set (match_dup 3)
3911 (compare:CC (match_dup 0)
3912 (const_int 0)))]
3913 "")
3914
3915 (define_insn ""
3916 [(set (match_operand:SI 0 "gpc_reg_operand" "=r")
3917 (and:SI (lshiftrt:SI (match_operand:SI 1 "gpc_reg_operand" "r")
3918 (match_operand:SI 2 "const_int_operand" "i"))
3919 (match_operand:SI 3 "mask_operand" "n")))]
3920 "includes_rshift_p (operands[2], operands[3])"
3921 "{rlinm|rlwinm} %0,%1,%s2,%m3,%M3")
3922
3923 (define_insn ""
3924 [(set (match_operand:CC 0 "cc_reg_operand" "=x,?y")
3925 (compare:CC
3926 (and:SI (lshiftrt:SI (match_operand:SI 1 "gpc_reg_operand" "r,r")
3927 (match_operand:SI 2 "const_int_operand" "i,i"))
3928 (match_operand:SI 3 "mask_operand" "n,n"))
3929 (const_int 0)))
3930 (clobber (match_scratch:SI 4 "=r,r"))]
3931 "includes_rshift_p (operands[2], operands[3])"
3932 "@
3933 {rlinm.|rlwinm.} %4,%1,%s2,%m3,%M3
3934 #"
3935 [(set_attr "type" "delayed_compare")
3936 (set_attr "length" "4,8")])
3937
3938 (define_split
3939 [(set (match_operand:CC 0 "cc_reg_not_cr0_operand" "")
3940 (compare:CC
3941 (and:SI (lshiftrt:SI (match_operand:SI 1 "gpc_reg_operand" "")
3942 (match_operand:SI 2 "const_int_operand" ""))
3943 (match_operand:SI 3 "mask_operand" ""))
3944 (const_int 0)))
3945 (clobber (match_scratch:SI 4 ""))]
3946 "includes_rshift_p (operands[2], operands[3]) && reload_completed"
3947 [(set (match_dup 4)
3948 (and:SI (lshiftrt:SI (match_dup 1) (match_dup 2))
3949 (match_dup 3)))
3950 (set (match_dup 0)
3951 (compare:CC (match_dup 4)
3952 (const_int 0)))]
3953 "")
3954
3955 (define_insn ""
3956 [(set (match_operand:CC 4 "cc_reg_operand" "=x,?y")
3957 (compare:CC
3958 (and:SI (lshiftrt:SI (match_operand:SI 1 "gpc_reg_operand" "r,r")
3959 (match_operand:SI 2 "const_int_operand" "i,i"))
3960 (match_operand:SI 3 "mask_operand" "n,n"))
3961 (const_int 0)))
3962 (set (match_operand:SI 0 "gpc_reg_operand" "=r,r")
3963 (and:SI (lshiftrt:SI (match_dup 1) (match_dup 2)) (match_dup 3)))]
3964 "includes_rshift_p (operands[2], operands[3])"
3965 "@
3966 {rlinm.|rlwinm.} %0,%1,%s2,%m3,%M3
3967 #"
3968 [(set_attr "type" "delayed_compare")
3969 (set_attr "length" "4,8")])
3970
3971 (define_split
3972 [(set (match_operand:CC 4 "cc_reg_not_cr0_operand" "")
3973 (compare:CC
3974 (and:SI (lshiftrt:SI (match_operand:SI 1 "gpc_reg_operand" "")
3975 (match_operand:SI 2 "const_int_operand" ""))
3976 (match_operand:SI 3 "mask_operand" ""))
3977 (const_int 0)))
3978 (set (match_operand:SI 0 "gpc_reg_operand" "")
3979 (and:SI (lshiftrt:SI (match_dup 1) (match_dup 2)) (match_dup 3)))]
3980 "includes_rshift_p (operands[2], operands[3]) && reload_completed"
3981 [(set (match_dup 0)
3982 (and:SI (lshiftrt:SI (match_dup 1) (match_dup 2)) (match_dup 3)))
3983 (set (match_dup 4)
3984 (compare:CC (match_dup 0)
3985 (const_int 0)))]
3986 "")
3987
3988 (define_insn ""
3989 [(set (match_operand:SI 0 "gpc_reg_operand" "=r")
3990 (zero_extend:SI
3991 (subreg:QI
3992 (lshiftrt:SI (match_operand:SI 1 "gpc_reg_operand" "r")
3993 (match_operand:SI 2 "const_int_operand" "i")) 0)))]
3994 "includes_rshift_p (operands[2], GEN_INT (255))"
3995 "{rlinm|rlwinm} %0,%1,%s2,0xff")
3996
3997 (define_insn ""
3998 [(set (match_operand:CC 0 "cc_reg_operand" "=x,?y")
3999 (compare:CC
4000 (zero_extend:SI
4001 (subreg:QI
4002 (lshiftrt:SI (match_operand:SI 1 "gpc_reg_operand" "r,r")
4003 (match_operand:SI 2 "const_int_operand" "i,i")) 0))
4004 (const_int 0)))
4005 (clobber (match_scratch:SI 3 "=r,r"))]
4006 "includes_rshift_p (operands[2], GEN_INT (255))"
4007 "@
4008 {rlinm.|rlwinm.} %3,%1,%s2,0xff
4009 #"
4010 [(set_attr "type" "delayed_compare")
4011 (set_attr "length" "4,8")])
4012
4013 (define_split
4014 [(set (match_operand:CC 0 "cc_reg_not_cr0_operand" "")
4015 (compare:CC
4016 (zero_extend:SI
4017 (subreg:QI
4018 (lshiftrt:SI (match_operand:SI 1 "gpc_reg_operand" "")
4019 (match_operand:SI 2 "const_int_operand" "")) 0))
4020 (const_int 0)))
4021 (clobber (match_scratch:SI 3 ""))]
4022 "includes_rshift_p (operands[2], GEN_INT (255)) && reload_completed"
4023 [(set (match_dup 3)
4024 (zero_extend:SI (subreg:QI
4025 (lshiftrt:SI (match_dup 1)
4026 (match_dup 2)) 0)))
4027 (set (match_dup 0)
4028 (compare:CC (match_dup 3)
4029 (const_int 0)))]
4030 "")
4031
4032 (define_insn ""
4033 [(set (match_operand:CC 3 "cc_reg_operand" "=x,?y")
4034 (compare:CC
4035 (zero_extend:SI
4036 (subreg:QI
4037 (lshiftrt:SI (match_operand:SI 1 "gpc_reg_operand" "r,r")
4038 (match_operand:SI 2 "const_int_operand" "i,i")) 0))
4039 (const_int 0)))
4040 (set (match_operand:SI 0 "gpc_reg_operand" "=r,r")
4041 (zero_extend:SI (subreg:QI (lshiftrt:SI (match_dup 1) (match_dup 2)) 0)))]
4042 "includes_rshift_p (operands[2], GEN_INT (255))"
4043 "@
4044 {rlinm.|rlwinm.} %0,%1,%s2,0xff
4045 #"
4046 [(set_attr "type" "delayed_compare")
4047 (set_attr "length" "4,8")])
4048
4049 (define_split
4050 [(set (match_operand:CC 3 "cc_reg_not_cr0_operand" "")
4051 (compare:CC
4052 (zero_extend:SI
4053 (subreg:QI
4054 (lshiftrt:SI (match_operand:SI 1 "gpc_reg_operand" "")
4055 (match_operand:SI 2 "const_int_operand" "")) 0))
4056 (const_int 0)))
4057 (set (match_operand:SI 0 "gpc_reg_operand" "")
4058 (zero_extend:SI (subreg:QI (lshiftrt:SI (match_dup 1) (match_dup 2)) 0)))]
4059 "includes_rshift_p (operands[2], GEN_INT (255)) && reload_completed"
4060 [(set (match_dup 0)
4061 (zero_extend:SI (subreg:QI (lshiftrt:SI (match_dup 1) (match_dup 2)) 0)))
4062 (set (match_dup 3)
4063 (compare:CC (match_dup 0)
4064 (const_int 0)))]
4065 "")
4066
4067 (define_insn ""
4068 [(set (match_operand:SI 0 "gpc_reg_operand" "=r")
4069 (zero_extend:SI
4070 (subreg:HI
4071 (lshiftrt:SI (match_operand:SI 1 "gpc_reg_operand" "r")
4072 (match_operand:SI 2 "const_int_operand" "i")) 0)))]
4073 "includes_rshift_p (operands[2], GEN_INT (65535))"
4074 "{rlinm|rlwinm} %0,%1,%s2,0xffff")
4075
4076 (define_insn ""
4077 [(set (match_operand:CC 0 "cc_reg_operand" "=x,?y")
4078 (compare:CC
4079 (zero_extend:SI
4080 (subreg:HI
4081 (lshiftrt:SI (match_operand:SI 1 "gpc_reg_operand" "r,r")
4082 (match_operand:SI 2 "const_int_operand" "i,i")) 0))
4083 (const_int 0)))
4084 (clobber (match_scratch:SI 3 "=r,r"))]
4085 "includes_rshift_p (operands[2], GEN_INT (65535))"
4086 "@
4087 {rlinm.|rlwinm.} %3,%1,%s2,0xffff
4088 #"
4089 [(set_attr "type" "delayed_compare")
4090 (set_attr "length" "4,8")])
4091
4092 (define_split
4093 [(set (match_operand:CC 0 "cc_reg_not_cr0_operand" "")
4094 (compare:CC
4095 (zero_extend:SI
4096 (subreg:HI
4097 (lshiftrt:SI (match_operand:SI 1 "gpc_reg_operand" "")
4098 (match_operand:SI 2 "const_int_operand" "")) 0))
4099 (const_int 0)))
4100 (clobber (match_scratch:SI 3 ""))]
4101 "includes_rshift_p (operands[2], GEN_INT (65535)) && reload_completed"
4102 [(set (match_dup 3)
4103 (zero_extend:SI (subreg:HI
4104 (lshiftrt:SI (match_dup 1)
4105 (match_dup 2)) 0)))
4106 (set (match_dup 0)
4107 (compare:CC (match_dup 3)
4108 (const_int 0)))]
4109 "")
4110
4111 (define_insn ""
4112 [(set (match_operand:CC 3 "cc_reg_operand" "=x,?y")
4113 (compare:CC
4114 (zero_extend:SI
4115 (subreg:HI
4116 (lshiftrt:SI (match_operand:SI 1 "gpc_reg_operand" "r,r")
4117 (match_operand:SI 2 "const_int_operand" "i,i")) 0))
4118 (const_int 0)))
4119 (set (match_operand:SI 0 "gpc_reg_operand" "=r,r")
4120 (zero_extend:SI (subreg:HI (lshiftrt:SI (match_dup 1) (match_dup 2)) 0)))]
4121 "includes_rshift_p (operands[2], GEN_INT (65535))"
4122 "@
4123 {rlinm.|rlwinm.} %0,%1,%s2,0xffff
4124 #"
4125 [(set_attr "type" "delayed_compare")
4126 (set_attr "length" "4,8")])
4127
4128 (define_split
4129 [(set (match_operand:CC 3 "cc_reg_not_cr0_operand" "")
4130 (compare:CC
4131 (zero_extend:SI
4132 (subreg:HI
4133 (lshiftrt:SI (match_operand:SI 1 "gpc_reg_operand" "")
4134 (match_operand:SI 2 "const_int_operand" "")) 0))
4135 (const_int 0)))
4136 (set (match_operand:SI 0 "gpc_reg_operand" "")
4137 (zero_extend:SI (subreg:HI (lshiftrt:SI (match_dup 1) (match_dup 2)) 0)))]
4138 "includes_rshift_p (operands[2], GEN_INT (65535)) && reload_completed"
4139 [(set (match_dup 0)
4140 (zero_extend:SI (subreg:HI (lshiftrt:SI (match_dup 1) (match_dup 2)) 0)))
4141 (set (match_dup 3)
4142 (compare:CC (match_dup 0)
4143 (const_int 0)))]
4144 "")
4145
4146 (define_insn ""
4147 [(set (zero_extract:SI (match_operand:SI 0 "gpc_reg_operand" "+r")
4148 (const_int 1)
4149 (match_operand:SI 1 "gpc_reg_operand" "r"))
4150 (ashiftrt:SI (match_operand:SI 2 "gpc_reg_operand" "r")
4151 (const_int 31)))]
4152 "TARGET_POWER"
4153 "rrib %0,%1,%2")
4154
4155 (define_insn ""
4156 [(set (zero_extract:SI (match_operand:SI 0 "gpc_reg_operand" "+r")
4157 (const_int 1)
4158 (match_operand:SI 1 "gpc_reg_operand" "r"))
4159 (lshiftrt:SI (match_operand:SI 2 "gpc_reg_operand" "r")
4160 (const_int 31)))]
4161 "TARGET_POWER"
4162 "rrib %0,%1,%2")
4163
4164 (define_insn ""
4165 [(set (zero_extract:SI (match_operand:SI 0 "gpc_reg_operand" "+r")
4166 (const_int 1)
4167 (match_operand:SI 1 "gpc_reg_operand" "r"))
4168 (zero_extract:SI (match_operand:SI 2 "gpc_reg_operand" "r")
4169 (const_int 1)
4170 (const_int 0)))]
4171 "TARGET_POWER"
4172 "rrib %0,%1,%2")
4173
4174 (define_expand "ashrsi3"
4175 [(set (match_operand:SI 0 "gpc_reg_operand" "")
4176 (ashiftrt:SI (match_operand:SI 1 "gpc_reg_operand" "")
4177 (match_operand:SI 2 "reg_or_cint_operand" "")))]
4178 ""
4179 "
4180 {
4181 if (TARGET_POWER)
4182 emit_insn (gen_ashrsi3_power (operands[0], operands[1], operands[2]));
4183 else
4184 emit_insn (gen_ashrsi3_no_power (operands[0], operands[1], operands[2]));
4185 DONE;
4186 }")
4187
4188 (define_insn "ashrsi3_power"
4189 [(set (match_operand:SI 0 "gpc_reg_operand" "=r,r")
4190 (ashiftrt:SI (match_operand:SI 1 "gpc_reg_operand" "r,r")
4191 (match_operand:SI 2 "reg_or_cint_operand" "r,i")))
4192 (clobber (match_scratch:SI 3 "=q,X"))]
4193 "TARGET_POWER"
4194 "@
4195 srea %0,%1,%2
4196 {srai|srawi} %0,%1,%h2")
4197
4198 (define_insn "ashrsi3_no_power"
4199 [(set (match_operand:SI 0 "gpc_reg_operand" "=r")
4200 (ashiftrt:SI (match_operand:SI 1 "gpc_reg_operand" "r")
4201 (match_operand:SI 2 "reg_or_cint_operand" "ri")))]
4202 "! TARGET_POWER"
4203 "{sra|sraw}%I2 %0,%1,%h2")
4204
4205 (define_insn ""
4206 [(set (match_operand:CC 0 "cc_reg_operand" "=x,x,?y,?y")
4207 (compare:CC (ashiftrt:SI (match_operand:SI 1 "gpc_reg_operand" "r,r,r,r")
4208 (match_operand:SI 2 "reg_or_cint_operand" "r,i,r,i"))
4209 (const_int 0)))
4210 (clobber (match_scratch:SI 3 "=r,r,r,r"))
4211 (clobber (match_scratch:SI 4 "=q,X,q,X"))]
4212 "TARGET_POWER"
4213 "@
4214 srea. %3,%1,%2
4215 {srai.|srawi.} %3,%1,%h2
4216 #
4217 #"
4218 [(set_attr "type" "delayed_compare")
4219 (set_attr "length" "4,4,8,8")])
4220
4221 (define_split
4222 [(set (match_operand:CC 0 "cc_reg_not_cr0_operand" "")
4223 (compare:CC (ashiftrt:SI (match_operand:SI 1 "gpc_reg_operand" "")
4224 (match_operand:SI 2 "reg_or_cint_operand" ""))
4225 (const_int 0)))
4226 (clobber (match_scratch:SI 3 ""))
4227 (clobber (match_scratch:SI 4 ""))]
4228 "TARGET_POWER && reload_completed"
4229 [(parallel [(set (match_dup 3)
4230 (ashiftrt:SI (match_dup 1) (match_dup 2)))
4231 (clobber (match_dup 4))])
4232 (set (match_dup 0)
4233 (compare:CC (match_dup 3)
4234 (const_int 0)))]
4235 "")
4236
4237 (define_insn ""
4238 [(set (match_operand:CC 0 "cc_reg_operand" "=x,?y")
4239 (compare:CC (ashiftrt:SI (match_operand:SI 1 "gpc_reg_operand" "r,r")
4240 (match_operand:SI 2 "reg_or_cint_operand" "ri,ri"))
4241 (const_int 0)))
4242 (clobber (match_scratch:SI 3 "=r,r"))]
4243 "! TARGET_POWER"
4244 "@
4245 {sra|sraw}%I2. %3,%1,%h2
4246 #"
4247 [(set_attr "type" "delayed_compare")
4248 (set_attr "length" "4,8")])
4249
4250 (define_split
4251 [(set (match_operand:CC 0 "cc_reg_not_cr0_operand" "")
4252 (compare:CC (ashiftrt:SI (match_operand:SI 1 "gpc_reg_operand" "")
4253 (match_operand:SI 2 "reg_or_cint_operand" ""))
4254 (const_int 0)))
4255 (clobber (match_scratch:SI 3 ""))]
4256 "! TARGET_POWER && reload_completed"
4257 [(set (match_dup 3)
4258 (ashiftrt:SI (match_dup 1) (match_dup 2)))
4259 (set (match_dup 0)
4260 (compare:CC (match_dup 3)
4261 (const_int 0)))]
4262 "")
4263
4264 (define_insn ""
4265 [(set (match_operand:CC 3 "cc_reg_operand" "=x,x,?y,?y")
4266 (compare:CC (ashiftrt:SI (match_operand:SI 1 "gpc_reg_operand" "r,r,r,r")
4267 (match_operand:SI 2 "reg_or_cint_operand" "r,i,r,i"))
4268 (const_int 0)))
4269 (set (match_operand:SI 0 "gpc_reg_operand" "=r,r,r,r")
4270 (ashiftrt:SI (match_dup 1) (match_dup 2)))
4271 (clobber (match_scratch:SI 4 "=q,X,q,X"))]
4272 "TARGET_POWER"
4273 "@
4274 srea. %0,%1,%2
4275 {srai.|srawi.} %0,%1,%h2
4276 #
4277 #"
4278 [(set_attr "type" "delayed_compare")
4279 (set_attr "length" "4,4,8,8")])
4280
4281 (define_split
4282 [(set (match_operand:CC 3 "cc_reg_not_cr0_operand" "")
4283 (compare:CC (ashiftrt:SI (match_operand:SI 1 "gpc_reg_operand" "")
4284 (match_operand:SI 2 "reg_or_cint_operand" ""))
4285 (const_int 0)))
4286 (set (match_operand:SI 0 "gpc_reg_operand" "")
4287 (ashiftrt:SI (match_dup 1) (match_dup 2)))
4288 (clobber (match_scratch:SI 4 ""))]
4289 "TARGET_POWER && reload_completed"
4290 [(parallel [(set (match_dup 0)
4291 (ashiftrt:SI (match_dup 1) (match_dup 2)))
4292 (clobber (match_dup 4))])
4293 (set (match_dup 3)
4294 (compare:CC (match_dup 0)
4295 (const_int 0)))]
4296 "")
4297
4298 (define_insn ""
4299 [(set (match_operand:CC 3 "cc_reg_operand" "=x,?y")
4300 (compare:CC (ashiftrt:SI (match_operand:SI 1 "gpc_reg_operand" "r,r")
4301 (match_operand:SI 2 "reg_or_cint_operand" "ri,ri"))
4302 (const_int 0)))
4303 (set (match_operand:SI 0 "gpc_reg_operand" "=r,r")
4304 (ashiftrt:SI (match_dup 1) (match_dup 2)))]
4305 "! TARGET_POWER"
4306 "@
4307 {sra|sraw}%I2. %0,%1,%h2
4308 #"
4309 [(set_attr "type" "delayed_compare")
4310 (set_attr "length" "4,8")])
4311 \f
4312 (define_split
4313 [(set (match_operand:CC 3 "cc_reg_not_cr0_operand" "")
4314 (compare:CC (ashiftrt:SI (match_operand:SI 1 "gpc_reg_operand" "")
4315 (match_operand:SI 2 "reg_or_cint_operand" ""))
4316 (const_int 0)))
4317 (set (match_operand:SI 0 "gpc_reg_operand" "")
4318 (ashiftrt:SI (match_dup 1) (match_dup 2)))]
4319 "! TARGET_POWER && reload_completed"
4320 [(set (match_dup 0)
4321 (ashiftrt:SI (match_dup 1) (match_dup 2)))
4322 (set (match_dup 3)
4323 (compare:CC (match_dup 0)
4324 (const_int 0)))]
4325 "")
4326
4327 ;; Floating-point insns, excluding normal data motion.
4328 ;;
4329 ;; PowerPC has a full set of single-precision floating point instructions.
4330 ;;
4331 ;; For the POWER architecture, we pretend that we have both SFmode and
4332 ;; DFmode insns, while, in fact, all fp insns are actually done in double.
4333 ;; The only conversions we will do will be when storing to memory. In that
4334 ;; case, we will use the "frsp" instruction before storing.
4335 ;;
4336 ;; Note that when we store into a single-precision memory location, we need to
4337 ;; use the frsp insn first. If the register being stored isn't dead, we
4338 ;; need a scratch register for the frsp. But this is difficult when the store
4339 ;; is done by reload. It is not incorrect to do the frsp on the register in
4340 ;; this case, we just lose precision that we would have otherwise gotten but
4341 ;; is not guaranteed. Perhaps this should be tightened up at some point.
4342
4343 (define_insn "extendsfdf2"
4344 [(set (match_operand:DF 0 "gpc_reg_operand" "=f")
4345 (float_extend:DF (match_operand:SF 1 "gpc_reg_operand" "f")))]
4346 "TARGET_HARD_FLOAT && TARGET_FPRS"
4347 "*
4348 {
4349 if (REGNO (operands[0]) == REGNO (operands[1]))
4350 return \"\";
4351 else
4352 return \"fmr %0,%1\";
4353 }"
4354 [(set_attr "type" "fp")])
4355
4356 (define_insn "truncdfsf2"
4357 [(set (match_operand:SF 0 "gpc_reg_operand" "=f")
4358 (float_truncate:SF (match_operand:DF 1 "gpc_reg_operand" "f")))]
4359 "TARGET_HARD_FLOAT && TARGET_FPRS"
4360 "frsp %0,%1"
4361 [(set_attr "type" "fp")])
4362
4363 (define_insn "aux_truncdfsf2"
4364 [(set (match_operand:SF 0 "gpc_reg_operand" "=f")
4365 (unspec:SF [(match_operand:SF 1 "gpc_reg_operand" "f")] 0))]
4366 "! TARGET_POWERPC && TARGET_HARD_FLOAT && TARGET_FPRS"
4367 "frsp %0,%1"
4368 [(set_attr "type" "fp")])
4369
4370 (define_expand "negsf2"
4371 [(set (match_operand:SF 0 "gpc_reg_operand" "")
4372 (neg:SF (match_operand:SF 1 "gpc_reg_operand" "")))]
4373 "TARGET_HARD_FLOAT"
4374 "")
4375
4376 (define_insn "*negsf2"
4377 [(set (match_operand:SF 0 "gpc_reg_operand" "=f")
4378 (neg:SF (match_operand:SF 1 "gpc_reg_operand" "f")))]
4379 "TARGET_HARD_FLOAT && TARGET_FPRS"
4380 "fneg %0,%1"
4381 [(set_attr "type" "fp")])
4382
4383 (define_expand "abssf2"
4384 [(set (match_operand:SF 0 "gpc_reg_operand" "")
4385 (abs:SF (match_operand:SF 1 "gpc_reg_operand" "")))]
4386 "TARGET_HARD_FLOAT"
4387 "")
4388
4389 (define_insn "*abssf2"
4390 [(set (match_operand:SF 0 "gpc_reg_operand" "=f")
4391 (abs:SF (match_operand:SF 1 "gpc_reg_operand" "f")))]
4392 "TARGET_HARD_FLOAT && TARGET_FPRS"
4393 "fabs %0,%1"
4394 [(set_attr "type" "fp")])
4395
4396 (define_insn ""
4397 [(set (match_operand:SF 0 "gpc_reg_operand" "=f")
4398 (neg:SF (abs:SF (match_operand:SF 1 "gpc_reg_operand" "f"))))]
4399 "TARGET_HARD_FLOAT && TARGET_FPRS"
4400 "fnabs %0,%1"
4401 [(set_attr "type" "fp")])
4402
4403 (define_expand "addsf3"
4404 [(set (match_operand:SF 0 "gpc_reg_operand" "")
4405 (plus:SF (match_operand:SF 1 "gpc_reg_operand" "")
4406 (match_operand:SF 2 "gpc_reg_operand" "")))]
4407 "TARGET_HARD_FLOAT"
4408 "")
4409
4410 (define_insn ""
4411 [(set (match_operand:SF 0 "gpc_reg_operand" "=f")
4412 (plus:SF (match_operand:SF 1 "gpc_reg_operand" "%f")
4413 (match_operand:SF 2 "gpc_reg_operand" "f")))]
4414 "TARGET_POWERPC && TARGET_HARD_FLOAT && TARGET_FPRS"
4415 "fadds %0,%1,%2"
4416 [(set_attr "type" "fp")])
4417
4418 (define_insn ""
4419 [(set (match_operand:SF 0 "gpc_reg_operand" "=f")
4420 (plus:SF (match_operand:SF 1 "gpc_reg_operand" "%f")
4421 (match_operand:SF 2 "gpc_reg_operand" "f")))]
4422 "! TARGET_POWERPC && TARGET_HARD_FLOAT && TARGET_FPRS"
4423 "{fa|fadd} %0,%1,%2"
4424 [(set_attr "type" "fp")])
4425
4426 (define_expand "subsf3"
4427 [(set (match_operand:SF 0 "gpc_reg_operand" "")
4428 (minus:SF (match_operand:SF 1 "gpc_reg_operand" "")
4429 (match_operand:SF 2 "gpc_reg_operand" "")))]
4430 "TARGET_HARD_FLOAT"
4431 "")
4432
4433 (define_insn ""
4434 [(set (match_operand:SF 0 "gpc_reg_operand" "=f")
4435 (minus:SF (match_operand:SF 1 "gpc_reg_operand" "f")
4436 (match_operand:SF 2 "gpc_reg_operand" "f")))]
4437 "TARGET_POWERPC && TARGET_HARD_FLOAT && TARGET_FPRS"
4438 "fsubs %0,%1,%2"
4439 [(set_attr "type" "fp")])
4440
4441 (define_insn ""
4442 [(set (match_operand:SF 0 "gpc_reg_operand" "=f")
4443 (minus:SF (match_operand:SF 1 "gpc_reg_operand" "f")
4444 (match_operand:SF 2 "gpc_reg_operand" "f")))]
4445 "! TARGET_POWERPC && TARGET_HARD_FLOAT && TARGET_FPRS"
4446 "{fs|fsub} %0,%1,%2"
4447 [(set_attr "type" "fp")])
4448
4449 (define_expand "mulsf3"
4450 [(set (match_operand:SF 0 "gpc_reg_operand" "")
4451 (mult:SF (match_operand:SF 1 "gpc_reg_operand" "")
4452 (match_operand:SF 2 "gpc_reg_operand" "")))]
4453 "TARGET_HARD_FLOAT"
4454 "")
4455
4456 (define_insn ""
4457 [(set (match_operand:SF 0 "gpc_reg_operand" "=f")
4458 (mult:SF (match_operand:SF 1 "gpc_reg_operand" "%f")
4459 (match_operand:SF 2 "gpc_reg_operand" "f")))]
4460 "TARGET_POWERPC && TARGET_HARD_FLOAT && TARGET_FPRS"
4461 "fmuls %0,%1,%2"
4462 [(set_attr "type" "fp")])
4463
4464 (define_insn ""
4465 [(set (match_operand:SF 0 "gpc_reg_operand" "=f")
4466 (mult:SF (match_operand:SF 1 "gpc_reg_operand" "%f")
4467 (match_operand:SF 2 "gpc_reg_operand" "f")))]
4468 "! TARGET_POWERPC && TARGET_HARD_FLOAT && TARGET_FPRS"
4469 "{fm|fmul} %0,%1,%2"
4470 [(set_attr "type" "dmul")])
4471
4472 (define_expand "divsf3"
4473 [(set (match_operand:SF 0 "gpc_reg_operand" "")
4474 (div:SF (match_operand:SF 1 "gpc_reg_operand" "")
4475 (match_operand:SF 2 "gpc_reg_operand" "")))]
4476 "TARGET_HARD_FLOAT"
4477 "")
4478
4479 (define_insn ""
4480 [(set (match_operand:SF 0 "gpc_reg_operand" "=f")
4481 (div:SF (match_operand:SF 1 "gpc_reg_operand" "f")
4482 (match_operand:SF 2 "gpc_reg_operand" "f")))]
4483 "TARGET_POWERPC && TARGET_HARD_FLOAT && TARGET_FPRS"
4484 "fdivs %0,%1,%2"
4485 [(set_attr "type" "sdiv")])
4486
4487 (define_insn ""
4488 [(set (match_operand:SF 0 "gpc_reg_operand" "=f")
4489 (div:SF (match_operand:SF 1 "gpc_reg_operand" "f")
4490 (match_operand:SF 2 "gpc_reg_operand" "f")))]
4491 "! TARGET_POWERPC && TARGET_HARD_FLOAT && TARGET_FPRS"
4492 "{fd|fdiv} %0,%1,%2"
4493 [(set_attr "type" "ddiv")])
4494
4495 (define_insn ""
4496 [(set (match_operand:SF 0 "gpc_reg_operand" "=f")
4497 (plus:SF (mult:SF (match_operand:SF 1 "gpc_reg_operand" "%f")
4498 (match_operand:SF 2 "gpc_reg_operand" "f"))
4499 (match_operand:SF 3 "gpc_reg_operand" "f")))]
4500 "TARGET_POWERPC && TARGET_HARD_FLOAT && TARGET_FPRS && TARGET_FUSED_MADD"
4501 "fmadds %0,%1,%2,%3"
4502 [(set_attr "type" "fp")])
4503
4504 (define_insn ""
4505 [(set (match_operand:SF 0 "gpc_reg_operand" "=f")
4506 (plus:SF (mult:SF (match_operand:SF 1 "gpc_reg_operand" "%f")
4507 (match_operand:SF 2 "gpc_reg_operand" "f"))
4508 (match_operand:SF 3 "gpc_reg_operand" "f")))]
4509 "! TARGET_POWERPC && TARGET_HARD_FLOAT && TARGET_FPRS && TARGET_FUSED_MADD"
4510 "{fma|fmadd} %0,%1,%2,%3"
4511 [(set_attr "type" "dmul")])
4512
4513 (define_insn ""
4514 [(set (match_operand:SF 0 "gpc_reg_operand" "=f")
4515 (minus:SF (mult:SF (match_operand:SF 1 "gpc_reg_operand" "%f")
4516 (match_operand:SF 2 "gpc_reg_operand" "f"))
4517 (match_operand:SF 3 "gpc_reg_operand" "f")))]
4518 "TARGET_POWERPC && TARGET_HARD_FLOAT && TARGET_FPRS && TARGET_FUSED_MADD"
4519 "fmsubs %0,%1,%2,%3"
4520 [(set_attr "type" "fp")])
4521
4522 (define_insn ""
4523 [(set (match_operand:SF 0 "gpc_reg_operand" "=f")
4524 (minus:SF (mult:SF (match_operand:SF 1 "gpc_reg_operand" "%f")
4525 (match_operand:SF 2 "gpc_reg_operand" "f"))
4526 (match_operand:SF 3 "gpc_reg_operand" "f")))]
4527 "! TARGET_POWERPC && TARGET_HARD_FLOAT && TARGET_FPRS && TARGET_FUSED_MADD"
4528 "{fms|fmsub} %0,%1,%2,%3"
4529 [(set_attr "type" "dmul")])
4530
4531 (define_insn ""
4532 [(set (match_operand:SF 0 "gpc_reg_operand" "=f")
4533 (neg:SF (plus:SF (mult:SF (match_operand:SF 1 "gpc_reg_operand" "%f")
4534 (match_operand:SF 2 "gpc_reg_operand" "f"))
4535 (match_operand:SF 3 "gpc_reg_operand" "f"))))]
4536 "TARGET_POWERPC && TARGET_HARD_FLOAT && TARGET_FPRS && TARGET_FUSED_MADD
4537 && HONOR_SIGNED_ZEROS (SFmode)"
4538 "fnmadds %0,%1,%2,%3"
4539 [(set_attr "type" "fp")])
4540
4541 (define_insn ""
4542 [(set (match_operand:SF 0 "gpc_reg_operand" "=f")
4543 (minus:SF (mult:SF (neg:SF (match_operand:SF 1 "gpc_reg_operand" "f"))
4544 (match_operand:SF 2 "gpc_reg_operand" "f"))
4545 (match_operand:SF 3 "gpc_reg_operand" "f")))]
4546 "TARGET_POWERPC && TARGET_HARD_FLOAT && TARGET_FPRS && TARGET_FUSED_MADD
4547 && ! HONOR_SIGNED_ZEROS (SFmode)"
4548 "fnmadds %0,%1,%2,%3"
4549 [(set_attr "type" "fp")])
4550
4551 (define_insn ""
4552 [(set (match_operand:SF 0 "gpc_reg_operand" "=f")
4553 (neg:SF (plus:SF (mult:SF (match_operand:SF 1 "gpc_reg_operand" "%f")
4554 (match_operand:SF 2 "gpc_reg_operand" "f"))
4555 (match_operand:SF 3 "gpc_reg_operand" "f"))))]
4556 "! TARGET_POWERPC && TARGET_HARD_FLOAT && TARGET_FPRS && TARGET_FUSED_MADD"
4557 "{fnma|fnmadd} %0,%1,%2,%3"
4558 [(set_attr "type" "dmul")])
4559
4560 (define_insn ""
4561 [(set (match_operand:SF 0 "gpc_reg_operand" "=f")
4562 (minus:SF (mult:SF (neg:SF (match_operand:SF 1 "gpc_reg_operand" "f"))
4563 (match_operand:SF 2 "gpc_reg_operand" "f"))
4564 (match_operand:SF 3 "gpc_reg_operand" "f")))]
4565 "! TARGET_POWERPC && TARGET_HARD_FLOAT && TARGET_FPRS && TARGET_FUSED_MADD
4566 && ! HONOR_SIGNED_ZEROS (SFmode)"
4567 "{fnma|fnmadd} %0,%1,%2,%3"
4568 [(set_attr "type" "dmul")])
4569
4570 (define_insn ""
4571 [(set (match_operand:SF 0 "gpc_reg_operand" "=f")
4572 (neg:SF (minus:SF (mult:SF (match_operand:SF 1 "gpc_reg_operand" "%f")
4573 (match_operand:SF 2 "gpc_reg_operand" "f"))
4574 (match_operand:SF 3 "gpc_reg_operand" "f"))))]
4575 "TARGET_POWERPC && TARGET_HARD_FLOAT && TARGET_FPRS && TARGET_FUSED_MADD
4576 && HONOR_SIGNED_ZEROS (SFmode)"
4577 "fnmsubs %0,%1,%2,%3"
4578 [(set_attr "type" "fp")])
4579
4580 (define_insn ""
4581 [(set (match_operand:SF 0 "gpc_reg_operand" "=f")
4582 (minus:SF (match_operand:SF 3 "gpc_reg_operand" "f")
4583 (mult:SF (match_operand:SF 1 "gpc_reg_operand" "%f")
4584 (match_operand:SF 2 "gpc_reg_operand" "f"))))]
4585 "TARGET_POWERPC && TARGET_HARD_FLOAT && TARGET_FPRS && TARGET_FUSED_MADD
4586 && ! HONOR_SIGNED_ZEROS (SFmode)"
4587 "fnmsubs %0,%1,%2,%3"
4588 [(set_attr "type" "fp")])
4589
4590 (define_insn ""
4591 [(set (match_operand:SF 0 "gpc_reg_operand" "=f")
4592 (neg:SF (minus:SF (mult:SF (match_operand:SF 1 "gpc_reg_operand" "%f")
4593 (match_operand:SF 2 "gpc_reg_operand" "f"))
4594 (match_operand:SF 3 "gpc_reg_operand" "f"))))]
4595 "! TARGET_POWERPC && TARGET_HARD_FLOAT && TARGET_FPRS && TARGET_FUSED_MADD"
4596 "{fnms|fnmsub} %0,%1,%2,%3"
4597 [(set_attr "type" "dmul")])
4598
4599 (define_insn ""
4600 [(set (match_operand:SF 0 "gpc_reg_operand" "=f")
4601 (minus:SF (match_operand:SF 3 "gpc_reg_operand" "f")
4602 (mult:SF (match_operand:SF 1 "gpc_reg_operand" "%f")
4603 (match_operand:SF 2 "gpc_reg_operand" "f"))))]
4604 "! TARGET_POWERPC && TARGET_HARD_FLOAT && TARGET_FPRS && TARGET_FUSED_MADD
4605 && ! HONOR_SIGNED_ZEROS (SFmode)"
4606 "{fnms|fnmsub} %0,%1,%2,%3"
4607 [(set_attr "type" "fp")])
4608
4609 (define_expand "sqrtsf2"
4610 [(set (match_operand:SF 0 "gpc_reg_operand" "")
4611 (sqrt:SF (match_operand:SF 1 "gpc_reg_operand" "")))]
4612 "(TARGET_PPC_GPOPT || TARGET_POWER2) && TARGET_HARD_FLOAT && TARGET_FPRS"
4613 "")
4614
4615 (define_insn ""
4616 [(set (match_operand:SF 0 "gpc_reg_operand" "=f")
4617 (sqrt:SF (match_operand:SF 1 "gpc_reg_operand" "f")))]
4618 "TARGET_PPC_GPOPT && TARGET_HARD_FLOAT && TARGET_FPRS"
4619 "fsqrts %0,%1"
4620 [(set_attr "type" "ssqrt")])
4621
4622 (define_insn ""
4623 [(set (match_operand:SF 0 "gpc_reg_operand" "=f")
4624 (sqrt:SF (match_operand:SF 1 "gpc_reg_operand" "f")))]
4625 "TARGET_POWER2 && TARGET_HARD_FLOAT && TARGET_FPRS"
4626 "fsqrt %0,%1"
4627 [(set_attr "type" "dsqrt")])
4628
4629 ;; For MIN, MAX, and conditional move, we use DEFINE_EXPAND's that involve a
4630 ;; fsel instruction and some auxiliary computations. Then we just have a
4631 ;; single DEFINE_INSN for fsel and the define_splits to make them if made by
4632 ;; combine.
4633 (define_expand "maxsf3"
4634 [(set (match_operand:SF 0 "gpc_reg_operand" "")
4635 (if_then_else:SF (ge (match_operand:SF 1 "gpc_reg_operand" "")
4636 (match_operand:SF 2 "gpc_reg_operand" ""))
4637 (match_dup 1)
4638 (match_dup 2)))]
4639 "TARGET_PPC_GFXOPT && TARGET_HARD_FLOAT && TARGET_FPRS"
4640 "{ rs6000_emit_minmax (operands[0], SMAX, operands[1], operands[2]); DONE;}")
4641
4642 (define_expand "minsf3"
4643 [(set (match_operand:SF 0 "gpc_reg_operand" "")
4644 (if_then_else:SF (ge (match_operand:SF 1 "gpc_reg_operand" "")
4645 (match_operand:SF 2 "gpc_reg_operand" ""))
4646 (match_dup 2)
4647 (match_dup 1)))]
4648 "TARGET_PPC_GFXOPT && TARGET_HARD_FLOAT && TARGET_FPRS"
4649 "{ rs6000_emit_minmax (operands[0], SMIN, operands[1], operands[2]); DONE;}")
4650
4651 (define_split
4652 [(set (match_operand:SF 0 "gpc_reg_operand" "")
4653 (match_operator:SF 3 "min_max_operator"
4654 [(match_operand:SF 1 "gpc_reg_operand" "")
4655 (match_operand:SF 2 "gpc_reg_operand" "")]))]
4656 "TARGET_PPC_GFXOPT && TARGET_HARD_FLOAT && TARGET_FPRS"
4657 [(const_int 0)]
4658 "
4659 { rs6000_emit_minmax (operands[0], GET_CODE (operands[3]),
4660 operands[1], operands[2]);
4661 DONE;
4662 }")
4663
4664 (define_expand "movsicc"
4665 [(set (match_operand:SI 0 "gpc_reg_operand" "")
4666 (if_then_else:SI (match_operand 1 "comparison_operator" "")
4667 (match_operand:SI 2 "gpc_reg_operand" "")
4668 (match_operand:SI 3 "gpc_reg_operand" "")))]
4669 "TARGET_ISEL"
4670 "
4671 {
4672 if (rs6000_emit_cmove (operands[0], operands[1], operands[2], operands[3]))
4673 DONE;
4674 else
4675 FAIL;
4676 }")
4677
4678 ;; We use the BASE_REGS for the isel input operands because, if rA is
4679 ;; 0, the value of 0 is placed in rD upon truth. Similarly for rB
4680 ;; because we may switch the operands and rB may end up being rA.
4681 ;;
4682 ;; We need 2 patterns: an unsigned and a signed pattern. We could
4683 ;; leave out the mode in operand 4 and use one pattern, but reload can
4684 ;; change the mode underneath our feet and then gets confused trying
4685 ;; to reload the value.
4686 (define_insn "isel_signed"
4687 [(set (match_operand:SI 0 "gpc_reg_operand" "=r")
4688 (if_then_else:SI
4689 (match_operator 1 "comparison_operator"
4690 [(match_operand:CC 4 "cc_reg_operand" "y")
4691 (const_int 0)])
4692 (match_operand:SI 2 "gpc_reg_operand" "b")
4693 (match_operand:SI 3 "gpc_reg_operand" "b")))]
4694 "TARGET_ISEL"
4695 "*
4696 { return output_isel (operands); }"
4697 [(set_attr "length" "4")])
4698
4699 (define_insn "isel_unsigned"
4700 [(set (match_operand:SI 0 "gpc_reg_operand" "=r")
4701 (if_then_else:SI
4702 (match_operator 1 "comparison_operator"
4703 [(match_operand:CCUNS 4 "cc_reg_operand" "y")
4704 (const_int 0)])
4705 (match_operand:SI 2 "gpc_reg_operand" "b")
4706 (match_operand:SI 3 "gpc_reg_operand" "b")))]
4707 "TARGET_ISEL"
4708 "*
4709 { return output_isel (operands); }"
4710 [(set_attr "length" "4")])
4711
4712 (define_expand "movsfcc"
4713 [(set (match_operand:SF 0 "gpc_reg_operand" "")
4714 (if_then_else:SF (match_operand 1 "comparison_operator" "")
4715 (match_operand:SF 2 "gpc_reg_operand" "")
4716 (match_operand:SF 3 "gpc_reg_operand" "")))]
4717 "TARGET_PPC_GFXOPT && TARGET_HARD_FLOAT && TARGET_FPRS"
4718 "
4719 {
4720 if (rs6000_emit_cmove (operands[0], operands[1], operands[2], operands[3]))
4721 DONE;
4722 else
4723 FAIL;
4724 }")
4725
4726 (define_insn "*fselsfsf4"
4727 [(set (match_operand:SF 0 "gpc_reg_operand" "=f")
4728 (if_then_else:SF (ge (match_operand:SF 1 "gpc_reg_operand" "f")
4729 (match_operand:SF 4 "zero_fp_constant" "F"))
4730 (match_operand:SF 2 "gpc_reg_operand" "f")
4731 (match_operand:SF 3 "gpc_reg_operand" "f")))]
4732 "TARGET_PPC_GFXOPT && TARGET_HARD_FLOAT && TARGET_FPRS"
4733 "fsel %0,%1,%2,%3"
4734 [(set_attr "type" "fp")])
4735
4736 (define_insn "*fseldfsf4"
4737 [(set (match_operand:SF 0 "gpc_reg_operand" "=f")
4738 (if_then_else:SF (ge (match_operand:DF 1 "gpc_reg_operand" "f")
4739 (match_operand:DF 4 "zero_fp_constant" "F"))
4740 (match_operand:SF 2 "gpc_reg_operand" "f")
4741 (match_operand:SF 3 "gpc_reg_operand" "f")))]
4742 "TARGET_PPC_GFXOPT && TARGET_HARD_FLOAT && TARGET_FPRS"
4743 "fsel %0,%1,%2,%3"
4744 [(set_attr "type" "fp")])
4745
4746 (define_insn "negdf2"
4747 [(set (match_operand:DF 0 "gpc_reg_operand" "=f")
4748 (neg:DF (match_operand:DF 1 "gpc_reg_operand" "f")))]
4749 "TARGET_HARD_FLOAT && TARGET_FPRS"
4750 "fneg %0,%1"
4751 [(set_attr "type" "fp")])
4752
4753 (define_insn "absdf2"
4754 [(set (match_operand:DF 0 "gpc_reg_operand" "=f")
4755 (abs:DF (match_operand:DF 1 "gpc_reg_operand" "f")))]
4756 "TARGET_HARD_FLOAT && TARGET_FPRS"
4757 "fabs %0,%1"
4758 [(set_attr "type" "fp")])
4759
4760 (define_insn ""
4761 [(set (match_operand:DF 0 "gpc_reg_operand" "=f")
4762 (neg:DF (abs:DF (match_operand:DF 1 "gpc_reg_operand" "f"))))]
4763 "TARGET_HARD_FLOAT && TARGET_FPRS"
4764 "fnabs %0,%1"
4765 [(set_attr "type" "fp")])
4766
4767 (define_insn "adddf3"
4768 [(set (match_operand:DF 0 "gpc_reg_operand" "=f")
4769 (plus:DF (match_operand:DF 1 "gpc_reg_operand" "%f")
4770 (match_operand:DF 2 "gpc_reg_operand" "f")))]
4771 "TARGET_HARD_FLOAT && TARGET_FPRS"
4772 "{fa|fadd} %0,%1,%2"
4773 [(set_attr "type" "fp")])
4774
4775 (define_insn "subdf3"
4776 [(set (match_operand:DF 0 "gpc_reg_operand" "=f")
4777 (minus:DF (match_operand:DF 1 "gpc_reg_operand" "f")
4778 (match_operand:DF 2 "gpc_reg_operand" "f")))]
4779 "TARGET_HARD_FLOAT && TARGET_FPRS"
4780 "{fs|fsub} %0,%1,%2"
4781 [(set_attr "type" "fp")])
4782
4783 (define_insn "muldf3"
4784 [(set (match_operand:DF 0 "gpc_reg_operand" "=f")
4785 (mult:DF (match_operand:DF 1 "gpc_reg_operand" "%f")
4786 (match_operand:DF 2 "gpc_reg_operand" "f")))]
4787 "TARGET_HARD_FLOAT && TARGET_FPRS"
4788 "{fm|fmul} %0,%1,%2"
4789 [(set_attr "type" "dmul")])
4790
4791 (define_insn "divdf3"
4792 [(set (match_operand:DF 0 "gpc_reg_operand" "=f")
4793 (div:DF (match_operand:DF 1 "gpc_reg_operand" "f")
4794 (match_operand:DF 2 "gpc_reg_operand" "f")))]
4795 "TARGET_HARD_FLOAT && TARGET_FPRS"
4796 "{fd|fdiv} %0,%1,%2"
4797 [(set_attr "type" "ddiv")])
4798
4799 (define_insn ""
4800 [(set (match_operand:DF 0 "gpc_reg_operand" "=f")
4801 (plus:DF (mult:DF (match_operand:DF 1 "gpc_reg_operand" "%f")
4802 (match_operand:DF 2 "gpc_reg_operand" "f"))
4803 (match_operand:DF 3 "gpc_reg_operand" "f")))]
4804 "TARGET_HARD_FLOAT && TARGET_FPRS && TARGET_FUSED_MADD"
4805 "{fma|fmadd} %0,%1,%2,%3"
4806 [(set_attr "type" "dmul")])
4807
4808 (define_insn ""
4809 [(set (match_operand:DF 0 "gpc_reg_operand" "=f")
4810 (minus:DF (mult:DF (match_operand:DF 1 "gpc_reg_operand" "%f")
4811 (match_operand:DF 2 "gpc_reg_operand" "f"))
4812 (match_operand:DF 3 "gpc_reg_operand" "f")))]
4813 "TARGET_HARD_FLOAT && TARGET_FPRS && TARGET_FUSED_MADD"
4814 "{fms|fmsub} %0,%1,%2,%3"
4815 [(set_attr "type" "dmul")])
4816
4817 (define_insn ""
4818 [(set (match_operand:DF 0 "gpc_reg_operand" "=f")
4819 (neg:DF (plus:DF (mult:DF (match_operand:DF 1 "gpc_reg_operand" "%f")
4820 (match_operand:DF 2 "gpc_reg_operand" "f"))
4821 (match_operand:DF 3 "gpc_reg_operand" "f"))))]
4822 "TARGET_HARD_FLOAT && TARGET_FPRS && TARGET_FUSED_MADD
4823 && HONOR_SIGNED_ZEROS (DFmode)"
4824 "{fnma|fnmadd} %0,%1,%2,%3"
4825 [(set_attr "type" "dmul")])
4826
4827 (define_insn ""
4828 [(set (match_operand:DF 0 "gpc_reg_operand" "=f")
4829 (minus:DF (mult:DF (neg:DF (match_operand:DF 1 "gpc_reg_operand" "f"))
4830 (match_operand:DF 2 "gpc_reg_operand" "f"))
4831 (match_operand:DF 3 "gpc_reg_operand" "f")))]
4832 "TARGET_HARD_FLOAT && TARGET_FPRS && TARGET_FUSED_MADD
4833 && ! HONOR_SIGNED_ZEROS (DFmode)"
4834 "{fnma|fnmadd} %0,%1,%2,%3"
4835 [(set_attr "type" "dmul")])
4836
4837 (define_insn ""
4838 [(set (match_operand:DF 0 "gpc_reg_operand" "=f")
4839 (neg:DF (minus:DF (mult:DF (match_operand:DF 1 "gpc_reg_operand" "%f")
4840 (match_operand:DF 2 "gpc_reg_operand" "f"))
4841 (match_operand:DF 3 "gpc_reg_operand" "f"))))]
4842 "TARGET_HARD_FLOAT && TARGET_FPRS && TARGET_FUSED_MADD
4843 && HONOR_SIGNED_ZEROS (DFmode)"
4844 "{fnms|fnmsub} %0,%1,%2,%3"
4845 [(set_attr "type" "dmul")])
4846
4847 (define_insn ""
4848 [(set (match_operand:DF 0 "gpc_reg_operand" "=f")
4849 (minus:DF (match_operand:DF 3 "gpc_reg_operand" "f")
4850 (mult:DF (match_operand:DF 1 "gpc_reg_operand" "%f")
4851 (match_operand:DF 2 "gpc_reg_operand" "f"))))]
4852 "TARGET_HARD_FLOAT && TARGET_FPRS && TARGET_FUSED_MADD
4853 && ! HONOR_SIGNED_ZEROS (DFmode)"
4854 "{fnms|fnmsub} %0,%1,%2,%3"
4855 [(set_attr "type" "dmul")])
4856
4857 (define_insn "sqrtdf2"
4858 [(set (match_operand:DF 0 "gpc_reg_operand" "=f")
4859 (sqrt:DF (match_operand:DF 1 "gpc_reg_operand" "f")))]
4860 "(TARGET_PPC_GPOPT || TARGET_POWER2) && TARGET_HARD_FLOAT && TARGET_FPRS"
4861 "fsqrt %0,%1"
4862 [(set_attr "type" "dsqrt")])
4863
4864 ;; The conditional move instructions allow us to perform max and min
4865 ;; operations even when
4866
4867 (define_expand "maxdf3"
4868 [(set (match_operand:DF 0 "gpc_reg_operand" "")
4869 (if_then_else:DF (ge (match_operand:DF 1 "gpc_reg_operand" "")
4870 (match_operand:DF 2 "gpc_reg_operand" ""))
4871 (match_dup 1)
4872 (match_dup 2)))]
4873 "TARGET_PPC_GFXOPT && TARGET_HARD_FLOAT && TARGET_FPRS"
4874 "{ rs6000_emit_minmax (operands[0], SMAX, operands[1], operands[2]); DONE;}")
4875
4876 (define_expand "mindf3"
4877 [(set (match_operand:DF 0 "gpc_reg_operand" "")
4878 (if_then_else:DF (ge (match_operand:DF 1 "gpc_reg_operand" "")
4879 (match_operand:DF 2 "gpc_reg_operand" ""))
4880 (match_dup 2)
4881 (match_dup 1)))]
4882 "TARGET_PPC_GFXOPT && TARGET_HARD_FLOAT && TARGET_FPRS"
4883 "{ rs6000_emit_minmax (operands[0], SMIN, operands[1], operands[2]); DONE;}")
4884
4885 (define_split
4886 [(set (match_operand:DF 0 "gpc_reg_operand" "")
4887 (match_operator:DF 3 "min_max_operator"
4888 [(match_operand:DF 1 "gpc_reg_operand" "")
4889 (match_operand:DF 2 "gpc_reg_operand" "")]))]
4890 "TARGET_PPC_GFXOPT && TARGET_HARD_FLOAT && TARGET_FPRS"
4891 [(const_int 0)]
4892 "
4893 { rs6000_emit_minmax (operands[0], GET_CODE (operands[3]),
4894 operands[1], operands[2]);
4895 DONE;
4896 }")
4897
4898 (define_expand "movdfcc"
4899 [(set (match_operand:DF 0 "gpc_reg_operand" "")
4900 (if_then_else:DF (match_operand 1 "comparison_operator" "")
4901 (match_operand:DF 2 "gpc_reg_operand" "")
4902 (match_operand:DF 3 "gpc_reg_operand" "")))]
4903 "TARGET_PPC_GFXOPT && TARGET_HARD_FLOAT && TARGET_FPRS"
4904 "
4905 {
4906 if (rs6000_emit_cmove (operands[0], operands[1], operands[2], operands[3]))
4907 DONE;
4908 else
4909 FAIL;
4910 }")
4911
4912 (define_insn "*fseldfdf4"
4913 [(set (match_operand:DF 0 "gpc_reg_operand" "=f")
4914 (if_then_else:DF (ge (match_operand:DF 1 "gpc_reg_operand" "f")
4915 (match_operand:DF 4 "zero_fp_constant" "F"))
4916 (match_operand:DF 2 "gpc_reg_operand" "f")
4917 (match_operand:DF 3 "gpc_reg_operand" "f")))]
4918 "TARGET_PPC_GFXOPT && TARGET_HARD_FLOAT && TARGET_FPRS"
4919 "fsel %0,%1,%2,%3"
4920 [(set_attr "type" "fp")])
4921
4922 (define_insn "*fselsfdf4"
4923 [(set (match_operand:DF 0 "gpc_reg_operand" "=f")
4924 (if_then_else:DF (ge (match_operand:SF 1 "gpc_reg_operand" "f")
4925 (match_operand:SF 4 "zero_fp_constant" "F"))
4926 (match_operand:DF 2 "gpc_reg_operand" "f")
4927 (match_operand:DF 3 "gpc_reg_operand" "f")))]
4928 "TARGET_PPC_GFXOPT"
4929 "fsel %0,%1,%2,%3"
4930 [(set_attr "type" "fp")])
4931 \f
4932 ;; Conversions to and from floating-point.
4933
4934 (define_expand "fixunssfsi2"
4935 [(set (match_operand:SI 0 "gpc_reg_operand" "")
4936 (unsigned_fix:SI (fix:SF (match_operand:SF 1 "gpc_reg_operand" ""))))]
4937 "TARGET_HARD_FLOAT && !TARGET_FPRS"
4938 "")
4939
4940 (define_expand "fix_truncsfsi2"
4941 [(set (match_operand:SI 0 "gpc_reg_operand" "")
4942 (fix:SI (match_operand:SF 1 "gpc_reg_operand" "")))]
4943 "TARGET_HARD_FLOAT && !TARGET_FPRS"
4944 "")
4945
4946 ; For each of these conversions, there is a define_expand, a define_insn
4947 ; with a '#' template, and a define_split (with C code). The idea is
4948 ; to allow constant folding with the template of the define_insn,
4949 ; then to have the insns split later (between sched1 and final).
4950
4951 (define_expand "floatsidf2"
4952 [(parallel [(set (match_operand:DF 0 "gpc_reg_operand" "")
4953 (float:DF (match_operand:SI 1 "gpc_reg_operand" "")))
4954 (use (match_dup 2))
4955 (use (match_dup 3))
4956 (clobber (match_dup 4))
4957 (clobber (match_dup 5))
4958 (clobber (match_dup 6))])]
4959 "TARGET_HARD_FLOAT && TARGET_FPRS"
4960 "
4961 {
4962 if (TARGET_POWERPC64)
4963 {
4964 rtx mem = assign_stack_temp (DImode, GET_MODE_SIZE (DImode), 0);
4965 rtx t1 = gen_reg_rtx (DImode);
4966 rtx t2 = gen_reg_rtx (DImode);
4967 emit_insn (gen_floatsidf_ppc64 (operands[0], operands[1], mem, t1, t2));
4968 DONE;
4969 }
4970
4971 operands[2] = force_reg (SImode, GEN_INT (0x43300000));
4972 operands[3] = force_reg (DFmode, CONST_DOUBLE_ATOF (\"4503601774854144\", DFmode));
4973 operands[4] = assign_stack_temp (DFmode, GET_MODE_SIZE (DFmode), 0);
4974 operands[5] = gen_reg_rtx (DFmode);
4975 operands[6] = gen_reg_rtx (SImode);
4976 }")
4977
4978 (define_insn "*floatsidf2_internal"
4979 [(set (match_operand:DF 0 "gpc_reg_operand" "=&f")
4980 (float:DF (match_operand:SI 1 "gpc_reg_operand" "r")))
4981 (use (match_operand:SI 2 "gpc_reg_operand" "r"))
4982 (use (match_operand:DF 3 "gpc_reg_operand" "f"))
4983 (clobber (match_operand:DF 4 "memory_operand" "=o"))
4984 (clobber (match_operand:DF 5 "gpc_reg_operand" "=&f"))
4985 (clobber (match_operand:SI 6 "gpc_reg_operand" "=&r"))]
4986 "! TARGET_POWERPC64 && TARGET_HARD_FLOAT && TARGET_FPRS"
4987 "#"
4988 [(set_attr "length" "24")])
4989
4990 (define_split
4991 [(set (match_operand:DF 0 "gpc_reg_operand" "")
4992 (float:DF (match_operand:SI 1 "gpc_reg_operand" "")))
4993 (use (match_operand:SI 2 "gpc_reg_operand" ""))
4994 (use (match_operand:DF 3 "gpc_reg_operand" ""))
4995 (clobber (match_operand:DF 4 "offsettable_mem_operand" ""))
4996 (clobber (match_operand:DF 5 "gpc_reg_operand" ""))
4997 (clobber (match_operand:SI 6 "gpc_reg_operand" ""))]
4998 "! TARGET_POWERPC64 && TARGET_HARD_FLOAT && TARGET_FPRS"
4999 [(set (match_operand:DF 0 "gpc_reg_operand" "")
5000 (float:DF (match_operand:SI 1 "gpc_reg_operand" "")))
5001 (use (match_operand:SI 2 "gpc_reg_operand" ""))
5002 (use (match_operand:DF 3 "gpc_reg_operand" ""))
5003 (clobber (match_operand:DF 4 "offsettable_mem_operand" ""))
5004 (clobber (match_operand:DF 5 "gpc_reg_operand" ""))
5005 (clobber (match_operand:SI 6 "gpc_reg_operand" ""))]
5006 "
5007 {
5008 rtx lowword, highword;
5009 if (GET_CODE (operands[4]) != MEM)
5010 abort();
5011 highword = XEXP (operands[4], 0);
5012 lowword = plus_constant (highword, 4);
5013 if (! WORDS_BIG_ENDIAN)
5014 {
5015 rtx tmp;
5016 tmp = highword; highword = lowword; lowword = tmp;
5017 }
5018
5019 emit_insn (gen_xorsi3 (operands[6], operands[1],
5020 GEN_INT (~ (HOST_WIDE_INT) 0x7fffffff)));
5021 emit_move_insn (gen_rtx_MEM (SImode, lowword), operands[6]);
5022 emit_move_insn (gen_rtx_MEM (SImode, highword), operands[2]);
5023 emit_move_insn (operands[5], operands[4]);
5024 emit_insn (gen_subdf3 (operands[0], operands[5], operands[3]));
5025 DONE;
5026 }")
5027
5028 (define_expand "floatunssisf2"
5029 [(set (match_operand:SF 0 "gpc_reg_operand" "")
5030 (unsigned_float:SF (match_operand:SI 1 "gpc_reg_operand" "")))]
5031 "TARGET_HARD_FLOAT && !TARGET_FPRS"
5032 "")
5033
5034 (define_expand "floatunssidf2"
5035 [(parallel [(set (match_operand:DF 0 "gpc_reg_operand" "")
5036 (unsigned_float:DF (match_operand:SI 1 "gpc_reg_operand" "")))
5037 (use (match_dup 2))
5038 (use (match_dup 3))
5039 (clobber (match_dup 4))
5040 (clobber (match_dup 5))])]
5041 "TARGET_HARD_FLOAT && TARGET_FPRS"
5042 "
5043 {
5044 if (TARGET_POWERPC64)
5045 {
5046 rtx mem = assign_stack_temp (DImode, GET_MODE_SIZE (DImode), 0);
5047 rtx t1 = gen_reg_rtx (DImode);
5048 rtx t2 = gen_reg_rtx (DImode);
5049 emit_insn (gen_floatunssidf_ppc64 (operands[0], operands[1], mem,
5050 t1, t2));
5051 DONE;
5052 }
5053
5054 operands[2] = force_reg (SImode, GEN_INT (0x43300000));
5055 operands[3] = force_reg (DFmode, CONST_DOUBLE_ATOF (\"4503599627370496\", DFmode));
5056 operands[4] = assign_stack_temp (DFmode, GET_MODE_SIZE (DFmode), 0);
5057 operands[5] = gen_reg_rtx (DFmode);
5058 }")
5059
5060 (define_insn "*floatunssidf2_internal"
5061 [(set (match_operand:DF 0 "gpc_reg_operand" "=&f")
5062 (unsigned_float:DF (match_operand:SI 1 "gpc_reg_operand" "r")))
5063 (use (match_operand:SI 2 "gpc_reg_operand" "r"))
5064 (use (match_operand:DF 3 "gpc_reg_operand" "f"))
5065 (clobber (match_operand:DF 4 "memory_operand" "=o"))
5066 (clobber (match_operand:DF 5 "gpc_reg_operand" "=&f"))]
5067 "! TARGET_POWERPC64 && TARGET_HARD_FLOAT && TARGET_FPRS"
5068 "#"
5069 [(set_attr "length" "20")])
5070
5071 (define_split
5072 [(set (match_operand:DF 0 "gpc_reg_operand" "")
5073 (unsigned_float:DF (match_operand:SI 1 "gpc_reg_operand" "")))
5074 (use (match_operand:SI 2 "gpc_reg_operand" ""))
5075 (use (match_operand:DF 3 "gpc_reg_operand" ""))
5076 (clobber (match_operand:DF 4 "offsettable_mem_operand" ""))
5077 (clobber (match_operand:DF 5 "gpc_reg_operand" ""))]
5078 "! TARGET_POWERPC64 && TARGET_HARD_FLOAT && TARGET_FPRS"
5079 [(set (match_operand:DF 0 "gpc_reg_operand" "")
5080 (unsigned_float:DF (match_operand:SI 1 "gpc_reg_operand" "")))
5081 (use (match_operand:SI 2 "gpc_reg_operand" ""))
5082 (use (match_operand:DF 3 "gpc_reg_operand" ""))
5083 (clobber (match_operand:DF 4 "offsettable_mem_operand" ""))
5084 (clobber (match_operand:DF 5 "gpc_reg_operand" ""))]
5085 "
5086 {
5087 rtx lowword, highword;
5088 if (GET_CODE (operands[4]) != MEM)
5089 abort();
5090 highword = XEXP (operands[4], 0);
5091 lowword = plus_constant (highword, 4);
5092 if (! WORDS_BIG_ENDIAN)
5093 {
5094 rtx tmp;
5095 tmp = highword; highword = lowword; lowword = tmp;
5096 }
5097
5098 emit_move_insn (gen_rtx_MEM (SImode, lowword), operands[1]);
5099 emit_move_insn (gen_rtx_MEM (SImode, highword), operands[2]);
5100 emit_move_insn (operands[5], operands[4]);
5101 emit_insn (gen_subdf3 (operands[0], operands[5], operands[3]));
5102 DONE;
5103 }")
5104
5105 (define_expand "fix_truncdfsi2"
5106 [(parallel [(set (match_operand:SI 0 "gpc_reg_operand" "")
5107 (fix:SI (match_operand:DF 1 "gpc_reg_operand" "")))
5108 (clobber (match_dup 2))
5109 (clobber (match_dup 3))])]
5110 "(TARGET_POWER2 || TARGET_POWERPC) && TARGET_HARD_FLOAT && TARGET_FPRS"
5111 "
5112 {
5113 operands[2] = gen_reg_rtx (DImode);
5114 operands[3] = assign_stack_temp (DImode, GET_MODE_SIZE (DImode), 0);
5115 }")
5116
5117 (define_insn "*fix_truncdfsi2_internal"
5118 [(set (match_operand:SI 0 "gpc_reg_operand" "=r")
5119 (fix:SI (match_operand:DF 1 "gpc_reg_operand" "f")))
5120 (clobber (match_operand:DI 2 "gpc_reg_operand" "=f"))
5121 (clobber (match_operand:DI 3 "memory_operand" "=o"))]
5122 "(TARGET_POWER2 || TARGET_POWERPC) && TARGET_HARD_FLOAT && TARGET_FPRS"
5123 "#"
5124 [(set_attr "length" "16")])
5125
5126 (define_split
5127 [(set (match_operand:SI 0 "gpc_reg_operand" "")
5128 (fix:SI (match_operand:DF 1 "gpc_reg_operand" "")))
5129 (clobber (match_operand:DI 2 "gpc_reg_operand" ""))
5130 (clobber (match_operand:DI 3 "offsettable_mem_operand" ""))]
5131 "(TARGET_POWER2 || TARGET_POWERPC) && TARGET_HARD_FLOAT && TARGET_FPRS"
5132 [(set (match_operand:SI 0 "gpc_reg_operand" "")
5133 (fix:SI (match_operand:DF 1 "gpc_reg_operand" "")))
5134 (clobber (match_operand:DI 2 "gpc_reg_operand" ""))
5135 (clobber (match_operand:DI 3 "offsettable_mem_operand" ""))]
5136 "
5137 {
5138 rtx lowword;
5139 if (GET_CODE (operands[3]) != MEM)
5140 abort();
5141 lowword = XEXP (operands[3], 0);
5142 if (WORDS_BIG_ENDIAN)
5143 lowword = plus_constant (lowword, 4);
5144
5145 emit_insn (gen_fctiwz (operands[2], operands[1]));
5146 emit_move_insn (operands[3], operands[2]);
5147 emit_move_insn (operands[0], gen_rtx_MEM (SImode, lowword));
5148 DONE;
5149 }")
5150
5151 ; Here, we use (set (reg) (unspec:DI [(fix:SI ...)] 10))
5152 ; rather than (set (subreg:SI (reg)) (fix:SI ...))
5153 ; because the first makes it clear that operand 0 is not live
5154 ; before the instruction.
5155 (define_insn "fctiwz"
5156 [(set (match_operand:DI 0 "gpc_reg_operand" "=*f")
5157 (unspec:DI [(fix:SI (match_operand:DF 1 "gpc_reg_operand" "f"))] 10))]
5158 "(TARGET_POWER2 || TARGET_POWERPC) && TARGET_HARD_FLOAT && TARGET_FPRS"
5159 "{fcirz|fctiwz} %0,%1"
5160 [(set_attr "type" "fp")])
5161
5162 (define_expand "floatsisf2"
5163 [(set (match_operand:SF 0 "gpc_reg_operand" "")
5164 (float:SF (match_operand:SI 1 "gpc_reg_operand" "")))]
5165 "TARGET_HARD_FLOAT && !TARGET_FPRS"
5166 "")
5167
5168 (define_insn "floatdidf2"
5169 [(set (match_operand:DF 0 "gpc_reg_operand" "=f")
5170 (float:DF (match_operand:DI 1 "gpc_reg_operand" "*f")))]
5171 "TARGET_POWERPC64 && TARGET_HARD_FLOAT && TARGET_FPRS"
5172 "fcfid %0,%1"
5173 [(set_attr "type" "fp")])
5174
5175 (define_insn_and_split "floatsidf_ppc64"
5176 [(set (match_operand:DF 0 "gpc_reg_operand" "=f")
5177 (float:DF (match_operand:SI 1 "gpc_reg_operand" "r")))
5178 (clobber (match_operand:DI 2 "memory_operand" "=o"))
5179 (clobber (match_operand:DI 3 "gpc_reg_operand" "=r"))
5180 (clobber (match_operand:DI 4 "gpc_reg_operand" "=f"))]
5181 "TARGET_POWERPC64 && TARGET_HARD_FLOAT && TARGET_FPRS"
5182 "#"
5183 ""
5184 [(set (match_dup 3) (sign_extend:DI (match_dup 1)))
5185 (set (match_dup 2) (match_dup 3))
5186 (set (match_dup 4) (match_dup 2))
5187 (set (match_dup 0) (float:DF (match_dup 4)))]
5188 "")
5189
5190 (define_insn_and_split "floatunssidf_ppc64"
5191 [(set (match_operand:DF 0 "gpc_reg_operand" "=f")
5192 (unsigned_float:DF (match_operand:SI 1 "gpc_reg_operand" "r")))
5193 (clobber (match_operand:DI 2 "memory_operand" "=o"))
5194 (clobber (match_operand:DI 3 "gpc_reg_operand" "=r"))
5195 (clobber (match_operand:DI 4 "gpc_reg_operand" "=f"))]
5196 "TARGET_POWERPC64 && TARGET_HARD_FLOAT && TARGET_FPRS"
5197 "#"
5198 ""
5199 [(set (match_dup 3) (zero_extend:DI (match_dup 1)))
5200 (set (match_dup 2) (match_dup 3))
5201 (set (match_dup 4) (match_dup 2))
5202 (set (match_dup 0) (float:DF (match_dup 4)))]
5203 "")
5204
5205 (define_insn "fix_truncdfdi2"
5206 [(set (match_operand:DI 0 "gpc_reg_operand" "=*f")
5207 (fix:DI (match_operand:DF 1 "gpc_reg_operand" "f")))]
5208 "TARGET_POWERPC64 && TARGET_HARD_FLOAT && TARGET_FPRS"
5209 "fctidz %0,%1"
5210 [(set_attr "type" "fp")])
5211
5212 (define_expand "floatdisf2"
5213 [(set (match_operand:SF 0 "gpc_reg_operand" "")
5214 (float:SF (match_operand:DI 1 "gpc_reg_operand" "")))]
5215 "TARGET_POWERPC64 && TARGET_HARD_FLOAT && TARGET_FPRS"
5216 "
5217 {
5218 if (!flag_unsafe_math_optimizations)
5219 {
5220 rtx label = gen_label_rtx ();
5221 emit_insn (gen_floatdisf2_internal2 (operands[1], label));
5222 emit_label (label);
5223 }
5224 emit_insn (gen_floatdisf2_internal1 (operands[0], operands[1]));
5225 DONE;
5226 }")
5227
5228 ;; This is not IEEE compliant if rounding mode is "round to nearest".
5229 ;; If the DI->DF conversion is inexact, then it's possible to suffer
5230 ;; from double rounding.
5231 (define_insn_and_split "floatdisf2_internal1"
5232 [(set (match_operand:SF 0 "gpc_reg_operand" "=f")
5233 (float:SF (match_operand:DI 1 "gpc_reg_operand" "*f")))
5234 (clobber (match_scratch:DF 2 "=f"))]
5235 "TARGET_POWERPC64 && TARGET_HARD_FLOAT && TARGET_FPRS"
5236 "#"
5237 "&& reload_completed"
5238 [(set (match_dup 2)
5239 (float:DF (match_dup 1)))
5240 (set (match_dup 0)
5241 (float_truncate:SF (match_dup 2)))]
5242 "")
5243
5244 ;; Twiddles bits to avoid double rounding.
5245 ;; Bits that might be truncated when converting to DFmode are replaced
5246 ;; by a bit that won't be lost at that stage, but is below the SFmode
5247 ;; rounding position.
5248 (define_expand "floatdisf2_internal2"
5249 [(parallel [(set (match_dup 4)
5250 (compare:CC (and:DI (match_operand:DI 0 "" "")
5251 (const_int 2047))
5252 (const_int 0)))
5253 (set (match_dup 2) (and:DI (match_dup 0) (const_int 2047)))
5254 (clobber (match_scratch:CC 7 ""))])
5255 (set (match_dup 3) (ashiftrt:DI (match_dup 0) (const_int 53)))
5256 (set (match_dup 3) (plus:DI (match_dup 3) (const_int 1)))
5257 (set (pc) (if_then_else (eq (match_dup 4) (const_int 0))
5258 (label_ref (match_operand:DI 1 "" ""))
5259 (pc)))
5260 (set (match_dup 5) (compare:CCUNS (match_dup 3) (const_int 2)))
5261 (set (pc) (if_then_else (ltu (match_dup 5) (const_int 0))
5262 (label_ref (match_dup 1))
5263 (pc)))
5264 (set (match_dup 0) (xor:DI (match_dup 0) (match_dup 2)))
5265 (set (match_dup 0) (ior:DI (match_dup 0) (const_int 2048)))]
5266 "TARGET_POWERPC64 && TARGET_HARD_FLOAT && TARGET_FPRS"
5267 "
5268 {
5269 operands[2] = gen_reg_rtx (DImode);
5270 operands[3] = gen_reg_rtx (DImode);
5271 operands[4] = gen_reg_rtx (CCmode);
5272 operands[5] = gen_reg_rtx (CCUNSmode);
5273 }")
5274 \f
5275 ;; Define the DImode operations that can be done in a small number
5276 ;; of instructions. The & constraints are to prevent the register
5277 ;; allocator from allocating registers that overlap with the inputs
5278 ;; (for example, having an input in 7,8 and an output in 6,7). We
5279 ;; also allow for the output being the same as one of the inputs.
5280
5281 (define_insn "*adddi3_noppc64"
5282 [(set (match_operand:DI 0 "gpc_reg_operand" "=&r,&r,r,r")
5283 (plus:DI (match_operand:DI 1 "gpc_reg_operand" "%r,r,0,0")
5284 (match_operand:DI 2 "reg_or_short_operand" "r,I,r,I")))]
5285 "! TARGET_POWERPC64"
5286 "*
5287 {
5288 if (WORDS_BIG_ENDIAN)
5289 return (GET_CODE (operands[2])) != CONST_INT
5290 ? \"{a|addc} %L0,%L1,%L2\;{ae|adde} %0,%1,%2\"
5291 : \"{ai|addic} %L0,%L1,%2\;{a%G2e|add%G2e} %0,%1\";
5292 else
5293 return (GET_CODE (operands[2])) != CONST_INT
5294 ? \"{a|addc} %0,%1,%2\;{ae|adde} %L0,%L1,%L2\"
5295 : \"{ai|addic} %0,%1,%2\;{a%G2e|add%G2e} %L0,%L1\";
5296 }"
5297 [(set_attr "length" "8")])
5298
5299 (define_insn "*subdi3_noppc64"
5300 [(set (match_operand:DI 0 "gpc_reg_operand" "=&r,&r,r,r,r")
5301 (minus:DI (match_operand:DI 1 "reg_or_short_operand" "r,I,0,r,I")
5302 (match_operand:DI 2 "gpc_reg_operand" "r,r,r,0,0")))]
5303 "! TARGET_POWERPC64"
5304 "*
5305 {
5306 if (WORDS_BIG_ENDIAN)
5307 return (GET_CODE (operands[1]) != CONST_INT)
5308 ? \"{sf|subfc} %L0,%L2,%L1\;{sfe|subfe} %0,%2,%1\"
5309 : \"{sfi|subfic} %L0,%L2,%1\;{sf%G1e|subf%G1e} %0,%2\";
5310 else
5311 return (GET_CODE (operands[1]) != CONST_INT)
5312 ? \"{sf|subfc} %0,%2,%1\;{sfe|subfe} %L0,%L2,%L1\"
5313 : \"{sfi|subfic} %0,%2,%1\;{sf%G1e|subf%G1e} %L0,%L2\";
5314 }"
5315 [(set_attr "length" "8")])
5316
5317 (define_insn "*negdi2_noppc64"
5318 [(set (match_operand:DI 0 "gpc_reg_operand" "=&r,r")
5319 (neg:DI (match_operand:DI 1 "gpc_reg_operand" "r,0")))]
5320 "! TARGET_POWERPC64"
5321 "*
5322 {
5323 return (WORDS_BIG_ENDIAN)
5324 ? \"{sfi|subfic} %L0,%L1,0\;{sfze|subfze} %0,%1\"
5325 : \"{sfi|subfic} %0,%1,0\;{sfze|subfze} %L0,%L1\";
5326 }"
5327 [(set_attr "length" "8")])
5328
5329 (define_expand "mulsidi3"
5330 [(set (match_operand:DI 0 "gpc_reg_operand" "")
5331 (mult:DI (sign_extend:DI (match_operand:SI 1 "gpc_reg_operand" ""))
5332 (sign_extend:DI (match_operand:SI 2 "gpc_reg_operand" ""))))]
5333 "! TARGET_POWERPC64"
5334 "
5335 {
5336 if (! TARGET_POWER && ! TARGET_POWERPC)
5337 {
5338 emit_move_insn (gen_rtx_REG (SImode, 3), operands[1]);
5339 emit_move_insn (gen_rtx_REG (SImode, 4), operands[2]);
5340 emit_insn (gen_mull_call ());
5341 if (WORDS_BIG_ENDIAN)
5342 emit_move_insn (operands[0], gen_rtx_REG (DImode, 3));
5343 else
5344 {
5345 emit_move_insn (operand_subword (operands[0], 0, 0, DImode),
5346 gen_rtx_REG (SImode, 3));
5347 emit_move_insn (operand_subword (operands[0], 1, 0, DImode),
5348 gen_rtx_REG (SImode, 4));
5349 }
5350 DONE;
5351 }
5352 else if (TARGET_POWER)
5353 {
5354 emit_insn (gen_mulsidi3_mq (operands[0], operands[1], operands[2]));
5355 DONE;
5356 }
5357 }")
5358
5359 (define_insn "mulsidi3_mq"
5360 [(set (match_operand:DI 0 "gpc_reg_operand" "=r")
5361 (mult:DI (sign_extend:DI (match_operand:SI 1 "gpc_reg_operand" "%r"))
5362 (sign_extend:DI (match_operand:SI 2 "gpc_reg_operand" "r"))))
5363 (clobber (match_scratch:SI 3 "=q"))]
5364 "TARGET_POWER"
5365 "mul %0,%1,%2\;mfmq %L0"
5366 [(set_attr "type" "imul")
5367 (set_attr "length" "8")])
5368
5369 (define_insn "*mulsidi3_no_mq"
5370 [(set (match_operand:DI 0 "gpc_reg_operand" "=&r")
5371 (mult:DI (sign_extend:DI (match_operand:SI 1 "gpc_reg_operand" "%r"))
5372 (sign_extend:DI (match_operand:SI 2 "gpc_reg_operand" "r"))))]
5373 "TARGET_POWERPC && ! TARGET_POWER && ! TARGET_POWERPC64"
5374 "*
5375 {
5376 return (WORDS_BIG_ENDIAN)
5377 ? \"mulhw %0,%1,%2\;mullw %L0,%1,%2\"
5378 : \"mulhw %L0,%1,%2\;mullw %0,%1,%2\";
5379 }"
5380 [(set_attr "type" "imul")
5381 (set_attr "length" "8")])
5382
5383 (define_split
5384 [(set (match_operand:DI 0 "gpc_reg_operand" "")
5385 (mult:DI (sign_extend:DI (match_operand:SI 1 "gpc_reg_operand" ""))
5386 (sign_extend:DI (match_operand:SI 2 "gpc_reg_operand" ""))))]
5387 "TARGET_POWERPC && ! TARGET_POWERPC64 && reload_completed"
5388 [(set (match_dup 3)
5389 (truncate:SI
5390 (lshiftrt:DI (mult:DI (sign_extend:DI (match_dup 1))
5391 (sign_extend:DI (match_dup 2)))
5392 (const_int 32))))
5393 (set (match_dup 4)
5394 (mult:SI (match_dup 1)
5395 (match_dup 2)))]
5396 "
5397 {
5398 int endian = (WORDS_BIG_ENDIAN == 0);
5399 operands[3] = operand_subword (operands[0], endian, 0, DImode);
5400 operands[4] = operand_subword (operands[0], 1 - endian, 0, DImode);
5401 }")
5402
5403 (define_expand "umulsidi3"
5404 [(set (match_operand:DI 0 "gpc_reg_operand" "")
5405 (mult:DI (zero_extend:DI (match_operand:SI 1 "gpc_reg_operand" ""))
5406 (zero_extend:DI (match_operand:SI 2 "gpc_reg_operand" ""))))]
5407 "TARGET_POWERPC && ! TARGET_POWERPC64"
5408 "
5409 {
5410 if (TARGET_POWER)
5411 {
5412 emit_insn (gen_umulsidi3_mq (operands[0], operands[1], operands[2]));
5413 DONE;
5414 }
5415 }")
5416
5417 (define_insn "umulsidi3_mq"
5418 [(set (match_operand:DI 0 "gpc_reg_operand" "=&r")
5419 (mult:DI (zero_extend:DI (match_operand:SI 1 "gpc_reg_operand" "%r"))
5420 (zero_extend:DI (match_operand:SI 2 "gpc_reg_operand" "r"))))
5421 (clobber (match_scratch:SI 3 "=q"))]
5422 "TARGET_POWERPC && TARGET_POWER"
5423 "*
5424 {
5425 return (WORDS_BIG_ENDIAN)
5426 ? \"mulhwu %0,%1,%2\;mullw %L0,%1,%2\"
5427 : \"mulhwu %L0,%1,%2\;mullw %0,%1,%2\";
5428 }"
5429 [(set_attr "type" "imul")
5430 (set_attr "length" "8")])
5431
5432 (define_insn "*umulsidi3_no_mq"
5433 [(set (match_operand:DI 0 "gpc_reg_operand" "=&r")
5434 (mult:DI (zero_extend:DI (match_operand:SI 1 "gpc_reg_operand" "%r"))
5435 (zero_extend:DI (match_operand:SI 2 "gpc_reg_operand" "r"))))]
5436 "TARGET_POWERPC && ! TARGET_POWER && ! TARGET_POWERPC64"
5437 "*
5438 {
5439 return (WORDS_BIG_ENDIAN)
5440 ? \"mulhwu %0,%1,%2\;mullw %L0,%1,%2\"
5441 : \"mulhwu %L0,%1,%2\;mullw %0,%1,%2\";
5442 }"
5443 [(set_attr "type" "imul")
5444 (set_attr "length" "8")])
5445
5446 (define_split
5447 [(set (match_operand:DI 0 "gpc_reg_operand" "")
5448 (mult:DI (zero_extend:DI (match_operand:SI 1 "gpc_reg_operand" ""))
5449 (zero_extend:DI (match_operand:SI 2 "gpc_reg_operand" ""))))]
5450 "TARGET_POWERPC && ! TARGET_POWERPC64 && reload_completed"
5451 [(set (match_dup 3)
5452 (truncate:SI
5453 (lshiftrt:DI (mult:DI (zero_extend:DI (match_dup 1))
5454 (zero_extend:DI (match_dup 2)))
5455 (const_int 32))))
5456 (set (match_dup 4)
5457 (mult:SI (match_dup 1)
5458 (match_dup 2)))]
5459 "
5460 {
5461 int endian = (WORDS_BIG_ENDIAN == 0);
5462 operands[3] = operand_subword (operands[0], endian, 0, DImode);
5463 operands[4] = operand_subword (operands[0], 1 - endian, 0, DImode);
5464 }")
5465
5466 (define_expand "smulsi3_highpart"
5467 [(set (match_operand:SI 0 "gpc_reg_operand" "")
5468 (truncate:SI
5469 (lshiftrt:DI (mult:DI (sign_extend:DI
5470 (match_operand:SI 1 "gpc_reg_operand" "%r"))
5471 (sign_extend:DI
5472 (match_operand:SI 2 "gpc_reg_operand" "r")))
5473 (const_int 32))))]
5474 ""
5475 "
5476 {
5477 if (! TARGET_POWER && ! TARGET_POWERPC)
5478 {
5479 emit_move_insn (gen_rtx_REG (SImode, 3), operands[1]);
5480 emit_move_insn (gen_rtx_REG (SImode, 4), operands[2]);
5481 emit_insn (gen_mulh_call ());
5482 emit_move_insn (operands[0], gen_rtx_REG (SImode, 3));
5483 DONE;
5484 }
5485 else if (TARGET_POWER)
5486 {
5487 emit_insn (gen_smulsi3_highpart_mq (operands[0], operands[1], operands[2]));
5488 DONE;
5489 }
5490 }")
5491
5492 (define_insn "smulsi3_highpart_mq"
5493 [(set (match_operand:SI 0 "gpc_reg_operand" "=r")
5494 (truncate:SI
5495 (lshiftrt:DI (mult:DI (sign_extend:DI
5496 (match_operand:SI 1 "gpc_reg_operand" "%r"))
5497 (sign_extend:DI
5498 (match_operand:SI 2 "gpc_reg_operand" "r")))
5499 (const_int 32))))
5500 (clobber (match_scratch:SI 3 "=q"))]
5501 "TARGET_POWER"
5502 "mul %0,%1,%2"
5503 [(set_attr "type" "imul")])
5504
5505 (define_insn "*smulsi3_highpart_no_mq"
5506 [(set (match_operand:SI 0 "gpc_reg_operand" "=r")
5507 (truncate:SI
5508 (lshiftrt:DI (mult:DI (sign_extend:DI
5509 (match_operand:SI 1 "gpc_reg_operand" "%r"))
5510 (sign_extend:DI
5511 (match_operand:SI 2 "gpc_reg_operand" "r")))
5512 (const_int 32))))]
5513 "TARGET_POWERPC && ! TARGET_POWER"
5514 "mulhw %0,%1,%2"
5515 [(set_attr "type" "imul")])
5516
5517 (define_expand "umulsi3_highpart"
5518 [(set (match_operand:SI 0 "gpc_reg_operand" "")
5519 (truncate:SI
5520 (lshiftrt:DI (mult:DI (zero_extend:DI
5521 (match_operand:SI 1 "gpc_reg_operand" ""))
5522 (zero_extend:DI
5523 (match_operand:SI 2 "gpc_reg_operand" "")))
5524 (const_int 32))))]
5525 "TARGET_POWERPC"
5526 "
5527 {
5528 if (TARGET_POWER)
5529 {
5530 emit_insn (gen_umulsi3_highpart_mq (operands[0], operands[1], operands[2]));
5531 DONE;
5532 }
5533 }")
5534
5535 (define_insn "umulsi3_highpart_mq"
5536 [(set (match_operand:SI 0 "gpc_reg_operand" "=r")
5537 (truncate:SI
5538 (lshiftrt:DI (mult:DI (zero_extend:DI
5539 (match_operand:SI 1 "gpc_reg_operand" "%r"))
5540 (zero_extend:DI
5541 (match_operand:SI 2 "gpc_reg_operand" "r")))
5542 (const_int 32))))
5543 (clobber (match_scratch:SI 3 "=q"))]
5544 "TARGET_POWERPC && TARGET_POWER"
5545 "mulhwu %0,%1,%2"
5546 [(set_attr "type" "imul")])
5547
5548 (define_insn "*umulsi3_highpart_no_mq"
5549 [(set (match_operand:SI 0 "gpc_reg_operand" "=r")
5550 (truncate:SI
5551 (lshiftrt:DI (mult:DI (zero_extend:DI
5552 (match_operand:SI 1 "gpc_reg_operand" "%r"))
5553 (zero_extend:DI
5554 (match_operand:SI 2 "gpc_reg_operand" "r")))
5555 (const_int 32))))]
5556 "TARGET_POWERPC && ! TARGET_POWER"
5557 "mulhwu %0,%1,%2"
5558 [(set_attr "type" "imul")])
5559
5560 ;; If operands 0 and 2 are in the same register, we have a problem. But
5561 ;; operands 0 and 1 (the usual case) can be in the same register. That's
5562 ;; why we have the strange constraints below.
5563 (define_insn "ashldi3_power"
5564 [(set (match_operand:DI 0 "gpc_reg_operand" "=r,r,r,&r")
5565 (ashift:DI (match_operand:DI 1 "gpc_reg_operand" "r,r,0,r")
5566 (match_operand:SI 2 "reg_or_cint_operand" "M,i,r,r")))
5567 (clobber (match_scratch:SI 3 "=X,q,q,q"))]
5568 "TARGET_POWER"
5569 "@
5570 {sli|slwi} %0,%L1,%h2\;{cal %L0,0(0)|li %L0,0}
5571 sl%I2q %L0,%L1,%h2\;sll%I2q %0,%1,%h2
5572 sl%I2q %L0,%L1,%h2\;sll%I2q %0,%1,%h2
5573 sl%I2q %L0,%L1,%h2\;sll%I2q %0,%1,%h2"
5574 [(set_attr "length" "8")])
5575
5576 (define_insn "lshrdi3_power"
5577 [(set (match_operand:DI 0 "gpc_reg_operand" "=r,r,r,&r")
5578 (lshiftrt:DI (match_operand:DI 1 "gpc_reg_operand" "r,r,0,r")
5579 (match_operand:SI 2 "reg_or_cint_operand" "M,i,r,r")))
5580 (clobber (match_scratch:SI 3 "=X,q,q,q"))]
5581 "TARGET_POWER"
5582 "@
5583 {s%A2i|s%A2wi} %L0,%1,%h2\;{cal %0,0(0)|li %0,0}
5584 sr%I2q %0,%1,%h2\;srl%I2q %L0,%L1,%h2
5585 sr%I2q %0,%1,%h2\;srl%I2q %L0,%L1,%h2
5586 sr%I2q %0,%1,%h2\;srl%I2q %L0,%L1,%h2"
5587 [(set_attr "length" "8")])
5588
5589 ;; Shift by a variable amount is too complex to be worth open-coding. We
5590 ;; just handle shifts by constants.
5591 (define_insn "ashrdi3_power"
5592 [(set (match_operand:DI 0 "gpc_reg_operand" "=&r,r")
5593 (ashiftrt:DI (match_operand:DI 1 "gpc_reg_operand" "r,r")
5594 (match_operand:SI 2 "const_int_operand" "M,i")))
5595 (clobber (match_scratch:SI 3 "=X,q"))]
5596 "TARGET_POWER"
5597 "@
5598 {srai|srawi} %0,%1,31\;{srai|srawi} %L0,%1,%h2
5599 sraiq %0,%1,%h2\;srliq %L0,%L1,%h2"
5600 [(set_attr "length" "8")])
5601
5602 (define_insn "ashrdi3_no_power"
5603 [(set (match_operand:DI 0 "gpc_reg_operand" "=&r,&r")
5604 (ashiftrt:DI (match_operand:DI 1 "gpc_reg_operand" "r,r")
5605 (match_operand:SI 2 "const_int_operand" "M,i")))]
5606 "TARGET_32BIT && !TARGET_POWER"
5607 "@
5608 {srai|srawi} %0,%1,31\;{srai|srawi} %L0,%1,%h2
5609 {sri|srwi} %L0,%L1,%h2\;insrwi %L0,%1,%h2,0\;{srai|srawi} %0,%1,%h2"
5610 [(set_attr "length" "8,12")])
5611 \f
5612 ;; PowerPC64 DImode operations.
5613
5614 (define_expand "adddi3"
5615 [(set (match_operand:DI 0 "gpc_reg_operand" "")
5616 (plus:DI (match_operand:DI 1 "gpc_reg_operand" "")
5617 (match_operand:DI 2 "reg_or_add_cint64_operand" "")))]
5618 ""
5619 "
5620 {
5621 if (! TARGET_POWERPC64)
5622 {
5623 if (non_short_cint_operand (operands[2], DImode))
5624 FAIL;
5625 }
5626 else
5627 if (GET_CODE (operands[2]) == CONST_INT
5628 && ! add_operand (operands[2], DImode))
5629 {
5630 rtx tmp = ((no_new_pseudos || rtx_equal_p (operands[0], operands[1]))
5631 ? operands[0] : gen_reg_rtx (DImode));
5632
5633 HOST_WIDE_INT val = INTVAL (operands[2]);
5634 HOST_WIDE_INT low = ((val & 0xffff) ^ 0x8000) - 0x8000;
5635 HOST_WIDE_INT rest = trunc_int_for_mode (val - low, DImode);
5636
5637 if (!CONST_OK_FOR_LETTER_P (rest, 'L'))
5638 FAIL;
5639
5640 /* The ordering here is important for the prolog expander.
5641 When space is allocated from the stack, adding 'low' first may
5642 produce a temporary deallocation (which would be bad). */
5643 emit_insn (gen_adddi3 (tmp, operands[1], GEN_INT (rest)));
5644 emit_insn (gen_adddi3 (operands[0], tmp, GEN_INT (low)));
5645 DONE;
5646 }
5647 }")
5648
5649 ;; Discourage ai/addic because of carry but provide it in an alternative
5650 ;; allowing register zero as source.
5651
5652 (define_insn "*adddi3_internal1"
5653 [(set (match_operand:DI 0 "gpc_reg_operand" "=r,r,?r,r")
5654 (plus:DI (match_operand:DI 1 "gpc_reg_operand" "%r,b,r,b")
5655 (match_operand:DI 2 "add_operand" "r,I,I,L")))]
5656 "TARGET_POWERPC64"
5657 "@
5658 add %0,%1,%2
5659 addi %0,%1,%2
5660 addic %0,%1,%2
5661 addis %0,%1,%v2")
5662
5663 (define_insn "*adddi3_internal2"
5664 [(set (match_operand:CC 0 "cc_reg_operand" "=x,x,?y,?y")
5665 (compare:CC (plus:DI (match_operand:DI 1 "gpc_reg_operand" "%r,r,r,r")
5666 (match_operand:DI 2 "reg_or_short_operand" "r,I,r,I"))
5667 (const_int 0)))
5668 (clobber (match_scratch:DI 3 "=r,r,r,r"))]
5669 "TARGET_POWERPC64"
5670 "@
5671 add. %3,%1,%2
5672 addic. %3,%1,%2
5673 #
5674 #"
5675 [(set_attr "type" "fast_compare,compare,compare,compare")
5676 (set_attr "length" "4,4,8,8")])
5677
5678 (define_split
5679 [(set (match_operand:CC 0 "cc_reg_not_cr0_operand" "")
5680 (compare:CC (plus:DI (match_operand:DI 1 "gpc_reg_operand" "")
5681 (match_operand:DI 2 "reg_or_short_operand" ""))
5682 (const_int 0)))
5683 (clobber (match_scratch:DI 3 ""))]
5684 "TARGET_POWERPC64 && reload_completed"
5685 [(set (match_dup 3)
5686 (plus:DI (match_dup 1) (match_dup 2)))
5687 (set (match_dup 0)
5688 (compare:CC (match_dup 3)
5689 (const_int 0)))]
5690 "")
5691
5692 (define_insn "*adddi3_internal3"
5693 [(set (match_operand:CC 3 "cc_reg_operand" "=x,x,?y,?y")
5694 (compare:CC (plus:DI (match_operand:DI 1 "gpc_reg_operand" "%r,r,r,r")
5695 (match_operand:DI 2 "reg_or_short_operand" "r,I,r,I"))
5696 (const_int 0)))
5697 (set (match_operand:DI 0 "gpc_reg_operand" "=r,r,r,r")
5698 (plus:DI (match_dup 1) (match_dup 2)))]
5699 "TARGET_POWERPC64"
5700 "@
5701 add. %0,%1,%2
5702 addic. %0,%1,%2
5703 #
5704 #"
5705 [(set_attr "type" "fast_compare,compare,compare,compare")
5706 (set_attr "length" "4,4,8,8")])
5707
5708 (define_split
5709 [(set (match_operand:CC 3 "cc_reg_not_cr0_operand" "")
5710 (compare:CC (plus:DI (match_operand:DI 1 "gpc_reg_operand" "")
5711 (match_operand:DI 2 "reg_or_short_operand" ""))
5712 (const_int 0)))
5713 (set (match_operand:DI 0 "gpc_reg_operand" "")
5714 (plus:DI (match_dup 1) (match_dup 2)))]
5715 "TARGET_POWERPC64 && reload_completed"
5716 [(set (match_dup 0)
5717 (plus:DI (match_dup 1) (match_dup 2)))
5718 (set (match_dup 3)
5719 (compare:CC (match_dup 0)
5720 (const_int 0)))]
5721 "")
5722
5723 ;; Split an add that we can't do in one insn into two insns, each of which
5724 ;; does one 16-bit part. This is used by combine. Note that the low-order
5725 ;; add should be last in case the result gets used in an address.
5726
5727 (define_split
5728 [(set (match_operand:DI 0 "gpc_reg_operand" "")
5729 (plus:DI (match_operand:DI 1 "gpc_reg_operand" "")
5730 (match_operand:DI 2 "non_add_cint_operand" "")))]
5731 "TARGET_POWERPC64"
5732 [(set (match_dup 0) (plus:DI (match_dup 1) (match_dup 3)))
5733 (set (match_dup 0) (plus:DI (match_dup 0) (match_dup 4)))]
5734 "
5735 {
5736 HOST_WIDE_INT val = INTVAL (operands[2]);
5737 HOST_WIDE_INT low = ((val & 0xffff) ^ 0x8000) - 0x8000;
5738 HOST_WIDE_INT rest = trunc_int_for_mode (val - low, DImode);
5739
5740 operands[4] = GEN_INT (low);
5741 if (CONST_OK_FOR_LETTER_P (rest, 'L'))
5742 operands[3] = GEN_INT (rest);
5743 else if (! no_new_pseudos)
5744 {
5745 operands[3] = gen_reg_rtx (DImode);
5746 emit_move_insn (operands[3], operands[2]);
5747 emit_insn (gen_adddi3 (operands[0], operands[1], operands[3]));
5748 DONE;
5749 }
5750 else
5751 FAIL;
5752 }")
5753
5754 (define_insn "one_cmpldi2"
5755 [(set (match_operand:DI 0 "gpc_reg_operand" "=r")
5756 (not:DI (match_operand:DI 1 "gpc_reg_operand" "r")))]
5757 "TARGET_POWERPC64"
5758 "nor %0,%1,%1")
5759
5760 (define_insn ""
5761 [(set (match_operand:CC 0 "cc_reg_operand" "=x,?y")
5762 (compare:CC (not:DI (match_operand:DI 1 "gpc_reg_operand" "r,r"))
5763 (const_int 0)))
5764 (clobber (match_scratch:DI 2 "=r,r"))]
5765 "TARGET_POWERPC64"
5766 "@
5767 nor. %2,%1,%1
5768 #"
5769 [(set_attr "type" "compare")
5770 (set_attr "length" "4,8")])
5771
5772 (define_split
5773 [(set (match_operand:CC 0 "cc_reg_not_cr0_operand" "")
5774 (compare:CC (not:DI (match_operand:DI 1 "gpc_reg_operand" ""))
5775 (const_int 0)))
5776 (clobber (match_scratch:DI 2 ""))]
5777 "TARGET_POWERPC64 && reload_completed"
5778 [(set (match_dup 2)
5779 (not:DI (match_dup 1)))
5780 (set (match_dup 0)
5781 (compare:CC (match_dup 2)
5782 (const_int 0)))]
5783 "")
5784
5785 (define_insn ""
5786 [(set (match_operand:CC 2 "cc_reg_operand" "=x,?y")
5787 (compare:CC (not:DI (match_operand:DI 1 "gpc_reg_operand" "r,r"))
5788 (const_int 0)))
5789 (set (match_operand:DI 0 "gpc_reg_operand" "=r,r")
5790 (not:DI (match_dup 1)))]
5791 "TARGET_POWERPC64"
5792 "@
5793 nor. %0,%1,%1
5794 #"
5795 [(set_attr "type" "compare")
5796 (set_attr "length" "4,8")])
5797
5798 (define_split
5799 [(set (match_operand:CC 2 "cc_reg_not_cr0_operand" "")
5800 (compare:CC (not:DI (match_operand:DI 1 "gpc_reg_operand" ""))
5801 (const_int 0)))
5802 (set (match_operand:DI 0 "gpc_reg_operand" "")
5803 (not:DI (match_dup 1)))]
5804 "TARGET_POWERPC64 && reload_completed"
5805 [(set (match_dup 0)
5806 (not:DI (match_dup 1)))
5807 (set (match_dup 2)
5808 (compare:CC (match_dup 0)
5809 (const_int 0)))]
5810 "")
5811
5812 (define_insn ""
5813 [(set (match_operand:DI 0 "gpc_reg_operand" "=r,r")
5814 (minus:DI (match_operand:DI 1 "reg_or_short_operand" "r,I")
5815 (match_operand:DI 2 "gpc_reg_operand" "r,r")))]
5816 "TARGET_POWERPC64"
5817 "@
5818 subf %0,%2,%1
5819 subfic %0,%2,%1")
5820
5821 (define_insn ""
5822 [(set (match_operand:CC 0 "cc_reg_operand" "=x,?y")
5823 (compare:CC (minus:DI (match_operand:DI 1 "gpc_reg_operand" "r,r")
5824 (match_operand:DI 2 "gpc_reg_operand" "r,r"))
5825 (const_int 0)))
5826 (clobber (match_scratch:DI 3 "=r,r"))]
5827 "TARGET_POWERPC64"
5828 "@
5829 subf. %3,%2,%1
5830 #"
5831 [(set_attr "type" "fast_compare")
5832 (set_attr "length" "4,8")])
5833
5834 (define_split
5835 [(set (match_operand:CC 0 "cc_reg_not_cr0_operand" "")
5836 (compare:CC (minus:DI (match_operand:DI 1 "gpc_reg_operand" "")
5837 (match_operand:DI 2 "gpc_reg_operand" ""))
5838 (const_int 0)))
5839 (clobber (match_scratch:DI 3 ""))]
5840 "TARGET_POWERPC64 && reload_completed"
5841 [(set (match_dup 3)
5842 (minus:DI (match_dup 1) (match_dup 2)))
5843 (set (match_dup 0)
5844 (compare:CC (match_dup 3)
5845 (const_int 0)))]
5846 "")
5847
5848 (define_insn ""
5849 [(set (match_operand:CC 3 "cc_reg_operand" "=x,?y")
5850 (compare:CC (minus:DI (match_operand:DI 1 "gpc_reg_operand" "r,r")
5851 (match_operand:DI 2 "gpc_reg_operand" "r,r"))
5852 (const_int 0)))
5853 (set (match_operand:DI 0 "gpc_reg_operand" "=r,r")
5854 (minus:DI (match_dup 1) (match_dup 2)))]
5855 "TARGET_POWERPC64"
5856 "@
5857 subf. %0,%2,%1
5858 #"
5859 [(set_attr "type" "fast_compare")
5860 (set_attr "length" "4,8")])
5861
5862 (define_split
5863 [(set (match_operand:CC 3 "cc_reg_not_cr0_operand" "")
5864 (compare:CC (minus:DI (match_operand:DI 1 "gpc_reg_operand" "")
5865 (match_operand:DI 2 "gpc_reg_operand" ""))
5866 (const_int 0)))
5867 (set (match_operand:DI 0 "gpc_reg_operand" "")
5868 (minus:DI (match_dup 1) (match_dup 2)))]
5869 "TARGET_POWERPC64 && reload_completed"
5870 [(set (match_dup 0)
5871 (minus:DI (match_dup 1) (match_dup 2)))
5872 (set (match_dup 3)
5873 (compare:CC (match_dup 0)
5874 (const_int 0)))]
5875 "")
5876
5877 (define_expand "subdi3"
5878 [(set (match_operand:DI 0 "gpc_reg_operand" "")
5879 (minus:DI (match_operand:DI 1 "reg_or_short_operand" "")
5880 (match_operand:DI 2 "reg_or_sub_cint64_operand" "")))]
5881 ""
5882 "
5883 {
5884 if (GET_CODE (operands[2]) == CONST_INT)
5885 {
5886 emit_insn (gen_adddi3 (operands[0], operands[1],
5887 negate_rtx (DImode, operands[2])));
5888 DONE;
5889 }
5890 }")
5891
5892 (define_insn_and_split "absdi2"
5893 [(set (match_operand:DI 0 "gpc_reg_operand" "=&r,r")
5894 (abs:DI (match_operand:DI 1 "gpc_reg_operand" "r,0")))
5895 (clobber (match_scratch:DI 2 "=&r,&r"))]
5896 "TARGET_POWERPC64"
5897 "#"
5898 "&& reload_completed"
5899 [(set (match_dup 2) (ashiftrt:DI (match_dup 1) (const_int 63)))
5900 (set (match_dup 0) (xor:DI (match_dup 2) (match_dup 1)))
5901 (set (match_dup 0) (minus:DI (match_dup 0) (match_dup 2)))]
5902 "")
5903
5904 (define_insn_and_split "*nabsdi2"
5905 [(set (match_operand:DI 0 "gpc_reg_operand" "=&r,r")
5906 (neg:DI (abs:DI (match_operand:DI 1 "gpc_reg_operand" "r,0"))))
5907 (clobber (match_scratch:DI 2 "=&r,&r"))]
5908 "TARGET_POWERPC64"
5909 "#"
5910 "&& reload_completed"
5911 [(set (match_dup 2) (ashiftrt:DI (match_dup 1) (const_int 63)))
5912 (set (match_dup 0) (xor:DI (match_dup 2) (match_dup 1)))
5913 (set (match_dup 0) (minus:DI (match_dup 2) (match_dup 0)))]
5914 "")
5915
5916 (define_expand "negdi2"
5917 [(set (match_operand:DI 0 "gpc_reg_operand" "")
5918 (neg:DI (match_operand:DI 1 "gpc_reg_operand" "")))]
5919 ""
5920 "")
5921
5922 (define_insn ""
5923 [(set (match_operand:DI 0 "gpc_reg_operand" "=r")
5924 (neg:DI (match_operand:DI 1 "gpc_reg_operand" "r")))]
5925 "TARGET_POWERPC64"
5926 "neg %0,%1")
5927
5928 (define_insn ""
5929 [(set (match_operand:CC 0 "cc_reg_operand" "=x,?y")
5930 (compare:CC (neg:DI (match_operand:DI 1 "gpc_reg_operand" "r,r"))
5931 (const_int 0)))
5932 (clobber (match_scratch:DI 2 "=r,r"))]
5933 "TARGET_POWERPC64"
5934 "@
5935 neg. %2,%1
5936 #"
5937 [(set_attr "type" "fast_compare")
5938 (set_attr "length" "4,8")])
5939
5940 (define_split
5941 [(set (match_operand:CC 0 "cc_reg_not_cr0_operand" "")
5942 (compare:CC (neg:DI (match_operand:DI 1 "gpc_reg_operand" ""))
5943 (const_int 0)))
5944 (clobber (match_scratch:DI 2 ""))]
5945 "TARGET_POWERPC64 && reload_completed"
5946 [(set (match_dup 2)
5947 (neg:DI (match_dup 1)))
5948 (set (match_dup 0)
5949 (compare:CC (match_dup 2)
5950 (const_int 0)))]
5951 "")
5952
5953 (define_insn ""
5954 [(set (match_operand:CC 2 "cc_reg_operand" "=x,?y")
5955 (compare:CC (neg:DI (match_operand:DI 1 "gpc_reg_operand" "r,r"))
5956 (const_int 0)))
5957 (set (match_operand:DI 0 "gpc_reg_operand" "=r,r")
5958 (neg:DI (match_dup 1)))]
5959 "TARGET_POWERPC64"
5960 "@
5961 neg. %0,%1
5962 #"
5963 [(set_attr "type" "fast_compare")
5964 (set_attr "length" "4,8")])
5965
5966 (define_split
5967 [(set (match_operand:CC 2 "cc_reg_not_cr0_operand" "")
5968 (compare:CC (neg:DI (match_operand:DI 1 "gpc_reg_operand" ""))
5969 (const_int 0)))
5970 (set (match_operand:DI 0 "gpc_reg_operand" "")
5971 (neg:DI (match_dup 1)))]
5972 "TARGET_POWERPC64 && reload_completed"
5973 [(set (match_dup 0)
5974 (neg:DI (match_dup 1)))
5975 (set (match_dup 2)
5976 (compare:CC (match_dup 0)
5977 (const_int 0)))]
5978 "")
5979
5980 (define_insn "clzdi2"
5981 [(set (match_operand:DI 0 "gpc_reg_operand" "=r")
5982 (clz:DI (match_operand:DI 1 "gpc_reg_operand" "r")))]
5983 "TARGET_POWERPC64"
5984 "cntlzd %0,%1")
5985
5986 (define_expand "ctzdi2"
5987 [(set (match_dup 2)
5988 (neg:DI (match_operand:DI 1 "gpc_reg_operand" "r")))
5989 (parallel [(set (match_dup 3) (and:DI (match_dup 1)
5990 (match_dup 2)))
5991 (clobber (scratch:CC))])
5992 (set (match_dup 4) (clz:DI (match_dup 3)))
5993 (set (match_operand:DI 0 "gpc_reg_operand" "=r")
5994 (minus:DI (const_int 63) (match_dup 4)))]
5995 "TARGET_POWERPC64"
5996 {
5997 operands[2] = gen_reg_rtx (DImode);
5998 operands[3] = gen_reg_rtx (DImode);
5999 operands[4] = gen_reg_rtx (DImode);
6000 })
6001
6002 (define_expand "ffsdi2"
6003 [(set (match_dup 2)
6004 (neg:DI (match_operand:DI 1 "gpc_reg_operand" "r")))
6005 (parallel [(set (match_dup 3) (and:DI (match_dup 1)
6006 (match_dup 2)))
6007 (clobber (scratch:CC))])
6008 (set (match_dup 4) (clz:DI (match_dup 3)))
6009 (set (match_operand:DI 0 "gpc_reg_operand" "=r")
6010 (minus:DI (const_int 64) (match_dup 4)))]
6011 "TARGET_POWERPC64"
6012 {
6013 operands[2] = gen_reg_rtx (DImode);
6014 operands[3] = gen_reg_rtx (DImode);
6015 operands[4] = gen_reg_rtx (DImode);
6016 })
6017
6018 (define_insn "muldi3"
6019 [(set (match_operand:DI 0 "gpc_reg_operand" "=r")
6020 (mult:DI (match_operand:DI 1 "gpc_reg_operand" "%r")
6021 (match_operand:DI 2 "gpc_reg_operand" "r")))]
6022 "TARGET_POWERPC64"
6023 "mulld %0,%1,%2"
6024 [(set_attr "type" "lmul")])
6025
6026 (define_insn "*muldi3_internal1"
6027 [(set (match_operand:CC 0 "cc_reg_operand" "=x,?y")
6028 (compare:CC (mult:DI (match_operand:DI 1 "gpc_reg_operand" "%r,r")
6029 (match_operand:DI 2 "gpc_reg_operand" "r,r"))
6030 (const_int 0)))
6031 (clobber (match_scratch:DI 3 "=r,r"))]
6032 "TARGET_POWERPC64"
6033 "@
6034 mulld. %3,%1,%2
6035 #"
6036 [(set_attr "type" "lmul_compare")
6037 (set_attr "length" "4,8")])
6038
6039 (define_split
6040 [(set (match_operand:CC 0 "cc_reg_not_cr0_operand" "")
6041 (compare:CC (mult:DI (match_operand:DI 1 "gpc_reg_operand" "")
6042 (match_operand:DI 2 "gpc_reg_operand" ""))
6043 (const_int 0)))
6044 (clobber (match_scratch:DI 3 ""))]
6045 "TARGET_POWERPC64 && reload_completed"
6046 [(set (match_dup 3)
6047 (mult:DI (match_dup 1) (match_dup 2)))
6048 (set (match_dup 0)
6049 (compare:CC (match_dup 3)
6050 (const_int 0)))]
6051 "")
6052
6053 (define_insn "*muldi3_internal2"
6054 [(set (match_operand:CC 3 "cc_reg_operand" "=x,?y")
6055 (compare:CC (mult:DI (match_operand:DI 1 "gpc_reg_operand" "%r,r")
6056 (match_operand:DI 2 "gpc_reg_operand" "r,r"))
6057 (const_int 0)))
6058 (set (match_operand:DI 0 "gpc_reg_operand" "=r,r")
6059 (mult:DI (match_dup 1) (match_dup 2)))]
6060 "TARGET_POWERPC64"
6061 "@
6062 mulld. %0,%1,%2
6063 #"
6064 [(set_attr "type" "lmul_compare")
6065 (set_attr "length" "4,8")])
6066
6067 (define_split
6068 [(set (match_operand:CC 3 "cc_reg_not_cr0_operand" "")
6069 (compare:CC (mult:DI (match_operand:DI 1 "gpc_reg_operand" "")
6070 (match_operand:DI 2 "gpc_reg_operand" ""))
6071 (const_int 0)))
6072 (set (match_operand:DI 0 "gpc_reg_operand" "")
6073 (mult:DI (match_dup 1) (match_dup 2)))]
6074 "TARGET_POWERPC64 && reload_completed"
6075 [(set (match_dup 0)
6076 (mult:DI (match_dup 1) (match_dup 2)))
6077 (set (match_dup 3)
6078 (compare:CC (match_dup 0)
6079 (const_int 0)))]
6080 "")
6081
6082 (define_insn "smuldi3_highpart"
6083 [(set (match_operand:DI 0 "gpc_reg_operand" "=r")
6084 (truncate:DI
6085 (lshiftrt:TI (mult:TI (sign_extend:TI
6086 (match_operand:DI 1 "gpc_reg_operand" "%r"))
6087 (sign_extend:TI
6088 (match_operand:DI 2 "gpc_reg_operand" "r")))
6089 (const_int 64))))]
6090 "TARGET_POWERPC64"
6091 "mulhd %0,%1,%2"
6092 [(set_attr "type" "lmul")])
6093
6094 (define_insn "umuldi3_highpart"
6095 [(set (match_operand:DI 0 "gpc_reg_operand" "=r")
6096 (truncate:DI
6097 (lshiftrt:TI (mult:TI (zero_extend:TI
6098 (match_operand:DI 1 "gpc_reg_operand" "%r"))
6099 (zero_extend:TI
6100 (match_operand:DI 2 "gpc_reg_operand" "r")))
6101 (const_int 64))))]
6102 "TARGET_POWERPC64"
6103 "mulhdu %0,%1,%2"
6104 [(set_attr "type" "lmul")])
6105
6106 (define_expand "divdi3"
6107 [(set (match_operand:DI 0 "gpc_reg_operand" "")
6108 (div:DI (match_operand:DI 1 "gpc_reg_operand" "")
6109 (match_operand:DI 2 "reg_or_cint_operand" "")))]
6110 "TARGET_POWERPC64"
6111 "
6112 {
6113 if (GET_CODE (operands[2]) == CONST_INT
6114 && INTVAL (operands[2]) > 0
6115 && exact_log2 (INTVAL (operands[2])) >= 0)
6116 ;
6117 else
6118 operands[2] = force_reg (DImode, operands[2]);
6119 }")
6120
6121 (define_expand "moddi3"
6122 [(use (match_operand:DI 0 "gpc_reg_operand" ""))
6123 (use (match_operand:DI 1 "gpc_reg_operand" ""))
6124 (use (match_operand:DI 2 "reg_or_cint_operand" ""))]
6125 "TARGET_POWERPC64"
6126 "
6127 {
6128 int i;
6129 rtx temp1;
6130 rtx temp2;
6131
6132 if (GET_CODE (operands[2]) != CONST_INT
6133 || INTVAL (operands[2]) <= 0
6134 || (i = exact_log2 (INTVAL (operands[2]))) < 0)
6135 FAIL;
6136
6137 temp1 = gen_reg_rtx (DImode);
6138 temp2 = gen_reg_rtx (DImode);
6139
6140 emit_insn (gen_divdi3 (temp1, operands[1], operands[2]));
6141 emit_insn (gen_ashldi3 (temp2, temp1, GEN_INT (i)));
6142 emit_insn (gen_subdi3 (operands[0], operands[1], temp2));
6143 DONE;
6144 }")
6145
6146 (define_insn ""
6147 [(set (match_operand:DI 0 "gpc_reg_operand" "=r")
6148 (div:DI (match_operand:DI 1 "gpc_reg_operand" "r")
6149 (match_operand:DI 2 "exact_log2_cint_operand" "N")))]
6150 "TARGET_POWERPC64"
6151 "sradi %0,%1,%p2\;addze %0,%0"
6152 [(set_attr "length" "8")])
6153
6154 (define_insn ""
6155 [(set (match_operand:CC 0 "cc_reg_operand" "=x,?y")
6156 (compare:CC (div:DI (match_operand:DI 1 "gpc_reg_operand" "r,r")
6157 (match_operand:DI 2 "exact_log2_cint_operand" "N,N"))
6158 (const_int 0)))
6159 (clobber (match_scratch:DI 3 "=r,r"))]
6160 "TARGET_POWERPC64"
6161 "@
6162 sradi %3,%1,%p2\;addze. %3,%3
6163 #"
6164 [(set_attr "type" "compare")
6165 (set_attr "length" "8,12")])
6166
6167 (define_split
6168 [(set (match_operand:CC 0 "cc_reg_not_cr0_operand" "")
6169 (compare:CC (div:DI (match_operand:DI 1 "gpc_reg_operand" "")
6170 (match_operand:DI 2 "exact_log2_cint_operand" ""))
6171 (const_int 0)))
6172 (clobber (match_scratch:DI 3 ""))]
6173 "TARGET_POWERPC64 && reload_completed"
6174 [(set (match_dup 3)
6175 (div:DI (match_dup 1) (match_dup 2)))
6176 (set (match_dup 0)
6177 (compare:CC (match_dup 3)
6178 (const_int 0)))]
6179 "")
6180
6181 (define_insn ""
6182 [(set (match_operand:CC 3 "cc_reg_operand" "=x,?y")
6183 (compare:CC (div:DI (match_operand:DI 1 "gpc_reg_operand" "r,r")
6184 (match_operand:DI 2 "exact_log2_cint_operand" "N,N"))
6185 (const_int 0)))
6186 (set (match_operand:DI 0 "gpc_reg_operand" "=r,r")
6187 (div:DI (match_dup 1) (match_dup 2)))]
6188 "TARGET_POWERPC64"
6189 "@
6190 sradi %0,%1,%p2\;addze. %0,%0
6191 #"
6192 [(set_attr "type" "compare")
6193 (set_attr "length" "8,12")])
6194
6195 (define_split
6196 [(set (match_operand:CC 3 "cc_reg_not_cr0_operand" "")
6197 (compare:CC (div:DI (match_operand:DI 1 "gpc_reg_operand" "")
6198 (match_operand:DI 2 "exact_log2_cint_operand" ""))
6199 (const_int 0)))
6200 (set (match_operand:DI 0 "gpc_reg_operand" "")
6201 (div:DI (match_dup 1) (match_dup 2)))]
6202 "TARGET_POWERPC64 && reload_completed"
6203 [(set (match_dup 0)
6204 (div:DI (match_dup 1) (match_dup 2)))
6205 (set (match_dup 3)
6206 (compare:CC (match_dup 0)
6207 (const_int 0)))]
6208 "")
6209
6210 (define_insn ""
6211 [(set (match_operand:DI 0 "gpc_reg_operand" "=r")
6212 (div:DI (match_operand:DI 1 "gpc_reg_operand" "r")
6213 (match_operand:DI 2 "gpc_reg_operand" "r")))]
6214 "TARGET_POWERPC64"
6215 "divd %0,%1,%2"
6216 [(set_attr "type" "ldiv")])
6217
6218 (define_insn "udivdi3"
6219 [(set (match_operand:DI 0 "gpc_reg_operand" "=r")
6220 (udiv:DI (match_operand:DI 1 "gpc_reg_operand" "r")
6221 (match_operand:DI 2 "gpc_reg_operand" "r")))]
6222 "TARGET_POWERPC64"
6223 "divdu %0,%1,%2"
6224 [(set_attr "type" "ldiv")])
6225
6226 (define_insn "rotldi3"
6227 [(set (match_operand:DI 0 "gpc_reg_operand" "=r")
6228 (rotate:DI (match_operand:DI 1 "gpc_reg_operand" "r")
6229 (match_operand:DI 2 "reg_or_cint_operand" "ri")))]
6230 "TARGET_POWERPC64"
6231 "rld%I2cl %0,%1,%H2,0")
6232
6233 (define_insn "*rotldi3_internal2"
6234 [(set (match_operand:CC 0 "cc_reg_operand" "=x,?y")
6235 (compare:CC (rotate:DI (match_operand:DI 1 "gpc_reg_operand" "r,r")
6236 (match_operand:DI 2 "reg_or_cint_operand" "ri,ri"))
6237 (const_int 0)))
6238 (clobber (match_scratch:DI 3 "=r,r"))]
6239 "TARGET_POWERPC64"
6240 "@
6241 rld%I2cl. %3,%1,%H2,0
6242 #"
6243 [(set_attr "type" "delayed_compare")
6244 (set_attr "length" "4,8")])
6245
6246 (define_split
6247 [(set (match_operand:CC 0 "cc_reg_not_cr0_operand" "")
6248 (compare:CC (rotate:DI (match_operand:DI 1 "gpc_reg_operand" "")
6249 (match_operand:DI 2 "reg_or_cint_operand" ""))
6250 (const_int 0)))
6251 (clobber (match_scratch:DI 3 ""))]
6252 "TARGET_POWERPC64 && reload_completed"
6253 [(set (match_dup 3)
6254 (rotate:DI (match_dup 1) (match_dup 2)))
6255 (set (match_dup 0)
6256 (compare:CC (match_dup 3)
6257 (const_int 0)))]
6258 "")
6259
6260 (define_insn "*rotldi3_internal3"
6261 [(set (match_operand:CC 3 "cc_reg_operand" "=x,?y")
6262 (compare:CC (rotate:DI (match_operand:DI 1 "gpc_reg_operand" "r,r")
6263 (match_operand:DI 2 "reg_or_cint_operand" "ri,ri"))
6264 (const_int 0)))
6265 (set (match_operand:DI 0 "gpc_reg_operand" "=r,r")
6266 (rotate:DI (match_dup 1) (match_dup 2)))]
6267 "TARGET_POWERPC64"
6268 "@
6269 rld%I2cl. %0,%1,%H2,0
6270 #"
6271 [(set_attr "type" "delayed_compare")
6272 (set_attr "length" "4,8")])
6273
6274 (define_split
6275 [(set (match_operand:CC 3 "cc_reg_not_cr0_operand" "")
6276 (compare:CC (rotate:DI (match_operand:DI 1 "gpc_reg_operand" "")
6277 (match_operand:DI 2 "reg_or_cint_operand" ""))
6278 (const_int 0)))
6279 (set (match_operand:DI 0 "gpc_reg_operand" "")
6280 (rotate:DI (match_dup 1) (match_dup 2)))]
6281 "TARGET_POWERPC64 && reload_completed"
6282 [(set (match_dup 0)
6283 (rotate:DI (match_dup 1) (match_dup 2)))
6284 (set (match_dup 3)
6285 (compare:CC (match_dup 0)
6286 (const_int 0)))]
6287 "")
6288
6289 (define_insn "*rotldi3_internal4"
6290 [(set (match_operand:DI 0 "gpc_reg_operand" "=r")
6291 (and:DI (rotate:DI (match_operand:DI 1 "gpc_reg_operand" "r")
6292 (match_operand:DI 2 "reg_or_cint_operand" "ri"))
6293 (match_operand:DI 3 "mask64_operand" "n")))]
6294 "TARGET_POWERPC64"
6295 "rld%I2c%B3 %0,%1,%H2,%S3")
6296
6297 (define_insn "*rotldi3_internal5"
6298 [(set (match_operand:CC 0 "cc_reg_operand" "=x,?y")
6299 (compare:CC (and:DI
6300 (rotate:DI (match_operand:DI 1 "gpc_reg_operand" "r,r")
6301 (match_operand:DI 2 "reg_or_cint_operand" "ri,ri"))
6302 (match_operand:DI 3 "mask64_operand" "n,n"))
6303 (const_int 0)))
6304 (clobber (match_scratch:DI 4 "=r,r"))]
6305 "TARGET_POWERPC64"
6306 "@
6307 rld%I2c%B3. %4,%1,%H2,%S3
6308 #"
6309 [(set_attr "type" "delayed_compare")
6310 (set_attr "length" "4,8")])
6311
6312 (define_split
6313 [(set (match_operand:CC 0 "cc_reg_not_cr0_operand" "")
6314 (compare:CC (and:DI
6315 (rotate:DI (match_operand:DI 1 "gpc_reg_operand" "")
6316 (match_operand:DI 2 "reg_or_cint_operand" ""))
6317 (match_operand:DI 3 "mask64_operand" ""))
6318 (const_int 0)))
6319 (clobber (match_scratch:DI 4 ""))]
6320 "TARGET_POWERPC64 && reload_completed"
6321 [(set (match_dup 4)
6322 (and:DI (rotate:DI (match_dup 1)
6323 (match_dup 2))
6324 (match_dup 3)))
6325 (set (match_dup 0)
6326 (compare:CC (match_dup 4)
6327 (const_int 0)))]
6328 "")
6329
6330 (define_insn "*rotldi3_internal6"
6331 [(set (match_operand:CC 4 "cc_reg_operand" "=x,?y")
6332 (compare:CC (and:DI
6333 (rotate:DI (match_operand:DI 1 "gpc_reg_operand" "r,r")
6334 (match_operand:DI 2 "reg_or_cint_operand" "ri,ri"))
6335 (match_operand:DI 3 "mask64_operand" "n,n"))
6336 (const_int 0)))
6337 (set (match_operand:DI 0 "gpc_reg_operand" "=r,r")
6338 (and:DI (rotate:DI (match_dup 1) (match_dup 2)) (match_dup 3)))]
6339 "TARGET_POWERPC64"
6340 "@
6341 rld%I2c%B3. %0,%1,%H2,%S3
6342 #"
6343 [(set_attr "type" "delayed_compare")
6344 (set_attr "length" "4,8")])
6345
6346 (define_split
6347 [(set (match_operand:CC 4 "cc_reg_not_cr0_operand" "")
6348 (compare:CC (and:DI
6349 (rotate:DI (match_operand:DI 1 "gpc_reg_operand" "")
6350 (match_operand:DI 2 "reg_or_cint_operand" ""))
6351 (match_operand:DI 3 "mask64_operand" ""))
6352 (const_int 0)))
6353 (set (match_operand:DI 0 "gpc_reg_operand" "")
6354 (and:DI (rotate:DI (match_dup 1) (match_dup 2)) (match_dup 3)))]
6355 "TARGET_POWERPC64 && reload_completed"
6356 [(set (match_dup 0)
6357 (and:DI (rotate:DI (match_dup 1) (match_dup 2)) (match_dup 3)))
6358 (set (match_dup 4)
6359 (compare:CC (match_dup 0)
6360 (const_int 0)))]
6361 "")
6362
6363 (define_insn "*rotldi3_internal7"
6364 [(set (match_operand:DI 0 "gpc_reg_operand" "=r")
6365 (zero_extend:DI
6366 (subreg:QI
6367 (rotate:DI (match_operand:DI 1 "gpc_reg_operand" "r")
6368 (match_operand:DI 2 "reg_or_cint_operand" "ri")) 0)))]
6369 "TARGET_POWERPC64"
6370 "rld%I2cl %0,%1,%H2,56")
6371
6372 (define_insn "*rotldi3_internal8"
6373 [(set (match_operand:CC 0 "cc_reg_operand" "=x,?y")
6374 (compare:CC (zero_extend:DI
6375 (subreg:QI
6376 (rotate:DI (match_operand:DI 1 "gpc_reg_operand" "r,r")
6377 (match_operand:DI 2 "reg_or_cint_operand" "ri,ri")) 0))
6378 (const_int 0)))
6379 (clobber (match_scratch:DI 3 "=r,r"))]
6380 "TARGET_POWERPC64"
6381 "@
6382 rld%I2cl. %3,%1,%H2,56
6383 #"
6384 [(set_attr "type" "delayed_compare")
6385 (set_attr "length" "4,8")])
6386
6387 (define_split
6388 [(set (match_operand:CC 0 "cc_reg_not_cr0_operand" "")
6389 (compare:CC (zero_extend:DI
6390 (subreg:QI
6391 (rotate:DI (match_operand:DI 1 "gpc_reg_operand" "")
6392 (match_operand:DI 2 "reg_or_cint_operand" "")) 0))
6393 (const_int 0)))
6394 (clobber (match_scratch:DI 3 ""))]
6395 "TARGET_POWERPC64 && reload_completed"
6396 [(set (match_dup 3)
6397 (zero_extend:DI (subreg:QI
6398 (rotate:DI (match_dup 1)
6399 (match_dup 2)) 0)))
6400 (set (match_dup 0)
6401 (compare:CC (match_dup 3)
6402 (const_int 0)))]
6403 "")
6404
6405 (define_insn "*rotldi3_internal9"
6406 [(set (match_operand:CC 3 "cc_reg_operand" "=x,?y")
6407 (compare:CC (zero_extend:DI
6408 (subreg:QI
6409 (rotate:DI (match_operand:DI 1 "gpc_reg_operand" "r,r")
6410 (match_operand:DI 2 "reg_or_cint_operand" "ri,ri")) 0))
6411 (const_int 0)))
6412 (set (match_operand:DI 0 "gpc_reg_operand" "=r,r")
6413 (zero_extend:DI (subreg:QI (rotate:DI (match_dup 1) (match_dup 2)) 0)))]
6414 "TARGET_POWERPC64"
6415 "@
6416 rld%I2cl. %0,%1,%H2,56
6417 #"
6418 [(set_attr "type" "delayed_compare")
6419 (set_attr "length" "4,8")])
6420
6421 (define_split
6422 [(set (match_operand:CC 3 "cc_reg_not_cr0_operand" "")
6423 (compare:CC (zero_extend:DI
6424 (subreg:QI
6425 (rotate:DI (match_operand:DI 1 "gpc_reg_operand" "")
6426 (match_operand:DI 2 "reg_or_cint_operand" "")) 0))
6427 (const_int 0)))
6428 (set (match_operand:DI 0 "gpc_reg_operand" "")
6429 (zero_extend:DI (subreg:QI (rotate:DI (match_dup 1) (match_dup 2)) 0)))]
6430 "TARGET_POWERPC64 && reload_completed"
6431 [(set (match_dup 0)
6432 (zero_extend:DI (subreg:QI (rotate:DI (match_dup 1) (match_dup 2)) 0)))
6433 (set (match_dup 3)
6434 (compare:CC (match_dup 0)
6435 (const_int 0)))]
6436 "")
6437
6438 (define_insn "*rotldi3_internal10"
6439 [(set (match_operand:DI 0 "gpc_reg_operand" "=r")
6440 (zero_extend:DI
6441 (subreg:HI
6442 (rotate:DI (match_operand:DI 1 "gpc_reg_operand" "r")
6443 (match_operand:DI 2 "reg_or_cint_operand" "ri")) 0)))]
6444 "TARGET_POWERPC64"
6445 "rld%I2cl %0,%1,%H2,48")
6446
6447 (define_insn "*rotldi3_internal11"
6448 [(set (match_operand:CC 0 "cc_reg_operand" "=x,?y")
6449 (compare:CC (zero_extend:DI
6450 (subreg:HI
6451 (rotate:DI (match_operand:DI 1 "gpc_reg_operand" "r,r")
6452 (match_operand:DI 2 "reg_or_cint_operand" "ri,ri")) 0))
6453 (const_int 0)))
6454 (clobber (match_scratch:DI 3 "=r,r"))]
6455 "TARGET_POWERPC64"
6456 "@
6457 rld%I2cl. %3,%1,%H2,48
6458 #"
6459 [(set_attr "type" "delayed_compare")
6460 (set_attr "length" "4,8")])
6461
6462 (define_split
6463 [(set (match_operand:CC 0 "cc_reg_not_cr0_operand" "")
6464 (compare:CC (zero_extend:DI
6465 (subreg:HI
6466 (rotate:DI (match_operand:DI 1 "gpc_reg_operand" "")
6467 (match_operand:DI 2 "reg_or_cint_operand" "")) 0))
6468 (const_int 0)))
6469 (clobber (match_scratch:DI 3 ""))]
6470 "TARGET_POWERPC64 && reload_completed"
6471 [(set (match_dup 3)
6472 (zero_extend:DI (subreg:HI
6473 (rotate:DI (match_dup 1)
6474 (match_dup 2)) 0)))
6475 (set (match_dup 0)
6476 (compare:CC (match_dup 3)
6477 (const_int 0)))]
6478 "")
6479
6480 (define_insn "*rotldi3_internal12"
6481 [(set (match_operand:CC 3 "cc_reg_operand" "=x,?y")
6482 (compare:CC (zero_extend:DI
6483 (subreg:HI
6484 (rotate:DI (match_operand:DI 1 "gpc_reg_operand" "r,r")
6485 (match_operand:DI 2 "reg_or_cint_operand" "ri,ri")) 0))
6486 (const_int 0)))
6487 (set (match_operand:DI 0 "gpc_reg_operand" "=r,r")
6488 (zero_extend:DI (subreg:HI (rotate:DI (match_dup 1) (match_dup 2)) 0)))]
6489 "TARGET_POWERPC64"
6490 "@
6491 rld%I2cl. %0,%1,%H2,48
6492 #"
6493 [(set_attr "type" "delayed_compare")
6494 (set_attr "length" "4,8")])
6495
6496 (define_split
6497 [(set (match_operand:CC 3 "cc_reg_not_cr0_operand" "")
6498 (compare:CC (zero_extend:DI
6499 (subreg:HI
6500 (rotate:DI (match_operand:DI 1 "gpc_reg_operand" "")
6501 (match_operand:DI 2 "reg_or_cint_operand" "")) 0))
6502 (const_int 0)))
6503 (set (match_operand:DI 0 "gpc_reg_operand" "")
6504 (zero_extend:DI (subreg:HI (rotate:DI (match_dup 1) (match_dup 2)) 0)))]
6505 "TARGET_POWERPC64 && reload_completed"
6506 [(set (match_dup 0)
6507 (zero_extend:DI (subreg:HI (rotate:DI (match_dup 1) (match_dup 2)) 0)))
6508 (set (match_dup 3)
6509 (compare:CC (match_dup 0)
6510 (const_int 0)))]
6511 "")
6512
6513 (define_insn "*rotldi3_internal13"
6514 [(set (match_operand:DI 0 "gpc_reg_operand" "=r")
6515 (zero_extend:DI
6516 (subreg:SI
6517 (rotate:DI (match_operand:DI 1 "gpc_reg_operand" "r")
6518 (match_operand:DI 2 "reg_or_cint_operand" "ri")) 0)))]
6519 "TARGET_POWERPC64"
6520 "rld%I2cl %0,%1,%H2,32")
6521
6522 (define_insn "*rotldi3_internal14"
6523 [(set (match_operand:CC 0 "cc_reg_operand" "=x,?y")
6524 (compare:CC (zero_extend:DI
6525 (subreg:SI
6526 (rotate:DI (match_operand:DI 1 "gpc_reg_operand" "r,r")
6527 (match_operand:DI 2 "reg_or_cint_operand" "ri,ri")) 0))
6528 (const_int 0)))
6529 (clobber (match_scratch:DI 3 "=r,r"))]
6530 "TARGET_POWERPC64"
6531 "@
6532 rld%I2cl. %3,%1,%H2,32
6533 #"
6534 [(set_attr "type" "delayed_compare")
6535 (set_attr "length" "4,8")])
6536
6537 (define_split
6538 [(set (match_operand:CC 0 "cc_reg_not_cr0_operand" "")
6539 (compare:CC (zero_extend:DI
6540 (subreg:SI
6541 (rotate:DI (match_operand:DI 1 "gpc_reg_operand" "")
6542 (match_operand:DI 2 "reg_or_cint_operand" "")) 0))
6543 (const_int 0)))
6544 (clobber (match_scratch:DI 3 ""))]
6545 "TARGET_POWERPC64 && reload_completed"
6546 [(set (match_dup 3)
6547 (zero_extend:DI (subreg:SI
6548 (rotate:DI (match_dup 1)
6549 (match_dup 2)) 0)))
6550 (set (match_dup 0)
6551 (compare:CC (match_dup 3)
6552 (const_int 0)))]
6553 "")
6554
6555 (define_insn "*rotldi3_internal15"
6556 [(set (match_operand:CC 3 "cc_reg_operand" "=x,?y")
6557 (compare:CC (zero_extend:DI
6558 (subreg:SI
6559 (rotate:DI (match_operand:DI 1 "gpc_reg_operand" "r,r")
6560 (match_operand:DI 2 "reg_or_cint_operand" "ri,ri")) 0))
6561 (const_int 0)))
6562 (set (match_operand:DI 0 "gpc_reg_operand" "=r,r")
6563 (zero_extend:DI (subreg:SI (rotate:DI (match_dup 1) (match_dup 2)) 0)))]
6564 "TARGET_POWERPC64"
6565 "@
6566 rld%I2cl. %0,%1,%H2,32
6567 #"
6568 [(set_attr "type" "delayed_compare")
6569 (set_attr "length" "4,8")])
6570
6571 (define_split
6572 [(set (match_operand:CC 3 "cc_reg_not_cr0_operand" "")
6573 (compare:CC (zero_extend:DI
6574 (subreg:SI
6575 (rotate:DI (match_operand:DI 1 "gpc_reg_operand" "")
6576 (match_operand:DI 2 "reg_or_cint_operand" "")) 0))
6577 (const_int 0)))
6578 (set (match_operand:DI 0 "gpc_reg_operand" "")
6579 (zero_extend:DI (subreg:SI (rotate:DI (match_dup 1) (match_dup 2)) 0)))]
6580 "TARGET_POWERPC64 && reload_completed"
6581 [(set (match_dup 0)
6582 (zero_extend:DI (subreg:SI (rotate:DI (match_dup 1) (match_dup 2)) 0)))
6583 (set (match_dup 3)
6584 (compare:CC (match_dup 0)
6585 (const_int 0)))]
6586 "")
6587
6588 (define_expand "ashldi3"
6589 [(set (match_operand:DI 0 "gpc_reg_operand" "")
6590 (ashift:DI (match_operand:DI 1 "gpc_reg_operand" "")
6591 (match_operand:SI 2 "reg_or_cint_operand" "")))]
6592 "TARGET_POWERPC64 || TARGET_POWER"
6593 "
6594 {
6595 if (TARGET_POWERPC64)
6596 ;
6597 else if (TARGET_POWER)
6598 {
6599 emit_insn (gen_ashldi3_power (operands[0], operands[1], operands[2]));
6600 DONE;
6601 }
6602 else
6603 FAIL;
6604 }")
6605
6606 (define_insn "*ashldi3_internal1"
6607 [(set (match_operand:DI 0 "gpc_reg_operand" "=r")
6608 (ashift:DI (match_operand:DI 1 "gpc_reg_operand" "r")
6609 (match_operand:SI 2 "reg_or_cint_operand" "ri")))]
6610 "TARGET_POWERPC64"
6611 "sld%I2 %0,%1,%H2"
6612 [(set_attr "length" "8")])
6613
6614 (define_insn "*ashldi3_internal2"
6615 [(set (match_operand:CC 0 "cc_reg_operand" "=x,?y")
6616 (compare:CC (ashift:DI (match_operand:DI 1 "gpc_reg_operand" "r,r")
6617 (match_operand:SI 2 "reg_or_cint_operand" "ri,ri"))
6618 (const_int 0)))
6619 (clobber (match_scratch:DI 3 "=r,r"))]
6620 "TARGET_POWERPC64"
6621 "@
6622 sld%I2. %3,%1,%H2
6623 #"
6624 [(set_attr "type" "delayed_compare")
6625 (set_attr "length" "4,8")])
6626
6627 (define_split
6628 [(set (match_operand:CC 0 "cc_reg_not_cr0_operand" "")
6629 (compare:CC (ashift:DI (match_operand:DI 1 "gpc_reg_operand" "")
6630 (match_operand:SI 2 "reg_or_cint_operand" ""))
6631 (const_int 0)))
6632 (clobber (match_scratch:DI 3 ""))]
6633 "TARGET_POWERPC64 && reload_completed"
6634 [(set (match_dup 3)
6635 (ashift:DI (match_dup 1) (match_dup 2)))
6636 (set (match_dup 0)
6637 (compare:CC (match_dup 3)
6638 (const_int 0)))]
6639 "")
6640
6641 (define_insn "*ashldi3_internal3"
6642 [(set (match_operand:CC 3 "cc_reg_operand" "=x,?y")
6643 (compare:CC (ashift:DI (match_operand:DI 1 "gpc_reg_operand" "r,r")
6644 (match_operand:SI 2 "reg_or_cint_operand" "ri,ri"))
6645 (const_int 0)))
6646 (set (match_operand:DI 0 "gpc_reg_operand" "=r,r")
6647 (ashift:DI (match_dup 1) (match_dup 2)))]
6648 "TARGET_POWERPC64"
6649 "@
6650 sld%I2. %0,%1,%H2
6651 #"
6652 [(set_attr "type" "delayed_compare")
6653 (set_attr "length" "4,8")])
6654
6655 (define_split
6656 [(set (match_operand:CC 3 "cc_reg_not_cr0_operand" "")
6657 (compare:CC (ashift:DI (match_operand:DI 1 "gpc_reg_operand" "")
6658 (match_operand:SI 2 "reg_or_cint_operand" ""))
6659 (const_int 0)))
6660 (set (match_operand:DI 0 "gpc_reg_operand" "")
6661 (ashift:DI (match_dup 1) (match_dup 2)))]
6662 "TARGET_POWERPC64 && reload_completed"
6663 [(set (match_dup 0)
6664 (ashift:DI (match_dup 1) (match_dup 2)))
6665 (set (match_dup 3)
6666 (compare:CC (match_dup 0)
6667 (const_int 0)))]
6668 "")
6669
6670 (define_insn "*ashldi3_internal4"
6671 [(set (match_operand:DI 0 "gpc_reg_operand" "=r")
6672 (and:DI (ashift:DI (match_operand:DI 1 "gpc_reg_operand" "r")
6673 (match_operand:SI 2 "const_int_operand" "i"))
6674 (match_operand:DI 3 "const_int_operand" "n")))]
6675 "TARGET_POWERPC64 && includes_rldic_lshift_p (operands[2], operands[3])"
6676 "rldic %0,%1,%H2,%W3")
6677
6678 (define_insn "ashldi3_internal5"
6679 [(set (match_operand:CC 0 "cc_reg_operand" "=x,?y")
6680 (compare:CC
6681 (and:DI (ashift:DI (match_operand:DI 1 "gpc_reg_operand" "r,r")
6682 (match_operand:SI 2 "const_int_operand" "i,i"))
6683 (match_operand:DI 3 "const_int_operand" "n,n"))
6684 (const_int 0)))
6685 (clobber (match_scratch:DI 4 "=r,r"))]
6686 "TARGET_POWERPC64 && includes_rldic_lshift_p (operands[2], operands[3])"
6687 "@
6688 rldic. %4,%1,%H2,%W3
6689 #"
6690 [(set_attr "type" "delayed_compare")
6691 (set_attr "length" "4,8")])
6692
6693 (define_split
6694 [(set (match_operand:CC 0 "cc_reg_not_cr0_operand" "")
6695 (compare:CC
6696 (and:DI (ashift:DI (match_operand:DI 1 "gpc_reg_operand" "")
6697 (match_operand:SI 2 "const_int_operand" ""))
6698 (match_operand:DI 3 "const_int_operand" ""))
6699 (const_int 0)))
6700 (clobber (match_scratch:DI 4 ""))]
6701 "TARGET_POWERPC64 && reload_completed
6702 && includes_rldic_lshift_p (operands[2], operands[3])"
6703 [(set (match_dup 4)
6704 (and:DI (ashift:DI (match_dup 1) (match_dup 2))
6705 (match_dup 3)))
6706 (set (match_dup 0)
6707 (compare:CC (match_dup 4)
6708 (const_int 0)))]
6709 "")
6710
6711 (define_insn "*ashldi3_internal6"
6712 [(set (match_operand:CC 4 "cc_reg_operand" "=x,?y")
6713 (compare:CC
6714 (and:DI (ashift:DI (match_operand:DI 1 "gpc_reg_operand" "r,r")
6715 (match_operand:SI 2 "const_int_operand" "i,i"))
6716 (match_operand:DI 3 "const_int_operand" "n,n"))
6717 (const_int 0)))
6718 (set (match_operand:DI 0 "gpc_reg_operand" "=r,r")
6719 (and:DI (ashift:DI (match_dup 1) (match_dup 2)) (match_dup 3)))]
6720 "TARGET_POWERPC64 && includes_rldic_lshift_p (operands[2], operands[3])"
6721 "@
6722 rldic. %0,%1,%H2,%W3
6723 #"
6724 [(set_attr "type" "delayed_compare")
6725 (set_attr "length" "4,8")])
6726
6727 (define_split
6728 [(set (match_operand:CC 4 "cc_reg_not_cr0_operand" "")
6729 (compare:CC
6730 (and:DI (ashift:DI (match_operand:DI 1 "gpc_reg_operand" "")
6731 (match_operand:SI 2 "const_int_operand" ""))
6732 (match_operand:DI 3 "const_int_operand" ""))
6733 (const_int 0)))
6734 (set (match_operand:DI 0 "gpc_reg_operand" "")
6735 (and:DI (ashift:DI (match_dup 1) (match_dup 2)) (match_dup 3)))]
6736 "TARGET_POWERPC64 && reload_completed
6737 && includes_rldic_lshift_p (operands[2], operands[3])"
6738 [(set (match_dup 0)
6739 (and:DI (ashift:DI (match_dup 1) (match_dup 2))
6740 (match_dup 3)))
6741 (set (match_dup 4)
6742 (compare:CC (match_dup 0)
6743 (const_int 0)))]
6744 "")
6745
6746 (define_insn "*ashldi3_internal7"
6747 [(set (match_operand:DI 0 "gpc_reg_operand" "=r")
6748 (and:DI (ashift:DI (match_operand:DI 1 "gpc_reg_operand" "r")
6749 (match_operand:SI 2 "const_int_operand" "i"))
6750 (match_operand:DI 3 "mask64_operand" "n")))]
6751 "TARGET_POWERPC64 && includes_rldicr_lshift_p (operands[2], operands[3])"
6752 "rldicr %0,%1,%H2,%S3")
6753
6754 (define_insn "ashldi3_internal8"
6755 [(set (match_operand:CC 0 "cc_reg_operand" "=x,?y")
6756 (compare:CC
6757 (and:DI (ashift:DI (match_operand:DI 1 "gpc_reg_operand" "r,r")
6758 (match_operand:SI 2 "const_int_operand" "i,i"))
6759 (match_operand:DI 3 "mask64_operand" "n,n"))
6760 (const_int 0)))
6761 (clobber (match_scratch:DI 4 "=r,r"))]
6762 "TARGET_POWERPC64 && includes_rldicr_lshift_p (operands[2], operands[3])"
6763 "@
6764 rldicr. %4,%1,%H2,%S3
6765 #"
6766 [(set_attr "type" "delayed_compare")
6767 (set_attr "length" "4,8")])
6768
6769 (define_split
6770 [(set (match_operand:CC 0 "cc_reg_not_cr0_operand" "")
6771 (compare:CC
6772 (and:DI (ashift:DI (match_operand:DI 1 "gpc_reg_operand" "")
6773 (match_operand:SI 2 "const_int_operand" ""))
6774 (match_operand:DI 3 "mask64_operand" ""))
6775 (const_int 0)))
6776 (clobber (match_scratch:DI 4 ""))]
6777 "TARGET_POWERPC64 && reload_completed
6778 && includes_rldicr_lshift_p (operands[2], operands[3])"
6779 [(set (match_dup 4)
6780 (and:DI (ashift:DI (match_dup 1) (match_dup 2))
6781 (match_dup 3)))
6782 (set (match_dup 0)
6783 (compare:CC (match_dup 4)
6784 (const_int 0)))]
6785 "")
6786
6787 (define_insn "*ashldi3_internal9"
6788 [(set (match_operand:CC 4 "cc_reg_operand" "=x,?y")
6789 (compare:CC
6790 (and:DI (ashift:DI (match_operand:DI 1 "gpc_reg_operand" "r,r")
6791 (match_operand:SI 2 "const_int_operand" "i,i"))
6792 (match_operand:DI 3 "mask64_operand" "n,n"))
6793 (const_int 0)))
6794 (set (match_operand:DI 0 "gpc_reg_operand" "=r,r")
6795 (and:DI (ashift:DI (match_dup 1) (match_dup 2)) (match_dup 3)))]
6796 "TARGET_POWERPC64 && includes_rldicr_lshift_p (operands[2], operands[3])"
6797 "@
6798 rldicr. %0,%1,%H2,%S3
6799 #"
6800 [(set_attr "type" "delayed_compare")
6801 (set_attr "length" "4,8")])
6802
6803 (define_split
6804 [(set (match_operand:CC 4 "cc_reg_not_cr0_operand" "")
6805 (compare:CC
6806 (and:DI (ashift:DI (match_operand:DI 1 "gpc_reg_operand" "")
6807 (match_operand:SI 2 "const_int_operand" ""))
6808 (match_operand:DI 3 "mask64_operand" ""))
6809 (const_int 0)))
6810 (set (match_operand:DI 0 "gpc_reg_operand" "")
6811 (and:DI (ashift:DI (match_dup 1) (match_dup 2)) (match_dup 3)))]
6812 "TARGET_POWERPC64 && reload_completed
6813 && includes_rldicr_lshift_p (operands[2], operands[3])"
6814 [(set (match_dup 0)
6815 (and:DI (ashift:DI (match_dup 1) (match_dup 2))
6816 (match_dup 3)))
6817 (set (match_dup 4)
6818 (compare:CC (match_dup 0)
6819 (const_int 0)))]
6820 "")
6821
6822 (define_expand "lshrdi3"
6823 [(set (match_operand:DI 0 "gpc_reg_operand" "")
6824 (lshiftrt:DI (match_operand:DI 1 "gpc_reg_operand" "")
6825 (match_operand:SI 2 "reg_or_cint_operand" "")))]
6826 "TARGET_POWERPC64 || TARGET_POWER"
6827 "
6828 {
6829 if (TARGET_POWERPC64)
6830 ;
6831 else if (TARGET_POWER)
6832 {
6833 emit_insn (gen_lshrdi3_power (operands[0], operands[1], operands[2]));
6834 DONE;
6835 }
6836 else
6837 FAIL;
6838 }")
6839
6840 (define_insn "*lshrdi3_internal1"
6841 [(set (match_operand:DI 0 "gpc_reg_operand" "=r")
6842 (lshiftrt:DI (match_operand:DI 1 "gpc_reg_operand" "r")
6843 (match_operand:SI 2 "reg_or_cint_operand" "ri")))]
6844 "TARGET_POWERPC64"
6845 "srd%I2 %0,%1,%H2")
6846
6847 (define_insn "*lshrdi3_internal2"
6848 [(set (match_operand:CC 0 "cc_reg_operand" "=x,?y")
6849 (compare:CC (lshiftrt:DI (match_operand:DI 1 "gpc_reg_operand" "r,r")
6850 (match_operand:SI 2 "reg_or_cint_operand" "ri,ri"))
6851 (const_int 0)))
6852 (clobber (match_scratch:DI 3 "=r,r"))]
6853 "TARGET_POWERPC64"
6854 "@
6855 srd%I2. %3,%1,%H2
6856 #"
6857 [(set_attr "type" "delayed_compare")
6858 (set_attr "length" "4,8")])
6859
6860 (define_split
6861 [(set (match_operand:CC 0 "cc_reg_not_cr0_operand" "")
6862 (compare:CC (lshiftrt:DI (match_operand:DI 1 "gpc_reg_operand" "")
6863 (match_operand:SI 2 "reg_or_cint_operand" ""))
6864 (const_int 0)))
6865 (clobber (match_scratch:DI 3 ""))]
6866 "TARGET_POWERPC64 && reload_completed"
6867 [(set (match_dup 3)
6868 (lshiftrt:DI (match_dup 1) (match_dup 2)))
6869 (set (match_dup 0)
6870 (compare:CC (match_dup 3)
6871 (const_int 0)))]
6872 "")
6873
6874 (define_insn "*lshrdi3_internal3"
6875 [(set (match_operand:CC 3 "cc_reg_operand" "=x,?y")
6876 (compare:CC (lshiftrt:DI (match_operand:DI 1 "gpc_reg_operand" "r,r")
6877 (match_operand:SI 2 "reg_or_cint_operand" "ri,ri"))
6878 (const_int 0)))
6879 (set (match_operand:DI 0 "gpc_reg_operand" "=r,r")
6880 (lshiftrt:DI (match_dup 1) (match_dup 2)))]
6881 "TARGET_POWERPC64"
6882 "@
6883 srd%I2. %0,%1,%H2
6884 #"
6885 [(set_attr "type" "delayed_compare")
6886 (set_attr "length" "4,8")])
6887
6888 (define_split
6889 [(set (match_operand:CC 3 "cc_reg_not_cr0_operand" "")
6890 (compare:CC (lshiftrt:DI (match_operand:DI 1 "gpc_reg_operand" "")
6891 (match_operand:SI 2 "reg_or_cint_operand" ""))
6892 (const_int 0)))
6893 (set (match_operand:DI 0 "gpc_reg_operand" "")
6894 (lshiftrt:DI (match_dup 1) (match_dup 2)))]
6895 "TARGET_POWERPC64 && reload_completed"
6896 [(set (match_dup 0)
6897 (lshiftrt:DI (match_dup 1) (match_dup 2)))
6898 (set (match_dup 3)
6899 (compare:CC (match_dup 0)
6900 (const_int 0)))]
6901 "")
6902
6903 (define_expand "ashrdi3"
6904 [(set (match_operand:DI 0 "gpc_reg_operand" "")
6905 (ashiftrt:DI (match_operand:DI 1 "gpc_reg_operand" "")
6906 (match_operand:SI 2 "reg_or_cint_operand" "")))]
6907 ""
6908 "
6909 {
6910 if (TARGET_POWERPC64)
6911 ;
6912 else if (TARGET_POWER && GET_CODE (operands[2]) == CONST_INT)
6913 {
6914 emit_insn (gen_ashrdi3_power (operands[0], operands[1], operands[2]));
6915 DONE;
6916 }
6917 else if (TARGET_32BIT && GET_CODE (operands[2]) == CONST_INT)
6918 {
6919 emit_insn (gen_ashrdi3_no_power (operands[0], operands[1], operands[2]));
6920 DONE;
6921 }
6922 else
6923 FAIL;
6924 }")
6925
6926 (define_insn "*ashrdi3_internal1"
6927 [(set (match_operand:DI 0 "gpc_reg_operand" "=r")
6928 (ashiftrt:DI (match_operand:DI 1 "gpc_reg_operand" "r")
6929 (match_operand:SI 2 "reg_or_cint_operand" "ri")))]
6930 "TARGET_POWERPC64"
6931 "srad%I2 %0,%1,%H2")
6932
6933 (define_insn "*ashrdi3_internal2"
6934 [(set (match_operand:CC 0 "cc_reg_operand" "=x,?y")
6935 (compare:CC (ashiftrt:DI (match_operand:DI 1 "gpc_reg_operand" "r,r")
6936 (match_operand:SI 2 "reg_or_cint_operand" "ri,ri"))
6937 (const_int 0)))
6938 (clobber (match_scratch:DI 3 "=r,r"))]
6939 "TARGET_POWERPC64"
6940 "@
6941 srad%I2. %3,%1,%H2
6942 #"
6943 [(set_attr "type" "delayed_compare")
6944 (set_attr "length" "4,8")])
6945
6946 (define_split
6947 [(set (match_operand:CC 0 "cc_reg_not_cr0_operand" "")
6948 (compare:CC (ashiftrt:DI (match_operand:DI 1 "gpc_reg_operand" "")
6949 (match_operand:SI 2 "reg_or_cint_operand" ""))
6950 (const_int 0)))
6951 (clobber (match_scratch:DI 3 ""))]
6952 "TARGET_POWERPC64 && reload_completed"
6953 [(set (match_dup 3)
6954 (ashiftrt:DI (match_dup 1) (match_dup 2)))
6955 (set (match_dup 0)
6956 (compare:CC (match_dup 3)
6957 (const_int 0)))]
6958 "")
6959
6960 (define_insn "*ashrdi3_internal3"
6961 [(set (match_operand:CC 3 "cc_reg_operand" "=x,?y")
6962 (compare:CC (ashiftrt:DI (match_operand:DI 1 "gpc_reg_operand" "r,r")
6963 (match_operand:SI 2 "reg_or_cint_operand" "ri,ri"))
6964 (const_int 0)))
6965 (set (match_operand:DI 0 "gpc_reg_operand" "=r,r")
6966 (ashiftrt:DI (match_dup 1) (match_dup 2)))]
6967 "TARGET_POWERPC64"
6968 "@
6969 srad%I2. %0,%1,%H2
6970 #"
6971 [(set_attr "type" "delayed_compare")
6972 (set_attr "length" "4,8")])
6973
6974 (define_split
6975 [(set (match_operand:CC 3 "cc_reg_not_cr0_operand" "")
6976 (compare:CC (ashiftrt:DI (match_operand:DI 1 "gpc_reg_operand" "")
6977 (match_operand:SI 2 "reg_or_cint_operand" ""))
6978 (const_int 0)))
6979 (set (match_operand:DI 0 "gpc_reg_operand" "")
6980 (ashiftrt:DI (match_dup 1) (match_dup 2)))]
6981 "TARGET_POWERPC64 && reload_completed"
6982 [(set (match_dup 0)
6983 (ashiftrt:DI (match_dup 1) (match_dup 2)))
6984 (set (match_dup 3)
6985 (compare:CC (match_dup 0)
6986 (const_int 0)))]
6987 "")
6988
6989 (define_insn "anddi3"
6990 [(set (match_operand:DI 0 "gpc_reg_operand" "=r,r,r,r,r")
6991 (and:DI (match_operand:DI 1 "gpc_reg_operand" "%r,r,r,r,r")
6992 (match_operand:DI 2 "and64_2_operand" "?r,S,K,J,t")))
6993 (clobber (match_scratch:CC 3 "=X,X,x,x,X"))]
6994 "TARGET_POWERPC64"
6995 "@
6996 and %0,%1,%2
6997 rldic%B2 %0,%1,0,%S2
6998 andi. %0,%1,%b2
6999 andis. %0,%1,%u2
7000 #"
7001 [(set_attr "length" "4,4,4,4,8")])
7002
7003 (define_split
7004 [(set (match_operand:DI 0 "gpc_reg_operand" "")
7005 (and:DI (match_operand:DI 1 "gpc_reg_operand" "")
7006 (match_operand:DI 2 "mask64_2_operand" "")))
7007 (clobber (match_scratch:CC 3 ""))]
7008 "TARGET_POWERPC64
7009 && (fixed_regs[CR0_REGNO] || !logical_operand (operands[2], DImode))
7010 && !mask64_operand (operands[2], DImode)"
7011 [(set (match_dup 0)
7012 (and:DI (rotate:DI (match_dup 1)
7013 (match_dup 4))
7014 (match_dup 5)))
7015 (set (match_dup 0)
7016 (and:DI (rotate:DI (match_dup 0)
7017 (match_dup 6))
7018 (match_dup 7)))]
7019 "
7020 {
7021 build_mask64_2_operands (operands[2], &operands[4]);
7022 }")
7023
7024 (define_insn "*anddi3_internal2"
7025 [(set (match_operand:CC 0 "cc_reg_operand" "=x,x,x,x,x,?y,?y,??y,??y,?y")
7026 (compare:CC (and:DI (match_operand:DI 1 "gpc_reg_operand" "%r,r,r,r,r,r,r,r,r,r")
7027 (match_operand:DI 2 "and64_2_operand" "r,S,K,J,t,r,S,K,J,t"))
7028 (const_int 0)))
7029 (clobber (match_scratch:DI 3 "=r,r,r,r,r,r,r,r,r,r"))
7030 (clobber (match_scratch:CC 4 "=X,X,X,X,X,X,X,x,x,X"))]
7031 "TARGET_POWERPC64"
7032 "@
7033 and. %3,%1,%2
7034 rldic%B2. %3,%1,0,%S2
7035 andi. %3,%1,%b2
7036 andis. %3,%1,%u2
7037 #
7038 #
7039 #
7040 #
7041 #
7042 #"
7043 [(set_attr "type" "compare,delayed_compare,compare,compare,delayed_compare,compare,compare,compare,compare,compare")
7044 (set_attr "length" "4,4,4,4,8,8,8,8,8,12")])
7045
7046 (define_split
7047 [(set (match_operand:CC 0 "cc_reg_not_cr0_operand" "")
7048 (compare:CC (and:DI (match_operand:DI 1 "gpc_reg_operand" "")
7049 (match_operand:DI 2 "and64_operand" ""))
7050 (const_int 0)))
7051 (clobber (match_scratch:DI 3 ""))
7052 (clobber (match_scratch:CC 4 ""))]
7053 "TARGET_POWERPC64 && reload_completed"
7054 [(parallel [(set (match_dup 3)
7055 (and:DI (match_dup 1)
7056 (match_dup 2)))
7057 (clobber (match_dup 4))])
7058 (set (match_dup 0)
7059 (compare:CC (match_dup 3)
7060 (const_int 0)))]
7061 "")
7062
7063 (define_split
7064 [(set (match_operand:CC 0 "cc_reg_operand" "")
7065 (compare:CC (and:DI (match_operand:DI 1 "gpc_reg_operand" "")
7066 (match_operand:DI 2 "mask64_2_operand" ""))
7067 (const_int 0)))
7068 (clobber (match_scratch:DI 3 ""))
7069 (clobber (match_scratch:CC 4 ""))]
7070 "TARGET_POWERPC64 && reload_completed
7071 && (fixed_regs[CR0_REGNO] || !logical_operand (operands[2], DImode))
7072 && !mask64_operand (operands[2], DImode)"
7073 [(set (match_dup 3)
7074 (and:DI (rotate:DI (match_dup 1)
7075 (match_dup 5))
7076 (match_dup 6)))
7077 (parallel [(set (match_dup 0)
7078 (compare:CC (and:DI (rotate:DI (match_dup 3)
7079 (match_dup 7))
7080 (match_dup 8))
7081 (const_int 0)))
7082 (clobber (match_dup 3))])]
7083 "
7084 {
7085 build_mask64_2_operands (operands[2], &operands[5]);
7086 }")
7087
7088 (define_insn "*anddi3_internal3"
7089 [(set (match_operand:CC 3 "cc_reg_operand" "=x,x,x,x,x,?y,?y,??y,??y,?y")
7090 (compare:CC (and:DI (match_operand:DI 1 "gpc_reg_operand" "%r,r,r,r,r,r,r,r,r,r")
7091 (match_operand:DI 2 "and64_2_operand" "r,S,K,J,t,r,S,K,J,t"))
7092 (const_int 0)))
7093 (set (match_operand:DI 0 "gpc_reg_operand" "=r,r,r,r,r,r,r,r,r,r")
7094 (and:DI (match_dup 1) (match_dup 2)))
7095 (clobber (match_scratch:CC 4 "=X,X,X,X,X,X,X,x,x,X"))]
7096 "TARGET_POWERPC64"
7097 "@
7098 and. %0,%1,%2
7099 rldic%B2. %0,%1,0,%S2
7100 andi. %0,%1,%b2
7101 andis. %0,%1,%u2
7102 #
7103 #
7104 #
7105 #
7106 #
7107 #"
7108 [(set_attr "type" "compare,delayed_compare,compare,compare,delayed_compare,compare,compare,compare,compare,compare")
7109 (set_attr "length" "4,4,4,4,8,8,8,8,8,12")])
7110
7111 (define_split
7112 [(set (match_operand:CC 3 "cc_reg_not_cr0_operand" "")
7113 (compare:CC (and:DI (match_operand:DI 1 "gpc_reg_operand" "")
7114 (match_operand:DI 2 "and64_operand" ""))
7115 (const_int 0)))
7116 (set (match_operand:DI 0 "gpc_reg_operand" "")
7117 (and:DI (match_dup 1) (match_dup 2)))
7118 (clobber (match_scratch:CC 4 ""))]
7119 "TARGET_POWERPC64 && reload_completed"
7120 [(parallel [(set (match_dup 0)
7121 (and:DI (match_dup 1) (match_dup 2)))
7122 (clobber (match_dup 4))])
7123 (set (match_dup 3)
7124 (compare:CC (match_dup 0)
7125 (const_int 0)))]
7126 "")
7127
7128 (define_split
7129 [(set (match_operand:CC 3 "cc_reg_operand" "")
7130 (compare:CC (and:DI (match_operand:DI 1 "gpc_reg_operand" "")
7131 (match_operand:DI 2 "mask64_2_operand" ""))
7132 (const_int 0)))
7133 (set (match_operand:DI 0 "gpc_reg_operand" "")
7134 (and:DI (match_dup 1) (match_dup 2)))
7135 (clobber (match_scratch:CC 4 ""))]
7136 "TARGET_POWERPC64 && reload_completed
7137 && (fixed_regs[CR0_REGNO] || !logical_operand (operands[2], DImode))
7138 && !mask64_operand (operands[2], DImode)"
7139 [(set (match_dup 0)
7140 (and:DI (rotate:DI (match_dup 1)
7141 (match_dup 5))
7142 (match_dup 6)))
7143 (parallel [(set (match_dup 3)
7144 (compare:CC (and:DI (rotate:DI (match_dup 0)
7145 (match_dup 7))
7146 (match_dup 8))
7147 (const_int 0)))
7148 (set (match_dup 0)
7149 (and:DI (rotate:DI (match_dup 0)
7150 (match_dup 7))
7151 (match_dup 8)))])]
7152 "
7153 {
7154 build_mask64_2_operands (operands[2], &operands[5]);
7155 }")
7156
7157 (define_expand "iordi3"
7158 [(set (match_operand:DI 0 "gpc_reg_operand" "")
7159 (ior:DI (match_operand:DI 1 "gpc_reg_operand" "")
7160 (match_operand:DI 2 "reg_or_logical_cint_operand" "")))]
7161 "TARGET_POWERPC64"
7162 "
7163 {
7164 if (non_logical_cint_operand (operands[2], DImode))
7165 {
7166 HOST_WIDE_INT value;
7167 rtx tmp = ((no_new_pseudos || rtx_equal_p (operands[0], operands[1]))
7168 ? operands[0] : gen_reg_rtx (DImode));
7169
7170 if (GET_CODE (operands[2]) == CONST_INT)
7171 {
7172 value = INTVAL (operands[2]);
7173 emit_insn (gen_iordi3 (tmp, operands[1],
7174 GEN_INT (value & (~ (HOST_WIDE_INT) 0xffff))));
7175 }
7176 else
7177 {
7178 value = CONST_DOUBLE_LOW (operands[2]);
7179 emit_insn (gen_iordi3 (tmp, operands[1],
7180 immed_double_const (value
7181 & (~ (HOST_WIDE_INT) 0xffff),
7182 0, DImode)));
7183 }
7184
7185 emit_insn (gen_iordi3 (operands[0], tmp, GEN_INT (value & 0xffff)));
7186 DONE;
7187 }
7188 }")
7189
7190 (define_expand "xordi3"
7191 [(set (match_operand:DI 0 "gpc_reg_operand" "")
7192 (xor:DI (match_operand:DI 1 "gpc_reg_operand" "")
7193 (match_operand:DI 2 "reg_or_logical_cint_operand" "")))]
7194 "TARGET_POWERPC64"
7195 "
7196 {
7197 if (non_logical_cint_operand (operands[2], DImode))
7198 {
7199 HOST_WIDE_INT value;
7200 rtx tmp = ((no_new_pseudos || rtx_equal_p (operands[0], operands[1]))
7201 ? operands[0] : gen_reg_rtx (DImode));
7202
7203 if (GET_CODE (operands[2]) == CONST_INT)
7204 {
7205 value = INTVAL (operands[2]);
7206 emit_insn (gen_xordi3 (tmp, operands[1],
7207 GEN_INT (value & (~ (HOST_WIDE_INT) 0xffff))));
7208 }
7209 else
7210 {
7211 value = CONST_DOUBLE_LOW (operands[2]);
7212 emit_insn (gen_xordi3 (tmp, operands[1],
7213 immed_double_const (value
7214 & (~ (HOST_WIDE_INT) 0xffff),
7215 0, DImode)));
7216 }
7217
7218 emit_insn (gen_xordi3 (operands[0], tmp, GEN_INT (value & 0xffff)));
7219 DONE;
7220 }
7221 }")
7222
7223 (define_insn "*booldi3_internal1"
7224 [(set (match_operand:DI 0 "gpc_reg_operand" "=r,r,r")
7225 (match_operator:DI 3 "boolean_or_operator"
7226 [(match_operand:DI 1 "gpc_reg_operand" "%r,r,r")
7227 (match_operand:DI 2 "logical_operand" "r,K,JF")]))]
7228 "TARGET_POWERPC64"
7229 "@
7230 %q3 %0,%1,%2
7231 %q3i %0,%1,%b2
7232 %q3is %0,%1,%u2")
7233
7234 (define_insn "*booldi3_internal2"
7235 [(set (match_operand:CC 0 "cc_reg_operand" "=x,?y")
7236 (compare:CC (match_operator:DI 4 "boolean_or_operator"
7237 [(match_operand:DI 1 "gpc_reg_operand" "%r,r")
7238 (match_operand:DI 2 "gpc_reg_operand" "r,r")])
7239 (const_int 0)))
7240 (clobber (match_scratch:DI 3 "=r,r"))]
7241 "TARGET_POWERPC64"
7242 "@
7243 %q4. %3,%1,%2
7244 #"
7245 [(set_attr "type" "compare")
7246 (set_attr "length" "4,8")])
7247
7248 (define_split
7249 [(set (match_operand:CC 0 "cc_reg_not_cr0_operand" "")
7250 (compare:CC (match_operator:DI 4 "boolean_operator"
7251 [(match_operand:DI 1 "gpc_reg_operand" "")
7252 (match_operand:DI 2 "gpc_reg_operand" "")])
7253 (const_int 0)))
7254 (clobber (match_scratch:DI 3 ""))]
7255 "TARGET_POWERPC64 && reload_completed"
7256 [(set (match_dup 3) (match_dup 4))
7257 (set (match_dup 0)
7258 (compare:CC (match_dup 3)
7259 (const_int 0)))]
7260 "")
7261
7262 (define_insn "*booldi3_internal3"
7263 [(set (match_operand:CC 3 "cc_reg_operand" "=x,?y")
7264 (compare:CC (match_operator:DI 4 "boolean_operator"
7265 [(match_operand:DI 1 "gpc_reg_operand" "%r,r")
7266 (match_operand:DI 2 "gpc_reg_operand" "r,r")])
7267 (const_int 0)))
7268 (set (match_operand:DI 0 "gpc_reg_operand" "=r,r")
7269 (match_dup 4))]
7270 "TARGET_POWERPC64"
7271 "@
7272 %q4. %0,%1,%2
7273 #"
7274 [(set_attr "type" "compare")
7275 (set_attr "length" "4,8")])
7276
7277 (define_split
7278 [(set (match_operand:CC 3 "cc_reg_not_cr0_operand" "")
7279 (compare:CC (match_operator:DI 4 "boolean_operator"
7280 [(match_operand:DI 1 "gpc_reg_operand" "")
7281 (match_operand:DI 2 "gpc_reg_operand" "")])
7282 (const_int 0)))
7283 (set (match_operand:DI 0 "gpc_reg_operand" "")
7284 (match_dup 4))]
7285 "TARGET_POWERPC64 && reload_completed"
7286 [(set (match_dup 0) (match_dup 4))
7287 (set (match_dup 3)
7288 (compare:CC (match_dup 0)
7289 (const_int 0)))]
7290 "")
7291
7292 ;; Split a logical operation that we can't do in one insn into two insns,
7293 ;; each of which does one 16-bit part. This is used by combine.
7294
7295 (define_split
7296 [(set (match_operand:DI 0 "gpc_reg_operand" "")
7297 (match_operator:DI 3 "boolean_or_operator"
7298 [(match_operand:DI 1 "gpc_reg_operand" "")
7299 (match_operand:DI 2 "non_logical_cint_operand" "")]))]
7300 "TARGET_POWERPC64"
7301 [(set (match_dup 0) (match_dup 4))
7302 (set (match_dup 0) (match_dup 5))]
7303 "
7304 {
7305 rtx i3,i4;
7306
7307 if (GET_CODE (operands[2]) == CONST_DOUBLE)
7308 {
7309 HOST_WIDE_INT value = CONST_DOUBLE_LOW (operands[2]);
7310 i3 = immed_double_const (value & (~ (HOST_WIDE_INT) 0xffff),
7311 0, DImode);
7312 i4 = GEN_INT (value & 0xffff);
7313 }
7314 else
7315 {
7316 i3 = GEN_INT (INTVAL (operands[2])
7317 & (~ (HOST_WIDE_INT) 0xffff));
7318 i4 = GEN_INT (INTVAL (operands[2]) & 0xffff);
7319 }
7320 operands[4] = gen_rtx (GET_CODE (operands[3]), DImode,
7321 operands[1], i3);
7322 operands[5] = gen_rtx (GET_CODE (operands[3]), DImode,
7323 operands[0], i4);
7324 }")
7325
7326 (define_insn "*boolcdi3_internal1"
7327 [(set (match_operand:DI 0 "gpc_reg_operand" "=r")
7328 (match_operator:DI 3 "boolean_operator"
7329 [(not:DI (match_operand:DI 1 "gpc_reg_operand" "r"))
7330 (match_operand:DI 2 "gpc_reg_operand" "r")]))]
7331 "TARGET_POWERPC64"
7332 "%q3 %0,%2,%1")
7333
7334 (define_insn "*boolcdi3_internal2"
7335 [(set (match_operand:CC 0 "cc_reg_operand" "=x,?y")
7336 (compare:CC (match_operator:DI 4 "boolean_operator"
7337 [(not:DI (match_operand:DI 1 "gpc_reg_operand" "r,r"))
7338 (match_operand:DI 2 "gpc_reg_operand" "r,r")])
7339 (const_int 0)))
7340 (clobber (match_scratch:DI 3 "=r,r"))]
7341 "TARGET_POWERPC64"
7342 "@
7343 %q4. %3,%2,%1
7344 #"
7345 [(set_attr "type" "compare")
7346 (set_attr "length" "4,8")])
7347
7348 (define_split
7349 [(set (match_operand:CC 0 "cc_reg_not_cr0_operand" "")
7350 (compare:CC (match_operator:DI 4 "boolean_operator"
7351 [(not:DI (match_operand:DI 1 "gpc_reg_operand" ""))
7352 (match_operand:DI 2 "gpc_reg_operand" "")])
7353 (const_int 0)))
7354 (clobber (match_scratch:DI 3 ""))]
7355 "TARGET_POWERPC64 && reload_completed"
7356 [(set (match_dup 3) (match_dup 4))
7357 (set (match_dup 0)
7358 (compare:CC (match_dup 3)
7359 (const_int 0)))]
7360 "")
7361
7362 (define_insn "*boolcdi3_internal3"
7363 [(set (match_operand:CC 3 "cc_reg_operand" "=x,?y")
7364 (compare:CC (match_operator:DI 4 "boolean_operator"
7365 [(not:DI (match_operand:DI 1 "gpc_reg_operand" "%r,r"))
7366 (match_operand:DI 2 "gpc_reg_operand" "r,r")])
7367 (const_int 0)))
7368 (set (match_operand:DI 0 "gpc_reg_operand" "=r,r")
7369 (match_dup 4))]
7370 "TARGET_POWERPC64"
7371 "@
7372 %q4. %0,%2,%1
7373 #"
7374 [(set_attr "type" "compare")
7375 (set_attr "length" "4,8")])
7376
7377 (define_split
7378 [(set (match_operand:CC 3 "cc_reg_not_cr0_operand" "")
7379 (compare:CC (match_operator:DI 4 "boolean_operator"
7380 [(not:DI (match_operand:DI 1 "gpc_reg_operand" ""))
7381 (match_operand:DI 2 "gpc_reg_operand" "")])
7382 (const_int 0)))
7383 (set (match_operand:DI 0 "gpc_reg_operand" "")
7384 (match_dup 4))]
7385 "TARGET_POWERPC64 && reload_completed"
7386 [(set (match_dup 0) (match_dup 4))
7387 (set (match_dup 3)
7388 (compare:CC (match_dup 0)
7389 (const_int 0)))]
7390 "")
7391
7392 (define_insn "*boolccdi3_internal1"
7393 [(set (match_operand:DI 0 "gpc_reg_operand" "=r")
7394 (match_operator:DI 3 "boolean_operator"
7395 [(not:DI (match_operand:DI 1 "gpc_reg_operand" "r"))
7396 (not:DI (match_operand:DI 2 "gpc_reg_operand" "r"))]))]
7397 "TARGET_POWERPC64"
7398 "%q3 %0,%1,%2")
7399
7400 (define_insn "*boolccdi3_internal2"
7401 [(set (match_operand:CC 0 "cc_reg_operand" "=x,?y")
7402 (compare:CC (match_operator:DI 4 "boolean_operator"
7403 [(not:DI (match_operand:DI 1 "gpc_reg_operand" "r,r"))
7404 (not:DI (match_operand:DI 2 "gpc_reg_operand" "r,r"))])
7405 (const_int 0)))
7406 (clobber (match_scratch:DI 3 "=r,r"))]
7407 "TARGET_POWERPC64"
7408 "@
7409 %q4. %3,%1,%2
7410 #"
7411 [(set_attr "type" "compare")
7412 (set_attr "length" "4,8")])
7413
7414 (define_split
7415 [(set (match_operand:CC 0 "cc_reg_not_cr0_operand" "")
7416 (compare:CC (match_operator:DI 4 "boolean_operator"
7417 [(not:DI (match_operand:DI 1 "gpc_reg_operand" ""))
7418 (not:DI (match_operand:DI 2 "gpc_reg_operand" ""))])
7419 (const_int 0)))
7420 (clobber (match_scratch:DI 3 ""))]
7421 "TARGET_POWERPC64 && reload_completed"
7422 [(set (match_dup 3) (match_dup 4))
7423 (set (match_dup 0)
7424 (compare:CC (match_dup 3)
7425 (const_int 0)))]
7426 "")
7427
7428 (define_insn "*boolccdi3_internal3"
7429 [(set (match_operand:CC 3 "cc_reg_operand" "=x,?y")
7430 (compare:CC (match_operator:DI 4 "boolean_operator"
7431 [(not:DI (match_operand:DI 1 "gpc_reg_operand" "%r,r"))
7432 (not:DI (match_operand:DI 2 "gpc_reg_operand" "r,r"))])
7433 (const_int 0)))
7434 (set (match_operand:DI 0 "gpc_reg_operand" "=r,r")
7435 (match_dup 4))]
7436 "TARGET_POWERPC64"
7437 "@
7438 %q4. %0,%1,%2
7439 #"
7440 [(set_attr "type" "compare")
7441 (set_attr "length" "4,8")])
7442
7443 (define_split
7444 [(set (match_operand:CC 3 "cc_reg_not_cr0_operand" "")
7445 (compare:CC (match_operator:DI 4 "boolean_operator"
7446 [(not:DI (match_operand:DI 1 "gpc_reg_operand" ""))
7447 (not:DI (match_operand:DI 2 "gpc_reg_operand" ""))])
7448 (const_int 0)))
7449 (set (match_operand:DI 0 "gpc_reg_operand" "")
7450 (match_dup 4))]
7451 "TARGET_POWERPC64 && reload_completed"
7452 [(set (match_dup 0) (match_dup 4))
7453 (set (match_dup 3)
7454 (compare:CC (match_dup 0)
7455 (const_int 0)))]
7456 "")
7457 \f
7458 ;; Now define ways of moving data around.
7459
7460 ;; Elf specific ways of loading addresses for non-PIC code.
7461 ;; The output of this could be r0, but we make a very strong
7462 ;; preference for a base register because it will usually
7463 ;; be needed there.
7464 (define_insn "elf_high"
7465 [(set (match_operand:SI 0 "gpc_reg_operand" "=b*r")
7466 (high:SI (match_operand 1 "" "")))]
7467 "TARGET_ELF && ! TARGET_64BIT"
7468 "{liu|lis} %0,%1@ha")
7469
7470 (define_insn "elf_low"
7471 [(set (match_operand:SI 0 "gpc_reg_operand" "=r,r")
7472 (lo_sum:SI (match_operand:SI 1 "gpc_reg_operand" "b,!*r")
7473 (match_operand 2 "" "")))]
7474 "TARGET_ELF && ! TARGET_64BIT"
7475 "@
7476 {cal|la} %0,%2@l(%1)
7477 {ai|addic} %0,%1,%K2")
7478
7479 ;; Mach-O PIC trickery.
7480 (define_insn "macho_high"
7481 [(set (match_operand:SI 0 "gpc_reg_operand" "=b*r")
7482 (high:SI (match_operand 1 "" "")))]
7483 "TARGET_MACHO && ! TARGET_64BIT"
7484 "{liu|lis} %0,ha16(%1)")
7485
7486 (define_insn "macho_low"
7487 [(set (match_operand:SI 0 "gpc_reg_operand" "=r,r")
7488 (lo_sum:SI (match_operand:SI 1 "gpc_reg_operand" "b,!*r")
7489 (match_operand 2 "" "")))]
7490 "TARGET_MACHO && ! TARGET_64BIT"
7491 "@
7492 {cal %0,%a2@l(%1)|la %0,lo16(%2)(%1)}
7493 {cal %0,%a2@l(%1)|addic %0,%1,lo16(%2)}")
7494
7495 ;; Set up a register with a value from the GOT table
7496
7497 (define_expand "movsi_got"
7498 [(set (match_operand:SI 0 "gpc_reg_operand" "")
7499 (unspec:SI [(match_operand:SI 1 "got_operand" "")
7500 (match_dup 2)] 8))]
7501 "DEFAULT_ABI == ABI_V4 && flag_pic == 1"
7502 "
7503 {
7504 if (GET_CODE (operands[1]) == CONST)
7505 {
7506 rtx offset = const0_rtx;
7507 HOST_WIDE_INT value;
7508
7509 operands[1] = eliminate_constant_term (XEXP (operands[1], 0), &offset);
7510 value = INTVAL (offset);
7511 if (value != 0)
7512 {
7513 rtx tmp = (no_new_pseudos ? operands[0] : gen_reg_rtx (Pmode));
7514 emit_insn (gen_movsi_got (tmp, operands[1]));
7515 emit_insn (gen_addsi3 (operands[0], tmp, offset));
7516 DONE;
7517 }
7518 }
7519
7520 operands[2] = rs6000_got_register (operands[1]);
7521 }")
7522
7523 (define_insn "*movsi_got_internal"
7524 [(set (match_operand:SI 0 "gpc_reg_operand" "=r")
7525 (unspec:SI [(match_operand:SI 1 "got_no_const_operand" "")
7526 (match_operand:SI 2 "gpc_reg_operand" "b")] 8))]
7527 "DEFAULT_ABI == ABI_V4 && flag_pic == 1"
7528 "{l|lwz} %0,%a1@got(%2)"
7529 [(set_attr "type" "load")])
7530
7531 ;; Used by sched, shorten_branches and final when the GOT pseudo reg
7532 ;; didn't get allocated to a hard register.
7533 (define_split
7534 [(set (match_operand:SI 0 "gpc_reg_operand" "")
7535 (unspec:SI [(match_operand:SI 1 "got_no_const_operand" "")
7536 (match_operand:SI 2 "memory_operand" "")] 8))]
7537 "DEFAULT_ABI == ABI_V4
7538 && flag_pic == 1
7539 && (reload_in_progress || reload_completed)"
7540 [(set (match_dup 0) (match_dup 2))
7541 (set (match_dup 0) (unspec:SI [(match_dup 1)(match_dup 0)] 8))]
7542 "")
7543
7544 ;; For SI, we special-case integers that can't be loaded in one insn. We
7545 ;; do the load 16-bits at a time. We could do this by loading from memory,
7546 ;; and this is even supposed to be faster, but it is simpler not to get
7547 ;; integers in the TOC.
7548 (define_expand "movsi"
7549 [(set (match_operand:SI 0 "general_operand" "")
7550 (match_operand:SI 1 "any_operand" ""))]
7551 ""
7552 "{ rs6000_emit_move (operands[0], operands[1], SImode); DONE; }")
7553
7554 (define_insn "movsi_low"
7555 [(set (match_operand:SI 0 "gpc_reg_operand" "=r")
7556 (mem:SI (lo_sum:SI (match_operand:SI 1 "gpc_reg_operand" "b")
7557 (match_operand 2 "" ""))))]
7558 "TARGET_MACHO && ! TARGET_64BIT"
7559 "{l|lwz} %0,lo16(%2)(%1)"
7560 [(set_attr "type" "load")
7561 (set_attr "length" "4")])
7562
7563 (define_insn "movsi_low_st"
7564 [(set (mem:SI (lo_sum:SI (match_operand:SI 1 "gpc_reg_operand" "b")
7565 (match_operand 2 "" "")))
7566 (match_operand:SI 0 "gpc_reg_operand" "r"))]
7567 "TARGET_MACHO && ! TARGET_64BIT"
7568 "{st|stw} %0,lo16(%2)(%1)"
7569 [(set_attr "type" "store")
7570 (set_attr "length" "4")])
7571
7572 (define_insn "movdf_low"
7573 [(set (match_operand:DF 0 "gpc_reg_operand" "=f,!r")
7574 (mem:DF (lo_sum:SI (match_operand:SI 1 "gpc_reg_operand" "b,b")
7575 (match_operand 2 "" ""))))]
7576 "TARGET_MACHO && TARGET_HARD_FLOAT && TARGET_FPRS && ! TARGET_64BIT"
7577 "*
7578 {
7579 switch (which_alternative)
7580 {
7581 case 0:
7582 return \"lfd %0,lo16(%2)(%1)\";
7583 case 1:
7584 {
7585 rtx operands2[4];
7586 operands2[0] = operands[0];
7587 operands2[1] = operands[1];
7588 operands2[2] = operands[2];
7589 operands2[3] = gen_rtx_REG (SImode, RS6000_PIC_OFFSET_TABLE_REGNUM);
7590 output_asm_insn (\"{l|lwz} %0,lo16(%2)(%1)\", operands);
7591 #if TARGET_MACHO
7592 if (MACHO_DYNAMIC_NO_PIC_P)
7593 output_asm_insn (\"{liu|lis} %L0,ha16(%2+4)\", operands);
7594 else
7595 /* We cannot rely on ha16(low half)==ha16(high half), alas,
7596 although in practice it almost always is. */
7597 output_asm_insn (\"{cau|addis} %L0,%3,ha16(%2+4)\", operands2);
7598 #endif
7599 return (\"{l|lwz} %L0,lo16(%2+4)(%L0)\");
7600 }
7601 default:
7602 abort();
7603 }
7604 }"
7605 [(set_attr "type" "load")
7606 (set_attr "length" "4,12")])
7607
7608 (define_insn "movdf_low_st"
7609 [(set (mem:DF (lo_sum:SI (match_operand:SI 1 "gpc_reg_operand" "b")
7610 (match_operand 2 "" "")))
7611 (match_operand:DF 0 "gpc_reg_operand" "f"))]
7612 "TARGET_MACHO && TARGET_HARD_FLOAT && TARGET_FPRS && ! TARGET_64BIT"
7613 "stfd %0,lo16(%2)(%1)"
7614 [(set_attr "type" "store")
7615 (set_attr "length" "4")])
7616
7617 (define_insn "movsf_low"
7618 [(set (match_operand:SF 0 "gpc_reg_operand" "=f,!r")
7619 (mem:SF (lo_sum:SI (match_operand:SI 1 "gpc_reg_operand" "b,b")
7620 (match_operand 2 "" ""))))]
7621 "TARGET_MACHO && TARGET_HARD_FLOAT && TARGET_FPRS && ! TARGET_64BIT"
7622 "@
7623 lfs %0,lo16(%2)(%1)
7624 {l|lwz} %0,lo16(%2)(%1)"
7625 [(set_attr "type" "load")
7626 (set_attr "length" "4")])
7627
7628 (define_insn "movsf_low_st"
7629 [(set (mem:SF (lo_sum:SI (match_operand:SI 1 "gpc_reg_operand" "b,b")
7630 (match_operand 2 "" "")))
7631 (match_operand:SF 0 "gpc_reg_operand" "f,!r"))]
7632 "TARGET_MACHO && TARGET_HARD_FLOAT && TARGET_FPRS && ! TARGET_64BIT"
7633 "@
7634 stfs %0,lo16(%2)(%1)
7635 {st|stw} %0,lo16(%2)(%1)"
7636 [(set_attr "type" "store")
7637 (set_attr "length" "4")])
7638
7639 (define_insn "*movsi_internal1"
7640 [(set (match_operand:SI 0 "nonimmediate_operand" "=r,r,r,m,r,r,r,r,r,*q,*c*l,*h,*h")
7641 (match_operand:SI 1 "input_operand" "r,U,m,r,I,L,n,R,*h,r,r,r,0"))]
7642 "gpc_reg_operand (operands[0], SImode)
7643 || gpc_reg_operand (operands[1], SImode)"
7644 "@
7645 mr %0,%1
7646 {cal|la} %0,%a1
7647 {l%U1%X1|lwz%U1%X1} %0,%1
7648 {st%U0%X0|stw%U0%X0} %1,%0
7649 {lil|li} %0,%1
7650 {liu|lis} %0,%v1
7651 #
7652 {cal|la} %0,%a1
7653 mf%1 %0
7654 mt%0 %1
7655 mt%0 %1
7656 mt%0 %1
7657 {cror 0,0,0|nop}"
7658 [(set_attr "type" "*,*,load,store,*,*,*,*,*,*,mtjmpr,*,*")
7659 (set_attr "length" "4,4,4,4,4,4,8,4,4,4,4,4,4")])
7660
7661 ;; Split a load of a large constant into the appropriate two-insn
7662 ;; sequence.
7663
7664 (define_split
7665 [(set (match_operand:SI 0 "gpc_reg_operand" "")
7666 (match_operand:SI 1 "const_int_operand" ""))]
7667 "(unsigned HOST_WIDE_INT) (INTVAL (operands[1]) + 0x8000) >= 0x10000
7668 && (INTVAL (operands[1]) & 0xffff) != 0"
7669 [(set (match_dup 0)
7670 (match_dup 2))
7671 (set (match_dup 0)
7672 (ior:SI (match_dup 0)
7673 (match_dup 3)))]
7674 "
7675 { rtx tem = rs6000_emit_set_const (operands[0], SImode, operands[1], 2);
7676
7677 if (tem == operands[0])
7678 DONE;
7679 else
7680 FAIL;
7681 }")
7682
7683 (define_insn "*movsi_internal2"
7684 [(set (match_operand:CC 2 "cc_reg_operand" "=x,?y")
7685 (compare:CC (match_operand:SI 1 "gpc_reg_operand" "r,r")
7686 (const_int 0)))
7687 (set (match_operand:SI 0 "gpc_reg_operand" "=r,r") (match_dup 1))]
7688 "! TARGET_POWERPC64"
7689 "@
7690 mr. %0,%1
7691 #"
7692 [(set_attr "type" "compare")
7693 (set_attr "length" "4,8")])
7694 \f
7695 (define_split
7696 [(set (match_operand:CC 2 "cc_reg_not_cr0_operand" "")
7697 (compare:CC (match_operand:SI 1 "gpc_reg_operand" "")
7698 (const_int 0)))
7699 (set (match_operand:SI 0 "gpc_reg_operand" "") (match_dup 1))]
7700 "! TARGET_POWERPC64 && reload_completed"
7701 [(set (match_dup 0) (match_dup 1))
7702 (set (match_dup 2)
7703 (compare:CC (match_dup 0)
7704 (const_int 0)))]
7705 "")
7706
7707 (define_expand "movhi"
7708 [(set (match_operand:HI 0 "general_operand" "")
7709 (match_operand:HI 1 "any_operand" ""))]
7710 ""
7711 "{ rs6000_emit_move (operands[0], operands[1], HImode); DONE; }")
7712
7713 (define_insn "*movhi_internal"
7714 [(set (match_operand:HI 0 "nonimmediate_operand" "=r,r,m,r,r,*q,*c*l,*h")
7715 (match_operand:HI 1 "input_operand" "r,m,r,i,*h,r,r,0"))]
7716 "gpc_reg_operand (operands[0], HImode)
7717 || gpc_reg_operand (operands[1], HImode)"
7718 "@
7719 mr %0,%1
7720 lhz%U1%X1 %0,%1
7721 sth%U0%X0 %1,%0
7722 {lil|li} %0,%w1
7723 mf%1 %0
7724 mt%0 %1
7725 mt%0 %1
7726 {cror 0,0,0|nop}"
7727 [(set_attr "type" "*,load,store,*,*,*,mtjmpr,*")])
7728
7729 (define_expand "movqi"
7730 [(set (match_operand:QI 0 "general_operand" "")
7731 (match_operand:QI 1 "any_operand" ""))]
7732 ""
7733 "{ rs6000_emit_move (operands[0], operands[1], QImode); DONE; }")
7734
7735 (define_insn "*movqi_internal"
7736 [(set (match_operand:QI 0 "nonimmediate_operand" "=r,r,m,r,r,*q,*c*l,*h")
7737 (match_operand:QI 1 "input_operand" "r,m,r,i,*h,r,r,0"))]
7738 "gpc_reg_operand (operands[0], QImode)
7739 || gpc_reg_operand (operands[1], QImode)"
7740 "@
7741 mr %0,%1
7742 lbz%U1%X1 %0,%1
7743 stb%U0%X0 %1,%0
7744 {lil|li} %0,%1
7745 mf%1 %0
7746 mt%0 %1
7747 mt%0 %1
7748 {cror 0,0,0|nop}"
7749 [(set_attr "type" "*,load,store,*,*,*,mtjmpr,*")])
7750 \f
7751 ;; Here is how to move condition codes around. When we store CC data in
7752 ;; an integer register or memory, we store just the high-order 4 bits.
7753 ;; This lets us not shift in the most common case of CR0.
7754 (define_expand "movcc"
7755 [(set (match_operand:CC 0 "nonimmediate_operand" "")
7756 (match_operand:CC 1 "nonimmediate_operand" ""))]
7757 ""
7758 "")
7759
7760 (define_insn "*movcc_internal1"
7761 [(set (match_operand:CC 0 "nonimmediate_operand" "=y,x,?y,r,r,r,r,q,cl,r,m")
7762 (match_operand:CC 1 "nonimmediate_operand" "y,r,r,x,y,r,h,r,r,m,r"))]
7763 "register_operand (operands[0], CCmode)
7764 || register_operand (operands[1], CCmode)"
7765 "@
7766 mcrf %0,%1
7767 mtcrf 128,%1
7768 {rlinm|rlwinm} %1,%1,%F0,0xffffffff\;mtcrf %R0,%1\;{rlinm|rlwinm} %1,%1,%f0,0xffffffff
7769 mfcr %0
7770 mfcr %0\;{rlinm|rlwinm} %0,%0,%f1,0xf0000000
7771 mr %0,%1
7772 mf%1 %0
7773 mt%0 %1
7774 mt%0 %1
7775 {l%U1%X1|lwz%U1%X1} %0,%1
7776 {st%U0%U1|stw%U0%U1} %1,%0"
7777 [(set_attr "type" "cr_logical,mtcr,mtcr,mfcr,mfcr,*,*,*,mtjmpr,load,store")
7778 (set_attr "length" "4,4,12,4,8,4,4,4,4,4,4")])
7779 \f
7780 ;; For floating-point, we normally deal with the floating-point registers
7781 ;; unless -msoft-float is used. The sole exception is that parameter passing
7782 ;; can produce floating-point values in fixed-point registers. Unless the
7783 ;; value is a simple constant or already in memory, we deal with this by
7784 ;; allocating memory and copying the value explicitly via that memory location.
7785 (define_expand "movsf"
7786 [(set (match_operand:SF 0 "nonimmediate_operand" "")
7787 (match_operand:SF 1 "any_operand" ""))]
7788 ""
7789 "{ rs6000_emit_move (operands[0], operands[1], SFmode); DONE; }")
7790
7791 (define_split
7792 [(set (match_operand:SF 0 "gpc_reg_operand" "")
7793 (match_operand:SF 1 "const_double_operand" ""))]
7794 "reload_completed
7795 && ((GET_CODE (operands[0]) == REG && REGNO (operands[0]) <= 31)
7796 || (GET_CODE (operands[0]) == SUBREG
7797 && GET_CODE (SUBREG_REG (operands[0])) == REG
7798 && REGNO (SUBREG_REG (operands[0])) <= 31))"
7799 [(set (match_dup 2) (match_dup 3))]
7800 "
7801 {
7802 long l;
7803 REAL_VALUE_TYPE rv;
7804
7805 REAL_VALUE_FROM_CONST_DOUBLE (rv, operands[1]);
7806 REAL_VALUE_TO_TARGET_SINGLE (rv, l);
7807
7808 if (! TARGET_POWERPC64)
7809 operands[2] = operand_subword (operands[0], 0, 0, SFmode);
7810 else
7811 operands[2] = gen_lowpart (SImode, operands[0]);
7812
7813 operands[3] = gen_int_mode (l, SImode);
7814 }")
7815
7816 (define_insn "*movsf_hardfloat"
7817 [(set (match_operand:SF 0 "nonimmediate_operand" "=!r,!r,m,f,f,m,!cl,!q,!r,!r,!r")
7818 (match_operand:SF 1 "input_operand" "r,m,r,f,m,f,r,r,h,G,Fn"))]
7819 "(gpc_reg_operand (operands[0], SFmode)
7820 || gpc_reg_operand (operands[1], SFmode))
7821 && (TARGET_HARD_FLOAT && TARGET_FPRS)"
7822 "@
7823 mr %0,%1
7824 {l%U1%X1|lwz%U1%X1} %0,%1
7825 {st%U0%X0|stw%U0%X0} %1,%0
7826 fmr %0,%1
7827 lfs%U1%X1 %0,%1
7828 stfs%U0%X0 %1,%0
7829 mt%0 %1
7830 mt%0 %1
7831 mf%1 %0
7832 #
7833 #"
7834 [(set_attr "type" "*,load,store,fp,fpload,fpstore,*,mtjmpr,*,*,*")
7835 (set_attr "length" "4,4,4,4,4,4,4,4,4,4,8")])
7836
7837 (define_insn "*movsf_softfloat"
7838 [(set (match_operand:SF 0 "nonimmediate_operand" "=r,cl,q,r,r,m,r,r,r,r,r")
7839 (match_operand:SF 1 "input_operand" "r,r,r,h,m,r,I,L,R,G,Fn"))]
7840 "(gpc_reg_operand (operands[0], SFmode)
7841 || gpc_reg_operand (operands[1], SFmode))
7842 && (TARGET_SOFT_FLOAT || !TARGET_FPRS)"
7843 "@
7844 mr %0,%1
7845 mt%0 %1
7846 mt%0 %1
7847 mf%1 %0
7848 {l%U1%X1|lwz%U1%X1} %0,%1
7849 {st%U0%X0|stw%U0%X0} %1,%0
7850 {lil|li} %0,%1
7851 {liu|lis} %0,%v1
7852 {cal|la} %0,%a1
7853 #
7854 #"
7855 [(set_attr "type" "*,mtjmpr,*,*,load,store,*,*,*,*,*")
7856 (set_attr "length" "4,4,4,4,4,4,4,4,4,4,8")])
7857
7858 \f
7859 (define_expand "movdf"
7860 [(set (match_operand:DF 0 "nonimmediate_operand" "")
7861 (match_operand:DF 1 "any_operand" ""))]
7862 ""
7863 "{ rs6000_emit_move (operands[0], operands[1], DFmode); DONE; }")
7864
7865 (define_split
7866 [(set (match_operand:DF 0 "gpc_reg_operand" "")
7867 (match_operand:DF 1 "const_int_operand" ""))]
7868 "! TARGET_POWERPC64 && reload_completed
7869 && ((GET_CODE (operands[0]) == REG && REGNO (operands[0]) <= 31)
7870 || (GET_CODE (operands[0]) == SUBREG
7871 && GET_CODE (SUBREG_REG (operands[0])) == REG
7872 && REGNO (SUBREG_REG (operands[0])) <= 31))"
7873 [(set (match_dup 2) (match_dup 4))
7874 (set (match_dup 3) (match_dup 1))]
7875 "
7876 {
7877 int endian = (WORDS_BIG_ENDIAN == 0);
7878 HOST_WIDE_INT value = INTVAL (operands[1]);
7879
7880 operands[2] = operand_subword (operands[0], endian, 0, DFmode);
7881 operands[3] = operand_subword (operands[0], 1 - endian, 0, DFmode);
7882 #if HOST_BITS_PER_WIDE_INT == 32
7883 operands[4] = (value & 0x80000000) ? constm1_rtx : const0_rtx;
7884 #else
7885 operands[4] = GEN_INT (value >> 32);
7886 operands[1] = GEN_INT (((value & 0xffffffff) ^ 0x80000000) - 0x80000000);
7887 #endif
7888 }")
7889
7890 (define_split
7891 [(set (match_operand:DF 0 "gpc_reg_operand" "")
7892 (match_operand:DF 1 "const_double_operand" ""))]
7893 "! TARGET_POWERPC64 && reload_completed
7894 && ((GET_CODE (operands[0]) == REG && REGNO (operands[0]) <= 31)
7895 || (GET_CODE (operands[0]) == SUBREG
7896 && GET_CODE (SUBREG_REG (operands[0])) == REG
7897 && REGNO (SUBREG_REG (operands[0])) <= 31))"
7898 [(set (match_dup 2) (match_dup 4))
7899 (set (match_dup 3) (match_dup 5))]
7900 "
7901 {
7902 int endian = (WORDS_BIG_ENDIAN == 0);
7903 long l[2];
7904 REAL_VALUE_TYPE rv;
7905
7906 REAL_VALUE_FROM_CONST_DOUBLE (rv, operands[1]);
7907 REAL_VALUE_TO_TARGET_DOUBLE (rv, l);
7908
7909 operands[2] = operand_subword (operands[0], endian, 0, DFmode);
7910 operands[3] = operand_subword (operands[0], 1 - endian, 0, DFmode);
7911 operands[4] = gen_int_mode (l[endian], SImode);
7912 operands[5] = gen_int_mode (l[1 - endian], SImode);
7913 }")
7914
7915 (define_split
7916 [(set (match_operand:DF 0 "gpc_reg_operand" "")
7917 (match_operand:DF 1 "easy_fp_constant" ""))]
7918 "TARGET_POWERPC64 && reload_completed
7919 && ((GET_CODE (operands[0]) == REG && REGNO (operands[0]) <= 31)
7920 || (GET_CODE (operands[0]) == SUBREG
7921 && GET_CODE (SUBREG_REG (operands[0])) == REG
7922 && REGNO (SUBREG_REG (operands[0])) <= 31))"
7923 [(set (match_dup 2) (match_dup 3))]
7924 "
7925 {
7926 int endian = (WORDS_BIG_ENDIAN == 0);
7927 long l[2];
7928 REAL_VALUE_TYPE rv;
7929 #if HOST_BITS_PER_WIDE_INT >= 64
7930 HOST_WIDE_INT val;
7931 #endif
7932
7933 REAL_VALUE_FROM_CONST_DOUBLE (rv, operands[1]);
7934 REAL_VALUE_TO_TARGET_DOUBLE (rv, l);
7935
7936 operands[2] = gen_lowpart (DImode, operands[0]);
7937 /* HIGHPART is lower memory address when WORDS_BIG_ENDIAN. */
7938 #if HOST_BITS_PER_WIDE_INT >= 64
7939 val = ((HOST_WIDE_INT)(unsigned long)l[endian] << 32
7940 | ((HOST_WIDE_INT)(unsigned long)l[1 - endian]));
7941
7942 operands[3] = gen_int_mode (val, DImode);
7943 #else
7944 operands[3] = immed_double_const (l[1 - endian], l[endian], DImode);
7945 #endif
7946 }")
7947
7948 ;; Don't have reload use general registers to load a constant. First,
7949 ;; it might not work if the output operand is the equivalent of
7950 ;; a non-offsettable memref, but also it is less efficient than loading
7951 ;; the constant into an FP register, since it will probably be used there.
7952 ;; The "??" is a kludge until we can figure out a more reasonable way
7953 ;; of handling these non-offsettable values.
7954 (define_insn "*movdf_hardfloat32"
7955 [(set (match_operand:DF 0 "nonimmediate_operand" "=!r,??r,m,f,f,m,!r,!r,!r")
7956 (match_operand:DF 1 "input_operand" "r,m,r,f,m,f,G,H,F"))]
7957 "! TARGET_POWERPC64 && TARGET_HARD_FLOAT && TARGET_FPRS
7958 && (gpc_reg_operand (operands[0], DFmode)
7959 || gpc_reg_operand (operands[1], DFmode))"
7960 "*
7961 {
7962 switch (which_alternative)
7963 {
7964 default:
7965 abort ();
7966 case 0:
7967 /* We normally copy the low-numbered register first. However, if
7968 the first register operand 0 is the same as the second register
7969 of operand 1, we must copy in the opposite order. */
7970 if (REGNO (operands[0]) == REGNO (operands[1]) + 1)
7971 return \"mr %L0,%L1\;mr %0,%1\";
7972 else
7973 return \"mr %0,%1\;mr %L0,%L1\";
7974 case 1:
7975 if (offsettable_memref_p (operands[1])
7976 || (GET_CODE (operands[1]) == MEM
7977 && (GET_CODE (XEXP (operands[1], 0)) == LO_SUM
7978 || GET_CODE (XEXP (operands[1], 0)) == PRE_INC
7979 || GET_CODE (XEXP (operands[1], 0)) == PRE_DEC)))
7980 {
7981 /* If the low-address word is used in the address, we must load
7982 it last. Otherwise, load it first. Note that we cannot have
7983 auto-increment in that case since the address register is
7984 known to be dead. */
7985 if (refers_to_regno_p (REGNO (operands[0]), REGNO (operands[0]) + 1,
7986 operands[1], 0))
7987 return \"{l|lwz} %L0,%L1\;{l|lwz} %0,%1\";
7988 else
7989 return \"{l%U1|lwz%U1} %0,%1\;{l|lwz} %L0,%L1\";
7990 }
7991 else
7992 {
7993 rtx addreg;
7994
7995 addreg = find_addr_reg (XEXP (operands[1], 0));
7996 if (refers_to_regno_p (REGNO (operands[0]),
7997 REGNO (operands[0]) + 1,
7998 operands[1], 0))
7999 {
8000 output_asm_insn (\"{cal|la} %0,4(%0)\", &addreg);
8001 output_asm_insn (\"{lx|lwzx} %L0,%1\", operands);
8002 output_asm_insn (\"{cal|la} %0,-4(%0)\", &addreg);
8003 return \"{lx|lwzx} %0,%1\";
8004 }
8005 else
8006 {
8007 output_asm_insn (\"{lx|lwzx} %0,%1\", operands);
8008 output_asm_insn (\"{cal|la} %0,4(%0)\", &addreg);
8009 output_asm_insn (\"{lx|lwzx} %L0,%1\", operands);
8010 output_asm_insn (\"{cal|la} %0,-4(%0)\", &addreg);
8011 return \"\";
8012 }
8013 }
8014 case 2:
8015 if (offsettable_memref_p (operands[0])
8016 || (GET_CODE (operands[0]) == MEM
8017 && (GET_CODE (XEXP (operands[0], 0)) == LO_SUM
8018 || GET_CODE (XEXP (operands[0], 0)) == PRE_INC
8019 || GET_CODE (XEXP (operands[0], 0)) == PRE_DEC)))
8020 return \"{st%U0|stw%U0} %1,%0\;{st|stw} %L1,%L0\";
8021 else
8022 {
8023 rtx addreg;
8024
8025 addreg = find_addr_reg (XEXP (operands[0], 0));
8026 output_asm_insn (\"{stx|stwx} %1,%0\", operands);
8027 output_asm_insn (\"{cal|la} %0,4(%0)\", &addreg);
8028 output_asm_insn (\"{stx|stwx} %L1,%0\", operands);
8029 output_asm_insn (\"{cal|la} %0,-4(%0)\", &addreg);
8030 return \"\";
8031 }
8032 case 3:
8033 return \"fmr %0,%1\";
8034 case 4:
8035 return \"lfd%U1%X1 %0,%1\";
8036 case 5:
8037 return \"stfd%U0%X0 %1,%0\";
8038 case 6:
8039 case 7:
8040 case 8:
8041 return \"#\";
8042 }
8043 }"
8044 [(set_attr "type" "*,load,store,fp,fpload,fpstore,*,*,*")
8045 (set_attr "length" "8,16,16,4,4,4,8,12,16")])
8046
8047 (define_insn "*movdf_softfloat32"
8048 [(set (match_operand:DF 0 "nonimmediate_operand" "=r,r,m,r,r,r")
8049 (match_operand:DF 1 "input_operand" "r,m,r,G,H,F"))]
8050 "! TARGET_POWERPC64 && (TARGET_SOFT_FLOAT || !TARGET_FPRS)
8051 && (gpc_reg_operand (operands[0], DFmode)
8052 || gpc_reg_operand (operands[1], DFmode))"
8053 "*
8054 {
8055 switch (which_alternative)
8056 {
8057 default:
8058 abort ();
8059 case 0:
8060 /* We normally copy the low-numbered register first. However, if
8061 the first register operand 0 is the same as the second register of
8062 operand 1, we must copy in the opposite order. */
8063 if (REGNO (operands[0]) == REGNO (operands[1]) + 1)
8064 return \"mr %L0,%L1\;mr %0,%1\";
8065 else
8066 return \"mr %0,%1\;mr %L0,%L1\";
8067 case 1:
8068 /* If the low-address word is used in the address, we must load
8069 it last. Otherwise, load it first. Note that we cannot have
8070 auto-increment in that case since the address register is
8071 known to be dead. */
8072 if (refers_to_regno_p (REGNO (operands[0]), REGNO (operands[0]) + 1,
8073 operands[1], 0))
8074 return \"{l|lwz} %L0,%L1\;{l|lwz} %0,%1\";
8075 else
8076 return \"{l%U1|lwz%U1} %0,%1\;{l|lwz} %L0,%L1\";
8077 case 2:
8078 return \"{st%U0|stw%U0} %1,%0\;{st|stw} %L1,%L0\";
8079 case 3:
8080 case 4:
8081 case 5:
8082 return \"#\";
8083 }
8084 }"
8085 [(set_attr "type" "*,load,store,*,*,*")
8086 (set_attr "length" "8,8,8,8,12,16")])
8087
8088 (define_insn "*movdf_hardfloat64"
8089 [(set (match_operand:DF 0 "nonimmediate_operand" "=!r,??r,m,f,f,m,!cl,!r,!r,!r,!r")
8090 (match_operand:DF 1 "input_operand" "r,m,r,f,m,f,r,h,G,H,F"))]
8091 "TARGET_POWERPC64 && TARGET_HARD_FLOAT && TARGET_FPRS
8092 && (gpc_reg_operand (operands[0], DFmode)
8093 || gpc_reg_operand (operands[1], DFmode))"
8094 "@
8095 mr %0,%1
8096 ld%U1%X1 %0,%1
8097 std%U0%X0 %1,%0
8098 fmr %0,%1
8099 lfd%U1%X1 %0,%1
8100 stfd%U0%X0 %1,%0
8101 mt%0 %1
8102 mf%1 %0
8103 #
8104 #
8105 #"
8106 [(set_attr "type" "*,load,store,fp,fpload,fpstore,mtjmpr,*,*,*,*")
8107 (set_attr "length" "4,4,4,4,4,4,4,4,8,12,16")])
8108
8109 (define_insn "*movdf_softfloat64"
8110 [(set (match_operand:DF 0 "nonimmediate_operand" "=r,cl,r,r,m,r,r,r")
8111 (match_operand:DF 1 "input_operand" "r,r,h,m,r,G,H,F"))]
8112 "TARGET_POWERPC64 && (TARGET_SOFT_FLOAT || !TARGET_FPRS)
8113 && (gpc_reg_operand (operands[0], DFmode)
8114 || gpc_reg_operand (operands[1], DFmode))"
8115 "@
8116 mr %0,%1
8117 mt%0 %1
8118 mf%1 %0
8119 ld%U1%X1 %0,%1
8120 std%U0%X0 %1,%0
8121 #
8122 #
8123 #"
8124 [(set_attr "type" "*,*,*,load,store,*,*,*")
8125 (set_attr "length" "4,4,4,4,4,8,12,16")])
8126 \f
8127 (define_expand "movtf"
8128 [(set (match_operand:TF 0 "general_operand" "")
8129 (match_operand:TF 1 "any_operand" ""))]
8130 "DEFAULT_ABI == ABI_AIX && TARGET_HARD_FLOAT && TARGET_FPRS
8131 && TARGET_LONG_DOUBLE_128"
8132 "{ rs6000_emit_move (operands[0], operands[1], TFmode); DONE; }")
8133
8134 (define_insn "*movtf_internal"
8135 [(set (match_operand:TF 0 "nonimmediate_operand" "=f,f,m,!r,!r,!r")
8136 (match_operand:TF 1 "input_operand" "f,m,f,G,H,F"))]
8137 "DEFAULT_ABI == ABI_AIX && TARGET_HARD_FLOAT && TARGET_FPRS
8138 && TARGET_LONG_DOUBLE_128
8139 && (gpc_reg_operand (operands[0], TFmode)
8140 || gpc_reg_operand (operands[1], TFmode))"
8141 "*
8142 {
8143 switch (which_alternative)
8144 {
8145 default:
8146 abort ();
8147 case 0:
8148 /* We normally copy the low-numbered register first. However, if
8149 the first register operand 0 is the same as the second register of
8150 operand 1, we must copy in the opposite order. */
8151 if (REGNO (operands[0]) == REGNO (operands[1]) + 1)
8152 return \"fmr %L0,%L1\;fmr %0,%1\";
8153 else
8154 return \"fmr %0,%1\;fmr %L0,%L1\";
8155 case 1:
8156 return \"lfd %0,%1\;lfd %L0,%Y1\";
8157 case 2:
8158 return \"stfd %1,%0\;stfd %L1,%Y0\";
8159 case 3:
8160 case 4:
8161 case 5:
8162 return \"#\";
8163 }
8164 }"
8165 [(set_attr "type" "fp,fpload,fpstore,*,*,*")
8166 (set_attr "length" "8,8,8,12,16,20")])
8167
8168 (define_split
8169 [(set (match_operand:TF 0 "gpc_reg_operand" "")
8170 (match_operand:TF 1 "easy_fp_constant" ""))]
8171 "(DEFAULT_ABI == ABI_AIX || DEFAULT_ABI == ABI_DARWIN)
8172 && TARGET_HARD_FLOAT && TARGET_FPRS && ! TARGET_POWERPC64
8173 && TARGET_LONG_DOUBLE_128 && reload_completed
8174 && ((GET_CODE (operands[0]) == REG && REGNO (operands[0]) <= 31)
8175 || (GET_CODE (operands[0]) == SUBREG
8176 && GET_CODE (SUBREG_REG (operands[0])) == REG
8177 && REGNO (SUBREG_REG (operands[0])) <= 31))"
8178 [(set (match_dup 2) (match_dup 6))
8179 (set (match_dup 3) (match_dup 7))
8180 (set (match_dup 4) (match_dup 8))
8181 (set (match_dup 5) (match_dup 9))]
8182 "
8183 {
8184 long l[4];
8185 REAL_VALUE_TYPE rv;
8186
8187 REAL_VALUE_FROM_CONST_DOUBLE (rv, operands[1]);
8188 REAL_VALUE_TO_TARGET_LONG_DOUBLE (rv, l);
8189
8190 operands[2] = operand_subword (operands[0], 0, 0, TFmode);
8191 operands[3] = operand_subword (operands[0], 1, 0, TFmode);
8192 operands[4] = operand_subword (operands[0], 2, 0, TFmode);
8193 operands[5] = operand_subword (operands[0], 3, 0, TFmode);
8194 operands[6] = gen_int_mode (l[0], SImode);
8195 operands[7] = gen_int_mode (l[1], SImode);
8196 operands[8] = gen_int_mode (l[2], SImode);
8197 operands[9] = gen_int_mode (l[3], SImode);
8198 }")
8199
8200 (define_split
8201 [(set (match_operand:TF 0 "gpc_reg_operand" "")
8202 (match_operand:TF 1 "easy_fp_constant" ""))]
8203 "(DEFAULT_ABI == ABI_AIX || DEFAULT_ABI == ABI_DARWIN)
8204 && TARGET_HARD_FLOAT && TARGET_FPRS && TARGET_POWERPC64
8205 && TARGET_LONG_DOUBLE_128 && reload_completed
8206 && ((GET_CODE (operands[0]) == REG && REGNO (operands[0]) <= 31)
8207 || (GET_CODE (operands[0]) == SUBREG
8208 && GET_CODE (SUBREG_REG (operands[0])) == REG
8209 && REGNO (SUBREG_REG (operands[0])) <= 31))"
8210 [(set (match_dup 2) (match_dup 4))
8211 (set (match_dup 3) (match_dup 5))]
8212 "
8213 {
8214 long l[4];
8215 REAL_VALUE_TYPE rv;
8216 #if HOST_BITS_PER_WIDE_INT >= 64
8217 HOST_WIDE_INT val;
8218 #endif
8219
8220 REAL_VALUE_FROM_CONST_DOUBLE (rv, operands[1]);
8221 REAL_VALUE_TO_TARGET_LONG_DOUBLE (rv, l);
8222
8223 operands[2] = gen_lowpart (DImode, operands[0]);
8224 operands[3] = gen_highpart (DImode, operands[0]);
8225 #if HOST_BITS_PER_WIDE_INT >= 64
8226 val = ((HOST_WIDE_INT)(unsigned long)l[0] << 32
8227 | ((HOST_WIDE_INT)(unsigned long)l[1]));
8228 operands[4] = gen_int_mode (val, DImode);
8229
8230 val = ((HOST_WIDE_INT)(unsigned long)l[2] << 32
8231 | ((HOST_WIDE_INT)(unsigned long)l[3]));
8232 operands[5] = gen_int_mode (val, DImode);
8233 #else
8234 operands[4] = immed_double_const (l[1], l[0], DImode);
8235 operands[5] = immed_double_const (l[3], l[2], DImode);
8236 #endif
8237 }")
8238
8239 (define_insn "extenddftf2"
8240 [(set (match_operand:TF 0 "gpc_reg_operand" "=f")
8241 (float_extend:TF (match_operand:DF 1 "gpc_reg_operand" "f")))]
8242 "DEFAULT_ABI == ABI_AIX && TARGET_HARD_FLOAT && TARGET_FPRS
8243 && TARGET_LONG_DOUBLE_128"
8244 "*
8245 {
8246 if (REGNO (operands[0]) == REGNO (operands[1]))
8247 return \"fsub %L0,%L0,%L0\";
8248 else
8249 return \"fmr %0,%1\;fsub %L0,%L0,%L0\";
8250 }"
8251 [(set_attr "type" "fp")])
8252
8253 (define_insn "extendsftf2"
8254 [(set (match_operand:TF 0 "gpc_reg_operand" "=f")
8255 (float_extend:TF (match_operand:SF 1 "gpc_reg_operand" "f")))]
8256 "DEFAULT_ABI == ABI_AIX && TARGET_HARD_FLOAT && TARGET_FPRS
8257 && TARGET_LONG_DOUBLE_128"
8258 "*
8259 {
8260 if (REGNO (operands[0]) == REGNO (operands[1]))
8261 return \"fsub %L0,%L0,%L0\";
8262 else
8263 return \"fmr %0,%1\;fsub %L0,%L0,%L0\";
8264 }"
8265 [(set_attr "type" "fp")])
8266
8267 (define_insn "trunctfdf2"
8268 [(set (match_operand:DF 0 "gpc_reg_operand" "=f")
8269 (float_truncate:DF (match_operand:TF 1 "gpc_reg_operand" "f")))]
8270 "DEFAULT_ABI == ABI_AIX && TARGET_HARD_FLOAT && TARGET_FPRS
8271 && TARGET_LONG_DOUBLE_128"
8272 "fadd %0,%1,%L1"
8273 [(set_attr "type" "fp")
8274 (set_attr "length" "8")])
8275
8276 (define_insn_and_split "trunctfsf2"
8277 [(set (match_operand:SF 0 "gpc_reg_operand" "=f")
8278 (float_truncate:SF (match_operand:TF 1 "gpc_reg_operand" "f")))
8279 (clobber (match_scratch:DF 2 "=f"))]
8280 "DEFAULT_ABI == ABI_AIX && TARGET_HARD_FLOAT
8281 && TARGET_FPRS && TARGET_LONG_DOUBLE_128"
8282 "#"
8283 "&& reload_completed"
8284 [(set (match_dup 2)
8285 (float_truncate:DF (match_dup 1)))
8286 (set (match_dup 0)
8287 (float_truncate:SF (match_dup 2)))]
8288 "")
8289
8290 (define_insn_and_split "floatditf2"
8291 [(set (match_operand:TF 0 "gpc_reg_operand" "=f")
8292 (float:TF (match_operand:DI 1 "gpc_reg_operand" "*f")))
8293 (clobber (match_scratch:DF 2 "=f"))]
8294 "DEFAULT_ABI == ABI_AIX && TARGET_POWERPC64
8295 && TARGET_HARD_FLOAT && TARGET_FPRS && TARGET_LONG_DOUBLE_128"
8296 "#"
8297 "&& reload_completed"
8298 [(set (match_dup 2)
8299 (float:DF (match_dup 1)))
8300 (set (match_dup 0)
8301 (float_extend:TF (match_dup 2)))]
8302 "")
8303
8304 (define_insn_and_split "floatsitf2"
8305 [(set (match_operand:TF 0 "gpc_reg_operand" "=f")
8306 (float:TF (match_operand:SI 1 "gpc_reg_operand" "r")))
8307 (clobber (match_scratch:DF 2 "=f"))]
8308 "DEFAULT_ABI == ABI_AIX && TARGET_HARD_FLOAT && TARGET_FPRS
8309 && TARGET_LONG_DOUBLE_128"
8310 "#"
8311 "&& reload_completed"
8312 [(set (match_dup 2)
8313 (float:DF (match_dup 1)))
8314 (set (match_dup 0)
8315 (float_extend:TF (match_dup 2)))]
8316 "")
8317
8318 (define_insn_and_split "fix_trunctfdi2"
8319 [(set (match_operand:DI 0 "gpc_reg_operand" "=*f")
8320 (fix:DI (match_operand:TF 1 "gpc_reg_operand" "f")))
8321 (clobber (match_scratch:DF 2 "=f"))]
8322 "DEFAULT_ABI == ABI_AIX && TARGET_POWERPC64
8323 && TARGET_HARD_FLOAT && TARGET_FPRS && TARGET_LONG_DOUBLE_128"
8324 "#"
8325 "&& reload_completed"
8326 [(set (match_dup 2)
8327 (float_truncate:DF (match_dup 1)))
8328 (set (match_dup 0)
8329 (fix:DI (match_dup 2)))]
8330 "")
8331
8332 (define_insn_and_split "fix_trunctfsi2"
8333 [(set (match_operand:SI 0 "gpc_reg_operand" "=r")
8334 (fix:SI (match_operand:TF 1 "gpc_reg_operand" "f")))
8335 (clobber (match_scratch:DF 2 "=f"))]
8336 "DEFAULT_ABI == ABI_AIX && TARGET_HARD_FLOAT && TARGET_FPRS
8337 && TARGET_LONG_DOUBLE_128"
8338 "#"
8339 "&& reload_completed"
8340 [(set (match_dup 2)
8341 (float_truncate:DF (match_dup 1)))
8342 (set (match_dup 0)
8343 (fix:SI (match_dup 2)))]
8344 "")
8345
8346 (define_insn "negtf2"
8347 [(set (match_operand:TF 0 "gpc_reg_operand" "=f")
8348 (neg:TF (match_operand:TF 1 "gpc_reg_operand" "f")))]
8349 "DEFAULT_ABI == ABI_AIX && TARGET_HARD_FLOAT && TARGET_FPRS
8350 && TARGET_LONG_DOUBLE_128"
8351 "*
8352 {
8353 if (REGNO (operands[0]) == REGNO (operands[1]) + 1)
8354 return \"fneg %L0,%L1\;fneg %0,%1\";
8355 else
8356 return \"fneg %0,%1\;fneg %L0,%L1\";
8357 }"
8358 [(set_attr "type" "fp")
8359 (set_attr "length" "8")])
8360
8361 (define_insn "abstf2"
8362 [(set (match_operand:TF 0 "gpc_reg_operand" "=f")
8363 (abs:TF (match_operand:TF 1 "gpc_reg_operand" "f")))]
8364 "DEFAULT_ABI == ABI_AIX && TARGET_HARD_FLOAT && TARGET_FPRS
8365 && TARGET_LONG_DOUBLE_128"
8366 "*
8367 {
8368 if (REGNO (operands[0]) == REGNO (operands[1]) + 1)
8369 return \"fabs %L0,%L1\;fabs %0,%1\";
8370 else
8371 return \"fabs %0,%1\;fabs %L0,%L1\";
8372 }"
8373 [(set_attr "type" "fp")
8374 (set_attr "length" "8")])
8375
8376 (define_insn ""
8377 [(set (match_operand:TF 0 "gpc_reg_operand" "=f")
8378 (neg:TF (abs:TF (match_operand:TF 1 "gpc_reg_operand" "f"))))]
8379 "DEFAULT_ABI == ABI_AIX && TARGET_HARD_FLOAT && TARGET_FPRS
8380 && TARGET_LONG_DOUBLE_128"
8381 "*
8382 {
8383 if (REGNO (operands[0]) == REGNO (operands[1]) + 1)
8384 return \"fnabs %L0,%L1\;fnabs %0,%1\";
8385 else
8386 return \"fnabs %0,%1\;fnabs %L0,%L1\";
8387 }"
8388 [(set_attr "type" "fp")
8389 (set_attr "length" "8")])
8390 \f
8391 ;; Next come the multi-word integer load and store and the load and store
8392 ;; multiple insns.
8393 (define_expand "movdi"
8394 [(set (match_operand:DI 0 "general_operand" "")
8395 (match_operand:DI 1 "any_operand" ""))]
8396 ""
8397 "{ rs6000_emit_move (operands[0], operands[1], DImode); DONE; }")
8398
8399 (define_insn "*movdi_internal32"
8400 [(set (match_operand:DI 0 "nonimmediate_operand" "=r,r,m,f,f,m,r,r,r,r,r")
8401 (match_operand:DI 1 "input_operand" "r,m,r,f,m,f,IJK,n,G,H,F"))]
8402 "! TARGET_POWERPC64
8403 && (gpc_reg_operand (operands[0], DImode)
8404 || gpc_reg_operand (operands[1], DImode))"
8405 "*
8406 {
8407 switch (which_alternative)
8408 {
8409 default:
8410 abort ();
8411 case 0:
8412 /* We normally copy the low-numbered register first. However, if
8413 the first register operand 0 is the same as the second register of
8414 operand 1, we must copy in the opposite order. */
8415 if (REGNO (operands[0]) == REGNO (operands[1]) + 1)
8416 return \"mr %L0,%L1\;mr %0,%1\";
8417 else
8418 return \"mr %0,%1\;mr %L0,%L1\";
8419 case 1:
8420 /* If the low-address word is used in the address, we must load it
8421 last. Otherwise, load it first. Note that we cannot have
8422 auto-increment in that case since the address register is known to be
8423 dead. */
8424 if (refers_to_regno_p (REGNO (operands[0]), REGNO (operands[0]) + 1,
8425 operands[1], 0))
8426 return \"{l|lwz} %L0,%L1\;{l|lwz} %0,%1\";
8427 else
8428 return \"{l%U1|lwz%U1} %0,%1\;{l|lwz} %L0,%L1\";
8429 case 2:
8430 return \"{st%U0|stw%U0} %1,%0\;{st|stw} %L1,%L0\";
8431 case 3:
8432 return \"fmr %0,%1\";
8433 case 4:
8434 return \"lfd%U1%X1 %0,%1\";
8435 case 5:
8436 return \"stfd%U0%X0 %1,%0\";
8437 case 6:
8438 case 7:
8439 case 8:
8440 case 9:
8441 case 10:
8442 return \"#\";
8443 }
8444 }"
8445 [(set_attr "type" "*,load,store,fp,fpload,fpstore,*,*,*,*,*")
8446 (set_attr "length" "8,8,8,4,4,4,8,12,8,12,16")])
8447
8448 (define_split
8449 [(set (match_operand:DI 0 "gpc_reg_operand" "")
8450 (match_operand:DI 1 "const_int_operand" ""))]
8451 "! TARGET_POWERPC64 && reload_completed"
8452 [(set (match_dup 2) (match_dup 4))
8453 (set (match_dup 3) (match_dup 1))]
8454 "
8455 {
8456 HOST_WIDE_INT value = INTVAL (operands[1]);
8457 operands[2] = operand_subword_force (operands[0], WORDS_BIG_ENDIAN == 0,
8458 DImode);
8459 operands[3] = operand_subword_force (operands[0], WORDS_BIG_ENDIAN != 0,
8460 DImode);
8461 #if HOST_BITS_PER_WIDE_INT == 32
8462 operands[4] = (value & 0x80000000) ? constm1_rtx : const0_rtx;
8463 #else
8464 operands[4] = GEN_INT (value >> 32);
8465 operands[1] = GEN_INT (((value & 0xffffffff) ^ 0x80000000) - 0x80000000);
8466 #endif
8467 }")
8468
8469 (define_split
8470 [(set (match_operand:DI 0 "gpc_reg_operand" "")
8471 (match_operand:DI 1 "const_double_operand" ""))]
8472 "HOST_BITS_PER_WIDE_INT == 32 && ! TARGET_POWERPC64 && reload_completed"
8473 [(set (match_dup 2) (match_dup 4))
8474 (set (match_dup 3) (match_dup 5))]
8475 "
8476 {
8477 operands[2] = operand_subword_force (operands[0], WORDS_BIG_ENDIAN == 0,
8478 DImode);
8479 operands[3] = operand_subword_force (operands[0], WORDS_BIG_ENDIAN != 0,
8480 DImode);
8481 operands[4] = GEN_INT (CONST_DOUBLE_HIGH (operands[1]));
8482 operands[5] = GEN_INT (CONST_DOUBLE_LOW (operands[1]));
8483 }")
8484
8485 (define_split
8486 [(set (match_operand:TI 0 "gpc_reg_operand" "")
8487 (match_operand:TI 1 "const_double_operand" ""))]
8488 "TARGET_POWERPC64"
8489 [(set (match_dup 2) (match_dup 4))
8490 (set (match_dup 3) (match_dup 5))]
8491 "
8492 {
8493 operands[2] = operand_subword_force (operands[0], WORDS_BIG_ENDIAN == 0,
8494 TImode);
8495 operands[3] = operand_subword_force (operands[0], WORDS_BIG_ENDIAN != 0,
8496 TImode);
8497 if (GET_CODE (operands[1]) == CONST_DOUBLE)
8498 {
8499 operands[4] = GEN_INT (CONST_DOUBLE_HIGH (operands[1]));
8500 operands[5] = GEN_INT (CONST_DOUBLE_LOW (operands[1]));
8501 }
8502 else if (GET_CODE (operands[1]) == CONST_INT)
8503 {
8504 operands[4] = GEN_INT (- (INTVAL (operands[1]) < 0));
8505 operands[5] = operands[1];
8506 }
8507 else
8508 FAIL;
8509 }")
8510
8511 (define_insn "*movdi_internal64"
8512 [(set (match_operand:DI 0 "nonimmediate_operand" "=r,r,m,r,r,r,r,?f,f,m,r,*h,*h")
8513 (match_operand:DI 1 "input_operand" "r,m,r,I,L,nF,R,f,m,f,*h,r,0"))]
8514 "TARGET_POWERPC64
8515 && (gpc_reg_operand (operands[0], DImode)
8516 || gpc_reg_operand (operands[1], DImode))"
8517 "@
8518 mr %0,%1
8519 ld%U1%X1 %0,%1
8520 std%U0%X0 %1,%0
8521 li %0,%1
8522 lis %0,%v1
8523 #
8524 {cal|la} %0,%a1
8525 fmr %0,%1
8526 lfd%U1%X1 %0,%1
8527 stfd%U0%X0 %1,%0
8528 mf%1 %0
8529 mt%0 %1
8530 {cror 0,0,0|nop}"
8531 [(set_attr "type" "*,load,store,*,*,*,*,fp,fpload,fpstore,*,mtjmpr,*")
8532 (set_attr "length" "4,4,4,4,4,20,4,4,4,4,4,4,4")])
8533
8534 ;; immediate value valid for a single instruction hiding in a const_double
8535 (define_insn ""
8536 [(set (match_operand:DI 0 "gpc_reg_operand" "=r")
8537 (match_operand:DI 1 "const_double_operand" "F"))]
8538 "HOST_BITS_PER_WIDE_INT == 32 && TARGET_POWERPC64
8539 && GET_CODE (operands[1]) == CONST_DOUBLE
8540 && num_insns_constant (operands[1], DImode) == 1"
8541 "*
8542 {
8543 return ((unsigned HOST_WIDE_INT)
8544 (CONST_DOUBLE_LOW (operands[1]) + 0x8000) < 0x10000)
8545 ? \"li %0,%1\" : \"lis %0,%v1\";
8546 }")
8547
8548 ;; Generate all one-bits and clear left or right.
8549 ;; Use (and:DI (rotate:DI ...)) to avoid anddi3 unnecessary clobber.
8550 (define_split
8551 [(set (match_operand:DI 0 "gpc_reg_operand" "")
8552 (match_operand:DI 1 "mask64_operand" ""))]
8553 "TARGET_POWERPC64 && num_insns_constant (operands[1], DImode) > 1"
8554 [(set (match_dup 0) (const_int -1))
8555 (set (match_dup 0)
8556 (and:DI (rotate:DI (match_dup 0)
8557 (const_int 0))
8558 (match_dup 1)))]
8559 "")
8560
8561 ;; Split a load of a large constant into the appropriate five-instruction
8562 ;; sequence. Handle anything in a constant number of insns.
8563 ;; When non-easy constants can go in the TOC, this should use
8564 ;; easy_fp_constant predicate.
8565 (define_split
8566 [(set (match_operand:DI 0 "gpc_reg_operand" "")
8567 (match_operand:DI 1 "const_int_operand" ""))]
8568 "TARGET_POWERPC64 && num_insns_constant (operands[1], DImode) > 1"
8569 [(set (match_dup 0) (match_dup 2))
8570 (set (match_dup 0) (plus:DI (match_dup 0) (match_dup 3)))]
8571 "
8572 { rtx tem = rs6000_emit_set_const (operands[0], DImode, operands[1], 5);
8573
8574 if (tem == operands[0])
8575 DONE;
8576 else
8577 FAIL;
8578 }")
8579
8580 (define_split
8581 [(set (match_operand:DI 0 "gpc_reg_operand" "")
8582 (match_operand:DI 1 "const_double_operand" ""))]
8583 "TARGET_POWERPC64 && num_insns_constant (operands[1], DImode) > 1"
8584 [(set (match_dup 0) (match_dup 2))
8585 (set (match_dup 0) (plus:DI (match_dup 0) (match_dup 3)))]
8586 "
8587 { rtx tem = rs6000_emit_set_const (operands[0], DImode, operands[1], 5);
8588
8589 if (tem == operands[0])
8590 DONE;
8591 else
8592 FAIL;
8593 }")
8594
8595 ;; Split a load of a large constant into the appropriate five-instruction
8596 (define_insn "*movdi_internal2"
8597 [(set (match_operand:CC 2 "cc_reg_operand" "=x,?y")
8598 (compare:CC (match_operand:DI 1 "gpc_reg_operand" "r,r")
8599 (const_int 0)))
8600 (set (match_operand:DI 0 "gpc_reg_operand" "=r,r") (match_dup 1))]
8601 "TARGET_POWERPC64"
8602 "@
8603 mr. %0,%1
8604 #"
8605 [(set_attr "type" "compare")
8606 (set_attr "length" "4,8")])
8607
8608 (define_split
8609 [(set (match_operand:CC 2 "cc_reg_not_cr0_operand" "")
8610 (compare:CC (match_operand:DI 1 "gpc_reg_operand" "")
8611 (const_int 0)))
8612 (set (match_operand:DI 0 "gpc_reg_operand" "") (match_dup 1))]
8613 "TARGET_POWERPC64 && reload_completed"
8614 [(set (match_dup 0) (match_dup 1))
8615 (set (match_dup 2)
8616 (compare:CC (match_dup 0)
8617 (const_int 0)))]
8618 "")
8619 \f
8620 ;; TImode is similar, except that we usually want to compute the address into
8621 ;; a register and use lsi/stsi (the exception is during reload). MQ is also
8622 ;; clobbered in stsi for POWER, so we need a SCRATCH for it.
8623 (define_expand "movti"
8624 [(parallel [(set (match_operand:TI 0 "general_operand" "")
8625 (match_operand:TI 1 "general_operand" ""))
8626 (clobber (scratch:SI))])]
8627 "TARGET_STRING || TARGET_POWERPC64"
8628 "{ rs6000_emit_move (operands[0], operands[1], TImode); DONE; }")
8629
8630 ;; We say that MQ is clobbered in the last alternative because the first
8631 ;; alternative would never get used otherwise since it would need a reload
8632 ;; while the 2nd alternative would not. We put memory cases first so they
8633 ;; are preferred. Otherwise, we'd try to reload the output instead of
8634 ;; giving the SCRATCH mq.
8635 (define_insn "*movti_power"
8636 [(set (match_operand:TI 0 "reg_or_mem_operand" "=Q,m,????r,????r,????r")
8637 (match_operand:TI 1 "reg_or_mem_operand" "r,r,r,Q,m"))
8638 (clobber (match_scratch:SI 2 "=q,q#X,X,X,X"))]
8639 "TARGET_STRING && TARGET_POWER && ! TARGET_POWERPC64
8640 && (gpc_reg_operand (operands[0], TImode) || gpc_reg_operand (operands[1], TImode))"
8641 "*
8642 {
8643 switch (which_alternative)
8644 {
8645 default:
8646 abort ();
8647
8648 case 0:
8649 return \"{stsi|stswi} %1,%P0,16\";
8650 case 1:
8651 return \"{st%U0|stw%U0} %1,%0\;{st|stw} %L1,%L0\;{st|stw} %Y1,%Y0\;{st|stw} %Z1,%Z0\";
8652 case 2:
8653 /* Normally copy registers with lowest numbered register copied first.
8654 But copy in the other order if the first register of the output
8655 is the second, third, or fourth register in the input. */
8656 if (REGNO (operands[0]) >= REGNO (operands[1]) + 1
8657 && REGNO (operands[0]) <= REGNO (operands[1]) + 3)
8658 return \"mr %Z0,%Z1\;mr %Y0,%Y1\;mr %L0,%L1\;mr %0,%1\";
8659 else
8660 return \"mr %0,%1\;mr %L0,%L1\;mr %Y0,%Y1\;mr %Z0,%Z1\";
8661 case 3:
8662 /* If the address is not used in the output, we can use lsi. Otherwise,
8663 fall through to generating four loads. */
8664 if (! reg_overlap_mentioned_p (operands[0], operands[1]))
8665 return \"{lsi|lswi} %0,%P1,16\";
8666 /* ... fall through ... */
8667 case 4:
8668 /* If the address register is the same as the register for the lowest-
8669 addressed word, load it last. Similarly for the next two words.
8670 Otherwise load lowest address to highest. */
8671 if (refers_to_regno_p (REGNO (operands[0]), REGNO (operands[0]) + 1,
8672 operands[1], 0))
8673 return \"{l|lwz} %L0,%L1\;{l|lwz} %Y0,%Y1\;{l|lwz} %Z0,%Z1\;{l|lwz} %0,%1\";
8674 else if (refers_to_regno_p (REGNO (operands[0]) + 1,
8675 REGNO (operands[0]) + 2, operands[1], 0))
8676 return \"{l|lwz} %0,%1\;{l|lwz} %Y0,%Y1\;{l|lwz} %Z0,%Z1\;{l|lwz} %L0,%L1\";
8677 else if (refers_to_regno_p (REGNO (operands[0]) + 2,
8678 REGNO (operands[0]) + 3, operands[1], 0))
8679 return \"{l|lwz} %0,%1\;{l|lwz} %L0,%L1\;{l|lwz} %Z0,%Z1\;{l|lwz} %Y0,%Y1\";
8680 else
8681 return \"{l%U1|lwz%U1} %0,%1\;{l|lwz} %L0,%L1\;{l|lwz} %Y0,%Y1\;{l|lwz} %Z0,%Z1\";
8682 }
8683 }"
8684 [(set_attr "type" "store,store,*,load,load")
8685 (set_attr "length" "4,16,16,4,16")])
8686
8687 (define_insn "*movti_string"
8688 [(set (match_operand:TI 0 "reg_or_mem_operand" "=Q,m,????r,????r,????r")
8689 (match_operand:TI 1 "reg_or_mem_operand" "r,r,r,Q,m"))]
8690 "TARGET_STRING && ! TARGET_POWER && ! TARGET_POWERPC64
8691 && (gpc_reg_operand (operands[0], TImode) || gpc_reg_operand (operands[1], TImode))"
8692 "*
8693 {
8694 switch (which_alternative)
8695 {
8696 default:
8697 abort ();
8698
8699 case 0:
8700 return \"{stsi|stswi} %1,%P0,16\";
8701 case 1:
8702 return \"{st%U0|stw%U0} %1,%0\;{st|stw} %L1,%L0\;{st|stw} %Y1,%Y0\;{st|stw} %Z1,%Z0\";
8703 case 2:
8704 /* Normally copy registers with lowest numbered register copied first.
8705 But copy in the other order if the first register of the output
8706 is the second, third, or fourth register in the input. */
8707 if (REGNO (operands[0]) >= REGNO (operands[1]) + 1
8708 && REGNO (operands[0]) <= REGNO (operands[1]) + 3)
8709 return \"mr %Z0,%Z1\;mr %Y0,%Y1\;mr %L0,%L1\;mr %0,%1\";
8710 else
8711 return \"mr %0,%1\;mr %L0,%L1\;mr %Y0,%Y1\;mr %Z0,%Z1\";
8712 case 3:
8713 /* If the address is not used in the output, we can use lsi. Otherwise,
8714 fall through to generating four loads. */
8715 if (! reg_overlap_mentioned_p (operands[0], operands[1]))
8716 return \"{lsi|lswi} %0,%P1,16\";
8717 /* ... fall through ... */
8718 case 4:
8719 /* If the address register is the same as the register for the lowest-
8720 addressed word, load it last. Similarly for the next two words.
8721 Otherwise load lowest address to highest. */
8722 if (refers_to_regno_p (REGNO (operands[0]), REGNO (operands[0]) + 1,
8723 operands[1], 0))
8724 return \"{l|lwz} %L0,%L1\;{l|lwz} %Y0,%Y1\;{l|lwz} %Z0,%Z1\;{l|lwz} %0,%1\";
8725 else if (refers_to_regno_p (REGNO (operands[0]) + 1,
8726 REGNO (operands[0]) + 2, operands[1], 0))
8727 return \"{l|lwz} %0,%1\;{l|lwz} %Y0,%Y1\;{l|lwz} %Z0,%Z1\;{l|lwz} %L0,%L1\";
8728 else if (refers_to_regno_p (REGNO (operands[0]) + 2,
8729 REGNO (operands[0]) + 3, operands[1], 0))
8730 return \"{l|lwz} %0,%1\;{l|lwz} %L0,%L1\;{l|lwz} %Z0,%Z1\;{l|lwz} %Y0,%Y1\";
8731 else
8732 return \"{l%U1|lwz%U1} %0,%1\;{l|lwz} %L0,%L1\;{l|lwz} %Y0,%Y1\;{l|lwz} %Z0,%Z1\";
8733 }
8734 }"
8735 [(set_attr "type" "store,store,*,load,load")
8736 (set_attr "length" "4,16,16,4,16")])
8737
8738 (define_insn "*movti_ppc64"
8739 [(set (match_operand:TI 0 "nonimmediate_operand" "=r,r,m")
8740 (match_operand:TI 1 "input_operand" "r,m,r"))]
8741 "TARGET_POWERPC64 && (gpc_reg_operand (operands[0], TImode)
8742 || gpc_reg_operand (operands[1], TImode))"
8743 "*
8744 {
8745 switch (which_alternative)
8746 {
8747 default:
8748 abort ();
8749 case 0:
8750 /* We normally copy the low-numbered register first. However, if
8751 the first register operand 0 is the same as the second register of
8752 operand 1, we must copy in the opposite order. */
8753 if (REGNO (operands[0]) == REGNO (operands[1]) + 1)
8754 return \"mr %L0,%L1\;mr %0,%1\";
8755 else
8756 return \"mr %0,%1\;mr %L0,%L1\";
8757 case 1:
8758 /* If the low-address word is used in the address, we must load it
8759 last. Otherwise, load it first. Note that we cannot have
8760 auto-increment in that case since the address register is known to be
8761 dead. */
8762 if (refers_to_regno_p (REGNO (operands[0]), REGNO (operands[0]) + 1,
8763 operands[1], 0))
8764 return \"ld %L0,%L1\;ld %0,%1\";
8765 else
8766 return \"ld%U1 %0,%1\;ld %L0,%L1\";
8767 case 2:
8768 return \"std%U0 %1,%0\;std %L1,%L0\";
8769 }
8770 }"
8771 [(set_attr "type" "*,load,store")
8772 (set_attr "length" "8,8,8")])
8773 \f
8774 (define_expand "load_multiple"
8775 [(match_par_dup 3 [(set (match_operand:SI 0 "" "")
8776 (match_operand:SI 1 "" ""))
8777 (use (match_operand:SI 2 "" ""))])]
8778 "TARGET_STRING && !TARGET_POWERPC64"
8779 "
8780 {
8781 int regno;
8782 int count;
8783 rtx op1;
8784 int i;
8785
8786 /* Support only loading a constant number of fixed-point registers from
8787 memory and only bother with this if more than two; the machine
8788 doesn't support more than eight. */
8789 if (GET_CODE (operands[2]) != CONST_INT
8790 || INTVAL (operands[2]) <= 2
8791 || INTVAL (operands[2]) > 8
8792 || GET_CODE (operands[1]) != MEM
8793 || GET_CODE (operands[0]) != REG
8794 || REGNO (operands[0]) >= 32)
8795 FAIL;
8796
8797 count = INTVAL (operands[2]);
8798 regno = REGNO (operands[0]);
8799
8800 operands[3] = gen_rtx_PARALLEL (VOIDmode, rtvec_alloc (count));
8801 op1 = replace_equiv_address (operands[1],
8802 force_reg (SImode, XEXP (operands[1], 0)));
8803
8804 for (i = 0; i < count; i++)
8805 XVECEXP (operands[3], 0, i)
8806 = gen_rtx_SET (VOIDmode, gen_rtx_REG (SImode, regno + i),
8807 adjust_address_nv (op1, SImode, i * 4));
8808 }")
8809
8810 (define_insn "*ldmsi8"
8811 [(match_parallel 0 "load_multiple_operation"
8812 [(set (match_operand:SI 2 "gpc_reg_operand" "")
8813 (mem:SI (match_operand:SI 1 "gpc_reg_operand" "b")))
8814 (set (match_operand:SI 3 "gpc_reg_operand" "")
8815 (mem:SI (plus:SI (match_dup 1) (const_int 4))))
8816 (set (match_operand:SI 4 "gpc_reg_operand" "")
8817 (mem:SI (plus:SI (match_dup 1) (const_int 8))))
8818 (set (match_operand:SI 5 "gpc_reg_operand" "")
8819 (mem:SI (plus:SI (match_dup 1) (const_int 12))))
8820 (set (match_operand:SI 6 "gpc_reg_operand" "")
8821 (mem:SI (plus:SI (match_dup 1) (const_int 16))))
8822 (set (match_operand:SI 7 "gpc_reg_operand" "")
8823 (mem:SI (plus:SI (match_dup 1) (const_int 20))))
8824 (set (match_operand:SI 8 "gpc_reg_operand" "")
8825 (mem:SI (plus:SI (match_dup 1) (const_int 24))))
8826 (set (match_operand:SI 9 "gpc_reg_operand" "")
8827 (mem:SI (plus:SI (match_dup 1) (const_int 28))))])]
8828 "TARGET_STRING && XVECLEN (operands[0], 0) == 8"
8829 "*
8830 { return rs6000_output_load_multiple (operands); }"
8831 [(set_attr "type" "load")
8832 (set_attr "length" "32")])
8833
8834 (define_insn "*ldmsi7"
8835 [(match_parallel 0 "load_multiple_operation"
8836 [(set (match_operand:SI 2 "gpc_reg_operand" "")
8837 (mem:SI (match_operand:SI 1 "gpc_reg_operand" "b")))
8838 (set (match_operand:SI 3 "gpc_reg_operand" "")
8839 (mem:SI (plus:SI (match_dup 1) (const_int 4))))
8840 (set (match_operand:SI 4 "gpc_reg_operand" "")
8841 (mem:SI (plus:SI (match_dup 1) (const_int 8))))
8842 (set (match_operand:SI 5 "gpc_reg_operand" "")
8843 (mem:SI (plus:SI (match_dup 1) (const_int 12))))
8844 (set (match_operand:SI 6 "gpc_reg_operand" "")
8845 (mem:SI (plus:SI (match_dup 1) (const_int 16))))
8846 (set (match_operand:SI 7 "gpc_reg_operand" "")
8847 (mem:SI (plus:SI (match_dup 1) (const_int 20))))
8848 (set (match_operand:SI 8 "gpc_reg_operand" "")
8849 (mem:SI (plus:SI (match_dup 1) (const_int 24))))])]
8850 "TARGET_STRING && XVECLEN (operands[0], 0) == 7"
8851 "*
8852 { return rs6000_output_load_multiple (operands); }"
8853 [(set_attr "type" "load")
8854 (set_attr "length" "32")])
8855
8856 (define_insn "*ldmsi6"
8857 [(match_parallel 0 "load_multiple_operation"
8858 [(set (match_operand:SI 2 "gpc_reg_operand" "")
8859 (mem:SI (match_operand:SI 1 "gpc_reg_operand" "b")))
8860 (set (match_operand:SI 3 "gpc_reg_operand" "")
8861 (mem:SI (plus:SI (match_dup 1) (const_int 4))))
8862 (set (match_operand:SI 4 "gpc_reg_operand" "")
8863 (mem:SI (plus:SI (match_dup 1) (const_int 8))))
8864 (set (match_operand:SI 5 "gpc_reg_operand" "")
8865 (mem:SI (plus:SI (match_dup 1) (const_int 12))))
8866 (set (match_operand:SI 6 "gpc_reg_operand" "")
8867 (mem:SI (plus:SI (match_dup 1) (const_int 16))))
8868 (set (match_operand:SI 7 "gpc_reg_operand" "")
8869 (mem:SI (plus:SI (match_dup 1) (const_int 20))))])]
8870 "TARGET_STRING && XVECLEN (operands[0], 0) == 6"
8871 "*
8872 { return rs6000_output_load_multiple (operands); }"
8873 [(set_attr "type" "load")
8874 (set_attr "length" "32")])
8875
8876 (define_insn "*ldmsi5"
8877 [(match_parallel 0 "load_multiple_operation"
8878 [(set (match_operand:SI 2 "gpc_reg_operand" "")
8879 (mem:SI (match_operand:SI 1 "gpc_reg_operand" "b")))
8880 (set (match_operand:SI 3 "gpc_reg_operand" "")
8881 (mem:SI (plus:SI (match_dup 1) (const_int 4))))
8882 (set (match_operand:SI 4 "gpc_reg_operand" "")
8883 (mem:SI (plus:SI (match_dup 1) (const_int 8))))
8884 (set (match_operand:SI 5 "gpc_reg_operand" "")
8885 (mem:SI (plus:SI (match_dup 1) (const_int 12))))
8886 (set (match_operand:SI 6 "gpc_reg_operand" "")
8887 (mem:SI (plus:SI (match_dup 1) (const_int 16))))])]
8888 "TARGET_STRING && XVECLEN (operands[0], 0) == 5"
8889 "*
8890 { return rs6000_output_load_multiple (operands); }"
8891 [(set_attr "type" "load")
8892 (set_attr "length" "32")])
8893
8894 (define_insn "*ldmsi4"
8895 [(match_parallel 0 "load_multiple_operation"
8896 [(set (match_operand:SI 2 "gpc_reg_operand" "")
8897 (mem:SI (match_operand:SI 1 "gpc_reg_operand" "b")))
8898 (set (match_operand:SI 3 "gpc_reg_operand" "")
8899 (mem:SI (plus:SI (match_dup 1) (const_int 4))))
8900 (set (match_operand:SI 4 "gpc_reg_operand" "")
8901 (mem:SI (plus:SI (match_dup 1) (const_int 8))))
8902 (set (match_operand:SI 5 "gpc_reg_operand" "")
8903 (mem:SI (plus:SI (match_dup 1) (const_int 12))))])]
8904 "TARGET_STRING && XVECLEN (operands[0], 0) == 4"
8905 "*
8906 { return rs6000_output_load_multiple (operands); }"
8907 [(set_attr "type" "load")
8908 (set_attr "length" "32")])
8909
8910 (define_insn "*ldmsi3"
8911 [(match_parallel 0 "load_multiple_operation"
8912 [(set (match_operand:SI 2 "gpc_reg_operand" "")
8913 (mem:SI (match_operand:SI 1 "gpc_reg_operand" "b")))
8914 (set (match_operand:SI 3 "gpc_reg_operand" "")
8915 (mem:SI (plus:SI (match_dup 1) (const_int 4))))
8916 (set (match_operand:SI 4 "gpc_reg_operand" "")
8917 (mem:SI (plus:SI (match_dup 1) (const_int 8))))])]
8918 "TARGET_STRING && XVECLEN (operands[0], 0) == 3"
8919 "*
8920 { return rs6000_output_load_multiple (operands); }"
8921 [(set_attr "type" "load")
8922 (set_attr "length" "32")])
8923
8924 (define_expand "store_multiple"
8925 [(match_par_dup 3 [(set (match_operand:SI 0 "" "")
8926 (match_operand:SI 1 "" ""))
8927 (clobber (scratch:SI))
8928 (use (match_operand:SI 2 "" ""))])]
8929 "TARGET_STRING && !TARGET_POWERPC64"
8930 "
8931 {
8932 int regno;
8933 int count;
8934 rtx to;
8935 rtx op0;
8936 int i;
8937
8938 /* Support only storing a constant number of fixed-point registers to
8939 memory and only bother with this if more than two; the machine
8940 doesn't support more than eight. */
8941 if (GET_CODE (operands[2]) != CONST_INT
8942 || INTVAL (operands[2]) <= 2
8943 || INTVAL (operands[2]) > 8
8944 || GET_CODE (operands[0]) != MEM
8945 || GET_CODE (operands[1]) != REG
8946 || REGNO (operands[1]) >= 32)
8947 FAIL;
8948
8949 count = INTVAL (operands[2]);
8950 regno = REGNO (operands[1]);
8951
8952 operands[3] = gen_rtx_PARALLEL (VOIDmode, rtvec_alloc (count + 1));
8953 to = force_reg (SImode, XEXP (operands[0], 0));
8954 op0 = replace_equiv_address (operands[0], to);
8955
8956 XVECEXP (operands[3], 0, 0)
8957 = gen_rtx_SET (VOIDmode, adjust_address_nv (op0, SImode, 0), operands[1]);
8958 XVECEXP (operands[3], 0, 1) = gen_rtx_CLOBBER (VOIDmode,
8959 gen_rtx_SCRATCH (SImode));
8960
8961 for (i = 1; i < count; i++)
8962 XVECEXP (operands[3], 0, i + 1)
8963 = gen_rtx_SET (VOIDmode,
8964 adjust_address_nv (op0, SImode, i * 4),
8965 gen_rtx_REG (SImode, regno + i));
8966 }")
8967
8968 (define_insn "*store_multiple_power"
8969 [(match_parallel 0 "store_multiple_operation"
8970 [(set (match_operand:SI 1 "indirect_operand" "=Q")
8971 (match_operand:SI 2 "gpc_reg_operand" "r"))
8972 (clobber (match_scratch:SI 3 "=q"))])]
8973 "TARGET_STRING && TARGET_POWER"
8974 "{stsi|stswi} %2,%P1,%O0"
8975 [(set_attr "type" "store")])
8976
8977 (define_insn "*stmsi8"
8978 [(match_parallel 0 "store_multiple_operation"
8979 [(set (mem:SI (match_operand:SI 1 "gpc_reg_operand" "b"))
8980 (match_operand:SI 2 "gpc_reg_operand" "r"))
8981 (clobber (match_scratch:SI 3 "X"))
8982 (set (mem:SI (plus:SI (match_dup 1) (const_int 4)))
8983 (match_operand:SI 4 "gpc_reg_operand" "r"))
8984 (set (mem:SI (plus:SI (match_dup 1) (const_int 8)))
8985 (match_operand:SI 5 "gpc_reg_operand" "r"))
8986 (set (mem:SI (plus:SI (match_dup 1) (const_int 12)))
8987 (match_operand:SI 6 "gpc_reg_operand" "r"))
8988 (set (mem:SI (plus:SI (match_dup 1) (const_int 16)))
8989 (match_operand:SI 7 "gpc_reg_operand" "r"))
8990 (set (mem:SI (plus:SI (match_dup 1) (const_int 20)))
8991 (match_operand:SI 8 "gpc_reg_operand" "r"))
8992 (set (mem:SI (plus:SI (match_dup 1) (const_int 24)))
8993 (match_operand:SI 9 "gpc_reg_operand" "r"))
8994 (set (mem:SI (plus:SI (match_dup 1) (const_int 28)))
8995 (match_operand:SI 10 "gpc_reg_operand" "r"))])]
8996 "TARGET_STRING && !TARGET_POWER && XVECLEN (operands[0], 0) == 9"
8997 "{stsi|stswi} %2,%1,%O0"
8998 [(set_attr "type" "store")])
8999
9000 (define_insn "*stmsi7"
9001 [(match_parallel 0 "store_multiple_operation"
9002 [(set (mem:SI (match_operand:SI 1 "gpc_reg_operand" "b"))
9003 (match_operand:SI 2 "gpc_reg_operand" "r"))
9004 (clobber (match_scratch:SI 3 "X"))
9005 (set (mem:SI (plus:SI (match_dup 1) (const_int 4)))
9006 (match_operand:SI 4 "gpc_reg_operand" "r"))
9007 (set (mem:SI (plus:SI (match_dup 1) (const_int 8)))
9008 (match_operand:SI 5 "gpc_reg_operand" "r"))
9009 (set (mem:SI (plus:SI (match_dup 1) (const_int 12)))
9010 (match_operand:SI 6 "gpc_reg_operand" "r"))
9011 (set (mem:SI (plus:SI (match_dup 1) (const_int 16)))
9012 (match_operand:SI 7 "gpc_reg_operand" "r"))
9013 (set (mem:SI (plus:SI (match_dup 1) (const_int 20)))
9014 (match_operand:SI 8 "gpc_reg_operand" "r"))
9015 (set (mem:SI (plus:SI (match_dup 1) (const_int 24)))
9016 (match_operand:SI 9 "gpc_reg_operand" "r"))])]
9017 "TARGET_STRING && !TARGET_POWER && XVECLEN (operands[0], 0) == 8"
9018 "{stsi|stswi} %2,%1,%O0"
9019 [(set_attr "type" "store")])
9020
9021 (define_insn "*stmsi6"
9022 [(match_parallel 0 "store_multiple_operation"
9023 [(set (mem:SI (match_operand:SI 1 "gpc_reg_operand" "b"))
9024 (match_operand:SI 2 "gpc_reg_operand" "r"))
9025 (clobber (match_scratch:SI 3 "X"))
9026 (set (mem:SI (plus:SI (match_dup 1) (const_int 4)))
9027 (match_operand:SI 4 "gpc_reg_operand" "r"))
9028 (set (mem:SI (plus:SI (match_dup 1) (const_int 8)))
9029 (match_operand:SI 5 "gpc_reg_operand" "r"))
9030 (set (mem:SI (plus:SI (match_dup 1) (const_int 12)))
9031 (match_operand:SI 6 "gpc_reg_operand" "r"))
9032 (set (mem:SI (plus:SI (match_dup 1) (const_int 16)))
9033 (match_operand:SI 7 "gpc_reg_operand" "r"))
9034 (set (mem:SI (plus:SI (match_dup 1) (const_int 20)))
9035 (match_operand:SI 8 "gpc_reg_operand" "r"))])]
9036 "TARGET_STRING && !TARGET_POWER && XVECLEN (operands[0], 0) == 7"
9037 "{stsi|stswi} %2,%1,%O0"
9038 [(set_attr "type" "store")])
9039
9040 (define_insn "*stmsi5"
9041 [(match_parallel 0 "store_multiple_operation"
9042 [(set (mem:SI (match_operand:SI 1 "gpc_reg_operand" "b"))
9043 (match_operand:SI 2 "gpc_reg_operand" "r"))
9044 (clobber (match_scratch:SI 3 "X"))
9045 (set (mem:SI (plus:SI (match_dup 1) (const_int 4)))
9046 (match_operand:SI 4 "gpc_reg_operand" "r"))
9047 (set (mem:SI (plus:SI (match_dup 1) (const_int 8)))
9048 (match_operand:SI 5 "gpc_reg_operand" "r"))
9049 (set (mem:SI (plus:SI (match_dup 1) (const_int 12)))
9050 (match_operand:SI 6 "gpc_reg_operand" "r"))
9051 (set (mem:SI (plus:SI (match_dup 1) (const_int 16)))
9052 (match_operand:SI 7 "gpc_reg_operand" "r"))])]
9053 "TARGET_STRING && !TARGET_POWER && XVECLEN (operands[0], 0) == 6"
9054 "{stsi|stswi} %2,%1,%O0"
9055 [(set_attr "type" "store")])
9056
9057 (define_insn "*stmsi4"
9058 [(match_parallel 0 "store_multiple_operation"
9059 [(set (mem:SI (match_operand:SI 1 "gpc_reg_operand" "b"))
9060 (match_operand:SI 2 "gpc_reg_operand" "r"))
9061 (clobber (match_scratch:SI 3 "X"))
9062 (set (mem:SI (plus:SI (match_dup 1) (const_int 4)))
9063 (match_operand:SI 4 "gpc_reg_operand" "r"))
9064 (set (mem:SI (plus:SI (match_dup 1) (const_int 8)))
9065 (match_operand:SI 5 "gpc_reg_operand" "r"))
9066 (set (mem:SI (plus:SI (match_dup 1) (const_int 12)))
9067 (match_operand:SI 6 "gpc_reg_operand" "r"))])]
9068 "TARGET_STRING && !TARGET_POWER && XVECLEN (operands[0], 0) == 5"
9069 "{stsi|stswi} %2,%1,%O0"
9070 [(set_attr "type" "store")])
9071
9072 (define_insn "*stmsi3"
9073 [(match_parallel 0 "store_multiple_operation"
9074 [(set (mem:SI (match_operand:SI 1 "gpc_reg_operand" "b"))
9075 (match_operand:SI 2 "gpc_reg_operand" "r"))
9076 (clobber (match_scratch:SI 3 "X"))
9077 (set (mem:SI (plus:SI (match_dup 1) (const_int 4)))
9078 (match_operand:SI 4 "gpc_reg_operand" "r"))
9079 (set (mem:SI (plus:SI (match_dup 1) (const_int 8)))
9080 (match_operand:SI 5 "gpc_reg_operand" "r"))])]
9081 "TARGET_STRING && !TARGET_POWER && XVECLEN (operands[0], 0) == 4"
9082 "{stsi|stswi} %2,%1,%O0"
9083 [(set_attr "type" "store")])
9084 \f
9085 ;; String/block move insn.
9086 ;; Argument 0 is the destination
9087 ;; Argument 1 is the source
9088 ;; Argument 2 is the length
9089 ;; Argument 3 is the alignment
9090
9091 (define_expand "movstrsi"
9092 [(parallel [(set (match_operand:BLK 0 "" "")
9093 (match_operand:BLK 1 "" ""))
9094 (use (match_operand:SI 2 "" ""))
9095 (use (match_operand:SI 3 "" ""))])]
9096 ""
9097 "
9098 {
9099 if (expand_block_move (operands))
9100 DONE;
9101 else
9102 FAIL;
9103 }")
9104
9105 ;; Move up to 32 bytes at a time. The fixed registers are needed because the
9106 ;; register allocator doesn't have a clue about allocating 8 word registers.
9107 ;; rD/rS = r5 is preferred, efficient form.
9108 (define_expand "movstrsi_8reg"
9109 [(parallel [(set (match_operand 0 "" "")
9110 (match_operand 1 "" ""))
9111 (use (match_operand 2 "" ""))
9112 (use (match_operand 3 "" ""))
9113 (clobber (reg:SI 5))
9114 (clobber (reg:SI 6))
9115 (clobber (reg:SI 7))
9116 (clobber (reg:SI 8))
9117 (clobber (reg:SI 9))
9118 (clobber (reg:SI 10))
9119 (clobber (reg:SI 11))
9120 (clobber (reg:SI 12))
9121 (clobber (match_scratch:SI 4 ""))])]
9122 "TARGET_STRING"
9123 "")
9124
9125 (define_insn ""
9126 [(set (mem:BLK (match_operand:SI 0 "gpc_reg_operand" "b"))
9127 (mem:BLK (match_operand:SI 1 "gpc_reg_operand" "b")))
9128 (use (match_operand:SI 2 "immediate_operand" "i"))
9129 (use (match_operand:SI 3 "immediate_operand" "i"))
9130 (clobber (match_operand:SI 4 "gpc_reg_operand" "=r"))
9131 (clobber (reg:SI 6))
9132 (clobber (reg:SI 7))
9133 (clobber (reg:SI 8))
9134 (clobber (reg:SI 9))
9135 (clobber (reg:SI 10))
9136 (clobber (reg:SI 11))
9137 (clobber (reg:SI 12))
9138 (clobber (match_scratch:SI 5 "=q"))]
9139 "TARGET_STRING && TARGET_POWER
9140 && ((INTVAL (operands[2]) > 24 && INTVAL (operands[2]) < 32)
9141 || INTVAL (operands[2]) == 0)
9142 && (REGNO (operands[0]) < 5 || REGNO (operands[0]) > 12)
9143 && (REGNO (operands[1]) < 5 || REGNO (operands[1]) > 12)
9144 && REGNO (operands[4]) == 5"
9145 "{lsi|lswi} %4,%1,%2\;{stsi|stswi} %4,%0,%2"
9146 [(set_attr "type" "load")
9147 (set_attr "length" "8")])
9148
9149 (define_insn ""
9150 [(set (mem:BLK (match_operand:SI 0 "gpc_reg_operand" "b"))
9151 (mem:BLK (match_operand:SI 1 "gpc_reg_operand" "b")))
9152 (use (match_operand:SI 2 "immediate_operand" "i"))
9153 (use (match_operand:SI 3 "immediate_operand" "i"))
9154 (clobber (match_operand:SI 4 "gpc_reg_operand" "=r"))
9155 (clobber (reg:SI 6))
9156 (clobber (reg:SI 7))
9157 (clobber (reg:SI 8))
9158 (clobber (reg:SI 9))
9159 (clobber (reg:SI 10))
9160 (clobber (reg:SI 11))
9161 (clobber (reg:SI 12))
9162 (clobber (match_scratch:SI 5 "X"))]
9163 "TARGET_STRING && ! TARGET_POWER
9164 && ((INTVAL (operands[2]) > 24 && INTVAL (operands[2]) < 32)
9165 || INTVAL (operands[2]) == 0)
9166 && (REGNO (operands[0]) < 5 || REGNO (operands[0]) > 12)
9167 && (REGNO (operands[1]) < 5 || REGNO (operands[1]) > 12)
9168 && REGNO (operands[4]) == 5"
9169 "{lsi|lswi} %4,%1,%2\;{stsi|stswi} %4,%0,%2"
9170 [(set_attr "type" "load")
9171 (set_attr "length" "8")])
9172
9173 (define_insn ""
9174 [(set (mem:BLK (match_operand:DI 0 "gpc_reg_operand" "b"))
9175 (mem:BLK (match_operand:DI 1 "gpc_reg_operand" "b")))
9176 (use (match_operand:SI 2 "immediate_operand" "i"))
9177 (use (match_operand:SI 3 "immediate_operand" "i"))
9178 (clobber (match_operand:SI 4 "gpc_reg_operand" "=r"))
9179 (clobber (reg:SI 6))
9180 (clobber (reg:SI 7))
9181 (clobber (reg:SI 8))
9182 (clobber (reg:SI 9))
9183 (clobber (reg:SI 10))
9184 (clobber (reg:SI 11))
9185 (clobber (reg:SI 12))
9186 (clobber (match_scratch:SI 5 "X"))]
9187 "TARGET_STRING && TARGET_POWERPC64
9188 && ((INTVAL (operands[2]) > 24 && INTVAL (operands[2]) < 32)
9189 || INTVAL (operands[2]) == 0)
9190 && (REGNO (operands[0]) < 5 || REGNO (operands[0]) > 12)
9191 && (REGNO (operands[1]) < 5 || REGNO (operands[1]) > 12)
9192 && REGNO (operands[4]) == 5"
9193 "{lsi|lswi} %4,%1,%2\;{stsi|stswi} %4,%0,%2"
9194 [(set_attr "type" "load")
9195 (set_attr "length" "8")])
9196
9197 ;; Move up to 24 bytes at a time. The fixed registers are needed because the
9198 ;; register allocator doesn't have a clue about allocating 6 word registers.
9199 ;; rD/rS = r5 is preferred, efficient form.
9200 (define_expand "movstrsi_6reg"
9201 [(parallel [(set (match_operand 0 "" "")
9202 (match_operand 1 "" ""))
9203 (use (match_operand 2 "" ""))
9204 (use (match_operand 3 "" ""))
9205 (clobber (reg:SI 5))
9206 (clobber (reg:SI 6))
9207 (clobber (reg:SI 7))
9208 (clobber (reg:SI 8))
9209 (clobber (reg:SI 9))
9210 (clobber (reg:SI 10))
9211 (clobber (match_scratch:SI 4 ""))])]
9212 "TARGET_STRING"
9213 "")
9214
9215 (define_insn ""
9216 [(set (mem:BLK (match_operand:SI 0 "gpc_reg_operand" "b"))
9217 (mem:BLK (match_operand:SI 1 "gpc_reg_operand" "b")))
9218 (use (match_operand:SI 2 "immediate_operand" "i"))
9219 (use (match_operand:SI 3 "immediate_operand" "i"))
9220 (clobber (match_operand:SI 4 "gpc_reg_operand" "=r"))
9221 (clobber (reg:SI 6))
9222 (clobber (reg:SI 7))
9223 (clobber (reg:SI 8))
9224 (clobber (reg:SI 9))
9225 (clobber (reg:SI 10))
9226 (clobber (match_scratch:SI 5 "=q"))]
9227 "TARGET_STRING && TARGET_POWER
9228 && INTVAL (operands[2]) > 16 && INTVAL (operands[2]) <= 24
9229 && (REGNO (operands[0]) < 5 || REGNO (operands[0]) > 10)
9230 && (REGNO (operands[1]) < 5 || REGNO (operands[1]) > 10)
9231 && REGNO (operands[4]) == 5"
9232 "{lsi|lswi} %4,%1,%2\;{stsi|stswi} %4,%0,%2"
9233 [(set_attr "type" "load")
9234 (set_attr "length" "8")])
9235
9236 (define_insn ""
9237 [(set (mem:BLK (match_operand:SI 0 "gpc_reg_operand" "b"))
9238 (mem:BLK (match_operand:SI 1 "gpc_reg_operand" "b")))
9239 (use (match_operand:SI 2 "immediate_operand" "i"))
9240 (use (match_operand:SI 3 "immediate_operand" "i"))
9241 (clobber (match_operand:SI 4 "gpc_reg_operand" "=r"))
9242 (clobber (reg:SI 6))
9243 (clobber (reg:SI 7))
9244 (clobber (reg:SI 8))
9245 (clobber (reg:SI 9))
9246 (clobber (reg:SI 10))
9247 (clobber (match_scratch:SI 5 "X"))]
9248 "TARGET_STRING && ! TARGET_POWER
9249 && INTVAL (operands[2]) > 16 && INTVAL (operands[2]) <= 32
9250 && (REGNO (operands[0]) < 5 || REGNO (operands[0]) > 10)
9251 && (REGNO (operands[1]) < 5 || REGNO (operands[1]) > 10)
9252 && REGNO (operands[4]) == 5"
9253 "{lsi|lswi} %4,%1,%2\;{stsi|stswi} %4,%0,%2"
9254 [(set_attr "type" "load")
9255 (set_attr "length" "8")])
9256
9257 (define_insn ""
9258 [(set (mem:BLK (match_operand:DI 0 "gpc_reg_operand" "b"))
9259 (mem:BLK (match_operand:DI 1 "gpc_reg_operand" "b")))
9260 (use (match_operand:SI 2 "immediate_operand" "i"))
9261 (use (match_operand:SI 3 "immediate_operand" "i"))
9262 (clobber (match_operand:SI 4 "gpc_reg_operand" "=r"))
9263 (clobber (reg:SI 6))
9264 (clobber (reg:SI 7))
9265 (clobber (reg:SI 8))
9266 (clobber (reg:SI 9))
9267 (clobber (reg:SI 10))
9268 (clobber (match_scratch:SI 5 "X"))]
9269 "TARGET_STRING && TARGET_POWERPC64
9270 && INTVAL (operands[2]) > 16 && INTVAL (operands[2]) <= 32
9271 && (REGNO (operands[0]) < 5 || REGNO (operands[0]) > 10)
9272 && (REGNO (operands[1]) < 5 || REGNO (operands[1]) > 10)
9273 && REGNO (operands[4]) == 5"
9274 "{lsi|lswi} %4,%1,%2\;{stsi|stswi} %4,%0,%2"
9275 [(set_attr "type" "load")
9276 (set_attr "length" "8")])
9277
9278 ;; Move up to 16 bytes at a time, using 4 fixed registers to avoid spill
9279 ;; problems with TImode.
9280 ;; rD/rS = r5 is preferred, efficient form.
9281 (define_expand "movstrsi_4reg"
9282 [(parallel [(set (match_operand 0 "" "")
9283 (match_operand 1 "" ""))
9284 (use (match_operand 2 "" ""))
9285 (use (match_operand 3 "" ""))
9286 (clobber (reg:SI 5))
9287 (clobber (reg:SI 6))
9288 (clobber (reg:SI 7))
9289 (clobber (reg:SI 8))
9290 (clobber (match_scratch:SI 4 ""))])]
9291 "TARGET_STRING"
9292 "")
9293
9294 (define_insn ""
9295 [(set (mem:BLK (match_operand:SI 0 "gpc_reg_operand" "b"))
9296 (mem:BLK (match_operand:SI 1 "gpc_reg_operand" "b")))
9297 (use (match_operand:SI 2 "immediate_operand" "i"))
9298 (use (match_operand:SI 3 "immediate_operand" "i"))
9299 (clobber (match_operand:SI 4 "gpc_reg_operand" "=r"))
9300 (clobber (reg:SI 6))
9301 (clobber (reg:SI 7))
9302 (clobber (reg:SI 8))
9303 (clobber (match_scratch:SI 5 "=q"))]
9304 "TARGET_STRING && TARGET_POWER
9305 && INTVAL (operands[2]) > 8 && INTVAL (operands[2]) <= 16
9306 && (REGNO (operands[0]) < 5 || REGNO (operands[0]) > 8)
9307 && (REGNO (operands[1]) < 5 || REGNO (operands[1]) > 8)
9308 && REGNO (operands[4]) == 5"
9309 "{lsi|lswi} %4,%1,%2\;{stsi|stswi} %4,%0,%2"
9310 [(set_attr "type" "load")
9311 (set_attr "length" "8")])
9312
9313 (define_insn ""
9314 [(set (mem:BLK (match_operand:SI 0 "gpc_reg_operand" "b"))
9315 (mem:BLK (match_operand:SI 1 "gpc_reg_operand" "b")))
9316 (use (match_operand:SI 2 "immediate_operand" "i"))
9317 (use (match_operand:SI 3 "immediate_operand" "i"))
9318 (clobber (match_operand:SI 4 "gpc_reg_operand" "=r"))
9319 (clobber (reg:SI 6))
9320 (clobber (reg:SI 7))
9321 (clobber (reg:SI 8))
9322 (clobber (match_scratch:SI 5 "X"))]
9323 "TARGET_STRING && ! TARGET_POWER
9324 && INTVAL (operands[2]) > 8 && INTVAL (operands[2]) <= 16
9325 && (REGNO (operands[0]) < 5 || REGNO (operands[0]) > 8)
9326 && (REGNO (operands[1]) < 5 || REGNO (operands[1]) > 8)
9327 && REGNO (operands[4]) == 5"
9328 "{lsi|lswi} %4,%1,%2\;{stsi|stswi} %4,%0,%2"
9329 [(set_attr "type" "load")
9330 (set_attr "length" "8")])
9331
9332 (define_insn ""
9333 [(set (mem:BLK (match_operand:DI 0 "gpc_reg_operand" "b"))
9334 (mem:BLK (match_operand:DI 1 "gpc_reg_operand" "b")))
9335 (use (match_operand:SI 2 "immediate_operand" "i"))
9336 (use (match_operand:SI 3 "immediate_operand" "i"))
9337 (clobber (match_operand:SI 4 "gpc_reg_operand" "=r"))
9338 (clobber (reg:SI 6))
9339 (clobber (reg:SI 7))
9340 (clobber (reg:SI 8))
9341 (clobber (match_scratch:SI 5 "X"))]
9342 "TARGET_STRING && TARGET_POWERPC64
9343 && INTVAL (operands[2]) > 8 && INTVAL (operands[2]) <= 16
9344 && (REGNO (operands[0]) < 5 || REGNO (operands[0]) > 8)
9345 && (REGNO (operands[1]) < 5 || REGNO (operands[1]) > 8)
9346 && REGNO (operands[4]) == 5"
9347 "{lsi|lswi} %4,%1,%2\;{stsi|stswi} %4,%0,%2"
9348 [(set_attr "type" "load")
9349 (set_attr "length" "8")])
9350
9351 ;; Move up to 8 bytes at a time.
9352 (define_expand "movstrsi_2reg"
9353 [(parallel [(set (match_operand 0 "" "")
9354 (match_operand 1 "" ""))
9355 (use (match_operand 2 "" ""))
9356 (use (match_operand 3 "" ""))
9357 (clobber (match_scratch:DI 4 ""))
9358 (clobber (match_scratch:SI 5 ""))])]
9359 "TARGET_STRING && ! TARGET_POWERPC64"
9360 "")
9361
9362 (define_insn ""
9363 [(set (mem:BLK (match_operand:SI 0 "gpc_reg_operand" "b"))
9364 (mem:BLK (match_operand:SI 1 "gpc_reg_operand" "b")))
9365 (use (match_operand:SI 2 "immediate_operand" "i"))
9366 (use (match_operand:SI 3 "immediate_operand" "i"))
9367 (clobber (match_scratch:DI 4 "=&r"))
9368 (clobber (match_scratch:SI 5 "=q"))]
9369 "TARGET_STRING && TARGET_POWER && ! TARGET_POWERPC64
9370 && INTVAL (operands[2]) > 4 && INTVAL (operands[2]) <= 8"
9371 "{lsi|lswi} %4,%1,%2\;{stsi|stswi} %4,%0,%2"
9372 [(set_attr "type" "load")
9373 (set_attr "length" "8")])
9374
9375 (define_insn ""
9376 [(set (mem:BLK (match_operand:SI 0 "gpc_reg_operand" "b"))
9377 (mem:BLK (match_operand:SI 1 "gpc_reg_operand" "b")))
9378 (use (match_operand:SI 2 "immediate_operand" "i"))
9379 (use (match_operand:SI 3 "immediate_operand" "i"))
9380 (clobber (match_scratch:DI 4 "=&r"))
9381 (clobber (match_scratch:SI 5 "X"))]
9382 "TARGET_STRING && ! TARGET_POWER && ! TARGET_POWERPC64
9383 && INTVAL (operands[2]) > 4 && INTVAL (operands[2]) <= 8"
9384 "{lsi|lswi} %4,%1,%2\;{stsi|stswi} %4,%0,%2"
9385 [(set_attr "type" "load")
9386 (set_attr "length" "8")])
9387
9388 ;; Move up to 4 bytes at a time.
9389 (define_expand "movstrsi_1reg"
9390 [(parallel [(set (match_operand 0 "" "")
9391 (match_operand 1 "" ""))
9392 (use (match_operand 2 "" ""))
9393 (use (match_operand 3 "" ""))
9394 (clobber (match_scratch:SI 4 ""))
9395 (clobber (match_scratch:SI 5 ""))])]
9396 "TARGET_STRING"
9397 "")
9398
9399 (define_insn ""
9400 [(set (mem:BLK (match_operand:SI 0 "gpc_reg_operand" "b"))
9401 (mem:BLK (match_operand:SI 1 "gpc_reg_operand" "b")))
9402 (use (match_operand:SI 2 "immediate_operand" "i"))
9403 (use (match_operand:SI 3 "immediate_operand" "i"))
9404 (clobber (match_scratch:SI 4 "=&r"))
9405 (clobber (match_scratch:SI 5 "=q"))]
9406 "TARGET_STRING && TARGET_POWER
9407 && INTVAL (operands[2]) > 0 && INTVAL (operands[2]) <= 4"
9408 "{lsi|lswi} %4,%1,%2\;{stsi|stswi} %4,%0,%2"
9409 [(set_attr "type" "load")
9410 (set_attr "length" "8")])
9411
9412 (define_insn ""
9413 [(set (mem:BLK (match_operand:SI 0 "gpc_reg_operand" "b"))
9414 (mem:BLK (match_operand:SI 1 "gpc_reg_operand" "b")))
9415 (use (match_operand:SI 2 "immediate_operand" "i"))
9416 (use (match_operand:SI 3 "immediate_operand" "i"))
9417 (clobber (match_scratch:SI 4 "=&r"))
9418 (clobber (match_scratch:SI 5 "X"))]
9419 "TARGET_STRING && ! TARGET_POWER
9420 && INTVAL (operands[2]) > 0 && INTVAL (operands[2]) <= 4"
9421 "{lsi|lswi} %4,%1,%2\;{stsi|stswi} %4,%0,%2"
9422 [(set_attr "type" "load")
9423 (set_attr "length" "8")])
9424
9425 (define_insn ""
9426 [(set (mem:BLK (match_operand:DI 0 "gpc_reg_operand" "b"))
9427 (mem:BLK (match_operand:DI 1 "gpc_reg_operand" "b")))
9428 (use (match_operand:SI 2 "immediate_operand" "i"))
9429 (use (match_operand:SI 3 "immediate_operand" "i"))
9430 (clobber (match_scratch:SI 4 "=&r"))
9431 (clobber (match_scratch:SI 5 "X"))]
9432 "TARGET_STRING && TARGET_POWERPC64
9433 && INTVAL (operands[2]) > 0 && INTVAL (operands[2]) <= 4"
9434 "{lsi|lswi} %4,%1,%2\;{stsi|stswi} %4,%0,%2"
9435 [(set_attr "type" "load")
9436 (set_attr "length" "8")])
9437
9438 \f
9439 ;; Define insns that do load or store with update. Some of these we can
9440 ;; get by using pre-decrement or pre-increment, but the hardware can also
9441 ;; do cases where the increment is not the size of the object.
9442 ;;
9443 ;; In all these cases, we use operands 0 and 1 for the register being
9444 ;; incremented because those are the operands that local-alloc will
9445 ;; tie and these are the pair most likely to be tieable (and the ones
9446 ;; that will benefit the most).
9447
9448 (define_insn "*movdi_update1"
9449 [(set (match_operand:DI 3 "gpc_reg_operand" "=r,r")
9450 (mem:DI (plus:DI (match_operand:DI 1 "gpc_reg_operand" "0,0")
9451 (match_operand:DI 2 "reg_or_aligned_short_operand" "r,I"))))
9452 (set (match_operand:DI 0 "gpc_reg_operand" "=b,b")
9453 (plus:DI (match_dup 1) (match_dup 2)))]
9454 "TARGET_POWERPC64 && TARGET_UPDATE"
9455 "@
9456 ldux %3,%0,%2
9457 ldu %3,%2(%0)"
9458 [(set_attr "type" "load_ux,load_u")])
9459
9460 (define_insn "movdi_update"
9461 [(set (mem:DI (plus:DI (match_operand:DI 1 "gpc_reg_operand" "0,0")
9462 (match_operand:DI 2 "reg_or_aligned_short_operand" "r,I")))
9463 (match_operand:DI 3 "gpc_reg_operand" "r,r"))
9464 (set (match_operand:DI 0 "gpc_reg_operand" "=b,b")
9465 (plus:DI (match_dup 1) (match_dup 2)))]
9466 "TARGET_POWERPC64 && TARGET_UPDATE"
9467 "@
9468 stdux %3,%0,%2
9469 stdu %3,%2(%0)"
9470 [(set_attr "type" "store_ux,store_u")])
9471
9472 (define_insn "*movsi_update1"
9473 [(set (match_operand:SI 3 "gpc_reg_operand" "=r,r")
9474 (mem:SI (plus:SI (match_operand:SI 1 "gpc_reg_operand" "0,0")
9475 (match_operand:SI 2 "reg_or_short_operand" "r,I"))))
9476 (set (match_operand:SI 0 "gpc_reg_operand" "=b,b")
9477 (plus:SI (match_dup 1) (match_dup 2)))]
9478 "TARGET_UPDATE"
9479 "@
9480 {lux|lwzux} %3,%0,%2
9481 {lu|lwzu} %3,%2(%0)"
9482 [(set_attr "type" "load_ux,load_u")])
9483
9484 (define_insn "*movsi_update2"
9485 [(set (match_operand:DI 3 "gpc_reg_operand" "=r")
9486 (sign_extend:DI
9487 (mem:SI (plus:DI (match_operand:DI 1 "gpc_reg_operand" "0")
9488 (match_operand:DI 2 "gpc_reg_operand" "r")))))
9489 (set (match_operand:DI 0 "gpc_reg_operand" "=b")
9490 (plus:DI (match_dup 1) (match_dup 2)))]
9491 "TARGET_POWERPC64"
9492 "lwaux %3,%0,%2"
9493 [(set_attr "type" "load_ext_ux")])
9494
9495 (define_insn "movsi_update"
9496 [(set (mem:SI (plus:SI (match_operand:SI 1 "gpc_reg_operand" "0,0")
9497 (match_operand:SI 2 "reg_or_short_operand" "r,I")))
9498 (match_operand:SI 3 "gpc_reg_operand" "r,r"))
9499 (set (match_operand:SI 0 "gpc_reg_operand" "=b,b")
9500 (plus:SI (match_dup 1) (match_dup 2)))]
9501 "TARGET_UPDATE"
9502 "@
9503 {stux|stwux} %3,%0,%2
9504 {stu|stwu} %3,%2(%0)"
9505 [(set_attr "type" "store_ux,store_u")])
9506
9507 (define_insn "*movhi_update1"
9508 [(set (match_operand:HI 3 "gpc_reg_operand" "=r,r")
9509 (mem:HI (plus:SI (match_operand:SI 1 "gpc_reg_operand" "0,0")
9510 (match_operand:SI 2 "reg_or_short_operand" "r,I"))))
9511 (set (match_operand:SI 0 "gpc_reg_operand" "=b,b")
9512 (plus:SI (match_dup 1) (match_dup 2)))]
9513 "TARGET_UPDATE"
9514 "@
9515 lhzux %3,%0,%2
9516 lhzu %3,%2(%0)"
9517 [(set_attr "type" "load_ux,load_u")])
9518
9519 (define_insn "*movhi_update2"
9520 [(set (match_operand:SI 3 "gpc_reg_operand" "=r,r")
9521 (zero_extend:SI
9522 (mem:HI (plus:SI (match_operand:SI 1 "gpc_reg_operand" "0,0")
9523 (match_operand:SI 2 "reg_or_short_operand" "r,I")))))
9524 (set (match_operand:SI 0 "gpc_reg_operand" "=b,b")
9525 (plus:SI (match_dup 1) (match_dup 2)))]
9526 "TARGET_UPDATE"
9527 "@
9528 lhzux %3,%0,%2
9529 lhzu %3,%2(%0)"
9530 [(set_attr "type" "load_ux,load_u")])
9531
9532 (define_insn "*movhi_update3"
9533 [(set (match_operand:SI 3 "gpc_reg_operand" "=r,r")
9534 (sign_extend:SI
9535 (mem:HI (plus:SI (match_operand:SI 1 "gpc_reg_operand" "0,0")
9536 (match_operand:SI 2 "reg_or_short_operand" "r,I")))))
9537 (set (match_operand:SI 0 "gpc_reg_operand" "=b,b")
9538 (plus:SI (match_dup 1) (match_dup 2)))]
9539 "TARGET_UPDATE"
9540 "@
9541 lhaux %3,%0,%2
9542 lhau %3,%2(%0)"
9543 [(set_attr "type" "load_ext_ux,load_ext_u")])
9544
9545 (define_insn "*movhi_update4"
9546 [(set (mem:HI (plus:SI (match_operand:SI 1 "gpc_reg_operand" "0,0")
9547 (match_operand:SI 2 "reg_or_short_operand" "r,I")))
9548 (match_operand:HI 3 "gpc_reg_operand" "r,r"))
9549 (set (match_operand:SI 0 "gpc_reg_operand" "=b,b")
9550 (plus:SI (match_dup 1) (match_dup 2)))]
9551 "TARGET_UPDATE"
9552 "@
9553 sthux %3,%0,%2
9554 sthu %3,%2(%0)"
9555 [(set_attr "type" "store_ux,store_u")])
9556
9557 (define_insn "*movqi_update1"
9558 [(set (match_operand:QI 3 "gpc_reg_operand" "=r,r")
9559 (mem:QI (plus:SI (match_operand:SI 1 "gpc_reg_operand" "0,0")
9560 (match_operand:SI 2 "reg_or_short_operand" "r,I"))))
9561 (set (match_operand:SI 0 "gpc_reg_operand" "=b,b")
9562 (plus:SI (match_dup 1) (match_dup 2)))]
9563 "TARGET_UPDATE"
9564 "@
9565 lbzux %3,%0,%2
9566 lbzu %3,%2(%0)"
9567 [(set_attr "type" "load_ux,load_u")])
9568
9569 (define_insn "*movqi_update2"
9570 [(set (match_operand:SI 3 "gpc_reg_operand" "=r,r")
9571 (zero_extend:SI
9572 (mem:QI (plus:SI (match_operand:SI 1 "gpc_reg_operand" "0,0")
9573 (match_operand:SI 2 "reg_or_short_operand" "r,I")))))
9574 (set (match_operand:SI 0 "gpc_reg_operand" "=b,b")
9575 (plus:SI (match_dup 1) (match_dup 2)))]
9576 "TARGET_UPDATE"
9577 "@
9578 lbzux %3,%0,%2
9579 lbzu %3,%2(%0)"
9580 [(set_attr "type" "load_ux,load_u")])
9581
9582 (define_insn "*movqi_update3"
9583 [(set (mem:QI (plus:SI (match_operand:SI 1 "gpc_reg_operand" "0,0")
9584 (match_operand:SI 2 "reg_or_short_operand" "r,I")))
9585 (match_operand:QI 3 "gpc_reg_operand" "r,r"))
9586 (set (match_operand:SI 0 "gpc_reg_operand" "=b,b")
9587 (plus:SI (match_dup 1) (match_dup 2)))]
9588 "TARGET_UPDATE"
9589 "@
9590 stbux %3,%0,%2
9591 stbu %3,%2(%0)"
9592 [(set_attr "type" "store_ux,store_u")])
9593
9594 (define_insn "*movsf_update1"
9595 [(set (match_operand:SF 3 "gpc_reg_operand" "=f,f")
9596 (mem:SF (plus:SI (match_operand:SI 1 "gpc_reg_operand" "0,0")
9597 (match_operand:SI 2 "reg_or_short_operand" "r,I"))))
9598 (set (match_operand:SI 0 "gpc_reg_operand" "=b,b")
9599 (plus:SI (match_dup 1) (match_dup 2)))]
9600 "TARGET_HARD_FLOAT && TARGET_FPRS && TARGET_UPDATE"
9601 "@
9602 lfsux %3,%0,%2
9603 lfsu %3,%2(%0)"
9604 [(set_attr "type" "fpload_ux,fpload_u")])
9605
9606 (define_insn "*movsf_update2"
9607 [(set (mem:SF (plus:SI (match_operand:SI 1 "gpc_reg_operand" "0,0")
9608 (match_operand:SI 2 "reg_or_short_operand" "r,I")))
9609 (match_operand:SF 3 "gpc_reg_operand" "f,f"))
9610 (set (match_operand:SI 0 "gpc_reg_operand" "=b,b")
9611 (plus:SI (match_dup 1) (match_dup 2)))]
9612 "TARGET_HARD_FLOAT && TARGET_FPRS && TARGET_UPDATE"
9613 "@
9614 stfsux %3,%0,%2
9615 stfsu %3,%2(%0)"
9616 [(set_attr "type" "fpstore_ux,fpstore_u")])
9617
9618 (define_insn "*movsf_update3"
9619 [(set (match_operand:SF 3 "gpc_reg_operand" "=r,r")
9620 (mem:SF (plus:SI (match_operand:SI 1 "gpc_reg_operand" "0,0")
9621 (match_operand:SI 2 "reg_or_short_operand" "r,I"))))
9622 (set (match_operand:SI 0 "gpc_reg_operand" "=b,b")
9623 (plus:SI (match_dup 1) (match_dup 2)))]
9624 "(TARGET_SOFT_FLOAT || !TARGET_FPRS) && TARGET_UPDATE"
9625 "@
9626 {lux|lwzux} %3,%0,%2
9627 {lu|lwzu} %3,%2(%0)"
9628 [(set_attr "type" "load_ux,load_u")])
9629
9630 (define_insn "*movsf_update4"
9631 [(set (mem:SF (plus:SI (match_operand:SI 1 "gpc_reg_operand" "0,0")
9632 (match_operand:SI 2 "reg_or_short_operand" "r,I")))
9633 (match_operand:SF 3 "gpc_reg_operand" "r,r"))
9634 (set (match_operand:SI 0 "gpc_reg_operand" "=b,b")
9635 (plus:SI (match_dup 1) (match_dup 2)))]
9636 "(TARGET_SOFT_FLOAT || !TARGET_FPRS) && TARGET_UPDATE"
9637 "@
9638 {stux|stwux} %3,%0,%2
9639 {stu|stwu} %3,%2(%0)"
9640 [(set_attr "type" "store_ux,store_u")])
9641
9642 (define_insn "*movdf_update1"
9643 [(set (match_operand:DF 3 "gpc_reg_operand" "=f,f")
9644 (mem:DF (plus:SI (match_operand:SI 1 "gpc_reg_operand" "0,0")
9645 (match_operand:SI 2 "reg_or_short_operand" "r,I"))))
9646 (set (match_operand:SI 0 "gpc_reg_operand" "=b,b")
9647 (plus:SI (match_dup 1) (match_dup 2)))]
9648 "TARGET_HARD_FLOAT && TARGET_FPRS && TARGET_UPDATE"
9649 "@
9650 lfdux %3,%0,%2
9651 lfdu %3,%2(%0)"
9652 [(set_attr "type" "fpload_ux,fpload_u")])
9653
9654 (define_insn "*movdf_update2"
9655 [(set (mem:DF (plus:SI (match_operand:SI 1 "gpc_reg_operand" "0,0")
9656 (match_operand:SI 2 "reg_or_short_operand" "r,I")))
9657 (match_operand:DF 3 "gpc_reg_operand" "f,f"))
9658 (set (match_operand:SI 0 "gpc_reg_operand" "=b,b")
9659 (plus:SI (match_dup 1) (match_dup 2)))]
9660 "TARGET_HARD_FLOAT && TARGET_FPRS && TARGET_UPDATE"
9661 "@
9662 stfdux %3,%0,%2
9663 stfdu %3,%2(%0)"
9664 [(set_attr "type" "fpstore_ux,fpstore_u")])
9665
9666 ;; Peephole to convert two consecutive FP loads or stores into lfq/stfq.
9667
9668 (define_peephole
9669 [(set (match_operand:DF 0 "gpc_reg_operand" "=f")
9670 (match_operand:DF 1 "memory_operand" ""))
9671 (set (match_operand:DF 2 "gpc_reg_operand" "=f")
9672 (match_operand:DF 3 "memory_operand" ""))]
9673 "TARGET_POWER2
9674 && TARGET_HARD_FLOAT && TARGET_FPRS
9675 && registers_ok_for_quad_peep (operands[0], operands[2])
9676 && ! MEM_VOLATILE_P (operands[1]) && ! MEM_VOLATILE_P (operands[3])
9677 && addrs_ok_for_quad_peep (XEXP (operands[1], 0), XEXP (operands[3], 0))"
9678 "lfq%U1%X1 %0,%1")
9679
9680 (define_peephole
9681 [(set (match_operand:DF 0 "memory_operand" "")
9682 (match_operand:DF 1 "gpc_reg_operand" "f"))
9683 (set (match_operand:DF 2 "memory_operand" "")
9684 (match_operand:DF 3 "gpc_reg_operand" "f"))]
9685 "TARGET_POWER2
9686 && TARGET_HARD_FLOAT && TARGET_FPRS
9687 && registers_ok_for_quad_peep (operands[1], operands[3])
9688 && ! MEM_VOLATILE_P (operands[0]) && ! MEM_VOLATILE_P (operands[2])
9689 && addrs_ok_for_quad_peep (XEXP (operands[0], 0), XEXP (operands[2], 0))"
9690 "stfq%U0%X0 %1,%0")
9691 \f
9692 ;; Next come insns related to the calling sequence.
9693 ;;
9694 ;; First, an insn to allocate new stack space for dynamic use (e.g., alloca).
9695 ;; We move the back-chain and decrement the stack pointer.
9696
9697 (define_expand "allocate_stack"
9698 [(set (match_operand 0 "gpc_reg_operand" "=r")
9699 (minus (reg 1) (match_operand 1 "reg_or_short_operand" "")))
9700 (set (reg 1)
9701 (minus (reg 1) (match_dup 1)))]
9702 ""
9703 "
9704 { rtx chain = gen_reg_rtx (Pmode);
9705 rtx stack_bot = gen_rtx_MEM (Pmode, stack_pointer_rtx);
9706 rtx neg_op0;
9707
9708 emit_move_insn (chain, stack_bot);
9709
9710 /* Check stack bounds if necessary. */
9711 if (current_function_limit_stack)
9712 {
9713 rtx available;
9714 available = expand_binop (Pmode, sub_optab,
9715 stack_pointer_rtx, stack_limit_rtx,
9716 NULL_RTX, 1, OPTAB_WIDEN);
9717 emit_insn (gen_cond_trap (LTU, available, operands[1], const0_rtx));
9718 }
9719
9720 if (GET_CODE (operands[1]) != CONST_INT
9721 || INTVAL (operands[1]) < -32767
9722 || INTVAL (operands[1]) > 32768)
9723 {
9724 neg_op0 = gen_reg_rtx (Pmode);
9725 if (TARGET_32BIT)
9726 emit_insn (gen_negsi2 (neg_op0, operands[1]));
9727 else
9728 emit_insn (gen_negdi2 (neg_op0, operands[1]));
9729 }
9730 else
9731 neg_op0 = GEN_INT (- INTVAL (operands[1]));
9732
9733 if (TARGET_UPDATE)
9734 emit_insn ((* ((TARGET_32BIT) ? gen_movsi_update : gen_movdi_update))
9735 (stack_pointer_rtx, stack_pointer_rtx, neg_op0, chain));
9736
9737 else
9738 {
9739 emit_insn ((* ((TARGET_32BIT) ? gen_addsi3 : gen_adddi3))
9740 (stack_pointer_rtx, stack_pointer_rtx, neg_op0));
9741 emit_move_insn (gen_rtx_MEM (Pmode, stack_pointer_rtx), chain);
9742 }
9743
9744 emit_move_insn (operands[0], virtual_stack_dynamic_rtx);
9745 DONE;
9746 }")
9747
9748 ;; These patterns say how to save and restore the stack pointer. We need not
9749 ;; save the stack pointer at function level since we are careful to
9750 ;; preserve the backchain. At block level, we have to restore the backchain
9751 ;; when we restore the stack pointer.
9752 ;;
9753 ;; For nonlocal gotos, we must save both the stack pointer and its
9754 ;; backchain and restore both. Note that in the nonlocal case, the
9755 ;; save area is a memory location.
9756
9757 (define_expand "save_stack_function"
9758 [(match_operand 0 "any_operand" "")
9759 (match_operand 1 "any_operand" "")]
9760 ""
9761 "DONE;")
9762
9763 (define_expand "restore_stack_function"
9764 [(match_operand 0 "any_operand" "")
9765 (match_operand 1 "any_operand" "")]
9766 ""
9767 "DONE;")
9768
9769 (define_expand "restore_stack_block"
9770 [(use (match_operand 0 "register_operand" ""))
9771 (set (match_dup 2) (match_dup 3))
9772 (set (match_dup 0) (match_operand 1 "register_operand" ""))
9773 (set (match_dup 3) (match_dup 2))]
9774 ""
9775 "
9776 {
9777 operands[2] = gen_reg_rtx (Pmode);
9778 operands[3] = gen_rtx_MEM (Pmode, operands[0]);
9779 }")
9780
9781 (define_expand "save_stack_nonlocal"
9782 [(match_operand 0 "memory_operand" "")
9783 (match_operand 1 "register_operand" "")]
9784 ""
9785 "
9786 {
9787 rtx temp = gen_reg_rtx (Pmode);
9788
9789 /* Copy the backchain to the first word, sp to the second. */
9790 emit_move_insn (temp, gen_rtx_MEM (Pmode, operands[1]));
9791 emit_move_insn (operand_subword (operands[0], 0, 0,
9792 (TARGET_32BIT ? DImode : TImode)),
9793 temp);
9794 emit_move_insn (operand_subword (operands[0], 1, 0, (TARGET_32BIT ? DImode : TImode)),
9795 operands[1]);
9796 DONE;
9797 }")
9798
9799 (define_expand "restore_stack_nonlocal"
9800 [(match_operand 0 "register_operand" "")
9801 (match_operand 1 "memory_operand" "")]
9802 ""
9803 "
9804 {
9805 rtx temp = gen_reg_rtx (Pmode);
9806
9807 /* Restore the backchain from the first word, sp from the second. */
9808 emit_move_insn (temp,
9809 operand_subword (operands[1], 0, 0, (TARGET_32BIT ? DImode : TImode)));
9810 emit_move_insn (operands[0],
9811 operand_subword (operands[1], 1, 0,
9812 (TARGET_32BIT ? DImode : TImode)));
9813 emit_move_insn (gen_rtx_MEM (Pmode, operands[0]), temp);
9814 DONE;
9815 }")
9816 \f
9817 ;; TOC register handling.
9818
9819 ;; Code to initialize the TOC register...
9820
9821 (define_insn "load_toc_aix_si"
9822 [(parallel [(set (match_operand:SI 0 "gpc_reg_operand" "=r")
9823 (unspec:SI [(const_int 0)] 7))
9824 (use (reg:SI 2))])]
9825 "DEFAULT_ABI == ABI_AIX && TARGET_32BIT"
9826 "*
9827 {
9828 char buf[30];
9829 ASM_GENERATE_INTERNAL_LABEL (buf, \"LCTOC\", 1);
9830 operands[1] = gen_rtx_SYMBOL_REF (Pmode, ggc_strdup (buf));
9831 operands[2] = gen_rtx_REG (Pmode, 2);
9832 return \"{l|lwz} %0,%1(%2)\";
9833 }"
9834 [(set_attr "type" "load")])
9835
9836 (define_insn "load_toc_aix_di"
9837 [(parallel [(set (match_operand:DI 0 "gpc_reg_operand" "=r")
9838 (unspec:DI [(const_int 0)] 7))
9839 (use (reg:DI 2))])]
9840 "DEFAULT_ABI == ABI_AIX && TARGET_64BIT"
9841 "*
9842 {
9843 char buf[30];
9844 #ifdef TARGET_RELOCATABLE
9845 ASM_GENERATE_INTERNAL_LABEL (buf, \"LCTOC\",
9846 !TARGET_MINIMAL_TOC || TARGET_RELOCATABLE);
9847 #else
9848 ASM_GENERATE_INTERNAL_LABEL (buf, \"LCTOC\", 1);
9849 #endif
9850 if (TARGET_ELF)
9851 strcat (buf, \"@toc\");
9852 operands[1] = gen_rtx_SYMBOL_REF (Pmode, ggc_strdup (buf));
9853 operands[2] = gen_rtx_REG (Pmode, 2);
9854 return \"ld %0,%1(%2)\";
9855 }"
9856 [(set_attr "type" "load")])
9857
9858 (define_insn "load_toc_v4_pic_si"
9859 [(set (match_operand:SI 0 "register_operand" "=l")
9860 (unspec:SI [(const_int 0)] 7))]
9861 "DEFAULT_ABI == ABI_V4 && flag_pic == 1 && TARGET_32BIT"
9862 "bl _GLOBAL_OFFSET_TABLE_@local-4"
9863 [(set_attr "type" "branch")
9864 (set_attr "length" "4")])
9865
9866 (define_insn "load_toc_v4_PIC_1"
9867 [(set (match_operand:SI 0 "register_operand" "=l")
9868 (match_operand:SI 1 "immediate_operand" "s"))
9869 (unspec [(match_dup 1)] 7)]
9870 "TARGET_ELF && DEFAULT_ABI != ABI_AIX && flag_pic == 2"
9871 "bcl 20,31,%1\\n%1:"
9872 [(set_attr "type" "branch")
9873 (set_attr "length" "4")])
9874
9875 (define_insn "load_toc_v4_PIC_1b"
9876 [(set (match_operand:SI 0 "register_operand" "=l")
9877 (match_operand:SI 1 "immediate_operand" "s"))
9878 (unspec [(match_dup 1) (match_operand 2 "immediate_operand" "s")] 6)]
9879 "TARGET_ELF && DEFAULT_ABI != ABI_AIX && flag_pic == 2"
9880 "bcl 20,31,%1\\n\\t.long %2-%1+4\\n%1:"
9881 [(set_attr "type" "branch")
9882 (set_attr "length" "8")])
9883
9884 (define_insn "load_toc_v4_PIC_2"
9885 [(set (match_operand:SI 0 "gpc_reg_operand" "=r")
9886 (mem:SI (plus:SI (match_operand:SI 1 "gpc_reg_operand" "b")
9887 (minus:SI (match_operand:SI 2 "immediate_operand" "s")
9888 (match_operand:SI 3 "immediate_operand" "s")))))]
9889 "TARGET_ELF && DEFAULT_ABI != ABI_AIX && flag_pic == 2"
9890 "{l|lwz} %0,%2-%3(%1)"
9891 [(set_attr "type" "load")])
9892
9893 (define_insn "load_macho_picbase"
9894 [(set (match_operand:SI 0 "register_operand" "=l")
9895 (unspec:SI [(match_operand:SI 1 "immediate_operand" "s")] 15))]
9896 "(DEFAULT_ABI == ABI_DARWIN) && flag_pic"
9897 "bcl 20,31,%1\\n%1:"
9898 [(set_attr "type" "branch")
9899 (set_attr "length" "4")])
9900
9901 (define_insn "macho_correct_pic"
9902 [(set (match_operand:SI 0 "gpc_reg_operand" "=r")
9903 (plus:SI (match_operand:SI 1 "gpc_reg_operand" "r")
9904 (unspec:SI [(match_operand:SI 2 "immediate_operand" "s")
9905 (match_operand:SI 3 "immediate_operand" "s")]
9906 16)))]
9907 "DEFAULT_ABI == ABI_DARWIN"
9908 "addis %0,%1,ha16(%2-%3)\n\taddi %0,%0,lo16(%2-%3)"
9909 [(set_attr "length" "8")])
9910
9911 ;; If the TOC is shared over a translation unit, as happens with all
9912 ;; the kinds of PIC that we support, we need to restore the TOC
9913 ;; pointer only when jumping over units of translation.
9914 ;; On Darwin, we need to reload the picbase.
9915
9916 (define_expand "builtin_setjmp_receiver"
9917 [(use (label_ref (match_operand 0 "" "")))]
9918 "(DEFAULT_ABI == ABI_V4 && flag_pic == 1)
9919 || (TARGET_TOC && TARGET_MINIMAL_TOC)
9920 || (DEFAULT_ABI == ABI_DARWIN && flag_pic)"
9921 "
9922 {
9923 #if TARGET_MACHO
9924 if (DEFAULT_ABI == ABI_DARWIN)
9925 {
9926 const char *picbase = machopic_function_base_name ();
9927 rtx picrtx = gen_rtx_SYMBOL_REF (Pmode, ggc_alloc_string (picbase, -1));
9928 rtx picreg = gen_rtx_REG (Pmode, RS6000_PIC_OFFSET_TABLE_REGNUM);
9929 rtx tmplabrtx;
9930 char tmplab[20];
9931
9932 ASM_GENERATE_INTERNAL_LABEL(tmplab, \"LSJR\",
9933 CODE_LABEL_NUMBER (operands[0]));
9934 tmplabrtx = gen_rtx_SYMBOL_REF (Pmode, ggc_alloc_string (tmplab, -1));
9935
9936 emit_insn (gen_load_macho_picbase (picreg, tmplabrtx));
9937 emit_insn (gen_macho_correct_pic (picreg, picreg, picrtx, tmplabrtx));
9938 }
9939 else
9940 #endif
9941 rs6000_emit_load_toc_table (FALSE);
9942 DONE;
9943 }")
9944 \f
9945 ;; A function pointer under AIX is a pointer to a data area whose first word
9946 ;; contains the actual address of the function, whose second word contains a
9947 ;; pointer to its TOC, and whose third word contains a value to place in the
9948 ;; static chain register (r11). Note that if we load the static chain, our
9949 ;; "trampoline" need not have any executable code.
9950
9951 (define_expand "call_indirect_aix32"
9952 [(set (match_dup 2)
9953 (mem:SI (match_operand:SI 0 "gpc_reg_operand" "")))
9954 (set (mem:SI (plus:SI (reg:SI 1) (const_int 20)))
9955 (reg:SI 2))
9956 (set (reg:SI 2)
9957 (mem:SI (plus:SI (match_dup 0)
9958 (const_int 4))))
9959 (set (reg:SI 11)
9960 (mem:SI (plus:SI (match_dup 0)
9961 (const_int 8))))
9962 (parallel [(call (mem:SI (match_dup 2))
9963 (match_operand 1 "" ""))
9964 (use (reg:SI 2))
9965 (use (reg:SI 11))
9966 (set (reg:SI 2)
9967 (mem:SI (plus:SI (reg:SI 1) (const_int 20))))
9968 (clobber (scratch:SI))])]
9969 "TARGET_32BIT"
9970 "
9971 { operands[2] = gen_reg_rtx (SImode); }")
9972
9973 (define_expand "call_indirect_aix64"
9974 [(set (match_dup 2)
9975 (mem:DI (match_operand:DI 0 "gpc_reg_operand" "")))
9976 (set (mem:DI (plus:DI (reg:DI 1) (const_int 40)))
9977 (reg:DI 2))
9978 (set (reg:DI 2)
9979 (mem:DI (plus:DI (match_dup 0)
9980 (const_int 8))))
9981 (set (reg:DI 11)
9982 (mem:DI (plus:DI (match_dup 0)
9983 (const_int 16))))
9984 (parallel [(call (mem:SI (match_dup 2))
9985 (match_operand 1 "" ""))
9986 (use (reg:DI 2))
9987 (use (reg:DI 11))
9988 (set (reg:DI 2)
9989 (mem:DI (plus:DI (reg:DI 1) (const_int 40))))
9990 (clobber (scratch:SI))])]
9991 "TARGET_64BIT"
9992 "
9993 { operands[2] = gen_reg_rtx (DImode); }")
9994
9995 (define_expand "call_value_indirect_aix32"
9996 [(set (match_dup 3)
9997 (mem:SI (match_operand:SI 1 "gpc_reg_operand" "")))
9998 (set (mem:SI (plus:SI (reg:SI 1) (const_int 20)))
9999 (reg:SI 2))
10000 (set (reg:SI 2)
10001 (mem:SI (plus:SI (match_dup 1)
10002 (const_int 4))))
10003 (set (reg:SI 11)
10004 (mem:SI (plus:SI (match_dup 1)
10005 (const_int 8))))
10006 (parallel [(set (match_operand 0 "" "")
10007 (call (mem:SI (match_dup 3))
10008 (match_operand 2 "" "")))
10009 (use (reg:SI 2))
10010 (use (reg:SI 11))
10011 (set (reg:SI 2)
10012 (mem:SI (plus:SI (reg:SI 1) (const_int 20))))
10013 (clobber (scratch:SI))])]
10014 "TARGET_32BIT"
10015 "
10016 { operands[3] = gen_reg_rtx (SImode); }")
10017
10018 (define_expand "call_value_indirect_aix64"
10019 [(set (match_dup 3)
10020 (mem:DI (match_operand:DI 1 "gpc_reg_operand" "")))
10021 (set (mem:DI (plus:DI (reg:DI 1) (const_int 40)))
10022 (reg:DI 2))
10023 (set (reg:DI 2)
10024 (mem:DI (plus:DI (match_dup 1)
10025 (const_int 8))))
10026 (set (reg:DI 11)
10027 (mem:DI (plus:DI (match_dup 1)
10028 (const_int 16))))
10029 (parallel [(set (match_operand 0 "" "")
10030 (call (mem:SI (match_dup 3))
10031 (match_operand 2 "" "")))
10032 (use (reg:DI 2))
10033 (use (reg:DI 11))
10034 (set (reg:DI 2)
10035 (mem:DI (plus:DI (reg:DI 1) (const_int 40))))
10036 (clobber (scratch:SI))])]
10037 "TARGET_64BIT"
10038 "
10039 { operands[3] = gen_reg_rtx (DImode); }")
10040
10041 ;; Now the definitions for the call and call_value insns
10042 (define_expand "call"
10043 [(parallel [(call (mem:SI (match_operand 0 "address_operand" ""))
10044 (match_operand 1 "" ""))
10045 (use (match_operand 2 "" ""))
10046 (clobber (scratch:SI))])]
10047 ""
10048 "
10049 {
10050 #if TARGET_MACHO
10051 if (MACHOPIC_INDIRECT)
10052 operands[0] = machopic_indirect_call_target (operands[0]);
10053 #endif
10054
10055 if (GET_CODE (operands[0]) != MEM || GET_CODE (operands[1]) != CONST_INT)
10056 abort ();
10057
10058 operands[0] = XEXP (operands[0], 0);
10059
10060 if (GET_CODE (operands[0]) != SYMBOL_REF
10061 || (INTVAL (operands[2]) & CALL_LONG) != 0)
10062 {
10063 if (INTVAL (operands[2]) & CALL_LONG)
10064 operands[0] = rs6000_longcall_ref (operands[0]);
10065
10066 if (DEFAULT_ABI == ABI_V4
10067 || DEFAULT_ABI == ABI_DARWIN)
10068 operands[0] = force_reg (Pmode, operands[0]);
10069
10070 else if (DEFAULT_ABI == ABI_AIX)
10071 {
10072 /* AIX function pointers are really pointers to a three word
10073 area. */
10074 emit_call_insn (TARGET_32BIT
10075 ? gen_call_indirect_aix32 (force_reg (SImode,
10076 operands[0]),
10077 operands[1])
10078 : gen_call_indirect_aix64 (force_reg (DImode,
10079 operands[0]),
10080 operands[1]));
10081 DONE;
10082 }
10083 else
10084 abort ();
10085 }
10086 }")
10087
10088 (define_expand "call_value"
10089 [(parallel [(set (match_operand 0 "" "")
10090 (call (mem:SI (match_operand 1 "address_operand" ""))
10091 (match_operand 2 "" "")))
10092 (use (match_operand 3 "" ""))
10093 (clobber (scratch:SI))])]
10094 ""
10095 "
10096 {
10097 #if TARGET_MACHO
10098 if (MACHOPIC_INDIRECT)
10099 operands[1] = machopic_indirect_call_target (operands[1]);
10100 #endif
10101
10102 if (GET_CODE (operands[1]) != MEM || GET_CODE (operands[2]) != CONST_INT)
10103 abort ();
10104
10105 operands[1] = XEXP (operands[1], 0);
10106
10107 if (GET_CODE (operands[1]) != SYMBOL_REF
10108 || (INTVAL (operands[3]) & CALL_LONG) != 0)
10109 {
10110 if (INTVAL (operands[3]) & CALL_LONG)
10111 operands[1] = rs6000_longcall_ref (operands[1]);
10112
10113 if (DEFAULT_ABI == ABI_V4
10114 || DEFAULT_ABI == ABI_DARWIN)
10115 operands[0] = force_reg (Pmode, operands[0]);
10116
10117 else if (DEFAULT_ABI == ABI_AIX)
10118 {
10119 /* AIX function pointers are really pointers to a three word
10120 area. */
10121 emit_call_insn (TARGET_32BIT
10122 ? gen_call_value_indirect_aix32 (operands[0],
10123 force_reg (SImode,
10124 operands[1]),
10125 operands[2])
10126 : gen_call_value_indirect_aix64 (operands[0],
10127 force_reg (DImode,
10128 operands[1]),
10129 operands[2]));
10130 DONE;
10131 }
10132 else
10133 abort ();
10134 }
10135 }")
10136
10137 ;; Call to function in current module. No TOC pointer reload needed.
10138 ;; Operand2 is nonzero if we are using the V.4 calling sequence and
10139 ;; either the function was not prototyped, or it was prototyped as a
10140 ;; variable argument function. It is > 0 if FP registers were passed
10141 ;; and < 0 if they were not.
10142
10143 (define_insn "*call_local32"
10144 [(call (mem:SI (match_operand:SI 0 "current_file_function_operand" "s,s"))
10145 (match_operand 1 "" "g,g"))
10146 (use (match_operand:SI 2 "immediate_operand" "O,n"))
10147 (clobber (match_scratch:SI 3 "=l,l"))]
10148 "(INTVAL (operands[2]) & CALL_LONG) == 0"
10149 "*
10150 {
10151 if (INTVAL (operands[2]) & CALL_V4_SET_FP_ARGS)
10152 output_asm_insn (\"crxor 6,6,6\", operands);
10153
10154 else if (INTVAL (operands[2]) & CALL_V4_CLEAR_FP_ARGS)
10155 output_asm_insn (\"creqv 6,6,6\", operands);
10156
10157 return (DEFAULT_ABI == ABI_V4 && flag_pic) ? \"bl %z0@local\" : \"bl %z0\";
10158 }"
10159 [(set_attr "type" "branch")
10160 (set_attr "length" "4,8")])
10161
10162 (define_insn "*call_local64"
10163 [(call (mem:SI (match_operand:DI 0 "current_file_function_operand" "s,s"))
10164 (match_operand 1 "" "g,g"))
10165 (use (match_operand:SI 2 "immediate_operand" "O,n"))
10166 (clobber (match_scratch:SI 3 "=l,l"))]
10167 "TARGET_64BIT && (INTVAL (operands[2]) & CALL_LONG) == 0"
10168 "*
10169 {
10170 if (INTVAL (operands[2]) & CALL_V4_SET_FP_ARGS)
10171 output_asm_insn (\"crxor 6,6,6\", operands);
10172
10173 else if (INTVAL (operands[2]) & CALL_V4_CLEAR_FP_ARGS)
10174 output_asm_insn (\"creqv 6,6,6\", operands);
10175
10176 return (DEFAULT_ABI == ABI_V4 && flag_pic) ? \"bl %z0@local\" : \"bl %z0\";
10177 }"
10178 [(set_attr "type" "branch")
10179 (set_attr "length" "4,8")])
10180
10181 (define_insn "*call_value_local32"
10182 [(set (match_operand 0 "" "")
10183 (call (mem:SI (match_operand:SI 1 "current_file_function_operand" "s,s"))
10184 (match_operand 2 "" "g,g")))
10185 (use (match_operand:SI 3 "immediate_operand" "O,n"))
10186 (clobber (match_scratch:SI 4 "=l,l"))]
10187 "(INTVAL (operands[3]) & CALL_LONG) == 0"
10188 "*
10189 {
10190 if (INTVAL (operands[3]) & CALL_V4_SET_FP_ARGS)
10191 output_asm_insn (\"crxor 6,6,6\", operands);
10192
10193 else if (INTVAL (operands[3]) & CALL_V4_CLEAR_FP_ARGS)
10194 output_asm_insn (\"creqv 6,6,6\", operands);
10195
10196 return (DEFAULT_ABI == ABI_V4 && flag_pic) ? \"bl %z1@local\" : \"bl %z1\";
10197 }"
10198 [(set_attr "type" "branch")
10199 (set_attr "length" "4,8")])
10200
10201
10202 (define_insn "*call_value_local64"
10203 [(set (match_operand 0 "" "")
10204 (call (mem:SI (match_operand:DI 1 "current_file_function_operand" "s,s"))
10205 (match_operand 2 "" "g,g")))
10206 (use (match_operand:SI 3 "immediate_operand" "O,n"))
10207 (clobber (match_scratch:SI 4 "=l,l"))]
10208 "TARGET_64BIT && (INTVAL (operands[3]) & CALL_LONG) == 0"
10209 "*
10210 {
10211 if (INTVAL (operands[3]) & CALL_V4_SET_FP_ARGS)
10212 output_asm_insn (\"crxor 6,6,6\", operands);
10213
10214 else if (INTVAL (operands[3]) & CALL_V4_CLEAR_FP_ARGS)
10215 output_asm_insn (\"creqv 6,6,6\", operands);
10216
10217 return (DEFAULT_ABI == ABI_V4 && flag_pic) ? \"bl %z1@local\" : \"bl %z1\";
10218 }"
10219 [(set_attr "type" "branch")
10220 (set_attr "length" "4,8")])
10221
10222 ;; Call to function which may be in another module. Restore the TOC
10223 ;; pointer (r2) after the call unless this is System V.
10224 ;; Operand2 is nonzero if we are using the V.4 calling sequence and
10225 ;; either the function was not prototyped, or it was prototyped as a
10226 ;; variable argument function. It is > 0 if FP registers were passed
10227 ;; and < 0 if they were not.
10228
10229 (define_insn "*call_indirect_nonlocal_aix32"
10230 [(call (mem:SI (match_operand:SI 0 "register_operand" "cl"))
10231 (match_operand 1 "" "g"))
10232 (use (reg:SI 2))
10233 (use (reg:SI 11))
10234 (set (reg:SI 2)
10235 (mem:SI (plus:SI (reg:SI 1) (const_int 20))))
10236 (clobber (match_scratch:SI 2 "=l"))]
10237 "TARGET_32BIT && DEFAULT_ABI == ABI_AIX"
10238 "b%T0l\;{l|lwz} 2,20(1)"
10239 [(set_attr "type" "jmpreg")
10240 (set_attr "length" "8")])
10241
10242 (define_insn "*call_nonlocal_aix32"
10243 [(call (mem:SI (match_operand:SI 0 "symbol_ref_operand" "s"))
10244 (match_operand 1 "" "g"))
10245 (use (match_operand:SI 2 "immediate_operand" "O"))
10246 (clobber (match_scratch:SI 3 "=l"))]
10247 "TARGET_32BIT
10248 && DEFAULT_ABI == ABI_AIX
10249 && (INTVAL (operands[2]) & CALL_LONG) == 0"
10250 "bl %z0\;%."
10251 [(set_attr "type" "branch")
10252 (set_attr "length" "8")])
10253
10254 (define_insn "*call_indirect_nonlocal_aix64"
10255 [(call (mem:SI (match_operand:DI 0 "register_operand" "cl"))
10256 (match_operand 1 "" "g"))
10257 (use (reg:DI 2))
10258 (use (reg:DI 11))
10259 (set (reg:DI 2)
10260 (mem:DI (plus:DI (reg:DI 1) (const_int 40))))
10261 (clobber (match_scratch:SI 2 "=l"))]
10262 "TARGET_64BIT && DEFAULT_ABI == ABI_AIX"
10263 "b%T0l\;ld 2,40(1)"
10264 [(set_attr "type" "jmpreg")
10265 (set_attr "length" "8")])
10266
10267 (define_insn "*call_nonlocal_aix64"
10268 [(call (mem:SI (match_operand:DI 0 "symbol_ref_operand" "s"))
10269 (match_operand 1 "" "g"))
10270 (use (match_operand:SI 2 "immediate_operand" "O"))
10271 (clobber (match_scratch:SI 3 "=l"))]
10272 "TARGET_64BIT
10273 && DEFAULT_ABI == ABI_AIX
10274 && (INTVAL (operands[2]) & CALL_LONG) == 0"
10275 "bl %z0\;%."
10276 [(set_attr "type" "branch")
10277 (set_attr "length" "8")])
10278
10279 (define_insn "*call_value_indirect_nonlocal_aix32"
10280 [(set (match_operand 0 "" "")
10281 (call (mem:SI (match_operand:SI 1 "register_operand" "cl"))
10282 (match_operand 2 "" "g")))
10283 (use (reg:SI 2))
10284 (use (reg:SI 11))
10285 (set (reg:SI 2)
10286 (mem:SI (plus:SI (reg:SI 1) (const_int 20))))
10287 (clobber (match_scratch:SI 3 "=l"))]
10288 "TARGET_32BIT && DEFAULT_ABI == ABI_AIX"
10289 "b%T1l\;{l|lwz} 2,20(1)"
10290 [(set_attr "type" "jmpreg")
10291 (set_attr "length" "8")])
10292
10293 (define_insn "*call_value_nonlocal_aix32"
10294 [(set (match_operand 0 "" "")
10295 (call (mem:SI (match_operand:SI 1 "symbol_ref_operand" "s"))
10296 (match_operand 2 "" "g")))
10297 (use (match_operand:SI 3 "immediate_operand" "O"))
10298 (clobber (match_scratch:SI 4 "=l"))]
10299 "TARGET_32BIT
10300 && DEFAULT_ABI == ABI_AIX
10301 && (INTVAL (operands[3]) & CALL_LONG) == 0"
10302 "bl %z1\;%."
10303 [(set_attr "type" "branch")
10304 (set_attr "length" "8")])
10305
10306 (define_insn "*call_value_indirect_nonlocal_aix64"
10307 [(set (match_operand 0 "" "")
10308 (call (mem:SI (match_operand:DI 1 "register_operand" "cl"))
10309 (match_operand 2 "" "g")))
10310 (use (reg:DI 2))
10311 (use (reg:DI 11))
10312 (set (reg:DI 2)
10313 (mem:DI (plus:DI (reg:DI 1) (const_int 40))))
10314 (clobber (match_scratch:SI 3 "=l"))]
10315 "TARGET_64BIT && DEFAULT_ABI == ABI_AIX"
10316 "b%T1l\;ld 2,40(1)"
10317 [(set_attr "type" "jmpreg")
10318 (set_attr "length" "8")])
10319
10320 (define_insn "*call_value_nonlocal_aix64"
10321 [(set (match_operand 0 "" "")
10322 (call (mem:SI (match_operand:DI 1 "symbol_ref_operand" "s"))
10323 (match_operand 2 "" "g")))
10324 (use (match_operand:SI 3 "immediate_operand" "O"))
10325 (clobber (match_scratch:SI 4 "=l"))]
10326 "TARGET_64BIT
10327 && DEFAULT_ABI == ABI_AIX
10328 && (INTVAL (operands[3]) & CALL_LONG) == 0"
10329 "bl %z1\;%."
10330 [(set_attr "type" "branch")
10331 (set_attr "length" "8")])
10332
10333 ;; A function pointer under System V is just a normal pointer
10334 ;; operands[0] is the function pointer
10335 ;; operands[1] is the stack size to clean up
10336 ;; operands[2] is the value FUNCTION_ARG returns for the VOID argument
10337 ;; which indicates how to set cr1
10338
10339 (define_insn "*call_indirect_nonlocal_sysv"
10340 [(call (mem:SI (match_operand:SI 0 "register_operand" "cl,cl"))
10341 (match_operand 1 "" "g,g"))
10342 (use (match_operand:SI 2 "immediate_operand" "O,n"))
10343 (clobber (match_scratch:SI 3 "=l,l"))]
10344 "DEFAULT_ABI == ABI_V4
10345 || DEFAULT_ABI == ABI_DARWIN"
10346 {
10347 if (INTVAL (operands[2]) & CALL_V4_SET_FP_ARGS)
10348 output_asm_insn ("crxor 6,6,6", operands);
10349
10350 else if (INTVAL (operands[2]) & CALL_V4_CLEAR_FP_ARGS)
10351 output_asm_insn ("creqv 6,6,6", operands);
10352
10353 return "b%T0l";
10354 }
10355 [(set_attr "type" "jmpreg,jmpreg")
10356 (set_attr "length" "4,8")])
10357
10358 (define_insn "*call_nonlocal_sysv"
10359 [(call (mem:SI (match_operand:SI 0 "symbol_ref_operand" "s,s"))
10360 (match_operand 1 "" "g,g"))
10361 (use (match_operand:SI 2 "immediate_operand" "O,n"))
10362 (clobber (match_scratch:SI 3 "=l,l"))]
10363 "(DEFAULT_ABI == ABI_V4
10364 || DEFAULT_ABI == ABI_DARWIN)
10365 && (INTVAL (operands[2]) & CALL_LONG) == 0"
10366 {
10367 if (INTVAL (operands[2]) & CALL_V4_SET_FP_ARGS)
10368 output_asm_insn ("crxor 6,6,6", operands);
10369
10370 else if (INTVAL (operands[2]) & CALL_V4_CLEAR_FP_ARGS)
10371 output_asm_insn ("creqv 6,6,6", operands);
10372
10373 return (DEFAULT_ABI == ABI_V4 && flag_pic) ? "bl %z0@plt" : "bl %z0";
10374 }
10375 [(set_attr "type" "branch,branch")
10376 (set_attr "length" "4,8")])
10377
10378 (define_insn "*call_value_indirect_nonlocal_sysv"
10379 [(set (match_operand 0 "" "")
10380 (call (mem:SI (match_operand:SI 1 "register_operand" "cl,cl"))
10381 (match_operand 2 "" "g,g")))
10382 (use (match_operand:SI 3 "immediate_operand" "O,n"))
10383 (clobber (match_scratch:SI 4 "=l,l"))]
10384 "DEFAULT_ABI == ABI_V4
10385 || DEFAULT_ABI == ABI_DARWIN"
10386 {
10387 if (INTVAL (operands[3]) & CALL_V4_SET_FP_ARGS)
10388 output_asm_insn ("crxor 6,6,6", operands);
10389
10390 else if (INTVAL (operands[3]) & CALL_V4_CLEAR_FP_ARGS)
10391 output_asm_insn ("creqv 6,6,6", operands);
10392
10393 return "b%T1l";
10394 }
10395 [(set_attr "type" "jmpreg,jmpreg")
10396 (set_attr "length" "4,8")])
10397
10398 (define_insn "*call_value_nonlocal_sysv"
10399 [(set (match_operand 0 "" "")
10400 (call (mem:SI (match_operand:SI 1 "symbol_ref_operand" "s,s"))
10401 (match_operand 2 "" "g,g")))
10402 (use (match_operand:SI 3 "immediate_operand" "O,n"))
10403 (clobber (match_scratch:SI 4 "=l,l"))]
10404 "(DEFAULT_ABI == ABI_V4
10405 || DEFAULT_ABI == ABI_DARWIN)
10406 && (INTVAL (operands[3]) & CALL_LONG) == 0"
10407 {
10408 if (INTVAL (operands[3]) & CALL_V4_SET_FP_ARGS)
10409 output_asm_insn ("crxor 6,6,6", operands);
10410
10411 else if (INTVAL (operands[3]) & CALL_V4_CLEAR_FP_ARGS)
10412 output_asm_insn ("creqv 6,6,6", operands);
10413
10414 return (DEFAULT_ABI == ABI_V4 && flag_pic) ? "bl %z1@plt" : "bl %z1";
10415 }
10416 [(set_attr "type" "branch,branch")
10417 (set_attr "length" "4,8")])
10418
10419 ;; Call subroutine returning any type.
10420 (define_expand "untyped_call"
10421 [(parallel [(call (match_operand 0 "" "")
10422 (const_int 0))
10423 (match_operand 1 "" "")
10424 (match_operand 2 "" "")])]
10425 ""
10426 "
10427 {
10428 int i;
10429
10430 emit_call_insn (GEN_CALL (operands[0], const0_rtx, const0_rtx, const0_rtx));
10431
10432 for (i = 0; i < XVECLEN (operands[2], 0); i++)
10433 {
10434 rtx set = XVECEXP (operands[2], 0, i);
10435 emit_move_insn (SET_DEST (set), SET_SRC (set));
10436 }
10437
10438 /* The optimizer does not know that the call sets the function value
10439 registers we stored in the result block. We avoid problems by
10440 claiming that all hard registers are used and clobbered at this
10441 point. */
10442 emit_insn (gen_blockage ());
10443
10444 DONE;
10445 }")
10446
10447 ;; sibling call patterns
10448 (define_expand "sibcall"
10449 [(parallel [(call (mem:SI (match_operand 0 "address_operand" ""))
10450 (match_operand 1 "" ""))
10451 (use (match_operand 2 "" ""))
10452 (use (match_operand 3 "" ""))
10453 (return)])]
10454 ""
10455 "
10456 {
10457 #if TARGET_MACHO
10458 if (MACHOPIC_INDIRECT)
10459 operands[0] = machopic_indirect_call_target (operands[0]);
10460 #endif
10461
10462 if (GET_CODE (operands[0]) != MEM || GET_CODE (operands[1]) != CONST_INT)
10463 abort ();
10464
10465 operands[0] = XEXP (operands[0], 0);
10466 operands[3] = gen_reg_rtx (SImode);
10467
10468 }")
10469
10470 ;; this and similar patterns must be marked as using LR, otherwise
10471 ;; dataflow will try to delete the store into it. This is true
10472 ;; even when the actual reg to jump to is in CTR, when LR was
10473 ;; saved and restored around the PIC-setting BCL.
10474 (define_insn "*sibcall_local32"
10475 [(call (mem:SI (match_operand:SI 0 "current_file_function_operand" "s,s"))
10476 (match_operand 1 "" "g,g"))
10477 (use (match_operand:SI 2 "immediate_operand" "O,n"))
10478 (use (match_operand:SI 3 "register_operand" "l,l"))
10479 (return)]
10480 "(INTVAL (operands[2]) & CALL_LONG) == 0"
10481 "*
10482 {
10483 if (INTVAL (operands[2]) & CALL_V4_SET_FP_ARGS)
10484 output_asm_insn (\"crxor 6,6,6\", operands);
10485
10486 else if (INTVAL (operands[2]) & CALL_V4_CLEAR_FP_ARGS)
10487 output_asm_insn (\"creqv 6,6,6\", operands);
10488
10489 return (DEFAULT_ABI == ABI_V4 && flag_pic) ? \"b %z0@local\" : \"b %z0\";
10490 }"
10491 [(set_attr "type" "branch")
10492 (set_attr "length" "4,8")])
10493
10494 (define_insn "*sibcall_local64"
10495 [(call (mem:SI (match_operand:DI 0 "current_file_function_operand" "s,s"))
10496 (match_operand 1 "" "g,g"))
10497 (use (match_operand:SI 2 "immediate_operand" "O,n"))
10498 (use (match_operand:SI 3 "register_operand" "l,l"))
10499 (return)]
10500 "TARGET_64BIT && (INTVAL (operands[2]) & CALL_LONG) == 0"
10501 "*
10502 {
10503 if (INTVAL (operands[2]) & CALL_V4_SET_FP_ARGS)
10504 output_asm_insn (\"crxor 6,6,6\", operands);
10505
10506 else if (INTVAL (operands[2]) & CALL_V4_CLEAR_FP_ARGS)
10507 output_asm_insn (\"creqv 6,6,6\", operands);
10508
10509 return (DEFAULT_ABI == ABI_V4 && flag_pic) ? \"b %z0@local\" : \"b %z0\";
10510 }"
10511 [(set_attr "type" "branch")
10512 (set_attr "length" "4,8")])
10513
10514 (define_insn "*sibcall_value_local32"
10515 [(set (match_operand 0 "" "")
10516 (call (mem:SI (match_operand:SI 1 "current_file_function_operand" "s,s"))
10517 (match_operand 2 "" "g,g")))
10518 (use (match_operand:SI 3 "immediate_operand" "O,n"))
10519 (use (match_operand:SI 4 "register_operand" "l,l"))
10520 (return)]
10521 "(INTVAL (operands[3]) & CALL_LONG) == 0"
10522 "*
10523 {
10524 if (INTVAL (operands[3]) & CALL_V4_SET_FP_ARGS)
10525 output_asm_insn (\"crxor 6,6,6\", operands);
10526
10527 else if (INTVAL (operands[3]) & CALL_V4_CLEAR_FP_ARGS)
10528 output_asm_insn (\"creqv 6,6,6\", operands);
10529
10530 return (DEFAULT_ABI == ABI_V4 && flag_pic) ? \"b %z1@local\" : \"b %z1\";
10531 }"
10532 [(set_attr "type" "branch")
10533 (set_attr "length" "4,8")])
10534
10535
10536 (define_insn "*sibcall_value_local64"
10537 [(set (match_operand 0 "" "")
10538 (call (mem:SI (match_operand:DI 1 "current_file_function_operand" "s,s"))
10539 (match_operand 2 "" "g,g")))
10540 (use (match_operand:SI 3 "immediate_operand" "O,n"))
10541 (use (match_operand:SI 4 "register_operand" "l,l"))
10542 (return)]
10543 "TARGET_64BIT && (INTVAL (operands[3]) & CALL_LONG) == 0"
10544 "*
10545 {
10546 if (INTVAL (operands[3]) & CALL_V4_SET_FP_ARGS)
10547 output_asm_insn (\"crxor 6,6,6\", operands);
10548
10549 else if (INTVAL (operands[3]) & CALL_V4_CLEAR_FP_ARGS)
10550 output_asm_insn (\"creqv 6,6,6\", operands);
10551
10552 return (DEFAULT_ABI == ABI_V4 && flag_pic) ? \"b %z1@local\" : \"b %z1\";
10553 }"
10554 [(set_attr "type" "branch")
10555 (set_attr "length" "4,8")])
10556
10557 (define_insn "*sibcall_nonlocal_aix32"
10558 [(call (mem:SI (match_operand:SI 0 "symbol_ref_operand" "s"))
10559 (match_operand 1 "" "g"))
10560 (use (match_operand:SI 2 "immediate_operand" "O"))
10561 (use (match_operand:SI 3 "register_operand" "l"))
10562 (return)]
10563 "TARGET_32BIT
10564 && DEFAULT_ABI == ABI_AIX
10565 && (INTVAL (operands[2]) & CALL_LONG) == 0"
10566 "b %z0"
10567 [(set_attr "type" "branch")
10568 (set_attr "length" "4")])
10569
10570 (define_insn "*sibcall_nonlocal_aix64"
10571 [(call (mem:SI (match_operand:DI 0 "symbol_ref_operand" "s"))
10572 (match_operand 1 "" "g"))
10573 (use (match_operand:SI 2 "immediate_operand" "O"))
10574 (use (match_operand:SI 3 "register_operand" "l"))
10575 (return)]
10576 "TARGET_64BIT
10577 && DEFAULT_ABI == ABI_AIX
10578 && (INTVAL (operands[2]) & CALL_LONG) == 0"
10579 "b %z0"
10580 [(set_attr "type" "branch")
10581 (set_attr "length" "4")])
10582
10583 (define_insn "*sibcall_value_nonlocal_aix32"
10584 [(set (match_operand 0 "" "")
10585 (call (mem:SI (match_operand:SI 1 "symbol_ref_operand" "s"))
10586 (match_operand 2 "" "g")))
10587 (use (match_operand:SI 3 "immediate_operand" "O"))
10588 (use (match_operand:SI 4 "register_operand" "l"))
10589 (return)]
10590 "TARGET_32BIT
10591 && DEFAULT_ABI == ABI_AIX
10592 && (INTVAL (operands[3]) & CALL_LONG) == 0"
10593 "b %z1"
10594 [(set_attr "type" "branch")
10595 (set_attr "length" "4")])
10596
10597 (define_insn "*sibcall_value_nonlocal_aix64"
10598 [(set (match_operand 0 "" "")
10599 (call (mem:SI (match_operand:DI 1 "symbol_ref_operand" "s"))
10600 (match_operand 2 "" "g")))
10601 (use (match_operand:SI 3 "immediate_operand" "O"))
10602 (use (match_operand:SI 4 "register_operand" "l"))
10603 (return)]
10604 "TARGET_64BIT
10605 && DEFAULT_ABI == ABI_AIX
10606 && (INTVAL (operands[3]) & CALL_LONG) == 0"
10607 "b %z1"
10608 [(set_attr "type" "branch")
10609 (set_attr "length" "4")])
10610
10611 (define_insn "*sibcall_nonlocal_sysv"
10612 [(call (mem:SI (match_operand:SI 0 "symbol_ref_operand" "s,s"))
10613 (match_operand 1 "" ""))
10614 (use (match_operand 2 "immediate_operand" "O,n"))
10615 (use (match_operand:SI 3 "register_operand" "l,l"))
10616 (return)]
10617 "(DEFAULT_ABI == ABI_DARWIN
10618 || DEFAULT_ABI == ABI_V4)
10619 && (INTVAL (operands[2]) & CALL_LONG) == 0"
10620 "*
10621 {
10622 if (INTVAL (operands[2]) & CALL_V4_SET_FP_ARGS)
10623 output_asm_insn (\"crxor 6,6,6\", operands);
10624
10625 else if (INTVAL (operands[2]) & CALL_V4_CLEAR_FP_ARGS)
10626 output_asm_insn (\"creqv 6,6,6\", operands);
10627
10628 return (DEFAULT_ABI == ABI_V4 && flag_pic) ? \"b %z0@plt\" : \"b %z0\";
10629 }"
10630 [(set_attr "type" "branch,branch")
10631 (set_attr "length" "4,8")])
10632
10633 (define_expand "sibcall_value"
10634 [(parallel [(set (match_operand 0 "register_operand" "")
10635 (call (mem:SI (match_operand 1 "address_operand" ""))
10636 (match_operand 2 "" "")))
10637 (use (match_operand 3 "" ""))
10638 (use (match_operand 4 "" ""))
10639 (return)])]
10640 ""
10641 "
10642 {
10643 #if TARGET_MACHO
10644 if (MACHOPIC_INDIRECT)
10645 operands[1] = machopic_indirect_call_target (operands[1]);
10646 #endif
10647
10648 if (GET_CODE (operands[1]) != MEM || GET_CODE (operands[2]) != CONST_INT)
10649 abort ();
10650
10651 operands[1] = XEXP (operands[1], 0);
10652 operands[4] = gen_reg_rtx (SImode);
10653
10654 }")
10655
10656 (define_insn "*sibcall_value_nonlocal_sysv"
10657 [(set (match_operand 0 "" "")
10658 (call (mem:SI (match_operand:SI 1 "symbol_ref_operand" "s,s"))
10659 (match_operand 2 "" "")))
10660 (use (match_operand:SI 3 "immediate_operand" "O,n"))
10661 (use (match_operand:SI 4 "register_operand" "l,l"))
10662 (return)]
10663 "(DEFAULT_ABI == ABI_DARWIN
10664 || DEFAULT_ABI == ABI_V4)
10665 && (INTVAL (operands[3]) & CALL_LONG) == 0"
10666 "*
10667 {
10668 if (INTVAL (operands[2]) & CALL_V4_SET_FP_ARGS)
10669 output_asm_insn (\"crxor 6,6,6\", operands);
10670
10671 else if (INTVAL (operands[2]) & CALL_V4_CLEAR_FP_ARGS)
10672 output_asm_insn (\"creqv 6,6,6\", operands);
10673
10674 return (DEFAULT_ABI == ABI_V4 && flag_pic) ? \"b %z1@plt\" : \"b %z1\";
10675 }"
10676 [(set_attr "type" "branch,branch")
10677 (set_attr "length" "4,8")])
10678
10679 (define_expand "sibcall_epilogue"
10680 [(use (const_int 0))]
10681 "TARGET_SCHED_PROLOG"
10682 "
10683 {
10684 rs6000_emit_epilogue (TRUE);
10685 DONE;
10686 }")
10687
10688 ;; UNSPEC_VOLATILE is considered to use and clobber all hard registers and
10689 ;; all of memory. This blocks insns from being moved across this point.
10690
10691 (define_insn "blockage"
10692 [(unspec_volatile [(const_int 0)] 0)]
10693 ""
10694 "")
10695 \f
10696 ;; Compare insns are next. Note that the RS/6000 has two types of compares,
10697 ;; signed & unsigned, and one type of branch.
10698 ;;
10699 ;; Start with the DEFINE_EXPANDs to generate the rtl for compares, scc
10700 ;; insns, and branches. We store the operands of compares until we see
10701 ;; how it is used.
10702 (define_expand "cmpsi"
10703 [(set (cc0)
10704 (compare (match_operand:SI 0 "gpc_reg_operand" "")
10705 (match_operand:SI 1 "reg_or_short_operand" "")))]
10706 ""
10707 "
10708 {
10709 /* Take care of the possibility that operands[1] might be negative but
10710 this might be a logical operation. That insn doesn't exist. */
10711 if (GET_CODE (operands[1]) == CONST_INT
10712 && INTVAL (operands[1]) < 0)
10713 operands[1] = force_reg (SImode, operands[1]);
10714
10715 rs6000_compare_op0 = operands[0];
10716 rs6000_compare_op1 = operands[1];
10717 rs6000_compare_fp_p = 0;
10718 DONE;
10719 }")
10720
10721 (define_expand "cmpdi"
10722 [(set (cc0)
10723 (compare (match_operand:DI 0 "gpc_reg_operand" "")
10724 (match_operand:DI 1 "reg_or_short_operand" "")))]
10725 "TARGET_POWERPC64"
10726 "
10727 {
10728 /* Take care of the possibility that operands[1] might be negative but
10729 this might be a logical operation. That insn doesn't exist. */
10730 if (GET_CODE (operands[1]) == CONST_INT
10731 && INTVAL (operands[1]) < 0)
10732 operands[1] = force_reg (DImode, operands[1]);
10733
10734 rs6000_compare_op0 = operands[0];
10735 rs6000_compare_op1 = operands[1];
10736 rs6000_compare_fp_p = 0;
10737 DONE;
10738 }")
10739
10740 (define_expand "cmpsf"
10741 [(set (cc0) (compare (match_operand:SF 0 "gpc_reg_operand" "")
10742 (match_operand:SF 1 "gpc_reg_operand" "")))]
10743 "TARGET_HARD_FLOAT"
10744 "
10745 {
10746 rs6000_compare_op0 = operands[0];
10747 rs6000_compare_op1 = operands[1];
10748 rs6000_compare_fp_p = 1;
10749 DONE;
10750 }")
10751
10752 (define_expand "cmpdf"
10753 [(set (cc0) (compare (match_operand:DF 0 "gpc_reg_operand" "")
10754 (match_operand:DF 1 "gpc_reg_operand" "")))]
10755 "TARGET_HARD_FLOAT && TARGET_FPRS"
10756 "
10757 {
10758 rs6000_compare_op0 = operands[0];
10759 rs6000_compare_op1 = operands[1];
10760 rs6000_compare_fp_p = 1;
10761 DONE;
10762 }")
10763
10764 (define_expand "cmptf"
10765 [(set (cc0) (compare (match_operand:TF 0 "gpc_reg_operand" "")
10766 (match_operand:TF 1 "gpc_reg_operand" "")))]
10767 "DEFAULT_ABI == ABI_AIX && TARGET_HARD_FLOAT
10768 && TARGET_FPRS && TARGET_LONG_DOUBLE_128"
10769 "
10770 {
10771 rs6000_compare_op0 = operands[0];
10772 rs6000_compare_op1 = operands[1];
10773 rs6000_compare_fp_p = 1;
10774 DONE;
10775 }")
10776
10777 (define_expand "beq"
10778 [(use (match_operand 0 "" ""))]
10779 ""
10780 "{ rs6000_emit_cbranch (EQ, operands[0]); DONE; }")
10781
10782 (define_expand "bne"
10783 [(use (match_operand 0 "" ""))]
10784 ""
10785 "{ rs6000_emit_cbranch (NE, operands[0]); DONE; }")
10786
10787 (define_expand "bge"
10788 [(use (match_operand 0 "" ""))]
10789 ""
10790 "{ rs6000_emit_cbranch (GE, operands[0]); DONE; }")
10791
10792 (define_expand "bgt"
10793 [(use (match_operand 0 "" ""))]
10794 ""
10795 "{ rs6000_emit_cbranch (GT, operands[0]); DONE; }")
10796
10797 (define_expand "ble"
10798 [(use (match_operand 0 "" ""))]
10799 ""
10800 "{ rs6000_emit_cbranch (LE, operands[0]); DONE; }")
10801
10802 (define_expand "blt"
10803 [(use (match_operand 0 "" ""))]
10804 ""
10805 "{ rs6000_emit_cbranch (LT, operands[0]); DONE; }")
10806
10807 (define_expand "bgeu"
10808 [(use (match_operand 0 "" ""))]
10809 ""
10810 "{ rs6000_emit_cbranch (GEU, operands[0]); DONE; }")
10811
10812 (define_expand "bgtu"
10813 [(use (match_operand 0 "" ""))]
10814 ""
10815 "{ rs6000_emit_cbranch (GTU, operands[0]); DONE; }")
10816
10817 (define_expand "bleu"
10818 [(use (match_operand 0 "" ""))]
10819 ""
10820 "{ rs6000_emit_cbranch (LEU, operands[0]); DONE; }")
10821
10822 (define_expand "bltu"
10823 [(use (match_operand 0 "" ""))]
10824 ""
10825 "{ rs6000_emit_cbranch (LTU, operands[0]); DONE; }")
10826
10827 (define_expand "bunordered"
10828 [(use (match_operand 0 "" ""))]
10829 ""
10830 "{ rs6000_emit_cbranch (UNORDERED, operands[0]); DONE; }")
10831
10832 (define_expand "bordered"
10833 [(use (match_operand 0 "" ""))]
10834 ""
10835 "{ rs6000_emit_cbranch (ORDERED, operands[0]); DONE; }")
10836
10837 (define_expand "buneq"
10838 [(use (match_operand 0 "" ""))]
10839 ""
10840 "{ rs6000_emit_cbranch (UNEQ, operands[0]); DONE; }")
10841
10842 (define_expand "bunge"
10843 [(use (match_operand 0 "" ""))]
10844 ""
10845 "{ rs6000_emit_cbranch (UNGE, operands[0]); DONE; }")
10846
10847 (define_expand "bungt"
10848 [(use (match_operand 0 "" ""))]
10849 ""
10850 "{ rs6000_emit_cbranch (UNGT, operands[0]); DONE; }")
10851
10852 (define_expand "bunle"
10853 [(use (match_operand 0 "" ""))]
10854 ""
10855 "{ rs6000_emit_cbranch (UNLE, operands[0]); DONE; }")
10856
10857 (define_expand "bunlt"
10858 [(use (match_operand 0 "" ""))]
10859 ""
10860 "{ rs6000_emit_cbranch (UNLT, operands[0]); DONE; }")
10861
10862 (define_expand "bltgt"
10863 [(use (match_operand 0 "" ""))]
10864 ""
10865 "{ rs6000_emit_cbranch (LTGT, operands[0]); DONE; }")
10866
10867 ;; For SNE, we would prefer that the xor/abs sequence be used for integers.
10868 ;; For SEQ, likewise, except that comparisons with zero should be done
10869 ;; with an scc insns. However, due to the order that combine see the
10870 ;; resulting insns, we must, in fact, allow SEQ for integers. Fail in
10871 ;; the cases we don't want to handle.
10872 (define_expand "seq"
10873 [(clobber (match_operand:SI 0 "gpc_reg_operand" ""))]
10874 ""
10875 "{ rs6000_emit_sCOND (EQ, operands[0]); DONE; }")
10876
10877 (define_expand "sne"
10878 [(clobber (match_operand:SI 0 "gpc_reg_operand" ""))]
10879 ""
10880 "
10881 {
10882 if (! rs6000_compare_fp_p)
10883 FAIL;
10884
10885 rs6000_emit_sCOND (NE, operands[0]);
10886 DONE;
10887 }")
10888
10889 ;; A > 0 is best done using the portable sequence, so fail in that case.
10890 (define_expand "sgt"
10891 [(clobber (match_operand:SI 0 "gpc_reg_operand" ""))]
10892 ""
10893 "
10894 {
10895 if (! rs6000_compare_fp_p
10896 && (! TARGET_POWER || rs6000_compare_op1 == const0_rtx))
10897 FAIL;
10898
10899 rs6000_emit_sCOND (GT, operands[0]);
10900 DONE;
10901 }")
10902
10903 ;; A < 0 is best done in the portable way for A an integer.
10904 (define_expand "slt"
10905 [(clobber (match_operand:SI 0 "gpc_reg_operand" ""))]
10906 ""
10907 "
10908 {
10909 if (! rs6000_compare_fp_p
10910 && (! TARGET_POWER || rs6000_compare_op1 == const0_rtx))
10911 FAIL;
10912
10913 rs6000_emit_sCOND (LT, operands[0]);
10914 DONE;
10915 }")
10916
10917 ;; A >= 0 is best done the portable way for A an integer.
10918 (define_expand "sge"
10919 [(clobber (match_operand:SI 0 "gpc_reg_operand" ""))]
10920 ""
10921 "
10922 {
10923 if (! rs6000_compare_fp_p
10924 && (! TARGET_POWER || rs6000_compare_op1 == const0_rtx))
10925 FAIL;
10926
10927 rs6000_emit_sCOND (GE, operands[0]);
10928 DONE;
10929 }")
10930
10931 ;; A <= 0 is best done the portable way for A an integer.
10932 (define_expand "sle"
10933 [(clobber (match_operand:SI 0 "gpc_reg_operand" ""))]
10934 ""
10935 "
10936 {
10937 if (! rs6000_compare_fp_p
10938 && (! TARGET_POWER || rs6000_compare_op1 == const0_rtx))
10939 FAIL;
10940
10941 rs6000_emit_sCOND (LE, operands[0]);
10942 DONE;
10943 }")
10944
10945 (define_expand "sgtu"
10946 [(clobber (match_operand:SI 0 "gpc_reg_operand" ""))]
10947 ""
10948 "{ rs6000_emit_sCOND (GTU, operands[0]); DONE; }")
10949
10950 (define_expand "sltu"
10951 [(clobber (match_operand:SI 0 "gpc_reg_operand" ""))]
10952 ""
10953 "{ rs6000_emit_sCOND (LTU, operands[0]); DONE; }")
10954
10955 (define_expand "sgeu"
10956 [(clobber (match_operand:SI 0 "gpc_reg_operand" ""))]
10957 ""
10958 "{ rs6000_emit_sCOND (GEU, operands[0]); DONE; }")
10959
10960 (define_expand "sleu"
10961 [(clobber (match_operand:SI 0 "gpc_reg_operand" ""))]
10962 ""
10963 "{ rs6000_emit_sCOND (LEU, operands[0]); DONE; }")
10964 \f
10965 ;; Here are the actual compare insns.
10966 (define_insn "*cmpsi_internal1"
10967 [(set (match_operand:CC 0 "cc_reg_operand" "=y")
10968 (compare:CC (match_operand:SI 1 "gpc_reg_operand" "r")
10969 (match_operand:SI 2 "reg_or_short_operand" "rI")))]
10970 ""
10971 "{cmp%I2|cmpw%I2} %0,%1,%2"
10972 [(set_attr "type" "cmp")])
10973
10974 (define_insn "*cmpdi_internal1"
10975 [(set (match_operand:CC 0 "cc_reg_operand" "=y")
10976 (compare:CC (match_operand:DI 1 "gpc_reg_operand" "r")
10977 (match_operand:DI 2 "reg_or_short_operand" "rI")))]
10978 "TARGET_POWERPC64"
10979 "cmpd%I2 %0,%1,%2"
10980 [(set_attr "type" "cmp")])
10981
10982 ;; If we are comparing a register for equality with a large constant,
10983 ;; we can do this with an XOR followed by a compare. But we need a scratch
10984 ;; register for the result of the XOR.
10985
10986 (define_split
10987 [(set (match_operand:CC 0 "cc_reg_operand" "")
10988 (compare:CC (match_operand:SI 1 "gpc_reg_operand" "")
10989 (match_operand:SI 2 "non_short_cint_operand" "")))
10990 (clobber (match_operand:SI 3 "gpc_reg_operand" ""))]
10991 "find_single_use (operands[0], insn, 0)
10992 && (GET_CODE (*find_single_use (operands[0], insn, 0)) == EQ
10993 || GET_CODE (*find_single_use (operands[0], insn, 0)) == NE)"
10994 [(set (match_dup 3) (xor:SI (match_dup 1) (match_dup 4)))
10995 (set (match_dup 0) (compare:CC (match_dup 3) (match_dup 5)))]
10996 "
10997 {
10998 /* Get the constant we are comparing against, C, and see what it looks like
10999 sign-extended to 16 bits. Then see what constant could be XOR'ed
11000 with C to get the sign-extended value. */
11001
11002 HOST_WIDE_INT c = INTVAL (operands[2]);
11003 HOST_WIDE_INT sextc = ((c & 0xffff) ^ 0x8000) - 0x8000;
11004 HOST_WIDE_INT xorv = c ^ sextc;
11005
11006 operands[4] = GEN_INT (xorv);
11007 operands[5] = GEN_INT (sextc);
11008 }")
11009
11010 (define_insn "*cmpsi_internal2"
11011 [(set (match_operand:CCUNS 0 "cc_reg_operand" "=y")
11012 (compare:CCUNS (match_operand:SI 1 "gpc_reg_operand" "r")
11013 (match_operand:SI 2 "reg_or_u_short_operand" "rK")))]
11014 ""
11015 "{cmpl%I2|cmplw%I2} %0,%1,%b2"
11016 [(set_attr "type" "cmp")])
11017
11018 (define_insn "*cmpdi_internal2"
11019 [(set (match_operand:CCUNS 0 "cc_reg_operand" "=y")
11020 (compare:CCUNS (match_operand:DI 1 "gpc_reg_operand" "r")
11021 (match_operand:DI 2 "reg_or_u_short_operand" "rK")))]
11022 ""
11023 "cmpld%I2 %0,%1,%b2"
11024 [(set_attr "type" "cmp")])
11025
11026 ;; The following two insns don't exist as single insns, but if we provide
11027 ;; them, we can swap an add and compare, which will enable us to overlap more
11028 ;; of the required delay between a compare and branch. We generate code for
11029 ;; them by splitting.
11030
11031 (define_insn ""
11032 [(set (match_operand:CC 3 "cc_reg_operand" "=y")
11033 (compare:CC (match_operand:SI 1 "gpc_reg_operand" "r")
11034 (match_operand:SI 2 "short_cint_operand" "i")))
11035 (set (match_operand:SI 0 "gpc_reg_operand" "=r")
11036 (plus:SI (match_dup 1) (match_operand:SI 4 "short_cint_operand" "i")))]
11037 ""
11038 "#"
11039 [(set_attr "length" "8")])
11040
11041 (define_insn ""
11042 [(set (match_operand:CCUNS 3 "cc_reg_operand" "=y")
11043 (compare:CCUNS (match_operand:SI 1 "gpc_reg_operand" "r")
11044 (match_operand:SI 2 "u_short_cint_operand" "i")))
11045 (set (match_operand:SI 0 "gpc_reg_operand" "=r")
11046 (plus:SI (match_dup 1) (match_operand:SI 4 "short_cint_operand" "i")))]
11047 ""
11048 "#"
11049 [(set_attr "length" "8")])
11050
11051 (define_split
11052 [(set (match_operand:CC 3 "cc_reg_operand" "")
11053 (compare:CC (match_operand:SI 1 "gpc_reg_operand" "")
11054 (match_operand:SI 2 "short_cint_operand" "")))
11055 (set (match_operand:SI 0 "gpc_reg_operand" "")
11056 (plus:SI (match_dup 1) (match_operand:SI 4 "short_cint_operand" "")))]
11057 ""
11058 [(set (match_dup 3) (compare:CC (match_dup 1) (match_dup 2)))
11059 (set (match_dup 0) (plus:SI (match_dup 1) (match_dup 4)))])
11060
11061 (define_split
11062 [(set (match_operand:CCUNS 3 "cc_reg_operand" "")
11063 (compare:CCUNS (match_operand:SI 1 "gpc_reg_operand" "")
11064 (match_operand:SI 2 "u_short_cint_operand" "")))
11065 (set (match_operand:SI 0 "gpc_reg_operand" "")
11066 (plus:SI (match_dup 1) (match_operand:SI 4 "short_cint_operand" "")))]
11067 ""
11068 [(set (match_dup 3) (compare:CCUNS (match_dup 1) (match_dup 2)))
11069 (set (match_dup 0) (plus:SI (match_dup 1) (match_dup 4)))])
11070
11071 (define_insn "*cmpsf_internal1"
11072 [(set (match_operand:CCFP 0 "cc_reg_operand" "=y")
11073 (compare:CCFP (match_operand:SF 1 "gpc_reg_operand" "f")
11074 (match_operand:SF 2 "gpc_reg_operand" "f")))]
11075 "TARGET_HARD_FLOAT && TARGET_FPRS"
11076 "fcmpu %0,%1,%2"
11077 [(set_attr "type" "fpcompare")])
11078
11079 (define_insn "*cmpdf_internal1"
11080 [(set (match_operand:CCFP 0 "cc_reg_operand" "=y")
11081 (compare:CCFP (match_operand:DF 1 "gpc_reg_operand" "f")
11082 (match_operand:DF 2 "gpc_reg_operand" "f")))]
11083 "TARGET_HARD_FLOAT && TARGET_FPRS"
11084 "fcmpu %0,%1,%2"
11085 [(set_attr "type" "fpcompare")])
11086
11087 ;; Only need to compare second words if first words equal
11088 (define_insn "*cmptf_internal1"
11089 [(set (match_operand:CCFP 0 "cc_reg_operand" "=y")
11090 (compare:CCFP (match_operand:TF 1 "gpc_reg_operand" "f")
11091 (match_operand:TF 2 "gpc_reg_operand" "f")))]
11092 "DEFAULT_ABI == ABI_AIX && TARGET_HARD_FLOAT && TARGET_FPRS
11093 && TARGET_LONG_DOUBLE_128"
11094 "fcmpu %0,%1,%2\;bne %0,$+4\;fcmpu %0,%L1,%L2"
11095 [(set_attr "type" "fpcompare")
11096 (set_attr "length" "12")])
11097 \f
11098 ;; Now we have the scc insns. We can do some combinations because of the
11099 ;; way the machine works.
11100 ;;
11101 ;; Note that this is probably faster if we can put an insn between the
11102 ;; mfcr and rlinm, but this is tricky. Let's leave it for now. In most
11103 ;; cases the insns below which don't use an intermediate CR field will
11104 ;; be used instead.
11105 (define_insn ""
11106 [(set (match_operand:SI 0 "gpc_reg_operand" "=r")
11107 (match_operator:SI 1 "scc_comparison_operator"
11108 [(match_operand 2 "cc_reg_operand" "y")
11109 (const_int 0)]))]
11110 ""
11111 "%D1mfcr %0\;{rlinm|rlwinm} %0,%0,%J1,1"
11112 [(set_attr "type" "mfcr")
11113 (set_attr "length" "12")])
11114
11115 ;; Same as above, but get the OV/ORDERED bit.
11116 (define_insn "move_from_CR_ov_bit"
11117 [(set (match_operand:SI 0 "gpc_reg_operand" "=r")
11118 (unspec:SI [(match_operand 1 "cc_reg_operand" "y")] 724))]
11119 "TARGET_ISEL"
11120 "%D1mfcr %0\;{rlinm|rlwinm} %0,%0,%t1,1"
11121 [(set_attr "type" "mfcr")
11122 (set_attr "length" "12")])
11123
11124 (define_insn ""
11125 [(set (match_operand:DI 0 "gpc_reg_operand" "=r")
11126 (match_operator:DI 1 "scc_comparison_operator"
11127 [(match_operand 2 "cc_reg_operand" "y")
11128 (const_int 0)]))]
11129 "TARGET_POWERPC64"
11130 "%D1mfcr %0\;{rlinm|rlwinm} %0,%0,%J1,1"
11131 [(set_attr "type" "mfcr")
11132 (set_attr "length" "12")])
11133
11134 (define_insn ""
11135 [(set (match_operand:CC 0 "cc_reg_operand" "=x,?y")
11136 (compare:CC (match_operator:SI 1 "scc_comparison_operator"
11137 [(match_operand 2 "cc_reg_operand" "y,y")
11138 (const_int 0)])
11139 (const_int 0)))
11140 (set (match_operand:SI 3 "gpc_reg_operand" "=r,r")
11141 (match_op_dup 1 [(match_dup 2) (const_int 0)]))]
11142 "! TARGET_POWERPC64"
11143 "@
11144 %D1mfcr %3\;{rlinm.|rlwinm.} %3,%3,%J1,1
11145 #"
11146 [(set_attr "type" "delayed_compare")
11147 (set_attr "length" "12,16")])
11148
11149 (define_split
11150 [(set (match_operand:CC 0 "cc_reg_not_cr0_operand" "")
11151 (compare:CC (match_operator:SI 1 "scc_comparison_operator"
11152 [(match_operand 2 "cc_reg_operand" "")
11153 (const_int 0)])
11154 (const_int 0)))
11155 (set (match_operand:SI 3 "gpc_reg_operand" "")
11156 (match_op_dup 1 [(match_dup 2) (const_int 0)]))]
11157 "! TARGET_POWERPC64 && reload_completed"
11158 [(set (match_dup 3)
11159 (match_op_dup 1 [(match_dup 2) (const_int 0)]))
11160 (set (match_dup 0)
11161 (compare:CC (match_dup 3)
11162 (const_int 0)))]
11163 "")
11164
11165 (define_insn ""
11166 [(set (match_operand:SI 0 "gpc_reg_operand" "=r")
11167 (ashift:SI (match_operator:SI 1 "scc_comparison_operator"
11168 [(match_operand 2 "cc_reg_operand" "y")
11169 (const_int 0)])
11170 (match_operand:SI 3 "const_int_operand" "n")))]
11171 ""
11172 "*
11173 {
11174 int is_bit = ccr_bit (operands[1], 1);
11175 int put_bit = 31 - (INTVAL (operands[3]) & 31);
11176 int count;
11177
11178 if (is_bit >= put_bit)
11179 count = is_bit - put_bit;
11180 else
11181 count = 32 - (put_bit - is_bit);
11182
11183 operands[4] = GEN_INT (count);
11184 operands[5] = GEN_INT (put_bit);
11185
11186 return \"%D1mfcr %0\;{rlinm|rlwinm} %0,%0,%4,%5,%5\";
11187 }"
11188 [(set_attr "type" "mfcr")
11189 (set_attr "length" "12")])
11190
11191 (define_insn ""
11192 [(set (match_operand:CC 0 "cc_reg_operand" "=x,?y")
11193 (compare:CC
11194 (ashift:SI (match_operator:SI 1 "scc_comparison_operator"
11195 [(match_operand 2 "cc_reg_operand" "y,y")
11196 (const_int 0)])
11197 (match_operand:SI 3 "const_int_operand" "n,n"))
11198 (const_int 0)))
11199 (set (match_operand:SI 4 "gpc_reg_operand" "=r,r")
11200 (ashift:SI (match_op_dup 1 [(match_dup 2) (const_int 0)])
11201 (match_dup 3)))]
11202 ""
11203 "*
11204 {
11205 int is_bit = ccr_bit (operands[1], 1);
11206 int put_bit = 31 - (INTVAL (operands[3]) & 31);
11207 int count;
11208
11209 /* Force split for non-cc0 compare. */
11210 if (which_alternative == 1)
11211 return \"#\";
11212
11213 if (is_bit >= put_bit)
11214 count = is_bit - put_bit;
11215 else
11216 count = 32 - (put_bit - is_bit);
11217
11218 operands[5] = GEN_INT (count);
11219 operands[6] = GEN_INT (put_bit);
11220
11221 return \"%D1mfcr %4\;{rlinm.|rlwinm.} %4,%4,%5,%6,%6\";
11222 }"
11223 [(set_attr "type" "delayed_compare")
11224 (set_attr "length" "12,16")])
11225
11226 (define_split
11227 [(set (match_operand:CC 0 "cc_reg_not_cr0_operand" "")
11228 (compare:CC
11229 (ashift:SI (match_operator:SI 1 "scc_comparison_operator"
11230 [(match_operand 2 "cc_reg_operand" "")
11231 (const_int 0)])
11232 (match_operand:SI 3 "const_int_operand" ""))
11233 (const_int 0)))
11234 (set (match_operand:SI 4 "gpc_reg_operand" "")
11235 (ashift:SI (match_op_dup 1 [(match_dup 2) (const_int 0)])
11236 (match_dup 3)))]
11237 "reload_completed"
11238 [(set (match_dup 4)
11239 (ashift:SI (match_op_dup 1 [(match_dup 2) (const_int 0)])
11240 (match_dup 3)))
11241 (set (match_dup 0)
11242 (compare:CC (match_dup 4)
11243 (const_int 0)))]
11244 "")
11245
11246 ;; There is a 3 cycle delay between consecutive mfcr instructions
11247 ;; so it is useful to combine 2 scc instructions to use only one mfcr.
11248
11249 (define_peephole
11250 [(set (match_operand:SI 0 "gpc_reg_operand" "=r")
11251 (match_operator:SI 1 "scc_comparison_operator"
11252 [(match_operand 2 "cc_reg_operand" "y")
11253 (const_int 0)]))
11254 (set (match_operand:SI 3 "gpc_reg_operand" "=r")
11255 (match_operator:SI 4 "scc_comparison_operator"
11256 [(match_operand 5 "cc_reg_operand" "y")
11257 (const_int 0)]))]
11258 "REGNO (operands[2]) != REGNO (operands[5])"
11259 "%D1%D4mfcr %3\;{rlinm|rlwinm} %0,%3,%J1,1\;{rlinm|rlwinm} %3,%3,%J4,1"
11260 [(set_attr "type" "mfcr")
11261 (set_attr "length" "20")])
11262
11263 (define_peephole
11264 [(set (match_operand:DI 0 "gpc_reg_operand" "=r")
11265 (match_operator:DI 1 "scc_comparison_operator"
11266 [(match_operand 2 "cc_reg_operand" "y")
11267 (const_int 0)]))
11268 (set (match_operand:DI 3 "gpc_reg_operand" "=r")
11269 (match_operator:DI 4 "scc_comparison_operator"
11270 [(match_operand 5 "cc_reg_operand" "y")
11271 (const_int 0)]))]
11272 "TARGET_POWERPC64 && REGNO (operands[2]) != REGNO (operands[5])"
11273 "%D1%D4mfcr %3\;{rlinm|rlwinm} %0,%3,%J1,1\;{rlinm|rlwinm} %3,%3,%J4,1"
11274 [(set_attr "type" "mfcr")
11275 (set_attr "length" "20")])
11276
11277 ;; There are some scc insns that can be done directly, without a compare.
11278 ;; These are faster because they don't involve the communications between
11279 ;; the FXU and branch units. In fact, we will be replacing all of the
11280 ;; integer scc insns here or in the portable methods in emit_store_flag.
11281 ;;
11282 ;; Also support (neg (scc ..)) since that construct is used to replace
11283 ;; branches, (plus (scc ..) ..) since that construct is common and
11284 ;; takes no more insns than scc, and (and (neg (scc ..)) ..) in the
11285 ;; cases where it is no more expensive than (neg (scc ..)).
11286
11287 ;; Have reload force a constant into a register for the simple insns that
11288 ;; otherwise won't accept constants. We do this because it is faster than
11289 ;; the cmp/mfcr sequence we would otherwise generate.
11290
11291 (define_insn ""
11292 [(set (match_operand:SI 0 "gpc_reg_operand" "=r,r,r,r,r")
11293 (eq:SI (match_operand:SI 1 "gpc_reg_operand" "%r,r,r,r,r")
11294 (match_operand:SI 2 "reg_or_cint_operand" "r,O,K,L,I")))
11295 (clobber (match_scratch:SI 3 "=r,&r,r,r,r"))]
11296 "! TARGET_POWERPC64"
11297 "@
11298 xor %0,%1,%2\;{sfi|subfic} %3,%0,0\;{ae|adde} %0,%3,%0
11299 {sfi|subfic} %3,%1,0\;{ae|adde} %0,%3,%1
11300 {xoril|xori} %0,%1,%b2\;{sfi|subfic} %3,%0,0\;{ae|adde} %0,%3,%0
11301 {xoriu|xoris} %0,%1,%u2\;{sfi|subfic} %3,%0,0\;{ae|adde} %0,%3,%0
11302 {sfi|subfic} %0,%1,%2\;{sfi|subfic} %3,%0,0\;{ae|adde} %0,%3,%0"
11303 [(set_attr "length" "12,8,12,12,12")])
11304
11305 (define_insn ""
11306 [(set (match_operand:DI 0 "gpc_reg_operand" "=r,r,r,r,r")
11307 (eq:DI (match_operand:DI 1 "gpc_reg_operand" "%r,r,r,r,r")
11308 (match_operand:DI 2 "reg_or_cint_operand" "r,O,K,J,I")))
11309 (clobber (match_scratch:DI 3 "=r,&r,r,r,r"))]
11310 "TARGET_POWERPC64"
11311 "@
11312 xor %0,%1,%2\;subfic %3,%0,0\;adde %0,%3,%0
11313 subfic %3,%1,0\;adde %0,%3,%1
11314 xori %0,%1,%b2\;subfic %3,%0,0\;adde %0,%3,%0
11315 xoris %0,%1,%u2\;subfic %3,%0,0\;adde %0,%3,%0
11316 subfic %0,%1,%2\;subfic %3,%0,0\;adde %0,%3,%0"
11317 [(set_attr "length" "12,8,12,12,12")])
11318
11319 (define_insn ""
11320 [(set (match_operand:CC 4 "cc_reg_operand" "=x,x,x,x,x,?y,?y,?y,?y,?y")
11321 (compare:CC
11322 (eq:SI (match_operand:SI 1 "gpc_reg_operand" "%r,r,r,r,r,r,r,r,r,r")
11323 (match_operand:SI 2 "reg_or_cint_operand" "r,O,K,L,I,r,O,K,L,I"))
11324 (const_int 0)))
11325 (set (match_operand:SI 0 "gpc_reg_operand" "=r,r,r,r,r,r,r,r,r,r")
11326 (eq:SI (match_dup 1) (match_dup 2)))
11327 (clobber (match_scratch:SI 3 "=r,&r,r,r,r,r,&r,r,r,r"))]
11328 "! TARGET_POWERPC64"
11329 "@
11330 xor %0,%1,%2\;{sfi|subfic} %3,%0,0\;{ae.|adde.} %0,%3,%0
11331 {sfi|subfic} %3,%1,0\;{ae.|adde.} %0,%3,%1
11332 {xoril|xori} %0,%1,%b2\;{sfi|subfic} %3,%0,0\;{ae.|adde.} %0,%3,%0
11333 {xoriu|xoris} %0,%1,%u2\;{sfi|subfic} %3,%0,0\;{ae.|adde.} %0,%3,%0
11334 {sfi|subfic} %0,%1,%2\;{sfi|subfic} %3,%0,0\;{ae.|adde.} %0,%3,%0
11335 #
11336 #
11337 #
11338 #
11339 #"
11340 [(set_attr "type" "compare")
11341 (set_attr "length" "12,8,12,12,12,16,12,16,16,16")])
11342
11343 (define_split
11344 [(set (match_operand:CC 4 "cc_reg_not_cr0_operand" "")
11345 (compare:CC
11346 (eq:SI (match_operand:SI 1 "gpc_reg_operand" "")
11347 (match_operand:SI 2 "reg_or_cint_operand" ""))
11348 (const_int 0)))
11349 (set (match_operand:SI 0 "gpc_reg_operand" "")
11350 (eq:SI (match_dup 1) (match_dup 2)))
11351 (clobber (match_scratch:SI 3 ""))]
11352 "! TARGET_POWERPC64 && reload_completed"
11353 [(parallel [(set (match_dup 0)
11354 (eq:SI (match_dup 1) (match_dup 2)))
11355 (clobber (match_dup 3))])
11356 (set (match_dup 4)
11357 (compare:CC (match_dup 0)
11358 (const_int 0)))]
11359 "")
11360
11361 (define_insn ""
11362 [(set (match_operand:CC 4 "cc_reg_operand" "=x,x,x,x,x,?y,?y,?y,?y,?y")
11363 (compare:CC
11364 (eq:DI (match_operand:DI 1 "gpc_reg_operand" "%r,r,r,r,r,r,r,r,r,r")
11365 (match_operand:DI 2 "reg_or_cint_operand" "r,O,K,J,I,r,O,K,J,I"))
11366 (const_int 0)))
11367 (set (match_operand:DI 0 "gpc_reg_operand" "=r,r,r,r,r,r,r,r,r,r")
11368 (eq:DI (match_dup 1) (match_dup 2)))
11369 (clobber (match_scratch:DI 3 "=r,&r,r,r,r,r,&r,r,r,r"))]
11370 "TARGET_POWERPC64"
11371 "@
11372 xor %0,%1,%2\;subfic %3,%0,0\;adde. %0,%3,%0
11373 subfic %3,%1,0\;adde. %0,%3,%1
11374 xori %0,%1,%b2\;subfic %3,%0,0\;adde. %0,%3,%0
11375 xoris %0,%1,%u2\;subfic %3,%0,0\;adde. %0,%3,%0
11376 subfic %0,%1,%2\;subfic %3,%0,0\;adde. %0,%3,%0
11377 #
11378 #
11379 #
11380 #
11381 #"
11382 [(set_attr "type" "compare")
11383 (set_attr "length" "12,8,12,12,12,16,12,16,16,16")])
11384
11385 (define_split
11386 [(set (match_operand:CC 4 "cc_reg_not_cr0_operand" "")
11387 (compare:CC
11388 (eq:DI (match_operand:DI 1 "gpc_reg_operand" "")
11389 (match_operand:DI 2 "reg_or_cint_operand" ""))
11390 (const_int 0)))
11391 (set (match_operand:DI 0 "gpc_reg_operand" "")
11392 (eq:DI (match_dup 1) (match_dup 2)))
11393 (clobber (match_scratch:DI 3 ""))]
11394 "TARGET_POWERPC64 && reload_completed"
11395 [(parallel [(set (match_dup 0)
11396 (eq:DI (match_dup 1) (match_dup 2)))
11397 (clobber (match_dup 3))])
11398 (set (match_dup 4)
11399 (compare:CC (match_dup 0)
11400 (const_int 0)))]
11401 "")
11402
11403 ;; We have insns of the form shown by the first define_insn below. If
11404 ;; there is something inside the comparison operation, we must split it.
11405 (define_split
11406 [(set (match_operand:SI 0 "gpc_reg_operand" "")
11407 (plus:SI (match_operator 1 "comparison_operator"
11408 [(match_operand:SI 2 "" "")
11409 (match_operand:SI 3
11410 "reg_or_cint_operand" "")])
11411 (match_operand:SI 4 "gpc_reg_operand" "")))
11412 (clobber (match_operand:SI 5 "register_operand" ""))]
11413 "! gpc_reg_operand (operands[2], SImode)"
11414 [(set (match_dup 5) (match_dup 2))
11415 (set (match_dup 2) (plus:SI (match_op_dup 1 [(match_dup 2) (match_dup 3)])
11416 (match_dup 4)))])
11417
11418 (define_insn ""
11419 [(set (match_operand:SI 0 "gpc_reg_operand" "=&r,&r,&r,&r,&r")
11420 (plus:SI (eq:SI (match_operand:SI 1 "gpc_reg_operand" "%r,r,r,r,r")
11421 (match_operand:SI 2 "reg_or_cint_operand" "r,O,K,L,I"))
11422 (match_operand:SI 3 "gpc_reg_operand" "r,r,r,r,r")))]
11423 "! TARGET_POWERPC64"
11424 "@
11425 xor %0,%1,%2\;{sfi|subfic} %0,%0,0\;{aze|addze} %0,%3
11426 {sfi|subfic} %0,%1,0\;{aze|addze} %0,%3
11427 {xoril|xori} %0,%1,%b2\;{sfi|subfic} %0,%0,0\;{aze|addze} %0,%3
11428 {xoriu|xoris} %0,%1,%u2\;{sfi|subfic} %0,%0,0\;{aze|addze} %0,%3
11429 {sfi|subfic} %0,%1,%2\;{sfi|subfic} %0,%0,0\;{aze|addze} %0,%3"
11430 [(set_attr "length" "12,8,12,12,12")])
11431
11432 (define_insn ""
11433 [(set (match_operand:CC 0 "cc_reg_operand" "=x,x,x,x,x,?y,?y,?y,?y,?y")
11434 (compare:CC
11435 (plus:SI
11436 (eq:SI (match_operand:SI 1 "gpc_reg_operand" "%r,r,r,r,r,r,r,r,r,r")
11437 (match_operand:SI 2 "reg_or_cint_operand" "r,O,K,L,I,r,O,K,L,I"))
11438 (match_operand:SI 3 "gpc_reg_operand" "r,r,r,r,r,r,r,r,r,r"))
11439 (const_int 0)))
11440 (clobber (match_scratch:SI 4 "=&r,&r,&r,&r,&r,&r,&r,&r,&r,&r"))]
11441 "! TARGET_POWERPC64"
11442 "@
11443 xor %4,%1,%2\;{sfi|subfic} %4,%4,0\;{aze.|addze.} %4,%3
11444 {sfi|subfic} %4,%1,0\;{aze.|addze.} %4,%3
11445 {xoril|xori} %4,%1,%b2\;{sfi|subfic} %4,%4,0\;{aze.|addze.} %4,%3
11446 {xoriu|xoris} %4,%1,%u2\;{sfi|subfic} %4,%4,0\;{aze.|addze.} %4,%3
11447 {sfi|subfic} %4,%1,%2\;{sfi|subfic} %4,%4,0\;{aze.|addze.} %4,%3
11448 #
11449 #
11450 #
11451 #
11452 #"
11453 [(set_attr "type" "compare")
11454 (set_attr "length" "12,8,12,12,12,16,12,16,16,16")])
11455
11456 (define_split
11457 [(set (match_operand:CC 0 "cc_reg_not_cr0_operand" "")
11458 (compare:CC
11459 (plus:SI
11460 (eq:SI (match_operand:SI 1 "gpc_reg_operand" "")
11461 (match_operand:SI 2 "reg_or_cint_operand" ""))
11462 (match_operand:SI 3 "gpc_reg_operand" ""))
11463 (const_int 0)))
11464 (clobber (match_scratch:SI 4 ""))]
11465 "! TARGET_POWERPC64 && reload_completed"
11466 [(set (match_dup 4)
11467 (plus:SI (eq:SI (match_dup 1)
11468 (match_dup 2))
11469 (match_dup 3)))
11470 (set (match_dup 0)
11471 (compare:CC (match_dup 4)
11472 (const_int 0)))]
11473 "")
11474
11475 (define_insn ""
11476 [(set (match_operand:CC 4 "cc_reg_operand" "=x,x,x,x,x,?y,?y,?y,?y,?y")
11477 (compare:CC
11478 (plus:SI
11479 (eq:SI (match_operand:SI 1 "gpc_reg_operand" "%r,r,r,r,r,r,r,r,r,r")
11480 (match_operand:SI 2 "reg_or_cint_operand" "r,O,K,L,I,r,O,K,L,I"))
11481 (match_operand:SI 3 "gpc_reg_operand" "r,r,r,r,r,r,r,r,r,r"))
11482 (const_int 0)))
11483 (set (match_operand:SI 0 "gpc_reg_operand" "=&r,&r,&r,&r,&r,&r,&r,&r,&r,&r")
11484 (plus:SI (eq:SI (match_dup 1) (match_dup 2)) (match_dup 3)))]
11485 "! TARGET_POWERPC64"
11486 "@
11487 xor %0,%1,%2\;{sfi|subfic} %0,%0,0\;{aze.|addze.} %0,%3
11488 {sfi|subfic} %0,%1,0\;{aze.|addze.} %0,%3
11489 {xoril|xori} %0,%1,%b2\;{sfi|subfic} %0,%0,0\;{aze.|addze.} %0,%3
11490 {xoriu|xoris} %0,%1,%u2\;{sfi|subfic} %0,%0,0\;{aze.|addze.} %0,%3
11491 {sfi|subfic} %0,%1,%2\;{sfi|subfic} %0,%0,0\;{aze.|addze.} %0,%3
11492 #
11493 #
11494 #
11495 #
11496 #"
11497 [(set_attr "type" "compare")
11498 (set_attr "length" "12,8,12,12,12,16,12,16,16,16")])
11499
11500 (define_split
11501 [(set (match_operand:CC 4 "cc_reg_not_cr0_operand" "")
11502 (compare:CC
11503 (plus:SI
11504 (eq:SI (match_operand:SI 1 "gpc_reg_operand" "")
11505 (match_operand:SI 2 "reg_or_cint_operand" ""))
11506 (match_operand:SI 3 "gpc_reg_operand" ""))
11507 (const_int 0)))
11508 (set (match_operand:SI 0 "gpc_reg_operand" "")
11509 (plus:SI (eq:SI (match_dup 1) (match_dup 2)) (match_dup 3)))]
11510 "! TARGET_POWERPC64 && reload_completed"
11511 [(set (match_dup 0)
11512 (plus:SI (eq:SI (match_dup 1) (match_dup 2)) (match_dup 3)))
11513 (set (match_dup 4)
11514 (compare:CC (match_dup 0)
11515 (const_int 0)))]
11516 "")
11517
11518 (define_insn ""
11519 [(set (match_operand:SI 0 "gpc_reg_operand" "=r,r,r,r,r")
11520 (neg:SI (eq:SI (match_operand:SI 1 "gpc_reg_operand" "%r,r,r,r,r")
11521 (match_operand:SI 2 "reg_or_cint_operand" "r,O,K,L,I"))))]
11522 "! TARGET_POWERPC64"
11523 "@
11524 xor %0,%1,%2\;{ai|addic} %0,%0,-1\;{sfe|subfe} %0,%0,%0
11525 {ai|addic} %0,%1,-1\;{sfe|subfe} %0,%0,%0
11526 {xoril|xori} %0,%1,%b2\;{ai|addic} %0,%0,-1\;{sfe|subfe} %0,%0,%0
11527 {xoriu|xoris} %0,%1,%u2\;{ai|addic} %0,%0,-1\;{sfe|subfe} %0,%0,%0
11528 {sfi|subfic} %0,%1,%2\;{ai|addic} %0,%0,-1\;{sfe|subfe} %0,%0,%0"
11529 [(set_attr "length" "12,8,12,12,12")])
11530
11531 ;; Simplify (ne X (const_int 0)) on the PowerPC. No need to on the Power,
11532 ;; since it nabs/sr is just as fast.
11533 (define_insn "*ne0"
11534 [(set (match_operand:SI 0 "gpc_reg_operand" "=&r")
11535 (lshiftrt:SI (neg:SI (abs:SI (match_operand:SI 1 "gpc_reg_operand" "r")))
11536 (const_int 31)))
11537 (clobber (match_scratch:SI 2 "=&r"))]
11538 "! TARGET_POWER && ! TARGET_POWERPC64 && !TARGET_ISEL"
11539 "{ai|addic} %2,%1,-1\;{sfe|subfe} %0,%2,%1"
11540 [(set_attr "length" "8")])
11541
11542 (define_insn ""
11543 [(set (match_operand:DI 0 "gpc_reg_operand" "=r")
11544 (lshiftrt:DI (neg:DI (abs:DI (match_operand:DI 1 "gpc_reg_operand" "r")))
11545 (const_int 63)))
11546 (clobber (match_scratch:DI 2 "=&r"))]
11547 "TARGET_POWERPC64"
11548 "addic %2,%1,-1\;subfe %0,%2,%1"
11549 [(set_attr "length" "8")])
11550
11551 ;; This is what (plus (ne X (const_int 0)) Y) looks like.
11552 (define_insn ""
11553 [(set (match_operand:SI 0 "gpc_reg_operand" "=r")
11554 (plus:SI (lshiftrt:SI
11555 (neg:SI (abs:SI (match_operand:SI 1 "gpc_reg_operand" "r")))
11556 (const_int 31))
11557 (match_operand:SI 2 "gpc_reg_operand" "r")))
11558 (clobber (match_scratch:SI 3 "=&r"))]
11559 "! TARGET_POWERPC64"
11560 "{ai|addic} %3,%1,-1\;{aze|addze} %0,%2"
11561 [(set_attr "length" "8")])
11562
11563 (define_insn ""
11564 [(set (match_operand:DI 0 "gpc_reg_operand" "=r")
11565 (plus:DI (lshiftrt:DI
11566 (neg:DI (abs:DI (match_operand:DI 1 "gpc_reg_operand" "r")))
11567 (const_int 63))
11568 (match_operand:DI 2 "gpc_reg_operand" "r")))
11569 (clobber (match_scratch:DI 3 "=&r"))]
11570 "TARGET_POWERPC64"
11571 "addic %3,%1,-1\;addze %0,%2"
11572 [(set_attr "length" "8")])
11573
11574 (define_insn ""
11575 [(set (match_operand:CC 0 "cc_reg_operand" "=x,?y")
11576 (compare:CC
11577 (plus:SI (lshiftrt:SI
11578 (neg:SI (abs:SI (match_operand:SI 1 "gpc_reg_operand" "r,r")))
11579 (const_int 31))
11580 (match_operand:SI 2 "gpc_reg_operand" "r,r"))
11581 (const_int 0)))
11582 (clobber (match_scratch:SI 3 "=&r,&r"))
11583 (clobber (match_scratch:SI 4 "=X,&r"))]
11584 "! TARGET_POWERPC64"
11585 "@
11586 {ai|addic} %3,%1,-1\;{aze.|addze.} %3,%2
11587 #"
11588 [(set_attr "type" "compare")
11589 (set_attr "length" "8,12")])
11590
11591 (define_split
11592 [(set (match_operand:CC 0 "cc_reg_not_cr0_operand" "")
11593 (compare:CC
11594 (plus:SI (lshiftrt:SI
11595 (neg:SI (abs:SI (match_operand:SI 1 "gpc_reg_operand" "")))
11596 (const_int 31))
11597 (match_operand:SI 2 "gpc_reg_operand" ""))
11598 (const_int 0)))
11599 (clobber (match_scratch:SI 3 ""))
11600 (clobber (match_scratch:SI 4 ""))]
11601 "! TARGET_POWERPC64 && reload_completed"
11602 [(parallel [(set (match_dup 3)
11603 (plus:SI (lshiftrt:SI (neg:SI (abs:SI (match_dup 1)))
11604 (const_int 31))
11605 (match_dup 2)))
11606 (clobber (match_dup 4))])
11607 (set (match_dup 0)
11608 (compare:CC (match_dup 3)
11609 (const_int 0)))]
11610 "")
11611
11612 (define_insn ""
11613 [(set (match_operand:CC 0 "cc_reg_operand" "=x,?y")
11614 (compare:CC
11615 (plus:DI (lshiftrt:DI
11616 (neg:DI (abs:DI (match_operand:DI 1 "gpc_reg_operand" "r,r")))
11617 (const_int 63))
11618 (match_operand:DI 2 "gpc_reg_operand" "r,r"))
11619 (const_int 0)))
11620 (clobber (match_scratch:DI 3 "=&r,&r"))]
11621 "TARGET_POWERPC64"
11622 "@
11623 addic %3,%1,-1\;addze. %3,%2
11624 #"
11625 [(set_attr "type" "compare")
11626 (set_attr "length" "8,12")])
11627
11628 (define_split
11629 [(set (match_operand:CC 0 "cc_reg_not_cr0_operand" "")
11630 (compare:CC
11631 (plus:DI (lshiftrt:DI
11632 (neg:DI (abs:DI (match_operand:DI 1 "gpc_reg_operand" "")))
11633 (const_int 63))
11634 (match_operand:DI 2 "gpc_reg_operand" ""))
11635 (const_int 0)))
11636 (clobber (match_scratch:DI 3 ""))]
11637 "TARGET_POWERPC64 && reload_completed"
11638 [(set (match_dup 3)
11639 (plus:DI (lshiftrt:DI (neg:DI (abs:DI (match_dup 1)))
11640 (const_int 63))
11641 (match_dup 2)))
11642 (set (match_dup 0)
11643 (compare:CC (match_dup 3)
11644 (const_int 0)))]
11645 "")
11646
11647 (define_insn ""
11648 [(set (match_operand:CC 4 "cc_reg_operand" "=x,?y")
11649 (compare:CC
11650 (plus:SI (lshiftrt:SI
11651 (neg:SI (abs:SI (match_operand:SI 1 "gpc_reg_operand" "r,r")))
11652 (const_int 31))
11653 (match_operand:SI 2 "gpc_reg_operand" "r,r"))
11654 (const_int 0)))
11655 (set (match_operand:SI 0 "gpc_reg_operand" "=r,r")
11656 (plus:SI (lshiftrt:SI (neg:SI (abs:SI (match_dup 1))) (const_int 31))
11657 (match_dup 2)))
11658 (clobber (match_scratch:SI 3 "=&r,&r"))]
11659 "! TARGET_POWERPC64"
11660 "@
11661 {ai|addic} %3,%1,-1\;{aze.|addze.} %0,%2
11662 #"
11663 [(set_attr "type" "compare")
11664 (set_attr "length" "8,12")])
11665
11666 (define_split
11667 [(set (match_operand:CC 4 "cc_reg_not_cr0_operand" "")
11668 (compare:CC
11669 (plus:SI (lshiftrt:SI
11670 (neg:SI (abs:SI (match_operand:SI 1 "gpc_reg_operand" "")))
11671 (const_int 31))
11672 (match_operand:SI 2 "gpc_reg_operand" ""))
11673 (const_int 0)))
11674 (set (match_operand:SI 0 "gpc_reg_operand" "")
11675 (plus:SI (lshiftrt:SI (neg:SI (abs:SI (match_dup 1))) (const_int 31))
11676 (match_dup 2)))
11677 (clobber (match_scratch:SI 3 ""))]
11678 "! TARGET_POWERPC64 && reload_completed"
11679 [(parallel [(set (match_dup 0)
11680 (plus:SI (lshiftrt:SI (neg:SI (abs:SI (match_dup 1))) (const_int 31))
11681 (match_dup 2)))
11682 (clobber (match_dup 3))])
11683 (set (match_dup 4)
11684 (compare:CC (match_dup 0)
11685 (const_int 0)))]
11686 "")
11687
11688 (define_insn ""
11689 [(set (match_operand:CC 4 "cc_reg_operand" "=x,?y")
11690 (compare:CC
11691 (plus:DI (lshiftrt:DI
11692 (neg:DI (abs:DI (match_operand:DI 1 "gpc_reg_operand" "r,r")))
11693 (const_int 63))
11694 (match_operand:DI 2 "gpc_reg_operand" "r,r"))
11695 (const_int 0)))
11696 (set (match_operand:DI 0 "gpc_reg_operand" "=r,r")
11697 (plus:DI (lshiftrt:DI (neg:DI (abs:DI (match_dup 1))) (const_int 63))
11698 (match_dup 2)))
11699 (clobber (match_scratch:DI 3 "=&r,&r"))]
11700 "TARGET_POWERPC64"
11701 "@
11702 addic %3,%1,-1\;addze. %0,%2
11703 #"
11704 [(set_attr "type" "compare")
11705 (set_attr "length" "8,12")])
11706
11707 (define_split
11708 [(set (match_operand:CC 4 "cc_reg_not_cr0_operand" "")
11709 (compare:CC
11710 (plus:DI (lshiftrt:DI
11711 (neg:DI (abs:DI (match_operand:DI 1 "gpc_reg_operand" "")))
11712 (const_int 63))
11713 (match_operand:DI 2 "gpc_reg_operand" ""))
11714 (const_int 0)))
11715 (set (match_operand:DI 0 "gpc_reg_operand" "")
11716 (plus:DI (lshiftrt:DI (neg:DI (abs:DI (match_dup 1))) (const_int 63))
11717 (match_dup 2)))
11718 (clobber (match_scratch:DI 3 ""))]
11719 "TARGET_POWERPC64 && reload_completed"
11720 [(parallel [(set (match_dup 0)
11721 (plus:DI (lshiftrt:DI (neg:DI (abs:DI (match_dup 1))) (const_int 63))
11722 (match_dup 2)))
11723 (clobber (match_dup 3))])
11724 (set (match_dup 4)
11725 (compare:CC (match_dup 0)
11726 (const_int 0)))]
11727 "")
11728
11729 (define_insn ""
11730 [(set (match_operand:SI 0 "gpc_reg_operand" "=r,r")
11731 (le:SI (match_operand:SI 1 "gpc_reg_operand" "r,r")
11732 (match_operand:SI 2 "reg_or_short_operand" "r,O")))
11733 (clobber (match_scratch:SI 3 "=r,X"))]
11734 "TARGET_POWER"
11735 "@
11736 doz %3,%2,%1\;{sfi|subfic} %0,%3,0\;{ae|adde} %0,%0,%3
11737 {ai|addic} %0,%1,-1\;{aze|addze} %0,%0\;{sri|srwi} %0,%0,31"
11738 [(set_attr "length" "12")])
11739
11740 (define_insn ""
11741 [(set (match_operand:CC 4 "cc_reg_operand" "=x,x,?y,?y")
11742 (compare:CC
11743 (le:SI (match_operand:SI 1 "gpc_reg_operand" "r,r,r,r")
11744 (match_operand:SI 2 "reg_or_short_operand" "r,O,r,O"))
11745 (const_int 0)))
11746 (set (match_operand:SI 0 "gpc_reg_operand" "=r,r,r,r")
11747 (le:SI (match_dup 1) (match_dup 2)))
11748 (clobber (match_scratch:SI 3 "=r,X,r,X"))]
11749 "TARGET_POWER"
11750 "@
11751 doz %3,%2,%1\;{sfi|subfic} %0,%3,0\;{ae.|adde.} %0,%0,%3
11752 {ai|addic} %0,%1,-1\;{aze|addze} %0,%0\;{sri.|srwi.} %0,%0,31
11753 #
11754 #"
11755 [(set_attr "type" "compare,delayed_compare,compare,delayed_compare")
11756 (set_attr "length" "12,12,16,16")])
11757
11758 (define_split
11759 [(set (match_operand:CC 4 "cc_reg_not_cr0_operand" "")
11760 (compare:CC
11761 (le:SI (match_operand:SI 1 "gpc_reg_operand" "")
11762 (match_operand:SI 2 "reg_or_short_operand" ""))
11763 (const_int 0)))
11764 (set (match_operand:SI 0 "gpc_reg_operand" "")
11765 (le:SI (match_dup 1) (match_dup 2)))
11766 (clobber (match_scratch:SI 3 ""))]
11767 "TARGET_POWER && reload_completed"
11768 [(parallel [(set (match_dup 0)
11769 (le:SI (match_dup 1) (match_dup 2)))
11770 (clobber (match_dup 3))])
11771 (set (match_dup 4)
11772 (compare:CC (match_dup 0)
11773 (const_int 0)))]
11774 "")
11775
11776 (define_insn ""
11777 [(set (match_operand:SI 0 "gpc_reg_operand" "=&r,&r")
11778 (plus:SI (le:SI (match_operand:SI 1 "gpc_reg_operand" "r,r")
11779 (match_operand:SI 2 "reg_or_short_operand" "r,O"))
11780 (match_operand:SI 3 "gpc_reg_operand" "r,r")))]
11781 "TARGET_POWER"
11782 "@
11783 doz %0,%2,%1\;{sfi|subfic} %0,%0,0\;{aze|addze} %0,%3
11784 {srai|srawi} %0,%1,31\;{sf|subfc} %0,%1,%0\;{aze|addze} %0,%3"
11785 [(set_attr "length" "12")])
11786
11787 (define_insn ""
11788 [(set (match_operand:CC 0 "cc_reg_operand" "=x,x,?y,?y")
11789 (compare:CC
11790 (plus:SI (le:SI (match_operand:SI 1 "gpc_reg_operand" "r,r,r,r")
11791 (match_operand:SI 2 "reg_or_short_operand" "r,O,r,O"))
11792 (match_operand:SI 3 "gpc_reg_operand" "r,r,r,r"))
11793 (const_int 0)))
11794 (clobber (match_scratch:SI 4 "=&r,&r,&r,&r"))]
11795 "TARGET_POWER"
11796 "@
11797 doz %4,%2,%1\;{sfi|subfic} %4,%4,0\;{aze.|addze.} %4,%3
11798 {srai|srawi} %4,%1,31\;{sf|subfc} %4,%1,%4\;{aze.|addze.} %4,%3
11799 #
11800 #"
11801 [(set_attr "type" "compare")
11802 (set_attr "length" "12,12,16,16")])
11803
11804 (define_split
11805 [(set (match_operand:CC 0 "cc_reg_not_cr0_operand" "")
11806 (compare:CC
11807 (plus:SI (le:SI (match_operand:SI 1 "gpc_reg_operand" "")
11808 (match_operand:SI 2 "reg_or_short_operand" ""))
11809 (match_operand:SI 3 "gpc_reg_operand" ""))
11810 (const_int 0)))
11811 (clobber (match_scratch:SI 4 ""))]
11812 "TARGET_POWER && reload_completed"
11813 [(set (match_dup 4)
11814 (plus:SI (le:SI (match_dup 1) (match_dup 2))
11815 (match_dup 3)))
11816 (set (match_dup 0)
11817 (compare:CC (match_dup 4)
11818 (const_int 0)))]
11819 "")
11820
11821 (define_insn ""
11822 [(set (match_operand:CC 4 "cc_reg_operand" "=x,x,?y,?y")
11823 (compare:CC
11824 (plus:SI (le:SI (match_operand:SI 1 "gpc_reg_operand" "r,r,r,r")
11825 (match_operand:SI 2 "reg_or_short_operand" "r,O,r,O"))
11826 (match_operand:SI 3 "gpc_reg_operand" "r,r,r,r"))
11827 (const_int 0)))
11828 (set (match_operand:SI 0 "gpc_reg_operand" "=&r,&r,&r,&r")
11829 (plus:SI (le:SI (match_dup 1) (match_dup 2)) (match_dup 3)))]
11830 "TARGET_POWER"
11831 "@
11832 doz %0,%2,%1\;{sfi|subfic} %0,%0,0\;{aze.|addze.} %0,%3
11833 {srai|srawi} %0,%1,31\;{sf|subfc} %0,%1,%0\;{aze.|addze.} %0,%3
11834 #
11835 #"
11836 [(set_attr "type" "compare")
11837 (set_attr "length" "12,12,16,16")])
11838
11839 (define_split
11840 [(set (match_operand:CC 4 "cc_reg_not_cr0_operand" "")
11841 (compare:CC
11842 (plus:SI (le:SI (match_operand:SI 1 "gpc_reg_operand" "")
11843 (match_operand:SI 2 "reg_or_short_operand" ""))
11844 (match_operand:SI 3 "gpc_reg_operand" ""))
11845 (const_int 0)))
11846 (set (match_operand:SI 0 "gpc_reg_operand" "")
11847 (plus:SI (le:SI (match_dup 1) (match_dup 2)) (match_dup 3)))]
11848 "TARGET_POWER && reload_completed"
11849 [(set (match_dup 0)
11850 (plus:SI (le:SI (match_dup 1) (match_dup 2)) (match_dup 3)))
11851 (set (match_dup 4)
11852 (compare:CC (match_dup 0)
11853 (const_int 0)))]
11854 "")
11855
11856 (define_insn ""
11857 [(set (match_operand:SI 0 "gpc_reg_operand" "=r,r")
11858 (neg:SI (le:SI (match_operand:SI 1 "gpc_reg_operand" "r,r")
11859 (match_operand:SI 2 "reg_or_short_operand" "r,O"))))]
11860 "TARGET_POWER"
11861 "@
11862 doz %0,%2,%1\;{ai|addic} %0,%0,-1\;{sfe|subfe} %0,%0,%0
11863 {ai|addic} %0,%1,-1\;{aze|addze} %0,%0\;{srai|srawi} %0,%0,31"
11864 [(set_attr "length" "12")])
11865
11866 (define_insn ""
11867 [(set (match_operand:SI 0 "gpc_reg_operand" "=r")
11868 (leu:SI (match_operand:SI 1 "gpc_reg_operand" "r")
11869 (match_operand:SI 2 "reg_or_short_operand" "rI")))]
11870 "! TARGET_POWERPC64"
11871 "{sf%I2|subf%I2c} %0,%1,%2\;{cal %0,0(0)|li %0,0}\;{ae|adde} %0,%0,%0"
11872 [(set_attr "length" "12")])
11873
11874 (define_insn ""
11875 [(set (match_operand:DI 0 "gpc_reg_operand" "=r")
11876 (leu:DI (match_operand:DI 1 "gpc_reg_operand" "r")
11877 (match_operand:DI 2 "reg_or_short_operand" "rI")))]
11878 "TARGET_POWERPC64"
11879 "subf%I2c %0,%1,%2\;li %0,0\;adde %0,%0,%0"
11880 [(set_attr "length" "12")])
11881
11882 (define_insn ""
11883 [(set (match_operand:CC 3 "cc_reg_operand" "=x,?y")
11884 (compare:CC
11885 (leu:DI (match_operand:DI 1 "gpc_reg_operand" "r,r")
11886 (match_operand:DI 2 "reg_or_short_operand" "rI,rI"))
11887 (const_int 0)))
11888 (set (match_operand:DI 0 "gpc_reg_operand" "=r,r")
11889 (leu:DI (match_dup 1) (match_dup 2)))]
11890 "TARGET_POWERPC64"
11891 "@
11892 subf%I2c %0,%1,%2\;li %0,0\;adde. %0,%0,%0
11893 #"
11894 [(set_attr "type" "compare")
11895 (set_attr "length" "12,16")])
11896
11897 (define_split
11898 [(set (match_operand:CC 3 "cc_reg_not_cr0_operand" "")
11899 (compare:CC
11900 (leu:DI (match_operand:DI 1 "gpc_reg_operand" "")
11901 (match_operand:DI 2 "reg_or_short_operand" ""))
11902 (const_int 0)))
11903 (set (match_operand:DI 0 "gpc_reg_operand" "")
11904 (leu:DI (match_dup 1) (match_dup 2)))]
11905 "TARGET_POWERPC64 && reload_completed"
11906 [(set (match_dup 0)
11907 (leu:DI (match_dup 1) (match_dup 2)))
11908 (set (match_dup 3)
11909 (compare:CC (match_dup 0)
11910 (const_int 0)))]
11911 "")
11912
11913 (define_insn ""
11914 [(set (match_operand:CC 3 "cc_reg_operand" "=x,?y")
11915 (compare:CC
11916 (leu:SI (match_operand:SI 1 "gpc_reg_operand" "r,r")
11917 (match_operand:SI 2 "reg_or_short_operand" "rI,rI"))
11918 (const_int 0)))
11919 (set (match_operand:SI 0 "gpc_reg_operand" "=r,r")
11920 (leu:SI (match_dup 1) (match_dup 2)))]
11921 "! TARGET_POWERPC64"
11922 "@
11923 {sf%I2|subf%I2c} %0,%1,%2\;{cal %0,0(0)|li %0,0}\;{ae.|adde.} %0,%0,%0
11924 #"
11925 [(set_attr "type" "compare")
11926 (set_attr "length" "12,16")])
11927
11928 (define_split
11929 [(set (match_operand:CC 3 "cc_reg_not_cr0_operand" "")
11930 (compare:CC
11931 (leu:SI (match_operand:SI 1 "gpc_reg_operand" "")
11932 (match_operand:SI 2 "reg_or_short_operand" ""))
11933 (const_int 0)))
11934 (set (match_operand:SI 0 "gpc_reg_operand" "")
11935 (leu:SI (match_dup 1) (match_dup 2)))]
11936 "! TARGET_POWERPC64 && reload_completed"
11937 [(set (match_dup 0)
11938 (leu:SI (match_dup 1) (match_dup 2)))
11939 (set (match_dup 3)
11940 (compare:CC (match_dup 0)
11941 (const_int 0)))]
11942 "")
11943
11944 (define_insn ""
11945 [(set (match_operand:CC 3 "cc_reg_operand" "=x,?y")
11946 (compare:CC
11947 (leu:DI (match_operand:DI 1 "gpc_reg_operand" "r,r")
11948 (match_operand:DI 2 "reg_or_short_operand" "rI,rI"))
11949 (const_int 0)))
11950 (set (match_operand:DI 0 "gpc_reg_operand" "=r,r")
11951 (leu:DI (match_dup 1) (match_dup 2)))]
11952 "TARGET_POWERPC64"
11953 "@
11954 subf%I2c %0,%1,%2\;li %0,0\;adde. %0,%0,%0
11955 #"
11956 [(set_attr "type" "compare")
11957 (set_attr "length" "12,16")])
11958
11959 (define_insn ""
11960 [(set (match_operand:SI 0 "gpc_reg_operand" "=&r")
11961 (plus:SI (leu:SI (match_operand:SI 1 "gpc_reg_operand" "r")
11962 (match_operand:SI 2 "reg_or_short_operand" "rI"))
11963 (match_operand:SI 3 "gpc_reg_operand" "r")))]
11964 "! TARGET_POWERPC64"
11965 "{sf%I2|subf%I2c} %0,%1,%2\;{aze|addze} %0,%3"
11966 [(set_attr "length" "8")])
11967
11968 (define_insn ""
11969 [(set (match_operand:CC 0 "cc_reg_operand" "=x,?y")
11970 (compare:CC
11971 (plus:SI (leu:SI (match_operand:SI 1 "gpc_reg_operand" "r,r")
11972 (match_operand:SI 2 "reg_or_short_operand" "rI,rI"))
11973 (match_operand:SI 3 "gpc_reg_operand" "r,r"))
11974 (const_int 0)))
11975 (clobber (match_scratch:SI 4 "=&r,&r"))]
11976 "! TARGET_POWERPC64"
11977 "@
11978 {sf%I2|subf%I2c} %4,%1,%2\;{aze.|addze.} %4,%3
11979 #"
11980 [(set_attr "type" "compare")
11981 (set_attr "length" "8,12")])
11982
11983 (define_split
11984 [(set (match_operand:CC 0 "cc_reg_not_cr0_operand" "")
11985 (compare:CC
11986 (plus:SI (leu:SI (match_operand:SI 1 "gpc_reg_operand" "")
11987 (match_operand:SI 2 "reg_or_short_operand" ""))
11988 (match_operand:SI 3 "gpc_reg_operand" ""))
11989 (const_int 0)))
11990 (clobber (match_scratch:SI 4 ""))]
11991 "! TARGET_POWERPC64 && reload_completed"
11992 [(set (match_dup 4)
11993 (plus:SI (leu:SI (match_dup 1) (match_dup 2))
11994 (match_dup 3)))
11995 (set (match_dup 0)
11996 (compare:CC (match_dup 4)
11997 (const_int 0)))]
11998 "")
11999
12000 (define_insn ""
12001 [(set (match_operand:CC 4 "cc_reg_operand" "=x,?y")
12002 (compare:CC
12003 (plus:SI (leu:SI (match_operand:SI 1 "gpc_reg_operand" "r,r")
12004 (match_operand:SI 2 "reg_or_short_operand" "rI,rI"))
12005 (match_operand:SI 3 "gpc_reg_operand" "r,r"))
12006 (const_int 0)))
12007 (set (match_operand:SI 0 "gpc_reg_operand" "=&r,&r")
12008 (plus:SI (leu:SI (match_dup 1) (match_dup 2)) (match_dup 3)))]
12009 "! TARGET_POWERPC64"
12010 "@
12011 {sf%I2|subf%I2c} %0,%1,%2\;{aze.|addze.} %0,%3
12012 #"
12013 [(set_attr "type" "compare")
12014 (set_attr "length" "8,12")])
12015
12016 (define_split
12017 [(set (match_operand:CC 4 "cc_reg_not_cr0_operand" "")
12018 (compare:CC
12019 (plus:SI (leu:SI (match_operand:SI 1 "gpc_reg_operand" "")
12020 (match_operand:SI 2 "reg_or_short_operand" ""))
12021 (match_operand:SI 3 "gpc_reg_operand" ""))
12022 (const_int 0)))
12023 (set (match_operand:SI 0 "gpc_reg_operand" "")
12024 (plus:SI (leu:SI (match_dup 1) (match_dup 2)) (match_dup 3)))]
12025 "! TARGET_POWERPC64 && reload_completed"
12026 [(set (match_dup 0)
12027 (plus:SI (leu:SI (match_dup 1) (match_dup 2)) (match_dup 3)))
12028 (set (match_dup 4)
12029 (compare:CC (match_dup 0)
12030 (const_int 0)))]
12031 "")
12032
12033 (define_insn ""
12034 [(set (match_operand:SI 0 "gpc_reg_operand" "=r")
12035 (neg:SI (leu:SI (match_operand:SI 1 "gpc_reg_operand" "r")
12036 (match_operand:SI 2 "reg_or_short_operand" "rI"))))]
12037 "! TARGET_POWERPC64"
12038 "{sf%I2|subf%I2c} %0,%1,%2\;{sfe|subfe} %0,%0,%0\;nand %0,%0,%0"
12039 [(set_attr "length" "12")])
12040
12041 (define_insn ""
12042 [(set (match_operand:SI 0 "gpc_reg_operand" "=&r")
12043 (and:SI (neg:SI
12044 (leu:SI (match_operand:SI 1 "gpc_reg_operand" "r")
12045 (match_operand:SI 2 "reg_or_short_operand" "rI")))
12046 (match_operand:SI 3 "gpc_reg_operand" "r")))]
12047 "! TARGET_POWERPC64"
12048 "{sf%I2|subf%I2c} %0,%1,%2\;{sfe|subfe} %0,%0,%0\;andc %0,%3,%0"
12049 [(set_attr "length" "12")])
12050
12051 (define_insn ""
12052 [(set (match_operand:CC 0 "cc_reg_operand" "=x,?y")
12053 (compare:CC
12054 (and:SI (neg:SI
12055 (leu:SI (match_operand:SI 1 "gpc_reg_operand" "r,r")
12056 (match_operand:SI 2 "reg_or_short_operand" "rI,rI")))
12057 (match_operand:SI 3 "gpc_reg_operand" "r,r"))
12058 (const_int 0)))
12059 (clobber (match_scratch:SI 4 "=&r,&r"))]
12060 "! TARGET_POWERPC64"
12061 "@
12062 {sf%I2|subf%I2c} %4,%1,%2\;{sfe|subfe} %4,%4,%4\;andc. %4,%3,%4
12063 #"
12064 [(set_attr "type" "compare")
12065 (set_attr "length" "12,16")])
12066
12067 (define_split
12068 [(set (match_operand:CC 0 "cc_reg_not_cr0_operand" "")
12069 (compare:CC
12070 (and:SI (neg:SI
12071 (leu:SI (match_operand:SI 1 "gpc_reg_operand" "")
12072 (match_operand:SI 2 "reg_or_short_operand" "")))
12073 (match_operand:SI 3 "gpc_reg_operand" ""))
12074 (const_int 0)))
12075 (clobber (match_scratch:SI 4 ""))]
12076 "! TARGET_POWERPC64 && reload_completed"
12077 [(set (match_dup 4)
12078 (and:SI (neg:SI (leu:SI (match_dup 1) (match_dup 2)))
12079 (match_dup 3)))
12080 (set (match_dup 0)
12081 (compare:CC (match_dup 4)
12082 (const_int 0)))]
12083 "")
12084
12085 (define_insn ""
12086 [(set (match_operand:CC 4 "cc_reg_operand" "=x,?y")
12087 (compare:CC
12088 (and:SI (neg:SI
12089 (leu:SI (match_operand:SI 1 "gpc_reg_operand" "r,r")
12090 (match_operand:SI 2 "reg_or_short_operand" "rI,rI")))
12091 (match_operand:SI 3 "gpc_reg_operand" "r,r"))
12092 (const_int 0)))
12093 (set (match_operand:SI 0 "gpc_reg_operand" "=&r,&r")
12094 (and:SI (neg:SI (leu:SI (match_dup 1) (match_dup 2))) (match_dup 3)))]
12095 "! TARGET_POWERPC64"
12096 "@
12097 {sf%I2|subf%I2c} %0,%1,%2\;{sfe|subfe} %0,%0,%0\;andc. %0,%3,%0
12098 #"
12099 [(set_attr "type" "compare")
12100 (set_attr "length" "12,16")])
12101
12102 (define_split
12103 [(set (match_operand:CC 4 "cc_reg_not_cr0_operand" "")
12104 (compare:CC
12105 (and:SI (neg:SI
12106 (leu:SI (match_operand:SI 1 "gpc_reg_operand" "")
12107 (match_operand:SI 2 "reg_or_short_operand" "")))
12108 (match_operand:SI 3 "gpc_reg_operand" ""))
12109 (const_int 0)))
12110 (set (match_operand:SI 0 "gpc_reg_operand" "")
12111 (and:SI (neg:SI (leu:SI (match_dup 1) (match_dup 2))) (match_dup 3)))]
12112 "! TARGET_POWERPC64 && reload_completed"
12113 [(set (match_dup 0)
12114 (and:SI (neg:SI (leu:SI (match_dup 1) (match_dup 2)))
12115 (match_dup 3)))
12116 (set (match_dup 4)
12117 (compare:CC (match_dup 0)
12118 (const_int 0)))]
12119 "")
12120
12121 (define_insn ""
12122 [(set (match_operand:SI 0 "gpc_reg_operand" "=r")
12123 (lt:SI (match_operand:SI 1 "gpc_reg_operand" "r")
12124 (match_operand:SI 2 "reg_or_short_operand" "rI")))]
12125 "TARGET_POWER"
12126 "doz%I2 %0,%1,%2\;nabs %0,%0\;{sri|srwi} %0,%0,31"
12127 [(set_attr "length" "12")])
12128
12129 (define_insn ""
12130 [(set (match_operand:CC 3 "cc_reg_operand" "=x,?y")
12131 (compare:CC
12132 (lt:SI (match_operand:SI 1 "gpc_reg_operand" "r,r")
12133 (match_operand:SI 2 "reg_or_short_operand" "rI,rI"))
12134 (const_int 0)))
12135 (set (match_operand:SI 0 "gpc_reg_operand" "=r,r")
12136 (lt:SI (match_dup 1) (match_dup 2)))]
12137 "TARGET_POWER"
12138 "@
12139 doz%I2 %0,%1,%2\;nabs %0,%0\;{sri.|srwi.} %0,%0,31
12140 #"
12141 [(set_attr "type" "delayed_compare")
12142 (set_attr "length" "12,16")])
12143
12144 (define_split
12145 [(set (match_operand:CC 3 "cc_reg_not_cr0_operand" "")
12146 (compare:CC
12147 (lt:SI (match_operand:SI 1 "gpc_reg_operand" "")
12148 (match_operand:SI 2 "reg_or_short_operand" ""))
12149 (const_int 0)))
12150 (set (match_operand:SI 0 "gpc_reg_operand" "")
12151 (lt:SI (match_dup 1) (match_dup 2)))]
12152 "TARGET_POWER && reload_completed"
12153 [(set (match_dup 0)
12154 (lt:SI (match_dup 1) (match_dup 2)))
12155 (set (match_dup 3)
12156 (compare:CC (match_dup 0)
12157 (const_int 0)))]
12158 "")
12159
12160 (define_insn ""
12161 [(set (match_operand:SI 0 "gpc_reg_operand" "=&r")
12162 (plus:SI (lt:SI (match_operand:SI 1 "gpc_reg_operand" "r")
12163 (match_operand:SI 2 "reg_or_short_operand" "rI"))
12164 (match_operand:SI 3 "gpc_reg_operand" "r")))]
12165 "TARGET_POWER"
12166 "doz%I2 %0,%1,%2\;{ai|addic} %0,%0,-1\;{aze|addze} %0,%3"
12167 [(set_attr "length" "12")])
12168
12169 (define_insn ""
12170 [(set (match_operand:CC 0 "cc_reg_operand" "=x,?y")
12171 (compare:CC
12172 (plus:SI (lt:SI (match_operand:SI 1 "gpc_reg_operand" "r,r")
12173 (match_operand:SI 2 "reg_or_short_operand" "rI,rI"))
12174 (match_operand:SI 3 "gpc_reg_operand" "r,r"))
12175 (const_int 0)))
12176 (clobber (match_scratch:SI 4 "=&r,&r"))]
12177 "TARGET_POWER"
12178 "@
12179 doz%I2 %4,%1,%2\;{ai|addic} %4,%4,-1\;{aze.|addze.} %4,%3
12180 #"
12181 [(set_attr "type" "compare")
12182 (set_attr "length" "12,16")])
12183
12184 (define_split
12185 [(set (match_operand:CC 0 "cc_reg_not_cr0_operand" "")
12186 (compare:CC
12187 (plus:SI (lt:SI (match_operand:SI 1 "gpc_reg_operand" "")
12188 (match_operand:SI 2 "reg_or_short_operand" ""))
12189 (match_operand:SI 3 "gpc_reg_operand" ""))
12190 (const_int 0)))
12191 (clobber (match_scratch:SI 4 ""))]
12192 "TARGET_POWER && reload_completed"
12193 [(set (match_dup 4)
12194 (plus:SI (lt:SI (match_dup 1) (match_dup 2))
12195 (match_dup 3)))
12196 (set (match_dup 0)
12197 (compare:CC (match_dup 4)
12198 (const_int 0)))]
12199 "")
12200
12201 (define_insn ""
12202 [(set (match_operand:CC 4 "cc_reg_operand" "=x,?y")
12203 (compare:CC
12204 (plus:SI (lt:SI (match_operand:SI 1 "gpc_reg_operand" "r,r")
12205 (match_operand:SI 2 "reg_or_short_operand" "rI,rI"))
12206 (match_operand:SI 3 "gpc_reg_operand" "r,r"))
12207 (const_int 0)))
12208 (set (match_operand:SI 0 "gpc_reg_operand" "=&r,&r")
12209 (plus:SI (lt:SI (match_dup 1) (match_dup 2)) (match_dup 3)))]
12210 "TARGET_POWER"
12211 "@
12212 doz%I2 %0,%1,%2\;{ai|addic} %0,%0,-1\;{aze.|addze.} %0,%3
12213 #"
12214 [(set_attr "type" "compare")
12215 (set_attr "length" "12,16")])
12216
12217 (define_split
12218 [(set (match_operand:CC 4 "cc_reg_not_cr0_operand" "")
12219 (compare:CC
12220 (plus:SI (lt:SI (match_operand:SI 1 "gpc_reg_operand" "")
12221 (match_operand:SI 2 "reg_or_short_operand" ""))
12222 (match_operand:SI 3 "gpc_reg_operand" ""))
12223 (const_int 0)))
12224 (set (match_operand:SI 0 "gpc_reg_operand" "")
12225 (plus:SI (lt:SI (match_dup 1) (match_dup 2)) (match_dup 3)))]
12226 "TARGET_POWER && reload_completed"
12227 [(set (match_dup 0)
12228 (plus:SI (lt:SI (match_dup 1) (match_dup 2)) (match_dup 3)))
12229 (set (match_dup 4)
12230 (compare:CC (match_dup 0)
12231 (const_int 0)))]
12232 "")
12233
12234 (define_insn ""
12235 [(set (match_operand:SI 0 "gpc_reg_operand" "=r")
12236 (neg:SI (lt:SI (match_operand:SI 1 "gpc_reg_operand" "r")
12237 (match_operand:SI 2 "reg_or_short_operand" "rI"))))]
12238 "TARGET_POWER"
12239 "doz%I2 %0,%1,%2\;nabs %0,%0\;{srai|srawi} %0,%0,31"
12240 [(set_attr "length" "12")])
12241
12242 (define_insn ""
12243 [(set (match_operand:SI 0 "gpc_reg_operand" "=r,r")
12244 (ltu:SI (match_operand:SI 1 "gpc_reg_operand" "r,r")
12245 (match_operand:SI 2 "reg_or_neg_short_operand" "r,P")))]
12246 "! TARGET_POWERPC64"
12247 "@
12248 {sf|subfc} %0,%2,%1\;{sfe|subfe} %0,%0,%0\;neg %0,%0
12249 {ai|addic} %0,%1,%n2\;{sfe|subfe} %0,%0,%0\;neg %0,%0"
12250 [(set_attr "length" "12")])
12251
12252 (define_insn ""
12253 [(set (match_operand:CC 3 "cc_reg_operand" "=x,x,?y,?y")
12254 (compare:CC
12255 (ltu:SI (match_operand:SI 1 "gpc_reg_operand" "r,r,r,r")
12256 (match_operand:SI 2 "reg_or_neg_short_operand" "r,P,r,P"))
12257 (const_int 0)))
12258 (set (match_operand:SI 0 "gpc_reg_operand" "=r,r,r,r")
12259 (ltu:SI (match_dup 1) (match_dup 2)))]
12260 "! TARGET_POWERPC64"
12261 "@
12262 {sf|subfc} %0,%2,%1\;{sfe|subfe} %0,%0,%0\;neg. %0,%0
12263 {ai|addic} %0,%1,%n2\;{sfe|subfe} %0,%0,%0\;neg. %0,%0
12264 #
12265 #"
12266 [(set_attr "type" "compare")
12267 (set_attr "length" "12,12,16,16")])
12268
12269 (define_split
12270 [(set (match_operand:CC 3 "cc_reg_not_cr0_operand" "")
12271 (compare:CC
12272 (ltu:SI (match_operand:SI 1 "gpc_reg_operand" "")
12273 (match_operand:SI 2 "reg_or_neg_short_operand" ""))
12274 (const_int 0)))
12275 (set (match_operand:SI 0 "gpc_reg_operand" "")
12276 (ltu:SI (match_dup 1) (match_dup 2)))]
12277 "! TARGET_POWERPC64 && reload_completed"
12278 [(set (match_dup 0)
12279 (ltu:SI (match_dup 1) (match_dup 2)))
12280 (set (match_dup 3)
12281 (compare:CC (match_dup 0)
12282 (const_int 0)))]
12283 "")
12284
12285 (define_insn ""
12286 [(set (match_operand:SI 0 "gpc_reg_operand" "=&r,&r")
12287 (plus:SI (ltu:SI (match_operand:SI 1 "gpc_reg_operand" "r,r")
12288 (match_operand:SI 2 "reg_or_neg_short_operand" "r,P"))
12289 (match_operand:SI 3 "reg_or_short_operand" "rI,rI")))]
12290 "! TARGET_POWERPC64"
12291 "@
12292 {sf|subfc} %0,%2,%1\;{sfe|subfe} %0,%0,%0\;{sf%I3|subf%I3c} %0,%0,%3
12293 {ai|addic} %0,%1,%n2\;{sfe|subfe} %0,%0,%0\;{sf%I3|subf%I3c} %0,%0,%3"
12294 [(set_attr "length" "12")])
12295
12296 (define_insn ""
12297 [(set (match_operand:CC 0 "cc_reg_operand" "=x,x,?y,?y")
12298 (compare:CC
12299 (plus:SI (ltu:SI (match_operand:SI 1 "gpc_reg_operand" "r,r,r,r")
12300 (match_operand:SI 2 "reg_or_neg_short_operand" "r,P,r,P"))
12301 (match_operand:SI 3 "gpc_reg_operand" "r,r,r,r"))
12302 (const_int 0)))
12303 (clobber (match_scratch:SI 4 "=&r,&r,&r,&r"))]
12304 "! TARGET_POWERPC64"
12305 "@
12306 {sf|subfc} %4,%2,%1\;{sfe|subfe} %4,%4,%4\;{sf.|subfc.} %4,%4,%3
12307 {ai|addic} %4,%1,%n2\;{sfe|subfe} %4,%4,%4\;{sf.|subfc.} %4,%4,%3
12308 #
12309 #"
12310 [(set_attr "type" "compare")
12311 (set_attr "length" "12,12,16,16")])
12312
12313 (define_split
12314 [(set (match_operand:CC 0 "cc_reg_not_cr0_operand" "")
12315 (compare:CC
12316 (plus:SI (ltu:SI (match_operand:SI 1 "gpc_reg_operand" "")
12317 (match_operand:SI 2 "reg_or_neg_short_operand" ""))
12318 (match_operand:SI 3 "gpc_reg_operand" ""))
12319 (const_int 0)))
12320 (clobber (match_scratch:SI 4 ""))]
12321 "! TARGET_POWERPC64 && reload_completed"
12322 [(set (match_dup 4)
12323 (plus:SI (ltu:SI (match_dup 1) (match_dup 2))
12324 (match_dup 3)))
12325 (set (match_dup 0)
12326 (compare:CC (match_dup 4)
12327 (const_int 0)))]
12328 "")
12329
12330 (define_insn ""
12331 [(set (match_operand:CC 4 "cc_reg_operand" "=x,x,?y,?y")
12332 (compare:CC
12333 (plus:SI (ltu:SI (match_operand:SI 1 "gpc_reg_operand" "r,r,r,r")
12334 (match_operand:SI 2 "reg_or_neg_short_operand" "r,P,r,P"))
12335 (match_operand:SI 3 "gpc_reg_operand" "r,r,r,r"))
12336 (const_int 0)))
12337 (set (match_operand:SI 0 "gpc_reg_operand" "=&r,&r,&r,&r")
12338 (plus:SI (ltu:SI (match_dup 1) (match_dup 2)) (match_dup 3)))]
12339 "! TARGET_POWERPC64"
12340 "@
12341 {sf|subfc} %0,%2,%1\;{sfe|subfe} %0,%0,%0\;{sf.|subfc.} %0,%0,%3
12342 {ai|addic} %0,%1,%n2\;{sfe|subfe} %0,%0,%0\;{sf.|subfc.} %0,%0,%3
12343 #
12344 #"
12345 [(set_attr "type" "compare")
12346 (set_attr "length" "12,12,16,16")])
12347
12348 (define_split
12349 [(set (match_operand:CC 4 "cc_reg_not_cr0_operand" "")
12350 (compare:CC
12351 (plus:SI (ltu:SI (match_operand:SI 1 "gpc_reg_operand" "")
12352 (match_operand:SI 2 "reg_or_neg_short_operand" ""))
12353 (match_operand:SI 3 "gpc_reg_operand" ""))
12354 (const_int 0)))
12355 (set (match_operand:SI 0 "gpc_reg_operand" "")
12356 (plus:SI (ltu:SI (match_dup 1) (match_dup 2)) (match_dup 3)))]
12357 "! TARGET_POWERPC64 && reload_completed"
12358 [(set (match_dup 0)
12359 (plus:SI (ltu:SI (match_dup 1) (match_dup 2)) (match_dup 3)))
12360 (set (match_dup 4)
12361 (compare:CC (match_dup 0)
12362 (const_int 0)))]
12363 "")
12364
12365 (define_insn ""
12366 [(set (match_operand:SI 0 "gpc_reg_operand" "=r,r")
12367 (neg:SI (ltu:SI (match_operand:SI 1 "gpc_reg_operand" "r,r")
12368 (match_operand:SI 2 "reg_or_neg_short_operand" "r,P"))))]
12369 "! TARGET_POWERPC64"
12370 "@
12371 {sf|subfc} %0,%2,%1\;{sfe|subfe} %0,%0,%0
12372 {ai|addic} %0,%1,%n2\;{sfe|subfe} %0,%0,%0"
12373 [(set_attr "length" "8")])
12374
12375 (define_insn ""
12376 [(set (match_operand:SI 0 "gpc_reg_operand" "=r")
12377 (ge:SI (match_operand:SI 1 "gpc_reg_operand" "r")
12378 (match_operand:SI 2 "reg_or_short_operand" "rI")))
12379 (clobber (match_scratch:SI 3 "=r"))]
12380 "TARGET_POWER"
12381 "doz%I2 %3,%1,%2\;{sfi|subfic} %0,%3,0\;{ae|adde} %0,%0,%3"
12382 [(set_attr "length" "12")])
12383
12384 (define_insn ""
12385 [(set (match_operand:CC 4 "cc_reg_operand" "=x,?y")
12386 (compare:CC
12387 (ge:SI (match_operand:SI 1 "gpc_reg_operand" "r,r")
12388 (match_operand:SI 2 "reg_or_short_operand" "rI,rI"))
12389 (const_int 0)))
12390 (set (match_operand:SI 0 "gpc_reg_operand" "=r,r")
12391 (ge:SI (match_dup 1) (match_dup 2)))
12392 (clobber (match_scratch:SI 3 "=r,r"))]
12393 "TARGET_POWER"
12394 "@
12395 doz%I2 %3,%1,%2\;{sfi|subfic} %0,%3,0\;{ae.|adde.} %0,%0,%3
12396 #"
12397 [(set_attr "type" "compare")
12398 (set_attr "length" "12,16")])
12399
12400 (define_split
12401 [(set (match_operand:CC 4 "cc_reg_not_cr0_operand" "")
12402 (compare:CC
12403 (ge:SI (match_operand:SI 1 "gpc_reg_operand" "")
12404 (match_operand:SI 2 "reg_or_short_operand" ""))
12405 (const_int 0)))
12406 (set (match_operand:SI 0 "gpc_reg_operand" "")
12407 (ge:SI (match_dup 1) (match_dup 2)))
12408 (clobber (match_scratch:SI 3 ""))]
12409 "TARGET_POWER && reload_completed"
12410 [(parallel [(set (match_dup 0)
12411 (ge:SI (match_dup 1) (match_dup 2)))
12412 (clobber (match_dup 3))])
12413 (set (match_dup 4)
12414 (compare:CC (match_dup 0)
12415 (const_int 0)))]
12416 "")
12417
12418 (define_insn ""
12419 [(set (match_operand:SI 0 "gpc_reg_operand" "=&r")
12420 (plus:SI (ge:SI (match_operand:SI 1 "gpc_reg_operand" "r")
12421 (match_operand:SI 2 "reg_or_short_operand" "rI"))
12422 (match_operand:SI 3 "gpc_reg_operand" "r")))]
12423 "TARGET_POWER"
12424 "doz%I2 %0,%1,%2\;{sfi|subfic} %0,%0,0\;{aze|addze} %0,%3"
12425 [(set_attr "length" "12")])
12426
12427 (define_insn ""
12428 [(set (match_operand:CC 0 "cc_reg_operand" "=x,?y")
12429 (compare:CC
12430 (plus:SI (ge:SI (match_operand:SI 1 "gpc_reg_operand" "r,r")
12431 (match_operand:SI 2 "reg_or_short_operand" "rI,rI"))
12432 (match_operand:SI 3 "gpc_reg_operand" "r,r"))
12433 (const_int 0)))
12434 (clobber (match_scratch:SI 4 "=&r,&r"))]
12435 "TARGET_POWER"
12436 "@
12437 doz%I2 %4,%1,%2\;{sfi|subfic} %4,%4,0\;{aze.|addze.} %4,%3
12438 #"
12439 [(set_attr "type" "compare")
12440 (set_attr "length" "12,16")])
12441
12442 (define_split
12443 [(set (match_operand:CC 0 "cc_reg_not_cr0_operand" "")
12444 (compare:CC
12445 (plus:SI (ge:SI (match_operand:SI 1 "gpc_reg_operand" "")
12446 (match_operand:SI 2 "reg_or_short_operand" ""))
12447 (match_operand:SI 3 "gpc_reg_operand" ""))
12448 (const_int 0)))
12449 (clobber (match_scratch:SI 4 ""))]
12450 "TARGET_POWER && reload_completed"
12451 [(set (match_dup 4)
12452 (plus:SI (ge:SI (match_dup 1) (match_dup 2))
12453 (match_dup 3)))
12454 (set (match_dup 0)
12455 (compare:CC (match_dup 4)
12456 (const_int 0)))]
12457 "")
12458
12459 (define_insn ""
12460 [(set (match_operand:CC 4 "cc_reg_operand" "=x,?y")
12461 (compare:CC
12462 (plus:SI (ge:SI (match_operand:SI 1 "gpc_reg_operand" "r,r")
12463 (match_operand:SI 2 "reg_or_short_operand" "rI,rI"))
12464 (match_operand:SI 3 "gpc_reg_operand" "r,r"))
12465 (const_int 0)))
12466 (set (match_operand:SI 0 "gpc_reg_operand" "=&r,&r")
12467 (plus:SI (ge:SI (match_dup 1) (match_dup 2)) (match_dup 3)))]
12468 "TARGET_POWER"
12469 "@
12470 doz%I2 %0,%1,%2\;{sfi|subfic} %0,%0,0\;{aze.|addze.} %0,%3
12471 #"
12472 [(set_attr "type" "compare")
12473 (set_attr "length" "12,16")])
12474
12475 (define_split
12476 [(set (match_operand:CC 4 "cc_reg_not_cr0_operand" "")
12477 (compare:CC
12478 (plus:SI (ge:SI (match_operand:SI 1 "gpc_reg_operand" "")
12479 (match_operand:SI 2 "reg_or_short_operand" ""))
12480 (match_operand:SI 3 "gpc_reg_operand" ""))
12481 (const_int 0)))
12482 (set (match_operand:SI 0 "gpc_reg_operand" "")
12483 (plus:SI (ge:SI (match_dup 1) (match_dup 2)) (match_dup 3)))]
12484 "TARGET_POWER && reload_completed"
12485 [(set (match_dup 0)
12486 (plus:SI (ge:SI (match_dup 1) (match_dup 2)) (match_dup 3)))
12487 (set (match_dup 4)
12488 (compare:CC (match_dup 0)
12489 (const_int 0)))]
12490 "")
12491
12492 (define_insn ""
12493 [(set (match_operand:SI 0 "gpc_reg_operand" "=r")
12494 (neg:SI (ge:SI (match_operand:SI 1 "gpc_reg_operand" "r")
12495 (match_operand:SI 2 "reg_or_short_operand" "rI"))))]
12496 "TARGET_POWER"
12497 "doz%I2 %0,%1,%2\;{ai|addic} %0,%0,-1\;{sfe|subfe} %0,%0,%0"
12498 [(set_attr "length" "12")])
12499
12500 (define_insn ""
12501 [(set (match_operand:SI 0 "gpc_reg_operand" "=r,r")
12502 (geu:SI (match_operand:SI 1 "gpc_reg_operand" "r,r")
12503 (match_operand:SI 2 "reg_or_neg_short_operand" "r,P")))]
12504 "! TARGET_POWERPC64"
12505 "@
12506 {sf|subfc} %0,%2,%1\;{cal %0,0(0)|li %0,0}\;{ae|adde} %0,%0,%0
12507 {ai|addic} %0,%1,%n2\;{cal %0,0(0)|li %0,0}\;{ae|adde} %0,%0,%0"
12508 [(set_attr "length" "12")])
12509
12510 (define_insn ""
12511 [(set (match_operand:DI 0 "gpc_reg_operand" "=r,r")
12512 (geu:DI (match_operand:DI 1 "gpc_reg_operand" "r,r")
12513 (match_operand:DI 2 "reg_or_neg_short_operand" "r,P")))]
12514 "TARGET_POWERPC64"
12515 "@
12516 subfc %0,%2,%1\;li %0,0\;adde %0,%0,%0
12517 addic %0,%1,%n2\;li %0,0\;adde %0,%0,%0"
12518 [(set_attr "length" "12")])
12519
12520 (define_insn ""
12521 [(set (match_operand:CC 3 "cc_reg_operand" "=x,x,?y,?y")
12522 (compare:CC
12523 (geu:SI (match_operand:SI 1 "gpc_reg_operand" "r,r,r,r")
12524 (match_operand:SI 2 "reg_or_neg_short_operand" "r,P,r,P"))
12525 (const_int 0)))
12526 (set (match_operand:SI 0 "gpc_reg_operand" "=r,r,r,r")
12527 (geu:SI (match_dup 1) (match_dup 2)))]
12528 "! TARGET_POWERPC64"
12529 "@
12530 {sf|subfc} %0,%2,%1\;{cal %0,0(0)|li %0,0}\;{ae.|adde.} %0,%0,%0
12531 {ai|addic} %0,%1,%n2\;{cal %0,0(0)|li %0,0}\;{ae.|adde.} %0,%0,%0
12532 #
12533 #"
12534 [(set_attr "type" "compare")
12535 (set_attr "length" "12,12,16,16")])
12536
12537 (define_split
12538 [(set (match_operand:CC 3 "cc_reg_not_cr0_operand" "")
12539 (compare:CC
12540 (geu:SI (match_operand:SI 1 "gpc_reg_operand" "")
12541 (match_operand:SI 2 "reg_or_neg_short_operand" ""))
12542 (const_int 0)))
12543 (set (match_operand:SI 0 "gpc_reg_operand" "")
12544 (geu:SI (match_dup 1) (match_dup 2)))]
12545 "! TARGET_POWERPC64 && reload_completed"
12546 [(set (match_dup 0)
12547 (geu:SI (match_dup 1) (match_dup 2)))
12548 (set (match_dup 3)
12549 (compare:CC (match_dup 0)
12550 (const_int 0)))]
12551 "")
12552
12553 (define_insn ""
12554 [(set (match_operand:CC 3 "cc_reg_operand" "=x,x,?y,?y")
12555 (compare:CC
12556 (geu:DI (match_operand:DI 1 "gpc_reg_operand" "r,r,r,r")
12557 (match_operand:DI 2 "reg_or_neg_short_operand" "r,P,r,P"))
12558 (const_int 0)))
12559 (set (match_operand:DI 0 "gpc_reg_operand" "=r,r,r,r")
12560 (geu:DI (match_dup 1) (match_dup 2)))]
12561 "TARGET_POWERPC64"
12562 "@
12563 subfc %0,%2,%1\;li %0,0\;adde. %0,%0,%0
12564 addic %0,%1,%n2\;li %0,0\;adde. %0,%0,%0
12565 #
12566 #"
12567 [(set_attr "type" "compare")
12568 (set_attr "length" "12,12,16,16")])
12569
12570 (define_split
12571 [(set (match_operand:CC 3 "cc_reg_not_cr0_operand" "")
12572 (compare:CC
12573 (geu:DI (match_operand:DI 1 "gpc_reg_operand" "")
12574 (match_operand:DI 2 "reg_or_neg_short_operand" ""))
12575 (const_int 0)))
12576 (set (match_operand:DI 0 "gpc_reg_operand" "")
12577 (geu:DI (match_dup 1) (match_dup 2)))]
12578 "TARGET_POWERPC64 && reload_completed"
12579 [(set (match_dup 0)
12580 (geu:DI (match_dup 1) (match_dup 2)))
12581 (set (match_dup 3)
12582 (compare:CC (match_dup 0)
12583 (const_int 0)))]
12584 "")
12585
12586 (define_insn ""
12587 [(set (match_operand:SI 0 "gpc_reg_operand" "=&r,&r")
12588 (plus:SI (geu:SI (match_operand:SI 1 "gpc_reg_operand" "r,r")
12589 (match_operand:SI 2 "reg_or_neg_short_operand" "r,P"))
12590 (match_operand:SI 3 "gpc_reg_operand" "r,r")))]
12591 "! TARGET_POWERPC64"
12592 "@
12593 {sf|subfc} %0,%2,%1\;{aze|addze} %0,%3
12594 {ai|addic} %0,%1,%n2\;{aze|addze} %0,%3"
12595 [(set_attr "length" "8")])
12596
12597 (define_insn ""
12598 [(set (match_operand:CC 0 "cc_reg_operand" "=x,x,?y,?y")
12599 (compare:CC
12600 (plus:SI (geu:SI (match_operand:SI 1 "gpc_reg_operand" "r,r,r,r")
12601 (match_operand:SI 2 "reg_or_neg_short_operand" "r,P,r,P"))
12602 (match_operand:SI 3 "gpc_reg_operand" "r,r,r,r"))
12603 (const_int 0)))
12604 (clobber (match_scratch:SI 4 "=&r,&r,&r,&r"))]
12605 "! TARGET_POWERPC64"
12606 "@
12607 {sf|subfc} %4,%2,%1\;{aze.|addze.} %4,%3
12608 {ai|addic} %4,%1,%n2\;{aze.|addze.} %4,%3
12609 #
12610 #"
12611 [(set_attr "type" "compare")
12612 (set_attr "length" "8,8,12,12")])
12613
12614 (define_split
12615 [(set (match_operand:CC 0 "cc_reg_not_cr0_operand" "")
12616 (compare:CC
12617 (plus:SI (geu:SI (match_operand:SI 1 "gpc_reg_operand" "")
12618 (match_operand:SI 2 "reg_or_neg_short_operand" ""))
12619 (match_operand:SI 3 "gpc_reg_operand" ""))
12620 (const_int 0)))
12621 (clobber (match_scratch:SI 4 ""))]
12622 "! TARGET_POWERPC64 && reload_completed"
12623 [(set (match_dup 4)
12624 (plus:SI (geu:SI (match_dup 1) (match_dup 2))
12625 (match_dup 3)))
12626 (set (match_dup 0)
12627 (compare:CC (match_dup 4)
12628 (const_int 0)))]
12629 "")
12630
12631 (define_insn ""
12632 [(set (match_operand:CC 4 "cc_reg_operand" "=x,x,?y,?y")
12633 (compare:CC
12634 (plus:SI (geu:SI (match_operand:SI 1 "gpc_reg_operand" "r,r,r,r")
12635 (match_operand:SI 2 "reg_or_neg_short_operand" "r,P,r,P"))
12636 (match_operand:SI 3 "gpc_reg_operand" "r,r,r,r"))
12637 (const_int 0)))
12638 (set (match_operand:SI 0 "gpc_reg_operand" "=&r,&r,&r,&r")
12639 (plus:SI (geu:SI (match_dup 1) (match_dup 2)) (match_dup 3)))]
12640 "! TARGET_POWERPC64"
12641 "@
12642 {sf|subfc} %0,%2,%1\;{aze.|addze.} %0,%3
12643 {ai|addic} %0,%1,%n2\;{aze.|addze.} %0,%3
12644 #
12645 #"
12646 [(set_attr "type" "compare")
12647 (set_attr "length" "8,8,12,12")])
12648
12649 (define_split
12650 [(set (match_operand:CC 4 "cc_reg_not_cr0_operand" "")
12651 (compare:CC
12652 (plus:SI (geu:SI (match_operand:SI 1 "gpc_reg_operand" "")
12653 (match_operand:SI 2 "reg_or_neg_short_operand" ""))
12654 (match_operand:SI 3 "gpc_reg_operand" ""))
12655 (const_int 0)))
12656 (set (match_operand:SI 0 "gpc_reg_operand" "")
12657 (plus:SI (geu:SI (match_dup 1) (match_dup 2)) (match_dup 3)))]
12658 "! TARGET_POWERPC64 && reload_completed"
12659 [(set (match_dup 0)
12660 (plus:SI (geu:SI (match_dup 1) (match_dup 2)) (match_dup 3)))
12661 (set (match_dup 4)
12662 (compare:CC (match_dup 0)
12663 (const_int 0)))]
12664 "")
12665
12666 (define_insn ""
12667 [(set (match_operand:SI 0 "gpc_reg_operand" "=r,r")
12668 (neg:SI (geu:SI (match_operand:SI 1 "gpc_reg_operand" "r,r")
12669 (match_operand:SI 2 "reg_or_short_operand" "r,I"))))]
12670 "! TARGET_POWERPC64"
12671 "@
12672 {sf|subfc} %0,%2,%1\;{sfe|subfe} %0,%0,%0\;nand %0,%0,%0
12673 {sfi|subfic} %0,%1,-1\;{a%I2|add%I2c} %0,%0,%2\;{sfe|subfe} %0,%0,%0"
12674 [(set_attr "length" "12")])
12675
12676 (define_insn ""
12677 [(set (match_operand:SI 0 "gpc_reg_operand" "=&r,&r")
12678 (and:SI (neg:SI
12679 (geu:SI (match_operand:SI 1 "gpc_reg_operand" "r,r")
12680 (match_operand:SI 2 "reg_or_neg_short_operand" "r,P")))
12681 (match_operand:SI 3 "gpc_reg_operand" "r,r")))]
12682 "! TARGET_POWERPC64"
12683 "@
12684 {sf|subfc} %0,%2,%1\;{sfe|subfe} %0,%0,%0\;andc %0,%3,%0
12685 {ai|addic} %0,%1,%n2\;{sfe|subfe} %0,%0,%0\;andc %0,%3,%0"
12686 [(set_attr "length" "12")])
12687
12688 (define_insn ""
12689 [(set (match_operand:CC 0 "cc_reg_operand" "=x,x,?y,?y")
12690 (compare:CC
12691 (and:SI (neg:SI
12692 (geu:SI (match_operand:SI 1 "gpc_reg_operand" "r,r,r,r")
12693 (match_operand:SI 2 "reg_or_neg_short_operand" "r,P,r,P")))
12694 (match_operand:SI 3 "gpc_reg_operand" "r,r,r,r"))
12695 (const_int 0)))
12696 (clobber (match_scratch:SI 4 "=&r,&r,&r,&r"))]
12697 "! TARGET_POWERPC64"
12698 "@
12699 {sf|subfc} %4,%2,%1\;{sfe|subfe} %4,%4,%4\;andc. %4,%3,%4
12700 {ai|addic} %4,%1,%n2\;{sfe|subfe} %4,%4,%4\;andc. %4,%3,%4
12701 #
12702 #"
12703 [(set_attr "type" "compare")
12704 (set_attr "length" "12,12,16,16")])
12705
12706 (define_split
12707 [(set (match_operand:CC 0 "cc_reg_not_cr0_operand" "")
12708 (compare:CC
12709 (and:SI (neg:SI
12710 (geu:SI (match_operand:SI 1 "gpc_reg_operand" "")
12711 (match_operand:SI 2 "reg_or_neg_short_operand" "")))
12712 (match_operand:SI 3 "gpc_reg_operand" ""))
12713 (const_int 0)))
12714 (clobber (match_scratch:SI 4 ""))]
12715 "! TARGET_POWERPC64 && reload_completed"
12716 [(set (match_dup 4)
12717 (and:SI (neg:SI (geu:SI (match_dup 1) (match_dup 2)))
12718 (match_dup 3)))
12719 (set (match_dup 0)
12720 (compare:CC (match_dup 4)
12721 (const_int 0)))]
12722 "")
12723
12724 (define_insn ""
12725 [(set (match_operand:CC 4 "cc_reg_operand" "=x,x,?y,?y")
12726 (compare:CC
12727 (and:SI (neg:SI
12728 (geu:SI (match_operand:SI 1 "gpc_reg_operand" "r,r,r,r")
12729 (match_operand:SI 2 "reg_or_neg_short_operand" "r,P,r,P")))
12730 (match_operand:SI 3 "gpc_reg_operand" "r,r,r,r"))
12731 (const_int 0)))
12732 (set (match_operand:SI 0 "gpc_reg_operand" "=&r,&r,&r,&r")
12733 (and:SI (neg:SI (geu:SI (match_dup 1) (match_dup 2))) (match_dup 3)))]
12734 "! TARGET_POWERPC64"
12735 "@
12736 {sf|subfc} %0,%2,%1\;{sfe|subfe} %0,%0,%0\;andc. %0,%3,%0
12737 {ai|addic} %0,%1,%n2\;{sfe|subfe} %0,%0,%0\;andc. %0,%3,%0
12738 #
12739 #"
12740 [(set_attr "type" "compare")
12741 (set_attr "length" "12,12,16,16")])
12742
12743 (define_split
12744 [(set (match_operand:CC 4 "cc_reg_not_cr0_operand" "")
12745 (compare:CC
12746 (and:SI (neg:SI
12747 (geu:SI (match_operand:SI 1 "gpc_reg_operand" "")
12748 (match_operand:SI 2 "reg_or_neg_short_operand" "")))
12749 (match_operand:SI 3 "gpc_reg_operand" ""))
12750 (const_int 0)))
12751 (set (match_operand:SI 0 "gpc_reg_operand" "")
12752 (and:SI (neg:SI (geu:SI (match_dup 1) (match_dup 2))) (match_dup 3)))]
12753 "! TARGET_POWERPC64 && reload_completed"
12754 [(set (match_dup 0)
12755 (and:SI (neg:SI (geu:SI (match_dup 1) (match_dup 2))) (match_dup 3)))
12756 (set (match_dup 4)
12757 (compare:CC (match_dup 0)
12758 (const_int 0)))]
12759 "")
12760
12761 (define_insn ""
12762 [(set (match_operand:SI 0 "gpc_reg_operand" "=r")
12763 (gt:SI (match_operand:SI 1 "gpc_reg_operand" "r")
12764 (const_int 0)))]
12765 "! TARGET_POWERPC64"
12766 "{sfi|subfic} %0,%1,0\;{ame|addme} %0,%0\;{sri|srwi} %0,%0,31"
12767 [(set_attr "length" "12")])
12768
12769 (define_insn ""
12770 [(set (match_operand:DI 0 "gpc_reg_operand" "=r")
12771 (gt:DI (match_operand:DI 1 "gpc_reg_operand" "r")
12772 (const_int 0)))]
12773 "TARGET_POWERPC64"
12774 "subfic %0,%1,0\;addme %0,%0\;srdi %0,%0,63"
12775 [(set_attr "length" "12")])
12776
12777 (define_insn ""
12778 [(set (match_operand:CC 2 "cc_reg_operand" "=x,?y")
12779 (compare:CC
12780 (gt:SI (match_operand:SI 1 "gpc_reg_operand" "r,r")
12781 (const_int 0))
12782 (const_int 0)))
12783 (set (match_operand:SI 0 "gpc_reg_operand" "=r,r")
12784 (gt:SI (match_dup 1) (const_int 0)))]
12785 "! TARGET_POWERPC64"
12786 "@
12787 {sfi|subfic} %0,%1,0\;{ame|addme} %0,%0\;{sri.|srwi.} %0,%0,31
12788 #"
12789 [(set_attr "type" "delayed_compare")
12790 (set_attr "length" "12,16")])
12791
12792 (define_split
12793 [(set (match_operand:CC 2 "cc_reg_not_cr0_operand" "")
12794 (compare:CC
12795 (gt:SI (match_operand:SI 1 "gpc_reg_operand" "")
12796 (const_int 0))
12797 (const_int 0)))
12798 (set (match_operand:SI 0 "gpc_reg_operand" "")
12799 (gt:SI (match_dup 1) (const_int 0)))]
12800 "! TARGET_POWERPC64 && reload_completed"
12801 [(set (match_dup 0)
12802 (gt:SI (match_dup 1) (const_int 0)))
12803 (set (match_dup 2)
12804 (compare:CC (match_dup 0)
12805 (const_int 0)))]
12806 "")
12807
12808 (define_insn ""
12809 [(set (match_operand:CC 2 "cc_reg_operand" "=x,?y")
12810 (compare:CC
12811 (gt:DI (match_operand:DI 1 "gpc_reg_operand" "r,r")
12812 (const_int 0))
12813 (const_int 0)))
12814 (set (match_operand:DI 0 "gpc_reg_operand" "=r,r")
12815 (gt:DI (match_dup 1) (const_int 0)))]
12816 "TARGET_POWERPC64"
12817 "@
12818 subfic %0,%1,0\;addme %0,%0\;srdi. %0,%0,63
12819 #"
12820 [(set_attr "type" "delayed_compare")
12821 (set_attr "length" "12,16")])
12822
12823 (define_split
12824 [(set (match_operand:CC 2 "cc_reg_not_cr0_operand" "")
12825 (compare:CC
12826 (gt:DI (match_operand:DI 1 "gpc_reg_operand" "")
12827 (const_int 0))
12828 (const_int 0)))
12829 (set (match_operand:DI 0 "gpc_reg_operand" "")
12830 (gt:DI (match_dup 1) (const_int 0)))]
12831 "TARGET_POWERPC64 && reload_completed"
12832 [(set (match_dup 0)
12833 (gt:DI (match_dup 1) (const_int 0)))
12834 (set (match_dup 2)
12835 (compare:CC (match_dup 0)
12836 (const_int 0)))]
12837 "")
12838
12839 (define_insn ""
12840 [(set (match_operand:SI 0 "gpc_reg_operand" "=r")
12841 (gt:SI (match_operand:SI 1 "gpc_reg_operand" "r")
12842 (match_operand:SI 2 "reg_or_short_operand" "r")))]
12843 "TARGET_POWER"
12844 "doz %0,%2,%1\;nabs %0,%0\;{sri|srwi} %0,%0,31"
12845 [(set_attr "length" "12")])
12846
12847 (define_insn ""
12848 [(set (match_operand:CC 3 "cc_reg_operand" "=x,?y")
12849 (compare:CC
12850 (gt:SI (match_operand:SI 1 "gpc_reg_operand" "r,r")
12851 (match_operand:SI 2 "reg_or_short_operand" "r,r"))
12852 (const_int 0)))
12853 (set (match_operand:SI 0 "gpc_reg_operand" "=r,r")
12854 (gt:SI (match_dup 1) (match_dup 2)))]
12855 "TARGET_POWER"
12856 "@
12857 doz %0,%2,%1\;nabs %0,%0\;{sri.|srwi.} %0,%0,31
12858 #"
12859 [(set_attr "type" "delayed_compare")
12860 (set_attr "length" "12,16")])
12861
12862 (define_split
12863 [(set (match_operand:CC 3 "cc_reg_not_cr0_operand" "")
12864 (compare:CC
12865 (gt:SI (match_operand:SI 1 "gpc_reg_operand" "")
12866 (match_operand:SI 2 "reg_or_short_operand" ""))
12867 (const_int 0)))
12868 (set (match_operand:SI 0 "gpc_reg_operand" "")
12869 (gt:SI (match_dup 1) (match_dup 2)))]
12870 "TARGET_POWER && reload_completed"
12871 [(set (match_dup 0)
12872 (gt:SI (match_dup 1) (match_dup 2)))
12873 (set (match_dup 3)
12874 (compare:CC (match_dup 0)
12875 (const_int 0)))]
12876 "")
12877
12878 (define_insn ""
12879 [(set (match_operand:SI 0 "gpc_reg_operand" "=&r")
12880 (plus:SI (gt:SI (match_operand:SI 1 "gpc_reg_operand" "r")
12881 (const_int 0))
12882 (match_operand:SI 2 "gpc_reg_operand" "r")))]
12883 "! TARGET_POWERPC64"
12884 "{a|addc} %0,%1,%1\;{sfe|subfe} %0,%1,%0\;{aze|addze} %0,%2"
12885 [(set_attr "length" "12")])
12886
12887 (define_insn ""
12888 [(set (match_operand:DI 0 "gpc_reg_operand" "=&r")
12889 (plus:DI (gt:DI (match_operand:DI 1 "gpc_reg_operand" "r")
12890 (const_int 0))
12891 (match_operand:DI 2 "gpc_reg_operand" "r")))]
12892 "TARGET_POWERPC64"
12893 "addc %0,%1,%1\;subfe %0,%1,%0\;addze %0,%2"
12894 [(set_attr "length" "12")])
12895
12896 (define_insn ""
12897 [(set (match_operand:CC 0 "cc_reg_operand" "=x,?y")
12898 (compare:CC
12899 (plus:SI (gt:SI (match_operand:SI 1 "gpc_reg_operand" "r,r")
12900 (const_int 0))
12901 (match_operand:SI 2 "gpc_reg_operand" "r,r"))
12902 (const_int 0)))
12903 (clobber (match_scratch:SI 3 "=&r,&r"))]
12904 "! TARGET_POWERPC64"
12905 "@
12906 {a|addc} %3,%1,%1\;{sfe|subfe} %3,%1,%3\;{aze.|addze.} %3,%2
12907 #"
12908 [(set_attr "type" "compare")
12909 (set_attr "length" "12,16")])
12910
12911 (define_split
12912 [(set (match_operand:CC 0 "cc_reg_not_cr0_operand" "")
12913 (compare:CC
12914 (plus:SI (gt:SI (match_operand:SI 1 "gpc_reg_operand" "")
12915 (const_int 0))
12916 (match_operand:SI 2 "gpc_reg_operand" ""))
12917 (const_int 0)))
12918 (clobber (match_scratch:SI 3 ""))]
12919 "! TARGET_POWERPC64 && reload_completed"
12920 [(set (match_dup 3)
12921 (plus:SI (gt:SI (match_dup 1) (const_int 0))
12922 (match_dup 2)))
12923 (set (match_dup 0)
12924 (compare:CC (match_dup 3)
12925 (const_int 0)))]
12926 "")
12927
12928 (define_insn ""
12929 [(set (match_operand:CC 0 "cc_reg_operand" "=x,?y")
12930 (compare:CC
12931 (plus:DI (gt:DI (match_operand:DI 1 "gpc_reg_operand" "r,r")
12932 (const_int 0))
12933 (match_operand:DI 2 "gpc_reg_operand" "r,r"))
12934 (const_int 0)))
12935 (clobber (match_scratch:DI 3 "=&r,&r"))]
12936 "TARGET_POWERPC64"
12937 "@
12938 addc %3,%1,%1\;subfe %3,%1,%3\;addze. %3,%2
12939 #"
12940 [(set_attr "type" "compare")
12941 (set_attr "length" "12,16")])
12942
12943 (define_split
12944 [(set (match_operand:CC 0 "cc_reg_not_cr0_operand" "")
12945 (compare:CC
12946 (plus:DI (gt:DI (match_operand:DI 1 "gpc_reg_operand" "")
12947 (const_int 0))
12948 (match_operand:DI 2 "gpc_reg_operand" ""))
12949 (const_int 0)))
12950 (clobber (match_scratch:DI 3 ""))]
12951 "TARGET_POWERPC64 && reload_completed"
12952 [(set (match_dup 3)
12953 (plus:DI (gt:DI (match_dup 1) (const_int 0))
12954 (match_dup 2)))
12955 (set (match_dup 0)
12956 (compare:CC (match_dup 3)
12957 (const_int 0)))]
12958 "")
12959
12960 (define_insn ""
12961 [(set (match_operand:CC 3 "cc_reg_operand" "=x,?y")
12962 (compare:CC
12963 (plus:SI (gt:SI (match_operand:SI 1 "gpc_reg_operand" "r,r")
12964 (const_int 0))
12965 (match_operand:SI 2 "gpc_reg_operand" "r,r"))
12966 (const_int 0)))
12967 (set (match_operand:SI 0 "gpc_reg_operand" "=&r,&r")
12968 (plus:SI (gt:SI (match_dup 1) (const_int 0)) (match_dup 2)))]
12969 "! TARGET_POWERPC64"
12970 "@
12971 {a|addc} %0,%1,%1\;{sfe|subfe} %0,%1,%0\;{aze.|addze.} %0,%2
12972 #"
12973 [(set_attr "type" "compare")
12974 (set_attr "length" "12,16")])
12975
12976 (define_split
12977 [(set (match_operand:CC 3 "cc_reg_not_cr0_operand" "")
12978 (compare:CC
12979 (plus:SI (gt:SI (match_operand:SI 1 "gpc_reg_operand" "")
12980 (const_int 0))
12981 (match_operand:SI 2 "gpc_reg_operand" ""))
12982 (const_int 0)))
12983 (set (match_operand:SI 0 "gpc_reg_operand" "")
12984 (plus:SI (gt:SI (match_dup 1) (const_int 0)) (match_dup 2)))]
12985 "! TARGET_POWERPC64 && reload_completed"
12986 [(set (match_dup 0)
12987 (plus:SI (gt:SI (match_dup 1) (const_int 0)) (match_dup 2)))
12988 (set (match_dup 3)
12989 (compare:CC (match_dup 0)
12990 (const_int 0)))]
12991 "")
12992
12993 (define_insn ""
12994 [(set (match_operand:CC 3 "cc_reg_operand" "=x,?y")
12995 (compare:CC
12996 (plus:DI (gt:DI (match_operand:DI 1 "gpc_reg_operand" "r,r")
12997 (const_int 0))
12998 (match_operand:DI 2 "gpc_reg_operand" "r,r"))
12999 (const_int 0)))
13000 (set (match_operand:DI 0 "gpc_reg_operand" "=&r,&r")
13001 (plus:DI (gt:DI (match_dup 1) (const_int 0)) (match_dup 2)))]
13002 "TARGET_POWERPC64"
13003 "@
13004 addc %0,%1,%1\;subfe %0,%1,%0\;addze. %0,%2
13005 #"
13006 [(set_attr "type" "compare")
13007 (set_attr "length" "12,16")])
13008
13009 (define_split
13010 [(set (match_operand:CC 3 "cc_reg_not_cr0_operand" "")
13011 (compare:CC
13012 (plus:DI (gt:DI (match_operand:DI 1 "gpc_reg_operand" "")
13013 (const_int 0))
13014 (match_operand:DI 2 "gpc_reg_operand" ""))
13015 (const_int 0)))
13016 (set (match_operand:DI 0 "gpc_reg_operand" "")
13017 (plus:DI (gt:DI (match_dup 1) (const_int 0)) (match_dup 2)))]
13018 "TARGET_POWERPC64 && reload_completed"
13019 [(set (match_dup 0)
13020 (plus:DI (gt:DI (match_dup 1) (const_int 0)) (match_dup 2)))
13021 (set (match_dup 3)
13022 (compare:CC (match_dup 0)
13023 (const_int 0)))]
13024 "")
13025
13026 (define_insn ""
13027 [(set (match_operand:SI 0 "gpc_reg_operand" "=&r")
13028 (plus:SI (gt:SI (match_operand:SI 1 "gpc_reg_operand" "r")
13029 (match_operand:SI 2 "reg_or_short_operand" "r"))
13030 (match_operand:SI 3 "gpc_reg_operand" "r")))]
13031 "TARGET_POWER"
13032 "doz %0,%2,%1\;{ai|addic} %0,%0,-1\;{aze|addze} %0,%3"
13033 [(set_attr "length" "12")])
13034
13035 (define_insn ""
13036 [(set (match_operand:CC 0 "cc_reg_operand" "=x,?y")
13037 (compare:CC
13038 (plus:SI (gt:SI (match_operand:SI 1 "gpc_reg_operand" "r,r")
13039 (match_operand:SI 2 "reg_or_short_operand" "r,r"))
13040 (match_operand:SI 3 "gpc_reg_operand" "r,r"))
13041 (const_int 0)))
13042 (clobber (match_scratch:SI 4 "=&r,&r"))]
13043 "TARGET_POWER"
13044 "@
13045 doz %4,%2,%1\;{ai|addic} %4,%4,-1\;{aze.|addze.} %4,%3
13046 #"
13047 [(set_attr "type" "compare")
13048 (set_attr "length" "12,16")])
13049
13050 (define_split
13051 [(set (match_operand:CC 0 "cc_reg_not_cr0_operand" "")
13052 (compare:CC
13053 (plus:SI (gt:SI (match_operand:SI 1 "gpc_reg_operand" "")
13054 (match_operand:SI 2 "reg_or_short_operand" ""))
13055 (match_operand:SI 3 "gpc_reg_operand" ""))
13056 (const_int 0)))
13057 (clobber (match_scratch:SI 4 ""))]
13058 "TARGET_POWER && reload_completed"
13059 [(set (match_dup 4)
13060 (plus:SI (gt:SI (match_dup 1) (match_dup 2)) (match_dup 3)))
13061 (set (match_dup 0)
13062 (compare:CC (match_dup 4)
13063 (const_int 0)))]
13064 "")
13065
13066 (define_insn ""
13067 [(set (match_operand:CC 4 "cc_reg_operand" "=x,?y")
13068 (compare:CC
13069 (plus:SI (gt:SI (match_operand:SI 1 "gpc_reg_operand" "r,r")
13070 (match_operand:SI 2 "reg_or_short_operand" "r,r"))
13071 (match_operand:SI 3 "gpc_reg_operand" "r,r"))
13072 (const_int 0)))
13073 (set (match_operand:SI 0 "gpc_reg_operand" "=&r,&r")
13074 (plus:SI (gt:SI (match_dup 1) (match_dup 2)) (match_dup 3)))]
13075 "TARGET_POWER"
13076 "@
13077 doz %0,%2,%1\;{ai|addic} %0,%0,-1\;{aze.|addze.} %0,%3
13078 #"
13079 [(set_attr "type" "compare")
13080 (set_attr "length" "12,16")])
13081
13082 (define_split
13083 [(set (match_operand:CC 4 "cc_reg_not_cr0_operand" "")
13084 (compare:CC
13085 (plus:SI (gt:SI (match_operand:SI 1 "gpc_reg_operand" "")
13086 (match_operand:SI 2 "reg_or_short_operand" ""))
13087 (match_operand:SI 3 "gpc_reg_operand" ""))
13088 (const_int 0)))
13089 (set (match_operand:SI 0 "gpc_reg_operand" "")
13090 (plus:SI (gt:SI (match_dup 1) (match_dup 2)) (match_dup 3)))]
13091 "TARGET_POWER && reload_completed"
13092 [(set (match_dup 0)
13093 (plus:SI (gt:SI (match_dup 1) (match_dup 2)) (match_dup 3)))
13094 (set (match_dup 4)
13095 (compare:CC (match_dup 0)
13096 (const_int 0)))]
13097 "")
13098
13099 (define_insn ""
13100 [(set (match_operand:SI 0 "gpc_reg_operand" "=r")
13101 (neg:SI (gt:SI (match_operand:SI 1 "gpc_reg_operand" "r")
13102 (const_int 0))))]
13103 "! TARGET_POWERPC64"
13104 "{sfi|subfic} %0,%1,0\;{ame|addme} %0,%0\;{srai|srawi} %0,%0,31"
13105 [(set_attr "length" "12")])
13106
13107 (define_insn ""
13108 [(set (match_operand:DI 0 "gpc_reg_operand" "=r")
13109 (neg:DI (gt:DI (match_operand:DI 1 "gpc_reg_operand" "r")
13110 (const_int 0))))]
13111 "TARGET_POWERPC64"
13112 "subfic %0,%1,0\;addme %0,%0\;sradi %0,%0,63"
13113 [(set_attr "length" "12")])
13114
13115 (define_insn ""
13116 [(set (match_operand:SI 0 "gpc_reg_operand" "=r")
13117 (neg:SI (gt:SI (match_operand:SI 1 "gpc_reg_operand" "r")
13118 (match_operand:SI 2 "reg_or_short_operand" "r"))))]
13119 "TARGET_POWER"
13120 "doz %0,%2,%1\;nabs %0,%0\;{srai|srawi} %0,%0,31"
13121 [(set_attr "length" "12")])
13122
13123 (define_insn ""
13124 [(set (match_operand:SI 0 "gpc_reg_operand" "=r")
13125 (gtu:SI (match_operand:SI 1 "gpc_reg_operand" "r")
13126 (match_operand:SI 2 "reg_or_short_operand" "rI")))]
13127 "! TARGET_POWERPC64"
13128 "{sf%I2|subf%I2c} %0,%1,%2\;{sfe|subfe} %0,%0,%0\;neg %0,%0"
13129 [(set_attr "length" "12")])
13130
13131 (define_insn ""
13132 [(set (match_operand:DI 0 "gpc_reg_operand" "=r")
13133 (gtu:DI (match_operand:DI 1 "gpc_reg_operand" "r")
13134 (match_operand:DI 2 "reg_or_short_operand" "rI")))]
13135 "TARGET_POWERPC64"
13136 "subf%I2c %0,%1,%2\;subfe %0,%0,%0\;neg %0,%0"
13137 [(set_attr "length" "12")])
13138
13139 (define_insn ""
13140 [(set (match_operand:CC 3 "cc_reg_operand" "=x,?y")
13141 (compare:CC
13142 (gtu:SI (match_operand:SI 1 "gpc_reg_operand" "r,r")
13143 (match_operand:SI 2 "reg_or_short_operand" "rI,rI"))
13144 (const_int 0)))
13145 (set (match_operand:SI 0 "gpc_reg_operand" "=r,r")
13146 (gtu:SI (match_dup 1) (match_dup 2)))]
13147 "! TARGET_POWERPC64"
13148 "@
13149 {sf%I2|subf%I2c} %0,%1,%2\;{sfe|subfe} %0,%0,%0\;neg. %0,%0
13150 #"
13151 [(set_attr "type" "compare")
13152 (set_attr "length" "12,16")])
13153
13154 (define_split
13155 [(set (match_operand:CC 3 "cc_reg_not_cr0_operand" "")
13156 (compare:CC
13157 (gtu:SI (match_operand:SI 1 "gpc_reg_operand" "")
13158 (match_operand:SI 2 "reg_or_short_operand" ""))
13159 (const_int 0)))
13160 (set (match_operand:SI 0 "gpc_reg_operand" "")
13161 (gtu:SI (match_dup 1) (match_dup 2)))]
13162 "! TARGET_POWERPC64 && reload_completed"
13163 [(set (match_dup 0)
13164 (gtu:SI (match_dup 1) (match_dup 2)))
13165 (set (match_dup 3)
13166 (compare:CC (match_dup 0)
13167 (const_int 0)))]
13168 "")
13169
13170 (define_insn ""
13171 [(set (match_operand:CC 3 "cc_reg_operand" "=x,?y")
13172 (compare:CC
13173 (gtu:DI (match_operand:DI 1 "gpc_reg_operand" "r,r")
13174 (match_operand:DI 2 "reg_or_short_operand" "rI,rI"))
13175 (const_int 0)))
13176 (set (match_operand:DI 0 "gpc_reg_operand" "=r,r")
13177 (gtu:DI (match_dup 1) (match_dup 2)))]
13178 "TARGET_POWERPC64"
13179 "@
13180 subf%I2c %0,%1,%2\;subfe %0,%0,%0\;neg. %0,%0
13181 #"
13182 [(set_attr "type" "compare")
13183 (set_attr "length" "12,16")])
13184
13185 (define_split
13186 [(set (match_operand:CC 3 "cc_reg_not_cr0_operand" "")
13187 (compare:CC
13188 (gtu:DI (match_operand:DI 1 "gpc_reg_operand" "")
13189 (match_operand:DI 2 "reg_or_short_operand" ""))
13190 (const_int 0)))
13191 (set (match_operand:DI 0 "gpc_reg_operand" "")
13192 (gtu:DI (match_dup 1) (match_dup 2)))]
13193 "TARGET_POWERPC64 && reload_completed"
13194 [(set (match_dup 0)
13195 (gtu:DI (match_dup 1) (match_dup 2)))
13196 (set (match_dup 3)
13197 (compare:CC (match_dup 0)
13198 (const_int 0)))]
13199 "")
13200
13201 (define_insn ""
13202 [(set (match_operand:SI 0 "gpc_reg_operand" "=&r,&r")
13203 (plus:SI (gtu:SI (match_operand:SI 1 "gpc_reg_operand" "r,r")
13204 (match_operand:SI 2 "reg_or_short_operand" "I,rI"))
13205 (match_operand:SI 3 "reg_or_short_operand" "r,rI")))]
13206 "! TARGET_POWERPC64"
13207 "@
13208 {ai|addic} %0,%1,%k2\;{aze|addze} %0,%3
13209 {sf%I2|subf%I2c} %0,%1,%2\;{sfe|subfe} %0,%0,%0\;{sf%I3|subf%I3c} %0,%0,%3"
13210 [(set_attr "length" "8,12")])
13211
13212 (define_insn ""
13213 [(set (match_operand:DI 0 "gpc_reg_operand" "=&r,&r")
13214 (plus:DI (gtu:DI (match_operand:DI 1 "gpc_reg_operand" "r,r")
13215 (match_operand:DI 2 "reg_or_short_operand" "I,rI"))
13216 (match_operand:DI 3 "reg_or_short_operand" "r,rI")))]
13217 "TARGET_POWERPC64"
13218 "@
13219 addic %0,%1,%k2\;addze %0,%3
13220 subf%I2c %0,%1,%2\;subfe %0,%0,%0\;subf%I3c %0,%0,%3"
13221 [(set_attr "length" "8,12")])
13222
13223 (define_insn ""
13224 [(set (match_operand:CC 0 "cc_reg_operand" "=x,x,?y,?y")
13225 (compare:CC
13226 (plus:SI (gtu:SI (match_operand:SI 1 "gpc_reg_operand" "r,r,r,r")
13227 (match_operand:SI 2 "reg_or_short_operand" "I,r,I,r"))
13228 (match_operand:SI 3 "gpc_reg_operand" "r,r,r,r"))
13229 (const_int 0)))
13230 (clobber (match_scratch:SI 4 "=&r,&r,&r,&r"))]
13231 "! TARGET_POWERPC64"
13232 "@
13233 {ai|addic} %4,%1,%k2\;{aze.|addze.} %4,%3
13234 {sf%I2|subf%I2c} %4,%1,%2\;{sfe|subfe} %4,%4,%4\;{sf.|subfc.} %4,%4,%3
13235 #
13236 #"
13237 [(set_attr "type" "compare")
13238 (set_attr "length" "8,12,12,16")])
13239
13240 (define_split
13241 [(set (match_operand:CC 0 "cc_reg_not_cr0_operand" "")
13242 (compare:CC
13243 (plus:SI (gtu:SI (match_operand:SI 1 "gpc_reg_operand" "")
13244 (match_operand:SI 2 "reg_or_short_operand" ""))
13245 (match_operand:SI 3 "gpc_reg_operand" ""))
13246 (const_int 0)))
13247 (clobber (match_scratch:SI 4 ""))]
13248 "! TARGET_POWERPC64 && reload_completed"
13249 [(set (match_dup 4)
13250 (plus:SI (gtu:SI (match_dup 1) (match_dup 2))
13251 (match_dup 3)))
13252 (set (match_dup 0)
13253 (compare:CC (match_dup 4)
13254 (const_int 0)))]
13255 "")
13256
13257 (define_insn ""
13258 [(set (match_operand:CC 0 "cc_reg_operand" "=x,x,?y,?y")
13259 (compare:CC
13260 (plus:DI (gtu:DI (match_operand:DI 1 "gpc_reg_operand" "r,r,r,r")
13261 (match_operand:DI 2 "reg_or_short_operand" "I,r,I,r"))
13262 (match_operand:DI 3 "gpc_reg_operand" "r,r,r,r"))
13263 (const_int 0)))
13264 (clobber (match_scratch:DI 4 "=&r,&r,&r,&r"))]
13265 "TARGET_POWERPC64"
13266 "@
13267 addic %4,%1,%k2\;addze. %4,%3
13268 subf%I2c %4,%1,%2\;subfe %4,%4,%4\;subfc. %4,%4,%3
13269 #
13270 #"
13271 [(set_attr "type" "compare")
13272 (set_attr "length" "8,12,12,16")])
13273
13274 (define_split
13275 [(set (match_operand:CC 0 "cc_reg_not_cr0_operand" "")
13276 (compare:CC
13277 (plus:DI (gtu:DI (match_operand:DI 1 "gpc_reg_operand" "")
13278 (match_operand:DI 2 "reg_or_short_operand" ""))
13279 (match_operand:DI 3 "gpc_reg_operand" ""))
13280 (const_int 0)))
13281 (clobber (match_scratch:DI 4 ""))]
13282 "TARGET_POWERPC64 && reload_completed"
13283 [(set (match_dup 4)
13284 (plus:DI (gtu:DI (match_dup 1) (match_dup 2))
13285 (match_dup 3)))
13286 (set (match_dup 0)
13287 (compare:CC (match_dup 4)
13288 (const_int 0)))]
13289 "")
13290
13291 (define_insn ""
13292 [(set (match_operand:CC 4 "cc_reg_operand" "=x,x,?y,?y")
13293 (compare:CC
13294 (plus:SI (gtu:SI (match_operand:SI 1 "gpc_reg_operand" "r,r,r,r")
13295 (match_operand:SI 2 "reg_or_short_operand" "I,r,I,r"))
13296 (match_operand:SI 3 "gpc_reg_operand" "r,r,r,r"))
13297 (const_int 0)))
13298 (set (match_operand:SI 0 "gpc_reg_operand" "=&r,&r,&r,&r")
13299 (plus:SI (gtu:SI (match_dup 1) (match_dup 2)) (match_dup 3)))]
13300 "! TARGET_POWERPC64"
13301 "@
13302 {ai|addic} %0,%1,%k2\;{aze.|addze.} %0,%3
13303 {sf%I2|subf%I2c} %0,%1,%2\;{sfe|subfe} %0,%0,%0\;{sf.|subfc.} %0,%0,%3
13304 #
13305 #"
13306 [(set_attr "type" "compare")
13307 (set_attr "length" "8,12,12,16")])
13308
13309 (define_split
13310 [(set (match_operand:CC 4 "cc_reg_not_cr0_operand" "")
13311 (compare:CC
13312 (plus:SI (gtu:SI (match_operand:SI 1 "gpc_reg_operand" "")
13313 (match_operand:SI 2 "reg_or_short_operand" ""))
13314 (match_operand:SI 3 "gpc_reg_operand" ""))
13315 (const_int 0)))
13316 (set (match_operand:SI 0 "gpc_reg_operand" "")
13317 (plus:SI (gtu:SI (match_dup 1) (match_dup 2)) (match_dup 3)))]
13318 "! TARGET_POWERPC64 && reload_completed"
13319 [(set (match_dup 0)
13320 (plus:SI (gtu:SI (match_dup 1) (match_dup 2)) (match_dup 3)))
13321 (set (match_dup 4)
13322 (compare:CC (match_dup 0)
13323 (const_int 0)))]
13324 "")
13325
13326 (define_insn ""
13327 [(set (match_operand:CC 4 "cc_reg_operand" "=x,x,?y,?y")
13328 (compare:CC
13329 (plus:DI (gtu:DI (match_operand:DI 1 "gpc_reg_operand" "r,r,r,r")
13330 (match_operand:DI 2 "reg_or_short_operand" "I,r,I,r"))
13331 (match_operand:DI 3 "gpc_reg_operand" "r,r,r,r"))
13332 (const_int 0)))
13333 (set (match_operand:DI 0 "gpc_reg_operand" "=&r,&r,&r,&r")
13334 (plus:DI (gtu:DI (match_dup 1) (match_dup 2)) (match_dup 3)))]
13335 "TARGET_POWERPC64"
13336 "@
13337 addic %0,%1,%k2\;addze. %0,%3
13338 subf%I2c %0,%1,%2\;subfe %0,%0,%0\;subfc. %0,%0,%3
13339 #
13340 #"
13341 [(set_attr "type" "compare")
13342 (set_attr "length" "8,12,12,16")])
13343
13344 (define_split
13345 [(set (match_operand:CC 4 "cc_reg_not_cr0_operand" "")
13346 (compare:CC
13347 (plus:DI (gtu:DI (match_operand:DI 1 "gpc_reg_operand" "")
13348 (match_operand:DI 2 "reg_or_short_operand" ""))
13349 (match_operand:DI 3 "gpc_reg_operand" ""))
13350 (const_int 0)))
13351 (set (match_operand:DI 0 "gpc_reg_operand" "")
13352 (plus:DI (gtu:DI (match_dup 1) (match_dup 2)) (match_dup 3)))]
13353 "TARGET_POWERPC64 && reload_completed"
13354 [(set (match_dup 0)
13355 (plus:DI (gtu:DI (match_dup 1) (match_dup 2)) (match_dup 3)))
13356 (set (match_dup 4)
13357 (compare:CC (match_dup 0)
13358 (const_int 0)))]
13359 "")
13360
13361 (define_insn ""
13362 [(set (match_operand:SI 0 "gpc_reg_operand" "=r")
13363 (neg:SI (gtu:SI (match_operand:SI 1 "gpc_reg_operand" "r")
13364 (match_operand:SI 2 "reg_or_short_operand" "rI"))))]
13365 "! TARGET_POWERPC64"
13366 "{sf%I2|subf%I2c} %0,%1,%2\;{sfe|subfe} %0,%0,%0"
13367 [(set_attr "length" "8")])
13368
13369 (define_insn ""
13370 [(set (match_operand:DI 0 "gpc_reg_operand" "=r")
13371 (neg:DI (gtu:DI (match_operand:DI 1 "gpc_reg_operand" "r")
13372 (match_operand:DI 2 "reg_or_short_operand" "rI"))))]
13373 "TARGET_POWERPC64"
13374 "subf%I2c %0,%1,%2\;subfe %0,%0,%0"
13375 [(set_attr "length" "8")])
13376 \f
13377 ;; Define both directions of branch and return. If we need a reload
13378 ;; register, we'd rather use CR0 since it is much easier to copy a
13379 ;; register CC value to there.
13380
13381 (define_insn ""
13382 [(set (pc)
13383 (if_then_else (match_operator 1 "branch_comparison_operator"
13384 [(match_operand 2
13385 "cc_reg_operand" "y")
13386 (const_int 0)])
13387 (label_ref (match_operand 0 "" ""))
13388 (pc)))]
13389 ""
13390 "*
13391 {
13392 return output_cbranch (operands[1], \"%l0\", 0, insn);
13393 }"
13394 [(set_attr "type" "branch")])
13395
13396 (define_insn ""
13397 [(set (pc)
13398 (if_then_else (match_operator 0 "branch_comparison_operator"
13399 [(match_operand 1
13400 "cc_reg_operand" "y")
13401 (const_int 0)])
13402 (return)
13403 (pc)))]
13404 "direct_return ()"
13405 "*
13406 {
13407 return output_cbranch (operands[0], NULL, 0, insn);
13408 }"
13409 [(set_attr "type" "branch")
13410 (set_attr "length" "4")])
13411
13412 (define_insn ""
13413 [(set (pc)
13414 (if_then_else (match_operator 1 "branch_comparison_operator"
13415 [(match_operand 2
13416 "cc_reg_operand" "y")
13417 (const_int 0)])
13418 (pc)
13419 (label_ref (match_operand 0 "" ""))))]
13420 ""
13421 "*
13422 {
13423 return output_cbranch (operands[1], \"%l0\", 1, insn);
13424 }"
13425 [(set_attr "type" "branch")])
13426
13427 (define_insn ""
13428 [(set (pc)
13429 (if_then_else (match_operator 0 "branch_comparison_operator"
13430 [(match_operand 1
13431 "cc_reg_operand" "y")
13432 (const_int 0)])
13433 (pc)
13434 (return)))]
13435 "direct_return ()"
13436 "*
13437 {
13438 return output_cbranch (operands[0], NULL, 1, insn);
13439 }"
13440 [(set_attr "type" "branch")
13441 (set_attr "length" "4")])
13442
13443 ;; Logic on condition register values.
13444
13445 ; This pattern matches things like
13446 ; (set (reg:CCEQ 68) (compare:CCEQ (ior:SI (gt:SI (reg:CCFP 68) (const_int 0))
13447 ; (eq:SI (reg:CCFP 68) (const_int 0)))
13448 ; (const_int 1)))
13449 ; which are generated by the branch logic.
13450 ; Prefer destructive operations where BT = BB (for crXX BT,BA,BB)
13451
13452 (define_insn ""
13453 [(set (match_operand:CCEQ 0 "cc_reg_operand" "=y,?y")
13454 (compare:CCEQ (match_operator:SI 1 "boolean_operator"
13455 [(match_operator:SI 2
13456 "branch_positive_comparison_operator"
13457 [(match_operand 3
13458 "cc_reg_operand" "y,y")
13459 (const_int 0)])
13460 (match_operator:SI 4
13461 "branch_positive_comparison_operator"
13462 [(match_operand 5
13463 "cc_reg_operand" "0,y")
13464 (const_int 0)])])
13465 (const_int 1)))]
13466 ""
13467 "cr%q1 %E0,%j2,%j4"
13468 [(set_attr "type" "cr_logical,delayed_cr")])
13469
13470 ; Why is the constant -1 here, but 1 in the previous pattern?
13471 ; Because ~1 has all but the low bit set.
13472 (define_insn ""
13473 [(set (match_operand:CCEQ 0 "cc_reg_operand" "=y,?y")
13474 (compare:CCEQ (match_operator:SI 1 "boolean_or_operator"
13475 [(not:SI (match_operator:SI 2
13476 "branch_positive_comparison_operator"
13477 [(match_operand 3
13478 "cc_reg_operand" "y,y")
13479 (const_int 0)]))
13480 (match_operator:SI 4
13481 "branch_positive_comparison_operator"
13482 [(match_operand 5
13483 "cc_reg_operand" "0,y")
13484 (const_int 0)])])
13485 (const_int -1)))]
13486 ""
13487 "cr%q1 %E0,%j2,%j4"
13488 [(set_attr "type" "cr_logical,delayed_cr")])
13489
13490 (define_insn ""
13491 [(set (match_operand:CCEQ 0 "cc_reg_operand" "=y,?y")
13492 (compare:CCEQ (match_operator:SI 1
13493 "branch_positive_comparison_operator"
13494 [(match_operand 2
13495 "cc_reg_operand" "0,y")
13496 (const_int 0)])
13497 (const_int 0)))]
13498 "!TARGET_SPE"
13499 "{crnor %E0,%j1,%j1|crnot %E0,%j1}"
13500 [(set_attr "type" "cr_logical,delayed_cr")])
13501
13502 ;; If we are comparing the result of two comparisons, this can be done
13503 ;; using creqv or crxor.
13504
13505 (define_insn_and_split ""
13506 [(set (match_operand:CCEQ 0 "cc_reg_operand" "=y")
13507 (compare:CCEQ (match_operator 1 "branch_comparison_operator"
13508 [(match_operand 2 "cc_reg_operand" "y")
13509 (const_int 0)])
13510 (match_operator 3 "branch_comparison_operator"
13511 [(match_operand 4 "cc_reg_operand" "y")
13512 (const_int 0)])))]
13513 ""
13514 "#"
13515 ""
13516 [(set (match_dup 0) (compare:CCEQ (xor:SI (match_dup 1) (match_dup 3))
13517 (match_dup 5)))]
13518 "
13519 {
13520 int positive_1, positive_2;
13521
13522 positive_1 = branch_positive_comparison_operator (operands[1], CCEQmode);
13523 positive_2 = branch_positive_comparison_operator (operands[3], CCEQmode);
13524
13525 if (! positive_1)
13526 operands[1] = gen_rtx (rs6000_reverse_condition (GET_MODE (operands[2]),
13527 GET_CODE (operands[1])),
13528 SImode,
13529 operands[2], const0_rtx);
13530 else if (GET_MODE (operands[1]) != SImode)
13531 operands[1] = gen_rtx (GET_CODE (operands[1]),
13532 SImode,
13533 operands[2], const0_rtx);
13534
13535 if (! positive_2)
13536 operands[3] = gen_rtx (rs6000_reverse_condition (GET_MODE (operands[4]),
13537 GET_CODE (operands[3])),
13538 SImode,
13539 operands[4], const0_rtx);
13540 else if (GET_MODE (operands[3]) != SImode)
13541 operands[3] = gen_rtx (GET_CODE (operands[3]),
13542 SImode,
13543 operands[4], const0_rtx);
13544
13545 if (positive_1 == positive_2)
13546 {
13547 operands[1] = gen_rtx_NOT (SImode, operands[1]);
13548 operands[5] = constm1_rtx;
13549 }
13550 else
13551 {
13552 operands[5] = const1_rtx;
13553 }
13554 }")
13555
13556 ;; Unconditional branch and return.
13557
13558 (define_insn "jump"
13559 [(set (pc)
13560 (label_ref (match_operand 0 "" "")))]
13561 ""
13562 "b %l0"
13563 [(set_attr "type" "branch")])
13564
13565 (define_insn "return"
13566 [(return)]
13567 "direct_return ()"
13568 "{br|blr}"
13569 [(set_attr "type" "jmpreg")])
13570
13571 (define_expand "indirect_jump"
13572 [(set (pc) (match_operand 0 "register_operand" ""))]
13573 ""
13574 "
13575 {
13576 if (TARGET_32BIT)
13577 emit_jump_insn (gen_indirect_jumpsi (operands[0]));
13578 else
13579 emit_jump_insn (gen_indirect_jumpdi (operands[0]));
13580 DONE;
13581 }")
13582
13583 (define_insn "indirect_jumpsi"
13584 [(set (pc) (match_operand:SI 0 "register_operand" "c,*l"))]
13585 "TARGET_32BIT"
13586 "@
13587 bctr
13588 {br|blr}"
13589 [(set_attr "type" "jmpreg")])
13590
13591 (define_insn "indirect_jumpdi"
13592 [(set (pc) (match_operand:DI 0 "register_operand" "c,*l"))]
13593 "TARGET_64BIT"
13594 "@
13595 bctr
13596 blr"
13597 [(set_attr "type" "jmpreg")])
13598
13599 ;; Table jump for switch statements:
13600 (define_expand "tablejump"
13601 [(use (match_operand 0 "" ""))
13602 (use (label_ref (match_operand 1 "" "")))]
13603 ""
13604 "
13605 {
13606 if (TARGET_32BIT)
13607 emit_jump_insn (gen_tablejumpsi (operands[0], operands[1]));
13608 else
13609 emit_jump_insn (gen_tablejumpdi (operands[0], operands[1]));
13610 DONE;
13611 }")
13612
13613 (define_expand "tablejumpsi"
13614 [(set (match_dup 3)
13615 (plus:SI (match_operand:SI 0 "" "")
13616 (match_dup 2)))
13617 (parallel [(set (pc) (match_dup 3))
13618 (use (label_ref (match_operand 1 "" "")))])]
13619 "TARGET_32BIT"
13620 "
13621 { operands[0] = force_reg (SImode, operands[0]);
13622 operands[2] = force_reg (SImode, gen_rtx_LABEL_REF (SImode, operands[1]));
13623 operands[3] = gen_reg_rtx (SImode);
13624 }")
13625
13626 (define_expand "tablejumpdi"
13627 [(set (match_dup 4)
13628 (sign_extend:DI (match_operand:SI 0 "lwa_operand" "rm")))
13629 (set (match_dup 3)
13630 (plus:DI (match_dup 4)
13631 (match_dup 2)))
13632 (parallel [(set (pc) (match_dup 3))
13633 (use (label_ref (match_operand 1 "" "")))])]
13634 "TARGET_64BIT"
13635 "
13636 { operands[2] = force_reg (DImode, gen_rtx_LABEL_REF (DImode, operands[1]));
13637 operands[3] = gen_reg_rtx (DImode);
13638 operands[4] = gen_reg_rtx (DImode);
13639 }")
13640
13641 (define_insn ""
13642 [(set (pc)
13643 (match_operand:SI 0 "register_operand" "c,*l"))
13644 (use (label_ref (match_operand 1 "" "")))]
13645 "TARGET_32BIT"
13646 "@
13647 bctr
13648 {br|blr}"
13649 [(set_attr "type" "jmpreg")])
13650
13651 (define_insn ""
13652 [(set (pc)
13653 (match_operand:DI 0 "register_operand" "c,*l"))
13654 (use (label_ref (match_operand 1 "" "")))]
13655 "TARGET_64BIT"
13656 "@
13657 bctr
13658 blr"
13659 [(set_attr "type" "jmpreg")])
13660
13661 (define_insn "nop"
13662 [(const_int 0)]
13663 ""
13664 "{cror 0,0,0|nop}")
13665 \f
13666 ;; Define the subtract-one-and-jump insns, starting with the template
13667 ;; so loop.c knows what to generate.
13668
13669 (define_expand "doloop_end"
13670 [(use (match_operand 0 "" "")) ; loop pseudo
13671 (use (match_operand 1 "" "")) ; iterations; zero if unknown
13672 (use (match_operand 2 "" "")) ; max iterations
13673 (use (match_operand 3 "" "")) ; loop level
13674 (use (match_operand 4 "" ""))] ; label
13675 ""
13676 "
13677 {
13678 /* Only use this on innermost loops. */
13679 if (INTVAL (operands[3]) > 1)
13680 FAIL;
13681 if (TARGET_POWERPC64)
13682 {
13683 if (GET_MODE (operands[0]) != DImode)
13684 FAIL;
13685 emit_jump_insn (gen_ctrdi (operands[0], operands[4]));
13686 }
13687 else
13688 {
13689 if (GET_MODE (operands[0]) != SImode)
13690 FAIL;
13691 emit_jump_insn (gen_ctrsi (operands[0], operands[4]));
13692 }
13693 DONE;
13694 }")
13695
13696 (define_expand "ctrsi"
13697 [(parallel [(set (pc)
13698 (if_then_else (ne (match_operand:SI 0 "register_operand" "")
13699 (const_int 1))
13700 (label_ref (match_operand 1 "" ""))
13701 (pc)))
13702 (set (match_dup 0)
13703 (plus:SI (match_dup 0)
13704 (const_int -1)))
13705 (clobber (match_scratch:CC 2 ""))
13706 (clobber (match_scratch:SI 3 ""))])]
13707 "! TARGET_POWERPC64"
13708 "")
13709
13710 (define_expand "ctrdi"
13711 [(parallel [(set (pc)
13712 (if_then_else (ne (match_operand:DI 0 "register_operand" "")
13713 (const_int 1))
13714 (label_ref (match_operand 1 "" ""))
13715 (pc)))
13716 (set (match_dup 0)
13717 (plus:DI (match_dup 0)
13718 (const_int -1)))
13719 (clobber (match_scratch:CC 2 ""))
13720 (clobber (match_scratch:DI 3 ""))])]
13721 "TARGET_POWERPC64"
13722 "")
13723
13724 ;; We need to be able to do this for any operand, including MEM, or we
13725 ;; will cause reload to blow up since we don't allow output reloads on
13726 ;; JUMP_INSNs.
13727 ;; For the length attribute to be calculated correctly, the
13728 ;; label MUST be operand 0.
13729
13730 (define_insn "*ctrsi_internal1"
13731 [(set (pc)
13732 (if_then_else (ne (match_operand:SI 1 "register_operand" "c,*r,*r")
13733 (const_int 1))
13734 (label_ref (match_operand 0 "" ""))
13735 (pc)))
13736 (set (match_operand:SI 2 "register_operand" "=1,*r,m*q*c*l")
13737 (plus:SI (match_dup 1)
13738 (const_int -1)))
13739 (clobber (match_scratch:CC 3 "=X,&x,&x"))
13740 (clobber (match_scratch:SI 4 "=X,X,r"))]
13741 "! TARGET_POWERPC64"
13742 "*
13743 {
13744 if (which_alternative != 0)
13745 return \"#\";
13746 else if (get_attr_length (insn) == 4)
13747 return \"{bdn|bdnz} %l0\";
13748 else
13749 return \"bdz $+8\;b %l0\";
13750 }"
13751 [(set_attr "type" "branch")
13752 (set_attr "length" "4,12,16")])
13753
13754 (define_insn "*ctrsi_internal2"
13755 [(set (pc)
13756 (if_then_else (ne (match_operand:SI 1 "register_operand" "c,*r,*r")
13757 (const_int 1))
13758 (pc)
13759 (label_ref (match_operand 0 "" ""))))
13760 (set (match_operand:SI 2 "register_operand" "=1,*r,m*q*c*l")
13761 (plus:SI (match_dup 1)
13762 (const_int -1)))
13763 (clobber (match_scratch:CC 3 "=X,&x,&x"))
13764 (clobber (match_scratch:SI 4 "=X,X,r"))]
13765 "! TARGET_POWERPC64"
13766 "*
13767 {
13768 if (which_alternative != 0)
13769 return \"#\";
13770 else if (get_attr_length (insn) == 4)
13771 return \"bdz %l0\";
13772 else
13773 return \"{bdn|bdnz} $+8\;b %l0\";
13774 }"
13775 [(set_attr "type" "branch")
13776 (set_attr "length" "4,12,16")])
13777
13778 (define_insn "*ctrdi_internal1"
13779 [(set (pc)
13780 (if_then_else (ne (match_operand:DI 1 "register_operand" "c,*r,*r")
13781 (const_int 1))
13782 (label_ref (match_operand 0 "" ""))
13783 (pc)))
13784 (set (match_operand:DI 2 "register_operand" "=1,*r,m*c*l")
13785 (plus:DI (match_dup 1)
13786 (const_int -1)))
13787 (clobber (match_scratch:CC 3 "=X,&x,&x"))
13788 (clobber (match_scratch:DI 4 "=X,X,r"))]
13789 "TARGET_POWERPC64"
13790 "*
13791 {
13792 if (which_alternative != 0)
13793 return \"#\";
13794 else if (get_attr_length (insn) == 4)
13795 return \"{bdn|bdnz} %l0\";
13796 else
13797 return \"bdz $+8\;b %l0\";
13798 }"
13799 [(set_attr "type" "branch")
13800 (set_attr "length" "4,12,16")])
13801
13802 (define_insn "*ctrdi_internal2"
13803 [(set (pc)
13804 (if_then_else (ne (match_operand:DI 1 "register_operand" "c,*r,*r")
13805 (const_int 1))
13806 (pc)
13807 (label_ref (match_operand 0 "" ""))))
13808 (set (match_operand:DI 2 "register_operand" "=1,*r,m*c*l")
13809 (plus:DI (match_dup 1)
13810 (const_int -1)))
13811 (clobber (match_scratch:CC 3 "=X,&x,&x"))
13812 (clobber (match_scratch:DI 4 "=X,X,r"))]
13813 "TARGET_POWERPC64"
13814 "*
13815 {
13816 if (which_alternative != 0)
13817 return \"#\";
13818 else if (get_attr_length (insn) == 4)
13819 return \"bdz %l0\";
13820 else
13821 return \"{bdn|bdnz} $+8\;b %l0\";
13822 }"
13823 [(set_attr "type" "branch")
13824 (set_attr "length" "4,12,16")])
13825
13826 ;; Similar, but we can use GE since we have a REG_NONNEG.
13827
13828 (define_insn "*ctrsi_internal3"
13829 [(set (pc)
13830 (if_then_else (ge (match_operand:SI 1 "register_operand" "c,*r,*r")
13831 (const_int 0))
13832 (label_ref (match_operand 0 "" ""))
13833 (pc)))
13834 (set (match_operand:SI 2 "register_operand" "=1,*r,m*q*c*l")
13835 (plus:SI (match_dup 1)
13836 (const_int -1)))
13837 (clobber (match_scratch:CC 3 "=X,&x,&X"))
13838 (clobber (match_scratch:SI 4 "=X,X,r"))]
13839 "! TARGET_POWERPC64 && find_reg_note (insn, REG_NONNEG, 0)"
13840 "*
13841 {
13842 if (which_alternative != 0)
13843 return \"#\";
13844 else if (get_attr_length (insn) == 4)
13845 return \"{bdn|bdnz} %l0\";
13846 else
13847 return \"bdz $+8\;b %l0\";
13848 }"
13849 [(set_attr "type" "branch")
13850 (set_attr "length" "4,12,16")])
13851
13852 (define_insn "*ctrsi_internal4"
13853 [(set (pc)
13854 (if_then_else (ge (match_operand:SI 1 "register_operand" "c,*r,*r")
13855 (const_int 0))
13856 (pc)
13857 (label_ref (match_operand 0 "" ""))))
13858 (set (match_operand:SI 2 "register_operand" "=1,*r,m*q*c*l")
13859 (plus:SI (match_dup 1)
13860 (const_int -1)))
13861 (clobber (match_scratch:CC 3 "=X,&x,&X"))
13862 (clobber (match_scratch:SI 4 "=X,X,r"))]
13863 "! TARGET_POWERPC64 && find_reg_note (insn, REG_NONNEG, 0)"
13864 "*
13865 {
13866 if (which_alternative != 0)
13867 return \"#\";
13868 else if (get_attr_length (insn) == 4)
13869 return \"bdz %l0\";
13870 else
13871 return \"{bdn|bdnz} $+8\;b %l0\";
13872 }"
13873 [(set_attr "type" "branch")
13874 (set_attr "length" "4,12,16")])
13875
13876 (define_insn "*ctrdi_internal3"
13877 [(set (pc)
13878 (if_then_else (ge (match_operand:DI 1 "register_operand" "c,*r,*r")
13879 (const_int 0))
13880 (label_ref (match_operand 0 "" ""))
13881 (pc)))
13882 (set (match_operand:DI 2 "register_operand" "=1,*r,m*c*l")
13883 (plus:DI (match_dup 1)
13884 (const_int -1)))
13885 (clobber (match_scratch:CC 3 "=X,&x,&x"))
13886 (clobber (match_scratch:DI 4 "=X,X,r"))]
13887 "TARGET_POWERPC64 && find_reg_note (insn, REG_NONNEG, 0)"
13888 "*
13889 {
13890 if (which_alternative != 0)
13891 return \"#\";
13892 else if (get_attr_length (insn) == 4)
13893 return \"{bdn|bdnz} %l0\";
13894 else
13895 return \"bdz $+8\;b %l0\";
13896 }"
13897 [(set_attr "type" "branch")
13898 (set_attr "length" "4,12,16")])
13899
13900 (define_insn "*ctrdi_internal4"
13901 [(set (pc)
13902 (if_then_else (ge (match_operand:DI 1 "register_operand" "c,*r,*r")
13903 (const_int 0))
13904 (pc)
13905 (label_ref (match_operand 0 "" ""))))
13906 (set (match_operand:DI 2 "register_operand" "=1,*r,m*c*l")
13907 (plus:DI (match_dup 1)
13908 (const_int -1)))
13909 (clobber (match_scratch:CC 3 "=X,&x,&x"))
13910 (clobber (match_scratch:DI 4 "=X,X,r"))]
13911 "TARGET_POWERPC64 && find_reg_note (insn, REG_NONNEG, 0)"
13912 "*
13913 {
13914 if (which_alternative != 0)
13915 return \"#\";
13916 else if (get_attr_length (insn) == 4)
13917 return \"bdz %l0\";
13918 else
13919 return \"{bdn|bdnz} $+8\;b %l0\";
13920 }"
13921 [(set_attr "type" "branch")
13922 (set_attr "length" "4,12,16")])
13923
13924 ;; Similar but use EQ
13925
13926 (define_insn "*ctrsi_internal5"
13927 [(set (pc)
13928 (if_then_else (eq (match_operand:SI 1 "register_operand" "c,*r,*r")
13929 (const_int 1))
13930 (label_ref (match_operand 0 "" ""))
13931 (pc)))
13932 (set (match_operand:SI 2 "register_operand" "=1,*r,m*q*c*l")
13933 (plus:SI (match_dup 1)
13934 (const_int -1)))
13935 (clobber (match_scratch:CC 3 "=X,&x,&x"))
13936 (clobber (match_scratch:SI 4 "=X,X,r"))]
13937 "! TARGET_POWERPC64"
13938 "*
13939 {
13940 if (which_alternative != 0)
13941 return \"#\";
13942 else if (get_attr_length (insn) == 4)
13943 return \"bdz %l0\";
13944 else
13945 return \"{bdn|bdnz} $+8\;b %l0\";
13946 }"
13947 [(set_attr "type" "branch")
13948 (set_attr "length" "4,12,16")])
13949
13950 (define_insn "*ctrsi_internal6"
13951 [(set (pc)
13952 (if_then_else (eq (match_operand:SI 1 "register_operand" "c,*r,*r")
13953 (const_int 1))
13954 (pc)
13955 (label_ref (match_operand 0 "" ""))))
13956 (set (match_operand:SI 2 "register_operand" "=1,*r,m*q*c*l")
13957 (plus:SI (match_dup 1)
13958 (const_int -1)))
13959 (clobber (match_scratch:CC 3 "=X,&x,&x"))
13960 (clobber (match_scratch:SI 4 "=X,X,r"))]
13961 "! TARGET_POWERPC64"
13962 "*
13963 {
13964 if (which_alternative != 0)
13965 return \"#\";
13966 else if (get_attr_length (insn) == 4)
13967 return \"{bdn|bdnz} %l0\";
13968 else
13969 return \"bdz $+8\;b %l0\";
13970 }"
13971 [(set_attr "type" "branch")
13972 (set_attr "length" "4,12,16")])
13973
13974 (define_insn "*ctrdi_internal5"
13975 [(set (pc)
13976 (if_then_else (eq (match_operand:DI 1 "register_operand" "c,*r,*r")
13977 (const_int 1))
13978 (label_ref (match_operand 0 "" ""))
13979 (pc)))
13980 (set (match_operand:DI 2 "register_operand" "=1,*r,m*c*l")
13981 (plus:DI (match_dup 1)
13982 (const_int -1)))
13983 (clobber (match_scratch:CC 3 "=X,&x,&x"))
13984 (clobber (match_scratch:DI 4 "=X,X,r"))]
13985 "TARGET_POWERPC64"
13986 "*
13987 {
13988 if (which_alternative != 0)
13989 return \"#\";
13990 else if (get_attr_length (insn) == 4)
13991 return \"bdz %l0\";
13992 else
13993 return \"{bdn|bdnz} $+8\;b %l0\";
13994 }"
13995 [(set_attr "type" "branch")
13996 (set_attr "length" "4,12,16")])
13997
13998 (define_insn "*ctrdi_internal6"
13999 [(set (pc)
14000 (if_then_else (eq (match_operand:DI 1 "register_operand" "c,*r,*r")
14001 (const_int 1))
14002 (pc)
14003 (label_ref (match_operand 0 "" ""))))
14004 (set (match_operand:DI 2 "register_operand" "=1,*r,m*c*l")
14005 (plus:DI (match_dup 1)
14006 (const_int -1)))
14007 (clobber (match_scratch:CC 3 "=X,&x,&x"))
14008 (clobber (match_scratch:DI 4 "=X,X,r"))]
14009 "TARGET_POWERPC64"
14010 "*
14011 {
14012 if (which_alternative != 0)
14013 return \"#\";
14014 else if (get_attr_length (insn) == 4)
14015 return \"{bdn|bdnz} %l0\";
14016 else
14017 return \"bdz $+8\;b %l0\";
14018 }"
14019 [(set_attr "type" "branch")
14020 (set_attr "length" "4,12,16")])
14021
14022 ;; Now the splitters if we could not allocate the CTR register
14023
14024 (define_split
14025 [(set (pc)
14026 (if_then_else (match_operator 2 "comparison_operator"
14027 [(match_operand:SI 1 "gpc_reg_operand" "")
14028 (const_int 1)])
14029 (match_operand 5 "" "")
14030 (match_operand 6 "" "")))
14031 (set (match_operand:SI 0 "gpc_reg_operand" "")
14032 (plus:SI (match_dup 1)
14033 (const_int -1)))
14034 (clobber (match_scratch:CC 3 ""))
14035 (clobber (match_scratch:SI 4 ""))]
14036 "! TARGET_POWERPC64 && reload_completed"
14037 [(parallel [(set (match_dup 3)
14038 (compare:CC (plus:SI (match_dup 1)
14039 (const_int -1))
14040 (const_int 0)))
14041 (set (match_dup 0)
14042 (plus:SI (match_dup 1)
14043 (const_int -1)))])
14044 (set (pc) (if_then_else (match_dup 7)
14045 (match_dup 5)
14046 (match_dup 6)))]
14047 "
14048 { operands[7] = gen_rtx (GET_CODE (operands[2]), VOIDmode, operands[3],
14049 const0_rtx); }")
14050
14051 (define_split
14052 [(set (pc)
14053 (if_then_else (match_operator 2 "comparison_operator"
14054 [(match_operand:SI 1 "gpc_reg_operand" "")
14055 (const_int 1)])
14056 (match_operand 5 "" "")
14057 (match_operand 6 "" "")))
14058 (set (match_operand:SI 0 "nonimmediate_operand" "")
14059 (plus:SI (match_dup 1) (const_int -1)))
14060 (clobber (match_scratch:CC 3 ""))
14061 (clobber (match_scratch:SI 4 ""))]
14062 "! TARGET_POWERPC64 && reload_completed
14063 && ! gpc_reg_operand (operands[0], SImode)"
14064 [(parallel [(set (match_dup 3)
14065 (compare:CC (plus:SI (match_dup 1)
14066 (const_int -1))
14067 (const_int 0)))
14068 (set (match_dup 4)
14069 (plus:SI (match_dup 1)
14070 (const_int -1)))])
14071 (set (match_dup 0)
14072 (match_dup 4))
14073 (set (pc) (if_then_else (match_dup 7)
14074 (match_dup 5)
14075 (match_dup 6)))]
14076 "
14077 { operands[7] = gen_rtx (GET_CODE (operands[2]), VOIDmode, operands[3],
14078 const0_rtx); }")
14079 (define_split
14080 [(set (pc)
14081 (if_then_else (match_operator 2 "comparison_operator"
14082 [(match_operand:DI 1 "gpc_reg_operand" "")
14083 (const_int 1)])
14084 (match_operand 5 "" "")
14085 (match_operand 6 "" "")))
14086 (set (match_operand:DI 0 "gpc_reg_operand" "")
14087 (plus:DI (match_dup 1)
14088 (const_int -1)))
14089 (clobber (match_scratch:CC 3 ""))
14090 (clobber (match_scratch:DI 4 ""))]
14091 "TARGET_POWERPC64 && reload_completed"
14092 [(parallel [(set (match_dup 3)
14093 (compare:CC (plus:DI (match_dup 1)
14094 (const_int -1))
14095 (const_int 0)))
14096 (set (match_dup 0)
14097 (plus:DI (match_dup 1)
14098 (const_int -1)))])
14099 (set (pc) (if_then_else (match_dup 7)
14100 (match_dup 5)
14101 (match_dup 6)))]
14102 "
14103 { operands[7] = gen_rtx (GET_CODE (operands[2]), VOIDmode, operands[3],
14104 const0_rtx); }")
14105
14106 (define_split
14107 [(set (pc)
14108 (if_then_else (match_operator 2 "comparison_operator"
14109 [(match_operand:DI 1 "gpc_reg_operand" "")
14110 (const_int 1)])
14111 (match_operand 5 "" "")
14112 (match_operand 6 "" "")))
14113 (set (match_operand:DI 0 "nonimmediate_operand" "")
14114 (plus:DI (match_dup 1) (const_int -1)))
14115 (clobber (match_scratch:CC 3 ""))
14116 (clobber (match_scratch:DI 4 ""))]
14117 "TARGET_POWERPC64 && reload_completed
14118 && ! gpc_reg_operand (operands[0], DImode)"
14119 [(parallel [(set (match_dup 3)
14120 (compare:CC (plus:DI (match_dup 1)
14121 (const_int -1))
14122 (const_int 0)))
14123 (set (match_dup 4)
14124 (plus:DI (match_dup 1)
14125 (const_int -1)))])
14126 (set (match_dup 0)
14127 (match_dup 4))
14128 (set (pc) (if_then_else (match_dup 7)
14129 (match_dup 5)
14130 (match_dup 6)))]
14131 "
14132 { operands[7] = gen_rtx (GET_CODE (operands[2]), VOIDmode, operands[3],
14133 const0_rtx); }")
14134
14135 \f
14136 (define_insn "trap"
14137 [(trap_if (const_int 1) (const_int 0))]
14138 ""
14139 "{t 31,0,0|trap}")
14140
14141 (define_expand "conditional_trap"
14142 [(trap_if (match_operator 0 "trap_comparison_operator"
14143 [(match_dup 2) (match_dup 3)])
14144 (match_operand 1 "const_int_operand" ""))]
14145 ""
14146 "if (rs6000_compare_fp_p || operands[1] != const0_rtx) FAIL;
14147 operands[2] = rs6000_compare_op0;
14148 operands[3] = rs6000_compare_op1;")
14149
14150 (define_insn ""
14151 [(trap_if (match_operator 0 "trap_comparison_operator"
14152 [(match_operand:SI 1 "register_operand" "r")
14153 (match_operand:SI 2 "reg_or_short_operand" "rI")])
14154 (const_int 0))]
14155 ""
14156 "{t|tw}%V0%I2 %1,%2")
14157
14158 (define_insn ""
14159 [(trap_if (match_operator 0 "trap_comparison_operator"
14160 [(match_operand:DI 1 "register_operand" "r")
14161 (match_operand:DI 2 "reg_or_short_operand" "rI")])
14162 (const_int 0))]
14163 "TARGET_POWERPC64"
14164 "td%V0%I2 %1,%2")
14165 \f
14166 ;; Insns related to generating the function prologue and epilogue.
14167
14168 (define_expand "prologue"
14169 [(use (const_int 0))]
14170 "TARGET_SCHED_PROLOG"
14171 "
14172 {
14173 rs6000_emit_prologue ();
14174 DONE;
14175 }")
14176
14177 (define_insn "movesi_from_cr"
14178 [(set (match_operand:SI 0 "gpc_reg_operand" "=r")
14179 (unspec:SI [(reg:CC 68) (reg:CC 69) (reg:CC 70) (reg:CC 71)
14180 (reg:CC 72) (reg:CC 73) (reg:CC 74) (reg:CC 75)] 19))]
14181 ""
14182 "mfcr %0"
14183 [(set_attr "type" "mfcr")])
14184
14185 (define_insn "*stmw"
14186 [(match_parallel 0 "stmw_operation"
14187 [(set (match_operand:SI 1 "memory_operand" "=m")
14188 (match_operand:SI 2 "gpc_reg_operand" "r"))])]
14189 "TARGET_MULTIPLE"
14190 "{stm|stmw} %2,%1")
14191
14192 (define_insn "*save_fpregs_si"
14193 [(match_parallel 0 "any_operand"
14194 [(clobber (match_operand:SI 1 "register_operand" "=l"))
14195 (use (match_operand:SI 2 "call_operand" "s"))
14196 (set (match_operand:DF 3 "memory_operand" "=m")
14197 (match_operand:DF 4 "gpc_reg_operand" "f"))])]
14198 "TARGET_32BIT"
14199 "bl %z2")
14200
14201 (define_insn "*save_fpregs_di"
14202 [(match_parallel 0 "any_operand"
14203 [(clobber (match_operand:DI 1 "register_operand" "=l"))
14204 (use (match_operand:DI 2 "call_operand" "s"))
14205 (set (match_operand:DF 3 "memory_operand" "=m")
14206 (match_operand:DF 4 "gpc_reg_operand" "f"))])]
14207 "TARGET_64BIT"
14208 "bl %z2")
14209
14210 ; These are to explain that changes to the stack pointer should
14211 ; not be moved over stores to stack memory.
14212 (define_insn "stack_tie"
14213 [(set (match_operand:BLK 0 "memory_operand" "+m")
14214 (unspec:BLK [(match_dup 0)] 5))]
14215 ""
14216 ""
14217 [(set_attr "length" "0")])
14218
14219
14220 (define_expand "epilogue"
14221 [(use (const_int 0))]
14222 "TARGET_SCHED_PROLOG"
14223 "
14224 {
14225 rs6000_emit_epilogue (FALSE);
14226 DONE;
14227 }")
14228
14229 ; On some processors, doing the mtcrf one CC register at a time is
14230 ; faster (like on the 604e). On others, doing them all at once is
14231 ; faster; for instance, on the 601 and 750.
14232
14233 (define_expand "movsi_to_cr_one"
14234 [(set (match_operand:CC 0 "cc_reg_operand" "=y")
14235 (unspec:CC [(match_operand:SI 1 "gpc_reg_operand" "r")
14236 (match_dup 2)] 20))]
14237 ""
14238 "operands[2] = GEN_INT (1 << (75 - REGNO (operands[0])));")
14239
14240 (define_insn "*movsi_to_cr"
14241 [(match_parallel 0 "mtcrf_operation"
14242 [(set (match_operand:CC 1 "cc_reg_operand" "=y")
14243 (unspec:CC [(match_operand:SI 2 "gpc_reg_operand" "r")
14244 (match_operand 3 "immediate_operand" "n")]
14245 20))])]
14246 ""
14247 "*
14248 {
14249 int mask = 0;
14250 int i;
14251 for (i = 0; i < XVECLEN (operands[0], 0); i++)
14252 mask |= INTVAL (XVECEXP (SET_SRC (XVECEXP (operands[0], 0, i)), 0, 1));
14253 operands[4] = GEN_INT (mask);
14254 return \"mtcrf %4,%2\";
14255 }"
14256 [(set_attr "type" "mtcr")])
14257
14258 (define_insn "*mtcrfsi"
14259 [(set (match_operand:CC 0 "cc_reg_operand" "=y")
14260 (unspec:CC [(match_operand:SI 1 "gpc_reg_operand" "r")
14261 (match_operand 2 "immediate_operand" "n")] 20))]
14262 "GET_CODE (operands[0]) == REG
14263 && CR_REGNO_P (REGNO (operands[0]))
14264 && GET_CODE (operands[2]) == CONST_INT
14265 && INTVAL (operands[2]) == 1 << (75 - REGNO (operands[0]))"
14266 "mtcrf %R0,%1"
14267 [(set_attr "type" "mtcr")])
14268
14269 ; The load-multiple instructions have similar properties.
14270 ; Note that "load_multiple" is a name known to the machine-independent
14271 ; code that actually corresponds to the powerpc load-string.
14272
14273 (define_insn "*lmw"
14274 [(match_parallel 0 "lmw_operation"
14275 [(set (match_operand:SI 1 "gpc_reg_operand" "=r")
14276 (match_operand:SI 2 "memory_operand" "m"))])]
14277 "TARGET_MULTIPLE"
14278 "{lm|lmw} %1,%2")
14279
14280 (define_insn "*return_internal_si"
14281 [(return)
14282 (use (match_operand:SI 0 "register_operand" "lc"))]
14283 "TARGET_32BIT"
14284 "b%T0"
14285 [(set_attr "type" "jmpreg")])
14286
14287 (define_insn "*return_internal_di"
14288 [(return)
14289 (use (match_operand:DI 0 "register_operand" "lc"))]
14290 "TARGET_64BIT"
14291 "b%T0"
14292 [(set_attr "type" "jmpreg")])
14293
14294 ; FIXME: This would probably be somewhat simpler if the Cygnus sibcall
14295 ; stuff was in GCC. Oh, and "any_operand" is a bit flexible...
14296
14297 (define_insn "*return_and_restore_fpregs_si"
14298 [(match_parallel 0 "any_operand"
14299 [(return)
14300 (use (match_operand:SI 1 "register_operand" "l"))
14301 (use (match_operand:SI 2 "call_operand" "s"))
14302 (set (match_operand:DF 3 "gpc_reg_operand" "=f")
14303 (match_operand:DF 4 "memory_operand" "m"))])]
14304 "TARGET_32BIT"
14305 "b %z2")
14306
14307 (define_insn "*return_and_restore_fpregs_di"
14308 [(match_parallel 0 "any_operand"
14309 [(return)
14310 (use (match_operand:DI 1 "register_operand" "l"))
14311 (use (match_operand:DI 2 "call_operand" "s"))
14312 (set (match_operand:DF 3 "gpc_reg_operand" "=f")
14313 (match_operand:DF 4 "memory_operand" "m"))])]
14314 "TARGET_64BIT"
14315 "b %z2")
14316
14317 ; This is used in compiling the unwind routines.
14318 (define_expand "eh_return"
14319 [(use (match_operand 0 "general_operand" ""))
14320 (use (match_operand 1 "general_operand" ""))]
14321 ""
14322 "
14323 {
14324 #if TARGET_AIX
14325 rs6000_emit_eh_toc_restore (operands[0]);
14326 #endif
14327 if (TARGET_32BIT)
14328 emit_insn (gen_eh_set_lr_si (operands[1]));
14329 else
14330 emit_insn (gen_eh_set_lr_di (operands[1]));
14331 emit_move_insn (EH_RETURN_STACKADJ_RTX, operands[0]);
14332 DONE;
14333 }")
14334
14335 ; We can't expand this before we know where the link register is stored.
14336 (define_insn "eh_set_lr_si"
14337 [(unspec_volatile [(match_operand:SI 0 "register_operand" "r")] 9)
14338 (clobber (match_scratch:SI 1 "=&b"))]
14339 "TARGET_32BIT"
14340 "#")
14341
14342 (define_insn "eh_set_lr_di"
14343 [(unspec_volatile [(match_operand:DI 0 "register_operand" "r")] 9)
14344 (clobber (match_scratch:DI 1 "=&b"))]
14345 "TARGET_64BIT"
14346 "#")
14347
14348 (define_split
14349 [(unspec_volatile [(match_operand 0 "register_operand" "")] 9)
14350 (clobber (match_scratch 1 ""))]
14351 "reload_completed"
14352 [(const_int 0)]
14353 "
14354 {
14355 rs6000_stack_t *info = rs6000_stack_info ();
14356
14357 if (info->lr_save_p)
14358 {
14359 rtx frame_rtx = stack_pointer_rtx;
14360 int sp_offset = 0;
14361 rtx tmp;
14362
14363 if (frame_pointer_needed
14364 || current_function_calls_alloca
14365 || info->total_size > 32767)
14366 {
14367 emit_move_insn (operands[1], gen_rtx_MEM (Pmode, frame_rtx));
14368 frame_rtx = operands[1];
14369 }
14370 else if (info->push_p)
14371 sp_offset = info->total_size;
14372
14373 tmp = plus_constant (frame_rtx, info->lr_save_offset + sp_offset);
14374 tmp = gen_rtx_MEM (Pmode, tmp);
14375 emit_move_insn (tmp, operands[0]);
14376 }
14377 else
14378 emit_move_insn (gen_rtx_REG (Pmode, LINK_REGISTER_REGNUM), operands[0]);
14379 DONE;
14380 }")
14381
14382 (define_insn "prefetch"
14383 [(prefetch (match_operand:V4SI 0 "address_operand" "p")
14384 (match_operand:SI 1 "const_int_operand" "n")
14385 (match_operand:SI 2 "const_int_operand" "n"))]
14386 "TARGET_POWERPC"
14387 "*
14388 {
14389 if (GET_CODE (operands[0]) == REG)
14390 return INTVAL (operands[1]) ? \"dcbtst 0,%0\" : \"dcbt 0,%0\";
14391 return INTVAL (operands[1]) ? \"dcbtst %a0\" : \"dcbt %a0\";
14392 }"
14393 [(set_attr "type" "load")])
14394
14395 (include "altivec.md")
14396 (include "spe.md")