]> git.ipfire.org Git - thirdparty/gcc.git/blame - gcc/config/rs6000/rs6000.md
* g++.dg/parse/crash10.C: Remove bogus error marker.
[thirdparty/gcc.git] / gcc / config / rs6000 / rs6000.md
CommitLineData
996a5f59 1;; Machine description for IBM RISC System 6000 (POWER) for GNU C compiler
d24652ee
GK
2;; Copyright (C) 1990, 1991, 1992, 1993, 1994, 1995, 1996, 1997, 1998,
3;; 1999, 2000, 2001, 2002, 2003 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)
52 ])
53
54;;
55;; UNSPEC_VOLATILE usage
56;;
57
58(define_constants
59 [(UNSPECV_BLOCK 0)
60 (UNSPECV_EH_RR 9) ; eh_reg_restore
61 ])
1fd4e8c1
RK
62\f
63;; Define an insn type attribute. This is used in function unit delay
64;; computations.
2c4a9cff 65(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
66 (const_string "integer"))
67
b19003d8 68;; Length (in bytes).
6cbadf36
GK
69; '(pc)' in the following doesn't include the instruction itself; it is
70; calculated as if the instruction had zero size.
b19003d8
RK
71(define_attr "length" ""
72 (if_then_else (eq_attr "type" "branch")
6cbadf36 73 (if_then_else (and (ge (minus (match_dup 0) (pc))
b19003d8 74 (const_int -32768))
6cbadf36
GK
75 (lt (minus (match_dup 0) (pc))
76 (const_int 32764)))
39a10a29
GK
77 (const_int 4)
78 (const_int 8))
b19003d8
RK
79 (const_int 4)))
80
cfb557c4
RK
81;; Processor type -- this attribute must exactly match the processor_type
82;; enumeration in rs6000.h.
83
b54cf83a 84(define_attr "cpu" "rios1,rios2,rs64a,mpccore,ppc403,ppc405,ppc440,ppc601,ppc603,ppc604,ppc604e,ppc620,ppc630,ppc750,ppc7400,ppc7450,ppc8540,power4"
cfb557c4
RK
85 (const (symbol_ref "rs6000_cpu_attr")))
86
b54cf83a
DE
87(automata_option "ndfa")
88
89(include "rios1.md")
90(include "rios2.md")
91(include "rs64.md")
92(include "mpc.md")
93(include "40x.md")
02ca7595 94(include "440.md")
b54cf83a
DE
95(include "603.md")
96(include "6xx.md")
97(include "7xx.md")
98(include "7450.md")
5e8006fa 99(include "8540.md")
b54cf83a 100(include "power4.md")
309323c2 101
1fd4e8c1
RK
102\f
103;; Start with fixed-point load and store insns. Here we put only the more
104;; complex forms. Basic data transfer is done later.
105
51b8fc2c
RK
106(define_expand "zero_extendqidi2"
107 [(set (match_operand:DI 0 "gpc_reg_operand" "")
108 (zero_extend:DI (match_operand:QI 1 "gpc_reg_operand" "")))]
109 "TARGET_POWERPC64"
110 "")
111
112(define_insn ""
113 [(set (match_operand:DI 0 "gpc_reg_operand" "=r,r")
114 (zero_extend:DI (match_operand:QI 1 "reg_or_mem_operand" "m,r")))]
115 "TARGET_POWERPC64"
116 "@
117 lbz%U1%X1 %0,%1
4371f8af 118 rldicl %0,%1,0,56"
51b8fc2c
RK
119 [(set_attr "type" "load,*")])
120
121(define_insn ""
9ebbca7d
GK
122 [(set (match_operand:CC 0 "cc_reg_operand" "=x,?y")
123 (compare:CC (zero_extend:DI (match_operand:QI 1 "gpc_reg_operand" "r,r"))
815cdc52 124 (const_int 0)))
9ebbca7d 125 (clobber (match_scratch:DI 2 "=r,r"))]
683bdff7 126 "TARGET_64BIT"
9ebbca7d
GK
127 "@
128 rldicl. %2,%1,0,56
129 #"
130 [(set_attr "type" "compare")
131 (set_attr "length" "4,8")])
132
133(define_split
134 [(set (match_operand:CC 0 "cc_reg_not_cr0_operand" "")
135 (compare:CC (zero_extend:DI (match_operand:QI 1 "gpc_reg_operand" ""))
136 (const_int 0)))
137 (clobber (match_scratch:DI 2 ""))]
138 "TARGET_POWERPC64 && reload_completed"
139 [(set (match_dup 2)
140 (zero_extend:DI (match_dup 1)))
141 (set (match_dup 0)
142 (compare:CC (match_dup 2)
143 (const_int 0)))]
144 "")
51b8fc2c
RK
145
146(define_insn ""
9ebbca7d
GK
147 [(set (match_operand:CC 2 "cc_reg_operand" "=x,?y")
148 (compare:CC (zero_extend:DI (match_operand:QI 1 "gpc_reg_operand" "r,r"))
51b8fc2c 149 (const_int 0)))
9ebbca7d 150 (set (match_operand:DI 0 "gpc_reg_operand" "=r,r")
51b8fc2c 151 (zero_extend:DI (match_dup 1)))]
683bdff7 152 "TARGET_64BIT"
9ebbca7d
GK
153 "@
154 rldicl. %0,%1,0,56
155 #"
156 [(set_attr "type" "compare")
157 (set_attr "length" "4,8")])
158
159(define_split
160 [(set (match_operand:CC 2 "cc_reg_not_cr0_operand" "")
161 (compare:CC (zero_extend:DI (match_operand:QI 1 "gpc_reg_operand" ""))
162 (const_int 0)))
163 (set (match_operand:DI 0 "gpc_reg_operand" "")
164 (zero_extend:DI (match_dup 1)))]
165 "TARGET_POWERPC64 && reload_completed"
166 [(set (match_dup 0)
167 (zero_extend:DI (match_dup 1)))
168 (set (match_dup 2)
169 (compare:CC (match_dup 0)
170 (const_int 0)))]
171 "")
51b8fc2c 172
2bee0449
RK
173(define_insn "extendqidi2"
174 [(set (match_operand:DI 0 "gpc_reg_operand" "=r")
175 (sign_extend:DI (match_operand:QI 1 "gpc_reg_operand" "r")))]
51b8fc2c 176 "TARGET_POWERPC64"
2bee0449 177 "extsb %0,%1")
51b8fc2c
RK
178
179(define_insn ""
9ebbca7d
GK
180 [(set (match_operand:CC 0 "cc_reg_operand" "=x,?y")
181 (compare:CC (sign_extend:DI (match_operand:QI 1 "gpc_reg_operand" "r,r"))
51b8fc2c 182 (const_int 0)))
9ebbca7d 183 (clobber (match_scratch:DI 2 "=r,r"))]
683bdff7 184 "TARGET_64BIT"
9ebbca7d
GK
185 "@
186 extsb. %2,%1
187 #"
188 [(set_attr "type" "compare")
189 (set_attr "length" "4,8")])
190
191(define_split
192 [(set (match_operand:CC 0 "cc_reg_not_cr0_operand" "")
193 (compare:CC (sign_extend:DI (match_operand:QI 1 "gpc_reg_operand" ""))
194 (const_int 0)))
195 (clobber (match_scratch:DI 2 ""))]
196 "TARGET_POWERPC64 && reload_completed"
197 [(set (match_dup 2)
198 (sign_extend:DI (match_dup 1)))
199 (set (match_dup 0)
200 (compare:CC (match_dup 2)
201 (const_int 0)))]
202 "")
51b8fc2c
RK
203
204(define_insn ""
9ebbca7d
GK
205 [(set (match_operand:CC 2 "cc_reg_operand" "=x,?y")
206 (compare:CC (sign_extend:DI (match_operand:QI 1 "gpc_reg_operand" "r,r"))
51b8fc2c 207 (const_int 0)))
9ebbca7d 208 (set (match_operand:DI 0 "gpc_reg_operand" "=r,r")
51b8fc2c 209 (sign_extend:DI (match_dup 1)))]
683bdff7 210 "TARGET_64BIT"
9ebbca7d
GK
211 "@
212 extsb. %0,%1
213 #"
214 [(set_attr "type" "compare")
215 (set_attr "length" "4,8")])
216
217(define_split
218 [(set (match_operand:CC 2 "cc_reg_not_cr0_operand" "")
219 (compare:CC (sign_extend:DI (match_operand:QI 1 "gpc_reg_operand" ""))
220 (const_int 0)))
221 (set (match_operand:DI 0 "gpc_reg_operand" "")
222 (sign_extend:DI (match_dup 1)))]
223 "TARGET_POWERPC64 && reload_completed"
224 [(set (match_dup 0)
225 (sign_extend:DI (match_dup 1)))
226 (set (match_dup 2)
227 (compare:CC (match_dup 0)
228 (const_int 0)))]
229 "")
51b8fc2c
RK
230
231(define_expand "zero_extendhidi2"
232 [(set (match_operand:DI 0 "gpc_reg_operand" "")
233 (zero_extend:DI (match_operand:HI 1 "gpc_reg_operand" "")))]
234 "TARGET_POWERPC64"
235 "")
236
237(define_insn ""
238 [(set (match_operand:DI 0 "gpc_reg_operand" "=r,r")
239 (zero_extend:DI (match_operand:HI 1 "reg_or_mem_operand" "m,r")))]
240 "TARGET_POWERPC64"
241 "@
242 lhz%U1%X1 %0,%1
4371f8af 243 rldicl %0,%1,0,48"
51b8fc2c
RK
244 [(set_attr "type" "load,*")])
245
246(define_insn ""
9ebbca7d
GK
247 [(set (match_operand:CC 0 "cc_reg_operand" "=x,?y")
248 (compare:CC (zero_extend:DI (match_operand:HI 1 "gpc_reg_operand" "r,r"))
51b8fc2c 249 (const_int 0)))
9ebbca7d 250 (clobber (match_scratch:DI 2 "=r,r"))]
683bdff7 251 "TARGET_64BIT"
9ebbca7d
GK
252 "@
253 rldicl. %2,%1,0,48
254 #"
255 [(set_attr "type" "compare")
256 (set_attr "length" "4,8")])
257
258(define_split
259 [(set (match_operand:CC 0 "cc_reg_not_cr0_operand" "")
260 (compare:CC (zero_extend:DI (match_operand:HI 1 "gpc_reg_operand" ""))
261 (const_int 0)))
262 (clobber (match_scratch:DI 2 ""))]
263 "TARGET_POWERPC64 && reload_completed"
264 [(set (match_dup 2)
265 (zero_extend:DI (match_dup 1)))
266 (set (match_dup 0)
267 (compare:CC (match_dup 2)
268 (const_int 0)))]
269 "")
51b8fc2c
RK
270
271(define_insn ""
9ebbca7d
GK
272 [(set (match_operand:CC 2 "cc_reg_operand" "=x,?y")
273 (compare:CC (zero_extend:DI (match_operand:HI 1 "gpc_reg_operand" "r,r"))
51b8fc2c 274 (const_int 0)))
9ebbca7d 275 (set (match_operand:DI 0 "gpc_reg_operand" "=r,r")
51b8fc2c 276 (zero_extend:DI (match_dup 1)))]
683bdff7 277 "TARGET_64BIT"
9ebbca7d
GK
278 "@
279 rldicl. %0,%1,0,48
280 #"
281 [(set_attr "type" "compare")
282 (set_attr "length" "4,8")])
283
284(define_split
285 [(set (match_operand:CC 2 "cc_reg_not_cr0_operand" "")
286 (compare:CC (zero_extend:DI (match_operand:HI 1 "gpc_reg_operand" ""))
287 (const_int 0)))
288 (set (match_operand:DI 0 "gpc_reg_operand" "")
289 (zero_extend:DI (match_dup 1)))]
290 "TARGET_POWERPC64 && reload_completed"
291 [(set (match_dup 0)
292 (zero_extend:DI (match_dup 1)))
293 (set (match_dup 2)
294 (compare:CC (match_dup 0)
295 (const_int 0)))]
296 "")
51b8fc2c
RK
297
298(define_expand "extendhidi2"
299 [(set (match_operand:DI 0 "gpc_reg_operand" "")
300 (sign_extend:DI (match_operand:HI 1 "gpc_reg_operand" "")))]
301 "TARGET_POWERPC64"
302 "")
303
304(define_insn ""
305 [(set (match_operand:DI 0 "gpc_reg_operand" "=r,r")
306 (sign_extend:DI (match_operand:HI 1 "reg_or_mem_operand" "m,r")))]
307 "TARGET_POWERPC64"
308 "@
309 lha%U1%X1 %0,%1
310 extsh %0,%1"
b54cf83a 311 [(set_attr "type" "load_ext,*")])
51b8fc2c
RK
312
313(define_insn ""
9ebbca7d
GK
314 [(set (match_operand:CC 0 "cc_reg_operand" "=x,?y")
315 (compare:CC (sign_extend:DI (match_operand:HI 1 "gpc_reg_operand" "r,r"))
51b8fc2c 316 (const_int 0)))
9ebbca7d 317 (clobber (match_scratch:DI 2 "=r,r"))]
683bdff7 318 "TARGET_64BIT"
9ebbca7d
GK
319 "@
320 extsh. %2,%1
321 #"
322 [(set_attr "type" "compare")
323 (set_attr "length" "4,8")])
324
325(define_split
326 [(set (match_operand:CC 0 "cc_reg_not_cr0_operand" "")
327 (compare:CC (sign_extend:DI (match_operand:HI 1 "gpc_reg_operand" ""))
328 (const_int 0)))
329 (clobber (match_scratch:DI 2 ""))]
330 "TARGET_POWERPC64 && reload_completed"
331 [(set (match_dup 2)
332 (sign_extend:DI (match_dup 1)))
333 (set (match_dup 0)
334 (compare:CC (match_dup 2)
335 (const_int 0)))]
336 "")
51b8fc2c
RK
337
338(define_insn ""
9ebbca7d
GK
339 [(set (match_operand:CC 2 "cc_reg_operand" "=x,?y")
340 (compare:CC (sign_extend:DI (match_operand:HI 1 "gpc_reg_operand" "r,r"))
51b8fc2c 341 (const_int 0)))
9ebbca7d 342 (set (match_operand:DI 0 "gpc_reg_operand" "=r,r")
51b8fc2c 343 (sign_extend:DI (match_dup 1)))]
683bdff7 344 "TARGET_64BIT"
9ebbca7d
GK
345 "@
346 extsh. %0,%1
347 #"
348 [(set_attr "type" "compare")
349 (set_attr "length" "4,8")])
350
351(define_split
352 [(set (match_operand:CC 2 "cc_reg_not_cr0_operand" "")
353 (compare:CC (sign_extend:DI (match_operand:HI 1 "gpc_reg_operand" ""))
354 (const_int 0)))
355 (set (match_operand:DI 0 "gpc_reg_operand" "")
356 (sign_extend:DI (match_dup 1)))]
357 "TARGET_POWERPC64 && reload_completed"
358 [(set (match_dup 0)
359 (sign_extend:DI (match_dup 1)))
360 (set (match_dup 2)
361 (compare:CC (match_dup 0)
362 (const_int 0)))]
363 "")
51b8fc2c
RK
364
365(define_expand "zero_extendsidi2"
366 [(set (match_operand:DI 0 "gpc_reg_operand" "")
367 (zero_extend:DI (match_operand:SI 1 "gpc_reg_operand" "")))]
368 "TARGET_POWERPC64"
369 "")
370
371(define_insn ""
372 [(set (match_operand:DI 0 "gpc_reg_operand" "=r,r")
373 (zero_extend:DI (match_operand:SI 1 "reg_or_mem_operand" "m,r")))]
374 "TARGET_POWERPC64"
375 "@
376 lwz%U1%X1 %0,%1
377 rldicl %0,%1,0,32"
378 [(set_attr "type" "load,*")])
379
380(define_insn ""
9ebbca7d
GK
381 [(set (match_operand:CC 0 "cc_reg_operand" "=x,?y")
382 (compare:CC (zero_extend:DI (match_operand:SI 1 "gpc_reg_operand" "r,r"))
51b8fc2c 383 (const_int 0)))
9ebbca7d 384 (clobber (match_scratch:DI 2 "=r,r"))]
683bdff7 385 "TARGET_64BIT"
9ebbca7d
GK
386 "@
387 rldicl. %2,%1,0,32
388 #"
389 [(set_attr "type" "compare")
390 (set_attr "length" "4,8")])
391
392(define_split
393 [(set (match_operand:CC 0 "cc_reg_not_cr0_operand" "")
394 (compare:CC (zero_extend:DI (match_operand:SI 1 "gpc_reg_operand" ""))
395 (const_int 0)))
396 (clobber (match_scratch:DI 2 ""))]
397 "TARGET_POWERPC64 && reload_completed"
398 [(set (match_dup 2)
399 (zero_extend:DI (match_dup 1)))
400 (set (match_dup 0)
401 (compare:CC (match_dup 2)
402 (const_int 0)))]
403 "")
51b8fc2c
RK
404
405(define_insn ""
9ebbca7d
GK
406 [(set (match_operand:CC 2 "cc_reg_operand" "=x,?y")
407 (compare:CC (zero_extend:DI (match_operand:SI 1 "gpc_reg_operand" "r,r"))
51b8fc2c 408 (const_int 0)))
9ebbca7d 409 (set (match_operand:DI 0 "gpc_reg_operand" "=r,r")
51b8fc2c 410 (zero_extend:DI (match_dup 1)))]
683bdff7 411 "TARGET_64BIT"
9ebbca7d
GK
412 "@
413 rldicl. %0,%1,0,32
414 #"
415 [(set_attr "type" "compare")
416 (set_attr "length" "4,8")])
417
418(define_split
419 [(set (match_operand:CC 2 "cc_reg_not_cr0_operand" "")
420 (compare:CC (zero_extend:DI (match_operand:SI 1 "gpc_reg_operand" ""))
421 (const_int 0)))
422 (set (match_operand:DI 0 "gpc_reg_operand" "")
423 (zero_extend:DI (match_dup 1)))]
424 "TARGET_POWERPC64 && reload_completed"
425 [(set (match_dup 0)
426 (zero_extend:DI (match_dup 1)))
427 (set (match_dup 2)
428 (compare:CC (match_dup 0)
429 (const_int 0)))]
430 "")
51b8fc2c
RK
431
432(define_expand "extendsidi2"
433 [(set (match_operand:DI 0 "gpc_reg_operand" "")
434 (sign_extend:DI (match_operand:SI 1 "gpc_reg_operand" "")))]
435 "TARGET_POWERPC64"
436 "")
437
438(define_insn ""
439 [(set (match_operand:DI 0 "gpc_reg_operand" "=r,r")
287f13ff 440 (sign_extend:DI (match_operand:SI 1 "lwa_operand" "m,r")))]
51b8fc2c
RK
441 "TARGET_POWERPC64"
442 "@
443 lwa%U1%X1 %0,%1
444 extsw %0,%1"
b54cf83a 445 [(set_attr "type" "load_ext,*")])
51b8fc2c
RK
446
447(define_insn ""
9ebbca7d
GK
448 [(set (match_operand:CC 0 "cc_reg_operand" "=x,?y")
449 (compare:CC (sign_extend:DI (match_operand:SI 1 "gpc_reg_operand" "r,r"))
51b8fc2c 450 (const_int 0)))
9ebbca7d 451 (clobber (match_scratch:DI 2 "=r,r"))]
683bdff7 452 "TARGET_64BIT"
9ebbca7d
GK
453 "@
454 extsw. %2,%1
455 #"
456 [(set_attr "type" "compare")
457 (set_attr "length" "4,8")])
458
459(define_split
460 [(set (match_operand:CC 0 "cc_reg_not_cr0_operand" "")
461 (compare:CC (sign_extend:DI (match_operand:SI 1 "gpc_reg_operand" ""))
462 (const_int 0)))
463 (clobber (match_scratch:DI 2 ""))]
464 "TARGET_POWERPC64 && reload_completed"
465 [(set (match_dup 2)
466 (sign_extend:DI (match_dup 1)))
467 (set (match_dup 0)
468 (compare:CC (match_dup 2)
469 (const_int 0)))]
470 "")
51b8fc2c
RK
471
472(define_insn ""
9ebbca7d
GK
473 [(set (match_operand:CC 2 "cc_reg_operand" "=x,?y")
474 (compare:CC (sign_extend:DI (match_operand:SI 1 "gpc_reg_operand" "r,r"))
51b8fc2c 475 (const_int 0)))
9ebbca7d 476 (set (match_operand:DI 0 "gpc_reg_operand" "=r,r")
51b8fc2c 477 (sign_extend:DI (match_dup 1)))]
683bdff7 478 "TARGET_64BIT"
9ebbca7d
GK
479 "@
480 extsw. %0,%1
481 #"
482 [(set_attr "type" "compare")
483 (set_attr "length" "4,8")])
484
485(define_split
486 [(set (match_operand:CC 2 "cc_reg_not_cr0_operand" "")
487 (compare:CC (sign_extend:DI (match_operand:SI 1 "gpc_reg_operand" ""))
488 (const_int 0)))
489 (set (match_operand:DI 0 "gpc_reg_operand" "")
490 (sign_extend:DI (match_dup 1)))]
491 "TARGET_POWERPC64 && reload_completed"
492 [(set (match_dup 0)
493 (sign_extend:DI (match_dup 1)))
494 (set (match_dup 2)
495 (compare:CC (match_dup 0)
496 (const_int 0)))]
497 "")
51b8fc2c 498
1fd4e8c1 499(define_expand "zero_extendqisi2"
cd2b37d9
RK
500 [(set (match_operand:SI 0 "gpc_reg_operand" "")
501 (zero_extend:SI (match_operand:QI 1 "gpc_reg_operand" "")))]
1fd4e8c1
RK
502 ""
503 "")
504
505(define_insn ""
cd2b37d9 506 [(set (match_operand:SI 0 "gpc_reg_operand" "=r,r")
1fd4e8c1
RK
507 (zero_extend:SI (match_operand:QI 1 "reg_or_mem_operand" "m,r")))]
508 ""
509 "@
510 lbz%U1%X1 %0,%1
005a35b9 511 {rlinm|rlwinm} %0,%1,0,0xff"
1fd4e8c1
RK
512 [(set_attr "type" "load,*")])
513
514(define_insn ""
9ebbca7d
GK
515 [(set (match_operand:CC 0 "cc_reg_operand" "=x,?y")
516 (compare:CC (zero_extend:SI (match_operand:QI 1 "gpc_reg_operand" "r,r"))
1fd4e8c1 517 (const_int 0)))
9ebbca7d 518 (clobber (match_scratch:SI 2 "=r,r"))]
1fd4e8c1 519 ""
9ebbca7d
GK
520 "@
521 {andil.|andi.} %2,%1,0xff
522 #"
523 [(set_attr "type" "compare")
524 (set_attr "length" "4,8")])
525
526(define_split
527 [(set (match_operand:CC 0 "cc_reg_not_cr0_operand" "")
528 (compare:CC (zero_extend:SI (match_operand:QI 1 "gpc_reg_operand" ""))
529 (const_int 0)))
530 (clobber (match_scratch:SI 2 ""))]
531 "reload_completed"
532 [(set (match_dup 2)
533 (zero_extend:SI (match_dup 1)))
534 (set (match_dup 0)
535 (compare:CC (match_dup 2)
536 (const_int 0)))]
537 "")
1fd4e8c1
RK
538
539(define_insn ""
9ebbca7d
GK
540 [(set (match_operand:CC 2 "cc_reg_operand" "=x,?y")
541 (compare:CC (zero_extend:SI (match_operand:QI 1 "gpc_reg_operand" "r,r"))
1fd4e8c1 542 (const_int 0)))
9ebbca7d 543 (set (match_operand:SI 0 "gpc_reg_operand" "=r,r")
1fd4e8c1
RK
544 (zero_extend:SI (match_dup 1)))]
545 ""
9ebbca7d
GK
546 "@
547 {andil.|andi.} %0,%1,0xff
548 #"
549 [(set_attr "type" "compare")
550 (set_attr "length" "4,8")])
551
552(define_split
553 [(set (match_operand:CC 2 "cc_reg_not_cr0_operand" "")
554 (compare:CC (zero_extend:SI (match_operand:QI 1 "gpc_reg_operand" ""))
555 (const_int 0)))
556 (set (match_operand:SI 0 "gpc_reg_operand" "")
557 (zero_extend:SI (match_dup 1)))]
558 "reload_completed"
559 [(set (match_dup 0)
560 (zero_extend:SI (match_dup 1)))
561 (set (match_dup 2)
562 (compare:CC (match_dup 0)
563 (const_int 0)))]
564 "")
1fd4e8c1 565
51b8fc2c
RK
566(define_expand "extendqisi2"
567 [(use (match_operand:SI 0 "gpc_reg_operand" ""))
568 (use (match_operand:QI 1 "gpc_reg_operand" ""))]
569 ""
570 "
571{
572 if (TARGET_POWERPC)
573 emit_insn (gen_extendqisi2_ppc (operands[0], operands[1]));
574 else if (TARGET_POWER)
575 emit_insn (gen_extendqisi2_power (operands[0], operands[1]));
576 else
577 emit_insn (gen_extendqisi2_no_power (operands[0], operands[1]));
578 DONE;
579}")
580
581(define_insn "extendqisi2_ppc"
2bee0449
RK
582 [(set (match_operand:SI 0 "gpc_reg_operand" "=r")
583 (sign_extend:SI (match_operand:QI 1 "gpc_reg_operand" "r")))]
51b8fc2c 584 "TARGET_POWERPC"
2bee0449 585 "extsb %0,%1")
51b8fc2c
RK
586
587(define_insn ""
9ebbca7d
GK
588 [(set (match_operand:CC 0 "cc_reg_operand" "=x,?y")
589 (compare:CC (sign_extend:SI (match_operand:QI 1 "gpc_reg_operand" "r,r"))
51b8fc2c 590 (const_int 0)))
9ebbca7d 591 (clobber (match_scratch:SI 2 "=r,r"))]
51b8fc2c 592 "TARGET_POWERPC"
9ebbca7d
GK
593 "@
594 extsb. %2,%1
595 #"
596 [(set_attr "type" "compare")
597 (set_attr "length" "4,8")])
598
599(define_split
600 [(set (match_operand:CC 0 "cc_reg_not_cr0_operand" "")
601 (compare:CC (sign_extend:SI (match_operand:QI 1 "gpc_reg_operand" ""))
602 (const_int 0)))
603 (clobber (match_scratch:SI 2 ""))]
604 "TARGET_POWERPC && reload_completed"
605 [(set (match_dup 2)
606 (sign_extend:SI (match_dup 1)))
607 (set (match_dup 0)
608 (compare:CC (match_dup 2)
609 (const_int 0)))]
610 "")
51b8fc2c
RK
611
612(define_insn ""
9ebbca7d
GK
613 [(set (match_operand:CC 2 "cc_reg_operand" "=x,?y")
614 (compare:CC (sign_extend:SI (match_operand:QI 1 "gpc_reg_operand" "r,r"))
51b8fc2c 615 (const_int 0)))
9ebbca7d 616 (set (match_operand:SI 0 "gpc_reg_operand" "=r,r")
51b8fc2c
RK
617 (sign_extend:SI (match_dup 1)))]
618 "TARGET_POWERPC"
9ebbca7d
GK
619 "@
620 extsb. %0,%1
621 #"
622 [(set_attr "type" "compare")
623 (set_attr "length" "4,8")])
624
625(define_split
626 [(set (match_operand:CC 2 "cc_reg_not_cr0_operand" "")
627 (compare:CC (sign_extend:SI (match_operand:QI 1 "gpc_reg_operand" ""))
628 (const_int 0)))
629 (set (match_operand:SI 0 "gpc_reg_operand" "")
630 (sign_extend:SI (match_dup 1)))]
631 "TARGET_POWERPC && reload_completed"
632 [(set (match_dup 0)
633 (sign_extend:SI (match_dup 1)))
634 (set (match_dup 2)
635 (compare:CC (match_dup 0)
636 (const_int 0)))]
637 "")
51b8fc2c
RK
638
639(define_expand "extendqisi2_power"
640 [(parallel [(set (match_dup 2)
641 (ashift:SI (match_operand:QI 1 "gpc_reg_operand" "")
642 (const_int 24)))
643 (clobber (scratch:SI))])
644 (parallel [(set (match_operand:SI 0 "gpc_reg_operand" "")
645 (ashiftrt:SI (match_dup 2)
646 (const_int 24)))
647 (clobber (scratch:SI))])]
648 "TARGET_POWER"
649 "
650{ operands[1] = gen_lowpart (SImode, operands[1]);
651 operands[2] = gen_reg_rtx (SImode); }")
652
653(define_expand "extendqisi2_no_power"
654 [(set (match_dup 2)
655 (ashift:SI (match_operand:QI 1 "gpc_reg_operand" "")
656 (const_int 24)))
657 (set (match_operand:SI 0 "gpc_reg_operand" "")
658 (ashiftrt:SI (match_dup 2)
659 (const_int 24)))]
660 "! TARGET_POWER && ! TARGET_POWERPC"
661 "
662{ operands[1] = gen_lowpart (SImode, operands[1]);
663 operands[2] = gen_reg_rtx (SImode); }")
664
1fd4e8c1 665(define_expand "zero_extendqihi2"
cd2b37d9
RK
666 [(set (match_operand:HI 0 "gpc_reg_operand" "")
667 (zero_extend:HI (match_operand:QI 1 "gpc_reg_operand" "")))]
1fd4e8c1
RK
668 ""
669 "")
670
671(define_insn ""
cd2b37d9 672 [(set (match_operand:HI 0 "gpc_reg_operand" "=r,r")
1fd4e8c1
RK
673 (zero_extend:HI (match_operand:QI 1 "reg_or_mem_operand" "m,r")))]
674 ""
675 "@
676 lbz%U1%X1 %0,%1
005a35b9 677 {rlinm|rlwinm} %0,%1,0,0xff"
51b8fc2c
RK
678 [(set_attr "type" "load,*")])
679
680(define_insn ""
9ebbca7d
GK
681 [(set (match_operand:CC 0 "cc_reg_operand" "=x,?y")
682 (compare:CC (zero_extend:HI (match_operand:QI 1 "gpc_reg_operand" "r,r"))
51b8fc2c 683 (const_int 0)))
9ebbca7d 684 (clobber (match_scratch:HI 2 "=r,r"))]
51b8fc2c 685 ""
9ebbca7d
GK
686 "@
687 {andil.|andi.} %2,%1,0xff
688 #"
689 [(set_attr "type" "compare")
690 (set_attr "length" "4,8")])
691
692(define_split
693 [(set (match_operand:CC 0 "cc_reg_not_cr0_operand" "")
694 (compare:CC (zero_extend:HI (match_operand:QI 1 "gpc_reg_operand" ""))
695 (const_int 0)))
696 (clobber (match_scratch:HI 2 ""))]
697 "reload_completed"
698 [(set (match_dup 2)
699 (zero_extend:HI (match_dup 1)))
700 (set (match_dup 0)
701 (compare:CC (match_dup 2)
702 (const_int 0)))]
703 "")
1fd4e8c1 704
51b8fc2c 705(define_insn ""
9ebbca7d
GK
706 [(set (match_operand:CC 2 "cc_reg_operand" "=x,?y")
707 (compare:CC (zero_extend:HI (match_operand:QI 1 "gpc_reg_operand" "r,r"))
51b8fc2c 708 (const_int 0)))
9ebbca7d 709 (set (match_operand:HI 0 "gpc_reg_operand" "=r,r")
815cdc52
MM
710 (zero_extend:HI (match_dup 1)))]
711 ""
9ebbca7d
GK
712 "@
713 {andil.|andi.} %0,%1,0xff
714 #"
715 [(set_attr "type" "compare")
716 (set_attr "length" "4,8")])
717
718(define_split
719 [(set (match_operand:CC 2 "cc_reg_not_cr0_operand" "")
720 (compare:CC (zero_extend:HI (match_operand:QI 1 "gpc_reg_operand" ""))
721 (const_int 0)))
722 (set (match_operand:HI 0 "gpc_reg_operand" "")
723 (zero_extend:HI (match_dup 1)))]
724 "reload_completed"
725 [(set (match_dup 0)
726 (zero_extend:HI (match_dup 1)))
727 (set (match_dup 2)
728 (compare:CC (match_dup 0)
729 (const_int 0)))]
730 "")
815cdc52
MM
731
732(define_expand "extendqihi2"
733 [(use (match_operand:HI 0 "gpc_reg_operand" ""))
734 (use (match_operand:QI 1 "gpc_reg_operand" ""))]
735 ""
736 "
737{
738 if (TARGET_POWERPC)
739 emit_insn (gen_extendqihi2_ppc (operands[0], operands[1]));
740 else if (TARGET_POWER)
741 emit_insn (gen_extendqihi2_power (operands[0], operands[1]));
742 else
743 emit_insn (gen_extendqihi2_no_power (operands[0], operands[1]));
744 DONE;
745}")
746
747(define_insn "extendqihi2_ppc"
748 [(set (match_operand:HI 0 "gpc_reg_operand" "=r")
749 (sign_extend:HI (match_operand:QI 1 "gpc_reg_operand" "r")))]
750 "TARGET_POWERPC"
751 "extsb %0,%1")
752
753(define_insn ""
9ebbca7d
GK
754 [(set (match_operand:CC 0 "cc_reg_operand" "=x,?y")
755 (compare:CC (sign_extend:HI (match_operand:QI 1 "gpc_reg_operand" "r,r"))
815cdc52 756 (const_int 0)))
9ebbca7d 757 (clobber (match_scratch:HI 2 "=r,r"))]
815cdc52 758 "TARGET_POWERPC"
9ebbca7d
GK
759 "@
760 extsb. %2,%1
761 #"
762 [(set_attr "type" "compare")
763 (set_attr "length" "4,8")])
764
765(define_split
766 [(set (match_operand:CC 0 "cc_reg_not_cr0_operand" "")
767 (compare:CC (sign_extend:HI (match_operand:QI 1 "gpc_reg_operand" ""))
768 (const_int 0)))
769 (clobber (match_scratch:HI 2 ""))]
770 "TARGET_POWERPC && reload_completed"
771 [(set (match_dup 2)
772 (sign_extend:HI (match_dup 1)))
773 (set (match_dup 0)
774 (compare:CC (match_dup 2)
775 (const_int 0)))]
776 "")
815cdc52
MM
777
778(define_insn ""
9ebbca7d
GK
779 [(set (match_operand:CC 2 "cc_reg_operand" "=x,?y")
780 (compare:CC (sign_extend:HI (match_operand:QI 1 "gpc_reg_operand" "r,r"))
51b8fc2c 781 (const_int 0)))
9ebbca7d 782 (set (match_operand:HI 0 "gpc_reg_operand" "=r,r")
51b8fc2c
RK
783 (sign_extend:HI (match_dup 1)))]
784 "TARGET_POWERPC"
9ebbca7d
GK
785 "@
786 extsb. %0,%1
787 #"
788 [(set_attr "type" "compare")
789 (set_attr "length" "4,8")])
790
791(define_split
792 [(set (match_operand:CC 2 "cc_reg_not_cr0_operand" "")
793 (compare:CC (sign_extend:HI (match_operand:QI 1 "gpc_reg_operand" ""))
794 (const_int 0)))
795 (set (match_operand:HI 0 "gpc_reg_operand" "")
796 (sign_extend:HI (match_dup 1)))]
797 "TARGET_POWERPC && reload_completed"
798 [(set (match_dup 0)
799 (sign_extend:HI (match_dup 1)))
800 (set (match_dup 2)
801 (compare:CC (match_dup 0)
802 (const_int 0)))]
803 "")
51b8fc2c
RK
804
805(define_expand "extendqihi2_power"
806 [(parallel [(set (match_dup 2)
807 (ashift:SI (match_operand:QI 1 "gpc_reg_operand" "")
808 (const_int 24)))
809 (clobber (scratch:SI))])
810 (parallel [(set (match_operand:HI 0 "gpc_reg_operand" "")
811 (ashiftrt:SI (match_dup 2)
812 (const_int 24)))
813 (clobber (scratch:SI))])]
814 "TARGET_POWER"
815 "
816{ operands[0] = gen_lowpart (SImode, operands[0]);
817 operands[1] = gen_lowpart (SImode, operands[1]);
818 operands[2] = gen_reg_rtx (SImode); }")
819
820(define_expand "extendqihi2_no_power"
821 [(set (match_dup 2)
822 (ashift:SI (match_operand:QI 1 "gpc_reg_operand" "")
823 (const_int 24)))
824 (set (match_operand:HI 0 "gpc_reg_operand" "")
825 (ashiftrt:SI (match_dup 2)
826 (const_int 24)))]
827 "! TARGET_POWER && ! TARGET_POWERPC"
828 "
829{ operands[0] = gen_lowpart (SImode, operands[0]);
830 operands[1] = gen_lowpart (SImode, operands[1]);
831 operands[2] = gen_reg_rtx (SImode); }")
832
1fd4e8c1 833(define_expand "zero_extendhisi2"
5f243543 834 [(set (match_operand:SI 0 "gpc_reg_operand" "")
cd2b37d9 835 (zero_extend:SI (match_operand:HI 1 "gpc_reg_operand" "")))]
1fd4e8c1
RK
836 ""
837 "")
838
839(define_insn ""
cd2b37d9 840 [(set (match_operand:SI 0 "gpc_reg_operand" "=r,r")
1fd4e8c1
RK
841 (zero_extend:SI (match_operand:HI 1 "reg_or_mem_operand" "m,r")))]
842 ""
843 "@
844 lhz%U1%X1 %0,%1
005a35b9 845 {rlinm|rlwinm} %0,%1,0,0xffff"
1fd4e8c1
RK
846 [(set_attr "type" "load,*")])
847
848(define_insn ""
9ebbca7d
GK
849 [(set (match_operand:CC 0 "cc_reg_operand" "=x,?y")
850 (compare:CC (zero_extend:SI (match_operand:HI 1 "gpc_reg_operand" "r,r"))
1fd4e8c1 851 (const_int 0)))
9ebbca7d 852 (clobber (match_scratch:SI 2 "=r,r"))]
1fd4e8c1 853 ""
9ebbca7d
GK
854 "@
855 {andil.|andi.} %2,%1,0xffff
856 #"
857 [(set_attr "type" "compare")
858 (set_attr "length" "4,8")])
859
860(define_split
861 [(set (match_operand:CC 0 "cc_reg_not_cr0_operand" "")
862 (compare:CC (zero_extend:SI (match_operand:HI 1 "gpc_reg_operand" ""))
863 (const_int 0)))
864 (clobber (match_scratch:SI 2 ""))]
865 "reload_completed"
866 [(set (match_dup 2)
867 (zero_extend:SI (match_dup 1)))
868 (set (match_dup 0)
869 (compare:CC (match_dup 2)
870 (const_int 0)))]
871 "")
1fd4e8c1
RK
872
873(define_insn ""
9ebbca7d
GK
874 [(set (match_operand:CC 2 "cc_reg_operand" "=x,?y")
875 (compare:CC (zero_extend:SI (match_operand:HI 1 "gpc_reg_operand" "r,r"))
1fd4e8c1 876 (const_int 0)))
9ebbca7d 877 (set (match_operand:SI 0 "gpc_reg_operand" "=r,r")
1fd4e8c1
RK
878 (zero_extend:SI (match_dup 1)))]
879 ""
9ebbca7d
GK
880 "@
881 {andil.|andi.} %0,%1,0xffff
882 #"
883 [(set_attr "type" "compare")
884 (set_attr "length" "4,8")])
885
886(define_split
887 [(set (match_operand:CC 2 "cc_reg_not_cr0_operand" "")
888 (compare:CC (zero_extend:SI (match_operand:HI 1 "gpc_reg_operand" ""))
889 (const_int 0)))
890 (set (match_operand:SI 0 "gpc_reg_operand" "")
891 (zero_extend:SI (match_dup 1)))]
892 "reload_completed"
893 [(set (match_dup 0)
894 (zero_extend:SI (match_dup 1)))
895 (set (match_dup 2)
896 (compare:CC (match_dup 0)
897 (const_int 0)))]
898 "")
1fd4e8c1
RK
899
900(define_expand "extendhisi2"
cd2b37d9
RK
901 [(set (match_operand:SI 0 "gpc_reg_operand" "")
902 (sign_extend:SI (match_operand:HI 1 "gpc_reg_operand" "")))]
1fd4e8c1
RK
903 ""
904 "")
905
906(define_insn ""
cd2b37d9 907 [(set (match_operand:SI 0 "gpc_reg_operand" "=r,r")
1fd4e8c1
RK
908 (sign_extend:SI (match_operand:HI 1 "reg_or_mem_operand" "m,r")))]
909 ""
910 "@
911 lha%U1%X1 %0,%1
ca7f5001 912 {exts|extsh} %0,%1"
b54cf83a 913 [(set_attr "type" "load_ext,*")])
1fd4e8c1
RK
914
915(define_insn ""
9ebbca7d
GK
916 [(set (match_operand:CC 0 "cc_reg_operand" "=x,?y")
917 (compare:CC (sign_extend:SI (match_operand:HI 1 "gpc_reg_operand" "r,r"))
1fd4e8c1 918 (const_int 0)))
9ebbca7d 919 (clobber (match_scratch:SI 2 "=r,r"))]
1fd4e8c1 920 ""
9ebbca7d
GK
921 "@
922 {exts.|extsh.} %2,%1
923 #"
924 [(set_attr "type" "compare")
925 (set_attr "length" "4,8")])
926
927(define_split
928 [(set (match_operand:CC 0 "cc_reg_not_cr0_operand" "")
929 (compare:CC (sign_extend:SI (match_operand:HI 1 "gpc_reg_operand" ""))
930 (const_int 0)))
931 (clobber (match_scratch:SI 2 ""))]
932 "reload_completed"
933 [(set (match_dup 2)
934 (sign_extend:SI (match_dup 1)))
935 (set (match_dup 0)
936 (compare:CC (match_dup 2)
937 (const_int 0)))]
938 "")
1fd4e8c1
RK
939
940(define_insn ""
9ebbca7d
GK
941 [(set (match_operand:CC 2 "cc_reg_operand" "=x,?y")
942 (compare:CC (sign_extend:SI (match_operand:HI 1 "gpc_reg_operand" "r,r"))
1fd4e8c1 943 (const_int 0)))
9ebbca7d 944 (set (match_operand:SI 0 "gpc_reg_operand" "=r,r")
1fd4e8c1
RK
945 (sign_extend:SI (match_dup 1)))]
946 ""
9ebbca7d
GK
947 "@
948 {exts.|extsh.} %0,%1
949 #"
950 [(set_attr "type" "compare")
951 (set_attr "length" "4,8")])
1fd4e8c1 952\f
9ebbca7d
GK
953(define_split
954 [(set (match_operand:CC 2 "cc_reg_not_cr0_operand" "")
955 (compare:CC (sign_extend:SI (match_operand:HI 1 "gpc_reg_operand" ""))
956 (const_int 0)))
957 (set (match_operand:SI 0 "gpc_reg_operand" "")
958 (sign_extend:SI (match_dup 1)))]
959 "reload_completed"
960 [(set (match_dup 0)
961 (sign_extend:SI (match_dup 1)))
962 (set (match_dup 2)
963 (compare:CC (match_dup 0)
964 (const_int 0)))]
965 "")
966
1fd4e8c1 967;; Fixed-point arithmetic insns.
deb9225a
RK
968
969;; Discourage ai/addic because of carry but provide it in an alternative
970;; allowing register zero as source.
7cd5235b
MM
971(define_expand "addsi3"
972 [(set (match_operand:SI 0 "gpc_reg_operand" "")
973 (plus:SI (match_operand:SI 1 "gpc_reg_operand" "")
f6bf7de2 974 (match_operand:SI 2 "reg_or_arith_cint_operand" "")))]
7cd5235b
MM
975 ""
976 "
977{
677a9668
DE
978 if (GET_CODE (operands[2]) == CONST_INT
979 && ! add_operand (operands[2], SImode))
7cd5235b 980 {
677a9668 981 rtx tmp = ((no_new_pseudos || rtx_equal_p (operands[0], operands[1]))
7cd5235b
MM
982 ? operands[0] : gen_reg_rtx (SImode));
983
2bfcf297 984 HOST_WIDE_INT val = INTVAL (operands[2]);
a65c591c 985 HOST_WIDE_INT low = ((val & 0xffff) ^ 0x8000) - 0x8000;
2bfcf297 986 HOST_WIDE_INT rest = trunc_int_for_mode (val - low, SImode);
7cd5235b 987
9ebbca7d
GK
988 /* The ordering here is important for the prolog expander.
989 When space is allocated from the stack, adding 'low' first may
990 produce a temporary deallocation (which would be bad). */
2bfcf297 991 emit_insn (gen_addsi3 (tmp, operands[1], GEN_INT (rest)));
7cd5235b
MM
992 emit_insn (gen_addsi3 (operands[0], tmp, GEN_INT (low)));
993 DONE;
994 }
995}")
996
997(define_insn "*addsi3_internal1"
998 [(set (match_operand:SI 0 "gpc_reg_operand" "=r,r,?r,r")
999 (plus:SI (match_operand:SI 1 "gpc_reg_operand" "%r,b,r,b")
9615f239 1000 (match_operand:SI 2 "add_operand" "r,I,I,L")))]
1fd4e8c1
RK
1001 ""
1002 "@
deb9225a
RK
1003 {cax|add} %0,%1,%2
1004 {cal %0,%2(%1)|addi %0,%1,%2}
1005 {ai|addic} %0,%1,%2
7cd5235b
MM
1006 {cau|addis} %0,%1,%v2"
1007 [(set_attr "length" "4,4,4,4")])
1fd4e8c1 1008
ee890fe2
SS
1009(define_insn "addsi3_high"
1010 [(set (match_operand:SI 0 "gpc_reg_operand" "=b")
1011 (plus:SI (match_operand:SI 1 "gpc_reg_operand" "b")
1012 (high:SI (match_operand 2 "" ""))))]
1013 "TARGET_MACHO && !TARGET_64BIT"
1014 "{cau|addis} %0,%1,ha16(%2)"
1015 [(set_attr "length" "4")])
1016
7cd5235b 1017(define_insn "*addsi3_internal2"
cb8cc086
MM
1018 [(set (match_operand:CC 0 "cc_reg_operand" "=x,x,?y,?y")
1019 (compare:CC (plus:SI (match_operand:SI 1 "gpc_reg_operand" "%r,r,r,r")
1020 (match_operand:SI 2 "reg_or_short_operand" "r,I,r,I"))
1fd4e8c1 1021 (const_int 0)))
cb8cc086 1022 (clobber (match_scratch:SI 3 "=r,r,r,r"))]
0ad91047 1023 "! TARGET_POWERPC64"
deb9225a
RK
1024 "@
1025 {cax.|add.} %3,%1,%2
cb8cc086
MM
1026 {ai.|addic.} %3,%1,%2
1027 #
1028 #"
a62bfff2 1029 [(set_attr "type" "fast_compare,compare,compare,compare")
cb8cc086
MM
1030 (set_attr "length" "4,4,8,8")])
1031
1032(define_split
1033 [(set (match_operand:CC 0 "cc_reg_not_cr0_operand" "")
1034 (compare:CC (plus:SI (match_operand:SI 1 "gpc_reg_operand" "")
1035 (match_operand:SI 2 "reg_or_short_operand" ""))
1036 (const_int 0)))
1037 (clobber (match_scratch:SI 3 ""))]
0ad91047 1038 "! TARGET_POWERPC64 && reload_completed"
cb8cc086
MM
1039 [(set (match_dup 3)
1040 (plus:SI (match_dup 1)
1041 (match_dup 2)))
1042 (set (match_dup 0)
1043 (compare:CC (match_dup 3)
1044 (const_int 0)))]
1045 "")
7e69e155 1046
7cd5235b 1047(define_insn "*addsi3_internal3"
cb8cc086
MM
1048 [(set (match_operand:CC 3 "cc_reg_operand" "=x,x,?y,?y")
1049 (compare:CC (plus:SI (match_operand:SI 1 "gpc_reg_operand" "%r,r,r,r")
1050 (match_operand:SI 2 "reg_or_short_operand" "r,I,r,I"))
1fd4e8c1 1051 (const_int 0)))
cb8cc086
MM
1052 (set (match_operand:SI 0 "gpc_reg_operand" "=r,r,r,r")
1053 (plus:SI (match_dup 1)
1054 (match_dup 2)))]
0ad91047 1055 "! TARGET_POWERPC64"
deb9225a
RK
1056 "@
1057 {cax.|add.} %0,%1,%2
cb8cc086
MM
1058 {ai.|addic.} %0,%1,%2
1059 #
1060 #"
a62bfff2 1061 [(set_attr "type" "fast_compare,compare,compare,compare")
cb8cc086
MM
1062 (set_attr "length" "4,4,8,8")])
1063
1064(define_split
1065 [(set (match_operand:CC 3 "cc_reg_not_cr0_operand" "")
1066 (compare:CC (plus:SI (match_operand:SI 1 "gpc_reg_operand" "")
1067 (match_operand:SI 2 "reg_or_short_operand" ""))
1068 (const_int 0)))
1069 (set (match_operand:SI 0 "gpc_reg_operand" "")
1070 (plus:SI (match_dup 1) (match_dup 2)))]
0ad91047 1071 "! TARGET_POWERPC64 && reload_completed"
cb8cc086
MM
1072 [(set (match_dup 0)
1073 (plus:SI (match_dup 1)
1074 (match_dup 2)))
1075 (set (match_dup 3)
1076 (compare:CC (match_dup 0)
1077 (const_int 0)))]
1078 "")
7e69e155 1079
f357808b
RK
1080;; Split an add that we can't do in one insn into two insns, each of which
1081;; does one 16-bit part. This is used by combine. Note that the low-order
1082;; add should be last in case the result gets used in an address.
1083
1084(define_split
cd2b37d9
RK
1085 [(set (match_operand:SI 0 "gpc_reg_operand" "")
1086 (plus:SI (match_operand:SI 1 "gpc_reg_operand" "")
f357808b 1087 (match_operand:SI 2 "non_add_cint_operand" "")))]
1fd4e8c1 1088 ""
f357808b
RK
1089 [(set (match_dup 0) (plus:SI (match_dup 1) (match_dup 3)))
1090 (set (match_dup 0) (plus:SI (match_dup 0) (match_dup 4)))]
1091"
1fd4e8c1 1092{
2bfcf297 1093 HOST_WIDE_INT val = INTVAL (operands[2]);
a65c591c 1094 HOST_WIDE_INT low = ((val & 0xffff) ^ 0x8000) - 0x8000;
2bfcf297 1095 HOST_WIDE_INT rest = trunc_int_for_mode (val - low, SImode);
1fd4e8c1 1096
2bfcf297 1097 operands[3] = GEN_INT (rest);
e6ca2c17 1098 operands[4] = GEN_INT (low);
1fd4e8c1
RK
1099}")
1100
8de2a197 1101(define_insn "one_cmplsi2"
cd2b37d9
RK
1102 [(set (match_operand:SI 0 "gpc_reg_operand" "=r")
1103 (not:SI (match_operand:SI 1 "gpc_reg_operand" "r")))]
1fd4e8c1 1104 ""
ca7f5001
RK
1105 "nor %0,%1,%1")
1106
1107(define_insn ""
52d3af72
DE
1108 [(set (match_operand:CC 0 "cc_reg_operand" "=x,?y")
1109 (compare:CC (not:SI (match_operand:SI 1 "gpc_reg_operand" "r,r"))
ca7f5001 1110 (const_int 0)))
52d3af72 1111 (clobber (match_scratch:SI 2 "=r,r"))]
0ad91047 1112 "! TARGET_POWERPC64"
52d3af72
DE
1113 "@
1114 nor. %2,%1,%1
1115 #"
1116 [(set_attr "type" "compare")
1117 (set_attr "length" "4,8")])
1118
1119(define_split
1120 [(set (match_operand:CC 0 "cc_reg_not_cr0_operand" "")
1121 (compare:CC (not:SI (match_operand:SI 1 "gpc_reg_operand" ""))
1122 (const_int 0)))
1123 (clobber (match_scratch:SI 2 ""))]
0ad91047 1124 "! TARGET_POWERPC64 && reload_completed"
52d3af72
DE
1125 [(set (match_dup 2)
1126 (not:SI (match_dup 1)))
1127 (set (match_dup 0)
1128 (compare:CC (match_dup 2)
1129 (const_int 0)))]
1130 "")
ca7f5001
RK
1131
1132(define_insn ""
52d3af72
DE
1133 [(set (match_operand:CC 2 "cc_reg_operand" "=x,?y")
1134 (compare:CC (not:SI (match_operand:SI 1 "gpc_reg_operand" "r,r"))
815cdc52 1135 (const_int 0)))
52d3af72 1136 (set (match_operand:SI 0 "gpc_reg_operand" "=r,r")
815cdc52 1137 (not:SI (match_dup 1)))]
0ad91047 1138 "! TARGET_POWERPC64"
52d3af72
DE
1139 "@
1140 nor. %0,%1,%1
1141 #"
1142 [(set_attr "type" "compare")
1143 (set_attr "length" "4,8")])
1144
1145(define_split
1146 [(set (match_operand:CC 2 "cc_reg_not_cr0_operand" "")
1147 (compare:CC (not:SI (match_operand:SI 1 "gpc_reg_operand" ""))
1148 (const_int 0)))
1cb18e3c 1149 (set (match_operand:SI 0 "gpc_reg_operand" "")
52d3af72 1150 (not:SI (match_dup 1)))]
0ad91047 1151 "! TARGET_POWERPC64 && reload_completed"
52d3af72
DE
1152 [(set (match_dup 0)
1153 (not:SI (match_dup 1)))
1154 (set (match_dup 2)
1155 (compare:CC (match_dup 0)
1156 (const_int 0)))]
1157 "")
1fd4e8c1
RK
1158
1159(define_insn ""
3d91674b
RK
1160 [(set (match_operand:SI 0 "gpc_reg_operand" "=r")
1161 (minus:SI (match_operand:SI 1 "reg_or_short_operand" "rI")
1162 (match_operand:SI 2 "gpc_reg_operand" "r")))]
deb9225a 1163 "! TARGET_POWERPC"
ca7f5001 1164 "{sf%I1|subf%I1c} %0,%2,%1")
1fd4e8c1 1165
deb9225a
RK
1166(define_insn ""
1167 [(set (match_operand:SI 0 "gpc_reg_operand" "=r,r")
1168 (minus:SI (match_operand:SI 1 "reg_or_short_operand" "r,I")
1169 (match_operand:SI 2 "gpc_reg_operand" "r,r")))]
1170 "TARGET_POWERPC"
1171 "@
1172 subf %0,%2,%1
1173 subfic %0,%2,%1")
1174
1fd4e8c1 1175(define_insn ""
cb8cc086
MM
1176 [(set (match_operand:CC 0 "cc_reg_operand" "=x,?y")
1177 (compare:CC (minus:SI (match_operand:SI 1 "gpc_reg_operand" "r,r")
1178 (match_operand:SI 2 "gpc_reg_operand" "r,r"))
1fd4e8c1 1179 (const_int 0)))
cb8cc086 1180 (clobber (match_scratch:SI 3 "=r,r"))]
deb9225a 1181 "! TARGET_POWERPC"
cb8cc086
MM
1182 "@
1183 {sf.|subfc.} %3,%2,%1
1184 #"
1185 [(set_attr "type" "compare")
1186 (set_attr "length" "4,8")])
1fd4e8c1 1187
deb9225a 1188(define_insn ""
cb8cc086
MM
1189 [(set (match_operand:CC 0 "cc_reg_operand" "=x,?y")
1190 (compare:CC (minus:SI (match_operand:SI 1 "gpc_reg_operand" "r,r")
1191 (match_operand:SI 2 "gpc_reg_operand" "r,r"))
deb9225a 1192 (const_int 0)))
cb8cc086 1193 (clobber (match_scratch:SI 3 "=r,r"))]
0ad91047 1194 "TARGET_POWERPC && ! TARGET_POWERPC64"
cb8cc086
MM
1195 "@
1196 subf. %3,%2,%1
1197 #"
a62bfff2 1198 [(set_attr "type" "fast_compare")
cb8cc086
MM
1199 (set_attr "length" "4,8")])
1200
1201(define_split
1202 [(set (match_operand:CC 0 "cc_reg_not_cr0_operand" "")
1203 (compare:CC (minus:SI (match_operand:SI 1 "gpc_reg_operand" "")
1204 (match_operand:SI 2 "gpc_reg_operand" ""))
1205 (const_int 0)))
1206 (clobber (match_scratch:SI 3 ""))]
0ad91047 1207 "! TARGET_POWERPC64 && reload_completed"
cb8cc086
MM
1208 [(set (match_dup 3)
1209 (minus:SI (match_dup 1)
1210 (match_dup 2)))
1211 (set (match_dup 0)
1212 (compare:CC (match_dup 3)
1213 (const_int 0)))]
1214 "")
deb9225a 1215
1fd4e8c1 1216(define_insn ""
cb8cc086
MM
1217 [(set (match_operand:CC 3 "cc_reg_operand" "=x,?y")
1218 (compare:CC (minus:SI (match_operand:SI 1 "gpc_reg_operand" "r,r")
1219 (match_operand:SI 2 "gpc_reg_operand" "r,r"))
1fd4e8c1 1220 (const_int 0)))
cb8cc086 1221 (set (match_operand:SI 0 "gpc_reg_operand" "=r,r")
1fd4e8c1 1222 (minus:SI (match_dup 1) (match_dup 2)))]
deb9225a 1223 "! TARGET_POWERPC"
cb8cc086
MM
1224 "@
1225 {sf.|subfc.} %0,%2,%1
1226 #"
1227 [(set_attr "type" "compare")
1228 (set_attr "length" "4,8")])
815cdc52 1229
29ae5b89 1230(define_insn ""
cb8cc086
MM
1231 [(set (match_operand:CC 3 "cc_reg_operand" "=x,?y")
1232 (compare:CC (minus:SI (match_operand:SI 1 "gpc_reg_operand" "r,r")
1233 (match_operand:SI 2 "gpc_reg_operand" "r,r"))
815cdc52 1234 (const_int 0)))
cb8cc086
MM
1235 (set (match_operand:SI 0 "gpc_reg_operand" "=r,r")
1236 (minus:SI (match_dup 1)
1237 (match_dup 2)))]
0ad91047 1238 "TARGET_POWERPC && ! TARGET_POWERPC64"
90612787
DE
1239 "@
1240 subf. %0,%2,%1
1241 #"
a62bfff2 1242 [(set_attr "type" "fast_compare")
cb8cc086
MM
1243 (set_attr "length" "4,8")])
1244
1245(define_split
1246 [(set (match_operand:CC 3 "cc_reg_not_cr0_operand" "")
1247 (compare:CC (minus:SI (match_operand:SI 1 "gpc_reg_operand" "")
1248 (match_operand:SI 2 "gpc_reg_operand" ""))
1249 (const_int 0)))
1250 (set (match_operand:SI 0 "gpc_reg_operand" "")
1251 (minus:SI (match_dup 1)
1252 (match_dup 2)))]
0ad91047 1253 "! TARGET_POWERPC64 && reload_completed"
cb8cc086
MM
1254 [(set (match_dup 0)
1255 (minus:SI (match_dup 1)
1256 (match_dup 2)))
1257 (set (match_dup 3)
1258 (compare:CC (match_dup 0)
1259 (const_int 0)))]
1260 "")
deb9225a 1261
1fd4e8c1 1262(define_expand "subsi3"
cd2b37d9 1263 [(set (match_operand:SI 0 "gpc_reg_operand" "")
1fd4e8c1 1264 (minus:SI (match_operand:SI 1 "reg_or_short_operand" "")
f6bf7de2 1265 (match_operand:SI 2 "reg_or_arith_cint_operand" "")))]
1fd4e8c1 1266 ""
a0044fb1
RK
1267 "
1268{
1269 if (GET_CODE (operands[2]) == CONST_INT)
1270 {
1271 emit_insn (gen_addsi3 (operands[0], operands[1],
1272 negate_rtx (SImode, operands[2])));
1273 DONE;
1274 }
1275}")
1fd4e8c1
RK
1276
1277;; For SMIN, SMAX, UMIN, and UMAX, we use DEFINE_EXPAND's that involve a doz[i]
1278;; instruction and some auxiliary computations. Then we just have a single
95ac8e67
RK
1279;; DEFINE_INSN for doz[i] and the define_splits to make them if made by
1280;; combine.
1fd4e8c1
RK
1281
1282(define_expand "sminsi3"
1283 [(set (match_dup 3)
cd2b37d9 1284 (if_then_else:SI (gt:SI (match_operand:SI 1 "gpc_reg_operand" "")
1fd4e8c1
RK
1285 (match_operand:SI 2 "reg_or_short_operand" ""))
1286 (const_int 0)
1287 (minus:SI (match_dup 2) (match_dup 1))))
cd2b37d9 1288 (set (match_operand:SI 0 "gpc_reg_operand" "")
1fd4e8c1 1289 (minus:SI (match_dup 2) (match_dup 3)))]
a3170dc6 1290 "TARGET_POWER || TARGET_ISEL"
1fd4e8c1 1291 "
a3170dc6
AH
1292{
1293 if (TARGET_ISEL)
1294 {
1295 operands[2] = force_reg (SImode, operands[2]);
1296 rs6000_emit_minmax (operands[0], SMIN, operands[1], operands[2]);
1297 DONE;
1298 }
1299
1300 operands[3] = gen_reg_rtx (SImode);
1301}")
1fd4e8c1 1302
95ac8e67
RK
1303(define_split
1304 [(set (match_operand:SI 0 "gpc_reg_operand" "")
1305 (smin:SI (match_operand:SI 1 "gpc_reg_operand" "")
1306 (match_operand:SI 2 "reg_or_short_operand" "")))
1307 (clobber (match_operand:SI 3 "gpc_reg_operand" ""))]
ca7f5001 1308 "TARGET_POWER"
95ac8e67
RK
1309 [(set (match_dup 3)
1310 (if_then_else:SI (gt:SI (match_dup 1) (match_dup 2))
1311 (const_int 0)
1312 (minus:SI (match_dup 2) (match_dup 1))))
1313 (set (match_dup 0) (minus:SI (match_dup 2) (match_dup 3)))]
1314 "")
1315
1fd4e8c1
RK
1316(define_expand "smaxsi3"
1317 [(set (match_dup 3)
cd2b37d9 1318 (if_then_else:SI (gt:SI (match_operand:SI 1 "gpc_reg_operand" "")
1fd4e8c1
RK
1319 (match_operand:SI 2 "reg_or_short_operand" ""))
1320 (const_int 0)
1321 (minus:SI (match_dup 2) (match_dup 1))))
cd2b37d9 1322 (set (match_operand:SI 0 "gpc_reg_operand" "")
1fd4e8c1 1323 (plus:SI (match_dup 3) (match_dup 1)))]
a3170dc6 1324 "TARGET_POWER || TARGET_ISEL"
1fd4e8c1 1325 "
a3170dc6
AH
1326{
1327 if (TARGET_ISEL)
1328 {
1329 operands[2] = force_reg (SImode, operands[2]);
1330 rs6000_emit_minmax (operands[0], SMAX, operands[1], operands[2]);
1331 DONE;
1332 }
1333 operands[3] = gen_reg_rtx (SImode);
1334}")
1fd4e8c1 1335
95ac8e67
RK
1336(define_split
1337 [(set (match_operand:SI 0 "gpc_reg_operand" "")
1338 (smax:SI (match_operand:SI 1 "gpc_reg_operand" "")
1339 (match_operand:SI 2 "reg_or_short_operand" "")))
1340 (clobber (match_operand:SI 3 "gpc_reg_operand" ""))]
ca7f5001 1341 "TARGET_POWER"
95ac8e67
RK
1342 [(set (match_dup 3)
1343 (if_then_else:SI (gt:SI (match_dup 1) (match_dup 2))
1344 (const_int 0)
1345 (minus:SI (match_dup 2) (match_dup 1))))
1346 (set (match_dup 0) (plus:SI (match_dup 3) (match_dup 1)))]
1347 "")
1348
1fd4e8c1 1349(define_expand "uminsi3"
cd2b37d9 1350 [(set (match_dup 3) (xor:SI (match_operand:SI 1 "gpc_reg_operand" "")
bb68ff55 1351 (match_dup 5)))
cd2b37d9 1352 (set (match_dup 4) (xor:SI (match_operand:SI 2 "gpc_reg_operand" "")
bb68ff55 1353 (match_dup 5)))
1fd4e8c1
RK
1354 (set (match_dup 3) (if_then_else:SI (gt (match_dup 3) (match_dup 4))
1355 (const_int 0)
1356 (minus:SI (match_dup 4) (match_dup 3))))
cd2b37d9 1357 (set (match_operand:SI 0 "gpc_reg_operand" "")
1fd4e8c1 1358 (minus:SI (match_dup 2) (match_dup 3)))]
a3170dc6 1359 "TARGET_POWER || TARGET_ISEL"
1fd4e8c1 1360 "
bb68ff55 1361{
a3170dc6
AH
1362 if (TARGET_ISEL)
1363 {
1364 rs6000_emit_minmax (operands[0], UMIN, operands[1], operands[2]);
1365 DONE;
1366 }
bb68ff55
MM
1367 operands[3] = gen_reg_rtx (SImode);
1368 operands[4] = gen_reg_rtx (SImode);
1369 operands[5] = GEN_INT (-2147483647 - 1);
1370}")
1fd4e8c1
RK
1371
1372(define_expand "umaxsi3"
cd2b37d9 1373 [(set (match_dup 3) (xor:SI (match_operand:SI 1 "gpc_reg_operand" "")
bb68ff55 1374 (match_dup 5)))
cd2b37d9 1375 (set (match_dup 4) (xor:SI (match_operand:SI 2 "gpc_reg_operand" "")
bb68ff55 1376 (match_dup 5)))
1fd4e8c1
RK
1377 (set (match_dup 3) (if_then_else:SI (gt (match_dup 3) (match_dup 4))
1378 (const_int 0)
1379 (minus:SI (match_dup 4) (match_dup 3))))
cd2b37d9 1380 (set (match_operand:SI 0 "gpc_reg_operand" "")
1fd4e8c1 1381 (plus:SI (match_dup 3) (match_dup 1)))]
a3170dc6 1382 "TARGET_POWER || TARGET_ISEL"
1fd4e8c1 1383 "
bb68ff55 1384{
a3170dc6
AH
1385 if (TARGET_ISEL)
1386 {
1387 rs6000_emit_minmax (operands[0], UMAX, operands[1], operands[2]);
1388 DONE;
1389 }
bb68ff55
MM
1390 operands[3] = gen_reg_rtx (SImode);
1391 operands[4] = gen_reg_rtx (SImode);
1392 operands[5] = GEN_INT (-2147483647 - 1);
1393}")
1fd4e8c1
RK
1394
1395(define_insn ""
cd2b37d9
RK
1396 [(set (match_operand:SI 0 "gpc_reg_operand" "=r")
1397 (if_then_else:SI (gt (match_operand:SI 1 "gpc_reg_operand" "r")
5c23c401 1398 (match_operand:SI 2 "reg_or_short_operand" "rI"))
1fd4e8c1
RK
1399 (const_int 0)
1400 (minus:SI (match_dup 2) (match_dup 1))))]
ca7f5001 1401 "TARGET_POWER"
1fd4e8c1
RK
1402 "doz%I2 %0,%1,%2")
1403
1404(define_insn ""
9ebbca7d 1405 [(set (match_operand:CC 0 "cc_reg_operand" "=x,?y")
1fd4e8c1 1406 (compare:CC
9ebbca7d
GK
1407 (if_then_else:SI (gt (match_operand:SI 1 "gpc_reg_operand" "r,r")
1408 (match_operand:SI 2 "reg_or_short_operand" "rI,rI"))
1fd4e8c1
RK
1409 (const_int 0)
1410 (minus:SI (match_dup 2) (match_dup 1)))
1411 (const_int 0)))
9ebbca7d 1412 (clobber (match_scratch:SI 3 "=r,r"))]
ca7f5001 1413 "TARGET_POWER"
9ebbca7d
GK
1414 "@
1415 doz%I2. %3,%1,%2
1416 #"
1417 [(set_attr "type" "delayed_compare")
1418 (set_attr "length" "4,8")])
1419
1420(define_split
1421 [(set (match_operand:CC 0 "cc_reg_not_cr0_operand" "")
1422 (compare:CC
1423 (if_then_else:SI (gt (match_operand:SI 1 "gpc_reg_operand" "")
1424 (match_operand:SI 2 "reg_or_short_operand" ""))
1425 (const_int 0)
1426 (minus:SI (match_dup 2) (match_dup 1)))
1427 (const_int 0)))
1428 (clobber (match_scratch:SI 3 ""))]
1429 "TARGET_POWER && reload_completed"
1430 [(set (match_dup 3)
1431 (if_then_else:SI (gt (match_dup 1) (match_dup 2))
1432 (const_int 0)
1433 (minus:SI (match_dup 2) (match_dup 1))))
1434 (set (match_dup 0)
1435 (compare:CC (match_dup 3)
1436 (const_int 0)))]
1437 "")
1fd4e8c1
RK
1438
1439(define_insn ""
9ebbca7d 1440 [(set (match_operand:CC 3 "cc_reg_operand" "=x,?y")
1fd4e8c1 1441 (compare:CC
9ebbca7d
GK
1442 (if_then_else:SI (gt (match_operand:SI 1 "gpc_reg_operand" "r,r")
1443 (match_operand:SI 2 "reg_or_short_operand" "rI,rI"))
1fd4e8c1
RK
1444 (const_int 0)
1445 (minus:SI (match_dup 2) (match_dup 1)))
1446 (const_int 0)))
9ebbca7d 1447 (set (match_operand:SI 0 "gpc_reg_operand" "=r,r")
1fd4e8c1
RK
1448 (if_then_else:SI (gt (match_dup 1) (match_dup 2))
1449 (const_int 0)
1450 (minus:SI (match_dup 2) (match_dup 1))))]
ca7f5001 1451 "TARGET_POWER"
9ebbca7d
GK
1452 "@
1453 doz%I2. %0,%1,%2
1454 #"
1455 [(set_attr "type" "delayed_compare")
1456 (set_attr "length" "4,8")])
1457
1458(define_split
1459 [(set (match_operand:CC 3 "cc_reg_not_cr0_operand" "")
1460 (compare:CC
1461 (if_then_else:SI (gt (match_operand:SI 1 "gpc_reg_operand" "")
1462 (match_operand:SI 2 "reg_or_short_operand" ""))
1463 (const_int 0)
1464 (minus:SI (match_dup 2) (match_dup 1)))
1465 (const_int 0)))
1466 (set (match_operand:SI 0 "gpc_reg_operand" "")
1467 (if_then_else:SI (gt (match_dup 1) (match_dup 2))
1468 (const_int 0)
1469 (minus:SI (match_dup 2) (match_dup 1))))]
1470 "TARGET_POWER && reload_completed"
1471 [(set (match_dup 0)
1472 (if_then_else:SI (gt (match_dup 1) (match_dup 2))
1473 (const_int 0)
1474 (minus:SI (match_dup 2) (match_dup 1))))
1475 (set (match_dup 3)
1476 (compare:CC (match_dup 0)
1477 (const_int 0)))]
1478 "")
1fd4e8c1
RK
1479
1480;; We don't need abs with condition code because such comparisons should
1481;; never be done.
ea9be077
MM
1482(define_expand "abssi2"
1483 [(set (match_operand:SI 0 "gpc_reg_operand" "")
1484 (abs:SI (match_operand:SI 1 "gpc_reg_operand" "")))]
1485 ""
1486 "
1487{
a3170dc6
AH
1488 if (TARGET_ISEL)
1489 {
1490 emit_insn (gen_abssi2_isel (operands[0], operands[1]));
1491 DONE;
1492 }
1493 else if (! TARGET_POWER)
ea9be077
MM
1494 {
1495 emit_insn (gen_abssi2_nopower (operands[0], operands[1]));
1496 DONE;
1497 }
1498}")
1499
ea112fc4 1500(define_insn "*abssi2_power"
cd2b37d9
RK
1501 [(set (match_operand:SI 0 "gpc_reg_operand" "=r")
1502 (abs:SI (match_operand:SI 1 "gpc_reg_operand" "r")))]
ca7f5001 1503 "TARGET_POWER"
1fd4e8c1
RK
1504 "abs %0,%1")
1505
a3170dc6
AH
1506(define_insn_and_split "abssi2_isel"
1507 [(set (match_operand:SI 0 "gpc_reg_operand" "=r")
1508 (abs:SI (match_operand:SI 1 "gpc_reg_operand" "b")))
8c48b6f5 1509 (clobber (match_scratch:SI 2 "=&b"))
a3170dc6
AH
1510 (clobber (match_scratch:CC 3 "=y"))]
1511 "TARGET_ISEL"
1512 "#"
1513 "&& reload_completed"
1514 [(set (match_dup 2) (neg:SI (match_dup 1)))
1515 (set (match_dup 3)
1516 (compare:CC (match_dup 1)
1517 (const_int 0)))
1518 (set (match_dup 0)
1519 (if_then_else:SI (ge (match_dup 3)
1520 (const_int 0))
1521 (match_dup 1)
1522 (match_dup 2)))]
1523 "")
1524
ea112fc4 1525(define_insn_and_split "abssi2_nopower"
ea9be077 1526 [(set (match_operand:SI 0 "gpc_reg_operand" "=&r,r")
ea112fc4 1527 (abs:SI (match_operand:SI 1 "gpc_reg_operand" "r,0")))
ea9be077 1528 (clobber (match_scratch:SI 2 "=&r,&r"))]
a3170dc6 1529 "! TARGET_POWER && ! TARGET_ISEL"
ea112fc4
DE
1530 "#"
1531 "&& reload_completed"
ea9be077
MM
1532 [(set (match_dup 2) (ashiftrt:SI (match_dup 1) (const_int 31)))
1533 (set (match_dup 0) (xor:SI (match_dup 2) (match_dup 1)))
7093ddee 1534 (set (match_dup 0) (minus:SI (match_dup 0) (match_dup 2)))]
ea9be077
MM
1535 "")
1536
463b558b 1537(define_insn "*nabs_power"
cd2b37d9
RK
1538 [(set (match_operand:SI 0 "gpc_reg_operand" "=r")
1539 (neg:SI (abs:SI (match_operand:SI 1 "gpc_reg_operand" "r"))))]
ca7f5001 1540 "TARGET_POWER"
1fd4e8c1
RK
1541 "nabs %0,%1")
1542
ea112fc4 1543(define_insn_and_split "*nabs_nopower"
ea9be077 1544 [(set (match_operand:SI 0 "gpc_reg_operand" "=&r,r")
ea112fc4 1545 (neg:SI (abs:SI (match_operand:SI 1 "gpc_reg_operand" "r,0"))))
ea9be077 1546 (clobber (match_scratch:SI 2 "=&r,&r"))]
0ad91047 1547 "! TARGET_POWER"
ea112fc4
DE
1548 "#"
1549 "&& reload_completed"
ea9be077
MM
1550 [(set (match_dup 2) (ashiftrt:SI (match_dup 1) (const_int 31)))
1551 (set (match_dup 0) (xor:SI (match_dup 2) (match_dup 1)))
7093ddee 1552 (set (match_dup 0) (minus:SI (match_dup 2) (match_dup 0)))]
ea9be077
MM
1553 "")
1554
1fd4e8c1 1555(define_insn "negsi2"
cd2b37d9
RK
1556 [(set (match_operand:SI 0 "gpc_reg_operand" "=r")
1557 (neg:SI (match_operand:SI 1 "gpc_reg_operand" "r")))]
1fd4e8c1
RK
1558 ""
1559 "neg %0,%1")
1560
1561(define_insn ""
9ebbca7d
GK
1562 [(set (match_operand:CC 0 "cc_reg_operand" "=x,?y")
1563 (compare:CC (neg:SI (match_operand:SI 1 "gpc_reg_operand" "r,r"))
1fd4e8c1 1564 (const_int 0)))
9ebbca7d 1565 (clobber (match_scratch:SI 2 "=r,r"))]
0ad91047 1566 "! TARGET_POWERPC64"
9ebbca7d
GK
1567 "@
1568 neg. %2,%1
1569 #"
a62bfff2 1570 [(set_attr "type" "fast_compare")
9ebbca7d
GK
1571 (set_attr "length" "4,8")])
1572
1573(define_split
1574 [(set (match_operand:CC 0 "cc_reg_not_cr0_operand" "")
1575 (compare:CC (neg:SI (match_operand:SI 1 "gpc_reg_operand" ""))
1576 (const_int 0)))
1577 (clobber (match_scratch:SI 2 ""))]
1578 "! TARGET_POWERPC64 && reload_completed"
1579 [(set (match_dup 2)
1580 (neg:SI (match_dup 1)))
1581 (set (match_dup 0)
1582 (compare:CC (match_dup 2)
1583 (const_int 0)))]
1584 "")
1fd4e8c1
RK
1585
1586(define_insn ""
9ebbca7d
GK
1587 [(set (match_operand:CC 2 "cc_reg_operand" "=x,?y")
1588 (compare:CC (neg:SI (match_operand:SI 1 "gpc_reg_operand" "r,r"))
815cdc52 1589 (const_int 0)))
9ebbca7d 1590 (set (match_operand:SI 0 "gpc_reg_operand" "=r,r")
815cdc52 1591 (neg:SI (match_dup 1)))]
0ad91047 1592 "! TARGET_POWERPC64"
9ebbca7d
GK
1593 "@
1594 neg. %0,%1
1595 #"
a62bfff2 1596 [(set_attr "type" "fast_compare")
9ebbca7d
GK
1597 (set_attr "length" "4,8")])
1598
1599(define_split
1600 [(set (match_operand:CC 2 "cc_reg_not_cr0_operand" "")
1601 (compare:CC (neg:SI (match_operand:SI 1 "gpc_reg_operand" ""))
1602 (const_int 0)))
1603 (set (match_operand:SI 0 "gpc_reg_operand" "")
1604 (neg:SI (match_dup 1)))]
1605 "! TARGET_POWERPC64 && reload_completed"
1606 [(set (match_dup 0)
1607 (neg:SI (match_dup 1)))
1608 (set (match_dup 2)
1609 (compare:CC (match_dup 0)
1610 (const_int 0)))]
1611 "")
1fd4e8c1 1612
1b1edcfa
DE
1613(define_insn "clzsi2"
1614 [(set (match_operand:SI 0 "gpc_reg_operand" "=r")
1615 (clz:SI (match_operand:SI 1 "gpc_reg_operand" "r")))]
1616 ""
1617 "{cntlz|cntlzw} %0,%1")
1618
1619(define_expand "ctzsi2"
4977bab6 1620 [(set (match_dup 2)
1b1edcfa 1621 (neg:SI (match_operand:SI 1 "gpc_reg_operand" "r")))
4977bab6 1622 (parallel [(set (match_dup 3) (and:SI (match_dup 1)
1b1edcfa
DE
1623 (match_dup 2)))
1624 (clobber (scratch:CC))])
d865b122 1625 (set (match_dup 4) (clz:SI (match_dup 3)))
4977bab6 1626 (set (match_operand:SI 0 "gpc_reg_operand" "=r")
1b1edcfa 1627 (minus:SI (const_int 31) (match_dup 4)))]
1fd4e8c1 1628 ""
4977bab6
ZW
1629 {
1630 operands[2] = gen_reg_rtx (SImode);
1631 operands[3] = gen_reg_rtx (SImode);
1632 operands[4] = gen_reg_rtx (SImode);
1633 })
1634
1b1edcfa
DE
1635(define_expand "ffssi2"
1636 [(set (match_dup 2)
1637 (neg:SI (match_operand:SI 1 "gpc_reg_operand" "r")))
1638 (parallel [(set (match_dup 3) (and:SI (match_dup 1)
1639 (match_dup 2)))
1640 (clobber (scratch:CC))])
1641 (set (match_dup 4) (clz:SI (match_dup 3)))
1642 (set (match_operand:SI 0 "gpc_reg_operand" "=r")
1643 (minus:SI (const_int 32) (match_dup 4)))]
4977bab6 1644 ""
1b1edcfa
DE
1645 {
1646 operands[2] = gen_reg_rtx (SImode);
1647 operands[3] = gen_reg_rtx (SImode);
1648 operands[4] = gen_reg_rtx (SImode);
1649 })
1650
ca7f5001
RK
1651(define_expand "mulsi3"
1652 [(use (match_operand:SI 0 "gpc_reg_operand" ""))
1653 (use (match_operand:SI 1 "gpc_reg_operand" ""))
1654 (use (match_operand:SI 2 "reg_or_short_operand" ""))]
1655 ""
1656 "
1657{
1658 if (TARGET_POWER)
68b40e7e 1659 emit_insn (gen_mulsi3_mq (operands[0], operands[1], operands[2]));
ca7f5001 1660 else
68b40e7e 1661 emit_insn (gen_mulsi3_no_mq (operands[0], operands[1], operands[2]));
ca7f5001
RK
1662 DONE;
1663}")
1664
68b40e7e 1665(define_insn "mulsi3_mq"
cd2b37d9
RK
1666 [(set (match_operand:SI 0 "gpc_reg_operand" "=r,r")
1667 (mult:SI (match_operand:SI 1 "gpc_reg_operand" "%r,r")
1fd4e8c1
RK
1668 (match_operand:SI 2 "reg_or_short_operand" "r,I")))
1669 (clobber (match_scratch:SI 3 "=q,q"))]
ca7f5001
RK
1670 "TARGET_POWER"
1671 "@
1672 {muls|mullw} %0,%1,%2
1673 {muli|mulli} %0,%1,%2"
c859cda6
DJ
1674 [(set (attr "type")
1675 (cond [(match_operand:SI 2 "s8bit_cint_operand" "")
1676 (const_string "imul3")
1677 (match_operand:SI 2 "short_cint_operand" "")
1678 (const_string "imul2")]
1679 (const_string "imul")))])
ca7f5001 1680
68b40e7e 1681(define_insn "mulsi3_no_mq"
ca7f5001
RK
1682 [(set (match_operand:SI 0 "gpc_reg_operand" "=r,r")
1683 (mult:SI (match_operand:SI 1 "gpc_reg_operand" "%r,r")
1684 (match_operand:SI 2 "reg_or_short_operand" "r,I")))]
68b40e7e 1685 "! TARGET_POWER"
1fd4e8c1 1686 "@
d904e9ed
RK
1687 {muls|mullw} %0,%1,%2
1688 {muli|mulli} %0,%1,%2"
c859cda6
DJ
1689 [(set (attr "type")
1690 (cond [(match_operand:SI 2 "s8bit_cint_operand" "")
1691 (const_string "imul3")
1692 (match_operand:SI 2 "short_cint_operand" "")
1693 (const_string "imul2")]
1694 (const_string "imul")))])
1fd4e8c1 1695
9259f3b0 1696(define_insn "*mulsi3_mq_internal1"
9ebbca7d
GK
1697 [(set (match_operand:CC 0 "cc_reg_operand" "=x,?y")
1698 (compare:CC (mult:SI (match_operand:SI 1 "gpc_reg_operand" "%r,r")
1699 (match_operand:SI 2 "gpc_reg_operand" "r,r"))
1fd4e8c1 1700 (const_int 0)))
9ebbca7d
GK
1701 (clobber (match_scratch:SI 3 "=r,r"))
1702 (clobber (match_scratch:SI 4 "=q,q"))]
ca7f5001 1703 "TARGET_POWER"
9ebbca7d
GK
1704 "@
1705 {muls.|mullw.} %3,%1,%2
1706 #"
9259f3b0 1707 [(set_attr "type" "imul_compare")
9ebbca7d
GK
1708 (set_attr "length" "4,8")])
1709
1710(define_split
1711 [(set (match_operand:CC 0 "cc_reg_not_cr0_operand" "")
1712 (compare:CC (mult:SI (match_operand:SI 1 "gpc_reg_operand" "")
1713 (match_operand:SI 2 "gpc_reg_operand" ""))
1714 (const_int 0)))
1715 (clobber (match_scratch:SI 3 ""))
1716 (clobber (match_scratch:SI 4 ""))]
1717 "TARGET_POWER && reload_completed"
1718 [(parallel [(set (match_dup 3)
1719 (mult:SI (match_dup 1) (match_dup 2)))
1720 (clobber (match_dup 4))])
1721 (set (match_dup 0)
1722 (compare:CC (match_dup 3)
1723 (const_int 0)))]
1724 "")
ca7f5001 1725
9259f3b0 1726(define_insn "*mulsi3_no_mq_internal1"
9ebbca7d
GK
1727 [(set (match_operand:CC 0 "cc_reg_operand" "=x,?y")
1728 (compare:CC (mult:SI (match_operand:SI 1 "gpc_reg_operand" "%r,r")
1729 (match_operand:SI 2 "gpc_reg_operand" "r,r"))
ca7f5001 1730 (const_int 0)))
9ebbca7d 1731 (clobber (match_scratch:SI 3 "=r,r"))]
25c341fa 1732 "! TARGET_POWER"
9ebbca7d
GK
1733 "@
1734 {muls.|mullw.} %3,%1,%2
1735 #"
9259f3b0 1736 [(set_attr "type" "imul_compare")
9ebbca7d
GK
1737 (set_attr "length" "4,8")])
1738
1739(define_split
1740 [(set (match_operand:CC 0 "cc_reg_not_cr0_operand" "")
1741 (compare:CC (mult:SI (match_operand:SI 1 "gpc_reg_operand" "")
1742 (match_operand:SI 2 "gpc_reg_operand" ""))
1743 (const_int 0)))
1744 (clobber (match_scratch:SI 3 ""))]
1745 "! TARGET_POWER && reload_completed"
1746 [(set (match_dup 3)
1747 (mult:SI (match_dup 1) (match_dup 2)))
1748 (set (match_dup 0)
1749 (compare:CC (match_dup 3)
1750 (const_int 0)))]
1751 "")
1fd4e8c1 1752
9259f3b0 1753(define_insn "*mulsi3_mq_internal2"
9ebbca7d
GK
1754 [(set (match_operand:CC 3 "cc_reg_operand" "=x,?y")
1755 (compare:CC (mult:SI (match_operand:SI 1 "gpc_reg_operand" "%r,r")
1756 (match_operand:SI 2 "gpc_reg_operand" "r,r"))
1fd4e8c1 1757 (const_int 0)))
9ebbca7d 1758 (set (match_operand:SI 0 "gpc_reg_operand" "=r,r")
29ae5b89 1759 (mult:SI (match_dup 1) (match_dup 2)))
9ebbca7d 1760 (clobber (match_scratch:SI 4 "=q,q"))]
ca7f5001 1761 "TARGET_POWER"
9ebbca7d
GK
1762 "@
1763 {muls.|mullw.} %0,%1,%2
1764 #"
9259f3b0 1765 [(set_attr "type" "imul_compare")
9ebbca7d
GK
1766 (set_attr "length" "4,8")])
1767
1768(define_split
1769 [(set (match_operand:CC 3 "cc_reg_not_cr0_operand" "")
1770 (compare:CC (mult:SI (match_operand:SI 1 "gpc_reg_operand" "")
1771 (match_operand:SI 2 "gpc_reg_operand" ""))
1772 (const_int 0)))
1773 (set (match_operand:SI 0 "gpc_reg_operand" "")
1774 (mult:SI (match_dup 1) (match_dup 2)))
1775 (clobber (match_scratch:SI 4 ""))]
1776 "TARGET_POWER && reload_completed"
1777 [(parallel [(set (match_dup 0)
1778 (mult:SI (match_dup 1) (match_dup 2)))
1779 (clobber (match_dup 4))])
1780 (set (match_dup 3)
1781 (compare:CC (match_dup 0)
1782 (const_int 0)))]
1783 "")
ca7f5001 1784
9259f3b0 1785(define_insn "*mulsi3_no_mq_internal2"
9ebbca7d
GK
1786 [(set (match_operand:CC 3 "cc_reg_operand" "=x,?y")
1787 (compare:CC (mult:SI (match_operand:SI 1 "gpc_reg_operand" "%r,r")
1788 (match_operand:SI 2 "gpc_reg_operand" "r,r"))
ca7f5001 1789 (const_int 0)))
9ebbca7d 1790 (set (match_operand:SI 0 "gpc_reg_operand" "=r,r")
ca7f5001 1791 (mult:SI (match_dup 1) (match_dup 2)))]
25c341fa 1792 "! TARGET_POWER"
9ebbca7d
GK
1793 "@
1794 {muls.|mullw.} %0,%1,%2
1795 #"
9259f3b0 1796 [(set_attr "type" "imul_compare")
9ebbca7d
GK
1797 (set_attr "length" "4,8")])
1798
1799(define_split
1800 [(set (match_operand:CC 3 "cc_reg_not_cr0_operand" "")
1801 (compare:CC (mult:SI (match_operand:SI 1 "gpc_reg_operand" "")
1802 (match_operand:SI 2 "gpc_reg_operand" ""))
1803 (const_int 0)))
1804 (set (match_operand:SI 0 "gpc_reg_operand" "")
1805 (mult:SI (match_dup 1) (match_dup 2)))]
1806 "! TARGET_POWER && reload_completed"
1807 [(set (match_dup 0)
1808 (mult:SI (match_dup 1) (match_dup 2)))
1809 (set (match_dup 3)
1810 (compare:CC (match_dup 0)
1811 (const_int 0)))]
1812 "")
1fd4e8c1
RK
1813
1814;; Operand 1 is divided by operand 2; quotient goes to operand
1815;; 0 and remainder to operand 3.
1816;; ??? At some point, see what, if anything, we can do about if (x % y == 0).
1817
8ffd9c51
RK
1818(define_expand "divmodsi4"
1819 [(parallel [(set (match_operand:SI 0 "gpc_reg_operand" "")
1820 (div:SI (match_operand:SI 1 "gpc_reg_operand" "")
1821 (match_operand:SI 2 "gpc_reg_operand" "")))
bb157ff4 1822 (set (match_operand:SI 3 "register_operand" "")
8ffd9c51
RK
1823 (mod:SI (match_dup 1) (match_dup 2)))])]
1824 "TARGET_POWER || (! TARGET_POWER && ! TARGET_POWERPC)"
1825 "
1826{
1827 if (! TARGET_POWER && ! TARGET_POWERPC)
1828 {
39403d82
DE
1829 emit_move_insn (gen_rtx_REG (SImode, 3), operands[1]);
1830 emit_move_insn (gen_rtx_REG (SImode, 4), operands[2]);
fada905b 1831 emit_insn (gen_divss_call ());
39403d82
DE
1832 emit_move_insn (operands[0], gen_rtx_REG (SImode, 3));
1833 emit_move_insn (operands[3], gen_rtx_REG (SImode, 4));
8ffd9c51
RK
1834 DONE;
1835 }
1836}")
deb9225a 1837
bb157ff4 1838(define_insn "*divmodsi4_internal"
cd2b37d9
RK
1839 [(set (match_operand:SI 0 "gpc_reg_operand" "=r")
1840 (div:SI (match_operand:SI 1 "gpc_reg_operand" "r")
1841 (match_operand:SI 2 "gpc_reg_operand" "r")))
bb157ff4 1842 (set (match_operand:SI 3 "register_operand" "=q")
1fd4e8c1 1843 (mod:SI (match_dup 1) (match_dup 2)))]
ca7f5001 1844 "TARGET_POWER"
cfb557c4
RK
1845 "divs %0,%1,%2"
1846 [(set_attr "type" "idiv")])
1fd4e8c1 1847
8ffd9c51
RK
1848(define_expand "udivsi3"
1849 [(set (match_operand:SI 0 "gpc_reg_operand" "")
1850 (udiv:SI (match_operand:SI 1 "gpc_reg_operand" "")
1851 (match_operand:SI 2 "gpc_reg_operand" "")))]
1852 "TARGET_POWERPC || (! TARGET_POWER && ! TARGET_POWERPC)"
1853 "
1854{
1855 if (! TARGET_POWER && ! TARGET_POWERPC)
1856 {
39403d82
DE
1857 emit_move_insn (gen_rtx_REG (SImode, 3), operands[1]);
1858 emit_move_insn (gen_rtx_REG (SImode, 4), operands[2]);
fada905b 1859 emit_insn (gen_quous_call ());
39403d82 1860 emit_move_insn (operands[0], gen_rtx_REG (SImode, 3));
8ffd9c51
RK
1861 DONE;
1862 }
f192bf8b
DE
1863 else if (TARGET_POWER)
1864 {
1865 emit_insn (gen_udivsi3_mq (operands[0], operands[1], operands[2]));
1866 DONE;
1867 }
8ffd9c51 1868}")
deb9225a 1869
f192bf8b
DE
1870(define_insn "udivsi3_mq"
1871 [(set (match_operand:SI 0 "gpc_reg_operand" "=r")
1872 (udiv:SI (match_operand:SI 1 "gpc_reg_operand" "r")
1873 (match_operand:SI 2 "gpc_reg_operand" "r")))
1874 (clobber (match_scratch:SI 3 "=q"))]
1875 "TARGET_POWERPC && TARGET_POWER"
1876 "divwu %0,%1,%2"
1877 [(set_attr "type" "idiv")])
1878
1879(define_insn "*udivsi3_no_mq"
ca7f5001
RK
1880 [(set (match_operand:SI 0 "gpc_reg_operand" "=r")
1881 (udiv:SI (match_operand:SI 1 "gpc_reg_operand" "r")
1882 (match_operand:SI 2 "gpc_reg_operand" "r")))]
f192bf8b 1883 "TARGET_POWERPC && ! TARGET_POWER"
a473029f 1884 "divwu %0,%1,%2"
ca7f5001
RK
1885 [(set_attr "type" "idiv")])
1886
1fd4e8c1 1887;; For powers of two we can do srai/aze for divide and then adjust for
ca7f5001 1888;; modulus. If it isn't a power of two, FAIL on POWER so divmodsi4 will be
8ffd9c51
RK
1889;; used; for PowerPC, force operands into register and do a normal divide;
1890;; for AIX common-mode, use quoss call on register operands.
1fd4e8c1 1891(define_expand "divsi3"
cd2b37d9
RK
1892 [(set (match_operand:SI 0 "gpc_reg_operand" "")
1893 (div:SI (match_operand:SI 1 "gpc_reg_operand" "")
1fd4e8c1
RK
1894 (match_operand:SI 2 "reg_or_cint_operand" "")))]
1895 ""
1896 "
1897{
ca7f5001 1898 if (GET_CODE (operands[2]) == CONST_INT
2bfcf297 1899 && INTVAL (operands[2]) > 0
ca7f5001
RK
1900 && exact_log2 (INTVAL (operands[2])) >= 0)
1901 ;
b6c9286a 1902 else if (TARGET_POWERPC)
f192bf8b
DE
1903 {
1904 operands[2] = force_reg (SImode, operands[2]);
1905 if (TARGET_POWER)
1906 {
1907 emit_insn (gen_divsi3_mq (operands[0], operands[1], operands[2]));
1908 DONE;
1909 }
1910 }
b6c9286a 1911 else if (TARGET_POWER)
1fd4e8c1 1912 FAIL;
405c5495 1913 else
8ffd9c51 1914 {
39403d82
DE
1915 emit_move_insn (gen_rtx_REG (SImode, 3), operands[1]);
1916 emit_move_insn (gen_rtx_REG (SImode, 4), operands[2]);
fada905b 1917 emit_insn (gen_quoss_call ());
39403d82 1918 emit_move_insn (operands[0], gen_rtx_REG (SImode, 3));
8ffd9c51
RK
1919 DONE;
1920 }
1fd4e8c1
RK
1921}")
1922
f192bf8b
DE
1923(define_insn "divsi3_mq"
1924 [(set (match_operand:SI 0 "gpc_reg_operand" "=r")
1925 (div:SI (match_operand:SI 1 "gpc_reg_operand" "r")
1926 (match_operand:SI 2 "gpc_reg_operand" "r")))
1927 (clobber (match_scratch:SI 3 "=q"))]
1928 "TARGET_POWERPC && TARGET_POWER"
1929 "divw %0,%1,%2"
1930 [(set_attr "type" "idiv")])
1931
1932(define_insn "*divsi3_no_mq"
1933 [(set (match_operand:SI 0 "gpc_reg_operand" "=r")
1934 (div:SI (match_operand:SI 1 "gpc_reg_operand" "r")
1935 (match_operand:SI 2 "gpc_reg_operand" "r")))]
1936 "TARGET_POWERPC && ! TARGET_POWER"
1937 "divw %0,%1,%2"
1938 [(set_attr "type" "idiv")])
1939
1fd4e8c1 1940(define_expand "modsi3"
85644414
RK
1941 [(use (match_operand:SI 0 "gpc_reg_operand" ""))
1942 (use (match_operand:SI 1 "gpc_reg_operand" ""))
405c5495 1943 (use (match_operand:SI 2 "reg_or_cint_operand" ""))]
39b52ba2 1944 ""
1fd4e8c1
RK
1945 "
1946{
481c7efa 1947 int i;
39b52ba2
RK
1948 rtx temp1;
1949 rtx temp2;
1950
2bfcf297 1951 if (GET_CODE (operands[2]) != CONST_INT
a65c591c 1952 || INTVAL (operands[2]) <= 0
2bfcf297 1953 || (i = exact_log2 (INTVAL (operands[2]))) < 0)
39b52ba2
RK
1954 FAIL;
1955
1956 temp1 = gen_reg_rtx (SImode);
1957 temp2 = gen_reg_rtx (SImode);
1fd4e8c1 1958
85644414 1959 emit_insn (gen_divsi3 (temp1, operands[1], operands[2]));
39b52ba2 1960 emit_insn (gen_ashlsi3 (temp2, temp1, GEN_INT (i)));
85644414
RK
1961 emit_insn (gen_subsi3 (operands[0], operands[1], temp2));
1962 DONE;
1fd4e8c1
RK
1963}")
1964
1965(define_insn ""
cd2b37d9
RK
1966 [(set (match_operand:SI 0 "gpc_reg_operand" "=r")
1967 (div:SI (match_operand:SI 1 "gpc_reg_operand" "r")
2bfcf297
DB
1968 (match_operand:SI 2 "exact_log2_cint_operand" "N")))]
1969 ""
ca7f5001 1970 "{srai|srawi} %0,%1,%p2\;{aze|addze} %0,%0"
b19003d8 1971 [(set_attr "length" "8")])
1fd4e8c1
RK
1972
1973(define_insn ""
9ebbca7d
GK
1974 [(set (match_operand:CC 0 "cc_reg_operand" "=x,?y")
1975 (compare:CC (div:SI (match_operand:SI 1 "gpc_reg_operand" "r,r")
2bfcf297 1976 (match_operand:SI 2 "exact_log2_cint_operand" "N,N"))
b6b12107 1977 (const_int 0)))
9ebbca7d 1978 (clobber (match_scratch:SI 3 "=r,r"))]
2bfcf297 1979 ""
9ebbca7d
GK
1980 "@
1981 {srai|srawi} %3,%1,%p2\;{aze.|addze.} %3,%3
1982 #"
b19003d8 1983 [(set_attr "type" "compare")
9ebbca7d
GK
1984 (set_attr "length" "8,12")])
1985
1986(define_split
1987 [(set (match_operand:CC 0 "cc_reg_not_cr0_operand" "")
1988 (compare:CC (div:SI (match_operand:SI 1 "gpc_reg_operand" "")
2bfcf297 1989 (match_operand:SI 2 "exact_log2_cint_operand" ""))
9ebbca7d
GK
1990 (const_int 0)))
1991 (clobber (match_scratch:SI 3 ""))]
2bfcf297 1992 "reload_completed"
9ebbca7d
GK
1993 [(set (match_dup 3)
1994 (div:SI (match_dup 1) (match_dup 2)))
1995 (set (match_dup 0)
1996 (compare:CC (match_dup 3)
1997 (const_int 0)))]
1998 "")
1fd4e8c1
RK
1999
2000(define_insn ""
9ebbca7d
GK
2001 [(set (match_operand:CC 3 "cc_reg_operand" "=x,?y")
2002 (compare:CC (div:SI (match_operand:SI 1 "gpc_reg_operand" "r,r")
2bfcf297 2003 (match_operand:SI 2 "exact_log2_cint_operand" "N,N"))
b6b12107 2004 (const_int 0)))
9ebbca7d 2005 (set (match_operand:SI 0 "gpc_reg_operand" "=r,r")
29ae5b89 2006 (div:SI (match_dup 1) (match_dup 2)))]
2bfcf297 2007 ""
9ebbca7d
GK
2008 "@
2009 {srai|srawi} %0,%1,%p2\;{aze.|addze.} %0,%0
2010 #"
b19003d8 2011 [(set_attr "type" "compare")
9ebbca7d
GK
2012 (set_attr "length" "8,12")])
2013
2014(define_split
2015 [(set (match_operand:CC 3 "cc_reg_not_cr0_operand" "")
2016 (compare:CC (div:SI (match_operand:SI 1 "gpc_reg_operand" "")
2bfcf297 2017 (match_operand:SI 2 "exact_log2_cint_operand" ""))
9ebbca7d
GK
2018 (const_int 0)))
2019 (set (match_operand:SI 0 "gpc_reg_operand" "")
2020 (div:SI (match_dup 1) (match_dup 2)))]
2bfcf297 2021 "reload_completed"
9ebbca7d
GK
2022 [(set (match_dup 0)
2023 (div:SI (match_dup 1) (match_dup 2)))
2024 (set (match_dup 3)
2025 (compare:CC (match_dup 0)
2026 (const_int 0)))]
2027 "")
1fd4e8c1
RK
2028
2029(define_insn ""
cd2b37d9 2030 [(set (match_operand:SI 0 "gpc_reg_operand" "=r")
1fd4e8c1 2031 (udiv:SI
996a5f59 2032 (plus:DI (ashift:DI
cd2b37d9 2033 (zero_extend:DI (match_operand:SI 1 "gpc_reg_operand" "r"))
1fd4e8c1 2034 (const_int 32))
23a900dc 2035 (zero_extend:DI (match_operand:SI 4 "register_operand" "2")))
cd2b37d9 2036 (match_operand:SI 3 "gpc_reg_operand" "r")))
740ab4a2 2037 (set (match_operand:SI 2 "register_operand" "=*q")
1fd4e8c1 2038 (umod:SI
996a5f59 2039 (plus:DI (ashift:DI
1fd4e8c1 2040 (zero_extend:DI (match_dup 1)) (const_int 32))
740ab4a2 2041 (zero_extend:DI (match_dup 4)))
1fd4e8c1 2042 (match_dup 3)))]
ca7f5001 2043 "TARGET_POWER"
cfb557c4
RK
2044 "div %0,%1,%3"
2045 [(set_attr "type" "idiv")])
1fd4e8c1
RK
2046
2047;; To do unsigned divide we handle the cases of the divisor looking like a
2048;; negative number. If it is a constant that is less than 2**31, we don't
2049;; have to worry about the branches. So make a few subroutines here.
2050;;
2051;; First comes the normal case.
2052(define_expand "udivmodsi4_normal"
2053 [(set (match_dup 4) (const_int 0))
2054 (parallel [(set (match_operand:SI 0 "" "")
996a5f59 2055 (udiv:SI (plus:DI (ashift:DI (zero_extend:DI (match_dup 4))
1fd4e8c1
RK
2056 (const_int 32))
2057 (zero_extend:DI (match_operand:SI 1 "" "")))
2058 (match_operand:SI 2 "" "")))
2059 (set (match_operand:SI 3 "" "")
996a5f59 2060 (umod:SI (plus:DI (ashift:DI (zero_extend:DI (match_dup 4))
1fd4e8c1
RK
2061 (const_int 32))
2062 (zero_extend:DI (match_dup 1)))
2063 (match_dup 2)))])]
ca7f5001 2064 "TARGET_POWER"
1fd4e8c1
RK
2065 "
2066{ operands[4] = gen_reg_rtx (SImode); }")
2067
2068;; This handles the branches.
2069(define_expand "udivmodsi4_tests"
2070 [(set (match_operand:SI 0 "" "") (const_int 0))
2071 (set (match_operand:SI 3 "" "") (match_operand:SI 1 "" ""))
2072 (set (match_dup 5) (compare:CCUNS (match_dup 1) (match_operand:SI 2 "" "")))
2073 (set (pc) (if_then_else (ltu (match_dup 5) (const_int 0))
2074 (label_ref (match_operand:SI 4 "" "")) (pc)))
2075 (set (match_dup 0) (const_int 1))
2076 (set (match_dup 3) (minus:SI (match_dup 1) (match_dup 2)))
2077 (set (match_dup 6) (compare:CC (match_dup 2) (const_int 0)))
2078 (set (pc) (if_then_else (lt (match_dup 6) (const_int 0))
2079 (label_ref (match_dup 4)) (pc)))]
ca7f5001 2080 "TARGET_POWER"
1fd4e8c1
RK
2081 "
2082{ operands[5] = gen_reg_rtx (CCUNSmode);
2083 operands[6] = gen_reg_rtx (CCmode);
2084}")
2085
2086(define_expand "udivmodsi4"
cd2b37d9
RK
2087 [(parallel [(set (match_operand:SI 0 "gpc_reg_operand" "")
2088 (udiv:SI (match_operand:SI 1 "gpc_reg_operand" "")
1fd4e8c1 2089 (match_operand:SI 2 "reg_or_cint_operand" "")))
cd2b37d9 2090 (set (match_operand:SI 3 "gpc_reg_operand" "")
1fd4e8c1 2091 (umod:SI (match_dup 1) (match_dup 2)))])]
8ffd9c51 2092 ""
1fd4e8c1
RK
2093 "
2094{
2095 rtx label = 0;
2096
8ffd9c51 2097 if (! TARGET_POWER)
c4d38ccb
MM
2098 {
2099 if (! TARGET_POWERPC)
2100 {
39403d82
DE
2101 emit_move_insn (gen_rtx_REG (SImode, 3), operands[1]);
2102 emit_move_insn (gen_rtx_REG (SImode, 4), operands[2]);
c4d38ccb 2103 emit_insn (gen_divus_call ());
39403d82
DE
2104 emit_move_insn (operands[0], gen_rtx_REG (SImode, 3));
2105 emit_move_insn (operands[3], gen_rtx_REG (SImode, 4));
c4d38ccb
MM
2106 DONE;
2107 }
2108 else
2109 FAIL;
2110 }
0081a354 2111
1fd4e8c1
RK
2112 if (GET_CODE (operands[2]) != CONST_INT || INTVAL (operands[2]) < 0)
2113 {
2114 operands[2] = force_reg (SImode, operands[2]);
2115 label = gen_label_rtx ();
2116 emit (gen_udivmodsi4_tests (operands[0], operands[1], operands[2],
2117 operands[3], label));
2118 }
2119 else
2120 operands[2] = force_reg (SImode, operands[2]);
2121
2122 emit (gen_udivmodsi4_normal (operands[0], operands[1], operands[2],
2123 operands[3]));
2124 if (label)
2125 emit_label (label);
2126
2127 DONE;
2128}")
0081a354 2129
fada905b
MM
2130;; AIX architecture-independent common-mode multiply (DImode),
2131;; divide/modulus, and quotient subroutine calls. Input operands in R3 and
2132;; R4; results in R3 and sometimes R4; link register always clobbered by bla
2133;; instruction; R0 sometimes clobbered; also, MQ sometimes clobbered but
2134;; assumed unused if generating common-mode, so ignore.
2135(define_insn "mulh_call"
2136 [(set (reg:SI 3)
2137 (truncate:SI
2138 (lshiftrt:DI (mult:DI (sign_extend:DI (reg:SI 3))
2139 (sign_extend:DI (reg:SI 4)))
2140 (const_int 32))))
cf27b467 2141 (clobber (match_scratch:SI 0 "=l"))]
fada905b 2142 "! TARGET_POWER && ! TARGET_POWERPC"
b7ff3d82
DE
2143 "bla __mulh"
2144 [(set_attr "type" "imul")])
fada905b
MM
2145
2146(define_insn "mull_call"
2147 [(set (reg:DI 3)
2148 (mult:DI (sign_extend:DI (reg:SI 3))
2149 (sign_extend:DI (reg:SI 4))))
2150 (clobber (match_scratch:SI 0 "=l"))
2151 (clobber (reg:SI 0))]
2152 "! TARGET_POWER && ! TARGET_POWERPC"
b7ff3d82
DE
2153 "bla __mull"
2154 [(set_attr "type" "imul")])
fada905b
MM
2155
2156(define_insn "divss_call"
2157 [(set (reg:SI 3)
2158 (div:SI (reg:SI 3) (reg:SI 4)))
2159 (set (reg:SI 4)
2160 (mod:SI (reg:SI 3) (reg:SI 4)))
2161 (clobber (match_scratch:SI 0 "=l"))
2162 (clobber (reg:SI 0))]
2163 "! TARGET_POWER && ! TARGET_POWERPC"
b7ff3d82
DE
2164 "bla __divss"
2165 [(set_attr "type" "idiv")])
fada905b
MM
2166
2167(define_insn "divus_call"
8ffd9c51
RK
2168 [(set (reg:SI 3)
2169 (udiv:SI (reg:SI 3) (reg:SI 4)))
2170 (set (reg:SI 4)
2171 (umod:SI (reg:SI 3) (reg:SI 4)))
2172 (clobber (match_scratch:SI 0 "=l"))
fada905b
MM
2173 (clobber (reg:SI 0))
2174 (clobber (match_scratch:CC 1 "=x"))
2175 (clobber (reg:CC 69))]
2176 "! TARGET_POWER && ! TARGET_POWERPC"
b7ff3d82
DE
2177 "bla __divus"
2178 [(set_attr "type" "idiv")])
fada905b
MM
2179
2180(define_insn "quoss_call"
2181 [(set (reg:SI 3)
2182 (div:SI (reg:SI 3) (reg:SI 4)))
cf27b467 2183 (clobber (match_scratch:SI 0 "=l"))]
8ffd9c51 2184 "! TARGET_POWER && ! TARGET_POWERPC"
b7ff3d82
DE
2185 "bla __quoss"
2186 [(set_attr "type" "idiv")])
0081a354 2187
fada905b
MM
2188(define_insn "quous_call"
2189 [(set (reg:SI 3)
2190 (udiv:SI (reg:SI 3) (reg:SI 4)))
2191 (clobber (match_scratch:SI 0 "=l"))
2192 (clobber (reg:SI 0))
2193 (clobber (match_scratch:CC 1 "=x"))
2194 (clobber (reg:CC 69))]
2195 "! TARGET_POWER && ! TARGET_POWERPC"
b7ff3d82
DE
2196 "bla __quous"
2197 [(set_attr "type" "idiv")])
8ffd9c51 2198\f
bb21487f 2199;; Logical instructions
dfbdccdb
GK
2200;; The logical instructions are mostly combined by using match_operator,
2201;; but the plain AND insns are somewhat different because there is no
2202;; plain 'andi' (only 'andi.'), no plain 'andis', and there are all
2203;; those rotate-and-mask operations. Thus, the AND insns come first.
2204
29ae5b89
JL
2205(define_insn "andsi3"
2206 [(set (match_operand:SI 0 "gpc_reg_operand" "=r,r,r,r")
2207 (and:SI (match_operand:SI 1 "gpc_reg_operand" "%r,r,r,r")
5f59ecb7 2208 (match_operand:SI 2 "and_operand" "?r,T,K,L")))
29ae5b89 2209 (clobber (match_scratch:CC 3 "=X,X,x,x"))]
1fd4e8c1
RK
2210 ""
2211 "@
2212 and %0,%1,%2
ca7f5001
RK
2213 {rlinm|rlwinm} %0,%1,0,%m2,%M2
2214 {andil.|andi.} %0,%1,%b2
9ebbca7d 2215 {andiu.|andis.} %0,%1,%u2")
52d3af72
DE
2216
2217;; Note to set cr's other than cr0 we do the and immediate and then
0ba1b2ff 2218;; the test again -- this avoids a mfcr which on the higher end
52d3af72 2219;; machines causes an execution serialization
1fd4e8c1 2220
7cd5235b 2221(define_insn "*andsi3_internal2"
52d3af72
DE
2222 [(set (match_operand:CC 0 "cc_reg_operand" "=x,x,x,x,?y,??y,??y,?y")
2223 (compare:CC (and:SI (match_operand:SI 1 "gpc_reg_operand" "%r,r,r,r,r,r,r,r")
5f59ecb7 2224 (match_operand:SI 2 "and_operand" "r,K,L,T,r,K,L,T"))
1fd4e8c1 2225 (const_int 0)))
52d3af72
DE
2226 (clobber (match_scratch:SI 3 "=r,r,r,r,r,r,r,r"))
2227 (clobber (match_scratch:CC 4 "=X,X,X,X,X,x,x,X"))]
0ad91047 2228 "! TARGET_POWERPC64"
1fd4e8c1
RK
2229 "@
2230 and. %3,%1,%2
ca7f5001
RK
2231 {andil.|andi.} %3,%1,%b2
2232 {andiu.|andis.} %3,%1,%u2
52d3af72
DE
2233 {rlinm.|rlwinm.} %3,%1,0,%m2,%M2
2234 #
2235 #
2236 #
2237 #"
2238 [(set_attr "type" "compare,compare,compare,delayed_compare,compare,compare,compare,compare")
2239 (set_attr "length" "4,4,4,4,8,8,8,8")])
1fd4e8c1 2240
0ba1b2ff
AM
2241(define_insn "*andsi3_internal3"
2242 [(set (match_operand:CC 0 "cc_reg_operand" "=x,x,x,x,?y,??y,??y,?y")
2243 (compare:CC (and:SI (match_operand:SI 1 "gpc_reg_operand" "%r,r,r,r,r,r,r,r")
2244 (match_operand:SI 2 "and_operand" "r,K,L,T,r,K,L,T"))
2245 (const_int 0)))
2246 (clobber (match_scratch:SI 3 "=r,r,r,r,r,r,r,r"))
2247 (clobber (match_scratch:CC 4 "=X,X,X,X,X,x,x,X"))]
683bdff7 2248 "TARGET_64BIT"
0ba1b2ff
AM
2249 "@
2250 #
2251 {andil.|andi.} %3,%1,%b2
2252 {andiu.|andis.} %3,%1,%u2
2253 {rlinm.|rlwinm.} %3,%1,0,%m2,%M2
2254 #
2255 #
2256 #
2257 #"
2258 [(set_attr "type" "compare,compare,compare,delayed_compare,compare,compare,compare,compare")
2259 (set_attr "length" "8,4,4,4,8,8,8,8")])
2260
52d3af72
DE
2261(define_split
2262 [(set (match_operand:CC 0 "cc_reg_not_cr0_operand" "")
2263 (compare:CC (and:SI (match_operand:SI 1 "gpc_reg_operand" "")
2264 (match_operand:SI 2 "and_operand" ""))
1fd4e8c1 2265 (const_int 0)))
52d3af72
DE
2266 (clobber (match_scratch:SI 3 ""))
2267 (clobber (match_scratch:CC 4 ""))]
0ba1b2ff 2268 "reload_completed"
52d3af72
DE
2269 [(parallel [(set (match_dup 3)
2270 (and:SI (match_dup 1)
2271 (match_dup 2)))
2272 (clobber (match_dup 4))])
2273 (set (match_dup 0)
2274 (compare:CC (match_dup 3)
2275 (const_int 0)))]
2276 "")
2277
0ba1b2ff
AM
2278;; We don't have a 32 bit "and. rt,ra,rb" for ppc64. cr is set from the
2279;; whole 64 bit reg, and we don't know what is in the high 32 bits.
2280
2281(define_split
2282 [(set (match_operand:CC 0 "cc_reg_operand" "")
2283 (compare:CC (and:SI (match_operand:SI 1 "gpc_reg_operand" "")
2284 (match_operand:SI 2 "gpc_reg_operand" ""))
2285 (const_int 0)))
2286 (clobber (match_scratch:SI 3 ""))
2287 (clobber (match_scratch:CC 4 ""))]
2288 "TARGET_POWERPC64 && reload_completed"
2289 [(parallel [(set (match_dup 3)
2290 (and:SI (match_dup 1)
2291 (match_dup 2)))
2292 (clobber (match_dup 4))])
2293 (set (match_dup 0)
2294 (compare:CC (match_dup 3)
2295 (const_int 0)))]
2296 "")
2297
2298(define_insn "*andsi3_internal4"
52d3af72
DE
2299 [(set (match_operand:CC 3 "cc_reg_operand" "=x,x,x,x,?y,??y,??y,?y")
2300 (compare:CC (and:SI (match_operand:SI 1 "gpc_reg_operand" "%r,r,r,r,r,r,r,r")
5f59ecb7 2301 (match_operand:SI 2 "and_operand" "r,K,L,T,r,K,L,T"))
52d3af72
DE
2302 (const_int 0)))
2303 (set (match_operand:SI 0 "gpc_reg_operand" "=r,r,r,r,r,r,r,r")
2304 (and:SI (match_dup 1)
2305 (match_dup 2)))
2306 (clobber (match_scratch:CC 4 "=X,X,X,X,X,x,x,X"))]
0ad91047 2307 "! TARGET_POWERPC64"
1fd4e8c1
RK
2308 "@
2309 and. %0,%1,%2
ca7f5001
RK
2310 {andil.|andi.} %0,%1,%b2
2311 {andiu.|andis.} %0,%1,%u2
52d3af72
DE
2312 {rlinm.|rlwinm.} %0,%1,0,%m2,%M2
2313 #
2314 #
2315 #
2316 #"
2317 [(set_attr "type" "compare,compare,compare,delayed_compare,compare,compare,compare,compare")
2318 (set_attr "length" "4,4,4,4,8,8,8,8")])
2319
0ba1b2ff
AM
2320(define_insn "*andsi3_internal5"
2321 [(set (match_operand:CC 3 "cc_reg_operand" "=x,x,x,x,?y,??y,??y,?y")
2322 (compare:CC (and:SI (match_operand:SI 1 "gpc_reg_operand" "%r,r,r,r,r,r,r,r")
2323 (match_operand:SI 2 "and_operand" "r,K,L,T,r,K,L,T"))
2324 (const_int 0)))
2325 (set (match_operand:SI 0 "gpc_reg_operand" "=r,r,r,r,r,r,r,r")
2326 (and:SI (match_dup 1)
2327 (match_dup 2)))
2328 (clobber (match_scratch:CC 4 "=X,X,X,X,X,x,x,X"))]
683bdff7 2329 "TARGET_64BIT"
0ba1b2ff
AM
2330 "@
2331 #
2332 {andil.|andi.} %0,%1,%b2
2333 {andiu.|andis.} %0,%1,%u2
2334 {rlinm.|rlwinm.} %0,%1,0,%m2,%M2
2335 #
2336 #
2337 #
2338 #"
2339 [(set_attr "type" "compare,compare,compare,delayed_compare,compare,compare,compare,compare")
2340 (set_attr "length" "8,4,4,4,8,8,8,8")])
2341
52d3af72
DE
2342(define_split
2343 [(set (match_operand:CC 3 "cc_reg_not_cr0_operand" "")
2344 (compare:CC (and:SI (match_operand:SI 1 "gpc_reg_operand" "")
2345 (match_operand:SI 2 "and_operand" ""))
2346 (const_int 0)))
2347 (set (match_operand:SI 0 "gpc_reg_operand" "")
2348 (and:SI (match_dup 1)
2349 (match_dup 2)))
2350 (clobber (match_scratch:CC 4 ""))]
0ba1b2ff 2351 "reload_completed"
52d3af72
DE
2352 [(parallel [(set (match_dup 0)
2353 (and:SI (match_dup 1)
2354 (match_dup 2)))
2355 (clobber (match_dup 4))])
2356 (set (match_dup 3)
2357 (compare:CC (match_dup 0)
2358 (const_int 0)))]
2359 "")
1fd4e8c1 2360
0ba1b2ff
AM
2361(define_split
2362 [(set (match_operand:CC 3 "cc_reg_operand" "")
2363 (compare:CC (and:SI (match_operand:SI 1 "gpc_reg_operand" "")
2364 (match_operand:SI 2 "gpc_reg_operand" ""))
2365 (const_int 0)))
2366 (set (match_operand:SI 0 "gpc_reg_operand" "")
2367 (and:SI (match_dup 1)
2368 (match_dup 2)))
2369 (clobber (match_scratch:CC 4 ""))]
2370 "TARGET_POWERPC64 && reload_completed"
2371 [(parallel [(set (match_dup 0)
2372 (and:SI (match_dup 1)
2373 (match_dup 2)))
2374 (clobber (match_dup 4))])
2375 (set (match_dup 3)
2376 (compare:CC (match_dup 0)
2377 (const_int 0)))]
2378 "")
2379
2380;; Handle the PowerPC64 rlwinm corner case
2381
2382(define_insn_and_split "*andsi3_internal6"
2383 [(set (match_operand:SI 0 "gpc_reg_operand" "=r")
2384 (and:SI (match_operand:SI 1 "gpc_reg_operand" "r")
2385 (match_operand:SI 2 "mask_operand_wrap" "i")))]
2386 "TARGET_POWERPC64"
2387 "#"
2388 "TARGET_POWERPC64"
2389 [(set (match_dup 0)
2390 (and:SI (rotate:SI (match_dup 1) (match_dup 3))
2391 (match_dup 4)))
2392 (set (match_dup 0)
2393 (rotate:SI (match_dup 0) (match_dup 5)))]
2394 "
2395{
2396 int mb = extract_MB (operands[2]);
2397 int me = extract_ME (operands[2]);
2398 operands[3] = GEN_INT (me + 1);
2399 operands[5] = GEN_INT (32 - (me + 1));
2400 operands[4] = GEN_INT (~((HOST_WIDE_INT) -1 << (33 + me - mb)));
2401}"
2402 [(set_attr "length" "8")])
2403
2404(define_insn_and_split "*andsi3_internal7"
2405 [(set (match_operand:CC 2 "cc_reg_operand" "=x,?y")
2406 (compare:CC (and:SI (match_operand:SI 0 "gpc_reg_operand" "r,r")
2407 (match_operand:SI 1 "mask_operand_wrap" "i,i"))
2408 (const_int 0)))
2409 (clobber (match_scratch:SI 3 "=r,r"))]
2410 "TARGET_POWERPC64"
2411 "#"
2412 "TARGET_POWERPC64"
2413 [(parallel [(set (match_dup 2)
2414 (compare:CC (and:SI (rotate:SI (match_dup 0) (match_dup 4))
2415 (match_dup 5))
2416 (const_int 0)))
2417 (clobber (match_dup 3))])]
2418 "
2419{
2420 int mb = extract_MB (operands[1]);
2421 int me = extract_ME (operands[1]);
2422 operands[4] = GEN_INT (me + 1);
2423 operands[5] = GEN_INT (~((HOST_WIDE_INT) -1 << (33 + me - mb)));
2424}"
2425 [(set_attr "type" "delayed_compare,compare")
2426 (set_attr "length" "4,8")])
2427
2428(define_insn_and_split "*andsi3_internal8"
2429 [(set (match_operand:CC 3 "cc_reg_operand" "=x,??y")
2430 (compare:CC (and:SI (match_operand:SI 1 "gpc_reg_operand" "r,r")
2431 (match_operand:SI 2 "mask_operand_wrap" "i,i"))
2432 (const_int 0)))
2433 (set (match_operand:SI 0 "gpc_reg_operand" "=r,r")
2434 (and:SI (match_dup 1)
2435 (match_dup 2)))]
2436 "TARGET_POWERPC64"
2437 "#"
2438 "TARGET_POWERPC64"
2439 [(parallel [(set (match_dup 3)
2440 (compare:CC (and:SI (rotate:SI (match_dup 1) (match_dup 4))
2441 (match_dup 5))
2442 (const_int 0)))
2443 (set (match_dup 0)
2444 (and:SI (rotate:SI (match_dup 1) (match_dup 4))
2445 (match_dup 5)))])
2446 (set (match_dup 0)
2447 (rotate:SI (match_dup 0) (match_dup 6)))]
2448 "
2449{
2450 int mb = extract_MB (operands[2]);
2451 int me = extract_ME (operands[2]);
2452 operands[4] = GEN_INT (me + 1);
2453 operands[6] = GEN_INT (32 - (me + 1));
2454 operands[5] = GEN_INT (~((HOST_WIDE_INT) -1 << (33 + me - mb)));
2455}"
2456 [(set_attr "type" "delayed_compare,compare")
2457 (set_attr "length" "8,12")])
2458
7cd5235b 2459(define_expand "iorsi3"
cd2b37d9 2460 [(set (match_operand:SI 0 "gpc_reg_operand" "")
7cd5235b 2461 (ior:SI (match_operand:SI 1 "gpc_reg_operand" "")
1d328b19 2462 (match_operand:SI 2 "reg_or_logical_cint_operand" "")))]
7cd5235b 2463 ""
f357808b
RK
2464 "
2465{
7cd5235b 2466 if (GET_CODE (operands[2]) == CONST_INT
677a9668 2467 && ! logical_operand (operands[2], SImode))
7cd5235b
MM
2468 {
2469 HOST_WIDE_INT value = INTVAL (operands[2]);
677a9668 2470 rtx tmp = ((no_new_pseudos || rtx_equal_p (operands[0], operands[1]))
7cd5235b
MM
2471 ? operands[0] : gen_reg_rtx (SImode));
2472
a260abc9
DE
2473 emit_insn (gen_iorsi3 (tmp, operands[1],
2474 GEN_INT (value & (~ (HOST_WIDE_INT) 0xffff))));
2475 emit_insn (gen_iorsi3 (operands[0], tmp, GEN_INT (value & 0xffff)));
7cd5235b
MM
2476 DONE;
2477 }
f357808b
RK
2478}")
2479
7cd5235b 2480(define_expand "xorsi3"
cd2b37d9 2481 [(set (match_operand:SI 0 "gpc_reg_operand" "")
7cd5235b 2482 (xor:SI (match_operand:SI 1 "gpc_reg_operand" "")
1d328b19 2483 (match_operand:SI 2 "reg_or_logical_cint_operand" "")))]
1fd4e8c1 2484 ""
7cd5235b 2485 "
1fd4e8c1 2486{
7cd5235b 2487 if (GET_CODE (operands[2]) == CONST_INT
677a9668 2488 && ! logical_operand (operands[2], SImode))
7cd5235b
MM
2489 {
2490 HOST_WIDE_INT value = INTVAL (operands[2]);
677a9668 2491 rtx tmp = ((no_new_pseudos || rtx_equal_p (operands[0], operands[1]))
7cd5235b
MM
2492 ? operands[0] : gen_reg_rtx (SImode));
2493
a260abc9
DE
2494 emit_insn (gen_xorsi3 (tmp, operands[1],
2495 GEN_INT (value & (~ (HOST_WIDE_INT) 0xffff))));
2496 emit_insn (gen_xorsi3 (operands[0], tmp, GEN_INT (value & 0xffff)));
7cd5235b
MM
2497 DONE;
2498 }
1fd4e8c1
RK
2499}")
2500
dfbdccdb 2501(define_insn "*boolsi3_internal1"
7cd5235b 2502 [(set (match_operand:SI 0 "gpc_reg_operand" "=r,r,r")
1d328b19 2503 (match_operator:SI 3 "boolean_or_operator"
dfbdccdb
GK
2504 [(match_operand:SI 1 "gpc_reg_operand" "%r,r,r")
2505 (match_operand:SI 2 "logical_operand" "r,K,L")]))]
1fd4e8c1
RK
2506 ""
2507 "@
dfbdccdb
GK
2508 %q3 %0,%1,%2
2509 {%q3il|%q3i} %0,%1,%b2
2510 {%q3iu|%q3is} %0,%1,%u2")
1fd4e8c1 2511
dfbdccdb 2512(define_insn "*boolsi3_internal2"
52d3af72 2513 [(set (match_operand:CC 0 "cc_reg_operand" "=x,?y")
1d328b19 2514 (compare:CC (match_operator:SI 4 "boolean_or_operator"
dfbdccdb
GK
2515 [(match_operand:SI 1 "gpc_reg_operand" "%r,r")
2516 (match_operand:SI 2 "gpc_reg_operand" "r,r")])
2517 (const_int 0)))
52d3af72 2518 (clobber (match_scratch:SI 3 "=r,r"))]
0ad91047 2519 "! TARGET_POWERPC64"
52d3af72 2520 "@
dfbdccdb 2521 %q4. %3,%1,%2
52d3af72
DE
2522 #"
2523 [(set_attr "type" "compare")
2524 (set_attr "length" "4,8")])
2525
2526(define_split
2527 [(set (match_operand:CC 0 "cc_reg_not_cr0_operand" "")
dfbdccdb 2528 (compare:CC (match_operator:SI 4 "boolean_operator"
75540af0
JH
2529 [(match_operand:SI 1 "gpc_reg_operand" "")
2530 (match_operand:SI 2 "gpc_reg_operand" "")])
dfbdccdb 2531 (const_int 0)))
52d3af72 2532 (clobber (match_scratch:SI 3 ""))]
0ad91047 2533 "! TARGET_POWERPC64 && reload_completed"
dfbdccdb 2534 [(set (match_dup 3) (match_dup 4))
52d3af72
DE
2535 (set (match_dup 0)
2536 (compare:CC (match_dup 3)
2537 (const_int 0)))]
2538 "")
815cdc52 2539
dfbdccdb 2540(define_insn "*boolsi3_internal3"
52d3af72 2541 [(set (match_operand:CC 3 "cc_reg_operand" "=x,?y")
dfbdccdb
GK
2542 (compare:CC (match_operator:SI 4 "boolean_operator"
2543 [(match_operand:SI 1 "gpc_reg_operand" "%r,r")
2544 (match_operand:SI 2 "gpc_reg_operand" "r,r")])
2545 (const_int 0)))
52d3af72 2546 (set (match_operand:SI 0 "gpc_reg_operand" "=r,r")
dfbdccdb 2547 (match_dup 4))]
0ad91047 2548 "! TARGET_POWERPC64"
52d3af72 2549 "@
dfbdccdb 2550 %q4. %0,%1,%2
52d3af72
DE
2551 #"
2552 [(set_attr "type" "compare")
2553 (set_attr "length" "4,8")])
2554
2555(define_split
e72247f4 2556 [(set (match_operand:CC 3 "cc_reg_not_cr0_operand" "")
dfbdccdb 2557 (compare:CC (match_operator:SI 4 "boolean_operator"
75540af0
JH
2558 [(match_operand:SI 1 "gpc_reg_operand" "")
2559 (match_operand:SI 2 "gpc_reg_operand" "")])
dfbdccdb 2560 (const_int 0)))
75540af0 2561 (set (match_operand:SI 0 "gpc_reg_operand" "")
dfbdccdb 2562 (match_dup 4))]
0ad91047 2563 "! TARGET_POWERPC64 && reload_completed"
dfbdccdb 2564 [(set (match_dup 0) (match_dup 4))
52d3af72
DE
2565 (set (match_dup 3)
2566 (compare:CC (match_dup 0)
2567 (const_int 0)))]
2568 "")
1fd4e8c1 2569
5bdc5878 2570;; Split a logical operation that we can't do in one insn into two insns,
dfbdccdb 2571;; each of which does one 16-bit part. This is used by combine.
a260abc9
DE
2572
2573(define_split
2574 [(set (match_operand:SI 0 "gpc_reg_operand" "")
1d328b19 2575 (match_operator:SI 3 "boolean_or_operator"
dfbdccdb
GK
2576 [(match_operand:SI 1 "gpc_reg_operand" "")
2577 (match_operand:SI 2 "non_logical_cint_operand" "")]))]
a260abc9 2578 ""
dfbdccdb
GK
2579 [(set (match_dup 0) (match_dup 4))
2580 (set (match_dup 0) (match_dup 5))]
a260abc9
DE
2581"
2582{
dfbdccdb
GK
2583 rtx i;
2584 i = GEN_INT (INTVAL (operands[2]) & (~ (HOST_WIDE_INT) 0xffff));
2585 operands[4] = gen_rtx (GET_CODE (operands[3]), SImode,
2586 operands[1], i);
2587 i = GEN_INT (INTVAL (operands[2]) & 0xffff);
2588 operands[5] = gen_rtx (GET_CODE (operands[3]), SImode,
2589 operands[0], i);
a260abc9
DE
2590}")
2591
dfbdccdb 2592(define_insn "*boolcsi3_internal1"
cd2b37d9 2593 [(set (match_operand:SI 0 "gpc_reg_operand" "=r")
dfbdccdb
GK
2594 (match_operator:SI 3 "boolean_operator"
2595 [(not:SI (match_operand:SI 1 "gpc_reg_operand" "r"))
40501e5f 2596 (match_operand:SI 2 "gpc_reg_operand" "r")]))]
1fd4e8c1 2597 ""
dfbdccdb 2598 "%q3 %0,%2,%1")
1fd4e8c1 2599
dfbdccdb 2600(define_insn "*boolcsi3_internal2"
52d3af72 2601 [(set (match_operand:CC 0 "cc_reg_operand" "=x,?y")
dfbdccdb
GK
2602 (compare:CC (match_operator:SI 4 "boolean_operator"
2603 [(not:SI (match_operand:SI 1 "gpc_reg_operand" "r,r"))
2604 (match_operand:SI 2 "gpc_reg_operand" "r,r")])
2605 (const_int 0)))
52d3af72 2606 (clobber (match_scratch:SI 3 "=r,r"))]
0ad91047 2607 "! TARGET_POWERPC64"
52d3af72 2608 "@
dfbdccdb 2609 %q4. %3,%2,%1
52d3af72
DE
2610 #"
2611 [(set_attr "type" "compare")
2612 (set_attr "length" "4,8")])
2613
2614(define_split
2615 [(set (match_operand:CC 0 "cc_reg_not_cr0_operand" "")
dfbdccdb 2616 (compare:CC (match_operator:SI 4 "boolean_operator"
75540af0
JH
2617 [(not:SI (match_operand:SI 1 "gpc_reg_operand" ""))
2618 (match_operand:SI 2 "gpc_reg_operand" "")])
dfbdccdb 2619 (const_int 0)))
52d3af72 2620 (clobber (match_scratch:SI 3 ""))]
0ad91047 2621 "! TARGET_POWERPC64 && reload_completed"
dfbdccdb 2622 [(set (match_dup 3) (match_dup 4))
52d3af72
DE
2623 (set (match_dup 0)
2624 (compare:CC (match_dup 3)
2625 (const_int 0)))]
2626 "")
1fd4e8c1 2627
dfbdccdb 2628(define_insn "*boolcsi3_internal3"
52d3af72 2629 [(set (match_operand:CC 3 "cc_reg_operand" "=x,?y")
dfbdccdb
GK
2630 (compare:CC (match_operator:SI 4 "boolean_operator"
2631 [(not:SI (match_operand:SI 1 "gpc_reg_operand" "%r,r"))
2632 (match_operand:SI 2 "gpc_reg_operand" "r,r")])
2633 (const_int 0)))
52d3af72 2634 (set (match_operand:SI 0 "gpc_reg_operand" "=r,r")
dfbdccdb 2635 (match_dup 4))]
0ad91047 2636 "! TARGET_POWERPC64"
52d3af72 2637 "@
dfbdccdb 2638 %q4. %0,%2,%1
52d3af72
DE
2639 #"
2640 [(set_attr "type" "compare")
2641 (set_attr "length" "4,8")])
2642
2643(define_split
e72247f4 2644 [(set (match_operand:CC 3 "cc_reg_not_cr0_operand" "")
dfbdccdb 2645 (compare:CC (match_operator:SI 4 "boolean_operator"
75540af0
JH
2646 [(not:SI (match_operand:SI 1 "gpc_reg_operand" ""))
2647 (match_operand:SI 2 "gpc_reg_operand" "")])
dfbdccdb 2648 (const_int 0)))
75540af0 2649 (set (match_operand:SI 0 "gpc_reg_operand" "")
dfbdccdb 2650 (match_dup 4))]
0ad91047 2651 "! TARGET_POWERPC64 && reload_completed"
dfbdccdb 2652 [(set (match_dup 0) (match_dup 4))
52d3af72
DE
2653 (set (match_dup 3)
2654 (compare:CC (match_dup 0)
2655 (const_int 0)))]
2656 "")
2657
dfbdccdb 2658(define_insn "*boolccsi3_internal1"
cd2b37d9 2659 [(set (match_operand:SI 0 "gpc_reg_operand" "=r")
dfbdccdb
GK
2660 (match_operator:SI 3 "boolean_operator"
2661 [(not:SI (match_operand:SI 1 "gpc_reg_operand" "r"))
40501e5f 2662 (not:SI (match_operand:SI 2 "gpc_reg_operand" "r"))]))]
1fd4e8c1 2663 ""
dfbdccdb 2664 "%q3 %0,%1,%2")
1fd4e8c1 2665
dfbdccdb 2666(define_insn "*boolccsi3_internal2"
52d3af72 2667 [(set (match_operand:CC 0 "cc_reg_operand" "=x,?y")
dfbdccdb
GK
2668 (compare:CC (match_operator:SI 4 "boolean_operator"
2669 [(not:SI (match_operand:SI 1 "gpc_reg_operand" "r,r"))
2670 (not:SI (match_operand:SI 2 "gpc_reg_operand" "r,r"))])
2671 (const_int 0)))
52d3af72 2672 (clobber (match_scratch:SI 3 "=r,r"))]
0ad91047 2673 "! TARGET_POWERPC64"
52d3af72 2674 "@
dfbdccdb 2675 %q4. %3,%1,%2
52d3af72
DE
2676 #"
2677 [(set_attr "type" "compare")
2678 (set_attr "length" "4,8")])
2679
2680(define_split
2681 [(set (match_operand:CC 0 "cc_reg_not_cr0_operand" "")
dfbdccdb 2682 (compare:CC (match_operator:SI 4 "boolean_operator"
75540af0
JH
2683 [(not:SI (match_operand:SI 1 "gpc_reg_operand" ""))
2684 (not:SI (match_operand:SI 2 "gpc_reg_operand" ""))])
dfbdccdb 2685 (const_int 0)))
52d3af72 2686 (clobber (match_scratch:SI 3 ""))]
0ad91047 2687 "! TARGET_POWERPC64 && reload_completed"
dfbdccdb 2688 [(set (match_dup 3) (match_dup 4))
52d3af72
DE
2689 (set (match_dup 0)
2690 (compare:CC (match_dup 3)
2691 (const_int 0)))]
2692 "")
1fd4e8c1 2693
dfbdccdb 2694(define_insn "*boolccsi3_internal3"
52d3af72 2695 [(set (match_operand:CC 3 "cc_reg_operand" "=x,?y")
dfbdccdb
GK
2696 (compare:CC (match_operator:SI 4 "boolean_operator"
2697 [(not:SI (match_operand:SI 1 "gpc_reg_operand" "%r,r"))
2698 (not:SI (match_operand:SI 2 "gpc_reg_operand" "r,r"))])
2699 (const_int 0)))
52d3af72 2700 (set (match_operand:SI 0 "gpc_reg_operand" "=r,r")
dfbdccdb 2701 (match_dup 4))]
0ad91047 2702 "! TARGET_POWERPC64"
52d3af72 2703 "@
dfbdccdb 2704 %q4. %0,%1,%2
52d3af72
DE
2705 #"
2706 [(set_attr "type" "compare")
2707 (set_attr "length" "4,8")])
2708
2709(define_split
e72247f4 2710 [(set (match_operand:CC 3 "cc_reg_not_cr0_operand" "")
dfbdccdb 2711 (compare:CC (match_operator:SI 4 "boolean_operator"
75540af0
JH
2712 [(not:SI (match_operand:SI 1 "gpc_reg_operand" ""))
2713 (not:SI (match_operand:SI 2 "gpc_reg_operand" ""))])
dfbdccdb 2714 (const_int 0)))
75540af0 2715 (set (match_operand:SI 0 "gpc_reg_operand" "")
dfbdccdb 2716 (match_dup 4))]
0ad91047 2717 "! TARGET_POWERPC64 && reload_completed"
dfbdccdb 2718 [(set (match_dup 0) (match_dup 4))
52d3af72
DE
2719 (set (match_dup 3)
2720 (compare:CC (match_dup 0)
2721 (const_int 0)))]
2722 "")
1fd4e8c1
RK
2723
2724;; maskir insn. We need four forms because things might be in arbitrary
2725;; orders. Don't define forms that only set CR fields because these
2726;; would modify an input register.
2727
7cd5235b 2728(define_insn "*maskir_internal1"
cd2b37d9 2729 [(set (match_operand:SI 0 "gpc_reg_operand" "=r")
01def764
RK
2730 (ior:SI (and:SI (not:SI (match_operand:SI 2 "gpc_reg_operand" "r"))
2731 (match_operand:SI 1 "gpc_reg_operand" "0"))
2732 (and:SI (match_dup 2)
cd2b37d9 2733 (match_operand:SI 3 "gpc_reg_operand" "r"))))]
ca7f5001 2734 "TARGET_POWER"
01def764 2735 "maskir %0,%3,%2")
1fd4e8c1 2736
7cd5235b 2737(define_insn "*maskir_internal2"
242e8072 2738 [(set (match_operand:SI 0 "gpc_reg_operand" "=r")
01def764
RK
2739 (ior:SI (and:SI (not:SI (match_operand:SI 2 "gpc_reg_operand" "r"))
2740 (match_operand:SI 1 "gpc_reg_operand" "0"))
cd2b37d9 2741 (and:SI (match_operand:SI 3 "gpc_reg_operand" "r")
01def764 2742 (match_dup 2))))]
ca7f5001 2743 "TARGET_POWER"
01def764 2744 "maskir %0,%3,%2")
1fd4e8c1 2745
7cd5235b 2746(define_insn "*maskir_internal3"
cd2b37d9 2747 [(set (match_operand:SI 0 "gpc_reg_operand" "=r")
01def764 2748 (ior:SI (and:SI (match_operand:SI 2 "gpc_reg_operand" "r")
cd2b37d9 2749 (match_operand:SI 3 "gpc_reg_operand" "r"))
01def764
RK
2750 (and:SI (not:SI (match_dup 2))
2751 (match_operand:SI 1 "gpc_reg_operand" "0"))))]
ca7f5001 2752 "TARGET_POWER"
01def764 2753 "maskir %0,%3,%2")
1fd4e8c1 2754
7cd5235b 2755(define_insn "*maskir_internal4"
cd2b37d9
RK
2756 [(set (match_operand:SI 0 "gpc_reg_operand" "=r")
2757 (ior:SI (and:SI (match_operand:SI 3 "gpc_reg_operand" "r")
01def764
RK
2758 (match_operand:SI 2 "gpc_reg_operand" "r"))
2759 (and:SI (not:SI (match_dup 2))
2760 (match_operand:SI 1 "gpc_reg_operand" "0"))))]
ca7f5001 2761 "TARGET_POWER"
01def764 2762 "maskir %0,%3,%2")
1fd4e8c1 2763
7cd5235b 2764(define_insn "*maskir_internal5"
9ebbca7d 2765 [(set (match_operand:CC 4 "cc_reg_operand" "=x,?y")
1fd4e8c1 2766 (compare:CC
9ebbca7d
GK
2767 (ior:SI (and:SI (not:SI (match_operand:SI 2 "gpc_reg_operand" "r,r"))
2768 (match_operand:SI 1 "gpc_reg_operand" "0,0"))
01def764 2769 (and:SI (match_dup 2)
9ebbca7d 2770 (match_operand:SI 3 "gpc_reg_operand" "r,r")))
1fd4e8c1 2771 (const_int 0)))
9ebbca7d 2772 (set (match_operand:SI 0 "gpc_reg_operand" "=r,r")
01def764
RK
2773 (ior:SI (and:SI (not:SI (match_dup 2)) (match_dup 1))
2774 (and:SI (match_dup 2) (match_dup 3))))]
ca7f5001 2775 "TARGET_POWER"
9ebbca7d
GK
2776 "@
2777 maskir. %0,%3,%2
2778 #"
2779 [(set_attr "type" "compare")
2780 (set_attr "length" "4,8")])
2781
2782(define_split
2783 [(set (match_operand:CC 4 "cc_reg_not_cr0_operand" "")
2784 (compare:CC
2785 (ior:SI (and:SI (not:SI (match_operand:SI 2 "gpc_reg_operand" ""))
2786 (match_operand:SI 1 "gpc_reg_operand" ""))
2787 (and:SI (match_dup 2)
2788 (match_operand:SI 3 "gpc_reg_operand" "")))
2789 (const_int 0)))
2790 (set (match_operand:SI 0 "gpc_reg_operand" "")
2791 (ior:SI (and:SI (not:SI (match_dup 2)) (match_dup 1))
2792 (and:SI (match_dup 2) (match_dup 3))))]
2793 "TARGET_POWER && reload_completed"
2794 [(set (match_dup 0)
2795 (ior:SI (and:SI (not:SI (match_dup 2)) (match_dup 1))
2796 (and:SI (match_dup 2) (match_dup 3))))
2797 (set (match_dup 4)
2798 (compare:CC (match_dup 0)
2799 (const_int 0)))]
2800 "")
1fd4e8c1 2801
7cd5235b 2802(define_insn "*maskir_internal6"
9ebbca7d 2803 [(set (match_operand:CC 4 "cc_reg_operand" "=x,?y")
1fd4e8c1 2804 (compare:CC
9ebbca7d
GK
2805 (ior:SI (and:SI (not:SI (match_operand:SI 2 "gpc_reg_operand" "r,r"))
2806 (match_operand:SI 1 "gpc_reg_operand" "0,0"))
2807 (and:SI (match_operand:SI 3 "gpc_reg_operand" "r,r")
01def764 2808 (match_dup 2)))
1fd4e8c1 2809 (const_int 0)))
9ebbca7d 2810 (set (match_operand:SI 0 "gpc_reg_operand" "=r,r")
01def764
RK
2811 (ior:SI (and:SI (not:SI (match_dup 2)) (match_dup 1))
2812 (and:SI (match_dup 3) (match_dup 2))))]
ca7f5001 2813 "TARGET_POWER"
9ebbca7d
GK
2814 "@
2815 maskir. %0,%3,%2
2816 #"
2817 [(set_attr "type" "compare")
2818 (set_attr "length" "4,8")])
2819
2820(define_split
2821 [(set (match_operand:CC 4 "cc_reg_not_cr0_operand" "")
2822 (compare:CC
2823 (ior:SI (and:SI (not:SI (match_operand:SI 2 "gpc_reg_operand" ""))
2824 (match_operand:SI 1 "gpc_reg_operand" ""))
2825 (and:SI (match_operand:SI 3 "gpc_reg_operand" "")
2826 (match_dup 2)))
2827 (const_int 0)))
2828 (set (match_operand:SI 0 "gpc_reg_operand" "")
2829 (ior:SI (and:SI (not:SI (match_dup 2)) (match_dup 1))
2830 (and:SI (match_dup 3) (match_dup 2))))]
2831 "TARGET_POWER && reload_completed"
2832 [(set (match_dup 0)
2833 (ior:SI (and:SI (not:SI (match_dup 2)) (match_dup 1))
2834 (and:SI (match_dup 3) (match_dup 2))))
2835 (set (match_dup 4)
2836 (compare:CC (match_dup 0)
2837 (const_int 0)))]
2838 "")
1fd4e8c1 2839
7cd5235b 2840(define_insn "*maskir_internal7"
9ebbca7d 2841 [(set (match_operand:CC 4 "cc_reg_operand" "=x,?y")
815cdc52 2842 (compare:CC
9ebbca7d
GK
2843 (ior:SI (and:SI (match_operand:SI 2 "gpc_reg_operand" "r,r")
2844 (match_operand:SI 3 "gpc_reg_operand" "r,r"))
815cdc52 2845 (and:SI (not:SI (match_dup 2))
9ebbca7d 2846 (match_operand:SI 1 "gpc_reg_operand" "0,0")))
815cdc52 2847 (const_int 0)))
9ebbca7d 2848 (set (match_operand:SI 0 "gpc_reg_operand" "=r,r")
815cdc52
MM
2849 (ior:SI (and:SI (match_dup 2) (match_dup 3))
2850 (and:SI (not:SI (match_dup 2)) (match_dup 1))))]
2851 "TARGET_POWER"
9ebbca7d
GK
2852 "@
2853 maskir. %0,%3,%2
2854 #"
2855 [(set_attr "type" "compare")
2856 (set_attr "length" "4,8")])
2857
2858(define_split
2859 [(set (match_operand:CC 4 "cc_reg_not_cr0_operand" "")
2860 (compare:CC
2861 (ior:SI (and:SI (match_operand:SI 2 "gpc_reg_operand" "")
2862 (match_operand:SI 3 "gpc_reg_operand" ""))
2863 (and:SI (not:SI (match_dup 2))
2864 (match_operand:SI 1 "gpc_reg_operand" "")))
2865 (const_int 0)))
2866 (set (match_operand:SI 0 "gpc_reg_operand" "")
2867 (ior:SI (and:SI (match_dup 2) (match_dup 3))
2868 (and:SI (not:SI (match_dup 2)) (match_dup 1))))]
2869 "TARGET_POWER && reload_completed"
2870 [(set (match_dup 0)
2871 (ior:SI (and:SI (match_dup 2) (match_dup 3))
2872 (and:SI (not:SI (match_dup 2)) (match_dup 1))))
2873 (set (match_dup 4)
2874 (compare:CC (match_dup 0)
2875 (const_int 0)))]
2876 "")
1fd4e8c1 2877
7cd5235b 2878(define_insn "*maskir_internal8"
9ebbca7d 2879 [(set (match_operand:CC 4 "cc_reg_operand" "=x,?y")
1fd4e8c1 2880 (compare:CC
9ebbca7d
GK
2881 (ior:SI (and:SI (match_operand:SI 3 "gpc_reg_operand" "r,r")
2882 (match_operand:SI 2 "gpc_reg_operand" "r,r"))
01def764 2883 (and:SI (not:SI (match_dup 2))
9ebbca7d 2884 (match_operand:SI 1 "gpc_reg_operand" "0,0")))
1fd4e8c1 2885 (const_int 0)))
9ebbca7d 2886 (set (match_operand:SI 0 "gpc_reg_operand" "=r,r")
01def764
RK
2887 (ior:SI (and:SI (match_dup 3) (match_dup 2))
2888 (and:SI (not:SI (match_dup 2)) (match_dup 1))))]
ca7f5001 2889 "TARGET_POWER"
9ebbca7d
GK
2890 "@
2891 maskir. %0,%3,%2
2892 #"
2893 [(set_attr "type" "compare")
2894 (set_attr "length" "4,8")])
fcce224d 2895
9ebbca7d
GK
2896(define_split
2897 [(set (match_operand:CC 4 "cc_reg_not_cr0_operand" "")
2898 (compare:CC
2899 (ior:SI (and:SI (match_operand:SI 3 "gpc_reg_operand" "")
2900 (match_operand:SI 2 "gpc_reg_operand" ""))
2901 (and:SI (not:SI (match_dup 2))
2902 (match_operand:SI 1 "gpc_reg_operand" "")))
2903 (const_int 0)))
2904 (set (match_operand:SI 0 "gpc_reg_operand" "")
2905 (ior:SI (and:SI (match_dup 3) (match_dup 2))
2906 (and:SI (not:SI (match_dup 2)) (match_dup 1))))]
2907 "TARGET_POWER && reload_completed"
2908 [(set (match_dup 0)
2909 (ior:SI (and:SI (match_dup 3) (match_dup 2))
2910 (and:SI (not:SI (match_dup 2)) (match_dup 1))))
2911 (set (match_dup 4)
2912 (compare:CC (match_dup 0)
2913 (const_int 0)))]
2914 "")
fcce224d 2915\f
1fd4e8c1
RK
2916;; Rotate and shift insns, in all their variants. These support shifts,
2917;; field inserts and extracts, and various combinations thereof.
034c1be0 2918(define_expand "insv"
0ad91047
DE
2919 [(set (zero_extract (match_operand 0 "gpc_reg_operand" "")
2920 (match_operand:SI 1 "const_int_operand" "")
2921 (match_operand:SI 2 "const_int_operand" ""))
2922 (match_operand 3 "gpc_reg_operand" ""))]
034c1be0
MM
2923 ""
2924 "
2925{
2926 /* Do not handle 16/8 bit structures that fit in HI/QI modes directly, since
2927 the (SUBREG:SI (REG:HI xxx)) that is otherwise generated can confuse the
2928 compiler if the address of the structure is taken later. */
2929 if (GET_CODE (operands[0]) == SUBREG
2930 && (GET_MODE_SIZE (GET_MODE (SUBREG_REG (operands[0]))) < UNITS_PER_WORD))
2931 FAIL;
a78e33fc
DE
2932
2933 if (TARGET_POWERPC64 && GET_MODE (operands[0]) == DImode)
2934 emit_insn (gen_insvdi (operands[0], operands[1], operands[2], operands[3]));
2935 else
2936 emit_insn (gen_insvsi (operands[0], operands[1], operands[2], operands[3]));
2937 DONE;
034c1be0
MM
2938}")
2939
a78e33fc 2940(define_insn "insvsi"
cd2b37d9 2941 [(set (zero_extract:SI (match_operand:SI 0 "gpc_reg_operand" "+r")
1fd4e8c1
RK
2942 (match_operand:SI 1 "const_int_operand" "i")
2943 (match_operand:SI 2 "const_int_operand" "i"))
cd2b37d9 2944 (match_operand:SI 3 "gpc_reg_operand" "r"))]
1fd4e8c1
RK
2945 ""
2946 "*
2947{
2948 int start = INTVAL (operands[2]) & 31;
2949 int size = INTVAL (operands[1]) & 31;
2950
89e9f3a8
MM
2951 operands[4] = GEN_INT (32 - start - size);
2952 operands[1] = GEN_INT (start + size - 1);
a66078ee 2953 return \"{rlimi|rlwimi} %0,%3,%h4,%h2,%h1\";
8e8238f1
DE
2954}"
2955 [(set_attr "type" "insert_word")])
1fd4e8c1 2956
a78e33fc 2957(define_insn "*insvsi_internal1"
d56d506a
RK
2958 [(set (zero_extract:SI (match_operand:SI 0 "gpc_reg_operand" "+r")
2959 (match_operand:SI 1 "const_int_operand" "i")
2960 (match_operand:SI 2 "const_int_operand" "i"))
2961 (ashift:SI (match_operand:SI 3 "gpc_reg_operand" "r")
2962 (match_operand:SI 4 "const_int_operand" "i")))]
f0dc3f49 2963 "(32 - (INTVAL (operands[4]) & 31)) >= INTVAL (operands[1])"
d56d506a
RK
2964 "*
2965{
2966 int shift = INTVAL (operands[4]) & 31;
2967 int start = INTVAL (operands[2]) & 31;
2968 int size = INTVAL (operands[1]) & 31;
2969
89e9f3a8
MM
2970 operands[4] = GEN_INT (shift - start - size);
2971 operands[1] = GEN_INT (start + size - 1);
a66078ee 2972 return \"{rlimi|rlwimi} %0,%3,%h4,%h2,%h1\";
8e8238f1
DE
2973}"
2974 [(set_attr "type" "insert_word")])
d56d506a 2975
a78e33fc 2976(define_insn "*insvsi_internal2"
d56d506a
RK
2977 [(set (zero_extract:SI (match_operand:SI 0 "gpc_reg_operand" "+r")
2978 (match_operand:SI 1 "const_int_operand" "i")
2979 (match_operand:SI 2 "const_int_operand" "i"))
2980 (ashiftrt:SI (match_operand:SI 3 "gpc_reg_operand" "r")
2981 (match_operand:SI 4 "const_int_operand" "i")))]
f0dc3f49 2982 "(32 - (INTVAL (operands[4]) & 31)) >= INTVAL (operands[1])"
d56d506a
RK
2983 "*
2984{
2985 int shift = INTVAL (operands[4]) & 31;
2986 int start = INTVAL (operands[2]) & 31;
2987 int size = INTVAL (operands[1]) & 31;
2988
89e9f3a8
MM
2989 operands[4] = GEN_INT (32 - shift - start - size);
2990 operands[1] = GEN_INT (start + size - 1);
a66078ee 2991 return \"{rlimi|rlwimi} %0,%3,%h4,%h2,%h1\";
8e8238f1
DE
2992}"
2993 [(set_attr "type" "insert_word")])
d56d506a 2994
a78e33fc 2995(define_insn "*insvsi_internal3"
d56d506a
RK
2996 [(set (zero_extract:SI (match_operand:SI 0 "gpc_reg_operand" "+r")
2997 (match_operand:SI 1 "const_int_operand" "i")
2998 (match_operand:SI 2 "const_int_operand" "i"))
2999 (lshiftrt:SI (match_operand:SI 3 "gpc_reg_operand" "r")
3000 (match_operand:SI 4 "const_int_operand" "i")))]
95e8f2f3 3001 "(32 - (INTVAL (operands[4]) & 31)) >= INTVAL (operands[1])"
d56d506a
RK
3002 "*
3003{
3004 int shift = INTVAL (operands[4]) & 31;
3005 int start = INTVAL (operands[2]) & 31;
3006 int size = INTVAL (operands[1]) & 31;
3007
89e9f3a8
MM
3008 operands[4] = GEN_INT (32 - shift - start - size);
3009 operands[1] = GEN_INT (start + size - 1);
a66078ee 3010 return \"{rlimi|rlwimi} %0,%3,%h4,%h2,%h1\";
8e8238f1
DE
3011}"
3012 [(set_attr "type" "insert_word")])
d56d506a 3013
a78e33fc 3014(define_insn "*insvsi_internal4"
d56d506a
RK
3015 [(set (zero_extract:SI (match_operand:SI 0 "gpc_reg_operand" "+r")
3016 (match_operand:SI 1 "const_int_operand" "i")
3017 (match_operand:SI 2 "const_int_operand" "i"))
3018 (zero_extract:SI (match_operand:SI 3 "gpc_reg_operand" "r")
3019 (match_operand:SI 4 "const_int_operand" "i")
3020 (match_operand:SI 5 "const_int_operand" "i")))]
3021 "INTVAL (operands[4]) >= INTVAL (operands[1])"
3022 "*
3023{
3024 int extract_start = INTVAL (operands[5]) & 31;
3025 int extract_size = INTVAL (operands[4]) & 31;
3026 int insert_start = INTVAL (operands[2]) & 31;
3027 int insert_size = INTVAL (operands[1]) & 31;
3028
3029/* Align extract field with insert field */
3a598fbe 3030 operands[5] = GEN_INT (extract_start + extract_size - insert_start - insert_size);
89e9f3a8 3031 operands[1] = GEN_INT (insert_start + insert_size - 1);
a66078ee 3032 return \"{rlimi|rlwimi} %0,%3,%h5,%h2,%h1\";
8e8238f1
DE
3033}"
3034 [(set_attr "type" "insert_word")])
d56d506a 3035
a78e33fc 3036(define_insn "insvdi"
685f3906 3037 [(set (zero_extract:DI (match_operand:DI 0 "gpc_reg_operand" "+r")
a78e33fc
DE
3038 (match_operand:SI 1 "const_int_operand" "i")
3039 (match_operand:SI 2 "const_int_operand" "i"))
685f3906
DE
3040 (match_operand:DI 3 "gpc_reg_operand" "r"))]
3041 "TARGET_POWERPC64"
3042 "*
3043{
3044 int start = INTVAL (operands[2]) & 63;
3045 int size = INTVAL (operands[1]) & 63;
3046
a78e33fc
DE
3047 operands[1] = GEN_INT (64 - start - size);
3048 return \"rldimi %0,%3,%H1,%H2\";
685f3906
DE
3049}")
3050
034c1be0 3051(define_expand "extzv"
0ad91047
DE
3052 [(set (match_operand 0 "gpc_reg_operand" "")
3053 (zero_extract (match_operand 1 "gpc_reg_operand" "")
3054 (match_operand:SI 2 "const_int_operand" "")
3055 (match_operand:SI 3 "const_int_operand" "")))]
034c1be0
MM
3056 ""
3057 "
3058{
3059 /* Do not handle 16/8 bit structures that fit in HI/QI modes directly, since
3060 the (SUBREG:SI (REG:HI xxx)) that is otherwise generated can confuse the
3061 compiler if the address of the structure is taken later. */
3062 if (GET_CODE (operands[0]) == SUBREG
3063 && (GET_MODE_SIZE (GET_MODE (SUBREG_REG (operands[0]))) < UNITS_PER_WORD))
3064 FAIL;
a78e33fc
DE
3065
3066 if (TARGET_POWERPC64 && GET_MODE (operands[1]) == DImode)
3067 emit_insn (gen_extzvdi (operands[0], operands[1], operands[2], operands[3]));
3068 else
3069 emit_insn (gen_extzvsi (operands[0], operands[1], operands[2], operands[3]));
3070 DONE;
034c1be0
MM
3071}")
3072
a78e33fc 3073(define_insn "extzvsi"
cd2b37d9
RK
3074 [(set (match_operand:SI 0 "gpc_reg_operand" "=r")
3075 (zero_extract:SI (match_operand:SI 1 "gpc_reg_operand" "r")
1fd4e8c1
RK
3076 (match_operand:SI 2 "const_int_operand" "i")
3077 (match_operand:SI 3 "const_int_operand" "i")))]
3078 ""
3079 "*
3080{
3081 int start = INTVAL (operands[3]) & 31;
3082 int size = INTVAL (operands[2]) & 31;
3083
3084 if (start + size >= 32)
3085 operands[3] = const0_rtx;
3086 else
89e9f3a8 3087 operands[3] = GEN_INT (start + size);
ca7f5001 3088 return \"{rlinm|rlwinm} %0,%1,%3,%s2,31\";
1fd4e8c1
RK
3089}")
3090
a78e33fc 3091(define_insn "*extzvsi_internal1"
9ebbca7d
GK
3092 [(set (match_operand:CC 0 "cc_reg_operand" "=x,?y")
3093 (compare:CC (zero_extract:SI (match_operand:SI 1 "gpc_reg_operand" "r,r")
3094 (match_operand:SI 2 "const_int_operand" "i,i")
3095 (match_operand:SI 3 "const_int_operand" "i,i"))
1fd4e8c1 3096 (const_int 0)))
9ebbca7d 3097 (clobber (match_scratch:SI 4 "=r,r"))]
ce71f754 3098 ""
1fd4e8c1
RK
3099 "*
3100{
3101 int start = INTVAL (operands[3]) & 31;
3102 int size = INTVAL (operands[2]) & 31;
3103
9ebbca7d
GK
3104 /* Force split for non-cc0 compare. */
3105 if (which_alternative == 1)
3106 return \"#\";
3107
43a88a8c 3108 /* If the bit-field being tested fits in the upper or lower half of a
a7a975e1
RK
3109 word, it is possible to use andiu. or andil. to test it. This is
3110 useful because the condition register set-use delay is smaller for
3111 andi[ul]. than for rlinm. This doesn't work when the starting bit
3112 position is 0 because the LT and GT bits may be set wrong. */
3113
3114 if ((start > 0 && start + size <= 16) || start >= 16)
df031c43 3115 {
3a598fbe 3116 operands[3] = GEN_INT (((1 << (16 - (start & 15)))
df031c43
RK
3117 - (1 << (16 - (start & 15) - size))));
3118 if (start < 16)
ca7f5001 3119 return \"{andiu.|andis.} %4,%1,%3\";
df031c43 3120 else
ca7f5001 3121 return \"{andil.|andi.} %4,%1,%3\";
df031c43 3122 }
7e69e155 3123
1fd4e8c1
RK
3124 if (start + size >= 32)
3125 operands[3] = const0_rtx;
3126 else
89e9f3a8 3127 operands[3] = GEN_INT (start + size);
ca7f5001 3128 return \"{rlinm.|rlwinm.} %4,%1,%3,%s2,31\";
1fd4e8c1 3129}"
9ebbca7d
GK
3130 [(set_attr "type" "compare")
3131 (set_attr "length" "4,8")])
3132
3133(define_split
3134 [(set (match_operand:CC 0 "cc_reg_not_cr0_operand" "")
3135 (compare:CC (zero_extract:SI (match_operand:SI 1 "gpc_reg_operand" "")
3136 (match_operand:SI 2 "const_int_operand" "")
3137 (match_operand:SI 3 "const_int_operand" ""))
3138 (const_int 0)))
3139 (clobber (match_scratch:SI 4 ""))]
ce71f754 3140 "reload_completed"
9ebbca7d
GK
3141 [(set (match_dup 4)
3142 (zero_extract:SI (match_dup 1) (match_dup 2)
3143 (match_dup 3)))
3144 (set (match_dup 0)
3145 (compare:CC (match_dup 4)
3146 (const_int 0)))]
3147 "")
1fd4e8c1 3148
a78e33fc 3149(define_insn "*extzvsi_internal2"
9ebbca7d
GK
3150 [(set (match_operand:CC 4 "cc_reg_operand" "=x,?y")
3151 (compare:CC (zero_extract:SI (match_operand:SI 1 "gpc_reg_operand" "r,r")
3152 (match_operand:SI 2 "const_int_operand" "i,i")
3153 (match_operand:SI 3 "const_int_operand" "i,i"))
1fd4e8c1 3154 (const_int 0)))
9ebbca7d 3155 (set (match_operand:SI 0 "gpc_reg_operand" "=r,r")
1fd4e8c1 3156 (zero_extract:SI (match_dup 1) (match_dup 2) (match_dup 3)))]
ce71f754 3157 ""
1fd4e8c1
RK
3158 "*
3159{
3160 int start = INTVAL (operands[3]) & 31;
3161 int size = INTVAL (operands[2]) & 31;
3162
9ebbca7d
GK
3163 /* Force split for non-cc0 compare. */
3164 if (which_alternative == 1)
3165 return \"#\";
3166
bc401279 3167 /* Since we are using the output value, we can't ignore any need for
43a88a8c 3168 a shift. The bit-field must end at the LSB. */
bc401279 3169 if (start >= 16 && start + size == 32)
df031c43 3170 {
bc401279
AM
3171 operands[3] = GEN_INT ((1 << size) - 1);
3172 return \"{andil.|andi.} %0,%1,%3\";
df031c43 3173 }
7e69e155 3174
1fd4e8c1
RK
3175 if (start + size >= 32)
3176 operands[3] = const0_rtx;
3177 else
89e9f3a8 3178 operands[3] = GEN_INT (start + size);
ca7f5001 3179 return \"{rlinm.|rlwinm.} %0,%1,%3,%s2,31\";
1fd4e8c1 3180}"
ce71f754 3181 [(set_attr "type" "compare")
9ebbca7d
GK
3182 (set_attr "length" "4,8")])
3183
3184(define_split
3185 [(set (match_operand:CC 4 "cc_reg_not_cr0_operand" "")
3186 (compare:CC (zero_extract:SI (match_operand:SI 1 "gpc_reg_operand" "")
3187 (match_operand:SI 2 "const_int_operand" "")
3188 (match_operand:SI 3 "const_int_operand" ""))
3189 (const_int 0)))
3190 (set (match_operand:SI 0 "gpc_reg_operand" "")
3191 (zero_extract:SI (match_dup 1) (match_dup 2) (match_dup 3)))]
ce71f754 3192 "reload_completed"
9ebbca7d
GK
3193 [(set (match_dup 0)
3194 (zero_extract:SI (match_dup 1) (match_dup 2) (match_dup 3)))
3195 (set (match_dup 4)
3196 (compare:CC (match_dup 0)
3197 (const_int 0)))]
3198 "")
1fd4e8c1 3199
a78e33fc 3200(define_insn "extzvdi"
685f3906
DE
3201 [(set (match_operand:DI 0 "gpc_reg_operand" "=r")
3202 (zero_extract:DI (match_operand:DI 1 "gpc_reg_operand" "r")
a78e33fc
DE
3203 (match_operand:SI 2 "const_int_operand" "i")
3204 (match_operand:SI 3 "const_int_operand" "i")))]
685f3906
DE
3205 "TARGET_POWERPC64"
3206 "*
3207{
3208 int start = INTVAL (operands[3]) & 63;
3209 int size = INTVAL (operands[2]) & 63;
3210
3211 if (start + size >= 64)
3212 operands[3] = const0_rtx;
3213 else
89e9f3a8
MM
3214 operands[3] = GEN_INT (start + size);
3215 operands[2] = GEN_INT (64 - size);
685f3906
DE
3216 return \"rldicl %0,%1,%3,%2\";
3217}")
3218
a78e33fc 3219(define_insn "*extzvdi_internal1"
29ae5b89
JL
3220 [(set (match_operand:CC 0 "gpc_reg_operand" "=x")
3221 (compare:CC (zero_extract:DI (match_operand:DI 1 "gpc_reg_operand" "r")
a78e33fc
DE
3222 (match_operand:SI 2 "const_int_operand" "i")
3223 (match_operand:SI 3 "const_int_operand" "i"))
685f3906 3224 (const_int 0)))
29ae5b89 3225 (clobber (match_scratch:DI 4 "=r"))]
683bdff7 3226 "TARGET_64BIT"
685f3906
DE
3227 "*
3228{
3229 int start = INTVAL (operands[3]) & 63;
3230 int size = INTVAL (operands[2]) & 63;
3231
3232 if (start + size >= 64)
3233 operands[3] = const0_rtx;
3234 else
89e9f3a8
MM
3235 operands[3] = GEN_INT (start + size);
3236 operands[2] = GEN_INT (64 - size);
685f3906
DE
3237 return \"rldicl. %4,%1,%3,%2\";
3238}")
3239
a78e33fc 3240(define_insn "*extzvdi_internal2"
29ae5b89
JL
3241 [(set (match_operand:CC 4 "gpc_reg_operand" "=x")
3242 (compare:CC (zero_extract:DI (match_operand:DI 1 "gpc_reg_operand" "r")
a78e33fc
DE
3243 (match_operand:SI 2 "const_int_operand" "i")
3244 (match_operand:SI 3 "const_int_operand" "i"))
685f3906 3245 (const_int 0)))
29ae5b89 3246 (set (match_operand:DI 0 "gpc_reg_operand" "=r")
685f3906 3247 (zero_extract:DI (match_dup 1) (match_dup 2) (match_dup 3)))]
683bdff7 3248 "TARGET_64BIT"
685f3906
DE
3249 "*
3250{
3251 int start = INTVAL (operands[3]) & 63;
3252 int size = INTVAL (operands[2]) & 63;
3253
3254 if (start + size >= 64)
3255 operands[3] = const0_rtx;
3256 else
89e9f3a8
MM
3257 operands[3] = GEN_INT (start + size);
3258 operands[2] = GEN_INT (64 - size);
685f3906
DE
3259 return \"rldicl. %0,%1,%3,%2\";
3260}")
3261
1fd4e8c1 3262(define_insn "rotlsi3"
cd2b37d9
RK
3263 [(set (match_operand:SI 0 "gpc_reg_operand" "=r")
3264 (rotate:SI (match_operand:SI 1 "gpc_reg_operand" "r")
1fd4e8c1
RK
3265 (match_operand:SI 2 "reg_or_cint_operand" "ri")))]
3266 ""
ca7f5001 3267 "{rl%I2nm|rlw%I2nm} %0,%1,%h2,0xffffffff")
1fd4e8c1 3268
a260abc9 3269(define_insn "*rotlsi3_internal2"
9ebbca7d
GK
3270 [(set (match_operand:CC 0 "cc_reg_operand" "=x,?y")
3271 (compare:CC (rotate:SI (match_operand:SI 1 "gpc_reg_operand" "r,r")
3272 (match_operand:SI 2 "reg_or_cint_operand" "ri,ri"))
1fd4e8c1 3273 (const_int 0)))
9ebbca7d 3274 (clobber (match_scratch:SI 3 "=r,r"))]
ce71f754 3275 ""
9ebbca7d
GK
3276 "@
3277 {rl%I2nm.|rlw%I2nm.} %3,%1,%h2,0xffffffff
3278 #"
3279 [(set_attr "type" "delayed_compare")
3280 (set_attr "length" "4,8")])
3281
3282(define_split
3283 [(set (match_operand:CC 0 "cc_reg_not_cr0_operand" "")
3284 (compare:CC (rotate:SI (match_operand:SI 1 "gpc_reg_operand" "")
3285 (match_operand:SI 2 "reg_or_cint_operand" ""))
3286 (const_int 0)))
3287 (clobber (match_scratch:SI 3 ""))]
ce71f754 3288 "reload_completed"
9ebbca7d
GK
3289 [(set (match_dup 3)
3290 (rotate:SI (match_dup 1) (match_dup 2)))
3291 (set (match_dup 0)
3292 (compare:CC (match_dup 3)
3293 (const_int 0)))]
3294 "")
1fd4e8c1 3295
a260abc9 3296(define_insn "*rotlsi3_internal3"
9ebbca7d
GK
3297 [(set (match_operand:CC 3 "cc_reg_operand" "=x,?y")
3298 (compare:CC (rotate:SI (match_operand:SI 1 "gpc_reg_operand" "r,r")
3299 (match_operand:SI 2 "reg_or_cint_operand" "ri,ri"))
1fd4e8c1 3300 (const_int 0)))
9ebbca7d 3301 (set (match_operand:SI 0 "gpc_reg_operand" "=r,r")
1fd4e8c1 3302 (rotate:SI (match_dup 1) (match_dup 2)))]
ce71f754 3303 ""
9ebbca7d
GK
3304 "@
3305 {rl%I2nm.|rlw%I2nm.} %0,%1,%h2,0xffffffff
3306 #"
3307 [(set_attr "type" "delayed_compare")
3308 (set_attr "length" "4,8")])
3309
3310(define_split
3311 [(set (match_operand:CC 3 "cc_reg_not_cr0_operand" "")
3312 (compare:CC (rotate:SI (match_operand:SI 1 "gpc_reg_operand" "")
3313 (match_operand:SI 2 "reg_or_cint_operand" ""))
3314 (const_int 0)))
3315 (set (match_operand:SI 0 "gpc_reg_operand" "")
3316 (rotate:SI (match_dup 1) (match_dup 2)))]
ce71f754 3317 "reload_completed"
9ebbca7d
GK
3318 [(set (match_dup 0)
3319 (rotate:SI (match_dup 1) (match_dup 2)))
3320 (set (match_dup 3)
3321 (compare:CC (match_dup 0)
3322 (const_int 0)))]
3323 "")
1fd4e8c1 3324
a260abc9 3325(define_insn "*rotlsi3_internal4"
cd2b37d9
RK
3326 [(set (match_operand:SI 0 "gpc_reg_operand" "=r")
3327 (and:SI (rotate:SI (match_operand:SI 1 "gpc_reg_operand" "r")
1fd4e8c1 3328 (match_operand:SI 2 "reg_or_cint_operand" "ri"))
ce71f754 3329 (match_operand:SI 3 "mask_operand" "n")))]
1fd4e8c1 3330 ""
ca7f5001 3331 "{rl%I2nm|rlw%I2nm} %0,%1,%h2,%m3,%M3")
1fd4e8c1 3332
a260abc9 3333(define_insn "*rotlsi3_internal5"
9ebbca7d 3334 [(set (match_operand:CC 0 "cc_reg_operand" "=x,?y")
1fd4e8c1 3335 (compare:CC (and:SI
9ebbca7d
GK
3336 (rotate:SI (match_operand:SI 1 "gpc_reg_operand" "r,r")
3337 (match_operand:SI 2 "reg_or_cint_operand" "ri,ri"))
ce71f754 3338 (match_operand:SI 3 "mask_operand" "n,n"))
1fd4e8c1 3339 (const_int 0)))
9ebbca7d 3340 (clobber (match_scratch:SI 4 "=r,r"))]
ce71f754 3341 ""
9ebbca7d
GK
3342 "@
3343 {rl%I2nm.|rlw%I2nm.} %4,%1,%h2,%m3,%M3
3344 #"
3345 [(set_attr "type" "delayed_compare")
3346 (set_attr "length" "4,8")])
3347
3348(define_split
3349 [(set (match_operand:CC 0 "cc_reg_not_cr0_operand" "")
3350 (compare:CC (and:SI
3351 (rotate:SI (match_operand:SI 1 "gpc_reg_operand" "")
3352 (match_operand:SI 2 "reg_or_cint_operand" ""))
3353 (match_operand:SI 3 "mask_operand" ""))
3354 (const_int 0)))
3355 (clobber (match_scratch:SI 4 ""))]
ce71f754 3356 "reload_completed"
9ebbca7d
GK
3357 [(set (match_dup 4)
3358 (and:SI (rotate:SI (match_dup 1)
3359 (match_dup 2))
3360 (match_dup 3)))
3361 (set (match_dup 0)
3362 (compare:CC (match_dup 4)
3363 (const_int 0)))]
3364 "")
1fd4e8c1 3365
a260abc9 3366(define_insn "*rotlsi3_internal6"
9ebbca7d 3367 [(set (match_operand:CC 4 "cc_reg_operand" "=x,?y")
1fd4e8c1 3368 (compare:CC (and:SI
9ebbca7d
GK
3369 (rotate:SI (match_operand:SI 1 "gpc_reg_operand" "r,r")
3370 (match_operand:SI 2 "reg_or_cint_operand" "ri,ri"))
ce71f754 3371 (match_operand:SI 3 "mask_operand" "n,n"))
1fd4e8c1 3372 (const_int 0)))
9ebbca7d 3373 (set (match_operand:SI 0 "gpc_reg_operand" "=r,r")
1fd4e8c1 3374 (and:SI (rotate:SI (match_dup 1) (match_dup 2)) (match_dup 3)))]
ce71f754 3375 ""
9ebbca7d
GK
3376 "@
3377 {rl%I2nm.|rlw%I2nm.} %0,%1,%h2,%m3,%M3
3378 #"
3379 [(set_attr "type" "delayed_compare")
3380 (set_attr "length" "4,8")])
3381
3382(define_split
3383 [(set (match_operand:CC 4 "cc_reg_not_cr0_operand" "")
3384 (compare:CC (and:SI
3385 (rotate:SI (match_operand:SI 1 "gpc_reg_operand" "")
3386 (match_operand:SI 2 "reg_or_cint_operand" ""))
3387 (match_operand:SI 3 "mask_operand" ""))
3388 (const_int 0)))
3389 (set (match_operand:SI 0 "gpc_reg_operand" "")
3390 (and:SI (rotate:SI (match_dup 1) (match_dup 2)) (match_dup 3)))]
ce71f754 3391 "reload_completed"
9ebbca7d
GK
3392 [(set (match_dup 0)
3393 (and:SI (rotate:SI (match_dup 1) (match_dup 2)) (match_dup 3)))
3394 (set (match_dup 4)
3395 (compare:CC (match_dup 0)
3396 (const_int 0)))]
3397 "")
1fd4e8c1 3398
a260abc9 3399(define_insn "*rotlsi3_internal7"
cd2b37d9 3400 [(set (match_operand:SI 0 "gpc_reg_operand" "=r")
1fd4e8c1
RK
3401 (zero_extend:SI
3402 (subreg:QI
cd2b37d9 3403 (rotate:SI (match_operand:SI 1 "gpc_reg_operand" "r")
1fd4e8c1
RK
3404 (match_operand:SI 2 "reg_or_cint_operand" "ri")) 0)))]
3405 ""
ca7f5001 3406 "{rl%I2nm|rlw%I2nm} %0,%1,%h2,0xff")
1fd4e8c1 3407
a260abc9 3408(define_insn "*rotlsi3_internal8"
9ebbca7d 3409 [(set (match_operand:CC 0 "cc_reg_operand" "=x,?y")
1fd4e8c1
RK
3410 (compare:CC (zero_extend:SI
3411 (subreg:QI
9ebbca7d
GK
3412 (rotate:SI (match_operand:SI 1 "gpc_reg_operand" "r,r")
3413 (match_operand:SI 2 "reg_or_cint_operand" "ri,ri")) 0))
1fd4e8c1 3414 (const_int 0)))
9ebbca7d 3415 (clobber (match_scratch:SI 3 "=r,r"))]
1fd4e8c1 3416 ""
9ebbca7d
GK
3417 "@
3418 {rl%I2nm.|rlw%I2nm.} %3,%1,%h2,0xff
3419 #"
3420 [(set_attr "type" "delayed_compare")
3421 (set_attr "length" "4,8")])
3422
3423(define_split
3424 [(set (match_operand:CC 0 "cc_reg_not_cr0_operand" "")
3425 (compare:CC (zero_extend:SI
3426 (subreg:QI
3427 (rotate:SI (match_operand:SI 1 "gpc_reg_operand" "")
3428 (match_operand:SI 2 "reg_or_cint_operand" "")) 0))
3429 (const_int 0)))
3430 (clobber (match_scratch:SI 3 ""))]
3431 "reload_completed"
3432 [(set (match_dup 3)
3433 (zero_extend:SI (subreg:QI
3434 (rotate:SI (match_dup 1)
3435 (match_dup 2)) 0)))
3436 (set (match_dup 0)
3437 (compare:CC (match_dup 3)
3438 (const_int 0)))]
3439 "")
1fd4e8c1 3440
a260abc9 3441(define_insn "*rotlsi3_internal9"
9ebbca7d 3442 [(set (match_operand:CC 3 "cc_reg_operand" "=x,?y")
1fd4e8c1
RK
3443 (compare:CC (zero_extend:SI
3444 (subreg:QI
9ebbca7d
GK
3445 (rotate:SI (match_operand:SI 1 "gpc_reg_operand" "r,r")
3446 (match_operand:SI 2 "reg_or_cint_operand" "ri,ri")) 0))
1fd4e8c1 3447 (const_int 0)))
9ebbca7d 3448 (set (match_operand:SI 0 "gpc_reg_operand" "=r,r")
1fd4e8c1
RK
3449 (zero_extend:SI (subreg:QI (rotate:SI (match_dup 1) (match_dup 2)) 0)))]
3450 ""
9ebbca7d
GK
3451 "@
3452 {rl%I2nm.|rlw%I2nm.} %0,%1,%h2,0xff
3453 #"
3454 [(set_attr "type" "delayed_compare")
3455 (set_attr "length" "4,8")])
3456
3457(define_split
3458 [(set (match_operand:CC 3 "cc_reg_not_cr0_operand" "")
3459 (compare:CC (zero_extend:SI
3460 (subreg:QI
3461 (rotate:SI (match_operand:SI 1 "gpc_reg_operand" "")
3462 (match_operand:SI 2 "reg_or_cint_operand" "")) 0))
3463 (const_int 0)))
3464 (set (match_operand:SI 0 "gpc_reg_operand" "")
3465 (zero_extend:SI (subreg:QI (rotate:SI (match_dup 1) (match_dup 2)) 0)))]
3466 "reload_completed"
3467 [(set (match_dup 0)
3468 (zero_extend:SI (subreg:QI (rotate:SI (match_dup 1) (match_dup 2)) 0)))
3469 (set (match_dup 3)
3470 (compare:CC (match_dup 0)
3471 (const_int 0)))]
3472 "")
1fd4e8c1 3473
a260abc9 3474(define_insn "*rotlsi3_internal10"
cd2b37d9 3475 [(set (match_operand:SI 0 "gpc_reg_operand" "=r")
1fd4e8c1
RK
3476 (zero_extend:SI
3477 (subreg:HI
cd2b37d9 3478 (rotate:SI (match_operand:SI 1 "gpc_reg_operand" "r")
1fd4e8c1
RK
3479 (match_operand:SI 2 "reg_or_cint_operand" "ri")) 0)))]
3480 ""
ca7f5001 3481 "{rl%I2nm|rlw%I2nm} %0,%1,%h2,0xffff")
1fd4e8c1 3482
a260abc9 3483(define_insn "*rotlsi3_internal11"
9ebbca7d 3484 [(set (match_operand:CC 0 "cc_reg_operand" "=x,?y")
1fd4e8c1
RK
3485 (compare:CC (zero_extend:SI
3486 (subreg:HI
9ebbca7d
GK
3487 (rotate:SI (match_operand:SI 1 "gpc_reg_operand" "r,r")
3488 (match_operand:SI 2 "reg_or_cint_operand" "ri,ri")) 0))
1fd4e8c1 3489 (const_int 0)))
9ebbca7d 3490 (clobber (match_scratch:SI 3 "=r,r"))]
1fd4e8c1 3491 ""
9ebbca7d
GK
3492 "@
3493 {rl%I2nm.|rlw%I2nm.} %3,%1,%h2,0xffff
3494 #"
3495 [(set_attr "type" "delayed_compare")
3496 (set_attr "length" "4,8")])
3497
3498(define_split
3499 [(set (match_operand:CC 0 "cc_reg_not_cr0_operand" "")
3500 (compare:CC (zero_extend:SI
3501 (subreg:HI
3502 (rotate:SI (match_operand:SI 1 "gpc_reg_operand" "")
3503 (match_operand:SI 2 "reg_or_cint_operand" "")) 0))
3504 (const_int 0)))
3505 (clobber (match_scratch:SI 3 ""))]
3506 "reload_completed"
3507 [(set (match_dup 3)
3508 (zero_extend:SI (subreg:HI
3509 (rotate:SI (match_dup 1)
3510 (match_dup 2)) 0)))
3511 (set (match_dup 0)
3512 (compare:CC (match_dup 3)
3513 (const_int 0)))]
3514 "")
1fd4e8c1 3515
a260abc9 3516(define_insn "*rotlsi3_internal12"
9ebbca7d 3517 [(set (match_operand:CC 3 "cc_reg_operand" "=x,?y")
1fd4e8c1
RK
3518 (compare:CC (zero_extend:SI
3519 (subreg:HI
9ebbca7d
GK
3520 (rotate:SI (match_operand:SI 1 "gpc_reg_operand" "r,r")
3521 (match_operand:SI 2 "reg_or_cint_operand" "ri,ri")) 0))
1fd4e8c1 3522 (const_int 0)))
9ebbca7d 3523 (set (match_operand:SI 0 "gpc_reg_operand" "=r,r")
1fd4e8c1
RK
3524 (zero_extend:SI (subreg:HI (rotate:SI (match_dup 1) (match_dup 2)) 0)))]
3525 ""
9ebbca7d
GK
3526 "@
3527 {rl%I2nm.|rlw%I2nm.} %0,%1,%h2,0xffff
3528 #"
3529 [(set_attr "type" "delayed_compare")
3530 (set_attr "length" "4,8")])
3531
3532(define_split
3533 [(set (match_operand:CC 3 "cc_reg_not_cr0_operand" "")
3534 (compare:CC (zero_extend:SI
3535 (subreg:HI
3536 (rotate:SI (match_operand:SI 1 "gpc_reg_operand" "")
3537 (match_operand:SI 2 "reg_or_cint_operand" "")) 0))
3538 (const_int 0)))
3539 (set (match_operand:SI 0 "gpc_reg_operand" "")
3540 (zero_extend:SI (subreg:HI (rotate:SI (match_dup 1) (match_dup 2)) 0)))]
3541 "reload_completed"
3542 [(set (match_dup 0)
3543 (zero_extend:SI (subreg:HI (rotate:SI (match_dup 1) (match_dup 2)) 0)))
3544 (set (match_dup 3)
3545 (compare:CC (match_dup 0)
3546 (const_int 0)))]
3547 "")
1fd4e8c1
RK
3548
3549;; Note that we use "sle." instead of "sl." so that we can set
3550;; SHIFT_COUNT_TRUNCATED.
3551
ca7f5001
RK
3552(define_expand "ashlsi3"
3553 [(use (match_operand:SI 0 "gpc_reg_operand" ""))
3554 (use (match_operand:SI 1 "gpc_reg_operand" ""))
3555 (use (match_operand:SI 2 "reg_or_cint_operand" ""))]
3556 ""
3557 "
3558{
3559 if (TARGET_POWER)
3560 emit_insn (gen_ashlsi3_power (operands[0], operands[1], operands[2]));
3561 else
25c341fa 3562 emit_insn (gen_ashlsi3_no_power (operands[0], operands[1], operands[2]));
ca7f5001
RK
3563 DONE;
3564}")
3565
3566(define_insn "ashlsi3_power"
cd2b37d9
RK
3567 [(set (match_operand:SI 0 "gpc_reg_operand" "=r,r")
3568 (ashift:SI (match_operand:SI 1 "gpc_reg_operand" "r,r")
1fd4e8c1
RK
3569 (match_operand:SI 2 "reg_or_cint_operand" "r,i")))
3570 (clobber (match_scratch:SI 3 "=q,X"))]
ca7f5001 3571 "TARGET_POWER"
1fd4e8c1
RK
3572 "@
3573 sle %0,%1,%2
9ebbca7d 3574 {sli|slwi} %0,%1,%h2")
ca7f5001 3575
25c341fa 3576(define_insn "ashlsi3_no_power"
ca7f5001
RK
3577 [(set (match_operand:SI 0 "gpc_reg_operand" "=r")
3578 (ashift:SI (match_operand:SI 1 "gpc_reg_operand" "r")
3579 (match_operand:SI 2 "reg_or_cint_operand" "ri")))]
25c341fa 3580 "! TARGET_POWER"
9ebbca7d 3581 "{sl|slw}%I2 %0,%1,%h2")
1fd4e8c1
RK
3582
3583(define_insn ""
9ebbca7d
GK
3584 [(set (match_operand:CC 0 "cc_reg_operand" "=x,x,?y,?y")
3585 (compare:CC (ashift:SI (match_operand:SI 1 "gpc_reg_operand" "r,r,r,r")
3586 (match_operand:SI 2 "reg_or_cint_operand" "r,i,r,i"))
1fd4e8c1 3587 (const_int 0)))
9ebbca7d
GK
3588 (clobber (match_scratch:SI 3 "=r,r,r,r"))
3589 (clobber (match_scratch:SI 4 "=q,X,q,X"))]
ca7f5001 3590 "TARGET_POWER"
1fd4e8c1
RK
3591 "@
3592 sle. %3,%1,%2
9ebbca7d
GK
3593 {sli.|slwi.} %3,%1,%h2
3594 #
3595 #"
3596 [(set_attr "type" "delayed_compare")
3597 (set_attr "length" "4,4,8,8")])
3598
3599(define_split
3600 [(set (match_operand:CC 0 "cc_reg_not_cr0_operand" "")
3601 (compare:CC (ashift:SI (match_operand:SI 1 "gpc_reg_operand" "")
3602 (match_operand:SI 2 "reg_or_cint_operand" ""))
3603 (const_int 0)))
3604 (clobber (match_scratch:SI 3 ""))
3605 (clobber (match_scratch:SI 4 ""))]
3606 "TARGET_POWER && reload_completed"
3607 [(parallel [(set (match_dup 3)
3608 (ashift:SI (match_dup 1) (match_dup 2)))
3609 (clobber (match_dup 4))])
3610 (set (match_dup 0)
3611 (compare:CC (match_dup 3)
3612 (const_int 0)))]
3613 "")
25c341fa 3614
ca7f5001 3615(define_insn ""
9ebbca7d
GK
3616 [(set (match_operand:CC 0 "cc_reg_operand" "=x,?y")
3617 (compare:CC (ashift:SI (match_operand:SI 1 "gpc_reg_operand" "r,r")
3618 (match_operand:SI 2 "reg_or_cint_operand" "ri,ri"))
ca7f5001 3619 (const_int 0)))
9ebbca7d 3620 (clobber (match_scratch:SI 3 "=r,r"))]
0ad91047 3621 "! TARGET_POWER && ! TARGET_POWERPC64"
9ebbca7d
GK
3622 "@
3623 {sl|slw}%I2. %3,%1,%h2
3624 #"
3625 [(set_attr "type" "delayed_compare")
3626 (set_attr "length" "4,8")])
3627
3628(define_split
3629 [(set (match_operand:CC 0 "cc_reg_not_cr0_operand" "")
3630 (compare:CC (ashift:SI (match_operand:SI 1 "gpc_reg_operand" "")
3631 (match_operand:SI 2 "reg_or_cint_operand" ""))
3632 (const_int 0)))
3633 (clobber (match_scratch:SI 3 ""))]
3634 "! TARGET_POWER && ! TARGET_POWERPC64 && reload_completed"
3635 [(set (match_dup 3)
3636 (ashift:SI (match_dup 1) (match_dup 2)))
3637 (set (match_dup 0)
3638 (compare:CC (match_dup 3)
3639 (const_int 0)))]
3640 "")
1fd4e8c1
RK
3641
3642(define_insn ""
9ebbca7d
GK
3643 [(set (match_operand:CC 3 "cc_reg_operand" "=x,x,?y,?y")
3644 (compare:CC (ashift:SI (match_operand:SI 1 "gpc_reg_operand" "r,r,r,r")
3645 (match_operand:SI 2 "reg_or_cint_operand" "r,i,r,i"))
1fd4e8c1 3646 (const_int 0)))
9ebbca7d 3647 (set (match_operand:SI 0 "gpc_reg_operand" "=r,r,r,r")
1fd4e8c1 3648 (ashift:SI (match_dup 1) (match_dup 2)))
9ebbca7d 3649 (clobber (match_scratch:SI 4 "=q,X,q,X"))]
ca7f5001 3650 "TARGET_POWER"
1fd4e8c1
RK
3651 "@
3652 sle. %0,%1,%2
9ebbca7d
GK
3653 {sli.|slwi.} %0,%1,%h2
3654 #
3655 #"
3656 [(set_attr "type" "delayed_compare")
3657 (set_attr "length" "4,4,8,8")])
3658
3659(define_split
3660 [(set (match_operand:CC 3 "cc_reg_not_cr0_operand" "")
3661 (compare:CC (ashift:SI (match_operand:SI 1 "gpc_reg_operand" "")
3662 (match_operand:SI 2 "reg_or_cint_operand" ""))
3663 (const_int 0)))
3664 (set (match_operand:SI 0 "gpc_reg_operand" "")
3665 (ashift:SI (match_dup 1) (match_dup 2)))
3666 (clobber (match_scratch:SI 4 ""))]
3667 "TARGET_POWER && reload_completed"
3668 [(parallel [(set (match_dup 0)
3669 (ashift:SI (match_dup 1) (match_dup 2)))
3670 (clobber (match_dup 4))])
3671 (set (match_dup 3)
3672 (compare:CC (match_dup 0)
3673 (const_int 0)))]
3674 "")
25c341fa 3675
ca7f5001 3676(define_insn ""
9ebbca7d
GK
3677 [(set (match_operand:CC 3 "cc_reg_operand" "=x,?y")
3678 (compare:CC (ashift:SI (match_operand:SI 1 "gpc_reg_operand" "r,r")
3679 (match_operand:SI 2 "reg_or_cint_operand" "ri,ri"))
ca7f5001 3680 (const_int 0)))
9ebbca7d 3681 (set (match_operand:SI 0 "gpc_reg_operand" "=r,r")
ca7f5001 3682 (ashift:SI (match_dup 1) (match_dup 2)))]
0ad91047 3683 "! TARGET_POWER && ! TARGET_POWERPC64"
9ebbca7d
GK
3684 "@
3685 {sl|slw}%I2. %0,%1,%h2
3686 #"
3687 [(set_attr "type" "delayed_compare")
3688 (set_attr "length" "4,8")])
3689
3690(define_split
3691 [(set (match_operand:CC 3 "cc_reg_not_cr0_operand" "")
3692 (compare:CC (ashift:SI (match_operand:SI 1 "gpc_reg_operand" "")
3693 (match_operand:SI 2 "reg_or_cint_operand" ""))
3694 (const_int 0)))
3695 (set (match_operand:SI 0 "gpc_reg_operand" "")
3696 (ashift:SI (match_dup 1) (match_dup 2)))]
3697 "! TARGET_POWER && ! TARGET_POWERPC64 && reload_completed"
3698 [(set (match_dup 0)
3699 (ashift:SI (match_dup 1) (match_dup 2)))
3700 (set (match_dup 3)
3701 (compare:CC (match_dup 0)
3702 (const_int 0)))]
3703 "")
1fd4e8c1
RK
3704
3705(define_insn ""
cd2b37d9
RK
3706 [(set (match_operand:SI 0 "gpc_reg_operand" "=r")
3707 (and:SI (ashift:SI (match_operand:SI 1 "gpc_reg_operand" "r")
1fd4e8c1 3708 (match_operand:SI 2 "const_int_operand" "i"))
ce71f754 3709 (match_operand:SI 3 "mask_operand" "n")))]
1fd4e8c1 3710 "includes_lshift_p (operands[2], operands[3])"
d56d506a 3711 "{rlinm|rlwinm} %0,%1,%h2,%m3,%M3")
1fd4e8c1
RK
3712
3713(define_insn ""
9ebbca7d 3714 [(set (match_operand:CC 0 "cc_reg_operand" "=x,?y")
1fd4e8c1 3715 (compare:CC
9ebbca7d
GK
3716 (and:SI (ashift:SI (match_operand:SI 1 "gpc_reg_operand" "r,r")
3717 (match_operand:SI 2 "const_int_operand" "i,i"))
ce71f754 3718 (match_operand:SI 3 "mask_operand" "n,n"))
1fd4e8c1 3719 (const_int 0)))
9ebbca7d 3720 (clobber (match_scratch:SI 4 "=r,r"))]
ce71f754 3721 "includes_lshift_p (operands[2], operands[3])"
9ebbca7d
GK
3722 "@
3723 {rlinm.|rlwinm.} %4,%1,%h2,%m3,%M3
3724 #"
3725 [(set_attr "type" "delayed_compare")
3726 (set_attr "length" "4,8")])
3727
3728(define_split
3729 [(set (match_operand:CC 0 "cc_reg_not_cr0_operand" "")
3730 (compare:CC
3731 (and:SI (ashift:SI (match_operand:SI 1 "gpc_reg_operand" "")
3732 (match_operand:SI 2 "const_int_operand" ""))
3733 (match_operand:SI 3 "mask_operand" ""))
3734 (const_int 0)))
3735 (clobber (match_scratch:SI 4 ""))]
ce71f754 3736 "includes_lshift_p (operands[2], operands[3]) && reload_completed"
9ebbca7d
GK
3737 [(set (match_dup 4)
3738 (and:SI (ashift:SI (match_dup 1) (match_dup 2))
3739 (match_dup 3)))
3740 (set (match_dup 0)
3741 (compare:CC (match_dup 4)
3742 (const_int 0)))]
3743 "")
1fd4e8c1
RK
3744
3745(define_insn ""
9ebbca7d 3746 [(set (match_operand:CC 4 "cc_reg_operand" "=x,?y")
1fd4e8c1 3747 (compare:CC
9ebbca7d
GK
3748 (and:SI (ashift:SI (match_operand:SI 1 "gpc_reg_operand" "r,r")
3749 (match_operand:SI 2 "const_int_operand" "i,i"))
ce71f754 3750 (match_operand:SI 3 "mask_operand" "n,n"))
1fd4e8c1 3751 (const_int 0)))
9ebbca7d 3752 (set (match_operand:SI 0 "gpc_reg_operand" "=r,r")
1fd4e8c1 3753 (and:SI (ashift:SI (match_dup 1) (match_dup 2)) (match_dup 3)))]
ce71f754 3754 "includes_lshift_p (operands[2], operands[3])"
9ebbca7d
GK
3755 "@
3756 {rlinm.|rlwinm.} %0,%1,%h2,%m3,%M3
3757 #"
3758 [(set_attr "type" "delayed_compare")
3759 (set_attr "length" "4,8")])
3760
3761(define_split
3762 [(set (match_operand:CC 4 "cc_reg_not_cr0_operand" "")
3763 (compare:CC
3764 (and:SI (ashift:SI (match_operand:SI 1 "gpc_reg_operand" "")
3765 (match_operand:SI 2 "const_int_operand" ""))
3766 (match_operand:SI 3 "mask_operand" ""))
3767 (const_int 0)))
3768 (set (match_operand:SI 0 "gpc_reg_operand" "")
3769 (and:SI (ashift:SI (match_dup 1) (match_dup 2)) (match_dup 3)))]
ce71f754 3770 "includes_lshift_p (operands[2], operands[3]) && reload_completed"
9ebbca7d
GK
3771 [(set (match_dup 0)
3772 (and:SI (ashift:SI (match_dup 1) (match_dup 2)) (match_dup 3)))
3773 (set (match_dup 4)
3774 (compare:CC (match_dup 0)
3775 (const_int 0)))]
3776 "")
1fd4e8c1 3777
ca7f5001 3778;; The AIX assembler mis-handles "sri x,x,0", so write that case as
5c23c401 3779;; "sli x,x,0".
ca7f5001
RK
3780(define_expand "lshrsi3"
3781 [(use (match_operand:SI 0 "gpc_reg_operand" ""))
3782 (use (match_operand:SI 1 "gpc_reg_operand" ""))
3783 (use (match_operand:SI 2 "reg_or_cint_operand" ""))]
3784 ""
3785 "
3786{
3787 if (TARGET_POWER)
3788 emit_insn (gen_lshrsi3_power (operands[0], operands[1], operands[2]));
3789 else
25c341fa 3790 emit_insn (gen_lshrsi3_no_power (operands[0], operands[1], operands[2]));
ca7f5001
RK
3791 DONE;
3792}")
3793
3794(define_insn "lshrsi3_power"
bdf423cb
MM
3795 [(set (match_operand:SI 0 "gpc_reg_operand" "=r,r,r")
3796 (lshiftrt:SI (match_operand:SI 1 "gpc_reg_operand" "r,r,r")
3797 (match_operand:SI 2 "reg_or_cint_operand" "r,O,i")))
3798 (clobber (match_scratch:SI 3 "=q,X,X"))]
ca7f5001 3799 "TARGET_POWER"
1fd4e8c1
RK
3800 "@
3801 sre %0,%1,%2
bdf423cb 3802 mr %0,%1
ca7f5001
RK
3803 {s%A2i|s%A2wi} %0,%1,%h2")
3804
25c341fa 3805(define_insn "lshrsi3_no_power"
bdf423cb
MM
3806 [(set (match_operand:SI 0 "gpc_reg_operand" "=r,r")
3807 (lshiftrt:SI (match_operand:SI 1 "gpc_reg_operand" "r,r")
3808 (match_operand:SI 2 "reg_or_cint_operand" "O,ri")))]
25c341fa 3809 "! TARGET_POWER"
bdf423cb
MM
3810 "@
3811 mr %0,%1
3812 {sr|srw}%I2 %0,%1,%h2")
1fd4e8c1
RK
3813
3814(define_insn ""
9ebbca7d
GK
3815 [(set (match_operand:CC 0 "cc_reg_operand" "=x,x,x,?y,?y,?y")
3816 (compare:CC (lshiftrt:SI (match_operand:SI 1 "gpc_reg_operand" "r,r,r,r,r,r")
3817 (match_operand:SI 2 "reg_or_cint_operand" "r,O,i,r,O,i"))
1fd4e8c1 3818 (const_int 0)))
9ebbca7d
GK
3819 (clobber (match_scratch:SI 3 "=r,X,r,r,X,r"))
3820 (clobber (match_scratch:SI 4 "=q,X,X,q,X,X"))]
ca7f5001 3821 "TARGET_POWER"
1fd4e8c1 3822 "@
29ae5b89
JL
3823 sre. %3,%1,%2
3824 mr. %1,%1
9ebbca7d
GK
3825 {s%A2i.|s%A2wi.} %3,%1,%h2
3826 #
3827 #
3828 #"
3829 [(set_attr "type" "delayed_compare")
3830 (set_attr "length" "4,4,4,8,8,8")])
3831
3832(define_split
3833 [(set (match_operand:CC 0 "cc_reg_not_cr0_operand" "")
3834 (compare:CC (lshiftrt:SI (match_operand:SI 1 "gpc_reg_operand" "")
3835 (match_operand:SI 2 "reg_or_cint_operand" ""))
3836 (const_int 0)))
3837 (clobber (match_scratch:SI 3 ""))
3838 (clobber (match_scratch:SI 4 ""))]
3839 "TARGET_POWER && reload_completed"
3840 [(parallel [(set (match_dup 3)
3841 (lshiftrt:SI (match_dup 1) (match_dup 2)))
3842 (clobber (match_dup 4))])
3843 (set (match_dup 0)
3844 (compare:CC (match_dup 3)
3845 (const_int 0)))]
3846 "")
ca7f5001
RK
3847
3848(define_insn ""
9ebbca7d
GK
3849 [(set (match_operand:CC 0 "cc_reg_operand" "=x,x,?y,?y")
3850 (compare:CC (lshiftrt:SI (match_operand:SI 1 "gpc_reg_operand" "r,r,r,r")
3851 (match_operand:SI 2 "reg_or_cint_operand" "O,ri,O,ri"))
ca7f5001 3852 (const_int 0)))
9ebbca7d 3853 (clobber (match_scratch:SI 3 "=X,r,X,r"))]
0ad91047 3854 "! TARGET_POWER && ! TARGET_POWERPC64"
bdf423cb
MM
3855 "@
3856 mr. %1,%1
9ebbca7d
GK
3857 {sr|srw}%I2. %3,%1,%h2
3858 #
3859 #"
3860 [(set_attr "type" "delayed_compare")
3861 (set_attr "length" "4,4,8,8")])
1fd4e8c1 3862
9ebbca7d
GK
3863(define_split
3864 [(set (match_operand:CC 0 "cc_reg_not_cr0_operand" "")
3865 (compare:CC (lshiftrt:SI (match_operand:SI 1 "gpc_reg_operand" "")
3866 (match_operand:SI 2 "reg_or_cint_operand" ""))
3867 (const_int 0)))
3868 (clobber (match_scratch:SI 3 ""))]
3869 "! TARGET_POWER && ! TARGET_POWERPC64 && reload_completed"
3870 [(set (match_dup 3)
3871 (lshiftrt:SI (match_dup 1) (match_dup 2)))
3872 (set (match_dup 0)
3873 (compare:CC (match_dup 3)
3874 (const_int 0)))]
3875 "")
3876
3877(define_insn ""
3878 [(set (match_operand:CC 3 "cc_reg_operand" "=x,x,x,?y,?y,?y")
3879 (compare:CC (lshiftrt:SI (match_operand:SI 1 "gpc_reg_operand" "r,r,r,r,r,r")
3880 (match_operand:SI 2 "reg_or_cint_operand" "r,O,i,r,O,i"))
1fd4e8c1 3881 (const_int 0)))
9ebbca7d 3882 (set (match_operand:SI 0 "gpc_reg_operand" "=r,r,r,r,r,r")
1fd4e8c1 3883 (lshiftrt:SI (match_dup 1) (match_dup 2)))
9ebbca7d 3884 (clobber (match_scratch:SI 4 "=q,X,X,q,X,X"))]
ca7f5001 3885 "TARGET_POWER"
1fd4e8c1 3886 "@
29ae5b89
JL
3887 sre. %0,%1,%2
3888 mr. %0,%1
9ebbca7d
GK
3889 {s%A2i.|s%A2wi.} %0,%1,%h2
3890 #
3891 #
3892 #"
3893 [(set_attr "type" "delayed_compare")
3894 (set_attr "length" "4,4,4,8,8,8")])
3895
3896(define_split
3897 [(set (match_operand:CC 3 "cc_reg_not_cr0_operand" "")
3898 (compare:CC (lshiftrt:SI (match_operand:SI 1 "gpc_reg_operand" "")
3899 (match_operand:SI 2 "reg_or_cint_operand" ""))
3900 (const_int 0)))
3901 (set (match_operand:SI 0 "gpc_reg_operand" "")
3902 (lshiftrt:SI (match_dup 1) (match_dup 2)))
3903 (clobber (match_scratch:SI 4 ""))]
3904 "TARGET_POWER && reload_completed"
3905 [(parallel [(set (match_dup 0)
3906 (lshiftrt:SI (match_dup 1) (match_dup 2)))
3907 (clobber (match_dup 4))])
3908 (set (match_dup 3)
3909 (compare:CC (match_dup 0)
3910 (const_int 0)))]
3911 "")
ca7f5001
RK
3912
3913(define_insn ""
9ebbca7d
GK
3914 [(set (match_operand:CC 3 "cc_reg_operand" "=x,x,?y,?y")
3915 (compare:CC (lshiftrt:SI (match_operand:SI 1 "gpc_reg_operand" "r,r,r,r")
3916 (match_operand:SI 2 "reg_or_cint_operand" "O,ri,O,ri"))
815cdc52 3917 (const_int 0)))
9ebbca7d 3918 (set (match_operand:SI 0 "gpc_reg_operand" "=r,r,r,r")
29ae5b89 3919 (lshiftrt:SI (match_dup 1) (match_dup 2)))]
0ad91047 3920 "! TARGET_POWER && ! TARGET_POWERPC64"
29ae5b89
JL
3921 "@
3922 mr. %0,%1
9ebbca7d
GK
3923 {sr|srw}%I2. %0,%1,%h2
3924 #
3925 #"
3926 [(set_attr "type" "delayed_compare")
3927 (set_attr "length" "4,4,8,8")])
3928
3929(define_split
3930 [(set (match_operand:CC 3 "cc_reg_not_cr0_operand" "")
3931 (compare:CC (lshiftrt:SI (match_operand:SI 1 "gpc_reg_operand" "")
3932 (match_operand:SI 2 "reg_or_cint_operand" ""))
3933 (const_int 0)))
3934 (set (match_operand:SI 0 "gpc_reg_operand" "")
3935 (lshiftrt:SI (match_dup 1) (match_dup 2)))]
3936 "! TARGET_POWER && ! TARGET_POWERPC64 && reload_completed"
3937 [(set (match_dup 0)
3938 (lshiftrt:SI (match_dup 1) (match_dup 2)))
3939 (set (match_dup 3)
3940 (compare:CC (match_dup 0)
3941 (const_int 0)))]
3942 "")
1fd4e8c1
RK
3943
3944(define_insn ""
cd2b37d9
RK
3945 [(set (match_operand:SI 0 "gpc_reg_operand" "=r")
3946 (and:SI (lshiftrt:SI (match_operand:SI 1 "gpc_reg_operand" "r")
1fd4e8c1 3947 (match_operand:SI 2 "const_int_operand" "i"))
ce71f754 3948 (match_operand:SI 3 "mask_operand" "n")))]
1fd4e8c1 3949 "includes_rshift_p (operands[2], operands[3])"
ca7f5001 3950 "{rlinm|rlwinm} %0,%1,%s2,%m3,%M3")
1fd4e8c1
RK
3951
3952(define_insn ""
9ebbca7d 3953 [(set (match_operand:CC 0 "cc_reg_operand" "=x,?y")
1fd4e8c1 3954 (compare:CC
9ebbca7d
GK
3955 (and:SI (lshiftrt:SI (match_operand:SI 1 "gpc_reg_operand" "r,r")
3956 (match_operand:SI 2 "const_int_operand" "i,i"))
ce71f754 3957 (match_operand:SI 3 "mask_operand" "n,n"))
1fd4e8c1 3958 (const_int 0)))
9ebbca7d 3959 (clobber (match_scratch:SI 4 "=r,r"))]
ce71f754 3960 "includes_rshift_p (operands[2], operands[3])"
9ebbca7d
GK
3961 "@
3962 {rlinm.|rlwinm.} %4,%1,%s2,%m3,%M3
3963 #"
3964 [(set_attr "type" "delayed_compare")
3965 (set_attr "length" "4,8")])
3966
3967(define_split
3968 [(set (match_operand:CC 0 "cc_reg_not_cr0_operand" "")
3969 (compare:CC
3970 (and:SI (lshiftrt:SI (match_operand:SI 1 "gpc_reg_operand" "")
3971 (match_operand:SI 2 "const_int_operand" ""))
3972 (match_operand:SI 3 "mask_operand" ""))
3973 (const_int 0)))
3974 (clobber (match_scratch:SI 4 ""))]
ce71f754 3975 "includes_rshift_p (operands[2], operands[3]) && reload_completed"
9ebbca7d
GK
3976 [(set (match_dup 4)
3977 (and:SI (lshiftrt:SI (match_dup 1) (match_dup 2))
3978 (match_dup 3)))
3979 (set (match_dup 0)
3980 (compare:CC (match_dup 4)
3981 (const_int 0)))]
3982 "")
1fd4e8c1
RK
3983
3984(define_insn ""
9ebbca7d 3985 [(set (match_operand:CC 4 "cc_reg_operand" "=x,?y")
1fd4e8c1 3986 (compare:CC
9ebbca7d
GK
3987 (and:SI (lshiftrt:SI (match_operand:SI 1 "gpc_reg_operand" "r,r")
3988 (match_operand:SI 2 "const_int_operand" "i,i"))
ce71f754 3989 (match_operand:SI 3 "mask_operand" "n,n"))
1fd4e8c1 3990 (const_int 0)))
9ebbca7d 3991 (set (match_operand:SI 0 "gpc_reg_operand" "=r,r")
1fd4e8c1 3992 (and:SI (lshiftrt:SI (match_dup 1) (match_dup 2)) (match_dup 3)))]
ce71f754 3993 "includes_rshift_p (operands[2], operands[3])"
9ebbca7d
GK
3994 "@
3995 {rlinm.|rlwinm.} %0,%1,%s2,%m3,%M3
3996 #"
3997 [(set_attr "type" "delayed_compare")
3998 (set_attr "length" "4,8")])
3999
4000(define_split
4001 [(set (match_operand:CC 4 "cc_reg_not_cr0_operand" "")
4002 (compare:CC
4003 (and:SI (lshiftrt:SI (match_operand:SI 1 "gpc_reg_operand" "")
4004 (match_operand:SI 2 "const_int_operand" ""))
4005 (match_operand:SI 3 "mask_operand" ""))
4006 (const_int 0)))
4007 (set (match_operand:SI 0 "gpc_reg_operand" "")
4008 (and:SI (lshiftrt:SI (match_dup 1) (match_dup 2)) (match_dup 3)))]
ce71f754 4009 "includes_rshift_p (operands[2], operands[3]) && reload_completed"
9ebbca7d
GK
4010 [(set (match_dup 0)
4011 (and:SI (lshiftrt:SI (match_dup 1) (match_dup 2)) (match_dup 3)))
4012 (set (match_dup 4)
4013 (compare:CC (match_dup 0)
4014 (const_int 0)))]
4015 "")
1fd4e8c1
RK
4016
4017(define_insn ""
cd2b37d9 4018 [(set (match_operand:SI 0 "gpc_reg_operand" "=r")
1fd4e8c1
RK
4019 (zero_extend:SI
4020 (subreg:QI
cd2b37d9 4021 (lshiftrt:SI (match_operand:SI 1 "gpc_reg_operand" "r")
1fd4e8c1 4022 (match_operand:SI 2 "const_int_operand" "i")) 0)))]
89e9f3a8 4023 "includes_rshift_p (operands[2], GEN_INT (255))"
ca7f5001 4024 "{rlinm|rlwinm} %0,%1,%s2,0xff")
1fd4e8c1
RK
4025
4026(define_insn ""
9ebbca7d 4027 [(set (match_operand:CC 0 "cc_reg_operand" "=x,?y")
1fd4e8c1
RK
4028 (compare:CC
4029 (zero_extend:SI
4030 (subreg:QI
9ebbca7d
GK
4031 (lshiftrt:SI (match_operand:SI 1 "gpc_reg_operand" "r,r")
4032 (match_operand:SI 2 "const_int_operand" "i,i")) 0))
1fd4e8c1 4033 (const_int 0)))
9ebbca7d 4034 (clobber (match_scratch:SI 3 "=r,r"))]
89e9f3a8 4035 "includes_rshift_p (operands[2], GEN_INT (255))"
9ebbca7d
GK
4036 "@
4037 {rlinm.|rlwinm.} %3,%1,%s2,0xff
4038 #"
4039 [(set_attr "type" "delayed_compare")
4040 (set_attr "length" "4,8")])
4041
4042(define_split
4043 [(set (match_operand:CC 0 "cc_reg_not_cr0_operand" "")
4044 (compare:CC
4045 (zero_extend:SI
4046 (subreg:QI
4047 (lshiftrt:SI (match_operand:SI 1 "gpc_reg_operand" "")
4048 (match_operand:SI 2 "const_int_operand" "")) 0))
4049 (const_int 0)))
4050 (clobber (match_scratch:SI 3 ""))]
4051 "includes_rshift_p (operands[2], GEN_INT (255)) && reload_completed"
4052 [(set (match_dup 3)
4053 (zero_extend:SI (subreg:QI
4054 (lshiftrt:SI (match_dup 1)
4055 (match_dup 2)) 0)))
4056 (set (match_dup 0)
4057 (compare:CC (match_dup 3)
4058 (const_int 0)))]
4059 "")
1fd4e8c1
RK
4060
4061(define_insn ""
9ebbca7d 4062 [(set (match_operand:CC 3 "cc_reg_operand" "=x,?y")
1fd4e8c1
RK
4063 (compare:CC
4064 (zero_extend:SI
4065 (subreg:QI
9ebbca7d
GK
4066 (lshiftrt:SI (match_operand:SI 1 "gpc_reg_operand" "r,r")
4067 (match_operand:SI 2 "const_int_operand" "i,i")) 0))
1fd4e8c1 4068 (const_int 0)))
9ebbca7d 4069 (set (match_operand:SI 0 "gpc_reg_operand" "=r,r")
1fd4e8c1 4070 (zero_extend:SI (subreg:QI (lshiftrt:SI (match_dup 1) (match_dup 2)) 0)))]
89e9f3a8 4071 "includes_rshift_p (operands[2], GEN_INT (255))"
9ebbca7d
GK
4072 "@
4073 {rlinm.|rlwinm.} %0,%1,%s2,0xff
4074 #"
4075 [(set_attr "type" "delayed_compare")
4076 (set_attr "length" "4,8")])
4077
4078(define_split
4079 [(set (match_operand:CC 3 "cc_reg_not_cr0_operand" "")
4080 (compare:CC
4081 (zero_extend:SI
4082 (subreg:QI
4083 (lshiftrt:SI (match_operand:SI 1 "gpc_reg_operand" "")
4084 (match_operand:SI 2 "const_int_operand" "")) 0))
4085 (const_int 0)))
4086 (set (match_operand:SI 0 "gpc_reg_operand" "")
4087 (zero_extend:SI (subreg:QI (lshiftrt:SI (match_dup 1) (match_dup 2)) 0)))]
4088 "includes_rshift_p (operands[2], GEN_INT (255)) && reload_completed"
4089 [(set (match_dup 0)
4090 (zero_extend:SI (subreg:QI (lshiftrt:SI (match_dup 1) (match_dup 2)) 0)))
4091 (set (match_dup 3)
4092 (compare:CC (match_dup 0)
4093 (const_int 0)))]
4094 "")
1fd4e8c1
RK
4095
4096(define_insn ""
cd2b37d9 4097 [(set (match_operand:SI 0 "gpc_reg_operand" "=r")
1fd4e8c1
RK
4098 (zero_extend:SI
4099 (subreg:HI
cd2b37d9 4100 (lshiftrt:SI (match_operand:SI 1 "gpc_reg_operand" "r")
1fd4e8c1 4101 (match_operand:SI 2 "const_int_operand" "i")) 0)))]
89e9f3a8 4102 "includes_rshift_p (operands[2], GEN_INT (65535))"
ca7f5001 4103 "{rlinm|rlwinm} %0,%1,%s2,0xffff")
1fd4e8c1
RK
4104
4105(define_insn ""
9ebbca7d 4106 [(set (match_operand:CC 0 "cc_reg_operand" "=x,?y")
1fd4e8c1
RK
4107 (compare:CC
4108 (zero_extend:SI
4109 (subreg:HI
9ebbca7d
GK
4110 (lshiftrt:SI (match_operand:SI 1 "gpc_reg_operand" "r,r")
4111 (match_operand:SI 2 "const_int_operand" "i,i")) 0))
1fd4e8c1 4112 (const_int 0)))
9ebbca7d 4113 (clobber (match_scratch:SI 3 "=r,r"))]
89e9f3a8 4114 "includes_rshift_p (operands[2], GEN_INT (65535))"
9ebbca7d
GK
4115 "@
4116 {rlinm.|rlwinm.} %3,%1,%s2,0xffff
4117 #"
4118 [(set_attr "type" "delayed_compare")
4119 (set_attr "length" "4,8")])
4120
4121(define_split
4122 [(set (match_operand:CC 0 "cc_reg_not_cr0_operand" "")
4123 (compare:CC
4124 (zero_extend:SI
4125 (subreg:HI
4126 (lshiftrt:SI (match_operand:SI 1 "gpc_reg_operand" "")
4127 (match_operand:SI 2 "const_int_operand" "")) 0))
4128 (const_int 0)))
4129 (clobber (match_scratch:SI 3 ""))]
4130 "includes_rshift_p (operands[2], GEN_INT (65535)) && reload_completed"
4131 [(set (match_dup 3)
4132 (zero_extend:SI (subreg:HI
4133 (lshiftrt:SI (match_dup 1)
4134 (match_dup 2)) 0)))
4135 (set (match_dup 0)
4136 (compare:CC (match_dup 3)
4137 (const_int 0)))]
4138 "")
1fd4e8c1
RK
4139
4140(define_insn ""
9ebbca7d 4141 [(set (match_operand:CC 3 "cc_reg_operand" "=x,?y")
1fd4e8c1
RK
4142 (compare:CC
4143 (zero_extend:SI
4144 (subreg:HI
9ebbca7d
GK
4145 (lshiftrt:SI (match_operand:SI 1 "gpc_reg_operand" "r,r")
4146 (match_operand:SI 2 "const_int_operand" "i,i")) 0))
1fd4e8c1 4147 (const_int 0)))
9ebbca7d 4148 (set (match_operand:SI 0 "gpc_reg_operand" "=r,r")
1fd4e8c1 4149 (zero_extend:SI (subreg:HI (lshiftrt:SI (match_dup 1) (match_dup 2)) 0)))]
89e9f3a8 4150 "includes_rshift_p (operands[2], GEN_INT (65535))"
9ebbca7d
GK
4151 "@
4152 {rlinm.|rlwinm.} %0,%1,%s2,0xffff
4153 #"
4154 [(set_attr "type" "delayed_compare")
4155 (set_attr "length" "4,8")])
4156
4157(define_split
4158 [(set (match_operand:CC 3 "cc_reg_not_cr0_operand" "")
4159 (compare:CC
4160 (zero_extend:SI
4161 (subreg:HI
4162 (lshiftrt:SI (match_operand:SI 1 "gpc_reg_operand" "")
4163 (match_operand:SI 2 "const_int_operand" "")) 0))
4164 (const_int 0)))
4165 (set (match_operand:SI 0 "gpc_reg_operand" "")
4166 (zero_extend:SI (subreg:HI (lshiftrt:SI (match_dup 1) (match_dup 2)) 0)))]
4167 "includes_rshift_p (operands[2], GEN_INT (65535)) && reload_completed"
4168 [(set (match_dup 0)
4169 (zero_extend:SI (subreg:HI (lshiftrt:SI (match_dup 1) (match_dup 2)) 0)))
4170 (set (match_dup 3)
4171 (compare:CC (match_dup 0)
4172 (const_int 0)))]
4173 "")
1fd4e8c1
RK
4174
4175(define_insn ""
cd2b37d9 4176 [(set (zero_extract:SI (match_operand:SI 0 "gpc_reg_operand" "+r")
1fd4e8c1 4177 (const_int 1)
cd2b37d9
RK
4178 (match_operand:SI 1 "gpc_reg_operand" "r"))
4179 (ashiftrt:SI (match_operand:SI 2 "gpc_reg_operand" "r")
1fd4e8c1 4180 (const_int 31)))]
ca7f5001 4181 "TARGET_POWER"
1fd4e8c1
RK
4182 "rrib %0,%1,%2")
4183
4184(define_insn ""
cd2b37d9 4185 [(set (zero_extract:SI (match_operand:SI 0 "gpc_reg_operand" "+r")
1fd4e8c1 4186 (const_int 1)
cd2b37d9
RK
4187 (match_operand:SI 1 "gpc_reg_operand" "r"))
4188 (lshiftrt:SI (match_operand:SI 2 "gpc_reg_operand" "r")
1fd4e8c1 4189 (const_int 31)))]
ca7f5001 4190 "TARGET_POWER"
1fd4e8c1
RK
4191 "rrib %0,%1,%2")
4192
4193(define_insn ""
cd2b37d9 4194 [(set (zero_extract:SI (match_operand:SI 0 "gpc_reg_operand" "+r")
1fd4e8c1 4195 (const_int 1)
cd2b37d9
RK
4196 (match_operand:SI 1 "gpc_reg_operand" "r"))
4197 (zero_extract:SI (match_operand:SI 2 "gpc_reg_operand" "r")
1fd4e8c1
RK
4198 (const_int 1)
4199 (const_int 0)))]
ca7f5001 4200 "TARGET_POWER"
1fd4e8c1
RK
4201 "rrib %0,%1,%2")
4202
ca7f5001
RK
4203(define_expand "ashrsi3"
4204 [(set (match_operand:SI 0 "gpc_reg_operand" "")
4205 (ashiftrt:SI (match_operand:SI 1 "gpc_reg_operand" "")
4206 (match_operand:SI 2 "reg_or_cint_operand" "")))]
4207 ""
4208 "
4209{
4210 if (TARGET_POWER)
4211 emit_insn (gen_ashrsi3_power (operands[0], operands[1], operands[2]));
4212 else
25c341fa 4213 emit_insn (gen_ashrsi3_no_power (operands[0], operands[1], operands[2]));
ca7f5001
RK
4214 DONE;
4215}")
4216
4217(define_insn "ashrsi3_power"
cd2b37d9
RK
4218 [(set (match_operand:SI 0 "gpc_reg_operand" "=r,r")
4219 (ashiftrt:SI (match_operand:SI 1 "gpc_reg_operand" "r,r")
1fd4e8c1
RK
4220 (match_operand:SI 2 "reg_or_cint_operand" "r,i")))
4221 (clobber (match_scratch:SI 3 "=q,X"))]
ca7f5001 4222 "TARGET_POWER"
1fd4e8c1
RK
4223 "@
4224 srea %0,%1,%2
ca7f5001
RK
4225 {srai|srawi} %0,%1,%h2")
4226
25c341fa 4227(define_insn "ashrsi3_no_power"
ca7f5001
RK
4228 [(set (match_operand:SI 0 "gpc_reg_operand" "=r")
4229 (ashiftrt:SI (match_operand:SI 1 "gpc_reg_operand" "r")
4230 (match_operand:SI 2 "reg_or_cint_operand" "ri")))]
25c341fa 4231 "! TARGET_POWER"
d904e9ed 4232 "{sra|sraw}%I2 %0,%1,%h2")
1fd4e8c1
RK
4233
4234(define_insn ""
9ebbca7d
GK
4235 [(set (match_operand:CC 0 "cc_reg_operand" "=x,x,?y,?y")
4236 (compare:CC (ashiftrt:SI (match_operand:SI 1 "gpc_reg_operand" "r,r,r,r")
4237 (match_operand:SI 2 "reg_or_cint_operand" "r,i,r,i"))
1fd4e8c1 4238 (const_int 0)))
9ebbca7d
GK
4239 (clobber (match_scratch:SI 3 "=r,r,r,r"))
4240 (clobber (match_scratch:SI 4 "=q,X,q,X"))]
ca7f5001 4241 "TARGET_POWER"
1fd4e8c1
RK
4242 "@
4243 srea. %3,%1,%2
9ebbca7d
GK
4244 {srai.|srawi.} %3,%1,%h2
4245 #
4246 #"
4247 [(set_attr "type" "delayed_compare")
4248 (set_attr "length" "4,4,8,8")])
4249
4250(define_split
4251 [(set (match_operand:CC 0 "cc_reg_not_cr0_operand" "")
4252 (compare:CC (ashiftrt:SI (match_operand:SI 1 "gpc_reg_operand" "")
4253 (match_operand:SI 2 "reg_or_cint_operand" ""))
4254 (const_int 0)))
4255 (clobber (match_scratch:SI 3 ""))
4256 (clobber (match_scratch:SI 4 ""))]
4257 "TARGET_POWER && reload_completed"
4258 [(parallel [(set (match_dup 3)
4259 (ashiftrt:SI (match_dup 1) (match_dup 2)))
4260 (clobber (match_dup 4))])
4261 (set (match_dup 0)
4262 (compare:CC (match_dup 3)
4263 (const_int 0)))]
4264 "")
ca7f5001
RK
4265
4266(define_insn ""
9ebbca7d
GK
4267 [(set (match_operand:CC 0 "cc_reg_operand" "=x,?y")
4268 (compare:CC (ashiftrt:SI (match_operand:SI 1 "gpc_reg_operand" "r,r")
4269 (match_operand:SI 2 "reg_or_cint_operand" "ri,ri"))
ca7f5001 4270 (const_int 0)))
9ebbca7d 4271 (clobber (match_scratch:SI 3 "=r,r"))]
25c341fa 4272 "! TARGET_POWER"
9ebbca7d
GK
4273 "@
4274 {sra|sraw}%I2. %3,%1,%h2
4275 #"
4276 [(set_attr "type" "delayed_compare")
4277 (set_attr "length" "4,8")])
4278
4279(define_split
4280 [(set (match_operand:CC 0 "cc_reg_not_cr0_operand" "")
4281 (compare:CC (ashiftrt:SI (match_operand:SI 1 "gpc_reg_operand" "")
4282 (match_operand:SI 2 "reg_or_cint_operand" ""))
4283 (const_int 0)))
4284 (clobber (match_scratch:SI 3 ""))]
4285 "! TARGET_POWER && reload_completed"
4286 [(set (match_dup 3)
4287 (ashiftrt:SI (match_dup 1) (match_dup 2)))
4288 (set (match_dup 0)
4289 (compare:CC (match_dup 3)
4290 (const_int 0)))]
4291 "")
1fd4e8c1
RK
4292
4293(define_insn ""
9ebbca7d
GK
4294 [(set (match_operand:CC 3 "cc_reg_operand" "=x,x,?y,?y")
4295 (compare:CC (ashiftrt:SI (match_operand:SI 1 "gpc_reg_operand" "r,r,r,r")
4296 (match_operand:SI 2 "reg_or_cint_operand" "r,i,r,i"))
1fd4e8c1 4297 (const_int 0)))
9ebbca7d 4298 (set (match_operand:SI 0 "gpc_reg_operand" "=r,r,r,r")
1fd4e8c1 4299 (ashiftrt:SI (match_dup 1) (match_dup 2)))
9ebbca7d 4300 (clobber (match_scratch:SI 4 "=q,X,q,X"))]
ca7f5001 4301 "TARGET_POWER"
1fd4e8c1
RK
4302 "@
4303 srea. %0,%1,%2
9ebbca7d
GK
4304 {srai.|srawi.} %0,%1,%h2
4305 #
4306 #"
4307 [(set_attr "type" "delayed_compare")
4308 (set_attr "length" "4,4,8,8")])
4309
4310(define_split
4311 [(set (match_operand:CC 3 "cc_reg_not_cr0_operand" "")
4312 (compare:CC (ashiftrt:SI (match_operand:SI 1 "gpc_reg_operand" "")
4313 (match_operand:SI 2 "reg_or_cint_operand" ""))
4314 (const_int 0)))
4315 (set (match_operand:SI 0 "gpc_reg_operand" "")
4316 (ashiftrt:SI (match_dup 1) (match_dup 2)))
4317 (clobber (match_scratch:SI 4 ""))]
4318 "TARGET_POWER && reload_completed"
4319 [(parallel [(set (match_dup 0)
4320 (ashiftrt:SI (match_dup 1) (match_dup 2)))
4321 (clobber (match_dup 4))])
4322 (set (match_dup 3)
4323 (compare:CC (match_dup 0)
4324 (const_int 0)))]
4325 "")
1fd4e8c1 4326
ca7f5001 4327(define_insn ""
9ebbca7d
GK
4328 [(set (match_operand:CC 3 "cc_reg_operand" "=x,?y")
4329 (compare:CC (ashiftrt:SI (match_operand:SI 1 "gpc_reg_operand" "r,r")
4330 (match_operand:SI 2 "reg_or_cint_operand" "ri,ri"))
ca7f5001 4331 (const_int 0)))
9ebbca7d 4332 (set (match_operand:SI 0 "gpc_reg_operand" "=r,r")
ca7f5001 4333 (ashiftrt:SI (match_dup 1) (match_dup 2)))]
25c341fa 4334 "! TARGET_POWER"
9ebbca7d
GK
4335 "@
4336 {sra|sraw}%I2. %0,%1,%h2
4337 #"
4338 [(set_attr "type" "delayed_compare")
4339 (set_attr "length" "4,8")])
1fd4e8c1 4340\f
9ebbca7d
GK
4341(define_split
4342 [(set (match_operand:CC 3 "cc_reg_not_cr0_operand" "")
4343 (compare:CC (ashiftrt:SI (match_operand:SI 1 "gpc_reg_operand" "")
4344 (match_operand:SI 2 "reg_or_cint_operand" ""))
4345 (const_int 0)))
4346 (set (match_operand:SI 0 "gpc_reg_operand" "")
4347 (ashiftrt:SI (match_dup 1) (match_dup 2)))]
4348 "! TARGET_POWER && reload_completed"
4349 [(set (match_dup 0)
4350 (ashiftrt:SI (match_dup 1) (match_dup 2)))
4351 (set (match_dup 3)
4352 (compare:CC (match_dup 0)
4353 (const_int 0)))]
4354 "")
4355
1fd4e8c1
RK
4356;; Floating-point insns, excluding normal data motion.
4357;;
ca7f5001
RK
4358;; PowerPC has a full set of single-precision floating point instructions.
4359;;
4360;; For the POWER architecture, we pretend that we have both SFmode and
4361;; DFmode insns, while, in fact, all fp insns are actually done in double.
4362;; The only conversions we will do will be when storing to memory. In that
4363;; case, we will use the "frsp" instruction before storing.
1fd4e8c1
RK
4364;;
4365;; Note that when we store into a single-precision memory location, we need to
4366;; use the frsp insn first. If the register being stored isn't dead, we
4367;; need a scratch register for the frsp. But this is difficult when the store
4368;; is done by reload. It is not incorrect to do the frsp on the register in
4369;; this case, we just lose precision that we would have otherwise gotten but
4370;; is not guaranteed. Perhaps this should be tightened up at some point.
4371
e8112008 4372(define_insn "extendsfdf2"
cd2b37d9 4373 [(set (match_operand:DF 0 "gpc_reg_operand" "=f")
e8112008 4374 (float_extend:DF (match_operand:SF 1 "gpc_reg_operand" "f")))]
a3170dc6 4375 "TARGET_HARD_FLOAT && TARGET_FPRS"
e8112008 4376 "*
5c30aff8 4377{
e8112008
RK
4378 if (REGNO (operands[0]) == REGNO (operands[1]))
4379 return \"\";
4380 else
4381 return \"fmr %0,%1\";
4382}"
4383 [(set_attr "type" "fp")])
1fd4e8c1
RK
4384
4385(define_insn "truncdfsf2"
cd2b37d9
RK
4386 [(set (match_operand:SF 0 "gpc_reg_operand" "=f")
4387 (float_truncate:SF (match_operand:DF 1 "gpc_reg_operand" "f")))]
a3170dc6 4388 "TARGET_HARD_FLOAT && TARGET_FPRS"
dcac138d 4389 "frsp %0,%1"
1fd4e8c1
RK
4390 [(set_attr "type" "fp")])
4391
455350f4
RK
4392(define_insn "aux_truncdfsf2"
4393 [(set (match_operand:SF 0 "gpc_reg_operand" "=f")
615158e2 4394 (unspec:SF [(match_operand:SF 1 "gpc_reg_operand" "f")] UNSPEC_FRSP))]
a3170dc6 4395 "! TARGET_POWERPC && TARGET_HARD_FLOAT && TARGET_FPRS"
455350f4
RK
4396 "frsp %0,%1"
4397 [(set_attr "type" "fp")])
4398
a3170dc6
AH
4399(define_expand "negsf2"
4400 [(set (match_operand:SF 0 "gpc_reg_operand" "")
4401 (neg:SF (match_operand:SF 1 "gpc_reg_operand" "")))]
4402 "TARGET_HARD_FLOAT"
4403 "")
4404
4405(define_insn "*negsf2"
cd2b37d9
RK
4406 [(set (match_operand:SF 0 "gpc_reg_operand" "=f")
4407 (neg:SF (match_operand:SF 1 "gpc_reg_operand" "f")))]
a3170dc6 4408 "TARGET_HARD_FLOAT && TARGET_FPRS"
1fd4e8c1
RK
4409 "fneg %0,%1"
4410 [(set_attr "type" "fp")])
4411
a3170dc6
AH
4412(define_expand "abssf2"
4413 [(set (match_operand:SF 0 "gpc_reg_operand" "")
4414 (abs:SF (match_operand:SF 1 "gpc_reg_operand" "")))]
4415 "TARGET_HARD_FLOAT"
4416 "")
4417
4418(define_insn "*abssf2"
cd2b37d9
RK
4419 [(set (match_operand:SF 0 "gpc_reg_operand" "=f")
4420 (abs:SF (match_operand:SF 1 "gpc_reg_operand" "f")))]
a3170dc6 4421 "TARGET_HARD_FLOAT && TARGET_FPRS"
1fd4e8c1
RK
4422 "fabs %0,%1"
4423 [(set_attr "type" "fp")])
4424
4425(define_insn ""
cd2b37d9
RK
4426 [(set (match_operand:SF 0 "gpc_reg_operand" "=f")
4427 (neg:SF (abs:SF (match_operand:SF 1 "gpc_reg_operand" "f"))))]
a3170dc6 4428 "TARGET_HARD_FLOAT && TARGET_FPRS"
1fd4e8c1
RK
4429 "fnabs %0,%1"
4430 [(set_attr "type" "fp")])
4431
ca7f5001
RK
4432(define_expand "addsf3"
4433 [(set (match_operand:SF 0 "gpc_reg_operand" "")
4434 (plus:SF (match_operand:SF 1 "gpc_reg_operand" "")
4435 (match_operand:SF 2 "gpc_reg_operand" "")))]
d14a6d05 4436 "TARGET_HARD_FLOAT"
ca7f5001
RK
4437 "")
4438
4439(define_insn ""
cd2b37d9
RK
4440 [(set (match_operand:SF 0 "gpc_reg_operand" "=f")
4441 (plus:SF (match_operand:SF 1 "gpc_reg_operand" "%f")
4442 (match_operand:SF 2 "gpc_reg_operand" "f")))]
a3170dc6 4443 "TARGET_POWERPC && TARGET_HARD_FLOAT && TARGET_FPRS"
b26c8351 4444 "fadds %0,%1,%2"
ca7f5001
RK
4445 [(set_attr "type" "fp")])
4446
4447(define_insn ""
4448 [(set (match_operand:SF 0 "gpc_reg_operand" "=f")
4449 (plus:SF (match_operand:SF 1 "gpc_reg_operand" "%f")
4450 (match_operand:SF 2 "gpc_reg_operand" "f")))]
a3170dc6 4451 "! TARGET_POWERPC && TARGET_HARD_FLOAT && TARGET_FPRS"
b26c8351 4452 "{fa|fadd} %0,%1,%2"
ca7f5001
RK
4453 [(set_attr "type" "fp")])
4454
4455(define_expand "subsf3"
4456 [(set (match_operand:SF 0 "gpc_reg_operand" "")
4457 (minus:SF (match_operand:SF 1 "gpc_reg_operand" "")
4458 (match_operand:SF 2 "gpc_reg_operand" "")))]
d14a6d05 4459 "TARGET_HARD_FLOAT"
ca7f5001
RK
4460 "")
4461
4462(define_insn ""
4463 [(set (match_operand:SF 0 "gpc_reg_operand" "=f")
4464 (minus:SF (match_operand:SF 1 "gpc_reg_operand" "f")
4465 (match_operand:SF 2 "gpc_reg_operand" "f")))]
a3170dc6 4466 "TARGET_POWERPC && TARGET_HARD_FLOAT && TARGET_FPRS"
b26c8351 4467 "fsubs %0,%1,%2"
1fd4e8c1
RK
4468 [(set_attr "type" "fp")])
4469
ca7f5001 4470(define_insn ""
cd2b37d9
RK
4471 [(set (match_operand:SF 0 "gpc_reg_operand" "=f")
4472 (minus:SF (match_operand:SF 1 "gpc_reg_operand" "f")
4473 (match_operand:SF 2 "gpc_reg_operand" "f")))]
a3170dc6 4474 "! TARGET_POWERPC && TARGET_HARD_FLOAT && TARGET_FPRS"
b26c8351 4475 "{fs|fsub} %0,%1,%2"
ca7f5001
RK
4476 [(set_attr "type" "fp")])
4477
4478(define_expand "mulsf3"
4479 [(set (match_operand:SF 0 "gpc_reg_operand" "")
4480 (mult:SF (match_operand:SF 1 "gpc_reg_operand" "")
4481 (match_operand:SF 2 "gpc_reg_operand" "")))]
d14a6d05 4482 "TARGET_HARD_FLOAT"
ca7f5001
RK
4483 "")
4484
4485(define_insn ""
4486 [(set (match_operand:SF 0 "gpc_reg_operand" "=f")
4487 (mult:SF (match_operand:SF 1 "gpc_reg_operand" "%f")
4488 (match_operand:SF 2 "gpc_reg_operand" "f")))]
a3170dc6 4489 "TARGET_POWERPC && TARGET_HARD_FLOAT && TARGET_FPRS"
b26c8351 4490 "fmuls %0,%1,%2"
1fd4e8c1
RK
4491 [(set_attr "type" "fp")])
4492
ca7f5001 4493(define_insn ""
cd2b37d9
RK
4494 [(set (match_operand:SF 0 "gpc_reg_operand" "=f")
4495 (mult:SF (match_operand:SF 1 "gpc_reg_operand" "%f")
4496 (match_operand:SF 2 "gpc_reg_operand" "f")))]
a3170dc6 4497 "! TARGET_POWERPC && TARGET_HARD_FLOAT && TARGET_FPRS"
b26c8351 4498 "{fm|fmul} %0,%1,%2"
0780f386 4499 [(set_attr "type" "dmul")])
1fd4e8c1 4500
ca7f5001
RK
4501(define_expand "divsf3"
4502 [(set (match_operand:SF 0 "gpc_reg_operand" "")
4503 (div:SF (match_operand:SF 1 "gpc_reg_operand" "")
4504 (match_operand:SF 2 "gpc_reg_operand" "")))]
d14a6d05 4505 "TARGET_HARD_FLOAT"
ca7f5001
RK
4506 "")
4507
4508(define_insn ""
cd2b37d9
RK
4509 [(set (match_operand:SF 0 "gpc_reg_operand" "=f")
4510 (div:SF (match_operand:SF 1 "gpc_reg_operand" "f")
4511 (match_operand:SF 2 "gpc_reg_operand" "f")))]
a3170dc6 4512 "TARGET_POWERPC && TARGET_HARD_FLOAT && TARGET_FPRS"
b26c8351 4513 "fdivs %0,%1,%2"
ca7f5001
RK
4514 [(set_attr "type" "sdiv")])
4515
4516(define_insn ""
4517 [(set (match_operand:SF 0 "gpc_reg_operand" "=f")
4518 (div:SF (match_operand:SF 1 "gpc_reg_operand" "f")
4519 (match_operand:SF 2 "gpc_reg_operand" "f")))]
a3170dc6 4520 "! TARGET_POWERPC && TARGET_HARD_FLOAT && TARGET_FPRS"
b26c8351 4521 "{fd|fdiv} %0,%1,%2"
0780f386 4522 [(set_attr "type" "ddiv")])
1fd4e8c1
RK
4523
4524(define_insn ""
cd2b37d9
RK
4525 [(set (match_operand:SF 0 "gpc_reg_operand" "=f")
4526 (plus:SF (mult:SF (match_operand:SF 1 "gpc_reg_operand" "%f")
4527 (match_operand:SF 2 "gpc_reg_operand" "f"))
4528 (match_operand:SF 3 "gpc_reg_operand" "f")))]
a3170dc6 4529 "TARGET_POWERPC && TARGET_HARD_FLOAT && TARGET_FPRS && TARGET_FUSED_MADD"
b26c8351 4530 "fmadds %0,%1,%2,%3"
ca7f5001
RK
4531 [(set_attr "type" "fp")])
4532
4533(define_insn ""
4534 [(set (match_operand:SF 0 "gpc_reg_operand" "=f")
4535 (plus:SF (mult:SF (match_operand:SF 1 "gpc_reg_operand" "%f")
4536 (match_operand:SF 2 "gpc_reg_operand" "f"))
4537 (match_operand:SF 3 "gpc_reg_operand" "f")))]
a3170dc6 4538 "! TARGET_POWERPC && TARGET_HARD_FLOAT && TARGET_FPRS && TARGET_FUSED_MADD"
b26c8351 4539 "{fma|fmadd} %0,%1,%2,%3"
cf27b467 4540 [(set_attr "type" "dmul")])
1fd4e8c1
RK
4541
4542(define_insn ""
cd2b37d9
RK
4543 [(set (match_operand:SF 0 "gpc_reg_operand" "=f")
4544 (minus:SF (mult:SF (match_operand:SF 1 "gpc_reg_operand" "%f")
4545 (match_operand:SF 2 "gpc_reg_operand" "f"))
4546 (match_operand:SF 3 "gpc_reg_operand" "f")))]
a3170dc6 4547 "TARGET_POWERPC && TARGET_HARD_FLOAT && TARGET_FPRS && TARGET_FUSED_MADD"
b26c8351 4548 "fmsubs %0,%1,%2,%3"
ca7f5001
RK
4549 [(set_attr "type" "fp")])
4550
4551(define_insn ""
4552 [(set (match_operand:SF 0 "gpc_reg_operand" "=f")
4553 (minus:SF (mult:SF (match_operand:SF 1 "gpc_reg_operand" "%f")
4554 (match_operand:SF 2 "gpc_reg_operand" "f"))
4555 (match_operand:SF 3 "gpc_reg_operand" "f")))]
a3170dc6 4556 "! TARGET_POWERPC && TARGET_HARD_FLOAT && TARGET_FPRS && TARGET_FUSED_MADD"
b26c8351 4557 "{fms|fmsub} %0,%1,%2,%3"
cf27b467 4558 [(set_attr "type" "dmul")])
1fd4e8c1
RK
4559
4560(define_insn ""
cd2b37d9
RK
4561 [(set (match_operand:SF 0 "gpc_reg_operand" "=f")
4562 (neg:SF (plus:SF (mult:SF (match_operand:SF 1 "gpc_reg_operand" "%f")
4563 (match_operand:SF 2 "gpc_reg_operand" "f"))
4564 (match_operand:SF 3 "gpc_reg_operand" "f"))))]
16823694
GK
4565 "TARGET_POWERPC && TARGET_HARD_FLOAT && TARGET_FPRS && TARGET_FUSED_MADD
4566 && HONOR_SIGNED_ZEROS (SFmode)"
4567 "fnmadds %0,%1,%2,%3"
4568 [(set_attr "type" "fp")])
4569
4570(define_insn ""
4571 [(set (match_operand:SF 0 "gpc_reg_operand" "=f")
4572 (minus:SF (mult:SF (neg:SF (match_operand:SF 1 "gpc_reg_operand" "f"))
4573 (match_operand:SF 2 "gpc_reg_operand" "f"))
4574 (match_operand:SF 3 "gpc_reg_operand" "f")))]
4575 "TARGET_POWERPC && TARGET_HARD_FLOAT && TARGET_FPRS && TARGET_FUSED_MADD
4576 && ! HONOR_SIGNED_ZEROS (SFmode)"
b26c8351 4577 "fnmadds %0,%1,%2,%3"
ca7f5001
RK
4578 [(set_attr "type" "fp")])
4579
4580(define_insn ""
4581 [(set (match_operand:SF 0 "gpc_reg_operand" "=f")
4582 (neg:SF (plus:SF (mult:SF (match_operand:SF 1 "gpc_reg_operand" "%f")
4583 (match_operand:SF 2 "gpc_reg_operand" "f"))
4584 (match_operand:SF 3 "gpc_reg_operand" "f"))))]
a3170dc6 4585 "! TARGET_POWERPC && TARGET_HARD_FLOAT && TARGET_FPRS && TARGET_FUSED_MADD"
b26c8351 4586 "{fnma|fnmadd} %0,%1,%2,%3"
cf27b467 4587 [(set_attr "type" "dmul")])
1fd4e8c1 4588
16823694
GK
4589(define_insn ""
4590 [(set (match_operand:SF 0 "gpc_reg_operand" "=f")
4591 (minus:SF (mult:SF (neg:SF (match_operand:SF 1 "gpc_reg_operand" "f"))
4592 (match_operand:SF 2 "gpc_reg_operand" "f"))
4593 (match_operand:SF 3 "gpc_reg_operand" "f")))]
4594 "! TARGET_POWERPC && TARGET_HARD_FLOAT && TARGET_FPRS && TARGET_FUSED_MADD
4595 && ! HONOR_SIGNED_ZEROS (SFmode)"
4596 "{fnma|fnmadd} %0,%1,%2,%3"
4597 [(set_attr "type" "dmul")])
4598
1fd4e8c1 4599(define_insn ""
cd2b37d9
RK
4600 [(set (match_operand:SF 0 "gpc_reg_operand" "=f")
4601 (neg:SF (minus:SF (mult:SF (match_operand:SF 1 "gpc_reg_operand" "%f")
4602 (match_operand:SF 2 "gpc_reg_operand" "f"))
4603 (match_operand:SF 3 "gpc_reg_operand" "f"))))]
16823694
GK
4604 "TARGET_POWERPC && TARGET_HARD_FLOAT && TARGET_FPRS && TARGET_FUSED_MADD
4605 && HONOR_SIGNED_ZEROS (SFmode)"
4606 "fnmsubs %0,%1,%2,%3"
4607 [(set_attr "type" "fp")])
4608
4609(define_insn ""
4610 [(set (match_operand:SF 0 "gpc_reg_operand" "=f")
4611 (minus:SF (match_operand:SF 3 "gpc_reg_operand" "f")
4612 (mult:SF (match_operand:SF 1 "gpc_reg_operand" "%f")
4613 (match_operand:SF 2 "gpc_reg_operand" "f"))))]
4614 "TARGET_POWERPC && TARGET_HARD_FLOAT && TARGET_FPRS && TARGET_FUSED_MADD
4615 && ! HONOR_SIGNED_ZEROS (SFmode)"
b26c8351 4616 "fnmsubs %0,%1,%2,%3"
ca7f5001
RK
4617 [(set_attr "type" "fp")])
4618
4619(define_insn ""
4620 [(set (match_operand:SF 0 "gpc_reg_operand" "=f")
4621 (neg:SF (minus:SF (mult:SF (match_operand:SF 1 "gpc_reg_operand" "%f")
4622 (match_operand:SF 2 "gpc_reg_operand" "f"))
4623 (match_operand:SF 3 "gpc_reg_operand" "f"))))]
a3170dc6 4624 "! TARGET_POWERPC && TARGET_HARD_FLOAT && TARGET_FPRS && TARGET_FUSED_MADD"
b26c8351 4625 "{fnms|fnmsub} %0,%1,%2,%3"
cf27b467 4626 [(set_attr "type" "dmul")])
1fd4e8c1 4627
16823694
GK
4628(define_insn ""
4629 [(set (match_operand:SF 0 "gpc_reg_operand" "=f")
4630 (minus:SF (match_operand:SF 3 "gpc_reg_operand" "f")
4631 (mult:SF (match_operand:SF 1 "gpc_reg_operand" "%f")
4632 (match_operand:SF 2 "gpc_reg_operand" "f"))))]
4633 "! TARGET_POWERPC && TARGET_HARD_FLOAT && TARGET_FPRS && TARGET_FUSED_MADD
4634 && ! HONOR_SIGNED_ZEROS (SFmode)"
4635 "{fnms|fnmsub} %0,%1,%2,%3"
4636 [(set_attr "type" "fp")])
4637
ca7f5001
RK
4638(define_expand "sqrtsf2"
4639 [(set (match_operand:SF 0 "gpc_reg_operand" "")
4640 (sqrt:SF (match_operand:SF 1 "gpc_reg_operand" "")))]
a3170dc6 4641 "(TARGET_PPC_GPOPT || TARGET_POWER2) && TARGET_HARD_FLOAT && TARGET_FPRS"
ca7f5001
RK
4642 "")
4643
4644(define_insn ""
4645 [(set (match_operand:SF 0 "gpc_reg_operand" "=f")
4646 (sqrt:SF (match_operand:SF 1 "gpc_reg_operand" "f")))]
a3170dc6 4647 "TARGET_PPC_GPOPT && TARGET_HARD_FLOAT && TARGET_FPRS"
ca7f5001
RK
4648 "fsqrts %0,%1"
4649 [(set_attr "type" "ssqrt")])
4650
4651(define_insn ""
4652 [(set (match_operand:SF 0 "gpc_reg_operand" "=f")
4653 (sqrt:SF (match_operand:SF 1 "gpc_reg_operand" "f")))]
a3170dc6 4654 "TARGET_POWER2 && TARGET_HARD_FLOAT && TARGET_FPRS"
ca7f5001
RK
4655 "fsqrt %0,%1"
4656 [(set_attr "type" "dsqrt")])
4657
94d7001a
RK
4658;; For MIN, MAX, and conditional move, we use DEFINE_EXPAND's that involve a
4659;; fsel instruction and some auxiliary computations. Then we just have a
4660;; single DEFINE_INSN for fsel and the define_splits to make them if made by
8e871c05
RK
4661;; combine.
4662(define_expand "maxsf3"
8e871c05 4663 [(set (match_operand:SF 0 "gpc_reg_operand" "")
50a0b056
GK
4664 (if_then_else:SF (ge (match_operand:SF 1 "gpc_reg_operand" "")
4665 (match_operand:SF 2 "gpc_reg_operand" ""))
8e871c05
RK
4666 (match_dup 1)
4667 (match_dup 2)))]
a3170dc6 4668 "TARGET_PPC_GFXOPT && TARGET_HARD_FLOAT && TARGET_FPRS"
50a0b056 4669 "{ rs6000_emit_minmax (operands[0], SMAX, operands[1], operands[2]); DONE;}")
2f607b94 4670
8e871c05 4671(define_expand "minsf3"
50a0b056
GK
4672 [(set (match_operand:SF 0 "gpc_reg_operand" "")
4673 (if_then_else:SF (ge (match_operand:SF 1 "gpc_reg_operand" "")
4674 (match_operand:SF 2 "gpc_reg_operand" ""))
4675 (match_dup 2)
4676 (match_dup 1)))]
a3170dc6 4677 "TARGET_PPC_GFXOPT && TARGET_HARD_FLOAT && TARGET_FPRS"
50a0b056 4678 "{ rs6000_emit_minmax (operands[0], SMIN, operands[1], operands[2]); DONE;}")
2f607b94 4679
8e871c05
RK
4680(define_split
4681 [(set (match_operand:SF 0 "gpc_reg_operand" "")
50a0b056
GK
4682 (match_operator:SF 3 "min_max_operator"
4683 [(match_operand:SF 1 "gpc_reg_operand" "")
4684 (match_operand:SF 2 "gpc_reg_operand" "")]))]
a3170dc6 4685 "TARGET_PPC_GFXOPT && TARGET_HARD_FLOAT && TARGET_FPRS"
50a0b056
GK
4686 [(const_int 0)]
4687 "
4688{ rs6000_emit_minmax (operands[0], GET_CODE (operands[3]),
4689 operands[1], operands[2]);
4690 DONE;
4691}")
2f607b94 4692
a3170dc6
AH
4693(define_expand "movsicc"
4694 [(set (match_operand:SI 0 "gpc_reg_operand" "")
4695 (if_then_else:SI (match_operand 1 "comparison_operator" "")
4696 (match_operand:SI 2 "gpc_reg_operand" "")
4697 (match_operand:SI 3 "gpc_reg_operand" "")))]
4698 "TARGET_ISEL"
4699 "
4700{
4701 if (rs6000_emit_cmove (operands[0], operands[1], operands[2], operands[3]))
4702 DONE;
4703 else
4704 FAIL;
4705}")
4706
4707;; We use the BASE_REGS for the isel input operands because, if rA is
4708;; 0, the value of 0 is placed in rD upon truth. Similarly for rB
4709;; because we may switch the operands and rB may end up being rA.
4710;;
4711;; We need 2 patterns: an unsigned and a signed pattern. We could
4712;; leave out the mode in operand 4 and use one pattern, but reload can
4713;; change the mode underneath our feet and then gets confused trying
4714;; to reload the value.
4715(define_insn "isel_signed"
4716 [(set (match_operand:SI 0 "gpc_reg_operand" "=r")
4717 (if_then_else:SI
4718 (match_operator 1 "comparison_operator"
4719 [(match_operand:CC 4 "cc_reg_operand" "y")
4720 (const_int 0)])
4721 (match_operand:SI 2 "gpc_reg_operand" "b")
4722 (match_operand:SI 3 "gpc_reg_operand" "b")))]
4723 "TARGET_ISEL"
4724 "*
4725{ return output_isel (operands); }"
4726 [(set_attr "length" "4")])
4727
4728(define_insn "isel_unsigned"
4729 [(set (match_operand:SI 0 "gpc_reg_operand" "=r")
4730 (if_then_else:SI
4731 (match_operator 1 "comparison_operator"
4732 [(match_operand:CCUNS 4 "cc_reg_operand" "y")
4733 (const_int 0)])
4734 (match_operand:SI 2 "gpc_reg_operand" "b")
4735 (match_operand:SI 3 "gpc_reg_operand" "b")))]
4736 "TARGET_ISEL"
4737 "*
4738{ return output_isel (operands); }"
4739 [(set_attr "length" "4")])
4740
94d7001a 4741(define_expand "movsfcc"
0ad91047 4742 [(set (match_operand:SF 0 "gpc_reg_operand" "")
94d7001a 4743 (if_then_else:SF (match_operand 1 "comparison_operator" "")
0ad91047
DE
4744 (match_operand:SF 2 "gpc_reg_operand" "")
4745 (match_operand:SF 3 "gpc_reg_operand" "")))]
a3170dc6 4746 "TARGET_PPC_GFXOPT && TARGET_HARD_FLOAT && TARGET_FPRS"
94d7001a
RK
4747 "
4748{
50a0b056
GK
4749 if (rs6000_emit_cmove (operands[0], operands[1], operands[2], operands[3]))
4750 DONE;
94d7001a 4751 else
50a0b056 4752 FAIL;
94d7001a 4753}")
d56d506a 4754
50a0b056 4755(define_insn "*fselsfsf4"
8e871c05
RK
4756 [(set (match_operand:SF 0 "gpc_reg_operand" "=f")
4757 (if_then_else:SF (ge (match_operand:SF 1 "gpc_reg_operand" "f")
50a0b056 4758 (match_operand:SF 4 "zero_fp_constant" "F"))
8e871c05
RK
4759 (match_operand:SF 2 "gpc_reg_operand" "f")
4760 (match_operand:SF 3 "gpc_reg_operand" "f")))]
a3170dc6 4761 "TARGET_PPC_GFXOPT && TARGET_HARD_FLOAT && TARGET_FPRS"
8e871c05
RK
4762 "fsel %0,%1,%2,%3"
4763 [(set_attr "type" "fp")])
2f607b94 4764
50a0b056 4765(define_insn "*fseldfsf4"
94d7001a
RK
4766 [(set (match_operand:SF 0 "gpc_reg_operand" "=f")
4767 (if_then_else:SF (ge (match_operand:DF 1 "gpc_reg_operand" "f")
d365ba42 4768 (match_operand:DF 4 "zero_fp_constant" "F"))
94d7001a
RK
4769 (match_operand:SF 2 "gpc_reg_operand" "f")
4770 (match_operand:SF 3 "gpc_reg_operand" "f")))]
a3170dc6 4771 "TARGET_PPC_GFXOPT && TARGET_HARD_FLOAT && TARGET_FPRS"
94d7001a
RK
4772 "fsel %0,%1,%2,%3"
4773 [(set_attr "type" "fp")])
d56d506a 4774
1fd4e8c1 4775(define_insn "negdf2"
cd2b37d9
RK
4776 [(set (match_operand:DF 0 "gpc_reg_operand" "=f")
4777 (neg:DF (match_operand:DF 1 "gpc_reg_operand" "f")))]
a3170dc6 4778 "TARGET_HARD_FLOAT && TARGET_FPRS"
1fd4e8c1
RK
4779 "fneg %0,%1"
4780 [(set_attr "type" "fp")])
4781
4782(define_insn "absdf2"
cd2b37d9
RK
4783 [(set (match_operand:DF 0 "gpc_reg_operand" "=f")
4784 (abs:DF (match_operand:DF 1 "gpc_reg_operand" "f")))]
a3170dc6 4785 "TARGET_HARD_FLOAT && TARGET_FPRS"
1fd4e8c1
RK
4786 "fabs %0,%1"
4787 [(set_attr "type" "fp")])
4788
4789(define_insn ""
cd2b37d9
RK
4790 [(set (match_operand:DF 0 "gpc_reg_operand" "=f")
4791 (neg:DF (abs:DF (match_operand:DF 1 "gpc_reg_operand" "f"))))]
a3170dc6 4792 "TARGET_HARD_FLOAT && TARGET_FPRS"
1fd4e8c1
RK
4793 "fnabs %0,%1"
4794 [(set_attr "type" "fp")])
4795
4796(define_insn "adddf3"
cd2b37d9
RK
4797 [(set (match_operand:DF 0 "gpc_reg_operand" "=f")
4798 (plus:DF (match_operand:DF 1 "gpc_reg_operand" "%f")
4799 (match_operand:DF 2 "gpc_reg_operand" "f")))]
a3170dc6 4800 "TARGET_HARD_FLOAT && TARGET_FPRS"
ca7f5001 4801 "{fa|fadd} %0,%1,%2"
1fd4e8c1
RK
4802 [(set_attr "type" "fp")])
4803
4804(define_insn "subdf3"
cd2b37d9
RK
4805 [(set (match_operand:DF 0 "gpc_reg_operand" "=f")
4806 (minus:DF (match_operand:DF 1 "gpc_reg_operand" "f")
4807 (match_operand:DF 2 "gpc_reg_operand" "f")))]
a3170dc6 4808 "TARGET_HARD_FLOAT && TARGET_FPRS"
ca7f5001 4809 "{fs|fsub} %0,%1,%2"
1fd4e8c1
RK
4810 [(set_attr "type" "fp")])
4811
4812(define_insn "muldf3"
cd2b37d9
RK
4813 [(set (match_operand:DF 0 "gpc_reg_operand" "=f")
4814 (mult:DF (match_operand:DF 1 "gpc_reg_operand" "%f")
4815 (match_operand:DF 2 "gpc_reg_operand" "f")))]
a3170dc6 4816 "TARGET_HARD_FLOAT && TARGET_FPRS"
ca7f5001 4817 "{fm|fmul} %0,%1,%2"
cfb557c4 4818 [(set_attr "type" "dmul")])
1fd4e8c1
RK
4819
4820(define_insn "divdf3"
cd2b37d9
RK
4821 [(set (match_operand:DF 0 "gpc_reg_operand" "=f")
4822 (div:DF (match_operand:DF 1 "gpc_reg_operand" "f")
4823 (match_operand:DF 2 "gpc_reg_operand" "f")))]
a3170dc6 4824 "TARGET_HARD_FLOAT && TARGET_FPRS"
ca7f5001 4825 "{fd|fdiv} %0,%1,%2"
cfb557c4 4826 [(set_attr "type" "ddiv")])
1fd4e8c1
RK
4827
4828(define_insn ""
cd2b37d9
RK
4829 [(set (match_operand:DF 0 "gpc_reg_operand" "=f")
4830 (plus:DF (mult:DF (match_operand:DF 1 "gpc_reg_operand" "%f")
4831 (match_operand:DF 2 "gpc_reg_operand" "f"))
4832 (match_operand:DF 3 "gpc_reg_operand" "f")))]
a3170dc6 4833 "TARGET_HARD_FLOAT && TARGET_FPRS && TARGET_FUSED_MADD"
ca7f5001 4834 "{fma|fmadd} %0,%1,%2,%3"
cfb557c4 4835 [(set_attr "type" "dmul")])
1fd4e8c1
RK
4836
4837(define_insn ""
cd2b37d9
RK
4838 [(set (match_operand:DF 0 "gpc_reg_operand" "=f")
4839 (minus:DF (mult:DF (match_operand:DF 1 "gpc_reg_operand" "%f")
4840 (match_operand:DF 2 "gpc_reg_operand" "f"))
4841 (match_operand:DF 3 "gpc_reg_operand" "f")))]
a3170dc6 4842 "TARGET_HARD_FLOAT && TARGET_FPRS && TARGET_FUSED_MADD"
ca7f5001 4843 "{fms|fmsub} %0,%1,%2,%3"
cfb557c4 4844 [(set_attr "type" "dmul")])
1fd4e8c1
RK
4845
4846(define_insn ""
cd2b37d9
RK
4847 [(set (match_operand:DF 0 "gpc_reg_operand" "=f")
4848 (neg:DF (plus:DF (mult:DF (match_operand:DF 1 "gpc_reg_operand" "%f")
4849 (match_operand:DF 2 "gpc_reg_operand" "f"))
4850 (match_operand:DF 3 "gpc_reg_operand" "f"))))]
16823694
GK
4851 "TARGET_HARD_FLOAT && TARGET_FPRS && TARGET_FUSED_MADD
4852 && HONOR_SIGNED_ZEROS (DFmode)"
4853 "{fnma|fnmadd} %0,%1,%2,%3"
4854 [(set_attr "type" "dmul")])
4855
4856(define_insn ""
4857 [(set (match_operand:DF 0 "gpc_reg_operand" "=f")
4858 (minus:DF (mult:DF (neg:DF (match_operand:DF 1 "gpc_reg_operand" "f"))
4859 (match_operand:DF 2 "gpc_reg_operand" "f"))
4860 (match_operand:DF 3 "gpc_reg_operand" "f")))]
4861 "TARGET_HARD_FLOAT && TARGET_FPRS && TARGET_FUSED_MADD
4862 && ! HONOR_SIGNED_ZEROS (DFmode)"
ca7f5001 4863 "{fnma|fnmadd} %0,%1,%2,%3"
cfb557c4 4864 [(set_attr "type" "dmul")])
1fd4e8c1
RK
4865
4866(define_insn ""
cd2b37d9
RK
4867 [(set (match_operand:DF 0 "gpc_reg_operand" "=f")
4868 (neg:DF (minus:DF (mult:DF (match_operand:DF 1 "gpc_reg_operand" "%f")
4869 (match_operand:DF 2 "gpc_reg_operand" "f"))
4870 (match_operand:DF 3 "gpc_reg_operand" "f"))))]
16823694
GK
4871 "TARGET_HARD_FLOAT && TARGET_FPRS && TARGET_FUSED_MADD
4872 && HONOR_SIGNED_ZEROS (DFmode)"
4873 "{fnms|fnmsub} %0,%1,%2,%3"
4874 [(set_attr "type" "dmul")])
4875
4876(define_insn ""
4877 [(set (match_operand:DF 0 "gpc_reg_operand" "=f")
4878 (minus:DF (match_operand:DF 3 "gpc_reg_operand" "f")
4879 (mult:DF (match_operand:DF 1 "gpc_reg_operand" "%f")
4880 (match_operand:DF 2 "gpc_reg_operand" "f"))))]
4881 "TARGET_HARD_FLOAT && TARGET_FPRS && TARGET_FUSED_MADD
4882 && ! HONOR_SIGNED_ZEROS (DFmode)"
ca7f5001 4883 "{fnms|fnmsub} %0,%1,%2,%3"
cfb557c4 4884 [(set_attr "type" "dmul")])
ca7f5001
RK
4885
4886(define_insn "sqrtdf2"
4887 [(set (match_operand:DF 0 "gpc_reg_operand" "=f")
4888 (sqrt:DF (match_operand:DF 1 "gpc_reg_operand" "f")))]
a3170dc6 4889 "(TARGET_PPC_GPOPT || TARGET_POWER2) && TARGET_HARD_FLOAT && TARGET_FPRS"
ca7f5001
RK
4890 "fsqrt %0,%1"
4891 [(set_attr "type" "dsqrt")])
b77dfefc 4892
50a0b056
GK
4893;; The conditional move instructions allow us to perform max and min
4894;; operations even when
b77dfefc 4895
8e871c05 4896(define_expand "maxdf3"
8e871c05 4897 [(set (match_operand:DF 0 "gpc_reg_operand" "")
50a0b056
GK
4898 (if_then_else:DF (ge (match_operand:DF 1 "gpc_reg_operand" "")
4899 (match_operand:DF 2 "gpc_reg_operand" ""))
8e871c05
RK
4900 (match_dup 1)
4901 (match_dup 2)))]
a3170dc6 4902 "TARGET_PPC_GFXOPT && TARGET_HARD_FLOAT && TARGET_FPRS"
50a0b056 4903 "{ rs6000_emit_minmax (operands[0], SMAX, operands[1], operands[2]); DONE;}")
b77dfefc 4904
8e871c05 4905(define_expand "mindf3"
50a0b056
GK
4906 [(set (match_operand:DF 0 "gpc_reg_operand" "")
4907 (if_then_else:DF (ge (match_operand:DF 1 "gpc_reg_operand" "")
4908 (match_operand:DF 2 "gpc_reg_operand" ""))
4909 (match_dup 2)
4910 (match_dup 1)))]
a3170dc6 4911 "TARGET_PPC_GFXOPT && TARGET_HARD_FLOAT && TARGET_FPRS"
50a0b056 4912 "{ rs6000_emit_minmax (operands[0], SMIN, operands[1], operands[2]); DONE;}")
b77dfefc 4913
8e871c05
RK
4914(define_split
4915 [(set (match_operand:DF 0 "gpc_reg_operand" "")
50a0b056
GK
4916 (match_operator:DF 3 "min_max_operator"
4917 [(match_operand:DF 1 "gpc_reg_operand" "")
4918 (match_operand:DF 2 "gpc_reg_operand" "")]))]
a3170dc6 4919 "TARGET_PPC_GFXOPT && TARGET_HARD_FLOAT && TARGET_FPRS"
50a0b056
GK
4920 [(const_int 0)]
4921 "
4922{ rs6000_emit_minmax (operands[0], GET_CODE (operands[3]),
4923 operands[1], operands[2]);
4924 DONE;
4925}")
b77dfefc 4926
94d7001a 4927(define_expand "movdfcc"
0ad91047 4928 [(set (match_operand:DF 0 "gpc_reg_operand" "")
94d7001a 4929 (if_then_else:DF (match_operand 1 "comparison_operator" "")
0ad91047
DE
4930 (match_operand:DF 2 "gpc_reg_operand" "")
4931 (match_operand:DF 3 "gpc_reg_operand" "")))]
a3170dc6 4932 "TARGET_PPC_GFXOPT && TARGET_HARD_FLOAT && TARGET_FPRS"
94d7001a
RK
4933 "
4934{
50a0b056
GK
4935 if (rs6000_emit_cmove (operands[0], operands[1], operands[2], operands[3]))
4936 DONE;
94d7001a 4937 else
50a0b056 4938 FAIL;
94d7001a 4939}")
d56d506a 4940
50a0b056 4941(define_insn "*fseldfdf4"
8e871c05
RK
4942 [(set (match_operand:DF 0 "gpc_reg_operand" "=f")
4943 (if_then_else:DF (ge (match_operand:DF 1 "gpc_reg_operand" "f")
50a0b056 4944 (match_operand:DF 4 "zero_fp_constant" "F"))
8e871c05
RK
4945 (match_operand:DF 2 "gpc_reg_operand" "f")
4946 (match_operand:DF 3 "gpc_reg_operand" "f")))]
a3170dc6 4947 "TARGET_PPC_GFXOPT && TARGET_HARD_FLOAT && TARGET_FPRS"
8e871c05
RK
4948 "fsel %0,%1,%2,%3"
4949 [(set_attr "type" "fp")])
d56d506a 4950
50a0b056 4951(define_insn "*fselsfdf4"
94d7001a
RK
4952 [(set (match_operand:DF 0 "gpc_reg_operand" "=f")
4953 (if_then_else:DF (ge (match_operand:SF 1 "gpc_reg_operand" "f")
50a0b056 4954 (match_operand:SF 4 "zero_fp_constant" "F"))
94d7001a
RK
4955 (match_operand:DF 2 "gpc_reg_operand" "f")
4956 (match_operand:DF 3 "gpc_reg_operand" "f")))]
4957 "TARGET_PPC_GFXOPT"
4958 "fsel %0,%1,%2,%3"
4959 [(set_attr "type" "fp")])
1fd4e8c1
RK
4960\f
4961;; Conversions to and from floating-point.
802a0058 4962
a3170dc6
AH
4963(define_expand "fixunssfsi2"
4964 [(set (match_operand:SI 0 "gpc_reg_operand" "")
4965 (unsigned_fix:SI (fix:SF (match_operand:SF 1 "gpc_reg_operand" ""))))]
4966 "TARGET_HARD_FLOAT && !TARGET_FPRS"
4967 "")
4968
4969(define_expand "fix_truncsfsi2"
4970 [(set (match_operand:SI 0 "gpc_reg_operand" "")
4971 (fix:SI (match_operand:SF 1 "gpc_reg_operand" "")))]
4972 "TARGET_HARD_FLOAT && !TARGET_FPRS"
4973 "")
4974
9ebbca7d
GK
4975; For each of these conversions, there is a define_expand, a define_insn
4976; with a '#' template, and a define_split (with C code). The idea is
4977; to allow constant folding with the template of the define_insn,
4978; then to have the insns split later (between sched1 and final).
4979
1fd4e8c1 4980(define_expand "floatsidf2"
802a0058
MM
4981 [(parallel [(set (match_operand:DF 0 "gpc_reg_operand" "")
4982 (float:DF (match_operand:SI 1 "gpc_reg_operand" "")))
4983 (use (match_dup 2))
4984 (use (match_dup 3))
208c89ce 4985 (clobber (match_dup 4))
a7df97e6 4986 (clobber (match_dup 5))
9ebbca7d 4987 (clobber (match_dup 6))])]
a3170dc6 4988 "TARGET_HARD_FLOAT && TARGET_FPRS"
1fd4e8c1
RK
4989 "
4990{
05d49501
AM
4991 if (TARGET_POWERPC64)
4992 {
4993 rtx mem = assign_stack_temp (DImode, GET_MODE_SIZE (DImode), 0);
4994 rtx t1 = gen_reg_rtx (DImode);
4995 rtx t2 = gen_reg_rtx (DImode);
4996 emit_insn (gen_floatsidf_ppc64 (operands[0], operands[1], mem, t1, t2));
4997 DONE;
4998 }
4999
802a0058 5000 operands[2] = force_reg (SImode, GEN_INT (0x43300000));
5692c7bc 5001 operands[3] = force_reg (DFmode, CONST_DOUBLE_ATOF (\"4503601774854144\", DFmode));
9ebbca7d
GK
5002 operands[4] = assign_stack_temp (DFmode, GET_MODE_SIZE (DFmode), 0);
5003 operands[5] = gen_reg_rtx (DFmode);
5004 operands[6] = gen_reg_rtx (SImode);
1fd4e8c1
RK
5005}")
5006
802a0058
MM
5007(define_insn "*floatsidf2_internal"
5008 [(set (match_operand:DF 0 "gpc_reg_operand" "=&f")
5009 (float:DF (match_operand:SI 1 "gpc_reg_operand" "r")))
5010 (use (match_operand:SI 2 "gpc_reg_operand" "r"))
5011 (use (match_operand:DF 3 "gpc_reg_operand" "f"))
9ebbca7d 5012 (clobber (match_operand:DF 4 "memory_operand" "=o"))
6f9c81f5
DJ
5013 (clobber (match_operand:DF 5 "gpc_reg_operand" "=&f"))
5014 (clobber (match_operand:SI 6 "gpc_reg_operand" "=&r"))]
a3170dc6 5015 "! TARGET_POWERPC64 && TARGET_HARD_FLOAT && TARGET_FPRS"
802a0058 5016 "#"
a7df97e6 5017 [(set_attr "length" "24")])
802a0058
MM
5018
5019(define_split
dbe3df29 5020 [(set (match_operand:DF 0 "gpc_reg_operand" "")
802a0058
MM
5021 (float:DF (match_operand:SI 1 "gpc_reg_operand" "")))
5022 (use (match_operand:SI 2 "gpc_reg_operand" ""))
5023 (use (match_operand:DF 3 "gpc_reg_operand" ""))
9ebbca7d
GK
5024 (clobber (match_operand:DF 4 "offsettable_mem_operand" ""))
5025 (clobber (match_operand:DF 5 "gpc_reg_operand" ""))
5026 (clobber (match_operand:SI 6 "gpc_reg_operand" ""))]
a3170dc6 5027 "! TARGET_POWERPC64 && TARGET_HARD_FLOAT && TARGET_FPRS"
9ebbca7d
GK
5028 [(set (match_operand:DF 0 "gpc_reg_operand" "")
5029 (float:DF (match_operand:SI 1 "gpc_reg_operand" "")))
5030 (use (match_operand:SI 2 "gpc_reg_operand" ""))
5031 (use (match_operand:DF 3 "gpc_reg_operand" ""))
5032 (clobber (match_operand:DF 4 "offsettable_mem_operand" ""))
5033 (clobber (match_operand:DF 5 "gpc_reg_operand" ""))
5034 (clobber (match_operand:SI 6 "gpc_reg_operand" ""))]
208c89ce
MM
5035 "
5036{
9ebbca7d
GK
5037 rtx lowword, highword;
5038 if (GET_CODE (operands[4]) != MEM)
5039 abort();
5040 highword = XEXP (operands[4], 0);
5041 lowword = plus_constant (highword, 4);
5042 if (! WORDS_BIG_ENDIAN)
5043 {
5044 rtx tmp;
5045 tmp = highword; highword = lowword; lowword = tmp;
5046 }
5047
5048 emit_insn (gen_xorsi3 (operands[6], operands[1],
5049 GEN_INT (~ (HOST_WIDE_INT) 0x7fffffff)));
5050 emit_move_insn (gen_rtx_MEM (SImode, lowword), operands[6]);
5051 emit_move_insn (gen_rtx_MEM (SImode, highword), operands[2]);
5052 emit_move_insn (operands[5], operands[4]);
5053 emit_insn (gen_subdf3 (operands[0], operands[5], operands[3]));
5054 DONE;
208c89ce 5055}")
802a0058 5056
a3170dc6
AH
5057(define_expand "floatunssisf2"
5058 [(set (match_operand:SF 0 "gpc_reg_operand" "")
5059 (unsigned_float:SF (match_operand:SI 1 "gpc_reg_operand" "")))]
5060 "TARGET_HARD_FLOAT && !TARGET_FPRS"
5061 "")
5062
802a0058
MM
5063(define_expand "floatunssidf2"
5064 [(parallel [(set (match_operand:DF 0 "gpc_reg_operand" "")
5065 (unsigned_float:DF (match_operand:SI 1 "gpc_reg_operand" "")))
5066 (use (match_dup 2))
5067 (use (match_dup 3))
a7df97e6 5068 (clobber (match_dup 4))
9ebbca7d 5069 (clobber (match_dup 5))])]
a3170dc6 5070 "TARGET_HARD_FLOAT && TARGET_FPRS"
1fd4e8c1
RK
5071 "
5072{
05d49501
AM
5073 if (TARGET_POWERPC64)
5074 {
5075 rtx mem = assign_stack_temp (DImode, GET_MODE_SIZE (DImode), 0);
5076 rtx t1 = gen_reg_rtx (DImode);
5077 rtx t2 = gen_reg_rtx (DImode);
5078 emit_insn (gen_floatunssidf_ppc64 (operands[0], operands[1], mem,
5079 t1, t2));
5080 DONE;
5081 }
5082
802a0058 5083 operands[2] = force_reg (SImode, GEN_INT (0x43300000));
5692c7bc 5084 operands[3] = force_reg (DFmode, CONST_DOUBLE_ATOF (\"4503599627370496\", DFmode));
9ebbca7d
GK
5085 operands[4] = assign_stack_temp (DFmode, GET_MODE_SIZE (DFmode), 0);
5086 operands[5] = gen_reg_rtx (DFmode);
1fd4e8c1
RK
5087}")
5088
802a0058
MM
5089(define_insn "*floatunssidf2_internal"
5090 [(set (match_operand:DF 0 "gpc_reg_operand" "=&f")
5091 (unsigned_float:DF (match_operand:SI 1 "gpc_reg_operand" "r")))
5092 (use (match_operand:SI 2 "gpc_reg_operand" "r"))
5093 (use (match_operand:DF 3 "gpc_reg_operand" "f"))
9ebbca7d 5094 (clobber (match_operand:DF 4 "memory_operand" "=o"))
6f9c81f5 5095 (clobber (match_operand:DF 5 "gpc_reg_operand" "=&f"))]
a3170dc6 5096 "! TARGET_POWERPC64 && TARGET_HARD_FLOAT && TARGET_FPRS"
802a0058 5097 "#"
a7df97e6 5098 [(set_attr "length" "20")])
802a0058
MM
5099
5100(define_split
5101 [(set (match_operand:DF 0 "gpc_reg_operand" "")
5102 (unsigned_float:DF (match_operand:SI 1 "gpc_reg_operand" "")))
5103 (use (match_operand:SI 2 "gpc_reg_operand" ""))
5104 (use (match_operand:DF 3 "gpc_reg_operand" ""))
9ebbca7d
GK
5105 (clobber (match_operand:DF 4 "offsettable_mem_operand" ""))
5106 (clobber (match_operand:DF 5 "gpc_reg_operand" ""))]
a3170dc6 5107 "! TARGET_POWERPC64 && TARGET_HARD_FLOAT && TARGET_FPRS"
9ebbca7d
GK
5108 [(set (match_operand:DF 0 "gpc_reg_operand" "")
5109 (unsigned_float:DF (match_operand:SI 1 "gpc_reg_operand" "")))
5110 (use (match_operand:SI 2 "gpc_reg_operand" ""))
5111 (use (match_operand:DF 3 "gpc_reg_operand" ""))
5112 (clobber (match_operand:DF 4 "offsettable_mem_operand" ""))
5113 (clobber (match_operand:DF 5 "gpc_reg_operand" ""))]
5114 "
802a0058 5115{
9ebbca7d
GK
5116 rtx lowword, highword;
5117 if (GET_CODE (operands[4]) != MEM)
5118 abort();
5119 highword = XEXP (operands[4], 0);
5120 lowword = plus_constant (highword, 4);
5121 if (! WORDS_BIG_ENDIAN)
f6968f59 5122 {
9ebbca7d
GK
5123 rtx tmp;
5124 tmp = highword; highword = lowword; lowword = tmp;
f6968f59 5125 }
802a0058 5126
9ebbca7d
GK
5127 emit_move_insn (gen_rtx_MEM (SImode, lowword), operands[1]);
5128 emit_move_insn (gen_rtx_MEM (SImode, highword), operands[2]);
5129 emit_move_insn (operands[5], operands[4]);
5130 emit_insn (gen_subdf3 (operands[0], operands[5], operands[3]));
5131 DONE;
5132}")
1fd4e8c1 5133
1fd4e8c1 5134(define_expand "fix_truncdfsi2"
802a0058
MM
5135 [(parallel [(set (match_operand:SI 0 "gpc_reg_operand" "")
5136 (fix:SI (match_operand:DF 1 "gpc_reg_operand" "")))
5137 (clobber (match_dup 2))
9ebbca7d 5138 (clobber (match_dup 3))])]
a3170dc6 5139 "(TARGET_POWER2 || TARGET_POWERPC) && TARGET_HARD_FLOAT && TARGET_FPRS"
1fd4e8c1
RK
5140 "
5141{
802a0058 5142 operands[2] = gen_reg_rtx (DImode);
9ebbca7d 5143 operands[3] = assign_stack_temp (DImode, GET_MODE_SIZE (DImode), 0);
1fd4e8c1
RK
5144}")
5145
802a0058
MM
5146(define_insn "*fix_truncdfsi2_internal"
5147 [(set (match_operand:SI 0 "gpc_reg_operand" "=r")
5148 (fix:SI (match_operand:DF 1 "gpc_reg_operand" "f")))
e3485bbc 5149 (clobber (match_operand:DI 2 "gpc_reg_operand" "=f"))
9ebbca7d 5150 (clobber (match_operand:DI 3 "memory_operand" "=o"))]
a3170dc6 5151 "(TARGET_POWER2 || TARGET_POWERPC) && TARGET_HARD_FLOAT && TARGET_FPRS"
802a0058 5152 "#"
9ebbca7d 5153 [(set_attr "length" "16")])
802a0058
MM
5154
5155(define_split
5156 [(set (match_operand:SI 0 "gpc_reg_operand" "")
75540af0 5157 (fix:SI (match_operand:DF 1 "gpc_reg_operand" "")))
802a0058 5158 (clobber (match_operand:DI 2 "gpc_reg_operand" ""))
9ebbca7d 5159 (clobber (match_operand:DI 3 "offsettable_mem_operand" ""))]
a3170dc6 5160 "(TARGET_POWER2 || TARGET_POWERPC) && TARGET_HARD_FLOAT && TARGET_FPRS"
9ebbca7d 5161 [(set (match_operand:SI 0 "gpc_reg_operand" "")
75540af0 5162 (fix:SI (match_operand:DF 1 "gpc_reg_operand" "")))
9ebbca7d
GK
5163 (clobber (match_operand:DI 2 "gpc_reg_operand" ""))
5164 (clobber (match_operand:DI 3 "offsettable_mem_operand" ""))]
5165 "
802a0058 5166{
9ebbca7d
GK
5167 rtx lowword;
5168 if (GET_CODE (operands[3]) != MEM)
5169 abort();
5170 lowword = XEXP (operands[3], 0);
5171 if (WORDS_BIG_ENDIAN)
5172 lowword = plus_constant (lowword, 4);
802a0058 5173
9ebbca7d
GK
5174 emit_insn (gen_fctiwz (operands[2], operands[1]));
5175 emit_move_insn (operands[3], operands[2]);
5176 emit_move_insn (operands[0], gen_rtx_MEM (SImode, lowword));
5177 DONE;
5178}")
802a0058 5179
615158e2 5180; Here, we use (set (reg) (unspec:DI [(fix:SI ...)] UNSPEC_FCTIWZ))
9ebbca7d
GK
5181; rather than (set (subreg:SI (reg)) (fix:SI ...))
5182; because the first makes it clear that operand 0 is not live
5183; before the instruction.
5184(define_insn "fctiwz"
61c07d3c 5185 [(set (match_operand:DI 0 "gpc_reg_operand" "=*f")
615158e2
JJ
5186 (unspec:DI [(fix:SI (match_operand:DF 1 "gpc_reg_operand" "f"))]
5187 UNSPEC_FCTIWZ))]
a3170dc6 5188 "(TARGET_POWER2 || TARGET_POWERPC) && TARGET_HARD_FLOAT && TARGET_FPRS"
a260abc9
DE
5189 "{fcirz|fctiwz} %0,%1"
5190 [(set_attr "type" "fp")])
5191
a3170dc6
AH
5192(define_expand "floatsisf2"
5193 [(set (match_operand:SF 0 "gpc_reg_operand" "")
5194 (float:SF (match_operand:SI 1 "gpc_reg_operand" "")))]
5195 "TARGET_HARD_FLOAT && !TARGET_FPRS"
5196 "")
5197
a473029f
RK
5198(define_insn "floatdidf2"
5199 [(set (match_operand:DF 0 "gpc_reg_operand" "=f")
61c07d3c 5200 (float:DF (match_operand:DI 1 "gpc_reg_operand" "*f")))]
a3170dc6 5201 "TARGET_POWERPC64 && TARGET_HARD_FLOAT && TARGET_FPRS"
a473029f
RK
5202 "fcfid %0,%1"
5203 [(set_attr "type" "fp")])
5204
05d49501
AM
5205(define_insn_and_split "floatsidf_ppc64"
5206 [(set (match_operand:DF 0 "gpc_reg_operand" "=f")
5207 (float:DF (match_operand:SI 1 "gpc_reg_operand" "r")))
5208 (clobber (match_operand:DI 2 "memory_operand" "=o"))
5209 (clobber (match_operand:DI 3 "gpc_reg_operand" "=r"))
5210 (clobber (match_operand:DI 4 "gpc_reg_operand" "=f"))]
a3170dc6 5211 "TARGET_POWERPC64 && TARGET_HARD_FLOAT && TARGET_FPRS"
05d49501
AM
5212 "#"
5213 ""
5214 [(set (match_dup 3) (sign_extend:DI (match_dup 1)))
5215 (set (match_dup 2) (match_dup 3))
5216 (set (match_dup 4) (match_dup 2))
5217 (set (match_dup 0) (float:DF (match_dup 4)))]
5218 "")
5219
5220(define_insn_and_split "floatunssidf_ppc64"
5221 [(set (match_operand:DF 0 "gpc_reg_operand" "=f")
5222 (unsigned_float:DF (match_operand:SI 1 "gpc_reg_operand" "r")))
5223 (clobber (match_operand:DI 2 "memory_operand" "=o"))
5224 (clobber (match_operand:DI 3 "gpc_reg_operand" "=r"))
5225 (clobber (match_operand:DI 4 "gpc_reg_operand" "=f"))]
a3170dc6 5226 "TARGET_POWERPC64 && TARGET_HARD_FLOAT && TARGET_FPRS"
05d49501
AM
5227 "#"
5228 ""
5229 [(set (match_dup 3) (zero_extend:DI (match_dup 1)))
5230 (set (match_dup 2) (match_dup 3))
5231 (set (match_dup 4) (match_dup 2))
5232 (set (match_dup 0) (float:DF (match_dup 4)))]
5233 "")
5234
a473029f 5235(define_insn "fix_truncdfdi2"
61c07d3c 5236 [(set (match_operand:DI 0 "gpc_reg_operand" "=*f")
a473029f 5237 (fix:DI (match_operand:DF 1 "gpc_reg_operand" "f")))]
a3170dc6 5238 "TARGET_POWERPC64 && TARGET_HARD_FLOAT && TARGET_FPRS"
a473029f
RK
5239 "fctidz %0,%1"
5240 [(set_attr "type" "fp")])
ea112fc4 5241
678b7733
AM
5242(define_expand "floatdisf2"
5243 [(set (match_operand:SF 0 "gpc_reg_operand" "")
5244 (float:SF (match_operand:DI 1 "gpc_reg_operand" "")))]
683bdff7 5245 "TARGET_64BIT && TARGET_HARD_FLOAT && TARGET_FPRS"
678b7733
AM
5246 "
5247{
5248 if (!flag_unsafe_math_optimizations)
5249 {
5250 rtx label = gen_label_rtx ();
5251 emit_insn (gen_floatdisf2_internal2 (operands[1], label));
5252 emit_label (label);
5253 }
5254 emit_insn (gen_floatdisf2_internal1 (operands[0], operands[1]));
5255 DONE;
5256}")
5257
5258;; This is not IEEE compliant if rounding mode is "round to nearest".
5259;; If the DI->DF conversion is inexact, then it's possible to suffer
5260;; from double rounding.
5261(define_insn_and_split "floatdisf2_internal1"
ea112fc4 5262 [(set (match_operand:SF 0 "gpc_reg_operand" "=f")
61c07d3c 5263 (float:SF (match_operand:DI 1 "gpc_reg_operand" "*f")))
ea112fc4 5264 (clobber (match_scratch:DF 2 "=f"))]
678b7733 5265 "TARGET_POWERPC64 && TARGET_HARD_FLOAT && TARGET_FPRS"
ea112fc4
DE
5266 "#"
5267 "&& reload_completed"
5268 [(set (match_dup 2)
5269 (float:DF (match_dup 1)))
5270 (set (match_dup 0)
5271 (float_truncate:SF (match_dup 2)))]
5272 "")
678b7733
AM
5273
5274;; Twiddles bits to avoid double rounding.
b6d08ca1 5275;; Bits that might be truncated when converting to DFmode are replaced
678b7733
AM
5276;; by a bit that won't be lost at that stage, but is below the SFmode
5277;; rounding position.
5278(define_expand "floatdisf2_internal2"
42a6388c
AM
5279 [(parallel [(set (match_dup 4)
5280 (compare:CC (and:DI (match_operand:DI 0 "" "")
5281 (const_int 2047))
5282 (const_int 0)))
5283 (set (match_dup 2) (and:DI (match_dup 0) (const_int 2047)))
5284 (clobber (match_scratch:CC 7 ""))])
678b7733
AM
5285 (set (match_dup 3) (ashiftrt:DI (match_dup 0) (const_int 53)))
5286 (set (match_dup 3) (plus:DI (match_dup 3) (const_int 1)))
5287 (set (pc) (if_then_else (eq (match_dup 4) (const_int 0))
5288 (label_ref (match_operand:DI 1 "" ""))
5289 (pc)))
5290 (set (match_dup 5) (compare:CCUNS (match_dup 3) (const_int 2)))
5291 (set (pc) (if_then_else (ltu (match_dup 5) (const_int 0))
5292 (label_ref (match_dup 1))
5293 (pc)))
5294 (set (match_dup 0) (xor:DI (match_dup 0) (match_dup 2)))
5295 (set (match_dup 0) (ior:DI (match_dup 0) (const_int 2048)))]
683bdff7 5296 "TARGET_64BIT && TARGET_HARD_FLOAT && TARGET_FPRS"
678b7733
AM
5297 "
5298{
5299 operands[2] = gen_reg_rtx (DImode);
5300 operands[3] = gen_reg_rtx (DImode);
5301 operands[4] = gen_reg_rtx (CCmode);
5302 operands[5] = gen_reg_rtx (CCUNSmode);
5303}")
1fd4e8c1
RK
5304\f
5305;; Define the DImode operations that can be done in a small number
a6ec530c
RK
5306;; of instructions. The & constraints are to prevent the register
5307;; allocator from allocating registers that overlap with the inputs
5308;; (for example, having an input in 7,8 and an output in 6,7). We
38e01259 5309;; also allow for the output being the same as one of the inputs.
a6ec530c 5310
266eb58a 5311(define_insn "*adddi3_noppc64"
a6ec530c
RK
5312 [(set (match_operand:DI 0 "gpc_reg_operand" "=&r,&r,r,r")
5313 (plus:DI (match_operand:DI 1 "gpc_reg_operand" "%r,r,0,0")
5314 (match_operand:DI 2 "reg_or_short_operand" "r,I,r,I")))]
e1f83b4d 5315 "! TARGET_POWERPC64"
0f645302
MM
5316 "*
5317{
5318 if (WORDS_BIG_ENDIAN)
5319 return (GET_CODE (operands[2])) != CONST_INT
5320 ? \"{a|addc} %L0,%L1,%L2\;{ae|adde} %0,%1,%2\"
5321 : \"{ai|addic} %L0,%L1,%2\;{a%G2e|add%G2e} %0,%1\";
5322 else
5323 return (GET_CODE (operands[2])) != CONST_INT
5324 ? \"{a|addc} %0,%1,%2\;{ae|adde} %L0,%L1,%L2\"
5325 : \"{ai|addic} %0,%1,%2\;{a%G2e|add%G2e} %L0,%L1\";
5326}"
b19003d8 5327 [(set_attr "length" "8")])
1fd4e8c1 5328
266eb58a 5329(define_insn "*subdi3_noppc64"
e7e5df70
RK
5330 [(set (match_operand:DI 0 "gpc_reg_operand" "=&r,&r,r,r,r")
5331 (minus:DI (match_operand:DI 1 "reg_or_short_operand" "r,I,0,r,I")
5332 (match_operand:DI 2 "gpc_reg_operand" "r,r,r,0,0")))]
266eb58a 5333 "! TARGET_POWERPC64"
5502823b
RK
5334 "*
5335{
0f645302
MM
5336 if (WORDS_BIG_ENDIAN)
5337 return (GET_CODE (operands[1]) != CONST_INT)
5338 ? \"{sf|subfc} %L0,%L2,%L1\;{sfe|subfe} %0,%2,%1\"
5339 : \"{sfi|subfic} %L0,%L2,%1\;{sf%G1e|subf%G1e} %0,%2\";
5340 else
5341 return (GET_CODE (operands[1]) != CONST_INT)
5342 ? \"{sf|subfc} %0,%2,%1\;{sfe|subfe} %L0,%L2,%L1\"
5343 : \"{sfi|subfic} %0,%2,%1\;{sf%G1e|subf%G1e} %L0,%L2\";
5502823b 5344}"
ca7f5001
RK
5345 [(set_attr "length" "8")])
5346
266eb58a 5347(define_insn "*negdi2_noppc64"
a6ec530c
RK
5348 [(set (match_operand:DI 0 "gpc_reg_operand" "=&r,r")
5349 (neg:DI (match_operand:DI 1 "gpc_reg_operand" "r,0")))]
51b8fc2c 5350 "! TARGET_POWERPC64"
5502823b
RK
5351 "*
5352{
5353 return (WORDS_BIG_ENDIAN)
5354 ? \"{sfi|subfic} %L0,%L1,0\;{sfze|subfze} %0,%1\"
5355 : \"{sfi|subfic} %0,%1,0\;{sfze|subfze} %L0,%L1\";
5356}"
ca7f5001
RK
5357 [(set_attr "length" "8")])
5358
8ffd9c51
RK
5359(define_expand "mulsidi3"
5360 [(set (match_operand:DI 0 "gpc_reg_operand" "")
5361 (mult:DI (sign_extend:DI (match_operand:SI 1 "gpc_reg_operand" ""))
5362 (sign_extend:DI (match_operand:SI 2 "gpc_reg_operand" ""))))]
a2f270cc 5363 "! TARGET_POWERPC64"
8ffd9c51
RK
5364 "
5365{
5366 if (! TARGET_POWER && ! TARGET_POWERPC)
5367 {
39403d82
DE
5368 emit_move_insn (gen_rtx_REG (SImode, 3), operands[1]);
5369 emit_move_insn (gen_rtx_REG (SImode, 4), operands[2]);
fada905b 5370 emit_insn (gen_mull_call ());
cf27b467 5371 if (WORDS_BIG_ENDIAN)
39403d82 5372 emit_move_insn (operands[0], gen_rtx_REG (DImode, 3));
cf27b467
MM
5373 else
5374 {
5375 emit_move_insn (operand_subword (operands[0], 0, 0, DImode),
39403d82 5376 gen_rtx_REG (SImode, 3));
cf27b467 5377 emit_move_insn (operand_subword (operands[0], 1, 0, DImode),
39403d82 5378 gen_rtx_REG (SImode, 4));
cf27b467 5379 }
8ffd9c51
RK
5380 DONE;
5381 }
5382 else if (TARGET_POWER)
5383 {
5384 emit_insn (gen_mulsidi3_mq (operands[0], operands[1], operands[2]));
5385 DONE;
5386 }
5387}")
deb9225a 5388
8ffd9c51 5389(define_insn "mulsidi3_mq"
cd2b37d9 5390 [(set (match_operand:DI 0 "gpc_reg_operand" "=r")
8ffd9c51 5391 (mult:DI (sign_extend:DI (match_operand:SI 1 "gpc_reg_operand" "%r"))
cd2b37d9 5392 (sign_extend:DI (match_operand:SI 2 "gpc_reg_operand" "r"))))
1fd4e8c1 5393 (clobber (match_scratch:SI 3 "=q"))]
ca7f5001 5394 "TARGET_POWER"
b19003d8 5395 "mul %0,%1,%2\;mfmq %L0"
8ffd9c51
RK
5396 [(set_attr "type" "imul")
5397 (set_attr "length" "8")])
deb9225a 5398
f192bf8b 5399(define_insn "*mulsidi3_no_mq"
425c176f 5400 [(set (match_operand:DI 0 "gpc_reg_operand" "=&r")
8ffd9c51
RK
5401 (mult:DI (sign_extend:DI (match_operand:SI 1 "gpc_reg_operand" "%r"))
5402 (sign_extend:DI (match_operand:SI 2 "gpc_reg_operand" "r"))))]
f192bf8b 5403 "TARGET_POWERPC && ! TARGET_POWER && ! TARGET_POWERPC64"
5502823b
RK
5404 "*
5405{
5406 return (WORDS_BIG_ENDIAN)
5407 ? \"mulhw %0,%1,%2\;mullw %L0,%1,%2\"
5408 : \"mulhw %L0,%1,%2\;mullw %0,%1,%2\";
5409}"
8ffd9c51
RK
5410 [(set_attr "type" "imul")
5411 (set_attr "length" "8")])
deb9225a 5412
ebedb4dd
MM
5413(define_split
5414 [(set (match_operand:DI 0 "gpc_reg_operand" "")
5415 (mult:DI (sign_extend:DI (match_operand:SI 1 "gpc_reg_operand" ""))
5416 (sign_extend:DI (match_operand:SI 2 "gpc_reg_operand" ""))))]
cf27b467 5417 "TARGET_POWERPC && ! TARGET_POWERPC64 && reload_completed"
ebedb4dd
MM
5418 [(set (match_dup 3)
5419 (truncate:SI
5420 (lshiftrt:DI (mult:DI (sign_extend:DI (match_dup 1))
5421 (sign_extend:DI (match_dup 2)))
5422 (const_int 32))))
5423 (set (match_dup 4)
5424 (mult:SI (match_dup 1)
5425 (match_dup 2)))]
5426 "
5427{
5428 int endian = (WORDS_BIG_ENDIAN == 0);
5429 operands[3] = operand_subword (operands[0], endian, 0, DImode);
5430 operands[4] = operand_subword (operands[0], 1 - endian, 0, DImode);
5431}")
5432
f192bf8b
DE
5433(define_expand "umulsidi3"
5434 [(set (match_operand:DI 0 "gpc_reg_operand" "")
5435 (mult:DI (zero_extend:DI (match_operand:SI 1 "gpc_reg_operand" ""))
5436 (zero_extend:DI (match_operand:SI 2 "gpc_reg_operand" ""))))]
5437 "TARGET_POWERPC && ! TARGET_POWERPC64"
5438 "
5439{
5440 if (TARGET_POWER)
5441 {
5442 emit_insn (gen_umulsidi3_mq (operands[0], operands[1], operands[2]));
5443 DONE;
5444 }
5445}")
5446
5447(define_insn "umulsidi3_mq"
5448 [(set (match_operand:DI 0 "gpc_reg_operand" "=&r")
5449 (mult:DI (zero_extend:DI (match_operand:SI 1 "gpc_reg_operand" "%r"))
5450 (zero_extend:DI (match_operand:SI 2 "gpc_reg_operand" "r"))))
5451 (clobber (match_scratch:SI 3 "=q"))]
5452 "TARGET_POWERPC && TARGET_POWER"
5453 "*
5454{
5455 return (WORDS_BIG_ENDIAN)
5456 ? \"mulhwu %0,%1,%2\;mullw %L0,%1,%2\"
5457 : \"mulhwu %L0,%1,%2\;mullw %0,%1,%2\";
5458}"
5459 [(set_attr "type" "imul")
5460 (set_attr "length" "8")])
5461
5462(define_insn "*umulsidi3_no_mq"
8106dc08
MM
5463 [(set (match_operand:DI 0 "gpc_reg_operand" "=&r")
5464 (mult:DI (zero_extend:DI (match_operand:SI 1 "gpc_reg_operand" "%r"))
5465 (zero_extend:DI (match_operand:SI 2 "gpc_reg_operand" "r"))))]
f192bf8b 5466 "TARGET_POWERPC && ! TARGET_POWER && ! TARGET_POWERPC64"
8106dc08
MM
5467 "*
5468{
5469 return (WORDS_BIG_ENDIAN)
5470 ? \"mulhwu %0,%1,%2\;mullw %L0,%1,%2\"
5471 : \"mulhwu %L0,%1,%2\;mullw %0,%1,%2\";
5472}"
5473 [(set_attr "type" "imul")
5474 (set_attr "length" "8")])
5475
ebedb4dd
MM
5476(define_split
5477 [(set (match_operand:DI 0 "gpc_reg_operand" "")
5478 (mult:DI (zero_extend:DI (match_operand:SI 1 "gpc_reg_operand" ""))
5479 (zero_extend:DI (match_operand:SI 2 "gpc_reg_operand" ""))))]
cf27b467 5480 "TARGET_POWERPC && ! TARGET_POWERPC64 && reload_completed"
ebedb4dd
MM
5481 [(set (match_dup 3)
5482 (truncate:SI
5483 (lshiftrt:DI (mult:DI (zero_extend:DI (match_dup 1))
5484 (zero_extend:DI (match_dup 2)))
5485 (const_int 32))))
5486 (set (match_dup 4)
5487 (mult:SI (match_dup 1)
5488 (match_dup 2)))]
5489 "
5490{
5491 int endian = (WORDS_BIG_ENDIAN == 0);
5492 operands[3] = operand_subword (operands[0], endian, 0, DImode);
5493 operands[4] = operand_subword (operands[0], 1 - endian, 0, DImode);
5494}")
5495
8ffd9c51
RK
5496(define_expand "smulsi3_highpart"
5497 [(set (match_operand:SI 0 "gpc_reg_operand" "")
5498 (truncate:SI
5499 (lshiftrt:DI (mult:DI (sign_extend:DI
5500 (match_operand:SI 1 "gpc_reg_operand" "%r"))
5501 (sign_extend:DI
5502 (match_operand:SI 2 "gpc_reg_operand" "r")))
5503 (const_int 32))))]
5504 ""
5505 "
5506{
5507 if (! TARGET_POWER && ! TARGET_POWERPC)
5508 {
39403d82
DE
5509 emit_move_insn (gen_rtx_REG (SImode, 3), operands[1]);
5510 emit_move_insn (gen_rtx_REG (SImode, 4), operands[2]);
fada905b 5511 emit_insn (gen_mulh_call ());
39403d82 5512 emit_move_insn (operands[0], gen_rtx_REG (SImode, 3));
8ffd9c51
RK
5513 DONE;
5514 }
5515 else if (TARGET_POWER)
5516 {
5517 emit_insn (gen_smulsi3_highpart_mq (operands[0], operands[1], operands[2]));
5518 DONE;
5519 }
5520}")
deb9225a 5521
8ffd9c51
RK
5522(define_insn "smulsi3_highpart_mq"
5523 [(set (match_operand:SI 0 "gpc_reg_operand" "=r")
5524 (truncate:SI
fada905b
MM
5525 (lshiftrt:DI (mult:DI (sign_extend:DI
5526 (match_operand:SI 1 "gpc_reg_operand" "%r"))
5527 (sign_extend:DI
5528 (match_operand:SI 2 "gpc_reg_operand" "r")))
8ffd9c51
RK
5529 (const_int 32))))
5530 (clobber (match_scratch:SI 3 "=q"))]
5531 "TARGET_POWER"
5532 "mul %0,%1,%2"
5533 [(set_attr "type" "imul")])
deb9225a 5534
f192bf8b 5535(define_insn "*smulsi3_highpart_no_mq"
8ffd9c51
RK
5536 [(set (match_operand:SI 0 "gpc_reg_operand" "=r")
5537 (truncate:SI
fada905b
MM
5538 (lshiftrt:DI (mult:DI (sign_extend:DI
5539 (match_operand:SI 1 "gpc_reg_operand" "%r"))
5540 (sign_extend:DI
5541 (match_operand:SI 2 "gpc_reg_operand" "r")))
8ffd9c51 5542 (const_int 32))))]
f192bf8b 5543 "TARGET_POWERPC && ! TARGET_POWER"
8ffd9c51
RK
5544 "mulhw %0,%1,%2"
5545 [(set_attr "type" "imul")])
deb9225a 5546
f192bf8b
DE
5547(define_expand "umulsi3_highpart"
5548 [(set (match_operand:SI 0 "gpc_reg_operand" "")
5549 (truncate:SI
5550 (lshiftrt:DI (mult:DI (zero_extend:DI
5551 (match_operand:SI 1 "gpc_reg_operand" ""))
5552 (zero_extend:DI
5553 (match_operand:SI 2 "gpc_reg_operand" "")))
5554 (const_int 32))))]
5555 "TARGET_POWERPC"
5556 "
5557{
5558 if (TARGET_POWER)
5559 {
5560 emit_insn (gen_umulsi3_highpart_mq (operands[0], operands[1], operands[2]));
5561 DONE;
5562 }
5563}")
5564
5565(define_insn "umulsi3_highpart_mq"
5566 [(set (match_operand:SI 0 "gpc_reg_operand" "=r")
5567 (truncate:SI
5568 (lshiftrt:DI (mult:DI (zero_extend:DI
5569 (match_operand:SI 1 "gpc_reg_operand" "%r"))
5570 (zero_extend:DI
5571 (match_operand:SI 2 "gpc_reg_operand" "r")))
5572 (const_int 32))))
5573 (clobber (match_scratch:SI 3 "=q"))]
5574 "TARGET_POWERPC && TARGET_POWER"
5575 "mulhwu %0,%1,%2"
5576 [(set_attr "type" "imul")])
5577
5578(define_insn "*umulsi3_highpart_no_mq"
266eb58a
DE
5579 [(set (match_operand:SI 0 "gpc_reg_operand" "=r")
5580 (truncate:SI
5581 (lshiftrt:DI (mult:DI (zero_extend:DI
5582 (match_operand:SI 1 "gpc_reg_operand" "%r"))
5583 (zero_extend:DI
5584 (match_operand:SI 2 "gpc_reg_operand" "r")))
5585 (const_int 32))))]
f192bf8b 5586 "TARGET_POWERPC && ! TARGET_POWER"
266eb58a
DE
5587 "mulhwu %0,%1,%2"
5588 [(set_attr "type" "imul")])
5589
5590;; If operands 0 and 2 are in the same register, we have a problem. But
5591;; operands 0 and 1 (the usual case) can be in the same register. That's
5592;; why we have the strange constraints below.
5593(define_insn "ashldi3_power"
5594 [(set (match_operand:DI 0 "gpc_reg_operand" "=r,r,r,&r")
5595 (ashift:DI (match_operand:DI 1 "gpc_reg_operand" "r,r,0,r")
5596 (match_operand:SI 2 "reg_or_cint_operand" "M,i,r,r")))
5597 (clobber (match_scratch:SI 3 "=X,q,q,q"))]
5598 "TARGET_POWER"
5599 "@
5600 {sli|slwi} %0,%L1,%h2\;{cal %L0,0(0)|li %L0,0}
5601 sl%I2q %L0,%L1,%h2\;sll%I2q %0,%1,%h2
5602 sl%I2q %L0,%L1,%h2\;sll%I2q %0,%1,%h2
5603 sl%I2q %L0,%L1,%h2\;sll%I2q %0,%1,%h2"
5604 [(set_attr "length" "8")])
5605
5606(define_insn "lshrdi3_power"
47ad8c61 5607 [(set (match_operand:DI 0 "gpc_reg_operand" "=r,r,r,&r")
266eb58a
DE
5608 (lshiftrt:DI (match_operand:DI 1 "gpc_reg_operand" "r,r,0,r")
5609 (match_operand:SI 2 "reg_or_cint_operand" "M,i,r,r")))
5610 (clobber (match_scratch:SI 3 "=X,q,q,q"))]
5611 "TARGET_POWER"
5612 "@
47ad8c61 5613 {s%A2i|s%A2wi} %L0,%1,%h2\;{cal %0,0(0)|li %0,0}
266eb58a
DE
5614 sr%I2q %0,%1,%h2\;srl%I2q %L0,%L1,%h2
5615 sr%I2q %0,%1,%h2\;srl%I2q %L0,%L1,%h2
5616 sr%I2q %0,%1,%h2\;srl%I2q %L0,%L1,%h2"
5617 [(set_attr "length" "8")])
5618
5619;; Shift by a variable amount is too complex to be worth open-coding. We
5620;; just handle shifts by constants.
5621(define_insn "ashrdi3_power"
7093ddee 5622 [(set (match_operand:DI 0 "gpc_reg_operand" "=&r,r")
266eb58a
DE
5623 (ashiftrt:DI (match_operand:DI 1 "gpc_reg_operand" "r,r")
5624 (match_operand:SI 2 "const_int_operand" "M,i")))
5625 (clobber (match_scratch:SI 3 "=X,q"))]
5626 "TARGET_POWER"
5627 "@
5628 {srai|srawi} %0,%1,31\;{srai|srawi} %L0,%1,%h2
5629 sraiq %0,%1,%h2\;srliq %L0,%L1,%h2"
5630 [(set_attr "length" "8")])
4aa74a4f
FS
5631
5632(define_insn "ashrdi3_no_power"
5633 [(set (match_operand:DI 0 "gpc_reg_operand" "=&r,&r")
5634 (ashiftrt:DI (match_operand:DI 1 "gpc_reg_operand" "r,r")
5635 (match_operand:SI 2 "const_int_operand" "M,i")))]
683bdff7 5636 "TARGET_32BIT && !TARGET_POWERPC64 && !TARGET_POWER"
4aa74a4f
FS
5637 "@
5638 {srai|srawi} %0,%1,31\;{srai|srawi} %L0,%1,%h2
5639 {sri|srwi} %L0,%L1,%h2\;insrwi %L0,%1,%h2,0\;{srai|srawi} %0,%1,%h2"
5640 [(set_attr "length" "8,12")])
683bdff7
FJ
5641
5642(define_insn "*ashrdisi3_noppc64"
5643 [(set (match_operand:SI 0 "gpc_reg_operand" "=r")
5644 (subreg:SI (ashiftrt:DI (match_operand:DI 1 "gpc_reg_operand" "r")
5645 (const_int 32)) 4))]
5646 "TARGET_32BIT && !TARGET_POWERPC64"
5647 "*
5648{
5649 if (REGNO (operands[0]) == REGNO (operands[1]))
5650 return \"\";
5651 else
5652 return \"mr %0,%1\";
5653}"
5654 [(set_attr "length" "4")])
5655
266eb58a
DE
5656\f
5657;; PowerPC64 DImode operations.
5658
5659(define_expand "adddi3"
5660 [(set (match_operand:DI 0 "gpc_reg_operand" "")
5661 (plus:DI (match_operand:DI 1 "gpc_reg_operand" "")
2bfcf297 5662 (match_operand:DI 2 "reg_or_add_cint64_operand" "")))]
266eb58a
DE
5663 ""
5664 "
5665{
a260abc9
DE
5666 if (! TARGET_POWERPC64)
5667 {
5668 if (non_short_cint_operand (operands[2], DImode))
5669 FAIL;
5670 }
5671 else
5672 if (GET_CODE (operands[2]) == CONST_INT
677a9668 5673 && ! add_operand (operands[2], DImode))
a260abc9 5674 {
677a9668 5675 rtx tmp = ((no_new_pseudos || rtx_equal_p (operands[0], operands[1]))
a260abc9
DE
5676 ? operands[0] : gen_reg_rtx (DImode));
5677
2bfcf297 5678 HOST_WIDE_INT val = INTVAL (operands[2]);
a65c591c 5679 HOST_WIDE_INT low = ((val & 0xffff) ^ 0x8000) - 0x8000;
2bfcf297 5680 HOST_WIDE_INT rest = trunc_int_for_mode (val - low, DImode);
a260abc9 5681
2bfcf297
DB
5682 if (!CONST_OK_FOR_LETTER_P (rest, 'L'))
5683 FAIL;
a260abc9 5684
2bfcf297
DB
5685 /* The ordering here is important for the prolog expander.
5686 When space is allocated from the stack, adding 'low' first may
5687 produce a temporary deallocation (which would be bad). */
5688 emit_insn (gen_adddi3 (tmp, operands[1], GEN_INT (rest)));
a260abc9
DE
5689 emit_insn (gen_adddi3 (operands[0], tmp, GEN_INT (low)));
5690 DONE;
5691 }
266eb58a
DE
5692}")
5693
5694;; Discourage ai/addic because of carry but provide it in an alternative
5695;; allowing register zero as source.
5696
a260abc9 5697(define_insn "*adddi3_internal1"
266eb58a
DE
5698 [(set (match_operand:DI 0 "gpc_reg_operand" "=r,r,?r,r")
5699 (plus:DI (match_operand:DI 1 "gpc_reg_operand" "%r,b,r,b")
9615f239 5700 (match_operand:DI 2 "add_operand" "r,I,I,L")))]
266eb58a
DE
5701 "TARGET_POWERPC64"
5702 "@
5703 add %0,%1,%2
5704 addi %0,%1,%2
5705 addic %0,%1,%2
802a0058 5706 addis %0,%1,%v2")
266eb58a 5707
a260abc9 5708(define_insn "*adddi3_internal2"
9ebbca7d
GK
5709 [(set (match_operand:CC 0 "cc_reg_operand" "=x,x,?y,?y")
5710 (compare:CC (plus:DI (match_operand:DI 1 "gpc_reg_operand" "%r,r,r,r")
5711 (match_operand:DI 2 "reg_or_short_operand" "r,I,r,I"))
266eb58a 5712 (const_int 0)))
9ebbca7d 5713 (clobber (match_scratch:DI 3 "=r,r,r,r"))]
683bdff7 5714 "TARGET_64BIT"
266eb58a
DE
5715 "@
5716 add. %3,%1,%2
9ebbca7d
GK
5717 addic. %3,%1,%2
5718 #
5719 #"
a62bfff2 5720 [(set_attr "type" "fast_compare,compare,compare,compare")
9ebbca7d
GK
5721 (set_attr "length" "4,4,8,8")])
5722
5723(define_split
5724 [(set (match_operand:CC 0 "cc_reg_not_cr0_operand" "")
5725 (compare:CC (plus:DI (match_operand:DI 1 "gpc_reg_operand" "")
5726 (match_operand:DI 2 "reg_or_short_operand" ""))
5727 (const_int 0)))
5728 (clobber (match_scratch:DI 3 ""))]
5729 "TARGET_POWERPC64 && reload_completed"
5730 [(set (match_dup 3)
5731 (plus:DI (match_dup 1) (match_dup 2)))
5732 (set (match_dup 0)
5733 (compare:CC (match_dup 3)
5734 (const_int 0)))]
5735 "")
266eb58a 5736
a260abc9 5737(define_insn "*adddi3_internal3"
9ebbca7d
GK
5738 [(set (match_operand:CC 3 "cc_reg_operand" "=x,x,?y,?y")
5739 (compare:CC (plus:DI (match_operand:DI 1 "gpc_reg_operand" "%r,r,r,r")
5740 (match_operand:DI 2 "reg_or_short_operand" "r,I,r,I"))
266eb58a 5741 (const_int 0)))
9ebbca7d 5742 (set (match_operand:DI 0 "gpc_reg_operand" "=r,r,r,r")
266eb58a 5743 (plus:DI (match_dup 1) (match_dup 2)))]
683bdff7 5744 "TARGET_64BIT"
266eb58a
DE
5745 "@
5746 add. %0,%1,%2
9ebbca7d
GK
5747 addic. %0,%1,%2
5748 #
5749 #"
a62bfff2 5750 [(set_attr "type" "fast_compare,compare,compare,compare")
9ebbca7d
GK
5751 (set_attr "length" "4,4,8,8")])
5752
5753(define_split
5754 [(set (match_operand:CC 3 "cc_reg_not_cr0_operand" "")
5755 (compare:CC (plus:DI (match_operand:DI 1 "gpc_reg_operand" "")
5756 (match_operand:DI 2 "reg_or_short_operand" ""))
5757 (const_int 0)))
5758 (set (match_operand:DI 0 "gpc_reg_operand" "")
5759 (plus:DI (match_dup 1) (match_dup 2)))]
5760 "TARGET_POWERPC64 && reload_completed"
5761 [(set (match_dup 0)
5762 (plus:DI (match_dup 1) (match_dup 2)))
5763 (set (match_dup 3)
5764 (compare:CC (match_dup 0)
5765 (const_int 0)))]
5766 "")
266eb58a
DE
5767
5768;; Split an add that we can't do in one insn into two insns, each of which
5769;; does one 16-bit part. This is used by combine. Note that the low-order
5770;; add should be last in case the result gets used in an address.
5771
5772(define_split
5773 [(set (match_operand:DI 0 "gpc_reg_operand" "")
5774 (plus:DI (match_operand:DI 1 "gpc_reg_operand" "")
5775 (match_operand:DI 2 "non_add_cint_operand" "")))]
5776 "TARGET_POWERPC64"
5777 [(set (match_dup 0) (plus:DI (match_dup 1) (match_dup 3)))
5778 (set (match_dup 0) (plus:DI (match_dup 0) (match_dup 4)))]
5779"
5780{
2bfcf297 5781 HOST_WIDE_INT val = INTVAL (operands[2]);
a65c591c 5782 HOST_WIDE_INT low = ((val & 0xffff) ^ 0x8000) - 0x8000;
2bfcf297 5783 HOST_WIDE_INT rest = trunc_int_for_mode (val - low, DImode);
266eb58a 5784
2bfcf297
DB
5785 operands[4] = GEN_INT (low);
5786 if (CONST_OK_FOR_LETTER_P (rest, 'L'))
5787 operands[3] = GEN_INT (rest);
5788 else if (! no_new_pseudos)
38886f37 5789 {
2bfcf297
DB
5790 operands[3] = gen_reg_rtx (DImode);
5791 emit_move_insn (operands[3], operands[2]);
5792 emit_insn (gen_adddi3 (operands[0], operands[1], operands[3]));
5793 DONE;
38886f37 5794 }
2bfcf297
DB
5795 else
5796 FAIL;
266eb58a
DE
5797}")
5798
5799(define_insn "one_cmpldi2"
5800 [(set (match_operand:DI 0 "gpc_reg_operand" "=r")
5801 (not:DI (match_operand:DI 1 "gpc_reg_operand" "r")))]
5802 "TARGET_POWERPC64"
5803 "nor %0,%1,%1")
5804
5805(define_insn ""
9ebbca7d
GK
5806 [(set (match_operand:CC 0 "cc_reg_operand" "=x,?y")
5807 (compare:CC (not:DI (match_operand:DI 1 "gpc_reg_operand" "r,r"))
266eb58a 5808 (const_int 0)))
9ebbca7d 5809 (clobber (match_scratch:DI 2 "=r,r"))]
683bdff7 5810 "TARGET_64BIT"
9ebbca7d
GK
5811 "@
5812 nor. %2,%1,%1
5813 #"
5814 [(set_attr "type" "compare")
5815 (set_attr "length" "4,8")])
5816
5817(define_split
5818 [(set (match_operand:CC 0 "cc_reg_not_cr0_operand" "")
5819 (compare:CC (not:DI (match_operand:DI 1 "gpc_reg_operand" ""))
5820 (const_int 0)))
5821 (clobber (match_scratch:DI 2 ""))]
5822 "TARGET_POWERPC64 && reload_completed"
5823 [(set (match_dup 2)
5824 (not:DI (match_dup 1)))
5825 (set (match_dup 0)
5826 (compare:CC (match_dup 2)
5827 (const_int 0)))]
5828 "")
266eb58a
DE
5829
5830(define_insn ""
9ebbca7d
GK
5831 [(set (match_operand:CC 2 "cc_reg_operand" "=x,?y")
5832 (compare:CC (not:DI (match_operand:DI 1 "gpc_reg_operand" "r,r"))
266eb58a 5833 (const_int 0)))
9ebbca7d 5834 (set (match_operand:DI 0 "gpc_reg_operand" "=r,r")
266eb58a 5835 (not:DI (match_dup 1)))]
683bdff7 5836 "TARGET_64BIT"
9ebbca7d
GK
5837 "@
5838 nor. %0,%1,%1
5839 #"
5840 [(set_attr "type" "compare")
5841 (set_attr "length" "4,8")])
5842
5843(define_split
5844 [(set (match_operand:CC 2 "cc_reg_not_cr0_operand" "")
5845 (compare:CC (not:DI (match_operand:DI 1 "gpc_reg_operand" ""))
5846 (const_int 0)))
5847 (set (match_operand:DI 0 "gpc_reg_operand" "")
5848 (not:DI (match_dup 1)))]
5849 "TARGET_POWERPC64 && reload_completed"
5850 [(set (match_dup 0)
5851 (not:DI (match_dup 1)))
5852 (set (match_dup 2)
5853 (compare:CC (match_dup 0)
5854 (const_int 0)))]
5855 "")
266eb58a
DE
5856
5857(define_insn ""
5858 [(set (match_operand:DI 0 "gpc_reg_operand" "=r,r")
5859 (minus:DI (match_operand:DI 1 "reg_or_short_operand" "r,I")
5860 (match_operand:DI 2 "gpc_reg_operand" "r,r")))]
5861 "TARGET_POWERPC64"
5862 "@
5863 subf %0,%2,%1
5864 subfic %0,%2,%1")
5865
5866(define_insn ""
9ebbca7d
GK
5867 [(set (match_operand:CC 0 "cc_reg_operand" "=x,?y")
5868 (compare:CC (minus:DI (match_operand:DI 1 "gpc_reg_operand" "r,r")
5869 (match_operand:DI 2 "gpc_reg_operand" "r,r"))
266eb58a 5870 (const_int 0)))
9ebbca7d 5871 (clobber (match_scratch:DI 3 "=r,r"))]
683bdff7 5872 "TARGET_64BIT"
9ebbca7d
GK
5873 "@
5874 subf. %3,%2,%1
5875 #"
a62bfff2 5876 [(set_attr "type" "fast_compare")
9ebbca7d
GK
5877 (set_attr "length" "4,8")])
5878
5879(define_split
5880 [(set (match_operand:CC 0 "cc_reg_not_cr0_operand" "")
5881 (compare:CC (minus:DI (match_operand:DI 1 "gpc_reg_operand" "")
5882 (match_operand:DI 2 "gpc_reg_operand" ""))
5883 (const_int 0)))
5884 (clobber (match_scratch:DI 3 ""))]
5885 "TARGET_POWERPC64 && reload_completed"
5886 [(set (match_dup 3)
5887 (minus:DI (match_dup 1) (match_dup 2)))
5888 (set (match_dup 0)
5889 (compare:CC (match_dup 3)
5890 (const_int 0)))]
5891 "")
266eb58a
DE
5892
5893(define_insn ""
9ebbca7d
GK
5894 [(set (match_operand:CC 3 "cc_reg_operand" "=x,?y")
5895 (compare:CC (minus:DI (match_operand:DI 1 "gpc_reg_operand" "r,r")
5896 (match_operand:DI 2 "gpc_reg_operand" "r,r"))
266eb58a 5897 (const_int 0)))
9ebbca7d 5898 (set (match_operand:DI 0 "gpc_reg_operand" "=r,r")
266eb58a 5899 (minus:DI (match_dup 1) (match_dup 2)))]
683bdff7 5900 "TARGET_64BIT"
9ebbca7d
GK
5901 "@
5902 subf. %0,%2,%1
5903 #"
a62bfff2 5904 [(set_attr "type" "fast_compare")
9ebbca7d
GK
5905 (set_attr "length" "4,8")])
5906
5907(define_split
5908 [(set (match_operand:CC 3 "cc_reg_not_cr0_operand" "")
5909 (compare:CC (minus:DI (match_operand:DI 1 "gpc_reg_operand" "")
5910 (match_operand:DI 2 "gpc_reg_operand" ""))
5911 (const_int 0)))
5912 (set (match_operand:DI 0 "gpc_reg_operand" "")
5913 (minus:DI (match_dup 1) (match_dup 2)))]
5914 "TARGET_POWERPC64 && reload_completed"
5915 [(set (match_dup 0)
5916 (minus:DI (match_dup 1) (match_dup 2)))
5917 (set (match_dup 3)
5918 (compare:CC (match_dup 0)
5919 (const_int 0)))]
5920 "")
266eb58a
DE
5921
5922(define_expand "subdi3"
5923 [(set (match_operand:DI 0 "gpc_reg_operand" "")
5924 (minus:DI (match_operand:DI 1 "reg_or_short_operand" "")
2bfcf297 5925 (match_operand:DI 2 "reg_or_sub_cint64_operand" "")))]
266eb58a
DE
5926 ""
5927 "
5928{
5929 if (GET_CODE (operands[2]) == CONST_INT)
5930 {
5931 emit_insn (gen_adddi3 (operands[0], operands[1],
5932 negate_rtx (DImode, operands[2])));
5933 DONE;
5934 }
5935}")
5936
ea112fc4 5937(define_insn_and_split "absdi2"
266eb58a 5938 [(set (match_operand:DI 0 "gpc_reg_operand" "=&r,r")
ea112fc4 5939 (abs:DI (match_operand:DI 1 "gpc_reg_operand" "r,0")))
266eb58a
DE
5940 (clobber (match_scratch:DI 2 "=&r,&r"))]
5941 "TARGET_POWERPC64"
ea112fc4
DE
5942 "#"
5943 "&& reload_completed"
a260abc9 5944 [(set (match_dup 2) (ashiftrt:DI (match_dup 1) (const_int 63)))
266eb58a 5945 (set (match_dup 0) (xor:DI (match_dup 2) (match_dup 1)))
a238cd8b 5946 (set (match_dup 0) (minus:DI (match_dup 0) (match_dup 2)))]
266eb58a
DE
5947 "")
5948
ea112fc4 5949(define_insn_and_split "*nabsdi2"
266eb58a 5950 [(set (match_operand:DI 0 "gpc_reg_operand" "=&r,r")
ea112fc4 5951 (neg:DI (abs:DI (match_operand:DI 1 "gpc_reg_operand" "r,0"))))
266eb58a
DE
5952 (clobber (match_scratch:DI 2 "=&r,&r"))]
5953 "TARGET_POWERPC64"
ea112fc4
DE
5954 "#"
5955 "&& reload_completed"
a260abc9 5956 [(set (match_dup 2) (ashiftrt:DI (match_dup 1) (const_int 63)))
266eb58a 5957 (set (match_dup 0) (xor:DI (match_dup 2) (match_dup 1)))
19ba8161 5958 (set (match_dup 0) (minus:DI (match_dup 2) (match_dup 0)))]
266eb58a
DE
5959 "")
5960
5961(define_expand "negdi2"
5962 [(set (match_operand:DI 0 "gpc_reg_operand" "")
5963 (neg:DI (match_operand:DI 1 "gpc_reg_operand" "")))]
5964 ""
5965 "")
5966
5967(define_insn ""
5968 [(set (match_operand:DI 0 "gpc_reg_operand" "=r")
5969 (neg:DI (match_operand:DI 1 "gpc_reg_operand" "r")))]
5970 "TARGET_POWERPC64"
5971 "neg %0,%1")
5972
5973(define_insn ""
9ebbca7d
GK
5974 [(set (match_operand:CC 0 "cc_reg_operand" "=x,?y")
5975 (compare:CC (neg:DI (match_operand:DI 1 "gpc_reg_operand" "r,r"))
266eb58a 5976 (const_int 0)))
9ebbca7d 5977 (clobber (match_scratch:DI 2 "=r,r"))]
683bdff7 5978 "TARGET_64BIT"
9ebbca7d
GK
5979 "@
5980 neg. %2,%1
5981 #"
a62bfff2 5982 [(set_attr "type" "fast_compare")
9ebbca7d
GK
5983 (set_attr "length" "4,8")])
5984
5985(define_split
5986 [(set (match_operand:CC 0 "cc_reg_not_cr0_operand" "")
5987 (compare:CC (neg:DI (match_operand:DI 1 "gpc_reg_operand" ""))
5988 (const_int 0)))
5989 (clobber (match_scratch:DI 2 ""))]
5990 "TARGET_POWERPC64 && reload_completed"
5991 [(set (match_dup 2)
5992 (neg:DI (match_dup 1)))
5993 (set (match_dup 0)
5994 (compare:CC (match_dup 2)
5995 (const_int 0)))]
5996 "")
815cdc52 5997
29ae5b89 5998(define_insn ""
9ebbca7d
GK
5999 [(set (match_operand:CC 2 "cc_reg_operand" "=x,?y")
6000 (compare:CC (neg:DI (match_operand:DI 1 "gpc_reg_operand" "r,r"))
815cdc52 6001 (const_int 0)))
9ebbca7d 6002 (set (match_operand:DI 0 "gpc_reg_operand" "=r,r")
815cdc52 6003 (neg:DI (match_dup 1)))]
683bdff7 6004 "TARGET_64BIT"
9ebbca7d
GK
6005 "@
6006 neg. %0,%1
6007 #"
a62bfff2 6008 [(set_attr "type" "fast_compare")
9ebbca7d
GK
6009 (set_attr "length" "4,8")])
6010
6011(define_split
6012 [(set (match_operand:CC 2 "cc_reg_not_cr0_operand" "")
6013 (compare:CC (neg:DI (match_operand:DI 1 "gpc_reg_operand" ""))
6014 (const_int 0)))
6015 (set (match_operand:DI 0 "gpc_reg_operand" "")
6016 (neg:DI (match_dup 1)))]
6017 "TARGET_POWERPC64 && reload_completed"
6018 [(set (match_dup 0)
6019 (neg:DI (match_dup 1)))
6020 (set (match_dup 2)
6021 (compare:CC (match_dup 0)
6022 (const_int 0)))]
6023 "")
266eb58a 6024
1b1edcfa
DE
6025(define_insn "clzdi2"
6026 [(set (match_operand:DI 0 "gpc_reg_operand" "=r")
6027 (clz:DI (match_operand:DI 1 "gpc_reg_operand" "r")))]
6028 "TARGET_POWERPC64"
6029 "cntlzd %0,%1")
6030
6031(define_expand "ctzdi2"
4977bab6 6032 [(set (match_dup 2)
1b1edcfa 6033 (neg:DI (match_operand:DI 1 "gpc_reg_operand" "r")))
4977bab6 6034 (parallel [(set (match_dup 3) (and:DI (match_dup 1)
1b1edcfa
DE
6035 (match_dup 2)))
6036 (clobber (scratch:CC))])
d865b122 6037 (set (match_dup 4) (clz:DI (match_dup 3)))
4977bab6 6038 (set (match_operand:DI 0 "gpc_reg_operand" "=r")
1b1edcfa 6039 (minus:DI (const_int 63) (match_dup 4)))]
266eb58a 6040 "TARGET_POWERPC64"
4977bab6
ZW
6041 {
6042 operands[2] = gen_reg_rtx (DImode);
6043 operands[3] = gen_reg_rtx (DImode);
6044 operands[4] = gen_reg_rtx (DImode);
6045 })
6046
1b1edcfa
DE
6047(define_expand "ffsdi2"
6048 [(set (match_dup 2)
6049 (neg:DI (match_operand:DI 1 "gpc_reg_operand" "r")))
6050 (parallel [(set (match_dup 3) (and:DI (match_dup 1)
6051 (match_dup 2)))
6052 (clobber (scratch:CC))])
6053 (set (match_dup 4) (clz:DI (match_dup 3)))
6054 (set (match_operand:DI 0 "gpc_reg_operand" "=r")
6055 (minus:DI (const_int 64) (match_dup 4)))]
4977bab6 6056 "TARGET_POWERPC64"
1b1edcfa
DE
6057 {
6058 operands[2] = gen_reg_rtx (DImode);
6059 operands[3] = gen_reg_rtx (DImode);
6060 operands[4] = gen_reg_rtx (DImode);
6061 })
266eb58a
DE
6062
6063(define_insn "muldi3"
6064 [(set (match_operand:DI 0 "gpc_reg_operand" "=r")
6065 (mult:DI (match_operand:DI 1 "gpc_reg_operand" "%r")
6066 (match_operand:DI 2 "gpc_reg_operand" "r")))]
6067 "TARGET_POWERPC64"
6068 "mulld %0,%1,%2"
3cb999d8 6069 [(set_attr "type" "lmul")])
266eb58a 6070
9259f3b0
DE
6071(define_insn "*muldi3_internal1"
6072 [(set (match_operand:CC 0 "cc_reg_operand" "=x,?y")
6073 (compare:CC (mult:DI (match_operand:DI 1 "gpc_reg_operand" "%r,r")
6074 (match_operand:DI 2 "gpc_reg_operand" "r,r"))
6075 (const_int 0)))
6076 (clobber (match_scratch:DI 3 "=r,r"))]
6077 "TARGET_POWERPC64"
6078 "@
6079 mulld. %3,%1,%2
6080 #"
6081 [(set_attr "type" "lmul_compare")
6082 (set_attr "length" "4,8")])
6083
6084(define_split
6085 [(set (match_operand:CC 0 "cc_reg_not_cr0_operand" "")
6086 (compare:CC (mult:DI (match_operand:DI 1 "gpc_reg_operand" "")
6087 (match_operand:DI 2 "gpc_reg_operand" ""))
6088 (const_int 0)))
6089 (clobber (match_scratch:DI 3 ""))]
6090 "TARGET_POWERPC64 && reload_completed"
6091 [(set (match_dup 3)
6092 (mult:DI (match_dup 1) (match_dup 2)))
6093 (set (match_dup 0)
6094 (compare:CC (match_dup 3)
6095 (const_int 0)))]
6096 "")
6097
6098(define_insn "*muldi3_internal2"
6099 [(set (match_operand:CC 3 "cc_reg_operand" "=x,?y")
6100 (compare:CC (mult:DI (match_operand:DI 1 "gpc_reg_operand" "%r,r")
6101 (match_operand:DI 2 "gpc_reg_operand" "r,r"))
6102 (const_int 0)))
6103 (set (match_operand:DI 0 "gpc_reg_operand" "=r,r")
6104 (mult:DI (match_dup 1) (match_dup 2)))]
6105 "TARGET_POWERPC64"
6106 "@
6107 mulld. %0,%1,%2
6108 #"
6109 [(set_attr "type" "lmul_compare")
6110 (set_attr "length" "4,8")])
6111
6112(define_split
6113 [(set (match_operand:CC 3 "cc_reg_not_cr0_operand" "")
6114 (compare:CC (mult:DI (match_operand:DI 1 "gpc_reg_operand" "")
6115 (match_operand:DI 2 "gpc_reg_operand" ""))
6116 (const_int 0)))
6117 (set (match_operand:DI 0 "gpc_reg_operand" "")
6118 (mult:DI (match_dup 1) (match_dup 2)))]
6119 "TARGET_POWERPC64 && reload_completed"
6120 [(set (match_dup 0)
6121 (mult:DI (match_dup 1) (match_dup 2)))
6122 (set (match_dup 3)
6123 (compare:CC (match_dup 0)
6124 (const_int 0)))]
6125 "")
6126
266eb58a
DE
6127(define_insn "smuldi3_highpart"
6128 [(set (match_operand:DI 0 "gpc_reg_operand" "=r")
6129 (truncate:DI
6130 (lshiftrt:TI (mult:TI (sign_extend:TI
6131 (match_operand:DI 1 "gpc_reg_operand" "%r"))
6132 (sign_extend:TI
6133 (match_operand:DI 2 "gpc_reg_operand" "r")))
6134 (const_int 64))))]
6135 "TARGET_POWERPC64"
6136 "mulhd %0,%1,%2"
3cb999d8 6137 [(set_attr "type" "lmul")])
266eb58a
DE
6138
6139(define_insn "umuldi3_highpart"
6140 [(set (match_operand:DI 0 "gpc_reg_operand" "=r")
6141 (truncate:DI
6142 (lshiftrt:TI (mult:TI (zero_extend:TI
6143 (match_operand:DI 1 "gpc_reg_operand" "%r"))
6144 (zero_extend:TI
6145 (match_operand:DI 2 "gpc_reg_operand" "r")))
6146 (const_int 64))))]
6147 "TARGET_POWERPC64"
6148 "mulhdu %0,%1,%2"
3cb999d8 6149 [(set_attr "type" "lmul")])
266eb58a
DE
6150
6151(define_expand "divdi3"
6152 [(set (match_operand:DI 0 "gpc_reg_operand" "")
6153 (div:DI (match_operand:DI 1 "gpc_reg_operand" "")
6154 (match_operand:DI 2 "reg_or_cint_operand" "")))]
6155 "TARGET_POWERPC64"
6156 "
6157{
6158 if (GET_CODE (operands[2]) == CONST_INT
2bfcf297 6159 && INTVAL (operands[2]) > 0
266eb58a
DE
6160 && exact_log2 (INTVAL (operands[2])) >= 0)
6161 ;
6162 else
6163 operands[2] = force_reg (DImode, operands[2]);
6164}")
6165
6166(define_expand "moddi3"
6167 [(use (match_operand:DI 0 "gpc_reg_operand" ""))
6168 (use (match_operand:DI 1 "gpc_reg_operand" ""))
6169 (use (match_operand:DI 2 "reg_or_cint_operand" ""))]
6170 "TARGET_POWERPC64"
6171 "
6172{
2bfcf297 6173 int i;
266eb58a
DE
6174 rtx temp1;
6175 rtx temp2;
6176
2bfcf297
DB
6177 if (GET_CODE (operands[2]) != CONST_INT
6178 || INTVAL (operands[2]) <= 0
6179 || (i = exact_log2 (INTVAL (operands[2]))) < 0)
266eb58a
DE
6180 FAIL;
6181
6182 temp1 = gen_reg_rtx (DImode);
6183 temp2 = gen_reg_rtx (DImode);
6184
6185 emit_insn (gen_divdi3 (temp1, operands[1], operands[2]));
6186 emit_insn (gen_ashldi3 (temp2, temp1, GEN_INT (i)));
6187 emit_insn (gen_subdi3 (operands[0], operands[1], temp2));
6188 DONE;
6189}")
6190
6191(define_insn ""
6192 [(set (match_operand:DI 0 "gpc_reg_operand" "=r")
6193 (div:DI (match_operand:DI 1 "gpc_reg_operand" "r")
2bfcf297
DB
6194 (match_operand:DI 2 "exact_log2_cint_operand" "N")))]
6195 "TARGET_POWERPC64"
266eb58a
DE
6196 "sradi %0,%1,%p2\;addze %0,%0"
6197 [(set_attr "length" "8")])
6198
6199(define_insn ""
9ebbca7d
GK
6200 [(set (match_operand:CC 0 "cc_reg_operand" "=x,?y")
6201 (compare:CC (div:DI (match_operand:DI 1 "gpc_reg_operand" "r,r")
2bfcf297 6202 (match_operand:DI 2 "exact_log2_cint_operand" "N,N"))
266eb58a 6203 (const_int 0)))
9ebbca7d 6204 (clobber (match_scratch:DI 3 "=r,r"))]
683bdff7 6205 "TARGET_64BIT"
9ebbca7d
GK
6206 "@
6207 sradi %3,%1,%p2\;addze. %3,%3
6208 #"
266eb58a 6209 [(set_attr "type" "compare")
9ebbca7d
GK
6210 (set_attr "length" "8,12")])
6211
6212(define_split
6213 [(set (match_operand:CC 0 "cc_reg_not_cr0_operand" "")
6214 (compare:CC (div:DI (match_operand:DI 1 "gpc_reg_operand" "")
2bfcf297 6215 (match_operand:DI 2 "exact_log2_cint_operand" ""))
9ebbca7d
GK
6216 (const_int 0)))
6217 (clobber (match_scratch:DI 3 ""))]
2bfcf297 6218 "TARGET_POWERPC64 && reload_completed"
9ebbca7d
GK
6219 [(set (match_dup 3)
6220 (div:DI (match_dup 1) (match_dup 2)))
6221 (set (match_dup 0)
6222 (compare:CC (match_dup 3)
6223 (const_int 0)))]
6224 "")
266eb58a
DE
6225
6226(define_insn ""
9ebbca7d
GK
6227 [(set (match_operand:CC 3 "cc_reg_operand" "=x,?y")
6228 (compare:CC (div:DI (match_operand:DI 1 "gpc_reg_operand" "r,r")
2bfcf297 6229 (match_operand:DI 2 "exact_log2_cint_operand" "N,N"))
266eb58a 6230 (const_int 0)))
9ebbca7d 6231 (set (match_operand:DI 0 "gpc_reg_operand" "=r,r")
266eb58a 6232 (div:DI (match_dup 1) (match_dup 2)))]
683bdff7 6233 "TARGET_64BIT"
9ebbca7d
GK
6234 "@
6235 sradi %0,%1,%p2\;addze. %0,%0
6236 #"
266eb58a 6237 [(set_attr "type" "compare")
9ebbca7d 6238 (set_attr "length" "8,12")])
266eb58a 6239
9ebbca7d
GK
6240(define_split
6241 [(set (match_operand:CC 3 "cc_reg_not_cr0_operand" "")
6242 (compare:CC (div:DI (match_operand:DI 1 "gpc_reg_operand" "")
2bfcf297 6243 (match_operand:DI 2 "exact_log2_cint_operand" ""))
9ebbca7d
GK
6244 (const_int 0)))
6245 (set (match_operand:DI 0 "gpc_reg_operand" "")
6246 (div:DI (match_dup 1) (match_dup 2)))]
2bfcf297 6247 "TARGET_POWERPC64 && reload_completed"
9ebbca7d
GK
6248 [(set (match_dup 0)
6249 (div:DI (match_dup 1) (match_dup 2)))
6250 (set (match_dup 3)
6251 (compare:CC (match_dup 0)
6252 (const_int 0)))]
6253 "")
6254
6255(define_insn ""
6256 [(set (match_operand:DI 0 "gpc_reg_operand" "=r")
266eb58a 6257 (div:DI (match_operand:DI 1 "gpc_reg_operand" "r")
a260abc9 6258 (match_operand:DI 2 "gpc_reg_operand" "r")))]
266eb58a
DE
6259 "TARGET_POWERPC64"
6260 "divd %0,%1,%2"
3cb999d8 6261 [(set_attr "type" "ldiv")])
266eb58a
DE
6262
6263(define_insn "udivdi3"
6264 [(set (match_operand:DI 0 "gpc_reg_operand" "=r")
6265 (udiv:DI (match_operand:DI 1 "gpc_reg_operand" "r")
6266 (match_operand:DI 2 "gpc_reg_operand" "r")))]
6267 "TARGET_POWERPC64"
6268 "divdu %0,%1,%2"
3cb999d8 6269 [(set_attr "type" "ldiv")])
266eb58a
DE
6270
6271(define_insn "rotldi3"
6272 [(set (match_operand:DI 0 "gpc_reg_operand" "=r")
6273 (rotate:DI (match_operand:DI 1 "gpc_reg_operand" "r")
6274 (match_operand:DI 2 "reg_or_cint_operand" "ri")))]
6275 "TARGET_POWERPC64"
a66078ee 6276 "rld%I2cl %0,%1,%H2,0")
266eb58a 6277
a260abc9 6278(define_insn "*rotldi3_internal2"
9ebbca7d
GK
6279 [(set (match_operand:CC 0 "cc_reg_operand" "=x,?y")
6280 (compare:CC (rotate:DI (match_operand:DI 1 "gpc_reg_operand" "r,r")
6281 (match_operand:DI 2 "reg_or_cint_operand" "ri,ri"))
266eb58a 6282 (const_int 0)))
9ebbca7d 6283 (clobber (match_scratch:DI 3 "=r,r"))]
683bdff7 6284 "TARGET_64BIT"
9ebbca7d
GK
6285 "@
6286 rld%I2cl. %3,%1,%H2,0
6287 #"
6288 [(set_attr "type" "delayed_compare")
6289 (set_attr "length" "4,8")])
6290
6291(define_split
6292 [(set (match_operand:CC 0 "cc_reg_not_cr0_operand" "")
6293 (compare:CC (rotate:DI (match_operand:DI 1 "gpc_reg_operand" "")
6294 (match_operand:DI 2 "reg_or_cint_operand" ""))
6295 (const_int 0)))
6296 (clobber (match_scratch:DI 3 ""))]
6297 "TARGET_POWERPC64 && reload_completed"
6298 [(set (match_dup 3)
6299 (rotate:DI (match_dup 1) (match_dup 2)))
6300 (set (match_dup 0)
6301 (compare:CC (match_dup 3)
6302 (const_int 0)))]
6303 "")
266eb58a 6304
a260abc9 6305(define_insn "*rotldi3_internal3"
9ebbca7d
GK
6306 [(set (match_operand:CC 3 "cc_reg_operand" "=x,?y")
6307 (compare:CC (rotate:DI (match_operand:DI 1 "gpc_reg_operand" "r,r")
6308 (match_operand:DI 2 "reg_or_cint_operand" "ri,ri"))
266eb58a 6309 (const_int 0)))
9ebbca7d 6310 (set (match_operand:DI 0 "gpc_reg_operand" "=r,r")
266eb58a 6311 (rotate:DI (match_dup 1) (match_dup 2)))]
683bdff7 6312 "TARGET_64BIT"
9ebbca7d
GK
6313 "@
6314 rld%I2cl. %0,%1,%H2,0
6315 #"
6316 [(set_attr "type" "delayed_compare")
6317 (set_attr "length" "4,8")])
6318
6319(define_split
6320 [(set (match_operand:CC 3 "cc_reg_not_cr0_operand" "")
6321 (compare:CC (rotate:DI (match_operand:DI 1 "gpc_reg_operand" "")
6322 (match_operand:DI 2 "reg_or_cint_operand" ""))
6323 (const_int 0)))
6324 (set (match_operand:DI 0 "gpc_reg_operand" "")
6325 (rotate:DI (match_dup 1) (match_dup 2)))]
6326 "TARGET_POWERPC64 && reload_completed"
6327 [(set (match_dup 0)
6328 (rotate:DI (match_dup 1) (match_dup 2)))
6329 (set (match_dup 3)
6330 (compare:CC (match_dup 0)
6331 (const_int 0)))]
6332 "")
266eb58a 6333
a260abc9
DE
6334(define_insn "*rotldi3_internal4"
6335 [(set (match_operand:DI 0 "gpc_reg_operand" "=r")
6336 (and:DI (rotate:DI (match_operand:DI 1 "gpc_reg_operand" "r")
6337 (match_operand:DI 2 "reg_or_cint_operand" "ri"))
ce71f754 6338 (match_operand:DI 3 "mask64_operand" "n")))]
a260abc9
DE
6339 "TARGET_POWERPC64"
6340 "rld%I2c%B3 %0,%1,%H2,%S3")
6341
6342(define_insn "*rotldi3_internal5"
9ebbca7d 6343 [(set (match_operand:CC 0 "cc_reg_operand" "=x,?y")
a260abc9 6344 (compare:CC (and:DI
9ebbca7d
GK
6345 (rotate:DI (match_operand:DI 1 "gpc_reg_operand" "r,r")
6346 (match_operand:DI 2 "reg_or_cint_operand" "ri,ri"))
ce71f754 6347 (match_operand:DI 3 "mask64_operand" "n,n"))
a260abc9 6348 (const_int 0)))
9ebbca7d 6349 (clobber (match_scratch:DI 4 "=r,r"))]
683bdff7 6350 "TARGET_64BIT"
9ebbca7d
GK
6351 "@
6352 rld%I2c%B3. %4,%1,%H2,%S3
6353 #"
6354 [(set_attr "type" "delayed_compare")
6355 (set_attr "length" "4,8")])
6356
6357(define_split
6358 [(set (match_operand:CC 0 "cc_reg_not_cr0_operand" "")
6359 (compare:CC (and:DI
6360 (rotate:DI (match_operand:DI 1 "gpc_reg_operand" "")
6361 (match_operand:DI 2 "reg_or_cint_operand" ""))
6362 (match_operand:DI 3 "mask64_operand" ""))
6363 (const_int 0)))
6364 (clobber (match_scratch:DI 4 ""))]
6365 "TARGET_POWERPC64 && reload_completed"
6366 [(set (match_dup 4)
6367 (and:DI (rotate:DI (match_dup 1)
6368 (match_dup 2))
6369 (match_dup 3)))
6370 (set (match_dup 0)
6371 (compare:CC (match_dup 4)
6372 (const_int 0)))]
6373 "")
a260abc9
DE
6374
6375(define_insn "*rotldi3_internal6"
9ebbca7d 6376 [(set (match_operand:CC 4 "cc_reg_operand" "=x,?y")
a260abc9 6377 (compare:CC (and:DI
9ebbca7d
GK
6378 (rotate:DI (match_operand:DI 1 "gpc_reg_operand" "r,r")
6379 (match_operand:DI 2 "reg_or_cint_operand" "ri,ri"))
ce71f754 6380 (match_operand:DI 3 "mask64_operand" "n,n"))
a260abc9 6381 (const_int 0)))
9ebbca7d 6382 (set (match_operand:DI 0 "gpc_reg_operand" "=r,r")
a260abc9 6383 (and:DI (rotate:DI (match_dup 1) (match_dup 2)) (match_dup 3)))]
683bdff7 6384 "TARGET_64BIT"
9ebbca7d
GK
6385 "@
6386 rld%I2c%B3. %0,%1,%H2,%S3
6387 #"
6388 [(set_attr "type" "delayed_compare")
6389 (set_attr "length" "4,8")])
6390
6391(define_split
6392 [(set (match_operand:CC 4 "cc_reg_not_cr0_operand" "")
6393 (compare:CC (and:DI
6394 (rotate:DI (match_operand:DI 1 "gpc_reg_operand" "")
6395 (match_operand:DI 2 "reg_or_cint_operand" ""))
6396 (match_operand:DI 3 "mask64_operand" ""))
6397 (const_int 0)))
6398 (set (match_operand:DI 0 "gpc_reg_operand" "")
6399 (and:DI (rotate:DI (match_dup 1) (match_dup 2)) (match_dup 3)))]
6400 "TARGET_POWERPC64 && reload_completed"
6401 [(set (match_dup 0)
6402 (and:DI (rotate:DI (match_dup 1) (match_dup 2)) (match_dup 3)))
6403 (set (match_dup 4)
6404 (compare:CC (match_dup 0)
6405 (const_int 0)))]
6406 "")
a260abc9
DE
6407
6408(define_insn "*rotldi3_internal7"
6409 [(set (match_operand:DI 0 "gpc_reg_operand" "=r")
6410 (zero_extend:DI
6411 (subreg:QI
6412 (rotate:DI (match_operand:DI 1 "gpc_reg_operand" "r")
6413 (match_operand:DI 2 "reg_or_cint_operand" "ri")) 0)))]
6414 "TARGET_POWERPC64"
6415 "rld%I2cl %0,%1,%H2,56")
6416
6417(define_insn "*rotldi3_internal8"
9ebbca7d 6418 [(set (match_operand:CC 0 "cc_reg_operand" "=x,?y")
a260abc9
DE
6419 (compare:CC (zero_extend:DI
6420 (subreg:QI
9ebbca7d
GK
6421 (rotate:DI (match_operand:DI 1 "gpc_reg_operand" "r,r")
6422 (match_operand:DI 2 "reg_or_cint_operand" "ri,ri")) 0))
a260abc9 6423 (const_int 0)))
9ebbca7d 6424 (clobber (match_scratch:DI 3 "=r,r"))]
683bdff7 6425 "TARGET_64BIT"
9ebbca7d
GK
6426 "@
6427 rld%I2cl. %3,%1,%H2,56
6428 #"
6429 [(set_attr "type" "delayed_compare")
6430 (set_attr "length" "4,8")])
6431
6432(define_split
6433 [(set (match_operand:CC 0 "cc_reg_not_cr0_operand" "")
6434 (compare:CC (zero_extend:DI
6435 (subreg:QI
6436 (rotate:DI (match_operand:DI 1 "gpc_reg_operand" "")
6437 (match_operand:DI 2 "reg_or_cint_operand" "")) 0))
6438 (const_int 0)))
6439 (clobber (match_scratch:DI 3 ""))]
6440 "TARGET_POWERPC64 && reload_completed"
6441 [(set (match_dup 3)
6442 (zero_extend:DI (subreg:QI
6443 (rotate:DI (match_dup 1)
6444 (match_dup 2)) 0)))
6445 (set (match_dup 0)
6446 (compare:CC (match_dup 3)
6447 (const_int 0)))]
6448 "")
a260abc9
DE
6449
6450(define_insn "*rotldi3_internal9"
9ebbca7d 6451 [(set (match_operand:CC 3 "cc_reg_operand" "=x,?y")
a260abc9
DE
6452 (compare:CC (zero_extend:DI
6453 (subreg:QI
9ebbca7d
GK
6454 (rotate:DI (match_operand:DI 1 "gpc_reg_operand" "r,r")
6455 (match_operand:DI 2 "reg_or_cint_operand" "ri,ri")) 0))
a260abc9 6456 (const_int 0)))
9ebbca7d 6457 (set (match_operand:DI 0 "gpc_reg_operand" "=r,r")
a260abc9 6458 (zero_extend:DI (subreg:QI (rotate:DI (match_dup 1) (match_dup 2)) 0)))]
683bdff7 6459 "TARGET_64BIT"
9ebbca7d
GK
6460 "@
6461 rld%I2cl. %0,%1,%H2,56
6462 #"
6463 [(set_attr "type" "delayed_compare")
6464 (set_attr "length" "4,8")])
6465
6466(define_split
6467 [(set (match_operand:CC 3 "cc_reg_not_cr0_operand" "")
6468 (compare:CC (zero_extend:DI
6469 (subreg:QI
6470 (rotate:DI (match_operand:DI 1 "gpc_reg_operand" "")
6471 (match_operand:DI 2 "reg_or_cint_operand" "")) 0))
6472 (const_int 0)))
6473 (set (match_operand:DI 0 "gpc_reg_operand" "")
6474 (zero_extend:DI (subreg:QI (rotate:DI (match_dup 1) (match_dup 2)) 0)))]
6475 "TARGET_POWERPC64 && reload_completed"
6476 [(set (match_dup 0)
6477 (zero_extend:DI (subreg:QI (rotate:DI (match_dup 1) (match_dup 2)) 0)))
6478 (set (match_dup 3)
6479 (compare:CC (match_dup 0)
6480 (const_int 0)))]
6481 "")
a260abc9
DE
6482
6483(define_insn "*rotldi3_internal10"
6484 [(set (match_operand:DI 0 "gpc_reg_operand" "=r")
6485 (zero_extend:DI
6486 (subreg:HI
6487 (rotate:DI (match_operand:DI 1 "gpc_reg_operand" "r")
6488 (match_operand:DI 2 "reg_or_cint_operand" "ri")) 0)))]
6489 "TARGET_POWERPC64"
6490 "rld%I2cl %0,%1,%H2,48")
6491
6492(define_insn "*rotldi3_internal11"
9ebbca7d 6493 [(set (match_operand:CC 0 "cc_reg_operand" "=x,?y")
a260abc9
DE
6494 (compare:CC (zero_extend:DI
6495 (subreg:HI
9ebbca7d
GK
6496 (rotate:DI (match_operand:DI 1 "gpc_reg_operand" "r,r")
6497 (match_operand:DI 2 "reg_or_cint_operand" "ri,ri")) 0))
a260abc9 6498 (const_int 0)))
9ebbca7d 6499 (clobber (match_scratch:DI 3 "=r,r"))]
683bdff7 6500 "TARGET_64BIT"
9ebbca7d
GK
6501 "@
6502 rld%I2cl. %3,%1,%H2,48
6503 #"
6504 [(set_attr "type" "delayed_compare")
6505 (set_attr "length" "4,8")])
6506
6507(define_split
6508 [(set (match_operand:CC 0 "cc_reg_not_cr0_operand" "")
6509 (compare:CC (zero_extend:DI
6510 (subreg:HI
6511 (rotate:DI (match_operand:DI 1 "gpc_reg_operand" "")
6512 (match_operand:DI 2 "reg_or_cint_operand" "")) 0))
6513 (const_int 0)))
6514 (clobber (match_scratch:DI 3 ""))]
6515 "TARGET_POWERPC64 && reload_completed"
6516 [(set (match_dup 3)
6517 (zero_extend:DI (subreg:HI
6518 (rotate:DI (match_dup 1)
6519 (match_dup 2)) 0)))
6520 (set (match_dup 0)
6521 (compare:CC (match_dup 3)
6522 (const_int 0)))]
6523 "")
a260abc9
DE
6524
6525(define_insn "*rotldi3_internal12"
9ebbca7d 6526 [(set (match_operand:CC 3 "cc_reg_operand" "=x,?y")
a260abc9
DE
6527 (compare:CC (zero_extend:DI
6528 (subreg:HI
9ebbca7d
GK
6529 (rotate:DI (match_operand:DI 1 "gpc_reg_operand" "r,r")
6530 (match_operand:DI 2 "reg_or_cint_operand" "ri,ri")) 0))
a260abc9 6531 (const_int 0)))
9ebbca7d 6532 (set (match_operand:DI 0 "gpc_reg_operand" "=r,r")
a260abc9 6533 (zero_extend:DI (subreg:HI (rotate:DI (match_dup 1) (match_dup 2)) 0)))]
683bdff7 6534 "TARGET_64BIT"
9ebbca7d
GK
6535 "@
6536 rld%I2cl. %0,%1,%H2,48
6537 #"
6538 [(set_attr "type" "delayed_compare")
6539 (set_attr "length" "4,8")])
6540
6541(define_split
6542 [(set (match_operand:CC 3 "cc_reg_not_cr0_operand" "")
6543 (compare:CC (zero_extend:DI
6544 (subreg:HI
6545 (rotate:DI (match_operand:DI 1 "gpc_reg_operand" "")
6546 (match_operand:DI 2 "reg_or_cint_operand" "")) 0))
6547 (const_int 0)))
6548 (set (match_operand:DI 0 "gpc_reg_operand" "")
6549 (zero_extend:DI (subreg:HI (rotate:DI (match_dup 1) (match_dup 2)) 0)))]
6550 "TARGET_POWERPC64 && reload_completed"
6551 [(set (match_dup 0)
6552 (zero_extend:DI (subreg:HI (rotate:DI (match_dup 1) (match_dup 2)) 0)))
6553 (set (match_dup 3)
6554 (compare:CC (match_dup 0)
6555 (const_int 0)))]
6556 "")
a260abc9
DE
6557
6558(define_insn "*rotldi3_internal13"
6559 [(set (match_operand:DI 0 "gpc_reg_operand" "=r")
6560 (zero_extend:DI
6561 (subreg:SI
6562 (rotate:DI (match_operand:DI 1 "gpc_reg_operand" "r")
6563 (match_operand:DI 2 "reg_or_cint_operand" "ri")) 0)))]
6564 "TARGET_POWERPC64"
6565 "rld%I2cl %0,%1,%H2,32")
6566
6567(define_insn "*rotldi3_internal14"
9ebbca7d 6568 [(set (match_operand:CC 0 "cc_reg_operand" "=x,?y")
a260abc9
DE
6569 (compare:CC (zero_extend:DI
6570 (subreg:SI
9ebbca7d
GK
6571 (rotate:DI (match_operand:DI 1 "gpc_reg_operand" "r,r")
6572 (match_operand:DI 2 "reg_or_cint_operand" "ri,ri")) 0))
a260abc9 6573 (const_int 0)))
9ebbca7d 6574 (clobber (match_scratch:DI 3 "=r,r"))]
683bdff7 6575 "TARGET_64BIT"
9ebbca7d
GK
6576 "@
6577 rld%I2cl. %3,%1,%H2,32
6578 #"
6579 [(set_attr "type" "delayed_compare")
6580 (set_attr "length" "4,8")])
6581
6582(define_split
6583 [(set (match_operand:CC 0 "cc_reg_not_cr0_operand" "")
6584 (compare:CC (zero_extend:DI
6585 (subreg:SI
6586 (rotate:DI (match_operand:DI 1 "gpc_reg_operand" "")
6587 (match_operand:DI 2 "reg_or_cint_operand" "")) 0))
6588 (const_int 0)))
6589 (clobber (match_scratch:DI 3 ""))]
6590 "TARGET_POWERPC64 && reload_completed"
6591 [(set (match_dup 3)
6592 (zero_extend:DI (subreg:SI
6593 (rotate:DI (match_dup 1)
6594 (match_dup 2)) 0)))
6595 (set (match_dup 0)
6596 (compare:CC (match_dup 3)
6597 (const_int 0)))]
6598 "")
a260abc9
DE
6599
6600(define_insn "*rotldi3_internal15"
9ebbca7d 6601 [(set (match_operand:CC 3 "cc_reg_operand" "=x,?y")
a260abc9
DE
6602 (compare:CC (zero_extend:DI
6603 (subreg:SI
9ebbca7d
GK
6604 (rotate:DI (match_operand:DI 1 "gpc_reg_operand" "r,r")
6605 (match_operand:DI 2 "reg_or_cint_operand" "ri,ri")) 0))
a260abc9 6606 (const_int 0)))
9ebbca7d 6607 (set (match_operand:DI 0 "gpc_reg_operand" "=r,r")
a260abc9 6608 (zero_extend:DI (subreg:SI (rotate:DI (match_dup 1) (match_dup 2)) 0)))]
683bdff7 6609 "TARGET_64BIT"
9ebbca7d
GK
6610 "@
6611 rld%I2cl. %0,%1,%H2,32
6612 #"
6613 [(set_attr "type" "delayed_compare")
6614 (set_attr "length" "4,8")])
6615
6616(define_split
6617 [(set (match_operand:CC 3 "cc_reg_not_cr0_operand" "")
6618 (compare:CC (zero_extend:DI
6619 (subreg:SI
6620 (rotate:DI (match_operand:DI 1 "gpc_reg_operand" "")
6621 (match_operand:DI 2 "reg_or_cint_operand" "")) 0))
6622 (const_int 0)))
6623 (set (match_operand:DI 0 "gpc_reg_operand" "")
6624 (zero_extend:DI (subreg:SI (rotate:DI (match_dup 1) (match_dup 2)) 0)))]
6625 "TARGET_POWERPC64 && reload_completed"
6626 [(set (match_dup 0)
6627 (zero_extend:DI (subreg:SI (rotate:DI (match_dup 1) (match_dup 2)) 0)))
6628 (set (match_dup 3)
6629 (compare:CC (match_dup 0)
6630 (const_int 0)))]
6631 "")
a260abc9 6632
266eb58a
DE
6633(define_expand "ashldi3"
6634 [(set (match_operand:DI 0 "gpc_reg_operand" "")
6635 (ashift:DI (match_operand:DI 1 "gpc_reg_operand" "")
6636 (match_operand:SI 2 "reg_or_cint_operand" "")))]
6637 "TARGET_POWERPC64 || TARGET_POWER"
6638 "
6639{
6640 if (TARGET_POWERPC64)
6641 ;
6642 else if (TARGET_POWER)
6643 {
6644 emit_insn (gen_ashldi3_power (operands[0], operands[1], operands[2]));
6645 DONE;
6646 }
6647 else
6648 FAIL;
6649}")
6650
e2c953b6 6651(define_insn "*ashldi3_internal1"
266eb58a
DE
6652 [(set (match_operand:DI 0 "gpc_reg_operand" "=r")
6653 (ashift:DI (match_operand:DI 1 "gpc_reg_operand" "r")
6654 (match_operand:SI 2 "reg_or_cint_operand" "ri")))]
6655 "TARGET_POWERPC64"
a66078ee 6656 "sld%I2 %0,%1,%H2"
266eb58a
DE
6657 [(set_attr "length" "8")])
6658
e2c953b6 6659(define_insn "*ashldi3_internal2"
9ebbca7d
GK
6660 [(set (match_operand:CC 0 "cc_reg_operand" "=x,?y")
6661 (compare:CC (ashift:DI (match_operand:DI 1 "gpc_reg_operand" "r,r")
6662 (match_operand:SI 2 "reg_or_cint_operand" "ri,ri"))
266eb58a 6663 (const_int 0)))
9ebbca7d 6664 (clobber (match_scratch:DI 3 "=r,r"))]
683bdff7 6665 "TARGET_64BIT"
9ebbca7d
GK
6666 "@
6667 sld%I2. %3,%1,%H2
6668 #"
6669 [(set_attr "type" "delayed_compare")
6670 (set_attr "length" "4,8")])
29ae5b89 6671
9ebbca7d
GK
6672(define_split
6673 [(set (match_operand:CC 0 "cc_reg_not_cr0_operand" "")
6674 (compare:CC (ashift:DI (match_operand:DI 1 "gpc_reg_operand" "")
6675 (match_operand:SI 2 "reg_or_cint_operand" ""))
6676 (const_int 0)))
6677 (clobber (match_scratch:DI 3 ""))]
6678 "TARGET_POWERPC64 && reload_completed"
6679 [(set (match_dup 3)
6680 (ashift:DI (match_dup 1) (match_dup 2)))
6681 (set (match_dup 0)
6682 (compare:CC (match_dup 3)
6683 (const_int 0)))]
6684 "")
6685
e2c953b6 6686(define_insn "*ashldi3_internal3"
9ebbca7d
GK
6687 [(set (match_operand:CC 3 "cc_reg_operand" "=x,?y")
6688 (compare:CC (ashift:DI (match_operand:DI 1 "gpc_reg_operand" "r,r")
6689 (match_operand:SI 2 "reg_or_cint_operand" "ri,ri"))
266eb58a 6690 (const_int 0)))
9ebbca7d 6691 (set (match_operand:DI 0 "gpc_reg_operand" "=r,r")
266eb58a 6692 (ashift:DI (match_dup 1) (match_dup 2)))]
683bdff7 6693 "TARGET_64BIT"
9ebbca7d
GK
6694 "@
6695 sld%I2. %0,%1,%H2
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 (ashift:DI (match_operand:DI 1 "gpc_reg_operand" "")
6703 (match_operand:SI 2 "reg_or_cint_operand" ""))
6704 (const_int 0)))
6705 (set (match_operand:DI 0 "gpc_reg_operand" "")
6706 (ashift:DI (match_dup 1) (match_dup 2)))]
6707 "TARGET_POWERPC64 && reload_completed"
6708 [(set (match_dup 0)
6709 (ashift:DI (match_dup 1) (match_dup 2)))
6710 (set (match_dup 3)
6711 (compare:CC (match_dup 0)
6712 (const_int 0)))]
6713 "")
266eb58a 6714
e2c953b6 6715(define_insn "*ashldi3_internal4"
3cb999d8
DE
6716 [(set (match_operand:DI 0 "gpc_reg_operand" "=r")
6717 (and:DI (ashift:DI (match_operand:DI 1 "gpc_reg_operand" "r")
6718 (match_operand:SI 2 "const_int_operand" "i"))
c5059423
AM
6719 (match_operand:DI 3 "const_int_operand" "n")))]
6720 "TARGET_POWERPC64 && includes_rldic_lshift_p (operands[2], operands[3])"
e2c953b6 6721 "rldic %0,%1,%H2,%W3")
3cb999d8 6722
e2c953b6 6723(define_insn "ashldi3_internal5"
9ebbca7d 6724 [(set (match_operand:CC 0 "cc_reg_operand" "=x,?y")
3cb999d8 6725 (compare:CC
9ebbca7d
GK
6726 (and:DI (ashift:DI (match_operand:DI 1 "gpc_reg_operand" "r,r")
6727 (match_operand:SI 2 "const_int_operand" "i,i"))
c5059423 6728 (match_operand:DI 3 "const_int_operand" "n,n"))
3cb999d8 6729 (const_int 0)))
9ebbca7d 6730 (clobber (match_scratch:DI 4 "=r,r"))]
683bdff7 6731 "TARGET_64BIT && includes_rldic_lshift_p (operands[2], operands[3])"
9ebbca7d 6732 "@
e2c953b6 6733 rldic. %4,%1,%H2,%W3
9ebbca7d
GK
6734 #"
6735 [(set_attr "type" "delayed_compare")
6736 (set_attr "length" "4,8")])
6737
6738(define_split
6739 [(set (match_operand:CC 0 "cc_reg_not_cr0_operand" "")
6740 (compare:CC
6741 (and:DI (ashift:DI (match_operand:DI 1 "gpc_reg_operand" "")
6742 (match_operand:SI 2 "const_int_operand" ""))
c5059423 6743 (match_operand:DI 3 "const_int_operand" ""))
9ebbca7d
GK
6744 (const_int 0)))
6745 (clobber (match_scratch:DI 4 ""))]
c5059423
AM
6746 "TARGET_POWERPC64 && reload_completed
6747 && includes_rldic_lshift_p (operands[2], operands[3])"
9ebbca7d
GK
6748 [(set (match_dup 4)
6749 (and:DI (ashift:DI (match_dup 1) (match_dup 2))
e2c953b6 6750 (match_dup 3)))
9ebbca7d
GK
6751 (set (match_dup 0)
6752 (compare:CC (match_dup 4)
6753 (const_int 0)))]
6754 "")
3cb999d8 6755
e2c953b6 6756(define_insn "*ashldi3_internal6"
9ebbca7d 6757 [(set (match_operand:CC 4 "cc_reg_operand" "=x,?y")
3cb999d8 6758 (compare:CC
9ebbca7d
GK
6759 (and:DI (ashift:DI (match_operand:DI 1 "gpc_reg_operand" "r,r")
6760 (match_operand:SI 2 "const_int_operand" "i,i"))
c5059423 6761 (match_operand:DI 3 "const_int_operand" "n,n"))
3cb999d8 6762 (const_int 0)))
9ebbca7d 6763 (set (match_operand:DI 0 "gpc_reg_operand" "=r,r")
3cb999d8 6764 (and:DI (ashift:DI (match_dup 1) (match_dup 2)) (match_dup 3)))]
683bdff7 6765 "TARGET_64BIT && includes_rldic_lshift_p (operands[2], operands[3])"
9ebbca7d 6766 "@
e2c953b6 6767 rldic. %0,%1,%H2,%W3
9ebbca7d
GK
6768 #"
6769 [(set_attr "type" "delayed_compare")
6770 (set_attr "length" "4,8")])
6771
6772(define_split
6773 [(set (match_operand:CC 4 "cc_reg_not_cr0_operand" "")
6774 (compare:CC
6775 (and:DI (ashift:DI (match_operand:DI 1 "gpc_reg_operand" "")
6776 (match_operand:SI 2 "const_int_operand" ""))
c5059423 6777 (match_operand:DI 3 "const_int_operand" ""))
9ebbca7d
GK
6778 (const_int 0)))
6779 (set (match_operand:DI 0 "gpc_reg_operand" "")
6780 (and:DI (ashift:DI (match_dup 1) (match_dup 2)) (match_dup 3)))]
c5059423
AM
6781 "TARGET_POWERPC64 && reload_completed
6782 && includes_rldic_lshift_p (operands[2], operands[3])"
6783 [(set (match_dup 0)
6784 (and:DI (ashift:DI (match_dup 1) (match_dup 2))
6785 (match_dup 3)))
6786 (set (match_dup 4)
6787 (compare:CC (match_dup 0)
6788 (const_int 0)))]
6789 "")
6790
6791(define_insn "*ashldi3_internal7"
6792 [(set (match_operand:DI 0 "gpc_reg_operand" "=r")
6793 (and:DI (ashift:DI (match_operand:DI 1 "gpc_reg_operand" "r")
6794 (match_operand:SI 2 "const_int_operand" "i"))
ce71f754 6795 (match_operand:DI 3 "mask64_operand" "n")))]
c5059423
AM
6796 "TARGET_POWERPC64 && includes_rldicr_lshift_p (operands[2], operands[3])"
6797 "rldicr %0,%1,%H2,%S3")
6798
6799(define_insn "ashldi3_internal8"
6800 [(set (match_operand:CC 0 "cc_reg_operand" "=x,?y")
6801 (compare:CC
6802 (and:DI (ashift:DI (match_operand:DI 1 "gpc_reg_operand" "r,r")
6803 (match_operand:SI 2 "const_int_operand" "i,i"))
ce71f754 6804 (match_operand:DI 3 "mask64_operand" "n,n"))
c5059423
AM
6805 (const_int 0)))
6806 (clobber (match_scratch:DI 4 "=r,r"))]
683bdff7 6807 "TARGET_64BIT && includes_rldicr_lshift_p (operands[2], operands[3])"
c5059423
AM
6808 "@
6809 rldicr. %4,%1,%H2,%S3
6810 #"
6811 [(set_attr "type" "delayed_compare")
6812 (set_attr "length" "4,8")])
6813
6814(define_split
6815 [(set (match_operand:CC 0 "cc_reg_not_cr0_operand" "")
6816 (compare:CC
6817 (and:DI (ashift:DI (match_operand:DI 1 "gpc_reg_operand" "")
6818 (match_operand:SI 2 "const_int_operand" ""))
6819 (match_operand:DI 3 "mask64_operand" ""))
6820 (const_int 0)))
6821 (clobber (match_scratch:DI 4 ""))]
6822 "TARGET_POWERPC64 && reload_completed
6823 && includes_rldicr_lshift_p (operands[2], operands[3])"
6824 [(set (match_dup 4)
6825 (and:DI (ashift:DI (match_dup 1) (match_dup 2))
6826 (match_dup 3)))
6827 (set (match_dup 0)
6828 (compare:CC (match_dup 4)
6829 (const_int 0)))]
6830 "")
6831
6832(define_insn "*ashldi3_internal9"
6833 [(set (match_operand:CC 4 "cc_reg_operand" "=x,?y")
6834 (compare:CC
6835 (and:DI (ashift:DI (match_operand:DI 1 "gpc_reg_operand" "r,r")
6836 (match_operand:SI 2 "const_int_operand" "i,i"))
ce71f754 6837 (match_operand:DI 3 "mask64_operand" "n,n"))
c5059423
AM
6838 (const_int 0)))
6839 (set (match_operand:DI 0 "gpc_reg_operand" "=r,r")
6840 (and:DI (ashift:DI (match_dup 1) (match_dup 2)) (match_dup 3)))]
683bdff7 6841 "TARGET_64BIT && includes_rldicr_lshift_p (operands[2], operands[3])"
c5059423
AM
6842 "@
6843 rldicr. %0,%1,%H2,%S3
6844 #"
6845 [(set_attr "type" "delayed_compare")
6846 (set_attr "length" "4,8")])
6847
6848(define_split
6849 [(set (match_operand:CC 4 "cc_reg_not_cr0_operand" "")
6850 (compare:CC
6851 (and:DI (ashift:DI (match_operand:DI 1 "gpc_reg_operand" "")
6852 (match_operand:SI 2 "const_int_operand" ""))
6853 (match_operand:DI 3 "mask64_operand" ""))
6854 (const_int 0)))
6855 (set (match_operand:DI 0 "gpc_reg_operand" "")
6856 (and:DI (ashift:DI (match_dup 1) (match_dup 2)) (match_dup 3)))]
6857 "TARGET_POWERPC64 && reload_completed
6858 && includes_rldicr_lshift_p (operands[2], operands[3])"
9ebbca7d 6859 [(set (match_dup 0)
e2c953b6
DE
6860 (and:DI (ashift:DI (match_dup 1) (match_dup 2))
6861 (match_dup 3)))
9ebbca7d
GK
6862 (set (match_dup 4)
6863 (compare:CC (match_dup 0)
6864 (const_int 0)))]
6865 "")
6866
6867(define_expand "lshrdi3"
266eb58a
DE
6868 [(set (match_operand:DI 0 "gpc_reg_operand" "")
6869 (lshiftrt:DI (match_operand:DI 1 "gpc_reg_operand" "")
6870 (match_operand:SI 2 "reg_or_cint_operand" "")))]
6871 "TARGET_POWERPC64 || TARGET_POWER"
6872 "
6873{
6874 if (TARGET_POWERPC64)
6875 ;
6876 else if (TARGET_POWER)
6877 {
6878 emit_insn (gen_lshrdi3_power (operands[0], operands[1], operands[2]));
6879 DONE;
6880 }
6881 else
6882 FAIL;
6883}")
6884
e2c953b6 6885(define_insn "*lshrdi3_internal1"
266eb58a
DE
6886 [(set (match_operand:DI 0 "gpc_reg_operand" "=r")
6887 (lshiftrt:DI (match_operand:DI 1 "gpc_reg_operand" "r")
6888 (match_operand:SI 2 "reg_or_cint_operand" "ri")))]
6889 "TARGET_POWERPC64"
a66078ee 6890 "srd%I2 %0,%1,%H2")
266eb58a 6891
e2c953b6 6892(define_insn "*lshrdi3_internal2"
9ebbca7d
GK
6893 [(set (match_operand:CC 0 "cc_reg_operand" "=x,?y")
6894 (compare:CC (lshiftrt:DI (match_operand:DI 1 "gpc_reg_operand" "r,r")
6895 (match_operand:SI 2 "reg_or_cint_operand" "ri,ri"))
29ae5b89 6896 (const_int 0)))
9ebbca7d 6897 (clobber (match_scratch:DI 3 "=r,r"))]
683bdff7 6898 "TARGET_64BIT "
9ebbca7d
GK
6899 "@
6900 srd%I2. %3,%1,%H2
6901 #"
6902 [(set_attr "type" "delayed_compare")
6903 (set_attr "length" "4,8")])
6904
6905(define_split
6906 [(set (match_operand:CC 0 "cc_reg_not_cr0_operand" "")
6907 (compare:CC (lshiftrt:DI (match_operand:DI 1 "gpc_reg_operand" "")
6908 (match_operand:SI 2 "reg_or_cint_operand" ""))
6909 (const_int 0)))
6910 (clobber (match_scratch:DI 3 ""))]
6911 "TARGET_POWERPC64 && reload_completed"
6912 [(set (match_dup 3)
6913 (lshiftrt:DI (match_dup 1) (match_dup 2)))
6914 (set (match_dup 0)
6915 (compare:CC (match_dup 3)
6916 (const_int 0)))]
6917 "")
266eb58a 6918
e2c953b6 6919(define_insn "*lshrdi3_internal3"
9ebbca7d
GK
6920 [(set (match_operand:CC 3 "cc_reg_operand" "=x,?y")
6921 (compare:CC (lshiftrt:DI (match_operand:DI 1 "gpc_reg_operand" "r,r")
6922 (match_operand:SI 2 "reg_or_cint_operand" "ri,ri"))
266eb58a 6923 (const_int 0)))
9ebbca7d 6924 (set (match_operand:DI 0 "gpc_reg_operand" "=r,r")
29ae5b89 6925 (lshiftrt:DI (match_dup 1) (match_dup 2)))]
683bdff7 6926 "TARGET_64BIT"
9ebbca7d
GK
6927 "@
6928 srd%I2. %0,%1,%H2
6929 #"
6930 [(set_attr "type" "delayed_compare")
6931 (set_attr "length" "4,8")])
6932
6933(define_split
6934 [(set (match_operand:CC 3 "cc_reg_not_cr0_operand" "")
6935 (compare:CC (lshiftrt:DI (match_operand:DI 1 "gpc_reg_operand" "")
6936 (match_operand:SI 2 "reg_or_cint_operand" ""))
6937 (const_int 0)))
6938 (set (match_operand:DI 0 "gpc_reg_operand" "")
6939 (lshiftrt:DI (match_dup 1) (match_dup 2)))]
6940 "TARGET_POWERPC64 && reload_completed"
6941 [(set (match_dup 0)
6942 (lshiftrt:DI (match_dup 1) (match_dup 2)))
6943 (set (match_dup 3)
6944 (compare:CC (match_dup 0)
6945 (const_int 0)))]
6946 "")
266eb58a
DE
6947
6948(define_expand "ashrdi3"
6949 [(set (match_operand:DI 0 "gpc_reg_operand" "")
6950 (ashiftrt:DI (match_operand:DI 1 "gpc_reg_operand" "")
6951 (match_operand:SI 2 "reg_or_cint_operand" "")))]
4aa74a4f 6952 ""
266eb58a
DE
6953 "
6954{
6955 if (TARGET_POWERPC64)
6956 ;
6957 else if (TARGET_POWER && GET_CODE (operands[2]) == CONST_INT)
6958 {
6959 emit_insn (gen_ashrdi3_power (operands[0], operands[1], operands[2]));
6960 DONE;
6961 }
4aa74a4f
FS
6962 else if (TARGET_32BIT && GET_CODE (operands[2]) == CONST_INT)
6963 {
6964 emit_insn (gen_ashrdi3_no_power (operands[0], operands[1], operands[2]));
6965 DONE;
6966 }
266eb58a
DE
6967 else
6968 FAIL;
6969}")
6970
e2c953b6 6971(define_insn "*ashrdi3_internal1"
266eb58a
DE
6972 [(set (match_operand:DI 0 "gpc_reg_operand" "=r")
6973 (ashiftrt:DI (match_operand:DI 1 "gpc_reg_operand" "r")
6974 (match_operand:SI 2 "reg_or_cint_operand" "ri")))]
6975 "TARGET_POWERPC64"
375490e0 6976 "srad%I2 %0,%1,%H2")
266eb58a 6977
e2c953b6 6978(define_insn "*ashrdi3_internal2"
9ebbca7d
GK
6979 [(set (match_operand:CC 0 "cc_reg_operand" "=x,?y")
6980 (compare:CC (ashiftrt:DI (match_operand:DI 1 "gpc_reg_operand" "r,r")
6981 (match_operand:SI 2 "reg_or_cint_operand" "ri,ri"))
266eb58a 6982 (const_int 0)))
9ebbca7d 6983 (clobber (match_scratch:DI 3 "=r,r"))]
683bdff7 6984 "TARGET_64BIT"
9ebbca7d
GK
6985 "@
6986 srad%I2. %3,%1,%H2
6987 #"
6988 [(set_attr "type" "delayed_compare")
6989 (set_attr "length" "4,8")])
6990
6991(define_split
6992 [(set (match_operand:CC 0 "cc_reg_not_cr0_operand" "")
6993 (compare:CC (ashiftrt:DI (match_operand:DI 1 "gpc_reg_operand" "")
6994 (match_operand:SI 2 "reg_or_cint_operand" ""))
6995 (const_int 0)))
6996 (clobber (match_scratch:DI 3 ""))]
6997 "TARGET_POWERPC64 && reload_completed"
6998 [(set (match_dup 3)
6999 (ashiftrt:DI (match_dup 1) (match_dup 2)))
7000 (set (match_dup 0)
7001 (compare:CC (match_dup 3)
7002 (const_int 0)))]
7003 "")
266eb58a 7004
e2c953b6 7005(define_insn "*ashrdi3_internal3"
9ebbca7d
GK
7006 [(set (match_operand:CC 3 "cc_reg_operand" "=x,?y")
7007 (compare:CC (ashiftrt:DI (match_operand:DI 1 "gpc_reg_operand" "r,r")
7008 (match_operand:SI 2 "reg_or_cint_operand" "ri,ri"))
266eb58a 7009 (const_int 0)))
9ebbca7d 7010 (set (match_operand:DI 0 "gpc_reg_operand" "=r,r")
266eb58a 7011 (ashiftrt:DI (match_dup 1) (match_dup 2)))]
683bdff7 7012 "TARGET_64BIT"
9ebbca7d
GK
7013 "@
7014 srad%I2. %0,%1,%H2
7015 #"
7016 [(set_attr "type" "delayed_compare")
7017 (set_attr "length" "4,8")])
7018
7019(define_split
7020 [(set (match_operand:CC 3 "cc_reg_not_cr0_operand" "")
7021 (compare:CC (ashiftrt:DI (match_operand:DI 1 "gpc_reg_operand" "")
7022 (match_operand:SI 2 "reg_or_cint_operand" ""))
7023 (const_int 0)))
7024 (set (match_operand:DI 0 "gpc_reg_operand" "")
7025 (ashiftrt:DI (match_dup 1) (match_dup 2)))]
7026 "TARGET_POWERPC64 && reload_completed"
7027 [(set (match_dup 0)
7028 (ashiftrt:DI (match_dup 1) (match_dup 2)))
7029 (set (match_dup 3)
7030 (compare:CC (match_dup 0)
7031 (const_int 0)))]
7032 "")
815cdc52 7033
29ae5b89 7034(define_insn "anddi3"
0ba1b2ff
AM
7035 [(set (match_operand:DI 0 "gpc_reg_operand" "=r,r,r,r,r")
7036 (and:DI (match_operand:DI 1 "gpc_reg_operand" "%r,r,r,r,r")
7037 (match_operand:DI 2 "and64_2_operand" "?r,S,K,J,t")))
7038 (clobber (match_scratch:CC 3 "=X,X,x,x,X"))]
6ffc8580 7039 "TARGET_POWERPC64"
266eb58a
DE
7040 "@
7041 and %0,%1,%2
29ae5b89
JL
7042 rldic%B2 %0,%1,0,%S2
7043 andi. %0,%1,%b2
0ba1b2ff
AM
7044 andis. %0,%1,%u2
7045 #"
7046 [(set_attr "length" "4,4,4,4,8")])
7047
7048(define_split
7049 [(set (match_operand:DI 0 "gpc_reg_operand" "")
7050 (and:DI (match_operand:DI 1 "gpc_reg_operand" "")
7051 (match_operand:DI 2 "mask64_2_operand" "")))
7052 (clobber (match_scratch:CC 3 ""))]
7053 "TARGET_POWERPC64
7054 && (fixed_regs[CR0_REGNO] || !logical_operand (operands[2], DImode))
7055 && !mask64_operand (operands[2], DImode)"
7056 [(set (match_dup 0)
7057 (and:DI (rotate:DI (match_dup 1)
7058 (match_dup 4))
7059 (match_dup 5)))
7060 (set (match_dup 0)
7061 (and:DI (rotate:DI (match_dup 0)
7062 (match_dup 6))
7063 (match_dup 7)))]
7064 "
7065{
7066 build_mask64_2_operands (operands[2], &operands[4]);
7067}")
266eb58a 7068
a260abc9 7069(define_insn "*anddi3_internal2"
0ba1b2ff
AM
7070 [(set (match_operand:CC 0 "cc_reg_operand" "=x,x,x,x,x,?y,?y,??y,??y,?y")
7071 (compare:CC (and:DI (match_operand:DI 1 "gpc_reg_operand" "%r,r,r,r,r,r,r,r,r,r")
7072 (match_operand:DI 2 "and64_2_operand" "r,S,K,J,t,r,S,K,J,t"))
266eb58a 7073 (const_int 0)))
0ba1b2ff
AM
7074 (clobber (match_scratch:DI 3 "=r,r,r,r,r,r,r,r,r,r"))
7075 (clobber (match_scratch:CC 4 "=X,X,X,X,X,X,X,x,x,X"))]
683bdff7 7076 "TARGET_64BIT"
266eb58a
DE
7077 "@
7078 and. %3,%1,%2
6c873122 7079 rldic%B2. %3,%1,0,%S2
6ffc8580
MM
7080 andi. %3,%1,%b2
7081 andis. %3,%1,%u2
9ebbca7d
GK
7082 #
7083 #
7084 #
0ba1b2ff
AM
7085 #
7086 #
9ebbca7d 7087 #"
0ba1b2ff
AM
7088 [(set_attr "type" "compare,delayed_compare,compare,compare,delayed_compare,compare,compare,compare,compare,compare")
7089 (set_attr "length" "4,4,4,4,8,8,8,8,8,12")])
9ebbca7d
GK
7090
7091(define_split
7092 [(set (match_operand:CC 0 "cc_reg_not_cr0_operand" "")
7093 (compare:CC (and:DI (match_operand:DI 1 "gpc_reg_operand" "")
7094 (match_operand:DI 2 "and64_operand" ""))
7095 (const_int 0)))
7096 (clobber (match_scratch:DI 3 ""))
7097 (clobber (match_scratch:CC 4 ""))]
7098 "TARGET_POWERPC64 && reload_completed"
7099 [(parallel [(set (match_dup 3)
7100 (and:DI (match_dup 1)
7101 (match_dup 2)))
7102 (clobber (match_dup 4))])
7103 (set (match_dup 0)
7104 (compare:CC (match_dup 3)
7105 (const_int 0)))]
7106 "")
266eb58a 7107
0ba1b2ff
AM
7108(define_split
7109 [(set (match_operand:CC 0 "cc_reg_operand" "")
7110 (compare:CC (and:DI (match_operand:DI 1 "gpc_reg_operand" "")
7111 (match_operand:DI 2 "mask64_2_operand" ""))
7112 (const_int 0)))
7113 (clobber (match_scratch:DI 3 ""))
7114 (clobber (match_scratch:CC 4 ""))]
7115 "TARGET_POWERPC64 && reload_completed
7116 && (fixed_regs[CR0_REGNO] || !logical_operand (operands[2], DImode))
7117 && !mask64_operand (operands[2], DImode)"
7118 [(set (match_dup 3)
7119 (and:DI (rotate:DI (match_dup 1)
7120 (match_dup 5))
7121 (match_dup 6)))
7122 (parallel [(set (match_dup 0)
7123 (compare:CC (and:DI (rotate:DI (match_dup 3)
7124 (match_dup 7))
7125 (match_dup 8))
7126 (const_int 0)))
7127 (clobber (match_dup 3))])]
7128 "
7129{
7130 build_mask64_2_operands (operands[2], &operands[5]);
7131}")
7132
a260abc9 7133(define_insn "*anddi3_internal3"
0ba1b2ff
AM
7134 [(set (match_operand:CC 3 "cc_reg_operand" "=x,x,x,x,x,?y,?y,??y,??y,?y")
7135 (compare:CC (and:DI (match_operand:DI 1 "gpc_reg_operand" "%r,r,r,r,r,r,r,r,r,r")
7136 (match_operand:DI 2 "and64_2_operand" "r,S,K,J,t,r,S,K,J,t"))
266eb58a 7137 (const_int 0)))
0ba1b2ff 7138 (set (match_operand:DI 0 "gpc_reg_operand" "=r,r,r,r,r,r,r,r,r,r")
9ebbca7d 7139 (and:DI (match_dup 1) (match_dup 2)))
0ba1b2ff 7140 (clobber (match_scratch:CC 4 "=X,X,X,X,X,X,X,x,x,X"))]
683bdff7 7141 "TARGET_64BIT"
266eb58a
DE
7142 "@
7143 and. %0,%1,%2
6c873122 7144 rldic%B2. %0,%1,0,%S2
6ffc8580
MM
7145 andi. %0,%1,%b2
7146 andis. %0,%1,%u2
9ebbca7d
GK
7147 #
7148 #
7149 #
0ba1b2ff
AM
7150 #
7151 #
9ebbca7d 7152 #"
0ba1b2ff
AM
7153 [(set_attr "type" "compare,delayed_compare,compare,compare,delayed_compare,compare,compare,compare,compare,compare")
7154 (set_attr "length" "4,4,4,4,8,8,8,8,8,12")])
9ebbca7d
GK
7155
7156(define_split
7157 [(set (match_operand:CC 3 "cc_reg_not_cr0_operand" "")
7158 (compare:CC (and:DI (match_operand:DI 1 "gpc_reg_operand" "")
7159 (match_operand:DI 2 "and64_operand" ""))
7160 (const_int 0)))
7161 (set (match_operand:DI 0 "gpc_reg_operand" "")
7162 (and:DI (match_dup 1) (match_dup 2)))
7163 (clobber (match_scratch:CC 4 ""))]
7164 "TARGET_POWERPC64 && reload_completed"
7165 [(parallel [(set (match_dup 0)
7166 (and:DI (match_dup 1) (match_dup 2)))
7167 (clobber (match_dup 4))])
7168 (set (match_dup 3)
7169 (compare:CC (match_dup 0)
7170 (const_int 0)))]
7171 "")
266eb58a 7172
0ba1b2ff
AM
7173(define_split
7174 [(set (match_operand:CC 3 "cc_reg_operand" "")
7175 (compare:CC (and:DI (match_operand:DI 1 "gpc_reg_operand" "")
7176 (match_operand:DI 2 "mask64_2_operand" ""))
7177 (const_int 0)))
7178 (set (match_operand:DI 0 "gpc_reg_operand" "")
7179 (and:DI (match_dup 1) (match_dup 2)))
7180 (clobber (match_scratch:CC 4 ""))]
7181 "TARGET_POWERPC64 && reload_completed
7182 && (fixed_regs[CR0_REGNO] || !logical_operand (operands[2], DImode))
7183 && !mask64_operand (operands[2], DImode)"
7184 [(set (match_dup 0)
7185 (and:DI (rotate:DI (match_dup 1)
7186 (match_dup 5))
7187 (match_dup 6)))
7188 (parallel [(set (match_dup 3)
7189 (compare:CC (and:DI (rotate:DI (match_dup 0)
7190 (match_dup 7))
7191 (match_dup 8))
7192 (const_int 0)))
7193 (set (match_dup 0)
7194 (and:DI (rotate:DI (match_dup 0)
7195 (match_dup 7))
7196 (match_dup 8)))])]
7197 "
7198{
7199 build_mask64_2_operands (operands[2], &operands[5]);
7200}")
7201
a260abc9 7202(define_expand "iordi3"
266eb58a 7203 [(set (match_operand:DI 0 "gpc_reg_operand" "")
a260abc9 7204 (ior:DI (match_operand:DI 1 "gpc_reg_operand" "")
1d328b19 7205 (match_operand:DI 2 "reg_or_logical_cint_operand" "")))]
266eb58a 7206 "TARGET_POWERPC64"
266eb58a
DE
7207 "
7208{
dfbdccdb 7209 if (non_logical_cint_operand (operands[2], DImode))
266eb58a 7210 {
dfbdccdb 7211 HOST_WIDE_INT value;
677a9668 7212 rtx tmp = ((no_new_pseudos || rtx_equal_p (operands[0], operands[1]))
a260abc9 7213 ? operands[0] : gen_reg_rtx (DImode));
266eb58a 7214
dfbdccdb
GK
7215 if (GET_CODE (operands[2]) == CONST_INT)
7216 {
7217 value = INTVAL (operands[2]);
7218 emit_insn (gen_iordi3 (tmp, operands[1],
7219 GEN_INT (value & (~ (HOST_WIDE_INT) 0xffff))));
7220 }
e2c953b6 7221 else
dfbdccdb
GK
7222 {
7223 value = CONST_DOUBLE_LOW (operands[2]);
7224 emit_insn (gen_iordi3 (tmp, operands[1],
7225 immed_double_const (value
7226 & (~ (HOST_WIDE_INT) 0xffff),
7227 0, DImode)));
7228 }
e2c953b6 7229
9ebbca7d
GK
7230 emit_insn (gen_iordi3 (operands[0], tmp, GEN_INT (value & 0xffff)));
7231 DONE;
7232 }
266eb58a
DE
7233}")
7234
a260abc9
DE
7235(define_expand "xordi3"
7236 [(set (match_operand:DI 0 "gpc_reg_operand" "")
7237 (xor:DI (match_operand:DI 1 "gpc_reg_operand" "")
1d328b19 7238 (match_operand:DI 2 "reg_or_logical_cint_operand" "")))]
a260abc9
DE
7239 "TARGET_POWERPC64"
7240 "
7241{
dfbdccdb 7242 if (non_logical_cint_operand (operands[2], DImode))
a260abc9 7243 {
dfbdccdb 7244 HOST_WIDE_INT value;
677a9668 7245 rtx tmp = ((no_new_pseudos || rtx_equal_p (operands[0], operands[1]))
a260abc9
DE
7246 ? operands[0] : gen_reg_rtx (DImode));
7247
dfbdccdb
GK
7248 if (GET_CODE (operands[2]) == CONST_INT)
7249 {
7250 value = INTVAL (operands[2]);
7251 emit_insn (gen_xordi3 (tmp, operands[1],
7252 GEN_INT (value & (~ (HOST_WIDE_INT) 0xffff))));
7253 }
e2c953b6 7254 else
dfbdccdb
GK
7255 {
7256 value = CONST_DOUBLE_LOW (operands[2]);
7257 emit_insn (gen_xordi3 (tmp, operands[1],
7258 immed_double_const (value
7259 & (~ (HOST_WIDE_INT) 0xffff),
7260 0, DImode)));
7261 }
e2c953b6 7262
9ebbca7d
GK
7263 emit_insn (gen_xordi3 (operands[0], tmp, GEN_INT (value & 0xffff)));
7264 DONE;
7265 }
a260abc9
DE
7266}")
7267
dfbdccdb 7268(define_insn "*booldi3_internal1"
266eb58a 7269 [(set (match_operand:DI 0 "gpc_reg_operand" "=r,r,r")
1d328b19 7270 (match_operator:DI 3 "boolean_or_operator"
dfbdccdb
GK
7271 [(match_operand:DI 1 "gpc_reg_operand" "%r,r,r")
7272 (match_operand:DI 2 "logical_operand" "r,K,JF")]))]
266eb58a 7273 "TARGET_POWERPC64"
1fd4e8c1 7274 "@
dfbdccdb
GK
7275 %q3 %0,%1,%2
7276 %q3i %0,%1,%b2
7277 %q3is %0,%1,%u2")
1fd4e8c1 7278
dfbdccdb 7279(define_insn "*booldi3_internal2"
9ebbca7d 7280 [(set (match_operand:CC 0 "cc_reg_operand" "=x,?y")
1d328b19 7281 (compare:CC (match_operator:DI 4 "boolean_or_operator"
dfbdccdb
GK
7282 [(match_operand:DI 1 "gpc_reg_operand" "%r,r")
7283 (match_operand:DI 2 "gpc_reg_operand" "r,r")])
7284 (const_int 0)))
9ebbca7d 7285 (clobber (match_scratch:DI 3 "=r,r"))]
683bdff7 7286 "TARGET_64BIT"
9ebbca7d 7287 "@
dfbdccdb 7288 %q4. %3,%1,%2
9ebbca7d
GK
7289 #"
7290 [(set_attr "type" "compare")
7291 (set_attr "length" "4,8")])
7292
7293(define_split
7294 [(set (match_operand:CC 0 "cc_reg_not_cr0_operand" "")
dfbdccdb 7295 (compare:CC (match_operator:DI 4 "boolean_operator"
75540af0
JH
7296 [(match_operand:DI 1 "gpc_reg_operand" "")
7297 (match_operand:DI 2 "gpc_reg_operand" "")])
dfbdccdb 7298 (const_int 0)))
9ebbca7d
GK
7299 (clobber (match_scratch:DI 3 ""))]
7300 "TARGET_POWERPC64 && reload_completed"
dfbdccdb 7301 [(set (match_dup 3) (match_dup 4))
9ebbca7d
GK
7302 (set (match_dup 0)
7303 (compare:CC (match_dup 3)
7304 (const_int 0)))]
7305 "")
1fd4e8c1 7306
dfbdccdb 7307(define_insn "*booldi3_internal3"
9ebbca7d 7308 [(set (match_operand:CC 3 "cc_reg_operand" "=x,?y")
dfbdccdb
GK
7309 (compare:CC (match_operator:DI 4 "boolean_operator"
7310 [(match_operand:DI 1 "gpc_reg_operand" "%r,r")
7311 (match_operand:DI 2 "gpc_reg_operand" "r,r")])
7312 (const_int 0)))
9ebbca7d 7313 (set (match_operand:DI 0 "gpc_reg_operand" "=r,r")
dfbdccdb 7314 (match_dup 4))]
683bdff7 7315 "TARGET_64BIT"
9ebbca7d 7316 "@
dfbdccdb 7317 %q4. %0,%1,%2
9ebbca7d
GK
7318 #"
7319 [(set_attr "type" "compare")
7320 (set_attr "length" "4,8")])
7321
7322(define_split
e72247f4 7323 [(set (match_operand:CC 3 "cc_reg_not_cr0_operand" "")
dfbdccdb 7324 (compare:CC (match_operator:DI 4 "boolean_operator"
75540af0
JH
7325 [(match_operand:DI 1 "gpc_reg_operand" "")
7326 (match_operand:DI 2 "gpc_reg_operand" "")])
dfbdccdb 7327 (const_int 0)))
75540af0 7328 (set (match_operand:DI 0 "gpc_reg_operand" "")
dfbdccdb 7329 (match_dup 4))]
9ebbca7d 7330 "TARGET_POWERPC64 && reload_completed"
dfbdccdb 7331 [(set (match_dup 0) (match_dup 4))
9ebbca7d
GK
7332 (set (match_dup 3)
7333 (compare:CC (match_dup 0)
7334 (const_int 0)))]
7335 "")
1fd4e8c1 7336
5bdc5878 7337;; Split a logical operation that we can't do in one insn into two insns,
dfbdccdb 7338;; each of which does one 16-bit part. This is used by combine.
266eb58a
DE
7339
7340(define_split
7341 [(set (match_operand:DI 0 "gpc_reg_operand" "")
1d328b19 7342 (match_operator:DI 3 "boolean_or_operator"
dfbdccdb
GK
7343 [(match_operand:DI 1 "gpc_reg_operand" "")
7344 (match_operand:DI 2 "non_logical_cint_operand" "")]))]
266eb58a 7345 "TARGET_POWERPC64"
dfbdccdb
GK
7346 [(set (match_dup 0) (match_dup 4))
7347 (set (match_dup 0) (match_dup 5))]
266eb58a
DE
7348"
7349{
dfbdccdb
GK
7350 rtx i3,i4;
7351
9ebbca7d
GK
7352 if (GET_CODE (operands[2]) == CONST_DOUBLE)
7353 {
7354 HOST_WIDE_INT value = CONST_DOUBLE_LOW (operands[2]);
dfbdccdb 7355 i3 = immed_double_const (value & (~ (HOST_WIDE_INT) 0xffff),
9ebbca7d 7356 0, DImode);
dfbdccdb 7357 i4 = GEN_INT (value & 0xffff);
9ebbca7d
GK
7358 }
7359 else
7360 {
dfbdccdb 7361 i3 = GEN_INT (INTVAL (operands[2])
9ebbca7d 7362 & (~ (HOST_WIDE_INT) 0xffff));
dfbdccdb 7363 i4 = GEN_INT (INTVAL (operands[2]) & 0xffff);
9ebbca7d 7364 }
dfbdccdb
GK
7365 operands[4] = gen_rtx (GET_CODE (operands[3]), DImode,
7366 operands[1], i3);
7367 operands[5] = gen_rtx (GET_CODE (operands[3]), DImode,
7368 operands[0], i4);
1fd4e8c1
RK
7369}")
7370
dfbdccdb 7371(define_insn "*boolcdi3_internal1"
9ebbca7d 7372 [(set (match_operand:DI 0 "gpc_reg_operand" "=r")
dfbdccdb
GK
7373 (match_operator:DI 3 "boolean_operator"
7374 [(not:DI (match_operand:DI 1 "gpc_reg_operand" "r"))
40501e5f 7375 (match_operand:DI 2 "gpc_reg_operand" "r")]))]
a473029f 7376 "TARGET_POWERPC64"
1d328b19 7377 "%q3 %0,%2,%1")
a473029f 7378
dfbdccdb 7379(define_insn "*boolcdi3_internal2"
9ebbca7d 7380 [(set (match_operand:CC 0 "cc_reg_operand" "=x,?y")
dfbdccdb
GK
7381 (compare:CC (match_operator:DI 4 "boolean_operator"
7382 [(not:DI (match_operand:DI 1 "gpc_reg_operand" "r,r"))
7383 (match_operand:DI 2 "gpc_reg_operand" "r,r")])
7384 (const_int 0)))
9ebbca7d 7385 (clobber (match_scratch:DI 3 "=r,r"))]
683bdff7 7386 "TARGET_64BIT"
9ebbca7d 7387 "@
1d328b19 7388 %q4. %3,%2,%1
9ebbca7d
GK
7389 #"
7390 [(set_attr "type" "compare")
7391 (set_attr "length" "4,8")])
7392
7393(define_split
7394 [(set (match_operand:CC 0 "cc_reg_not_cr0_operand" "")
dfbdccdb 7395 (compare:CC (match_operator:DI 4 "boolean_operator"
75540af0
JH
7396 [(not:DI (match_operand:DI 1 "gpc_reg_operand" ""))
7397 (match_operand:DI 2 "gpc_reg_operand" "")])
dfbdccdb 7398 (const_int 0)))
9ebbca7d
GK
7399 (clobber (match_scratch:DI 3 ""))]
7400 "TARGET_POWERPC64 && reload_completed"
dfbdccdb 7401 [(set (match_dup 3) (match_dup 4))
9ebbca7d
GK
7402 (set (match_dup 0)
7403 (compare:CC (match_dup 3)
7404 (const_int 0)))]
7405 "")
a473029f 7406
dfbdccdb 7407(define_insn "*boolcdi3_internal3"
9ebbca7d 7408 [(set (match_operand:CC 3 "cc_reg_operand" "=x,?y")
dfbdccdb
GK
7409 (compare:CC (match_operator:DI 4 "boolean_operator"
7410 [(not:DI (match_operand:DI 1 "gpc_reg_operand" "%r,r"))
7411 (match_operand:DI 2 "gpc_reg_operand" "r,r")])
7412 (const_int 0)))
9ebbca7d 7413 (set (match_operand:DI 0 "gpc_reg_operand" "=r,r")
dfbdccdb 7414 (match_dup 4))]
683bdff7 7415 "TARGET_64BIT"
9ebbca7d 7416 "@
1d328b19 7417 %q4. %0,%2,%1
9ebbca7d
GK
7418 #"
7419 [(set_attr "type" "compare")
7420 (set_attr "length" "4,8")])
7421
7422(define_split
e72247f4 7423 [(set (match_operand:CC 3 "cc_reg_not_cr0_operand" "")
dfbdccdb 7424 (compare:CC (match_operator:DI 4 "boolean_operator"
75540af0
JH
7425 [(not:DI (match_operand:DI 1 "gpc_reg_operand" ""))
7426 (match_operand:DI 2 "gpc_reg_operand" "")])
dfbdccdb 7427 (const_int 0)))
75540af0 7428 (set (match_operand:DI 0 "gpc_reg_operand" "")
dfbdccdb 7429 (match_dup 4))]
9ebbca7d 7430 "TARGET_POWERPC64 && reload_completed"
dfbdccdb 7431 [(set (match_dup 0) (match_dup 4))
9ebbca7d
GK
7432 (set (match_dup 3)
7433 (compare:CC (match_dup 0)
7434 (const_int 0)))]
7435 "")
266eb58a 7436
dfbdccdb 7437(define_insn "*boolccdi3_internal1"
a473029f 7438 [(set (match_operand:DI 0 "gpc_reg_operand" "=r")
dfbdccdb
GK
7439 (match_operator:DI 3 "boolean_operator"
7440 [(not:DI (match_operand:DI 1 "gpc_reg_operand" "r"))
40501e5f 7441 (not:DI (match_operand:DI 2 "gpc_reg_operand" "r"))]))]
a473029f 7442 "TARGET_POWERPC64"
dfbdccdb 7443 "%q3 %0,%1,%2")
a473029f 7444
dfbdccdb 7445(define_insn "*boolccdi3_internal2"
9ebbca7d 7446 [(set (match_operand:CC 0 "cc_reg_operand" "=x,?y")
dfbdccdb
GK
7447 (compare:CC (match_operator:DI 4 "boolean_operator"
7448 [(not:DI (match_operand:DI 1 "gpc_reg_operand" "r,r"))
7449 (not:DI (match_operand:DI 2 "gpc_reg_operand" "r,r"))])
7450 (const_int 0)))
9ebbca7d 7451 (clobber (match_scratch:DI 3 "=r,r"))]
683bdff7 7452 "TARGET_64BIT"
9ebbca7d 7453 "@
dfbdccdb 7454 %q4. %3,%1,%2
9ebbca7d
GK
7455 #"
7456 [(set_attr "type" "compare")
7457 (set_attr "length" "4,8")])
7458
7459(define_split
7460 [(set (match_operand:CC 0 "cc_reg_not_cr0_operand" "")
dfbdccdb 7461 (compare:CC (match_operator:DI 4 "boolean_operator"
75540af0
JH
7462 [(not:DI (match_operand:DI 1 "gpc_reg_operand" ""))
7463 (not:DI (match_operand:DI 2 "gpc_reg_operand" ""))])
dfbdccdb 7464 (const_int 0)))
9ebbca7d
GK
7465 (clobber (match_scratch:DI 3 ""))]
7466 "TARGET_POWERPC64 && reload_completed"
dfbdccdb 7467 [(set (match_dup 3) (match_dup 4))
9ebbca7d
GK
7468 (set (match_dup 0)
7469 (compare:CC (match_dup 3)
7470 (const_int 0)))]
7471 "")
266eb58a 7472
dfbdccdb 7473(define_insn "*boolccdi3_internal3"
9ebbca7d 7474 [(set (match_operand:CC 3 "cc_reg_operand" "=x,?y")
dfbdccdb
GK
7475 (compare:CC (match_operator:DI 4 "boolean_operator"
7476 [(not:DI (match_operand:DI 1 "gpc_reg_operand" "%r,r"))
7477 (not:DI (match_operand:DI 2 "gpc_reg_operand" "r,r"))])
7478 (const_int 0)))
9ebbca7d 7479 (set (match_operand:DI 0 "gpc_reg_operand" "=r,r")
dfbdccdb 7480 (match_dup 4))]
683bdff7 7481 "TARGET_64BIT"
9ebbca7d 7482 "@
dfbdccdb 7483 %q4. %0,%1,%2
9ebbca7d
GK
7484 #"
7485 [(set_attr "type" "compare")
7486 (set_attr "length" "4,8")])
7487
7488(define_split
e72247f4 7489 [(set (match_operand:CC 3 "cc_reg_not_cr0_operand" "")
dfbdccdb 7490 (compare:CC (match_operator:DI 4 "boolean_operator"
75540af0
JH
7491 [(not:DI (match_operand:DI 1 "gpc_reg_operand" ""))
7492 (not:DI (match_operand:DI 2 "gpc_reg_operand" ""))])
dfbdccdb 7493 (const_int 0)))
75540af0 7494 (set (match_operand:DI 0 "gpc_reg_operand" "")
dfbdccdb 7495 (match_dup 4))]
9ebbca7d 7496 "TARGET_POWERPC64 && reload_completed"
dfbdccdb 7497 [(set (match_dup 0) (match_dup 4))
9ebbca7d
GK
7498 (set (match_dup 3)
7499 (compare:CC (match_dup 0)
7500 (const_int 0)))]
7501 "")
dfbdccdb 7502\f
1fd4e8c1 7503;; Now define ways of moving data around.
4697a36c
MM
7504
7505;; Elf specific ways of loading addresses for non-PIC code.
9ebbca7d
GK
7506;; The output of this could be r0, but we make a very strong
7507;; preference for a base register because it will usually
7508;; be needed there.
4697a36c 7509(define_insn "elf_high"
9ebbca7d 7510 [(set (match_operand:SI 0 "gpc_reg_operand" "=b*r")
4697a36c 7511 (high:SI (match_operand 1 "" "")))]
0ad91047 7512 "TARGET_ELF && ! TARGET_64BIT"
a6c2a102 7513 "{liu|lis} %0,%1@ha")
4697a36c
MM
7514
7515(define_insn "elf_low"
9ebbca7d
GK
7516 [(set (match_operand:SI 0 "gpc_reg_operand" "=r,r")
7517 (lo_sum:SI (match_operand:SI 1 "gpc_reg_operand" "b,!*r")
4697a36c 7518 (match_operand 2 "" "")))]
0ad91047 7519 "TARGET_ELF && ! TARGET_64BIT"
9ebbca7d
GK
7520 "@
7521 {cal|la} %0,%2@l(%1)
81eace42 7522 {ai|addic} %0,%1,%K2")
4697a36c 7523
ee890fe2
SS
7524;; Mach-O PIC trickery.
7525(define_insn "macho_high"
7526 [(set (match_operand:SI 0 "gpc_reg_operand" "=b*r")
7527 (high:SI (match_operand 1 "" "")))]
7528 "TARGET_MACHO && ! TARGET_64BIT"
7529 "{liu|lis} %0,ha16(%1)")
7530
7531(define_insn "macho_low"
7532 [(set (match_operand:SI 0 "gpc_reg_operand" "=r,r")
7533 (lo_sum:SI (match_operand:SI 1 "gpc_reg_operand" "b,!*r")
7534 (match_operand 2 "" "")))]
7535 "TARGET_MACHO && ! TARGET_64BIT"
7536 "@
7537 {cal %0,%a2@l(%1)|la %0,lo16(%2)(%1)}
7538 {cal %0,%a2@l(%1)|addic %0,%1,lo16(%2)}")
7539
766a866c
MM
7540;; Set up a register with a value from the GOT table
7541
7542(define_expand "movsi_got"
52d3af72 7543 [(set (match_operand:SI 0 "gpc_reg_operand" "")
9ebbca7d 7544 (unspec:SI [(match_operand:SI 1 "got_operand" "")
615158e2 7545 (match_dup 2)] UNSPEC_MOVSI_GOT))]
f607bc57 7546 "DEFAULT_ABI == ABI_V4 && flag_pic == 1"
766a866c
MM
7547 "
7548{
38c1f2d7
MM
7549 if (GET_CODE (operands[1]) == CONST)
7550 {
7551 rtx offset = const0_rtx;
7552 HOST_WIDE_INT value;
7553
7554 operands[1] = eliminate_constant_term (XEXP (operands[1], 0), &offset);
7555 value = INTVAL (offset);
7556 if (value != 0)
7557 {
677a9668 7558 rtx tmp = (no_new_pseudos ? operands[0] : gen_reg_rtx (Pmode));
38c1f2d7
MM
7559 emit_insn (gen_movsi_got (tmp, operands[1]));
7560 emit_insn (gen_addsi3 (operands[0], tmp, offset));
7561 DONE;
7562 }
7563 }
7564
c4c40373 7565 operands[2] = rs6000_got_register (operands[1]);
766a866c
MM
7566}")
7567
84f414bc 7568(define_insn "*movsi_got_internal"
52d3af72 7569 [(set (match_operand:SI 0 "gpc_reg_operand" "=r")
9ebbca7d 7570 (unspec:SI [(match_operand:SI 1 "got_no_const_operand" "")
615158e2
JJ
7571 (match_operand:SI 2 "gpc_reg_operand" "b")]
7572 UNSPEC_MOVSI_GOT))]
f607bc57 7573 "DEFAULT_ABI == ABI_V4 && flag_pic == 1"
766a866c
MM
7574 "{l|lwz} %0,%a1@got(%2)"
7575 [(set_attr "type" "load")])
7576
b22b9b3e
JL
7577;; Used by sched, shorten_branches and final when the GOT pseudo reg
7578;; didn't get allocated to a hard register.
7579(define_split
75540af0 7580 [(set (match_operand:SI 0 "gpc_reg_operand" "")
9ebbca7d 7581 (unspec:SI [(match_operand:SI 1 "got_no_const_operand" "")
615158e2
JJ
7582 (match_operand:SI 2 "memory_operand" "")]
7583 UNSPEC_MOVSI_GOT))]
f607bc57 7584 "DEFAULT_ABI == ABI_V4
b22b9b3e
JL
7585 && flag_pic == 1
7586 && (reload_in_progress || reload_completed)"
7587 [(set (match_dup 0) (match_dup 2))
615158e2
JJ
7588 (set (match_dup 0) (unspec:SI [(match_dup 1)(match_dup 0)]
7589 UNSPEC_MOVSI_GOT))]
b22b9b3e
JL
7590 "")
7591
1fd4e8c1
RK
7592;; For SI, we special-case integers that can't be loaded in one insn. We
7593;; do the load 16-bits at a time. We could do this by loading from memory,
7594;; and this is even supposed to be faster, but it is simpler not to get
7595;; integers in the TOC.
7596(define_expand "movsi"
7597 [(set (match_operand:SI 0 "general_operand" "")
7598 (match_operand:SI 1 "any_operand" ""))]
7599 ""
fb4d4348 7600 "{ rs6000_emit_move (operands[0], operands[1], SImode); DONE; }")
1fd4e8c1 7601
ee890fe2
SS
7602(define_insn "movsi_low"
7603 [(set (match_operand:SI 0 "gpc_reg_operand" "=r")
f585a356 7604 (mem:SI (lo_sum:SI (match_operand:SI 1 "gpc_reg_operand" "b")
ee890fe2
SS
7605 (match_operand 2 "" ""))))]
7606 "TARGET_MACHO && ! TARGET_64BIT"
7607 "{l|lwz} %0,lo16(%2)(%1)"
7608 [(set_attr "type" "load")
7609 (set_attr "length" "4")])
7610
c859cda6 7611(define_insn "movsi_low_st"
f585a356 7612 [(set (mem:SI (lo_sum:SI (match_operand:SI 1 "gpc_reg_operand" "b")
c859cda6
DJ
7613 (match_operand 2 "" "")))
7614 (match_operand:SI 0 "gpc_reg_operand" "r"))]
7615 "TARGET_MACHO && ! TARGET_64BIT"
7616 "{st|stw} %0,lo16(%2)(%1)"
7617 [(set_attr "type" "store")
7618 (set_attr "length" "4")])
7619
7620(define_insn "movdf_low"
234e114c 7621 [(set (match_operand:DF 0 "gpc_reg_operand" "=f,!r")
f585a356 7622 (mem:DF (lo_sum:SI (match_operand:SI 1 "gpc_reg_operand" "b,b")
c859cda6 7623 (match_operand 2 "" ""))))]
a3170dc6 7624 "TARGET_MACHO && TARGET_HARD_FLOAT && TARGET_FPRS && ! TARGET_64BIT"
234e114c
DJ
7625 "*
7626{
7627 switch (which_alternative)
7628 {
7629 case 0:
7630 return \"lfd %0,lo16(%2)(%1)\";
7631 case 1:
7632 {
7633 rtx operands2[4];
7634 operands2[0] = operands[0];
7635 operands2[1] = operands[1];
7636 operands2[2] = operands[2];
683bdff7
FJ
7637 if (TARGET_POWERPC64 && TARGET_32BIT)
7638 /* Note, old assemblers didn't support relocation here. */
7639 return \"ld %0,lo16(%2)(%1)\";
ab82a49f 7640 else
683bdff7
FJ
7641 {
7642 operands2[3] = gen_rtx_REG (SImode, RS6000_PIC_OFFSET_TABLE_REGNUM);
7643 output_asm_insn (\"{l|lwz} %0,lo16(%2)(%1)\", operands);
7644#if TARGET_MACHO
7645 if (MACHO_DYNAMIC_NO_PIC_P)
7646 output_asm_insn (\"{liu|lis} %L0,ha16(%2+4)\", operands);
7647 else
7648 /* We cannot rely on ha16(low half)==ha16(high half), alas,
7649 although in practice it almost always is. */
7650 output_asm_insn (\"{cau|addis} %L0,%3,ha16(%2+4)\", operands2);
ab82a49f 7651#endif
683bdff7
FJ
7652 return (\"{l|lwz} %L0,lo16(%2+4)(%L0)\");
7653 }
234e114c
DJ
7654 }
7655 default:
7656 abort();
7657 }
7658}"
c859cda6 7659 [(set_attr "type" "load")
234e114c 7660 (set_attr "length" "4,12")])
c859cda6
DJ
7661
7662(define_insn "movdf_low_st"
f585a356 7663 [(set (mem:DF (lo_sum:SI (match_operand:SI 1 "gpc_reg_operand" "b")
c859cda6
DJ
7664 (match_operand 2 "" "")))
7665 (match_operand:DF 0 "gpc_reg_operand" "f"))]
a3170dc6 7666 "TARGET_MACHO && TARGET_HARD_FLOAT && TARGET_FPRS && ! TARGET_64BIT"
c859cda6
DJ
7667 "stfd %0,lo16(%2)(%1)"
7668 [(set_attr "type" "store")
7669 (set_attr "length" "4")])
7670
7671(define_insn "movsf_low"
fd3b43f2 7672 [(set (match_operand:SF 0 "gpc_reg_operand" "=f,!r")
f585a356 7673 (mem:SF (lo_sum:SI (match_operand:SI 1 "gpc_reg_operand" "b,b")
c859cda6 7674 (match_operand 2 "" ""))))]
a3170dc6 7675 "TARGET_MACHO && TARGET_HARD_FLOAT && TARGET_FPRS && ! TARGET_64BIT"
fd3b43f2
DJ
7676 "@
7677 lfs %0,lo16(%2)(%1)
7678 {l|lwz} %0,lo16(%2)(%1)"
c859cda6
DJ
7679 [(set_attr "type" "load")
7680 (set_attr "length" "4")])
7681
7682(define_insn "movsf_low_st"
f585a356 7683 [(set (mem:SF (lo_sum:SI (match_operand:SI 1 "gpc_reg_operand" "b,b")
c859cda6 7684 (match_operand 2 "" "")))
fd3b43f2 7685 (match_operand:SF 0 "gpc_reg_operand" "f,!r"))]
a3170dc6 7686 "TARGET_MACHO && TARGET_HARD_FLOAT && TARGET_FPRS && ! TARGET_64BIT"
fd3b43f2
DJ
7687 "@
7688 stfs %0,lo16(%2)(%1)
7689 {st|stw} %0,lo16(%2)(%1)"
c859cda6
DJ
7690 [(set_attr "type" "store")
7691 (set_attr "length" "4")])
7692
acad7ed3 7693(define_insn "*movsi_internal1"
a004eb82
AH
7694 [(set (match_operand:SI 0 "nonimmediate_operand" "=r,r,r,m,r,r,r,r,r,*q,*c*l,*h,*h")
7695 (match_operand:SI 1 "input_operand" "r,U,m,r,I,L,n,R,*h,r,r,r,0"))]
19d5775a
RK
7696 "gpc_reg_operand (operands[0], SImode)
7697 || gpc_reg_operand (operands[1], SImode)"
1fd4e8c1 7698 "@
deb9225a 7699 mr %0,%1
b9442c72 7700 {cal|la} %0,%a1
ca7f5001
RK
7701 {l%U1%X1|lwz%U1%X1} %0,%1
7702 {st%U0%X0|stw%U0%X0} %1,%0
19d5775a 7703 {lil|li} %0,%1
802a0058 7704 {liu|lis} %0,%v1
beaec479 7705 #
aee86b38 7706 {cal|la} %0,%a1
1fd4e8c1 7707 mf%1 %0
5c23c401 7708 mt%0 %1
e76e75bb 7709 mt%0 %1
a004eb82 7710 mt%0 %1
e34eaae5 7711 {cror 0,0,0|nop}"
02ca7595 7712 [(set_attr "type" "*,*,load,store,*,*,*,*,mfjmpr,*,mtjmpr,*,*")
a004eb82 7713 (set_attr "length" "4,4,4,4,4,4,8,4,4,4,4,4,4")])
1fd4e8c1 7714
77fa0940
RK
7715;; Split a load of a large constant into the appropriate two-insn
7716;; sequence.
7717
7718(define_split
7719 [(set (match_operand:SI 0 "gpc_reg_operand" "")
7720 (match_operand:SI 1 "const_int_operand" ""))]
bb21487f 7721 "(unsigned HOST_WIDE_INT) (INTVAL (operands[1]) + 0x8000) >= 0x10000
77fa0940
RK
7722 && (INTVAL (operands[1]) & 0xffff) != 0"
7723 [(set (match_dup 0)
7724 (match_dup 2))
7725 (set (match_dup 0)
7726 (ior:SI (match_dup 0)
7727 (match_dup 3)))]
7728 "
af8cb5c5
DE
7729{ rtx tem = rs6000_emit_set_const (operands[0], SImode, operands[1], 2);
7730
7731 if (tem == operands[0])
7732 DONE;
7733 else
7734 FAIL;
77fa0940
RK
7735}")
7736
acad7ed3 7737(define_insn "*movsi_internal2"
bb84cb12
DE
7738 [(set (match_operand:CC 2 "cc_reg_operand" "=y,x,?y")
7739 (compare:CC (match_operand:SI 1 "gpc_reg_operand" "0,r,r")
1fd4e8c1 7740 (const_int 0)))
bb84cb12 7741 (set (match_operand:SI 0 "gpc_reg_operand" "=r,r,r") (match_dup 1))]
0ad91047 7742 "! TARGET_POWERPC64"
9ebbca7d 7743 "@
bb84cb12 7744 {cmpi|cmpwi} %2,%0,0
9ebbca7d
GK
7745 mr. %0,%1
7746 #"
bb84cb12
DE
7747 [(set_attr "type" "cmp,compare,cmp")
7748 (set_attr "length" "4,4,8")])
7749
9ebbca7d
GK
7750(define_split
7751 [(set (match_operand:CC 2 "cc_reg_not_cr0_operand" "")
7752 (compare:CC (match_operand:SI 1 "gpc_reg_operand" "")
7753 (const_int 0)))
7754 (set (match_operand:SI 0 "gpc_reg_operand" "") (match_dup 1))]
7755 "! TARGET_POWERPC64 && reload_completed"
7756 [(set (match_dup 0) (match_dup 1))
7757 (set (match_dup 2)
7758 (compare:CC (match_dup 0)
7759 (const_int 0)))]
7760 "")
bb84cb12 7761\f
1fd4e8c1
RK
7762(define_expand "movhi"
7763 [(set (match_operand:HI 0 "general_operand" "")
7764 (match_operand:HI 1 "any_operand" ""))]
7765 ""
fb4d4348 7766 "{ rs6000_emit_move (operands[0], operands[1], HImode); DONE; }")
1fd4e8c1 7767
e34eaae5 7768(define_insn "*movhi_internal"
fb81d7ce
RK
7769 [(set (match_operand:HI 0 "nonimmediate_operand" "=r,r,m,r,r,*q,*c*l,*h")
7770 (match_operand:HI 1 "input_operand" "r,m,r,i,*h,r,r,0"))]
19d5775a
RK
7771 "gpc_reg_operand (operands[0], HImode)
7772 || gpc_reg_operand (operands[1], HImode)"
1fd4e8c1 7773 "@
deb9225a 7774 mr %0,%1
1fd4e8c1
RK
7775 lhz%U1%X1 %0,%1
7776 sth%U0%X0 %1,%0
19d5775a 7777 {lil|li} %0,%w1
1fd4e8c1 7778 mf%1 %0
e76e75bb 7779 mt%0 %1
fb81d7ce 7780 mt%0 %1
e34eaae5 7781 {cror 0,0,0|nop}"
02ca7595 7782 [(set_attr "type" "*,load,store,*,mfjmpr,*,mtjmpr,*")])
1fd4e8c1
RK
7783
7784(define_expand "movqi"
7785 [(set (match_operand:QI 0 "general_operand" "")
7786 (match_operand:QI 1 "any_operand" ""))]
7787 ""
fb4d4348 7788 "{ rs6000_emit_move (operands[0], operands[1], QImode); DONE; }")
1fd4e8c1 7789
e34eaae5 7790(define_insn "*movqi_internal"
fb81d7ce
RK
7791 [(set (match_operand:QI 0 "nonimmediate_operand" "=r,r,m,r,r,*q,*c*l,*h")
7792 (match_operand:QI 1 "input_operand" "r,m,r,i,*h,r,r,0"))]
19d5775a
RK
7793 "gpc_reg_operand (operands[0], QImode)
7794 || gpc_reg_operand (operands[1], QImode)"
1fd4e8c1 7795 "@
deb9225a 7796 mr %0,%1
1fd4e8c1
RK
7797 lbz%U1%X1 %0,%1
7798 stb%U0%X0 %1,%0
19d5775a 7799 {lil|li} %0,%1
1fd4e8c1 7800 mf%1 %0
e76e75bb 7801 mt%0 %1
fb81d7ce 7802 mt%0 %1
e34eaae5 7803 {cror 0,0,0|nop}"
02ca7595 7804 [(set_attr "type" "*,load,store,*,mfjmpr,*,mtjmpr,*")])
1fd4e8c1
RK
7805\f
7806;; Here is how to move condition codes around. When we store CC data in
7807;; an integer register or memory, we store just the high-order 4 bits.
7808;; This lets us not shift in the most common case of CR0.
7809(define_expand "movcc"
7810 [(set (match_operand:CC 0 "nonimmediate_operand" "")
7811 (match_operand:CC 1 "nonimmediate_operand" ""))]
7812 ""
7813 "")
7814
a65c591c 7815(define_insn "*movcc_internal1"
b54cf83a
DE
7816 [(set (match_operand:CC 0 "nonimmediate_operand" "=y,x,?y,r,r,r,r,q,cl,r,m")
7817 (match_operand:CC 1 "nonimmediate_operand" "y,r,r,x,y,r,h,r,r,m,r"))]
1fd4e8c1
RK
7818 "register_operand (operands[0], CCmode)
7819 || register_operand (operands[1], CCmode)"
7820 "@
7821 mcrf %0,%1
7822 mtcrf 128,%1
ca7f5001 7823 {rlinm|rlwinm} %1,%1,%F0,0xffffffff\;mtcrf %R0,%1\;{rlinm|rlwinm} %1,%1,%f0,0xffffffff
2c4a9cff
DE
7824 mfcr %0%Q1
7825 mfcr %0%Q1\;{rlinm|rlwinm} %0,%0,%f1,0xf0000000
deb9225a 7826 mr %0,%1
b54cf83a 7827 mf%1 %0
b991a865
GK
7828 mt%0 %1
7829 mt%0 %1
ca7f5001
RK
7830 {l%U1%X1|lwz%U1%X1} %0,%1
7831 {st%U0%U1|stw%U0%U1} %1,%0"
2c4a9cff
DE
7832 [(set (attr "type")
7833 (cond [(eq_attr "alternative" "0")
7834 (const_string "cr_logical")
7835 (eq_attr "alternative" "1,2")
7836 (const_string "mtcr")
7837 (eq_attr "alternative" "5,7")
7838 (const_string "integer")
7839 (eq_attr "alternative" "6")
7840 (const_string "mfjmpr")
7841 (eq_attr "alternative" "8")
7842 (const_string "mtjmpr")
7843 (eq_attr "alternative" "9")
7844 (const_string "load")
7845 (eq_attr "alternative" "10")
7846 (const_string "store")
7847 (ne (symbol_ref "TARGET_MFCRF") (const_int 0))
7848 (const_string "mfcrf")
7849 ]
7850 (const_string "mfcr")))
b991a865 7851 (set_attr "length" "4,4,12,4,8,4,4,4,4,4,4")])
1fd4e8c1 7852\f
e52e05ca
MM
7853;; For floating-point, we normally deal with the floating-point registers
7854;; unless -msoft-float is used. The sole exception is that parameter passing
7855;; can produce floating-point values in fixed-point registers. Unless the
7856;; value is a simple constant or already in memory, we deal with this by
7857;; allocating memory and copying the value explicitly via that memory location.
1fd4e8c1
RK
7858(define_expand "movsf"
7859 [(set (match_operand:SF 0 "nonimmediate_operand" "")
7860 (match_operand:SF 1 "any_operand" ""))]
7861 ""
fb4d4348 7862 "{ rs6000_emit_move (operands[0], operands[1], SFmode); DONE; }")
1fd4e8c1 7863
1fd4e8c1 7864(define_split
cd2b37d9 7865 [(set (match_operand:SF 0 "gpc_reg_operand" "")
c4c40373 7866 (match_operand:SF 1 "const_double_operand" ""))]
f99f88e0 7867 "reload_completed
5ae4759c
MM
7868 && ((GET_CODE (operands[0]) == REG && REGNO (operands[0]) <= 31)
7869 || (GET_CODE (operands[0]) == SUBREG
7870 && GET_CODE (SUBREG_REG (operands[0])) == REG
7871 && REGNO (SUBREG_REG (operands[0])) <= 31))"
c4c40373 7872 [(set (match_dup 2) (match_dup 3))]
685f3906
DE
7873 "
7874{
7875 long l;
7876 REAL_VALUE_TYPE rv;
7877
7878 REAL_VALUE_FROM_CONST_DOUBLE (rv, operands[1]);
7879 REAL_VALUE_TO_TARGET_SINGLE (rv, l);
c4c40373 7880
f99f88e0
DE
7881 if (! TARGET_POWERPC64)
7882 operands[2] = operand_subword (operands[0], 0, 0, SFmode);
7883 else
7884 operands[2] = gen_lowpart (SImode, operands[0]);
a260abc9 7885
2496c7bd 7886 operands[3] = gen_int_mode (l, SImode);
a260abc9
DE
7887}")
7888
c4c40373 7889(define_insn "*movsf_hardfloat"
b991a865
GK
7890 [(set (match_operand:SF 0 "nonimmediate_operand" "=!r,!r,m,f,f,m,!cl,!q,!r,!r,!r")
7891 (match_operand:SF 1 "input_operand" "r,m,r,f,m,f,r,r,h,G,Fn"))]
d14a6d05 7892 "(gpc_reg_operand (operands[0], SFmode)
a3170dc6
AH
7893 || gpc_reg_operand (operands[1], SFmode))
7894 && (TARGET_HARD_FLOAT && TARGET_FPRS)"
1fd4e8c1 7895 "@
f99f88e0
DE
7896 mr %0,%1
7897 {l%U1%X1|lwz%U1%X1} %0,%1
7898 {st%U0%X0|stw%U0%X0} %1,%0
1fd4e8c1
RK
7899 fmr %0,%1
7900 lfs%U1%X1 %0,%1
c4c40373 7901 stfs%U0%X0 %1,%0
b991a865
GK
7902 mt%0 %1
7903 mt%0 %1
7904 mf%1 %0
c4c40373
MM
7905 #
7906 #"
b991a865
GK
7907 [(set_attr "type" "*,load,store,fp,fpload,fpstore,*,mtjmpr,*,*,*")
7908 (set_attr "length" "4,4,4,4,4,4,4,4,4,4,8")])
d14a6d05 7909
c4c40373 7910(define_insn "*movsf_softfloat"
dd0fbae2
MK
7911 [(set (match_operand:SF 0 "nonimmediate_operand" "=r,cl,q,r,r,m,r,r,r,r,r,*h")
7912 (match_operand:SF 1 "input_operand" "r,r,r,h,m,r,I,L,R,G,Fn,0"))]
d14a6d05 7913 "(gpc_reg_operand (operands[0], SFmode)
a3170dc6
AH
7914 || gpc_reg_operand (operands[1], SFmode))
7915 && (TARGET_SOFT_FLOAT || !TARGET_FPRS)"
d14a6d05
MM
7916 "@
7917 mr %0,%1
b991a865
GK
7918 mt%0 %1
7919 mt%0 %1
7920 mf%1 %0
d14a6d05
MM
7921 {l%U1%X1|lwz%U1%X1} %0,%1
7922 {st%U0%X0|stw%U0%X0} %1,%0
7923 {lil|li} %0,%1
802a0058 7924 {liu|lis} %0,%v1
aee86b38 7925 {cal|la} %0,%a1
c4c40373 7926 #
dd0fbae2
MK
7927 #
7928 {cror 0,0,0|nop}"
7929 [(set_attr "type" "*,mtjmpr,*,*,load,store,*,*,*,*,*,*")
7930 (set_attr "length" "4,4,4,4,4,4,4,4,4,4,8,4")])
d14a6d05 7931
1fd4e8c1
RK
7932\f
7933(define_expand "movdf"
7934 [(set (match_operand:DF 0 "nonimmediate_operand" "")
7935 (match_operand:DF 1 "any_operand" ""))]
7936 ""
fb4d4348 7937 "{ rs6000_emit_move (operands[0], operands[1], DFmode); DONE; }")
1fd4e8c1
RK
7938
7939(define_split
cd2b37d9 7940 [(set (match_operand:DF 0 "gpc_reg_operand" "")
c4c40373 7941 (match_operand:DF 1 "const_int_operand" ""))]
a260abc9 7942 "! TARGET_POWERPC64 && reload_completed
5ae4759c
MM
7943 && ((GET_CODE (operands[0]) == REG && REGNO (operands[0]) <= 31)
7944 || (GET_CODE (operands[0]) == SUBREG
7945 && GET_CODE (SUBREG_REG (operands[0])) == REG
7946 && REGNO (SUBREG_REG (operands[0])) <= 31))"
c4c40373
MM
7947 [(set (match_dup 2) (match_dup 4))
7948 (set (match_dup 3) (match_dup 1))]
7949 "
7950{
5ae4759c 7951 int endian = (WORDS_BIG_ENDIAN == 0);
5f59ecb7
DE
7952 HOST_WIDE_INT value = INTVAL (operands[1]);
7953
5ae4759c
MM
7954 operands[2] = operand_subword (operands[0], endian, 0, DFmode);
7955 operands[3] = operand_subword (operands[0], 1 - endian, 0, DFmode);
5f59ecb7
DE
7956#if HOST_BITS_PER_WIDE_INT == 32
7957 operands[4] = (value & 0x80000000) ? constm1_rtx : const0_rtx;
7958#else
7959 operands[4] = GEN_INT (value >> 32);
a65c591c 7960 operands[1] = GEN_INT (((value & 0xffffffff) ^ 0x80000000) - 0x80000000);
5f59ecb7 7961#endif
c4c40373
MM
7962}")
7963
c4c40373
MM
7964(define_split
7965 [(set (match_operand:DF 0 "gpc_reg_operand" "")
7966 (match_operand:DF 1 "const_double_operand" ""))]
a260abc9 7967 "! TARGET_POWERPC64 && reload_completed
5ae4759c
MM
7968 && ((GET_CODE (operands[0]) == REG && REGNO (operands[0]) <= 31)
7969 || (GET_CODE (operands[0]) == SUBREG
7970 && GET_CODE (SUBREG_REG (operands[0])) == REG
7971 && REGNO (SUBREG_REG (operands[0])) <= 31))"
c4c40373
MM
7972 [(set (match_dup 2) (match_dup 4))
7973 (set (match_dup 3) (match_dup 5))]
7974 "
7975{
5ae4759c 7976 int endian = (WORDS_BIG_ENDIAN == 0);
47ad8c61
MM
7977 long l[2];
7978 REAL_VALUE_TYPE rv;
7979
7980 REAL_VALUE_FROM_CONST_DOUBLE (rv, operands[1]);
7981 REAL_VALUE_TO_TARGET_DOUBLE (rv, l);
7982
5ae4759c
MM
7983 operands[2] = operand_subword (operands[0], endian, 0, DFmode);
7984 operands[3] = operand_subword (operands[0], 1 - endian, 0, DFmode);
2496c7bd
LB
7985 operands[4] = gen_int_mode (l[endian], SImode);
7986 operands[5] = gen_int_mode (l[1 - endian], SImode);
c4c40373
MM
7987}")
7988
efc08378
DE
7989(define_split
7990 [(set (match_operand:DF 0 "gpc_reg_operand" "")
685f3906 7991 (match_operand:DF 1 "easy_fp_constant" ""))]
a260abc9 7992 "TARGET_POWERPC64 && reload_completed
5ae4759c
MM
7993 && ((GET_CODE (operands[0]) == REG && REGNO (operands[0]) <= 31)
7994 || (GET_CODE (operands[0]) == SUBREG
7995 && GET_CODE (SUBREG_REG (operands[0])) == REG
7996 && REGNO (SUBREG_REG (operands[0])) <= 31))"
a260abc9 7997 [(set (match_dup 2) (match_dup 3))]
5ae4759c 7998 "
a260abc9
DE
7999{
8000 int endian = (WORDS_BIG_ENDIAN == 0);
8001 long l[2];
8002 REAL_VALUE_TYPE rv;
4977bab6 8003#if HOST_BITS_PER_WIDE_INT >= 64
5b029315 8004 HOST_WIDE_INT val;
4977bab6 8005#endif
a260abc9
DE
8006
8007 REAL_VALUE_FROM_CONST_DOUBLE (rv, operands[1]);
8008 REAL_VALUE_TO_TARGET_DOUBLE (rv, l);
8009
8010 operands[2] = gen_lowpart (DImode, operands[0]);
8011 /* HIGHPART is lower memory address when WORDS_BIG_ENDIAN. */
5b029315 8012#if HOST_BITS_PER_WIDE_INT >= 64
a2419b96
DE
8013 val = ((HOST_WIDE_INT)(unsigned long)l[endian] << 32
8014 | ((HOST_WIDE_INT)(unsigned long)l[1 - endian]));
5b029315 8015
f5264b52 8016 operands[3] = gen_int_mode (val, DImode);
5b029315 8017#else
a260abc9 8018 operands[3] = immed_double_const (l[1 - endian], l[endian], DImode);
5b029315 8019#endif
a260abc9 8020}")
efc08378 8021
4eae5fe1 8022;; Don't have reload use general registers to load a constant. First,
1427100a 8023;; it might not work if the output operand is the equivalent of
4eae5fe1
RK
8024;; a non-offsettable memref, but also it is less efficient than loading
8025;; the constant into an FP register, since it will probably be used there.
8026;; The "??" is a kludge until we can figure out a more reasonable way
8027;; of handling these non-offsettable values.
c4c40373 8028(define_insn "*movdf_hardfloat32"
914a7297
DE
8029 [(set (match_operand:DF 0 "nonimmediate_operand" "=!r,??r,m,f,f,m,!r,!r,!r")
8030 (match_operand:DF 1 "input_operand" "r,m,r,f,m,f,G,H,F"))]
a3170dc6 8031 "! TARGET_POWERPC64 && TARGET_HARD_FLOAT && TARGET_FPRS
52d3af72
DE
8032 && (gpc_reg_operand (operands[0], DFmode)
8033 || gpc_reg_operand (operands[1], DFmode))"
e7113111
RK
8034 "*
8035{
8036 switch (which_alternative)
8037 {
a260abc9 8038 default:
a6c2a102 8039 abort ();
e7113111
RK
8040 case 0:
8041 /* We normally copy the low-numbered register first. However, if
000034eb
DE
8042 the first register operand 0 is the same as the second register
8043 of operand 1, we must copy in the opposite order. */
e7113111 8044 if (REGNO (operands[0]) == REGNO (operands[1]) + 1)
deb9225a 8045 return \"mr %L0,%L1\;mr %0,%1\";
e7113111 8046 else
deb9225a 8047 return \"mr %0,%1\;mr %L0,%L1\";
e7113111 8048 case 1:
2b97222d
DE
8049 if (offsettable_memref_p (operands[1])
8050 || (GET_CODE (operands[1]) == MEM
69f51a21
DE
8051 && (GET_CODE (XEXP (operands[1], 0)) == LO_SUM
8052 || GET_CODE (XEXP (operands[1], 0)) == PRE_INC
8053 || GET_CODE (XEXP (operands[1], 0)) == PRE_DEC)))
000034eb
DE
8054 {
8055 /* If the low-address word is used in the address, we must load
8056 it last. Otherwise, load it first. Note that we cannot have
8057 auto-increment in that case since the address register is
8058 known to be dead. */
8059 if (refers_to_regno_p (REGNO (operands[0]), REGNO (operands[0]) + 1,
8060 operands[1], 0))
8061 return \"{l|lwz} %L0,%L1\;{l|lwz} %0,%1\";
8062 else
8063 return \"{l%U1|lwz%U1} %0,%1\;{l|lwz} %L0,%L1\";
8064 }
e7113111 8065 else
000034eb
DE
8066 {
8067 rtx addreg;
8068
000034eb
DE
8069 addreg = find_addr_reg (XEXP (operands[1], 0));
8070 if (refers_to_regno_p (REGNO (operands[0]),
8071 REGNO (operands[0]) + 1,
8072 operands[1], 0))
8073 {
8074 output_asm_insn (\"{cal|la} %0,4(%0)\", &addreg);
2b97222d 8075 output_asm_insn (\"{lx|lwzx} %L0,%1\", operands);
000034eb 8076 output_asm_insn (\"{cal|la} %0,-4(%0)\", &addreg);
2b97222d 8077 return \"{lx|lwzx} %0,%1\";
000034eb
DE
8078 }
8079 else
8080 {
2b97222d 8081 output_asm_insn (\"{lx|lwzx} %0,%1\", operands);
000034eb 8082 output_asm_insn (\"{cal|la} %0,4(%0)\", &addreg);
2b97222d 8083 output_asm_insn (\"{lx|lwzx} %L0,%1\", operands);
000034eb
DE
8084 output_asm_insn (\"{cal|la} %0,-4(%0)\", &addreg);
8085 return \"\";
8086 }
8087 }
e7113111 8088 case 2:
2b97222d
DE
8089 if (offsettable_memref_p (operands[0])
8090 || (GET_CODE (operands[0]) == MEM
69f51a21
DE
8091 && (GET_CODE (XEXP (operands[0], 0)) == LO_SUM
8092 || GET_CODE (XEXP (operands[0], 0)) == PRE_INC
8093 || GET_CODE (XEXP (operands[0], 0)) == PRE_DEC)))
000034eb
DE
8094 return \"{st%U0|stw%U0} %1,%0\;{st|stw} %L1,%L0\";
8095 else
8096 {
8097 rtx addreg;
8098
000034eb 8099 addreg = find_addr_reg (XEXP (operands[0], 0));
2b97222d 8100 output_asm_insn (\"{stx|stwx} %1,%0\", operands);
000034eb 8101 output_asm_insn (\"{cal|la} %0,4(%0)\", &addreg);
2b97222d 8102 output_asm_insn (\"{stx|stwx} %L1,%0\", operands);
000034eb
DE
8103 output_asm_insn (\"{cal|la} %0,-4(%0)\", &addreg);
8104 return \"\";
8105 }
e7113111 8106 case 3:
914a7297 8107 return \"fmr %0,%1\";
e7113111 8108 case 4:
914a7297 8109 return \"lfd%U1%X1 %0,%1\";
e7113111 8110 case 5:
914a7297 8111 return \"stfd%U0%X0 %1,%0\";
e7113111 8112 case 6:
c4c40373 8113 case 7:
c4c40373 8114 case 8:
914a7297 8115 return \"#\";
e7113111
RK
8116 }
8117}"
914a7297
DE
8118 [(set_attr "type" "*,load,store,fp,fpload,fpstore,*,*,*")
8119 (set_attr "length" "8,16,16,4,4,4,8,12,16")])
51b8fc2c 8120
c4c40373 8121(define_insn "*movdf_softfloat32"
1427100a
DE
8122 [(set (match_operand:DF 0 "nonimmediate_operand" "=r,r,m,r,r,r")
8123 (match_operand:DF 1 "input_operand" "r,m,r,G,H,F"))]
a3170dc6 8124 "! TARGET_POWERPC64 && (TARGET_SOFT_FLOAT || !TARGET_FPRS)
52d3af72
DE
8125 && (gpc_reg_operand (operands[0], DFmode)
8126 || gpc_reg_operand (operands[1], DFmode))"
dc4f83ca
MM
8127 "*
8128{
8129 switch (which_alternative)
8130 {
a260abc9 8131 default:
a6c2a102 8132 abort ();
dc4f83ca
MM
8133 case 0:
8134 /* We normally copy the low-numbered register first. However, if
8135 the first register operand 0 is the same as the second register of
8136 operand 1, we must copy in the opposite order. */
8137 if (REGNO (operands[0]) == REGNO (operands[1]) + 1)
8138 return \"mr %L0,%L1\;mr %0,%1\";
8139 else
8140 return \"mr %0,%1\;mr %L0,%L1\";
8141 case 1:
3cb999d8
DE
8142 /* If the low-address word is used in the address, we must load
8143 it last. Otherwise, load it first. Note that we cannot have
8144 auto-increment in that case since the address register is
8145 known to be dead. */
dc4f83ca 8146 if (refers_to_regno_p (REGNO (operands[0]), REGNO (operands[0]) + 1,
3cb999d8 8147 operands[1], 0))
dc4f83ca
MM
8148 return \"{l|lwz} %L0,%L1\;{l|lwz} %0,%1\";
8149 else
8150 return \"{l%U1|lwz%U1} %0,%1\;{l|lwz} %L0,%L1\";
8151 case 2:
8152 return \"{st%U0|stw%U0} %1,%0\;{st|stw} %L1,%L0\";
8153 case 3:
c4c40373
MM
8154 case 4:
8155 case 5:
dc4f83ca
MM
8156 return \"#\";
8157 }
8158}"
c4c40373
MM
8159 [(set_attr "type" "*,load,store,*,*,*")
8160 (set_attr "length" "8,8,8,8,12,16")])
dc4f83ca 8161
c4c40373 8162(define_insn "*movdf_hardfloat64"
914a7297
DE
8163 [(set (match_operand:DF 0 "nonimmediate_operand" "=!r,??r,m,f,f,m,!cl,!r,!r,!r,!r")
8164 (match_operand:DF 1 "input_operand" "r,m,r,f,m,f,r,h,G,H,F"))]
a3170dc6 8165 "TARGET_POWERPC64 && TARGET_HARD_FLOAT && TARGET_FPRS
52d3af72
DE
8166 && (gpc_reg_operand (operands[0], DFmode)
8167 || gpc_reg_operand (operands[1], DFmode))"
51b8fc2c 8168 "@
3d5570cb
RK
8169 mr %0,%1
8170 ld%U1%X1 %0,%1
96bb8ed3 8171 std%U0%X0 %1,%0
3d5570cb 8172 fmr %0,%1
f63184ac 8173 lfd%U1%X1 %0,%1
914a7297
DE
8174 stfd%U0%X0 %1,%0
8175 mt%0 %1
8176 mf%1 %0
8177 #
8178 #
8179 #"
8180 [(set_attr "type" "*,load,store,fp,fpload,fpstore,mtjmpr,*,*,*,*")
8181 (set_attr "length" "4,4,4,4,4,4,4,4,8,12,16")])
dc4f83ca 8182
c4c40373 8183(define_insn "*movdf_softfloat64"
e2d0915c
AM
8184 [(set (match_operand:DF 0 "nonimmediate_operand" "=r,cl,r,r,m,r,r,r,*h")
8185 (match_operand:DF 1 "input_operand" "r,r,h,m,r,G,H,F,0"))]
a3170dc6 8186 "TARGET_POWERPC64 && (TARGET_SOFT_FLOAT || !TARGET_FPRS)
52d3af72
DE
8187 && (gpc_reg_operand (operands[0], DFmode)
8188 || gpc_reg_operand (operands[1], DFmode))"
dc4f83ca
MM
8189 "@
8190 mr %0,%1
914a7297
DE
8191 mt%0 %1
8192 mf%1 %0
dc4f83ca 8193 ld%U1%X1 %0,%1
96bb8ed3 8194 std%U0%X0 %1,%0
c4c40373
MM
8195 #
8196 #
e2d0915c
AM
8197 #
8198 nop"
8199 [(set_attr "type" "*,*,*,load,store,*,*,*,*")
8200 (set_attr "length" "4,4,4,4,4,8,12,16,4")])
1fd4e8c1 8201\f
06f4e019
DE
8202(define_expand "movtf"
8203 [(set (match_operand:TF 0 "general_operand" "")
8204 (match_operand:TF 1 "any_operand" ""))]
a3170dc6
AH
8205 "DEFAULT_ABI == ABI_AIX && TARGET_HARD_FLOAT && TARGET_FPRS
8206 && TARGET_LONG_DOUBLE_128"
06f4e019
DE
8207 "{ rs6000_emit_move (operands[0], operands[1], TFmode); DONE; }")
8208
8209(define_insn "*movtf_internal"
8210 [(set (match_operand:TF 0 "nonimmediate_operand" "=f,f,m,!r,!r,!r")
8211 (match_operand:TF 1 "input_operand" "f,m,f,G,H,F"))]
a3170dc6
AH
8212 "DEFAULT_ABI == ABI_AIX && TARGET_HARD_FLOAT && TARGET_FPRS
8213 && TARGET_LONG_DOUBLE_128
06f4e019
DE
8214 && (gpc_reg_operand (operands[0], TFmode)
8215 || gpc_reg_operand (operands[1], TFmode))"
8216 "*
8217{
8218 switch (which_alternative)
8219 {
8220 default:
8221 abort ();
8222 case 0:
8223 /* We normally copy the low-numbered register first. However, if
8224 the first register operand 0 is the same as the second register of
8225 operand 1, we must copy in the opposite order. */
8226 if (REGNO (operands[0]) == REGNO (operands[1]) + 1)
8227 return \"fmr %L0,%L1\;fmr %0,%1\";
8228 else
8229 return \"fmr %0,%1\;fmr %L0,%L1\";
8230 case 1:
f5264b52 8231 return \"lfd %0,%1\;lfd %L0,%Y1\";
06f4e019 8232 case 2:
f5264b52 8233 return \"stfd %1,%0\;stfd %L1,%Y0\";
06f4e019
DE
8234 case 3:
8235 case 4:
8236 case 5:
8237 return \"#\";
8238 }
8239}"
8240 [(set_attr "type" "fp,fpload,fpstore,*,*,*")
8241 (set_attr "length" "8,8,8,12,16,20")])
8242
8243(define_split
8244 [(set (match_operand:TF 0 "gpc_reg_operand" "")
f5264b52 8245 (match_operand:TF 1 "easy_fp_constant" ""))]
fcce224d
DE
8246 "(DEFAULT_ABI == ABI_AIX || DEFAULT_ABI == ABI_DARWIN)
8247 && TARGET_HARD_FLOAT && TARGET_FPRS && ! TARGET_POWERPC64
8248 && TARGET_LONG_DOUBLE_128 && reload_completed
8249 && ((GET_CODE (operands[0]) == REG && REGNO (operands[0]) <= 31)
8250 || (GET_CODE (operands[0]) == SUBREG
8251 && GET_CODE (SUBREG_REG (operands[0])) == REG
8252 && REGNO (SUBREG_REG (operands[0])) <= 31))"
8253 [(set (match_dup 2) (match_dup 6))
8254 (set (match_dup 3) (match_dup 7))
8255 (set (match_dup 4) (match_dup 8))
8256 (set (match_dup 5) (match_dup 9))]
8257 "
8258{
8259 long l[4];
8260 REAL_VALUE_TYPE rv;
8261
8262 REAL_VALUE_FROM_CONST_DOUBLE (rv, operands[1]);
8263 REAL_VALUE_TO_TARGET_LONG_DOUBLE (rv, l);
8264
8265 operands[2] = operand_subword (operands[0], 0, 0, TFmode);
8266 operands[3] = operand_subword (operands[0], 1, 0, TFmode);
8267 operands[4] = operand_subword (operands[0], 2, 0, TFmode);
8268 operands[5] = operand_subword (operands[0], 3, 0, TFmode);
8269 operands[6] = gen_int_mode (l[0], SImode);
8270 operands[7] = gen_int_mode (l[1], SImode);
8271 operands[8] = gen_int_mode (l[2], SImode);
8272 operands[9] = gen_int_mode (l[3], SImode);
8273}")
8274
8275(define_split
8276 [(set (match_operand:TF 0 "gpc_reg_operand" "")
8277 (match_operand:TF 1 "easy_fp_constant" ""))]
8278 "(DEFAULT_ABI == ABI_AIX || DEFAULT_ABI == ABI_DARWIN)
8279 && TARGET_HARD_FLOAT && TARGET_FPRS && TARGET_POWERPC64
8280 && TARGET_LONG_DOUBLE_128 && reload_completed
8281 && ((GET_CODE (operands[0]) == REG && REGNO (operands[0]) <= 31)
8282 || (GET_CODE (operands[0]) == SUBREG
8283 && GET_CODE (SUBREG_REG (operands[0])) == REG
8284 && REGNO (SUBREG_REG (operands[0])) <= 31))"
8285 [(set (match_dup 2) (match_dup 4))
8286 (set (match_dup 3) (match_dup 5))]
06f4e019
DE
8287 "
8288{
fcce224d
DE
8289 long l[4];
8290 REAL_VALUE_TYPE rv;
d24652ee 8291#if HOST_BITS_PER_WIDE_INT >= 64
f5264b52 8292 HOST_WIDE_INT val;
d24652ee 8293#endif
fcce224d
DE
8294
8295 REAL_VALUE_FROM_CONST_DOUBLE (rv, operands[1]);
8296 REAL_VALUE_TO_TARGET_LONG_DOUBLE (rv, l);
8297
f5264b52
DE
8298 operands[2] = gen_lowpart (DImode, operands[0]);
8299 operands[3] = gen_highpart (DImode, operands[0]);
8300#if HOST_BITS_PER_WIDE_INT >= 64
a2419b96
DE
8301 val = ((HOST_WIDE_INT)(unsigned long)l[0] << 32
8302 | ((HOST_WIDE_INT)(unsigned long)l[1]));
f5264b52
DE
8303 operands[4] = gen_int_mode (val, DImode);
8304
a2419b96
DE
8305 val = ((HOST_WIDE_INT)(unsigned long)l[2] << 32
8306 | ((HOST_WIDE_INT)(unsigned long)l[3]));
f5264b52
DE
8307 operands[5] = gen_int_mode (val, DImode);
8308#else
8309 operands[4] = immed_double_const (l[1], l[0], DImode);
8310 operands[5] = immed_double_const (l[3], l[2], DImode);
8311#endif
06f4e019
DE
8312}")
8313
a2419b96 8314(define_insn "extenddftf2"
06f4e019
DE
8315 [(set (match_operand:TF 0 "gpc_reg_operand" "=f")
8316 (float_extend:TF (match_operand:DF 1 "gpc_reg_operand" "f")))]
a3170dc6
AH
8317 "DEFAULT_ABI == ABI_AIX && TARGET_HARD_FLOAT && TARGET_FPRS
8318 && TARGET_LONG_DOUBLE_128"
a2419b96 8319 "*
06f4e019 8320{
a2419b96
DE
8321 if (REGNO (operands[0]) == REGNO (operands[1]))
8322 return \"fsub %L0,%L0,%L0\";
8323 else
8324 return \"fmr %0,%1\;fsub %L0,%L0,%L0\";
8325}"
8326 [(set_attr "type" "fp")])
06f4e019 8327
a2419b96 8328(define_insn "extendsftf2"
06f4e019
DE
8329 [(set (match_operand:TF 0 "gpc_reg_operand" "=f")
8330 (float_extend:TF (match_operand:SF 1 "gpc_reg_operand" "f")))]
a3170dc6
AH
8331 "DEFAULT_ABI == ABI_AIX && TARGET_HARD_FLOAT && TARGET_FPRS
8332 && TARGET_LONG_DOUBLE_128"
a2419b96 8333 "*
06f4e019 8334{
a2419b96
DE
8335 if (REGNO (operands[0]) == REGNO (operands[1]))
8336 return \"fsub %L0,%L0,%L0\";
8337 else
8338 return \"fmr %0,%1\;fsub %L0,%L0,%L0\";
8339}"
8340 [(set_attr "type" "fp")])
06f4e019
DE
8341
8342(define_insn "trunctfdf2"
8343 [(set (match_operand:DF 0 "gpc_reg_operand" "=f")
8344 (float_truncate:DF (match_operand:TF 1 "gpc_reg_operand" "f")))]
a3170dc6
AH
8345 "DEFAULT_ABI == ABI_AIX && TARGET_HARD_FLOAT && TARGET_FPRS
8346 && TARGET_LONG_DOUBLE_128"
06f4e019
DE
8347 "fadd %0,%1,%L1"
8348 [(set_attr "type" "fp")
8349 (set_attr "length" "8")])
8350
8351(define_insn_and_split "trunctfsf2"
8352 [(set (match_operand:SF 0 "gpc_reg_operand" "=f")
ea112fc4
DE
8353 (float_truncate:SF (match_operand:TF 1 "gpc_reg_operand" "f")))
8354 (clobber (match_scratch:DF 2 "=f"))]
a3170dc6
AH
8355 "DEFAULT_ABI == ABI_AIX && TARGET_HARD_FLOAT
8356 && TARGET_FPRS && TARGET_LONG_DOUBLE_128"
06f4e019 8357 "#"
ea112fc4 8358 "&& reload_completed"
06f4e019
DE
8359 [(set (match_dup 2)
8360 (float_truncate:DF (match_dup 1)))
8361 (set (match_dup 0)
8362 (float_truncate:SF (match_dup 2)))]
ea112fc4 8363 "")
06f4e019 8364
ea112fc4
DE
8365(define_insn_and_split "floatditf2"
8366 [(set (match_operand:TF 0 "gpc_reg_operand" "=f")
61c07d3c 8367 (float:TF (match_operand:DI 1 "gpc_reg_operand" "*f")))
ea112fc4
DE
8368 (clobber (match_scratch:DF 2 "=f"))]
8369 "DEFAULT_ABI == ABI_AIX && TARGET_POWERPC64
a3170dc6 8370 && TARGET_HARD_FLOAT && TARGET_FPRS && TARGET_LONG_DOUBLE_128"
ea112fc4
DE
8371 "#"
8372 "&& reload_completed"
06f4e019 8373 [(set (match_dup 2)
a2419b96
DE
8374 (float:DF (match_dup 1)))
8375 (set (match_dup 0)
06f4e019 8376 (float_extend:TF (match_dup 2)))]
ea112fc4 8377 "")
06f4e019 8378
ea112fc4
DE
8379(define_insn_and_split "floatsitf2"
8380 [(set (match_operand:TF 0 "gpc_reg_operand" "=f")
61c07d3c 8381 (float:TF (match_operand:SI 1 "gpc_reg_operand" "r")))
ea112fc4 8382 (clobber (match_scratch:DF 2 "=f"))]
a3170dc6
AH
8383 "DEFAULT_ABI == ABI_AIX && TARGET_HARD_FLOAT && TARGET_FPRS
8384 && TARGET_LONG_DOUBLE_128"
ea112fc4
DE
8385 "#"
8386 "&& reload_completed"
06f4e019 8387 [(set (match_dup 2)
a2419b96
DE
8388 (float:DF (match_dup 1)))
8389 (set (match_dup 0)
06f4e019 8390 (float_extend:TF (match_dup 2)))]
ea112fc4 8391 "")
06f4e019 8392
ea112fc4 8393(define_insn_and_split "fix_trunctfdi2"
61c07d3c 8394 [(set (match_operand:DI 0 "gpc_reg_operand" "=*f")
a2419b96
DE
8395 (fix:DI (match_operand:TF 1 "gpc_reg_operand" "f")))
8396 (clobber (match_scratch:DF 2 "=f"))]
ea112fc4 8397 "DEFAULT_ABI == ABI_AIX && TARGET_POWERPC64
a3170dc6 8398 && TARGET_HARD_FLOAT && TARGET_FPRS && TARGET_LONG_DOUBLE_128"
ea112fc4
DE
8399 "#"
8400 "&& reload_completed"
06f4e019 8401 [(set (match_dup 2)
a2419b96
DE
8402 (float_truncate:DF (match_dup 1)))
8403 (set (match_dup 0)
8404 (fix:DI (match_dup 2)))]
ea112fc4 8405 "")
06f4e019 8406
ea112fc4 8407(define_insn_and_split "fix_trunctfsi2"
61c07d3c 8408 [(set (match_operand:SI 0 "gpc_reg_operand" "=r")
a2419b96
DE
8409 (fix:SI (match_operand:TF 1 "gpc_reg_operand" "f")))
8410 (clobber (match_scratch:DF 2 "=f"))]
a3170dc6
AH
8411 "DEFAULT_ABI == ABI_AIX && TARGET_HARD_FLOAT && TARGET_FPRS
8412 && TARGET_LONG_DOUBLE_128"
ea112fc4
DE
8413 "#"
8414 "&& reload_completed"
06f4e019 8415 [(set (match_dup 2)
a2419b96
DE
8416 (float_truncate:DF (match_dup 1)))
8417 (set (match_dup 0)
06f4e019 8418 (fix:SI (match_dup 2)))]
ea112fc4 8419 "")
06f4e019
DE
8420
8421(define_insn "negtf2"
8422 [(set (match_operand:TF 0 "gpc_reg_operand" "=f")
8423 (neg:TF (match_operand:TF 1 "gpc_reg_operand" "f")))]
a3170dc6
AH
8424 "DEFAULT_ABI == ABI_AIX && TARGET_HARD_FLOAT && TARGET_FPRS
8425 && TARGET_LONG_DOUBLE_128"
06f4e019
DE
8426 "*
8427{
8428 if (REGNO (operands[0]) == REGNO (operands[1]) + 1)
8429 return \"fneg %L0,%L1\;fneg %0,%1\";
8430 else
8431 return \"fneg %0,%1\;fneg %L0,%L1\";
8432}"
8433 [(set_attr "type" "fp")
8434 (set_attr "length" "8")])
8435
8436(define_insn "abstf2"
8437 [(set (match_operand:TF 0 "gpc_reg_operand" "=f")
8438 (abs:TF (match_operand:TF 1 "gpc_reg_operand" "f")))]
a3170dc6
AH
8439 "DEFAULT_ABI == ABI_AIX && TARGET_HARD_FLOAT && TARGET_FPRS
8440 && TARGET_LONG_DOUBLE_128"
06f4e019
DE
8441 "*
8442{
8443 if (REGNO (operands[0]) == REGNO (operands[1]) + 1)
8444 return \"fabs %L0,%L1\;fabs %0,%1\";
8445 else
8446 return \"fabs %0,%1\;fabs %L0,%L1\";
8447}"
8448 [(set_attr "type" "fp")
8449 (set_attr "length" "8")])
8450
8451(define_insn ""
8452 [(set (match_operand:TF 0 "gpc_reg_operand" "=f")
8453 (neg:TF (abs:TF (match_operand:TF 1 "gpc_reg_operand" "f"))))]
a3170dc6
AH
8454 "DEFAULT_ABI == ABI_AIX && TARGET_HARD_FLOAT && TARGET_FPRS
8455 && TARGET_LONG_DOUBLE_128"
06f4e019
DE
8456 "*
8457{
8458 if (REGNO (operands[0]) == REGNO (operands[1]) + 1)
8459 return \"fnabs %L0,%L1\;fnabs %0,%1\";
8460 else
8461 return \"fnabs %0,%1\;fnabs %L0,%L1\";
8462}"
8463 [(set_attr "type" "fp")
8464 (set_attr "length" "8")])
8465\f
1fd4e8c1
RK
8466;; Next come the multi-word integer load and store and the load and store
8467;; multiple insns.
8468(define_expand "movdi"
8469 [(set (match_operand:DI 0 "general_operand" "")
e6ca2c17 8470 (match_operand:DI 1 "any_operand" ""))]
1fd4e8c1 8471 ""
fb4d4348 8472 "{ rs6000_emit_move (operands[0], operands[1], DImode); DONE; }")
1fd4e8c1 8473
acad7ed3 8474(define_insn "*movdi_internal32"
4e74d8ec
MM
8475 [(set (match_operand:DI 0 "nonimmediate_operand" "=r,r,m,f,f,m,r,r,r,r,r")
8476 (match_operand:DI 1 "input_operand" "r,m,r,f,m,f,IJK,n,G,H,F"))]
a260abc9 8477 "! TARGET_POWERPC64
4e74d8ec
MM
8478 && (gpc_reg_operand (operands[0], DImode)
8479 || gpc_reg_operand (operands[1], DImode))"
1fd4e8c1
RK
8480 "*
8481{
8482 switch (which_alternative)
8483 {
a260abc9 8484 default:
a6c2a102 8485 abort ();
1fd4e8c1 8486 case 0:
1fd4e8c1 8487 case 1:
1fd4e8c1 8488 case 2:
3a1f863f 8489 return \"#\";
8ffd9c51
RK
8490 case 3:
8491 return \"fmr %0,%1\";
8492 case 4:
8493 return \"lfd%U1%X1 %0,%1\";
8494 case 5:
8495 return \"stfd%U0%X0 %1,%0\";
4e74d8ec
MM
8496 case 6:
8497 case 7:
8498 case 8:
8499 case 9:
8500 case 10:
8501 return \"#\";
1fd4e8c1
RK
8502 }
8503}"
3a1f863f 8504 [(set_attr "type" "*,load,store,fp,fpload,fpstore,*,*,*,*,*")])
4e74d8ec
MM
8505
8506(define_split
8507 [(set (match_operand:DI 0 "gpc_reg_operand" "")
8508 (match_operand:DI 1 "const_int_operand" ""))]
a260abc9 8509 "! TARGET_POWERPC64 && reload_completed"
4e74d8ec
MM
8510 [(set (match_dup 2) (match_dup 4))
8511 (set (match_dup 3) (match_dup 1))]
8512 "
8513{
5f59ecb7 8514 HOST_WIDE_INT value = INTVAL (operands[1]);
bdaa0181
GK
8515 operands[2] = operand_subword_force (operands[0], WORDS_BIG_ENDIAN == 0,
8516 DImode);
8517 operands[3] = operand_subword_force (operands[0], WORDS_BIG_ENDIAN != 0,
8518 DImode);
75d39459 8519#if HOST_BITS_PER_WIDE_INT == 32
5f59ecb7 8520 operands[4] = (value & 0x80000000) ? constm1_rtx : const0_rtx;
75d39459 8521#else
5f59ecb7 8522 operands[4] = GEN_INT (value >> 32);
a65c591c 8523 operands[1] = GEN_INT (((value & 0xffffffff) ^ 0x80000000) - 0x80000000);
75d39459 8524#endif
4e74d8ec
MM
8525}")
8526
4e74d8ec
MM
8527(define_split
8528 [(set (match_operand:DI 0 "gpc_reg_operand" "")
8529 (match_operand:DI 1 "const_double_operand" ""))]
75d39459 8530 "HOST_BITS_PER_WIDE_INT == 32 && ! TARGET_POWERPC64 && reload_completed"
4e74d8ec
MM
8531 [(set (match_dup 2) (match_dup 4))
8532 (set (match_dup 3) (match_dup 5))]
8533 "
8534{
bdaa0181
GK
8535 operands[2] = operand_subword_force (operands[0], WORDS_BIG_ENDIAN == 0,
8536 DImode);
8537 operands[3] = operand_subword_force (operands[0], WORDS_BIG_ENDIAN != 0,
8538 DImode);
f6968f59
MM
8539 operands[4] = GEN_INT (CONST_DOUBLE_HIGH (operands[1]));
8540 operands[5] = GEN_INT (CONST_DOUBLE_LOW (operands[1]));
4e74d8ec
MM
8541}")
8542
3a1f863f
DE
8543(define_split
8544 [(set (match_operand:DI 0 "nonimmediate_operand" "")
8545 (match_operand:DI 1 "input_operand" ""))]
8546 "reload_completed && !TARGET_POWERPC64
8547 && gpr_or_gpr_p (operands[0], operands[1])"
8548 [(set (match_dup 2) (match_dup 4))
8549 (set (match_dup 3) (match_dup 5))]
8550"{
8551 rs6000_split_multireg_move (operands);
8552}")
8553
6fc19dc9
AM
8554(define_split
8555 [(set (match_operand:TI 0 "gpc_reg_operand" "")
8556 (match_operand:TI 1 "const_double_operand" ""))]
8557 "TARGET_POWERPC64"
8558 [(set (match_dup 2) (match_dup 4))
8559 (set (match_dup 3) (match_dup 5))]
8560 "
8561{
8562 operands[2] = operand_subword_force (operands[0], WORDS_BIG_ENDIAN == 0,
8563 TImode);
8564 operands[3] = operand_subword_force (operands[0], WORDS_BIG_ENDIAN != 0,
8565 TImode);
8566 if (GET_CODE (operands[1]) == CONST_DOUBLE)
8567 {
8568 operands[4] = GEN_INT (CONST_DOUBLE_HIGH (operands[1]));
8569 operands[5] = GEN_INT (CONST_DOUBLE_LOW (operands[1]));
8570 }
8571 else if (GET_CODE (operands[1]) == CONST_INT)
8572 {
8573 operands[4] = GEN_INT (- (INTVAL (operands[1]) < 0));
8574 operands[5] = operands[1];
8575 }
8576 else
8577 FAIL;
8578}")
8579
acad7ed3 8580(define_insn "*movdi_internal64"
5d7e6254 8581 [(set (match_operand:DI 0 "nonimmediate_operand" "=r,r,m,r,r,r,r,?f,f,m,r,*h,*h")
9615f239 8582 (match_operand:DI 1 "input_operand" "r,m,r,I,L,nF,R,f,m,f,*h,r,0"))]
a260abc9 8583 "TARGET_POWERPC64
4e74d8ec
MM
8584 && (gpc_reg_operand (operands[0], DImode)
8585 || gpc_reg_operand (operands[1], DImode))"
51b8fc2c 8586 "@
3d5570cb
RK
8587 mr %0,%1
8588 ld%U1%X1 %0,%1
96bb8ed3 8589 std%U0%X0 %1,%0
3d5570cb 8590 li %0,%1
802a0058 8591 lis %0,%v1
e6ca2c17 8592 #
aee86b38 8593 {cal|la} %0,%a1
3d5570cb
RK
8594 fmr %0,%1
8595 lfd%U1%X1 %0,%1
8596 stfd%U0%X0 %1,%0
8597 mf%1 %0
08075ead 8598 mt%0 %1
e34eaae5 8599 {cror 0,0,0|nop}"
02ca7595 8600 [(set_attr "type" "*,load,store,*,*,*,*,fp,fpload,fpstore,mfjmpr,mtjmpr,*")
e6ca2c17
DE
8601 (set_attr "length" "4,4,4,4,4,20,4,4,4,4,4,4,4")])
8602
5f59ecb7 8603;; immediate value valid for a single instruction hiding in a const_double
a260abc9
DE
8604(define_insn ""
8605 [(set (match_operand:DI 0 "gpc_reg_operand" "=r")
8606 (match_operand:DI 1 "const_double_operand" "F"))]
5f59ecb7
DE
8607 "HOST_BITS_PER_WIDE_INT == 32 && TARGET_POWERPC64
8608 && GET_CODE (operands[1]) == CONST_DOUBLE
a260abc9
DE
8609 && num_insns_constant (operands[1], DImode) == 1"
8610 "*
8611{
8612 return ((unsigned HOST_WIDE_INT)
8613 (CONST_DOUBLE_LOW (operands[1]) + 0x8000) < 0x10000)
8614 ? \"li %0,%1\" : \"lis %0,%v1\";
8615}")
8616
a260abc9
DE
8617;; Generate all one-bits and clear left or right.
8618;; Use (and:DI (rotate:DI ...)) to avoid anddi3 unnecessary clobber.
8619(define_split
8620 [(set (match_operand:DI 0 "gpc_reg_operand" "")
8621 (match_operand:DI 1 "mask64_operand" ""))]
8622 "TARGET_POWERPC64 && num_insns_constant (operands[1], DImode) > 1"
8623 [(set (match_dup 0) (const_int -1))
e6ca2c17 8624 (set (match_dup 0)
a260abc9
DE
8625 (and:DI (rotate:DI (match_dup 0)
8626 (const_int 0))
8627 (match_dup 1)))]
8628 "")
8629
8630;; Split a load of a large constant into the appropriate five-instruction
8631;; sequence. Handle anything in a constant number of insns.
8632;; When non-easy constants can go in the TOC, this should use
8633;; easy_fp_constant predicate.
8634(define_split
8635 [(set (match_operand:DI 0 "gpc_reg_operand" "")
2bfcf297
DB
8636 (match_operand:DI 1 "const_int_operand" ""))]
8637 "TARGET_POWERPC64 && num_insns_constant (operands[1], DImode) > 1"
8638 [(set (match_dup 0) (match_dup 2))
8639 (set (match_dup 0) (plus:DI (match_dup 0) (match_dup 3)))]
e6ca2c17 8640 "
2bfcf297
DB
8641{ rtx tem = rs6000_emit_set_const (operands[0], DImode, operands[1], 5);
8642
8643 if (tem == operands[0])
8644 DONE;
e8d791dd 8645 else
2bfcf297 8646 FAIL;
5f59ecb7 8647}")
e6ca2c17 8648
5f59ecb7
DE
8649(define_split
8650 [(set (match_operand:DI 0 "gpc_reg_operand" "")
2bfcf297
DB
8651 (match_operand:DI 1 "const_double_operand" ""))]
8652 "TARGET_POWERPC64 && num_insns_constant (operands[1], DImode) > 1"
8653 [(set (match_dup 0) (match_dup 2))
8654 (set (match_dup 0) (plus:DI (match_dup 0) (match_dup 3)))]
5f59ecb7 8655 "
2bfcf297
DB
8656{ rtx tem = rs6000_emit_set_const (operands[0], DImode, operands[1], 5);
8657
8658 if (tem == operands[0])
8659 DONE;
8660 else
8661 FAIL;
e6ca2c17 8662}")
08075ead 8663
acad7ed3 8664(define_insn "*movdi_internal2"
bb84cb12
DE
8665 [(set (match_operand:CC 2 "cc_reg_operand" "=y,x,?y")
8666 (compare:CC (match_operand:DI 1 "gpc_reg_operand" "0,r,r")
08075ead 8667 (const_int 0)))
bb84cb12 8668 (set (match_operand:DI 0 "gpc_reg_operand" "=r,r,r") (match_dup 1))]
683bdff7 8669 "TARGET_64BIT"
9ebbca7d 8670 "@
bb84cb12 8671 cmpdi %2,%0,0
9ebbca7d
GK
8672 mr. %0,%1
8673 #"
bb84cb12
DE
8674 [(set_attr "type" "cmp,compare,cmp")
8675 (set_attr "length" "4,4,8")])
acad7ed3 8676
9ebbca7d
GK
8677(define_split
8678 [(set (match_operand:CC 2 "cc_reg_not_cr0_operand" "")
8679 (compare:CC (match_operand:DI 1 "gpc_reg_operand" "")
8680 (const_int 0)))
8681 (set (match_operand:DI 0 "gpc_reg_operand" "") (match_dup 1))]
8682 "TARGET_POWERPC64 && reload_completed"
8683 [(set (match_dup 0) (match_dup 1))
8684 (set (match_dup 2)
8685 (compare:CC (match_dup 0)
8686 (const_int 0)))]
8687 "")
acad7ed3 8688\f
1fd4e8c1
RK
8689;; TImode is similar, except that we usually want to compute the address into
8690;; a register and use lsi/stsi (the exception is during reload). MQ is also
ca7f5001 8691;; clobbered in stsi for POWER, so we need a SCRATCH for it.
1fd4e8c1
RK
8692(define_expand "movti"
8693 [(parallel [(set (match_operand:TI 0 "general_operand" "")
8694 (match_operand:TI 1 "general_operand" ""))
8695 (clobber (scratch:SI))])]
3a1f863f 8696 ""
fb4d4348 8697 "{ rs6000_emit_move (operands[0], operands[1], TImode); DONE; }")
1fd4e8c1
RK
8698
8699;; We say that MQ is clobbered in the last alternative because the first
8700;; alternative would never get used otherwise since it would need a reload
8701;; while the 2nd alternative would not. We put memory cases first so they
8702;; are preferred. Otherwise, we'd try to reload the output instead of
8703;; giving the SCRATCH mq.
3a1f863f 8704
a260abc9 8705(define_insn "*movti_power"
e1469d0d 8706 [(set (match_operand:TI 0 "reg_or_mem_operand" "=Q,m,????r,????r,????r")
1fd4e8c1
RK
8707 (match_operand:TI 1 "reg_or_mem_operand" "r,r,r,Q,m"))
8708 (clobber (match_scratch:SI 2 "=q,q#X,X,X,X"))]
683bdff7 8709 "TARGET_POWER && ! TARGET_POWERPC64
dc4f83ca 8710 && (gpc_reg_operand (operands[0], TImode) || gpc_reg_operand (operands[1], TImode))"
1fd4e8c1
RK
8711 "*
8712{
8713 switch (which_alternative)
8714 {
dc4f83ca
MM
8715 default:
8716 abort ();
8717
1fd4e8c1 8718 case 0:
3a1f863f
DE
8719 if (TARGET_STRING)
8720 return \"{stsi|stswi} %1,%P0,16\";
1fd4e8c1 8721 case 1:
1fd4e8c1 8722 case 2:
3a1f863f 8723 return \"#\";
1fd4e8c1
RK
8724 case 3:
8725 /* If the address is not used in the output, we can use lsi. Otherwise,
8726 fall through to generating four loads. */
e876481c
DE
8727 if (TARGET_STRING
8728 && ! reg_overlap_mentioned_p (operands[0], operands[1]))
ca7f5001 8729 return \"{lsi|lswi} %0,%P1,16\";
82e41834 8730 /* ... fall through ... */
1fd4e8c1 8731 case 4:
3a1f863f 8732 return \"#\";
1fd4e8c1
RK
8733 }
8734}"
3a1f863f 8735 [(set_attr "type" "store,store,*,load,load")])
51b8fc2c 8736
a260abc9 8737(define_insn "*movti_string"
cd1d3445 8738 [(set (match_operand:TI 0 "reg_or_mem_operand" "=Q,m,????r,????r,????r")
27dc0551 8739 (match_operand:TI 1 "reg_or_mem_operand" "r,r,r,Q,m"))]
3a1f863f 8740 "! TARGET_POWER && ! TARGET_POWERPC64
dc4f83ca
MM
8741 && (gpc_reg_operand (operands[0], TImode) || gpc_reg_operand (operands[1], TImode))"
8742 "*
8743{
8744 switch (which_alternative)
8745 {
8746 default:
8747 abort ();
dc4f83ca 8748 case 0:
3a1f863f
DE
8749 if (TARGET_STRING)
8750 return \"{stsi|stswi} %1,%P0,16\";
dc4f83ca 8751 case 1:
cd1d3445 8752 case 2:
3a1f863f 8753 return \"#\";
cd1d3445
DE
8754 case 3:
8755 /* If the address is not used in the output, we can use lsi. Otherwise,
8756 fall through to generating four loads. */
3a1f863f
DE
8757 if (TARGET_STRING
8758 && ! reg_overlap_mentioned_p (operands[0], operands[1]))
cd1d3445
DE
8759 return \"{lsi|lswi} %0,%P1,16\";
8760 /* ... fall through ... */
8761 case 4:
3a1f863f 8762 return \"#\";
dc4f83ca
MM
8763 }
8764}"
3a1f863f 8765 [(set_attr "type" "store,store,*,load,load")])
dc4f83ca 8766
a260abc9 8767(define_insn "*movti_ppc64"
3a1f863f
DE
8768 [(set (match_operand:TI 0 "nonimmediate_operand" "=r,m,r")
8769 (match_operand:TI 1 "input_operand" "r,r,o"))]
51b8fc2c
RK
8770 "TARGET_POWERPC64 && (gpc_reg_operand (operands[0], TImode)
8771 || gpc_reg_operand (operands[1], TImode))"
3a1f863f
DE
8772 "@
8773 #
8774 #
8775 #"
8776 [(set_attr "type" "*,load,store")])
8777
8778(define_split
8779 [(set (match_operand:TI 0 "nonimmediate_operand" "")
8780 (match_operand:TI 1 "input_operand" ""))]
8781 "reload_completed && TARGET_POWERPC64
8782 && gpr_or_gpr_p (operands[0], operands[1])"
8783 [(set (match_dup 2) (match_dup 4))
8784 (set (match_dup 3) (match_dup 5))]
8785"{
8786 rs6000_split_multireg_move (operands);
8787}")
8788
8789(define_split
8790 [(set (match_operand:TI 0 "nonimmediate_operand" "")
8791 (match_operand:TI 1 "input_operand" ""))]
8792 "reload_completed && !TARGET_POWERPC64
8793 && gpr_or_gpr_p (operands[0], operands[1])"
8794 [(set (match_dup 2) (match_dup 6))
8795 (set (match_dup 3) (match_dup 7))
8796 (set (match_dup 4) (match_dup 8))
8797 (set (match_dup 5) (match_dup 9))]
8798"{
8799 rs6000_split_multireg_move (operands);
8800}")
8801
8802
1fd4e8c1
RK
8803\f
8804(define_expand "load_multiple"
2f622005
RK
8805 [(match_par_dup 3 [(set (match_operand:SI 0 "" "")
8806 (match_operand:SI 1 "" ""))
8807 (use (match_operand:SI 2 "" ""))])]
09a625f7 8808 "TARGET_STRING && !TARGET_POWERPC64"
1fd4e8c1
RK
8809 "
8810{
8811 int regno;
8812 int count;
792760b9 8813 rtx op1;
1fd4e8c1
RK
8814 int i;
8815
8816 /* Support only loading a constant number of fixed-point registers from
8817 memory and only bother with this if more than two; the machine
8818 doesn't support more than eight. */
8819 if (GET_CODE (operands[2]) != CONST_INT
8820 || INTVAL (operands[2]) <= 2
8821 || INTVAL (operands[2]) > 8
8822 || GET_CODE (operands[1]) != MEM
8823 || GET_CODE (operands[0]) != REG
8824 || REGNO (operands[0]) >= 32)
8825 FAIL;
8826
8827 count = INTVAL (operands[2]);
8828 regno = REGNO (operands[0]);
8829
39403d82 8830 operands[3] = gen_rtx_PARALLEL (VOIDmode, rtvec_alloc (count));
792760b9
RK
8831 op1 = replace_equiv_address (operands[1],
8832 force_reg (SImode, XEXP (operands[1], 0)));
1fd4e8c1
RK
8833
8834 for (i = 0; i < count; i++)
8835 XVECEXP (operands[3], 0, i)
39403d82 8836 = gen_rtx_SET (VOIDmode, gen_rtx_REG (SImode, regno + i),
7ef788f0 8837 adjust_address_nv (op1, SImode, i * 4));
1fd4e8c1
RK
8838}")
8839
9caa3eb2 8840(define_insn "*ldmsi8"
1fd4e8c1 8841 [(match_parallel 0 "load_multiple_operation"
9caa3eb2
DE
8842 [(set (match_operand:SI 2 "gpc_reg_operand" "")
8843 (mem:SI (match_operand:SI 1 "gpc_reg_operand" "b")))
8844 (set (match_operand:SI 3 "gpc_reg_operand" "")
8845 (mem:SI (plus:SI (match_dup 1) (const_int 4))))
8846 (set (match_operand:SI 4 "gpc_reg_operand" "")
8847 (mem:SI (plus:SI (match_dup 1) (const_int 8))))
8848 (set (match_operand:SI 5 "gpc_reg_operand" "")
8849 (mem:SI (plus:SI (match_dup 1) (const_int 12))))
8850 (set (match_operand:SI 6 "gpc_reg_operand" "")
8851 (mem:SI (plus:SI (match_dup 1) (const_int 16))))
8852 (set (match_operand:SI 7 "gpc_reg_operand" "")
8853 (mem:SI (plus:SI (match_dup 1) (const_int 20))))
8854 (set (match_operand:SI 8 "gpc_reg_operand" "")
8855 (mem:SI (plus:SI (match_dup 1) (const_int 24))))
8856 (set (match_operand:SI 9 "gpc_reg_operand" "")
8857 (mem:SI (plus:SI (match_dup 1) (const_int 28))))])]
8858 "TARGET_STRING && XVECLEN (operands[0], 0) == 8"
1fd4e8c1 8859 "*
9caa3eb2
DE
8860{ return rs6000_output_load_multiple (operands); }"
8861 [(set_attr "type" "load")
8862 (set_attr "length" "32")])
1fd4e8c1 8863
9caa3eb2
DE
8864(define_insn "*ldmsi7"
8865 [(match_parallel 0 "load_multiple_operation"
8866 [(set (match_operand:SI 2 "gpc_reg_operand" "")
8867 (mem:SI (match_operand:SI 1 "gpc_reg_operand" "b")))
8868 (set (match_operand:SI 3 "gpc_reg_operand" "")
8869 (mem:SI (plus:SI (match_dup 1) (const_int 4))))
8870 (set (match_operand:SI 4 "gpc_reg_operand" "")
8871 (mem:SI (plus:SI (match_dup 1) (const_int 8))))
8872 (set (match_operand:SI 5 "gpc_reg_operand" "")
8873 (mem:SI (plus:SI (match_dup 1) (const_int 12))))
8874 (set (match_operand:SI 6 "gpc_reg_operand" "")
8875 (mem:SI (plus:SI (match_dup 1) (const_int 16))))
8876 (set (match_operand:SI 7 "gpc_reg_operand" "")
8877 (mem:SI (plus:SI (match_dup 1) (const_int 20))))
8878 (set (match_operand:SI 8 "gpc_reg_operand" "")
8879 (mem:SI (plus:SI (match_dup 1) (const_int 24))))])]
8880 "TARGET_STRING && XVECLEN (operands[0], 0) == 7"
8881 "*
8882{ return rs6000_output_load_multiple (operands); }"
8883 [(set_attr "type" "load")
8884 (set_attr "length" "32")])
8885
8886(define_insn "*ldmsi6"
8887 [(match_parallel 0 "load_multiple_operation"
8888 [(set (match_operand:SI 2 "gpc_reg_operand" "")
8889 (mem:SI (match_operand:SI 1 "gpc_reg_operand" "b")))
8890 (set (match_operand:SI 3 "gpc_reg_operand" "")
8891 (mem:SI (plus:SI (match_dup 1) (const_int 4))))
8892 (set (match_operand:SI 4 "gpc_reg_operand" "")
8893 (mem:SI (plus:SI (match_dup 1) (const_int 8))))
8894 (set (match_operand:SI 5 "gpc_reg_operand" "")
8895 (mem:SI (plus:SI (match_dup 1) (const_int 12))))
8896 (set (match_operand:SI 6 "gpc_reg_operand" "")
8897 (mem:SI (plus:SI (match_dup 1) (const_int 16))))
8898 (set (match_operand:SI 7 "gpc_reg_operand" "")
8899 (mem:SI (plus:SI (match_dup 1) (const_int 20))))])]
8900 "TARGET_STRING && XVECLEN (operands[0], 0) == 6"
8901 "*
8902{ return rs6000_output_load_multiple (operands); }"
8903 [(set_attr "type" "load")
8904 (set_attr "length" "32")])
8905
8906(define_insn "*ldmsi5"
8907 [(match_parallel 0 "load_multiple_operation"
8908 [(set (match_operand:SI 2 "gpc_reg_operand" "")
8909 (mem:SI (match_operand:SI 1 "gpc_reg_operand" "b")))
8910 (set (match_operand:SI 3 "gpc_reg_operand" "")
8911 (mem:SI (plus:SI (match_dup 1) (const_int 4))))
8912 (set (match_operand:SI 4 "gpc_reg_operand" "")
8913 (mem:SI (plus:SI (match_dup 1) (const_int 8))))
8914 (set (match_operand:SI 5 "gpc_reg_operand" "")
8915 (mem:SI (plus:SI (match_dup 1) (const_int 12))))
8916 (set (match_operand:SI 6 "gpc_reg_operand" "")
8917 (mem:SI (plus:SI (match_dup 1) (const_int 16))))])]
8918 "TARGET_STRING && XVECLEN (operands[0], 0) == 5"
8919 "*
8920{ return rs6000_output_load_multiple (operands); }"
8921 [(set_attr "type" "load")
8922 (set_attr "length" "32")])
8923
8924(define_insn "*ldmsi4"
8925 [(match_parallel 0 "load_multiple_operation"
8926 [(set (match_operand:SI 2 "gpc_reg_operand" "")
8927 (mem:SI (match_operand:SI 1 "gpc_reg_operand" "b")))
8928 (set (match_operand:SI 3 "gpc_reg_operand" "")
8929 (mem:SI (plus:SI (match_dup 1) (const_int 4))))
8930 (set (match_operand:SI 4 "gpc_reg_operand" "")
8931 (mem:SI (plus:SI (match_dup 1) (const_int 8))))
8932 (set (match_operand:SI 5 "gpc_reg_operand" "")
8933 (mem:SI (plus:SI (match_dup 1) (const_int 12))))])]
8934 "TARGET_STRING && XVECLEN (operands[0], 0) == 4"
8935 "*
8936{ return rs6000_output_load_multiple (operands); }"
8937 [(set_attr "type" "load")
8938 (set_attr "length" "32")])
8939
8940(define_insn "*ldmsi3"
8941 [(match_parallel 0 "load_multiple_operation"
8942 [(set (match_operand:SI 2 "gpc_reg_operand" "")
8943 (mem:SI (match_operand:SI 1 "gpc_reg_operand" "b")))
8944 (set (match_operand:SI 3 "gpc_reg_operand" "")
8945 (mem:SI (plus:SI (match_dup 1) (const_int 4))))
8946 (set (match_operand:SI 4 "gpc_reg_operand" "")
8947 (mem:SI (plus:SI (match_dup 1) (const_int 8))))])]
8948 "TARGET_STRING && XVECLEN (operands[0], 0) == 3"
8949 "*
8950{ return rs6000_output_load_multiple (operands); }"
b19003d8 8951 [(set_attr "type" "load")
e82ee4cc 8952 (set_attr "length" "32")])
b19003d8 8953
1fd4e8c1 8954(define_expand "store_multiple"
2f622005
RK
8955 [(match_par_dup 3 [(set (match_operand:SI 0 "" "")
8956 (match_operand:SI 1 "" ""))
8957 (clobber (scratch:SI))
8958 (use (match_operand:SI 2 "" ""))])]
09a625f7 8959 "TARGET_STRING && !TARGET_POWERPC64"
1fd4e8c1
RK
8960 "
8961{
8962 int regno;
8963 int count;
8964 rtx to;
792760b9 8965 rtx op0;
1fd4e8c1
RK
8966 int i;
8967
8968 /* Support only storing a constant number of fixed-point registers to
8969 memory and only bother with this if more than two; the machine
8970 doesn't support more than eight. */
8971 if (GET_CODE (operands[2]) != CONST_INT
8972 || INTVAL (operands[2]) <= 2
8973 || INTVAL (operands[2]) > 8
8974 || GET_CODE (operands[0]) != MEM
8975 || GET_CODE (operands[1]) != REG
8976 || REGNO (operands[1]) >= 32)
8977 FAIL;
8978
8979 count = INTVAL (operands[2]);
8980 regno = REGNO (operands[1]);
8981
39403d82 8982 operands[3] = gen_rtx_PARALLEL (VOIDmode, rtvec_alloc (count + 1));
1fd4e8c1 8983 to = force_reg (SImode, XEXP (operands[0], 0));
792760b9 8984 op0 = replace_equiv_address (operands[0], to);
1fd4e8c1
RK
8985
8986 XVECEXP (operands[3], 0, 0)
7ef788f0 8987 = gen_rtx_SET (VOIDmode, adjust_address_nv (op0, SImode, 0), operands[1]);
39403d82 8988 XVECEXP (operands[3], 0, 1) = gen_rtx_CLOBBER (VOIDmode,
c5c76735 8989 gen_rtx_SCRATCH (SImode));
1fd4e8c1
RK
8990
8991 for (i = 1; i < count; i++)
8992 XVECEXP (operands[3], 0, i + 1)
39403d82 8993 = gen_rtx_SET (VOIDmode,
7ef788f0 8994 adjust_address_nv (op0, SImode, i * 4),
c5c76735 8995 gen_rtx_REG (SImode, regno + i));
1fd4e8c1
RK
8996}")
8997
9caa3eb2 8998(define_insn "*store_multiple_power"
1fd4e8c1
RK
8999 [(match_parallel 0 "store_multiple_operation"
9000 [(set (match_operand:SI 1 "indirect_operand" "=Q")
cd2b37d9 9001 (match_operand:SI 2 "gpc_reg_operand" "r"))
1fd4e8c1 9002 (clobber (match_scratch:SI 3 "=q"))])]
7e69e155 9003 "TARGET_STRING && TARGET_POWER"
b7ff3d82
DE
9004 "{stsi|stswi} %2,%P1,%O0"
9005 [(set_attr "type" "store")])
d14a6d05 9006
e46e3130 9007(define_insn "*stmsi8"
d14a6d05 9008 [(match_parallel 0 "store_multiple_operation"
e46e3130
DJ
9009 [(set (mem:SI (match_operand:SI 1 "gpc_reg_operand" "b"))
9010 (match_operand:SI 2 "gpc_reg_operand" "r"))
9011 (clobber (match_scratch:SI 3 "X"))
9012 (set (mem:SI (plus:SI (match_dup 1) (const_int 4)))
9013 (match_operand:SI 4 "gpc_reg_operand" "r"))
9014 (set (mem:SI (plus:SI (match_dup 1) (const_int 8)))
9015 (match_operand:SI 5 "gpc_reg_operand" "r"))
9016 (set (mem:SI (plus:SI (match_dup 1) (const_int 12)))
9017 (match_operand:SI 6 "gpc_reg_operand" "r"))
9018 (set (mem:SI (plus:SI (match_dup 1) (const_int 16)))
9019 (match_operand:SI 7 "gpc_reg_operand" "r"))
9020 (set (mem:SI (plus:SI (match_dup 1) (const_int 20)))
9021 (match_operand:SI 8 "gpc_reg_operand" "r"))
9022 (set (mem:SI (plus:SI (match_dup 1) (const_int 24)))
9023 (match_operand:SI 9 "gpc_reg_operand" "r"))
9024 (set (mem:SI (plus:SI (match_dup 1) (const_int 28)))
9025 (match_operand:SI 10 "gpc_reg_operand" "r"))])]
9026 "TARGET_STRING && !TARGET_POWER && XVECLEN (operands[0], 0) == 9"
9027 "{stsi|stswi} %2,%1,%O0"
9028 [(set_attr "type" "store")])
9029
9030(define_insn "*stmsi7"
9031 [(match_parallel 0 "store_multiple_operation"
9032 [(set (mem:SI (match_operand:SI 1 "gpc_reg_operand" "b"))
9033 (match_operand:SI 2 "gpc_reg_operand" "r"))
9034 (clobber (match_scratch:SI 3 "X"))
9035 (set (mem:SI (plus:SI (match_dup 1) (const_int 4)))
9036 (match_operand:SI 4 "gpc_reg_operand" "r"))
9037 (set (mem:SI (plus:SI (match_dup 1) (const_int 8)))
9038 (match_operand:SI 5 "gpc_reg_operand" "r"))
9039 (set (mem:SI (plus:SI (match_dup 1) (const_int 12)))
9040 (match_operand:SI 6 "gpc_reg_operand" "r"))
9041 (set (mem:SI (plus:SI (match_dup 1) (const_int 16)))
9042 (match_operand:SI 7 "gpc_reg_operand" "r"))
9043 (set (mem:SI (plus:SI (match_dup 1) (const_int 20)))
9044 (match_operand:SI 8 "gpc_reg_operand" "r"))
9045 (set (mem:SI (plus:SI (match_dup 1) (const_int 24)))
9046 (match_operand:SI 9 "gpc_reg_operand" "r"))])]
9047 "TARGET_STRING && !TARGET_POWER && XVECLEN (operands[0], 0) == 8"
9048 "{stsi|stswi} %2,%1,%O0"
9049 [(set_attr "type" "store")])
9050
9051(define_insn "*stmsi6"
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 (set (mem:SI (plus:SI (match_dup 1) (const_int 20)))
9065 (match_operand:SI 8 "gpc_reg_operand" "r"))])]
9066 "TARGET_STRING && !TARGET_POWER && XVECLEN (operands[0], 0) == 7"
9067 "{stsi|stswi} %2,%1,%O0"
9068 [(set_attr "type" "store")])
9069
9070(define_insn "*stmsi5"
9071 [(match_parallel 0 "store_multiple_operation"
9072 [(set (mem:SI (match_operand:SI 1 "gpc_reg_operand" "b"))
9073 (match_operand:SI 2 "gpc_reg_operand" "r"))
9074 (clobber (match_scratch:SI 3 "X"))
9075 (set (mem:SI (plus:SI (match_dup 1) (const_int 4)))
9076 (match_operand:SI 4 "gpc_reg_operand" "r"))
9077 (set (mem:SI (plus:SI (match_dup 1) (const_int 8)))
9078 (match_operand:SI 5 "gpc_reg_operand" "r"))
9079 (set (mem:SI (plus:SI (match_dup 1) (const_int 12)))
9080 (match_operand:SI 6 "gpc_reg_operand" "r"))
9081 (set (mem:SI (plus:SI (match_dup 1) (const_int 16)))
9082 (match_operand:SI 7 "gpc_reg_operand" "r"))])]
9083 "TARGET_STRING && !TARGET_POWER && XVECLEN (operands[0], 0) == 6"
9084 "{stsi|stswi} %2,%1,%O0"
9085 [(set_attr "type" "store")])
9086
9087(define_insn "*stmsi4"
9088 [(match_parallel 0 "store_multiple_operation"
9089 [(set (mem:SI (match_operand:SI 1 "gpc_reg_operand" "b"))
9090 (match_operand:SI 2 "gpc_reg_operand" "r"))
9091 (clobber (match_scratch:SI 3 "X"))
9092 (set (mem:SI (plus:SI (match_dup 1) (const_int 4)))
9093 (match_operand:SI 4 "gpc_reg_operand" "r"))
9094 (set (mem:SI (plus:SI (match_dup 1) (const_int 8)))
9095 (match_operand:SI 5 "gpc_reg_operand" "r"))
9096 (set (mem:SI (plus:SI (match_dup 1) (const_int 12)))
9097 (match_operand:SI 6 "gpc_reg_operand" "r"))])]
9098 "TARGET_STRING && !TARGET_POWER && XVECLEN (operands[0], 0) == 5"
b7ff3d82
DE
9099 "{stsi|stswi} %2,%1,%O0"
9100 [(set_attr "type" "store")])
7e69e155 9101
e46e3130
DJ
9102(define_insn "*stmsi3"
9103 [(match_parallel 0 "store_multiple_operation"
9104 [(set (mem:SI (match_operand:SI 1 "gpc_reg_operand" "b"))
9105 (match_operand:SI 2 "gpc_reg_operand" "r"))
9106 (clobber (match_scratch:SI 3 "X"))
9107 (set (mem:SI (plus:SI (match_dup 1) (const_int 4)))
9108 (match_operand:SI 4 "gpc_reg_operand" "r"))
9109 (set (mem:SI (plus:SI (match_dup 1) (const_int 8)))
9110 (match_operand:SI 5 "gpc_reg_operand" "r"))])]
9111 "TARGET_STRING && !TARGET_POWER && XVECLEN (operands[0], 0) == 4"
9112 "{stsi|stswi} %2,%1,%O0"
9113 [(set_attr "type" "store")])
7e69e155
MM
9114\f
9115;; String/block move insn.
9116;; Argument 0 is the destination
9117;; Argument 1 is the source
9118;; Argument 2 is the length
9119;; Argument 3 is the alignment
9120
9121(define_expand "movstrsi"
b6c9286a
MM
9122 [(parallel [(set (match_operand:BLK 0 "" "")
9123 (match_operand:BLK 1 "" ""))
9124 (use (match_operand:SI 2 "" ""))
9125 (use (match_operand:SI 3 "" ""))])]
7e69e155
MM
9126 ""
9127 "
9128{
9129 if (expand_block_move (operands))
9130 DONE;
9131 else
9132 FAIL;
9133}")
9134
9135;; Move up to 32 bytes at a time. The fixed registers are needed because the
f9562f27
DE
9136;; register allocator doesn't have a clue about allocating 8 word registers.
9137;; rD/rS = r5 is preferred, efficient form.
7e69e155 9138(define_expand "movstrsi_8reg"
b6c9286a
MM
9139 [(parallel [(set (match_operand 0 "" "")
9140 (match_operand 1 "" ""))
9141 (use (match_operand 2 "" ""))
9142 (use (match_operand 3 "" ""))
7e69e155
MM
9143 (clobber (reg:SI 5))
9144 (clobber (reg:SI 6))
9145 (clobber (reg:SI 7))
9146 (clobber (reg:SI 8))
9147 (clobber (reg:SI 9))
9148 (clobber (reg:SI 10))
9149 (clobber (reg:SI 11))
9150 (clobber (reg:SI 12))
3c67b673 9151 (clobber (match_scratch:SI 4 ""))])]
7e69e155
MM
9152 "TARGET_STRING"
9153 "")
9154
9155(define_insn ""
52d3af72
DE
9156 [(set (mem:BLK (match_operand:SI 0 "gpc_reg_operand" "b"))
9157 (mem:BLK (match_operand:SI 1 "gpc_reg_operand" "b")))
3c67b673
RK
9158 (use (match_operand:SI 2 "immediate_operand" "i"))
9159 (use (match_operand:SI 3 "immediate_operand" "i"))
52d3af72 9160 (clobber (match_operand:SI 4 "gpc_reg_operand" "=r"))
7e69e155
MM
9161 (clobber (reg:SI 6))
9162 (clobber (reg:SI 7))
9163 (clobber (reg:SI 8))
9164 (clobber (reg:SI 9))
9165 (clobber (reg:SI 10))
9166 (clobber (reg:SI 11))
9167 (clobber (reg:SI 12))
3c67b673 9168 (clobber (match_scratch:SI 5 "=q"))]
7e69e155 9169 "TARGET_STRING && TARGET_POWER
f9562f27
DE
9170 && ((INTVAL (operands[2]) > 24 && INTVAL (operands[2]) < 32)
9171 || INTVAL (operands[2]) == 0)
7e69e155
MM
9172 && (REGNO (operands[0]) < 5 || REGNO (operands[0]) > 12)
9173 && (REGNO (operands[1]) < 5 || REGNO (operands[1]) > 12)
3c67b673
RK
9174 && REGNO (operands[4]) == 5"
9175 "{lsi|lswi} %4,%1,%2\;{stsi|stswi} %4,%0,%2"
b7ff3d82
DE
9176 [(set_attr "type" "load")
9177 (set_attr "length" "8")])
7e69e155
MM
9178
9179(define_insn ""
52d3af72
DE
9180 [(set (mem:BLK (match_operand:SI 0 "gpc_reg_operand" "b"))
9181 (mem:BLK (match_operand:SI 1 "gpc_reg_operand" "b")))
3c67b673
RK
9182 (use (match_operand:SI 2 "immediate_operand" "i"))
9183 (use (match_operand:SI 3 "immediate_operand" "i"))
52d3af72 9184 (clobber (match_operand:SI 4 "gpc_reg_operand" "=r"))
7e69e155
MM
9185 (clobber (reg:SI 6))
9186 (clobber (reg:SI 7))
9187 (clobber (reg:SI 8))
9188 (clobber (reg:SI 9))
9189 (clobber (reg:SI 10))
9190 (clobber (reg:SI 11))
9191 (clobber (reg:SI 12))
3c67b673 9192 (clobber (match_scratch:SI 5 "X"))]
0ad91047 9193 "TARGET_STRING && ! TARGET_POWER
f9562f27
DE
9194 && ((INTVAL (operands[2]) > 24 && INTVAL (operands[2]) < 32)
9195 || INTVAL (operands[2]) == 0)
7e69e155
MM
9196 && (REGNO (operands[0]) < 5 || REGNO (operands[0]) > 12)
9197 && (REGNO (operands[1]) < 5 || REGNO (operands[1]) > 12)
3c67b673
RK
9198 && REGNO (operands[4]) == 5"
9199 "{lsi|lswi} %4,%1,%2\;{stsi|stswi} %4,%0,%2"
b7ff3d82
DE
9200 [(set_attr "type" "load")
9201 (set_attr "length" "8")])
7e69e155 9202
09a625f7
TR
9203(define_insn ""
9204 [(set (mem:BLK (match_operand:DI 0 "gpc_reg_operand" "b"))
9205 (mem:BLK (match_operand:DI 1 "gpc_reg_operand" "b")))
9206 (use (match_operand:SI 2 "immediate_operand" "i"))
9207 (use (match_operand:SI 3 "immediate_operand" "i"))
9208 (clobber (match_operand:SI 4 "gpc_reg_operand" "=r"))
9209 (clobber (reg:SI 6))
9210 (clobber (reg:SI 7))
9211 (clobber (reg:SI 8))
9212 (clobber (reg:SI 9))
9213 (clobber (reg:SI 10))
9214 (clobber (reg:SI 11))
9215 (clobber (reg:SI 12))
9216 (clobber (match_scratch:SI 5 "X"))]
9217 "TARGET_STRING && TARGET_POWERPC64
9218 && ((INTVAL (operands[2]) > 24 && INTVAL (operands[2]) < 32)
9219 || INTVAL (operands[2]) == 0)
9220 && (REGNO (operands[0]) < 5 || REGNO (operands[0]) > 12)
9221 && (REGNO (operands[1]) < 5 || REGNO (operands[1]) > 12)
9222 && REGNO (operands[4]) == 5"
9223 "{lsi|lswi} %4,%1,%2\;{stsi|stswi} %4,%0,%2"
9224 [(set_attr "type" "load")
9225 (set_attr "length" "8")])
9226
7e69e155 9227;; Move up to 24 bytes at a time. The fixed registers are needed because the
f9562f27
DE
9228;; register allocator doesn't have a clue about allocating 6 word registers.
9229;; rD/rS = r5 is preferred, efficient form.
7e69e155 9230(define_expand "movstrsi_6reg"
b6c9286a
MM
9231 [(parallel [(set (match_operand 0 "" "")
9232 (match_operand 1 "" ""))
9233 (use (match_operand 2 "" ""))
9234 (use (match_operand 3 "" ""))
f9562f27
DE
9235 (clobber (reg:SI 5))
9236 (clobber (reg:SI 6))
7e69e155
MM
9237 (clobber (reg:SI 7))
9238 (clobber (reg:SI 8))
9239 (clobber (reg:SI 9))
9240 (clobber (reg:SI 10))
3c67b673 9241 (clobber (match_scratch:SI 4 ""))])]
7e69e155
MM
9242 "TARGET_STRING"
9243 "")
9244
9245(define_insn ""
52d3af72
DE
9246 [(set (mem:BLK (match_operand:SI 0 "gpc_reg_operand" "b"))
9247 (mem:BLK (match_operand:SI 1 "gpc_reg_operand" "b")))
3c67b673
RK
9248 (use (match_operand:SI 2 "immediate_operand" "i"))
9249 (use (match_operand:SI 3 "immediate_operand" "i"))
52d3af72 9250 (clobber (match_operand:SI 4 "gpc_reg_operand" "=r"))
f9562f27
DE
9251 (clobber (reg:SI 6))
9252 (clobber (reg:SI 7))
7e69e155
MM
9253 (clobber (reg:SI 8))
9254 (clobber (reg:SI 9))
9255 (clobber (reg:SI 10))
3c67b673 9256 (clobber (match_scratch:SI 5 "=q"))]
7e69e155
MM
9257 "TARGET_STRING && TARGET_POWER
9258 && INTVAL (operands[2]) > 16 && INTVAL (operands[2]) <= 24
f9562f27
DE
9259 && (REGNO (operands[0]) < 5 || REGNO (operands[0]) > 10)
9260 && (REGNO (operands[1]) < 5 || REGNO (operands[1]) > 10)
9261 && REGNO (operands[4]) == 5"
3c67b673 9262 "{lsi|lswi} %4,%1,%2\;{stsi|stswi} %4,%0,%2"
b7ff3d82
DE
9263 [(set_attr "type" "load")
9264 (set_attr "length" "8")])
7e69e155
MM
9265
9266(define_insn ""
52d3af72
DE
9267 [(set (mem:BLK (match_operand:SI 0 "gpc_reg_operand" "b"))
9268 (mem:BLK (match_operand:SI 1 "gpc_reg_operand" "b")))
3c67b673
RK
9269 (use (match_operand:SI 2 "immediate_operand" "i"))
9270 (use (match_operand:SI 3 "immediate_operand" "i"))
52d3af72 9271 (clobber (match_operand:SI 4 "gpc_reg_operand" "=r"))
f9562f27
DE
9272 (clobber (reg:SI 6))
9273 (clobber (reg:SI 7))
7e69e155
MM
9274 (clobber (reg:SI 8))
9275 (clobber (reg:SI 9))
9276 (clobber (reg:SI 10))
3c67b673 9277 (clobber (match_scratch:SI 5 "X"))]
0ad91047 9278 "TARGET_STRING && ! TARGET_POWER
7e69e155 9279 && INTVAL (operands[2]) > 16 && INTVAL (operands[2]) <= 32
f9562f27
DE
9280 && (REGNO (operands[0]) < 5 || REGNO (operands[0]) > 10)
9281 && (REGNO (operands[1]) < 5 || REGNO (operands[1]) > 10)
9282 && REGNO (operands[4]) == 5"
3c67b673 9283 "{lsi|lswi} %4,%1,%2\;{stsi|stswi} %4,%0,%2"
b7ff3d82
DE
9284 [(set_attr "type" "load")
9285 (set_attr "length" "8")])
7e69e155 9286
09a625f7
TR
9287(define_insn ""
9288 [(set (mem:BLK (match_operand:DI 0 "gpc_reg_operand" "b"))
9289 (mem:BLK (match_operand:DI 1 "gpc_reg_operand" "b")))
9290 (use (match_operand:SI 2 "immediate_operand" "i"))
9291 (use (match_operand:SI 3 "immediate_operand" "i"))
9292 (clobber (match_operand:SI 4 "gpc_reg_operand" "=r"))
9293 (clobber (reg:SI 6))
9294 (clobber (reg:SI 7))
9295 (clobber (reg:SI 8))
9296 (clobber (reg:SI 9))
9297 (clobber (reg:SI 10))
9298 (clobber (match_scratch:SI 5 "X"))]
9299 "TARGET_STRING && TARGET_POWERPC64
9300 && INTVAL (operands[2]) > 16 && INTVAL (operands[2]) <= 32
9301 && (REGNO (operands[0]) < 5 || REGNO (operands[0]) > 10)
9302 && (REGNO (operands[1]) < 5 || REGNO (operands[1]) > 10)
9303 && REGNO (operands[4]) == 5"
9304 "{lsi|lswi} %4,%1,%2\;{stsi|stswi} %4,%0,%2"
9305 [(set_attr "type" "load")
9306 (set_attr "length" "8")])
9307
f9562f27
DE
9308;; Move up to 16 bytes at a time, using 4 fixed registers to avoid spill
9309;; problems with TImode.
9310;; rD/rS = r5 is preferred, efficient form.
7e69e155 9311(define_expand "movstrsi_4reg"
b6c9286a
MM
9312 [(parallel [(set (match_operand 0 "" "")
9313 (match_operand 1 "" ""))
9314 (use (match_operand 2 "" ""))
9315 (use (match_operand 3 "" ""))
f9562f27
DE
9316 (clobber (reg:SI 5))
9317 (clobber (reg:SI 6))
9318 (clobber (reg:SI 7))
9319 (clobber (reg:SI 8))
3c67b673 9320 (clobber (match_scratch:SI 4 ""))])]
7e69e155
MM
9321 "TARGET_STRING"
9322 "")
9323
9324(define_insn ""
52d3af72
DE
9325 [(set (mem:BLK (match_operand:SI 0 "gpc_reg_operand" "b"))
9326 (mem:BLK (match_operand:SI 1 "gpc_reg_operand" "b")))
3c67b673
RK
9327 (use (match_operand:SI 2 "immediate_operand" "i"))
9328 (use (match_operand:SI 3 "immediate_operand" "i"))
52d3af72 9329 (clobber (match_operand:SI 4 "gpc_reg_operand" "=r"))
f9562f27
DE
9330 (clobber (reg:SI 6))
9331 (clobber (reg:SI 7))
9332 (clobber (reg:SI 8))
3c67b673 9333 (clobber (match_scratch:SI 5 "=q"))]
7e69e155
MM
9334 "TARGET_STRING && TARGET_POWER
9335 && INTVAL (operands[2]) > 8 && INTVAL (operands[2]) <= 16
f9562f27
DE
9336 && (REGNO (operands[0]) < 5 || REGNO (operands[0]) > 8)
9337 && (REGNO (operands[1]) < 5 || REGNO (operands[1]) > 8)
9338 && REGNO (operands[4]) == 5"
3c67b673 9339 "{lsi|lswi} %4,%1,%2\;{stsi|stswi} %4,%0,%2"
b7ff3d82
DE
9340 [(set_attr "type" "load")
9341 (set_attr "length" "8")])
7e69e155
MM
9342
9343(define_insn ""
52d3af72
DE
9344 [(set (mem:BLK (match_operand:SI 0 "gpc_reg_operand" "b"))
9345 (mem:BLK (match_operand:SI 1 "gpc_reg_operand" "b")))
3c67b673
RK
9346 (use (match_operand:SI 2 "immediate_operand" "i"))
9347 (use (match_operand:SI 3 "immediate_operand" "i"))
52d3af72 9348 (clobber (match_operand:SI 4 "gpc_reg_operand" "=r"))
f9562f27
DE
9349 (clobber (reg:SI 6))
9350 (clobber (reg:SI 7))
9351 (clobber (reg:SI 8))
3c67b673 9352 (clobber (match_scratch:SI 5 "X"))]
0ad91047 9353 "TARGET_STRING && ! TARGET_POWER
7e69e155 9354 && INTVAL (operands[2]) > 8 && INTVAL (operands[2]) <= 16
f9562f27
DE
9355 && (REGNO (operands[0]) < 5 || REGNO (operands[0]) > 8)
9356 && (REGNO (operands[1]) < 5 || REGNO (operands[1]) > 8)
9357 && REGNO (operands[4]) == 5"
3c67b673 9358 "{lsi|lswi} %4,%1,%2\;{stsi|stswi} %4,%0,%2"
b7ff3d82
DE
9359 [(set_attr "type" "load")
9360 (set_attr "length" "8")])
7e69e155 9361
09a625f7
TR
9362(define_insn ""
9363 [(set (mem:BLK (match_operand:DI 0 "gpc_reg_operand" "b"))
9364 (mem:BLK (match_operand:DI 1 "gpc_reg_operand" "b")))
9365 (use (match_operand:SI 2 "immediate_operand" "i"))
9366 (use (match_operand:SI 3 "immediate_operand" "i"))
9367 (clobber (match_operand:SI 4 "gpc_reg_operand" "=r"))
9368 (clobber (reg:SI 6))
9369 (clobber (reg:SI 7))
9370 (clobber (reg:SI 8))
9371 (clobber (match_scratch:SI 5 "X"))]
9372 "TARGET_STRING && TARGET_POWERPC64
9373 && INTVAL (operands[2]) > 8 && INTVAL (operands[2]) <= 16
9374 && (REGNO (operands[0]) < 5 || REGNO (operands[0]) > 8)
9375 && (REGNO (operands[1]) < 5 || REGNO (operands[1]) > 8)
9376 && REGNO (operands[4]) == 5"
9377 "{lsi|lswi} %4,%1,%2\;{stsi|stswi} %4,%0,%2"
9378 [(set_attr "type" "load")
9379 (set_attr "length" "8")])
9380
7e69e155
MM
9381;; Move up to 8 bytes at a time.
9382(define_expand "movstrsi_2reg"
b6c9286a
MM
9383 [(parallel [(set (match_operand 0 "" "")
9384 (match_operand 1 "" ""))
9385 (use (match_operand 2 "" ""))
9386 (use (match_operand 3 "" ""))
3c67b673
RK
9387 (clobber (match_scratch:DI 4 ""))
9388 (clobber (match_scratch:SI 5 ""))])]
f9562f27 9389 "TARGET_STRING && ! TARGET_POWERPC64"
7e69e155
MM
9390 "")
9391
9392(define_insn ""
52d3af72
DE
9393 [(set (mem:BLK (match_operand:SI 0 "gpc_reg_operand" "b"))
9394 (mem:BLK (match_operand:SI 1 "gpc_reg_operand" "b")))
3c67b673
RK
9395 (use (match_operand:SI 2 "immediate_operand" "i"))
9396 (use (match_operand:SI 3 "immediate_operand" "i"))
9397 (clobber (match_scratch:DI 4 "=&r"))
9398 (clobber (match_scratch:SI 5 "=q"))]
f9562f27 9399 "TARGET_STRING && TARGET_POWER && ! TARGET_POWERPC64
3c67b673
RK
9400 && INTVAL (operands[2]) > 4 && INTVAL (operands[2]) <= 8"
9401 "{lsi|lswi} %4,%1,%2\;{stsi|stswi} %4,%0,%2"
b7ff3d82
DE
9402 [(set_attr "type" "load")
9403 (set_attr "length" "8")])
7e69e155
MM
9404
9405(define_insn ""
52d3af72
DE
9406 [(set (mem:BLK (match_operand:SI 0 "gpc_reg_operand" "b"))
9407 (mem:BLK (match_operand:SI 1 "gpc_reg_operand" "b")))
3c67b673
RK
9408 (use (match_operand:SI 2 "immediate_operand" "i"))
9409 (use (match_operand:SI 3 "immediate_operand" "i"))
9410 (clobber (match_scratch:DI 4 "=&r"))
9411 (clobber (match_scratch:SI 5 "X"))]
f9562f27 9412 "TARGET_STRING && ! TARGET_POWER && ! TARGET_POWERPC64
7e69e155 9413 && INTVAL (operands[2]) > 4 && INTVAL (operands[2]) <= 8"
3c67b673 9414 "{lsi|lswi} %4,%1,%2\;{stsi|stswi} %4,%0,%2"
b7ff3d82
DE
9415 [(set_attr "type" "load")
9416 (set_attr "length" "8")])
7e69e155
MM
9417
9418;; Move up to 4 bytes at a time.
9419(define_expand "movstrsi_1reg"
b6c9286a
MM
9420 [(parallel [(set (match_operand 0 "" "")
9421 (match_operand 1 "" ""))
9422 (use (match_operand 2 "" ""))
9423 (use (match_operand 3 "" ""))
3c67b673
RK
9424 (clobber (match_scratch:SI 4 ""))
9425 (clobber (match_scratch:SI 5 ""))])]
7e69e155
MM
9426 "TARGET_STRING"
9427 "")
9428
9429(define_insn ""
52d3af72
DE
9430 [(set (mem:BLK (match_operand:SI 0 "gpc_reg_operand" "b"))
9431 (mem:BLK (match_operand:SI 1 "gpc_reg_operand" "b")))
3c67b673
RK
9432 (use (match_operand:SI 2 "immediate_operand" "i"))
9433 (use (match_operand:SI 3 "immediate_operand" "i"))
9434 (clobber (match_scratch:SI 4 "=&r"))
9435 (clobber (match_scratch:SI 5 "=q"))]
7e69e155
MM
9436 "TARGET_STRING && TARGET_POWER
9437 && INTVAL (operands[2]) > 0 && INTVAL (operands[2]) <= 4"
3c67b673 9438 "{lsi|lswi} %4,%1,%2\;{stsi|stswi} %4,%0,%2"
b7ff3d82
DE
9439 [(set_attr "type" "load")
9440 (set_attr "length" "8")])
7e69e155
MM
9441
9442(define_insn ""
52d3af72
DE
9443 [(set (mem:BLK (match_operand:SI 0 "gpc_reg_operand" "b"))
9444 (mem:BLK (match_operand:SI 1 "gpc_reg_operand" "b")))
3c67b673
RK
9445 (use (match_operand:SI 2 "immediate_operand" "i"))
9446 (use (match_operand:SI 3 "immediate_operand" "i"))
9447 (clobber (match_scratch:SI 4 "=&r"))
9448 (clobber (match_scratch:SI 5 "X"))]
0ad91047 9449 "TARGET_STRING && ! TARGET_POWER
7e69e155 9450 && INTVAL (operands[2]) > 0 && INTVAL (operands[2]) <= 4"
09a625f7
TR
9451 "{lsi|lswi} %4,%1,%2\;{stsi|stswi} %4,%0,%2"
9452 [(set_attr "type" "load")
9453 (set_attr "length" "8")])
9454
9455(define_insn ""
9456 [(set (mem:BLK (match_operand:DI 0 "gpc_reg_operand" "b"))
9457 (mem:BLK (match_operand:DI 1 "gpc_reg_operand" "b")))
9458 (use (match_operand:SI 2 "immediate_operand" "i"))
9459 (use (match_operand:SI 3 "immediate_operand" "i"))
9460 (clobber (match_scratch:SI 4 "=&r"))
9461 (clobber (match_scratch:SI 5 "X"))]
9462 "TARGET_STRING && TARGET_POWERPC64
9463 && INTVAL (operands[2]) > 0 && INTVAL (operands[2]) <= 4"
3c67b673 9464 "{lsi|lswi} %4,%1,%2\;{stsi|stswi} %4,%0,%2"
b7ff3d82
DE
9465 [(set_attr "type" "load")
9466 (set_attr "length" "8")])
7e69e155 9467
1fd4e8c1 9468\f
7e69e155 9469;; Define insns that do load or store with update. Some of these we can
1fd4e8c1
RK
9470;; get by using pre-decrement or pre-increment, but the hardware can also
9471;; do cases where the increment is not the size of the object.
9472;;
9473;; In all these cases, we use operands 0 and 1 for the register being
9474;; incremented because those are the operands that local-alloc will
9475;; tie and these are the pair most likely to be tieable (and the ones
9476;; that will benefit the most).
9477
38c1f2d7 9478(define_insn "*movdi_update1"
51b8fc2c 9479 [(set (match_operand:DI 3 "gpc_reg_operand" "=r,r")
ad8bd902 9480 (mem:DI (plus:DI (match_operand:DI 1 "gpc_reg_operand" "0,0")
768070a0 9481 (match_operand:DI 2 "reg_or_aligned_short_operand" "r,I"))))
51b8fc2c
RK
9482 (set (match_operand:DI 0 "gpc_reg_operand" "=b,b")
9483 (plus:DI (match_dup 1) (match_dup 2)))]
38c1f2d7 9484 "TARGET_POWERPC64 && TARGET_UPDATE"
51b8fc2c
RK
9485 "@
9486 ldux %3,%0,%2
9487 ldu %3,%2(%0)"
b54cf83a 9488 [(set_attr "type" "load_ux,load_u")])
287f13ff 9489
4697a36c 9490(define_insn "movdi_update"
51b8fc2c 9491 [(set (mem:DI (plus:DI (match_operand:DI 1 "gpc_reg_operand" "0,0")
768070a0 9492 (match_operand:DI 2 "reg_or_aligned_short_operand" "r,I")))
51b8fc2c
RK
9493 (match_operand:DI 3 "gpc_reg_operand" "r,r"))
9494 (set (match_operand:DI 0 "gpc_reg_operand" "=b,b")
9495 (plus:DI (match_dup 1) (match_dup 2)))]
38c1f2d7 9496 "TARGET_POWERPC64 && TARGET_UPDATE"
51b8fc2c
RK
9497 "@
9498 stdux %3,%0,%2
b7ff3d82 9499 stdu %3,%2(%0)"
b54cf83a 9500 [(set_attr "type" "store_ux,store_u")])
51b8fc2c 9501
38c1f2d7 9502(define_insn "*movsi_update1"
cd2b37d9
RK
9503 [(set (match_operand:SI 3 "gpc_reg_operand" "=r,r")
9504 (mem:SI (plus:SI (match_operand:SI 1 "gpc_reg_operand" "0,0")
1fd4e8c1 9505 (match_operand:SI 2 "reg_or_short_operand" "r,I"))))
cd2b37d9 9506 (set (match_operand:SI 0 "gpc_reg_operand" "=b,b")
1fd4e8c1 9507 (plus:SI (match_dup 1) (match_dup 2)))]
f7b3ab8a 9508 "TARGET_UPDATE"
1fd4e8c1 9509 "@
ca7f5001
RK
9510 {lux|lwzux} %3,%0,%2
9511 {lu|lwzu} %3,%2(%0)"
b54cf83a
DE
9512 [(set_attr "type" "load_ux,load_u")])
9513
9514(define_insn "*movsi_update2"
9515 [(set (match_operand:DI 3 "gpc_reg_operand" "=r")
9516 (sign_extend:DI
9517 (mem:SI (plus:DI (match_operand:DI 1 "gpc_reg_operand" "0")
9518 (match_operand:DI 2 "gpc_reg_operand" "r")))))
9519 (set (match_operand:DI 0 "gpc_reg_operand" "=b")
9520 (plus:DI (match_dup 1) (match_dup 2)))]
9521 "TARGET_POWERPC64"
9522 "lwaux %3,%0,%2"
9523 [(set_attr "type" "load_ext_ux")])
1fd4e8c1 9524
4697a36c 9525(define_insn "movsi_update"
cd2b37d9 9526 [(set (mem:SI (plus:SI (match_operand:SI 1 "gpc_reg_operand" "0,0")
1fd4e8c1 9527 (match_operand:SI 2 "reg_or_short_operand" "r,I")))
cd2b37d9
RK
9528 (match_operand:SI 3 "gpc_reg_operand" "r,r"))
9529 (set (match_operand:SI 0 "gpc_reg_operand" "=b,b")
1fd4e8c1 9530 (plus:SI (match_dup 1) (match_dup 2)))]
38c1f2d7 9531 "TARGET_UPDATE"
1fd4e8c1 9532 "@
ca7f5001 9533 {stux|stwux} %3,%0,%2
b7ff3d82 9534 {stu|stwu} %3,%2(%0)"
b54cf83a 9535 [(set_attr "type" "store_ux,store_u")])
1fd4e8c1 9536
b54cf83a 9537(define_insn "*movhi_update1"
cd2b37d9
RK
9538 [(set (match_operand:HI 3 "gpc_reg_operand" "=r,r")
9539 (mem:HI (plus:SI (match_operand:SI 1 "gpc_reg_operand" "0,0")
1fd4e8c1 9540 (match_operand:SI 2 "reg_or_short_operand" "r,I"))))
cd2b37d9 9541 (set (match_operand:SI 0 "gpc_reg_operand" "=b,b")
1fd4e8c1 9542 (plus:SI (match_dup 1) (match_dup 2)))]
38c1f2d7 9543 "TARGET_UPDATE"
1fd4e8c1 9544 "@
5f243543
RK
9545 lhzux %3,%0,%2
9546 lhzu %3,%2(%0)"
b54cf83a 9547 [(set_attr "type" "load_ux,load_u")])
1fd4e8c1 9548
38c1f2d7 9549(define_insn "*movhi_update2"
cd2b37d9 9550 [(set (match_operand:SI 3 "gpc_reg_operand" "=r,r")
1fd4e8c1 9551 (zero_extend:SI
cd2b37d9 9552 (mem:HI (plus:SI (match_operand:SI 1 "gpc_reg_operand" "0,0")
1fd4e8c1 9553 (match_operand:SI 2 "reg_or_short_operand" "r,I")))))
cd2b37d9 9554 (set (match_operand:SI 0 "gpc_reg_operand" "=b,b")
1fd4e8c1 9555 (plus:SI (match_dup 1) (match_dup 2)))]
38c1f2d7 9556 "TARGET_UPDATE"
1fd4e8c1 9557 "@
5f243543
RK
9558 lhzux %3,%0,%2
9559 lhzu %3,%2(%0)"
b54cf83a 9560 [(set_attr "type" "load_ux,load_u")])
1fd4e8c1 9561
38c1f2d7 9562(define_insn "*movhi_update3"
cd2b37d9 9563 [(set (match_operand:SI 3 "gpc_reg_operand" "=r,r")
1fd4e8c1 9564 (sign_extend:SI
cd2b37d9 9565 (mem:HI (plus:SI (match_operand:SI 1 "gpc_reg_operand" "0,0")
1fd4e8c1 9566 (match_operand:SI 2 "reg_or_short_operand" "r,I")))))
cd2b37d9 9567 (set (match_operand:SI 0 "gpc_reg_operand" "=b,b")
1fd4e8c1 9568 (plus:SI (match_dup 1) (match_dup 2)))]
38c1f2d7 9569 "TARGET_UPDATE"
1fd4e8c1 9570 "@
5f243543
RK
9571 lhaux %3,%0,%2
9572 lhau %3,%2(%0)"
b54cf83a 9573 [(set_attr "type" "load_ext_ux,load_ext_u")])
1fd4e8c1 9574
38c1f2d7 9575(define_insn "*movhi_update4"
cd2b37d9 9576 [(set (mem:HI (plus:SI (match_operand:SI 1 "gpc_reg_operand" "0,0")
1fd4e8c1 9577 (match_operand:SI 2 "reg_or_short_operand" "r,I")))
cd2b37d9
RK
9578 (match_operand:HI 3 "gpc_reg_operand" "r,r"))
9579 (set (match_operand:SI 0 "gpc_reg_operand" "=b,b")
1fd4e8c1 9580 (plus:SI (match_dup 1) (match_dup 2)))]
38c1f2d7 9581 "TARGET_UPDATE"
1fd4e8c1 9582 "@
5f243543 9583 sthux %3,%0,%2
b7ff3d82 9584 sthu %3,%2(%0)"
b54cf83a 9585 [(set_attr "type" "store_ux,store_u")])
1fd4e8c1 9586
38c1f2d7 9587(define_insn "*movqi_update1"
cd2b37d9
RK
9588 [(set (match_operand:QI 3 "gpc_reg_operand" "=r,r")
9589 (mem:QI (plus:SI (match_operand:SI 1 "gpc_reg_operand" "0,0")
1fd4e8c1 9590 (match_operand:SI 2 "reg_or_short_operand" "r,I"))))
cd2b37d9 9591 (set (match_operand:SI 0 "gpc_reg_operand" "=b,b")
1fd4e8c1 9592 (plus:SI (match_dup 1) (match_dup 2)))]
38c1f2d7 9593 "TARGET_UPDATE"
1fd4e8c1 9594 "@
5f243543
RK
9595 lbzux %3,%0,%2
9596 lbzu %3,%2(%0)"
b54cf83a 9597 [(set_attr "type" "load_ux,load_u")])
1fd4e8c1 9598
38c1f2d7 9599(define_insn "*movqi_update2"
cd2b37d9 9600 [(set (match_operand:SI 3 "gpc_reg_operand" "=r,r")
1fd4e8c1 9601 (zero_extend:SI
cd2b37d9 9602 (mem:QI (plus:SI (match_operand:SI 1 "gpc_reg_operand" "0,0")
1fd4e8c1 9603 (match_operand:SI 2 "reg_or_short_operand" "r,I")))))
cd2b37d9 9604 (set (match_operand:SI 0 "gpc_reg_operand" "=b,b")
1fd4e8c1 9605 (plus:SI (match_dup 1) (match_dup 2)))]
38c1f2d7 9606 "TARGET_UPDATE"
1fd4e8c1 9607 "@
5f243543
RK
9608 lbzux %3,%0,%2
9609 lbzu %3,%2(%0)"
b54cf83a 9610 [(set_attr "type" "load_ux,load_u")])
1fd4e8c1 9611
38c1f2d7 9612(define_insn "*movqi_update3"
cd2b37d9 9613 [(set (mem:QI (plus:SI (match_operand:SI 1 "gpc_reg_operand" "0,0")
1fd4e8c1 9614 (match_operand:SI 2 "reg_or_short_operand" "r,I")))
cd2b37d9
RK
9615 (match_operand:QI 3 "gpc_reg_operand" "r,r"))
9616 (set (match_operand:SI 0 "gpc_reg_operand" "=b,b")
1fd4e8c1 9617 (plus:SI (match_dup 1) (match_dup 2)))]
38c1f2d7 9618 "TARGET_UPDATE"
1fd4e8c1 9619 "@
5f243543 9620 stbux %3,%0,%2
b7ff3d82 9621 stbu %3,%2(%0)"
b54cf83a 9622 [(set_attr "type" "store_ux,store_u")])
1fd4e8c1 9623
38c1f2d7 9624(define_insn "*movsf_update1"
cd2b37d9 9625 [(set (match_operand:SF 3 "gpc_reg_operand" "=f,f")
df8b713c 9626 (mem:SF (plus:SI (match_operand:SI 1 "gpc_reg_operand" "0,0")
1fd4e8c1 9627 (match_operand:SI 2 "reg_or_short_operand" "r,I"))))
cd2b37d9 9628 (set (match_operand:SI 0 "gpc_reg_operand" "=b,b")
1fd4e8c1 9629 (plus:SI (match_dup 1) (match_dup 2)))]
a3170dc6 9630 "TARGET_HARD_FLOAT && TARGET_FPRS && TARGET_UPDATE"
1fd4e8c1 9631 "@
5f243543
RK
9632 lfsux %3,%0,%2
9633 lfsu %3,%2(%0)"
b54cf83a 9634 [(set_attr "type" "fpload_ux,fpload_u")])
1fd4e8c1 9635
38c1f2d7 9636(define_insn "*movsf_update2"
cd2b37d9 9637 [(set (mem:SF (plus:SI (match_operand:SI 1 "gpc_reg_operand" "0,0")
1fd4e8c1 9638 (match_operand:SI 2 "reg_or_short_operand" "r,I")))
cd2b37d9
RK
9639 (match_operand:SF 3 "gpc_reg_operand" "f,f"))
9640 (set (match_operand:SI 0 "gpc_reg_operand" "=b,b")
1fd4e8c1 9641 (plus:SI (match_dup 1) (match_dup 2)))]
a3170dc6 9642 "TARGET_HARD_FLOAT && TARGET_FPRS && TARGET_UPDATE"
1fd4e8c1 9643 "@
85fff2f3 9644 stfsux %3,%0,%2
b7ff3d82 9645 stfsu %3,%2(%0)"
b54cf83a 9646 [(set_attr "type" "fpstore_ux,fpstore_u")])
1fd4e8c1 9647
38c1f2d7
MM
9648(define_insn "*movsf_update3"
9649 [(set (match_operand:SF 3 "gpc_reg_operand" "=r,r")
9650 (mem:SF (plus:SI (match_operand:SI 1 "gpc_reg_operand" "0,0")
9651 (match_operand:SI 2 "reg_or_short_operand" "r,I"))))
9652 (set (match_operand:SI 0 "gpc_reg_operand" "=b,b")
9653 (plus:SI (match_dup 1) (match_dup 2)))]
a3170dc6 9654 "(TARGET_SOFT_FLOAT || !TARGET_FPRS) && TARGET_UPDATE"
38c1f2d7
MM
9655 "@
9656 {lux|lwzux} %3,%0,%2
9657 {lu|lwzu} %3,%2(%0)"
b54cf83a 9658 [(set_attr "type" "load_ux,load_u")])
38c1f2d7
MM
9659
9660(define_insn "*movsf_update4"
9661 [(set (mem:SF (plus:SI (match_operand:SI 1 "gpc_reg_operand" "0,0")
9662 (match_operand:SI 2 "reg_or_short_operand" "r,I")))
9663 (match_operand:SF 3 "gpc_reg_operand" "r,r"))
9664 (set (match_operand:SI 0 "gpc_reg_operand" "=b,b")
9665 (plus:SI (match_dup 1) (match_dup 2)))]
a3170dc6 9666 "(TARGET_SOFT_FLOAT || !TARGET_FPRS) && TARGET_UPDATE"
38c1f2d7
MM
9667 "@
9668 {stux|stwux} %3,%0,%2
9669 {stu|stwu} %3,%2(%0)"
b54cf83a 9670 [(set_attr "type" "store_ux,store_u")])
38c1f2d7
MM
9671
9672(define_insn "*movdf_update1"
cd2b37d9
RK
9673 [(set (match_operand:DF 3 "gpc_reg_operand" "=f,f")
9674 (mem:DF (plus:SI (match_operand:SI 1 "gpc_reg_operand" "0,0")
1fd4e8c1 9675 (match_operand:SI 2 "reg_or_short_operand" "r,I"))))
cd2b37d9 9676 (set (match_operand:SI 0 "gpc_reg_operand" "=b,b")
1fd4e8c1 9677 (plus:SI (match_dup 1) (match_dup 2)))]
a3170dc6 9678 "TARGET_HARD_FLOAT && TARGET_FPRS && TARGET_UPDATE"
1fd4e8c1 9679 "@
5f243543
RK
9680 lfdux %3,%0,%2
9681 lfdu %3,%2(%0)"
b54cf83a 9682 [(set_attr "type" "fpload_ux,fpload_u")])
1fd4e8c1 9683
38c1f2d7 9684(define_insn "*movdf_update2"
cd2b37d9 9685 [(set (mem:DF (plus:SI (match_operand:SI 1 "gpc_reg_operand" "0,0")
1fd4e8c1 9686 (match_operand:SI 2 "reg_or_short_operand" "r,I")))
cd2b37d9
RK
9687 (match_operand:DF 3 "gpc_reg_operand" "f,f"))
9688 (set (match_operand:SI 0 "gpc_reg_operand" "=b,b")
1fd4e8c1 9689 (plus:SI (match_dup 1) (match_dup 2)))]
a3170dc6 9690 "TARGET_HARD_FLOAT && TARGET_FPRS && TARGET_UPDATE"
1fd4e8c1 9691 "@
5f243543 9692 stfdux %3,%0,%2
b7ff3d82 9693 stfdu %3,%2(%0)"
b54cf83a 9694 [(set_attr "type" "fpstore_ux,fpstore_u")])
4c70a4f3
RK
9695
9696;; Peephole to convert two consecutive FP loads or stores into lfq/stfq.
9697
9698(define_peephole
9699 [(set (match_operand:DF 0 "gpc_reg_operand" "=f")
9700 (match_operand:DF 1 "memory_operand" ""))
9701 (set (match_operand:DF 2 "gpc_reg_operand" "=f")
9702 (match_operand:DF 3 "memory_operand" ""))]
9703 "TARGET_POWER2
a3170dc6 9704 && TARGET_HARD_FLOAT && TARGET_FPRS
4c70a4f3
RK
9705 && registers_ok_for_quad_peep (operands[0], operands[2])
9706 && ! MEM_VOLATILE_P (operands[1]) && ! MEM_VOLATILE_P (operands[3])
9707 && addrs_ok_for_quad_peep (XEXP (operands[1], 0), XEXP (operands[3], 0))"
9708 "lfq%U1%X1 %0,%1")
9709
9710(define_peephole
9711 [(set (match_operand:DF 0 "memory_operand" "")
9712 (match_operand:DF 1 "gpc_reg_operand" "f"))
9713 (set (match_operand:DF 2 "memory_operand" "")
9714 (match_operand:DF 3 "gpc_reg_operand" "f"))]
9715 "TARGET_POWER2
a3170dc6 9716 && TARGET_HARD_FLOAT && TARGET_FPRS
4c70a4f3
RK
9717 && registers_ok_for_quad_peep (operands[1], operands[3])
9718 && ! MEM_VOLATILE_P (operands[0]) && ! MEM_VOLATILE_P (operands[2])
9719 && addrs_ok_for_quad_peep (XEXP (operands[0], 0), XEXP (operands[2], 0))"
9720 "stfq%U0%X0 %1,%0")
1fd4e8c1 9721\f
c4501e62
JJ
9722;; TLS support.
9723
9724;; "b" output constraint here and on tls_ld to support tls linker optimization.
9725(define_insn "tls_gd_32"
9726 [(set (match_operand:SI 0 "register_operand" "=b")
9727 (unspec:SI [(match_operand:SI 1 "register_operand" "b")
9728 (match_operand:SI 2 "rs6000_tls_symbol_ref" "")]
9729 UNSPEC_TLSGD))]
9730 "HAVE_AS_TLS && !TARGET_64BIT"
9731 "addi %0,%1,%2@got@tlsgd")
9732
9733(define_insn "tls_gd_64"
9734 [(set (match_operand:DI 0 "register_operand" "=b")
9735 (unspec:DI [(match_operand:DI 1 "register_operand" "b")
9736 (match_operand:DI 2 "rs6000_tls_symbol_ref" "")]
9737 UNSPEC_TLSGD))]
9738 "HAVE_AS_TLS && TARGET_64BIT"
9739 "addi %0,%1,%2@got@tlsgd")
9740
9741(define_insn "tls_ld_32"
9742 [(set (match_operand:SI 0 "register_operand" "=b")
9743 (unspec:SI [(match_operand:SI 1 "register_operand" "b")]
9744 UNSPEC_TLSLD))]
9745 "HAVE_AS_TLS && !TARGET_64BIT"
9746 "addi %0,%1,%&@got@tlsld")
9747
9748(define_insn "tls_ld_64"
9749 [(set (match_operand:DI 0 "register_operand" "=b")
9750 (unspec:DI [(match_operand:DI 1 "register_operand" "b")]
9751 UNSPEC_TLSLD))]
9752 "HAVE_AS_TLS && TARGET_64BIT"
9753 "addi %0,%1,%&@got@tlsld")
9754
9755(define_insn "tls_dtprel_32"
9756 [(set (match_operand:SI 0 "register_operand" "=r")
9757 (unspec:SI [(match_operand:SI 1 "register_operand" "b")
9758 (match_operand:SI 2 "rs6000_tls_symbol_ref" "")]
9759 UNSPEC_TLSDTPREL))]
9760 "HAVE_AS_TLS && !TARGET_64BIT"
9761 "addi %0,%1,%2@dtprel")
9762
9763(define_insn "tls_dtprel_64"
9764 [(set (match_operand:DI 0 "register_operand" "=r")
9765 (unspec:DI [(match_operand:DI 1 "register_operand" "b")
9766 (match_operand:DI 2 "rs6000_tls_symbol_ref" "")]
9767 UNSPEC_TLSDTPREL))]
9768 "HAVE_AS_TLS && TARGET_64BIT"
9769 "addi %0,%1,%2@dtprel")
9770
9771(define_insn "tls_dtprel_ha_32"
9772 [(set (match_operand:SI 0 "register_operand" "=r")
9773 (unspec:SI [(match_operand:SI 1 "register_operand" "b")
9774 (match_operand:SI 2 "rs6000_tls_symbol_ref" "")]
9775 UNSPEC_TLSDTPRELHA))]
9776 "HAVE_AS_TLS && !TARGET_64BIT"
9777 "addis %0,%1,%2@dtprel@ha")
9778
9779(define_insn "tls_dtprel_ha_64"
9780 [(set (match_operand:DI 0 "register_operand" "=r")
9781 (unspec:DI [(match_operand:DI 1 "register_operand" "b")
9782 (match_operand:DI 2 "rs6000_tls_symbol_ref" "")]
9783 UNSPEC_TLSDTPRELHA))]
9784 "HAVE_AS_TLS && TARGET_64BIT"
9785 "addis %0,%1,%2@dtprel@ha")
9786
9787(define_insn "tls_dtprel_lo_32"
9788 [(set (match_operand:SI 0 "register_operand" "=r")
9789 (unspec:SI [(match_operand:SI 1 "register_operand" "b")
9790 (match_operand:SI 2 "rs6000_tls_symbol_ref" "")]
9791 UNSPEC_TLSDTPRELLO))]
9792 "HAVE_AS_TLS && !TARGET_64BIT"
9793 "addi %0,%1,%2@dtprel@l")
9794
9795(define_insn "tls_dtprel_lo_64"
9796 [(set (match_operand:DI 0 "register_operand" "=r")
9797 (unspec:DI [(match_operand:DI 1 "register_operand" "b")
9798 (match_operand:DI 2 "rs6000_tls_symbol_ref" "")]
9799 UNSPEC_TLSDTPRELLO))]
9800 "HAVE_AS_TLS && TARGET_64BIT"
9801 "addi %0,%1,%2@dtprel@l")
9802
9803(define_insn "tls_got_dtprel_32"
9804 [(set (match_operand:SI 0 "register_operand" "=r")
9805 (unspec:SI [(match_operand:SI 1 "register_operand" "b")
9806 (match_operand:SI 2 "rs6000_tls_symbol_ref" "")]
9807 UNSPEC_TLSGOTDTPREL))]
9808 "HAVE_AS_TLS && !TARGET_64BIT"
9809 "lwz %0,%2@got@dtprel(%1)")
9810
9811(define_insn "tls_got_dtprel_64"
9812 [(set (match_operand:DI 0 "register_operand" "=r")
9813 (unspec:DI [(match_operand:DI 1 "register_operand" "b")
9814 (match_operand:DI 2 "rs6000_tls_symbol_ref" "")]
9815 UNSPEC_TLSGOTDTPREL))]
9816 "HAVE_AS_TLS && TARGET_64BIT"
9817 "ld %0,%2@got@dtprel(%1)")
9818
9819(define_insn "tls_tprel_32"
9820 [(set (match_operand:SI 0 "register_operand" "=r")
9821 (unspec:SI [(match_operand:SI 1 "register_operand" "b")
9822 (match_operand:SI 2 "rs6000_tls_symbol_ref" "")]
9823 UNSPEC_TLSTPREL))]
9824 "HAVE_AS_TLS && !TARGET_64BIT"
9825 "addi %0,%1,%2@tprel")
9826
9827(define_insn "tls_tprel_64"
9828 [(set (match_operand:DI 0 "register_operand" "=r")
9829 (unspec:DI [(match_operand:DI 1 "register_operand" "b")
9830 (match_operand:DI 2 "rs6000_tls_symbol_ref" "")]
9831 UNSPEC_TLSTPREL))]
9832 "HAVE_AS_TLS && TARGET_64BIT"
9833 "addi %0,%1,%2@tprel")
9834
9835(define_insn "tls_tprel_ha_32"
9836 [(set (match_operand:SI 0 "register_operand" "=r")
9837 (unspec:SI [(match_operand:SI 1 "register_operand" "b")
9838 (match_operand:SI 2 "rs6000_tls_symbol_ref" "")]
9839 UNSPEC_TLSTPRELHA))]
9840 "HAVE_AS_TLS && !TARGET_64BIT"
9841 "addis %0,%1,%2@tprel@ha")
9842
9843(define_insn "tls_tprel_ha_64"
9844 [(set (match_operand:DI 0 "register_operand" "=r")
9845 (unspec:DI [(match_operand:DI 1 "register_operand" "b")
9846 (match_operand:DI 2 "rs6000_tls_symbol_ref" "")]
9847 UNSPEC_TLSTPRELHA))]
9848 "HAVE_AS_TLS && TARGET_64BIT"
9849 "addis %0,%1,%2@tprel@ha")
9850
9851(define_insn "tls_tprel_lo_32"
9852 [(set (match_operand:SI 0 "register_operand" "=r")
9853 (unspec:SI [(match_operand:SI 1 "register_operand" "b")
9854 (match_operand:SI 2 "rs6000_tls_symbol_ref" "")]
9855 UNSPEC_TLSTPRELLO))]
9856 "HAVE_AS_TLS && !TARGET_64BIT"
9857 "addi %0,%1,%2@tprel@l")
9858
9859(define_insn "tls_tprel_lo_64"
9860 [(set (match_operand:DI 0 "register_operand" "=r")
9861 (unspec:DI [(match_operand:DI 1 "register_operand" "b")
9862 (match_operand:DI 2 "rs6000_tls_symbol_ref" "")]
9863 UNSPEC_TLSTPRELLO))]
9864 "HAVE_AS_TLS && TARGET_64BIT"
9865 "addi %0,%1,%2@tprel@l")
9866
c1207243 9867;; "b" output constraint here and on tls_tls input to support linker tls
c4501e62
JJ
9868;; optimization. The linker may edit the instructions emitted by a
9869;; tls_got_tprel/tls_tls pair to addis,addi.
9870(define_insn "tls_got_tprel_32"
9871 [(set (match_operand:SI 0 "register_operand" "=b")
9872 (unspec:SI [(match_operand:SI 1 "register_operand" "b")
9873 (match_operand:SI 2 "rs6000_tls_symbol_ref" "")]
9874 UNSPEC_TLSGOTTPREL))]
9875 "HAVE_AS_TLS && !TARGET_64BIT"
9876 "lwz %0,%2@got@tprel(%1)")
9877
9878(define_insn "tls_got_tprel_64"
9879 [(set (match_operand:DI 0 "register_operand" "=b")
9880 (unspec:DI [(match_operand:DI 1 "register_operand" "b")
9881 (match_operand:DI 2 "rs6000_tls_symbol_ref" "")]
9882 UNSPEC_TLSGOTTPREL))]
9883 "HAVE_AS_TLS && TARGET_64BIT"
9884 "ld %0,%2@got@tprel(%1)")
9885
9886(define_insn "tls_tls_32"
9887 [(set (match_operand:SI 0 "register_operand" "=r")
9888 (unspec:SI [(match_operand:SI 1 "register_operand" "b")
9889 (match_operand:SI 2 "rs6000_tls_symbol_ref" "")]
9890 UNSPEC_TLSTLS))]
9891 "HAVE_AS_TLS && !TARGET_64BIT"
9892 "add %0,%1,%2@tls")
9893
9894(define_insn "tls_tls_64"
9895 [(set (match_operand:DI 0 "register_operand" "=r")
9896 (unspec:DI [(match_operand:DI 1 "register_operand" "b")
9897 (match_operand:DI 2 "rs6000_tls_symbol_ref" "")]
9898 UNSPEC_TLSTLS))]
9899 "HAVE_AS_TLS && TARGET_64BIT"
9900 "add %0,%1,%2@tls")
9901\f
1fd4e8c1
RK
9902;; Next come insns related to the calling sequence.
9903;;
9904;; First, an insn to allocate new stack space for dynamic use (e.g., alloca).
7e69e155 9905;; We move the back-chain and decrement the stack pointer.
1fd4e8c1
RK
9906
9907(define_expand "allocate_stack"
52d3af72 9908 [(set (match_operand 0 "gpc_reg_operand" "=r")
a260abc9
DE
9909 (minus (reg 1) (match_operand 1 "reg_or_short_operand" "")))
9910 (set (reg 1)
9911 (minus (reg 1) (match_dup 1)))]
1fd4e8c1
RK
9912 ""
9913 "
4697a36c 9914{ rtx chain = gen_reg_rtx (Pmode);
39403d82 9915 rtx stack_bot = gen_rtx_MEM (Pmode, stack_pointer_rtx);
4697a36c 9916 rtx neg_op0;
1fd4e8c1
RK
9917
9918 emit_move_insn (chain, stack_bot);
4697a36c 9919
a157febd
GK
9920 /* Check stack bounds if necessary. */
9921 if (current_function_limit_stack)
9922 {
9923 rtx available;
9924 available = expand_binop (Pmode, sub_optab,
9925 stack_pointer_rtx, stack_limit_rtx,
9926 NULL_RTX, 1, OPTAB_WIDEN);
9927 emit_insn (gen_cond_trap (LTU, available, operands[1], const0_rtx));
9928 }
9929
e9a25f70
JL
9930 if (GET_CODE (operands[1]) != CONST_INT
9931 || INTVAL (operands[1]) < -32767
9932 || INTVAL (operands[1]) > 32768)
4697a36c
MM
9933 {
9934 neg_op0 = gen_reg_rtx (Pmode);
e6ca2c17 9935 if (TARGET_32BIT)
e9a25f70 9936 emit_insn (gen_negsi2 (neg_op0, operands[1]));
e6ca2c17 9937 else
e9a25f70 9938 emit_insn (gen_negdi2 (neg_op0, operands[1]));
4697a36c
MM
9939 }
9940 else
e9a25f70 9941 neg_op0 = GEN_INT (- INTVAL (operands[1]));
4697a36c 9942
38c1f2d7
MM
9943 if (TARGET_UPDATE)
9944 emit_insn ((* ((TARGET_32BIT) ? gen_movsi_update : gen_movdi_update))
9945 (stack_pointer_rtx, stack_pointer_rtx, neg_op0, chain));
4697a36c 9946
38c1f2d7
MM
9947 else
9948 {
9949 emit_insn ((* ((TARGET_32BIT) ? gen_addsi3 : gen_adddi3))
9950 (stack_pointer_rtx, stack_pointer_rtx, neg_op0));
39403d82 9951 emit_move_insn (gen_rtx_MEM (Pmode, stack_pointer_rtx), chain);
38c1f2d7 9952 }
e9a25f70
JL
9953
9954 emit_move_insn (operands[0], virtual_stack_dynamic_rtx);
1fd4e8c1
RK
9955 DONE;
9956}")
59257ff7
RK
9957
9958;; These patterns say how to save and restore the stack pointer. We need not
9959;; save the stack pointer at function level since we are careful to
9960;; preserve the backchain. At block level, we have to restore the backchain
9961;; when we restore the stack pointer.
9962;;
9963;; For nonlocal gotos, we must save both the stack pointer and its
9964;; backchain and restore both. Note that in the nonlocal case, the
9965;; save area is a memory location.
9966
9967(define_expand "save_stack_function"
ff381587
MM
9968 [(match_operand 0 "any_operand" "")
9969 (match_operand 1 "any_operand" "")]
59257ff7 9970 ""
ff381587 9971 "DONE;")
59257ff7
RK
9972
9973(define_expand "restore_stack_function"
ff381587
MM
9974 [(match_operand 0 "any_operand" "")
9975 (match_operand 1 "any_operand" "")]
59257ff7 9976 ""
ff381587 9977 "DONE;")
59257ff7
RK
9978
9979(define_expand "restore_stack_block"
dfdfa60f
DE
9980 [(use (match_operand 0 "register_operand" ""))
9981 (set (match_dup 2) (match_dup 3))
a260abc9 9982 (set (match_dup 0) (match_operand 1 "register_operand" ""))
dfdfa60f 9983 (set (match_dup 3) (match_dup 2))]
59257ff7
RK
9984 ""
9985 "
dfdfa60f
DE
9986{
9987 operands[2] = gen_reg_rtx (Pmode);
39403d82 9988 operands[3] = gen_rtx_MEM (Pmode, operands[0]);
dfdfa60f 9989}")
59257ff7
RK
9990
9991(define_expand "save_stack_nonlocal"
a260abc9
DE
9992 [(match_operand 0 "memory_operand" "")
9993 (match_operand 1 "register_operand" "")]
59257ff7
RK
9994 ""
9995 "
9996{
a260abc9 9997 rtx temp = gen_reg_rtx (Pmode);
59257ff7
RK
9998
9999 /* Copy the backchain to the first word, sp to the second. */
39403d82 10000 emit_move_insn (temp, gen_rtx_MEM (Pmode, operands[1]));
c5c76735
JL
10001 emit_move_insn (operand_subword (operands[0], 0, 0,
10002 (TARGET_32BIT ? DImode : TImode)),
a260abc9
DE
10003 temp);
10004 emit_move_insn (operand_subword (operands[0], 1, 0, (TARGET_32BIT ? DImode : TImode)),
10005 operands[1]);
59257ff7
RK
10006 DONE;
10007}")
7e69e155 10008
59257ff7 10009(define_expand "restore_stack_nonlocal"
a260abc9
DE
10010 [(match_operand 0 "register_operand" "")
10011 (match_operand 1 "memory_operand" "")]
59257ff7
RK
10012 ""
10013 "
10014{
a260abc9 10015 rtx temp = gen_reg_rtx (Pmode);
59257ff7
RK
10016
10017 /* Restore the backchain from the first word, sp from the second. */
a260abc9
DE
10018 emit_move_insn (temp,
10019 operand_subword (operands[1], 0, 0, (TARGET_32BIT ? DImode : TImode)));
10020 emit_move_insn (operands[0],
c5c76735
JL
10021 operand_subword (operands[1], 1, 0,
10022 (TARGET_32BIT ? DImode : TImode)));
39403d82 10023 emit_move_insn (gen_rtx_MEM (Pmode, operands[0]), temp);
59257ff7
RK
10024 DONE;
10025}")
9ebbca7d
GK
10026\f
10027;; TOC register handling.
b6c9286a 10028
9ebbca7d 10029;; Code to initialize the TOC register...
f0f6a223 10030
9ebbca7d 10031(define_insn "load_toc_aix_si"
e72247f4 10032 [(parallel [(set (match_operand:SI 0 "gpc_reg_operand" "=r")
615158e2 10033 (unspec:SI [(const_int 0)] UNSPEC_TOC))
46aaf10d 10034 (use (reg:SI 2))])]
2bfcf297 10035 "DEFAULT_ABI == ABI_AIX && TARGET_32BIT"
f0f6a223
RK
10036 "*
10037{
9ebbca7d
GK
10038 char buf[30];
10039 ASM_GENERATE_INTERNAL_LABEL (buf, \"LCTOC\", 1);
a8a05998 10040 operands[1] = gen_rtx_SYMBOL_REF (Pmode, ggc_strdup (buf));
9ebbca7d
GK
10041 operands[2] = gen_rtx_REG (Pmode, 2);
10042 return \"{l|lwz} %0,%1(%2)\";
f0f6a223
RK
10043}"
10044 [(set_attr "type" "load")])
9ebbca7d
GK
10045
10046(define_insn "load_toc_aix_di"
e72247f4 10047 [(parallel [(set (match_operand:DI 0 "gpc_reg_operand" "=r")
615158e2 10048 (unspec:DI [(const_int 0)] UNSPEC_TOC))
46aaf10d 10049 (use (reg:DI 2))])]
2bfcf297 10050 "DEFAULT_ABI == ABI_AIX && TARGET_64BIT"
9ebbca7d
GK
10051 "*
10052{
10053 char buf[30];
f585a356
DE
10054#ifdef TARGET_RELOCATABLE
10055 ASM_GENERATE_INTERNAL_LABEL (buf, \"LCTOC\",
10056 !TARGET_MINIMAL_TOC || TARGET_RELOCATABLE);
10057#else
9ebbca7d 10058 ASM_GENERATE_INTERNAL_LABEL (buf, \"LCTOC\", 1);
f585a356 10059#endif
2bfcf297
DB
10060 if (TARGET_ELF)
10061 strcat (buf, \"@toc\");
a8a05998 10062 operands[1] = gen_rtx_SYMBOL_REF (Pmode, ggc_strdup (buf));
9ebbca7d
GK
10063 operands[2] = gen_rtx_REG (Pmode, 2);
10064 return \"ld %0,%1(%2)\";
10065}"
10066 [(set_attr "type" "load")])
10067
10068(define_insn "load_toc_v4_pic_si"
10069 [(set (match_operand:SI 0 "register_operand" "=l")
615158e2 10070 (unspec:SI [(const_int 0)] UNSPEC_TOC))]
f607bc57 10071 "DEFAULT_ABI == ABI_V4 && flag_pic == 1 && TARGET_32BIT"
9ebbca7d
GK
10072 "bl _GLOBAL_OFFSET_TABLE_@local-4"
10073 [(set_attr "type" "branch")
10074 (set_attr "length" "4")])
10075
9ebbca7d
GK
10076(define_insn "load_toc_v4_PIC_1"
10077 [(set (match_operand:SI 0 "register_operand" "=l")
10078 (match_operand:SI 1 "immediate_operand" "s"))
c4501e62 10079 (use (unspec [(match_dup 1)] UNSPEC_TOC))]
20b71b17 10080 "TARGET_ELF && DEFAULT_ABI != ABI_AIX && flag_pic == 2"
df7a8989 10081 "bcl 20,31,%1\\n%1:"
9ebbca7d
GK
10082 [(set_attr "type" "branch")
10083 (set_attr "length" "4")])
10084
10085(define_insn "load_toc_v4_PIC_1b"
10086 [(set (match_operand:SI 0 "register_operand" "=l")
10087 (match_operand:SI 1 "immediate_operand" "s"))
c4501e62
JJ
10088 (use (unspec [(match_dup 1) (match_operand 2 "immediate_operand" "s")]
10089 UNSPEC_TOCPTR))]
20b71b17 10090 "TARGET_ELF && DEFAULT_ABI != ABI_AIX && flag_pic == 2"
c4501e62 10091 "bcl 20,31,%1+4\\n%1:\\n\\t.long %2-%1"
9ebbca7d
GK
10092 [(set_attr "type" "branch")
10093 (set_attr "length" "8")])
10094
10095(define_insn "load_toc_v4_PIC_2"
f585a356 10096 [(set (match_operand:SI 0 "gpc_reg_operand" "=r")
a2900460 10097 (mem:SI (plus:SI (match_operand:SI 1 "gpc_reg_operand" "b")
9ebbca7d
GK
10098 (minus:SI (match_operand:SI 2 "immediate_operand" "s")
10099 (match_operand:SI 3 "immediate_operand" "s")))))]
20b71b17 10100 "TARGET_ELF && DEFAULT_ABI != ABI_AIX && flag_pic == 2"
9ebbca7d
GK
10101 "{l|lwz} %0,%2-%3(%1)"
10102 [(set_attr "type" "load")])
10103
ee890fe2
SS
10104(define_insn "load_macho_picbase"
10105 [(set (match_operand:SI 0 "register_operand" "=l")
615158e2
JJ
10106 (unspec:SI [(match_operand:SI 1 "immediate_operand" "s")]
10107 UNSPEC_LD_MPIC))]
ee890fe2 10108 "(DEFAULT_ABI == ABI_DARWIN) && flag_pic"
f51eee6a 10109 "bcl 20,31,%1\\n%1:"
ee890fe2
SS
10110 [(set_attr "type" "branch")
10111 (set_attr "length" "4")])
10112
f51eee6a
GK
10113(define_insn "macho_correct_pic"
10114 [(set (match_operand:SI 0 "gpc_reg_operand" "=r")
8291cc0e 10115 (plus:SI (match_operand:SI 1 "gpc_reg_operand" "r")
f51eee6a
GK
10116 (unspec:SI [(match_operand:SI 2 "immediate_operand" "s")
10117 (match_operand:SI 3 "immediate_operand" "s")]
615158e2 10118 UNSPEC_MPIC_CORRECT)))]
f51eee6a 10119 "DEFAULT_ABI == ABI_DARWIN"
8291cc0e 10120 "addis %0,%1,ha16(%2-%3)\n\taddi %0,%0,lo16(%2-%3)"
f51eee6a
GK
10121 [(set_attr "length" "8")])
10122
9ebbca7d
GK
10123;; If the TOC is shared over a translation unit, as happens with all
10124;; the kinds of PIC that we support, we need to restore the TOC
10125;; pointer only when jumping over units of translation.
f51eee6a 10126;; On Darwin, we need to reload the picbase.
9ebbca7d
GK
10127
10128(define_expand "builtin_setjmp_receiver"
10129 [(use (label_ref (match_operand 0 "" "")))]
f607bc57 10130 "(DEFAULT_ABI == ABI_V4 && flag_pic == 1)
f51eee6a
GK
10131 || (TARGET_TOC && TARGET_MINIMAL_TOC)
10132 || (DEFAULT_ABI == ABI_DARWIN && flag_pic)"
9ebbca7d
GK
10133 "
10134{
84d7dd4a 10135#if TARGET_MACHO
f51eee6a
GK
10136 if (DEFAULT_ABI == ABI_DARWIN)
10137 {
d24652ee 10138 const char *picbase = machopic_function_base_name ();
485bad26 10139 rtx picrtx = gen_rtx_SYMBOL_REF (Pmode, ggc_strdup (picbase));
f51eee6a
GK
10140 rtx picreg = gen_rtx_REG (Pmode, RS6000_PIC_OFFSET_TABLE_REGNUM);
10141 rtx tmplabrtx;
10142 char tmplab[20];
10143
10144 ASM_GENERATE_INTERNAL_LABEL(tmplab, \"LSJR\",
10145 CODE_LABEL_NUMBER (operands[0]));
485bad26 10146 tmplabrtx = gen_rtx_SYMBOL_REF (Pmode, ggc_strdup (tmplab));
f51eee6a
GK
10147
10148 emit_insn (gen_load_macho_picbase (picreg, tmplabrtx));
10149 emit_insn (gen_macho_correct_pic (picreg, picreg, picrtx, tmplabrtx));
10150 }
10151 else
84d7dd4a 10152#endif
f51eee6a 10153 rs6000_emit_load_toc_table (FALSE);
9ebbca7d
GK
10154 DONE;
10155}")
10156\f
10157;; A function pointer under AIX is a pointer to a data area whose first word
10158;; contains the actual address of the function, whose second word contains a
b6c9286a
MM
10159;; pointer to its TOC, and whose third word contains a value to place in the
10160;; static chain register (r11). Note that if we load the static chain, our
1fd4e8c1 10161;; "trampoline" need not have any executable code.
b6c9286a 10162
cccf3bdc
DE
10163(define_expand "call_indirect_aix32"
10164 [(set (match_dup 2)
10165 (mem:SI (match_operand:SI 0 "gpc_reg_operand" "")))
10166 (set (mem:SI (plus:SI (reg:SI 1) (const_int 20)))
10167 (reg:SI 2))
10168 (set (reg:SI 2)
10169 (mem:SI (plus:SI (match_dup 0)
10170 (const_int 4))))
10171 (set (reg:SI 11)
10172 (mem:SI (plus:SI (match_dup 0)
10173 (const_int 8))))
10174 (parallel [(call (mem:SI (match_dup 2))
10175 (match_operand 1 "" ""))
10176 (use (reg:SI 2))
10177 (use (reg:SI 11))
10178 (set (reg:SI 2)
10179 (mem:SI (plus:SI (reg:SI 1) (const_int 20))))
10180 (clobber (scratch:SI))])]
10181 "TARGET_32BIT"
10182 "
10183{ operands[2] = gen_reg_rtx (SImode); }")
b6c9286a 10184
cccf3bdc
DE
10185(define_expand "call_indirect_aix64"
10186 [(set (match_dup 2)
10187 (mem:DI (match_operand:DI 0 "gpc_reg_operand" "")))
10188 (set (mem:DI (plus:DI (reg:DI 1) (const_int 40)))
10189 (reg:DI 2))
10190 (set (reg:DI 2)
10191 (mem:DI (plus:DI (match_dup 0)
10192 (const_int 8))))
10193 (set (reg:DI 11)
10194 (mem:DI (plus:DI (match_dup 0)
10195 (const_int 16))))
10196 (parallel [(call (mem:SI (match_dup 2))
10197 (match_operand 1 "" ""))
10198 (use (reg:DI 2))
10199 (use (reg:DI 11))
10200 (set (reg:DI 2)
10201 (mem:DI (plus:DI (reg:DI 1) (const_int 40))))
10202 (clobber (scratch:SI))])]
10203 "TARGET_64BIT"
10204 "
10205{ operands[2] = gen_reg_rtx (DImode); }")
b6c9286a 10206
cccf3bdc
DE
10207(define_expand "call_value_indirect_aix32"
10208 [(set (match_dup 3)
10209 (mem:SI (match_operand:SI 1 "gpc_reg_operand" "")))
10210 (set (mem:SI (plus:SI (reg:SI 1) (const_int 20)))
10211 (reg:SI 2))
10212 (set (reg:SI 2)
10213 (mem:SI (plus:SI (match_dup 1)
10214 (const_int 4))))
10215 (set (reg:SI 11)
10216 (mem:SI (plus:SI (match_dup 1)
10217 (const_int 8))))
10218 (parallel [(set (match_operand 0 "" "")
10219 (call (mem:SI (match_dup 3))
10220 (match_operand 2 "" "")))
10221 (use (reg:SI 2))
10222 (use (reg:SI 11))
10223 (set (reg:SI 2)
10224 (mem:SI (plus:SI (reg:SI 1) (const_int 20))))
10225 (clobber (scratch:SI))])]
10226 "TARGET_32BIT"
10227 "
10228{ operands[3] = gen_reg_rtx (SImode); }")
b6c9286a 10229
cccf3bdc
DE
10230(define_expand "call_value_indirect_aix64"
10231 [(set (match_dup 3)
10232 (mem:DI (match_operand:DI 1 "gpc_reg_operand" "")))
10233 (set (mem:DI (plus:DI (reg:DI 1) (const_int 40)))
10234 (reg:DI 2))
10235 (set (reg:DI 2)
10236 (mem:DI (plus:DI (match_dup 1)
10237 (const_int 8))))
10238 (set (reg:DI 11)
10239 (mem:DI (plus:DI (match_dup 1)
10240 (const_int 16))))
10241 (parallel [(set (match_operand 0 "" "")
10242 (call (mem:SI (match_dup 3))
10243 (match_operand 2 "" "")))
10244 (use (reg:DI 2))
10245 (use (reg:DI 11))
10246 (set (reg:DI 2)
10247 (mem:DI (plus:DI (reg:DI 1) (const_int 40))))
10248 (clobber (scratch:SI))])]
10249 "TARGET_64BIT"
10250 "
10251{ operands[3] = gen_reg_rtx (DImode); }")
1fd4e8c1 10252
b6c9286a 10253;; Now the definitions for the call and call_value insns
1fd4e8c1 10254(define_expand "call"
a260abc9 10255 [(parallel [(call (mem:SI (match_operand 0 "address_operand" ""))
1fd4e8c1 10256 (match_operand 1 "" ""))
4697a36c 10257 (use (match_operand 2 "" ""))
1fd4e8c1
RK
10258 (clobber (scratch:SI))])]
10259 ""
10260 "
10261{
ee890fe2 10262#if TARGET_MACHO
ab82a49f 10263 if (MACHOPIC_INDIRECT)
ee890fe2
SS
10264 operands[0] = machopic_indirect_call_target (operands[0]);
10265#endif
10266
1fd4e8c1
RK
10267 if (GET_CODE (operands[0]) != MEM || GET_CODE (operands[1]) != CONST_INT)
10268 abort ();
10269
10270 operands[0] = XEXP (operands[0], 0);
7509c759 10271
6a4cee5f 10272 if (GET_CODE (operands[0]) != SYMBOL_REF
473f51b6 10273 || (DEFAULT_ABI == ABI_AIX && !SYMBOL_REF_FUNCTION_P (operands[0]))
6a4cee5f 10274 || (INTVAL (operands[2]) & CALL_LONG) != 0)
1fd4e8c1 10275 {
6a4cee5f
MM
10276 if (INTVAL (operands[2]) & CALL_LONG)
10277 operands[0] = rs6000_longcall_ref (operands[0]);
10278
cccf3bdc 10279 if (DEFAULT_ABI == ABI_V4
f607bc57 10280 || DEFAULT_ABI == ABI_DARWIN)
cccf3bdc 10281 operands[0] = force_reg (Pmode, operands[0]);
1fd4e8c1 10282
cccf3bdc
DE
10283 else if (DEFAULT_ABI == ABI_AIX)
10284 {
10285 /* AIX function pointers are really pointers to a three word
10286 area. */
10287 emit_call_insn (TARGET_32BIT
10288 ? gen_call_indirect_aix32 (force_reg (SImode,
10289 operands[0]),
10290 operands[1])
10291 : gen_call_indirect_aix64 (force_reg (DImode,
10292 operands[0]),
10293 operands[1]));
10294 DONE;
b6c9286a 10295 }
cccf3bdc
DE
10296 else
10297 abort ();
1fd4e8c1
RK
10298 }
10299}")
10300
10301(define_expand "call_value"
10302 [(parallel [(set (match_operand 0 "" "")
a260abc9 10303 (call (mem:SI (match_operand 1 "address_operand" ""))
1fd4e8c1 10304 (match_operand 2 "" "")))
4697a36c 10305 (use (match_operand 3 "" ""))
1fd4e8c1
RK
10306 (clobber (scratch:SI))])]
10307 ""
10308 "
10309{
ee890fe2 10310#if TARGET_MACHO
ab82a49f 10311 if (MACHOPIC_INDIRECT)
ee890fe2
SS
10312 operands[1] = machopic_indirect_call_target (operands[1]);
10313#endif
10314
1fd4e8c1
RK
10315 if (GET_CODE (operands[1]) != MEM || GET_CODE (operands[2]) != CONST_INT)
10316 abort ();
10317
10318 operands[1] = XEXP (operands[1], 0);
7509c759 10319
6a4cee5f 10320 if (GET_CODE (operands[1]) != SYMBOL_REF
473f51b6 10321 || (DEFAULT_ABI == ABI_AIX && !SYMBOL_REF_FUNCTION_P (operands[1]))
6a4cee5f 10322 || (INTVAL (operands[3]) & CALL_LONG) != 0)
1fd4e8c1 10323 {
6756293c 10324 if (INTVAL (operands[3]) & CALL_LONG)
6a4cee5f
MM
10325 operands[1] = rs6000_longcall_ref (operands[1]);
10326
cccf3bdc 10327 if (DEFAULT_ABI == ABI_V4
f607bc57 10328 || DEFAULT_ABI == ABI_DARWIN)
cccf3bdc 10329 operands[0] = force_reg (Pmode, operands[0]);
1fd4e8c1 10330
cccf3bdc
DE
10331 else if (DEFAULT_ABI == ABI_AIX)
10332 {
10333 /* AIX function pointers are really pointers to a three word
10334 area. */
10335 emit_call_insn (TARGET_32BIT
10336 ? gen_call_value_indirect_aix32 (operands[0],
10337 force_reg (SImode,
10338 operands[1]),
10339 operands[2])
10340 : gen_call_value_indirect_aix64 (operands[0],
10341 force_reg (DImode,
10342 operands[1]),
10343 operands[2]));
10344 DONE;
b6c9286a 10345 }
cccf3bdc
DE
10346 else
10347 abort ();
1fd4e8c1
RK
10348 }
10349}")
10350
04780ee7 10351;; Call to function in current module. No TOC pointer reload needed.
a0ab749a 10352;; Operand2 is nonzero if we are using the V.4 calling sequence and
4697a36c
MM
10353;; either the function was not prototyped, or it was prototyped as a
10354;; variable argument function. It is > 0 if FP registers were passed
10355;; and < 0 if they were not.
04780ee7 10356
a260abc9 10357(define_insn "*call_local32"
4697a36c
MM
10358 [(call (mem:SI (match_operand:SI 0 "current_file_function_operand" "s,s"))
10359 (match_operand 1 "" "g,g"))
10360 (use (match_operand:SI 2 "immediate_operand" "O,n"))
10361 (clobber (match_scratch:SI 3 "=l,l"))]
5a19791c 10362 "(INTVAL (operands[2]) & CALL_LONG) == 0"
4697a36c
MM
10363 "*
10364{
6a4cee5f
MM
10365 if (INTVAL (operands[2]) & CALL_V4_SET_FP_ARGS)
10366 output_asm_insn (\"crxor 6,6,6\", operands);
10367
10368 else if (INTVAL (operands[2]) & CALL_V4_CLEAR_FP_ARGS)
10369 output_asm_insn (\"creqv 6,6,6\", operands);
4697a36c 10370
a226df46 10371 return (DEFAULT_ABI == ABI_V4 && flag_pic) ? \"bl %z0@local\" : \"bl %z0\";
4697a36c 10372}"
b7ff3d82
DE
10373 [(set_attr "type" "branch")
10374 (set_attr "length" "4,8")])
04780ee7 10375
a260abc9
DE
10376(define_insn "*call_local64"
10377 [(call (mem:SI (match_operand:DI 0 "current_file_function_operand" "s,s"))
10378 (match_operand 1 "" "g,g"))
10379 (use (match_operand:SI 2 "immediate_operand" "O,n"))
10380 (clobber (match_scratch:SI 3 "=l,l"))]
10381 "TARGET_64BIT && (INTVAL (operands[2]) & CALL_LONG) == 0"
10382 "*
10383{
10384 if (INTVAL (operands[2]) & CALL_V4_SET_FP_ARGS)
10385 output_asm_insn (\"crxor 6,6,6\", operands);
10386
10387 else if (INTVAL (operands[2]) & CALL_V4_CLEAR_FP_ARGS)
10388 output_asm_insn (\"creqv 6,6,6\", operands);
10389
10390 return (DEFAULT_ABI == ABI_V4 && flag_pic) ? \"bl %z0@local\" : \"bl %z0\";
10391}"
10392 [(set_attr "type" "branch")
10393 (set_attr "length" "4,8")])
10394
cccf3bdc 10395(define_insn "*call_value_local32"
d18dba68 10396 [(set (match_operand 0 "" "")
a260abc9
DE
10397 (call (mem:SI (match_operand:SI 1 "current_file_function_operand" "s,s"))
10398 (match_operand 2 "" "g,g")))
10399 (use (match_operand:SI 3 "immediate_operand" "O,n"))
10400 (clobber (match_scratch:SI 4 "=l,l"))]
10401 "(INTVAL (operands[3]) & CALL_LONG) == 0"
10402 "*
10403{
10404 if (INTVAL (operands[3]) & CALL_V4_SET_FP_ARGS)
10405 output_asm_insn (\"crxor 6,6,6\", operands);
10406
10407 else if (INTVAL (operands[3]) & CALL_V4_CLEAR_FP_ARGS)
10408 output_asm_insn (\"creqv 6,6,6\", operands);
10409
10410 return (DEFAULT_ABI == ABI_V4 && flag_pic) ? \"bl %z1@local\" : \"bl %z1\";
10411}"
10412 [(set_attr "type" "branch")
10413 (set_attr "length" "4,8")])
10414
10415
cccf3bdc 10416(define_insn "*call_value_local64"
d18dba68 10417 [(set (match_operand 0 "" "")
a260abc9
DE
10418 (call (mem:SI (match_operand:DI 1 "current_file_function_operand" "s,s"))
10419 (match_operand 2 "" "g,g")))
10420 (use (match_operand:SI 3 "immediate_operand" "O,n"))
10421 (clobber (match_scratch:SI 4 "=l,l"))]
10422 "TARGET_64BIT && (INTVAL (operands[3]) & CALL_LONG) == 0"
10423 "*
10424{
10425 if (INTVAL (operands[3]) & CALL_V4_SET_FP_ARGS)
10426 output_asm_insn (\"crxor 6,6,6\", operands);
10427
10428 else if (INTVAL (operands[3]) & CALL_V4_CLEAR_FP_ARGS)
10429 output_asm_insn (\"creqv 6,6,6\", operands);
10430
10431 return (DEFAULT_ABI == ABI_V4 && flag_pic) ? \"bl %z1@local\" : \"bl %z1\";
10432}"
10433 [(set_attr "type" "branch")
10434 (set_attr "length" "4,8")])
10435
04780ee7 10436;; Call to function which may be in another module. Restore the TOC
911f679c 10437;; pointer (r2) after the call unless this is System V.
a0ab749a 10438;; Operand2 is nonzero if we are using the V.4 calling sequence and
4697a36c
MM
10439;; either the function was not prototyped, or it was prototyped as a
10440;; variable argument function. It is > 0 if FP registers were passed
10441;; and < 0 if they were not.
04780ee7 10442
cccf3bdc
DE
10443(define_insn "*call_indirect_nonlocal_aix32"
10444 [(call (mem:SI (match_operand:SI 0 "register_operand" "cl"))
10445 (match_operand 1 "" "g"))
10446 (use (reg:SI 2))
10447 (use (reg:SI 11))
10448 (set (reg:SI 2)
10449 (mem:SI (plus:SI (reg:SI 1) (const_int 20))))
c77e04ae 10450 (clobber (match_scratch:SI 2 "=l"))]
cccf3bdc
DE
10451 "TARGET_32BIT && DEFAULT_ABI == ABI_AIX"
10452 "b%T0l\;{l|lwz} 2,20(1)"
10453 [(set_attr "type" "jmpreg")
10454 (set_attr "length" "8")])
10455
a260abc9 10456(define_insn "*call_nonlocal_aix32"
cc4d5fec 10457 [(call (mem:SI (match_operand:SI 0 "symbol_ref_operand" "s"))
cccf3bdc
DE
10458 (match_operand 1 "" "g"))
10459 (use (match_operand:SI 2 "immediate_operand" "O"))
10460 (clobber (match_scratch:SI 3 "=l"))]
10461 "TARGET_32BIT
10462 && DEFAULT_ABI == ABI_AIX
5a19791c 10463 && (INTVAL (operands[2]) & CALL_LONG) == 0"
cccf3bdc 10464 "bl %z0\;%."
b7ff3d82 10465 [(set_attr "type" "branch")
cccf3bdc
DE
10466 (set_attr "length" "8")])
10467
10468(define_insn "*call_indirect_nonlocal_aix64"
10469 [(call (mem:SI (match_operand:DI 0 "register_operand" "cl"))
10470 (match_operand 1 "" "g"))
10471 (use (reg:DI 2))
10472 (use (reg:DI 11))
10473 (set (reg:DI 2)
10474 (mem:DI (plus:DI (reg:DI 1) (const_int 40))))
c77e04ae 10475 (clobber (match_scratch:SI 2 "=l"))]
cccf3bdc
DE
10476 "TARGET_64BIT && DEFAULT_ABI == ABI_AIX"
10477 "b%T0l\;ld 2,40(1)"
10478 [(set_attr "type" "jmpreg")
10479 (set_attr "length" "8")])
59313e4e 10480
a260abc9 10481(define_insn "*call_nonlocal_aix64"
cc4d5fec 10482 [(call (mem:SI (match_operand:DI 0 "symbol_ref_operand" "s"))
cccf3bdc
DE
10483 (match_operand 1 "" "g"))
10484 (use (match_operand:SI 2 "immediate_operand" "O"))
10485 (clobber (match_scratch:SI 3 "=l"))]
9ebbca7d
GK
10486 "TARGET_64BIT
10487 && DEFAULT_ABI == ABI_AIX
a260abc9 10488 && (INTVAL (operands[2]) & CALL_LONG) == 0"
cccf3bdc 10489 "bl %z0\;%."
a260abc9 10490 [(set_attr "type" "branch")
cccf3bdc 10491 (set_attr "length" "8")])
7509c759 10492
cccf3bdc 10493(define_insn "*call_value_indirect_nonlocal_aix32"
d18dba68 10494 [(set (match_operand 0 "" "")
cccf3bdc
DE
10495 (call (mem:SI (match_operand:SI 1 "register_operand" "cl"))
10496 (match_operand 2 "" "g")))
10497 (use (reg:SI 2))
10498 (use (reg:SI 11))
10499 (set (reg:SI 2)
10500 (mem:SI (plus:SI (reg:SI 1) (const_int 20))))
10501 (clobber (match_scratch:SI 3 "=l"))]
10502 "TARGET_32BIT && DEFAULT_ABI == ABI_AIX"
10503 "b%T1l\;{l|lwz} 2,20(1)"
10504 [(set_attr "type" "jmpreg")
10505 (set_attr "length" "8")])
1fd4e8c1 10506
cccf3bdc 10507(define_insn "*call_value_nonlocal_aix32"
d18dba68 10508 [(set (match_operand 0 "" "")
cc4d5fec 10509 (call (mem:SI (match_operand:SI 1 "symbol_ref_operand" "s"))
cccf3bdc
DE
10510 (match_operand 2 "" "g")))
10511 (use (match_operand:SI 3 "immediate_operand" "O"))
10512 (clobber (match_scratch:SI 4 "=l"))]
10513 "TARGET_32BIT
10514 && DEFAULT_ABI == ABI_AIX
a260abc9 10515 && (INTVAL (operands[3]) & CALL_LONG) == 0"
cccf3bdc 10516 "bl %z1\;%."
b7ff3d82 10517 [(set_attr "type" "branch")
cccf3bdc 10518 (set_attr "length" "8")])
04780ee7 10519
cccf3bdc 10520(define_insn "*call_value_indirect_nonlocal_aix64"
d18dba68 10521 [(set (match_operand 0 "" "")
cccf3bdc
DE
10522 (call (mem:SI (match_operand:DI 1 "register_operand" "cl"))
10523 (match_operand 2 "" "g")))
10524 (use (reg:DI 2))
10525 (use (reg:DI 11))
10526 (set (reg:DI 2)
10527 (mem:DI (plus:DI (reg:DI 1) (const_int 40))))
10528 (clobber (match_scratch:SI 3 "=l"))]
10529 "TARGET_64BIT && DEFAULT_ABI == ABI_AIX"
10530 "b%T1l\;ld 2,40(1)"
10531 [(set_attr "type" "jmpreg")
10532 (set_attr "length" "8")])
10533
10534(define_insn "*call_value_nonlocal_aix64"
d18dba68 10535 [(set (match_operand 0 "" "")
cc4d5fec 10536 (call (mem:SI (match_operand:DI 1 "symbol_ref_operand" "s"))
cccf3bdc
DE
10537 (match_operand 2 "" "g")))
10538 (use (match_operand:SI 3 "immediate_operand" "O"))
10539 (clobber (match_scratch:SI 4 "=l"))]
9ebbca7d
GK
10540 "TARGET_64BIT
10541 && DEFAULT_ABI == ABI_AIX
5a19791c 10542 && (INTVAL (operands[3]) & CALL_LONG) == 0"
cccf3bdc
DE
10543 "bl %z1\;%."
10544 [(set_attr "type" "branch")
10545 (set_attr "length" "8")])
10546
10547;; A function pointer under System V is just a normal pointer
10548;; operands[0] is the function pointer
10549;; operands[1] is the stack size to clean up
10550;; operands[2] is the value FUNCTION_ARG returns for the VOID argument
10551;; which indicates how to set cr1
10552
a5c76ee6
ZW
10553(define_insn "*call_indirect_nonlocal_sysv"
10554 [(call (mem:SI (match_operand:SI 0 "register_operand" "cl,cl"))
10555 (match_operand 1 "" "g,g"))
10556 (use (match_operand:SI 2 "immediate_operand" "O,n"))
10557 (clobber (match_scratch:SI 3 "=l,l"))]
50d440bc 10558 "DEFAULT_ABI == ABI_V4
f607bc57 10559 || DEFAULT_ABI == ABI_DARWIN"
911f679c 10560{
cccf3bdc 10561 if (INTVAL (operands[2]) & CALL_V4_SET_FP_ARGS)
a5c76ee6 10562 output_asm_insn ("crxor 6,6,6", operands);
6a4cee5f 10563
cccf3bdc 10564 else if (INTVAL (operands[2]) & CALL_V4_CLEAR_FP_ARGS)
a5c76ee6 10565 output_asm_insn ("creqv 6,6,6", operands);
7509c759 10566
a5c76ee6
ZW
10567 return "b%T0l";
10568}
10569 [(set_attr "type" "jmpreg,jmpreg")
10570 (set_attr "length" "4,8")])
cccf3bdc 10571
a5c76ee6
ZW
10572(define_insn "*call_nonlocal_sysv"
10573 [(call (mem:SI (match_operand:SI 0 "symbol_ref_operand" "s,s"))
10574 (match_operand 1 "" "g,g"))
10575 (use (match_operand:SI 2 "immediate_operand" "O,n"))
10576 (clobber (match_scratch:SI 3 "=l,l"))]
50d440bc 10577 "(DEFAULT_ABI == ABI_V4
a5c76ee6
ZW
10578 || DEFAULT_ABI == ABI_DARWIN)
10579 && (INTVAL (operands[2]) & CALL_LONG) == 0"
10580{
10581 if (INTVAL (operands[2]) & CALL_V4_SET_FP_ARGS)
10582 output_asm_insn ("crxor 6,6,6", operands);
10583
10584 else if (INTVAL (operands[2]) & CALL_V4_CLEAR_FP_ARGS)
10585 output_asm_insn ("creqv 6,6,6", operands);
10586
10587 return (DEFAULT_ABI == ABI_V4 && flag_pic) ? "bl %z0@plt" : "bl %z0";
10588}
10589 [(set_attr "type" "branch,branch")
10590 (set_attr "length" "4,8")])
10591
10592(define_insn "*call_value_indirect_nonlocal_sysv"
d18dba68 10593 [(set (match_operand 0 "" "")
a5c76ee6
ZW
10594 (call (mem:SI (match_operand:SI 1 "register_operand" "cl,cl"))
10595 (match_operand 2 "" "g,g")))
10596 (use (match_operand:SI 3 "immediate_operand" "O,n"))
10597 (clobber (match_scratch:SI 4 "=l,l"))]
50d440bc 10598 "DEFAULT_ABI == ABI_V4
f607bc57 10599 || DEFAULT_ABI == ABI_DARWIN"
b6c9286a 10600{
6a4cee5f 10601 if (INTVAL (operands[3]) & CALL_V4_SET_FP_ARGS)
a5c76ee6 10602 output_asm_insn ("crxor 6,6,6", operands);
6a4cee5f
MM
10603
10604 else if (INTVAL (operands[3]) & CALL_V4_CLEAR_FP_ARGS)
a5c76ee6 10605 output_asm_insn ("creqv 6,6,6", operands);
7509c759 10606
a5c76ee6
ZW
10607 return "b%T1l";
10608}
10609 [(set_attr "type" "jmpreg,jmpreg")
10610 (set_attr "length" "4,8")])
10611
10612(define_insn "*call_value_nonlocal_sysv"
10613 [(set (match_operand 0 "" "")
10614 (call (mem:SI (match_operand:SI 1 "symbol_ref_operand" "s,s"))
10615 (match_operand 2 "" "g,g")))
10616 (use (match_operand:SI 3 "immediate_operand" "O,n"))
10617 (clobber (match_scratch:SI 4 "=l,l"))]
50d440bc 10618 "(DEFAULT_ABI == ABI_V4
a5c76ee6
ZW
10619 || DEFAULT_ABI == ABI_DARWIN)
10620 && (INTVAL (operands[3]) & CALL_LONG) == 0"
10621{
10622 if (INTVAL (operands[3]) & CALL_V4_SET_FP_ARGS)
10623 output_asm_insn ("crxor 6,6,6", operands);
10624
10625 else if (INTVAL (operands[3]) & CALL_V4_CLEAR_FP_ARGS)
10626 output_asm_insn ("creqv 6,6,6", operands);
10627
10628 return (DEFAULT_ABI == ABI_V4 && flag_pic) ? "bl %z1@plt" : "bl %z1";
10629}
10630 [(set_attr "type" "branch,branch")
10631 (set_attr "length" "4,8")])
e6f948e3
RK
10632
10633;; Call subroutine returning any type.
e6f948e3
RK
10634(define_expand "untyped_call"
10635 [(parallel [(call (match_operand 0 "" "")
10636 (const_int 0))
10637 (match_operand 1 "" "")
10638 (match_operand 2 "" "")])]
10639 ""
10640 "
10641{
10642 int i;
10643
7d70b8b2 10644 emit_call_insn (GEN_CALL (operands[0], const0_rtx, const0_rtx, const0_rtx));
e6f948e3
RK
10645
10646 for (i = 0; i < XVECLEN (operands[2], 0); i++)
10647 {
10648 rtx set = XVECEXP (operands[2], 0, i);
10649 emit_move_insn (SET_DEST (set), SET_SRC (set));
10650 }
10651
10652 /* The optimizer does not know that the call sets the function value
10653 registers we stored in the result block. We avoid problems by
10654 claiming that all hard registers are used and clobbered at this
10655 point. */
10656 emit_insn (gen_blockage ());
10657
10658 DONE;
10659}")
10660
5e1bf043
DJ
10661;; sibling call patterns
10662(define_expand "sibcall"
10663 [(parallel [(call (mem:SI (match_operand 0 "address_operand" ""))
10664 (match_operand 1 "" ""))
10665 (use (match_operand 2 "" ""))
fe352c29 10666 (use (match_operand 3 "" ""))
5e1bf043
DJ
10667 (return)])]
10668 ""
10669 "
10670{
10671#if TARGET_MACHO
ab82a49f 10672 if (MACHOPIC_INDIRECT)
5e1bf043
DJ
10673 operands[0] = machopic_indirect_call_target (operands[0]);
10674#endif
10675
10676 if (GET_CODE (operands[0]) != MEM || GET_CODE (operands[1]) != CONST_INT)
10677 abort ();
10678
10679 operands[0] = XEXP (operands[0], 0);
fe352c29 10680 operands[3] = gen_reg_rtx (SImode);
5e1bf043
DJ
10681
10682}")
10683
10684;; this and similar patterns must be marked as using LR, otherwise
10685;; dataflow will try to delete the store into it. This is true
10686;; even when the actual reg to jump to is in CTR, when LR was
10687;; saved and restored around the PIC-setting BCL.
10688(define_insn "*sibcall_local32"
10689 [(call (mem:SI (match_operand:SI 0 "current_file_function_operand" "s,s"))
10690 (match_operand 1 "" "g,g"))
10691 (use (match_operand:SI 2 "immediate_operand" "O,n"))
fe352c29 10692 (use (match_operand:SI 3 "register_operand" "l,l"))
5e1bf043
DJ
10693 (return)]
10694 "(INTVAL (operands[2]) & CALL_LONG) == 0"
10695 "*
10696{
10697 if (INTVAL (operands[2]) & CALL_V4_SET_FP_ARGS)
10698 output_asm_insn (\"crxor 6,6,6\", operands);
10699
10700 else if (INTVAL (operands[2]) & CALL_V4_CLEAR_FP_ARGS)
10701 output_asm_insn (\"creqv 6,6,6\", operands);
10702
10703 return (DEFAULT_ABI == ABI_V4 && flag_pic) ? \"b %z0@local\" : \"b %z0\";
10704}"
10705 [(set_attr "type" "branch")
10706 (set_attr "length" "4,8")])
10707
10708(define_insn "*sibcall_local64"
10709 [(call (mem:SI (match_operand:DI 0 "current_file_function_operand" "s,s"))
10710 (match_operand 1 "" "g,g"))
10711 (use (match_operand:SI 2 "immediate_operand" "O,n"))
fe352c29 10712 (use (match_operand:SI 3 "register_operand" "l,l"))
5e1bf043
DJ
10713 (return)]
10714 "TARGET_64BIT && (INTVAL (operands[2]) & CALL_LONG) == 0"
10715 "*
10716{
10717 if (INTVAL (operands[2]) & CALL_V4_SET_FP_ARGS)
10718 output_asm_insn (\"crxor 6,6,6\", operands);
10719
10720 else if (INTVAL (operands[2]) & CALL_V4_CLEAR_FP_ARGS)
10721 output_asm_insn (\"creqv 6,6,6\", operands);
10722
10723 return (DEFAULT_ABI == ABI_V4 && flag_pic) ? \"b %z0@local\" : \"b %z0\";
10724}"
10725 [(set_attr "type" "branch")
10726 (set_attr "length" "4,8")])
10727
10728(define_insn "*sibcall_value_local32"
10729 [(set (match_operand 0 "" "")
10730 (call (mem:SI (match_operand:SI 1 "current_file_function_operand" "s,s"))
10731 (match_operand 2 "" "g,g")))
10732 (use (match_operand:SI 3 "immediate_operand" "O,n"))
fe352c29 10733 (use (match_operand:SI 4 "register_operand" "l,l"))
5e1bf043
DJ
10734 (return)]
10735 "(INTVAL (operands[3]) & CALL_LONG) == 0"
10736 "*
10737{
10738 if (INTVAL (operands[3]) & CALL_V4_SET_FP_ARGS)
10739 output_asm_insn (\"crxor 6,6,6\", operands);
10740
10741 else if (INTVAL (operands[3]) & CALL_V4_CLEAR_FP_ARGS)
10742 output_asm_insn (\"creqv 6,6,6\", operands);
10743
10744 return (DEFAULT_ABI == ABI_V4 && flag_pic) ? \"b %z1@local\" : \"b %z1\";
10745}"
10746 [(set_attr "type" "branch")
10747 (set_attr "length" "4,8")])
10748
10749
10750(define_insn "*sibcall_value_local64"
10751 [(set (match_operand 0 "" "")
10752 (call (mem:SI (match_operand:DI 1 "current_file_function_operand" "s,s"))
10753 (match_operand 2 "" "g,g")))
10754 (use (match_operand:SI 3 "immediate_operand" "O,n"))
fe352c29 10755 (use (match_operand:SI 4 "register_operand" "l,l"))
5e1bf043
DJ
10756 (return)]
10757 "TARGET_64BIT && (INTVAL (operands[3]) & CALL_LONG) == 0"
10758 "*
10759{
10760 if (INTVAL (operands[3]) & CALL_V4_SET_FP_ARGS)
10761 output_asm_insn (\"crxor 6,6,6\", operands);
10762
10763 else if (INTVAL (operands[3]) & CALL_V4_CLEAR_FP_ARGS)
10764 output_asm_insn (\"creqv 6,6,6\", operands);
10765
10766 return (DEFAULT_ABI == ABI_V4 && flag_pic) ? \"b %z1@local\" : \"b %z1\";
10767}"
10768 [(set_attr "type" "branch")
10769 (set_attr "length" "4,8")])
10770
10771(define_insn "*sibcall_nonlocal_aix32"
10772 [(call (mem:SI (match_operand:SI 0 "symbol_ref_operand" "s"))
10773 (match_operand 1 "" "g"))
10774 (use (match_operand:SI 2 "immediate_operand" "O"))
fe352c29 10775 (use (match_operand:SI 3 "register_operand" "l"))
5e1bf043
DJ
10776 (return)]
10777 "TARGET_32BIT
10778 && DEFAULT_ABI == ABI_AIX
10779 && (INTVAL (operands[2]) & CALL_LONG) == 0"
10780 "b %z0"
10781 [(set_attr "type" "branch")
10782 (set_attr "length" "4")])
10783
10784(define_insn "*sibcall_nonlocal_aix64"
10785 [(call (mem:SI (match_operand:DI 0 "symbol_ref_operand" "s"))
10786 (match_operand 1 "" "g"))
10787 (use (match_operand:SI 2 "immediate_operand" "O"))
fe352c29 10788 (use (match_operand:SI 3 "register_operand" "l"))
5e1bf043
DJ
10789 (return)]
10790 "TARGET_64BIT
10791 && DEFAULT_ABI == ABI_AIX
10792 && (INTVAL (operands[2]) & CALL_LONG) == 0"
10793 "b %z0"
10794 [(set_attr "type" "branch")
10795 (set_attr "length" "4")])
10796
10797(define_insn "*sibcall_value_nonlocal_aix32"
10798 [(set (match_operand 0 "" "")
10799 (call (mem:SI (match_operand:SI 1 "symbol_ref_operand" "s"))
10800 (match_operand 2 "" "g")))
10801 (use (match_operand:SI 3 "immediate_operand" "O"))
fe352c29 10802 (use (match_operand:SI 4 "register_operand" "l"))
5e1bf043
DJ
10803 (return)]
10804 "TARGET_32BIT
10805 && DEFAULT_ABI == ABI_AIX
10806 && (INTVAL (operands[3]) & CALL_LONG) == 0"
10807 "b %z1"
10808 [(set_attr "type" "branch")
10809 (set_attr "length" "4")])
10810
10811(define_insn "*sibcall_value_nonlocal_aix64"
10812 [(set (match_operand 0 "" "")
10813 (call (mem:SI (match_operand:DI 1 "symbol_ref_operand" "s"))
10814 (match_operand 2 "" "g")))
10815 (use (match_operand:SI 3 "immediate_operand" "O"))
fe352c29 10816 (use (match_operand:SI 4 "register_operand" "l"))
5e1bf043
DJ
10817 (return)]
10818 "TARGET_64BIT
10819 && DEFAULT_ABI == ABI_AIX
10820 && (INTVAL (operands[3]) & CALL_LONG) == 0"
10821 "b %z1"
10822 [(set_attr "type" "branch")
10823 (set_attr "length" "4")])
10824
10825(define_insn "*sibcall_nonlocal_sysv"
10826 [(call (mem:SI (match_operand:SI 0 "symbol_ref_operand" "s,s"))
10827 (match_operand 1 "" ""))
10828 (use (match_operand 2 "immediate_operand" "O,n"))
fe352c29 10829 (use (match_operand:SI 3 "register_operand" "l,l"))
5e1bf043
DJ
10830 (return)]
10831 "(DEFAULT_ABI == ABI_DARWIN
50d440bc 10832 || DEFAULT_ABI == ABI_V4)
5e1bf043
DJ
10833 && (INTVAL (operands[2]) & CALL_LONG) == 0"
10834 "*
10835{
10836 if (INTVAL (operands[2]) & CALL_V4_SET_FP_ARGS)
10837 output_asm_insn (\"crxor 6,6,6\", operands);
10838
10839 else if (INTVAL (operands[2]) & CALL_V4_CLEAR_FP_ARGS)
10840 output_asm_insn (\"creqv 6,6,6\", operands);
10841
10842 return (DEFAULT_ABI == ABI_V4 && flag_pic) ? \"b %z0@plt\" : \"b %z0\";
10843}"
10844 [(set_attr "type" "branch,branch")
10845 (set_attr "length" "4,8")])
10846
10847(define_expand "sibcall_value"
10848 [(parallel [(set (match_operand 0 "register_operand" "")
10849 (call (mem:SI (match_operand 1 "address_operand" ""))
10850 (match_operand 2 "" "")))
10851 (use (match_operand 3 "" ""))
fe352c29 10852 (use (match_operand 4 "" ""))
5e1bf043
DJ
10853 (return)])]
10854 ""
10855 "
10856{
10857#if TARGET_MACHO
ab82a49f 10858 if (MACHOPIC_INDIRECT)
5e1bf043
DJ
10859 operands[1] = machopic_indirect_call_target (operands[1]);
10860#endif
10861
10862 if (GET_CODE (operands[1]) != MEM || GET_CODE (operands[2]) != CONST_INT)
10863 abort ();
10864
10865 operands[1] = XEXP (operands[1], 0);
fe352c29 10866 operands[4] = gen_reg_rtx (SImode);
5e1bf043
DJ
10867
10868}")
10869
10870(define_insn "*sibcall_value_nonlocal_sysv"
10871 [(set (match_operand 0 "" "")
10872 (call (mem:SI (match_operand:SI 1 "symbol_ref_operand" "s,s"))
10873 (match_operand 2 "" "")))
10874 (use (match_operand:SI 3 "immediate_operand" "O,n"))
fe352c29 10875 (use (match_operand:SI 4 "register_operand" "l,l"))
5e1bf043
DJ
10876 (return)]
10877 "(DEFAULT_ABI == ABI_DARWIN
50d440bc 10878 || DEFAULT_ABI == ABI_V4)
5e1bf043
DJ
10879 && (INTVAL (operands[3]) & CALL_LONG) == 0"
10880 "*
10881{
10882 if (INTVAL (operands[2]) & CALL_V4_SET_FP_ARGS)
10883 output_asm_insn (\"crxor 6,6,6\", operands);
10884
10885 else if (INTVAL (operands[2]) & CALL_V4_CLEAR_FP_ARGS)
10886 output_asm_insn (\"creqv 6,6,6\", operands);
10887
10888 return (DEFAULT_ABI == ABI_V4 && flag_pic) ? \"b %z1@plt\" : \"b %z1\";
10889}"
10890 [(set_attr "type" "branch,branch")
10891 (set_attr "length" "4,8")])
10892
10893(define_expand "sibcall_epilogue"
10894 [(use (const_int 0))]
10895 "TARGET_SCHED_PROLOG"
10896 "
10897{
10898 rs6000_emit_epilogue (TRUE);
10899 DONE;
10900}")
10901
e6f948e3
RK
10902;; UNSPEC_VOLATILE is considered to use and clobber all hard registers and
10903;; all of memory. This blocks insns from being moved across this point.
10904
10905(define_insn "blockage"
615158e2 10906 [(unspec_volatile [(const_int 0)] UNSPECV_BLOCK)]
e6f948e3
RK
10907 ""
10908 "")
1fd4e8c1
RK
10909\f
10910;; Compare insns are next. Note that the RS/6000 has two types of compares,
7e69e155 10911;; signed & unsigned, and one type of branch.
1fd4e8c1
RK
10912;;
10913;; Start with the DEFINE_EXPANDs to generate the rtl for compares, scc
10914;; insns, and branches. We store the operands of compares until we see
10915;; how it is used.
10916(define_expand "cmpsi"
10917 [(set (cc0)
cd2b37d9 10918 (compare (match_operand:SI 0 "gpc_reg_operand" "")
1fd4e8c1
RK
10919 (match_operand:SI 1 "reg_or_short_operand" "")))]
10920 ""
10921 "
10922{
10923 /* Take care of the possibility that operands[1] might be negative but
10924 this might be a logical operation. That insn doesn't exist. */
10925 if (GET_CODE (operands[1]) == CONST_INT
10926 && INTVAL (operands[1]) < 0)
10927 operands[1] = force_reg (SImode, operands[1]);
10928
10929 rs6000_compare_op0 = operands[0];
10930 rs6000_compare_op1 = operands[1];
10931 rs6000_compare_fp_p = 0;
10932 DONE;
10933}")
10934
266eb58a
DE
10935(define_expand "cmpdi"
10936 [(set (cc0)
10937 (compare (match_operand:DI 0 "gpc_reg_operand" "")
10938 (match_operand:DI 1 "reg_or_short_operand" "")))]
10939 "TARGET_POWERPC64"
10940 "
10941{
10942 /* Take care of the possibility that operands[1] might be negative but
10943 this might be a logical operation. That insn doesn't exist. */
10944 if (GET_CODE (operands[1]) == CONST_INT
10945 && INTVAL (operands[1]) < 0)
10946 operands[1] = force_reg (DImode, operands[1]);
10947
10948 rs6000_compare_op0 = operands[0];
10949 rs6000_compare_op1 = operands[1];
10950 rs6000_compare_fp_p = 0;
10951 DONE;
10952}")
10953
1fd4e8c1 10954(define_expand "cmpsf"
cd2b37d9
RK
10955 [(set (cc0) (compare (match_operand:SF 0 "gpc_reg_operand" "")
10956 (match_operand:SF 1 "gpc_reg_operand" "")))]
d14a6d05 10957 "TARGET_HARD_FLOAT"
1fd4e8c1
RK
10958 "
10959{
10960 rs6000_compare_op0 = operands[0];
10961 rs6000_compare_op1 = operands[1];
10962 rs6000_compare_fp_p = 1;
10963 DONE;
10964}")
10965
10966(define_expand "cmpdf"
cd2b37d9
RK
10967 [(set (cc0) (compare (match_operand:DF 0 "gpc_reg_operand" "")
10968 (match_operand:DF 1 "gpc_reg_operand" "")))]
a3170dc6 10969 "TARGET_HARD_FLOAT && TARGET_FPRS"
1fd4e8c1
RK
10970 "
10971{
10972 rs6000_compare_op0 = operands[0];
10973 rs6000_compare_op1 = operands[1];
10974 rs6000_compare_fp_p = 1;
10975 DONE;
10976}")
10977
d6f99ca4 10978(define_expand "cmptf"
e7a4130e
DE
10979 [(set (cc0) (compare (match_operand:TF 0 "gpc_reg_operand" "")
10980 (match_operand:TF 1 "gpc_reg_operand" "")))]
a3170dc6
AH
10981 "DEFAULT_ABI == ABI_AIX && TARGET_HARD_FLOAT
10982 && TARGET_FPRS && TARGET_LONG_DOUBLE_128"
d6f99ca4
DE
10983 "
10984{
10985 rs6000_compare_op0 = operands[0];
10986 rs6000_compare_op1 = operands[1];
10987 rs6000_compare_fp_p = 1;
10988 DONE;
10989}")
10990
1fd4e8c1 10991(define_expand "beq"
39a10a29 10992 [(use (match_operand 0 "" ""))]
1fd4e8c1 10993 ""
39a10a29 10994 "{ rs6000_emit_cbranch (EQ, operands[0]); DONE; }")
1fd4e8c1
RK
10995
10996(define_expand "bne"
39a10a29 10997 [(use (match_operand 0 "" ""))]
1fd4e8c1 10998 ""
39a10a29 10999 "{ rs6000_emit_cbranch (NE, operands[0]); DONE; }")
1fd4e8c1 11000
39a10a29
GK
11001(define_expand "bge"
11002 [(use (match_operand 0 "" ""))]
1fd4e8c1 11003 ""
39a10a29 11004 "{ rs6000_emit_cbranch (GE, operands[0]); DONE; }")
1fd4e8c1
RK
11005
11006(define_expand "bgt"
39a10a29 11007 [(use (match_operand 0 "" ""))]
1fd4e8c1 11008 ""
39a10a29 11009 "{ rs6000_emit_cbranch (GT, operands[0]); DONE; }")
1fd4e8c1
RK
11010
11011(define_expand "ble"
39a10a29 11012 [(use (match_operand 0 "" ""))]
1fd4e8c1 11013 ""
39a10a29 11014 "{ rs6000_emit_cbranch (LE, operands[0]); DONE; }")
1fd4e8c1 11015
39a10a29
GK
11016(define_expand "blt"
11017 [(use (match_operand 0 "" ""))]
1fd4e8c1 11018 ""
39a10a29 11019 "{ rs6000_emit_cbranch (LT, operands[0]); DONE; }")
1fd4e8c1 11020
39a10a29
GK
11021(define_expand "bgeu"
11022 [(use (match_operand 0 "" ""))]
1fd4e8c1 11023 ""
39a10a29 11024 "{ rs6000_emit_cbranch (GEU, operands[0]); DONE; }")
1fd4e8c1 11025
39a10a29
GK
11026(define_expand "bgtu"
11027 [(use (match_operand 0 "" ""))]
1fd4e8c1 11028 ""
39a10a29 11029 "{ rs6000_emit_cbranch (GTU, operands[0]); DONE; }")
1fd4e8c1 11030
39a10a29
GK
11031(define_expand "bleu"
11032 [(use (match_operand 0 "" ""))]
1fd4e8c1 11033 ""
39a10a29 11034 "{ rs6000_emit_cbranch (LEU, operands[0]); DONE; }")
1fd4e8c1 11035
39a10a29
GK
11036(define_expand "bltu"
11037 [(use (match_operand 0 "" ""))]
1fd4e8c1 11038 ""
39a10a29 11039 "{ rs6000_emit_cbranch (LTU, operands[0]); DONE; }")
1fd4e8c1 11040
1c882ea4 11041(define_expand "bunordered"
39a10a29 11042 [(use (match_operand 0 "" ""))]
1c882ea4 11043 ""
39a10a29 11044 "{ rs6000_emit_cbranch (UNORDERED, operands[0]); DONE; }")
1c882ea4
GK
11045
11046(define_expand "bordered"
39a10a29 11047 [(use (match_operand 0 "" ""))]
1c882ea4 11048 ""
39a10a29 11049 "{ rs6000_emit_cbranch (ORDERED, operands[0]); DONE; }")
1c882ea4
GK
11050
11051(define_expand "buneq"
39a10a29 11052 [(use (match_operand 0 "" ""))]
1c882ea4 11053 ""
39a10a29 11054 "{ rs6000_emit_cbranch (UNEQ, operands[0]); DONE; }")
1c882ea4
GK
11055
11056(define_expand "bunge"
39a10a29 11057 [(use (match_operand 0 "" ""))]
1c882ea4 11058 ""
39a10a29 11059 "{ rs6000_emit_cbranch (UNGE, operands[0]); DONE; }")
1c882ea4
GK
11060
11061(define_expand "bungt"
39a10a29 11062 [(use (match_operand 0 "" ""))]
1c882ea4 11063 ""
39a10a29 11064 "{ rs6000_emit_cbranch (UNGT, operands[0]); DONE; }")
1c882ea4
GK
11065
11066(define_expand "bunle"
39a10a29 11067 [(use (match_operand 0 "" ""))]
1c882ea4 11068 ""
39a10a29 11069 "{ rs6000_emit_cbranch (UNLE, operands[0]); DONE; }")
1c882ea4
GK
11070
11071(define_expand "bunlt"
39a10a29 11072 [(use (match_operand 0 "" ""))]
1c882ea4 11073 ""
39a10a29 11074 "{ rs6000_emit_cbranch (UNLT, operands[0]); DONE; }")
1c882ea4
GK
11075
11076(define_expand "bltgt"
39a10a29 11077 [(use (match_operand 0 "" ""))]
1c882ea4 11078 ""
39a10a29 11079 "{ rs6000_emit_cbranch (LTGT, operands[0]); DONE; }")
1c882ea4 11080
1fd4e8c1
RK
11081;; For SNE, we would prefer that the xor/abs sequence be used for integers.
11082;; For SEQ, likewise, except that comparisons with zero should be done
11083;; with an scc insns. However, due to the order that combine see the
11084;; resulting insns, we must, in fact, allow SEQ for integers. Fail in
11085;; the cases we don't want to handle.
11086(define_expand "seq"
39a10a29 11087 [(clobber (match_operand:SI 0 "gpc_reg_operand" ""))]
1fd4e8c1 11088 ""
39a10a29 11089 "{ rs6000_emit_sCOND (EQ, operands[0]); DONE; }")
1fd4e8c1
RK
11090
11091(define_expand "sne"
39a10a29 11092 [(clobber (match_operand:SI 0 "gpc_reg_operand" ""))]
1fd4e8c1
RK
11093 ""
11094 "
39a10a29
GK
11095{
11096 if (! rs6000_compare_fp_p)
1fd4e8c1
RK
11097 FAIL;
11098
39a10a29
GK
11099 rs6000_emit_sCOND (NE, operands[0]);
11100 DONE;
1fd4e8c1
RK
11101}")
11102
b7053a3f
GK
11103;; A >= 0 is best done the portable way for A an integer.
11104(define_expand "sge"
39a10a29 11105 [(clobber (match_operand:SI 0 "gpc_reg_operand" ""))]
1fd4e8c1
RK
11106 ""
11107 "
5638268e
DE
11108{
11109 if (! rs6000_compare_fp_p
11110 && (! TARGET_POWER || rs6000_compare_op1 == const0_rtx))
1fd4e8c1
RK
11111 FAIL;
11112
b7053a3f 11113 rs6000_emit_sCOND (GE, operands[0]);
39a10a29 11114 DONE;
1fd4e8c1
RK
11115}")
11116
b7053a3f
GK
11117;; A > 0 is best done using the portable sequence, so fail in that case.
11118(define_expand "sgt"
39a10a29 11119 [(clobber (match_operand:SI 0 "gpc_reg_operand" ""))]
1fd4e8c1
RK
11120 ""
11121 "
5638268e 11122{
b7053a3f 11123 if (! rs6000_compare_fp_p
5638268e 11124 && (! TARGET_POWER || rs6000_compare_op1 == const0_rtx))
1fd4e8c1
RK
11125 FAIL;
11126
b7053a3f 11127 rs6000_emit_sCOND (GT, operands[0]);
39a10a29 11128 DONE;
1fd4e8c1
RK
11129}")
11130
b7053a3f
GK
11131;; A <= 0 is best done the portable way for A an integer.
11132(define_expand "sle"
39a10a29 11133 [(clobber (match_operand:SI 0 "gpc_reg_operand" ""))]
1fd4e8c1 11134 ""
5638268e
DE
11135 "
11136{
11137 if (! rs6000_compare_fp_p
11138 && (! TARGET_POWER || rs6000_compare_op1 == const0_rtx))
11139 FAIL;
11140
b7053a3f 11141 rs6000_emit_sCOND (LE, operands[0]);
5638268e
DE
11142 DONE;
11143}")
1fd4e8c1 11144
b7053a3f
GK
11145;; A < 0 is best done in the portable way for A an integer.
11146(define_expand "slt"
39a10a29 11147 [(clobber (match_operand:SI 0 "gpc_reg_operand" ""))]
1fd4e8c1
RK
11148 ""
11149 "
5638268e 11150{
b7053a3f 11151 if (! rs6000_compare_fp_p
5638268e 11152 && (! TARGET_POWER || rs6000_compare_op1 == const0_rtx))
1fd4e8c1
RK
11153 FAIL;
11154
b7053a3f 11155 rs6000_emit_sCOND (LT, operands[0]);
39a10a29 11156 DONE;
1fd4e8c1
RK
11157}")
11158
b7053a3f
GK
11159(define_expand "sgeu"
11160 [(clobber (match_operand:SI 0 "gpc_reg_operand" ""))]
11161 ""
11162 "{ rs6000_emit_sCOND (GEU, operands[0]); DONE; }")
11163
1fd4e8c1 11164(define_expand "sgtu"
39a10a29 11165 [(clobber (match_operand:SI 0 "gpc_reg_operand" ""))]
1fd4e8c1 11166 ""
39a10a29 11167 "{ rs6000_emit_sCOND (GTU, operands[0]); DONE; }")
1fd4e8c1 11168
b7053a3f
GK
11169(define_expand "sleu"
11170 [(clobber (match_operand:SI 0 "gpc_reg_operand" ""))]
11171 ""
11172 "{ rs6000_emit_sCOND (LEU, operands[0]); DONE; }")
11173
1fd4e8c1 11174(define_expand "sltu"
39a10a29 11175 [(clobber (match_operand:SI 0 "gpc_reg_operand" ""))]
1fd4e8c1 11176 ""
39a10a29 11177 "{ rs6000_emit_sCOND (LTU, operands[0]); DONE; }")
1fd4e8c1 11178
b7053a3f 11179(define_expand "sunordered"
39a10a29 11180 [(clobber (match_operand:SI 0 "gpc_reg_operand" ""))]
1fd4e8c1 11181 ""
b7053a3f 11182 "{ rs6000_emit_sCOND (UNORDERED, operands[0]); DONE; }")
1fd4e8c1 11183
b7053a3f 11184(define_expand "sordered"
39a10a29 11185 [(clobber (match_operand:SI 0 "gpc_reg_operand" ""))]
1fd4e8c1 11186 ""
b7053a3f
GK
11187 "{ rs6000_emit_sCOND (ORDERED, operands[0]); DONE; }")
11188
11189(define_expand "suneq"
11190 [(clobber (match_operand:SI 0 "gpc_reg_operand" ""))]
11191 ""
11192 "{ rs6000_emit_sCOND (UNEQ, operands[0]); DONE; }")
11193
11194(define_expand "sunge"
11195 [(clobber (match_operand:SI 0 "gpc_reg_operand" ""))]
11196 ""
11197 "{ rs6000_emit_sCOND (UNGE, operands[0]); DONE; }")
11198
11199(define_expand "sungt"
11200 [(clobber (match_operand:SI 0 "gpc_reg_operand" ""))]
11201 ""
11202 "{ rs6000_emit_sCOND (UNGT, operands[0]); DONE; }")
11203
11204(define_expand "sunle"
11205 [(clobber (match_operand:SI 0 "gpc_reg_operand" ""))]
11206 ""
11207 "{ rs6000_emit_sCOND (UNLE, operands[0]); DONE; }")
11208
11209(define_expand "sunlt"
11210 [(clobber (match_operand:SI 0 "gpc_reg_operand" ""))]
11211 ""
11212 "{ rs6000_emit_sCOND (UNLT, operands[0]); DONE; }")
11213
11214(define_expand "sltgt"
11215 [(clobber (match_operand:SI 0 "gpc_reg_operand" ""))]
11216 ""
11217 "{ rs6000_emit_sCOND (LTGT, operands[0]); DONE; }")
11218
1fd4e8c1
RK
11219\f
11220;; Here are the actual compare insns.
acad7ed3 11221(define_insn "*cmpsi_internal1"
1fd4e8c1 11222 [(set (match_operand:CC 0 "cc_reg_operand" "=y")
cd2b37d9 11223 (compare:CC (match_operand:SI 1 "gpc_reg_operand" "r")
1fd4e8c1
RK
11224 (match_operand:SI 2 "reg_or_short_operand" "rI")))]
11225 ""
7f340546 11226 "{cmp%I2|cmpw%I2} %0,%1,%2"
b54cf83a 11227 [(set_attr "type" "cmp")])
1fd4e8c1 11228
acad7ed3 11229(define_insn "*cmpdi_internal1"
266eb58a
DE
11230 [(set (match_operand:CC 0 "cc_reg_operand" "=y")
11231 (compare:CC (match_operand:DI 1 "gpc_reg_operand" "r")
11232 (match_operand:DI 2 "reg_or_short_operand" "rI")))]
11233 "TARGET_POWERPC64"
11234 "cmpd%I2 %0,%1,%2"
b54cf83a 11235 [(set_attr "type" "cmp")])
266eb58a 11236
f357808b
RK
11237;; If we are comparing a register for equality with a large constant,
11238;; we can do this with an XOR followed by a compare. But we need a scratch
11239;; register for the result of the XOR.
11240
11241(define_split
11242 [(set (match_operand:CC 0 "cc_reg_operand" "")
cd2b37d9 11243 (compare:CC (match_operand:SI 1 "gpc_reg_operand" "")
f357808b 11244 (match_operand:SI 2 "non_short_cint_operand" "")))
cd2b37d9 11245 (clobber (match_operand:SI 3 "gpc_reg_operand" ""))]
f357808b
RK
11246 "find_single_use (operands[0], insn, 0)
11247 && (GET_CODE (*find_single_use (operands[0], insn, 0)) == EQ
11248 || GET_CODE (*find_single_use (operands[0], insn, 0)) == NE)"
11249 [(set (match_dup 3) (xor:SI (match_dup 1) (match_dup 4)))
11250 (set (match_dup 0) (compare:CC (match_dup 3) (match_dup 5)))]
11251 "
11252{
11253 /* Get the constant we are comparing against, C, and see what it looks like
11254 sign-extended to 16 bits. Then see what constant could be XOR'ed
11255 with C to get the sign-extended value. */
11256
5f59ecb7 11257 HOST_WIDE_INT c = INTVAL (operands[2]);
a65c591c 11258 HOST_WIDE_INT sextc = ((c & 0xffff) ^ 0x8000) - 0x8000;
5f59ecb7 11259 HOST_WIDE_INT xorv = c ^ sextc;
f357808b 11260
89e9f3a8
MM
11261 operands[4] = GEN_INT (xorv);
11262 operands[5] = GEN_INT (sextc);
f357808b
RK
11263}")
11264
acad7ed3 11265(define_insn "*cmpsi_internal2"
1fd4e8c1 11266 [(set (match_operand:CCUNS 0 "cc_reg_operand" "=y")
cd2b37d9 11267 (compare:CCUNS (match_operand:SI 1 "gpc_reg_operand" "r")
9ebbca7d 11268 (match_operand:SI 2 "reg_or_u_short_operand" "rK")))]
1fd4e8c1 11269 ""
e2c953b6 11270 "{cmpl%I2|cmplw%I2} %0,%1,%b2"
b54cf83a 11271 [(set_attr "type" "cmp")])
1fd4e8c1 11272
acad7ed3 11273(define_insn "*cmpdi_internal2"
266eb58a
DE
11274 [(set (match_operand:CCUNS 0 "cc_reg_operand" "=y")
11275 (compare:CCUNS (match_operand:DI 1 "gpc_reg_operand" "r")
9ebbca7d 11276 (match_operand:DI 2 "reg_or_u_short_operand" "rK")))]
266eb58a 11277 ""
e2c953b6 11278 "cmpld%I2 %0,%1,%b2"
b54cf83a 11279 [(set_attr "type" "cmp")])
266eb58a 11280
1fd4e8c1
RK
11281;; The following two insns don't exist as single insns, but if we provide
11282;; them, we can swap an add and compare, which will enable us to overlap more
11283;; of the required delay between a compare and branch. We generate code for
11284;; them by splitting.
11285
11286(define_insn ""
11287 [(set (match_operand:CC 3 "cc_reg_operand" "=y")
cd2b37d9 11288 (compare:CC (match_operand:SI 1 "gpc_reg_operand" "r")
1fd4e8c1 11289 (match_operand:SI 2 "short_cint_operand" "i")))
cd2b37d9 11290 (set (match_operand:SI 0 "gpc_reg_operand" "=r")
1fd4e8c1
RK
11291 (plus:SI (match_dup 1) (match_operand:SI 4 "short_cint_operand" "i")))]
11292 ""
baf97f86
RK
11293 "#"
11294 [(set_attr "length" "8")])
7e69e155 11295
1fd4e8c1
RK
11296(define_insn ""
11297 [(set (match_operand:CCUNS 3 "cc_reg_operand" "=y")
cd2b37d9 11298 (compare:CCUNS (match_operand:SI 1 "gpc_reg_operand" "r")
1fd4e8c1 11299 (match_operand:SI 2 "u_short_cint_operand" "i")))
cd2b37d9 11300 (set (match_operand:SI 0 "gpc_reg_operand" "=r")
1fd4e8c1
RK
11301 (plus:SI (match_dup 1) (match_operand:SI 4 "short_cint_operand" "i")))]
11302 ""
baf97f86
RK
11303 "#"
11304 [(set_attr "length" "8")])
7e69e155 11305
1fd4e8c1
RK
11306(define_split
11307 [(set (match_operand:CC 3 "cc_reg_operand" "")
cd2b37d9 11308 (compare:CC (match_operand:SI 1 "gpc_reg_operand" "")
1fd4e8c1 11309 (match_operand:SI 2 "short_cint_operand" "")))
cd2b37d9 11310 (set (match_operand:SI 0 "gpc_reg_operand" "")
1fd4e8c1
RK
11311 (plus:SI (match_dup 1) (match_operand:SI 4 "short_cint_operand" "")))]
11312 ""
11313 [(set (match_dup 3) (compare:CC (match_dup 1) (match_dup 2)))
11314 (set (match_dup 0) (plus:SI (match_dup 1) (match_dup 4)))])
11315
11316(define_split
11317 [(set (match_operand:CCUNS 3 "cc_reg_operand" "")
cd2b37d9 11318 (compare:CCUNS (match_operand:SI 1 "gpc_reg_operand" "")
1fd4e8c1 11319 (match_operand:SI 2 "u_short_cint_operand" "")))
cd2b37d9 11320 (set (match_operand:SI 0 "gpc_reg_operand" "")
1fd4e8c1
RK
11321 (plus:SI (match_dup 1) (match_operand:SI 4 "short_cint_operand" "")))]
11322 ""
11323 [(set (match_dup 3) (compare:CCUNS (match_dup 1) (match_dup 2)))
11324 (set (match_dup 0) (plus:SI (match_dup 1) (match_dup 4)))])
11325
acad7ed3 11326(define_insn "*cmpsf_internal1"
1fd4e8c1 11327 [(set (match_operand:CCFP 0 "cc_reg_operand" "=y")
cd2b37d9
RK
11328 (compare:CCFP (match_operand:SF 1 "gpc_reg_operand" "f")
11329 (match_operand:SF 2 "gpc_reg_operand" "f")))]
a3170dc6 11330 "TARGET_HARD_FLOAT && TARGET_FPRS"
1fd4e8c1
RK
11331 "fcmpu %0,%1,%2"
11332 [(set_attr "type" "fpcompare")])
11333
acad7ed3 11334(define_insn "*cmpdf_internal1"
1fd4e8c1 11335 [(set (match_operand:CCFP 0 "cc_reg_operand" "=y")
cd2b37d9
RK
11336 (compare:CCFP (match_operand:DF 1 "gpc_reg_operand" "f")
11337 (match_operand:DF 2 "gpc_reg_operand" "f")))]
a3170dc6 11338 "TARGET_HARD_FLOAT && TARGET_FPRS"
1fd4e8c1
RK
11339 "fcmpu %0,%1,%2"
11340 [(set_attr "type" "fpcompare")])
d6f99ca4
DE
11341
11342;; Only need to compare second words if first words equal
11343(define_insn "*cmptf_internal1"
11344 [(set (match_operand:CCFP 0 "cc_reg_operand" "=y")
11345 (compare:CCFP (match_operand:TF 1 "gpc_reg_operand" "f")
11346 (match_operand:TF 2 "gpc_reg_operand" "f")))]
a3170dc6
AH
11347 "DEFAULT_ABI == ABI_AIX && TARGET_HARD_FLOAT && TARGET_FPRS
11348 && TARGET_LONG_DOUBLE_128"
2e7d5318 11349 "fcmpu %0,%1,%2\;bne %0,$+4\;fcmpu %0,%L1,%L2"
d6f99ca4
DE
11350 [(set_attr "type" "fpcompare")
11351 (set_attr "length" "12")])
1fd4e8c1
RK
11352\f
11353;; Now we have the scc insns. We can do some combinations because of the
11354;; way the machine works.
11355;;
11356;; Note that this is probably faster if we can put an insn between the
c5defebb
RK
11357;; mfcr and rlinm, but this is tricky. Let's leave it for now. In most
11358;; cases the insns below which don't use an intermediate CR field will
11359;; be used instead.
1fd4e8c1 11360(define_insn ""
cd2b37d9 11361 [(set (match_operand:SI 0 "gpc_reg_operand" "=r")
1fd4e8c1
RK
11362 (match_operator:SI 1 "scc_comparison_operator"
11363 [(match_operand 2 "cc_reg_operand" "y")
11364 (const_int 0)]))]
11365 ""
2c4a9cff
DE
11366 "mfcr %0%Q2\;{rlinm|rlwinm} %0,%0,%J1,1"
11367 [(set (attr "type")
11368 (cond [(ne (symbol_ref "TARGET_MFCRF") (const_int 0))
11369 (const_string "mfcrf")
11370 ]
11371 (const_string "mfcr")))
309323c2 11372 (set_attr "length" "12")])
1fd4e8c1 11373
a3170dc6
AH
11374;; Same as above, but get the OV/ORDERED bit.
11375(define_insn "move_from_CR_ov_bit"
11376 [(set (match_operand:SI 0 "gpc_reg_operand" "=r")
615158e2 11377 (unspec:SI [(match_operand 1 "cc_reg_operand" "y")] UNSPEC_MV_CR_OV))]
a3170dc6 11378 "TARGET_ISEL"
b7053a3f 11379 "mfcr %0\;{rlinm|rlwinm} %0,%0,%t1,1"
b54cf83a
DE
11380 [(set_attr "type" "mfcr")
11381 (set_attr "length" "12")])
a3170dc6 11382
1fd4e8c1 11383(define_insn ""
9ebbca7d
GK
11384 [(set (match_operand:DI 0 "gpc_reg_operand" "=r")
11385 (match_operator:DI 1 "scc_comparison_operator"
11386 [(match_operand 2 "cc_reg_operand" "y")
11387 (const_int 0)]))]
11388 "TARGET_POWERPC64"
2c4a9cff
DE
11389 "mfcr %0%Q2\;{rlinm|rlwinm} %0,%0,%J1,1"
11390 [(set (attr "type")
11391 (cond [(ne (symbol_ref "TARGET_MFCRF") (const_int 0))
11392 (const_string "mfcrf")
11393 ]
11394 (const_string "mfcr")))
309323c2 11395 (set_attr "length" "12")])
9ebbca7d
GK
11396
11397(define_insn ""
11398 [(set (match_operand:CC 0 "cc_reg_operand" "=x,?y")
1fd4e8c1 11399 (compare:CC (match_operator:SI 1 "scc_comparison_operator"
9ebbca7d 11400 [(match_operand 2 "cc_reg_operand" "y,y")
1fd4e8c1
RK
11401 (const_int 0)])
11402 (const_int 0)))
9ebbca7d 11403 (set (match_operand:SI 3 "gpc_reg_operand" "=r,r")
1fd4e8c1 11404 (match_op_dup 1 [(match_dup 2) (const_int 0)]))]
0ad91047 11405 "! TARGET_POWERPC64"
9ebbca7d 11406 "@
2c4a9cff 11407 mfcr %3%Q2\;{rlinm.|rlwinm.} %3,%3,%J1,1
9ebbca7d 11408 #"
b19003d8 11409 [(set_attr "type" "delayed_compare")
9ebbca7d
GK
11410 (set_attr "length" "12,16")])
11411
11412(define_split
11413 [(set (match_operand:CC 0 "cc_reg_not_cr0_operand" "")
11414 (compare:CC (match_operator:SI 1 "scc_comparison_operator"
11415 [(match_operand 2 "cc_reg_operand" "")
11416 (const_int 0)])
11417 (const_int 0)))
11418 (set (match_operand:SI 3 "gpc_reg_operand" "")
11419 (match_op_dup 1 [(match_dup 2) (const_int 0)]))]
11420 "! TARGET_POWERPC64 && reload_completed"
11421 [(set (match_dup 3)
11422 (match_op_dup 1 [(match_dup 2) (const_int 0)]))
11423 (set (match_dup 0)
11424 (compare:CC (match_dup 3)
11425 (const_int 0)))]
11426 "")
1fd4e8c1
RK
11427
11428(define_insn ""
cd2b37d9 11429 [(set (match_operand:SI 0 "gpc_reg_operand" "=r")
1fd4e8c1
RK
11430 (ashift:SI (match_operator:SI 1 "scc_comparison_operator"
11431 [(match_operand 2 "cc_reg_operand" "y")
11432 (const_int 0)])
11433 (match_operand:SI 3 "const_int_operand" "n")))]
11434 ""
11435 "*
11436{
11437 int is_bit = ccr_bit (operands[1], 1);
11438 int put_bit = 31 - (INTVAL (operands[3]) & 31);
11439 int count;
11440
11441 if (is_bit >= put_bit)
11442 count = is_bit - put_bit;
11443 else
11444 count = 32 - (put_bit - is_bit);
11445
89e9f3a8
MM
11446 operands[4] = GEN_INT (count);
11447 operands[5] = GEN_INT (put_bit);
1fd4e8c1 11448
2c4a9cff 11449 return \"mfcr %0%Q2\;{rlinm|rlwinm} %0,%0,%4,%5,%5\";
b19003d8 11450}"
2c4a9cff
DE
11451 [(set (attr "type")
11452 (cond [(ne (symbol_ref "TARGET_MFCRF") (const_int 0))
11453 (const_string "mfcrf")
11454 ]
11455 (const_string "mfcr")))
309323c2 11456 (set_attr "length" "12")])
1fd4e8c1
RK
11457
11458(define_insn ""
9ebbca7d 11459 [(set (match_operand:CC 0 "cc_reg_operand" "=x,?y")
1fd4e8c1
RK
11460 (compare:CC
11461 (ashift:SI (match_operator:SI 1 "scc_comparison_operator"
9ebbca7d 11462 [(match_operand 2 "cc_reg_operand" "y,y")
1fd4e8c1 11463 (const_int 0)])
9ebbca7d 11464 (match_operand:SI 3 "const_int_operand" "n,n"))
1fd4e8c1 11465 (const_int 0)))
9ebbca7d 11466 (set (match_operand:SI 4 "gpc_reg_operand" "=r,r")
1fd4e8c1
RK
11467 (ashift:SI (match_op_dup 1 [(match_dup 2) (const_int 0)])
11468 (match_dup 3)))]
ce71f754 11469 ""
1fd4e8c1
RK
11470 "*
11471{
11472 int is_bit = ccr_bit (operands[1], 1);
11473 int put_bit = 31 - (INTVAL (operands[3]) & 31);
11474 int count;
11475
9ebbca7d
GK
11476 /* Force split for non-cc0 compare. */
11477 if (which_alternative == 1)
11478 return \"#\";
11479
1fd4e8c1
RK
11480 if (is_bit >= put_bit)
11481 count = is_bit - put_bit;
11482 else
11483 count = 32 - (put_bit - is_bit);
11484
89e9f3a8
MM
11485 operands[5] = GEN_INT (count);
11486 operands[6] = GEN_INT (put_bit);
1fd4e8c1 11487
2c4a9cff 11488 return \"mfcr %4%Q2\;{rlinm.|rlwinm.} %4,%4,%5,%6,%6\";
1fd4e8c1 11489}"
b19003d8 11490 [(set_attr "type" "delayed_compare")
9ebbca7d
GK
11491 (set_attr "length" "12,16")])
11492
11493(define_split
11494 [(set (match_operand:CC 0 "cc_reg_not_cr0_operand" "")
11495 (compare:CC
11496 (ashift:SI (match_operator:SI 1 "scc_comparison_operator"
11497 [(match_operand 2 "cc_reg_operand" "")
11498 (const_int 0)])
11499 (match_operand:SI 3 "const_int_operand" ""))
11500 (const_int 0)))
11501 (set (match_operand:SI 4 "gpc_reg_operand" "")
11502 (ashift:SI (match_op_dup 1 [(match_dup 2) (const_int 0)])
11503 (match_dup 3)))]
ce71f754 11504 "reload_completed"
9ebbca7d
GK
11505 [(set (match_dup 4)
11506 (ashift:SI (match_op_dup 1 [(match_dup 2) (const_int 0)])
11507 (match_dup 3)))
11508 (set (match_dup 0)
11509 (compare:CC (match_dup 4)
11510 (const_int 0)))]
11511 "")
1fd4e8c1 11512
c5defebb
RK
11513;; There is a 3 cycle delay between consecutive mfcr instructions
11514;; so it is useful to combine 2 scc instructions to use only one mfcr.
11515
11516(define_peephole
cd2b37d9 11517 [(set (match_operand:SI 0 "gpc_reg_operand" "=r")
c5defebb
RK
11518 (match_operator:SI 1 "scc_comparison_operator"
11519 [(match_operand 2 "cc_reg_operand" "y")
11520 (const_int 0)]))
cd2b37d9 11521 (set (match_operand:SI 3 "gpc_reg_operand" "=r")
c5defebb
RK
11522 (match_operator:SI 4 "scc_comparison_operator"
11523 [(match_operand 5 "cc_reg_operand" "y")
11524 (const_int 0)]))]
309323c2 11525 "REGNO (operands[2]) != REGNO (operands[5])"
b7053a3f 11526 "mfcr %3\;{rlinm|rlwinm} %0,%3,%J1,1\;{rlinm|rlwinm} %3,%3,%J4,1"
b54cf83a 11527 [(set_attr "type" "mfcr")
309323c2 11528 (set_attr "length" "20")])
c5defebb 11529
9ebbca7d
GK
11530(define_peephole
11531 [(set (match_operand:DI 0 "gpc_reg_operand" "=r")
11532 (match_operator:DI 1 "scc_comparison_operator"
11533 [(match_operand 2 "cc_reg_operand" "y")
11534 (const_int 0)]))
11535 (set (match_operand:DI 3 "gpc_reg_operand" "=r")
11536 (match_operator:DI 4 "scc_comparison_operator"
11537 [(match_operand 5 "cc_reg_operand" "y")
11538 (const_int 0)]))]
309323c2 11539 "TARGET_POWERPC64 && REGNO (operands[2]) != REGNO (operands[5])"
b7053a3f 11540 "mfcr %3\;{rlinm|rlwinm} %0,%3,%J1,1\;{rlinm|rlwinm} %3,%3,%J4,1"
b54cf83a 11541 [(set_attr "type" "mfcr")
309323c2 11542 (set_attr "length" "20")])
9ebbca7d 11543
1fd4e8c1
RK
11544;; There are some scc insns that can be done directly, without a compare.
11545;; These are faster because they don't involve the communications between
11546;; the FXU and branch units. In fact, we will be replacing all of the
11547;; integer scc insns here or in the portable methods in emit_store_flag.
11548;;
11549;; Also support (neg (scc ..)) since that construct is used to replace
11550;; branches, (plus (scc ..) ..) since that construct is common and
11551;; takes no more insns than scc, and (and (neg (scc ..)) ..) in the
11552;; cases where it is no more expensive than (neg (scc ..)).
11553
11554;; Have reload force a constant into a register for the simple insns that
11555;; otherwise won't accept constants. We do this because it is faster than
11556;; the cmp/mfcr sequence we would otherwise generate.
11557
11558(define_insn ""
cd2b37d9
RK
11559 [(set (match_operand:SI 0 "gpc_reg_operand" "=r,r,r,r,r")
11560 (eq:SI (match_operand:SI 1 "gpc_reg_operand" "%r,r,r,r,r")
5f59ecb7 11561 (match_operand:SI 2 "reg_or_cint_operand" "r,O,K,L,I")))
1fd4e8c1 11562 (clobber (match_scratch:SI 3 "=r,&r,r,r,r"))]
683bdff7 11563 "TARGET_32BIT"
1fd4e8c1 11564 "@
ca7f5001 11565 xor %0,%1,%2\;{sfi|subfic} %3,%0,0\;{ae|adde} %0,%3,%0
71d2371f 11566 {sfi|subfic} %3,%1,0\;{ae|adde} %0,%3,%1
ca7f5001
RK
11567 {xoril|xori} %0,%1,%b2\;{sfi|subfic} %3,%0,0\;{ae|adde} %0,%3,%0
11568 {xoriu|xoris} %0,%1,%u2\;{sfi|subfic} %3,%0,0\;{ae|adde} %0,%3,%0
11569 {sfi|subfic} %0,%1,%2\;{sfi|subfic} %3,%0,0\;{ae|adde} %0,%3,%0"
b19003d8 11570 [(set_attr "length" "12,8,12,12,12")])
1fd4e8c1 11571
a260abc9
DE
11572(define_insn ""
11573 [(set (match_operand:DI 0 "gpc_reg_operand" "=r,r,r,r,r")
11574 (eq:DI (match_operand:DI 1 "gpc_reg_operand" "%r,r,r,r,r")
11575 (match_operand:DI 2 "reg_or_cint_operand" "r,O,K,J,I")))
11576 (clobber (match_scratch:DI 3 "=r,&r,r,r,r"))]
683bdff7 11577 "TARGET_64BIT"
a260abc9
DE
11578 "@
11579 xor %0,%1,%2\;subfic %3,%0,0\;adde %0,%3,%0
11580 subfic %3,%1,0\;adde %0,%3,%1
11581 xori %0,%1,%b2\;subfic %3,%0,0\;adde %0,%3,%0
11582 xoris %0,%1,%u2\;subfic %3,%0,0\;adde %0,%3,%0
11583 subfic %0,%1,%2\;subfic %3,%0,0\;adde %0,%3,%0"
11584 [(set_attr "length" "12,8,12,12,12")])
11585
1fd4e8c1 11586(define_insn ""
9ebbca7d 11587 [(set (match_operand:CC 4 "cc_reg_operand" "=x,x,x,x,x,?y,?y,?y,?y,?y")
7e69e155 11588 (compare:CC
9ebbca7d
GK
11589 (eq:SI (match_operand:SI 1 "gpc_reg_operand" "%r,r,r,r,r,r,r,r,r,r")
11590 (match_operand:SI 2 "reg_or_cint_operand" "r,O,K,L,I,r,O,K,L,I"))
1fd4e8c1 11591 (const_int 0)))
9ebbca7d 11592 (set (match_operand:SI 0 "gpc_reg_operand" "=r,r,r,r,r,r,r,r,r,r")
1fd4e8c1 11593 (eq:SI (match_dup 1) (match_dup 2)))
9ebbca7d 11594 (clobber (match_scratch:SI 3 "=r,&r,r,r,r,r,&r,r,r,r"))]
683bdff7 11595 "TARGET_32BIT"
1fd4e8c1 11596 "@
ca7f5001
RK
11597 xor %0,%1,%2\;{sfi|subfic} %3,%0,0\;{ae.|adde.} %0,%3,%0
11598 {sfi|subfic} %3,%1,0\;{ae.|adde.} %0,%3,%1
11599 {xoril|xori} %0,%1,%b2\;{sfi|subfic} %3,%0,0\;{ae.|adde.} %0,%3,%0
11600 {xoriu|xoris} %0,%1,%u2\;{sfi|subfic} %3,%0,0\;{ae.|adde.} %0,%3,%0
9ebbca7d
GK
11601 {sfi|subfic} %0,%1,%2\;{sfi|subfic} %3,%0,0\;{ae.|adde.} %0,%3,%0
11602 #
11603 #
11604 #
11605 #
11606 #"
b19003d8 11607 [(set_attr "type" "compare")
9ebbca7d
GK
11608 (set_attr "length" "12,8,12,12,12,16,12,16,16,16")])
11609
11610(define_split
11611 [(set (match_operand:CC 4 "cc_reg_not_cr0_operand" "")
11612 (compare:CC
11613 (eq:SI (match_operand:SI 1 "gpc_reg_operand" "")
11614 (match_operand:SI 2 "reg_or_cint_operand" ""))
11615 (const_int 0)))
11616 (set (match_operand:SI 0 "gpc_reg_operand" "")
11617 (eq:SI (match_dup 1) (match_dup 2)))
11618 (clobber (match_scratch:SI 3 ""))]
683bdff7 11619 "TARGET_32BIT && reload_completed"
9ebbca7d
GK
11620 [(parallel [(set (match_dup 0)
11621 (eq:SI (match_dup 1) (match_dup 2)))
11622 (clobber (match_dup 3))])
11623 (set (match_dup 4)
11624 (compare:CC (match_dup 0)
11625 (const_int 0)))]
11626 "")
b19003d8 11627
a260abc9 11628(define_insn ""
9ebbca7d 11629 [(set (match_operand:CC 4 "cc_reg_operand" "=x,x,x,x,x,?y,?y,?y,?y,?y")
a260abc9 11630 (compare:CC
9ebbca7d
GK
11631 (eq:DI (match_operand:DI 1 "gpc_reg_operand" "%r,r,r,r,r,r,r,r,r,r")
11632 (match_operand:DI 2 "reg_or_cint_operand" "r,O,K,J,I,r,O,K,J,I"))
a260abc9 11633 (const_int 0)))
9ebbca7d 11634 (set (match_operand:DI 0 "gpc_reg_operand" "=r,r,r,r,r,r,r,r,r,r")
a260abc9 11635 (eq:DI (match_dup 1) (match_dup 2)))
9ebbca7d 11636 (clobber (match_scratch:DI 3 "=r,&r,r,r,r,r,&r,r,r,r"))]
683bdff7 11637 "TARGET_64BIT"
a260abc9
DE
11638 "@
11639 xor %0,%1,%2\;subfic %3,%0,0\;adde. %0,%3,%0
11640 subfic %3,%1,0\;adde. %0,%3,%1
11641 xori %0,%1,%b2\;subfic %3,%0,0\;adde. %0,%3,%0
11642 xoris %0,%1,%u2\;subfic %3,%0,0\;adde. %0,%3,%0
9ebbca7d
GK
11643 subfic %0,%1,%2\;subfic %3,%0,0\;adde. %0,%3,%0
11644 #
11645 #
11646 #
11647 #
11648 #"
a260abc9 11649 [(set_attr "type" "compare")
9ebbca7d
GK
11650 (set_attr "length" "12,8,12,12,12,16,12,16,16,16")])
11651
11652(define_split
11653 [(set (match_operand:CC 4 "cc_reg_not_cr0_operand" "")
11654 (compare:CC
11655 (eq:DI (match_operand:DI 1 "gpc_reg_operand" "")
11656 (match_operand:DI 2 "reg_or_cint_operand" ""))
11657 (const_int 0)))
11658 (set (match_operand:DI 0 "gpc_reg_operand" "")
11659 (eq:DI (match_dup 1) (match_dup 2)))
11660 (clobber (match_scratch:DI 3 ""))]
683bdff7 11661 "TARGET_64BIT && reload_completed"
9ebbca7d
GK
11662 [(parallel [(set (match_dup 0)
11663 (eq:DI (match_dup 1) (match_dup 2)))
11664 (clobber (match_dup 3))])
11665 (set (match_dup 4)
11666 (compare:CC (match_dup 0)
11667 (const_int 0)))]
11668 "")
a260abc9 11669
b19003d8
RK
11670;; We have insns of the form shown by the first define_insn below. If
11671;; there is something inside the comparison operation, we must split it.
11672(define_split
11673 [(set (match_operand:SI 0 "gpc_reg_operand" "")
11674 (plus:SI (match_operator 1 "comparison_operator"
11675 [(match_operand:SI 2 "" "")
11676 (match_operand:SI 3
11677 "reg_or_cint_operand" "")])
11678 (match_operand:SI 4 "gpc_reg_operand" "")))
11679 (clobber (match_operand:SI 5 "register_operand" ""))]
11680 "! gpc_reg_operand (operands[2], SImode)"
11681 [(set (match_dup 5) (match_dup 2))
11682 (set (match_dup 2) (plus:SI (match_op_dup 1 [(match_dup 2) (match_dup 3)])
11683 (match_dup 4)))])
1fd4e8c1
RK
11684
11685(define_insn ""
5276df18 11686 [(set (match_operand:SI 0 "gpc_reg_operand" "=&r,&r,&r,&r,&r")
cd2b37d9 11687 (plus:SI (eq:SI (match_operand:SI 1 "gpc_reg_operand" "%r,r,r,r,r")
5f59ecb7 11688 (match_operand:SI 2 "reg_or_cint_operand" "r,O,K,L,I"))
5276df18 11689 (match_operand:SI 3 "gpc_reg_operand" "r,r,r,r,r")))]
683bdff7 11690 "TARGET_32BIT"
1fd4e8c1 11691 "@
5276df18
DE
11692 xor %0,%1,%2\;{sfi|subfic} %0,%0,0\;{aze|addze} %0,%3
11693 {sfi|subfic} %0,%1,0\;{aze|addze} %0,%3
11694 {xoril|xori} %0,%1,%b2\;{sfi|subfic} %0,%0,0\;{aze|addze} %0,%3
11695 {xoriu|xoris} %0,%1,%u2\;{sfi|subfic} %0,%0,0\;{aze|addze} %0,%3
11696 {sfi|subfic} %0,%1,%2\;{sfi|subfic} %0,%0,0\;{aze|addze} %0,%3"
b19003d8 11697 [(set_attr "length" "12,8,12,12,12")])
1fd4e8c1
RK
11698
11699(define_insn ""
9ebbca7d 11700 [(set (match_operand:CC 0 "cc_reg_operand" "=x,x,x,x,x,?y,?y,?y,?y,?y")
7e69e155 11701 (compare:CC
1fd4e8c1 11702 (plus:SI
9ebbca7d
GK
11703 (eq:SI (match_operand:SI 1 "gpc_reg_operand" "%r,r,r,r,r,r,r,r,r,r")
11704 (match_operand:SI 2 "reg_or_cint_operand" "r,O,K,L,I,r,O,K,L,I"))
11705 (match_operand:SI 3 "gpc_reg_operand" "r,r,r,r,r,r,r,r,r,r"))
1fd4e8c1 11706 (const_int 0)))
9ebbca7d 11707 (clobber (match_scratch:SI 4 "=&r,&r,&r,&r,&r,&r,&r,&r,&r,&r"))]
683bdff7 11708 "TARGET_32BIT"
1fd4e8c1 11709 "@
ca7f5001 11710 xor %4,%1,%2\;{sfi|subfic} %4,%4,0\;{aze.|addze.} %4,%3
19378cf8 11711 {sfi|subfic} %4,%1,0\;{aze.|addze.} %4,%3
ca7f5001
RK
11712 {xoril|xori} %4,%1,%b2\;{sfi|subfic} %4,%4,0\;{aze.|addze.} %4,%3
11713 {xoriu|xoris} %4,%1,%u2\;{sfi|subfic} %4,%4,0\;{aze.|addze.} %4,%3
9ebbca7d
GK
11714 {sfi|subfic} %4,%1,%2\;{sfi|subfic} %4,%4,0\;{aze.|addze.} %4,%3
11715 #
11716 #
11717 #
11718 #
11719 #"
b19003d8 11720 [(set_attr "type" "compare")
9ebbca7d
GK
11721 (set_attr "length" "12,8,12,12,12,16,12,16,16,16")])
11722
11723(define_split
11724 [(set (match_operand:CC 0 "cc_reg_not_cr0_operand" "")
11725 (compare:CC
11726 (plus:SI
11727 (eq:SI (match_operand:SI 1 "gpc_reg_operand" "")
11728 (match_operand:SI 2 "reg_or_cint_operand" ""))
11729 (match_operand:SI 3 "gpc_reg_operand" ""))
11730 (const_int 0)))
11731 (clobber (match_scratch:SI 4 ""))]
683bdff7 11732 "TARGET_32BIT && reload_completed"
9ebbca7d
GK
11733 [(set (match_dup 4)
11734 (plus:SI (eq:SI (match_dup 1)
11735 (match_dup 2))
11736 (match_dup 3)))
11737 (set (match_dup 0)
11738 (compare:CC (match_dup 4)
11739 (const_int 0)))]
11740 "")
1fd4e8c1
RK
11741
11742(define_insn ""
0387639b 11743 [(set (match_operand:CC 4 "cc_reg_operand" "=x,x,x,x,x,?y,?y,?y,?y,?y")
7e69e155 11744 (compare:CC
1fd4e8c1 11745 (plus:SI
9ebbca7d
GK
11746 (eq:SI (match_operand:SI 1 "gpc_reg_operand" "%r,r,r,r,r,r,r,r,r,r")
11747 (match_operand:SI 2 "reg_or_cint_operand" "r,O,K,L,I,r,O,K,L,I"))
11748 (match_operand:SI 3 "gpc_reg_operand" "r,r,r,r,r,r,r,r,r,r"))
1fd4e8c1 11749 (const_int 0)))
0387639b
DE
11750 (set (match_operand:SI 0 "gpc_reg_operand" "=&r,&r,&r,&r,&r,&r,&r,&r,&r,&r")
11751 (plus:SI (eq:SI (match_dup 1) (match_dup 2)) (match_dup 3)))]
683bdff7 11752 "TARGET_32BIT"
1fd4e8c1 11753 "@
0387639b
DE
11754 xor %0,%1,%2\;{sfi|subfic} %0,%0,0\;{aze.|addze.} %0,%3
11755 {sfi|subfic} %0,%1,0\;{aze.|addze.} %0,%3
11756 {xoril|xori} %0,%1,%b2\;{sfi|subfic} %0,%0,0\;{aze.|addze.} %0,%3
11757 {xoriu|xoris} %0,%1,%u2\;{sfi|subfic} %0,%0,0\;{aze.|addze.} %0,%3
11758 {sfi|subfic} %0,%1,%2\;{sfi|subfic} %0,%0,0\;{aze.|addze.} %0,%3
9ebbca7d
GK
11759 #
11760 #
11761 #
11762 #
11763 #"
11764 [(set_attr "type" "compare")
11765 (set_attr "length" "12,8,12,12,12,16,12,16,16,16")])
11766
11767(define_split
0387639b 11768 [(set (match_operand:CC 4 "cc_reg_not_cr0_operand" "")
9ebbca7d
GK
11769 (compare:CC
11770 (plus:SI
11771 (eq:SI (match_operand:SI 1 "gpc_reg_operand" "")
11772 (match_operand:SI 2 "reg_or_cint_operand" ""))
11773 (match_operand:SI 3 "gpc_reg_operand" ""))
11774 (const_int 0)))
11775 (set (match_operand:SI 0 "gpc_reg_operand" "")
0387639b 11776 (plus:SI (eq:SI (match_dup 1) (match_dup 2)) (match_dup 3)))]
683bdff7 11777 "TARGET_32BIT && reload_completed"
0387639b 11778 [(set (match_dup 0)
9ebbca7d 11779 (plus:SI (eq:SI (match_dup 1) (match_dup 2)) (match_dup 3)))
0387639b 11780 (set (match_dup 4)
9ebbca7d
GK
11781 (compare:CC (match_dup 0)
11782 (const_int 0)))]
11783 "")
11784
1fd4e8c1 11785(define_insn ""
cd2b37d9 11786 [(set (match_operand:SI 0 "gpc_reg_operand" "=r,r,r,r,r")
deb9225a 11787 (neg:SI (eq:SI (match_operand:SI 1 "gpc_reg_operand" "%r,r,r,r,r")
5f59ecb7 11788 (match_operand:SI 2 "reg_or_cint_operand" "r,O,K,L,I"))))]
683bdff7 11789 "TARGET_32BIT"
1fd4e8c1 11790 "@
ca7f5001
RK
11791 xor %0,%1,%2\;{ai|addic} %0,%0,-1\;{sfe|subfe} %0,%0,%0
11792 {ai|addic} %0,%1,-1\;{sfe|subfe} %0,%0,%0
11793 {xoril|xori} %0,%1,%b2\;{ai|addic} %0,%0,-1\;{sfe|subfe} %0,%0,%0
11794 {xoriu|xoris} %0,%1,%u2\;{ai|addic} %0,%0,-1\;{sfe|subfe} %0,%0,%0
11795 {sfi|subfic} %0,%1,%2\;{ai|addic} %0,%0,-1\;{sfe|subfe} %0,%0,%0"
b19003d8 11796 [(set_attr "length" "12,8,12,12,12")])
1fd4e8c1 11797
ea9be077
MM
11798;; Simplify (ne X (const_int 0)) on the PowerPC. No need to on the Power,
11799;; since it nabs/sr is just as fast.
463b558b 11800(define_insn "*ne0"
b4e95693 11801 [(set (match_operand:SI 0 "gpc_reg_operand" "=&r")
ea9be077
MM
11802 (lshiftrt:SI (neg:SI (abs:SI (match_operand:SI 1 "gpc_reg_operand" "r")))
11803 (const_int 31)))
11804 (clobber (match_scratch:SI 2 "=&r"))]
683bdff7 11805 "! TARGET_POWER && TARGET_32BIT && !TARGET_ISEL"
ea9be077
MM
11806 "{ai|addic} %2,%1,-1\;{sfe|subfe} %0,%2,%1"
11807 [(set_attr "length" "8")])
11808
a260abc9
DE
11809(define_insn ""
11810 [(set (match_operand:DI 0 "gpc_reg_operand" "=r")
11811 (lshiftrt:DI (neg:DI (abs:DI (match_operand:DI 1 "gpc_reg_operand" "r")))
11812 (const_int 63)))
11813 (clobber (match_scratch:DI 2 "=&r"))]
683bdff7 11814 "TARGET_64BIT"
a260abc9
DE
11815 "addic %2,%1,-1\;subfe %0,%2,%1"
11816 [(set_attr "length" "8")])
11817
1fd4e8c1
RK
11818;; This is what (plus (ne X (const_int 0)) Y) looks like.
11819(define_insn ""
cd2b37d9 11820 [(set (match_operand:SI 0 "gpc_reg_operand" "=r")
1fd4e8c1 11821 (plus:SI (lshiftrt:SI
cd2b37d9 11822 (neg:SI (abs:SI (match_operand:SI 1 "gpc_reg_operand" "r")))
1fd4e8c1 11823 (const_int 31))
cd2b37d9 11824 (match_operand:SI 2 "gpc_reg_operand" "r")))
1fd4e8c1 11825 (clobber (match_scratch:SI 3 "=&r"))]
683bdff7 11826 "TARGET_32BIT"
ca7f5001 11827 "{ai|addic} %3,%1,-1\;{aze|addze} %0,%2"
b19003d8 11828 [(set_attr "length" "8")])
1fd4e8c1 11829
a260abc9
DE
11830(define_insn ""
11831 [(set (match_operand:DI 0 "gpc_reg_operand" "=r")
11832 (plus:DI (lshiftrt:DI
11833 (neg:DI (abs:DI (match_operand:DI 1 "gpc_reg_operand" "r")))
11834 (const_int 63))
11835 (match_operand:DI 2 "gpc_reg_operand" "r")))
11836 (clobber (match_scratch:DI 3 "=&r"))]
683bdff7 11837 "TARGET_64BIT"
a260abc9
DE
11838 "addic %3,%1,-1\;addze %0,%2"
11839 [(set_attr "length" "8")])
11840
1fd4e8c1 11841(define_insn ""
9ebbca7d 11842 [(set (match_operand:CC 0 "cc_reg_operand" "=x,?y")
1fd4e8c1
RK
11843 (compare:CC
11844 (plus:SI (lshiftrt:SI
9ebbca7d 11845 (neg:SI (abs:SI (match_operand:SI 1 "gpc_reg_operand" "r,r")))
1fd4e8c1 11846 (const_int 31))
9ebbca7d 11847 (match_operand:SI 2 "gpc_reg_operand" "r,r"))
1fd4e8c1 11848 (const_int 0)))
889b90a1
GK
11849 (clobber (match_scratch:SI 3 "=&r,&r"))
11850 (clobber (match_scratch:SI 4 "=X,&r"))]
683bdff7 11851 "TARGET_32BIT"
9ebbca7d
GK
11852 "@
11853 {ai|addic} %3,%1,-1\;{aze.|addze.} %3,%2
11854 #"
b19003d8 11855 [(set_attr "type" "compare")
9ebbca7d
GK
11856 (set_attr "length" "8,12")])
11857
11858(define_split
11859 [(set (match_operand:CC 0 "cc_reg_not_cr0_operand" "")
11860 (compare:CC
11861 (plus:SI (lshiftrt:SI
11862 (neg:SI (abs:SI (match_operand:SI 1 "gpc_reg_operand" "")))
11863 (const_int 31))
11864 (match_operand:SI 2 "gpc_reg_operand" ""))
11865 (const_int 0)))
889b90a1
GK
11866 (clobber (match_scratch:SI 3 ""))
11867 (clobber (match_scratch:SI 4 ""))]
683bdff7 11868 "TARGET_32BIT && reload_completed"
889b90a1 11869 [(parallel [(set (match_dup 3)
ce71f754
AM
11870 (plus:SI (lshiftrt:SI (neg:SI (abs:SI (match_dup 1)))
11871 (const_int 31))
11872 (match_dup 2)))
889b90a1 11873 (clobber (match_dup 4))])
9ebbca7d
GK
11874 (set (match_dup 0)
11875 (compare:CC (match_dup 3)
11876 (const_int 0)))]
11877 "")
1fd4e8c1 11878
a260abc9 11879(define_insn ""
9ebbca7d 11880 [(set (match_operand:CC 0 "cc_reg_operand" "=x,?y")
a260abc9
DE
11881 (compare:CC
11882 (plus:DI (lshiftrt:DI
9ebbca7d 11883 (neg:DI (abs:DI (match_operand:DI 1 "gpc_reg_operand" "r,r")))
a260abc9 11884 (const_int 63))
9ebbca7d 11885 (match_operand:DI 2 "gpc_reg_operand" "r,r"))
a260abc9 11886 (const_int 0)))
9ebbca7d 11887 (clobber (match_scratch:DI 3 "=&r,&r"))]
683bdff7 11888 "TARGET_64BIT"
9ebbca7d
GK
11889 "@
11890 addic %3,%1,-1\;addze. %3,%2
11891 #"
a260abc9 11892 [(set_attr "type" "compare")
9ebbca7d
GK
11893 (set_attr "length" "8,12")])
11894
11895(define_split
11896 [(set (match_operand:CC 0 "cc_reg_not_cr0_operand" "")
11897 (compare:CC
11898 (plus:DI (lshiftrt:DI
11899 (neg:DI (abs:DI (match_operand:DI 1 "gpc_reg_operand" "")))
11900 (const_int 63))
11901 (match_operand:DI 2 "gpc_reg_operand" ""))
11902 (const_int 0)))
11903 (clobber (match_scratch:DI 3 ""))]
683bdff7 11904 "TARGET_64BIT && reload_completed"
9ebbca7d
GK
11905 [(set (match_dup 3)
11906 (plus:DI (lshiftrt:DI (neg:DI (abs:DI (match_dup 1)))
11907 (const_int 63))
11908 (match_dup 2)))
11909 (set (match_dup 0)
11910 (compare:CC (match_dup 3)
11911 (const_int 0)))]
11912 "")
a260abc9 11913
1fd4e8c1 11914(define_insn ""
9ebbca7d 11915 [(set (match_operand:CC 4 "cc_reg_operand" "=x,?y")
1fd4e8c1
RK
11916 (compare:CC
11917 (plus:SI (lshiftrt:SI
9ebbca7d 11918 (neg:SI (abs:SI (match_operand:SI 1 "gpc_reg_operand" "r,r")))
1fd4e8c1 11919 (const_int 31))
9ebbca7d 11920 (match_operand:SI 2 "gpc_reg_operand" "r,r"))
1fd4e8c1 11921 (const_int 0)))
9ebbca7d 11922 (set (match_operand:SI 0 "gpc_reg_operand" "=r,r")
1fd4e8c1
RK
11923 (plus:SI (lshiftrt:SI (neg:SI (abs:SI (match_dup 1))) (const_int 31))
11924 (match_dup 2)))
9ebbca7d 11925 (clobber (match_scratch:SI 3 "=&r,&r"))]
683bdff7 11926 "TARGET_32BIT"
9ebbca7d
GK
11927 "@
11928 {ai|addic} %3,%1,-1\;{aze.|addze.} %0,%2
11929 #"
b19003d8 11930 [(set_attr "type" "compare")
9ebbca7d
GK
11931 (set_attr "length" "8,12")])
11932
11933(define_split
11934 [(set (match_operand:CC 4 "cc_reg_not_cr0_operand" "")
11935 (compare:CC
11936 (plus:SI (lshiftrt:SI
11937 (neg:SI (abs:SI (match_operand:SI 1 "gpc_reg_operand" "")))
11938 (const_int 31))
11939 (match_operand:SI 2 "gpc_reg_operand" ""))
11940 (const_int 0)))
11941 (set (match_operand:SI 0 "gpc_reg_operand" "")
11942 (plus:SI (lshiftrt:SI (neg:SI (abs:SI (match_dup 1))) (const_int 31))
11943 (match_dup 2)))
11944 (clobber (match_scratch:SI 3 ""))]
683bdff7 11945 "TARGET_32BIT && reload_completed"
9ebbca7d
GK
11946 [(parallel [(set (match_dup 0)
11947 (plus:SI (lshiftrt:SI (neg:SI (abs:SI (match_dup 1))) (const_int 31))
11948 (match_dup 2)))
11949 (clobber (match_dup 3))])
11950 (set (match_dup 4)
11951 (compare:CC (match_dup 0)
11952 (const_int 0)))]
11953 "")
1fd4e8c1 11954
a260abc9 11955(define_insn ""
9ebbca7d 11956 [(set (match_operand:CC 4 "cc_reg_operand" "=x,?y")
a260abc9
DE
11957 (compare:CC
11958 (plus:DI (lshiftrt:DI
9ebbca7d 11959 (neg:DI (abs:DI (match_operand:DI 1 "gpc_reg_operand" "r,r")))
a260abc9 11960 (const_int 63))
9ebbca7d 11961 (match_operand:DI 2 "gpc_reg_operand" "r,r"))
a260abc9 11962 (const_int 0)))
9ebbca7d 11963 (set (match_operand:DI 0 "gpc_reg_operand" "=r,r")
a260abc9
DE
11964 (plus:DI (lshiftrt:DI (neg:DI (abs:DI (match_dup 1))) (const_int 63))
11965 (match_dup 2)))
9ebbca7d 11966 (clobber (match_scratch:DI 3 "=&r,&r"))]
683bdff7 11967 "TARGET_64BIT"
9ebbca7d
GK
11968 "@
11969 addic %3,%1,-1\;addze. %0,%2
11970 #"
a260abc9 11971 [(set_attr "type" "compare")
9ebbca7d
GK
11972 (set_attr "length" "8,12")])
11973
11974(define_split
11975 [(set (match_operand:CC 4 "cc_reg_not_cr0_operand" "")
11976 (compare:CC
11977 (plus:DI (lshiftrt:DI
11978 (neg:DI (abs:DI (match_operand:DI 1 "gpc_reg_operand" "")))
11979 (const_int 63))
11980 (match_operand:DI 2 "gpc_reg_operand" ""))
11981 (const_int 0)))
11982 (set (match_operand:DI 0 "gpc_reg_operand" "")
11983 (plus:DI (lshiftrt:DI (neg:DI (abs:DI (match_dup 1))) (const_int 63))
11984 (match_dup 2)))
11985 (clobber (match_scratch:DI 3 ""))]
683bdff7 11986 "TARGET_64BIT && reload_completed"
9ebbca7d
GK
11987 [(parallel [(set (match_dup 0)
11988 (plus:DI (lshiftrt:DI (neg:DI (abs:DI (match_dup 1))) (const_int 63))
11989 (match_dup 2)))
11990 (clobber (match_dup 3))])
11991 (set (match_dup 4)
11992 (compare:CC (match_dup 0)
11993 (const_int 0)))]
11994 "")
a260abc9 11995
1fd4e8c1 11996(define_insn ""
cd2b37d9
RK
11997 [(set (match_operand:SI 0 "gpc_reg_operand" "=r,r")
11998 (le:SI (match_operand:SI 1 "gpc_reg_operand" "r,r")
1fd4e8c1
RK
11999 (match_operand:SI 2 "reg_or_short_operand" "r,O")))
12000 (clobber (match_scratch:SI 3 "=r,X"))]
ca7f5001 12001 "TARGET_POWER"
1fd4e8c1 12002 "@
ca7f5001 12003 doz %3,%2,%1\;{sfi|subfic} %0,%3,0\;{ae|adde} %0,%0,%3
7f340546 12004 {ai|addic} %0,%1,-1\;{aze|addze} %0,%0\;{sri|srwi} %0,%0,31"
b19003d8 12005 [(set_attr "length" "12")])
1fd4e8c1
RK
12006
12007(define_insn ""
9ebbca7d 12008 [(set (match_operand:CC 4 "cc_reg_operand" "=x,x,?y,?y")
1fd4e8c1 12009 (compare:CC
9ebbca7d
GK
12010 (le:SI (match_operand:SI 1 "gpc_reg_operand" "r,r,r,r")
12011 (match_operand:SI 2 "reg_or_short_operand" "r,O,r,O"))
1fd4e8c1 12012 (const_int 0)))
9ebbca7d 12013 (set (match_operand:SI 0 "gpc_reg_operand" "=r,r,r,r")
1fd4e8c1 12014 (le:SI (match_dup 1) (match_dup 2)))
9ebbca7d 12015 (clobber (match_scratch:SI 3 "=r,X,r,X"))]
ca7f5001 12016 "TARGET_POWER"
1fd4e8c1 12017 "@
ca7f5001 12018 doz %3,%2,%1\;{sfi|subfic} %0,%3,0\;{ae.|adde.} %0,%0,%3
9ebbca7d
GK
12019 {ai|addic} %0,%1,-1\;{aze|addze} %0,%0\;{sri.|srwi.} %0,%0,31
12020 #
12021 #"
12022 [(set_attr "type" "compare,delayed_compare,compare,delayed_compare")
12023 (set_attr "length" "12,12,16,16")])
12024
12025(define_split
12026 [(set (match_operand:CC 4 "cc_reg_not_cr0_operand" "")
12027 (compare:CC
12028 (le:SI (match_operand:SI 1 "gpc_reg_operand" "")
12029 (match_operand:SI 2 "reg_or_short_operand" ""))
12030 (const_int 0)))
12031 (set (match_operand:SI 0 "gpc_reg_operand" "")
12032 (le:SI (match_dup 1) (match_dup 2)))
12033 (clobber (match_scratch:SI 3 ""))]
12034 "TARGET_POWER && reload_completed"
12035 [(parallel [(set (match_dup 0)
12036 (le:SI (match_dup 1) (match_dup 2)))
12037 (clobber (match_dup 3))])
12038 (set (match_dup 4)
12039 (compare:CC (match_dup 0)
12040 (const_int 0)))]
12041 "")
1fd4e8c1
RK
12042
12043(define_insn ""
097657c3 12044 [(set (match_operand:SI 0 "gpc_reg_operand" "=&r,&r")
cd2b37d9 12045 (plus:SI (le:SI (match_operand:SI 1 "gpc_reg_operand" "r,r")
1fd4e8c1 12046 (match_operand:SI 2 "reg_or_short_operand" "r,O"))
097657c3 12047 (match_operand:SI 3 "gpc_reg_operand" "r,r")))]
ca7f5001 12048 "TARGET_POWER"
1fd4e8c1 12049 "@
097657c3
AM
12050 doz %0,%2,%1\;{sfi|subfic} %0,%0,0\;{aze|addze} %0,%3
12051 {srai|srawi} %0,%1,31\;{sf|subfc} %0,%1,%0\;{aze|addze} %0,%3"
b19003d8 12052 [(set_attr "length" "12")])
1fd4e8c1
RK
12053
12054(define_insn ""
9ebbca7d 12055 [(set (match_operand:CC 0 "cc_reg_operand" "=x,x,?y,?y")
1fd4e8c1 12056 (compare:CC
9ebbca7d
GK
12057 (plus:SI (le:SI (match_operand:SI 1 "gpc_reg_operand" "r,r,r,r")
12058 (match_operand:SI 2 "reg_or_short_operand" "r,O,r,O"))
12059 (match_operand:SI 3 "gpc_reg_operand" "r,r,r,r"))
1fd4e8c1 12060 (const_int 0)))
9ebbca7d 12061 (clobber (match_scratch:SI 4 "=&r,&r,&r,&r"))]
ca7f5001 12062 "TARGET_POWER"
1fd4e8c1 12063 "@
ca7f5001 12064 doz %4,%2,%1\;{sfi|subfic} %4,%4,0\;{aze.|addze.} %4,%3
9ebbca7d
GK
12065 {srai|srawi} %4,%1,31\;{sf|subfc} %4,%1,%4\;{aze.|addze.} %4,%3
12066 #
12067 #"
b19003d8 12068 [(set_attr "type" "compare")
9ebbca7d
GK
12069 (set_attr "length" "12,12,16,16")])
12070
12071(define_split
12072 [(set (match_operand:CC 0 "cc_reg_not_cr0_operand" "")
12073 (compare:CC
12074 (plus:SI (le:SI (match_operand:SI 1 "gpc_reg_operand" "")
12075 (match_operand:SI 2 "reg_or_short_operand" ""))
12076 (match_operand:SI 3 "gpc_reg_operand" ""))
12077 (const_int 0)))
12078 (clobber (match_scratch:SI 4 ""))]
12079 "TARGET_POWER && reload_completed"
12080 [(set (match_dup 4)
12081 (plus:SI (le:SI (match_dup 1) (match_dup 2))
097657c3 12082 (match_dup 3)))
9ebbca7d
GK
12083 (set (match_dup 0)
12084 (compare:CC (match_dup 4)
12085 (const_int 0)))]
12086 "")
1fd4e8c1
RK
12087
12088(define_insn ""
097657c3 12089 [(set (match_operand:CC 4 "cc_reg_operand" "=x,x,?y,?y")
1fd4e8c1 12090 (compare:CC
9ebbca7d
GK
12091 (plus:SI (le:SI (match_operand:SI 1 "gpc_reg_operand" "r,r,r,r")
12092 (match_operand:SI 2 "reg_or_short_operand" "r,O,r,O"))
12093 (match_operand:SI 3 "gpc_reg_operand" "r,r,r,r"))
1fd4e8c1 12094 (const_int 0)))
097657c3
AM
12095 (set (match_operand:SI 0 "gpc_reg_operand" "=&r,&r,&r,&r")
12096 (plus:SI (le:SI (match_dup 1) (match_dup 2)) (match_dup 3)))]
ca7f5001 12097 "TARGET_POWER"
1fd4e8c1 12098 "@
097657c3
AM
12099 doz %0,%2,%1\;{sfi|subfic} %0,%0,0\;{aze.|addze.} %0,%3
12100 {srai|srawi} %0,%1,31\;{sf|subfc} %0,%1,%0\;{aze.|addze.} %0,%3
9ebbca7d
GK
12101 #
12102 #"
b19003d8 12103 [(set_attr "type" "compare")
9ebbca7d
GK
12104 (set_attr "length" "12,12,16,16")])
12105
12106(define_split
097657c3 12107 [(set (match_operand:CC 4 "cc_reg_not_cr0_operand" "")
9ebbca7d
GK
12108 (compare:CC
12109 (plus:SI (le:SI (match_operand:SI 1 "gpc_reg_operand" "")
12110 (match_operand:SI 2 "reg_or_short_operand" ""))
12111 (match_operand:SI 3 "gpc_reg_operand" ""))
12112 (const_int 0)))
12113 (set (match_operand:SI 0 "gpc_reg_operand" "")
097657c3 12114 (plus:SI (le:SI (match_dup 1) (match_dup 2)) (match_dup 3)))]
9ebbca7d 12115 "TARGET_POWER && reload_completed"
097657c3 12116 [(set (match_dup 0)
9ebbca7d 12117 (plus:SI (le:SI (match_dup 1) (match_dup 2)) (match_dup 3)))
097657c3 12118 (set (match_dup 4)
9ebbca7d
GK
12119 (compare:CC (match_dup 0)
12120 (const_int 0)))]
12121 "")
1fd4e8c1
RK
12122
12123(define_insn ""
cd2b37d9
RK
12124 [(set (match_operand:SI 0 "gpc_reg_operand" "=r,r")
12125 (neg:SI (le:SI (match_operand:SI 1 "gpc_reg_operand" "r,r")
1fd4e8c1 12126 (match_operand:SI 2 "reg_or_short_operand" "r,O"))))]
ca7f5001 12127 "TARGET_POWER"
1fd4e8c1 12128 "@
ca7f5001
RK
12129 doz %0,%2,%1\;{ai|addic} %0,%0,-1\;{sfe|subfe} %0,%0,%0
12130 {ai|addic} %0,%1,-1\;{aze|addze} %0,%0\;{srai|srawi} %0,%0,31"
b19003d8 12131 [(set_attr "length" "12")])
1fd4e8c1
RK
12132
12133(define_insn ""
cd2b37d9
RK
12134 [(set (match_operand:SI 0 "gpc_reg_operand" "=r")
12135 (leu:SI (match_operand:SI 1 "gpc_reg_operand" "r")
1fd4e8c1 12136 (match_operand:SI 2 "reg_or_short_operand" "rI")))]
f9562f27 12137 "! TARGET_POWERPC64"
ca7f5001 12138 "{sf%I2|subf%I2c} %0,%1,%2\;{cal %0,0(0)|li %0,0}\;{ae|adde} %0,%0,%0"
b19003d8 12139 [(set_attr "length" "12")])
1fd4e8c1 12140
f9562f27
DE
12141(define_insn ""
12142 [(set (match_operand:DI 0 "gpc_reg_operand" "=r")
12143 (leu:DI (match_operand:DI 1 "gpc_reg_operand" "r")
12144 (match_operand:DI 2 "reg_or_short_operand" "rI")))]
683bdff7 12145 "TARGET_64BIT"
f9562f27
DE
12146 "subf%I2c %0,%1,%2\;li %0,0\;adde %0,%0,%0"
12147 [(set_attr "length" "12")])
12148
12149(define_insn ""
9ebbca7d 12150 [(set (match_operand:CC 3 "cc_reg_operand" "=x,?y")
f9562f27 12151 (compare:CC
9ebbca7d
GK
12152 (leu:DI (match_operand:DI 1 "gpc_reg_operand" "r,r")
12153 (match_operand:DI 2 "reg_or_short_operand" "rI,rI"))
f9562f27 12154 (const_int 0)))
9ebbca7d 12155 (set (match_operand:DI 0 "gpc_reg_operand" "=r,r")
f9562f27 12156 (leu:DI (match_dup 1) (match_dup 2)))]
683bdff7 12157 "TARGET_64BIT"
9ebbca7d
GK
12158 "@
12159 subf%I2c %0,%1,%2\;li %0,0\;adde. %0,%0,%0
12160 #"
f9562f27 12161 [(set_attr "type" "compare")
9ebbca7d
GK
12162 (set_attr "length" "12,16")])
12163
12164(define_split
12165 [(set (match_operand:CC 3 "cc_reg_not_cr0_operand" "")
12166 (compare:CC
12167 (leu:DI (match_operand:DI 1 "gpc_reg_operand" "")
12168 (match_operand:DI 2 "reg_or_short_operand" ""))
12169 (const_int 0)))
12170 (set (match_operand:DI 0 "gpc_reg_operand" "")
12171 (leu:DI (match_dup 1) (match_dup 2)))]
683bdff7 12172 "TARGET_64BIT && reload_completed"
9ebbca7d
GK
12173 [(set (match_dup 0)
12174 (leu:DI (match_dup 1) (match_dup 2)))
12175 (set (match_dup 3)
12176 (compare:CC (match_dup 0)
12177 (const_int 0)))]
12178 "")
f9562f27 12179
1fd4e8c1 12180(define_insn ""
9ebbca7d 12181 [(set (match_operand:CC 3 "cc_reg_operand" "=x,?y")
1fd4e8c1 12182 (compare:CC
9ebbca7d
GK
12183 (leu:SI (match_operand:SI 1 "gpc_reg_operand" "r,r")
12184 (match_operand:SI 2 "reg_or_short_operand" "rI,rI"))
1fd4e8c1 12185 (const_int 0)))
9ebbca7d 12186 (set (match_operand:SI 0 "gpc_reg_operand" "=r,r")
1fd4e8c1 12187 (leu:SI (match_dup 1) (match_dup 2)))]
683bdff7 12188 "TARGET_32BIT"
9ebbca7d
GK
12189 "@
12190 {sf%I2|subf%I2c} %0,%1,%2\;{cal %0,0(0)|li %0,0}\;{ae.|adde.} %0,%0,%0
12191 #"
b19003d8 12192 [(set_attr "type" "compare")
9ebbca7d
GK
12193 (set_attr "length" "12,16")])
12194
12195(define_split
12196 [(set (match_operand:CC 3 "cc_reg_not_cr0_operand" "")
12197 (compare:CC
12198 (leu:SI (match_operand:SI 1 "gpc_reg_operand" "")
12199 (match_operand:SI 2 "reg_or_short_operand" ""))
12200 (const_int 0)))
12201 (set (match_operand:SI 0 "gpc_reg_operand" "")
12202 (leu:SI (match_dup 1) (match_dup 2)))]
683bdff7 12203 "TARGET_32BIT && reload_completed"
9ebbca7d
GK
12204 [(set (match_dup 0)
12205 (leu:SI (match_dup 1) (match_dup 2)))
12206 (set (match_dup 3)
12207 (compare:CC (match_dup 0)
12208 (const_int 0)))]
12209 "")
1fd4e8c1
RK
12210
12211(define_insn ""
80103f96 12212 [(set (match_operand:SI 0 "gpc_reg_operand" "=&r")
cd2b37d9 12213 (plus:SI (leu:SI (match_operand:SI 1 "gpc_reg_operand" "r")
1fd4e8c1 12214 (match_operand:SI 2 "reg_or_short_operand" "rI"))
80103f96 12215 (match_operand:SI 3 "gpc_reg_operand" "r")))]
683bdff7 12216 "TARGET_32BIT"
80103f96 12217 "{sf%I2|subf%I2c} %0,%1,%2\;{aze|addze} %0,%3"
b19003d8 12218 [(set_attr "length" "8")])
1fd4e8c1
RK
12219
12220(define_insn ""
9ebbca7d 12221 [(set (match_operand:CC 0 "cc_reg_operand" "=x,?y")
1fd4e8c1 12222 (compare:CC
9ebbca7d
GK
12223 (plus:SI (leu:SI (match_operand:SI 1 "gpc_reg_operand" "r,r")
12224 (match_operand:SI 2 "reg_or_short_operand" "rI,rI"))
12225 (match_operand:SI 3 "gpc_reg_operand" "r,r"))
1fd4e8c1 12226 (const_int 0)))
9ebbca7d 12227 (clobber (match_scratch:SI 4 "=&r,&r"))]
683bdff7 12228 "TARGET_32BIT"
9ebbca7d
GK
12229 "@
12230 {sf%I2|subf%I2c} %4,%1,%2\;{aze.|addze.} %4,%3
12231 #"
b19003d8 12232 [(set_attr "type" "compare")
9ebbca7d
GK
12233 (set_attr "length" "8,12")])
12234
12235(define_split
12236 [(set (match_operand:CC 0 "cc_reg_not_cr0_operand" "")
12237 (compare:CC
12238 (plus:SI (leu:SI (match_operand:SI 1 "gpc_reg_operand" "")
12239 (match_operand:SI 2 "reg_or_short_operand" ""))
12240 (match_operand:SI 3 "gpc_reg_operand" ""))
12241 (const_int 0)))
12242 (clobber (match_scratch:SI 4 ""))]
683bdff7 12243 "TARGET_32BIT && reload_completed"
9ebbca7d
GK
12244 [(set (match_dup 4)
12245 (plus:SI (leu:SI (match_dup 1) (match_dup 2))
12246 (match_dup 3)))
12247 (set (match_dup 0)
12248 (compare:CC (match_dup 4)
12249 (const_int 0)))]
12250 "")
1fd4e8c1
RK
12251
12252(define_insn ""
097657c3 12253 [(set (match_operand:CC 4 "cc_reg_operand" "=x,?y")
1fd4e8c1 12254 (compare:CC
9ebbca7d
GK
12255 (plus:SI (leu:SI (match_operand:SI 1 "gpc_reg_operand" "r,r")
12256 (match_operand:SI 2 "reg_or_short_operand" "rI,rI"))
12257 (match_operand:SI 3 "gpc_reg_operand" "r,r"))
1fd4e8c1 12258 (const_int 0)))
097657c3
AM
12259 (set (match_operand:SI 0 "gpc_reg_operand" "=&r,&r")
12260 (plus:SI (leu:SI (match_dup 1) (match_dup 2)) (match_dup 3)))]
683bdff7 12261 "TARGET_32BIT"
9ebbca7d 12262 "@
097657c3 12263 {sf%I2|subf%I2c} %0,%1,%2\;{aze.|addze.} %0,%3
9ebbca7d 12264 #"
b19003d8 12265 [(set_attr "type" "compare")
9ebbca7d
GK
12266 (set_attr "length" "8,12")])
12267
12268(define_split
097657c3 12269 [(set (match_operand:CC 4 "cc_reg_not_cr0_operand" "")
9ebbca7d
GK
12270 (compare:CC
12271 (plus:SI (leu:SI (match_operand:SI 1 "gpc_reg_operand" "")
12272 (match_operand:SI 2 "reg_or_short_operand" ""))
12273 (match_operand:SI 3 "gpc_reg_operand" ""))
12274 (const_int 0)))
12275 (set (match_operand:SI 0 "gpc_reg_operand" "")
097657c3 12276 (plus:SI (leu:SI (match_dup 1) (match_dup 2)) (match_dup 3)))]
683bdff7 12277 "TARGET_32BIT && reload_completed"
097657c3 12278 [(set (match_dup 0)
9ebbca7d 12279 (plus:SI (leu:SI (match_dup 1) (match_dup 2)) (match_dup 3)))
097657c3 12280 (set (match_dup 4)
9ebbca7d
GK
12281 (compare:CC (match_dup 0)
12282 (const_int 0)))]
12283 "")
1fd4e8c1
RK
12284
12285(define_insn ""
cd2b37d9
RK
12286 [(set (match_operand:SI 0 "gpc_reg_operand" "=r")
12287 (neg:SI (leu:SI (match_operand:SI 1 "gpc_reg_operand" "r")
1fd4e8c1 12288 (match_operand:SI 2 "reg_or_short_operand" "rI"))))]
683bdff7 12289 "TARGET_32BIT"
ca7f5001 12290 "{sf%I2|subf%I2c} %0,%1,%2\;{sfe|subfe} %0,%0,%0\;nand %0,%0,%0"
b19003d8 12291 [(set_attr "length" "12")])
1fd4e8c1
RK
12292
12293(define_insn ""
097657c3 12294 [(set (match_operand:SI 0 "gpc_reg_operand" "=&r")
1fd4e8c1 12295 (and:SI (neg:SI
cd2b37d9 12296 (leu:SI (match_operand:SI 1 "gpc_reg_operand" "r")
1fd4e8c1 12297 (match_operand:SI 2 "reg_or_short_operand" "rI")))
097657c3 12298 (match_operand:SI 3 "gpc_reg_operand" "r")))]
683bdff7 12299 "TARGET_32BIT"
097657c3 12300 "{sf%I2|subf%I2c} %0,%1,%2\;{sfe|subfe} %0,%0,%0\;andc %0,%3,%0"
b19003d8 12301 [(set_attr "length" "12")])
1fd4e8c1
RK
12302
12303(define_insn ""
9ebbca7d 12304 [(set (match_operand:CC 0 "cc_reg_operand" "=x,?y")
1fd4e8c1
RK
12305 (compare:CC
12306 (and:SI (neg:SI
9ebbca7d
GK
12307 (leu:SI (match_operand:SI 1 "gpc_reg_operand" "r,r")
12308 (match_operand:SI 2 "reg_or_short_operand" "rI,rI")))
12309 (match_operand:SI 3 "gpc_reg_operand" "r,r"))
1fd4e8c1 12310 (const_int 0)))
9ebbca7d 12311 (clobber (match_scratch:SI 4 "=&r,&r"))]
683bdff7 12312 "TARGET_32BIT"
9ebbca7d
GK
12313 "@
12314 {sf%I2|subf%I2c} %4,%1,%2\;{sfe|subfe} %4,%4,%4\;andc. %4,%3,%4
12315 #"
12316 [(set_attr "type" "compare")
12317 (set_attr "length" "12,16")])
12318
12319(define_split
12320 [(set (match_operand:CC 0 "cc_reg_not_cr0_operand" "")
12321 (compare:CC
12322 (and:SI (neg:SI
12323 (leu:SI (match_operand:SI 1 "gpc_reg_operand" "")
12324 (match_operand:SI 2 "reg_or_short_operand" "")))
12325 (match_operand:SI 3 "gpc_reg_operand" ""))
12326 (const_int 0)))
12327 (clobber (match_scratch:SI 4 ""))]
683bdff7 12328 "TARGET_32BIT && reload_completed"
9ebbca7d 12329 [(set (match_dup 4)
097657c3
AM
12330 (and:SI (neg:SI (leu:SI (match_dup 1) (match_dup 2)))
12331 (match_dup 3)))
9ebbca7d
GK
12332 (set (match_dup 0)
12333 (compare:CC (match_dup 4)
12334 (const_int 0)))]
12335 "")
1fd4e8c1
RK
12336
12337(define_insn ""
097657c3 12338 [(set (match_operand:CC 4 "cc_reg_operand" "=x,?y")
1fd4e8c1
RK
12339 (compare:CC
12340 (and:SI (neg:SI
9ebbca7d
GK
12341 (leu:SI (match_operand:SI 1 "gpc_reg_operand" "r,r")
12342 (match_operand:SI 2 "reg_or_short_operand" "rI,rI")))
12343 (match_operand:SI 3 "gpc_reg_operand" "r,r"))
1fd4e8c1 12344 (const_int 0)))
097657c3
AM
12345 (set (match_operand:SI 0 "gpc_reg_operand" "=&r,&r")
12346 (and:SI (neg:SI (leu:SI (match_dup 1) (match_dup 2))) (match_dup 3)))]
683bdff7 12347 "TARGET_32BIT"
9ebbca7d 12348 "@
097657c3 12349 {sf%I2|subf%I2c} %0,%1,%2\;{sfe|subfe} %0,%0,%0\;andc. %0,%3,%0
9ebbca7d 12350 #"
b19003d8 12351 [(set_attr "type" "compare")
9ebbca7d
GK
12352 (set_attr "length" "12,16")])
12353
12354(define_split
097657c3 12355 [(set (match_operand:CC 4 "cc_reg_not_cr0_operand" "")
9ebbca7d
GK
12356 (compare:CC
12357 (and:SI (neg:SI
12358 (leu:SI (match_operand:SI 1 "gpc_reg_operand" "")
12359 (match_operand:SI 2 "reg_or_short_operand" "")))
12360 (match_operand:SI 3 "gpc_reg_operand" ""))
12361 (const_int 0)))
12362 (set (match_operand:SI 0 "gpc_reg_operand" "")
097657c3 12363 (and:SI (neg:SI (leu:SI (match_dup 1) (match_dup 2))) (match_dup 3)))]
683bdff7 12364 "TARGET_32BIT && reload_completed"
097657c3
AM
12365 [(set (match_dup 0)
12366 (and:SI (neg:SI (leu:SI (match_dup 1) (match_dup 2)))
12367 (match_dup 3)))
12368 (set (match_dup 4)
9ebbca7d
GK
12369 (compare:CC (match_dup 0)
12370 (const_int 0)))]
12371 "")
1fd4e8c1
RK
12372
12373(define_insn ""
cd2b37d9
RK
12374 [(set (match_operand:SI 0 "gpc_reg_operand" "=r")
12375 (lt:SI (match_operand:SI 1 "gpc_reg_operand" "r")
1fd4e8c1 12376 (match_operand:SI 2 "reg_or_short_operand" "rI")))]
ca7f5001 12377 "TARGET_POWER"
7f340546 12378 "doz%I2 %0,%1,%2\;nabs %0,%0\;{sri|srwi} %0,%0,31"
b19003d8 12379 [(set_attr "length" "12")])
1fd4e8c1
RK
12380
12381(define_insn ""
9ebbca7d 12382 [(set (match_operand:CC 3 "cc_reg_operand" "=x,?y")
1fd4e8c1 12383 (compare:CC
9ebbca7d
GK
12384 (lt:SI (match_operand:SI 1 "gpc_reg_operand" "r,r")
12385 (match_operand:SI 2 "reg_or_short_operand" "rI,rI"))
1fd4e8c1 12386 (const_int 0)))
9ebbca7d 12387 (set (match_operand:SI 0 "gpc_reg_operand" "=r,r")
1fd4e8c1 12388 (lt:SI (match_dup 1) (match_dup 2)))]
ca7f5001 12389 "TARGET_POWER"
9ebbca7d
GK
12390 "@
12391 doz%I2 %0,%1,%2\;nabs %0,%0\;{sri.|srwi.} %0,%0,31
12392 #"
29ae5b89 12393 [(set_attr "type" "delayed_compare")
9ebbca7d
GK
12394 (set_attr "length" "12,16")])
12395
12396(define_split
12397 [(set (match_operand:CC 3 "cc_reg_not_cr0_operand" "")
12398 (compare:CC
12399 (lt:SI (match_operand:SI 1 "gpc_reg_operand" "")
12400 (match_operand:SI 2 "reg_or_short_operand" ""))
12401 (const_int 0)))
12402 (set (match_operand:SI 0 "gpc_reg_operand" "")
12403 (lt:SI (match_dup 1) (match_dup 2)))]
12404 "TARGET_POWER && reload_completed"
12405 [(set (match_dup 0)
12406 (lt:SI (match_dup 1) (match_dup 2)))
12407 (set (match_dup 3)
12408 (compare:CC (match_dup 0)
12409 (const_int 0)))]
12410 "")
1fd4e8c1
RK
12411
12412(define_insn ""
097657c3 12413 [(set (match_operand:SI 0 "gpc_reg_operand" "=&r")
cd2b37d9 12414 (plus:SI (lt:SI (match_operand:SI 1 "gpc_reg_operand" "r")
1fd4e8c1 12415 (match_operand:SI 2 "reg_or_short_operand" "rI"))
097657c3 12416 (match_operand:SI 3 "gpc_reg_operand" "r")))]
ca7f5001 12417 "TARGET_POWER"
097657c3 12418 "doz%I2 %0,%1,%2\;{ai|addic} %0,%0,-1\;{aze|addze} %0,%3"
b19003d8 12419 [(set_attr "length" "12")])
1fd4e8c1
RK
12420
12421(define_insn ""
9ebbca7d 12422 [(set (match_operand:CC 0 "cc_reg_operand" "=x,?y")
1fd4e8c1 12423 (compare:CC
9ebbca7d
GK
12424 (plus:SI (lt:SI (match_operand:SI 1 "gpc_reg_operand" "r,r")
12425 (match_operand:SI 2 "reg_or_short_operand" "rI,rI"))
12426 (match_operand:SI 3 "gpc_reg_operand" "r,r"))
1fd4e8c1 12427 (const_int 0)))
9ebbca7d 12428 (clobber (match_scratch:SI 4 "=&r,&r"))]
ca7f5001 12429 "TARGET_POWER"
9ebbca7d
GK
12430 "@
12431 doz%I2 %4,%1,%2\;{ai|addic} %4,%4,-1\;{aze.|addze.} %4,%3
12432 #"
b19003d8 12433 [(set_attr "type" "compare")
9ebbca7d
GK
12434 (set_attr "length" "12,16")])
12435
12436(define_split
12437 [(set (match_operand:CC 0 "cc_reg_not_cr0_operand" "")
12438 (compare:CC
12439 (plus:SI (lt:SI (match_operand:SI 1 "gpc_reg_operand" "")
12440 (match_operand:SI 2 "reg_or_short_operand" ""))
12441 (match_operand:SI 3 "gpc_reg_operand" ""))
12442 (const_int 0)))
12443 (clobber (match_scratch:SI 4 ""))]
12444 "TARGET_POWER && reload_completed"
12445 [(set (match_dup 4)
12446 (plus:SI (lt:SI (match_dup 1) (match_dup 2))
097657c3 12447 (match_dup 3)))
9ebbca7d
GK
12448 (set (match_dup 0)
12449 (compare:CC (match_dup 4)
12450 (const_int 0)))]
12451 "")
1fd4e8c1
RK
12452
12453(define_insn ""
097657c3 12454 [(set (match_operand:CC 4 "cc_reg_operand" "=x,?y")
1fd4e8c1 12455 (compare:CC
9ebbca7d
GK
12456 (plus:SI (lt:SI (match_operand:SI 1 "gpc_reg_operand" "r,r")
12457 (match_operand:SI 2 "reg_or_short_operand" "rI,rI"))
12458 (match_operand:SI 3 "gpc_reg_operand" "r,r"))
1fd4e8c1 12459 (const_int 0)))
097657c3
AM
12460 (set (match_operand:SI 0 "gpc_reg_operand" "=&r,&r")
12461 (plus:SI (lt:SI (match_dup 1) (match_dup 2)) (match_dup 3)))]
ca7f5001 12462 "TARGET_POWER"
9ebbca7d 12463 "@
097657c3 12464 doz%I2 %0,%1,%2\;{ai|addic} %0,%0,-1\;{aze.|addze.} %0,%3
9ebbca7d 12465 #"
b19003d8 12466 [(set_attr "type" "compare")
9ebbca7d
GK
12467 (set_attr "length" "12,16")])
12468
12469(define_split
097657c3 12470 [(set (match_operand:CC 4 "cc_reg_not_cr0_operand" "")
9ebbca7d
GK
12471 (compare:CC
12472 (plus:SI (lt:SI (match_operand:SI 1 "gpc_reg_operand" "")
12473 (match_operand:SI 2 "reg_or_short_operand" ""))
12474 (match_operand:SI 3 "gpc_reg_operand" ""))
12475 (const_int 0)))
12476 (set (match_operand:SI 0 "gpc_reg_operand" "")
097657c3 12477 (plus:SI (lt:SI (match_dup 1) (match_dup 2)) (match_dup 3)))]
9ebbca7d 12478 "TARGET_POWER && reload_completed"
097657c3 12479 [(set (match_dup 0)
9ebbca7d 12480 (plus:SI (lt:SI (match_dup 1) (match_dup 2)) (match_dup 3)))
097657c3 12481 (set (match_dup 4)
9ebbca7d
GK
12482 (compare:CC (match_dup 0)
12483 (const_int 0)))]
12484 "")
1fd4e8c1
RK
12485
12486(define_insn ""
cd2b37d9
RK
12487 [(set (match_operand:SI 0 "gpc_reg_operand" "=r")
12488 (neg:SI (lt:SI (match_operand:SI 1 "gpc_reg_operand" "r")
1fd4e8c1 12489 (match_operand:SI 2 "reg_or_short_operand" "rI"))))]
ca7f5001
RK
12490 "TARGET_POWER"
12491 "doz%I2 %0,%1,%2\;nabs %0,%0\;{srai|srawi} %0,%0,31"
b19003d8 12492 [(set_attr "length" "12")])
1fd4e8c1
RK
12493
12494(define_insn ""
cd2b37d9
RK
12495 [(set (match_operand:SI 0 "gpc_reg_operand" "=r,r")
12496 (ltu:SI (match_operand:SI 1 "gpc_reg_operand" "r,r")
1fd4e8c1 12497 (match_operand:SI 2 "reg_or_neg_short_operand" "r,P")))]
683bdff7 12498 "TARGET_32BIT"
1fd4e8c1 12499 "@
ca7f5001
RK
12500 {sf|subfc} %0,%2,%1\;{sfe|subfe} %0,%0,%0\;neg %0,%0
12501 {ai|addic} %0,%1,%n2\;{sfe|subfe} %0,%0,%0\;neg %0,%0"
b19003d8 12502 [(set_attr "length" "12")])
1fd4e8c1
RK
12503
12504(define_insn ""
9ebbca7d 12505 [(set (match_operand:CC 3 "cc_reg_operand" "=x,x,?y,?y")
1fd4e8c1 12506 (compare:CC
9ebbca7d
GK
12507 (ltu:SI (match_operand:SI 1 "gpc_reg_operand" "r,r,r,r")
12508 (match_operand:SI 2 "reg_or_neg_short_operand" "r,P,r,P"))
1fd4e8c1 12509 (const_int 0)))
9ebbca7d 12510 (set (match_operand:SI 0 "gpc_reg_operand" "=r,r,r,r")
1fd4e8c1 12511 (ltu:SI (match_dup 1) (match_dup 2)))]
683bdff7 12512 "TARGET_32BIT"
1fd4e8c1 12513 "@
ca7f5001 12514 {sf|subfc} %0,%2,%1\;{sfe|subfe} %0,%0,%0\;neg. %0,%0
9ebbca7d
GK
12515 {ai|addic} %0,%1,%n2\;{sfe|subfe} %0,%0,%0\;neg. %0,%0
12516 #
12517 #"
b19003d8 12518 [(set_attr "type" "compare")
9ebbca7d
GK
12519 (set_attr "length" "12,12,16,16")])
12520
12521(define_split
12522 [(set (match_operand:CC 3 "cc_reg_not_cr0_operand" "")
12523 (compare:CC
12524 (ltu:SI (match_operand:SI 1 "gpc_reg_operand" "")
12525 (match_operand:SI 2 "reg_or_neg_short_operand" ""))
12526 (const_int 0)))
12527 (set (match_operand:SI 0 "gpc_reg_operand" "")
12528 (ltu:SI (match_dup 1) (match_dup 2)))]
683bdff7 12529 "TARGET_32BIT && reload_completed"
9ebbca7d
GK
12530 [(set (match_dup 0)
12531 (ltu:SI (match_dup 1) (match_dup 2)))
12532 (set (match_dup 3)
12533 (compare:CC (match_dup 0)
12534 (const_int 0)))]
12535 "")
1fd4e8c1
RK
12536
12537(define_insn ""
80103f96 12538 [(set (match_operand:SI 0 "gpc_reg_operand" "=&r,&r")
19378cf8
MM
12539 (plus:SI (ltu:SI (match_operand:SI 1 "gpc_reg_operand" "r,r")
12540 (match_operand:SI 2 "reg_or_neg_short_operand" "r,P"))
80103f96 12541 (match_operand:SI 3 "reg_or_short_operand" "rI,rI")))]
683bdff7 12542 "TARGET_32BIT"
1fd4e8c1 12543 "@
80103f96
FS
12544 {sf|subfc} %0,%2,%1\;{sfe|subfe} %0,%0,%0\;{sf%I3|subf%I3c} %0,%0,%3
12545 {ai|addic} %0,%1,%n2\;{sfe|subfe} %0,%0,%0\;{sf%I3|subf%I3c} %0,%0,%3"
b19003d8 12546 [(set_attr "length" "12")])
1fd4e8c1
RK
12547
12548(define_insn ""
9ebbca7d 12549 [(set (match_operand:CC 0 "cc_reg_operand" "=x,x,?y,?y")
1fd4e8c1 12550 (compare:CC
9ebbca7d
GK
12551 (plus:SI (ltu:SI (match_operand:SI 1 "gpc_reg_operand" "r,r,r,r")
12552 (match_operand:SI 2 "reg_or_neg_short_operand" "r,P,r,P"))
12553 (match_operand:SI 3 "gpc_reg_operand" "r,r,r,r"))
1fd4e8c1 12554 (const_int 0)))
9ebbca7d 12555 (clobber (match_scratch:SI 4 "=&r,&r,&r,&r"))]
683bdff7 12556 "TARGET_32BIT"
1fd4e8c1 12557 "@
ca7f5001 12558 {sf|subfc} %4,%2,%1\;{sfe|subfe} %4,%4,%4\;{sf.|subfc.} %4,%4,%3
9ebbca7d
GK
12559 {ai|addic} %4,%1,%n2\;{sfe|subfe} %4,%4,%4\;{sf.|subfc.} %4,%4,%3
12560 #
12561 #"
b19003d8 12562 [(set_attr "type" "compare")
9ebbca7d
GK
12563 (set_attr "length" "12,12,16,16")])
12564
12565(define_split
12566 [(set (match_operand:CC 0 "cc_reg_not_cr0_operand" "")
12567 (compare:CC
12568 (plus:SI (ltu:SI (match_operand:SI 1 "gpc_reg_operand" "")
12569 (match_operand:SI 2 "reg_or_neg_short_operand" ""))
12570 (match_operand:SI 3 "gpc_reg_operand" ""))
12571 (const_int 0)))
12572 (clobber (match_scratch:SI 4 ""))]
683bdff7 12573 "TARGET_32BIT && reload_completed"
9ebbca7d
GK
12574 [(set (match_dup 4)
12575 (plus:SI (ltu:SI (match_dup 1) (match_dup 2))
097657c3 12576 (match_dup 3)))
9ebbca7d
GK
12577 (set (match_dup 0)
12578 (compare:CC (match_dup 4)
12579 (const_int 0)))]
12580 "")
1fd4e8c1
RK
12581
12582(define_insn ""
097657c3 12583 [(set (match_operand:CC 4 "cc_reg_operand" "=x,x,?y,?y")
1fd4e8c1 12584 (compare:CC
9ebbca7d
GK
12585 (plus:SI (ltu:SI (match_operand:SI 1 "gpc_reg_operand" "r,r,r,r")
12586 (match_operand:SI 2 "reg_or_neg_short_operand" "r,P,r,P"))
12587 (match_operand:SI 3 "gpc_reg_operand" "r,r,r,r"))
1fd4e8c1 12588 (const_int 0)))
097657c3
AM
12589 (set (match_operand:SI 0 "gpc_reg_operand" "=&r,&r,&r,&r")
12590 (plus:SI (ltu:SI (match_dup 1) (match_dup 2)) (match_dup 3)))]
683bdff7 12591 "TARGET_32BIT"
1fd4e8c1 12592 "@
097657c3
AM
12593 {sf|subfc} %0,%2,%1\;{sfe|subfe} %0,%0,%0\;{sf.|subfc.} %0,%0,%3
12594 {ai|addic} %0,%1,%n2\;{sfe|subfe} %0,%0,%0\;{sf.|subfc.} %0,%0,%3
9ebbca7d
GK
12595 #
12596 #"
b19003d8 12597 [(set_attr "type" "compare")
9ebbca7d
GK
12598 (set_attr "length" "12,12,16,16")])
12599
12600(define_split
097657c3 12601 [(set (match_operand:CC 4 "cc_reg_not_cr0_operand" "")
9ebbca7d
GK
12602 (compare:CC
12603 (plus:SI (ltu:SI (match_operand:SI 1 "gpc_reg_operand" "")
12604 (match_operand:SI 2 "reg_or_neg_short_operand" ""))
12605 (match_operand:SI 3 "gpc_reg_operand" ""))
12606 (const_int 0)))
12607 (set (match_operand:SI 0 "gpc_reg_operand" "")
097657c3 12608 (plus:SI (ltu:SI (match_dup 1) (match_dup 2)) (match_dup 3)))]
683bdff7 12609 "TARGET_32BIT && reload_completed"
097657c3 12610 [(set (match_dup 0)
9ebbca7d 12611 (plus:SI (ltu:SI (match_dup 1) (match_dup 2)) (match_dup 3)))
097657c3 12612 (set (match_dup 4)
9ebbca7d
GK
12613 (compare:CC (match_dup 0)
12614 (const_int 0)))]
12615 "")
1fd4e8c1
RK
12616
12617(define_insn ""
cd2b37d9
RK
12618 [(set (match_operand:SI 0 "gpc_reg_operand" "=r,r")
12619 (neg:SI (ltu:SI (match_operand:SI 1 "gpc_reg_operand" "r,r")
1fd4e8c1 12620 (match_operand:SI 2 "reg_or_neg_short_operand" "r,P"))))]
683bdff7 12621 "TARGET_32BIT"
1fd4e8c1 12622 "@
ca7f5001
RK
12623 {sf|subfc} %0,%2,%1\;{sfe|subfe} %0,%0,%0
12624 {ai|addic} %0,%1,%n2\;{sfe|subfe} %0,%0,%0"
b19003d8 12625 [(set_attr "length" "8")])
1fd4e8c1
RK
12626
12627(define_insn ""
cd2b37d9
RK
12628 [(set (match_operand:SI 0 "gpc_reg_operand" "=r")
12629 (ge:SI (match_operand:SI 1 "gpc_reg_operand" "r")
1fd4e8c1
RK
12630 (match_operand:SI 2 "reg_or_short_operand" "rI")))
12631 (clobber (match_scratch:SI 3 "=r"))]
ca7f5001
RK
12632 "TARGET_POWER"
12633 "doz%I2 %3,%1,%2\;{sfi|subfic} %0,%3,0\;{ae|adde} %0,%0,%3"
b19003d8 12634 [(set_attr "length" "12")])
1fd4e8c1 12635
9ebbca7d
GK
12636(define_insn ""
12637 [(set (match_operand:CC 4 "cc_reg_operand" "=x,?y")
1fd4e8c1 12638 (compare:CC
9ebbca7d
GK
12639 (ge:SI (match_operand:SI 1 "gpc_reg_operand" "r,r")
12640 (match_operand:SI 2 "reg_or_short_operand" "rI,rI"))
1fd4e8c1 12641 (const_int 0)))
9ebbca7d 12642 (set (match_operand:SI 0 "gpc_reg_operand" "=r,r")
1fd4e8c1 12643 (ge:SI (match_dup 1) (match_dup 2)))
9ebbca7d 12644 (clobber (match_scratch:SI 3 "=r,r"))]
ca7f5001 12645 "TARGET_POWER"
9ebbca7d
GK
12646 "@
12647 doz%I2 %3,%1,%2\;{sfi|subfic} %0,%3,0\;{ae.|adde.} %0,%0,%3
12648 #"
12649 [(set_attr "type" "compare")
12650 (set_attr "length" "12,16")])
12651
12652(define_split
12653 [(set (match_operand:CC 4 "cc_reg_not_cr0_operand" "")
12654 (compare:CC
12655 (ge:SI (match_operand:SI 1 "gpc_reg_operand" "")
12656 (match_operand:SI 2 "reg_or_short_operand" ""))
12657 (const_int 0)))
12658 (set (match_operand:SI 0 "gpc_reg_operand" "")
12659 (ge:SI (match_dup 1) (match_dup 2)))
12660 (clobber (match_scratch:SI 3 ""))]
12661 "TARGET_POWER && reload_completed"
12662 [(parallel [(set (match_dup 0)
097657c3
AM
12663 (ge:SI (match_dup 1) (match_dup 2)))
12664 (clobber (match_dup 3))])
9ebbca7d
GK
12665 (set (match_dup 4)
12666 (compare:CC (match_dup 0)
12667 (const_int 0)))]
12668 "")
12669
1fd4e8c1 12670(define_insn ""
097657c3 12671 [(set (match_operand:SI 0 "gpc_reg_operand" "=&r")
cd2b37d9 12672 (plus:SI (ge:SI (match_operand:SI 1 "gpc_reg_operand" "r")
1fd4e8c1 12673 (match_operand:SI 2 "reg_or_short_operand" "rI"))
097657c3 12674 (match_operand:SI 3 "gpc_reg_operand" "r")))]
ca7f5001 12675 "TARGET_POWER"
097657c3 12676 "doz%I2 %0,%1,%2\;{sfi|subfic} %0,%0,0\;{aze|addze} %0,%3"
b19003d8 12677 [(set_attr "length" "12")])
1fd4e8c1
RK
12678
12679(define_insn ""
9ebbca7d 12680 [(set (match_operand:CC 0 "cc_reg_operand" "=x,?y")
1fd4e8c1 12681 (compare:CC
9ebbca7d
GK
12682 (plus:SI (ge:SI (match_operand:SI 1 "gpc_reg_operand" "r,r")
12683 (match_operand:SI 2 "reg_or_short_operand" "rI,rI"))
12684 (match_operand:SI 3 "gpc_reg_operand" "r,r"))
1fd4e8c1 12685 (const_int 0)))
9ebbca7d 12686 (clobber (match_scratch:SI 4 "=&r,&r"))]
ca7f5001 12687 "TARGET_POWER"
9ebbca7d
GK
12688 "@
12689 doz%I2 %4,%1,%2\;{sfi|subfic} %4,%4,0\;{aze.|addze.} %4,%3
12690 #"
b19003d8 12691 [(set_attr "type" "compare")
9ebbca7d
GK
12692 (set_attr "length" "12,16")])
12693
12694(define_split
12695 [(set (match_operand:CC 0 "cc_reg_not_cr0_operand" "")
12696 (compare:CC
12697 (plus:SI (ge:SI (match_operand:SI 1 "gpc_reg_operand" "")
12698 (match_operand:SI 2 "reg_or_short_operand" ""))
12699 (match_operand:SI 3 "gpc_reg_operand" ""))
12700 (const_int 0)))
12701 (clobber (match_scratch:SI 4 ""))]
12702 "TARGET_POWER && reload_completed"
12703 [(set (match_dup 4)
12704 (plus:SI (ge:SI (match_dup 1) (match_dup 2))
097657c3 12705 (match_dup 3)))
9ebbca7d
GK
12706 (set (match_dup 0)
12707 (compare:CC (match_dup 4)
12708 (const_int 0)))]
12709 "")
1fd4e8c1
RK
12710
12711(define_insn ""
097657c3 12712 [(set (match_operand:CC 4 "cc_reg_operand" "=x,?y")
1fd4e8c1 12713 (compare:CC
9ebbca7d
GK
12714 (plus:SI (ge:SI (match_operand:SI 1 "gpc_reg_operand" "r,r")
12715 (match_operand:SI 2 "reg_or_short_operand" "rI,rI"))
12716 (match_operand:SI 3 "gpc_reg_operand" "r,r"))
1fd4e8c1 12717 (const_int 0)))
097657c3
AM
12718 (set (match_operand:SI 0 "gpc_reg_operand" "=&r,&r")
12719 (plus:SI (ge:SI (match_dup 1) (match_dup 2)) (match_dup 3)))]
ca7f5001 12720 "TARGET_POWER"
9ebbca7d 12721 "@
097657c3 12722 doz%I2 %0,%1,%2\;{sfi|subfic} %0,%0,0\;{aze.|addze.} %0,%3
9ebbca7d 12723 #"
b19003d8 12724 [(set_attr "type" "compare")
9ebbca7d
GK
12725 (set_attr "length" "12,16")])
12726
12727(define_split
097657c3 12728 [(set (match_operand:CC 4 "cc_reg_not_cr0_operand" "")
9ebbca7d
GK
12729 (compare:CC
12730 (plus:SI (ge:SI (match_operand:SI 1 "gpc_reg_operand" "")
12731 (match_operand:SI 2 "reg_or_short_operand" ""))
12732 (match_operand:SI 3 "gpc_reg_operand" ""))
12733 (const_int 0)))
12734 (set (match_operand:SI 0 "gpc_reg_operand" "")
097657c3 12735 (plus:SI (ge:SI (match_dup 1) (match_dup 2)) (match_dup 3)))]
9ebbca7d 12736 "TARGET_POWER && reload_completed"
097657c3 12737 [(set (match_dup 0)
9ebbca7d 12738 (plus:SI (ge:SI (match_dup 1) (match_dup 2)) (match_dup 3)))
097657c3 12739 (set (match_dup 4)
9ebbca7d
GK
12740 (compare:CC (match_dup 0)
12741 (const_int 0)))]
12742 "")
1fd4e8c1
RK
12743
12744(define_insn ""
cd2b37d9
RK
12745 [(set (match_operand:SI 0 "gpc_reg_operand" "=r")
12746 (neg:SI (ge:SI (match_operand:SI 1 "gpc_reg_operand" "r")
1fd4e8c1 12747 (match_operand:SI 2 "reg_or_short_operand" "rI"))))]
ca7f5001
RK
12748 "TARGET_POWER"
12749 "doz%I2 %0,%1,%2\;{ai|addic} %0,%0,-1\;{sfe|subfe} %0,%0,%0"
b19003d8 12750 [(set_attr "length" "12")])
1fd4e8c1 12751
1fd4e8c1 12752(define_insn ""
cd2b37d9
RK
12753 [(set (match_operand:SI 0 "gpc_reg_operand" "=r,r")
12754 (geu:SI (match_operand:SI 1 "gpc_reg_operand" "r,r")
1fd4e8c1 12755 (match_operand:SI 2 "reg_or_neg_short_operand" "r,P")))]
683bdff7 12756 "TARGET_32BIT"
1fd4e8c1 12757 "@
ca7f5001
RK
12758 {sf|subfc} %0,%2,%1\;{cal %0,0(0)|li %0,0}\;{ae|adde} %0,%0,%0
12759 {ai|addic} %0,%1,%n2\;{cal %0,0(0)|li %0,0}\;{ae|adde} %0,%0,%0"
b19003d8 12760 [(set_attr "length" "12")])
1fd4e8c1 12761
f9562f27
DE
12762(define_insn ""
12763 [(set (match_operand:DI 0 "gpc_reg_operand" "=r,r")
12764 (geu:DI (match_operand:DI 1 "gpc_reg_operand" "r,r")
12765 (match_operand:DI 2 "reg_or_neg_short_operand" "r,P")))]
683bdff7 12766 "TARGET_64BIT"
f9562f27
DE
12767 "@
12768 subfc %0,%2,%1\;li %0,0\;adde %0,%0,%0
12769 addic %0,%1,%n2\;li %0,0\;adde %0,%0,%0"
12770 [(set_attr "length" "12")])
12771
1fd4e8c1 12772(define_insn ""
9ebbca7d 12773 [(set (match_operand:CC 3 "cc_reg_operand" "=x,x,?y,?y")
1fd4e8c1 12774 (compare:CC
9ebbca7d
GK
12775 (geu:SI (match_operand:SI 1 "gpc_reg_operand" "r,r,r,r")
12776 (match_operand:SI 2 "reg_or_neg_short_operand" "r,P,r,P"))
1fd4e8c1 12777 (const_int 0)))
9ebbca7d 12778 (set (match_operand:SI 0 "gpc_reg_operand" "=r,r,r,r")
1fd4e8c1 12779 (geu:SI (match_dup 1) (match_dup 2)))]
683bdff7 12780 "TARGET_32BIT"
1fd4e8c1 12781 "@
ca7f5001 12782 {sf|subfc} %0,%2,%1\;{cal %0,0(0)|li %0,0}\;{ae.|adde.} %0,%0,%0
9ebbca7d
GK
12783 {ai|addic} %0,%1,%n2\;{cal %0,0(0)|li %0,0}\;{ae.|adde.} %0,%0,%0
12784 #
12785 #"
b19003d8 12786 [(set_attr "type" "compare")
9ebbca7d
GK
12787 (set_attr "length" "12,12,16,16")])
12788
12789(define_split
12790 [(set (match_operand:CC 3 "cc_reg_not_cr0_operand" "")
12791 (compare:CC
12792 (geu:SI (match_operand:SI 1 "gpc_reg_operand" "")
12793 (match_operand:SI 2 "reg_or_neg_short_operand" ""))
12794 (const_int 0)))
12795 (set (match_operand:SI 0 "gpc_reg_operand" "")
12796 (geu:SI (match_dup 1) (match_dup 2)))]
683bdff7 12797 "TARGET_32BIT && reload_completed"
9ebbca7d
GK
12798 [(set (match_dup 0)
12799 (geu:SI (match_dup 1) (match_dup 2)))
12800 (set (match_dup 3)
12801 (compare:CC (match_dup 0)
12802 (const_int 0)))]
12803 "")
1fd4e8c1 12804
f9562f27 12805(define_insn ""
9ebbca7d 12806 [(set (match_operand:CC 3 "cc_reg_operand" "=x,x,?y,?y")
f9562f27 12807 (compare:CC
9ebbca7d
GK
12808 (geu:DI (match_operand:DI 1 "gpc_reg_operand" "r,r,r,r")
12809 (match_operand:DI 2 "reg_or_neg_short_operand" "r,P,r,P"))
f9562f27 12810 (const_int 0)))
9ebbca7d 12811 (set (match_operand:DI 0 "gpc_reg_operand" "=r,r,r,r")
f9562f27 12812 (geu:DI (match_dup 1) (match_dup 2)))]
683bdff7 12813 "TARGET_64BIT"
f9562f27
DE
12814 "@
12815 subfc %0,%2,%1\;li %0,0\;adde. %0,%0,%0
9ebbca7d
GK
12816 addic %0,%1,%n2\;li %0,0\;adde. %0,%0,%0
12817 #
12818 #"
f9562f27 12819 [(set_attr "type" "compare")
9ebbca7d
GK
12820 (set_attr "length" "12,12,16,16")])
12821
12822(define_split
12823 [(set (match_operand:CC 3 "cc_reg_not_cr0_operand" "")
12824 (compare:CC
12825 (geu:DI (match_operand:DI 1 "gpc_reg_operand" "")
12826 (match_operand:DI 2 "reg_or_neg_short_operand" ""))
12827 (const_int 0)))
12828 (set (match_operand:DI 0 "gpc_reg_operand" "")
12829 (geu:DI (match_dup 1) (match_dup 2)))]
683bdff7 12830 "TARGET_64BIT && reload_completed"
9ebbca7d
GK
12831 [(set (match_dup 0)
12832 (geu:DI (match_dup 1) (match_dup 2)))
12833 (set (match_dup 3)
12834 (compare:CC (match_dup 0)
12835 (const_int 0)))]
12836 "")
f9562f27 12837
1fd4e8c1 12838(define_insn ""
80103f96 12839 [(set (match_operand:SI 0 "gpc_reg_operand" "=&r,&r")
cd2b37d9 12840 (plus:SI (geu:SI (match_operand:SI 1 "gpc_reg_operand" "r,r")
1fd4e8c1 12841 (match_operand:SI 2 "reg_or_neg_short_operand" "r,P"))
80103f96 12842 (match_operand:SI 3 "gpc_reg_operand" "r,r")))]
683bdff7 12843 "TARGET_32BIT"
1fd4e8c1 12844 "@
80103f96
FS
12845 {sf|subfc} %0,%2,%1\;{aze|addze} %0,%3
12846 {ai|addic} %0,%1,%n2\;{aze|addze} %0,%3"
b19003d8 12847 [(set_attr "length" "8")])
1fd4e8c1
RK
12848
12849(define_insn ""
9ebbca7d 12850 [(set (match_operand:CC 0 "cc_reg_operand" "=x,x,?y,?y")
1fd4e8c1 12851 (compare:CC
9ebbca7d
GK
12852 (plus:SI (geu:SI (match_operand:SI 1 "gpc_reg_operand" "r,r,r,r")
12853 (match_operand:SI 2 "reg_or_neg_short_operand" "r,P,r,P"))
12854 (match_operand:SI 3 "gpc_reg_operand" "r,r,r,r"))
1fd4e8c1 12855 (const_int 0)))
9ebbca7d 12856 (clobber (match_scratch:SI 4 "=&r,&r,&r,&r"))]
683bdff7 12857 "TARGET_32BIT"
1fd4e8c1 12858 "@
ca7f5001 12859 {sf|subfc} %4,%2,%1\;{aze.|addze.} %4,%3
9ebbca7d
GK
12860 {ai|addic} %4,%1,%n2\;{aze.|addze.} %4,%3
12861 #
12862 #"
b19003d8 12863 [(set_attr "type" "compare")
9ebbca7d
GK
12864 (set_attr "length" "8,8,12,12")])
12865
12866(define_split
12867 [(set (match_operand:CC 0 "cc_reg_not_cr0_operand" "")
12868 (compare:CC
12869 (plus:SI (geu:SI (match_operand:SI 1 "gpc_reg_operand" "")
12870 (match_operand:SI 2 "reg_or_neg_short_operand" ""))
12871 (match_operand:SI 3 "gpc_reg_operand" ""))
12872 (const_int 0)))
12873 (clobber (match_scratch:SI 4 ""))]
683bdff7 12874 "TARGET_32BIT && reload_completed"
9ebbca7d
GK
12875 [(set (match_dup 4)
12876 (plus:SI (geu:SI (match_dup 1) (match_dup 2))
12877 (match_dup 3)))
12878 (set (match_dup 0)
12879 (compare:CC (match_dup 4)
12880 (const_int 0)))]
12881 "")
1fd4e8c1
RK
12882
12883(define_insn ""
097657c3 12884 [(set (match_operand:CC 4 "cc_reg_operand" "=x,x,?y,?y")
1fd4e8c1 12885 (compare:CC
9ebbca7d
GK
12886 (plus:SI (geu:SI (match_operand:SI 1 "gpc_reg_operand" "r,r,r,r")
12887 (match_operand:SI 2 "reg_or_neg_short_operand" "r,P,r,P"))
12888 (match_operand:SI 3 "gpc_reg_operand" "r,r,r,r"))
1fd4e8c1 12889 (const_int 0)))
097657c3
AM
12890 (set (match_operand:SI 0 "gpc_reg_operand" "=&r,&r,&r,&r")
12891 (plus:SI (geu:SI (match_dup 1) (match_dup 2)) (match_dup 3)))]
683bdff7 12892 "TARGET_32BIT"
1fd4e8c1 12893 "@
097657c3
AM
12894 {sf|subfc} %0,%2,%1\;{aze.|addze.} %0,%3
12895 {ai|addic} %0,%1,%n2\;{aze.|addze.} %0,%3
9ebbca7d
GK
12896 #
12897 #"
b19003d8 12898 [(set_attr "type" "compare")
9ebbca7d
GK
12899 (set_attr "length" "8,8,12,12")])
12900
12901(define_split
097657c3 12902 [(set (match_operand:CC 4 "cc_reg_not_cr0_operand" "")
9ebbca7d
GK
12903 (compare:CC
12904 (plus:SI (geu:SI (match_operand:SI 1 "gpc_reg_operand" "")
12905 (match_operand:SI 2 "reg_or_neg_short_operand" ""))
12906 (match_operand:SI 3 "gpc_reg_operand" ""))
12907 (const_int 0)))
12908 (set (match_operand:SI 0 "gpc_reg_operand" "")
097657c3 12909 (plus:SI (geu:SI (match_dup 1) (match_dup 2)) (match_dup 3)))]
683bdff7 12910 "TARGET_32BIT && reload_completed"
097657c3 12911 [(set (match_dup 0)
9ebbca7d 12912 (plus:SI (geu:SI (match_dup 1) (match_dup 2)) (match_dup 3)))
097657c3 12913 (set (match_dup 4)
9ebbca7d
GK
12914 (compare:CC (match_dup 0)
12915 (const_int 0)))]
12916 "")
1fd4e8c1
RK
12917
12918(define_insn ""
cd2b37d9
RK
12919 [(set (match_operand:SI 0 "gpc_reg_operand" "=r,r")
12920 (neg:SI (geu:SI (match_operand:SI 1 "gpc_reg_operand" "r,r")
1fd4e8c1 12921 (match_operand:SI 2 "reg_or_short_operand" "r,I"))))]
683bdff7 12922 "TARGET_32BIT"
1fd4e8c1 12923 "@
ca7f5001 12924 {sf|subfc} %0,%2,%1\;{sfe|subfe} %0,%0,%0\;nand %0,%0,%0
8106dc08 12925 {sfi|subfic} %0,%1,-1\;{a%I2|add%I2c} %0,%0,%2\;{sfe|subfe} %0,%0,%0"
b19003d8 12926 [(set_attr "length" "12")])
1fd4e8c1
RK
12927
12928(define_insn ""
097657c3 12929 [(set (match_operand:SI 0 "gpc_reg_operand" "=&r,&r")
1fd4e8c1 12930 (and:SI (neg:SI
cd2b37d9 12931 (geu:SI (match_operand:SI 1 "gpc_reg_operand" "r,r")
1fd4e8c1 12932 (match_operand:SI 2 "reg_or_neg_short_operand" "r,P")))
097657c3 12933 (match_operand:SI 3 "gpc_reg_operand" "r,r")))]
683bdff7 12934 "TARGET_32BIT"
1fd4e8c1 12935 "@
097657c3
AM
12936 {sf|subfc} %0,%2,%1\;{sfe|subfe} %0,%0,%0\;andc %0,%3,%0
12937 {ai|addic} %0,%1,%n2\;{sfe|subfe} %0,%0,%0\;andc %0,%3,%0"
b19003d8 12938 [(set_attr "length" "12")])
1fd4e8c1
RK
12939
12940(define_insn ""
9ebbca7d 12941 [(set (match_operand:CC 0 "cc_reg_operand" "=x,x,?y,?y")
1fd4e8c1
RK
12942 (compare:CC
12943 (and:SI (neg:SI
9ebbca7d
GK
12944 (geu:SI (match_operand:SI 1 "gpc_reg_operand" "r,r,r,r")
12945 (match_operand:SI 2 "reg_or_neg_short_operand" "r,P,r,P")))
12946 (match_operand:SI 3 "gpc_reg_operand" "r,r,r,r"))
1fd4e8c1 12947 (const_int 0)))
9ebbca7d 12948 (clobber (match_scratch:SI 4 "=&r,&r,&r,&r"))]
683bdff7 12949 "TARGET_32BIT"
1fd4e8c1 12950 "@
ca7f5001 12951 {sf|subfc} %4,%2,%1\;{sfe|subfe} %4,%4,%4\;andc. %4,%3,%4
9ebbca7d
GK
12952 {ai|addic} %4,%1,%n2\;{sfe|subfe} %4,%4,%4\;andc. %4,%3,%4
12953 #
12954 #"
b19003d8 12955 [(set_attr "type" "compare")
9ebbca7d
GK
12956 (set_attr "length" "12,12,16,16")])
12957
12958(define_split
12959 [(set (match_operand:CC 0 "cc_reg_not_cr0_operand" "")
12960 (compare:CC
12961 (and:SI (neg:SI
12962 (geu:SI (match_operand:SI 1 "gpc_reg_operand" "")
12963 (match_operand:SI 2 "reg_or_neg_short_operand" "")))
12964 (match_operand:SI 3 "gpc_reg_operand" ""))
12965 (const_int 0)))
12966 (clobber (match_scratch:SI 4 ""))]
683bdff7 12967 "TARGET_32BIT && reload_completed"
9ebbca7d 12968 [(set (match_dup 4)
097657c3
AM
12969 (and:SI (neg:SI (geu:SI (match_dup 1) (match_dup 2)))
12970 (match_dup 3)))
9ebbca7d
GK
12971 (set (match_dup 0)
12972 (compare:CC (match_dup 4)
12973 (const_int 0)))]
12974 "")
1fd4e8c1
RK
12975
12976(define_insn ""
097657c3 12977 [(set (match_operand:CC 4 "cc_reg_operand" "=x,x,?y,?y")
1fd4e8c1
RK
12978 (compare:CC
12979 (and:SI (neg:SI
9ebbca7d
GK
12980 (geu:SI (match_operand:SI 1 "gpc_reg_operand" "r,r,r,r")
12981 (match_operand:SI 2 "reg_or_neg_short_operand" "r,P,r,P")))
12982 (match_operand:SI 3 "gpc_reg_operand" "r,r,r,r"))
1fd4e8c1 12983 (const_int 0)))
097657c3
AM
12984 (set (match_operand:SI 0 "gpc_reg_operand" "=&r,&r,&r,&r")
12985 (and:SI (neg:SI (geu:SI (match_dup 1) (match_dup 2))) (match_dup 3)))]
683bdff7 12986 "TARGET_32BIT"
1fd4e8c1 12987 "@
097657c3
AM
12988 {sf|subfc} %0,%2,%1\;{sfe|subfe} %0,%0,%0\;andc. %0,%3,%0
12989 {ai|addic} %0,%1,%n2\;{sfe|subfe} %0,%0,%0\;andc. %0,%3,%0
9ebbca7d
GK
12990 #
12991 #"
b19003d8 12992 [(set_attr "type" "compare")
9ebbca7d
GK
12993 (set_attr "length" "12,12,16,16")])
12994
12995(define_split
097657c3 12996 [(set (match_operand:CC 4 "cc_reg_not_cr0_operand" "")
9ebbca7d
GK
12997 (compare:CC
12998 (and:SI (neg:SI
12999 (geu:SI (match_operand:SI 1 "gpc_reg_operand" "")
13000 (match_operand:SI 2 "reg_or_neg_short_operand" "")))
13001 (match_operand:SI 3 "gpc_reg_operand" ""))
13002 (const_int 0)))
13003 (set (match_operand:SI 0 "gpc_reg_operand" "")
097657c3 13004 (and:SI (neg:SI (geu:SI (match_dup 1) (match_dup 2))) (match_dup 3)))]
683bdff7 13005 "TARGET_32BIT && reload_completed"
097657c3 13006 [(set (match_dup 0)
9ebbca7d 13007 (and:SI (neg:SI (geu:SI (match_dup 1) (match_dup 2))) (match_dup 3)))
097657c3 13008 (set (match_dup 4)
9ebbca7d
GK
13009 (compare:CC (match_dup 0)
13010 (const_int 0)))]
13011 "")
1fd4e8c1
RK
13012
13013(define_insn ""
cd2b37d9
RK
13014 [(set (match_operand:SI 0 "gpc_reg_operand" "=r")
13015 (gt:SI (match_operand:SI 1 "gpc_reg_operand" "r")
1fd4e8c1 13016 (const_int 0)))]
683bdff7 13017 "TARGET_32BIT"
ca7f5001 13018 "{sfi|subfic} %0,%1,0\;{ame|addme} %0,%0\;{sri|srwi} %0,%0,31"
b19003d8 13019 [(set_attr "length" "12")])
1fd4e8c1 13020
f9562f27
DE
13021(define_insn ""
13022 [(set (match_operand:DI 0 "gpc_reg_operand" "=r")
13023 (gt:DI (match_operand:DI 1 "gpc_reg_operand" "r")
13024 (const_int 0)))]
683bdff7 13025 "TARGET_64BIT"
f9562f27
DE
13026 "subfic %0,%1,0\;addme %0,%0\;srdi %0,%0,63"
13027 [(set_attr "length" "12")])
13028
1fd4e8c1 13029(define_insn ""
9ebbca7d 13030 [(set (match_operand:CC 2 "cc_reg_operand" "=x,?y")
1fd4e8c1 13031 (compare:CC
9ebbca7d 13032 (gt:SI (match_operand:SI 1 "gpc_reg_operand" "r,r")
1fd4e8c1
RK
13033 (const_int 0))
13034 (const_int 0)))
9ebbca7d 13035 (set (match_operand:SI 0 "gpc_reg_operand" "=r,r")
1fd4e8c1 13036 (gt:SI (match_dup 1) (const_int 0)))]
683bdff7 13037 "TARGET_32BIT"
9ebbca7d
GK
13038 "@
13039 {sfi|subfic} %0,%1,0\;{ame|addme} %0,%0\;{sri.|srwi.} %0,%0,31
13040 #"
29ae5b89 13041 [(set_attr "type" "delayed_compare")
9ebbca7d
GK
13042 (set_attr "length" "12,16")])
13043
13044(define_split
13045 [(set (match_operand:CC 2 "cc_reg_not_cr0_operand" "")
13046 (compare:CC
13047 (gt:SI (match_operand:SI 1 "gpc_reg_operand" "")
13048 (const_int 0))
13049 (const_int 0)))
13050 (set (match_operand:SI 0 "gpc_reg_operand" "")
13051 (gt:SI (match_dup 1) (const_int 0)))]
683bdff7 13052 "TARGET_32BIT && reload_completed"
9ebbca7d
GK
13053 [(set (match_dup 0)
13054 (gt:SI (match_dup 1) (const_int 0)))
13055 (set (match_dup 2)
13056 (compare:CC (match_dup 0)
13057 (const_int 0)))]
13058 "")
1fd4e8c1 13059
f9562f27 13060(define_insn ""
9ebbca7d 13061 [(set (match_operand:CC 2 "cc_reg_operand" "=x,?y")
f9562f27 13062 (compare:CC
9ebbca7d 13063 (gt:DI (match_operand:DI 1 "gpc_reg_operand" "r,r")
f9562f27
DE
13064 (const_int 0))
13065 (const_int 0)))
9ebbca7d 13066 (set (match_operand:DI 0 "gpc_reg_operand" "=r,r")
f9562f27 13067 (gt:DI (match_dup 1) (const_int 0)))]
683bdff7 13068 "TARGET_64BIT"
9ebbca7d
GK
13069 "@
13070 subfic %0,%1,0\;addme %0,%0\;srdi. %0,%0,63
13071 #"
f9562f27 13072 [(set_attr "type" "delayed_compare")
9ebbca7d
GK
13073 (set_attr "length" "12,16")])
13074
13075(define_split
13076 [(set (match_operand:CC 2 "cc_reg_not_cr0_operand" "")
13077 (compare:CC
13078 (gt:DI (match_operand:DI 1 "gpc_reg_operand" "")
13079 (const_int 0))
13080 (const_int 0)))
13081 (set (match_operand:DI 0 "gpc_reg_operand" "")
13082 (gt:DI (match_dup 1) (const_int 0)))]
683bdff7 13083 "TARGET_64BIT && reload_completed"
9ebbca7d
GK
13084 [(set (match_dup 0)
13085 (gt:DI (match_dup 1) (const_int 0)))
13086 (set (match_dup 2)
13087 (compare:CC (match_dup 0)
13088 (const_int 0)))]
13089 "")
f9562f27 13090
1fd4e8c1 13091(define_insn ""
cd2b37d9
RK
13092 [(set (match_operand:SI 0 "gpc_reg_operand" "=r")
13093 (gt:SI (match_operand:SI 1 "gpc_reg_operand" "r")
1fd4e8c1 13094 (match_operand:SI 2 "reg_or_short_operand" "r")))]
ca7f5001
RK
13095 "TARGET_POWER"
13096 "doz %0,%2,%1\;nabs %0,%0\;{sri|srwi} %0,%0,31"
b19003d8 13097 [(set_attr "length" "12")])
1fd4e8c1
RK
13098
13099(define_insn ""
9ebbca7d 13100 [(set (match_operand:CC 3 "cc_reg_operand" "=x,?y")
1fd4e8c1 13101 (compare:CC
9ebbca7d
GK
13102 (gt:SI (match_operand:SI 1 "gpc_reg_operand" "r,r")
13103 (match_operand:SI 2 "reg_or_short_operand" "r,r"))
1fd4e8c1 13104 (const_int 0)))
9ebbca7d 13105 (set (match_operand:SI 0 "gpc_reg_operand" "=r,r")
1fd4e8c1 13106 (gt:SI (match_dup 1) (match_dup 2)))]
ca7f5001 13107 "TARGET_POWER"
9ebbca7d
GK
13108 "@
13109 doz %0,%2,%1\;nabs %0,%0\;{sri.|srwi.} %0,%0,31
13110 #"
29ae5b89 13111 [(set_attr "type" "delayed_compare")
9ebbca7d
GK
13112 (set_attr "length" "12,16")])
13113
13114(define_split
13115 [(set (match_operand:CC 3 "cc_reg_not_cr0_operand" "")
13116 (compare:CC
13117 (gt:SI (match_operand:SI 1 "gpc_reg_operand" "")
13118 (match_operand:SI 2 "reg_or_short_operand" ""))
13119 (const_int 0)))
13120 (set (match_operand:SI 0 "gpc_reg_operand" "")
13121 (gt:SI (match_dup 1) (match_dup 2)))]
13122 "TARGET_POWER && reload_completed"
13123 [(set (match_dup 0)
13124 (gt:SI (match_dup 1) (match_dup 2)))
13125 (set (match_dup 3)
13126 (compare:CC (match_dup 0)
13127 (const_int 0)))]
13128 "")
1fd4e8c1
RK
13129
13130(define_insn ""
80103f96 13131 [(set (match_operand:SI 0 "gpc_reg_operand" "=&r")
cd2b37d9 13132 (plus:SI (gt:SI (match_operand:SI 1 "gpc_reg_operand" "r")
1fd4e8c1 13133 (const_int 0))
80103f96 13134 (match_operand:SI 2 "gpc_reg_operand" "r")))]
683bdff7 13135 "TARGET_32BIT"
80103f96 13136 "{a|addc} %0,%1,%1\;{sfe|subfe} %0,%1,%0\;{aze|addze} %0,%2"
b19003d8 13137 [(set_attr "length" "12")])
1fd4e8c1 13138
f9562f27 13139(define_insn ""
097657c3 13140 [(set (match_operand:DI 0 "gpc_reg_operand" "=&r")
f9562f27
DE
13141 (plus:DI (gt:DI (match_operand:DI 1 "gpc_reg_operand" "r")
13142 (const_int 0))
097657c3 13143 (match_operand:DI 2 "gpc_reg_operand" "r")))]
683bdff7 13144 "TARGET_64BIT"
097657c3 13145 "addc %0,%1,%1\;subfe %0,%1,%0\;addze %0,%2"
f9562f27
DE
13146 [(set_attr "length" "12")])
13147
1fd4e8c1 13148(define_insn ""
9ebbca7d 13149 [(set (match_operand:CC 0 "cc_reg_operand" "=x,?y")
1fd4e8c1 13150 (compare:CC
9ebbca7d 13151 (plus:SI (gt:SI (match_operand:SI 1 "gpc_reg_operand" "r,r")
1fd4e8c1 13152 (const_int 0))
9ebbca7d 13153 (match_operand:SI 2 "gpc_reg_operand" "r,r"))
1fd4e8c1 13154 (const_int 0)))
9ebbca7d 13155 (clobber (match_scratch:SI 3 "=&r,&r"))]
683bdff7 13156 "TARGET_32BIT"
9ebbca7d
GK
13157 "@
13158 {a|addc} %3,%1,%1\;{sfe|subfe} %3,%1,%3\;{aze.|addze.} %3,%2
13159 #"
b19003d8 13160 [(set_attr "type" "compare")
9ebbca7d
GK
13161 (set_attr "length" "12,16")])
13162
13163(define_split
13164 [(set (match_operand:CC 0 "cc_reg_not_cr0_operand" "")
13165 (compare:CC
13166 (plus:SI (gt:SI (match_operand:SI 1 "gpc_reg_operand" "")
13167 (const_int 0))
13168 (match_operand:SI 2 "gpc_reg_operand" ""))
13169 (const_int 0)))
13170 (clobber (match_scratch:SI 3 ""))]
683bdff7 13171 "TARGET_32BIT && reload_completed"
9ebbca7d
GK
13172 [(set (match_dup 3)
13173 (plus:SI (gt:SI (match_dup 1) (const_int 0))
13174 (match_dup 2)))
13175 (set (match_dup 0)
13176 (compare:CC (match_dup 3)
13177 (const_int 0)))]
13178 "")
1fd4e8c1 13179
f9562f27 13180(define_insn ""
9ebbca7d 13181 [(set (match_operand:CC 0 "cc_reg_operand" "=x,?y")
f9562f27 13182 (compare:CC
9ebbca7d 13183 (plus:DI (gt:DI (match_operand:DI 1 "gpc_reg_operand" "r,r")
f9562f27 13184 (const_int 0))
9ebbca7d 13185 (match_operand:DI 2 "gpc_reg_operand" "r,r"))
f9562f27 13186 (const_int 0)))
9ebbca7d 13187 (clobber (match_scratch:DI 3 "=&r,&r"))]
683bdff7 13188 "TARGET_64BIT"
9ebbca7d
GK
13189 "@
13190 addc %3,%1,%1\;subfe %3,%1,%3\;addze. %3,%2
13191 #"
f9562f27 13192 [(set_attr "type" "compare")
9ebbca7d
GK
13193 (set_attr "length" "12,16")])
13194
13195(define_split
13196 [(set (match_operand:CC 0 "cc_reg_not_cr0_operand" "")
13197 (compare:CC
13198 (plus:DI (gt:DI (match_operand:DI 1 "gpc_reg_operand" "")
13199 (const_int 0))
13200 (match_operand:DI 2 "gpc_reg_operand" ""))
13201 (const_int 0)))
13202 (clobber (match_scratch:DI 3 ""))]
683bdff7 13203 "TARGET_64BIT && reload_completed"
9ebbca7d
GK
13204 [(set (match_dup 3)
13205 (plus:DI (gt:DI (match_dup 1) (const_int 0))
097657c3 13206 (match_dup 2)))
9ebbca7d
GK
13207 (set (match_dup 0)
13208 (compare:CC (match_dup 3)
13209 (const_int 0)))]
13210 "")
f9562f27 13211
1fd4e8c1 13212(define_insn ""
097657c3 13213 [(set (match_operand:CC 3 "cc_reg_operand" "=x,?y")
9ebbca7d
GK
13214 (compare:CC
13215 (plus:SI (gt:SI (match_operand:SI 1 "gpc_reg_operand" "r,r")
13216 (const_int 0))
13217 (match_operand:SI 2 "gpc_reg_operand" "r,r"))
13218 (const_int 0)))
097657c3
AM
13219 (set (match_operand:SI 0 "gpc_reg_operand" "=&r,&r")
13220 (plus:SI (gt:SI (match_dup 1) (const_int 0)) (match_dup 2)))]
683bdff7 13221 "TARGET_32BIT"
9ebbca7d 13222 "@
097657c3 13223 {a|addc} %0,%1,%1\;{sfe|subfe} %0,%1,%0\;{aze.|addze.} %0,%2
9ebbca7d
GK
13224 #"
13225 [(set_attr "type" "compare")
13226 (set_attr "length" "12,16")])
13227
13228(define_split
097657c3 13229 [(set (match_operand:CC 3 "cc_reg_not_cr0_operand" "")
1fd4e8c1 13230 (compare:CC
9ebbca7d 13231 (plus:SI (gt:SI (match_operand:SI 1 "gpc_reg_operand" "")
1fd4e8c1 13232 (const_int 0))
9ebbca7d 13233 (match_operand:SI 2 "gpc_reg_operand" ""))
1fd4e8c1 13234 (const_int 0)))
9ebbca7d 13235 (set (match_operand:SI 0 "gpc_reg_operand" "")
097657c3 13236 (plus:SI (gt:SI (match_dup 1) (const_int 0)) (match_dup 2)))]
683bdff7 13237 "TARGET_32BIT && reload_completed"
097657c3 13238 [(set (match_dup 0)
9ebbca7d 13239 (plus:SI (gt:SI (match_dup 1) (const_int 0)) (match_dup 2)))
097657c3 13240 (set (match_dup 3)
9ebbca7d
GK
13241 (compare:CC (match_dup 0)
13242 (const_int 0)))]
13243 "")
1fd4e8c1 13244
f9562f27 13245(define_insn ""
097657c3 13246 [(set (match_operand:CC 3 "cc_reg_operand" "=x,?y")
f9562f27 13247 (compare:CC
9ebbca7d 13248 (plus:DI (gt:DI (match_operand:DI 1 "gpc_reg_operand" "r,r")
f9562f27 13249 (const_int 0))
9ebbca7d 13250 (match_operand:DI 2 "gpc_reg_operand" "r,r"))
f9562f27 13251 (const_int 0)))
097657c3
AM
13252 (set (match_operand:DI 0 "gpc_reg_operand" "=&r,&r")
13253 (plus:DI (gt:DI (match_dup 1) (const_int 0)) (match_dup 2)))]
683bdff7 13254 "TARGET_64BIT"
9ebbca7d 13255 "@
097657c3 13256 addc %0,%1,%1\;subfe %0,%1,%0\;addze. %0,%2
9ebbca7d 13257 #"
f9562f27 13258 [(set_attr "type" "compare")
9ebbca7d
GK
13259 (set_attr "length" "12,16")])
13260
13261(define_split
097657c3 13262 [(set (match_operand:CC 3 "cc_reg_not_cr0_operand" "")
9ebbca7d
GK
13263 (compare:CC
13264 (plus:DI (gt:DI (match_operand:DI 1 "gpc_reg_operand" "")
13265 (const_int 0))
13266 (match_operand:DI 2 "gpc_reg_operand" ""))
13267 (const_int 0)))
13268 (set (match_operand:DI 0 "gpc_reg_operand" "")
097657c3 13269 (plus:DI (gt:DI (match_dup 1) (const_int 0)) (match_dup 2)))]
683bdff7 13270 "TARGET_64BIT && reload_completed"
097657c3 13271 [(set (match_dup 0)
9ebbca7d 13272 (plus:DI (gt:DI (match_dup 1) (const_int 0)) (match_dup 2)))
097657c3 13273 (set (match_dup 3)
9ebbca7d
GK
13274 (compare:CC (match_dup 0)
13275 (const_int 0)))]
13276 "")
f9562f27 13277
1fd4e8c1 13278(define_insn ""
097657c3 13279 [(set (match_operand:SI 0 "gpc_reg_operand" "=&r")
cd2b37d9 13280 (plus:SI (gt:SI (match_operand:SI 1 "gpc_reg_operand" "r")
1fd4e8c1 13281 (match_operand:SI 2 "reg_or_short_operand" "r"))
097657c3 13282 (match_operand:SI 3 "gpc_reg_operand" "r")))]
ca7f5001 13283 "TARGET_POWER"
097657c3 13284 "doz %0,%2,%1\;{ai|addic} %0,%0,-1\;{aze|addze} %0,%3"
b19003d8 13285 [(set_attr "length" "12")])
1fd4e8c1
RK
13286
13287(define_insn ""
9ebbca7d 13288 [(set (match_operand:CC 0 "cc_reg_operand" "=x,?y")
1fd4e8c1 13289 (compare:CC
9ebbca7d
GK
13290 (plus:SI (gt:SI (match_operand:SI 1 "gpc_reg_operand" "r,r")
13291 (match_operand:SI 2 "reg_or_short_operand" "r,r"))
13292 (match_operand:SI 3 "gpc_reg_operand" "r,r"))
1fd4e8c1 13293 (const_int 0)))
9ebbca7d 13294 (clobber (match_scratch:SI 4 "=&r,&r"))]
ca7f5001 13295 "TARGET_POWER"
9ebbca7d
GK
13296 "@
13297 doz %4,%2,%1\;{ai|addic} %4,%4,-1\;{aze.|addze.} %4,%3
13298 #"
b19003d8 13299 [(set_attr "type" "compare")
9ebbca7d
GK
13300 (set_attr "length" "12,16")])
13301
13302(define_split
13303 [(set (match_operand:CC 0 "cc_reg_not_cr0_operand" "")
13304 (compare:CC
13305 (plus:SI (gt:SI (match_operand:SI 1 "gpc_reg_operand" "")
13306 (match_operand:SI 2 "reg_or_short_operand" ""))
13307 (match_operand:SI 3 "gpc_reg_operand" ""))
13308 (const_int 0)))
13309 (clobber (match_scratch:SI 4 ""))]
13310 "TARGET_POWER && reload_completed"
13311 [(set (match_dup 4)
097657c3 13312 (plus:SI (gt:SI (match_dup 1) (match_dup 2)) (match_dup 3)))
9ebbca7d
GK
13313 (set (match_dup 0)
13314 (compare:CC (match_dup 4)
13315 (const_int 0)))]
13316 "")
1fd4e8c1
RK
13317
13318(define_insn ""
097657c3 13319 [(set (match_operand:CC 4 "cc_reg_operand" "=x,?y")
1fd4e8c1 13320 (compare:CC
9ebbca7d
GK
13321 (plus:SI (gt:SI (match_operand:SI 1 "gpc_reg_operand" "r,r")
13322 (match_operand:SI 2 "reg_or_short_operand" "r,r"))
13323 (match_operand:SI 3 "gpc_reg_operand" "r,r"))
1fd4e8c1 13324 (const_int 0)))
097657c3
AM
13325 (set (match_operand:SI 0 "gpc_reg_operand" "=&r,&r")
13326 (plus:SI (gt:SI (match_dup 1) (match_dup 2)) (match_dup 3)))]
ca7f5001 13327 "TARGET_POWER"
9ebbca7d 13328 "@
097657c3 13329 doz %0,%2,%1\;{ai|addic} %0,%0,-1\;{aze.|addze.} %0,%3
9ebbca7d 13330 #"
b19003d8 13331 [(set_attr "type" "compare")
9ebbca7d
GK
13332 (set_attr "length" "12,16")])
13333
13334(define_split
097657c3 13335 [(set (match_operand:CC 4 "cc_reg_not_cr0_operand" "")
9ebbca7d
GK
13336 (compare:CC
13337 (plus:SI (gt:SI (match_operand:SI 1 "gpc_reg_operand" "")
13338 (match_operand:SI 2 "reg_or_short_operand" ""))
13339 (match_operand:SI 3 "gpc_reg_operand" ""))
13340 (const_int 0)))
13341 (set (match_operand:SI 0 "gpc_reg_operand" "")
097657c3 13342 (plus:SI (gt:SI (match_dup 1) (match_dup 2)) (match_dup 3)))]
9ebbca7d 13343 "TARGET_POWER && reload_completed"
097657c3 13344 [(set (match_dup 0)
9ebbca7d 13345 (plus:SI (gt:SI (match_dup 1) (match_dup 2)) (match_dup 3)))
097657c3 13346 (set (match_dup 4)
9ebbca7d
GK
13347 (compare:CC (match_dup 0)
13348 (const_int 0)))]
13349 "")
1fd4e8c1
RK
13350
13351(define_insn ""
cd2b37d9
RK
13352 [(set (match_operand:SI 0 "gpc_reg_operand" "=r")
13353 (neg:SI (gt:SI (match_operand:SI 1 "gpc_reg_operand" "r")
1fd4e8c1 13354 (const_int 0))))]
683bdff7 13355 "TARGET_32BIT"
ca7f5001 13356 "{sfi|subfic} %0,%1,0\;{ame|addme} %0,%0\;{srai|srawi} %0,%0,31"
b19003d8 13357 [(set_attr "length" "12")])
1fd4e8c1 13358
f9562f27
DE
13359(define_insn ""
13360 [(set (match_operand:DI 0 "gpc_reg_operand" "=r")
13361 (neg:DI (gt:DI (match_operand:DI 1 "gpc_reg_operand" "r")
13362 (const_int 0))))]
683bdff7 13363 "TARGET_64BIT"
8377288b 13364 "subfic %0,%1,0\;addme %0,%0\;sradi %0,%0,63"
f9562f27
DE
13365 [(set_attr "length" "12")])
13366
1fd4e8c1 13367(define_insn ""
cd2b37d9
RK
13368 [(set (match_operand:SI 0 "gpc_reg_operand" "=r")
13369 (neg:SI (gt:SI (match_operand:SI 1 "gpc_reg_operand" "r")
1fd4e8c1 13370 (match_operand:SI 2 "reg_or_short_operand" "r"))))]
ca7f5001
RK
13371 "TARGET_POWER"
13372 "doz %0,%2,%1\;nabs %0,%0\;{srai|srawi} %0,%0,31"
b19003d8 13373 [(set_attr "length" "12")])
1fd4e8c1
RK
13374
13375(define_insn ""
cd2b37d9
RK
13376 [(set (match_operand:SI 0 "gpc_reg_operand" "=r")
13377 (gtu:SI (match_operand:SI 1 "gpc_reg_operand" "r")
1fd4e8c1 13378 (match_operand:SI 2 "reg_or_short_operand" "rI")))]
683bdff7 13379 "TARGET_32BIT"
ca7f5001 13380 "{sf%I2|subf%I2c} %0,%1,%2\;{sfe|subfe} %0,%0,%0\;neg %0,%0"
b19003d8 13381 [(set_attr "length" "12")])
1fd4e8c1 13382
f9562f27
DE
13383(define_insn ""
13384 [(set (match_operand:DI 0 "gpc_reg_operand" "=r")
13385 (gtu:DI (match_operand:DI 1 "gpc_reg_operand" "r")
13386 (match_operand:DI 2 "reg_or_short_operand" "rI")))]
683bdff7 13387 "TARGET_64BIT"
f9562f27
DE
13388 "subf%I2c %0,%1,%2\;subfe %0,%0,%0\;neg %0,%0"
13389 [(set_attr "length" "12")])
13390
1fd4e8c1 13391(define_insn ""
9ebbca7d 13392 [(set (match_operand:CC 3 "cc_reg_operand" "=x,?y")
1fd4e8c1 13393 (compare:CC
9ebbca7d
GK
13394 (gtu:SI (match_operand:SI 1 "gpc_reg_operand" "r,r")
13395 (match_operand:SI 2 "reg_or_short_operand" "rI,rI"))
1fd4e8c1 13396 (const_int 0)))
9ebbca7d 13397 (set (match_operand:SI 0 "gpc_reg_operand" "=r,r")
1fd4e8c1 13398 (gtu:SI (match_dup 1) (match_dup 2)))]
683bdff7 13399 "TARGET_32BIT"
9ebbca7d
GK
13400 "@
13401 {sf%I2|subf%I2c} %0,%1,%2\;{sfe|subfe} %0,%0,%0\;neg. %0,%0
13402 #"
b19003d8 13403 [(set_attr "type" "compare")
9ebbca7d
GK
13404 (set_attr "length" "12,16")])
13405
13406(define_split
13407 [(set (match_operand:CC 3 "cc_reg_not_cr0_operand" "")
13408 (compare:CC
13409 (gtu:SI (match_operand:SI 1 "gpc_reg_operand" "")
13410 (match_operand:SI 2 "reg_or_short_operand" ""))
13411 (const_int 0)))
13412 (set (match_operand:SI 0 "gpc_reg_operand" "")
13413 (gtu:SI (match_dup 1) (match_dup 2)))]
683bdff7 13414 "TARGET_32BIT && reload_completed"
9ebbca7d
GK
13415 [(set (match_dup 0)
13416 (gtu:SI (match_dup 1) (match_dup 2)))
13417 (set (match_dup 3)
13418 (compare:CC (match_dup 0)
13419 (const_int 0)))]
13420 "")
1fd4e8c1 13421
f9562f27 13422(define_insn ""
9ebbca7d 13423 [(set (match_operand:CC 3 "cc_reg_operand" "=x,?y")
f9562f27 13424 (compare:CC
9ebbca7d
GK
13425 (gtu:DI (match_operand:DI 1 "gpc_reg_operand" "r,r")
13426 (match_operand:DI 2 "reg_or_short_operand" "rI,rI"))
f9562f27 13427 (const_int 0)))
9ebbca7d 13428 (set (match_operand:DI 0 "gpc_reg_operand" "=r,r")
f9562f27 13429 (gtu:DI (match_dup 1) (match_dup 2)))]
683bdff7 13430 "TARGET_64BIT"
9ebbca7d
GK
13431 "@
13432 subf%I2c %0,%1,%2\;subfe %0,%0,%0\;neg. %0,%0
13433 #"
f9562f27 13434 [(set_attr "type" "compare")
9ebbca7d
GK
13435 (set_attr "length" "12,16")])
13436
13437(define_split
13438 [(set (match_operand:CC 3 "cc_reg_not_cr0_operand" "")
13439 (compare:CC
13440 (gtu:DI (match_operand:DI 1 "gpc_reg_operand" "")
13441 (match_operand:DI 2 "reg_or_short_operand" ""))
13442 (const_int 0)))
13443 (set (match_operand:DI 0 "gpc_reg_operand" "")
13444 (gtu:DI (match_dup 1) (match_dup 2)))]
683bdff7 13445 "TARGET_64BIT && reload_completed"
9ebbca7d
GK
13446 [(set (match_dup 0)
13447 (gtu:DI (match_dup 1) (match_dup 2)))
13448 (set (match_dup 3)
13449 (compare:CC (match_dup 0)
13450 (const_int 0)))]
13451 "")
f9562f27 13452
1fd4e8c1 13453(define_insn ""
80103f96 13454 [(set (match_operand:SI 0 "gpc_reg_operand" "=&r,&r")
19378cf8
MM
13455 (plus:SI (gtu:SI (match_operand:SI 1 "gpc_reg_operand" "r,r")
13456 (match_operand:SI 2 "reg_or_short_operand" "I,rI"))
80103f96 13457 (match_operand:SI 3 "reg_or_short_operand" "r,rI")))]
683bdff7 13458 "TARGET_32BIT"
00751805 13459 "@
80103f96
FS
13460 {ai|addic} %0,%1,%k2\;{aze|addze} %0,%3
13461 {sf%I2|subf%I2c} %0,%1,%2\;{sfe|subfe} %0,%0,%0\;{sf%I3|subf%I3c} %0,%0,%3"
19378cf8 13462 [(set_attr "length" "8,12")])
1fd4e8c1 13463
f9562f27 13464(define_insn ""
097657c3 13465 [(set (match_operand:DI 0 "gpc_reg_operand" "=&r,&r")
f9562f27
DE
13466 (plus:DI (gtu:DI (match_operand:DI 1 "gpc_reg_operand" "r,r")
13467 (match_operand:DI 2 "reg_or_short_operand" "I,rI"))
097657c3 13468 (match_operand:DI 3 "reg_or_short_operand" "r,rI")))]
683bdff7 13469 "TARGET_64BIT"
f9562f27 13470 "@
097657c3
AM
13471 addic %0,%1,%k2\;addze %0,%3
13472 subf%I2c %0,%1,%2\;subfe %0,%0,%0\;subf%I3c %0,%0,%3"
f9562f27
DE
13473 [(set_attr "length" "8,12")])
13474
1fd4e8c1 13475(define_insn ""
9ebbca7d 13476 [(set (match_operand:CC 0 "cc_reg_operand" "=x,x,?y,?y")
1fd4e8c1 13477 (compare:CC
9ebbca7d
GK
13478 (plus:SI (gtu:SI (match_operand:SI 1 "gpc_reg_operand" "r,r,r,r")
13479 (match_operand:SI 2 "reg_or_short_operand" "I,r,I,r"))
13480 (match_operand:SI 3 "gpc_reg_operand" "r,r,r,r"))
1fd4e8c1 13481 (const_int 0)))
9ebbca7d 13482 (clobber (match_scratch:SI 4 "=&r,&r,&r,&r"))]
683bdff7 13483 "TARGET_32BIT"
00751805 13484 "@
19378cf8 13485 {ai|addic} %4,%1,%k2\;{aze.|addze.} %4,%3
9ebbca7d
GK
13486 {sf%I2|subf%I2c} %4,%1,%2\;{sfe|subfe} %4,%4,%4\;{sf.|subfc.} %4,%4,%3
13487 #
13488 #"
b19003d8 13489 [(set_attr "type" "compare")
9ebbca7d
GK
13490 (set_attr "length" "8,12,12,16")])
13491
13492(define_split
13493 [(set (match_operand:CC 0 "cc_reg_not_cr0_operand" "")
13494 (compare:CC
13495 (plus:SI (gtu:SI (match_operand:SI 1 "gpc_reg_operand" "")
13496 (match_operand:SI 2 "reg_or_short_operand" ""))
13497 (match_operand:SI 3 "gpc_reg_operand" ""))
13498 (const_int 0)))
13499 (clobber (match_scratch:SI 4 ""))]
683bdff7 13500 "TARGET_32BIT && reload_completed"
9ebbca7d
GK
13501 [(set (match_dup 4)
13502 (plus:SI (gtu:SI (match_dup 1) (match_dup 2))
097657c3 13503 (match_dup 3)))
9ebbca7d
GK
13504 (set (match_dup 0)
13505 (compare:CC (match_dup 4)
13506 (const_int 0)))]
13507 "")
1fd4e8c1 13508
f9562f27 13509(define_insn ""
9ebbca7d 13510 [(set (match_operand:CC 0 "cc_reg_operand" "=x,x,?y,?y")
f9562f27 13511 (compare:CC
9ebbca7d
GK
13512 (plus:DI (gtu:DI (match_operand:DI 1 "gpc_reg_operand" "r,r,r,r")
13513 (match_operand:DI 2 "reg_or_short_operand" "I,r,I,r"))
13514 (match_operand:DI 3 "gpc_reg_operand" "r,r,r,r"))
f9562f27 13515 (const_int 0)))
9ebbca7d 13516 (clobber (match_scratch:DI 4 "=&r,&r,&r,&r"))]
683bdff7 13517 "TARGET_64BIT"
f9562f27
DE
13518 "@
13519 addic %4,%1,%k2\;addze. %4,%3
9ebbca7d
GK
13520 subf%I2c %4,%1,%2\;subfe %4,%4,%4\;subfc. %4,%4,%3
13521 #
13522 #"
f9562f27 13523 [(set_attr "type" "compare")
9ebbca7d
GK
13524 (set_attr "length" "8,12,12,16")])
13525
13526(define_split
13527 [(set (match_operand:CC 0 "cc_reg_not_cr0_operand" "")
13528 (compare:CC
13529 (plus:DI (gtu:DI (match_operand:DI 1 "gpc_reg_operand" "")
13530 (match_operand:DI 2 "reg_or_short_operand" ""))
13531 (match_operand:DI 3 "gpc_reg_operand" ""))
13532 (const_int 0)))
13533 (clobber (match_scratch:DI 4 ""))]
683bdff7 13534 "TARGET_64BIT && reload_completed"
9ebbca7d
GK
13535 [(set (match_dup 4)
13536 (plus:DI (gtu:DI (match_dup 1) (match_dup 2))
13537 (match_dup 3)))
13538 (set (match_dup 0)
13539 (compare:CC (match_dup 4)
13540 (const_int 0)))]
13541 "")
f9562f27 13542
1fd4e8c1 13543(define_insn ""
097657c3 13544 [(set (match_operand:CC 4 "cc_reg_operand" "=x,x,?y,?y")
1fd4e8c1 13545 (compare:CC
9ebbca7d
GK
13546 (plus:SI (gtu:SI (match_operand:SI 1 "gpc_reg_operand" "r,r,r,r")
13547 (match_operand:SI 2 "reg_or_short_operand" "I,r,I,r"))
13548 (match_operand:SI 3 "gpc_reg_operand" "r,r,r,r"))
1fd4e8c1 13549 (const_int 0)))
097657c3
AM
13550 (set (match_operand:SI 0 "gpc_reg_operand" "=&r,&r,&r,&r")
13551 (plus:SI (gtu:SI (match_dup 1) (match_dup 2)) (match_dup 3)))]
683bdff7 13552 "TARGET_32BIT"
00751805 13553 "@
097657c3
AM
13554 {ai|addic} %0,%1,%k2\;{aze.|addze.} %0,%3
13555 {sf%I2|subf%I2c} %0,%1,%2\;{sfe|subfe} %0,%0,%0\;{sf.|subfc.} %0,%0,%3
9ebbca7d
GK
13556 #
13557 #"
b19003d8 13558 [(set_attr "type" "compare")
9ebbca7d
GK
13559 (set_attr "length" "8,12,12,16")])
13560
13561(define_split
097657c3 13562 [(set (match_operand:CC 4 "cc_reg_not_cr0_operand" "")
9ebbca7d
GK
13563 (compare:CC
13564 (plus:SI (gtu:SI (match_operand:SI 1 "gpc_reg_operand" "")
13565 (match_operand:SI 2 "reg_or_short_operand" ""))
13566 (match_operand:SI 3 "gpc_reg_operand" ""))
13567 (const_int 0)))
13568 (set (match_operand:SI 0 "gpc_reg_operand" "")
097657c3 13569 (plus:SI (gtu:SI (match_dup 1) (match_dup 2)) (match_dup 3)))]
683bdff7 13570 "TARGET_32BIT && reload_completed"
097657c3 13571 [(set (match_dup 0)
9ebbca7d 13572 (plus:SI (gtu:SI (match_dup 1) (match_dup 2)) (match_dup 3)))
097657c3 13573 (set (match_dup 4)
9ebbca7d
GK
13574 (compare:CC (match_dup 0)
13575 (const_int 0)))]
13576 "")
1fd4e8c1 13577
f9562f27 13578(define_insn ""
097657c3 13579 [(set (match_operand:CC 4 "cc_reg_operand" "=x,x,?y,?y")
f9562f27 13580 (compare:CC
9ebbca7d
GK
13581 (plus:DI (gtu:DI (match_operand:DI 1 "gpc_reg_operand" "r,r,r,r")
13582 (match_operand:DI 2 "reg_or_short_operand" "I,r,I,r"))
13583 (match_operand:DI 3 "gpc_reg_operand" "r,r,r,r"))
f9562f27 13584 (const_int 0)))
097657c3
AM
13585 (set (match_operand:DI 0 "gpc_reg_operand" "=&r,&r,&r,&r")
13586 (plus:DI (gtu:DI (match_dup 1) (match_dup 2)) (match_dup 3)))]
683bdff7 13587 "TARGET_64BIT"
f9562f27 13588 "@
097657c3
AM
13589 addic %0,%1,%k2\;addze. %0,%3
13590 subf%I2c %0,%1,%2\;subfe %0,%0,%0\;subfc. %0,%0,%3
9ebbca7d
GK
13591 #
13592 #"
f9562f27 13593 [(set_attr "type" "compare")
9ebbca7d
GK
13594 (set_attr "length" "8,12,12,16")])
13595
13596(define_split
097657c3 13597 [(set (match_operand:CC 4 "cc_reg_not_cr0_operand" "")
9ebbca7d
GK
13598 (compare:CC
13599 (plus:DI (gtu:DI (match_operand:DI 1 "gpc_reg_operand" "")
13600 (match_operand:DI 2 "reg_or_short_operand" ""))
13601 (match_operand:DI 3 "gpc_reg_operand" ""))
13602 (const_int 0)))
13603 (set (match_operand:DI 0 "gpc_reg_operand" "")
097657c3 13604 (plus:DI (gtu:DI (match_dup 1) (match_dup 2)) (match_dup 3)))]
683bdff7 13605 "TARGET_64BIT && reload_completed"
097657c3 13606 [(set (match_dup 0)
9ebbca7d 13607 (plus:DI (gtu:DI (match_dup 1) (match_dup 2)) (match_dup 3)))
097657c3 13608 (set (match_dup 4)
9ebbca7d
GK
13609 (compare:CC (match_dup 0)
13610 (const_int 0)))]
13611 "")
f9562f27 13612
1fd4e8c1 13613(define_insn ""
cd2b37d9
RK
13614 [(set (match_operand:SI 0 "gpc_reg_operand" "=r")
13615 (neg:SI (gtu:SI (match_operand:SI 1 "gpc_reg_operand" "r")
1fd4e8c1 13616 (match_operand:SI 2 "reg_or_short_operand" "rI"))))]
683bdff7 13617 "TARGET_32BIT"
ca7f5001 13618 "{sf%I2|subf%I2c} %0,%1,%2\;{sfe|subfe} %0,%0,%0"
b19003d8 13619 [(set_attr "length" "8")])
f9562f27
DE
13620
13621(define_insn ""
13622 [(set (match_operand:DI 0 "gpc_reg_operand" "=r")
13623 (neg:DI (gtu:DI (match_operand:DI 1 "gpc_reg_operand" "r")
13624 (match_operand:DI 2 "reg_or_short_operand" "rI"))))]
683bdff7 13625 "TARGET_64BIT"
f9562f27
DE
13626 "subf%I2c %0,%1,%2\;subfe %0,%0,%0"
13627 [(set_attr "length" "8")])
1fd4e8c1
RK
13628\f
13629;; Define both directions of branch and return. If we need a reload
13630;; register, we'd rather use CR0 since it is much easier to copy a
13631;; register CC value to there.
13632
13633(define_insn ""
13634 [(set (pc)
13635 (if_then_else (match_operator 1 "branch_comparison_operator"
13636 [(match_operand 2
b54cf83a 13637 "cc_reg_operand" "y")
1fd4e8c1
RK
13638 (const_int 0)])
13639 (label_ref (match_operand 0 "" ""))
13640 (pc)))]
13641 ""
b19003d8
RK
13642 "*
13643{
12a4e8c5 13644 return output_cbranch (operands[1], \"%l0\", 0, insn);
b19003d8
RK
13645}"
13646 [(set_attr "type" "branch")])
13647
1fd4e8c1
RK
13648(define_insn ""
13649 [(set (pc)
13650 (if_then_else (match_operator 0 "branch_comparison_operator"
13651 [(match_operand 1
b54cf83a 13652 "cc_reg_operand" "y")
1fd4e8c1
RK
13653 (const_int 0)])
13654 (return)
13655 (pc)))]
13656 "direct_return ()"
12a4e8c5
GK
13657 "*
13658{
13659 return output_cbranch (operands[0], NULL, 0, insn);
13660}"
b7ff3d82 13661 [(set_attr "type" "branch")
39a10a29 13662 (set_attr "length" "4")])
1fd4e8c1
RK
13663
13664(define_insn ""
13665 [(set (pc)
13666 (if_then_else (match_operator 1 "branch_comparison_operator"
13667 [(match_operand 2
b54cf83a 13668 "cc_reg_operand" "y")
1fd4e8c1
RK
13669 (const_int 0)])
13670 (pc)
13671 (label_ref (match_operand 0 "" ""))))]
13672 ""
b19003d8
RK
13673 "*
13674{
12a4e8c5 13675 return output_cbranch (operands[1], \"%l0\", 1, insn);
b19003d8
RK
13676}"
13677 [(set_attr "type" "branch")])
1fd4e8c1
RK
13678
13679(define_insn ""
13680 [(set (pc)
13681 (if_then_else (match_operator 0 "branch_comparison_operator"
13682 [(match_operand 1
b54cf83a 13683 "cc_reg_operand" "y")
1fd4e8c1
RK
13684 (const_int 0)])
13685 (pc)
13686 (return)))]
13687 "direct_return ()"
12a4e8c5
GK
13688 "*
13689{
13690 return output_cbranch (operands[0], NULL, 1, insn);
13691}"
b7ff3d82 13692 [(set_attr "type" "branch")
39a10a29
GK
13693 (set_attr "length" "4")])
13694
13695;; Logic on condition register values.
13696
13697; This pattern matches things like
13698; (set (reg:CCEQ 68) (compare:CCEQ (ior:SI (gt:SI (reg:CCFP 68) (const_int 0))
13699; (eq:SI (reg:CCFP 68) (const_int 0)))
13700; (const_int 1)))
13701; which are generated by the branch logic.
b54cf83a 13702; Prefer destructive operations where BT = BB (for crXX BT,BA,BB)
39a10a29
GK
13703
13704(define_insn ""
b54cf83a 13705 [(set (match_operand:CCEQ 0 "cc_reg_operand" "=y,?y")
39a10a29 13706 (compare:CCEQ (match_operator:SI 1 "boolean_operator"
b54cf83a 13707 [(match_operator:SI 2
39a10a29
GK
13708 "branch_positive_comparison_operator"
13709 [(match_operand 3
b54cf83a 13710 "cc_reg_operand" "y,y")
39a10a29 13711 (const_int 0)])
b54cf83a 13712 (match_operator:SI 4
39a10a29
GK
13713 "branch_positive_comparison_operator"
13714 [(match_operand 5
b54cf83a 13715 "cc_reg_operand" "0,y")
39a10a29
GK
13716 (const_int 0)])])
13717 (const_int 1)))]
13718 ""
13719 "cr%q1 %E0,%j2,%j4"
b54cf83a 13720 [(set_attr "type" "cr_logical,delayed_cr")])
39a10a29
GK
13721
13722; Why is the constant -1 here, but 1 in the previous pattern?
13723; Because ~1 has all but the low bit set.
13724(define_insn ""
b54cf83a 13725 [(set (match_operand:CCEQ 0 "cc_reg_operand" "=y,?y")
39a10a29 13726 (compare:CCEQ (match_operator:SI 1 "boolean_or_operator"
b54cf83a 13727 [(not:SI (match_operator:SI 2
39a10a29
GK
13728 "branch_positive_comparison_operator"
13729 [(match_operand 3
b54cf83a 13730 "cc_reg_operand" "y,y")
39a10a29
GK
13731 (const_int 0)]))
13732 (match_operator:SI 4
13733 "branch_positive_comparison_operator"
13734 [(match_operand 5
b54cf83a 13735 "cc_reg_operand" "0,y")
39a10a29
GK
13736 (const_int 0)])])
13737 (const_int -1)))]
13738 ""
13739 "cr%q1 %E0,%j2,%j4"
b54cf83a 13740 [(set_attr "type" "cr_logical,delayed_cr")])
39a10a29
GK
13741
13742(define_insn ""
b54cf83a 13743 [(set (match_operand:CCEQ 0 "cc_reg_operand" "=y,?y")
6c873122 13744 (compare:CCEQ (match_operator:SI 1
39a10a29 13745 "branch_positive_comparison_operator"
6c873122 13746 [(match_operand 2
b54cf83a 13747 "cc_reg_operand" "0,y")
39a10a29
GK
13748 (const_int 0)])
13749 (const_int 0)))]
fe6b547a 13750 "!TARGET_SPE"
251b3667 13751 "{crnor %E0,%j1,%j1|crnot %E0,%j1}"
b54cf83a 13752 [(set_attr "type" "cr_logical,delayed_cr")])
39a10a29
GK
13753
13754;; If we are comparing the result of two comparisons, this can be done
13755;; using creqv or crxor.
13756
13757(define_insn_and_split ""
13758 [(set (match_operand:CCEQ 0 "cc_reg_operand" "=y")
13759 (compare:CCEQ (match_operator 1 "branch_comparison_operator"
13760 [(match_operand 2 "cc_reg_operand" "y")
13761 (const_int 0)])
13762 (match_operator 3 "branch_comparison_operator"
13763 [(match_operand 4 "cc_reg_operand" "y")
13764 (const_int 0)])))]
13765 ""
13766 "#"
13767 ""
13768 [(set (match_dup 0) (compare:CCEQ (xor:SI (match_dup 1) (match_dup 3))
13769 (match_dup 5)))]
13770 "
13771{
13772 int positive_1, positive_2;
13773
13774 positive_1 = branch_positive_comparison_operator (operands[1], CCEQmode);
13775 positive_2 = branch_positive_comparison_operator (operands[3], CCEQmode);
13776
13777 if (! positive_1)
2d4368e6 13778 operands[1] = gen_rtx (rs6000_reverse_condition (GET_MODE (operands[2]),
39a10a29 13779 GET_CODE (operands[1])),
2d4368e6
DE
13780 SImode,
13781 operands[2], const0_rtx);
39a10a29 13782 else if (GET_MODE (operands[1]) != SImode)
2d4368e6
DE
13783 operands[1] = gen_rtx (GET_CODE (operands[1]),
13784 SImode,
13785 operands[2], const0_rtx);
39a10a29
GK
13786
13787 if (! positive_2)
2d4368e6 13788 operands[3] = gen_rtx (rs6000_reverse_condition (GET_MODE (operands[4]),
39a10a29 13789 GET_CODE (operands[3])),
2d4368e6
DE
13790 SImode,
13791 operands[4], const0_rtx);
39a10a29 13792 else if (GET_MODE (operands[3]) != SImode)
2d4368e6
DE
13793 operands[3] = gen_rtx (GET_CODE (operands[3]),
13794 SImode,
13795 operands[4], const0_rtx);
39a10a29
GK
13796
13797 if (positive_1 == positive_2)
251b3667
DE
13798 {
13799 operands[1] = gen_rtx_NOT (SImode, operands[1]);
13800 operands[5] = constm1_rtx;
13801 }
13802 else
13803 {
13804 operands[5] = const1_rtx;
13805 }
39a10a29 13806}")
1fd4e8c1
RK
13807
13808;; Unconditional branch and return.
13809
13810(define_insn "jump"
13811 [(set (pc)
13812 (label_ref (match_operand 0 "" "")))]
13813 ""
b7ff3d82
DE
13814 "b %l0"
13815 [(set_attr "type" "branch")])
1fd4e8c1
RK
13816
13817(define_insn "return"
13818 [(return)]
13819 "direct_return ()"
324e52cc
TG
13820 "{br|blr}"
13821 [(set_attr "type" "jmpreg")])
1fd4e8c1 13822
0ad91047
DE
13823(define_expand "indirect_jump"
13824 [(set (pc) (match_operand 0 "register_operand" ""))]
1fd4e8c1 13825 ""
0ad91047
DE
13826 "
13827{
13828 if (TARGET_32BIT)
13829 emit_jump_insn (gen_indirect_jumpsi (operands[0]));
13830 else
13831 emit_jump_insn (gen_indirect_jumpdi (operands[0]));
13832 DONE;
13833}")
13834
13835(define_insn "indirect_jumpsi"
b92b324d 13836 [(set (pc) (match_operand:SI 0 "register_operand" "c,*l"))]
0ad91047 13837 "TARGET_32BIT"
b92b324d
DE
13838 "@
13839 bctr
13840 {br|blr}"
324e52cc 13841 [(set_attr "type" "jmpreg")])
1fd4e8c1 13842
0ad91047 13843(define_insn "indirect_jumpdi"
b92b324d 13844 [(set (pc) (match_operand:DI 0 "register_operand" "c,*l"))]
0ad91047 13845 "TARGET_64BIT"
b92b324d
DE
13846 "@
13847 bctr
13848 blr"
266eb58a
DE
13849 [(set_attr "type" "jmpreg")])
13850
1fd4e8c1
RK
13851;; Table jump for switch statements:
13852(define_expand "tablejump"
e6ca2c17
DE
13853 [(use (match_operand 0 "" ""))
13854 (use (label_ref (match_operand 1 "" "")))]
13855 ""
13856 "
13857{
13858 if (TARGET_32BIT)
13859 emit_jump_insn (gen_tablejumpsi (operands[0], operands[1]));
13860 else
13861 emit_jump_insn (gen_tablejumpdi (operands[0], operands[1]));
13862 DONE;
13863}")
13864
13865(define_expand "tablejumpsi"
1fd4e8c1
RK
13866 [(set (match_dup 3)
13867 (plus:SI (match_operand:SI 0 "" "")
13868 (match_dup 2)))
13869 (parallel [(set (pc) (match_dup 3))
13870 (use (label_ref (match_operand 1 "" "")))])]
0ad91047 13871 "TARGET_32BIT"
1fd4e8c1
RK
13872 "
13873{ operands[0] = force_reg (SImode, operands[0]);
c5c76735 13874 operands[2] = force_reg (SImode, gen_rtx_LABEL_REF (SImode, operands[1]));
1fd4e8c1
RK
13875 operands[3] = gen_reg_rtx (SImode);
13876}")
13877
e6ca2c17 13878(define_expand "tablejumpdi"
9ebbca7d
GK
13879 [(set (match_dup 4)
13880 (sign_extend:DI (match_operand:SI 0 "lwa_operand" "rm")))
13881 (set (match_dup 3)
13882 (plus:DI (match_dup 4)
e6ca2c17
DE
13883 (match_dup 2)))
13884 (parallel [(set (pc) (match_dup 3))
13885 (use (label_ref (match_operand 1 "" "")))])]
0ad91047 13886 "TARGET_64BIT"
e6ca2c17 13887 "
9ebbca7d 13888{ operands[2] = force_reg (DImode, gen_rtx_LABEL_REF (DImode, operands[1]));
e6ca2c17 13889 operands[3] = gen_reg_rtx (DImode);
9ebbca7d 13890 operands[4] = gen_reg_rtx (DImode);
e6ca2c17
DE
13891}")
13892
1fd4e8c1
RK
13893(define_insn ""
13894 [(set (pc)
c859cda6 13895 (match_operand:SI 0 "register_operand" "c,*l"))
1fd4e8c1 13896 (use (label_ref (match_operand 1 "" "")))]
0ad91047 13897 "TARGET_32BIT"
c859cda6
DJ
13898 "@
13899 bctr
13900 {br|blr}"
a6845123 13901 [(set_attr "type" "jmpreg")])
1fd4e8c1 13902
266eb58a
DE
13903(define_insn ""
13904 [(set (pc)
c859cda6 13905 (match_operand:DI 0 "register_operand" "c,*l"))
266eb58a 13906 (use (label_ref (match_operand 1 "" "")))]
0ad91047 13907 "TARGET_64BIT"
c859cda6
DJ
13908 "@
13909 bctr
13910 blr"
266eb58a
DE
13911 [(set_attr "type" "jmpreg")])
13912
1fd4e8c1
RK
13913(define_insn "nop"
13914 [(const_int 0)]
13915 ""
ca7f5001 13916 "{cror 0,0,0|nop}")
1fd4e8c1 13917\f
7e69e155 13918;; Define the subtract-one-and-jump insns, starting with the template
c225ba7b
RK
13919;; so loop.c knows what to generate.
13920
5527bf14
RH
13921(define_expand "doloop_end"
13922 [(use (match_operand 0 "" "")) ; loop pseudo
13923 (use (match_operand 1 "" "")) ; iterations; zero if unknown
13924 (use (match_operand 2 "" "")) ; max iterations
13925 (use (match_operand 3 "" "")) ; loop level
13926 (use (match_operand 4 "" ""))] ; label
0ad91047
DE
13927 ""
13928 "
13929{
5527bf14
RH
13930 /* Only use this on innermost loops. */
13931 if (INTVAL (operands[3]) > 1)
13932 FAIL;
683bdff7 13933 if (TARGET_64BIT)
5527bf14
RH
13934 {
13935 if (GET_MODE (operands[0]) != DImode)
13936 FAIL;
13937 emit_jump_insn (gen_ctrdi (operands[0], operands[4]));
13938 }
0ad91047 13939 else
5527bf14
RH
13940 {
13941 if (GET_MODE (operands[0]) != SImode)
13942 FAIL;
13943 emit_jump_insn (gen_ctrsi (operands[0], operands[4]));
13944 }
0ad91047
DE
13945 DONE;
13946}")
13947
13948(define_expand "ctrsi"
3cb999d8
DE
13949 [(parallel [(set (pc)
13950 (if_then_else (ne (match_operand:SI 0 "register_operand" "")
13951 (const_int 1))
13952 (label_ref (match_operand 1 "" ""))
13953 (pc)))
b6c9286a
MM
13954 (set (match_dup 0)
13955 (plus:SI (match_dup 0)
13956 (const_int -1)))
5f81043f
RK
13957 (clobber (match_scratch:CC 2 ""))
13958 (clobber (match_scratch:SI 3 ""))])]
683bdff7 13959 "TARGET_32BIT"
0ad91047
DE
13960 "")
13961
13962(define_expand "ctrdi"
3cb999d8
DE
13963 [(parallel [(set (pc)
13964 (if_then_else (ne (match_operand:DI 0 "register_operand" "")
13965 (const_int 1))
13966 (label_ref (match_operand 1 "" ""))
13967 (pc)))
0ad91047
DE
13968 (set (match_dup 0)
13969 (plus:DI (match_dup 0)
13970 (const_int -1)))
13971 (clobber (match_scratch:CC 2 ""))
61c07d3c 13972 (clobber (match_scratch:DI 3 ""))])]
683bdff7 13973 "TARGET_64BIT"
61c07d3c 13974 "")
c225ba7b 13975
1fd4e8c1
RK
13976;; We need to be able to do this for any operand, including MEM, or we
13977;; will cause reload to blow up since we don't allow output reloads on
7e69e155 13978;; JUMP_INSNs.
0ad91047 13979;; For the length attribute to be calculated correctly, the
5f81043f
RK
13980;; label MUST be operand 0.
13981
0ad91047 13982(define_insn "*ctrsi_internal1"
1fd4e8c1 13983 [(set (pc)
43b68ce5 13984 (if_then_else (ne (match_operand:SI 1 "register_operand" "c,*r,*r,*r")
1fd4e8c1 13985 (const_int 1))
a6845123 13986 (label_ref (match_operand 0 "" ""))
1fd4e8c1 13987 (pc)))
43b68ce5 13988 (set (match_operand:SI 2 "register_operand" "=1,*r,m,*q*c*l")
5f81043f
RK
13989 (plus:SI (match_dup 1)
13990 (const_int -1)))
43b68ce5
DE
13991 (clobber (match_scratch:CC 3 "=X,&x,&x,&x"))
13992 (clobber (match_scratch:SI 4 "=X,X,&r,r"))]
683bdff7 13993 "TARGET_32BIT"
b19003d8
RK
13994 "*
13995{
af87a13e 13996 if (which_alternative != 0)
b19003d8 13997 return \"#\";
856a6884 13998 else if (get_attr_length (insn) == 4)
a6845123 13999 return \"{bdn|bdnz} %l0\";
b19003d8 14000 else
f607bc57 14001 return \"bdz $+8\;b %l0\";
b19003d8 14002}"
baf97f86 14003 [(set_attr "type" "branch")
5a195cb5 14004 (set_attr "length" "*,12,16,16")])
7e69e155 14005
0ad91047 14006(define_insn "*ctrsi_internal2"
5f81043f 14007 [(set (pc)
43b68ce5 14008 (if_then_else (ne (match_operand:SI 1 "register_operand" "c,*r,*r,*r")
5f81043f
RK
14009 (const_int 1))
14010 (pc)
14011 (label_ref (match_operand 0 "" ""))))
43b68ce5 14012 (set (match_operand:SI 2 "register_operand" "=1,*r,m,*q*c*l")
5f81043f
RK
14013 (plus:SI (match_dup 1)
14014 (const_int -1)))
43b68ce5
DE
14015 (clobber (match_scratch:CC 3 "=X,&x,&x,&x"))
14016 (clobber (match_scratch:SI 4 "=X,X,&r,r"))]
683bdff7 14017 "TARGET_32BIT"
0ad91047
DE
14018 "*
14019{
14020 if (which_alternative != 0)
14021 return \"#\";
856a6884 14022 else if (get_attr_length (insn) == 4)
0ad91047
DE
14023 return \"bdz %l0\";
14024 else
f607bc57 14025 return \"{bdn|bdnz} $+8\;b %l0\";
0ad91047
DE
14026}"
14027 [(set_attr "type" "branch")
5a195cb5 14028 (set_attr "length" "*,12,16,16")])
0ad91047
DE
14029
14030(define_insn "*ctrdi_internal1"
14031 [(set (pc)
43b68ce5 14032 (if_then_else (ne (match_operand:DI 1 "register_operand" "c,*r,*r,*r")
0ad91047
DE
14033 (const_int 1))
14034 (label_ref (match_operand 0 "" ""))
14035 (pc)))
43b68ce5 14036 (set (match_operand:DI 2 "register_operand" "=1,*r,m,*c*l")
0ad91047
DE
14037 (plus:DI (match_dup 1)
14038 (const_int -1)))
43b68ce5
DE
14039 (clobber (match_scratch:CC 3 "=X,&x,&x,&x"))
14040 (clobber (match_scratch:DI 4 "=X,X,&r,r"))]
683bdff7 14041 "TARGET_64BIT"
0ad91047
DE
14042 "*
14043{
14044 if (which_alternative != 0)
14045 return \"#\";
856a6884 14046 else if (get_attr_length (insn) == 4)
0ad91047
DE
14047 return \"{bdn|bdnz} %l0\";
14048 else
f607bc57 14049 return \"bdz $+8\;b %l0\";
0ad91047
DE
14050}"
14051 [(set_attr "type" "branch")
5a195cb5 14052 (set_attr "length" "*,12,16,16")])
0ad91047
DE
14053
14054(define_insn "*ctrdi_internal2"
14055 [(set (pc)
43b68ce5 14056 (if_then_else (ne (match_operand:DI 1 "register_operand" "c,*r,*r,*r")
0ad91047
DE
14057 (const_int 1))
14058 (pc)
14059 (label_ref (match_operand 0 "" ""))))
43b68ce5 14060 (set (match_operand:DI 2 "register_operand" "=1,*r,m,*c*l")
0ad91047
DE
14061 (plus:DI (match_dup 1)
14062 (const_int -1)))
43b68ce5
DE
14063 (clobber (match_scratch:CC 3 "=X,&x,&x,&x"))
14064 (clobber (match_scratch:DI 4 "=X,X,&r,r"))]
683bdff7 14065 "TARGET_64BIT"
5f81043f
RK
14066 "*
14067{
14068 if (which_alternative != 0)
14069 return \"#\";
856a6884 14070 else if (get_attr_length (insn) == 4)
5f81043f
RK
14071 return \"bdz %l0\";
14072 else
f607bc57 14073 return \"{bdn|bdnz} $+8\;b %l0\";
5f81043f
RK
14074}"
14075 [(set_attr "type" "branch")
5a195cb5 14076 (set_attr "length" "*,12,16,16")])
5f81043f 14077
c225ba7b 14078;; Similar, but we can use GE since we have a REG_NONNEG.
0ad91047
DE
14079
14080(define_insn "*ctrsi_internal3"
1fd4e8c1 14081 [(set (pc)
43b68ce5 14082 (if_then_else (ge (match_operand:SI 1 "register_operand" "c,*r,*r,*r")
1fd4e8c1 14083 (const_int 0))
a6845123 14084 (label_ref (match_operand 0 "" ""))
1fd4e8c1 14085 (pc)))
43b68ce5 14086 (set (match_operand:SI 2 "register_operand" "=1,*r,m,*q*c*l")
5f81043f
RK
14087 (plus:SI (match_dup 1)
14088 (const_int -1)))
43b68ce5
DE
14089 (clobber (match_scratch:CC 3 "=X,&x,&x,&x"))
14090 (clobber (match_scratch:SI 4 "=X,X,&r,r"))]
683bdff7 14091 "TARGET_32BIT && find_reg_note (insn, REG_NONNEG, 0)"
b19003d8
RK
14092 "*
14093{
af87a13e 14094 if (which_alternative != 0)
b19003d8 14095 return \"#\";
856a6884 14096 else if (get_attr_length (insn) == 4)
a6845123 14097 return \"{bdn|bdnz} %l0\";
b19003d8 14098 else
f607bc57 14099 return \"bdz $+8\;b %l0\";
b19003d8 14100}"
baf97f86 14101 [(set_attr "type" "branch")
5a195cb5 14102 (set_attr "length" "*,12,16,16")])
7e69e155 14103
0ad91047 14104(define_insn "*ctrsi_internal4"
1fd4e8c1 14105 [(set (pc)
43b68ce5 14106 (if_then_else (ge (match_operand:SI 1 "register_operand" "c,*r,*r,*r")
5f81043f
RK
14107 (const_int 0))
14108 (pc)
14109 (label_ref (match_operand 0 "" ""))))
43b68ce5 14110 (set (match_operand:SI 2 "register_operand" "=1,*r,m,*q*c*l")
5f81043f
RK
14111 (plus:SI (match_dup 1)
14112 (const_int -1)))
43b68ce5
DE
14113 (clobber (match_scratch:CC 3 "=X,&x,&x,&x"))
14114 (clobber (match_scratch:SI 4 "=X,X,&r,r"))]
683bdff7 14115 "TARGET_32BIT && find_reg_note (insn, REG_NONNEG, 0)"
5f81043f
RK
14116 "*
14117{
14118 if (which_alternative != 0)
14119 return \"#\";
856a6884 14120 else if (get_attr_length (insn) == 4)
5f81043f
RK
14121 return \"bdz %l0\";
14122 else
f607bc57 14123 return \"{bdn|bdnz} $+8\;b %l0\";
5f81043f
RK
14124}"
14125 [(set_attr "type" "branch")
5a195cb5 14126 (set_attr "length" "*,12,16,16")])
5f81043f 14127
0ad91047
DE
14128(define_insn "*ctrdi_internal3"
14129 [(set (pc)
43b68ce5 14130 (if_then_else (ge (match_operand:DI 1 "register_operand" "c,*r,*r,*r")
0ad91047
DE
14131 (const_int 0))
14132 (label_ref (match_operand 0 "" ""))
14133 (pc)))
43b68ce5 14134 (set (match_operand:DI 2 "register_operand" "=1,*r,m,*c*l")
0ad91047
DE
14135 (plus:DI (match_dup 1)
14136 (const_int -1)))
43b68ce5
DE
14137 (clobber (match_scratch:CC 3 "=X,&x,&x,&x"))
14138 (clobber (match_scratch:DI 4 "=X,X,&r,r"))]
683bdff7 14139 "TARGET_64BIT && find_reg_note (insn, REG_NONNEG, 0)"
0ad91047
DE
14140 "*
14141{
14142 if (which_alternative != 0)
14143 return \"#\";
856a6884 14144 else if (get_attr_length (insn) == 4)
0ad91047
DE
14145 return \"{bdn|bdnz} %l0\";
14146 else
f607bc57 14147 return \"bdz $+8\;b %l0\";
0ad91047
DE
14148}"
14149 [(set_attr "type" "branch")
5a195cb5 14150 (set_attr "length" "*,12,16,16")])
0ad91047
DE
14151
14152(define_insn "*ctrdi_internal4"
14153 [(set (pc)
43b68ce5 14154 (if_then_else (ge (match_operand:DI 1 "register_operand" "c,*r,*r,*r")
0ad91047
DE
14155 (const_int 0))
14156 (pc)
14157 (label_ref (match_operand 0 "" ""))))
43b68ce5 14158 (set (match_operand:DI 2 "register_operand" "=1,*r,m,*c*l")
0ad91047
DE
14159 (plus:DI (match_dup 1)
14160 (const_int -1)))
43b68ce5
DE
14161 (clobber (match_scratch:CC 3 "=X,&x,&x,&x"))
14162 (clobber (match_scratch:DI 4 "=X,X,&r,r"))]
683bdff7 14163 "TARGET_64BIT && find_reg_note (insn, REG_NONNEG, 0)"
0ad91047
DE
14164 "*
14165{
14166 if (which_alternative != 0)
14167 return \"#\";
856a6884 14168 else if (get_attr_length (insn) == 4)
0ad91047
DE
14169 return \"bdz %l0\";
14170 else
f607bc57 14171 return \"{bdn|bdnz} $+8\;b %l0\";
0ad91047
DE
14172}"
14173 [(set_attr "type" "branch")
5a195cb5 14174 (set_attr "length" "*,12,16,16")])
0ad91047
DE
14175
14176;; Similar but use EQ
14177
14178(define_insn "*ctrsi_internal5"
5f81043f 14179 [(set (pc)
43b68ce5 14180 (if_then_else (eq (match_operand:SI 1 "register_operand" "c,*r,*r,*r")
1fd4e8c1 14181 (const_int 1))
a6845123 14182 (label_ref (match_operand 0 "" ""))
1fd4e8c1 14183 (pc)))
43b68ce5 14184 (set (match_operand:SI 2 "register_operand" "=1,*r,m,*q*c*l")
5f81043f
RK
14185 (plus:SI (match_dup 1)
14186 (const_int -1)))
43b68ce5
DE
14187 (clobber (match_scratch:CC 3 "=X,&x,&x,&x"))
14188 (clobber (match_scratch:SI 4 "=X,X,&r,r"))]
683bdff7 14189 "TARGET_32BIT"
b19003d8
RK
14190 "*
14191{
af87a13e 14192 if (which_alternative != 0)
b19003d8 14193 return \"#\";
856a6884 14194 else if (get_attr_length (insn) == 4)
a6845123 14195 return \"bdz %l0\";
b19003d8 14196 else
f607bc57 14197 return \"{bdn|bdnz} $+8\;b %l0\";
b19003d8 14198}"
baf97f86 14199 [(set_attr "type" "branch")
5a195cb5 14200 (set_attr "length" "*,12,16,16")])
1fd4e8c1 14201
0ad91047 14202(define_insn "*ctrsi_internal6"
5f81043f 14203 [(set (pc)
43b68ce5 14204 (if_then_else (eq (match_operand:SI 1 "register_operand" "c,*r,*r,*r")
5f81043f
RK
14205 (const_int 1))
14206 (pc)
14207 (label_ref (match_operand 0 "" ""))))
43b68ce5 14208 (set (match_operand:SI 2 "register_operand" "=1,*r,m,*q*c*l")
5f81043f
RK
14209 (plus:SI (match_dup 1)
14210 (const_int -1)))
43b68ce5
DE
14211 (clobber (match_scratch:CC 3 "=X,&x,&x,&x"))
14212 (clobber (match_scratch:SI 4 "=X,X,&r,r"))]
683bdff7 14213 "TARGET_32BIT"
0ad91047
DE
14214 "*
14215{
14216 if (which_alternative != 0)
14217 return \"#\";
856a6884 14218 else if (get_attr_length (insn) == 4)
0ad91047
DE
14219 return \"{bdn|bdnz} %l0\";
14220 else
f607bc57 14221 return \"bdz $+8\;b %l0\";
0ad91047
DE
14222}"
14223 [(set_attr "type" "branch")
5a195cb5 14224 (set_attr "length" "*,12,16,16")])
0ad91047
DE
14225
14226(define_insn "*ctrdi_internal5"
14227 [(set (pc)
43b68ce5 14228 (if_then_else (eq (match_operand:DI 1 "register_operand" "c,*r,*r,*r")
0ad91047
DE
14229 (const_int 1))
14230 (label_ref (match_operand 0 "" ""))
14231 (pc)))
43b68ce5 14232 (set (match_operand:DI 2 "register_operand" "=1,*r,m,*c*l")
0ad91047
DE
14233 (plus:DI (match_dup 1)
14234 (const_int -1)))
43b68ce5
DE
14235 (clobber (match_scratch:CC 3 "=X,&x,&x,&x"))
14236 (clobber (match_scratch:DI 4 "=X,X,&r,r"))]
683bdff7 14237 "TARGET_64BIT"
0ad91047
DE
14238 "*
14239{
14240 if (which_alternative != 0)
14241 return \"#\";
856a6884 14242 else if (get_attr_length (insn) == 4)
0ad91047
DE
14243 return \"bdz %l0\";
14244 else
f607bc57 14245 return \"{bdn|bdnz} $+8\;b %l0\";
0ad91047
DE
14246}"
14247 [(set_attr "type" "branch")
5a195cb5 14248 (set_attr "length" "*,12,16,16")])
0ad91047
DE
14249
14250(define_insn "*ctrdi_internal6"
14251 [(set (pc)
43b68ce5 14252 (if_then_else (eq (match_operand:DI 1 "register_operand" "c,*r,*r,*r")
0ad91047
DE
14253 (const_int 1))
14254 (pc)
14255 (label_ref (match_operand 0 "" ""))))
43b68ce5 14256 (set (match_operand:DI 2 "register_operand" "=1,*r,m,*c*l")
0ad91047
DE
14257 (plus:DI (match_dup 1)
14258 (const_int -1)))
43b68ce5
DE
14259 (clobber (match_scratch:CC 3 "=X,&x,&x,&x"))
14260 (clobber (match_scratch:DI 4 "=X,X,&r,r"))]
683bdff7 14261 "TARGET_64BIT"
5f81043f
RK
14262 "*
14263{
14264 if (which_alternative != 0)
14265 return \"#\";
856a6884 14266 else if (get_attr_length (insn) == 4)
5f81043f
RK
14267 return \"{bdn|bdnz} %l0\";
14268 else
f607bc57 14269 return \"bdz $+8\;b %l0\";
5f81043f
RK
14270}"
14271 [(set_attr "type" "branch")
5a195cb5 14272 (set_attr "length" "*,12,16,16")])
5f81043f 14273
0ad91047
DE
14274;; Now the splitters if we could not allocate the CTR register
14275
1fd4e8c1
RK
14276(define_split
14277 [(set (pc)
14278 (if_then_else (match_operator 2 "comparison_operator"
cd2b37d9 14279 [(match_operand:SI 1 "gpc_reg_operand" "")
1fd4e8c1
RK
14280 (const_int 1)])
14281 (match_operand 5 "" "")
14282 (match_operand 6 "" "")))
cd2b37d9 14283 (set (match_operand:SI 0 "gpc_reg_operand" "")
5f81043f
RK
14284 (plus:SI (match_dup 1)
14285 (const_int -1)))
1fd4e8c1
RK
14286 (clobber (match_scratch:CC 3 ""))
14287 (clobber (match_scratch:SI 4 ""))]
0ad91047 14288 "! TARGET_POWERPC64 && reload_completed"
1fd4e8c1 14289 [(parallel [(set (match_dup 3)
5f81043f
RK
14290 (compare:CC (plus:SI (match_dup 1)
14291 (const_int -1))
1fd4e8c1 14292 (const_int 0)))
5f81043f
RK
14293 (set (match_dup 0)
14294 (plus:SI (match_dup 1)
14295 (const_int -1)))])
14296 (set (pc) (if_then_else (match_dup 7)
14297 (match_dup 5)
14298 (match_dup 6)))]
1fd4e8c1
RK
14299 "
14300{ operands[7] = gen_rtx (GET_CODE (operands[2]), VOIDmode, operands[3],
14301 const0_rtx); }")
14302
14303(define_split
14304 [(set (pc)
14305 (if_then_else (match_operator 2 "comparison_operator"
cd2b37d9 14306 [(match_operand:SI 1 "gpc_reg_operand" "")
1fd4e8c1
RK
14307 (const_int 1)])
14308 (match_operand 5 "" "")
14309 (match_operand 6 "" "")))
9ebbca7d 14310 (set (match_operand:SI 0 "nonimmediate_operand" "")
1fd4e8c1
RK
14311 (plus:SI (match_dup 1) (const_int -1)))
14312 (clobber (match_scratch:CC 3 ""))
14313 (clobber (match_scratch:SI 4 ""))]
0ad91047
DE
14314 "! TARGET_POWERPC64 && reload_completed
14315 && ! gpc_reg_operand (operands[0], SImode)"
1fd4e8c1 14316 [(parallel [(set (match_dup 3)
5f81043f
RK
14317 (compare:CC (plus:SI (match_dup 1)
14318 (const_int -1))
1fd4e8c1 14319 (const_int 0)))
5f81043f
RK
14320 (set (match_dup 4)
14321 (plus:SI (match_dup 1)
14322 (const_int -1)))])
14323 (set (match_dup 0)
14324 (match_dup 4))
14325 (set (pc) (if_then_else (match_dup 7)
14326 (match_dup 5)
14327 (match_dup 6)))]
1fd4e8c1
RK
14328 "
14329{ operands[7] = gen_rtx (GET_CODE (operands[2]), VOIDmode, operands[3],
14330 const0_rtx); }")
0ad91047
DE
14331(define_split
14332 [(set (pc)
14333 (if_then_else (match_operator 2 "comparison_operator"
14334 [(match_operand:DI 1 "gpc_reg_operand" "")
14335 (const_int 1)])
61c07d3c
DE
14336 (match_operand 5 "" "")
14337 (match_operand 6 "" "")))
0ad91047
DE
14338 (set (match_operand:DI 0 "gpc_reg_operand" "")
14339 (plus:DI (match_dup 1)
14340 (const_int -1)))
14341 (clobber (match_scratch:CC 3 ""))
61c07d3c 14342 (clobber (match_scratch:DI 4 ""))]
683bdff7 14343 "TARGET_64BIT && reload_completed"
0ad91047
DE
14344 [(parallel [(set (match_dup 3)
14345 (compare:CC (plus:DI (match_dup 1)
14346 (const_int -1))
14347 (const_int 0)))
14348 (set (match_dup 0)
14349 (plus:DI (match_dup 1)
14350 (const_int -1)))])
61c07d3c
DE
14351 (set (pc) (if_then_else (match_dup 7)
14352 (match_dup 5)
14353 (match_dup 6)))]
0ad91047 14354 "
61c07d3c 14355{ operands[7] = gen_rtx (GET_CODE (operands[2]), VOIDmode, operands[3],
0ad91047
DE
14356 const0_rtx); }")
14357
14358(define_split
14359 [(set (pc)
14360 (if_then_else (match_operator 2 "comparison_operator"
14361 [(match_operand:DI 1 "gpc_reg_operand" "")
14362 (const_int 1)])
61c07d3c
DE
14363 (match_operand 5 "" "")
14364 (match_operand 6 "" "")))
9ebbca7d 14365 (set (match_operand:DI 0 "nonimmediate_operand" "")
0ad91047
DE
14366 (plus:DI (match_dup 1) (const_int -1)))
14367 (clobber (match_scratch:CC 3 ""))
61c07d3c 14368 (clobber (match_scratch:DI 4 ""))]
683bdff7 14369 "TARGET_64BIT && reload_completed
0ad91047
DE
14370 && ! gpc_reg_operand (operands[0], DImode)"
14371 [(parallel [(set (match_dup 3)
14372 (compare:CC (plus:DI (match_dup 1)
14373 (const_int -1))
14374 (const_int 0)))
14375 (set (match_dup 4)
14376 (plus:DI (match_dup 1)
14377 (const_int -1)))])
14378 (set (match_dup 0)
14379 (match_dup 4))
61c07d3c
DE
14380 (set (pc) (if_then_else (match_dup 7)
14381 (match_dup 5)
14382 (match_dup 6)))]
0ad91047 14383 "
61c07d3c 14384{ operands[7] = gen_rtx (GET_CODE (operands[2]), VOIDmode, operands[3],
0ad91047 14385 const0_rtx); }")
c94ccb87 14386
683bdff7
FJ
14387; These two are for 64-bit hardware running 32-bit mode.
14388; We don't use the add. instruction in this mode.
14389(define_split
14390 [(set (pc)
14391 (if_then_else (match_operator 2 "comparison_operator"
14392 [(match_operand:SI 1 "gpc_reg_operand" "")
14393 (const_int 1)])
14394 (match_operand 5 "" "")
14395 (match_operand 6 "" "")))
14396 (set (match_operand:SI 0 "gpc_reg_operand" "")
14397 (plus:SI (match_dup 1)
14398 (const_int -1)))
14399 (clobber (match_scratch:CC 3 ""))
14400 (clobber (match_scratch:SI 4 ""))]
14401 "TARGET_POWERPC64 && TARGET_32BIT && reload_completed"
14402 [(set (match_dup 0)
14403 (plus:SI (match_dup 1)
14404 (const_int -1)))
14405 (set (match_dup 3)
14406 (compare:CC (match_dup 0)
14407 (const_int 0)))
14408 (set (pc) (if_then_else (match_dup 7)
14409 (match_dup 5)
14410 (match_dup 6)))]
14411 "
14412{ operands[7] = gen_rtx (GET_CODE (operands[2]), VOIDmode, operands[3],
14413 const0_rtx); }")
14414
14415(define_split
14416 [(set (pc)
14417 (if_then_else (match_operator 2 "comparison_operator"
14418 [(match_operand:SI 1 "gpc_reg_operand" "")
14419 (const_int 1)])
14420 (match_operand 5 "" "")
14421 (match_operand 6 "" "")))
14422 (set (match_operand:SI 0 "nonimmediate_operand" "")
14423 (plus:SI (match_dup 1) (const_int -1)))
14424 (clobber (match_scratch:CC 3 ""))
14425 (clobber (match_scratch:SI 4 ""))]
14426 "TARGET_POWERPC64 && TARGET_32BIT && reload_completed
14427 && ! gpc_reg_operand (operands[0], SImode)"
14428 [(set (match_dup 4)
14429 (plus:SI (match_dup 1)
14430 (const_int -1)))
14431 (set (match_dup 3)
14432 (compare:CC (match_dup 4)
14433 (const_int 0)))
14434 (set (match_dup 0)
14435 (match_dup 4))
14436 (set (pc) (if_then_else (match_dup 7)
14437 (match_dup 5)
14438 (match_dup 6)))]
14439 "
14440{ operands[7] = gen_rtx (GET_CODE (operands[2]), VOIDmode, operands[3],
14441 const0_rtx); }")
14442
e0cd0770
JC
14443\f
14444(define_insn "trap"
14445 [(trap_if (const_int 1) (const_int 0))]
14446 ""
14447 "{t 31,0,0|trap}")
14448
14449(define_expand "conditional_trap"
14450 [(trap_if (match_operator 0 "trap_comparison_operator"
14451 [(match_dup 2) (match_dup 3)])
14452 (match_operand 1 "const_int_operand" ""))]
14453 ""
14454 "if (rs6000_compare_fp_p || operands[1] != const0_rtx) FAIL;
14455 operands[2] = rs6000_compare_op0;
14456 operands[3] = rs6000_compare_op1;")
14457
14458(define_insn ""
14459 [(trap_if (match_operator 0 "trap_comparison_operator"
14460 [(match_operand:SI 1 "register_operand" "r")
14461 (match_operand:SI 2 "reg_or_short_operand" "rI")])
14462 (const_int 0))]
14463 ""
a157febd
GK
14464 "{t|tw}%V0%I2 %1,%2")
14465
14466(define_insn ""
14467 [(trap_if (match_operator 0 "trap_comparison_operator"
14468 [(match_operand:DI 1 "register_operand" "r")
14469 (match_operand:DI 2 "reg_or_short_operand" "rI")])
14470 (const_int 0))]
14471 "TARGET_POWERPC64"
14472 "td%V0%I2 %1,%2")
9ebbca7d
GK
14473\f
14474;; Insns related to generating the function prologue and epilogue.
14475
14476(define_expand "prologue"
14477 [(use (const_int 0))]
14478 "TARGET_SCHED_PROLOG"
14479 "
14480{
14481 rs6000_emit_prologue ();
14482 DONE;
14483}")
14484
2c4a9cff
DE
14485(define_insn "*movesi_from_cr_one"
14486 [(match_parallel 0 "mfcr_operation"
14487 [(set (match_operand:SI 1 "gpc_reg_operand" "=r")
14488 (unspec:SI [(match_operand:CC 2 "cc_reg_operand" "y")
14489 (match_operand 3 "immediate_operand" "n")]
14490 UNSPEC_MOVESI_FROM_CR))])]
14491 "TARGET_MFCRF"
14492 "*
14493{
14494 int mask = 0;
14495 int i;
14496 for (i = 0; i < XVECLEN (operands[0], 0); i++)
14497 {
14498 mask = INTVAL (XVECEXP (SET_SRC (XVECEXP (operands[0], 0, i)), 0, 1));
14499 operands[4] = GEN_INT (mask);
14500 output_asm_insn (\"mfcr %1,%4\", operands);
14501 }
14502 return \"\";
14503}"
14504 [(set_attr "type" "mfcrf")])
14505
9ebbca7d
GK
14506(define_insn "movesi_from_cr"
14507 [(set (match_operand:SI 0 "gpc_reg_operand" "=r")
14508 (unspec:SI [(reg:CC 68) (reg:CC 69) (reg:CC 70) (reg:CC 71)
615158e2
JJ
14509 (reg:CC 72) (reg:CC 73) (reg:CC 74) (reg:CC 75)]
14510 UNSPEC_MOVESI_FROM_CR))]
9ebbca7d 14511 ""
309323c2 14512 "mfcr %0"
b54cf83a 14513 [(set_attr "type" "mfcr")])
9ebbca7d
GK
14514
14515(define_insn "*stmw"
e033a023
DE
14516 [(match_parallel 0 "stmw_operation"
14517 [(set (match_operand:SI 1 "memory_operand" "=m")
14518 (match_operand:SI 2 "gpc_reg_operand" "r"))])]
14519 "TARGET_MULTIPLE"
14520 "{stm|stmw} %2,%1")
9ebbca7d
GK
14521
14522(define_insn "*save_fpregs_si"
e033a023
DE
14523 [(match_parallel 0 "any_operand"
14524 [(clobber (match_operand:SI 1 "register_operand" "=l"))
14525 (use (match_operand:SI 2 "call_operand" "s"))
14526 (set (match_operand:DF 3 "memory_operand" "=m")
14527 (match_operand:DF 4 "gpc_reg_operand" "f"))])]
14528 "TARGET_32BIT"
14529 "bl %z2"
14530 [(set_attr "type" "branch")
14531 (set_attr "length" "4")])
9ebbca7d
GK
14532
14533(define_insn "*save_fpregs_di"
e033a023
DE
14534 [(match_parallel 0 "any_operand"
14535 [(clobber (match_operand:DI 1 "register_operand" "=l"))
14536 (use (match_operand:DI 2 "call_operand" "s"))
14537 (set (match_operand:DF 3 "memory_operand" "=m")
14538 (match_operand:DF 4 "gpc_reg_operand" "f"))])]
14539 "TARGET_64BIT"
14540 "bl %z2"
14541 [(set_attr "type" "branch")
14542 (set_attr "length" "4")])
9ebbca7d
GK
14543
14544; These are to explain that changes to the stack pointer should
14545; not be moved over stores to stack memory.
14546(define_insn "stack_tie"
14547 [(set (match_operand:BLK 0 "memory_operand" "+m")
615158e2 14548 (unspec:BLK [(match_dup 0)] UNSPEC_TIE))]
9ebbca7d
GK
14549 ""
14550 ""
14551 [(set_attr "length" "0")])
14552
14553
14554(define_expand "epilogue"
14555 [(use (const_int 0))]
14556 "TARGET_SCHED_PROLOG"
14557 "
14558{
14559 rs6000_emit_epilogue (FALSE);
14560 DONE;
14561}")
14562
14563; On some processors, doing the mtcrf one CC register at a time is
14564; faster (like on the 604e). On others, doing them all at once is
14565; faster; for instance, on the 601 and 750.
14566
14567(define_expand "movsi_to_cr_one"
35aba846
DE
14568 [(set (match_operand:CC 0 "cc_reg_operand" "=y")
14569 (unspec:CC [(match_operand:SI 1 "gpc_reg_operand" "r")
615158e2 14570 (match_dup 2)] UNSPEC_MOVESI_TO_CR))]
35aba846
DE
14571 ""
14572 "operands[2] = GEN_INT (1 << (75 - REGNO (operands[0])));")
9ebbca7d
GK
14573
14574(define_insn "*movsi_to_cr"
35aba846
DE
14575 [(match_parallel 0 "mtcrf_operation"
14576 [(set (match_operand:CC 1 "cc_reg_operand" "=y")
14577 (unspec:CC [(match_operand:SI 2 "gpc_reg_operand" "r")
14578 (match_operand 3 "immediate_operand" "n")]
615158e2 14579 UNSPEC_MOVESI_TO_CR))])]
9ebbca7d 14580 ""
e35b9579
GK
14581 "*
14582{
14583 int mask = 0;
14584 int i;
14585 for (i = 0; i < XVECLEN (operands[0], 0); i++)
14586 mask |= INTVAL (XVECEXP (SET_SRC (XVECEXP (operands[0], 0, i)), 0, 1));
14587 operands[4] = GEN_INT (mask);
14588 return \"mtcrf %4,%2\";
309323c2 14589}"
b54cf83a 14590 [(set_attr "type" "mtcr")])
9ebbca7d 14591
b54cf83a 14592(define_insn "*mtcrfsi"
309323c2
DE
14593 [(set (match_operand:CC 0 "cc_reg_operand" "=y")
14594 (unspec:CC [(match_operand:SI 1 "gpc_reg_operand" "r")
615158e2
JJ
14595 (match_operand 2 "immediate_operand" "n")]
14596 UNSPEC_MOVESI_TO_CR))]
309323c2
DE
14597 "GET_CODE (operands[0]) == REG
14598 && CR_REGNO_P (REGNO (operands[0]))
14599 && GET_CODE (operands[2]) == CONST_INT
14600 && INTVAL (operands[2]) == 1 << (75 - REGNO (operands[0]))"
14601 "mtcrf %R0,%1"
b54cf83a 14602 [(set_attr "type" "mtcr")])
9ebbca7d
GK
14603
14604; The load-multiple instructions have similar properties.
14605; Note that "load_multiple" is a name known to the machine-independent
14606; code that actually corresponds to the powerpc load-string.
14607
14608(define_insn "*lmw"
35aba846
DE
14609 [(match_parallel 0 "lmw_operation"
14610 [(set (match_operand:SI 1 "gpc_reg_operand" "=r")
14611 (match_operand:SI 2 "memory_operand" "m"))])]
14612 "TARGET_MULTIPLE"
14613 "{lm|lmw} %1,%2")
9ebbca7d
GK
14614
14615(define_insn "*return_internal_si"
e35b9579
GK
14616 [(return)
14617 (use (match_operand:SI 0 "register_operand" "lc"))]
9ebbca7d 14618 "TARGET_32BIT"
cccf3bdc 14619 "b%T0"
9ebbca7d
GK
14620 [(set_attr "type" "jmpreg")])
14621
14622(define_insn "*return_internal_di"
e35b9579
GK
14623 [(return)
14624 (use (match_operand:DI 0 "register_operand" "lc"))]
9ebbca7d 14625 "TARGET_64BIT"
cccf3bdc 14626 "b%T0"
9ebbca7d
GK
14627 [(set_attr "type" "jmpreg")])
14628
14629; FIXME: This would probably be somewhat simpler if the Cygnus sibcall
14630; stuff was in GCC. Oh, and "any_operand" is a bit flexible...
14631
14632(define_insn "*return_and_restore_fpregs_si"
14633 [(match_parallel 0 "any_operand"
e35b9579
GK
14634 [(return)
14635 (use (match_operand:SI 1 "register_operand" "l"))
9ebbca7d
GK
14636 (use (match_operand:SI 2 "call_operand" "s"))
14637 (set (match_operand:DF 3 "gpc_reg_operand" "=f")
14638 (match_operand:DF 4 "memory_operand" "m"))])]
14639 "TARGET_32BIT"
14640 "b %z2")
14641
14642(define_insn "*return_and_restore_fpregs_di"
14643 [(match_parallel 0 "any_operand"
e35b9579
GK
14644 [(return)
14645 (use (match_operand:DI 1 "register_operand" "l"))
9ebbca7d
GK
14646 (use (match_operand:DI 2 "call_operand" "s"))
14647 (set (match_operand:DF 3 "gpc_reg_operand" "=f")
14648 (match_operand:DF 4 "memory_operand" "m"))])]
14649 "TARGET_64BIT"
14650 "b %z2")
14651
83720594
RH
14652; This is used in compiling the unwind routines.
14653(define_expand "eh_return"
34dc173c 14654 [(use (match_operand 0 "general_operand" ""))]
9ebbca7d
GK
14655 ""
14656 "
14657{
83720594 14658 if (TARGET_32BIT)
34dc173c 14659 emit_insn (gen_eh_set_lr_si (operands[0]));
9ebbca7d 14660 else
34dc173c 14661 emit_insn (gen_eh_set_lr_di (operands[0]));
9ebbca7d
GK
14662 DONE;
14663}")
14664
83720594
RH
14665; We can't expand this before we know where the link register is stored.
14666(define_insn "eh_set_lr_si"
615158e2
JJ
14667 [(unspec_volatile [(match_operand:SI 0 "register_operand" "r")]
14668 UNSPECV_EH_RR)
466eb3e0 14669 (clobber (match_scratch:SI 1 "=&b"))]
83720594
RH
14670 "TARGET_32BIT"
14671 "#")
14672
14673(define_insn "eh_set_lr_di"
615158e2
JJ
14674 [(unspec_volatile [(match_operand:DI 0 "register_operand" "r")]
14675 UNSPECV_EH_RR)
466eb3e0 14676 (clobber (match_scratch:DI 1 "=&b"))]
83720594
RH
14677 "TARGET_64BIT"
14678 "#")
9ebbca7d
GK
14679
14680(define_split
615158e2 14681 [(unspec_volatile [(match_operand 0 "register_operand" "")] UNSPECV_EH_RR)
83720594
RH
14682 (clobber (match_scratch 1 ""))]
14683 "reload_completed"
14684 [(const_int 0)]
9ebbca7d
GK
14685 "
14686{
83720594 14687 rs6000_stack_t *info = rs6000_stack_info ();
9ebbca7d 14688
83720594
RH
14689 if (info->lr_save_p)
14690 {
14691 rtx frame_rtx = stack_pointer_rtx;
14692 int sp_offset = 0;
14693 rtx tmp;
9ebbca7d 14694
83720594
RH
14695 if (frame_pointer_needed
14696 || current_function_calls_alloca
14697 || info->total_size > 32767)
14698 {
14699 emit_move_insn (operands[1], gen_rtx_MEM (Pmode, frame_rtx));
14700 frame_rtx = operands[1];
14701 }
14702 else if (info->push_p)
14703 sp_offset = info->total_size;
9ebbca7d 14704
83720594
RH
14705 tmp = plus_constant (frame_rtx, info->lr_save_offset + sp_offset);
14706 tmp = gen_rtx_MEM (Pmode, tmp);
14707 emit_move_insn (tmp, operands[0]);
14708 }
14709 else
14710 emit_move_insn (gen_rtx_REG (Pmode, LINK_REGISTER_REGNUM), operands[0]);
14711 DONE;
14712}")
0ac081f6 14713
01a2ccd0
DE
14714(define_insn "prefetch"
14715 [(prefetch (match_operand:V4SI 0 "address_operand" "p")
6041bf2f
DE
14716 (match_operand:SI 1 "const_int_operand" "n")
14717 (match_operand:SI 2 "const_int_operand" "n"))]
01a2ccd0 14718 "TARGET_POWERPC"
6041bf2f
DE
14719 "*
14720{
01a2ccd0
DE
14721 if (GET_CODE (operands[0]) == REG)
14722 return INTVAL (operands[1]) ? \"dcbtst 0,%0\" : \"dcbt 0,%0\";
14723 return INTVAL (operands[1]) ? \"dcbtst %a0\" : \"dcbt %a0\";
6041bf2f
DE
14724}"
14725 [(set_attr "type" "load")])
a3170dc6 14726
10ed84db 14727(include "altivec.md")
a3170dc6 14728(include "spe.md")