]> git.ipfire.org Git - thirdparty/gcc.git/blame - gcc/config/rs6000/rs6000.md
tree-flow-inline.h (get_def_ops, [...]): Add operand structure reference.
[thirdparty/gcc.git] / gcc / config / rs6000 / rs6000.md
CommitLineData
996a5f59 1;; Machine description for IBM RISC System 6000 (POWER) for GNU C compiler
d24652ee 2;; Copyright (C) 1990, 1991, 1992, 1993, 1994, 1995, 1996, 1997, 1998,
affad9a4 3;; 1999, 2000, 2001, 2002, 2003, 2004 Free Software Foundation, Inc.
996a5f59 4;; Contributed by Richard Kenner (kenner@vlsi1.ultra.nyu.edu)
1fd4e8c1 5
5de601cf 6;; This file is part of GCC.
1fd4e8c1 7
5de601cf
NC
8;; GCC is free software; you can redistribute it and/or modify it
9;; under the terms of the GNU General Public License as published
10;; by the Free Software Foundation; either version 2, or (at your
11;; option) any later version.
1fd4e8c1 12
5de601cf
NC
13;; GCC is distributed in the hope that it will be useful, but WITHOUT
14;; ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
15;; or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public
16;; License for more details.
1fd4e8c1
RK
17
18;; You should have received a copy of the GNU General Public License
5de601cf
NC
19;; along with GCC; see the file COPYING. If not, write to the
20;; Free Software Foundation, 59 Temple Place - Suite 330, Boston,
21;; MA 02111-1307, USA.
1fd4e8c1
RK
22
23;;- See file "rtl.def" for documentation on define_insn, match_*, et. al.
9ebbca7d 24
615158e2
JJ
25;;
26;; UNSPEC usage
27;;
28
29(define_constants
30 [(UNSPEC_FRSP 0) ; frsp for POWER machines
31 (UNSPEC_TIE 5) ; tie stack contents and stack pointer
32 (UNSPEC_TOCPTR 6) ; address of a word pointing to the TOC
33 (UNSPEC_TOC 7) ; address of the TOC (more-or-less)
34 (UNSPEC_MOVSI_GOT 8)
35 (UNSPEC_MV_CR_OV 9) ; move_from_CR_ov_bit
36 (UNSPEC_FCTIWZ 10)
37 (UNSPEC_LD_MPIC 15) ; load_macho_picbase
38 (UNSPEC_MPIC_CORRECT 16) ; macho_correct_pic
39 (UNSPEC_TLSGD 17)
40 (UNSPEC_TLSLD 18)
41 (UNSPEC_MOVESI_FROM_CR 19)
42 (UNSPEC_MOVESI_TO_CR 20)
43 (UNSPEC_TLSDTPREL 21)
44 (UNSPEC_TLSDTPRELHA 22)
45 (UNSPEC_TLSDTPRELLO 23)
46 (UNSPEC_TLSGOTDTPREL 24)
47 (UNSPEC_TLSTPREL 25)
48 (UNSPEC_TLSTPRELHA 26)
49 (UNSPEC_TLSTPRELLO 27)
50 (UNSPEC_TLSGOTTPREL 28)
51 (UNSPEC_TLSTLS 29)
ecb62ae7 52 (UNSPEC_FIX_TRUNC_TF 30) ; fadd, rounding towards zero
6b1fedc3 53 (UNSPEC_MV_CR_EQ 31) ; move_from_CR_eq_bit
615158e2
JJ
54 ])
55
56;;
57;; UNSPEC_VOLATILE usage
58;;
59
60(define_constants
61 [(UNSPECV_BLOCK 0)
62 (UNSPECV_EH_RR 9) ; eh_reg_restore
63 ])
1fd4e8c1
RK
64\f
65;; Define an insn type attribute. This is used in function unit delay
66;; computations.
2c4a9cff 67(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,insert_word,branch,cmp,fast_compare,compare,delayed_compare,imul_compare,lmul_compare,fpcompare,cr_logical,delayed_cr,mfcr,mfcrf,mtcr,mfjmpr,mtjmpr,fp,fpsimple,dmul,sdiv,ddiv,ssqrt,dsqrt,jmpreg,brinc,vecsimple,veccomplex,vecdiv,veccmp,veccmpsimple,vecperm,vecfloat,vecfdiv"
1fd4e8c1
RK
68 (const_string "integer"))
69
b19003d8 70;; Length (in bytes).
6ae08853 71; '(pc)' in the following doesn't include the instruction itself; it is
6cbadf36 72; calculated as if the instruction had zero size.
b19003d8
RK
73(define_attr "length" ""
74 (if_then_else (eq_attr "type" "branch")
6cbadf36 75 (if_then_else (and (ge (minus (match_dup 0) (pc))
b19003d8 76 (const_int -32768))
6cbadf36
GK
77 (lt (minus (match_dup 0) (pc))
78 (const_int 32764)))
39a10a29
GK
79 (const_int 4)
80 (const_int 8))
b19003d8
RK
81 (const_int 4)))
82
cfb557c4
RK
83;; Processor type -- this attribute must exactly match the processor_type
84;; enumeration in rs6000.h.
85
ec507f2d 86(define_attr "cpu" "rios1,rios2,rs64a,mpccore,ppc403,ppc405,ppc440,ppc601,ppc603,ppc604,ppc604e,ppc620,ppc630,ppc750,ppc7400,ppc7450,ppc8540,power4,power5"
cfb557c4
RK
87 (const (symbol_ref "rs6000_cpu_attr")))
88
b54cf83a
DE
89(automata_option "ndfa")
90
91(include "rios1.md")
92(include "rios2.md")
93(include "rs64.md")
94(include "mpc.md")
95(include "40x.md")
02ca7595 96(include "440.md")
b54cf83a
DE
97(include "603.md")
98(include "6xx.md")
99(include "7xx.md")
100(include "7450.md")
5e8006fa 101(include "8540.md")
b54cf83a 102(include "power4.md")
ec507f2d 103(include "power5.md")
309323c2 104
1fd4e8c1
RK
105\f
106;; Start with fixed-point load and store insns. Here we put only the more
107;; complex forms. Basic data transfer is done later.
108
51b8fc2c
RK
109(define_expand "zero_extendqidi2"
110 [(set (match_operand:DI 0 "gpc_reg_operand" "")
111 (zero_extend:DI (match_operand:QI 1 "gpc_reg_operand" "")))]
112 "TARGET_POWERPC64"
113 "")
114
115(define_insn ""
116 [(set (match_operand:DI 0 "gpc_reg_operand" "=r,r")
117 (zero_extend:DI (match_operand:QI 1 "reg_or_mem_operand" "m,r")))]
118 "TARGET_POWERPC64"
119 "@
120 lbz%U1%X1 %0,%1
4371f8af 121 rldicl %0,%1,0,56"
51b8fc2c
RK
122 [(set_attr "type" "load,*")])
123
124(define_insn ""
9ebbca7d
GK
125 [(set (match_operand:CC 0 "cc_reg_operand" "=x,?y")
126 (compare:CC (zero_extend:DI (match_operand:QI 1 "gpc_reg_operand" "r,r"))
815cdc52 127 (const_int 0)))
9ebbca7d 128 (clobber (match_scratch:DI 2 "=r,r"))]
683bdff7 129 "TARGET_64BIT"
9ebbca7d
GK
130 "@
131 rldicl. %2,%1,0,56
132 #"
133 [(set_attr "type" "compare")
134 (set_attr "length" "4,8")])
135
136(define_split
137 [(set (match_operand:CC 0 "cc_reg_not_cr0_operand" "")
138 (compare:CC (zero_extend:DI (match_operand:QI 1 "gpc_reg_operand" ""))
139 (const_int 0)))
140 (clobber (match_scratch:DI 2 ""))]
141 "TARGET_POWERPC64 && reload_completed"
142 [(set (match_dup 2)
143 (zero_extend:DI (match_dup 1)))
144 (set (match_dup 0)
145 (compare:CC (match_dup 2)
146 (const_int 0)))]
147 "")
51b8fc2c
RK
148
149(define_insn ""
9ebbca7d
GK
150 [(set (match_operand:CC 2 "cc_reg_operand" "=x,?y")
151 (compare:CC (zero_extend:DI (match_operand:QI 1 "gpc_reg_operand" "r,r"))
51b8fc2c 152 (const_int 0)))
9ebbca7d 153 (set (match_operand:DI 0 "gpc_reg_operand" "=r,r")
51b8fc2c 154 (zero_extend:DI (match_dup 1)))]
683bdff7 155 "TARGET_64BIT"
9ebbca7d
GK
156 "@
157 rldicl. %0,%1,0,56
158 #"
159 [(set_attr "type" "compare")
160 (set_attr "length" "4,8")])
161
162(define_split
163 [(set (match_operand:CC 2 "cc_reg_not_cr0_operand" "")
164 (compare:CC (zero_extend:DI (match_operand:QI 1 "gpc_reg_operand" ""))
165 (const_int 0)))
166 (set (match_operand:DI 0 "gpc_reg_operand" "")
167 (zero_extend:DI (match_dup 1)))]
168 "TARGET_POWERPC64 && reload_completed"
169 [(set (match_dup 0)
170 (zero_extend:DI (match_dup 1)))
171 (set (match_dup 2)
172 (compare:CC (match_dup 0)
173 (const_int 0)))]
174 "")
51b8fc2c 175
2bee0449
RK
176(define_insn "extendqidi2"
177 [(set (match_operand:DI 0 "gpc_reg_operand" "=r")
178 (sign_extend:DI (match_operand:QI 1 "gpc_reg_operand" "r")))]
51b8fc2c 179 "TARGET_POWERPC64"
2bee0449 180 "extsb %0,%1")
51b8fc2c
RK
181
182(define_insn ""
9ebbca7d
GK
183 [(set (match_operand:CC 0 "cc_reg_operand" "=x,?y")
184 (compare:CC (sign_extend:DI (match_operand:QI 1 "gpc_reg_operand" "r,r"))
51b8fc2c 185 (const_int 0)))
9ebbca7d 186 (clobber (match_scratch:DI 2 "=r,r"))]
683bdff7 187 "TARGET_64BIT"
9ebbca7d
GK
188 "@
189 extsb. %2,%1
190 #"
191 [(set_attr "type" "compare")
192 (set_attr "length" "4,8")])
193
194(define_split
195 [(set (match_operand:CC 0 "cc_reg_not_cr0_operand" "")
196 (compare:CC (sign_extend:DI (match_operand:QI 1 "gpc_reg_operand" ""))
197 (const_int 0)))
198 (clobber (match_scratch:DI 2 ""))]
199 "TARGET_POWERPC64 && reload_completed"
200 [(set (match_dup 2)
201 (sign_extend:DI (match_dup 1)))
202 (set (match_dup 0)
203 (compare:CC (match_dup 2)
204 (const_int 0)))]
205 "")
51b8fc2c
RK
206
207(define_insn ""
9ebbca7d
GK
208 [(set (match_operand:CC 2 "cc_reg_operand" "=x,?y")
209 (compare:CC (sign_extend:DI (match_operand:QI 1 "gpc_reg_operand" "r,r"))
51b8fc2c 210 (const_int 0)))
9ebbca7d 211 (set (match_operand:DI 0 "gpc_reg_operand" "=r,r")
51b8fc2c 212 (sign_extend:DI (match_dup 1)))]
683bdff7 213 "TARGET_64BIT"
9ebbca7d
GK
214 "@
215 extsb. %0,%1
216 #"
217 [(set_attr "type" "compare")
218 (set_attr "length" "4,8")])
219
220(define_split
221 [(set (match_operand:CC 2 "cc_reg_not_cr0_operand" "")
222 (compare:CC (sign_extend:DI (match_operand:QI 1 "gpc_reg_operand" ""))
223 (const_int 0)))
224 (set (match_operand:DI 0 "gpc_reg_operand" "")
225 (sign_extend:DI (match_dup 1)))]
226 "TARGET_POWERPC64 && reload_completed"
227 [(set (match_dup 0)
228 (sign_extend:DI (match_dup 1)))
229 (set (match_dup 2)
230 (compare:CC (match_dup 0)
231 (const_int 0)))]
232 "")
51b8fc2c
RK
233
234(define_expand "zero_extendhidi2"
235 [(set (match_operand:DI 0 "gpc_reg_operand" "")
236 (zero_extend:DI (match_operand:HI 1 "gpc_reg_operand" "")))]
237 "TARGET_POWERPC64"
238 "")
239
240(define_insn ""
241 [(set (match_operand:DI 0 "gpc_reg_operand" "=r,r")
242 (zero_extend:DI (match_operand:HI 1 "reg_or_mem_operand" "m,r")))]
243 "TARGET_POWERPC64"
244 "@
245 lhz%U1%X1 %0,%1
4371f8af 246 rldicl %0,%1,0,48"
51b8fc2c
RK
247 [(set_attr "type" "load,*")])
248
249(define_insn ""
9ebbca7d
GK
250 [(set (match_operand:CC 0 "cc_reg_operand" "=x,?y")
251 (compare:CC (zero_extend:DI (match_operand:HI 1 "gpc_reg_operand" "r,r"))
51b8fc2c 252 (const_int 0)))
9ebbca7d 253 (clobber (match_scratch:DI 2 "=r,r"))]
683bdff7 254 "TARGET_64BIT"
9ebbca7d
GK
255 "@
256 rldicl. %2,%1,0,48
257 #"
258 [(set_attr "type" "compare")
259 (set_attr "length" "4,8")])
260
261(define_split
262 [(set (match_operand:CC 0 "cc_reg_not_cr0_operand" "")
263 (compare:CC (zero_extend:DI (match_operand:HI 1 "gpc_reg_operand" ""))
264 (const_int 0)))
265 (clobber (match_scratch:DI 2 ""))]
266 "TARGET_POWERPC64 && reload_completed"
267 [(set (match_dup 2)
268 (zero_extend:DI (match_dup 1)))
269 (set (match_dup 0)
270 (compare:CC (match_dup 2)
271 (const_int 0)))]
272 "")
51b8fc2c
RK
273
274(define_insn ""
9ebbca7d
GK
275 [(set (match_operand:CC 2 "cc_reg_operand" "=x,?y")
276 (compare:CC (zero_extend:DI (match_operand:HI 1 "gpc_reg_operand" "r,r"))
51b8fc2c 277 (const_int 0)))
9ebbca7d 278 (set (match_operand:DI 0 "gpc_reg_operand" "=r,r")
51b8fc2c 279 (zero_extend:DI (match_dup 1)))]
683bdff7 280 "TARGET_64BIT"
9ebbca7d
GK
281 "@
282 rldicl. %0,%1,0,48
283 #"
284 [(set_attr "type" "compare")
285 (set_attr "length" "4,8")])
286
287(define_split
288 [(set (match_operand:CC 2 "cc_reg_not_cr0_operand" "")
289 (compare:CC (zero_extend:DI (match_operand:HI 1 "gpc_reg_operand" ""))
290 (const_int 0)))
291 (set (match_operand:DI 0 "gpc_reg_operand" "")
292 (zero_extend:DI (match_dup 1)))]
293 "TARGET_POWERPC64 && reload_completed"
294 [(set (match_dup 0)
295 (zero_extend:DI (match_dup 1)))
296 (set (match_dup 2)
297 (compare:CC (match_dup 0)
298 (const_int 0)))]
299 "")
51b8fc2c
RK
300
301(define_expand "extendhidi2"
302 [(set (match_operand:DI 0 "gpc_reg_operand" "")
303 (sign_extend:DI (match_operand:HI 1 "gpc_reg_operand" "")))]
304 "TARGET_POWERPC64"
305 "")
306
307(define_insn ""
308 [(set (match_operand:DI 0 "gpc_reg_operand" "=r,r")
309 (sign_extend:DI (match_operand:HI 1 "reg_or_mem_operand" "m,r")))]
310 "TARGET_POWERPC64"
311 "@
312 lha%U1%X1 %0,%1
313 extsh %0,%1"
b54cf83a 314 [(set_attr "type" "load_ext,*")])
51b8fc2c
RK
315
316(define_insn ""
9ebbca7d
GK
317 [(set (match_operand:CC 0 "cc_reg_operand" "=x,?y")
318 (compare:CC (sign_extend:DI (match_operand:HI 1 "gpc_reg_operand" "r,r"))
51b8fc2c 319 (const_int 0)))
9ebbca7d 320 (clobber (match_scratch:DI 2 "=r,r"))]
683bdff7 321 "TARGET_64BIT"
9ebbca7d
GK
322 "@
323 extsh. %2,%1
324 #"
325 [(set_attr "type" "compare")
326 (set_attr "length" "4,8")])
327
328(define_split
329 [(set (match_operand:CC 0 "cc_reg_not_cr0_operand" "")
330 (compare:CC (sign_extend:DI (match_operand:HI 1 "gpc_reg_operand" ""))
331 (const_int 0)))
332 (clobber (match_scratch:DI 2 ""))]
333 "TARGET_POWERPC64 && reload_completed"
334 [(set (match_dup 2)
335 (sign_extend:DI (match_dup 1)))
336 (set (match_dup 0)
337 (compare:CC (match_dup 2)
338 (const_int 0)))]
339 "")
51b8fc2c
RK
340
341(define_insn ""
9ebbca7d
GK
342 [(set (match_operand:CC 2 "cc_reg_operand" "=x,?y")
343 (compare:CC (sign_extend:DI (match_operand:HI 1 "gpc_reg_operand" "r,r"))
51b8fc2c 344 (const_int 0)))
9ebbca7d 345 (set (match_operand:DI 0 "gpc_reg_operand" "=r,r")
51b8fc2c 346 (sign_extend:DI (match_dup 1)))]
683bdff7 347 "TARGET_64BIT"
9ebbca7d
GK
348 "@
349 extsh. %0,%1
350 #"
351 [(set_attr "type" "compare")
352 (set_attr "length" "4,8")])
353
354(define_split
355 [(set (match_operand:CC 2 "cc_reg_not_cr0_operand" "")
356 (compare:CC (sign_extend:DI (match_operand:HI 1 "gpc_reg_operand" ""))
357 (const_int 0)))
358 (set (match_operand:DI 0 "gpc_reg_operand" "")
359 (sign_extend:DI (match_dup 1)))]
360 "TARGET_POWERPC64 && reload_completed"
361 [(set (match_dup 0)
362 (sign_extend:DI (match_dup 1)))
363 (set (match_dup 2)
364 (compare:CC (match_dup 0)
365 (const_int 0)))]
366 "")
51b8fc2c
RK
367
368(define_expand "zero_extendsidi2"
369 [(set (match_operand:DI 0 "gpc_reg_operand" "")
370 (zero_extend:DI (match_operand:SI 1 "gpc_reg_operand" "")))]
371 "TARGET_POWERPC64"
372 "")
373
374(define_insn ""
375 [(set (match_operand:DI 0 "gpc_reg_operand" "=r,r")
376 (zero_extend:DI (match_operand:SI 1 "reg_or_mem_operand" "m,r")))]
377 "TARGET_POWERPC64"
378 "@
379 lwz%U1%X1 %0,%1
380 rldicl %0,%1,0,32"
381 [(set_attr "type" "load,*")])
382
383(define_insn ""
9ebbca7d
GK
384 [(set (match_operand:CC 0 "cc_reg_operand" "=x,?y")
385 (compare:CC (zero_extend:DI (match_operand:SI 1 "gpc_reg_operand" "r,r"))
51b8fc2c 386 (const_int 0)))
9ebbca7d 387 (clobber (match_scratch:DI 2 "=r,r"))]
683bdff7 388 "TARGET_64BIT"
9ebbca7d
GK
389 "@
390 rldicl. %2,%1,0,32
391 #"
392 [(set_attr "type" "compare")
393 (set_attr "length" "4,8")])
394
395(define_split
396 [(set (match_operand:CC 0 "cc_reg_not_cr0_operand" "")
397 (compare:CC (zero_extend:DI (match_operand:SI 1 "gpc_reg_operand" ""))
398 (const_int 0)))
399 (clobber (match_scratch:DI 2 ""))]
400 "TARGET_POWERPC64 && reload_completed"
401 [(set (match_dup 2)
402 (zero_extend:DI (match_dup 1)))
403 (set (match_dup 0)
404 (compare:CC (match_dup 2)
405 (const_int 0)))]
406 "")
51b8fc2c
RK
407
408(define_insn ""
9ebbca7d
GK
409 [(set (match_operand:CC 2 "cc_reg_operand" "=x,?y")
410 (compare:CC (zero_extend:DI (match_operand:SI 1 "gpc_reg_operand" "r,r"))
51b8fc2c 411 (const_int 0)))
9ebbca7d 412 (set (match_operand:DI 0 "gpc_reg_operand" "=r,r")
51b8fc2c 413 (zero_extend:DI (match_dup 1)))]
683bdff7 414 "TARGET_64BIT"
9ebbca7d
GK
415 "@
416 rldicl. %0,%1,0,32
417 #"
418 [(set_attr "type" "compare")
419 (set_attr "length" "4,8")])
420
421(define_split
422 [(set (match_operand:CC 2 "cc_reg_not_cr0_operand" "")
423 (compare:CC (zero_extend:DI (match_operand:SI 1 "gpc_reg_operand" ""))
424 (const_int 0)))
425 (set (match_operand:DI 0 "gpc_reg_operand" "")
426 (zero_extend:DI (match_dup 1)))]
427 "TARGET_POWERPC64 && reload_completed"
428 [(set (match_dup 0)
429 (zero_extend:DI (match_dup 1)))
430 (set (match_dup 2)
431 (compare:CC (match_dup 0)
432 (const_int 0)))]
433 "")
51b8fc2c
RK
434
435(define_expand "extendsidi2"
436 [(set (match_operand:DI 0 "gpc_reg_operand" "")
437 (sign_extend:DI (match_operand:SI 1 "gpc_reg_operand" "")))]
438 "TARGET_POWERPC64"
439 "")
440
441(define_insn ""
442 [(set (match_operand:DI 0 "gpc_reg_operand" "=r,r")
287f13ff 443 (sign_extend:DI (match_operand:SI 1 "lwa_operand" "m,r")))]
51b8fc2c
RK
444 "TARGET_POWERPC64"
445 "@
446 lwa%U1%X1 %0,%1
447 extsw %0,%1"
b54cf83a 448 [(set_attr "type" "load_ext,*")])
51b8fc2c
RK
449
450(define_insn ""
9ebbca7d
GK
451 [(set (match_operand:CC 0 "cc_reg_operand" "=x,?y")
452 (compare:CC (sign_extend:DI (match_operand:SI 1 "gpc_reg_operand" "r,r"))
51b8fc2c 453 (const_int 0)))
9ebbca7d 454 (clobber (match_scratch:DI 2 "=r,r"))]
683bdff7 455 "TARGET_64BIT"
9ebbca7d
GK
456 "@
457 extsw. %2,%1
458 #"
459 [(set_attr "type" "compare")
460 (set_attr "length" "4,8")])
461
462(define_split
463 [(set (match_operand:CC 0 "cc_reg_not_cr0_operand" "")
464 (compare:CC (sign_extend:DI (match_operand:SI 1 "gpc_reg_operand" ""))
465 (const_int 0)))
466 (clobber (match_scratch:DI 2 ""))]
467 "TARGET_POWERPC64 && reload_completed"
468 [(set (match_dup 2)
469 (sign_extend:DI (match_dup 1)))
470 (set (match_dup 0)
471 (compare:CC (match_dup 2)
472 (const_int 0)))]
473 "")
51b8fc2c
RK
474
475(define_insn ""
9ebbca7d
GK
476 [(set (match_operand:CC 2 "cc_reg_operand" "=x,?y")
477 (compare:CC (sign_extend:DI (match_operand:SI 1 "gpc_reg_operand" "r,r"))
51b8fc2c 478 (const_int 0)))
9ebbca7d 479 (set (match_operand:DI 0 "gpc_reg_operand" "=r,r")
51b8fc2c 480 (sign_extend:DI (match_dup 1)))]
683bdff7 481 "TARGET_64BIT"
9ebbca7d
GK
482 "@
483 extsw. %0,%1
484 #"
485 [(set_attr "type" "compare")
486 (set_attr "length" "4,8")])
487
488(define_split
489 [(set (match_operand:CC 2 "cc_reg_not_cr0_operand" "")
490 (compare:CC (sign_extend:DI (match_operand:SI 1 "gpc_reg_operand" ""))
491 (const_int 0)))
492 (set (match_operand:DI 0 "gpc_reg_operand" "")
493 (sign_extend:DI (match_dup 1)))]
494 "TARGET_POWERPC64 && reload_completed"
495 [(set (match_dup 0)
496 (sign_extend:DI (match_dup 1)))
497 (set (match_dup 2)
498 (compare:CC (match_dup 0)
499 (const_int 0)))]
500 "")
51b8fc2c 501
1fd4e8c1 502(define_expand "zero_extendqisi2"
cd2b37d9
RK
503 [(set (match_operand:SI 0 "gpc_reg_operand" "")
504 (zero_extend:SI (match_operand:QI 1 "gpc_reg_operand" "")))]
1fd4e8c1
RK
505 ""
506 "")
507
508(define_insn ""
cd2b37d9 509 [(set (match_operand:SI 0 "gpc_reg_operand" "=r,r")
1fd4e8c1
RK
510 (zero_extend:SI (match_operand:QI 1 "reg_or_mem_operand" "m,r")))]
511 ""
512 "@
513 lbz%U1%X1 %0,%1
005a35b9 514 {rlinm|rlwinm} %0,%1,0,0xff"
1fd4e8c1
RK
515 [(set_attr "type" "load,*")])
516
517(define_insn ""
9ebbca7d
GK
518 [(set (match_operand:CC 0 "cc_reg_operand" "=x,?y")
519 (compare:CC (zero_extend:SI (match_operand:QI 1 "gpc_reg_operand" "r,r"))
1fd4e8c1 520 (const_int 0)))
9ebbca7d 521 (clobber (match_scratch:SI 2 "=r,r"))]
1fd4e8c1 522 ""
9ebbca7d
GK
523 "@
524 {andil.|andi.} %2,%1,0xff
525 #"
526 [(set_attr "type" "compare")
527 (set_attr "length" "4,8")])
528
529(define_split
530 [(set (match_operand:CC 0 "cc_reg_not_cr0_operand" "")
531 (compare:CC (zero_extend:SI (match_operand:QI 1 "gpc_reg_operand" ""))
532 (const_int 0)))
533 (clobber (match_scratch:SI 2 ""))]
534 "reload_completed"
535 [(set (match_dup 2)
536 (zero_extend:SI (match_dup 1)))
537 (set (match_dup 0)
538 (compare:CC (match_dup 2)
539 (const_int 0)))]
540 "")
1fd4e8c1
RK
541
542(define_insn ""
9ebbca7d
GK
543 [(set (match_operand:CC 2 "cc_reg_operand" "=x,?y")
544 (compare:CC (zero_extend:SI (match_operand:QI 1 "gpc_reg_operand" "r,r"))
1fd4e8c1 545 (const_int 0)))
9ebbca7d 546 (set (match_operand:SI 0 "gpc_reg_operand" "=r,r")
1fd4e8c1
RK
547 (zero_extend:SI (match_dup 1)))]
548 ""
9ebbca7d
GK
549 "@
550 {andil.|andi.} %0,%1,0xff
551 #"
552 [(set_attr "type" "compare")
553 (set_attr "length" "4,8")])
554
555(define_split
556 [(set (match_operand:CC 2 "cc_reg_not_cr0_operand" "")
557 (compare:CC (zero_extend:SI (match_operand:QI 1 "gpc_reg_operand" ""))
558 (const_int 0)))
559 (set (match_operand:SI 0 "gpc_reg_operand" "")
560 (zero_extend:SI (match_dup 1)))]
561 "reload_completed"
562 [(set (match_dup 0)
563 (zero_extend:SI (match_dup 1)))
564 (set (match_dup 2)
565 (compare:CC (match_dup 0)
566 (const_int 0)))]
567 "")
1fd4e8c1 568
51b8fc2c
RK
569(define_expand "extendqisi2"
570 [(use (match_operand:SI 0 "gpc_reg_operand" ""))
571 (use (match_operand:QI 1 "gpc_reg_operand" ""))]
572 ""
573 "
574{
575 if (TARGET_POWERPC)
576 emit_insn (gen_extendqisi2_ppc (operands[0], operands[1]));
577 else if (TARGET_POWER)
578 emit_insn (gen_extendqisi2_power (operands[0], operands[1]));
579 else
580 emit_insn (gen_extendqisi2_no_power (operands[0], operands[1]));
581 DONE;
582}")
583
584(define_insn "extendqisi2_ppc"
2bee0449
RK
585 [(set (match_operand:SI 0 "gpc_reg_operand" "=r")
586 (sign_extend:SI (match_operand:QI 1 "gpc_reg_operand" "r")))]
51b8fc2c 587 "TARGET_POWERPC"
2bee0449 588 "extsb %0,%1")
51b8fc2c
RK
589
590(define_insn ""
9ebbca7d
GK
591 [(set (match_operand:CC 0 "cc_reg_operand" "=x,?y")
592 (compare:CC (sign_extend:SI (match_operand:QI 1 "gpc_reg_operand" "r,r"))
51b8fc2c 593 (const_int 0)))
9ebbca7d 594 (clobber (match_scratch:SI 2 "=r,r"))]
51b8fc2c 595 "TARGET_POWERPC"
9ebbca7d
GK
596 "@
597 extsb. %2,%1
598 #"
599 [(set_attr "type" "compare")
600 (set_attr "length" "4,8")])
601
602(define_split
603 [(set (match_operand:CC 0 "cc_reg_not_cr0_operand" "")
604 (compare:CC (sign_extend:SI (match_operand:QI 1 "gpc_reg_operand" ""))
605 (const_int 0)))
606 (clobber (match_scratch:SI 2 ""))]
607 "TARGET_POWERPC && reload_completed"
608 [(set (match_dup 2)
609 (sign_extend:SI (match_dup 1)))
610 (set (match_dup 0)
611 (compare:CC (match_dup 2)
612 (const_int 0)))]
613 "")
51b8fc2c
RK
614
615(define_insn ""
9ebbca7d
GK
616 [(set (match_operand:CC 2 "cc_reg_operand" "=x,?y")
617 (compare:CC (sign_extend:SI (match_operand:QI 1 "gpc_reg_operand" "r,r"))
51b8fc2c 618 (const_int 0)))
9ebbca7d 619 (set (match_operand:SI 0 "gpc_reg_operand" "=r,r")
51b8fc2c
RK
620 (sign_extend:SI (match_dup 1)))]
621 "TARGET_POWERPC"
9ebbca7d
GK
622 "@
623 extsb. %0,%1
624 #"
625 [(set_attr "type" "compare")
626 (set_attr "length" "4,8")])
627
628(define_split
629 [(set (match_operand:CC 2 "cc_reg_not_cr0_operand" "")
630 (compare:CC (sign_extend:SI (match_operand:QI 1 "gpc_reg_operand" ""))
631 (const_int 0)))
632 (set (match_operand:SI 0 "gpc_reg_operand" "")
633 (sign_extend:SI (match_dup 1)))]
634 "TARGET_POWERPC && reload_completed"
635 [(set (match_dup 0)
636 (sign_extend:SI (match_dup 1)))
637 (set (match_dup 2)
638 (compare:CC (match_dup 0)
639 (const_int 0)))]
640 "")
51b8fc2c
RK
641
642(define_expand "extendqisi2_power"
643 [(parallel [(set (match_dup 2)
644 (ashift:SI (match_operand:QI 1 "gpc_reg_operand" "")
645 (const_int 24)))
646 (clobber (scratch:SI))])
647 (parallel [(set (match_operand:SI 0 "gpc_reg_operand" "")
648 (ashiftrt:SI (match_dup 2)
649 (const_int 24)))
650 (clobber (scratch:SI))])]
651 "TARGET_POWER"
652 "
653{ operands[1] = gen_lowpart (SImode, operands[1]);
654 operands[2] = gen_reg_rtx (SImode); }")
655
656(define_expand "extendqisi2_no_power"
657 [(set (match_dup 2)
658 (ashift:SI (match_operand:QI 1 "gpc_reg_operand" "")
659 (const_int 24)))
660 (set (match_operand:SI 0 "gpc_reg_operand" "")
661 (ashiftrt:SI (match_dup 2)
662 (const_int 24)))]
663 "! TARGET_POWER && ! TARGET_POWERPC"
664 "
665{ operands[1] = gen_lowpart (SImode, operands[1]);
666 operands[2] = gen_reg_rtx (SImode); }")
667
1fd4e8c1 668(define_expand "zero_extendqihi2"
cd2b37d9
RK
669 [(set (match_operand:HI 0 "gpc_reg_operand" "")
670 (zero_extend:HI (match_operand:QI 1 "gpc_reg_operand" "")))]
1fd4e8c1
RK
671 ""
672 "")
673
674(define_insn ""
cd2b37d9 675 [(set (match_operand:HI 0 "gpc_reg_operand" "=r,r")
1fd4e8c1
RK
676 (zero_extend:HI (match_operand:QI 1 "reg_or_mem_operand" "m,r")))]
677 ""
678 "@
679 lbz%U1%X1 %0,%1
005a35b9 680 {rlinm|rlwinm} %0,%1,0,0xff"
51b8fc2c
RK
681 [(set_attr "type" "load,*")])
682
683(define_insn ""
9ebbca7d
GK
684 [(set (match_operand:CC 0 "cc_reg_operand" "=x,?y")
685 (compare:CC (zero_extend:HI (match_operand:QI 1 "gpc_reg_operand" "r,r"))
51b8fc2c 686 (const_int 0)))
9ebbca7d 687 (clobber (match_scratch:HI 2 "=r,r"))]
51b8fc2c 688 ""
9ebbca7d
GK
689 "@
690 {andil.|andi.} %2,%1,0xff
691 #"
692 [(set_attr "type" "compare")
693 (set_attr "length" "4,8")])
694
695(define_split
696 [(set (match_operand:CC 0 "cc_reg_not_cr0_operand" "")
697 (compare:CC (zero_extend:HI (match_operand:QI 1 "gpc_reg_operand" ""))
698 (const_int 0)))
699 (clobber (match_scratch:HI 2 ""))]
700 "reload_completed"
701 [(set (match_dup 2)
702 (zero_extend:HI (match_dup 1)))
703 (set (match_dup 0)
704 (compare:CC (match_dup 2)
705 (const_int 0)))]
706 "")
1fd4e8c1 707
51b8fc2c 708(define_insn ""
9ebbca7d
GK
709 [(set (match_operand:CC 2 "cc_reg_operand" "=x,?y")
710 (compare:CC (zero_extend:HI (match_operand:QI 1 "gpc_reg_operand" "r,r"))
51b8fc2c 711 (const_int 0)))
9ebbca7d 712 (set (match_operand:HI 0 "gpc_reg_operand" "=r,r")
815cdc52
MM
713 (zero_extend:HI (match_dup 1)))]
714 ""
9ebbca7d
GK
715 "@
716 {andil.|andi.} %0,%1,0xff
717 #"
718 [(set_attr "type" "compare")
719 (set_attr "length" "4,8")])
720
721(define_split
722 [(set (match_operand:CC 2 "cc_reg_not_cr0_operand" "")
723 (compare:CC (zero_extend:HI (match_operand:QI 1 "gpc_reg_operand" ""))
724 (const_int 0)))
725 (set (match_operand:HI 0 "gpc_reg_operand" "")
726 (zero_extend:HI (match_dup 1)))]
727 "reload_completed"
728 [(set (match_dup 0)
729 (zero_extend:HI (match_dup 1)))
730 (set (match_dup 2)
731 (compare:CC (match_dup 0)
732 (const_int 0)))]
733 "")
815cdc52
MM
734
735(define_expand "extendqihi2"
736 [(use (match_operand:HI 0 "gpc_reg_operand" ""))
737 (use (match_operand:QI 1 "gpc_reg_operand" ""))]
738 ""
739 "
740{
741 if (TARGET_POWERPC)
742 emit_insn (gen_extendqihi2_ppc (operands[0], operands[1]));
743 else if (TARGET_POWER)
744 emit_insn (gen_extendqihi2_power (operands[0], operands[1]));
745 else
746 emit_insn (gen_extendqihi2_no_power (operands[0], operands[1]));
747 DONE;
748}")
749
750(define_insn "extendqihi2_ppc"
751 [(set (match_operand:HI 0 "gpc_reg_operand" "=r")
752 (sign_extend:HI (match_operand:QI 1 "gpc_reg_operand" "r")))]
753 "TARGET_POWERPC"
754 "extsb %0,%1")
755
756(define_insn ""
9ebbca7d
GK
757 [(set (match_operand:CC 0 "cc_reg_operand" "=x,?y")
758 (compare:CC (sign_extend:HI (match_operand:QI 1 "gpc_reg_operand" "r,r"))
815cdc52 759 (const_int 0)))
9ebbca7d 760 (clobber (match_scratch:HI 2 "=r,r"))]
815cdc52 761 "TARGET_POWERPC"
9ebbca7d
GK
762 "@
763 extsb. %2,%1
764 #"
765 [(set_attr "type" "compare")
766 (set_attr "length" "4,8")])
767
768(define_split
769 [(set (match_operand:CC 0 "cc_reg_not_cr0_operand" "")
770 (compare:CC (sign_extend:HI (match_operand:QI 1 "gpc_reg_operand" ""))
771 (const_int 0)))
772 (clobber (match_scratch:HI 2 ""))]
773 "TARGET_POWERPC && reload_completed"
774 [(set (match_dup 2)
775 (sign_extend:HI (match_dup 1)))
776 (set (match_dup 0)
777 (compare:CC (match_dup 2)
778 (const_int 0)))]
779 "")
815cdc52
MM
780
781(define_insn ""
9ebbca7d
GK
782 [(set (match_operand:CC 2 "cc_reg_operand" "=x,?y")
783 (compare:CC (sign_extend:HI (match_operand:QI 1 "gpc_reg_operand" "r,r"))
51b8fc2c 784 (const_int 0)))
9ebbca7d 785 (set (match_operand:HI 0 "gpc_reg_operand" "=r,r")
51b8fc2c
RK
786 (sign_extend:HI (match_dup 1)))]
787 "TARGET_POWERPC"
9ebbca7d
GK
788 "@
789 extsb. %0,%1
790 #"
791 [(set_attr "type" "compare")
792 (set_attr "length" "4,8")])
793
794(define_split
795 [(set (match_operand:CC 2 "cc_reg_not_cr0_operand" "")
796 (compare:CC (sign_extend:HI (match_operand:QI 1 "gpc_reg_operand" ""))
797 (const_int 0)))
798 (set (match_operand:HI 0 "gpc_reg_operand" "")
799 (sign_extend:HI (match_dup 1)))]
800 "TARGET_POWERPC && reload_completed"
801 [(set (match_dup 0)
802 (sign_extend:HI (match_dup 1)))
803 (set (match_dup 2)
804 (compare:CC (match_dup 0)
805 (const_int 0)))]
806 "")
51b8fc2c
RK
807
808(define_expand "extendqihi2_power"
809 [(parallel [(set (match_dup 2)
810 (ashift:SI (match_operand:QI 1 "gpc_reg_operand" "")
811 (const_int 24)))
812 (clobber (scratch:SI))])
813 (parallel [(set (match_operand:HI 0 "gpc_reg_operand" "")
814 (ashiftrt:SI (match_dup 2)
815 (const_int 24)))
816 (clobber (scratch:SI))])]
817 "TARGET_POWER"
818 "
819{ operands[0] = gen_lowpart (SImode, operands[0]);
820 operands[1] = gen_lowpart (SImode, operands[1]);
821 operands[2] = gen_reg_rtx (SImode); }")
822
823(define_expand "extendqihi2_no_power"
824 [(set (match_dup 2)
825 (ashift:SI (match_operand:QI 1 "gpc_reg_operand" "")
826 (const_int 24)))
827 (set (match_operand:HI 0 "gpc_reg_operand" "")
828 (ashiftrt:SI (match_dup 2)
829 (const_int 24)))]
830 "! TARGET_POWER && ! TARGET_POWERPC"
831 "
832{ operands[0] = gen_lowpart (SImode, operands[0]);
833 operands[1] = gen_lowpart (SImode, operands[1]);
834 operands[2] = gen_reg_rtx (SImode); }")
835
1fd4e8c1 836(define_expand "zero_extendhisi2"
5f243543 837 [(set (match_operand:SI 0 "gpc_reg_operand" "")
cd2b37d9 838 (zero_extend:SI (match_operand:HI 1 "gpc_reg_operand" "")))]
1fd4e8c1
RK
839 ""
840 "")
841
842(define_insn ""
cd2b37d9 843 [(set (match_operand:SI 0 "gpc_reg_operand" "=r,r")
1fd4e8c1
RK
844 (zero_extend:SI (match_operand:HI 1 "reg_or_mem_operand" "m,r")))]
845 ""
846 "@
847 lhz%U1%X1 %0,%1
005a35b9 848 {rlinm|rlwinm} %0,%1,0,0xffff"
1fd4e8c1
RK
849 [(set_attr "type" "load,*")])
850
851(define_insn ""
9ebbca7d
GK
852 [(set (match_operand:CC 0 "cc_reg_operand" "=x,?y")
853 (compare:CC (zero_extend:SI (match_operand:HI 1 "gpc_reg_operand" "r,r"))
1fd4e8c1 854 (const_int 0)))
9ebbca7d 855 (clobber (match_scratch:SI 2 "=r,r"))]
1fd4e8c1 856 ""
9ebbca7d
GK
857 "@
858 {andil.|andi.} %2,%1,0xffff
859 #"
860 [(set_attr "type" "compare")
861 (set_attr "length" "4,8")])
862
863(define_split
864 [(set (match_operand:CC 0 "cc_reg_not_cr0_operand" "")
865 (compare:CC (zero_extend:SI (match_operand:HI 1 "gpc_reg_operand" ""))
866 (const_int 0)))
867 (clobber (match_scratch:SI 2 ""))]
868 "reload_completed"
869 [(set (match_dup 2)
870 (zero_extend:SI (match_dup 1)))
871 (set (match_dup 0)
872 (compare:CC (match_dup 2)
873 (const_int 0)))]
874 "")
1fd4e8c1
RK
875
876(define_insn ""
9ebbca7d
GK
877 [(set (match_operand:CC 2 "cc_reg_operand" "=x,?y")
878 (compare:CC (zero_extend:SI (match_operand:HI 1 "gpc_reg_operand" "r,r"))
1fd4e8c1 879 (const_int 0)))
9ebbca7d 880 (set (match_operand:SI 0 "gpc_reg_operand" "=r,r")
1fd4e8c1
RK
881 (zero_extend:SI (match_dup 1)))]
882 ""
9ebbca7d
GK
883 "@
884 {andil.|andi.} %0,%1,0xffff
885 #"
886 [(set_attr "type" "compare")
887 (set_attr "length" "4,8")])
888
889(define_split
890 [(set (match_operand:CC 2 "cc_reg_not_cr0_operand" "")
891 (compare:CC (zero_extend:SI (match_operand:HI 1 "gpc_reg_operand" ""))
892 (const_int 0)))
893 (set (match_operand:SI 0 "gpc_reg_operand" "")
894 (zero_extend:SI (match_dup 1)))]
895 "reload_completed"
896 [(set (match_dup 0)
897 (zero_extend:SI (match_dup 1)))
898 (set (match_dup 2)
899 (compare:CC (match_dup 0)
900 (const_int 0)))]
901 "")
1fd4e8c1
RK
902
903(define_expand "extendhisi2"
cd2b37d9
RK
904 [(set (match_operand:SI 0 "gpc_reg_operand" "")
905 (sign_extend:SI (match_operand:HI 1 "gpc_reg_operand" "")))]
1fd4e8c1
RK
906 ""
907 "")
908
909(define_insn ""
cd2b37d9 910 [(set (match_operand:SI 0 "gpc_reg_operand" "=r,r")
1fd4e8c1
RK
911 (sign_extend:SI (match_operand:HI 1 "reg_or_mem_operand" "m,r")))]
912 ""
913 "@
914 lha%U1%X1 %0,%1
ca7f5001 915 {exts|extsh} %0,%1"
b54cf83a 916 [(set_attr "type" "load_ext,*")])
1fd4e8c1
RK
917
918(define_insn ""
9ebbca7d
GK
919 [(set (match_operand:CC 0 "cc_reg_operand" "=x,?y")
920 (compare:CC (sign_extend:SI (match_operand:HI 1 "gpc_reg_operand" "r,r"))
1fd4e8c1 921 (const_int 0)))
9ebbca7d 922 (clobber (match_scratch:SI 2 "=r,r"))]
1fd4e8c1 923 ""
9ebbca7d
GK
924 "@
925 {exts.|extsh.} %2,%1
926 #"
927 [(set_attr "type" "compare")
928 (set_attr "length" "4,8")])
929
930(define_split
931 [(set (match_operand:CC 0 "cc_reg_not_cr0_operand" "")
932 (compare:CC (sign_extend:SI (match_operand:HI 1 "gpc_reg_operand" ""))
933 (const_int 0)))
934 (clobber (match_scratch:SI 2 ""))]
935 "reload_completed"
936 [(set (match_dup 2)
937 (sign_extend:SI (match_dup 1)))
938 (set (match_dup 0)
939 (compare:CC (match_dup 2)
940 (const_int 0)))]
941 "")
1fd4e8c1
RK
942
943(define_insn ""
9ebbca7d
GK
944 [(set (match_operand:CC 2 "cc_reg_operand" "=x,?y")
945 (compare:CC (sign_extend:SI (match_operand:HI 1 "gpc_reg_operand" "r,r"))
1fd4e8c1 946 (const_int 0)))
9ebbca7d 947 (set (match_operand:SI 0 "gpc_reg_operand" "=r,r")
1fd4e8c1
RK
948 (sign_extend:SI (match_dup 1)))]
949 ""
9ebbca7d
GK
950 "@
951 {exts.|extsh.} %0,%1
952 #"
953 [(set_attr "type" "compare")
954 (set_attr "length" "4,8")])
1fd4e8c1 955\f
9ebbca7d
GK
956(define_split
957 [(set (match_operand:CC 2 "cc_reg_not_cr0_operand" "")
958 (compare:CC (sign_extend:SI (match_operand:HI 1 "gpc_reg_operand" ""))
959 (const_int 0)))
960 (set (match_operand:SI 0 "gpc_reg_operand" "")
961 (sign_extend:SI (match_dup 1)))]
962 "reload_completed"
963 [(set (match_dup 0)
964 (sign_extend:SI (match_dup 1)))
965 (set (match_dup 2)
966 (compare:CC (match_dup 0)
967 (const_int 0)))]
968 "")
969
1fd4e8c1 970;; Fixed-point arithmetic insns.
deb9225a
RK
971
972;; Discourage ai/addic because of carry but provide it in an alternative
973;; allowing register zero as source.
7cd5235b
MM
974(define_expand "addsi3"
975 [(set (match_operand:SI 0 "gpc_reg_operand" "")
976 (plus:SI (match_operand:SI 1 "gpc_reg_operand" "")
f6bf7de2 977 (match_operand:SI 2 "reg_or_arith_cint_operand" "")))]
7cd5235b
MM
978 ""
979 "
980{
677a9668
DE
981 if (GET_CODE (operands[2]) == CONST_INT
982 && ! add_operand (operands[2], SImode))
7cd5235b 983 {
677a9668 984 rtx tmp = ((no_new_pseudos || rtx_equal_p (operands[0], operands[1]))
7cd5235b
MM
985 ? operands[0] : gen_reg_rtx (SImode));
986
2bfcf297 987 HOST_WIDE_INT val = INTVAL (operands[2]);
a65c591c 988 HOST_WIDE_INT low = ((val & 0xffff) ^ 0x8000) - 0x8000;
2bfcf297 989 HOST_WIDE_INT rest = trunc_int_for_mode (val - low, SImode);
7cd5235b 990
9ebbca7d
GK
991 /* The ordering here is important for the prolog expander.
992 When space is allocated from the stack, adding 'low' first may
993 produce a temporary deallocation (which would be bad). */
2bfcf297 994 emit_insn (gen_addsi3 (tmp, operands[1], GEN_INT (rest)));
7cd5235b
MM
995 emit_insn (gen_addsi3 (operands[0], tmp, GEN_INT (low)));
996 DONE;
997 }
998}")
999
1000(define_insn "*addsi3_internal1"
1001 [(set (match_operand:SI 0 "gpc_reg_operand" "=r,r,?r,r")
1002 (plus:SI (match_operand:SI 1 "gpc_reg_operand" "%r,b,r,b")
9615f239 1003 (match_operand:SI 2 "add_operand" "r,I,I,L")))]
1fd4e8c1
RK
1004 ""
1005 "@
deb9225a
RK
1006 {cax|add} %0,%1,%2
1007 {cal %0,%2(%1)|addi %0,%1,%2}
1008 {ai|addic} %0,%1,%2
7cd5235b
MM
1009 {cau|addis} %0,%1,%v2"
1010 [(set_attr "length" "4,4,4,4")])
1fd4e8c1 1011
ee890fe2
SS
1012(define_insn "addsi3_high"
1013 [(set (match_operand:SI 0 "gpc_reg_operand" "=b")
1014 (plus:SI (match_operand:SI 1 "gpc_reg_operand" "b")
1015 (high:SI (match_operand 2 "" ""))))]
1016 "TARGET_MACHO && !TARGET_64BIT"
1017 "{cau|addis} %0,%1,ha16(%2)"
1018 [(set_attr "length" "4")])
1019
7cd5235b 1020(define_insn "*addsi3_internal2"
cb8cc086
MM
1021 [(set (match_operand:CC 0 "cc_reg_operand" "=x,x,?y,?y")
1022 (compare:CC (plus:SI (match_operand:SI 1 "gpc_reg_operand" "%r,r,r,r")
1023 (match_operand:SI 2 "reg_or_short_operand" "r,I,r,I"))
1fd4e8c1 1024 (const_int 0)))
cb8cc086 1025 (clobber (match_scratch:SI 3 "=r,r,r,r"))]
4b8a63d6 1026 "TARGET_32BIT"
deb9225a
RK
1027 "@
1028 {cax.|add.} %3,%1,%2
cb8cc086
MM
1029 {ai.|addic.} %3,%1,%2
1030 #
1031 #"
a62bfff2 1032 [(set_attr "type" "fast_compare,compare,compare,compare")
cb8cc086
MM
1033 (set_attr "length" "4,4,8,8")])
1034
1035(define_split
1036 [(set (match_operand:CC 0 "cc_reg_not_cr0_operand" "")
1037 (compare:CC (plus:SI (match_operand:SI 1 "gpc_reg_operand" "")
1038 (match_operand:SI 2 "reg_or_short_operand" ""))
1039 (const_int 0)))
1040 (clobber (match_scratch:SI 3 ""))]
4b8a63d6 1041 "TARGET_32BIT && reload_completed"
cb8cc086
MM
1042 [(set (match_dup 3)
1043 (plus:SI (match_dup 1)
1044 (match_dup 2)))
1045 (set (match_dup 0)
1046 (compare:CC (match_dup 3)
1047 (const_int 0)))]
1048 "")
7e69e155 1049
7cd5235b 1050(define_insn "*addsi3_internal3"
cb8cc086
MM
1051 [(set (match_operand:CC 3 "cc_reg_operand" "=x,x,?y,?y")
1052 (compare:CC (plus:SI (match_operand:SI 1 "gpc_reg_operand" "%r,r,r,r")
1053 (match_operand:SI 2 "reg_or_short_operand" "r,I,r,I"))
1fd4e8c1 1054 (const_int 0)))
cb8cc086
MM
1055 (set (match_operand:SI 0 "gpc_reg_operand" "=r,r,r,r")
1056 (plus:SI (match_dup 1)
1057 (match_dup 2)))]
4b8a63d6 1058 "TARGET_32BIT"
deb9225a
RK
1059 "@
1060 {cax.|add.} %0,%1,%2
cb8cc086
MM
1061 {ai.|addic.} %0,%1,%2
1062 #
1063 #"
a62bfff2 1064 [(set_attr "type" "fast_compare,compare,compare,compare")
cb8cc086
MM
1065 (set_attr "length" "4,4,8,8")])
1066
1067(define_split
1068 [(set (match_operand:CC 3 "cc_reg_not_cr0_operand" "")
1069 (compare:CC (plus:SI (match_operand:SI 1 "gpc_reg_operand" "")
1070 (match_operand:SI 2 "reg_or_short_operand" ""))
1071 (const_int 0)))
1072 (set (match_operand:SI 0 "gpc_reg_operand" "")
1073 (plus:SI (match_dup 1) (match_dup 2)))]
4b8a63d6 1074 "TARGET_32BIT && reload_completed"
cb8cc086
MM
1075 [(set (match_dup 0)
1076 (plus:SI (match_dup 1)
1077 (match_dup 2)))
1078 (set (match_dup 3)
1079 (compare:CC (match_dup 0)
1080 (const_int 0)))]
1081 "")
7e69e155 1082
f357808b
RK
1083;; Split an add that we can't do in one insn into two insns, each of which
1084;; does one 16-bit part. This is used by combine. Note that the low-order
1085;; add should be last in case the result gets used in an address.
1086
1087(define_split
cd2b37d9
RK
1088 [(set (match_operand:SI 0 "gpc_reg_operand" "")
1089 (plus:SI (match_operand:SI 1 "gpc_reg_operand" "")
f357808b 1090 (match_operand:SI 2 "non_add_cint_operand" "")))]
1fd4e8c1 1091 ""
f357808b
RK
1092 [(set (match_dup 0) (plus:SI (match_dup 1) (match_dup 3)))
1093 (set (match_dup 0) (plus:SI (match_dup 0) (match_dup 4)))]
1094"
1fd4e8c1 1095{
2bfcf297 1096 HOST_WIDE_INT val = INTVAL (operands[2]);
a65c591c 1097 HOST_WIDE_INT low = ((val & 0xffff) ^ 0x8000) - 0x8000;
2bfcf297 1098 HOST_WIDE_INT rest = trunc_int_for_mode (val - low, SImode);
1fd4e8c1 1099
2bfcf297 1100 operands[3] = GEN_INT (rest);
e6ca2c17 1101 operands[4] = GEN_INT (low);
1fd4e8c1
RK
1102}")
1103
8de2a197 1104(define_insn "one_cmplsi2"
cd2b37d9
RK
1105 [(set (match_operand:SI 0 "gpc_reg_operand" "=r")
1106 (not:SI (match_operand:SI 1 "gpc_reg_operand" "r")))]
1fd4e8c1 1107 ""
ca7f5001
RK
1108 "nor %0,%1,%1")
1109
1110(define_insn ""
52d3af72
DE
1111 [(set (match_operand:CC 0 "cc_reg_operand" "=x,?y")
1112 (compare:CC (not:SI (match_operand:SI 1 "gpc_reg_operand" "r,r"))
ca7f5001 1113 (const_int 0)))
52d3af72 1114 (clobber (match_scratch:SI 2 "=r,r"))]
4b8a63d6 1115 "TARGET_32BIT"
52d3af72
DE
1116 "@
1117 nor. %2,%1,%1
1118 #"
1119 [(set_attr "type" "compare")
1120 (set_attr "length" "4,8")])
1121
1122(define_split
1123 [(set (match_operand:CC 0 "cc_reg_not_cr0_operand" "")
1124 (compare:CC (not:SI (match_operand:SI 1 "gpc_reg_operand" ""))
1125 (const_int 0)))
1126 (clobber (match_scratch:SI 2 ""))]
4b8a63d6 1127 "TARGET_32BIT && reload_completed"
52d3af72
DE
1128 [(set (match_dup 2)
1129 (not:SI (match_dup 1)))
1130 (set (match_dup 0)
1131 (compare:CC (match_dup 2)
1132 (const_int 0)))]
1133 "")
ca7f5001
RK
1134
1135(define_insn ""
52d3af72
DE
1136 [(set (match_operand:CC 2 "cc_reg_operand" "=x,?y")
1137 (compare:CC (not:SI (match_operand:SI 1 "gpc_reg_operand" "r,r"))
815cdc52 1138 (const_int 0)))
52d3af72 1139 (set (match_operand:SI 0 "gpc_reg_operand" "=r,r")
815cdc52 1140 (not:SI (match_dup 1)))]
4b8a63d6 1141 "TARGET_32BIT"
52d3af72
DE
1142 "@
1143 nor. %0,%1,%1
1144 #"
1145 [(set_attr "type" "compare")
1146 (set_attr "length" "4,8")])
1147
1148(define_split
1149 [(set (match_operand:CC 2 "cc_reg_not_cr0_operand" "")
1150 (compare:CC (not:SI (match_operand:SI 1 "gpc_reg_operand" ""))
1151 (const_int 0)))
1cb18e3c 1152 (set (match_operand:SI 0 "gpc_reg_operand" "")
52d3af72 1153 (not:SI (match_dup 1)))]
4b8a63d6 1154 "TARGET_32BIT && reload_completed"
52d3af72
DE
1155 [(set (match_dup 0)
1156 (not:SI (match_dup 1)))
1157 (set (match_dup 2)
1158 (compare:CC (match_dup 0)
1159 (const_int 0)))]
1160 "")
1fd4e8c1
RK
1161
1162(define_insn ""
3d91674b
RK
1163 [(set (match_operand:SI 0 "gpc_reg_operand" "=r")
1164 (minus:SI (match_operand:SI 1 "reg_or_short_operand" "rI")
1165 (match_operand:SI 2 "gpc_reg_operand" "r")))]
deb9225a 1166 "! TARGET_POWERPC"
ca7f5001 1167 "{sf%I1|subf%I1c} %0,%2,%1")
1fd4e8c1 1168
deb9225a
RK
1169(define_insn ""
1170 [(set (match_operand:SI 0 "gpc_reg_operand" "=r,r")
1171 (minus:SI (match_operand:SI 1 "reg_or_short_operand" "r,I")
1172 (match_operand:SI 2 "gpc_reg_operand" "r,r")))]
1173 "TARGET_POWERPC"
1174 "@
1175 subf %0,%2,%1
1176 subfic %0,%2,%1")
1177
1fd4e8c1 1178(define_insn ""
cb8cc086
MM
1179 [(set (match_operand:CC 0 "cc_reg_operand" "=x,?y")
1180 (compare:CC (minus:SI (match_operand:SI 1 "gpc_reg_operand" "r,r")
1181 (match_operand:SI 2 "gpc_reg_operand" "r,r"))
1fd4e8c1 1182 (const_int 0)))
cb8cc086 1183 (clobber (match_scratch:SI 3 "=r,r"))]
deb9225a 1184 "! TARGET_POWERPC"
cb8cc086
MM
1185 "@
1186 {sf.|subfc.} %3,%2,%1
1187 #"
1188 [(set_attr "type" "compare")
1189 (set_attr "length" "4,8")])
1fd4e8c1 1190
deb9225a 1191(define_insn ""
cb8cc086
MM
1192 [(set (match_operand:CC 0 "cc_reg_operand" "=x,?y")
1193 (compare:CC (minus:SI (match_operand:SI 1 "gpc_reg_operand" "r,r")
1194 (match_operand:SI 2 "gpc_reg_operand" "r,r"))
deb9225a 1195 (const_int 0)))
cb8cc086 1196 (clobber (match_scratch:SI 3 "=r,r"))]
4b8a63d6 1197 "TARGET_POWERPC && TARGET_32BIT"
cb8cc086
MM
1198 "@
1199 subf. %3,%2,%1
1200 #"
a62bfff2 1201 [(set_attr "type" "fast_compare")
cb8cc086
MM
1202 (set_attr "length" "4,8")])
1203
1204(define_split
1205 [(set (match_operand:CC 0 "cc_reg_not_cr0_operand" "")
1206 (compare:CC (minus:SI (match_operand:SI 1 "gpc_reg_operand" "")
1207 (match_operand:SI 2 "gpc_reg_operand" ""))
1208 (const_int 0)))
1209 (clobber (match_scratch:SI 3 ""))]
4b8a63d6 1210 "TARGET_32BIT && reload_completed"
cb8cc086
MM
1211 [(set (match_dup 3)
1212 (minus:SI (match_dup 1)
1213 (match_dup 2)))
1214 (set (match_dup 0)
1215 (compare:CC (match_dup 3)
1216 (const_int 0)))]
1217 "")
deb9225a 1218
1fd4e8c1 1219(define_insn ""
cb8cc086
MM
1220 [(set (match_operand:CC 3 "cc_reg_operand" "=x,?y")
1221 (compare:CC (minus:SI (match_operand:SI 1 "gpc_reg_operand" "r,r")
1222 (match_operand:SI 2 "gpc_reg_operand" "r,r"))
1fd4e8c1 1223 (const_int 0)))
cb8cc086 1224 (set (match_operand:SI 0 "gpc_reg_operand" "=r,r")
1fd4e8c1 1225 (minus:SI (match_dup 1) (match_dup 2)))]
deb9225a 1226 "! TARGET_POWERPC"
cb8cc086
MM
1227 "@
1228 {sf.|subfc.} %0,%2,%1
1229 #"
1230 [(set_attr "type" "compare")
1231 (set_attr "length" "4,8")])
815cdc52 1232
29ae5b89 1233(define_insn ""
cb8cc086
MM
1234 [(set (match_operand:CC 3 "cc_reg_operand" "=x,?y")
1235 (compare:CC (minus:SI (match_operand:SI 1 "gpc_reg_operand" "r,r")
1236 (match_operand:SI 2 "gpc_reg_operand" "r,r"))
815cdc52 1237 (const_int 0)))
cb8cc086
MM
1238 (set (match_operand:SI 0 "gpc_reg_operand" "=r,r")
1239 (minus:SI (match_dup 1)
1240 (match_dup 2)))]
4b8a63d6 1241 "TARGET_POWERPC && TARGET_32BIT"
90612787
DE
1242 "@
1243 subf. %0,%2,%1
1244 #"
a62bfff2 1245 [(set_attr "type" "fast_compare")
cb8cc086
MM
1246 (set_attr "length" "4,8")])
1247
1248(define_split
1249 [(set (match_operand:CC 3 "cc_reg_not_cr0_operand" "")
1250 (compare:CC (minus:SI (match_operand:SI 1 "gpc_reg_operand" "")
1251 (match_operand:SI 2 "gpc_reg_operand" ""))
1252 (const_int 0)))
1253 (set (match_operand:SI 0 "gpc_reg_operand" "")
1254 (minus:SI (match_dup 1)
1255 (match_dup 2)))]
4b8a63d6 1256 "TARGET_32BIT && reload_completed"
cb8cc086
MM
1257 [(set (match_dup 0)
1258 (minus:SI (match_dup 1)
1259 (match_dup 2)))
1260 (set (match_dup 3)
1261 (compare:CC (match_dup 0)
1262 (const_int 0)))]
1263 "")
deb9225a 1264
1fd4e8c1 1265(define_expand "subsi3"
cd2b37d9 1266 [(set (match_operand:SI 0 "gpc_reg_operand" "")
1fd4e8c1 1267 (minus:SI (match_operand:SI 1 "reg_or_short_operand" "")
f6bf7de2 1268 (match_operand:SI 2 "reg_or_arith_cint_operand" "")))]
1fd4e8c1 1269 ""
a0044fb1
RK
1270 "
1271{
1272 if (GET_CODE (operands[2]) == CONST_INT)
1273 {
1274 emit_insn (gen_addsi3 (operands[0], operands[1],
1275 negate_rtx (SImode, operands[2])));
1276 DONE;
1277 }
1278}")
1fd4e8c1
RK
1279
1280;; For SMIN, SMAX, UMIN, and UMAX, we use DEFINE_EXPAND's that involve a doz[i]
1281;; instruction and some auxiliary computations. Then we just have a single
95ac8e67
RK
1282;; DEFINE_INSN for doz[i] and the define_splits to make them if made by
1283;; combine.
1fd4e8c1
RK
1284
1285(define_expand "sminsi3"
1286 [(set (match_dup 3)
cd2b37d9 1287 (if_then_else:SI (gt:SI (match_operand:SI 1 "gpc_reg_operand" "")
1fd4e8c1
RK
1288 (match_operand:SI 2 "reg_or_short_operand" ""))
1289 (const_int 0)
1290 (minus:SI (match_dup 2) (match_dup 1))))
cd2b37d9 1291 (set (match_operand:SI 0 "gpc_reg_operand" "")
1fd4e8c1 1292 (minus:SI (match_dup 2) (match_dup 3)))]
a3170dc6 1293 "TARGET_POWER || TARGET_ISEL"
1fd4e8c1 1294 "
a3170dc6
AH
1295{
1296 if (TARGET_ISEL)
1297 {
1298 operands[2] = force_reg (SImode, operands[2]);
1299 rs6000_emit_minmax (operands[0], SMIN, operands[1], operands[2]);
1300 DONE;
1301 }
1302
1303 operands[3] = gen_reg_rtx (SImode);
1304}")
1fd4e8c1 1305
95ac8e67
RK
1306(define_split
1307 [(set (match_operand:SI 0 "gpc_reg_operand" "")
1308 (smin:SI (match_operand:SI 1 "gpc_reg_operand" "")
1309 (match_operand:SI 2 "reg_or_short_operand" "")))
1310 (clobber (match_operand:SI 3 "gpc_reg_operand" ""))]
ca7f5001 1311 "TARGET_POWER"
95ac8e67
RK
1312 [(set (match_dup 3)
1313 (if_then_else:SI (gt:SI (match_dup 1) (match_dup 2))
1314 (const_int 0)
1315 (minus:SI (match_dup 2) (match_dup 1))))
1316 (set (match_dup 0) (minus:SI (match_dup 2) (match_dup 3)))]
1317 "")
1318
1fd4e8c1
RK
1319(define_expand "smaxsi3"
1320 [(set (match_dup 3)
cd2b37d9 1321 (if_then_else:SI (gt:SI (match_operand:SI 1 "gpc_reg_operand" "")
1fd4e8c1
RK
1322 (match_operand:SI 2 "reg_or_short_operand" ""))
1323 (const_int 0)
1324 (minus:SI (match_dup 2) (match_dup 1))))
cd2b37d9 1325 (set (match_operand:SI 0 "gpc_reg_operand" "")
1fd4e8c1 1326 (plus:SI (match_dup 3) (match_dup 1)))]
a3170dc6 1327 "TARGET_POWER || TARGET_ISEL"
1fd4e8c1 1328 "
a3170dc6
AH
1329{
1330 if (TARGET_ISEL)
1331 {
1332 operands[2] = force_reg (SImode, operands[2]);
1333 rs6000_emit_minmax (operands[0], SMAX, operands[1], operands[2]);
1334 DONE;
1335 }
1336 operands[3] = gen_reg_rtx (SImode);
1337}")
1fd4e8c1 1338
95ac8e67
RK
1339(define_split
1340 [(set (match_operand:SI 0 "gpc_reg_operand" "")
1341 (smax:SI (match_operand:SI 1 "gpc_reg_operand" "")
1342 (match_operand:SI 2 "reg_or_short_operand" "")))
1343 (clobber (match_operand:SI 3 "gpc_reg_operand" ""))]
ca7f5001 1344 "TARGET_POWER"
95ac8e67
RK
1345 [(set (match_dup 3)
1346 (if_then_else:SI (gt:SI (match_dup 1) (match_dup 2))
1347 (const_int 0)
1348 (minus:SI (match_dup 2) (match_dup 1))))
1349 (set (match_dup 0) (plus:SI (match_dup 3) (match_dup 1)))]
1350 "")
1351
1fd4e8c1 1352(define_expand "uminsi3"
cd2b37d9 1353 [(set (match_dup 3) (xor:SI (match_operand:SI 1 "gpc_reg_operand" "")
bb68ff55 1354 (match_dup 5)))
cd2b37d9 1355 (set (match_dup 4) (xor:SI (match_operand:SI 2 "gpc_reg_operand" "")
bb68ff55 1356 (match_dup 5)))
1fd4e8c1
RK
1357 (set (match_dup 3) (if_then_else:SI (gt (match_dup 3) (match_dup 4))
1358 (const_int 0)
1359 (minus:SI (match_dup 4) (match_dup 3))))
cd2b37d9 1360 (set (match_operand:SI 0 "gpc_reg_operand" "")
1fd4e8c1 1361 (minus:SI (match_dup 2) (match_dup 3)))]
a3170dc6 1362 "TARGET_POWER || TARGET_ISEL"
1fd4e8c1 1363 "
bb68ff55 1364{
a3170dc6
AH
1365 if (TARGET_ISEL)
1366 {
1367 rs6000_emit_minmax (operands[0], UMIN, operands[1], operands[2]);
1368 DONE;
1369 }
bb68ff55
MM
1370 operands[3] = gen_reg_rtx (SImode);
1371 operands[4] = gen_reg_rtx (SImode);
1372 operands[5] = GEN_INT (-2147483647 - 1);
1373}")
1fd4e8c1
RK
1374
1375(define_expand "umaxsi3"
cd2b37d9 1376 [(set (match_dup 3) (xor:SI (match_operand:SI 1 "gpc_reg_operand" "")
bb68ff55 1377 (match_dup 5)))
cd2b37d9 1378 (set (match_dup 4) (xor:SI (match_operand:SI 2 "gpc_reg_operand" "")
bb68ff55 1379 (match_dup 5)))
1fd4e8c1
RK
1380 (set (match_dup 3) (if_then_else:SI (gt (match_dup 3) (match_dup 4))
1381 (const_int 0)
1382 (minus:SI (match_dup 4) (match_dup 3))))
cd2b37d9 1383 (set (match_operand:SI 0 "gpc_reg_operand" "")
1fd4e8c1 1384 (plus:SI (match_dup 3) (match_dup 1)))]
a3170dc6 1385 "TARGET_POWER || TARGET_ISEL"
1fd4e8c1 1386 "
bb68ff55 1387{
a3170dc6
AH
1388 if (TARGET_ISEL)
1389 {
1390 rs6000_emit_minmax (operands[0], UMAX, operands[1], operands[2]);
1391 DONE;
1392 }
bb68ff55
MM
1393 operands[3] = gen_reg_rtx (SImode);
1394 operands[4] = gen_reg_rtx (SImode);
1395 operands[5] = GEN_INT (-2147483647 - 1);
1396}")
1fd4e8c1
RK
1397
1398(define_insn ""
cd2b37d9
RK
1399 [(set (match_operand:SI 0 "gpc_reg_operand" "=r")
1400 (if_then_else:SI (gt (match_operand:SI 1 "gpc_reg_operand" "r")
5c23c401 1401 (match_operand:SI 2 "reg_or_short_operand" "rI"))
1fd4e8c1
RK
1402 (const_int 0)
1403 (minus:SI (match_dup 2) (match_dup 1))))]
ca7f5001 1404 "TARGET_POWER"
1fd4e8c1
RK
1405 "doz%I2 %0,%1,%2")
1406
1407(define_insn ""
9ebbca7d 1408 [(set (match_operand:CC 0 "cc_reg_operand" "=x,?y")
1fd4e8c1 1409 (compare:CC
9ebbca7d
GK
1410 (if_then_else:SI (gt (match_operand:SI 1 "gpc_reg_operand" "r,r")
1411 (match_operand:SI 2 "reg_or_short_operand" "rI,rI"))
1fd4e8c1
RK
1412 (const_int 0)
1413 (minus:SI (match_dup 2) (match_dup 1)))
1414 (const_int 0)))
9ebbca7d 1415 (clobber (match_scratch:SI 3 "=r,r"))]
ca7f5001 1416 "TARGET_POWER"
9ebbca7d
GK
1417 "@
1418 doz%I2. %3,%1,%2
1419 #"
1420 [(set_attr "type" "delayed_compare")
1421 (set_attr "length" "4,8")])
1422
1423(define_split
1424 [(set (match_operand:CC 0 "cc_reg_not_cr0_operand" "")
1425 (compare:CC
1426 (if_then_else:SI (gt (match_operand:SI 1 "gpc_reg_operand" "")
1427 (match_operand:SI 2 "reg_or_short_operand" ""))
1428 (const_int 0)
1429 (minus:SI (match_dup 2) (match_dup 1)))
1430 (const_int 0)))
1431 (clobber (match_scratch:SI 3 ""))]
1432 "TARGET_POWER && reload_completed"
1433 [(set (match_dup 3)
1434 (if_then_else:SI (gt (match_dup 1) (match_dup 2))
1435 (const_int 0)
1436 (minus:SI (match_dup 2) (match_dup 1))))
1437 (set (match_dup 0)
1438 (compare:CC (match_dup 3)
1439 (const_int 0)))]
1440 "")
1fd4e8c1
RK
1441
1442(define_insn ""
9ebbca7d 1443 [(set (match_operand:CC 3 "cc_reg_operand" "=x,?y")
1fd4e8c1 1444 (compare:CC
9ebbca7d
GK
1445 (if_then_else:SI (gt (match_operand:SI 1 "gpc_reg_operand" "r,r")
1446 (match_operand:SI 2 "reg_or_short_operand" "rI,rI"))
1fd4e8c1
RK
1447 (const_int 0)
1448 (minus:SI (match_dup 2) (match_dup 1)))
1449 (const_int 0)))
9ebbca7d 1450 (set (match_operand:SI 0 "gpc_reg_operand" "=r,r")
1fd4e8c1
RK
1451 (if_then_else:SI (gt (match_dup 1) (match_dup 2))
1452 (const_int 0)
1453 (minus:SI (match_dup 2) (match_dup 1))))]
ca7f5001 1454 "TARGET_POWER"
9ebbca7d
GK
1455 "@
1456 doz%I2. %0,%1,%2
1457 #"
1458 [(set_attr "type" "delayed_compare")
1459 (set_attr "length" "4,8")])
1460
1461(define_split
1462 [(set (match_operand:CC 3 "cc_reg_not_cr0_operand" "")
1463 (compare:CC
1464 (if_then_else:SI (gt (match_operand:SI 1 "gpc_reg_operand" "")
1465 (match_operand:SI 2 "reg_or_short_operand" ""))
1466 (const_int 0)
1467 (minus:SI (match_dup 2) (match_dup 1)))
1468 (const_int 0)))
1469 (set (match_operand:SI 0 "gpc_reg_operand" "")
1470 (if_then_else:SI (gt (match_dup 1) (match_dup 2))
1471 (const_int 0)
1472 (minus:SI (match_dup 2) (match_dup 1))))]
1473 "TARGET_POWER && reload_completed"
1474 [(set (match_dup 0)
1475 (if_then_else:SI (gt (match_dup 1) (match_dup 2))
1476 (const_int 0)
1477 (minus:SI (match_dup 2) (match_dup 1))))
1478 (set (match_dup 3)
1479 (compare:CC (match_dup 0)
1480 (const_int 0)))]
1481 "")
1fd4e8c1
RK
1482
1483;; We don't need abs with condition code because such comparisons should
1484;; never be done.
ea9be077
MM
1485(define_expand "abssi2"
1486 [(set (match_operand:SI 0 "gpc_reg_operand" "")
1487 (abs:SI (match_operand:SI 1 "gpc_reg_operand" "")))]
1488 ""
1489 "
1490{
a3170dc6
AH
1491 if (TARGET_ISEL)
1492 {
1493 emit_insn (gen_abssi2_isel (operands[0], operands[1]));
1494 DONE;
1495 }
1496 else if (! TARGET_POWER)
ea9be077
MM
1497 {
1498 emit_insn (gen_abssi2_nopower (operands[0], operands[1]));
1499 DONE;
1500 }
1501}")
1502
ea112fc4 1503(define_insn "*abssi2_power"
cd2b37d9
RK
1504 [(set (match_operand:SI 0 "gpc_reg_operand" "=r")
1505 (abs:SI (match_operand:SI 1 "gpc_reg_operand" "r")))]
ca7f5001 1506 "TARGET_POWER"
1fd4e8c1
RK
1507 "abs %0,%1")
1508
a3170dc6
AH
1509(define_insn_and_split "abssi2_isel"
1510 [(set (match_operand:SI 0 "gpc_reg_operand" "=r")
1511 (abs:SI (match_operand:SI 1 "gpc_reg_operand" "b")))
8c48b6f5 1512 (clobber (match_scratch:SI 2 "=&b"))
a3170dc6
AH
1513 (clobber (match_scratch:CC 3 "=y"))]
1514 "TARGET_ISEL"
1515 "#"
1516 "&& reload_completed"
1517 [(set (match_dup 2) (neg:SI (match_dup 1)))
1518 (set (match_dup 3)
1519 (compare:CC (match_dup 1)
1520 (const_int 0)))
1521 (set (match_dup 0)
1522 (if_then_else:SI (ge (match_dup 3)
1523 (const_int 0))
1524 (match_dup 1)
1525 (match_dup 2)))]
1526 "")
1527
ea112fc4 1528(define_insn_and_split "abssi2_nopower"
ea9be077 1529 [(set (match_operand:SI 0 "gpc_reg_operand" "=&r,r")
ea112fc4 1530 (abs:SI (match_operand:SI 1 "gpc_reg_operand" "r,0")))
ea9be077 1531 (clobber (match_scratch:SI 2 "=&r,&r"))]
a3170dc6 1532 "! TARGET_POWER && ! TARGET_ISEL"
ea112fc4
DE
1533 "#"
1534 "&& reload_completed"
ea9be077
MM
1535 [(set (match_dup 2) (ashiftrt:SI (match_dup 1) (const_int 31)))
1536 (set (match_dup 0) (xor:SI (match_dup 2) (match_dup 1)))
7093ddee 1537 (set (match_dup 0) (minus:SI (match_dup 0) (match_dup 2)))]
ea9be077
MM
1538 "")
1539
463b558b 1540(define_insn "*nabs_power"
cd2b37d9
RK
1541 [(set (match_operand:SI 0 "gpc_reg_operand" "=r")
1542 (neg:SI (abs:SI (match_operand:SI 1 "gpc_reg_operand" "r"))))]
ca7f5001 1543 "TARGET_POWER"
1fd4e8c1
RK
1544 "nabs %0,%1")
1545
ea112fc4 1546(define_insn_and_split "*nabs_nopower"
ea9be077 1547 [(set (match_operand:SI 0 "gpc_reg_operand" "=&r,r")
ea112fc4 1548 (neg:SI (abs:SI (match_operand:SI 1 "gpc_reg_operand" "r,0"))))
ea9be077 1549 (clobber (match_scratch:SI 2 "=&r,&r"))]
0ad91047 1550 "! TARGET_POWER"
ea112fc4
DE
1551 "#"
1552 "&& reload_completed"
ea9be077
MM
1553 [(set (match_dup 2) (ashiftrt:SI (match_dup 1) (const_int 31)))
1554 (set (match_dup 0) (xor:SI (match_dup 2) (match_dup 1)))
7093ddee 1555 (set (match_dup 0) (minus:SI (match_dup 2) (match_dup 0)))]
ea9be077
MM
1556 "")
1557
1fd4e8c1 1558(define_insn "negsi2"
cd2b37d9
RK
1559 [(set (match_operand:SI 0 "gpc_reg_operand" "=r")
1560 (neg:SI (match_operand:SI 1 "gpc_reg_operand" "r")))]
1fd4e8c1
RK
1561 ""
1562 "neg %0,%1")
1563
1564(define_insn ""
9ebbca7d
GK
1565 [(set (match_operand:CC 0 "cc_reg_operand" "=x,?y")
1566 (compare:CC (neg:SI (match_operand:SI 1 "gpc_reg_operand" "r,r"))
1fd4e8c1 1567 (const_int 0)))
9ebbca7d 1568 (clobber (match_scratch:SI 2 "=r,r"))]
4b8a63d6 1569 "TARGET_32BIT"
9ebbca7d
GK
1570 "@
1571 neg. %2,%1
1572 #"
a62bfff2 1573 [(set_attr "type" "fast_compare")
9ebbca7d
GK
1574 (set_attr "length" "4,8")])
1575
1576(define_split
1577 [(set (match_operand:CC 0 "cc_reg_not_cr0_operand" "")
1578 (compare:CC (neg:SI (match_operand:SI 1 "gpc_reg_operand" ""))
1579 (const_int 0)))
1580 (clobber (match_scratch:SI 2 ""))]
4b8a63d6 1581 "TARGET_32BIT && reload_completed"
9ebbca7d
GK
1582 [(set (match_dup 2)
1583 (neg:SI (match_dup 1)))
1584 (set (match_dup 0)
1585 (compare:CC (match_dup 2)
1586 (const_int 0)))]
1587 "")
1fd4e8c1
RK
1588
1589(define_insn ""
9ebbca7d
GK
1590 [(set (match_operand:CC 2 "cc_reg_operand" "=x,?y")
1591 (compare:CC (neg:SI (match_operand:SI 1 "gpc_reg_operand" "r,r"))
815cdc52 1592 (const_int 0)))
9ebbca7d 1593 (set (match_operand:SI 0 "gpc_reg_operand" "=r,r")
815cdc52 1594 (neg:SI (match_dup 1)))]
4b8a63d6 1595 "TARGET_32BIT"
9ebbca7d
GK
1596 "@
1597 neg. %0,%1
1598 #"
a62bfff2 1599 [(set_attr "type" "fast_compare")
9ebbca7d
GK
1600 (set_attr "length" "4,8")])
1601
1602(define_split
1603 [(set (match_operand:CC 2 "cc_reg_not_cr0_operand" "")
1604 (compare:CC (neg:SI (match_operand:SI 1 "gpc_reg_operand" ""))
1605 (const_int 0)))
1606 (set (match_operand:SI 0 "gpc_reg_operand" "")
1607 (neg:SI (match_dup 1)))]
4b8a63d6 1608 "TARGET_32BIT && reload_completed"
9ebbca7d
GK
1609 [(set (match_dup 0)
1610 (neg:SI (match_dup 1)))
1611 (set (match_dup 2)
1612 (compare:CC (match_dup 0)
1613 (const_int 0)))]
1614 "")
1fd4e8c1 1615
1b1edcfa
DE
1616(define_insn "clzsi2"
1617 [(set (match_operand:SI 0 "gpc_reg_operand" "=r")
1618 (clz:SI (match_operand:SI 1 "gpc_reg_operand" "r")))]
1619 ""
1620 "{cntlz|cntlzw} %0,%1")
1621
1622(define_expand "ctzsi2"
4977bab6 1623 [(set (match_dup 2)
1b1edcfa 1624 (neg:SI (match_operand:SI 1 "gpc_reg_operand" "r")))
4977bab6 1625 (parallel [(set (match_dup 3) (and:SI (match_dup 1)
1b1edcfa
DE
1626 (match_dup 2)))
1627 (clobber (scratch:CC))])
d865b122 1628 (set (match_dup 4) (clz:SI (match_dup 3)))
4977bab6 1629 (set (match_operand:SI 0 "gpc_reg_operand" "=r")
1b1edcfa 1630 (minus:SI (const_int 31) (match_dup 4)))]
1fd4e8c1 1631 ""
4977bab6
ZW
1632 {
1633 operands[2] = gen_reg_rtx (SImode);
1634 operands[3] = gen_reg_rtx (SImode);
1635 operands[4] = gen_reg_rtx (SImode);
1636 })
6ae08853 1637
1b1edcfa
DE
1638(define_expand "ffssi2"
1639 [(set (match_dup 2)
1640 (neg:SI (match_operand:SI 1 "gpc_reg_operand" "r")))
1641 (parallel [(set (match_dup 3) (and:SI (match_dup 1)
1642 (match_dup 2)))
1643 (clobber (scratch:CC))])
1644 (set (match_dup 4) (clz:SI (match_dup 3)))
1645 (set (match_operand:SI 0 "gpc_reg_operand" "=r")
1646 (minus:SI (const_int 32) (match_dup 4)))]
4977bab6 1647 ""
1b1edcfa
DE
1648 {
1649 operands[2] = gen_reg_rtx (SImode);
1650 operands[3] = gen_reg_rtx (SImode);
1651 operands[4] = gen_reg_rtx (SImode);
1652 })
6ae08853 1653
ca7f5001
RK
1654(define_expand "mulsi3"
1655 [(use (match_operand:SI 0 "gpc_reg_operand" ""))
1656 (use (match_operand:SI 1 "gpc_reg_operand" ""))
1657 (use (match_operand:SI 2 "reg_or_short_operand" ""))]
1658 ""
1659 "
1660{
1661 if (TARGET_POWER)
68b40e7e 1662 emit_insn (gen_mulsi3_mq (operands[0], operands[1], operands[2]));
ca7f5001 1663 else
68b40e7e 1664 emit_insn (gen_mulsi3_no_mq (operands[0], operands[1], operands[2]));
ca7f5001
RK
1665 DONE;
1666}")
1667
68b40e7e 1668(define_insn "mulsi3_mq"
cd2b37d9
RK
1669 [(set (match_operand:SI 0 "gpc_reg_operand" "=r,r")
1670 (mult:SI (match_operand:SI 1 "gpc_reg_operand" "%r,r")
1fd4e8c1
RK
1671 (match_operand:SI 2 "reg_or_short_operand" "r,I")))
1672 (clobber (match_scratch:SI 3 "=q,q"))]
ca7f5001
RK
1673 "TARGET_POWER"
1674 "@
1675 {muls|mullw} %0,%1,%2
1676 {muli|mulli} %0,%1,%2"
6ae08853 1677 [(set (attr "type")
c859cda6
DJ
1678 (cond [(match_operand:SI 2 "s8bit_cint_operand" "")
1679 (const_string "imul3")
6ae08853 1680 (match_operand:SI 2 "short_cint_operand" "")
c859cda6
DJ
1681 (const_string "imul2")]
1682 (const_string "imul")))])
ca7f5001 1683
68b40e7e 1684(define_insn "mulsi3_no_mq"
ca7f5001
RK
1685 [(set (match_operand:SI 0 "gpc_reg_operand" "=r,r")
1686 (mult:SI (match_operand:SI 1 "gpc_reg_operand" "%r,r")
1687 (match_operand:SI 2 "reg_or_short_operand" "r,I")))]
68b40e7e 1688 "! TARGET_POWER"
1fd4e8c1 1689 "@
d904e9ed
RK
1690 {muls|mullw} %0,%1,%2
1691 {muli|mulli} %0,%1,%2"
6ae08853 1692 [(set (attr "type")
c859cda6
DJ
1693 (cond [(match_operand:SI 2 "s8bit_cint_operand" "")
1694 (const_string "imul3")
6ae08853 1695 (match_operand:SI 2 "short_cint_operand" "")
c859cda6
DJ
1696 (const_string "imul2")]
1697 (const_string "imul")))])
1fd4e8c1 1698
9259f3b0 1699(define_insn "*mulsi3_mq_internal1"
9ebbca7d
GK
1700 [(set (match_operand:CC 0 "cc_reg_operand" "=x,?y")
1701 (compare:CC (mult:SI (match_operand:SI 1 "gpc_reg_operand" "%r,r")
1702 (match_operand:SI 2 "gpc_reg_operand" "r,r"))
1fd4e8c1 1703 (const_int 0)))
9ebbca7d
GK
1704 (clobber (match_scratch:SI 3 "=r,r"))
1705 (clobber (match_scratch:SI 4 "=q,q"))]
ca7f5001 1706 "TARGET_POWER"
9ebbca7d
GK
1707 "@
1708 {muls.|mullw.} %3,%1,%2
1709 #"
9259f3b0 1710 [(set_attr "type" "imul_compare")
9ebbca7d
GK
1711 (set_attr "length" "4,8")])
1712
1713(define_split
1714 [(set (match_operand:CC 0 "cc_reg_not_cr0_operand" "")
1715 (compare:CC (mult:SI (match_operand:SI 1 "gpc_reg_operand" "")
1716 (match_operand:SI 2 "gpc_reg_operand" ""))
1717 (const_int 0)))
1718 (clobber (match_scratch:SI 3 ""))
1719 (clobber (match_scratch:SI 4 ""))]
1720 "TARGET_POWER && reload_completed"
1721 [(parallel [(set (match_dup 3)
1722 (mult:SI (match_dup 1) (match_dup 2)))
1723 (clobber (match_dup 4))])
1724 (set (match_dup 0)
1725 (compare:CC (match_dup 3)
1726 (const_int 0)))]
1727 "")
ca7f5001 1728
9259f3b0 1729(define_insn "*mulsi3_no_mq_internal1"
9ebbca7d
GK
1730 [(set (match_operand:CC 0 "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"))
ca7f5001 1733 (const_int 0)))
9ebbca7d 1734 (clobber (match_scratch:SI 3 "=r,r"))]
25c341fa 1735 "! TARGET_POWER"
9ebbca7d
GK
1736 "@
1737 {muls.|mullw.} %3,%1,%2
1738 #"
9259f3b0 1739 [(set_attr "type" "imul_compare")
9ebbca7d
GK
1740 (set_attr "length" "4,8")])
1741
1742(define_split
1743 [(set (match_operand:CC 0 "cc_reg_not_cr0_operand" "")
1744 (compare:CC (mult:SI (match_operand:SI 1 "gpc_reg_operand" "")
1745 (match_operand:SI 2 "gpc_reg_operand" ""))
1746 (const_int 0)))
1747 (clobber (match_scratch:SI 3 ""))]
1748 "! TARGET_POWER && reload_completed"
1749 [(set (match_dup 3)
1750 (mult:SI (match_dup 1) (match_dup 2)))
1751 (set (match_dup 0)
1752 (compare:CC (match_dup 3)
1753 (const_int 0)))]
1754 "")
1fd4e8c1 1755
9259f3b0 1756(define_insn "*mulsi3_mq_internal2"
9ebbca7d
GK
1757 [(set (match_operand:CC 3 "cc_reg_operand" "=x,?y")
1758 (compare:CC (mult:SI (match_operand:SI 1 "gpc_reg_operand" "%r,r")
1759 (match_operand:SI 2 "gpc_reg_operand" "r,r"))
1fd4e8c1 1760 (const_int 0)))
9ebbca7d 1761 (set (match_operand:SI 0 "gpc_reg_operand" "=r,r")
29ae5b89 1762 (mult:SI (match_dup 1) (match_dup 2)))
9ebbca7d 1763 (clobber (match_scratch:SI 4 "=q,q"))]
ca7f5001 1764 "TARGET_POWER"
9ebbca7d
GK
1765 "@
1766 {muls.|mullw.} %0,%1,%2
1767 #"
9259f3b0 1768 [(set_attr "type" "imul_compare")
9ebbca7d
GK
1769 (set_attr "length" "4,8")])
1770
1771(define_split
1772 [(set (match_operand:CC 3 "cc_reg_not_cr0_operand" "")
1773 (compare:CC (mult:SI (match_operand:SI 1 "gpc_reg_operand" "")
1774 (match_operand:SI 2 "gpc_reg_operand" ""))
1775 (const_int 0)))
1776 (set (match_operand:SI 0 "gpc_reg_operand" "")
1777 (mult:SI (match_dup 1) (match_dup 2)))
1778 (clobber (match_scratch:SI 4 ""))]
1779 "TARGET_POWER && reload_completed"
1780 [(parallel [(set (match_dup 0)
1781 (mult:SI (match_dup 1) (match_dup 2)))
1782 (clobber (match_dup 4))])
1783 (set (match_dup 3)
1784 (compare:CC (match_dup 0)
1785 (const_int 0)))]
1786 "")
ca7f5001 1787
9259f3b0 1788(define_insn "*mulsi3_no_mq_internal2"
9ebbca7d
GK
1789 [(set (match_operand:CC 3 "cc_reg_operand" "=x,?y")
1790 (compare:CC (mult:SI (match_operand:SI 1 "gpc_reg_operand" "%r,r")
1791 (match_operand:SI 2 "gpc_reg_operand" "r,r"))
ca7f5001 1792 (const_int 0)))
9ebbca7d 1793 (set (match_operand:SI 0 "gpc_reg_operand" "=r,r")
ca7f5001 1794 (mult:SI (match_dup 1) (match_dup 2)))]
25c341fa 1795 "! TARGET_POWER"
9ebbca7d
GK
1796 "@
1797 {muls.|mullw.} %0,%1,%2
1798 #"
9259f3b0 1799 [(set_attr "type" "imul_compare")
9ebbca7d
GK
1800 (set_attr "length" "4,8")])
1801
1802(define_split
1803 [(set (match_operand:CC 3 "cc_reg_not_cr0_operand" "")
1804 (compare:CC (mult:SI (match_operand:SI 1 "gpc_reg_operand" "")
1805 (match_operand:SI 2 "gpc_reg_operand" ""))
1806 (const_int 0)))
1807 (set (match_operand:SI 0 "gpc_reg_operand" "")
1808 (mult:SI (match_dup 1) (match_dup 2)))]
1809 "! TARGET_POWER && reload_completed"
1810 [(set (match_dup 0)
1811 (mult:SI (match_dup 1) (match_dup 2)))
1812 (set (match_dup 3)
1813 (compare:CC (match_dup 0)
1814 (const_int 0)))]
1815 "")
1fd4e8c1
RK
1816
1817;; Operand 1 is divided by operand 2; quotient goes to operand
1818;; 0 and remainder to operand 3.
1819;; ??? At some point, see what, if anything, we can do about if (x % y == 0).
1820
8ffd9c51
RK
1821(define_expand "divmodsi4"
1822 [(parallel [(set (match_operand:SI 0 "gpc_reg_operand" "")
1823 (div:SI (match_operand:SI 1 "gpc_reg_operand" "")
1824 (match_operand:SI 2 "gpc_reg_operand" "")))
bb157ff4 1825 (set (match_operand:SI 3 "register_operand" "")
8ffd9c51
RK
1826 (mod:SI (match_dup 1) (match_dup 2)))])]
1827 "TARGET_POWER || (! TARGET_POWER && ! TARGET_POWERPC)"
1828 "
1829{
1830 if (! TARGET_POWER && ! TARGET_POWERPC)
1831 {
39403d82
DE
1832 emit_move_insn (gen_rtx_REG (SImode, 3), operands[1]);
1833 emit_move_insn (gen_rtx_REG (SImode, 4), operands[2]);
fada905b 1834 emit_insn (gen_divss_call ());
39403d82
DE
1835 emit_move_insn (operands[0], gen_rtx_REG (SImode, 3));
1836 emit_move_insn (operands[3], gen_rtx_REG (SImode, 4));
8ffd9c51
RK
1837 DONE;
1838 }
1839}")
deb9225a 1840
bb157ff4 1841(define_insn "*divmodsi4_internal"
cd2b37d9
RK
1842 [(set (match_operand:SI 0 "gpc_reg_operand" "=r")
1843 (div:SI (match_operand:SI 1 "gpc_reg_operand" "r")
1844 (match_operand:SI 2 "gpc_reg_operand" "r")))
bb157ff4 1845 (set (match_operand:SI 3 "register_operand" "=q")
1fd4e8c1 1846 (mod:SI (match_dup 1) (match_dup 2)))]
ca7f5001 1847 "TARGET_POWER"
cfb557c4
RK
1848 "divs %0,%1,%2"
1849 [(set_attr "type" "idiv")])
1fd4e8c1 1850
8ffd9c51
RK
1851(define_expand "udivsi3"
1852 [(set (match_operand:SI 0 "gpc_reg_operand" "")
1853 (udiv:SI (match_operand:SI 1 "gpc_reg_operand" "")
1854 (match_operand:SI 2 "gpc_reg_operand" "")))]
1855 "TARGET_POWERPC || (! TARGET_POWER && ! TARGET_POWERPC)"
1856 "
1857{
1858 if (! TARGET_POWER && ! TARGET_POWERPC)
1859 {
39403d82
DE
1860 emit_move_insn (gen_rtx_REG (SImode, 3), operands[1]);
1861 emit_move_insn (gen_rtx_REG (SImode, 4), operands[2]);
fada905b 1862 emit_insn (gen_quous_call ());
39403d82 1863 emit_move_insn (operands[0], gen_rtx_REG (SImode, 3));
8ffd9c51
RK
1864 DONE;
1865 }
f192bf8b
DE
1866 else if (TARGET_POWER)
1867 {
1868 emit_insn (gen_udivsi3_mq (operands[0], operands[1], operands[2]));
1869 DONE;
1870 }
8ffd9c51 1871}")
deb9225a 1872
f192bf8b
DE
1873(define_insn "udivsi3_mq"
1874 [(set (match_operand:SI 0 "gpc_reg_operand" "=r")
1875 (udiv:SI (match_operand:SI 1 "gpc_reg_operand" "r")
1876 (match_operand:SI 2 "gpc_reg_operand" "r")))
1877 (clobber (match_scratch:SI 3 "=q"))]
1878 "TARGET_POWERPC && TARGET_POWER"
1879 "divwu %0,%1,%2"
1880 [(set_attr "type" "idiv")])
1881
1882(define_insn "*udivsi3_no_mq"
ca7f5001
RK
1883 [(set (match_operand:SI 0 "gpc_reg_operand" "=r")
1884 (udiv:SI (match_operand:SI 1 "gpc_reg_operand" "r")
1885 (match_operand:SI 2 "gpc_reg_operand" "r")))]
f192bf8b 1886 "TARGET_POWERPC && ! TARGET_POWER"
a473029f 1887 "divwu %0,%1,%2"
ca7f5001
RK
1888 [(set_attr "type" "idiv")])
1889
1fd4e8c1 1890;; For powers of two we can do srai/aze for divide and then adjust for
ca7f5001 1891;; modulus. If it isn't a power of two, FAIL on POWER so divmodsi4 will be
8ffd9c51
RK
1892;; used; for PowerPC, force operands into register and do a normal divide;
1893;; for AIX common-mode, use quoss call on register operands.
1fd4e8c1 1894(define_expand "divsi3"
cd2b37d9
RK
1895 [(set (match_operand:SI 0 "gpc_reg_operand" "")
1896 (div:SI (match_operand:SI 1 "gpc_reg_operand" "")
1fd4e8c1
RK
1897 (match_operand:SI 2 "reg_or_cint_operand" "")))]
1898 ""
1899 "
1900{
ca7f5001 1901 if (GET_CODE (operands[2]) == CONST_INT
2bfcf297 1902 && INTVAL (operands[2]) > 0
ca7f5001
RK
1903 && exact_log2 (INTVAL (operands[2])) >= 0)
1904 ;
b6c9286a 1905 else if (TARGET_POWERPC)
f192bf8b
DE
1906 {
1907 operands[2] = force_reg (SImode, operands[2]);
1908 if (TARGET_POWER)
1909 {
1910 emit_insn (gen_divsi3_mq (operands[0], operands[1], operands[2]));
1911 DONE;
1912 }
1913 }
b6c9286a 1914 else if (TARGET_POWER)
1fd4e8c1 1915 FAIL;
405c5495 1916 else
8ffd9c51 1917 {
39403d82
DE
1918 emit_move_insn (gen_rtx_REG (SImode, 3), operands[1]);
1919 emit_move_insn (gen_rtx_REG (SImode, 4), operands[2]);
fada905b 1920 emit_insn (gen_quoss_call ());
39403d82 1921 emit_move_insn (operands[0], gen_rtx_REG (SImode, 3));
8ffd9c51
RK
1922 DONE;
1923 }
1fd4e8c1
RK
1924}")
1925
f192bf8b
DE
1926(define_insn "divsi3_mq"
1927 [(set (match_operand:SI 0 "gpc_reg_operand" "=r")
1928 (div:SI (match_operand:SI 1 "gpc_reg_operand" "r")
1929 (match_operand:SI 2 "gpc_reg_operand" "r")))
1930 (clobber (match_scratch:SI 3 "=q"))]
1931 "TARGET_POWERPC && TARGET_POWER"
1932 "divw %0,%1,%2"
1933 [(set_attr "type" "idiv")])
1934
1935(define_insn "*divsi3_no_mq"
1936 [(set (match_operand:SI 0 "gpc_reg_operand" "=r")
1937 (div:SI (match_operand:SI 1 "gpc_reg_operand" "r")
1938 (match_operand:SI 2 "gpc_reg_operand" "r")))]
1939 "TARGET_POWERPC && ! TARGET_POWER"
1940 "divw %0,%1,%2"
1941 [(set_attr "type" "idiv")])
1942
1fd4e8c1 1943(define_expand "modsi3"
85644414
RK
1944 [(use (match_operand:SI 0 "gpc_reg_operand" ""))
1945 (use (match_operand:SI 1 "gpc_reg_operand" ""))
405c5495 1946 (use (match_operand:SI 2 "reg_or_cint_operand" ""))]
39b52ba2 1947 ""
1fd4e8c1
RK
1948 "
1949{
481c7efa 1950 int i;
39b52ba2
RK
1951 rtx temp1;
1952 rtx temp2;
1953
2bfcf297 1954 if (GET_CODE (operands[2]) != CONST_INT
a65c591c 1955 || INTVAL (operands[2]) <= 0
2bfcf297 1956 || (i = exact_log2 (INTVAL (operands[2]))) < 0)
39b52ba2
RK
1957 FAIL;
1958
1959 temp1 = gen_reg_rtx (SImode);
1960 temp2 = gen_reg_rtx (SImode);
1fd4e8c1 1961
85644414 1962 emit_insn (gen_divsi3 (temp1, operands[1], operands[2]));
39b52ba2 1963 emit_insn (gen_ashlsi3 (temp2, temp1, GEN_INT (i)));
85644414
RK
1964 emit_insn (gen_subsi3 (operands[0], operands[1], temp2));
1965 DONE;
1fd4e8c1
RK
1966}")
1967
1968(define_insn ""
cd2b37d9
RK
1969 [(set (match_operand:SI 0 "gpc_reg_operand" "=r")
1970 (div:SI (match_operand:SI 1 "gpc_reg_operand" "r")
2bfcf297
DB
1971 (match_operand:SI 2 "exact_log2_cint_operand" "N")))]
1972 ""
ca7f5001 1973 "{srai|srawi} %0,%1,%p2\;{aze|addze} %0,%0"
b19003d8 1974 [(set_attr "length" "8")])
1fd4e8c1
RK
1975
1976(define_insn ""
9ebbca7d
GK
1977 [(set (match_operand:CC 0 "cc_reg_operand" "=x,?y")
1978 (compare:CC (div:SI (match_operand:SI 1 "gpc_reg_operand" "r,r")
2bfcf297 1979 (match_operand:SI 2 "exact_log2_cint_operand" "N,N"))
b6b12107 1980 (const_int 0)))
9ebbca7d 1981 (clobber (match_scratch:SI 3 "=r,r"))]
2bfcf297 1982 ""
9ebbca7d
GK
1983 "@
1984 {srai|srawi} %3,%1,%p2\;{aze.|addze.} %3,%3
1985 #"
b19003d8 1986 [(set_attr "type" "compare")
9ebbca7d
GK
1987 (set_attr "length" "8,12")])
1988
1989(define_split
1990 [(set (match_operand:CC 0 "cc_reg_not_cr0_operand" "")
1991 (compare:CC (div:SI (match_operand:SI 1 "gpc_reg_operand" "")
2bfcf297 1992 (match_operand:SI 2 "exact_log2_cint_operand" ""))
9ebbca7d
GK
1993 (const_int 0)))
1994 (clobber (match_scratch:SI 3 ""))]
2bfcf297 1995 "reload_completed"
9ebbca7d
GK
1996 [(set (match_dup 3)
1997 (div:SI (match_dup 1) (match_dup 2)))
1998 (set (match_dup 0)
1999 (compare:CC (match_dup 3)
2000 (const_int 0)))]
2001 "")
1fd4e8c1
RK
2002
2003(define_insn ""
9ebbca7d
GK
2004 [(set (match_operand:CC 3 "cc_reg_operand" "=x,?y")
2005 (compare:CC (div:SI (match_operand:SI 1 "gpc_reg_operand" "r,r")
2bfcf297 2006 (match_operand:SI 2 "exact_log2_cint_operand" "N,N"))
b6b12107 2007 (const_int 0)))
9ebbca7d 2008 (set (match_operand:SI 0 "gpc_reg_operand" "=r,r")
29ae5b89 2009 (div:SI (match_dup 1) (match_dup 2)))]
2bfcf297 2010 ""
9ebbca7d
GK
2011 "@
2012 {srai|srawi} %0,%1,%p2\;{aze.|addze.} %0,%0
2013 #"
b19003d8 2014 [(set_attr "type" "compare")
9ebbca7d
GK
2015 (set_attr "length" "8,12")])
2016
2017(define_split
2018 [(set (match_operand:CC 3 "cc_reg_not_cr0_operand" "")
2019 (compare:CC (div:SI (match_operand:SI 1 "gpc_reg_operand" "")
2bfcf297 2020 (match_operand:SI 2 "exact_log2_cint_operand" ""))
9ebbca7d
GK
2021 (const_int 0)))
2022 (set (match_operand:SI 0 "gpc_reg_operand" "")
2023 (div:SI (match_dup 1) (match_dup 2)))]
2bfcf297 2024 "reload_completed"
9ebbca7d
GK
2025 [(set (match_dup 0)
2026 (div:SI (match_dup 1) (match_dup 2)))
2027 (set (match_dup 3)
2028 (compare:CC (match_dup 0)
2029 (const_int 0)))]
2030 "")
1fd4e8c1
RK
2031
2032(define_insn ""
cd2b37d9 2033 [(set (match_operand:SI 0 "gpc_reg_operand" "=r")
1fd4e8c1 2034 (udiv:SI
996a5f59 2035 (plus:DI (ashift:DI
cd2b37d9 2036 (zero_extend:DI (match_operand:SI 1 "gpc_reg_operand" "r"))
1fd4e8c1 2037 (const_int 32))
23a900dc 2038 (zero_extend:DI (match_operand:SI 4 "register_operand" "2")))
cd2b37d9 2039 (match_operand:SI 3 "gpc_reg_operand" "r")))
740ab4a2 2040 (set (match_operand:SI 2 "register_operand" "=*q")
1fd4e8c1 2041 (umod:SI
996a5f59 2042 (plus:DI (ashift:DI
1fd4e8c1 2043 (zero_extend:DI (match_dup 1)) (const_int 32))
740ab4a2 2044 (zero_extend:DI (match_dup 4)))
1fd4e8c1 2045 (match_dup 3)))]
ca7f5001 2046 "TARGET_POWER"
cfb557c4
RK
2047 "div %0,%1,%3"
2048 [(set_attr "type" "idiv")])
1fd4e8c1
RK
2049
2050;; To do unsigned divide we handle the cases of the divisor looking like a
2051;; negative number. If it is a constant that is less than 2**31, we don't
2052;; have to worry about the branches. So make a few subroutines here.
2053;;
2054;; First comes the normal case.
2055(define_expand "udivmodsi4_normal"
2056 [(set (match_dup 4) (const_int 0))
2057 (parallel [(set (match_operand:SI 0 "" "")
996a5f59 2058 (udiv:SI (plus:DI (ashift:DI (zero_extend:DI (match_dup 4))
1fd4e8c1
RK
2059 (const_int 32))
2060 (zero_extend:DI (match_operand:SI 1 "" "")))
2061 (match_operand:SI 2 "" "")))
2062 (set (match_operand:SI 3 "" "")
996a5f59 2063 (umod:SI (plus:DI (ashift:DI (zero_extend:DI (match_dup 4))
1fd4e8c1
RK
2064 (const_int 32))
2065 (zero_extend:DI (match_dup 1)))
2066 (match_dup 2)))])]
ca7f5001 2067 "TARGET_POWER"
1fd4e8c1
RK
2068 "
2069{ operands[4] = gen_reg_rtx (SImode); }")
2070
2071;; This handles the branches.
2072(define_expand "udivmodsi4_tests"
2073 [(set (match_operand:SI 0 "" "") (const_int 0))
2074 (set (match_operand:SI 3 "" "") (match_operand:SI 1 "" ""))
2075 (set (match_dup 5) (compare:CCUNS (match_dup 1) (match_operand:SI 2 "" "")))
2076 (set (pc) (if_then_else (ltu (match_dup 5) (const_int 0))
2077 (label_ref (match_operand:SI 4 "" "")) (pc)))
2078 (set (match_dup 0) (const_int 1))
2079 (set (match_dup 3) (minus:SI (match_dup 1) (match_dup 2)))
2080 (set (match_dup 6) (compare:CC (match_dup 2) (const_int 0)))
2081 (set (pc) (if_then_else (lt (match_dup 6) (const_int 0))
2082 (label_ref (match_dup 4)) (pc)))]
ca7f5001 2083 "TARGET_POWER"
1fd4e8c1
RK
2084 "
2085{ operands[5] = gen_reg_rtx (CCUNSmode);
2086 operands[6] = gen_reg_rtx (CCmode);
2087}")
2088
2089(define_expand "udivmodsi4"
cd2b37d9
RK
2090 [(parallel [(set (match_operand:SI 0 "gpc_reg_operand" "")
2091 (udiv:SI (match_operand:SI 1 "gpc_reg_operand" "")
1fd4e8c1 2092 (match_operand:SI 2 "reg_or_cint_operand" "")))
cd2b37d9 2093 (set (match_operand:SI 3 "gpc_reg_operand" "")
1fd4e8c1 2094 (umod:SI (match_dup 1) (match_dup 2)))])]
8ffd9c51 2095 ""
1fd4e8c1
RK
2096 "
2097{
2098 rtx label = 0;
2099
8ffd9c51 2100 if (! TARGET_POWER)
c4d38ccb
MM
2101 {
2102 if (! TARGET_POWERPC)
2103 {
39403d82
DE
2104 emit_move_insn (gen_rtx_REG (SImode, 3), operands[1]);
2105 emit_move_insn (gen_rtx_REG (SImode, 4), operands[2]);
c4d38ccb 2106 emit_insn (gen_divus_call ());
39403d82
DE
2107 emit_move_insn (operands[0], gen_rtx_REG (SImode, 3));
2108 emit_move_insn (operands[3], gen_rtx_REG (SImode, 4));
c4d38ccb
MM
2109 DONE;
2110 }
2111 else
2112 FAIL;
2113 }
0081a354 2114
1fd4e8c1
RK
2115 if (GET_CODE (operands[2]) != CONST_INT || INTVAL (operands[2]) < 0)
2116 {
2117 operands[2] = force_reg (SImode, operands[2]);
2118 label = gen_label_rtx ();
2119 emit (gen_udivmodsi4_tests (operands[0], operands[1], operands[2],
2120 operands[3], label));
2121 }
2122 else
2123 operands[2] = force_reg (SImode, operands[2]);
2124
2125 emit (gen_udivmodsi4_normal (operands[0], operands[1], operands[2],
2126 operands[3]));
2127 if (label)
2128 emit_label (label);
2129
2130 DONE;
2131}")
0081a354 2132
fada905b
MM
2133;; AIX architecture-independent common-mode multiply (DImode),
2134;; divide/modulus, and quotient subroutine calls. Input operands in R3 and
2135;; R4; results in R3 and sometimes R4; link register always clobbered by bla
2136;; instruction; R0 sometimes clobbered; also, MQ sometimes clobbered but
2137;; assumed unused if generating common-mode, so ignore.
2138(define_insn "mulh_call"
2139 [(set (reg:SI 3)
2140 (truncate:SI
2141 (lshiftrt:DI (mult:DI (sign_extend:DI (reg:SI 3))
2142 (sign_extend:DI (reg:SI 4)))
2143 (const_int 32))))
cf27b467 2144 (clobber (match_scratch:SI 0 "=l"))]
fada905b 2145 "! TARGET_POWER && ! TARGET_POWERPC"
b7ff3d82
DE
2146 "bla __mulh"
2147 [(set_attr "type" "imul")])
fada905b
MM
2148
2149(define_insn "mull_call"
2150 [(set (reg:DI 3)
2151 (mult:DI (sign_extend:DI (reg:SI 3))
2152 (sign_extend:DI (reg:SI 4))))
2153 (clobber (match_scratch:SI 0 "=l"))
2154 (clobber (reg:SI 0))]
2155 "! TARGET_POWER && ! TARGET_POWERPC"
b7ff3d82
DE
2156 "bla __mull"
2157 [(set_attr "type" "imul")])
fada905b
MM
2158
2159(define_insn "divss_call"
2160 [(set (reg:SI 3)
2161 (div:SI (reg:SI 3) (reg:SI 4)))
2162 (set (reg:SI 4)
2163 (mod:SI (reg:SI 3) (reg:SI 4)))
2164 (clobber (match_scratch:SI 0 "=l"))
2165 (clobber (reg:SI 0))]
2166 "! TARGET_POWER && ! TARGET_POWERPC"
b7ff3d82
DE
2167 "bla __divss"
2168 [(set_attr "type" "idiv")])
fada905b
MM
2169
2170(define_insn "divus_call"
8ffd9c51
RK
2171 [(set (reg:SI 3)
2172 (udiv:SI (reg:SI 3) (reg:SI 4)))
2173 (set (reg:SI 4)
2174 (umod:SI (reg:SI 3) (reg:SI 4)))
2175 (clobber (match_scratch:SI 0 "=l"))
fada905b
MM
2176 (clobber (reg:SI 0))
2177 (clobber (match_scratch:CC 1 "=x"))
2178 (clobber (reg:CC 69))]
2179 "! TARGET_POWER && ! TARGET_POWERPC"
b7ff3d82
DE
2180 "bla __divus"
2181 [(set_attr "type" "idiv")])
fada905b
MM
2182
2183(define_insn "quoss_call"
2184 [(set (reg:SI 3)
2185 (div:SI (reg:SI 3) (reg:SI 4)))
cf27b467 2186 (clobber (match_scratch:SI 0 "=l"))]
8ffd9c51 2187 "! TARGET_POWER && ! TARGET_POWERPC"
b7ff3d82
DE
2188 "bla __quoss"
2189 [(set_attr "type" "idiv")])
0081a354 2190
fada905b
MM
2191(define_insn "quous_call"
2192 [(set (reg:SI 3)
2193 (udiv:SI (reg:SI 3) (reg:SI 4)))
2194 (clobber (match_scratch:SI 0 "=l"))
2195 (clobber (reg:SI 0))
2196 (clobber (match_scratch:CC 1 "=x"))
2197 (clobber (reg:CC 69))]
2198 "! TARGET_POWER && ! TARGET_POWERPC"
b7ff3d82
DE
2199 "bla __quous"
2200 [(set_attr "type" "idiv")])
8ffd9c51 2201\f
bb21487f 2202;; Logical instructions
dfbdccdb
GK
2203;; The logical instructions are mostly combined by using match_operator,
2204;; but the plain AND insns are somewhat different because there is no
2205;; plain 'andi' (only 'andi.'), no plain 'andis', and there are all
2206;; those rotate-and-mask operations. Thus, the AND insns come first.
2207
29ae5b89
JL
2208(define_insn "andsi3"
2209 [(set (match_operand:SI 0 "gpc_reg_operand" "=r,r,r,r")
2210 (and:SI (match_operand:SI 1 "gpc_reg_operand" "%r,r,r,r")
5f59ecb7 2211 (match_operand:SI 2 "and_operand" "?r,T,K,L")))
29ae5b89 2212 (clobber (match_scratch:CC 3 "=X,X,x,x"))]
1fd4e8c1
RK
2213 ""
2214 "@
2215 and %0,%1,%2
ca7f5001
RK
2216 {rlinm|rlwinm} %0,%1,0,%m2,%M2
2217 {andil.|andi.} %0,%1,%b2
9ebbca7d 2218 {andiu.|andis.} %0,%1,%u2")
52d3af72
DE
2219
2220;; Note to set cr's other than cr0 we do the and immediate and then
0ba1b2ff 2221;; the test again -- this avoids a mfcr which on the higher end
52d3af72 2222;; machines causes an execution serialization
1fd4e8c1 2223
7cd5235b 2224(define_insn "*andsi3_internal2"
52d3af72
DE
2225 [(set (match_operand:CC 0 "cc_reg_operand" "=x,x,x,x,?y,??y,??y,?y")
2226 (compare:CC (and:SI (match_operand:SI 1 "gpc_reg_operand" "%r,r,r,r,r,r,r,r")
5f59ecb7 2227 (match_operand:SI 2 "and_operand" "r,K,L,T,r,K,L,T"))
1fd4e8c1 2228 (const_int 0)))
52d3af72
DE
2229 (clobber (match_scratch:SI 3 "=r,r,r,r,r,r,r,r"))
2230 (clobber (match_scratch:CC 4 "=X,X,X,X,X,x,x,X"))]
4b8a63d6 2231 "TARGET_32BIT"
1fd4e8c1
RK
2232 "@
2233 and. %3,%1,%2
ca7f5001
RK
2234 {andil.|andi.} %3,%1,%b2
2235 {andiu.|andis.} %3,%1,%u2
52d3af72
DE
2236 {rlinm.|rlwinm.} %3,%1,0,%m2,%M2
2237 #
2238 #
2239 #
2240 #"
2241 [(set_attr "type" "compare,compare,compare,delayed_compare,compare,compare,compare,compare")
2242 (set_attr "length" "4,4,4,4,8,8,8,8")])
1fd4e8c1 2243
0ba1b2ff
AM
2244(define_insn "*andsi3_internal3"
2245 [(set (match_operand:CC 0 "cc_reg_operand" "=x,x,x,x,?y,??y,??y,?y")
2246 (compare:CC (and:SI (match_operand:SI 1 "gpc_reg_operand" "%r,r,r,r,r,r,r,r")
2247 (match_operand:SI 2 "and_operand" "r,K,L,T,r,K,L,T"))
2248 (const_int 0)))
2249 (clobber (match_scratch:SI 3 "=r,r,r,r,r,r,r,r"))
2250 (clobber (match_scratch:CC 4 "=X,X,X,X,X,x,x,X"))]
683bdff7 2251 "TARGET_64BIT"
0ba1b2ff
AM
2252 "@
2253 #
2254 {andil.|andi.} %3,%1,%b2
2255 {andiu.|andis.} %3,%1,%u2
2256 {rlinm.|rlwinm.} %3,%1,0,%m2,%M2
2257 #
2258 #
2259 #
2260 #"
2261 [(set_attr "type" "compare,compare,compare,delayed_compare,compare,compare,compare,compare")
2262 (set_attr "length" "8,4,4,4,8,8,8,8")])
2263
52d3af72
DE
2264(define_split
2265 [(set (match_operand:CC 0 "cc_reg_not_cr0_operand" "")
2266 (compare:CC (and:SI (match_operand:SI 1 "gpc_reg_operand" "")
2267 (match_operand:SI 2 "and_operand" ""))
1fd4e8c1 2268 (const_int 0)))
52d3af72
DE
2269 (clobber (match_scratch:SI 3 ""))
2270 (clobber (match_scratch:CC 4 ""))]
0ba1b2ff 2271 "reload_completed"
52d3af72
DE
2272 [(parallel [(set (match_dup 3)
2273 (and:SI (match_dup 1)
2274 (match_dup 2)))
2275 (clobber (match_dup 4))])
2276 (set (match_dup 0)
2277 (compare:CC (match_dup 3)
2278 (const_int 0)))]
2279 "")
2280
0ba1b2ff
AM
2281;; We don't have a 32 bit "and. rt,ra,rb" for ppc64. cr is set from the
2282;; whole 64 bit reg, and we don't know what is in the high 32 bits.
2283
2284(define_split
2285 [(set (match_operand:CC 0 "cc_reg_operand" "")
2286 (compare:CC (and:SI (match_operand:SI 1 "gpc_reg_operand" "")
2287 (match_operand:SI 2 "gpc_reg_operand" ""))
2288 (const_int 0)))
2289 (clobber (match_scratch:SI 3 ""))
2290 (clobber (match_scratch:CC 4 ""))]
2291 "TARGET_POWERPC64 && reload_completed"
2292 [(parallel [(set (match_dup 3)
2293 (and:SI (match_dup 1)
2294 (match_dup 2)))
2295 (clobber (match_dup 4))])
2296 (set (match_dup 0)
2297 (compare:CC (match_dup 3)
2298 (const_int 0)))]
2299 "")
2300
2301(define_insn "*andsi3_internal4"
52d3af72
DE
2302 [(set (match_operand:CC 3 "cc_reg_operand" "=x,x,x,x,?y,??y,??y,?y")
2303 (compare:CC (and:SI (match_operand:SI 1 "gpc_reg_operand" "%r,r,r,r,r,r,r,r")
5f59ecb7 2304 (match_operand:SI 2 "and_operand" "r,K,L,T,r,K,L,T"))
52d3af72
DE
2305 (const_int 0)))
2306 (set (match_operand:SI 0 "gpc_reg_operand" "=r,r,r,r,r,r,r,r")
2307 (and:SI (match_dup 1)
2308 (match_dup 2)))
2309 (clobber (match_scratch:CC 4 "=X,X,X,X,X,x,x,X"))]
4b8a63d6 2310 "TARGET_32BIT"
1fd4e8c1
RK
2311 "@
2312 and. %0,%1,%2
ca7f5001
RK
2313 {andil.|andi.} %0,%1,%b2
2314 {andiu.|andis.} %0,%1,%u2
52d3af72
DE
2315 {rlinm.|rlwinm.} %0,%1,0,%m2,%M2
2316 #
2317 #
2318 #
2319 #"
2320 [(set_attr "type" "compare,compare,compare,delayed_compare,compare,compare,compare,compare")
2321 (set_attr "length" "4,4,4,4,8,8,8,8")])
2322
0ba1b2ff
AM
2323(define_insn "*andsi3_internal5"
2324 [(set (match_operand:CC 3 "cc_reg_operand" "=x,x,x,x,?y,??y,??y,?y")
2325 (compare:CC (and:SI (match_operand:SI 1 "gpc_reg_operand" "%r,r,r,r,r,r,r,r")
2326 (match_operand:SI 2 "and_operand" "r,K,L,T,r,K,L,T"))
2327 (const_int 0)))
2328 (set (match_operand:SI 0 "gpc_reg_operand" "=r,r,r,r,r,r,r,r")
2329 (and:SI (match_dup 1)
2330 (match_dup 2)))
2331 (clobber (match_scratch:CC 4 "=X,X,X,X,X,x,x,X"))]
683bdff7 2332 "TARGET_64BIT"
0ba1b2ff
AM
2333 "@
2334 #
2335 {andil.|andi.} %0,%1,%b2
2336 {andiu.|andis.} %0,%1,%u2
2337 {rlinm.|rlwinm.} %0,%1,0,%m2,%M2
2338 #
2339 #
2340 #
2341 #"
2342 [(set_attr "type" "compare,compare,compare,delayed_compare,compare,compare,compare,compare")
2343 (set_attr "length" "8,4,4,4,8,8,8,8")])
2344
52d3af72
DE
2345(define_split
2346 [(set (match_operand:CC 3 "cc_reg_not_cr0_operand" "")
2347 (compare:CC (and:SI (match_operand:SI 1 "gpc_reg_operand" "")
2348 (match_operand:SI 2 "and_operand" ""))
2349 (const_int 0)))
2350 (set (match_operand:SI 0 "gpc_reg_operand" "")
2351 (and:SI (match_dup 1)
2352 (match_dup 2)))
2353 (clobber (match_scratch:CC 4 ""))]
0ba1b2ff 2354 "reload_completed"
52d3af72
DE
2355 [(parallel [(set (match_dup 0)
2356 (and:SI (match_dup 1)
2357 (match_dup 2)))
2358 (clobber (match_dup 4))])
2359 (set (match_dup 3)
2360 (compare:CC (match_dup 0)
2361 (const_int 0)))]
2362 "")
1fd4e8c1 2363
0ba1b2ff
AM
2364(define_split
2365 [(set (match_operand:CC 3 "cc_reg_operand" "")
2366 (compare:CC (and:SI (match_operand:SI 1 "gpc_reg_operand" "")
2367 (match_operand:SI 2 "gpc_reg_operand" ""))
2368 (const_int 0)))
2369 (set (match_operand:SI 0 "gpc_reg_operand" "")
2370 (and:SI (match_dup 1)
2371 (match_dup 2)))
2372 (clobber (match_scratch:CC 4 ""))]
2373 "TARGET_POWERPC64 && reload_completed"
2374 [(parallel [(set (match_dup 0)
2375 (and:SI (match_dup 1)
2376 (match_dup 2)))
2377 (clobber (match_dup 4))])
2378 (set (match_dup 3)
2379 (compare:CC (match_dup 0)
2380 (const_int 0)))]
2381 "")
2382
2383;; Handle the PowerPC64 rlwinm corner case
2384
2385(define_insn_and_split "*andsi3_internal6"
2386 [(set (match_operand:SI 0 "gpc_reg_operand" "=r")
2387 (and:SI (match_operand:SI 1 "gpc_reg_operand" "r")
2388 (match_operand:SI 2 "mask_operand_wrap" "i")))]
2389 "TARGET_POWERPC64"
2390 "#"
2391 "TARGET_POWERPC64"
2392 [(set (match_dup 0)
2393 (and:SI (rotate:SI (match_dup 1) (match_dup 3))
2394 (match_dup 4)))
2395 (set (match_dup 0)
2396 (rotate:SI (match_dup 0) (match_dup 5)))]
2397 "
2398{
2399 int mb = extract_MB (operands[2]);
2400 int me = extract_ME (operands[2]);
2401 operands[3] = GEN_INT (me + 1);
2402 operands[5] = GEN_INT (32 - (me + 1));
2403 operands[4] = GEN_INT (~((HOST_WIDE_INT) -1 << (33 + me - mb)));
2404}"
2405 [(set_attr "length" "8")])
2406
2407(define_insn_and_split "*andsi3_internal7"
2408 [(set (match_operand:CC 2 "cc_reg_operand" "=x,?y")
2409 (compare:CC (and:SI (match_operand:SI 0 "gpc_reg_operand" "r,r")
2410 (match_operand:SI 1 "mask_operand_wrap" "i,i"))
2411 (const_int 0)))
2412 (clobber (match_scratch:SI 3 "=r,r"))]
2413 "TARGET_POWERPC64"
2414 "#"
2415 "TARGET_POWERPC64"
2416 [(parallel [(set (match_dup 2)
2417 (compare:CC (and:SI (rotate:SI (match_dup 0) (match_dup 4))
2418 (match_dup 5))
2419 (const_int 0)))
2420 (clobber (match_dup 3))])]
2421 "
2422{
2423 int mb = extract_MB (operands[1]);
2424 int me = extract_ME (operands[1]);
2425 operands[4] = GEN_INT (me + 1);
2426 operands[5] = GEN_INT (~((HOST_WIDE_INT) -1 << (33 + me - mb)));
2427}"
2428 [(set_attr "type" "delayed_compare,compare")
2429 (set_attr "length" "4,8")])
2430
2431(define_insn_and_split "*andsi3_internal8"
2432 [(set (match_operand:CC 3 "cc_reg_operand" "=x,??y")
2433 (compare:CC (and:SI (match_operand:SI 1 "gpc_reg_operand" "r,r")
2434 (match_operand:SI 2 "mask_operand_wrap" "i,i"))
2435 (const_int 0)))
2436 (set (match_operand:SI 0 "gpc_reg_operand" "=r,r")
2437 (and:SI (match_dup 1)
2438 (match_dup 2)))]
2439 "TARGET_POWERPC64"
2440 "#"
2441 "TARGET_POWERPC64"
2442 [(parallel [(set (match_dup 3)
2443 (compare:CC (and:SI (rotate:SI (match_dup 1) (match_dup 4))
2444 (match_dup 5))
2445 (const_int 0)))
2446 (set (match_dup 0)
2447 (and:SI (rotate:SI (match_dup 1) (match_dup 4))
2448 (match_dup 5)))])
2449 (set (match_dup 0)
2450 (rotate:SI (match_dup 0) (match_dup 6)))]
2451 "
2452{
2453 int mb = extract_MB (operands[2]);
2454 int me = extract_ME (operands[2]);
2455 operands[4] = GEN_INT (me + 1);
2456 operands[6] = GEN_INT (32 - (me + 1));
2457 operands[5] = GEN_INT (~((HOST_WIDE_INT) -1 << (33 + me - mb)));
2458}"
2459 [(set_attr "type" "delayed_compare,compare")
2460 (set_attr "length" "8,12")])
2461
7cd5235b 2462(define_expand "iorsi3"
cd2b37d9 2463 [(set (match_operand:SI 0 "gpc_reg_operand" "")
7cd5235b 2464 (ior:SI (match_operand:SI 1 "gpc_reg_operand" "")
1d328b19 2465 (match_operand:SI 2 "reg_or_logical_cint_operand" "")))]
7cd5235b 2466 ""
f357808b
RK
2467 "
2468{
7cd5235b 2469 if (GET_CODE (operands[2]) == CONST_INT
677a9668 2470 && ! logical_operand (operands[2], SImode))
7cd5235b
MM
2471 {
2472 HOST_WIDE_INT value = INTVAL (operands[2]);
677a9668 2473 rtx tmp = ((no_new_pseudos || rtx_equal_p (operands[0], operands[1]))
7cd5235b
MM
2474 ? operands[0] : gen_reg_rtx (SImode));
2475
a260abc9
DE
2476 emit_insn (gen_iorsi3 (tmp, operands[1],
2477 GEN_INT (value & (~ (HOST_WIDE_INT) 0xffff))));
2478 emit_insn (gen_iorsi3 (operands[0], tmp, GEN_INT (value & 0xffff)));
7cd5235b
MM
2479 DONE;
2480 }
f357808b
RK
2481}")
2482
7cd5235b 2483(define_expand "xorsi3"
cd2b37d9 2484 [(set (match_operand:SI 0 "gpc_reg_operand" "")
7cd5235b 2485 (xor:SI (match_operand:SI 1 "gpc_reg_operand" "")
1d328b19 2486 (match_operand:SI 2 "reg_or_logical_cint_operand" "")))]
1fd4e8c1 2487 ""
7cd5235b 2488 "
1fd4e8c1 2489{
7cd5235b 2490 if (GET_CODE (operands[2]) == CONST_INT
677a9668 2491 && ! logical_operand (operands[2], SImode))
7cd5235b
MM
2492 {
2493 HOST_WIDE_INT value = INTVAL (operands[2]);
677a9668 2494 rtx tmp = ((no_new_pseudos || rtx_equal_p (operands[0], operands[1]))
7cd5235b
MM
2495 ? operands[0] : gen_reg_rtx (SImode));
2496
a260abc9
DE
2497 emit_insn (gen_xorsi3 (tmp, operands[1],
2498 GEN_INT (value & (~ (HOST_WIDE_INT) 0xffff))));
2499 emit_insn (gen_xorsi3 (operands[0], tmp, GEN_INT (value & 0xffff)));
7cd5235b
MM
2500 DONE;
2501 }
1fd4e8c1
RK
2502}")
2503
dfbdccdb 2504(define_insn "*boolsi3_internal1"
7cd5235b 2505 [(set (match_operand:SI 0 "gpc_reg_operand" "=r,r,r")
1d328b19 2506 (match_operator:SI 3 "boolean_or_operator"
dfbdccdb
GK
2507 [(match_operand:SI 1 "gpc_reg_operand" "%r,r,r")
2508 (match_operand:SI 2 "logical_operand" "r,K,L")]))]
1fd4e8c1
RK
2509 ""
2510 "@
dfbdccdb
GK
2511 %q3 %0,%1,%2
2512 {%q3il|%q3i} %0,%1,%b2
2513 {%q3iu|%q3is} %0,%1,%u2")
1fd4e8c1 2514
dfbdccdb 2515(define_insn "*boolsi3_internal2"
52d3af72 2516 [(set (match_operand:CC 0 "cc_reg_operand" "=x,?y")
1d328b19 2517 (compare:CC (match_operator:SI 4 "boolean_or_operator"
dfbdccdb
GK
2518 [(match_operand:SI 1 "gpc_reg_operand" "%r,r")
2519 (match_operand:SI 2 "gpc_reg_operand" "r,r")])
2520 (const_int 0)))
52d3af72 2521 (clobber (match_scratch:SI 3 "=r,r"))]
4b8a63d6 2522 "TARGET_32BIT"
52d3af72 2523 "@
dfbdccdb 2524 %q4. %3,%1,%2
52d3af72
DE
2525 #"
2526 [(set_attr "type" "compare")
2527 (set_attr "length" "4,8")])
2528
2529(define_split
2530 [(set (match_operand:CC 0 "cc_reg_not_cr0_operand" "")
dfbdccdb 2531 (compare:CC (match_operator:SI 4 "boolean_operator"
75540af0
JH
2532 [(match_operand:SI 1 "gpc_reg_operand" "")
2533 (match_operand:SI 2 "gpc_reg_operand" "")])
dfbdccdb 2534 (const_int 0)))
52d3af72 2535 (clobber (match_scratch:SI 3 ""))]
4b8a63d6 2536 "TARGET_32BIT && reload_completed"
dfbdccdb 2537 [(set (match_dup 3) (match_dup 4))
52d3af72
DE
2538 (set (match_dup 0)
2539 (compare:CC (match_dup 3)
2540 (const_int 0)))]
2541 "")
815cdc52 2542
dfbdccdb 2543(define_insn "*boolsi3_internal3"
52d3af72 2544 [(set (match_operand:CC 3 "cc_reg_operand" "=x,?y")
dfbdccdb
GK
2545 (compare:CC (match_operator:SI 4 "boolean_operator"
2546 [(match_operand:SI 1 "gpc_reg_operand" "%r,r")
2547 (match_operand:SI 2 "gpc_reg_operand" "r,r")])
2548 (const_int 0)))
52d3af72 2549 (set (match_operand:SI 0 "gpc_reg_operand" "=r,r")
dfbdccdb 2550 (match_dup 4))]
4b8a63d6 2551 "TARGET_32BIT"
52d3af72 2552 "@
dfbdccdb 2553 %q4. %0,%1,%2
52d3af72
DE
2554 #"
2555 [(set_attr "type" "compare")
2556 (set_attr "length" "4,8")])
2557
2558(define_split
e72247f4 2559 [(set (match_operand:CC 3 "cc_reg_not_cr0_operand" "")
dfbdccdb 2560 (compare:CC (match_operator:SI 4 "boolean_operator"
75540af0
JH
2561 [(match_operand:SI 1 "gpc_reg_operand" "")
2562 (match_operand:SI 2 "gpc_reg_operand" "")])
dfbdccdb 2563 (const_int 0)))
75540af0 2564 (set (match_operand:SI 0 "gpc_reg_operand" "")
dfbdccdb 2565 (match_dup 4))]
4b8a63d6 2566 "TARGET_32BIT && reload_completed"
dfbdccdb 2567 [(set (match_dup 0) (match_dup 4))
52d3af72
DE
2568 (set (match_dup 3)
2569 (compare:CC (match_dup 0)
2570 (const_int 0)))]
2571 "")
1fd4e8c1 2572
6ae08853 2573;; Split a logical operation that we can't do in one insn into two insns,
dfbdccdb 2574;; each of which does one 16-bit part. This is used by combine.
a260abc9
DE
2575
2576(define_split
2577 [(set (match_operand:SI 0 "gpc_reg_operand" "")
1d328b19 2578 (match_operator:SI 3 "boolean_or_operator"
dfbdccdb
GK
2579 [(match_operand:SI 1 "gpc_reg_operand" "")
2580 (match_operand:SI 2 "non_logical_cint_operand" "")]))]
a260abc9 2581 ""
dfbdccdb
GK
2582 [(set (match_dup 0) (match_dup 4))
2583 (set (match_dup 0) (match_dup 5))]
a260abc9
DE
2584"
2585{
dfbdccdb
GK
2586 rtx i;
2587 i = GEN_INT (INTVAL (operands[2]) & (~ (HOST_WIDE_INT) 0xffff));
1c563bed 2588 operands[4] = gen_rtx_fmt_ee (GET_CODE (operands[3]), SImode,
0f4c242b 2589 operands[1], i);
dfbdccdb 2590 i = GEN_INT (INTVAL (operands[2]) & 0xffff);
1c563bed 2591 operands[5] = gen_rtx_fmt_ee (GET_CODE (operands[3]), SImode,
0f4c242b 2592 operands[0], i);
a260abc9
DE
2593}")
2594
dfbdccdb 2595(define_insn "*boolcsi3_internal1"
cd2b37d9 2596 [(set (match_operand:SI 0 "gpc_reg_operand" "=r")
dfbdccdb
GK
2597 (match_operator:SI 3 "boolean_operator"
2598 [(not:SI (match_operand:SI 1 "gpc_reg_operand" "r"))
40501e5f 2599 (match_operand:SI 2 "gpc_reg_operand" "r")]))]
1fd4e8c1 2600 ""
dfbdccdb 2601 "%q3 %0,%2,%1")
1fd4e8c1 2602
dfbdccdb 2603(define_insn "*boolcsi3_internal2"
52d3af72 2604 [(set (match_operand:CC 0 "cc_reg_operand" "=x,?y")
dfbdccdb
GK
2605 (compare:CC (match_operator:SI 4 "boolean_operator"
2606 [(not:SI (match_operand:SI 1 "gpc_reg_operand" "r,r"))
2607 (match_operand:SI 2 "gpc_reg_operand" "r,r")])
2608 (const_int 0)))
52d3af72 2609 (clobber (match_scratch:SI 3 "=r,r"))]
4b8a63d6 2610 "TARGET_32BIT"
52d3af72 2611 "@
dfbdccdb 2612 %q4. %3,%2,%1
52d3af72
DE
2613 #"
2614 [(set_attr "type" "compare")
2615 (set_attr "length" "4,8")])
2616
2617(define_split
2618 [(set (match_operand:CC 0 "cc_reg_not_cr0_operand" "")
dfbdccdb 2619 (compare:CC (match_operator:SI 4 "boolean_operator"
75540af0
JH
2620 [(not:SI (match_operand:SI 1 "gpc_reg_operand" ""))
2621 (match_operand:SI 2 "gpc_reg_operand" "")])
dfbdccdb 2622 (const_int 0)))
52d3af72 2623 (clobber (match_scratch:SI 3 ""))]
4b8a63d6 2624 "TARGET_32BIT && reload_completed"
dfbdccdb 2625 [(set (match_dup 3) (match_dup 4))
52d3af72
DE
2626 (set (match_dup 0)
2627 (compare:CC (match_dup 3)
2628 (const_int 0)))]
2629 "")
1fd4e8c1 2630
dfbdccdb 2631(define_insn "*boolcsi3_internal3"
52d3af72 2632 [(set (match_operand:CC 3 "cc_reg_operand" "=x,?y")
dfbdccdb
GK
2633 (compare:CC (match_operator:SI 4 "boolean_operator"
2634 [(not:SI (match_operand:SI 1 "gpc_reg_operand" "%r,r"))
2635 (match_operand:SI 2 "gpc_reg_operand" "r,r")])
2636 (const_int 0)))
52d3af72 2637 (set (match_operand:SI 0 "gpc_reg_operand" "=r,r")
dfbdccdb 2638 (match_dup 4))]
4b8a63d6 2639 "TARGET_32BIT"
52d3af72 2640 "@
dfbdccdb 2641 %q4. %0,%2,%1
52d3af72
DE
2642 #"
2643 [(set_attr "type" "compare")
2644 (set_attr "length" "4,8")])
2645
2646(define_split
e72247f4 2647 [(set (match_operand:CC 3 "cc_reg_not_cr0_operand" "")
dfbdccdb 2648 (compare:CC (match_operator:SI 4 "boolean_operator"
75540af0
JH
2649 [(not:SI (match_operand:SI 1 "gpc_reg_operand" ""))
2650 (match_operand:SI 2 "gpc_reg_operand" "")])
dfbdccdb 2651 (const_int 0)))
75540af0 2652 (set (match_operand:SI 0 "gpc_reg_operand" "")
dfbdccdb 2653 (match_dup 4))]
4b8a63d6 2654 "TARGET_32BIT && reload_completed"
dfbdccdb 2655 [(set (match_dup 0) (match_dup 4))
52d3af72
DE
2656 (set (match_dup 3)
2657 (compare:CC (match_dup 0)
2658 (const_int 0)))]
2659 "")
2660
dfbdccdb 2661(define_insn "*boolccsi3_internal1"
cd2b37d9 2662 [(set (match_operand:SI 0 "gpc_reg_operand" "=r")
dfbdccdb
GK
2663 (match_operator:SI 3 "boolean_operator"
2664 [(not:SI (match_operand:SI 1 "gpc_reg_operand" "r"))
40501e5f 2665 (not:SI (match_operand:SI 2 "gpc_reg_operand" "r"))]))]
1fd4e8c1 2666 ""
dfbdccdb 2667 "%q3 %0,%1,%2")
1fd4e8c1 2668
dfbdccdb 2669(define_insn "*boolccsi3_internal2"
52d3af72 2670 [(set (match_operand:CC 0 "cc_reg_operand" "=x,?y")
dfbdccdb
GK
2671 (compare:CC (match_operator:SI 4 "boolean_operator"
2672 [(not:SI (match_operand:SI 1 "gpc_reg_operand" "r,r"))
2673 (not:SI (match_operand:SI 2 "gpc_reg_operand" "r,r"))])
2674 (const_int 0)))
52d3af72 2675 (clobber (match_scratch:SI 3 "=r,r"))]
4b8a63d6 2676 "TARGET_32BIT"
52d3af72 2677 "@
dfbdccdb 2678 %q4. %3,%1,%2
52d3af72
DE
2679 #"
2680 [(set_attr "type" "compare")
2681 (set_attr "length" "4,8")])
2682
2683(define_split
2684 [(set (match_operand:CC 0 "cc_reg_not_cr0_operand" "")
dfbdccdb 2685 (compare:CC (match_operator:SI 4 "boolean_operator"
75540af0
JH
2686 [(not:SI (match_operand:SI 1 "gpc_reg_operand" ""))
2687 (not:SI (match_operand:SI 2 "gpc_reg_operand" ""))])
dfbdccdb 2688 (const_int 0)))
52d3af72 2689 (clobber (match_scratch:SI 3 ""))]
4b8a63d6 2690 "TARGET_32BIT && reload_completed"
dfbdccdb 2691 [(set (match_dup 3) (match_dup 4))
52d3af72
DE
2692 (set (match_dup 0)
2693 (compare:CC (match_dup 3)
2694 (const_int 0)))]
2695 "")
1fd4e8c1 2696
dfbdccdb 2697(define_insn "*boolccsi3_internal3"
52d3af72 2698 [(set (match_operand:CC 3 "cc_reg_operand" "=x,?y")
dfbdccdb
GK
2699 (compare:CC (match_operator:SI 4 "boolean_operator"
2700 [(not:SI (match_operand:SI 1 "gpc_reg_operand" "%r,r"))
2701 (not:SI (match_operand:SI 2 "gpc_reg_operand" "r,r"))])
2702 (const_int 0)))
52d3af72 2703 (set (match_operand:SI 0 "gpc_reg_operand" "=r,r")
dfbdccdb 2704 (match_dup 4))]
4b8a63d6 2705 "TARGET_32BIT"
52d3af72 2706 "@
dfbdccdb 2707 %q4. %0,%1,%2
52d3af72
DE
2708 #"
2709 [(set_attr "type" "compare")
2710 (set_attr "length" "4,8")])
2711
2712(define_split
e72247f4 2713 [(set (match_operand:CC 3 "cc_reg_not_cr0_operand" "")
dfbdccdb 2714 (compare:CC (match_operator:SI 4 "boolean_operator"
75540af0
JH
2715 [(not:SI (match_operand:SI 1 "gpc_reg_operand" ""))
2716 (not:SI (match_operand:SI 2 "gpc_reg_operand" ""))])
dfbdccdb 2717 (const_int 0)))
75540af0 2718 (set (match_operand:SI 0 "gpc_reg_operand" "")
dfbdccdb 2719 (match_dup 4))]
4b8a63d6 2720 "TARGET_32BIT && reload_completed"
dfbdccdb 2721 [(set (match_dup 0) (match_dup 4))
52d3af72
DE
2722 (set (match_dup 3)
2723 (compare:CC (match_dup 0)
2724 (const_int 0)))]
2725 "")
1fd4e8c1
RK
2726
2727;; maskir insn. We need four forms because things might be in arbitrary
2728;; orders. Don't define forms that only set CR fields because these
2729;; would modify an input register.
2730
7cd5235b 2731(define_insn "*maskir_internal1"
cd2b37d9 2732 [(set (match_operand:SI 0 "gpc_reg_operand" "=r")
01def764
RK
2733 (ior:SI (and:SI (not:SI (match_operand:SI 2 "gpc_reg_operand" "r"))
2734 (match_operand:SI 1 "gpc_reg_operand" "0"))
2735 (and:SI (match_dup 2)
cd2b37d9 2736 (match_operand:SI 3 "gpc_reg_operand" "r"))))]
ca7f5001 2737 "TARGET_POWER"
01def764 2738 "maskir %0,%3,%2")
1fd4e8c1 2739
7cd5235b 2740(define_insn "*maskir_internal2"
242e8072 2741 [(set (match_operand:SI 0 "gpc_reg_operand" "=r")
01def764
RK
2742 (ior:SI (and:SI (not:SI (match_operand:SI 2 "gpc_reg_operand" "r"))
2743 (match_operand:SI 1 "gpc_reg_operand" "0"))
cd2b37d9 2744 (and:SI (match_operand:SI 3 "gpc_reg_operand" "r")
01def764 2745 (match_dup 2))))]
ca7f5001 2746 "TARGET_POWER"
01def764 2747 "maskir %0,%3,%2")
1fd4e8c1 2748
7cd5235b 2749(define_insn "*maskir_internal3"
cd2b37d9 2750 [(set (match_operand:SI 0 "gpc_reg_operand" "=r")
01def764 2751 (ior:SI (and:SI (match_operand:SI 2 "gpc_reg_operand" "r")
cd2b37d9 2752 (match_operand:SI 3 "gpc_reg_operand" "r"))
01def764
RK
2753 (and:SI (not:SI (match_dup 2))
2754 (match_operand:SI 1 "gpc_reg_operand" "0"))))]
ca7f5001 2755 "TARGET_POWER"
01def764 2756 "maskir %0,%3,%2")
1fd4e8c1 2757
7cd5235b 2758(define_insn "*maskir_internal4"
cd2b37d9
RK
2759 [(set (match_operand:SI 0 "gpc_reg_operand" "=r")
2760 (ior:SI (and:SI (match_operand:SI 3 "gpc_reg_operand" "r")
01def764
RK
2761 (match_operand:SI 2 "gpc_reg_operand" "r"))
2762 (and:SI (not:SI (match_dup 2))
2763 (match_operand:SI 1 "gpc_reg_operand" "0"))))]
ca7f5001 2764 "TARGET_POWER"
01def764 2765 "maskir %0,%3,%2")
1fd4e8c1 2766
7cd5235b 2767(define_insn "*maskir_internal5"
9ebbca7d 2768 [(set (match_operand:CC 4 "cc_reg_operand" "=x,?y")
1fd4e8c1 2769 (compare:CC
9ebbca7d
GK
2770 (ior:SI (and:SI (not:SI (match_operand:SI 2 "gpc_reg_operand" "r,r"))
2771 (match_operand:SI 1 "gpc_reg_operand" "0,0"))
01def764 2772 (and:SI (match_dup 2)
9ebbca7d 2773 (match_operand:SI 3 "gpc_reg_operand" "r,r")))
1fd4e8c1 2774 (const_int 0)))
9ebbca7d 2775 (set (match_operand:SI 0 "gpc_reg_operand" "=r,r")
01def764
RK
2776 (ior:SI (and:SI (not:SI (match_dup 2)) (match_dup 1))
2777 (and:SI (match_dup 2) (match_dup 3))))]
ca7f5001 2778 "TARGET_POWER"
9ebbca7d
GK
2779 "@
2780 maskir. %0,%3,%2
2781 #"
2782 [(set_attr "type" "compare")
2783 (set_attr "length" "4,8")])
2784
2785(define_split
2786 [(set (match_operand:CC 4 "cc_reg_not_cr0_operand" "")
2787 (compare:CC
2788 (ior:SI (and:SI (not:SI (match_operand:SI 2 "gpc_reg_operand" ""))
2789 (match_operand:SI 1 "gpc_reg_operand" ""))
2790 (and:SI (match_dup 2)
2791 (match_operand:SI 3 "gpc_reg_operand" "")))
2792 (const_int 0)))
2793 (set (match_operand:SI 0 "gpc_reg_operand" "")
2794 (ior:SI (and:SI (not:SI (match_dup 2)) (match_dup 1))
2795 (and:SI (match_dup 2) (match_dup 3))))]
2796 "TARGET_POWER && reload_completed"
2797 [(set (match_dup 0)
2798 (ior:SI (and:SI (not:SI (match_dup 2)) (match_dup 1))
2799 (and:SI (match_dup 2) (match_dup 3))))
2800 (set (match_dup 4)
2801 (compare:CC (match_dup 0)
2802 (const_int 0)))]
2803 "")
1fd4e8c1 2804
7cd5235b 2805(define_insn "*maskir_internal6"
9ebbca7d 2806 [(set (match_operand:CC 4 "cc_reg_operand" "=x,?y")
1fd4e8c1 2807 (compare:CC
9ebbca7d
GK
2808 (ior:SI (and:SI (not:SI (match_operand:SI 2 "gpc_reg_operand" "r,r"))
2809 (match_operand:SI 1 "gpc_reg_operand" "0,0"))
2810 (and:SI (match_operand:SI 3 "gpc_reg_operand" "r,r")
01def764 2811 (match_dup 2)))
1fd4e8c1 2812 (const_int 0)))
9ebbca7d 2813 (set (match_operand:SI 0 "gpc_reg_operand" "=r,r")
01def764
RK
2814 (ior:SI (and:SI (not:SI (match_dup 2)) (match_dup 1))
2815 (and:SI (match_dup 3) (match_dup 2))))]
ca7f5001 2816 "TARGET_POWER"
9ebbca7d
GK
2817 "@
2818 maskir. %0,%3,%2
2819 #"
2820 [(set_attr "type" "compare")
2821 (set_attr "length" "4,8")])
2822
2823(define_split
2824 [(set (match_operand:CC 4 "cc_reg_not_cr0_operand" "")
2825 (compare:CC
2826 (ior:SI (and:SI (not:SI (match_operand:SI 2 "gpc_reg_operand" ""))
2827 (match_operand:SI 1 "gpc_reg_operand" ""))
2828 (and:SI (match_operand:SI 3 "gpc_reg_operand" "")
2829 (match_dup 2)))
2830 (const_int 0)))
2831 (set (match_operand:SI 0 "gpc_reg_operand" "")
2832 (ior:SI (and:SI (not:SI (match_dup 2)) (match_dup 1))
2833 (and:SI (match_dup 3) (match_dup 2))))]
2834 "TARGET_POWER && reload_completed"
2835 [(set (match_dup 0)
2836 (ior:SI (and:SI (not:SI (match_dup 2)) (match_dup 1))
2837 (and:SI (match_dup 3) (match_dup 2))))
2838 (set (match_dup 4)
2839 (compare:CC (match_dup 0)
2840 (const_int 0)))]
2841 "")
1fd4e8c1 2842
7cd5235b 2843(define_insn "*maskir_internal7"
9ebbca7d 2844 [(set (match_operand:CC 4 "cc_reg_operand" "=x,?y")
815cdc52 2845 (compare:CC
9ebbca7d
GK
2846 (ior:SI (and:SI (match_operand:SI 2 "gpc_reg_operand" "r,r")
2847 (match_operand:SI 3 "gpc_reg_operand" "r,r"))
815cdc52 2848 (and:SI (not:SI (match_dup 2))
9ebbca7d 2849 (match_operand:SI 1 "gpc_reg_operand" "0,0")))
815cdc52 2850 (const_int 0)))
9ebbca7d 2851 (set (match_operand:SI 0 "gpc_reg_operand" "=r,r")
815cdc52
MM
2852 (ior:SI (and:SI (match_dup 2) (match_dup 3))
2853 (and:SI (not:SI (match_dup 2)) (match_dup 1))))]
2854 "TARGET_POWER"
9ebbca7d
GK
2855 "@
2856 maskir. %0,%3,%2
2857 #"
2858 [(set_attr "type" "compare")
2859 (set_attr "length" "4,8")])
2860
2861(define_split
2862 [(set (match_operand:CC 4 "cc_reg_not_cr0_operand" "")
2863 (compare:CC
2864 (ior:SI (and:SI (match_operand:SI 2 "gpc_reg_operand" "")
2865 (match_operand:SI 3 "gpc_reg_operand" ""))
2866 (and:SI (not:SI (match_dup 2))
2867 (match_operand:SI 1 "gpc_reg_operand" "")))
2868 (const_int 0)))
2869 (set (match_operand:SI 0 "gpc_reg_operand" "")
2870 (ior:SI (and:SI (match_dup 2) (match_dup 3))
2871 (and:SI (not:SI (match_dup 2)) (match_dup 1))))]
2872 "TARGET_POWER && reload_completed"
2873 [(set (match_dup 0)
2874 (ior:SI (and:SI (match_dup 2) (match_dup 3))
2875 (and:SI (not:SI (match_dup 2)) (match_dup 1))))
2876 (set (match_dup 4)
2877 (compare:CC (match_dup 0)
2878 (const_int 0)))]
2879 "")
1fd4e8c1 2880
7cd5235b 2881(define_insn "*maskir_internal8"
9ebbca7d 2882 [(set (match_operand:CC 4 "cc_reg_operand" "=x,?y")
1fd4e8c1 2883 (compare:CC
9ebbca7d
GK
2884 (ior:SI (and:SI (match_operand:SI 3 "gpc_reg_operand" "r,r")
2885 (match_operand:SI 2 "gpc_reg_operand" "r,r"))
01def764 2886 (and:SI (not:SI (match_dup 2))
9ebbca7d 2887 (match_operand:SI 1 "gpc_reg_operand" "0,0")))
1fd4e8c1 2888 (const_int 0)))
9ebbca7d 2889 (set (match_operand:SI 0 "gpc_reg_operand" "=r,r")
01def764
RK
2890 (ior:SI (and:SI (match_dup 3) (match_dup 2))
2891 (and:SI (not:SI (match_dup 2)) (match_dup 1))))]
ca7f5001 2892 "TARGET_POWER"
9ebbca7d
GK
2893 "@
2894 maskir. %0,%3,%2
2895 #"
2896 [(set_attr "type" "compare")
2897 (set_attr "length" "4,8")])
fcce224d 2898
9ebbca7d
GK
2899(define_split
2900 [(set (match_operand:CC 4 "cc_reg_not_cr0_operand" "")
2901 (compare:CC
2902 (ior:SI (and:SI (match_operand:SI 3 "gpc_reg_operand" "")
2903 (match_operand:SI 2 "gpc_reg_operand" ""))
2904 (and:SI (not:SI (match_dup 2))
2905 (match_operand:SI 1 "gpc_reg_operand" "")))
2906 (const_int 0)))
2907 (set (match_operand:SI 0 "gpc_reg_operand" "")
2908 (ior:SI (and:SI (match_dup 3) (match_dup 2))
2909 (and:SI (not:SI (match_dup 2)) (match_dup 1))))]
2910 "TARGET_POWER && reload_completed"
2911 [(set (match_dup 0)
2912 (ior:SI (and:SI (match_dup 3) (match_dup 2))
2913 (and:SI (not:SI (match_dup 2)) (match_dup 1))))
2914 (set (match_dup 4)
2915 (compare:CC (match_dup 0)
2916 (const_int 0)))]
2917 "")
fcce224d 2918\f
1fd4e8c1
RK
2919;; Rotate and shift insns, in all their variants. These support shifts,
2920;; field inserts and extracts, and various combinations thereof.
034c1be0 2921(define_expand "insv"
0ad91047
DE
2922 [(set (zero_extract (match_operand 0 "gpc_reg_operand" "")
2923 (match_operand:SI 1 "const_int_operand" "")
2924 (match_operand:SI 2 "const_int_operand" ""))
2925 (match_operand 3 "gpc_reg_operand" ""))]
034c1be0
MM
2926 ""
2927 "
2928{
2929 /* Do not handle 16/8 bit structures that fit in HI/QI modes directly, since
2930 the (SUBREG:SI (REG:HI xxx)) that is otherwise generated can confuse the
2931 compiler if the address of the structure is taken later. */
2932 if (GET_CODE (operands[0]) == SUBREG
2933 && (GET_MODE_SIZE (GET_MODE (SUBREG_REG (operands[0]))) < UNITS_PER_WORD))
2934 FAIL;
a78e33fc
DE
2935
2936 if (TARGET_POWERPC64 && GET_MODE (operands[0]) == DImode)
2937 emit_insn (gen_insvdi (operands[0], operands[1], operands[2], operands[3]));
2938 else
2939 emit_insn (gen_insvsi (operands[0], operands[1], operands[2], operands[3]));
2940 DONE;
034c1be0
MM
2941}")
2942
a78e33fc 2943(define_insn "insvsi"
cd2b37d9 2944 [(set (zero_extract:SI (match_operand:SI 0 "gpc_reg_operand" "+r")
1fd4e8c1
RK
2945 (match_operand:SI 1 "const_int_operand" "i")
2946 (match_operand:SI 2 "const_int_operand" "i"))
cd2b37d9 2947 (match_operand:SI 3 "gpc_reg_operand" "r"))]
1fd4e8c1
RK
2948 ""
2949 "*
2950{
2951 int start = INTVAL (operands[2]) & 31;
2952 int size = INTVAL (operands[1]) & 31;
2953
89e9f3a8
MM
2954 operands[4] = GEN_INT (32 - start - size);
2955 operands[1] = GEN_INT (start + size - 1);
a66078ee 2956 return \"{rlimi|rlwimi} %0,%3,%h4,%h2,%h1\";
8e8238f1
DE
2957}"
2958 [(set_attr "type" "insert_word")])
1fd4e8c1 2959
a78e33fc 2960(define_insn "*insvsi_internal1"
d56d506a
RK
2961 [(set (zero_extract:SI (match_operand:SI 0 "gpc_reg_operand" "+r")
2962 (match_operand:SI 1 "const_int_operand" "i")
2963 (match_operand:SI 2 "const_int_operand" "i"))
2964 (ashift:SI (match_operand:SI 3 "gpc_reg_operand" "r")
2965 (match_operand:SI 4 "const_int_operand" "i")))]
f0dc3f49 2966 "(32 - (INTVAL (operands[4]) & 31)) >= INTVAL (operands[1])"
d56d506a
RK
2967 "*
2968{
2969 int shift = INTVAL (operands[4]) & 31;
2970 int start = INTVAL (operands[2]) & 31;
2971 int size = INTVAL (operands[1]) & 31;
2972
89e9f3a8
MM
2973 operands[4] = GEN_INT (shift - start - size);
2974 operands[1] = GEN_INT (start + size - 1);
a66078ee 2975 return \"{rlimi|rlwimi} %0,%3,%h4,%h2,%h1\";
8e8238f1
DE
2976}"
2977 [(set_attr "type" "insert_word")])
d56d506a 2978
a78e33fc 2979(define_insn "*insvsi_internal2"
d56d506a
RK
2980 [(set (zero_extract:SI (match_operand:SI 0 "gpc_reg_operand" "+r")
2981 (match_operand:SI 1 "const_int_operand" "i")
2982 (match_operand:SI 2 "const_int_operand" "i"))
2983 (ashiftrt:SI (match_operand:SI 3 "gpc_reg_operand" "r")
2984 (match_operand:SI 4 "const_int_operand" "i")))]
f0dc3f49 2985 "(32 - (INTVAL (operands[4]) & 31)) >= INTVAL (operands[1])"
d56d506a
RK
2986 "*
2987{
2988 int shift = INTVAL (operands[4]) & 31;
2989 int start = INTVAL (operands[2]) & 31;
2990 int size = INTVAL (operands[1]) & 31;
2991
89e9f3a8
MM
2992 operands[4] = GEN_INT (32 - shift - start - size);
2993 operands[1] = GEN_INT (start + size - 1);
a66078ee 2994 return \"{rlimi|rlwimi} %0,%3,%h4,%h2,%h1\";
8e8238f1
DE
2995}"
2996 [(set_attr "type" "insert_word")])
d56d506a 2997
a78e33fc 2998(define_insn "*insvsi_internal3"
d56d506a
RK
2999 [(set (zero_extract:SI (match_operand:SI 0 "gpc_reg_operand" "+r")
3000 (match_operand:SI 1 "const_int_operand" "i")
3001 (match_operand:SI 2 "const_int_operand" "i"))
3002 (lshiftrt:SI (match_operand:SI 3 "gpc_reg_operand" "r")
3003 (match_operand:SI 4 "const_int_operand" "i")))]
95e8f2f3 3004 "(32 - (INTVAL (operands[4]) & 31)) >= INTVAL (operands[1])"
d56d506a
RK
3005 "*
3006{
3007 int shift = INTVAL (operands[4]) & 31;
3008 int start = INTVAL (operands[2]) & 31;
3009 int size = INTVAL (operands[1]) & 31;
3010
89e9f3a8
MM
3011 operands[4] = GEN_INT (32 - shift - start - size);
3012 operands[1] = GEN_INT (start + size - 1);
a66078ee 3013 return \"{rlimi|rlwimi} %0,%3,%h4,%h2,%h1\";
8e8238f1
DE
3014}"
3015 [(set_attr "type" "insert_word")])
d56d506a 3016
a78e33fc 3017(define_insn "*insvsi_internal4"
d56d506a
RK
3018 [(set (zero_extract:SI (match_operand:SI 0 "gpc_reg_operand" "+r")
3019 (match_operand:SI 1 "const_int_operand" "i")
3020 (match_operand:SI 2 "const_int_operand" "i"))
3021 (zero_extract:SI (match_operand:SI 3 "gpc_reg_operand" "r")
3022 (match_operand:SI 4 "const_int_operand" "i")
3023 (match_operand:SI 5 "const_int_operand" "i")))]
3024 "INTVAL (operands[4]) >= INTVAL (operands[1])"
3025 "*
3026{
3027 int extract_start = INTVAL (operands[5]) & 31;
3028 int extract_size = INTVAL (operands[4]) & 31;
3029 int insert_start = INTVAL (operands[2]) & 31;
3030 int insert_size = INTVAL (operands[1]) & 31;
3031
3032/* Align extract field with insert field */
3a598fbe 3033 operands[5] = GEN_INT (extract_start + extract_size - insert_start - insert_size);
89e9f3a8 3034 operands[1] = GEN_INT (insert_start + insert_size - 1);
a66078ee 3035 return \"{rlimi|rlwimi} %0,%3,%h5,%h2,%h1\";
8e8238f1
DE
3036}"
3037 [(set_attr "type" "insert_word")])
d56d506a 3038
f241bf89
EC
3039;; combine patterns for rlwimi
3040(define_insn "*insvsi_internal5"
3041 [(set (match_operand:SI 0 "gpc_reg_operand" "=r")
3042 (ior:SI (and:SI (match_operand:SI 4 "gpc_reg_operand" "0")
3043 (match_operand:SI 1 "mask_operand" "i"))
3044 (and:SI (lshiftrt:SI (match_operand:SI 3 "gpc_reg_operand" "r")
3045 (match_operand:SI 2 "const_int_operand" "i"))
3046 (match_operand:SI 5 "mask_operand" "i"))))]
3047 "TARGET_POWERPC && INTVAL(operands[1]) == ~INTVAL(operands[5])"
3048 "*
3049{
3050 int me = extract_ME(operands[5]);
3051 int mb = extract_MB(operands[5]);
3052 operands[4] = GEN_INT(32 - INTVAL(operands[2]));
3053 operands[2] = GEN_INT(mb);
3054 operands[1] = GEN_INT(me);
3055 return \"{rlimi|rlwimi} %0,%3,%h4,%h2,%h1\";
3056}"
3057 [(set_attr "type" "insert_word")])
3058
3059(define_insn "*insvsi_internal6"
3060 [(set (match_operand:SI 0 "gpc_reg_operand" "=r")
3061 (ior:SI (and:SI (lshiftrt:SI (match_operand:SI 3 "gpc_reg_operand" "r")
3062 (match_operand:SI 2 "const_int_operand" "i"))
3063 (match_operand:SI 5 "mask_operand" "i"))
3064 (and:SI (match_operand:SI 4 "gpc_reg_operand" "0")
3065 (match_operand:SI 1 "mask_operand" "i"))))]
3066 "TARGET_POWERPC && INTVAL(operands[1]) == ~INTVAL(operands[5])"
3067 "*
3068{
3069 int me = extract_ME(operands[5]);
3070 int mb = extract_MB(operands[5]);
3071 operands[4] = GEN_INT(32 - INTVAL(operands[2]));
3072 operands[2] = GEN_INT(mb);
3073 operands[1] = GEN_INT(me);
3074 return \"{rlimi|rlwimi} %0,%3,%h4,%h2,%h1\";
3075}"
3076 [(set_attr "type" "insert_word")])
3077
a78e33fc 3078(define_insn "insvdi"
685f3906 3079 [(set (zero_extract:DI (match_operand:DI 0 "gpc_reg_operand" "+r")
a78e33fc
DE
3080 (match_operand:SI 1 "const_int_operand" "i")
3081 (match_operand:SI 2 "const_int_operand" "i"))
685f3906
DE
3082 (match_operand:DI 3 "gpc_reg_operand" "r"))]
3083 "TARGET_POWERPC64"
3084 "*
3085{
3086 int start = INTVAL (operands[2]) & 63;
3087 int size = INTVAL (operands[1]) & 63;
3088
a78e33fc
DE
3089 operands[1] = GEN_INT (64 - start - size);
3090 return \"rldimi %0,%3,%H1,%H2\";
685f3906
DE
3091}")
3092
11ac38b2
DE
3093(define_insn "*insvdi_internal2"
3094 [(set (zero_extract:DI (match_operand:DI 0 "gpc_reg_operand" "+r")
3095 (match_operand:SI 1 "const_int_operand" "i")
3096 (match_operand:SI 2 "const_int_operand" "i"))
3097 (ashiftrt:DI (match_operand:DI 3 "gpc_reg_operand" "r")
3098 (match_operand:SI 4 "const_int_operand" "i")))]
3099 "TARGET_POWERPC64
3100 && insvdi_rshift_rlwimi_p (operands[1], operands[2], operands[4])"
3101 "*
3102{
3103 int shift = INTVAL (operands[4]) & 63;
3104 int start = (INTVAL (operands[2]) & 63) - 32;
3105 int size = INTVAL (operands[1]) & 63;
3106
3107 operands[4] = GEN_INT (64 - shift - start - size);
3108 operands[2] = GEN_INT (start);
3109 operands[1] = GEN_INT (start + size - 1);
3110 return \"rlwimi %0,%3,%h4,%h2,%h1\";
3111}")
3112
3113(define_insn "*insvdi_internal3"
3114 [(set (zero_extract:DI (match_operand:DI 0 "gpc_reg_operand" "+r")
3115 (match_operand:SI 1 "const_int_operand" "i")
3116 (match_operand:SI 2 "const_int_operand" "i"))
3117 (lshiftrt:DI (match_operand:DI 3 "gpc_reg_operand" "r")
3118 (match_operand:SI 4 "const_int_operand" "i")))]
3119 "TARGET_POWERPC64
3120 && insvdi_rshift_rlwimi_p (operands[1], operands[2], operands[4])"
3121 "*
3122{
3123 int shift = INTVAL (operands[4]) & 63;
3124 int start = (INTVAL (operands[2]) & 63) - 32;
3125 int size = INTVAL (operands[1]) & 63;
3126
3127 operands[4] = GEN_INT (64 - shift - start - size);
3128 operands[2] = GEN_INT (start);
3129 operands[1] = GEN_INT (start + size - 1);
3130 return \"rlwimi %0,%3,%h4,%h2,%h1\";
3131}")
3132
034c1be0 3133(define_expand "extzv"
0ad91047
DE
3134 [(set (match_operand 0 "gpc_reg_operand" "")
3135 (zero_extract (match_operand 1 "gpc_reg_operand" "")
3136 (match_operand:SI 2 "const_int_operand" "")
3137 (match_operand:SI 3 "const_int_operand" "")))]
034c1be0
MM
3138 ""
3139 "
3140{
3141 /* Do not handle 16/8 bit structures that fit in HI/QI modes directly, since
3142 the (SUBREG:SI (REG:HI xxx)) that is otherwise generated can confuse the
3143 compiler if the address of the structure is taken later. */
3144 if (GET_CODE (operands[0]) == SUBREG
3145 && (GET_MODE_SIZE (GET_MODE (SUBREG_REG (operands[0]))) < UNITS_PER_WORD))
3146 FAIL;
a78e33fc
DE
3147
3148 if (TARGET_POWERPC64 && GET_MODE (operands[1]) == DImode)
3149 emit_insn (gen_extzvdi (operands[0], operands[1], operands[2], operands[3]));
3150 else
3151 emit_insn (gen_extzvsi (operands[0], operands[1], operands[2], operands[3]));
3152 DONE;
034c1be0
MM
3153}")
3154
a78e33fc 3155(define_insn "extzvsi"
cd2b37d9
RK
3156 [(set (match_operand:SI 0 "gpc_reg_operand" "=r")
3157 (zero_extract:SI (match_operand:SI 1 "gpc_reg_operand" "r")
1fd4e8c1
RK
3158 (match_operand:SI 2 "const_int_operand" "i")
3159 (match_operand:SI 3 "const_int_operand" "i")))]
3160 ""
3161 "*
3162{
3163 int start = INTVAL (operands[3]) & 31;
3164 int size = INTVAL (operands[2]) & 31;
3165
3166 if (start + size >= 32)
3167 operands[3] = const0_rtx;
3168 else
89e9f3a8 3169 operands[3] = GEN_INT (start + size);
ca7f5001 3170 return \"{rlinm|rlwinm} %0,%1,%3,%s2,31\";
1fd4e8c1
RK
3171}")
3172
a78e33fc 3173(define_insn "*extzvsi_internal1"
9ebbca7d
GK
3174 [(set (match_operand:CC 0 "cc_reg_operand" "=x,?y")
3175 (compare:CC (zero_extract:SI (match_operand:SI 1 "gpc_reg_operand" "r,r")
3176 (match_operand:SI 2 "const_int_operand" "i,i")
3177 (match_operand:SI 3 "const_int_operand" "i,i"))
1fd4e8c1 3178 (const_int 0)))
9ebbca7d 3179 (clobber (match_scratch:SI 4 "=r,r"))]
ce71f754 3180 ""
1fd4e8c1
RK
3181 "*
3182{
3183 int start = INTVAL (operands[3]) & 31;
3184 int size = INTVAL (operands[2]) & 31;
3185
9ebbca7d
GK
3186 /* Force split for non-cc0 compare. */
3187 if (which_alternative == 1)
3188 return \"#\";
3189
43a88a8c 3190 /* If the bit-field being tested fits in the upper or lower half of a
a7a975e1
RK
3191 word, it is possible to use andiu. or andil. to test it. This is
3192 useful because the condition register set-use delay is smaller for
3193 andi[ul]. than for rlinm. This doesn't work when the starting bit
3194 position is 0 because the LT and GT bits may be set wrong. */
3195
3196 if ((start > 0 && start + size <= 16) || start >= 16)
df031c43 3197 {
3a598fbe 3198 operands[3] = GEN_INT (((1 << (16 - (start & 15)))
df031c43
RK
3199 - (1 << (16 - (start & 15) - size))));
3200 if (start < 16)
ca7f5001 3201 return \"{andiu.|andis.} %4,%1,%3\";
df031c43 3202 else
ca7f5001 3203 return \"{andil.|andi.} %4,%1,%3\";
df031c43 3204 }
7e69e155 3205
1fd4e8c1
RK
3206 if (start + size >= 32)
3207 operands[3] = const0_rtx;
3208 else
89e9f3a8 3209 operands[3] = GEN_INT (start + size);
ca7f5001 3210 return \"{rlinm.|rlwinm.} %4,%1,%3,%s2,31\";
1fd4e8c1 3211}"
9ebbca7d
GK
3212 [(set_attr "type" "compare")
3213 (set_attr "length" "4,8")])
3214
3215(define_split
3216 [(set (match_operand:CC 0 "cc_reg_not_cr0_operand" "")
3217 (compare:CC (zero_extract:SI (match_operand:SI 1 "gpc_reg_operand" "")
3218 (match_operand:SI 2 "const_int_operand" "")
3219 (match_operand:SI 3 "const_int_operand" ""))
3220 (const_int 0)))
3221 (clobber (match_scratch:SI 4 ""))]
ce71f754 3222 "reload_completed"
9ebbca7d
GK
3223 [(set (match_dup 4)
3224 (zero_extract:SI (match_dup 1) (match_dup 2)
3225 (match_dup 3)))
3226 (set (match_dup 0)
3227 (compare:CC (match_dup 4)
3228 (const_int 0)))]
3229 "")
1fd4e8c1 3230
a78e33fc 3231(define_insn "*extzvsi_internal2"
9ebbca7d
GK
3232 [(set (match_operand:CC 4 "cc_reg_operand" "=x,?y")
3233 (compare:CC (zero_extract:SI (match_operand:SI 1 "gpc_reg_operand" "r,r")
3234 (match_operand:SI 2 "const_int_operand" "i,i")
3235 (match_operand:SI 3 "const_int_operand" "i,i"))
1fd4e8c1 3236 (const_int 0)))
9ebbca7d 3237 (set (match_operand:SI 0 "gpc_reg_operand" "=r,r")
1fd4e8c1 3238 (zero_extract:SI (match_dup 1) (match_dup 2) (match_dup 3)))]
ce71f754 3239 ""
1fd4e8c1
RK
3240 "*
3241{
3242 int start = INTVAL (operands[3]) & 31;
3243 int size = INTVAL (operands[2]) & 31;
3244
9ebbca7d
GK
3245 /* Force split for non-cc0 compare. */
3246 if (which_alternative == 1)
3247 return \"#\";
3248
bc401279 3249 /* Since we are using the output value, we can't ignore any need for
43a88a8c 3250 a shift. The bit-field must end at the LSB. */
bc401279 3251 if (start >= 16 && start + size == 32)
df031c43 3252 {
bc401279
AM
3253 operands[3] = GEN_INT ((1 << size) - 1);
3254 return \"{andil.|andi.} %0,%1,%3\";
df031c43 3255 }
7e69e155 3256
1fd4e8c1
RK
3257 if (start + size >= 32)
3258 operands[3] = const0_rtx;
3259 else
89e9f3a8 3260 operands[3] = GEN_INT (start + size);
ca7f5001 3261 return \"{rlinm.|rlwinm.} %0,%1,%3,%s2,31\";
1fd4e8c1 3262}"
ce71f754 3263 [(set_attr "type" "compare")
9ebbca7d
GK
3264 (set_attr "length" "4,8")])
3265
3266(define_split
3267 [(set (match_operand:CC 4 "cc_reg_not_cr0_operand" "")
3268 (compare:CC (zero_extract:SI (match_operand:SI 1 "gpc_reg_operand" "")
3269 (match_operand:SI 2 "const_int_operand" "")
3270 (match_operand:SI 3 "const_int_operand" ""))
3271 (const_int 0)))
3272 (set (match_operand:SI 0 "gpc_reg_operand" "")
3273 (zero_extract:SI (match_dup 1) (match_dup 2) (match_dup 3)))]
ce71f754 3274 "reload_completed"
9ebbca7d
GK
3275 [(set (match_dup 0)
3276 (zero_extract:SI (match_dup 1) (match_dup 2) (match_dup 3)))
3277 (set (match_dup 4)
3278 (compare:CC (match_dup 0)
3279 (const_int 0)))]
3280 "")
1fd4e8c1 3281
a78e33fc 3282(define_insn "extzvdi"
685f3906
DE
3283 [(set (match_operand:DI 0 "gpc_reg_operand" "=r")
3284 (zero_extract:DI (match_operand:DI 1 "gpc_reg_operand" "r")
a78e33fc
DE
3285 (match_operand:SI 2 "const_int_operand" "i")
3286 (match_operand:SI 3 "const_int_operand" "i")))]
685f3906
DE
3287 "TARGET_POWERPC64"
3288 "*
3289{
3290 int start = INTVAL (operands[3]) & 63;
3291 int size = INTVAL (operands[2]) & 63;
3292
3293 if (start + size >= 64)
3294 operands[3] = const0_rtx;
3295 else
89e9f3a8
MM
3296 operands[3] = GEN_INT (start + size);
3297 operands[2] = GEN_INT (64 - size);
685f3906
DE
3298 return \"rldicl %0,%1,%3,%2\";
3299}")
3300
a78e33fc 3301(define_insn "*extzvdi_internal1"
29ae5b89
JL
3302 [(set (match_operand:CC 0 "gpc_reg_operand" "=x")
3303 (compare:CC (zero_extract:DI (match_operand:DI 1 "gpc_reg_operand" "r")
a78e33fc
DE
3304 (match_operand:SI 2 "const_int_operand" "i")
3305 (match_operand:SI 3 "const_int_operand" "i"))
685f3906 3306 (const_int 0)))
29ae5b89 3307 (clobber (match_scratch:DI 4 "=r"))]
683bdff7 3308 "TARGET_64BIT"
685f3906
DE
3309 "*
3310{
3311 int start = INTVAL (operands[3]) & 63;
3312 int size = INTVAL (operands[2]) & 63;
3313
3314 if (start + size >= 64)
3315 operands[3] = const0_rtx;
3316 else
89e9f3a8
MM
3317 operands[3] = GEN_INT (start + size);
3318 operands[2] = GEN_INT (64 - size);
685f3906
DE
3319 return \"rldicl. %4,%1,%3,%2\";
3320}")
3321
a78e33fc 3322(define_insn "*extzvdi_internal2"
29ae5b89
JL
3323 [(set (match_operand:CC 4 "gpc_reg_operand" "=x")
3324 (compare:CC (zero_extract:DI (match_operand:DI 1 "gpc_reg_operand" "r")
a78e33fc
DE
3325 (match_operand:SI 2 "const_int_operand" "i")
3326 (match_operand:SI 3 "const_int_operand" "i"))
685f3906 3327 (const_int 0)))
29ae5b89 3328 (set (match_operand:DI 0 "gpc_reg_operand" "=r")
685f3906 3329 (zero_extract:DI (match_dup 1) (match_dup 2) (match_dup 3)))]
683bdff7 3330 "TARGET_64BIT"
685f3906
DE
3331 "*
3332{
3333 int start = INTVAL (operands[3]) & 63;
3334 int size = INTVAL (operands[2]) & 63;
3335
3336 if (start + size >= 64)
3337 operands[3] = const0_rtx;
3338 else
89e9f3a8
MM
3339 operands[3] = GEN_INT (start + size);
3340 operands[2] = GEN_INT (64 - size);
685f3906
DE
3341 return \"rldicl. %0,%1,%3,%2\";
3342}")
3343
1fd4e8c1 3344(define_insn "rotlsi3"
cd2b37d9
RK
3345 [(set (match_operand:SI 0 "gpc_reg_operand" "=r")
3346 (rotate:SI (match_operand:SI 1 "gpc_reg_operand" "r")
1fd4e8c1
RK
3347 (match_operand:SI 2 "reg_or_cint_operand" "ri")))]
3348 ""
ca7f5001 3349 "{rl%I2nm|rlw%I2nm} %0,%1,%h2,0xffffffff")
1fd4e8c1 3350
a260abc9 3351(define_insn "*rotlsi3_internal2"
9ebbca7d
GK
3352 [(set (match_operand:CC 0 "cc_reg_operand" "=x,?y")
3353 (compare:CC (rotate:SI (match_operand:SI 1 "gpc_reg_operand" "r,r")
3354 (match_operand:SI 2 "reg_or_cint_operand" "ri,ri"))
1fd4e8c1 3355 (const_int 0)))
9ebbca7d 3356 (clobber (match_scratch:SI 3 "=r,r"))]
ce71f754 3357 ""
9ebbca7d
GK
3358 "@
3359 {rl%I2nm.|rlw%I2nm.} %3,%1,%h2,0xffffffff
3360 #"
3361 [(set_attr "type" "delayed_compare")
3362 (set_attr "length" "4,8")])
3363
3364(define_split
3365 [(set (match_operand:CC 0 "cc_reg_not_cr0_operand" "")
3366 (compare:CC (rotate:SI (match_operand:SI 1 "gpc_reg_operand" "")
3367 (match_operand:SI 2 "reg_or_cint_operand" ""))
3368 (const_int 0)))
3369 (clobber (match_scratch:SI 3 ""))]
ce71f754 3370 "reload_completed"
9ebbca7d
GK
3371 [(set (match_dup 3)
3372 (rotate:SI (match_dup 1) (match_dup 2)))
3373 (set (match_dup 0)
3374 (compare:CC (match_dup 3)
3375 (const_int 0)))]
3376 "")
1fd4e8c1 3377
a260abc9 3378(define_insn "*rotlsi3_internal3"
9ebbca7d
GK
3379 [(set (match_operand:CC 3 "cc_reg_operand" "=x,?y")
3380 (compare:CC (rotate:SI (match_operand:SI 1 "gpc_reg_operand" "r,r")
3381 (match_operand:SI 2 "reg_or_cint_operand" "ri,ri"))
1fd4e8c1 3382 (const_int 0)))
9ebbca7d 3383 (set (match_operand:SI 0 "gpc_reg_operand" "=r,r")
1fd4e8c1 3384 (rotate:SI (match_dup 1) (match_dup 2)))]
ce71f754 3385 ""
9ebbca7d
GK
3386 "@
3387 {rl%I2nm.|rlw%I2nm.} %0,%1,%h2,0xffffffff
3388 #"
3389 [(set_attr "type" "delayed_compare")
3390 (set_attr "length" "4,8")])
3391
3392(define_split
3393 [(set (match_operand:CC 3 "cc_reg_not_cr0_operand" "")
3394 (compare:CC (rotate:SI (match_operand:SI 1 "gpc_reg_operand" "")
3395 (match_operand:SI 2 "reg_or_cint_operand" ""))
3396 (const_int 0)))
3397 (set (match_operand:SI 0 "gpc_reg_operand" "")
3398 (rotate:SI (match_dup 1) (match_dup 2)))]
ce71f754 3399 "reload_completed"
9ebbca7d
GK
3400 [(set (match_dup 0)
3401 (rotate:SI (match_dup 1) (match_dup 2)))
3402 (set (match_dup 3)
3403 (compare:CC (match_dup 0)
3404 (const_int 0)))]
3405 "")
1fd4e8c1 3406
a260abc9 3407(define_insn "*rotlsi3_internal4"
cd2b37d9
RK
3408 [(set (match_operand:SI 0 "gpc_reg_operand" "=r")
3409 (and:SI (rotate:SI (match_operand:SI 1 "gpc_reg_operand" "r")
1fd4e8c1 3410 (match_operand:SI 2 "reg_or_cint_operand" "ri"))
ce71f754 3411 (match_operand:SI 3 "mask_operand" "n")))]
1fd4e8c1 3412 ""
ca7f5001 3413 "{rl%I2nm|rlw%I2nm} %0,%1,%h2,%m3,%M3")
1fd4e8c1 3414
a260abc9 3415(define_insn "*rotlsi3_internal5"
9ebbca7d 3416 [(set (match_operand:CC 0 "cc_reg_operand" "=x,?y")
1fd4e8c1 3417 (compare:CC (and:SI
9ebbca7d
GK
3418 (rotate:SI (match_operand:SI 1 "gpc_reg_operand" "r,r")
3419 (match_operand:SI 2 "reg_or_cint_operand" "ri,ri"))
ce71f754 3420 (match_operand:SI 3 "mask_operand" "n,n"))
1fd4e8c1 3421 (const_int 0)))
9ebbca7d 3422 (clobber (match_scratch:SI 4 "=r,r"))]
ce71f754 3423 ""
9ebbca7d
GK
3424 "@
3425 {rl%I2nm.|rlw%I2nm.} %4,%1,%h2,%m3,%M3
3426 #"
3427 [(set_attr "type" "delayed_compare")
3428 (set_attr "length" "4,8")])
3429
3430(define_split
3431 [(set (match_operand:CC 0 "cc_reg_not_cr0_operand" "")
3432 (compare:CC (and:SI
3433 (rotate:SI (match_operand:SI 1 "gpc_reg_operand" "")
3434 (match_operand:SI 2 "reg_or_cint_operand" ""))
3435 (match_operand:SI 3 "mask_operand" ""))
3436 (const_int 0)))
3437 (clobber (match_scratch:SI 4 ""))]
ce71f754 3438 "reload_completed"
9ebbca7d
GK
3439 [(set (match_dup 4)
3440 (and:SI (rotate:SI (match_dup 1)
3441 (match_dup 2))
3442 (match_dup 3)))
3443 (set (match_dup 0)
3444 (compare:CC (match_dup 4)
3445 (const_int 0)))]
3446 "")
1fd4e8c1 3447
a260abc9 3448(define_insn "*rotlsi3_internal6"
9ebbca7d 3449 [(set (match_operand:CC 4 "cc_reg_operand" "=x,?y")
1fd4e8c1 3450 (compare:CC (and:SI
9ebbca7d
GK
3451 (rotate:SI (match_operand:SI 1 "gpc_reg_operand" "r,r")
3452 (match_operand:SI 2 "reg_or_cint_operand" "ri,ri"))
ce71f754 3453 (match_operand:SI 3 "mask_operand" "n,n"))
1fd4e8c1 3454 (const_int 0)))
9ebbca7d 3455 (set (match_operand:SI 0 "gpc_reg_operand" "=r,r")
1fd4e8c1 3456 (and:SI (rotate:SI (match_dup 1) (match_dup 2)) (match_dup 3)))]
ce71f754 3457 ""
9ebbca7d
GK
3458 "@
3459 {rl%I2nm.|rlw%I2nm.} %0,%1,%h2,%m3,%M3
3460 #"
3461 [(set_attr "type" "delayed_compare")
3462 (set_attr "length" "4,8")])
3463
3464(define_split
3465 [(set (match_operand:CC 4 "cc_reg_not_cr0_operand" "")
3466 (compare:CC (and:SI
3467 (rotate:SI (match_operand:SI 1 "gpc_reg_operand" "")
3468 (match_operand:SI 2 "reg_or_cint_operand" ""))
3469 (match_operand:SI 3 "mask_operand" ""))
3470 (const_int 0)))
3471 (set (match_operand:SI 0 "gpc_reg_operand" "")
3472 (and:SI (rotate:SI (match_dup 1) (match_dup 2)) (match_dup 3)))]
ce71f754 3473 "reload_completed"
9ebbca7d
GK
3474 [(set (match_dup 0)
3475 (and:SI (rotate:SI (match_dup 1) (match_dup 2)) (match_dup 3)))
3476 (set (match_dup 4)
3477 (compare:CC (match_dup 0)
3478 (const_int 0)))]
3479 "")
1fd4e8c1 3480
a260abc9 3481(define_insn "*rotlsi3_internal7"
cd2b37d9 3482 [(set (match_operand:SI 0 "gpc_reg_operand" "=r")
1fd4e8c1
RK
3483 (zero_extend:SI
3484 (subreg:QI
cd2b37d9 3485 (rotate:SI (match_operand:SI 1 "gpc_reg_operand" "r")
1fd4e8c1
RK
3486 (match_operand:SI 2 "reg_or_cint_operand" "ri")) 0)))]
3487 ""
ca7f5001 3488 "{rl%I2nm|rlw%I2nm} %0,%1,%h2,0xff")
1fd4e8c1 3489
a260abc9 3490(define_insn "*rotlsi3_internal8"
9ebbca7d 3491 [(set (match_operand:CC 0 "cc_reg_operand" "=x,?y")
1fd4e8c1
RK
3492 (compare:CC (zero_extend:SI
3493 (subreg:QI
9ebbca7d
GK
3494 (rotate:SI (match_operand:SI 1 "gpc_reg_operand" "r,r")
3495 (match_operand:SI 2 "reg_or_cint_operand" "ri,ri")) 0))
1fd4e8c1 3496 (const_int 0)))
9ebbca7d 3497 (clobber (match_scratch:SI 3 "=r,r"))]
1fd4e8c1 3498 ""
9ebbca7d
GK
3499 "@
3500 {rl%I2nm.|rlw%I2nm.} %3,%1,%h2,0xff
3501 #"
3502 [(set_attr "type" "delayed_compare")
3503 (set_attr "length" "4,8")])
3504
3505(define_split
3506 [(set (match_operand:CC 0 "cc_reg_not_cr0_operand" "")
3507 (compare:CC (zero_extend:SI
3508 (subreg:QI
3509 (rotate:SI (match_operand:SI 1 "gpc_reg_operand" "")
3510 (match_operand:SI 2 "reg_or_cint_operand" "")) 0))
3511 (const_int 0)))
3512 (clobber (match_scratch:SI 3 ""))]
3513 "reload_completed"
3514 [(set (match_dup 3)
3515 (zero_extend:SI (subreg:QI
3516 (rotate:SI (match_dup 1)
3517 (match_dup 2)) 0)))
3518 (set (match_dup 0)
3519 (compare:CC (match_dup 3)
3520 (const_int 0)))]
3521 "")
1fd4e8c1 3522
a260abc9 3523(define_insn "*rotlsi3_internal9"
9ebbca7d 3524 [(set (match_operand:CC 3 "cc_reg_operand" "=x,?y")
1fd4e8c1
RK
3525 (compare:CC (zero_extend:SI
3526 (subreg:QI
9ebbca7d
GK
3527 (rotate:SI (match_operand:SI 1 "gpc_reg_operand" "r,r")
3528 (match_operand:SI 2 "reg_or_cint_operand" "ri,ri")) 0))
1fd4e8c1 3529 (const_int 0)))
9ebbca7d 3530 (set (match_operand:SI 0 "gpc_reg_operand" "=r,r")
1fd4e8c1
RK
3531 (zero_extend:SI (subreg:QI (rotate:SI (match_dup 1) (match_dup 2)) 0)))]
3532 ""
9ebbca7d
GK
3533 "@
3534 {rl%I2nm.|rlw%I2nm.} %0,%1,%h2,0xff
3535 #"
3536 [(set_attr "type" "delayed_compare")
3537 (set_attr "length" "4,8")])
3538
3539(define_split
3540 [(set (match_operand:CC 3 "cc_reg_not_cr0_operand" "")
3541 (compare:CC (zero_extend:SI
3542 (subreg:QI
3543 (rotate:SI (match_operand:SI 1 "gpc_reg_operand" "")
3544 (match_operand:SI 2 "reg_or_cint_operand" "")) 0))
3545 (const_int 0)))
3546 (set (match_operand:SI 0 "gpc_reg_operand" "")
3547 (zero_extend:SI (subreg:QI (rotate:SI (match_dup 1) (match_dup 2)) 0)))]
3548 "reload_completed"
3549 [(set (match_dup 0)
3550 (zero_extend:SI (subreg:QI (rotate:SI (match_dup 1) (match_dup 2)) 0)))
3551 (set (match_dup 3)
3552 (compare:CC (match_dup 0)
3553 (const_int 0)))]
3554 "")
1fd4e8c1 3555
a260abc9 3556(define_insn "*rotlsi3_internal10"
cd2b37d9 3557 [(set (match_operand:SI 0 "gpc_reg_operand" "=r")
1fd4e8c1
RK
3558 (zero_extend:SI
3559 (subreg:HI
cd2b37d9 3560 (rotate:SI (match_operand:SI 1 "gpc_reg_operand" "r")
1fd4e8c1
RK
3561 (match_operand:SI 2 "reg_or_cint_operand" "ri")) 0)))]
3562 ""
ca7f5001 3563 "{rl%I2nm|rlw%I2nm} %0,%1,%h2,0xffff")
1fd4e8c1 3564
a260abc9 3565(define_insn "*rotlsi3_internal11"
9ebbca7d 3566 [(set (match_operand:CC 0 "cc_reg_operand" "=x,?y")
1fd4e8c1
RK
3567 (compare:CC (zero_extend:SI
3568 (subreg:HI
9ebbca7d
GK
3569 (rotate:SI (match_operand:SI 1 "gpc_reg_operand" "r,r")
3570 (match_operand:SI 2 "reg_or_cint_operand" "ri,ri")) 0))
1fd4e8c1 3571 (const_int 0)))
9ebbca7d 3572 (clobber (match_scratch:SI 3 "=r,r"))]
1fd4e8c1 3573 ""
9ebbca7d
GK
3574 "@
3575 {rl%I2nm.|rlw%I2nm.} %3,%1,%h2,0xffff
3576 #"
3577 [(set_attr "type" "delayed_compare")
3578 (set_attr "length" "4,8")])
3579
3580(define_split
3581 [(set (match_operand:CC 0 "cc_reg_not_cr0_operand" "")
3582 (compare:CC (zero_extend:SI
3583 (subreg:HI
3584 (rotate:SI (match_operand:SI 1 "gpc_reg_operand" "")
3585 (match_operand:SI 2 "reg_or_cint_operand" "")) 0))
3586 (const_int 0)))
3587 (clobber (match_scratch:SI 3 ""))]
3588 "reload_completed"
3589 [(set (match_dup 3)
3590 (zero_extend:SI (subreg:HI
3591 (rotate:SI (match_dup 1)
3592 (match_dup 2)) 0)))
3593 (set (match_dup 0)
3594 (compare:CC (match_dup 3)
3595 (const_int 0)))]
3596 "")
1fd4e8c1 3597
a260abc9 3598(define_insn "*rotlsi3_internal12"
9ebbca7d 3599 [(set (match_operand:CC 3 "cc_reg_operand" "=x,?y")
1fd4e8c1
RK
3600 (compare:CC (zero_extend:SI
3601 (subreg:HI
9ebbca7d
GK
3602 (rotate:SI (match_operand:SI 1 "gpc_reg_operand" "r,r")
3603 (match_operand:SI 2 "reg_or_cint_operand" "ri,ri")) 0))
1fd4e8c1 3604 (const_int 0)))
9ebbca7d 3605 (set (match_operand:SI 0 "gpc_reg_operand" "=r,r")
1fd4e8c1
RK
3606 (zero_extend:SI (subreg:HI (rotate:SI (match_dup 1) (match_dup 2)) 0)))]
3607 ""
9ebbca7d
GK
3608 "@
3609 {rl%I2nm.|rlw%I2nm.} %0,%1,%h2,0xffff
3610 #"
3611 [(set_attr "type" "delayed_compare")
3612 (set_attr "length" "4,8")])
3613
3614(define_split
3615 [(set (match_operand:CC 3 "cc_reg_not_cr0_operand" "")
3616 (compare:CC (zero_extend:SI
3617 (subreg:HI
3618 (rotate:SI (match_operand:SI 1 "gpc_reg_operand" "")
3619 (match_operand:SI 2 "reg_or_cint_operand" "")) 0))
3620 (const_int 0)))
3621 (set (match_operand:SI 0 "gpc_reg_operand" "")
3622 (zero_extend:SI (subreg:HI (rotate:SI (match_dup 1) (match_dup 2)) 0)))]
3623 "reload_completed"
3624 [(set (match_dup 0)
3625 (zero_extend:SI (subreg:HI (rotate:SI (match_dup 1) (match_dup 2)) 0)))
3626 (set (match_dup 3)
3627 (compare:CC (match_dup 0)
3628 (const_int 0)))]
3629 "")
1fd4e8c1
RK
3630
3631;; Note that we use "sle." instead of "sl." so that we can set
3632;; SHIFT_COUNT_TRUNCATED.
3633
ca7f5001
RK
3634(define_expand "ashlsi3"
3635 [(use (match_operand:SI 0 "gpc_reg_operand" ""))
3636 (use (match_operand:SI 1 "gpc_reg_operand" ""))
3637 (use (match_operand:SI 2 "reg_or_cint_operand" ""))]
3638 ""
3639 "
3640{
3641 if (TARGET_POWER)
3642 emit_insn (gen_ashlsi3_power (operands[0], operands[1], operands[2]));
3643 else
25c341fa 3644 emit_insn (gen_ashlsi3_no_power (operands[0], operands[1], operands[2]));
ca7f5001
RK
3645 DONE;
3646}")
3647
3648(define_insn "ashlsi3_power"
cd2b37d9
RK
3649 [(set (match_operand:SI 0 "gpc_reg_operand" "=r,r")
3650 (ashift:SI (match_operand:SI 1 "gpc_reg_operand" "r,r")
1fd4e8c1
RK
3651 (match_operand:SI 2 "reg_or_cint_operand" "r,i")))
3652 (clobber (match_scratch:SI 3 "=q,X"))]
ca7f5001 3653 "TARGET_POWER"
1fd4e8c1
RK
3654 "@
3655 sle %0,%1,%2
9ebbca7d 3656 {sli|slwi} %0,%1,%h2")
ca7f5001 3657
25c341fa 3658(define_insn "ashlsi3_no_power"
ca7f5001
RK
3659 [(set (match_operand:SI 0 "gpc_reg_operand" "=r")
3660 (ashift:SI (match_operand:SI 1 "gpc_reg_operand" "r")
3661 (match_operand:SI 2 "reg_or_cint_operand" "ri")))]
25c341fa 3662 "! TARGET_POWER"
9ebbca7d 3663 "{sl|slw}%I2 %0,%1,%h2")
1fd4e8c1
RK
3664
3665(define_insn ""
9ebbca7d
GK
3666 [(set (match_operand:CC 0 "cc_reg_operand" "=x,x,?y,?y")
3667 (compare:CC (ashift:SI (match_operand:SI 1 "gpc_reg_operand" "r,r,r,r")
3668 (match_operand:SI 2 "reg_or_cint_operand" "r,i,r,i"))
1fd4e8c1 3669 (const_int 0)))
9ebbca7d
GK
3670 (clobber (match_scratch:SI 3 "=r,r,r,r"))
3671 (clobber (match_scratch:SI 4 "=q,X,q,X"))]
ca7f5001 3672 "TARGET_POWER"
1fd4e8c1
RK
3673 "@
3674 sle. %3,%1,%2
9ebbca7d
GK
3675 {sli.|slwi.} %3,%1,%h2
3676 #
3677 #"
3678 [(set_attr "type" "delayed_compare")
3679 (set_attr "length" "4,4,8,8")])
3680
3681(define_split
3682 [(set (match_operand:CC 0 "cc_reg_not_cr0_operand" "")
3683 (compare:CC (ashift:SI (match_operand:SI 1 "gpc_reg_operand" "")
3684 (match_operand:SI 2 "reg_or_cint_operand" ""))
3685 (const_int 0)))
3686 (clobber (match_scratch:SI 3 ""))
3687 (clobber (match_scratch:SI 4 ""))]
3688 "TARGET_POWER && reload_completed"
3689 [(parallel [(set (match_dup 3)
3690 (ashift:SI (match_dup 1) (match_dup 2)))
3691 (clobber (match_dup 4))])
3692 (set (match_dup 0)
3693 (compare:CC (match_dup 3)
3694 (const_int 0)))]
3695 "")
25c341fa 3696
ca7f5001 3697(define_insn ""
9ebbca7d
GK
3698 [(set (match_operand:CC 0 "cc_reg_operand" "=x,?y")
3699 (compare:CC (ashift:SI (match_operand:SI 1 "gpc_reg_operand" "r,r")
3700 (match_operand:SI 2 "reg_or_cint_operand" "ri,ri"))
ca7f5001 3701 (const_int 0)))
9ebbca7d 3702 (clobber (match_scratch:SI 3 "=r,r"))]
4b8a63d6 3703 "! TARGET_POWER && TARGET_32BIT"
9ebbca7d
GK
3704 "@
3705 {sl|slw}%I2. %3,%1,%h2
3706 #"
3707 [(set_attr "type" "delayed_compare")
3708 (set_attr "length" "4,8")])
3709
3710(define_split
3711 [(set (match_operand:CC 0 "cc_reg_not_cr0_operand" "")
3712 (compare:CC (ashift:SI (match_operand:SI 1 "gpc_reg_operand" "")
3713 (match_operand:SI 2 "reg_or_cint_operand" ""))
3714 (const_int 0)))
3715 (clobber (match_scratch:SI 3 ""))]
4b8a63d6 3716 "! TARGET_POWER && TARGET_32BIT && reload_completed"
9ebbca7d
GK
3717 [(set (match_dup 3)
3718 (ashift:SI (match_dup 1) (match_dup 2)))
3719 (set (match_dup 0)
3720 (compare:CC (match_dup 3)
3721 (const_int 0)))]
3722 "")
1fd4e8c1
RK
3723
3724(define_insn ""
9ebbca7d
GK
3725 [(set (match_operand:CC 3 "cc_reg_operand" "=x,x,?y,?y")
3726 (compare:CC (ashift:SI (match_operand:SI 1 "gpc_reg_operand" "r,r,r,r")
3727 (match_operand:SI 2 "reg_or_cint_operand" "r,i,r,i"))
1fd4e8c1 3728 (const_int 0)))
9ebbca7d 3729 (set (match_operand:SI 0 "gpc_reg_operand" "=r,r,r,r")
1fd4e8c1 3730 (ashift:SI (match_dup 1) (match_dup 2)))
9ebbca7d 3731 (clobber (match_scratch:SI 4 "=q,X,q,X"))]
ca7f5001 3732 "TARGET_POWER"
1fd4e8c1
RK
3733 "@
3734 sle. %0,%1,%2
9ebbca7d
GK
3735 {sli.|slwi.} %0,%1,%h2
3736 #
3737 #"
3738 [(set_attr "type" "delayed_compare")
3739 (set_attr "length" "4,4,8,8")])
3740
3741(define_split
3742 [(set (match_operand:CC 3 "cc_reg_not_cr0_operand" "")
3743 (compare:CC (ashift:SI (match_operand:SI 1 "gpc_reg_operand" "")
3744 (match_operand:SI 2 "reg_or_cint_operand" ""))
3745 (const_int 0)))
3746 (set (match_operand:SI 0 "gpc_reg_operand" "")
3747 (ashift:SI (match_dup 1) (match_dup 2)))
3748 (clobber (match_scratch:SI 4 ""))]
3749 "TARGET_POWER && reload_completed"
3750 [(parallel [(set (match_dup 0)
3751 (ashift:SI (match_dup 1) (match_dup 2)))
3752 (clobber (match_dup 4))])
3753 (set (match_dup 3)
3754 (compare:CC (match_dup 0)
3755 (const_int 0)))]
3756 "")
25c341fa 3757
ca7f5001 3758(define_insn ""
9ebbca7d
GK
3759 [(set (match_operand:CC 3 "cc_reg_operand" "=x,?y")
3760 (compare:CC (ashift:SI (match_operand:SI 1 "gpc_reg_operand" "r,r")
3761 (match_operand:SI 2 "reg_or_cint_operand" "ri,ri"))
ca7f5001 3762 (const_int 0)))
9ebbca7d 3763 (set (match_operand:SI 0 "gpc_reg_operand" "=r,r")
ca7f5001 3764 (ashift:SI (match_dup 1) (match_dup 2)))]
4b8a63d6 3765 "! TARGET_POWER && TARGET_32BIT"
9ebbca7d
GK
3766 "@
3767 {sl|slw}%I2. %0,%1,%h2
3768 #"
3769 [(set_attr "type" "delayed_compare")
3770 (set_attr "length" "4,8")])
3771
3772(define_split
3773 [(set (match_operand:CC 3 "cc_reg_not_cr0_operand" "")
3774 (compare:CC (ashift:SI (match_operand:SI 1 "gpc_reg_operand" "")
3775 (match_operand:SI 2 "reg_or_cint_operand" ""))
3776 (const_int 0)))
3777 (set (match_operand:SI 0 "gpc_reg_operand" "")
3778 (ashift:SI (match_dup 1) (match_dup 2)))]
4b8a63d6 3779 "! TARGET_POWER && TARGET_32BIT && reload_completed"
9ebbca7d
GK
3780 [(set (match_dup 0)
3781 (ashift:SI (match_dup 1) (match_dup 2)))
3782 (set (match_dup 3)
3783 (compare:CC (match_dup 0)
3784 (const_int 0)))]
3785 "")
1fd4e8c1
RK
3786
3787(define_insn ""
cd2b37d9
RK
3788 [(set (match_operand:SI 0 "gpc_reg_operand" "=r")
3789 (and:SI (ashift:SI (match_operand:SI 1 "gpc_reg_operand" "r")
1fd4e8c1 3790 (match_operand:SI 2 "const_int_operand" "i"))
ce71f754 3791 (match_operand:SI 3 "mask_operand" "n")))]
1fd4e8c1 3792 "includes_lshift_p (operands[2], operands[3])"
d56d506a 3793 "{rlinm|rlwinm} %0,%1,%h2,%m3,%M3")
1fd4e8c1
RK
3794
3795(define_insn ""
9ebbca7d 3796 [(set (match_operand:CC 0 "cc_reg_operand" "=x,?y")
1fd4e8c1 3797 (compare:CC
9ebbca7d
GK
3798 (and:SI (ashift:SI (match_operand:SI 1 "gpc_reg_operand" "r,r")
3799 (match_operand:SI 2 "const_int_operand" "i,i"))
ce71f754 3800 (match_operand:SI 3 "mask_operand" "n,n"))
1fd4e8c1 3801 (const_int 0)))
9ebbca7d 3802 (clobber (match_scratch:SI 4 "=r,r"))]
ce71f754 3803 "includes_lshift_p (operands[2], operands[3])"
9ebbca7d
GK
3804 "@
3805 {rlinm.|rlwinm.} %4,%1,%h2,%m3,%M3
3806 #"
3807 [(set_attr "type" "delayed_compare")
3808 (set_attr "length" "4,8")])
3809
3810(define_split
3811 [(set (match_operand:CC 0 "cc_reg_not_cr0_operand" "")
3812 (compare:CC
3813 (and:SI (ashift:SI (match_operand:SI 1 "gpc_reg_operand" "")
3814 (match_operand:SI 2 "const_int_operand" ""))
3815 (match_operand:SI 3 "mask_operand" ""))
3816 (const_int 0)))
3817 (clobber (match_scratch:SI 4 ""))]
ce71f754 3818 "includes_lshift_p (operands[2], operands[3]) && reload_completed"
9ebbca7d
GK
3819 [(set (match_dup 4)
3820 (and:SI (ashift:SI (match_dup 1) (match_dup 2))
3821 (match_dup 3)))
3822 (set (match_dup 0)
3823 (compare:CC (match_dup 4)
3824 (const_int 0)))]
3825 "")
1fd4e8c1
RK
3826
3827(define_insn ""
9ebbca7d 3828 [(set (match_operand:CC 4 "cc_reg_operand" "=x,?y")
1fd4e8c1 3829 (compare:CC
9ebbca7d
GK
3830 (and:SI (ashift:SI (match_operand:SI 1 "gpc_reg_operand" "r,r")
3831 (match_operand:SI 2 "const_int_operand" "i,i"))
ce71f754 3832 (match_operand:SI 3 "mask_operand" "n,n"))
1fd4e8c1 3833 (const_int 0)))
9ebbca7d 3834 (set (match_operand:SI 0 "gpc_reg_operand" "=r,r")
1fd4e8c1 3835 (and:SI (ashift:SI (match_dup 1) (match_dup 2)) (match_dup 3)))]
ce71f754 3836 "includes_lshift_p (operands[2], operands[3])"
9ebbca7d
GK
3837 "@
3838 {rlinm.|rlwinm.} %0,%1,%h2,%m3,%M3
3839 #"
3840 [(set_attr "type" "delayed_compare")
3841 (set_attr "length" "4,8")])
3842
3843(define_split
3844 [(set (match_operand:CC 4 "cc_reg_not_cr0_operand" "")
3845 (compare:CC
3846 (and:SI (ashift:SI (match_operand:SI 1 "gpc_reg_operand" "")
3847 (match_operand:SI 2 "const_int_operand" ""))
3848 (match_operand:SI 3 "mask_operand" ""))
3849 (const_int 0)))
3850 (set (match_operand:SI 0 "gpc_reg_operand" "")
3851 (and:SI (ashift:SI (match_dup 1) (match_dup 2)) (match_dup 3)))]
ce71f754 3852 "includes_lshift_p (operands[2], operands[3]) && reload_completed"
9ebbca7d
GK
3853 [(set (match_dup 0)
3854 (and:SI (ashift:SI (match_dup 1) (match_dup 2)) (match_dup 3)))
3855 (set (match_dup 4)
3856 (compare:CC (match_dup 0)
3857 (const_int 0)))]
3858 "")
1fd4e8c1 3859
ca7f5001 3860;; The AIX assembler mis-handles "sri x,x,0", so write that case as
5c23c401 3861;; "sli x,x,0".
ca7f5001
RK
3862(define_expand "lshrsi3"
3863 [(use (match_operand:SI 0 "gpc_reg_operand" ""))
3864 (use (match_operand:SI 1 "gpc_reg_operand" ""))
3865 (use (match_operand:SI 2 "reg_or_cint_operand" ""))]
3866 ""
3867 "
3868{
3869 if (TARGET_POWER)
3870 emit_insn (gen_lshrsi3_power (operands[0], operands[1], operands[2]));
3871 else
25c341fa 3872 emit_insn (gen_lshrsi3_no_power (operands[0], operands[1], operands[2]));
ca7f5001
RK
3873 DONE;
3874}")
3875
3876(define_insn "lshrsi3_power"
bdf423cb
MM
3877 [(set (match_operand:SI 0 "gpc_reg_operand" "=r,r,r")
3878 (lshiftrt:SI (match_operand:SI 1 "gpc_reg_operand" "r,r,r")
3879 (match_operand:SI 2 "reg_or_cint_operand" "r,O,i")))
3880 (clobber (match_scratch:SI 3 "=q,X,X"))]
ca7f5001 3881 "TARGET_POWER"
1fd4e8c1
RK
3882 "@
3883 sre %0,%1,%2
bdf423cb 3884 mr %0,%1
ca7f5001
RK
3885 {s%A2i|s%A2wi} %0,%1,%h2")
3886
25c341fa 3887(define_insn "lshrsi3_no_power"
bdf423cb
MM
3888 [(set (match_operand:SI 0 "gpc_reg_operand" "=r,r")
3889 (lshiftrt:SI (match_operand:SI 1 "gpc_reg_operand" "r,r")
3890 (match_operand:SI 2 "reg_or_cint_operand" "O,ri")))]
25c341fa 3891 "! TARGET_POWER"
bdf423cb
MM
3892 "@
3893 mr %0,%1
3894 {sr|srw}%I2 %0,%1,%h2")
1fd4e8c1
RK
3895
3896(define_insn ""
9ebbca7d
GK
3897 [(set (match_operand:CC 0 "cc_reg_operand" "=x,x,x,?y,?y,?y")
3898 (compare:CC (lshiftrt:SI (match_operand:SI 1 "gpc_reg_operand" "r,r,r,r,r,r")
3899 (match_operand:SI 2 "reg_or_cint_operand" "r,O,i,r,O,i"))
1fd4e8c1 3900 (const_int 0)))
9ebbca7d
GK
3901 (clobber (match_scratch:SI 3 "=r,X,r,r,X,r"))
3902 (clobber (match_scratch:SI 4 "=q,X,X,q,X,X"))]
ca7f5001 3903 "TARGET_POWER"
1fd4e8c1 3904 "@
29ae5b89
JL
3905 sre. %3,%1,%2
3906 mr. %1,%1
9ebbca7d
GK
3907 {s%A2i.|s%A2wi.} %3,%1,%h2
3908 #
3909 #
3910 #"
3911 [(set_attr "type" "delayed_compare")
3912 (set_attr "length" "4,4,4,8,8,8")])
3913
3914(define_split
3915 [(set (match_operand:CC 0 "cc_reg_not_cr0_operand" "")
3916 (compare:CC (lshiftrt:SI (match_operand:SI 1 "gpc_reg_operand" "")
3917 (match_operand:SI 2 "reg_or_cint_operand" ""))
3918 (const_int 0)))
3919 (clobber (match_scratch:SI 3 ""))
3920 (clobber (match_scratch:SI 4 ""))]
3921 "TARGET_POWER && reload_completed"
3922 [(parallel [(set (match_dup 3)
3923 (lshiftrt:SI (match_dup 1) (match_dup 2)))
3924 (clobber (match_dup 4))])
3925 (set (match_dup 0)
3926 (compare:CC (match_dup 3)
3927 (const_int 0)))]
3928 "")
ca7f5001
RK
3929
3930(define_insn ""
9ebbca7d
GK
3931 [(set (match_operand:CC 0 "cc_reg_operand" "=x,x,?y,?y")
3932 (compare:CC (lshiftrt:SI (match_operand:SI 1 "gpc_reg_operand" "r,r,r,r")
3933 (match_operand:SI 2 "reg_or_cint_operand" "O,ri,O,ri"))
ca7f5001 3934 (const_int 0)))
9ebbca7d 3935 (clobber (match_scratch:SI 3 "=X,r,X,r"))]
4b8a63d6 3936 "! TARGET_POWER && TARGET_32BIT"
bdf423cb
MM
3937 "@
3938 mr. %1,%1
9ebbca7d
GK
3939 {sr|srw}%I2. %3,%1,%h2
3940 #
3941 #"
3942 [(set_attr "type" "delayed_compare")
3943 (set_attr "length" "4,4,8,8")])
1fd4e8c1 3944
9ebbca7d
GK
3945(define_split
3946 [(set (match_operand:CC 0 "cc_reg_not_cr0_operand" "")
3947 (compare:CC (lshiftrt:SI (match_operand:SI 1 "gpc_reg_operand" "")
3948 (match_operand:SI 2 "reg_or_cint_operand" ""))
3949 (const_int 0)))
3950 (clobber (match_scratch:SI 3 ""))]
4b8a63d6 3951 "! TARGET_POWER && TARGET_32BIT && reload_completed"
9ebbca7d
GK
3952 [(set (match_dup 3)
3953 (lshiftrt:SI (match_dup 1) (match_dup 2)))
3954 (set (match_dup 0)
3955 (compare:CC (match_dup 3)
3956 (const_int 0)))]
3957 "")
3958
3959(define_insn ""
3960 [(set (match_operand:CC 3 "cc_reg_operand" "=x,x,x,?y,?y,?y")
3961 (compare:CC (lshiftrt:SI (match_operand:SI 1 "gpc_reg_operand" "r,r,r,r,r,r")
3962 (match_operand:SI 2 "reg_or_cint_operand" "r,O,i,r,O,i"))
1fd4e8c1 3963 (const_int 0)))
9ebbca7d 3964 (set (match_operand:SI 0 "gpc_reg_operand" "=r,r,r,r,r,r")
1fd4e8c1 3965 (lshiftrt:SI (match_dup 1) (match_dup 2)))
9ebbca7d 3966 (clobber (match_scratch:SI 4 "=q,X,X,q,X,X"))]
ca7f5001 3967 "TARGET_POWER"
1fd4e8c1 3968 "@
29ae5b89
JL
3969 sre. %0,%1,%2
3970 mr. %0,%1
9ebbca7d
GK
3971 {s%A2i.|s%A2wi.} %0,%1,%h2
3972 #
3973 #
3974 #"
3975 [(set_attr "type" "delayed_compare")
3976 (set_attr "length" "4,4,4,8,8,8")])
3977
3978(define_split
3979 [(set (match_operand:CC 3 "cc_reg_not_cr0_operand" "")
3980 (compare:CC (lshiftrt:SI (match_operand:SI 1 "gpc_reg_operand" "")
3981 (match_operand:SI 2 "reg_or_cint_operand" ""))
3982 (const_int 0)))
3983 (set (match_operand:SI 0 "gpc_reg_operand" "")
3984 (lshiftrt:SI (match_dup 1) (match_dup 2)))
3985 (clobber (match_scratch:SI 4 ""))]
3986 "TARGET_POWER && reload_completed"
3987 [(parallel [(set (match_dup 0)
3988 (lshiftrt:SI (match_dup 1) (match_dup 2)))
3989 (clobber (match_dup 4))])
3990 (set (match_dup 3)
3991 (compare:CC (match_dup 0)
3992 (const_int 0)))]
3993 "")
ca7f5001
RK
3994
3995(define_insn ""
9ebbca7d
GK
3996 [(set (match_operand:CC 3 "cc_reg_operand" "=x,x,?y,?y")
3997 (compare:CC (lshiftrt:SI (match_operand:SI 1 "gpc_reg_operand" "r,r,r,r")
3998 (match_operand:SI 2 "reg_or_cint_operand" "O,ri,O,ri"))
815cdc52 3999 (const_int 0)))
9ebbca7d 4000 (set (match_operand:SI 0 "gpc_reg_operand" "=r,r,r,r")
29ae5b89 4001 (lshiftrt:SI (match_dup 1) (match_dup 2)))]
4b8a63d6 4002 "! TARGET_POWER && TARGET_32BIT"
29ae5b89
JL
4003 "@
4004 mr. %0,%1
9ebbca7d
GK
4005 {sr|srw}%I2. %0,%1,%h2
4006 #
4007 #"
4008 [(set_attr "type" "delayed_compare")
4009 (set_attr "length" "4,4,8,8")])
4010
4011(define_split
4012 [(set (match_operand:CC 3 "cc_reg_not_cr0_operand" "")
4013 (compare:CC (lshiftrt:SI (match_operand:SI 1 "gpc_reg_operand" "")
4014 (match_operand:SI 2 "reg_or_cint_operand" ""))
4015 (const_int 0)))
4016 (set (match_operand:SI 0 "gpc_reg_operand" "")
4017 (lshiftrt:SI (match_dup 1) (match_dup 2)))]
4b8a63d6 4018 "! TARGET_POWER && TARGET_32BIT && reload_completed"
9ebbca7d
GK
4019 [(set (match_dup 0)
4020 (lshiftrt:SI (match_dup 1) (match_dup 2)))
4021 (set (match_dup 3)
4022 (compare:CC (match_dup 0)
4023 (const_int 0)))]
4024 "")
1fd4e8c1
RK
4025
4026(define_insn ""
cd2b37d9
RK
4027 [(set (match_operand:SI 0 "gpc_reg_operand" "=r")
4028 (and:SI (lshiftrt:SI (match_operand:SI 1 "gpc_reg_operand" "r")
1fd4e8c1 4029 (match_operand:SI 2 "const_int_operand" "i"))
ce71f754 4030 (match_operand:SI 3 "mask_operand" "n")))]
1fd4e8c1 4031 "includes_rshift_p (operands[2], operands[3])"
ca7f5001 4032 "{rlinm|rlwinm} %0,%1,%s2,%m3,%M3")
1fd4e8c1
RK
4033
4034(define_insn ""
9ebbca7d 4035 [(set (match_operand:CC 0 "cc_reg_operand" "=x,?y")
1fd4e8c1 4036 (compare:CC
9ebbca7d
GK
4037 (and:SI (lshiftrt:SI (match_operand:SI 1 "gpc_reg_operand" "r,r")
4038 (match_operand:SI 2 "const_int_operand" "i,i"))
ce71f754 4039 (match_operand:SI 3 "mask_operand" "n,n"))
1fd4e8c1 4040 (const_int 0)))
9ebbca7d 4041 (clobber (match_scratch:SI 4 "=r,r"))]
ce71f754 4042 "includes_rshift_p (operands[2], operands[3])"
9ebbca7d
GK
4043 "@
4044 {rlinm.|rlwinm.} %4,%1,%s2,%m3,%M3
4045 #"
4046 [(set_attr "type" "delayed_compare")
4047 (set_attr "length" "4,8")])
4048
4049(define_split
4050 [(set (match_operand:CC 0 "cc_reg_not_cr0_operand" "")
4051 (compare:CC
4052 (and:SI (lshiftrt:SI (match_operand:SI 1 "gpc_reg_operand" "")
4053 (match_operand:SI 2 "const_int_operand" ""))
4054 (match_operand:SI 3 "mask_operand" ""))
4055 (const_int 0)))
4056 (clobber (match_scratch:SI 4 ""))]
ce71f754 4057 "includes_rshift_p (operands[2], operands[3]) && reload_completed"
9ebbca7d
GK
4058 [(set (match_dup 4)
4059 (and:SI (lshiftrt:SI (match_dup 1) (match_dup 2))
4060 (match_dup 3)))
4061 (set (match_dup 0)
4062 (compare:CC (match_dup 4)
4063 (const_int 0)))]
4064 "")
1fd4e8c1
RK
4065
4066(define_insn ""
9ebbca7d 4067 [(set (match_operand:CC 4 "cc_reg_operand" "=x,?y")
1fd4e8c1 4068 (compare:CC
9ebbca7d
GK
4069 (and:SI (lshiftrt:SI (match_operand:SI 1 "gpc_reg_operand" "r,r")
4070 (match_operand:SI 2 "const_int_operand" "i,i"))
ce71f754 4071 (match_operand:SI 3 "mask_operand" "n,n"))
1fd4e8c1 4072 (const_int 0)))
9ebbca7d 4073 (set (match_operand:SI 0 "gpc_reg_operand" "=r,r")
1fd4e8c1 4074 (and:SI (lshiftrt:SI (match_dup 1) (match_dup 2)) (match_dup 3)))]
ce71f754 4075 "includes_rshift_p (operands[2], operands[3])"
9ebbca7d
GK
4076 "@
4077 {rlinm.|rlwinm.} %0,%1,%s2,%m3,%M3
4078 #"
4079 [(set_attr "type" "delayed_compare")
4080 (set_attr "length" "4,8")])
4081
4082(define_split
4083 [(set (match_operand:CC 4 "cc_reg_not_cr0_operand" "")
4084 (compare:CC
4085 (and:SI (lshiftrt:SI (match_operand:SI 1 "gpc_reg_operand" "")
4086 (match_operand:SI 2 "const_int_operand" ""))
4087 (match_operand:SI 3 "mask_operand" ""))
4088 (const_int 0)))
4089 (set (match_operand:SI 0 "gpc_reg_operand" "")
4090 (and:SI (lshiftrt:SI (match_dup 1) (match_dup 2)) (match_dup 3)))]
ce71f754 4091 "includes_rshift_p (operands[2], operands[3]) && reload_completed"
9ebbca7d
GK
4092 [(set (match_dup 0)
4093 (and:SI (lshiftrt:SI (match_dup 1) (match_dup 2)) (match_dup 3)))
4094 (set (match_dup 4)
4095 (compare:CC (match_dup 0)
4096 (const_int 0)))]
4097 "")
1fd4e8c1
RK
4098
4099(define_insn ""
cd2b37d9 4100 [(set (match_operand:SI 0 "gpc_reg_operand" "=r")
1fd4e8c1
RK
4101 (zero_extend:SI
4102 (subreg:QI
cd2b37d9 4103 (lshiftrt:SI (match_operand:SI 1 "gpc_reg_operand" "r")
1fd4e8c1 4104 (match_operand:SI 2 "const_int_operand" "i")) 0)))]
89e9f3a8 4105 "includes_rshift_p (operands[2], GEN_INT (255))"
ca7f5001 4106 "{rlinm|rlwinm} %0,%1,%s2,0xff")
1fd4e8c1
RK
4107
4108(define_insn ""
9ebbca7d 4109 [(set (match_operand:CC 0 "cc_reg_operand" "=x,?y")
1fd4e8c1
RK
4110 (compare:CC
4111 (zero_extend:SI
4112 (subreg:QI
9ebbca7d
GK
4113 (lshiftrt:SI (match_operand:SI 1 "gpc_reg_operand" "r,r")
4114 (match_operand:SI 2 "const_int_operand" "i,i")) 0))
1fd4e8c1 4115 (const_int 0)))
9ebbca7d 4116 (clobber (match_scratch:SI 3 "=r,r"))]
89e9f3a8 4117 "includes_rshift_p (operands[2], GEN_INT (255))"
9ebbca7d
GK
4118 "@
4119 {rlinm.|rlwinm.} %3,%1,%s2,0xff
4120 #"
4121 [(set_attr "type" "delayed_compare")
4122 (set_attr "length" "4,8")])
4123
4124(define_split
4125 [(set (match_operand:CC 0 "cc_reg_not_cr0_operand" "")
4126 (compare:CC
4127 (zero_extend:SI
4128 (subreg:QI
4129 (lshiftrt:SI (match_operand:SI 1 "gpc_reg_operand" "")
4130 (match_operand:SI 2 "const_int_operand" "")) 0))
4131 (const_int 0)))
4132 (clobber (match_scratch:SI 3 ""))]
4133 "includes_rshift_p (operands[2], GEN_INT (255)) && reload_completed"
4134 [(set (match_dup 3)
4135 (zero_extend:SI (subreg:QI
4136 (lshiftrt:SI (match_dup 1)
4137 (match_dup 2)) 0)))
4138 (set (match_dup 0)
4139 (compare:CC (match_dup 3)
4140 (const_int 0)))]
4141 "")
1fd4e8c1
RK
4142
4143(define_insn ""
9ebbca7d 4144 [(set (match_operand:CC 3 "cc_reg_operand" "=x,?y")
1fd4e8c1
RK
4145 (compare:CC
4146 (zero_extend:SI
4147 (subreg:QI
9ebbca7d
GK
4148 (lshiftrt:SI (match_operand:SI 1 "gpc_reg_operand" "r,r")
4149 (match_operand:SI 2 "const_int_operand" "i,i")) 0))
1fd4e8c1 4150 (const_int 0)))
9ebbca7d 4151 (set (match_operand:SI 0 "gpc_reg_operand" "=r,r")
1fd4e8c1 4152 (zero_extend:SI (subreg:QI (lshiftrt:SI (match_dup 1) (match_dup 2)) 0)))]
89e9f3a8 4153 "includes_rshift_p (operands[2], GEN_INT (255))"
9ebbca7d
GK
4154 "@
4155 {rlinm.|rlwinm.} %0,%1,%s2,0xff
4156 #"
4157 [(set_attr "type" "delayed_compare")
4158 (set_attr "length" "4,8")])
4159
4160(define_split
4161 [(set (match_operand:CC 3 "cc_reg_not_cr0_operand" "")
4162 (compare:CC
4163 (zero_extend:SI
4164 (subreg:QI
4165 (lshiftrt:SI (match_operand:SI 1 "gpc_reg_operand" "")
4166 (match_operand:SI 2 "const_int_operand" "")) 0))
4167 (const_int 0)))
4168 (set (match_operand:SI 0 "gpc_reg_operand" "")
4169 (zero_extend:SI (subreg:QI (lshiftrt:SI (match_dup 1) (match_dup 2)) 0)))]
4170 "includes_rshift_p (operands[2], GEN_INT (255)) && reload_completed"
4171 [(set (match_dup 0)
4172 (zero_extend:SI (subreg:QI (lshiftrt:SI (match_dup 1) (match_dup 2)) 0)))
4173 (set (match_dup 3)
4174 (compare:CC (match_dup 0)
4175 (const_int 0)))]
4176 "")
1fd4e8c1
RK
4177
4178(define_insn ""
cd2b37d9 4179 [(set (match_operand:SI 0 "gpc_reg_operand" "=r")
1fd4e8c1
RK
4180 (zero_extend:SI
4181 (subreg:HI
cd2b37d9 4182 (lshiftrt:SI (match_operand:SI 1 "gpc_reg_operand" "r")
1fd4e8c1 4183 (match_operand:SI 2 "const_int_operand" "i")) 0)))]
89e9f3a8 4184 "includes_rshift_p (operands[2], GEN_INT (65535))"
ca7f5001 4185 "{rlinm|rlwinm} %0,%1,%s2,0xffff")
1fd4e8c1
RK
4186
4187(define_insn ""
9ebbca7d 4188 [(set (match_operand:CC 0 "cc_reg_operand" "=x,?y")
1fd4e8c1
RK
4189 (compare:CC
4190 (zero_extend:SI
4191 (subreg:HI
9ebbca7d
GK
4192 (lshiftrt:SI (match_operand:SI 1 "gpc_reg_operand" "r,r")
4193 (match_operand:SI 2 "const_int_operand" "i,i")) 0))
1fd4e8c1 4194 (const_int 0)))
9ebbca7d 4195 (clobber (match_scratch:SI 3 "=r,r"))]
89e9f3a8 4196 "includes_rshift_p (operands[2], GEN_INT (65535))"
9ebbca7d
GK
4197 "@
4198 {rlinm.|rlwinm.} %3,%1,%s2,0xffff
4199 #"
4200 [(set_attr "type" "delayed_compare")
4201 (set_attr "length" "4,8")])
4202
4203(define_split
4204 [(set (match_operand:CC 0 "cc_reg_not_cr0_operand" "")
4205 (compare:CC
4206 (zero_extend:SI
4207 (subreg:HI
4208 (lshiftrt:SI (match_operand:SI 1 "gpc_reg_operand" "")
4209 (match_operand:SI 2 "const_int_operand" "")) 0))
4210 (const_int 0)))
4211 (clobber (match_scratch:SI 3 ""))]
4212 "includes_rshift_p (operands[2], GEN_INT (65535)) && reload_completed"
4213 [(set (match_dup 3)
4214 (zero_extend:SI (subreg:HI
4215 (lshiftrt:SI (match_dup 1)
4216 (match_dup 2)) 0)))
4217 (set (match_dup 0)
4218 (compare:CC (match_dup 3)
4219 (const_int 0)))]
4220 "")
1fd4e8c1
RK
4221
4222(define_insn ""
9ebbca7d 4223 [(set (match_operand:CC 3 "cc_reg_operand" "=x,?y")
1fd4e8c1
RK
4224 (compare:CC
4225 (zero_extend:SI
4226 (subreg:HI
9ebbca7d
GK
4227 (lshiftrt:SI (match_operand:SI 1 "gpc_reg_operand" "r,r")
4228 (match_operand:SI 2 "const_int_operand" "i,i")) 0))
1fd4e8c1 4229 (const_int 0)))
9ebbca7d 4230 (set (match_operand:SI 0 "gpc_reg_operand" "=r,r")
1fd4e8c1 4231 (zero_extend:SI (subreg:HI (lshiftrt:SI (match_dup 1) (match_dup 2)) 0)))]
89e9f3a8 4232 "includes_rshift_p (operands[2], GEN_INT (65535))"
9ebbca7d
GK
4233 "@
4234 {rlinm.|rlwinm.} %0,%1,%s2,0xffff
4235 #"
4236 [(set_attr "type" "delayed_compare")
4237 (set_attr "length" "4,8")])
4238
4239(define_split
4240 [(set (match_operand:CC 3 "cc_reg_not_cr0_operand" "")
4241 (compare:CC
4242 (zero_extend:SI
4243 (subreg:HI
4244 (lshiftrt:SI (match_operand:SI 1 "gpc_reg_operand" "")
4245 (match_operand:SI 2 "const_int_operand" "")) 0))
4246 (const_int 0)))
4247 (set (match_operand:SI 0 "gpc_reg_operand" "")
4248 (zero_extend:SI (subreg:HI (lshiftrt:SI (match_dup 1) (match_dup 2)) 0)))]
4249 "includes_rshift_p (operands[2], GEN_INT (65535)) && reload_completed"
4250 [(set (match_dup 0)
4251 (zero_extend:SI (subreg:HI (lshiftrt:SI (match_dup 1) (match_dup 2)) 0)))
4252 (set (match_dup 3)
4253 (compare:CC (match_dup 0)
4254 (const_int 0)))]
4255 "")
1fd4e8c1
RK
4256
4257(define_insn ""
cd2b37d9 4258 [(set (zero_extract:SI (match_operand:SI 0 "gpc_reg_operand" "+r")
1fd4e8c1 4259 (const_int 1)
cd2b37d9
RK
4260 (match_operand:SI 1 "gpc_reg_operand" "r"))
4261 (ashiftrt:SI (match_operand:SI 2 "gpc_reg_operand" "r")
1fd4e8c1 4262 (const_int 31)))]
ca7f5001 4263 "TARGET_POWER"
1fd4e8c1
RK
4264 "rrib %0,%1,%2")
4265
4266(define_insn ""
cd2b37d9 4267 [(set (zero_extract:SI (match_operand:SI 0 "gpc_reg_operand" "+r")
1fd4e8c1 4268 (const_int 1)
cd2b37d9
RK
4269 (match_operand:SI 1 "gpc_reg_operand" "r"))
4270 (lshiftrt:SI (match_operand:SI 2 "gpc_reg_operand" "r")
1fd4e8c1 4271 (const_int 31)))]
ca7f5001 4272 "TARGET_POWER"
1fd4e8c1
RK
4273 "rrib %0,%1,%2")
4274
4275(define_insn ""
cd2b37d9 4276 [(set (zero_extract:SI (match_operand:SI 0 "gpc_reg_operand" "+r")
1fd4e8c1 4277 (const_int 1)
cd2b37d9
RK
4278 (match_operand:SI 1 "gpc_reg_operand" "r"))
4279 (zero_extract:SI (match_operand:SI 2 "gpc_reg_operand" "r")
1fd4e8c1
RK
4280 (const_int 1)
4281 (const_int 0)))]
ca7f5001 4282 "TARGET_POWER"
1fd4e8c1
RK
4283 "rrib %0,%1,%2")
4284
ca7f5001
RK
4285(define_expand "ashrsi3"
4286 [(set (match_operand:SI 0 "gpc_reg_operand" "")
4287 (ashiftrt:SI (match_operand:SI 1 "gpc_reg_operand" "")
4288 (match_operand:SI 2 "reg_or_cint_operand" "")))]
4289 ""
4290 "
4291{
4292 if (TARGET_POWER)
4293 emit_insn (gen_ashrsi3_power (operands[0], operands[1], operands[2]));
4294 else
25c341fa 4295 emit_insn (gen_ashrsi3_no_power (operands[0], operands[1], operands[2]));
ca7f5001
RK
4296 DONE;
4297}")
4298
4299(define_insn "ashrsi3_power"
cd2b37d9
RK
4300 [(set (match_operand:SI 0 "gpc_reg_operand" "=r,r")
4301 (ashiftrt:SI (match_operand:SI 1 "gpc_reg_operand" "r,r")
1fd4e8c1
RK
4302 (match_operand:SI 2 "reg_or_cint_operand" "r,i")))
4303 (clobber (match_scratch:SI 3 "=q,X"))]
ca7f5001 4304 "TARGET_POWER"
1fd4e8c1
RK
4305 "@
4306 srea %0,%1,%2
ca7f5001
RK
4307 {srai|srawi} %0,%1,%h2")
4308
25c341fa 4309(define_insn "ashrsi3_no_power"
ca7f5001
RK
4310 [(set (match_operand:SI 0 "gpc_reg_operand" "=r")
4311 (ashiftrt:SI (match_operand:SI 1 "gpc_reg_operand" "r")
4312 (match_operand:SI 2 "reg_or_cint_operand" "ri")))]
25c341fa 4313 "! TARGET_POWER"
d904e9ed 4314 "{sra|sraw}%I2 %0,%1,%h2")
1fd4e8c1
RK
4315
4316(define_insn ""
9ebbca7d
GK
4317 [(set (match_operand:CC 0 "cc_reg_operand" "=x,x,?y,?y")
4318 (compare:CC (ashiftrt:SI (match_operand:SI 1 "gpc_reg_operand" "r,r,r,r")
4319 (match_operand:SI 2 "reg_or_cint_operand" "r,i,r,i"))
1fd4e8c1 4320 (const_int 0)))
9ebbca7d
GK
4321 (clobber (match_scratch:SI 3 "=r,r,r,r"))
4322 (clobber (match_scratch:SI 4 "=q,X,q,X"))]
ca7f5001 4323 "TARGET_POWER"
1fd4e8c1
RK
4324 "@
4325 srea. %3,%1,%2
9ebbca7d
GK
4326 {srai.|srawi.} %3,%1,%h2
4327 #
4328 #"
4329 [(set_attr "type" "delayed_compare")
4330 (set_attr "length" "4,4,8,8")])
4331
4332(define_split
4333 [(set (match_operand:CC 0 "cc_reg_not_cr0_operand" "")
4334 (compare:CC (ashiftrt:SI (match_operand:SI 1 "gpc_reg_operand" "")
4335 (match_operand:SI 2 "reg_or_cint_operand" ""))
4336 (const_int 0)))
4337 (clobber (match_scratch:SI 3 ""))
4338 (clobber (match_scratch:SI 4 ""))]
4339 "TARGET_POWER && reload_completed"
4340 [(parallel [(set (match_dup 3)
4341 (ashiftrt:SI (match_dup 1) (match_dup 2)))
4342 (clobber (match_dup 4))])
4343 (set (match_dup 0)
4344 (compare:CC (match_dup 3)
4345 (const_int 0)))]
4346 "")
ca7f5001
RK
4347
4348(define_insn ""
9ebbca7d
GK
4349 [(set (match_operand:CC 0 "cc_reg_operand" "=x,?y")
4350 (compare:CC (ashiftrt:SI (match_operand:SI 1 "gpc_reg_operand" "r,r")
4351 (match_operand:SI 2 "reg_or_cint_operand" "ri,ri"))
ca7f5001 4352 (const_int 0)))
9ebbca7d 4353 (clobber (match_scratch:SI 3 "=r,r"))]
25c341fa 4354 "! TARGET_POWER"
9ebbca7d
GK
4355 "@
4356 {sra|sraw}%I2. %3,%1,%h2
4357 #"
4358 [(set_attr "type" "delayed_compare")
4359 (set_attr "length" "4,8")])
4360
4361(define_split
4362 [(set (match_operand:CC 0 "cc_reg_not_cr0_operand" "")
4363 (compare:CC (ashiftrt:SI (match_operand:SI 1 "gpc_reg_operand" "")
4364 (match_operand:SI 2 "reg_or_cint_operand" ""))
4365 (const_int 0)))
4366 (clobber (match_scratch:SI 3 ""))]
4367 "! TARGET_POWER && reload_completed"
4368 [(set (match_dup 3)
4369 (ashiftrt:SI (match_dup 1) (match_dup 2)))
4370 (set (match_dup 0)
4371 (compare:CC (match_dup 3)
4372 (const_int 0)))]
4373 "")
1fd4e8c1
RK
4374
4375(define_insn ""
9ebbca7d
GK
4376 [(set (match_operand:CC 3 "cc_reg_operand" "=x,x,?y,?y")
4377 (compare:CC (ashiftrt:SI (match_operand:SI 1 "gpc_reg_operand" "r,r,r,r")
4378 (match_operand:SI 2 "reg_or_cint_operand" "r,i,r,i"))
1fd4e8c1 4379 (const_int 0)))
9ebbca7d 4380 (set (match_operand:SI 0 "gpc_reg_operand" "=r,r,r,r")
1fd4e8c1 4381 (ashiftrt:SI (match_dup 1) (match_dup 2)))
9ebbca7d 4382 (clobber (match_scratch:SI 4 "=q,X,q,X"))]
ca7f5001 4383 "TARGET_POWER"
1fd4e8c1
RK
4384 "@
4385 srea. %0,%1,%2
9ebbca7d
GK
4386 {srai.|srawi.} %0,%1,%h2
4387 #
4388 #"
4389 [(set_attr "type" "delayed_compare")
4390 (set_attr "length" "4,4,8,8")])
4391
4392(define_split
4393 [(set (match_operand:CC 3 "cc_reg_not_cr0_operand" "")
4394 (compare:CC (ashiftrt:SI (match_operand:SI 1 "gpc_reg_operand" "")
4395 (match_operand:SI 2 "reg_or_cint_operand" ""))
4396 (const_int 0)))
4397 (set (match_operand:SI 0 "gpc_reg_operand" "")
4398 (ashiftrt:SI (match_dup 1) (match_dup 2)))
4399 (clobber (match_scratch:SI 4 ""))]
4400 "TARGET_POWER && reload_completed"
4401 [(parallel [(set (match_dup 0)
4402 (ashiftrt:SI (match_dup 1) (match_dup 2)))
4403 (clobber (match_dup 4))])
4404 (set (match_dup 3)
4405 (compare:CC (match_dup 0)
4406 (const_int 0)))]
4407 "")
1fd4e8c1 4408
ca7f5001 4409(define_insn ""
9ebbca7d
GK
4410 [(set (match_operand:CC 3 "cc_reg_operand" "=x,?y")
4411 (compare:CC (ashiftrt:SI (match_operand:SI 1 "gpc_reg_operand" "r,r")
4412 (match_operand:SI 2 "reg_or_cint_operand" "ri,ri"))
ca7f5001 4413 (const_int 0)))
9ebbca7d 4414 (set (match_operand:SI 0 "gpc_reg_operand" "=r,r")
ca7f5001 4415 (ashiftrt:SI (match_dup 1) (match_dup 2)))]
25c341fa 4416 "! TARGET_POWER"
9ebbca7d
GK
4417 "@
4418 {sra|sraw}%I2. %0,%1,%h2
4419 #"
4420 [(set_attr "type" "delayed_compare")
4421 (set_attr "length" "4,8")])
1fd4e8c1 4422\f
9ebbca7d
GK
4423(define_split
4424 [(set (match_operand:CC 3 "cc_reg_not_cr0_operand" "")
4425 (compare:CC (ashiftrt:SI (match_operand:SI 1 "gpc_reg_operand" "")
4426 (match_operand:SI 2 "reg_or_cint_operand" ""))
4427 (const_int 0)))
4428 (set (match_operand:SI 0 "gpc_reg_operand" "")
4429 (ashiftrt:SI (match_dup 1) (match_dup 2)))]
4430 "! TARGET_POWER && reload_completed"
4431 [(set (match_dup 0)
4432 (ashiftrt:SI (match_dup 1) (match_dup 2)))
4433 (set (match_dup 3)
4434 (compare:CC (match_dup 0)
4435 (const_int 0)))]
4436 "")
4437
1fd4e8c1
RK
4438;; Floating-point insns, excluding normal data motion.
4439;;
ca7f5001
RK
4440;; PowerPC has a full set of single-precision floating point instructions.
4441;;
4442;; For the POWER architecture, we pretend that we have both SFmode and
4443;; DFmode insns, while, in fact, all fp insns are actually done in double.
4444;; The only conversions we will do will be when storing to memory. In that
4445;; case, we will use the "frsp" instruction before storing.
1fd4e8c1
RK
4446;;
4447;; Note that when we store into a single-precision memory location, we need to
4448;; use the frsp insn first. If the register being stored isn't dead, we
4449;; need a scratch register for the frsp. But this is difficult when the store
4450;; is done by reload. It is not incorrect to do the frsp on the register in
4451;; this case, we just lose precision that we would have otherwise gotten but
4452;; is not guaranteed. Perhaps this should be tightened up at some point.
4453
11ac38b2
DE
4454(define_insn_and_split "extendsfdf2"
4455 [(set (match_operand:DF 0 "gpc_reg_operand" "=f,?f")
4456 (float_extend:DF (match_operand:SF 1 "gpc_reg_operand" "0,f")))]
a3170dc6 4457 "TARGET_HARD_FLOAT && TARGET_FPRS"
11ac38b2
DE
4458 "@
4459 #
4460 fmr %0,%1"
4461 "&& reload_completed && REGNO (operands[0]) == REGNO (operands[1])"
4462 [(const_int 0)]
5c30aff8 4463{
11ac38b2
DE
4464 emit_note (NOTE_INSN_DELETED);
4465 DONE;
4466}
e8112008 4467 [(set_attr "type" "fp")])
1fd4e8c1
RK
4468
4469(define_insn "truncdfsf2"
cd2b37d9
RK
4470 [(set (match_operand:SF 0 "gpc_reg_operand" "=f")
4471 (float_truncate:SF (match_operand:DF 1 "gpc_reg_operand" "f")))]
a3170dc6 4472 "TARGET_HARD_FLOAT && TARGET_FPRS"
dcac138d 4473 "frsp %0,%1"
1fd4e8c1
RK
4474 [(set_attr "type" "fp")])
4475
455350f4
RK
4476(define_insn "aux_truncdfsf2"
4477 [(set (match_operand:SF 0 "gpc_reg_operand" "=f")
615158e2 4478 (unspec:SF [(match_operand:SF 1 "gpc_reg_operand" "f")] UNSPEC_FRSP))]
a3170dc6 4479 "! TARGET_POWERPC && TARGET_HARD_FLOAT && TARGET_FPRS"
455350f4
RK
4480 "frsp %0,%1"
4481 [(set_attr "type" "fp")])
4482
a3170dc6
AH
4483(define_expand "negsf2"
4484 [(set (match_operand:SF 0 "gpc_reg_operand" "")
4485 (neg:SF (match_operand:SF 1 "gpc_reg_operand" "")))]
4486 "TARGET_HARD_FLOAT"
4487 "")
4488
4489(define_insn "*negsf2"
cd2b37d9
RK
4490 [(set (match_operand:SF 0 "gpc_reg_operand" "=f")
4491 (neg:SF (match_operand:SF 1 "gpc_reg_operand" "f")))]
a3170dc6 4492 "TARGET_HARD_FLOAT && TARGET_FPRS"
1fd4e8c1
RK
4493 "fneg %0,%1"
4494 [(set_attr "type" "fp")])
4495
a3170dc6
AH
4496(define_expand "abssf2"
4497 [(set (match_operand:SF 0 "gpc_reg_operand" "")
4498 (abs:SF (match_operand:SF 1 "gpc_reg_operand" "")))]
4499 "TARGET_HARD_FLOAT"
4500 "")
4501
4502(define_insn "*abssf2"
cd2b37d9
RK
4503 [(set (match_operand:SF 0 "gpc_reg_operand" "=f")
4504 (abs:SF (match_operand:SF 1 "gpc_reg_operand" "f")))]
a3170dc6 4505 "TARGET_HARD_FLOAT && TARGET_FPRS"
1fd4e8c1
RK
4506 "fabs %0,%1"
4507 [(set_attr "type" "fp")])
4508
4509(define_insn ""
cd2b37d9
RK
4510 [(set (match_operand:SF 0 "gpc_reg_operand" "=f")
4511 (neg:SF (abs:SF (match_operand:SF 1 "gpc_reg_operand" "f"))))]
a3170dc6 4512 "TARGET_HARD_FLOAT && TARGET_FPRS"
1fd4e8c1
RK
4513 "fnabs %0,%1"
4514 [(set_attr "type" "fp")])
4515
ca7f5001
RK
4516(define_expand "addsf3"
4517 [(set (match_operand:SF 0 "gpc_reg_operand" "")
4518 (plus:SF (match_operand:SF 1 "gpc_reg_operand" "")
4519 (match_operand:SF 2 "gpc_reg_operand" "")))]
d14a6d05 4520 "TARGET_HARD_FLOAT"
ca7f5001
RK
4521 "")
4522
4523(define_insn ""
cd2b37d9
RK
4524 [(set (match_operand:SF 0 "gpc_reg_operand" "=f")
4525 (plus:SF (match_operand:SF 1 "gpc_reg_operand" "%f")
4526 (match_operand:SF 2 "gpc_reg_operand" "f")))]
a3170dc6 4527 "TARGET_POWERPC && TARGET_HARD_FLOAT && TARGET_FPRS"
b26c8351 4528 "fadds %0,%1,%2"
ca7f5001
RK
4529 [(set_attr "type" "fp")])
4530
4531(define_insn ""
4532 [(set (match_operand:SF 0 "gpc_reg_operand" "=f")
4533 (plus:SF (match_operand:SF 1 "gpc_reg_operand" "%f")
4534 (match_operand:SF 2 "gpc_reg_operand" "f")))]
a3170dc6 4535 "! TARGET_POWERPC && TARGET_HARD_FLOAT && TARGET_FPRS"
b26c8351 4536 "{fa|fadd} %0,%1,%2"
ca7f5001
RK
4537 [(set_attr "type" "fp")])
4538
4539(define_expand "subsf3"
4540 [(set (match_operand:SF 0 "gpc_reg_operand" "")
4541 (minus:SF (match_operand:SF 1 "gpc_reg_operand" "")
4542 (match_operand:SF 2 "gpc_reg_operand" "")))]
d14a6d05 4543 "TARGET_HARD_FLOAT"
ca7f5001
RK
4544 "")
4545
4546(define_insn ""
4547 [(set (match_operand:SF 0 "gpc_reg_operand" "=f")
4548 (minus:SF (match_operand:SF 1 "gpc_reg_operand" "f")
4549 (match_operand:SF 2 "gpc_reg_operand" "f")))]
a3170dc6 4550 "TARGET_POWERPC && TARGET_HARD_FLOAT && TARGET_FPRS"
b26c8351 4551 "fsubs %0,%1,%2"
1fd4e8c1
RK
4552 [(set_attr "type" "fp")])
4553
ca7f5001 4554(define_insn ""
cd2b37d9
RK
4555 [(set (match_operand:SF 0 "gpc_reg_operand" "=f")
4556 (minus:SF (match_operand:SF 1 "gpc_reg_operand" "f")
4557 (match_operand:SF 2 "gpc_reg_operand" "f")))]
a3170dc6 4558 "! TARGET_POWERPC && TARGET_HARD_FLOAT && TARGET_FPRS"
b26c8351 4559 "{fs|fsub} %0,%1,%2"
ca7f5001
RK
4560 [(set_attr "type" "fp")])
4561
4562(define_expand "mulsf3"
4563 [(set (match_operand:SF 0 "gpc_reg_operand" "")
4564 (mult:SF (match_operand:SF 1 "gpc_reg_operand" "")
4565 (match_operand:SF 2 "gpc_reg_operand" "")))]
d14a6d05 4566 "TARGET_HARD_FLOAT"
ca7f5001
RK
4567 "")
4568
4569(define_insn ""
4570 [(set (match_operand:SF 0 "gpc_reg_operand" "=f")
4571 (mult:SF (match_operand:SF 1 "gpc_reg_operand" "%f")
4572 (match_operand:SF 2 "gpc_reg_operand" "f")))]
a3170dc6 4573 "TARGET_POWERPC && TARGET_HARD_FLOAT && TARGET_FPRS"
b26c8351 4574 "fmuls %0,%1,%2"
1fd4e8c1
RK
4575 [(set_attr "type" "fp")])
4576
ca7f5001 4577(define_insn ""
cd2b37d9
RK
4578 [(set (match_operand:SF 0 "gpc_reg_operand" "=f")
4579 (mult:SF (match_operand:SF 1 "gpc_reg_operand" "%f")
4580 (match_operand:SF 2 "gpc_reg_operand" "f")))]
a3170dc6 4581 "! TARGET_POWERPC && TARGET_HARD_FLOAT && TARGET_FPRS"
b26c8351 4582 "{fm|fmul} %0,%1,%2"
0780f386 4583 [(set_attr "type" "dmul")])
1fd4e8c1 4584
ca7f5001
RK
4585(define_expand "divsf3"
4586 [(set (match_operand:SF 0 "gpc_reg_operand" "")
4587 (div:SF (match_operand:SF 1 "gpc_reg_operand" "")
4588 (match_operand:SF 2 "gpc_reg_operand" "")))]
d14a6d05 4589 "TARGET_HARD_FLOAT"
ca7f5001
RK
4590 "")
4591
4592(define_insn ""
cd2b37d9
RK
4593 [(set (match_operand:SF 0 "gpc_reg_operand" "=f")
4594 (div:SF (match_operand:SF 1 "gpc_reg_operand" "f")
4595 (match_operand:SF 2 "gpc_reg_operand" "f")))]
a3170dc6 4596 "TARGET_POWERPC && TARGET_HARD_FLOAT && TARGET_FPRS"
b26c8351 4597 "fdivs %0,%1,%2"
ca7f5001
RK
4598 [(set_attr "type" "sdiv")])
4599
4600(define_insn ""
4601 [(set (match_operand:SF 0 "gpc_reg_operand" "=f")
4602 (div:SF (match_operand:SF 1 "gpc_reg_operand" "f")
4603 (match_operand:SF 2 "gpc_reg_operand" "f")))]
a3170dc6 4604 "! TARGET_POWERPC && TARGET_HARD_FLOAT && TARGET_FPRS"
b26c8351 4605 "{fd|fdiv} %0,%1,%2"
0780f386 4606 [(set_attr "type" "ddiv")])
1fd4e8c1
RK
4607
4608(define_insn ""
cd2b37d9
RK
4609 [(set (match_operand:SF 0 "gpc_reg_operand" "=f")
4610 (plus:SF (mult:SF (match_operand:SF 1 "gpc_reg_operand" "%f")
4611 (match_operand:SF 2 "gpc_reg_operand" "f"))
4612 (match_operand:SF 3 "gpc_reg_operand" "f")))]
a3170dc6 4613 "TARGET_POWERPC && TARGET_HARD_FLOAT && TARGET_FPRS && TARGET_FUSED_MADD"
b26c8351 4614 "fmadds %0,%1,%2,%3"
ca7f5001
RK
4615 [(set_attr "type" "fp")])
4616
4617(define_insn ""
4618 [(set (match_operand:SF 0 "gpc_reg_operand" "=f")
4619 (plus:SF (mult:SF (match_operand:SF 1 "gpc_reg_operand" "%f")
4620 (match_operand:SF 2 "gpc_reg_operand" "f"))
4621 (match_operand:SF 3 "gpc_reg_operand" "f")))]
a3170dc6 4622 "! TARGET_POWERPC && TARGET_HARD_FLOAT && TARGET_FPRS && TARGET_FUSED_MADD"
b26c8351 4623 "{fma|fmadd} %0,%1,%2,%3"
cf27b467 4624 [(set_attr "type" "dmul")])
1fd4e8c1
RK
4625
4626(define_insn ""
cd2b37d9
RK
4627 [(set (match_operand:SF 0 "gpc_reg_operand" "=f")
4628 (minus:SF (mult:SF (match_operand:SF 1 "gpc_reg_operand" "%f")
4629 (match_operand:SF 2 "gpc_reg_operand" "f"))
4630 (match_operand:SF 3 "gpc_reg_operand" "f")))]
a3170dc6 4631 "TARGET_POWERPC && TARGET_HARD_FLOAT && TARGET_FPRS && TARGET_FUSED_MADD"
b26c8351 4632 "fmsubs %0,%1,%2,%3"
ca7f5001
RK
4633 [(set_attr "type" "fp")])
4634
4635(define_insn ""
4636 [(set (match_operand:SF 0 "gpc_reg_operand" "=f")
4637 (minus:SF (mult:SF (match_operand:SF 1 "gpc_reg_operand" "%f")
4638 (match_operand:SF 2 "gpc_reg_operand" "f"))
4639 (match_operand:SF 3 "gpc_reg_operand" "f")))]
a3170dc6 4640 "! TARGET_POWERPC && TARGET_HARD_FLOAT && TARGET_FPRS && TARGET_FUSED_MADD"
b26c8351 4641 "{fms|fmsub} %0,%1,%2,%3"
cf27b467 4642 [(set_attr "type" "dmul")])
1fd4e8c1
RK
4643
4644(define_insn ""
cd2b37d9
RK
4645 [(set (match_operand:SF 0 "gpc_reg_operand" "=f")
4646 (neg:SF (plus:SF (mult:SF (match_operand:SF 1 "gpc_reg_operand" "%f")
4647 (match_operand:SF 2 "gpc_reg_operand" "f"))
4648 (match_operand:SF 3 "gpc_reg_operand" "f"))))]
16823694
GK
4649 "TARGET_POWERPC && TARGET_HARD_FLOAT && TARGET_FPRS && TARGET_FUSED_MADD
4650 && HONOR_SIGNED_ZEROS (SFmode)"
4651 "fnmadds %0,%1,%2,%3"
4652 [(set_attr "type" "fp")])
4653
4654(define_insn ""
4655 [(set (match_operand:SF 0 "gpc_reg_operand" "=f")
4656 (minus:SF (mult:SF (neg:SF (match_operand:SF 1 "gpc_reg_operand" "f"))
4657 (match_operand:SF 2 "gpc_reg_operand" "f"))
4658 (match_operand:SF 3 "gpc_reg_operand" "f")))]
4659 "TARGET_POWERPC && TARGET_HARD_FLOAT && TARGET_FPRS && TARGET_FUSED_MADD
4660 && ! HONOR_SIGNED_ZEROS (SFmode)"
b26c8351 4661 "fnmadds %0,%1,%2,%3"
ca7f5001
RK
4662 [(set_attr "type" "fp")])
4663
4664(define_insn ""
4665 [(set (match_operand:SF 0 "gpc_reg_operand" "=f")
4666 (neg:SF (plus:SF (mult:SF (match_operand:SF 1 "gpc_reg_operand" "%f")
4667 (match_operand:SF 2 "gpc_reg_operand" "f"))
4668 (match_operand:SF 3 "gpc_reg_operand" "f"))))]
a3170dc6 4669 "! TARGET_POWERPC && TARGET_HARD_FLOAT && TARGET_FPRS && TARGET_FUSED_MADD"
b26c8351 4670 "{fnma|fnmadd} %0,%1,%2,%3"
cf27b467 4671 [(set_attr "type" "dmul")])
1fd4e8c1 4672
16823694
GK
4673(define_insn ""
4674 [(set (match_operand:SF 0 "gpc_reg_operand" "=f")
4675 (minus:SF (mult:SF (neg:SF (match_operand:SF 1 "gpc_reg_operand" "f"))
4676 (match_operand:SF 2 "gpc_reg_operand" "f"))
4677 (match_operand:SF 3 "gpc_reg_operand" "f")))]
4678 "! TARGET_POWERPC && TARGET_HARD_FLOAT && TARGET_FPRS && TARGET_FUSED_MADD
4679 && ! HONOR_SIGNED_ZEROS (SFmode)"
4680 "{fnma|fnmadd} %0,%1,%2,%3"
4681 [(set_attr "type" "dmul")])
4682
1fd4e8c1 4683(define_insn ""
cd2b37d9
RK
4684 [(set (match_operand:SF 0 "gpc_reg_operand" "=f")
4685 (neg:SF (minus:SF (mult:SF (match_operand:SF 1 "gpc_reg_operand" "%f")
4686 (match_operand:SF 2 "gpc_reg_operand" "f"))
4687 (match_operand:SF 3 "gpc_reg_operand" "f"))))]
16823694
GK
4688 "TARGET_POWERPC && TARGET_HARD_FLOAT && TARGET_FPRS && TARGET_FUSED_MADD
4689 && HONOR_SIGNED_ZEROS (SFmode)"
4690 "fnmsubs %0,%1,%2,%3"
4691 [(set_attr "type" "fp")])
4692
4693(define_insn ""
4694 [(set (match_operand:SF 0 "gpc_reg_operand" "=f")
4695 (minus:SF (match_operand:SF 3 "gpc_reg_operand" "f")
4696 (mult:SF (match_operand:SF 1 "gpc_reg_operand" "%f")
4697 (match_operand:SF 2 "gpc_reg_operand" "f"))))]
4698 "TARGET_POWERPC && TARGET_HARD_FLOAT && TARGET_FPRS && TARGET_FUSED_MADD
4699 && ! HONOR_SIGNED_ZEROS (SFmode)"
b26c8351 4700 "fnmsubs %0,%1,%2,%3"
ca7f5001
RK
4701 [(set_attr "type" "fp")])
4702
4703(define_insn ""
4704 [(set (match_operand:SF 0 "gpc_reg_operand" "=f")
4705 (neg:SF (minus:SF (mult:SF (match_operand:SF 1 "gpc_reg_operand" "%f")
4706 (match_operand:SF 2 "gpc_reg_operand" "f"))
4707 (match_operand:SF 3 "gpc_reg_operand" "f"))))]
a3170dc6 4708 "! TARGET_POWERPC && TARGET_HARD_FLOAT && TARGET_FPRS && TARGET_FUSED_MADD"
b26c8351 4709 "{fnms|fnmsub} %0,%1,%2,%3"
cf27b467 4710 [(set_attr "type" "dmul")])
1fd4e8c1 4711
16823694
GK
4712(define_insn ""
4713 [(set (match_operand:SF 0 "gpc_reg_operand" "=f")
4714 (minus:SF (match_operand:SF 3 "gpc_reg_operand" "f")
4715 (mult:SF (match_operand:SF 1 "gpc_reg_operand" "%f")
4716 (match_operand:SF 2 "gpc_reg_operand" "f"))))]
4717 "! TARGET_POWERPC && TARGET_HARD_FLOAT && TARGET_FPRS && TARGET_FUSED_MADD
4718 && ! HONOR_SIGNED_ZEROS (SFmode)"
4719 "{fnms|fnmsub} %0,%1,%2,%3"
4720 [(set_attr "type" "fp")])
4721
ca7f5001
RK
4722(define_expand "sqrtsf2"
4723 [(set (match_operand:SF 0 "gpc_reg_operand" "")
4724 (sqrt:SF (match_operand:SF 1 "gpc_reg_operand" "")))]
a3170dc6 4725 "(TARGET_PPC_GPOPT || TARGET_POWER2) && TARGET_HARD_FLOAT && TARGET_FPRS"
ca7f5001
RK
4726 "")
4727
4728(define_insn ""
4729 [(set (match_operand:SF 0 "gpc_reg_operand" "=f")
4730 (sqrt:SF (match_operand:SF 1 "gpc_reg_operand" "f")))]
a3170dc6 4731 "TARGET_PPC_GPOPT && TARGET_HARD_FLOAT && TARGET_FPRS"
ca7f5001
RK
4732 "fsqrts %0,%1"
4733 [(set_attr "type" "ssqrt")])
4734
4735(define_insn ""
4736 [(set (match_operand:SF 0 "gpc_reg_operand" "=f")
4737 (sqrt:SF (match_operand:SF 1 "gpc_reg_operand" "f")))]
a3170dc6 4738 "TARGET_POWER2 && TARGET_HARD_FLOAT && TARGET_FPRS"
ca7f5001
RK
4739 "fsqrt %0,%1"
4740 [(set_attr "type" "dsqrt")])
4741
94d7001a
RK
4742;; For MIN, MAX, and conditional move, we use DEFINE_EXPAND's that involve a
4743;; fsel instruction and some auxiliary computations. Then we just have a
4744;; single DEFINE_INSN for fsel and the define_splits to make them if made by
8e871c05
RK
4745;; combine.
4746(define_expand "maxsf3"
8e871c05 4747 [(set (match_operand:SF 0 "gpc_reg_operand" "")
50a0b056
GK
4748 (if_then_else:SF (ge (match_operand:SF 1 "gpc_reg_operand" "")
4749 (match_operand:SF 2 "gpc_reg_operand" ""))
8e871c05
RK
4750 (match_dup 1)
4751 (match_dup 2)))]
a3170dc6 4752 "TARGET_PPC_GFXOPT && TARGET_HARD_FLOAT && TARGET_FPRS"
50a0b056 4753 "{ rs6000_emit_minmax (operands[0], SMAX, operands[1], operands[2]); DONE;}")
2f607b94 4754
8e871c05 4755(define_expand "minsf3"
50a0b056
GK
4756 [(set (match_operand:SF 0 "gpc_reg_operand" "")
4757 (if_then_else:SF (ge (match_operand:SF 1 "gpc_reg_operand" "")
4758 (match_operand:SF 2 "gpc_reg_operand" ""))
4759 (match_dup 2)
4760 (match_dup 1)))]
a3170dc6 4761 "TARGET_PPC_GFXOPT && TARGET_HARD_FLOAT && TARGET_FPRS"
50a0b056 4762 "{ rs6000_emit_minmax (operands[0], SMIN, operands[1], operands[2]); DONE;}")
2f607b94 4763
8e871c05
RK
4764(define_split
4765 [(set (match_operand:SF 0 "gpc_reg_operand" "")
50a0b056
GK
4766 (match_operator:SF 3 "min_max_operator"
4767 [(match_operand:SF 1 "gpc_reg_operand" "")
4768 (match_operand:SF 2 "gpc_reg_operand" "")]))]
a3170dc6 4769 "TARGET_PPC_GFXOPT && TARGET_HARD_FLOAT && TARGET_FPRS"
50a0b056
GK
4770 [(const_int 0)]
4771 "
6ae08853 4772{ rs6000_emit_minmax (operands[0], GET_CODE (operands[3]),
50a0b056
GK
4773 operands[1], operands[2]);
4774 DONE;
4775}")
2f607b94 4776
a3170dc6
AH
4777(define_expand "movsicc"
4778 [(set (match_operand:SI 0 "gpc_reg_operand" "")
4779 (if_then_else:SI (match_operand 1 "comparison_operator" "")
4780 (match_operand:SI 2 "gpc_reg_operand" "")
4781 (match_operand:SI 3 "gpc_reg_operand" "")))]
4782 "TARGET_ISEL"
4783 "
4784{
4785 if (rs6000_emit_cmove (operands[0], operands[1], operands[2], operands[3]))
4786 DONE;
4787 else
4788 FAIL;
4789}")
4790
4791;; We use the BASE_REGS for the isel input operands because, if rA is
4792;; 0, the value of 0 is placed in rD upon truth. Similarly for rB
4793;; because we may switch the operands and rB may end up being rA.
4794;;
4795;; We need 2 patterns: an unsigned and a signed pattern. We could
4796;; leave out the mode in operand 4 and use one pattern, but reload can
4797;; change the mode underneath our feet and then gets confused trying
4798;; to reload the value.
4799(define_insn "isel_signed"
4800 [(set (match_operand:SI 0 "gpc_reg_operand" "=r")
4801 (if_then_else:SI
4802 (match_operator 1 "comparison_operator"
4803 [(match_operand:CC 4 "cc_reg_operand" "y")
4804 (const_int 0)])
4805 (match_operand:SI 2 "gpc_reg_operand" "b")
4806 (match_operand:SI 3 "gpc_reg_operand" "b")))]
4807 "TARGET_ISEL"
4808 "*
4809{ return output_isel (operands); }"
4810 [(set_attr "length" "4")])
4811
4812(define_insn "isel_unsigned"
4813 [(set (match_operand:SI 0 "gpc_reg_operand" "=r")
4814 (if_then_else:SI
4815 (match_operator 1 "comparison_operator"
4816 [(match_operand:CCUNS 4 "cc_reg_operand" "y")
4817 (const_int 0)])
4818 (match_operand:SI 2 "gpc_reg_operand" "b")
4819 (match_operand:SI 3 "gpc_reg_operand" "b")))]
4820 "TARGET_ISEL"
4821 "*
4822{ return output_isel (operands); }"
4823 [(set_attr "length" "4")])
4824
94d7001a 4825(define_expand "movsfcc"
0ad91047 4826 [(set (match_operand:SF 0 "gpc_reg_operand" "")
94d7001a 4827 (if_then_else:SF (match_operand 1 "comparison_operator" "")
0ad91047
DE
4828 (match_operand:SF 2 "gpc_reg_operand" "")
4829 (match_operand:SF 3 "gpc_reg_operand" "")))]
a3170dc6 4830 "TARGET_PPC_GFXOPT && TARGET_HARD_FLOAT && TARGET_FPRS"
94d7001a
RK
4831 "
4832{
50a0b056
GK
4833 if (rs6000_emit_cmove (operands[0], operands[1], operands[2], operands[3]))
4834 DONE;
94d7001a 4835 else
50a0b056 4836 FAIL;
94d7001a 4837}")
d56d506a 4838
50a0b056 4839(define_insn "*fselsfsf4"
8e871c05
RK
4840 [(set (match_operand:SF 0 "gpc_reg_operand" "=f")
4841 (if_then_else:SF (ge (match_operand:SF 1 "gpc_reg_operand" "f")
50a0b056 4842 (match_operand:SF 4 "zero_fp_constant" "F"))
8e871c05
RK
4843 (match_operand:SF 2 "gpc_reg_operand" "f")
4844 (match_operand:SF 3 "gpc_reg_operand" "f")))]
a3170dc6 4845 "TARGET_PPC_GFXOPT && TARGET_HARD_FLOAT && TARGET_FPRS"
8e871c05
RK
4846 "fsel %0,%1,%2,%3"
4847 [(set_attr "type" "fp")])
2f607b94 4848
50a0b056 4849(define_insn "*fseldfsf4"
94d7001a
RK
4850 [(set (match_operand:SF 0 "gpc_reg_operand" "=f")
4851 (if_then_else:SF (ge (match_operand:DF 1 "gpc_reg_operand" "f")
d365ba42 4852 (match_operand:DF 4 "zero_fp_constant" "F"))
94d7001a
RK
4853 (match_operand:SF 2 "gpc_reg_operand" "f")
4854 (match_operand:SF 3 "gpc_reg_operand" "f")))]
a3170dc6 4855 "TARGET_PPC_GFXOPT && TARGET_HARD_FLOAT && TARGET_FPRS"
94d7001a
RK
4856 "fsel %0,%1,%2,%3"
4857 [(set_attr "type" "fp")])
d56d506a 4858
1fd4e8c1 4859(define_insn "negdf2"
cd2b37d9
RK
4860 [(set (match_operand:DF 0 "gpc_reg_operand" "=f")
4861 (neg:DF (match_operand:DF 1 "gpc_reg_operand" "f")))]
a3170dc6 4862 "TARGET_HARD_FLOAT && TARGET_FPRS"
1fd4e8c1
RK
4863 "fneg %0,%1"
4864 [(set_attr "type" "fp")])
4865
4866(define_insn "absdf2"
cd2b37d9
RK
4867 [(set (match_operand:DF 0 "gpc_reg_operand" "=f")
4868 (abs:DF (match_operand:DF 1 "gpc_reg_operand" "f")))]
a3170dc6 4869 "TARGET_HARD_FLOAT && TARGET_FPRS"
1fd4e8c1
RK
4870 "fabs %0,%1"
4871 [(set_attr "type" "fp")])
4872
4873(define_insn ""
cd2b37d9
RK
4874 [(set (match_operand:DF 0 "gpc_reg_operand" "=f")
4875 (neg:DF (abs:DF (match_operand:DF 1 "gpc_reg_operand" "f"))))]
a3170dc6 4876 "TARGET_HARD_FLOAT && TARGET_FPRS"
1fd4e8c1
RK
4877 "fnabs %0,%1"
4878 [(set_attr "type" "fp")])
4879
4880(define_insn "adddf3"
cd2b37d9
RK
4881 [(set (match_operand:DF 0 "gpc_reg_operand" "=f")
4882 (plus:DF (match_operand:DF 1 "gpc_reg_operand" "%f")
4883 (match_operand:DF 2 "gpc_reg_operand" "f")))]
a3170dc6 4884 "TARGET_HARD_FLOAT && TARGET_FPRS"
ca7f5001 4885 "{fa|fadd} %0,%1,%2"
1fd4e8c1
RK
4886 [(set_attr "type" "fp")])
4887
4888(define_insn "subdf3"
cd2b37d9
RK
4889 [(set (match_operand:DF 0 "gpc_reg_operand" "=f")
4890 (minus:DF (match_operand:DF 1 "gpc_reg_operand" "f")
4891 (match_operand:DF 2 "gpc_reg_operand" "f")))]
a3170dc6 4892 "TARGET_HARD_FLOAT && TARGET_FPRS"
ca7f5001 4893 "{fs|fsub} %0,%1,%2"
1fd4e8c1
RK
4894 [(set_attr "type" "fp")])
4895
4896(define_insn "muldf3"
cd2b37d9
RK
4897 [(set (match_operand:DF 0 "gpc_reg_operand" "=f")
4898 (mult:DF (match_operand:DF 1 "gpc_reg_operand" "%f")
4899 (match_operand:DF 2 "gpc_reg_operand" "f")))]
a3170dc6 4900 "TARGET_HARD_FLOAT && TARGET_FPRS"
ca7f5001 4901 "{fm|fmul} %0,%1,%2"
cfb557c4 4902 [(set_attr "type" "dmul")])
1fd4e8c1
RK
4903
4904(define_insn "divdf3"
cd2b37d9
RK
4905 [(set (match_operand:DF 0 "gpc_reg_operand" "=f")
4906 (div:DF (match_operand:DF 1 "gpc_reg_operand" "f")
4907 (match_operand:DF 2 "gpc_reg_operand" "f")))]
a3170dc6 4908 "TARGET_HARD_FLOAT && TARGET_FPRS"
ca7f5001 4909 "{fd|fdiv} %0,%1,%2"
cfb557c4 4910 [(set_attr "type" "ddiv")])
1fd4e8c1
RK
4911
4912(define_insn ""
cd2b37d9
RK
4913 [(set (match_operand:DF 0 "gpc_reg_operand" "=f")
4914 (plus:DF (mult:DF (match_operand:DF 1 "gpc_reg_operand" "%f")
4915 (match_operand:DF 2 "gpc_reg_operand" "f"))
4916 (match_operand:DF 3 "gpc_reg_operand" "f")))]
a3170dc6 4917 "TARGET_HARD_FLOAT && TARGET_FPRS && TARGET_FUSED_MADD"
ca7f5001 4918 "{fma|fmadd} %0,%1,%2,%3"
cfb557c4 4919 [(set_attr "type" "dmul")])
1fd4e8c1
RK
4920
4921(define_insn ""
cd2b37d9
RK
4922 [(set (match_operand:DF 0 "gpc_reg_operand" "=f")
4923 (minus:DF (mult:DF (match_operand:DF 1 "gpc_reg_operand" "%f")
4924 (match_operand:DF 2 "gpc_reg_operand" "f"))
4925 (match_operand:DF 3 "gpc_reg_operand" "f")))]
a3170dc6 4926 "TARGET_HARD_FLOAT && TARGET_FPRS && TARGET_FUSED_MADD"
ca7f5001 4927 "{fms|fmsub} %0,%1,%2,%3"
cfb557c4 4928 [(set_attr "type" "dmul")])
1fd4e8c1
RK
4929
4930(define_insn ""
cd2b37d9
RK
4931 [(set (match_operand:DF 0 "gpc_reg_operand" "=f")
4932 (neg:DF (plus:DF (mult:DF (match_operand:DF 1 "gpc_reg_operand" "%f")
4933 (match_operand:DF 2 "gpc_reg_operand" "f"))
4934 (match_operand:DF 3 "gpc_reg_operand" "f"))))]
16823694
GK
4935 "TARGET_HARD_FLOAT && TARGET_FPRS && TARGET_FUSED_MADD
4936 && HONOR_SIGNED_ZEROS (DFmode)"
4937 "{fnma|fnmadd} %0,%1,%2,%3"
4938 [(set_attr "type" "dmul")])
4939
4940(define_insn ""
4941 [(set (match_operand:DF 0 "gpc_reg_operand" "=f")
4942 (minus:DF (mult:DF (neg:DF (match_operand:DF 1 "gpc_reg_operand" "f"))
4943 (match_operand:DF 2 "gpc_reg_operand" "f"))
4944 (match_operand:DF 3 "gpc_reg_operand" "f")))]
4945 "TARGET_HARD_FLOAT && TARGET_FPRS && TARGET_FUSED_MADD
4946 && ! HONOR_SIGNED_ZEROS (DFmode)"
ca7f5001 4947 "{fnma|fnmadd} %0,%1,%2,%3"
cfb557c4 4948 [(set_attr "type" "dmul")])
1fd4e8c1
RK
4949
4950(define_insn ""
cd2b37d9
RK
4951 [(set (match_operand:DF 0 "gpc_reg_operand" "=f")
4952 (neg:DF (minus:DF (mult:DF (match_operand:DF 1 "gpc_reg_operand" "%f")
4953 (match_operand:DF 2 "gpc_reg_operand" "f"))
4954 (match_operand:DF 3 "gpc_reg_operand" "f"))))]
16823694
GK
4955 "TARGET_HARD_FLOAT && TARGET_FPRS && TARGET_FUSED_MADD
4956 && HONOR_SIGNED_ZEROS (DFmode)"
4957 "{fnms|fnmsub} %0,%1,%2,%3"
4958 [(set_attr "type" "dmul")])
4959
4960(define_insn ""
4961 [(set (match_operand:DF 0 "gpc_reg_operand" "=f")
4962 (minus:DF (match_operand:DF 3 "gpc_reg_operand" "f")
4963 (mult:DF (match_operand:DF 1 "gpc_reg_operand" "%f")
4964 (match_operand:DF 2 "gpc_reg_operand" "f"))))]
6ae08853 4965 "TARGET_HARD_FLOAT && TARGET_FPRS && TARGET_FUSED_MADD
16823694 4966 && ! HONOR_SIGNED_ZEROS (DFmode)"
ca7f5001 4967 "{fnms|fnmsub} %0,%1,%2,%3"
cfb557c4 4968 [(set_attr "type" "dmul")])
ca7f5001
RK
4969
4970(define_insn "sqrtdf2"
4971 [(set (match_operand:DF 0 "gpc_reg_operand" "=f")
4972 (sqrt:DF (match_operand:DF 1 "gpc_reg_operand" "f")))]
a3170dc6 4973 "(TARGET_PPC_GPOPT || TARGET_POWER2) && TARGET_HARD_FLOAT && TARGET_FPRS"
ca7f5001
RK
4974 "fsqrt %0,%1"
4975 [(set_attr "type" "dsqrt")])
b77dfefc 4976
50a0b056 4977;; The conditional move instructions allow us to perform max and min
6ae08853 4978;; operations even when
b77dfefc 4979
8e871c05 4980(define_expand "maxdf3"
8e871c05 4981 [(set (match_operand:DF 0 "gpc_reg_operand" "")
50a0b056
GK
4982 (if_then_else:DF (ge (match_operand:DF 1 "gpc_reg_operand" "")
4983 (match_operand:DF 2 "gpc_reg_operand" ""))
8e871c05
RK
4984 (match_dup 1)
4985 (match_dup 2)))]
a3170dc6 4986 "TARGET_PPC_GFXOPT && TARGET_HARD_FLOAT && TARGET_FPRS"
50a0b056 4987 "{ rs6000_emit_minmax (operands[0], SMAX, operands[1], operands[2]); DONE;}")
b77dfefc 4988
8e871c05 4989(define_expand "mindf3"
50a0b056
GK
4990 [(set (match_operand:DF 0 "gpc_reg_operand" "")
4991 (if_then_else:DF (ge (match_operand:DF 1 "gpc_reg_operand" "")
4992 (match_operand:DF 2 "gpc_reg_operand" ""))
4993 (match_dup 2)
4994 (match_dup 1)))]
a3170dc6 4995 "TARGET_PPC_GFXOPT && TARGET_HARD_FLOAT && TARGET_FPRS"
50a0b056 4996 "{ rs6000_emit_minmax (operands[0], SMIN, operands[1], operands[2]); DONE;}")
b77dfefc 4997
8e871c05
RK
4998(define_split
4999 [(set (match_operand:DF 0 "gpc_reg_operand" "")
50a0b056
GK
5000 (match_operator:DF 3 "min_max_operator"
5001 [(match_operand:DF 1 "gpc_reg_operand" "")
5002 (match_operand:DF 2 "gpc_reg_operand" "")]))]
a3170dc6 5003 "TARGET_PPC_GFXOPT && TARGET_HARD_FLOAT && TARGET_FPRS"
50a0b056
GK
5004 [(const_int 0)]
5005 "
6ae08853 5006{ rs6000_emit_minmax (operands[0], GET_CODE (operands[3]),
50a0b056
GK
5007 operands[1], operands[2]);
5008 DONE;
5009}")
b77dfefc 5010
94d7001a 5011(define_expand "movdfcc"
0ad91047 5012 [(set (match_operand:DF 0 "gpc_reg_operand" "")
94d7001a 5013 (if_then_else:DF (match_operand 1 "comparison_operator" "")
0ad91047
DE
5014 (match_operand:DF 2 "gpc_reg_operand" "")
5015 (match_operand:DF 3 "gpc_reg_operand" "")))]
a3170dc6 5016 "TARGET_PPC_GFXOPT && TARGET_HARD_FLOAT && TARGET_FPRS"
94d7001a
RK
5017 "
5018{
50a0b056
GK
5019 if (rs6000_emit_cmove (operands[0], operands[1], operands[2], operands[3]))
5020 DONE;
94d7001a 5021 else
50a0b056 5022 FAIL;
94d7001a 5023}")
d56d506a 5024
50a0b056 5025(define_insn "*fseldfdf4"
8e871c05
RK
5026 [(set (match_operand:DF 0 "gpc_reg_operand" "=f")
5027 (if_then_else:DF (ge (match_operand:DF 1 "gpc_reg_operand" "f")
50a0b056 5028 (match_operand:DF 4 "zero_fp_constant" "F"))
8e871c05
RK
5029 (match_operand:DF 2 "gpc_reg_operand" "f")
5030 (match_operand:DF 3 "gpc_reg_operand" "f")))]
a3170dc6 5031 "TARGET_PPC_GFXOPT && TARGET_HARD_FLOAT && TARGET_FPRS"
8e871c05
RK
5032 "fsel %0,%1,%2,%3"
5033 [(set_attr "type" "fp")])
d56d506a 5034
50a0b056 5035(define_insn "*fselsfdf4"
94d7001a
RK
5036 [(set (match_operand:DF 0 "gpc_reg_operand" "=f")
5037 (if_then_else:DF (ge (match_operand:SF 1 "gpc_reg_operand" "f")
50a0b056 5038 (match_operand:SF 4 "zero_fp_constant" "F"))
94d7001a
RK
5039 (match_operand:DF 2 "gpc_reg_operand" "f")
5040 (match_operand:DF 3 "gpc_reg_operand" "f")))]
5041 "TARGET_PPC_GFXOPT"
5042 "fsel %0,%1,%2,%3"
5043 [(set_attr "type" "fp")])
1fd4e8c1 5044\f
d095928f
AH
5045;; Conversions to and from floating-point.
5046
5047(define_expand "fixuns_truncsfsi2"
5048 [(set (match_operand:SI 0 "gpc_reg_operand" "")
5049 (unsigned_fix:SI (match_operand:SF 1 "gpc_reg_operand" "")))]
5050 "TARGET_HARD_FLOAT && !TARGET_FPRS"
5051 "")
5052
5053(define_expand "fix_truncsfsi2"
5054 [(set (match_operand:SI 0 "gpc_reg_operand" "")
5055 (fix:SI (match_operand:SF 1 "gpc_reg_operand" "")))]
5056 "TARGET_HARD_FLOAT && !TARGET_FPRS"
5057 "")
5058
9ebbca7d
GK
5059; For each of these conversions, there is a define_expand, a define_insn
5060; with a '#' template, and a define_split (with C code). The idea is
5061; to allow constant folding with the template of the define_insn,
5062; then to have the insns split later (between sched1 and final).
5063
1fd4e8c1 5064(define_expand "floatsidf2"
802a0058
MM
5065 [(parallel [(set (match_operand:DF 0 "gpc_reg_operand" "")
5066 (float:DF (match_operand:SI 1 "gpc_reg_operand" "")))
5067 (use (match_dup 2))
5068 (use (match_dup 3))
208c89ce 5069 (clobber (match_dup 4))
a7df97e6 5070 (clobber (match_dup 5))
9ebbca7d 5071 (clobber (match_dup 6))])]
a3170dc6 5072 "TARGET_HARD_FLOAT && TARGET_FPRS"
1fd4e8c1
RK
5073 "
5074{
05d49501
AM
5075 if (TARGET_POWERPC64)
5076 {
5077 rtx mem = assign_stack_temp (DImode, GET_MODE_SIZE (DImode), 0);
5078 rtx t1 = gen_reg_rtx (DImode);
5079 rtx t2 = gen_reg_rtx (DImode);
5080 emit_insn (gen_floatsidf_ppc64 (operands[0], operands[1], mem, t1, t2));
5081 DONE;
5082 }
5083
802a0058 5084 operands[2] = force_reg (SImode, GEN_INT (0x43300000));
5692c7bc 5085 operands[3] = force_reg (DFmode, CONST_DOUBLE_ATOF (\"4503601774854144\", DFmode));
9ebbca7d
GK
5086 operands[4] = assign_stack_temp (DFmode, GET_MODE_SIZE (DFmode), 0);
5087 operands[5] = gen_reg_rtx (DFmode);
5088 operands[6] = gen_reg_rtx (SImode);
1fd4e8c1
RK
5089}")
5090
802a0058
MM
5091(define_insn "*floatsidf2_internal"
5092 [(set (match_operand:DF 0 "gpc_reg_operand" "=&f")
5093 (float:DF (match_operand:SI 1 "gpc_reg_operand" "r")))
5094 (use (match_operand:SI 2 "gpc_reg_operand" "r"))
5095 (use (match_operand:DF 3 "gpc_reg_operand" "f"))
9ebbca7d 5096 (clobber (match_operand:DF 4 "memory_operand" "=o"))
6f9c81f5
DJ
5097 (clobber (match_operand:DF 5 "gpc_reg_operand" "=&f"))
5098 (clobber (match_operand:SI 6 "gpc_reg_operand" "=&r"))]
a3170dc6 5099 "! TARGET_POWERPC64 && TARGET_HARD_FLOAT && TARGET_FPRS"
802a0058 5100 "#"
a7df97e6 5101 [(set_attr "length" "24")])
802a0058
MM
5102
5103(define_split
dbe3df29 5104 [(set (match_operand:DF 0 "gpc_reg_operand" "")
802a0058
MM
5105 (float:DF (match_operand:SI 1 "gpc_reg_operand" "")))
5106 (use (match_operand:SI 2 "gpc_reg_operand" ""))
5107 (use (match_operand:DF 3 "gpc_reg_operand" ""))
9ebbca7d
GK
5108 (clobber (match_operand:DF 4 "offsettable_mem_operand" ""))
5109 (clobber (match_operand:DF 5 "gpc_reg_operand" ""))
5110 (clobber (match_operand:SI 6 "gpc_reg_operand" ""))]
a3170dc6 5111 "! TARGET_POWERPC64 && TARGET_HARD_FLOAT && TARGET_FPRS"
9ebbca7d
GK
5112 [(set (match_operand:DF 0 "gpc_reg_operand" "")
5113 (float:DF (match_operand:SI 1 "gpc_reg_operand" "")))
5114 (use (match_operand:SI 2 "gpc_reg_operand" ""))
5115 (use (match_operand:DF 3 "gpc_reg_operand" ""))
5116 (clobber (match_operand:DF 4 "offsettable_mem_operand" ""))
5117 (clobber (match_operand:DF 5 "gpc_reg_operand" ""))
5118 (clobber (match_operand:SI 6 "gpc_reg_operand" ""))]
208c89ce
MM
5119 "
5120{
9ebbca7d
GK
5121 rtx lowword, highword;
5122 if (GET_CODE (operands[4]) != MEM)
5123 abort();
5124 highword = XEXP (operands[4], 0);
5125 lowword = plus_constant (highword, 4);
5126 if (! WORDS_BIG_ENDIAN)
5127 {
5128 rtx tmp;
5129 tmp = highword; highword = lowword; lowword = tmp;
5130 }
5131
6ae08853 5132 emit_insn (gen_xorsi3 (operands[6], operands[1],
9ebbca7d
GK
5133 GEN_INT (~ (HOST_WIDE_INT) 0x7fffffff)));
5134 emit_move_insn (gen_rtx_MEM (SImode, lowword), operands[6]);
5135 emit_move_insn (gen_rtx_MEM (SImode, highword), operands[2]);
5136 emit_move_insn (operands[5], operands[4]);
5137 emit_insn (gen_subdf3 (operands[0], operands[5], operands[3]));
5138 DONE;
208c89ce 5139}")
802a0058 5140
a3170dc6
AH
5141(define_expand "floatunssisf2"
5142 [(set (match_operand:SF 0 "gpc_reg_operand" "")
5143 (unsigned_float:SF (match_operand:SI 1 "gpc_reg_operand" "")))]
5144 "TARGET_HARD_FLOAT && !TARGET_FPRS"
5145 "")
5146
802a0058
MM
5147(define_expand "floatunssidf2"
5148 [(parallel [(set (match_operand:DF 0 "gpc_reg_operand" "")
5149 (unsigned_float:DF (match_operand:SI 1 "gpc_reg_operand" "")))
5150 (use (match_dup 2))
5151 (use (match_dup 3))
a7df97e6 5152 (clobber (match_dup 4))
9ebbca7d 5153 (clobber (match_dup 5))])]
a3170dc6 5154 "TARGET_HARD_FLOAT && TARGET_FPRS"
1fd4e8c1
RK
5155 "
5156{
05d49501
AM
5157 if (TARGET_POWERPC64)
5158 {
5159 rtx mem = assign_stack_temp (DImode, GET_MODE_SIZE (DImode), 0);
5160 rtx t1 = gen_reg_rtx (DImode);
5161 rtx t2 = gen_reg_rtx (DImode);
5162 emit_insn (gen_floatunssidf_ppc64 (operands[0], operands[1], mem,
5163 t1, t2));
5164 DONE;
5165 }
5166
802a0058 5167 operands[2] = force_reg (SImode, GEN_INT (0x43300000));
5692c7bc 5168 operands[3] = force_reg (DFmode, CONST_DOUBLE_ATOF (\"4503599627370496\", DFmode));
9ebbca7d
GK
5169 operands[4] = assign_stack_temp (DFmode, GET_MODE_SIZE (DFmode), 0);
5170 operands[5] = gen_reg_rtx (DFmode);
1fd4e8c1
RK
5171}")
5172
802a0058
MM
5173(define_insn "*floatunssidf2_internal"
5174 [(set (match_operand:DF 0 "gpc_reg_operand" "=&f")
5175 (unsigned_float:DF (match_operand:SI 1 "gpc_reg_operand" "r")))
5176 (use (match_operand:SI 2 "gpc_reg_operand" "r"))
5177 (use (match_operand:DF 3 "gpc_reg_operand" "f"))
9ebbca7d 5178 (clobber (match_operand:DF 4 "memory_operand" "=o"))
6f9c81f5 5179 (clobber (match_operand:DF 5 "gpc_reg_operand" "=&f"))]
a3170dc6 5180 "! TARGET_POWERPC64 && TARGET_HARD_FLOAT && TARGET_FPRS"
802a0058 5181 "#"
a7df97e6 5182 [(set_attr "length" "20")])
802a0058
MM
5183
5184(define_split
5185 [(set (match_operand:DF 0 "gpc_reg_operand" "")
5186 (unsigned_float:DF (match_operand:SI 1 "gpc_reg_operand" "")))
5187 (use (match_operand:SI 2 "gpc_reg_operand" ""))
5188 (use (match_operand:DF 3 "gpc_reg_operand" ""))
9ebbca7d
GK
5189 (clobber (match_operand:DF 4 "offsettable_mem_operand" ""))
5190 (clobber (match_operand:DF 5 "gpc_reg_operand" ""))]
a3170dc6 5191 "! TARGET_POWERPC64 && TARGET_HARD_FLOAT && TARGET_FPRS"
9ebbca7d
GK
5192 [(set (match_operand:DF 0 "gpc_reg_operand" "")
5193 (unsigned_float:DF (match_operand:SI 1 "gpc_reg_operand" "")))
5194 (use (match_operand:SI 2 "gpc_reg_operand" ""))
5195 (use (match_operand:DF 3 "gpc_reg_operand" ""))
5196 (clobber (match_operand:DF 4 "offsettable_mem_operand" ""))
5197 (clobber (match_operand:DF 5 "gpc_reg_operand" ""))]
5198 "
802a0058 5199{
9ebbca7d
GK
5200 rtx lowword, highword;
5201 if (GET_CODE (operands[4]) != MEM)
5202 abort();
5203 highword = XEXP (operands[4], 0);
5204 lowword = plus_constant (highword, 4);
5205 if (! WORDS_BIG_ENDIAN)
f6968f59 5206 {
9ebbca7d
GK
5207 rtx tmp;
5208 tmp = highword; highword = lowword; lowword = tmp;
f6968f59 5209 }
802a0058 5210
9ebbca7d
GK
5211 emit_move_insn (gen_rtx_MEM (SImode, lowword), operands[1]);
5212 emit_move_insn (gen_rtx_MEM (SImode, highword), operands[2]);
5213 emit_move_insn (operands[5], operands[4]);
5214 emit_insn (gen_subdf3 (operands[0], operands[5], operands[3]));
5215 DONE;
5216}")
1fd4e8c1 5217
1fd4e8c1 5218(define_expand "fix_truncdfsi2"
802a0058
MM
5219 [(parallel [(set (match_operand:SI 0 "gpc_reg_operand" "")
5220 (fix:SI (match_operand:DF 1 "gpc_reg_operand" "")))
5221 (clobber (match_dup 2))
9ebbca7d 5222 (clobber (match_dup 3))])]
a3170dc6 5223 "(TARGET_POWER2 || TARGET_POWERPC) && TARGET_HARD_FLOAT && TARGET_FPRS"
1fd4e8c1
RK
5224 "
5225{
802a0058 5226 operands[2] = gen_reg_rtx (DImode);
9ebbca7d 5227 operands[3] = assign_stack_temp (DImode, GET_MODE_SIZE (DImode), 0);
1fd4e8c1
RK
5228}")
5229
802a0058
MM
5230(define_insn "*fix_truncdfsi2_internal"
5231 [(set (match_operand:SI 0 "gpc_reg_operand" "=r")
5232 (fix:SI (match_operand:DF 1 "gpc_reg_operand" "f")))
e3485bbc 5233 (clobber (match_operand:DI 2 "gpc_reg_operand" "=f"))
9ebbca7d 5234 (clobber (match_operand:DI 3 "memory_operand" "=o"))]
a3170dc6 5235 "(TARGET_POWER2 || TARGET_POWERPC) && TARGET_HARD_FLOAT && TARGET_FPRS"
802a0058 5236 "#"
9ebbca7d 5237 [(set_attr "length" "16")])
802a0058
MM
5238
5239(define_split
5240 [(set (match_operand:SI 0 "gpc_reg_operand" "")
75540af0 5241 (fix:SI (match_operand:DF 1 "gpc_reg_operand" "")))
802a0058 5242 (clobber (match_operand:DI 2 "gpc_reg_operand" ""))
9ebbca7d 5243 (clobber (match_operand:DI 3 "offsettable_mem_operand" ""))]
a3170dc6 5244 "(TARGET_POWER2 || TARGET_POWERPC) && TARGET_HARD_FLOAT && TARGET_FPRS"
9ebbca7d 5245 [(set (match_operand:SI 0 "gpc_reg_operand" "")
75540af0 5246 (fix:SI (match_operand:DF 1 "gpc_reg_operand" "")))
9ebbca7d
GK
5247 (clobber (match_operand:DI 2 "gpc_reg_operand" ""))
5248 (clobber (match_operand:DI 3 "offsettable_mem_operand" ""))]
5249 "
802a0058 5250{
9ebbca7d
GK
5251 rtx lowword;
5252 if (GET_CODE (operands[3]) != MEM)
5253 abort();
5254 lowword = XEXP (operands[3], 0);
5255 if (WORDS_BIG_ENDIAN)
5256 lowword = plus_constant (lowword, 4);
802a0058 5257
9ebbca7d
GK
5258 emit_insn (gen_fctiwz (operands[2], operands[1]));
5259 emit_move_insn (operands[3], operands[2]);
5260 emit_move_insn (operands[0], gen_rtx_MEM (SImode, lowword));
5261 DONE;
5262}")
802a0058 5263
615158e2 5264; Here, we use (set (reg) (unspec:DI [(fix:SI ...)] UNSPEC_FCTIWZ))
9ebbca7d
GK
5265; rather than (set (subreg:SI (reg)) (fix:SI ...))
5266; because the first makes it clear that operand 0 is not live
5267; before the instruction.
5268(define_insn "fctiwz"
61c07d3c 5269 [(set (match_operand:DI 0 "gpc_reg_operand" "=*f")
615158e2
JJ
5270 (unspec:DI [(fix:SI (match_operand:DF 1 "gpc_reg_operand" "f"))]
5271 UNSPEC_FCTIWZ))]
a3170dc6 5272 "(TARGET_POWER2 || TARGET_POWERPC) && TARGET_HARD_FLOAT && TARGET_FPRS"
a260abc9
DE
5273 "{fcirz|fctiwz} %0,%1"
5274 [(set_attr "type" "fp")])
5275
a3170dc6
AH
5276(define_expand "floatsisf2"
5277 [(set (match_operand:SF 0 "gpc_reg_operand" "")
5278 (float:SF (match_operand:SI 1 "gpc_reg_operand" "")))]
5279 "TARGET_HARD_FLOAT && !TARGET_FPRS"
5280 "")
5281
a473029f
RK
5282(define_insn "floatdidf2"
5283 [(set (match_operand:DF 0 "gpc_reg_operand" "=f")
61c07d3c 5284 (float:DF (match_operand:DI 1 "gpc_reg_operand" "*f")))]
a3170dc6 5285 "TARGET_POWERPC64 && TARGET_HARD_FLOAT && TARGET_FPRS"
a473029f
RK
5286 "fcfid %0,%1"
5287 [(set_attr "type" "fp")])
5288
05d49501
AM
5289(define_insn_and_split "floatsidf_ppc64"
5290 [(set (match_operand:DF 0 "gpc_reg_operand" "=f")
5291 (float:DF (match_operand:SI 1 "gpc_reg_operand" "r")))
5292 (clobber (match_operand:DI 2 "memory_operand" "=o"))
5293 (clobber (match_operand:DI 3 "gpc_reg_operand" "=r"))
5294 (clobber (match_operand:DI 4 "gpc_reg_operand" "=f"))]
a3170dc6 5295 "TARGET_POWERPC64 && TARGET_HARD_FLOAT && TARGET_FPRS"
05d49501 5296 "#"
ecb62ae7 5297 "&& 1"
05d49501
AM
5298 [(set (match_dup 3) (sign_extend:DI (match_dup 1)))
5299 (set (match_dup 2) (match_dup 3))
5300 (set (match_dup 4) (match_dup 2))
5301 (set (match_dup 0) (float:DF (match_dup 4)))]
5302 "")
5303
5304(define_insn_and_split "floatunssidf_ppc64"
5305 [(set (match_operand:DF 0 "gpc_reg_operand" "=f")
5306 (unsigned_float:DF (match_operand:SI 1 "gpc_reg_operand" "r")))
5307 (clobber (match_operand:DI 2 "memory_operand" "=o"))
5308 (clobber (match_operand:DI 3 "gpc_reg_operand" "=r"))
5309 (clobber (match_operand:DI 4 "gpc_reg_operand" "=f"))]
a3170dc6 5310 "TARGET_POWERPC64 && TARGET_HARD_FLOAT && TARGET_FPRS"
05d49501 5311 "#"
ecb62ae7 5312 "&& 1"
05d49501
AM
5313 [(set (match_dup 3) (zero_extend:DI (match_dup 1)))
5314 (set (match_dup 2) (match_dup 3))
5315 (set (match_dup 4) (match_dup 2))
5316 (set (match_dup 0) (float:DF (match_dup 4)))]
5317 "")
5318
a473029f 5319(define_insn "fix_truncdfdi2"
61c07d3c 5320 [(set (match_operand:DI 0 "gpc_reg_operand" "=*f")
a473029f 5321 (fix:DI (match_operand:DF 1 "gpc_reg_operand" "f")))]
a3170dc6 5322 "TARGET_POWERPC64 && TARGET_HARD_FLOAT && TARGET_FPRS"
a473029f
RK
5323 "fctidz %0,%1"
5324 [(set_attr "type" "fp")])
ea112fc4 5325
678b7733
AM
5326(define_expand "floatdisf2"
5327 [(set (match_operand:SF 0 "gpc_reg_operand" "")
5328 (float:SF (match_operand:DI 1 "gpc_reg_operand" "")))]
683bdff7 5329 "TARGET_64BIT && TARGET_HARD_FLOAT && TARGET_FPRS"
678b7733
AM
5330 "
5331{
5332 if (!flag_unsafe_math_optimizations)
5333 {
5334 rtx label = gen_label_rtx ();
5335 emit_insn (gen_floatdisf2_internal2 (operands[1], label));
5336 emit_label (label);
5337 }
5338 emit_insn (gen_floatdisf2_internal1 (operands[0], operands[1]));
5339 DONE;
5340}")
5341
5342;; This is not IEEE compliant if rounding mode is "round to nearest".
5343;; If the DI->DF conversion is inexact, then it's possible to suffer
5344;; from double rounding.
5345(define_insn_and_split "floatdisf2_internal1"
ea112fc4 5346 [(set (match_operand:SF 0 "gpc_reg_operand" "=f")
61c07d3c 5347 (float:SF (match_operand:DI 1 "gpc_reg_operand" "*f")))
ea112fc4 5348 (clobber (match_scratch:DF 2 "=f"))]
678b7733 5349 "TARGET_POWERPC64 && TARGET_HARD_FLOAT && TARGET_FPRS"
ea112fc4
DE
5350 "#"
5351 "&& reload_completed"
5352 [(set (match_dup 2)
5353 (float:DF (match_dup 1)))
5354 (set (match_dup 0)
5355 (float_truncate:SF (match_dup 2)))]
5356 "")
678b7733
AM
5357
5358;; Twiddles bits to avoid double rounding.
b6d08ca1 5359;; Bits that might be truncated when converting to DFmode are replaced
678b7733
AM
5360;; by a bit that won't be lost at that stage, but is below the SFmode
5361;; rounding position.
5362(define_expand "floatdisf2_internal2"
42a6388c
AM
5363 [(parallel [(set (match_dup 4)
5364 (compare:CC (and:DI (match_operand:DI 0 "" "")
5365 (const_int 2047))
5366 (const_int 0)))
5367 (set (match_dup 2) (and:DI (match_dup 0) (const_int 2047)))
5368 (clobber (match_scratch:CC 7 ""))])
678b7733
AM
5369 (set (match_dup 3) (ashiftrt:DI (match_dup 0) (const_int 53)))
5370 (set (match_dup 3) (plus:DI (match_dup 3) (const_int 1)))
5371 (set (pc) (if_then_else (eq (match_dup 4) (const_int 0))
5372 (label_ref (match_operand:DI 1 "" ""))
5373 (pc)))
5374 (set (match_dup 5) (compare:CCUNS (match_dup 3) (const_int 2)))
5375 (set (pc) (if_then_else (ltu (match_dup 5) (const_int 0))
5376 (label_ref (match_dup 1))
5377 (pc)))
5378 (set (match_dup 0) (xor:DI (match_dup 0) (match_dup 2)))
5379 (set (match_dup 0) (ior:DI (match_dup 0) (const_int 2048)))]
683bdff7 5380 "TARGET_64BIT && TARGET_HARD_FLOAT && TARGET_FPRS"
678b7733
AM
5381 "
5382{
5383 operands[2] = gen_reg_rtx (DImode);
5384 operands[3] = gen_reg_rtx (DImode);
5385 operands[4] = gen_reg_rtx (CCmode);
5386 operands[5] = gen_reg_rtx (CCUNSmode);
5387}")
1fd4e8c1
RK
5388\f
5389;; Define the DImode operations that can be done in a small number
a6ec530c
RK
5390;; of instructions. The & constraints are to prevent the register
5391;; allocator from allocating registers that overlap with the inputs
5392;; (for example, having an input in 7,8 and an output in 6,7). We
38e01259 5393;; also allow for the output being the same as one of the inputs.
a6ec530c 5394
266eb58a 5395(define_insn "*adddi3_noppc64"
a6ec530c
RK
5396 [(set (match_operand:DI 0 "gpc_reg_operand" "=&r,&r,r,r")
5397 (plus:DI (match_operand:DI 1 "gpc_reg_operand" "%r,r,0,0")
5398 (match_operand:DI 2 "reg_or_short_operand" "r,I,r,I")))]
e1f83b4d 5399 "! TARGET_POWERPC64"
0f645302
MM
5400 "*
5401{
5402 if (WORDS_BIG_ENDIAN)
5403 return (GET_CODE (operands[2])) != CONST_INT
5404 ? \"{a|addc} %L0,%L1,%L2\;{ae|adde} %0,%1,%2\"
5405 : \"{ai|addic} %L0,%L1,%2\;{a%G2e|add%G2e} %0,%1\";
5406 else
5407 return (GET_CODE (operands[2])) != CONST_INT
5408 ? \"{a|addc} %0,%1,%2\;{ae|adde} %L0,%L1,%L2\"
5409 : \"{ai|addic} %0,%1,%2\;{a%G2e|add%G2e} %L0,%L1\";
5410}"
b19003d8 5411 [(set_attr "length" "8")])
1fd4e8c1 5412
266eb58a 5413(define_insn "*subdi3_noppc64"
e7e5df70
RK
5414 [(set (match_operand:DI 0 "gpc_reg_operand" "=&r,&r,r,r,r")
5415 (minus:DI (match_operand:DI 1 "reg_or_short_operand" "r,I,0,r,I")
5416 (match_operand:DI 2 "gpc_reg_operand" "r,r,r,0,0")))]
266eb58a 5417 "! TARGET_POWERPC64"
5502823b
RK
5418 "*
5419{
0f645302
MM
5420 if (WORDS_BIG_ENDIAN)
5421 return (GET_CODE (operands[1]) != CONST_INT)
5422 ? \"{sf|subfc} %L0,%L2,%L1\;{sfe|subfe} %0,%2,%1\"
5423 : \"{sfi|subfic} %L0,%L2,%1\;{sf%G1e|subf%G1e} %0,%2\";
5424 else
5425 return (GET_CODE (operands[1]) != CONST_INT)
5426 ? \"{sf|subfc} %0,%2,%1\;{sfe|subfe} %L0,%L2,%L1\"
5427 : \"{sfi|subfic} %0,%2,%1\;{sf%G1e|subf%G1e} %L0,%L2\";
5502823b 5428}"
ca7f5001
RK
5429 [(set_attr "length" "8")])
5430
266eb58a 5431(define_insn "*negdi2_noppc64"
a6ec530c
RK
5432 [(set (match_operand:DI 0 "gpc_reg_operand" "=&r,r")
5433 (neg:DI (match_operand:DI 1 "gpc_reg_operand" "r,0")))]
51b8fc2c 5434 "! TARGET_POWERPC64"
5502823b
RK
5435 "*
5436{
5437 return (WORDS_BIG_ENDIAN)
5438 ? \"{sfi|subfic} %L0,%L1,0\;{sfze|subfze} %0,%1\"
5439 : \"{sfi|subfic} %0,%1,0\;{sfze|subfze} %L0,%L1\";
5440}"
ca7f5001
RK
5441 [(set_attr "length" "8")])
5442
8ffd9c51
RK
5443(define_expand "mulsidi3"
5444 [(set (match_operand:DI 0 "gpc_reg_operand" "")
5445 (mult:DI (sign_extend:DI (match_operand:SI 1 "gpc_reg_operand" ""))
5446 (sign_extend:DI (match_operand:SI 2 "gpc_reg_operand" ""))))]
a2f270cc 5447 "! TARGET_POWERPC64"
8ffd9c51
RK
5448 "
5449{
5450 if (! TARGET_POWER && ! TARGET_POWERPC)
5451 {
39403d82
DE
5452 emit_move_insn (gen_rtx_REG (SImode, 3), operands[1]);
5453 emit_move_insn (gen_rtx_REG (SImode, 4), operands[2]);
fada905b 5454 emit_insn (gen_mull_call ());
cf27b467 5455 if (WORDS_BIG_ENDIAN)
39403d82 5456 emit_move_insn (operands[0], gen_rtx_REG (DImode, 3));
cf27b467
MM
5457 else
5458 {
5459 emit_move_insn (operand_subword (operands[0], 0, 0, DImode),
39403d82 5460 gen_rtx_REG (SImode, 3));
cf27b467 5461 emit_move_insn (operand_subword (operands[0], 1, 0, DImode),
39403d82 5462 gen_rtx_REG (SImode, 4));
cf27b467 5463 }
8ffd9c51
RK
5464 DONE;
5465 }
5466 else if (TARGET_POWER)
5467 {
5468 emit_insn (gen_mulsidi3_mq (operands[0], operands[1], operands[2]));
5469 DONE;
5470 }
5471}")
deb9225a 5472
8ffd9c51 5473(define_insn "mulsidi3_mq"
cd2b37d9 5474 [(set (match_operand:DI 0 "gpc_reg_operand" "=r")
8ffd9c51 5475 (mult:DI (sign_extend:DI (match_operand:SI 1 "gpc_reg_operand" "%r"))
cd2b37d9 5476 (sign_extend:DI (match_operand:SI 2 "gpc_reg_operand" "r"))))
1fd4e8c1 5477 (clobber (match_scratch:SI 3 "=q"))]
ca7f5001 5478 "TARGET_POWER"
b19003d8 5479 "mul %0,%1,%2\;mfmq %L0"
8ffd9c51
RK
5480 [(set_attr "type" "imul")
5481 (set_attr "length" "8")])
deb9225a 5482
f192bf8b 5483(define_insn "*mulsidi3_no_mq"
425c176f 5484 [(set (match_operand:DI 0 "gpc_reg_operand" "=&r")
8ffd9c51
RK
5485 (mult:DI (sign_extend:DI (match_operand:SI 1 "gpc_reg_operand" "%r"))
5486 (sign_extend:DI (match_operand:SI 2 "gpc_reg_operand" "r"))))]
f192bf8b 5487 "TARGET_POWERPC && ! TARGET_POWER && ! TARGET_POWERPC64"
5502823b
RK
5488 "*
5489{
5490 return (WORDS_BIG_ENDIAN)
5491 ? \"mulhw %0,%1,%2\;mullw %L0,%1,%2\"
5492 : \"mulhw %L0,%1,%2\;mullw %0,%1,%2\";
5493}"
8ffd9c51
RK
5494 [(set_attr "type" "imul")
5495 (set_attr "length" "8")])
deb9225a 5496
ebedb4dd
MM
5497(define_split
5498 [(set (match_operand:DI 0 "gpc_reg_operand" "")
5499 (mult:DI (sign_extend:DI (match_operand:SI 1 "gpc_reg_operand" ""))
5500 (sign_extend:DI (match_operand:SI 2 "gpc_reg_operand" ""))))]
cf27b467 5501 "TARGET_POWERPC && ! TARGET_POWERPC64 && reload_completed"
ebedb4dd
MM
5502 [(set (match_dup 3)
5503 (truncate:SI
5504 (lshiftrt:DI (mult:DI (sign_extend:DI (match_dup 1))
5505 (sign_extend:DI (match_dup 2)))
5506 (const_int 32))))
5507 (set (match_dup 4)
5508 (mult:SI (match_dup 1)
5509 (match_dup 2)))]
5510 "
5511{
5512 int endian = (WORDS_BIG_ENDIAN == 0);
5513 operands[3] = operand_subword (operands[0], endian, 0, DImode);
5514 operands[4] = operand_subword (operands[0], 1 - endian, 0, DImode);
5515}")
5516
f192bf8b
DE
5517(define_expand "umulsidi3"
5518 [(set (match_operand:DI 0 "gpc_reg_operand" "")
5519 (mult:DI (zero_extend:DI (match_operand:SI 1 "gpc_reg_operand" ""))
5520 (zero_extend:DI (match_operand:SI 2 "gpc_reg_operand" ""))))]
5521 "TARGET_POWERPC && ! TARGET_POWERPC64"
5522 "
5523{
5524 if (TARGET_POWER)
5525 {
5526 emit_insn (gen_umulsidi3_mq (operands[0], operands[1], operands[2]));
5527 DONE;
5528 }
5529}")
5530
5531(define_insn "umulsidi3_mq"
5532 [(set (match_operand:DI 0 "gpc_reg_operand" "=&r")
5533 (mult:DI (zero_extend:DI (match_operand:SI 1 "gpc_reg_operand" "%r"))
5534 (zero_extend:DI (match_operand:SI 2 "gpc_reg_operand" "r"))))
5535 (clobber (match_scratch:SI 3 "=q"))]
5536 "TARGET_POWERPC && TARGET_POWER"
5537 "*
5538{
5539 return (WORDS_BIG_ENDIAN)
5540 ? \"mulhwu %0,%1,%2\;mullw %L0,%1,%2\"
5541 : \"mulhwu %L0,%1,%2\;mullw %0,%1,%2\";
5542}"
5543 [(set_attr "type" "imul")
5544 (set_attr "length" "8")])
5545
5546(define_insn "*umulsidi3_no_mq"
8106dc08
MM
5547 [(set (match_operand:DI 0 "gpc_reg_operand" "=&r")
5548 (mult:DI (zero_extend:DI (match_operand:SI 1 "gpc_reg_operand" "%r"))
5549 (zero_extend:DI (match_operand:SI 2 "gpc_reg_operand" "r"))))]
f192bf8b 5550 "TARGET_POWERPC && ! TARGET_POWER && ! TARGET_POWERPC64"
8106dc08
MM
5551 "*
5552{
5553 return (WORDS_BIG_ENDIAN)
5554 ? \"mulhwu %0,%1,%2\;mullw %L0,%1,%2\"
5555 : \"mulhwu %L0,%1,%2\;mullw %0,%1,%2\";
5556}"
5557 [(set_attr "type" "imul")
5558 (set_attr "length" "8")])
5559
ebedb4dd
MM
5560(define_split
5561 [(set (match_operand:DI 0 "gpc_reg_operand" "")
5562 (mult:DI (zero_extend:DI (match_operand:SI 1 "gpc_reg_operand" ""))
5563 (zero_extend:DI (match_operand:SI 2 "gpc_reg_operand" ""))))]
cf27b467 5564 "TARGET_POWERPC && ! TARGET_POWERPC64 && reload_completed"
ebedb4dd
MM
5565 [(set (match_dup 3)
5566 (truncate:SI
5567 (lshiftrt:DI (mult:DI (zero_extend:DI (match_dup 1))
5568 (zero_extend:DI (match_dup 2)))
5569 (const_int 32))))
5570 (set (match_dup 4)
5571 (mult:SI (match_dup 1)
5572 (match_dup 2)))]
5573 "
5574{
5575 int endian = (WORDS_BIG_ENDIAN == 0);
5576 operands[3] = operand_subword (operands[0], endian, 0, DImode);
5577 operands[4] = operand_subword (operands[0], 1 - endian, 0, DImode);
5578}")
5579
8ffd9c51
RK
5580(define_expand "smulsi3_highpart"
5581 [(set (match_operand:SI 0 "gpc_reg_operand" "")
5582 (truncate:SI
5583 (lshiftrt:DI (mult:DI (sign_extend:DI
5584 (match_operand:SI 1 "gpc_reg_operand" "%r"))
5585 (sign_extend:DI
5586 (match_operand:SI 2 "gpc_reg_operand" "r")))
5587 (const_int 32))))]
5588 ""
5589 "
5590{
5591 if (! TARGET_POWER && ! TARGET_POWERPC)
5592 {
39403d82
DE
5593 emit_move_insn (gen_rtx_REG (SImode, 3), operands[1]);
5594 emit_move_insn (gen_rtx_REG (SImode, 4), operands[2]);
fada905b 5595 emit_insn (gen_mulh_call ());
39403d82 5596 emit_move_insn (operands[0], gen_rtx_REG (SImode, 3));
8ffd9c51
RK
5597 DONE;
5598 }
5599 else if (TARGET_POWER)
5600 {
5601 emit_insn (gen_smulsi3_highpart_mq (operands[0], operands[1], operands[2]));
5602 DONE;
5603 }
5604}")
deb9225a 5605
8ffd9c51
RK
5606(define_insn "smulsi3_highpart_mq"
5607 [(set (match_operand:SI 0 "gpc_reg_operand" "=r")
5608 (truncate:SI
fada905b
MM
5609 (lshiftrt:DI (mult:DI (sign_extend:DI
5610 (match_operand:SI 1 "gpc_reg_operand" "%r"))
5611 (sign_extend:DI
5612 (match_operand:SI 2 "gpc_reg_operand" "r")))
8ffd9c51
RK
5613 (const_int 32))))
5614 (clobber (match_scratch:SI 3 "=q"))]
5615 "TARGET_POWER"
5616 "mul %0,%1,%2"
5617 [(set_attr "type" "imul")])
deb9225a 5618
f192bf8b 5619(define_insn "*smulsi3_highpart_no_mq"
8ffd9c51
RK
5620 [(set (match_operand:SI 0 "gpc_reg_operand" "=r")
5621 (truncate:SI
fada905b
MM
5622 (lshiftrt:DI (mult:DI (sign_extend:DI
5623 (match_operand:SI 1 "gpc_reg_operand" "%r"))
5624 (sign_extend:DI
5625 (match_operand:SI 2 "gpc_reg_operand" "r")))
8ffd9c51 5626 (const_int 32))))]
f192bf8b 5627 "TARGET_POWERPC && ! TARGET_POWER"
8ffd9c51
RK
5628 "mulhw %0,%1,%2"
5629 [(set_attr "type" "imul")])
deb9225a 5630
f192bf8b
DE
5631(define_expand "umulsi3_highpart"
5632 [(set (match_operand:SI 0 "gpc_reg_operand" "")
5633 (truncate:SI
5634 (lshiftrt:DI (mult:DI (zero_extend:DI
5635 (match_operand:SI 1 "gpc_reg_operand" ""))
5636 (zero_extend:DI
5637 (match_operand:SI 2 "gpc_reg_operand" "")))
5638 (const_int 32))))]
5639 "TARGET_POWERPC"
5640 "
5641{
5642 if (TARGET_POWER)
5643 {
5644 emit_insn (gen_umulsi3_highpart_mq (operands[0], operands[1], operands[2]));
5645 DONE;
5646 }
5647}")
5648
5649(define_insn "umulsi3_highpart_mq"
5650 [(set (match_operand:SI 0 "gpc_reg_operand" "=r")
5651 (truncate:SI
5652 (lshiftrt:DI (mult:DI (zero_extend:DI
5653 (match_operand:SI 1 "gpc_reg_operand" "%r"))
5654 (zero_extend:DI
5655 (match_operand:SI 2 "gpc_reg_operand" "r")))
5656 (const_int 32))))
5657 (clobber (match_scratch:SI 3 "=q"))]
5658 "TARGET_POWERPC && TARGET_POWER"
5659 "mulhwu %0,%1,%2"
5660 [(set_attr "type" "imul")])
5661
5662(define_insn "*umulsi3_highpart_no_mq"
266eb58a
DE
5663 [(set (match_operand:SI 0 "gpc_reg_operand" "=r")
5664 (truncate:SI
5665 (lshiftrt:DI (mult:DI (zero_extend:DI
5666 (match_operand:SI 1 "gpc_reg_operand" "%r"))
5667 (zero_extend:DI
5668 (match_operand:SI 2 "gpc_reg_operand" "r")))
5669 (const_int 32))))]
f192bf8b 5670 "TARGET_POWERPC && ! TARGET_POWER"
266eb58a
DE
5671 "mulhwu %0,%1,%2"
5672 [(set_attr "type" "imul")])
5673
5674;; If operands 0 and 2 are in the same register, we have a problem. But
5675;; operands 0 and 1 (the usual case) can be in the same register. That's
5676;; why we have the strange constraints below.
5677(define_insn "ashldi3_power"
5678 [(set (match_operand:DI 0 "gpc_reg_operand" "=r,r,r,&r")
5679 (ashift:DI (match_operand:DI 1 "gpc_reg_operand" "r,r,0,r")
5680 (match_operand:SI 2 "reg_or_cint_operand" "M,i,r,r")))
5681 (clobber (match_scratch:SI 3 "=X,q,q,q"))]
5682 "TARGET_POWER"
5683 "@
5684 {sli|slwi} %0,%L1,%h2\;{cal %L0,0(0)|li %L0,0}
5685 sl%I2q %L0,%L1,%h2\;sll%I2q %0,%1,%h2
5686 sl%I2q %L0,%L1,%h2\;sll%I2q %0,%1,%h2
5687 sl%I2q %L0,%L1,%h2\;sll%I2q %0,%1,%h2"
5688 [(set_attr "length" "8")])
5689
5690(define_insn "lshrdi3_power"
47ad8c61 5691 [(set (match_operand:DI 0 "gpc_reg_operand" "=r,r,r,&r")
266eb58a
DE
5692 (lshiftrt:DI (match_operand:DI 1 "gpc_reg_operand" "r,r,0,r")
5693 (match_operand:SI 2 "reg_or_cint_operand" "M,i,r,r")))
5694 (clobber (match_scratch:SI 3 "=X,q,q,q"))]
5695 "TARGET_POWER"
5696 "@
47ad8c61 5697 {s%A2i|s%A2wi} %L0,%1,%h2\;{cal %0,0(0)|li %0,0}
266eb58a
DE
5698 sr%I2q %0,%1,%h2\;srl%I2q %L0,%L1,%h2
5699 sr%I2q %0,%1,%h2\;srl%I2q %L0,%L1,%h2
5700 sr%I2q %0,%1,%h2\;srl%I2q %L0,%L1,%h2"
5701 [(set_attr "length" "8")])
5702
5703;; Shift by a variable amount is too complex to be worth open-coding. We
5704;; just handle shifts by constants.
5705(define_insn "ashrdi3_power"
7093ddee 5706 [(set (match_operand:DI 0 "gpc_reg_operand" "=&r,r")
266eb58a
DE
5707 (ashiftrt:DI (match_operand:DI 1 "gpc_reg_operand" "r,r")
5708 (match_operand:SI 2 "const_int_operand" "M,i")))
5709 (clobber (match_scratch:SI 3 "=X,q"))]
5710 "TARGET_POWER"
5711 "@
5712 {srai|srawi} %0,%1,31\;{srai|srawi} %L0,%1,%h2
5713 sraiq %0,%1,%h2\;srliq %L0,%L1,%h2"
5714 [(set_attr "length" "8")])
4aa74a4f
FS
5715
5716(define_insn "ashrdi3_no_power"
5717 [(set (match_operand:DI 0 "gpc_reg_operand" "=&r,&r")
5718 (ashiftrt:DI (match_operand:DI 1 "gpc_reg_operand" "r,r")
5719 (match_operand:SI 2 "const_int_operand" "M,i")))]
97727e85 5720 "TARGET_32BIT && !TARGET_POWERPC64 && !TARGET_POWER && WORDS_BIG_ENDIAN"
4aa74a4f
FS
5721 "@
5722 {srai|srawi} %0,%1,31\;{srai|srawi} %L0,%1,%h2
5723 {sri|srwi} %L0,%L1,%h2\;insrwi %L0,%1,%h2,0\;{srai|srawi} %0,%1,%h2"
5724 [(set_attr "length" "8,12")])
683bdff7
FJ
5725
5726(define_insn "*ashrdisi3_noppc64"
5727 [(set (match_operand:SI 0 "gpc_reg_operand" "=r")
6ae08853 5728 (subreg:SI (ashiftrt:DI (match_operand:DI 1 "gpc_reg_operand" "r")
683bdff7
FJ
5729 (const_int 32)) 4))]
5730 "TARGET_32BIT && !TARGET_POWERPC64"
5731 "*
5732{
5733 if (REGNO (operands[0]) == REGNO (operands[1]))
5734 return \"\";
5735 else
5736 return \"mr %0,%1\";
5737}"
6ae08853 5738 [(set_attr "length" "4")])
683bdff7 5739
266eb58a
DE
5740\f
5741;; PowerPC64 DImode operations.
5742
5743(define_expand "adddi3"
5744 [(set (match_operand:DI 0 "gpc_reg_operand" "")
5745 (plus:DI (match_operand:DI 1 "gpc_reg_operand" "")
2bfcf297 5746 (match_operand:DI 2 "reg_or_add_cint64_operand" "")))]
266eb58a
DE
5747 ""
5748 "
5749{
a260abc9
DE
5750 if (! TARGET_POWERPC64)
5751 {
5752 if (non_short_cint_operand (operands[2], DImode))
5753 FAIL;
5754 }
5755 else
5756 if (GET_CODE (operands[2]) == CONST_INT
677a9668 5757 && ! add_operand (operands[2], DImode))
a260abc9 5758 {
677a9668 5759 rtx tmp = ((no_new_pseudos || rtx_equal_p (operands[0], operands[1]))
a260abc9
DE
5760 ? operands[0] : gen_reg_rtx (DImode));
5761
2bfcf297 5762 HOST_WIDE_INT val = INTVAL (operands[2]);
a65c591c 5763 HOST_WIDE_INT low = ((val & 0xffff) ^ 0x8000) - 0x8000;
2bfcf297 5764 HOST_WIDE_INT rest = trunc_int_for_mode (val - low, DImode);
a260abc9 5765
2bfcf297
DB
5766 if (!CONST_OK_FOR_LETTER_P (rest, 'L'))
5767 FAIL;
a260abc9 5768
2bfcf297
DB
5769 /* The ordering here is important for the prolog expander.
5770 When space is allocated from the stack, adding 'low' first may
5771 produce a temporary deallocation (which would be bad). */
5772 emit_insn (gen_adddi3 (tmp, operands[1], GEN_INT (rest)));
a260abc9
DE
5773 emit_insn (gen_adddi3 (operands[0], tmp, GEN_INT (low)));
5774 DONE;
5775 }
266eb58a
DE
5776}")
5777
5778;; Discourage ai/addic because of carry but provide it in an alternative
5779;; allowing register zero as source.
5780
a260abc9 5781(define_insn "*adddi3_internal1"
266eb58a
DE
5782 [(set (match_operand:DI 0 "gpc_reg_operand" "=r,r,?r,r")
5783 (plus:DI (match_operand:DI 1 "gpc_reg_operand" "%r,b,r,b")
9615f239 5784 (match_operand:DI 2 "add_operand" "r,I,I,L")))]
266eb58a
DE
5785 "TARGET_POWERPC64"
5786 "@
5787 add %0,%1,%2
5788 addi %0,%1,%2
5789 addic %0,%1,%2
802a0058 5790 addis %0,%1,%v2")
266eb58a 5791
a260abc9 5792(define_insn "*adddi3_internal2"
9ebbca7d
GK
5793 [(set (match_operand:CC 0 "cc_reg_operand" "=x,x,?y,?y")
5794 (compare:CC (plus:DI (match_operand:DI 1 "gpc_reg_operand" "%r,r,r,r")
5795 (match_operand:DI 2 "reg_or_short_operand" "r,I,r,I"))
266eb58a 5796 (const_int 0)))
9ebbca7d 5797 (clobber (match_scratch:DI 3 "=r,r,r,r"))]
683bdff7 5798 "TARGET_64BIT"
266eb58a
DE
5799 "@
5800 add. %3,%1,%2
9ebbca7d
GK
5801 addic. %3,%1,%2
5802 #
5803 #"
a62bfff2 5804 [(set_attr "type" "fast_compare,compare,compare,compare")
9ebbca7d
GK
5805 (set_attr "length" "4,4,8,8")])
5806
5807(define_split
5808 [(set (match_operand:CC 0 "cc_reg_not_cr0_operand" "")
5809 (compare:CC (plus:DI (match_operand:DI 1 "gpc_reg_operand" "")
5810 (match_operand:DI 2 "reg_or_short_operand" ""))
5811 (const_int 0)))
5812 (clobber (match_scratch:DI 3 ""))]
5813 "TARGET_POWERPC64 && reload_completed"
5814 [(set (match_dup 3)
5815 (plus:DI (match_dup 1) (match_dup 2)))
5816 (set (match_dup 0)
5817 (compare:CC (match_dup 3)
5818 (const_int 0)))]
5819 "")
266eb58a 5820
a260abc9 5821(define_insn "*adddi3_internal3"
9ebbca7d
GK
5822 [(set (match_operand:CC 3 "cc_reg_operand" "=x,x,?y,?y")
5823 (compare:CC (plus:DI (match_operand:DI 1 "gpc_reg_operand" "%r,r,r,r")
5824 (match_operand:DI 2 "reg_or_short_operand" "r,I,r,I"))
266eb58a 5825 (const_int 0)))
9ebbca7d 5826 (set (match_operand:DI 0 "gpc_reg_operand" "=r,r,r,r")
266eb58a 5827 (plus:DI (match_dup 1) (match_dup 2)))]
683bdff7 5828 "TARGET_64BIT"
266eb58a
DE
5829 "@
5830 add. %0,%1,%2
9ebbca7d
GK
5831 addic. %0,%1,%2
5832 #
5833 #"
a62bfff2 5834 [(set_attr "type" "fast_compare,compare,compare,compare")
9ebbca7d
GK
5835 (set_attr "length" "4,4,8,8")])
5836
5837(define_split
5838 [(set (match_operand:CC 3 "cc_reg_not_cr0_operand" "")
5839 (compare:CC (plus:DI (match_operand:DI 1 "gpc_reg_operand" "")
5840 (match_operand:DI 2 "reg_or_short_operand" ""))
5841 (const_int 0)))
5842 (set (match_operand:DI 0 "gpc_reg_operand" "")
5843 (plus:DI (match_dup 1) (match_dup 2)))]
5844 "TARGET_POWERPC64 && reload_completed"
5845 [(set (match_dup 0)
5846 (plus:DI (match_dup 1) (match_dup 2)))
5847 (set (match_dup 3)
5848 (compare:CC (match_dup 0)
5849 (const_int 0)))]
5850 "")
266eb58a
DE
5851
5852;; Split an add that we can't do in one insn into two insns, each of which
5853;; does one 16-bit part. This is used by combine. Note that the low-order
5854;; add should be last in case the result gets used in an address.
5855
5856(define_split
5857 [(set (match_operand:DI 0 "gpc_reg_operand" "")
5858 (plus:DI (match_operand:DI 1 "gpc_reg_operand" "")
5859 (match_operand:DI 2 "non_add_cint_operand" "")))]
5860 "TARGET_POWERPC64"
5861 [(set (match_dup 0) (plus:DI (match_dup 1) (match_dup 3)))
5862 (set (match_dup 0) (plus:DI (match_dup 0) (match_dup 4)))]
5863"
5864{
2bfcf297 5865 HOST_WIDE_INT val = INTVAL (operands[2]);
a65c591c 5866 HOST_WIDE_INT low = ((val & 0xffff) ^ 0x8000) - 0x8000;
2bfcf297 5867 HOST_WIDE_INT rest = trunc_int_for_mode (val - low, DImode);
266eb58a 5868
2bfcf297
DB
5869 operands[4] = GEN_INT (low);
5870 if (CONST_OK_FOR_LETTER_P (rest, 'L'))
5871 operands[3] = GEN_INT (rest);
5872 else if (! no_new_pseudos)
38886f37 5873 {
2bfcf297
DB
5874 operands[3] = gen_reg_rtx (DImode);
5875 emit_move_insn (operands[3], operands[2]);
5876 emit_insn (gen_adddi3 (operands[0], operands[1], operands[3]));
5877 DONE;
38886f37 5878 }
2bfcf297
DB
5879 else
5880 FAIL;
266eb58a
DE
5881}")
5882
5883(define_insn "one_cmpldi2"
5884 [(set (match_operand:DI 0 "gpc_reg_operand" "=r")
5885 (not:DI (match_operand:DI 1 "gpc_reg_operand" "r")))]
5886 "TARGET_POWERPC64"
5887 "nor %0,%1,%1")
5888
5889(define_insn ""
9ebbca7d
GK
5890 [(set (match_operand:CC 0 "cc_reg_operand" "=x,?y")
5891 (compare:CC (not:DI (match_operand:DI 1 "gpc_reg_operand" "r,r"))
266eb58a 5892 (const_int 0)))
9ebbca7d 5893 (clobber (match_scratch:DI 2 "=r,r"))]
683bdff7 5894 "TARGET_64BIT"
9ebbca7d
GK
5895 "@
5896 nor. %2,%1,%1
5897 #"
5898 [(set_attr "type" "compare")
5899 (set_attr "length" "4,8")])
5900
5901(define_split
5902 [(set (match_operand:CC 0 "cc_reg_not_cr0_operand" "")
5903 (compare:CC (not:DI (match_operand:DI 1 "gpc_reg_operand" ""))
5904 (const_int 0)))
5905 (clobber (match_scratch:DI 2 ""))]
5906 "TARGET_POWERPC64 && reload_completed"
5907 [(set (match_dup 2)
5908 (not:DI (match_dup 1)))
5909 (set (match_dup 0)
5910 (compare:CC (match_dup 2)
5911 (const_int 0)))]
5912 "")
266eb58a
DE
5913
5914(define_insn ""
9ebbca7d
GK
5915 [(set (match_operand:CC 2 "cc_reg_operand" "=x,?y")
5916 (compare:CC (not:DI (match_operand:DI 1 "gpc_reg_operand" "r,r"))
266eb58a 5917 (const_int 0)))
9ebbca7d 5918 (set (match_operand:DI 0 "gpc_reg_operand" "=r,r")
266eb58a 5919 (not:DI (match_dup 1)))]
683bdff7 5920 "TARGET_64BIT"
9ebbca7d
GK
5921 "@
5922 nor. %0,%1,%1
5923 #"
5924 [(set_attr "type" "compare")
5925 (set_attr "length" "4,8")])
5926
5927(define_split
5928 [(set (match_operand:CC 2 "cc_reg_not_cr0_operand" "")
5929 (compare:CC (not:DI (match_operand:DI 1 "gpc_reg_operand" ""))
5930 (const_int 0)))
5931 (set (match_operand:DI 0 "gpc_reg_operand" "")
5932 (not:DI (match_dup 1)))]
5933 "TARGET_POWERPC64 && reload_completed"
5934 [(set (match_dup 0)
5935 (not:DI (match_dup 1)))
5936 (set (match_dup 2)
5937 (compare:CC (match_dup 0)
5938 (const_int 0)))]
5939 "")
266eb58a
DE
5940
5941(define_insn ""
5942 [(set (match_operand:DI 0 "gpc_reg_operand" "=r,r")
5943 (minus:DI (match_operand:DI 1 "reg_or_short_operand" "r,I")
5944 (match_operand:DI 2 "gpc_reg_operand" "r,r")))]
5945 "TARGET_POWERPC64"
5946 "@
5947 subf %0,%2,%1
5948 subfic %0,%2,%1")
5949
5950(define_insn ""
9ebbca7d
GK
5951 [(set (match_operand:CC 0 "cc_reg_operand" "=x,?y")
5952 (compare:CC (minus:DI (match_operand:DI 1 "gpc_reg_operand" "r,r")
5953 (match_operand:DI 2 "gpc_reg_operand" "r,r"))
266eb58a 5954 (const_int 0)))
9ebbca7d 5955 (clobber (match_scratch:DI 3 "=r,r"))]
683bdff7 5956 "TARGET_64BIT"
9ebbca7d
GK
5957 "@
5958 subf. %3,%2,%1
5959 #"
a62bfff2 5960 [(set_attr "type" "fast_compare")
9ebbca7d
GK
5961 (set_attr "length" "4,8")])
5962
5963(define_split
5964 [(set (match_operand:CC 0 "cc_reg_not_cr0_operand" "")
5965 (compare:CC (minus:DI (match_operand:DI 1 "gpc_reg_operand" "")
5966 (match_operand:DI 2 "gpc_reg_operand" ""))
5967 (const_int 0)))
5968 (clobber (match_scratch:DI 3 ""))]
5969 "TARGET_POWERPC64 && reload_completed"
5970 [(set (match_dup 3)
5971 (minus:DI (match_dup 1) (match_dup 2)))
5972 (set (match_dup 0)
5973 (compare:CC (match_dup 3)
5974 (const_int 0)))]
5975 "")
266eb58a
DE
5976
5977(define_insn ""
9ebbca7d
GK
5978 [(set (match_operand:CC 3 "cc_reg_operand" "=x,?y")
5979 (compare:CC (minus:DI (match_operand:DI 1 "gpc_reg_operand" "r,r")
5980 (match_operand:DI 2 "gpc_reg_operand" "r,r"))
266eb58a 5981 (const_int 0)))
9ebbca7d 5982 (set (match_operand:DI 0 "gpc_reg_operand" "=r,r")
266eb58a 5983 (minus:DI (match_dup 1) (match_dup 2)))]
683bdff7 5984 "TARGET_64BIT"
9ebbca7d
GK
5985 "@
5986 subf. %0,%2,%1
5987 #"
a62bfff2 5988 [(set_attr "type" "fast_compare")
9ebbca7d
GK
5989 (set_attr "length" "4,8")])
5990
5991(define_split
5992 [(set (match_operand:CC 3 "cc_reg_not_cr0_operand" "")
5993 (compare:CC (minus:DI (match_operand:DI 1 "gpc_reg_operand" "")
5994 (match_operand:DI 2 "gpc_reg_operand" ""))
5995 (const_int 0)))
5996 (set (match_operand:DI 0 "gpc_reg_operand" "")
5997 (minus:DI (match_dup 1) (match_dup 2)))]
5998 "TARGET_POWERPC64 && reload_completed"
5999 [(set (match_dup 0)
6000 (minus:DI (match_dup 1) (match_dup 2)))
6001 (set (match_dup 3)
6002 (compare:CC (match_dup 0)
6003 (const_int 0)))]
6004 "")
266eb58a
DE
6005
6006(define_expand "subdi3"
6007 [(set (match_operand:DI 0 "gpc_reg_operand" "")
6008 (minus:DI (match_operand:DI 1 "reg_or_short_operand" "")
2bfcf297 6009 (match_operand:DI 2 "reg_or_sub_cint64_operand" "")))]
266eb58a
DE
6010 ""
6011 "
6012{
6013 if (GET_CODE (operands[2]) == CONST_INT)
6014 {
6015 emit_insn (gen_adddi3 (operands[0], operands[1],
6016 negate_rtx (DImode, operands[2])));
6017 DONE;
6018 }
6019}")
6020
ea112fc4 6021(define_insn_and_split "absdi2"
266eb58a 6022 [(set (match_operand:DI 0 "gpc_reg_operand" "=&r,r")
ea112fc4 6023 (abs:DI (match_operand:DI 1 "gpc_reg_operand" "r,0")))
266eb58a
DE
6024 (clobber (match_scratch:DI 2 "=&r,&r"))]
6025 "TARGET_POWERPC64"
ea112fc4
DE
6026 "#"
6027 "&& reload_completed"
a260abc9 6028 [(set (match_dup 2) (ashiftrt:DI (match_dup 1) (const_int 63)))
266eb58a 6029 (set (match_dup 0) (xor:DI (match_dup 2) (match_dup 1)))
a238cd8b 6030 (set (match_dup 0) (minus:DI (match_dup 0) (match_dup 2)))]
266eb58a
DE
6031 "")
6032
ea112fc4 6033(define_insn_and_split "*nabsdi2"
266eb58a 6034 [(set (match_operand:DI 0 "gpc_reg_operand" "=&r,r")
ea112fc4 6035 (neg:DI (abs:DI (match_operand:DI 1 "gpc_reg_operand" "r,0"))))
266eb58a
DE
6036 (clobber (match_scratch:DI 2 "=&r,&r"))]
6037 "TARGET_POWERPC64"
ea112fc4
DE
6038 "#"
6039 "&& reload_completed"
a260abc9 6040 [(set (match_dup 2) (ashiftrt:DI (match_dup 1) (const_int 63)))
266eb58a 6041 (set (match_dup 0) (xor:DI (match_dup 2) (match_dup 1)))
19ba8161 6042 (set (match_dup 0) (minus:DI (match_dup 2) (match_dup 0)))]
266eb58a
DE
6043 "")
6044
6045(define_expand "negdi2"
6046 [(set (match_operand:DI 0 "gpc_reg_operand" "")
6047 (neg:DI (match_operand:DI 1 "gpc_reg_operand" "")))]
6048 ""
6049 "")
6050
6051(define_insn ""
6052 [(set (match_operand:DI 0 "gpc_reg_operand" "=r")
6053 (neg:DI (match_operand:DI 1 "gpc_reg_operand" "r")))]
6054 "TARGET_POWERPC64"
6055 "neg %0,%1")
6056
6057(define_insn ""
9ebbca7d
GK
6058 [(set (match_operand:CC 0 "cc_reg_operand" "=x,?y")
6059 (compare:CC (neg:DI (match_operand:DI 1 "gpc_reg_operand" "r,r"))
266eb58a 6060 (const_int 0)))
9ebbca7d 6061 (clobber (match_scratch:DI 2 "=r,r"))]
683bdff7 6062 "TARGET_64BIT"
9ebbca7d
GK
6063 "@
6064 neg. %2,%1
6065 #"
a62bfff2 6066 [(set_attr "type" "fast_compare")
9ebbca7d
GK
6067 (set_attr "length" "4,8")])
6068
6069(define_split
6070 [(set (match_operand:CC 0 "cc_reg_not_cr0_operand" "")
6071 (compare:CC (neg:DI (match_operand:DI 1 "gpc_reg_operand" ""))
6072 (const_int 0)))
6073 (clobber (match_scratch:DI 2 ""))]
6074 "TARGET_POWERPC64 && reload_completed"
6075 [(set (match_dup 2)
6076 (neg:DI (match_dup 1)))
6077 (set (match_dup 0)
6078 (compare:CC (match_dup 2)
6079 (const_int 0)))]
6080 "")
815cdc52 6081
29ae5b89 6082(define_insn ""
9ebbca7d
GK
6083 [(set (match_operand:CC 2 "cc_reg_operand" "=x,?y")
6084 (compare:CC (neg:DI (match_operand:DI 1 "gpc_reg_operand" "r,r"))
815cdc52 6085 (const_int 0)))
9ebbca7d 6086 (set (match_operand:DI 0 "gpc_reg_operand" "=r,r")
815cdc52 6087 (neg:DI (match_dup 1)))]
683bdff7 6088 "TARGET_64BIT"
9ebbca7d
GK
6089 "@
6090 neg. %0,%1
6091 #"
a62bfff2 6092 [(set_attr "type" "fast_compare")
9ebbca7d
GK
6093 (set_attr "length" "4,8")])
6094
6095(define_split
6096 [(set (match_operand:CC 2 "cc_reg_not_cr0_operand" "")
6097 (compare:CC (neg:DI (match_operand:DI 1 "gpc_reg_operand" ""))
6098 (const_int 0)))
6099 (set (match_operand:DI 0 "gpc_reg_operand" "")
6100 (neg:DI (match_dup 1)))]
6101 "TARGET_POWERPC64 && reload_completed"
6102 [(set (match_dup 0)
6103 (neg:DI (match_dup 1)))
6104 (set (match_dup 2)
6105 (compare:CC (match_dup 0)
6106 (const_int 0)))]
6107 "")
266eb58a 6108
1b1edcfa
DE
6109(define_insn "clzdi2"
6110 [(set (match_operand:DI 0 "gpc_reg_operand" "=r")
6111 (clz:DI (match_operand:DI 1 "gpc_reg_operand" "r")))]
6112 "TARGET_POWERPC64"
6113 "cntlzd %0,%1")
6114
6115(define_expand "ctzdi2"
4977bab6 6116 [(set (match_dup 2)
1b1edcfa 6117 (neg:DI (match_operand:DI 1 "gpc_reg_operand" "r")))
6ae08853
AM
6118 (parallel [(set (match_dup 3) (and:DI (match_dup 1)
6119 (match_dup 2)))
1b1edcfa 6120 (clobber (scratch:CC))])
d865b122 6121 (set (match_dup 4) (clz:DI (match_dup 3)))
4977bab6 6122 (set (match_operand:DI 0 "gpc_reg_operand" "=r")
1b1edcfa 6123 (minus:DI (const_int 63) (match_dup 4)))]
266eb58a 6124 "TARGET_POWERPC64"
4977bab6 6125 {
6ae08853 6126 operands[2] = gen_reg_rtx (DImode);
4977bab6
ZW
6127 operands[3] = gen_reg_rtx (DImode);
6128 operands[4] = gen_reg_rtx (DImode);
6129 })
6130
1b1edcfa
DE
6131(define_expand "ffsdi2"
6132 [(set (match_dup 2)
6133 (neg:DI (match_operand:DI 1 "gpc_reg_operand" "r")))
6ae08853
AM
6134 (parallel [(set (match_dup 3) (and:DI (match_dup 1)
6135 (match_dup 2)))
1b1edcfa
DE
6136 (clobber (scratch:CC))])
6137 (set (match_dup 4) (clz:DI (match_dup 3)))
6138 (set (match_operand:DI 0 "gpc_reg_operand" "=r")
6139 (minus:DI (const_int 64) (match_dup 4)))]
4977bab6 6140 "TARGET_POWERPC64"
1b1edcfa 6141 {
6ae08853 6142 operands[2] = gen_reg_rtx (DImode);
1b1edcfa
DE
6143 operands[3] = gen_reg_rtx (DImode);
6144 operands[4] = gen_reg_rtx (DImode);
6145 })
266eb58a
DE
6146
6147(define_insn "muldi3"
6148 [(set (match_operand:DI 0 "gpc_reg_operand" "=r")
6149 (mult:DI (match_operand:DI 1 "gpc_reg_operand" "%r")
6150 (match_operand:DI 2 "gpc_reg_operand" "r")))]
6151 "TARGET_POWERPC64"
6152 "mulld %0,%1,%2"
3cb999d8 6153 [(set_attr "type" "lmul")])
266eb58a 6154
9259f3b0
DE
6155(define_insn "*muldi3_internal1"
6156 [(set (match_operand:CC 0 "cc_reg_operand" "=x,?y")
6157 (compare:CC (mult:DI (match_operand:DI 1 "gpc_reg_operand" "%r,r")
6158 (match_operand:DI 2 "gpc_reg_operand" "r,r"))
6159 (const_int 0)))
6160 (clobber (match_scratch:DI 3 "=r,r"))]
6161 "TARGET_POWERPC64"
6162 "@
6163 mulld. %3,%1,%2
6164 #"
6165 [(set_attr "type" "lmul_compare")
6166 (set_attr "length" "4,8")])
6167
6168(define_split
6169 [(set (match_operand:CC 0 "cc_reg_not_cr0_operand" "")
6170 (compare:CC (mult:DI (match_operand:DI 1 "gpc_reg_operand" "")
6171 (match_operand:DI 2 "gpc_reg_operand" ""))
6172 (const_int 0)))
6173 (clobber (match_scratch:DI 3 ""))]
6174 "TARGET_POWERPC64 && reload_completed"
6175 [(set (match_dup 3)
6176 (mult:DI (match_dup 1) (match_dup 2)))
6177 (set (match_dup 0)
6178 (compare:CC (match_dup 3)
6179 (const_int 0)))]
6180 "")
6181
6182(define_insn "*muldi3_internal2"
6183 [(set (match_operand:CC 3 "cc_reg_operand" "=x,?y")
6184 (compare:CC (mult:DI (match_operand:DI 1 "gpc_reg_operand" "%r,r")
6185 (match_operand:DI 2 "gpc_reg_operand" "r,r"))
6186 (const_int 0)))
6187 (set (match_operand:DI 0 "gpc_reg_operand" "=r,r")
6188 (mult:DI (match_dup 1) (match_dup 2)))]
6189 "TARGET_POWERPC64"
6190 "@
6191 mulld. %0,%1,%2
6192 #"
6193 [(set_attr "type" "lmul_compare")
6194 (set_attr "length" "4,8")])
6195
6196(define_split
6197 [(set (match_operand:CC 3 "cc_reg_not_cr0_operand" "")
6198 (compare:CC (mult:DI (match_operand:DI 1 "gpc_reg_operand" "")
6199 (match_operand:DI 2 "gpc_reg_operand" ""))
6200 (const_int 0)))
6201 (set (match_operand:DI 0 "gpc_reg_operand" "")
6202 (mult:DI (match_dup 1) (match_dup 2)))]
6203 "TARGET_POWERPC64 && reload_completed"
6204 [(set (match_dup 0)
6205 (mult:DI (match_dup 1) (match_dup 2)))
6206 (set (match_dup 3)
6207 (compare:CC (match_dup 0)
6208 (const_int 0)))]
6209 "")
6210
266eb58a
DE
6211(define_insn "smuldi3_highpart"
6212 [(set (match_operand:DI 0 "gpc_reg_operand" "=r")
6213 (truncate:DI
6214 (lshiftrt:TI (mult:TI (sign_extend:TI
6215 (match_operand:DI 1 "gpc_reg_operand" "%r"))
6216 (sign_extend:TI
6217 (match_operand:DI 2 "gpc_reg_operand" "r")))
6218 (const_int 64))))]
6219 "TARGET_POWERPC64"
6220 "mulhd %0,%1,%2"
3cb999d8 6221 [(set_attr "type" "lmul")])
266eb58a
DE
6222
6223(define_insn "umuldi3_highpart"
6224 [(set (match_operand:DI 0 "gpc_reg_operand" "=r")
6225 (truncate:DI
6226 (lshiftrt:TI (mult:TI (zero_extend:TI
6227 (match_operand:DI 1 "gpc_reg_operand" "%r"))
6228 (zero_extend:TI
6229 (match_operand:DI 2 "gpc_reg_operand" "r")))
6230 (const_int 64))))]
6231 "TARGET_POWERPC64"
6232 "mulhdu %0,%1,%2"
3cb999d8 6233 [(set_attr "type" "lmul")])
266eb58a
DE
6234
6235(define_expand "divdi3"
6236 [(set (match_operand:DI 0 "gpc_reg_operand" "")
6237 (div:DI (match_operand:DI 1 "gpc_reg_operand" "")
6238 (match_operand:DI 2 "reg_or_cint_operand" "")))]
6239 "TARGET_POWERPC64"
6240 "
6241{
6242 if (GET_CODE (operands[2]) == CONST_INT
2bfcf297 6243 && INTVAL (operands[2]) > 0
266eb58a
DE
6244 && exact_log2 (INTVAL (operands[2])) >= 0)
6245 ;
6246 else
6247 operands[2] = force_reg (DImode, operands[2]);
6248}")
6249
6250(define_expand "moddi3"
6251 [(use (match_operand:DI 0 "gpc_reg_operand" ""))
6252 (use (match_operand:DI 1 "gpc_reg_operand" ""))
6253 (use (match_operand:DI 2 "reg_or_cint_operand" ""))]
6254 "TARGET_POWERPC64"
6255 "
6256{
2bfcf297 6257 int i;
266eb58a
DE
6258 rtx temp1;
6259 rtx temp2;
6260
2bfcf297
DB
6261 if (GET_CODE (operands[2]) != CONST_INT
6262 || INTVAL (operands[2]) <= 0
6263 || (i = exact_log2 (INTVAL (operands[2]))) < 0)
266eb58a
DE
6264 FAIL;
6265
6266 temp1 = gen_reg_rtx (DImode);
6267 temp2 = gen_reg_rtx (DImode);
6268
6269 emit_insn (gen_divdi3 (temp1, operands[1], operands[2]));
6270 emit_insn (gen_ashldi3 (temp2, temp1, GEN_INT (i)));
6271 emit_insn (gen_subdi3 (operands[0], operands[1], temp2));
6272 DONE;
6273}")
6274
6275(define_insn ""
6276 [(set (match_operand:DI 0 "gpc_reg_operand" "=r")
6277 (div:DI (match_operand:DI 1 "gpc_reg_operand" "r")
2bfcf297
DB
6278 (match_operand:DI 2 "exact_log2_cint_operand" "N")))]
6279 "TARGET_POWERPC64"
266eb58a
DE
6280 "sradi %0,%1,%p2\;addze %0,%0"
6281 [(set_attr "length" "8")])
6282
6283(define_insn ""
9ebbca7d
GK
6284 [(set (match_operand:CC 0 "cc_reg_operand" "=x,?y")
6285 (compare:CC (div:DI (match_operand:DI 1 "gpc_reg_operand" "r,r")
2bfcf297 6286 (match_operand:DI 2 "exact_log2_cint_operand" "N,N"))
266eb58a 6287 (const_int 0)))
9ebbca7d 6288 (clobber (match_scratch:DI 3 "=r,r"))]
683bdff7 6289 "TARGET_64BIT"
9ebbca7d
GK
6290 "@
6291 sradi %3,%1,%p2\;addze. %3,%3
6292 #"
266eb58a 6293 [(set_attr "type" "compare")
9ebbca7d
GK
6294 (set_attr "length" "8,12")])
6295
6296(define_split
6297 [(set (match_operand:CC 0 "cc_reg_not_cr0_operand" "")
6298 (compare:CC (div:DI (match_operand:DI 1 "gpc_reg_operand" "")
2bfcf297 6299 (match_operand:DI 2 "exact_log2_cint_operand" ""))
9ebbca7d
GK
6300 (const_int 0)))
6301 (clobber (match_scratch:DI 3 ""))]
2bfcf297 6302 "TARGET_POWERPC64 && reload_completed"
9ebbca7d
GK
6303 [(set (match_dup 3)
6304 (div:DI (match_dup 1) (match_dup 2)))
6305 (set (match_dup 0)
6306 (compare:CC (match_dup 3)
6307 (const_int 0)))]
6308 "")
266eb58a
DE
6309
6310(define_insn ""
9ebbca7d
GK
6311 [(set (match_operand:CC 3 "cc_reg_operand" "=x,?y")
6312 (compare:CC (div:DI (match_operand:DI 1 "gpc_reg_operand" "r,r")
2bfcf297 6313 (match_operand:DI 2 "exact_log2_cint_operand" "N,N"))
266eb58a 6314 (const_int 0)))
9ebbca7d 6315 (set (match_operand:DI 0 "gpc_reg_operand" "=r,r")
266eb58a 6316 (div:DI (match_dup 1) (match_dup 2)))]
683bdff7 6317 "TARGET_64BIT"
9ebbca7d
GK
6318 "@
6319 sradi %0,%1,%p2\;addze. %0,%0
6320 #"
266eb58a 6321 [(set_attr "type" "compare")
9ebbca7d 6322 (set_attr "length" "8,12")])
266eb58a 6323
9ebbca7d
GK
6324(define_split
6325 [(set (match_operand:CC 3 "cc_reg_not_cr0_operand" "")
6326 (compare:CC (div:DI (match_operand:DI 1 "gpc_reg_operand" "")
2bfcf297 6327 (match_operand:DI 2 "exact_log2_cint_operand" ""))
9ebbca7d
GK
6328 (const_int 0)))
6329 (set (match_operand:DI 0 "gpc_reg_operand" "")
6330 (div:DI (match_dup 1) (match_dup 2)))]
2bfcf297 6331 "TARGET_POWERPC64 && reload_completed"
9ebbca7d
GK
6332 [(set (match_dup 0)
6333 (div:DI (match_dup 1) (match_dup 2)))
6334 (set (match_dup 3)
6335 (compare:CC (match_dup 0)
6336 (const_int 0)))]
6337 "")
6338
6339(define_insn ""
6340 [(set (match_operand:DI 0 "gpc_reg_operand" "=r")
266eb58a 6341 (div:DI (match_operand:DI 1 "gpc_reg_operand" "r")
a260abc9 6342 (match_operand:DI 2 "gpc_reg_operand" "r")))]
266eb58a
DE
6343 "TARGET_POWERPC64"
6344 "divd %0,%1,%2"
3cb999d8 6345 [(set_attr "type" "ldiv")])
266eb58a
DE
6346
6347(define_insn "udivdi3"
6348 [(set (match_operand:DI 0 "gpc_reg_operand" "=r")
6349 (udiv:DI (match_operand:DI 1 "gpc_reg_operand" "r")
6350 (match_operand:DI 2 "gpc_reg_operand" "r")))]
6351 "TARGET_POWERPC64"
6352 "divdu %0,%1,%2"
3cb999d8 6353 [(set_attr "type" "ldiv")])
266eb58a
DE
6354
6355(define_insn "rotldi3"
6356 [(set (match_operand:DI 0 "gpc_reg_operand" "=r")
6357 (rotate:DI (match_operand:DI 1 "gpc_reg_operand" "r")
6358 (match_operand:DI 2 "reg_or_cint_operand" "ri")))]
6359 "TARGET_POWERPC64"
a66078ee 6360 "rld%I2cl %0,%1,%H2,0")
266eb58a 6361
a260abc9 6362(define_insn "*rotldi3_internal2"
9ebbca7d
GK
6363 [(set (match_operand:CC 0 "cc_reg_operand" "=x,?y")
6364 (compare:CC (rotate:DI (match_operand:DI 1 "gpc_reg_operand" "r,r")
6365 (match_operand:DI 2 "reg_or_cint_operand" "ri,ri"))
266eb58a 6366 (const_int 0)))
9ebbca7d 6367 (clobber (match_scratch:DI 3 "=r,r"))]
683bdff7 6368 "TARGET_64BIT"
9ebbca7d
GK
6369 "@
6370 rld%I2cl. %3,%1,%H2,0
6371 #"
6372 [(set_attr "type" "delayed_compare")
6373 (set_attr "length" "4,8")])
6374
6375(define_split
6376 [(set (match_operand:CC 0 "cc_reg_not_cr0_operand" "")
6377 (compare:CC (rotate:DI (match_operand:DI 1 "gpc_reg_operand" "")
6378 (match_operand:DI 2 "reg_or_cint_operand" ""))
6379 (const_int 0)))
6380 (clobber (match_scratch:DI 3 ""))]
6381 "TARGET_POWERPC64 && reload_completed"
6382 [(set (match_dup 3)
6383 (rotate:DI (match_dup 1) (match_dup 2)))
6384 (set (match_dup 0)
6385 (compare:CC (match_dup 3)
6386 (const_int 0)))]
6387 "")
266eb58a 6388
a260abc9 6389(define_insn "*rotldi3_internal3"
9ebbca7d
GK
6390 [(set (match_operand:CC 3 "cc_reg_operand" "=x,?y")
6391 (compare:CC (rotate:DI (match_operand:DI 1 "gpc_reg_operand" "r,r")
6392 (match_operand:DI 2 "reg_or_cint_operand" "ri,ri"))
266eb58a 6393 (const_int 0)))
9ebbca7d 6394 (set (match_operand:DI 0 "gpc_reg_operand" "=r,r")
266eb58a 6395 (rotate:DI (match_dup 1) (match_dup 2)))]
683bdff7 6396 "TARGET_64BIT"
9ebbca7d
GK
6397 "@
6398 rld%I2cl. %0,%1,%H2,0
6399 #"
6400 [(set_attr "type" "delayed_compare")
6401 (set_attr "length" "4,8")])
6402
6403(define_split
6404 [(set (match_operand:CC 3 "cc_reg_not_cr0_operand" "")
6405 (compare:CC (rotate:DI (match_operand:DI 1 "gpc_reg_operand" "")
6406 (match_operand:DI 2 "reg_or_cint_operand" ""))
6407 (const_int 0)))
6408 (set (match_operand:DI 0 "gpc_reg_operand" "")
6409 (rotate:DI (match_dup 1) (match_dup 2)))]
6410 "TARGET_POWERPC64 && reload_completed"
6411 [(set (match_dup 0)
6412 (rotate:DI (match_dup 1) (match_dup 2)))
6413 (set (match_dup 3)
6414 (compare:CC (match_dup 0)
6415 (const_int 0)))]
6416 "")
266eb58a 6417
a260abc9
DE
6418(define_insn "*rotldi3_internal4"
6419 [(set (match_operand:DI 0 "gpc_reg_operand" "=r")
6420 (and:DI (rotate:DI (match_operand:DI 1 "gpc_reg_operand" "r")
6421 (match_operand:DI 2 "reg_or_cint_operand" "ri"))
ce71f754 6422 (match_operand:DI 3 "mask64_operand" "n")))]
a260abc9
DE
6423 "TARGET_POWERPC64"
6424 "rld%I2c%B3 %0,%1,%H2,%S3")
6425
6426(define_insn "*rotldi3_internal5"
9ebbca7d 6427 [(set (match_operand:CC 0 "cc_reg_operand" "=x,?y")
a260abc9 6428 (compare:CC (and:DI
9ebbca7d
GK
6429 (rotate:DI (match_operand:DI 1 "gpc_reg_operand" "r,r")
6430 (match_operand:DI 2 "reg_or_cint_operand" "ri,ri"))
ce71f754 6431 (match_operand:DI 3 "mask64_operand" "n,n"))
a260abc9 6432 (const_int 0)))
9ebbca7d 6433 (clobber (match_scratch:DI 4 "=r,r"))]
683bdff7 6434 "TARGET_64BIT"
9ebbca7d
GK
6435 "@
6436 rld%I2c%B3. %4,%1,%H2,%S3
6437 #"
6438 [(set_attr "type" "delayed_compare")
6439 (set_attr "length" "4,8")])
6440
6441(define_split
6442 [(set (match_operand:CC 0 "cc_reg_not_cr0_operand" "")
6443 (compare:CC (and:DI
6444 (rotate:DI (match_operand:DI 1 "gpc_reg_operand" "")
6445 (match_operand:DI 2 "reg_or_cint_operand" ""))
6446 (match_operand:DI 3 "mask64_operand" ""))
6447 (const_int 0)))
6448 (clobber (match_scratch:DI 4 ""))]
6449 "TARGET_POWERPC64 && reload_completed"
6450 [(set (match_dup 4)
6451 (and:DI (rotate:DI (match_dup 1)
6452 (match_dup 2))
6453 (match_dup 3)))
6454 (set (match_dup 0)
6455 (compare:CC (match_dup 4)
6456 (const_int 0)))]
6457 "")
a260abc9
DE
6458
6459(define_insn "*rotldi3_internal6"
9ebbca7d 6460 [(set (match_operand:CC 4 "cc_reg_operand" "=x,?y")
a260abc9 6461 (compare:CC (and:DI
9ebbca7d
GK
6462 (rotate:DI (match_operand:DI 1 "gpc_reg_operand" "r,r")
6463 (match_operand:DI 2 "reg_or_cint_operand" "ri,ri"))
ce71f754 6464 (match_operand:DI 3 "mask64_operand" "n,n"))
a260abc9 6465 (const_int 0)))
9ebbca7d 6466 (set (match_operand:DI 0 "gpc_reg_operand" "=r,r")
a260abc9 6467 (and:DI (rotate:DI (match_dup 1) (match_dup 2)) (match_dup 3)))]
683bdff7 6468 "TARGET_64BIT"
9ebbca7d
GK
6469 "@
6470 rld%I2c%B3. %0,%1,%H2,%S3
6471 #"
6472 [(set_attr "type" "delayed_compare")
6473 (set_attr "length" "4,8")])
6474
6475(define_split
6476 [(set (match_operand:CC 4 "cc_reg_not_cr0_operand" "")
6477 (compare:CC (and:DI
6478 (rotate:DI (match_operand:DI 1 "gpc_reg_operand" "")
6479 (match_operand:DI 2 "reg_or_cint_operand" ""))
6480 (match_operand:DI 3 "mask64_operand" ""))
6481 (const_int 0)))
6482 (set (match_operand:DI 0 "gpc_reg_operand" "")
6483 (and:DI (rotate:DI (match_dup 1) (match_dup 2)) (match_dup 3)))]
6484 "TARGET_POWERPC64 && reload_completed"
6485 [(set (match_dup 0)
6486 (and:DI (rotate:DI (match_dup 1) (match_dup 2)) (match_dup 3)))
6487 (set (match_dup 4)
6488 (compare:CC (match_dup 0)
6489 (const_int 0)))]
6490 "")
a260abc9
DE
6491
6492(define_insn "*rotldi3_internal7"
6493 [(set (match_operand:DI 0 "gpc_reg_operand" "=r")
6494 (zero_extend:DI
6495 (subreg:QI
6496 (rotate:DI (match_operand:DI 1 "gpc_reg_operand" "r")
6497 (match_operand:DI 2 "reg_or_cint_operand" "ri")) 0)))]
6498 "TARGET_POWERPC64"
6499 "rld%I2cl %0,%1,%H2,56")
6500
6501(define_insn "*rotldi3_internal8"
9ebbca7d 6502 [(set (match_operand:CC 0 "cc_reg_operand" "=x,?y")
a260abc9
DE
6503 (compare:CC (zero_extend:DI
6504 (subreg:QI
9ebbca7d
GK
6505 (rotate:DI (match_operand:DI 1 "gpc_reg_operand" "r,r")
6506 (match_operand:DI 2 "reg_or_cint_operand" "ri,ri")) 0))
a260abc9 6507 (const_int 0)))
9ebbca7d 6508 (clobber (match_scratch:DI 3 "=r,r"))]
683bdff7 6509 "TARGET_64BIT"
9ebbca7d
GK
6510 "@
6511 rld%I2cl. %3,%1,%H2,56
6512 #"
6513 [(set_attr "type" "delayed_compare")
6514 (set_attr "length" "4,8")])
6515
6516(define_split
6517 [(set (match_operand:CC 0 "cc_reg_not_cr0_operand" "")
6518 (compare:CC (zero_extend:DI
6519 (subreg:QI
6520 (rotate:DI (match_operand:DI 1 "gpc_reg_operand" "")
6521 (match_operand:DI 2 "reg_or_cint_operand" "")) 0))
6522 (const_int 0)))
6523 (clobber (match_scratch:DI 3 ""))]
6524 "TARGET_POWERPC64 && reload_completed"
6525 [(set (match_dup 3)
6526 (zero_extend:DI (subreg:QI
6527 (rotate:DI (match_dup 1)
6528 (match_dup 2)) 0)))
6529 (set (match_dup 0)
6530 (compare:CC (match_dup 3)
6531 (const_int 0)))]
6532 "")
a260abc9
DE
6533
6534(define_insn "*rotldi3_internal9"
9ebbca7d 6535 [(set (match_operand:CC 3 "cc_reg_operand" "=x,?y")
a260abc9
DE
6536 (compare:CC (zero_extend:DI
6537 (subreg:QI
9ebbca7d
GK
6538 (rotate:DI (match_operand:DI 1 "gpc_reg_operand" "r,r")
6539 (match_operand:DI 2 "reg_or_cint_operand" "ri,ri")) 0))
a260abc9 6540 (const_int 0)))
9ebbca7d 6541 (set (match_operand:DI 0 "gpc_reg_operand" "=r,r")
a260abc9 6542 (zero_extend:DI (subreg:QI (rotate:DI (match_dup 1) (match_dup 2)) 0)))]
683bdff7 6543 "TARGET_64BIT"
9ebbca7d
GK
6544 "@
6545 rld%I2cl. %0,%1,%H2,56
6546 #"
6547 [(set_attr "type" "delayed_compare")
6548 (set_attr "length" "4,8")])
6549
6550(define_split
6551 [(set (match_operand:CC 3 "cc_reg_not_cr0_operand" "")
6552 (compare:CC (zero_extend:DI
6553 (subreg:QI
6554 (rotate:DI (match_operand:DI 1 "gpc_reg_operand" "")
6555 (match_operand:DI 2 "reg_or_cint_operand" "")) 0))
6556 (const_int 0)))
6557 (set (match_operand:DI 0 "gpc_reg_operand" "")
6558 (zero_extend:DI (subreg:QI (rotate:DI (match_dup 1) (match_dup 2)) 0)))]
6559 "TARGET_POWERPC64 && reload_completed"
6560 [(set (match_dup 0)
6561 (zero_extend:DI (subreg:QI (rotate:DI (match_dup 1) (match_dup 2)) 0)))
6562 (set (match_dup 3)
6563 (compare:CC (match_dup 0)
6564 (const_int 0)))]
6565 "")
a260abc9
DE
6566
6567(define_insn "*rotldi3_internal10"
6568 [(set (match_operand:DI 0 "gpc_reg_operand" "=r")
6569 (zero_extend:DI
6570 (subreg:HI
6571 (rotate:DI (match_operand:DI 1 "gpc_reg_operand" "r")
6572 (match_operand:DI 2 "reg_or_cint_operand" "ri")) 0)))]
6573 "TARGET_POWERPC64"
6574 "rld%I2cl %0,%1,%H2,48")
6575
6576(define_insn "*rotldi3_internal11"
9ebbca7d 6577 [(set (match_operand:CC 0 "cc_reg_operand" "=x,?y")
a260abc9
DE
6578 (compare:CC (zero_extend:DI
6579 (subreg:HI
9ebbca7d
GK
6580 (rotate:DI (match_operand:DI 1 "gpc_reg_operand" "r,r")
6581 (match_operand:DI 2 "reg_or_cint_operand" "ri,ri")) 0))
a260abc9 6582 (const_int 0)))
9ebbca7d 6583 (clobber (match_scratch:DI 3 "=r,r"))]
683bdff7 6584 "TARGET_64BIT"
9ebbca7d
GK
6585 "@
6586 rld%I2cl. %3,%1,%H2,48
6587 #"
6588 [(set_attr "type" "delayed_compare")
6589 (set_attr "length" "4,8")])
6590
6591(define_split
6592 [(set (match_operand:CC 0 "cc_reg_not_cr0_operand" "")
6593 (compare:CC (zero_extend:DI
6594 (subreg:HI
6595 (rotate:DI (match_operand:DI 1 "gpc_reg_operand" "")
6596 (match_operand:DI 2 "reg_or_cint_operand" "")) 0))
6597 (const_int 0)))
6598 (clobber (match_scratch:DI 3 ""))]
6599 "TARGET_POWERPC64 && reload_completed"
6600 [(set (match_dup 3)
6601 (zero_extend:DI (subreg:HI
6602 (rotate:DI (match_dup 1)
6603 (match_dup 2)) 0)))
6604 (set (match_dup 0)
6605 (compare:CC (match_dup 3)
6606 (const_int 0)))]
6607 "")
a260abc9
DE
6608
6609(define_insn "*rotldi3_internal12"
9ebbca7d 6610 [(set (match_operand:CC 3 "cc_reg_operand" "=x,?y")
a260abc9
DE
6611 (compare:CC (zero_extend:DI
6612 (subreg:HI
9ebbca7d
GK
6613 (rotate:DI (match_operand:DI 1 "gpc_reg_operand" "r,r")
6614 (match_operand:DI 2 "reg_or_cint_operand" "ri,ri")) 0))
a260abc9 6615 (const_int 0)))
9ebbca7d 6616 (set (match_operand:DI 0 "gpc_reg_operand" "=r,r")
a260abc9 6617 (zero_extend:DI (subreg:HI (rotate:DI (match_dup 1) (match_dup 2)) 0)))]
683bdff7 6618 "TARGET_64BIT"
9ebbca7d
GK
6619 "@
6620 rld%I2cl. %0,%1,%H2,48
6621 #"
6622 [(set_attr "type" "delayed_compare")
6623 (set_attr "length" "4,8")])
6624
6625(define_split
6626 [(set (match_operand:CC 3 "cc_reg_not_cr0_operand" "")
6627 (compare:CC (zero_extend:DI
6628 (subreg:HI
6629 (rotate:DI (match_operand:DI 1 "gpc_reg_operand" "")
6630 (match_operand:DI 2 "reg_or_cint_operand" "")) 0))
6631 (const_int 0)))
6632 (set (match_operand:DI 0 "gpc_reg_operand" "")
6633 (zero_extend:DI (subreg:HI (rotate:DI (match_dup 1) (match_dup 2)) 0)))]
6634 "TARGET_POWERPC64 && reload_completed"
6635 [(set (match_dup 0)
6636 (zero_extend:DI (subreg:HI (rotate:DI (match_dup 1) (match_dup 2)) 0)))
6637 (set (match_dup 3)
6638 (compare:CC (match_dup 0)
6639 (const_int 0)))]
6640 "")
a260abc9
DE
6641
6642(define_insn "*rotldi3_internal13"
6643 [(set (match_operand:DI 0 "gpc_reg_operand" "=r")
6644 (zero_extend:DI
6645 (subreg:SI
6646 (rotate:DI (match_operand:DI 1 "gpc_reg_operand" "r")
6647 (match_operand:DI 2 "reg_or_cint_operand" "ri")) 0)))]
6648 "TARGET_POWERPC64"
6649 "rld%I2cl %0,%1,%H2,32")
6650
6651(define_insn "*rotldi3_internal14"
9ebbca7d 6652 [(set (match_operand:CC 0 "cc_reg_operand" "=x,?y")
a260abc9
DE
6653 (compare:CC (zero_extend:DI
6654 (subreg:SI
9ebbca7d
GK
6655 (rotate:DI (match_operand:DI 1 "gpc_reg_operand" "r,r")
6656 (match_operand:DI 2 "reg_or_cint_operand" "ri,ri")) 0))
a260abc9 6657 (const_int 0)))
9ebbca7d 6658 (clobber (match_scratch:DI 3 "=r,r"))]
683bdff7 6659 "TARGET_64BIT"
9ebbca7d
GK
6660 "@
6661 rld%I2cl. %3,%1,%H2,32
6662 #"
6663 [(set_attr "type" "delayed_compare")
6664 (set_attr "length" "4,8")])
6665
6666(define_split
6667 [(set (match_operand:CC 0 "cc_reg_not_cr0_operand" "")
6668 (compare:CC (zero_extend:DI
6669 (subreg:SI
6670 (rotate:DI (match_operand:DI 1 "gpc_reg_operand" "")
6671 (match_operand:DI 2 "reg_or_cint_operand" "")) 0))
6672 (const_int 0)))
6673 (clobber (match_scratch:DI 3 ""))]
6674 "TARGET_POWERPC64 && reload_completed"
6675 [(set (match_dup 3)
6676 (zero_extend:DI (subreg:SI
6677 (rotate:DI (match_dup 1)
6678 (match_dup 2)) 0)))
6679 (set (match_dup 0)
6680 (compare:CC (match_dup 3)
6681 (const_int 0)))]
6682 "")
a260abc9
DE
6683
6684(define_insn "*rotldi3_internal15"
9ebbca7d 6685 [(set (match_operand:CC 3 "cc_reg_operand" "=x,?y")
a260abc9
DE
6686 (compare:CC (zero_extend:DI
6687 (subreg:SI
9ebbca7d
GK
6688 (rotate:DI (match_operand:DI 1 "gpc_reg_operand" "r,r")
6689 (match_operand:DI 2 "reg_or_cint_operand" "ri,ri")) 0))
a260abc9 6690 (const_int 0)))
9ebbca7d 6691 (set (match_operand:DI 0 "gpc_reg_operand" "=r,r")
a260abc9 6692 (zero_extend:DI (subreg:SI (rotate:DI (match_dup 1) (match_dup 2)) 0)))]
683bdff7 6693 "TARGET_64BIT"
9ebbca7d
GK
6694 "@
6695 rld%I2cl. %0,%1,%H2,32
6696 #"
6697 [(set_attr "type" "delayed_compare")
6698 (set_attr "length" "4,8")])
6699
6700(define_split
6701 [(set (match_operand:CC 3 "cc_reg_not_cr0_operand" "")
6702 (compare:CC (zero_extend:DI
6703 (subreg:SI
6704 (rotate:DI (match_operand:DI 1 "gpc_reg_operand" "")
6705 (match_operand:DI 2 "reg_or_cint_operand" "")) 0))
6706 (const_int 0)))
6707 (set (match_operand:DI 0 "gpc_reg_operand" "")
6708 (zero_extend:DI (subreg:SI (rotate:DI (match_dup 1) (match_dup 2)) 0)))]
6709 "TARGET_POWERPC64 && reload_completed"
6710 [(set (match_dup 0)
6711 (zero_extend:DI (subreg:SI (rotate:DI (match_dup 1) (match_dup 2)) 0)))
6712 (set (match_dup 3)
6713 (compare:CC (match_dup 0)
6714 (const_int 0)))]
6715 "")
a260abc9 6716
266eb58a
DE
6717(define_expand "ashldi3"
6718 [(set (match_operand:DI 0 "gpc_reg_operand" "")
6719 (ashift:DI (match_operand:DI 1 "gpc_reg_operand" "")
6720 (match_operand:SI 2 "reg_or_cint_operand" "")))]
6721 "TARGET_POWERPC64 || TARGET_POWER"
6722 "
6723{
6724 if (TARGET_POWERPC64)
6725 ;
6726 else if (TARGET_POWER)
6727 {
6728 emit_insn (gen_ashldi3_power (operands[0], operands[1], operands[2]));
6729 DONE;
6730 }
6731 else
6732 FAIL;
6733}")
6734
e2c953b6 6735(define_insn "*ashldi3_internal1"
266eb58a
DE
6736 [(set (match_operand:DI 0 "gpc_reg_operand" "=r")
6737 (ashift:DI (match_operand:DI 1 "gpc_reg_operand" "r")
6738 (match_operand:SI 2 "reg_or_cint_operand" "ri")))]
6739 "TARGET_POWERPC64"
a66078ee 6740 "sld%I2 %0,%1,%H2"
266eb58a 6741 [(set_attr "length" "8")])
6ae08853 6742
e2c953b6 6743(define_insn "*ashldi3_internal2"
9ebbca7d
GK
6744 [(set (match_operand:CC 0 "cc_reg_operand" "=x,?y")
6745 (compare:CC (ashift:DI (match_operand:DI 1 "gpc_reg_operand" "r,r")
6746 (match_operand:SI 2 "reg_or_cint_operand" "ri,ri"))
266eb58a 6747 (const_int 0)))
9ebbca7d 6748 (clobber (match_scratch:DI 3 "=r,r"))]
683bdff7 6749 "TARGET_64BIT"
9ebbca7d
GK
6750 "@
6751 sld%I2. %3,%1,%H2
6752 #"
6753 [(set_attr "type" "delayed_compare")
6754 (set_attr "length" "4,8")])
6ae08853 6755
9ebbca7d
GK
6756(define_split
6757 [(set (match_operand:CC 0 "cc_reg_not_cr0_operand" "")
6758 (compare:CC (ashift:DI (match_operand:DI 1 "gpc_reg_operand" "")
6759 (match_operand:SI 2 "reg_or_cint_operand" ""))
6760 (const_int 0)))
6761 (clobber (match_scratch:DI 3 ""))]
6762 "TARGET_POWERPC64 && reload_completed"
6763 [(set (match_dup 3)
6764 (ashift:DI (match_dup 1) (match_dup 2)))
6765 (set (match_dup 0)
6766 (compare:CC (match_dup 3)
6767 (const_int 0)))]
6768 "")
6769
e2c953b6 6770(define_insn "*ashldi3_internal3"
9ebbca7d
GK
6771 [(set (match_operand:CC 3 "cc_reg_operand" "=x,?y")
6772 (compare:CC (ashift:DI (match_operand:DI 1 "gpc_reg_operand" "r,r")
6773 (match_operand:SI 2 "reg_or_cint_operand" "ri,ri"))
266eb58a 6774 (const_int 0)))
9ebbca7d 6775 (set (match_operand:DI 0 "gpc_reg_operand" "=r,r")
266eb58a 6776 (ashift:DI (match_dup 1) (match_dup 2)))]
683bdff7 6777 "TARGET_64BIT"
9ebbca7d
GK
6778 "@
6779 sld%I2. %0,%1,%H2
6780 #"
6781 [(set_attr "type" "delayed_compare")
6782 (set_attr "length" "4,8")])
6783
6784(define_split
6785 [(set (match_operand:CC 3 "cc_reg_not_cr0_operand" "")
6786 (compare:CC (ashift:DI (match_operand:DI 1 "gpc_reg_operand" "")
6787 (match_operand:SI 2 "reg_or_cint_operand" ""))
6788 (const_int 0)))
6789 (set (match_operand:DI 0 "gpc_reg_operand" "")
6790 (ashift:DI (match_dup 1) (match_dup 2)))]
6791 "TARGET_POWERPC64 && reload_completed"
6792 [(set (match_dup 0)
6793 (ashift:DI (match_dup 1) (match_dup 2)))
6794 (set (match_dup 3)
6795 (compare:CC (match_dup 0)
6796 (const_int 0)))]
6797 "")
266eb58a 6798
e2c953b6 6799(define_insn "*ashldi3_internal4"
3cb999d8
DE
6800 [(set (match_operand:DI 0 "gpc_reg_operand" "=r")
6801 (and:DI (ashift:DI (match_operand:DI 1 "gpc_reg_operand" "r")
6802 (match_operand:SI 2 "const_int_operand" "i"))
c5059423
AM
6803 (match_operand:DI 3 "const_int_operand" "n")))]
6804 "TARGET_POWERPC64 && includes_rldic_lshift_p (operands[2], operands[3])"
e2c953b6 6805 "rldic %0,%1,%H2,%W3")
3cb999d8 6806
e2c953b6 6807(define_insn "ashldi3_internal5"
9ebbca7d 6808 [(set (match_operand:CC 0 "cc_reg_operand" "=x,?y")
3cb999d8 6809 (compare:CC
9ebbca7d
GK
6810 (and:DI (ashift:DI (match_operand:DI 1 "gpc_reg_operand" "r,r")
6811 (match_operand:SI 2 "const_int_operand" "i,i"))
c5059423 6812 (match_operand:DI 3 "const_int_operand" "n,n"))
3cb999d8 6813 (const_int 0)))
9ebbca7d 6814 (clobber (match_scratch:DI 4 "=r,r"))]
683bdff7 6815 "TARGET_64BIT && includes_rldic_lshift_p (operands[2], operands[3])"
9ebbca7d 6816 "@
e2c953b6 6817 rldic. %4,%1,%H2,%W3
9ebbca7d
GK
6818 #"
6819 [(set_attr "type" "delayed_compare")
6820 (set_attr "length" "4,8")])
6821
6822(define_split
6823 [(set (match_operand:CC 0 "cc_reg_not_cr0_operand" "")
6824 (compare:CC
6825 (and:DI (ashift:DI (match_operand:DI 1 "gpc_reg_operand" "")
6826 (match_operand:SI 2 "const_int_operand" ""))
c5059423 6827 (match_operand:DI 3 "const_int_operand" ""))
9ebbca7d
GK
6828 (const_int 0)))
6829 (clobber (match_scratch:DI 4 ""))]
c5059423
AM
6830 "TARGET_POWERPC64 && reload_completed
6831 && includes_rldic_lshift_p (operands[2], operands[3])"
9ebbca7d
GK
6832 [(set (match_dup 4)
6833 (and:DI (ashift:DI (match_dup 1) (match_dup 2))
e2c953b6 6834 (match_dup 3)))
9ebbca7d
GK
6835 (set (match_dup 0)
6836 (compare:CC (match_dup 4)
6837 (const_int 0)))]
6838 "")
3cb999d8 6839
e2c953b6 6840(define_insn "*ashldi3_internal6"
9ebbca7d 6841 [(set (match_operand:CC 4 "cc_reg_operand" "=x,?y")
3cb999d8 6842 (compare:CC
9ebbca7d
GK
6843 (and:DI (ashift:DI (match_operand:DI 1 "gpc_reg_operand" "r,r")
6844 (match_operand:SI 2 "const_int_operand" "i,i"))
c5059423 6845 (match_operand:DI 3 "const_int_operand" "n,n"))
3cb999d8 6846 (const_int 0)))
9ebbca7d 6847 (set (match_operand:DI 0 "gpc_reg_operand" "=r,r")
3cb999d8 6848 (and:DI (ashift:DI (match_dup 1) (match_dup 2)) (match_dup 3)))]
683bdff7 6849 "TARGET_64BIT && includes_rldic_lshift_p (operands[2], operands[3])"
9ebbca7d 6850 "@
e2c953b6 6851 rldic. %0,%1,%H2,%W3
9ebbca7d
GK
6852 #"
6853 [(set_attr "type" "delayed_compare")
6854 (set_attr "length" "4,8")])
6855
6856(define_split
6857 [(set (match_operand:CC 4 "cc_reg_not_cr0_operand" "")
6858 (compare:CC
6859 (and:DI (ashift:DI (match_operand:DI 1 "gpc_reg_operand" "")
6860 (match_operand:SI 2 "const_int_operand" ""))
c5059423 6861 (match_operand:DI 3 "const_int_operand" ""))
9ebbca7d
GK
6862 (const_int 0)))
6863 (set (match_operand:DI 0 "gpc_reg_operand" "")
6864 (and:DI (ashift:DI (match_dup 1) (match_dup 2)) (match_dup 3)))]
c5059423
AM
6865 "TARGET_POWERPC64 && reload_completed
6866 && includes_rldic_lshift_p (operands[2], operands[3])"
6867 [(set (match_dup 0)
6868 (and:DI (ashift:DI (match_dup 1) (match_dup 2))
6869 (match_dup 3)))
6870 (set (match_dup 4)
6871 (compare:CC (match_dup 0)
6872 (const_int 0)))]
6873 "")
6874
6875(define_insn "*ashldi3_internal7"
6876 [(set (match_operand:DI 0 "gpc_reg_operand" "=r")
6877 (and:DI (ashift:DI (match_operand:DI 1 "gpc_reg_operand" "r")
6878 (match_operand:SI 2 "const_int_operand" "i"))
ce71f754 6879 (match_operand:DI 3 "mask64_operand" "n")))]
c5059423
AM
6880 "TARGET_POWERPC64 && includes_rldicr_lshift_p (operands[2], operands[3])"
6881 "rldicr %0,%1,%H2,%S3")
6882
6883(define_insn "ashldi3_internal8"
6884 [(set (match_operand:CC 0 "cc_reg_operand" "=x,?y")
6885 (compare:CC
6886 (and:DI (ashift:DI (match_operand:DI 1 "gpc_reg_operand" "r,r")
6887 (match_operand:SI 2 "const_int_operand" "i,i"))
ce71f754 6888 (match_operand:DI 3 "mask64_operand" "n,n"))
c5059423
AM
6889 (const_int 0)))
6890 (clobber (match_scratch:DI 4 "=r,r"))]
683bdff7 6891 "TARGET_64BIT && includes_rldicr_lshift_p (operands[2], operands[3])"
c5059423
AM
6892 "@
6893 rldicr. %4,%1,%H2,%S3
6894 #"
6895 [(set_attr "type" "delayed_compare")
6896 (set_attr "length" "4,8")])
6897
6898(define_split
6899 [(set (match_operand:CC 0 "cc_reg_not_cr0_operand" "")
6900 (compare:CC
6901 (and:DI (ashift:DI (match_operand:DI 1 "gpc_reg_operand" "")
6902 (match_operand:SI 2 "const_int_operand" ""))
6903 (match_operand:DI 3 "mask64_operand" ""))
6904 (const_int 0)))
6905 (clobber (match_scratch:DI 4 ""))]
6906 "TARGET_POWERPC64 && reload_completed
6907 && includes_rldicr_lshift_p (operands[2], operands[3])"
6908 [(set (match_dup 4)
6909 (and:DI (ashift:DI (match_dup 1) (match_dup 2))
6910 (match_dup 3)))
6911 (set (match_dup 0)
6912 (compare:CC (match_dup 4)
6913 (const_int 0)))]
6914 "")
6915
6916(define_insn "*ashldi3_internal9"
6917 [(set (match_operand:CC 4 "cc_reg_operand" "=x,?y")
6918 (compare:CC
6919 (and:DI (ashift:DI (match_operand:DI 1 "gpc_reg_operand" "r,r")
6920 (match_operand:SI 2 "const_int_operand" "i,i"))
ce71f754 6921 (match_operand:DI 3 "mask64_operand" "n,n"))
c5059423
AM
6922 (const_int 0)))
6923 (set (match_operand:DI 0 "gpc_reg_operand" "=r,r")
6924 (and:DI (ashift:DI (match_dup 1) (match_dup 2)) (match_dup 3)))]
683bdff7 6925 "TARGET_64BIT && includes_rldicr_lshift_p (operands[2], operands[3])"
c5059423
AM
6926 "@
6927 rldicr. %0,%1,%H2,%S3
6928 #"
6929 [(set_attr "type" "delayed_compare")
6930 (set_attr "length" "4,8")])
6931
6932(define_split
6933 [(set (match_operand:CC 4 "cc_reg_not_cr0_operand" "")
6934 (compare:CC
6935 (and:DI (ashift:DI (match_operand:DI 1 "gpc_reg_operand" "")
6936 (match_operand:SI 2 "const_int_operand" ""))
6937 (match_operand:DI 3 "mask64_operand" ""))
6938 (const_int 0)))
6939 (set (match_operand:DI 0 "gpc_reg_operand" "")
6940 (and:DI (ashift:DI (match_dup 1) (match_dup 2)) (match_dup 3)))]
6941 "TARGET_POWERPC64 && reload_completed
6942 && includes_rldicr_lshift_p (operands[2], operands[3])"
9ebbca7d 6943 [(set (match_dup 0)
e2c953b6
DE
6944 (and:DI (ashift:DI (match_dup 1) (match_dup 2))
6945 (match_dup 3)))
9ebbca7d
GK
6946 (set (match_dup 4)
6947 (compare:CC (match_dup 0)
6948 (const_int 0)))]
6949 "")
6950
6951(define_expand "lshrdi3"
266eb58a
DE
6952 [(set (match_operand:DI 0 "gpc_reg_operand" "")
6953 (lshiftrt:DI (match_operand:DI 1 "gpc_reg_operand" "")
6954 (match_operand:SI 2 "reg_or_cint_operand" "")))]
6955 "TARGET_POWERPC64 || TARGET_POWER"
6956 "
6957{
6958 if (TARGET_POWERPC64)
6959 ;
6960 else if (TARGET_POWER)
6961 {
6962 emit_insn (gen_lshrdi3_power (operands[0], operands[1], operands[2]));
6963 DONE;
6964 }
6965 else
6966 FAIL;
6967}")
6968
e2c953b6 6969(define_insn "*lshrdi3_internal1"
266eb58a
DE
6970 [(set (match_operand:DI 0 "gpc_reg_operand" "=r")
6971 (lshiftrt:DI (match_operand:DI 1 "gpc_reg_operand" "r")
6972 (match_operand:SI 2 "reg_or_cint_operand" "ri")))]
6973 "TARGET_POWERPC64"
a66078ee 6974 "srd%I2 %0,%1,%H2")
266eb58a 6975
e2c953b6 6976(define_insn "*lshrdi3_internal2"
9ebbca7d
GK
6977 [(set (match_operand:CC 0 "cc_reg_operand" "=x,?y")
6978 (compare:CC (lshiftrt:DI (match_operand:DI 1 "gpc_reg_operand" "r,r")
6979 (match_operand:SI 2 "reg_or_cint_operand" "ri,ri"))
29ae5b89 6980 (const_int 0)))
9ebbca7d 6981 (clobber (match_scratch:DI 3 "=r,r"))]
683bdff7 6982 "TARGET_64BIT "
9ebbca7d
GK
6983 "@
6984 srd%I2. %3,%1,%H2
6985 #"
6986 [(set_attr "type" "delayed_compare")
6987 (set_attr "length" "4,8")])
6988
6989(define_split
6990 [(set (match_operand:CC 0 "cc_reg_not_cr0_operand" "")
6991 (compare:CC (lshiftrt:DI (match_operand:DI 1 "gpc_reg_operand" "")
6992 (match_operand:SI 2 "reg_or_cint_operand" ""))
6993 (const_int 0)))
6994 (clobber (match_scratch:DI 3 ""))]
6995 "TARGET_POWERPC64 && reload_completed"
6996 [(set (match_dup 3)
6997 (lshiftrt:DI (match_dup 1) (match_dup 2)))
6998 (set (match_dup 0)
6999 (compare:CC (match_dup 3)
7000 (const_int 0)))]
7001 "")
266eb58a 7002
e2c953b6 7003(define_insn "*lshrdi3_internal3"
9ebbca7d
GK
7004 [(set (match_operand:CC 3 "cc_reg_operand" "=x,?y")
7005 (compare:CC (lshiftrt:DI (match_operand:DI 1 "gpc_reg_operand" "r,r")
7006 (match_operand:SI 2 "reg_or_cint_operand" "ri,ri"))
266eb58a 7007 (const_int 0)))
9ebbca7d 7008 (set (match_operand:DI 0 "gpc_reg_operand" "=r,r")
29ae5b89 7009 (lshiftrt:DI (match_dup 1) (match_dup 2)))]
683bdff7 7010 "TARGET_64BIT"
9ebbca7d
GK
7011 "@
7012 srd%I2. %0,%1,%H2
7013 #"
7014 [(set_attr "type" "delayed_compare")
7015 (set_attr "length" "4,8")])
7016
7017(define_split
7018 [(set (match_operand:CC 3 "cc_reg_not_cr0_operand" "")
7019 (compare:CC (lshiftrt:DI (match_operand:DI 1 "gpc_reg_operand" "")
7020 (match_operand:SI 2 "reg_or_cint_operand" ""))
7021 (const_int 0)))
7022 (set (match_operand:DI 0 "gpc_reg_operand" "")
7023 (lshiftrt:DI (match_dup 1) (match_dup 2)))]
7024 "TARGET_POWERPC64 && reload_completed"
7025 [(set (match_dup 0)
7026 (lshiftrt:DI (match_dup 1) (match_dup 2)))
7027 (set (match_dup 3)
7028 (compare:CC (match_dup 0)
7029 (const_int 0)))]
7030 "")
266eb58a
DE
7031
7032(define_expand "ashrdi3"
7033 [(set (match_operand:DI 0 "gpc_reg_operand" "")
7034 (ashiftrt:DI (match_operand:DI 1 "gpc_reg_operand" "")
7035 (match_operand:SI 2 "reg_or_cint_operand" "")))]
97727e85 7036 "WORDS_BIG_ENDIAN"
266eb58a
DE
7037 "
7038{
7039 if (TARGET_POWERPC64)
7040 ;
7041 else if (TARGET_POWER && GET_CODE (operands[2]) == CONST_INT)
7042 {
7043 emit_insn (gen_ashrdi3_power (operands[0], operands[1], operands[2]));
7044 DONE;
7045 }
97727e85
AH
7046 else if (TARGET_32BIT && GET_CODE (operands[2]) == CONST_INT
7047 && WORDS_BIG_ENDIAN)
4aa74a4f
FS
7048 {
7049 emit_insn (gen_ashrdi3_no_power (operands[0], operands[1], operands[2]));
7050 DONE;
7051 }
266eb58a
DE
7052 else
7053 FAIL;
7054}")
7055
e2c953b6 7056(define_insn "*ashrdi3_internal1"
266eb58a
DE
7057 [(set (match_operand:DI 0 "gpc_reg_operand" "=r")
7058 (ashiftrt:DI (match_operand:DI 1 "gpc_reg_operand" "r")
7059 (match_operand:SI 2 "reg_or_cint_operand" "ri")))]
7060 "TARGET_POWERPC64"
375490e0 7061 "srad%I2 %0,%1,%H2")
266eb58a 7062
e2c953b6 7063(define_insn "*ashrdi3_internal2"
9ebbca7d
GK
7064 [(set (match_operand:CC 0 "cc_reg_operand" "=x,?y")
7065 (compare:CC (ashiftrt:DI (match_operand:DI 1 "gpc_reg_operand" "r,r")
7066 (match_operand:SI 2 "reg_or_cint_operand" "ri,ri"))
266eb58a 7067 (const_int 0)))
9ebbca7d 7068 (clobber (match_scratch:DI 3 "=r,r"))]
683bdff7 7069 "TARGET_64BIT"
9ebbca7d
GK
7070 "@
7071 srad%I2. %3,%1,%H2
7072 #"
7073 [(set_attr "type" "delayed_compare")
7074 (set_attr "length" "4,8")])
7075
7076(define_split
7077 [(set (match_operand:CC 0 "cc_reg_not_cr0_operand" "")
7078 (compare:CC (ashiftrt:DI (match_operand:DI 1 "gpc_reg_operand" "")
7079 (match_operand:SI 2 "reg_or_cint_operand" ""))
7080 (const_int 0)))
7081 (clobber (match_scratch:DI 3 ""))]
7082 "TARGET_POWERPC64 && reload_completed"
7083 [(set (match_dup 3)
7084 (ashiftrt:DI (match_dup 1) (match_dup 2)))
7085 (set (match_dup 0)
7086 (compare:CC (match_dup 3)
7087 (const_int 0)))]
7088 "")
266eb58a 7089
e2c953b6 7090(define_insn "*ashrdi3_internal3"
9ebbca7d
GK
7091 [(set (match_operand:CC 3 "cc_reg_operand" "=x,?y")
7092 (compare:CC (ashiftrt:DI (match_operand:DI 1 "gpc_reg_operand" "r,r")
7093 (match_operand:SI 2 "reg_or_cint_operand" "ri,ri"))
266eb58a 7094 (const_int 0)))
9ebbca7d 7095 (set (match_operand:DI 0 "gpc_reg_operand" "=r,r")
266eb58a 7096 (ashiftrt:DI (match_dup 1) (match_dup 2)))]
683bdff7 7097 "TARGET_64BIT"
9ebbca7d
GK
7098 "@
7099 srad%I2. %0,%1,%H2
7100 #"
7101 [(set_attr "type" "delayed_compare")
7102 (set_attr "length" "4,8")])
7103
7104(define_split
7105 [(set (match_operand:CC 3 "cc_reg_not_cr0_operand" "")
7106 (compare:CC (ashiftrt:DI (match_operand:DI 1 "gpc_reg_operand" "")
7107 (match_operand:SI 2 "reg_or_cint_operand" ""))
7108 (const_int 0)))
7109 (set (match_operand:DI 0 "gpc_reg_operand" "")
7110 (ashiftrt:DI (match_dup 1) (match_dup 2)))]
7111 "TARGET_POWERPC64 && reload_completed"
7112 [(set (match_dup 0)
7113 (ashiftrt:DI (match_dup 1) (match_dup 2)))
7114 (set (match_dup 3)
7115 (compare:CC (match_dup 0)
7116 (const_int 0)))]
7117 "")
815cdc52 7118
29ae5b89 7119(define_insn "anddi3"
0ba1b2ff
AM
7120 [(set (match_operand:DI 0 "gpc_reg_operand" "=r,r,r,r,r")
7121 (and:DI (match_operand:DI 1 "gpc_reg_operand" "%r,r,r,r,r")
7122 (match_operand:DI 2 "and64_2_operand" "?r,S,K,J,t")))
7123 (clobber (match_scratch:CC 3 "=X,X,x,x,X"))]
6ffc8580 7124 "TARGET_POWERPC64"
266eb58a
DE
7125 "@
7126 and %0,%1,%2
29ae5b89
JL
7127 rldic%B2 %0,%1,0,%S2
7128 andi. %0,%1,%b2
0ba1b2ff
AM
7129 andis. %0,%1,%u2
7130 #"
7131 [(set_attr "length" "4,4,4,4,8")])
7132
7133(define_split
7134 [(set (match_operand:DI 0 "gpc_reg_operand" "")
7135 (and:DI (match_operand:DI 1 "gpc_reg_operand" "")
7136 (match_operand:DI 2 "mask64_2_operand" "")))
7137 (clobber (match_scratch:CC 3 ""))]
7138 "TARGET_POWERPC64
7139 && (fixed_regs[CR0_REGNO] || !logical_operand (operands[2], DImode))
7140 && !mask64_operand (operands[2], DImode)"
7141 [(set (match_dup 0)
7142 (and:DI (rotate:DI (match_dup 1)
7143 (match_dup 4))
7144 (match_dup 5)))
7145 (set (match_dup 0)
7146 (and:DI (rotate:DI (match_dup 0)
7147 (match_dup 6))
7148 (match_dup 7)))]
7149 "
7150{
7151 build_mask64_2_operands (operands[2], &operands[4]);
7152}")
266eb58a 7153
a260abc9 7154(define_insn "*anddi3_internal2"
0ba1b2ff
AM
7155 [(set (match_operand:CC 0 "cc_reg_operand" "=x,x,x,x,x,?y,?y,??y,??y,?y")
7156 (compare:CC (and:DI (match_operand:DI 1 "gpc_reg_operand" "%r,r,r,r,r,r,r,r,r,r")
7157 (match_operand:DI 2 "and64_2_operand" "r,S,K,J,t,r,S,K,J,t"))
266eb58a 7158 (const_int 0)))
0ba1b2ff
AM
7159 (clobber (match_scratch:DI 3 "=r,r,r,r,r,r,r,r,r,r"))
7160 (clobber (match_scratch:CC 4 "=X,X,X,X,X,X,X,x,x,X"))]
683bdff7 7161 "TARGET_64BIT"
266eb58a
DE
7162 "@
7163 and. %3,%1,%2
6c873122 7164 rldic%B2. %3,%1,0,%S2
6ffc8580
MM
7165 andi. %3,%1,%b2
7166 andis. %3,%1,%u2
9ebbca7d
GK
7167 #
7168 #
7169 #
0ba1b2ff
AM
7170 #
7171 #
9ebbca7d 7172 #"
0ba1b2ff
AM
7173 [(set_attr "type" "compare,delayed_compare,compare,compare,delayed_compare,compare,compare,compare,compare,compare")
7174 (set_attr "length" "4,4,4,4,8,8,8,8,8,12")])
9ebbca7d
GK
7175
7176(define_split
7177 [(set (match_operand:CC 0 "cc_reg_not_cr0_operand" "")
7178 (compare:CC (and:DI (match_operand:DI 1 "gpc_reg_operand" "")
7179 (match_operand:DI 2 "and64_operand" ""))
7180 (const_int 0)))
7181 (clobber (match_scratch:DI 3 ""))
7182 (clobber (match_scratch:CC 4 ""))]
7183 "TARGET_POWERPC64 && reload_completed"
7184 [(parallel [(set (match_dup 3)
7185 (and:DI (match_dup 1)
7186 (match_dup 2)))
7187 (clobber (match_dup 4))])
7188 (set (match_dup 0)
7189 (compare:CC (match_dup 3)
7190 (const_int 0)))]
7191 "")
266eb58a 7192
0ba1b2ff
AM
7193(define_split
7194 [(set (match_operand:CC 0 "cc_reg_operand" "")
7195 (compare:CC (and:DI (match_operand:DI 1 "gpc_reg_operand" "")
7196 (match_operand:DI 2 "mask64_2_operand" ""))
7197 (const_int 0)))
7198 (clobber (match_scratch:DI 3 ""))
7199 (clobber (match_scratch:CC 4 ""))]
7200 "TARGET_POWERPC64 && reload_completed
7201 && (fixed_regs[CR0_REGNO] || !logical_operand (operands[2], DImode))
7202 && !mask64_operand (operands[2], DImode)"
7203 [(set (match_dup 3)
7204 (and:DI (rotate:DI (match_dup 1)
7205 (match_dup 5))
7206 (match_dup 6)))
7207 (parallel [(set (match_dup 0)
7208 (compare:CC (and:DI (rotate:DI (match_dup 3)
7209 (match_dup 7))
7210 (match_dup 8))
7211 (const_int 0)))
7212 (clobber (match_dup 3))])]
7213 "
7214{
7215 build_mask64_2_operands (operands[2], &operands[5]);
7216}")
7217
a260abc9 7218(define_insn "*anddi3_internal3"
0ba1b2ff
AM
7219 [(set (match_operand:CC 3 "cc_reg_operand" "=x,x,x,x,x,?y,?y,??y,??y,?y")
7220 (compare:CC (and:DI (match_operand:DI 1 "gpc_reg_operand" "%r,r,r,r,r,r,r,r,r,r")
7221 (match_operand:DI 2 "and64_2_operand" "r,S,K,J,t,r,S,K,J,t"))
266eb58a 7222 (const_int 0)))
0ba1b2ff 7223 (set (match_operand:DI 0 "gpc_reg_operand" "=r,r,r,r,r,r,r,r,r,r")
9ebbca7d 7224 (and:DI (match_dup 1) (match_dup 2)))
0ba1b2ff 7225 (clobber (match_scratch:CC 4 "=X,X,X,X,X,X,X,x,x,X"))]
683bdff7 7226 "TARGET_64BIT"
266eb58a
DE
7227 "@
7228 and. %0,%1,%2
6c873122 7229 rldic%B2. %0,%1,0,%S2
6ffc8580
MM
7230 andi. %0,%1,%b2
7231 andis. %0,%1,%u2
9ebbca7d
GK
7232 #
7233 #
7234 #
0ba1b2ff
AM
7235 #
7236 #
9ebbca7d 7237 #"
0ba1b2ff
AM
7238 [(set_attr "type" "compare,delayed_compare,compare,compare,delayed_compare,compare,compare,compare,compare,compare")
7239 (set_attr "length" "4,4,4,4,8,8,8,8,8,12")])
9ebbca7d
GK
7240
7241(define_split
7242 [(set (match_operand:CC 3 "cc_reg_not_cr0_operand" "")
7243 (compare:CC (and:DI (match_operand:DI 1 "gpc_reg_operand" "")
7244 (match_operand:DI 2 "and64_operand" ""))
7245 (const_int 0)))
7246 (set (match_operand:DI 0 "gpc_reg_operand" "")
7247 (and:DI (match_dup 1) (match_dup 2)))
7248 (clobber (match_scratch:CC 4 ""))]
7249 "TARGET_POWERPC64 && reload_completed"
7250 [(parallel [(set (match_dup 0)
7251 (and:DI (match_dup 1) (match_dup 2)))
7252 (clobber (match_dup 4))])
7253 (set (match_dup 3)
7254 (compare:CC (match_dup 0)
7255 (const_int 0)))]
7256 "")
266eb58a 7257
0ba1b2ff
AM
7258(define_split
7259 [(set (match_operand:CC 3 "cc_reg_operand" "")
7260 (compare:CC (and:DI (match_operand:DI 1 "gpc_reg_operand" "")
7261 (match_operand:DI 2 "mask64_2_operand" ""))
7262 (const_int 0)))
7263 (set (match_operand:DI 0 "gpc_reg_operand" "")
7264 (and:DI (match_dup 1) (match_dup 2)))
7265 (clobber (match_scratch:CC 4 ""))]
7266 "TARGET_POWERPC64 && reload_completed
7267 && (fixed_regs[CR0_REGNO] || !logical_operand (operands[2], DImode))
7268 && !mask64_operand (operands[2], DImode)"
7269 [(set (match_dup 0)
7270 (and:DI (rotate:DI (match_dup 1)
7271 (match_dup 5))
7272 (match_dup 6)))
7273 (parallel [(set (match_dup 3)
7274 (compare:CC (and:DI (rotate:DI (match_dup 0)
7275 (match_dup 7))
7276 (match_dup 8))
7277 (const_int 0)))
7278 (set (match_dup 0)
7279 (and:DI (rotate:DI (match_dup 0)
7280 (match_dup 7))
7281 (match_dup 8)))])]
7282 "
7283{
7284 build_mask64_2_operands (operands[2], &operands[5]);
7285}")
7286
a260abc9 7287(define_expand "iordi3"
266eb58a 7288 [(set (match_operand:DI 0 "gpc_reg_operand" "")
a260abc9 7289 (ior:DI (match_operand:DI 1 "gpc_reg_operand" "")
1d328b19 7290 (match_operand:DI 2 "reg_or_logical_cint_operand" "")))]
266eb58a 7291 "TARGET_POWERPC64"
266eb58a
DE
7292 "
7293{
dfbdccdb 7294 if (non_logical_cint_operand (operands[2], DImode))
266eb58a 7295 {
dfbdccdb 7296 HOST_WIDE_INT value;
677a9668 7297 rtx tmp = ((no_new_pseudos || rtx_equal_p (operands[0], operands[1]))
a260abc9 7298 ? operands[0] : gen_reg_rtx (DImode));
266eb58a 7299
dfbdccdb
GK
7300 if (GET_CODE (operands[2]) == CONST_INT)
7301 {
7302 value = INTVAL (operands[2]);
7303 emit_insn (gen_iordi3 (tmp, operands[1],
7304 GEN_INT (value & (~ (HOST_WIDE_INT) 0xffff))));
7305 }
e2c953b6 7306 else
dfbdccdb
GK
7307 {
7308 value = CONST_DOUBLE_LOW (operands[2]);
7309 emit_insn (gen_iordi3 (tmp, operands[1],
7310 immed_double_const (value
7311 & (~ (HOST_WIDE_INT) 0xffff),
7312 0, DImode)));
7313 }
e2c953b6 7314
9ebbca7d
GK
7315 emit_insn (gen_iordi3 (operands[0], tmp, GEN_INT (value & 0xffff)));
7316 DONE;
7317 }
266eb58a
DE
7318}")
7319
a260abc9
DE
7320(define_expand "xordi3"
7321 [(set (match_operand:DI 0 "gpc_reg_operand" "")
7322 (xor:DI (match_operand:DI 1 "gpc_reg_operand" "")
1d328b19 7323 (match_operand:DI 2 "reg_or_logical_cint_operand" "")))]
a260abc9
DE
7324 "TARGET_POWERPC64"
7325 "
7326{
dfbdccdb 7327 if (non_logical_cint_operand (operands[2], DImode))
a260abc9 7328 {
dfbdccdb 7329 HOST_WIDE_INT value;
677a9668 7330 rtx tmp = ((no_new_pseudos || rtx_equal_p (operands[0], operands[1]))
a260abc9
DE
7331 ? operands[0] : gen_reg_rtx (DImode));
7332
dfbdccdb
GK
7333 if (GET_CODE (operands[2]) == CONST_INT)
7334 {
7335 value = INTVAL (operands[2]);
7336 emit_insn (gen_xordi3 (tmp, operands[1],
7337 GEN_INT (value & (~ (HOST_WIDE_INT) 0xffff))));
7338 }
e2c953b6 7339 else
dfbdccdb
GK
7340 {
7341 value = CONST_DOUBLE_LOW (operands[2]);
7342 emit_insn (gen_xordi3 (tmp, operands[1],
7343 immed_double_const (value
7344 & (~ (HOST_WIDE_INT) 0xffff),
7345 0, DImode)));
7346 }
e2c953b6 7347
9ebbca7d
GK
7348 emit_insn (gen_xordi3 (operands[0], tmp, GEN_INT (value & 0xffff)));
7349 DONE;
7350 }
a260abc9
DE
7351}")
7352
dfbdccdb 7353(define_insn "*booldi3_internal1"
266eb58a 7354 [(set (match_operand:DI 0 "gpc_reg_operand" "=r,r,r")
1d328b19 7355 (match_operator:DI 3 "boolean_or_operator"
dfbdccdb
GK
7356 [(match_operand:DI 1 "gpc_reg_operand" "%r,r,r")
7357 (match_operand:DI 2 "logical_operand" "r,K,JF")]))]
266eb58a 7358 "TARGET_POWERPC64"
1fd4e8c1 7359 "@
dfbdccdb
GK
7360 %q3 %0,%1,%2
7361 %q3i %0,%1,%b2
7362 %q3is %0,%1,%u2")
1fd4e8c1 7363
dfbdccdb 7364(define_insn "*booldi3_internal2"
9ebbca7d 7365 [(set (match_operand:CC 0 "cc_reg_operand" "=x,?y")
1d328b19 7366 (compare:CC (match_operator:DI 4 "boolean_or_operator"
dfbdccdb
GK
7367 [(match_operand:DI 1 "gpc_reg_operand" "%r,r")
7368 (match_operand:DI 2 "gpc_reg_operand" "r,r")])
7369 (const_int 0)))
9ebbca7d 7370 (clobber (match_scratch:DI 3 "=r,r"))]
683bdff7 7371 "TARGET_64BIT"
9ebbca7d 7372 "@
dfbdccdb 7373 %q4. %3,%1,%2
9ebbca7d
GK
7374 #"
7375 [(set_attr "type" "compare")
7376 (set_attr "length" "4,8")])
7377
7378(define_split
7379 [(set (match_operand:CC 0 "cc_reg_not_cr0_operand" "")
dfbdccdb 7380 (compare:CC (match_operator:DI 4 "boolean_operator"
75540af0
JH
7381 [(match_operand:DI 1 "gpc_reg_operand" "")
7382 (match_operand:DI 2 "gpc_reg_operand" "")])
dfbdccdb 7383 (const_int 0)))
9ebbca7d
GK
7384 (clobber (match_scratch:DI 3 ""))]
7385 "TARGET_POWERPC64 && reload_completed"
dfbdccdb 7386 [(set (match_dup 3) (match_dup 4))
9ebbca7d
GK
7387 (set (match_dup 0)
7388 (compare:CC (match_dup 3)
7389 (const_int 0)))]
7390 "")
1fd4e8c1 7391
dfbdccdb 7392(define_insn "*booldi3_internal3"
9ebbca7d 7393 [(set (match_operand:CC 3 "cc_reg_operand" "=x,?y")
dfbdccdb
GK
7394 (compare:CC (match_operator:DI 4 "boolean_operator"
7395 [(match_operand:DI 1 "gpc_reg_operand" "%r,r")
7396 (match_operand:DI 2 "gpc_reg_operand" "r,r")])
7397 (const_int 0)))
9ebbca7d 7398 (set (match_operand:DI 0 "gpc_reg_operand" "=r,r")
dfbdccdb 7399 (match_dup 4))]
683bdff7 7400 "TARGET_64BIT"
9ebbca7d 7401 "@
dfbdccdb 7402 %q4. %0,%1,%2
9ebbca7d
GK
7403 #"
7404 [(set_attr "type" "compare")
7405 (set_attr "length" "4,8")])
7406
7407(define_split
e72247f4 7408 [(set (match_operand:CC 3 "cc_reg_not_cr0_operand" "")
dfbdccdb 7409 (compare:CC (match_operator:DI 4 "boolean_operator"
75540af0
JH
7410 [(match_operand:DI 1 "gpc_reg_operand" "")
7411 (match_operand:DI 2 "gpc_reg_operand" "")])
dfbdccdb 7412 (const_int 0)))
75540af0 7413 (set (match_operand:DI 0 "gpc_reg_operand" "")
dfbdccdb 7414 (match_dup 4))]
9ebbca7d 7415 "TARGET_POWERPC64 && reload_completed"
dfbdccdb 7416 [(set (match_dup 0) (match_dup 4))
9ebbca7d
GK
7417 (set (match_dup 3)
7418 (compare:CC (match_dup 0)
7419 (const_int 0)))]
7420 "")
1fd4e8c1 7421
6ae08853 7422;; Split a logical operation that we can't do in one insn into two insns,
dfbdccdb 7423;; each of which does one 16-bit part. This is used by combine.
266eb58a
DE
7424
7425(define_split
7426 [(set (match_operand:DI 0 "gpc_reg_operand" "")
1d328b19 7427 (match_operator:DI 3 "boolean_or_operator"
dfbdccdb
GK
7428 [(match_operand:DI 1 "gpc_reg_operand" "")
7429 (match_operand:DI 2 "non_logical_cint_operand" "")]))]
266eb58a 7430 "TARGET_POWERPC64"
dfbdccdb
GK
7431 [(set (match_dup 0) (match_dup 4))
7432 (set (match_dup 0) (match_dup 5))]
266eb58a
DE
7433"
7434{
dfbdccdb 7435 rtx i3,i4;
6ae08853 7436
9ebbca7d
GK
7437 if (GET_CODE (operands[2]) == CONST_DOUBLE)
7438 {
7439 HOST_WIDE_INT value = CONST_DOUBLE_LOW (operands[2]);
dfbdccdb 7440 i3 = immed_double_const (value & (~ (HOST_WIDE_INT) 0xffff),
9ebbca7d 7441 0, DImode);
dfbdccdb 7442 i4 = GEN_INT (value & 0xffff);
9ebbca7d
GK
7443 }
7444 else
7445 {
dfbdccdb 7446 i3 = GEN_INT (INTVAL (operands[2])
9ebbca7d 7447 & (~ (HOST_WIDE_INT) 0xffff));
dfbdccdb 7448 i4 = GEN_INT (INTVAL (operands[2]) & 0xffff);
9ebbca7d 7449 }
1c563bed 7450 operands[4] = gen_rtx_fmt_ee (GET_CODE (operands[3]), DImode,
0f4c242b 7451 operands[1], i3);
1c563bed 7452 operands[5] = gen_rtx_fmt_ee (GET_CODE (operands[3]), DImode,
0f4c242b 7453 operands[0], i4);
1fd4e8c1
RK
7454}")
7455
dfbdccdb 7456(define_insn "*boolcdi3_internal1"
9ebbca7d 7457 [(set (match_operand:DI 0 "gpc_reg_operand" "=r")
dfbdccdb
GK
7458 (match_operator:DI 3 "boolean_operator"
7459 [(not:DI (match_operand:DI 1 "gpc_reg_operand" "r"))
40501e5f 7460 (match_operand:DI 2 "gpc_reg_operand" "r")]))]
a473029f 7461 "TARGET_POWERPC64"
1d328b19 7462 "%q3 %0,%2,%1")
a473029f 7463
dfbdccdb 7464(define_insn "*boolcdi3_internal2"
9ebbca7d 7465 [(set (match_operand:CC 0 "cc_reg_operand" "=x,?y")
dfbdccdb
GK
7466 (compare:CC (match_operator:DI 4 "boolean_operator"
7467 [(not:DI (match_operand:DI 1 "gpc_reg_operand" "r,r"))
7468 (match_operand:DI 2 "gpc_reg_operand" "r,r")])
7469 (const_int 0)))
9ebbca7d 7470 (clobber (match_scratch:DI 3 "=r,r"))]
683bdff7 7471 "TARGET_64BIT"
9ebbca7d 7472 "@
1d328b19 7473 %q4. %3,%2,%1
9ebbca7d
GK
7474 #"
7475 [(set_attr "type" "compare")
7476 (set_attr "length" "4,8")])
7477
7478(define_split
7479 [(set (match_operand:CC 0 "cc_reg_not_cr0_operand" "")
dfbdccdb 7480 (compare:CC (match_operator:DI 4 "boolean_operator"
75540af0
JH
7481 [(not:DI (match_operand:DI 1 "gpc_reg_operand" ""))
7482 (match_operand:DI 2 "gpc_reg_operand" "")])
dfbdccdb 7483 (const_int 0)))
9ebbca7d
GK
7484 (clobber (match_scratch:DI 3 ""))]
7485 "TARGET_POWERPC64 && reload_completed"
dfbdccdb 7486 [(set (match_dup 3) (match_dup 4))
9ebbca7d
GK
7487 (set (match_dup 0)
7488 (compare:CC (match_dup 3)
7489 (const_int 0)))]
7490 "")
a473029f 7491
dfbdccdb 7492(define_insn "*boolcdi3_internal3"
9ebbca7d 7493 [(set (match_operand:CC 3 "cc_reg_operand" "=x,?y")
dfbdccdb
GK
7494 (compare:CC (match_operator:DI 4 "boolean_operator"
7495 [(not:DI (match_operand:DI 1 "gpc_reg_operand" "%r,r"))
7496 (match_operand:DI 2 "gpc_reg_operand" "r,r")])
7497 (const_int 0)))
9ebbca7d 7498 (set (match_operand:DI 0 "gpc_reg_operand" "=r,r")
dfbdccdb 7499 (match_dup 4))]
683bdff7 7500 "TARGET_64BIT"
9ebbca7d 7501 "@
1d328b19 7502 %q4. %0,%2,%1
9ebbca7d
GK
7503 #"
7504 [(set_attr "type" "compare")
7505 (set_attr "length" "4,8")])
7506
7507(define_split
e72247f4 7508 [(set (match_operand:CC 3 "cc_reg_not_cr0_operand" "")
dfbdccdb 7509 (compare:CC (match_operator:DI 4 "boolean_operator"
75540af0
JH
7510 [(not:DI (match_operand:DI 1 "gpc_reg_operand" ""))
7511 (match_operand:DI 2 "gpc_reg_operand" "")])
dfbdccdb 7512 (const_int 0)))
75540af0 7513 (set (match_operand:DI 0 "gpc_reg_operand" "")
dfbdccdb 7514 (match_dup 4))]
9ebbca7d 7515 "TARGET_POWERPC64 && reload_completed"
dfbdccdb 7516 [(set (match_dup 0) (match_dup 4))
9ebbca7d
GK
7517 (set (match_dup 3)
7518 (compare:CC (match_dup 0)
7519 (const_int 0)))]
7520 "")
266eb58a 7521
dfbdccdb 7522(define_insn "*boolccdi3_internal1"
a473029f 7523 [(set (match_operand:DI 0 "gpc_reg_operand" "=r")
dfbdccdb
GK
7524 (match_operator:DI 3 "boolean_operator"
7525 [(not:DI (match_operand:DI 1 "gpc_reg_operand" "r"))
40501e5f 7526 (not:DI (match_operand:DI 2 "gpc_reg_operand" "r"))]))]
a473029f 7527 "TARGET_POWERPC64"
dfbdccdb 7528 "%q3 %0,%1,%2")
a473029f 7529
dfbdccdb 7530(define_insn "*boolccdi3_internal2"
9ebbca7d 7531 [(set (match_operand:CC 0 "cc_reg_operand" "=x,?y")
dfbdccdb
GK
7532 (compare:CC (match_operator:DI 4 "boolean_operator"
7533 [(not:DI (match_operand:DI 1 "gpc_reg_operand" "r,r"))
7534 (not:DI (match_operand:DI 2 "gpc_reg_operand" "r,r"))])
7535 (const_int 0)))
9ebbca7d 7536 (clobber (match_scratch:DI 3 "=r,r"))]
683bdff7 7537 "TARGET_64BIT"
9ebbca7d 7538 "@
dfbdccdb 7539 %q4. %3,%1,%2
9ebbca7d
GK
7540 #"
7541 [(set_attr "type" "compare")
7542 (set_attr "length" "4,8")])
7543
7544(define_split
7545 [(set (match_operand:CC 0 "cc_reg_not_cr0_operand" "")
dfbdccdb 7546 (compare:CC (match_operator:DI 4 "boolean_operator"
75540af0
JH
7547 [(not:DI (match_operand:DI 1 "gpc_reg_operand" ""))
7548 (not:DI (match_operand:DI 2 "gpc_reg_operand" ""))])
dfbdccdb 7549 (const_int 0)))
9ebbca7d
GK
7550 (clobber (match_scratch:DI 3 ""))]
7551 "TARGET_POWERPC64 && reload_completed"
dfbdccdb 7552 [(set (match_dup 3) (match_dup 4))
9ebbca7d
GK
7553 (set (match_dup 0)
7554 (compare:CC (match_dup 3)
7555 (const_int 0)))]
7556 "")
266eb58a 7557
dfbdccdb 7558(define_insn "*boolccdi3_internal3"
9ebbca7d 7559 [(set (match_operand:CC 3 "cc_reg_operand" "=x,?y")
dfbdccdb
GK
7560 (compare:CC (match_operator:DI 4 "boolean_operator"
7561 [(not:DI (match_operand:DI 1 "gpc_reg_operand" "%r,r"))
7562 (not:DI (match_operand:DI 2 "gpc_reg_operand" "r,r"))])
7563 (const_int 0)))
9ebbca7d 7564 (set (match_operand:DI 0 "gpc_reg_operand" "=r,r")
dfbdccdb 7565 (match_dup 4))]
683bdff7 7566 "TARGET_64BIT"
9ebbca7d 7567 "@
dfbdccdb 7568 %q4. %0,%1,%2
9ebbca7d
GK
7569 #"
7570 [(set_attr "type" "compare")
7571 (set_attr "length" "4,8")])
7572
7573(define_split
e72247f4 7574 [(set (match_operand:CC 3 "cc_reg_not_cr0_operand" "")
dfbdccdb 7575 (compare:CC (match_operator:DI 4 "boolean_operator"
75540af0
JH
7576 [(not:DI (match_operand:DI 1 "gpc_reg_operand" ""))
7577 (not:DI (match_operand:DI 2 "gpc_reg_operand" ""))])
dfbdccdb 7578 (const_int 0)))
75540af0 7579 (set (match_operand:DI 0 "gpc_reg_operand" "")
dfbdccdb 7580 (match_dup 4))]
9ebbca7d 7581 "TARGET_POWERPC64 && reload_completed"
dfbdccdb 7582 [(set (match_dup 0) (match_dup 4))
9ebbca7d
GK
7583 (set (match_dup 3)
7584 (compare:CC (match_dup 0)
7585 (const_int 0)))]
7586 "")
dfbdccdb 7587\f
1fd4e8c1 7588;; Now define ways of moving data around.
4697a36c
MM
7589
7590;; Elf specific ways of loading addresses for non-PIC code.
9ebbca7d
GK
7591;; The output of this could be r0, but we make a very strong
7592;; preference for a base register because it will usually
7593;; be needed there.
4697a36c 7594(define_insn "elf_high"
9ebbca7d 7595 [(set (match_operand:SI 0 "gpc_reg_operand" "=b*r")
4697a36c 7596 (high:SI (match_operand 1 "" "")))]
0ad91047 7597 "TARGET_ELF && ! TARGET_64BIT"
a6c2a102 7598 "{liu|lis} %0,%1@ha")
4697a36c
MM
7599
7600(define_insn "elf_low"
9ebbca7d
GK
7601 [(set (match_operand:SI 0 "gpc_reg_operand" "=r,r")
7602 (lo_sum:SI (match_operand:SI 1 "gpc_reg_operand" "b,!*r")
4697a36c 7603 (match_operand 2 "" "")))]
0ad91047 7604 "TARGET_ELF && ! TARGET_64BIT"
9ebbca7d
GK
7605 "@
7606 {cal|la} %0,%2@l(%1)
81eace42 7607 {ai|addic} %0,%1,%K2")
4697a36c 7608
ee890fe2
SS
7609;; Mach-O PIC trickery.
7610(define_insn "macho_high"
7611 [(set (match_operand:SI 0 "gpc_reg_operand" "=b*r")
7612 (high:SI (match_operand 1 "" "")))]
7613 "TARGET_MACHO && ! TARGET_64BIT"
7614 "{liu|lis} %0,ha16(%1)")
7615
7616(define_insn "macho_low"
7617 [(set (match_operand:SI 0 "gpc_reg_operand" "=r,r")
7618 (lo_sum:SI (match_operand:SI 1 "gpc_reg_operand" "b,!*r")
7619 (match_operand 2 "" "")))]
7620 "TARGET_MACHO && ! TARGET_64BIT"
7621 "@
7622 {cal %0,%a2@l(%1)|la %0,lo16(%2)(%1)}
7623 {cal %0,%a2@l(%1)|addic %0,%1,lo16(%2)}")
7624
766a866c
MM
7625;; Set up a register with a value from the GOT table
7626
7627(define_expand "movsi_got"
52d3af72 7628 [(set (match_operand:SI 0 "gpc_reg_operand" "")
9ebbca7d 7629 (unspec:SI [(match_operand:SI 1 "got_operand" "")
615158e2 7630 (match_dup 2)] UNSPEC_MOVSI_GOT))]
f607bc57 7631 "DEFAULT_ABI == ABI_V4 && flag_pic == 1"
766a866c
MM
7632 "
7633{
38c1f2d7
MM
7634 if (GET_CODE (operands[1]) == CONST)
7635 {
7636 rtx offset = const0_rtx;
7637 HOST_WIDE_INT value;
7638
7639 operands[1] = eliminate_constant_term (XEXP (operands[1], 0), &offset);
7640 value = INTVAL (offset);
7641 if (value != 0)
7642 {
677a9668 7643 rtx tmp = (no_new_pseudos ? operands[0] : gen_reg_rtx (Pmode));
38c1f2d7
MM
7644 emit_insn (gen_movsi_got (tmp, operands[1]));
7645 emit_insn (gen_addsi3 (operands[0], tmp, offset));
7646 DONE;
7647 }
7648 }
7649
c4c40373 7650 operands[2] = rs6000_got_register (operands[1]);
766a866c
MM
7651}")
7652
84f414bc 7653(define_insn "*movsi_got_internal"
52d3af72 7654 [(set (match_operand:SI 0 "gpc_reg_operand" "=r")
9ebbca7d 7655 (unspec:SI [(match_operand:SI 1 "got_no_const_operand" "")
615158e2
JJ
7656 (match_operand:SI 2 "gpc_reg_operand" "b")]
7657 UNSPEC_MOVSI_GOT))]
f607bc57 7658 "DEFAULT_ABI == ABI_V4 && flag_pic == 1"
766a866c
MM
7659 "{l|lwz} %0,%a1@got(%2)"
7660 [(set_attr "type" "load")])
7661
b22b9b3e
JL
7662;; Used by sched, shorten_branches and final when the GOT pseudo reg
7663;; didn't get allocated to a hard register.
6ae08853 7664(define_split
75540af0 7665 [(set (match_operand:SI 0 "gpc_reg_operand" "")
9ebbca7d 7666 (unspec:SI [(match_operand:SI 1 "got_no_const_operand" "")
615158e2
JJ
7667 (match_operand:SI 2 "memory_operand" "")]
7668 UNSPEC_MOVSI_GOT))]
f607bc57 7669 "DEFAULT_ABI == ABI_V4
b22b9b3e
JL
7670 && flag_pic == 1
7671 && (reload_in_progress || reload_completed)"
7672 [(set (match_dup 0) (match_dup 2))
615158e2
JJ
7673 (set (match_dup 0) (unspec:SI [(match_dup 1)(match_dup 0)]
7674 UNSPEC_MOVSI_GOT))]
b22b9b3e
JL
7675 "")
7676
1fd4e8c1
RK
7677;; For SI, we special-case integers that can't be loaded in one insn. We
7678;; do the load 16-bits at a time. We could do this by loading from memory,
7679;; and this is even supposed to be faster, but it is simpler not to get
7680;; integers in the TOC.
7681(define_expand "movsi"
7682 [(set (match_operand:SI 0 "general_operand" "")
7683 (match_operand:SI 1 "any_operand" ""))]
7684 ""
fb4d4348 7685 "{ rs6000_emit_move (operands[0], operands[1], SImode); DONE; }")
1fd4e8c1 7686
ee890fe2
SS
7687(define_insn "movsi_low"
7688 [(set (match_operand:SI 0 "gpc_reg_operand" "=r")
f585a356 7689 (mem:SI (lo_sum:SI (match_operand:SI 1 "gpc_reg_operand" "b")
ee890fe2
SS
7690 (match_operand 2 "" ""))))]
7691 "TARGET_MACHO && ! TARGET_64BIT"
7692 "{l|lwz} %0,lo16(%2)(%1)"
7693 [(set_attr "type" "load")
7694 (set_attr "length" "4")])
7695
c859cda6 7696(define_insn "movsi_low_st"
f585a356 7697 [(set (mem:SI (lo_sum:SI (match_operand:SI 1 "gpc_reg_operand" "b")
c859cda6
DJ
7698 (match_operand 2 "" "")))
7699 (match_operand:SI 0 "gpc_reg_operand" "r"))]
7700 "TARGET_MACHO && ! TARGET_64BIT"
7701 "{st|stw} %0,lo16(%2)(%1)"
7702 [(set_attr "type" "store")
7703 (set_attr "length" "4")])
7704
7705(define_insn "movdf_low"
234e114c 7706 [(set (match_operand:DF 0 "gpc_reg_operand" "=f,!r")
f585a356 7707 (mem:DF (lo_sum:SI (match_operand:SI 1 "gpc_reg_operand" "b,b")
c859cda6 7708 (match_operand 2 "" ""))))]
a3170dc6 7709 "TARGET_MACHO && TARGET_HARD_FLOAT && TARGET_FPRS && ! TARGET_64BIT"
234e114c
DJ
7710 "*
7711{
7712 switch (which_alternative)
7713 {
7714 case 0:
7715 return \"lfd %0,lo16(%2)(%1)\";
7716 case 1:
7717 {
7718 rtx operands2[4];
7719 operands2[0] = operands[0];
7720 operands2[1] = operands[1];
7721 operands2[2] = operands[2];
683bdff7 7722 if (TARGET_POWERPC64 && TARGET_32BIT)
a3c9585f 7723 /* Note, old assemblers didn't support relocation here. */
683bdff7 7724 return \"ld %0,lo16(%2)(%1)\";
ab82a49f 7725 else
683bdff7 7726 {
6ae08853 7727 operands2[3] = gen_rtx_REG (SImode, RS6000_PIC_OFFSET_TABLE_REGNUM);
683bdff7
FJ
7728 output_asm_insn (\"{l|lwz} %0,lo16(%2)(%1)\", operands);
7729#if TARGET_MACHO
7730 if (MACHO_DYNAMIC_NO_PIC_P)
7731 output_asm_insn (\"{liu|lis} %L0,ha16(%2+4)\", operands);
6ae08853 7732 else
683bdff7
FJ
7733 /* We cannot rely on ha16(low half)==ha16(high half), alas,
7734 although in practice it almost always is. */
7735 output_asm_insn (\"{cau|addis} %L0,%3,ha16(%2+4)\", operands2);
ab82a49f 7736#endif
683bdff7
FJ
7737 return (\"{l|lwz} %L0,lo16(%2+4)(%L0)\");
7738 }
234e114c
DJ
7739 }
7740 default:
7741 abort();
7742 }
7743}"
c859cda6 7744 [(set_attr "type" "load")
234e114c 7745 (set_attr "length" "4,12")])
c859cda6
DJ
7746
7747(define_insn "movdf_low_st"
f585a356 7748 [(set (mem:DF (lo_sum:SI (match_operand:SI 1 "gpc_reg_operand" "b")
c859cda6
DJ
7749 (match_operand 2 "" "")))
7750 (match_operand:DF 0 "gpc_reg_operand" "f"))]
a3170dc6 7751 "TARGET_MACHO && TARGET_HARD_FLOAT && TARGET_FPRS && ! TARGET_64BIT"
c859cda6
DJ
7752 "stfd %0,lo16(%2)(%1)"
7753 [(set_attr "type" "store")
7754 (set_attr "length" "4")])
7755
7756(define_insn "movsf_low"
fd3b43f2 7757 [(set (match_operand:SF 0 "gpc_reg_operand" "=f,!r")
f585a356 7758 (mem:SF (lo_sum:SI (match_operand:SI 1 "gpc_reg_operand" "b,b")
c859cda6 7759 (match_operand 2 "" ""))))]
a3170dc6 7760 "TARGET_MACHO && TARGET_HARD_FLOAT && TARGET_FPRS && ! TARGET_64BIT"
fd3b43f2
DJ
7761 "@
7762 lfs %0,lo16(%2)(%1)
7763 {l|lwz} %0,lo16(%2)(%1)"
c859cda6
DJ
7764 [(set_attr "type" "load")
7765 (set_attr "length" "4")])
7766
7767(define_insn "movsf_low_st"
f585a356 7768 [(set (mem:SF (lo_sum:SI (match_operand:SI 1 "gpc_reg_operand" "b,b")
c859cda6 7769 (match_operand 2 "" "")))
fd3b43f2 7770 (match_operand:SF 0 "gpc_reg_operand" "f,!r"))]
a3170dc6 7771 "TARGET_MACHO && TARGET_HARD_FLOAT && TARGET_FPRS && ! TARGET_64BIT"
fd3b43f2
DJ
7772 "@
7773 stfs %0,lo16(%2)(%1)
7774 {st|stw} %0,lo16(%2)(%1)"
c859cda6
DJ
7775 [(set_attr "type" "store")
7776 (set_attr "length" "4")])
7777
acad7ed3 7778(define_insn "*movsi_internal1"
a004eb82
AH
7779 [(set (match_operand:SI 0 "nonimmediate_operand" "=r,r,r,m,r,r,r,r,r,*q,*c*l,*h,*h")
7780 (match_operand:SI 1 "input_operand" "r,U,m,r,I,L,n,R,*h,r,r,r,0"))]
19d5775a
RK
7781 "gpc_reg_operand (operands[0], SImode)
7782 || gpc_reg_operand (operands[1], SImode)"
1fd4e8c1 7783 "@
deb9225a 7784 mr %0,%1
b9442c72 7785 {cal|la} %0,%a1
ca7f5001
RK
7786 {l%U1%X1|lwz%U1%X1} %0,%1
7787 {st%U0%X0|stw%U0%X0} %1,%0
19d5775a 7788 {lil|li} %0,%1
802a0058 7789 {liu|lis} %0,%v1
beaec479 7790 #
aee86b38 7791 {cal|la} %0,%a1
1fd4e8c1 7792 mf%1 %0
5c23c401 7793 mt%0 %1
e76e75bb 7794 mt%0 %1
a004eb82 7795 mt%0 %1
e34eaae5 7796 {cror 0,0,0|nop}"
02ca7595 7797 [(set_attr "type" "*,*,load,store,*,*,*,*,mfjmpr,*,mtjmpr,*,*")
a004eb82 7798 (set_attr "length" "4,4,4,4,4,4,8,4,4,4,4,4,4")])
1fd4e8c1 7799
77fa0940
RK
7800;; Split a load of a large constant into the appropriate two-insn
7801;; sequence.
7802
7803(define_split
7804 [(set (match_operand:SI 0 "gpc_reg_operand" "")
7805 (match_operand:SI 1 "const_int_operand" ""))]
bb21487f 7806 "(unsigned HOST_WIDE_INT) (INTVAL (operands[1]) + 0x8000) >= 0x10000
77fa0940
RK
7807 && (INTVAL (operands[1]) & 0xffff) != 0"
7808 [(set (match_dup 0)
7809 (match_dup 2))
7810 (set (match_dup 0)
7811 (ior:SI (match_dup 0)
7812 (match_dup 3)))]
7813 "
af8cb5c5
DE
7814{ rtx tem = rs6000_emit_set_const (operands[0], SImode, operands[1], 2);
7815
7816 if (tem == operands[0])
7817 DONE;
7818 else
7819 FAIL;
77fa0940
RK
7820}")
7821
acad7ed3 7822(define_insn "*movsi_internal2"
bb84cb12
DE
7823 [(set (match_operand:CC 2 "cc_reg_operand" "=y,x,?y")
7824 (compare:CC (match_operand:SI 1 "gpc_reg_operand" "0,r,r")
1fd4e8c1 7825 (const_int 0)))
bb84cb12 7826 (set (match_operand:SI 0 "gpc_reg_operand" "=r,r,r") (match_dup 1))]
4b8a63d6 7827 "TARGET_32BIT"
9ebbca7d 7828 "@
bb84cb12 7829 {cmpi|cmpwi} %2,%0,0
9ebbca7d
GK
7830 mr. %0,%1
7831 #"
bb84cb12
DE
7832 [(set_attr "type" "cmp,compare,cmp")
7833 (set_attr "length" "4,4,8")])
7834
9ebbca7d
GK
7835(define_split
7836 [(set (match_operand:CC 2 "cc_reg_not_cr0_operand" "")
7837 (compare:CC (match_operand:SI 1 "gpc_reg_operand" "")
7838 (const_int 0)))
7839 (set (match_operand:SI 0 "gpc_reg_operand" "") (match_dup 1))]
4b8a63d6 7840 "TARGET_32BIT && reload_completed"
9ebbca7d
GK
7841 [(set (match_dup 0) (match_dup 1))
7842 (set (match_dup 2)
7843 (compare:CC (match_dup 0)
7844 (const_int 0)))]
7845 "")
bb84cb12 7846\f
1fd4e8c1
RK
7847(define_expand "movhi"
7848 [(set (match_operand:HI 0 "general_operand" "")
7849 (match_operand:HI 1 "any_operand" ""))]
7850 ""
fb4d4348 7851 "{ rs6000_emit_move (operands[0], operands[1], HImode); DONE; }")
1fd4e8c1 7852
e34eaae5 7853(define_insn "*movhi_internal"
fb81d7ce
RK
7854 [(set (match_operand:HI 0 "nonimmediate_operand" "=r,r,m,r,r,*q,*c*l,*h")
7855 (match_operand:HI 1 "input_operand" "r,m,r,i,*h,r,r,0"))]
19d5775a
RK
7856 "gpc_reg_operand (operands[0], HImode)
7857 || gpc_reg_operand (operands[1], HImode)"
1fd4e8c1 7858 "@
deb9225a 7859 mr %0,%1
1fd4e8c1
RK
7860 lhz%U1%X1 %0,%1
7861 sth%U0%X0 %1,%0
19d5775a 7862 {lil|li} %0,%w1
1fd4e8c1 7863 mf%1 %0
e76e75bb 7864 mt%0 %1
fb81d7ce 7865 mt%0 %1
e34eaae5 7866 {cror 0,0,0|nop}"
02ca7595 7867 [(set_attr "type" "*,load,store,*,mfjmpr,*,mtjmpr,*")])
1fd4e8c1
RK
7868
7869(define_expand "movqi"
7870 [(set (match_operand:QI 0 "general_operand" "")
7871 (match_operand:QI 1 "any_operand" ""))]
7872 ""
fb4d4348 7873 "{ rs6000_emit_move (operands[0], operands[1], QImode); DONE; }")
1fd4e8c1 7874
e34eaae5 7875(define_insn "*movqi_internal"
fb81d7ce
RK
7876 [(set (match_operand:QI 0 "nonimmediate_operand" "=r,r,m,r,r,*q,*c*l,*h")
7877 (match_operand:QI 1 "input_operand" "r,m,r,i,*h,r,r,0"))]
19d5775a
RK
7878 "gpc_reg_operand (operands[0], QImode)
7879 || gpc_reg_operand (operands[1], QImode)"
1fd4e8c1 7880 "@
deb9225a 7881 mr %0,%1
1fd4e8c1
RK
7882 lbz%U1%X1 %0,%1
7883 stb%U0%X0 %1,%0
19d5775a 7884 {lil|li} %0,%1
1fd4e8c1 7885 mf%1 %0
e76e75bb 7886 mt%0 %1
fb81d7ce 7887 mt%0 %1
e34eaae5 7888 {cror 0,0,0|nop}"
02ca7595 7889 [(set_attr "type" "*,load,store,*,mfjmpr,*,mtjmpr,*")])
1fd4e8c1
RK
7890\f
7891;; Here is how to move condition codes around. When we store CC data in
7892;; an integer register or memory, we store just the high-order 4 bits.
7893;; This lets us not shift in the most common case of CR0.
7894(define_expand "movcc"
7895 [(set (match_operand:CC 0 "nonimmediate_operand" "")
7896 (match_operand:CC 1 "nonimmediate_operand" ""))]
7897 ""
7898 "")
7899
a65c591c 7900(define_insn "*movcc_internal1"
b54cf83a
DE
7901 [(set (match_operand:CC 0 "nonimmediate_operand" "=y,x,?y,r,r,r,r,q,cl,r,m")
7902 (match_operand:CC 1 "nonimmediate_operand" "y,r,r,x,y,r,h,r,r,m,r"))]
1fd4e8c1
RK
7903 "register_operand (operands[0], CCmode)
7904 || register_operand (operands[1], CCmode)"
7905 "@
7906 mcrf %0,%1
7907 mtcrf 128,%1
ca7f5001 7908 {rlinm|rlwinm} %1,%1,%F0,0xffffffff\;mtcrf %R0,%1\;{rlinm|rlwinm} %1,%1,%f0,0xffffffff
2c4a9cff
DE
7909 mfcr %0%Q1
7910 mfcr %0%Q1\;{rlinm|rlwinm} %0,%0,%f1,0xf0000000
deb9225a 7911 mr %0,%1
b54cf83a 7912 mf%1 %0
b991a865
GK
7913 mt%0 %1
7914 mt%0 %1
ca7f5001
RK
7915 {l%U1%X1|lwz%U1%X1} %0,%1
7916 {st%U0%U1|stw%U0%U1} %1,%0"
2c4a9cff
DE
7917 [(set (attr "type")
7918 (cond [(eq_attr "alternative" "0")
7919 (const_string "cr_logical")
7920 (eq_attr "alternative" "1,2")
7921 (const_string "mtcr")
7922 (eq_attr "alternative" "5,7")
7923 (const_string "integer")
7924 (eq_attr "alternative" "6")
7925 (const_string "mfjmpr")
7926 (eq_attr "alternative" "8")
7927 (const_string "mtjmpr")
7928 (eq_attr "alternative" "9")
7929 (const_string "load")
7930 (eq_attr "alternative" "10")
7931 (const_string "store")
7932 (ne (symbol_ref "TARGET_MFCRF") (const_int 0))
7933 (const_string "mfcrf")
7934 ]
7935 (const_string "mfcr")))
b991a865 7936 (set_attr "length" "4,4,12,4,8,4,4,4,4,4,4")])
1fd4e8c1 7937\f
e52e05ca
MM
7938;; For floating-point, we normally deal with the floating-point registers
7939;; unless -msoft-float is used. The sole exception is that parameter passing
7940;; can produce floating-point values in fixed-point registers. Unless the
7941;; value is a simple constant or already in memory, we deal with this by
7942;; allocating memory and copying the value explicitly via that memory location.
1fd4e8c1
RK
7943(define_expand "movsf"
7944 [(set (match_operand:SF 0 "nonimmediate_operand" "")
7945 (match_operand:SF 1 "any_operand" ""))]
7946 ""
fb4d4348 7947 "{ rs6000_emit_move (operands[0], operands[1], SFmode); DONE; }")
1fd4e8c1 7948
1fd4e8c1 7949(define_split
cd2b37d9 7950 [(set (match_operand:SF 0 "gpc_reg_operand" "")
c4c40373 7951 (match_operand:SF 1 "const_double_operand" ""))]
f99f88e0 7952 "reload_completed
5ae4759c
MM
7953 && ((GET_CODE (operands[0]) == REG && REGNO (operands[0]) <= 31)
7954 || (GET_CODE (operands[0]) == SUBREG
7955 && GET_CODE (SUBREG_REG (operands[0])) == REG
7956 && REGNO (SUBREG_REG (operands[0])) <= 31))"
c4c40373 7957 [(set (match_dup 2) (match_dup 3))]
685f3906
DE
7958 "
7959{
7960 long l;
7961 REAL_VALUE_TYPE rv;
7962
7963 REAL_VALUE_FROM_CONST_DOUBLE (rv, operands[1]);
7964 REAL_VALUE_TO_TARGET_SINGLE (rv, l);
c4c40373 7965
f99f88e0
DE
7966 if (! TARGET_POWERPC64)
7967 operands[2] = operand_subword (operands[0], 0, 0, SFmode);
7968 else
7969 operands[2] = gen_lowpart (SImode, operands[0]);
a260abc9 7970
2496c7bd 7971 operands[3] = gen_int_mode (l, SImode);
a260abc9
DE
7972}")
7973
c4c40373 7974(define_insn "*movsf_hardfloat"
ae6669e7
DJ
7975 [(set (match_operand:SF 0 "nonimmediate_operand" "=!r,!r,m,f,f,m,!cl,!q,!r,!h,!r,!r")
7976 (match_operand:SF 1 "input_operand" "r,m,r,f,m,f,r,r,h,0,G,Fn"))]
d14a6d05 7977 "(gpc_reg_operand (operands[0], SFmode)
a3170dc6
AH
7978 || gpc_reg_operand (operands[1], SFmode))
7979 && (TARGET_HARD_FLOAT && TARGET_FPRS)"
1fd4e8c1 7980 "@
f99f88e0
DE
7981 mr %0,%1
7982 {l%U1%X1|lwz%U1%X1} %0,%1
7983 {st%U0%X0|stw%U0%X0} %1,%0
1fd4e8c1
RK
7984 fmr %0,%1
7985 lfs%U1%X1 %0,%1
c4c40373 7986 stfs%U0%X0 %1,%0
b991a865
GK
7987 mt%0 %1
7988 mt%0 %1
7989 mf%1 %0
e0740893 7990 {cror 0,0,0|nop}
c4c40373
MM
7991 #
7992 #"
ae6669e7
DJ
7993 [(set_attr "type" "*,load,store,fp,fpload,fpstore,*,mtjmpr,*,*,*,*")
7994 (set_attr "length" "4,4,4,4,4,4,4,4,4,4,4,8")])
d14a6d05 7995
c4c40373 7996(define_insn "*movsf_softfloat"
dd0fbae2
MK
7997 [(set (match_operand:SF 0 "nonimmediate_operand" "=r,cl,q,r,r,m,r,r,r,r,r,*h")
7998 (match_operand:SF 1 "input_operand" "r,r,r,h,m,r,I,L,R,G,Fn,0"))]
d14a6d05 7999 "(gpc_reg_operand (operands[0], SFmode)
a3170dc6
AH
8000 || gpc_reg_operand (operands[1], SFmode))
8001 && (TARGET_SOFT_FLOAT || !TARGET_FPRS)"
d14a6d05
MM
8002 "@
8003 mr %0,%1
b991a865
GK
8004 mt%0 %1
8005 mt%0 %1
8006 mf%1 %0
d14a6d05
MM
8007 {l%U1%X1|lwz%U1%X1} %0,%1
8008 {st%U0%X0|stw%U0%X0} %1,%0
8009 {lil|li} %0,%1
802a0058 8010 {liu|lis} %0,%v1
aee86b38 8011 {cal|la} %0,%a1
c4c40373 8012 #
dd0fbae2
MK
8013 #
8014 {cror 0,0,0|nop}"
8015 [(set_attr "type" "*,mtjmpr,*,*,load,store,*,*,*,*,*,*")
8016 (set_attr "length" "4,4,4,4,4,4,4,4,4,4,8,4")])
d14a6d05 8017
1fd4e8c1
RK
8018\f
8019(define_expand "movdf"
8020 [(set (match_operand:DF 0 "nonimmediate_operand" "")
8021 (match_operand:DF 1 "any_operand" ""))]
8022 ""
fb4d4348 8023 "{ rs6000_emit_move (operands[0], operands[1], DFmode); DONE; }")
1fd4e8c1
RK
8024
8025(define_split
cd2b37d9 8026 [(set (match_operand:DF 0 "gpc_reg_operand" "")
c4c40373 8027 (match_operand:DF 1 "const_int_operand" ""))]
a260abc9 8028 "! TARGET_POWERPC64 && reload_completed
5ae4759c
MM
8029 && ((GET_CODE (operands[0]) == REG && REGNO (operands[0]) <= 31)
8030 || (GET_CODE (operands[0]) == SUBREG
8031 && GET_CODE (SUBREG_REG (operands[0])) == REG
8032 && REGNO (SUBREG_REG (operands[0])) <= 31))"
c4c40373
MM
8033 [(set (match_dup 2) (match_dup 4))
8034 (set (match_dup 3) (match_dup 1))]
8035 "
8036{
5ae4759c 8037 int endian = (WORDS_BIG_ENDIAN == 0);
5f59ecb7
DE
8038 HOST_WIDE_INT value = INTVAL (operands[1]);
8039
5ae4759c
MM
8040 operands[2] = operand_subword (operands[0], endian, 0, DFmode);
8041 operands[3] = operand_subword (operands[0], 1 - endian, 0, DFmode);
5f59ecb7
DE
8042#if HOST_BITS_PER_WIDE_INT == 32
8043 operands[4] = (value & 0x80000000) ? constm1_rtx : const0_rtx;
8044#else
8045 operands[4] = GEN_INT (value >> 32);
a65c591c 8046 operands[1] = GEN_INT (((value & 0xffffffff) ^ 0x80000000) - 0x80000000);
5f59ecb7 8047#endif
c4c40373
MM
8048}")
8049
c4c40373
MM
8050(define_split
8051 [(set (match_operand:DF 0 "gpc_reg_operand" "")
8052 (match_operand:DF 1 "const_double_operand" ""))]
a260abc9 8053 "! TARGET_POWERPC64 && reload_completed
5ae4759c
MM
8054 && ((GET_CODE (operands[0]) == REG && REGNO (operands[0]) <= 31)
8055 || (GET_CODE (operands[0]) == SUBREG
8056 && GET_CODE (SUBREG_REG (operands[0])) == REG
8057 && REGNO (SUBREG_REG (operands[0])) <= 31))"
c4c40373
MM
8058 [(set (match_dup 2) (match_dup 4))
8059 (set (match_dup 3) (match_dup 5))]
8060 "
8061{
5ae4759c 8062 int endian = (WORDS_BIG_ENDIAN == 0);
47ad8c61
MM
8063 long l[2];
8064 REAL_VALUE_TYPE rv;
8065
8066 REAL_VALUE_FROM_CONST_DOUBLE (rv, operands[1]);
8067 REAL_VALUE_TO_TARGET_DOUBLE (rv, l);
8068
5ae4759c
MM
8069 operands[2] = operand_subword (operands[0], endian, 0, DFmode);
8070 operands[3] = operand_subword (operands[0], 1 - endian, 0, DFmode);
2496c7bd
LB
8071 operands[4] = gen_int_mode (l[endian], SImode);
8072 operands[5] = gen_int_mode (l[1 - endian], SImode);
c4c40373
MM
8073}")
8074
efc08378
DE
8075(define_split
8076 [(set (match_operand:DF 0 "gpc_reg_operand" "")
685f3906 8077 (match_operand:DF 1 "easy_fp_constant" ""))]
a260abc9 8078 "TARGET_POWERPC64 && reload_completed
5ae4759c
MM
8079 && ((GET_CODE (operands[0]) == REG && REGNO (operands[0]) <= 31)
8080 || (GET_CODE (operands[0]) == SUBREG
8081 && GET_CODE (SUBREG_REG (operands[0])) == REG
8082 && REGNO (SUBREG_REG (operands[0])) <= 31))"
a260abc9 8083 [(set (match_dup 2) (match_dup 3))]
5ae4759c 8084 "
a260abc9
DE
8085{
8086 int endian = (WORDS_BIG_ENDIAN == 0);
8087 long l[2];
8088 REAL_VALUE_TYPE rv;
4977bab6 8089#if HOST_BITS_PER_WIDE_INT >= 64
5b029315 8090 HOST_WIDE_INT val;
4977bab6 8091#endif
a260abc9
DE
8092
8093 REAL_VALUE_FROM_CONST_DOUBLE (rv, operands[1]);
8094 REAL_VALUE_TO_TARGET_DOUBLE (rv, l);
8095
8096 operands[2] = gen_lowpart (DImode, operands[0]);
8097 /* HIGHPART is lower memory address when WORDS_BIG_ENDIAN. */
5b029315 8098#if HOST_BITS_PER_WIDE_INT >= 64
a2419b96
DE
8099 val = ((HOST_WIDE_INT)(unsigned long)l[endian] << 32
8100 | ((HOST_WIDE_INT)(unsigned long)l[1 - endian]));
5b029315 8101
f5264b52 8102 operands[3] = gen_int_mode (val, DImode);
5b029315 8103#else
a260abc9 8104 operands[3] = immed_double_const (l[1 - endian], l[endian], DImode);
5b029315 8105#endif
a260abc9 8106}")
efc08378 8107
4eae5fe1 8108;; Don't have reload use general registers to load a constant. First,
1427100a 8109;; it might not work if the output operand is the equivalent of
4eae5fe1
RK
8110;; a non-offsettable memref, but also it is less efficient than loading
8111;; the constant into an FP register, since it will probably be used there.
8112;; The "??" is a kludge until we can figure out a more reasonable way
8113;; of handling these non-offsettable values.
c4c40373 8114(define_insn "*movdf_hardfloat32"
914a7297
DE
8115 [(set (match_operand:DF 0 "nonimmediate_operand" "=!r,??r,m,f,f,m,!r,!r,!r")
8116 (match_operand:DF 1 "input_operand" "r,m,r,f,m,f,G,H,F"))]
a3170dc6 8117 "! TARGET_POWERPC64 && TARGET_HARD_FLOAT && TARGET_FPRS
52d3af72
DE
8118 && (gpc_reg_operand (operands[0], DFmode)
8119 || gpc_reg_operand (operands[1], DFmode))"
e7113111
RK
8120 "*
8121{
8122 switch (which_alternative)
8123 {
a260abc9 8124 default:
a6c2a102 8125 abort ();
e7113111
RK
8126 case 0:
8127 /* We normally copy the low-numbered register first. However, if
000034eb
DE
8128 the first register operand 0 is the same as the second register
8129 of operand 1, we must copy in the opposite order. */
e7113111 8130 if (REGNO (operands[0]) == REGNO (operands[1]) + 1)
deb9225a 8131 return \"mr %L0,%L1\;mr %0,%1\";
e7113111 8132 else
deb9225a 8133 return \"mr %0,%1\;mr %L0,%L1\";
e7113111 8134 case 1:
819e019c
EC
8135 if (GET_CODE (operands[1]) == MEM
8136 && (rs6000_legitimate_offset_address_p (DFmode, XEXP (operands[1], 0),
8137 reload_completed || reload_in_progress)
8138 || GET_CODE (XEXP (operands[1], 0)) == REG
8139 || GET_CODE (XEXP (operands[1], 0)) == LO_SUM
69f51a21 8140 || GET_CODE (XEXP (operands[1], 0)) == PRE_INC
819e019c 8141 || GET_CODE (XEXP (operands[1], 0)) == PRE_DEC))
000034eb
DE
8142 {
8143 /* If the low-address word is used in the address, we must load
8144 it last. Otherwise, load it first. Note that we cannot have
8145 auto-increment in that case since the address register is
8146 known to be dead. */
8147 if (refers_to_regno_p (REGNO (operands[0]), REGNO (operands[0]) + 1,
8148 operands[1], 0))
8149 return \"{l|lwz} %L0,%L1\;{l|lwz} %0,%1\";
8150 else
8151 return \"{l%U1|lwz%U1} %0,%1\;{l|lwz} %L0,%L1\";
8152 }
e7113111 8153 else
000034eb
DE
8154 {
8155 rtx addreg;
8156
000034eb
DE
8157 addreg = find_addr_reg (XEXP (operands[1], 0));
8158 if (refers_to_regno_p (REGNO (operands[0]),
8159 REGNO (operands[0]) + 1,
8160 operands[1], 0))
8161 {
8162 output_asm_insn (\"{cal|la} %0,4(%0)\", &addreg);
2b97222d 8163 output_asm_insn (\"{lx|lwzx} %L0,%1\", operands);
000034eb 8164 output_asm_insn (\"{cal|la} %0,-4(%0)\", &addreg);
2b97222d 8165 return \"{lx|lwzx} %0,%1\";
000034eb
DE
8166 }
8167 else
8168 {
2b97222d 8169 output_asm_insn (\"{lx|lwzx} %0,%1\", operands);
000034eb 8170 output_asm_insn (\"{cal|la} %0,4(%0)\", &addreg);
2b97222d 8171 output_asm_insn (\"{lx|lwzx} %L0,%1\", operands);
000034eb
DE
8172 output_asm_insn (\"{cal|la} %0,-4(%0)\", &addreg);
8173 return \"\";
8174 }
8175 }
e7113111 8176 case 2:
819e019c
EC
8177 if (GET_CODE (operands[0]) == MEM
8178 && (rs6000_legitimate_offset_address_p (DFmode, XEXP (operands[0], 0),
8179 reload_completed || reload_in_progress)
8180 || GET_CODE (XEXP (operands[0], 0)) == REG
8181 || GET_CODE (XEXP (operands[0], 0)) == LO_SUM
69f51a21 8182 || GET_CODE (XEXP (operands[0], 0)) == PRE_INC
819e019c 8183 || GET_CODE (XEXP (operands[0], 0)) == PRE_DEC))
000034eb
DE
8184 return \"{st%U0|stw%U0} %1,%0\;{st|stw} %L1,%L0\";
8185 else
8186 {
8187 rtx addreg;
8188
000034eb 8189 addreg = find_addr_reg (XEXP (operands[0], 0));
2b97222d 8190 output_asm_insn (\"{stx|stwx} %1,%0\", operands);
000034eb 8191 output_asm_insn (\"{cal|la} %0,4(%0)\", &addreg);
2b97222d 8192 output_asm_insn (\"{stx|stwx} %L1,%0\", operands);
000034eb
DE
8193 output_asm_insn (\"{cal|la} %0,-4(%0)\", &addreg);
8194 return \"\";
8195 }
e7113111 8196 case 3:
914a7297 8197 return \"fmr %0,%1\";
e7113111 8198 case 4:
914a7297 8199 return \"lfd%U1%X1 %0,%1\";
e7113111 8200 case 5:
914a7297 8201 return \"stfd%U0%X0 %1,%0\";
e7113111 8202 case 6:
c4c40373 8203 case 7:
c4c40373 8204 case 8:
914a7297 8205 return \"#\";
e7113111
RK
8206 }
8207}"
914a7297
DE
8208 [(set_attr "type" "*,load,store,fp,fpload,fpstore,*,*,*")
8209 (set_attr "length" "8,16,16,4,4,4,8,12,16")])
51b8fc2c 8210
c4c40373 8211(define_insn "*movdf_softfloat32"
1427100a
DE
8212 [(set (match_operand:DF 0 "nonimmediate_operand" "=r,r,m,r,r,r")
8213 (match_operand:DF 1 "input_operand" "r,m,r,G,H,F"))]
a3170dc6 8214 "! TARGET_POWERPC64 && (TARGET_SOFT_FLOAT || !TARGET_FPRS)
52d3af72
DE
8215 && (gpc_reg_operand (operands[0], DFmode)
8216 || gpc_reg_operand (operands[1], DFmode))"
dc4f83ca
MM
8217 "*
8218{
8219 switch (which_alternative)
8220 {
a260abc9 8221 default:
a6c2a102 8222 abort ();
dc4f83ca
MM
8223 case 0:
8224 /* We normally copy the low-numbered register first. However, if
8225 the first register operand 0 is the same as the second register of
8226 operand 1, we must copy in the opposite order. */
8227 if (REGNO (operands[0]) == REGNO (operands[1]) + 1)
8228 return \"mr %L0,%L1\;mr %0,%1\";
8229 else
8230 return \"mr %0,%1\;mr %L0,%L1\";
8231 case 1:
3cb999d8
DE
8232 /* If the low-address word is used in the address, we must load
8233 it last. Otherwise, load it first. Note that we cannot have
8234 auto-increment in that case since the address register is
8235 known to be dead. */
dc4f83ca 8236 if (refers_to_regno_p (REGNO (operands[0]), REGNO (operands[0]) + 1,
3cb999d8 8237 operands[1], 0))
dc4f83ca
MM
8238 return \"{l|lwz} %L0,%L1\;{l|lwz} %0,%1\";
8239 else
8240 return \"{l%U1|lwz%U1} %0,%1\;{l|lwz} %L0,%L1\";
8241 case 2:
8242 return \"{st%U0|stw%U0} %1,%0\;{st|stw} %L1,%L0\";
8243 case 3:
c4c40373
MM
8244 case 4:
8245 case 5:
dc4f83ca
MM
8246 return \"#\";
8247 }
8248}"
c4c40373
MM
8249 [(set_attr "type" "*,load,store,*,*,*")
8250 (set_attr "length" "8,8,8,8,12,16")])
dc4f83ca 8251
d2288d5d
HP
8252; ld/std require word-aligned displacements -> 'Y' constraint.
8253; List Y->r and r->Y before r->r for reload.
c4c40373 8254(define_insn "*movdf_hardfloat64"
ae6669e7
DJ
8255 [(set (match_operand:DF 0 "nonimmediate_operand" "=Y,r,!r,f,f,m,!cl,!r,!h,!r,!r,!r")
8256 (match_operand:DF 1 "input_operand" "r,Y,r,f,m,f,r,h,0,G,H,F"))]
a3170dc6 8257 "TARGET_POWERPC64 && TARGET_HARD_FLOAT && TARGET_FPRS
52d3af72
DE
8258 && (gpc_reg_operand (operands[0], DFmode)
8259 || gpc_reg_operand (operands[1], DFmode))"
51b8fc2c 8260 "@
96bb8ed3 8261 std%U0%X0 %1,%0
3364872d
FJ
8262 ld%U1%X1 %0,%1
8263 mr %0,%1
3d5570cb 8264 fmr %0,%1
f63184ac 8265 lfd%U1%X1 %0,%1
914a7297
DE
8266 stfd%U0%X0 %1,%0
8267 mt%0 %1
8268 mf%1 %0
e0740893 8269 {cror 0,0,0|nop}
914a7297
DE
8270 #
8271 #
8272 #"
ae6669e7
DJ
8273 [(set_attr "type" "*,load,store,fp,fpload,fpstore,mtjmpr,*,*,*,*,*")
8274 (set_attr "length" "4,4,4,4,4,4,4,4,4,8,12,16")])
dc4f83ca 8275
c4c40373 8276(define_insn "*movdf_softfloat64"
d2288d5d
HP
8277 [(set (match_operand:DF 0 "nonimmediate_operand" "=r,Y,r,cl,r,r,r,r,*h")
8278 (match_operand:DF 1 "input_operand" "Y,r,r,r,h,G,H,F,0"))]
a3170dc6 8279 "TARGET_POWERPC64 && (TARGET_SOFT_FLOAT || !TARGET_FPRS)
52d3af72
DE
8280 && (gpc_reg_operand (operands[0], DFmode)
8281 || gpc_reg_operand (operands[1], DFmode))"
dc4f83ca 8282 "@
d2288d5d
HP
8283 ld%U1%X1 %0,%1
8284 std%U0%X0 %1,%0
dc4f83ca 8285 mr %0,%1
914a7297
DE
8286 mt%0 %1
8287 mf%1 %0
c4c40373
MM
8288 #
8289 #
e2d0915c 8290 #
e0740893 8291 {cror 0,0,0|nop}"
d2288d5d 8292 [(set_attr "type" "load,store,*,*,*,*,*,*,*")
e2d0915c 8293 (set_attr "length" "4,4,4,4,4,8,12,16,4")])
1fd4e8c1 8294\f
06f4e019
DE
8295(define_expand "movtf"
8296 [(set (match_operand:TF 0 "general_operand" "")
8297 (match_operand:TF 1 "any_operand" ""))]
39e63627
GK
8298 "(DEFAULT_ABI == ABI_AIX || DEFAULT_ABI == ABI_DARWIN)
8299 && TARGET_HARD_FLOAT && TARGET_FPRS && TARGET_LONG_DOUBLE_128"
06f4e019
DE
8300 "{ rs6000_emit_move (operands[0], operands[1], TFmode); DONE; }")
8301
a9baceb1
GK
8302; It's important to list the o->f and f->o moves before f->f because
8303; otherwise reload, given m->f, will try to pick f->f and reload it,
112ccb83 8304; which doesn't make progress. Likewise r->o<> must be before r->r.
a9baceb1 8305(define_insn_and_split "*movtf_internal"
112ccb83
GK
8306 [(set (match_operand:TF 0 "nonimmediate_operand" "=o,f,f,r,o<>,r")
8307 (match_operand:TF 1 "input_operand" "f,o,f,mGHF,r,r"))]
39e63627
GK
8308 "(DEFAULT_ABI == ABI_AIX || DEFAULT_ABI == ABI_DARWIN)
8309 && TARGET_HARD_FLOAT && TARGET_FPRS && TARGET_LONG_DOUBLE_128
06f4e019
DE
8310 && (gpc_reg_operand (operands[0], TFmode)
8311 || gpc_reg_operand (operands[1], TFmode))"
a9baceb1 8312 "#"
ecb62ae7 8313 "&& reload_completed"
a9baceb1
GK
8314 [(pc)]
8315{ rs6000_split_multireg_move (operands[0], operands[1]); DONE; }
112ccb83 8316 [(set_attr "length" "8,8,8,20,20,16")])
06f4e019 8317
ecb62ae7
GK
8318(define_expand "extenddftf2"
8319 [(parallel [(set (match_operand:TF 0 "nonimmediate_operand" "")
8320 (float_extend:TF (match_operand:DF 1 "input_operand" "")))
8321 (use (match_dup 2))])]
39e63627
GK
8322 "(DEFAULT_ABI == ABI_AIX || DEFAULT_ABI == ABI_DARWIN)
8323 && TARGET_HARD_FLOAT && TARGET_FPRS && TARGET_LONG_DOUBLE_128"
06f4e019 8324{
ecb62ae7
GK
8325 operands[2] = CONST0_RTX (DFmode);
8326})
06f4e019 8327
ecb62ae7
GK
8328(define_insn_and_split "*extenddftf2_internal"
8329 [(set (match_operand:TF 0 "nonimmediate_operand" "=o,f,&f,r")
8330 (float_extend:TF (match_operand:DF 1 "input_operand" "fr,mf,mf,rmGHF")))
8331 (use (match_operand:DF 2 "input_operand" "rf,m,f,n"))]
39e63627
GK
8332 "(DEFAULT_ABI == ABI_AIX || DEFAULT_ABI == ABI_DARWIN)
8333 && TARGET_HARD_FLOAT && TARGET_FPRS && TARGET_LONG_DOUBLE_128"
ecb62ae7
GK
8334 "#"
8335 "&& reload_completed"
8336 [(pc)]
06f4e019 8337{
ecb62ae7
GK
8338 const int lo_word = FLOAT_WORDS_BIG_ENDIAN ? GET_MODE_SIZE (DFmode) : 0;
8339 const int hi_word = FLOAT_WORDS_BIG_ENDIAN ? 0 : GET_MODE_SIZE (DFmode);
8340 emit_move_insn (simplify_gen_subreg (DFmode, operands[0], TFmode, hi_word),
8341 operands[1]);
8342 emit_move_insn (simplify_gen_subreg (DFmode, operands[0], TFmode, lo_word),
8343 operands[2]);
8344 DONE;
6ae08853 8345})
ecb62ae7
GK
8346
8347(define_expand "extendsftf2"
8348 [(set (match_operand:TF 0 "nonimmediate_operand" "")
8349 (float_extend:TF (match_operand:SF 1 "gpc_reg_operand" "")))]
8350 "(DEFAULT_ABI == ABI_AIX || DEFAULT_ABI == ABI_DARWIN)
8351 && TARGET_HARD_FLOAT && TARGET_FPRS && TARGET_LONG_DOUBLE_128"
8352{
8353 rtx tmp = gen_reg_rtx (DFmode);
8354 emit_insn (gen_extendsfdf2 (tmp, operands[1]));
8355 emit_insn (gen_extenddftf2 (operands[0], tmp));
8356 DONE;
8357})
06f4e019
DE
8358
8359(define_insn "trunctfdf2"
8360 [(set (match_operand:DF 0 "gpc_reg_operand" "=f")
8361 (float_truncate:DF (match_operand:TF 1 "gpc_reg_operand" "f")))]
39e63627
GK
8362 "(DEFAULT_ABI == ABI_AIX || DEFAULT_ABI == ABI_DARWIN)
8363 && TARGET_HARD_FLOAT && TARGET_FPRS && TARGET_LONG_DOUBLE_128"
06f4e019
DE
8364 "fadd %0,%1,%L1"
8365 [(set_attr "type" "fp")
ecb62ae7 8366 (set_attr "length" "4")])
06f4e019
DE
8367
8368(define_insn_and_split "trunctfsf2"
8369 [(set (match_operand:SF 0 "gpc_reg_operand" "=f")
ea112fc4
DE
8370 (float_truncate:SF (match_operand:TF 1 "gpc_reg_operand" "f")))
8371 (clobber (match_scratch:DF 2 "=f"))]
39e63627
GK
8372 "(DEFAULT_ABI == ABI_AIX || DEFAULT_ABI == ABI_DARWIN)
8373 && TARGET_HARD_FLOAT && TARGET_FPRS && TARGET_LONG_DOUBLE_128"
06f4e019 8374 "#"
ea112fc4 8375 "&& reload_completed"
06f4e019
DE
8376 [(set (match_dup 2)
8377 (float_truncate:DF (match_dup 1)))
8378 (set (match_dup 0)
8379 (float_truncate:SF (match_dup 2)))]
ea112fc4 8380 "")
06f4e019 8381
0c90aa3c 8382(define_expand "floatsitf2"
ea112fc4 8383 [(set (match_operand:TF 0 "gpc_reg_operand" "=f")
0c90aa3c 8384 (float:TF (match_operand:SI 1 "gpc_reg_operand" "r")))]
39e63627
GK
8385 "(DEFAULT_ABI == ABI_AIX || DEFAULT_ABI == ABI_DARWIN)
8386 && TARGET_HARD_FLOAT && TARGET_FPRS && TARGET_LONG_DOUBLE_128"
0c90aa3c
GK
8387{
8388 rtx tmp = gen_reg_rtx (DFmode);
8389 expand_float (tmp, operands[1], false);
8390 emit_insn (gen_extenddftf2 (operands[0], tmp));
8391 DONE;
8392})
06f4e019 8393
ecb62ae7
GK
8394; fadd, but rounding towards zero.
8395; This is probably not the optimal code sequence.
8396(define_insn "fix_trunc_helper"
8397 [(set (match_operand:DF 0 "gpc_reg_operand" "=f")
8398 (unspec:DF [(match_operand:TF 1 "gpc_reg_operand" "f")]
8399 UNSPEC_FIX_TRUNC_TF))
8400 (clobber (match_operand:DF 2 "gpc_reg_operand" "=&f"))]
8401 "TARGET_HARD_FLOAT && TARGET_FPRS"
8402 "mffs %2\n\tmtfsb1 31\n\tmtfsb0 30\n\tfadd %0,%1,%L1\n\tmtfsf 1,%2"
8403 [(set_attr "type" "fp")
8404 (set_attr "length" "20")])
8405
0c90aa3c 8406(define_expand "fix_trunctfsi2"
ecb62ae7
GK
8407 [(parallel [(set (match_operand:SI 0 "gpc_reg_operand" "")
8408 (fix:SI (match_operand:TF 1 "gpc_reg_operand" "")))
8409 (clobber (match_dup 2))
8410 (clobber (match_dup 3))
8411 (clobber (match_dup 4))
8412 (clobber (match_dup 5))])]
8413 "(DEFAULT_ABI == ABI_AIX || DEFAULT_ABI == ABI_DARWIN)
8414 && (TARGET_POWER2 || TARGET_POWERPC)
8415 && TARGET_HARD_FLOAT && TARGET_FPRS && TARGET_LONG_DOUBLE_128"
8416{
8417 operands[2] = gen_reg_rtx (DFmode);
8418 operands[3] = gen_reg_rtx (DFmode);
8419 operands[4] = gen_reg_rtx (DImode);
8420 operands[5] = assign_stack_temp (DImode, GET_MODE_SIZE (DImode), 0);
8421})
8422
8423(define_insn_and_split "*fix_trunctfsi2_internal"
61c07d3c 8424 [(set (match_operand:SI 0 "gpc_reg_operand" "=r")
ecb62ae7
GK
8425 (fix:SI (match_operand:TF 1 "gpc_reg_operand" "f")))
8426 (clobber (match_operand:DF 2 "gpc_reg_operand" "=f"))
8427 (clobber (match_operand:DF 3 "gpc_reg_operand" "=&f"))
8428 (clobber (match_operand:DI 4 "gpc_reg_operand" "=f"))
8429 (clobber (match_operand:DI 5 "memory_operand" "=o"))]
39e63627
GK
8430 "(DEFAULT_ABI == ABI_AIX || DEFAULT_ABI == ABI_DARWIN)
8431 && TARGET_HARD_FLOAT && TARGET_FPRS && TARGET_LONG_DOUBLE_128"
ecb62ae7
GK
8432 "#"
8433 "&& reload_completed"
8434 [(pc)]
0c90aa3c 8435{
ecb62ae7
GK
8436 rtx lowword;
8437 emit_insn (gen_fix_trunc_helper (operands[2], operands[1], operands[3]));
8438
8439 if (GET_CODE (operands[5]) != MEM)
8440 abort();
8441 lowword = XEXP (operands[5], 0);
8442 if (WORDS_BIG_ENDIAN)
8443 lowword = plus_constant (lowword, 4);
8444
8445 emit_insn (gen_fctiwz (operands[4], operands[2]));
8446 emit_move_insn (operands[5], operands[4]);
8447 emit_move_insn (operands[0], gen_rtx_MEM (SImode, lowword));
0c90aa3c
GK
8448 DONE;
8449})
06f4e019
DE
8450
8451(define_insn "negtf2"
8452 [(set (match_operand:TF 0 "gpc_reg_operand" "=f")
8453 (neg:TF (match_operand:TF 1 "gpc_reg_operand" "f")))]
39e63627
GK
8454 "(DEFAULT_ABI == ABI_AIX || DEFAULT_ABI == ABI_DARWIN)
8455 && TARGET_HARD_FLOAT && TARGET_FPRS && TARGET_LONG_DOUBLE_128"
06f4e019
DE
8456 "*
8457{
8458 if (REGNO (operands[0]) == REGNO (operands[1]) + 1)
8459 return \"fneg %L0,%L1\;fneg %0,%1\";
8460 else
8461 return \"fneg %0,%1\;fneg %L0,%L1\";
8462}"
8463 [(set_attr "type" "fp")
8464 (set_attr "length" "8")])
8465
1a402dc1 8466(define_expand "abstf2"
06f4e019
DE
8467 [(set (match_operand:TF 0 "gpc_reg_operand" "=f")
8468 (abs:TF (match_operand:TF 1 "gpc_reg_operand" "f")))]
39e63627
GK
8469 "(DEFAULT_ABI == ABI_AIX || DEFAULT_ABI == ABI_DARWIN)
8470 && TARGET_HARD_FLOAT && TARGET_FPRS && TARGET_LONG_DOUBLE_128"
1a402dc1 8471 "
06f4e019 8472{
1a402dc1
AM
8473 rtx label = gen_label_rtx ();
8474 emit_insn (gen_abstf2_internal (operands[0], operands[1], label));
8475 emit_label (label);
8476 DONE;
8477}")
06f4e019 8478
1a402dc1 8479(define_expand "abstf2_internal"
06f4e019 8480 [(set (match_operand:TF 0 "gpc_reg_operand" "=f")
1a402dc1
AM
8481 (match_operand:TF 1 "gpc_reg_operand" "f"))
8482 (set (match_dup 3) (match_dup 5))
8483 (set (match_dup 5) (abs:DF (match_dup 5)))
8484 (set (match_dup 4) (compare:CCFP (match_dup 3) (match_dup 5)))
8485 (set (pc) (if_then_else (eq (match_dup 4) (const_int 0))
8486 (label_ref (match_operand 2 "" ""))
8487 (pc)))
8488 (set (match_dup 6) (neg:DF (match_dup 6)))]
39e63627
GK
8489 "(DEFAULT_ABI == ABI_AIX || DEFAULT_ABI == ABI_DARWIN)
8490 && TARGET_HARD_FLOAT && TARGET_FPRS && TARGET_LONG_DOUBLE_128"
1a402dc1 8491 "
06f4e019 8492{
1a402dc1
AM
8493 const int hi_word = FLOAT_WORDS_BIG_ENDIAN ? 0 : GET_MODE_SIZE (DFmode);
8494 const int lo_word = FLOAT_WORDS_BIG_ENDIAN ? GET_MODE_SIZE (DFmode) : 0;
8495 operands[3] = gen_reg_rtx (DFmode);
8496 operands[4] = gen_reg_rtx (CCFPmode);
8497 operands[5] = simplify_gen_subreg (DFmode, operands[0], TFmode, hi_word);
8498 operands[6] = simplify_gen_subreg (DFmode, operands[0], TFmode, lo_word);
8499}")
06f4e019 8500\f
1fd4e8c1
RK
8501;; Next come the multi-word integer load and store and the load and store
8502;; multiple insns.
8503(define_expand "movdi"
8504 [(set (match_operand:DI 0 "general_operand" "")
e6ca2c17 8505 (match_operand:DI 1 "any_operand" ""))]
1fd4e8c1 8506 ""
fb4d4348 8507 "{ rs6000_emit_move (operands[0], operands[1], DImode); DONE; }")
1fd4e8c1 8508
112ccb83
GK
8509; List r->r after r->"o<>", otherwise reload will try to reload a
8510; non-offsettable address by using r->r which won't make progress.
acad7ed3 8511(define_insn "*movdi_internal32"
112ccb83
GK
8512 [(set (match_operand:DI 0 "nonimmediate_operand" "=o<>,r,r,f,f,m,r")
8513 (match_operand:DI 1 "input_operand" "r,r,m,f,m,f,IJKnGHF"))]
a260abc9 8514 "! TARGET_POWERPC64
4e74d8ec
MM
8515 && (gpc_reg_operand (operands[0], DImode)
8516 || gpc_reg_operand (operands[1], DImode))"
112ccb83
GK
8517 "@
8518 #
8519 #
8520 #
8521 fmr %0,%1
8522 lfd%U1%X1 %0,%1
8523 stfd%U0%X0 %1,%0
8524 #"
8525 [(set_attr "type" "load,*,store,fp,fpload,fpstore,*")])
4e74d8ec
MM
8526
8527(define_split
8528 [(set (match_operand:DI 0 "gpc_reg_operand" "")
8529 (match_operand:DI 1 "const_int_operand" ""))]
a260abc9 8530 "! TARGET_POWERPC64 && reload_completed"
4e74d8ec
MM
8531 [(set (match_dup 2) (match_dup 4))
8532 (set (match_dup 3) (match_dup 1))]
8533 "
8534{
5f59ecb7 8535 HOST_WIDE_INT value = INTVAL (operands[1]);
bdaa0181
GK
8536 operands[2] = operand_subword_force (operands[0], WORDS_BIG_ENDIAN == 0,
8537 DImode);
8538 operands[3] = operand_subword_force (operands[0], WORDS_BIG_ENDIAN != 0,
8539 DImode);
75d39459 8540#if HOST_BITS_PER_WIDE_INT == 32
5f59ecb7 8541 operands[4] = (value & 0x80000000) ? constm1_rtx : const0_rtx;
75d39459 8542#else
5f59ecb7 8543 operands[4] = GEN_INT (value >> 32);
a65c591c 8544 operands[1] = GEN_INT (((value & 0xffffffff) ^ 0x80000000) - 0x80000000);
75d39459 8545#endif
4e74d8ec
MM
8546}")
8547
3a1f863f
DE
8548(define_split
8549 [(set (match_operand:DI 0 "nonimmediate_operand" "")
8550 (match_operand:DI 1 "input_operand" ""))]
6ae08853 8551 "reload_completed && !TARGET_POWERPC64
3a1f863f 8552 && gpr_or_gpr_p (operands[0], operands[1])"
a9baceb1
GK
8553 [(pc)]
8554{ rs6000_split_multireg_move (operands[0], operands[1]); DONE; })
3a1f863f 8555
6fc19dc9
AM
8556(define_split
8557 [(set (match_operand:TI 0 "gpc_reg_operand" "")
8558 (match_operand:TI 1 "const_double_operand" ""))]
8559 "TARGET_POWERPC64"
8560 [(set (match_dup 2) (match_dup 4))
8561 (set (match_dup 3) (match_dup 5))]
8562 "
8563{
8564 operands[2] = operand_subword_force (operands[0], WORDS_BIG_ENDIAN == 0,
8565 TImode);
8566 operands[3] = operand_subword_force (operands[0], WORDS_BIG_ENDIAN != 0,
8567 TImode);
8568 if (GET_CODE (operands[1]) == CONST_DOUBLE)
8569 {
8570 operands[4] = GEN_INT (CONST_DOUBLE_HIGH (operands[1]));
8571 operands[5] = GEN_INT (CONST_DOUBLE_LOW (operands[1]));
8572 }
8573 else if (GET_CODE (operands[1]) == CONST_INT)
8574 {
8575 operands[4] = GEN_INT (- (INTVAL (operands[1]) < 0));
8576 operands[5] = operands[1];
8577 }
8578 else
8579 FAIL;
8580}")
8581
acad7ed3 8582(define_insn "*movdi_internal64"
fa0a2ae5 8583 [(set (match_operand:DI 0 "nonimmediate_operand" "=r,r,m,r,r,r,r,??f,f,m,r,*h,*h")
9615f239 8584 (match_operand:DI 1 "input_operand" "r,m,r,I,L,nF,R,f,m,f,*h,r,0"))]
a260abc9 8585 "TARGET_POWERPC64
4e74d8ec
MM
8586 && (gpc_reg_operand (operands[0], DImode)
8587 || gpc_reg_operand (operands[1], DImode))"
51b8fc2c 8588 "@
3d5570cb
RK
8589 mr %0,%1
8590 ld%U1%X1 %0,%1
96bb8ed3 8591 std%U0%X0 %1,%0
3d5570cb 8592 li %0,%1
802a0058 8593 lis %0,%v1
e6ca2c17 8594 #
aee86b38 8595 {cal|la} %0,%a1
3d5570cb
RK
8596 fmr %0,%1
8597 lfd%U1%X1 %0,%1
8598 stfd%U0%X0 %1,%0
8599 mf%1 %0
08075ead 8600 mt%0 %1
e34eaae5 8601 {cror 0,0,0|nop}"
02ca7595 8602 [(set_attr "type" "*,load,store,*,*,*,*,fp,fpload,fpstore,mfjmpr,mtjmpr,*")
e6ca2c17
DE
8603 (set_attr "length" "4,4,4,4,4,20,4,4,4,4,4,4,4")])
8604
5f59ecb7 8605;; immediate value valid for a single instruction hiding in a const_double
a260abc9
DE
8606(define_insn ""
8607 [(set (match_operand:DI 0 "gpc_reg_operand" "=r")
8608 (match_operand:DI 1 "const_double_operand" "F"))]
5f59ecb7
DE
8609 "HOST_BITS_PER_WIDE_INT == 32 && TARGET_POWERPC64
8610 && GET_CODE (operands[1]) == CONST_DOUBLE
a260abc9
DE
8611 && num_insns_constant (operands[1], DImode) == 1"
8612 "*
8613{
8614 return ((unsigned HOST_WIDE_INT)
8615 (CONST_DOUBLE_LOW (operands[1]) + 0x8000) < 0x10000)
8616 ? \"li %0,%1\" : \"lis %0,%v1\";
8617}")
8618
a260abc9
DE
8619;; Generate all one-bits and clear left or right.
8620;; Use (and:DI (rotate:DI ...)) to avoid anddi3 unnecessary clobber.
8621(define_split
8622 [(set (match_operand:DI 0 "gpc_reg_operand" "")
8623 (match_operand:DI 1 "mask64_operand" ""))]
8624 "TARGET_POWERPC64 && num_insns_constant (operands[1], DImode) > 1"
8625 [(set (match_dup 0) (const_int -1))
e6ca2c17 8626 (set (match_dup 0)
a260abc9
DE
8627 (and:DI (rotate:DI (match_dup 0)
8628 (const_int 0))
8629 (match_dup 1)))]
8630 "")
8631
8632;; Split a load of a large constant into the appropriate five-instruction
8633;; sequence. Handle anything in a constant number of insns.
8634;; When non-easy constants can go in the TOC, this should use
8635;; easy_fp_constant predicate.
8636(define_split
8637 [(set (match_operand:DI 0 "gpc_reg_operand" "")
2bfcf297
DB
8638 (match_operand:DI 1 "const_int_operand" ""))]
8639 "TARGET_POWERPC64 && num_insns_constant (operands[1], DImode) > 1"
8640 [(set (match_dup 0) (match_dup 2))
8641 (set (match_dup 0) (plus:DI (match_dup 0) (match_dup 3)))]
e6ca2c17 8642 "
2bfcf297
DB
8643{ rtx tem = rs6000_emit_set_const (operands[0], DImode, operands[1], 5);
8644
8645 if (tem == operands[0])
8646 DONE;
e8d791dd 8647 else
2bfcf297 8648 FAIL;
5f59ecb7 8649}")
e6ca2c17 8650
5f59ecb7
DE
8651(define_split
8652 [(set (match_operand:DI 0 "gpc_reg_operand" "")
2bfcf297
DB
8653 (match_operand:DI 1 "const_double_operand" ""))]
8654 "TARGET_POWERPC64 && num_insns_constant (operands[1], DImode) > 1"
8655 [(set (match_dup 0) (match_dup 2))
8656 (set (match_dup 0) (plus:DI (match_dup 0) (match_dup 3)))]
5f59ecb7 8657 "
2bfcf297
DB
8658{ rtx tem = rs6000_emit_set_const (operands[0], DImode, operands[1], 5);
8659
8660 if (tem == operands[0])
8661 DONE;
8662 else
8663 FAIL;
e6ca2c17 8664}")
08075ead 8665
acad7ed3 8666(define_insn "*movdi_internal2"
bb84cb12
DE
8667 [(set (match_operand:CC 2 "cc_reg_operand" "=y,x,?y")
8668 (compare:CC (match_operand:DI 1 "gpc_reg_operand" "0,r,r")
08075ead 8669 (const_int 0)))
bb84cb12 8670 (set (match_operand:DI 0 "gpc_reg_operand" "=r,r,r") (match_dup 1))]
683bdff7 8671 "TARGET_64BIT"
9ebbca7d 8672 "@
bb84cb12 8673 cmpdi %2,%0,0
9ebbca7d
GK
8674 mr. %0,%1
8675 #"
bb84cb12
DE
8676 [(set_attr "type" "cmp,compare,cmp")
8677 (set_attr "length" "4,4,8")])
acad7ed3 8678
9ebbca7d
GK
8679(define_split
8680 [(set (match_operand:CC 2 "cc_reg_not_cr0_operand" "")
8681 (compare:CC (match_operand:DI 1 "gpc_reg_operand" "")
8682 (const_int 0)))
8683 (set (match_operand:DI 0 "gpc_reg_operand" "") (match_dup 1))]
8684 "TARGET_POWERPC64 && reload_completed"
8685 [(set (match_dup 0) (match_dup 1))
8686 (set (match_dup 2)
8687 (compare:CC (match_dup 0)
8688 (const_int 0)))]
8689 "")
acad7ed3 8690\f
1fd4e8c1
RK
8691;; TImode is similar, except that we usually want to compute the address into
8692;; a register and use lsi/stsi (the exception is during reload). MQ is also
ca7f5001 8693;; clobbered in stsi for POWER, so we need a SCRATCH for it.
1fd4e8c1
RK
8694(define_expand "movti"
8695 [(parallel [(set (match_operand:TI 0 "general_operand" "")
8696 (match_operand:TI 1 "general_operand" ""))
8697 (clobber (scratch:SI))])]
3a1f863f 8698 ""
fb4d4348 8699 "{ rs6000_emit_move (operands[0], operands[1], TImode); DONE; }")
1fd4e8c1
RK
8700
8701;; We say that MQ is clobbered in the last alternative because the first
8702;; alternative would never get used otherwise since it would need a reload
8703;; while the 2nd alternative would not. We put memory cases first so they
8704;; are preferred. Otherwise, we'd try to reload the output instead of
8705;; giving the SCRATCH mq.
3a1f863f 8706
a260abc9 8707(define_insn "*movti_power"
e1469d0d 8708 [(set (match_operand:TI 0 "reg_or_mem_operand" "=Q,m,????r,????r,????r")
1fd4e8c1
RK
8709 (match_operand:TI 1 "reg_or_mem_operand" "r,r,r,Q,m"))
8710 (clobber (match_scratch:SI 2 "=q,q#X,X,X,X"))]
6ae08853 8711 "TARGET_POWER && ! TARGET_POWERPC64
dc4f83ca 8712 && (gpc_reg_operand (operands[0], TImode) || gpc_reg_operand (operands[1], TImode))"
1fd4e8c1
RK
8713 "*
8714{
8715 switch (which_alternative)
8716 {
dc4f83ca
MM
8717 default:
8718 abort ();
8719
1fd4e8c1 8720 case 0:
3a1f863f
DE
8721 if (TARGET_STRING)
8722 return \"{stsi|stswi} %1,%P0,16\";
1fd4e8c1 8723 case 1:
1fd4e8c1 8724 case 2:
3a1f863f 8725 return \"#\";
1fd4e8c1
RK
8726 case 3:
8727 /* If the address is not used in the output, we can use lsi. Otherwise,
8728 fall through to generating four loads. */
e876481c
DE
8729 if (TARGET_STRING
8730 && ! reg_overlap_mentioned_p (operands[0], operands[1]))
ca7f5001 8731 return \"{lsi|lswi} %0,%P1,16\";
82e41834 8732 /* ... fall through ... */
1fd4e8c1 8733 case 4:
3a1f863f 8734 return \"#\";
1fd4e8c1
RK
8735 }
8736}"
3a1f863f 8737 [(set_attr "type" "store,store,*,load,load")])
51b8fc2c 8738
a260abc9 8739(define_insn "*movti_string"
112ccb83 8740 [(set (match_operand:TI 0 "reg_or_mem_operand" "=Q,o<>,????r,????r,????r")
27dc0551 8741 (match_operand:TI 1 "reg_or_mem_operand" "r,r,r,Q,m"))]
3a1f863f 8742 "! TARGET_POWER && ! TARGET_POWERPC64
dc4f83ca
MM
8743 && (gpc_reg_operand (operands[0], TImode) || gpc_reg_operand (operands[1], TImode))"
8744 "*
8745{
8746 switch (which_alternative)
8747 {
8748 default:
8749 abort ();
dc4f83ca 8750 case 0:
3a1f863f
DE
8751 if (TARGET_STRING)
8752 return \"{stsi|stswi} %1,%P0,16\";
dc4f83ca 8753 case 1:
cd1d3445 8754 case 2:
3a1f863f 8755 return \"#\";
cd1d3445
DE
8756 case 3:
8757 /* If the address is not used in the output, we can use lsi. Otherwise,
8758 fall through to generating four loads. */
6ae08853 8759 if (TARGET_STRING
3a1f863f 8760 && ! reg_overlap_mentioned_p (operands[0], operands[1]))
cd1d3445
DE
8761 return \"{lsi|lswi} %0,%P1,16\";
8762 /* ... fall through ... */
8763 case 4:
3a1f863f 8764 return \"#\";
dc4f83ca
MM
8765 }
8766}"
3a1f863f 8767 [(set_attr "type" "store,store,*,load,load")])
dc4f83ca 8768
a260abc9 8769(define_insn "*movti_ppc64"
112ccb83
GK
8770 [(set (match_operand:TI 0 "nonimmediate_operand" "=r,o<>,r")
8771 (match_operand:TI 1 "input_operand" "r,r,m"))]
51b8fc2c
RK
8772 "TARGET_POWERPC64 && (gpc_reg_operand (operands[0], TImode)
8773 || gpc_reg_operand (operands[1], TImode))"
112ccb83 8774 "#"
3a1f863f
DE
8775 [(set_attr "type" "*,load,store")])
8776
8777(define_split
8778 [(set (match_operand:TI 0 "nonimmediate_operand" "")
8779 (match_operand:TI 1 "input_operand" ""))]
a9baceb1 8780 "reload_completed
3a1f863f 8781 && gpr_or_gpr_p (operands[0], operands[1])"
a9baceb1
GK
8782 [(pc)]
8783{ rs6000_split_multireg_move (operands[0], operands[1]); DONE; })
1fd4e8c1
RK
8784\f
8785(define_expand "load_multiple"
2f622005
RK
8786 [(match_par_dup 3 [(set (match_operand:SI 0 "" "")
8787 (match_operand:SI 1 "" ""))
8788 (use (match_operand:SI 2 "" ""))])]
09a625f7 8789 "TARGET_STRING && !TARGET_POWERPC64"
1fd4e8c1
RK
8790 "
8791{
8792 int regno;
8793 int count;
792760b9 8794 rtx op1;
1fd4e8c1
RK
8795 int i;
8796
8797 /* Support only loading a constant number of fixed-point registers from
8798 memory and only bother with this if more than two; the machine
8799 doesn't support more than eight. */
8800 if (GET_CODE (operands[2]) != CONST_INT
8801 || INTVAL (operands[2]) <= 2
8802 || INTVAL (operands[2]) > 8
8803 || GET_CODE (operands[1]) != MEM
8804 || GET_CODE (operands[0]) != REG
8805 || REGNO (operands[0]) >= 32)
8806 FAIL;
8807
8808 count = INTVAL (operands[2]);
8809 regno = REGNO (operands[0]);
8810
39403d82 8811 operands[3] = gen_rtx_PARALLEL (VOIDmode, rtvec_alloc (count));
792760b9
RK
8812 op1 = replace_equiv_address (operands[1],
8813 force_reg (SImode, XEXP (operands[1], 0)));
1fd4e8c1
RK
8814
8815 for (i = 0; i < count; i++)
8816 XVECEXP (operands[3], 0, i)
39403d82 8817 = gen_rtx_SET (VOIDmode, gen_rtx_REG (SImode, regno + i),
7ef788f0 8818 adjust_address_nv (op1, SImode, i * 4));
1fd4e8c1
RK
8819}")
8820
9caa3eb2 8821(define_insn "*ldmsi8"
1fd4e8c1 8822 [(match_parallel 0 "load_multiple_operation"
9caa3eb2
DE
8823 [(set (match_operand:SI 2 "gpc_reg_operand" "")
8824 (mem:SI (match_operand:SI 1 "gpc_reg_operand" "b")))
8825 (set (match_operand:SI 3 "gpc_reg_operand" "")
8826 (mem:SI (plus:SI (match_dup 1) (const_int 4))))
8827 (set (match_operand:SI 4 "gpc_reg_operand" "")
8828 (mem:SI (plus:SI (match_dup 1) (const_int 8))))
8829 (set (match_operand:SI 5 "gpc_reg_operand" "")
8830 (mem:SI (plus:SI (match_dup 1) (const_int 12))))
8831 (set (match_operand:SI 6 "gpc_reg_operand" "")
8832 (mem:SI (plus:SI (match_dup 1) (const_int 16))))
8833 (set (match_operand:SI 7 "gpc_reg_operand" "")
8834 (mem:SI (plus:SI (match_dup 1) (const_int 20))))
8835 (set (match_operand:SI 8 "gpc_reg_operand" "")
8836 (mem:SI (plus:SI (match_dup 1) (const_int 24))))
8837 (set (match_operand:SI 9 "gpc_reg_operand" "")
8838 (mem:SI (plus:SI (match_dup 1) (const_int 28))))])]
8839 "TARGET_STRING && XVECLEN (operands[0], 0) == 8"
1fd4e8c1 8840 "*
9caa3eb2
DE
8841{ return rs6000_output_load_multiple (operands); }"
8842 [(set_attr "type" "load")
8843 (set_attr "length" "32")])
1fd4e8c1 8844
9caa3eb2
DE
8845(define_insn "*ldmsi7"
8846 [(match_parallel 0 "load_multiple_operation"
8847 [(set (match_operand:SI 2 "gpc_reg_operand" "")
8848 (mem:SI (match_operand:SI 1 "gpc_reg_operand" "b")))
8849 (set (match_operand:SI 3 "gpc_reg_operand" "")
8850 (mem:SI (plus:SI (match_dup 1) (const_int 4))))
8851 (set (match_operand:SI 4 "gpc_reg_operand" "")
8852 (mem:SI (plus:SI (match_dup 1) (const_int 8))))
8853 (set (match_operand:SI 5 "gpc_reg_operand" "")
8854 (mem:SI (plus:SI (match_dup 1) (const_int 12))))
8855 (set (match_operand:SI 6 "gpc_reg_operand" "")
8856 (mem:SI (plus:SI (match_dup 1) (const_int 16))))
8857 (set (match_operand:SI 7 "gpc_reg_operand" "")
8858 (mem:SI (plus:SI (match_dup 1) (const_int 20))))
8859 (set (match_operand:SI 8 "gpc_reg_operand" "")
8860 (mem:SI (plus:SI (match_dup 1) (const_int 24))))])]
8861 "TARGET_STRING && XVECLEN (operands[0], 0) == 7"
8862 "*
8863{ return rs6000_output_load_multiple (operands); }"
8864 [(set_attr "type" "load")
8865 (set_attr "length" "32")])
8866
8867(define_insn "*ldmsi6"
8868 [(match_parallel 0 "load_multiple_operation"
8869 [(set (match_operand:SI 2 "gpc_reg_operand" "")
8870 (mem:SI (match_operand:SI 1 "gpc_reg_operand" "b")))
8871 (set (match_operand:SI 3 "gpc_reg_operand" "")
8872 (mem:SI (plus:SI (match_dup 1) (const_int 4))))
8873 (set (match_operand:SI 4 "gpc_reg_operand" "")
8874 (mem:SI (plus:SI (match_dup 1) (const_int 8))))
8875 (set (match_operand:SI 5 "gpc_reg_operand" "")
8876 (mem:SI (plus:SI (match_dup 1) (const_int 12))))
8877 (set (match_operand:SI 6 "gpc_reg_operand" "")
8878 (mem:SI (plus:SI (match_dup 1) (const_int 16))))
8879 (set (match_operand:SI 7 "gpc_reg_operand" "")
8880 (mem:SI (plus:SI (match_dup 1) (const_int 20))))])]
8881 "TARGET_STRING && XVECLEN (operands[0], 0) == 6"
8882 "*
8883{ return rs6000_output_load_multiple (operands); }"
8884 [(set_attr "type" "load")
8885 (set_attr "length" "32")])
8886
8887(define_insn "*ldmsi5"
8888 [(match_parallel 0 "load_multiple_operation"
8889 [(set (match_operand:SI 2 "gpc_reg_operand" "")
8890 (mem:SI (match_operand:SI 1 "gpc_reg_operand" "b")))
8891 (set (match_operand:SI 3 "gpc_reg_operand" "")
8892 (mem:SI (plus:SI (match_dup 1) (const_int 4))))
8893 (set (match_operand:SI 4 "gpc_reg_operand" "")
8894 (mem:SI (plus:SI (match_dup 1) (const_int 8))))
8895 (set (match_operand:SI 5 "gpc_reg_operand" "")
8896 (mem:SI (plus:SI (match_dup 1) (const_int 12))))
8897 (set (match_operand:SI 6 "gpc_reg_operand" "")
8898 (mem:SI (plus:SI (match_dup 1) (const_int 16))))])]
8899 "TARGET_STRING && XVECLEN (operands[0], 0) == 5"
8900 "*
8901{ return rs6000_output_load_multiple (operands); }"
8902 [(set_attr "type" "load")
8903 (set_attr "length" "32")])
8904
8905(define_insn "*ldmsi4"
8906 [(match_parallel 0 "load_multiple_operation"
8907 [(set (match_operand:SI 2 "gpc_reg_operand" "")
8908 (mem:SI (match_operand:SI 1 "gpc_reg_operand" "b")))
8909 (set (match_operand:SI 3 "gpc_reg_operand" "")
8910 (mem:SI (plus:SI (match_dup 1) (const_int 4))))
8911 (set (match_operand:SI 4 "gpc_reg_operand" "")
8912 (mem:SI (plus:SI (match_dup 1) (const_int 8))))
8913 (set (match_operand:SI 5 "gpc_reg_operand" "")
8914 (mem:SI (plus:SI (match_dup 1) (const_int 12))))])]
8915 "TARGET_STRING && XVECLEN (operands[0], 0) == 4"
8916 "*
8917{ return rs6000_output_load_multiple (operands); }"
8918 [(set_attr "type" "load")
8919 (set_attr "length" "32")])
8920
8921(define_insn "*ldmsi3"
8922 [(match_parallel 0 "load_multiple_operation"
8923 [(set (match_operand:SI 2 "gpc_reg_operand" "")
8924 (mem:SI (match_operand:SI 1 "gpc_reg_operand" "b")))
8925 (set (match_operand:SI 3 "gpc_reg_operand" "")
8926 (mem:SI (plus:SI (match_dup 1) (const_int 4))))
8927 (set (match_operand:SI 4 "gpc_reg_operand" "")
8928 (mem:SI (plus:SI (match_dup 1) (const_int 8))))])]
8929 "TARGET_STRING && XVECLEN (operands[0], 0) == 3"
8930 "*
8931{ return rs6000_output_load_multiple (operands); }"
b19003d8 8932 [(set_attr "type" "load")
e82ee4cc 8933 (set_attr "length" "32")])
b19003d8 8934
1fd4e8c1 8935(define_expand "store_multiple"
2f622005
RK
8936 [(match_par_dup 3 [(set (match_operand:SI 0 "" "")
8937 (match_operand:SI 1 "" ""))
8938 (clobber (scratch:SI))
8939 (use (match_operand:SI 2 "" ""))])]
09a625f7 8940 "TARGET_STRING && !TARGET_POWERPC64"
1fd4e8c1
RK
8941 "
8942{
8943 int regno;
8944 int count;
8945 rtx to;
792760b9 8946 rtx op0;
1fd4e8c1
RK
8947 int i;
8948
8949 /* Support only storing a constant number of fixed-point registers to
8950 memory and only bother with this if more than two; the machine
8951 doesn't support more than eight. */
8952 if (GET_CODE (operands[2]) != CONST_INT
8953 || INTVAL (operands[2]) <= 2
8954 || INTVAL (operands[2]) > 8
8955 || GET_CODE (operands[0]) != MEM
8956 || GET_CODE (operands[1]) != REG
8957 || REGNO (operands[1]) >= 32)
8958 FAIL;
8959
8960 count = INTVAL (operands[2]);
8961 regno = REGNO (operands[1]);
8962
39403d82 8963 operands[3] = gen_rtx_PARALLEL (VOIDmode, rtvec_alloc (count + 1));
1fd4e8c1 8964 to = force_reg (SImode, XEXP (operands[0], 0));
792760b9 8965 op0 = replace_equiv_address (operands[0], to);
1fd4e8c1
RK
8966
8967 XVECEXP (operands[3], 0, 0)
7ef788f0 8968 = gen_rtx_SET (VOIDmode, adjust_address_nv (op0, SImode, 0), operands[1]);
39403d82 8969 XVECEXP (operands[3], 0, 1) = gen_rtx_CLOBBER (VOIDmode,
c5c76735 8970 gen_rtx_SCRATCH (SImode));
1fd4e8c1
RK
8971
8972 for (i = 1; i < count; i++)
8973 XVECEXP (operands[3], 0, i + 1)
39403d82 8974 = gen_rtx_SET (VOIDmode,
7ef788f0 8975 adjust_address_nv (op0, SImode, i * 4),
c5c76735 8976 gen_rtx_REG (SImode, regno + i));
1fd4e8c1
RK
8977}")
8978
9caa3eb2 8979(define_insn "*store_multiple_power"
1fd4e8c1
RK
8980 [(match_parallel 0 "store_multiple_operation"
8981 [(set (match_operand:SI 1 "indirect_operand" "=Q")
cd2b37d9 8982 (match_operand:SI 2 "gpc_reg_operand" "r"))
1fd4e8c1 8983 (clobber (match_scratch:SI 3 "=q"))])]
7e69e155 8984 "TARGET_STRING && TARGET_POWER"
b7ff3d82
DE
8985 "{stsi|stswi} %2,%P1,%O0"
8986 [(set_attr "type" "store")])
d14a6d05 8987
e46e3130 8988(define_insn "*stmsi8"
d14a6d05 8989 [(match_parallel 0 "store_multiple_operation"
e46e3130
DJ
8990 [(set (mem:SI (match_operand:SI 1 "gpc_reg_operand" "b"))
8991 (match_operand:SI 2 "gpc_reg_operand" "r"))
8992 (clobber (match_scratch:SI 3 "X"))
8993 (set (mem:SI (plus:SI (match_dup 1) (const_int 4)))
8994 (match_operand:SI 4 "gpc_reg_operand" "r"))
8995 (set (mem:SI (plus:SI (match_dup 1) (const_int 8)))
8996 (match_operand:SI 5 "gpc_reg_operand" "r"))
8997 (set (mem:SI (plus:SI (match_dup 1) (const_int 12)))
8998 (match_operand:SI 6 "gpc_reg_operand" "r"))
8999 (set (mem:SI (plus:SI (match_dup 1) (const_int 16)))
9000 (match_operand:SI 7 "gpc_reg_operand" "r"))
9001 (set (mem:SI (plus:SI (match_dup 1) (const_int 20)))
9002 (match_operand:SI 8 "gpc_reg_operand" "r"))
9003 (set (mem:SI (plus:SI (match_dup 1) (const_int 24)))
9004 (match_operand:SI 9 "gpc_reg_operand" "r"))
9005 (set (mem:SI (plus:SI (match_dup 1) (const_int 28)))
9006 (match_operand:SI 10 "gpc_reg_operand" "r"))])]
9007 "TARGET_STRING && !TARGET_POWER && XVECLEN (operands[0], 0) == 9"
9008 "{stsi|stswi} %2,%1,%O0"
9009 [(set_attr "type" "store")])
9010
9011(define_insn "*stmsi7"
9012 [(match_parallel 0 "store_multiple_operation"
9013 [(set (mem:SI (match_operand:SI 1 "gpc_reg_operand" "b"))
9014 (match_operand:SI 2 "gpc_reg_operand" "r"))
9015 (clobber (match_scratch:SI 3 "X"))
9016 (set (mem:SI (plus:SI (match_dup 1) (const_int 4)))
9017 (match_operand:SI 4 "gpc_reg_operand" "r"))
9018 (set (mem:SI (plus:SI (match_dup 1) (const_int 8)))
9019 (match_operand:SI 5 "gpc_reg_operand" "r"))
9020 (set (mem:SI (plus:SI (match_dup 1) (const_int 12)))
9021 (match_operand:SI 6 "gpc_reg_operand" "r"))
9022 (set (mem:SI (plus:SI (match_dup 1) (const_int 16)))
9023 (match_operand:SI 7 "gpc_reg_operand" "r"))
9024 (set (mem:SI (plus:SI (match_dup 1) (const_int 20)))
9025 (match_operand:SI 8 "gpc_reg_operand" "r"))
9026 (set (mem:SI (plus:SI (match_dup 1) (const_int 24)))
9027 (match_operand:SI 9 "gpc_reg_operand" "r"))])]
9028 "TARGET_STRING && !TARGET_POWER && XVECLEN (operands[0], 0) == 8"
9029 "{stsi|stswi} %2,%1,%O0"
9030 [(set_attr "type" "store")])
9031
9032(define_insn "*stmsi6"
9033 [(match_parallel 0 "store_multiple_operation"
9034 [(set (mem:SI (match_operand:SI 1 "gpc_reg_operand" "b"))
9035 (match_operand:SI 2 "gpc_reg_operand" "r"))
9036 (clobber (match_scratch:SI 3 "X"))
9037 (set (mem:SI (plus:SI (match_dup 1) (const_int 4)))
9038 (match_operand:SI 4 "gpc_reg_operand" "r"))
9039 (set (mem:SI (plus:SI (match_dup 1) (const_int 8)))
9040 (match_operand:SI 5 "gpc_reg_operand" "r"))
9041 (set (mem:SI (plus:SI (match_dup 1) (const_int 12)))
9042 (match_operand:SI 6 "gpc_reg_operand" "r"))
9043 (set (mem:SI (plus:SI (match_dup 1) (const_int 16)))
9044 (match_operand:SI 7 "gpc_reg_operand" "r"))
9045 (set (mem:SI (plus:SI (match_dup 1) (const_int 20)))
9046 (match_operand:SI 8 "gpc_reg_operand" "r"))])]
9047 "TARGET_STRING && !TARGET_POWER && XVECLEN (operands[0], 0) == 7"
9048 "{stsi|stswi} %2,%1,%O0"
9049 [(set_attr "type" "store")])
9050
9051(define_insn "*stmsi5"
9052 [(match_parallel 0 "store_multiple_operation"
9053 [(set (mem:SI (match_operand:SI 1 "gpc_reg_operand" "b"))
9054 (match_operand:SI 2 "gpc_reg_operand" "r"))
9055 (clobber (match_scratch:SI 3 "X"))
9056 (set (mem:SI (plus:SI (match_dup 1) (const_int 4)))
9057 (match_operand:SI 4 "gpc_reg_operand" "r"))
9058 (set (mem:SI (plus:SI (match_dup 1) (const_int 8)))
9059 (match_operand:SI 5 "gpc_reg_operand" "r"))
9060 (set (mem:SI (plus:SI (match_dup 1) (const_int 12)))
9061 (match_operand:SI 6 "gpc_reg_operand" "r"))
9062 (set (mem:SI (plus:SI (match_dup 1) (const_int 16)))
9063 (match_operand:SI 7 "gpc_reg_operand" "r"))])]
9064 "TARGET_STRING && !TARGET_POWER && XVECLEN (operands[0], 0) == 6"
9065 "{stsi|stswi} %2,%1,%O0"
9066 [(set_attr "type" "store")])
9067
9068(define_insn "*stmsi4"
9069 [(match_parallel 0 "store_multiple_operation"
9070 [(set (mem:SI (match_operand:SI 1 "gpc_reg_operand" "b"))
9071 (match_operand:SI 2 "gpc_reg_operand" "r"))
9072 (clobber (match_scratch:SI 3 "X"))
9073 (set (mem:SI (plus:SI (match_dup 1) (const_int 4)))
9074 (match_operand:SI 4 "gpc_reg_operand" "r"))
9075 (set (mem:SI (plus:SI (match_dup 1) (const_int 8)))
9076 (match_operand:SI 5 "gpc_reg_operand" "r"))
9077 (set (mem:SI (plus:SI (match_dup 1) (const_int 12)))
9078 (match_operand:SI 6 "gpc_reg_operand" "r"))])]
9079 "TARGET_STRING && !TARGET_POWER && XVECLEN (operands[0], 0) == 5"
b7ff3d82
DE
9080 "{stsi|stswi} %2,%1,%O0"
9081 [(set_attr "type" "store")])
7e69e155 9082
e46e3130
DJ
9083(define_insn "*stmsi3"
9084 [(match_parallel 0 "store_multiple_operation"
9085 [(set (mem:SI (match_operand:SI 1 "gpc_reg_operand" "b"))
9086 (match_operand:SI 2 "gpc_reg_operand" "r"))
9087 (clobber (match_scratch:SI 3 "X"))
9088 (set (mem:SI (plus:SI (match_dup 1) (const_int 4)))
9089 (match_operand:SI 4 "gpc_reg_operand" "r"))
9090 (set (mem:SI (plus:SI (match_dup 1) (const_int 8)))
9091 (match_operand:SI 5 "gpc_reg_operand" "r"))])]
9092 "TARGET_STRING && !TARGET_POWER && XVECLEN (operands[0], 0) == 4"
9093 "{stsi|stswi} %2,%1,%O0"
9094 [(set_attr "type" "store")])
7e69e155 9095\f
fba73eb1
DE
9096(define_expand "clrmemsi"
9097 [(parallel [(set (match_operand:BLK 0 "" "")
9098 (const_int 0))
9099 (use (match_operand:SI 1 "" ""))
9100 (use (match_operand:SI 2 "" ""))])]
9101 ""
9102 "
9103{
9104 if (expand_block_clear (operands))
9105 DONE;
9106 else
9107 FAIL;
9108}")
9109
7e69e155
MM
9110;; String/block move insn.
9111;; Argument 0 is the destination
9112;; Argument 1 is the source
9113;; Argument 2 is the length
9114;; Argument 3 is the alignment
9115
70128ad9 9116(define_expand "movmemsi"
b6c9286a
MM
9117 [(parallel [(set (match_operand:BLK 0 "" "")
9118 (match_operand:BLK 1 "" ""))
9119 (use (match_operand:SI 2 "" ""))
9120 (use (match_operand:SI 3 "" ""))])]
7e69e155
MM
9121 ""
9122 "
9123{
9124 if (expand_block_move (operands))
9125 DONE;
9126 else
9127 FAIL;
9128}")
9129
9130;; Move up to 32 bytes at a time. The fixed registers are needed because the
f9562f27
DE
9131;; register allocator doesn't have a clue about allocating 8 word registers.
9132;; rD/rS = r5 is preferred, efficient form.
70128ad9 9133(define_expand "movmemsi_8reg"
b6c9286a
MM
9134 [(parallel [(set (match_operand 0 "" "")
9135 (match_operand 1 "" ""))
9136 (use (match_operand 2 "" ""))
9137 (use (match_operand 3 "" ""))
7e69e155
MM
9138 (clobber (reg:SI 5))
9139 (clobber (reg:SI 6))
9140 (clobber (reg:SI 7))
9141 (clobber (reg:SI 8))
9142 (clobber (reg:SI 9))
9143 (clobber (reg:SI 10))
9144 (clobber (reg:SI 11))
9145 (clobber (reg:SI 12))
3c67b673 9146 (clobber (match_scratch:SI 4 ""))])]
7e69e155
MM
9147 "TARGET_STRING"
9148 "")
9149
9150(define_insn ""
52d3af72
DE
9151 [(set (mem:BLK (match_operand:SI 0 "gpc_reg_operand" "b"))
9152 (mem:BLK (match_operand:SI 1 "gpc_reg_operand" "b")))
3c67b673
RK
9153 (use (match_operand:SI 2 "immediate_operand" "i"))
9154 (use (match_operand:SI 3 "immediate_operand" "i"))
52d3af72 9155 (clobber (match_operand:SI 4 "gpc_reg_operand" "=r"))
7e69e155
MM
9156 (clobber (reg:SI 6))
9157 (clobber (reg:SI 7))
9158 (clobber (reg:SI 8))
9159 (clobber (reg:SI 9))
9160 (clobber (reg:SI 10))
9161 (clobber (reg:SI 11))
9162 (clobber (reg:SI 12))
3c67b673 9163 (clobber (match_scratch:SI 5 "=q"))]
7e69e155 9164 "TARGET_STRING && TARGET_POWER
f9562f27
DE
9165 && ((INTVAL (operands[2]) > 24 && INTVAL (operands[2]) < 32)
9166 || INTVAL (operands[2]) == 0)
7e69e155
MM
9167 && (REGNO (operands[0]) < 5 || REGNO (operands[0]) > 12)
9168 && (REGNO (operands[1]) < 5 || REGNO (operands[1]) > 12)
3c67b673
RK
9169 && REGNO (operands[4]) == 5"
9170 "{lsi|lswi} %4,%1,%2\;{stsi|stswi} %4,%0,%2"
b7ff3d82
DE
9171 [(set_attr "type" "load")
9172 (set_attr "length" "8")])
7e69e155
MM
9173
9174(define_insn ""
52d3af72
DE
9175 [(set (mem:BLK (match_operand:SI 0 "gpc_reg_operand" "b"))
9176 (mem:BLK (match_operand:SI 1 "gpc_reg_operand" "b")))
3c67b673
RK
9177 (use (match_operand:SI 2 "immediate_operand" "i"))
9178 (use (match_operand:SI 3 "immediate_operand" "i"))
52d3af72 9179 (clobber (match_operand:SI 4 "gpc_reg_operand" "=r"))
7e69e155
MM
9180 (clobber (reg:SI 6))
9181 (clobber (reg:SI 7))
9182 (clobber (reg:SI 8))
9183 (clobber (reg:SI 9))
9184 (clobber (reg:SI 10))
9185 (clobber (reg:SI 11))
9186 (clobber (reg:SI 12))
3c67b673 9187 (clobber (match_scratch:SI 5 "X"))]
0ad91047 9188 "TARGET_STRING && ! TARGET_POWER
f9562f27
DE
9189 && ((INTVAL (operands[2]) > 24 && INTVAL (operands[2]) < 32)
9190 || INTVAL (operands[2]) == 0)
7e69e155
MM
9191 && (REGNO (operands[0]) < 5 || REGNO (operands[0]) > 12)
9192 && (REGNO (operands[1]) < 5 || REGNO (operands[1]) > 12)
3c67b673
RK
9193 && REGNO (operands[4]) == 5"
9194 "{lsi|lswi} %4,%1,%2\;{stsi|stswi} %4,%0,%2"
b7ff3d82
DE
9195 [(set_attr "type" "load")
9196 (set_attr "length" "8")])
7e69e155 9197
09a625f7
TR
9198(define_insn ""
9199 [(set (mem:BLK (match_operand:DI 0 "gpc_reg_operand" "b"))
9200 (mem:BLK (match_operand:DI 1 "gpc_reg_operand" "b")))
9201 (use (match_operand:SI 2 "immediate_operand" "i"))
9202 (use (match_operand:SI 3 "immediate_operand" "i"))
9203 (clobber (match_operand:SI 4 "gpc_reg_operand" "=r"))
9204 (clobber (reg:SI 6))
9205 (clobber (reg:SI 7))
9206 (clobber (reg:SI 8))
9207 (clobber (reg:SI 9))
9208 (clobber (reg:SI 10))
9209 (clobber (reg:SI 11))
9210 (clobber (reg:SI 12))
9211 (clobber (match_scratch:SI 5 "X"))]
9212 "TARGET_STRING && TARGET_POWERPC64
9213 && ((INTVAL (operands[2]) > 24 && INTVAL (operands[2]) < 32)
9214 || INTVAL (operands[2]) == 0)
9215 && (REGNO (operands[0]) < 5 || REGNO (operands[0]) > 12)
9216 && (REGNO (operands[1]) < 5 || REGNO (operands[1]) > 12)
9217 && REGNO (operands[4]) == 5"
9218 "{lsi|lswi} %4,%1,%2\;{stsi|stswi} %4,%0,%2"
9219 [(set_attr "type" "load")
9220 (set_attr "length" "8")])
9221
7e69e155 9222;; Move up to 24 bytes at a time. The fixed registers are needed because the
f9562f27
DE
9223;; register allocator doesn't have a clue about allocating 6 word registers.
9224;; rD/rS = r5 is preferred, efficient form.
70128ad9 9225(define_expand "movmemsi_6reg"
b6c9286a
MM
9226 [(parallel [(set (match_operand 0 "" "")
9227 (match_operand 1 "" ""))
9228 (use (match_operand 2 "" ""))
9229 (use (match_operand 3 "" ""))
f9562f27
DE
9230 (clobber (reg:SI 5))
9231 (clobber (reg:SI 6))
7e69e155
MM
9232 (clobber (reg:SI 7))
9233 (clobber (reg:SI 8))
9234 (clobber (reg:SI 9))
9235 (clobber (reg:SI 10))
3c67b673 9236 (clobber (match_scratch:SI 4 ""))])]
7e69e155
MM
9237 "TARGET_STRING"
9238 "")
9239
9240(define_insn ""
52d3af72
DE
9241 [(set (mem:BLK (match_operand:SI 0 "gpc_reg_operand" "b"))
9242 (mem:BLK (match_operand:SI 1 "gpc_reg_operand" "b")))
3c67b673
RK
9243 (use (match_operand:SI 2 "immediate_operand" "i"))
9244 (use (match_operand:SI 3 "immediate_operand" "i"))
52d3af72 9245 (clobber (match_operand:SI 4 "gpc_reg_operand" "=r"))
f9562f27
DE
9246 (clobber (reg:SI 6))
9247 (clobber (reg:SI 7))
7e69e155
MM
9248 (clobber (reg:SI 8))
9249 (clobber (reg:SI 9))
9250 (clobber (reg:SI 10))
3c67b673 9251 (clobber (match_scratch:SI 5 "=q"))]
7e69e155
MM
9252 "TARGET_STRING && TARGET_POWER
9253 && INTVAL (operands[2]) > 16 && INTVAL (operands[2]) <= 24
f9562f27
DE
9254 && (REGNO (operands[0]) < 5 || REGNO (operands[0]) > 10)
9255 && (REGNO (operands[1]) < 5 || REGNO (operands[1]) > 10)
9256 && REGNO (operands[4]) == 5"
3c67b673 9257 "{lsi|lswi} %4,%1,%2\;{stsi|stswi} %4,%0,%2"
b7ff3d82
DE
9258 [(set_attr "type" "load")
9259 (set_attr "length" "8")])
7e69e155
MM
9260
9261(define_insn ""
52d3af72
DE
9262 [(set (mem:BLK (match_operand:SI 0 "gpc_reg_operand" "b"))
9263 (mem:BLK (match_operand:SI 1 "gpc_reg_operand" "b")))
3c67b673
RK
9264 (use (match_operand:SI 2 "immediate_operand" "i"))
9265 (use (match_operand:SI 3 "immediate_operand" "i"))
52d3af72 9266 (clobber (match_operand:SI 4 "gpc_reg_operand" "=r"))
f9562f27
DE
9267 (clobber (reg:SI 6))
9268 (clobber (reg:SI 7))
7e69e155
MM
9269 (clobber (reg:SI 8))
9270 (clobber (reg:SI 9))
9271 (clobber (reg:SI 10))
3c67b673 9272 (clobber (match_scratch:SI 5 "X"))]
0ad91047 9273 "TARGET_STRING && ! TARGET_POWER
7e69e155 9274 && INTVAL (operands[2]) > 16 && INTVAL (operands[2]) <= 32
f9562f27
DE
9275 && (REGNO (operands[0]) < 5 || REGNO (operands[0]) > 10)
9276 && (REGNO (operands[1]) < 5 || REGNO (operands[1]) > 10)
9277 && REGNO (operands[4]) == 5"
3c67b673 9278 "{lsi|lswi} %4,%1,%2\;{stsi|stswi} %4,%0,%2"
b7ff3d82
DE
9279 [(set_attr "type" "load")
9280 (set_attr "length" "8")])
7e69e155 9281
09a625f7
TR
9282(define_insn ""
9283 [(set (mem:BLK (match_operand:DI 0 "gpc_reg_operand" "b"))
9284 (mem:BLK (match_operand:DI 1 "gpc_reg_operand" "b")))
9285 (use (match_operand:SI 2 "immediate_operand" "i"))
9286 (use (match_operand:SI 3 "immediate_operand" "i"))
9287 (clobber (match_operand:SI 4 "gpc_reg_operand" "=r"))
9288 (clobber (reg:SI 6))
9289 (clobber (reg:SI 7))
9290 (clobber (reg:SI 8))
9291 (clobber (reg:SI 9))
9292 (clobber (reg:SI 10))
9293 (clobber (match_scratch:SI 5 "X"))]
9294 "TARGET_STRING && TARGET_POWERPC64
9295 && INTVAL (operands[2]) > 16 && INTVAL (operands[2]) <= 32
9296 && (REGNO (operands[0]) < 5 || REGNO (operands[0]) > 10)
9297 && (REGNO (operands[1]) < 5 || REGNO (operands[1]) > 10)
9298 && REGNO (operands[4]) == 5"
9299 "{lsi|lswi} %4,%1,%2\;{stsi|stswi} %4,%0,%2"
9300 [(set_attr "type" "load")
9301 (set_attr "length" "8")])
9302
f9562f27
DE
9303;; Move up to 16 bytes at a time, using 4 fixed registers to avoid spill
9304;; problems with TImode.
9305;; rD/rS = r5 is preferred, efficient form.
70128ad9 9306(define_expand "movmemsi_4reg"
b6c9286a
MM
9307 [(parallel [(set (match_operand 0 "" "")
9308 (match_operand 1 "" ""))
9309 (use (match_operand 2 "" ""))
9310 (use (match_operand 3 "" ""))
f9562f27
DE
9311 (clobber (reg:SI 5))
9312 (clobber (reg:SI 6))
9313 (clobber (reg:SI 7))
9314 (clobber (reg:SI 8))
3c67b673 9315 (clobber (match_scratch:SI 4 ""))])]
7e69e155
MM
9316 "TARGET_STRING"
9317 "")
9318
9319(define_insn ""
52d3af72
DE
9320 [(set (mem:BLK (match_operand:SI 0 "gpc_reg_operand" "b"))
9321 (mem:BLK (match_operand:SI 1 "gpc_reg_operand" "b")))
3c67b673
RK
9322 (use (match_operand:SI 2 "immediate_operand" "i"))
9323 (use (match_operand:SI 3 "immediate_operand" "i"))
52d3af72 9324 (clobber (match_operand:SI 4 "gpc_reg_operand" "=r"))
f9562f27
DE
9325 (clobber (reg:SI 6))
9326 (clobber (reg:SI 7))
9327 (clobber (reg:SI 8))
3c67b673 9328 (clobber (match_scratch:SI 5 "=q"))]
7e69e155
MM
9329 "TARGET_STRING && TARGET_POWER
9330 && INTVAL (operands[2]) > 8 && INTVAL (operands[2]) <= 16
f9562f27
DE
9331 && (REGNO (operands[0]) < 5 || REGNO (operands[0]) > 8)
9332 && (REGNO (operands[1]) < 5 || REGNO (operands[1]) > 8)
9333 && REGNO (operands[4]) == 5"
3c67b673 9334 "{lsi|lswi} %4,%1,%2\;{stsi|stswi} %4,%0,%2"
b7ff3d82
DE
9335 [(set_attr "type" "load")
9336 (set_attr "length" "8")])
7e69e155
MM
9337
9338(define_insn ""
52d3af72
DE
9339 [(set (mem:BLK (match_operand:SI 0 "gpc_reg_operand" "b"))
9340 (mem:BLK (match_operand:SI 1 "gpc_reg_operand" "b")))
3c67b673
RK
9341 (use (match_operand:SI 2 "immediate_operand" "i"))
9342 (use (match_operand:SI 3 "immediate_operand" "i"))
52d3af72 9343 (clobber (match_operand:SI 4 "gpc_reg_operand" "=r"))
f9562f27
DE
9344 (clobber (reg:SI 6))
9345 (clobber (reg:SI 7))
9346 (clobber (reg:SI 8))
3c67b673 9347 (clobber (match_scratch:SI 5 "X"))]
0ad91047 9348 "TARGET_STRING && ! TARGET_POWER
7e69e155 9349 && INTVAL (operands[2]) > 8 && INTVAL (operands[2]) <= 16
f9562f27
DE
9350 && (REGNO (operands[0]) < 5 || REGNO (operands[0]) > 8)
9351 && (REGNO (operands[1]) < 5 || REGNO (operands[1]) > 8)
9352 && REGNO (operands[4]) == 5"
3c67b673 9353 "{lsi|lswi} %4,%1,%2\;{stsi|stswi} %4,%0,%2"
b7ff3d82
DE
9354 [(set_attr "type" "load")
9355 (set_attr "length" "8")])
7e69e155 9356
09a625f7
TR
9357(define_insn ""
9358 [(set (mem:BLK (match_operand:DI 0 "gpc_reg_operand" "b"))
9359 (mem:BLK (match_operand:DI 1 "gpc_reg_operand" "b")))
9360 (use (match_operand:SI 2 "immediate_operand" "i"))
9361 (use (match_operand:SI 3 "immediate_operand" "i"))
9362 (clobber (match_operand:SI 4 "gpc_reg_operand" "=r"))
9363 (clobber (reg:SI 6))
9364 (clobber (reg:SI 7))
9365 (clobber (reg:SI 8))
9366 (clobber (match_scratch:SI 5 "X"))]
9367 "TARGET_STRING && TARGET_POWERPC64
9368 && INTVAL (operands[2]) > 8 && INTVAL (operands[2]) <= 16
9369 && (REGNO (operands[0]) < 5 || REGNO (operands[0]) > 8)
9370 && (REGNO (operands[1]) < 5 || REGNO (operands[1]) > 8)
9371 && REGNO (operands[4]) == 5"
9372 "{lsi|lswi} %4,%1,%2\;{stsi|stswi} %4,%0,%2"
9373 [(set_attr "type" "load")
9374 (set_attr "length" "8")])
9375
7e69e155 9376;; Move up to 8 bytes at a time.
70128ad9 9377(define_expand "movmemsi_2reg"
b6c9286a
MM
9378 [(parallel [(set (match_operand 0 "" "")
9379 (match_operand 1 "" ""))
9380 (use (match_operand 2 "" ""))
9381 (use (match_operand 3 "" ""))
3c67b673
RK
9382 (clobber (match_scratch:DI 4 ""))
9383 (clobber (match_scratch:SI 5 ""))])]
f9562f27 9384 "TARGET_STRING && ! TARGET_POWERPC64"
7e69e155
MM
9385 "")
9386
9387(define_insn ""
52d3af72
DE
9388 [(set (mem:BLK (match_operand:SI 0 "gpc_reg_operand" "b"))
9389 (mem:BLK (match_operand:SI 1 "gpc_reg_operand" "b")))
3c67b673
RK
9390 (use (match_operand:SI 2 "immediate_operand" "i"))
9391 (use (match_operand:SI 3 "immediate_operand" "i"))
9392 (clobber (match_scratch:DI 4 "=&r"))
9393 (clobber (match_scratch:SI 5 "=q"))]
f9562f27 9394 "TARGET_STRING && TARGET_POWER && ! TARGET_POWERPC64
3c67b673
RK
9395 && INTVAL (operands[2]) > 4 && INTVAL (operands[2]) <= 8"
9396 "{lsi|lswi} %4,%1,%2\;{stsi|stswi} %4,%0,%2"
b7ff3d82
DE
9397 [(set_attr "type" "load")
9398 (set_attr "length" "8")])
7e69e155
MM
9399
9400(define_insn ""
52d3af72
DE
9401 [(set (mem:BLK (match_operand:SI 0 "gpc_reg_operand" "b"))
9402 (mem:BLK (match_operand:SI 1 "gpc_reg_operand" "b")))
3c67b673
RK
9403 (use (match_operand:SI 2 "immediate_operand" "i"))
9404 (use (match_operand:SI 3 "immediate_operand" "i"))
9405 (clobber (match_scratch:DI 4 "=&r"))
9406 (clobber (match_scratch:SI 5 "X"))]
f9562f27 9407 "TARGET_STRING && ! TARGET_POWER && ! TARGET_POWERPC64
7e69e155 9408 && INTVAL (operands[2]) > 4 && INTVAL (operands[2]) <= 8"
3c67b673 9409 "{lsi|lswi} %4,%1,%2\;{stsi|stswi} %4,%0,%2"
b7ff3d82
DE
9410 [(set_attr "type" "load")
9411 (set_attr "length" "8")])
7e69e155
MM
9412
9413;; Move up to 4 bytes at a time.
70128ad9 9414(define_expand "movmemsi_1reg"
b6c9286a
MM
9415 [(parallel [(set (match_operand 0 "" "")
9416 (match_operand 1 "" ""))
9417 (use (match_operand 2 "" ""))
9418 (use (match_operand 3 "" ""))
3c67b673
RK
9419 (clobber (match_scratch:SI 4 ""))
9420 (clobber (match_scratch:SI 5 ""))])]
7e69e155
MM
9421 "TARGET_STRING"
9422 "")
9423
9424(define_insn ""
52d3af72
DE
9425 [(set (mem:BLK (match_operand:SI 0 "gpc_reg_operand" "b"))
9426 (mem:BLK (match_operand:SI 1 "gpc_reg_operand" "b")))
3c67b673
RK
9427 (use (match_operand:SI 2 "immediate_operand" "i"))
9428 (use (match_operand:SI 3 "immediate_operand" "i"))
9429 (clobber (match_scratch:SI 4 "=&r"))
9430 (clobber (match_scratch:SI 5 "=q"))]
7e69e155
MM
9431 "TARGET_STRING && TARGET_POWER
9432 && INTVAL (operands[2]) > 0 && INTVAL (operands[2]) <= 4"
3c67b673 9433 "{lsi|lswi} %4,%1,%2\;{stsi|stswi} %4,%0,%2"
b7ff3d82
DE
9434 [(set_attr "type" "load")
9435 (set_attr "length" "8")])
7e69e155
MM
9436
9437(define_insn ""
52d3af72
DE
9438 [(set (mem:BLK (match_operand:SI 0 "gpc_reg_operand" "b"))
9439 (mem:BLK (match_operand:SI 1 "gpc_reg_operand" "b")))
3c67b673
RK
9440 (use (match_operand:SI 2 "immediate_operand" "i"))
9441 (use (match_operand:SI 3 "immediate_operand" "i"))
9442 (clobber (match_scratch:SI 4 "=&r"))
9443 (clobber (match_scratch:SI 5 "X"))]
0ad91047 9444 "TARGET_STRING && ! TARGET_POWER
7e69e155 9445 && INTVAL (operands[2]) > 0 && INTVAL (operands[2]) <= 4"
09a625f7
TR
9446 "{lsi|lswi} %4,%1,%2\;{stsi|stswi} %4,%0,%2"
9447 [(set_attr "type" "load")
9448 (set_attr "length" "8")])
9449
9450(define_insn ""
9451 [(set (mem:BLK (match_operand:DI 0 "gpc_reg_operand" "b"))
9452 (mem:BLK (match_operand:DI 1 "gpc_reg_operand" "b")))
9453 (use (match_operand:SI 2 "immediate_operand" "i"))
9454 (use (match_operand:SI 3 "immediate_operand" "i"))
9455 (clobber (match_scratch:SI 4 "=&r"))
9456 (clobber (match_scratch:SI 5 "X"))]
9457 "TARGET_STRING && TARGET_POWERPC64
9458 && INTVAL (operands[2]) > 0 && INTVAL (operands[2]) <= 4"
3c67b673 9459 "{lsi|lswi} %4,%1,%2\;{stsi|stswi} %4,%0,%2"
b7ff3d82
DE
9460 [(set_attr "type" "load")
9461 (set_attr "length" "8")])
7e69e155 9462
1fd4e8c1 9463\f
7e69e155 9464;; Define insns that do load or store with update. Some of these we can
1fd4e8c1
RK
9465;; get by using pre-decrement or pre-increment, but the hardware can also
9466;; do cases where the increment is not the size of the object.
9467;;
9468;; In all these cases, we use operands 0 and 1 for the register being
9469;; incremented because those are the operands that local-alloc will
9470;; tie and these are the pair most likely to be tieable (and the ones
9471;; that will benefit the most).
9472
38c1f2d7 9473(define_insn "*movdi_update1"
51b8fc2c 9474 [(set (match_operand:DI 3 "gpc_reg_operand" "=r,r")
ad8bd902 9475 (mem:DI (plus:DI (match_operand:DI 1 "gpc_reg_operand" "0,0")
768070a0 9476 (match_operand:DI 2 "reg_or_aligned_short_operand" "r,I"))))
51b8fc2c
RK
9477 (set (match_operand:DI 0 "gpc_reg_operand" "=b,b")
9478 (plus:DI (match_dup 1) (match_dup 2)))]
38c1f2d7 9479 "TARGET_POWERPC64 && TARGET_UPDATE"
51b8fc2c
RK
9480 "@
9481 ldux %3,%0,%2
9482 ldu %3,%2(%0)"
b54cf83a 9483 [(set_attr "type" "load_ux,load_u")])
287f13ff 9484
4697a36c 9485(define_insn "movdi_update"
51b8fc2c 9486 [(set (mem:DI (plus:DI (match_operand:DI 1 "gpc_reg_operand" "0,0")
768070a0 9487 (match_operand:DI 2 "reg_or_aligned_short_operand" "r,I")))
51b8fc2c
RK
9488 (match_operand:DI 3 "gpc_reg_operand" "r,r"))
9489 (set (match_operand:DI 0 "gpc_reg_operand" "=b,b")
9490 (plus:DI (match_dup 1) (match_dup 2)))]
38c1f2d7 9491 "TARGET_POWERPC64 && TARGET_UPDATE"
51b8fc2c
RK
9492 "@
9493 stdux %3,%0,%2
b7ff3d82 9494 stdu %3,%2(%0)"
b54cf83a 9495 [(set_attr "type" "store_ux,store_u")])
51b8fc2c 9496
38c1f2d7 9497(define_insn "*movsi_update1"
cd2b37d9
RK
9498 [(set (match_operand:SI 3 "gpc_reg_operand" "=r,r")
9499 (mem:SI (plus:SI (match_operand:SI 1 "gpc_reg_operand" "0,0")
1fd4e8c1 9500 (match_operand:SI 2 "reg_or_short_operand" "r,I"))))
cd2b37d9 9501 (set (match_operand:SI 0 "gpc_reg_operand" "=b,b")
1fd4e8c1 9502 (plus:SI (match_dup 1) (match_dup 2)))]
f7b3ab8a 9503 "TARGET_UPDATE"
1fd4e8c1 9504 "@
ca7f5001
RK
9505 {lux|lwzux} %3,%0,%2
9506 {lu|lwzu} %3,%2(%0)"
b54cf83a
DE
9507 [(set_attr "type" "load_ux,load_u")])
9508
9509(define_insn "*movsi_update2"
9510 [(set (match_operand:DI 3 "gpc_reg_operand" "=r")
9511 (sign_extend:DI
9512 (mem:SI (plus:DI (match_operand:DI 1 "gpc_reg_operand" "0")
9513 (match_operand:DI 2 "gpc_reg_operand" "r")))))
9514 (set (match_operand:DI 0 "gpc_reg_operand" "=b")
9515 (plus:DI (match_dup 1) (match_dup 2)))]
9516 "TARGET_POWERPC64"
9517 "lwaux %3,%0,%2"
9518 [(set_attr "type" "load_ext_ux")])
1fd4e8c1 9519
4697a36c 9520(define_insn "movsi_update"
cd2b37d9 9521 [(set (mem:SI (plus:SI (match_operand:SI 1 "gpc_reg_operand" "0,0")
1fd4e8c1 9522 (match_operand:SI 2 "reg_or_short_operand" "r,I")))
cd2b37d9
RK
9523 (match_operand:SI 3 "gpc_reg_operand" "r,r"))
9524 (set (match_operand:SI 0 "gpc_reg_operand" "=b,b")
1fd4e8c1 9525 (plus:SI (match_dup 1) (match_dup 2)))]
38c1f2d7 9526 "TARGET_UPDATE"
1fd4e8c1 9527 "@
ca7f5001 9528 {stux|stwux} %3,%0,%2
b7ff3d82 9529 {stu|stwu} %3,%2(%0)"
b54cf83a 9530 [(set_attr "type" "store_ux,store_u")])
1fd4e8c1 9531
b54cf83a 9532(define_insn "*movhi_update1"
cd2b37d9
RK
9533 [(set (match_operand:HI 3 "gpc_reg_operand" "=r,r")
9534 (mem:HI (plus:SI (match_operand:SI 1 "gpc_reg_operand" "0,0")
1fd4e8c1 9535 (match_operand:SI 2 "reg_or_short_operand" "r,I"))))
cd2b37d9 9536 (set (match_operand:SI 0 "gpc_reg_operand" "=b,b")
1fd4e8c1 9537 (plus:SI (match_dup 1) (match_dup 2)))]
38c1f2d7 9538 "TARGET_UPDATE"
1fd4e8c1 9539 "@
5f243543
RK
9540 lhzux %3,%0,%2
9541 lhzu %3,%2(%0)"
b54cf83a 9542 [(set_attr "type" "load_ux,load_u")])
1fd4e8c1 9543
38c1f2d7 9544(define_insn "*movhi_update2"
cd2b37d9 9545 [(set (match_operand:SI 3 "gpc_reg_operand" "=r,r")
1fd4e8c1 9546 (zero_extend:SI
cd2b37d9 9547 (mem:HI (plus:SI (match_operand:SI 1 "gpc_reg_operand" "0,0")
1fd4e8c1 9548 (match_operand:SI 2 "reg_or_short_operand" "r,I")))))
cd2b37d9 9549 (set (match_operand:SI 0 "gpc_reg_operand" "=b,b")
1fd4e8c1 9550 (plus:SI (match_dup 1) (match_dup 2)))]
38c1f2d7 9551 "TARGET_UPDATE"
1fd4e8c1 9552 "@
5f243543
RK
9553 lhzux %3,%0,%2
9554 lhzu %3,%2(%0)"
b54cf83a 9555 [(set_attr "type" "load_ux,load_u")])
1fd4e8c1 9556
38c1f2d7 9557(define_insn "*movhi_update3"
cd2b37d9 9558 [(set (match_operand:SI 3 "gpc_reg_operand" "=r,r")
1fd4e8c1 9559 (sign_extend:SI
cd2b37d9 9560 (mem:HI (plus:SI (match_operand:SI 1 "gpc_reg_operand" "0,0")
1fd4e8c1 9561 (match_operand:SI 2 "reg_or_short_operand" "r,I")))))
cd2b37d9 9562 (set (match_operand:SI 0 "gpc_reg_operand" "=b,b")
1fd4e8c1 9563 (plus:SI (match_dup 1) (match_dup 2)))]
38c1f2d7 9564 "TARGET_UPDATE"
1fd4e8c1 9565 "@
5f243543
RK
9566 lhaux %3,%0,%2
9567 lhau %3,%2(%0)"
b54cf83a 9568 [(set_attr "type" "load_ext_ux,load_ext_u")])
1fd4e8c1 9569
38c1f2d7 9570(define_insn "*movhi_update4"
cd2b37d9 9571 [(set (mem:HI (plus:SI (match_operand:SI 1 "gpc_reg_operand" "0,0")
1fd4e8c1 9572 (match_operand:SI 2 "reg_or_short_operand" "r,I")))
cd2b37d9
RK
9573 (match_operand:HI 3 "gpc_reg_operand" "r,r"))
9574 (set (match_operand:SI 0 "gpc_reg_operand" "=b,b")
1fd4e8c1 9575 (plus:SI (match_dup 1) (match_dup 2)))]
38c1f2d7 9576 "TARGET_UPDATE"
1fd4e8c1 9577 "@
5f243543 9578 sthux %3,%0,%2
b7ff3d82 9579 sthu %3,%2(%0)"
b54cf83a 9580 [(set_attr "type" "store_ux,store_u")])
1fd4e8c1 9581
38c1f2d7 9582(define_insn "*movqi_update1"
cd2b37d9
RK
9583 [(set (match_operand:QI 3 "gpc_reg_operand" "=r,r")
9584 (mem:QI (plus:SI (match_operand:SI 1 "gpc_reg_operand" "0,0")
1fd4e8c1 9585 (match_operand:SI 2 "reg_or_short_operand" "r,I"))))
cd2b37d9 9586 (set (match_operand:SI 0 "gpc_reg_operand" "=b,b")
1fd4e8c1 9587 (plus:SI (match_dup 1) (match_dup 2)))]
38c1f2d7 9588 "TARGET_UPDATE"
1fd4e8c1 9589 "@
5f243543
RK
9590 lbzux %3,%0,%2
9591 lbzu %3,%2(%0)"
b54cf83a 9592 [(set_attr "type" "load_ux,load_u")])
1fd4e8c1 9593
38c1f2d7 9594(define_insn "*movqi_update2"
cd2b37d9 9595 [(set (match_operand:SI 3 "gpc_reg_operand" "=r,r")
1fd4e8c1 9596 (zero_extend:SI
cd2b37d9 9597 (mem:QI (plus:SI (match_operand:SI 1 "gpc_reg_operand" "0,0")
1fd4e8c1 9598 (match_operand:SI 2 "reg_or_short_operand" "r,I")))))
cd2b37d9 9599 (set (match_operand:SI 0 "gpc_reg_operand" "=b,b")
1fd4e8c1 9600 (plus:SI (match_dup 1) (match_dup 2)))]
38c1f2d7 9601 "TARGET_UPDATE"
1fd4e8c1 9602 "@
5f243543
RK
9603 lbzux %3,%0,%2
9604 lbzu %3,%2(%0)"
b54cf83a 9605 [(set_attr "type" "load_ux,load_u")])
1fd4e8c1 9606
38c1f2d7 9607(define_insn "*movqi_update3"
cd2b37d9 9608 [(set (mem:QI (plus:SI (match_operand:SI 1 "gpc_reg_operand" "0,0")
1fd4e8c1 9609 (match_operand:SI 2 "reg_or_short_operand" "r,I")))
cd2b37d9
RK
9610 (match_operand:QI 3 "gpc_reg_operand" "r,r"))
9611 (set (match_operand:SI 0 "gpc_reg_operand" "=b,b")
1fd4e8c1 9612 (plus:SI (match_dup 1) (match_dup 2)))]
38c1f2d7 9613 "TARGET_UPDATE"
1fd4e8c1 9614 "@
5f243543 9615 stbux %3,%0,%2
b7ff3d82 9616 stbu %3,%2(%0)"
b54cf83a 9617 [(set_attr "type" "store_ux,store_u")])
1fd4e8c1 9618
38c1f2d7 9619(define_insn "*movsf_update1"
cd2b37d9 9620 [(set (match_operand:SF 3 "gpc_reg_operand" "=f,f")
df8b713c 9621 (mem:SF (plus:SI (match_operand:SI 1 "gpc_reg_operand" "0,0")
1fd4e8c1 9622 (match_operand:SI 2 "reg_or_short_operand" "r,I"))))
cd2b37d9 9623 (set (match_operand:SI 0 "gpc_reg_operand" "=b,b")
1fd4e8c1 9624 (plus:SI (match_dup 1) (match_dup 2)))]
a3170dc6 9625 "TARGET_HARD_FLOAT && TARGET_FPRS && TARGET_UPDATE"
1fd4e8c1 9626 "@
5f243543
RK
9627 lfsux %3,%0,%2
9628 lfsu %3,%2(%0)"
b54cf83a 9629 [(set_attr "type" "fpload_ux,fpload_u")])
1fd4e8c1 9630
38c1f2d7 9631(define_insn "*movsf_update2"
cd2b37d9 9632 [(set (mem:SF (plus:SI (match_operand:SI 1 "gpc_reg_operand" "0,0")
1fd4e8c1 9633 (match_operand:SI 2 "reg_or_short_operand" "r,I")))
cd2b37d9
RK
9634 (match_operand:SF 3 "gpc_reg_operand" "f,f"))
9635 (set (match_operand:SI 0 "gpc_reg_operand" "=b,b")
1fd4e8c1 9636 (plus:SI (match_dup 1) (match_dup 2)))]
a3170dc6 9637 "TARGET_HARD_FLOAT && TARGET_FPRS && TARGET_UPDATE"
1fd4e8c1 9638 "@
85fff2f3 9639 stfsux %3,%0,%2
b7ff3d82 9640 stfsu %3,%2(%0)"
b54cf83a 9641 [(set_attr "type" "fpstore_ux,fpstore_u")])
1fd4e8c1 9642
38c1f2d7
MM
9643(define_insn "*movsf_update3"
9644 [(set (match_operand:SF 3 "gpc_reg_operand" "=r,r")
9645 (mem:SF (plus:SI (match_operand:SI 1 "gpc_reg_operand" "0,0")
9646 (match_operand:SI 2 "reg_or_short_operand" "r,I"))))
9647 (set (match_operand:SI 0 "gpc_reg_operand" "=b,b")
9648 (plus:SI (match_dup 1) (match_dup 2)))]
a3170dc6 9649 "(TARGET_SOFT_FLOAT || !TARGET_FPRS) && TARGET_UPDATE"
38c1f2d7
MM
9650 "@
9651 {lux|lwzux} %3,%0,%2
9652 {lu|lwzu} %3,%2(%0)"
b54cf83a 9653 [(set_attr "type" "load_ux,load_u")])
38c1f2d7
MM
9654
9655(define_insn "*movsf_update4"
9656 [(set (mem:SF (plus:SI (match_operand:SI 1 "gpc_reg_operand" "0,0")
9657 (match_operand:SI 2 "reg_or_short_operand" "r,I")))
9658 (match_operand:SF 3 "gpc_reg_operand" "r,r"))
9659 (set (match_operand:SI 0 "gpc_reg_operand" "=b,b")
9660 (plus:SI (match_dup 1) (match_dup 2)))]
a3170dc6 9661 "(TARGET_SOFT_FLOAT || !TARGET_FPRS) && TARGET_UPDATE"
38c1f2d7
MM
9662 "@
9663 {stux|stwux} %3,%0,%2
9664 {stu|stwu} %3,%2(%0)"
b54cf83a 9665 [(set_attr "type" "store_ux,store_u")])
38c1f2d7
MM
9666
9667(define_insn "*movdf_update1"
cd2b37d9
RK
9668 [(set (match_operand:DF 3 "gpc_reg_operand" "=f,f")
9669 (mem:DF (plus:SI (match_operand:SI 1 "gpc_reg_operand" "0,0")
1fd4e8c1 9670 (match_operand:SI 2 "reg_or_short_operand" "r,I"))))
cd2b37d9 9671 (set (match_operand:SI 0 "gpc_reg_operand" "=b,b")
1fd4e8c1 9672 (plus:SI (match_dup 1) (match_dup 2)))]
a3170dc6 9673 "TARGET_HARD_FLOAT && TARGET_FPRS && TARGET_UPDATE"
1fd4e8c1 9674 "@
5f243543
RK
9675 lfdux %3,%0,%2
9676 lfdu %3,%2(%0)"
b54cf83a 9677 [(set_attr "type" "fpload_ux,fpload_u")])
1fd4e8c1 9678
38c1f2d7 9679(define_insn "*movdf_update2"
cd2b37d9 9680 [(set (mem:DF (plus:SI (match_operand:SI 1 "gpc_reg_operand" "0,0")
1fd4e8c1 9681 (match_operand:SI 2 "reg_or_short_operand" "r,I")))
cd2b37d9
RK
9682 (match_operand:DF 3 "gpc_reg_operand" "f,f"))
9683 (set (match_operand:SI 0 "gpc_reg_operand" "=b,b")
1fd4e8c1 9684 (plus:SI (match_dup 1) (match_dup 2)))]
a3170dc6 9685 "TARGET_HARD_FLOAT && TARGET_FPRS && TARGET_UPDATE"
1fd4e8c1 9686 "@
5f243543 9687 stfdux %3,%0,%2
b7ff3d82 9688 stfdu %3,%2(%0)"
b54cf83a 9689 [(set_attr "type" "fpstore_ux,fpstore_u")])
4c70a4f3
RK
9690
9691;; Peephole to convert two consecutive FP loads or stores into lfq/stfq.
9692
90f81f99
AP
9693(define_insn "*lfq_power2"
9694 [(set (match_operand:TF 0 "gpc_reg_operand" "=f")
9695 (match_operand:TF 1 "memory_operand" ""))]
9696 "TARGET_POWER2
9697 && TARGET_HARD_FLOAT && TARGET_FPRS"
9698 "lfq%U1%X1 %0,%1")
9699
9700(define_peephole2
9701 [(set (match_operand:DF 0 "gpc_reg_operand" "")
4c70a4f3 9702 (match_operand:DF 1 "memory_operand" ""))
90f81f99 9703 (set (match_operand:DF 2 "gpc_reg_operand" "")
4c70a4f3
RK
9704 (match_operand:DF 3 "memory_operand" ""))]
9705 "TARGET_POWER2
a3170dc6 9706 && TARGET_HARD_FLOAT && TARGET_FPRS
4c70a4f3 9707 && registers_ok_for_quad_peep (operands[0], operands[2])
90f81f99
AP
9708 && mems_ok_for_quad_peep (operands[1], operands[3])"
9709 [(set (match_dup 0)
9710 (match_dup 1))]
9711 "operands[1] = widen_memory_access (operands[1], TFmode, 0);
9712 operands[0] = gen_rtx_REG (TFmode, REGNO (operands[0]));")
4c70a4f3 9713
90f81f99
AP
9714(define_insn "*stfq_power2"
9715 [(set (match_operand:TF 0 "memory_operand" "")
9716 (match_operand:TF 1 "gpc_reg_operand" "f"))]
9717 "TARGET_POWER2
9718 && TARGET_HARD_FLOAT && TARGET_FPRS"
9719 "stfq%U0%X0 %1,%0")
9720
9721
9722(define_peephole2
4c70a4f3 9723 [(set (match_operand:DF 0 "memory_operand" "")
90f81f99 9724 (match_operand:DF 1 "gpc_reg_operand" ""))
4c70a4f3 9725 (set (match_operand:DF 2 "memory_operand" "")
90f81f99 9726 (match_operand:DF 3 "gpc_reg_operand" ""))]
4c70a4f3 9727 "TARGET_POWER2
a3170dc6 9728 && TARGET_HARD_FLOAT && TARGET_FPRS
4c70a4f3 9729 && registers_ok_for_quad_peep (operands[1], operands[3])
90f81f99
AP
9730 && mems_ok_for_quad_peep (operands[0], operands[2])"
9731 [(set (match_dup 0)
9732 (match_dup 1))]
9733 "operands[0] = widen_memory_access (operands[0], TFmode, 0);
9734 operands[1] = gen_rtx_REG (TFmode, REGNO (operands[1]));")
1fd4e8c1 9735\f
c4501e62
JJ
9736;; TLS support.
9737
9738;; "b" output constraint here and on tls_ld to support tls linker optimization.
9739(define_insn "tls_gd_32"
b150f4f3
DE
9740 [(set (match_operand:SI 0 "gpc_reg_operand" "=b")
9741 (unspec:SI [(match_operand:SI 1 "gpc_reg_operand" "b")
c4501e62
JJ
9742 (match_operand:SI 2 "rs6000_tls_symbol_ref" "")]
9743 UNSPEC_TLSGD))]
9744 "HAVE_AS_TLS && !TARGET_64BIT"
9745 "addi %0,%1,%2@got@tlsgd")
9746
9747(define_insn "tls_gd_64"
b150f4f3
DE
9748 [(set (match_operand:DI 0 "gpc_reg_operand" "=b")
9749 (unspec:DI [(match_operand:DI 1 "gpc_reg_operand" "b")
c4501e62
JJ
9750 (match_operand:DI 2 "rs6000_tls_symbol_ref" "")]
9751 UNSPEC_TLSGD))]
9752 "HAVE_AS_TLS && TARGET_64BIT"
9753 "addi %0,%1,%2@got@tlsgd")
9754
9755(define_insn "tls_ld_32"
b150f4f3
DE
9756 [(set (match_operand:SI 0 "gpc_reg_operand" "=b")
9757 (unspec:SI [(match_operand:SI 1 "gpc_reg_operand" "b")]
c4501e62
JJ
9758 UNSPEC_TLSLD))]
9759 "HAVE_AS_TLS && !TARGET_64BIT"
9760 "addi %0,%1,%&@got@tlsld")
9761
9762(define_insn "tls_ld_64"
b150f4f3
DE
9763 [(set (match_operand:DI 0 "gpc_reg_operand" "=b")
9764 (unspec:DI [(match_operand:DI 1 "gpc_reg_operand" "b")]
c4501e62
JJ
9765 UNSPEC_TLSLD))]
9766 "HAVE_AS_TLS && TARGET_64BIT"
9767 "addi %0,%1,%&@got@tlsld")
9768
9769(define_insn "tls_dtprel_32"
b150f4f3
DE
9770 [(set (match_operand:SI 0 "gpc_reg_operand" "=r")
9771 (unspec:SI [(match_operand:SI 1 "gpc_reg_operand" "b")
c4501e62
JJ
9772 (match_operand:SI 2 "rs6000_tls_symbol_ref" "")]
9773 UNSPEC_TLSDTPREL))]
9774 "HAVE_AS_TLS && !TARGET_64BIT"
9775 "addi %0,%1,%2@dtprel")
9776
9777(define_insn "tls_dtprel_64"
b150f4f3
DE
9778 [(set (match_operand:DI 0 "gpc_reg_operand" "=r")
9779 (unspec:DI [(match_operand:DI 1 "gpc_reg_operand" "b")
c4501e62
JJ
9780 (match_operand:DI 2 "rs6000_tls_symbol_ref" "")]
9781 UNSPEC_TLSDTPREL))]
9782 "HAVE_AS_TLS && TARGET_64BIT"
9783 "addi %0,%1,%2@dtprel")
9784
9785(define_insn "tls_dtprel_ha_32"
b150f4f3
DE
9786 [(set (match_operand:SI 0 "gpc_reg_operand" "=r")
9787 (unspec:SI [(match_operand:SI 1 "gpc_reg_operand" "b")
c4501e62
JJ
9788 (match_operand:SI 2 "rs6000_tls_symbol_ref" "")]
9789 UNSPEC_TLSDTPRELHA))]
9790 "HAVE_AS_TLS && !TARGET_64BIT"
9791 "addis %0,%1,%2@dtprel@ha")
9792
9793(define_insn "tls_dtprel_ha_64"
b150f4f3
DE
9794 [(set (match_operand:DI 0 "gpc_reg_operand" "=r")
9795 (unspec:DI [(match_operand:DI 1 "gpc_reg_operand" "b")
c4501e62
JJ
9796 (match_operand:DI 2 "rs6000_tls_symbol_ref" "")]
9797 UNSPEC_TLSDTPRELHA))]
9798 "HAVE_AS_TLS && TARGET_64BIT"
9799 "addis %0,%1,%2@dtprel@ha")
9800
9801(define_insn "tls_dtprel_lo_32"
b150f4f3
DE
9802 [(set (match_operand:SI 0 "gpc_reg_operand" "=r")
9803 (unspec:SI [(match_operand:SI 1 "gpc_reg_operand" "b")
c4501e62
JJ
9804 (match_operand:SI 2 "rs6000_tls_symbol_ref" "")]
9805 UNSPEC_TLSDTPRELLO))]
9806 "HAVE_AS_TLS && !TARGET_64BIT"
9807 "addi %0,%1,%2@dtprel@l")
9808
9809(define_insn "tls_dtprel_lo_64"
b150f4f3
DE
9810 [(set (match_operand:DI 0 "gpc_reg_operand" "=r")
9811 (unspec:DI [(match_operand:DI 1 "gpc_reg_operand" "b")
c4501e62
JJ
9812 (match_operand:DI 2 "rs6000_tls_symbol_ref" "")]
9813 UNSPEC_TLSDTPRELLO))]
9814 "HAVE_AS_TLS && TARGET_64BIT"
9815 "addi %0,%1,%2@dtprel@l")
9816
9817(define_insn "tls_got_dtprel_32"
b150f4f3
DE
9818 [(set (match_operand:SI 0 "gpc_reg_operand" "=r")
9819 (unspec:SI [(match_operand:SI 1 "gpc_reg_operand" "b")
c4501e62
JJ
9820 (match_operand:SI 2 "rs6000_tls_symbol_ref" "")]
9821 UNSPEC_TLSGOTDTPREL))]
9822 "HAVE_AS_TLS && !TARGET_64BIT"
9823 "lwz %0,%2@got@dtprel(%1)")
9824
9825(define_insn "tls_got_dtprel_64"
b150f4f3
DE
9826 [(set (match_operand:DI 0 "gpc_reg_operand" "=r")
9827 (unspec:DI [(match_operand:DI 1 "gpc_reg_operand" "b")
c4501e62
JJ
9828 (match_operand:DI 2 "rs6000_tls_symbol_ref" "")]
9829 UNSPEC_TLSGOTDTPREL))]
9830 "HAVE_AS_TLS && TARGET_64BIT"
9831 "ld %0,%2@got@dtprel(%1)")
9832
9833(define_insn "tls_tprel_32"
b150f4f3
DE
9834 [(set (match_operand:SI 0 "gpc_reg_operand" "=r")
9835 (unspec:SI [(match_operand:SI 1 "gpc_reg_operand" "b")
c4501e62
JJ
9836 (match_operand:SI 2 "rs6000_tls_symbol_ref" "")]
9837 UNSPEC_TLSTPREL))]
9838 "HAVE_AS_TLS && !TARGET_64BIT"
9839 "addi %0,%1,%2@tprel")
9840
9841(define_insn "tls_tprel_64"
b150f4f3
DE
9842 [(set (match_operand:DI 0 "gpc_reg_operand" "=r")
9843 (unspec:DI [(match_operand:DI 1 "gpc_reg_operand" "b")
c4501e62
JJ
9844 (match_operand:DI 2 "rs6000_tls_symbol_ref" "")]
9845 UNSPEC_TLSTPREL))]
9846 "HAVE_AS_TLS && TARGET_64BIT"
9847 "addi %0,%1,%2@tprel")
9848
9849(define_insn "tls_tprel_ha_32"
b150f4f3
DE
9850 [(set (match_operand:SI 0 "gpc_reg_operand" "=r")
9851 (unspec:SI [(match_operand:SI 1 "gpc_reg_operand" "b")
c4501e62
JJ
9852 (match_operand:SI 2 "rs6000_tls_symbol_ref" "")]
9853 UNSPEC_TLSTPRELHA))]
9854 "HAVE_AS_TLS && !TARGET_64BIT"
9855 "addis %0,%1,%2@tprel@ha")
9856
9857(define_insn "tls_tprel_ha_64"
b150f4f3
DE
9858 [(set (match_operand:DI 0 "gpc_reg_operand" "=r")
9859 (unspec:DI [(match_operand:DI 1 "gpc_reg_operand" "b")
c4501e62
JJ
9860 (match_operand:DI 2 "rs6000_tls_symbol_ref" "")]
9861 UNSPEC_TLSTPRELHA))]
9862 "HAVE_AS_TLS && TARGET_64BIT"
9863 "addis %0,%1,%2@tprel@ha")
9864
9865(define_insn "tls_tprel_lo_32"
b150f4f3
DE
9866 [(set (match_operand:SI 0 "gpc_reg_operand" "=r")
9867 (unspec:SI [(match_operand:SI 1 "gpc_reg_operand" "b")
c4501e62
JJ
9868 (match_operand:SI 2 "rs6000_tls_symbol_ref" "")]
9869 UNSPEC_TLSTPRELLO))]
9870 "HAVE_AS_TLS && !TARGET_64BIT"
9871 "addi %0,%1,%2@tprel@l")
9872
9873(define_insn "tls_tprel_lo_64"
b150f4f3
DE
9874 [(set (match_operand:DI 0 "gpc_reg_operand" "=r")
9875 (unspec:DI [(match_operand:DI 1 "gpc_reg_operand" "b")
c4501e62
JJ
9876 (match_operand:DI 2 "rs6000_tls_symbol_ref" "")]
9877 UNSPEC_TLSTPRELLO))]
9878 "HAVE_AS_TLS && TARGET_64BIT"
9879 "addi %0,%1,%2@tprel@l")
9880
c1207243 9881;; "b" output constraint here and on tls_tls input to support linker tls
c4501e62
JJ
9882;; optimization. The linker may edit the instructions emitted by a
9883;; tls_got_tprel/tls_tls pair to addis,addi.
9884(define_insn "tls_got_tprel_32"
b150f4f3
DE
9885 [(set (match_operand:SI 0 "gpc_reg_operand" "=b")
9886 (unspec:SI [(match_operand:SI 1 "gpc_reg_operand" "b")
c4501e62
JJ
9887 (match_operand:SI 2 "rs6000_tls_symbol_ref" "")]
9888 UNSPEC_TLSGOTTPREL))]
9889 "HAVE_AS_TLS && !TARGET_64BIT"
9890 "lwz %0,%2@got@tprel(%1)")
9891
9892(define_insn "tls_got_tprel_64"
b150f4f3
DE
9893 [(set (match_operand:DI 0 "gpc_reg_operand" "=b")
9894 (unspec:DI [(match_operand:DI 1 "gpc_reg_operand" "b")
c4501e62
JJ
9895 (match_operand:DI 2 "rs6000_tls_symbol_ref" "")]
9896 UNSPEC_TLSGOTTPREL))]
9897 "HAVE_AS_TLS && TARGET_64BIT"
9898 "ld %0,%2@got@tprel(%1)")
9899
9900(define_insn "tls_tls_32"
b150f4f3
DE
9901 [(set (match_operand:SI 0 "gpc_reg_operand" "=r")
9902 (unspec:SI [(match_operand:SI 1 "gpc_reg_operand" "b")
c4501e62
JJ
9903 (match_operand:SI 2 "rs6000_tls_symbol_ref" "")]
9904 UNSPEC_TLSTLS))]
9905 "HAVE_AS_TLS && !TARGET_64BIT"
9906 "add %0,%1,%2@tls")
9907
9908(define_insn "tls_tls_64"
b150f4f3
DE
9909 [(set (match_operand:DI 0 "gpc_reg_operand" "=r")
9910 (unspec:DI [(match_operand:DI 1 "gpc_reg_operand" "b")
c4501e62
JJ
9911 (match_operand:DI 2 "rs6000_tls_symbol_ref" "")]
9912 UNSPEC_TLSTLS))]
9913 "HAVE_AS_TLS && TARGET_64BIT"
9914 "add %0,%1,%2@tls")
9915\f
1fd4e8c1
RK
9916;; Next come insns related to the calling sequence.
9917;;
9918;; First, an insn to allocate new stack space for dynamic use (e.g., alloca).
7e69e155 9919;; We move the back-chain and decrement the stack pointer.
1fd4e8c1
RK
9920
9921(define_expand "allocate_stack"
52d3af72 9922 [(set (match_operand 0 "gpc_reg_operand" "=r")
a260abc9
DE
9923 (minus (reg 1) (match_operand 1 "reg_or_short_operand" "")))
9924 (set (reg 1)
9925 (minus (reg 1) (match_dup 1)))]
1fd4e8c1
RK
9926 ""
9927 "
4697a36c 9928{ rtx chain = gen_reg_rtx (Pmode);
39403d82 9929 rtx stack_bot = gen_rtx_MEM (Pmode, stack_pointer_rtx);
4697a36c 9930 rtx neg_op0;
1fd4e8c1
RK
9931
9932 emit_move_insn (chain, stack_bot);
4697a36c 9933
a157febd
GK
9934 /* Check stack bounds if necessary. */
9935 if (current_function_limit_stack)
9936 {
9937 rtx available;
6ae08853 9938 available = expand_binop (Pmode, sub_optab,
a157febd
GK
9939 stack_pointer_rtx, stack_limit_rtx,
9940 NULL_RTX, 1, OPTAB_WIDEN);
9941 emit_insn (gen_cond_trap (LTU, available, operands[1], const0_rtx));
9942 }
9943
e9a25f70
JL
9944 if (GET_CODE (operands[1]) != CONST_INT
9945 || INTVAL (operands[1]) < -32767
9946 || INTVAL (operands[1]) > 32768)
4697a36c
MM
9947 {
9948 neg_op0 = gen_reg_rtx (Pmode);
e6ca2c17 9949 if (TARGET_32BIT)
e9a25f70 9950 emit_insn (gen_negsi2 (neg_op0, operands[1]));
e6ca2c17 9951 else
e9a25f70 9952 emit_insn (gen_negdi2 (neg_op0, operands[1]));
4697a36c
MM
9953 }
9954 else
e9a25f70 9955 neg_op0 = GEN_INT (- INTVAL (operands[1]));
4697a36c 9956
38c1f2d7
MM
9957 if (TARGET_UPDATE)
9958 emit_insn ((* ((TARGET_32BIT) ? gen_movsi_update : gen_movdi_update))
9959 (stack_pointer_rtx, stack_pointer_rtx, neg_op0, chain));
4697a36c 9960
38c1f2d7
MM
9961 else
9962 {
9963 emit_insn ((* ((TARGET_32BIT) ? gen_addsi3 : gen_adddi3))
9964 (stack_pointer_rtx, stack_pointer_rtx, neg_op0));
39403d82 9965 emit_move_insn (gen_rtx_MEM (Pmode, stack_pointer_rtx), chain);
38c1f2d7 9966 }
e9a25f70
JL
9967
9968 emit_move_insn (operands[0], virtual_stack_dynamic_rtx);
1fd4e8c1
RK
9969 DONE;
9970}")
59257ff7
RK
9971
9972;; These patterns say how to save and restore the stack pointer. We need not
9973;; save the stack pointer at function level since we are careful to
9974;; preserve the backchain. At block level, we have to restore the backchain
9975;; when we restore the stack pointer.
9976;;
9977;; For nonlocal gotos, we must save both the stack pointer and its
9978;; backchain and restore both. Note that in the nonlocal case, the
9979;; save area is a memory location.
9980
9981(define_expand "save_stack_function"
ff381587
MM
9982 [(match_operand 0 "any_operand" "")
9983 (match_operand 1 "any_operand" "")]
59257ff7 9984 ""
ff381587 9985 "DONE;")
59257ff7
RK
9986
9987(define_expand "restore_stack_function"
ff381587
MM
9988 [(match_operand 0 "any_operand" "")
9989 (match_operand 1 "any_operand" "")]
59257ff7 9990 ""
ff381587 9991 "DONE;")
59257ff7
RK
9992
9993(define_expand "restore_stack_block"
dfdfa60f
DE
9994 [(use (match_operand 0 "register_operand" ""))
9995 (set (match_dup 2) (match_dup 3))
a260abc9 9996 (set (match_dup 0) (match_operand 1 "register_operand" ""))
dfdfa60f 9997 (set (match_dup 3) (match_dup 2))]
59257ff7
RK
9998 ""
9999 "
dfdfa60f
DE
10000{
10001 operands[2] = gen_reg_rtx (Pmode);
39403d82 10002 operands[3] = gen_rtx_MEM (Pmode, operands[0]);
dfdfa60f 10003}")
59257ff7
RK
10004
10005(define_expand "save_stack_nonlocal"
a260abc9
DE
10006 [(match_operand 0 "memory_operand" "")
10007 (match_operand 1 "register_operand" "")]
59257ff7
RK
10008 ""
10009 "
10010{
a260abc9 10011 rtx temp = gen_reg_rtx (Pmode);
11b25716 10012 int units_per_word = (TARGET_32BIT) ? 4 : 8;
59257ff7
RK
10013
10014 /* Copy the backchain to the first word, sp to the second. */
39403d82 10015 emit_move_insn (temp, gen_rtx_MEM (Pmode, operands[1]));
39e453d7
DE
10016 emit_move_insn (adjust_address_nv (operands[0], Pmode, 0), temp);
10017 emit_move_insn (adjust_address_nv (operands[0], Pmode, units_per_word),
a260abc9 10018 operands[1]);
59257ff7
RK
10019 DONE;
10020}")
7e69e155 10021
59257ff7 10022(define_expand "restore_stack_nonlocal"
a260abc9
DE
10023 [(match_operand 0 "register_operand" "")
10024 (match_operand 1 "memory_operand" "")]
59257ff7
RK
10025 ""
10026 "
10027{
a260abc9 10028 rtx temp = gen_reg_rtx (Pmode);
11b25716 10029 int units_per_word = (TARGET_32BIT) ? 4 : 8;
59257ff7
RK
10030
10031 /* Restore the backchain from the first word, sp from the second. */
a260abc9 10032 emit_move_insn (temp,
39e453d7 10033 adjust_address_nv (operands[1], Pmode, 0));
a260abc9 10034 emit_move_insn (operands[0],
39e453d7 10035 adjust_address_nv (operands[1], Pmode, units_per_word));
39403d82 10036 emit_move_insn (gen_rtx_MEM (Pmode, operands[0]), temp);
59257ff7
RK
10037 DONE;
10038}")
9ebbca7d
GK
10039\f
10040;; TOC register handling.
b6c9286a 10041
9ebbca7d 10042;; Code to initialize the TOC register...
f0f6a223 10043
9ebbca7d 10044(define_insn "load_toc_aix_si"
e72247f4 10045 [(parallel [(set (match_operand:SI 0 "gpc_reg_operand" "=r")
615158e2 10046 (unspec:SI [(const_int 0)] UNSPEC_TOC))
46aaf10d 10047 (use (reg:SI 2))])]
2bfcf297 10048 "DEFAULT_ABI == ABI_AIX && TARGET_32BIT"
f0f6a223
RK
10049 "*
10050{
9ebbca7d
GK
10051 char buf[30];
10052 ASM_GENERATE_INTERNAL_LABEL (buf, \"LCTOC\", 1);
a8a05998 10053 operands[1] = gen_rtx_SYMBOL_REF (Pmode, ggc_strdup (buf));
9ebbca7d
GK
10054 operands[2] = gen_rtx_REG (Pmode, 2);
10055 return \"{l|lwz} %0,%1(%2)\";
f0f6a223
RK
10056}"
10057 [(set_attr "type" "load")])
9ebbca7d
GK
10058
10059(define_insn "load_toc_aix_di"
e72247f4 10060 [(parallel [(set (match_operand:DI 0 "gpc_reg_operand" "=r")
615158e2 10061 (unspec:DI [(const_int 0)] UNSPEC_TOC))
46aaf10d 10062 (use (reg:DI 2))])]
2bfcf297 10063 "DEFAULT_ABI == ABI_AIX && TARGET_64BIT"
9ebbca7d
GK
10064 "*
10065{
10066 char buf[30];
f585a356
DE
10067#ifdef TARGET_RELOCATABLE
10068 ASM_GENERATE_INTERNAL_LABEL (buf, \"LCTOC\",
10069 !TARGET_MINIMAL_TOC || TARGET_RELOCATABLE);
10070#else
9ebbca7d 10071 ASM_GENERATE_INTERNAL_LABEL (buf, \"LCTOC\", 1);
f585a356 10072#endif
2bfcf297
DB
10073 if (TARGET_ELF)
10074 strcat (buf, \"@toc\");
a8a05998 10075 operands[1] = gen_rtx_SYMBOL_REF (Pmode, ggc_strdup (buf));
9ebbca7d
GK
10076 operands[2] = gen_rtx_REG (Pmode, 2);
10077 return \"ld %0,%1(%2)\";
10078}"
10079 [(set_attr "type" "load")])
10080
10081(define_insn "load_toc_v4_pic_si"
10082 [(set (match_operand:SI 0 "register_operand" "=l")
615158e2 10083 (unspec:SI [(const_int 0)] UNSPEC_TOC))]
f607bc57 10084 "DEFAULT_ABI == ABI_V4 && flag_pic == 1 && TARGET_32BIT"
9ebbca7d
GK
10085 "bl _GLOBAL_OFFSET_TABLE_@local-4"
10086 [(set_attr "type" "branch")
10087 (set_attr "length" "4")])
10088
9ebbca7d
GK
10089(define_insn "load_toc_v4_PIC_1"
10090 [(set (match_operand:SI 0 "register_operand" "=l")
10091 (match_operand:SI 1 "immediate_operand" "s"))
c4501e62 10092 (use (unspec [(match_dup 1)] UNSPEC_TOC))]
20b71b17 10093 "TARGET_ELF && DEFAULT_ABI != ABI_AIX && flag_pic == 2"
df7a8989 10094 "bcl 20,31,%1\\n%1:"
9ebbca7d
GK
10095 [(set_attr "type" "branch")
10096 (set_attr "length" "4")])
10097
10098(define_insn "load_toc_v4_PIC_1b"
10099 [(set (match_operand:SI 0 "register_operand" "=l")
10100 (match_operand:SI 1 "immediate_operand" "s"))
c4501e62
JJ
10101 (use (unspec [(match_dup 1) (match_operand 2 "immediate_operand" "s")]
10102 UNSPEC_TOCPTR))]
20b71b17 10103 "TARGET_ELF && DEFAULT_ABI != ABI_AIX && flag_pic == 2"
c4501e62 10104 "bcl 20,31,%1+4\\n%1:\\n\\t.long %2-%1"
9ebbca7d
GK
10105 [(set_attr "type" "branch")
10106 (set_attr "length" "8")])
10107
10108(define_insn "load_toc_v4_PIC_2"
f585a356 10109 [(set (match_operand:SI 0 "gpc_reg_operand" "=r")
a2900460 10110 (mem:SI (plus:SI (match_operand:SI 1 "gpc_reg_operand" "b")
9ebbca7d
GK
10111 (minus:SI (match_operand:SI 2 "immediate_operand" "s")
10112 (match_operand:SI 3 "immediate_operand" "s")))))]
20b71b17 10113 "TARGET_ELF && DEFAULT_ABI != ABI_AIX && flag_pic == 2"
9ebbca7d
GK
10114 "{l|lwz} %0,%2-%3(%1)"
10115 [(set_attr "type" "load")])
10116
ee890fe2
SS
10117(define_insn "load_macho_picbase"
10118 [(set (match_operand:SI 0 "register_operand" "=l")
615158e2
JJ
10119 (unspec:SI [(match_operand:SI 1 "immediate_operand" "s")]
10120 UNSPEC_LD_MPIC))]
ee890fe2 10121 "(DEFAULT_ABI == ABI_DARWIN) && flag_pic"
f51eee6a 10122 "bcl 20,31,%1\\n%1:"
ee890fe2
SS
10123 [(set_attr "type" "branch")
10124 (set_attr "length" "4")])
10125
f51eee6a
GK
10126(define_insn "macho_correct_pic"
10127 [(set (match_operand:SI 0 "gpc_reg_operand" "=r")
8291cc0e 10128 (plus:SI (match_operand:SI 1 "gpc_reg_operand" "r")
f51eee6a
GK
10129 (unspec:SI [(match_operand:SI 2 "immediate_operand" "s")
10130 (match_operand:SI 3 "immediate_operand" "s")]
615158e2 10131 UNSPEC_MPIC_CORRECT)))]
f51eee6a 10132 "DEFAULT_ABI == ABI_DARWIN"
8291cc0e 10133 "addis %0,%1,ha16(%2-%3)\n\taddi %0,%0,lo16(%2-%3)"
f51eee6a
GK
10134 [(set_attr "length" "8")])
10135
9ebbca7d
GK
10136;; If the TOC is shared over a translation unit, as happens with all
10137;; the kinds of PIC that we support, we need to restore the TOC
10138;; pointer only when jumping over units of translation.
f51eee6a 10139;; On Darwin, we need to reload the picbase.
9ebbca7d
GK
10140
10141(define_expand "builtin_setjmp_receiver"
10142 [(use (label_ref (match_operand 0 "" "")))]
f607bc57 10143 "(DEFAULT_ABI == ABI_V4 && flag_pic == 1)
f51eee6a
GK
10144 || (TARGET_TOC && TARGET_MINIMAL_TOC)
10145 || (DEFAULT_ABI == ABI_DARWIN && flag_pic)"
9ebbca7d
GK
10146 "
10147{
84d7dd4a 10148#if TARGET_MACHO
f51eee6a
GK
10149 if (DEFAULT_ABI == ABI_DARWIN)
10150 {
d24652ee 10151 const char *picbase = machopic_function_base_name ();
485bad26 10152 rtx picrtx = gen_rtx_SYMBOL_REF (Pmode, ggc_strdup (picbase));
f51eee6a
GK
10153 rtx picreg = gen_rtx_REG (Pmode, RS6000_PIC_OFFSET_TABLE_REGNUM);
10154 rtx tmplabrtx;
10155 char tmplab[20];
10156
10157 ASM_GENERATE_INTERNAL_LABEL(tmplab, \"LSJR\",
10158 CODE_LABEL_NUMBER (operands[0]));
485bad26 10159 tmplabrtx = gen_rtx_SYMBOL_REF (Pmode, ggc_strdup (tmplab));
f51eee6a
GK
10160
10161 emit_insn (gen_load_macho_picbase (picreg, tmplabrtx));
10162 emit_insn (gen_macho_correct_pic (picreg, picreg, picrtx, tmplabrtx));
10163 }
10164 else
84d7dd4a 10165#endif
f51eee6a 10166 rs6000_emit_load_toc_table (FALSE);
9ebbca7d
GK
10167 DONE;
10168}")
10169\f
10170;; A function pointer under AIX is a pointer to a data area whose first word
10171;; contains the actual address of the function, whose second word contains a
b6c9286a
MM
10172;; pointer to its TOC, and whose third word contains a value to place in the
10173;; static chain register (r11). Note that if we load the static chain, our
1fd4e8c1 10174;; "trampoline" need not have any executable code.
b6c9286a 10175
cccf3bdc
DE
10176(define_expand "call_indirect_aix32"
10177 [(set (match_dup 2)
10178 (mem:SI (match_operand:SI 0 "gpc_reg_operand" "")))
10179 (set (mem:SI (plus:SI (reg:SI 1) (const_int 20)))
10180 (reg:SI 2))
10181 (set (reg:SI 2)
10182 (mem:SI (plus:SI (match_dup 0)
10183 (const_int 4))))
10184 (set (reg:SI 11)
10185 (mem:SI (plus:SI (match_dup 0)
10186 (const_int 8))))
10187 (parallel [(call (mem:SI (match_dup 2))
10188 (match_operand 1 "" ""))
10189 (use (reg:SI 2))
10190 (use (reg:SI 11))
10191 (set (reg:SI 2)
10192 (mem:SI (plus:SI (reg:SI 1) (const_int 20))))
10193 (clobber (scratch:SI))])]
10194 "TARGET_32BIT"
10195 "
10196{ operands[2] = gen_reg_rtx (SImode); }")
b6c9286a 10197
cccf3bdc
DE
10198(define_expand "call_indirect_aix64"
10199 [(set (match_dup 2)
10200 (mem:DI (match_operand:DI 0 "gpc_reg_operand" "")))
10201 (set (mem:DI (plus:DI (reg:DI 1) (const_int 40)))
10202 (reg:DI 2))
10203 (set (reg:DI 2)
10204 (mem:DI (plus:DI (match_dup 0)
10205 (const_int 8))))
10206 (set (reg:DI 11)
10207 (mem:DI (plus:DI (match_dup 0)
10208 (const_int 16))))
10209 (parallel [(call (mem:SI (match_dup 2))
10210 (match_operand 1 "" ""))
10211 (use (reg:DI 2))
10212 (use (reg:DI 11))
10213 (set (reg:DI 2)
10214 (mem:DI (plus:DI (reg:DI 1) (const_int 40))))
10215 (clobber (scratch:SI))])]
10216 "TARGET_64BIT"
10217 "
10218{ operands[2] = gen_reg_rtx (DImode); }")
b6c9286a 10219
cccf3bdc
DE
10220(define_expand "call_value_indirect_aix32"
10221 [(set (match_dup 3)
10222 (mem:SI (match_operand:SI 1 "gpc_reg_operand" "")))
10223 (set (mem:SI (plus:SI (reg:SI 1) (const_int 20)))
10224 (reg:SI 2))
10225 (set (reg:SI 2)
10226 (mem:SI (plus:SI (match_dup 1)
10227 (const_int 4))))
10228 (set (reg:SI 11)
10229 (mem:SI (plus:SI (match_dup 1)
10230 (const_int 8))))
10231 (parallel [(set (match_operand 0 "" "")
10232 (call (mem:SI (match_dup 3))
10233 (match_operand 2 "" "")))
10234 (use (reg:SI 2))
10235 (use (reg:SI 11))
10236 (set (reg:SI 2)
10237 (mem:SI (plus:SI (reg:SI 1) (const_int 20))))
10238 (clobber (scratch:SI))])]
10239 "TARGET_32BIT"
10240 "
10241{ operands[3] = gen_reg_rtx (SImode); }")
b6c9286a 10242
cccf3bdc
DE
10243(define_expand "call_value_indirect_aix64"
10244 [(set (match_dup 3)
10245 (mem:DI (match_operand:DI 1 "gpc_reg_operand" "")))
10246 (set (mem:DI (plus:DI (reg:DI 1) (const_int 40)))
10247 (reg:DI 2))
10248 (set (reg:DI 2)
10249 (mem:DI (plus:DI (match_dup 1)
10250 (const_int 8))))
10251 (set (reg:DI 11)
10252 (mem:DI (plus:DI (match_dup 1)
10253 (const_int 16))))
10254 (parallel [(set (match_operand 0 "" "")
10255 (call (mem:SI (match_dup 3))
10256 (match_operand 2 "" "")))
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 (scratch:SI))])]
10262 "TARGET_64BIT"
10263 "
10264{ operands[3] = gen_reg_rtx (DImode); }")
1fd4e8c1 10265
b6c9286a 10266;; Now the definitions for the call and call_value insns
1fd4e8c1 10267(define_expand "call"
a260abc9 10268 [(parallel [(call (mem:SI (match_operand 0 "address_operand" ""))
1fd4e8c1 10269 (match_operand 1 "" ""))
4697a36c 10270 (use (match_operand 2 "" ""))
1fd4e8c1
RK
10271 (clobber (scratch:SI))])]
10272 ""
10273 "
10274{
ee890fe2 10275#if TARGET_MACHO
ab82a49f 10276 if (MACHOPIC_INDIRECT)
ee890fe2
SS
10277 operands[0] = machopic_indirect_call_target (operands[0]);
10278#endif
10279
1fd4e8c1
RK
10280 if (GET_CODE (operands[0]) != MEM || GET_CODE (operands[1]) != CONST_INT)
10281 abort ();
10282
10283 operands[0] = XEXP (operands[0], 0);
7509c759 10284
6a4cee5f 10285 if (GET_CODE (operands[0]) != SYMBOL_REF
473f51b6 10286 || (DEFAULT_ABI == ABI_AIX && !SYMBOL_REF_FUNCTION_P (operands[0]))
efdba735 10287 || (DEFAULT_ABI != ABI_DARWIN && (INTVAL (operands[2]) & CALL_LONG) != 0))
1fd4e8c1 10288 {
6a4cee5f
MM
10289 if (INTVAL (operands[2]) & CALL_LONG)
10290 operands[0] = rs6000_longcall_ref (operands[0]);
10291
cccf3bdc 10292 if (DEFAULT_ABI == ABI_V4
f607bc57 10293 || DEFAULT_ABI == ABI_DARWIN)
bbf294a5 10294 operands[0] = force_reg (Pmode, operands[0]);
1fd4e8c1 10295
cccf3bdc
DE
10296 else if (DEFAULT_ABI == ABI_AIX)
10297 {
10298 /* AIX function pointers are really pointers to a three word
10299 area. */
10300 emit_call_insn (TARGET_32BIT
10301 ? gen_call_indirect_aix32 (force_reg (SImode,
10302 operands[0]),
10303 operands[1])
10304 : gen_call_indirect_aix64 (force_reg (DImode,
10305 operands[0]),
10306 operands[1]));
10307 DONE;
b6c9286a 10308 }
cccf3bdc
DE
10309 else
10310 abort ();
1fd4e8c1
RK
10311 }
10312}")
10313
10314(define_expand "call_value"
10315 [(parallel [(set (match_operand 0 "" "")
a260abc9 10316 (call (mem:SI (match_operand 1 "address_operand" ""))
1fd4e8c1 10317 (match_operand 2 "" "")))
4697a36c 10318 (use (match_operand 3 "" ""))
1fd4e8c1
RK
10319 (clobber (scratch:SI))])]
10320 ""
10321 "
10322{
ee890fe2 10323#if TARGET_MACHO
ab82a49f 10324 if (MACHOPIC_INDIRECT)
ee890fe2
SS
10325 operands[1] = machopic_indirect_call_target (operands[1]);
10326#endif
10327
1fd4e8c1
RK
10328 if (GET_CODE (operands[1]) != MEM || GET_CODE (operands[2]) != CONST_INT)
10329 abort ();
10330
10331 operands[1] = XEXP (operands[1], 0);
7509c759 10332
6a4cee5f 10333 if (GET_CODE (operands[1]) != SYMBOL_REF
473f51b6 10334 || (DEFAULT_ABI == ABI_AIX && !SYMBOL_REF_FUNCTION_P (operands[1]))
efdba735 10335 || (DEFAULT_ABI != ABI_DARWIN && (INTVAL (operands[3]) & CALL_LONG) != 0))
1fd4e8c1 10336 {
6756293c 10337 if (INTVAL (operands[3]) & CALL_LONG)
6a4cee5f
MM
10338 operands[1] = rs6000_longcall_ref (operands[1]);
10339
cccf3bdc 10340 if (DEFAULT_ABI == ABI_V4
f607bc57 10341 || DEFAULT_ABI == ABI_DARWIN)
bbf294a5 10342 operands[1] = force_reg (Pmode, operands[1]);
1fd4e8c1 10343
cccf3bdc
DE
10344 else if (DEFAULT_ABI == ABI_AIX)
10345 {
10346 /* AIX function pointers are really pointers to a three word
10347 area. */
10348 emit_call_insn (TARGET_32BIT
10349 ? gen_call_value_indirect_aix32 (operands[0],
10350 force_reg (SImode,
10351 operands[1]),
10352 operands[2])
10353 : gen_call_value_indirect_aix64 (operands[0],
10354 force_reg (DImode,
10355 operands[1]),
10356 operands[2]));
10357 DONE;
b6c9286a 10358 }
cccf3bdc
DE
10359 else
10360 abort ();
1fd4e8c1
RK
10361 }
10362}")
10363
04780ee7 10364;; Call to function in current module. No TOC pointer reload needed.
a0ab749a 10365;; Operand2 is nonzero if we are using the V.4 calling sequence and
4697a36c
MM
10366;; either the function was not prototyped, or it was prototyped as a
10367;; variable argument function. It is > 0 if FP registers were passed
10368;; and < 0 if they were not.
04780ee7 10369
a260abc9 10370(define_insn "*call_local32"
4697a36c
MM
10371 [(call (mem:SI (match_operand:SI 0 "current_file_function_operand" "s,s"))
10372 (match_operand 1 "" "g,g"))
10373 (use (match_operand:SI 2 "immediate_operand" "O,n"))
10374 (clobber (match_scratch:SI 3 "=l,l"))]
5a19791c 10375 "(INTVAL (operands[2]) & CALL_LONG) == 0"
4697a36c
MM
10376 "*
10377{
6a4cee5f
MM
10378 if (INTVAL (operands[2]) & CALL_V4_SET_FP_ARGS)
10379 output_asm_insn (\"crxor 6,6,6\", operands);
10380
10381 else if (INTVAL (operands[2]) & CALL_V4_CLEAR_FP_ARGS)
10382 output_asm_insn (\"creqv 6,6,6\", operands);
4697a36c 10383
a226df46 10384 return (DEFAULT_ABI == ABI_V4 && flag_pic) ? \"bl %z0@local\" : \"bl %z0\";
4697a36c 10385}"
b7ff3d82
DE
10386 [(set_attr "type" "branch")
10387 (set_attr "length" "4,8")])
04780ee7 10388
a260abc9
DE
10389(define_insn "*call_local64"
10390 [(call (mem:SI (match_operand:DI 0 "current_file_function_operand" "s,s"))
10391 (match_operand 1 "" "g,g"))
10392 (use (match_operand:SI 2 "immediate_operand" "O,n"))
10393 (clobber (match_scratch:SI 3 "=l,l"))]
10394 "TARGET_64BIT && (INTVAL (operands[2]) & CALL_LONG) == 0"
10395 "*
10396{
10397 if (INTVAL (operands[2]) & CALL_V4_SET_FP_ARGS)
10398 output_asm_insn (\"crxor 6,6,6\", operands);
10399
10400 else if (INTVAL (operands[2]) & CALL_V4_CLEAR_FP_ARGS)
10401 output_asm_insn (\"creqv 6,6,6\", operands);
10402
10403 return (DEFAULT_ABI == ABI_V4 && flag_pic) ? \"bl %z0@local\" : \"bl %z0\";
10404}"
10405 [(set_attr "type" "branch")
10406 (set_attr "length" "4,8")])
10407
cccf3bdc 10408(define_insn "*call_value_local32"
d18dba68 10409 [(set (match_operand 0 "" "")
a260abc9
DE
10410 (call (mem:SI (match_operand:SI 1 "current_file_function_operand" "s,s"))
10411 (match_operand 2 "" "g,g")))
10412 (use (match_operand:SI 3 "immediate_operand" "O,n"))
10413 (clobber (match_scratch:SI 4 "=l,l"))]
10414 "(INTVAL (operands[3]) & CALL_LONG) == 0"
10415 "*
10416{
10417 if (INTVAL (operands[3]) & CALL_V4_SET_FP_ARGS)
10418 output_asm_insn (\"crxor 6,6,6\", operands);
10419
10420 else if (INTVAL (operands[3]) & CALL_V4_CLEAR_FP_ARGS)
10421 output_asm_insn (\"creqv 6,6,6\", operands);
10422
10423 return (DEFAULT_ABI == ABI_V4 && flag_pic) ? \"bl %z1@local\" : \"bl %z1\";
10424}"
10425 [(set_attr "type" "branch")
10426 (set_attr "length" "4,8")])
10427
10428
cccf3bdc 10429(define_insn "*call_value_local64"
d18dba68 10430 [(set (match_operand 0 "" "")
a260abc9
DE
10431 (call (mem:SI (match_operand:DI 1 "current_file_function_operand" "s,s"))
10432 (match_operand 2 "" "g,g")))
10433 (use (match_operand:SI 3 "immediate_operand" "O,n"))
10434 (clobber (match_scratch:SI 4 "=l,l"))]
10435 "TARGET_64BIT && (INTVAL (operands[3]) & CALL_LONG) == 0"
10436 "*
10437{
10438 if (INTVAL (operands[3]) & CALL_V4_SET_FP_ARGS)
10439 output_asm_insn (\"crxor 6,6,6\", operands);
10440
10441 else if (INTVAL (operands[3]) & CALL_V4_CLEAR_FP_ARGS)
10442 output_asm_insn (\"creqv 6,6,6\", operands);
10443
10444 return (DEFAULT_ABI == ABI_V4 && flag_pic) ? \"bl %z1@local\" : \"bl %z1\";
10445}"
10446 [(set_attr "type" "branch")
10447 (set_attr "length" "4,8")])
10448
04780ee7 10449;; Call to function which may be in another module. Restore the TOC
911f679c 10450;; pointer (r2) after the call unless this is System V.
a0ab749a 10451;; Operand2 is nonzero if we are using the V.4 calling sequence and
4697a36c
MM
10452;; either the function was not prototyped, or it was prototyped as a
10453;; variable argument function. It is > 0 if FP registers were passed
10454;; and < 0 if they were not.
04780ee7 10455
cccf3bdc
DE
10456(define_insn "*call_indirect_nonlocal_aix32"
10457 [(call (mem:SI (match_operand:SI 0 "register_operand" "cl"))
10458 (match_operand 1 "" "g"))
10459 (use (reg:SI 2))
10460 (use (reg:SI 11))
10461 (set (reg:SI 2)
10462 (mem:SI (plus:SI (reg:SI 1) (const_int 20))))
c77e04ae 10463 (clobber (match_scratch:SI 2 "=l"))]
cccf3bdc
DE
10464 "TARGET_32BIT && DEFAULT_ABI == ABI_AIX"
10465 "b%T0l\;{l|lwz} 2,20(1)"
10466 [(set_attr "type" "jmpreg")
10467 (set_attr "length" "8")])
10468
a260abc9 10469(define_insn "*call_nonlocal_aix32"
cc4d5fec 10470 [(call (mem:SI (match_operand:SI 0 "symbol_ref_operand" "s"))
cccf3bdc
DE
10471 (match_operand 1 "" "g"))
10472 (use (match_operand:SI 2 "immediate_operand" "O"))
10473 (clobber (match_scratch:SI 3 "=l"))]
10474 "TARGET_32BIT
10475 && DEFAULT_ABI == ABI_AIX
5a19791c 10476 && (INTVAL (operands[2]) & CALL_LONG) == 0"
cccf3bdc 10477 "bl %z0\;%."
b7ff3d82 10478 [(set_attr "type" "branch")
cccf3bdc
DE
10479 (set_attr "length" "8")])
10480
10481(define_insn "*call_indirect_nonlocal_aix64"
10482 [(call (mem:SI (match_operand:DI 0 "register_operand" "cl"))
10483 (match_operand 1 "" "g"))
10484 (use (reg:DI 2))
10485 (use (reg:DI 11))
10486 (set (reg:DI 2)
10487 (mem:DI (plus:DI (reg:DI 1) (const_int 40))))
c77e04ae 10488 (clobber (match_scratch:SI 2 "=l"))]
cccf3bdc
DE
10489 "TARGET_64BIT && DEFAULT_ABI == ABI_AIX"
10490 "b%T0l\;ld 2,40(1)"
10491 [(set_attr "type" "jmpreg")
10492 (set_attr "length" "8")])
59313e4e 10493
a260abc9 10494(define_insn "*call_nonlocal_aix64"
cc4d5fec 10495 [(call (mem:SI (match_operand:DI 0 "symbol_ref_operand" "s"))
cccf3bdc
DE
10496 (match_operand 1 "" "g"))
10497 (use (match_operand:SI 2 "immediate_operand" "O"))
10498 (clobber (match_scratch:SI 3 "=l"))]
6ae08853 10499 "TARGET_64BIT
9ebbca7d 10500 && DEFAULT_ABI == ABI_AIX
a260abc9 10501 && (INTVAL (operands[2]) & CALL_LONG) == 0"
cccf3bdc 10502 "bl %z0\;%."
a260abc9 10503 [(set_attr "type" "branch")
cccf3bdc 10504 (set_attr "length" "8")])
7509c759 10505
cccf3bdc 10506(define_insn "*call_value_indirect_nonlocal_aix32"
d18dba68 10507 [(set (match_operand 0 "" "")
cccf3bdc
DE
10508 (call (mem:SI (match_operand:SI 1 "register_operand" "cl"))
10509 (match_operand 2 "" "g")))
10510 (use (reg:SI 2))
10511 (use (reg:SI 11))
10512 (set (reg:SI 2)
10513 (mem:SI (plus:SI (reg:SI 1) (const_int 20))))
10514 (clobber (match_scratch:SI 3 "=l"))]
10515 "TARGET_32BIT && DEFAULT_ABI == ABI_AIX"
10516 "b%T1l\;{l|lwz} 2,20(1)"
10517 [(set_attr "type" "jmpreg")
10518 (set_attr "length" "8")])
1fd4e8c1 10519
cccf3bdc 10520(define_insn "*call_value_nonlocal_aix32"
d18dba68 10521 [(set (match_operand 0 "" "")
cc4d5fec 10522 (call (mem:SI (match_operand:SI 1 "symbol_ref_operand" "s"))
cccf3bdc
DE
10523 (match_operand 2 "" "g")))
10524 (use (match_operand:SI 3 "immediate_operand" "O"))
10525 (clobber (match_scratch:SI 4 "=l"))]
10526 "TARGET_32BIT
10527 && DEFAULT_ABI == ABI_AIX
a260abc9 10528 && (INTVAL (operands[3]) & CALL_LONG) == 0"
cccf3bdc 10529 "bl %z1\;%."
b7ff3d82 10530 [(set_attr "type" "branch")
cccf3bdc 10531 (set_attr "length" "8")])
04780ee7 10532
cccf3bdc 10533(define_insn "*call_value_indirect_nonlocal_aix64"
d18dba68 10534 [(set (match_operand 0 "" "")
cccf3bdc
DE
10535 (call (mem:SI (match_operand:DI 1 "register_operand" "cl"))
10536 (match_operand 2 "" "g")))
10537 (use (reg:DI 2))
10538 (use (reg:DI 11))
10539 (set (reg:DI 2)
10540 (mem:DI (plus:DI (reg:DI 1) (const_int 40))))
10541 (clobber (match_scratch:SI 3 "=l"))]
10542 "TARGET_64BIT && DEFAULT_ABI == ABI_AIX"
10543 "b%T1l\;ld 2,40(1)"
10544 [(set_attr "type" "jmpreg")
10545 (set_attr "length" "8")])
10546
10547(define_insn "*call_value_nonlocal_aix64"
d18dba68 10548 [(set (match_operand 0 "" "")
cc4d5fec 10549 (call (mem:SI (match_operand:DI 1 "symbol_ref_operand" "s"))
cccf3bdc
DE
10550 (match_operand 2 "" "g")))
10551 (use (match_operand:SI 3 "immediate_operand" "O"))
10552 (clobber (match_scratch:SI 4 "=l"))]
6ae08853 10553 "TARGET_64BIT
9ebbca7d 10554 && DEFAULT_ABI == ABI_AIX
5a19791c 10555 && (INTVAL (operands[3]) & CALL_LONG) == 0"
cccf3bdc
DE
10556 "bl %z1\;%."
10557 [(set_attr "type" "branch")
10558 (set_attr "length" "8")])
10559
10560;; A function pointer under System V is just a normal pointer
10561;; operands[0] is the function pointer
10562;; operands[1] is the stack size to clean up
10563;; operands[2] is the value FUNCTION_ARG returns for the VOID argument
10564;; which indicates how to set cr1
10565
a5c76ee6
ZW
10566(define_insn "*call_indirect_nonlocal_sysv"
10567 [(call (mem:SI (match_operand:SI 0 "register_operand" "cl,cl"))
10568 (match_operand 1 "" "g,g"))
10569 (use (match_operand:SI 2 "immediate_operand" "O,n"))
10570 (clobber (match_scratch:SI 3 "=l,l"))]
50d440bc 10571 "DEFAULT_ABI == ABI_V4
f607bc57 10572 || DEFAULT_ABI == ABI_DARWIN"
911f679c 10573{
cccf3bdc 10574 if (INTVAL (operands[2]) & CALL_V4_SET_FP_ARGS)
a5c76ee6 10575 output_asm_insn ("crxor 6,6,6", operands);
6a4cee5f 10576
cccf3bdc 10577 else if (INTVAL (operands[2]) & CALL_V4_CLEAR_FP_ARGS)
a5c76ee6 10578 output_asm_insn ("creqv 6,6,6", operands);
7509c759 10579
a5c76ee6
ZW
10580 return "b%T0l";
10581}
10582 [(set_attr "type" "jmpreg,jmpreg")
10583 (set_attr "length" "4,8")])
cccf3bdc 10584
a5c76ee6
ZW
10585(define_insn "*call_nonlocal_sysv"
10586 [(call (mem:SI (match_operand:SI 0 "symbol_ref_operand" "s,s"))
10587 (match_operand 1 "" "g,g"))
10588 (use (match_operand:SI 2 "immediate_operand" "O,n"))
10589 (clobber (match_scratch:SI 3 "=l,l"))]
efdba735
SH
10590 "(DEFAULT_ABI == ABI_DARWIN
10591 || (DEFAULT_ABI == ABI_V4
10592 && (INTVAL (operands[2]) & CALL_LONG) == 0))"
a5c76ee6
ZW
10593{
10594 if (INTVAL (operands[2]) & CALL_V4_SET_FP_ARGS)
10595 output_asm_insn ("crxor 6,6,6", operands);
10596
10597 else if (INTVAL (operands[2]) & CALL_V4_CLEAR_FP_ARGS)
10598 output_asm_insn ("creqv 6,6,6", operands);
10599
c989f2f7 10600#if TARGET_MACHO
efdba735
SH
10601 return output_call(insn, operands, 0, 2);
10602#else
a5c76ee6 10603 return (DEFAULT_ABI == ABI_V4 && flag_pic) ? "bl %z0@plt" : "bl %z0";
6ae08853 10604#endif
a5c76ee6
ZW
10605}
10606 [(set_attr "type" "branch,branch")
10607 (set_attr "length" "4,8")])
10608
10609(define_insn "*call_value_indirect_nonlocal_sysv"
d18dba68 10610 [(set (match_operand 0 "" "")
a5c76ee6
ZW
10611 (call (mem:SI (match_operand:SI 1 "register_operand" "cl,cl"))
10612 (match_operand 2 "" "g,g")))
10613 (use (match_operand:SI 3 "immediate_operand" "O,n"))
10614 (clobber (match_scratch:SI 4 "=l,l"))]
50d440bc 10615 "DEFAULT_ABI == ABI_V4
f607bc57 10616 || DEFAULT_ABI == ABI_DARWIN"
b6c9286a 10617{
6a4cee5f 10618 if (INTVAL (operands[3]) & CALL_V4_SET_FP_ARGS)
a5c76ee6 10619 output_asm_insn ("crxor 6,6,6", operands);
6a4cee5f
MM
10620
10621 else if (INTVAL (operands[3]) & CALL_V4_CLEAR_FP_ARGS)
a5c76ee6 10622 output_asm_insn ("creqv 6,6,6", operands);
7509c759 10623
a5c76ee6
ZW
10624 return "b%T1l";
10625}
10626 [(set_attr "type" "jmpreg,jmpreg")
10627 (set_attr "length" "4,8")])
10628
10629(define_insn "*call_value_nonlocal_sysv"
10630 [(set (match_operand 0 "" "")
10631 (call (mem:SI (match_operand:SI 1 "symbol_ref_operand" "s,s"))
10632 (match_operand 2 "" "g,g")))
10633 (use (match_operand:SI 3 "immediate_operand" "O,n"))
10634 (clobber (match_scratch:SI 4 "=l,l"))]
efdba735
SH
10635 "(DEFAULT_ABI == ABI_DARWIN
10636 || (DEFAULT_ABI == ABI_V4
10637 && (INTVAL (operands[3]) & CALL_LONG) == 0))"
a5c76ee6
ZW
10638{
10639 if (INTVAL (operands[3]) & CALL_V4_SET_FP_ARGS)
10640 output_asm_insn ("crxor 6,6,6", operands);
10641
10642 else if (INTVAL (operands[3]) & CALL_V4_CLEAR_FP_ARGS)
10643 output_asm_insn ("creqv 6,6,6", operands);
10644
c989f2f7 10645#if TARGET_MACHO
efdba735
SH
10646 return output_call(insn, operands, 1, 3);
10647#else
a5c76ee6 10648 return (DEFAULT_ABI == ABI_V4 && flag_pic) ? "bl %z1@plt" : "bl %z1";
6ae08853 10649#endif
a5c76ee6
ZW
10650}
10651 [(set_attr "type" "branch,branch")
10652 (set_attr "length" "4,8")])
e6f948e3
RK
10653
10654;; Call subroutine returning any type.
e6f948e3
RK
10655(define_expand "untyped_call"
10656 [(parallel [(call (match_operand 0 "" "")
10657 (const_int 0))
10658 (match_operand 1 "" "")
10659 (match_operand 2 "" "")])]
10660 ""
10661 "
10662{
10663 int i;
10664
7d70b8b2 10665 emit_call_insn (GEN_CALL (operands[0], const0_rtx, const0_rtx, const0_rtx));
e6f948e3
RK
10666
10667 for (i = 0; i < XVECLEN (operands[2], 0); i++)
10668 {
10669 rtx set = XVECEXP (operands[2], 0, i);
10670 emit_move_insn (SET_DEST (set), SET_SRC (set));
10671 }
10672
10673 /* The optimizer does not know that the call sets the function value
10674 registers we stored in the result block. We avoid problems by
10675 claiming that all hard registers are used and clobbered at this
10676 point. */
10677 emit_insn (gen_blockage ());
10678
10679 DONE;
10680}")
10681
5e1bf043
DJ
10682;; sibling call patterns
10683(define_expand "sibcall"
10684 [(parallel [(call (mem:SI (match_operand 0 "address_operand" ""))
10685 (match_operand 1 "" ""))
10686 (use (match_operand 2 "" ""))
fe352c29 10687 (use (match_operand 3 "" ""))
5e1bf043
DJ
10688 (return)])]
10689 ""
10690 "
10691{
10692#if TARGET_MACHO
ab82a49f 10693 if (MACHOPIC_INDIRECT)
5e1bf043
DJ
10694 operands[0] = machopic_indirect_call_target (operands[0]);
10695#endif
10696
10697 if (GET_CODE (operands[0]) != MEM || GET_CODE (operands[1]) != CONST_INT)
10698 abort ();
10699
10700 operands[0] = XEXP (operands[0], 0);
fe352c29 10701 operands[3] = gen_reg_rtx (SImode);
5e1bf043
DJ
10702
10703}")
10704
10705;; this and similar patterns must be marked as using LR, otherwise
10706;; dataflow will try to delete the store into it. This is true
10707;; even when the actual reg to jump to is in CTR, when LR was
10708;; saved and restored around the PIC-setting BCL.
10709(define_insn "*sibcall_local32"
10710 [(call (mem:SI (match_operand:SI 0 "current_file_function_operand" "s,s"))
10711 (match_operand 1 "" "g,g"))
10712 (use (match_operand:SI 2 "immediate_operand" "O,n"))
fe352c29 10713 (use (match_operand:SI 3 "register_operand" "l,l"))
5e1bf043
DJ
10714 (return)]
10715 "(INTVAL (operands[2]) & CALL_LONG) == 0"
10716 "*
10717{
10718 if (INTVAL (operands[2]) & CALL_V4_SET_FP_ARGS)
10719 output_asm_insn (\"crxor 6,6,6\", operands);
10720
10721 else if (INTVAL (operands[2]) & CALL_V4_CLEAR_FP_ARGS)
10722 output_asm_insn (\"creqv 6,6,6\", operands);
10723
10724 return (DEFAULT_ABI == ABI_V4 && flag_pic) ? \"b %z0@local\" : \"b %z0\";
10725}"
10726 [(set_attr "type" "branch")
10727 (set_attr "length" "4,8")])
10728
10729(define_insn "*sibcall_local64"
10730 [(call (mem:SI (match_operand:DI 0 "current_file_function_operand" "s,s"))
10731 (match_operand 1 "" "g,g"))
10732 (use (match_operand:SI 2 "immediate_operand" "O,n"))
fe352c29 10733 (use (match_operand:SI 3 "register_operand" "l,l"))
5e1bf043
DJ
10734 (return)]
10735 "TARGET_64BIT && (INTVAL (operands[2]) & CALL_LONG) == 0"
10736 "*
10737{
10738 if (INTVAL (operands[2]) & CALL_V4_SET_FP_ARGS)
10739 output_asm_insn (\"crxor 6,6,6\", operands);
10740
10741 else if (INTVAL (operands[2]) & CALL_V4_CLEAR_FP_ARGS)
10742 output_asm_insn (\"creqv 6,6,6\", operands);
10743
10744 return (DEFAULT_ABI == ABI_V4 && flag_pic) ? \"b %z0@local\" : \"b %z0\";
10745}"
10746 [(set_attr "type" "branch")
10747 (set_attr "length" "4,8")])
10748
10749(define_insn "*sibcall_value_local32"
10750 [(set (match_operand 0 "" "")
10751 (call (mem:SI (match_operand:SI 1 "current_file_function_operand" "s,s"))
10752 (match_operand 2 "" "g,g")))
10753 (use (match_operand:SI 3 "immediate_operand" "O,n"))
fe352c29 10754 (use (match_operand:SI 4 "register_operand" "l,l"))
5e1bf043
DJ
10755 (return)]
10756 "(INTVAL (operands[3]) & CALL_LONG) == 0"
10757 "*
10758{
10759 if (INTVAL (operands[3]) & CALL_V4_SET_FP_ARGS)
10760 output_asm_insn (\"crxor 6,6,6\", operands);
10761
10762 else if (INTVAL (operands[3]) & CALL_V4_CLEAR_FP_ARGS)
10763 output_asm_insn (\"creqv 6,6,6\", operands);
10764
10765 return (DEFAULT_ABI == ABI_V4 && flag_pic) ? \"b %z1@local\" : \"b %z1\";
10766}"
10767 [(set_attr "type" "branch")
10768 (set_attr "length" "4,8")])
10769
10770
10771(define_insn "*sibcall_value_local64"
10772 [(set (match_operand 0 "" "")
10773 (call (mem:SI (match_operand:DI 1 "current_file_function_operand" "s,s"))
10774 (match_operand 2 "" "g,g")))
10775 (use (match_operand:SI 3 "immediate_operand" "O,n"))
fe352c29 10776 (use (match_operand:SI 4 "register_operand" "l,l"))
5e1bf043
DJ
10777 (return)]
10778 "TARGET_64BIT && (INTVAL (operands[3]) & CALL_LONG) == 0"
10779 "*
10780{
10781 if (INTVAL (operands[3]) & CALL_V4_SET_FP_ARGS)
10782 output_asm_insn (\"crxor 6,6,6\", operands);
10783
10784 else if (INTVAL (operands[3]) & CALL_V4_CLEAR_FP_ARGS)
10785 output_asm_insn (\"creqv 6,6,6\", operands);
10786
10787 return (DEFAULT_ABI == ABI_V4 && flag_pic) ? \"b %z1@local\" : \"b %z1\";
10788}"
10789 [(set_attr "type" "branch")
10790 (set_attr "length" "4,8")])
10791
10792(define_insn "*sibcall_nonlocal_aix32"
10793 [(call (mem:SI (match_operand:SI 0 "symbol_ref_operand" "s"))
10794 (match_operand 1 "" "g"))
10795 (use (match_operand:SI 2 "immediate_operand" "O"))
fe352c29 10796 (use (match_operand:SI 3 "register_operand" "l"))
5e1bf043
DJ
10797 (return)]
10798 "TARGET_32BIT
10799 && DEFAULT_ABI == ABI_AIX
10800 && (INTVAL (operands[2]) & CALL_LONG) == 0"
10801 "b %z0"
10802 [(set_attr "type" "branch")
10803 (set_attr "length" "4")])
10804
10805(define_insn "*sibcall_nonlocal_aix64"
10806 [(call (mem:SI (match_operand:DI 0 "symbol_ref_operand" "s"))
10807 (match_operand 1 "" "g"))
10808 (use (match_operand:SI 2 "immediate_operand" "O"))
fe352c29 10809 (use (match_operand:SI 3 "register_operand" "l"))
5e1bf043 10810 (return)]
6ae08853 10811 "TARGET_64BIT
5e1bf043
DJ
10812 && DEFAULT_ABI == ABI_AIX
10813 && (INTVAL (operands[2]) & CALL_LONG) == 0"
10814 "b %z0"
10815 [(set_attr "type" "branch")
10816 (set_attr "length" "4")])
10817
10818(define_insn "*sibcall_value_nonlocal_aix32"
10819 [(set (match_operand 0 "" "")
10820 (call (mem:SI (match_operand:SI 1 "symbol_ref_operand" "s"))
10821 (match_operand 2 "" "g")))
10822 (use (match_operand:SI 3 "immediate_operand" "O"))
fe352c29 10823 (use (match_operand:SI 4 "register_operand" "l"))
5e1bf043
DJ
10824 (return)]
10825 "TARGET_32BIT
10826 && DEFAULT_ABI == ABI_AIX
10827 && (INTVAL (operands[3]) & CALL_LONG) == 0"
10828 "b %z1"
10829 [(set_attr "type" "branch")
10830 (set_attr "length" "4")])
10831
10832(define_insn "*sibcall_value_nonlocal_aix64"
10833 [(set (match_operand 0 "" "")
10834 (call (mem:SI (match_operand:DI 1 "symbol_ref_operand" "s"))
10835 (match_operand 2 "" "g")))
10836 (use (match_operand:SI 3 "immediate_operand" "O"))
fe352c29 10837 (use (match_operand:SI 4 "register_operand" "l"))
5e1bf043 10838 (return)]
6ae08853 10839 "TARGET_64BIT
5e1bf043
DJ
10840 && DEFAULT_ABI == ABI_AIX
10841 && (INTVAL (operands[3]) & CALL_LONG) == 0"
10842 "b %z1"
10843 [(set_attr "type" "branch")
10844 (set_attr "length" "4")])
10845
10846(define_insn "*sibcall_nonlocal_sysv"
10847 [(call (mem:SI (match_operand:SI 0 "symbol_ref_operand" "s,s"))
10848 (match_operand 1 "" ""))
10849 (use (match_operand 2 "immediate_operand" "O,n"))
fe352c29 10850 (use (match_operand:SI 3 "register_operand" "l,l"))
5e1bf043
DJ
10851 (return)]
10852 "(DEFAULT_ABI == ABI_DARWIN
50d440bc 10853 || DEFAULT_ABI == ABI_V4)
5e1bf043
DJ
10854 && (INTVAL (operands[2]) & CALL_LONG) == 0"
10855 "*
10856{
10857 if (INTVAL (operands[2]) & CALL_V4_SET_FP_ARGS)
10858 output_asm_insn (\"crxor 6,6,6\", operands);
10859
10860 else if (INTVAL (operands[2]) & CALL_V4_CLEAR_FP_ARGS)
10861 output_asm_insn (\"creqv 6,6,6\", operands);
10862
10863 return (DEFAULT_ABI == ABI_V4 && flag_pic) ? \"b %z0@plt\" : \"b %z0\";
10864}"
10865 [(set_attr "type" "branch,branch")
10866 (set_attr "length" "4,8")])
10867
10868(define_expand "sibcall_value"
10869 [(parallel [(set (match_operand 0 "register_operand" "")
10870 (call (mem:SI (match_operand 1 "address_operand" ""))
10871 (match_operand 2 "" "")))
10872 (use (match_operand 3 "" ""))
fe352c29 10873 (use (match_operand 4 "" ""))
5e1bf043
DJ
10874 (return)])]
10875 ""
10876 "
10877{
10878#if TARGET_MACHO
ab82a49f 10879 if (MACHOPIC_INDIRECT)
5e1bf043
DJ
10880 operands[1] = machopic_indirect_call_target (operands[1]);
10881#endif
10882
10883 if (GET_CODE (operands[1]) != MEM || GET_CODE (operands[2]) != CONST_INT)
10884 abort ();
10885
10886 operands[1] = XEXP (operands[1], 0);
fe352c29 10887 operands[4] = gen_reg_rtx (SImode);
5e1bf043
DJ
10888
10889}")
10890
10891(define_insn "*sibcall_value_nonlocal_sysv"
10892 [(set (match_operand 0 "" "")
10893 (call (mem:SI (match_operand:SI 1 "symbol_ref_operand" "s,s"))
10894 (match_operand 2 "" "")))
10895 (use (match_operand:SI 3 "immediate_operand" "O,n"))
fe352c29 10896 (use (match_operand:SI 4 "register_operand" "l,l"))
5e1bf043
DJ
10897 (return)]
10898 "(DEFAULT_ABI == ABI_DARWIN
50d440bc 10899 || DEFAULT_ABI == ABI_V4)
5e1bf043
DJ
10900 && (INTVAL (operands[3]) & CALL_LONG) == 0"
10901 "*
10902{
10903 if (INTVAL (operands[2]) & CALL_V4_SET_FP_ARGS)
10904 output_asm_insn (\"crxor 6,6,6\", operands);
10905
10906 else if (INTVAL (operands[2]) & CALL_V4_CLEAR_FP_ARGS)
10907 output_asm_insn (\"creqv 6,6,6\", operands);
10908
10909 return (DEFAULT_ABI == ABI_V4 && flag_pic) ? \"b %z1@plt\" : \"b %z1\";
10910}"
10911 [(set_attr "type" "branch,branch")
10912 (set_attr "length" "4,8")])
10913
10914(define_expand "sibcall_epilogue"
10915 [(use (const_int 0))]
10916 "TARGET_SCHED_PROLOG"
10917 "
10918{
10919 rs6000_emit_epilogue (TRUE);
10920 DONE;
10921}")
10922
e6f948e3
RK
10923;; UNSPEC_VOLATILE is considered to use and clobber all hard registers and
10924;; all of memory. This blocks insns from being moved across this point.
10925
10926(define_insn "blockage"
615158e2 10927 [(unspec_volatile [(const_int 0)] UNSPECV_BLOCK)]
e6f948e3
RK
10928 ""
10929 "")
1fd4e8c1
RK
10930\f
10931;; Compare insns are next. Note that the RS/6000 has two types of compares,
7e69e155 10932;; signed & unsigned, and one type of branch.
1fd4e8c1
RK
10933;;
10934;; Start with the DEFINE_EXPANDs to generate the rtl for compares, scc
10935;; insns, and branches. We store the operands of compares until we see
10936;; how it is used.
10937(define_expand "cmpsi"
10938 [(set (cc0)
cd2b37d9 10939 (compare (match_operand:SI 0 "gpc_reg_operand" "")
1fd4e8c1
RK
10940 (match_operand:SI 1 "reg_or_short_operand" "")))]
10941 ""
10942 "
10943{
10944 /* Take care of the possibility that operands[1] might be negative but
10945 this might be a logical operation. That insn doesn't exist. */
10946 if (GET_CODE (operands[1]) == CONST_INT
10947 && INTVAL (operands[1]) < 0)
10948 operands[1] = force_reg (SImode, operands[1]);
10949
10950 rs6000_compare_op0 = operands[0];
10951 rs6000_compare_op1 = operands[1];
10952 rs6000_compare_fp_p = 0;
10953 DONE;
10954}")
10955
266eb58a
DE
10956(define_expand "cmpdi"
10957 [(set (cc0)
10958 (compare (match_operand:DI 0 "gpc_reg_operand" "")
10959 (match_operand:DI 1 "reg_or_short_operand" "")))]
10960 "TARGET_POWERPC64"
10961 "
10962{
10963 /* Take care of the possibility that operands[1] might be negative but
10964 this might be a logical operation. That insn doesn't exist. */
10965 if (GET_CODE (operands[1]) == CONST_INT
10966 && INTVAL (operands[1]) < 0)
10967 operands[1] = force_reg (DImode, operands[1]);
10968
10969 rs6000_compare_op0 = operands[0];
10970 rs6000_compare_op1 = operands[1];
10971 rs6000_compare_fp_p = 0;
10972 DONE;
10973}")
10974
1fd4e8c1 10975(define_expand "cmpsf"
cd2b37d9
RK
10976 [(set (cc0) (compare (match_operand:SF 0 "gpc_reg_operand" "")
10977 (match_operand:SF 1 "gpc_reg_operand" "")))]
d14a6d05 10978 "TARGET_HARD_FLOAT"
1fd4e8c1
RK
10979 "
10980{
10981 rs6000_compare_op0 = operands[0];
10982 rs6000_compare_op1 = operands[1];
10983 rs6000_compare_fp_p = 1;
10984 DONE;
10985}")
10986
10987(define_expand "cmpdf"
cd2b37d9
RK
10988 [(set (cc0) (compare (match_operand:DF 0 "gpc_reg_operand" "")
10989 (match_operand:DF 1 "gpc_reg_operand" "")))]
a3170dc6 10990 "TARGET_HARD_FLOAT && TARGET_FPRS"
1fd4e8c1
RK
10991 "
10992{
10993 rs6000_compare_op0 = operands[0];
10994 rs6000_compare_op1 = operands[1];
10995 rs6000_compare_fp_p = 1;
10996 DONE;
10997}")
10998
d6f99ca4 10999(define_expand "cmptf"
e7a4130e
DE
11000 [(set (cc0) (compare (match_operand:TF 0 "gpc_reg_operand" "")
11001 (match_operand:TF 1 "gpc_reg_operand" "")))]
39e63627
GK
11002 "(DEFAULT_ABI == ABI_AIX || DEFAULT_ABI == ABI_DARWIN)
11003 && TARGET_HARD_FLOAT && TARGET_FPRS && TARGET_LONG_DOUBLE_128"
d6f99ca4
DE
11004 "
11005{
11006 rs6000_compare_op0 = operands[0];
11007 rs6000_compare_op1 = operands[1];
11008 rs6000_compare_fp_p = 1;
11009 DONE;
11010}")
11011
1fd4e8c1 11012(define_expand "beq"
39a10a29 11013 [(use (match_operand 0 "" ""))]
1fd4e8c1 11014 ""
39a10a29 11015 "{ rs6000_emit_cbranch (EQ, operands[0]); DONE; }")
1fd4e8c1
RK
11016
11017(define_expand "bne"
39a10a29 11018 [(use (match_operand 0 "" ""))]
1fd4e8c1 11019 ""
39a10a29 11020 "{ rs6000_emit_cbranch (NE, operands[0]); DONE; }")
1fd4e8c1 11021
39a10a29
GK
11022(define_expand "bge"
11023 [(use (match_operand 0 "" ""))]
1fd4e8c1 11024 ""
39a10a29 11025 "{ rs6000_emit_cbranch (GE, operands[0]); DONE; }")
1fd4e8c1
RK
11026
11027(define_expand "bgt"
39a10a29 11028 [(use (match_operand 0 "" ""))]
1fd4e8c1 11029 ""
39a10a29 11030 "{ rs6000_emit_cbranch (GT, operands[0]); DONE; }")
1fd4e8c1
RK
11031
11032(define_expand "ble"
39a10a29 11033 [(use (match_operand 0 "" ""))]
1fd4e8c1 11034 ""
39a10a29 11035 "{ rs6000_emit_cbranch (LE, operands[0]); DONE; }")
1fd4e8c1 11036
39a10a29
GK
11037(define_expand "blt"
11038 [(use (match_operand 0 "" ""))]
1fd4e8c1 11039 ""
39a10a29 11040 "{ rs6000_emit_cbranch (LT, operands[0]); DONE; }")
1fd4e8c1 11041
39a10a29
GK
11042(define_expand "bgeu"
11043 [(use (match_operand 0 "" ""))]
1fd4e8c1 11044 ""
39a10a29 11045 "{ rs6000_emit_cbranch (GEU, operands[0]); DONE; }")
1fd4e8c1 11046
39a10a29
GK
11047(define_expand "bgtu"
11048 [(use (match_operand 0 "" ""))]
1fd4e8c1 11049 ""
39a10a29 11050 "{ rs6000_emit_cbranch (GTU, operands[0]); DONE; }")
1fd4e8c1 11051
39a10a29
GK
11052(define_expand "bleu"
11053 [(use (match_operand 0 "" ""))]
1fd4e8c1 11054 ""
39a10a29 11055 "{ rs6000_emit_cbranch (LEU, operands[0]); DONE; }")
1fd4e8c1 11056
39a10a29
GK
11057(define_expand "bltu"
11058 [(use (match_operand 0 "" ""))]
1fd4e8c1 11059 ""
39a10a29 11060 "{ rs6000_emit_cbranch (LTU, operands[0]); DONE; }")
1fd4e8c1 11061
1c882ea4 11062(define_expand "bunordered"
39a10a29 11063 [(use (match_operand 0 "" ""))]
7a1bf2f9 11064 "! (TARGET_HARD_FLOAT && TARGET_E500 && !TARGET_FPRS)"
39a10a29 11065 "{ rs6000_emit_cbranch (UNORDERED, operands[0]); DONE; }")
1c882ea4
GK
11066
11067(define_expand "bordered"
39a10a29 11068 [(use (match_operand 0 "" ""))]
7a1bf2f9 11069 "! (TARGET_HARD_FLOAT && TARGET_E500 && !TARGET_FPRS)"
39a10a29 11070 "{ rs6000_emit_cbranch (ORDERED, operands[0]); DONE; }")
1c882ea4
GK
11071
11072(define_expand "buneq"
39a10a29 11073 [(use (match_operand 0 "" ""))]
1c882ea4 11074 ""
39a10a29 11075 "{ rs6000_emit_cbranch (UNEQ, operands[0]); DONE; }")
1c882ea4
GK
11076
11077(define_expand "bunge"
39a10a29 11078 [(use (match_operand 0 "" ""))]
1c882ea4 11079 ""
39a10a29 11080 "{ rs6000_emit_cbranch (UNGE, operands[0]); DONE; }")
1c882ea4
GK
11081
11082(define_expand "bungt"
39a10a29 11083 [(use (match_operand 0 "" ""))]
1c882ea4 11084 ""
39a10a29 11085 "{ rs6000_emit_cbranch (UNGT, operands[0]); DONE; }")
1c882ea4
GK
11086
11087(define_expand "bunle"
39a10a29 11088 [(use (match_operand 0 "" ""))]
1c882ea4 11089 ""
39a10a29 11090 "{ rs6000_emit_cbranch (UNLE, operands[0]); DONE; }")
1c882ea4
GK
11091
11092(define_expand "bunlt"
39a10a29 11093 [(use (match_operand 0 "" ""))]
1c882ea4 11094 ""
39a10a29 11095 "{ rs6000_emit_cbranch (UNLT, operands[0]); DONE; }")
1c882ea4
GK
11096
11097(define_expand "bltgt"
39a10a29 11098 [(use (match_operand 0 "" ""))]
1c882ea4 11099 ""
39a10a29 11100 "{ rs6000_emit_cbranch (LTGT, operands[0]); DONE; }")
1c882ea4 11101
1fd4e8c1
RK
11102;; For SNE, we would prefer that the xor/abs sequence be used for integers.
11103;; For SEQ, likewise, except that comparisons with zero should be done
11104;; with an scc insns. However, due to the order that combine see the
11105;; resulting insns, we must, in fact, allow SEQ for integers. Fail in
11106;; the cases we don't want to handle.
11107(define_expand "seq"
39a10a29 11108 [(clobber (match_operand:SI 0 "gpc_reg_operand" ""))]
1fd4e8c1 11109 ""
39a10a29 11110 "{ rs6000_emit_sCOND (EQ, operands[0]); DONE; }")
1fd4e8c1
RK
11111
11112(define_expand "sne"
39a10a29 11113 [(clobber (match_operand:SI 0 "gpc_reg_operand" ""))]
1fd4e8c1
RK
11114 ""
11115 "
6ae08853 11116{
39a10a29 11117 if (! rs6000_compare_fp_p)
1fd4e8c1
RK
11118 FAIL;
11119
6ae08853 11120 rs6000_emit_sCOND (NE, operands[0]);
39a10a29 11121 DONE;
1fd4e8c1
RK
11122}")
11123
b7053a3f
GK
11124;; A >= 0 is best done the portable way for A an integer.
11125(define_expand "sge"
39a10a29 11126 [(clobber (match_operand:SI 0 "gpc_reg_operand" ""))]
1fd4e8c1
RK
11127 ""
11128 "
5638268e
DE
11129{
11130 if (! rs6000_compare_fp_p
11131 && (! TARGET_POWER || rs6000_compare_op1 == const0_rtx))
1fd4e8c1
RK
11132 FAIL;
11133
b7053a3f 11134 rs6000_emit_sCOND (GE, operands[0]);
39a10a29 11135 DONE;
1fd4e8c1
RK
11136}")
11137
b7053a3f
GK
11138;; A > 0 is best done using the portable sequence, so fail in that case.
11139(define_expand "sgt"
39a10a29 11140 [(clobber (match_operand:SI 0 "gpc_reg_operand" ""))]
1fd4e8c1
RK
11141 ""
11142 "
5638268e 11143{
b7053a3f 11144 if (! rs6000_compare_fp_p
5638268e 11145 && (! TARGET_POWER || rs6000_compare_op1 == const0_rtx))
1fd4e8c1
RK
11146 FAIL;
11147
6ae08853 11148 rs6000_emit_sCOND (GT, operands[0]);
39a10a29 11149 DONE;
1fd4e8c1
RK
11150}")
11151
b7053a3f
GK
11152;; A <= 0 is best done the portable way for A an integer.
11153(define_expand "sle"
39a10a29 11154 [(clobber (match_operand:SI 0 "gpc_reg_operand" ""))]
1fd4e8c1 11155 ""
5638268e
DE
11156 "
11157{
11158 if (! rs6000_compare_fp_p
11159 && (! TARGET_POWER || rs6000_compare_op1 == const0_rtx))
11160 FAIL;
11161
6ae08853 11162 rs6000_emit_sCOND (LE, operands[0]);
5638268e
DE
11163 DONE;
11164}")
1fd4e8c1 11165
b7053a3f
GK
11166;; A < 0 is best done in the portable way for A an integer.
11167(define_expand "slt"
39a10a29 11168 [(clobber (match_operand:SI 0 "gpc_reg_operand" ""))]
1fd4e8c1
RK
11169 ""
11170 "
5638268e 11171{
6ae08853 11172 if (! rs6000_compare_fp_p
5638268e 11173 && (! TARGET_POWER || rs6000_compare_op1 == const0_rtx))
1fd4e8c1
RK
11174 FAIL;
11175
6ae08853 11176 rs6000_emit_sCOND (LT, operands[0]);
39a10a29 11177 DONE;
1fd4e8c1
RK
11178}")
11179
b7053a3f
GK
11180(define_expand "sgeu"
11181 [(clobber (match_operand:SI 0 "gpc_reg_operand" ""))]
11182 ""
11183 "{ rs6000_emit_sCOND (GEU, operands[0]); DONE; }")
11184
1fd4e8c1 11185(define_expand "sgtu"
39a10a29 11186 [(clobber (match_operand:SI 0 "gpc_reg_operand" ""))]
1fd4e8c1 11187 ""
39a10a29 11188 "{ rs6000_emit_sCOND (GTU, operands[0]); DONE; }")
1fd4e8c1 11189
b7053a3f
GK
11190(define_expand "sleu"
11191 [(clobber (match_operand:SI 0 "gpc_reg_operand" ""))]
11192 ""
11193 "{ rs6000_emit_sCOND (LEU, operands[0]); DONE; }")
11194
1fd4e8c1 11195(define_expand "sltu"
39a10a29 11196 [(clobber (match_operand:SI 0 "gpc_reg_operand" ""))]
1fd4e8c1 11197 ""
39a10a29 11198 "{ rs6000_emit_sCOND (LTU, operands[0]); DONE; }")
1fd4e8c1 11199
b7053a3f 11200(define_expand "sunordered"
39a10a29 11201 [(clobber (match_operand:SI 0 "gpc_reg_operand" ""))]
1fd4e8c1 11202 ""
b7053a3f 11203 "{ rs6000_emit_sCOND (UNORDERED, operands[0]); DONE; }")
1fd4e8c1 11204
b7053a3f 11205(define_expand "sordered"
39a10a29 11206 [(clobber (match_operand:SI 0 "gpc_reg_operand" ""))]
1fd4e8c1 11207 ""
b7053a3f
GK
11208 "{ rs6000_emit_sCOND (ORDERED, operands[0]); DONE; }")
11209
11210(define_expand "suneq"
11211 [(clobber (match_operand:SI 0 "gpc_reg_operand" ""))]
11212 ""
11213 "{ rs6000_emit_sCOND (UNEQ, operands[0]); DONE; }")
11214
11215(define_expand "sunge"
11216 [(clobber (match_operand:SI 0 "gpc_reg_operand" ""))]
11217 ""
11218 "{ rs6000_emit_sCOND (UNGE, operands[0]); DONE; }")
11219
11220(define_expand "sungt"
11221 [(clobber (match_operand:SI 0 "gpc_reg_operand" ""))]
11222 ""
11223 "{ rs6000_emit_sCOND (UNGT, operands[0]); DONE; }")
11224
11225(define_expand "sunle"
11226 [(clobber (match_operand:SI 0 "gpc_reg_operand" ""))]
11227 ""
11228 "{ rs6000_emit_sCOND (UNLE, operands[0]); DONE; }")
11229
11230(define_expand "sunlt"
11231 [(clobber (match_operand:SI 0 "gpc_reg_operand" ""))]
11232 ""
11233 "{ rs6000_emit_sCOND (UNLT, operands[0]); DONE; }")
11234
11235(define_expand "sltgt"
11236 [(clobber (match_operand:SI 0 "gpc_reg_operand" ""))]
11237 ""
11238 "{ rs6000_emit_sCOND (LTGT, operands[0]); DONE; }")
11239
1fd4e8c1
RK
11240\f
11241;; Here are the actual compare insns.
acad7ed3 11242(define_insn "*cmpsi_internal1"
1fd4e8c1 11243 [(set (match_operand:CC 0 "cc_reg_operand" "=y")
cd2b37d9 11244 (compare:CC (match_operand:SI 1 "gpc_reg_operand" "r")
1fd4e8c1
RK
11245 (match_operand:SI 2 "reg_or_short_operand" "rI")))]
11246 ""
7f340546 11247 "{cmp%I2|cmpw%I2} %0,%1,%2"
b54cf83a 11248 [(set_attr "type" "cmp")])
1fd4e8c1 11249
acad7ed3 11250(define_insn "*cmpdi_internal1"
266eb58a
DE
11251 [(set (match_operand:CC 0 "cc_reg_operand" "=y")
11252 (compare:CC (match_operand:DI 1 "gpc_reg_operand" "r")
11253 (match_operand:DI 2 "reg_or_short_operand" "rI")))]
11254 "TARGET_POWERPC64"
11255 "cmpd%I2 %0,%1,%2"
b54cf83a 11256 [(set_attr "type" "cmp")])
266eb58a 11257
f357808b
RK
11258;; If we are comparing a register for equality with a large constant,
11259;; we can do this with an XOR followed by a compare. But we need a scratch
11260;; register for the result of the XOR.
11261
11262(define_split
11263 [(set (match_operand:CC 0 "cc_reg_operand" "")
cd2b37d9 11264 (compare:CC (match_operand:SI 1 "gpc_reg_operand" "")
f357808b 11265 (match_operand:SI 2 "non_short_cint_operand" "")))
cd2b37d9 11266 (clobber (match_operand:SI 3 "gpc_reg_operand" ""))]
f357808b
RK
11267 "find_single_use (operands[0], insn, 0)
11268 && (GET_CODE (*find_single_use (operands[0], insn, 0)) == EQ
11269 || GET_CODE (*find_single_use (operands[0], insn, 0)) == NE)"
11270 [(set (match_dup 3) (xor:SI (match_dup 1) (match_dup 4)))
11271 (set (match_dup 0) (compare:CC (match_dup 3) (match_dup 5)))]
11272 "
11273{
11274 /* Get the constant we are comparing against, C, and see what it looks like
11275 sign-extended to 16 bits. Then see what constant could be XOR'ed
11276 with C to get the sign-extended value. */
11277
5f59ecb7 11278 HOST_WIDE_INT c = INTVAL (operands[2]);
a65c591c 11279 HOST_WIDE_INT sextc = ((c & 0xffff) ^ 0x8000) - 0x8000;
5f59ecb7 11280 HOST_WIDE_INT xorv = c ^ sextc;
f357808b 11281
89e9f3a8
MM
11282 operands[4] = GEN_INT (xorv);
11283 operands[5] = GEN_INT (sextc);
f357808b
RK
11284}")
11285
acad7ed3 11286(define_insn "*cmpsi_internal2"
1fd4e8c1 11287 [(set (match_operand:CCUNS 0 "cc_reg_operand" "=y")
cd2b37d9 11288 (compare:CCUNS (match_operand:SI 1 "gpc_reg_operand" "r")
9ebbca7d 11289 (match_operand:SI 2 "reg_or_u_short_operand" "rK")))]
1fd4e8c1 11290 ""
e2c953b6 11291 "{cmpl%I2|cmplw%I2} %0,%1,%b2"
b54cf83a 11292 [(set_attr "type" "cmp")])
1fd4e8c1 11293
acad7ed3 11294(define_insn "*cmpdi_internal2"
266eb58a
DE
11295 [(set (match_operand:CCUNS 0 "cc_reg_operand" "=y")
11296 (compare:CCUNS (match_operand:DI 1 "gpc_reg_operand" "r")
9ebbca7d 11297 (match_operand:DI 2 "reg_or_u_short_operand" "rK")))]
266eb58a 11298 ""
e2c953b6 11299 "cmpld%I2 %0,%1,%b2"
b54cf83a 11300 [(set_attr "type" "cmp")])
266eb58a 11301
1fd4e8c1
RK
11302;; The following two insns don't exist as single insns, but if we provide
11303;; them, we can swap an add and compare, which will enable us to overlap more
11304;; of the required delay between a compare and branch. We generate code for
11305;; them by splitting.
11306
11307(define_insn ""
11308 [(set (match_operand:CC 3 "cc_reg_operand" "=y")
cd2b37d9 11309 (compare:CC (match_operand:SI 1 "gpc_reg_operand" "r")
1fd4e8c1 11310 (match_operand:SI 2 "short_cint_operand" "i")))
cd2b37d9 11311 (set (match_operand:SI 0 "gpc_reg_operand" "=r")
1fd4e8c1
RK
11312 (plus:SI (match_dup 1) (match_operand:SI 4 "short_cint_operand" "i")))]
11313 ""
baf97f86
RK
11314 "#"
11315 [(set_attr "length" "8")])
7e69e155 11316
1fd4e8c1
RK
11317(define_insn ""
11318 [(set (match_operand:CCUNS 3 "cc_reg_operand" "=y")
cd2b37d9 11319 (compare:CCUNS (match_operand:SI 1 "gpc_reg_operand" "r")
1fd4e8c1 11320 (match_operand:SI 2 "u_short_cint_operand" "i")))
cd2b37d9 11321 (set (match_operand:SI 0 "gpc_reg_operand" "=r")
1fd4e8c1
RK
11322 (plus:SI (match_dup 1) (match_operand:SI 4 "short_cint_operand" "i")))]
11323 ""
baf97f86
RK
11324 "#"
11325 [(set_attr "length" "8")])
7e69e155 11326
1fd4e8c1
RK
11327(define_split
11328 [(set (match_operand:CC 3 "cc_reg_operand" "")
cd2b37d9 11329 (compare:CC (match_operand:SI 1 "gpc_reg_operand" "")
1fd4e8c1 11330 (match_operand:SI 2 "short_cint_operand" "")))
cd2b37d9 11331 (set (match_operand:SI 0 "gpc_reg_operand" "")
1fd4e8c1
RK
11332 (plus:SI (match_dup 1) (match_operand:SI 4 "short_cint_operand" "")))]
11333 ""
11334 [(set (match_dup 3) (compare:CC (match_dup 1) (match_dup 2)))
11335 (set (match_dup 0) (plus:SI (match_dup 1) (match_dup 4)))])
11336
11337(define_split
11338 [(set (match_operand:CCUNS 3 "cc_reg_operand" "")
cd2b37d9 11339 (compare:CCUNS (match_operand:SI 1 "gpc_reg_operand" "")
1fd4e8c1 11340 (match_operand:SI 2 "u_short_cint_operand" "")))
cd2b37d9 11341 (set (match_operand:SI 0 "gpc_reg_operand" "")
1fd4e8c1
RK
11342 (plus:SI (match_dup 1) (match_operand:SI 4 "short_cint_operand" "")))]
11343 ""
11344 [(set (match_dup 3) (compare:CCUNS (match_dup 1) (match_dup 2)))
11345 (set (match_dup 0) (plus:SI (match_dup 1) (match_dup 4)))])
11346
acad7ed3 11347(define_insn "*cmpsf_internal1"
1fd4e8c1 11348 [(set (match_operand:CCFP 0 "cc_reg_operand" "=y")
cd2b37d9
RK
11349 (compare:CCFP (match_operand:SF 1 "gpc_reg_operand" "f")
11350 (match_operand:SF 2 "gpc_reg_operand" "f")))]
a3170dc6 11351 "TARGET_HARD_FLOAT && TARGET_FPRS"
1fd4e8c1
RK
11352 "fcmpu %0,%1,%2"
11353 [(set_attr "type" "fpcompare")])
11354
acad7ed3 11355(define_insn "*cmpdf_internal1"
1fd4e8c1 11356 [(set (match_operand:CCFP 0 "cc_reg_operand" "=y")
cd2b37d9
RK
11357 (compare:CCFP (match_operand:DF 1 "gpc_reg_operand" "f")
11358 (match_operand:DF 2 "gpc_reg_operand" "f")))]
a3170dc6 11359 "TARGET_HARD_FLOAT && TARGET_FPRS"
1fd4e8c1
RK
11360 "fcmpu %0,%1,%2"
11361 [(set_attr "type" "fpcompare")])
d6f99ca4
DE
11362
11363;; Only need to compare second words if first words equal
11364(define_insn "*cmptf_internal1"
11365 [(set (match_operand:CCFP 0 "cc_reg_operand" "=y")
11366 (compare:CCFP (match_operand:TF 1 "gpc_reg_operand" "f")
11367 (match_operand:TF 2 "gpc_reg_operand" "f")))]
39e63627
GK
11368 "(DEFAULT_ABI == ABI_AIX || DEFAULT_ABI == ABI_DARWIN)
11369 && TARGET_HARD_FLOAT && TARGET_FPRS && TARGET_LONG_DOUBLE_128"
ecb62ae7 11370 "fcmpu %0,%1,%2\;bne %0,$+8\;fcmpu %0,%L1,%L2"
d6f99ca4
DE
11371 [(set_attr "type" "fpcompare")
11372 (set_attr "length" "12")])
1fd4e8c1
RK
11373\f
11374;; Now we have the scc insns. We can do some combinations because of the
11375;; way the machine works.
11376;;
11377;; Note that this is probably faster if we can put an insn between the
c5defebb
RK
11378;; mfcr and rlinm, but this is tricky. Let's leave it for now. In most
11379;; cases the insns below which don't use an intermediate CR field will
11380;; be used instead.
1fd4e8c1 11381(define_insn ""
cd2b37d9 11382 [(set (match_operand:SI 0 "gpc_reg_operand" "=r")
1fd4e8c1
RK
11383 (match_operator:SI 1 "scc_comparison_operator"
11384 [(match_operand 2 "cc_reg_operand" "y")
11385 (const_int 0)]))]
11386 ""
2c4a9cff
DE
11387 "mfcr %0%Q2\;{rlinm|rlwinm} %0,%0,%J1,1"
11388 [(set (attr "type")
11389 (cond [(ne (symbol_ref "TARGET_MFCRF") (const_int 0))
11390 (const_string "mfcrf")
11391 ]
11392 (const_string "mfcr")))
309323c2 11393 (set_attr "length" "12")])
1fd4e8c1 11394
423c1189 11395;; Same as above, but get the GT bit.
6b1fedc3 11396(define_insn "move_from_CR_eq_bit"
423c1189 11397 [(set (match_operand:SI 0 "gpc_reg_operand" "=r")
6b1fedc3 11398 (unspec:SI [(match_operand 1 "cc_reg_operand" "y")] UNSPEC_MV_CR_EQ))]
423c1189
AH
11399 "TARGET_E500"
11400 "mfcr %0\;{rlinm|rlwinm} %0,%0,%D1,1"
11401 [(set_attr "type" "mfcr")
11402 (set_attr "length" "12")])
11403
a3170dc6
AH
11404;; Same as above, but get the OV/ORDERED bit.
11405(define_insn "move_from_CR_ov_bit"
11406 [(set (match_operand:SI 0 "gpc_reg_operand" "=r")
615158e2 11407 (unspec:SI [(match_operand 1 "cc_reg_operand" "y")] UNSPEC_MV_CR_OV))]
a3170dc6 11408 "TARGET_ISEL"
b7053a3f 11409 "mfcr %0\;{rlinm|rlwinm} %0,%0,%t1,1"
b54cf83a
DE
11410 [(set_attr "type" "mfcr")
11411 (set_attr "length" "12")])
a3170dc6 11412
1fd4e8c1 11413(define_insn ""
9ebbca7d
GK
11414 [(set (match_operand:DI 0 "gpc_reg_operand" "=r")
11415 (match_operator:DI 1 "scc_comparison_operator"
11416 [(match_operand 2 "cc_reg_operand" "y")
11417 (const_int 0)]))]
11418 "TARGET_POWERPC64"
2c4a9cff
DE
11419 "mfcr %0%Q2\;{rlinm|rlwinm} %0,%0,%J1,1"
11420 [(set (attr "type")
11421 (cond [(ne (symbol_ref "TARGET_MFCRF") (const_int 0))
11422 (const_string "mfcrf")
11423 ]
11424 (const_string "mfcr")))
309323c2 11425 (set_attr "length" "12")])
9ebbca7d
GK
11426
11427(define_insn ""
11428 [(set (match_operand:CC 0 "cc_reg_operand" "=x,?y")
1fd4e8c1 11429 (compare:CC (match_operator:SI 1 "scc_comparison_operator"
9ebbca7d 11430 [(match_operand 2 "cc_reg_operand" "y,y")
1fd4e8c1
RK
11431 (const_int 0)])
11432 (const_int 0)))
9ebbca7d 11433 (set (match_operand:SI 3 "gpc_reg_operand" "=r,r")
1fd4e8c1 11434 (match_op_dup 1 [(match_dup 2) (const_int 0)]))]
4b8a63d6 11435 "TARGET_32BIT"
9ebbca7d 11436 "@
2c4a9cff 11437 mfcr %3%Q2\;{rlinm.|rlwinm.} %3,%3,%J1,1
9ebbca7d 11438 #"
b19003d8 11439 [(set_attr "type" "delayed_compare")
9ebbca7d
GK
11440 (set_attr "length" "12,16")])
11441
11442(define_split
11443 [(set (match_operand:CC 0 "cc_reg_not_cr0_operand" "")
11444 (compare:CC (match_operator:SI 1 "scc_comparison_operator"
11445 [(match_operand 2 "cc_reg_operand" "")
11446 (const_int 0)])
11447 (const_int 0)))
11448 (set (match_operand:SI 3 "gpc_reg_operand" "")
11449 (match_op_dup 1 [(match_dup 2) (const_int 0)]))]
4b8a63d6 11450 "TARGET_32BIT && reload_completed"
9ebbca7d
GK
11451 [(set (match_dup 3)
11452 (match_op_dup 1 [(match_dup 2) (const_int 0)]))
11453 (set (match_dup 0)
11454 (compare:CC (match_dup 3)
11455 (const_int 0)))]
11456 "")
1fd4e8c1
RK
11457
11458(define_insn ""
cd2b37d9 11459 [(set (match_operand:SI 0 "gpc_reg_operand" "=r")
1fd4e8c1
RK
11460 (ashift:SI (match_operator:SI 1 "scc_comparison_operator"
11461 [(match_operand 2 "cc_reg_operand" "y")
11462 (const_int 0)])
11463 (match_operand:SI 3 "const_int_operand" "n")))]
11464 ""
11465 "*
11466{
11467 int is_bit = ccr_bit (operands[1], 1);
11468 int put_bit = 31 - (INTVAL (operands[3]) & 31);
11469 int count;
11470
11471 if (is_bit >= put_bit)
11472 count = is_bit - put_bit;
11473 else
11474 count = 32 - (put_bit - is_bit);
11475
89e9f3a8
MM
11476 operands[4] = GEN_INT (count);
11477 operands[5] = GEN_INT (put_bit);
1fd4e8c1 11478
2c4a9cff 11479 return \"mfcr %0%Q2\;{rlinm|rlwinm} %0,%0,%4,%5,%5\";
b19003d8 11480}"
2c4a9cff
DE
11481 [(set (attr "type")
11482 (cond [(ne (symbol_ref "TARGET_MFCRF") (const_int 0))
11483 (const_string "mfcrf")
11484 ]
11485 (const_string "mfcr")))
309323c2 11486 (set_attr "length" "12")])
1fd4e8c1
RK
11487
11488(define_insn ""
9ebbca7d 11489 [(set (match_operand:CC 0 "cc_reg_operand" "=x,?y")
1fd4e8c1
RK
11490 (compare:CC
11491 (ashift:SI (match_operator:SI 1 "scc_comparison_operator"
9ebbca7d 11492 [(match_operand 2 "cc_reg_operand" "y,y")
1fd4e8c1 11493 (const_int 0)])
9ebbca7d 11494 (match_operand:SI 3 "const_int_operand" "n,n"))
1fd4e8c1 11495 (const_int 0)))
9ebbca7d 11496 (set (match_operand:SI 4 "gpc_reg_operand" "=r,r")
1fd4e8c1
RK
11497 (ashift:SI (match_op_dup 1 [(match_dup 2) (const_int 0)])
11498 (match_dup 3)))]
ce71f754 11499 ""
1fd4e8c1
RK
11500 "*
11501{
11502 int is_bit = ccr_bit (operands[1], 1);
11503 int put_bit = 31 - (INTVAL (operands[3]) & 31);
11504 int count;
11505
9ebbca7d
GK
11506 /* Force split for non-cc0 compare. */
11507 if (which_alternative == 1)
11508 return \"#\";
11509
1fd4e8c1
RK
11510 if (is_bit >= put_bit)
11511 count = is_bit - put_bit;
11512 else
11513 count = 32 - (put_bit - is_bit);
11514
89e9f3a8
MM
11515 operands[5] = GEN_INT (count);
11516 operands[6] = GEN_INT (put_bit);
1fd4e8c1 11517
2c4a9cff 11518 return \"mfcr %4%Q2\;{rlinm.|rlwinm.} %4,%4,%5,%6,%6\";
1fd4e8c1 11519}"
b19003d8 11520 [(set_attr "type" "delayed_compare")
9ebbca7d
GK
11521 (set_attr "length" "12,16")])
11522
11523(define_split
11524 [(set (match_operand:CC 0 "cc_reg_not_cr0_operand" "")
11525 (compare:CC
11526 (ashift:SI (match_operator:SI 1 "scc_comparison_operator"
11527 [(match_operand 2 "cc_reg_operand" "")
11528 (const_int 0)])
11529 (match_operand:SI 3 "const_int_operand" ""))
11530 (const_int 0)))
11531 (set (match_operand:SI 4 "gpc_reg_operand" "")
11532 (ashift:SI (match_op_dup 1 [(match_dup 2) (const_int 0)])
11533 (match_dup 3)))]
ce71f754 11534 "reload_completed"
9ebbca7d
GK
11535 [(set (match_dup 4)
11536 (ashift:SI (match_op_dup 1 [(match_dup 2) (const_int 0)])
11537 (match_dup 3)))
11538 (set (match_dup 0)
11539 (compare:CC (match_dup 4)
11540 (const_int 0)))]
11541 "")
1fd4e8c1 11542
c5defebb
RK
11543;; There is a 3 cycle delay between consecutive mfcr instructions
11544;; so it is useful to combine 2 scc instructions to use only one mfcr.
11545
11546(define_peephole
cd2b37d9 11547 [(set (match_operand:SI 0 "gpc_reg_operand" "=r")
c5defebb
RK
11548 (match_operator:SI 1 "scc_comparison_operator"
11549 [(match_operand 2 "cc_reg_operand" "y")
11550 (const_int 0)]))
cd2b37d9 11551 (set (match_operand:SI 3 "gpc_reg_operand" "=r")
c5defebb
RK
11552 (match_operator:SI 4 "scc_comparison_operator"
11553 [(match_operand 5 "cc_reg_operand" "y")
11554 (const_int 0)]))]
309323c2 11555 "REGNO (operands[2]) != REGNO (operands[5])"
b7053a3f 11556 "mfcr %3\;{rlinm|rlwinm} %0,%3,%J1,1\;{rlinm|rlwinm} %3,%3,%J4,1"
b54cf83a 11557 [(set_attr "type" "mfcr")
309323c2 11558 (set_attr "length" "20")])
c5defebb 11559
9ebbca7d
GK
11560(define_peephole
11561 [(set (match_operand:DI 0 "gpc_reg_operand" "=r")
11562 (match_operator:DI 1 "scc_comparison_operator"
11563 [(match_operand 2 "cc_reg_operand" "y")
11564 (const_int 0)]))
11565 (set (match_operand:DI 3 "gpc_reg_operand" "=r")
11566 (match_operator:DI 4 "scc_comparison_operator"
11567 [(match_operand 5 "cc_reg_operand" "y")
11568 (const_int 0)]))]
309323c2 11569 "TARGET_POWERPC64 && REGNO (operands[2]) != REGNO (operands[5])"
b7053a3f 11570 "mfcr %3\;{rlinm|rlwinm} %0,%3,%J1,1\;{rlinm|rlwinm} %3,%3,%J4,1"
b54cf83a 11571 [(set_attr "type" "mfcr")
309323c2 11572 (set_attr "length" "20")])
9ebbca7d 11573
1fd4e8c1
RK
11574;; There are some scc insns that can be done directly, without a compare.
11575;; These are faster because they don't involve the communications between
11576;; the FXU and branch units. In fact, we will be replacing all of the
11577;; integer scc insns here or in the portable methods in emit_store_flag.
11578;;
11579;; Also support (neg (scc ..)) since that construct is used to replace
11580;; branches, (plus (scc ..) ..) since that construct is common and
11581;; takes no more insns than scc, and (and (neg (scc ..)) ..) in the
11582;; cases where it is no more expensive than (neg (scc ..)).
11583
11584;; Have reload force a constant into a register for the simple insns that
11585;; otherwise won't accept constants. We do this because it is faster than
11586;; the cmp/mfcr sequence we would otherwise generate.
11587
11588(define_insn ""
cd2b37d9
RK
11589 [(set (match_operand:SI 0 "gpc_reg_operand" "=r,r,r,r,r")
11590 (eq:SI (match_operand:SI 1 "gpc_reg_operand" "%r,r,r,r,r")
5f59ecb7 11591 (match_operand:SI 2 "reg_or_cint_operand" "r,O,K,L,I")))
1fd4e8c1 11592 (clobber (match_scratch:SI 3 "=r,&r,r,r,r"))]
683bdff7 11593 "TARGET_32BIT"
1fd4e8c1 11594 "@
ca7f5001 11595 xor %0,%1,%2\;{sfi|subfic} %3,%0,0\;{ae|adde} %0,%3,%0
71d2371f 11596 {sfi|subfic} %3,%1,0\;{ae|adde} %0,%3,%1
ca7f5001
RK
11597 {xoril|xori} %0,%1,%b2\;{sfi|subfic} %3,%0,0\;{ae|adde} %0,%3,%0
11598 {xoriu|xoris} %0,%1,%u2\;{sfi|subfic} %3,%0,0\;{ae|adde} %0,%3,%0
11599 {sfi|subfic} %0,%1,%2\;{sfi|subfic} %3,%0,0\;{ae|adde} %0,%3,%0"
b19003d8 11600 [(set_attr "length" "12,8,12,12,12")])
1fd4e8c1 11601
a260abc9
DE
11602(define_insn ""
11603 [(set (match_operand:DI 0 "gpc_reg_operand" "=r,r,r,r,r")
11604 (eq:DI (match_operand:DI 1 "gpc_reg_operand" "%r,r,r,r,r")
11605 (match_operand:DI 2 "reg_or_cint_operand" "r,O,K,J,I")))
11606 (clobber (match_scratch:DI 3 "=r,&r,r,r,r"))]
683bdff7 11607 "TARGET_64BIT"
a260abc9
DE
11608 "@
11609 xor %0,%1,%2\;subfic %3,%0,0\;adde %0,%3,%0
11610 subfic %3,%1,0\;adde %0,%3,%1
11611 xori %0,%1,%b2\;subfic %3,%0,0\;adde %0,%3,%0
11612 xoris %0,%1,%u2\;subfic %3,%0,0\;adde %0,%3,%0
11613 subfic %0,%1,%2\;subfic %3,%0,0\;adde %0,%3,%0"
11614 [(set_attr "length" "12,8,12,12,12")])
11615
1fd4e8c1 11616(define_insn ""
9ebbca7d 11617 [(set (match_operand:CC 4 "cc_reg_operand" "=x,x,x,x,x,?y,?y,?y,?y,?y")
7e69e155 11618 (compare:CC
9ebbca7d
GK
11619 (eq:SI (match_operand:SI 1 "gpc_reg_operand" "%r,r,r,r,r,r,r,r,r,r")
11620 (match_operand:SI 2 "reg_or_cint_operand" "r,O,K,L,I,r,O,K,L,I"))
1fd4e8c1 11621 (const_int 0)))
9ebbca7d 11622 (set (match_operand:SI 0 "gpc_reg_operand" "=r,r,r,r,r,r,r,r,r,r")
1fd4e8c1 11623 (eq:SI (match_dup 1) (match_dup 2)))
9ebbca7d 11624 (clobber (match_scratch:SI 3 "=r,&r,r,r,r,r,&r,r,r,r"))]
683bdff7 11625 "TARGET_32BIT"
1fd4e8c1 11626 "@
ca7f5001
RK
11627 xor %0,%1,%2\;{sfi|subfic} %3,%0,0\;{ae.|adde.} %0,%3,%0
11628 {sfi|subfic} %3,%1,0\;{ae.|adde.} %0,%3,%1
11629 {xoril|xori} %0,%1,%b2\;{sfi|subfic} %3,%0,0\;{ae.|adde.} %0,%3,%0
11630 {xoriu|xoris} %0,%1,%u2\;{sfi|subfic} %3,%0,0\;{ae.|adde.} %0,%3,%0
9ebbca7d
GK
11631 {sfi|subfic} %0,%1,%2\;{sfi|subfic} %3,%0,0\;{ae.|adde.} %0,%3,%0
11632 #
11633 #
11634 #
11635 #
11636 #"
b19003d8 11637 [(set_attr "type" "compare")
9ebbca7d
GK
11638 (set_attr "length" "12,8,12,12,12,16,12,16,16,16")])
11639
11640(define_split
11641 [(set (match_operand:CC 4 "cc_reg_not_cr0_operand" "")
11642 (compare:CC
11643 (eq:SI (match_operand:SI 1 "gpc_reg_operand" "")
11644 (match_operand:SI 2 "reg_or_cint_operand" ""))
11645 (const_int 0)))
11646 (set (match_operand:SI 0 "gpc_reg_operand" "")
11647 (eq:SI (match_dup 1) (match_dup 2)))
11648 (clobber (match_scratch:SI 3 ""))]
683bdff7 11649 "TARGET_32BIT && reload_completed"
9ebbca7d
GK
11650 [(parallel [(set (match_dup 0)
11651 (eq:SI (match_dup 1) (match_dup 2)))
11652 (clobber (match_dup 3))])
11653 (set (match_dup 4)
11654 (compare:CC (match_dup 0)
11655 (const_int 0)))]
11656 "")
b19003d8 11657
a260abc9 11658(define_insn ""
9ebbca7d 11659 [(set (match_operand:CC 4 "cc_reg_operand" "=x,x,x,x,x,?y,?y,?y,?y,?y")
a260abc9 11660 (compare:CC
9ebbca7d
GK
11661 (eq:DI (match_operand:DI 1 "gpc_reg_operand" "%r,r,r,r,r,r,r,r,r,r")
11662 (match_operand:DI 2 "reg_or_cint_operand" "r,O,K,J,I,r,O,K,J,I"))
a260abc9 11663 (const_int 0)))
9ebbca7d 11664 (set (match_operand:DI 0 "gpc_reg_operand" "=r,r,r,r,r,r,r,r,r,r")
a260abc9 11665 (eq:DI (match_dup 1) (match_dup 2)))
9ebbca7d 11666 (clobber (match_scratch:DI 3 "=r,&r,r,r,r,r,&r,r,r,r"))]
683bdff7 11667 "TARGET_64BIT"
a260abc9
DE
11668 "@
11669 xor %0,%1,%2\;subfic %3,%0,0\;adde. %0,%3,%0
11670 subfic %3,%1,0\;adde. %0,%3,%1
11671 xori %0,%1,%b2\;subfic %3,%0,0\;adde. %0,%3,%0
11672 xoris %0,%1,%u2\;subfic %3,%0,0\;adde. %0,%3,%0
9ebbca7d
GK
11673 subfic %0,%1,%2\;subfic %3,%0,0\;adde. %0,%3,%0
11674 #
11675 #
11676 #
11677 #
11678 #"
a260abc9 11679 [(set_attr "type" "compare")
9ebbca7d
GK
11680 (set_attr "length" "12,8,12,12,12,16,12,16,16,16")])
11681
11682(define_split
11683 [(set (match_operand:CC 4 "cc_reg_not_cr0_operand" "")
11684 (compare:CC
11685 (eq:DI (match_operand:DI 1 "gpc_reg_operand" "")
11686 (match_operand:DI 2 "reg_or_cint_operand" ""))
11687 (const_int 0)))
11688 (set (match_operand:DI 0 "gpc_reg_operand" "")
11689 (eq:DI (match_dup 1) (match_dup 2)))
11690 (clobber (match_scratch:DI 3 ""))]
683bdff7 11691 "TARGET_64BIT && reload_completed"
9ebbca7d
GK
11692 [(parallel [(set (match_dup 0)
11693 (eq:DI (match_dup 1) (match_dup 2)))
11694 (clobber (match_dup 3))])
11695 (set (match_dup 4)
11696 (compare:CC (match_dup 0)
11697 (const_int 0)))]
11698 "")
a260abc9 11699
b19003d8
RK
11700;; We have insns of the form shown by the first define_insn below. If
11701;; there is something inside the comparison operation, we must split it.
11702(define_split
11703 [(set (match_operand:SI 0 "gpc_reg_operand" "")
11704 (plus:SI (match_operator 1 "comparison_operator"
11705 [(match_operand:SI 2 "" "")
11706 (match_operand:SI 3
11707 "reg_or_cint_operand" "")])
11708 (match_operand:SI 4 "gpc_reg_operand" "")))
11709 (clobber (match_operand:SI 5 "register_operand" ""))]
11710 "! gpc_reg_operand (operands[2], SImode)"
11711 [(set (match_dup 5) (match_dup 2))
11712 (set (match_dup 2) (plus:SI (match_op_dup 1 [(match_dup 2) (match_dup 3)])
11713 (match_dup 4)))])
1fd4e8c1
RK
11714
11715(define_insn ""
5276df18 11716 [(set (match_operand:SI 0 "gpc_reg_operand" "=&r,&r,&r,&r,&r")
cd2b37d9 11717 (plus:SI (eq:SI (match_operand:SI 1 "gpc_reg_operand" "%r,r,r,r,r")
5f59ecb7 11718 (match_operand:SI 2 "reg_or_cint_operand" "r,O,K,L,I"))
5276df18 11719 (match_operand:SI 3 "gpc_reg_operand" "r,r,r,r,r")))]
683bdff7 11720 "TARGET_32BIT"
1fd4e8c1 11721 "@
5276df18
DE
11722 xor %0,%1,%2\;{sfi|subfic} %0,%0,0\;{aze|addze} %0,%3
11723 {sfi|subfic} %0,%1,0\;{aze|addze} %0,%3
11724 {xoril|xori} %0,%1,%b2\;{sfi|subfic} %0,%0,0\;{aze|addze} %0,%3
11725 {xoriu|xoris} %0,%1,%u2\;{sfi|subfic} %0,%0,0\;{aze|addze} %0,%3
11726 {sfi|subfic} %0,%1,%2\;{sfi|subfic} %0,%0,0\;{aze|addze} %0,%3"
b19003d8 11727 [(set_attr "length" "12,8,12,12,12")])
1fd4e8c1
RK
11728
11729(define_insn ""
9ebbca7d 11730 [(set (match_operand:CC 0 "cc_reg_operand" "=x,x,x,x,x,?y,?y,?y,?y,?y")
7e69e155 11731 (compare:CC
1fd4e8c1 11732 (plus:SI
9ebbca7d
GK
11733 (eq:SI (match_operand:SI 1 "gpc_reg_operand" "%r,r,r,r,r,r,r,r,r,r")
11734 (match_operand:SI 2 "reg_or_cint_operand" "r,O,K,L,I,r,O,K,L,I"))
11735 (match_operand:SI 3 "gpc_reg_operand" "r,r,r,r,r,r,r,r,r,r"))
1fd4e8c1 11736 (const_int 0)))
9ebbca7d 11737 (clobber (match_scratch:SI 4 "=&r,&r,&r,&r,&r,&r,&r,&r,&r,&r"))]
683bdff7 11738 "TARGET_32BIT"
1fd4e8c1 11739 "@
ca7f5001 11740 xor %4,%1,%2\;{sfi|subfic} %4,%4,0\;{aze.|addze.} %4,%3
19378cf8 11741 {sfi|subfic} %4,%1,0\;{aze.|addze.} %4,%3
ca7f5001
RK
11742 {xoril|xori} %4,%1,%b2\;{sfi|subfic} %4,%4,0\;{aze.|addze.} %4,%3
11743 {xoriu|xoris} %4,%1,%u2\;{sfi|subfic} %4,%4,0\;{aze.|addze.} %4,%3
9ebbca7d
GK
11744 {sfi|subfic} %4,%1,%2\;{sfi|subfic} %4,%4,0\;{aze.|addze.} %4,%3
11745 #
11746 #
11747 #
11748 #
11749 #"
b19003d8 11750 [(set_attr "type" "compare")
9ebbca7d
GK
11751 (set_attr "length" "12,8,12,12,12,16,12,16,16,16")])
11752
11753(define_split
11754 [(set (match_operand:CC 0 "cc_reg_not_cr0_operand" "")
11755 (compare:CC
11756 (plus:SI
11757 (eq:SI (match_operand:SI 1 "gpc_reg_operand" "")
11758 (match_operand:SI 2 "reg_or_cint_operand" ""))
11759 (match_operand:SI 3 "gpc_reg_operand" ""))
11760 (const_int 0)))
11761 (clobber (match_scratch:SI 4 ""))]
683bdff7 11762 "TARGET_32BIT && reload_completed"
9ebbca7d
GK
11763 [(set (match_dup 4)
11764 (plus:SI (eq:SI (match_dup 1)
11765 (match_dup 2))
11766 (match_dup 3)))
11767 (set (match_dup 0)
11768 (compare:CC (match_dup 4)
11769 (const_int 0)))]
11770 "")
1fd4e8c1
RK
11771
11772(define_insn ""
0387639b 11773 [(set (match_operand:CC 4 "cc_reg_operand" "=x,x,x,x,x,?y,?y,?y,?y,?y")
7e69e155 11774 (compare:CC
1fd4e8c1 11775 (plus:SI
9ebbca7d
GK
11776 (eq:SI (match_operand:SI 1 "gpc_reg_operand" "%r,r,r,r,r,r,r,r,r,r")
11777 (match_operand:SI 2 "reg_or_cint_operand" "r,O,K,L,I,r,O,K,L,I"))
11778 (match_operand:SI 3 "gpc_reg_operand" "r,r,r,r,r,r,r,r,r,r"))
1fd4e8c1 11779 (const_int 0)))
0387639b
DE
11780 (set (match_operand:SI 0 "gpc_reg_operand" "=&r,&r,&r,&r,&r,&r,&r,&r,&r,&r")
11781 (plus:SI (eq:SI (match_dup 1) (match_dup 2)) (match_dup 3)))]
683bdff7 11782 "TARGET_32BIT"
1fd4e8c1 11783 "@
0387639b
DE
11784 xor %0,%1,%2\;{sfi|subfic} %0,%0,0\;{aze.|addze.} %0,%3
11785 {sfi|subfic} %0,%1,0\;{aze.|addze.} %0,%3
11786 {xoril|xori} %0,%1,%b2\;{sfi|subfic} %0,%0,0\;{aze.|addze.} %0,%3
11787 {xoriu|xoris} %0,%1,%u2\;{sfi|subfic} %0,%0,0\;{aze.|addze.} %0,%3
11788 {sfi|subfic} %0,%1,%2\;{sfi|subfic} %0,%0,0\;{aze.|addze.} %0,%3
9ebbca7d
GK
11789 #
11790 #
11791 #
11792 #
11793 #"
11794 [(set_attr "type" "compare")
11795 (set_attr "length" "12,8,12,12,12,16,12,16,16,16")])
11796
11797(define_split
0387639b 11798 [(set (match_operand:CC 4 "cc_reg_not_cr0_operand" "")
9ebbca7d
GK
11799 (compare:CC
11800 (plus:SI
11801 (eq:SI (match_operand:SI 1 "gpc_reg_operand" "")
11802 (match_operand:SI 2 "reg_or_cint_operand" ""))
11803 (match_operand:SI 3 "gpc_reg_operand" ""))
11804 (const_int 0)))
11805 (set (match_operand:SI 0 "gpc_reg_operand" "")
0387639b 11806 (plus:SI (eq:SI (match_dup 1) (match_dup 2)) (match_dup 3)))]
683bdff7 11807 "TARGET_32BIT && reload_completed"
0387639b 11808 [(set (match_dup 0)
9ebbca7d 11809 (plus:SI (eq:SI (match_dup 1) (match_dup 2)) (match_dup 3)))
0387639b 11810 (set (match_dup 4)
9ebbca7d
GK
11811 (compare:CC (match_dup 0)
11812 (const_int 0)))]
11813 "")
11814
1fd4e8c1 11815(define_insn ""
cd2b37d9 11816 [(set (match_operand:SI 0 "gpc_reg_operand" "=r,r,r,r,r")
deb9225a 11817 (neg:SI (eq:SI (match_operand:SI 1 "gpc_reg_operand" "%r,r,r,r,r")
5f59ecb7 11818 (match_operand:SI 2 "reg_or_cint_operand" "r,O,K,L,I"))))]
683bdff7 11819 "TARGET_32BIT"
1fd4e8c1 11820 "@
ca7f5001
RK
11821 xor %0,%1,%2\;{ai|addic} %0,%0,-1\;{sfe|subfe} %0,%0,%0
11822 {ai|addic} %0,%1,-1\;{sfe|subfe} %0,%0,%0
11823 {xoril|xori} %0,%1,%b2\;{ai|addic} %0,%0,-1\;{sfe|subfe} %0,%0,%0
11824 {xoriu|xoris} %0,%1,%u2\;{ai|addic} %0,%0,-1\;{sfe|subfe} %0,%0,%0
11825 {sfi|subfic} %0,%1,%2\;{ai|addic} %0,%0,-1\;{sfe|subfe} %0,%0,%0"
b19003d8 11826 [(set_attr "length" "12,8,12,12,12")])
1fd4e8c1 11827
ea9be077
MM
11828;; Simplify (ne X (const_int 0)) on the PowerPC. No need to on the Power,
11829;; since it nabs/sr is just as fast.
463b558b 11830(define_insn "*ne0"
b4e95693 11831 [(set (match_operand:SI 0 "gpc_reg_operand" "=&r")
ea9be077
MM
11832 (lshiftrt:SI (neg:SI (abs:SI (match_operand:SI 1 "gpc_reg_operand" "r")))
11833 (const_int 31)))
11834 (clobber (match_scratch:SI 2 "=&r"))]
683bdff7 11835 "! TARGET_POWER && TARGET_32BIT && !TARGET_ISEL"
ea9be077
MM
11836 "{ai|addic} %2,%1,-1\;{sfe|subfe} %0,%2,%1"
11837 [(set_attr "length" "8")])
11838
a260abc9
DE
11839(define_insn ""
11840 [(set (match_operand:DI 0 "gpc_reg_operand" "=r")
11841 (lshiftrt:DI (neg:DI (abs:DI (match_operand:DI 1 "gpc_reg_operand" "r")))
11842 (const_int 63)))
11843 (clobber (match_scratch:DI 2 "=&r"))]
683bdff7 11844 "TARGET_64BIT"
a260abc9
DE
11845 "addic %2,%1,-1\;subfe %0,%2,%1"
11846 [(set_attr "length" "8")])
11847
1fd4e8c1
RK
11848;; This is what (plus (ne X (const_int 0)) Y) looks like.
11849(define_insn ""
cd2b37d9 11850 [(set (match_operand:SI 0 "gpc_reg_operand" "=r")
1fd4e8c1 11851 (plus:SI (lshiftrt:SI
cd2b37d9 11852 (neg:SI (abs:SI (match_operand:SI 1 "gpc_reg_operand" "r")))
1fd4e8c1 11853 (const_int 31))
cd2b37d9 11854 (match_operand:SI 2 "gpc_reg_operand" "r")))
1fd4e8c1 11855 (clobber (match_scratch:SI 3 "=&r"))]
683bdff7 11856 "TARGET_32BIT"
ca7f5001 11857 "{ai|addic} %3,%1,-1\;{aze|addze} %0,%2"
b19003d8 11858 [(set_attr "length" "8")])
1fd4e8c1 11859
a260abc9
DE
11860(define_insn ""
11861 [(set (match_operand:DI 0 "gpc_reg_operand" "=r")
11862 (plus:DI (lshiftrt:DI
11863 (neg:DI (abs:DI (match_operand:DI 1 "gpc_reg_operand" "r")))
11864 (const_int 63))
11865 (match_operand:DI 2 "gpc_reg_operand" "r")))
11866 (clobber (match_scratch:DI 3 "=&r"))]
683bdff7 11867 "TARGET_64BIT"
a260abc9
DE
11868 "addic %3,%1,-1\;addze %0,%2"
11869 [(set_attr "length" "8")])
11870
1fd4e8c1 11871(define_insn ""
9ebbca7d 11872 [(set (match_operand:CC 0 "cc_reg_operand" "=x,?y")
1fd4e8c1
RK
11873 (compare:CC
11874 (plus:SI (lshiftrt:SI
9ebbca7d 11875 (neg:SI (abs:SI (match_operand:SI 1 "gpc_reg_operand" "r,r")))
1fd4e8c1 11876 (const_int 31))
9ebbca7d 11877 (match_operand:SI 2 "gpc_reg_operand" "r,r"))
1fd4e8c1 11878 (const_int 0)))
889b90a1
GK
11879 (clobber (match_scratch:SI 3 "=&r,&r"))
11880 (clobber (match_scratch:SI 4 "=X,&r"))]
683bdff7 11881 "TARGET_32BIT"
9ebbca7d
GK
11882 "@
11883 {ai|addic} %3,%1,-1\;{aze.|addze.} %3,%2
11884 #"
b19003d8 11885 [(set_attr "type" "compare")
9ebbca7d
GK
11886 (set_attr "length" "8,12")])
11887
11888(define_split
11889 [(set (match_operand:CC 0 "cc_reg_not_cr0_operand" "")
11890 (compare:CC
11891 (plus:SI (lshiftrt:SI
11892 (neg:SI (abs:SI (match_operand:SI 1 "gpc_reg_operand" "")))
11893 (const_int 31))
11894 (match_operand:SI 2 "gpc_reg_operand" ""))
11895 (const_int 0)))
889b90a1
GK
11896 (clobber (match_scratch:SI 3 ""))
11897 (clobber (match_scratch:SI 4 ""))]
683bdff7 11898 "TARGET_32BIT && reload_completed"
889b90a1 11899 [(parallel [(set (match_dup 3)
ce71f754
AM
11900 (plus:SI (lshiftrt:SI (neg:SI (abs:SI (match_dup 1)))
11901 (const_int 31))
11902 (match_dup 2)))
889b90a1 11903 (clobber (match_dup 4))])
9ebbca7d
GK
11904 (set (match_dup 0)
11905 (compare:CC (match_dup 3)
11906 (const_int 0)))]
11907 "")
1fd4e8c1 11908
a260abc9 11909(define_insn ""
9ebbca7d 11910 [(set (match_operand:CC 0 "cc_reg_operand" "=x,?y")
a260abc9
DE
11911 (compare:CC
11912 (plus:DI (lshiftrt:DI
9ebbca7d 11913 (neg:DI (abs:DI (match_operand:DI 1 "gpc_reg_operand" "r,r")))
a260abc9 11914 (const_int 63))
9ebbca7d 11915 (match_operand:DI 2 "gpc_reg_operand" "r,r"))
a260abc9 11916 (const_int 0)))
9ebbca7d 11917 (clobber (match_scratch:DI 3 "=&r,&r"))]
683bdff7 11918 "TARGET_64BIT"
9ebbca7d
GK
11919 "@
11920 addic %3,%1,-1\;addze. %3,%2
11921 #"
a260abc9 11922 [(set_attr "type" "compare")
9ebbca7d
GK
11923 (set_attr "length" "8,12")])
11924
11925(define_split
11926 [(set (match_operand:CC 0 "cc_reg_not_cr0_operand" "")
11927 (compare:CC
11928 (plus:DI (lshiftrt:DI
11929 (neg:DI (abs:DI (match_operand:DI 1 "gpc_reg_operand" "")))
11930 (const_int 63))
11931 (match_operand:DI 2 "gpc_reg_operand" ""))
11932 (const_int 0)))
11933 (clobber (match_scratch:DI 3 ""))]
683bdff7 11934 "TARGET_64BIT && reload_completed"
9ebbca7d
GK
11935 [(set (match_dup 3)
11936 (plus:DI (lshiftrt:DI (neg:DI (abs:DI (match_dup 1)))
11937 (const_int 63))
11938 (match_dup 2)))
11939 (set (match_dup 0)
11940 (compare:CC (match_dup 3)
11941 (const_int 0)))]
11942 "")
a260abc9 11943
1fd4e8c1 11944(define_insn ""
9ebbca7d 11945 [(set (match_operand:CC 4 "cc_reg_operand" "=x,?y")
1fd4e8c1
RK
11946 (compare:CC
11947 (plus:SI (lshiftrt:SI
9ebbca7d 11948 (neg:SI (abs:SI (match_operand:SI 1 "gpc_reg_operand" "r,r")))
1fd4e8c1 11949 (const_int 31))
9ebbca7d 11950 (match_operand:SI 2 "gpc_reg_operand" "r,r"))
1fd4e8c1 11951 (const_int 0)))
9ebbca7d 11952 (set (match_operand:SI 0 "gpc_reg_operand" "=r,r")
1fd4e8c1
RK
11953 (plus:SI (lshiftrt:SI (neg:SI (abs:SI (match_dup 1))) (const_int 31))
11954 (match_dup 2)))
9ebbca7d 11955 (clobber (match_scratch:SI 3 "=&r,&r"))]
683bdff7 11956 "TARGET_32BIT"
9ebbca7d
GK
11957 "@
11958 {ai|addic} %3,%1,-1\;{aze.|addze.} %0,%2
11959 #"
b19003d8 11960 [(set_attr "type" "compare")
9ebbca7d
GK
11961 (set_attr "length" "8,12")])
11962
11963(define_split
11964 [(set (match_operand:CC 4 "cc_reg_not_cr0_operand" "")
11965 (compare:CC
11966 (plus:SI (lshiftrt:SI
11967 (neg:SI (abs:SI (match_operand:SI 1 "gpc_reg_operand" "")))
11968 (const_int 31))
11969 (match_operand:SI 2 "gpc_reg_operand" ""))
11970 (const_int 0)))
11971 (set (match_operand:SI 0 "gpc_reg_operand" "")
11972 (plus:SI (lshiftrt:SI (neg:SI (abs:SI (match_dup 1))) (const_int 31))
11973 (match_dup 2)))
11974 (clobber (match_scratch:SI 3 ""))]
683bdff7 11975 "TARGET_32BIT && reload_completed"
9ebbca7d
GK
11976 [(parallel [(set (match_dup 0)
11977 (plus:SI (lshiftrt:SI (neg:SI (abs:SI (match_dup 1))) (const_int 31))
11978 (match_dup 2)))
11979 (clobber (match_dup 3))])
11980 (set (match_dup 4)
11981 (compare:CC (match_dup 0)
11982 (const_int 0)))]
11983 "")
1fd4e8c1 11984
a260abc9 11985(define_insn ""
9ebbca7d 11986 [(set (match_operand:CC 4 "cc_reg_operand" "=x,?y")
a260abc9
DE
11987 (compare:CC
11988 (plus:DI (lshiftrt:DI
9ebbca7d 11989 (neg:DI (abs:DI (match_operand:DI 1 "gpc_reg_operand" "r,r")))
a260abc9 11990 (const_int 63))
9ebbca7d 11991 (match_operand:DI 2 "gpc_reg_operand" "r,r"))
a260abc9 11992 (const_int 0)))
9ebbca7d 11993 (set (match_operand:DI 0 "gpc_reg_operand" "=r,r")
a260abc9
DE
11994 (plus:DI (lshiftrt:DI (neg:DI (abs:DI (match_dup 1))) (const_int 63))
11995 (match_dup 2)))
9ebbca7d 11996 (clobber (match_scratch:DI 3 "=&r,&r"))]
683bdff7 11997 "TARGET_64BIT"
9ebbca7d
GK
11998 "@
11999 addic %3,%1,-1\;addze. %0,%2
12000 #"
a260abc9 12001 [(set_attr "type" "compare")
9ebbca7d
GK
12002 (set_attr "length" "8,12")])
12003
12004(define_split
12005 [(set (match_operand:CC 4 "cc_reg_not_cr0_operand" "")
12006 (compare:CC
12007 (plus:DI (lshiftrt:DI
12008 (neg:DI (abs:DI (match_operand:DI 1 "gpc_reg_operand" "")))
12009 (const_int 63))
12010 (match_operand:DI 2 "gpc_reg_operand" ""))
12011 (const_int 0)))
12012 (set (match_operand:DI 0 "gpc_reg_operand" "")
12013 (plus:DI (lshiftrt:DI (neg:DI (abs:DI (match_dup 1))) (const_int 63))
12014 (match_dup 2)))
12015 (clobber (match_scratch:DI 3 ""))]
683bdff7 12016 "TARGET_64BIT && reload_completed"
9ebbca7d
GK
12017 [(parallel [(set (match_dup 0)
12018 (plus:DI (lshiftrt:DI (neg:DI (abs:DI (match_dup 1))) (const_int 63))
12019 (match_dup 2)))
12020 (clobber (match_dup 3))])
12021 (set (match_dup 4)
12022 (compare:CC (match_dup 0)
12023 (const_int 0)))]
12024 "")
a260abc9 12025
1fd4e8c1 12026(define_insn ""
cd2b37d9
RK
12027 [(set (match_operand:SI 0 "gpc_reg_operand" "=r,r")
12028 (le:SI (match_operand:SI 1 "gpc_reg_operand" "r,r")
1fd4e8c1
RK
12029 (match_operand:SI 2 "reg_or_short_operand" "r,O")))
12030 (clobber (match_scratch:SI 3 "=r,X"))]
ca7f5001 12031 "TARGET_POWER"
1fd4e8c1 12032 "@
ca7f5001 12033 doz %3,%2,%1\;{sfi|subfic} %0,%3,0\;{ae|adde} %0,%0,%3
7f340546 12034 {ai|addic} %0,%1,-1\;{aze|addze} %0,%0\;{sri|srwi} %0,%0,31"
b19003d8 12035 [(set_attr "length" "12")])
1fd4e8c1
RK
12036
12037(define_insn ""
9ebbca7d 12038 [(set (match_operand:CC 4 "cc_reg_operand" "=x,x,?y,?y")
1fd4e8c1 12039 (compare:CC
9ebbca7d
GK
12040 (le:SI (match_operand:SI 1 "gpc_reg_operand" "r,r,r,r")
12041 (match_operand:SI 2 "reg_or_short_operand" "r,O,r,O"))
1fd4e8c1 12042 (const_int 0)))
9ebbca7d 12043 (set (match_operand:SI 0 "gpc_reg_operand" "=r,r,r,r")
1fd4e8c1 12044 (le:SI (match_dup 1) (match_dup 2)))
9ebbca7d 12045 (clobber (match_scratch:SI 3 "=r,X,r,X"))]
ca7f5001 12046 "TARGET_POWER"
1fd4e8c1 12047 "@
ca7f5001 12048 doz %3,%2,%1\;{sfi|subfic} %0,%3,0\;{ae.|adde.} %0,%0,%3
9ebbca7d
GK
12049 {ai|addic} %0,%1,-1\;{aze|addze} %0,%0\;{sri.|srwi.} %0,%0,31
12050 #
12051 #"
12052 [(set_attr "type" "compare,delayed_compare,compare,delayed_compare")
12053 (set_attr "length" "12,12,16,16")])
12054
12055(define_split
12056 [(set (match_operand:CC 4 "cc_reg_not_cr0_operand" "")
12057 (compare:CC
12058 (le:SI (match_operand:SI 1 "gpc_reg_operand" "")
12059 (match_operand:SI 2 "reg_or_short_operand" ""))
12060 (const_int 0)))
12061 (set (match_operand:SI 0 "gpc_reg_operand" "")
12062 (le:SI (match_dup 1) (match_dup 2)))
12063 (clobber (match_scratch:SI 3 ""))]
12064 "TARGET_POWER && reload_completed"
12065 [(parallel [(set (match_dup 0)
12066 (le:SI (match_dup 1) (match_dup 2)))
12067 (clobber (match_dup 3))])
12068 (set (match_dup 4)
12069 (compare:CC (match_dup 0)
12070 (const_int 0)))]
12071 "")
1fd4e8c1
RK
12072
12073(define_insn ""
097657c3 12074 [(set (match_operand:SI 0 "gpc_reg_operand" "=&r,&r")
cd2b37d9 12075 (plus:SI (le:SI (match_operand:SI 1 "gpc_reg_operand" "r,r")
1fd4e8c1 12076 (match_operand:SI 2 "reg_or_short_operand" "r,O"))
097657c3 12077 (match_operand:SI 3 "gpc_reg_operand" "r,r")))]
ca7f5001 12078 "TARGET_POWER"
1fd4e8c1 12079 "@
097657c3
AM
12080 doz %0,%2,%1\;{sfi|subfic} %0,%0,0\;{aze|addze} %0,%3
12081 {srai|srawi} %0,%1,31\;{sf|subfc} %0,%1,%0\;{aze|addze} %0,%3"
b19003d8 12082 [(set_attr "length" "12")])
1fd4e8c1
RK
12083
12084(define_insn ""
9ebbca7d 12085 [(set (match_operand:CC 0 "cc_reg_operand" "=x,x,?y,?y")
1fd4e8c1 12086 (compare:CC
9ebbca7d
GK
12087 (plus:SI (le:SI (match_operand:SI 1 "gpc_reg_operand" "r,r,r,r")
12088 (match_operand:SI 2 "reg_or_short_operand" "r,O,r,O"))
12089 (match_operand:SI 3 "gpc_reg_operand" "r,r,r,r"))
1fd4e8c1 12090 (const_int 0)))
9ebbca7d 12091 (clobber (match_scratch:SI 4 "=&r,&r,&r,&r"))]
ca7f5001 12092 "TARGET_POWER"
1fd4e8c1 12093 "@
ca7f5001 12094 doz %4,%2,%1\;{sfi|subfic} %4,%4,0\;{aze.|addze.} %4,%3
9ebbca7d
GK
12095 {srai|srawi} %4,%1,31\;{sf|subfc} %4,%1,%4\;{aze.|addze.} %4,%3
12096 #
12097 #"
b19003d8 12098 [(set_attr "type" "compare")
9ebbca7d
GK
12099 (set_attr "length" "12,12,16,16")])
12100
12101(define_split
12102 [(set (match_operand:CC 0 "cc_reg_not_cr0_operand" "")
12103 (compare:CC
12104 (plus:SI (le:SI (match_operand:SI 1 "gpc_reg_operand" "")
12105 (match_operand:SI 2 "reg_or_short_operand" ""))
12106 (match_operand:SI 3 "gpc_reg_operand" ""))
12107 (const_int 0)))
12108 (clobber (match_scratch:SI 4 ""))]
12109 "TARGET_POWER && reload_completed"
12110 [(set (match_dup 4)
12111 (plus:SI (le:SI (match_dup 1) (match_dup 2))
097657c3 12112 (match_dup 3)))
9ebbca7d
GK
12113 (set (match_dup 0)
12114 (compare:CC (match_dup 4)
12115 (const_int 0)))]
12116 "")
1fd4e8c1
RK
12117
12118(define_insn ""
097657c3 12119 [(set (match_operand:CC 4 "cc_reg_operand" "=x,x,?y,?y")
1fd4e8c1 12120 (compare:CC
9ebbca7d
GK
12121 (plus:SI (le:SI (match_operand:SI 1 "gpc_reg_operand" "r,r,r,r")
12122 (match_operand:SI 2 "reg_or_short_operand" "r,O,r,O"))
12123 (match_operand:SI 3 "gpc_reg_operand" "r,r,r,r"))
1fd4e8c1 12124 (const_int 0)))
097657c3
AM
12125 (set (match_operand:SI 0 "gpc_reg_operand" "=&r,&r,&r,&r")
12126 (plus:SI (le:SI (match_dup 1) (match_dup 2)) (match_dup 3)))]
ca7f5001 12127 "TARGET_POWER"
1fd4e8c1 12128 "@
097657c3
AM
12129 doz %0,%2,%1\;{sfi|subfic} %0,%0,0\;{aze.|addze.} %0,%3
12130 {srai|srawi} %0,%1,31\;{sf|subfc} %0,%1,%0\;{aze.|addze.} %0,%3
9ebbca7d
GK
12131 #
12132 #"
b19003d8 12133 [(set_attr "type" "compare")
9ebbca7d
GK
12134 (set_attr "length" "12,12,16,16")])
12135
12136(define_split
097657c3 12137 [(set (match_operand:CC 4 "cc_reg_not_cr0_operand" "")
9ebbca7d
GK
12138 (compare:CC
12139 (plus:SI (le:SI (match_operand:SI 1 "gpc_reg_operand" "")
12140 (match_operand:SI 2 "reg_or_short_operand" ""))
12141 (match_operand:SI 3 "gpc_reg_operand" ""))
12142 (const_int 0)))
12143 (set (match_operand:SI 0 "gpc_reg_operand" "")
097657c3 12144 (plus:SI (le:SI (match_dup 1) (match_dup 2)) (match_dup 3)))]
9ebbca7d 12145 "TARGET_POWER && reload_completed"
097657c3 12146 [(set (match_dup 0)
9ebbca7d 12147 (plus:SI (le:SI (match_dup 1) (match_dup 2)) (match_dup 3)))
097657c3 12148 (set (match_dup 4)
9ebbca7d
GK
12149 (compare:CC (match_dup 0)
12150 (const_int 0)))]
12151 "")
1fd4e8c1
RK
12152
12153(define_insn ""
cd2b37d9
RK
12154 [(set (match_operand:SI 0 "gpc_reg_operand" "=r,r")
12155 (neg:SI (le:SI (match_operand:SI 1 "gpc_reg_operand" "r,r")
1fd4e8c1 12156 (match_operand:SI 2 "reg_or_short_operand" "r,O"))))]
ca7f5001 12157 "TARGET_POWER"
1fd4e8c1 12158 "@
ca7f5001
RK
12159 doz %0,%2,%1\;{ai|addic} %0,%0,-1\;{sfe|subfe} %0,%0,%0
12160 {ai|addic} %0,%1,-1\;{aze|addze} %0,%0\;{srai|srawi} %0,%0,31"
b19003d8 12161 [(set_attr "length" "12")])
1fd4e8c1
RK
12162
12163(define_insn ""
cd2b37d9
RK
12164 [(set (match_operand:SI 0 "gpc_reg_operand" "=r")
12165 (leu:SI (match_operand:SI 1 "gpc_reg_operand" "r")
1fd4e8c1 12166 (match_operand:SI 2 "reg_or_short_operand" "rI")))]
4b8a63d6 12167 "TARGET_32BIT"
ca7f5001 12168 "{sf%I2|subf%I2c} %0,%1,%2\;{cal %0,0(0)|li %0,0}\;{ae|adde} %0,%0,%0"
b19003d8 12169 [(set_attr "length" "12")])
1fd4e8c1 12170
f9562f27
DE
12171(define_insn ""
12172 [(set (match_operand:DI 0 "gpc_reg_operand" "=r")
12173 (leu:DI (match_operand:DI 1 "gpc_reg_operand" "r")
12174 (match_operand:DI 2 "reg_or_short_operand" "rI")))]
683bdff7 12175 "TARGET_64BIT"
f9562f27
DE
12176 "subf%I2c %0,%1,%2\;li %0,0\;adde %0,%0,%0"
12177 [(set_attr "length" "12")])
12178
12179(define_insn ""
9ebbca7d 12180 [(set (match_operand:CC 3 "cc_reg_operand" "=x,?y")
f9562f27 12181 (compare:CC
9ebbca7d
GK
12182 (leu:DI (match_operand:DI 1 "gpc_reg_operand" "r,r")
12183 (match_operand:DI 2 "reg_or_short_operand" "rI,rI"))
f9562f27 12184 (const_int 0)))
9ebbca7d 12185 (set (match_operand:DI 0 "gpc_reg_operand" "=r,r")
f9562f27 12186 (leu:DI (match_dup 1) (match_dup 2)))]
683bdff7 12187 "TARGET_64BIT"
9ebbca7d
GK
12188 "@
12189 subf%I2c %0,%1,%2\;li %0,0\;adde. %0,%0,%0
12190 #"
f9562f27 12191 [(set_attr "type" "compare")
9ebbca7d
GK
12192 (set_attr "length" "12,16")])
12193
12194(define_split
12195 [(set (match_operand:CC 3 "cc_reg_not_cr0_operand" "")
12196 (compare:CC
12197 (leu:DI (match_operand:DI 1 "gpc_reg_operand" "")
12198 (match_operand:DI 2 "reg_or_short_operand" ""))
12199 (const_int 0)))
12200 (set (match_operand:DI 0 "gpc_reg_operand" "")
12201 (leu:DI (match_dup 1) (match_dup 2)))]
683bdff7 12202 "TARGET_64BIT && reload_completed"
9ebbca7d
GK
12203 [(set (match_dup 0)
12204 (leu:DI (match_dup 1) (match_dup 2)))
12205 (set (match_dup 3)
12206 (compare:CC (match_dup 0)
12207 (const_int 0)))]
12208 "")
f9562f27 12209
1fd4e8c1 12210(define_insn ""
9ebbca7d 12211 [(set (match_operand:CC 3 "cc_reg_operand" "=x,?y")
1fd4e8c1 12212 (compare:CC
9ebbca7d
GK
12213 (leu:SI (match_operand:SI 1 "gpc_reg_operand" "r,r")
12214 (match_operand:SI 2 "reg_or_short_operand" "rI,rI"))
1fd4e8c1 12215 (const_int 0)))
9ebbca7d 12216 (set (match_operand:SI 0 "gpc_reg_operand" "=r,r")
1fd4e8c1 12217 (leu:SI (match_dup 1) (match_dup 2)))]
683bdff7 12218 "TARGET_32BIT"
9ebbca7d
GK
12219 "@
12220 {sf%I2|subf%I2c} %0,%1,%2\;{cal %0,0(0)|li %0,0}\;{ae.|adde.} %0,%0,%0
12221 #"
b19003d8 12222 [(set_attr "type" "compare")
9ebbca7d
GK
12223 (set_attr "length" "12,16")])
12224
12225(define_split
12226 [(set (match_operand:CC 3 "cc_reg_not_cr0_operand" "")
12227 (compare:CC
12228 (leu:SI (match_operand:SI 1 "gpc_reg_operand" "")
12229 (match_operand:SI 2 "reg_or_short_operand" ""))
12230 (const_int 0)))
12231 (set (match_operand:SI 0 "gpc_reg_operand" "")
12232 (leu:SI (match_dup 1) (match_dup 2)))]
683bdff7 12233 "TARGET_32BIT && reload_completed"
9ebbca7d
GK
12234 [(set (match_dup 0)
12235 (leu:SI (match_dup 1) (match_dup 2)))
12236 (set (match_dup 3)
12237 (compare:CC (match_dup 0)
12238 (const_int 0)))]
12239 "")
1fd4e8c1
RK
12240
12241(define_insn ""
80103f96 12242 [(set (match_operand:SI 0 "gpc_reg_operand" "=&r")
cd2b37d9 12243 (plus:SI (leu:SI (match_operand:SI 1 "gpc_reg_operand" "r")
1fd4e8c1 12244 (match_operand:SI 2 "reg_or_short_operand" "rI"))
80103f96 12245 (match_operand:SI 3 "gpc_reg_operand" "r")))]
683bdff7 12246 "TARGET_32BIT"
80103f96 12247 "{sf%I2|subf%I2c} %0,%1,%2\;{aze|addze} %0,%3"
b19003d8 12248 [(set_attr "length" "8")])
1fd4e8c1
RK
12249
12250(define_insn ""
9ebbca7d 12251 [(set (match_operand:CC 0 "cc_reg_operand" "=x,?y")
1fd4e8c1 12252 (compare:CC
9ebbca7d
GK
12253 (plus:SI (leu:SI (match_operand:SI 1 "gpc_reg_operand" "r,r")
12254 (match_operand:SI 2 "reg_or_short_operand" "rI,rI"))
12255 (match_operand:SI 3 "gpc_reg_operand" "r,r"))
1fd4e8c1 12256 (const_int 0)))
9ebbca7d 12257 (clobber (match_scratch:SI 4 "=&r,&r"))]
683bdff7 12258 "TARGET_32BIT"
9ebbca7d
GK
12259 "@
12260 {sf%I2|subf%I2c} %4,%1,%2\;{aze.|addze.} %4,%3
12261 #"
b19003d8 12262 [(set_attr "type" "compare")
9ebbca7d
GK
12263 (set_attr "length" "8,12")])
12264
12265(define_split
12266 [(set (match_operand:CC 0 "cc_reg_not_cr0_operand" "")
12267 (compare:CC
12268 (plus:SI (leu:SI (match_operand:SI 1 "gpc_reg_operand" "")
12269 (match_operand:SI 2 "reg_or_short_operand" ""))
12270 (match_operand:SI 3 "gpc_reg_operand" ""))
12271 (const_int 0)))
12272 (clobber (match_scratch:SI 4 ""))]
683bdff7 12273 "TARGET_32BIT && reload_completed"
9ebbca7d
GK
12274 [(set (match_dup 4)
12275 (plus:SI (leu:SI (match_dup 1) (match_dup 2))
12276 (match_dup 3)))
12277 (set (match_dup 0)
12278 (compare:CC (match_dup 4)
12279 (const_int 0)))]
12280 "")
1fd4e8c1
RK
12281
12282(define_insn ""
097657c3 12283 [(set (match_operand:CC 4 "cc_reg_operand" "=x,?y")
1fd4e8c1 12284 (compare:CC
9ebbca7d
GK
12285 (plus:SI (leu:SI (match_operand:SI 1 "gpc_reg_operand" "r,r")
12286 (match_operand:SI 2 "reg_or_short_operand" "rI,rI"))
12287 (match_operand:SI 3 "gpc_reg_operand" "r,r"))
1fd4e8c1 12288 (const_int 0)))
097657c3
AM
12289 (set (match_operand:SI 0 "gpc_reg_operand" "=&r,&r")
12290 (plus:SI (leu:SI (match_dup 1) (match_dup 2)) (match_dup 3)))]
683bdff7 12291 "TARGET_32BIT"
9ebbca7d 12292 "@
097657c3 12293 {sf%I2|subf%I2c} %0,%1,%2\;{aze.|addze.} %0,%3
9ebbca7d 12294 #"
b19003d8 12295 [(set_attr "type" "compare")
9ebbca7d
GK
12296 (set_attr "length" "8,12")])
12297
12298(define_split
097657c3 12299 [(set (match_operand:CC 4 "cc_reg_not_cr0_operand" "")
9ebbca7d
GK
12300 (compare:CC
12301 (plus:SI (leu:SI (match_operand:SI 1 "gpc_reg_operand" "")
12302 (match_operand:SI 2 "reg_or_short_operand" ""))
12303 (match_operand:SI 3 "gpc_reg_operand" ""))
12304 (const_int 0)))
12305 (set (match_operand:SI 0 "gpc_reg_operand" "")
097657c3 12306 (plus:SI (leu:SI (match_dup 1) (match_dup 2)) (match_dup 3)))]
683bdff7 12307 "TARGET_32BIT && reload_completed"
097657c3 12308 [(set (match_dup 0)
9ebbca7d 12309 (plus:SI (leu:SI (match_dup 1) (match_dup 2)) (match_dup 3)))
097657c3 12310 (set (match_dup 4)
9ebbca7d
GK
12311 (compare:CC (match_dup 0)
12312 (const_int 0)))]
12313 "")
1fd4e8c1
RK
12314
12315(define_insn ""
cd2b37d9
RK
12316 [(set (match_operand:SI 0 "gpc_reg_operand" "=r")
12317 (neg:SI (leu:SI (match_operand:SI 1 "gpc_reg_operand" "r")
1fd4e8c1 12318 (match_operand:SI 2 "reg_or_short_operand" "rI"))))]
683bdff7 12319 "TARGET_32BIT"
ca7f5001 12320 "{sf%I2|subf%I2c} %0,%1,%2\;{sfe|subfe} %0,%0,%0\;nand %0,%0,%0"
b19003d8 12321 [(set_attr "length" "12")])
1fd4e8c1
RK
12322
12323(define_insn ""
097657c3 12324 [(set (match_operand:SI 0 "gpc_reg_operand" "=&r")
1fd4e8c1 12325 (and:SI (neg:SI
cd2b37d9 12326 (leu:SI (match_operand:SI 1 "gpc_reg_operand" "r")
1fd4e8c1 12327 (match_operand:SI 2 "reg_or_short_operand" "rI")))
097657c3 12328 (match_operand:SI 3 "gpc_reg_operand" "r")))]
683bdff7 12329 "TARGET_32BIT"
097657c3 12330 "{sf%I2|subf%I2c} %0,%1,%2\;{sfe|subfe} %0,%0,%0\;andc %0,%3,%0"
b19003d8 12331 [(set_attr "length" "12")])
1fd4e8c1
RK
12332
12333(define_insn ""
9ebbca7d 12334 [(set (match_operand:CC 0 "cc_reg_operand" "=x,?y")
1fd4e8c1
RK
12335 (compare:CC
12336 (and:SI (neg:SI
9ebbca7d
GK
12337 (leu:SI (match_operand:SI 1 "gpc_reg_operand" "r,r")
12338 (match_operand:SI 2 "reg_or_short_operand" "rI,rI")))
12339 (match_operand:SI 3 "gpc_reg_operand" "r,r"))
1fd4e8c1 12340 (const_int 0)))
9ebbca7d 12341 (clobber (match_scratch:SI 4 "=&r,&r"))]
683bdff7 12342 "TARGET_32BIT"
9ebbca7d
GK
12343 "@
12344 {sf%I2|subf%I2c} %4,%1,%2\;{sfe|subfe} %4,%4,%4\;andc. %4,%3,%4
12345 #"
12346 [(set_attr "type" "compare")
12347 (set_attr "length" "12,16")])
12348
12349(define_split
12350 [(set (match_operand:CC 0 "cc_reg_not_cr0_operand" "")
12351 (compare:CC
12352 (and:SI (neg:SI
12353 (leu:SI (match_operand:SI 1 "gpc_reg_operand" "")
12354 (match_operand:SI 2 "reg_or_short_operand" "")))
12355 (match_operand:SI 3 "gpc_reg_operand" ""))
12356 (const_int 0)))
12357 (clobber (match_scratch:SI 4 ""))]
683bdff7 12358 "TARGET_32BIT && reload_completed"
9ebbca7d 12359 [(set (match_dup 4)
097657c3
AM
12360 (and:SI (neg:SI (leu:SI (match_dup 1) (match_dup 2)))
12361 (match_dup 3)))
9ebbca7d
GK
12362 (set (match_dup 0)
12363 (compare:CC (match_dup 4)
12364 (const_int 0)))]
12365 "")
1fd4e8c1
RK
12366
12367(define_insn ""
097657c3 12368 [(set (match_operand:CC 4 "cc_reg_operand" "=x,?y")
1fd4e8c1
RK
12369 (compare:CC
12370 (and:SI (neg:SI
9ebbca7d
GK
12371 (leu:SI (match_operand:SI 1 "gpc_reg_operand" "r,r")
12372 (match_operand:SI 2 "reg_or_short_operand" "rI,rI")))
12373 (match_operand:SI 3 "gpc_reg_operand" "r,r"))
1fd4e8c1 12374 (const_int 0)))
097657c3
AM
12375 (set (match_operand:SI 0 "gpc_reg_operand" "=&r,&r")
12376 (and:SI (neg:SI (leu:SI (match_dup 1) (match_dup 2))) (match_dup 3)))]
683bdff7 12377 "TARGET_32BIT"
9ebbca7d 12378 "@
097657c3 12379 {sf%I2|subf%I2c} %0,%1,%2\;{sfe|subfe} %0,%0,%0\;andc. %0,%3,%0
9ebbca7d 12380 #"
b19003d8 12381 [(set_attr "type" "compare")
9ebbca7d
GK
12382 (set_attr "length" "12,16")])
12383
12384(define_split
097657c3 12385 [(set (match_operand:CC 4 "cc_reg_not_cr0_operand" "")
9ebbca7d
GK
12386 (compare:CC
12387 (and:SI (neg:SI
12388 (leu:SI (match_operand:SI 1 "gpc_reg_operand" "")
12389 (match_operand:SI 2 "reg_or_short_operand" "")))
12390 (match_operand:SI 3 "gpc_reg_operand" ""))
12391 (const_int 0)))
12392 (set (match_operand:SI 0 "gpc_reg_operand" "")
097657c3 12393 (and:SI (neg:SI (leu:SI (match_dup 1) (match_dup 2))) (match_dup 3)))]
683bdff7 12394 "TARGET_32BIT && reload_completed"
097657c3
AM
12395 [(set (match_dup 0)
12396 (and:SI (neg:SI (leu:SI (match_dup 1) (match_dup 2)))
12397 (match_dup 3)))
12398 (set (match_dup 4)
9ebbca7d
GK
12399 (compare:CC (match_dup 0)
12400 (const_int 0)))]
12401 "")
1fd4e8c1
RK
12402
12403(define_insn ""
cd2b37d9
RK
12404 [(set (match_operand:SI 0 "gpc_reg_operand" "=r")
12405 (lt:SI (match_operand:SI 1 "gpc_reg_operand" "r")
1fd4e8c1 12406 (match_operand:SI 2 "reg_or_short_operand" "rI")))]
ca7f5001 12407 "TARGET_POWER"
7f340546 12408 "doz%I2 %0,%1,%2\;nabs %0,%0\;{sri|srwi} %0,%0,31"
b19003d8 12409 [(set_attr "length" "12")])
1fd4e8c1
RK
12410
12411(define_insn ""
9ebbca7d 12412 [(set (match_operand:CC 3 "cc_reg_operand" "=x,?y")
1fd4e8c1 12413 (compare:CC
9ebbca7d
GK
12414 (lt:SI (match_operand:SI 1 "gpc_reg_operand" "r,r")
12415 (match_operand:SI 2 "reg_or_short_operand" "rI,rI"))
1fd4e8c1 12416 (const_int 0)))
9ebbca7d 12417 (set (match_operand:SI 0 "gpc_reg_operand" "=r,r")
1fd4e8c1 12418 (lt:SI (match_dup 1) (match_dup 2)))]
ca7f5001 12419 "TARGET_POWER"
9ebbca7d
GK
12420 "@
12421 doz%I2 %0,%1,%2\;nabs %0,%0\;{sri.|srwi.} %0,%0,31
12422 #"
29ae5b89 12423 [(set_attr "type" "delayed_compare")
9ebbca7d
GK
12424 (set_attr "length" "12,16")])
12425
12426(define_split
12427 [(set (match_operand:CC 3 "cc_reg_not_cr0_operand" "")
12428 (compare:CC
12429 (lt:SI (match_operand:SI 1 "gpc_reg_operand" "")
12430 (match_operand:SI 2 "reg_or_short_operand" ""))
12431 (const_int 0)))
12432 (set (match_operand:SI 0 "gpc_reg_operand" "")
12433 (lt:SI (match_dup 1) (match_dup 2)))]
12434 "TARGET_POWER && reload_completed"
12435 [(set (match_dup 0)
12436 (lt:SI (match_dup 1) (match_dup 2)))
12437 (set (match_dup 3)
12438 (compare:CC (match_dup 0)
12439 (const_int 0)))]
12440 "")
1fd4e8c1
RK
12441
12442(define_insn ""
097657c3 12443 [(set (match_operand:SI 0 "gpc_reg_operand" "=&r")
cd2b37d9 12444 (plus:SI (lt:SI (match_operand:SI 1 "gpc_reg_operand" "r")
1fd4e8c1 12445 (match_operand:SI 2 "reg_or_short_operand" "rI"))
097657c3 12446 (match_operand:SI 3 "gpc_reg_operand" "r")))]
ca7f5001 12447 "TARGET_POWER"
097657c3 12448 "doz%I2 %0,%1,%2\;{ai|addic} %0,%0,-1\;{aze|addze} %0,%3"
b19003d8 12449 [(set_attr "length" "12")])
1fd4e8c1
RK
12450
12451(define_insn ""
9ebbca7d 12452 [(set (match_operand:CC 0 "cc_reg_operand" "=x,?y")
1fd4e8c1 12453 (compare:CC
9ebbca7d
GK
12454 (plus:SI (lt:SI (match_operand:SI 1 "gpc_reg_operand" "r,r")
12455 (match_operand:SI 2 "reg_or_short_operand" "rI,rI"))
12456 (match_operand:SI 3 "gpc_reg_operand" "r,r"))
1fd4e8c1 12457 (const_int 0)))
9ebbca7d 12458 (clobber (match_scratch:SI 4 "=&r,&r"))]
ca7f5001 12459 "TARGET_POWER"
9ebbca7d
GK
12460 "@
12461 doz%I2 %4,%1,%2\;{ai|addic} %4,%4,-1\;{aze.|addze.} %4,%3
12462 #"
b19003d8 12463 [(set_attr "type" "compare")
9ebbca7d
GK
12464 (set_attr "length" "12,16")])
12465
12466(define_split
12467 [(set (match_operand:CC 0 "cc_reg_not_cr0_operand" "")
12468 (compare:CC
12469 (plus:SI (lt:SI (match_operand:SI 1 "gpc_reg_operand" "")
12470 (match_operand:SI 2 "reg_or_short_operand" ""))
12471 (match_operand:SI 3 "gpc_reg_operand" ""))
12472 (const_int 0)))
12473 (clobber (match_scratch:SI 4 ""))]
12474 "TARGET_POWER && reload_completed"
12475 [(set (match_dup 4)
12476 (plus:SI (lt:SI (match_dup 1) (match_dup 2))
097657c3 12477 (match_dup 3)))
9ebbca7d
GK
12478 (set (match_dup 0)
12479 (compare:CC (match_dup 4)
12480 (const_int 0)))]
12481 "")
1fd4e8c1
RK
12482
12483(define_insn ""
097657c3 12484 [(set (match_operand:CC 4 "cc_reg_operand" "=x,?y")
1fd4e8c1 12485 (compare:CC
9ebbca7d
GK
12486 (plus:SI (lt:SI (match_operand:SI 1 "gpc_reg_operand" "r,r")
12487 (match_operand:SI 2 "reg_or_short_operand" "rI,rI"))
12488 (match_operand:SI 3 "gpc_reg_operand" "r,r"))
1fd4e8c1 12489 (const_int 0)))
097657c3
AM
12490 (set (match_operand:SI 0 "gpc_reg_operand" "=&r,&r")
12491 (plus:SI (lt:SI (match_dup 1) (match_dup 2)) (match_dup 3)))]
ca7f5001 12492 "TARGET_POWER"
9ebbca7d 12493 "@
097657c3 12494 doz%I2 %0,%1,%2\;{ai|addic} %0,%0,-1\;{aze.|addze.} %0,%3
9ebbca7d 12495 #"
b19003d8 12496 [(set_attr "type" "compare")
9ebbca7d
GK
12497 (set_attr "length" "12,16")])
12498
12499(define_split
097657c3 12500 [(set (match_operand:CC 4 "cc_reg_not_cr0_operand" "")
9ebbca7d
GK
12501 (compare:CC
12502 (plus:SI (lt:SI (match_operand:SI 1 "gpc_reg_operand" "")
12503 (match_operand:SI 2 "reg_or_short_operand" ""))
12504 (match_operand:SI 3 "gpc_reg_operand" ""))
12505 (const_int 0)))
12506 (set (match_operand:SI 0 "gpc_reg_operand" "")
097657c3 12507 (plus:SI (lt:SI (match_dup 1) (match_dup 2)) (match_dup 3)))]
9ebbca7d 12508 "TARGET_POWER && reload_completed"
097657c3 12509 [(set (match_dup 0)
9ebbca7d 12510 (plus:SI (lt:SI (match_dup 1) (match_dup 2)) (match_dup 3)))
097657c3 12511 (set (match_dup 4)
9ebbca7d
GK
12512 (compare:CC (match_dup 0)
12513 (const_int 0)))]
12514 "")
1fd4e8c1
RK
12515
12516(define_insn ""
cd2b37d9
RK
12517 [(set (match_operand:SI 0 "gpc_reg_operand" "=r")
12518 (neg:SI (lt:SI (match_operand:SI 1 "gpc_reg_operand" "r")
1fd4e8c1 12519 (match_operand:SI 2 "reg_or_short_operand" "rI"))))]
ca7f5001
RK
12520 "TARGET_POWER"
12521 "doz%I2 %0,%1,%2\;nabs %0,%0\;{srai|srawi} %0,%0,31"
b19003d8 12522 [(set_attr "length" "12")])
1fd4e8c1
RK
12523
12524(define_insn ""
cd2b37d9
RK
12525 [(set (match_operand:SI 0 "gpc_reg_operand" "=r,r")
12526 (ltu:SI (match_operand:SI 1 "gpc_reg_operand" "r,r")
1fd4e8c1 12527 (match_operand:SI 2 "reg_or_neg_short_operand" "r,P")))]
683bdff7 12528 "TARGET_32BIT"
1fd4e8c1 12529 "@
ca7f5001
RK
12530 {sf|subfc} %0,%2,%1\;{sfe|subfe} %0,%0,%0\;neg %0,%0
12531 {ai|addic} %0,%1,%n2\;{sfe|subfe} %0,%0,%0\;neg %0,%0"
b19003d8 12532 [(set_attr "length" "12")])
1fd4e8c1
RK
12533
12534(define_insn ""
9ebbca7d 12535 [(set (match_operand:CC 3 "cc_reg_operand" "=x,x,?y,?y")
1fd4e8c1 12536 (compare:CC
9ebbca7d
GK
12537 (ltu:SI (match_operand:SI 1 "gpc_reg_operand" "r,r,r,r")
12538 (match_operand:SI 2 "reg_or_neg_short_operand" "r,P,r,P"))
1fd4e8c1 12539 (const_int 0)))
9ebbca7d 12540 (set (match_operand:SI 0 "gpc_reg_operand" "=r,r,r,r")
1fd4e8c1 12541 (ltu:SI (match_dup 1) (match_dup 2)))]
683bdff7 12542 "TARGET_32BIT"
1fd4e8c1 12543 "@
ca7f5001 12544 {sf|subfc} %0,%2,%1\;{sfe|subfe} %0,%0,%0\;neg. %0,%0
9ebbca7d
GK
12545 {ai|addic} %0,%1,%n2\;{sfe|subfe} %0,%0,%0\;neg. %0,%0
12546 #
12547 #"
b19003d8 12548 [(set_attr "type" "compare")
9ebbca7d
GK
12549 (set_attr "length" "12,12,16,16")])
12550
12551(define_split
12552 [(set (match_operand:CC 3 "cc_reg_not_cr0_operand" "")
12553 (compare:CC
12554 (ltu:SI (match_operand:SI 1 "gpc_reg_operand" "")
12555 (match_operand:SI 2 "reg_or_neg_short_operand" ""))
12556 (const_int 0)))
12557 (set (match_operand:SI 0 "gpc_reg_operand" "")
12558 (ltu:SI (match_dup 1) (match_dup 2)))]
683bdff7 12559 "TARGET_32BIT && reload_completed"
9ebbca7d
GK
12560 [(set (match_dup 0)
12561 (ltu:SI (match_dup 1) (match_dup 2)))
12562 (set (match_dup 3)
12563 (compare:CC (match_dup 0)
12564 (const_int 0)))]
12565 "")
1fd4e8c1
RK
12566
12567(define_insn ""
80103f96 12568 [(set (match_operand:SI 0 "gpc_reg_operand" "=&r,&r")
19378cf8
MM
12569 (plus:SI (ltu:SI (match_operand:SI 1 "gpc_reg_operand" "r,r")
12570 (match_operand:SI 2 "reg_or_neg_short_operand" "r,P"))
80103f96 12571 (match_operand:SI 3 "reg_or_short_operand" "rI,rI")))]
683bdff7 12572 "TARGET_32BIT"
1fd4e8c1 12573 "@
80103f96
FS
12574 {sf|subfc} %0,%2,%1\;{sfe|subfe} %0,%0,%0\;{sf%I3|subf%I3c} %0,%0,%3
12575 {ai|addic} %0,%1,%n2\;{sfe|subfe} %0,%0,%0\;{sf%I3|subf%I3c} %0,%0,%3"
b19003d8 12576 [(set_attr "length" "12")])
1fd4e8c1
RK
12577
12578(define_insn ""
9ebbca7d 12579 [(set (match_operand:CC 0 "cc_reg_operand" "=x,x,?y,?y")
1fd4e8c1 12580 (compare:CC
9ebbca7d
GK
12581 (plus:SI (ltu:SI (match_operand:SI 1 "gpc_reg_operand" "r,r,r,r")
12582 (match_operand:SI 2 "reg_or_neg_short_operand" "r,P,r,P"))
12583 (match_operand:SI 3 "gpc_reg_operand" "r,r,r,r"))
1fd4e8c1 12584 (const_int 0)))
9ebbca7d 12585 (clobber (match_scratch:SI 4 "=&r,&r,&r,&r"))]
683bdff7 12586 "TARGET_32BIT"
1fd4e8c1 12587 "@
ca7f5001 12588 {sf|subfc} %4,%2,%1\;{sfe|subfe} %4,%4,%4\;{sf.|subfc.} %4,%4,%3
9ebbca7d
GK
12589 {ai|addic} %4,%1,%n2\;{sfe|subfe} %4,%4,%4\;{sf.|subfc.} %4,%4,%3
12590 #
12591 #"
b19003d8 12592 [(set_attr "type" "compare")
9ebbca7d
GK
12593 (set_attr "length" "12,12,16,16")])
12594
12595(define_split
12596 [(set (match_operand:CC 0 "cc_reg_not_cr0_operand" "")
12597 (compare:CC
12598 (plus:SI (ltu:SI (match_operand:SI 1 "gpc_reg_operand" "")
12599 (match_operand:SI 2 "reg_or_neg_short_operand" ""))
12600 (match_operand:SI 3 "gpc_reg_operand" ""))
12601 (const_int 0)))
12602 (clobber (match_scratch:SI 4 ""))]
683bdff7 12603 "TARGET_32BIT && reload_completed"
9ebbca7d
GK
12604 [(set (match_dup 4)
12605 (plus:SI (ltu:SI (match_dup 1) (match_dup 2))
097657c3 12606 (match_dup 3)))
9ebbca7d
GK
12607 (set (match_dup 0)
12608 (compare:CC (match_dup 4)
12609 (const_int 0)))]
12610 "")
1fd4e8c1
RK
12611
12612(define_insn ""
097657c3 12613 [(set (match_operand:CC 4 "cc_reg_operand" "=x,x,?y,?y")
1fd4e8c1 12614 (compare:CC
9ebbca7d
GK
12615 (plus:SI (ltu:SI (match_operand:SI 1 "gpc_reg_operand" "r,r,r,r")
12616 (match_operand:SI 2 "reg_or_neg_short_operand" "r,P,r,P"))
12617 (match_operand:SI 3 "gpc_reg_operand" "r,r,r,r"))
1fd4e8c1 12618 (const_int 0)))
097657c3
AM
12619 (set (match_operand:SI 0 "gpc_reg_operand" "=&r,&r,&r,&r")
12620 (plus:SI (ltu:SI (match_dup 1) (match_dup 2)) (match_dup 3)))]
683bdff7 12621 "TARGET_32BIT"
1fd4e8c1 12622 "@
097657c3
AM
12623 {sf|subfc} %0,%2,%1\;{sfe|subfe} %0,%0,%0\;{sf.|subfc.} %0,%0,%3
12624 {ai|addic} %0,%1,%n2\;{sfe|subfe} %0,%0,%0\;{sf.|subfc.} %0,%0,%3
9ebbca7d
GK
12625 #
12626 #"
b19003d8 12627 [(set_attr "type" "compare")
9ebbca7d
GK
12628 (set_attr "length" "12,12,16,16")])
12629
12630(define_split
097657c3 12631 [(set (match_operand:CC 4 "cc_reg_not_cr0_operand" "")
9ebbca7d
GK
12632 (compare:CC
12633 (plus:SI (ltu:SI (match_operand:SI 1 "gpc_reg_operand" "")
12634 (match_operand:SI 2 "reg_or_neg_short_operand" ""))
12635 (match_operand:SI 3 "gpc_reg_operand" ""))
12636 (const_int 0)))
12637 (set (match_operand:SI 0 "gpc_reg_operand" "")
097657c3 12638 (plus:SI (ltu:SI (match_dup 1) (match_dup 2)) (match_dup 3)))]
683bdff7 12639 "TARGET_32BIT && reload_completed"
097657c3 12640 [(set (match_dup 0)
9ebbca7d 12641 (plus:SI (ltu:SI (match_dup 1) (match_dup 2)) (match_dup 3)))
097657c3 12642 (set (match_dup 4)
9ebbca7d
GK
12643 (compare:CC (match_dup 0)
12644 (const_int 0)))]
12645 "")
1fd4e8c1
RK
12646
12647(define_insn ""
cd2b37d9
RK
12648 [(set (match_operand:SI 0 "gpc_reg_operand" "=r,r")
12649 (neg:SI (ltu:SI (match_operand:SI 1 "gpc_reg_operand" "r,r")
1fd4e8c1 12650 (match_operand:SI 2 "reg_or_neg_short_operand" "r,P"))))]
683bdff7 12651 "TARGET_32BIT"
1fd4e8c1 12652 "@
ca7f5001
RK
12653 {sf|subfc} %0,%2,%1\;{sfe|subfe} %0,%0,%0
12654 {ai|addic} %0,%1,%n2\;{sfe|subfe} %0,%0,%0"
b19003d8 12655 [(set_attr "length" "8")])
1fd4e8c1
RK
12656
12657(define_insn ""
cd2b37d9
RK
12658 [(set (match_operand:SI 0 "gpc_reg_operand" "=r")
12659 (ge:SI (match_operand:SI 1 "gpc_reg_operand" "r")
1fd4e8c1
RK
12660 (match_operand:SI 2 "reg_or_short_operand" "rI")))
12661 (clobber (match_scratch:SI 3 "=r"))]
ca7f5001
RK
12662 "TARGET_POWER"
12663 "doz%I2 %3,%1,%2\;{sfi|subfic} %0,%3,0\;{ae|adde} %0,%0,%3"
b19003d8 12664 [(set_attr "length" "12")])
1fd4e8c1 12665
9ebbca7d
GK
12666(define_insn ""
12667 [(set (match_operand:CC 4 "cc_reg_operand" "=x,?y")
1fd4e8c1 12668 (compare:CC
9ebbca7d
GK
12669 (ge:SI (match_operand:SI 1 "gpc_reg_operand" "r,r")
12670 (match_operand:SI 2 "reg_or_short_operand" "rI,rI"))
1fd4e8c1 12671 (const_int 0)))
9ebbca7d 12672 (set (match_operand:SI 0 "gpc_reg_operand" "=r,r")
1fd4e8c1 12673 (ge:SI (match_dup 1) (match_dup 2)))
9ebbca7d 12674 (clobber (match_scratch:SI 3 "=r,r"))]
ca7f5001 12675 "TARGET_POWER"
9ebbca7d
GK
12676 "@
12677 doz%I2 %3,%1,%2\;{sfi|subfic} %0,%3,0\;{ae.|adde.} %0,%0,%3
12678 #"
12679 [(set_attr "type" "compare")
12680 (set_attr "length" "12,16")])
12681
12682(define_split
12683 [(set (match_operand:CC 4 "cc_reg_not_cr0_operand" "")
12684 (compare:CC
12685 (ge:SI (match_operand:SI 1 "gpc_reg_operand" "")
12686 (match_operand:SI 2 "reg_or_short_operand" ""))
12687 (const_int 0)))
12688 (set (match_operand:SI 0 "gpc_reg_operand" "")
12689 (ge:SI (match_dup 1) (match_dup 2)))
12690 (clobber (match_scratch:SI 3 ""))]
12691 "TARGET_POWER && reload_completed"
12692 [(parallel [(set (match_dup 0)
097657c3
AM
12693 (ge:SI (match_dup 1) (match_dup 2)))
12694 (clobber (match_dup 3))])
9ebbca7d
GK
12695 (set (match_dup 4)
12696 (compare:CC (match_dup 0)
12697 (const_int 0)))]
12698 "")
12699
1fd4e8c1 12700(define_insn ""
097657c3 12701 [(set (match_operand:SI 0 "gpc_reg_operand" "=&r")
cd2b37d9 12702 (plus:SI (ge:SI (match_operand:SI 1 "gpc_reg_operand" "r")
1fd4e8c1 12703 (match_operand:SI 2 "reg_or_short_operand" "rI"))
097657c3 12704 (match_operand:SI 3 "gpc_reg_operand" "r")))]
ca7f5001 12705 "TARGET_POWER"
097657c3 12706 "doz%I2 %0,%1,%2\;{sfi|subfic} %0,%0,0\;{aze|addze} %0,%3"
b19003d8 12707 [(set_attr "length" "12")])
1fd4e8c1
RK
12708
12709(define_insn ""
9ebbca7d 12710 [(set (match_operand:CC 0 "cc_reg_operand" "=x,?y")
1fd4e8c1 12711 (compare:CC
9ebbca7d
GK
12712 (plus:SI (ge:SI (match_operand:SI 1 "gpc_reg_operand" "r,r")
12713 (match_operand:SI 2 "reg_or_short_operand" "rI,rI"))
12714 (match_operand:SI 3 "gpc_reg_operand" "r,r"))
1fd4e8c1 12715 (const_int 0)))
9ebbca7d 12716 (clobber (match_scratch:SI 4 "=&r,&r"))]
ca7f5001 12717 "TARGET_POWER"
9ebbca7d
GK
12718 "@
12719 doz%I2 %4,%1,%2\;{sfi|subfic} %4,%4,0\;{aze.|addze.} %4,%3
12720 #"
b19003d8 12721 [(set_attr "type" "compare")
9ebbca7d
GK
12722 (set_attr "length" "12,16")])
12723
12724(define_split
12725 [(set (match_operand:CC 0 "cc_reg_not_cr0_operand" "")
12726 (compare:CC
12727 (plus:SI (ge:SI (match_operand:SI 1 "gpc_reg_operand" "")
12728 (match_operand:SI 2 "reg_or_short_operand" ""))
12729 (match_operand:SI 3 "gpc_reg_operand" ""))
12730 (const_int 0)))
12731 (clobber (match_scratch:SI 4 ""))]
12732 "TARGET_POWER && reload_completed"
12733 [(set (match_dup 4)
12734 (plus:SI (ge:SI (match_dup 1) (match_dup 2))
097657c3 12735 (match_dup 3)))
9ebbca7d
GK
12736 (set (match_dup 0)
12737 (compare:CC (match_dup 4)
12738 (const_int 0)))]
12739 "")
1fd4e8c1
RK
12740
12741(define_insn ""
097657c3 12742 [(set (match_operand:CC 4 "cc_reg_operand" "=x,?y")
1fd4e8c1 12743 (compare:CC
9ebbca7d
GK
12744 (plus:SI (ge:SI (match_operand:SI 1 "gpc_reg_operand" "r,r")
12745 (match_operand:SI 2 "reg_or_short_operand" "rI,rI"))
12746 (match_operand:SI 3 "gpc_reg_operand" "r,r"))
1fd4e8c1 12747 (const_int 0)))
097657c3
AM
12748 (set (match_operand:SI 0 "gpc_reg_operand" "=&r,&r")
12749 (plus:SI (ge:SI (match_dup 1) (match_dup 2)) (match_dup 3)))]
ca7f5001 12750 "TARGET_POWER"
9ebbca7d 12751 "@
097657c3 12752 doz%I2 %0,%1,%2\;{sfi|subfic} %0,%0,0\;{aze.|addze.} %0,%3
9ebbca7d 12753 #"
b19003d8 12754 [(set_attr "type" "compare")
9ebbca7d
GK
12755 (set_attr "length" "12,16")])
12756
12757(define_split
097657c3 12758 [(set (match_operand:CC 4 "cc_reg_not_cr0_operand" "")
9ebbca7d
GK
12759 (compare:CC
12760 (plus:SI (ge:SI (match_operand:SI 1 "gpc_reg_operand" "")
12761 (match_operand:SI 2 "reg_or_short_operand" ""))
12762 (match_operand:SI 3 "gpc_reg_operand" ""))
12763 (const_int 0)))
12764 (set (match_operand:SI 0 "gpc_reg_operand" "")
097657c3 12765 (plus:SI (ge:SI (match_dup 1) (match_dup 2)) (match_dup 3)))]
9ebbca7d 12766 "TARGET_POWER && reload_completed"
097657c3 12767 [(set (match_dup 0)
9ebbca7d 12768 (plus:SI (ge:SI (match_dup 1) (match_dup 2)) (match_dup 3)))
097657c3 12769 (set (match_dup 4)
9ebbca7d
GK
12770 (compare:CC (match_dup 0)
12771 (const_int 0)))]
12772 "")
1fd4e8c1
RK
12773
12774(define_insn ""
cd2b37d9
RK
12775 [(set (match_operand:SI 0 "gpc_reg_operand" "=r")
12776 (neg:SI (ge:SI (match_operand:SI 1 "gpc_reg_operand" "r")
1fd4e8c1 12777 (match_operand:SI 2 "reg_or_short_operand" "rI"))))]
ca7f5001
RK
12778 "TARGET_POWER"
12779 "doz%I2 %0,%1,%2\;{ai|addic} %0,%0,-1\;{sfe|subfe} %0,%0,%0"
b19003d8 12780 [(set_attr "length" "12")])
1fd4e8c1 12781
1fd4e8c1 12782(define_insn ""
cd2b37d9
RK
12783 [(set (match_operand:SI 0 "gpc_reg_operand" "=r,r")
12784 (geu:SI (match_operand:SI 1 "gpc_reg_operand" "r,r")
1fd4e8c1 12785 (match_operand:SI 2 "reg_or_neg_short_operand" "r,P")))]
683bdff7 12786 "TARGET_32BIT"
1fd4e8c1 12787 "@
ca7f5001
RK
12788 {sf|subfc} %0,%2,%1\;{cal %0,0(0)|li %0,0}\;{ae|adde} %0,%0,%0
12789 {ai|addic} %0,%1,%n2\;{cal %0,0(0)|li %0,0}\;{ae|adde} %0,%0,%0"
b19003d8 12790 [(set_attr "length" "12")])
1fd4e8c1 12791
f9562f27
DE
12792(define_insn ""
12793 [(set (match_operand:DI 0 "gpc_reg_operand" "=r,r")
12794 (geu:DI (match_operand:DI 1 "gpc_reg_operand" "r,r")
12795 (match_operand:DI 2 "reg_or_neg_short_operand" "r,P")))]
683bdff7 12796 "TARGET_64BIT"
f9562f27
DE
12797 "@
12798 subfc %0,%2,%1\;li %0,0\;adde %0,%0,%0
12799 addic %0,%1,%n2\;li %0,0\;adde %0,%0,%0"
12800 [(set_attr "length" "12")])
12801
1fd4e8c1 12802(define_insn ""
9ebbca7d 12803 [(set (match_operand:CC 3 "cc_reg_operand" "=x,x,?y,?y")
1fd4e8c1 12804 (compare:CC
9ebbca7d
GK
12805 (geu:SI (match_operand:SI 1 "gpc_reg_operand" "r,r,r,r")
12806 (match_operand:SI 2 "reg_or_neg_short_operand" "r,P,r,P"))
1fd4e8c1 12807 (const_int 0)))
9ebbca7d 12808 (set (match_operand:SI 0 "gpc_reg_operand" "=r,r,r,r")
1fd4e8c1 12809 (geu:SI (match_dup 1) (match_dup 2)))]
683bdff7 12810 "TARGET_32BIT"
1fd4e8c1 12811 "@
ca7f5001 12812 {sf|subfc} %0,%2,%1\;{cal %0,0(0)|li %0,0}\;{ae.|adde.} %0,%0,%0
9ebbca7d
GK
12813 {ai|addic} %0,%1,%n2\;{cal %0,0(0)|li %0,0}\;{ae.|adde.} %0,%0,%0
12814 #
12815 #"
b19003d8 12816 [(set_attr "type" "compare")
9ebbca7d
GK
12817 (set_attr "length" "12,12,16,16")])
12818
12819(define_split
12820 [(set (match_operand:CC 3 "cc_reg_not_cr0_operand" "")
12821 (compare:CC
12822 (geu:SI (match_operand:SI 1 "gpc_reg_operand" "")
12823 (match_operand:SI 2 "reg_or_neg_short_operand" ""))
12824 (const_int 0)))
12825 (set (match_operand:SI 0 "gpc_reg_operand" "")
12826 (geu:SI (match_dup 1) (match_dup 2)))]
683bdff7 12827 "TARGET_32BIT && reload_completed"
9ebbca7d
GK
12828 [(set (match_dup 0)
12829 (geu:SI (match_dup 1) (match_dup 2)))
12830 (set (match_dup 3)
12831 (compare:CC (match_dup 0)
12832 (const_int 0)))]
12833 "")
1fd4e8c1 12834
f9562f27 12835(define_insn ""
9ebbca7d 12836 [(set (match_operand:CC 3 "cc_reg_operand" "=x,x,?y,?y")
f9562f27 12837 (compare:CC
9ebbca7d
GK
12838 (geu:DI (match_operand:DI 1 "gpc_reg_operand" "r,r,r,r")
12839 (match_operand:DI 2 "reg_or_neg_short_operand" "r,P,r,P"))
f9562f27 12840 (const_int 0)))
9ebbca7d 12841 (set (match_operand:DI 0 "gpc_reg_operand" "=r,r,r,r")
f9562f27 12842 (geu:DI (match_dup 1) (match_dup 2)))]
683bdff7 12843 "TARGET_64BIT"
f9562f27
DE
12844 "@
12845 subfc %0,%2,%1\;li %0,0\;adde. %0,%0,%0
9ebbca7d
GK
12846 addic %0,%1,%n2\;li %0,0\;adde. %0,%0,%0
12847 #
12848 #"
f9562f27 12849 [(set_attr "type" "compare")
9ebbca7d
GK
12850 (set_attr "length" "12,12,16,16")])
12851
12852(define_split
12853 [(set (match_operand:CC 3 "cc_reg_not_cr0_operand" "")
12854 (compare:CC
12855 (geu:DI (match_operand:DI 1 "gpc_reg_operand" "")
12856 (match_operand:DI 2 "reg_or_neg_short_operand" ""))
12857 (const_int 0)))
12858 (set (match_operand:DI 0 "gpc_reg_operand" "")
12859 (geu:DI (match_dup 1) (match_dup 2)))]
683bdff7 12860 "TARGET_64BIT && reload_completed"
9ebbca7d
GK
12861 [(set (match_dup 0)
12862 (geu:DI (match_dup 1) (match_dup 2)))
12863 (set (match_dup 3)
12864 (compare:CC (match_dup 0)
12865 (const_int 0)))]
12866 "")
f9562f27 12867
1fd4e8c1 12868(define_insn ""
80103f96 12869 [(set (match_operand:SI 0 "gpc_reg_operand" "=&r,&r")
cd2b37d9 12870 (plus:SI (geu:SI (match_operand:SI 1 "gpc_reg_operand" "r,r")
1fd4e8c1 12871 (match_operand:SI 2 "reg_or_neg_short_operand" "r,P"))
80103f96 12872 (match_operand:SI 3 "gpc_reg_operand" "r,r")))]
683bdff7 12873 "TARGET_32BIT"
1fd4e8c1 12874 "@
80103f96
FS
12875 {sf|subfc} %0,%2,%1\;{aze|addze} %0,%3
12876 {ai|addic} %0,%1,%n2\;{aze|addze} %0,%3"
b19003d8 12877 [(set_attr "length" "8")])
1fd4e8c1
RK
12878
12879(define_insn ""
9ebbca7d 12880 [(set (match_operand:CC 0 "cc_reg_operand" "=x,x,?y,?y")
1fd4e8c1 12881 (compare:CC
9ebbca7d
GK
12882 (plus:SI (geu:SI (match_operand:SI 1 "gpc_reg_operand" "r,r,r,r")
12883 (match_operand:SI 2 "reg_or_neg_short_operand" "r,P,r,P"))
12884 (match_operand:SI 3 "gpc_reg_operand" "r,r,r,r"))
1fd4e8c1 12885 (const_int 0)))
9ebbca7d 12886 (clobber (match_scratch:SI 4 "=&r,&r,&r,&r"))]
683bdff7 12887 "TARGET_32BIT"
1fd4e8c1 12888 "@
ca7f5001 12889 {sf|subfc} %4,%2,%1\;{aze.|addze.} %4,%3
9ebbca7d
GK
12890 {ai|addic} %4,%1,%n2\;{aze.|addze.} %4,%3
12891 #
12892 #"
b19003d8 12893 [(set_attr "type" "compare")
9ebbca7d
GK
12894 (set_attr "length" "8,8,12,12")])
12895
12896(define_split
12897 [(set (match_operand:CC 0 "cc_reg_not_cr0_operand" "")
12898 (compare:CC
12899 (plus:SI (geu:SI (match_operand:SI 1 "gpc_reg_operand" "")
12900 (match_operand:SI 2 "reg_or_neg_short_operand" ""))
12901 (match_operand:SI 3 "gpc_reg_operand" ""))
12902 (const_int 0)))
12903 (clobber (match_scratch:SI 4 ""))]
683bdff7 12904 "TARGET_32BIT && reload_completed"
9ebbca7d
GK
12905 [(set (match_dup 4)
12906 (plus:SI (geu:SI (match_dup 1) (match_dup 2))
12907 (match_dup 3)))
12908 (set (match_dup 0)
12909 (compare:CC (match_dup 4)
12910 (const_int 0)))]
12911 "")
1fd4e8c1
RK
12912
12913(define_insn ""
097657c3 12914 [(set (match_operand:CC 4 "cc_reg_operand" "=x,x,?y,?y")
1fd4e8c1 12915 (compare:CC
9ebbca7d
GK
12916 (plus:SI (geu:SI (match_operand:SI 1 "gpc_reg_operand" "r,r,r,r")
12917 (match_operand:SI 2 "reg_or_neg_short_operand" "r,P,r,P"))
12918 (match_operand:SI 3 "gpc_reg_operand" "r,r,r,r"))
1fd4e8c1 12919 (const_int 0)))
097657c3
AM
12920 (set (match_operand:SI 0 "gpc_reg_operand" "=&r,&r,&r,&r")
12921 (plus:SI (geu:SI (match_dup 1) (match_dup 2)) (match_dup 3)))]
683bdff7 12922 "TARGET_32BIT"
1fd4e8c1 12923 "@
097657c3
AM
12924 {sf|subfc} %0,%2,%1\;{aze.|addze.} %0,%3
12925 {ai|addic} %0,%1,%n2\;{aze.|addze.} %0,%3
9ebbca7d
GK
12926 #
12927 #"
b19003d8 12928 [(set_attr "type" "compare")
9ebbca7d
GK
12929 (set_attr "length" "8,8,12,12")])
12930
12931(define_split
097657c3 12932 [(set (match_operand:CC 4 "cc_reg_not_cr0_operand" "")
9ebbca7d
GK
12933 (compare:CC
12934 (plus:SI (geu:SI (match_operand:SI 1 "gpc_reg_operand" "")
12935 (match_operand:SI 2 "reg_or_neg_short_operand" ""))
12936 (match_operand:SI 3 "gpc_reg_operand" ""))
12937 (const_int 0)))
12938 (set (match_operand:SI 0 "gpc_reg_operand" "")
097657c3 12939 (plus:SI (geu:SI (match_dup 1) (match_dup 2)) (match_dup 3)))]
683bdff7 12940 "TARGET_32BIT && reload_completed"
097657c3 12941 [(set (match_dup 0)
9ebbca7d 12942 (plus:SI (geu:SI (match_dup 1) (match_dup 2)) (match_dup 3)))
097657c3 12943 (set (match_dup 4)
9ebbca7d
GK
12944 (compare:CC (match_dup 0)
12945 (const_int 0)))]
12946 "")
1fd4e8c1
RK
12947
12948(define_insn ""
cd2b37d9
RK
12949 [(set (match_operand:SI 0 "gpc_reg_operand" "=r,r")
12950 (neg:SI (geu:SI (match_operand:SI 1 "gpc_reg_operand" "r,r")
1fd4e8c1 12951 (match_operand:SI 2 "reg_or_short_operand" "r,I"))))]
683bdff7 12952 "TARGET_32BIT"
1fd4e8c1 12953 "@
ca7f5001 12954 {sf|subfc} %0,%2,%1\;{sfe|subfe} %0,%0,%0\;nand %0,%0,%0
8106dc08 12955 {sfi|subfic} %0,%1,-1\;{a%I2|add%I2c} %0,%0,%2\;{sfe|subfe} %0,%0,%0"
b19003d8 12956 [(set_attr "length" "12")])
1fd4e8c1
RK
12957
12958(define_insn ""
097657c3 12959 [(set (match_operand:SI 0 "gpc_reg_operand" "=&r,&r")
1fd4e8c1 12960 (and:SI (neg:SI
cd2b37d9 12961 (geu:SI (match_operand:SI 1 "gpc_reg_operand" "r,r")
1fd4e8c1 12962 (match_operand:SI 2 "reg_or_neg_short_operand" "r,P")))
097657c3 12963 (match_operand:SI 3 "gpc_reg_operand" "r,r")))]
683bdff7 12964 "TARGET_32BIT"
1fd4e8c1 12965 "@
097657c3
AM
12966 {sf|subfc} %0,%2,%1\;{sfe|subfe} %0,%0,%0\;andc %0,%3,%0
12967 {ai|addic} %0,%1,%n2\;{sfe|subfe} %0,%0,%0\;andc %0,%3,%0"
b19003d8 12968 [(set_attr "length" "12")])
1fd4e8c1
RK
12969
12970(define_insn ""
9ebbca7d 12971 [(set (match_operand:CC 0 "cc_reg_operand" "=x,x,?y,?y")
1fd4e8c1
RK
12972 (compare:CC
12973 (and:SI (neg:SI
9ebbca7d
GK
12974 (geu:SI (match_operand:SI 1 "gpc_reg_operand" "r,r,r,r")
12975 (match_operand:SI 2 "reg_or_neg_short_operand" "r,P,r,P")))
12976 (match_operand:SI 3 "gpc_reg_operand" "r,r,r,r"))
1fd4e8c1 12977 (const_int 0)))
9ebbca7d 12978 (clobber (match_scratch:SI 4 "=&r,&r,&r,&r"))]
683bdff7 12979 "TARGET_32BIT"
1fd4e8c1 12980 "@
ca7f5001 12981 {sf|subfc} %4,%2,%1\;{sfe|subfe} %4,%4,%4\;andc. %4,%3,%4
9ebbca7d
GK
12982 {ai|addic} %4,%1,%n2\;{sfe|subfe} %4,%4,%4\;andc. %4,%3,%4
12983 #
12984 #"
b19003d8 12985 [(set_attr "type" "compare")
9ebbca7d
GK
12986 (set_attr "length" "12,12,16,16")])
12987
12988(define_split
12989 [(set (match_operand:CC 0 "cc_reg_not_cr0_operand" "")
12990 (compare:CC
12991 (and:SI (neg:SI
12992 (geu:SI (match_operand:SI 1 "gpc_reg_operand" "")
12993 (match_operand:SI 2 "reg_or_neg_short_operand" "")))
12994 (match_operand:SI 3 "gpc_reg_operand" ""))
12995 (const_int 0)))
12996 (clobber (match_scratch:SI 4 ""))]
683bdff7 12997 "TARGET_32BIT && reload_completed"
9ebbca7d 12998 [(set (match_dup 4)
097657c3
AM
12999 (and:SI (neg:SI (geu:SI (match_dup 1) (match_dup 2)))
13000 (match_dup 3)))
9ebbca7d
GK
13001 (set (match_dup 0)
13002 (compare:CC (match_dup 4)
13003 (const_int 0)))]
13004 "")
1fd4e8c1
RK
13005
13006(define_insn ""
097657c3 13007 [(set (match_operand:CC 4 "cc_reg_operand" "=x,x,?y,?y")
1fd4e8c1
RK
13008 (compare:CC
13009 (and:SI (neg:SI
9ebbca7d
GK
13010 (geu:SI (match_operand:SI 1 "gpc_reg_operand" "r,r,r,r")
13011 (match_operand:SI 2 "reg_or_neg_short_operand" "r,P,r,P")))
13012 (match_operand:SI 3 "gpc_reg_operand" "r,r,r,r"))
1fd4e8c1 13013 (const_int 0)))
097657c3
AM
13014 (set (match_operand:SI 0 "gpc_reg_operand" "=&r,&r,&r,&r")
13015 (and:SI (neg:SI (geu:SI (match_dup 1) (match_dup 2))) (match_dup 3)))]
683bdff7 13016 "TARGET_32BIT"
1fd4e8c1 13017 "@
097657c3
AM
13018 {sf|subfc} %0,%2,%1\;{sfe|subfe} %0,%0,%0\;andc. %0,%3,%0
13019 {ai|addic} %0,%1,%n2\;{sfe|subfe} %0,%0,%0\;andc. %0,%3,%0
9ebbca7d
GK
13020 #
13021 #"
b19003d8 13022 [(set_attr "type" "compare")
9ebbca7d
GK
13023 (set_attr "length" "12,12,16,16")])
13024
13025(define_split
097657c3 13026 [(set (match_operand:CC 4 "cc_reg_not_cr0_operand" "")
9ebbca7d
GK
13027 (compare:CC
13028 (and:SI (neg:SI
13029 (geu:SI (match_operand:SI 1 "gpc_reg_operand" "")
13030 (match_operand:SI 2 "reg_or_neg_short_operand" "")))
13031 (match_operand:SI 3 "gpc_reg_operand" ""))
13032 (const_int 0)))
13033 (set (match_operand:SI 0 "gpc_reg_operand" "")
097657c3 13034 (and:SI (neg:SI (geu:SI (match_dup 1) (match_dup 2))) (match_dup 3)))]
683bdff7 13035 "TARGET_32BIT && reload_completed"
097657c3 13036 [(set (match_dup 0)
9ebbca7d 13037 (and:SI (neg:SI (geu:SI (match_dup 1) (match_dup 2))) (match_dup 3)))
097657c3 13038 (set (match_dup 4)
9ebbca7d
GK
13039 (compare:CC (match_dup 0)
13040 (const_int 0)))]
13041 "")
1fd4e8c1
RK
13042
13043(define_insn ""
cd2b37d9
RK
13044 [(set (match_operand:SI 0 "gpc_reg_operand" "=r")
13045 (gt:SI (match_operand:SI 1 "gpc_reg_operand" "r")
1fd4e8c1 13046 (const_int 0)))]
683bdff7 13047 "TARGET_32BIT"
ca7f5001 13048 "{sfi|subfic} %0,%1,0\;{ame|addme} %0,%0\;{sri|srwi} %0,%0,31"
b19003d8 13049 [(set_attr "length" "12")])
1fd4e8c1 13050
f9562f27
DE
13051(define_insn ""
13052 [(set (match_operand:DI 0 "gpc_reg_operand" "=r")
13053 (gt:DI (match_operand:DI 1 "gpc_reg_operand" "r")
13054 (const_int 0)))]
683bdff7 13055 "TARGET_64BIT"
f9562f27
DE
13056 "subfic %0,%1,0\;addme %0,%0\;srdi %0,%0,63"
13057 [(set_attr "length" "12")])
13058
1fd4e8c1 13059(define_insn ""
9ebbca7d 13060 [(set (match_operand:CC 2 "cc_reg_operand" "=x,?y")
1fd4e8c1 13061 (compare:CC
9ebbca7d 13062 (gt:SI (match_operand:SI 1 "gpc_reg_operand" "r,r")
1fd4e8c1
RK
13063 (const_int 0))
13064 (const_int 0)))
9ebbca7d 13065 (set (match_operand:SI 0 "gpc_reg_operand" "=r,r")
1fd4e8c1 13066 (gt:SI (match_dup 1) (const_int 0)))]
683bdff7 13067 "TARGET_32BIT"
9ebbca7d
GK
13068 "@
13069 {sfi|subfic} %0,%1,0\;{ame|addme} %0,%0\;{sri.|srwi.} %0,%0,31
13070 #"
29ae5b89 13071 [(set_attr "type" "delayed_compare")
9ebbca7d
GK
13072 (set_attr "length" "12,16")])
13073
13074(define_split
13075 [(set (match_operand:CC 2 "cc_reg_not_cr0_operand" "")
13076 (compare:CC
13077 (gt:SI (match_operand:SI 1 "gpc_reg_operand" "")
13078 (const_int 0))
13079 (const_int 0)))
13080 (set (match_operand:SI 0 "gpc_reg_operand" "")
13081 (gt:SI (match_dup 1) (const_int 0)))]
683bdff7 13082 "TARGET_32BIT && reload_completed"
9ebbca7d
GK
13083 [(set (match_dup 0)
13084 (gt:SI (match_dup 1) (const_int 0)))
13085 (set (match_dup 2)
13086 (compare:CC (match_dup 0)
13087 (const_int 0)))]
13088 "")
1fd4e8c1 13089
f9562f27 13090(define_insn ""
9ebbca7d 13091 [(set (match_operand:CC 2 "cc_reg_operand" "=x,?y")
f9562f27 13092 (compare:CC
9ebbca7d 13093 (gt:DI (match_operand:DI 1 "gpc_reg_operand" "r,r")
f9562f27
DE
13094 (const_int 0))
13095 (const_int 0)))
9ebbca7d 13096 (set (match_operand:DI 0 "gpc_reg_operand" "=r,r")
f9562f27 13097 (gt:DI (match_dup 1) (const_int 0)))]
683bdff7 13098 "TARGET_64BIT"
9ebbca7d
GK
13099 "@
13100 subfic %0,%1,0\;addme %0,%0\;srdi. %0,%0,63
13101 #"
f9562f27 13102 [(set_attr "type" "delayed_compare")
9ebbca7d
GK
13103 (set_attr "length" "12,16")])
13104
13105(define_split
13106 [(set (match_operand:CC 2 "cc_reg_not_cr0_operand" "")
13107 (compare:CC
13108 (gt:DI (match_operand:DI 1 "gpc_reg_operand" "")
13109 (const_int 0))
13110 (const_int 0)))
13111 (set (match_operand:DI 0 "gpc_reg_operand" "")
13112 (gt:DI (match_dup 1) (const_int 0)))]
683bdff7 13113 "TARGET_64BIT && reload_completed"
9ebbca7d
GK
13114 [(set (match_dup 0)
13115 (gt:DI (match_dup 1) (const_int 0)))
13116 (set (match_dup 2)
13117 (compare:CC (match_dup 0)
13118 (const_int 0)))]
13119 "")
f9562f27 13120
1fd4e8c1 13121(define_insn ""
cd2b37d9
RK
13122 [(set (match_operand:SI 0 "gpc_reg_operand" "=r")
13123 (gt:SI (match_operand:SI 1 "gpc_reg_operand" "r")
1fd4e8c1 13124 (match_operand:SI 2 "reg_or_short_operand" "r")))]
ca7f5001
RK
13125 "TARGET_POWER"
13126 "doz %0,%2,%1\;nabs %0,%0\;{sri|srwi} %0,%0,31"
b19003d8 13127 [(set_attr "length" "12")])
1fd4e8c1
RK
13128
13129(define_insn ""
9ebbca7d 13130 [(set (match_operand:CC 3 "cc_reg_operand" "=x,?y")
1fd4e8c1 13131 (compare:CC
9ebbca7d
GK
13132 (gt:SI (match_operand:SI 1 "gpc_reg_operand" "r,r")
13133 (match_operand:SI 2 "reg_or_short_operand" "r,r"))
1fd4e8c1 13134 (const_int 0)))
9ebbca7d 13135 (set (match_operand:SI 0 "gpc_reg_operand" "=r,r")
1fd4e8c1 13136 (gt:SI (match_dup 1) (match_dup 2)))]
ca7f5001 13137 "TARGET_POWER"
9ebbca7d
GK
13138 "@
13139 doz %0,%2,%1\;nabs %0,%0\;{sri.|srwi.} %0,%0,31
13140 #"
29ae5b89 13141 [(set_attr "type" "delayed_compare")
9ebbca7d
GK
13142 (set_attr "length" "12,16")])
13143
13144(define_split
13145 [(set (match_operand:CC 3 "cc_reg_not_cr0_operand" "")
13146 (compare:CC
13147 (gt:SI (match_operand:SI 1 "gpc_reg_operand" "")
13148 (match_operand:SI 2 "reg_or_short_operand" ""))
13149 (const_int 0)))
13150 (set (match_operand:SI 0 "gpc_reg_operand" "")
13151 (gt:SI (match_dup 1) (match_dup 2)))]
13152 "TARGET_POWER && reload_completed"
13153 [(set (match_dup 0)
13154 (gt:SI (match_dup 1) (match_dup 2)))
13155 (set (match_dup 3)
13156 (compare:CC (match_dup 0)
13157 (const_int 0)))]
13158 "")
1fd4e8c1
RK
13159
13160(define_insn ""
80103f96 13161 [(set (match_operand:SI 0 "gpc_reg_operand" "=&r")
cd2b37d9 13162 (plus:SI (gt:SI (match_operand:SI 1 "gpc_reg_operand" "r")
1fd4e8c1 13163 (const_int 0))
80103f96 13164 (match_operand:SI 2 "gpc_reg_operand" "r")))]
683bdff7 13165 "TARGET_32BIT"
80103f96 13166 "{a|addc} %0,%1,%1\;{sfe|subfe} %0,%1,%0\;{aze|addze} %0,%2"
b19003d8 13167 [(set_attr "length" "12")])
1fd4e8c1 13168
f9562f27 13169(define_insn ""
097657c3 13170 [(set (match_operand:DI 0 "gpc_reg_operand" "=&r")
f9562f27
DE
13171 (plus:DI (gt:DI (match_operand:DI 1 "gpc_reg_operand" "r")
13172 (const_int 0))
097657c3 13173 (match_operand:DI 2 "gpc_reg_operand" "r")))]
683bdff7 13174 "TARGET_64BIT"
097657c3 13175 "addc %0,%1,%1\;subfe %0,%1,%0\;addze %0,%2"
f9562f27
DE
13176 [(set_attr "length" "12")])
13177
1fd4e8c1 13178(define_insn ""
9ebbca7d 13179 [(set (match_operand:CC 0 "cc_reg_operand" "=x,?y")
1fd4e8c1 13180 (compare:CC
9ebbca7d 13181 (plus:SI (gt:SI (match_operand:SI 1 "gpc_reg_operand" "r,r")
1fd4e8c1 13182 (const_int 0))
9ebbca7d 13183 (match_operand:SI 2 "gpc_reg_operand" "r,r"))
1fd4e8c1 13184 (const_int 0)))
9ebbca7d 13185 (clobber (match_scratch:SI 3 "=&r,&r"))]
683bdff7 13186 "TARGET_32BIT"
9ebbca7d
GK
13187 "@
13188 {a|addc} %3,%1,%1\;{sfe|subfe} %3,%1,%3\;{aze.|addze.} %3,%2
13189 #"
b19003d8 13190 [(set_attr "type" "compare")
9ebbca7d
GK
13191 (set_attr "length" "12,16")])
13192
13193(define_split
13194 [(set (match_operand:CC 0 "cc_reg_not_cr0_operand" "")
13195 (compare:CC
13196 (plus:SI (gt:SI (match_operand:SI 1 "gpc_reg_operand" "")
13197 (const_int 0))
13198 (match_operand:SI 2 "gpc_reg_operand" ""))
13199 (const_int 0)))
13200 (clobber (match_scratch:SI 3 ""))]
683bdff7 13201 "TARGET_32BIT && reload_completed"
9ebbca7d
GK
13202 [(set (match_dup 3)
13203 (plus:SI (gt:SI (match_dup 1) (const_int 0))
13204 (match_dup 2)))
13205 (set (match_dup 0)
13206 (compare:CC (match_dup 3)
13207 (const_int 0)))]
13208 "")
1fd4e8c1 13209
f9562f27 13210(define_insn ""
9ebbca7d 13211 [(set (match_operand:CC 0 "cc_reg_operand" "=x,?y")
f9562f27 13212 (compare:CC
9ebbca7d 13213 (plus:DI (gt:DI (match_operand:DI 1 "gpc_reg_operand" "r,r")
f9562f27 13214 (const_int 0))
9ebbca7d 13215 (match_operand:DI 2 "gpc_reg_operand" "r,r"))
f9562f27 13216 (const_int 0)))
9ebbca7d 13217 (clobber (match_scratch:DI 3 "=&r,&r"))]
683bdff7 13218 "TARGET_64BIT"
9ebbca7d
GK
13219 "@
13220 addc %3,%1,%1\;subfe %3,%1,%3\;addze. %3,%2
13221 #"
f9562f27 13222 [(set_attr "type" "compare")
9ebbca7d
GK
13223 (set_attr "length" "12,16")])
13224
13225(define_split
13226 [(set (match_operand:CC 0 "cc_reg_not_cr0_operand" "")
13227 (compare:CC
13228 (plus:DI (gt:DI (match_operand:DI 1 "gpc_reg_operand" "")
13229 (const_int 0))
13230 (match_operand:DI 2 "gpc_reg_operand" ""))
13231 (const_int 0)))
13232 (clobber (match_scratch:DI 3 ""))]
683bdff7 13233 "TARGET_64BIT && reload_completed"
9ebbca7d
GK
13234 [(set (match_dup 3)
13235 (plus:DI (gt:DI (match_dup 1) (const_int 0))
097657c3 13236 (match_dup 2)))
9ebbca7d
GK
13237 (set (match_dup 0)
13238 (compare:CC (match_dup 3)
13239 (const_int 0)))]
13240 "")
f9562f27 13241
1fd4e8c1 13242(define_insn ""
097657c3 13243 [(set (match_operand:CC 3 "cc_reg_operand" "=x,?y")
9ebbca7d
GK
13244 (compare:CC
13245 (plus:SI (gt:SI (match_operand:SI 1 "gpc_reg_operand" "r,r")
13246 (const_int 0))
13247 (match_operand:SI 2 "gpc_reg_operand" "r,r"))
13248 (const_int 0)))
097657c3
AM
13249 (set (match_operand:SI 0 "gpc_reg_operand" "=&r,&r")
13250 (plus:SI (gt:SI (match_dup 1) (const_int 0)) (match_dup 2)))]
683bdff7 13251 "TARGET_32BIT"
9ebbca7d 13252 "@
097657c3 13253 {a|addc} %0,%1,%1\;{sfe|subfe} %0,%1,%0\;{aze.|addze.} %0,%2
9ebbca7d
GK
13254 #"
13255 [(set_attr "type" "compare")
13256 (set_attr "length" "12,16")])
13257
13258(define_split
097657c3 13259 [(set (match_operand:CC 3 "cc_reg_not_cr0_operand" "")
1fd4e8c1 13260 (compare:CC
9ebbca7d 13261 (plus:SI (gt:SI (match_operand:SI 1 "gpc_reg_operand" "")
1fd4e8c1 13262 (const_int 0))
9ebbca7d 13263 (match_operand:SI 2 "gpc_reg_operand" ""))
1fd4e8c1 13264 (const_int 0)))
9ebbca7d 13265 (set (match_operand:SI 0 "gpc_reg_operand" "")
097657c3 13266 (plus:SI (gt:SI (match_dup 1) (const_int 0)) (match_dup 2)))]
683bdff7 13267 "TARGET_32BIT && reload_completed"
097657c3 13268 [(set (match_dup 0)
9ebbca7d 13269 (plus:SI (gt:SI (match_dup 1) (const_int 0)) (match_dup 2)))
097657c3 13270 (set (match_dup 3)
9ebbca7d
GK
13271 (compare:CC (match_dup 0)
13272 (const_int 0)))]
13273 "")
1fd4e8c1 13274
f9562f27 13275(define_insn ""
097657c3 13276 [(set (match_operand:CC 3 "cc_reg_operand" "=x,?y")
f9562f27 13277 (compare:CC
9ebbca7d 13278 (plus:DI (gt:DI (match_operand:DI 1 "gpc_reg_operand" "r,r")
f9562f27 13279 (const_int 0))
9ebbca7d 13280 (match_operand:DI 2 "gpc_reg_operand" "r,r"))
f9562f27 13281 (const_int 0)))
097657c3
AM
13282 (set (match_operand:DI 0 "gpc_reg_operand" "=&r,&r")
13283 (plus:DI (gt:DI (match_dup 1) (const_int 0)) (match_dup 2)))]
683bdff7 13284 "TARGET_64BIT"
9ebbca7d 13285 "@
097657c3 13286 addc %0,%1,%1\;subfe %0,%1,%0\;addze. %0,%2
9ebbca7d 13287 #"
f9562f27 13288 [(set_attr "type" "compare")
9ebbca7d
GK
13289 (set_attr "length" "12,16")])
13290
13291(define_split
097657c3 13292 [(set (match_operand:CC 3 "cc_reg_not_cr0_operand" "")
9ebbca7d
GK
13293 (compare:CC
13294 (plus:DI (gt:DI (match_operand:DI 1 "gpc_reg_operand" "")
13295 (const_int 0))
13296 (match_operand:DI 2 "gpc_reg_operand" ""))
13297 (const_int 0)))
13298 (set (match_operand:DI 0 "gpc_reg_operand" "")
097657c3 13299 (plus:DI (gt:DI (match_dup 1) (const_int 0)) (match_dup 2)))]
683bdff7 13300 "TARGET_64BIT && reload_completed"
097657c3 13301 [(set (match_dup 0)
9ebbca7d 13302 (plus:DI (gt:DI (match_dup 1) (const_int 0)) (match_dup 2)))
097657c3 13303 (set (match_dup 3)
9ebbca7d
GK
13304 (compare:CC (match_dup 0)
13305 (const_int 0)))]
13306 "")
f9562f27 13307
1fd4e8c1 13308(define_insn ""
097657c3 13309 [(set (match_operand:SI 0 "gpc_reg_operand" "=&r")
cd2b37d9 13310 (plus:SI (gt:SI (match_operand:SI 1 "gpc_reg_operand" "r")
1fd4e8c1 13311 (match_operand:SI 2 "reg_or_short_operand" "r"))
097657c3 13312 (match_operand:SI 3 "gpc_reg_operand" "r")))]
ca7f5001 13313 "TARGET_POWER"
097657c3 13314 "doz %0,%2,%1\;{ai|addic} %0,%0,-1\;{aze|addze} %0,%3"
b19003d8 13315 [(set_attr "length" "12")])
1fd4e8c1
RK
13316
13317(define_insn ""
9ebbca7d 13318 [(set (match_operand:CC 0 "cc_reg_operand" "=x,?y")
1fd4e8c1 13319 (compare:CC
9ebbca7d
GK
13320 (plus:SI (gt:SI (match_operand:SI 1 "gpc_reg_operand" "r,r")
13321 (match_operand:SI 2 "reg_or_short_operand" "r,r"))
13322 (match_operand:SI 3 "gpc_reg_operand" "r,r"))
1fd4e8c1 13323 (const_int 0)))
9ebbca7d 13324 (clobber (match_scratch:SI 4 "=&r,&r"))]
ca7f5001 13325 "TARGET_POWER"
9ebbca7d
GK
13326 "@
13327 doz %4,%2,%1\;{ai|addic} %4,%4,-1\;{aze.|addze.} %4,%3
13328 #"
b19003d8 13329 [(set_attr "type" "compare")
9ebbca7d
GK
13330 (set_attr "length" "12,16")])
13331
13332(define_split
13333 [(set (match_operand:CC 0 "cc_reg_not_cr0_operand" "")
13334 (compare:CC
13335 (plus:SI (gt:SI (match_operand:SI 1 "gpc_reg_operand" "")
13336 (match_operand:SI 2 "reg_or_short_operand" ""))
13337 (match_operand:SI 3 "gpc_reg_operand" ""))
13338 (const_int 0)))
13339 (clobber (match_scratch:SI 4 ""))]
13340 "TARGET_POWER && reload_completed"
13341 [(set (match_dup 4)
097657c3 13342 (plus:SI (gt:SI (match_dup 1) (match_dup 2)) (match_dup 3)))
9ebbca7d
GK
13343 (set (match_dup 0)
13344 (compare:CC (match_dup 4)
13345 (const_int 0)))]
13346 "")
1fd4e8c1
RK
13347
13348(define_insn ""
097657c3 13349 [(set (match_operand:CC 4 "cc_reg_operand" "=x,?y")
1fd4e8c1 13350 (compare:CC
9ebbca7d
GK
13351 (plus:SI (gt:SI (match_operand:SI 1 "gpc_reg_operand" "r,r")
13352 (match_operand:SI 2 "reg_or_short_operand" "r,r"))
13353 (match_operand:SI 3 "gpc_reg_operand" "r,r"))
1fd4e8c1 13354 (const_int 0)))
097657c3
AM
13355 (set (match_operand:SI 0 "gpc_reg_operand" "=&r,&r")
13356 (plus:SI (gt:SI (match_dup 1) (match_dup 2)) (match_dup 3)))]
ca7f5001 13357 "TARGET_POWER"
9ebbca7d 13358 "@
097657c3 13359 doz %0,%2,%1\;{ai|addic} %0,%0,-1\;{aze.|addze.} %0,%3
9ebbca7d 13360 #"
b19003d8 13361 [(set_attr "type" "compare")
9ebbca7d
GK
13362 (set_attr "length" "12,16")])
13363
13364(define_split
097657c3 13365 [(set (match_operand:CC 4 "cc_reg_not_cr0_operand" "")
9ebbca7d
GK
13366 (compare:CC
13367 (plus:SI (gt:SI (match_operand:SI 1 "gpc_reg_operand" "")
13368 (match_operand:SI 2 "reg_or_short_operand" ""))
13369 (match_operand:SI 3 "gpc_reg_operand" ""))
13370 (const_int 0)))
13371 (set (match_operand:SI 0 "gpc_reg_operand" "")
097657c3 13372 (plus:SI (gt:SI (match_dup 1) (match_dup 2)) (match_dup 3)))]
9ebbca7d 13373 "TARGET_POWER && reload_completed"
097657c3 13374 [(set (match_dup 0)
9ebbca7d 13375 (plus:SI (gt:SI (match_dup 1) (match_dup 2)) (match_dup 3)))
097657c3 13376 (set (match_dup 4)
9ebbca7d
GK
13377 (compare:CC (match_dup 0)
13378 (const_int 0)))]
13379 "")
1fd4e8c1
RK
13380
13381(define_insn ""
cd2b37d9
RK
13382 [(set (match_operand:SI 0 "gpc_reg_operand" "=r")
13383 (neg:SI (gt:SI (match_operand:SI 1 "gpc_reg_operand" "r")
1fd4e8c1 13384 (const_int 0))))]
683bdff7 13385 "TARGET_32BIT"
ca7f5001 13386 "{sfi|subfic} %0,%1,0\;{ame|addme} %0,%0\;{srai|srawi} %0,%0,31"
b19003d8 13387 [(set_attr "length" "12")])
1fd4e8c1 13388
f9562f27
DE
13389(define_insn ""
13390 [(set (match_operand:DI 0 "gpc_reg_operand" "=r")
13391 (neg:DI (gt:DI (match_operand:DI 1 "gpc_reg_operand" "r")
13392 (const_int 0))))]
683bdff7 13393 "TARGET_64BIT"
8377288b 13394 "subfic %0,%1,0\;addme %0,%0\;sradi %0,%0,63"
f9562f27
DE
13395 [(set_attr "length" "12")])
13396
1fd4e8c1 13397(define_insn ""
cd2b37d9
RK
13398 [(set (match_operand:SI 0 "gpc_reg_operand" "=r")
13399 (neg:SI (gt:SI (match_operand:SI 1 "gpc_reg_operand" "r")
1fd4e8c1 13400 (match_operand:SI 2 "reg_or_short_operand" "r"))))]
ca7f5001
RK
13401 "TARGET_POWER"
13402 "doz %0,%2,%1\;nabs %0,%0\;{srai|srawi} %0,%0,31"
b19003d8 13403 [(set_attr "length" "12")])
1fd4e8c1
RK
13404
13405(define_insn ""
cd2b37d9
RK
13406 [(set (match_operand:SI 0 "gpc_reg_operand" "=r")
13407 (gtu:SI (match_operand:SI 1 "gpc_reg_operand" "r")
1fd4e8c1 13408 (match_operand:SI 2 "reg_or_short_operand" "rI")))]
683bdff7 13409 "TARGET_32BIT"
ca7f5001 13410 "{sf%I2|subf%I2c} %0,%1,%2\;{sfe|subfe} %0,%0,%0\;neg %0,%0"
b19003d8 13411 [(set_attr "length" "12")])
1fd4e8c1 13412
f9562f27
DE
13413(define_insn ""
13414 [(set (match_operand:DI 0 "gpc_reg_operand" "=r")
13415 (gtu:DI (match_operand:DI 1 "gpc_reg_operand" "r")
13416 (match_operand:DI 2 "reg_or_short_operand" "rI")))]
683bdff7 13417 "TARGET_64BIT"
f9562f27
DE
13418 "subf%I2c %0,%1,%2\;subfe %0,%0,%0\;neg %0,%0"
13419 [(set_attr "length" "12")])
13420
1fd4e8c1 13421(define_insn ""
9ebbca7d 13422 [(set (match_operand:CC 3 "cc_reg_operand" "=x,?y")
1fd4e8c1 13423 (compare:CC
9ebbca7d
GK
13424 (gtu:SI (match_operand:SI 1 "gpc_reg_operand" "r,r")
13425 (match_operand:SI 2 "reg_or_short_operand" "rI,rI"))
1fd4e8c1 13426 (const_int 0)))
9ebbca7d 13427 (set (match_operand:SI 0 "gpc_reg_operand" "=r,r")
1fd4e8c1 13428 (gtu:SI (match_dup 1) (match_dup 2)))]
683bdff7 13429 "TARGET_32BIT"
9ebbca7d
GK
13430 "@
13431 {sf%I2|subf%I2c} %0,%1,%2\;{sfe|subfe} %0,%0,%0\;neg. %0,%0
13432 #"
b19003d8 13433 [(set_attr "type" "compare")
9ebbca7d
GK
13434 (set_attr "length" "12,16")])
13435
13436(define_split
13437 [(set (match_operand:CC 3 "cc_reg_not_cr0_operand" "")
13438 (compare:CC
13439 (gtu:SI (match_operand:SI 1 "gpc_reg_operand" "")
13440 (match_operand:SI 2 "reg_or_short_operand" ""))
13441 (const_int 0)))
13442 (set (match_operand:SI 0 "gpc_reg_operand" "")
13443 (gtu:SI (match_dup 1) (match_dup 2)))]
683bdff7 13444 "TARGET_32BIT && reload_completed"
9ebbca7d
GK
13445 [(set (match_dup 0)
13446 (gtu:SI (match_dup 1) (match_dup 2)))
13447 (set (match_dup 3)
13448 (compare:CC (match_dup 0)
13449 (const_int 0)))]
13450 "")
1fd4e8c1 13451
f9562f27 13452(define_insn ""
9ebbca7d 13453 [(set (match_operand:CC 3 "cc_reg_operand" "=x,?y")
f9562f27 13454 (compare:CC
9ebbca7d
GK
13455 (gtu:DI (match_operand:DI 1 "gpc_reg_operand" "r,r")
13456 (match_operand:DI 2 "reg_or_short_operand" "rI,rI"))
f9562f27 13457 (const_int 0)))
9ebbca7d 13458 (set (match_operand:DI 0 "gpc_reg_operand" "=r,r")
f9562f27 13459 (gtu:DI (match_dup 1) (match_dup 2)))]
683bdff7 13460 "TARGET_64BIT"
9ebbca7d
GK
13461 "@
13462 subf%I2c %0,%1,%2\;subfe %0,%0,%0\;neg. %0,%0
13463 #"
f9562f27 13464 [(set_attr "type" "compare")
9ebbca7d
GK
13465 (set_attr "length" "12,16")])
13466
13467(define_split
13468 [(set (match_operand:CC 3 "cc_reg_not_cr0_operand" "")
13469 (compare:CC
13470 (gtu:DI (match_operand:DI 1 "gpc_reg_operand" "")
13471 (match_operand:DI 2 "reg_or_short_operand" ""))
13472 (const_int 0)))
13473 (set (match_operand:DI 0 "gpc_reg_operand" "")
13474 (gtu:DI (match_dup 1) (match_dup 2)))]
683bdff7 13475 "TARGET_64BIT && reload_completed"
9ebbca7d
GK
13476 [(set (match_dup 0)
13477 (gtu:DI (match_dup 1) (match_dup 2)))
13478 (set (match_dup 3)
13479 (compare:CC (match_dup 0)
13480 (const_int 0)))]
13481 "")
f9562f27 13482
1fd4e8c1 13483(define_insn ""
80103f96 13484 [(set (match_operand:SI 0 "gpc_reg_operand" "=&r,&r")
19378cf8
MM
13485 (plus:SI (gtu:SI (match_operand:SI 1 "gpc_reg_operand" "r,r")
13486 (match_operand:SI 2 "reg_or_short_operand" "I,rI"))
80103f96 13487 (match_operand:SI 3 "reg_or_short_operand" "r,rI")))]
683bdff7 13488 "TARGET_32BIT"
00751805 13489 "@
80103f96
FS
13490 {ai|addic} %0,%1,%k2\;{aze|addze} %0,%3
13491 {sf%I2|subf%I2c} %0,%1,%2\;{sfe|subfe} %0,%0,%0\;{sf%I3|subf%I3c} %0,%0,%3"
19378cf8 13492 [(set_attr "length" "8,12")])
1fd4e8c1 13493
f9562f27 13494(define_insn ""
097657c3 13495 [(set (match_operand:DI 0 "gpc_reg_operand" "=&r,&r")
f9562f27
DE
13496 (plus:DI (gtu:DI (match_operand:DI 1 "gpc_reg_operand" "r,r")
13497 (match_operand:DI 2 "reg_or_short_operand" "I,rI"))
097657c3 13498 (match_operand:DI 3 "reg_or_short_operand" "r,rI")))]
683bdff7 13499 "TARGET_64BIT"
f9562f27 13500 "@
097657c3
AM
13501 addic %0,%1,%k2\;addze %0,%3
13502 subf%I2c %0,%1,%2\;subfe %0,%0,%0\;subf%I3c %0,%0,%3"
f9562f27
DE
13503 [(set_attr "length" "8,12")])
13504
1fd4e8c1 13505(define_insn ""
9ebbca7d 13506 [(set (match_operand:CC 0 "cc_reg_operand" "=x,x,?y,?y")
1fd4e8c1 13507 (compare:CC
9ebbca7d
GK
13508 (plus:SI (gtu:SI (match_operand:SI 1 "gpc_reg_operand" "r,r,r,r")
13509 (match_operand:SI 2 "reg_or_short_operand" "I,r,I,r"))
13510 (match_operand:SI 3 "gpc_reg_operand" "r,r,r,r"))
1fd4e8c1 13511 (const_int 0)))
9ebbca7d 13512 (clobber (match_scratch:SI 4 "=&r,&r,&r,&r"))]
683bdff7 13513 "TARGET_32BIT"
00751805 13514 "@
19378cf8 13515 {ai|addic} %4,%1,%k2\;{aze.|addze.} %4,%3
9ebbca7d
GK
13516 {sf%I2|subf%I2c} %4,%1,%2\;{sfe|subfe} %4,%4,%4\;{sf.|subfc.} %4,%4,%3
13517 #
13518 #"
b19003d8 13519 [(set_attr "type" "compare")
9ebbca7d
GK
13520 (set_attr "length" "8,12,12,16")])
13521
13522(define_split
13523 [(set (match_operand:CC 0 "cc_reg_not_cr0_operand" "")
13524 (compare:CC
13525 (plus:SI (gtu:SI (match_operand:SI 1 "gpc_reg_operand" "")
13526 (match_operand:SI 2 "reg_or_short_operand" ""))
13527 (match_operand:SI 3 "gpc_reg_operand" ""))
13528 (const_int 0)))
13529 (clobber (match_scratch:SI 4 ""))]
683bdff7 13530 "TARGET_32BIT && reload_completed"
9ebbca7d
GK
13531 [(set (match_dup 4)
13532 (plus:SI (gtu:SI (match_dup 1) (match_dup 2))
097657c3 13533 (match_dup 3)))
9ebbca7d
GK
13534 (set (match_dup 0)
13535 (compare:CC (match_dup 4)
13536 (const_int 0)))]
13537 "")
1fd4e8c1 13538
f9562f27 13539(define_insn ""
9ebbca7d 13540 [(set (match_operand:CC 0 "cc_reg_operand" "=x,x,?y,?y")
f9562f27 13541 (compare:CC
9ebbca7d
GK
13542 (plus:DI (gtu:DI (match_operand:DI 1 "gpc_reg_operand" "r,r,r,r")
13543 (match_operand:DI 2 "reg_or_short_operand" "I,r,I,r"))
13544 (match_operand:DI 3 "gpc_reg_operand" "r,r,r,r"))
f9562f27 13545 (const_int 0)))
9ebbca7d 13546 (clobber (match_scratch:DI 4 "=&r,&r,&r,&r"))]
683bdff7 13547 "TARGET_64BIT"
f9562f27
DE
13548 "@
13549 addic %4,%1,%k2\;addze. %4,%3
9ebbca7d
GK
13550 subf%I2c %4,%1,%2\;subfe %4,%4,%4\;subfc. %4,%4,%3
13551 #
13552 #"
f9562f27 13553 [(set_attr "type" "compare")
9ebbca7d
GK
13554 (set_attr "length" "8,12,12,16")])
13555
13556(define_split
13557 [(set (match_operand:CC 0 "cc_reg_not_cr0_operand" "")
13558 (compare:CC
13559 (plus:DI (gtu:DI (match_operand:DI 1 "gpc_reg_operand" "")
13560 (match_operand:DI 2 "reg_or_short_operand" ""))
13561 (match_operand:DI 3 "gpc_reg_operand" ""))
13562 (const_int 0)))
13563 (clobber (match_scratch:DI 4 ""))]
683bdff7 13564 "TARGET_64BIT && reload_completed"
9ebbca7d
GK
13565 [(set (match_dup 4)
13566 (plus:DI (gtu:DI (match_dup 1) (match_dup 2))
13567 (match_dup 3)))
13568 (set (match_dup 0)
13569 (compare:CC (match_dup 4)
13570 (const_int 0)))]
13571 "")
f9562f27 13572
1fd4e8c1 13573(define_insn ""
097657c3 13574 [(set (match_operand:CC 4 "cc_reg_operand" "=x,x,?y,?y")
1fd4e8c1 13575 (compare:CC
9ebbca7d
GK
13576 (plus:SI (gtu:SI (match_operand:SI 1 "gpc_reg_operand" "r,r,r,r")
13577 (match_operand:SI 2 "reg_or_short_operand" "I,r,I,r"))
13578 (match_operand:SI 3 "gpc_reg_operand" "r,r,r,r"))
1fd4e8c1 13579 (const_int 0)))
097657c3
AM
13580 (set (match_operand:SI 0 "gpc_reg_operand" "=&r,&r,&r,&r")
13581 (plus:SI (gtu:SI (match_dup 1) (match_dup 2)) (match_dup 3)))]
683bdff7 13582 "TARGET_32BIT"
00751805 13583 "@
097657c3
AM
13584 {ai|addic} %0,%1,%k2\;{aze.|addze.} %0,%3
13585 {sf%I2|subf%I2c} %0,%1,%2\;{sfe|subfe} %0,%0,%0\;{sf.|subfc.} %0,%0,%3
9ebbca7d
GK
13586 #
13587 #"
b19003d8 13588 [(set_attr "type" "compare")
9ebbca7d
GK
13589 (set_attr "length" "8,12,12,16")])
13590
13591(define_split
097657c3 13592 [(set (match_operand:CC 4 "cc_reg_not_cr0_operand" "")
9ebbca7d
GK
13593 (compare:CC
13594 (plus:SI (gtu:SI (match_operand:SI 1 "gpc_reg_operand" "")
13595 (match_operand:SI 2 "reg_or_short_operand" ""))
13596 (match_operand:SI 3 "gpc_reg_operand" ""))
13597 (const_int 0)))
13598 (set (match_operand:SI 0 "gpc_reg_operand" "")
097657c3 13599 (plus:SI (gtu:SI (match_dup 1) (match_dup 2)) (match_dup 3)))]
683bdff7 13600 "TARGET_32BIT && reload_completed"
097657c3 13601 [(set (match_dup 0)
9ebbca7d 13602 (plus:SI (gtu:SI (match_dup 1) (match_dup 2)) (match_dup 3)))
097657c3 13603 (set (match_dup 4)
9ebbca7d
GK
13604 (compare:CC (match_dup 0)
13605 (const_int 0)))]
13606 "")
1fd4e8c1 13607
f9562f27 13608(define_insn ""
097657c3 13609 [(set (match_operand:CC 4 "cc_reg_operand" "=x,x,?y,?y")
f9562f27 13610 (compare:CC
9ebbca7d
GK
13611 (plus:DI (gtu:DI (match_operand:DI 1 "gpc_reg_operand" "r,r,r,r")
13612 (match_operand:DI 2 "reg_or_short_operand" "I,r,I,r"))
13613 (match_operand:DI 3 "gpc_reg_operand" "r,r,r,r"))
f9562f27 13614 (const_int 0)))
097657c3
AM
13615 (set (match_operand:DI 0 "gpc_reg_operand" "=&r,&r,&r,&r")
13616 (plus:DI (gtu:DI (match_dup 1) (match_dup 2)) (match_dup 3)))]
683bdff7 13617 "TARGET_64BIT"
f9562f27 13618 "@
097657c3
AM
13619 addic %0,%1,%k2\;addze. %0,%3
13620 subf%I2c %0,%1,%2\;subfe %0,%0,%0\;subfc. %0,%0,%3
9ebbca7d
GK
13621 #
13622 #"
f9562f27 13623 [(set_attr "type" "compare")
9ebbca7d
GK
13624 (set_attr "length" "8,12,12,16")])
13625
13626(define_split
097657c3 13627 [(set (match_operand:CC 4 "cc_reg_not_cr0_operand" "")
9ebbca7d
GK
13628 (compare:CC
13629 (plus:DI (gtu:DI (match_operand:DI 1 "gpc_reg_operand" "")
13630 (match_operand:DI 2 "reg_or_short_operand" ""))
13631 (match_operand:DI 3 "gpc_reg_operand" ""))
13632 (const_int 0)))
13633 (set (match_operand:DI 0 "gpc_reg_operand" "")
097657c3 13634 (plus:DI (gtu:DI (match_dup 1) (match_dup 2)) (match_dup 3)))]
683bdff7 13635 "TARGET_64BIT && reload_completed"
097657c3 13636 [(set (match_dup 0)
9ebbca7d 13637 (plus:DI (gtu:DI (match_dup 1) (match_dup 2)) (match_dup 3)))
097657c3 13638 (set (match_dup 4)
9ebbca7d
GK
13639 (compare:CC (match_dup 0)
13640 (const_int 0)))]
13641 "")
f9562f27 13642
1fd4e8c1 13643(define_insn ""
cd2b37d9
RK
13644 [(set (match_operand:SI 0 "gpc_reg_operand" "=r")
13645 (neg:SI (gtu:SI (match_operand:SI 1 "gpc_reg_operand" "r")
1fd4e8c1 13646 (match_operand:SI 2 "reg_or_short_operand" "rI"))))]
683bdff7 13647 "TARGET_32BIT"
ca7f5001 13648 "{sf%I2|subf%I2c} %0,%1,%2\;{sfe|subfe} %0,%0,%0"
b19003d8 13649 [(set_attr "length" "8")])
f9562f27
DE
13650
13651(define_insn ""
13652 [(set (match_operand:DI 0 "gpc_reg_operand" "=r")
13653 (neg:DI (gtu:DI (match_operand:DI 1 "gpc_reg_operand" "r")
13654 (match_operand:DI 2 "reg_or_short_operand" "rI"))))]
683bdff7 13655 "TARGET_64BIT"
f9562f27
DE
13656 "subf%I2c %0,%1,%2\;subfe %0,%0,%0"
13657 [(set_attr "length" "8")])
1fd4e8c1
RK
13658\f
13659;; Define both directions of branch and return. If we need a reload
13660;; register, we'd rather use CR0 since it is much easier to copy a
13661;; register CC value to there.
13662
13663(define_insn ""
13664 [(set (pc)
13665 (if_then_else (match_operator 1 "branch_comparison_operator"
13666 [(match_operand 2
b54cf83a 13667 "cc_reg_operand" "y")
1fd4e8c1
RK
13668 (const_int 0)])
13669 (label_ref (match_operand 0 "" ""))
13670 (pc)))]
13671 ""
b19003d8
RK
13672 "*
13673{
12a4e8c5 13674 return output_cbranch (operands[1], \"%l0\", 0, insn);
b19003d8
RK
13675}"
13676 [(set_attr "type" "branch")])
13677
1fd4e8c1
RK
13678(define_insn ""
13679 [(set (pc)
13680 (if_then_else (match_operator 0 "branch_comparison_operator"
13681 [(match_operand 1
b54cf83a 13682 "cc_reg_operand" "y")
1fd4e8c1
RK
13683 (const_int 0)])
13684 (return)
13685 (pc)))]
13686 "direct_return ()"
12a4e8c5
GK
13687 "*
13688{
13689 return output_cbranch (operands[0], NULL, 0, insn);
13690}"
b7ff3d82 13691 [(set_attr "type" "branch")
39a10a29 13692 (set_attr "length" "4")])
1fd4e8c1
RK
13693
13694(define_insn ""
13695 [(set (pc)
13696 (if_then_else (match_operator 1 "branch_comparison_operator"
13697 [(match_operand 2
b54cf83a 13698 "cc_reg_operand" "y")
1fd4e8c1
RK
13699 (const_int 0)])
13700 (pc)
13701 (label_ref (match_operand 0 "" ""))))]
13702 ""
b19003d8
RK
13703 "*
13704{
12a4e8c5 13705 return output_cbranch (operands[1], \"%l0\", 1, insn);
b19003d8
RK
13706}"
13707 [(set_attr "type" "branch")])
1fd4e8c1
RK
13708
13709(define_insn ""
13710 [(set (pc)
13711 (if_then_else (match_operator 0 "branch_comparison_operator"
13712 [(match_operand 1
b54cf83a 13713 "cc_reg_operand" "y")
1fd4e8c1
RK
13714 (const_int 0)])
13715 (pc)
13716 (return)))]
13717 "direct_return ()"
12a4e8c5
GK
13718 "*
13719{
13720 return output_cbranch (operands[0], NULL, 1, insn);
13721}"
b7ff3d82 13722 [(set_attr "type" "branch")
39a10a29
GK
13723 (set_attr "length" "4")])
13724
13725;; Logic on condition register values.
13726
13727; This pattern matches things like
13728; (set (reg:CCEQ 68) (compare:CCEQ (ior:SI (gt:SI (reg:CCFP 68) (const_int 0))
13729; (eq:SI (reg:CCFP 68) (const_int 0)))
13730; (const_int 1)))
13731; which are generated by the branch logic.
b54cf83a 13732; Prefer destructive operations where BT = BB (for crXX BT,BA,BB)
39a10a29 13733
423c1189 13734(define_insn "*cceq_ior_compare"
b54cf83a 13735 [(set (match_operand:CCEQ 0 "cc_reg_operand" "=y,?y")
39a10a29 13736 (compare:CCEQ (match_operator:SI 1 "boolean_operator"
b54cf83a 13737 [(match_operator:SI 2
39a10a29
GK
13738 "branch_positive_comparison_operator"
13739 [(match_operand 3
b54cf83a 13740 "cc_reg_operand" "y,y")
39a10a29 13741 (const_int 0)])
b54cf83a 13742 (match_operator:SI 4
39a10a29
GK
13743 "branch_positive_comparison_operator"
13744 [(match_operand 5
b54cf83a 13745 "cc_reg_operand" "0,y")
39a10a29
GK
13746 (const_int 0)])])
13747 (const_int 1)))]
24fab1d3 13748 ""
39a10a29 13749 "cr%q1 %E0,%j2,%j4"
b54cf83a 13750 [(set_attr "type" "cr_logical,delayed_cr")])
39a10a29
GK
13751
13752; Why is the constant -1 here, but 1 in the previous pattern?
13753; Because ~1 has all but the low bit set.
13754(define_insn ""
b54cf83a 13755 [(set (match_operand:CCEQ 0 "cc_reg_operand" "=y,?y")
39a10a29 13756 (compare:CCEQ (match_operator:SI 1 "boolean_or_operator"
b54cf83a 13757 [(not:SI (match_operator:SI 2
39a10a29
GK
13758 "branch_positive_comparison_operator"
13759 [(match_operand 3
b54cf83a 13760 "cc_reg_operand" "y,y")
39a10a29
GK
13761 (const_int 0)]))
13762 (match_operator:SI 4
13763 "branch_positive_comparison_operator"
13764 [(match_operand 5
b54cf83a 13765 "cc_reg_operand" "0,y")
39a10a29
GK
13766 (const_int 0)])])
13767 (const_int -1)))]
13768 ""
13769 "cr%q1 %E0,%j2,%j4"
b54cf83a 13770 [(set_attr "type" "cr_logical,delayed_cr")])
39a10a29 13771
423c1189 13772(define_insn "*cceq_rev_compare"
b54cf83a 13773 [(set (match_operand:CCEQ 0 "cc_reg_operand" "=y,?y")
6c873122 13774 (compare:CCEQ (match_operator:SI 1
39a10a29 13775 "branch_positive_comparison_operator"
6c873122 13776 [(match_operand 2
b54cf83a 13777 "cc_reg_operand" "0,y")
39a10a29
GK
13778 (const_int 0)])
13779 (const_int 0)))]
423c1189 13780 ""
251b3667 13781 "{crnor %E0,%j1,%j1|crnot %E0,%j1}"
b54cf83a 13782 [(set_attr "type" "cr_logical,delayed_cr")])
39a10a29
GK
13783
13784;; If we are comparing the result of two comparisons, this can be done
13785;; using creqv or crxor.
13786
13787(define_insn_and_split ""
13788 [(set (match_operand:CCEQ 0 "cc_reg_operand" "=y")
13789 (compare:CCEQ (match_operator 1 "branch_comparison_operator"
13790 [(match_operand 2 "cc_reg_operand" "y")
13791 (const_int 0)])
13792 (match_operator 3 "branch_comparison_operator"
13793 [(match_operand 4 "cc_reg_operand" "y")
13794 (const_int 0)])))]
13795 ""
13796 "#"
13797 ""
13798 [(set (match_dup 0) (compare:CCEQ (xor:SI (match_dup 1) (match_dup 3))
13799 (match_dup 5)))]
13800 "
13801{
13802 int positive_1, positive_2;
13803
13804 positive_1 = branch_positive_comparison_operator (operands[1], CCEQmode);
13805 positive_2 = branch_positive_comparison_operator (operands[3], CCEQmode);
13806
13807 if (! positive_1)
1c563bed 13808 operands[1] = gen_rtx_fmt_ee (rs6000_reverse_condition (GET_MODE (operands[2]),
0f4c242b
KH
13809 GET_CODE (operands[1])),
13810 SImode,
13811 operands[2], const0_rtx);
39a10a29 13812 else if (GET_MODE (operands[1]) != SImode)
0f4c242b
KH
13813 operands[1] = gen_rtx_fmt_ee (GET_CODE (operands[1]), SImode,
13814 operands[2], const0_rtx);
39a10a29
GK
13815
13816 if (! positive_2)
1c563bed 13817 operands[3] = gen_rtx_fmt_ee (rs6000_reverse_condition (GET_MODE (operands[4]),
0f4c242b
KH
13818 GET_CODE (operands[3])),
13819 SImode,
13820 operands[4], const0_rtx);
39a10a29 13821 else if (GET_MODE (operands[3]) != SImode)
0f4c242b
KH
13822 operands[3] = gen_rtx_fmt_ee (GET_CODE (operands[3]), SImode,
13823 operands[4], const0_rtx);
39a10a29
GK
13824
13825 if (positive_1 == positive_2)
251b3667
DE
13826 {
13827 operands[1] = gen_rtx_NOT (SImode, operands[1]);
13828 operands[5] = constm1_rtx;
13829 }
13830 else
13831 {
13832 operands[5] = const1_rtx;
13833 }
39a10a29 13834}")
1fd4e8c1
RK
13835
13836;; Unconditional branch and return.
13837
13838(define_insn "jump"
13839 [(set (pc)
13840 (label_ref (match_operand 0 "" "")))]
13841 ""
b7ff3d82
DE
13842 "b %l0"
13843 [(set_attr "type" "branch")])
1fd4e8c1
RK
13844
13845(define_insn "return"
13846 [(return)]
13847 "direct_return ()"
324e52cc
TG
13848 "{br|blr}"
13849 [(set_attr "type" "jmpreg")])
1fd4e8c1 13850
0ad91047
DE
13851(define_expand "indirect_jump"
13852 [(set (pc) (match_operand 0 "register_operand" ""))]
1fd4e8c1 13853 ""
0ad91047
DE
13854 "
13855{
13856 if (TARGET_32BIT)
13857 emit_jump_insn (gen_indirect_jumpsi (operands[0]));
13858 else
13859 emit_jump_insn (gen_indirect_jumpdi (operands[0]));
13860 DONE;
13861}")
13862
13863(define_insn "indirect_jumpsi"
b92b324d 13864 [(set (pc) (match_operand:SI 0 "register_operand" "c,*l"))]
0ad91047 13865 "TARGET_32BIT"
b92b324d
DE
13866 "@
13867 bctr
13868 {br|blr}"
324e52cc 13869 [(set_attr "type" "jmpreg")])
1fd4e8c1 13870
0ad91047 13871(define_insn "indirect_jumpdi"
b92b324d 13872 [(set (pc) (match_operand:DI 0 "register_operand" "c,*l"))]
0ad91047 13873 "TARGET_64BIT"
b92b324d
DE
13874 "@
13875 bctr
13876 blr"
266eb58a
DE
13877 [(set_attr "type" "jmpreg")])
13878
1fd4e8c1
RK
13879;; Table jump for switch statements:
13880(define_expand "tablejump"
e6ca2c17
DE
13881 [(use (match_operand 0 "" ""))
13882 (use (label_ref (match_operand 1 "" "")))]
13883 ""
13884 "
13885{
13886 if (TARGET_32BIT)
13887 emit_jump_insn (gen_tablejumpsi (operands[0], operands[1]));
13888 else
13889 emit_jump_insn (gen_tablejumpdi (operands[0], operands[1]));
13890 DONE;
13891}")
13892
13893(define_expand "tablejumpsi"
1fd4e8c1
RK
13894 [(set (match_dup 3)
13895 (plus:SI (match_operand:SI 0 "" "")
13896 (match_dup 2)))
13897 (parallel [(set (pc) (match_dup 3))
13898 (use (label_ref (match_operand 1 "" "")))])]
0ad91047 13899 "TARGET_32BIT"
1fd4e8c1
RK
13900 "
13901{ operands[0] = force_reg (SImode, operands[0]);
c5c76735 13902 operands[2] = force_reg (SImode, gen_rtx_LABEL_REF (SImode, operands[1]));
1fd4e8c1
RK
13903 operands[3] = gen_reg_rtx (SImode);
13904}")
13905
e6ca2c17 13906(define_expand "tablejumpdi"
6ae08853 13907 [(set (match_dup 4)
9ebbca7d
GK
13908 (sign_extend:DI (match_operand:SI 0 "lwa_operand" "rm")))
13909 (set (match_dup 3)
13910 (plus:DI (match_dup 4)
e6ca2c17
DE
13911 (match_dup 2)))
13912 (parallel [(set (pc) (match_dup 3))
13913 (use (label_ref (match_operand 1 "" "")))])]
0ad91047 13914 "TARGET_64BIT"
e6ca2c17 13915 "
9ebbca7d 13916{ operands[2] = force_reg (DImode, gen_rtx_LABEL_REF (DImode, operands[1]));
e6ca2c17 13917 operands[3] = gen_reg_rtx (DImode);
9ebbca7d 13918 operands[4] = gen_reg_rtx (DImode);
e6ca2c17
DE
13919}")
13920
1fd4e8c1
RK
13921(define_insn ""
13922 [(set (pc)
c859cda6 13923 (match_operand:SI 0 "register_operand" "c,*l"))
1fd4e8c1 13924 (use (label_ref (match_operand 1 "" "")))]
0ad91047 13925 "TARGET_32BIT"
c859cda6
DJ
13926 "@
13927 bctr
13928 {br|blr}"
a6845123 13929 [(set_attr "type" "jmpreg")])
1fd4e8c1 13930
266eb58a
DE
13931(define_insn ""
13932 [(set (pc)
c859cda6 13933 (match_operand:DI 0 "register_operand" "c,*l"))
266eb58a 13934 (use (label_ref (match_operand 1 "" "")))]
0ad91047 13935 "TARGET_64BIT"
c859cda6
DJ
13936 "@
13937 bctr
13938 blr"
266eb58a
DE
13939 [(set_attr "type" "jmpreg")])
13940
1fd4e8c1
RK
13941(define_insn "nop"
13942 [(const_int 0)]
13943 ""
ca7f5001 13944 "{cror 0,0,0|nop}")
1fd4e8c1 13945\f
7e69e155 13946;; Define the subtract-one-and-jump insns, starting with the template
c225ba7b
RK
13947;; so loop.c knows what to generate.
13948
5527bf14
RH
13949(define_expand "doloop_end"
13950 [(use (match_operand 0 "" "")) ; loop pseudo
13951 (use (match_operand 1 "" "")) ; iterations; zero if unknown
13952 (use (match_operand 2 "" "")) ; max iterations
13953 (use (match_operand 3 "" "")) ; loop level
13954 (use (match_operand 4 "" ""))] ; label
0ad91047
DE
13955 ""
13956 "
13957{
5527bf14
RH
13958 /* Only use this on innermost loops. */
13959 if (INTVAL (operands[3]) > 1)
13960 FAIL;
683bdff7 13961 if (TARGET_64BIT)
5527bf14
RH
13962 {
13963 if (GET_MODE (operands[0]) != DImode)
13964 FAIL;
13965 emit_jump_insn (gen_ctrdi (operands[0], operands[4]));
13966 }
0ad91047 13967 else
5527bf14
RH
13968 {
13969 if (GET_MODE (operands[0]) != SImode)
13970 FAIL;
13971 emit_jump_insn (gen_ctrsi (operands[0], operands[4]));
13972 }
0ad91047
DE
13973 DONE;
13974}")
13975
13976(define_expand "ctrsi"
3cb999d8
DE
13977 [(parallel [(set (pc)
13978 (if_then_else (ne (match_operand:SI 0 "register_operand" "")
13979 (const_int 1))
13980 (label_ref (match_operand 1 "" ""))
13981 (pc)))
b6c9286a
MM
13982 (set (match_dup 0)
13983 (plus:SI (match_dup 0)
13984 (const_int -1)))
5f81043f
RK
13985 (clobber (match_scratch:CC 2 ""))
13986 (clobber (match_scratch:SI 3 ""))])]
683bdff7 13987 "TARGET_32BIT"
0ad91047
DE
13988 "")
13989
13990(define_expand "ctrdi"
3cb999d8
DE
13991 [(parallel [(set (pc)
13992 (if_then_else (ne (match_operand:DI 0 "register_operand" "")
13993 (const_int 1))
13994 (label_ref (match_operand 1 "" ""))
13995 (pc)))
0ad91047
DE
13996 (set (match_dup 0)
13997 (plus:DI (match_dup 0)
13998 (const_int -1)))
13999 (clobber (match_scratch:CC 2 ""))
61c07d3c 14000 (clobber (match_scratch:DI 3 ""))])]
683bdff7 14001 "TARGET_64BIT"
61c07d3c 14002 "")
c225ba7b 14003
1fd4e8c1
RK
14004;; We need to be able to do this for any operand, including MEM, or we
14005;; will cause reload to blow up since we don't allow output reloads on
7e69e155 14006;; JUMP_INSNs.
0ad91047 14007;; For the length attribute to be calculated correctly, the
5f81043f
RK
14008;; label MUST be operand 0.
14009
0ad91047 14010(define_insn "*ctrsi_internal1"
1fd4e8c1 14011 [(set (pc)
43b68ce5 14012 (if_then_else (ne (match_operand:SI 1 "register_operand" "c,*r,*r,*r")
1fd4e8c1 14013 (const_int 1))
a6845123 14014 (label_ref (match_operand 0 "" ""))
1fd4e8c1 14015 (pc)))
b150f4f3 14016 (set (match_operand:SI 2 "nonimmediate_operand" "=1,*r,m,*q*c*l")
5f81043f
RK
14017 (plus:SI (match_dup 1)
14018 (const_int -1)))
43b68ce5
DE
14019 (clobber (match_scratch:CC 3 "=X,&x,&x,&x"))
14020 (clobber (match_scratch:SI 4 "=X,X,&r,r"))]
683bdff7 14021 "TARGET_32BIT"
b19003d8
RK
14022 "*
14023{
af87a13e 14024 if (which_alternative != 0)
b19003d8 14025 return \"#\";
856a6884 14026 else if (get_attr_length (insn) == 4)
a6845123 14027 return \"{bdn|bdnz} %l0\";
b19003d8 14028 else
f607bc57 14029 return \"bdz $+8\;b %l0\";
b19003d8 14030}"
baf97f86 14031 [(set_attr "type" "branch")
5a195cb5 14032 (set_attr "length" "*,12,16,16")])
7e69e155 14033
0ad91047 14034(define_insn "*ctrsi_internal2"
5f81043f 14035 [(set (pc)
43b68ce5 14036 (if_then_else (ne (match_operand:SI 1 "register_operand" "c,*r,*r,*r")
5f81043f
RK
14037 (const_int 1))
14038 (pc)
14039 (label_ref (match_operand 0 "" ""))))
b150f4f3 14040 (set (match_operand:SI 2 "nonimmediate_operand" "=1,*r,m,*q*c*l")
5f81043f
RK
14041 (plus:SI (match_dup 1)
14042 (const_int -1)))
43b68ce5
DE
14043 (clobber (match_scratch:CC 3 "=X,&x,&x,&x"))
14044 (clobber (match_scratch:SI 4 "=X,X,&r,r"))]
683bdff7 14045 "TARGET_32BIT"
0ad91047
DE
14046 "*
14047{
14048 if (which_alternative != 0)
14049 return \"#\";
856a6884 14050 else if (get_attr_length (insn) == 4)
0ad91047
DE
14051 return \"bdz %l0\";
14052 else
f607bc57 14053 return \"{bdn|bdnz} $+8\;b %l0\";
0ad91047
DE
14054}"
14055 [(set_attr "type" "branch")
5a195cb5 14056 (set_attr "length" "*,12,16,16")])
0ad91047
DE
14057
14058(define_insn "*ctrdi_internal1"
14059 [(set (pc)
43b68ce5 14060 (if_then_else (ne (match_operand:DI 1 "register_operand" "c,*r,*r,*r")
0ad91047
DE
14061 (const_int 1))
14062 (label_ref (match_operand 0 "" ""))
14063 (pc)))
b150f4f3 14064 (set (match_operand:DI 2 "nonimmediate_operand" "=1,*r,m,*c*l")
0ad91047
DE
14065 (plus:DI (match_dup 1)
14066 (const_int -1)))
43b68ce5
DE
14067 (clobber (match_scratch:CC 3 "=X,&x,&x,&x"))
14068 (clobber (match_scratch:DI 4 "=X,X,&r,r"))]
683bdff7 14069 "TARGET_64BIT"
0ad91047
DE
14070 "*
14071{
14072 if (which_alternative != 0)
14073 return \"#\";
856a6884 14074 else if (get_attr_length (insn) == 4)
0ad91047
DE
14075 return \"{bdn|bdnz} %l0\";
14076 else
f607bc57 14077 return \"bdz $+8\;b %l0\";
0ad91047
DE
14078}"
14079 [(set_attr "type" "branch")
5a195cb5 14080 (set_attr "length" "*,12,16,16")])
0ad91047
DE
14081
14082(define_insn "*ctrdi_internal2"
14083 [(set (pc)
43b68ce5 14084 (if_then_else (ne (match_operand:DI 1 "register_operand" "c,*r,*r,*r")
0ad91047
DE
14085 (const_int 1))
14086 (pc)
14087 (label_ref (match_operand 0 "" ""))))
b150f4f3 14088 (set (match_operand:DI 2 "nonimmediate_operand" "=1,*r,m,*c*l")
0ad91047
DE
14089 (plus:DI (match_dup 1)
14090 (const_int -1)))
43b68ce5
DE
14091 (clobber (match_scratch:CC 3 "=X,&x,&x,&x"))
14092 (clobber (match_scratch:DI 4 "=X,X,&r,r"))]
683bdff7 14093 "TARGET_64BIT"
5f81043f
RK
14094 "*
14095{
14096 if (which_alternative != 0)
14097 return \"#\";
856a6884 14098 else if (get_attr_length (insn) == 4)
5f81043f
RK
14099 return \"bdz %l0\";
14100 else
f607bc57 14101 return \"{bdn|bdnz} $+8\;b %l0\";
5f81043f
RK
14102}"
14103 [(set_attr "type" "branch")
5a195cb5 14104 (set_attr "length" "*,12,16,16")])
5f81043f 14105
0ad91047
DE
14106;; Similar but use EQ
14107
14108(define_insn "*ctrsi_internal5"
5f81043f 14109 [(set (pc)
43b68ce5 14110 (if_then_else (eq (match_operand:SI 1 "register_operand" "c,*r,*r,*r")
1fd4e8c1 14111 (const_int 1))
a6845123 14112 (label_ref (match_operand 0 "" ""))
1fd4e8c1 14113 (pc)))
b150f4f3 14114 (set (match_operand:SI 2 "nonimmediate_operand" "=1,*r,m,*q*c*l")
5f81043f
RK
14115 (plus:SI (match_dup 1)
14116 (const_int -1)))
43b68ce5
DE
14117 (clobber (match_scratch:CC 3 "=X,&x,&x,&x"))
14118 (clobber (match_scratch:SI 4 "=X,X,&r,r"))]
683bdff7 14119 "TARGET_32BIT"
b19003d8
RK
14120 "*
14121{
af87a13e 14122 if (which_alternative != 0)
b19003d8 14123 return \"#\";
856a6884 14124 else if (get_attr_length (insn) == 4)
a6845123 14125 return \"bdz %l0\";
b19003d8 14126 else
f607bc57 14127 return \"{bdn|bdnz} $+8\;b %l0\";
b19003d8 14128}"
baf97f86 14129 [(set_attr "type" "branch")
5a195cb5 14130 (set_attr "length" "*,12,16,16")])
1fd4e8c1 14131
0ad91047 14132(define_insn "*ctrsi_internal6"
5f81043f 14133 [(set (pc)
43b68ce5 14134 (if_then_else (eq (match_operand:SI 1 "register_operand" "c,*r,*r,*r")
5f81043f
RK
14135 (const_int 1))
14136 (pc)
14137 (label_ref (match_operand 0 "" ""))))
b150f4f3 14138 (set (match_operand:SI 2 "nonimmediate_operand" "=1,*r,m,*q*c*l")
5f81043f
RK
14139 (plus:SI (match_dup 1)
14140 (const_int -1)))
43b68ce5
DE
14141 (clobber (match_scratch:CC 3 "=X,&x,&x,&x"))
14142 (clobber (match_scratch:SI 4 "=X,X,&r,r"))]
683bdff7 14143 "TARGET_32BIT"
0ad91047
DE
14144 "*
14145{
14146 if (which_alternative != 0)
14147 return \"#\";
856a6884 14148 else if (get_attr_length (insn) == 4)
0ad91047
DE
14149 return \"{bdn|bdnz} %l0\";
14150 else
f607bc57 14151 return \"bdz $+8\;b %l0\";
0ad91047
DE
14152}"
14153 [(set_attr "type" "branch")
5a195cb5 14154 (set_attr "length" "*,12,16,16")])
0ad91047
DE
14155
14156(define_insn "*ctrdi_internal5"
14157 [(set (pc)
43b68ce5 14158 (if_then_else (eq (match_operand:DI 1 "register_operand" "c,*r,*r,*r")
0ad91047
DE
14159 (const_int 1))
14160 (label_ref (match_operand 0 "" ""))
14161 (pc)))
b150f4f3 14162 (set (match_operand:DI 2 "nonimmediate_operand" "=1,*r,m,*c*l")
0ad91047
DE
14163 (plus:DI (match_dup 1)
14164 (const_int -1)))
43b68ce5
DE
14165 (clobber (match_scratch:CC 3 "=X,&x,&x,&x"))
14166 (clobber (match_scratch:DI 4 "=X,X,&r,r"))]
683bdff7 14167 "TARGET_64BIT"
0ad91047
DE
14168 "*
14169{
14170 if (which_alternative != 0)
14171 return \"#\";
856a6884 14172 else if (get_attr_length (insn) == 4)
0ad91047
DE
14173 return \"bdz %l0\";
14174 else
f607bc57 14175 return \"{bdn|bdnz} $+8\;b %l0\";
0ad91047
DE
14176}"
14177 [(set_attr "type" "branch")
5a195cb5 14178 (set_attr "length" "*,12,16,16")])
0ad91047
DE
14179
14180(define_insn "*ctrdi_internal6"
14181 [(set (pc)
43b68ce5 14182 (if_then_else (eq (match_operand:DI 1 "register_operand" "c,*r,*r,*r")
0ad91047
DE
14183 (const_int 1))
14184 (pc)
14185 (label_ref (match_operand 0 "" ""))))
b150f4f3 14186 (set (match_operand:DI 2 "nonimmediate_operand" "=1,*r,m,*c*l")
0ad91047
DE
14187 (plus:DI (match_dup 1)
14188 (const_int -1)))
43b68ce5
DE
14189 (clobber (match_scratch:CC 3 "=X,&x,&x,&x"))
14190 (clobber (match_scratch:DI 4 "=X,X,&r,r"))]
683bdff7 14191 "TARGET_64BIT"
5f81043f
RK
14192 "*
14193{
14194 if (which_alternative != 0)
14195 return \"#\";
856a6884 14196 else if (get_attr_length (insn) == 4)
5f81043f
RK
14197 return \"{bdn|bdnz} %l0\";
14198 else
f607bc57 14199 return \"bdz $+8\;b %l0\";
5f81043f
RK
14200}"
14201 [(set_attr "type" "branch")
5a195cb5 14202 (set_attr "length" "*,12,16,16")])
5f81043f 14203
0ad91047
DE
14204;; Now the splitters if we could not allocate the CTR register
14205
1fd4e8c1
RK
14206(define_split
14207 [(set (pc)
14208 (if_then_else (match_operator 2 "comparison_operator"
cd2b37d9 14209 [(match_operand:SI 1 "gpc_reg_operand" "")
1fd4e8c1
RK
14210 (const_int 1)])
14211 (match_operand 5 "" "")
14212 (match_operand 6 "" "")))
cd2b37d9 14213 (set (match_operand:SI 0 "gpc_reg_operand" "")
5f81043f
RK
14214 (plus:SI (match_dup 1)
14215 (const_int -1)))
1fd4e8c1
RK
14216 (clobber (match_scratch:CC 3 ""))
14217 (clobber (match_scratch:SI 4 ""))]
4b8a63d6 14218 "TARGET_32BIT && reload_completed"
1fd4e8c1 14219 [(parallel [(set (match_dup 3)
5f81043f
RK
14220 (compare:CC (plus:SI (match_dup 1)
14221 (const_int -1))
1fd4e8c1 14222 (const_int 0)))
5f81043f
RK
14223 (set (match_dup 0)
14224 (plus:SI (match_dup 1)
14225 (const_int -1)))])
14226 (set (pc) (if_then_else (match_dup 7)
14227 (match_dup 5)
14228 (match_dup 6)))]
1fd4e8c1 14229 "
0f4c242b
KH
14230{ operands[7] = gen_rtx_fmt_ee (GET_CODE (operands[2]), VOIDmode,
14231 operands[3], const0_rtx); }")
1fd4e8c1
RK
14232
14233(define_split
14234 [(set (pc)
14235 (if_then_else (match_operator 2 "comparison_operator"
cd2b37d9 14236 [(match_operand:SI 1 "gpc_reg_operand" "")
1fd4e8c1
RK
14237 (const_int 1)])
14238 (match_operand 5 "" "")
14239 (match_operand 6 "" "")))
9ebbca7d 14240 (set (match_operand:SI 0 "nonimmediate_operand" "")
1fd4e8c1
RK
14241 (plus:SI (match_dup 1) (const_int -1)))
14242 (clobber (match_scratch:CC 3 ""))
14243 (clobber (match_scratch:SI 4 ""))]
4b8a63d6 14244 "TARGET_32BIT && reload_completed
0ad91047 14245 && ! gpc_reg_operand (operands[0], SImode)"
1fd4e8c1 14246 [(parallel [(set (match_dup 3)
5f81043f
RK
14247 (compare:CC (plus:SI (match_dup 1)
14248 (const_int -1))
1fd4e8c1 14249 (const_int 0)))
5f81043f
RK
14250 (set (match_dup 4)
14251 (plus:SI (match_dup 1)
14252 (const_int -1)))])
14253 (set (match_dup 0)
14254 (match_dup 4))
14255 (set (pc) (if_then_else (match_dup 7)
14256 (match_dup 5)
14257 (match_dup 6)))]
1fd4e8c1 14258 "
0f4c242b
KH
14259{ operands[7] = gen_rtx_fmt_ee (GET_CODE (operands[2]), VOIDmode,
14260 operands[3], const0_rtx); }")
0ad91047
DE
14261(define_split
14262 [(set (pc)
14263 (if_then_else (match_operator 2 "comparison_operator"
14264 [(match_operand:DI 1 "gpc_reg_operand" "")
14265 (const_int 1)])
61c07d3c
DE
14266 (match_operand 5 "" "")
14267 (match_operand 6 "" "")))
0ad91047
DE
14268 (set (match_operand:DI 0 "gpc_reg_operand" "")
14269 (plus:DI (match_dup 1)
14270 (const_int -1)))
14271 (clobber (match_scratch:CC 3 ""))
61c07d3c 14272 (clobber (match_scratch:DI 4 ""))]
683bdff7 14273 "TARGET_64BIT && reload_completed"
0ad91047
DE
14274 [(parallel [(set (match_dup 3)
14275 (compare:CC (plus:DI (match_dup 1)
14276 (const_int -1))
14277 (const_int 0)))
14278 (set (match_dup 0)
14279 (plus:DI (match_dup 1)
14280 (const_int -1)))])
61c07d3c
DE
14281 (set (pc) (if_then_else (match_dup 7)
14282 (match_dup 5)
14283 (match_dup 6)))]
0ad91047 14284 "
0f4c242b
KH
14285{ operands[7] = gen_rtx_fmt_ee (GET_CODE (operands[2]), VOIDmode,
14286 operands[3], const0_rtx); }")
0ad91047
DE
14287
14288(define_split
14289 [(set (pc)
14290 (if_then_else (match_operator 2 "comparison_operator"
14291 [(match_operand:DI 1 "gpc_reg_operand" "")
14292 (const_int 1)])
61c07d3c
DE
14293 (match_operand 5 "" "")
14294 (match_operand 6 "" "")))
9ebbca7d 14295 (set (match_operand:DI 0 "nonimmediate_operand" "")
0ad91047
DE
14296 (plus:DI (match_dup 1) (const_int -1)))
14297 (clobber (match_scratch:CC 3 ""))
61c07d3c 14298 (clobber (match_scratch:DI 4 ""))]
683bdff7 14299 "TARGET_64BIT && reload_completed
0ad91047
DE
14300 && ! gpc_reg_operand (operands[0], DImode)"
14301 [(parallel [(set (match_dup 3)
14302 (compare:CC (plus:DI (match_dup 1)
14303 (const_int -1))
14304 (const_int 0)))
14305 (set (match_dup 4)
14306 (plus:DI (match_dup 1)
14307 (const_int -1)))])
14308 (set (match_dup 0)
14309 (match_dup 4))
61c07d3c
DE
14310 (set (pc) (if_then_else (match_dup 7)
14311 (match_dup 5)
14312 (match_dup 6)))]
0ad91047 14313 "
0f4c242b
KH
14314{ operands[7] = gen_rtx_fmt_ee (GET_CODE (operands[2]), VOIDmode,
14315 operands[3], const0_rtx); }")
e0cd0770
JC
14316\f
14317(define_insn "trap"
14318 [(trap_if (const_int 1) (const_int 0))]
14319 ""
14320 "{t 31,0,0|trap}")
14321
14322(define_expand "conditional_trap"
14323 [(trap_if (match_operator 0 "trap_comparison_operator"
14324 [(match_dup 2) (match_dup 3)])
14325 (match_operand 1 "const_int_operand" ""))]
14326 ""
14327 "if (rs6000_compare_fp_p || operands[1] != const0_rtx) FAIL;
14328 operands[2] = rs6000_compare_op0;
14329 operands[3] = rs6000_compare_op1;")
14330
14331(define_insn ""
14332 [(trap_if (match_operator 0 "trap_comparison_operator"
14333 [(match_operand:SI 1 "register_operand" "r")
14334 (match_operand:SI 2 "reg_or_short_operand" "rI")])
14335 (const_int 0))]
14336 ""
a157febd
GK
14337 "{t|tw}%V0%I2 %1,%2")
14338
14339(define_insn ""
14340 [(trap_if (match_operator 0 "trap_comparison_operator"
14341 [(match_operand:DI 1 "register_operand" "r")
14342 (match_operand:DI 2 "reg_or_short_operand" "rI")])
14343 (const_int 0))]
14344 "TARGET_POWERPC64"
14345 "td%V0%I2 %1,%2")
9ebbca7d
GK
14346\f
14347;; Insns related to generating the function prologue and epilogue.
14348
14349(define_expand "prologue"
14350 [(use (const_int 0))]
14351 "TARGET_SCHED_PROLOG"
14352 "
14353{
14354 rs6000_emit_prologue ();
14355 DONE;
14356}")
14357
2c4a9cff
DE
14358(define_insn "*movesi_from_cr_one"
14359 [(match_parallel 0 "mfcr_operation"
14360 [(set (match_operand:SI 1 "gpc_reg_operand" "=r")
14361 (unspec:SI [(match_operand:CC 2 "cc_reg_operand" "y")
14362 (match_operand 3 "immediate_operand" "n")]
14363 UNSPEC_MOVESI_FROM_CR))])]
14364 "TARGET_MFCRF"
14365 "*
14366{
14367 int mask = 0;
14368 int i;
14369 for (i = 0; i < XVECLEN (operands[0], 0); i++)
14370 {
14371 mask = INTVAL (XVECEXP (SET_SRC (XVECEXP (operands[0], 0, i)), 0, 1));
14372 operands[4] = GEN_INT (mask);
14373 output_asm_insn (\"mfcr %1,%4\", operands);
14374 }
14375 return \"\";
14376}"
14377 [(set_attr "type" "mfcrf")])
14378
9ebbca7d
GK
14379(define_insn "movesi_from_cr"
14380 [(set (match_operand:SI 0 "gpc_reg_operand" "=r")
6ae08853 14381 (unspec:SI [(reg:CC 68) (reg:CC 69) (reg:CC 70) (reg:CC 71)
615158e2
JJ
14382 (reg:CC 72) (reg:CC 73) (reg:CC 74) (reg:CC 75)]
14383 UNSPEC_MOVESI_FROM_CR))]
9ebbca7d 14384 ""
309323c2 14385 "mfcr %0"
b54cf83a 14386 [(set_attr "type" "mfcr")])
9ebbca7d
GK
14387
14388(define_insn "*stmw"
e033a023
DE
14389 [(match_parallel 0 "stmw_operation"
14390 [(set (match_operand:SI 1 "memory_operand" "=m")
14391 (match_operand:SI 2 "gpc_reg_operand" "r"))])]
14392 "TARGET_MULTIPLE"
14393 "{stm|stmw} %2,%1")
6ae08853 14394
9ebbca7d 14395(define_insn "*save_fpregs_si"
e033a023
DE
14396 [(match_parallel 0 "any_operand"
14397 [(clobber (match_operand:SI 1 "register_operand" "=l"))
14398 (use (match_operand:SI 2 "call_operand" "s"))
14399 (set (match_operand:DF 3 "memory_operand" "=m")
14400 (match_operand:DF 4 "gpc_reg_operand" "f"))])]
14401 "TARGET_32BIT"
14402 "bl %z2"
14403 [(set_attr "type" "branch")
14404 (set_attr "length" "4")])
9ebbca7d
GK
14405
14406(define_insn "*save_fpregs_di"
e033a023
DE
14407 [(match_parallel 0 "any_operand"
14408 [(clobber (match_operand:DI 1 "register_operand" "=l"))
14409 (use (match_operand:DI 2 "call_operand" "s"))
14410 (set (match_operand:DF 3 "memory_operand" "=m")
14411 (match_operand:DF 4 "gpc_reg_operand" "f"))])]
14412 "TARGET_64BIT"
14413 "bl %z2"
14414 [(set_attr "type" "branch")
14415 (set_attr "length" "4")])
9ebbca7d
GK
14416
14417; These are to explain that changes to the stack pointer should
14418; not be moved over stores to stack memory.
14419(define_insn "stack_tie"
14420 [(set (match_operand:BLK 0 "memory_operand" "+m")
615158e2 14421 (unspec:BLK [(match_dup 0)] UNSPEC_TIE))]
9ebbca7d
GK
14422 ""
14423 ""
14424 [(set_attr "length" "0")])
14425
14426
14427(define_expand "epilogue"
14428 [(use (const_int 0))]
14429 "TARGET_SCHED_PROLOG"
14430 "
14431{
14432 rs6000_emit_epilogue (FALSE);
14433 DONE;
14434}")
14435
14436; On some processors, doing the mtcrf one CC register at a time is
14437; faster (like on the 604e). On others, doing them all at once is
14438; faster; for instance, on the 601 and 750.
14439
14440(define_expand "movsi_to_cr_one"
35aba846
DE
14441 [(set (match_operand:CC 0 "cc_reg_operand" "=y")
14442 (unspec:CC [(match_operand:SI 1 "gpc_reg_operand" "r")
615158e2 14443 (match_dup 2)] UNSPEC_MOVESI_TO_CR))]
35aba846
DE
14444 ""
14445 "operands[2] = GEN_INT (1 << (75 - REGNO (operands[0])));")
9ebbca7d
GK
14446
14447(define_insn "*movsi_to_cr"
35aba846
DE
14448 [(match_parallel 0 "mtcrf_operation"
14449 [(set (match_operand:CC 1 "cc_reg_operand" "=y")
14450 (unspec:CC [(match_operand:SI 2 "gpc_reg_operand" "r")
14451 (match_operand 3 "immediate_operand" "n")]
615158e2 14452 UNSPEC_MOVESI_TO_CR))])]
9ebbca7d 14453 ""
e35b9579
GK
14454 "*
14455{
14456 int mask = 0;
14457 int i;
14458 for (i = 0; i < XVECLEN (operands[0], 0); i++)
14459 mask |= INTVAL (XVECEXP (SET_SRC (XVECEXP (operands[0], 0, i)), 0, 1));
14460 operands[4] = GEN_INT (mask);
14461 return \"mtcrf %4,%2\";
309323c2 14462}"
b54cf83a 14463 [(set_attr "type" "mtcr")])
9ebbca7d 14464
b54cf83a 14465(define_insn "*mtcrfsi"
309323c2
DE
14466 [(set (match_operand:CC 0 "cc_reg_operand" "=y")
14467 (unspec:CC [(match_operand:SI 1 "gpc_reg_operand" "r")
615158e2
JJ
14468 (match_operand 2 "immediate_operand" "n")]
14469 UNSPEC_MOVESI_TO_CR))]
6ae08853 14470 "GET_CODE (operands[0]) == REG
309323c2
DE
14471 && CR_REGNO_P (REGNO (operands[0]))
14472 && GET_CODE (operands[2]) == CONST_INT
14473 && INTVAL (operands[2]) == 1 << (75 - REGNO (operands[0]))"
14474 "mtcrf %R0,%1"
b54cf83a 14475 [(set_attr "type" "mtcr")])
9ebbca7d
GK
14476
14477; The load-multiple instructions have similar properties.
14478; Note that "load_multiple" is a name known to the machine-independent
14479; code that actually corresponds to the powerpc load-string.
14480
14481(define_insn "*lmw"
35aba846
DE
14482 [(match_parallel 0 "lmw_operation"
14483 [(set (match_operand:SI 1 "gpc_reg_operand" "=r")
14484 (match_operand:SI 2 "memory_operand" "m"))])]
14485 "TARGET_MULTIPLE"
14486 "{lm|lmw} %1,%2")
6ae08853 14487
9ebbca7d 14488(define_insn "*return_internal_si"
e35b9579
GK
14489 [(return)
14490 (use (match_operand:SI 0 "register_operand" "lc"))]
9ebbca7d 14491 "TARGET_32BIT"
cccf3bdc 14492 "b%T0"
9ebbca7d
GK
14493 [(set_attr "type" "jmpreg")])
14494
14495(define_insn "*return_internal_di"
e35b9579
GK
14496 [(return)
14497 (use (match_operand:DI 0 "register_operand" "lc"))]
9ebbca7d 14498 "TARGET_64BIT"
cccf3bdc 14499 "b%T0"
9ebbca7d
GK
14500 [(set_attr "type" "jmpreg")])
14501
14502; FIXME: This would probably be somewhat simpler if the Cygnus sibcall
14503; stuff was in GCC. Oh, and "any_operand" is a bit flexible...
14504
14505(define_insn "*return_and_restore_fpregs_si"
14506 [(match_parallel 0 "any_operand"
e35b9579
GK
14507 [(return)
14508 (use (match_operand:SI 1 "register_operand" "l"))
9ebbca7d
GK
14509 (use (match_operand:SI 2 "call_operand" "s"))
14510 (set (match_operand:DF 3 "gpc_reg_operand" "=f")
14511 (match_operand:DF 4 "memory_operand" "m"))])]
14512 "TARGET_32BIT"
14513 "b %z2")
14514
14515(define_insn "*return_and_restore_fpregs_di"
14516 [(match_parallel 0 "any_operand"
e35b9579
GK
14517 [(return)
14518 (use (match_operand:DI 1 "register_operand" "l"))
9ebbca7d
GK
14519 (use (match_operand:DI 2 "call_operand" "s"))
14520 (set (match_operand:DF 3 "gpc_reg_operand" "=f")
14521 (match_operand:DF 4 "memory_operand" "m"))])]
14522 "TARGET_64BIT"
14523 "b %z2")
14524
83720594
RH
14525; This is used in compiling the unwind routines.
14526(define_expand "eh_return"
34dc173c 14527 [(use (match_operand 0 "general_operand" ""))]
9ebbca7d
GK
14528 ""
14529 "
14530{
83720594 14531 if (TARGET_32BIT)
34dc173c 14532 emit_insn (gen_eh_set_lr_si (operands[0]));
9ebbca7d 14533 else
34dc173c 14534 emit_insn (gen_eh_set_lr_di (operands[0]));
9ebbca7d
GK
14535 DONE;
14536}")
14537
83720594
RH
14538; We can't expand this before we know where the link register is stored.
14539(define_insn "eh_set_lr_si"
615158e2
JJ
14540 [(unspec_volatile [(match_operand:SI 0 "register_operand" "r")]
14541 UNSPECV_EH_RR)
466eb3e0 14542 (clobber (match_scratch:SI 1 "=&b"))]
83720594
RH
14543 "TARGET_32BIT"
14544 "#")
14545
14546(define_insn "eh_set_lr_di"
615158e2
JJ
14547 [(unspec_volatile [(match_operand:DI 0 "register_operand" "r")]
14548 UNSPECV_EH_RR)
466eb3e0 14549 (clobber (match_scratch:DI 1 "=&b"))]
83720594
RH
14550 "TARGET_64BIT"
14551 "#")
9ebbca7d
GK
14552
14553(define_split
615158e2 14554 [(unspec_volatile [(match_operand 0 "register_operand" "")] UNSPECV_EH_RR)
83720594
RH
14555 (clobber (match_scratch 1 ""))]
14556 "reload_completed"
14557 [(const_int 0)]
9ebbca7d
GK
14558 "
14559{
d1d0c603 14560 rs6000_emit_eh_reg_restore (operands[0], operands[1]);
83720594
RH
14561 DONE;
14562}")
0ac081f6 14563
01a2ccd0
DE
14564(define_insn "prefetch"
14565 [(prefetch (match_operand:V4SI 0 "address_operand" "p")
6041bf2f
DE
14566 (match_operand:SI 1 "const_int_operand" "n")
14567 (match_operand:SI 2 "const_int_operand" "n"))]
01a2ccd0 14568 "TARGET_POWERPC"
6041bf2f
DE
14569 "*
14570{
01a2ccd0
DE
14571 if (GET_CODE (operands[0]) == REG)
14572 return INTVAL (operands[1]) ? \"dcbtst 0,%0\" : \"dcbt 0,%0\";
14573 return INTVAL (operands[1]) ? \"dcbtst %a0\" : \"dcbt %a0\";
6041bf2f
DE
14574}"
14575 [(set_attr "type" "load")])
a3170dc6 14576
10ed84db 14577(include "altivec.md")
a3170dc6 14578(include "spe.md")