]> git.ipfire.org Git - thirdparty/gcc.git/blame - gcc/config/rs6000/rs6000.md
crash16.C: Function name is the correct location for an error regarding a function.
[thirdparty/gcc.git] / gcc / config / rs6000 / rs6000.md
CommitLineData
996a5f59 1;; Machine description for IBM RISC System 6000 (POWER) for GNU C compiler
d24652ee 2;; Copyright (C) 1990, 1991, 1992, 1993, 1994, 1995, 1996, 1997, 1998,
8ef65e3d 3;; 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007
602ea4d3 4;; Free Software Foundation, Inc.
996a5f59 5;; Contributed by Richard Kenner (kenner@vlsi1.ultra.nyu.edu)
1fd4e8c1 6
5de601cf 7;; This file is part of GCC.
1fd4e8c1 8
5de601cf
NC
9;; GCC is free software; you can redistribute it and/or modify it
10;; under the terms of the GNU General Public License as published
2f83c7d6 11;; by the Free Software Foundation; either version 3, or (at your
5de601cf 12;; option) any later version.
1fd4e8c1 13
5de601cf
NC
14;; GCC is distributed in the hope that it will be useful, but WITHOUT
15;; ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
16;; or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public
17;; License for more details.
1fd4e8c1
RK
18
19;; You should have received a copy of the GNU General Public License
2f83c7d6
NC
20;; along with GCC; see the file COPYING3. If not see
21;; <http://www.gnu.org/licenses/>.
1fd4e8c1
RK
22
23;;- See file "rtl.def" for documentation on define_insn, match_*, et. al.
9ebbca7d 24
1de43f85
DE
25;;
26;; REGNOS
27;;
28
29(define_constants
30 [(MQ_REGNO 64)
31 (LR_REGNO 65)
32 (CTR_REGNO 66)
33 (CR0_REGNO 68)
34 (CR1_REGNO 69)
35 (CR2_REGNO 70)
36 (CR3_REGNO 71)
37 (CR4_REGNO 72)
38 (CR5_REGNO 73)
39 (CR6_REGNO 74)
40 (CR7_REGNO 75)
41 (MAX_CR_REGNO 75)
42 (XER_REGNO 76)
43 (FIRST_ALTIVEC_REGNO 77)
44 (LAST_ALTIVEC_REGNO 108)
45 (VRSAVE_REGNO 109)
46 (VSCR_REGNO 110)
47 (SPE_ACC_REGNO 111)
48 (SPEFSCR_REGNO 112)
49 (SFP_REGNO 113)
50 ])
51
615158e2
JJ
52;;
53;; UNSPEC usage
54;;
55
56(define_constants
57 [(UNSPEC_FRSP 0) ; frsp for POWER machines
58 (UNSPEC_TIE 5) ; tie stack contents and stack pointer
59 (UNSPEC_TOCPTR 6) ; address of a word pointing to the TOC
60 (UNSPEC_TOC 7) ; address of the TOC (more-or-less)
61 (UNSPEC_MOVSI_GOT 8)
62 (UNSPEC_MV_CR_OV 9) ; move_from_CR_ov_bit
63 (UNSPEC_FCTIWZ 10)
9719f3b7
DE
64 (UNSPEC_FRIM 11)
65 (UNSPEC_FRIN 12)
66 (UNSPEC_FRIP 13)
67 (UNSPEC_FRIZ 14)
615158e2
JJ
68 (UNSPEC_LD_MPIC 15) ; load_macho_picbase
69 (UNSPEC_MPIC_CORRECT 16) ; macho_correct_pic
70 (UNSPEC_TLSGD 17)
71 (UNSPEC_TLSLD 18)
72 (UNSPEC_MOVESI_FROM_CR 19)
73 (UNSPEC_MOVESI_TO_CR 20)
74 (UNSPEC_TLSDTPREL 21)
75 (UNSPEC_TLSDTPRELHA 22)
76 (UNSPEC_TLSDTPRELLO 23)
77 (UNSPEC_TLSGOTDTPREL 24)
78 (UNSPEC_TLSTPREL 25)
79 (UNSPEC_TLSTPRELHA 26)
80 (UNSPEC_TLSTPRELLO 27)
81 (UNSPEC_TLSGOTTPREL 28)
82 (UNSPEC_TLSTLS 29)
ecb62ae7 83 (UNSPEC_FIX_TRUNC_TF 30) ; fadd, rounding towards zero
cef6b86c 84 (UNSPEC_MV_CR_GT 31) ; move_from_CR_gt_bit
da4c340c 85 (UNSPEC_STFIWX 32)
9f0076e5
DE
86 (UNSPEC_POPCNTB 33)
87 (UNSPEC_FRES 34)
88 (UNSPEC_SP_SET 35)
89 (UNSPEC_SP_TEST 36)
90 (UNSPEC_SYNC 37)
91 (UNSPEC_LWSYNC 38)
92 (UNSPEC_ISYNC 39)
93 (UNSPEC_SYNC_OP 40)
94 (UNSPEC_ATOMIC 41)
95 (UNSPEC_CMPXCHG 42)
96 (UNSPEC_XCHG 43)
97 (UNSPEC_AND 44)
716019c0
JM
98 (UNSPEC_DLMZB 45)
99 (UNSPEC_DLMZB_CR 46)
100 (UNSPEC_DLMZB_STRLEN 47)
9c78b944 101 (UNSPEC_RSQRT 48)
615158e2
JJ
102 ])
103
104;;
105;; UNSPEC_VOLATILE usage
106;;
107
108(define_constants
109 [(UNSPECV_BLOCK 0)
b52110d4
DE
110 (UNSPECV_LL 1) ; load-locked
111 (UNSPECV_SC 2) ; store-conditional
615158e2
JJ
112 (UNSPECV_EH_RR 9) ; eh_reg_restore
113 ])
1fd4e8c1
RK
114\f
115;; Define an insn type attribute. This is used in function unit delay
116;; computations.
44cd321e 117(define_attr "type" "integer,two,three,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,var_delayed_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,isync,sync,load_l,store_c,shift,trap,insert_dword,var_shift_rotate,cntlz,exts,mffgpr,mftgpr"
1fd4e8c1
RK
118 (const_string "integer"))
119
b19003d8 120;; Length (in bytes).
6ae08853 121; '(pc)' in the following doesn't include the instruction itself; it is
6cbadf36 122; calculated as if the instruction had zero size.
b19003d8
RK
123(define_attr "length" ""
124 (if_then_else (eq_attr "type" "branch")
6cbadf36 125 (if_then_else (and (ge (minus (match_dup 0) (pc))
b19003d8 126 (const_int -32768))
6cbadf36
GK
127 (lt (minus (match_dup 0) (pc))
128 (const_int 32764)))
39a10a29
GK
129 (const_int 4)
130 (const_int 8))
b19003d8
RK
131 (const_int 4)))
132
cfb557c4
RK
133;; Processor type -- this attribute must exactly match the processor_type
134;; enumeration in rs6000.h.
135
edae5fe3 136(define_attr "cpu" "rios1,rios2,rs64a,mpccore,ppc403,ppc405,ppc440,ppc601,ppc603,ppc604,ppc604e,ppc620,ppc630,ppc750,ppc7400,ppc7450,ppc8540,ppce300c2,ppce300c3,ppce500mc,power4,power5,power6,cell"
cfb557c4
RK
137 (const (symbol_ref "rs6000_cpu_attr")))
138
d296e02e
AP
139
140;; If this instruction is microcoded on the CELL processor
141; The default for load and stores is conditional
142; The default for load extended and the recorded instructions is always microcoded
143(define_attr "cell_micro" "not,conditional,always"
144 (if_then_else (ior (ior (eq_attr "type" "load")
145 (eq_attr "type" "store"))
146 (ior (eq_attr "type" "fpload")
147 (eq_attr "type" "fpstore")))
148 (const_string "conditional")
149 (if_then_else (ior (eq_attr "type" "load_ext")
150 (ior (eq_attr "type" "compare")
151 (eq_attr "type" "delayed_compare")))
152 (const_string "always")
153 (const_string "not"))))
154
155
b54cf83a
DE
156(automata_option "ndfa")
157
158(include "rios1.md")
159(include "rios2.md")
160(include "rs64.md")
161(include "mpc.md")
162(include "40x.md")
02ca7595 163(include "440.md")
b54cf83a
DE
164(include "603.md")
165(include "6xx.md")
166(include "7xx.md")
167(include "7450.md")
5e8006fa 168(include "8540.md")
fa41c305 169(include "e300c2c3.md")
edae5fe3 170(include "e500mc.md")
b54cf83a 171(include "power4.md")
ec507f2d 172(include "power5.md")
44cd321e 173(include "power6.md")
d296e02e 174(include "cell.md")
48d72335
DE
175
176(include "predicates.md")
279bb624 177(include "constraints.md")
48d72335 178
ac9e2cff 179(include "darwin.md")
309323c2 180
1fd4e8c1 181\f
3abcb3a7 182;; Mode iterators
915167f5 183
3abcb3a7 184; This mode iterator allows :GPR to be used to indicate the allowable size
915167f5 185; of whole values in GPRs.
3abcb3a7 186(define_mode_iterator GPR [SI (DI "TARGET_POWERPC64")])
915167f5 187
0354e5d8 188; Any supported integer mode.
3abcb3a7 189(define_mode_iterator INT [QI HI SI DI TI])
915167f5 190
0354e5d8 191; Any supported integer mode that fits in one register.
3abcb3a7 192(define_mode_iterator INT1 [QI HI SI (DI "TARGET_POWERPC64")])
915167f5 193
b5568f07 194; extend modes for DImode
3abcb3a7 195(define_mode_iterator QHSI [QI HI SI])
b5568f07 196
0354e5d8 197; SImode or DImode, even if DImode doesn't fit in GPRs.
3abcb3a7 198(define_mode_iterator SDI [SI DI])
0354e5d8
GK
199
200; The size of a pointer. Also, the size of the value that a record-condition
201; (one with a '.') will compare.
3abcb3a7 202(define_mode_iterator P [(SI "TARGET_32BIT") (DI "TARGET_64BIT")])
2e6c9641 203
4ae234b0 204; Any hardware-supported floating-point mode
3abcb3a7 205(define_mode_iterator FP [(SF "TARGET_HARD_FLOAT")
4ae234b0 206 (DF "TARGET_HARD_FLOAT && (TARGET_FPRS || TARGET_E500_DOUBLE)")
602ea4d3 207 (TF "!TARGET_IEEEQUAD
17caeff2
JM
208 && TARGET_HARD_FLOAT
209 && (TARGET_FPRS || TARGET_E500_DOUBLE)
6ef9a246
JJ
210 && TARGET_LONG_DOUBLE_128")
211 (DD "TARGET_DFP")
212 (TD "TARGET_DFP")])
4ae234b0 213
915167f5 214; Various instructions that come in SI and DI forms.
0354e5d8 215; A generic w/d attribute, for things like cmpw/cmpd.
b5568f07
DE
216(define_mode_attr wd [(QI "b") (HI "h") (SI "w") (DI "d")])
217
218; DImode bits
219(define_mode_attr dbits [(QI "56") (HI "48") (SI "32")])
915167f5
GK
220
221\f
1fd4e8c1
RK
222;; Start with fixed-point load and store insns. Here we put only the more
223;; complex forms. Basic data transfer is done later.
224
b5568f07 225(define_expand "zero_extend<mode>di2"
51b8fc2c 226 [(set (match_operand:DI 0 "gpc_reg_operand" "")
b5568f07 227 (zero_extend:DI (match_operand:QHSI 1 "gpc_reg_operand" "")))]
51b8fc2c
RK
228 "TARGET_POWERPC64"
229 "")
230
b5568f07 231(define_insn "*zero_extend<mode>di2_internal1"
51b8fc2c 232 [(set (match_operand:DI 0 "gpc_reg_operand" "=r,r")
b5568f07 233 (zero_extend:DI (match_operand:QHSI 1 "reg_or_mem_operand" "m,r")))]
51b8fc2c
RK
234 "TARGET_POWERPC64"
235 "@
b5568f07
DE
236 l<wd>z%U1%X1 %0,%1
237 rldicl %0,%1,0,<dbits>"
51b8fc2c
RK
238 [(set_attr "type" "load,*")])
239
b5568f07 240(define_insn "*zero_extend<mode>di2_internal2"
9ebbca7d 241 [(set (match_operand:CC 0 "cc_reg_operand" "=x,?y")
b5568f07 242 (compare:CC (zero_extend:DI (match_operand:QHSI 1 "gpc_reg_operand" "r,r"))
815cdc52 243 (const_int 0)))
9ebbca7d 244 (clobber (match_scratch:DI 2 "=r,r"))]
683bdff7 245 "TARGET_64BIT"
9ebbca7d 246 "@
b5568f07 247 rldicl. %2,%1,0,<dbits>
9ebbca7d
GK
248 #"
249 [(set_attr "type" "compare")
250 (set_attr "length" "4,8")])
251
252(define_split
253 [(set (match_operand:CC 0 "cc_reg_not_cr0_operand" "")
b5568f07 254 (compare:CC (zero_extend:DI (match_operand:QHSI 1 "gpc_reg_operand" ""))
9ebbca7d
GK
255 (const_int 0)))
256 (clobber (match_scratch:DI 2 ""))]
257 "TARGET_POWERPC64 && reload_completed"
258 [(set (match_dup 2)
259 (zero_extend:DI (match_dup 1)))
260 (set (match_dup 0)
261 (compare:CC (match_dup 2)
262 (const_int 0)))]
263 "")
51b8fc2c 264
b5568f07 265(define_insn "*zero_extend<mode>di2_internal3"
9ebbca7d 266 [(set (match_operand:CC 2 "cc_reg_operand" "=x,?y")
b5568f07 267 (compare:CC (zero_extend:DI (match_operand:QHSI 1 "gpc_reg_operand" "r,r"))
51b8fc2c 268 (const_int 0)))
9ebbca7d 269 (set (match_operand:DI 0 "gpc_reg_operand" "=r,r")
51b8fc2c 270 (zero_extend:DI (match_dup 1)))]
683bdff7 271 "TARGET_64BIT"
9ebbca7d 272 "@
b5568f07 273 rldicl. %0,%1,0,<dbits>
9ebbca7d
GK
274 #"
275 [(set_attr "type" "compare")
276 (set_attr "length" "4,8")])
277
278(define_split
279 [(set (match_operand:CC 2 "cc_reg_not_cr0_operand" "")
b5568f07 280 (compare:CC (zero_extend:DI (match_operand:QHSI 1 "gpc_reg_operand" ""))
9ebbca7d
GK
281 (const_int 0)))
282 (set (match_operand:DI 0 "gpc_reg_operand" "")
283 (zero_extend:DI (match_dup 1)))]
284 "TARGET_POWERPC64 && reload_completed"
285 [(set (match_dup 0)
286 (zero_extend:DI (match_dup 1)))
287 (set (match_dup 2)
288 (compare:CC (match_dup 0)
289 (const_int 0)))]
290 "")
51b8fc2c 291
2bee0449
RK
292(define_insn "extendqidi2"
293 [(set (match_operand:DI 0 "gpc_reg_operand" "=r")
294 (sign_extend:DI (match_operand:QI 1 "gpc_reg_operand" "r")))]
51b8fc2c 295 "TARGET_POWERPC64"
44cd321e
PS
296 "extsb %0,%1"
297 [(set_attr "type" "exts")])
51b8fc2c
RK
298
299(define_insn ""
9ebbca7d
GK
300 [(set (match_operand:CC 0 "cc_reg_operand" "=x,?y")
301 (compare:CC (sign_extend:DI (match_operand:QI 1 "gpc_reg_operand" "r,r"))
51b8fc2c 302 (const_int 0)))
9ebbca7d 303 (clobber (match_scratch:DI 2 "=r,r"))]
683bdff7 304 "TARGET_64BIT"
9ebbca7d
GK
305 "@
306 extsb. %2,%1
307 #"
308 [(set_attr "type" "compare")
309 (set_attr "length" "4,8")])
310
311(define_split
312 [(set (match_operand:CC 0 "cc_reg_not_cr0_operand" "")
313 (compare:CC (sign_extend:DI (match_operand:QI 1 "gpc_reg_operand" ""))
314 (const_int 0)))
315 (clobber (match_scratch:DI 2 ""))]
316 "TARGET_POWERPC64 && reload_completed"
317 [(set (match_dup 2)
318 (sign_extend:DI (match_dup 1)))
319 (set (match_dup 0)
320 (compare:CC (match_dup 2)
321 (const_int 0)))]
322 "")
51b8fc2c
RK
323
324(define_insn ""
9ebbca7d
GK
325 [(set (match_operand:CC 2 "cc_reg_operand" "=x,?y")
326 (compare:CC (sign_extend:DI (match_operand:QI 1 "gpc_reg_operand" "r,r"))
51b8fc2c 327 (const_int 0)))
9ebbca7d 328 (set (match_operand:DI 0 "gpc_reg_operand" "=r,r")
51b8fc2c 329 (sign_extend:DI (match_dup 1)))]
683bdff7 330 "TARGET_64BIT"
9ebbca7d
GK
331 "@
332 extsb. %0,%1
333 #"
334 [(set_attr "type" "compare")
335 (set_attr "length" "4,8")])
336
337(define_split
338 [(set (match_operand:CC 2 "cc_reg_not_cr0_operand" "")
339 (compare:CC (sign_extend:DI (match_operand:QI 1 "gpc_reg_operand" ""))
340 (const_int 0)))
341 (set (match_operand:DI 0 "gpc_reg_operand" "")
342 (sign_extend:DI (match_dup 1)))]
343 "TARGET_POWERPC64 && reload_completed"
344 [(set (match_dup 0)
345 (sign_extend:DI (match_dup 1)))
346 (set (match_dup 2)
347 (compare:CC (match_dup 0)
348 (const_int 0)))]
349 "")
51b8fc2c 350
51b8fc2c
RK
351(define_expand "extendhidi2"
352 [(set (match_operand:DI 0 "gpc_reg_operand" "")
353 (sign_extend:DI (match_operand:HI 1 "gpc_reg_operand" "")))]
354 "TARGET_POWERPC64"
355 "")
356
357(define_insn ""
358 [(set (match_operand:DI 0 "gpc_reg_operand" "=r,r")
359 (sign_extend:DI (match_operand:HI 1 "reg_or_mem_operand" "m,r")))]
360 "TARGET_POWERPC64"
361 "@
362 lha%U1%X1 %0,%1
363 extsh %0,%1"
44cd321e 364 [(set_attr "type" "load_ext,exts")])
51b8fc2c
RK
365
366(define_insn ""
9ebbca7d
GK
367 [(set (match_operand:CC 0 "cc_reg_operand" "=x,?y")
368 (compare:CC (sign_extend:DI (match_operand:HI 1 "gpc_reg_operand" "r,r"))
51b8fc2c 369 (const_int 0)))
9ebbca7d 370 (clobber (match_scratch:DI 2 "=r,r"))]
683bdff7 371 "TARGET_64BIT"
9ebbca7d
GK
372 "@
373 extsh. %2,%1
374 #"
375 [(set_attr "type" "compare")
376 (set_attr "length" "4,8")])
377
378(define_split
379 [(set (match_operand:CC 0 "cc_reg_not_cr0_operand" "")
380 (compare:CC (sign_extend:DI (match_operand:HI 1 "gpc_reg_operand" ""))
381 (const_int 0)))
382 (clobber (match_scratch:DI 2 ""))]
383 "TARGET_POWERPC64 && reload_completed"
384 [(set (match_dup 2)
385 (sign_extend:DI (match_dup 1)))
386 (set (match_dup 0)
387 (compare:CC (match_dup 2)
388 (const_int 0)))]
389 "")
51b8fc2c
RK
390
391(define_insn ""
9ebbca7d
GK
392 [(set (match_operand:CC 2 "cc_reg_operand" "=x,?y")
393 (compare:CC (sign_extend:DI (match_operand:HI 1 "gpc_reg_operand" "r,r"))
51b8fc2c 394 (const_int 0)))
9ebbca7d 395 (set (match_operand:DI 0 "gpc_reg_operand" "=r,r")
51b8fc2c 396 (sign_extend:DI (match_dup 1)))]
683bdff7 397 "TARGET_64BIT"
9ebbca7d
GK
398 "@
399 extsh. %0,%1
400 #"
401 [(set_attr "type" "compare")
402 (set_attr "length" "4,8")])
403
404(define_split
405 [(set (match_operand:CC 2 "cc_reg_not_cr0_operand" "")
406 (compare:CC (sign_extend:DI (match_operand:HI 1 "gpc_reg_operand" ""))
407 (const_int 0)))
408 (set (match_operand:DI 0 "gpc_reg_operand" "")
409 (sign_extend:DI (match_dup 1)))]
410 "TARGET_POWERPC64 && reload_completed"
411 [(set (match_dup 0)
412 (sign_extend:DI (match_dup 1)))
413 (set (match_dup 2)
414 (compare:CC (match_dup 0)
415 (const_int 0)))]
416 "")
51b8fc2c 417
51b8fc2c
RK
418(define_expand "extendsidi2"
419 [(set (match_operand:DI 0 "gpc_reg_operand" "")
420 (sign_extend:DI (match_operand:SI 1 "gpc_reg_operand" "")))]
421 "TARGET_POWERPC64"
422 "")
423
424(define_insn ""
425 [(set (match_operand:DI 0 "gpc_reg_operand" "=r,r")
287f13ff 426 (sign_extend:DI (match_operand:SI 1 "lwa_operand" "m,r")))]
51b8fc2c
RK
427 "TARGET_POWERPC64"
428 "@
429 lwa%U1%X1 %0,%1
430 extsw %0,%1"
44cd321e 431 [(set_attr "type" "load_ext,exts")])
51b8fc2c
RK
432
433(define_insn ""
9ebbca7d
GK
434 [(set (match_operand:CC 0 "cc_reg_operand" "=x,?y")
435 (compare:CC (sign_extend:DI (match_operand:SI 1 "gpc_reg_operand" "r,r"))
51b8fc2c 436 (const_int 0)))
9ebbca7d 437 (clobber (match_scratch:DI 2 "=r,r"))]
683bdff7 438 "TARGET_64BIT"
9ebbca7d
GK
439 "@
440 extsw. %2,%1
441 #"
442 [(set_attr "type" "compare")
443 (set_attr "length" "4,8")])
444
445(define_split
446 [(set (match_operand:CC 0 "cc_reg_not_cr0_operand" "")
447 (compare:CC (sign_extend:DI (match_operand:SI 1 "gpc_reg_operand" ""))
448 (const_int 0)))
449 (clobber (match_scratch:DI 2 ""))]
450 "TARGET_POWERPC64 && reload_completed"
451 [(set (match_dup 2)
452 (sign_extend:DI (match_dup 1)))
453 (set (match_dup 0)
454 (compare:CC (match_dup 2)
455 (const_int 0)))]
456 "")
51b8fc2c
RK
457
458(define_insn ""
9ebbca7d
GK
459 [(set (match_operand:CC 2 "cc_reg_operand" "=x,?y")
460 (compare:CC (sign_extend:DI (match_operand:SI 1 "gpc_reg_operand" "r,r"))
51b8fc2c 461 (const_int 0)))
9ebbca7d 462 (set (match_operand:DI 0 "gpc_reg_operand" "=r,r")
51b8fc2c 463 (sign_extend:DI (match_dup 1)))]
683bdff7 464 "TARGET_64BIT"
9ebbca7d
GK
465 "@
466 extsw. %0,%1
467 #"
468 [(set_attr "type" "compare")
469 (set_attr "length" "4,8")])
470
471(define_split
472 [(set (match_operand:CC 2 "cc_reg_not_cr0_operand" "")
473 (compare:CC (sign_extend:DI (match_operand:SI 1 "gpc_reg_operand" ""))
474 (const_int 0)))
475 (set (match_operand:DI 0 "gpc_reg_operand" "")
476 (sign_extend:DI (match_dup 1)))]
477 "TARGET_POWERPC64 && reload_completed"
478 [(set (match_dup 0)
479 (sign_extend:DI (match_dup 1)))
480 (set (match_dup 2)
481 (compare:CC (match_dup 0)
482 (const_int 0)))]
483 "")
51b8fc2c 484
1fd4e8c1 485(define_expand "zero_extendqisi2"
cd2b37d9
RK
486 [(set (match_operand:SI 0 "gpc_reg_operand" "")
487 (zero_extend:SI (match_operand:QI 1 "gpc_reg_operand" "")))]
1fd4e8c1
RK
488 ""
489 "")
490
491(define_insn ""
cd2b37d9 492 [(set (match_operand:SI 0 "gpc_reg_operand" "=r,r")
1fd4e8c1
RK
493 (zero_extend:SI (match_operand:QI 1 "reg_or_mem_operand" "m,r")))]
494 ""
495 "@
496 lbz%U1%X1 %0,%1
005a35b9 497 {rlinm|rlwinm} %0,%1,0,0xff"
1fd4e8c1
RK
498 [(set_attr "type" "load,*")])
499
500(define_insn ""
9ebbca7d
GK
501 [(set (match_operand:CC 0 "cc_reg_operand" "=x,?y")
502 (compare:CC (zero_extend:SI (match_operand:QI 1 "gpc_reg_operand" "r,r"))
1fd4e8c1 503 (const_int 0)))
9ebbca7d 504 (clobber (match_scratch:SI 2 "=r,r"))]
1fd4e8c1 505 ""
9ebbca7d
GK
506 "@
507 {andil.|andi.} %2,%1,0xff
508 #"
509 [(set_attr "type" "compare")
510 (set_attr "length" "4,8")])
511
512(define_split
513 [(set (match_operand:CC 0 "cc_reg_not_cr0_operand" "")
514 (compare:CC (zero_extend:SI (match_operand:QI 1 "gpc_reg_operand" ""))
515 (const_int 0)))
516 (clobber (match_scratch:SI 2 ""))]
517 "reload_completed"
518 [(set (match_dup 2)
519 (zero_extend:SI (match_dup 1)))
520 (set (match_dup 0)
521 (compare:CC (match_dup 2)
522 (const_int 0)))]
523 "")
1fd4e8c1
RK
524
525(define_insn ""
9ebbca7d
GK
526 [(set (match_operand:CC 2 "cc_reg_operand" "=x,?y")
527 (compare:CC (zero_extend:SI (match_operand:QI 1 "gpc_reg_operand" "r,r"))
1fd4e8c1 528 (const_int 0)))
9ebbca7d 529 (set (match_operand:SI 0 "gpc_reg_operand" "=r,r")
1fd4e8c1
RK
530 (zero_extend:SI (match_dup 1)))]
531 ""
9ebbca7d
GK
532 "@
533 {andil.|andi.} %0,%1,0xff
534 #"
535 [(set_attr "type" "compare")
536 (set_attr "length" "4,8")])
537
538(define_split
539 [(set (match_operand:CC 2 "cc_reg_not_cr0_operand" "")
540 (compare:CC (zero_extend:SI (match_operand:QI 1 "gpc_reg_operand" ""))
541 (const_int 0)))
542 (set (match_operand:SI 0 "gpc_reg_operand" "")
543 (zero_extend:SI (match_dup 1)))]
544 "reload_completed"
545 [(set (match_dup 0)
546 (zero_extend:SI (match_dup 1)))
547 (set (match_dup 2)
548 (compare:CC (match_dup 0)
549 (const_int 0)))]
550 "")
1fd4e8c1 551
51b8fc2c
RK
552(define_expand "extendqisi2"
553 [(use (match_operand:SI 0 "gpc_reg_operand" ""))
554 (use (match_operand:QI 1 "gpc_reg_operand" ""))]
555 ""
556 "
557{
558 if (TARGET_POWERPC)
559 emit_insn (gen_extendqisi2_ppc (operands[0], operands[1]));
560 else if (TARGET_POWER)
561 emit_insn (gen_extendqisi2_power (operands[0], operands[1]));
562 else
563 emit_insn (gen_extendqisi2_no_power (operands[0], operands[1]));
564 DONE;
565}")
566
567(define_insn "extendqisi2_ppc"
2bee0449
RK
568 [(set (match_operand:SI 0 "gpc_reg_operand" "=r")
569 (sign_extend:SI (match_operand:QI 1 "gpc_reg_operand" "r")))]
51b8fc2c 570 "TARGET_POWERPC"
44cd321e
PS
571 "extsb %0,%1"
572 [(set_attr "type" "exts")])
51b8fc2c
RK
573
574(define_insn ""
9ebbca7d
GK
575 [(set (match_operand:CC 0 "cc_reg_operand" "=x,?y")
576 (compare:CC (sign_extend:SI (match_operand:QI 1 "gpc_reg_operand" "r,r"))
51b8fc2c 577 (const_int 0)))
9ebbca7d 578 (clobber (match_scratch:SI 2 "=r,r"))]
51b8fc2c 579 "TARGET_POWERPC"
9ebbca7d
GK
580 "@
581 extsb. %2,%1
582 #"
583 [(set_attr "type" "compare")
584 (set_attr "length" "4,8")])
585
586(define_split
587 [(set (match_operand:CC 0 "cc_reg_not_cr0_operand" "")
588 (compare:CC (sign_extend:SI (match_operand:QI 1 "gpc_reg_operand" ""))
589 (const_int 0)))
590 (clobber (match_scratch:SI 2 ""))]
591 "TARGET_POWERPC && reload_completed"
592 [(set (match_dup 2)
593 (sign_extend:SI (match_dup 1)))
594 (set (match_dup 0)
595 (compare:CC (match_dup 2)
596 (const_int 0)))]
597 "")
51b8fc2c
RK
598
599(define_insn ""
9ebbca7d
GK
600 [(set (match_operand:CC 2 "cc_reg_operand" "=x,?y")
601 (compare:CC (sign_extend:SI (match_operand:QI 1 "gpc_reg_operand" "r,r"))
51b8fc2c 602 (const_int 0)))
9ebbca7d 603 (set (match_operand:SI 0 "gpc_reg_operand" "=r,r")
51b8fc2c
RK
604 (sign_extend:SI (match_dup 1)))]
605 "TARGET_POWERPC"
9ebbca7d
GK
606 "@
607 extsb. %0,%1
608 #"
609 [(set_attr "type" "compare")
610 (set_attr "length" "4,8")])
611
612(define_split
613 [(set (match_operand:CC 2 "cc_reg_not_cr0_operand" "")
614 (compare:CC (sign_extend:SI (match_operand:QI 1 "gpc_reg_operand" ""))
615 (const_int 0)))
616 (set (match_operand:SI 0 "gpc_reg_operand" "")
617 (sign_extend:SI (match_dup 1)))]
618 "TARGET_POWERPC && reload_completed"
619 [(set (match_dup 0)
620 (sign_extend:SI (match_dup 1)))
621 (set (match_dup 2)
622 (compare:CC (match_dup 0)
623 (const_int 0)))]
624 "")
51b8fc2c
RK
625
626(define_expand "extendqisi2_power"
627 [(parallel [(set (match_dup 2)
628 (ashift:SI (match_operand:QI 1 "gpc_reg_operand" "")
629 (const_int 24)))
630 (clobber (scratch:SI))])
631 (parallel [(set (match_operand:SI 0 "gpc_reg_operand" "")
632 (ashiftrt:SI (match_dup 2)
633 (const_int 24)))
634 (clobber (scratch:SI))])]
635 "TARGET_POWER"
636 "
637{ operands[1] = gen_lowpart (SImode, operands[1]);
638 operands[2] = gen_reg_rtx (SImode); }")
639
640(define_expand "extendqisi2_no_power"
641 [(set (match_dup 2)
642 (ashift:SI (match_operand:QI 1 "gpc_reg_operand" "")
643 (const_int 24)))
644 (set (match_operand:SI 0 "gpc_reg_operand" "")
645 (ashiftrt:SI (match_dup 2)
646 (const_int 24)))]
647 "! TARGET_POWER && ! TARGET_POWERPC"
648 "
649{ operands[1] = gen_lowpart (SImode, operands[1]);
650 operands[2] = gen_reg_rtx (SImode); }")
651
1fd4e8c1 652(define_expand "zero_extendqihi2"
cd2b37d9
RK
653 [(set (match_operand:HI 0 "gpc_reg_operand" "")
654 (zero_extend:HI (match_operand:QI 1 "gpc_reg_operand" "")))]
1fd4e8c1
RK
655 ""
656 "")
657
658(define_insn ""
cd2b37d9 659 [(set (match_operand:HI 0 "gpc_reg_operand" "=r,r")
1fd4e8c1
RK
660 (zero_extend:HI (match_operand:QI 1 "reg_or_mem_operand" "m,r")))]
661 ""
662 "@
663 lbz%U1%X1 %0,%1
005a35b9 664 {rlinm|rlwinm} %0,%1,0,0xff"
51b8fc2c
RK
665 [(set_attr "type" "load,*")])
666
667(define_insn ""
9ebbca7d
GK
668 [(set (match_operand:CC 0 "cc_reg_operand" "=x,?y")
669 (compare:CC (zero_extend:HI (match_operand:QI 1 "gpc_reg_operand" "r,r"))
51b8fc2c 670 (const_int 0)))
9ebbca7d 671 (clobber (match_scratch:HI 2 "=r,r"))]
51b8fc2c 672 ""
9ebbca7d
GK
673 "@
674 {andil.|andi.} %2,%1,0xff
675 #"
676 [(set_attr "type" "compare")
677 (set_attr "length" "4,8")])
678
679(define_split
680 [(set (match_operand:CC 0 "cc_reg_not_cr0_operand" "")
681 (compare:CC (zero_extend:HI (match_operand:QI 1 "gpc_reg_operand" ""))
682 (const_int 0)))
683 (clobber (match_scratch:HI 2 ""))]
684 "reload_completed"
685 [(set (match_dup 2)
686 (zero_extend:HI (match_dup 1)))
687 (set (match_dup 0)
688 (compare:CC (match_dup 2)
689 (const_int 0)))]
690 "")
1fd4e8c1 691
51b8fc2c 692(define_insn ""
9ebbca7d
GK
693 [(set (match_operand:CC 2 "cc_reg_operand" "=x,?y")
694 (compare:CC (zero_extend:HI (match_operand:QI 1 "gpc_reg_operand" "r,r"))
51b8fc2c 695 (const_int 0)))
9ebbca7d 696 (set (match_operand:HI 0 "gpc_reg_operand" "=r,r")
815cdc52
MM
697 (zero_extend:HI (match_dup 1)))]
698 ""
9ebbca7d
GK
699 "@
700 {andil.|andi.} %0,%1,0xff
701 #"
702 [(set_attr "type" "compare")
703 (set_attr "length" "4,8")])
704
705(define_split
706 [(set (match_operand:CC 2 "cc_reg_not_cr0_operand" "")
707 (compare:CC (zero_extend:HI (match_operand:QI 1 "gpc_reg_operand" ""))
708 (const_int 0)))
709 (set (match_operand:HI 0 "gpc_reg_operand" "")
710 (zero_extend:HI (match_dup 1)))]
711 "reload_completed"
712 [(set (match_dup 0)
713 (zero_extend:HI (match_dup 1)))
714 (set (match_dup 2)
715 (compare:CC (match_dup 0)
716 (const_int 0)))]
717 "")
815cdc52
MM
718
719(define_expand "extendqihi2"
720 [(use (match_operand:HI 0 "gpc_reg_operand" ""))
721 (use (match_operand:QI 1 "gpc_reg_operand" ""))]
722 ""
723 "
724{
725 if (TARGET_POWERPC)
726 emit_insn (gen_extendqihi2_ppc (operands[0], operands[1]));
727 else if (TARGET_POWER)
728 emit_insn (gen_extendqihi2_power (operands[0], operands[1]));
729 else
730 emit_insn (gen_extendqihi2_no_power (operands[0], operands[1]));
731 DONE;
732}")
733
734(define_insn "extendqihi2_ppc"
735 [(set (match_operand:HI 0 "gpc_reg_operand" "=r")
736 (sign_extend:HI (match_operand:QI 1 "gpc_reg_operand" "r")))]
737 "TARGET_POWERPC"
44cd321e
PS
738 "extsb %0,%1"
739 [(set_attr "type" "exts")])
815cdc52
MM
740
741(define_insn ""
9ebbca7d
GK
742 [(set (match_operand:CC 0 "cc_reg_operand" "=x,?y")
743 (compare:CC (sign_extend:HI (match_operand:QI 1 "gpc_reg_operand" "r,r"))
815cdc52 744 (const_int 0)))
9ebbca7d 745 (clobber (match_scratch:HI 2 "=r,r"))]
815cdc52 746 "TARGET_POWERPC"
9ebbca7d
GK
747 "@
748 extsb. %2,%1
749 #"
750 [(set_attr "type" "compare")
751 (set_attr "length" "4,8")])
752
753(define_split
754 [(set (match_operand:CC 0 "cc_reg_not_cr0_operand" "")
755 (compare:CC (sign_extend:HI (match_operand:QI 1 "gpc_reg_operand" ""))
756 (const_int 0)))
757 (clobber (match_scratch:HI 2 ""))]
758 "TARGET_POWERPC && reload_completed"
759 [(set (match_dup 2)
760 (sign_extend:HI (match_dup 1)))
761 (set (match_dup 0)
762 (compare:CC (match_dup 2)
763 (const_int 0)))]
764 "")
815cdc52
MM
765
766(define_insn ""
9ebbca7d
GK
767 [(set (match_operand:CC 2 "cc_reg_operand" "=x,?y")
768 (compare:CC (sign_extend:HI (match_operand:QI 1 "gpc_reg_operand" "r,r"))
51b8fc2c 769 (const_int 0)))
9ebbca7d 770 (set (match_operand:HI 0 "gpc_reg_operand" "=r,r")
51b8fc2c
RK
771 (sign_extend:HI (match_dup 1)))]
772 "TARGET_POWERPC"
9ebbca7d
GK
773 "@
774 extsb. %0,%1
775 #"
776 [(set_attr "type" "compare")
777 (set_attr "length" "4,8")])
778
779(define_split
780 [(set (match_operand:CC 2 "cc_reg_not_cr0_operand" "")
781 (compare:CC (sign_extend:HI (match_operand:QI 1 "gpc_reg_operand" ""))
782 (const_int 0)))
783 (set (match_operand:HI 0 "gpc_reg_operand" "")
784 (sign_extend:HI (match_dup 1)))]
785 "TARGET_POWERPC && reload_completed"
786 [(set (match_dup 0)
787 (sign_extend:HI (match_dup 1)))
788 (set (match_dup 2)
789 (compare:CC (match_dup 0)
790 (const_int 0)))]
791 "")
51b8fc2c
RK
792
793(define_expand "extendqihi2_power"
794 [(parallel [(set (match_dup 2)
795 (ashift:SI (match_operand:QI 1 "gpc_reg_operand" "")
796 (const_int 24)))
797 (clobber (scratch:SI))])
798 (parallel [(set (match_operand:HI 0 "gpc_reg_operand" "")
799 (ashiftrt:SI (match_dup 2)
800 (const_int 24)))
801 (clobber (scratch:SI))])]
802 "TARGET_POWER"
803 "
804{ operands[0] = gen_lowpart (SImode, operands[0]);
805 operands[1] = gen_lowpart (SImode, operands[1]);
806 operands[2] = gen_reg_rtx (SImode); }")
807
808(define_expand "extendqihi2_no_power"
809 [(set (match_dup 2)
810 (ashift:SI (match_operand:QI 1 "gpc_reg_operand" "")
811 (const_int 24)))
812 (set (match_operand:HI 0 "gpc_reg_operand" "")
813 (ashiftrt:SI (match_dup 2)
814 (const_int 24)))]
815 "! TARGET_POWER && ! TARGET_POWERPC"
816 "
817{ operands[0] = gen_lowpart (SImode, operands[0]);
818 operands[1] = gen_lowpart (SImode, operands[1]);
819 operands[2] = gen_reg_rtx (SImode); }")
820
1fd4e8c1 821(define_expand "zero_extendhisi2"
5f243543 822 [(set (match_operand:SI 0 "gpc_reg_operand" "")
cd2b37d9 823 (zero_extend:SI (match_operand:HI 1 "gpc_reg_operand" "")))]
1fd4e8c1
RK
824 ""
825 "")
826
827(define_insn ""
cd2b37d9 828 [(set (match_operand:SI 0 "gpc_reg_operand" "=r,r")
1fd4e8c1
RK
829 (zero_extend:SI (match_operand:HI 1 "reg_or_mem_operand" "m,r")))]
830 ""
831 "@
832 lhz%U1%X1 %0,%1
005a35b9 833 {rlinm|rlwinm} %0,%1,0,0xffff"
1fd4e8c1
RK
834 [(set_attr "type" "load,*")])
835
836(define_insn ""
9ebbca7d
GK
837 [(set (match_operand:CC 0 "cc_reg_operand" "=x,?y")
838 (compare:CC (zero_extend:SI (match_operand:HI 1 "gpc_reg_operand" "r,r"))
1fd4e8c1 839 (const_int 0)))
9ebbca7d 840 (clobber (match_scratch:SI 2 "=r,r"))]
1fd4e8c1 841 ""
9ebbca7d
GK
842 "@
843 {andil.|andi.} %2,%1,0xffff
844 #"
845 [(set_attr "type" "compare")
846 (set_attr "length" "4,8")])
847
848(define_split
849 [(set (match_operand:CC 0 "cc_reg_not_cr0_operand" "")
850 (compare:CC (zero_extend:SI (match_operand:HI 1 "gpc_reg_operand" ""))
851 (const_int 0)))
852 (clobber (match_scratch:SI 2 ""))]
853 "reload_completed"
854 [(set (match_dup 2)
855 (zero_extend:SI (match_dup 1)))
856 (set (match_dup 0)
857 (compare:CC (match_dup 2)
858 (const_int 0)))]
859 "")
1fd4e8c1
RK
860
861(define_insn ""
9ebbca7d
GK
862 [(set (match_operand:CC 2 "cc_reg_operand" "=x,?y")
863 (compare:CC (zero_extend:SI (match_operand:HI 1 "gpc_reg_operand" "r,r"))
1fd4e8c1 864 (const_int 0)))
9ebbca7d 865 (set (match_operand:SI 0 "gpc_reg_operand" "=r,r")
1fd4e8c1
RK
866 (zero_extend:SI (match_dup 1)))]
867 ""
9ebbca7d
GK
868 "@
869 {andil.|andi.} %0,%1,0xffff
870 #"
871 [(set_attr "type" "compare")
872 (set_attr "length" "4,8")])
873
874(define_split
875 [(set (match_operand:CC 2 "cc_reg_not_cr0_operand" "")
876 (compare:CC (zero_extend:SI (match_operand:HI 1 "gpc_reg_operand" ""))
877 (const_int 0)))
878 (set (match_operand:SI 0 "gpc_reg_operand" "")
879 (zero_extend:SI (match_dup 1)))]
880 "reload_completed"
881 [(set (match_dup 0)
882 (zero_extend:SI (match_dup 1)))
883 (set (match_dup 2)
884 (compare:CC (match_dup 0)
885 (const_int 0)))]
886 "")
1fd4e8c1
RK
887
888(define_expand "extendhisi2"
cd2b37d9
RK
889 [(set (match_operand:SI 0 "gpc_reg_operand" "")
890 (sign_extend:SI (match_operand:HI 1 "gpc_reg_operand" "")))]
1fd4e8c1
RK
891 ""
892 "")
893
894(define_insn ""
cd2b37d9 895 [(set (match_operand:SI 0 "gpc_reg_operand" "=r,r")
1fd4e8c1
RK
896 (sign_extend:SI (match_operand:HI 1 "reg_or_mem_operand" "m,r")))]
897 ""
898 "@
899 lha%U1%X1 %0,%1
ca7f5001 900 {exts|extsh} %0,%1"
44cd321e 901 [(set_attr "type" "load_ext,exts")])
1fd4e8c1
RK
902
903(define_insn ""
9ebbca7d
GK
904 [(set (match_operand:CC 0 "cc_reg_operand" "=x,?y")
905 (compare:CC (sign_extend:SI (match_operand:HI 1 "gpc_reg_operand" "r,r"))
1fd4e8c1 906 (const_int 0)))
9ebbca7d 907 (clobber (match_scratch:SI 2 "=r,r"))]
1fd4e8c1 908 ""
9ebbca7d
GK
909 "@
910 {exts.|extsh.} %2,%1
911 #"
912 [(set_attr "type" "compare")
913 (set_attr "length" "4,8")])
914
915(define_split
916 [(set (match_operand:CC 0 "cc_reg_not_cr0_operand" "")
917 (compare:CC (sign_extend:SI (match_operand:HI 1 "gpc_reg_operand" ""))
918 (const_int 0)))
919 (clobber (match_scratch:SI 2 ""))]
920 "reload_completed"
921 [(set (match_dup 2)
922 (sign_extend:SI (match_dup 1)))
923 (set (match_dup 0)
924 (compare:CC (match_dup 2)
925 (const_int 0)))]
926 "")
1fd4e8c1
RK
927
928(define_insn ""
9ebbca7d
GK
929 [(set (match_operand:CC 2 "cc_reg_operand" "=x,?y")
930 (compare:CC (sign_extend:SI (match_operand:HI 1 "gpc_reg_operand" "r,r"))
1fd4e8c1 931 (const_int 0)))
9ebbca7d 932 (set (match_operand:SI 0 "gpc_reg_operand" "=r,r")
1fd4e8c1
RK
933 (sign_extend:SI (match_dup 1)))]
934 ""
9ebbca7d
GK
935 "@
936 {exts.|extsh.} %0,%1
937 #"
938 [(set_attr "type" "compare")
939 (set_attr "length" "4,8")])
1fd4e8c1 940\f
4adf8008 941;; IBM 405, 440 and 464 half-word multiplication operations.
131aeb82
JM
942
943(define_insn "*macchwc"
944 [(set (match_operand:CC 3 "cc_reg_operand" "=x")
945 (compare:CC (plus:SI (mult:SI (ashiftrt:SI
946 (match_operand:SI 2 "gpc_reg_operand" "r")
947 (const_int 16))
948 (sign_extend:SI
949 (match_operand:HI 1 "gpc_reg_operand" "r")))
950 (match_operand:SI 4 "gpc_reg_operand" "0"))
951 (const_int 0)))
952 (set (match_operand:SI 0 "gpc_reg_operand" "=r")
953 (plus:SI (mult:SI (ashiftrt:SI
954 (match_dup 2)
955 (const_int 16))
956 (sign_extend:SI
957 (match_dup 1)))
958 (match_dup 4)))]
959 "TARGET_MULHW"
960 "macchw. %0, %1, %2"
961 [(set_attr "type" "imul3")])
962
963(define_insn "*macchw"
964 [(set (match_operand:SI 0 "gpc_reg_operand" "=r")
965 (plus:SI (mult:SI (ashiftrt:SI
966 (match_operand:SI 2 "gpc_reg_operand" "r")
967 (const_int 16))
968 (sign_extend:SI
969 (match_operand:HI 1 "gpc_reg_operand" "r")))
970 (match_operand:SI 3 "gpc_reg_operand" "0")))]
971 "TARGET_MULHW"
972 "macchw %0, %1, %2"
973 [(set_attr "type" "imul3")])
974
975(define_insn "*macchwuc"
976 [(set (match_operand:CC 3 "cc_reg_operand" "=x")
977 (compare:CC (plus:SI (mult:SI (lshiftrt:SI
978 (match_operand:SI 2 "gpc_reg_operand" "r")
979 (const_int 16))
980 (zero_extend:SI
981 (match_operand:HI 1 "gpc_reg_operand" "r")))
982 (match_operand:SI 4 "gpc_reg_operand" "0"))
983 (const_int 0)))
984 (set (match_operand:SI 0 "gpc_reg_operand" "=r")
985 (plus:SI (mult:SI (lshiftrt:SI
986 (match_dup 2)
987 (const_int 16))
988 (zero_extend:SI
989 (match_dup 1)))
990 (match_dup 4)))]
991 "TARGET_MULHW"
992 "macchwu. %0, %1, %2"
993 [(set_attr "type" "imul3")])
994
995(define_insn "*macchwu"
996 [(set (match_operand:SI 0 "gpc_reg_operand" "=r")
997 (plus:SI (mult:SI (lshiftrt:SI
998 (match_operand:SI 2 "gpc_reg_operand" "r")
999 (const_int 16))
1000 (zero_extend:SI
1001 (match_operand:HI 1 "gpc_reg_operand" "r")))
1002 (match_operand:SI 3 "gpc_reg_operand" "0")))]
1003 "TARGET_MULHW"
1004 "macchwu %0, %1, %2"
1005 [(set_attr "type" "imul3")])
1006
1007(define_insn "*machhwc"
1008 [(set (match_operand:CC 3 "cc_reg_operand" "=x")
1009 (compare:CC (plus:SI (mult:SI (ashiftrt:SI
1010 (match_operand:SI 1 "gpc_reg_operand" "%r")
1011 (const_int 16))
1012 (ashiftrt:SI
1013 (match_operand:SI 2 "gpc_reg_operand" "r")
1014 (const_int 16)))
1015 (match_operand:SI 4 "gpc_reg_operand" "0"))
1016 (const_int 0)))
1017 (set (match_operand:SI 0 "gpc_reg_operand" "=r")
1018 (plus:SI (mult:SI (ashiftrt:SI
1019 (match_dup 1)
1020 (const_int 16))
1021 (ashiftrt:SI
1022 (match_dup 2)
1023 (const_int 16)))
1024 (match_dup 4)))]
1025 "TARGET_MULHW"
1026 "machhw. %0, %1, %2"
1027 [(set_attr "type" "imul3")])
1028
1029(define_insn "*machhw"
1030 [(set (match_operand:SI 0 "gpc_reg_operand" "=r")
1031 (plus:SI (mult:SI (ashiftrt:SI
1032 (match_operand:SI 1 "gpc_reg_operand" "%r")
1033 (const_int 16))
1034 (ashiftrt:SI
1035 (match_operand:SI 2 "gpc_reg_operand" "r")
1036 (const_int 16)))
1037 (match_operand:SI 3 "gpc_reg_operand" "0")))]
1038 "TARGET_MULHW"
1039 "machhw %0, %1, %2"
1040 [(set_attr "type" "imul3")])
1041
1042(define_insn "*machhwuc"
1043 [(set (match_operand:CC 3 "cc_reg_operand" "=x")
1044 (compare:CC (plus:SI (mult:SI (lshiftrt:SI
1045 (match_operand:SI 1 "gpc_reg_operand" "%r")
1046 (const_int 16))
1047 (lshiftrt:SI
1048 (match_operand:SI 2 "gpc_reg_operand" "r")
1049 (const_int 16)))
1050 (match_operand:SI 4 "gpc_reg_operand" "0"))
1051 (const_int 0)))
1052 (set (match_operand:SI 0 "gpc_reg_operand" "=r")
1053 (plus:SI (mult:SI (lshiftrt:SI
1054 (match_dup 1)
1055 (const_int 16))
1056 (lshiftrt:SI
1057 (match_dup 2)
1058 (const_int 16)))
1059 (match_dup 4)))]
1060 "TARGET_MULHW"
1061 "machhwu. %0, %1, %2"
1062 [(set_attr "type" "imul3")])
1063
1064(define_insn "*machhwu"
1065 [(set (match_operand:SI 0 "gpc_reg_operand" "=r")
1066 (plus:SI (mult:SI (lshiftrt:SI
1067 (match_operand:SI 1 "gpc_reg_operand" "%r")
1068 (const_int 16))
1069 (lshiftrt:SI
1070 (match_operand:SI 2 "gpc_reg_operand" "r")
1071 (const_int 16)))
1072 (match_operand:SI 3 "gpc_reg_operand" "0")))]
1073 "TARGET_MULHW"
1074 "machhwu %0, %1, %2"
1075 [(set_attr "type" "imul3")])
1076
1077(define_insn "*maclhwc"
1078 [(set (match_operand:CC 3 "cc_reg_operand" "=x")
1079 (compare:CC (plus:SI (mult:SI (sign_extend:SI
1080 (match_operand:HI 1 "gpc_reg_operand" "%r"))
1081 (sign_extend:SI
1082 (match_operand:HI 2 "gpc_reg_operand" "r")))
1083 (match_operand:SI 4 "gpc_reg_operand" "0"))
1084 (const_int 0)))
1085 (set (match_operand:SI 0 "gpc_reg_operand" "=r")
1086 (plus:SI (mult:SI (sign_extend:SI
1087 (match_dup 1))
1088 (sign_extend:SI
1089 (match_dup 2)))
1090 (match_dup 4)))]
1091 "TARGET_MULHW"
1092 "maclhw. %0, %1, %2"
1093 [(set_attr "type" "imul3")])
1094
1095(define_insn "*maclhw"
1096 [(set (match_operand:SI 0 "gpc_reg_operand" "=r")
1097 (plus:SI (mult:SI (sign_extend:SI
1098 (match_operand:HI 1 "gpc_reg_operand" "%r"))
1099 (sign_extend:SI
1100 (match_operand:HI 2 "gpc_reg_operand" "r")))
1101 (match_operand:SI 3 "gpc_reg_operand" "0")))]
1102 "TARGET_MULHW"
1103 "maclhw %0, %1, %2"
1104 [(set_attr "type" "imul3")])
1105
1106(define_insn "*maclhwuc"
1107 [(set (match_operand:CC 3 "cc_reg_operand" "=x")
1108 (compare:CC (plus:SI (mult:SI (zero_extend:SI
1109 (match_operand:HI 1 "gpc_reg_operand" "%r"))
1110 (zero_extend:SI
1111 (match_operand:HI 2 "gpc_reg_operand" "r")))
1112 (match_operand:SI 4 "gpc_reg_operand" "0"))
1113 (const_int 0)))
1114 (set (match_operand:SI 0 "gpc_reg_operand" "=r")
1115 (plus:SI (mult:SI (zero_extend:SI
1116 (match_dup 1))
1117 (zero_extend:SI
1118 (match_dup 2)))
1119 (match_dup 4)))]
1120 "TARGET_MULHW"
1121 "maclhwu. %0, %1, %2"
1122 [(set_attr "type" "imul3")])
1123
1124(define_insn "*maclhwu"
1125 [(set (match_operand:SI 0 "gpc_reg_operand" "=r")
1126 (plus:SI (mult:SI (zero_extend:SI
1127 (match_operand:HI 1 "gpc_reg_operand" "%r"))
1128 (zero_extend:SI
1129 (match_operand:HI 2 "gpc_reg_operand" "r")))
1130 (match_operand:SI 3 "gpc_reg_operand" "0")))]
1131 "TARGET_MULHW"
1132 "maclhwu %0, %1, %2"
1133 [(set_attr "type" "imul3")])
1134
1135(define_insn "*nmacchwc"
1136 [(set (match_operand:CC 3 "cc_reg_operand" "=x")
1137 (compare:CC (minus:SI (match_operand:SI 4 "gpc_reg_operand" "0")
1138 (mult:SI (ashiftrt:SI
1139 (match_operand:SI 2 "gpc_reg_operand" "r")
1140 (const_int 16))
1141 (sign_extend:SI
1142 (match_operand:HI 1 "gpc_reg_operand" "r"))))
1143 (const_int 0)))
1144 (set (match_operand:SI 0 "gpc_reg_operand" "=r")
1145 (minus:SI (match_dup 4)
1146 (mult:SI (ashiftrt:SI
1147 (match_dup 2)
1148 (const_int 16))
1149 (sign_extend:SI
1150 (match_dup 1)))))]
1151 "TARGET_MULHW"
1152 "nmacchw. %0, %1, %2"
1153 [(set_attr "type" "imul3")])
1154
1155(define_insn "*nmacchw"
1156 [(set (match_operand:SI 0 "gpc_reg_operand" "=r")
1157 (minus:SI (match_operand:SI 3 "gpc_reg_operand" "0")
1158 (mult:SI (ashiftrt:SI
1159 (match_operand:SI 2 "gpc_reg_operand" "r")
1160 (const_int 16))
1161 (sign_extend:SI
1162 (match_operand:HI 1 "gpc_reg_operand" "r")))))]
1163 "TARGET_MULHW"
1164 "nmacchw %0, %1, %2"
1165 [(set_attr "type" "imul3")])
1166
1167(define_insn "*nmachhwc"
1168 [(set (match_operand:CC 3 "cc_reg_operand" "=x")
1169 (compare:CC (minus:SI (match_operand:SI 4 "gpc_reg_operand" "0")
1170 (mult:SI (ashiftrt:SI
1171 (match_operand:SI 1 "gpc_reg_operand" "%r")
1172 (const_int 16))
1173 (ashiftrt:SI
1174 (match_operand:SI 2 "gpc_reg_operand" "r")
1175 (const_int 16))))
1176 (const_int 0)))
1177 (set (match_operand:SI 0 "gpc_reg_operand" "=r")
1178 (minus:SI (match_dup 4)
1179 (mult:SI (ashiftrt:SI
1180 (match_dup 1)
1181 (const_int 16))
1182 (ashiftrt:SI
1183 (match_dup 2)
1184 (const_int 16)))))]
1185 "TARGET_MULHW"
1186 "nmachhw. %0, %1, %2"
1187 [(set_attr "type" "imul3")])
1188
1189(define_insn "*nmachhw"
1190 [(set (match_operand:SI 0 "gpc_reg_operand" "=r")
1191 (minus:SI (match_operand:SI 3 "gpc_reg_operand" "0")
1192 (mult:SI (ashiftrt:SI
1193 (match_operand:SI 1 "gpc_reg_operand" "%r")
1194 (const_int 16))
1195 (ashiftrt:SI
1196 (match_operand:SI 2 "gpc_reg_operand" "r")
1197 (const_int 16)))))]
1198 "TARGET_MULHW"
1199 "nmachhw %0, %1, %2"
1200 [(set_attr "type" "imul3")])
1201
1202(define_insn "*nmaclhwc"
1203 [(set (match_operand:CC 3 "cc_reg_operand" "=x")
1204 (compare:CC (minus:SI (match_operand:SI 4 "gpc_reg_operand" "0")
1205 (mult:SI (sign_extend:SI
1206 (match_operand:HI 1 "gpc_reg_operand" "%r"))
1207 (sign_extend:SI
1208 (match_operand:HI 2 "gpc_reg_operand" "r"))))
1209 (const_int 0)))
1210 (set (match_operand:SI 0 "gpc_reg_operand" "=r")
1211 (minus:SI (match_dup 4)
1212 (mult:SI (sign_extend:SI
1213 (match_dup 1))
1214 (sign_extend:SI
1215 (match_dup 2)))))]
1216 "TARGET_MULHW"
1217 "nmaclhw. %0, %1, %2"
1218 [(set_attr "type" "imul3")])
1219
1220(define_insn "*nmaclhw"
1221 [(set (match_operand:SI 0 "gpc_reg_operand" "=r")
1222 (minus:SI (match_operand:SI 3 "gpc_reg_operand" "0")
1223 (mult:SI (sign_extend:SI
1224 (match_operand:HI 1 "gpc_reg_operand" "%r"))
1225 (sign_extend:SI
1226 (match_operand:HI 2 "gpc_reg_operand" "r")))))]
1227 "TARGET_MULHW"
1228 "nmaclhw %0, %1, %2"
1229 [(set_attr "type" "imul3")])
1230
1231(define_insn "*mulchwc"
1232 [(set (match_operand:CC 3 "cc_reg_operand" "=x")
1233 (compare:CC (mult:SI (ashiftrt:SI
1234 (match_operand:SI 2 "gpc_reg_operand" "r")
1235 (const_int 16))
1236 (sign_extend:SI
1237 (match_operand:HI 1 "gpc_reg_operand" "r")))
1238 (const_int 0)))
1239 (set (match_operand:SI 0 "gpc_reg_operand" "=r")
1240 (mult:SI (ashiftrt:SI
1241 (match_dup 2)
1242 (const_int 16))
1243 (sign_extend:SI
1244 (match_dup 1))))]
1245 "TARGET_MULHW"
1246 "mulchw. %0, %1, %2"
1247 [(set_attr "type" "imul3")])
1248
1249(define_insn "*mulchw"
1250 [(set (match_operand:SI 0 "gpc_reg_operand" "=r")
1251 (mult:SI (ashiftrt:SI
1252 (match_operand:SI 2 "gpc_reg_operand" "r")
1253 (const_int 16))
1254 (sign_extend:SI
1255 (match_operand:HI 1 "gpc_reg_operand" "r"))))]
1256 "TARGET_MULHW"
1257 "mulchw %0, %1, %2"
1258 [(set_attr "type" "imul3")])
1259
1260(define_insn "*mulchwuc"
1261 [(set (match_operand:CC 3 "cc_reg_operand" "=x")
1262 (compare:CC (mult:SI (lshiftrt:SI
1263 (match_operand:SI 2 "gpc_reg_operand" "r")
1264 (const_int 16))
1265 (zero_extend:SI
1266 (match_operand:HI 1 "gpc_reg_operand" "r")))
1267 (const_int 0)))
1268 (set (match_operand:SI 0 "gpc_reg_operand" "=r")
1269 (mult:SI (lshiftrt:SI
1270 (match_dup 2)
1271 (const_int 16))
1272 (zero_extend:SI
1273 (match_dup 1))))]
1274 "TARGET_MULHW"
1275 "mulchwu. %0, %1, %2"
1276 [(set_attr "type" "imul3")])
1277
1278(define_insn "*mulchwu"
1279 [(set (match_operand:SI 0 "gpc_reg_operand" "=r")
1280 (mult:SI (lshiftrt:SI
1281 (match_operand:SI 2 "gpc_reg_operand" "r")
1282 (const_int 16))
1283 (zero_extend:SI
1284 (match_operand:HI 1 "gpc_reg_operand" "r"))))]
1285 "TARGET_MULHW"
1286 "mulchwu %0, %1, %2"
1287 [(set_attr "type" "imul3")])
1288
1289(define_insn "*mulhhwc"
1290 [(set (match_operand:CC 3 "cc_reg_operand" "=x")
1291 (compare:CC (mult:SI (ashiftrt:SI
1292 (match_operand:SI 1 "gpc_reg_operand" "%r")
1293 (const_int 16))
1294 (ashiftrt:SI
1295 (match_operand:SI 2 "gpc_reg_operand" "r")
1296 (const_int 16)))
1297 (const_int 0)))
1298 (set (match_operand:SI 0 "gpc_reg_operand" "=r")
1299 (mult:SI (ashiftrt:SI
1300 (match_dup 1)
1301 (const_int 16))
1302 (ashiftrt:SI
1303 (match_dup 2)
1304 (const_int 16))))]
1305 "TARGET_MULHW"
1306 "mulhhw. %0, %1, %2"
1307 [(set_attr "type" "imul3")])
1308
1309(define_insn "*mulhhw"
1310 [(set (match_operand:SI 0 "gpc_reg_operand" "=r")
1311 (mult:SI (ashiftrt:SI
1312 (match_operand:SI 1 "gpc_reg_operand" "%r")
1313 (const_int 16))
1314 (ashiftrt:SI
1315 (match_operand:SI 2 "gpc_reg_operand" "r")
1316 (const_int 16))))]
1317 "TARGET_MULHW"
1318 "mulhhw %0, %1, %2"
1319 [(set_attr "type" "imul3")])
1320
1321(define_insn "*mulhhwuc"
1322 [(set (match_operand:CC 3 "cc_reg_operand" "=x")
1323 (compare:CC (mult:SI (lshiftrt:SI
1324 (match_operand:SI 1 "gpc_reg_operand" "%r")
1325 (const_int 16))
1326 (lshiftrt:SI
1327 (match_operand:SI 2 "gpc_reg_operand" "r")
1328 (const_int 16)))
1329 (const_int 0)))
1330 (set (match_operand:SI 0 "gpc_reg_operand" "=r")
1331 (mult:SI (lshiftrt:SI
1332 (match_dup 1)
1333 (const_int 16))
1334 (lshiftrt:SI
1335 (match_dup 2)
1336 (const_int 16))))]
1337 "TARGET_MULHW"
1338 "mulhhwu. %0, %1, %2"
1339 [(set_attr "type" "imul3")])
1340
1341(define_insn "*mulhhwu"
1342 [(set (match_operand:SI 0 "gpc_reg_operand" "=r")
1343 (mult:SI (lshiftrt:SI
1344 (match_operand:SI 1 "gpc_reg_operand" "%r")
1345 (const_int 16))
1346 (lshiftrt:SI
1347 (match_operand:SI 2 "gpc_reg_operand" "r")
1348 (const_int 16))))]
1349 "TARGET_MULHW"
1350 "mulhhwu %0, %1, %2"
1351 [(set_attr "type" "imul3")])
1352
1353(define_insn "*mullhwc"
1354 [(set (match_operand:CC 3 "cc_reg_operand" "=x")
1355 (compare:CC (mult:SI (sign_extend:SI
1356 (match_operand:HI 1 "gpc_reg_operand" "%r"))
1357 (sign_extend:SI
1358 (match_operand:HI 2 "gpc_reg_operand" "r")))
1359 (const_int 0)))
1360 (set (match_operand:SI 0 "gpc_reg_operand" "=r")
1361 (mult:SI (sign_extend:SI
1362 (match_dup 1))
1363 (sign_extend:SI
1364 (match_dup 2))))]
1365 "TARGET_MULHW"
1366 "mullhw. %0, %1, %2"
1367 [(set_attr "type" "imul3")])
1368
1369(define_insn "*mullhw"
1370 [(set (match_operand:SI 0 "gpc_reg_operand" "=r")
1371 (mult:SI (sign_extend:SI
1372 (match_operand:HI 1 "gpc_reg_operand" "%r"))
1373 (sign_extend:SI
1374 (match_operand:HI 2 "gpc_reg_operand" "r"))))]
1375 "TARGET_MULHW"
1376 "mullhw %0, %1, %2"
1377 [(set_attr "type" "imul3")])
1378
1379(define_insn "*mullhwuc"
1380 [(set (match_operand:CC 3 "cc_reg_operand" "=x")
1381 (compare:CC (mult:SI (zero_extend:SI
1382 (match_operand:HI 1 "gpc_reg_operand" "%r"))
1383 (zero_extend:SI
1384 (match_operand:HI 2 "gpc_reg_operand" "r")))
1385 (const_int 0)))
1386 (set (match_operand:SI 0 "gpc_reg_operand" "=r")
1387 (mult:SI (zero_extend:SI
1388 (match_dup 1))
1389 (zero_extend:SI
1390 (match_dup 2))))]
1391 "TARGET_MULHW"
1392 "mullhwu. %0, %1, %2"
1393 [(set_attr "type" "imul3")])
1394
1395(define_insn "*mullhwu"
1396 [(set (match_operand:SI 0 "gpc_reg_operand" "=r")
1397 (mult:SI (zero_extend:SI
1398 (match_operand:HI 1 "gpc_reg_operand" "%r"))
1399 (zero_extend:SI
1400 (match_operand:HI 2 "gpc_reg_operand" "r"))))]
1401 "TARGET_MULHW"
1402 "mullhwu %0, %1, %2"
1403 [(set_attr "type" "imul3")])
1404\f
4adf8008 1405;; IBM 405, 440 and 464 string-search dlmzb instruction support.
716019c0
JM
1406(define_insn "dlmzb"
1407 [(set (match_operand:CC 3 "cc_reg_operand" "=x")
1408 (unspec:CC [(match_operand:SI 1 "gpc_reg_operand" "r")
1409 (match_operand:SI 2 "gpc_reg_operand" "r")]
1410 UNSPEC_DLMZB_CR))
1411 (set (match_operand:SI 0 "gpc_reg_operand" "=r")
1412 (unspec:SI [(match_dup 1)
1413 (match_dup 2)]
1414 UNSPEC_DLMZB))]
1415 "TARGET_DLMZB"
1416 "dlmzb. %0, %1, %2")
1417
1418(define_expand "strlensi"
1419 [(set (match_operand:SI 0 "gpc_reg_operand" "")
1420 (unspec:SI [(match_operand:BLK 1 "general_operand" "")
1421 (match_operand:QI 2 "const_int_operand" "")
1422 (match_operand 3 "const_int_operand" "")]
1423 UNSPEC_DLMZB_STRLEN))
1424 (clobber (match_scratch:CC 4 "=x"))]
1425 "TARGET_DLMZB && WORDS_BIG_ENDIAN && !optimize_size"
1426{
1427 rtx result = operands[0];
1428 rtx src = operands[1];
1429 rtx search_char = operands[2];
1430 rtx align = operands[3];
1431 rtx addr, scratch_string, word1, word2, scratch_dlmzb;
1432 rtx loop_label, end_label, mem, cr0, cond;
1433 if (search_char != const0_rtx
1434 || GET_CODE (align) != CONST_INT
1435 || INTVAL (align) < 8)
1436 FAIL;
1437 word1 = gen_reg_rtx (SImode);
1438 word2 = gen_reg_rtx (SImode);
1439 scratch_dlmzb = gen_reg_rtx (SImode);
1440 scratch_string = gen_reg_rtx (Pmode);
1441 loop_label = gen_label_rtx ();
1442 end_label = gen_label_rtx ();
1443 addr = force_reg (Pmode, XEXP (src, 0));
1444 emit_move_insn (scratch_string, addr);
1445 emit_label (loop_label);
1446 mem = change_address (src, SImode, scratch_string);
1447 emit_move_insn (word1, mem);
1448 emit_move_insn (word2, adjust_address (mem, SImode, 4));
1449 cr0 = gen_rtx_REG (CCmode, CR0_REGNO);
1450 emit_insn (gen_dlmzb (scratch_dlmzb, word1, word2, cr0));
1451 cond = gen_rtx_NE (VOIDmode, cr0, const0_rtx);
1452 emit_jump_insn (gen_rtx_SET (VOIDmode,
1453 pc_rtx,
1454 gen_rtx_IF_THEN_ELSE (VOIDmode,
1455 cond,
1456 gen_rtx_LABEL_REF
1457 (VOIDmode,
1458 end_label),
1459 pc_rtx)));
1460 emit_insn (gen_addsi3 (scratch_string, scratch_string, GEN_INT (8)));
1461 emit_jump_insn (gen_rtx_SET (VOIDmode,
1462 pc_rtx,
1463 gen_rtx_LABEL_REF (VOIDmode, loop_label)));
ea5bd0d8 1464 emit_barrier ();
716019c0
JM
1465 emit_label (end_label);
1466 emit_insn (gen_addsi3 (scratch_string, scratch_string, scratch_dlmzb));
1467 emit_insn (gen_subsi3 (result, scratch_string, addr));
1468 emit_insn (gen_subsi3 (result, result, const1_rtx));
1469 DONE;
1470})
1471\f
9ebbca7d
GK
1472(define_split
1473 [(set (match_operand:CC 2 "cc_reg_not_cr0_operand" "")
1474 (compare:CC (sign_extend:SI (match_operand:HI 1 "gpc_reg_operand" ""))
1475 (const_int 0)))
1476 (set (match_operand:SI 0 "gpc_reg_operand" "")
1477 (sign_extend:SI (match_dup 1)))]
1478 "reload_completed"
1479 [(set (match_dup 0)
1480 (sign_extend:SI (match_dup 1)))
1481 (set (match_dup 2)
1482 (compare:CC (match_dup 0)
1483 (const_int 0)))]
1484 "")
1485
1fd4e8c1 1486;; Fixed-point arithmetic insns.
deb9225a 1487
0354e5d8
GK
1488(define_expand "add<mode>3"
1489 [(set (match_operand:SDI 0 "gpc_reg_operand" "")
1490 (plus:SDI (match_operand:SDI 1 "gpc_reg_operand" "")
4ae234b0 1491 (match_operand:SDI 2 "reg_or_add_cint_operand" "")))]
7cd5235b 1492 ""
7cd5235b 1493{
0354e5d8
GK
1494 if (<MODE>mode == DImode && ! TARGET_POWERPC64)
1495 {
1496 if (non_short_cint_operand (operands[2], DImode))
1497 FAIL;
1498 }
1499 else if (GET_CODE (operands[2]) == CONST_INT
1500 && ! add_operand (operands[2], <MODE>mode))
7cd5235b 1501 {
b3a13419
ILT
1502 rtx tmp = ((!can_create_pseudo_p ()
1503 || rtx_equal_p (operands[0], operands[1]))
0354e5d8 1504 ? operands[0] : gen_reg_rtx (<MODE>mode));
7cd5235b 1505
2bfcf297 1506 HOST_WIDE_INT val = INTVAL (operands[2]);
a65c591c 1507 HOST_WIDE_INT low = ((val & 0xffff) ^ 0x8000) - 0x8000;
0354e5d8
GK
1508 HOST_WIDE_INT rest = trunc_int_for_mode (val - low, <MODE>mode);
1509
279bb624 1510 if (<MODE>mode == DImode && !satisfies_constraint_L (GEN_INT (rest)))
0354e5d8 1511 FAIL;
7cd5235b 1512
9ebbca7d
GK
1513 /* The ordering here is important for the prolog expander.
1514 When space is allocated from the stack, adding 'low' first may
1515 produce a temporary deallocation (which would be bad). */
0354e5d8
GK
1516 emit_insn (gen_add<mode>3 (tmp, operands[1], GEN_INT (rest)));
1517 emit_insn (gen_add<mode>3 (operands[0], tmp, GEN_INT (low)));
7cd5235b
MM
1518 DONE;
1519 }
279bb624 1520})
7cd5235b 1521
0354e5d8
GK
1522;; Discourage ai/addic because of carry but provide it in an alternative
1523;; allowing register zero as source.
1524(define_insn "*add<mode>3_internal1"
1525 [(set (match_operand:GPR 0 "gpc_reg_operand" "=r,r,?r,r")
1526 (plus:GPR (match_operand:GPR 1 "gpc_reg_operand" "%r,b,r,b")
1527 (match_operand:GPR 2 "add_operand" "r,I,I,L")))]
7393f7f8 1528 "!DECIMAL_FLOAT_MODE_P (GET_MODE (operands[0])) && !DECIMAL_FLOAT_MODE_P (GET_MODE (operands[1]))"
1fd4e8c1 1529 "@
deb9225a
RK
1530 {cax|add} %0,%1,%2
1531 {cal %0,%2(%1)|addi %0,%1,%2}
1532 {ai|addic} %0,%1,%2
7cd5235b
MM
1533 {cau|addis} %0,%1,%v2"
1534 [(set_attr "length" "4,4,4,4")])
1fd4e8c1 1535
ee890fe2
SS
1536(define_insn "addsi3_high"
1537 [(set (match_operand:SI 0 "gpc_reg_operand" "=b")
1538 (plus:SI (match_operand:SI 1 "gpc_reg_operand" "b")
1539 (high:SI (match_operand 2 "" ""))))]
1540 "TARGET_MACHO && !TARGET_64BIT"
1541 "{cau|addis} %0,%1,ha16(%2)"
1542 [(set_attr "length" "4")])
1543
0354e5d8 1544(define_insn "*add<mode>3_internal2"
cb8cc086 1545 [(set (match_operand:CC 0 "cc_reg_operand" "=x,x,?y,?y")
0354e5d8
GK
1546 (compare:CC (plus:P (match_operand:P 1 "gpc_reg_operand" "%r,r,r,r")
1547 (match_operand:P 2 "reg_or_short_operand" "r,I,r,I"))
1fd4e8c1 1548 (const_int 0)))
0354e5d8
GK
1549 (clobber (match_scratch:P 3 "=r,r,r,r"))]
1550 ""
deb9225a
RK
1551 "@
1552 {cax.|add.} %3,%1,%2
cb8cc086
MM
1553 {ai.|addic.} %3,%1,%2
1554 #
1555 #"
a62bfff2 1556 [(set_attr "type" "fast_compare,compare,compare,compare")
cb8cc086
MM
1557 (set_attr "length" "4,4,8,8")])
1558
1559(define_split
1560 [(set (match_operand:CC 0 "cc_reg_not_cr0_operand" "")
0354e5d8
GK
1561 (compare:CC (plus:GPR (match_operand:GPR 1 "gpc_reg_operand" "")
1562 (match_operand:GPR 2 "reg_or_short_operand" ""))
cb8cc086 1563 (const_int 0)))
0354e5d8
GK
1564 (clobber (match_scratch:GPR 3 ""))]
1565 "reload_completed"
cb8cc086 1566 [(set (match_dup 3)
0354e5d8 1567 (plus:GPR (match_dup 1)
cb8cc086
MM
1568 (match_dup 2)))
1569 (set (match_dup 0)
1570 (compare:CC (match_dup 3)
1571 (const_int 0)))]
1572 "")
7e69e155 1573
0354e5d8 1574(define_insn "*add<mode>3_internal3"
cb8cc086 1575 [(set (match_operand:CC 3 "cc_reg_operand" "=x,x,?y,?y")
0354e5d8
GK
1576 (compare:CC (plus:P (match_operand:P 1 "gpc_reg_operand" "%r,r,r,r")
1577 (match_operand:P 2 "reg_or_short_operand" "r,I,r,I"))
1fd4e8c1 1578 (const_int 0)))
0354e5d8
GK
1579 (set (match_operand:P 0 "gpc_reg_operand" "=r,r,r,r")
1580 (plus:P (match_dup 1)
1581 (match_dup 2)))]
1582 ""
deb9225a
RK
1583 "@
1584 {cax.|add.} %0,%1,%2
cb8cc086
MM
1585 {ai.|addic.} %0,%1,%2
1586 #
1587 #"
a62bfff2 1588 [(set_attr "type" "fast_compare,compare,compare,compare")
cb8cc086
MM
1589 (set_attr "length" "4,4,8,8")])
1590
1591(define_split
1592 [(set (match_operand:CC 3 "cc_reg_not_cr0_operand" "")
0354e5d8
GK
1593 (compare:CC (plus:P (match_operand:P 1 "gpc_reg_operand" "")
1594 (match_operand:P 2 "reg_or_short_operand" ""))
cb8cc086 1595 (const_int 0)))
0354e5d8
GK
1596 (set (match_operand:P 0 "gpc_reg_operand" "")
1597 (plus:P (match_dup 1) (match_dup 2)))]
1598 "reload_completed"
cb8cc086 1599 [(set (match_dup 0)
0354e5d8
GK
1600 (plus:P (match_dup 1)
1601 (match_dup 2)))
cb8cc086
MM
1602 (set (match_dup 3)
1603 (compare:CC (match_dup 0)
1604 (const_int 0)))]
1605 "")
7e69e155 1606
f357808b
RK
1607;; Split an add that we can't do in one insn into two insns, each of which
1608;; does one 16-bit part. This is used by combine. Note that the low-order
1609;; add should be last in case the result gets used in an address.
1610
1611(define_split
0354e5d8
GK
1612 [(set (match_operand:GPR 0 "gpc_reg_operand" "")
1613 (plus:GPR (match_operand:GPR 1 "gpc_reg_operand" "")
1614 (match_operand:GPR 2 "non_add_cint_operand" "")))]
1fd4e8c1 1615 ""
0354e5d8
GK
1616 [(set (match_dup 0) (plus:GPR (match_dup 1) (match_dup 3)))
1617 (set (match_dup 0) (plus:GPR (match_dup 0) (match_dup 4)))]
1fd4e8c1 1618{
2bfcf297 1619 HOST_WIDE_INT val = INTVAL (operands[2]);
a65c591c 1620 HOST_WIDE_INT low = ((val & 0xffff) ^ 0x8000) - 0x8000;
0354e5d8 1621 HOST_WIDE_INT rest = trunc_int_for_mode (val - low, <MODE>mode);
1fd4e8c1 1622
e6ca2c17 1623 operands[4] = GEN_INT (low);
279bb624 1624 if (<MODE>mode == SImode || satisfies_constraint_L (GEN_INT (rest)))
0354e5d8 1625 operands[3] = GEN_INT (rest);
b3a13419 1626 else if (can_create_pseudo_p ())
0354e5d8
GK
1627 {
1628 operands[3] = gen_reg_rtx (DImode);
1629 emit_move_insn (operands[3], operands[2]);
1630 emit_insn (gen_adddi3 (operands[0], operands[1], operands[3]));
1631 DONE;
1632 }
1633 else
1634 FAIL;
279bb624 1635})
1fd4e8c1 1636
0354e5d8
GK
1637(define_insn "one_cmpl<mode>2"
1638 [(set (match_operand:GPR 0 "gpc_reg_operand" "=r")
1639 (not:GPR (match_operand:GPR 1 "gpc_reg_operand" "r")))]
1fd4e8c1 1640 ""
ca7f5001
RK
1641 "nor %0,%1,%1")
1642
1643(define_insn ""
52d3af72 1644 [(set (match_operand:CC 0 "cc_reg_operand" "=x,?y")
0354e5d8 1645 (compare:CC (not:P (match_operand:P 1 "gpc_reg_operand" "r,r"))
ca7f5001 1646 (const_int 0)))
0354e5d8
GK
1647 (clobber (match_scratch:P 2 "=r,r"))]
1648 ""
52d3af72
DE
1649 "@
1650 nor. %2,%1,%1
1651 #"
1652 [(set_attr "type" "compare")
1653 (set_attr "length" "4,8")])
1654
1655(define_split
1656 [(set (match_operand:CC 0 "cc_reg_not_cr0_operand" "")
0354e5d8 1657 (compare:CC (not:P (match_operand:P 1 "gpc_reg_operand" ""))
52d3af72 1658 (const_int 0)))
0354e5d8
GK
1659 (clobber (match_scratch:P 2 ""))]
1660 "reload_completed"
52d3af72 1661 [(set (match_dup 2)
0354e5d8 1662 (not:P (match_dup 1)))
52d3af72
DE
1663 (set (match_dup 0)
1664 (compare:CC (match_dup 2)
1665 (const_int 0)))]
1666 "")
ca7f5001
RK
1667
1668(define_insn ""
52d3af72 1669 [(set (match_operand:CC 2 "cc_reg_operand" "=x,?y")
0354e5d8 1670 (compare:CC (not:P (match_operand:P 1 "gpc_reg_operand" "r,r"))
815cdc52 1671 (const_int 0)))
0354e5d8
GK
1672 (set (match_operand:P 0 "gpc_reg_operand" "=r,r")
1673 (not:P (match_dup 1)))]
1674 ""
52d3af72
DE
1675 "@
1676 nor. %0,%1,%1
1677 #"
1678 [(set_attr "type" "compare")
1679 (set_attr "length" "4,8")])
1680
1681(define_split
1682 [(set (match_operand:CC 2 "cc_reg_not_cr0_operand" "")
0354e5d8 1683 (compare:CC (not:P (match_operand:P 1 "gpc_reg_operand" ""))
52d3af72 1684 (const_int 0)))
0354e5d8
GK
1685 (set (match_operand:P 0 "gpc_reg_operand" "")
1686 (not:P (match_dup 1)))]
1687 "reload_completed"
52d3af72 1688 [(set (match_dup 0)
0354e5d8 1689 (not:P (match_dup 1)))
52d3af72
DE
1690 (set (match_dup 2)
1691 (compare:CC (match_dup 0)
1692 (const_int 0)))]
1693 "")
1fd4e8c1
RK
1694
1695(define_insn ""
3d91674b
RK
1696 [(set (match_operand:SI 0 "gpc_reg_operand" "=r")
1697 (minus:SI (match_operand:SI 1 "reg_or_short_operand" "rI")
1698 (match_operand:SI 2 "gpc_reg_operand" "r")))]
deb9225a 1699 "! TARGET_POWERPC"
ca7f5001 1700 "{sf%I1|subf%I1c} %0,%2,%1")
1fd4e8c1 1701
deb9225a 1702(define_insn ""
0354e5d8
GK
1703 [(set (match_operand:GPR 0 "gpc_reg_operand" "=r,r")
1704 (minus:GPR (match_operand:GPR 1 "reg_or_short_operand" "r,I")
1705 (match_operand:GPR 2 "gpc_reg_operand" "r,r")))]
deb9225a
RK
1706 "TARGET_POWERPC"
1707 "@
1708 subf %0,%2,%1
1709 subfic %0,%2,%1")
1710
1fd4e8c1 1711(define_insn ""
cb8cc086
MM
1712 [(set (match_operand:CC 0 "cc_reg_operand" "=x,?y")
1713 (compare:CC (minus:SI (match_operand:SI 1 "gpc_reg_operand" "r,r")
1714 (match_operand:SI 2 "gpc_reg_operand" "r,r"))
1fd4e8c1 1715 (const_int 0)))
cb8cc086 1716 (clobber (match_scratch:SI 3 "=r,r"))]
deb9225a 1717 "! TARGET_POWERPC"
cb8cc086
MM
1718 "@
1719 {sf.|subfc.} %3,%2,%1
1720 #"
1721 [(set_attr "type" "compare")
1722 (set_attr "length" "4,8")])
1fd4e8c1 1723
deb9225a 1724(define_insn ""
cb8cc086 1725 [(set (match_operand:CC 0 "cc_reg_operand" "=x,?y")
0354e5d8
GK
1726 (compare:CC (minus:P (match_operand:P 1 "gpc_reg_operand" "r,r")
1727 (match_operand:P 2 "gpc_reg_operand" "r,r"))
deb9225a 1728 (const_int 0)))
0354e5d8
GK
1729 (clobber (match_scratch:P 3 "=r,r"))]
1730 "TARGET_POWERPC"
cb8cc086
MM
1731 "@
1732 subf. %3,%2,%1
1733 #"
a62bfff2 1734 [(set_attr "type" "fast_compare")
cb8cc086
MM
1735 (set_attr "length" "4,8")])
1736
1737(define_split
1738 [(set (match_operand:CC 0 "cc_reg_not_cr0_operand" "")
0354e5d8
GK
1739 (compare:CC (minus:P (match_operand:P 1 "gpc_reg_operand" "")
1740 (match_operand:P 2 "gpc_reg_operand" ""))
cb8cc086 1741 (const_int 0)))
0354e5d8
GK
1742 (clobber (match_scratch:P 3 ""))]
1743 "reload_completed"
cb8cc086 1744 [(set (match_dup 3)
0354e5d8 1745 (minus:P (match_dup 1)
cb8cc086
MM
1746 (match_dup 2)))
1747 (set (match_dup 0)
1748 (compare:CC (match_dup 3)
1749 (const_int 0)))]
1750 "")
deb9225a 1751
1fd4e8c1 1752(define_insn ""
cb8cc086
MM
1753 [(set (match_operand:CC 3 "cc_reg_operand" "=x,?y")
1754 (compare:CC (minus:SI (match_operand:SI 1 "gpc_reg_operand" "r,r")
1755 (match_operand:SI 2 "gpc_reg_operand" "r,r"))
1fd4e8c1 1756 (const_int 0)))
cb8cc086 1757 (set (match_operand:SI 0 "gpc_reg_operand" "=r,r")
1fd4e8c1 1758 (minus:SI (match_dup 1) (match_dup 2)))]
deb9225a 1759 "! TARGET_POWERPC"
cb8cc086
MM
1760 "@
1761 {sf.|subfc.} %0,%2,%1
1762 #"
1763 [(set_attr "type" "compare")
1764 (set_attr "length" "4,8")])
815cdc52 1765
29ae5b89 1766(define_insn ""
cb8cc086 1767 [(set (match_operand:CC 3 "cc_reg_operand" "=x,?y")
0354e5d8
GK
1768 (compare:CC (minus:P (match_operand:P 1 "gpc_reg_operand" "r,r")
1769 (match_operand:P 2 "gpc_reg_operand" "r,r"))
815cdc52 1770 (const_int 0)))
0354e5d8
GK
1771 (set (match_operand:P 0 "gpc_reg_operand" "=r,r")
1772 (minus:P (match_dup 1)
cb8cc086 1773 (match_dup 2)))]
0354e5d8 1774 "TARGET_POWERPC"
90612787
DE
1775 "@
1776 subf. %0,%2,%1
1777 #"
a62bfff2 1778 [(set_attr "type" "fast_compare")
cb8cc086
MM
1779 (set_attr "length" "4,8")])
1780
1781(define_split
1782 [(set (match_operand:CC 3 "cc_reg_not_cr0_operand" "")
0354e5d8
GK
1783 (compare:CC (minus:P (match_operand:P 1 "gpc_reg_operand" "")
1784 (match_operand:P 2 "gpc_reg_operand" ""))
cb8cc086 1785 (const_int 0)))
0354e5d8
GK
1786 (set (match_operand:P 0 "gpc_reg_operand" "")
1787 (minus:P (match_dup 1)
cb8cc086 1788 (match_dup 2)))]
0354e5d8 1789 "reload_completed"
cb8cc086 1790 [(set (match_dup 0)
0354e5d8 1791 (minus:P (match_dup 1)
cb8cc086
MM
1792 (match_dup 2)))
1793 (set (match_dup 3)
1794 (compare:CC (match_dup 0)
1795 (const_int 0)))]
1796 "")
deb9225a 1797
0354e5d8
GK
1798(define_expand "sub<mode>3"
1799 [(set (match_operand:SDI 0 "gpc_reg_operand" "")
1800 (minus:SDI (match_operand:SDI 1 "reg_or_short_operand" "")
4ae234b0 1801 (match_operand:SDI 2 "reg_or_sub_cint_operand" "")))]
1fd4e8c1 1802 ""
a0044fb1
RK
1803 "
1804{
1805 if (GET_CODE (operands[2]) == CONST_INT)
1806 {
0354e5d8
GK
1807 emit_insn (gen_add<mode>3 (operands[0], operands[1],
1808 negate_rtx (<MODE>mode, operands[2])));
a0044fb1
RK
1809 DONE;
1810 }
1811}")
1fd4e8c1
RK
1812
1813;; For SMIN, SMAX, UMIN, and UMAX, we use DEFINE_EXPAND's that involve a doz[i]
1814;; instruction and some auxiliary computations. Then we just have a single
95ac8e67
RK
1815;; DEFINE_INSN for doz[i] and the define_splits to make them if made by
1816;; combine.
1fd4e8c1
RK
1817
1818(define_expand "sminsi3"
1819 [(set (match_dup 3)
cd2b37d9 1820 (if_then_else:SI (gt:SI (match_operand:SI 1 "gpc_reg_operand" "")
1fd4e8c1
RK
1821 (match_operand:SI 2 "reg_or_short_operand" ""))
1822 (const_int 0)
1823 (minus:SI (match_dup 2) (match_dup 1))))
cd2b37d9 1824 (set (match_operand:SI 0 "gpc_reg_operand" "")
1fd4e8c1 1825 (minus:SI (match_dup 2) (match_dup 3)))]
a3170dc6 1826 "TARGET_POWER || TARGET_ISEL"
1fd4e8c1 1827 "
a3170dc6
AH
1828{
1829 if (TARGET_ISEL)
1830 {
1831 operands[2] = force_reg (SImode, operands[2]);
1832 rs6000_emit_minmax (operands[0], SMIN, operands[1], operands[2]);
1833 DONE;
1834 }
1835
1836 operands[3] = gen_reg_rtx (SImode);
1837}")
1fd4e8c1 1838
95ac8e67
RK
1839(define_split
1840 [(set (match_operand:SI 0 "gpc_reg_operand" "")
1841 (smin:SI (match_operand:SI 1 "gpc_reg_operand" "")
1842 (match_operand:SI 2 "reg_or_short_operand" "")))
1843 (clobber (match_operand:SI 3 "gpc_reg_operand" ""))]
ca7f5001 1844 "TARGET_POWER"
95ac8e67
RK
1845 [(set (match_dup 3)
1846 (if_then_else:SI (gt:SI (match_dup 1) (match_dup 2))
1847 (const_int 0)
1848 (minus:SI (match_dup 2) (match_dup 1))))
1849 (set (match_dup 0) (minus:SI (match_dup 2) (match_dup 3)))]
1850 "")
1851
1fd4e8c1
RK
1852(define_expand "smaxsi3"
1853 [(set (match_dup 3)
cd2b37d9 1854 (if_then_else:SI (gt:SI (match_operand:SI 1 "gpc_reg_operand" "")
1fd4e8c1
RK
1855 (match_operand:SI 2 "reg_or_short_operand" ""))
1856 (const_int 0)
1857 (minus:SI (match_dup 2) (match_dup 1))))
cd2b37d9 1858 (set (match_operand:SI 0 "gpc_reg_operand" "")
1fd4e8c1 1859 (plus:SI (match_dup 3) (match_dup 1)))]
a3170dc6 1860 "TARGET_POWER || TARGET_ISEL"
1fd4e8c1 1861 "
a3170dc6
AH
1862{
1863 if (TARGET_ISEL)
1864 {
1865 operands[2] = force_reg (SImode, operands[2]);
1866 rs6000_emit_minmax (operands[0], SMAX, operands[1], operands[2]);
1867 DONE;
1868 }
1869 operands[3] = gen_reg_rtx (SImode);
1870}")
1fd4e8c1 1871
95ac8e67
RK
1872(define_split
1873 [(set (match_operand:SI 0 "gpc_reg_operand" "")
1874 (smax:SI (match_operand:SI 1 "gpc_reg_operand" "")
1875 (match_operand:SI 2 "reg_or_short_operand" "")))
1876 (clobber (match_operand:SI 3 "gpc_reg_operand" ""))]
ca7f5001 1877 "TARGET_POWER"
95ac8e67
RK
1878 [(set (match_dup 3)
1879 (if_then_else:SI (gt:SI (match_dup 1) (match_dup 2))
1880 (const_int 0)
1881 (minus:SI (match_dup 2) (match_dup 1))))
1882 (set (match_dup 0) (plus:SI (match_dup 3) (match_dup 1)))]
1883 "")
1884
1fd4e8c1 1885(define_expand "uminsi3"
cd2b37d9 1886 [(set (match_dup 3) (xor:SI (match_operand:SI 1 "gpc_reg_operand" "")
bb68ff55 1887 (match_dup 5)))
cd2b37d9 1888 (set (match_dup 4) (xor:SI (match_operand:SI 2 "gpc_reg_operand" "")
bb68ff55 1889 (match_dup 5)))
1fd4e8c1
RK
1890 (set (match_dup 3) (if_then_else:SI (gt (match_dup 3) (match_dup 4))
1891 (const_int 0)
1892 (minus:SI (match_dup 4) (match_dup 3))))
cd2b37d9 1893 (set (match_operand:SI 0 "gpc_reg_operand" "")
1fd4e8c1 1894 (minus:SI (match_dup 2) (match_dup 3)))]
a3170dc6 1895 "TARGET_POWER || TARGET_ISEL"
1fd4e8c1 1896 "
bb68ff55 1897{
a3170dc6
AH
1898 if (TARGET_ISEL)
1899 {
1900 rs6000_emit_minmax (operands[0], UMIN, operands[1], operands[2]);
1901 DONE;
1902 }
bb68ff55
MM
1903 operands[3] = gen_reg_rtx (SImode);
1904 operands[4] = gen_reg_rtx (SImode);
1905 operands[5] = GEN_INT (-2147483647 - 1);
1906}")
1fd4e8c1
RK
1907
1908(define_expand "umaxsi3"
cd2b37d9 1909 [(set (match_dup 3) (xor:SI (match_operand:SI 1 "gpc_reg_operand" "")
bb68ff55 1910 (match_dup 5)))
cd2b37d9 1911 (set (match_dup 4) (xor:SI (match_operand:SI 2 "gpc_reg_operand" "")
bb68ff55 1912 (match_dup 5)))
1fd4e8c1
RK
1913 (set (match_dup 3) (if_then_else:SI (gt (match_dup 3) (match_dup 4))
1914 (const_int 0)
1915 (minus:SI (match_dup 4) (match_dup 3))))
cd2b37d9 1916 (set (match_operand:SI 0 "gpc_reg_operand" "")
1fd4e8c1 1917 (plus:SI (match_dup 3) (match_dup 1)))]
a3170dc6 1918 "TARGET_POWER || TARGET_ISEL"
1fd4e8c1 1919 "
bb68ff55 1920{
a3170dc6
AH
1921 if (TARGET_ISEL)
1922 {
1923 rs6000_emit_minmax (operands[0], UMAX, operands[1], operands[2]);
1924 DONE;
1925 }
bb68ff55
MM
1926 operands[3] = gen_reg_rtx (SImode);
1927 operands[4] = gen_reg_rtx (SImode);
1928 operands[5] = GEN_INT (-2147483647 - 1);
1929}")
1fd4e8c1
RK
1930
1931(define_insn ""
cd2b37d9
RK
1932 [(set (match_operand:SI 0 "gpc_reg_operand" "=r")
1933 (if_then_else:SI (gt (match_operand:SI 1 "gpc_reg_operand" "r")
5c23c401 1934 (match_operand:SI 2 "reg_or_short_operand" "rI"))
1fd4e8c1
RK
1935 (const_int 0)
1936 (minus:SI (match_dup 2) (match_dup 1))))]
ca7f5001 1937 "TARGET_POWER"
1fd4e8c1
RK
1938 "doz%I2 %0,%1,%2")
1939
1940(define_insn ""
9ebbca7d 1941 [(set (match_operand:CC 0 "cc_reg_operand" "=x,?y")
1fd4e8c1 1942 (compare:CC
9ebbca7d
GK
1943 (if_then_else:SI (gt (match_operand:SI 1 "gpc_reg_operand" "r,r")
1944 (match_operand:SI 2 "reg_or_short_operand" "rI,rI"))
1fd4e8c1
RK
1945 (const_int 0)
1946 (minus:SI (match_dup 2) (match_dup 1)))
1947 (const_int 0)))
9ebbca7d 1948 (clobber (match_scratch:SI 3 "=r,r"))]
ca7f5001 1949 "TARGET_POWER"
9ebbca7d
GK
1950 "@
1951 doz%I2. %3,%1,%2
1952 #"
1953 [(set_attr "type" "delayed_compare")
1954 (set_attr "length" "4,8")])
1955
1956(define_split
1957 [(set (match_operand:CC 0 "cc_reg_not_cr0_operand" "")
1958 (compare:CC
1959 (if_then_else:SI (gt (match_operand:SI 1 "gpc_reg_operand" "")
1960 (match_operand:SI 2 "reg_or_short_operand" ""))
1961 (const_int 0)
1962 (minus:SI (match_dup 2) (match_dup 1)))
1963 (const_int 0)))
1964 (clobber (match_scratch:SI 3 ""))]
1965 "TARGET_POWER && reload_completed"
1966 [(set (match_dup 3)
1967 (if_then_else:SI (gt (match_dup 1) (match_dup 2))
1968 (const_int 0)
1969 (minus:SI (match_dup 2) (match_dup 1))))
1970 (set (match_dup 0)
1971 (compare:CC (match_dup 3)
1972 (const_int 0)))]
1973 "")
1fd4e8c1
RK
1974
1975(define_insn ""
9ebbca7d 1976 [(set (match_operand:CC 3 "cc_reg_operand" "=x,?y")
1fd4e8c1 1977 (compare:CC
9ebbca7d
GK
1978 (if_then_else:SI (gt (match_operand:SI 1 "gpc_reg_operand" "r,r")
1979 (match_operand:SI 2 "reg_or_short_operand" "rI,rI"))
1fd4e8c1
RK
1980 (const_int 0)
1981 (minus:SI (match_dup 2) (match_dup 1)))
1982 (const_int 0)))
9ebbca7d 1983 (set (match_operand:SI 0 "gpc_reg_operand" "=r,r")
1fd4e8c1
RK
1984 (if_then_else:SI (gt (match_dup 1) (match_dup 2))
1985 (const_int 0)
1986 (minus:SI (match_dup 2) (match_dup 1))))]
ca7f5001 1987 "TARGET_POWER"
9ebbca7d
GK
1988 "@
1989 doz%I2. %0,%1,%2
1990 #"
1991 [(set_attr "type" "delayed_compare")
1992 (set_attr "length" "4,8")])
1993
1994(define_split
1995 [(set (match_operand:CC 3 "cc_reg_not_cr0_operand" "")
1996 (compare:CC
1997 (if_then_else:SI (gt (match_operand:SI 1 "gpc_reg_operand" "")
1998 (match_operand:SI 2 "reg_or_short_operand" ""))
1999 (const_int 0)
2000 (minus:SI (match_dup 2) (match_dup 1)))
2001 (const_int 0)))
2002 (set (match_operand:SI 0 "gpc_reg_operand" "")
2003 (if_then_else:SI (gt (match_dup 1) (match_dup 2))
2004 (const_int 0)
2005 (minus:SI (match_dup 2) (match_dup 1))))]
2006 "TARGET_POWER && reload_completed"
2007 [(set (match_dup 0)
2008 (if_then_else:SI (gt (match_dup 1) (match_dup 2))
2009 (const_int 0)
2010 (minus:SI (match_dup 2) (match_dup 1))))
2011 (set (match_dup 3)
2012 (compare:CC (match_dup 0)
2013 (const_int 0)))]
2014 "")
1fd4e8c1
RK
2015
2016;; We don't need abs with condition code because such comparisons should
2017;; never be done.
ea9be077
MM
2018(define_expand "abssi2"
2019 [(set (match_operand:SI 0 "gpc_reg_operand" "")
2020 (abs:SI (match_operand:SI 1 "gpc_reg_operand" "")))]
2021 ""
2022 "
2023{
a3170dc6
AH
2024 if (TARGET_ISEL)
2025 {
2026 emit_insn (gen_abssi2_isel (operands[0], operands[1]));
2027 DONE;
2028 }
2029 else if (! TARGET_POWER)
ea9be077
MM
2030 {
2031 emit_insn (gen_abssi2_nopower (operands[0], operands[1]));
2032 DONE;
2033 }
2034}")
2035
ea112fc4 2036(define_insn "*abssi2_power"
cd2b37d9
RK
2037 [(set (match_operand:SI 0 "gpc_reg_operand" "=r")
2038 (abs:SI (match_operand:SI 1 "gpc_reg_operand" "r")))]
ca7f5001 2039 "TARGET_POWER"
1fd4e8c1
RK
2040 "abs %0,%1")
2041
a3170dc6
AH
2042(define_insn_and_split "abssi2_isel"
2043 [(set (match_operand:SI 0 "gpc_reg_operand" "=r")
2044 (abs:SI (match_operand:SI 1 "gpc_reg_operand" "b")))
8c48b6f5 2045 (clobber (match_scratch:SI 2 "=&b"))
a3170dc6
AH
2046 (clobber (match_scratch:CC 3 "=y"))]
2047 "TARGET_ISEL"
2048 "#"
2049 "&& reload_completed"
2050 [(set (match_dup 2) (neg:SI (match_dup 1)))
2051 (set (match_dup 3)
2052 (compare:CC (match_dup 1)
2053 (const_int 0)))
2054 (set (match_dup 0)
2055 (if_then_else:SI (ge (match_dup 3)
2056 (const_int 0))
2057 (match_dup 1)
2058 (match_dup 2)))]
2059 "")
2060
ea112fc4 2061(define_insn_and_split "abssi2_nopower"
ea9be077 2062 [(set (match_operand:SI 0 "gpc_reg_operand" "=&r,r")
ea112fc4 2063 (abs:SI (match_operand:SI 1 "gpc_reg_operand" "r,0")))
ea9be077 2064 (clobber (match_scratch:SI 2 "=&r,&r"))]
a3170dc6 2065 "! TARGET_POWER && ! TARGET_ISEL"
ea112fc4
DE
2066 "#"
2067 "&& reload_completed"
ea9be077
MM
2068 [(set (match_dup 2) (ashiftrt:SI (match_dup 1) (const_int 31)))
2069 (set (match_dup 0) (xor:SI (match_dup 2) (match_dup 1)))
7093ddee 2070 (set (match_dup 0) (minus:SI (match_dup 0) (match_dup 2)))]
ea9be077
MM
2071 "")
2072
463b558b 2073(define_insn "*nabs_power"
cd2b37d9
RK
2074 [(set (match_operand:SI 0 "gpc_reg_operand" "=r")
2075 (neg:SI (abs:SI (match_operand:SI 1 "gpc_reg_operand" "r"))))]
ca7f5001 2076 "TARGET_POWER"
1fd4e8c1
RK
2077 "nabs %0,%1")
2078
ea112fc4 2079(define_insn_and_split "*nabs_nopower"
ea9be077 2080 [(set (match_operand:SI 0 "gpc_reg_operand" "=&r,r")
ea112fc4 2081 (neg:SI (abs:SI (match_operand:SI 1 "gpc_reg_operand" "r,0"))))
ea9be077 2082 (clobber (match_scratch:SI 2 "=&r,&r"))]
0ad91047 2083 "! TARGET_POWER"
ea112fc4
DE
2084 "#"
2085 "&& reload_completed"
ea9be077
MM
2086 [(set (match_dup 2) (ashiftrt:SI (match_dup 1) (const_int 31)))
2087 (set (match_dup 0) (xor:SI (match_dup 2) (match_dup 1)))
7093ddee 2088 (set (match_dup 0) (minus:SI (match_dup 2) (match_dup 0)))]
ea9be077
MM
2089 "")
2090
0354e5d8
GK
2091(define_expand "neg<mode>2"
2092 [(set (match_operand:SDI 0 "gpc_reg_operand" "")
2093 (neg:SDI (match_operand:SDI 1 "gpc_reg_operand" "")))]
2094 ""
2095 "")
2096
2097(define_insn "*neg<mode>2_internal"
2098 [(set (match_operand:GPR 0 "gpc_reg_operand" "=r")
2099 (neg:GPR (match_operand:GPR 1 "gpc_reg_operand" "r")))]
1fd4e8c1
RK
2100 ""
2101 "neg %0,%1")
2102
2103(define_insn ""
9ebbca7d 2104 [(set (match_operand:CC 0 "cc_reg_operand" "=x,?y")
0354e5d8 2105 (compare:CC (neg:P (match_operand:P 1 "gpc_reg_operand" "r,r"))
1fd4e8c1 2106 (const_int 0)))
0354e5d8
GK
2107 (clobber (match_scratch:P 2 "=r,r"))]
2108 ""
9ebbca7d
GK
2109 "@
2110 neg. %2,%1
2111 #"
a62bfff2 2112 [(set_attr "type" "fast_compare")
9ebbca7d
GK
2113 (set_attr "length" "4,8")])
2114
2115(define_split
2116 [(set (match_operand:CC 0 "cc_reg_not_cr0_operand" "")
0354e5d8 2117 (compare:CC (neg:P (match_operand:P 1 "gpc_reg_operand" ""))
9ebbca7d 2118 (const_int 0)))
0354e5d8
GK
2119 (clobber (match_scratch:P 2 ""))]
2120 "reload_completed"
9ebbca7d 2121 [(set (match_dup 2)
0354e5d8 2122 (neg:P (match_dup 1)))
9ebbca7d
GK
2123 (set (match_dup 0)
2124 (compare:CC (match_dup 2)
2125 (const_int 0)))]
2126 "")
1fd4e8c1
RK
2127
2128(define_insn ""
9ebbca7d 2129 [(set (match_operand:CC 2 "cc_reg_operand" "=x,?y")
0354e5d8 2130 (compare:CC (neg:P (match_operand:P 1 "gpc_reg_operand" "r,r"))
815cdc52 2131 (const_int 0)))
0354e5d8
GK
2132 (set (match_operand:P 0 "gpc_reg_operand" "=r,r")
2133 (neg:P (match_dup 1)))]
2134 ""
9ebbca7d
GK
2135 "@
2136 neg. %0,%1
2137 #"
a62bfff2 2138 [(set_attr "type" "fast_compare")
9ebbca7d
GK
2139 (set_attr "length" "4,8")])
2140
2141(define_split
2142 [(set (match_operand:CC 2 "cc_reg_not_cr0_operand" "")
0354e5d8 2143 (compare:CC (neg:P (match_operand:P 1 "gpc_reg_operand" ""))
9ebbca7d 2144 (const_int 0)))
0354e5d8
GK
2145 (set (match_operand:P 0 "gpc_reg_operand" "")
2146 (neg:P (match_dup 1)))]
66859ace 2147 "reload_completed"
9ebbca7d 2148 [(set (match_dup 0)
0354e5d8 2149 (neg:P (match_dup 1)))
9ebbca7d
GK
2150 (set (match_dup 2)
2151 (compare:CC (match_dup 0)
2152 (const_int 0)))]
2153 "")
1fd4e8c1 2154
0354e5d8
GK
2155(define_insn "clz<mode>2"
2156 [(set (match_operand:GPR 0 "gpc_reg_operand" "=r")
2157 (clz:GPR (match_operand:GPR 1 "gpc_reg_operand" "r")))]
1b1edcfa 2158 ""
44cd321e
PS
2159 "{cntlz|cntlz<wd>} %0,%1"
2160 [(set_attr "type" "cntlz")])
1b1edcfa 2161
0354e5d8 2162(define_expand "ctz<mode>2"
4977bab6 2163 [(set (match_dup 2)
e42ac3de 2164 (neg:GPR (match_operand:GPR 1 "gpc_reg_operand" "")))
0354e5d8
GK
2165 (parallel [(set (match_dup 3) (and:GPR (match_dup 1)
2166 (match_dup 2)))
1b1edcfa 2167 (clobber (scratch:CC))])
0354e5d8 2168 (set (match_dup 4) (clz:GPR (match_dup 3)))
e42ac3de 2169 (set (match_operand:GPR 0 "gpc_reg_operand" "")
0354e5d8 2170 (minus:GPR (match_dup 5) (match_dup 4)))]
1fd4e8c1 2171 ""
4977bab6 2172 {
0354e5d8
GK
2173 operands[2] = gen_reg_rtx (<MODE>mode);
2174 operands[3] = gen_reg_rtx (<MODE>mode);
2175 operands[4] = gen_reg_rtx (<MODE>mode);
2176 operands[5] = GEN_INT (GET_MODE_BITSIZE (<MODE>mode) - 1);
4977bab6 2177 })
6ae08853 2178
0354e5d8 2179(define_expand "ffs<mode>2"
1b1edcfa 2180 [(set (match_dup 2)
e42ac3de 2181 (neg:GPR (match_operand:GPR 1 "gpc_reg_operand" "")))
0354e5d8
GK
2182 (parallel [(set (match_dup 3) (and:GPR (match_dup 1)
2183 (match_dup 2)))
1b1edcfa 2184 (clobber (scratch:CC))])
0354e5d8 2185 (set (match_dup 4) (clz:GPR (match_dup 3)))
e42ac3de 2186 (set (match_operand:GPR 0 "gpc_reg_operand" "")
0354e5d8 2187 (minus:GPR (match_dup 5) (match_dup 4)))]
4977bab6 2188 ""
1b1edcfa 2189 {
0354e5d8
GK
2190 operands[2] = gen_reg_rtx (<MODE>mode);
2191 operands[3] = gen_reg_rtx (<MODE>mode);
2192 operands[4] = gen_reg_rtx (<MODE>mode);
2193 operands[5] = GEN_INT (GET_MODE_BITSIZE (<MODE>mode));
1b1edcfa 2194 })
6ae08853 2195
432218ba
DE
2196(define_insn "popcntb<mode>2"
2197 [(set (match_operand:GPR 0 "gpc_reg_operand" "=r")
2198 (unspec:GPR [(match_operand:GPR 1 "gpc_reg_operand" "r")]
2199 UNSPEC_POPCNTB))]
2200 "TARGET_POPCNTB"
2201 "popcntb %0,%1")
2202
565ef4ba 2203(define_expand "popcount<mode>2"
e42ac3de
RS
2204 [(set (match_operand:GPR 0 "gpc_reg_operand" "")
2205 (popcount:GPR (match_operand:GPR 1 "gpc_reg_operand" "")))]
565ef4ba
RS
2206 "TARGET_POPCNTB"
2207 {
2208 rs6000_emit_popcount (operands[0], operands[1]);
2209 DONE;
2210 })
2211
2212(define_expand "parity<mode>2"
e42ac3de
RS
2213 [(set (match_operand:GPR 0 "gpc_reg_operand" "")
2214 (parity:GPR (match_operand:GPR 1 "gpc_reg_operand" "")))]
565ef4ba
RS
2215 "TARGET_POPCNTB"
2216 {
2217 rs6000_emit_parity (operands[0], operands[1]);
2218 DONE;
2219 })
2220
03f79051
DE
2221(define_insn "bswapsi2"
2222 [(set (match_operand:SI 0 "reg_or_mem_operand" "=r,Z,&r")
2223 (bswap:SI (match_operand:SI 1 "reg_or_mem_operand" "Z,r,r")))]
2224 ""
2225 "@
2226 {lbrx|lwbrx} %0,%y1
2227 {stbrx|stwbrx} %1,%y0
2228 #"
2229 [(set_attr "length" "4,4,12")])
2230
2231(define_split
2232 [(set (match_operand:SI 0 "gpc_reg_operand" "")
2233 (bswap:SI (match_operand:SI 1 "gpc_reg_operand" "")))]
2234 "reload_completed"
2235 [(set (match_dup 0)
2236 (rotate:SI (match_dup 1) (const_int 8)))
2237 (set (zero_extract:SI (match_dup 0)
2238 (const_int 8)
2239 (const_int 0))
2240 (match_dup 1))
2241 (set (zero_extract:SI (match_dup 0)
2242 (const_int 8)
2243 (const_int 16))
2244 (rotate:SI (match_dup 1)
2245 (const_int 16)))]
2246 "")
2247
ca7f5001
RK
2248(define_expand "mulsi3"
2249 [(use (match_operand:SI 0 "gpc_reg_operand" ""))
2250 (use (match_operand:SI 1 "gpc_reg_operand" ""))
2251 (use (match_operand:SI 2 "reg_or_short_operand" ""))]
2252 ""
2253 "
2254{
2255 if (TARGET_POWER)
68b40e7e 2256 emit_insn (gen_mulsi3_mq (operands[0], operands[1], operands[2]));
ca7f5001 2257 else
68b40e7e 2258 emit_insn (gen_mulsi3_no_mq (operands[0], operands[1], operands[2]));
ca7f5001
RK
2259 DONE;
2260}")
2261
68b40e7e 2262(define_insn "mulsi3_mq"
cd2b37d9
RK
2263 [(set (match_operand:SI 0 "gpc_reg_operand" "=r,r")
2264 (mult:SI (match_operand:SI 1 "gpc_reg_operand" "%r,r")
1fd4e8c1
RK
2265 (match_operand:SI 2 "reg_or_short_operand" "r,I")))
2266 (clobber (match_scratch:SI 3 "=q,q"))]
ca7f5001
RK
2267 "TARGET_POWER"
2268 "@
2269 {muls|mullw} %0,%1,%2
2270 {muli|mulli} %0,%1,%2"
6ae08853 2271 [(set (attr "type")
c859cda6
DJ
2272 (cond [(match_operand:SI 2 "s8bit_cint_operand" "")
2273 (const_string "imul3")
6ae08853 2274 (match_operand:SI 2 "short_cint_operand" "")
c859cda6
DJ
2275 (const_string "imul2")]
2276 (const_string "imul")))])
ca7f5001 2277
68b40e7e 2278(define_insn "mulsi3_no_mq"
ca7f5001
RK
2279 [(set (match_operand:SI 0 "gpc_reg_operand" "=r,r")
2280 (mult:SI (match_operand:SI 1 "gpc_reg_operand" "%r,r")
2281 (match_operand:SI 2 "reg_or_short_operand" "r,I")))]
68b40e7e 2282 "! TARGET_POWER"
1fd4e8c1 2283 "@
d904e9ed
RK
2284 {muls|mullw} %0,%1,%2
2285 {muli|mulli} %0,%1,%2"
6ae08853 2286 [(set (attr "type")
c859cda6
DJ
2287 (cond [(match_operand:SI 2 "s8bit_cint_operand" "")
2288 (const_string "imul3")
6ae08853 2289 (match_operand:SI 2 "short_cint_operand" "")
c859cda6
DJ
2290 (const_string "imul2")]
2291 (const_string "imul")))])
1fd4e8c1 2292
9259f3b0 2293(define_insn "*mulsi3_mq_internal1"
9ebbca7d
GK
2294 [(set (match_operand:CC 0 "cc_reg_operand" "=x,?y")
2295 (compare:CC (mult:SI (match_operand:SI 1 "gpc_reg_operand" "%r,r")
2296 (match_operand:SI 2 "gpc_reg_operand" "r,r"))
1fd4e8c1 2297 (const_int 0)))
9ebbca7d
GK
2298 (clobber (match_scratch:SI 3 "=r,r"))
2299 (clobber (match_scratch:SI 4 "=q,q"))]
ca7f5001 2300 "TARGET_POWER"
9ebbca7d
GK
2301 "@
2302 {muls.|mullw.} %3,%1,%2
2303 #"
9259f3b0 2304 [(set_attr "type" "imul_compare")
9ebbca7d
GK
2305 (set_attr "length" "4,8")])
2306
2307(define_split
2308 [(set (match_operand:CC 0 "cc_reg_not_cr0_operand" "")
2309 (compare:CC (mult:SI (match_operand:SI 1 "gpc_reg_operand" "")
2310 (match_operand:SI 2 "gpc_reg_operand" ""))
2311 (const_int 0)))
2312 (clobber (match_scratch:SI 3 ""))
2313 (clobber (match_scratch:SI 4 ""))]
2314 "TARGET_POWER && reload_completed"
2315 [(parallel [(set (match_dup 3)
2316 (mult:SI (match_dup 1) (match_dup 2)))
2317 (clobber (match_dup 4))])
2318 (set (match_dup 0)
2319 (compare:CC (match_dup 3)
2320 (const_int 0)))]
2321 "")
ca7f5001 2322
9259f3b0 2323(define_insn "*mulsi3_no_mq_internal1"
9ebbca7d
GK
2324 [(set (match_operand:CC 0 "cc_reg_operand" "=x,?y")
2325 (compare:CC (mult:SI (match_operand:SI 1 "gpc_reg_operand" "%r,r")
2326 (match_operand:SI 2 "gpc_reg_operand" "r,r"))
ca7f5001 2327 (const_int 0)))
9ebbca7d 2328 (clobber (match_scratch:SI 3 "=r,r"))]
25c341fa 2329 "! TARGET_POWER"
9ebbca7d
GK
2330 "@
2331 {muls.|mullw.} %3,%1,%2
2332 #"
9259f3b0 2333 [(set_attr "type" "imul_compare")
9ebbca7d
GK
2334 (set_attr "length" "4,8")])
2335
2336(define_split
2337 [(set (match_operand:CC 0 "cc_reg_not_cr0_operand" "")
2338 (compare:CC (mult:SI (match_operand:SI 1 "gpc_reg_operand" "")
2339 (match_operand:SI 2 "gpc_reg_operand" ""))
2340 (const_int 0)))
2341 (clobber (match_scratch:SI 3 ""))]
2342 "! TARGET_POWER && reload_completed"
2343 [(set (match_dup 3)
2344 (mult:SI (match_dup 1) (match_dup 2)))
2345 (set (match_dup 0)
2346 (compare:CC (match_dup 3)
2347 (const_int 0)))]
2348 "")
1fd4e8c1 2349
9259f3b0 2350(define_insn "*mulsi3_mq_internal2"
9ebbca7d
GK
2351 [(set (match_operand:CC 3 "cc_reg_operand" "=x,?y")
2352 (compare:CC (mult:SI (match_operand:SI 1 "gpc_reg_operand" "%r,r")
2353 (match_operand:SI 2 "gpc_reg_operand" "r,r"))
1fd4e8c1 2354 (const_int 0)))
9ebbca7d 2355 (set (match_operand:SI 0 "gpc_reg_operand" "=r,r")
29ae5b89 2356 (mult:SI (match_dup 1) (match_dup 2)))
9ebbca7d 2357 (clobber (match_scratch:SI 4 "=q,q"))]
ca7f5001 2358 "TARGET_POWER"
9ebbca7d
GK
2359 "@
2360 {muls.|mullw.} %0,%1,%2
2361 #"
9259f3b0 2362 [(set_attr "type" "imul_compare")
9ebbca7d
GK
2363 (set_attr "length" "4,8")])
2364
2365(define_split
2366 [(set (match_operand:CC 3 "cc_reg_not_cr0_operand" "")
2367 (compare:CC (mult:SI (match_operand:SI 1 "gpc_reg_operand" "")
2368 (match_operand:SI 2 "gpc_reg_operand" ""))
2369 (const_int 0)))
2370 (set (match_operand:SI 0 "gpc_reg_operand" "")
2371 (mult:SI (match_dup 1) (match_dup 2)))
2372 (clobber (match_scratch:SI 4 ""))]
2373 "TARGET_POWER && reload_completed"
2374 [(parallel [(set (match_dup 0)
2375 (mult:SI (match_dup 1) (match_dup 2)))
2376 (clobber (match_dup 4))])
2377 (set (match_dup 3)
2378 (compare:CC (match_dup 0)
2379 (const_int 0)))]
2380 "")
ca7f5001 2381
9259f3b0 2382(define_insn "*mulsi3_no_mq_internal2"
9ebbca7d
GK
2383 [(set (match_operand:CC 3 "cc_reg_operand" "=x,?y")
2384 (compare:CC (mult:SI (match_operand:SI 1 "gpc_reg_operand" "%r,r")
2385 (match_operand:SI 2 "gpc_reg_operand" "r,r"))
ca7f5001 2386 (const_int 0)))
9ebbca7d 2387 (set (match_operand:SI 0 "gpc_reg_operand" "=r,r")
ca7f5001 2388 (mult:SI (match_dup 1) (match_dup 2)))]
25c341fa 2389 "! TARGET_POWER"
9ebbca7d
GK
2390 "@
2391 {muls.|mullw.} %0,%1,%2
2392 #"
9259f3b0 2393 [(set_attr "type" "imul_compare")
9ebbca7d
GK
2394 (set_attr "length" "4,8")])
2395
2396(define_split
2397 [(set (match_operand:CC 3 "cc_reg_not_cr0_operand" "")
2398 (compare:CC (mult:SI (match_operand:SI 1 "gpc_reg_operand" "")
2399 (match_operand:SI 2 "gpc_reg_operand" ""))
2400 (const_int 0)))
2401 (set (match_operand:SI 0 "gpc_reg_operand" "")
2402 (mult:SI (match_dup 1) (match_dup 2)))]
2403 "! TARGET_POWER && reload_completed"
2404 [(set (match_dup 0)
2405 (mult:SI (match_dup 1) (match_dup 2)))
2406 (set (match_dup 3)
2407 (compare:CC (match_dup 0)
2408 (const_int 0)))]
2409 "")
1fd4e8c1
RK
2410
2411;; Operand 1 is divided by operand 2; quotient goes to operand
2412;; 0 and remainder to operand 3.
2413;; ??? At some point, see what, if anything, we can do about if (x % y == 0).
2414
8ffd9c51
RK
2415(define_expand "divmodsi4"
2416 [(parallel [(set (match_operand:SI 0 "gpc_reg_operand" "")
2417 (div:SI (match_operand:SI 1 "gpc_reg_operand" "")
2418 (match_operand:SI 2 "gpc_reg_operand" "")))
bb157ff4 2419 (set (match_operand:SI 3 "register_operand" "")
8ffd9c51
RK
2420 (mod:SI (match_dup 1) (match_dup 2)))])]
2421 "TARGET_POWER || (! TARGET_POWER && ! TARGET_POWERPC)"
2422 "
2423{
2424 if (! TARGET_POWER && ! TARGET_POWERPC)
2425 {
39403d82
DE
2426 emit_move_insn (gen_rtx_REG (SImode, 3), operands[1]);
2427 emit_move_insn (gen_rtx_REG (SImode, 4), operands[2]);
fada905b 2428 emit_insn (gen_divss_call ());
39403d82
DE
2429 emit_move_insn (operands[0], gen_rtx_REG (SImode, 3));
2430 emit_move_insn (operands[3], gen_rtx_REG (SImode, 4));
8ffd9c51
RK
2431 DONE;
2432 }
2433}")
deb9225a 2434
bb157ff4 2435(define_insn "*divmodsi4_internal"
cd2b37d9
RK
2436 [(set (match_operand:SI 0 "gpc_reg_operand" "=r")
2437 (div:SI (match_operand:SI 1 "gpc_reg_operand" "r")
2438 (match_operand:SI 2 "gpc_reg_operand" "r")))
bb157ff4 2439 (set (match_operand:SI 3 "register_operand" "=q")
1fd4e8c1 2440 (mod:SI (match_dup 1) (match_dup 2)))]
ca7f5001 2441 "TARGET_POWER"
cfb557c4
RK
2442 "divs %0,%1,%2"
2443 [(set_attr "type" "idiv")])
1fd4e8c1 2444
4ae234b0
GK
2445(define_expand "udiv<mode>3"
2446 [(set (match_operand:GPR 0 "gpc_reg_operand" "")
2447 (udiv:GPR (match_operand:GPR 1 "gpc_reg_operand" "")
2448 (match_operand:GPR 2 "gpc_reg_operand" "")))]
8ffd9c51
RK
2449 "TARGET_POWERPC || (! TARGET_POWER && ! TARGET_POWERPC)"
2450 "
2451{
2452 if (! TARGET_POWER && ! TARGET_POWERPC)
2453 {
39403d82
DE
2454 emit_move_insn (gen_rtx_REG (SImode, 3), operands[1]);
2455 emit_move_insn (gen_rtx_REG (SImode, 4), operands[2]);
fada905b 2456 emit_insn (gen_quous_call ());
39403d82 2457 emit_move_insn (operands[0], gen_rtx_REG (SImode, 3));
8ffd9c51
RK
2458 DONE;
2459 }
f192bf8b
DE
2460 else if (TARGET_POWER)
2461 {
2462 emit_insn (gen_udivsi3_mq (operands[0], operands[1], operands[2]));
2463 DONE;
2464 }
8ffd9c51 2465}")
deb9225a 2466
f192bf8b
DE
2467(define_insn "udivsi3_mq"
2468 [(set (match_operand:SI 0 "gpc_reg_operand" "=r")
2469 (udiv:SI (match_operand:SI 1 "gpc_reg_operand" "r")
2470 (match_operand:SI 2 "gpc_reg_operand" "r")))
2471 (clobber (match_scratch:SI 3 "=q"))]
2472 "TARGET_POWERPC && TARGET_POWER"
2473 "divwu %0,%1,%2"
2474 [(set_attr "type" "idiv")])
2475
2476(define_insn "*udivsi3_no_mq"
4ae234b0
GK
2477 [(set (match_operand:GPR 0 "gpc_reg_operand" "=r")
2478 (udiv:GPR (match_operand:GPR 1 "gpc_reg_operand" "r")
2479 (match_operand:GPR 2 "gpc_reg_operand" "r")))]
f192bf8b 2480 "TARGET_POWERPC && ! TARGET_POWER"
4ae234b0 2481 "div<wd>u %0,%1,%2"
44cd321e
PS
2482 [(set (attr "type")
2483 (cond [(match_operand:SI 0 "" "")
2484 (const_string "idiv")]
2485 (const_string "ldiv")))])
2486
ca7f5001 2487
1fd4e8c1 2488;; For powers of two we can do srai/aze for divide and then adjust for
ca7f5001 2489;; modulus. If it isn't a power of two, FAIL on POWER so divmodsi4 will be
8ffd9c51
RK
2490;; used; for PowerPC, force operands into register and do a normal divide;
2491;; for AIX common-mode, use quoss call on register operands.
4ae234b0
GK
2492(define_expand "div<mode>3"
2493 [(set (match_operand:GPR 0 "gpc_reg_operand" "")
2494 (div:GPR (match_operand:GPR 1 "gpc_reg_operand" "")
2495 (match_operand:GPR 2 "reg_or_cint_operand" "")))]
1fd4e8c1
RK
2496 ""
2497 "
2498{
ca7f5001 2499 if (GET_CODE (operands[2]) == CONST_INT
2bfcf297 2500 && INTVAL (operands[2]) > 0
ca7f5001
RK
2501 && exact_log2 (INTVAL (operands[2])) >= 0)
2502 ;
b6c9286a 2503 else if (TARGET_POWERPC)
f192bf8b 2504 {
99e8e649 2505 operands[2] = force_reg (<MODE>mode, operands[2]);
f192bf8b
DE
2506 if (TARGET_POWER)
2507 {
2508 emit_insn (gen_divsi3_mq (operands[0], operands[1], operands[2]));
2509 DONE;
2510 }
2511 }
b6c9286a 2512 else if (TARGET_POWER)
1fd4e8c1 2513 FAIL;
405c5495 2514 else
8ffd9c51 2515 {
39403d82
DE
2516 emit_move_insn (gen_rtx_REG (SImode, 3), operands[1]);
2517 emit_move_insn (gen_rtx_REG (SImode, 4), operands[2]);
fada905b 2518 emit_insn (gen_quoss_call ());
39403d82 2519 emit_move_insn (operands[0], gen_rtx_REG (SImode, 3));
8ffd9c51
RK
2520 DONE;
2521 }
1fd4e8c1
RK
2522}")
2523
f192bf8b
DE
2524(define_insn "divsi3_mq"
2525 [(set (match_operand:SI 0 "gpc_reg_operand" "=r")
2526 (div:SI (match_operand:SI 1 "gpc_reg_operand" "r")
2527 (match_operand:SI 2 "gpc_reg_operand" "r")))
2528 (clobber (match_scratch:SI 3 "=q"))]
2529 "TARGET_POWERPC && TARGET_POWER"
2530 "divw %0,%1,%2"
2531 [(set_attr "type" "idiv")])
2532
4ae234b0
GK
2533(define_insn "*div<mode>3_no_mq"
2534 [(set (match_operand:GPR 0 "gpc_reg_operand" "=r")
2535 (div:GPR (match_operand:GPR 1 "gpc_reg_operand" "r")
2536 (match_operand:GPR 2 "gpc_reg_operand" "r")))]
f192bf8b 2537 "TARGET_POWERPC && ! TARGET_POWER"
4ae234b0 2538 "div<wd> %0,%1,%2"
44cd321e
PS
2539 [(set (attr "type")
2540 (cond [(match_operand:SI 0 "" "")
2541 (const_string "idiv")]
2542 (const_string "ldiv")))])
f192bf8b 2543
4ae234b0
GK
2544(define_expand "mod<mode>3"
2545 [(use (match_operand:GPR 0 "gpc_reg_operand" ""))
2546 (use (match_operand:GPR 1 "gpc_reg_operand" ""))
2547 (use (match_operand:GPR 2 "reg_or_cint_operand" ""))]
39b52ba2 2548 ""
1fd4e8c1
RK
2549 "
2550{
481c7efa 2551 int i;
39b52ba2
RK
2552 rtx temp1;
2553 rtx temp2;
2554
2bfcf297 2555 if (GET_CODE (operands[2]) != CONST_INT
a65c591c 2556 || INTVAL (operands[2]) <= 0
2bfcf297 2557 || (i = exact_log2 (INTVAL (operands[2]))) < 0)
39b52ba2
RK
2558 FAIL;
2559
4ae234b0
GK
2560 temp1 = gen_reg_rtx (<MODE>mode);
2561 temp2 = gen_reg_rtx (<MODE>mode);
1fd4e8c1 2562
4ae234b0
GK
2563 emit_insn (gen_div<mode>3 (temp1, operands[1], operands[2]));
2564 emit_insn (gen_ashl<mode>3 (temp2, temp1, GEN_INT (i)));
2565 emit_insn (gen_sub<mode>3 (operands[0], operands[1], temp2));
85644414 2566 DONE;
1fd4e8c1
RK
2567}")
2568
2569(define_insn ""
4ae234b0
GK
2570 [(set (match_operand:GPR 0 "gpc_reg_operand" "=r")
2571 (div:GPR (match_operand:GPR 1 "gpc_reg_operand" "r")
2572 (match_operand:GPR 2 "exact_log2_cint_operand" "N")))]
2bfcf297 2573 ""
4ae234b0 2574 "{srai|sra<wd>i} %0,%1,%p2\;{aze|addze} %0,%0"
943c15ed
DE
2575 [(set_attr "type" "two")
2576 (set_attr "length" "8")])
1fd4e8c1
RK
2577
2578(define_insn ""
9ebbca7d 2579 [(set (match_operand:CC 0 "cc_reg_operand" "=x,?y")
4ae234b0
GK
2580 (compare:CC (div:P (match_operand:P 1 "gpc_reg_operand" "r,r")
2581 (match_operand:P 2 "exact_log2_cint_operand" "N,N"))
b6b12107 2582 (const_int 0)))
4ae234b0 2583 (clobber (match_scratch:P 3 "=r,r"))]
2bfcf297 2584 ""
9ebbca7d 2585 "@
4ae234b0 2586 {srai|sra<wd>i} %3,%1,%p2\;{aze.|addze.} %3,%3
9ebbca7d 2587 #"
b19003d8 2588 [(set_attr "type" "compare")
9ebbca7d
GK
2589 (set_attr "length" "8,12")])
2590
2591(define_split
2592 [(set (match_operand:CC 0 "cc_reg_not_cr0_operand" "")
4ae234b0
GK
2593 (compare:CC (div:GPR (match_operand:GPR 1 "gpc_reg_operand" "")
2594 (match_operand:GPR 2 "exact_log2_cint_operand"
2595 ""))
9ebbca7d 2596 (const_int 0)))
4ae234b0 2597 (clobber (match_scratch:GPR 3 ""))]
2bfcf297 2598 "reload_completed"
9ebbca7d 2599 [(set (match_dup 3)
4ae234b0 2600 (div:<MODE> (match_dup 1) (match_dup 2)))
9ebbca7d
GK
2601 (set (match_dup 0)
2602 (compare:CC (match_dup 3)
2603 (const_int 0)))]
2604 "")
1fd4e8c1
RK
2605
2606(define_insn ""
9ebbca7d 2607 [(set (match_operand:CC 3 "cc_reg_operand" "=x,?y")
4ae234b0
GK
2608 (compare:CC (div:P (match_operand:P 1 "gpc_reg_operand" "r,r")
2609 (match_operand:P 2 "exact_log2_cint_operand" "N,N"))
b6b12107 2610 (const_int 0)))
4ae234b0
GK
2611 (set (match_operand:P 0 "gpc_reg_operand" "=r,r")
2612 (div:P (match_dup 1) (match_dup 2)))]
2bfcf297 2613 ""
9ebbca7d 2614 "@
4ae234b0 2615 {srai|sra<wd>i} %0,%1,%p2\;{aze.|addze.} %0,%0
9ebbca7d 2616 #"
b19003d8 2617 [(set_attr "type" "compare")
9ebbca7d
GK
2618 (set_attr "length" "8,12")])
2619
2620(define_split
2621 [(set (match_operand:CC 3 "cc_reg_not_cr0_operand" "")
4ae234b0
GK
2622 (compare:CC (div:GPR (match_operand:GPR 1 "gpc_reg_operand" "")
2623 (match_operand:GPR 2 "exact_log2_cint_operand"
2624 ""))
9ebbca7d 2625 (const_int 0)))
4ae234b0
GK
2626 (set (match_operand:GPR 0 "gpc_reg_operand" "")
2627 (div:GPR (match_dup 1) (match_dup 2)))]
2bfcf297 2628 "reload_completed"
9ebbca7d 2629 [(set (match_dup 0)
4ae234b0 2630 (div:<MODE> (match_dup 1) (match_dup 2)))
9ebbca7d
GK
2631 (set (match_dup 3)
2632 (compare:CC (match_dup 0)
2633 (const_int 0)))]
2634 "")
1fd4e8c1
RK
2635
2636(define_insn ""
cd2b37d9 2637 [(set (match_operand:SI 0 "gpc_reg_operand" "=r")
1fd4e8c1 2638 (udiv:SI
996a5f59 2639 (plus:DI (ashift:DI
cd2b37d9 2640 (zero_extend:DI (match_operand:SI 1 "gpc_reg_operand" "r"))
1fd4e8c1 2641 (const_int 32))
23a900dc 2642 (zero_extend:DI (match_operand:SI 4 "register_operand" "2")))
cd2b37d9 2643 (match_operand:SI 3 "gpc_reg_operand" "r")))
740ab4a2 2644 (set (match_operand:SI 2 "register_operand" "=*q")
1fd4e8c1 2645 (umod:SI
996a5f59 2646 (plus:DI (ashift:DI
1fd4e8c1 2647 (zero_extend:DI (match_dup 1)) (const_int 32))
740ab4a2 2648 (zero_extend:DI (match_dup 4)))
1fd4e8c1 2649 (match_dup 3)))]
ca7f5001 2650 "TARGET_POWER"
cfb557c4
RK
2651 "div %0,%1,%3"
2652 [(set_attr "type" "idiv")])
1fd4e8c1
RK
2653
2654;; To do unsigned divide we handle the cases of the divisor looking like a
2655;; negative number. If it is a constant that is less than 2**31, we don't
2656;; have to worry about the branches. So make a few subroutines here.
2657;;
2658;; First comes the normal case.
2659(define_expand "udivmodsi4_normal"
2660 [(set (match_dup 4) (const_int 0))
2661 (parallel [(set (match_operand:SI 0 "" "")
996a5f59 2662 (udiv:SI (plus:DI (ashift:DI (zero_extend:DI (match_dup 4))
1fd4e8c1
RK
2663 (const_int 32))
2664 (zero_extend:DI (match_operand:SI 1 "" "")))
2665 (match_operand:SI 2 "" "")))
2666 (set (match_operand:SI 3 "" "")
996a5f59 2667 (umod:SI (plus:DI (ashift:DI (zero_extend:DI (match_dup 4))
1fd4e8c1
RK
2668 (const_int 32))
2669 (zero_extend:DI (match_dup 1)))
2670 (match_dup 2)))])]
ca7f5001 2671 "TARGET_POWER"
1fd4e8c1
RK
2672 "
2673{ operands[4] = gen_reg_rtx (SImode); }")
2674
2675;; This handles the branches.
2676(define_expand "udivmodsi4_tests"
2677 [(set (match_operand:SI 0 "" "") (const_int 0))
2678 (set (match_operand:SI 3 "" "") (match_operand:SI 1 "" ""))
2679 (set (match_dup 5) (compare:CCUNS (match_dup 1) (match_operand:SI 2 "" "")))
2680 (set (pc) (if_then_else (ltu (match_dup 5) (const_int 0))
2681 (label_ref (match_operand:SI 4 "" "")) (pc)))
2682 (set (match_dup 0) (const_int 1))
2683 (set (match_dup 3) (minus:SI (match_dup 1) (match_dup 2)))
2684 (set (match_dup 6) (compare:CC (match_dup 2) (const_int 0)))
2685 (set (pc) (if_then_else (lt (match_dup 6) (const_int 0))
2686 (label_ref (match_dup 4)) (pc)))]
ca7f5001 2687 "TARGET_POWER"
1fd4e8c1
RK
2688 "
2689{ operands[5] = gen_reg_rtx (CCUNSmode);
2690 operands[6] = gen_reg_rtx (CCmode);
2691}")
2692
2693(define_expand "udivmodsi4"
cd2b37d9
RK
2694 [(parallel [(set (match_operand:SI 0 "gpc_reg_operand" "")
2695 (udiv:SI (match_operand:SI 1 "gpc_reg_operand" "")
1fd4e8c1 2696 (match_operand:SI 2 "reg_or_cint_operand" "")))
cd2b37d9 2697 (set (match_operand:SI 3 "gpc_reg_operand" "")
1fd4e8c1 2698 (umod:SI (match_dup 1) (match_dup 2)))])]
8ffd9c51 2699 ""
1fd4e8c1
RK
2700 "
2701{
2702 rtx label = 0;
2703
8ffd9c51 2704 if (! TARGET_POWER)
c4d38ccb
MM
2705 {
2706 if (! TARGET_POWERPC)
2707 {
39403d82
DE
2708 emit_move_insn (gen_rtx_REG (SImode, 3), operands[1]);
2709 emit_move_insn (gen_rtx_REG (SImode, 4), operands[2]);
c4d38ccb 2710 emit_insn (gen_divus_call ());
39403d82
DE
2711 emit_move_insn (operands[0], gen_rtx_REG (SImode, 3));
2712 emit_move_insn (operands[3], gen_rtx_REG (SImode, 4));
c4d38ccb
MM
2713 DONE;
2714 }
2715 else
2716 FAIL;
2717 }
0081a354 2718
1fd4e8c1
RK
2719 if (GET_CODE (operands[2]) != CONST_INT || INTVAL (operands[2]) < 0)
2720 {
2721 operands[2] = force_reg (SImode, operands[2]);
2722 label = gen_label_rtx ();
2723 emit (gen_udivmodsi4_tests (operands[0], operands[1], operands[2],
2724 operands[3], label));
2725 }
2726 else
2727 operands[2] = force_reg (SImode, operands[2]);
2728
2729 emit (gen_udivmodsi4_normal (operands[0], operands[1], operands[2],
2730 operands[3]));
2731 if (label)
2732 emit_label (label);
2733
2734 DONE;
2735}")
0081a354 2736
fada905b
MM
2737;; AIX architecture-independent common-mode multiply (DImode),
2738;; divide/modulus, and quotient subroutine calls. Input operands in R3 and
2739;; R4; results in R3 and sometimes R4; link register always clobbered by bla
2740;; instruction; R0 sometimes clobbered; also, MQ sometimes clobbered but
2741;; assumed unused if generating common-mode, so ignore.
2742(define_insn "mulh_call"
2743 [(set (reg:SI 3)
2744 (truncate:SI
2745 (lshiftrt:DI (mult:DI (sign_extend:DI (reg:SI 3))
2746 (sign_extend:DI (reg:SI 4)))
2747 (const_int 32))))
1de43f85 2748 (clobber (reg:SI LR_REGNO))]
fada905b 2749 "! TARGET_POWER && ! TARGET_POWERPC"
b7ff3d82
DE
2750 "bla __mulh"
2751 [(set_attr "type" "imul")])
fada905b
MM
2752
2753(define_insn "mull_call"
2754 [(set (reg:DI 3)
2755 (mult:DI (sign_extend:DI (reg:SI 3))
2756 (sign_extend:DI (reg:SI 4))))
1de43f85 2757 (clobber (reg:SI LR_REGNO))
fada905b
MM
2758 (clobber (reg:SI 0))]
2759 "! TARGET_POWER && ! TARGET_POWERPC"
b7ff3d82
DE
2760 "bla __mull"
2761 [(set_attr "type" "imul")])
fada905b
MM
2762
2763(define_insn "divss_call"
2764 [(set (reg:SI 3)
2765 (div:SI (reg:SI 3) (reg:SI 4)))
2766 (set (reg:SI 4)
2767 (mod:SI (reg:SI 3) (reg:SI 4)))
1de43f85 2768 (clobber (reg:SI LR_REGNO))
fada905b
MM
2769 (clobber (reg:SI 0))]
2770 "! TARGET_POWER && ! TARGET_POWERPC"
b7ff3d82
DE
2771 "bla __divss"
2772 [(set_attr "type" "idiv")])
fada905b
MM
2773
2774(define_insn "divus_call"
8ffd9c51
RK
2775 [(set (reg:SI 3)
2776 (udiv:SI (reg:SI 3) (reg:SI 4)))
2777 (set (reg:SI 4)
2778 (umod:SI (reg:SI 3) (reg:SI 4)))
1de43f85 2779 (clobber (reg:SI LR_REGNO))
fada905b 2780 (clobber (reg:SI 0))
e65a3857 2781 (clobber (match_scratch:CC 0 "=x"))
1de43f85 2782 (clobber (reg:CC CR1_REGNO))]
fada905b 2783 "! TARGET_POWER && ! TARGET_POWERPC"
b7ff3d82
DE
2784 "bla __divus"
2785 [(set_attr "type" "idiv")])
fada905b
MM
2786
2787(define_insn "quoss_call"
2788 [(set (reg:SI 3)
2789 (div:SI (reg:SI 3) (reg:SI 4)))
1de43f85 2790 (clobber (reg:SI LR_REGNO))]
8ffd9c51 2791 "! TARGET_POWER && ! TARGET_POWERPC"
b7ff3d82
DE
2792 "bla __quoss"
2793 [(set_attr "type" "idiv")])
0081a354 2794
fada905b
MM
2795(define_insn "quous_call"
2796 [(set (reg:SI 3)
2797 (udiv:SI (reg:SI 3) (reg:SI 4)))
1de43f85 2798 (clobber (reg:SI LR_REGNO))
fada905b 2799 (clobber (reg:SI 0))
e65a3857 2800 (clobber (match_scratch:CC 0 "=x"))
1de43f85 2801 (clobber (reg:CC CR1_REGNO))]
fada905b 2802 "! TARGET_POWER && ! TARGET_POWERPC"
b7ff3d82
DE
2803 "bla __quous"
2804 [(set_attr "type" "idiv")])
8ffd9c51 2805\f
bb21487f 2806;; Logical instructions
dfbdccdb
GK
2807;; The logical instructions are mostly combined by using match_operator,
2808;; but the plain AND insns are somewhat different because there is no
2809;; plain 'andi' (only 'andi.'), no plain 'andis', and there are all
2810;; those rotate-and-mask operations. Thus, the AND insns come first.
2811
29ae5b89
JL
2812(define_insn "andsi3"
2813 [(set (match_operand:SI 0 "gpc_reg_operand" "=r,r,r,r")
2814 (and:SI (match_operand:SI 1 "gpc_reg_operand" "%r,r,r,r")
5f59ecb7 2815 (match_operand:SI 2 "and_operand" "?r,T,K,L")))
29ae5b89 2816 (clobber (match_scratch:CC 3 "=X,X,x,x"))]
1fd4e8c1
RK
2817 ""
2818 "@
2819 and %0,%1,%2
ca7f5001
RK
2820 {rlinm|rlwinm} %0,%1,0,%m2,%M2
2821 {andil.|andi.} %0,%1,%b2
520308bc
DE
2822 {andiu.|andis.} %0,%1,%u2"
2823 [(set_attr "type" "*,*,compare,compare")])
52d3af72
DE
2824
2825;; Note to set cr's other than cr0 we do the and immediate and then
0ba1b2ff 2826;; the test again -- this avoids a mfcr which on the higher end
52d3af72 2827;; machines causes an execution serialization
1fd4e8c1 2828
7cd5235b 2829(define_insn "*andsi3_internal2"
52d3af72
DE
2830 [(set (match_operand:CC 0 "cc_reg_operand" "=x,x,x,x,?y,??y,??y,?y")
2831 (compare:CC (and:SI (match_operand:SI 1 "gpc_reg_operand" "%r,r,r,r,r,r,r,r")
5f59ecb7 2832 (match_operand:SI 2 "and_operand" "r,K,L,T,r,K,L,T"))
1fd4e8c1 2833 (const_int 0)))
52d3af72
DE
2834 (clobber (match_scratch:SI 3 "=r,r,r,r,r,r,r,r"))
2835 (clobber (match_scratch:CC 4 "=X,X,X,X,X,x,x,X"))]
4b8a63d6 2836 "TARGET_32BIT"
1fd4e8c1
RK
2837 "@
2838 and. %3,%1,%2
ca7f5001
RK
2839 {andil.|andi.} %3,%1,%b2
2840 {andiu.|andis.} %3,%1,%u2
52d3af72
DE
2841 {rlinm.|rlwinm.} %3,%1,0,%m2,%M2
2842 #
2843 #
2844 #
2845 #"
2846 [(set_attr "type" "compare,compare,compare,delayed_compare,compare,compare,compare,compare")
2847 (set_attr "length" "4,4,4,4,8,8,8,8")])
1fd4e8c1 2848
0ba1b2ff
AM
2849(define_insn "*andsi3_internal3"
2850 [(set (match_operand:CC 0 "cc_reg_operand" "=x,x,x,x,?y,??y,??y,?y")
2851 (compare:CC (and:SI (match_operand:SI 1 "gpc_reg_operand" "%r,r,r,r,r,r,r,r")
2852 (match_operand:SI 2 "and_operand" "r,K,L,T,r,K,L,T"))
2853 (const_int 0)))
2854 (clobber (match_scratch:SI 3 "=r,r,r,r,r,r,r,r"))
2855 (clobber (match_scratch:CC 4 "=X,X,X,X,X,x,x,X"))]
683bdff7 2856 "TARGET_64BIT"
0ba1b2ff
AM
2857 "@
2858 #
2859 {andil.|andi.} %3,%1,%b2
2860 {andiu.|andis.} %3,%1,%u2
2861 {rlinm.|rlwinm.} %3,%1,0,%m2,%M2
2862 #
2863 #
2864 #
2865 #"
2866 [(set_attr "type" "compare,compare,compare,delayed_compare,compare,compare,compare,compare")
2867 (set_attr "length" "8,4,4,4,8,8,8,8")])
2868
52d3af72
DE
2869(define_split
2870 [(set (match_operand:CC 0 "cc_reg_not_cr0_operand" "")
4ae234b0
GK
2871 (compare:CC (and:GPR (match_operand:GPR 1 "gpc_reg_operand" "")
2872 (match_operand:GPR 2 "and_operand" ""))
1fd4e8c1 2873 (const_int 0)))
4ae234b0 2874 (clobber (match_scratch:GPR 3 ""))
52d3af72 2875 (clobber (match_scratch:CC 4 ""))]
0ba1b2ff 2876 "reload_completed"
52d3af72 2877 [(parallel [(set (match_dup 3)
4ae234b0
GK
2878 (and:<MODE> (match_dup 1)
2879 (match_dup 2)))
52d3af72
DE
2880 (clobber (match_dup 4))])
2881 (set (match_dup 0)
2882 (compare:CC (match_dup 3)
2883 (const_int 0)))]
2884 "")
2885
0ba1b2ff
AM
2886;; We don't have a 32 bit "and. rt,ra,rb" for ppc64. cr is set from the
2887;; whole 64 bit reg, and we don't know what is in the high 32 bits.
2888
2889(define_split
2890 [(set (match_operand:CC 0 "cc_reg_operand" "")
2891 (compare:CC (and:SI (match_operand:SI 1 "gpc_reg_operand" "")
2892 (match_operand:SI 2 "gpc_reg_operand" ""))
2893 (const_int 0)))
2894 (clobber (match_scratch:SI 3 ""))
2895 (clobber (match_scratch:CC 4 ""))]
2896 "TARGET_POWERPC64 && reload_completed"
2897 [(parallel [(set (match_dup 3)
2898 (and:SI (match_dup 1)
2899 (match_dup 2)))
2900 (clobber (match_dup 4))])
2901 (set (match_dup 0)
2902 (compare:CC (match_dup 3)
2903 (const_int 0)))]
2904 "")
2905
2906(define_insn "*andsi3_internal4"
52d3af72
DE
2907 [(set (match_operand:CC 3 "cc_reg_operand" "=x,x,x,x,?y,??y,??y,?y")
2908 (compare:CC (and:SI (match_operand:SI 1 "gpc_reg_operand" "%r,r,r,r,r,r,r,r")
5f59ecb7 2909 (match_operand:SI 2 "and_operand" "r,K,L,T,r,K,L,T"))
52d3af72
DE
2910 (const_int 0)))
2911 (set (match_operand:SI 0 "gpc_reg_operand" "=r,r,r,r,r,r,r,r")
2912 (and:SI (match_dup 1)
2913 (match_dup 2)))
2914 (clobber (match_scratch:CC 4 "=X,X,X,X,X,x,x,X"))]
4b8a63d6 2915 "TARGET_32BIT"
1fd4e8c1
RK
2916 "@
2917 and. %0,%1,%2
ca7f5001
RK
2918 {andil.|andi.} %0,%1,%b2
2919 {andiu.|andis.} %0,%1,%u2
52d3af72
DE
2920 {rlinm.|rlwinm.} %0,%1,0,%m2,%M2
2921 #
2922 #
2923 #
2924 #"
2925 [(set_attr "type" "compare,compare,compare,delayed_compare,compare,compare,compare,compare")
2926 (set_attr "length" "4,4,4,4,8,8,8,8")])
2927
0ba1b2ff
AM
2928(define_insn "*andsi3_internal5"
2929 [(set (match_operand:CC 3 "cc_reg_operand" "=x,x,x,x,?y,??y,??y,?y")
2930 (compare:CC (and:SI (match_operand:SI 1 "gpc_reg_operand" "%r,r,r,r,r,r,r,r")
2931 (match_operand:SI 2 "and_operand" "r,K,L,T,r,K,L,T"))
2932 (const_int 0)))
2933 (set (match_operand:SI 0 "gpc_reg_operand" "=r,r,r,r,r,r,r,r")
2934 (and:SI (match_dup 1)
2935 (match_dup 2)))
2936 (clobber (match_scratch:CC 4 "=X,X,X,X,X,x,x,X"))]
683bdff7 2937 "TARGET_64BIT"
0ba1b2ff
AM
2938 "@
2939 #
2940 {andil.|andi.} %0,%1,%b2
2941 {andiu.|andis.} %0,%1,%u2
2942 {rlinm.|rlwinm.} %0,%1,0,%m2,%M2
2943 #
2944 #
2945 #
2946 #"
2947 [(set_attr "type" "compare,compare,compare,delayed_compare,compare,compare,compare,compare")
2948 (set_attr "length" "8,4,4,4,8,8,8,8")])
2949
52d3af72
DE
2950(define_split
2951 [(set (match_operand:CC 3 "cc_reg_not_cr0_operand" "")
2952 (compare:CC (and:SI (match_operand:SI 1 "gpc_reg_operand" "")
2953 (match_operand:SI 2 "and_operand" ""))
2954 (const_int 0)))
2955 (set (match_operand:SI 0 "gpc_reg_operand" "")
2956 (and:SI (match_dup 1)
2957 (match_dup 2)))
2958 (clobber (match_scratch:CC 4 ""))]
0ba1b2ff 2959 "reload_completed"
52d3af72
DE
2960 [(parallel [(set (match_dup 0)
2961 (and:SI (match_dup 1)
2962 (match_dup 2)))
2963 (clobber (match_dup 4))])
2964 (set (match_dup 3)
2965 (compare:CC (match_dup 0)
2966 (const_int 0)))]
2967 "")
1fd4e8c1 2968
0ba1b2ff
AM
2969(define_split
2970 [(set (match_operand:CC 3 "cc_reg_operand" "")
2971 (compare:CC (and:SI (match_operand:SI 1 "gpc_reg_operand" "")
2972 (match_operand:SI 2 "gpc_reg_operand" ""))
2973 (const_int 0)))
2974 (set (match_operand:SI 0 "gpc_reg_operand" "")
2975 (and:SI (match_dup 1)
2976 (match_dup 2)))
2977 (clobber (match_scratch:CC 4 ""))]
2978 "TARGET_POWERPC64 && reload_completed"
2979 [(parallel [(set (match_dup 0)
2980 (and:SI (match_dup 1)
2981 (match_dup 2)))
2982 (clobber (match_dup 4))])
2983 (set (match_dup 3)
2984 (compare:CC (match_dup 0)
2985 (const_int 0)))]
2986 "")
2987
2988;; Handle the PowerPC64 rlwinm corner case
2989
2990(define_insn_and_split "*andsi3_internal6"
2991 [(set (match_operand:SI 0 "gpc_reg_operand" "=r")
2992 (and:SI (match_operand:SI 1 "gpc_reg_operand" "r")
2993 (match_operand:SI 2 "mask_operand_wrap" "i")))]
2994 "TARGET_POWERPC64"
2995 "#"
2996 "TARGET_POWERPC64"
2997 [(set (match_dup 0)
2998 (and:SI (rotate:SI (match_dup 1) (match_dup 3))
2999 (match_dup 4)))
3000 (set (match_dup 0)
3001 (rotate:SI (match_dup 0) (match_dup 5)))]
3002 "
3003{
3004 int mb = extract_MB (operands[2]);
3005 int me = extract_ME (operands[2]);
3006 operands[3] = GEN_INT (me + 1);
3007 operands[5] = GEN_INT (32 - (me + 1));
3008 operands[4] = GEN_INT (~((HOST_WIDE_INT) -1 << (33 + me - mb)));
3009}"
3010 [(set_attr "length" "8")])
3011
7cd5235b 3012(define_expand "iorsi3"
cd2b37d9 3013 [(set (match_operand:SI 0 "gpc_reg_operand" "")
7cd5235b 3014 (ior:SI (match_operand:SI 1 "gpc_reg_operand" "")
1d328b19 3015 (match_operand:SI 2 "reg_or_logical_cint_operand" "")))]
7cd5235b 3016 ""
f357808b
RK
3017 "
3018{
7cd5235b 3019 if (GET_CODE (operands[2]) == CONST_INT
677a9668 3020 && ! logical_operand (operands[2], SImode))
7cd5235b
MM
3021 {
3022 HOST_WIDE_INT value = INTVAL (operands[2]);
b3a13419
ILT
3023 rtx tmp = ((!can_create_pseudo_p ()
3024 || rtx_equal_p (operands[0], operands[1]))
7cd5235b
MM
3025 ? operands[0] : gen_reg_rtx (SImode));
3026
a260abc9
DE
3027 emit_insn (gen_iorsi3 (tmp, operands[1],
3028 GEN_INT (value & (~ (HOST_WIDE_INT) 0xffff))));
3029 emit_insn (gen_iorsi3 (operands[0], tmp, GEN_INT (value & 0xffff)));
7cd5235b
MM
3030 DONE;
3031 }
f357808b
RK
3032}")
3033
7cd5235b 3034(define_expand "xorsi3"
cd2b37d9 3035 [(set (match_operand:SI 0 "gpc_reg_operand" "")
7cd5235b 3036 (xor:SI (match_operand:SI 1 "gpc_reg_operand" "")
1d328b19 3037 (match_operand:SI 2 "reg_or_logical_cint_operand" "")))]
1fd4e8c1 3038 ""
7cd5235b 3039 "
1fd4e8c1 3040{
7cd5235b 3041 if (GET_CODE (operands[2]) == CONST_INT
677a9668 3042 && ! logical_operand (operands[2], SImode))
7cd5235b
MM
3043 {
3044 HOST_WIDE_INT value = INTVAL (operands[2]);
b3a13419
ILT
3045 rtx tmp = ((!can_create_pseudo_p ()
3046 || rtx_equal_p (operands[0], operands[1]))
7cd5235b
MM
3047 ? operands[0] : gen_reg_rtx (SImode));
3048
a260abc9
DE
3049 emit_insn (gen_xorsi3 (tmp, operands[1],
3050 GEN_INT (value & (~ (HOST_WIDE_INT) 0xffff))));
3051 emit_insn (gen_xorsi3 (operands[0], tmp, GEN_INT (value & 0xffff)));
7cd5235b
MM
3052 DONE;
3053 }
1fd4e8c1
RK
3054}")
3055
dfbdccdb 3056(define_insn "*boolsi3_internal1"
7cd5235b 3057 [(set (match_operand:SI 0 "gpc_reg_operand" "=r,r,r")
1d328b19 3058 (match_operator:SI 3 "boolean_or_operator"
dfbdccdb
GK
3059 [(match_operand:SI 1 "gpc_reg_operand" "%r,r,r")
3060 (match_operand:SI 2 "logical_operand" "r,K,L")]))]
1fd4e8c1
RK
3061 ""
3062 "@
dfbdccdb
GK
3063 %q3 %0,%1,%2
3064 {%q3il|%q3i} %0,%1,%b2
3065 {%q3iu|%q3is} %0,%1,%u2")
1fd4e8c1 3066
dfbdccdb 3067(define_insn "*boolsi3_internal2"
52d3af72 3068 [(set (match_operand:CC 0 "cc_reg_operand" "=x,?y")
1d328b19 3069 (compare:CC (match_operator:SI 4 "boolean_or_operator"
dfbdccdb
GK
3070 [(match_operand:SI 1 "gpc_reg_operand" "%r,r")
3071 (match_operand:SI 2 "gpc_reg_operand" "r,r")])
3072 (const_int 0)))
52d3af72 3073 (clobber (match_scratch:SI 3 "=r,r"))]
4b8a63d6 3074 "TARGET_32BIT"
52d3af72 3075 "@
dfbdccdb 3076 %q4. %3,%1,%2
52d3af72
DE
3077 #"
3078 [(set_attr "type" "compare")
3079 (set_attr "length" "4,8")])
3080
3081(define_split
3082 [(set (match_operand:CC 0 "cc_reg_not_cr0_operand" "")
dfbdccdb 3083 (compare:CC (match_operator:SI 4 "boolean_operator"
75540af0
JH
3084 [(match_operand:SI 1 "gpc_reg_operand" "")
3085 (match_operand:SI 2 "gpc_reg_operand" "")])
dfbdccdb 3086 (const_int 0)))
52d3af72 3087 (clobber (match_scratch:SI 3 ""))]
4b8a63d6 3088 "TARGET_32BIT && reload_completed"
dfbdccdb 3089 [(set (match_dup 3) (match_dup 4))
52d3af72
DE
3090 (set (match_dup 0)
3091 (compare:CC (match_dup 3)
3092 (const_int 0)))]
3093 "")
815cdc52 3094
dfbdccdb 3095(define_insn "*boolsi3_internal3"
52d3af72 3096 [(set (match_operand:CC 3 "cc_reg_operand" "=x,?y")
dfbdccdb
GK
3097 (compare:CC (match_operator:SI 4 "boolean_operator"
3098 [(match_operand:SI 1 "gpc_reg_operand" "%r,r")
3099 (match_operand:SI 2 "gpc_reg_operand" "r,r")])
3100 (const_int 0)))
52d3af72 3101 (set (match_operand:SI 0 "gpc_reg_operand" "=r,r")
dfbdccdb 3102 (match_dup 4))]
4b8a63d6 3103 "TARGET_32BIT"
52d3af72 3104 "@
dfbdccdb 3105 %q4. %0,%1,%2
52d3af72
DE
3106 #"
3107 [(set_attr "type" "compare")
3108 (set_attr "length" "4,8")])
3109
3110(define_split
e72247f4 3111 [(set (match_operand:CC 3 "cc_reg_not_cr0_operand" "")
dfbdccdb 3112 (compare:CC (match_operator:SI 4 "boolean_operator"
75540af0
JH
3113 [(match_operand:SI 1 "gpc_reg_operand" "")
3114 (match_operand:SI 2 "gpc_reg_operand" "")])
dfbdccdb 3115 (const_int 0)))
75540af0 3116 (set (match_operand:SI 0 "gpc_reg_operand" "")
dfbdccdb 3117 (match_dup 4))]
4b8a63d6 3118 "TARGET_32BIT && reload_completed"
dfbdccdb 3119 [(set (match_dup 0) (match_dup 4))
52d3af72
DE
3120 (set (match_dup 3)
3121 (compare:CC (match_dup 0)
3122 (const_int 0)))]
3123 "")
1fd4e8c1 3124
6ae08853 3125;; Split a logical operation that we can't do in one insn into two insns,
dfbdccdb 3126;; each of which does one 16-bit part. This is used by combine.
a260abc9
DE
3127
3128(define_split
3129 [(set (match_operand:SI 0 "gpc_reg_operand" "")
1d328b19 3130 (match_operator:SI 3 "boolean_or_operator"
dfbdccdb
GK
3131 [(match_operand:SI 1 "gpc_reg_operand" "")
3132 (match_operand:SI 2 "non_logical_cint_operand" "")]))]
a260abc9 3133 ""
dfbdccdb
GK
3134 [(set (match_dup 0) (match_dup 4))
3135 (set (match_dup 0) (match_dup 5))]
a260abc9
DE
3136"
3137{
dfbdccdb
GK
3138 rtx i;
3139 i = GEN_INT (INTVAL (operands[2]) & (~ (HOST_WIDE_INT) 0xffff));
1c563bed 3140 operands[4] = gen_rtx_fmt_ee (GET_CODE (operands[3]), SImode,
0f4c242b 3141 operands[1], i);
dfbdccdb 3142 i = GEN_INT (INTVAL (operands[2]) & 0xffff);
1c563bed 3143 operands[5] = gen_rtx_fmt_ee (GET_CODE (operands[3]), SImode,
0f4c242b 3144 operands[0], i);
a260abc9
DE
3145}")
3146
dfbdccdb 3147(define_insn "*boolcsi3_internal1"
cd2b37d9 3148 [(set (match_operand:SI 0 "gpc_reg_operand" "=r")
dfbdccdb
GK
3149 (match_operator:SI 3 "boolean_operator"
3150 [(not:SI (match_operand:SI 1 "gpc_reg_operand" "r"))
40501e5f 3151 (match_operand:SI 2 "gpc_reg_operand" "r")]))]
1fd4e8c1 3152 ""
dfbdccdb 3153 "%q3 %0,%2,%1")
1fd4e8c1 3154
dfbdccdb 3155(define_insn "*boolcsi3_internal2"
52d3af72 3156 [(set (match_operand:CC 0 "cc_reg_operand" "=x,?y")
dfbdccdb
GK
3157 (compare:CC (match_operator:SI 4 "boolean_operator"
3158 [(not:SI (match_operand:SI 1 "gpc_reg_operand" "r,r"))
3159 (match_operand:SI 2 "gpc_reg_operand" "r,r")])
3160 (const_int 0)))
52d3af72 3161 (clobber (match_scratch:SI 3 "=r,r"))]
4b8a63d6 3162 "TARGET_32BIT"
52d3af72 3163 "@
dfbdccdb 3164 %q4. %3,%2,%1
52d3af72
DE
3165 #"
3166 [(set_attr "type" "compare")
3167 (set_attr "length" "4,8")])
3168
3169(define_split
3170 [(set (match_operand:CC 0 "cc_reg_not_cr0_operand" "")
dfbdccdb 3171 (compare:CC (match_operator:SI 4 "boolean_operator"
75540af0
JH
3172 [(not:SI (match_operand:SI 1 "gpc_reg_operand" ""))
3173 (match_operand:SI 2 "gpc_reg_operand" "")])
dfbdccdb 3174 (const_int 0)))
52d3af72 3175 (clobber (match_scratch:SI 3 ""))]
4b8a63d6 3176 "TARGET_32BIT && reload_completed"
dfbdccdb 3177 [(set (match_dup 3) (match_dup 4))
52d3af72
DE
3178 (set (match_dup 0)
3179 (compare:CC (match_dup 3)
3180 (const_int 0)))]
3181 "")
1fd4e8c1 3182
dfbdccdb 3183(define_insn "*boolcsi3_internal3"
52d3af72 3184 [(set (match_operand:CC 3 "cc_reg_operand" "=x,?y")
dfbdccdb
GK
3185 (compare:CC (match_operator:SI 4 "boolean_operator"
3186 [(not:SI (match_operand:SI 1 "gpc_reg_operand" "%r,r"))
3187 (match_operand:SI 2 "gpc_reg_operand" "r,r")])
3188 (const_int 0)))
52d3af72 3189 (set (match_operand:SI 0 "gpc_reg_operand" "=r,r")
dfbdccdb 3190 (match_dup 4))]
4b8a63d6 3191 "TARGET_32BIT"
52d3af72 3192 "@
dfbdccdb 3193 %q4. %0,%2,%1
52d3af72
DE
3194 #"
3195 [(set_attr "type" "compare")
3196 (set_attr "length" "4,8")])
3197
3198(define_split
e72247f4 3199 [(set (match_operand:CC 3 "cc_reg_not_cr0_operand" "")
dfbdccdb 3200 (compare:CC (match_operator:SI 4 "boolean_operator"
75540af0
JH
3201 [(not:SI (match_operand:SI 1 "gpc_reg_operand" ""))
3202 (match_operand:SI 2 "gpc_reg_operand" "")])
dfbdccdb 3203 (const_int 0)))
75540af0 3204 (set (match_operand:SI 0 "gpc_reg_operand" "")
dfbdccdb 3205 (match_dup 4))]
4b8a63d6 3206 "TARGET_32BIT && reload_completed"
dfbdccdb 3207 [(set (match_dup 0) (match_dup 4))
52d3af72
DE
3208 (set (match_dup 3)
3209 (compare:CC (match_dup 0)
3210 (const_int 0)))]
3211 "")
3212
dfbdccdb 3213(define_insn "*boolccsi3_internal1"
cd2b37d9 3214 [(set (match_operand:SI 0 "gpc_reg_operand" "=r")
dfbdccdb
GK
3215 (match_operator:SI 3 "boolean_operator"
3216 [(not:SI (match_operand:SI 1 "gpc_reg_operand" "r"))
40501e5f 3217 (not:SI (match_operand:SI 2 "gpc_reg_operand" "r"))]))]
1fd4e8c1 3218 ""
dfbdccdb 3219 "%q3 %0,%1,%2")
1fd4e8c1 3220
dfbdccdb 3221(define_insn "*boolccsi3_internal2"
52d3af72 3222 [(set (match_operand:CC 0 "cc_reg_operand" "=x,?y")
dfbdccdb
GK
3223 (compare:CC (match_operator:SI 4 "boolean_operator"
3224 [(not:SI (match_operand:SI 1 "gpc_reg_operand" "r,r"))
3225 (not:SI (match_operand:SI 2 "gpc_reg_operand" "r,r"))])
3226 (const_int 0)))
52d3af72 3227 (clobber (match_scratch:SI 3 "=r,r"))]
4b8a63d6 3228 "TARGET_32BIT"
52d3af72 3229 "@
dfbdccdb 3230 %q4. %3,%1,%2
52d3af72
DE
3231 #"
3232 [(set_attr "type" "compare")
3233 (set_attr "length" "4,8")])
3234
3235(define_split
3236 [(set (match_operand:CC 0 "cc_reg_not_cr0_operand" "")
dfbdccdb 3237 (compare:CC (match_operator:SI 4 "boolean_operator"
75540af0
JH
3238 [(not:SI (match_operand:SI 1 "gpc_reg_operand" ""))
3239 (not:SI (match_operand:SI 2 "gpc_reg_operand" ""))])
dfbdccdb 3240 (const_int 0)))
52d3af72 3241 (clobber (match_scratch:SI 3 ""))]
4b8a63d6 3242 "TARGET_32BIT && reload_completed"
dfbdccdb 3243 [(set (match_dup 3) (match_dup 4))
52d3af72
DE
3244 (set (match_dup 0)
3245 (compare:CC (match_dup 3)
3246 (const_int 0)))]
3247 "")
1fd4e8c1 3248
dfbdccdb 3249(define_insn "*boolccsi3_internal3"
52d3af72 3250 [(set (match_operand:CC 3 "cc_reg_operand" "=x,?y")
dfbdccdb
GK
3251 (compare:CC (match_operator:SI 4 "boolean_operator"
3252 [(not:SI (match_operand:SI 1 "gpc_reg_operand" "%r,r"))
3253 (not:SI (match_operand:SI 2 "gpc_reg_operand" "r,r"))])
3254 (const_int 0)))
52d3af72 3255 (set (match_operand:SI 0 "gpc_reg_operand" "=r,r")
dfbdccdb 3256 (match_dup 4))]
4b8a63d6 3257 "TARGET_32BIT"
52d3af72 3258 "@
dfbdccdb 3259 %q4. %0,%1,%2
52d3af72
DE
3260 #"
3261 [(set_attr "type" "compare")
3262 (set_attr "length" "4,8")])
3263
3264(define_split
e72247f4 3265 [(set (match_operand:CC 3 "cc_reg_not_cr0_operand" "")
dfbdccdb 3266 (compare:CC (match_operator:SI 4 "boolean_operator"
75540af0
JH
3267 [(not:SI (match_operand:SI 1 "gpc_reg_operand" ""))
3268 (not:SI (match_operand:SI 2 "gpc_reg_operand" ""))])
dfbdccdb 3269 (const_int 0)))
75540af0 3270 (set (match_operand:SI 0 "gpc_reg_operand" "")
dfbdccdb 3271 (match_dup 4))]
4b8a63d6 3272 "TARGET_32BIT && reload_completed"
dfbdccdb 3273 [(set (match_dup 0) (match_dup 4))
52d3af72
DE
3274 (set (match_dup 3)
3275 (compare:CC (match_dup 0)
3276 (const_int 0)))]
3277 "")
1fd4e8c1
RK
3278
3279;; maskir insn. We need four forms because things might be in arbitrary
3280;; orders. Don't define forms that only set CR fields because these
3281;; would modify an input register.
3282
7cd5235b 3283(define_insn "*maskir_internal1"
cd2b37d9 3284 [(set (match_operand:SI 0 "gpc_reg_operand" "=r")
01def764
RK
3285 (ior:SI (and:SI (not:SI (match_operand:SI 2 "gpc_reg_operand" "r"))
3286 (match_operand:SI 1 "gpc_reg_operand" "0"))
3287 (and:SI (match_dup 2)
cd2b37d9 3288 (match_operand:SI 3 "gpc_reg_operand" "r"))))]
ca7f5001 3289 "TARGET_POWER"
01def764 3290 "maskir %0,%3,%2")
1fd4e8c1 3291
7cd5235b 3292(define_insn "*maskir_internal2"
242e8072 3293 [(set (match_operand:SI 0 "gpc_reg_operand" "=r")
01def764
RK
3294 (ior:SI (and:SI (not:SI (match_operand:SI 2 "gpc_reg_operand" "r"))
3295 (match_operand:SI 1 "gpc_reg_operand" "0"))
cd2b37d9 3296 (and:SI (match_operand:SI 3 "gpc_reg_operand" "r")
01def764 3297 (match_dup 2))))]
ca7f5001 3298 "TARGET_POWER"
01def764 3299 "maskir %0,%3,%2")
1fd4e8c1 3300
7cd5235b 3301(define_insn "*maskir_internal3"
cd2b37d9 3302 [(set (match_operand:SI 0 "gpc_reg_operand" "=r")
01def764 3303 (ior:SI (and:SI (match_operand:SI 2 "gpc_reg_operand" "r")
cd2b37d9 3304 (match_operand:SI 3 "gpc_reg_operand" "r"))
01def764
RK
3305 (and:SI (not:SI (match_dup 2))
3306 (match_operand:SI 1 "gpc_reg_operand" "0"))))]
ca7f5001 3307 "TARGET_POWER"
01def764 3308 "maskir %0,%3,%2")
1fd4e8c1 3309
7cd5235b 3310(define_insn "*maskir_internal4"
cd2b37d9
RK
3311 [(set (match_operand:SI 0 "gpc_reg_operand" "=r")
3312 (ior:SI (and:SI (match_operand:SI 3 "gpc_reg_operand" "r")
01def764
RK
3313 (match_operand:SI 2 "gpc_reg_operand" "r"))
3314 (and:SI (not:SI (match_dup 2))
3315 (match_operand:SI 1 "gpc_reg_operand" "0"))))]
ca7f5001 3316 "TARGET_POWER"
01def764 3317 "maskir %0,%3,%2")
1fd4e8c1 3318
7cd5235b 3319(define_insn "*maskir_internal5"
9ebbca7d 3320 [(set (match_operand:CC 4 "cc_reg_operand" "=x,?y")
1fd4e8c1 3321 (compare:CC
9ebbca7d
GK
3322 (ior:SI (and:SI (not:SI (match_operand:SI 2 "gpc_reg_operand" "r,r"))
3323 (match_operand:SI 1 "gpc_reg_operand" "0,0"))
01def764 3324 (and:SI (match_dup 2)
9ebbca7d 3325 (match_operand:SI 3 "gpc_reg_operand" "r,r")))
1fd4e8c1 3326 (const_int 0)))
9ebbca7d 3327 (set (match_operand:SI 0 "gpc_reg_operand" "=r,r")
01def764
RK
3328 (ior:SI (and:SI (not:SI (match_dup 2)) (match_dup 1))
3329 (and:SI (match_dup 2) (match_dup 3))))]
ca7f5001 3330 "TARGET_POWER"
9ebbca7d
GK
3331 "@
3332 maskir. %0,%3,%2
3333 #"
3334 [(set_attr "type" "compare")
3335 (set_attr "length" "4,8")])
3336
3337(define_split
3338 [(set (match_operand:CC 4 "cc_reg_not_cr0_operand" "")
3339 (compare:CC
3340 (ior:SI (and:SI (not:SI (match_operand:SI 2 "gpc_reg_operand" ""))
3341 (match_operand:SI 1 "gpc_reg_operand" ""))
3342 (and:SI (match_dup 2)
3343 (match_operand:SI 3 "gpc_reg_operand" "")))
3344 (const_int 0)))
3345 (set (match_operand:SI 0 "gpc_reg_operand" "")
3346 (ior:SI (and:SI (not:SI (match_dup 2)) (match_dup 1))
3347 (and:SI (match_dup 2) (match_dup 3))))]
3348 "TARGET_POWER && reload_completed"
3349 [(set (match_dup 0)
3350 (ior:SI (and:SI (not:SI (match_dup 2)) (match_dup 1))
3351 (and:SI (match_dup 2) (match_dup 3))))
3352 (set (match_dup 4)
3353 (compare:CC (match_dup 0)
3354 (const_int 0)))]
3355 "")
1fd4e8c1 3356
7cd5235b 3357(define_insn "*maskir_internal6"
9ebbca7d 3358 [(set (match_operand:CC 4 "cc_reg_operand" "=x,?y")
1fd4e8c1 3359 (compare:CC
9ebbca7d
GK
3360 (ior:SI (and:SI (not:SI (match_operand:SI 2 "gpc_reg_operand" "r,r"))
3361 (match_operand:SI 1 "gpc_reg_operand" "0,0"))
3362 (and:SI (match_operand:SI 3 "gpc_reg_operand" "r,r")
01def764 3363 (match_dup 2)))
1fd4e8c1 3364 (const_int 0)))
9ebbca7d 3365 (set (match_operand:SI 0 "gpc_reg_operand" "=r,r")
01def764
RK
3366 (ior:SI (and:SI (not:SI (match_dup 2)) (match_dup 1))
3367 (and:SI (match_dup 3) (match_dup 2))))]
ca7f5001 3368 "TARGET_POWER"
9ebbca7d
GK
3369 "@
3370 maskir. %0,%3,%2
3371 #"
3372 [(set_attr "type" "compare")
3373 (set_attr "length" "4,8")])
3374
3375(define_split
3376 [(set (match_operand:CC 4 "cc_reg_not_cr0_operand" "")
3377 (compare:CC
3378 (ior:SI (and:SI (not:SI (match_operand:SI 2 "gpc_reg_operand" ""))
3379 (match_operand:SI 1 "gpc_reg_operand" ""))
3380 (and:SI (match_operand:SI 3 "gpc_reg_operand" "")
3381 (match_dup 2)))
3382 (const_int 0)))
3383 (set (match_operand:SI 0 "gpc_reg_operand" "")
3384 (ior:SI (and:SI (not:SI (match_dup 2)) (match_dup 1))
3385 (and:SI (match_dup 3) (match_dup 2))))]
3386 "TARGET_POWER && reload_completed"
3387 [(set (match_dup 0)
3388 (ior:SI (and:SI (not:SI (match_dup 2)) (match_dup 1))
3389 (and:SI (match_dup 3) (match_dup 2))))
3390 (set (match_dup 4)
3391 (compare:CC (match_dup 0)
3392 (const_int 0)))]
3393 "")
1fd4e8c1 3394
7cd5235b 3395(define_insn "*maskir_internal7"
9ebbca7d 3396 [(set (match_operand:CC 4 "cc_reg_operand" "=x,?y")
815cdc52 3397 (compare:CC
9ebbca7d
GK
3398 (ior:SI (and:SI (match_operand:SI 2 "gpc_reg_operand" "r,r")
3399 (match_operand:SI 3 "gpc_reg_operand" "r,r"))
815cdc52 3400 (and:SI (not:SI (match_dup 2))
9ebbca7d 3401 (match_operand:SI 1 "gpc_reg_operand" "0,0")))
815cdc52 3402 (const_int 0)))
9ebbca7d 3403 (set (match_operand:SI 0 "gpc_reg_operand" "=r,r")
815cdc52
MM
3404 (ior:SI (and:SI (match_dup 2) (match_dup 3))
3405 (and:SI (not:SI (match_dup 2)) (match_dup 1))))]
3406 "TARGET_POWER"
9ebbca7d
GK
3407 "@
3408 maskir. %0,%3,%2
3409 #"
3410 [(set_attr "type" "compare")
3411 (set_attr "length" "4,8")])
3412
3413(define_split
3414 [(set (match_operand:CC 4 "cc_reg_not_cr0_operand" "")
3415 (compare:CC
3416 (ior:SI (and:SI (match_operand:SI 2 "gpc_reg_operand" "")
3417 (match_operand:SI 3 "gpc_reg_operand" ""))
3418 (and:SI (not:SI (match_dup 2))
3419 (match_operand:SI 1 "gpc_reg_operand" "")))
3420 (const_int 0)))
3421 (set (match_operand:SI 0 "gpc_reg_operand" "")
3422 (ior:SI (and:SI (match_dup 2) (match_dup 3))
3423 (and:SI (not:SI (match_dup 2)) (match_dup 1))))]
3424 "TARGET_POWER && reload_completed"
3425 [(set (match_dup 0)
3426 (ior:SI (and:SI (match_dup 2) (match_dup 3))
3427 (and:SI (not:SI (match_dup 2)) (match_dup 1))))
3428 (set (match_dup 4)
3429 (compare:CC (match_dup 0)
3430 (const_int 0)))]
3431 "")
1fd4e8c1 3432
7cd5235b 3433(define_insn "*maskir_internal8"
9ebbca7d 3434 [(set (match_operand:CC 4 "cc_reg_operand" "=x,?y")
1fd4e8c1 3435 (compare:CC
9ebbca7d
GK
3436 (ior:SI (and:SI (match_operand:SI 3 "gpc_reg_operand" "r,r")
3437 (match_operand:SI 2 "gpc_reg_operand" "r,r"))
01def764 3438 (and:SI (not:SI (match_dup 2))
9ebbca7d 3439 (match_operand:SI 1 "gpc_reg_operand" "0,0")))
1fd4e8c1 3440 (const_int 0)))
9ebbca7d 3441 (set (match_operand:SI 0 "gpc_reg_operand" "=r,r")
01def764
RK
3442 (ior:SI (and:SI (match_dup 3) (match_dup 2))
3443 (and:SI (not:SI (match_dup 2)) (match_dup 1))))]
ca7f5001 3444 "TARGET_POWER"
9ebbca7d
GK
3445 "@
3446 maskir. %0,%3,%2
3447 #"
3448 [(set_attr "type" "compare")
3449 (set_attr "length" "4,8")])
fcce224d 3450
9ebbca7d
GK
3451(define_split
3452 [(set (match_operand:CC 4 "cc_reg_not_cr0_operand" "")
3453 (compare:CC
3454 (ior:SI (and:SI (match_operand:SI 3 "gpc_reg_operand" "")
3455 (match_operand:SI 2 "gpc_reg_operand" ""))
3456 (and:SI (not:SI (match_dup 2))
3457 (match_operand:SI 1 "gpc_reg_operand" "")))
3458 (const_int 0)))
3459 (set (match_operand:SI 0 "gpc_reg_operand" "")
3460 (ior:SI (and:SI (match_dup 3) (match_dup 2))
3461 (and:SI (not:SI (match_dup 2)) (match_dup 1))))]
3462 "TARGET_POWER && reload_completed"
3463 [(set (match_dup 0)
3464 (ior:SI (and:SI (match_dup 3) (match_dup 2))
3465 (and:SI (not:SI (match_dup 2)) (match_dup 1))))
3466 (set (match_dup 4)
3467 (compare:CC (match_dup 0)
3468 (const_int 0)))]
3469 "")
fcce224d 3470\f
1fd4e8c1
RK
3471;; Rotate and shift insns, in all their variants. These support shifts,
3472;; field inserts and extracts, and various combinations thereof.
034c1be0 3473(define_expand "insv"
0ad91047
DE
3474 [(set (zero_extract (match_operand 0 "gpc_reg_operand" "")
3475 (match_operand:SI 1 "const_int_operand" "")
3476 (match_operand:SI 2 "const_int_operand" ""))
3477 (match_operand 3 "gpc_reg_operand" ""))]
034c1be0
MM
3478 ""
3479 "
3480{
3481 /* Do not handle 16/8 bit structures that fit in HI/QI modes directly, since
3482 the (SUBREG:SI (REG:HI xxx)) that is otherwise generated can confuse the
14502dad
JM
3483 compiler if the address of the structure is taken later. Likewise, do
3484 not handle invalid E500 subregs. */
034c1be0 3485 if (GET_CODE (operands[0]) == SUBREG
14502dad
JM
3486 && (GET_MODE_SIZE (GET_MODE (SUBREG_REG (operands[0]))) < UNITS_PER_WORD
3487 || ((TARGET_E500_DOUBLE || TARGET_SPE)
3488 && invalid_e500_subreg (operands[0], GET_MODE (operands[0])))))
034c1be0 3489 FAIL;
a78e33fc
DE
3490
3491 if (TARGET_POWERPC64 && GET_MODE (operands[0]) == DImode)
3492 emit_insn (gen_insvdi (operands[0], operands[1], operands[2], operands[3]));
3493 else
3494 emit_insn (gen_insvsi (operands[0], operands[1], operands[2], operands[3]));
3495 DONE;
034c1be0
MM
3496}")
3497
a78e33fc 3498(define_insn "insvsi"
cd2b37d9 3499 [(set (zero_extract:SI (match_operand:SI 0 "gpc_reg_operand" "+r")
1fd4e8c1
RK
3500 (match_operand:SI 1 "const_int_operand" "i")
3501 (match_operand:SI 2 "const_int_operand" "i"))
cd2b37d9 3502 (match_operand:SI 3 "gpc_reg_operand" "r"))]
1fd4e8c1
RK
3503 ""
3504 "*
3505{
3506 int start = INTVAL (operands[2]) & 31;
3507 int size = INTVAL (operands[1]) & 31;
3508
89e9f3a8
MM
3509 operands[4] = GEN_INT (32 - start - size);
3510 operands[1] = GEN_INT (start + size - 1);
a66078ee 3511 return \"{rlimi|rlwimi} %0,%3,%h4,%h2,%h1\";
8e8238f1
DE
3512}"
3513 [(set_attr "type" "insert_word")])
1fd4e8c1 3514
a78e33fc 3515(define_insn "*insvsi_internal1"
d56d506a
RK
3516 [(set (zero_extract:SI (match_operand:SI 0 "gpc_reg_operand" "+r")
3517 (match_operand:SI 1 "const_int_operand" "i")
3518 (match_operand:SI 2 "const_int_operand" "i"))
6d0a8091 3519 (rotate:SI (match_operand:SI 3 "gpc_reg_operand" "r")
d56d506a 3520 (match_operand:SI 4 "const_int_operand" "i")))]
f0dc3f49 3521 "(32 - (INTVAL (operands[4]) & 31)) >= INTVAL (operands[1])"
d56d506a
RK
3522 "*
3523{
3524 int shift = INTVAL (operands[4]) & 31;
3525 int start = INTVAL (operands[2]) & 31;
3526 int size = INTVAL (operands[1]) & 31;
3527
89e9f3a8 3528 operands[4] = GEN_INT (shift - start - size);
6d0a8091 3529 operands[1] = GEN_INT (start + size - 1);
a66078ee 3530 return \"{rlimi|rlwimi} %0,%3,%h4,%h2,%h1\";
8e8238f1
DE
3531}"
3532 [(set_attr "type" "insert_word")])
d56d506a 3533
a78e33fc 3534(define_insn "*insvsi_internal2"
d56d506a
RK
3535 [(set (zero_extract:SI (match_operand:SI 0 "gpc_reg_operand" "+r")
3536 (match_operand:SI 1 "const_int_operand" "i")
3537 (match_operand:SI 2 "const_int_operand" "i"))
3538 (ashiftrt:SI (match_operand:SI 3 "gpc_reg_operand" "r")
3539 (match_operand:SI 4 "const_int_operand" "i")))]
f0dc3f49 3540 "(32 - (INTVAL (operands[4]) & 31)) >= INTVAL (operands[1])"
d56d506a
RK
3541 "*
3542{
3543 int shift = INTVAL (operands[4]) & 31;
3544 int start = INTVAL (operands[2]) & 31;
3545 int size = INTVAL (operands[1]) & 31;
3546
89e9f3a8
MM
3547 operands[4] = GEN_INT (32 - shift - start - size);
3548 operands[1] = GEN_INT (start + size - 1);
a66078ee 3549 return \"{rlimi|rlwimi} %0,%3,%h4,%h2,%h1\";
8e8238f1
DE
3550}"
3551 [(set_attr "type" "insert_word")])
d56d506a 3552
a78e33fc 3553(define_insn "*insvsi_internal3"
d56d506a
RK
3554 [(set (zero_extract:SI (match_operand:SI 0 "gpc_reg_operand" "+r")
3555 (match_operand:SI 1 "const_int_operand" "i")
3556 (match_operand:SI 2 "const_int_operand" "i"))
3557 (lshiftrt:SI (match_operand:SI 3 "gpc_reg_operand" "r")
3558 (match_operand:SI 4 "const_int_operand" "i")))]
95e8f2f3 3559 "(32 - (INTVAL (operands[4]) & 31)) >= INTVAL (operands[1])"
d56d506a
RK
3560 "*
3561{
3562 int shift = INTVAL (operands[4]) & 31;
3563 int start = INTVAL (operands[2]) & 31;
3564 int size = INTVAL (operands[1]) & 31;
3565
89e9f3a8
MM
3566 operands[4] = GEN_INT (32 - shift - start - size);
3567 operands[1] = GEN_INT (start + size - 1);
a66078ee 3568 return \"{rlimi|rlwimi} %0,%3,%h4,%h2,%h1\";
8e8238f1
DE
3569}"
3570 [(set_attr "type" "insert_word")])
d56d506a 3571
a78e33fc 3572(define_insn "*insvsi_internal4"
d56d506a
RK
3573 [(set (zero_extract:SI (match_operand:SI 0 "gpc_reg_operand" "+r")
3574 (match_operand:SI 1 "const_int_operand" "i")
3575 (match_operand:SI 2 "const_int_operand" "i"))
3576 (zero_extract:SI (match_operand:SI 3 "gpc_reg_operand" "r")
3577 (match_operand:SI 4 "const_int_operand" "i")
3578 (match_operand:SI 5 "const_int_operand" "i")))]
3579 "INTVAL (operands[4]) >= INTVAL (operands[1])"
3580 "*
3581{
3582 int extract_start = INTVAL (operands[5]) & 31;
3583 int extract_size = INTVAL (operands[4]) & 31;
3584 int insert_start = INTVAL (operands[2]) & 31;
3585 int insert_size = INTVAL (operands[1]) & 31;
3586
3587/* Align extract field with insert field */
3a598fbe 3588 operands[5] = GEN_INT (extract_start + extract_size - insert_start - insert_size);
89e9f3a8 3589 operands[1] = GEN_INT (insert_start + insert_size - 1);
a66078ee 3590 return \"{rlimi|rlwimi} %0,%3,%h5,%h2,%h1\";
8e8238f1
DE
3591}"
3592 [(set_attr "type" "insert_word")])
d56d506a 3593
f241bf89
EC
3594;; combine patterns for rlwimi
3595(define_insn "*insvsi_internal5"
3596 [(set (match_operand:SI 0 "gpc_reg_operand" "=r")
3597 (ior:SI (and:SI (match_operand:SI 4 "gpc_reg_operand" "0")
3598 (match_operand:SI 1 "mask_operand" "i"))
3599 (and:SI (lshiftrt:SI (match_operand:SI 3 "gpc_reg_operand" "r")
3600 (match_operand:SI 2 "const_int_operand" "i"))
3601 (match_operand:SI 5 "mask_operand" "i"))))]
3602 "TARGET_POWERPC && INTVAL(operands[1]) == ~INTVAL(operands[5])"
3603 "*
3604{
3605 int me = extract_ME(operands[5]);
3606 int mb = extract_MB(operands[5]);
3607 operands[4] = GEN_INT(32 - INTVAL(operands[2]));
3608 operands[2] = GEN_INT(mb);
3609 operands[1] = GEN_INT(me);
3610 return \"{rlimi|rlwimi} %0,%3,%h4,%h2,%h1\";
3611}"
3612 [(set_attr "type" "insert_word")])
3613
3614(define_insn "*insvsi_internal6"
3615 [(set (match_operand:SI 0 "gpc_reg_operand" "=r")
3616 (ior:SI (and:SI (lshiftrt:SI (match_operand:SI 3 "gpc_reg_operand" "r")
3617 (match_operand:SI 2 "const_int_operand" "i"))
3618 (match_operand:SI 5 "mask_operand" "i"))
3619 (and:SI (match_operand:SI 4 "gpc_reg_operand" "0")
3620 (match_operand:SI 1 "mask_operand" "i"))))]
3621 "TARGET_POWERPC && INTVAL(operands[1]) == ~INTVAL(operands[5])"
3622 "*
3623{
3624 int me = extract_ME(operands[5]);
3625 int mb = extract_MB(operands[5]);
3626 operands[4] = GEN_INT(32 - INTVAL(operands[2]));
3627 operands[2] = GEN_INT(mb);
3628 operands[1] = GEN_INT(me);
3629 return \"{rlimi|rlwimi} %0,%3,%h4,%h2,%h1\";
3630}"
3631 [(set_attr "type" "insert_word")])
3632
a78e33fc 3633(define_insn "insvdi"
685f3906 3634 [(set (zero_extract:DI (match_operand:DI 0 "gpc_reg_operand" "+r")
a78e33fc
DE
3635 (match_operand:SI 1 "const_int_operand" "i")
3636 (match_operand:SI 2 "const_int_operand" "i"))
685f3906
DE
3637 (match_operand:DI 3 "gpc_reg_operand" "r"))]
3638 "TARGET_POWERPC64"
3639 "*
3640{
3641 int start = INTVAL (operands[2]) & 63;
3642 int size = INTVAL (operands[1]) & 63;
3643
a78e33fc
DE
3644 operands[1] = GEN_INT (64 - start - size);
3645 return \"rldimi %0,%3,%H1,%H2\";
44cd321e
PS
3646}"
3647 [(set_attr "type" "insert_dword")])
685f3906 3648
11ac38b2
DE
3649(define_insn "*insvdi_internal2"
3650 [(set (zero_extract:DI (match_operand:DI 0 "gpc_reg_operand" "+r")
3651 (match_operand:SI 1 "const_int_operand" "i")
3652 (match_operand:SI 2 "const_int_operand" "i"))
3653 (ashiftrt:DI (match_operand:DI 3 "gpc_reg_operand" "r")
3654 (match_operand:SI 4 "const_int_operand" "i")))]
3655 "TARGET_POWERPC64
3656 && insvdi_rshift_rlwimi_p (operands[1], operands[2], operands[4])"
3657 "*
3658{
3659 int shift = INTVAL (operands[4]) & 63;
3660 int start = (INTVAL (operands[2]) & 63) - 32;
3661 int size = INTVAL (operands[1]) & 63;
3662
3663 operands[4] = GEN_INT (64 - shift - start - size);
3664 operands[2] = GEN_INT (start);
3665 operands[1] = GEN_INT (start + size - 1);
3666 return \"rlwimi %0,%3,%h4,%h2,%h1\";
3667}")
3668
3669(define_insn "*insvdi_internal3"
3670 [(set (zero_extract:DI (match_operand:DI 0 "gpc_reg_operand" "+r")
3671 (match_operand:SI 1 "const_int_operand" "i")
3672 (match_operand:SI 2 "const_int_operand" "i"))
3673 (lshiftrt:DI (match_operand:DI 3 "gpc_reg_operand" "r")
3674 (match_operand:SI 4 "const_int_operand" "i")))]
3675 "TARGET_POWERPC64
3676 && insvdi_rshift_rlwimi_p (operands[1], operands[2], operands[4])"
3677 "*
3678{
3679 int shift = INTVAL (operands[4]) & 63;
3680 int start = (INTVAL (operands[2]) & 63) - 32;
3681 int size = INTVAL (operands[1]) & 63;
3682
3683 operands[4] = GEN_INT (64 - shift - start - size);
3684 operands[2] = GEN_INT (start);
3685 operands[1] = GEN_INT (start + size - 1);
3686 return \"rlwimi %0,%3,%h4,%h2,%h1\";
3687}")
3688
034c1be0 3689(define_expand "extzv"
0ad91047
DE
3690 [(set (match_operand 0 "gpc_reg_operand" "")
3691 (zero_extract (match_operand 1 "gpc_reg_operand" "")
3692 (match_operand:SI 2 "const_int_operand" "")
3693 (match_operand:SI 3 "const_int_operand" "")))]
034c1be0
MM
3694 ""
3695 "
3696{
3697 /* Do not handle 16/8 bit structures that fit in HI/QI modes directly, since
3698 the (SUBREG:SI (REG:HI xxx)) that is otherwise generated can confuse the
3699 compiler if the address of the structure is taken later. */
3700 if (GET_CODE (operands[0]) == SUBREG
3701 && (GET_MODE_SIZE (GET_MODE (SUBREG_REG (operands[0]))) < UNITS_PER_WORD))
3702 FAIL;
a78e33fc
DE
3703
3704 if (TARGET_POWERPC64 && GET_MODE (operands[1]) == DImode)
3705 emit_insn (gen_extzvdi (operands[0], operands[1], operands[2], operands[3]));
3706 else
3707 emit_insn (gen_extzvsi (operands[0], operands[1], operands[2], operands[3]));
3708 DONE;
034c1be0
MM
3709}")
3710
a78e33fc 3711(define_insn "extzvsi"
cd2b37d9
RK
3712 [(set (match_operand:SI 0 "gpc_reg_operand" "=r")
3713 (zero_extract:SI (match_operand:SI 1 "gpc_reg_operand" "r")
1fd4e8c1
RK
3714 (match_operand:SI 2 "const_int_operand" "i")
3715 (match_operand:SI 3 "const_int_operand" "i")))]
3716 ""
3717 "*
3718{
3719 int start = INTVAL (operands[3]) & 31;
3720 int size = INTVAL (operands[2]) & 31;
3721
3722 if (start + size >= 32)
3723 operands[3] = const0_rtx;
3724 else
89e9f3a8 3725 operands[3] = GEN_INT (start + size);
ca7f5001 3726 return \"{rlinm|rlwinm} %0,%1,%3,%s2,31\";
1fd4e8c1
RK
3727}")
3728
a78e33fc 3729(define_insn "*extzvsi_internal1"
9ebbca7d
GK
3730 [(set (match_operand:CC 0 "cc_reg_operand" "=x,?y")
3731 (compare:CC (zero_extract:SI (match_operand:SI 1 "gpc_reg_operand" "r,r")
3732 (match_operand:SI 2 "const_int_operand" "i,i")
3733 (match_operand:SI 3 "const_int_operand" "i,i"))
1fd4e8c1 3734 (const_int 0)))
9ebbca7d 3735 (clobber (match_scratch:SI 4 "=r,r"))]
ce71f754 3736 ""
1fd4e8c1
RK
3737 "*
3738{
3739 int start = INTVAL (operands[3]) & 31;
3740 int size = INTVAL (operands[2]) & 31;
3741
9ebbca7d
GK
3742 /* Force split for non-cc0 compare. */
3743 if (which_alternative == 1)
3744 return \"#\";
3745
43a88a8c 3746 /* If the bit-field being tested fits in the upper or lower half of a
a7a975e1
RK
3747 word, it is possible to use andiu. or andil. to test it. This is
3748 useful because the condition register set-use delay is smaller for
3749 andi[ul]. than for rlinm. This doesn't work when the starting bit
3750 position is 0 because the LT and GT bits may be set wrong. */
3751
3752 if ((start > 0 && start + size <= 16) || start >= 16)
df031c43 3753 {
3a598fbe 3754 operands[3] = GEN_INT (((1 << (16 - (start & 15)))
df031c43
RK
3755 - (1 << (16 - (start & 15) - size))));
3756 if (start < 16)
ca7f5001 3757 return \"{andiu.|andis.} %4,%1,%3\";
df031c43 3758 else
ca7f5001 3759 return \"{andil.|andi.} %4,%1,%3\";
df031c43 3760 }
7e69e155 3761
1fd4e8c1
RK
3762 if (start + size >= 32)
3763 operands[3] = const0_rtx;
3764 else
89e9f3a8 3765 operands[3] = GEN_INT (start + size);
ca7f5001 3766 return \"{rlinm.|rlwinm.} %4,%1,%3,%s2,31\";
1fd4e8c1 3767}"
44cd321e 3768 [(set_attr "type" "delayed_compare")
9ebbca7d
GK
3769 (set_attr "length" "4,8")])
3770
3771(define_split
3772 [(set (match_operand:CC 0 "cc_reg_not_cr0_operand" "")
3773 (compare:CC (zero_extract:SI (match_operand:SI 1 "gpc_reg_operand" "")
3774 (match_operand:SI 2 "const_int_operand" "")
3775 (match_operand:SI 3 "const_int_operand" ""))
3776 (const_int 0)))
3777 (clobber (match_scratch:SI 4 ""))]
ce71f754 3778 "reload_completed"
9ebbca7d
GK
3779 [(set (match_dup 4)
3780 (zero_extract:SI (match_dup 1) (match_dup 2)
3781 (match_dup 3)))
3782 (set (match_dup 0)
3783 (compare:CC (match_dup 4)
3784 (const_int 0)))]
3785 "")
1fd4e8c1 3786
a78e33fc 3787(define_insn "*extzvsi_internal2"
9ebbca7d
GK
3788 [(set (match_operand:CC 4 "cc_reg_operand" "=x,?y")
3789 (compare:CC (zero_extract:SI (match_operand:SI 1 "gpc_reg_operand" "r,r")
3790 (match_operand:SI 2 "const_int_operand" "i,i")
3791 (match_operand:SI 3 "const_int_operand" "i,i"))
1fd4e8c1 3792 (const_int 0)))
9ebbca7d 3793 (set (match_operand:SI 0 "gpc_reg_operand" "=r,r")
1fd4e8c1 3794 (zero_extract:SI (match_dup 1) (match_dup 2) (match_dup 3)))]
ce71f754 3795 ""
1fd4e8c1
RK
3796 "*
3797{
3798 int start = INTVAL (operands[3]) & 31;
3799 int size = INTVAL (operands[2]) & 31;
3800
9ebbca7d
GK
3801 /* Force split for non-cc0 compare. */
3802 if (which_alternative == 1)
3803 return \"#\";
3804
bc401279 3805 /* Since we are using the output value, we can't ignore any need for
43a88a8c 3806 a shift. The bit-field must end at the LSB. */
bc401279 3807 if (start >= 16 && start + size == 32)
df031c43 3808 {
bc401279
AM
3809 operands[3] = GEN_INT ((1 << size) - 1);
3810 return \"{andil.|andi.} %0,%1,%3\";
df031c43 3811 }
7e69e155 3812
1fd4e8c1
RK
3813 if (start + size >= 32)
3814 operands[3] = const0_rtx;
3815 else
89e9f3a8 3816 operands[3] = GEN_INT (start + size);
ca7f5001 3817 return \"{rlinm.|rlwinm.} %0,%1,%3,%s2,31\";
1fd4e8c1 3818}"
44cd321e 3819 [(set_attr "type" "delayed_compare")
9ebbca7d
GK
3820 (set_attr "length" "4,8")])
3821
3822(define_split
3823 [(set (match_operand:CC 4 "cc_reg_not_cr0_operand" "")
3824 (compare:CC (zero_extract:SI (match_operand:SI 1 "gpc_reg_operand" "")
3825 (match_operand:SI 2 "const_int_operand" "")
3826 (match_operand:SI 3 "const_int_operand" ""))
3827 (const_int 0)))
3828 (set (match_operand:SI 0 "gpc_reg_operand" "")
3829 (zero_extract:SI (match_dup 1) (match_dup 2) (match_dup 3)))]
ce71f754 3830 "reload_completed"
9ebbca7d
GK
3831 [(set (match_dup 0)
3832 (zero_extract:SI (match_dup 1) (match_dup 2) (match_dup 3)))
3833 (set (match_dup 4)
3834 (compare:CC (match_dup 0)
3835 (const_int 0)))]
3836 "")
1fd4e8c1 3837
a78e33fc 3838(define_insn "extzvdi"
685f3906
DE
3839 [(set (match_operand:DI 0 "gpc_reg_operand" "=r")
3840 (zero_extract:DI (match_operand:DI 1 "gpc_reg_operand" "r")
a78e33fc
DE
3841 (match_operand:SI 2 "const_int_operand" "i")
3842 (match_operand:SI 3 "const_int_operand" "i")))]
685f3906
DE
3843 "TARGET_POWERPC64"
3844 "*
3845{
3846 int start = INTVAL (operands[3]) & 63;
3847 int size = INTVAL (operands[2]) & 63;
3848
3849 if (start + size >= 64)
3850 operands[3] = const0_rtx;
3851 else
89e9f3a8
MM
3852 operands[3] = GEN_INT (start + size);
3853 operands[2] = GEN_INT (64 - size);
685f3906
DE
3854 return \"rldicl %0,%1,%3,%2\";
3855}")
3856
a78e33fc 3857(define_insn "*extzvdi_internal1"
29ae5b89
JL
3858 [(set (match_operand:CC 0 "gpc_reg_operand" "=x")
3859 (compare:CC (zero_extract:DI (match_operand:DI 1 "gpc_reg_operand" "r")
a78e33fc
DE
3860 (match_operand:SI 2 "const_int_operand" "i")
3861 (match_operand:SI 3 "const_int_operand" "i"))
685f3906 3862 (const_int 0)))
29ae5b89 3863 (clobber (match_scratch:DI 4 "=r"))]
683bdff7 3864 "TARGET_64BIT"
685f3906
DE
3865 "*
3866{
3867 int start = INTVAL (operands[3]) & 63;
3868 int size = INTVAL (operands[2]) & 63;
3869
3870 if (start + size >= 64)
3871 operands[3] = const0_rtx;
3872 else
89e9f3a8
MM
3873 operands[3] = GEN_INT (start + size);
3874 operands[2] = GEN_INT (64 - size);
685f3906 3875 return \"rldicl. %4,%1,%3,%2\";
9a3c428b
DE
3876}"
3877 [(set_attr "type" "compare")])
685f3906 3878
a78e33fc 3879(define_insn "*extzvdi_internal2"
29ae5b89
JL
3880 [(set (match_operand:CC 4 "gpc_reg_operand" "=x")
3881 (compare:CC (zero_extract:DI (match_operand:DI 1 "gpc_reg_operand" "r")
a78e33fc
DE
3882 (match_operand:SI 2 "const_int_operand" "i")
3883 (match_operand:SI 3 "const_int_operand" "i"))
685f3906 3884 (const_int 0)))
29ae5b89 3885 (set (match_operand:DI 0 "gpc_reg_operand" "=r")
685f3906 3886 (zero_extract:DI (match_dup 1) (match_dup 2) (match_dup 3)))]
683bdff7 3887 "TARGET_64BIT"
685f3906
DE
3888 "*
3889{
3890 int start = INTVAL (operands[3]) & 63;
3891 int size = INTVAL (operands[2]) & 63;
3892
3893 if (start + size >= 64)
3894 operands[3] = const0_rtx;
3895 else
89e9f3a8
MM
3896 operands[3] = GEN_INT (start + size);
3897 operands[2] = GEN_INT (64 - size);
685f3906 3898 return \"rldicl. %0,%1,%3,%2\";
9a3c428b
DE
3899}"
3900 [(set_attr "type" "compare")])
685f3906 3901
1fd4e8c1 3902(define_insn "rotlsi3"
44cd321e
PS
3903 [(set (match_operand:SI 0 "gpc_reg_operand" "=r,r")
3904 (rotate:SI (match_operand:SI 1 "gpc_reg_operand" "r,r")
3905 (match_operand:SI 2 "reg_or_cint_operand" "r,i")))]
1fd4e8c1 3906 ""
44cd321e
PS
3907 "@
3908 {rlnm|rlwnm} %0,%1,%2,0xffffffff
3909 {rlinm|rlwinm} %0,%1,%h2,0xffffffff"
3910 [(set_attr "type" "var_shift_rotate,integer")])
1fd4e8c1 3911
a260abc9 3912(define_insn "*rotlsi3_internal2"
44cd321e
PS
3913 [(set (match_operand:CC 0 "cc_reg_operand" "=x,x,?y,?y")
3914 (compare:CC (rotate:SI (match_operand:SI 1 "gpc_reg_operand" "r,r,r,r")
3915 (match_operand:SI 2 "reg_or_cint_operand" "r,i,r,i"))
1fd4e8c1 3916 (const_int 0)))
44cd321e 3917 (clobber (match_scratch:SI 3 "=r,r,r,r"))]
ce71f754 3918 ""
9ebbca7d 3919 "@
44cd321e
PS
3920 {rlnm.|rlwnm.} %3,%1,%2,0xffffffff
3921 {rlinm.|rlwinm.} %3,%1,%h2,0xffffffff
3922 #
9ebbca7d 3923 #"
44cd321e
PS
3924 [(set_attr "type" "var_delayed_compare,delayed_compare,var_delayed_compare,delayed_compare")
3925 (set_attr "length" "4,4,8,8")])
9ebbca7d
GK
3926
3927(define_split
3928 [(set (match_operand:CC 0 "cc_reg_not_cr0_operand" "")
3929 (compare:CC (rotate:SI (match_operand:SI 1 "gpc_reg_operand" "")
3930 (match_operand:SI 2 "reg_or_cint_operand" ""))
3931 (const_int 0)))
3932 (clobber (match_scratch:SI 3 ""))]
ce71f754 3933 "reload_completed"
9ebbca7d
GK
3934 [(set (match_dup 3)
3935 (rotate:SI (match_dup 1) (match_dup 2)))
3936 (set (match_dup 0)
3937 (compare:CC (match_dup 3)
3938 (const_int 0)))]
3939 "")
1fd4e8c1 3940
a260abc9 3941(define_insn "*rotlsi3_internal3"
44cd321e
PS
3942 [(set (match_operand:CC 3 "cc_reg_operand" "=x,x,?y,?y")
3943 (compare:CC (rotate:SI (match_operand:SI 1 "gpc_reg_operand" "r,r,r,r")
3944 (match_operand:SI 2 "reg_or_cint_operand" "r,i,r,i"))
1fd4e8c1 3945 (const_int 0)))
44cd321e 3946 (set (match_operand:SI 0 "gpc_reg_operand" "=r,r,r,r")
1fd4e8c1 3947 (rotate:SI (match_dup 1) (match_dup 2)))]
ce71f754 3948 ""
9ebbca7d 3949 "@
44cd321e
PS
3950 {rlnm.|rlwnm.} %0,%1,%2,0xffffffff
3951 {rlinm.|rlwinm.} %0,%1,%h2,0xffffffff
3952 #
9ebbca7d 3953 #"
44cd321e
PS
3954 [(set_attr "type" "var_delayed_compare,delayed_compare,var_delayed_compare,delayed_compare")
3955 (set_attr "length" "4,4,8,8")])
9ebbca7d
GK
3956
3957(define_split
3958 [(set (match_operand:CC 3 "cc_reg_not_cr0_operand" "")
3959 (compare:CC (rotate:SI (match_operand:SI 1 "gpc_reg_operand" "")
3960 (match_operand:SI 2 "reg_or_cint_operand" ""))
3961 (const_int 0)))
3962 (set (match_operand:SI 0 "gpc_reg_operand" "")
3963 (rotate:SI (match_dup 1) (match_dup 2)))]
ce71f754 3964 "reload_completed"
9ebbca7d
GK
3965 [(set (match_dup 0)
3966 (rotate:SI (match_dup 1) (match_dup 2)))
3967 (set (match_dup 3)
3968 (compare:CC (match_dup 0)
3969 (const_int 0)))]
3970 "")
1fd4e8c1 3971
a260abc9 3972(define_insn "*rotlsi3_internal4"
44cd321e
PS
3973 [(set (match_operand:SI 0 "gpc_reg_operand" "=r,r")
3974 (and:SI (rotate:SI (match_operand:SI 1 "gpc_reg_operand" "r,r")
3975 (match_operand:SI 2 "reg_or_cint_operand" "r,i"))
3976 (match_operand:SI 3 "mask_operand" "n,n")))]
1fd4e8c1 3977 ""
44cd321e
PS
3978 "@
3979 {rlnm|rlwnm} %0,%1,%2,%m3,%M3
3980 {rlinm|rlwinm} %0,%1,%h2,%m3,%M3"
3981 [(set_attr "type" "var_shift_rotate,integer")])
1fd4e8c1 3982
a260abc9 3983(define_insn "*rotlsi3_internal5"
44cd321e 3984 [(set (match_operand:CC 0 "cc_reg_operand" "=x,x,?y,?y")
1fd4e8c1 3985 (compare:CC (and:SI
44cd321e
PS
3986 (rotate:SI (match_operand:SI 1 "gpc_reg_operand" "r,r,r,r")
3987 (match_operand:SI 2 "reg_or_cint_operand" "r,i,r,i"))
3988 (match_operand:SI 3 "mask_operand" "n,n,n,n"))
1fd4e8c1 3989 (const_int 0)))
44cd321e 3990 (clobber (match_scratch:SI 4 "=r,r,r,r"))]
ce71f754 3991 ""
9ebbca7d 3992 "@
44cd321e
PS
3993 {rlnm.|rlwnm.} %4,%1,%2,%m3,%M3
3994 {rlinm.|rlwinm.} %4,%1,%h2,%m3,%M3
3995 #
9ebbca7d 3996 #"
44cd321e
PS
3997 [(set_attr "type" "var_delayed_compare,delayed_compare,var_delayed_compare,delayed_compare")
3998 (set_attr "length" "4,4,8,8")])
9ebbca7d
GK
3999
4000(define_split
4001 [(set (match_operand:CC 0 "cc_reg_not_cr0_operand" "")
4002 (compare:CC (and:SI
4003 (rotate:SI (match_operand:SI 1 "gpc_reg_operand" "")
4004 (match_operand:SI 2 "reg_or_cint_operand" ""))
4005 (match_operand:SI 3 "mask_operand" ""))
4006 (const_int 0)))
4007 (clobber (match_scratch:SI 4 ""))]
ce71f754 4008 "reload_completed"
9ebbca7d
GK
4009 [(set (match_dup 4)
4010 (and:SI (rotate:SI (match_dup 1)
4011 (match_dup 2))
4012 (match_dup 3)))
4013 (set (match_dup 0)
4014 (compare:CC (match_dup 4)
4015 (const_int 0)))]
4016 "")
1fd4e8c1 4017
a260abc9 4018(define_insn "*rotlsi3_internal6"
44cd321e 4019 [(set (match_operand:CC 4 "cc_reg_operand" "=x,x,?y,?y")
1fd4e8c1 4020 (compare:CC (and:SI
44cd321e
PS
4021 (rotate:SI (match_operand:SI 1 "gpc_reg_operand" "r,r,r,r")
4022 (match_operand:SI 2 "reg_or_cint_operand" "r,i,r,i"))
4023 (match_operand:SI 3 "mask_operand" "n,n,n,n"))
1fd4e8c1 4024 (const_int 0)))
44cd321e 4025 (set (match_operand:SI 0 "gpc_reg_operand" "=r,r,r,r")
1fd4e8c1 4026 (and:SI (rotate:SI (match_dup 1) (match_dup 2)) (match_dup 3)))]
ce71f754 4027 ""
9ebbca7d 4028 "@
44cd321e
PS
4029 {rlnm.|rlwnm.} %0,%1,%2,%m3,%M3
4030 {rlinm.|rlwinm.} %0,%1,%h2,%m3,%M3
4031 #
9ebbca7d 4032 #"
44cd321e
PS
4033 [(set_attr "type" "var_delayed_compare,delayed_compare,var_delayed_compare,delayed_compare")
4034 (set_attr "length" "4,4,8,8")])
9ebbca7d
GK
4035
4036(define_split
4037 [(set (match_operand:CC 4 "cc_reg_not_cr0_operand" "")
4038 (compare:CC (and:SI
4039 (rotate:SI (match_operand:SI 1 "gpc_reg_operand" "")
4040 (match_operand:SI 2 "reg_or_cint_operand" ""))
4041 (match_operand:SI 3 "mask_operand" ""))
4042 (const_int 0)))
4043 (set (match_operand:SI 0 "gpc_reg_operand" "")
4044 (and:SI (rotate:SI (match_dup 1) (match_dup 2)) (match_dup 3)))]
ce71f754 4045 "reload_completed"
9ebbca7d
GK
4046 [(set (match_dup 0)
4047 (and:SI (rotate:SI (match_dup 1) (match_dup 2)) (match_dup 3)))
4048 (set (match_dup 4)
4049 (compare:CC (match_dup 0)
4050 (const_int 0)))]
4051 "")
1fd4e8c1 4052
a260abc9 4053(define_insn "*rotlsi3_internal7"
cd2b37d9 4054 [(set (match_operand:SI 0 "gpc_reg_operand" "=r")
1fd4e8c1
RK
4055 (zero_extend:SI
4056 (subreg:QI
cd2b37d9 4057 (rotate:SI (match_operand:SI 1 "gpc_reg_operand" "r")
1fd4e8c1
RK
4058 (match_operand:SI 2 "reg_or_cint_operand" "ri")) 0)))]
4059 ""
ca7f5001 4060 "{rl%I2nm|rlw%I2nm} %0,%1,%h2,0xff")
1fd4e8c1 4061
a260abc9 4062(define_insn "*rotlsi3_internal8"
44cd321e 4063 [(set (match_operand:CC 0 "cc_reg_operand" "=x,x,?y,?y")
1fd4e8c1
RK
4064 (compare:CC (zero_extend:SI
4065 (subreg:QI
44cd321e
PS
4066 (rotate:SI (match_operand:SI 1 "gpc_reg_operand" "r,r,r,r")
4067 (match_operand:SI 2 "reg_or_cint_operand" "r,i,r,i")) 0))
1fd4e8c1 4068 (const_int 0)))
44cd321e 4069 (clobber (match_scratch:SI 3 "=r,r,r,r"))]
1fd4e8c1 4070 ""
9ebbca7d 4071 "@
44cd321e
PS
4072 {rlnm.|rlwnm.} %3,%1,%2,0xff
4073 {rlinm.|rlwinm.} %3,%1,%h2,0xff
4074 #
9ebbca7d 4075 #"
44cd321e
PS
4076 [(set_attr "type" "var_delayed_compare,delayed_compare,var_delayed_compare,delayed_compare")
4077 (set_attr "length" "4,4,8,8")])
9ebbca7d
GK
4078
4079(define_split
4080 [(set (match_operand:CC 0 "cc_reg_not_cr0_operand" "")
4081 (compare:CC (zero_extend:SI
4082 (subreg:QI
4083 (rotate:SI (match_operand:SI 1 "gpc_reg_operand" "")
4084 (match_operand:SI 2 "reg_or_cint_operand" "")) 0))
4085 (const_int 0)))
4086 (clobber (match_scratch:SI 3 ""))]
4087 "reload_completed"
4088 [(set (match_dup 3)
4089 (zero_extend:SI (subreg:QI
4090 (rotate:SI (match_dup 1)
4091 (match_dup 2)) 0)))
4092 (set (match_dup 0)
4093 (compare:CC (match_dup 3)
4094 (const_int 0)))]
4095 "")
1fd4e8c1 4096
a260abc9 4097(define_insn "*rotlsi3_internal9"
44cd321e 4098 [(set (match_operand:CC 3 "cc_reg_operand" "=x,x,?y,?y")
1fd4e8c1
RK
4099 (compare:CC (zero_extend:SI
4100 (subreg:QI
44cd321e
PS
4101 (rotate:SI (match_operand:SI 1 "gpc_reg_operand" "r,r,r,r")
4102 (match_operand:SI 2 "reg_or_cint_operand" "r,i,r,i")) 0))
1fd4e8c1 4103 (const_int 0)))
44cd321e 4104 (set (match_operand:SI 0 "gpc_reg_operand" "=r,r,r,r")
1fd4e8c1
RK
4105 (zero_extend:SI (subreg:QI (rotate:SI (match_dup 1) (match_dup 2)) 0)))]
4106 ""
9ebbca7d 4107 "@
44cd321e
PS
4108 {rlnm.|rlwnm.} %0,%1,%2,0xff
4109 {rlinm.|rlwinm.} %0,%1,%h2,0xff
4110 #
9ebbca7d 4111 #"
44cd321e
PS
4112 [(set_attr "type" "var_delayed_compare,delayed_compare,var_delayed_compare,delayed_compare")
4113 (set_attr "length" "4,4,8,8")])
9ebbca7d
GK
4114
4115(define_split
4116 [(set (match_operand:CC 3 "cc_reg_not_cr0_operand" "")
4117 (compare:CC (zero_extend:SI
4118 (subreg:QI
4119 (rotate:SI (match_operand:SI 1 "gpc_reg_operand" "")
4120 (match_operand:SI 2 "reg_or_cint_operand" "")) 0))
4121 (const_int 0)))
4122 (set (match_operand:SI 0 "gpc_reg_operand" "")
4123 (zero_extend:SI (subreg:QI (rotate:SI (match_dup 1) (match_dup 2)) 0)))]
4124 "reload_completed"
4125 [(set (match_dup 0)
4126 (zero_extend:SI (subreg:QI (rotate:SI (match_dup 1) (match_dup 2)) 0)))
4127 (set (match_dup 3)
4128 (compare:CC (match_dup 0)
4129 (const_int 0)))]
4130 "")
1fd4e8c1 4131
a260abc9 4132(define_insn "*rotlsi3_internal10"
44cd321e 4133 [(set (match_operand:SI 0 "gpc_reg_operand" "=r,r")
1fd4e8c1
RK
4134 (zero_extend:SI
4135 (subreg:HI
44cd321e
PS
4136 (rotate:SI (match_operand:SI 1 "gpc_reg_operand" "r,r")
4137 (match_operand:SI 2 "reg_or_cint_operand" "r,i")) 0)))]
1fd4e8c1 4138 ""
44cd321e
PS
4139 "@
4140 {rlnm|rlwnm} %0,%1,%2,0xffff
4141 {rlinm|rlwinm} %0,%1,%h2,0xffff"
4142 [(set_attr "type" "var_shift_rotate,integer")])
4143
1fd4e8c1 4144
a260abc9 4145(define_insn "*rotlsi3_internal11"
44cd321e 4146 [(set (match_operand:CC 0 "cc_reg_operand" "=x,x,?y,?y")
1fd4e8c1
RK
4147 (compare:CC (zero_extend:SI
4148 (subreg:HI
44cd321e
PS
4149 (rotate:SI (match_operand:SI 1 "gpc_reg_operand" "r,r,r,r")
4150 (match_operand:SI 2 "reg_or_cint_operand" "r,i,r,i")) 0))
1fd4e8c1 4151 (const_int 0)))
44cd321e 4152 (clobber (match_scratch:SI 3 "=r,r,r,r"))]
1fd4e8c1 4153 ""
9ebbca7d 4154 "@
44cd321e
PS
4155 {rlnm.|rlwnm.} %3,%1,%2,0xffff
4156 {rlinm.|rlwinm.} %3,%1,%h2,0xffff
4157 #
9ebbca7d 4158 #"
44cd321e
PS
4159 [(set_attr "type" "var_delayed_compare,delayed_compare,var_delayed_compare,delayed_compare")
4160 (set_attr "length" "4,4,8,8")])
9ebbca7d
GK
4161
4162(define_split
4163 [(set (match_operand:CC 0 "cc_reg_not_cr0_operand" "")
4164 (compare:CC (zero_extend:SI
4165 (subreg:HI
4166 (rotate:SI (match_operand:SI 1 "gpc_reg_operand" "")
4167 (match_operand:SI 2 "reg_or_cint_operand" "")) 0))
4168 (const_int 0)))
4169 (clobber (match_scratch:SI 3 ""))]
4170 "reload_completed"
4171 [(set (match_dup 3)
4172 (zero_extend:SI (subreg:HI
4173 (rotate:SI (match_dup 1)
4174 (match_dup 2)) 0)))
4175 (set (match_dup 0)
4176 (compare:CC (match_dup 3)
4177 (const_int 0)))]
4178 "")
1fd4e8c1 4179
a260abc9 4180(define_insn "*rotlsi3_internal12"
44cd321e 4181 [(set (match_operand:CC 3 "cc_reg_operand" "=x,x,?y,?y")
1fd4e8c1
RK
4182 (compare:CC (zero_extend:SI
4183 (subreg:HI
44cd321e
PS
4184 (rotate:SI (match_operand:SI 1 "gpc_reg_operand" "r,r,r,r")
4185 (match_operand:SI 2 "reg_or_cint_operand" "r,i,r,i")) 0))
1fd4e8c1 4186 (const_int 0)))
44cd321e 4187 (set (match_operand:SI 0 "gpc_reg_operand" "=r,r,r,r")
1fd4e8c1
RK
4188 (zero_extend:SI (subreg:HI (rotate:SI (match_dup 1) (match_dup 2)) 0)))]
4189 ""
9ebbca7d 4190 "@
44cd321e
PS
4191 {rlnm.|rlwnm.} %0,%1,%2,0xffff
4192 {rlinm.|rlwinm.} %0,%1,%h2,0xffff
4193 #
9ebbca7d 4194 #"
44cd321e
PS
4195 [(set_attr "type" "var_delayed_compare,delayed_compare,var_delayed_compare,delayed_compare")
4196 (set_attr "length" "4,4,8,8")])
9ebbca7d
GK
4197
4198(define_split
4199 [(set (match_operand:CC 3 "cc_reg_not_cr0_operand" "")
4200 (compare:CC (zero_extend:SI
4201 (subreg:HI
4202 (rotate:SI (match_operand:SI 1 "gpc_reg_operand" "")
4203 (match_operand:SI 2 "reg_or_cint_operand" "")) 0))
4204 (const_int 0)))
4205 (set (match_operand:SI 0 "gpc_reg_operand" "")
4206 (zero_extend:SI (subreg:HI (rotate:SI (match_dup 1) (match_dup 2)) 0)))]
4207 "reload_completed"
4208 [(set (match_dup 0)
4209 (zero_extend:SI (subreg:HI (rotate:SI (match_dup 1) (match_dup 2)) 0)))
4210 (set (match_dup 3)
4211 (compare:CC (match_dup 0)
4212 (const_int 0)))]
4213 "")
1fd4e8c1
RK
4214
4215;; Note that we use "sle." instead of "sl." so that we can set
4216;; SHIFT_COUNT_TRUNCATED.
4217
ca7f5001
RK
4218(define_expand "ashlsi3"
4219 [(use (match_operand:SI 0 "gpc_reg_operand" ""))
4220 (use (match_operand:SI 1 "gpc_reg_operand" ""))
4221 (use (match_operand:SI 2 "reg_or_cint_operand" ""))]
4222 ""
4223 "
4224{
4225 if (TARGET_POWER)
4226 emit_insn (gen_ashlsi3_power (operands[0], operands[1], operands[2]));
4227 else
25c341fa 4228 emit_insn (gen_ashlsi3_no_power (operands[0], operands[1], operands[2]));
ca7f5001
RK
4229 DONE;
4230}")
4231
4232(define_insn "ashlsi3_power"
cd2b37d9
RK
4233 [(set (match_operand:SI 0 "gpc_reg_operand" "=r,r")
4234 (ashift:SI (match_operand:SI 1 "gpc_reg_operand" "r,r")
1fd4e8c1
RK
4235 (match_operand:SI 2 "reg_or_cint_operand" "r,i")))
4236 (clobber (match_scratch:SI 3 "=q,X"))]
ca7f5001 4237 "TARGET_POWER"
1fd4e8c1
RK
4238 "@
4239 sle %0,%1,%2
9ebbca7d 4240 {sli|slwi} %0,%1,%h2")
ca7f5001 4241
25c341fa 4242(define_insn "ashlsi3_no_power"
44cd321e
PS
4243 [(set (match_operand:SI 0 "gpc_reg_operand" "=r,r")
4244 (ashift:SI (match_operand:SI 1 "gpc_reg_operand" "r,r")
4245 (match_operand:SI 2 "reg_or_cint_operand" "r,i")))]
25c341fa 4246 "! TARGET_POWER"
44cd321e
PS
4247 "@
4248 {sl|slw} %0,%1,%2
4249 {sli|slwi} %0,%1,%h2"
4250 [(set_attr "type" "var_shift_rotate,shift")])
1fd4e8c1
RK
4251
4252(define_insn ""
9ebbca7d
GK
4253 [(set (match_operand:CC 0 "cc_reg_operand" "=x,x,?y,?y")
4254 (compare:CC (ashift:SI (match_operand:SI 1 "gpc_reg_operand" "r,r,r,r")
4255 (match_operand:SI 2 "reg_or_cint_operand" "r,i,r,i"))
1fd4e8c1 4256 (const_int 0)))
9ebbca7d
GK
4257 (clobber (match_scratch:SI 3 "=r,r,r,r"))
4258 (clobber (match_scratch:SI 4 "=q,X,q,X"))]
ca7f5001 4259 "TARGET_POWER"
1fd4e8c1
RK
4260 "@
4261 sle. %3,%1,%2
9ebbca7d
GK
4262 {sli.|slwi.} %3,%1,%h2
4263 #
4264 #"
4265 [(set_attr "type" "delayed_compare")
4266 (set_attr "length" "4,4,8,8")])
4267
4268(define_split
4269 [(set (match_operand:CC 0 "cc_reg_not_cr0_operand" "")
4270 (compare:CC (ashift:SI (match_operand:SI 1 "gpc_reg_operand" "")
4271 (match_operand:SI 2 "reg_or_cint_operand" ""))
4272 (const_int 0)))
4273 (clobber (match_scratch:SI 3 ""))
4274 (clobber (match_scratch:SI 4 ""))]
4275 "TARGET_POWER && reload_completed"
4276 [(parallel [(set (match_dup 3)
4277 (ashift:SI (match_dup 1) (match_dup 2)))
4278 (clobber (match_dup 4))])
4279 (set (match_dup 0)
4280 (compare:CC (match_dup 3)
4281 (const_int 0)))]
4282 "")
25c341fa 4283
ca7f5001 4284(define_insn ""
44cd321e
PS
4285 [(set (match_operand:CC 0 "cc_reg_operand" "=x,x,?y,?y")
4286 (compare:CC (ashift:SI (match_operand:SI 1 "gpc_reg_operand" "r,r,r,r")
4287 (match_operand:SI 2 "reg_or_cint_operand" "r,i,r,i"))
ca7f5001 4288 (const_int 0)))
44cd321e 4289 (clobber (match_scratch:SI 3 "=r,r,r,r"))]
4b8a63d6 4290 "! TARGET_POWER && TARGET_32BIT"
9ebbca7d 4291 "@
44cd321e
PS
4292 {sl.|slw.} %3,%1,%2
4293 {sli.|slwi.} %3,%1,%h2
4294 #
9ebbca7d 4295 #"
44cd321e
PS
4296 [(set_attr "type" "var_delayed_compare,delayed_compare,var_delayed_compare,delayed_compare")
4297 (set_attr "length" "4,4,8,8")])
9ebbca7d
GK
4298
4299(define_split
4300 [(set (match_operand:CC 0 "cc_reg_not_cr0_operand" "")
4301 (compare:CC (ashift:SI (match_operand:SI 1 "gpc_reg_operand" "")
4302 (match_operand:SI 2 "reg_or_cint_operand" ""))
4303 (const_int 0)))
4304 (clobber (match_scratch:SI 3 ""))]
4b8a63d6 4305 "! TARGET_POWER && TARGET_32BIT && reload_completed"
9ebbca7d
GK
4306 [(set (match_dup 3)
4307 (ashift:SI (match_dup 1) (match_dup 2)))
4308 (set (match_dup 0)
4309 (compare:CC (match_dup 3)
4310 (const_int 0)))]
4311 "")
1fd4e8c1
RK
4312
4313(define_insn ""
9ebbca7d
GK
4314 [(set (match_operand:CC 3 "cc_reg_operand" "=x,x,?y,?y")
4315 (compare:CC (ashift:SI (match_operand:SI 1 "gpc_reg_operand" "r,r,r,r")
4316 (match_operand:SI 2 "reg_or_cint_operand" "r,i,r,i"))
1fd4e8c1 4317 (const_int 0)))
9ebbca7d 4318 (set (match_operand:SI 0 "gpc_reg_operand" "=r,r,r,r")
1fd4e8c1 4319 (ashift:SI (match_dup 1) (match_dup 2)))
9ebbca7d 4320 (clobber (match_scratch:SI 4 "=q,X,q,X"))]
ca7f5001 4321 "TARGET_POWER"
1fd4e8c1
RK
4322 "@
4323 sle. %0,%1,%2
9ebbca7d
GK
4324 {sli.|slwi.} %0,%1,%h2
4325 #
4326 #"
4327 [(set_attr "type" "delayed_compare")
4328 (set_attr "length" "4,4,8,8")])
4329
4330(define_split
4331 [(set (match_operand:CC 3 "cc_reg_not_cr0_operand" "")
4332 (compare:CC (ashift:SI (match_operand:SI 1 "gpc_reg_operand" "")
4333 (match_operand:SI 2 "reg_or_cint_operand" ""))
4334 (const_int 0)))
4335 (set (match_operand:SI 0 "gpc_reg_operand" "")
4336 (ashift:SI (match_dup 1) (match_dup 2)))
4337 (clobber (match_scratch:SI 4 ""))]
4338 "TARGET_POWER && reload_completed"
4339 [(parallel [(set (match_dup 0)
4340 (ashift:SI (match_dup 1) (match_dup 2)))
4341 (clobber (match_dup 4))])
4342 (set (match_dup 3)
4343 (compare:CC (match_dup 0)
4344 (const_int 0)))]
4345 "")
25c341fa 4346
ca7f5001 4347(define_insn ""
44cd321e
PS
4348 [(set (match_operand:CC 3 "cc_reg_operand" "=x,x,?y,?y")
4349 (compare:CC (ashift:SI (match_operand:SI 1 "gpc_reg_operand" "r,r,r,r")
4350 (match_operand:SI 2 "reg_or_cint_operand" "r,i,r,i"))
ca7f5001 4351 (const_int 0)))
44cd321e 4352 (set (match_operand:SI 0 "gpc_reg_operand" "=r,r,r,r")
ca7f5001 4353 (ashift:SI (match_dup 1) (match_dup 2)))]
4b8a63d6 4354 "! TARGET_POWER && TARGET_32BIT"
9ebbca7d 4355 "@
44cd321e
PS
4356 {sl.|slw.} %0,%1,%2
4357 {sli.|slwi.} %0,%1,%h2
4358 #
9ebbca7d 4359 #"
44cd321e
PS
4360 [(set_attr "type" "var_delayed_compare,delayed_compare,var_delayed_compare,delayed_compare")
4361 (set_attr "length" "4,4,8,8")])
9ebbca7d
GK
4362
4363(define_split
4364 [(set (match_operand:CC 3 "cc_reg_not_cr0_operand" "")
4365 (compare:CC (ashift:SI (match_operand:SI 1 "gpc_reg_operand" "")
4366 (match_operand:SI 2 "reg_or_cint_operand" ""))
4367 (const_int 0)))
4368 (set (match_operand:SI 0 "gpc_reg_operand" "")
4369 (ashift:SI (match_dup 1) (match_dup 2)))]
4b8a63d6 4370 "! TARGET_POWER && TARGET_32BIT && reload_completed"
9ebbca7d
GK
4371 [(set (match_dup 0)
4372 (ashift:SI (match_dup 1) (match_dup 2)))
4373 (set (match_dup 3)
4374 (compare:CC (match_dup 0)
4375 (const_int 0)))]
4376 "")
1fd4e8c1 4377
915167f5 4378(define_insn "rlwinm"
cd2b37d9
RK
4379 [(set (match_operand:SI 0 "gpc_reg_operand" "=r")
4380 (and:SI (ashift:SI (match_operand:SI 1 "gpc_reg_operand" "r")
1fd4e8c1 4381 (match_operand:SI 2 "const_int_operand" "i"))
ce71f754 4382 (match_operand:SI 3 "mask_operand" "n")))]
1fd4e8c1 4383 "includes_lshift_p (operands[2], operands[3])"
d56d506a 4384 "{rlinm|rlwinm} %0,%1,%h2,%m3,%M3")
1fd4e8c1
RK
4385
4386(define_insn ""
9ebbca7d 4387 [(set (match_operand:CC 0 "cc_reg_operand" "=x,?y")
1fd4e8c1 4388 (compare:CC
9ebbca7d
GK
4389 (and:SI (ashift:SI (match_operand:SI 1 "gpc_reg_operand" "r,r")
4390 (match_operand:SI 2 "const_int_operand" "i,i"))
ce71f754 4391 (match_operand:SI 3 "mask_operand" "n,n"))
1fd4e8c1 4392 (const_int 0)))
9ebbca7d 4393 (clobber (match_scratch:SI 4 "=r,r"))]
ce71f754 4394 "includes_lshift_p (operands[2], operands[3])"
9ebbca7d
GK
4395 "@
4396 {rlinm.|rlwinm.} %4,%1,%h2,%m3,%M3
4397 #"
4398 [(set_attr "type" "delayed_compare")
4399 (set_attr "length" "4,8")])
4400
4401(define_split
4402 [(set (match_operand:CC 0 "cc_reg_not_cr0_operand" "")
4403 (compare:CC
4404 (and:SI (ashift:SI (match_operand:SI 1 "gpc_reg_operand" "")
4405 (match_operand:SI 2 "const_int_operand" ""))
4406 (match_operand:SI 3 "mask_operand" ""))
4407 (const_int 0)))
4408 (clobber (match_scratch:SI 4 ""))]
ce71f754 4409 "includes_lshift_p (operands[2], operands[3]) && reload_completed"
9ebbca7d
GK
4410 [(set (match_dup 4)
4411 (and:SI (ashift:SI (match_dup 1) (match_dup 2))
4412 (match_dup 3)))
4413 (set (match_dup 0)
4414 (compare:CC (match_dup 4)
4415 (const_int 0)))]
4416 "")
1fd4e8c1
RK
4417
4418(define_insn ""
9ebbca7d 4419 [(set (match_operand:CC 4 "cc_reg_operand" "=x,?y")
1fd4e8c1 4420 (compare:CC
9ebbca7d
GK
4421 (and:SI (ashift:SI (match_operand:SI 1 "gpc_reg_operand" "r,r")
4422 (match_operand:SI 2 "const_int_operand" "i,i"))
ce71f754 4423 (match_operand:SI 3 "mask_operand" "n,n"))
1fd4e8c1 4424 (const_int 0)))
9ebbca7d 4425 (set (match_operand:SI 0 "gpc_reg_operand" "=r,r")
1fd4e8c1 4426 (and:SI (ashift:SI (match_dup 1) (match_dup 2)) (match_dup 3)))]
ce71f754 4427 "includes_lshift_p (operands[2], operands[3])"
9ebbca7d
GK
4428 "@
4429 {rlinm.|rlwinm.} %0,%1,%h2,%m3,%M3
4430 #"
4431 [(set_attr "type" "delayed_compare")
4432 (set_attr "length" "4,8")])
4433
4434(define_split
4435 [(set (match_operand:CC 4 "cc_reg_not_cr0_operand" "")
4436 (compare:CC
4437 (and:SI (ashift:SI (match_operand:SI 1 "gpc_reg_operand" "")
4438 (match_operand:SI 2 "const_int_operand" ""))
4439 (match_operand:SI 3 "mask_operand" ""))
4440 (const_int 0)))
4441 (set (match_operand:SI 0 "gpc_reg_operand" "")
4442 (and:SI (ashift:SI (match_dup 1) (match_dup 2)) (match_dup 3)))]
ce71f754 4443 "includes_lshift_p (operands[2], operands[3]) && reload_completed"
9ebbca7d
GK
4444 [(set (match_dup 0)
4445 (and:SI (ashift:SI (match_dup 1) (match_dup 2)) (match_dup 3)))
4446 (set (match_dup 4)
4447 (compare:CC (match_dup 0)
4448 (const_int 0)))]
4449 "")
1fd4e8c1 4450
ca7f5001 4451;; The AIX assembler mis-handles "sri x,x,0", so write that case as
5c23c401 4452;; "sli x,x,0".
ca7f5001
RK
4453(define_expand "lshrsi3"
4454 [(use (match_operand:SI 0 "gpc_reg_operand" ""))
4455 (use (match_operand:SI 1 "gpc_reg_operand" ""))
4456 (use (match_operand:SI 2 "reg_or_cint_operand" ""))]
4457 ""
4458 "
4459{
4460 if (TARGET_POWER)
4461 emit_insn (gen_lshrsi3_power (operands[0], operands[1], operands[2]));
4462 else
25c341fa 4463 emit_insn (gen_lshrsi3_no_power (operands[0], operands[1], operands[2]));
ca7f5001
RK
4464 DONE;
4465}")
4466
4467(define_insn "lshrsi3_power"
bdf423cb
MM
4468 [(set (match_operand:SI 0 "gpc_reg_operand" "=r,r,r")
4469 (lshiftrt:SI (match_operand:SI 1 "gpc_reg_operand" "r,r,r")
4470 (match_operand:SI 2 "reg_or_cint_operand" "r,O,i")))
4471 (clobber (match_scratch:SI 3 "=q,X,X"))]
ca7f5001 4472 "TARGET_POWER"
1fd4e8c1
RK
4473 "@
4474 sre %0,%1,%2
bdf423cb 4475 mr %0,%1
ca7f5001
RK
4476 {s%A2i|s%A2wi} %0,%1,%h2")
4477
25c341fa 4478(define_insn "lshrsi3_no_power"
44cd321e
PS
4479 [(set (match_operand:SI 0 "gpc_reg_operand" "=r,r,r")
4480 (lshiftrt:SI (match_operand:SI 1 "gpc_reg_operand" "r,r,r")
4481 (match_operand:SI 2 "reg_or_cint_operand" "O,r,i")))]
25c341fa 4482 "! TARGET_POWER"
bdf423cb
MM
4483 "@
4484 mr %0,%1
44cd321e
PS
4485 {sr|srw} %0,%1,%2
4486 {sri|srwi} %0,%1,%h2"
4487 [(set_attr "type" "integer,var_shift_rotate,shift")])
1fd4e8c1
RK
4488
4489(define_insn ""
9ebbca7d
GK
4490 [(set (match_operand:CC 0 "cc_reg_operand" "=x,x,x,?y,?y,?y")
4491 (compare:CC (lshiftrt:SI (match_operand:SI 1 "gpc_reg_operand" "r,r,r,r,r,r")
4492 (match_operand:SI 2 "reg_or_cint_operand" "r,O,i,r,O,i"))
1fd4e8c1 4493 (const_int 0)))
9ebbca7d
GK
4494 (clobber (match_scratch:SI 3 "=r,X,r,r,X,r"))
4495 (clobber (match_scratch:SI 4 "=q,X,X,q,X,X"))]
ca7f5001 4496 "TARGET_POWER"
1fd4e8c1 4497 "@
29ae5b89
JL
4498 sre. %3,%1,%2
4499 mr. %1,%1
9ebbca7d
GK
4500 {s%A2i.|s%A2wi.} %3,%1,%h2
4501 #
4502 #
4503 #"
4504 [(set_attr "type" "delayed_compare")
4505 (set_attr "length" "4,4,4,8,8,8")])
4506
4507(define_split
4508 [(set (match_operand:CC 0 "cc_reg_not_cr0_operand" "")
4509 (compare:CC (lshiftrt:SI (match_operand:SI 1 "gpc_reg_operand" "")
4510 (match_operand:SI 2 "reg_or_cint_operand" ""))
4511 (const_int 0)))
4512 (clobber (match_scratch:SI 3 ""))
4513 (clobber (match_scratch:SI 4 ""))]
4514 "TARGET_POWER && reload_completed"
4515 [(parallel [(set (match_dup 3)
4516 (lshiftrt:SI (match_dup 1) (match_dup 2)))
4517 (clobber (match_dup 4))])
4518 (set (match_dup 0)
4519 (compare:CC (match_dup 3)
4520 (const_int 0)))]
4521 "")
ca7f5001
RK
4522
4523(define_insn ""
44cd321e
PS
4524 [(set (match_operand:CC 0 "cc_reg_operand" "=x,x,x,?y,?y,?y")
4525 (compare:CC (lshiftrt:SI (match_operand:SI 1 "gpc_reg_operand" "r,r,r,r,r,r")
4526 (match_operand:SI 2 "reg_or_cint_operand" "O,r,i,O,r,i"))
ca7f5001 4527 (const_int 0)))
44cd321e 4528 (clobber (match_scratch:SI 3 "=X,r,r,X,r,r"))]
4b8a63d6 4529 "! TARGET_POWER && TARGET_32BIT"
bdf423cb
MM
4530 "@
4531 mr. %1,%1
44cd321e
PS
4532 {sr.|srw.} %3,%1,%2
4533 {sri.|srwi.} %3,%1,%h2
4534 #
9ebbca7d
GK
4535 #
4536 #"
44cd321e
PS
4537 [(set_attr "type" "delayed_compare,var_delayed_compare,delayed_compare,delayed_compare,var_delayed_compare,delayed_compare")
4538 (set_attr "length" "4,4,4,8,8,8")])
1fd4e8c1 4539
9ebbca7d
GK
4540(define_split
4541 [(set (match_operand:CC 0 "cc_reg_not_cr0_operand" "")
4542 (compare:CC (lshiftrt:SI (match_operand:SI 1 "gpc_reg_operand" "")
4543 (match_operand:SI 2 "reg_or_cint_operand" ""))
4544 (const_int 0)))
4545 (clobber (match_scratch:SI 3 ""))]
4b8a63d6 4546 "! TARGET_POWER && TARGET_32BIT && reload_completed"
9ebbca7d
GK
4547 [(set (match_dup 3)
4548 (lshiftrt:SI (match_dup 1) (match_dup 2)))
4549 (set (match_dup 0)
4550 (compare:CC (match_dup 3)
4551 (const_int 0)))]
4552 "")
4553
4554(define_insn ""
4555 [(set (match_operand:CC 3 "cc_reg_operand" "=x,x,x,?y,?y,?y")
4556 (compare:CC (lshiftrt:SI (match_operand:SI 1 "gpc_reg_operand" "r,r,r,r,r,r")
4557 (match_operand:SI 2 "reg_or_cint_operand" "r,O,i,r,O,i"))
1fd4e8c1 4558 (const_int 0)))
9ebbca7d 4559 (set (match_operand:SI 0 "gpc_reg_operand" "=r,r,r,r,r,r")
1fd4e8c1 4560 (lshiftrt:SI (match_dup 1) (match_dup 2)))
9ebbca7d 4561 (clobber (match_scratch:SI 4 "=q,X,X,q,X,X"))]
ca7f5001 4562 "TARGET_POWER"
1fd4e8c1 4563 "@
29ae5b89
JL
4564 sre. %0,%1,%2
4565 mr. %0,%1
9ebbca7d
GK
4566 {s%A2i.|s%A2wi.} %0,%1,%h2
4567 #
4568 #
4569 #"
4570 [(set_attr "type" "delayed_compare")
4571 (set_attr "length" "4,4,4,8,8,8")])
4572
4573(define_split
4574 [(set (match_operand:CC 3 "cc_reg_not_cr0_operand" "")
4575 (compare:CC (lshiftrt:SI (match_operand:SI 1 "gpc_reg_operand" "")
4576 (match_operand:SI 2 "reg_or_cint_operand" ""))
4577 (const_int 0)))
4578 (set (match_operand:SI 0 "gpc_reg_operand" "")
4579 (lshiftrt:SI (match_dup 1) (match_dup 2)))
4580 (clobber (match_scratch:SI 4 ""))]
4581 "TARGET_POWER && reload_completed"
4582 [(parallel [(set (match_dup 0)
4583 (lshiftrt:SI (match_dup 1) (match_dup 2)))
4584 (clobber (match_dup 4))])
4585 (set (match_dup 3)
4586 (compare:CC (match_dup 0)
4587 (const_int 0)))]
4588 "")
ca7f5001
RK
4589
4590(define_insn ""
44cd321e
PS
4591 [(set (match_operand:CC 3 "cc_reg_operand" "=x,x,x,?y,?y,?y")
4592 (compare:CC (lshiftrt:SI (match_operand:SI 1 "gpc_reg_operand" "r,r,r,r,r,r")
4593 (match_operand:SI 2 "reg_or_cint_operand" "O,r,i,O,r,i"))
815cdc52 4594 (const_int 0)))
44cd321e 4595 (set (match_operand:SI 0 "gpc_reg_operand" "=r,r,r,r,r,r")
29ae5b89 4596 (lshiftrt:SI (match_dup 1) (match_dup 2)))]
4b8a63d6 4597 "! TARGET_POWER && TARGET_32BIT"
29ae5b89
JL
4598 "@
4599 mr. %0,%1
44cd321e
PS
4600 {sr.|srw.} %0,%1,%2
4601 {sri.|srwi.} %0,%1,%h2
4602 #
9ebbca7d
GK
4603 #
4604 #"
44cd321e
PS
4605 [(set_attr "type" "delayed_compare,var_delayed_compare,delayed_compare,delayed_compare,var_delayed_compare,delayed_compare")
4606 (set_attr "length" "4,4,4,8,8,8")])
9ebbca7d
GK
4607
4608(define_split
4609 [(set (match_operand:CC 3 "cc_reg_not_cr0_operand" "")
4610 (compare:CC (lshiftrt:SI (match_operand:SI 1 "gpc_reg_operand" "")
4611 (match_operand:SI 2 "reg_or_cint_operand" ""))
4612 (const_int 0)))
4613 (set (match_operand:SI 0 "gpc_reg_operand" "")
4614 (lshiftrt:SI (match_dup 1) (match_dup 2)))]
4b8a63d6 4615 "! TARGET_POWER && TARGET_32BIT && reload_completed"
9ebbca7d
GK
4616 [(set (match_dup 0)
4617 (lshiftrt:SI (match_dup 1) (match_dup 2)))
4618 (set (match_dup 3)
4619 (compare:CC (match_dup 0)
4620 (const_int 0)))]
4621 "")
1fd4e8c1
RK
4622
4623(define_insn ""
cd2b37d9
RK
4624 [(set (match_operand:SI 0 "gpc_reg_operand" "=r")
4625 (and:SI (lshiftrt:SI (match_operand:SI 1 "gpc_reg_operand" "r")
1fd4e8c1 4626 (match_operand:SI 2 "const_int_operand" "i"))
ce71f754 4627 (match_operand:SI 3 "mask_operand" "n")))]
1fd4e8c1 4628 "includes_rshift_p (operands[2], operands[3])"
ca7f5001 4629 "{rlinm|rlwinm} %0,%1,%s2,%m3,%M3")
1fd4e8c1
RK
4630
4631(define_insn ""
9ebbca7d 4632 [(set (match_operand:CC 0 "cc_reg_operand" "=x,?y")
1fd4e8c1 4633 (compare:CC
9ebbca7d
GK
4634 (and:SI (lshiftrt:SI (match_operand:SI 1 "gpc_reg_operand" "r,r")
4635 (match_operand:SI 2 "const_int_operand" "i,i"))
ce71f754 4636 (match_operand:SI 3 "mask_operand" "n,n"))
1fd4e8c1 4637 (const_int 0)))
9ebbca7d 4638 (clobber (match_scratch:SI 4 "=r,r"))]
ce71f754 4639 "includes_rshift_p (operands[2], operands[3])"
9ebbca7d
GK
4640 "@
4641 {rlinm.|rlwinm.} %4,%1,%s2,%m3,%M3
4642 #"
4643 [(set_attr "type" "delayed_compare")
4644 (set_attr "length" "4,8")])
4645
4646(define_split
4647 [(set (match_operand:CC 0 "cc_reg_not_cr0_operand" "")
4648 (compare:CC
4649 (and:SI (lshiftrt:SI (match_operand:SI 1 "gpc_reg_operand" "")
4650 (match_operand:SI 2 "const_int_operand" ""))
4651 (match_operand:SI 3 "mask_operand" ""))
4652 (const_int 0)))
4653 (clobber (match_scratch:SI 4 ""))]
ce71f754 4654 "includes_rshift_p (operands[2], operands[3]) && reload_completed"
9ebbca7d
GK
4655 [(set (match_dup 4)
4656 (and:SI (lshiftrt:SI (match_dup 1) (match_dup 2))
4657 (match_dup 3)))
4658 (set (match_dup 0)
4659 (compare:CC (match_dup 4)
4660 (const_int 0)))]
4661 "")
1fd4e8c1
RK
4662
4663(define_insn ""
9ebbca7d 4664 [(set (match_operand:CC 4 "cc_reg_operand" "=x,?y")
1fd4e8c1 4665 (compare:CC
9ebbca7d
GK
4666 (and:SI (lshiftrt:SI (match_operand:SI 1 "gpc_reg_operand" "r,r")
4667 (match_operand:SI 2 "const_int_operand" "i,i"))
ce71f754 4668 (match_operand:SI 3 "mask_operand" "n,n"))
1fd4e8c1 4669 (const_int 0)))
9ebbca7d 4670 (set (match_operand:SI 0 "gpc_reg_operand" "=r,r")
1fd4e8c1 4671 (and:SI (lshiftrt:SI (match_dup 1) (match_dup 2)) (match_dup 3)))]
ce71f754 4672 "includes_rshift_p (operands[2], operands[3])"
9ebbca7d
GK
4673 "@
4674 {rlinm.|rlwinm.} %0,%1,%s2,%m3,%M3
4675 #"
4676 [(set_attr "type" "delayed_compare")
4677 (set_attr "length" "4,8")])
4678
4679(define_split
4680 [(set (match_operand:CC 4 "cc_reg_not_cr0_operand" "")
4681 (compare:CC
4682 (and:SI (lshiftrt:SI (match_operand:SI 1 "gpc_reg_operand" "")
4683 (match_operand:SI 2 "const_int_operand" ""))
4684 (match_operand:SI 3 "mask_operand" ""))
4685 (const_int 0)))
4686 (set (match_operand:SI 0 "gpc_reg_operand" "")
4687 (and:SI (lshiftrt:SI (match_dup 1) (match_dup 2)) (match_dup 3)))]
ce71f754 4688 "includes_rshift_p (operands[2], operands[3]) && reload_completed"
9ebbca7d
GK
4689 [(set (match_dup 0)
4690 (and:SI (lshiftrt:SI (match_dup 1) (match_dup 2)) (match_dup 3)))
4691 (set (match_dup 4)
4692 (compare:CC (match_dup 0)
4693 (const_int 0)))]
4694 "")
1fd4e8c1
RK
4695
4696(define_insn ""
cd2b37d9 4697 [(set (match_operand:SI 0 "gpc_reg_operand" "=r")
1fd4e8c1
RK
4698 (zero_extend:SI
4699 (subreg:QI
cd2b37d9 4700 (lshiftrt:SI (match_operand:SI 1 "gpc_reg_operand" "r")
1fd4e8c1 4701 (match_operand:SI 2 "const_int_operand" "i")) 0)))]
89e9f3a8 4702 "includes_rshift_p (operands[2], GEN_INT (255))"
ca7f5001 4703 "{rlinm|rlwinm} %0,%1,%s2,0xff")
1fd4e8c1
RK
4704
4705(define_insn ""
9ebbca7d 4706 [(set (match_operand:CC 0 "cc_reg_operand" "=x,?y")
1fd4e8c1
RK
4707 (compare:CC
4708 (zero_extend:SI
4709 (subreg:QI
9ebbca7d
GK
4710 (lshiftrt:SI (match_operand:SI 1 "gpc_reg_operand" "r,r")
4711 (match_operand:SI 2 "const_int_operand" "i,i")) 0))
1fd4e8c1 4712 (const_int 0)))
9ebbca7d 4713 (clobber (match_scratch:SI 3 "=r,r"))]
89e9f3a8 4714 "includes_rshift_p (operands[2], GEN_INT (255))"
9ebbca7d
GK
4715 "@
4716 {rlinm.|rlwinm.} %3,%1,%s2,0xff
4717 #"
4718 [(set_attr "type" "delayed_compare")
4719 (set_attr "length" "4,8")])
4720
4721(define_split
4722 [(set (match_operand:CC 0 "cc_reg_not_cr0_operand" "")
4723 (compare:CC
4724 (zero_extend:SI
4725 (subreg:QI
4726 (lshiftrt:SI (match_operand:SI 1 "gpc_reg_operand" "")
4727 (match_operand:SI 2 "const_int_operand" "")) 0))
4728 (const_int 0)))
4729 (clobber (match_scratch:SI 3 ""))]
4730 "includes_rshift_p (operands[2], GEN_INT (255)) && reload_completed"
4731 [(set (match_dup 3)
4732 (zero_extend:SI (subreg:QI
4733 (lshiftrt:SI (match_dup 1)
4734 (match_dup 2)) 0)))
4735 (set (match_dup 0)
4736 (compare:CC (match_dup 3)
4737 (const_int 0)))]
4738 "")
1fd4e8c1
RK
4739
4740(define_insn ""
9ebbca7d 4741 [(set (match_operand:CC 3 "cc_reg_operand" "=x,?y")
1fd4e8c1
RK
4742 (compare:CC
4743 (zero_extend:SI
4744 (subreg:QI
9ebbca7d
GK
4745 (lshiftrt:SI (match_operand:SI 1 "gpc_reg_operand" "r,r")
4746 (match_operand:SI 2 "const_int_operand" "i,i")) 0))
1fd4e8c1 4747 (const_int 0)))
9ebbca7d 4748 (set (match_operand:SI 0 "gpc_reg_operand" "=r,r")
1fd4e8c1 4749 (zero_extend:SI (subreg:QI (lshiftrt:SI (match_dup 1) (match_dup 2)) 0)))]
89e9f3a8 4750 "includes_rshift_p (operands[2], GEN_INT (255))"
9ebbca7d
GK
4751 "@
4752 {rlinm.|rlwinm.} %0,%1,%s2,0xff
4753 #"
4754 [(set_attr "type" "delayed_compare")
4755 (set_attr "length" "4,8")])
4756
4757(define_split
4758 [(set (match_operand:CC 3 "cc_reg_not_cr0_operand" "")
4759 (compare:CC
4760 (zero_extend:SI
4761 (subreg:QI
4762 (lshiftrt:SI (match_operand:SI 1 "gpc_reg_operand" "")
4763 (match_operand:SI 2 "const_int_operand" "")) 0))
4764 (const_int 0)))
4765 (set (match_operand:SI 0 "gpc_reg_operand" "")
4766 (zero_extend:SI (subreg:QI (lshiftrt:SI (match_dup 1) (match_dup 2)) 0)))]
4767 "includes_rshift_p (operands[2], GEN_INT (255)) && reload_completed"
4768 [(set (match_dup 0)
4769 (zero_extend:SI (subreg:QI (lshiftrt:SI (match_dup 1) (match_dup 2)) 0)))
4770 (set (match_dup 3)
4771 (compare:CC (match_dup 0)
4772 (const_int 0)))]
4773 "")
1fd4e8c1
RK
4774
4775(define_insn ""
cd2b37d9 4776 [(set (match_operand:SI 0 "gpc_reg_operand" "=r")
1fd4e8c1
RK
4777 (zero_extend:SI
4778 (subreg:HI
cd2b37d9 4779 (lshiftrt:SI (match_operand:SI 1 "gpc_reg_operand" "r")
1fd4e8c1 4780 (match_operand:SI 2 "const_int_operand" "i")) 0)))]
89e9f3a8 4781 "includes_rshift_p (operands[2], GEN_INT (65535))"
ca7f5001 4782 "{rlinm|rlwinm} %0,%1,%s2,0xffff")
1fd4e8c1
RK
4783
4784(define_insn ""
9ebbca7d 4785 [(set (match_operand:CC 0 "cc_reg_operand" "=x,?y")
1fd4e8c1
RK
4786 (compare:CC
4787 (zero_extend:SI
4788 (subreg:HI
9ebbca7d
GK
4789 (lshiftrt:SI (match_operand:SI 1 "gpc_reg_operand" "r,r")
4790 (match_operand:SI 2 "const_int_operand" "i,i")) 0))
1fd4e8c1 4791 (const_int 0)))
9ebbca7d 4792 (clobber (match_scratch:SI 3 "=r,r"))]
89e9f3a8 4793 "includes_rshift_p (operands[2], GEN_INT (65535))"
9ebbca7d
GK
4794 "@
4795 {rlinm.|rlwinm.} %3,%1,%s2,0xffff
4796 #"
4797 [(set_attr "type" "delayed_compare")
4798 (set_attr "length" "4,8")])
4799
4800(define_split
4801 [(set (match_operand:CC 0 "cc_reg_not_cr0_operand" "")
4802 (compare:CC
4803 (zero_extend:SI
4804 (subreg:HI
4805 (lshiftrt:SI (match_operand:SI 1 "gpc_reg_operand" "")
4806 (match_operand:SI 2 "const_int_operand" "")) 0))
4807 (const_int 0)))
4808 (clobber (match_scratch:SI 3 ""))]
4809 "includes_rshift_p (operands[2], GEN_INT (65535)) && reload_completed"
4810 [(set (match_dup 3)
4811 (zero_extend:SI (subreg:HI
4812 (lshiftrt:SI (match_dup 1)
4813 (match_dup 2)) 0)))
4814 (set (match_dup 0)
4815 (compare:CC (match_dup 3)
4816 (const_int 0)))]
4817 "")
1fd4e8c1
RK
4818
4819(define_insn ""
9ebbca7d 4820 [(set (match_operand:CC 3 "cc_reg_operand" "=x,?y")
1fd4e8c1
RK
4821 (compare:CC
4822 (zero_extend:SI
4823 (subreg:HI
9ebbca7d
GK
4824 (lshiftrt:SI (match_operand:SI 1 "gpc_reg_operand" "r,r")
4825 (match_operand:SI 2 "const_int_operand" "i,i")) 0))
1fd4e8c1 4826 (const_int 0)))
9ebbca7d 4827 (set (match_operand:SI 0 "gpc_reg_operand" "=r,r")
1fd4e8c1 4828 (zero_extend:SI (subreg:HI (lshiftrt:SI (match_dup 1) (match_dup 2)) 0)))]
89e9f3a8 4829 "includes_rshift_p (operands[2], GEN_INT (65535))"
9ebbca7d
GK
4830 "@
4831 {rlinm.|rlwinm.} %0,%1,%s2,0xffff
4832 #"
4833 [(set_attr "type" "delayed_compare")
4834 (set_attr "length" "4,8")])
4835
4836(define_split
4837 [(set (match_operand:CC 3 "cc_reg_not_cr0_operand" "")
4838 (compare:CC
4839 (zero_extend:SI
4840 (subreg:HI
4841 (lshiftrt:SI (match_operand:SI 1 "gpc_reg_operand" "")
4842 (match_operand:SI 2 "const_int_operand" "")) 0))
4843 (const_int 0)))
4844 (set (match_operand:SI 0 "gpc_reg_operand" "")
4845 (zero_extend:SI (subreg:HI (lshiftrt:SI (match_dup 1) (match_dup 2)) 0)))]
4846 "includes_rshift_p (operands[2], GEN_INT (65535)) && reload_completed"
4847 [(set (match_dup 0)
4848 (zero_extend:SI (subreg:HI (lshiftrt:SI (match_dup 1) (match_dup 2)) 0)))
4849 (set (match_dup 3)
4850 (compare:CC (match_dup 0)
4851 (const_int 0)))]
4852 "")
1fd4e8c1
RK
4853
4854(define_insn ""
cd2b37d9 4855 [(set (zero_extract:SI (match_operand:SI 0 "gpc_reg_operand" "+r")
1fd4e8c1 4856 (const_int 1)
cd2b37d9
RK
4857 (match_operand:SI 1 "gpc_reg_operand" "r"))
4858 (ashiftrt:SI (match_operand:SI 2 "gpc_reg_operand" "r")
1fd4e8c1 4859 (const_int 31)))]
ca7f5001 4860 "TARGET_POWER"
1fd4e8c1
RK
4861 "rrib %0,%1,%2")
4862
4863(define_insn ""
cd2b37d9 4864 [(set (zero_extract:SI (match_operand:SI 0 "gpc_reg_operand" "+r")
1fd4e8c1 4865 (const_int 1)
cd2b37d9
RK
4866 (match_operand:SI 1 "gpc_reg_operand" "r"))
4867 (lshiftrt:SI (match_operand:SI 2 "gpc_reg_operand" "r")
1fd4e8c1 4868 (const_int 31)))]
ca7f5001 4869 "TARGET_POWER"
1fd4e8c1
RK
4870 "rrib %0,%1,%2")
4871
4872(define_insn ""
cd2b37d9 4873 [(set (zero_extract:SI (match_operand:SI 0 "gpc_reg_operand" "+r")
1fd4e8c1 4874 (const_int 1)
cd2b37d9
RK
4875 (match_operand:SI 1 "gpc_reg_operand" "r"))
4876 (zero_extract:SI (match_operand:SI 2 "gpc_reg_operand" "r")
1fd4e8c1
RK
4877 (const_int 1)
4878 (const_int 0)))]
ca7f5001 4879 "TARGET_POWER"
1fd4e8c1
RK
4880 "rrib %0,%1,%2")
4881
ca7f5001
RK
4882(define_expand "ashrsi3"
4883 [(set (match_operand:SI 0 "gpc_reg_operand" "")
4884 (ashiftrt:SI (match_operand:SI 1 "gpc_reg_operand" "")
4885 (match_operand:SI 2 "reg_or_cint_operand" "")))]
4886 ""
4887 "
4888{
4889 if (TARGET_POWER)
4890 emit_insn (gen_ashrsi3_power (operands[0], operands[1], operands[2]));
4891 else
25c341fa 4892 emit_insn (gen_ashrsi3_no_power (operands[0], operands[1], operands[2]));
ca7f5001
RK
4893 DONE;
4894}")
4895
4896(define_insn "ashrsi3_power"
cd2b37d9
RK
4897 [(set (match_operand:SI 0 "gpc_reg_operand" "=r,r")
4898 (ashiftrt:SI (match_operand:SI 1 "gpc_reg_operand" "r,r")
1fd4e8c1
RK
4899 (match_operand:SI 2 "reg_or_cint_operand" "r,i")))
4900 (clobber (match_scratch:SI 3 "=q,X"))]
ca7f5001 4901 "TARGET_POWER"
1fd4e8c1
RK
4902 "@
4903 srea %0,%1,%2
44cd321e
PS
4904 {srai|srawi} %0,%1,%h2"
4905 [(set_attr "type" "shift")])
ca7f5001 4906
25c341fa 4907(define_insn "ashrsi3_no_power"
44cd321e
PS
4908 [(set (match_operand:SI 0 "gpc_reg_operand" "=r,r")
4909 (ashiftrt:SI (match_operand:SI 1 "gpc_reg_operand" "r,r")
4910 (match_operand:SI 2 "reg_or_cint_operand" "r,i")))]
25c341fa 4911 "! TARGET_POWER"
44cd321e
PS
4912 "@
4913 {sra|sraw} %0,%1,%2
4914 {srai|srawi} %0,%1,%h2"
4915 [(set_attr "type" "var_shift_rotate,shift")])
1fd4e8c1
RK
4916
4917(define_insn ""
9ebbca7d
GK
4918 [(set (match_operand:CC 0 "cc_reg_operand" "=x,x,?y,?y")
4919 (compare:CC (ashiftrt:SI (match_operand:SI 1 "gpc_reg_operand" "r,r,r,r")
4920 (match_operand:SI 2 "reg_or_cint_operand" "r,i,r,i"))
1fd4e8c1 4921 (const_int 0)))
9ebbca7d
GK
4922 (clobber (match_scratch:SI 3 "=r,r,r,r"))
4923 (clobber (match_scratch:SI 4 "=q,X,q,X"))]
ca7f5001 4924 "TARGET_POWER"
1fd4e8c1
RK
4925 "@
4926 srea. %3,%1,%2
9ebbca7d
GK
4927 {srai.|srawi.} %3,%1,%h2
4928 #
4929 #"
4930 [(set_attr "type" "delayed_compare")
4931 (set_attr "length" "4,4,8,8")])
4932
4933(define_split
4934 [(set (match_operand:CC 0 "cc_reg_not_cr0_operand" "")
4935 (compare:CC (ashiftrt:SI (match_operand:SI 1 "gpc_reg_operand" "")
4936 (match_operand:SI 2 "reg_or_cint_operand" ""))
4937 (const_int 0)))
4938 (clobber (match_scratch:SI 3 ""))
4939 (clobber (match_scratch:SI 4 ""))]
4940 "TARGET_POWER && reload_completed"
4941 [(parallel [(set (match_dup 3)
4942 (ashiftrt:SI (match_dup 1) (match_dup 2)))
4943 (clobber (match_dup 4))])
4944 (set (match_dup 0)
4945 (compare:CC (match_dup 3)
4946 (const_int 0)))]
4947 "")
ca7f5001
RK
4948
4949(define_insn ""
44cd321e
PS
4950 [(set (match_operand:CC 0 "cc_reg_operand" "=x,x,?y,?y")
4951 (compare:CC (ashiftrt:SI (match_operand:SI 1 "gpc_reg_operand" "r,r,r,r")
4952 (match_operand:SI 2 "reg_or_cint_operand" "r,i,r,i"))
ca7f5001 4953 (const_int 0)))
44cd321e 4954 (clobber (match_scratch:SI 3 "=r,r,r,r"))]
25c341fa 4955 "! TARGET_POWER"
9ebbca7d 4956 "@
44cd321e
PS
4957 {sra.|sraw.} %3,%1,%2
4958 {srai.|srawi.} %3,%1,%h2
4959 #
9ebbca7d 4960 #"
44cd321e
PS
4961 [(set_attr "type" "var_delayed_compare,delayed_compare,var_delayed_compare,delayed_compare")
4962 (set_attr "length" "4,4,8,8")])
9ebbca7d
GK
4963
4964(define_split
4965 [(set (match_operand:CC 0 "cc_reg_not_cr0_operand" "")
4966 (compare:CC (ashiftrt:SI (match_operand:SI 1 "gpc_reg_operand" "")
4967 (match_operand:SI 2 "reg_or_cint_operand" ""))
4968 (const_int 0)))
4969 (clobber (match_scratch:SI 3 ""))]
4970 "! TARGET_POWER && reload_completed"
4971 [(set (match_dup 3)
4972 (ashiftrt:SI (match_dup 1) (match_dup 2)))
4973 (set (match_dup 0)
4974 (compare:CC (match_dup 3)
4975 (const_int 0)))]
4976 "")
1fd4e8c1
RK
4977
4978(define_insn ""
9ebbca7d
GK
4979 [(set (match_operand:CC 3 "cc_reg_operand" "=x,x,?y,?y")
4980 (compare:CC (ashiftrt:SI (match_operand:SI 1 "gpc_reg_operand" "r,r,r,r")
4981 (match_operand:SI 2 "reg_or_cint_operand" "r,i,r,i"))
1fd4e8c1 4982 (const_int 0)))
9ebbca7d 4983 (set (match_operand:SI 0 "gpc_reg_operand" "=r,r,r,r")
1fd4e8c1 4984 (ashiftrt:SI (match_dup 1) (match_dup 2)))
9ebbca7d 4985 (clobber (match_scratch:SI 4 "=q,X,q,X"))]
ca7f5001 4986 "TARGET_POWER"
1fd4e8c1
RK
4987 "@
4988 srea. %0,%1,%2
9ebbca7d
GK
4989 {srai.|srawi.} %0,%1,%h2
4990 #
4991 #"
4992 [(set_attr "type" "delayed_compare")
4993 (set_attr "length" "4,4,8,8")])
4994
4995(define_split
4996 [(set (match_operand:CC 3 "cc_reg_not_cr0_operand" "")
4997 (compare:CC (ashiftrt:SI (match_operand:SI 1 "gpc_reg_operand" "")
4998 (match_operand:SI 2 "reg_or_cint_operand" ""))
4999 (const_int 0)))
5000 (set (match_operand:SI 0 "gpc_reg_operand" "")
5001 (ashiftrt:SI (match_dup 1) (match_dup 2)))
5002 (clobber (match_scratch:SI 4 ""))]
5003 "TARGET_POWER && reload_completed"
5004 [(parallel [(set (match_dup 0)
5005 (ashiftrt:SI (match_dup 1) (match_dup 2)))
5006 (clobber (match_dup 4))])
5007 (set (match_dup 3)
5008 (compare:CC (match_dup 0)
5009 (const_int 0)))]
5010 "")
1fd4e8c1 5011
ca7f5001 5012(define_insn ""
44cd321e
PS
5013 [(set (match_operand:CC 3 "cc_reg_operand" "=x,x,?y,?y")
5014 (compare:CC (ashiftrt:SI (match_operand:SI 1 "gpc_reg_operand" "r,r,r,r")
5015 (match_operand:SI 2 "reg_or_cint_operand" "r,i,r,i"))
ca7f5001 5016 (const_int 0)))
44cd321e 5017 (set (match_operand:SI 0 "gpc_reg_operand" "=r,r,r,r")
ca7f5001 5018 (ashiftrt:SI (match_dup 1) (match_dup 2)))]
25c341fa 5019 "! TARGET_POWER"
9ebbca7d 5020 "@
44cd321e
PS
5021 {sra.|sraw.} %0,%1,%2
5022 {srai.|srawi.} %0,%1,%h2
5023 #
9ebbca7d 5024 #"
44cd321e
PS
5025 [(set_attr "type" "var_delayed_compare,delayed_compare,var_delayed_compare,delayed_compare")
5026 (set_attr "length" "4,4,8,8")])
1fd4e8c1 5027\f
9ebbca7d
GK
5028(define_split
5029 [(set (match_operand:CC 3 "cc_reg_not_cr0_operand" "")
5030 (compare:CC (ashiftrt:SI (match_operand:SI 1 "gpc_reg_operand" "")
5031 (match_operand:SI 2 "reg_or_cint_operand" ""))
5032 (const_int 0)))
5033 (set (match_operand:SI 0 "gpc_reg_operand" "")
5034 (ashiftrt:SI (match_dup 1) (match_dup 2)))]
5035 "! TARGET_POWER && reload_completed"
5036 [(set (match_dup 0)
5037 (ashiftrt:SI (match_dup 1) (match_dup 2)))
5038 (set (match_dup 3)
5039 (compare:CC (match_dup 0)
5040 (const_int 0)))]
5041 "")
5042
1fd4e8c1
RK
5043;; Floating-point insns, excluding normal data motion.
5044;;
ca7f5001
RK
5045;; PowerPC has a full set of single-precision floating point instructions.
5046;;
5047;; For the POWER architecture, we pretend that we have both SFmode and
5048;; DFmode insns, while, in fact, all fp insns are actually done in double.
5049;; The only conversions we will do will be when storing to memory. In that
5050;; case, we will use the "frsp" instruction before storing.
1fd4e8c1
RK
5051;;
5052;; Note that when we store into a single-precision memory location, we need to
5053;; use the frsp insn first. If the register being stored isn't dead, we
5054;; need a scratch register for the frsp. But this is difficult when the store
5055;; is done by reload. It is not incorrect to do the frsp on the register in
5056;; this case, we just lose precision that we would have otherwise gotten but
5057;; is not guaranteed. Perhaps this should be tightened up at some point.
5058
99176a91
AH
5059(define_expand "extendsfdf2"
5060 [(set (match_operand:DF 0 "gpc_reg_operand" "")
97c54d9a 5061 (float_extend:DF (match_operand:SF 1 "reg_or_none500mem_operand" "")))]
99176a91
AH
5062 "TARGET_HARD_FLOAT && (TARGET_FPRS || TARGET_E500_DOUBLE)"
5063 "")
5064
5065(define_insn_and_split "*extendsfdf2_fpr"
97c54d9a
DE
5066 [(set (match_operand:DF 0 "gpc_reg_operand" "=f,?f,f")
5067 (float_extend:DF (match_operand:SF 1 "reg_or_mem_operand" "0,f,m")))]
a3170dc6 5068 "TARGET_HARD_FLOAT && TARGET_FPRS"
11ac38b2
DE
5069 "@
5070 #
97c54d9a
DE
5071 fmr %0,%1
5072 lfs%U1%X1 %0,%1"
d7b1468b 5073 "&& reload_completed && REG_P (operands[1]) && REGNO (operands[0]) == REGNO (operands[1])"
11ac38b2 5074 [(const_int 0)]
5c30aff8 5075{
11ac38b2
DE
5076 emit_note (NOTE_INSN_DELETED);
5077 DONE;
5078}
97c54d9a 5079 [(set_attr "type" "fp,fp,fpload")])
1fd4e8c1 5080
7a2f7870
AH
5081(define_expand "truncdfsf2"
5082 [(set (match_operand:SF 0 "gpc_reg_operand" "")
5083 (float_truncate:SF (match_operand:DF 1 "gpc_reg_operand" "")))]
5084 "TARGET_HARD_FLOAT && (TARGET_FPRS || TARGET_E500_DOUBLE)"
5085 "")
5086
99176a91 5087(define_insn "*truncdfsf2_fpr"
cd2b37d9
RK
5088 [(set (match_operand:SF 0 "gpc_reg_operand" "=f")
5089 (float_truncate:SF (match_operand:DF 1 "gpc_reg_operand" "f")))]
a3170dc6 5090 "TARGET_HARD_FLOAT && TARGET_FPRS"
dcac138d 5091 "frsp %0,%1"
1fd4e8c1
RK
5092 [(set_attr "type" "fp")])
5093
455350f4
RK
5094(define_insn "aux_truncdfsf2"
5095 [(set (match_operand:SF 0 "gpc_reg_operand" "=f")
615158e2 5096 (unspec:SF [(match_operand:SF 1 "gpc_reg_operand" "f")] UNSPEC_FRSP))]
a3170dc6 5097 "! TARGET_POWERPC && TARGET_HARD_FLOAT && TARGET_FPRS"
455350f4
RK
5098 "frsp %0,%1"
5099 [(set_attr "type" "fp")])
5100
a3170dc6
AH
5101(define_expand "negsf2"
5102 [(set (match_operand:SF 0 "gpc_reg_operand" "")
5103 (neg:SF (match_operand:SF 1 "gpc_reg_operand" "")))]
5104 "TARGET_HARD_FLOAT"
5105 "")
5106
5107(define_insn "*negsf2"
cd2b37d9
RK
5108 [(set (match_operand:SF 0 "gpc_reg_operand" "=f")
5109 (neg:SF (match_operand:SF 1 "gpc_reg_operand" "f")))]
a3170dc6 5110 "TARGET_HARD_FLOAT && TARGET_FPRS"
1fd4e8c1
RK
5111 "fneg %0,%1"
5112 [(set_attr "type" "fp")])
5113
a3170dc6
AH
5114(define_expand "abssf2"
5115 [(set (match_operand:SF 0 "gpc_reg_operand" "")
5116 (abs:SF (match_operand:SF 1 "gpc_reg_operand" "")))]
5117 "TARGET_HARD_FLOAT"
5118 "")
5119
5120(define_insn "*abssf2"
cd2b37d9
RK
5121 [(set (match_operand:SF 0 "gpc_reg_operand" "=f")
5122 (abs:SF (match_operand:SF 1 "gpc_reg_operand" "f")))]
a3170dc6 5123 "TARGET_HARD_FLOAT && TARGET_FPRS"
1fd4e8c1
RK
5124 "fabs %0,%1"
5125 [(set_attr "type" "fp")])
5126
5127(define_insn ""
cd2b37d9
RK
5128 [(set (match_operand:SF 0 "gpc_reg_operand" "=f")
5129 (neg:SF (abs:SF (match_operand:SF 1 "gpc_reg_operand" "f"))))]
a3170dc6 5130 "TARGET_HARD_FLOAT && TARGET_FPRS"
1fd4e8c1
RK
5131 "fnabs %0,%1"
5132 [(set_attr "type" "fp")])
5133
ca7f5001
RK
5134(define_expand "addsf3"
5135 [(set (match_operand:SF 0 "gpc_reg_operand" "")
5136 (plus:SF (match_operand:SF 1 "gpc_reg_operand" "")
5137 (match_operand:SF 2 "gpc_reg_operand" "")))]
d14a6d05 5138 "TARGET_HARD_FLOAT"
ca7f5001
RK
5139 "")
5140
5141(define_insn ""
cd2b37d9
RK
5142 [(set (match_operand:SF 0 "gpc_reg_operand" "=f")
5143 (plus:SF (match_operand:SF 1 "gpc_reg_operand" "%f")
5144 (match_operand:SF 2 "gpc_reg_operand" "f")))]
a3170dc6 5145 "TARGET_POWERPC && TARGET_HARD_FLOAT && TARGET_FPRS"
b26c8351 5146 "fadds %0,%1,%2"
ca7f5001
RK
5147 [(set_attr "type" "fp")])
5148
5149(define_insn ""
5150 [(set (match_operand:SF 0 "gpc_reg_operand" "=f")
5151 (plus:SF (match_operand:SF 1 "gpc_reg_operand" "%f")
5152 (match_operand:SF 2 "gpc_reg_operand" "f")))]
a3170dc6 5153 "! TARGET_POWERPC && TARGET_HARD_FLOAT && TARGET_FPRS"
b26c8351 5154 "{fa|fadd} %0,%1,%2"
ca7f5001
RK
5155 [(set_attr "type" "fp")])
5156
5157(define_expand "subsf3"
5158 [(set (match_operand:SF 0 "gpc_reg_operand" "")
5159 (minus:SF (match_operand:SF 1 "gpc_reg_operand" "")
5160 (match_operand:SF 2 "gpc_reg_operand" "")))]
d14a6d05 5161 "TARGET_HARD_FLOAT"
ca7f5001
RK
5162 "")
5163
5164(define_insn ""
5165 [(set (match_operand:SF 0 "gpc_reg_operand" "=f")
5166 (minus:SF (match_operand:SF 1 "gpc_reg_operand" "f")
5167 (match_operand:SF 2 "gpc_reg_operand" "f")))]
a3170dc6 5168 "TARGET_POWERPC && TARGET_HARD_FLOAT && TARGET_FPRS"
b26c8351 5169 "fsubs %0,%1,%2"
1fd4e8c1
RK
5170 [(set_attr "type" "fp")])
5171
ca7f5001 5172(define_insn ""
cd2b37d9
RK
5173 [(set (match_operand:SF 0 "gpc_reg_operand" "=f")
5174 (minus:SF (match_operand:SF 1 "gpc_reg_operand" "f")
5175 (match_operand:SF 2 "gpc_reg_operand" "f")))]
a3170dc6 5176 "! TARGET_POWERPC && TARGET_HARD_FLOAT && TARGET_FPRS"
b26c8351 5177 "{fs|fsub} %0,%1,%2"
ca7f5001
RK
5178 [(set_attr "type" "fp")])
5179
5180(define_expand "mulsf3"
5181 [(set (match_operand:SF 0 "gpc_reg_operand" "")
5182 (mult:SF (match_operand:SF 1 "gpc_reg_operand" "")
5183 (match_operand:SF 2 "gpc_reg_operand" "")))]
d14a6d05 5184 "TARGET_HARD_FLOAT"
ca7f5001
RK
5185 "")
5186
5187(define_insn ""
5188 [(set (match_operand:SF 0 "gpc_reg_operand" "=f")
5189 (mult:SF (match_operand:SF 1 "gpc_reg_operand" "%f")
5190 (match_operand:SF 2 "gpc_reg_operand" "f")))]
a3170dc6 5191 "TARGET_POWERPC && TARGET_HARD_FLOAT && TARGET_FPRS"
b26c8351 5192 "fmuls %0,%1,%2"
1fd4e8c1
RK
5193 [(set_attr "type" "fp")])
5194
ca7f5001 5195(define_insn ""
cd2b37d9
RK
5196 [(set (match_operand:SF 0 "gpc_reg_operand" "=f")
5197 (mult:SF (match_operand:SF 1 "gpc_reg_operand" "%f")
5198 (match_operand:SF 2 "gpc_reg_operand" "f")))]
a3170dc6 5199 "! TARGET_POWERPC && TARGET_HARD_FLOAT && TARGET_FPRS"
b26c8351 5200 "{fm|fmul} %0,%1,%2"
0780f386 5201 [(set_attr "type" "dmul")])
1fd4e8c1 5202
ca7f5001
RK
5203(define_expand "divsf3"
5204 [(set (match_operand:SF 0 "gpc_reg_operand" "")
5205 (div:SF (match_operand:SF 1 "gpc_reg_operand" "")
5206 (match_operand:SF 2 "gpc_reg_operand" "")))]
d14a6d05 5207 "TARGET_HARD_FLOAT"
9c78b944 5208 "")
ca7f5001
RK
5209
5210(define_insn ""
cd2b37d9
RK
5211 [(set (match_operand:SF 0 "gpc_reg_operand" "=f")
5212 (div:SF (match_operand:SF 1 "gpc_reg_operand" "f")
5213 (match_operand:SF 2 "gpc_reg_operand" "f")))]
a3170dc6 5214 "TARGET_POWERPC && TARGET_HARD_FLOAT && TARGET_FPRS"
b26c8351 5215 "fdivs %0,%1,%2"
ca7f5001
RK
5216 [(set_attr "type" "sdiv")])
5217
5218(define_insn ""
5219 [(set (match_operand:SF 0 "gpc_reg_operand" "=f")
5220 (div:SF (match_operand:SF 1 "gpc_reg_operand" "f")
5221 (match_operand:SF 2 "gpc_reg_operand" "f")))]
a3170dc6 5222 "! TARGET_POWERPC && TARGET_HARD_FLOAT && TARGET_FPRS"
b26c8351 5223 "{fd|fdiv} %0,%1,%2"
0780f386 5224 [(set_attr "type" "ddiv")])
1fd4e8c1 5225
9c78b944
DE
5226(define_expand "recipsf3"
5227 [(set (match_operand:SF 0 "gpc_reg_operand" "=f")
5228 (unspec:SF [(match_operand:SF 1 "gpc_reg_operand" "f")
5229 (match_operand:SF 2 "gpc_reg_operand" "f")]
5230 UNSPEC_FRES))]
5231 "TARGET_RECIP && TARGET_HARD_FLOAT && TARGET_PPC_GFXOPT && !optimize_size
5232 && flag_finite_math_only && !flag_trapping_math"
5233{
5234 rs6000_emit_swdivsf (operands[0], operands[1], operands[2]);
5235 DONE;
5236})
5237
5238(define_insn "fres"
5239 [(set (match_operand:SF 0 "gpc_reg_operand" "=f")
5240 (unspec:SF [(match_operand:SF 1 "gpc_reg_operand" "f")] UNSPEC_FRES))]
5241 "TARGET_PPC_GFXOPT && flag_finite_math_only"
5242 "fres %0,%1"
5243 [(set_attr "type" "fp")])
5244
1fd4e8c1 5245(define_insn ""
cd2b37d9
RK
5246 [(set (match_operand:SF 0 "gpc_reg_operand" "=f")
5247 (plus:SF (mult:SF (match_operand:SF 1 "gpc_reg_operand" "%f")
5248 (match_operand:SF 2 "gpc_reg_operand" "f"))
5249 (match_operand:SF 3 "gpc_reg_operand" "f")))]
a3170dc6 5250 "TARGET_POWERPC && TARGET_HARD_FLOAT && TARGET_FPRS && TARGET_FUSED_MADD"
b26c8351 5251 "fmadds %0,%1,%2,%3"
ca7f5001
RK
5252 [(set_attr "type" "fp")])
5253
5254(define_insn ""
5255 [(set (match_operand:SF 0 "gpc_reg_operand" "=f")
5256 (plus:SF (mult:SF (match_operand:SF 1 "gpc_reg_operand" "%f")
5257 (match_operand:SF 2 "gpc_reg_operand" "f"))
5258 (match_operand:SF 3 "gpc_reg_operand" "f")))]
a3170dc6 5259 "! TARGET_POWERPC && TARGET_HARD_FLOAT && TARGET_FPRS && TARGET_FUSED_MADD"
b26c8351 5260 "{fma|fmadd} %0,%1,%2,%3"
cf27b467 5261 [(set_attr "type" "dmul")])
1fd4e8c1
RK
5262
5263(define_insn ""
cd2b37d9
RK
5264 [(set (match_operand:SF 0 "gpc_reg_operand" "=f")
5265 (minus:SF (mult:SF (match_operand:SF 1 "gpc_reg_operand" "%f")
5266 (match_operand:SF 2 "gpc_reg_operand" "f"))
5267 (match_operand:SF 3 "gpc_reg_operand" "f")))]
a3170dc6 5268 "TARGET_POWERPC && TARGET_HARD_FLOAT && TARGET_FPRS && TARGET_FUSED_MADD"
b26c8351 5269 "fmsubs %0,%1,%2,%3"
ca7f5001
RK
5270 [(set_attr "type" "fp")])
5271
5272(define_insn ""
5273 [(set (match_operand:SF 0 "gpc_reg_operand" "=f")
5274 (minus:SF (mult:SF (match_operand:SF 1 "gpc_reg_operand" "%f")
5275 (match_operand:SF 2 "gpc_reg_operand" "f"))
5276 (match_operand:SF 3 "gpc_reg_operand" "f")))]
a3170dc6 5277 "! TARGET_POWERPC && TARGET_HARD_FLOAT && TARGET_FPRS && TARGET_FUSED_MADD"
b26c8351 5278 "{fms|fmsub} %0,%1,%2,%3"
cf27b467 5279 [(set_attr "type" "dmul")])
1fd4e8c1
RK
5280
5281(define_insn ""
cd2b37d9
RK
5282 [(set (match_operand:SF 0 "gpc_reg_operand" "=f")
5283 (neg:SF (plus:SF (mult:SF (match_operand:SF 1 "gpc_reg_operand" "%f")
5284 (match_operand:SF 2 "gpc_reg_operand" "f"))
5285 (match_operand:SF 3 "gpc_reg_operand" "f"))))]
16823694
GK
5286 "TARGET_POWERPC && TARGET_HARD_FLOAT && TARGET_FPRS && TARGET_FUSED_MADD
5287 && HONOR_SIGNED_ZEROS (SFmode)"
5288 "fnmadds %0,%1,%2,%3"
5289 [(set_attr "type" "fp")])
5290
5291(define_insn ""
5292 [(set (match_operand:SF 0 "gpc_reg_operand" "=f")
5293 (minus:SF (mult:SF (neg:SF (match_operand:SF 1 "gpc_reg_operand" "f"))
5294 (match_operand:SF 2 "gpc_reg_operand" "f"))
5295 (match_operand:SF 3 "gpc_reg_operand" "f")))]
5296 "TARGET_POWERPC && TARGET_HARD_FLOAT && TARGET_FPRS && TARGET_FUSED_MADD
5297 && ! HONOR_SIGNED_ZEROS (SFmode)"
b26c8351 5298 "fnmadds %0,%1,%2,%3"
ca7f5001
RK
5299 [(set_attr "type" "fp")])
5300
5301(define_insn ""
5302 [(set (match_operand:SF 0 "gpc_reg_operand" "=f")
5303 (neg:SF (plus:SF (mult:SF (match_operand:SF 1 "gpc_reg_operand" "%f")
5304 (match_operand:SF 2 "gpc_reg_operand" "f"))
5305 (match_operand:SF 3 "gpc_reg_operand" "f"))))]
a3170dc6 5306 "! TARGET_POWERPC && TARGET_HARD_FLOAT && TARGET_FPRS && TARGET_FUSED_MADD"
b26c8351 5307 "{fnma|fnmadd} %0,%1,%2,%3"
cf27b467 5308 [(set_attr "type" "dmul")])
1fd4e8c1 5309
16823694
GK
5310(define_insn ""
5311 [(set (match_operand:SF 0 "gpc_reg_operand" "=f")
5312 (minus:SF (mult:SF (neg:SF (match_operand:SF 1 "gpc_reg_operand" "f"))
5313 (match_operand:SF 2 "gpc_reg_operand" "f"))
5314 (match_operand:SF 3 "gpc_reg_operand" "f")))]
5315 "! TARGET_POWERPC && TARGET_HARD_FLOAT && TARGET_FPRS && TARGET_FUSED_MADD
5316 && ! HONOR_SIGNED_ZEROS (SFmode)"
5317 "{fnma|fnmadd} %0,%1,%2,%3"
5318 [(set_attr "type" "dmul")])
5319
1fd4e8c1 5320(define_insn ""
cd2b37d9
RK
5321 [(set (match_operand:SF 0 "gpc_reg_operand" "=f")
5322 (neg:SF (minus:SF (mult:SF (match_operand:SF 1 "gpc_reg_operand" "%f")
5323 (match_operand:SF 2 "gpc_reg_operand" "f"))
5324 (match_operand:SF 3 "gpc_reg_operand" "f"))))]
16823694
GK
5325 "TARGET_POWERPC && TARGET_HARD_FLOAT && TARGET_FPRS && TARGET_FUSED_MADD
5326 && HONOR_SIGNED_ZEROS (SFmode)"
5327 "fnmsubs %0,%1,%2,%3"
5328 [(set_attr "type" "fp")])
5329
5330(define_insn ""
5331 [(set (match_operand:SF 0 "gpc_reg_operand" "=f")
5332 (minus:SF (match_operand:SF 3 "gpc_reg_operand" "f")
5333 (mult:SF (match_operand:SF 1 "gpc_reg_operand" "%f")
5334 (match_operand:SF 2 "gpc_reg_operand" "f"))))]
5335 "TARGET_POWERPC && TARGET_HARD_FLOAT && TARGET_FPRS && TARGET_FUSED_MADD
5336 && ! HONOR_SIGNED_ZEROS (SFmode)"
b26c8351 5337 "fnmsubs %0,%1,%2,%3"
ca7f5001
RK
5338 [(set_attr "type" "fp")])
5339
5340(define_insn ""
5341 [(set (match_operand:SF 0 "gpc_reg_operand" "=f")
5342 (neg:SF (minus:SF (mult:SF (match_operand:SF 1 "gpc_reg_operand" "%f")
5343 (match_operand:SF 2 "gpc_reg_operand" "f"))
5344 (match_operand:SF 3 "gpc_reg_operand" "f"))))]
a3170dc6 5345 "! TARGET_POWERPC && TARGET_HARD_FLOAT && TARGET_FPRS && TARGET_FUSED_MADD"
b26c8351 5346 "{fnms|fnmsub} %0,%1,%2,%3"
cf27b467 5347 [(set_attr "type" "dmul")])
1fd4e8c1 5348
16823694
GK
5349(define_insn ""
5350 [(set (match_operand:SF 0 "gpc_reg_operand" "=f")
5351 (minus:SF (match_operand:SF 3 "gpc_reg_operand" "f")
5352 (mult:SF (match_operand:SF 1 "gpc_reg_operand" "%f")
5353 (match_operand:SF 2 "gpc_reg_operand" "f"))))]
5354 "! TARGET_POWERPC && TARGET_HARD_FLOAT && TARGET_FPRS && TARGET_FUSED_MADD
5355 && ! HONOR_SIGNED_ZEROS (SFmode)"
5356 "{fnms|fnmsub} %0,%1,%2,%3"
9c6fdb46 5357 [(set_attr "type" "dmul")])
16823694 5358
ca7f5001
RK
5359(define_expand "sqrtsf2"
5360 [(set (match_operand:SF 0 "gpc_reg_operand" "")
5361 (sqrt:SF (match_operand:SF 1 "gpc_reg_operand" "")))]
a3170dc6 5362 "(TARGET_PPC_GPOPT || TARGET_POWER2) && TARGET_HARD_FLOAT && TARGET_FPRS"
ca7f5001
RK
5363 "")
5364
5365(define_insn ""
5366 [(set (match_operand:SF 0 "gpc_reg_operand" "=f")
5367 (sqrt:SF (match_operand:SF 1 "gpc_reg_operand" "f")))]
a3170dc6 5368 "TARGET_PPC_GPOPT && TARGET_HARD_FLOAT && TARGET_FPRS"
ca7f5001
RK
5369 "fsqrts %0,%1"
5370 [(set_attr "type" "ssqrt")])
5371
5372(define_insn ""
5373 [(set (match_operand:SF 0 "gpc_reg_operand" "=f")
5374 (sqrt:SF (match_operand:SF 1 "gpc_reg_operand" "f")))]
a3170dc6 5375 "TARGET_POWER2 && TARGET_HARD_FLOAT && TARGET_FPRS"
ca7f5001
RK
5376 "fsqrt %0,%1"
5377 [(set_attr "type" "dsqrt")])
5378
9c78b944
DE
5379(define_expand "rsqrtsf2"
5380 [(set (match_operand:SF 0 "gpc_reg_operand" "=f")
5381 (unspec:SF [(match_operand:SF 1 "gpc_reg_operand" "f")]
5382 UNSPEC_RSQRT))]
5383 "TARGET_RECIP && TARGET_HARD_FLOAT && TARGET_PPC_GFXOPT && !optimize_size
5384 && flag_finite_math_only && !flag_trapping_math"
5385{
5386 rs6000_emit_swrsqrtsf (operands[0], operands[1]);
5387 DONE;
5388})
5389
5390(define_insn "*rsqrt_internal1"
5391 [(set (match_operand:SF 0 "gpc_reg_operand" "=f")
5392 (unspec:SF [(match_operand:SF 1 "gpc_reg_operand" "f")]
5393 UNSPEC_RSQRT))]
5394 "TARGET_HARD_FLOAT && TARGET_PPC_GFXOPT"
5395 "frsqrte %0,%1"
5396 [(set_attr "type" "fp")])
5397
0530bc70
AP
5398(define_expand "copysignsf3"
5399 [(set (match_dup 3)
5400 (abs:SF (match_operand:SF 1 "gpc_reg_operand" "")))
5401 (set (match_dup 4)
5402 (neg:SF (abs:SF (match_dup 1))))
5403 (set (match_operand:SF 0 "gpc_reg_operand" "")
5404 (if_then_else:SF (ge (match_operand:SF 2 "gpc_reg_operand" "")
5405 (match_dup 5))
5406 (match_dup 3)
5407 (match_dup 4)))]
5408 "TARGET_PPC_GFXOPT && TARGET_HARD_FLOAT && TARGET_FPRS
bb8df8a6 5409 && !HONOR_NANS (SFmode) && !HONOR_SIGNED_ZEROS (SFmode)"
0530bc70
AP
5410 {
5411 operands[3] = gen_reg_rtx (SFmode);
5412 operands[4] = gen_reg_rtx (SFmode);
5413 operands[5] = CONST0_RTX (SFmode);
5414 })
5415
5416(define_expand "copysigndf3"
5417 [(set (match_dup 3)
5418 (abs:DF (match_operand:DF 1 "gpc_reg_operand" "")))
5419 (set (match_dup 4)
5420 (neg:DF (abs:DF (match_dup 1))))
5421 (set (match_operand:DF 0 "gpc_reg_operand" "")
5422 (if_then_else:DF (ge (match_operand:DF 2 "gpc_reg_operand" "")
5423 (match_dup 5))
5424 (match_dup 3)
5425 (match_dup 4)))]
5426 "TARGET_PPC_GFXOPT && TARGET_HARD_FLOAT && TARGET_FPRS
5427 && !HONOR_NANS (DFmode) && !HONOR_SIGNED_ZEROS (DFmode)"
5428 {
5429 operands[3] = gen_reg_rtx (DFmode);
5430 operands[4] = gen_reg_rtx (DFmode);
5431 operands[5] = CONST0_RTX (DFmode);
5432 })
5433
94d7001a
RK
5434;; For MIN, MAX, and conditional move, we use DEFINE_EXPAND's that involve a
5435;; fsel instruction and some auxiliary computations. Then we just have a
5436;; single DEFINE_INSN for fsel and the define_splits to make them if made by
8e871c05 5437;; combine.
7ae4d8d4 5438(define_expand "smaxsf3"
8e871c05 5439 [(set (match_operand:SF 0 "gpc_reg_operand" "")
50a0b056
GK
5440 (if_then_else:SF (ge (match_operand:SF 1 "gpc_reg_operand" "")
5441 (match_operand:SF 2 "gpc_reg_operand" ""))
8e871c05
RK
5442 (match_dup 1)
5443 (match_dup 2)))]
89e73849 5444 "TARGET_PPC_GFXOPT && TARGET_HARD_FLOAT && TARGET_FPRS && !flag_trapping_math"
50a0b056 5445 "{ rs6000_emit_minmax (operands[0], SMAX, operands[1], operands[2]); DONE;}")
2f607b94 5446
7ae4d8d4 5447(define_expand "sminsf3"
50a0b056
GK
5448 [(set (match_operand:SF 0 "gpc_reg_operand" "")
5449 (if_then_else:SF (ge (match_operand:SF 1 "gpc_reg_operand" "")
5450 (match_operand:SF 2 "gpc_reg_operand" ""))
5451 (match_dup 2)
5452 (match_dup 1)))]
89e73849 5453 "TARGET_PPC_GFXOPT && TARGET_HARD_FLOAT && TARGET_FPRS && !flag_trapping_math"
50a0b056 5454 "{ rs6000_emit_minmax (operands[0], SMIN, operands[1], operands[2]); DONE;}")
2f607b94 5455
8e871c05
RK
5456(define_split
5457 [(set (match_operand:SF 0 "gpc_reg_operand" "")
50a0b056
GK
5458 (match_operator:SF 3 "min_max_operator"
5459 [(match_operand:SF 1 "gpc_reg_operand" "")
5460 (match_operand:SF 2 "gpc_reg_operand" "")]))]
89e73849 5461 "TARGET_PPC_GFXOPT && TARGET_HARD_FLOAT && TARGET_FPRS && !flag_trapping_math"
50a0b056
GK
5462 [(const_int 0)]
5463 "
6ae08853 5464{ rs6000_emit_minmax (operands[0], GET_CODE (operands[3]),
50a0b056
GK
5465 operands[1], operands[2]);
5466 DONE;
5467}")
2f607b94 5468
a3170dc6
AH
5469(define_expand "movsicc"
5470 [(set (match_operand:SI 0 "gpc_reg_operand" "")
5471 (if_then_else:SI (match_operand 1 "comparison_operator" "")
5472 (match_operand:SI 2 "gpc_reg_operand" "")
5473 (match_operand:SI 3 "gpc_reg_operand" "")))]
5474 "TARGET_ISEL"
5475 "
5476{
5477 if (rs6000_emit_cmove (operands[0], operands[1], operands[2], operands[3]))
5478 DONE;
5479 else
5480 FAIL;
5481}")
5482
5483;; We use the BASE_REGS for the isel input operands because, if rA is
5484;; 0, the value of 0 is placed in rD upon truth. Similarly for rB
5485;; because we may switch the operands and rB may end up being rA.
5486;;
5487;; We need 2 patterns: an unsigned and a signed pattern. We could
5488;; leave out the mode in operand 4 and use one pattern, but reload can
5489;; change the mode underneath our feet and then gets confused trying
5490;; to reload the value.
5491(define_insn "isel_signed"
5492 [(set (match_operand:SI 0 "gpc_reg_operand" "=r")
5493 (if_then_else:SI
5494 (match_operator 1 "comparison_operator"
5495 [(match_operand:CC 4 "cc_reg_operand" "y")
5496 (const_int 0)])
5497 (match_operand:SI 2 "gpc_reg_operand" "b")
5498 (match_operand:SI 3 "gpc_reg_operand" "b")))]
5499 "TARGET_ISEL"
5500 "*
5501{ return output_isel (operands); }"
5502 [(set_attr "length" "4")])
5503
5504(define_insn "isel_unsigned"
5505 [(set (match_operand:SI 0 "gpc_reg_operand" "=r")
5506 (if_then_else:SI
5507 (match_operator 1 "comparison_operator"
5508 [(match_operand:CCUNS 4 "cc_reg_operand" "y")
5509 (const_int 0)])
5510 (match_operand:SI 2 "gpc_reg_operand" "b")
5511 (match_operand:SI 3 "gpc_reg_operand" "b")))]
5512 "TARGET_ISEL"
5513 "*
5514{ return output_isel (operands); }"
5515 [(set_attr "length" "4")])
5516
94d7001a 5517(define_expand "movsfcc"
0ad91047 5518 [(set (match_operand:SF 0 "gpc_reg_operand" "")
94d7001a 5519 (if_then_else:SF (match_operand 1 "comparison_operator" "")
0ad91047
DE
5520 (match_operand:SF 2 "gpc_reg_operand" "")
5521 (match_operand:SF 3 "gpc_reg_operand" "")))]
a3170dc6 5522 "TARGET_PPC_GFXOPT && TARGET_HARD_FLOAT && TARGET_FPRS"
94d7001a
RK
5523 "
5524{
50a0b056
GK
5525 if (rs6000_emit_cmove (operands[0], operands[1], operands[2], operands[3]))
5526 DONE;
94d7001a 5527 else
50a0b056 5528 FAIL;
94d7001a 5529}")
d56d506a 5530
50a0b056 5531(define_insn "*fselsfsf4"
8e871c05
RK
5532 [(set (match_operand:SF 0 "gpc_reg_operand" "=f")
5533 (if_then_else:SF (ge (match_operand:SF 1 "gpc_reg_operand" "f")
50a0b056 5534 (match_operand:SF 4 "zero_fp_constant" "F"))
8e871c05
RK
5535 (match_operand:SF 2 "gpc_reg_operand" "f")
5536 (match_operand:SF 3 "gpc_reg_operand" "f")))]
a3170dc6 5537 "TARGET_PPC_GFXOPT && TARGET_HARD_FLOAT && TARGET_FPRS"
8e871c05
RK
5538 "fsel %0,%1,%2,%3"
5539 [(set_attr "type" "fp")])
2f607b94 5540
50a0b056 5541(define_insn "*fseldfsf4"
94d7001a
RK
5542 [(set (match_operand:SF 0 "gpc_reg_operand" "=f")
5543 (if_then_else:SF (ge (match_operand:DF 1 "gpc_reg_operand" "f")
d365ba42 5544 (match_operand:DF 4 "zero_fp_constant" "F"))
94d7001a
RK
5545 (match_operand:SF 2 "gpc_reg_operand" "f")
5546 (match_operand:SF 3 "gpc_reg_operand" "f")))]
a3170dc6 5547 "TARGET_PPC_GFXOPT && TARGET_HARD_FLOAT && TARGET_FPRS"
94d7001a
RK
5548 "fsel %0,%1,%2,%3"
5549 [(set_attr "type" "fp")])
d56d506a 5550
7a2f7870
AH
5551(define_expand "negdf2"
5552 [(set (match_operand:DF 0 "gpc_reg_operand" "")
5553 (neg:DF (match_operand:DF 1 "gpc_reg_operand" "")))]
5554 "TARGET_HARD_FLOAT && (TARGET_FPRS || TARGET_E500_DOUBLE)"
5555 "")
5556
99176a91 5557(define_insn "*negdf2_fpr"
cd2b37d9
RK
5558 [(set (match_operand:DF 0 "gpc_reg_operand" "=f")
5559 (neg:DF (match_operand:DF 1 "gpc_reg_operand" "f")))]
a3170dc6 5560 "TARGET_HARD_FLOAT && TARGET_FPRS"
1fd4e8c1
RK
5561 "fneg %0,%1"
5562 [(set_attr "type" "fp")])
5563
7a2f7870
AH
5564(define_expand "absdf2"
5565 [(set (match_operand:DF 0 "gpc_reg_operand" "")
5566 (abs:DF (match_operand:DF 1 "gpc_reg_operand" "")))]
5567 "TARGET_HARD_FLOAT && (TARGET_FPRS || TARGET_E500_DOUBLE)"
5568 "")
5569
99176a91 5570(define_insn "*absdf2_fpr"
cd2b37d9
RK
5571 [(set (match_operand:DF 0 "gpc_reg_operand" "=f")
5572 (abs:DF (match_operand:DF 1 "gpc_reg_operand" "f")))]
a3170dc6 5573 "TARGET_HARD_FLOAT && TARGET_FPRS"
1fd4e8c1
RK
5574 "fabs %0,%1"
5575 [(set_attr "type" "fp")])
5576
99176a91 5577(define_insn "*nabsdf2_fpr"
cd2b37d9
RK
5578 [(set (match_operand:DF 0 "gpc_reg_operand" "=f")
5579 (neg:DF (abs:DF (match_operand:DF 1 "gpc_reg_operand" "f"))))]
a3170dc6 5580 "TARGET_HARD_FLOAT && TARGET_FPRS"
1fd4e8c1
RK
5581 "fnabs %0,%1"
5582 [(set_attr "type" "fp")])
5583
7a2f7870
AH
5584(define_expand "adddf3"
5585 [(set (match_operand:DF 0 "gpc_reg_operand" "")
5586 (plus:DF (match_operand:DF 1 "gpc_reg_operand" "")
5587 (match_operand:DF 2 "gpc_reg_operand" "")))]
5588 "TARGET_HARD_FLOAT && (TARGET_FPRS || TARGET_E500_DOUBLE)"
5589 "")
5590
99176a91 5591(define_insn "*adddf3_fpr"
cd2b37d9
RK
5592 [(set (match_operand:DF 0 "gpc_reg_operand" "=f")
5593 (plus:DF (match_operand:DF 1 "gpc_reg_operand" "%f")
5594 (match_operand:DF 2 "gpc_reg_operand" "f")))]
a3170dc6 5595 "TARGET_HARD_FLOAT && TARGET_FPRS"
ca7f5001 5596 "{fa|fadd} %0,%1,%2"
1fd4e8c1
RK
5597 [(set_attr "type" "fp")])
5598
7a2f7870
AH
5599(define_expand "subdf3"
5600 [(set (match_operand:DF 0 "gpc_reg_operand" "")
5601 (minus:DF (match_operand:DF 1 "gpc_reg_operand" "")
5602 (match_operand:DF 2 "gpc_reg_operand" "")))]
5603 "TARGET_HARD_FLOAT && (TARGET_FPRS || TARGET_E500_DOUBLE)"
5604 "")
5605
99176a91 5606(define_insn "*subdf3_fpr"
cd2b37d9
RK
5607 [(set (match_operand:DF 0 "gpc_reg_operand" "=f")
5608 (minus:DF (match_operand:DF 1 "gpc_reg_operand" "f")
5609 (match_operand:DF 2 "gpc_reg_operand" "f")))]
a3170dc6 5610 "TARGET_HARD_FLOAT && TARGET_FPRS"
ca7f5001 5611 "{fs|fsub} %0,%1,%2"
1fd4e8c1
RK
5612 [(set_attr "type" "fp")])
5613
7a2f7870
AH
5614(define_expand "muldf3"
5615 [(set (match_operand:DF 0 "gpc_reg_operand" "")
5616 (mult:DF (match_operand:DF 1 "gpc_reg_operand" "")
5617 (match_operand:DF 2 "gpc_reg_operand" "")))]
5618 "TARGET_HARD_FLOAT && (TARGET_FPRS || TARGET_E500_DOUBLE)"
5619 "")
5620
99176a91 5621(define_insn "*muldf3_fpr"
cd2b37d9
RK
5622 [(set (match_operand:DF 0 "gpc_reg_operand" "=f")
5623 (mult:DF (match_operand:DF 1 "gpc_reg_operand" "%f")
5624 (match_operand:DF 2 "gpc_reg_operand" "f")))]
a3170dc6 5625 "TARGET_HARD_FLOAT && TARGET_FPRS"
ca7f5001 5626 "{fm|fmul} %0,%1,%2"
cfb557c4 5627 [(set_attr "type" "dmul")])
1fd4e8c1 5628
7a2f7870
AH
5629(define_expand "divdf3"
5630 [(set (match_operand:DF 0 "gpc_reg_operand" "")
5631 (div:DF (match_operand:DF 1 "gpc_reg_operand" "")
5632 (match_operand:DF 2 "gpc_reg_operand" "")))]
5633 "TARGET_HARD_FLOAT && (TARGET_FPRS || TARGET_E500_DOUBLE)"
9c78b944 5634 "")
7a2f7870 5635
99176a91 5636(define_insn "*divdf3_fpr"
cd2b37d9
RK
5637 [(set (match_operand:DF 0 "gpc_reg_operand" "=f")
5638 (div:DF (match_operand:DF 1 "gpc_reg_operand" "f")
5639 (match_operand:DF 2 "gpc_reg_operand" "f")))]
a3170dc6 5640 "TARGET_HARD_FLOAT && TARGET_FPRS"
ca7f5001 5641 "{fd|fdiv} %0,%1,%2"
cfb557c4 5642 [(set_attr "type" "ddiv")])
1fd4e8c1 5643
9c78b944
DE
5644(define_expand "recipdf3"
5645 [(set (match_operand:DF 0 "gpc_reg_operand" "=f")
5646 (unspec:DF [(match_operand:DF 1 "gpc_reg_operand" "f")
5647 (match_operand:DF 2 "gpc_reg_operand" "f")]
5648 UNSPEC_FRES))]
5649 "TARGET_RECIP && TARGET_HARD_FLOAT && TARGET_POPCNTB && !optimize_size
5650 && flag_finite_math_only && !flag_trapping_math"
5651{
5652 rs6000_emit_swdivdf (operands[0], operands[1], operands[2]);
5653 DONE;
5654})
5655
5656(define_insn "fred"
5657 [(set (match_operand:DF 0 "gpc_reg_operand" "=f")
5658 (unspec:DF [(match_operand:DF 1 "gpc_reg_operand" "f")] UNSPEC_FRES))]
5659 "TARGET_POPCNTB && flag_finite_math_only"
5660 "fre %0,%1"
5661 [(set_attr "type" "fp")])
5662
1fd4e8c1 5663(define_insn ""
cd2b37d9
RK
5664 [(set (match_operand:DF 0 "gpc_reg_operand" "=f")
5665 (plus:DF (mult:DF (match_operand:DF 1 "gpc_reg_operand" "%f")
5666 (match_operand:DF 2 "gpc_reg_operand" "f"))
5667 (match_operand:DF 3 "gpc_reg_operand" "f")))]
a3170dc6 5668 "TARGET_HARD_FLOAT && TARGET_FPRS && TARGET_FUSED_MADD"
ca7f5001 5669 "{fma|fmadd} %0,%1,%2,%3"
cfb557c4 5670 [(set_attr "type" "dmul")])
1fd4e8c1
RK
5671
5672(define_insn ""
cd2b37d9
RK
5673 [(set (match_operand:DF 0 "gpc_reg_operand" "=f")
5674 (minus:DF (mult:DF (match_operand:DF 1 "gpc_reg_operand" "%f")
5675 (match_operand:DF 2 "gpc_reg_operand" "f"))
5676 (match_operand:DF 3 "gpc_reg_operand" "f")))]
a3170dc6 5677 "TARGET_HARD_FLOAT && TARGET_FPRS && TARGET_FUSED_MADD"
ca7f5001 5678 "{fms|fmsub} %0,%1,%2,%3"
cfb557c4 5679 [(set_attr "type" "dmul")])
1fd4e8c1
RK
5680
5681(define_insn ""
cd2b37d9
RK
5682 [(set (match_operand:DF 0 "gpc_reg_operand" "=f")
5683 (neg:DF (plus:DF (mult:DF (match_operand:DF 1 "gpc_reg_operand" "%f")
5684 (match_operand:DF 2 "gpc_reg_operand" "f"))
5685 (match_operand:DF 3 "gpc_reg_operand" "f"))))]
16823694
GK
5686 "TARGET_HARD_FLOAT && TARGET_FPRS && TARGET_FUSED_MADD
5687 && HONOR_SIGNED_ZEROS (DFmode)"
5688 "{fnma|fnmadd} %0,%1,%2,%3"
5689 [(set_attr "type" "dmul")])
5690
5691(define_insn ""
5692 [(set (match_operand:DF 0 "gpc_reg_operand" "=f")
5693 (minus:DF (mult:DF (neg:DF (match_operand:DF 1 "gpc_reg_operand" "f"))
5694 (match_operand:DF 2 "gpc_reg_operand" "f"))
5695 (match_operand:DF 3 "gpc_reg_operand" "f")))]
5696 "TARGET_HARD_FLOAT && TARGET_FPRS && TARGET_FUSED_MADD
5697 && ! HONOR_SIGNED_ZEROS (DFmode)"
ca7f5001 5698 "{fnma|fnmadd} %0,%1,%2,%3"
cfb557c4 5699 [(set_attr "type" "dmul")])
1fd4e8c1
RK
5700
5701(define_insn ""
cd2b37d9
RK
5702 [(set (match_operand:DF 0 "gpc_reg_operand" "=f")
5703 (neg:DF (minus:DF (mult:DF (match_operand:DF 1 "gpc_reg_operand" "%f")
5704 (match_operand:DF 2 "gpc_reg_operand" "f"))
5705 (match_operand:DF 3 "gpc_reg_operand" "f"))))]
16823694
GK
5706 "TARGET_HARD_FLOAT && TARGET_FPRS && TARGET_FUSED_MADD
5707 && HONOR_SIGNED_ZEROS (DFmode)"
5708 "{fnms|fnmsub} %0,%1,%2,%3"
5709 [(set_attr "type" "dmul")])
5710
5711(define_insn ""
5712 [(set (match_operand:DF 0 "gpc_reg_operand" "=f")
5713 (minus:DF (match_operand:DF 3 "gpc_reg_operand" "f")
5714 (mult:DF (match_operand:DF 1 "gpc_reg_operand" "%f")
5715 (match_operand:DF 2 "gpc_reg_operand" "f"))))]
6ae08853 5716 "TARGET_HARD_FLOAT && TARGET_FPRS && TARGET_FUSED_MADD
16823694 5717 && ! HONOR_SIGNED_ZEROS (DFmode)"
ca7f5001 5718 "{fnms|fnmsub} %0,%1,%2,%3"
cfb557c4 5719 [(set_attr "type" "dmul")])
ca7f5001
RK
5720
5721(define_insn "sqrtdf2"
5722 [(set (match_operand:DF 0 "gpc_reg_operand" "=f")
5723 (sqrt:DF (match_operand:DF 1 "gpc_reg_operand" "f")))]
a3170dc6 5724 "(TARGET_PPC_GPOPT || TARGET_POWER2) && TARGET_HARD_FLOAT && TARGET_FPRS"
ca7f5001
RK
5725 "fsqrt %0,%1"
5726 [(set_attr "type" "dsqrt")])
b77dfefc 5727
50a0b056 5728;; The conditional move instructions allow us to perform max and min
6ae08853 5729;; operations even when
b77dfefc 5730
7ae4d8d4 5731(define_expand "smaxdf3"
8e871c05 5732 [(set (match_operand:DF 0 "gpc_reg_operand" "")
50a0b056
GK
5733 (if_then_else:DF (ge (match_operand:DF 1 "gpc_reg_operand" "")
5734 (match_operand:DF 2 "gpc_reg_operand" ""))
8e871c05
RK
5735 (match_dup 1)
5736 (match_dup 2)))]
89e73849 5737 "TARGET_PPC_GFXOPT && TARGET_HARD_FLOAT && TARGET_FPRS && !flag_trapping_math"
50a0b056 5738 "{ rs6000_emit_minmax (operands[0], SMAX, operands[1], operands[2]); DONE;}")
b77dfefc 5739
7ae4d8d4 5740(define_expand "smindf3"
50a0b056
GK
5741 [(set (match_operand:DF 0 "gpc_reg_operand" "")
5742 (if_then_else:DF (ge (match_operand:DF 1 "gpc_reg_operand" "")
5743 (match_operand:DF 2 "gpc_reg_operand" ""))
5744 (match_dup 2)
5745 (match_dup 1)))]
89e73849 5746 "TARGET_PPC_GFXOPT && TARGET_HARD_FLOAT && TARGET_FPRS && !flag_trapping_math"
50a0b056 5747 "{ rs6000_emit_minmax (operands[0], SMIN, operands[1], operands[2]); DONE;}")
b77dfefc 5748
8e871c05
RK
5749(define_split
5750 [(set (match_operand:DF 0 "gpc_reg_operand" "")
50a0b056
GK
5751 (match_operator:DF 3 "min_max_operator"
5752 [(match_operand:DF 1 "gpc_reg_operand" "")
5753 (match_operand:DF 2 "gpc_reg_operand" "")]))]
89e73849 5754 "TARGET_PPC_GFXOPT && TARGET_HARD_FLOAT && TARGET_FPRS && !flag_trapping_math"
50a0b056
GK
5755 [(const_int 0)]
5756 "
6ae08853 5757{ rs6000_emit_minmax (operands[0], GET_CODE (operands[3]),
50a0b056
GK
5758 operands[1], operands[2]);
5759 DONE;
5760}")
b77dfefc 5761
94d7001a 5762(define_expand "movdfcc"
0ad91047 5763 [(set (match_operand:DF 0 "gpc_reg_operand" "")
94d7001a 5764 (if_then_else:DF (match_operand 1 "comparison_operator" "")
0ad91047
DE
5765 (match_operand:DF 2 "gpc_reg_operand" "")
5766 (match_operand:DF 3 "gpc_reg_operand" "")))]
a3170dc6 5767 "TARGET_PPC_GFXOPT && TARGET_HARD_FLOAT && TARGET_FPRS"
94d7001a
RK
5768 "
5769{
50a0b056
GK
5770 if (rs6000_emit_cmove (operands[0], operands[1], operands[2], operands[3]))
5771 DONE;
94d7001a 5772 else
50a0b056 5773 FAIL;
94d7001a 5774}")
d56d506a 5775
50a0b056 5776(define_insn "*fseldfdf4"
8e871c05
RK
5777 [(set (match_operand:DF 0 "gpc_reg_operand" "=f")
5778 (if_then_else:DF (ge (match_operand:DF 1 "gpc_reg_operand" "f")
50a0b056 5779 (match_operand:DF 4 "zero_fp_constant" "F"))
8e871c05
RK
5780 (match_operand:DF 2 "gpc_reg_operand" "f")
5781 (match_operand:DF 3 "gpc_reg_operand" "f")))]
a3170dc6 5782 "TARGET_PPC_GFXOPT && TARGET_HARD_FLOAT && TARGET_FPRS"
8e871c05
RK
5783 "fsel %0,%1,%2,%3"
5784 [(set_attr "type" "fp")])
d56d506a 5785
50a0b056 5786(define_insn "*fselsfdf4"
94d7001a
RK
5787 [(set (match_operand:DF 0 "gpc_reg_operand" "=f")
5788 (if_then_else:DF (ge (match_operand:SF 1 "gpc_reg_operand" "f")
50a0b056 5789 (match_operand:SF 4 "zero_fp_constant" "F"))
94d7001a
RK
5790 (match_operand:DF 2 "gpc_reg_operand" "f")
5791 (match_operand:DF 3 "gpc_reg_operand" "f")))]
5792 "TARGET_PPC_GFXOPT"
5793 "fsel %0,%1,%2,%3"
5794 [(set_attr "type" "fp")])
1fd4e8c1 5795\f
d095928f
AH
5796;; Conversions to and from floating-point.
5797
5798(define_expand "fixuns_truncsfsi2"
5799 [(set (match_operand:SI 0 "gpc_reg_operand" "")
5800 (unsigned_fix:SI (match_operand:SF 1 "gpc_reg_operand" "")))]
5801 "TARGET_HARD_FLOAT && !TARGET_FPRS"
5802 "")
5803
5804(define_expand "fix_truncsfsi2"
5805 [(set (match_operand:SI 0 "gpc_reg_operand" "")
5806 (fix:SI (match_operand:SF 1 "gpc_reg_operand" "")))]
5807 "TARGET_HARD_FLOAT && !TARGET_FPRS"
5808 "")
5809
9ebbca7d
GK
5810; For each of these conversions, there is a define_expand, a define_insn
5811; with a '#' template, and a define_split (with C code). The idea is
5812; to allow constant folding with the template of the define_insn,
5813; then to have the insns split later (between sched1 and final).
5814
1fd4e8c1 5815(define_expand "floatsidf2"
802a0058
MM
5816 [(parallel [(set (match_operand:DF 0 "gpc_reg_operand" "")
5817 (float:DF (match_operand:SI 1 "gpc_reg_operand" "")))
5818 (use (match_dup 2))
5819 (use (match_dup 3))
208c89ce 5820 (clobber (match_dup 4))
a7df97e6 5821 (clobber (match_dup 5))
9ebbca7d 5822 (clobber (match_dup 6))])]
17caeff2 5823 "TARGET_HARD_FLOAT && (TARGET_FPRS || TARGET_E500_DOUBLE)"
1fd4e8c1
RK
5824 "
5825{
99176a91
AH
5826 if (TARGET_E500_DOUBLE)
5827 {
5828 emit_insn (gen_spe_floatsidf2 (operands[0], operands[1]));
5829 DONE;
5830 }
44cd321e
PS
5831 if (TARGET_POWERPC64 && TARGET_MFPGPR && TARGET_HARD_FLOAT && TARGET_FPRS)
5832 {
5833 rtx t1 = gen_reg_rtx (DImode);
5834 emit_insn (gen_floatsidf_ppc64_mfpgpr (operands[0], operands[1], t1));
5835 DONE;
5836 }
05d49501
AM
5837 if (TARGET_POWERPC64)
5838 {
5839 rtx mem = assign_stack_temp (DImode, GET_MODE_SIZE (DImode), 0);
5840 rtx t1 = gen_reg_rtx (DImode);
5841 rtx t2 = gen_reg_rtx (DImode);
5842 emit_insn (gen_floatsidf_ppc64 (operands[0], operands[1], mem, t1, t2));
5843 DONE;
5844 }
5845
802a0058 5846 operands[2] = force_reg (SImode, GEN_INT (0x43300000));
5692c7bc 5847 operands[3] = force_reg (DFmode, CONST_DOUBLE_ATOF (\"4503601774854144\", DFmode));
9ebbca7d
GK
5848 operands[4] = assign_stack_temp (DFmode, GET_MODE_SIZE (DFmode), 0);
5849 operands[5] = gen_reg_rtx (DFmode);
5850 operands[6] = gen_reg_rtx (SImode);
1fd4e8c1
RK
5851}")
5852
230215f5 5853(define_insn_and_split "*floatsidf2_internal"
802a0058
MM
5854 [(set (match_operand:DF 0 "gpc_reg_operand" "=&f")
5855 (float:DF (match_operand:SI 1 "gpc_reg_operand" "r")))
5856 (use (match_operand:SI 2 "gpc_reg_operand" "r"))
5857 (use (match_operand:DF 3 "gpc_reg_operand" "f"))
b0d6c7d8 5858 (clobber (match_operand:DF 4 "offsettable_mem_operand" "=o"))
6f9c81f5
DJ
5859 (clobber (match_operand:DF 5 "gpc_reg_operand" "=&f"))
5860 (clobber (match_operand:SI 6 "gpc_reg_operand" "=&r"))]
a3170dc6 5861 "! TARGET_POWERPC64 && TARGET_HARD_FLOAT && TARGET_FPRS"
802a0058 5862 "#"
b3a13419 5863 "&& (can_create_pseudo_p () || offsettable_nonstrict_memref_p (operands[4]))"
230215f5 5864 [(pc)]
208c89ce
MM
5865 "
5866{
9ebbca7d 5867 rtx lowword, highword;
230215f5
GK
5868 gcc_assert (MEM_P (operands[4]));
5869 highword = adjust_address (operands[4], SImode, 0);
5870 lowword = adjust_address (operands[4], SImode, 4);
9ebbca7d
GK
5871 if (! WORDS_BIG_ENDIAN)
5872 {
5873 rtx tmp;
5874 tmp = highword; highword = lowword; lowword = tmp;
5875 }
5876
6ae08853 5877 emit_insn (gen_xorsi3 (operands[6], operands[1],
9ebbca7d 5878 GEN_INT (~ (HOST_WIDE_INT) 0x7fffffff)));
230215f5
GK
5879 emit_move_insn (lowword, operands[6]);
5880 emit_move_insn (highword, operands[2]);
9ebbca7d
GK
5881 emit_move_insn (operands[5], operands[4]);
5882 emit_insn (gen_subdf3 (operands[0], operands[5], operands[3]));
5883 DONE;
230215f5
GK
5884}"
5885 [(set_attr "length" "24")])
802a0058 5886
a3170dc6
AH
5887(define_expand "floatunssisf2"
5888 [(set (match_operand:SF 0 "gpc_reg_operand" "")
5889 (unsigned_float:SF (match_operand:SI 1 "gpc_reg_operand" "")))]
5890 "TARGET_HARD_FLOAT && !TARGET_FPRS"
5891 "")
5892
802a0058
MM
5893(define_expand "floatunssidf2"
5894 [(parallel [(set (match_operand:DF 0 "gpc_reg_operand" "")
5895 (unsigned_float:DF (match_operand:SI 1 "gpc_reg_operand" "")))
5896 (use (match_dup 2))
5897 (use (match_dup 3))
a7df97e6 5898 (clobber (match_dup 4))
9ebbca7d 5899 (clobber (match_dup 5))])]
99176a91 5900 "TARGET_HARD_FLOAT && (TARGET_FPRS || TARGET_E500_DOUBLE)"
1fd4e8c1
RK
5901 "
5902{
99176a91
AH
5903 if (TARGET_E500_DOUBLE)
5904 {
5905 emit_insn (gen_spe_floatunssidf2 (operands[0], operands[1]));
5906 DONE;
5907 }
05d49501
AM
5908 if (TARGET_POWERPC64)
5909 {
5910 rtx mem = assign_stack_temp (DImode, GET_MODE_SIZE (DImode), 0);
5911 rtx t1 = gen_reg_rtx (DImode);
5912 rtx t2 = gen_reg_rtx (DImode);
5913 emit_insn (gen_floatunssidf_ppc64 (operands[0], operands[1], mem,
5914 t1, t2));
5915 DONE;
5916 }
5917
802a0058 5918 operands[2] = force_reg (SImode, GEN_INT (0x43300000));
5692c7bc 5919 operands[3] = force_reg (DFmode, CONST_DOUBLE_ATOF (\"4503599627370496\", DFmode));
9ebbca7d
GK
5920 operands[4] = assign_stack_temp (DFmode, GET_MODE_SIZE (DFmode), 0);
5921 operands[5] = gen_reg_rtx (DFmode);
1fd4e8c1
RK
5922}")
5923
230215f5 5924(define_insn_and_split "*floatunssidf2_internal"
802a0058
MM
5925 [(set (match_operand:DF 0 "gpc_reg_operand" "=&f")
5926 (unsigned_float:DF (match_operand:SI 1 "gpc_reg_operand" "r")))
5927 (use (match_operand:SI 2 "gpc_reg_operand" "r"))
5928 (use (match_operand:DF 3 "gpc_reg_operand" "f"))
b0d6c7d8 5929 (clobber (match_operand:DF 4 "offsettable_mem_operand" "=o"))
6f9c81f5 5930 (clobber (match_operand:DF 5 "gpc_reg_operand" "=&f"))]
a3170dc6 5931 "! TARGET_POWERPC64 && TARGET_HARD_FLOAT && TARGET_FPRS"
802a0058 5932 "#"
b3a13419 5933 "&& (can_create_pseudo_p () || offsettable_nonstrict_memref_p (operands[4]))"
230215f5 5934 [(pc)]
9ebbca7d 5935 "
802a0058 5936{
9ebbca7d 5937 rtx lowword, highword;
230215f5
GK
5938 gcc_assert (MEM_P (operands[4]));
5939 highword = adjust_address (operands[4], SImode, 0);
5940 lowword = adjust_address (operands[4], SImode, 4);
9ebbca7d 5941 if (! WORDS_BIG_ENDIAN)
f6968f59 5942 {
9ebbca7d
GK
5943 rtx tmp;
5944 tmp = highword; highword = lowword; lowword = tmp;
f6968f59 5945 }
802a0058 5946
230215f5
GK
5947 emit_move_insn (lowword, operands[1]);
5948 emit_move_insn (highword, operands[2]);
9ebbca7d
GK
5949 emit_move_insn (operands[5], operands[4]);
5950 emit_insn (gen_subdf3 (operands[0], operands[5], operands[3]));
5951 DONE;
230215f5
GK
5952}"
5953 [(set_attr "length" "20")])
1fd4e8c1 5954
1fd4e8c1 5955(define_expand "fix_truncdfsi2"
045a8eb3 5956 [(parallel [(set (match_operand:SI 0 "fix_trunc_dest_operand" "")
802a0058
MM
5957 (fix:SI (match_operand:DF 1 "gpc_reg_operand" "")))
5958 (clobber (match_dup 2))
9ebbca7d 5959 (clobber (match_dup 3))])]
99176a91
AH
5960 "(TARGET_POWER2 || TARGET_POWERPC)
5961 && TARGET_HARD_FLOAT && (TARGET_FPRS || TARGET_E500_DOUBLE)"
1fd4e8c1
RK
5962 "
5963{
99176a91
AH
5964 if (TARGET_E500_DOUBLE)
5965 {
5966 emit_insn (gen_spe_fix_truncdfsi2 (operands[0], operands[1]));
5967 DONE;
5968 }
802a0058 5969 operands[2] = gen_reg_rtx (DImode);
44cd321e
PS
5970 if (TARGET_POWERPC64 && TARGET_MFPGPR && TARGET_HARD_FLOAT && TARGET_FPRS
5971 && gpc_reg_operand(operands[0], GET_MODE (operands[0])))
5972 {
5973 operands[3] = gen_reg_rtx (DImode);
5974 emit_insn (gen_fix_truncdfsi2_mfpgpr (operands[0], operands[1],
5975 operands[2], operands[3]));
5976 DONE;
5977 }
da4c340c
GK
5978 if (TARGET_PPC_GFXOPT)
5979 {
5980 rtx orig_dest = operands[0];
045a8eb3 5981 if (! memory_operand (orig_dest, GET_MODE (orig_dest)))
da4c340c
GK
5982 operands[0] = assign_stack_temp (SImode, GET_MODE_SIZE (SImode), 0);
5983 emit_insn (gen_fix_truncdfsi2_internal_gfxopt (operands[0], operands[1],
5984 operands[2]));
5985 if (operands[0] != orig_dest)
5986 emit_move_insn (orig_dest, operands[0]);
5987 DONE;
5988 }
9ebbca7d 5989 operands[3] = assign_stack_temp (DImode, GET_MODE_SIZE (DImode), 0);
1fd4e8c1
RK
5990}")
5991
da4c340c 5992(define_insn_and_split "*fix_truncdfsi2_internal"
802a0058
MM
5993 [(set (match_operand:SI 0 "gpc_reg_operand" "=r")
5994 (fix:SI (match_operand:DF 1 "gpc_reg_operand" "f")))
e3485bbc 5995 (clobber (match_operand:DI 2 "gpc_reg_operand" "=f"))
b0d6c7d8 5996 (clobber (match_operand:DI 3 "offsettable_mem_operand" "=o"))]
a3170dc6 5997 "(TARGET_POWER2 || TARGET_POWERPC) && TARGET_HARD_FLOAT && TARGET_FPRS"
802a0058 5998 "#"
b3a13419 5999 "&& (can_create_pseudo_p () || offsettable_nonstrict_memref_p (operands[3]))"
da4c340c 6000 [(pc)]
9ebbca7d 6001 "
802a0058 6002{
9ebbca7d 6003 rtx lowword;
230215f5
GK
6004 gcc_assert (MEM_P (operands[3]));
6005 lowword = adjust_address (operands[3], SImode, WORDS_BIG_ENDIAN ? 4 : 0);
802a0058 6006
9ebbca7d
GK
6007 emit_insn (gen_fctiwz (operands[2], operands[1]));
6008 emit_move_insn (operands[3], operands[2]);
230215f5 6009 emit_move_insn (operands[0], lowword);
9ebbca7d 6010 DONE;
da4c340c
GK
6011}"
6012 [(set_attr "length" "16")])
6013
6014(define_insn_and_split "fix_truncdfsi2_internal_gfxopt"
6015 [(set (match_operand:SI 0 "memory_operand" "=Z")
6016 (fix:SI (match_operand:DF 1 "gpc_reg_operand" "f")))
6017 (clobber (match_operand:DI 2 "gpc_reg_operand" "=f"))]
6018 "(TARGET_POWER2 || TARGET_POWERPC) && TARGET_HARD_FLOAT && TARGET_FPRS
6019 && TARGET_PPC_GFXOPT"
6020 "#"
6021 "&& 1"
6022 [(pc)]
6023 "
6024{
6025 emit_insn (gen_fctiwz (operands[2], operands[1]));
6026 emit_insn (gen_stfiwx (operands[0], operands[2]));
6027 DONE;
6028}"
6029 [(set_attr "length" "16")])
802a0058 6030
44cd321e
PS
6031(define_insn_and_split "fix_truncdfsi2_mfpgpr"
6032 [(set (match_operand:SI 0 "gpc_reg_operand" "=r")
6033 (fix:SI (match_operand:DF 1 "gpc_reg_operand" "f")))
6034 (clobber (match_operand:DI 2 "gpc_reg_operand" "=f"))
6035 (clobber (match_operand:DI 3 "gpc_reg_operand" "=r"))]
6036 "TARGET_POWERPC64 && TARGET_MFPGPR && TARGET_HARD_FLOAT && TARGET_FPRS"
6037 "#"
6038 "&& 1"
6039 [(set (match_dup 2) (unspec:DI [(fix:SI (match_dup 1))] UNSPEC_FCTIWZ))
6040 (set (match_dup 3) (match_dup 2))
6041 (set (match_dup 0) (subreg:SI (match_dup 3) 4))]
6042 ""
6043 [(set_attr "length" "12")])
6044
615158e2 6045; Here, we use (set (reg) (unspec:DI [(fix:SI ...)] UNSPEC_FCTIWZ))
9ebbca7d
GK
6046; rather than (set (subreg:SI (reg)) (fix:SI ...))
6047; because the first makes it clear that operand 0 is not live
6048; before the instruction.
6049(define_insn "fctiwz"
da4c340c 6050 [(set (match_operand:DI 0 "gpc_reg_operand" "=f")
615158e2
JJ
6051 (unspec:DI [(fix:SI (match_operand:DF 1 "gpc_reg_operand" "f"))]
6052 UNSPEC_FCTIWZ))]
a3170dc6 6053 "(TARGET_POWER2 || TARGET_POWERPC) && TARGET_HARD_FLOAT && TARGET_FPRS"
a260abc9
DE
6054 "{fcirz|fctiwz} %0,%1"
6055 [(set_attr "type" "fp")])
6056
9719f3b7
DE
6057(define_insn "btruncdf2"
6058 [(set (match_operand:DF 0 "gpc_reg_operand" "=f")
6059 (unspec:DF [(match_operand:DF 1 "gpc_reg_operand" "f")] UNSPEC_FRIZ))]
6060 "TARGET_FPRND && TARGET_HARD_FLOAT && TARGET_FPRS"
6061 "friz %0,%1"
6062 [(set_attr "type" "fp")])
6063
6064(define_insn "btruncsf2"
6065 [(set (match_operand:SF 0 "gpc_reg_operand" "=f")
6066 (unspec:SF [(match_operand:SF 1 "gpc_reg_operand" "f")] UNSPEC_FRIZ))]
6067 "TARGET_FPRND && TARGET_HARD_FLOAT && TARGET_FPRS"
833126ad 6068 "friz %0,%1"
9719f3b7
DE
6069 [(set_attr "type" "fp")])
6070
6071(define_insn "ceildf2"
6072 [(set (match_operand:DF 0 "gpc_reg_operand" "=f")
6073 (unspec:DF [(match_operand:DF 1 "gpc_reg_operand" "f")] UNSPEC_FRIP))]
6074 "TARGET_FPRND && TARGET_HARD_FLOAT && TARGET_FPRS"
6075 "frip %0,%1"
6076 [(set_attr "type" "fp")])
6077
6078(define_insn "ceilsf2"
833126ad 6079 [(set (match_operand:SF 0 "gpc_reg_operand" "=f")
9719f3b7
DE
6080 (unspec:SF [(match_operand:SF 1 "gpc_reg_operand" "f")] UNSPEC_FRIP))]
6081 "TARGET_FPRND && TARGET_HARD_FLOAT && TARGET_FPRS"
833126ad 6082 "frip %0,%1"
9719f3b7
DE
6083 [(set_attr "type" "fp")])
6084
6085(define_insn "floordf2"
6086 [(set (match_operand:DF 0 "gpc_reg_operand" "=f")
6087 (unspec:DF [(match_operand:DF 1 "gpc_reg_operand" "f")] UNSPEC_FRIM))]
6088 "TARGET_FPRND && TARGET_HARD_FLOAT && TARGET_FPRS"
6089 "frim %0,%1"
6090 [(set_attr "type" "fp")])
6091
6092(define_insn "floorsf2"
6093 [(set (match_operand:SF 0 "gpc_reg_operand" "=f")
6094 (unspec:SF [(match_operand:SF 1 "gpc_reg_operand" "f")] UNSPEC_FRIM))]
6095 "TARGET_FPRND && TARGET_HARD_FLOAT && TARGET_FPRS"
833126ad 6096 "frim %0,%1"
9719f3b7
DE
6097 [(set_attr "type" "fp")])
6098
6099(define_insn "rounddf2"
6100 [(set (match_operand:DF 0 "gpc_reg_operand" "=f")
6101 (unspec:DF [(match_operand:DF 1 "gpc_reg_operand" "f")] UNSPEC_FRIN))]
6102 "TARGET_FPRND && TARGET_HARD_FLOAT && TARGET_FPRS"
6103 "frin %0,%1"
6104 [(set_attr "type" "fp")])
6105
6106(define_insn "roundsf2"
6107 [(set (match_operand:SF 0 "gpc_reg_operand" "=f")
6108 (unspec:SF [(match_operand:SF 1 "gpc_reg_operand" "f")] UNSPEC_FRIN))]
6109 "TARGET_FPRND && TARGET_HARD_FLOAT && TARGET_FPRS"
833126ad 6110 "frin %0,%1"
9719f3b7
DE
6111 [(set_attr "type" "fp")])
6112
da4c340c
GK
6113; An UNSPEC is used so we don't have to support SImode in FP registers.
6114(define_insn "stfiwx"
6115 [(set (match_operand:SI 0 "memory_operand" "=Z")
6116 (unspec:SI [(match_operand:DI 1 "gpc_reg_operand" "f")]
6117 UNSPEC_STFIWX))]
6118 "TARGET_PPC_GFXOPT"
6119 "stfiwx %1,%y0"
6120 [(set_attr "type" "fpstore")])
6121
a3170dc6
AH
6122(define_expand "floatsisf2"
6123 [(set (match_operand:SF 0 "gpc_reg_operand" "")
6124 (float:SF (match_operand:SI 1 "gpc_reg_operand" "")))]
6125 "TARGET_HARD_FLOAT && !TARGET_FPRS"
6126 "")
6127
a473029f
RK
6128(define_insn "floatdidf2"
6129 [(set (match_operand:DF 0 "gpc_reg_operand" "=f")
94e98316 6130 (float:DF (match_operand:DI 1 "gpc_reg_operand" "!f#r")))]
a3170dc6 6131 "TARGET_POWERPC64 && TARGET_HARD_FLOAT && TARGET_FPRS"
a473029f
RK
6132 "fcfid %0,%1"
6133 [(set_attr "type" "fp")])
6134
44cd321e
PS
6135(define_insn_and_split "floatsidf_ppc64_mfpgpr"
6136 [(set (match_operand:DF 0 "gpc_reg_operand" "=f")
6137 (float:DF (match_operand:SI 1 "gpc_reg_operand" "r")))
6138 (clobber (match_operand:DI 2 "gpc_reg_operand" "=r"))]
6139 "TARGET_POWERPC64 && TARGET_MFPGPR && TARGET_HARD_FLOAT && TARGET_FPRS"
6140 "#"
6141 "&& 1"
6142 [(set (match_dup 2) (sign_extend:DI (match_dup 1)))
6143 (set (match_dup 0) (float:DF (match_dup 2)))]
6144 "")
6145
05d49501
AM
6146(define_insn_and_split "floatsidf_ppc64"
6147 [(set (match_operand:DF 0 "gpc_reg_operand" "=f")
6148 (float:DF (match_operand:SI 1 "gpc_reg_operand" "r")))
b0d6c7d8 6149 (clobber (match_operand:DI 2 "offsettable_mem_operand" "=o"))
05d49501
AM
6150 (clobber (match_operand:DI 3 "gpc_reg_operand" "=r"))
6151 (clobber (match_operand:DI 4 "gpc_reg_operand" "=f"))]
44cd321e 6152 "TARGET_POWERPC64 && !TARGET_MFPGPR && TARGET_HARD_FLOAT && TARGET_FPRS"
05d49501 6153 "#"
ecb62ae7 6154 "&& 1"
05d49501
AM
6155 [(set (match_dup 3) (sign_extend:DI (match_dup 1)))
6156 (set (match_dup 2) (match_dup 3))
6157 (set (match_dup 4) (match_dup 2))
6158 (set (match_dup 0) (float:DF (match_dup 4)))]
6159 "")
6160
6161(define_insn_and_split "floatunssidf_ppc64"
6162 [(set (match_operand:DF 0 "gpc_reg_operand" "=f")
6163 (unsigned_float:DF (match_operand:SI 1 "gpc_reg_operand" "r")))
b0d6c7d8 6164 (clobber (match_operand:DI 2 "offsettable_mem_operand" "=o"))
05d49501
AM
6165 (clobber (match_operand:DI 3 "gpc_reg_operand" "=r"))
6166 (clobber (match_operand:DI 4 "gpc_reg_operand" "=f"))]
a3170dc6 6167 "TARGET_POWERPC64 && TARGET_HARD_FLOAT && TARGET_FPRS"
05d49501 6168 "#"
ecb62ae7 6169 "&& 1"
05d49501
AM
6170 [(set (match_dup 3) (zero_extend:DI (match_dup 1)))
6171 (set (match_dup 2) (match_dup 3))
6172 (set (match_dup 4) (match_dup 2))
6173 (set (match_dup 0) (float:DF (match_dup 4)))]
6174 "")
6175
a473029f 6176(define_insn "fix_truncdfdi2"
94e98316 6177 [(set (match_operand:DI 0 "gpc_reg_operand" "=!f#r")
a473029f 6178 (fix:DI (match_operand:DF 1 "gpc_reg_operand" "f")))]
a3170dc6 6179 "TARGET_POWERPC64 && TARGET_HARD_FLOAT && TARGET_FPRS"
a473029f
RK
6180 "fctidz %0,%1"
6181 [(set_attr "type" "fp")])
ea112fc4 6182
678b7733
AM
6183(define_expand "floatdisf2"
6184 [(set (match_operand:SF 0 "gpc_reg_operand" "")
6185 (float:SF (match_operand:DI 1 "gpc_reg_operand" "")))]
994cf173 6186 "TARGET_POWERPC64 && TARGET_HARD_FLOAT && TARGET_FPRS"
678b7733
AM
6187 "
6188{
994cf173 6189 rtx val = operands[1];
678b7733
AM
6190 if (!flag_unsafe_math_optimizations)
6191 {
6192 rtx label = gen_label_rtx ();
994cf173
AM
6193 val = gen_reg_rtx (DImode);
6194 emit_insn (gen_floatdisf2_internal2 (val, operands[1], label));
678b7733
AM
6195 emit_label (label);
6196 }
994cf173 6197 emit_insn (gen_floatdisf2_internal1 (operands[0], val));
678b7733
AM
6198 DONE;
6199}")
6200
6201;; This is not IEEE compliant if rounding mode is "round to nearest".
6202;; If the DI->DF conversion is inexact, then it's possible to suffer
6203;; from double rounding.
6204(define_insn_and_split "floatdisf2_internal1"
ea112fc4 6205 [(set (match_operand:SF 0 "gpc_reg_operand" "=f")
94e98316 6206 (float:SF (match_operand:DI 1 "gpc_reg_operand" "!f#r")))
ea112fc4 6207 (clobber (match_scratch:DF 2 "=f"))]
678b7733 6208 "TARGET_POWERPC64 && TARGET_HARD_FLOAT && TARGET_FPRS"
ea112fc4
DE
6209 "#"
6210 "&& reload_completed"
6211 [(set (match_dup 2)
6212 (float:DF (match_dup 1)))
6213 (set (match_dup 0)
6214 (float_truncate:SF (match_dup 2)))]
6215 "")
678b7733
AM
6216
6217;; Twiddles bits to avoid double rounding.
b6d08ca1 6218;; Bits that might be truncated when converting to DFmode are replaced
678b7733
AM
6219;; by a bit that won't be lost at that stage, but is below the SFmode
6220;; rounding position.
6221(define_expand "floatdisf2_internal2"
994cf173
AM
6222 [(set (match_dup 3) (ashiftrt:DI (match_operand:DI 1 "" "")
6223 (const_int 53)))
6224 (parallel [(set (match_operand:DI 0 "" "") (and:DI (match_dup 1)
6225 (const_int 2047)))
6226 (clobber (scratch:CC))])
6227 (set (match_dup 3) (plus:DI (match_dup 3)
6228 (const_int 1)))
6229 (set (match_dup 0) (plus:DI (match_dup 0)
6230 (const_int 2047)))
6231 (set (match_dup 4) (compare:CCUNS (match_dup 3)
c22e62a6 6232 (const_int 2)))
994cf173
AM
6233 (set (match_dup 0) (ior:DI (match_dup 0)
6234 (match_dup 1)))
6235 (parallel [(set (match_dup 0) (and:DI (match_dup 0)
6236 (const_int -2048)))
6237 (clobber (scratch:CC))])
6238 (set (pc) (if_then_else (geu (match_dup 4) (const_int 0))
6239 (label_ref (match_operand:DI 2 "" ""))
678b7733 6240 (pc)))
994cf173
AM
6241 (set (match_dup 0) (match_dup 1))]
6242 "TARGET_POWERPC64 && TARGET_HARD_FLOAT && TARGET_FPRS"
678b7733
AM
6243 "
6244{
678b7733 6245 operands[3] = gen_reg_rtx (DImode);
994cf173 6246 operands[4] = gen_reg_rtx (CCUNSmode);
678b7733 6247}")
1fd4e8c1
RK
6248\f
6249;; Define the DImode operations that can be done in a small number
a6ec530c
RK
6250;; of instructions. The & constraints are to prevent the register
6251;; allocator from allocating registers that overlap with the inputs
6252;; (for example, having an input in 7,8 and an output in 6,7). We
38e01259 6253;; also allow for the output being the same as one of the inputs.
a6ec530c 6254
266eb58a 6255(define_insn "*adddi3_noppc64"
a6ec530c
RK
6256 [(set (match_operand:DI 0 "gpc_reg_operand" "=&r,&r,r,r")
6257 (plus:DI (match_operand:DI 1 "gpc_reg_operand" "%r,r,0,0")
6258 (match_operand:DI 2 "reg_or_short_operand" "r,I,r,I")))]
e1f83b4d 6259 "! TARGET_POWERPC64"
0f645302
MM
6260 "*
6261{
6262 if (WORDS_BIG_ENDIAN)
6263 return (GET_CODE (operands[2])) != CONST_INT
6264 ? \"{a|addc} %L0,%L1,%L2\;{ae|adde} %0,%1,%2\"
6265 : \"{ai|addic} %L0,%L1,%2\;{a%G2e|add%G2e} %0,%1\";
6266 else
6267 return (GET_CODE (operands[2])) != CONST_INT
6268 ? \"{a|addc} %0,%1,%2\;{ae|adde} %L0,%L1,%L2\"
6269 : \"{ai|addic} %0,%1,%2\;{a%G2e|add%G2e} %L0,%L1\";
6270}"
943c15ed
DE
6271 [(set_attr "type" "two")
6272 (set_attr "length" "8")])
1fd4e8c1 6273
266eb58a 6274(define_insn "*subdi3_noppc64"
e7e5df70
RK
6275 [(set (match_operand:DI 0 "gpc_reg_operand" "=&r,&r,r,r,r")
6276 (minus:DI (match_operand:DI 1 "reg_or_short_operand" "r,I,0,r,I")
6277 (match_operand:DI 2 "gpc_reg_operand" "r,r,r,0,0")))]
266eb58a 6278 "! TARGET_POWERPC64"
5502823b
RK
6279 "*
6280{
0f645302
MM
6281 if (WORDS_BIG_ENDIAN)
6282 return (GET_CODE (operands[1]) != CONST_INT)
6283 ? \"{sf|subfc} %L0,%L2,%L1\;{sfe|subfe} %0,%2,%1\"
6284 : \"{sfi|subfic} %L0,%L2,%1\;{sf%G1e|subf%G1e} %0,%2\";
6285 else
6286 return (GET_CODE (operands[1]) != CONST_INT)
6287 ? \"{sf|subfc} %0,%2,%1\;{sfe|subfe} %L0,%L2,%L1\"
6288 : \"{sfi|subfic} %0,%2,%1\;{sf%G1e|subf%G1e} %L0,%L2\";
5502823b 6289}"
943c15ed
DE
6290 [(set_attr "type" "two")
6291 (set_attr "length" "8")])
ca7f5001 6292
266eb58a 6293(define_insn "*negdi2_noppc64"
a6ec530c
RK
6294 [(set (match_operand:DI 0 "gpc_reg_operand" "=&r,r")
6295 (neg:DI (match_operand:DI 1 "gpc_reg_operand" "r,0")))]
51b8fc2c 6296 "! TARGET_POWERPC64"
5502823b
RK
6297 "*
6298{
6299 return (WORDS_BIG_ENDIAN)
6300 ? \"{sfi|subfic} %L0,%L1,0\;{sfze|subfze} %0,%1\"
6301 : \"{sfi|subfic} %0,%1,0\;{sfze|subfze} %L0,%L1\";
6302}"
943c15ed
DE
6303 [(set_attr "type" "two")
6304 (set_attr "length" "8")])
ca7f5001 6305
8ffd9c51
RK
6306(define_expand "mulsidi3"
6307 [(set (match_operand:DI 0 "gpc_reg_operand" "")
6308 (mult:DI (sign_extend:DI (match_operand:SI 1 "gpc_reg_operand" ""))
6309 (sign_extend:DI (match_operand:SI 2 "gpc_reg_operand" ""))))]
a2f270cc 6310 "! TARGET_POWERPC64"
8ffd9c51
RK
6311 "
6312{
6313 if (! TARGET_POWER && ! TARGET_POWERPC)
6314 {
39403d82
DE
6315 emit_move_insn (gen_rtx_REG (SImode, 3), operands[1]);
6316 emit_move_insn (gen_rtx_REG (SImode, 4), operands[2]);
fada905b 6317 emit_insn (gen_mull_call ());
cf27b467 6318 if (WORDS_BIG_ENDIAN)
39403d82 6319 emit_move_insn (operands[0], gen_rtx_REG (DImode, 3));
cf27b467
MM
6320 else
6321 {
6322 emit_move_insn (operand_subword (operands[0], 0, 0, DImode),
39403d82 6323 gen_rtx_REG (SImode, 3));
cf27b467 6324 emit_move_insn (operand_subword (operands[0], 1, 0, DImode),
39403d82 6325 gen_rtx_REG (SImode, 4));
cf27b467 6326 }
8ffd9c51
RK
6327 DONE;
6328 }
6329 else if (TARGET_POWER)
6330 {
6331 emit_insn (gen_mulsidi3_mq (operands[0], operands[1], operands[2]));
6332 DONE;
6333 }
6334}")
deb9225a 6335
8ffd9c51 6336(define_insn "mulsidi3_mq"
cd2b37d9 6337 [(set (match_operand:DI 0 "gpc_reg_operand" "=r")
8ffd9c51 6338 (mult:DI (sign_extend:DI (match_operand:SI 1 "gpc_reg_operand" "%r"))
cd2b37d9 6339 (sign_extend:DI (match_operand:SI 2 "gpc_reg_operand" "r"))))
1fd4e8c1 6340 (clobber (match_scratch:SI 3 "=q"))]
ca7f5001 6341 "TARGET_POWER"
b19003d8 6342 "mul %0,%1,%2\;mfmq %L0"
8ffd9c51
RK
6343 [(set_attr "type" "imul")
6344 (set_attr "length" "8")])
deb9225a 6345
f192bf8b 6346(define_insn "*mulsidi3_no_mq"
425c176f 6347 [(set (match_operand:DI 0 "gpc_reg_operand" "=&r")
8ffd9c51
RK
6348 (mult:DI (sign_extend:DI (match_operand:SI 1 "gpc_reg_operand" "%r"))
6349 (sign_extend:DI (match_operand:SI 2 "gpc_reg_operand" "r"))))]
f192bf8b 6350 "TARGET_POWERPC && ! TARGET_POWER && ! TARGET_POWERPC64"
5502823b
RK
6351 "*
6352{
6353 return (WORDS_BIG_ENDIAN)
6354 ? \"mulhw %0,%1,%2\;mullw %L0,%1,%2\"
6355 : \"mulhw %L0,%1,%2\;mullw %0,%1,%2\";
6356}"
8ffd9c51
RK
6357 [(set_attr "type" "imul")
6358 (set_attr "length" "8")])
deb9225a 6359
ebedb4dd
MM
6360(define_split
6361 [(set (match_operand:DI 0 "gpc_reg_operand" "")
6362 (mult:DI (sign_extend:DI (match_operand:SI 1 "gpc_reg_operand" ""))
6363 (sign_extend:DI (match_operand:SI 2 "gpc_reg_operand" ""))))]
cf27b467 6364 "TARGET_POWERPC && ! TARGET_POWERPC64 && reload_completed"
ebedb4dd
MM
6365 [(set (match_dup 3)
6366 (truncate:SI
6367 (lshiftrt:DI (mult:DI (sign_extend:DI (match_dup 1))
6368 (sign_extend:DI (match_dup 2)))
6369 (const_int 32))))
6370 (set (match_dup 4)
6371 (mult:SI (match_dup 1)
6372 (match_dup 2)))]
6373 "
6374{
6375 int endian = (WORDS_BIG_ENDIAN == 0);
6376 operands[3] = operand_subword (operands[0], endian, 0, DImode);
6377 operands[4] = operand_subword (operands[0], 1 - endian, 0, DImode);
6378}")
6379
f192bf8b
DE
6380(define_expand "umulsidi3"
6381 [(set (match_operand:DI 0 "gpc_reg_operand" "")
6382 (mult:DI (zero_extend:DI (match_operand:SI 1 "gpc_reg_operand" ""))
6383 (zero_extend:DI (match_operand:SI 2 "gpc_reg_operand" ""))))]
6384 "TARGET_POWERPC && ! TARGET_POWERPC64"
6385 "
6386{
6387 if (TARGET_POWER)
6388 {
6389 emit_insn (gen_umulsidi3_mq (operands[0], operands[1], operands[2]));
6390 DONE;
6391 }
6392}")
6393
6394(define_insn "umulsidi3_mq"
6395 [(set (match_operand:DI 0 "gpc_reg_operand" "=&r")
6396 (mult:DI (zero_extend:DI (match_operand:SI 1 "gpc_reg_operand" "%r"))
6397 (zero_extend:DI (match_operand:SI 2 "gpc_reg_operand" "r"))))
6398 (clobber (match_scratch:SI 3 "=q"))]
6399 "TARGET_POWERPC && TARGET_POWER"
6400 "*
6401{
6402 return (WORDS_BIG_ENDIAN)
6403 ? \"mulhwu %0,%1,%2\;mullw %L0,%1,%2\"
6404 : \"mulhwu %L0,%1,%2\;mullw %0,%1,%2\";
6405}"
6406 [(set_attr "type" "imul")
6407 (set_attr "length" "8")])
6408
6409(define_insn "*umulsidi3_no_mq"
8106dc08
MM
6410 [(set (match_operand:DI 0 "gpc_reg_operand" "=&r")
6411 (mult:DI (zero_extend:DI (match_operand:SI 1 "gpc_reg_operand" "%r"))
6412 (zero_extend:DI (match_operand:SI 2 "gpc_reg_operand" "r"))))]
f192bf8b 6413 "TARGET_POWERPC && ! TARGET_POWER && ! TARGET_POWERPC64"
8106dc08
MM
6414 "*
6415{
6416 return (WORDS_BIG_ENDIAN)
6417 ? \"mulhwu %0,%1,%2\;mullw %L0,%1,%2\"
6418 : \"mulhwu %L0,%1,%2\;mullw %0,%1,%2\";
6419}"
6420 [(set_attr "type" "imul")
6421 (set_attr "length" "8")])
6422
ebedb4dd
MM
6423(define_split
6424 [(set (match_operand:DI 0 "gpc_reg_operand" "")
6425 (mult:DI (zero_extend:DI (match_operand:SI 1 "gpc_reg_operand" ""))
6426 (zero_extend:DI (match_operand:SI 2 "gpc_reg_operand" ""))))]
cf27b467 6427 "TARGET_POWERPC && ! TARGET_POWERPC64 && reload_completed"
ebedb4dd
MM
6428 [(set (match_dup 3)
6429 (truncate:SI
6430 (lshiftrt:DI (mult:DI (zero_extend:DI (match_dup 1))
6431 (zero_extend:DI (match_dup 2)))
6432 (const_int 32))))
6433 (set (match_dup 4)
6434 (mult:SI (match_dup 1)
6435 (match_dup 2)))]
6436 "
6437{
6438 int endian = (WORDS_BIG_ENDIAN == 0);
6439 operands[3] = operand_subword (operands[0], endian, 0, DImode);
6440 operands[4] = operand_subword (operands[0], 1 - endian, 0, DImode);
6441}")
6442
8ffd9c51
RK
6443(define_expand "smulsi3_highpart"
6444 [(set (match_operand:SI 0 "gpc_reg_operand" "")
6445 (truncate:SI
6446 (lshiftrt:DI (mult:DI (sign_extend:DI
e42ac3de 6447 (match_operand:SI 1 "gpc_reg_operand" ""))
8ffd9c51 6448 (sign_extend:DI
e42ac3de 6449 (match_operand:SI 2 "gpc_reg_operand" "")))
8ffd9c51
RK
6450 (const_int 32))))]
6451 ""
6452 "
6453{
6454 if (! TARGET_POWER && ! TARGET_POWERPC)
6455 {
39403d82
DE
6456 emit_move_insn (gen_rtx_REG (SImode, 3), operands[1]);
6457 emit_move_insn (gen_rtx_REG (SImode, 4), operands[2]);
fada905b 6458 emit_insn (gen_mulh_call ());
39403d82 6459 emit_move_insn (operands[0], gen_rtx_REG (SImode, 3));
8ffd9c51
RK
6460 DONE;
6461 }
6462 else if (TARGET_POWER)
6463 {
6464 emit_insn (gen_smulsi3_highpart_mq (operands[0], operands[1], operands[2]));
6465 DONE;
6466 }
6467}")
deb9225a 6468
8ffd9c51
RK
6469(define_insn "smulsi3_highpart_mq"
6470 [(set (match_operand:SI 0 "gpc_reg_operand" "=r")
6471 (truncate:SI
fada905b
MM
6472 (lshiftrt:DI (mult:DI (sign_extend:DI
6473 (match_operand:SI 1 "gpc_reg_operand" "%r"))
6474 (sign_extend:DI
6475 (match_operand:SI 2 "gpc_reg_operand" "r")))
8ffd9c51
RK
6476 (const_int 32))))
6477 (clobber (match_scratch:SI 3 "=q"))]
6478 "TARGET_POWER"
6479 "mul %0,%1,%2"
6480 [(set_attr "type" "imul")])
deb9225a 6481
f192bf8b 6482(define_insn "*smulsi3_highpart_no_mq"
8ffd9c51
RK
6483 [(set (match_operand:SI 0 "gpc_reg_operand" "=r")
6484 (truncate:SI
fada905b
MM
6485 (lshiftrt:DI (mult:DI (sign_extend:DI
6486 (match_operand:SI 1 "gpc_reg_operand" "%r"))
6487 (sign_extend:DI
6488 (match_operand:SI 2 "gpc_reg_operand" "r")))
8ffd9c51 6489 (const_int 32))))]
f192bf8b 6490 "TARGET_POWERPC && ! TARGET_POWER"
8ffd9c51
RK
6491 "mulhw %0,%1,%2"
6492 [(set_attr "type" "imul")])
deb9225a 6493
f192bf8b
DE
6494(define_expand "umulsi3_highpart"
6495 [(set (match_operand:SI 0 "gpc_reg_operand" "")
6496 (truncate:SI
6497 (lshiftrt:DI (mult:DI (zero_extend:DI
6498 (match_operand:SI 1 "gpc_reg_operand" ""))
6499 (zero_extend:DI
6500 (match_operand:SI 2 "gpc_reg_operand" "")))
6501 (const_int 32))))]
6502 "TARGET_POWERPC"
6503 "
6504{
6505 if (TARGET_POWER)
6506 {
6507 emit_insn (gen_umulsi3_highpart_mq (operands[0], operands[1], operands[2]));
6508 DONE;
6509 }
6510}")
6511
6512(define_insn "umulsi3_highpart_mq"
6513 [(set (match_operand:SI 0 "gpc_reg_operand" "=r")
6514 (truncate:SI
6515 (lshiftrt:DI (mult:DI (zero_extend:DI
6516 (match_operand:SI 1 "gpc_reg_operand" "%r"))
6517 (zero_extend:DI
6518 (match_operand:SI 2 "gpc_reg_operand" "r")))
6519 (const_int 32))))
6520 (clobber (match_scratch:SI 3 "=q"))]
6521 "TARGET_POWERPC && TARGET_POWER"
6522 "mulhwu %0,%1,%2"
6523 [(set_attr "type" "imul")])
6524
6525(define_insn "*umulsi3_highpart_no_mq"
266eb58a
DE
6526 [(set (match_operand:SI 0 "gpc_reg_operand" "=r")
6527 (truncate:SI
6528 (lshiftrt:DI (mult:DI (zero_extend:DI
6529 (match_operand:SI 1 "gpc_reg_operand" "%r"))
6530 (zero_extend:DI
6531 (match_operand:SI 2 "gpc_reg_operand" "r")))
6532 (const_int 32))))]
f192bf8b 6533 "TARGET_POWERPC && ! TARGET_POWER"
266eb58a
DE
6534 "mulhwu %0,%1,%2"
6535 [(set_attr "type" "imul")])
6536
6537;; If operands 0 and 2 are in the same register, we have a problem. But
6538;; operands 0 and 1 (the usual case) can be in the same register. That's
6539;; why we have the strange constraints below.
6540(define_insn "ashldi3_power"
6541 [(set (match_operand:DI 0 "gpc_reg_operand" "=r,r,r,&r")
6542 (ashift:DI (match_operand:DI 1 "gpc_reg_operand" "r,r,0,r")
6543 (match_operand:SI 2 "reg_or_cint_operand" "M,i,r,r")))
6544 (clobber (match_scratch:SI 3 "=X,q,q,q"))]
6545 "TARGET_POWER"
6546 "@
6547 {sli|slwi} %0,%L1,%h2\;{cal %L0,0(0)|li %L0,0}
6548 sl%I2q %L0,%L1,%h2\;sll%I2q %0,%1,%h2
6549 sl%I2q %L0,%L1,%h2\;sll%I2q %0,%1,%h2
6550 sl%I2q %L0,%L1,%h2\;sll%I2q %0,%1,%h2"
6551 [(set_attr "length" "8")])
6552
6553(define_insn "lshrdi3_power"
47ad8c61 6554 [(set (match_operand:DI 0 "gpc_reg_operand" "=r,r,r,&r")
266eb58a
DE
6555 (lshiftrt:DI (match_operand:DI 1 "gpc_reg_operand" "r,r,0,r")
6556 (match_operand:SI 2 "reg_or_cint_operand" "M,i,r,r")))
6557 (clobber (match_scratch:SI 3 "=X,q,q,q"))]
6558 "TARGET_POWER"
6559 "@
47ad8c61 6560 {s%A2i|s%A2wi} %L0,%1,%h2\;{cal %0,0(0)|li %0,0}
266eb58a
DE
6561 sr%I2q %0,%1,%h2\;srl%I2q %L0,%L1,%h2
6562 sr%I2q %0,%1,%h2\;srl%I2q %L0,%L1,%h2
6563 sr%I2q %0,%1,%h2\;srl%I2q %L0,%L1,%h2"
6564 [(set_attr "length" "8")])
6565
6566;; Shift by a variable amount is too complex to be worth open-coding. We
6567;; just handle shifts by constants.
6568(define_insn "ashrdi3_power"
7093ddee 6569 [(set (match_operand:DI 0 "gpc_reg_operand" "=&r,r")
266eb58a
DE
6570 (ashiftrt:DI (match_operand:DI 1 "gpc_reg_operand" "r,r")
6571 (match_operand:SI 2 "const_int_operand" "M,i")))
6572 (clobber (match_scratch:SI 3 "=X,q"))]
6573 "TARGET_POWER"
6574 "@
6575 {srai|srawi} %0,%1,31\;{srai|srawi} %L0,%1,%h2
6576 sraiq %0,%1,%h2\;srliq %L0,%L1,%h2"
44cd321e
PS
6577 [(set_attr "type" "shift")
6578 (set_attr "length" "8")])
4aa74a4f
FS
6579
6580(define_insn "ashrdi3_no_power"
6581 [(set (match_operand:DI 0 "gpc_reg_operand" "=&r,&r")
6582 (ashiftrt:DI (match_operand:DI 1 "gpc_reg_operand" "r,r")
6583 (match_operand:SI 2 "const_int_operand" "M,i")))]
97727e85 6584 "TARGET_32BIT && !TARGET_POWERPC64 && !TARGET_POWER && WORDS_BIG_ENDIAN"
4aa74a4f
FS
6585 "@
6586 {srai|srawi} %0,%1,31\;{srai|srawi} %L0,%1,%h2
6587 {sri|srwi} %L0,%L1,%h2\;insrwi %L0,%1,%h2,0\;{srai|srawi} %0,%1,%h2"
943c15ed
DE
6588 [(set_attr "type" "two,three")
6589 (set_attr "length" "8,12")])
683bdff7
FJ
6590
6591(define_insn "*ashrdisi3_noppc64"
6592 [(set (match_operand:SI 0 "gpc_reg_operand" "=r")
6ae08853 6593 (subreg:SI (ashiftrt:DI (match_operand:DI 1 "gpc_reg_operand" "r")
683bdff7
FJ
6594 (const_int 32)) 4))]
6595 "TARGET_32BIT && !TARGET_POWERPC64"
6596 "*
6597{
6598 if (REGNO (operands[0]) == REGNO (operands[1]))
6599 return \"\";
6600 else
6601 return \"mr %0,%1\";
6602}"
6ae08853 6603 [(set_attr "length" "4")])
683bdff7 6604
266eb58a
DE
6605\f
6606;; PowerPC64 DImode operations.
6607
ea112fc4 6608(define_insn_and_split "absdi2"
266eb58a 6609 [(set (match_operand:DI 0 "gpc_reg_operand" "=&r,r")
ea112fc4 6610 (abs:DI (match_operand:DI 1 "gpc_reg_operand" "r,0")))
266eb58a
DE
6611 (clobber (match_scratch:DI 2 "=&r,&r"))]
6612 "TARGET_POWERPC64"
ea112fc4
DE
6613 "#"
6614 "&& reload_completed"
a260abc9 6615 [(set (match_dup 2) (ashiftrt:DI (match_dup 1) (const_int 63)))
266eb58a 6616 (set (match_dup 0) (xor:DI (match_dup 2) (match_dup 1)))
a238cd8b 6617 (set (match_dup 0) (minus:DI (match_dup 0) (match_dup 2)))]
266eb58a
DE
6618 "")
6619
ea112fc4 6620(define_insn_and_split "*nabsdi2"
266eb58a 6621 [(set (match_operand:DI 0 "gpc_reg_operand" "=&r,r")
ea112fc4 6622 (neg:DI (abs:DI (match_operand:DI 1 "gpc_reg_operand" "r,0"))))
266eb58a
DE
6623 (clobber (match_scratch:DI 2 "=&r,&r"))]
6624 "TARGET_POWERPC64"
ea112fc4
DE
6625 "#"
6626 "&& reload_completed"
a260abc9 6627 [(set (match_dup 2) (ashiftrt:DI (match_dup 1) (const_int 63)))
266eb58a 6628 (set (match_dup 0) (xor:DI (match_dup 2) (match_dup 1)))
19ba8161 6629 (set (match_dup 0) (minus:DI (match_dup 2) (match_dup 0)))]
266eb58a
DE
6630 "")
6631
266eb58a 6632(define_insn "muldi3"
c9692532
DE
6633 [(set (match_operand:DI 0 "gpc_reg_operand" "=r,r")
6634 (mult:DI (match_operand:DI 1 "gpc_reg_operand" "%r,r")
6635 (match_operand:DI 2 "reg_or_short_operand" "r,I")))]
266eb58a 6636 "TARGET_POWERPC64"
c9692532
DE
6637 "@
6638 mulld %0,%1,%2
6639 mulli %0,%1,%2"
6640 [(set (attr "type")
6641 (cond [(match_operand:SI 2 "s8bit_cint_operand" "")
6642 (const_string "imul3")
6643 (match_operand:SI 2 "short_cint_operand" "")
6644 (const_string "imul2")]
6645 (const_string "lmul")))])
266eb58a 6646
9259f3b0
DE
6647(define_insn "*muldi3_internal1"
6648 [(set (match_operand:CC 0 "cc_reg_operand" "=x,?y")
6649 (compare:CC (mult:DI (match_operand:DI 1 "gpc_reg_operand" "%r,r")
6650 (match_operand:DI 2 "gpc_reg_operand" "r,r"))
6651 (const_int 0)))
6652 (clobber (match_scratch:DI 3 "=r,r"))]
6653 "TARGET_POWERPC64"
6654 "@
6655 mulld. %3,%1,%2
6656 #"
6657 [(set_attr "type" "lmul_compare")
6658 (set_attr "length" "4,8")])
6659
6660(define_split
6661 [(set (match_operand:CC 0 "cc_reg_not_cr0_operand" "")
6662 (compare:CC (mult:DI (match_operand:DI 1 "gpc_reg_operand" "")
6663 (match_operand:DI 2 "gpc_reg_operand" ""))
6664 (const_int 0)))
6665 (clobber (match_scratch:DI 3 ""))]
6666 "TARGET_POWERPC64 && reload_completed"
6667 [(set (match_dup 3)
6668 (mult:DI (match_dup 1) (match_dup 2)))
6669 (set (match_dup 0)
6670 (compare:CC (match_dup 3)
6671 (const_int 0)))]
6672 "")
6673
6674(define_insn "*muldi3_internal2"
6675 [(set (match_operand:CC 3 "cc_reg_operand" "=x,?y")
6676 (compare:CC (mult:DI (match_operand:DI 1 "gpc_reg_operand" "%r,r")
6677 (match_operand:DI 2 "gpc_reg_operand" "r,r"))
6678 (const_int 0)))
6679 (set (match_operand:DI 0 "gpc_reg_operand" "=r,r")
6680 (mult:DI (match_dup 1) (match_dup 2)))]
6681 "TARGET_POWERPC64"
6682 "@
6683 mulld. %0,%1,%2
6684 #"
6685 [(set_attr "type" "lmul_compare")
6686 (set_attr "length" "4,8")])
6687
6688(define_split
6689 [(set (match_operand:CC 3 "cc_reg_not_cr0_operand" "")
6690 (compare:CC (mult:DI (match_operand:DI 1 "gpc_reg_operand" "")
6691 (match_operand:DI 2 "gpc_reg_operand" ""))
6692 (const_int 0)))
6693 (set (match_operand:DI 0 "gpc_reg_operand" "")
6694 (mult:DI (match_dup 1) (match_dup 2)))]
6695 "TARGET_POWERPC64 && reload_completed"
6696 [(set (match_dup 0)
6697 (mult:DI (match_dup 1) (match_dup 2)))
6698 (set (match_dup 3)
6699 (compare:CC (match_dup 0)
6700 (const_int 0)))]
6701 "")
6702
266eb58a
DE
6703(define_insn "smuldi3_highpart"
6704 [(set (match_operand:DI 0 "gpc_reg_operand" "=r")
6705 (truncate:DI
6706 (lshiftrt:TI (mult:TI (sign_extend:TI
6707 (match_operand:DI 1 "gpc_reg_operand" "%r"))
6708 (sign_extend:TI
6709 (match_operand:DI 2 "gpc_reg_operand" "r")))
6710 (const_int 64))))]
6711 "TARGET_POWERPC64"
6712 "mulhd %0,%1,%2"
3cb999d8 6713 [(set_attr "type" "lmul")])
266eb58a
DE
6714
6715(define_insn "umuldi3_highpart"
6716 [(set (match_operand:DI 0 "gpc_reg_operand" "=r")
6717 (truncate:DI
6718 (lshiftrt:TI (mult:TI (zero_extend:TI
6719 (match_operand:DI 1 "gpc_reg_operand" "%r"))
6720 (zero_extend:TI
6721 (match_operand:DI 2 "gpc_reg_operand" "r")))
6722 (const_int 64))))]
6723 "TARGET_POWERPC64"
6724 "mulhdu %0,%1,%2"
3cb999d8 6725 [(set_attr "type" "lmul")])
266eb58a 6726
266eb58a 6727(define_insn "rotldi3"
44cd321e
PS
6728 [(set (match_operand:DI 0 "gpc_reg_operand" "=r,r")
6729 (rotate:DI (match_operand:DI 1 "gpc_reg_operand" "r,r")
6730 (match_operand:DI 2 "reg_or_cint_operand" "r,i")))]
266eb58a 6731 "TARGET_POWERPC64"
44cd321e
PS
6732 "@
6733 rldcl %0,%1,%2,0
6734 rldicl %0,%1,%H2,0"
6735 [(set_attr "type" "var_shift_rotate,integer")])
266eb58a 6736
a260abc9 6737(define_insn "*rotldi3_internal2"
44cd321e
PS
6738 [(set (match_operand:CC 0 "cc_reg_operand" "=x,x,?y,?y")
6739 (compare:CC (rotate:DI (match_operand:DI 1 "gpc_reg_operand" "r,r,r,r")
6740 (match_operand:DI 2 "reg_or_cint_operand" "r,i,r,i"))
266eb58a 6741 (const_int 0)))
44cd321e 6742 (clobber (match_scratch:DI 3 "=r,r,r,r"))]
683bdff7 6743 "TARGET_64BIT"
9ebbca7d 6744 "@
44cd321e
PS
6745 rldcl. %3,%1,%2,0
6746 rldicl. %3,%1,%H2,0
6747 #
9ebbca7d 6748 #"
44cd321e
PS
6749 [(set_attr "type" "var_delayed_compare,delayed_compare,var_delayed_compare,delayed_compare")
6750 (set_attr "length" "4,4,8,8")])
9ebbca7d
GK
6751
6752(define_split
6753 [(set (match_operand:CC 0 "cc_reg_not_cr0_operand" "")
6754 (compare:CC (rotate:DI (match_operand:DI 1 "gpc_reg_operand" "")
6755 (match_operand:DI 2 "reg_or_cint_operand" ""))
6756 (const_int 0)))
6757 (clobber (match_scratch:DI 3 ""))]
6758 "TARGET_POWERPC64 && reload_completed"
6759 [(set (match_dup 3)
6760 (rotate:DI (match_dup 1) (match_dup 2)))
6761 (set (match_dup 0)
6762 (compare:CC (match_dup 3)
6763 (const_int 0)))]
6764 "")
266eb58a 6765
a260abc9 6766(define_insn "*rotldi3_internal3"
44cd321e
PS
6767 [(set (match_operand:CC 3 "cc_reg_operand" "=x,x,?y,?y")
6768 (compare:CC (rotate:DI (match_operand:DI 1 "gpc_reg_operand" "r,r,r,r")
6769 (match_operand:DI 2 "reg_or_cint_operand" "r,i,r,i"))
266eb58a 6770 (const_int 0)))
44cd321e 6771 (set (match_operand:DI 0 "gpc_reg_operand" "=r,r,r,r")
266eb58a 6772 (rotate:DI (match_dup 1) (match_dup 2)))]
683bdff7 6773 "TARGET_64BIT"
9ebbca7d 6774 "@
44cd321e
PS
6775 rldcl. %0,%1,%2,0
6776 rldicl. %0,%1,%H2,0
6777 #
9ebbca7d 6778 #"
44cd321e
PS
6779 [(set_attr "type" "var_delayed_compare,delayed_compare,var_delayed_compare,delayed_compare")
6780 (set_attr "length" "4,4,8,8")])
9ebbca7d
GK
6781
6782(define_split
6783 [(set (match_operand:CC 3 "cc_reg_not_cr0_operand" "")
6784 (compare:CC (rotate:DI (match_operand:DI 1 "gpc_reg_operand" "")
6785 (match_operand:DI 2 "reg_or_cint_operand" ""))
6786 (const_int 0)))
6787 (set (match_operand:DI 0 "gpc_reg_operand" "")
6788 (rotate:DI (match_dup 1) (match_dup 2)))]
6789 "TARGET_POWERPC64 && reload_completed"
6790 [(set (match_dup 0)
6791 (rotate:DI (match_dup 1) (match_dup 2)))
6792 (set (match_dup 3)
6793 (compare:CC (match_dup 0)
6794 (const_int 0)))]
6795 "")
266eb58a 6796
a260abc9 6797(define_insn "*rotldi3_internal4"
44cd321e
PS
6798 [(set (match_operand:DI 0 "gpc_reg_operand" "=r,r")
6799 (and:DI (rotate:DI (match_operand:DI 1 "gpc_reg_operand" "r,r")
6800 (match_operand:DI 2 "reg_or_cint_operand" "r,i"))
6801 (match_operand:DI 3 "mask64_operand" "n,n")))]
a260abc9 6802 "TARGET_POWERPC64"
44cd321e
PS
6803 "@
6804 rldc%B3 %0,%1,%2,%S3
6805 rldic%B3 %0,%1,%H2,%S3"
6806 [(set_attr "type" "var_shift_rotate,integer")])
a260abc9
DE
6807
6808(define_insn "*rotldi3_internal5"
44cd321e 6809 [(set (match_operand:CC 0 "cc_reg_operand" "=x,x,?y,?y")
a260abc9 6810 (compare:CC (and:DI
44cd321e
PS
6811 (rotate:DI (match_operand:DI 1 "gpc_reg_operand" "r,r,r,r")
6812 (match_operand:DI 2 "reg_or_cint_operand" "r,i,r,i"))
6813 (match_operand:DI 3 "mask64_operand" "n,n,n,n"))
a260abc9 6814 (const_int 0)))
44cd321e 6815 (clobber (match_scratch:DI 4 "=r,r,r,r"))]
683bdff7 6816 "TARGET_64BIT"
9ebbca7d 6817 "@
44cd321e
PS
6818 rldc%B3. %4,%1,%2,%S3
6819 rldic%B3. %4,%1,%H2,%S3
6820 #
9ebbca7d 6821 #"
44cd321e
PS
6822 [(set_attr "type" "var_delayed_compare,delayed_compare,var_delayed_compare,delayed_compare")
6823 (set_attr "length" "4,4,8,8")])
9ebbca7d
GK
6824
6825(define_split
6826 [(set (match_operand:CC 0 "cc_reg_not_cr0_operand" "")
6827 (compare:CC (and:DI
6828 (rotate:DI (match_operand:DI 1 "gpc_reg_operand" "")
6829 (match_operand:DI 2 "reg_or_cint_operand" ""))
1990cd79 6830 (match_operand:DI 3 "mask64_operand" ""))
9ebbca7d
GK
6831 (const_int 0)))
6832 (clobber (match_scratch:DI 4 ""))]
6833 "TARGET_POWERPC64 && reload_completed"
6834 [(set (match_dup 4)
6835 (and:DI (rotate:DI (match_dup 1)
6836 (match_dup 2))
6837 (match_dup 3)))
6838 (set (match_dup 0)
6839 (compare:CC (match_dup 4)
6840 (const_int 0)))]
6841 "")
a260abc9
DE
6842
6843(define_insn "*rotldi3_internal6"
44cd321e 6844 [(set (match_operand:CC 4 "cc_reg_operand" "=x,x,?y,?y")
a260abc9 6845 (compare:CC (and:DI
44cd321e
PS
6846 (rotate:DI (match_operand:DI 1 "gpc_reg_operand" "r,r,r,r")
6847 (match_operand:DI 2 "reg_or_cint_operand" "r,i,r,i"))
6848 (match_operand:DI 3 "mask64_operand" "n,n,n,n"))
a260abc9 6849 (const_int 0)))
44cd321e 6850 (set (match_operand:DI 0 "gpc_reg_operand" "=r,r,r,r")
a260abc9 6851 (and:DI (rotate:DI (match_dup 1) (match_dup 2)) (match_dup 3)))]
683bdff7 6852 "TARGET_64BIT"
9ebbca7d 6853 "@
44cd321e
PS
6854 rldc%B3. %0,%1,%2,%S3
6855 rldic%B3. %0,%1,%H2,%S3
6856 #
9ebbca7d 6857 #"
44cd321e
PS
6858 [(set_attr "type" "var_delayed_compare,delayed_compare,var_delayed_compare,delayed_compare")
6859 (set_attr "length" "4,4,8,8")])
9ebbca7d
GK
6860
6861(define_split
6862 [(set (match_operand:CC 4 "cc_reg_not_cr0_operand" "")
6863 (compare:CC (and:DI
6864 (rotate:DI (match_operand:DI 1 "gpc_reg_operand" "")
6865 (match_operand:DI 2 "reg_or_cint_operand" ""))
1990cd79 6866 (match_operand:DI 3 "mask64_operand" ""))
9ebbca7d
GK
6867 (const_int 0)))
6868 (set (match_operand:DI 0 "gpc_reg_operand" "")
6869 (and:DI (rotate:DI (match_dup 1) (match_dup 2)) (match_dup 3)))]
6870 "TARGET_POWERPC64 && reload_completed"
6871 [(set (match_dup 0)
6872 (and:DI (rotate:DI (match_dup 1) (match_dup 2)) (match_dup 3)))
6873 (set (match_dup 4)
6874 (compare:CC (match_dup 0)
6875 (const_int 0)))]
6876 "")
a260abc9
DE
6877
6878(define_insn "*rotldi3_internal7"
44cd321e 6879 [(set (match_operand:DI 0 "gpc_reg_operand" "=r,r")
a260abc9
DE
6880 (zero_extend:DI
6881 (subreg:QI
44cd321e
PS
6882 (rotate:DI (match_operand:DI 1 "gpc_reg_operand" "r,r")
6883 (match_operand:DI 2 "reg_or_cint_operand" "r,i")) 0)))]
a260abc9 6884 "TARGET_POWERPC64"
44cd321e
PS
6885 "@
6886 rldcl %0,%1,%2,56
6887 rldicl %0,%1,%H2,56"
6888 [(set_attr "type" "var_shift_rotate,integer")])
a260abc9
DE
6889
6890(define_insn "*rotldi3_internal8"
44cd321e 6891 [(set (match_operand:CC 0 "cc_reg_operand" "=x,x,?y,?y")
a260abc9
DE
6892 (compare:CC (zero_extend:DI
6893 (subreg:QI
44cd321e
PS
6894 (rotate:DI (match_operand:DI 1 "gpc_reg_operand" "r,r,r,r")
6895 (match_operand:DI 2 "reg_or_cint_operand" "r,i,r,i")) 0))
a260abc9 6896 (const_int 0)))
44cd321e 6897 (clobber (match_scratch:DI 3 "=r,r,r,r"))]
683bdff7 6898 "TARGET_64BIT"
9ebbca7d 6899 "@
44cd321e
PS
6900 rldcl. %3,%1,%2,56
6901 rldicl. %3,%1,%H2,56
6902 #
9ebbca7d 6903 #"
44cd321e
PS
6904 [(set_attr "type" "var_delayed_compare,delayed_compare,var_delayed_compare,delayed_compare")
6905 (set_attr "length" "4,4,8,8")])
9ebbca7d
GK
6906
6907(define_split
6908 [(set (match_operand:CC 0 "cc_reg_not_cr0_operand" "")
6909 (compare:CC (zero_extend:DI
6910 (subreg:QI
6911 (rotate:DI (match_operand:DI 1 "gpc_reg_operand" "")
6912 (match_operand:DI 2 "reg_or_cint_operand" "")) 0))
6913 (const_int 0)))
6914 (clobber (match_scratch:DI 3 ""))]
6915 "TARGET_POWERPC64 && reload_completed"
6916 [(set (match_dup 3)
6917 (zero_extend:DI (subreg:QI
6918 (rotate:DI (match_dup 1)
6919 (match_dup 2)) 0)))
6920 (set (match_dup 0)
6921 (compare:CC (match_dup 3)
6922 (const_int 0)))]
6923 "")
a260abc9
DE
6924
6925(define_insn "*rotldi3_internal9"
44cd321e 6926 [(set (match_operand:CC 3 "cc_reg_operand" "=x,x,?y,?y")
a260abc9
DE
6927 (compare:CC (zero_extend:DI
6928 (subreg:QI
44cd321e
PS
6929 (rotate:DI (match_operand:DI 1 "gpc_reg_operand" "r,r,r,r")
6930 (match_operand:DI 2 "reg_or_cint_operand" "r,i,r,i")) 0))
a260abc9 6931 (const_int 0)))
44cd321e 6932 (set (match_operand:DI 0 "gpc_reg_operand" "=r,r,r,r")
a260abc9 6933 (zero_extend:DI (subreg:QI (rotate:DI (match_dup 1) (match_dup 2)) 0)))]
683bdff7 6934 "TARGET_64BIT"
9ebbca7d 6935 "@
44cd321e
PS
6936 rldcl. %0,%1,%2,56
6937 rldicl. %0,%1,%H2,56
6938 #
9ebbca7d 6939 #"
44cd321e
PS
6940 [(set_attr "type" "var_delayed_compare,delayed_compare,var_delayed_compare,delayed_compare")
6941 (set_attr "length" "4,4,8,8")])
9ebbca7d
GK
6942
6943(define_split
6944 [(set (match_operand:CC 3 "cc_reg_not_cr0_operand" "")
6945 (compare:CC (zero_extend:DI
6946 (subreg:QI
6947 (rotate:DI (match_operand:DI 1 "gpc_reg_operand" "")
6948 (match_operand:DI 2 "reg_or_cint_operand" "")) 0))
6949 (const_int 0)))
6950 (set (match_operand:DI 0 "gpc_reg_operand" "")
6951 (zero_extend:DI (subreg:QI (rotate:DI (match_dup 1) (match_dup 2)) 0)))]
6952 "TARGET_POWERPC64 && reload_completed"
6953 [(set (match_dup 0)
6954 (zero_extend:DI (subreg:QI (rotate:DI (match_dup 1) (match_dup 2)) 0)))
6955 (set (match_dup 3)
6956 (compare:CC (match_dup 0)
6957 (const_int 0)))]
6958 "")
a260abc9
DE
6959
6960(define_insn "*rotldi3_internal10"
44cd321e 6961 [(set (match_operand:DI 0 "gpc_reg_operand" "=r,r")
a260abc9
DE
6962 (zero_extend:DI
6963 (subreg:HI
44cd321e
PS
6964 (rotate:DI (match_operand:DI 1 "gpc_reg_operand" "r,r")
6965 (match_operand:DI 2 "reg_or_cint_operand" "r,i")) 0)))]
a260abc9 6966 "TARGET_POWERPC64"
44cd321e
PS
6967 "@
6968 rldcl %0,%1,%2,48
6969 rldicl %0,%1,%H2,48"
6970 [(set_attr "type" "var_shift_rotate,integer")])
a260abc9
DE
6971
6972(define_insn "*rotldi3_internal11"
44cd321e 6973 [(set (match_operand:CC 0 "cc_reg_operand" "=x,x,?y,?y")
a260abc9
DE
6974 (compare:CC (zero_extend:DI
6975 (subreg:HI
44cd321e
PS
6976 (rotate:DI (match_operand:DI 1 "gpc_reg_operand" "r,r,r,r")
6977 (match_operand:DI 2 "reg_or_cint_operand" "r,i,r,i")) 0))
a260abc9 6978 (const_int 0)))
44cd321e 6979 (clobber (match_scratch:DI 3 "=r,r,r,r"))]
683bdff7 6980 "TARGET_64BIT"
9ebbca7d 6981 "@
44cd321e
PS
6982 rldcl. %3,%1,%2,48
6983 rldicl. %3,%1,%H2,48
6984 #
9ebbca7d 6985 #"
44cd321e
PS
6986 [(set_attr "type" "var_delayed_compare,delayed_compare,var_delayed_compare,delayed_compare")
6987 (set_attr "length" "4,4,8,8")])
9ebbca7d
GK
6988
6989(define_split
6990 [(set (match_operand:CC 0 "cc_reg_not_cr0_operand" "")
6991 (compare:CC (zero_extend:DI
6992 (subreg:HI
6993 (rotate:DI (match_operand:DI 1 "gpc_reg_operand" "")
6994 (match_operand:DI 2 "reg_or_cint_operand" "")) 0))
6995 (const_int 0)))
6996 (clobber (match_scratch:DI 3 ""))]
6997 "TARGET_POWERPC64 && reload_completed"
6998 [(set (match_dup 3)
6999 (zero_extend:DI (subreg:HI
7000 (rotate:DI (match_dup 1)
7001 (match_dup 2)) 0)))
7002 (set (match_dup 0)
7003 (compare:CC (match_dup 3)
7004 (const_int 0)))]
7005 "")
a260abc9
DE
7006
7007(define_insn "*rotldi3_internal12"
44cd321e 7008 [(set (match_operand:CC 3 "cc_reg_operand" "=x,x,?y,?y")
a260abc9
DE
7009 (compare:CC (zero_extend:DI
7010 (subreg:HI
44cd321e
PS
7011 (rotate:DI (match_operand:DI 1 "gpc_reg_operand" "r,r,r,r")
7012 (match_operand:DI 2 "reg_or_cint_operand" "r,i,r,i")) 0))
a260abc9 7013 (const_int 0)))
44cd321e 7014 (set (match_operand:DI 0 "gpc_reg_operand" "=r,r,r,r")
a260abc9 7015 (zero_extend:DI (subreg:HI (rotate:DI (match_dup 1) (match_dup 2)) 0)))]
683bdff7 7016 "TARGET_64BIT"
9ebbca7d 7017 "@
44cd321e
PS
7018 rldcl. %0,%1,%2,48
7019 rldicl. %0,%1,%H2,48
7020 #
9ebbca7d 7021 #"
44cd321e
PS
7022 [(set_attr "type" "var_delayed_compare,delayed_compare,var_delayed_compare,delayed_compare")
7023 (set_attr "length" "4,4,8,8")])
9ebbca7d
GK
7024
7025(define_split
7026 [(set (match_operand:CC 3 "cc_reg_not_cr0_operand" "")
7027 (compare:CC (zero_extend:DI
7028 (subreg:HI
7029 (rotate:DI (match_operand:DI 1 "gpc_reg_operand" "")
7030 (match_operand:DI 2 "reg_or_cint_operand" "")) 0))
7031 (const_int 0)))
7032 (set (match_operand:DI 0 "gpc_reg_operand" "")
7033 (zero_extend:DI (subreg:HI (rotate:DI (match_dup 1) (match_dup 2)) 0)))]
7034 "TARGET_POWERPC64 && reload_completed"
7035 [(set (match_dup 0)
7036 (zero_extend:DI (subreg:HI (rotate:DI (match_dup 1) (match_dup 2)) 0)))
7037 (set (match_dup 3)
7038 (compare:CC (match_dup 0)
7039 (const_int 0)))]
7040 "")
a260abc9
DE
7041
7042(define_insn "*rotldi3_internal13"
44cd321e 7043 [(set (match_operand:DI 0 "gpc_reg_operand" "=r,r")
a260abc9
DE
7044 (zero_extend:DI
7045 (subreg:SI
44cd321e
PS
7046 (rotate:DI (match_operand:DI 1 "gpc_reg_operand" "r,r")
7047 (match_operand:DI 2 "reg_or_cint_operand" "r,i")) 0)))]
a260abc9 7048 "TARGET_POWERPC64"
44cd321e
PS
7049 "@
7050 rldcl %0,%1,%2,32
7051 rldicl %0,%1,%H2,32"
7052 [(set_attr "type" "var_shift_rotate,integer")])
a260abc9
DE
7053
7054(define_insn "*rotldi3_internal14"
44cd321e 7055 [(set (match_operand:CC 0 "cc_reg_operand" "=x,x,?y,?y")
a260abc9
DE
7056 (compare:CC (zero_extend:DI
7057 (subreg:SI
44cd321e
PS
7058 (rotate:DI (match_operand:DI 1 "gpc_reg_operand" "r,r,r,r")
7059 (match_operand:DI 2 "reg_or_cint_operand" "r,i,r,i")) 0))
a260abc9 7060 (const_int 0)))
44cd321e 7061 (clobber (match_scratch:DI 3 "=r,r,r,r"))]
683bdff7 7062 "TARGET_64BIT"
9ebbca7d 7063 "@
44cd321e
PS
7064 rldcl. %3,%1,%2,32
7065 rldicl. %3,%1,%H2,32
7066 #
9ebbca7d 7067 #"
44cd321e
PS
7068 [(set_attr "type" "var_delayed_compare,delayed_compare,var_delayed_compare,delayed_compare")
7069 (set_attr "length" "4,4,8,8")])
9ebbca7d
GK
7070
7071(define_split
7072 [(set (match_operand:CC 0 "cc_reg_not_cr0_operand" "")
7073 (compare:CC (zero_extend:DI
7074 (subreg:SI
7075 (rotate:DI (match_operand:DI 1 "gpc_reg_operand" "")
7076 (match_operand:DI 2 "reg_or_cint_operand" "")) 0))
7077 (const_int 0)))
7078 (clobber (match_scratch:DI 3 ""))]
7079 "TARGET_POWERPC64 && reload_completed"
7080 [(set (match_dup 3)
7081 (zero_extend:DI (subreg:SI
7082 (rotate:DI (match_dup 1)
7083 (match_dup 2)) 0)))
7084 (set (match_dup 0)
7085 (compare:CC (match_dup 3)
7086 (const_int 0)))]
7087 "")
a260abc9
DE
7088
7089(define_insn "*rotldi3_internal15"
44cd321e 7090 [(set (match_operand:CC 3 "cc_reg_operand" "=x,x,?y,?y")
a260abc9
DE
7091 (compare:CC (zero_extend:DI
7092 (subreg:SI
44cd321e
PS
7093 (rotate:DI (match_operand:DI 1 "gpc_reg_operand" "r,r,r,r")
7094 (match_operand:DI 2 "reg_or_cint_operand" "r,i,r,i")) 0))
a260abc9 7095 (const_int 0)))
44cd321e 7096 (set (match_operand:DI 0 "gpc_reg_operand" "=r,r,r,r")
a260abc9 7097 (zero_extend:DI (subreg:SI (rotate:DI (match_dup 1) (match_dup 2)) 0)))]
683bdff7 7098 "TARGET_64BIT"
9ebbca7d 7099 "@
44cd321e
PS
7100 rldcl. %0,%1,%2,32
7101 rldicl. %0,%1,%H2,32
7102 #
9ebbca7d 7103 #"
44cd321e
PS
7104 [(set_attr "type" "var_delayed_compare,delayed_compare,var_delayed_compare,delayed_compare")
7105 (set_attr "length" "4,4,8,8")])
9ebbca7d
GK
7106
7107(define_split
7108 [(set (match_operand:CC 3 "cc_reg_not_cr0_operand" "")
7109 (compare:CC (zero_extend:DI
7110 (subreg:SI
7111 (rotate:DI (match_operand:DI 1 "gpc_reg_operand" "")
7112 (match_operand:DI 2 "reg_or_cint_operand" "")) 0))
7113 (const_int 0)))
7114 (set (match_operand:DI 0 "gpc_reg_operand" "")
7115 (zero_extend:DI (subreg:SI (rotate:DI (match_dup 1) (match_dup 2)) 0)))]
7116 "TARGET_POWERPC64 && reload_completed"
7117 [(set (match_dup 0)
7118 (zero_extend:DI (subreg:SI (rotate:DI (match_dup 1) (match_dup 2)) 0)))
7119 (set (match_dup 3)
7120 (compare:CC (match_dup 0)
7121 (const_int 0)))]
7122 "")
a260abc9 7123
266eb58a
DE
7124(define_expand "ashldi3"
7125 [(set (match_operand:DI 0 "gpc_reg_operand" "")
7126 (ashift:DI (match_operand:DI 1 "gpc_reg_operand" "")
7127 (match_operand:SI 2 "reg_or_cint_operand" "")))]
7128 "TARGET_POWERPC64 || TARGET_POWER"
7129 "
7130{
7131 if (TARGET_POWERPC64)
7132 ;
7133 else if (TARGET_POWER)
7134 {
7135 emit_insn (gen_ashldi3_power (operands[0], operands[1], operands[2]));
7136 DONE;
7137 }
7138 else
7139 FAIL;
7140}")
7141
e2c953b6 7142(define_insn "*ashldi3_internal1"
44cd321e
PS
7143 [(set (match_operand:DI 0 "gpc_reg_operand" "=r,r")
7144 (ashift:DI (match_operand:DI 1 "gpc_reg_operand" "r,r")
7145 (match_operand:SI 2 "reg_or_cint_operand" "r,i")))]
266eb58a 7146 "TARGET_POWERPC64"
44cd321e
PS
7147 "@
7148 sld %0,%1,%2
7149 sldi %0,%1,%H2"
7150 [(set_attr "type" "var_shift_rotate,shift")])
6ae08853 7151
e2c953b6 7152(define_insn "*ashldi3_internal2"
44cd321e
PS
7153 [(set (match_operand:CC 0 "cc_reg_operand" "=x,x,?y,?y")
7154 (compare:CC (ashift:DI (match_operand:DI 1 "gpc_reg_operand" "r,r,r,r")
7155 (match_operand:SI 2 "reg_or_cint_operand" "r,i,r,i"))
266eb58a 7156 (const_int 0)))
44cd321e 7157 (clobber (match_scratch:DI 3 "=r,r,r,r"))]
683bdff7 7158 "TARGET_64BIT"
9ebbca7d 7159 "@
44cd321e
PS
7160 sld. %3,%1,%2
7161 sldi. %3,%1,%H2
7162 #
9ebbca7d 7163 #"
44cd321e
PS
7164 [(set_attr "type" "var_delayed_compare,delayed_compare,var_delayed_compare,delayed_compare")
7165 (set_attr "length" "4,4,8,8")])
6ae08853 7166
9ebbca7d
GK
7167(define_split
7168 [(set (match_operand:CC 0 "cc_reg_not_cr0_operand" "")
7169 (compare:CC (ashift:DI (match_operand:DI 1 "gpc_reg_operand" "")
7170 (match_operand:SI 2 "reg_or_cint_operand" ""))
7171 (const_int 0)))
7172 (clobber (match_scratch:DI 3 ""))]
7173 "TARGET_POWERPC64 && reload_completed"
7174 [(set (match_dup 3)
7175 (ashift:DI (match_dup 1) (match_dup 2)))
7176 (set (match_dup 0)
7177 (compare:CC (match_dup 3)
7178 (const_int 0)))]
7179 "")
7180
e2c953b6 7181(define_insn "*ashldi3_internal3"
44cd321e
PS
7182 [(set (match_operand:CC 3 "cc_reg_operand" "=x,x,?y,?y")
7183 (compare:CC (ashift:DI (match_operand:DI 1 "gpc_reg_operand" "r,r,r,r")
7184 (match_operand:SI 2 "reg_or_cint_operand" "r,i,r,i"))
266eb58a 7185 (const_int 0)))
44cd321e 7186 (set (match_operand:DI 0 "gpc_reg_operand" "=r,r,r,r")
266eb58a 7187 (ashift:DI (match_dup 1) (match_dup 2)))]
683bdff7 7188 "TARGET_64BIT"
9ebbca7d 7189 "@
44cd321e
PS
7190 sld. %0,%1,%2
7191 sldi. %0,%1,%H2
7192 #
9ebbca7d 7193 #"
44cd321e
PS
7194 [(set_attr "type" "var_delayed_compare,delayed_compare,var_delayed_compare,delayed_compare")
7195 (set_attr "length" "4,4,8,8")])
9ebbca7d
GK
7196
7197(define_split
7198 [(set (match_operand:CC 3 "cc_reg_not_cr0_operand" "")
7199 (compare:CC (ashift:DI (match_operand:DI 1 "gpc_reg_operand" "")
7200 (match_operand:SI 2 "reg_or_cint_operand" ""))
7201 (const_int 0)))
7202 (set (match_operand:DI 0 "gpc_reg_operand" "")
7203 (ashift:DI (match_dup 1) (match_dup 2)))]
7204 "TARGET_POWERPC64 && reload_completed"
7205 [(set (match_dup 0)
7206 (ashift:DI (match_dup 1) (match_dup 2)))
7207 (set (match_dup 3)
7208 (compare:CC (match_dup 0)
7209 (const_int 0)))]
7210 "")
266eb58a 7211
e2c953b6 7212(define_insn "*ashldi3_internal4"
3cb999d8
DE
7213 [(set (match_operand:DI 0 "gpc_reg_operand" "=r")
7214 (and:DI (ashift:DI (match_operand:DI 1 "gpc_reg_operand" "r")
7215 (match_operand:SI 2 "const_int_operand" "i"))
c5059423
AM
7216 (match_operand:DI 3 "const_int_operand" "n")))]
7217 "TARGET_POWERPC64 && includes_rldic_lshift_p (operands[2], operands[3])"
e2c953b6 7218 "rldic %0,%1,%H2,%W3")
3cb999d8 7219
e2c953b6 7220(define_insn "ashldi3_internal5"
9ebbca7d 7221 [(set (match_operand:CC 0 "cc_reg_operand" "=x,?y")
3cb999d8 7222 (compare:CC
9ebbca7d
GK
7223 (and:DI (ashift:DI (match_operand:DI 1 "gpc_reg_operand" "r,r")
7224 (match_operand:SI 2 "const_int_operand" "i,i"))
c5059423 7225 (match_operand:DI 3 "const_int_operand" "n,n"))
3cb999d8 7226 (const_int 0)))
9ebbca7d 7227 (clobber (match_scratch:DI 4 "=r,r"))]
683bdff7 7228 "TARGET_64BIT && includes_rldic_lshift_p (operands[2], operands[3])"
9ebbca7d 7229 "@
e2c953b6 7230 rldic. %4,%1,%H2,%W3
9ebbca7d 7231 #"
9c6fdb46 7232 [(set_attr "type" "compare")
9ebbca7d
GK
7233 (set_attr "length" "4,8")])
7234
7235(define_split
7236 [(set (match_operand:CC 0 "cc_reg_not_cr0_operand" "")
7237 (compare:CC
7238 (and:DI (ashift:DI (match_operand:DI 1 "gpc_reg_operand" "")
7239 (match_operand:SI 2 "const_int_operand" ""))
c5059423 7240 (match_operand:DI 3 "const_int_operand" ""))
9ebbca7d
GK
7241 (const_int 0)))
7242 (clobber (match_scratch:DI 4 ""))]
c5059423
AM
7243 "TARGET_POWERPC64 && reload_completed
7244 && includes_rldic_lshift_p (operands[2], operands[3])"
9ebbca7d
GK
7245 [(set (match_dup 4)
7246 (and:DI (ashift:DI (match_dup 1) (match_dup 2))
e2c953b6 7247 (match_dup 3)))
9ebbca7d
GK
7248 (set (match_dup 0)
7249 (compare:CC (match_dup 4)
7250 (const_int 0)))]
7251 "")
3cb999d8 7252
e2c953b6 7253(define_insn "*ashldi3_internal6"
9ebbca7d 7254 [(set (match_operand:CC 4 "cc_reg_operand" "=x,?y")
3cb999d8 7255 (compare:CC
9ebbca7d
GK
7256 (and:DI (ashift:DI (match_operand:DI 1 "gpc_reg_operand" "r,r")
7257 (match_operand:SI 2 "const_int_operand" "i,i"))
c5059423 7258 (match_operand:DI 3 "const_int_operand" "n,n"))
3cb999d8 7259 (const_int 0)))
9ebbca7d 7260 (set (match_operand:DI 0 "gpc_reg_operand" "=r,r")
3cb999d8 7261 (and:DI (ashift:DI (match_dup 1) (match_dup 2)) (match_dup 3)))]
683bdff7 7262 "TARGET_64BIT && includes_rldic_lshift_p (operands[2], operands[3])"
9ebbca7d 7263 "@
e2c953b6 7264 rldic. %0,%1,%H2,%W3
9ebbca7d 7265 #"
9c6fdb46 7266 [(set_attr "type" "compare")
9ebbca7d
GK
7267 (set_attr "length" "4,8")])
7268
7269(define_split
7270 [(set (match_operand:CC 4 "cc_reg_not_cr0_operand" "")
7271 (compare:CC
7272 (and:DI (ashift:DI (match_operand:DI 1 "gpc_reg_operand" "")
7273 (match_operand:SI 2 "const_int_operand" ""))
c5059423 7274 (match_operand:DI 3 "const_int_operand" ""))
9ebbca7d
GK
7275 (const_int 0)))
7276 (set (match_operand:DI 0 "gpc_reg_operand" "")
7277 (and:DI (ashift:DI (match_dup 1) (match_dup 2)) (match_dup 3)))]
c5059423
AM
7278 "TARGET_POWERPC64 && reload_completed
7279 && includes_rldic_lshift_p (operands[2], operands[3])"
7280 [(set (match_dup 0)
7281 (and:DI (ashift:DI (match_dup 1) (match_dup 2))
7282 (match_dup 3)))
7283 (set (match_dup 4)
7284 (compare:CC (match_dup 0)
7285 (const_int 0)))]
7286 "")
7287
7288(define_insn "*ashldi3_internal7"
7289 [(set (match_operand:DI 0 "gpc_reg_operand" "=r")
7290 (and:DI (ashift:DI (match_operand:DI 1 "gpc_reg_operand" "r")
7291 (match_operand:SI 2 "const_int_operand" "i"))
1990cd79 7292 (match_operand:DI 3 "mask64_operand" "n")))]
c5059423
AM
7293 "TARGET_POWERPC64 && includes_rldicr_lshift_p (operands[2], operands[3])"
7294 "rldicr %0,%1,%H2,%S3")
7295
7296(define_insn "ashldi3_internal8"
7297 [(set (match_operand:CC 0 "cc_reg_operand" "=x,?y")
7298 (compare:CC
7299 (and:DI (ashift:DI (match_operand:DI 1 "gpc_reg_operand" "r,r")
7300 (match_operand:SI 2 "const_int_operand" "i,i"))
1990cd79 7301 (match_operand:DI 3 "mask64_operand" "n,n"))
c5059423
AM
7302 (const_int 0)))
7303 (clobber (match_scratch:DI 4 "=r,r"))]
683bdff7 7304 "TARGET_64BIT && includes_rldicr_lshift_p (operands[2], operands[3])"
c5059423
AM
7305 "@
7306 rldicr. %4,%1,%H2,%S3
7307 #"
9c6fdb46 7308 [(set_attr "type" "compare")
c5059423
AM
7309 (set_attr "length" "4,8")])
7310
7311(define_split
7312 [(set (match_operand:CC 0 "cc_reg_not_cr0_operand" "")
7313 (compare:CC
7314 (and:DI (ashift:DI (match_operand:DI 1 "gpc_reg_operand" "")
7315 (match_operand:SI 2 "const_int_operand" ""))
1990cd79 7316 (match_operand:DI 3 "mask64_operand" ""))
c5059423
AM
7317 (const_int 0)))
7318 (clobber (match_scratch:DI 4 ""))]
7319 "TARGET_POWERPC64 && reload_completed
7320 && includes_rldicr_lshift_p (operands[2], operands[3])"
7321 [(set (match_dup 4)
7322 (and:DI (ashift:DI (match_dup 1) (match_dup 2))
7323 (match_dup 3)))
7324 (set (match_dup 0)
7325 (compare:CC (match_dup 4)
7326 (const_int 0)))]
7327 "")
7328
7329(define_insn "*ashldi3_internal9"
7330 [(set (match_operand:CC 4 "cc_reg_operand" "=x,?y")
7331 (compare:CC
7332 (and:DI (ashift:DI (match_operand:DI 1 "gpc_reg_operand" "r,r")
7333 (match_operand:SI 2 "const_int_operand" "i,i"))
1990cd79 7334 (match_operand:DI 3 "mask64_operand" "n,n"))
c5059423
AM
7335 (const_int 0)))
7336 (set (match_operand:DI 0 "gpc_reg_operand" "=r,r")
7337 (and:DI (ashift:DI (match_dup 1) (match_dup 2)) (match_dup 3)))]
683bdff7 7338 "TARGET_64BIT && includes_rldicr_lshift_p (operands[2], operands[3])"
c5059423
AM
7339 "@
7340 rldicr. %0,%1,%H2,%S3
7341 #"
9c6fdb46 7342 [(set_attr "type" "compare")
c5059423
AM
7343 (set_attr "length" "4,8")])
7344
7345(define_split
7346 [(set (match_operand:CC 4 "cc_reg_not_cr0_operand" "")
7347 (compare:CC
7348 (and:DI (ashift:DI (match_operand:DI 1 "gpc_reg_operand" "")
7349 (match_operand:SI 2 "const_int_operand" ""))
1990cd79 7350 (match_operand:DI 3 "mask64_operand" ""))
c5059423
AM
7351 (const_int 0)))
7352 (set (match_operand:DI 0 "gpc_reg_operand" "")
7353 (and:DI (ashift:DI (match_dup 1) (match_dup 2)) (match_dup 3)))]
7354 "TARGET_POWERPC64 && reload_completed
7355 && includes_rldicr_lshift_p (operands[2], operands[3])"
9ebbca7d 7356 [(set (match_dup 0)
e2c953b6
DE
7357 (and:DI (ashift:DI (match_dup 1) (match_dup 2))
7358 (match_dup 3)))
9ebbca7d
GK
7359 (set (match_dup 4)
7360 (compare:CC (match_dup 0)
7361 (const_int 0)))]
7362 "")
7363
7364(define_expand "lshrdi3"
266eb58a
DE
7365 [(set (match_operand:DI 0 "gpc_reg_operand" "")
7366 (lshiftrt:DI (match_operand:DI 1 "gpc_reg_operand" "")
7367 (match_operand:SI 2 "reg_or_cint_operand" "")))]
7368 "TARGET_POWERPC64 || TARGET_POWER"
7369 "
7370{
7371 if (TARGET_POWERPC64)
7372 ;
7373 else if (TARGET_POWER)
7374 {
7375 emit_insn (gen_lshrdi3_power (operands[0], operands[1], operands[2]));
7376 DONE;
7377 }
7378 else
7379 FAIL;
7380}")
7381
e2c953b6 7382(define_insn "*lshrdi3_internal1"
44cd321e
PS
7383 [(set (match_operand:DI 0 "gpc_reg_operand" "=r,r")
7384 (lshiftrt:DI (match_operand:DI 1 "gpc_reg_operand" "r,r")
7385 (match_operand:SI 2 "reg_or_cint_operand" "r,i")))]
266eb58a 7386 "TARGET_POWERPC64"
44cd321e
PS
7387 "@
7388 srd %0,%1,%2
7389 srdi %0,%1,%H2"
7390 [(set_attr "type" "var_shift_rotate,shift")])
266eb58a 7391
e2c953b6 7392(define_insn "*lshrdi3_internal2"
44cd321e
PS
7393 [(set (match_operand:CC 0 "cc_reg_operand" "=x,x,?y,?y")
7394 (compare:CC (lshiftrt:DI (match_operand:DI 1 "gpc_reg_operand" "r,r,r,r")
7395 (match_operand:SI 2 "reg_or_cint_operand" "r,i,r,i"))
29ae5b89 7396 (const_int 0)))
44cd321e 7397 (clobber (match_scratch:DI 3 "=r,r,r,r"))]
683bdff7 7398 "TARGET_64BIT "
9ebbca7d 7399 "@
44cd321e
PS
7400 srd. %3,%1,%2
7401 srdi. %3,%1,%H2
7402 #
9ebbca7d 7403 #"
44cd321e
PS
7404 [(set_attr "type" "var_delayed_compare,delayed_compare,var_delayed_compare,delayed_compare")
7405 (set_attr "length" "4,4,8,8")])
9ebbca7d
GK
7406
7407(define_split
7408 [(set (match_operand:CC 0 "cc_reg_not_cr0_operand" "")
7409 (compare:CC (lshiftrt:DI (match_operand:DI 1 "gpc_reg_operand" "")
7410 (match_operand:SI 2 "reg_or_cint_operand" ""))
7411 (const_int 0)))
7412 (clobber (match_scratch:DI 3 ""))]
7413 "TARGET_POWERPC64 && reload_completed"
7414 [(set (match_dup 3)
7415 (lshiftrt:DI (match_dup 1) (match_dup 2)))
7416 (set (match_dup 0)
7417 (compare:CC (match_dup 3)
7418 (const_int 0)))]
7419 "")
266eb58a 7420
e2c953b6 7421(define_insn "*lshrdi3_internal3"
44cd321e
PS
7422 [(set (match_operand:CC 3 "cc_reg_operand" "=x,x,?y,?y")
7423 (compare:CC (lshiftrt:DI (match_operand:DI 1 "gpc_reg_operand" "r,r,r,r")
7424 (match_operand:SI 2 "reg_or_cint_operand" "r,i,r,i"))
266eb58a 7425 (const_int 0)))
44cd321e 7426 (set (match_operand:DI 0 "gpc_reg_operand" "=r,r,r,r")
29ae5b89 7427 (lshiftrt:DI (match_dup 1) (match_dup 2)))]
683bdff7 7428 "TARGET_64BIT"
9ebbca7d 7429 "@
44cd321e
PS
7430 srd. %0,%1,%2
7431 srdi. %0,%1,%H2
7432 #
9ebbca7d 7433 #"
44cd321e
PS
7434 [(set_attr "type" "var_delayed_compare,delayed_compare,var_delayed_compare,delayed_compare")
7435 (set_attr "length" "4,4,8,8")])
9ebbca7d
GK
7436
7437(define_split
7438 [(set (match_operand:CC 3 "cc_reg_not_cr0_operand" "")
7439 (compare:CC (lshiftrt:DI (match_operand:DI 1 "gpc_reg_operand" "")
7440 (match_operand:SI 2 "reg_or_cint_operand" ""))
7441 (const_int 0)))
7442 (set (match_operand:DI 0 "gpc_reg_operand" "")
7443 (lshiftrt:DI (match_dup 1) (match_dup 2)))]
7444 "TARGET_POWERPC64 && reload_completed"
7445 [(set (match_dup 0)
7446 (lshiftrt:DI (match_dup 1) (match_dup 2)))
7447 (set (match_dup 3)
7448 (compare:CC (match_dup 0)
7449 (const_int 0)))]
7450 "")
266eb58a
DE
7451
7452(define_expand "ashrdi3"
7453 [(set (match_operand:DI 0 "gpc_reg_operand" "")
7454 (ashiftrt:DI (match_operand:DI 1 "gpc_reg_operand" "")
7455 (match_operand:SI 2 "reg_or_cint_operand" "")))]
97727e85 7456 "WORDS_BIG_ENDIAN"
266eb58a
DE
7457 "
7458{
7459 if (TARGET_POWERPC64)
7460 ;
7461 else if (TARGET_POWER && GET_CODE (operands[2]) == CONST_INT)
7462 {
7463 emit_insn (gen_ashrdi3_power (operands[0], operands[1], operands[2]));
7464 DONE;
7465 }
97727e85
AH
7466 else if (TARGET_32BIT && GET_CODE (operands[2]) == CONST_INT
7467 && WORDS_BIG_ENDIAN)
4aa74a4f
FS
7468 {
7469 emit_insn (gen_ashrdi3_no_power (operands[0], operands[1], operands[2]));
7470 DONE;
7471 }
266eb58a
DE
7472 else
7473 FAIL;
7474}")
7475
e2c953b6 7476(define_insn "*ashrdi3_internal1"
44cd321e
PS
7477 [(set (match_operand:DI 0 "gpc_reg_operand" "=r,r")
7478 (ashiftrt:DI (match_operand:DI 1 "gpc_reg_operand" "r,r")
7479 (match_operand:SI 2 "reg_or_cint_operand" "r,i")))]
266eb58a 7480 "TARGET_POWERPC64"
44cd321e
PS
7481 "@
7482 srad %0,%1,%2
7483 sradi %0,%1,%H2"
7484 [(set_attr "type" "var_shift_rotate,shift")])
266eb58a 7485
e2c953b6 7486(define_insn "*ashrdi3_internal2"
44cd321e
PS
7487 [(set (match_operand:CC 0 "cc_reg_operand" "=x,x,?y,?y")
7488 (compare:CC (ashiftrt:DI (match_operand:DI 1 "gpc_reg_operand" "r,r,r,r")
7489 (match_operand:SI 2 "reg_or_cint_operand" "r,i,r,i"))
266eb58a 7490 (const_int 0)))
44cd321e 7491 (clobber (match_scratch:DI 3 "=r,r,r,r"))]
683bdff7 7492 "TARGET_64BIT"
9ebbca7d 7493 "@
44cd321e
PS
7494 srad. %3,%1,%2
7495 sradi. %3,%1,%H2
7496 #
9ebbca7d 7497 #"
44cd321e
PS
7498 [(set_attr "type" "var_delayed_compare,delayed_compare,var_delayed_compare,delayed_compare")
7499 (set_attr "length" "4,4,8,8")])
9ebbca7d
GK
7500
7501(define_split
7502 [(set (match_operand:CC 0 "cc_reg_not_cr0_operand" "")
7503 (compare:CC (ashiftrt:DI (match_operand:DI 1 "gpc_reg_operand" "")
7504 (match_operand:SI 2 "reg_or_cint_operand" ""))
7505 (const_int 0)))
7506 (clobber (match_scratch:DI 3 ""))]
7507 "TARGET_POWERPC64 && reload_completed"
7508 [(set (match_dup 3)
7509 (ashiftrt:DI (match_dup 1) (match_dup 2)))
7510 (set (match_dup 0)
7511 (compare:CC (match_dup 3)
7512 (const_int 0)))]
7513 "")
266eb58a 7514
e2c953b6 7515(define_insn "*ashrdi3_internal3"
44cd321e
PS
7516 [(set (match_operand:CC 3 "cc_reg_operand" "=x,x,?y,?y")
7517 (compare:CC (ashiftrt:DI (match_operand:DI 1 "gpc_reg_operand" "r,r,r,r")
7518 (match_operand:SI 2 "reg_or_cint_operand" "r,i,r,i"))
266eb58a 7519 (const_int 0)))
44cd321e 7520 (set (match_operand:DI 0 "gpc_reg_operand" "=r,r,r,r")
266eb58a 7521 (ashiftrt:DI (match_dup 1) (match_dup 2)))]
683bdff7 7522 "TARGET_64BIT"
9ebbca7d 7523 "@
44cd321e
PS
7524 srad. %0,%1,%2
7525 sradi. %0,%1,%H2
7526 #
9ebbca7d 7527 #"
44cd321e
PS
7528 [(set_attr "type" "var_delayed_compare,delayed_compare,var_delayed_compare,delayed_compare")
7529 (set_attr "length" "4,4,8,8")])
9ebbca7d
GK
7530
7531(define_split
7532 [(set (match_operand:CC 3 "cc_reg_not_cr0_operand" "")
7533 (compare:CC (ashiftrt:DI (match_operand:DI 1 "gpc_reg_operand" "")
7534 (match_operand:SI 2 "reg_or_cint_operand" ""))
7535 (const_int 0)))
7536 (set (match_operand:DI 0 "gpc_reg_operand" "")
7537 (ashiftrt:DI (match_dup 1) (match_dup 2)))]
7538 "TARGET_POWERPC64 && reload_completed"
7539 [(set (match_dup 0)
7540 (ashiftrt:DI (match_dup 1) (match_dup 2)))
7541 (set (match_dup 3)
7542 (compare:CC (match_dup 0)
7543 (const_int 0)))]
7544 "")
815cdc52 7545
29ae5b89 7546(define_insn "anddi3"
e1e2e653
NS
7547 [(set (match_operand:DI 0 "gpc_reg_operand" "=r,r,r,r,r,r")
7548 (and:DI (match_operand:DI 1 "gpc_reg_operand" "%r,r,r,r,r,r")
7549 (match_operand:DI 2 "and64_2_operand" "?r,S,T,K,J,t")))
7550 (clobber (match_scratch:CC 3 "=X,X,X,x,x,X"))]
6ffc8580 7551 "TARGET_POWERPC64"
266eb58a
DE
7552 "@
7553 and %0,%1,%2
29ae5b89 7554 rldic%B2 %0,%1,0,%S2
e1e2e653 7555 rlwinm %0,%1,0,%m2,%M2
29ae5b89 7556 andi. %0,%1,%b2
0ba1b2ff
AM
7557 andis. %0,%1,%u2
7558 #"
e1e2e653
NS
7559 [(set_attr "type" "*,*,*,compare,compare,*")
7560 (set_attr "length" "4,4,4,4,4,8")])
0ba1b2ff
AM
7561
7562(define_split
7563 [(set (match_operand:DI 0 "gpc_reg_operand" "")
7564 (and:DI (match_operand:DI 1 "gpc_reg_operand" "")
7565 (match_operand:DI 2 "mask64_2_operand" "")))
7566 (clobber (match_scratch:CC 3 ""))]
7567 "TARGET_POWERPC64
7568 && (fixed_regs[CR0_REGNO] || !logical_operand (operands[2], DImode))
1990cd79
AM
7569 && !mask_operand (operands[2], DImode)
7570 && !mask64_operand (operands[2], DImode)"
0ba1b2ff
AM
7571 [(set (match_dup 0)
7572 (and:DI (rotate:DI (match_dup 1)
7573 (match_dup 4))
7574 (match_dup 5)))
7575 (set (match_dup 0)
7576 (and:DI (rotate:DI (match_dup 0)
7577 (match_dup 6))
7578 (match_dup 7)))]
0ba1b2ff
AM
7579{
7580 build_mask64_2_operands (operands[2], &operands[4]);
e1e2e653 7581})
266eb58a 7582
a260abc9 7583(define_insn "*anddi3_internal2"
1990cd79
AM
7584 [(set (match_operand:CC 0 "cc_reg_operand" "=x,x,x,x,x,x,?y,?y,?y,??y,??y,?y")
7585 (compare:CC (and:DI (match_operand:DI 1 "gpc_reg_operand" "%r,r,r,r,r,r,r,r,r,r,r,r")
7586 (match_operand:DI 2 "and64_2_operand" "r,S,T,K,J,t,r,S,T,K,J,t"))
266eb58a 7587 (const_int 0)))
1990cd79
AM
7588 (clobber (match_scratch:DI 3 "=r,r,r,r,r,r,r,r,r,r,r,r"))
7589 (clobber (match_scratch:CC 4 "=X,X,X,X,X,X,X,X,X,x,x,X"))]
683bdff7 7590 "TARGET_64BIT"
266eb58a
DE
7591 "@
7592 and. %3,%1,%2
6c873122 7593 rldic%B2. %3,%1,0,%S2
1990cd79 7594 rlwinm. %3,%1,0,%m2,%M2
6ffc8580
MM
7595 andi. %3,%1,%b2
7596 andis. %3,%1,%u2
9ebbca7d
GK
7597 #
7598 #
7599 #
0ba1b2ff
AM
7600 #
7601 #
1990cd79 7602 #
9ebbca7d 7603 #"
44cd321e 7604 [(set_attr "type" "compare,compare,delayed_compare,compare,compare,compare,compare,compare,compare,compare,compare,compare")
1990cd79 7605 (set_attr "length" "4,4,4,4,4,8,8,8,8,8,8,12")])
9ebbca7d 7606
0ba1b2ff
AM
7607(define_split
7608 [(set (match_operand:CC 0 "cc_reg_operand" "")
7609 (compare:CC (and:DI (match_operand:DI 1 "gpc_reg_operand" "")
7610 (match_operand:DI 2 "mask64_2_operand" ""))
7611 (const_int 0)))
7612 (clobber (match_scratch:DI 3 ""))
7613 (clobber (match_scratch:CC 4 ""))]
1990cd79 7614 "TARGET_64BIT && reload_completed
0ba1b2ff 7615 && (fixed_regs[CR0_REGNO] || !logical_operand (operands[2], DImode))
1990cd79
AM
7616 && !mask_operand (operands[2], DImode)
7617 && !mask64_operand (operands[2], DImode)"
0ba1b2ff
AM
7618 [(set (match_dup 3)
7619 (and:DI (rotate:DI (match_dup 1)
7620 (match_dup 5))
7621 (match_dup 6)))
7622 (parallel [(set (match_dup 0)
7623 (compare:CC (and:DI (rotate:DI (match_dup 3)
7624 (match_dup 7))
7625 (match_dup 8))
7626 (const_int 0)))
7627 (clobber (match_dup 3))])]
7628 "
7629{
7630 build_mask64_2_operands (operands[2], &operands[5]);
7631}")
7632
a260abc9 7633(define_insn "*anddi3_internal3"
1990cd79
AM
7634 [(set (match_operand:CC 3 "cc_reg_operand" "=x,x,x,x,x,x,?y,?y,?y,??y,??y,?y")
7635 (compare:CC (and:DI (match_operand:DI 1 "gpc_reg_operand" "%r,r,r,r,r,r,r,r,r,r,r,r")
7636 (match_operand:DI 2 "and64_2_operand" "r,S,T,K,J,t,r,S,T,K,J,t"))
266eb58a 7637 (const_int 0)))
1990cd79 7638 (set (match_operand:DI 0 "gpc_reg_operand" "=r,r,r,r,r,r,r,r,r,r,r,r")
9ebbca7d 7639 (and:DI (match_dup 1) (match_dup 2)))
1990cd79 7640 (clobber (match_scratch:CC 4 "=X,X,X,X,X,X,X,X,X,x,x,X"))]
683bdff7 7641 "TARGET_64BIT"
266eb58a
DE
7642 "@
7643 and. %0,%1,%2
6c873122 7644 rldic%B2. %0,%1,0,%S2
1990cd79 7645 rlwinm. %0,%1,0,%m2,%M2
6ffc8580
MM
7646 andi. %0,%1,%b2
7647 andis. %0,%1,%u2
9ebbca7d
GK
7648 #
7649 #
7650 #
0ba1b2ff
AM
7651 #
7652 #
1990cd79 7653 #
9ebbca7d 7654 #"
44cd321e 7655 [(set_attr "type" "compare,compare,delayed_compare,compare,compare,compare,compare,compare,compare,compare,compare,compare")
1990cd79 7656 (set_attr "length" "4,4,4,4,4,8,8,8,8,8,8,12")])
9ebbca7d
GK
7657
7658(define_split
7659 [(set (match_operand:CC 3 "cc_reg_not_cr0_operand" "")
7660 (compare:CC (and:DI (match_operand:DI 1 "gpc_reg_operand" "")
1990cd79 7661 (match_operand:DI 2 "and64_2_operand" ""))
9ebbca7d
GK
7662 (const_int 0)))
7663 (set (match_operand:DI 0 "gpc_reg_operand" "")
7664 (and:DI (match_dup 1) (match_dup 2)))
7665 (clobber (match_scratch:CC 4 ""))]
1990cd79 7666 "TARGET_64BIT && reload_completed"
9ebbca7d
GK
7667 [(parallel [(set (match_dup 0)
7668 (and:DI (match_dup 1) (match_dup 2)))
7669 (clobber (match_dup 4))])
7670 (set (match_dup 3)
7671 (compare:CC (match_dup 0)
7672 (const_int 0)))]
7673 "")
266eb58a 7674
0ba1b2ff
AM
7675(define_split
7676 [(set (match_operand:CC 3 "cc_reg_operand" "")
7677 (compare:CC (and:DI (match_operand:DI 1 "gpc_reg_operand" "")
7678 (match_operand:DI 2 "mask64_2_operand" ""))
7679 (const_int 0)))
7680 (set (match_operand:DI 0 "gpc_reg_operand" "")
7681 (and:DI (match_dup 1) (match_dup 2)))
7682 (clobber (match_scratch:CC 4 ""))]
1990cd79 7683 "TARGET_64BIT && reload_completed
0ba1b2ff 7684 && (fixed_regs[CR0_REGNO] || !logical_operand (operands[2], DImode))
1990cd79
AM
7685 && !mask_operand (operands[2], DImode)
7686 && !mask64_operand (operands[2], DImode)"
0ba1b2ff
AM
7687 [(set (match_dup 0)
7688 (and:DI (rotate:DI (match_dup 1)
7689 (match_dup 5))
7690 (match_dup 6)))
7691 (parallel [(set (match_dup 3)
7692 (compare:CC (and:DI (rotate:DI (match_dup 0)
7693 (match_dup 7))
7694 (match_dup 8))
7695 (const_int 0)))
7696 (set (match_dup 0)
7697 (and:DI (rotate:DI (match_dup 0)
7698 (match_dup 7))
7699 (match_dup 8)))])]
7700 "
7701{
7702 build_mask64_2_operands (operands[2], &operands[5]);
7703}")
7704
a260abc9 7705(define_expand "iordi3"
266eb58a 7706 [(set (match_operand:DI 0 "gpc_reg_operand" "")
a260abc9 7707 (ior:DI (match_operand:DI 1 "gpc_reg_operand" "")
1d328b19 7708 (match_operand:DI 2 "reg_or_logical_cint_operand" "")))]
266eb58a 7709 "TARGET_POWERPC64"
266eb58a
DE
7710 "
7711{
dfbdccdb 7712 if (non_logical_cint_operand (operands[2], DImode))
266eb58a 7713 {
dfbdccdb 7714 HOST_WIDE_INT value;
b3a13419
ILT
7715 rtx tmp = ((!can_create_pseudo_p ()
7716 || rtx_equal_p (operands[0], operands[1]))
a260abc9 7717 ? operands[0] : gen_reg_rtx (DImode));
266eb58a 7718
dfbdccdb
GK
7719 if (GET_CODE (operands[2]) == CONST_INT)
7720 {
7721 value = INTVAL (operands[2]);
7722 emit_insn (gen_iordi3 (tmp, operands[1],
7723 GEN_INT (value & (~ (HOST_WIDE_INT) 0xffff))));
7724 }
e2c953b6 7725 else
dfbdccdb
GK
7726 {
7727 value = CONST_DOUBLE_LOW (operands[2]);
7728 emit_insn (gen_iordi3 (tmp, operands[1],
7729 immed_double_const (value
7730 & (~ (HOST_WIDE_INT) 0xffff),
7731 0, DImode)));
7732 }
e2c953b6 7733
9ebbca7d
GK
7734 emit_insn (gen_iordi3 (operands[0], tmp, GEN_INT (value & 0xffff)));
7735 DONE;
7736 }
266eb58a
DE
7737}")
7738
a260abc9
DE
7739(define_expand "xordi3"
7740 [(set (match_operand:DI 0 "gpc_reg_operand" "")
7741 (xor:DI (match_operand:DI 1 "gpc_reg_operand" "")
1d328b19 7742 (match_operand:DI 2 "reg_or_logical_cint_operand" "")))]
a260abc9
DE
7743 "TARGET_POWERPC64"
7744 "
7745{
dfbdccdb 7746 if (non_logical_cint_operand (operands[2], DImode))
a260abc9 7747 {
dfbdccdb 7748 HOST_WIDE_INT value;
b3a13419
ILT
7749 rtx tmp = ((!can_create_pseudo_p ()
7750 || rtx_equal_p (operands[0], operands[1]))
a260abc9
DE
7751 ? operands[0] : gen_reg_rtx (DImode));
7752
dfbdccdb
GK
7753 if (GET_CODE (operands[2]) == CONST_INT)
7754 {
7755 value = INTVAL (operands[2]);
7756 emit_insn (gen_xordi3 (tmp, operands[1],
7757 GEN_INT (value & (~ (HOST_WIDE_INT) 0xffff))));
7758 }
e2c953b6 7759 else
dfbdccdb
GK
7760 {
7761 value = CONST_DOUBLE_LOW (operands[2]);
7762 emit_insn (gen_xordi3 (tmp, operands[1],
7763 immed_double_const (value
7764 & (~ (HOST_WIDE_INT) 0xffff),
7765 0, DImode)));
7766 }
e2c953b6 7767
9ebbca7d
GK
7768 emit_insn (gen_xordi3 (operands[0], tmp, GEN_INT (value & 0xffff)));
7769 DONE;
7770 }
a260abc9
DE
7771}")
7772
dfbdccdb 7773(define_insn "*booldi3_internal1"
266eb58a 7774 [(set (match_operand:DI 0 "gpc_reg_operand" "=r,r,r")
1d328b19 7775 (match_operator:DI 3 "boolean_or_operator"
dfbdccdb
GK
7776 [(match_operand:DI 1 "gpc_reg_operand" "%r,r,r")
7777 (match_operand:DI 2 "logical_operand" "r,K,JF")]))]
266eb58a 7778 "TARGET_POWERPC64"
1fd4e8c1 7779 "@
dfbdccdb
GK
7780 %q3 %0,%1,%2
7781 %q3i %0,%1,%b2
7782 %q3is %0,%1,%u2")
1fd4e8c1 7783
dfbdccdb 7784(define_insn "*booldi3_internal2"
9ebbca7d 7785 [(set (match_operand:CC 0 "cc_reg_operand" "=x,?y")
1d328b19 7786 (compare:CC (match_operator:DI 4 "boolean_or_operator"
dfbdccdb
GK
7787 [(match_operand:DI 1 "gpc_reg_operand" "%r,r")
7788 (match_operand:DI 2 "gpc_reg_operand" "r,r")])
7789 (const_int 0)))
9ebbca7d 7790 (clobber (match_scratch:DI 3 "=r,r"))]
683bdff7 7791 "TARGET_64BIT"
9ebbca7d 7792 "@
dfbdccdb 7793 %q4. %3,%1,%2
9ebbca7d
GK
7794 #"
7795 [(set_attr "type" "compare")
7796 (set_attr "length" "4,8")])
7797
7798(define_split
7799 [(set (match_operand:CC 0 "cc_reg_not_cr0_operand" "")
dfbdccdb 7800 (compare:CC (match_operator:DI 4 "boolean_operator"
75540af0
JH
7801 [(match_operand:DI 1 "gpc_reg_operand" "")
7802 (match_operand:DI 2 "gpc_reg_operand" "")])
dfbdccdb 7803 (const_int 0)))
9ebbca7d
GK
7804 (clobber (match_scratch:DI 3 ""))]
7805 "TARGET_POWERPC64 && reload_completed"
dfbdccdb 7806 [(set (match_dup 3) (match_dup 4))
9ebbca7d
GK
7807 (set (match_dup 0)
7808 (compare:CC (match_dup 3)
7809 (const_int 0)))]
7810 "")
1fd4e8c1 7811
dfbdccdb 7812(define_insn "*booldi3_internal3"
9ebbca7d 7813 [(set (match_operand:CC 3 "cc_reg_operand" "=x,?y")
dfbdccdb
GK
7814 (compare:CC (match_operator:DI 4 "boolean_operator"
7815 [(match_operand:DI 1 "gpc_reg_operand" "%r,r")
7816 (match_operand:DI 2 "gpc_reg_operand" "r,r")])
7817 (const_int 0)))
9ebbca7d 7818 (set (match_operand:DI 0 "gpc_reg_operand" "=r,r")
dfbdccdb 7819 (match_dup 4))]
683bdff7 7820 "TARGET_64BIT"
9ebbca7d 7821 "@
dfbdccdb 7822 %q4. %0,%1,%2
9ebbca7d
GK
7823 #"
7824 [(set_attr "type" "compare")
7825 (set_attr "length" "4,8")])
7826
7827(define_split
e72247f4 7828 [(set (match_operand:CC 3 "cc_reg_not_cr0_operand" "")
dfbdccdb 7829 (compare:CC (match_operator:DI 4 "boolean_operator"
75540af0
JH
7830 [(match_operand:DI 1 "gpc_reg_operand" "")
7831 (match_operand:DI 2 "gpc_reg_operand" "")])
dfbdccdb 7832 (const_int 0)))
75540af0 7833 (set (match_operand:DI 0 "gpc_reg_operand" "")
dfbdccdb 7834 (match_dup 4))]
9ebbca7d 7835 "TARGET_POWERPC64 && reload_completed"
dfbdccdb 7836 [(set (match_dup 0) (match_dup 4))
9ebbca7d
GK
7837 (set (match_dup 3)
7838 (compare:CC (match_dup 0)
7839 (const_int 0)))]
7840 "")
1fd4e8c1 7841
6ae08853 7842;; Split a logical operation that we can't do in one insn into two insns,
dfbdccdb 7843;; each of which does one 16-bit part. This is used by combine.
266eb58a
DE
7844
7845(define_split
7846 [(set (match_operand:DI 0 "gpc_reg_operand" "")
1d328b19 7847 (match_operator:DI 3 "boolean_or_operator"
dfbdccdb
GK
7848 [(match_operand:DI 1 "gpc_reg_operand" "")
7849 (match_operand:DI 2 "non_logical_cint_operand" "")]))]
266eb58a 7850 "TARGET_POWERPC64"
dfbdccdb
GK
7851 [(set (match_dup 0) (match_dup 4))
7852 (set (match_dup 0) (match_dup 5))]
266eb58a
DE
7853"
7854{
dfbdccdb 7855 rtx i3,i4;
6ae08853 7856
9ebbca7d
GK
7857 if (GET_CODE (operands[2]) == CONST_DOUBLE)
7858 {
7859 HOST_WIDE_INT value = CONST_DOUBLE_LOW (operands[2]);
dfbdccdb 7860 i3 = immed_double_const (value & (~ (HOST_WIDE_INT) 0xffff),
9ebbca7d 7861 0, DImode);
dfbdccdb 7862 i4 = GEN_INT (value & 0xffff);
9ebbca7d
GK
7863 }
7864 else
7865 {
dfbdccdb 7866 i3 = GEN_INT (INTVAL (operands[2])
9ebbca7d 7867 & (~ (HOST_WIDE_INT) 0xffff));
dfbdccdb 7868 i4 = GEN_INT (INTVAL (operands[2]) & 0xffff);
9ebbca7d 7869 }
1c563bed 7870 operands[4] = gen_rtx_fmt_ee (GET_CODE (operands[3]), DImode,
0f4c242b 7871 operands[1], i3);
1c563bed 7872 operands[5] = gen_rtx_fmt_ee (GET_CODE (operands[3]), DImode,
0f4c242b 7873 operands[0], i4);
1fd4e8c1
RK
7874}")
7875
dfbdccdb 7876(define_insn "*boolcdi3_internal1"
9ebbca7d 7877 [(set (match_operand:DI 0 "gpc_reg_operand" "=r")
dfbdccdb
GK
7878 (match_operator:DI 3 "boolean_operator"
7879 [(not:DI (match_operand:DI 1 "gpc_reg_operand" "r"))
40501e5f 7880 (match_operand:DI 2 "gpc_reg_operand" "r")]))]
a473029f 7881 "TARGET_POWERPC64"
1d328b19 7882 "%q3 %0,%2,%1")
a473029f 7883
dfbdccdb 7884(define_insn "*boolcdi3_internal2"
9ebbca7d 7885 [(set (match_operand:CC 0 "cc_reg_operand" "=x,?y")
dfbdccdb
GK
7886 (compare:CC (match_operator:DI 4 "boolean_operator"
7887 [(not:DI (match_operand:DI 1 "gpc_reg_operand" "r,r"))
7888 (match_operand:DI 2 "gpc_reg_operand" "r,r")])
7889 (const_int 0)))
9ebbca7d 7890 (clobber (match_scratch:DI 3 "=r,r"))]
683bdff7 7891 "TARGET_64BIT"
9ebbca7d 7892 "@
1d328b19 7893 %q4. %3,%2,%1
9ebbca7d
GK
7894 #"
7895 [(set_attr "type" "compare")
7896 (set_attr "length" "4,8")])
7897
7898(define_split
7899 [(set (match_operand:CC 0 "cc_reg_not_cr0_operand" "")
dfbdccdb 7900 (compare:CC (match_operator:DI 4 "boolean_operator"
75540af0
JH
7901 [(not:DI (match_operand:DI 1 "gpc_reg_operand" ""))
7902 (match_operand:DI 2 "gpc_reg_operand" "")])
dfbdccdb 7903 (const_int 0)))
9ebbca7d
GK
7904 (clobber (match_scratch:DI 3 ""))]
7905 "TARGET_POWERPC64 && reload_completed"
dfbdccdb 7906 [(set (match_dup 3) (match_dup 4))
9ebbca7d
GK
7907 (set (match_dup 0)
7908 (compare:CC (match_dup 3)
7909 (const_int 0)))]
7910 "")
a473029f 7911
dfbdccdb 7912(define_insn "*boolcdi3_internal3"
9ebbca7d 7913 [(set (match_operand:CC 3 "cc_reg_operand" "=x,?y")
dfbdccdb
GK
7914 (compare:CC (match_operator:DI 4 "boolean_operator"
7915 [(not:DI (match_operand:DI 1 "gpc_reg_operand" "%r,r"))
7916 (match_operand:DI 2 "gpc_reg_operand" "r,r")])
7917 (const_int 0)))
9ebbca7d 7918 (set (match_operand:DI 0 "gpc_reg_operand" "=r,r")
dfbdccdb 7919 (match_dup 4))]
683bdff7 7920 "TARGET_64BIT"
9ebbca7d 7921 "@
1d328b19 7922 %q4. %0,%2,%1
9ebbca7d
GK
7923 #"
7924 [(set_attr "type" "compare")
7925 (set_attr "length" "4,8")])
7926
7927(define_split
e72247f4 7928 [(set (match_operand:CC 3 "cc_reg_not_cr0_operand" "")
dfbdccdb 7929 (compare:CC (match_operator:DI 4 "boolean_operator"
75540af0
JH
7930 [(not:DI (match_operand:DI 1 "gpc_reg_operand" ""))
7931 (match_operand:DI 2 "gpc_reg_operand" "")])
dfbdccdb 7932 (const_int 0)))
75540af0 7933 (set (match_operand:DI 0 "gpc_reg_operand" "")
dfbdccdb 7934 (match_dup 4))]
9ebbca7d 7935 "TARGET_POWERPC64 && reload_completed"
dfbdccdb 7936 [(set (match_dup 0) (match_dup 4))
9ebbca7d
GK
7937 (set (match_dup 3)
7938 (compare:CC (match_dup 0)
7939 (const_int 0)))]
7940 "")
266eb58a 7941
dfbdccdb 7942(define_insn "*boolccdi3_internal1"
a473029f 7943 [(set (match_operand:DI 0 "gpc_reg_operand" "=r")
dfbdccdb
GK
7944 (match_operator:DI 3 "boolean_operator"
7945 [(not:DI (match_operand:DI 1 "gpc_reg_operand" "r"))
40501e5f 7946 (not:DI (match_operand:DI 2 "gpc_reg_operand" "r"))]))]
a473029f 7947 "TARGET_POWERPC64"
dfbdccdb 7948 "%q3 %0,%1,%2")
a473029f 7949
dfbdccdb 7950(define_insn "*boolccdi3_internal2"
9ebbca7d 7951 [(set (match_operand:CC 0 "cc_reg_operand" "=x,?y")
dfbdccdb
GK
7952 (compare:CC (match_operator:DI 4 "boolean_operator"
7953 [(not:DI (match_operand:DI 1 "gpc_reg_operand" "r,r"))
7954 (not:DI (match_operand:DI 2 "gpc_reg_operand" "r,r"))])
7955 (const_int 0)))
9ebbca7d 7956 (clobber (match_scratch:DI 3 "=r,r"))]
683bdff7 7957 "TARGET_64BIT"
9ebbca7d 7958 "@
dfbdccdb 7959 %q4. %3,%1,%2
9ebbca7d
GK
7960 #"
7961 [(set_attr "type" "compare")
7962 (set_attr "length" "4,8")])
7963
7964(define_split
7965 [(set (match_operand:CC 0 "cc_reg_not_cr0_operand" "")
dfbdccdb 7966 (compare:CC (match_operator:DI 4 "boolean_operator"
75540af0
JH
7967 [(not:DI (match_operand:DI 1 "gpc_reg_operand" ""))
7968 (not:DI (match_operand:DI 2 "gpc_reg_operand" ""))])
dfbdccdb 7969 (const_int 0)))
9ebbca7d
GK
7970 (clobber (match_scratch:DI 3 ""))]
7971 "TARGET_POWERPC64 && reload_completed"
dfbdccdb 7972 [(set (match_dup 3) (match_dup 4))
9ebbca7d
GK
7973 (set (match_dup 0)
7974 (compare:CC (match_dup 3)
7975 (const_int 0)))]
7976 "")
266eb58a 7977
dfbdccdb 7978(define_insn "*boolccdi3_internal3"
9ebbca7d 7979 [(set (match_operand:CC 3 "cc_reg_operand" "=x,?y")
dfbdccdb
GK
7980 (compare:CC (match_operator:DI 4 "boolean_operator"
7981 [(not:DI (match_operand:DI 1 "gpc_reg_operand" "%r,r"))
7982 (not:DI (match_operand:DI 2 "gpc_reg_operand" "r,r"))])
7983 (const_int 0)))
9ebbca7d 7984 (set (match_operand:DI 0 "gpc_reg_operand" "=r,r")
dfbdccdb 7985 (match_dup 4))]
683bdff7 7986 "TARGET_64BIT"
9ebbca7d 7987 "@
dfbdccdb 7988 %q4. %0,%1,%2
9ebbca7d
GK
7989 #"
7990 [(set_attr "type" "compare")
7991 (set_attr "length" "4,8")])
7992
7993(define_split
e72247f4 7994 [(set (match_operand:CC 3 "cc_reg_not_cr0_operand" "")
dfbdccdb 7995 (compare:CC (match_operator:DI 4 "boolean_operator"
75540af0
JH
7996 [(not:DI (match_operand:DI 1 "gpc_reg_operand" ""))
7997 (not:DI (match_operand:DI 2 "gpc_reg_operand" ""))])
dfbdccdb 7998 (const_int 0)))
75540af0 7999 (set (match_operand:DI 0 "gpc_reg_operand" "")
dfbdccdb 8000 (match_dup 4))]
9ebbca7d 8001 "TARGET_POWERPC64 && reload_completed"
dfbdccdb 8002 [(set (match_dup 0) (match_dup 4))
9ebbca7d
GK
8003 (set (match_dup 3)
8004 (compare:CC (match_dup 0)
8005 (const_int 0)))]
8006 "")
dfbdccdb 8007\f
1fd4e8c1 8008;; Now define ways of moving data around.
4697a36c 8009
766a866c
MM
8010;; Set up a register with a value from the GOT table
8011
8012(define_expand "movsi_got"
52d3af72 8013 [(set (match_operand:SI 0 "gpc_reg_operand" "")
9ebbca7d 8014 (unspec:SI [(match_operand:SI 1 "got_operand" "")
615158e2 8015 (match_dup 2)] UNSPEC_MOVSI_GOT))]
f607bc57 8016 "DEFAULT_ABI == ABI_V4 && flag_pic == 1"
766a866c
MM
8017 "
8018{
38c1f2d7
MM
8019 if (GET_CODE (operands[1]) == CONST)
8020 {
8021 rtx offset = const0_rtx;
8022 HOST_WIDE_INT value;
8023
8024 operands[1] = eliminate_constant_term (XEXP (operands[1], 0), &offset);
8025 value = INTVAL (offset);
8026 if (value != 0)
8027 {
b3a13419
ILT
8028 rtx tmp = (!can_create_pseudo_p ()
8029 ? operands[0]
8030 : gen_reg_rtx (Pmode));
38c1f2d7
MM
8031 emit_insn (gen_movsi_got (tmp, operands[1]));
8032 emit_insn (gen_addsi3 (operands[0], tmp, offset));
8033 DONE;
8034 }
8035 }
8036
c4c40373 8037 operands[2] = rs6000_got_register (operands[1]);
766a866c
MM
8038}")
8039
84f414bc 8040(define_insn "*movsi_got_internal"
52d3af72 8041 [(set (match_operand:SI 0 "gpc_reg_operand" "=r")
9ebbca7d 8042 (unspec:SI [(match_operand:SI 1 "got_no_const_operand" "")
615158e2
JJ
8043 (match_operand:SI 2 "gpc_reg_operand" "b")]
8044 UNSPEC_MOVSI_GOT))]
f607bc57 8045 "DEFAULT_ABI == ABI_V4 && flag_pic == 1"
766a866c
MM
8046 "{l|lwz} %0,%a1@got(%2)"
8047 [(set_attr "type" "load")])
8048
b22b9b3e
JL
8049;; Used by sched, shorten_branches and final when the GOT pseudo reg
8050;; didn't get allocated to a hard register.
6ae08853 8051(define_split
75540af0 8052 [(set (match_operand:SI 0 "gpc_reg_operand" "")
9ebbca7d 8053 (unspec:SI [(match_operand:SI 1 "got_no_const_operand" "")
615158e2
JJ
8054 (match_operand:SI 2 "memory_operand" "")]
8055 UNSPEC_MOVSI_GOT))]
f607bc57 8056 "DEFAULT_ABI == ABI_V4
b22b9b3e
JL
8057 && flag_pic == 1
8058 && (reload_in_progress || reload_completed)"
8059 [(set (match_dup 0) (match_dup 2))
615158e2
JJ
8060 (set (match_dup 0) (unspec:SI [(match_dup 1)(match_dup 0)]
8061 UNSPEC_MOVSI_GOT))]
b22b9b3e
JL
8062 "")
8063
1fd4e8c1
RK
8064;; For SI, we special-case integers that can't be loaded in one insn. We
8065;; do the load 16-bits at a time. We could do this by loading from memory,
8066;; and this is even supposed to be faster, but it is simpler not to get
8067;; integers in the TOC.
ee890fe2
SS
8068(define_insn "movsi_low"
8069 [(set (match_operand:SI 0 "gpc_reg_operand" "=r")
f585a356 8070 (mem:SI (lo_sum:SI (match_operand:SI 1 "gpc_reg_operand" "b")
ee890fe2
SS
8071 (match_operand 2 "" ""))))]
8072 "TARGET_MACHO && ! TARGET_64BIT"
8073 "{l|lwz} %0,lo16(%2)(%1)"
8074 [(set_attr "type" "load")
8075 (set_attr "length" "4")])
8076
acad7ed3 8077(define_insn "*movsi_internal1"
165a5bad 8078 [(set (match_operand:SI 0 "rs6000_nonimmediate_operand" "=r,r,r,m,r,r,r,r,r,*q,*c*l,*h,*h")
a004eb82 8079 (match_operand:SI 1 "input_operand" "r,U,m,r,I,L,n,R,*h,r,r,r,0"))]
19d5775a
RK
8080 "gpc_reg_operand (operands[0], SImode)
8081 || gpc_reg_operand (operands[1], SImode)"
1fd4e8c1 8082 "@
deb9225a 8083 mr %0,%1
b9442c72 8084 {cal|la} %0,%a1
ca7f5001
RK
8085 {l%U1%X1|lwz%U1%X1} %0,%1
8086 {st%U0%X0|stw%U0%X0} %1,%0
19d5775a 8087 {lil|li} %0,%1
802a0058 8088 {liu|lis} %0,%v1
beaec479 8089 #
aee86b38 8090 {cal|la} %0,%a1
1fd4e8c1 8091 mf%1 %0
5c23c401 8092 mt%0 %1
e76e75bb 8093 mt%0 %1
a004eb82 8094 mt%0 %1
e34eaae5 8095 {cror 0,0,0|nop}"
02ca7595 8096 [(set_attr "type" "*,*,load,store,*,*,*,*,mfjmpr,*,mtjmpr,*,*")
a004eb82 8097 (set_attr "length" "4,4,4,4,4,4,8,4,4,4,4,4,4")])
1fd4e8c1 8098
77fa0940
RK
8099;; Split a load of a large constant into the appropriate two-insn
8100;; sequence.
8101
8102(define_split
8103 [(set (match_operand:SI 0 "gpc_reg_operand" "")
8104 (match_operand:SI 1 "const_int_operand" ""))]
bb21487f 8105 "(unsigned HOST_WIDE_INT) (INTVAL (operands[1]) + 0x8000) >= 0x10000
77fa0940
RK
8106 && (INTVAL (operands[1]) & 0xffff) != 0"
8107 [(set (match_dup 0)
8108 (match_dup 2))
8109 (set (match_dup 0)
8110 (ior:SI (match_dup 0)
8111 (match_dup 3)))]
8112 "
af8cb5c5
DE
8113{ rtx tem = rs6000_emit_set_const (operands[0], SImode, operands[1], 2);
8114
8115 if (tem == operands[0])
8116 DONE;
8117 else
8118 FAIL;
77fa0940
RK
8119}")
8120
4ae234b0 8121(define_insn "*mov<mode>_internal2"
bb84cb12 8122 [(set (match_operand:CC 2 "cc_reg_operand" "=y,x,?y")
4ae234b0 8123 (compare:CC (match_operand:P 1 "gpc_reg_operand" "0,r,r")
1fd4e8c1 8124 (const_int 0)))
4ae234b0
GK
8125 (set (match_operand:P 0 "gpc_reg_operand" "=r,r,r") (match_dup 1))]
8126 ""
9ebbca7d 8127 "@
4ae234b0 8128 {cmpi|cmp<wd>i} %2,%0,0
9ebbca7d
GK
8129 mr. %0,%1
8130 #"
bb84cb12
DE
8131 [(set_attr "type" "cmp,compare,cmp")
8132 (set_attr "length" "4,4,8")])
8133
9ebbca7d
GK
8134(define_split
8135 [(set (match_operand:CC 2 "cc_reg_not_cr0_operand" "")
4ae234b0 8136 (compare:CC (match_operand:P 1 "gpc_reg_operand" "")
9ebbca7d 8137 (const_int 0)))
4ae234b0
GK
8138 (set (match_operand:P 0 "gpc_reg_operand" "") (match_dup 1))]
8139 "reload_completed"
9ebbca7d
GK
8140 [(set (match_dup 0) (match_dup 1))
8141 (set (match_dup 2)
8142 (compare:CC (match_dup 0)
8143 (const_int 0)))]
8144 "")
bb84cb12 8145\f
e34eaae5 8146(define_insn "*movhi_internal"
fb81d7ce
RK
8147 [(set (match_operand:HI 0 "nonimmediate_operand" "=r,r,m,r,r,*q,*c*l,*h")
8148 (match_operand:HI 1 "input_operand" "r,m,r,i,*h,r,r,0"))]
19d5775a
RK
8149 "gpc_reg_operand (operands[0], HImode)
8150 || gpc_reg_operand (operands[1], HImode)"
1fd4e8c1 8151 "@
deb9225a 8152 mr %0,%1
1fd4e8c1
RK
8153 lhz%U1%X1 %0,%1
8154 sth%U0%X0 %1,%0
19d5775a 8155 {lil|li} %0,%w1
1fd4e8c1 8156 mf%1 %0
e76e75bb 8157 mt%0 %1
fb81d7ce 8158 mt%0 %1
e34eaae5 8159 {cror 0,0,0|nop}"
02ca7595 8160 [(set_attr "type" "*,load,store,*,mfjmpr,*,mtjmpr,*")])
1fd4e8c1 8161
4ae234b0
GK
8162(define_expand "mov<mode>"
8163 [(set (match_operand:INT 0 "general_operand" "")
8164 (match_operand:INT 1 "any_operand" ""))]
1fd4e8c1 8165 ""
4ae234b0 8166 "{ rs6000_emit_move (operands[0], operands[1], <MODE>mode); DONE; }")
1fd4e8c1 8167
e34eaae5 8168(define_insn "*movqi_internal"
fb81d7ce
RK
8169 [(set (match_operand:QI 0 "nonimmediate_operand" "=r,r,m,r,r,*q,*c*l,*h")
8170 (match_operand:QI 1 "input_operand" "r,m,r,i,*h,r,r,0"))]
19d5775a
RK
8171 "gpc_reg_operand (operands[0], QImode)
8172 || gpc_reg_operand (operands[1], QImode)"
1fd4e8c1 8173 "@
deb9225a 8174 mr %0,%1
1fd4e8c1
RK
8175 lbz%U1%X1 %0,%1
8176 stb%U0%X0 %1,%0
19d5775a 8177 {lil|li} %0,%1
1fd4e8c1 8178 mf%1 %0
e76e75bb 8179 mt%0 %1
fb81d7ce 8180 mt%0 %1
e34eaae5 8181 {cror 0,0,0|nop}"
02ca7595 8182 [(set_attr "type" "*,load,store,*,mfjmpr,*,mtjmpr,*")])
1fd4e8c1
RK
8183\f
8184;; Here is how to move condition codes around. When we store CC data in
8185;; an integer register or memory, we store just the high-order 4 bits.
8186;; This lets us not shift in the most common case of CR0.
8187(define_expand "movcc"
8188 [(set (match_operand:CC 0 "nonimmediate_operand" "")
8189 (match_operand:CC 1 "nonimmediate_operand" ""))]
8190 ""
8191 "")
8192
a65c591c 8193(define_insn "*movcc_internal1"
4eb585a4
DE
8194 [(set (match_operand:CC 0 "nonimmediate_operand" "=y,x,?y,y,r,r,r,r,r,q,cl,r,m")
8195 (match_operand:CC 1 "general_operand" "y,r,r,O,x,y,r,I,h,r,r,m,r"))]
1fd4e8c1
RK
8196 "register_operand (operands[0], CCmode)
8197 || register_operand (operands[1], CCmode)"
8198 "@
8199 mcrf %0,%1
8200 mtcrf 128,%1
ca7f5001 8201 {rlinm|rlwinm} %1,%1,%F0,0xffffffff\;mtcrf %R0,%1\;{rlinm|rlwinm} %1,%1,%f0,0xffffffff
4eb585a4 8202 crxor %0,%0,%0
2c4a9cff
DE
8203 mfcr %0%Q1
8204 mfcr %0%Q1\;{rlinm|rlwinm} %0,%0,%f1,0xf0000000
deb9225a 8205 mr %0,%1
4eb585a4 8206 {lil|li} %0,%1
b54cf83a 8207 mf%1 %0
b991a865
GK
8208 mt%0 %1
8209 mt%0 %1
ca7f5001
RK
8210 {l%U1%X1|lwz%U1%X1} %0,%1
8211 {st%U0%U1|stw%U0%U1} %1,%0"
2c4a9cff 8212 [(set (attr "type")
4eb585a4 8213 (cond [(eq_attr "alternative" "0,3")
2c4a9cff
DE
8214 (const_string "cr_logical")
8215 (eq_attr "alternative" "1,2")
8216 (const_string "mtcr")
4eb585a4 8217 (eq_attr "alternative" "6,7,9")
2c4a9cff 8218 (const_string "integer")
2c4a9cff 8219 (eq_attr "alternative" "8")
4eb585a4
DE
8220 (const_string "mfjmpr")
8221 (eq_attr "alternative" "10")
2c4a9cff 8222 (const_string "mtjmpr")
4eb585a4 8223 (eq_attr "alternative" "11")
2c4a9cff 8224 (const_string "load")
4eb585a4 8225 (eq_attr "alternative" "12")
2c4a9cff
DE
8226 (const_string "store")
8227 (ne (symbol_ref "TARGET_MFCRF") (const_int 0))
8228 (const_string "mfcrf")
8229 ]
8230 (const_string "mfcr")))
4eb585a4 8231 (set_attr "length" "4,4,12,4,4,8,4,4,4,4,4,4,4")])
1fd4e8c1 8232\f
e52e05ca
MM
8233;; For floating-point, we normally deal with the floating-point registers
8234;; unless -msoft-float is used. The sole exception is that parameter passing
8235;; can produce floating-point values in fixed-point registers. Unless the
8236;; value is a simple constant or already in memory, we deal with this by
8237;; allocating memory and copying the value explicitly via that memory location.
1fd4e8c1
RK
8238(define_expand "movsf"
8239 [(set (match_operand:SF 0 "nonimmediate_operand" "")
8240 (match_operand:SF 1 "any_operand" ""))]
8241 ""
fb4d4348 8242 "{ rs6000_emit_move (operands[0], operands[1], SFmode); DONE; }")
1fd4e8c1 8243
1fd4e8c1 8244(define_split
cd2b37d9 8245 [(set (match_operand:SF 0 "gpc_reg_operand" "")
c4c40373 8246 (match_operand:SF 1 "const_double_operand" ""))]
f99f88e0 8247 "reload_completed
5ae4759c
MM
8248 && ((GET_CODE (operands[0]) == REG && REGNO (operands[0]) <= 31)
8249 || (GET_CODE (operands[0]) == SUBREG
8250 && GET_CODE (SUBREG_REG (operands[0])) == REG
8251 && REGNO (SUBREG_REG (operands[0])) <= 31))"
c4c40373 8252 [(set (match_dup 2) (match_dup 3))]
685f3906
DE
8253 "
8254{
8255 long l;
8256 REAL_VALUE_TYPE rv;
8257
8258 REAL_VALUE_FROM_CONST_DOUBLE (rv, operands[1]);
8259 REAL_VALUE_TO_TARGET_SINGLE (rv, l);
c4c40373 8260
f99f88e0
DE
8261 if (! TARGET_POWERPC64)
8262 operands[2] = operand_subword (operands[0], 0, 0, SFmode);
8263 else
8264 operands[2] = gen_lowpart (SImode, operands[0]);
a260abc9 8265
2496c7bd 8266 operands[3] = gen_int_mode (l, SImode);
a260abc9
DE
8267}")
8268
c4c40373 8269(define_insn "*movsf_hardfloat"
fb3249ef 8270 [(set (match_operand:SF 0 "nonimmediate_operand" "=!r,!r,m,f,f,m,*c*l,*q,!r,*h,!r,!r")
ae6669e7 8271 (match_operand:SF 1 "input_operand" "r,m,r,f,m,f,r,r,h,0,G,Fn"))]
d14a6d05 8272 "(gpc_reg_operand (operands[0], SFmode)
a3170dc6
AH
8273 || gpc_reg_operand (operands[1], SFmode))
8274 && (TARGET_HARD_FLOAT && TARGET_FPRS)"
1fd4e8c1 8275 "@
f99f88e0
DE
8276 mr %0,%1
8277 {l%U1%X1|lwz%U1%X1} %0,%1
8278 {st%U0%X0|stw%U0%X0} %1,%0
1fd4e8c1
RK
8279 fmr %0,%1
8280 lfs%U1%X1 %0,%1
c4c40373 8281 stfs%U0%X0 %1,%0
b991a865
GK
8282 mt%0 %1
8283 mt%0 %1
8284 mf%1 %0
e0740893 8285 {cror 0,0,0|nop}
c4c40373
MM
8286 #
8287 #"
9c6fdb46 8288 [(set_attr "type" "*,load,store,fp,fpload,fpstore,mtjmpr,*,mfjmpr,*,*,*")
ae6669e7 8289 (set_attr "length" "4,4,4,4,4,4,4,4,4,4,4,8")])
d14a6d05 8290
c4c40373 8291(define_insn "*movsf_softfloat"
dd0fbae2
MK
8292 [(set (match_operand:SF 0 "nonimmediate_operand" "=r,cl,q,r,r,m,r,r,r,r,r,*h")
8293 (match_operand:SF 1 "input_operand" "r,r,r,h,m,r,I,L,R,G,Fn,0"))]
d14a6d05 8294 "(gpc_reg_operand (operands[0], SFmode)
a3170dc6
AH
8295 || gpc_reg_operand (operands[1], SFmode))
8296 && (TARGET_SOFT_FLOAT || !TARGET_FPRS)"
d14a6d05
MM
8297 "@
8298 mr %0,%1
b991a865
GK
8299 mt%0 %1
8300 mt%0 %1
8301 mf%1 %0
d14a6d05
MM
8302 {l%U1%X1|lwz%U1%X1} %0,%1
8303 {st%U0%X0|stw%U0%X0} %1,%0
8304 {lil|li} %0,%1
802a0058 8305 {liu|lis} %0,%v1
aee86b38 8306 {cal|la} %0,%a1
c4c40373 8307 #
dd0fbae2
MK
8308 #
8309 {cror 0,0,0|nop}"
9c6fdb46 8310 [(set_attr "type" "*,mtjmpr,*,mfjmpr,load,store,*,*,*,*,*,*")
dd0fbae2 8311 (set_attr "length" "4,4,4,4,4,4,4,4,4,4,8,4")])
d14a6d05 8312
1fd4e8c1
RK
8313\f
8314(define_expand "movdf"
8315 [(set (match_operand:DF 0 "nonimmediate_operand" "")
8316 (match_operand:DF 1 "any_operand" ""))]
8317 ""
fb4d4348 8318 "{ rs6000_emit_move (operands[0], operands[1], DFmode); DONE; }")
1fd4e8c1
RK
8319
8320(define_split
cd2b37d9 8321 [(set (match_operand:DF 0 "gpc_reg_operand" "")
c4c40373 8322 (match_operand:DF 1 "const_int_operand" ""))]
a260abc9 8323 "! TARGET_POWERPC64 && reload_completed
5ae4759c
MM
8324 && ((GET_CODE (operands[0]) == REG && REGNO (operands[0]) <= 31)
8325 || (GET_CODE (operands[0]) == SUBREG
8326 && GET_CODE (SUBREG_REG (operands[0])) == REG
8327 && REGNO (SUBREG_REG (operands[0])) <= 31))"
c4c40373
MM
8328 [(set (match_dup 2) (match_dup 4))
8329 (set (match_dup 3) (match_dup 1))]
8330 "
8331{
5ae4759c 8332 int endian = (WORDS_BIG_ENDIAN == 0);
5f59ecb7
DE
8333 HOST_WIDE_INT value = INTVAL (operands[1]);
8334
5ae4759c
MM
8335 operands[2] = operand_subword (operands[0], endian, 0, DFmode);
8336 operands[3] = operand_subword (operands[0], 1 - endian, 0, DFmode);
5f59ecb7
DE
8337#if HOST_BITS_PER_WIDE_INT == 32
8338 operands[4] = (value & 0x80000000) ? constm1_rtx : const0_rtx;
8339#else
8340 operands[4] = GEN_INT (value >> 32);
a65c591c 8341 operands[1] = GEN_INT (((value & 0xffffffff) ^ 0x80000000) - 0x80000000);
5f59ecb7 8342#endif
c4c40373
MM
8343}")
8344
c4c40373
MM
8345(define_split
8346 [(set (match_operand:DF 0 "gpc_reg_operand" "")
8347 (match_operand:DF 1 "const_double_operand" ""))]
a260abc9 8348 "! TARGET_POWERPC64 && reload_completed
5ae4759c
MM
8349 && ((GET_CODE (operands[0]) == REG && REGNO (operands[0]) <= 31)
8350 || (GET_CODE (operands[0]) == SUBREG
8351 && GET_CODE (SUBREG_REG (operands[0])) == REG
8352 && REGNO (SUBREG_REG (operands[0])) <= 31))"
c4c40373
MM
8353 [(set (match_dup 2) (match_dup 4))
8354 (set (match_dup 3) (match_dup 5))]
8355 "
8356{
5ae4759c 8357 int endian = (WORDS_BIG_ENDIAN == 0);
47ad8c61
MM
8358 long l[2];
8359 REAL_VALUE_TYPE rv;
8360
8361 REAL_VALUE_FROM_CONST_DOUBLE (rv, operands[1]);
8362 REAL_VALUE_TO_TARGET_DOUBLE (rv, l);
8363
5ae4759c
MM
8364 operands[2] = operand_subword (operands[0], endian, 0, DFmode);
8365 operands[3] = operand_subword (operands[0], 1 - endian, 0, DFmode);
2496c7bd
LB
8366 operands[4] = gen_int_mode (l[endian], SImode);
8367 operands[5] = gen_int_mode (l[1 - endian], SImode);
c4c40373
MM
8368}")
8369
efc08378
DE
8370(define_split
8371 [(set (match_operand:DF 0 "gpc_reg_operand" "")
8308679f 8372 (match_operand:DF 1 "const_double_operand" ""))]
a260abc9 8373 "TARGET_POWERPC64 && reload_completed
5ae4759c
MM
8374 && ((GET_CODE (operands[0]) == REG && REGNO (operands[0]) <= 31)
8375 || (GET_CODE (operands[0]) == SUBREG
8376 && GET_CODE (SUBREG_REG (operands[0])) == REG
8377 && REGNO (SUBREG_REG (operands[0])) <= 31))"
a260abc9 8378 [(set (match_dup 2) (match_dup 3))]
5ae4759c 8379 "
a260abc9
DE
8380{
8381 int endian = (WORDS_BIG_ENDIAN == 0);
8382 long l[2];
8383 REAL_VALUE_TYPE rv;
4977bab6 8384#if HOST_BITS_PER_WIDE_INT >= 64
5b029315 8385 HOST_WIDE_INT val;
4977bab6 8386#endif
a260abc9
DE
8387
8388 REAL_VALUE_FROM_CONST_DOUBLE (rv, operands[1]);
8389 REAL_VALUE_TO_TARGET_DOUBLE (rv, l);
8390
8391 operands[2] = gen_lowpart (DImode, operands[0]);
8392 /* HIGHPART is lower memory address when WORDS_BIG_ENDIAN. */
5b029315 8393#if HOST_BITS_PER_WIDE_INT >= 64
a2419b96
DE
8394 val = ((HOST_WIDE_INT)(unsigned long)l[endian] << 32
8395 | ((HOST_WIDE_INT)(unsigned long)l[1 - endian]));
5b029315 8396
f5264b52 8397 operands[3] = gen_int_mode (val, DImode);
5b029315 8398#else
a260abc9 8399 operands[3] = immed_double_const (l[1 - endian], l[endian], DImode);
5b029315 8400#endif
a260abc9 8401}")
efc08378 8402
4eae5fe1 8403;; Don't have reload use general registers to load a constant. First,
1427100a 8404;; it might not work if the output operand is the equivalent of
4eae5fe1
RK
8405;; a non-offsettable memref, but also it is less efficient than loading
8406;; the constant into an FP register, since it will probably be used there.
8407;; The "??" is a kludge until we can figure out a more reasonable way
8408;; of handling these non-offsettable values.
c4c40373 8409(define_insn "*movdf_hardfloat32"
914a7297
DE
8410 [(set (match_operand:DF 0 "nonimmediate_operand" "=!r,??r,m,f,f,m,!r,!r,!r")
8411 (match_operand:DF 1 "input_operand" "r,m,r,f,m,f,G,H,F"))]
a3170dc6 8412 "! TARGET_POWERPC64 && TARGET_HARD_FLOAT && TARGET_FPRS
52d3af72
DE
8413 && (gpc_reg_operand (operands[0], DFmode)
8414 || gpc_reg_operand (operands[1], DFmode))"
e7113111
RK
8415 "*
8416{
8417 switch (which_alternative)
8418 {
a260abc9 8419 default:
37409796 8420 gcc_unreachable ();
e7113111
RK
8421 case 0:
8422 /* We normally copy the low-numbered register first. However, if
000034eb
DE
8423 the first register operand 0 is the same as the second register
8424 of operand 1, we must copy in the opposite order. */
e7113111 8425 if (REGNO (operands[0]) == REGNO (operands[1]) + 1)
deb9225a 8426 return \"mr %L0,%L1\;mr %0,%1\";
e7113111 8427 else
deb9225a 8428 return \"mr %0,%1\;mr %L0,%L1\";
e7113111 8429 case 1:
d04b6e6e
EB
8430 if (rs6000_offsettable_memref_p (operands[1])
8431 || (GET_CODE (operands[1]) == MEM
8432 && (GET_CODE (XEXP (operands[1], 0)) == LO_SUM
8433 || GET_CODE (XEXP (operands[1], 0)) == PRE_INC
6fb5fa3c
DB
8434 || GET_CODE (XEXP (operands[1], 0)) == PRE_DEC
8435 || GET_CODE (XEXP (operands[1], 0)) == PRE_MODIFY)))
000034eb
DE
8436 {
8437 /* If the low-address word is used in the address, we must load
8438 it last. Otherwise, load it first. Note that we cannot have
8439 auto-increment in that case since the address register is
8440 known to be dead. */
8441 if (refers_to_regno_p (REGNO (operands[0]), REGNO (operands[0]) + 1,
8442 operands[1], 0))
8443 return \"{l|lwz} %L0,%L1\;{l|lwz} %0,%1\";
8444 else
6fb5fa3c 8445 return \"{l%U1%X1|lwz%U1%X1} %0,%1\;{l|lwz} %L0,%L1\";
000034eb 8446 }
e7113111 8447 else
000034eb
DE
8448 {
8449 rtx addreg;
8450
000034eb
DE
8451 addreg = find_addr_reg (XEXP (operands[1], 0));
8452 if (refers_to_regno_p (REGNO (operands[0]),
8453 REGNO (operands[0]) + 1,
8454 operands[1], 0))
8455 {
8456 output_asm_insn (\"{cal|la} %0,4(%0)\", &addreg);
2284bd2b 8457 output_asm_insn (\"{l%X1|lwz%X1} %L0,%1\", operands);
000034eb 8458 output_asm_insn (\"{cal|la} %0,-4(%0)\", &addreg);
2284bd2b 8459 return \"{l%X1|lwz%X1} %0,%1\";
000034eb
DE
8460 }
8461 else
8462 {
2284bd2b 8463 output_asm_insn (\"{l%X1|lwz%X1} %0,%1\", operands);
000034eb 8464 output_asm_insn (\"{cal|la} %0,4(%0)\", &addreg);
2284bd2b 8465 output_asm_insn (\"{l%X1|lwz%X1} %L0,%1\", operands);
000034eb
DE
8466 output_asm_insn (\"{cal|la} %0,-4(%0)\", &addreg);
8467 return \"\";
8468 }
8469 }
e7113111 8470 case 2:
d04b6e6e
EB
8471 if (rs6000_offsettable_memref_p (operands[0])
8472 || (GET_CODE (operands[0]) == MEM
8473 && (GET_CODE (XEXP (operands[0], 0)) == LO_SUM
8474 || GET_CODE (XEXP (operands[0], 0)) == PRE_INC
6fb5fa3c
DB
8475 || GET_CODE (XEXP (operands[0], 0)) == PRE_DEC
8476 || GET_CODE (XEXP (operands[0], 0)) == PRE_MODIFY)))
8477 return \"{st%U0%X0|stw%U0%X0} %1,%0\;{st|stw} %L1,%L0\";
000034eb
DE
8478 else
8479 {
8480 rtx addreg;
8481
000034eb 8482 addreg = find_addr_reg (XEXP (operands[0], 0));
2284bd2b 8483 output_asm_insn (\"{st%X0|stw%X0} %1,%0\", operands);
000034eb 8484 output_asm_insn (\"{cal|la} %0,4(%0)\", &addreg);
2284bd2b 8485 output_asm_insn (\"{st%X0|stw%X0} %L1,%0\", operands);
000034eb
DE
8486 output_asm_insn (\"{cal|la} %0,-4(%0)\", &addreg);
8487 return \"\";
8488 }
e7113111 8489 case 3:
914a7297 8490 return \"fmr %0,%1\";
e7113111 8491 case 4:
914a7297 8492 return \"lfd%U1%X1 %0,%1\";
e7113111 8493 case 5:
914a7297 8494 return \"stfd%U0%X0 %1,%0\";
e7113111 8495 case 6:
c4c40373 8496 case 7:
c4c40373 8497 case 8:
914a7297 8498 return \"#\";
e7113111
RK
8499 }
8500}"
943c15ed 8501 [(set_attr "type" "two,load,store,fp,fpload,fpstore,*,*,*")
914a7297 8502 (set_attr "length" "8,16,16,4,4,4,8,12,16")])
51b8fc2c 8503
c4c40373 8504(define_insn "*movdf_softfloat32"
1427100a
DE
8505 [(set (match_operand:DF 0 "nonimmediate_operand" "=r,r,m,r,r,r")
8506 (match_operand:DF 1 "input_operand" "r,m,r,G,H,F"))]
7a2f7870 8507 "! TARGET_POWERPC64 && (TARGET_SOFT_FLOAT || TARGET_E500_SINGLE)
52d3af72
DE
8508 && (gpc_reg_operand (operands[0], DFmode)
8509 || gpc_reg_operand (operands[1], DFmode))"
dc4f83ca
MM
8510 "*
8511{
8512 switch (which_alternative)
8513 {
a260abc9 8514 default:
37409796 8515 gcc_unreachable ();
dc4f83ca
MM
8516 case 0:
8517 /* We normally copy the low-numbered register first. However, if
8518 the first register operand 0 is the same as the second register of
8519 operand 1, we must copy in the opposite order. */
8520 if (REGNO (operands[0]) == REGNO (operands[1]) + 1)
8521 return \"mr %L0,%L1\;mr %0,%1\";
8522 else
8523 return \"mr %0,%1\;mr %L0,%L1\";
8524 case 1:
3cb999d8
DE
8525 /* If the low-address word is used in the address, we must load
8526 it last. Otherwise, load it first. Note that we cannot have
8527 auto-increment in that case since the address register is
8528 known to be dead. */
dc4f83ca 8529 if (refers_to_regno_p (REGNO (operands[0]), REGNO (operands[0]) + 1,
3cb999d8 8530 operands[1], 0))
dc4f83ca
MM
8531 return \"{l|lwz} %L0,%L1\;{l|lwz} %0,%1\";
8532 else
6fb5fa3c 8533 return \"{l%U1%X1|lwz%U1%X1} %0,%1\;{l|lwz} %L0,%L1\";
dc4f83ca 8534 case 2:
6fb5fa3c 8535 return \"{st%U0%X0|stw%U0%X0} %1,%0\;{st|stw} %L1,%L0\";
dc4f83ca 8536 case 3:
c4c40373
MM
8537 case 4:
8538 case 5:
dc4f83ca
MM
8539 return \"#\";
8540 }
8541}"
943c15ed 8542 [(set_attr "type" "two,load,store,*,*,*")
c4c40373 8543 (set_attr "length" "8,8,8,8,12,16")])
dc4f83ca 8544
44cd321e
PS
8545; ld/std require word-aligned displacements -> 'Y' constraint.
8546; List Y->r and r->Y before r->r for reload.
8547(define_insn "*movdf_hardfloat64_mfpgpr"
8548 [(set (match_operand:DF 0 "nonimmediate_operand" "=Y,r,!r,f,f,m,*c*l,!r,*h,!r,!r,!r,r,f")
8549 (match_operand:DF 1 "input_operand" "r,Y,r,f,m,f,r,h,0,G,H,F,f,r"))]
8550 "TARGET_POWERPC64 && TARGET_MFPGPR && TARGET_HARD_FLOAT && TARGET_FPRS
8551 && (gpc_reg_operand (operands[0], DFmode)
8552 || gpc_reg_operand (operands[1], DFmode))"
8553 "@
8554 std%U0%X0 %1,%0
8555 ld%U1%X1 %0,%1
8556 mr %0,%1
8557 fmr %0,%1
8558 lfd%U1%X1 %0,%1
8559 stfd%U0%X0 %1,%0
8560 mt%0 %1
8561 mf%1 %0
8562 {cror 0,0,0|nop}
8563 #
8564 #
8565 #
8566 mftgpr %0,%1
8567 mffgpr %0,%1"
8568 [(set_attr "type" "store,load,*,fp,fpload,fpstore,mtjmpr,mfjmpr,*,*,*,*,mftgpr,mffgpr")
8569 (set_attr "length" "4,4,4,4,4,4,4,4,4,8,12,16,4,4")])
8570
d2288d5d
HP
8571; ld/std require word-aligned displacements -> 'Y' constraint.
8572; List Y->r and r->Y before r->r for reload.
c4c40373 8573(define_insn "*movdf_hardfloat64"
fb3249ef 8574 [(set (match_operand:DF 0 "nonimmediate_operand" "=Y,r,!r,f,f,m,*c*l,!r,*h,!r,!r,!r")
ae6669e7 8575 (match_operand:DF 1 "input_operand" "r,Y,r,f,m,f,r,h,0,G,H,F"))]
44cd321e 8576 "TARGET_POWERPC64 && !TARGET_MFPGPR && TARGET_HARD_FLOAT && TARGET_FPRS
52d3af72
DE
8577 && (gpc_reg_operand (operands[0], DFmode)
8578 || gpc_reg_operand (operands[1], DFmode))"
51b8fc2c 8579 "@
96bb8ed3 8580 std%U0%X0 %1,%0
3364872d
FJ
8581 ld%U1%X1 %0,%1
8582 mr %0,%1
3d5570cb 8583 fmr %0,%1
f63184ac 8584 lfd%U1%X1 %0,%1
914a7297
DE
8585 stfd%U0%X0 %1,%0
8586 mt%0 %1
8587 mf%1 %0
e0740893 8588 {cror 0,0,0|nop}
914a7297
DE
8589 #
8590 #
8591 #"
9c6fdb46 8592 [(set_attr "type" "store,load,*,fp,fpload,fpstore,mtjmpr,mfjmpr,*,*,*,*")
ae6669e7 8593 (set_attr "length" "4,4,4,4,4,4,4,4,4,8,12,16")])
dc4f83ca 8594
c4c40373 8595(define_insn "*movdf_softfloat64"
d2288d5d
HP
8596 [(set (match_operand:DF 0 "nonimmediate_operand" "=r,Y,r,cl,r,r,r,r,*h")
8597 (match_operand:DF 1 "input_operand" "Y,r,r,r,h,G,H,F,0"))]
a3170dc6 8598 "TARGET_POWERPC64 && (TARGET_SOFT_FLOAT || !TARGET_FPRS)
52d3af72
DE
8599 && (gpc_reg_operand (operands[0], DFmode)
8600 || gpc_reg_operand (operands[1], DFmode))"
dc4f83ca 8601 "@
d2288d5d
HP
8602 ld%U1%X1 %0,%1
8603 std%U0%X0 %1,%0
dc4f83ca 8604 mr %0,%1
914a7297
DE
8605 mt%0 %1
8606 mf%1 %0
c4c40373
MM
8607 #
8608 #
e2d0915c 8609 #
e0740893 8610 {cror 0,0,0|nop}"
9c6fdb46 8611 [(set_attr "type" "load,store,*,mtjmpr,mfjmpr,*,*,*,*")
e2d0915c 8612 (set_attr "length" "4,4,4,4,4,8,12,16,4")])
1fd4e8c1 8613\f
06f4e019
DE
8614(define_expand "movtf"
8615 [(set (match_operand:TF 0 "general_operand" "")
8616 (match_operand:TF 1 "any_operand" ""))]
8521c414 8617 "!TARGET_IEEEQUAD && TARGET_LONG_DOUBLE_128"
06f4e019
DE
8618 "{ rs6000_emit_move (operands[0], operands[1], TFmode); DONE; }")
8619
a9baceb1
GK
8620; It's important to list the o->f and f->o moves before f->f because
8621; otherwise reload, given m->f, will try to pick f->f and reload it,
409f61cd 8622; which doesn't make progress. Likewise r->Y must be before r->r.
a9baceb1 8623(define_insn_and_split "*movtf_internal"
409f61cd
AM
8624 [(set (match_operand:TF 0 "nonimmediate_operand" "=o,f,f,r,Y,r")
8625 (match_operand:TF 1 "input_operand" "f,o,f,YGHF,r,r"))]
602ea4d3 8626 "!TARGET_IEEEQUAD
39e63627 8627 && TARGET_HARD_FLOAT && TARGET_FPRS && TARGET_LONG_DOUBLE_128
06f4e019
DE
8628 && (gpc_reg_operand (operands[0], TFmode)
8629 || gpc_reg_operand (operands[1], TFmode))"
a9baceb1 8630 "#"
ecb62ae7 8631 "&& reload_completed"
a9baceb1
GK
8632 [(pc)]
8633{ rs6000_split_multireg_move (operands[0], operands[1]); DONE; }
112ccb83 8634 [(set_attr "length" "8,8,8,20,20,16")])
06f4e019 8635
8521c414 8636(define_insn_and_split "*movtf_softfloat"
17caeff2 8637 [(set (match_operand:TF 0 "rs6000_nonimmediate_operand" "=r,Y,r")
8521c414
JM
8638 (match_operand:TF 1 "input_operand" "YGHF,r,r"))]
8639 "!TARGET_IEEEQUAD
8640 && (TARGET_SOFT_FLOAT || !TARGET_FPRS) && TARGET_LONG_DOUBLE_128
8641 && (gpc_reg_operand (operands[0], TFmode)
8642 || gpc_reg_operand (operands[1], TFmode))"
8643 "#"
8644 "&& reload_completed"
8645 [(pc)]
8646{ rs6000_split_multireg_move (operands[0], operands[1]); DONE; }
8647 [(set_attr "length" "20,20,16")])
8648
ecb62ae7 8649(define_expand "extenddftf2"
17caeff2
JM
8650 [(set (match_operand:TF 0 "nonimmediate_operand" "")
8651 (float_extend:TF (match_operand:DF 1 "input_operand" "")))]
8652 "!TARGET_IEEEQUAD
8653 && TARGET_HARD_FLOAT
8654 && (TARGET_FPRS || TARGET_E500_DOUBLE)
8655 && TARGET_LONG_DOUBLE_128"
8656{
8657 if (TARGET_E500_DOUBLE)
8658 emit_insn (gen_spe_extenddftf2 (operands[0], operands[1]));
8659 else
8660 emit_insn (gen_extenddftf2_fprs (operands[0], operands[1]));
8661 DONE;
8662})
8663
8664(define_expand "extenddftf2_fprs"
ecb62ae7
GK
8665 [(parallel [(set (match_operand:TF 0 "nonimmediate_operand" "")
8666 (float_extend:TF (match_operand:DF 1 "input_operand" "")))
8667 (use (match_dup 2))])]
602ea4d3 8668 "!TARGET_IEEEQUAD
39e63627 8669 && TARGET_HARD_FLOAT && TARGET_FPRS && TARGET_LONG_DOUBLE_128"
06f4e019 8670{
ecb62ae7 8671 operands[2] = CONST0_RTX (DFmode);
aa9cf005
DE
8672 /* Generate GOT reference early for SVR4 PIC. */
8673 if (DEFAULT_ABI == ABI_V4 && flag_pic)
8674 operands[2] = validize_mem (force_const_mem (DFmode, operands[2]));
ecb62ae7 8675})
06f4e019 8676
ecb62ae7
GK
8677(define_insn_and_split "*extenddftf2_internal"
8678 [(set (match_operand:TF 0 "nonimmediate_operand" "=o,f,&f,r")
8679 (float_extend:TF (match_operand:DF 1 "input_operand" "fr,mf,mf,rmGHF")))
97c54d9a 8680 (use (match_operand:DF 2 "zero_reg_mem_operand" "rf,m,f,n"))]
602ea4d3 8681 "!TARGET_IEEEQUAD
39e63627 8682 && TARGET_HARD_FLOAT && TARGET_FPRS && TARGET_LONG_DOUBLE_128"
ecb62ae7
GK
8683 "#"
8684 "&& reload_completed"
8685 [(pc)]
06f4e019 8686{
ecb62ae7
GK
8687 const int lo_word = FLOAT_WORDS_BIG_ENDIAN ? GET_MODE_SIZE (DFmode) : 0;
8688 const int hi_word = FLOAT_WORDS_BIG_ENDIAN ? 0 : GET_MODE_SIZE (DFmode);
8689 emit_move_insn (simplify_gen_subreg (DFmode, operands[0], TFmode, hi_word),
8690 operands[1]);
8691 emit_move_insn (simplify_gen_subreg (DFmode, operands[0], TFmode, lo_word),
8692 operands[2]);
8693 DONE;
6ae08853 8694})
ecb62ae7
GK
8695
8696(define_expand "extendsftf2"
8697 [(set (match_operand:TF 0 "nonimmediate_operand" "")
8698 (float_extend:TF (match_operand:SF 1 "gpc_reg_operand" "")))]
602ea4d3 8699 "!TARGET_IEEEQUAD
17caeff2
JM
8700 && TARGET_HARD_FLOAT
8701 && (TARGET_FPRS || TARGET_E500_DOUBLE)
8702 && TARGET_LONG_DOUBLE_128"
ecb62ae7
GK
8703{
8704 rtx tmp = gen_reg_rtx (DFmode);
8705 emit_insn (gen_extendsfdf2 (tmp, operands[1]));
8706 emit_insn (gen_extenddftf2 (operands[0], tmp));
8707 DONE;
8708})
06f4e019 8709
8cb320b8 8710(define_expand "trunctfdf2"
589b3fda
DE
8711 [(set (match_operand:DF 0 "gpc_reg_operand" "")
8712 (float_truncate:DF (match_operand:TF 1 "gpc_reg_operand" "")))]
602ea4d3 8713 "!TARGET_IEEEQUAD
17caeff2
JM
8714 && TARGET_HARD_FLOAT
8715 && (TARGET_FPRS || TARGET_E500_DOUBLE)
8716 && TARGET_LONG_DOUBLE_128"
589b3fda 8717 "")
8cb320b8
DE
8718
8719(define_insn_and_split "trunctfdf2_internal1"
8720 [(set (match_operand:DF 0 "gpc_reg_operand" "=f,?f")
8721 (float_truncate:DF (match_operand:TF 1 "gpc_reg_operand" "0,f")))]
602ea4d3 8722 "!TARGET_IEEEQUAD && !TARGET_XL_COMPAT
8cb320b8
DE
8723 && TARGET_HARD_FLOAT && TARGET_FPRS && TARGET_LONG_DOUBLE_128"
8724 "@
8725 #
8726 fmr %0,%1"
8727 "&& reload_completed && REGNO (operands[0]) == REGNO (operands[1])"
8728 [(const_int 0)]
8729{
8730 emit_note (NOTE_INSN_DELETED);
8731 DONE;
8732}
8733 [(set_attr "type" "fp")])
8734
8735(define_insn "trunctfdf2_internal2"
8736 [(set (match_operand:DF 0 "gpc_reg_operand" "=f")
8737 (float_truncate:DF (match_operand:TF 1 "gpc_reg_operand" "f")))]
602ea4d3 8738 "!TARGET_IEEEQUAD && TARGET_XL_COMPAT
8cb320b8 8739 && TARGET_HARD_FLOAT && TARGET_FPRS && TARGET_LONG_DOUBLE_128"
06f4e019 8740 "fadd %0,%1,%L1"
8cb320b8 8741 [(set_attr "type" "fp")])
06f4e019 8742
17caeff2
JM
8743(define_expand "trunctfsf2"
8744 [(set (match_operand:SF 0 "gpc_reg_operand" "")
8745 (float_truncate:SF (match_operand:TF 1 "gpc_reg_operand" "")))]
8746 "!TARGET_IEEEQUAD
8747 && TARGET_HARD_FLOAT
8748 && (TARGET_FPRS || TARGET_E500_DOUBLE)
8749 && TARGET_LONG_DOUBLE_128"
8750{
8751 if (TARGET_E500_DOUBLE)
8752 emit_insn (gen_spe_trunctfsf2 (operands[0], operands[1]));
8753 else
8754 emit_insn (gen_trunctfsf2_fprs (operands[0], operands[1]));
8755 DONE;
8756})
8757
8758(define_insn_and_split "trunctfsf2_fprs"
06f4e019 8759 [(set (match_operand:SF 0 "gpc_reg_operand" "=f")
ea112fc4
DE
8760 (float_truncate:SF (match_operand:TF 1 "gpc_reg_operand" "f")))
8761 (clobber (match_scratch:DF 2 "=f"))]
602ea4d3 8762 "!TARGET_IEEEQUAD
39e63627 8763 && TARGET_HARD_FLOAT && TARGET_FPRS && TARGET_LONG_DOUBLE_128"
06f4e019 8764 "#"
ea112fc4 8765 "&& reload_completed"
06f4e019
DE
8766 [(set (match_dup 2)
8767 (float_truncate:DF (match_dup 1)))
8768 (set (match_dup 0)
8769 (float_truncate:SF (match_dup 2)))]
ea112fc4 8770 "")
06f4e019 8771
0c90aa3c 8772(define_expand "floatsitf2"
d29b7f64
DE
8773 [(set (match_operand:TF 0 "gpc_reg_operand" "")
8774 (float:TF (match_operand:SI 1 "gpc_reg_operand" "")))]
602ea4d3 8775 "!TARGET_IEEEQUAD
17caeff2
JM
8776 && TARGET_HARD_FLOAT
8777 && (TARGET_FPRS || TARGET_E500_DOUBLE)
8778 && TARGET_LONG_DOUBLE_128"
0c90aa3c
GK
8779{
8780 rtx tmp = gen_reg_rtx (DFmode);
8781 expand_float (tmp, operands[1], false);
8782 emit_insn (gen_extenddftf2 (operands[0], tmp));
8783 DONE;
8784})
06f4e019 8785
ecb62ae7
GK
8786; fadd, but rounding towards zero.
8787; This is probably not the optimal code sequence.
8788(define_insn "fix_trunc_helper"
8789 [(set (match_operand:DF 0 "gpc_reg_operand" "=f")
8790 (unspec:DF [(match_operand:TF 1 "gpc_reg_operand" "f")]
8791 UNSPEC_FIX_TRUNC_TF))
8792 (clobber (match_operand:DF 2 "gpc_reg_operand" "=&f"))]
8793 "TARGET_HARD_FLOAT && TARGET_FPRS"
8794 "mffs %2\n\tmtfsb1 31\n\tmtfsb0 30\n\tfadd %0,%1,%L1\n\tmtfsf 1,%2"
8795 [(set_attr "type" "fp")
8796 (set_attr "length" "20")])
8797
0c90aa3c 8798(define_expand "fix_trunctfsi2"
17caeff2
JM
8799 [(set (match_operand:SI 0 "gpc_reg_operand" "")
8800 (fix:SI (match_operand:TF 1 "gpc_reg_operand" "")))]
8801 "!TARGET_IEEEQUAD
8802 && (TARGET_POWER2 || TARGET_POWERPC)
8803 && TARGET_HARD_FLOAT
8804 && (TARGET_FPRS || TARGET_E500_DOUBLE)
8805 && TARGET_LONG_DOUBLE_128"
8806{
8807 if (TARGET_E500_DOUBLE)
8808 emit_insn (gen_spe_fix_trunctfsi2 (operands[0], operands[1]));
8809 else
8810 emit_insn (gen_fix_trunctfsi2_fprs (operands[0], operands[1]));
8811 DONE;
8812})
8813
8814(define_expand "fix_trunctfsi2_fprs"
ecb62ae7
GK
8815 [(parallel [(set (match_operand:SI 0 "gpc_reg_operand" "")
8816 (fix:SI (match_operand:TF 1 "gpc_reg_operand" "")))
8817 (clobber (match_dup 2))
8818 (clobber (match_dup 3))
8819 (clobber (match_dup 4))
8820 (clobber (match_dup 5))])]
602ea4d3 8821 "!TARGET_IEEEQUAD
ecb62ae7
GK
8822 && (TARGET_POWER2 || TARGET_POWERPC)
8823 && TARGET_HARD_FLOAT && TARGET_FPRS && TARGET_LONG_DOUBLE_128"
8824{
8825 operands[2] = gen_reg_rtx (DFmode);
8826 operands[3] = gen_reg_rtx (DFmode);
8827 operands[4] = gen_reg_rtx (DImode);
8828 operands[5] = assign_stack_temp (DImode, GET_MODE_SIZE (DImode), 0);
8829})
8830
8831(define_insn_and_split "*fix_trunctfsi2_internal"
61c07d3c 8832 [(set (match_operand:SI 0 "gpc_reg_operand" "=r")
ecb62ae7
GK
8833 (fix:SI (match_operand:TF 1 "gpc_reg_operand" "f")))
8834 (clobber (match_operand:DF 2 "gpc_reg_operand" "=f"))
8835 (clobber (match_operand:DF 3 "gpc_reg_operand" "=&f"))
8836 (clobber (match_operand:DI 4 "gpc_reg_operand" "=f"))
b0d6c7d8 8837 (clobber (match_operand:DI 5 "offsettable_mem_operand" "=o"))]
602ea4d3 8838 "!TARGET_IEEEQUAD
39e63627 8839 && TARGET_HARD_FLOAT && TARGET_FPRS && TARGET_LONG_DOUBLE_128"
ecb62ae7 8840 "#"
b3a13419 8841 "&& (can_create_pseudo_p () || offsettable_nonstrict_memref_p (operands[5]))"
ecb62ae7 8842 [(pc)]
0c90aa3c 8843{
ecb62ae7
GK
8844 rtx lowword;
8845 emit_insn (gen_fix_trunc_helper (operands[2], operands[1], operands[3]));
8846
230215f5
GK
8847 gcc_assert (MEM_P (operands[5]));
8848 lowword = adjust_address (operands[5], SImode, WORDS_BIG_ENDIAN ? 4 : 0);
ecb62ae7
GK
8849
8850 emit_insn (gen_fctiwz (operands[4], operands[2]));
8851 emit_move_insn (operands[5], operands[4]);
230215f5 8852 emit_move_insn (operands[0], lowword);
0c90aa3c
GK
8853 DONE;
8854})
06f4e019 8855
17caeff2
JM
8856(define_expand "negtf2"
8857 [(set (match_operand:TF 0 "gpc_reg_operand" "")
8858 (neg:TF (match_operand:TF 1 "gpc_reg_operand" "")))]
8859 "!TARGET_IEEEQUAD
8860 && TARGET_HARD_FLOAT
8861 && (TARGET_FPRS || TARGET_E500_DOUBLE)
8862 && TARGET_LONG_DOUBLE_128"
8863 "")
8864
8865(define_insn "negtf2_internal"
06f4e019
DE
8866 [(set (match_operand:TF 0 "gpc_reg_operand" "=f")
8867 (neg:TF (match_operand:TF 1 "gpc_reg_operand" "f")))]
602ea4d3 8868 "!TARGET_IEEEQUAD
39e63627 8869 && TARGET_HARD_FLOAT && TARGET_FPRS && TARGET_LONG_DOUBLE_128"
06f4e019
DE
8870 "*
8871{
8872 if (REGNO (operands[0]) == REGNO (operands[1]) + 1)
8873 return \"fneg %L0,%L1\;fneg %0,%1\";
8874 else
8875 return \"fneg %0,%1\;fneg %L0,%L1\";
8876}"
8877 [(set_attr "type" "fp")
8878 (set_attr "length" "8")])
8879
1a402dc1 8880(define_expand "abstf2"
17caeff2
JM
8881 [(set (match_operand:TF 0 "gpc_reg_operand" "")
8882 (abs:TF (match_operand:TF 1 "gpc_reg_operand" "")))]
602ea4d3 8883 "!TARGET_IEEEQUAD
17caeff2
JM
8884 && TARGET_HARD_FLOAT
8885 && (TARGET_FPRS || TARGET_E500_DOUBLE)
8886 && TARGET_LONG_DOUBLE_128"
1a402dc1 8887 "
06f4e019 8888{
1a402dc1 8889 rtx label = gen_label_rtx ();
17caeff2
JM
8890 if (TARGET_E500_DOUBLE)
8891 {
8892 if (flag_unsafe_math_optimizations)
8893 emit_insn (gen_spe_abstf2_tst (operands[0], operands[1], label));
8894 else
8895 emit_insn (gen_spe_abstf2_cmp (operands[0], operands[1], label));
8896 }
8897 else
8898 emit_insn (gen_abstf2_internal (operands[0], operands[1], label));
1a402dc1
AM
8899 emit_label (label);
8900 DONE;
8901}")
06f4e019 8902
1a402dc1 8903(define_expand "abstf2_internal"
e42ac3de
RS
8904 [(set (match_operand:TF 0 "gpc_reg_operand" "")
8905 (match_operand:TF 1 "gpc_reg_operand" ""))
1a402dc1
AM
8906 (set (match_dup 3) (match_dup 5))
8907 (set (match_dup 5) (abs:DF (match_dup 5)))
8908 (set (match_dup 4) (compare:CCFP (match_dup 3) (match_dup 5)))
8909 (set (pc) (if_then_else (eq (match_dup 4) (const_int 0))
8910 (label_ref (match_operand 2 "" ""))
8911 (pc)))
8912 (set (match_dup 6) (neg:DF (match_dup 6)))]
602ea4d3 8913 "!TARGET_IEEEQUAD
39e63627 8914 && TARGET_HARD_FLOAT && TARGET_FPRS && TARGET_LONG_DOUBLE_128"
1a402dc1 8915 "
06f4e019 8916{
1a402dc1
AM
8917 const int hi_word = FLOAT_WORDS_BIG_ENDIAN ? 0 : GET_MODE_SIZE (DFmode);
8918 const int lo_word = FLOAT_WORDS_BIG_ENDIAN ? GET_MODE_SIZE (DFmode) : 0;
8919 operands[3] = gen_reg_rtx (DFmode);
8920 operands[4] = gen_reg_rtx (CCFPmode);
8921 operands[5] = simplify_gen_subreg (DFmode, operands[0], TFmode, hi_word);
8922 operands[6] = simplify_gen_subreg (DFmode, operands[0], TFmode, lo_word);
8923}")
06f4e019 8924\f
1fd4e8c1
RK
8925;; Next come the multi-word integer load and store and the load and store
8926;; multiple insns.
1fd4e8c1 8927
112ccb83
GK
8928; List r->r after r->"o<>", otherwise reload will try to reload a
8929; non-offsettable address by using r->r which won't make progress.
acad7ed3 8930(define_insn "*movdi_internal32"
17caeff2 8931 [(set (match_operand:DI 0 "rs6000_nonimmediate_operand" "=o<>,r,r,*f,*f,m,r")
112ccb83 8932 (match_operand:DI 1 "input_operand" "r,r,m,f,m,f,IJKnGHF"))]
a260abc9 8933 "! TARGET_POWERPC64
4e74d8ec
MM
8934 && (gpc_reg_operand (operands[0], DImode)
8935 || gpc_reg_operand (operands[1], DImode))"
112ccb83
GK
8936 "@
8937 #
8938 #
8939 #
8940 fmr %0,%1
8941 lfd%U1%X1 %0,%1
8942 stfd%U0%X0 %1,%0
8943 #"
8944 [(set_attr "type" "load,*,store,fp,fpload,fpstore,*")])
4e74d8ec
MM
8945
8946(define_split
8947 [(set (match_operand:DI 0 "gpc_reg_operand" "")
8948 (match_operand:DI 1 "const_int_operand" ""))]
a260abc9 8949 "! TARGET_POWERPC64 && reload_completed"
4e74d8ec
MM
8950 [(set (match_dup 2) (match_dup 4))
8951 (set (match_dup 3) (match_dup 1))]
8952 "
8953{
5f59ecb7 8954 HOST_WIDE_INT value = INTVAL (operands[1]);
bdaa0181
GK
8955 operands[2] = operand_subword_force (operands[0], WORDS_BIG_ENDIAN == 0,
8956 DImode);
8957 operands[3] = operand_subword_force (operands[0], WORDS_BIG_ENDIAN != 0,
8958 DImode);
75d39459 8959#if HOST_BITS_PER_WIDE_INT == 32
5f59ecb7 8960 operands[4] = (value & 0x80000000) ? constm1_rtx : const0_rtx;
75d39459 8961#else
5f59ecb7 8962 operands[4] = GEN_INT (value >> 32);
a65c591c 8963 operands[1] = GEN_INT (((value & 0xffffffff) ^ 0x80000000) - 0x80000000);
75d39459 8964#endif
4e74d8ec
MM
8965}")
8966
3a1f863f 8967(define_split
17caeff2 8968 [(set (match_operand:DI 0 "rs6000_nonimmediate_operand" "")
3a1f863f 8969 (match_operand:DI 1 "input_operand" ""))]
6ae08853 8970 "reload_completed && !TARGET_POWERPC64
3a1f863f 8971 && gpr_or_gpr_p (operands[0], operands[1])"
a9baceb1
GK
8972 [(pc)]
8973{ rs6000_split_multireg_move (operands[0], operands[1]); DONE; })
3a1f863f 8974
44cd321e
PS
8975(define_insn "*movdi_mfpgpr"
8976 [(set (match_operand:DI 0 "nonimmediate_operand" "=r,r,m,r,r,r,r,*f,*f,m,r,*h,*h,r,*f")
8977 (match_operand:DI 1 "input_operand" "r,m,r,I,L,nF,R,f,m,f,*h,r,0,*f,r"))]
8978 "TARGET_POWERPC64 && TARGET_MFPGPR && TARGET_HARD_FLOAT && TARGET_FPRS
8979 && (gpc_reg_operand (operands[0], DImode)
8980 || gpc_reg_operand (operands[1], DImode))"
8981 "@
8982 mr %0,%1
8983 ld%U1%X1 %0,%1
8984 std%U0%X0 %1,%0
8985 li %0,%1
8986 lis %0,%v1
8987 #
8988 {cal|la} %0,%a1
8989 fmr %0,%1
8990 lfd%U1%X1 %0,%1
8991 stfd%U0%X0 %1,%0
8992 mf%1 %0
8993 mt%0 %1
8994 {cror 0,0,0|nop}
8995 mftgpr %0,%1
8996 mffgpr %0,%1"
8997 [(set_attr "type" "*,load,store,*,*,*,*,fp,fpload,fpstore,mfjmpr,mtjmpr,*,mftgpr,mffgpr")
8998 (set_attr "length" "4,4,4,4,4,20,4,4,4,4,4,4,4,4,4")])
8999
acad7ed3 9000(define_insn "*movdi_internal64"
343f6bbf 9001 [(set (match_operand:DI 0 "nonimmediate_operand" "=r,r,m,r,r,r,r,*f,*f,m,r,*h,*h")
9615f239 9002 (match_operand:DI 1 "input_operand" "r,m,r,I,L,nF,R,f,m,f,*h,r,0"))]
44cd321e 9003 "TARGET_POWERPC64 && (!TARGET_MFPGPR || !TARGET_HARD_FLOAT || !TARGET_FPRS)
4e74d8ec
MM
9004 && (gpc_reg_operand (operands[0], DImode)
9005 || gpc_reg_operand (operands[1], DImode))"
51b8fc2c 9006 "@
3d5570cb
RK
9007 mr %0,%1
9008 ld%U1%X1 %0,%1
96bb8ed3 9009 std%U0%X0 %1,%0
3d5570cb 9010 li %0,%1
802a0058 9011 lis %0,%v1
e6ca2c17 9012 #
aee86b38 9013 {cal|la} %0,%a1
3d5570cb
RK
9014 fmr %0,%1
9015 lfd%U1%X1 %0,%1
9016 stfd%U0%X0 %1,%0
9017 mf%1 %0
08075ead 9018 mt%0 %1
e34eaae5 9019 {cror 0,0,0|nop}"
02ca7595 9020 [(set_attr "type" "*,load,store,*,*,*,*,fp,fpload,fpstore,mfjmpr,mtjmpr,*")
e6ca2c17
DE
9021 (set_attr "length" "4,4,4,4,4,20,4,4,4,4,4,4,4")])
9022
5f59ecb7 9023;; immediate value valid for a single instruction hiding in a const_double
a260abc9
DE
9024(define_insn ""
9025 [(set (match_operand:DI 0 "gpc_reg_operand" "=r")
9026 (match_operand:DI 1 "const_double_operand" "F"))]
5f59ecb7
DE
9027 "HOST_BITS_PER_WIDE_INT == 32 && TARGET_POWERPC64
9028 && GET_CODE (operands[1]) == CONST_DOUBLE
a260abc9
DE
9029 && num_insns_constant (operands[1], DImode) == 1"
9030 "*
9031{
9032 return ((unsigned HOST_WIDE_INT)
9033 (CONST_DOUBLE_LOW (operands[1]) + 0x8000) < 0x10000)
9034 ? \"li %0,%1\" : \"lis %0,%v1\";
9035}")
9036
a260abc9
DE
9037;; Generate all one-bits and clear left or right.
9038;; Use (and:DI (rotate:DI ...)) to avoid anddi3 unnecessary clobber.
9039(define_split
9040 [(set (match_operand:DI 0 "gpc_reg_operand" "")
1990cd79 9041 (match_operand:DI 1 "mask64_operand" ""))]
a260abc9
DE
9042 "TARGET_POWERPC64 && num_insns_constant (operands[1], DImode) > 1"
9043 [(set (match_dup 0) (const_int -1))
e6ca2c17 9044 (set (match_dup 0)
a260abc9
DE
9045 (and:DI (rotate:DI (match_dup 0)
9046 (const_int 0))
9047 (match_dup 1)))]
9048 "")
9049
9050;; Split a load of a large constant into the appropriate five-instruction
9051;; sequence. Handle anything in a constant number of insns.
9052;; When non-easy constants can go in the TOC, this should use
9053;; easy_fp_constant predicate.
9054(define_split
9055 [(set (match_operand:DI 0 "gpc_reg_operand" "")
2bfcf297
DB
9056 (match_operand:DI 1 "const_int_operand" ""))]
9057 "TARGET_POWERPC64 && num_insns_constant (operands[1], DImode) > 1"
9058 [(set (match_dup 0) (match_dup 2))
9059 (set (match_dup 0) (plus:DI (match_dup 0) (match_dup 3)))]
e6ca2c17 9060 "
2bfcf297
DB
9061{ rtx tem = rs6000_emit_set_const (operands[0], DImode, operands[1], 5);
9062
9063 if (tem == operands[0])
9064 DONE;
e8d791dd 9065 else
2bfcf297 9066 FAIL;
5f59ecb7 9067}")
e6ca2c17 9068
5f59ecb7
DE
9069(define_split
9070 [(set (match_operand:DI 0 "gpc_reg_operand" "")
2bfcf297
DB
9071 (match_operand:DI 1 "const_double_operand" ""))]
9072 "TARGET_POWERPC64 && num_insns_constant (operands[1], DImode) > 1"
9073 [(set (match_dup 0) (match_dup 2))
9074 (set (match_dup 0) (plus:DI (match_dup 0) (match_dup 3)))]
5f59ecb7 9075 "
2bfcf297
DB
9076{ rtx tem = rs6000_emit_set_const (operands[0], DImode, operands[1], 5);
9077
9078 if (tem == operands[0])
9079 DONE;
9080 else
9081 FAIL;
e6ca2c17 9082}")
acad7ed3 9083\f
1fd4e8c1
RK
9084;; TImode is similar, except that we usually want to compute the address into
9085;; a register and use lsi/stsi (the exception is during reload). MQ is also
ca7f5001 9086;; clobbered in stsi for POWER, so we need a SCRATCH for it.
1fd4e8c1
RK
9087
9088;; We say that MQ is clobbered in the last alternative because the first
9089;; alternative would never get used otherwise since it would need a reload
9090;; while the 2nd alternative would not. We put memory cases first so they
9091;; are preferred. Otherwise, we'd try to reload the output instead of
9092;; giving the SCRATCH mq.
3a1f863f 9093
a260abc9 9094(define_insn "*movti_power"
7f514158
AM
9095 [(set (match_operand:TI 0 "reg_or_mem_operand" "=Q,m,????r,????r,????r,r")
9096 (match_operand:TI 1 "input_operand" "r,r,r,Q,m,n"))
9097 (clobber (match_scratch:SI 2 "=q,q#X,X,X,X,X"))]
6ae08853 9098 "TARGET_POWER && ! TARGET_POWERPC64
dc4f83ca 9099 && (gpc_reg_operand (operands[0], TImode) || gpc_reg_operand (operands[1], TImode))"
1fd4e8c1
RK
9100 "*
9101{
9102 switch (which_alternative)
9103 {
dc4f83ca 9104 default:
37409796 9105 gcc_unreachable ();
dc4f83ca 9106
1fd4e8c1 9107 case 0:
3a1f863f
DE
9108 if (TARGET_STRING)
9109 return \"{stsi|stswi} %1,%P0,16\";
1fd4e8c1 9110 case 1:
1fd4e8c1 9111 case 2:
3a1f863f 9112 return \"#\";
1fd4e8c1
RK
9113 case 3:
9114 /* If the address is not used in the output, we can use lsi. Otherwise,
9115 fall through to generating four loads. */
e876481c
DE
9116 if (TARGET_STRING
9117 && ! reg_overlap_mentioned_p (operands[0], operands[1]))
ca7f5001 9118 return \"{lsi|lswi} %0,%P1,16\";
82e41834 9119 /* ... fall through ... */
1fd4e8c1 9120 case 4:
7f514158 9121 case 5:
3a1f863f 9122 return \"#\";
1fd4e8c1
RK
9123 }
9124}"
7f514158 9125 [(set_attr "type" "store,store,*,load,load,*")])
51b8fc2c 9126
a260abc9 9127(define_insn "*movti_string"
7f514158
AM
9128 [(set (match_operand:TI 0 "reg_or_mem_operand" "=Q,o<>,????r,????r,????r,r")
9129 (match_operand:TI 1 "input_operand" "r,r,r,Q,m,n"))]
3a1f863f 9130 "! TARGET_POWER && ! TARGET_POWERPC64
dc4f83ca
MM
9131 && (gpc_reg_operand (operands[0], TImode) || gpc_reg_operand (operands[1], TImode))"
9132 "*
9133{
9134 switch (which_alternative)
9135 {
9136 default:
37409796 9137 gcc_unreachable ();
dc4f83ca 9138 case 0:
3a1f863f
DE
9139 if (TARGET_STRING)
9140 return \"{stsi|stswi} %1,%P0,16\";
dc4f83ca 9141 case 1:
cd1d3445 9142 case 2:
3a1f863f 9143 return \"#\";
cd1d3445
DE
9144 case 3:
9145 /* If the address is not used in the output, we can use lsi. Otherwise,
9146 fall through to generating four loads. */
6ae08853 9147 if (TARGET_STRING
3a1f863f 9148 && ! reg_overlap_mentioned_p (operands[0], operands[1]))
cd1d3445
DE
9149 return \"{lsi|lswi} %0,%P1,16\";
9150 /* ... fall through ... */
9151 case 4:
7f514158 9152 case 5:
3a1f863f 9153 return \"#\";
dc4f83ca
MM
9154 }
9155}"
9c6fdb46 9156 [(set_attr "type" "store_ux,store_ux,*,load_ux,load_ux,*")])
dc4f83ca 9157
a260abc9 9158(define_insn "*movti_ppc64"
112ccb83
GK
9159 [(set (match_operand:TI 0 "nonimmediate_operand" "=r,o<>,r")
9160 (match_operand:TI 1 "input_operand" "r,r,m"))]
51b8fc2c
RK
9161 "TARGET_POWERPC64 && (gpc_reg_operand (operands[0], TImode)
9162 || gpc_reg_operand (operands[1], TImode))"
112ccb83 9163 "#"
3a1f863f
DE
9164 [(set_attr "type" "*,load,store")])
9165
7f514158
AM
9166(define_split
9167 [(set (match_operand:TI 0 "gpc_reg_operand" "")
9168 (match_operand:TI 1 "const_double_operand" ""))]
9169 "TARGET_POWERPC64"
9170 [(set (match_dup 2) (match_dup 4))
9171 (set (match_dup 3) (match_dup 5))]
9172 "
9173{
9174 operands[2] = operand_subword_force (operands[0], WORDS_BIG_ENDIAN == 0,
9175 TImode);
9176 operands[3] = operand_subword_force (operands[0], WORDS_BIG_ENDIAN != 0,
9177 TImode);
9178 if (GET_CODE (operands[1]) == CONST_DOUBLE)
9179 {
9180 operands[4] = GEN_INT (CONST_DOUBLE_HIGH (operands[1]));
9181 operands[5] = GEN_INT (CONST_DOUBLE_LOW (operands[1]));
9182 }
9183 else if (GET_CODE (operands[1]) == CONST_INT)
9184 {
9185 operands[4] = GEN_INT (- (INTVAL (operands[1]) < 0));
9186 operands[5] = operands[1];
9187 }
9188 else
9189 FAIL;
9190}")
9191
3a1f863f
DE
9192(define_split
9193 [(set (match_operand:TI 0 "nonimmediate_operand" "")
9194 (match_operand:TI 1 "input_operand" ""))]
a9baceb1 9195 "reload_completed
3a1f863f 9196 && gpr_or_gpr_p (operands[0], operands[1])"
a9baceb1
GK
9197 [(pc)]
9198{ rs6000_split_multireg_move (operands[0], operands[1]); DONE; })
1fd4e8c1
RK
9199\f
9200(define_expand "load_multiple"
2f622005
RK
9201 [(match_par_dup 3 [(set (match_operand:SI 0 "" "")
9202 (match_operand:SI 1 "" ""))
9203 (use (match_operand:SI 2 "" ""))])]
09a625f7 9204 "TARGET_STRING && !TARGET_POWERPC64"
1fd4e8c1
RK
9205 "
9206{
9207 int regno;
9208 int count;
792760b9 9209 rtx op1;
1fd4e8c1
RK
9210 int i;
9211
9212 /* Support only loading a constant number of fixed-point registers from
9213 memory and only bother with this if more than two; the machine
9214 doesn't support more than eight. */
9215 if (GET_CODE (operands[2]) != CONST_INT
9216 || INTVAL (operands[2]) <= 2
9217 || INTVAL (operands[2]) > 8
9218 || GET_CODE (operands[1]) != MEM
9219 || GET_CODE (operands[0]) != REG
9220 || REGNO (operands[0]) >= 32)
9221 FAIL;
9222
9223 count = INTVAL (operands[2]);
9224 regno = REGNO (operands[0]);
9225
39403d82 9226 operands[3] = gen_rtx_PARALLEL (VOIDmode, rtvec_alloc (count));
792760b9
RK
9227 op1 = replace_equiv_address (operands[1],
9228 force_reg (SImode, XEXP (operands[1], 0)));
1fd4e8c1
RK
9229
9230 for (i = 0; i < count; i++)
9231 XVECEXP (operands[3], 0, i)
39403d82 9232 = gen_rtx_SET (VOIDmode, gen_rtx_REG (SImode, regno + i),
7ef788f0 9233 adjust_address_nv (op1, SImode, i * 4));
1fd4e8c1
RK
9234}")
9235
9caa3eb2 9236(define_insn "*ldmsi8"
1fd4e8c1 9237 [(match_parallel 0 "load_multiple_operation"
9caa3eb2
DE
9238 [(set (match_operand:SI 2 "gpc_reg_operand" "")
9239 (mem:SI (match_operand:SI 1 "gpc_reg_operand" "b")))
9240 (set (match_operand:SI 3 "gpc_reg_operand" "")
9241 (mem:SI (plus:SI (match_dup 1) (const_int 4))))
9242 (set (match_operand:SI 4 "gpc_reg_operand" "")
9243 (mem:SI (plus:SI (match_dup 1) (const_int 8))))
9244 (set (match_operand:SI 5 "gpc_reg_operand" "")
9245 (mem:SI (plus:SI (match_dup 1) (const_int 12))))
9246 (set (match_operand:SI 6 "gpc_reg_operand" "")
9247 (mem:SI (plus:SI (match_dup 1) (const_int 16))))
9248 (set (match_operand:SI 7 "gpc_reg_operand" "")
9249 (mem:SI (plus:SI (match_dup 1) (const_int 20))))
9250 (set (match_operand:SI 8 "gpc_reg_operand" "")
9251 (mem:SI (plus:SI (match_dup 1) (const_int 24))))
9252 (set (match_operand:SI 9 "gpc_reg_operand" "")
9253 (mem:SI (plus:SI (match_dup 1) (const_int 28))))])]
9254 "TARGET_STRING && XVECLEN (operands[0], 0) == 8"
1fd4e8c1 9255 "*
9caa3eb2 9256{ return rs6000_output_load_multiple (operands); }"
9c6fdb46 9257 [(set_attr "type" "load_ux")
9caa3eb2 9258 (set_attr "length" "32")])
1fd4e8c1 9259
9caa3eb2
DE
9260(define_insn "*ldmsi7"
9261 [(match_parallel 0 "load_multiple_operation"
9262 [(set (match_operand:SI 2 "gpc_reg_operand" "")
9263 (mem:SI (match_operand:SI 1 "gpc_reg_operand" "b")))
9264 (set (match_operand:SI 3 "gpc_reg_operand" "")
9265 (mem:SI (plus:SI (match_dup 1) (const_int 4))))
9266 (set (match_operand:SI 4 "gpc_reg_operand" "")
9267 (mem:SI (plus:SI (match_dup 1) (const_int 8))))
9268 (set (match_operand:SI 5 "gpc_reg_operand" "")
9269 (mem:SI (plus:SI (match_dup 1) (const_int 12))))
9270 (set (match_operand:SI 6 "gpc_reg_operand" "")
9271 (mem:SI (plus:SI (match_dup 1) (const_int 16))))
9272 (set (match_operand:SI 7 "gpc_reg_operand" "")
9273 (mem:SI (plus:SI (match_dup 1) (const_int 20))))
9274 (set (match_operand:SI 8 "gpc_reg_operand" "")
9275 (mem:SI (plus:SI (match_dup 1) (const_int 24))))])]
9276 "TARGET_STRING && XVECLEN (operands[0], 0) == 7"
9277 "*
9278{ return rs6000_output_load_multiple (operands); }"
9c6fdb46 9279 [(set_attr "type" "load_ux")
9caa3eb2
DE
9280 (set_attr "length" "32")])
9281
9282(define_insn "*ldmsi6"
9283 [(match_parallel 0 "load_multiple_operation"
9284 [(set (match_operand:SI 2 "gpc_reg_operand" "")
9285 (mem:SI (match_operand:SI 1 "gpc_reg_operand" "b")))
9286 (set (match_operand:SI 3 "gpc_reg_operand" "")
9287 (mem:SI (plus:SI (match_dup 1) (const_int 4))))
9288 (set (match_operand:SI 4 "gpc_reg_operand" "")
9289 (mem:SI (plus:SI (match_dup 1) (const_int 8))))
9290 (set (match_operand:SI 5 "gpc_reg_operand" "")
9291 (mem:SI (plus:SI (match_dup 1) (const_int 12))))
9292 (set (match_operand:SI 6 "gpc_reg_operand" "")
9293 (mem:SI (plus:SI (match_dup 1) (const_int 16))))
9294 (set (match_operand:SI 7 "gpc_reg_operand" "")
9295 (mem:SI (plus:SI (match_dup 1) (const_int 20))))])]
9296 "TARGET_STRING && XVECLEN (operands[0], 0) == 6"
9297 "*
9298{ return rs6000_output_load_multiple (operands); }"
9c6fdb46 9299 [(set_attr "type" "load_ux")
9caa3eb2
DE
9300 (set_attr "length" "32")])
9301
9302(define_insn "*ldmsi5"
9303 [(match_parallel 0 "load_multiple_operation"
9304 [(set (match_operand:SI 2 "gpc_reg_operand" "")
9305 (mem:SI (match_operand:SI 1 "gpc_reg_operand" "b")))
9306 (set (match_operand:SI 3 "gpc_reg_operand" "")
9307 (mem:SI (plus:SI (match_dup 1) (const_int 4))))
9308 (set (match_operand:SI 4 "gpc_reg_operand" "")
9309 (mem:SI (plus:SI (match_dup 1) (const_int 8))))
9310 (set (match_operand:SI 5 "gpc_reg_operand" "")
9311 (mem:SI (plus:SI (match_dup 1) (const_int 12))))
9312 (set (match_operand:SI 6 "gpc_reg_operand" "")
9313 (mem:SI (plus:SI (match_dup 1) (const_int 16))))])]
9314 "TARGET_STRING && XVECLEN (operands[0], 0) == 5"
9315 "*
9316{ return rs6000_output_load_multiple (operands); }"
9c6fdb46 9317 [(set_attr "type" "load_ux")
9caa3eb2
DE
9318 (set_attr "length" "32")])
9319
9320(define_insn "*ldmsi4"
9321 [(match_parallel 0 "load_multiple_operation"
9322 [(set (match_operand:SI 2 "gpc_reg_operand" "")
9323 (mem:SI (match_operand:SI 1 "gpc_reg_operand" "b")))
9324 (set (match_operand:SI 3 "gpc_reg_operand" "")
9325 (mem:SI (plus:SI (match_dup 1) (const_int 4))))
9326 (set (match_operand:SI 4 "gpc_reg_operand" "")
9327 (mem:SI (plus:SI (match_dup 1) (const_int 8))))
9328 (set (match_operand:SI 5 "gpc_reg_operand" "")
9329 (mem:SI (plus:SI (match_dup 1) (const_int 12))))])]
9330 "TARGET_STRING && XVECLEN (operands[0], 0) == 4"
9331 "*
9332{ return rs6000_output_load_multiple (operands); }"
9c6fdb46 9333 [(set_attr "type" "load_ux")
9caa3eb2
DE
9334 (set_attr "length" "32")])
9335
9336(define_insn "*ldmsi3"
9337 [(match_parallel 0 "load_multiple_operation"
9338 [(set (match_operand:SI 2 "gpc_reg_operand" "")
9339 (mem:SI (match_operand:SI 1 "gpc_reg_operand" "b")))
9340 (set (match_operand:SI 3 "gpc_reg_operand" "")
9341 (mem:SI (plus:SI (match_dup 1) (const_int 4))))
9342 (set (match_operand:SI 4 "gpc_reg_operand" "")
9343 (mem:SI (plus:SI (match_dup 1) (const_int 8))))])]
9344 "TARGET_STRING && XVECLEN (operands[0], 0) == 3"
9345 "*
9346{ return rs6000_output_load_multiple (operands); }"
9c6fdb46 9347 [(set_attr "type" "load_ux")
e82ee4cc 9348 (set_attr "length" "32")])
b19003d8 9349
1fd4e8c1 9350(define_expand "store_multiple"
2f622005
RK
9351 [(match_par_dup 3 [(set (match_operand:SI 0 "" "")
9352 (match_operand:SI 1 "" ""))
9353 (clobber (scratch:SI))
9354 (use (match_operand:SI 2 "" ""))])]
09a625f7 9355 "TARGET_STRING && !TARGET_POWERPC64"
1fd4e8c1
RK
9356 "
9357{
9358 int regno;
9359 int count;
9360 rtx to;
792760b9 9361 rtx op0;
1fd4e8c1
RK
9362 int i;
9363
9364 /* Support only storing a constant number of fixed-point registers to
9365 memory and only bother with this if more than two; the machine
9366 doesn't support more than eight. */
9367 if (GET_CODE (operands[2]) != CONST_INT
9368 || INTVAL (operands[2]) <= 2
9369 || INTVAL (operands[2]) > 8
9370 || GET_CODE (operands[0]) != MEM
9371 || GET_CODE (operands[1]) != REG
9372 || REGNO (operands[1]) >= 32)
9373 FAIL;
9374
9375 count = INTVAL (operands[2]);
9376 regno = REGNO (operands[1]);
9377
39403d82 9378 operands[3] = gen_rtx_PARALLEL (VOIDmode, rtvec_alloc (count + 1));
1fd4e8c1 9379 to = force_reg (SImode, XEXP (operands[0], 0));
792760b9 9380 op0 = replace_equiv_address (operands[0], to);
1fd4e8c1
RK
9381
9382 XVECEXP (operands[3], 0, 0)
7ef788f0 9383 = gen_rtx_SET (VOIDmode, adjust_address_nv (op0, SImode, 0), operands[1]);
39403d82 9384 XVECEXP (operands[3], 0, 1) = gen_rtx_CLOBBER (VOIDmode,
c5c76735 9385 gen_rtx_SCRATCH (SImode));
1fd4e8c1
RK
9386
9387 for (i = 1; i < count; i++)
9388 XVECEXP (operands[3], 0, i + 1)
39403d82 9389 = gen_rtx_SET (VOIDmode,
7ef788f0 9390 adjust_address_nv (op0, SImode, i * 4),
c5c76735 9391 gen_rtx_REG (SImode, regno + i));
1fd4e8c1
RK
9392}")
9393
e46e3130 9394(define_insn "*stmsi8"
d14a6d05 9395 [(match_parallel 0 "store_multiple_operation"
e46e3130
DJ
9396 [(set (mem:SI (match_operand:SI 1 "gpc_reg_operand" "b"))
9397 (match_operand:SI 2 "gpc_reg_operand" "r"))
edd54d25 9398 (clobber (match_scratch:SI 3 "=X"))
e46e3130
DJ
9399 (set (mem:SI (plus:SI (match_dup 1) (const_int 4)))
9400 (match_operand:SI 4 "gpc_reg_operand" "r"))
9401 (set (mem:SI (plus:SI (match_dup 1) (const_int 8)))
9402 (match_operand:SI 5 "gpc_reg_operand" "r"))
9403 (set (mem:SI (plus:SI (match_dup 1) (const_int 12)))
9404 (match_operand:SI 6 "gpc_reg_operand" "r"))
9405 (set (mem:SI (plus:SI (match_dup 1) (const_int 16)))
9406 (match_operand:SI 7 "gpc_reg_operand" "r"))
9407 (set (mem:SI (plus:SI (match_dup 1) (const_int 20)))
9408 (match_operand:SI 8 "gpc_reg_operand" "r"))
9409 (set (mem:SI (plus:SI (match_dup 1) (const_int 24)))
9410 (match_operand:SI 9 "gpc_reg_operand" "r"))
9411 (set (mem:SI (plus:SI (match_dup 1) (const_int 28)))
9412 (match_operand:SI 10 "gpc_reg_operand" "r"))])]
9413 "TARGET_STRING && !TARGET_POWER && XVECLEN (operands[0], 0) == 9"
9414 "{stsi|stswi} %2,%1,%O0"
9c6fdb46 9415 [(set_attr "type" "store_ux")])
e46e3130
DJ
9416
9417(define_insn "*stmsi7"
9418 [(match_parallel 0 "store_multiple_operation"
9419 [(set (mem:SI (match_operand:SI 1 "gpc_reg_operand" "b"))
9420 (match_operand:SI 2 "gpc_reg_operand" "r"))
edd54d25 9421 (clobber (match_scratch:SI 3 "=X"))
e46e3130
DJ
9422 (set (mem:SI (plus:SI (match_dup 1) (const_int 4)))
9423 (match_operand:SI 4 "gpc_reg_operand" "r"))
9424 (set (mem:SI (plus:SI (match_dup 1) (const_int 8)))
9425 (match_operand:SI 5 "gpc_reg_operand" "r"))
9426 (set (mem:SI (plus:SI (match_dup 1) (const_int 12)))
9427 (match_operand:SI 6 "gpc_reg_operand" "r"))
9428 (set (mem:SI (plus:SI (match_dup 1) (const_int 16)))
9429 (match_operand:SI 7 "gpc_reg_operand" "r"))
9430 (set (mem:SI (plus:SI (match_dup 1) (const_int 20)))
9431 (match_operand:SI 8 "gpc_reg_operand" "r"))
9432 (set (mem:SI (plus:SI (match_dup 1) (const_int 24)))
9433 (match_operand:SI 9 "gpc_reg_operand" "r"))])]
9434 "TARGET_STRING && !TARGET_POWER && XVECLEN (operands[0], 0) == 8"
9435 "{stsi|stswi} %2,%1,%O0"
9c6fdb46 9436 [(set_attr "type" "store_ux")])
e46e3130
DJ
9437
9438(define_insn "*stmsi6"
9439 [(match_parallel 0 "store_multiple_operation"
9440 [(set (mem:SI (match_operand:SI 1 "gpc_reg_operand" "b"))
9441 (match_operand:SI 2 "gpc_reg_operand" "r"))
edd54d25 9442 (clobber (match_scratch:SI 3 "=X"))
e46e3130
DJ
9443 (set (mem:SI (plus:SI (match_dup 1) (const_int 4)))
9444 (match_operand:SI 4 "gpc_reg_operand" "r"))
9445 (set (mem:SI (plus:SI (match_dup 1) (const_int 8)))
9446 (match_operand:SI 5 "gpc_reg_operand" "r"))
9447 (set (mem:SI (plus:SI (match_dup 1) (const_int 12)))
9448 (match_operand:SI 6 "gpc_reg_operand" "r"))
9449 (set (mem:SI (plus:SI (match_dup 1) (const_int 16)))
9450 (match_operand:SI 7 "gpc_reg_operand" "r"))
9451 (set (mem:SI (plus:SI (match_dup 1) (const_int 20)))
9452 (match_operand:SI 8 "gpc_reg_operand" "r"))])]
9453 "TARGET_STRING && !TARGET_POWER && XVECLEN (operands[0], 0) == 7"
9454 "{stsi|stswi} %2,%1,%O0"
9c6fdb46 9455 [(set_attr "type" "store_ux")])
e46e3130
DJ
9456
9457(define_insn "*stmsi5"
9458 [(match_parallel 0 "store_multiple_operation"
9459 [(set (mem:SI (match_operand:SI 1 "gpc_reg_operand" "b"))
9460 (match_operand:SI 2 "gpc_reg_operand" "r"))
edd54d25 9461 (clobber (match_scratch:SI 3 "=X"))
e46e3130
DJ
9462 (set (mem:SI (plus:SI (match_dup 1) (const_int 4)))
9463 (match_operand:SI 4 "gpc_reg_operand" "r"))
9464 (set (mem:SI (plus:SI (match_dup 1) (const_int 8)))
9465 (match_operand:SI 5 "gpc_reg_operand" "r"))
9466 (set (mem:SI (plus:SI (match_dup 1) (const_int 12)))
9467 (match_operand:SI 6 "gpc_reg_operand" "r"))
9468 (set (mem:SI (plus:SI (match_dup 1) (const_int 16)))
9469 (match_operand:SI 7 "gpc_reg_operand" "r"))])]
9470 "TARGET_STRING && !TARGET_POWER && XVECLEN (operands[0], 0) == 6"
9471 "{stsi|stswi} %2,%1,%O0"
9c6fdb46 9472 [(set_attr "type" "store_ux")])
e46e3130
DJ
9473
9474(define_insn "*stmsi4"
9475 [(match_parallel 0 "store_multiple_operation"
9476 [(set (mem:SI (match_operand:SI 1 "gpc_reg_operand" "b"))
9477 (match_operand:SI 2 "gpc_reg_operand" "r"))
edd54d25 9478 (clobber (match_scratch:SI 3 "=X"))
e46e3130
DJ
9479 (set (mem:SI (plus:SI (match_dup 1) (const_int 4)))
9480 (match_operand:SI 4 "gpc_reg_operand" "r"))
9481 (set (mem:SI (plus:SI (match_dup 1) (const_int 8)))
9482 (match_operand:SI 5 "gpc_reg_operand" "r"))
9483 (set (mem:SI (plus:SI (match_dup 1) (const_int 12)))
9484 (match_operand:SI 6 "gpc_reg_operand" "r"))])]
9485 "TARGET_STRING && !TARGET_POWER && XVECLEN (operands[0], 0) == 5"
b7ff3d82 9486 "{stsi|stswi} %2,%1,%O0"
9c6fdb46 9487 [(set_attr "type" "store_ux")])
7e69e155 9488
e46e3130
DJ
9489(define_insn "*stmsi3"
9490 [(match_parallel 0 "store_multiple_operation"
9491 [(set (mem:SI (match_operand:SI 1 "gpc_reg_operand" "b"))
9492 (match_operand:SI 2 "gpc_reg_operand" "r"))
edd54d25 9493 (clobber (match_scratch:SI 3 "=X"))
e46e3130
DJ
9494 (set (mem:SI (plus:SI (match_dup 1) (const_int 4)))
9495 (match_operand:SI 4 "gpc_reg_operand" "r"))
9496 (set (mem:SI (plus:SI (match_dup 1) (const_int 8)))
9497 (match_operand:SI 5 "gpc_reg_operand" "r"))])]
9498 "TARGET_STRING && !TARGET_POWER && XVECLEN (operands[0], 0) == 4"
9499 "{stsi|stswi} %2,%1,%O0"
9c6fdb46 9500 [(set_attr "type" "store_ux")])
d2894ab5
DE
9501
9502(define_insn "*stmsi8_power"
9503 [(match_parallel 0 "store_multiple_operation"
9504 [(set (mem:SI (match_operand:SI 1 "gpc_reg_operand" "b"))
9505 (match_operand:SI 2 "gpc_reg_operand" "r"))
1958f718 9506 (clobber (match_scratch:SI 3 "=q"))
d2894ab5
DE
9507 (set (mem:SI (plus:SI (match_dup 1) (const_int 4)))
9508 (match_operand:SI 4 "gpc_reg_operand" "r"))
9509 (set (mem:SI (plus:SI (match_dup 1) (const_int 8)))
9510 (match_operand:SI 5 "gpc_reg_operand" "r"))
9511 (set (mem:SI (plus:SI (match_dup 1) (const_int 12)))
9512 (match_operand:SI 6 "gpc_reg_operand" "r"))
9513 (set (mem:SI (plus:SI (match_dup 1) (const_int 16)))
9514 (match_operand:SI 7 "gpc_reg_operand" "r"))
9515 (set (mem:SI (plus:SI (match_dup 1) (const_int 20)))
9516 (match_operand:SI 8 "gpc_reg_operand" "r"))
9517 (set (mem:SI (plus:SI (match_dup 1) (const_int 24)))
9518 (match_operand:SI 9 "gpc_reg_operand" "r"))
9519 (set (mem:SI (plus:SI (match_dup 1) (const_int 28)))
9520 (match_operand:SI 10 "gpc_reg_operand" "r"))])]
9521 "TARGET_STRING && TARGET_POWER && XVECLEN (operands[0], 0) == 9"
9522 "{stsi|stswi} %2,%1,%O0"
9523 [(set_attr "type" "store_ux")])
9524
9525(define_insn "*stmsi7_power"
9526 [(match_parallel 0 "store_multiple_operation"
9527 [(set (mem:SI (match_operand:SI 1 "gpc_reg_operand" "b"))
9528 (match_operand:SI 2 "gpc_reg_operand" "r"))
1958f718 9529 (clobber (match_scratch:SI 3 "=q"))
d2894ab5
DE
9530 (set (mem:SI (plus:SI (match_dup 1) (const_int 4)))
9531 (match_operand:SI 4 "gpc_reg_operand" "r"))
9532 (set (mem:SI (plus:SI (match_dup 1) (const_int 8)))
9533 (match_operand:SI 5 "gpc_reg_operand" "r"))
9534 (set (mem:SI (plus:SI (match_dup 1) (const_int 12)))
9535 (match_operand:SI 6 "gpc_reg_operand" "r"))
9536 (set (mem:SI (plus:SI (match_dup 1) (const_int 16)))
9537 (match_operand:SI 7 "gpc_reg_operand" "r"))
9538 (set (mem:SI (plus:SI (match_dup 1) (const_int 20)))
9539 (match_operand:SI 8 "gpc_reg_operand" "r"))
9540 (set (mem:SI (plus:SI (match_dup 1) (const_int 24)))
9541 (match_operand:SI 9 "gpc_reg_operand" "r"))])]
9542 "TARGET_STRING && TARGET_POWER && XVECLEN (operands[0], 0) == 8"
9543 "{stsi|stswi} %2,%1,%O0"
9544 [(set_attr "type" "store_ux")])
9545
9546(define_insn "*stmsi6_power"
9547 [(match_parallel 0 "store_multiple_operation"
9548 [(set (mem:SI (match_operand:SI 1 "gpc_reg_operand" "b"))
9549 (match_operand:SI 2 "gpc_reg_operand" "r"))
1958f718 9550 (clobber (match_scratch:SI 3 "=q"))
d2894ab5
DE
9551 (set (mem:SI (plus:SI (match_dup 1) (const_int 4)))
9552 (match_operand:SI 4 "gpc_reg_operand" "r"))
9553 (set (mem:SI (plus:SI (match_dup 1) (const_int 8)))
9554 (match_operand:SI 5 "gpc_reg_operand" "r"))
9555 (set (mem:SI (plus:SI (match_dup 1) (const_int 12)))
9556 (match_operand:SI 6 "gpc_reg_operand" "r"))
9557 (set (mem:SI (plus:SI (match_dup 1) (const_int 16)))
9558 (match_operand:SI 7 "gpc_reg_operand" "r"))
9559 (set (mem:SI (plus:SI (match_dup 1) (const_int 20)))
9560 (match_operand:SI 8 "gpc_reg_operand" "r"))])]
9561 "TARGET_STRING && TARGET_POWER && XVECLEN (operands[0], 0) == 7"
9562 "{stsi|stswi} %2,%1,%O0"
9563 [(set_attr "type" "store_ux")])
9564
9565(define_insn "*stmsi5_power"
9566 [(match_parallel 0 "store_multiple_operation"
9567 [(set (mem:SI (match_operand:SI 1 "gpc_reg_operand" "b"))
9568 (match_operand:SI 2 "gpc_reg_operand" "r"))
1958f718 9569 (clobber (match_scratch:SI 3 "=q"))
d2894ab5
DE
9570 (set (mem:SI (plus:SI (match_dup 1) (const_int 4)))
9571 (match_operand:SI 4 "gpc_reg_operand" "r"))
9572 (set (mem:SI (plus:SI (match_dup 1) (const_int 8)))
9573 (match_operand:SI 5 "gpc_reg_operand" "r"))
9574 (set (mem:SI (plus:SI (match_dup 1) (const_int 12)))
9575 (match_operand:SI 6 "gpc_reg_operand" "r"))
9576 (set (mem:SI (plus:SI (match_dup 1) (const_int 16)))
9577 (match_operand:SI 7 "gpc_reg_operand" "r"))])]
9578 "TARGET_STRING && TARGET_POWER && XVECLEN (operands[0], 0) == 6"
9579 "{stsi|stswi} %2,%1,%O0"
9580 [(set_attr "type" "store_ux")])
9581
9582(define_insn "*stmsi4_power"
9583 [(match_parallel 0 "store_multiple_operation"
9584 [(set (mem:SI (match_operand:SI 1 "gpc_reg_operand" "b"))
9585 (match_operand:SI 2 "gpc_reg_operand" "r"))
1958f718 9586 (clobber (match_scratch:SI 3 "=q"))
d2894ab5
DE
9587 (set (mem:SI (plus:SI (match_dup 1) (const_int 4)))
9588 (match_operand:SI 4 "gpc_reg_operand" "r"))
9589 (set (mem:SI (plus:SI (match_dup 1) (const_int 8)))
9590 (match_operand:SI 5 "gpc_reg_operand" "r"))
9591 (set (mem:SI (plus:SI (match_dup 1) (const_int 12)))
9592 (match_operand:SI 6 "gpc_reg_operand" "r"))])]
9593 "TARGET_STRING && TARGET_POWER && XVECLEN (operands[0], 0) == 5"
9594 "{stsi|stswi} %2,%1,%O0"
9595 [(set_attr "type" "store_ux")])
9596
9597(define_insn "*stmsi3_power"
9598 [(match_parallel 0 "store_multiple_operation"
9599 [(set (mem:SI (match_operand:SI 1 "gpc_reg_operand" "b"))
9600 (match_operand:SI 2 "gpc_reg_operand" "r"))
1958f718 9601 (clobber (match_scratch:SI 3 "=q"))
d2894ab5
DE
9602 (set (mem:SI (plus:SI (match_dup 1) (const_int 4)))
9603 (match_operand:SI 4 "gpc_reg_operand" "r"))
9604 (set (mem:SI (plus:SI (match_dup 1) (const_int 8)))
9605 (match_operand:SI 5 "gpc_reg_operand" "r"))])]
9606 "TARGET_STRING && TARGET_POWER && XVECLEN (operands[0], 0) == 4"
9607 "{stsi|stswi} %2,%1,%O0"
9608 [(set_attr "type" "store_ux")])
7e69e155 9609\f
57e84f18 9610(define_expand "setmemsi"
fba73eb1 9611 [(parallel [(set (match_operand:BLK 0 "" "")
98843c92 9612 (match_operand 2 "const_int_operand" ""))
fba73eb1 9613 (use (match_operand:SI 1 "" ""))
57e84f18 9614 (use (match_operand:SI 3 "" ""))])]
fba73eb1
DE
9615 ""
9616 "
9617{
57e84f18 9618 /* If value to set is not zero, use the library routine. */
a05be2e0 9619 if (operands[2] != const0_rtx)
57e84f18
AS
9620 FAIL;
9621
fba73eb1
DE
9622 if (expand_block_clear (operands))
9623 DONE;
9624 else
9625 FAIL;
9626}")
9627
7e69e155
MM
9628;; String/block move insn.
9629;; Argument 0 is the destination
9630;; Argument 1 is the source
9631;; Argument 2 is the length
9632;; Argument 3 is the alignment
9633
70128ad9 9634(define_expand "movmemsi"
b6c9286a
MM
9635 [(parallel [(set (match_operand:BLK 0 "" "")
9636 (match_operand:BLK 1 "" ""))
9637 (use (match_operand:SI 2 "" ""))
9638 (use (match_operand:SI 3 "" ""))])]
7e69e155
MM
9639 ""
9640 "
9641{
9642 if (expand_block_move (operands))
9643 DONE;
9644 else
9645 FAIL;
9646}")
9647
9648;; Move up to 32 bytes at a time. The fixed registers are needed because the
f9562f27
DE
9649;; register allocator doesn't have a clue about allocating 8 word registers.
9650;; rD/rS = r5 is preferred, efficient form.
70128ad9 9651(define_expand "movmemsi_8reg"
b6c9286a
MM
9652 [(parallel [(set (match_operand 0 "" "")
9653 (match_operand 1 "" ""))
9654 (use (match_operand 2 "" ""))
9655 (use (match_operand 3 "" ""))
7e69e155
MM
9656 (clobber (reg:SI 5))
9657 (clobber (reg:SI 6))
9658 (clobber (reg:SI 7))
9659 (clobber (reg:SI 8))
9660 (clobber (reg:SI 9))
9661 (clobber (reg:SI 10))
9662 (clobber (reg:SI 11))
9663 (clobber (reg:SI 12))
3c67b673 9664 (clobber (match_scratch:SI 4 ""))])]
7e69e155
MM
9665 "TARGET_STRING"
9666 "")
9667
9668(define_insn ""
52d3af72
DE
9669 [(set (mem:BLK (match_operand:SI 0 "gpc_reg_operand" "b"))
9670 (mem:BLK (match_operand:SI 1 "gpc_reg_operand" "b")))
3c67b673
RK
9671 (use (match_operand:SI 2 "immediate_operand" "i"))
9672 (use (match_operand:SI 3 "immediate_operand" "i"))
423addc5 9673 (clobber (match_operand:SI 4 "gpc_reg_operand" "=&r"))
7e69e155
MM
9674 (clobber (reg:SI 6))
9675 (clobber (reg:SI 7))
9676 (clobber (reg:SI 8))
9677 (clobber (reg:SI 9))
9678 (clobber (reg:SI 10))
9679 (clobber (reg:SI 11))
9680 (clobber (reg:SI 12))
3c67b673 9681 (clobber (match_scratch:SI 5 "=q"))]
7e69e155 9682 "TARGET_STRING && TARGET_POWER
f9562f27
DE
9683 && ((INTVAL (operands[2]) > 24 && INTVAL (operands[2]) < 32)
9684 || INTVAL (operands[2]) == 0)
7e69e155
MM
9685 && (REGNO (operands[0]) < 5 || REGNO (operands[0]) > 12)
9686 && (REGNO (operands[1]) < 5 || REGNO (operands[1]) > 12)
3c67b673
RK
9687 && REGNO (operands[4]) == 5"
9688 "{lsi|lswi} %4,%1,%2\;{stsi|stswi} %4,%0,%2"
9c6fdb46 9689 [(set_attr "type" "store_ux")
b7ff3d82 9690 (set_attr "length" "8")])
7e69e155
MM
9691
9692(define_insn ""
4ae234b0
GK
9693 [(set (mem:BLK (match_operand:P 0 "gpc_reg_operand" "b"))
9694 (mem:BLK (match_operand:P 1 "gpc_reg_operand" "b")))
3c67b673
RK
9695 (use (match_operand:SI 2 "immediate_operand" "i"))
9696 (use (match_operand:SI 3 "immediate_operand" "i"))
423addc5 9697 (clobber (match_operand:SI 4 "gpc_reg_operand" "=&r"))
7e69e155
MM
9698 (clobber (reg:SI 6))
9699 (clobber (reg:SI 7))
9700 (clobber (reg:SI 8))
9701 (clobber (reg:SI 9))
9702 (clobber (reg:SI 10))
9703 (clobber (reg:SI 11))
9704 (clobber (reg:SI 12))
edd54d25 9705 (clobber (match_scratch:SI 5 "=X"))]
0ad91047 9706 "TARGET_STRING && ! TARGET_POWER
f9562f27
DE
9707 && ((INTVAL (operands[2]) > 24 && INTVAL (operands[2]) < 32)
9708 || INTVAL (operands[2]) == 0)
7e69e155
MM
9709 && (REGNO (operands[0]) < 5 || REGNO (operands[0]) > 12)
9710 && (REGNO (operands[1]) < 5 || REGNO (operands[1]) > 12)
3c67b673
RK
9711 && REGNO (operands[4]) == 5"
9712 "{lsi|lswi} %4,%1,%2\;{stsi|stswi} %4,%0,%2"
9c6fdb46 9713 [(set_attr "type" "store_ux")
b7ff3d82 9714 (set_attr "length" "8")])
7e69e155
MM
9715
9716;; Move up to 24 bytes at a time. The fixed registers are needed because the
f9562f27
DE
9717;; register allocator doesn't have a clue about allocating 6 word registers.
9718;; rD/rS = r5 is preferred, efficient form.
70128ad9 9719(define_expand "movmemsi_6reg"
b6c9286a
MM
9720 [(parallel [(set (match_operand 0 "" "")
9721 (match_operand 1 "" ""))
9722 (use (match_operand 2 "" ""))
9723 (use (match_operand 3 "" ""))
f9562f27
DE
9724 (clobber (reg:SI 5))
9725 (clobber (reg:SI 6))
7e69e155
MM
9726 (clobber (reg:SI 7))
9727 (clobber (reg:SI 8))
9728 (clobber (reg:SI 9))
9729 (clobber (reg:SI 10))
3c67b673 9730 (clobber (match_scratch:SI 4 ""))])]
7e69e155
MM
9731 "TARGET_STRING"
9732 "")
9733
9734(define_insn ""
52d3af72
DE
9735 [(set (mem:BLK (match_operand:SI 0 "gpc_reg_operand" "b"))
9736 (mem:BLK (match_operand:SI 1 "gpc_reg_operand" "b")))
3c67b673
RK
9737 (use (match_operand:SI 2 "immediate_operand" "i"))
9738 (use (match_operand:SI 3 "immediate_operand" "i"))
423addc5 9739 (clobber (match_operand:SI 4 "gpc_reg_operand" "=&r"))
f9562f27
DE
9740 (clobber (reg:SI 6))
9741 (clobber (reg:SI 7))
7e69e155
MM
9742 (clobber (reg:SI 8))
9743 (clobber (reg:SI 9))
9744 (clobber (reg:SI 10))
3c67b673 9745 (clobber (match_scratch:SI 5 "=q"))]
7e69e155
MM
9746 "TARGET_STRING && TARGET_POWER
9747 && INTVAL (operands[2]) > 16 && INTVAL (operands[2]) <= 24
f9562f27
DE
9748 && (REGNO (operands[0]) < 5 || REGNO (operands[0]) > 10)
9749 && (REGNO (operands[1]) < 5 || REGNO (operands[1]) > 10)
9750 && REGNO (operands[4]) == 5"
3c67b673 9751 "{lsi|lswi} %4,%1,%2\;{stsi|stswi} %4,%0,%2"
9c6fdb46 9752 [(set_attr "type" "store_ux")
b7ff3d82 9753 (set_attr "length" "8")])
7e69e155
MM
9754
9755(define_insn ""
4ae234b0
GK
9756 [(set (mem:BLK (match_operand:P 0 "gpc_reg_operand" "b"))
9757 (mem:BLK (match_operand:P 1 "gpc_reg_operand" "b")))
3c67b673
RK
9758 (use (match_operand:SI 2 "immediate_operand" "i"))
9759 (use (match_operand:SI 3 "immediate_operand" "i"))
423addc5 9760 (clobber (match_operand:SI 4 "gpc_reg_operand" "=&r"))
f9562f27
DE
9761 (clobber (reg:SI 6))
9762 (clobber (reg:SI 7))
7e69e155
MM
9763 (clobber (reg:SI 8))
9764 (clobber (reg:SI 9))
9765 (clobber (reg:SI 10))
edd54d25 9766 (clobber (match_scratch:SI 5 "=X"))]
0ad91047 9767 "TARGET_STRING && ! TARGET_POWER
7e69e155 9768 && INTVAL (operands[2]) > 16 && INTVAL (operands[2]) <= 32
f9562f27
DE
9769 && (REGNO (operands[0]) < 5 || REGNO (operands[0]) > 10)
9770 && (REGNO (operands[1]) < 5 || REGNO (operands[1]) > 10)
9771 && REGNO (operands[4]) == 5"
3c67b673 9772 "{lsi|lswi} %4,%1,%2\;{stsi|stswi} %4,%0,%2"
9c6fdb46 9773 [(set_attr "type" "store_ux")
b7ff3d82 9774 (set_attr "length" "8")])
7e69e155 9775
f9562f27
DE
9776;; Move up to 16 bytes at a time, using 4 fixed registers to avoid spill
9777;; problems with TImode.
9778;; rD/rS = r5 is preferred, efficient form.
70128ad9 9779(define_expand "movmemsi_4reg"
b6c9286a
MM
9780 [(parallel [(set (match_operand 0 "" "")
9781 (match_operand 1 "" ""))
9782 (use (match_operand 2 "" ""))
9783 (use (match_operand 3 "" ""))
f9562f27
DE
9784 (clobber (reg:SI 5))
9785 (clobber (reg:SI 6))
9786 (clobber (reg:SI 7))
9787 (clobber (reg:SI 8))
3c67b673 9788 (clobber (match_scratch:SI 4 ""))])]
7e69e155
MM
9789 "TARGET_STRING"
9790 "")
9791
9792(define_insn ""
52d3af72
DE
9793 [(set (mem:BLK (match_operand:SI 0 "gpc_reg_operand" "b"))
9794 (mem:BLK (match_operand:SI 1 "gpc_reg_operand" "b")))
3c67b673
RK
9795 (use (match_operand:SI 2 "immediate_operand" "i"))
9796 (use (match_operand:SI 3 "immediate_operand" "i"))
423addc5 9797 (clobber (match_operand:SI 4 "gpc_reg_operand" "=&r"))
f9562f27
DE
9798 (clobber (reg:SI 6))
9799 (clobber (reg:SI 7))
9800 (clobber (reg:SI 8))
3c67b673 9801 (clobber (match_scratch:SI 5 "=q"))]
7e69e155
MM
9802 "TARGET_STRING && TARGET_POWER
9803 && INTVAL (operands[2]) > 8 && INTVAL (operands[2]) <= 16
f9562f27
DE
9804 && (REGNO (operands[0]) < 5 || REGNO (operands[0]) > 8)
9805 && (REGNO (operands[1]) < 5 || REGNO (operands[1]) > 8)
9806 && REGNO (operands[4]) == 5"
3c67b673 9807 "{lsi|lswi} %4,%1,%2\;{stsi|stswi} %4,%0,%2"
9c6fdb46 9808 [(set_attr "type" "store_ux")
b7ff3d82 9809 (set_attr "length" "8")])
7e69e155
MM
9810
9811(define_insn ""
4ae234b0
GK
9812 [(set (mem:BLK (match_operand:P 0 "gpc_reg_operand" "b"))
9813 (mem:BLK (match_operand:P 1 "gpc_reg_operand" "b")))
3c67b673
RK
9814 (use (match_operand:SI 2 "immediate_operand" "i"))
9815 (use (match_operand:SI 3 "immediate_operand" "i"))
423addc5 9816 (clobber (match_operand:SI 4 "gpc_reg_operand" "=&r"))
f9562f27
DE
9817 (clobber (reg:SI 6))
9818 (clobber (reg:SI 7))
9819 (clobber (reg:SI 8))
edd54d25 9820 (clobber (match_scratch:SI 5 "=X"))]
0ad91047 9821 "TARGET_STRING && ! TARGET_POWER
7e69e155 9822 && INTVAL (operands[2]) > 8 && INTVAL (operands[2]) <= 16
f9562f27
DE
9823 && (REGNO (operands[0]) < 5 || REGNO (operands[0]) > 8)
9824 && (REGNO (operands[1]) < 5 || REGNO (operands[1]) > 8)
9825 && REGNO (operands[4]) == 5"
3c67b673 9826 "{lsi|lswi} %4,%1,%2\;{stsi|stswi} %4,%0,%2"
9c6fdb46 9827 [(set_attr "type" "store_ux")
b7ff3d82 9828 (set_attr "length" "8")])
7e69e155
MM
9829
9830;; Move up to 8 bytes at a time.
70128ad9 9831(define_expand "movmemsi_2reg"
b6c9286a
MM
9832 [(parallel [(set (match_operand 0 "" "")
9833 (match_operand 1 "" ""))
9834 (use (match_operand 2 "" ""))
9835 (use (match_operand 3 "" ""))
3c67b673
RK
9836 (clobber (match_scratch:DI 4 ""))
9837 (clobber (match_scratch:SI 5 ""))])]
f9562f27 9838 "TARGET_STRING && ! TARGET_POWERPC64"
7e69e155
MM
9839 "")
9840
9841(define_insn ""
52d3af72
DE
9842 [(set (mem:BLK (match_operand:SI 0 "gpc_reg_operand" "b"))
9843 (mem:BLK (match_operand:SI 1 "gpc_reg_operand" "b")))
3c67b673
RK
9844 (use (match_operand:SI 2 "immediate_operand" "i"))
9845 (use (match_operand:SI 3 "immediate_operand" "i"))
9846 (clobber (match_scratch:DI 4 "=&r"))
9847 (clobber (match_scratch:SI 5 "=q"))]
f9562f27 9848 "TARGET_STRING && TARGET_POWER && ! TARGET_POWERPC64
3c67b673
RK
9849 && INTVAL (operands[2]) > 4 && INTVAL (operands[2]) <= 8"
9850 "{lsi|lswi} %4,%1,%2\;{stsi|stswi} %4,%0,%2"
9c6fdb46 9851 [(set_attr "type" "store_ux")
b7ff3d82 9852 (set_attr "length" "8")])
7e69e155
MM
9853
9854(define_insn ""
52d3af72
DE
9855 [(set (mem:BLK (match_operand:SI 0 "gpc_reg_operand" "b"))
9856 (mem:BLK (match_operand:SI 1 "gpc_reg_operand" "b")))
3c67b673
RK
9857 (use (match_operand:SI 2 "immediate_operand" "i"))
9858 (use (match_operand:SI 3 "immediate_operand" "i"))
9859 (clobber (match_scratch:DI 4 "=&r"))
edd54d25 9860 (clobber (match_scratch:SI 5 "=X"))]
f9562f27 9861 "TARGET_STRING && ! TARGET_POWER && ! TARGET_POWERPC64
7e69e155 9862 && INTVAL (operands[2]) > 4 && INTVAL (operands[2]) <= 8"
3c67b673 9863 "{lsi|lswi} %4,%1,%2\;{stsi|stswi} %4,%0,%2"
9c6fdb46 9864 [(set_attr "type" "store_ux")
b7ff3d82 9865 (set_attr "length" "8")])
7e69e155
MM
9866
9867;; Move up to 4 bytes at a time.
70128ad9 9868(define_expand "movmemsi_1reg"
b6c9286a
MM
9869 [(parallel [(set (match_operand 0 "" "")
9870 (match_operand 1 "" ""))
9871 (use (match_operand 2 "" ""))
9872 (use (match_operand 3 "" ""))
3c67b673
RK
9873 (clobber (match_scratch:SI 4 ""))
9874 (clobber (match_scratch:SI 5 ""))])]
7e69e155
MM
9875 "TARGET_STRING"
9876 "")
9877
9878(define_insn ""
52d3af72
DE
9879 [(set (mem:BLK (match_operand:SI 0 "gpc_reg_operand" "b"))
9880 (mem:BLK (match_operand:SI 1 "gpc_reg_operand" "b")))
3c67b673
RK
9881 (use (match_operand:SI 2 "immediate_operand" "i"))
9882 (use (match_operand:SI 3 "immediate_operand" "i"))
9883 (clobber (match_scratch:SI 4 "=&r"))
9884 (clobber (match_scratch:SI 5 "=q"))]
7e69e155
MM
9885 "TARGET_STRING && TARGET_POWER
9886 && INTVAL (operands[2]) > 0 && INTVAL (operands[2]) <= 4"
3c67b673 9887 "{lsi|lswi} %4,%1,%2\;{stsi|stswi} %4,%0,%2"
9c6fdb46 9888 [(set_attr "type" "store_ux")
b7ff3d82 9889 (set_attr "length" "8")])
7e69e155
MM
9890
9891(define_insn ""
4ae234b0
GK
9892 [(set (mem:BLK (match_operand:P 0 "gpc_reg_operand" "b"))
9893 (mem:BLK (match_operand:P 1 "gpc_reg_operand" "b")))
3c67b673
RK
9894 (use (match_operand:SI 2 "immediate_operand" "i"))
9895 (use (match_operand:SI 3 "immediate_operand" "i"))
9896 (clobber (match_scratch:SI 4 "=&r"))
edd54d25 9897 (clobber (match_scratch:SI 5 "=X"))]
0ad91047 9898 "TARGET_STRING && ! TARGET_POWER
7e69e155 9899 && INTVAL (operands[2]) > 0 && INTVAL (operands[2]) <= 4"
09a625f7 9900 "{lsi|lswi} %4,%1,%2\;{stsi|stswi} %4,%0,%2"
9c6fdb46 9901 [(set_attr "type" "store_ux")
09a625f7 9902 (set_attr "length" "8")])
1fd4e8c1 9903\f
7e69e155 9904;; Define insns that do load or store with update. Some of these we can
1fd4e8c1
RK
9905;; get by using pre-decrement or pre-increment, but the hardware can also
9906;; do cases where the increment is not the size of the object.
9907;;
9908;; In all these cases, we use operands 0 and 1 for the register being
9909;; incremented because those are the operands that local-alloc will
9910;; tie and these are the pair most likely to be tieable (and the ones
9911;; that will benefit the most).
9912
38c1f2d7 9913(define_insn "*movdi_update1"
51b8fc2c 9914 [(set (match_operand:DI 3 "gpc_reg_operand" "=r,r")
ad8bd902 9915 (mem:DI (plus:DI (match_operand:DI 1 "gpc_reg_operand" "0,0")
768070a0 9916 (match_operand:DI 2 "reg_or_aligned_short_operand" "r,I"))))
51b8fc2c
RK
9917 (set (match_operand:DI 0 "gpc_reg_operand" "=b,b")
9918 (plus:DI (match_dup 1) (match_dup 2)))]
38c1f2d7 9919 "TARGET_POWERPC64 && TARGET_UPDATE"
51b8fc2c
RK
9920 "@
9921 ldux %3,%0,%2
9922 ldu %3,%2(%0)"
b54cf83a 9923 [(set_attr "type" "load_ux,load_u")])
287f13ff 9924
2e6c9641
FJ
9925(define_insn "movdi_<mode>_update"
9926 [(set (mem:DI (plus:P (match_operand:P 1 "gpc_reg_operand" "0,0")
9927 (match_operand:P 2 "reg_or_aligned_short_operand" "r,I")))
51b8fc2c 9928 (match_operand:DI 3 "gpc_reg_operand" "r,r"))
2e6c9641
FJ
9929 (set (match_operand:P 0 "gpc_reg_operand" "=b,b")
9930 (plus:P (match_dup 1) (match_dup 2)))]
38c1f2d7 9931 "TARGET_POWERPC64 && TARGET_UPDATE"
51b8fc2c
RK
9932 "@
9933 stdux %3,%0,%2
b7ff3d82 9934 stdu %3,%2(%0)"
b54cf83a 9935 [(set_attr "type" "store_ux,store_u")])
51b8fc2c 9936
38c1f2d7 9937(define_insn "*movsi_update1"
cd2b37d9
RK
9938 [(set (match_operand:SI 3 "gpc_reg_operand" "=r,r")
9939 (mem:SI (plus:SI (match_operand:SI 1 "gpc_reg_operand" "0,0")
1fd4e8c1 9940 (match_operand:SI 2 "reg_or_short_operand" "r,I"))))
cd2b37d9 9941 (set (match_operand:SI 0 "gpc_reg_operand" "=b,b")
1fd4e8c1 9942 (plus:SI (match_dup 1) (match_dup 2)))]
f7b3ab8a 9943 "TARGET_UPDATE"
1fd4e8c1 9944 "@
ca7f5001
RK
9945 {lux|lwzux} %3,%0,%2
9946 {lu|lwzu} %3,%2(%0)"
b54cf83a
DE
9947 [(set_attr "type" "load_ux,load_u")])
9948
9949(define_insn "*movsi_update2"
9950 [(set (match_operand:DI 3 "gpc_reg_operand" "=r")
9951 (sign_extend:DI
9952 (mem:SI (plus:DI (match_operand:DI 1 "gpc_reg_operand" "0")
9953 (match_operand:DI 2 "gpc_reg_operand" "r")))))
9954 (set (match_operand:DI 0 "gpc_reg_operand" "=b")
9955 (plus:DI (match_dup 1) (match_dup 2)))]
9956 "TARGET_POWERPC64"
9957 "lwaux %3,%0,%2"
9958 [(set_attr "type" "load_ext_ux")])
1fd4e8c1 9959
4697a36c 9960(define_insn "movsi_update"
cd2b37d9 9961 [(set (mem:SI (plus:SI (match_operand:SI 1 "gpc_reg_operand" "0,0")
1fd4e8c1 9962 (match_operand:SI 2 "reg_or_short_operand" "r,I")))
cd2b37d9
RK
9963 (match_operand:SI 3 "gpc_reg_operand" "r,r"))
9964 (set (match_operand:SI 0 "gpc_reg_operand" "=b,b")
1fd4e8c1 9965 (plus:SI (match_dup 1) (match_dup 2)))]
38c1f2d7 9966 "TARGET_UPDATE"
1fd4e8c1 9967 "@
ca7f5001 9968 {stux|stwux} %3,%0,%2
b7ff3d82 9969 {stu|stwu} %3,%2(%0)"
b54cf83a 9970 [(set_attr "type" "store_ux,store_u")])
1fd4e8c1 9971
b54cf83a 9972(define_insn "*movhi_update1"
cd2b37d9
RK
9973 [(set (match_operand:HI 3 "gpc_reg_operand" "=r,r")
9974 (mem:HI (plus:SI (match_operand:SI 1 "gpc_reg_operand" "0,0")
1fd4e8c1 9975 (match_operand:SI 2 "reg_or_short_operand" "r,I"))))
cd2b37d9 9976 (set (match_operand:SI 0 "gpc_reg_operand" "=b,b")
1fd4e8c1 9977 (plus:SI (match_dup 1) (match_dup 2)))]
38c1f2d7 9978 "TARGET_UPDATE"
1fd4e8c1 9979 "@
5f243543
RK
9980 lhzux %3,%0,%2
9981 lhzu %3,%2(%0)"
b54cf83a 9982 [(set_attr "type" "load_ux,load_u")])
1fd4e8c1 9983
38c1f2d7 9984(define_insn "*movhi_update2"
cd2b37d9 9985 [(set (match_operand:SI 3 "gpc_reg_operand" "=r,r")
1fd4e8c1 9986 (zero_extend:SI
cd2b37d9 9987 (mem:HI (plus:SI (match_operand:SI 1 "gpc_reg_operand" "0,0")
1fd4e8c1 9988 (match_operand:SI 2 "reg_or_short_operand" "r,I")))))
cd2b37d9 9989 (set (match_operand:SI 0 "gpc_reg_operand" "=b,b")
1fd4e8c1 9990 (plus:SI (match_dup 1) (match_dup 2)))]
38c1f2d7 9991 "TARGET_UPDATE"
1fd4e8c1 9992 "@
5f243543
RK
9993 lhzux %3,%0,%2
9994 lhzu %3,%2(%0)"
b54cf83a 9995 [(set_attr "type" "load_ux,load_u")])
1fd4e8c1 9996
38c1f2d7 9997(define_insn "*movhi_update3"
cd2b37d9 9998 [(set (match_operand:SI 3 "gpc_reg_operand" "=r,r")
1fd4e8c1 9999 (sign_extend:SI
cd2b37d9 10000 (mem:HI (plus:SI (match_operand:SI 1 "gpc_reg_operand" "0,0")
1fd4e8c1 10001 (match_operand:SI 2 "reg_or_short_operand" "r,I")))))
cd2b37d9 10002 (set (match_operand:SI 0 "gpc_reg_operand" "=b,b")
1fd4e8c1 10003 (plus:SI (match_dup 1) (match_dup 2)))]
38c1f2d7 10004 "TARGET_UPDATE"
1fd4e8c1 10005 "@
5f243543
RK
10006 lhaux %3,%0,%2
10007 lhau %3,%2(%0)"
b54cf83a 10008 [(set_attr "type" "load_ext_ux,load_ext_u")])
1fd4e8c1 10009
38c1f2d7 10010(define_insn "*movhi_update4"
cd2b37d9 10011 [(set (mem:HI (plus:SI (match_operand:SI 1 "gpc_reg_operand" "0,0")
1fd4e8c1 10012 (match_operand:SI 2 "reg_or_short_operand" "r,I")))
cd2b37d9
RK
10013 (match_operand:HI 3 "gpc_reg_operand" "r,r"))
10014 (set (match_operand:SI 0 "gpc_reg_operand" "=b,b")
1fd4e8c1 10015 (plus:SI (match_dup 1) (match_dup 2)))]
38c1f2d7 10016 "TARGET_UPDATE"
1fd4e8c1 10017 "@
5f243543 10018 sthux %3,%0,%2
b7ff3d82 10019 sthu %3,%2(%0)"
b54cf83a 10020 [(set_attr "type" "store_ux,store_u")])
1fd4e8c1 10021
38c1f2d7 10022(define_insn "*movqi_update1"
cd2b37d9
RK
10023 [(set (match_operand:QI 3 "gpc_reg_operand" "=r,r")
10024 (mem:QI (plus:SI (match_operand:SI 1 "gpc_reg_operand" "0,0")
1fd4e8c1 10025 (match_operand:SI 2 "reg_or_short_operand" "r,I"))))
cd2b37d9 10026 (set (match_operand:SI 0 "gpc_reg_operand" "=b,b")
1fd4e8c1 10027 (plus:SI (match_dup 1) (match_dup 2)))]
38c1f2d7 10028 "TARGET_UPDATE"
1fd4e8c1 10029 "@
5f243543
RK
10030 lbzux %3,%0,%2
10031 lbzu %3,%2(%0)"
b54cf83a 10032 [(set_attr "type" "load_ux,load_u")])
1fd4e8c1 10033
38c1f2d7 10034(define_insn "*movqi_update2"
cd2b37d9 10035 [(set (match_operand:SI 3 "gpc_reg_operand" "=r,r")
1fd4e8c1 10036 (zero_extend:SI
cd2b37d9 10037 (mem:QI (plus:SI (match_operand:SI 1 "gpc_reg_operand" "0,0")
1fd4e8c1 10038 (match_operand:SI 2 "reg_or_short_operand" "r,I")))))
cd2b37d9 10039 (set (match_operand:SI 0 "gpc_reg_operand" "=b,b")
1fd4e8c1 10040 (plus:SI (match_dup 1) (match_dup 2)))]
38c1f2d7 10041 "TARGET_UPDATE"
1fd4e8c1 10042 "@
5f243543
RK
10043 lbzux %3,%0,%2
10044 lbzu %3,%2(%0)"
b54cf83a 10045 [(set_attr "type" "load_ux,load_u")])
1fd4e8c1 10046
38c1f2d7 10047(define_insn "*movqi_update3"
cd2b37d9 10048 [(set (mem:QI (plus:SI (match_operand:SI 1 "gpc_reg_operand" "0,0")
1fd4e8c1 10049 (match_operand:SI 2 "reg_or_short_operand" "r,I")))
cd2b37d9
RK
10050 (match_operand:QI 3 "gpc_reg_operand" "r,r"))
10051 (set (match_operand:SI 0 "gpc_reg_operand" "=b,b")
1fd4e8c1 10052 (plus:SI (match_dup 1) (match_dup 2)))]
38c1f2d7 10053 "TARGET_UPDATE"
1fd4e8c1 10054 "@
5f243543 10055 stbux %3,%0,%2
b7ff3d82 10056 stbu %3,%2(%0)"
b54cf83a 10057 [(set_attr "type" "store_ux,store_u")])
1fd4e8c1 10058
38c1f2d7 10059(define_insn "*movsf_update1"
cd2b37d9 10060 [(set (match_operand:SF 3 "gpc_reg_operand" "=f,f")
df8b713c 10061 (mem:SF (plus:SI (match_operand:SI 1 "gpc_reg_operand" "0,0")
1fd4e8c1 10062 (match_operand:SI 2 "reg_or_short_operand" "r,I"))))
cd2b37d9 10063 (set (match_operand:SI 0 "gpc_reg_operand" "=b,b")
1fd4e8c1 10064 (plus:SI (match_dup 1) (match_dup 2)))]
a3170dc6 10065 "TARGET_HARD_FLOAT && TARGET_FPRS && TARGET_UPDATE"
1fd4e8c1 10066 "@
5f243543
RK
10067 lfsux %3,%0,%2
10068 lfsu %3,%2(%0)"
b54cf83a 10069 [(set_attr "type" "fpload_ux,fpload_u")])
1fd4e8c1 10070
38c1f2d7 10071(define_insn "*movsf_update2"
cd2b37d9 10072 [(set (mem:SF (plus:SI (match_operand:SI 1 "gpc_reg_operand" "0,0")
1fd4e8c1 10073 (match_operand:SI 2 "reg_or_short_operand" "r,I")))
cd2b37d9
RK
10074 (match_operand:SF 3 "gpc_reg_operand" "f,f"))
10075 (set (match_operand:SI 0 "gpc_reg_operand" "=b,b")
1fd4e8c1 10076 (plus:SI (match_dup 1) (match_dup 2)))]
a3170dc6 10077 "TARGET_HARD_FLOAT && TARGET_FPRS && TARGET_UPDATE"
1fd4e8c1 10078 "@
85fff2f3 10079 stfsux %3,%0,%2
b7ff3d82 10080 stfsu %3,%2(%0)"
b54cf83a 10081 [(set_attr "type" "fpstore_ux,fpstore_u")])
1fd4e8c1 10082
38c1f2d7
MM
10083(define_insn "*movsf_update3"
10084 [(set (match_operand:SF 3 "gpc_reg_operand" "=r,r")
10085 (mem:SF (plus:SI (match_operand:SI 1 "gpc_reg_operand" "0,0")
10086 (match_operand:SI 2 "reg_or_short_operand" "r,I"))))
10087 (set (match_operand:SI 0 "gpc_reg_operand" "=b,b")
10088 (plus:SI (match_dup 1) (match_dup 2)))]
a3170dc6 10089 "(TARGET_SOFT_FLOAT || !TARGET_FPRS) && TARGET_UPDATE"
38c1f2d7
MM
10090 "@
10091 {lux|lwzux} %3,%0,%2
10092 {lu|lwzu} %3,%2(%0)"
b54cf83a 10093 [(set_attr "type" "load_ux,load_u")])
38c1f2d7
MM
10094
10095(define_insn "*movsf_update4"
10096 [(set (mem:SF (plus:SI (match_operand:SI 1 "gpc_reg_operand" "0,0")
10097 (match_operand:SI 2 "reg_or_short_operand" "r,I")))
10098 (match_operand:SF 3 "gpc_reg_operand" "r,r"))
10099 (set (match_operand:SI 0 "gpc_reg_operand" "=b,b")
10100 (plus:SI (match_dup 1) (match_dup 2)))]
a3170dc6 10101 "(TARGET_SOFT_FLOAT || !TARGET_FPRS) && TARGET_UPDATE"
38c1f2d7
MM
10102 "@
10103 {stux|stwux} %3,%0,%2
10104 {stu|stwu} %3,%2(%0)"
b54cf83a 10105 [(set_attr "type" "store_ux,store_u")])
38c1f2d7
MM
10106
10107(define_insn "*movdf_update1"
cd2b37d9
RK
10108 [(set (match_operand:DF 3 "gpc_reg_operand" "=f,f")
10109 (mem:DF (plus:SI (match_operand:SI 1 "gpc_reg_operand" "0,0")
1fd4e8c1 10110 (match_operand:SI 2 "reg_or_short_operand" "r,I"))))
cd2b37d9 10111 (set (match_operand:SI 0 "gpc_reg_operand" "=b,b")
1fd4e8c1 10112 (plus:SI (match_dup 1) (match_dup 2)))]
a3170dc6 10113 "TARGET_HARD_FLOAT && TARGET_FPRS && TARGET_UPDATE"
1fd4e8c1 10114 "@
5f243543
RK
10115 lfdux %3,%0,%2
10116 lfdu %3,%2(%0)"
b54cf83a 10117 [(set_attr "type" "fpload_ux,fpload_u")])
1fd4e8c1 10118
38c1f2d7 10119(define_insn "*movdf_update2"
cd2b37d9 10120 [(set (mem:DF (plus:SI (match_operand:SI 1 "gpc_reg_operand" "0,0")
1fd4e8c1 10121 (match_operand:SI 2 "reg_or_short_operand" "r,I")))
cd2b37d9
RK
10122 (match_operand:DF 3 "gpc_reg_operand" "f,f"))
10123 (set (match_operand:SI 0 "gpc_reg_operand" "=b,b")
1fd4e8c1 10124 (plus:SI (match_dup 1) (match_dup 2)))]
a3170dc6 10125 "TARGET_HARD_FLOAT && TARGET_FPRS && TARGET_UPDATE"
1fd4e8c1 10126 "@
5f243543 10127 stfdux %3,%0,%2
b7ff3d82 10128 stfdu %3,%2(%0)"
b54cf83a 10129 [(set_attr "type" "fpstore_ux,fpstore_u")])
4c70a4f3
RK
10130
10131;; Peephole to convert two consecutive FP loads or stores into lfq/stfq.
10132
90f81f99 10133(define_insn "*lfq_power2"
bb8df8a6
EC
10134 [(set (match_operand:V2DF 0 "gpc_reg_operand" "=f")
10135 (match_operand:V2DF 1 "memory_operand" ""))]
90f81f99
AP
10136 "TARGET_POWER2
10137 && TARGET_HARD_FLOAT && TARGET_FPRS"
bb8df8a6 10138 "lfq%U1%X1 %0,%1")
90f81f99
AP
10139
10140(define_peephole2
10141 [(set (match_operand:DF 0 "gpc_reg_operand" "")
4c70a4f3 10142 (match_operand:DF 1 "memory_operand" ""))
90f81f99 10143 (set (match_operand:DF 2 "gpc_reg_operand" "")
4c70a4f3
RK
10144 (match_operand:DF 3 "memory_operand" ""))]
10145 "TARGET_POWER2
a3170dc6 10146 && TARGET_HARD_FLOAT && TARGET_FPRS
4c70a4f3 10147 && registers_ok_for_quad_peep (operands[0], operands[2])
90f81f99
AP
10148 && mems_ok_for_quad_peep (operands[1], operands[3])"
10149 [(set (match_dup 0)
bb8df8a6
EC
10150 (match_dup 1))]
10151 "operands[1] = widen_memory_access (operands[1], V2DFmode, 0);
10152 operands[0] = gen_rtx_REG (V2DFmode, REGNO (operands[0]));")
4c70a4f3 10153
90f81f99 10154(define_insn "*stfq_power2"
bb8df8a6
EC
10155 [(set (match_operand:V2DF 0 "memory_operand" "")
10156 (match_operand:V2DF 1 "gpc_reg_operand" "f"))]
90f81f99
AP
10157 "TARGET_POWER2
10158 && TARGET_HARD_FLOAT && TARGET_FPRS"
10159 "stfq%U0%X0 %1,%0")
10160
10161
10162(define_peephole2
4c70a4f3 10163 [(set (match_operand:DF 0 "memory_operand" "")
90f81f99 10164 (match_operand:DF 1 "gpc_reg_operand" ""))
4c70a4f3 10165 (set (match_operand:DF 2 "memory_operand" "")
90f81f99 10166 (match_operand:DF 3 "gpc_reg_operand" ""))]
4c70a4f3 10167 "TARGET_POWER2
a3170dc6 10168 && TARGET_HARD_FLOAT && TARGET_FPRS
4c70a4f3 10169 && registers_ok_for_quad_peep (operands[1], operands[3])
90f81f99
AP
10170 && mems_ok_for_quad_peep (operands[0], operands[2])"
10171 [(set (match_dup 0)
10172 (match_dup 1))]
bb8df8a6
EC
10173 "operands[0] = widen_memory_access (operands[0], V2DFmode, 0);
10174 operands[1] = gen_rtx_REG (V2DFmode, REGNO (operands[1]));")
2f4d9502 10175
036aadfc 10176;; After inserting conditional returns we can sometimes have
2f4d9502
NS
10177;; unnecessary register moves. Unfortunately we cannot have a
10178;; modeless peephole here, because some single SImode sets have early
10179;; clobber outputs. Although those sets expand to multi-ppc-insn
10180;; sequences, using get_attr_length here will smash the operands
10181;; array. Neither is there an early_cobbler_p predicate.
036aadfc 10182;; Disallow subregs for E500 so we don't munge frob_di_df_2.
2f4d9502
NS
10183(define_peephole2
10184 [(set (match_operand:DF 0 "gpc_reg_operand" "")
10185 (match_operand:DF 1 "any_operand" ""))
10186 (set (match_operand:DF 2 "gpc_reg_operand" "")
10187 (match_dup 0))]
036aadfc
AM
10188 "!(TARGET_E500_DOUBLE && GET_CODE (operands[2]) == SUBREG)
10189 && peep2_reg_dead_p (2, operands[0])"
2f4d9502
NS
10190 [(set (match_dup 2) (match_dup 1))])
10191
10192(define_peephole2
10193 [(set (match_operand:SF 0 "gpc_reg_operand" "")
10194 (match_operand:SF 1 "any_operand" ""))
10195 (set (match_operand:SF 2 "gpc_reg_operand" "")
10196 (match_dup 0))]
10197 "peep2_reg_dead_p (2, operands[0])"
10198 [(set (match_dup 2) (match_dup 1))])
10199
1fd4e8c1 10200\f
c4501e62
JJ
10201;; TLS support.
10202
02135bc1
SB
10203;; Mode attributes for different ABIs.
10204(define_mode_iterator TLSmode [(SI "! TARGET_64BIT") (DI "TARGET_64BIT")])
10205(define_mode_attr tls_abi_suffix [(SI "32") (DI "64")])
10206(define_mode_attr tls_sysv_suffix [(SI "si") (DI "di")])
10207(define_mode_attr tls_insn_suffix [(SI "wz") (DI "d")])
10208
10209(define_insn "tls_gd_aix<TLSmode:tls_abi_suffix>"
10210 [(set (match_operand:TLSmode 0 "gpc_reg_operand" "=b")
10211 (call (mem:TLSmode (match_operand:TLSmode 3 "symbol_ref_operand" "s"))
10212 (match_operand 4 "" "g")))
10213 (unspec:TLSmode [(match_operand:TLSmode 1 "gpc_reg_operand" "b")
10214 (match_operand:TLSmode 2 "rs6000_tls_symbol_ref" "")]
10215 UNSPEC_TLSGD)
10216 (clobber (reg:SI LR_REGNO))]
10217 "HAVE_AS_TLS && DEFAULT_ABI == ABI_AIX"
10218 "addi %0,%1,%2@got@tlsgd\;bl %z3\;%."
10219 [(set_attr "type" "two")
10220 (set_attr "length" "12")])
10221
10222(define_insn "tls_gd_sysv<TLSmode:tls_sysv_suffix>"
10223 [(set (match_operand:TLSmode 0 "gpc_reg_operand" "=b")
10224 (call (mem:TLSmode (match_operand:TLSmode 3 "symbol_ref_operand" "s"))
10225 (match_operand 4 "" "g")))
10226 (unspec:TLSmode [(match_operand:TLSmode 1 "gpc_reg_operand" "b")
10227 (match_operand:TLSmode 2 "rs6000_tls_symbol_ref" "")]
10228 UNSPEC_TLSGD)
10229 (clobber (reg:SI LR_REGNO))]
10230 "HAVE_AS_TLS && DEFAULT_ABI == ABI_V4"
10231{
10232 if (flag_pic)
10233 {
10234 if (TARGET_SECURE_PLT && flag_pic == 2)
10235 return "addi %0,%1,%2@got@tlsgd\;bl %z3+32768@plt";
10236 else
10237 return "addi %0,%1,%2@got@tlsgd\;bl %z3@plt";
10238 }
10239 else
10240 return "addi %0,%1,%2@got@tlsgd\;bl %z3";
10241}
10242 [(set_attr "type" "two")
10243 (set_attr "length" "8")])
c4501e62 10244
02135bc1
SB
10245(define_insn "tls_ld_aix<TLSmode:tls_abi_suffix>"
10246 [(set (match_operand:TLSmode 0 "gpc_reg_operand" "=b")
10247 (call (mem:TLSmode (match_operand:TLSmode 2 "symbol_ref_operand" "s"))
10248 (match_operand 3 "" "g")))
10249 (unspec:TLSmode [(match_operand:TLSmode 1 "gpc_reg_operand" "b")]
10250 UNSPEC_TLSLD)
10251 (clobber (reg:SI LR_REGNO))]
10252 "HAVE_AS_TLS && DEFAULT_ABI == ABI_AIX"
10253 "addi %0,%1,%&@got@tlsld\;bl %z2\;%."
10254 [(set_attr "length" "12")])
c4501e62 10255
02135bc1
SB
10256(define_insn "tls_ld_sysv<TLSmode:tls_sysv_suffix>"
10257 [(set (match_operand:TLSmode 0 "gpc_reg_operand" "=b")
10258 (call (mem:TLSmode (match_operand:TLSmode 2 "symbol_ref_operand" "s"))
10259 (match_operand 3 "" "g")))
10260 (unspec:TLSmode [(match_operand:TLSmode 1 "gpc_reg_operand" "b")]
10261 UNSPEC_TLSLD)
10262 (clobber (reg:SI LR_REGNO))]
10263 "HAVE_AS_TLS && DEFAULT_ABI == ABI_V4"
10264{
10265 if (flag_pic)
10266 {
10267 if (TARGET_SECURE_PLT && flag_pic == 2)
10268 return "addi %0,%1,%&@got@tlsld\;bl %z2+32768@plt";
10269 else
10270 return "addi %0,%1,%&@got@tlsld\;bl %z2@plt";
10271 }
10272 else
10273 return "addi %0,%1,%&@got@tlsld\;bl %z2";
10274}
10275 [(set_attr "length" "8")])
c4501e62 10276
02135bc1
SB
10277(define_insn "tls_dtprel_<TLSmode:tls_abi_suffix>"
10278 [(set (match_operand:TLSmode 0 "gpc_reg_operand" "=r")
10279 (unspec:TLSmode [(match_operand:TLSmode 1 "gpc_reg_operand" "b")
10280 (match_operand:TLSmode 2 "rs6000_tls_symbol_ref" "")]
10281 UNSPEC_TLSDTPREL))]
10282 "HAVE_AS_TLS"
10283 "addi %0,%1,%2@dtprel")
c4501e62 10284
02135bc1
SB
10285(define_insn "tls_dtprel_ha_<TLSmode:tls_abi_suffix>"
10286 [(set (match_operand:TLSmode 0 "gpc_reg_operand" "=r")
10287 (unspec:TLSmode [(match_operand:TLSmode 1 "gpc_reg_operand" "b")
10288 (match_operand:TLSmode 2 "rs6000_tls_symbol_ref" "")]
10289 UNSPEC_TLSDTPRELHA))]
10290 "HAVE_AS_TLS"
10291 "addis %0,%1,%2@dtprel@ha")
c4501e62 10292
02135bc1
SB
10293(define_insn "tls_dtprel_lo_<TLSmode:tls_abi_suffix>"
10294 [(set (match_operand:TLSmode 0 "gpc_reg_operand" "=r")
10295 (unspec:TLSmode [(match_operand:TLSmode 1 "gpc_reg_operand" "b")
10296 (match_operand:TLSmode 2 "rs6000_tls_symbol_ref" "")]
10297 UNSPEC_TLSDTPRELLO))]
10298 "HAVE_AS_TLS"
c4501e62
JJ
10299 "addi %0,%1,%2@dtprel@l")
10300
02135bc1
SB
10301(define_insn "tls_got_dtprel_<TLSmode:tls_abi_suffix>"
10302 [(set (match_operand:TLSmode 0 "gpc_reg_operand" "=r")
10303 (unspec:TLSmode [(match_operand:TLSmode 1 "gpc_reg_operand" "b")
10304 (match_operand:TLSmode 2 "rs6000_tls_symbol_ref" "")]
10305 UNSPEC_TLSGOTDTPREL))]
10306 "HAVE_AS_TLS"
10307 "l<TLSmode:tls_insn_suffix> %0,%2@got@dtprel(%1)")
10308
10309(define_insn "tls_tprel_<TLSmode:tls_abi_suffix>"
10310 [(set (match_operand:TLSmode 0 "gpc_reg_operand" "=r")
10311 (unspec:TLSmode [(match_operand:TLSmode 1 "gpc_reg_operand" "b")
10312 (match_operand:TLSmode 2 "rs6000_tls_symbol_ref" "")]
10313 UNSPEC_TLSTPREL))]
10314 "HAVE_AS_TLS"
c4501e62
JJ
10315 "addi %0,%1,%2@tprel")
10316
02135bc1
SB
10317(define_insn "tls_tprel_ha_<TLSmode:tls_abi_suffix>"
10318 [(set (match_operand:TLSmode 0 "gpc_reg_operand" "=r")
10319 (unspec:TLSmode [(match_operand:TLSmode 1 "gpc_reg_operand" "b")
10320 (match_operand:TLSmode 2 "rs6000_tls_symbol_ref" "")]
10321 UNSPEC_TLSTPRELHA))]
10322 "HAVE_AS_TLS"
c4501e62
JJ
10323 "addis %0,%1,%2@tprel@ha")
10324
02135bc1
SB
10325(define_insn "tls_tprel_lo_<TLSmode:tls_abi_suffix>"
10326 [(set (match_operand:TLSmode 0 "gpc_reg_operand" "=r")
10327 (unspec:TLSmode [(match_operand:TLSmode 1 "gpc_reg_operand" "b")
10328 (match_operand:TLSmode 2 "rs6000_tls_symbol_ref" "")]
10329 UNSPEC_TLSTPRELLO))]
10330 "HAVE_AS_TLS"
c4501e62
JJ
10331 "addi %0,%1,%2@tprel@l")
10332
c1207243 10333;; "b" output constraint here and on tls_tls input to support linker tls
c4501e62
JJ
10334;; optimization. The linker may edit the instructions emitted by a
10335;; tls_got_tprel/tls_tls pair to addis,addi.
02135bc1
SB
10336(define_insn "tls_got_tprel_<TLSmode:tls_abi_suffix>"
10337 [(set (match_operand:TLSmode 0 "gpc_reg_operand" "=b")
10338 (unspec:TLSmode [(match_operand:TLSmode 1 "gpc_reg_operand" "b")
10339 (match_operand:TLSmode 2 "rs6000_tls_symbol_ref" "")]
10340 UNSPEC_TLSGOTTPREL))]
10341 "HAVE_AS_TLS"
10342 "l<TLSmode:tls_insn_suffix> %0,%2@got@tprel(%1)")
10343
10344(define_insn "tls_tls_<TLSmode:tls_abi_suffix>"
10345 [(set (match_operand:TLSmode 0 "gpc_reg_operand" "=r")
10346 (unspec:TLSmode [(match_operand:TLSmode 1 "gpc_reg_operand" "b")
10347 (match_operand:TLSmode 2 "rs6000_tls_symbol_ref" "")]
10348 UNSPEC_TLSTLS))]
10349 "HAVE_AS_TLS"
c4501e62
JJ
10350 "add %0,%1,%2@tls")
10351
c4501e62 10352\f
1fd4e8c1
RK
10353;; Next come insns related to the calling sequence.
10354;;
10355;; First, an insn to allocate new stack space for dynamic use (e.g., alloca).
7e69e155 10356;; We move the back-chain and decrement the stack pointer.
1fd4e8c1
RK
10357
10358(define_expand "allocate_stack"
e42ac3de 10359 [(set (match_operand 0 "gpc_reg_operand" "")
a260abc9
DE
10360 (minus (reg 1) (match_operand 1 "reg_or_short_operand" "")))
10361 (set (reg 1)
10362 (minus (reg 1) (match_dup 1)))]
1fd4e8c1
RK
10363 ""
10364 "
4697a36c 10365{ rtx chain = gen_reg_rtx (Pmode);
39403d82 10366 rtx stack_bot = gen_rtx_MEM (Pmode, stack_pointer_rtx);
4697a36c 10367 rtx neg_op0;
1fd4e8c1
RK
10368
10369 emit_move_insn (chain, stack_bot);
4697a36c 10370
a157febd 10371 /* Check stack bounds if necessary. */
e3b5732b 10372 if (crtl->limit_stack)
a157febd
GK
10373 {
10374 rtx available;
6ae08853 10375 available = expand_binop (Pmode, sub_optab,
a157febd
GK
10376 stack_pointer_rtx, stack_limit_rtx,
10377 NULL_RTX, 1, OPTAB_WIDEN);
10378 emit_insn (gen_cond_trap (LTU, available, operands[1], const0_rtx));
10379 }
10380
e9a25f70
JL
10381 if (GET_CODE (operands[1]) != CONST_INT
10382 || INTVAL (operands[1]) < -32767
10383 || INTVAL (operands[1]) > 32768)
4697a36c
MM
10384 {
10385 neg_op0 = gen_reg_rtx (Pmode);
e6ca2c17 10386 if (TARGET_32BIT)
e9a25f70 10387 emit_insn (gen_negsi2 (neg_op0, operands[1]));
e6ca2c17 10388 else
e9a25f70 10389 emit_insn (gen_negdi2 (neg_op0, operands[1]));
4697a36c
MM
10390 }
10391 else
e9a25f70 10392 neg_op0 = GEN_INT (- INTVAL (operands[1]));
4697a36c 10393
38c1f2d7 10394 if (TARGET_UPDATE)
2e6c9641 10395 emit_insn ((* ((TARGET_32BIT) ? gen_movsi_update : gen_movdi_di_update))
38c1f2d7 10396 (stack_pointer_rtx, stack_pointer_rtx, neg_op0, chain));
4697a36c 10397
38c1f2d7
MM
10398 else
10399 {
10400 emit_insn ((* ((TARGET_32BIT) ? gen_addsi3 : gen_adddi3))
10401 (stack_pointer_rtx, stack_pointer_rtx, neg_op0));
39403d82 10402 emit_move_insn (gen_rtx_MEM (Pmode, stack_pointer_rtx), chain);
38c1f2d7 10403 }
e9a25f70
JL
10404
10405 emit_move_insn (operands[0], virtual_stack_dynamic_rtx);
1fd4e8c1
RK
10406 DONE;
10407}")
59257ff7
RK
10408
10409;; These patterns say how to save and restore the stack pointer. We need not
10410;; save the stack pointer at function level since we are careful to
10411;; preserve the backchain. At block level, we have to restore the backchain
10412;; when we restore the stack pointer.
10413;;
10414;; For nonlocal gotos, we must save both the stack pointer and its
10415;; backchain and restore both. Note that in the nonlocal case, the
10416;; save area is a memory location.
10417
10418(define_expand "save_stack_function"
ff381587
MM
10419 [(match_operand 0 "any_operand" "")
10420 (match_operand 1 "any_operand" "")]
59257ff7 10421 ""
ff381587 10422 "DONE;")
59257ff7
RK
10423
10424(define_expand "restore_stack_function"
ff381587
MM
10425 [(match_operand 0 "any_operand" "")
10426 (match_operand 1 "any_operand" "")]
59257ff7 10427 ""
ff381587 10428 "DONE;")
59257ff7 10429
2eef28ec
AM
10430;; Adjust stack pointer (op0) to a new value (op1).
10431;; First copy old stack backchain to new location, and ensure that the
10432;; scheduler won't reorder the sp assignment before the backchain write.
59257ff7 10433(define_expand "restore_stack_block"
2eef28ec
AM
10434 [(set (match_dup 2) (match_dup 3))
10435 (set (match_dup 4) (match_dup 2))
10436 (set (match_dup 5) (unspec:BLK [(match_dup 5)] UNSPEC_TIE))
10437 (set (match_operand 0 "register_operand" "")
10438 (match_operand 1 "register_operand" ""))]
59257ff7
RK
10439 ""
10440 "
dfdfa60f 10441{
583da60a 10442 operands[1] = force_reg (Pmode, operands[1]);
dfdfa60f 10443 operands[2] = gen_reg_rtx (Pmode);
2eef28ec
AM
10444 operands[3] = gen_frame_mem (Pmode, operands[0]);
10445 operands[4] = gen_frame_mem (Pmode, operands[1]);
10446 operands[5] = gen_frame_mem (BLKmode, operands[0]);
dfdfa60f 10447}")
59257ff7
RK
10448
10449(define_expand "save_stack_nonlocal"
2eef28ec
AM
10450 [(set (match_dup 3) (match_dup 4))
10451 (set (match_operand 0 "memory_operand" "") (match_dup 3))
10452 (set (match_dup 2) (match_operand 1 "register_operand" ""))]
59257ff7
RK
10453 ""
10454 "
10455{
11b25716 10456 int units_per_word = (TARGET_32BIT) ? 4 : 8;
59257ff7
RK
10457
10458 /* Copy the backchain to the first word, sp to the second. */
2eef28ec
AM
10459 operands[0] = adjust_address_nv (operands[0], Pmode, 0);
10460 operands[2] = adjust_address_nv (operands[0], Pmode, units_per_word);
10461 operands[3] = gen_reg_rtx (Pmode);
10462 operands[4] = gen_frame_mem (Pmode, operands[1]);
59257ff7 10463}")
7e69e155 10464
59257ff7 10465(define_expand "restore_stack_nonlocal"
2eef28ec
AM
10466 [(set (match_dup 2) (match_operand 1 "memory_operand" ""))
10467 (set (match_dup 3) (match_dup 4))
10468 (set (match_dup 5) (match_dup 2))
10469 (set (match_dup 6) (unspec:BLK [(match_dup 6)] UNSPEC_TIE))
10470 (set (match_operand 0 "register_operand" "") (match_dup 3))]
59257ff7
RK
10471 ""
10472 "
10473{
11b25716 10474 int units_per_word = (TARGET_32BIT) ? 4 : 8;
59257ff7
RK
10475
10476 /* Restore the backchain from the first word, sp from the second. */
2eef28ec
AM
10477 operands[2] = gen_reg_rtx (Pmode);
10478 operands[3] = gen_reg_rtx (Pmode);
10479 operands[1] = adjust_address_nv (operands[1], Pmode, 0);
10480 operands[4] = adjust_address_nv (operands[1], Pmode, units_per_word);
10481 operands[5] = gen_frame_mem (Pmode, operands[3]);
10482 operands[6] = gen_frame_mem (BLKmode, operands[0]);
59257ff7 10483}")
9ebbca7d
GK
10484\f
10485;; TOC register handling.
b6c9286a 10486
9ebbca7d 10487;; Code to initialize the TOC register...
f0f6a223 10488
9ebbca7d 10489(define_insn "load_toc_aix_si"
e72247f4 10490 [(parallel [(set (match_operand:SI 0 "gpc_reg_operand" "=r")
615158e2 10491 (unspec:SI [(const_int 0)] UNSPEC_TOC))
46aaf10d 10492 (use (reg:SI 2))])]
2bfcf297 10493 "DEFAULT_ABI == ABI_AIX && TARGET_32BIT"
f0f6a223
RK
10494 "*
10495{
9ebbca7d
GK
10496 char buf[30];
10497 ASM_GENERATE_INTERNAL_LABEL (buf, \"LCTOC\", 1);
a8a05998 10498 operands[1] = gen_rtx_SYMBOL_REF (Pmode, ggc_strdup (buf));
9ebbca7d
GK
10499 operands[2] = gen_rtx_REG (Pmode, 2);
10500 return \"{l|lwz} %0,%1(%2)\";
f0f6a223
RK
10501}"
10502 [(set_attr "type" "load")])
9ebbca7d
GK
10503
10504(define_insn "load_toc_aix_di"
e72247f4 10505 [(parallel [(set (match_operand:DI 0 "gpc_reg_operand" "=r")
615158e2 10506 (unspec:DI [(const_int 0)] UNSPEC_TOC))
46aaf10d 10507 (use (reg:DI 2))])]
2bfcf297 10508 "DEFAULT_ABI == ABI_AIX && TARGET_64BIT"
9ebbca7d
GK
10509 "*
10510{
10511 char buf[30];
f585a356
DE
10512#ifdef TARGET_RELOCATABLE
10513 ASM_GENERATE_INTERNAL_LABEL (buf, \"LCTOC\",
10514 !TARGET_MINIMAL_TOC || TARGET_RELOCATABLE);
10515#else
9ebbca7d 10516 ASM_GENERATE_INTERNAL_LABEL (buf, \"LCTOC\", 1);
f585a356 10517#endif
2bfcf297
DB
10518 if (TARGET_ELF)
10519 strcat (buf, \"@toc\");
a8a05998 10520 operands[1] = gen_rtx_SYMBOL_REF (Pmode, ggc_strdup (buf));
9ebbca7d
GK
10521 operands[2] = gen_rtx_REG (Pmode, 2);
10522 return \"ld %0,%1(%2)\";
10523}"
10524 [(set_attr "type" "load")])
10525
10526(define_insn "load_toc_v4_pic_si"
1de43f85 10527 [(set (reg:SI LR_REGNO)
615158e2 10528 (unspec:SI [(const_int 0)] UNSPEC_TOC))]
f607bc57 10529 "DEFAULT_ABI == ABI_V4 && flag_pic == 1 && TARGET_32BIT"
9ebbca7d
GK
10530 "bl _GLOBAL_OFFSET_TABLE_@local-4"
10531 [(set_attr "type" "branch")
10532 (set_attr "length" "4")])
10533
9ebbca7d 10534(define_insn "load_toc_v4_PIC_1"
1de43f85 10535 [(set (reg:SI LR_REGNO)
e65a3857
DE
10536 (match_operand:SI 0 "immediate_operand" "s"))
10537 (use (unspec [(match_dup 0)] UNSPEC_TOC))]
7f970b70
AM
10538 "TARGET_ELF && DEFAULT_ABI != ABI_AIX
10539 && (flag_pic == 2 || (flag_pic && TARGET_SECURE_PLT))"
e65a3857 10540 "bcl 20,31,%0\\n%0:"
9ebbca7d
GK
10541 [(set_attr "type" "branch")
10542 (set_attr "length" "4")])
10543
10544(define_insn "load_toc_v4_PIC_1b"
1de43f85 10545 [(set (reg:SI LR_REGNO)
e65a3857 10546 (unspec:SI [(match_operand:SI 0 "immediate_operand" "s")]
c4501e62 10547 UNSPEC_TOCPTR))]
20b71b17 10548 "TARGET_ELF && DEFAULT_ABI != ABI_AIX && flag_pic == 2"
e65a3857 10549 "bcl 20,31,$+8\\n\\t.long %0-$"
9ebbca7d
GK
10550 [(set_attr "type" "branch")
10551 (set_attr "length" "8")])
10552
10553(define_insn "load_toc_v4_PIC_2"
f585a356 10554 [(set (match_operand:SI 0 "gpc_reg_operand" "=r")
a2900460 10555 (mem:SI (plus:SI (match_operand:SI 1 "gpc_reg_operand" "b")
9ebbca7d
GK
10556 (minus:SI (match_operand:SI 2 "immediate_operand" "s")
10557 (match_operand:SI 3 "immediate_operand" "s")))))]
20b71b17 10558 "TARGET_ELF && DEFAULT_ABI != ABI_AIX && flag_pic == 2"
9ebbca7d
GK
10559 "{l|lwz} %0,%2-%3(%1)"
10560 [(set_attr "type" "load")])
10561
7f970b70
AM
10562(define_insn "load_toc_v4_PIC_3b"
10563 [(set (match_operand:SI 0 "gpc_reg_operand" "=b")
10564 (plus:SI (match_operand:SI 1 "gpc_reg_operand" "r")
10565 (high:SI
10566 (minus:SI (match_operand:SI 2 "symbol_ref_operand" "s")
10567 (match_operand:SI 3 "symbol_ref_operand" "s")))))]
10568 "TARGET_ELF && TARGET_SECURE_PLT && DEFAULT_ABI != ABI_AIX && flag_pic"
10569 "{cau|addis} %0,%1,%2-%3@ha")
10570
10571(define_insn "load_toc_v4_PIC_3c"
10572 [(set (match_operand:SI 0 "gpc_reg_operand" "=r")
10573 (lo_sum:SI (match_operand:SI 1 "gpc_reg_operand" "b")
10574 (minus:SI (match_operand:SI 2 "symbol_ref_operand" "s")
10575 (match_operand:SI 3 "symbol_ref_operand" "s"))))]
10576 "TARGET_ELF && TARGET_SECURE_PLT && DEFAULT_ABI != ABI_AIX && flag_pic"
10577 "{cal|addi} %0,%1,%2-%3@l")
f51eee6a 10578
9ebbca7d
GK
10579;; If the TOC is shared over a translation unit, as happens with all
10580;; the kinds of PIC that we support, we need to restore the TOC
10581;; pointer only when jumping over units of translation.
f51eee6a 10582;; On Darwin, we need to reload the picbase.
9ebbca7d
GK
10583
10584(define_expand "builtin_setjmp_receiver"
10585 [(use (label_ref (match_operand 0 "" "")))]
f607bc57 10586 "(DEFAULT_ABI == ABI_V4 && flag_pic == 1)
f51eee6a
GK
10587 || (TARGET_TOC && TARGET_MINIMAL_TOC)
10588 || (DEFAULT_ABI == ABI_DARWIN && flag_pic)"
9ebbca7d
GK
10589 "
10590{
84d7dd4a 10591#if TARGET_MACHO
f51eee6a
GK
10592 if (DEFAULT_ABI == ABI_DARWIN)
10593 {
d24652ee 10594 const char *picbase = machopic_function_base_name ();
485bad26 10595 rtx picrtx = gen_rtx_SYMBOL_REF (Pmode, ggc_strdup (picbase));
f51eee6a
GK
10596 rtx picreg = gen_rtx_REG (Pmode, RS6000_PIC_OFFSET_TABLE_REGNUM);
10597 rtx tmplabrtx;
10598 char tmplab[20];
10599
10600 ASM_GENERATE_INTERNAL_LABEL(tmplab, \"LSJR\",
10601 CODE_LABEL_NUMBER (operands[0]));
485bad26 10602 tmplabrtx = gen_rtx_SYMBOL_REF (Pmode, ggc_strdup (tmplab));
f51eee6a 10603
316fbf19 10604 emit_insn (gen_load_macho_picbase (tmplabrtx));
1de43f85 10605 emit_move_insn (picreg, gen_rtx_REG (Pmode, LR_REGNO));
b8a55285 10606 emit_insn (gen_macho_correct_pic (picreg, picreg, picrtx, tmplabrtx));
f51eee6a
GK
10607 }
10608 else
84d7dd4a 10609#endif
f51eee6a 10610 rs6000_emit_load_toc_table (FALSE);
9ebbca7d
GK
10611 DONE;
10612}")
7f970b70
AM
10613
10614;; Elf specific ways of loading addresses for non-PIC code.
10615;; The output of this could be r0, but we make a very strong
10616;; preference for a base register because it will usually
10617;; be needed there.
10618(define_insn "elf_high"
10619 [(set (match_operand:SI 0 "gpc_reg_operand" "=b*r")
10620 (high:SI (match_operand 1 "" "")))]
10621 "TARGET_ELF && ! TARGET_64BIT"
10622 "{liu|lis} %0,%1@ha")
10623
10624(define_insn "elf_low"
10625 [(set (match_operand:SI 0 "gpc_reg_operand" "=r,r")
10626 (lo_sum:SI (match_operand:SI 1 "gpc_reg_operand" "b,!*r")
10627 (match_operand 2 "" "")))]
10628 "TARGET_ELF && ! TARGET_64BIT"
10629 "@
10630 {cal|la} %0,%2@l(%1)
10631 {ai|addic} %0,%1,%K2")
9ebbca7d
GK
10632\f
10633;; A function pointer under AIX is a pointer to a data area whose first word
10634;; contains the actual address of the function, whose second word contains a
b6c9286a
MM
10635;; pointer to its TOC, and whose third word contains a value to place in the
10636;; static chain register (r11). Note that if we load the static chain, our
1fd4e8c1 10637;; "trampoline" need not have any executable code.
b6c9286a 10638
cccf3bdc
DE
10639(define_expand "call_indirect_aix32"
10640 [(set (match_dup 2)
10641 (mem:SI (match_operand:SI 0 "gpc_reg_operand" "")))
10642 (set (mem:SI (plus:SI (reg:SI 1) (const_int 20)))
10643 (reg:SI 2))
10644 (set (reg:SI 2)
10645 (mem:SI (plus:SI (match_dup 0)
10646 (const_int 4))))
10647 (set (reg:SI 11)
10648 (mem:SI (plus:SI (match_dup 0)
10649 (const_int 8))))
10650 (parallel [(call (mem:SI (match_dup 2))
10651 (match_operand 1 "" ""))
10652 (use (reg:SI 2))
10653 (use (reg:SI 11))
10654 (set (reg:SI 2)
10655 (mem:SI (plus:SI (reg:SI 1) (const_int 20))))
1de43f85 10656 (clobber (reg:SI LR_REGNO))])]
cccf3bdc
DE
10657 "TARGET_32BIT"
10658 "
10659{ operands[2] = gen_reg_rtx (SImode); }")
b6c9286a 10660
cccf3bdc
DE
10661(define_expand "call_indirect_aix64"
10662 [(set (match_dup 2)
10663 (mem:DI (match_operand:DI 0 "gpc_reg_operand" "")))
10664 (set (mem:DI (plus:DI (reg:DI 1) (const_int 40)))
10665 (reg:DI 2))
10666 (set (reg:DI 2)
10667 (mem:DI (plus:DI (match_dup 0)
10668 (const_int 8))))
10669 (set (reg:DI 11)
10670 (mem:DI (plus:DI (match_dup 0)
10671 (const_int 16))))
10672 (parallel [(call (mem:SI (match_dup 2))
10673 (match_operand 1 "" ""))
10674 (use (reg:DI 2))
10675 (use (reg:DI 11))
10676 (set (reg:DI 2)
10677 (mem:DI (plus:DI (reg:DI 1) (const_int 40))))
1de43f85 10678 (clobber (reg:SI LR_REGNO))])]
cccf3bdc
DE
10679 "TARGET_64BIT"
10680 "
10681{ operands[2] = gen_reg_rtx (DImode); }")
b6c9286a 10682
cccf3bdc
DE
10683(define_expand "call_value_indirect_aix32"
10684 [(set (match_dup 3)
10685 (mem:SI (match_operand:SI 1 "gpc_reg_operand" "")))
10686 (set (mem:SI (plus:SI (reg:SI 1) (const_int 20)))
10687 (reg:SI 2))
10688 (set (reg:SI 2)
10689 (mem:SI (plus:SI (match_dup 1)
10690 (const_int 4))))
10691 (set (reg:SI 11)
10692 (mem:SI (plus:SI (match_dup 1)
10693 (const_int 8))))
10694 (parallel [(set (match_operand 0 "" "")
10695 (call (mem:SI (match_dup 3))
10696 (match_operand 2 "" "")))
10697 (use (reg:SI 2))
10698 (use (reg:SI 11))
10699 (set (reg:SI 2)
10700 (mem:SI (plus:SI (reg:SI 1) (const_int 20))))
1de43f85 10701 (clobber (reg:SI LR_REGNO))])]
cccf3bdc
DE
10702 "TARGET_32BIT"
10703 "
10704{ operands[3] = gen_reg_rtx (SImode); }")
b6c9286a 10705
cccf3bdc
DE
10706(define_expand "call_value_indirect_aix64"
10707 [(set (match_dup 3)
10708 (mem:DI (match_operand:DI 1 "gpc_reg_operand" "")))
10709 (set (mem:DI (plus:DI (reg:DI 1) (const_int 40)))
10710 (reg:DI 2))
10711 (set (reg:DI 2)
10712 (mem:DI (plus:DI (match_dup 1)
10713 (const_int 8))))
10714 (set (reg:DI 11)
10715 (mem:DI (plus:DI (match_dup 1)
10716 (const_int 16))))
10717 (parallel [(set (match_operand 0 "" "")
10718 (call (mem:SI (match_dup 3))
10719 (match_operand 2 "" "")))
10720 (use (reg:DI 2))
10721 (use (reg:DI 11))
10722 (set (reg:DI 2)
10723 (mem:DI (plus:DI (reg:DI 1) (const_int 40))))
1de43f85 10724 (clobber (reg:SI LR_REGNO))])]
cccf3bdc
DE
10725 "TARGET_64BIT"
10726 "
10727{ operands[3] = gen_reg_rtx (DImode); }")
1fd4e8c1 10728
b6c9286a 10729;; Now the definitions for the call and call_value insns
1fd4e8c1 10730(define_expand "call"
a260abc9 10731 [(parallel [(call (mem:SI (match_operand 0 "address_operand" ""))
1fd4e8c1 10732 (match_operand 1 "" ""))
4697a36c 10733 (use (match_operand 2 "" ""))
1de43f85 10734 (clobber (reg:SI LR_REGNO))])]
1fd4e8c1
RK
10735 ""
10736 "
10737{
ee890fe2 10738#if TARGET_MACHO
ab82a49f 10739 if (MACHOPIC_INDIRECT)
ee890fe2
SS
10740 operands[0] = machopic_indirect_call_target (operands[0]);
10741#endif
10742
37409796
NS
10743 gcc_assert (GET_CODE (operands[0]) == MEM);
10744 gcc_assert (GET_CODE (operands[1]) == CONST_INT);
1fd4e8c1
RK
10745
10746 operands[0] = XEXP (operands[0], 0);
7509c759 10747
6a4cee5f 10748 if (GET_CODE (operands[0]) != SYMBOL_REF
473f51b6 10749 || (DEFAULT_ABI == ABI_AIX && !SYMBOL_REF_FUNCTION_P (operands[0]))
efdba735 10750 || (DEFAULT_ABI != ABI_DARWIN && (INTVAL (operands[2]) & CALL_LONG) != 0))
1fd4e8c1 10751 {
6a4cee5f
MM
10752 if (INTVAL (operands[2]) & CALL_LONG)
10753 operands[0] = rs6000_longcall_ref (operands[0]);
10754
37409796
NS
10755 switch (DEFAULT_ABI)
10756 {
10757 case ABI_V4:
10758 case ABI_DARWIN:
10759 operands[0] = force_reg (Pmode, operands[0]);
10760 break;
1fd4e8c1 10761
37409796 10762 case ABI_AIX:
cccf3bdc
DE
10763 /* AIX function pointers are really pointers to a three word
10764 area. */
10765 emit_call_insn (TARGET_32BIT
10766 ? gen_call_indirect_aix32 (force_reg (SImode,
10767 operands[0]),
10768 operands[1])
10769 : gen_call_indirect_aix64 (force_reg (DImode,
10770 operands[0]),
10771 operands[1]));
10772 DONE;
37409796
NS
10773
10774 default:
10775 gcc_unreachable ();
b6c9286a 10776 }
1fd4e8c1
RK
10777 }
10778}")
10779
10780(define_expand "call_value"
10781 [(parallel [(set (match_operand 0 "" "")
a260abc9 10782 (call (mem:SI (match_operand 1 "address_operand" ""))
1fd4e8c1 10783 (match_operand 2 "" "")))
4697a36c 10784 (use (match_operand 3 "" ""))
1de43f85 10785 (clobber (reg:SI LR_REGNO))])]
1fd4e8c1
RK
10786 ""
10787 "
10788{
ee890fe2 10789#if TARGET_MACHO
ab82a49f 10790 if (MACHOPIC_INDIRECT)
ee890fe2
SS
10791 operands[1] = machopic_indirect_call_target (operands[1]);
10792#endif
10793
37409796
NS
10794 gcc_assert (GET_CODE (operands[1]) == MEM);
10795 gcc_assert (GET_CODE (operands[2]) == CONST_INT);
1fd4e8c1
RK
10796
10797 operands[1] = XEXP (operands[1], 0);
7509c759 10798
6a4cee5f 10799 if (GET_CODE (operands[1]) != SYMBOL_REF
473f51b6 10800 || (DEFAULT_ABI == ABI_AIX && !SYMBOL_REF_FUNCTION_P (operands[1]))
efdba735 10801 || (DEFAULT_ABI != ABI_DARWIN && (INTVAL (operands[3]) & CALL_LONG) != 0))
1fd4e8c1 10802 {
6756293c 10803 if (INTVAL (operands[3]) & CALL_LONG)
6a4cee5f
MM
10804 operands[1] = rs6000_longcall_ref (operands[1]);
10805
37409796
NS
10806 switch (DEFAULT_ABI)
10807 {
10808 case ABI_V4:
10809 case ABI_DARWIN:
10810 operands[1] = force_reg (Pmode, operands[1]);
10811 break;
1fd4e8c1 10812
37409796 10813 case ABI_AIX:
cccf3bdc
DE
10814 /* AIX function pointers are really pointers to a three word
10815 area. */
10816 emit_call_insn (TARGET_32BIT
10817 ? gen_call_value_indirect_aix32 (operands[0],
10818 force_reg (SImode,
10819 operands[1]),
10820 operands[2])
10821 : gen_call_value_indirect_aix64 (operands[0],
10822 force_reg (DImode,
10823 operands[1]),
10824 operands[2]));
10825 DONE;
37409796
NS
10826
10827 default:
10828 gcc_unreachable ();
b6c9286a 10829 }
1fd4e8c1
RK
10830 }
10831}")
10832
04780ee7 10833;; Call to function in current module. No TOC pointer reload needed.
a0ab749a 10834;; Operand2 is nonzero if we are using the V.4 calling sequence and
4697a36c
MM
10835;; either the function was not prototyped, or it was prototyped as a
10836;; variable argument function. It is > 0 if FP registers were passed
10837;; and < 0 if they were not.
04780ee7 10838
a260abc9 10839(define_insn "*call_local32"
4697a36c
MM
10840 [(call (mem:SI (match_operand:SI 0 "current_file_function_operand" "s,s"))
10841 (match_operand 1 "" "g,g"))
10842 (use (match_operand:SI 2 "immediate_operand" "O,n"))
1de43f85 10843 (clobber (reg:SI LR_REGNO))]
5a19791c 10844 "(INTVAL (operands[2]) & CALL_LONG) == 0"
4697a36c
MM
10845 "*
10846{
6a4cee5f
MM
10847 if (INTVAL (operands[2]) & CALL_V4_SET_FP_ARGS)
10848 output_asm_insn (\"crxor 6,6,6\", operands);
10849
10850 else if (INTVAL (operands[2]) & CALL_V4_CLEAR_FP_ARGS)
10851 output_asm_insn (\"creqv 6,6,6\", operands);
4697a36c 10852
a226df46 10853 return (DEFAULT_ABI == ABI_V4 && flag_pic) ? \"bl %z0@local\" : \"bl %z0\";
4697a36c 10854}"
b7ff3d82
DE
10855 [(set_attr "type" "branch")
10856 (set_attr "length" "4,8")])
04780ee7 10857
a260abc9
DE
10858(define_insn "*call_local64"
10859 [(call (mem:SI (match_operand:DI 0 "current_file_function_operand" "s,s"))
10860 (match_operand 1 "" "g,g"))
10861 (use (match_operand:SI 2 "immediate_operand" "O,n"))
1de43f85 10862 (clobber (reg:SI LR_REGNO))]
a260abc9
DE
10863 "TARGET_64BIT && (INTVAL (operands[2]) & CALL_LONG) == 0"
10864 "*
10865{
10866 if (INTVAL (operands[2]) & CALL_V4_SET_FP_ARGS)
10867 output_asm_insn (\"crxor 6,6,6\", operands);
10868
10869 else if (INTVAL (operands[2]) & CALL_V4_CLEAR_FP_ARGS)
10870 output_asm_insn (\"creqv 6,6,6\", operands);
10871
10872 return (DEFAULT_ABI == ABI_V4 && flag_pic) ? \"bl %z0@local\" : \"bl %z0\";
10873}"
10874 [(set_attr "type" "branch")
10875 (set_attr "length" "4,8")])
10876
cccf3bdc 10877(define_insn "*call_value_local32"
d18dba68 10878 [(set (match_operand 0 "" "")
a260abc9
DE
10879 (call (mem:SI (match_operand:SI 1 "current_file_function_operand" "s,s"))
10880 (match_operand 2 "" "g,g")))
10881 (use (match_operand:SI 3 "immediate_operand" "O,n"))
1de43f85 10882 (clobber (reg:SI LR_REGNO))]
a260abc9
DE
10883 "(INTVAL (operands[3]) & CALL_LONG) == 0"
10884 "*
10885{
10886 if (INTVAL (operands[3]) & CALL_V4_SET_FP_ARGS)
10887 output_asm_insn (\"crxor 6,6,6\", operands);
10888
10889 else if (INTVAL (operands[3]) & CALL_V4_CLEAR_FP_ARGS)
10890 output_asm_insn (\"creqv 6,6,6\", operands);
10891
10892 return (DEFAULT_ABI == ABI_V4 && flag_pic) ? \"bl %z1@local\" : \"bl %z1\";
10893}"
10894 [(set_attr "type" "branch")
10895 (set_attr "length" "4,8")])
10896
10897
cccf3bdc 10898(define_insn "*call_value_local64"
d18dba68 10899 [(set (match_operand 0 "" "")
a260abc9
DE
10900 (call (mem:SI (match_operand:DI 1 "current_file_function_operand" "s,s"))
10901 (match_operand 2 "" "g,g")))
10902 (use (match_operand:SI 3 "immediate_operand" "O,n"))
1de43f85 10903 (clobber (reg:SI LR_REGNO))]
a260abc9
DE
10904 "TARGET_64BIT && (INTVAL (operands[3]) & CALL_LONG) == 0"
10905 "*
10906{
10907 if (INTVAL (operands[3]) & CALL_V4_SET_FP_ARGS)
10908 output_asm_insn (\"crxor 6,6,6\", operands);
10909
10910 else if (INTVAL (operands[3]) & CALL_V4_CLEAR_FP_ARGS)
10911 output_asm_insn (\"creqv 6,6,6\", operands);
10912
10913 return (DEFAULT_ABI == ABI_V4 && flag_pic) ? \"bl %z1@local\" : \"bl %z1\";
10914}"
10915 [(set_attr "type" "branch")
10916 (set_attr "length" "4,8")])
10917
04780ee7 10918;; Call to function which may be in another module. Restore the TOC
911f679c 10919;; pointer (r2) after the call unless this is System V.
a0ab749a 10920;; Operand2 is nonzero if we are using the V.4 calling sequence and
4697a36c
MM
10921;; either the function was not prototyped, or it was prototyped as a
10922;; variable argument function. It is > 0 if FP registers were passed
10923;; and < 0 if they were not.
04780ee7 10924
cccf3bdc 10925(define_insn "*call_indirect_nonlocal_aix32"
70ae0191
DE
10926 [(call (mem:SI (match_operand:SI 0 "register_operand" "c,*l"))
10927 (match_operand 1 "" "g,g"))
cccf3bdc
DE
10928 (use (reg:SI 2))
10929 (use (reg:SI 11))
10930 (set (reg:SI 2)
10931 (mem:SI (plus:SI (reg:SI 1) (const_int 20))))
1de43f85 10932 (clobber (reg:SI LR_REGNO))]
cccf3bdc
DE
10933 "TARGET_32BIT && DEFAULT_ABI == ABI_AIX"
10934 "b%T0l\;{l|lwz} 2,20(1)"
10935 [(set_attr "type" "jmpreg")
10936 (set_attr "length" "8")])
10937
a260abc9 10938(define_insn "*call_nonlocal_aix32"
cc4d5fec 10939 [(call (mem:SI (match_operand:SI 0 "symbol_ref_operand" "s"))
cccf3bdc
DE
10940 (match_operand 1 "" "g"))
10941 (use (match_operand:SI 2 "immediate_operand" "O"))
1de43f85 10942 (clobber (reg:SI LR_REGNO))]
cccf3bdc
DE
10943 "TARGET_32BIT
10944 && DEFAULT_ABI == ABI_AIX
5a19791c 10945 && (INTVAL (operands[2]) & CALL_LONG) == 0"
cccf3bdc 10946 "bl %z0\;%."
b7ff3d82 10947 [(set_attr "type" "branch")
cccf3bdc
DE
10948 (set_attr "length" "8")])
10949
10950(define_insn "*call_indirect_nonlocal_aix64"
70ae0191
DE
10951 [(call (mem:SI (match_operand:DI 0 "register_operand" "c,*l"))
10952 (match_operand 1 "" "g,g"))
cccf3bdc
DE
10953 (use (reg:DI 2))
10954 (use (reg:DI 11))
10955 (set (reg:DI 2)
10956 (mem:DI (plus:DI (reg:DI 1) (const_int 40))))
1de43f85 10957 (clobber (reg:SI LR_REGNO))]
cccf3bdc
DE
10958 "TARGET_64BIT && DEFAULT_ABI == ABI_AIX"
10959 "b%T0l\;ld 2,40(1)"
10960 [(set_attr "type" "jmpreg")
10961 (set_attr "length" "8")])
59313e4e 10962
a260abc9 10963(define_insn "*call_nonlocal_aix64"
cc4d5fec 10964 [(call (mem:SI (match_operand:DI 0 "symbol_ref_operand" "s"))
cccf3bdc
DE
10965 (match_operand 1 "" "g"))
10966 (use (match_operand:SI 2 "immediate_operand" "O"))
1de43f85 10967 (clobber (reg:SI LR_REGNO))]
6ae08853 10968 "TARGET_64BIT
9ebbca7d 10969 && DEFAULT_ABI == ABI_AIX
a260abc9 10970 && (INTVAL (operands[2]) & CALL_LONG) == 0"
cccf3bdc 10971 "bl %z0\;%."
a260abc9 10972 [(set_attr "type" "branch")
cccf3bdc 10973 (set_attr "length" "8")])
7509c759 10974
cccf3bdc 10975(define_insn "*call_value_indirect_nonlocal_aix32"
d18dba68 10976 [(set (match_operand 0 "" "")
70ae0191
DE
10977 (call (mem:SI (match_operand:SI 1 "register_operand" "c,*l"))
10978 (match_operand 2 "" "g,g")))
cccf3bdc
DE
10979 (use (reg:SI 2))
10980 (use (reg:SI 11))
10981 (set (reg:SI 2)
10982 (mem:SI (plus:SI (reg:SI 1) (const_int 20))))
1de43f85 10983 (clobber (reg:SI LR_REGNO))]
cccf3bdc
DE
10984 "TARGET_32BIT && DEFAULT_ABI == ABI_AIX"
10985 "b%T1l\;{l|lwz} 2,20(1)"
10986 [(set_attr "type" "jmpreg")
10987 (set_attr "length" "8")])
1fd4e8c1 10988
cccf3bdc 10989(define_insn "*call_value_nonlocal_aix32"
d18dba68 10990 [(set (match_operand 0 "" "")
cc4d5fec 10991 (call (mem:SI (match_operand:SI 1 "symbol_ref_operand" "s"))
cccf3bdc
DE
10992 (match_operand 2 "" "g")))
10993 (use (match_operand:SI 3 "immediate_operand" "O"))
1de43f85 10994 (clobber (reg:SI LR_REGNO))]
cccf3bdc
DE
10995 "TARGET_32BIT
10996 && DEFAULT_ABI == ABI_AIX
a260abc9 10997 && (INTVAL (operands[3]) & CALL_LONG) == 0"
cccf3bdc 10998 "bl %z1\;%."
b7ff3d82 10999 [(set_attr "type" "branch")
cccf3bdc 11000 (set_attr "length" "8")])
04780ee7 11001
cccf3bdc 11002(define_insn "*call_value_indirect_nonlocal_aix64"
d18dba68 11003 [(set (match_operand 0 "" "")
70ae0191
DE
11004 (call (mem:SI (match_operand:DI 1 "register_operand" "c,*l"))
11005 (match_operand 2 "" "g,g")))
cccf3bdc
DE
11006 (use (reg:DI 2))
11007 (use (reg:DI 11))
11008 (set (reg:DI 2)
11009 (mem:DI (plus:DI (reg:DI 1) (const_int 40))))
1de43f85 11010 (clobber (reg:SI LR_REGNO))]
cccf3bdc
DE
11011 "TARGET_64BIT && DEFAULT_ABI == ABI_AIX"
11012 "b%T1l\;ld 2,40(1)"
11013 [(set_attr "type" "jmpreg")
11014 (set_attr "length" "8")])
11015
11016(define_insn "*call_value_nonlocal_aix64"
d18dba68 11017 [(set (match_operand 0 "" "")
cc4d5fec 11018 (call (mem:SI (match_operand:DI 1 "symbol_ref_operand" "s"))
cccf3bdc
DE
11019 (match_operand 2 "" "g")))
11020 (use (match_operand:SI 3 "immediate_operand" "O"))
1de43f85 11021 (clobber (reg:SI LR_REGNO))]
6ae08853 11022 "TARGET_64BIT
9ebbca7d 11023 && DEFAULT_ABI == ABI_AIX
5a19791c 11024 && (INTVAL (operands[3]) & CALL_LONG) == 0"
cccf3bdc
DE
11025 "bl %z1\;%."
11026 [(set_attr "type" "branch")
11027 (set_attr "length" "8")])
11028
11029;; A function pointer under System V is just a normal pointer
11030;; operands[0] is the function pointer
11031;; operands[1] is the stack size to clean up
11032;; operands[2] is the value FUNCTION_ARG returns for the VOID argument
11033;; which indicates how to set cr1
11034
9613eaff
SH
11035(define_insn "*call_indirect_nonlocal_sysv<mode>"
11036 [(call (mem:SI (match_operand:P 0 "register_operand" "c,*l,c,*l"))
6d0a8091
DJ
11037 (match_operand 1 "" "g,g,g,g"))
11038 (use (match_operand:SI 2 "immediate_operand" "O,O,n,n"))
1de43f85 11039 (clobber (reg:SI LR_REGNO))]
50d440bc 11040 "DEFAULT_ABI == ABI_V4
f607bc57 11041 || DEFAULT_ABI == ABI_DARWIN"
911f679c 11042{
cccf3bdc 11043 if (INTVAL (operands[2]) & CALL_V4_SET_FP_ARGS)
a5c76ee6 11044 output_asm_insn ("crxor 6,6,6", operands);
6a4cee5f 11045
cccf3bdc 11046 else if (INTVAL (operands[2]) & CALL_V4_CLEAR_FP_ARGS)
a5c76ee6 11047 output_asm_insn ("creqv 6,6,6", operands);
7509c759 11048
a5c76ee6
ZW
11049 return "b%T0l";
11050}
6d0a8091
DJ
11051 [(set_attr "type" "jmpreg,jmpreg,jmpreg,jmpreg")
11052 (set_attr "length" "4,4,8,8")])
cccf3bdc 11053
1d3155fc 11054(define_insn_and_split "*call_nonlocal_sysv<mode>"
9613eaff 11055 [(call (mem:SI (match_operand:P 0 "symbol_ref_operand" "s,s"))
a5c76ee6
ZW
11056 (match_operand 1 "" "g,g"))
11057 (use (match_operand:SI 2 "immediate_operand" "O,n"))
1de43f85 11058 (clobber (reg:SI LR_REGNO))]
efdba735
SH
11059 "(DEFAULT_ABI == ABI_DARWIN
11060 || (DEFAULT_ABI == ABI_V4
11061 && (INTVAL (operands[2]) & CALL_LONG) == 0))"
a5c76ee6
ZW
11062{
11063 if (INTVAL (operands[2]) & CALL_V4_SET_FP_ARGS)
11064 output_asm_insn ("crxor 6,6,6", operands);
11065
11066 else if (INTVAL (operands[2]) & CALL_V4_CLEAR_FP_ARGS)
11067 output_asm_insn ("creqv 6,6,6", operands);
11068
c989f2f7 11069#if TARGET_MACHO
efdba735
SH
11070 return output_call(insn, operands, 0, 2);
11071#else
7f970b70
AM
11072 if (DEFAULT_ABI == ABI_V4 && flag_pic)
11073 {
1d3155fc
AM
11074 gcc_assert (!TARGET_SECURE_PLT);
11075 return "bl %z0@plt";
7f970b70
AM
11076 }
11077 else
11078 return "bl %z0";
6ae08853 11079#endif
1d3155fc
AM
11080}
11081 "DEFAULT_ABI == ABI_V4
11082 && TARGET_SECURE_PLT && flag_pic && !SYMBOL_REF_LOCAL_P (operands[0])
11083 && (INTVAL (operands[2]) & CALL_LONG) == 0"
11084 [(parallel [(call (mem:SI (match_dup 0))
11085 (match_dup 1))
11086 (use (match_dup 2))
11087 (use (match_dup 3))
11088 (clobber (reg:SI LR_REGNO))])]
11089{
11090 operands[3] = pic_offset_table_rtx;
11091}
11092 [(set_attr "type" "branch,branch")
11093 (set_attr "length" "4,8")])
11094
11095(define_insn "*call_nonlocal_sysv_secure<mode>"
11096 [(call (mem:SI (match_operand:P 0 "symbol_ref_operand" "s,s"))
11097 (match_operand 1 "" "g,g"))
11098 (use (match_operand:SI 2 "immediate_operand" "O,n"))
11099 (use (match_operand:SI 3 "register_operand" "r,r"))
11100 (clobber (reg:SI LR_REGNO))]
11101 "(DEFAULT_ABI == ABI_V4
11102 && TARGET_SECURE_PLT && flag_pic && !SYMBOL_REF_LOCAL_P (operands[0])
11103 && (INTVAL (operands[2]) & CALL_LONG) == 0)"
11104{
11105 if (INTVAL (operands[2]) & CALL_V4_SET_FP_ARGS)
11106 output_asm_insn ("crxor 6,6,6", operands);
11107
11108 else if (INTVAL (operands[2]) & CALL_V4_CLEAR_FP_ARGS)
11109 output_asm_insn ("creqv 6,6,6", operands);
11110
11111 if (flag_pic == 2)
11112 /* The magic 32768 offset here and in the other sysv call insns
11113 corresponds to the offset of r30 in .got2, as given by LCTOC1.
11114 See sysv4.h:toc_section. */
11115 return "bl %z0+32768@plt";
11116 else
11117 return "bl %z0@plt";
a5c76ee6
ZW
11118}
11119 [(set_attr "type" "branch,branch")
11120 (set_attr "length" "4,8")])
11121
9613eaff 11122(define_insn "*call_value_indirect_nonlocal_sysv<mode>"
d18dba68 11123 [(set (match_operand 0 "" "")
9613eaff 11124 (call (mem:SI (match_operand:P 1 "register_operand" "c,*l,c,*l"))
6d0a8091
DJ
11125 (match_operand 2 "" "g,g,g,g")))
11126 (use (match_operand:SI 3 "immediate_operand" "O,O,n,n"))
1de43f85 11127 (clobber (reg:SI LR_REGNO))]
50d440bc 11128 "DEFAULT_ABI == ABI_V4
f607bc57 11129 || DEFAULT_ABI == ABI_DARWIN"
b6c9286a 11130{
6a4cee5f 11131 if (INTVAL (operands[3]) & CALL_V4_SET_FP_ARGS)
a5c76ee6 11132 output_asm_insn ("crxor 6,6,6", operands);
6a4cee5f
MM
11133
11134 else if (INTVAL (operands[3]) & CALL_V4_CLEAR_FP_ARGS)
a5c76ee6 11135 output_asm_insn ("creqv 6,6,6", operands);
7509c759 11136
a5c76ee6
ZW
11137 return "b%T1l";
11138}
6d0a8091
DJ
11139 [(set_attr "type" "jmpreg,jmpreg,jmpreg,jmpreg")
11140 (set_attr "length" "4,4,8,8")])
a5c76ee6 11141
1d3155fc 11142(define_insn_and_split "*call_value_nonlocal_sysv<mode>"
a5c76ee6 11143 [(set (match_operand 0 "" "")
9613eaff 11144 (call (mem:SI (match_operand:P 1 "symbol_ref_operand" "s,s"))
a5c76ee6
ZW
11145 (match_operand 2 "" "g,g")))
11146 (use (match_operand:SI 3 "immediate_operand" "O,n"))
1de43f85 11147 (clobber (reg:SI LR_REGNO))]
efdba735
SH
11148 "(DEFAULT_ABI == ABI_DARWIN
11149 || (DEFAULT_ABI == ABI_V4
11150 && (INTVAL (operands[3]) & CALL_LONG) == 0))"
a5c76ee6
ZW
11151{
11152 if (INTVAL (operands[3]) & CALL_V4_SET_FP_ARGS)
11153 output_asm_insn ("crxor 6,6,6", operands);
11154
11155 else if (INTVAL (operands[3]) & CALL_V4_CLEAR_FP_ARGS)
11156 output_asm_insn ("creqv 6,6,6", operands);
11157
c989f2f7 11158#if TARGET_MACHO
efdba735
SH
11159 return output_call(insn, operands, 1, 3);
11160#else
7f970b70
AM
11161 if (DEFAULT_ABI == ABI_V4 && flag_pic)
11162 {
1d3155fc
AM
11163 gcc_assert (!TARGET_SECURE_PLT);
11164 return "bl %z1@plt";
7f970b70
AM
11165 }
11166 else
11167 return "bl %z1";
6ae08853 11168#endif
1d3155fc
AM
11169}
11170 "DEFAULT_ABI == ABI_V4
11171 && TARGET_SECURE_PLT && flag_pic && !SYMBOL_REF_LOCAL_P (operands[1])
11172 && (INTVAL (operands[3]) & CALL_LONG) == 0"
11173 [(parallel [(set (match_dup 0)
11174 (call (mem:SI (match_dup 1))
11175 (match_dup 2)))
11176 (use (match_dup 3))
11177 (use (match_dup 4))
11178 (clobber (reg:SI LR_REGNO))])]
11179{
11180 operands[4] = pic_offset_table_rtx;
11181}
11182 [(set_attr "type" "branch,branch")
11183 (set_attr "length" "4,8")])
11184
11185(define_insn "*call_value_nonlocal_sysv_secure<mode>"
11186 [(set (match_operand 0 "" "")
11187 (call (mem:SI (match_operand:P 1 "symbol_ref_operand" "s,s"))
11188 (match_operand 2 "" "g,g")))
11189 (use (match_operand:SI 3 "immediate_operand" "O,n"))
11190 (use (match_operand:SI 4 "register_operand" "r,r"))
11191 (clobber (reg:SI LR_REGNO))]
11192 "(DEFAULT_ABI == ABI_V4
11193 && TARGET_SECURE_PLT && flag_pic && !SYMBOL_REF_LOCAL_P (operands[1])
11194 && (INTVAL (operands[3]) & CALL_LONG) == 0)"
11195{
11196 if (INTVAL (operands[3]) & CALL_V4_SET_FP_ARGS)
11197 output_asm_insn ("crxor 6,6,6", operands);
11198
11199 else if (INTVAL (operands[3]) & CALL_V4_CLEAR_FP_ARGS)
11200 output_asm_insn ("creqv 6,6,6", operands);
11201
11202 if (flag_pic == 2)
11203 return "bl %z1+32768@plt";
11204 else
11205 return "bl %z1@plt";
a5c76ee6
ZW
11206}
11207 [(set_attr "type" "branch,branch")
11208 (set_attr "length" "4,8")])
e6f948e3
RK
11209
11210;; Call subroutine returning any type.
e6f948e3
RK
11211(define_expand "untyped_call"
11212 [(parallel [(call (match_operand 0 "" "")
11213 (const_int 0))
11214 (match_operand 1 "" "")
11215 (match_operand 2 "" "")])]
11216 ""
11217 "
11218{
11219 int i;
11220
7d70b8b2 11221 emit_call_insn (GEN_CALL (operands[0], const0_rtx, const0_rtx, const0_rtx));
e6f948e3
RK
11222
11223 for (i = 0; i < XVECLEN (operands[2], 0); i++)
11224 {
11225 rtx set = XVECEXP (operands[2], 0, i);
11226 emit_move_insn (SET_DEST (set), SET_SRC (set));
11227 }
11228
11229 /* The optimizer does not know that the call sets the function value
11230 registers we stored in the result block. We avoid problems by
11231 claiming that all hard registers are used and clobbered at this
11232 point. */
11233 emit_insn (gen_blockage ());
11234
11235 DONE;
11236}")
11237
5e1bf043
DJ
11238;; sibling call patterns
11239(define_expand "sibcall"
11240 [(parallel [(call (mem:SI (match_operand 0 "address_operand" ""))
11241 (match_operand 1 "" ""))
11242 (use (match_operand 2 "" ""))
1de43f85 11243 (use (reg:SI LR_REGNO))
5e1bf043
DJ
11244 (return)])]
11245 ""
11246 "
11247{
11248#if TARGET_MACHO
ab82a49f 11249 if (MACHOPIC_INDIRECT)
5e1bf043
DJ
11250 operands[0] = machopic_indirect_call_target (operands[0]);
11251#endif
11252
37409796
NS
11253 gcc_assert (GET_CODE (operands[0]) == MEM);
11254 gcc_assert (GET_CODE (operands[1]) == CONST_INT);
5e1bf043
DJ
11255
11256 operands[0] = XEXP (operands[0], 0);
5e1bf043
DJ
11257}")
11258
11259;; this and similar patterns must be marked as using LR, otherwise
11260;; dataflow will try to delete the store into it. This is true
11261;; even when the actual reg to jump to is in CTR, when LR was
11262;; saved and restored around the PIC-setting BCL.
11263(define_insn "*sibcall_local32"
11264 [(call (mem:SI (match_operand:SI 0 "current_file_function_operand" "s,s"))
11265 (match_operand 1 "" "g,g"))
11266 (use (match_operand:SI 2 "immediate_operand" "O,n"))
1de43f85 11267 (use (reg:SI LR_REGNO))
5e1bf043
DJ
11268 (return)]
11269 "(INTVAL (operands[2]) & CALL_LONG) == 0"
11270 "*
11271{
11272 if (INTVAL (operands[2]) & CALL_V4_SET_FP_ARGS)
11273 output_asm_insn (\"crxor 6,6,6\", operands);
11274
11275 else if (INTVAL (operands[2]) & CALL_V4_CLEAR_FP_ARGS)
11276 output_asm_insn (\"creqv 6,6,6\", operands);
11277
11278 return (DEFAULT_ABI == ABI_V4 && flag_pic) ? \"b %z0@local\" : \"b %z0\";
11279}"
11280 [(set_attr "type" "branch")
11281 (set_attr "length" "4,8")])
11282
11283(define_insn "*sibcall_local64"
11284 [(call (mem:SI (match_operand:DI 0 "current_file_function_operand" "s,s"))
11285 (match_operand 1 "" "g,g"))
11286 (use (match_operand:SI 2 "immediate_operand" "O,n"))
1de43f85 11287 (use (reg:SI LR_REGNO))
5e1bf043
DJ
11288 (return)]
11289 "TARGET_64BIT && (INTVAL (operands[2]) & CALL_LONG) == 0"
11290 "*
11291{
11292 if (INTVAL (operands[2]) & CALL_V4_SET_FP_ARGS)
11293 output_asm_insn (\"crxor 6,6,6\", operands);
11294
11295 else if (INTVAL (operands[2]) & CALL_V4_CLEAR_FP_ARGS)
11296 output_asm_insn (\"creqv 6,6,6\", operands);
11297
11298 return (DEFAULT_ABI == ABI_V4 && flag_pic) ? \"b %z0@local\" : \"b %z0\";
11299}"
11300 [(set_attr "type" "branch")
11301 (set_attr "length" "4,8")])
11302
11303(define_insn "*sibcall_value_local32"
11304 [(set (match_operand 0 "" "")
11305 (call (mem:SI (match_operand:SI 1 "current_file_function_operand" "s,s"))
11306 (match_operand 2 "" "g,g")))
11307 (use (match_operand:SI 3 "immediate_operand" "O,n"))
1de43f85 11308 (use (reg:SI LR_REGNO))
5e1bf043
DJ
11309 (return)]
11310 "(INTVAL (operands[3]) & CALL_LONG) == 0"
11311 "*
11312{
11313 if (INTVAL (operands[3]) & CALL_V4_SET_FP_ARGS)
11314 output_asm_insn (\"crxor 6,6,6\", operands);
11315
11316 else if (INTVAL (operands[3]) & CALL_V4_CLEAR_FP_ARGS)
11317 output_asm_insn (\"creqv 6,6,6\", operands);
11318
11319 return (DEFAULT_ABI == ABI_V4 && flag_pic) ? \"b %z1@local\" : \"b %z1\";
11320}"
11321 [(set_attr "type" "branch")
11322 (set_attr "length" "4,8")])
11323
11324
11325(define_insn "*sibcall_value_local64"
11326 [(set (match_operand 0 "" "")
11327 (call (mem:SI (match_operand:DI 1 "current_file_function_operand" "s,s"))
11328 (match_operand 2 "" "g,g")))
11329 (use (match_operand:SI 3 "immediate_operand" "O,n"))
1de43f85 11330 (use (reg:SI LR_REGNO))
5e1bf043
DJ
11331 (return)]
11332 "TARGET_64BIT && (INTVAL (operands[3]) & CALL_LONG) == 0"
11333 "*
11334{
11335 if (INTVAL (operands[3]) & CALL_V4_SET_FP_ARGS)
11336 output_asm_insn (\"crxor 6,6,6\", operands);
11337
11338 else if (INTVAL (operands[3]) & CALL_V4_CLEAR_FP_ARGS)
11339 output_asm_insn (\"creqv 6,6,6\", operands);
11340
11341 return (DEFAULT_ABI == ABI_V4 && flag_pic) ? \"b %z1@local\" : \"b %z1\";
11342}"
11343 [(set_attr "type" "branch")
11344 (set_attr "length" "4,8")])
11345
11346(define_insn "*sibcall_nonlocal_aix32"
11347 [(call (mem:SI (match_operand:SI 0 "symbol_ref_operand" "s"))
11348 (match_operand 1 "" "g"))
11349 (use (match_operand:SI 2 "immediate_operand" "O"))
1de43f85 11350 (use (reg:SI LR_REGNO))
5e1bf043
DJ
11351 (return)]
11352 "TARGET_32BIT
11353 && DEFAULT_ABI == ABI_AIX
11354 && (INTVAL (operands[2]) & CALL_LONG) == 0"
11355 "b %z0"
11356 [(set_attr "type" "branch")
11357 (set_attr "length" "4")])
11358
11359(define_insn "*sibcall_nonlocal_aix64"
11360 [(call (mem:SI (match_operand:DI 0 "symbol_ref_operand" "s"))
11361 (match_operand 1 "" "g"))
11362 (use (match_operand:SI 2 "immediate_operand" "O"))
1de43f85 11363 (use (reg:SI LR_REGNO))
5e1bf043 11364 (return)]
6ae08853 11365 "TARGET_64BIT
5e1bf043
DJ
11366 && DEFAULT_ABI == ABI_AIX
11367 && (INTVAL (operands[2]) & CALL_LONG) == 0"
11368 "b %z0"
11369 [(set_attr "type" "branch")
11370 (set_attr "length" "4")])
11371
11372(define_insn "*sibcall_value_nonlocal_aix32"
11373 [(set (match_operand 0 "" "")
11374 (call (mem:SI (match_operand:SI 1 "symbol_ref_operand" "s"))
11375 (match_operand 2 "" "g")))
11376 (use (match_operand:SI 3 "immediate_operand" "O"))
1de43f85 11377 (use (reg:SI LR_REGNO))
5e1bf043
DJ
11378 (return)]
11379 "TARGET_32BIT
11380 && DEFAULT_ABI == ABI_AIX
11381 && (INTVAL (operands[3]) & CALL_LONG) == 0"
11382 "b %z1"
11383 [(set_attr "type" "branch")
11384 (set_attr "length" "4")])
11385
11386(define_insn "*sibcall_value_nonlocal_aix64"
11387 [(set (match_operand 0 "" "")
11388 (call (mem:SI (match_operand:DI 1 "symbol_ref_operand" "s"))
11389 (match_operand 2 "" "g")))
11390 (use (match_operand:SI 3 "immediate_operand" "O"))
1de43f85 11391 (use (reg:SI LR_REGNO))
5e1bf043 11392 (return)]
6ae08853 11393 "TARGET_64BIT
5e1bf043
DJ
11394 && DEFAULT_ABI == ABI_AIX
11395 && (INTVAL (operands[3]) & CALL_LONG) == 0"
11396 "b %z1"
11397 [(set_attr "type" "branch")
11398 (set_attr "length" "4")])
11399
9613eaff
SH
11400(define_insn "*sibcall_nonlocal_sysv<mode>"
11401 [(call (mem:SI (match_operand:P 0 "symbol_ref_operand" "s,s"))
5e1bf043
DJ
11402 (match_operand 1 "" ""))
11403 (use (match_operand 2 "immediate_operand" "O,n"))
1de43f85 11404 (use (reg:SI LR_REGNO))
5e1bf043
DJ
11405 (return)]
11406 "(DEFAULT_ABI == ABI_DARWIN
50d440bc 11407 || DEFAULT_ABI == ABI_V4)
5e1bf043
DJ
11408 && (INTVAL (operands[2]) & CALL_LONG) == 0"
11409 "*
11410{
11411 if (INTVAL (operands[2]) & CALL_V4_SET_FP_ARGS)
11412 output_asm_insn (\"crxor 6,6,6\", operands);
11413
11414 else if (INTVAL (operands[2]) & CALL_V4_CLEAR_FP_ARGS)
11415 output_asm_insn (\"creqv 6,6,6\", operands);
11416
7f970b70
AM
11417 if (DEFAULT_ABI == ABI_V4 && flag_pic)
11418 {
1d3155fc
AM
11419 gcc_assert (!TARGET_SECURE_PLT);
11420 return \"b %z0@plt\";
7f970b70
AM
11421 }
11422 else
11423 return \"b %z0\";
5e1bf043
DJ
11424}"
11425 [(set_attr "type" "branch,branch")
11426 (set_attr "length" "4,8")])
11427
11428(define_expand "sibcall_value"
11429 [(parallel [(set (match_operand 0 "register_operand" "")
11430 (call (mem:SI (match_operand 1 "address_operand" ""))
11431 (match_operand 2 "" "")))
11432 (use (match_operand 3 "" ""))
1de43f85 11433 (use (reg:SI LR_REGNO))
5e1bf043
DJ
11434 (return)])]
11435 ""
11436 "
11437{
11438#if TARGET_MACHO
ab82a49f 11439 if (MACHOPIC_INDIRECT)
5e1bf043
DJ
11440 operands[1] = machopic_indirect_call_target (operands[1]);
11441#endif
11442
37409796
NS
11443 gcc_assert (GET_CODE (operands[1]) == MEM);
11444 gcc_assert (GET_CODE (operands[2]) == CONST_INT);
5e1bf043
DJ
11445
11446 operands[1] = XEXP (operands[1], 0);
5e1bf043
DJ
11447}")
11448
9613eaff 11449(define_insn "*sibcall_value_nonlocal_sysv<mode>"
5e1bf043 11450 [(set (match_operand 0 "" "")
9613eaff 11451 (call (mem:SI (match_operand:P 1 "symbol_ref_operand" "s,s"))
5e1bf043
DJ
11452 (match_operand 2 "" "")))
11453 (use (match_operand:SI 3 "immediate_operand" "O,n"))
1de43f85 11454 (use (reg:SI LR_REGNO))
5e1bf043
DJ
11455 (return)]
11456 "(DEFAULT_ABI == ABI_DARWIN
50d440bc 11457 || DEFAULT_ABI == ABI_V4)
5e1bf043
DJ
11458 && (INTVAL (operands[3]) & CALL_LONG) == 0"
11459 "*
11460{
11461 if (INTVAL (operands[2]) & CALL_V4_SET_FP_ARGS)
11462 output_asm_insn (\"crxor 6,6,6\", operands);
11463
11464 else if (INTVAL (operands[2]) & CALL_V4_CLEAR_FP_ARGS)
11465 output_asm_insn (\"creqv 6,6,6\", operands);
11466
7f970b70
AM
11467 if (DEFAULT_ABI == ABI_V4 && flag_pic)
11468 {
1d3155fc
AM
11469 gcc_assert (!TARGET_SECURE_PLT);
11470 return \"b %z1@plt\";
7f970b70
AM
11471 }
11472 else
11473 return \"b %z1\";
5e1bf043
DJ
11474}"
11475 [(set_attr "type" "branch,branch")
11476 (set_attr "length" "4,8")])
11477
11478(define_expand "sibcall_epilogue"
11479 [(use (const_int 0))]
11480 "TARGET_SCHED_PROLOG"
11481 "
11482{
11483 rs6000_emit_epilogue (TRUE);
11484 DONE;
11485}")
11486
e6f948e3
RK
11487;; UNSPEC_VOLATILE is considered to use and clobber all hard registers and
11488;; all of memory. This blocks insns from being moved across this point.
11489
11490(define_insn "blockage"
615158e2 11491 [(unspec_volatile [(const_int 0)] UNSPECV_BLOCK)]
e6f948e3
RK
11492 ""
11493 "")
1fd4e8c1
RK
11494\f
11495;; Compare insns are next. Note that the RS/6000 has two types of compares,
7e69e155 11496;; signed & unsigned, and one type of branch.
1fd4e8c1
RK
11497;;
11498;; Start with the DEFINE_EXPANDs to generate the rtl for compares, scc
11499;; insns, and branches. We store the operands of compares until we see
11500;; how it is used.
4ae234b0 11501(define_expand "cmp<mode>"
1fd4e8c1 11502 [(set (cc0)
4ae234b0
GK
11503 (compare (match_operand:GPR 0 "gpc_reg_operand" "")
11504 (match_operand:GPR 1 "reg_or_short_operand" "")))]
1fd4e8c1
RK
11505 ""
11506 "
11507{
11508 /* Take care of the possibility that operands[1] might be negative but
11509 this might be a logical operation. That insn doesn't exist. */
11510 if (GET_CODE (operands[1]) == CONST_INT
11511 && INTVAL (operands[1]) < 0)
4ae234b0 11512 operands[1] = force_reg (<MODE>mode, operands[1]);
1fd4e8c1
RK
11513
11514 rs6000_compare_op0 = operands[0];
11515 rs6000_compare_op1 = operands[1];
11516 rs6000_compare_fp_p = 0;
11517 DONE;
11518}")
11519
4ae234b0
GK
11520(define_expand "cmp<mode>"
11521 [(set (cc0) (compare (match_operand:FP 0 "gpc_reg_operand" "")
11522 (match_operand:FP 1 "gpc_reg_operand" "")))]
11523 ""
d6f99ca4
DE
11524 "
11525{
11526 rs6000_compare_op0 = operands[0];
11527 rs6000_compare_op1 = operands[1];
11528 rs6000_compare_fp_p = 1;
11529 DONE;
11530}")
11531
1fd4e8c1 11532(define_expand "beq"
39a10a29 11533 [(use (match_operand 0 "" ""))]
1fd4e8c1 11534 ""
39a10a29 11535 "{ rs6000_emit_cbranch (EQ, operands[0]); DONE; }")
1fd4e8c1
RK
11536
11537(define_expand "bne"
39a10a29 11538 [(use (match_operand 0 "" ""))]
1fd4e8c1 11539 ""
39a10a29 11540 "{ rs6000_emit_cbranch (NE, operands[0]); DONE; }")
1fd4e8c1 11541
39a10a29
GK
11542(define_expand "bge"
11543 [(use (match_operand 0 "" ""))]
1fd4e8c1 11544 ""
39a10a29 11545 "{ rs6000_emit_cbranch (GE, operands[0]); DONE; }")
1fd4e8c1
RK
11546
11547(define_expand "bgt"
39a10a29 11548 [(use (match_operand 0 "" ""))]
1fd4e8c1 11549 ""
39a10a29 11550 "{ rs6000_emit_cbranch (GT, operands[0]); DONE; }")
1fd4e8c1
RK
11551
11552(define_expand "ble"
39a10a29 11553 [(use (match_operand 0 "" ""))]
1fd4e8c1 11554 ""
39a10a29 11555 "{ rs6000_emit_cbranch (LE, operands[0]); DONE; }")
1fd4e8c1 11556
39a10a29
GK
11557(define_expand "blt"
11558 [(use (match_operand 0 "" ""))]
1fd4e8c1 11559 ""
39a10a29 11560 "{ rs6000_emit_cbranch (LT, operands[0]); DONE; }")
1fd4e8c1 11561
39a10a29
GK
11562(define_expand "bgeu"
11563 [(use (match_operand 0 "" ""))]
1fd4e8c1 11564 ""
39a10a29 11565 "{ rs6000_emit_cbranch (GEU, operands[0]); DONE; }")
1fd4e8c1 11566
39a10a29
GK
11567(define_expand "bgtu"
11568 [(use (match_operand 0 "" ""))]
1fd4e8c1 11569 ""
39a10a29 11570 "{ rs6000_emit_cbranch (GTU, operands[0]); DONE; }")
1fd4e8c1 11571
39a10a29
GK
11572(define_expand "bleu"
11573 [(use (match_operand 0 "" ""))]
1fd4e8c1 11574 ""
39a10a29 11575 "{ rs6000_emit_cbranch (LEU, operands[0]); DONE; }")
1fd4e8c1 11576
39a10a29
GK
11577(define_expand "bltu"
11578 [(use (match_operand 0 "" ""))]
1fd4e8c1 11579 ""
39a10a29 11580 "{ rs6000_emit_cbranch (LTU, operands[0]); DONE; }")
1fd4e8c1 11581
1c882ea4 11582(define_expand "bunordered"
39a10a29 11583 [(use (match_operand 0 "" ""))]
8ef65e3d 11584 "! (TARGET_HARD_FLOAT && !TARGET_FPRS)"
39a10a29 11585 "{ rs6000_emit_cbranch (UNORDERED, operands[0]); DONE; }")
1c882ea4
GK
11586
11587(define_expand "bordered"
39a10a29 11588 [(use (match_operand 0 "" ""))]
8ef65e3d 11589 "! (TARGET_HARD_FLOAT && !TARGET_FPRS)"
39a10a29 11590 "{ rs6000_emit_cbranch (ORDERED, operands[0]); DONE; }")
1c882ea4
GK
11591
11592(define_expand "buneq"
39a10a29 11593 [(use (match_operand 0 "" ""))]
b26941b4 11594 "! (TARGET_HARD_FLOAT && !TARGET_FPRS)"
39a10a29 11595 "{ rs6000_emit_cbranch (UNEQ, operands[0]); DONE; }")
1c882ea4
GK
11596
11597(define_expand "bunge"
39a10a29 11598 [(use (match_operand 0 "" ""))]
b26941b4 11599 "! (TARGET_HARD_FLOAT && !TARGET_FPRS)"
39a10a29 11600 "{ rs6000_emit_cbranch (UNGE, operands[0]); DONE; }")
1c882ea4
GK
11601
11602(define_expand "bungt"
39a10a29 11603 [(use (match_operand 0 "" ""))]
b26941b4 11604 "! (TARGET_HARD_FLOAT && !TARGET_FPRS)"
39a10a29 11605 "{ rs6000_emit_cbranch (UNGT, operands[0]); DONE; }")
1c882ea4
GK
11606
11607(define_expand "bunle"
39a10a29 11608 [(use (match_operand 0 "" ""))]
b26941b4 11609 "! (TARGET_HARD_FLOAT && !TARGET_FPRS)"
39a10a29 11610 "{ rs6000_emit_cbranch (UNLE, operands[0]); DONE; }")
1c882ea4
GK
11611
11612(define_expand "bunlt"
39a10a29 11613 [(use (match_operand 0 "" ""))]
b26941b4 11614 "! (TARGET_HARD_FLOAT && !TARGET_FPRS)"
39a10a29 11615 "{ rs6000_emit_cbranch (UNLT, operands[0]); DONE; }")
1c882ea4
GK
11616
11617(define_expand "bltgt"
39a10a29 11618 [(use (match_operand 0 "" ""))]
1c882ea4 11619 ""
39a10a29 11620 "{ rs6000_emit_cbranch (LTGT, operands[0]); DONE; }")
1c882ea4 11621
1fd4e8c1
RK
11622;; For SNE, we would prefer that the xor/abs sequence be used for integers.
11623;; For SEQ, likewise, except that comparisons with zero should be done
11624;; with an scc insns. However, due to the order that combine see the
11625;; resulting insns, we must, in fact, allow SEQ for integers. Fail in
11626;; the cases we don't want to handle.
11627(define_expand "seq"
39a10a29 11628 [(clobber (match_operand:SI 0 "gpc_reg_operand" ""))]
1fd4e8c1 11629 ""
39a10a29 11630 "{ rs6000_emit_sCOND (EQ, operands[0]); DONE; }")
1fd4e8c1
RK
11631
11632(define_expand "sne"
39a10a29 11633 [(clobber (match_operand:SI 0 "gpc_reg_operand" ""))]
1fd4e8c1
RK
11634 ""
11635 "
6ae08853 11636{
39a10a29 11637 if (! rs6000_compare_fp_p)
1fd4e8c1
RK
11638 FAIL;
11639
6ae08853 11640 rs6000_emit_sCOND (NE, operands[0]);
39a10a29 11641 DONE;
1fd4e8c1
RK
11642}")
11643
b7053a3f
GK
11644;; A >= 0 is best done the portable way for A an integer.
11645(define_expand "sge"
39a10a29 11646 [(clobber (match_operand:SI 0 "gpc_reg_operand" ""))]
1fd4e8c1
RK
11647 ""
11648 "
5638268e 11649{
e56d7409 11650 if (! rs6000_compare_fp_p && rs6000_compare_op1 == const0_rtx)
1fd4e8c1
RK
11651 FAIL;
11652
b7053a3f 11653 rs6000_emit_sCOND (GE, operands[0]);
39a10a29 11654 DONE;
1fd4e8c1
RK
11655}")
11656
b7053a3f
GK
11657;; A > 0 is best done using the portable sequence, so fail in that case.
11658(define_expand "sgt"
39a10a29 11659 [(clobber (match_operand:SI 0 "gpc_reg_operand" ""))]
1fd4e8c1
RK
11660 ""
11661 "
5638268e 11662{
e56d7409 11663 if (! rs6000_compare_fp_p && rs6000_compare_op1 == const0_rtx)
1fd4e8c1
RK
11664 FAIL;
11665
6ae08853 11666 rs6000_emit_sCOND (GT, operands[0]);
39a10a29 11667 DONE;
1fd4e8c1
RK
11668}")
11669
b7053a3f
GK
11670;; A <= 0 is best done the portable way for A an integer.
11671(define_expand "sle"
39a10a29 11672 [(clobber (match_operand:SI 0 "gpc_reg_operand" ""))]
1fd4e8c1 11673 ""
5638268e
DE
11674 "
11675{
e56d7409 11676 if (! rs6000_compare_fp_p && rs6000_compare_op1 == const0_rtx)
5638268e
DE
11677 FAIL;
11678
6ae08853 11679 rs6000_emit_sCOND (LE, operands[0]);
5638268e
DE
11680 DONE;
11681}")
1fd4e8c1 11682
b7053a3f
GK
11683;; A < 0 is best done in the portable way for A an integer.
11684(define_expand "slt"
39a10a29 11685 [(clobber (match_operand:SI 0 "gpc_reg_operand" ""))]
1fd4e8c1
RK
11686 ""
11687 "
5638268e 11688{
e56d7409 11689 if (! rs6000_compare_fp_p && rs6000_compare_op1 == const0_rtx)
1fd4e8c1
RK
11690 FAIL;
11691
6ae08853 11692 rs6000_emit_sCOND (LT, operands[0]);
39a10a29 11693 DONE;
1fd4e8c1
RK
11694}")
11695
b7053a3f
GK
11696(define_expand "sgeu"
11697 [(clobber (match_operand:SI 0 "gpc_reg_operand" ""))]
11698 ""
11699 "{ rs6000_emit_sCOND (GEU, operands[0]); DONE; }")
11700
1fd4e8c1 11701(define_expand "sgtu"
39a10a29 11702 [(clobber (match_operand:SI 0 "gpc_reg_operand" ""))]
1fd4e8c1 11703 ""
39a10a29 11704 "{ rs6000_emit_sCOND (GTU, operands[0]); DONE; }")
1fd4e8c1 11705
b7053a3f
GK
11706(define_expand "sleu"
11707 [(clobber (match_operand:SI 0 "gpc_reg_operand" ""))]
11708 ""
11709 "{ rs6000_emit_sCOND (LEU, operands[0]); DONE; }")
11710
1fd4e8c1 11711(define_expand "sltu"
39a10a29 11712 [(clobber (match_operand:SI 0 "gpc_reg_operand" ""))]
1fd4e8c1 11713 ""
39a10a29 11714 "{ rs6000_emit_sCOND (LTU, operands[0]); DONE; }")
1fd4e8c1 11715
b7053a3f 11716(define_expand "sunordered"
39a10a29 11717 [(clobber (match_operand:SI 0 "gpc_reg_operand" ""))]
8ef65e3d 11718 "! (TARGET_HARD_FLOAT && !TARGET_FPRS)"
b7053a3f 11719 "{ rs6000_emit_sCOND (UNORDERED, operands[0]); DONE; }")
1fd4e8c1 11720
b7053a3f 11721(define_expand "sordered"
39a10a29 11722 [(clobber (match_operand:SI 0 "gpc_reg_operand" ""))]
8ef65e3d 11723 "! (TARGET_HARD_FLOAT && !TARGET_FPRS)"
b7053a3f
GK
11724 "{ rs6000_emit_sCOND (ORDERED, operands[0]); DONE; }")
11725
11726(define_expand "suneq"
11727 [(clobber (match_operand:SI 0 "gpc_reg_operand" ""))]
b26941b4 11728 "! (TARGET_HARD_FLOAT && !TARGET_FPRS)"
b7053a3f
GK
11729 "{ rs6000_emit_sCOND (UNEQ, operands[0]); DONE; }")
11730
11731(define_expand "sunge"
11732 [(clobber (match_operand:SI 0 "gpc_reg_operand" ""))]
b26941b4 11733 "! (TARGET_HARD_FLOAT && !TARGET_FPRS)"
b7053a3f
GK
11734 "{ rs6000_emit_sCOND (UNGE, operands[0]); DONE; }")
11735
11736(define_expand "sungt"
11737 [(clobber (match_operand:SI 0 "gpc_reg_operand" ""))]
b26941b4 11738 "! (TARGET_HARD_FLOAT && !TARGET_FPRS)"
b7053a3f
GK
11739 "{ rs6000_emit_sCOND (UNGT, operands[0]); DONE; }")
11740
11741(define_expand "sunle"
11742 [(clobber (match_operand:SI 0 "gpc_reg_operand" ""))]
b26941b4 11743 "! (TARGET_HARD_FLOAT && !TARGET_FPRS)"
b7053a3f
GK
11744 "{ rs6000_emit_sCOND (UNLE, operands[0]); DONE; }")
11745
11746(define_expand "sunlt"
11747 [(clobber (match_operand:SI 0 "gpc_reg_operand" ""))]
b26941b4 11748 "! (TARGET_HARD_FLOAT && !TARGET_FPRS)"
b7053a3f
GK
11749 "{ rs6000_emit_sCOND (UNLT, operands[0]); DONE; }")
11750
11751(define_expand "sltgt"
11752 [(clobber (match_operand:SI 0 "gpc_reg_operand" ""))]
11753 ""
11754 "{ rs6000_emit_sCOND (LTGT, operands[0]); DONE; }")
11755
3aebbe5f
JJ
11756(define_expand "stack_protect_set"
11757 [(match_operand 0 "memory_operand" "")
11758 (match_operand 1 "memory_operand" "")]
11759 ""
11760{
77008252
JJ
11761#ifdef TARGET_THREAD_SSP_OFFSET
11762 rtx tlsreg = gen_rtx_REG (Pmode, TARGET_64BIT ? 13 : 2);
11763 rtx addr = gen_rtx_PLUS (Pmode, tlsreg, GEN_INT (TARGET_THREAD_SSP_OFFSET));
11764 operands[1] = gen_rtx_MEM (Pmode, addr);
11765#endif
3aebbe5f
JJ
11766 if (TARGET_64BIT)
11767 emit_insn (gen_stack_protect_setdi (operands[0], operands[1]));
11768 else
11769 emit_insn (gen_stack_protect_setsi (operands[0], operands[1]));
11770 DONE;
11771})
11772
11773(define_insn "stack_protect_setsi"
11774 [(set (match_operand:SI 0 "memory_operand" "=m")
11775 (unspec:SI [(match_operand:SI 1 "memory_operand" "m")] UNSPEC_SP_SET))
11776 (set (match_scratch:SI 2 "=&r") (const_int 0))]
11777 "TARGET_32BIT"
11778 "{l%U1%X1|lwz%U1%X1} %2,%1\;{st%U0%X0|stw%U0%X0} %2,%0\;{lil|li} %2,0"
11779 [(set_attr "type" "three")
11780 (set_attr "length" "12")])
11781
11782(define_insn "stack_protect_setdi"
11783 [(set (match_operand:DI 0 "memory_operand" "=m")
11784 (unspec:DI [(match_operand:DI 1 "memory_operand" "m")] UNSPEC_SP_SET))
11785 (set (match_scratch:DI 2 "=&r") (const_int 0))]
11786 "TARGET_64BIT"
11787 "ld%U1%X1 %2,%1\;std%U0%X0 %2,%0\;{lil|li} %2,0"
11788 [(set_attr "type" "three")
11789 (set_attr "length" "12")])
11790
11791(define_expand "stack_protect_test"
11792 [(match_operand 0 "memory_operand" "")
11793 (match_operand 1 "memory_operand" "")
11794 (match_operand 2 "" "")]
11795 ""
11796{
77008252
JJ
11797#ifdef TARGET_THREAD_SSP_OFFSET
11798 rtx tlsreg = gen_rtx_REG (Pmode, TARGET_64BIT ? 13 : 2);
11799 rtx addr = gen_rtx_PLUS (Pmode, tlsreg, GEN_INT (TARGET_THREAD_SSP_OFFSET));
11800 operands[1] = gen_rtx_MEM (Pmode, addr);
11801#endif
3aebbe5f
JJ
11802 rs6000_compare_op0 = operands[0];
11803 rs6000_compare_op1 = gen_rtx_UNSPEC (Pmode, gen_rtvec (1, operands[1]),
11804 UNSPEC_SP_TEST);
11805 rs6000_compare_fp_p = 0;
11806 emit_jump_insn (gen_beq (operands[2]));
11807 DONE;
11808})
11809
11810(define_insn "stack_protect_testsi"
11811 [(set (match_operand:CCEQ 0 "cc_reg_operand" "=x,?y")
11812 (unspec:CCEQ [(match_operand:SI 1 "memory_operand" "m,m")
11813 (match_operand:SI 2 "memory_operand" "m,m")]
11814 UNSPEC_SP_TEST))
41f12ed0
JJ
11815 (set (match_scratch:SI 4 "=r,r") (const_int 0))
11816 (clobber (match_scratch:SI 3 "=&r,&r"))]
3aebbe5f
JJ
11817 "TARGET_32BIT"
11818 "@
11819 {l%U1%X1|lwz%U1%X1} %3,%1\;{l%U2%X2|lwz%U2%X2} %4,%2\;xor. %3,%3,%4\;{lil|li} %4,0
11820 {l%U1%X1|lwz%U1%X1} %3,%1\;{l%U2%X2|lwz%U2%X2} %4,%2\;{cmpl|cmplw} %0,%3,%4\;{lil|li} %3,0\;{lil|li} %4,0"
11821 [(set_attr "length" "16,20")])
11822
11823(define_insn "stack_protect_testdi"
11824 [(set (match_operand:CCEQ 0 "cc_reg_operand" "=x,?y")
11825 (unspec:CCEQ [(match_operand:DI 1 "memory_operand" "m,m")
11826 (match_operand:DI 2 "memory_operand" "m,m")]
11827 UNSPEC_SP_TEST))
41f12ed0
JJ
11828 (set (match_scratch:DI 4 "=r,r") (const_int 0))
11829 (clobber (match_scratch:DI 3 "=&r,&r"))]
3aebbe5f
JJ
11830 "TARGET_64BIT"
11831 "@
11832 ld%U1%X1 %3,%1\;ld%U2%X2 %4,%2\;xor. %3,%3,%4\;{lil|li} %4,0
11833 ld%U1%X1 %3,%1\;ld%U2%X2 %4,%2\;cmpld %0,%3,%4\;{lil|li} %3,0\;{lil|li} %4,0"
11834 [(set_attr "length" "16,20")])
11835
1fd4e8c1
RK
11836\f
11837;; Here are the actual compare insns.
4ae234b0 11838(define_insn "*cmp<mode>_internal1"
1fd4e8c1 11839 [(set (match_operand:CC 0 "cc_reg_operand" "=y")
4ae234b0
GK
11840 (compare:CC (match_operand:GPR 1 "gpc_reg_operand" "r")
11841 (match_operand:GPR 2 "reg_or_short_operand" "rI")))]
1fd4e8c1 11842 ""
4ae234b0 11843 "{cmp%I2|cmp<wd>%I2} %0,%1,%2"
b54cf83a 11844 [(set_attr "type" "cmp")])
266eb58a 11845
f357808b 11846;; If we are comparing a register for equality with a large constant,
28d0e143
PB
11847;; we can do this with an XOR followed by a compare. But this is profitable
11848;; only if the large constant is only used for the comparison (and in this
11849;; case we already have a register to reuse as scratch).
130869aa
PB
11850;;
11851;; For 64-bit registers, we could only do so if the constant's bit 15 is clear:
11852;; otherwise we'd need to XOR with FFFFFFFF????0000 which is not available.
f357808b 11853
28d0e143 11854(define_peephole2
130869aa 11855 [(set (match_operand:SI 0 "register_operand")
410c459d 11856 (match_operand:SI 1 "logical_const_operand" ""))
130869aa 11857 (set (match_dup 0) (match_operator:SI 3 "boolean_or_operator"
28d0e143 11858 [(match_dup 0)
410c459d 11859 (match_operand:SI 2 "logical_const_operand" "")]))
28d0e143 11860 (set (match_operand:CC 4 "cc_reg_operand" "")
130869aa 11861 (compare:CC (match_operand:SI 5 "gpc_reg_operand" "")
28d0e143
PB
11862 (match_dup 0)))
11863 (set (pc)
11864 (if_then_else (match_operator 6 "equality_operator"
11865 [(match_dup 4) (const_int 0)])
11866 (match_operand 7 "" "")
11867 (match_operand 8 "" "")))]
130869aa
PB
11868 "peep2_reg_dead_p (3, operands[0])
11869 && peep2_reg_dead_p (4, operands[4])"
11870 [(set (match_dup 0) (xor:SI (match_dup 5) (match_dup 9)))
28d0e143
PB
11871 (set (match_dup 4) (compare:CC (match_dup 0) (match_dup 10)))
11872 (set (pc) (if_then_else (match_dup 6) (match_dup 7) (match_dup 8)))]
11873
11874{
11875 /* Get the constant we are comparing against, and see what it looks like
11876 when sign-extended from 16 to 32 bits. Then see what constant we could
11877 XOR with SEXTC to get the sign-extended value. */
11878 rtx cnst = simplify_const_binary_operation (GET_CODE (operands[3]),
130869aa 11879 SImode,
28d0e143
PB
11880 operands[1], operands[2]);
11881 HOST_WIDE_INT c = INTVAL (cnst);
a65c591c 11882 HOST_WIDE_INT sextc = ((c & 0xffff) ^ 0x8000) - 0x8000;
5f59ecb7 11883 HOST_WIDE_INT xorv = c ^ sextc;
f357808b 11884
28d0e143
PB
11885 operands[9] = GEN_INT (xorv);
11886 operands[10] = GEN_INT (sextc);
11887})
f357808b 11888
acad7ed3 11889(define_insn "*cmpsi_internal2"
1fd4e8c1 11890 [(set (match_operand:CCUNS 0 "cc_reg_operand" "=y")
cd2b37d9 11891 (compare:CCUNS (match_operand:SI 1 "gpc_reg_operand" "r")
9ebbca7d 11892 (match_operand:SI 2 "reg_or_u_short_operand" "rK")))]
1fd4e8c1 11893 ""
e2c953b6 11894 "{cmpl%I2|cmplw%I2} %0,%1,%b2"
b54cf83a 11895 [(set_attr "type" "cmp")])
1fd4e8c1 11896
acad7ed3 11897(define_insn "*cmpdi_internal2"
266eb58a
DE
11898 [(set (match_operand:CCUNS 0 "cc_reg_operand" "=y")
11899 (compare:CCUNS (match_operand:DI 1 "gpc_reg_operand" "r")
9ebbca7d 11900 (match_operand:DI 2 "reg_or_u_short_operand" "rK")))]
266eb58a 11901 ""
e2c953b6 11902 "cmpld%I2 %0,%1,%b2"
b54cf83a 11903 [(set_attr "type" "cmp")])
266eb58a 11904
1fd4e8c1
RK
11905;; The following two insns don't exist as single insns, but if we provide
11906;; them, we can swap an add and compare, which will enable us to overlap more
11907;; of the required delay between a compare and branch. We generate code for
11908;; them by splitting.
11909
11910(define_insn ""
11911 [(set (match_operand:CC 3 "cc_reg_operand" "=y")
cd2b37d9 11912 (compare:CC (match_operand:SI 1 "gpc_reg_operand" "r")
1fd4e8c1 11913 (match_operand:SI 2 "short_cint_operand" "i")))
cd2b37d9 11914 (set (match_operand:SI 0 "gpc_reg_operand" "=r")
1fd4e8c1
RK
11915 (plus:SI (match_dup 1) (match_operand:SI 4 "short_cint_operand" "i")))]
11916 ""
baf97f86
RK
11917 "#"
11918 [(set_attr "length" "8")])
7e69e155 11919
1fd4e8c1
RK
11920(define_insn ""
11921 [(set (match_operand:CCUNS 3 "cc_reg_operand" "=y")
cd2b37d9 11922 (compare:CCUNS (match_operand:SI 1 "gpc_reg_operand" "r")
1fd4e8c1 11923 (match_operand:SI 2 "u_short_cint_operand" "i")))
cd2b37d9 11924 (set (match_operand:SI 0 "gpc_reg_operand" "=r")
1fd4e8c1
RK
11925 (plus:SI (match_dup 1) (match_operand:SI 4 "short_cint_operand" "i")))]
11926 ""
baf97f86
RK
11927 "#"
11928 [(set_attr "length" "8")])
7e69e155 11929
1fd4e8c1
RK
11930(define_split
11931 [(set (match_operand:CC 3 "cc_reg_operand" "")
cd2b37d9 11932 (compare:CC (match_operand:SI 1 "gpc_reg_operand" "")
1fd4e8c1 11933 (match_operand:SI 2 "short_cint_operand" "")))
cd2b37d9 11934 (set (match_operand:SI 0 "gpc_reg_operand" "")
1fd4e8c1
RK
11935 (plus:SI (match_dup 1) (match_operand:SI 4 "short_cint_operand" "")))]
11936 ""
11937 [(set (match_dup 3) (compare:CC (match_dup 1) (match_dup 2)))
11938 (set (match_dup 0) (plus:SI (match_dup 1) (match_dup 4)))])
11939
11940(define_split
11941 [(set (match_operand:CCUNS 3 "cc_reg_operand" "")
cd2b37d9 11942 (compare:CCUNS (match_operand:SI 1 "gpc_reg_operand" "")
1fd4e8c1 11943 (match_operand:SI 2 "u_short_cint_operand" "")))
cd2b37d9 11944 (set (match_operand:SI 0 "gpc_reg_operand" "")
1fd4e8c1
RK
11945 (plus:SI (match_dup 1) (match_operand:SI 4 "short_cint_operand" "")))]
11946 ""
11947 [(set (match_dup 3) (compare:CCUNS (match_dup 1) (match_dup 2)))
11948 (set (match_dup 0) (plus:SI (match_dup 1) (match_dup 4)))])
11949
acad7ed3 11950(define_insn "*cmpsf_internal1"
1fd4e8c1 11951 [(set (match_operand:CCFP 0 "cc_reg_operand" "=y")
cd2b37d9
RK
11952 (compare:CCFP (match_operand:SF 1 "gpc_reg_operand" "f")
11953 (match_operand:SF 2 "gpc_reg_operand" "f")))]
a3170dc6 11954 "TARGET_HARD_FLOAT && TARGET_FPRS"
1fd4e8c1
RK
11955 "fcmpu %0,%1,%2"
11956 [(set_attr "type" "fpcompare")])
11957
acad7ed3 11958(define_insn "*cmpdf_internal1"
1fd4e8c1 11959 [(set (match_operand:CCFP 0 "cc_reg_operand" "=y")
cd2b37d9
RK
11960 (compare:CCFP (match_operand:DF 1 "gpc_reg_operand" "f")
11961 (match_operand:DF 2 "gpc_reg_operand" "f")))]
a3170dc6 11962 "TARGET_HARD_FLOAT && TARGET_FPRS"
1fd4e8c1
RK
11963 "fcmpu %0,%1,%2"
11964 [(set_attr "type" "fpcompare")])
d6f99ca4
DE
11965
11966;; Only need to compare second words if first words equal
11967(define_insn "*cmptf_internal1"
11968 [(set (match_operand:CCFP 0 "cc_reg_operand" "=y")
11969 (compare:CCFP (match_operand:TF 1 "gpc_reg_operand" "f")
11970 (match_operand:TF 2 "gpc_reg_operand" "f")))]
602ea4d3 11971 "!TARGET_IEEEQUAD && !TARGET_XL_COMPAT
39e63627 11972 && TARGET_HARD_FLOAT && TARGET_FPRS && TARGET_LONG_DOUBLE_128"
ecb62ae7 11973 "fcmpu %0,%1,%2\;bne %0,$+8\;fcmpu %0,%L1,%L2"
d6f99ca4
DE
11974 [(set_attr "type" "fpcompare")
11975 (set_attr "length" "12")])
de17c25f
DE
11976
11977(define_insn_and_split "*cmptf_internal2"
11978 [(set (match_operand:CCFP 0 "cc_reg_operand" "=y")
11979 (compare:CCFP (match_operand:TF 1 "gpc_reg_operand" "f")
11980 (match_operand:TF 2 "gpc_reg_operand" "f")))
11981 (clobber (match_scratch:DF 3 "=f"))
11982 (clobber (match_scratch:DF 4 "=f"))
11983 (clobber (match_scratch:DF 5 "=f"))
11984 (clobber (match_scratch:DF 6 "=f"))
11985 (clobber (match_scratch:DF 7 "=f"))
11986 (clobber (match_scratch:DF 8 "=f"))
11987 (clobber (match_scratch:DF 9 "=f"))
11988 (clobber (match_scratch:DF 10 "=f"))]
602ea4d3 11989 "!TARGET_IEEEQUAD && TARGET_XL_COMPAT
de17c25f
DE
11990 && TARGET_HARD_FLOAT && TARGET_FPRS && TARGET_LONG_DOUBLE_128"
11991 "#"
11992 "&& reload_completed"
11993 [(set (match_dup 3) (match_dup 13))
11994 (set (match_dup 4) (match_dup 14))
11995 (set (match_dup 9) (abs:DF (match_dup 5)))
11996 (set (match_dup 0) (compare:CCFP (match_dup 9) (match_dup 3)))
11997 (set (pc) (if_then_else (ne (match_dup 0) (const_int 0))
11998 (label_ref (match_dup 11))
11999 (pc)))
12000 (set (match_dup 0) (compare:CCFP (match_dup 5) (match_dup 7)))
12001 (set (pc) (label_ref (match_dup 12)))
12002 (match_dup 11)
12003 (set (match_dup 10) (minus:DF (match_dup 5) (match_dup 7)))
12004 (set (match_dup 9) (minus:DF (match_dup 6) (match_dup 8)))
12005 (set (match_dup 9) (plus:DF (match_dup 10) (match_dup 9)))
12006 (set (match_dup 0) (compare:CCFP (match_dup 7) (match_dup 4)))
12007 (match_dup 12)]
12008{
12009 REAL_VALUE_TYPE rv;
12010 const int lo_word = FLOAT_WORDS_BIG_ENDIAN ? GET_MODE_SIZE (DFmode) : 0;
12011 const int hi_word = FLOAT_WORDS_BIG_ENDIAN ? 0 : GET_MODE_SIZE (DFmode);
12012
12013 operands[5] = simplify_gen_subreg (DFmode, operands[1], TFmode, hi_word);
12014 operands[6] = simplify_gen_subreg (DFmode, operands[1], TFmode, lo_word);
12015 operands[7] = simplify_gen_subreg (DFmode, operands[2], TFmode, hi_word);
12016 operands[8] = simplify_gen_subreg (DFmode, operands[2], TFmode, lo_word);
12017 operands[11] = gen_label_rtx ();
12018 operands[12] = gen_label_rtx ();
12019 real_inf (&rv);
12020 operands[13] = force_const_mem (DFmode,
12021 CONST_DOUBLE_FROM_REAL_VALUE (rv, DFmode));
12022 operands[14] = force_const_mem (DFmode,
12023 CONST_DOUBLE_FROM_REAL_VALUE (dconst0,
12024 DFmode));
12025 if (TARGET_TOC)
12026 {
12027 operands[13] = gen_const_mem (DFmode,
12028 create_TOC_reference (XEXP (operands[13], 0)));
12029 operands[14] = gen_const_mem (DFmode,
12030 create_TOC_reference (XEXP (operands[14], 0)));
12031 set_mem_alias_set (operands[13], get_TOC_alias_set ());
12032 set_mem_alias_set (operands[14], get_TOC_alias_set ());
12033 }
12034})
1fd4e8c1
RK
12035\f
12036;; Now we have the scc insns. We can do some combinations because of the
12037;; way the machine works.
12038;;
12039;; Note that this is probably faster if we can put an insn between the
c5defebb
RK
12040;; mfcr and rlinm, but this is tricky. Let's leave it for now. In most
12041;; cases the insns below which don't use an intermediate CR field will
12042;; be used instead.
1fd4e8c1 12043(define_insn ""
cd2b37d9 12044 [(set (match_operand:SI 0 "gpc_reg_operand" "=r")
1fd4e8c1
RK
12045 (match_operator:SI 1 "scc_comparison_operator"
12046 [(match_operand 2 "cc_reg_operand" "y")
12047 (const_int 0)]))]
12048 ""
2c4a9cff
DE
12049 "mfcr %0%Q2\;{rlinm|rlwinm} %0,%0,%J1,1"
12050 [(set (attr "type")
12051 (cond [(ne (symbol_ref "TARGET_MFCRF") (const_int 0))
12052 (const_string "mfcrf")
12053 ]
12054 (const_string "mfcr")))
c1618c0c 12055 (set_attr "length" "8")])
1fd4e8c1 12056
423c1189 12057;; Same as above, but get the GT bit.
64022b5d 12058(define_insn "move_from_CR_gt_bit"
423c1189 12059 [(set (match_operand:SI 0 "gpc_reg_operand" "=r")
64022b5d 12060 (unspec:SI [(match_operand 1 "cc_reg_operand" "y")] UNSPEC_MV_CR_GT))]
423c1189 12061 "TARGET_E500"
64022b5d 12062 "mfcr %0\;{rlinm|rlwinm} %0,%0,%D1,31,31"
423c1189 12063 [(set_attr "type" "mfcr")
c1618c0c 12064 (set_attr "length" "8")])
423c1189 12065
a3170dc6
AH
12066;; Same as above, but get the OV/ORDERED bit.
12067(define_insn "move_from_CR_ov_bit"
12068 [(set (match_operand:SI 0 "gpc_reg_operand" "=r")
615158e2 12069 (unspec:SI [(match_operand 1 "cc_reg_operand" "y")] UNSPEC_MV_CR_OV))]
a3170dc6 12070 "TARGET_ISEL"
b7053a3f 12071 "mfcr %0\;{rlinm|rlwinm} %0,%0,%t1,1"
b54cf83a 12072 [(set_attr "type" "mfcr")
c1618c0c 12073 (set_attr "length" "8")])
a3170dc6 12074
1fd4e8c1 12075(define_insn ""
9ebbca7d
GK
12076 [(set (match_operand:DI 0 "gpc_reg_operand" "=r")
12077 (match_operator:DI 1 "scc_comparison_operator"
12078 [(match_operand 2 "cc_reg_operand" "y")
12079 (const_int 0)]))]
12080 "TARGET_POWERPC64"
2c4a9cff
DE
12081 "mfcr %0%Q2\;{rlinm|rlwinm} %0,%0,%J1,1"
12082 [(set (attr "type")
12083 (cond [(ne (symbol_ref "TARGET_MFCRF") (const_int 0))
12084 (const_string "mfcrf")
12085 ]
12086 (const_string "mfcr")))
c1618c0c 12087 (set_attr "length" "8")])
9ebbca7d
GK
12088
12089(define_insn ""
12090 [(set (match_operand:CC 0 "cc_reg_operand" "=x,?y")
1fd4e8c1 12091 (compare:CC (match_operator:SI 1 "scc_comparison_operator"
9ebbca7d 12092 [(match_operand 2 "cc_reg_operand" "y,y")
1fd4e8c1
RK
12093 (const_int 0)])
12094 (const_int 0)))
9ebbca7d 12095 (set (match_operand:SI 3 "gpc_reg_operand" "=r,r")
1fd4e8c1 12096 (match_op_dup 1 [(match_dup 2) (const_int 0)]))]
4b8a63d6 12097 "TARGET_32BIT"
9ebbca7d 12098 "@
2c4a9cff 12099 mfcr %3%Q2\;{rlinm.|rlwinm.} %3,%3,%J1,1
9ebbca7d 12100 #"
b19003d8 12101 [(set_attr "type" "delayed_compare")
c1618c0c 12102 (set_attr "length" "8,16")])
9ebbca7d
GK
12103
12104(define_split
12105 [(set (match_operand:CC 0 "cc_reg_not_cr0_operand" "")
12106 (compare:CC (match_operator:SI 1 "scc_comparison_operator"
12107 [(match_operand 2 "cc_reg_operand" "")
12108 (const_int 0)])
12109 (const_int 0)))
12110 (set (match_operand:SI 3 "gpc_reg_operand" "")
12111 (match_op_dup 1 [(match_dup 2) (const_int 0)]))]
4b8a63d6 12112 "TARGET_32BIT && reload_completed"
9ebbca7d
GK
12113 [(set (match_dup 3)
12114 (match_op_dup 1 [(match_dup 2) (const_int 0)]))
12115 (set (match_dup 0)
12116 (compare:CC (match_dup 3)
12117 (const_int 0)))]
12118 "")
1fd4e8c1
RK
12119
12120(define_insn ""
cd2b37d9 12121 [(set (match_operand:SI 0 "gpc_reg_operand" "=r")
1fd4e8c1
RK
12122 (ashift:SI (match_operator:SI 1 "scc_comparison_operator"
12123 [(match_operand 2 "cc_reg_operand" "y")
12124 (const_int 0)])
12125 (match_operand:SI 3 "const_int_operand" "n")))]
12126 ""
12127 "*
12128{
12129 int is_bit = ccr_bit (operands[1], 1);
12130 int put_bit = 31 - (INTVAL (operands[3]) & 31);
12131 int count;
12132
12133 if (is_bit >= put_bit)
12134 count = is_bit - put_bit;
12135 else
12136 count = 32 - (put_bit - is_bit);
12137
89e9f3a8
MM
12138 operands[4] = GEN_INT (count);
12139 operands[5] = GEN_INT (put_bit);
1fd4e8c1 12140
2c4a9cff 12141 return \"mfcr %0%Q2\;{rlinm|rlwinm} %0,%0,%4,%5,%5\";
b19003d8 12142}"
2c4a9cff
DE
12143 [(set (attr "type")
12144 (cond [(ne (symbol_ref "TARGET_MFCRF") (const_int 0))
12145 (const_string "mfcrf")
12146 ]
12147 (const_string "mfcr")))
c1618c0c 12148 (set_attr "length" "8")])
1fd4e8c1
RK
12149
12150(define_insn ""
9ebbca7d 12151 [(set (match_operand:CC 0 "cc_reg_operand" "=x,?y")
1fd4e8c1
RK
12152 (compare:CC
12153 (ashift:SI (match_operator:SI 1 "scc_comparison_operator"
9ebbca7d 12154 [(match_operand 2 "cc_reg_operand" "y,y")
1fd4e8c1 12155 (const_int 0)])
9ebbca7d 12156 (match_operand:SI 3 "const_int_operand" "n,n"))
1fd4e8c1 12157 (const_int 0)))
9ebbca7d 12158 (set (match_operand:SI 4 "gpc_reg_operand" "=r,r")
1fd4e8c1
RK
12159 (ashift:SI (match_op_dup 1 [(match_dup 2) (const_int 0)])
12160 (match_dup 3)))]
ce71f754 12161 ""
1fd4e8c1
RK
12162 "*
12163{
12164 int is_bit = ccr_bit (operands[1], 1);
12165 int put_bit = 31 - (INTVAL (operands[3]) & 31);
12166 int count;
12167
9ebbca7d
GK
12168 /* Force split for non-cc0 compare. */
12169 if (which_alternative == 1)
12170 return \"#\";
12171
1fd4e8c1
RK
12172 if (is_bit >= put_bit)
12173 count = is_bit - put_bit;
12174 else
12175 count = 32 - (put_bit - is_bit);
12176
89e9f3a8
MM
12177 operands[5] = GEN_INT (count);
12178 operands[6] = GEN_INT (put_bit);
1fd4e8c1 12179
2c4a9cff 12180 return \"mfcr %4%Q2\;{rlinm.|rlwinm.} %4,%4,%5,%6,%6\";
1fd4e8c1 12181}"
b19003d8 12182 [(set_attr "type" "delayed_compare")
c1618c0c 12183 (set_attr "length" "8,16")])
9ebbca7d
GK
12184
12185(define_split
12186 [(set (match_operand:CC 0 "cc_reg_not_cr0_operand" "")
12187 (compare:CC
12188 (ashift:SI (match_operator:SI 1 "scc_comparison_operator"
12189 [(match_operand 2 "cc_reg_operand" "")
12190 (const_int 0)])
12191 (match_operand:SI 3 "const_int_operand" ""))
12192 (const_int 0)))
12193 (set (match_operand:SI 4 "gpc_reg_operand" "")
12194 (ashift:SI (match_op_dup 1 [(match_dup 2) (const_int 0)])
12195 (match_dup 3)))]
ce71f754 12196 "reload_completed"
9ebbca7d
GK
12197 [(set (match_dup 4)
12198 (ashift:SI (match_op_dup 1 [(match_dup 2) (const_int 0)])
12199 (match_dup 3)))
12200 (set (match_dup 0)
12201 (compare:CC (match_dup 4)
12202 (const_int 0)))]
12203 "")
1fd4e8c1 12204
c5defebb
RK
12205;; There is a 3 cycle delay between consecutive mfcr instructions
12206;; so it is useful to combine 2 scc instructions to use only one mfcr.
12207
12208(define_peephole
cd2b37d9 12209 [(set (match_operand:SI 0 "gpc_reg_operand" "=r")
c5defebb
RK
12210 (match_operator:SI 1 "scc_comparison_operator"
12211 [(match_operand 2 "cc_reg_operand" "y")
12212 (const_int 0)]))
cd2b37d9 12213 (set (match_operand:SI 3 "gpc_reg_operand" "=r")
c5defebb
RK
12214 (match_operator:SI 4 "scc_comparison_operator"
12215 [(match_operand 5 "cc_reg_operand" "y")
12216 (const_int 0)]))]
309323c2 12217 "REGNO (operands[2]) != REGNO (operands[5])"
b7053a3f 12218 "mfcr %3\;{rlinm|rlwinm} %0,%3,%J1,1\;{rlinm|rlwinm} %3,%3,%J4,1"
b54cf83a 12219 [(set_attr "type" "mfcr")
c1618c0c 12220 (set_attr "length" "12")])
c5defebb 12221
9ebbca7d
GK
12222(define_peephole
12223 [(set (match_operand:DI 0 "gpc_reg_operand" "=r")
12224 (match_operator:DI 1 "scc_comparison_operator"
12225 [(match_operand 2 "cc_reg_operand" "y")
12226 (const_int 0)]))
12227 (set (match_operand:DI 3 "gpc_reg_operand" "=r")
12228 (match_operator:DI 4 "scc_comparison_operator"
12229 [(match_operand 5 "cc_reg_operand" "y")
12230 (const_int 0)]))]
309323c2 12231 "TARGET_POWERPC64 && REGNO (operands[2]) != REGNO (operands[5])"
b7053a3f 12232 "mfcr %3\;{rlinm|rlwinm} %0,%3,%J1,1\;{rlinm|rlwinm} %3,%3,%J4,1"
b54cf83a 12233 [(set_attr "type" "mfcr")
c1618c0c 12234 (set_attr "length" "12")])
9ebbca7d 12235
1fd4e8c1
RK
12236;; There are some scc insns that can be done directly, without a compare.
12237;; These are faster because they don't involve the communications between
12238;; the FXU and branch units. In fact, we will be replacing all of the
12239;; integer scc insns here or in the portable methods in emit_store_flag.
12240;;
12241;; Also support (neg (scc ..)) since that construct is used to replace
12242;; branches, (plus (scc ..) ..) since that construct is common and
12243;; takes no more insns than scc, and (and (neg (scc ..)) ..) in the
12244;; cases where it is no more expensive than (neg (scc ..)).
12245
12246;; Have reload force a constant into a register for the simple insns that
12247;; otherwise won't accept constants. We do this because it is faster than
12248;; the cmp/mfcr sequence we would otherwise generate.
12249
e9441276
DE
12250(define_mode_attr scc_eq_op2 [(SI "rKLI")
12251 (DI "rKJI")])
a260abc9 12252
e9441276
DE
12253(define_insn_and_split "*eq<mode>"
12254 [(set (match_operand:GPR 0 "gpc_reg_operand" "=r")
12255 (eq:GPR (match_operand:GPR 1 "gpc_reg_operand" "r")
d0515b39 12256 (match_operand:GPR 2 "scc_eq_operand" "<scc_eq_op2>")))]
27f0fe7f 12257 "!TARGET_POWER"
e9441276 12258 "#"
27f0fe7f 12259 "!TARGET_POWER"
d0515b39
DE
12260 [(set (match_dup 0)
12261 (clz:GPR (match_dup 3)))
70ae0191 12262 (set (match_dup 0)
d0515b39 12263 (lshiftrt:GPR (match_dup 0) (match_dup 4)))]
70ae0191 12264 {
e9441276
DE
12265 if (GET_CODE (operands[2]) != CONST_INT || INTVAL (operands[2]) != 0)
12266 {
d0515b39
DE
12267 /* Use output operand as intermediate. */
12268 operands[3] = operands[0];
12269
e9441276 12270 if (logical_operand (operands[2], <MODE>mode))
d0515b39 12271 emit_insn (gen_rtx_SET (VOIDmode, operands[3],
e9441276
DE
12272 gen_rtx_XOR (<MODE>mode,
12273 operands[1], operands[2])));
12274 else
d0515b39 12275 emit_insn (gen_rtx_SET (VOIDmode, operands[3],
e9441276
DE
12276 gen_rtx_PLUS (<MODE>mode, operands[1],
12277 negate_rtx (<MODE>mode,
12278 operands[2]))));
12279 }
12280 else
d0515b39 12281 operands[3] = operands[1];
9ebbca7d 12282
d0515b39 12283 operands[4] = GEN_INT (exact_log2 (GET_MODE_BITSIZE (<MODE>mode)));
e9441276 12284 })
a260abc9 12285
e9441276 12286(define_insn_and_split "*eq<mode>_compare"
d0515b39 12287 [(set (match_operand:CC 3 "cc_reg_operand" "=y")
70ae0191 12288 (compare:CC
1fa5c709
DE
12289 (eq:P (match_operand:P 1 "gpc_reg_operand" "=r")
12290 (match_operand:P 2 "scc_eq_operand" "<scc_eq_op2>"))
70ae0191 12291 (const_int 0)))
1fa5c709 12292 (set (match_operand:P 0 "gpc_reg_operand" "=r")
d0515b39 12293 (eq:P (match_dup 1) (match_dup 2)))]
27f0fe7f 12294 "!TARGET_POWER && optimize_size"
e9441276 12295 "#"
27f0fe7f 12296 "!TARGET_POWER && optimize_size"
d0515b39 12297 [(set (match_dup 0)
1fa5c709 12298 (clz:P (match_dup 4)))
d0515b39
DE
12299 (parallel [(set (match_dup 3)
12300 (compare:CC (lshiftrt:P (match_dup 0) (match_dup 5))
70ae0191
DE
12301 (const_int 0)))
12302 (set (match_dup 0)
d0515b39 12303 (lshiftrt:P (match_dup 0) (match_dup 5)))])]
70ae0191 12304 {
e9441276
DE
12305 if (GET_CODE (operands[2]) != CONST_INT || INTVAL (operands[2]) != 0)
12306 {
d0515b39
DE
12307 /* Use output operand as intermediate. */
12308 operands[4] = operands[0];
12309
e9441276
DE
12310 if (logical_operand (operands[2], <MODE>mode))
12311 emit_insn (gen_rtx_SET (VOIDmode, operands[4],
12312 gen_rtx_XOR (<MODE>mode,
12313 operands[1], operands[2])));
12314 else
12315 emit_insn (gen_rtx_SET (VOIDmode, operands[4],
12316 gen_rtx_PLUS (<MODE>mode, operands[1],
12317 negate_rtx (<MODE>mode,
12318 operands[2]))));
12319 }
12320 else
12321 operands[4] = operands[1];
12322
d0515b39 12323 operands[5] = GEN_INT (exact_log2 (GET_MODE_BITSIZE (<MODE>mode)));
70ae0191
DE
12324 })
12325
05f68097
DE
12326(define_insn "*eqsi_power"
12327 [(set (match_operand:SI 0 "gpc_reg_operand" "=r,r,r,r,r")
12328 (eq:SI (match_operand:SI 1 "gpc_reg_operand" "%r,r,r,r,r")
12329 (match_operand:SI 2 "reg_or_cint_operand" "r,O,K,L,I")))
12330 (clobber (match_scratch:SI 3 "=r,&r,r,r,r"))]
12331 "TARGET_POWER"
12332 "@
12333 xor %0,%1,%2\;{sfi|subfic} %3,%0,0\;{ae|adde} %0,%3,%0
12334 {sfi|subfic} %3,%1,0\;{ae|adde} %0,%3,%1
12335 {xoril|xori} %0,%1,%b2\;{sfi|subfic} %3,%0,0\;{ae|adde} %0,%3,%0
12336 {xoriu|xoris} %0,%1,%u2\;{sfi|subfic} %3,%0,0\;{ae|adde} %0,%3,%0
12337 {sfi|subfic} %0,%1,%2\;{sfi|subfic} %3,%0,0\;{ae|adde} %0,%3,%0"
12338 [(set_attr "type" "three,two,three,three,three")
12339 (set_attr "length" "12,8,12,12,12")])
12340
b19003d8
RK
12341;; We have insns of the form shown by the first define_insn below. If
12342;; there is something inside the comparison operation, we must split it.
12343(define_split
12344 [(set (match_operand:SI 0 "gpc_reg_operand" "")
12345 (plus:SI (match_operator 1 "comparison_operator"
12346 [(match_operand:SI 2 "" "")
12347 (match_operand:SI 3
12348 "reg_or_cint_operand" "")])
12349 (match_operand:SI 4 "gpc_reg_operand" "")))
12350 (clobber (match_operand:SI 5 "register_operand" ""))]
12351 "! gpc_reg_operand (operands[2], SImode)"
12352 [(set (match_dup 5) (match_dup 2))
12353 (set (match_dup 2) (plus:SI (match_op_dup 1 [(match_dup 2) (match_dup 3)])
12354 (match_dup 4)))])
1fd4e8c1 12355
297abd0d 12356(define_insn "*plus_eqsi"
5276df18 12357 [(set (match_operand:SI 0 "gpc_reg_operand" "=&r,&r,&r,&r,&r")
cd2b37d9 12358 (plus:SI (eq:SI (match_operand:SI 1 "gpc_reg_operand" "%r,r,r,r,r")
56fc483e 12359 (match_operand:SI 2 "scc_eq_operand" "r,O,K,L,I"))
5276df18 12360 (match_operand:SI 3 "gpc_reg_operand" "r,r,r,r,r")))]
59d6560b 12361 "TARGET_32BIT"
1fd4e8c1 12362 "@
5276df18
DE
12363 xor %0,%1,%2\;{sfi|subfic} %0,%0,0\;{aze|addze} %0,%3
12364 {sfi|subfic} %0,%1,0\;{aze|addze} %0,%3
12365 {xoril|xori} %0,%1,%b2\;{sfi|subfic} %0,%0,0\;{aze|addze} %0,%3
12366 {xoriu|xoris} %0,%1,%u2\;{sfi|subfic} %0,%0,0\;{aze|addze} %0,%3
12367 {sfi|subfic} %0,%1,%2\;{sfi|subfic} %0,%0,0\;{aze|addze} %0,%3"
943c15ed
DE
12368 [(set_attr "type" "three,two,three,three,three")
12369 (set_attr "length" "12,8,12,12,12")])
1fd4e8c1 12370
297abd0d 12371(define_insn "*compare_plus_eqsi"
9ebbca7d 12372 [(set (match_operand:CC 0 "cc_reg_operand" "=x,x,x,x,x,?y,?y,?y,?y,?y")
7e69e155 12373 (compare:CC
1fd4e8c1 12374 (plus:SI
9ebbca7d 12375 (eq:SI (match_operand:SI 1 "gpc_reg_operand" "%r,r,r,r,r,r,r,r,r,r")
56fc483e 12376 (match_operand:SI 2 "scc_eq_operand" "r,O,K,L,I,r,O,K,L,I"))
9ebbca7d 12377 (match_operand:SI 3 "gpc_reg_operand" "r,r,r,r,r,r,r,r,r,r"))
1fd4e8c1 12378 (const_int 0)))
9ebbca7d 12379 (clobber (match_scratch:SI 4 "=&r,&r,&r,&r,&r,&r,&r,&r,&r,&r"))]
297abd0d 12380 "TARGET_32BIT && optimize_size"
1fd4e8c1 12381 "@
ca7f5001 12382 xor %4,%1,%2\;{sfi|subfic} %4,%4,0\;{aze.|addze.} %4,%3
19378cf8 12383 {sfi|subfic} %4,%1,0\;{aze.|addze.} %4,%3
ca7f5001
RK
12384 {xoril|xori} %4,%1,%b2\;{sfi|subfic} %4,%4,0\;{aze.|addze.} %4,%3
12385 {xoriu|xoris} %4,%1,%u2\;{sfi|subfic} %4,%4,0\;{aze.|addze.} %4,%3
9ebbca7d
GK
12386 {sfi|subfic} %4,%1,%2\;{sfi|subfic} %4,%4,0\;{aze.|addze.} %4,%3
12387 #
12388 #
12389 #
12390 #
12391 #"
b19003d8 12392 [(set_attr "type" "compare")
9ebbca7d
GK
12393 (set_attr "length" "12,8,12,12,12,16,12,16,16,16")])
12394
12395(define_split
12396 [(set (match_operand:CC 0 "cc_reg_not_cr0_operand" "")
12397 (compare:CC
12398 (plus:SI
12399 (eq:SI (match_operand:SI 1 "gpc_reg_operand" "")
56fc483e 12400 (match_operand:SI 2 "scc_eq_operand" ""))
9ebbca7d
GK
12401 (match_operand:SI 3 "gpc_reg_operand" ""))
12402 (const_int 0)))
12403 (clobber (match_scratch:SI 4 ""))]
297abd0d 12404 "TARGET_32BIT && optimize_size && reload_completed"
9ebbca7d
GK
12405 [(set (match_dup 4)
12406 (plus:SI (eq:SI (match_dup 1)
12407 (match_dup 2))
12408 (match_dup 3)))
12409 (set (match_dup 0)
12410 (compare:CC (match_dup 4)
12411 (const_int 0)))]
12412 "")
1fd4e8c1 12413
297abd0d 12414(define_insn "*plus_eqsi_compare"
0387639b 12415 [(set (match_operand:CC 4 "cc_reg_operand" "=x,x,x,x,x,?y,?y,?y,?y,?y")
7e69e155 12416 (compare:CC
1fd4e8c1 12417 (plus:SI
9ebbca7d 12418 (eq:SI (match_operand:SI 1 "gpc_reg_operand" "%r,r,r,r,r,r,r,r,r,r")
56fc483e 12419 (match_operand:SI 2 "scc_eq_operand" "r,O,K,L,I,r,O,K,L,I"))
9ebbca7d 12420 (match_operand:SI 3 "gpc_reg_operand" "r,r,r,r,r,r,r,r,r,r"))
1fd4e8c1 12421 (const_int 0)))
0387639b
DE
12422 (set (match_operand:SI 0 "gpc_reg_operand" "=&r,&r,&r,&r,&r,&r,&r,&r,&r,&r")
12423 (plus:SI (eq:SI (match_dup 1) (match_dup 2)) (match_dup 3)))]
297abd0d 12424 "TARGET_32BIT && optimize_size"
1fd4e8c1 12425 "@
0387639b
DE
12426 xor %0,%1,%2\;{sfi|subfic} %0,%0,0\;{aze.|addze.} %0,%3
12427 {sfi|subfic} %0,%1,0\;{aze.|addze.} %0,%3
12428 {xoril|xori} %0,%1,%b2\;{sfi|subfic} %0,%0,0\;{aze.|addze.} %0,%3
12429 {xoriu|xoris} %0,%1,%u2\;{sfi|subfic} %0,%0,0\;{aze.|addze.} %0,%3
12430 {sfi|subfic} %0,%1,%2\;{sfi|subfic} %0,%0,0\;{aze.|addze.} %0,%3
9ebbca7d
GK
12431 #
12432 #
12433 #
12434 #
12435 #"
12436 [(set_attr "type" "compare")
12437 (set_attr "length" "12,8,12,12,12,16,12,16,16,16")])
12438
12439(define_split
0387639b 12440 [(set (match_operand:CC 4 "cc_reg_not_cr0_operand" "")
9ebbca7d
GK
12441 (compare:CC
12442 (plus:SI
12443 (eq:SI (match_operand:SI 1 "gpc_reg_operand" "")
56fc483e 12444 (match_operand:SI 2 "scc_eq_operand" ""))
9ebbca7d
GK
12445 (match_operand:SI 3 "gpc_reg_operand" ""))
12446 (const_int 0)))
12447 (set (match_operand:SI 0 "gpc_reg_operand" "")
0387639b 12448 (plus:SI (eq:SI (match_dup 1) (match_dup 2)) (match_dup 3)))]
297abd0d 12449 "TARGET_32BIT && optimize_size && reload_completed"
0387639b 12450 [(set (match_dup 0)
9ebbca7d 12451 (plus:SI (eq:SI (match_dup 1) (match_dup 2)) (match_dup 3)))
0387639b 12452 (set (match_dup 4)
9ebbca7d
GK
12453 (compare:CC (match_dup 0)
12454 (const_int 0)))]
12455 "")
12456
d0515b39
DE
12457(define_insn "*neg_eq0<mode>"
12458 [(set (match_operand:P 0 "gpc_reg_operand" "=r")
12459 (neg:P (eq:P (match_operand:P 1 "gpc_reg_operand" "r")
12460 (const_int 0))))]
59d6560b 12461 ""
d0515b39
DE
12462 "{ai|addic} %0,%1,-1\;{sfe|subfe} %0,%0,%0"
12463 [(set_attr "type" "two")
12464 (set_attr "length" "8")])
12465
12466(define_insn_and_split "*neg_eq<mode>"
12467 [(set (match_operand:P 0 "gpc_reg_operand" "=r")
12468 (neg:P (eq:P (match_operand:P 1 "gpc_reg_operand" "%r")
12469 (match_operand:P 2 "scc_eq_operand" "<scc_eq_op2>"))))]
59d6560b 12470 ""
d0515b39 12471 "#"
59d6560b 12472 ""
d0515b39
DE
12473 [(set (match_dup 0) (neg:P (eq:P (match_dup 3) (const_int 0))))]
12474 {
12475 if (GET_CODE (operands[2]) != CONST_INT || INTVAL (operands[2]) != 0)
12476 {
12477 /* Use output operand as intermediate. */
12478 operands[3] = operands[0];
12479
12480 if (logical_operand (operands[2], <MODE>mode))
12481 emit_insn (gen_rtx_SET (VOIDmode, operands[3],
12482 gen_rtx_XOR (<MODE>mode,
12483 operands[1], operands[2])));
12484 else
12485 emit_insn (gen_rtx_SET (VOIDmode, operands[3],
12486 gen_rtx_PLUS (<MODE>mode, operands[1],
12487 negate_rtx (<MODE>mode,
12488 operands[2]))));
12489 }
12490 else
12491 operands[3] = operands[1];
12492 })
1fd4e8c1 12493
ea9be077
MM
12494;; Simplify (ne X (const_int 0)) on the PowerPC. No need to on the Power,
12495;; since it nabs/sr is just as fast.
ce45ef46 12496(define_insn "*ne0si"
b4e95693 12497 [(set (match_operand:SI 0 "gpc_reg_operand" "=&r")
ea9be077
MM
12498 (lshiftrt:SI (neg:SI (abs:SI (match_operand:SI 1 "gpc_reg_operand" "r")))
12499 (const_int 31)))
12500 (clobber (match_scratch:SI 2 "=&r"))]
683bdff7 12501 "! TARGET_POWER && TARGET_32BIT && !TARGET_ISEL"
ea9be077 12502 "{ai|addic} %2,%1,-1\;{sfe|subfe} %0,%2,%1"
943c15ed
DE
12503 [(set_attr "type" "two")
12504 (set_attr "length" "8")])
ea9be077 12505
ce45ef46 12506(define_insn "*ne0di"
a260abc9
DE
12507 [(set (match_operand:DI 0 "gpc_reg_operand" "=r")
12508 (lshiftrt:DI (neg:DI (abs:DI (match_operand:DI 1 "gpc_reg_operand" "r")))
12509 (const_int 63)))
12510 (clobber (match_scratch:DI 2 "=&r"))]
683bdff7 12511 "TARGET_64BIT"
a260abc9 12512 "addic %2,%1,-1\;subfe %0,%2,%1"
943c15ed
DE
12513 [(set_attr "type" "two")
12514 (set_attr "length" "8")])
a260abc9 12515
1fd4e8c1 12516;; This is what (plus (ne X (const_int 0)) Y) looks like.
297abd0d 12517(define_insn "*plus_ne0si"
cd2b37d9 12518 [(set (match_operand:SI 0 "gpc_reg_operand" "=r")
1fd4e8c1 12519 (plus:SI (lshiftrt:SI
cd2b37d9 12520 (neg:SI (abs:SI (match_operand:SI 1 "gpc_reg_operand" "r")))
1fd4e8c1 12521 (const_int 31))
cd2b37d9 12522 (match_operand:SI 2 "gpc_reg_operand" "r")))
1fd4e8c1 12523 (clobber (match_scratch:SI 3 "=&r"))]
683bdff7 12524 "TARGET_32BIT"
ca7f5001 12525 "{ai|addic} %3,%1,-1\;{aze|addze} %0,%2"
943c15ed
DE
12526 [(set_attr "type" "two")
12527 (set_attr "length" "8")])
1fd4e8c1 12528
297abd0d 12529(define_insn "*plus_ne0di"
a260abc9
DE
12530 [(set (match_operand:DI 0 "gpc_reg_operand" "=r")
12531 (plus:DI (lshiftrt:DI
12532 (neg:DI (abs:DI (match_operand:DI 1 "gpc_reg_operand" "r")))
12533 (const_int 63))
12534 (match_operand:DI 2 "gpc_reg_operand" "r")))
12535 (clobber (match_scratch:DI 3 "=&r"))]
683bdff7 12536 "TARGET_64BIT"
a260abc9 12537 "addic %3,%1,-1\;addze %0,%2"
943c15ed
DE
12538 [(set_attr "type" "two")
12539 (set_attr "length" "8")])
a260abc9 12540
297abd0d 12541(define_insn "*compare_plus_ne0si"
9ebbca7d 12542 [(set (match_operand:CC 0 "cc_reg_operand" "=x,?y")
1fd4e8c1
RK
12543 (compare:CC
12544 (plus:SI (lshiftrt:SI
9ebbca7d 12545 (neg:SI (abs:SI (match_operand:SI 1 "gpc_reg_operand" "r,r")))
1fd4e8c1 12546 (const_int 31))
9ebbca7d 12547 (match_operand:SI 2 "gpc_reg_operand" "r,r"))
1fd4e8c1 12548 (const_int 0)))
889b90a1
GK
12549 (clobber (match_scratch:SI 3 "=&r,&r"))
12550 (clobber (match_scratch:SI 4 "=X,&r"))]
683bdff7 12551 "TARGET_32BIT"
9ebbca7d
GK
12552 "@
12553 {ai|addic} %3,%1,-1\;{aze.|addze.} %3,%2
12554 #"
b19003d8 12555 [(set_attr "type" "compare")
9ebbca7d
GK
12556 (set_attr "length" "8,12")])
12557
12558(define_split
12559 [(set (match_operand:CC 0 "cc_reg_not_cr0_operand" "")
12560 (compare:CC
12561 (plus:SI (lshiftrt:SI
12562 (neg:SI (abs:SI (match_operand:SI 1 "gpc_reg_operand" "")))
12563 (const_int 31))
12564 (match_operand:SI 2 "gpc_reg_operand" ""))
12565 (const_int 0)))
889b90a1
GK
12566 (clobber (match_scratch:SI 3 ""))
12567 (clobber (match_scratch:SI 4 ""))]
683bdff7 12568 "TARGET_32BIT && reload_completed"
889b90a1 12569 [(parallel [(set (match_dup 3)
ce71f754
AM
12570 (plus:SI (lshiftrt:SI (neg:SI (abs:SI (match_dup 1)))
12571 (const_int 31))
12572 (match_dup 2)))
889b90a1 12573 (clobber (match_dup 4))])
9ebbca7d
GK
12574 (set (match_dup 0)
12575 (compare:CC (match_dup 3)
12576 (const_int 0)))]
12577 "")
1fd4e8c1 12578
297abd0d 12579(define_insn "*compare_plus_ne0di"
9ebbca7d 12580 [(set (match_operand:CC 0 "cc_reg_operand" "=x,?y")
a260abc9
DE
12581 (compare:CC
12582 (plus:DI (lshiftrt:DI
9ebbca7d 12583 (neg:DI (abs:DI (match_operand:DI 1 "gpc_reg_operand" "r,r")))
a260abc9 12584 (const_int 63))
9ebbca7d 12585 (match_operand:DI 2 "gpc_reg_operand" "r,r"))
a260abc9 12586 (const_int 0)))
9ebbca7d 12587 (clobber (match_scratch:DI 3 "=&r,&r"))]
683bdff7 12588 "TARGET_64BIT"
9ebbca7d
GK
12589 "@
12590 addic %3,%1,-1\;addze. %3,%2
12591 #"
a260abc9 12592 [(set_attr "type" "compare")
9ebbca7d
GK
12593 (set_attr "length" "8,12")])
12594
12595(define_split
12596 [(set (match_operand:CC 0 "cc_reg_not_cr0_operand" "")
12597 (compare:CC
12598 (plus:DI (lshiftrt:DI
12599 (neg:DI (abs:DI (match_operand:DI 1 "gpc_reg_operand" "")))
12600 (const_int 63))
12601 (match_operand:DI 2 "gpc_reg_operand" ""))
12602 (const_int 0)))
12603 (clobber (match_scratch:DI 3 ""))]
683bdff7 12604 "TARGET_64BIT && reload_completed"
9ebbca7d
GK
12605 [(set (match_dup 3)
12606 (plus:DI (lshiftrt:DI (neg:DI (abs:DI (match_dup 1)))
12607 (const_int 63))
12608 (match_dup 2)))
12609 (set (match_dup 0)
12610 (compare:CC (match_dup 3)
12611 (const_int 0)))]
12612 "")
a260abc9 12613
297abd0d 12614(define_insn "*plus_ne0si_compare"
9ebbca7d 12615 [(set (match_operand:CC 4 "cc_reg_operand" "=x,?y")
1fd4e8c1
RK
12616 (compare:CC
12617 (plus:SI (lshiftrt:SI
9ebbca7d 12618 (neg:SI (abs:SI (match_operand:SI 1 "gpc_reg_operand" "r,r")))
1fd4e8c1 12619 (const_int 31))
9ebbca7d 12620 (match_operand:SI 2 "gpc_reg_operand" "r,r"))
1fd4e8c1 12621 (const_int 0)))
9ebbca7d 12622 (set (match_operand:SI 0 "gpc_reg_operand" "=r,r")
1fd4e8c1
RK
12623 (plus:SI (lshiftrt:SI (neg:SI (abs:SI (match_dup 1))) (const_int 31))
12624 (match_dup 2)))
9ebbca7d 12625 (clobber (match_scratch:SI 3 "=&r,&r"))]
683bdff7 12626 "TARGET_32BIT"
9ebbca7d
GK
12627 "@
12628 {ai|addic} %3,%1,-1\;{aze.|addze.} %0,%2
12629 #"
b19003d8 12630 [(set_attr "type" "compare")
9ebbca7d
GK
12631 (set_attr "length" "8,12")])
12632
12633(define_split
12634 [(set (match_operand:CC 4 "cc_reg_not_cr0_operand" "")
12635 (compare:CC
12636 (plus:SI (lshiftrt:SI
12637 (neg:SI (abs:SI (match_operand:SI 1 "gpc_reg_operand" "")))
12638 (const_int 31))
12639 (match_operand:SI 2 "gpc_reg_operand" ""))
12640 (const_int 0)))
12641 (set (match_operand:SI 0 "gpc_reg_operand" "")
12642 (plus:SI (lshiftrt:SI (neg:SI (abs:SI (match_dup 1))) (const_int 31))
12643 (match_dup 2)))
12644 (clobber (match_scratch:SI 3 ""))]
683bdff7 12645 "TARGET_32BIT && reload_completed"
9ebbca7d
GK
12646 [(parallel [(set (match_dup 0)
12647 (plus:SI (lshiftrt:SI (neg:SI (abs:SI (match_dup 1))) (const_int 31))
12648 (match_dup 2)))
12649 (clobber (match_dup 3))])
12650 (set (match_dup 4)
12651 (compare:CC (match_dup 0)
12652 (const_int 0)))]
12653 "")
1fd4e8c1 12654
297abd0d 12655(define_insn "*plus_ne0di_compare"
9ebbca7d 12656 [(set (match_operand:CC 4 "cc_reg_operand" "=x,?y")
a260abc9
DE
12657 (compare:CC
12658 (plus:DI (lshiftrt:DI
9ebbca7d 12659 (neg:DI (abs:DI (match_operand:DI 1 "gpc_reg_operand" "r,r")))
a260abc9 12660 (const_int 63))
9ebbca7d 12661 (match_operand:DI 2 "gpc_reg_operand" "r,r"))
a260abc9 12662 (const_int 0)))
9ebbca7d 12663 (set (match_operand:DI 0 "gpc_reg_operand" "=r,r")
a260abc9
DE
12664 (plus:DI (lshiftrt:DI (neg:DI (abs:DI (match_dup 1))) (const_int 63))
12665 (match_dup 2)))
9ebbca7d 12666 (clobber (match_scratch:DI 3 "=&r,&r"))]
683bdff7 12667 "TARGET_64BIT"
9ebbca7d
GK
12668 "@
12669 addic %3,%1,-1\;addze. %0,%2
12670 #"
a260abc9 12671 [(set_attr "type" "compare")
9ebbca7d
GK
12672 (set_attr "length" "8,12")])
12673
12674(define_split
12675 [(set (match_operand:CC 4 "cc_reg_not_cr0_operand" "")
12676 (compare:CC
12677 (plus:DI (lshiftrt:DI
12678 (neg:DI (abs:DI (match_operand:DI 1 "gpc_reg_operand" "")))
12679 (const_int 63))
12680 (match_operand:DI 2 "gpc_reg_operand" ""))
12681 (const_int 0)))
12682 (set (match_operand:DI 0 "gpc_reg_operand" "")
12683 (plus:DI (lshiftrt:DI (neg:DI (abs:DI (match_dup 1))) (const_int 63))
12684 (match_dup 2)))
12685 (clobber (match_scratch:DI 3 ""))]
683bdff7 12686 "TARGET_64BIT && reload_completed"
9ebbca7d
GK
12687 [(parallel [(set (match_dup 0)
12688 (plus:DI (lshiftrt:DI (neg:DI (abs:DI (match_dup 1))) (const_int 63))
12689 (match_dup 2)))
12690 (clobber (match_dup 3))])
12691 (set (match_dup 4)
12692 (compare:CC (match_dup 0)
12693 (const_int 0)))]
12694 "")
a260abc9 12695
1fd4e8c1 12696(define_insn ""
cd2b37d9
RK
12697 [(set (match_operand:SI 0 "gpc_reg_operand" "=r,r")
12698 (le:SI (match_operand:SI 1 "gpc_reg_operand" "r,r")
1fd4e8c1
RK
12699 (match_operand:SI 2 "reg_or_short_operand" "r,O")))
12700 (clobber (match_scratch:SI 3 "=r,X"))]
ca7f5001 12701 "TARGET_POWER"
1fd4e8c1 12702 "@
ca7f5001 12703 doz %3,%2,%1\;{sfi|subfic} %0,%3,0\;{ae|adde} %0,%0,%3
7f340546 12704 {ai|addic} %0,%1,-1\;{aze|addze} %0,%0\;{sri|srwi} %0,%0,31"
b19003d8 12705 [(set_attr "length" "12")])
1fd4e8c1
RK
12706
12707(define_insn ""
9ebbca7d 12708 [(set (match_operand:CC 4 "cc_reg_operand" "=x,x,?y,?y")
1fd4e8c1 12709 (compare:CC
9ebbca7d
GK
12710 (le:SI (match_operand:SI 1 "gpc_reg_operand" "r,r,r,r")
12711 (match_operand:SI 2 "reg_or_short_operand" "r,O,r,O"))
1fd4e8c1 12712 (const_int 0)))
9ebbca7d 12713 (set (match_operand:SI 0 "gpc_reg_operand" "=r,r,r,r")
1fd4e8c1 12714 (le:SI (match_dup 1) (match_dup 2)))
9ebbca7d 12715 (clobber (match_scratch:SI 3 "=r,X,r,X"))]
ca7f5001 12716 "TARGET_POWER"
1fd4e8c1 12717 "@
ca7f5001 12718 doz %3,%2,%1\;{sfi|subfic} %0,%3,0\;{ae.|adde.} %0,%0,%3
9ebbca7d
GK
12719 {ai|addic} %0,%1,-1\;{aze|addze} %0,%0\;{sri.|srwi.} %0,%0,31
12720 #
12721 #"
12722 [(set_attr "type" "compare,delayed_compare,compare,delayed_compare")
12723 (set_attr "length" "12,12,16,16")])
12724
12725(define_split
12726 [(set (match_operand:CC 4 "cc_reg_not_cr0_operand" "")
12727 (compare:CC
12728 (le:SI (match_operand:SI 1 "gpc_reg_operand" "")
12729 (match_operand:SI 2 "reg_or_short_operand" ""))
12730 (const_int 0)))
12731 (set (match_operand:SI 0 "gpc_reg_operand" "")
12732 (le:SI (match_dup 1) (match_dup 2)))
12733 (clobber (match_scratch:SI 3 ""))]
12734 "TARGET_POWER && reload_completed"
12735 [(parallel [(set (match_dup 0)
12736 (le:SI (match_dup 1) (match_dup 2)))
12737 (clobber (match_dup 3))])
12738 (set (match_dup 4)
12739 (compare:CC (match_dup 0)
12740 (const_int 0)))]
12741 "")
1fd4e8c1
RK
12742
12743(define_insn ""
097657c3 12744 [(set (match_operand:SI 0 "gpc_reg_operand" "=&r,&r")
cd2b37d9 12745 (plus:SI (le:SI (match_operand:SI 1 "gpc_reg_operand" "r,r")
1fd4e8c1 12746 (match_operand:SI 2 "reg_or_short_operand" "r,O"))
097657c3 12747 (match_operand:SI 3 "gpc_reg_operand" "r,r")))]
ca7f5001 12748 "TARGET_POWER"
1fd4e8c1 12749 "@
097657c3
AM
12750 doz %0,%2,%1\;{sfi|subfic} %0,%0,0\;{aze|addze} %0,%3
12751 {srai|srawi} %0,%1,31\;{sf|subfc} %0,%1,%0\;{aze|addze} %0,%3"
b19003d8 12752 [(set_attr "length" "12")])
1fd4e8c1
RK
12753
12754(define_insn ""
9ebbca7d 12755 [(set (match_operand:CC 0 "cc_reg_operand" "=x,x,?y,?y")
1fd4e8c1 12756 (compare:CC
9ebbca7d
GK
12757 (plus:SI (le:SI (match_operand:SI 1 "gpc_reg_operand" "r,r,r,r")
12758 (match_operand:SI 2 "reg_or_short_operand" "r,O,r,O"))
12759 (match_operand:SI 3 "gpc_reg_operand" "r,r,r,r"))
1fd4e8c1 12760 (const_int 0)))
9ebbca7d 12761 (clobber (match_scratch:SI 4 "=&r,&r,&r,&r"))]
ca7f5001 12762 "TARGET_POWER"
1fd4e8c1 12763 "@
ca7f5001 12764 doz %4,%2,%1\;{sfi|subfic} %4,%4,0\;{aze.|addze.} %4,%3
9ebbca7d
GK
12765 {srai|srawi} %4,%1,31\;{sf|subfc} %4,%1,%4\;{aze.|addze.} %4,%3
12766 #
12767 #"
b19003d8 12768 [(set_attr "type" "compare")
9ebbca7d
GK
12769 (set_attr "length" "12,12,16,16")])
12770
12771(define_split
12772 [(set (match_operand:CC 0 "cc_reg_not_cr0_operand" "")
12773 (compare:CC
12774 (plus:SI (le:SI (match_operand:SI 1 "gpc_reg_operand" "")
12775 (match_operand:SI 2 "reg_or_short_operand" ""))
12776 (match_operand:SI 3 "gpc_reg_operand" ""))
12777 (const_int 0)))
12778 (clobber (match_scratch:SI 4 ""))]
12779 "TARGET_POWER && reload_completed"
12780 [(set (match_dup 4)
12781 (plus:SI (le:SI (match_dup 1) (match_dup 2))
097657c3 12782 (match_dup 3)))
9ebbca7d
GK
12783 (set (match_dup 0)
12784 (compare:CC (match_dup 4)
12785 (const_int 0)))]
12786 "")
1fd4e8c1
RK
12787
12788(define_insn ""
097657c3 12789 [(set (match_operand:CC 4 "cc_reg_operand" "=x,x,?y,?y")
1fd4e8c1 12790 (compare:CC
9ebbca7d
GK
12791 (plus:SI (le:SI (match_operand:SI 1 "gpc_reg_operand" "r,r,r,r")
12792 (match_operand:SI 2 "reg_or_short_operand" "r,O,r,O"))
12793 (match_operand:SI 3 "gpc_reg_operand" "r,r,r,r"))
1fd4e8c1 12794 (const_int 0)))
097657c3
AM
12795 (set (match_operand:SI 0 "gpc_reg_operand" "=&r,&r,&r,&r")
12796 (plus:SI (le:SI (match_dup 1) (match_dup 2)) (match_dup 3)))]
ca7f5001 12797 "TARGET_POWER"
1fd4e8c1 12798 "@
097657c3
AM
12799 doz %0,%2,%1\;{sfi|subfic} %0,%0,0\;{aze.|addze.} %0,%3
12800 {srai|srawi} %0,%1,31\;{sf|subfc} %0,%1,%0\;{aze.|addze.} %0,%3
9ebbca7d
GK
12801 #
12802 #"
b19003d8 12803 [(set_attr "type" "compare")
9ebbca7d
GK
12804 (set_attr "length" "12,12,16,16")])
12805
12806(define_split
097657c3 12807 [(set (match_operand:CC 4 "cc_reg_not_cr0_operand" "")
9ebbca7d
GK
12808 (compare:CC
12809 (plus:SI (le:SI (match_operand:SI 1 "gpc_reg_operand" "")
12810 (match_operand:SI 2 "reg_or_short_operand" ""))
12811 (match_operand:SI 3 "gpc_reg_operand" ""))
12812 (const_int 0)))
12813 (set (match_operand:SI 0 "gpc_reg_operand" "")
097657c3 12814 (plus:SI (le:SI (match_dup 1) (match_dup 2)) (match_dup 3)))]
9ebbca7d 12815 "TARGET_POWER && reload_completed"
097657c3 12816 [(set (match_dup 0)
9ebbca7d 12817 (plus:SI (le:SI (match_dup 1) (match_dup 2)) (match_dup 3)))
097657c3 12818 (set (match_dup 4)
9ebbca7d
GK
12819 (compare:CC (match_dup 0)
12820 (const_int 0)))]
12821 "")
1fd4e8c1
RK
12822
12823(define_insn ""
cd2b37d9
RK
12824 [(set (match_operand:SI 0 "gpc_reg_operand" "=r,r")
12825 (neg:SI (le:SI (match_operand:SI 1 "gpc_reg_operand" "r,r")
1fd4e8c1 12826 (match_operand:SI 2 "reg_or_short_operand" "r,O"))))]
ca7f5001 12827 "TARGET_POWER"
1fd4e8c1 12828 "@
ca7f5001
RK
12829 doz %0,%2,%1\;{ai|addic} %0,%0,-1\;{sfe|subfe} %0,%0,%0
12830 {ai|addic} %0,%1,-1\;{aze|addze} %0,%0\;{srai|srawi} %0,%0,31"
b19003d8 12831 [(set_attr "length" "12")])
1fd4e8c1 12832
a2dba291
DE
12833(define_insn "*leu<mode>"
12834 [(set (match_operand:P 0 "gpc_reg_operand" "=r")
12835 (leu:P (match_operand:P 1 "gpc_reg_operand" "r")
12836 (match_operand:P 2 "reg_or_short_operand" "rI")))]
12837 ""
ca7f5001 12838 "{sf%I2|subf%I2c} %0,%1,%2\;{cal %0,0(0)|li %0,0}\;{ae|adde} %0,%0,%0"
943c15ed
DE
12839 [(set_attr "type" "three")
12840 (set_attr "length" "12")])
1fd4e8c1 12841
a2dba291 12842(define_insn "*leu<mode>_compare"
9ebbca7d 12843 [(set (match_operand:CC 3 "cc_reg_operand" "=x,?y")
1fd4e8c1 12844 (compare:CC
a2dba291
DE
12845 (leu:P (match_operand:P 1 "gpc_reg_operand" "r,r")
12846 (match_operand:P 2 "reg_or_short_operand" "rI,rI"))
1fd4e8c1 12847 (const_int 0)))
a2dba291
DE
12848 (set (match_operand:P 0 "gpc_reg_operand" "=r,r")
12849 (leu:P (match_dup 1) (match_dup 2)))]
12850 ""
9ebbca7d
GK
12851 "@
12852 {sf%I2|subf%I2c} %0,%1,%2\;{cal %0,0(0)|li %0,0}\;{ae.|adde.} %0,%0,%0
12853 #"
b19003d8 12854 [(set_attr "type" "compare")
9ebbca7d
GK
12855 (set_attr "length" "12,16")])
12856
12857(define_split
12858 [(set (match_operand:CC 3 "cc_reg_not_cr0_operand" "")
12859 (compare:CC
a2dba291
DE
12860 (leu:P (match_operand:P 1 "gpc_reg_operand" "")
12861 (match_operand:P 2 "reg_or_short_operand" ""))
9ebbca7d 12862 (const_int 0)))
a2dba291
DE
12863 (set (match_operand:P 0 "gpc_reg_operand" "")
12864 (leu:P (match_dup 1) (match_dup 2)))]
12865 "reload_completed"
9ebbca7d 12866 [(set (match_dup 0)
a2dba291 12867 (leu:P (match_dup 1) (match_dup 2)))
9ebbca7d
GK
12868 (set (match_dup 3)
12869 (compare:CC (match_dup 0)
12870 (const_int 0)))]
12871 "")
1fd4e8c1 12872
a2dba291
DE
12873(define_insn "*plus_leu<mode>"
12874 [(set (match_operand:P 0 "gpc_reg_operand" "=&r")
12875 (plus:P (leu:P (match_operand:P 1 "gpc_reg_operand" "r")
12876 (match_operand:P 2 "reg_or_short_operand" "rI"))
12877 (match_operand:P 3 "gpc_reg_operand" "r")))]
12878 ""
80103f96 12879 "{sf%I2|subf%I2c} %0,%1,%2\;{aze|addze} %0,%3"
943c15ed
DE
12880 [(set_attr "type" "two")
12881 (set_attr "length" "8")])
1fd4e8c1
RK
12882
12883(define_insn ""
9ebbca7d 12884 [(set (match_operand:CC 0 "cc_reg_operand" "=x,?y")
1fd4e8c1 12885 (compare:CC
9ebbca7d
GK
12886 (plus:SI (leu:SI (match_operand:SI 1 "gpc_reg_operand" "r,r")
12887 (match_operand:SI 2 "reg_or_short_operand" "rI,rI"))
12888 (match_operand:SI 3 "gpc_reg_operand" "r,r"))
1fd4e8c1 12889 (const_int 0)))
9ebbca7d 12890 (clobber (match_scratch:SI 4 "=&r,&r"))]
683bdff7 12891 "TARGET_32BIT"
9ebbca7d
GK
12892 "@
12893 {sf%I2|subf%I2c} %4,%1,%2\;{aze.|addze.} %4,%3
12894 #"
b19003d8 12895 [(set_attr "type" "compare")
9ebbca7d
GK
12896 (set_attr "length" "8,12")])
12897
12898(define_split
12899 [(set (match_operand:CC 0 "cc_reg_not_cr0_operand" "")
12900 (compare:CC
12901 (plus:SI (leu:SI (match_operand:SI 1 "gpc_reg_operand" "")
12902 (match_operand:SI 2 "reg_or_short_operand" ""))
12903 (match_operand:SI 3 "gpc_reg_operand" ""))
12904 (const_int 0)))
12905 (clobber (match_scratch:SI 4 ""))]
683bdff7 12906 "TARGET_32BIT && reload_completed"
9ebbca7d
GK
12907 [(set (match_dup 4)
12908 (plus:SI (leu:SI (match_dup 1) (match_dup 2))
12909 (match_dup 3)))
12910 (set (match_dup 0)
12911 (compare:CC (match_dup 4)
12912 (const_int 0)))]
12913 "")
1fd4e8c1
RK
12914
12915(define_insn ""
097657c3 12916 [(set (match_operand:CC 4 "cc_reg_operand" "=x,?y")
1fd4e8c1 12917 (compare:CC
9ebbca7d
GK
12918 (plus:SI (leu:SI (match_operand:SI 1 "gpc_reg_operand" "r,r")
12919 (match_operand:SI 2 "reg_or_short_operand" "rI,rI"))
12920 (match_operand:SI 3 "gpc_reg_operand" "r,r"))
1fd4e8c1 12921 (const_int 0)))
097657c3
AM
12922 (set (match_operand:SI 0 "gpc_reg_operand" "=&r,&r")
12923 (plus:SI (leu:SI (match_dup 1) (match_dup 2)) (match_dup 3)))]
683bdff7 12924 "TARGET_32BIT"
9ebbca7d 12925 "@
097657c3 12926 {sf%I2|subf%I2c} %0,%1,%2\;{aze.|addze.} %0,%3
9ebbca7d 12927 #"
b19003d8 12928 [(set_attr "type" "compare")
9ebbca7d
GK
12929 (set_attr "length" "8,12")])
12930
12931(define_split
097657c3 12932 [(set (match_operand:CC 4 "cc_reg_not_cr0_operand" "")
9ebbca7d
GK
12933 (compare:CC
12934 (plus:SI (leu:SI (match_operand:SI 1 "gpc_reg_operand" "")
12935 (match_operand:SI 2 "reg_or_short_operand" ""))
12936 (match_operand:SI 3 "gpc_reg_operand" ""))
12937 (const_int 0)))
12938 (set (match_operand:SI 0 "gpc_reg_operand" "")
097657c3 12939 (plus:SI (leu:SI (match_dup 1) (match_dup 2)) (match_dup 3)))]
683bdff7 12940 "TARGET_32BIT && reload_completed"
097657c3 12941 [(set (match_dup 0)
9ebbca7d 12942 (plus:SI (leu:SI (match_dup 1) (match_dup 2)) (match_dup 3)))
097657c3 12943 (set (match_dup 4)
9ebbca7d
GK
12944 (compare:CC (match_dup 0)
12945 (const_int 0)))]
12946 "")
1fd4e8c1 12947
a2dba291
DE
12948(define_insn "*neg_leu<mode>"
12949 [(set (match_operand:P 0 "gpc_reg_operand" "=r")
12950 (neg:P (leu:P (match_operand:P 1 "gpc_reg_operand" "r")
12951 (match_operand:P 2 "reg_or_short_operand" "rI"))))]
12952 ""
ca7f5001 12953 "{sf%I2|subf%I2c} %0,%1,%2\;{sfe|subfe} %0,%0,%0\;nand %0,%0,%0"
943c15ed
DE
12954 [(set_attr "type" "three")
12955 (set_attr "length" "12")])
1fd4e8c1 12956
a2dba291
DE
12957(define_insn "*and_neg_leu<mode>"
12958 [(set (match_operand:P 0 "gpc_reg_operand" "=&r")
12959 (and:P (neg:P
12960 (leu:P (match_operand:P 1 "gpc_reg_operand" "r")
12961 (match_operand:P 2 "reg_or_short_operand" "rI")))
12962 (match_operand:P 3 "gpc_reg_operand" "r")))]
12963 ""
097657c3 12964 "{sf%I2|subf%I2c} %0,%1,%2\;{sfe|subfe} %0,%0,%0\;andc %0,%3,%0"
943c15ed
DE
12965 [(set_attr "type" "three")
12966 (set_attr "length" "12")])
1fd4e8c1
RK
12967
12968(define_insn ""
9ebbca7d 12969 [(set (match_operand:CC 0 "cc_reg_operand" "=x,?y")
1fd4e8c1
RK
12970 (compare:CC
12971 (and:SI (neg:SI
9ebbca7d
GK
12972 (leu:SI (match_operand:SI 1 "gpc_reg_operand" "r,r")
12973 (match_operand:SI 2 "reg_or_short_operand" "rI,rI")))
12974 (match_operand:SI 3 "gpc_reg_operand" "r,r"))
1fd4e8c1 12975 (const_int 0)))
9ebbca7d 12976 (clobber (match_scratch:SI 4 "=&r,&r"))]
683bdff7 12977 "TARGET_32BIT"
9ebbca7d
GK
12978 "@
12979 {sf%I2|subf%I2c} %4,%1,%2\;{sfe|subfe} %4,%4,%4\;andc. %4,%3,%4
12980 #"
12981 [(set_attr "type" "compare")
12982 (set_attr "length" "12,16")])
12983
12984(define_split
12985 [(set (match_operand:CC 0 "cc_reg_not_cr0_operand" "")
12986 (compare:CC
12987 (and:SI (neg:SI
12988 (leu:SI (match_operand:SI 1 "gpc_reg_operand" "")
12989 (match_operand:SI 2 "reg_or_short_operand" "")))
12990 (match_operand:SI 3 "gpc_reg_operand" ""))
12991 (const_int 0)))
12992 (clobber (match_scratch:SI 4 ""))]
683bdff7 12993 "TARGET_32BIT && reload_completed"
9ebbca7d 12994 [(set (match_dup 4)
097657c3
AM
12995 (and:SI (neg:SI (leu:SI (match_dup 1) (match_dup 2)))
12996 (match_dup 3)))
9ebbca7d
GK
12997 (set (match_dup 0)
12998 (compare:CC (match_dup 4)
12999 (const_int 0)))]
13000 "")
1fd4e8c1
RK
13001
13002(define_insn ""
097657c3 13003 [(set (match_operand:CC 4 "cc_reg_operand" "=x,?y")
1fd4e8c1
RK
13004 (compare:CC
13005 (and:SI (neg:SI
9ebbca7d
GK
13006 (leu:SI (match_operand:SI 1 "gpc_reg_operand" "r,r")
13007 (match_operand:SI 2 "reg_or_short_operand" "rI,rI")))
13008 (match_operand:SI 3 "gpc_reg_operand" "r,r"))
1fd4e8c1 13009 (const_int 0)))
097657c3
AM
13010 (set (match_operand:SI 0 "gpc_reg_operand" "=&r,&r")
13011 (and:SI (neg:SI (leu:SI (match_dup 1) (match_dup 2))) (match_dup 3)))]
683bdff7 13012 "TARGET_32BIT"
9ebbca7d 13013 "@
097657c3 13014 {sf%I2|subf%I2c} %0,%1,%2\;{sfe|subfe} %0,%0,%0\;andc. %0,%3,%0
9ebbca7d 13015 #"
b19003d8 13016 [(set_attr "type" "compare")
9ebbca7d
GK
13017 (set_attr "length" "12,16")])
13018
13019(define_split
097657c3 13020 [(set (match_operand:CC 4 "cc_reg_not_cr0_operand" "")
9ebbca7d
GK
13021 (compare:CC
13022 (and:SI (neg:SI
13023 (leu:SI (match_operand:SI 1 "gpc_reg_operand" "")
13024 (match_operand:SI 2 "reg_or_short_operand" "")))
13025 (match_operand:SI 3 "gpc_reg_operand" ""))
13026 (const_int 0)))
13027 (set (match_operand:SI 0 "gpc_reg_operand" "")
097657c3 13028 (and:SI (neg:SI (leu:SI (match_dup 1) (match_dup 2))) (match_dup 3)))]
683bdff7 13029 "TARGET_32BIT && reload_completed"
097657c3
AM
13030 [(set (match_dup 0)
13031 (and:SI (neg:SI (leu:SI (match_dup 1) (match_dup 2)))
13032 (match_dup 3)))
13033 (set (match_dup 4)
9ebbca7d
GK
13034 (compare:CC (match_dup 0)
13035 (const_int 0)))]
13036 "")
1fd4e8c1
RK
13037
13038(define_insn ""
cd2b37d9
RK
13039 [(set (match_operand:SI 0 "gpc_reg_operand" "=r")
13040 (lt:SI (match_operand:SI 1 "gpc_reg_operand" "r")
1fd4e8c1 13041 (match_operand:SI 2 "reg_or_short_operand" "rI")))]
ca7f5001 13042 "TARGET_POWER"
7f340546 13043 "doz%I2 %0,%1,%2\;nabs %0,%0\;{sri|srwi} %0,%0,31"
b19003d8 13044 [(set_attr "length" "12")])
1fd4e8c1
RK
13045
13046(define_insn ""
9ebbca7d 13047 [(set (match_operand:CC 3 "cc_reg_operand" "=x,?y")
1fd4e8c1 13048 (compare:CC
9ebbca7d
GK
13049 (lt:SI (match_operand:SI 1 "gpc_reg_operand" "r,r")
13050 (match_operand:SI 2 "reg_or_short_operand" "rI,rI"))
1fd4e8c1 13051 (const_int 0)))
9ebbca7d 13052 (set (match_operand:SI 0 "gpc_reg_operand" "=r,r")
1fd4e8c1 13053 (lt:SI (match_dup 1) (match_dup 2)))]
ca7f5001 13054 "TARGET_POWER"
9ebbca7d
GK
13055 "@
13056 doz%I2 %0,%1,%2\;nabs %0,%0\;{sri.|srwi.} %0,%0,31
13057 #"
29ae5b89 13058 [(set_attr "type" "delayed_compare")
9ebbca7d
GK
13059 (set_attr "length" "12,16")])
13060
13061(define_split
13062 [(set (match_operand:CC 3 "cc_reg_not_cr0_operand" "")
13063 (compare:CC
13064 (lt:SI (match_operand:SI 1 "gpc_reg_operand" "")
13065 (match_operand:SI 2 "reg_or_short_operand" ""))
13066 (const_int 0)))
13067 (set (match_operand:SI 0 "gpc_reg_operand" "")
13068 (lt:SI (match_dup 1) (match_dup 2)))]
13069 "TARGET_POWER && reload_completed"
13070 [(set (match_dup 0)
13071 (lt:SI (match_dup 1) (match_dup 2)))
13072 (set (match_dup 3)
13073 (compare:CC (match_dup 0)
13074 (const_int 0)))]
13075 "")
1fd4e8c1
RK
13076
13077(define_insn ""
097657c3 13078 [(set (match_operand:SI 0 "gpc_reg_operand" "=&r")
cd2b37d9 13079 (plus:SI (lt:SI (match_operand:SI 1 "gpc_reg_operand" "r")
1fd4e8c1 13080 (match_operand:SI 2 "reg_or_short_operand" "rI"))
097657c3 13081 (match_operand:SI 3 "gpc_reg_operand" "r")))]
ca7f5001 13082 "TARGET_POWER"
097657c3 13083 "doz%I2 %0,%1,%2\;{ai|addic} %0,%0,-1\;{aze|addze} %0,%3"
b19003d8 13084 [(set_attr "length" "12")])
1fd4e8c1
RK
13085
13086(define_insn ""
9ebbca7d 13087 [(set (match_operand:CC 0 "cc_reg_operand" "=x,?y")
1fd4e8c1 13088 (compare:CC
9ebbca7d
GK
13089 (plus:SI (lt:SI (match_operand:SI 1 "gpc_reg_operand" "r,r")
13090 (match_operand:SI 2 "reg_or_short_operand" "rI,rI"))
13091 (match_operand:SI 3 "gpc_reg_operand" "r,r"))
1fd4e8c1 13092 (const_int 0)))
9ebbca7d 13093 (clobber (match_scratch:SI 4 "=&r,&r"))]
ca7f5001 13094 "TARGET_POWER"
9ebbca7d
GK
13095 "@
13096 doz%I2 %4,%1,%2\;{ai|addic} %4,%4,-1\;{aze.|addze.} %4,%3
13097 #"
b19003d8 13098 [(set_attr "type" "compare")
9ebbca7d
GK
13099 (set_attr "length" "12,16")])
13100
13101(define_split
13102 [(set (match_operand:CC 0 "cc_reg_not_cr0_operand" "")
13103 (compare:CC
13104 (plus:SI (lt:SI (match_operand:SI 1 "gpc_reg_operand" "")
13105 (match_operand:SI 2 "reg_or_short_operand" ""))
13106 (match_operand:SI 3 "gpc_reg_operand" ""))
13107 (const_int 0)))
13108 (clobber (match_scratch:SI 4 ""))]
13109 "TARGET_POWER && reload_completed"
13110 [(set (match_dup 4)
13111 (plus:SI (lt:SI (match_dup 1) (match_dup 2))
097657c3 13112 (match_dup 3)))
9ebbca7d
GK
13113 (set (match_dup 0)
13114 (compare:CC (match_dup 4)
13115 (const_int 0)))]
13116 "")
1fd4e8c1
RK
13117
13118(define_insn ""
097657c3 13119 [(set (match_operand:CC 4 "cc_reg_operand" "=x,?y")
1fd4e8c1 13120 (compare:CC
9ebbca7d
GK
13121 (plus:SI (lt:SI (match_operand:SI 1 "gpc_reg_operand" "r,r")
13122 (match_operand:SI 2 "reg_or_short_operand" "rI,rI"))
13123 (match_operand:SI 3 "gpc_reg_operand" "r,r"))
1fd4e8c1 13124 (const_int 0)))
097657c3
AM
13125 (set (match_operand:SI 0 "gpc_reg_operand" "=&r,&r")
13126 (plus:SI (lt:SI (match_dup 1) (match_dup 2)) (match_dup 3)))]
ca7f5001 13127 "TARGET_POWER"
9ebbca7d 13128 "@
097657c3 13129 doz%I2 %0,%1,%2\;{ai|addic} %0,%0,-1\;{aze.|addze.} %0,%3
9ebbca7d 13130 #"
b19003d8 13131 [(set_attr "type" "compare")
9ebbca7d
GK
13132 (set_attr "length" "12,16")])
13133
13134(define_split
097657c3 13135 [(set (match_operand:CC 4 "cc_reg_not_cr0_operand" "")
9ebbca7d
GK
13136 (compare:CC
13137 (plus:SI (lt:SI (match_operand:SI 1 "gpc_reg_operand" "")
13138 (match_operand:SI 2 "reg_or_short_operand" ""))
13139 (match_operand:SI 3 "gpc_reg_operand" ""))
13140 (const_int 0)))
13141 (set (match_operand:SI 0 "gpc_reg_operand" "")
097657c3 13142 (plus:SI (lt:SI (match_dup 1) (match_dup 2)) (match_dup 3)))]
9ebbca7d 13143 "TARGET_POWER && reload_completed"
097657c3 13144 [(set (match_dup 0)
9ebbca7d 13145 (plus:SI (lt:SI (match_dup 1) (match_dup 2)) (match_dup 3)))
097657c3 13146 (set (match_dup 4)
9ebbca7d
GK
13147 (compare:CC (match_dup 0)
13148 (const_int 0)))]
13149 "")
1fd4e8c1
RK
13150
13151(define_insn ""
cd2b37d9
RK
13152 [(set (match_operand:SI 0 "gpc_reg_operand" "=r")
13153 (neg:SI (lt:SI (match_operand:SI 1 "gpc_reg_operand" "r")
1fd4e8c1 13154 (match_operand:SI 2 "reg_or_short_operand" "rI"))))]
ca7f5001
RK
13155 "TARGET_POWER"
13156 "doz%I2 %0,%1,%2\;nabs %0,%0\;{srai|srawi} %0,%0,31"
b19003d8 13157 [(set_attr "length" "12")])
1fd4e8c1 13158
ce45ef46
DE
13159(define_insn_and_split "*ltu<mode>"
13160 [(set (match_operand:P 0 "gpc_reg_operand" "=r,r")
13161 (ltu:P (match_operand:P 1 "gpc_reg_operand" "r,r")
13162 (match_operand:P 2 "reg_or_neg_short_operand" "r,P")))]
13163 ""
c0600ecd 13164 "#"
ce45ef46
DE
13165 ""
13166 [(set (match_dup 0) (neg:P (ltu:P (match_dup 1) (match_dup 2))))
13167 (set (match_dup 0) (neg:P (match_dup 0)))]
c0600ecd 13168 "")
1fd4e8c1 13169
1e24ce83 13170(define_insn_and_split "*ltu<mode>_compare"
9ebbca7d 13171 [(set (match_operand:CC 3 "cc_reg_operand" "=x,x,?y,?y")
1fd4e8c1 13172 (compare:CC
a2dba291
DE
13173 (ltu:P (match_operand:P 1 "gpc_reg_operand" "r,r,r,r")
13174 (match_operand:P 2 "reg_or_neg_short_operand" "r,P,r,P"))
1fd4e8c1 13175 (const_int 0)))
a2dba291
DE
13176 (set (match_operand:P 0 "gpc_reg_operand" "=r,r,r,r")
13177 (ltu:P (match_dup 1) (match_dup 2)))]
13178 ""
1e24ce83
DE
13179 "#"
13180 ""
13181 [(set (match_dup 0) (neg:P (ltu:P (match_dup 1) (match_dup 2))))
13182 (parallel [(set (match_dup 3)
13183 (compare:CC (neg:P (match_dup 0)) (const_int 0)))
13184 (set (match_dup 0) (neg:P (match_dup 0)))])]
9ebbca7d 13185 "")
1fd4e8c1 13186
a2dba291
DE
13187(define_insn_and_split "*plus_ltu<mode>"
13188 [(set (match_operand:P 0 "gpc_reg_operand" "=&r,r")
13189 (plus:P (ltu:P (match_operand:P 1 "gpc_reg_operand" "r,r")
13190 (match_operand:P 2 "reg_or_neg_short_operand" "r,P"))
1e24ce83 13191 (match_operand:P 3 "reg_or_short_operand" "rI,rI")))]
a2dba291 13192 ""
c0600ecd 13193 "#"
04fa46cf 13194 "&& !reg_overlap_mentioned_p (operands[0], operands[3])"
a2dba291
DE
13195 [(set (match_dup 0) (neg:P (ltu:P (match_dup 1) (match_dup 2))))
13196 (set (match_dup 0) (minus:P (match_dup 3) (match_dup 0)))]
c0600ecd 13197 "")
1fd4e8c1 13198
1e24ce83 13199(define_insn_and_split "*plus_ltu<mode>_compare"
097657c3 13200 [(set (match_operand:CC 4 "cc_reg_operand" "=x,x,?y,?y")
1fd4e8c1 13201 (compare:CC
1e24ce83
DE
13202 (plus:P (ltu:P (match_operand:P 1 "gpc_reg_operand" "r,r,r,r")
13203 (match_operand:P 2 "reg_or_neg_short_operand" "r,P,r,P"))
13204 (match_operand:P 3 "gpc_reg_operand" "r,r,r,r"))
1fd4e8c1 13205 (const_int 0)))
1e24ce83
DE
13206 (set (match_operand:P 0 "gpc_reg_operand" "=&r,&r,&r,&r")
13207 (plus:P (ltu:P (match_dup 1) (match_dup 2)) (match_dup 3)))]
13208 ""
13209 "#"
13210 "&& !reg_overlap_mentioned_p (operands[0], operands[3])"
13211 [(set (match_dup 0) (neg:P (ltu:P (match_dup 1) (match_dup 2))))
13212 (parallel [(set (match_dup 4)
13213 (compare:CC (minus:P (match_dup 3) (match_dup 0))
13214 (const_int 0)))
13215 (set (match_dup 0) (minus:P (match_dup 3) (match_dup 0)))])]
9ebbca7d 13216 "")
1fd4e8c1 13217
ce45ef46
DE
13218(define_insn "*neg_ltu<mode>"
13219 [(set (match_operand:P 0 "gpc_reg_operand" "=r,r")
13220 (neg:P (ltu:P (match_operand:P 1 "gpc_reg_operand" "r,r")
13221 (match_operand:P 2 "reg_or_neg_short_operand" "r,P"))))]
13222 ""
c0600ecd
DE
13223 "@
13224 {sf|subfc} %0,%2,%1\;{sfe|subfe} %0,%0,%0
13225 {ai|addic} %0,%1,%n2\;{sfe|subfe} %0,%0,%0"
943c15ed 13226 [(set_attr "type" "two")
c0600ecd 13227 (set_attr "length" "8")])
1fd4e8c1
RK
13228
13229(define_insn ""
cd2b37d9
RK
13230 [(set (match_operand:SI 0 "gpc_reg_operand" "=r")
13231 (ge:SI (match_operand:SI 1 "gpc_reg_operand" "r")
1fd4e8c1
RK
13232 (match_operand:SI 2 "reg_or_short_operand" "rI")))
13233 (clobber (match_scratch:SI 3 "=r"))]
ca7f5001
RK
13234 "TARGET_POWER"
13235 "doz%I2 %3,%1,%2\;{sfi|subfic} %0,%3,0\;{ae|adde} %0,%0,%3"
b19003d8 13236 [(set_attr "length" "12")])
1fd4e8c1 13237
9ebbca7d
GK
13238(define_insn ""
13239 [(set (match_operand:CC 4 "cc_reg_operand" "=x,?y")
1fd4e8c1 13240 (compare:CC
9ebbca7d
GK
13241 (ge:SI (match_operand:SI 1 "gpc_reg_operand" "r,r")
13242 (match_operand:SI 2 "reg_or_short_operand" "rI,rI"))
1fd4e8c1 13243 (const_int 0)))
9ebbca7d 13244 (set (match_operand:SI 0 "gpc_reg_operand" "=r,r")
1fd4e8c1 13245 (ge:SI (match_dup 1) (match_dup 2)))
9ebbca7d 13246 (clobber (match_scratch:SI 3 "=r,r"))]
ca7f5001 13247 "TARGET_POWER"
9ebbca7d
GK
13248 "@
13249 doz%I2 %3,%1,%2\;{sfi|subfic} %0,%3,0\;{ae.|adde.} %0,%0,%3
13250 #"
13251 [(set_attr "type" "compare")
13252 (set_attr "length" "12,16")])
13253
13254(define_split
13255 [(set (match_operand:CC 4 "cc_reg_not_cr0_operand" "")
13256 (compare:CC
13257 (ge:SI (match_operand:SI 1 "gpc_reg_operand" "")
13258 (match_operand:SI 2 "reg_or_short_operand" ""))
13259 (const_int 0)))
13260 (set (match_operand:SI 0 "gpc_reg_operand" "")
13261 (ge:SI (match_dup 1) (match_dup 2)))
13262 (clobber (match_scratch:SI 3 ""))]
13263 "TARGET_POWER && reload_completed"
13264 [(parallel [(set (match_dup 0)
097657c3
AM
13265 (ge:SI (match_dup 1) (match_dup 2)))
13266 (clobber (match_dup 3))])
9ebbca7d
GK
13267 (set (match_dup 4)
13268 (compare:CC (match_dup 0)
13269 (const_int 0)))]
13270 "")
13271
1fd4e8c1 13272(define_insn ""
097657c3 13273 [(set (match_operand:SI 0 "gpc_reg_operand" "=&r")
cd2b37d9 13274 (plus:SI (ge:SI (match_operand:SI 1 "gpc_reg_operand" "r")
1fd4e8c1 13275 (match_operand:SI 2 "reg_or_short_operand" "rI"))
097657c3 13276 (match_operand:SI 3 "gpc_reg_operand" "r")))]
ca7f5001 13277 "TARGET_POWER"
097657c3 13278 "doz%I2 %0,%1,%2\;{sfi|subfic} %0,%0,0\;{aze|addze} %0,%3"
b19003d8 13279 [(set_attr "length" "12")])
1fd4e8c1
RK
13280
13281(define_insn ""
9ebbca7d 13282 [(set (match_operand:CC 0 "cc_reg_operand" "=x,?y")
1fd4e8c1 13283 (compare:CC
9ebbca7d
GK
13284 (plus:SI (ge:SI (match_operand:SI 1 "gpc_reg_operand" "r,r")
13285 (match_operand:SI 2 "reg_or_short_operand" "rI,rI"))
13286 (match_operand:SI 3 "gpc_reg_operand" "r,r"))
1fd4e8c1 13287 (const_int 0)))
9ebbca7d 13288 (clobber (match_scratch:SI 4 "=&r,&r"))]
ca7f5001 13289 "TARGET_POWER"
9ebbca7d
GK
13290 "@
13291 doz%I2 %4,%1,%2\;{sfi|subfic} %4,%4,0\;{aze.|addze.} %4,%3
13292 #"
b19003d8 13293 [(set_attr "type" "compare")
9ebbca7d
GK
13294 (set_attr "length" "12,16")])
13295
13296(define_split
13297 [(set (match_operand:CC 0 "cc_reg_not_cr0_operand" "")
13298 (compare:CC
13299 (plus:SI (ge:SI (match_operand:SI 1 "gpc_reg_operand" "")
13300 (match_operand:SI 2 "reg_or_short_operand" ""))
13301 (match_operand:SI 3 "gpc_reg_operand" ""))
13302 (const_int 0)))
13303 (clobber (match_scratch:SI 4 ""))]
13304 "TARGET_POWER && reload_completed"
13305 [(set (match_dup 4)
13306 (plus:SI (ge:SI (match_dup 1) (match_dup 2))
097657c3 13307 (match_dup 3)))
9ebbca7d
GK
13308 (set (match_dup 0)
13309 (compare:CC (match_dup 4)
13310 (const_int 0)))]
13311 "")
1fd4e8c1
RK
13312
13313(define_insn ""
097657c3 13314 [(set (match_operand:CC 4 "cc_reg_operand" "=x,?y")
1fd4e8c1 13315 (compare:CC
9ebbca7d
GK
13316 (plus:SI (ge:SI (match_operand:SI 1 "gpc_reg_operand" "r,r")
13317 (match_operand:SI 2 "reg_or_short_operand" "rI,rI"))
13318 (match_operand:SI 3 "gpc_reg_operand" "r,r"))
1fd4e8c1 13319 (const_int 0)))
097657c3
AM
13320 (set (match_operand:SI 0 "gpc_reg_operand" "=&r,&r")
13321 (plus:SI (ge:SI (match_dup 1) (match_dup 2)) (match_dup 3)))]
ca7f5001 13322 "TARGET_POWER"
9ebbca7d 13323 "@
097657c3 13324 doz%I2 %0,%1,%2\;{sfi|subfic} %0,%0,0\;{aze.|addze.} %0,%3
9ebbca7d 13325 #"
b19003d8 13326 [(set_attr "type" "compare")
9ebbca7d
GK
13327 (set_attr "length" "12,16")])
13328
13329(define_split
097657c3 13330 [(set (match_operand:CC 4 "cc_reg_not_cr0_operand" "")
9ebbca7d
GK
13331 (compare:CC
13332 (plus:SI (ge:SI (match_operand:SI 1 "gpc_reg_operand" "")
13333 (match_operand:SI 2 "reg_or_short_operand" ""))
13334 (match_operand:SI 3 "gpc_reg_operand" ""))
13335 (const_int 0)))
13336 (set (match_operand:SI 0 "gpc_reg_operand" "")
097657c3 13337 (plus:SI (ge:SI (match_dup 1) (match_dup 2)) (match_dup 3)))]
9ebbca7d 13338 "TARGET_POWER && reload_completed"
097657c3 13339 [(set (match_dup 0)
9ebbca7d 13340 (plus:SI (ge:SI (match_dup 1) (match_dup 2)) (match_dup 3)))
097657c3 13341 (set (match_dup 4)
9ebbca7d
GK
13342 (compare:CC (match_dup 0)
13343 (const_int 0)))]
13344 "")
1fd4e8c1
RK
13345
13346(define_insn ""
cd2b37d9
RK
13347 [(set (match_operand:SI 0 "gpc_reg_operand" "=r")
13348 (neg:SI (ge:SI (match_operand:SI 1 "gpc_reg_operand" "r")
1fd4e8c1 13349 (match_operand:SI 2 "reg_or_short_operand" "rI"))))]
ca7f5001
RK
13350 "TARGET_POWER"
13351 "doz%I2 %0,%1,%2\;{ai|addic} %0,%0,-1\;{sfe|subfe} %0,%0,%0"
b19003d8 13352 [(set_attr "length" "12")])
1fd4e8c1 13353
a2dba291
DE
13354(define_insn "*geu<mode>"
13355 [(set (match_operand:P 0 "gpc_reg_operand" "=r,r")
13356 (geu:P (match_operand:P 1 "gpc_reg_operand" "r,r")
13357 (match_operand:P 2 "reg_or_neg_short_operand" "r,P")))]
13358 ""
1fd4e8c1 13359 "@
ca7f5001
RK
13360 {sf|subfc} %0,%2,%1\;{cal %0,0(0)|li %0,0}\;{ae|adde} %0,%0,%0
13361 {ai|addic} %0,%1,%n2\;{cal %0,0(0)|li %0,0}\;{ae|adde} %0,%0,%0"
943c15ed
DE
13362 [(set_attr "type" "three")
13363 (set_attr "length" "12")])
1fd4e8c1 13364
a2dba291 13365(define_insn "*geu<mode>_compare"
9ebbca7d 13366 [(set (match_operand:CC 3 "cc_reg_operand" "=x,x,?y,?y")
1fd4e8c1 13367 (compare:CC
a2dba291
DE
13368 (geu:P (match_operand:P 1 "gpc_reg_operand" "r,r,r,r")
13369 (match_operand:P 2 "reg_or_neg_short_operand" "r,P,r,P"))
1fd4e8c1 13370 (const_int 0)))
a2dba291
DE
13371 (set (match_operand:P 0 "gpc_reg_operand" "=r,r,r,r")
13372 (geu:P (match_dup 1) (match_dup 2)))]
13373 ""
1fd4e8c1 13374 "@
ca7f5001 13375 {sf|subfc} %0,%2,%1\;{cal %0,0(0)|li %0,0}\;{ae.|adde.} %0,%0,%0
9ebbca7d
GK
13376 {ai|addic} %0,%1,%n2\;{cal %0,0(0)|li %0,0}\;{ae.|adde.} %0,%0,%0
13377 #
13378 #"
b19003d8 13379 [(set_attr "type" "compare")
9ebbca7d
GK
13380 (set_attr "length" "12,12,16,16")])
13381
13382(define_split
13383 [(set (match_operand:CC 3 "cc_reg_not_cr0_operand" "")
13384 (compare:CC
a2dba291
DE
13385 (geu:P (match_operand:P 1 "gpc_reg_operand" "")
13386 (match_operand:P 2 "reg_or_neg_short_operand" ""))
9ebbca7d 13387 (const_int 0)))
a2dba291
DE
13388 (set (match_operand:P 0 "gpc_reg_operand" "")
13389 (geu:P (match_dup 1) (match_dup 2)))]
13390 "reload_completed"
9ebbca7d 13391 [(set (match_dup 0)
a2dba291 13392 (geu:P (match_dup 1) (match_dup 2)))
9ebbca7d
GK
13393 (set (match_dup 3)
13394 (compare:CC (match_dup 0)
13395 (const_int 0)))]
13396 "")
f9562f27 13397
a2dba291
DE
13398(define_insn "*plus_geu<mode>"
13399 [(set (match_operand:P 0 "gpc_reg_operand" "=&r,&r")
13400 (plus:P (geu:P (match_operand:P 1 "gpc_reg_operand" "r,r")
13401 (match_operand:P 2 "reg_or_neg_short_operand" "r,P"))
13402 (match_operand:P 3 "gpc_reg_operand" "r,r")))]
13403 ""
1fd4e8c1 13404 "@
80103f96
FS
13405 {sf|subfc} %0,%2,%1\;{aze|addze} %0,%3
13406 {ai|addic} %0,%1,%n2\;{aze|addze} %0,%3"
943c15ed
DE
13407 [(set_attr "type" "two")
13408 (set_attr "length" "8")])
1fd4e8c1
RK
13409
13410(define_insn ""
9ebbca7d 13411 [(set (match_operand:CC 0 "cc_reg_operand" "=x,x,?y,?y")
1fd4e8c1 13412 (compare:CC
9ebbca7d
GK
13413 (plus:SI (geu:SI (match_operand:SI 1 "gpc_reg_operand" "r,r,r,r")
13414 (match_operand:SI 2 "reg_or_neg_short_operand" "r,P,r,P"))
13415 (match_operand:SI 3 "gpc_reg_operand" "r,r,r,r"))
1fd4e8c1 13416 (const_int 0)))
9ebbca7d 13417 (clobber (match_scratch:SI 4 "=&r,&r,&r,&r"))]
683bdff7 13418 "TARGET_32BIT"
1fd4e8c1 13419 "@
ca7f5001 13420 {sf|subfc} %4,%2,%1\;{aze.|addze.} %4,%3
9ebbca7d
GK
13421 {ai|addic} %4,%1,%n2\;{aze.|addze.} %4,%3
13422 #
13423 #"
b19003d8 13424 [(set_attr "type" "compare")
9ebbca7d
GK
13425 (set_attr "length" "8,8,12,12")])
13426
13427(define_split
13428 [(set (match_operand:CC 0 "cc_reg_not_cr0_operand" "")
13429 (compare:CC
13430 (plus:SI (geu:SI (match_operand:SI 1 "gpc_reg_operand" "")
13431 (match_operand:SI 2 "reg_or_neg_short_operand" ""))
13432 (match_operand:SI 3 "gpc_reg_operand" ""))
13433 (const_int 0)))
13434 (clobber (match_scratch:SI 4 ""))]
683bdff7 13435 "TARGET_32BIT && reload_completed"
9ebbca7d
GK
13436 [(set (match_dup 4)
13437 (plus:SI (geu:SI (match_dup 1) (match_dup 2))
13438 (match_dup 3)))
13439 (set (match_dup 0)
13440 (compare:CC (match_dup 4)
13441 (const_int 0)))]
13442 "")
1fd4e8c1
RK
13443
13444(define_insn ""
097657c3 13445 [(set (match_operand:CC 4 "cc_reg_operand" "=x,x,?y,?y")
1fd4e8c1 13446 (compare:CC
9ebbca7d
GK
13447 (plus:SI (geu:SI (match_operand:SI 1 "gpc_reg_operand" "r,r,r,r")
13448 (match_operand:SI 2 "reg_or_neg_short_operand" "r,P,r,P"))
13449 (match_operand:SI 3 "gpc_reg_operand" "r,r,r,r"))
1fd4e8c1 13450 (const_int 0)))
097657c3
AM
13451 (set (match_operand:SI 0 "gpc_reg_operand" "=&r,&r,&r,&r")
13452 (plus:SI (geu:SI (match_dup 1) (match_dup 2)) (match_dup 3)))]
683bdff7 13453 "TARGET_32BIT"
1fd4e8c1 13454 "@
097657c3
AM
13455 {sf|subfc} %0,%2,%1\;{aze.|addze.} %0,%3
13456 {ai|addic} %0,%1,%n2\;{aze.|addze.} %0,%3
9ebbca7d
GK
13457 #
13458 #"
b19003d8 13459 [(set_attr "type" "compare")
9ebbca7d
GK
13460 (set_attr "length" "8,8,12,12")])
13461
13462(define_split
097657c3 13463 [(set (match_operand:CC 4 "cc_reg_not_cr0_operand" "")
9ebbca7d
GK
13464 (compare:CC
13465 (plus:SI (geu:SI (match_operand:SI 1 "gpc_reg_operand" "")
13466 (match_operand:SI 2 "reg_or_neg_short_operand" ""))
13467 (match_operand:SI 3 "gpc_reg_operand" ""))
13468 (const_int 0)))
13469 (set (match_operand:SI 0 "gpc_reg_operand" "")
097657c3 13470 (plus:SI (geu:SI (match_dup 1) (match_dup 2)) (match_dup 3)))]
683bdff7 13471 "TARGET_32BIT && reload_completed"
097657c3 13472 [(set (match_dup 0)
9ebbca7d 13473 (plus:SI (geu:SI (match_dup 1) (match_dup 2)) (match_dup 3)))
097657c3 13474 (set (match_dup 4)
9ebbca7d
GK
13475 (compare:CC (match_dup 0)
13476 (const_int 0)))]
13477 "")
1fd4e8c1 13478
a2dba291
DE
13479(define_insn "*neg_geu<mode>"
13480 [(set (match_operand:P 0 "gpc_reg_operand" "=r,r")
13481 (neg:P (geu:P (match_operand:P 1 "gpc_reg_operand" "r,r")
13482 (match_operand:P 2 "reg_or_short_operand" "r,I"))))]
13483 ""
1fd4e8c1 13484 "@
ca7f5001 13485 {sf|subfc} %0,%2,%1\;{sfe|subfe} %0,%0,%0\;nand %0,%0,%0
8106dc08 13486 {sfi|subfic} %0,%1,-1\;{a%I2|add%I2c} %0,%0,%2\;{sfe|subfe} %0,%0,%0"
943c15ed
DE
13487 [(set_attr "type" "three")
13488 (set_attr "length" "12")])
1fd4e8c1 13489
a2dba291
DE
13490(define_insn "*and_neg_geu<mode>"
13491 [(set (match_operand:P 0 "gpc_reg_operand" "=&r,&r")
13492 (and:P (neg:P
13493 (geu:P (match_operand:P 1 "gpc_reg_operand" "r,r")
13494 (match_operand:P 2 "reg_or_neg_short_operand" "r,P")))
13495 (match_operand:P 3 "gpc_reg_operand" "r,r")))]
13496 ""
1fd4e8c1 13497 "@
097657c3
AM
13498 {sf|subfc} %0,%2,%1\;{sfe|subfe} %0,%0,%0\;andc %0,%3,%0
13499 {ai|addic} %0,%1,%n2\;{sfe|subfe} %0,%0,%0\;andc %0,%3,%0"
943c15ed
DE
13500 [(set_attr "type" "three")
13501 (set_attr "length" "12")])
1fd4e8c1
RK
13502
13503(define_insn ""
9ebbca7d 13504 [(set (match_operand:CC 0 "cc_reg_operand" "=x,x,?y,?y")
1fd4e8c1
RK
13505 (compare:CC
13506 (and:SI (neg:SI
9ebbca7d
GK
13507 (geu:SI (match_operand:SI 1 "gpc_reg_operand" "r,r,r,r")
13508 (match_operand:SI 2 "reg_or_neg_short_operand" "r,P,r,P")))
13509 (match_operand:SI 3 "gpc_reg_operand" "r,r,r,r"))
1fd4e8c1 13510 (const_int 0)))
9ebbca7d 13511 (clobber (match_scratch:SI 4 "=&r,&r,&r,&r"))]
683bdff7 13512 "TARGET_32BIT"
1fd4e8c1 13513 "@
ca7f5001 13514 {sf|subfc} %4,%2,%1\;{sfe|subfe} %4,%4,%4\;andc. %4,%3,%4
9ebbca7d
GK
13515 {ai|addic} %4,%1,%n2\;{sfe|subfe} %4,%4,%4\;andc. %4,%3,%4
13516 #
13517 #"
b19003d8 13518 [(set_attr "type" "compare")
9ebbca7d
GK
13519 (set_attr "length" "12,12,16,16")])
13520
13521(define_split
13522 [(set (match_operand:CC 0 "cc_reg_not_cr0_operand" "")
13523 (compare:CC
13524 (and:SI (neg:SI
13525 (geu:SI (match_operand:SI 1 "gpc_reg_operand" "")
13526 (match_operand:SI 2 "reg_or_neg_short_operand" "")))
13527 (match_operand:SI 3 "gpc_reg_operand" ""))
13528 (const_int 0)))
13529 (clobber (match_scratch:SI 4 ""))]
683bdff7 13530 "TARGET_32BIT && reload_completed"
9ebbca7d 13531 [(set (match_dup 4)
097657c3
AM
13532 (and:SI (neg:SI (geu:SI (match_dup 1) (match_dup 2)))
13533 (match_dup 3)))
9ebbca7d
GK
13534 (set (match_dup 0)
13535 (compare:CC (match_dup 4)
13536 (const_int 0)))]
13537 "")
1fd4e8c1
RK
13538
13539(define_insn ""
097657c3 13540 [(set (match_operand:CC 4 "cc_reg_operand" "=x,x,?y,?y")
1fd4e8c1
RK
13541 (compare:CC
13542 (and:SI (neg:SI
9ebbca7d
GK
13543 (geu:SI (match_operand:SI 1 "gpc_reg_operand" "r,r,r,r")
13544 (match_operand:SI 2 "reg_or_neg_short_operand" "r,P,r,P")))
13545 (match_operand:SI 3 "gpc_reg_operand" "r,r,r,r"))
1fd4e8c1 13546 (const_int 0)))
097657c3
AM
13547 (set (match_operand:SI 0 "gpc_reg_operand" "=&r,&r,&r,&r")
13548 (and:SI (neg:SI (geu:SI (match_dup 1) (match_dup 2))) (match_dup 3)))]
683bdff7 13549 "TARGET_32BIT"
1fd4e8c1 13550 "@
097657c3
AM
13551 {sf|subfc} %0,%2,%1\;{sfe|subfe} %0,%0,%0\;andc. %0,%3,%0
13552 {ai|addic} %0,%1,%n2\;{sfe|subfe} %0,%0,%0\;andc. %0,%3,%0
9ebbca7d
GK
13553 #
13554 #"
b19003d8 13555 [(set_attr "type" "compare")
9ebbca7d
GK
13556 (set_attr "length" "12,12,16,16")])
13557
13558(define_split
097657c3 13559 [(set (match_operand:CC 4 "cc_reg_not_cr0_operand" "")
9ebbca7d
GK
13560 (compare:CC
13561 (and:SI (neg:SI
13562 (geu:SI (match_operand:SI 1 "gpc_reg_operand" "")
13563 (match_operand:SI 2 "reg_or_neg_short_operand" "")))
13564 (match_operand:SI 3 "gpc_reg_operand" ""))
13565 (const_int 0)))
13566 (set (match_operand:SI 0 "gpc_reg_operand" "")
097657c3 13567 (and:SI (neg:SI (geu:SI (match_dup 1) (match_dup 2))) (match_dup 3)))]
683bdff7 13568 "TARGET_32BIT && reload_completed"
097657c3 13569 [(set (match_dup 0)
9ebbca7d 13570 (and:SI (neg:SI (geu:SI (match_dup 1) (match_dup 2))) (match_dup 3)))
097657c3 13571 (set (match_dup 4)
9ebbca7d
GK
13572 (compare:CC (match_dup 0)
13573 (const_int 0)))]
13574 "")
1fd4e8c1 13575
1fd4e8c1 13576(define_insn ""
cd2b37d9
RK
13577 [(set (match_operand:SI 0 "gpc_reg_operand" "=r")
13578 (gt:SI (match_operand:SI 1 "gpc_reg_operand" "r")
1fd4e8c1 13579 (match_operand:SI 2 "reg_or_short_operand" "r")))]
ca7f5001
RK
13580 "TARGET_POWER"
13581 "doz %0,%2,%1\;nabs %0,%0\;{sri|srwi} %0,%0,31"
b19003d8 13582 [(set_attr "length" "12")])
1fd4e8c1
RK
13583
13584(define_insn ""
9ebbca7d 13585 [(set (match_operand:CC 3 "cc_reg_operand" "=x,?y")
1fd4e8c1 13586 (compare:CC
9ebbca7d
GK
13587 (gt:SI (match_operand:SI 1 "gpc_reg_operand" "r,r")
13588 (match_operand:SI 2 "reg_or_short_operand" "r,r"))
1fd4e8c1 13589 (const_int 0)))
9ebbca7d 13590 (set (match_operand:SI 0 "gpc_reg_operand" "=r,r")
1fd4e8c1 13591 (gt:SI (match_dup 1) (match_dup 2)))]
ca7f5001 13592 "TARGET_POWER"
9ebbca7d
GK
13593 "@
13594 doz %0,%2,%1\;nabs %0,%0\;{sri.|srwi.} %0,%0,31
13595 #"
29ae5b89 13596 [(set_attr "type" "delayed_compare")
9ebbca7d
GK
13597 (set_attr "length" "12,16")])
13598
13599(define_split
13600 [(set (match_operand:CC 3 "cc_reg_not_cr0_operand" "")
13601 (compare:CC
13602 (gt:SI (match_operand:SI 1 "gpc_reg_operand" "")
13603 (match_operand:SI 2 "reg_or_short_operand" ""))
13604 (const_int 0)))
13605 (set (match_operand:SI 0 "gpc_reg_operand" "")
13606 (gt:SI (match_dup 1) (match_dup 2)))]
13607 "TARGET_POWER && reload_completed"
13608 [(set (match_dup 0)
13609 (gt:SI (match_dup 1) (match_dup 2)))
13610 (set (match_dup 3)
13611 (compare:CC (match_dup 0)
13612 (const_int 0)))]
13613 "")
1fd4e8c1 13614
d0515b39 13615(define_insn "*plus_gt0<mode>"
a2dba291
DE
13616 [(set (match_operand:P 0 "gpc_reg_operand" "=&r")
13617 (plus:P (gt:P (match_operand:P 1 "gpc_reg_operand" "r")
13618 (const_int 0))
13619 (match_operand:P 2 "gpc_reg_operand" "r")))]
13620 ""
80103f96 13621 "{a|addc} %0,%1,%1\;{sfe|subfe} %0,%1,%0\;{aze|addze} %0,%2"
943c15ed
DE
13622 [(set_attr "type" "three")
13623 (set_attr "length" "12")])
1fd4e8c1
RK
13624
13625(define_insn ""
9ebbca7d 13626 [(set (match_operand:CC 0 "cc_reg_operand" "=x,?y")
1fd4e8c1 13627 (compare:CC
9ebbca7d 13628 (plus:SI (gt:SI (match_operand:SI 1 "gpc_reg_operand" "r,r")
1fd4e8c1 13629 (const_int 0))
9ebbca7d 13630 (match_operand:SI 2 "gpc_reg_operand" "r,r"))
1fd4e8c1 13631 (const_int 0)))
9ebbca7d 13632 (clobber (match_scratch:SI 3 "=&r,&r"))]
683bdff7 13633 "TARGET_32BIT"
9ebbca7d
GK
13634 "@
13635 {a|addc} %3,%1,%1\;{sfe|subfe} %3,%1,%3\;{aze.|addze.} %3,%2
13636 #"
b19003d8 13637 [(set_attr "type" "compare")
9ebbca7d
GK
13638 (set_attr "length" "12,16")])
13639
13640(define_split
13641 [(set (match_operand:CC 0 "cc_reg_not_cr0_operand" "")
13642 (compare:CC
13643 (plus:SI (gt:SI (match_operand:SI 1 "gpc_reg_operand" "")
13644 (const_int 0))
13645 (match_operand:SI 2 "gpc_reg_operand" ""))
13646 (const_int 0)))
13647 (clobber (match_scratch:SI 3 ""))]
683bdff7 13648 "TARGET_32BIT && reload_completed"
9ebbca7d
GK
13649 [(set (match_dup 3)
13650 (plus:SI (gt:SI (match_dup 1) (const_int 0))
13651 (match_dup 2)))
13652 (set (match_dup 0)
13653 (compare:CC (match_dup 3)
13654 (const_int 0)))]
13655 "")
1fd4e8c1 13656
f9562f27 13657(define_insn ""
9ebbca7d 13658 [(set (match_operand:CC 0 "cc_reg_operand" "=x,?y")
f9562f27 13659 (compare:CC
9ebbca7d 13660 (plus:DI (gt:DI (match_operand:DI 1 "gpc_reg_operand" "r,r")
f9562f27 13661 (const_int 0))
9ebbca7d 13662 (match_operand:DI 2 "gpc_reg_operand" "r,r"))
f9562f27 13663 (const_int 0)))
9ebbca7d 13664 (clobber (match_scratch:DI 3 "=&r,&r"))]
683bdff7 13665 "TARGET_64BIT"
9ebbca7d
GK
13666 "@
13667 addc %3,%1,%1\;subfe %3,%1,%3\;addze. %3,%2
13668 #"
f9562f27 13669 [(set_attr "type" "compare")
9ebbca7d
GK
13670 (set_attr "length" "12,16")])
13671
13672(define_split
13673 [(set (match_operand:CC 0 "cc_reg_not_cr0_operand" "")
13674 (compare:CC
13675 (plus:DI (gt:DI (match_operand:DI 1 "gpc_reg_operand" "")
13676 (const_int 0))
13677 (match_operand:DI 2 "gpc_reg_operand" ""))
13678 (const_int 0)))
13679 (clobber (match_scratch:DI 3 ""))]
683bdff7 13680 "TARGET_64BIT && reload_completed"
9ebbca7d
GK
13681 [(set (match_dup 3)
13682 (plus:DI (gt:DI (match_dup 1) (const_int 0))
097657c3 13683 (match_dup 2)))
9ebbca7d
GK
13684 (set (match_dup 0)
13685 (compare:CC (match_dup 3)
13686 (const_int 0)))]
13687 "")
f9562f27 13688
1fd4e8c1 13689(define_insn ""
097657c3 13690 [(set (match_operand:CC 3 "cc_reg_operand" "=x,?y")
9ebbca7d
GK
13691 (compare:CC
13692 (plus:SI (gt:SI (match_operand:SI 1 "gpc_reg_operand" "r,r")
13693 (const_int 0))
13694 (match_operand:SI 2 "gpc_reg_operand" "r,r"))
13695 (const_int 0)))
097657c3
AM
13696 (set (match_operand:SI 0 "gpc_reg_operand" "=&r,&r")
13697 (plus:SI (gt:SI (match_dup 1) (const_int 0)) (match_dup 2)))]
683bdff7 13698 "TARGET_32BIT"
9ebbca7d 13699 "@
097657c3 13700 {a|addc} %0,%1,%1\;{sfe|subfe} %0,%1,%0\;{aze.|addze.} %0,%2
9ebbca7d
GK
13701 #"
13702 [(set_attr "type" "compare")
13703 (set_attr "length" "12,16")])
13704
13705(define_split
097657c3 13706 [(set (match_operand:CC 3 "cc_reg_not_cr0_operand" "")
1fd4e8c1 13707 (compare:CC
9ebbca7d 13708 (plus:SI (gt:SI (match_operand:SI 1 "gpc_reg_operand" "")
1fd4e8c1 13709 (const_int 0))
9ebbca7d 13710 (match_operand:SI 2 "gpc_reg_operand" ""))
1fd4e8c1 13711 (const_int 0)))
9ebbca7d 13712 (set (match_operand:SI 0 "gpc_reg_operand" "")
097657c3 13713 (plus:SI (gt:SI (match_dup 1) (const_int 0)) (match_dup 2)))]
683bdff7 13714 "TARGET_32BIT && reload_completed"
097657c3 13715 [(set (match_dup 0)
9ebbca7d 13716 (plus:SI (gt:SI (match_dup 1) (const_int 0)) (match_dup 2)))
097657c3 13717 (set (match_dup 3)
9ebbca7d
GK
13718 (compare:CC (match_dup 0)
13719 (const_int 0)))]
13720 "")
1fd4e8c1 13721
f9562f27 13722(define_insn ""
097657c3 13723 [(set (match_operand:CC 3 "cc_reg_operand" "=x,?y")
f9562f27 13724 (compare:CC
9ebbca7d 13725 (plus:DI (gt:DI (match_operand:DI 1 "gpc_reg_operand" "r,r")
f9562f27 13726 (const_int 0))
9ebbca7d 13727 (match_operand:DI 2 "gpc_reg_operand" "r,r"))
f9562f27 13728 (const_int 0)))
097657c3
AM
13729 (set (match_operand:DI 0 "gpc_reg_operand" "=&r,&r")
13730 (plus:DI (gt:DI (match_dup 1) (const_int 0)) (match_dup 2)))]
683bdff7 13731 "TARGET_64BIT"
9ebbca7d 13732 "@
097657c3 13733 addc %0,%1,%1\;subfe %0,%1,%0\;addze. %0,%2
9ebbca7d 13734 #"
f9562f27 13735 [(set_attr "type" "compare")
9ebbca7d
GK
13736 (set_attr "length" "12,16")])
13737
13738(define_split
097657c3 13739 [(set (match_operand:CC 3 "cc_reg_not_cr0_operand" "")
9ebbca7d
GK
13740 (compare:CC
13741 (plus:DI (gt:DI (match_operand:DI 1 "gpc_reg_operand" "")
13742 (const_int 0))
13743 (match_operand:DI 2 "gpc_reg_operand" ""))
13744 (const_int 0)))
13745 (set (match_operand:DI 0 "gpc_reg_operand" "")
097657c3 13746 (plus:DI (gt:DI (match_dup 1) (const_int 0)) (match_dup 2)))]
683bdff7 13747 "TARGET_64BIT && reload_completed"
097657c3 13748 [(set (match_dup 0)
9ebbca7d 13749 (plus:DI (gt:DI (match_dup 1) (const_int 0)) (match_dup 2)))
097657c3 13750 (set (match_dup 3)
9ebbca7d
GK
13751 (compare:CC (match_dup 0)
13752 (const_int 0)))]
13753 "")
f9562f27 13754
1fd4e8c1 13755(define_insn ""
097657c3 13756 [(set (match_operand:SI 0 "gpc_reg_operand" "=&r")
cd2b37d9 13757 (plus:SI (gt:SI (match_operand:SI 1 "gpc_reg_operand" "r")
1fd4e8c1 13758 (match_operand:SI 2 "reg_or_short_operand" "r"))
097657c3 13759 (match_operand:SI 3 "gpc_reg_operand" "r")))]
ca7f5001 13760 "TARGET_POWER"
097657c3 13761 "doz %0,%2,%1\;{ai|addic} %0,%0,-1\;{aze|addze} %0,%3"
b19003d8 13762 [(set_attr "length" "12")])
1fd4e8c1
RK
13763
13764(define_insn ""
9ebbca7d 13765 [(set (match_operand:CC 0 "cc_reg_operand" "=x,?y")
1fd4e8c1 13766 (compare:CC
9ebbca7d
GK
13767 (plus:SI (gt:SI (match_operand:SI 1 "gpc_reg_operand" "r,r")
13768 (match_operand:SI 2 "reg_or_short_operand" "r,r"))
13769 (match_operand:SI 3 "gpc_reg_operand" "r,r"))
1fd4e8c1 13770 (const_int 0)))
9ebbca7d 13771 (clobber (match_scratch:SI 4 "=&r,&r"))]
ca7f5001 13772 "TARGET_POWER"
9ebbca7d
GK
13773 "@
13774 doz %4,%2,%1\;{ai|addic} %4,%4,-1\;{aze.|addze.} %4,%3
13775 #"
b19003d8 13776 [(set_attr "type" "compare")
9ebbca7d
GK
13777 (set_attr "length" "12,16")])
13778
13779(define_split
13780 [(set (match_operand:CC 0 "cc_reg_not_cr0_operand" "")
13781 (compare:CC
13782 (plus:SI (gt:SI (match_operand:SI 1 "gpc_reg_operand" "")
13783 (match_operand:SI 2 "reg_or_short_operand" ""))
13784 (match_operand:SI 3 "gpc_reg_operand" ""))
13785 (const_int 0)))
13786 (clobber (match_scratch:SI 4 ""))]
13787 "TARGET_POWER && reload_completed"
13788 [(set (match_dup 4)
097657c3 13789 (plus:SI (gt:SI (match_dup 1) (match_dup 2)) (match_dup 3)))
9ebbca7d
GK
13790 (set (match_dup 0)
13791 (compare:CC (match_dup 4)
13792 (const_int 0)))]
13793 "")
1fd4e8c1
RK
13794
13795(define_insn ""
097657c3 13796 [(set (match_operand:CC 4 "cc_reg_operand" "=x,?y")
1fd4e8c1 13797 (compare:CC
9ebbca7d
GK
13798 (plus:SI (gt:SI (match_operand:SI 1 "gpc_reg_operand" "r,r")
13799 (match_operand:SI 2 "reg_or_short_operand" "r,r"))
13800 (match_operand:SI 3 "gpc_reg_operand" "r,r"))
1fd4e8c1 13801 (const_int 0)))
097657c3
AM
13802 (set (match_operand:SI 0 "gpc_reg_operand" "=&r,&r")
13803 (plus:SI (gt:SI (match_dup 1) (match_dup 2)) (match_dup 3)))]
ca7f5001 13804 "TARGET_POWER"
9ebbca7d 13805 "@
097657c3 13806 doz %0,%2,%1\;{ai|addic} %0,%0,-1\;{aze.|addze.} %0,%3
9ebbca7d 13807 #"
b19003d8 13808 [(set_attr "type" "compare")
9ebbca7d
GK
13809 (set_attr "length" "12,16")])
13810
13811(define_split
097657c3 13812 [(set (match_operand:CC 4 "cc_reg_not_cr0_operand" "")
9ebbca7d
GK
13813 (compare:CC
13814 (plus:SI (gt:SI (match_operand:SI 1 "gpc_reg_operand" "")
13815 (match_operand:SI 2 "reg_or_short_operand" ""))
13816 (match_operand:SI 3 "gpc_reg_operand" ""))
13817 (const_int 0)))
13818 (set (match_operand:SI 0 "gpc_reg_operand" "")
097657c3 13819 (plus:SI (gt:SI (match_dup 1) (match_dup 2)) (match_dup 3)))]
9ebbca7d 13820 "TARGET_POWER && reload_completed"
097657c3 13821 [(set (match_dup 0)
9ebbca7d 13822 (plus:SI (gt:SI (match_dup 1) (match_dup 2)) (match_dup 3)))
097657c3 13823 (set (match_dup 4)
9ebbca7d
GK
13824 (compare:CC (match_dup 0)
13825 (const_int 0)))]
13826 "")
1fd4e8c1 13827
1fd4e8c1 13828(define_insn ""
cd2b37d9
RK
13829 [(set (match_operand:SI 0 "gpc_reg_operand" "=r")
13830 (neg:SI (gt:SI (match_operand:SI 1 "gpc_reg_operand" "r")
1fd4e8c1 13831 (match_operand:SI 2 "reg_or_short_operand" "r"))))]
ca7f5001
RK
13832 "TARGET_POWER"
13833 "doz %0,%2,%1\;nabs %0,%0\;{srai|srawi} %0,%0,31"
b19003d8 13834 [(set_attr "length" "12")])
1fd4e8c1 13835
ce45ef46
DE
13836(define_insn_and_split "*gtu<mode>"
13837 [(set (match_operand:P 0 "gpc_reg_operand" "=r")
13838 (gtu:P (match_operand:P 1 "gpc_reg_operand" "r")
13839 (match_operand:P 2 "reg_or_short_operand" "rI")))]
13840 ""
c0600ecd 13841 "#"
ce45ef46
DE
13842 ""
13843 [(set (match_dup 0) (neg:P (gtu:P (match_dup 1) (match_dup 2))))
13844 (set (match_dup 0) (neg:P (match_dup 0)))]
c0600ecd 13845 "")
f9562f27 13846
1e24ce83 13847(define_insn_and_split "*gtu<mode>_compare"
9ebbca7d 13848 [(set (match_operand:CC 3 "cc_reg_operand" "=x,?y")
1fd4e8c1 13849 (compare:CC
a2dba291
DE
13850 (gtu:P (match_operand:P 1 "gpc_reg_operand" "r,r")
13851 (match_operand:P 2 "reg_or_short_operand" "rI,rI"))
1fd4e8c1 13852 (const_int 0)))
a2dba291
DE
13853 (set (match_operand:P 0 "gpc_reg_operand" "=r,r")
13854 (gtu:P (match_dup 1) (match_dup 2)))]
13855 ""
1e24ce83
DE
13856 "#"
13857 ""
13858 [(set (match_dup 0) (neg:P (gtu:P (match_dup 1) (match_dup 2))))
13859 (parallel [(set (match_dup 3)
13860 (compare:CC (neg:P (match_dup 0)) (const_int 0)))
13861 (set (match_dup 0) (neg:P (match_dup 0)))])]
9ebbca7d 13862 "")
f9562f27 13863
1e24ce83 13864(define_insn_and_split "*plus_gtu<mode>"
a2dba291
DE
13865 [(set (match_operand:P 0 "gpc_reg_operand" "=&r")
13866 (plus:P (gtu:P (match_operand:P 1 "gpc_reg_operand" "r")
13867 (match_operand:P 2 "reg_or_short_operand" "rI"))
13868 (match_operand:P 3 "reg_or_short_operand" "rI")))]
13869 ""
c0600ecd 13870 "#"
04fa46cf 13871 "&& !reg_overlap_mentioned_p (operands[0], operands[3])"
a2dba291
DE
13872 [(set (match_dup 0) (neg:P (gtu:P (match_dup 1) (match_dup 2))))
13873 (set (match_dup 0) (minus:P (match_dup 3) (match_dup 0)))]
c0600ecd 13874 "")
f9562f27 13875
1e24ce83 13876(define_insn_and_split "*plus_gtu<mode>_compare"
097657c3 13877 [(set (match_operand:CC 4 "cc_reg_operand" "=x,x,?y,?y")
f9562f27 13878 (compare:CC
1e24ce83
DE
13879 (plus:P (gtu:P (match_operand:P 1 "gpc_reg_operand" "r,r,r,r")
13880 (match_operand:P 2 "reg_or_short_operand" "I,r,I,r"))
13881 (match_operand:P 3 "gpc_reg_operand" "r,r,r,r"))
f9562f27 13882 (const_int 0)))
1e24ce83
DE
13883 (set (match_operand:P 0 "gpc_reg_operand" "=&r,&r,&r,&r")
13884 (plus:P (gtu:P (match_dup 1) (match_dup 2)) (match_dup 3)))]
13885 ""
13886 "#"
13887 "&& !reg_overlap_mentioned_p (operands[0], operands[3])"
13888 [(set (match_dup 0) (neg:P (gtu:P (match_dup 1) (match_dup 2))))
13889 (parallel [(set (match_dup 4)
13890 (compare:CC (minus:P (match_dup 3) (match_dup 0))
13891 (const_int 0)))
13892 (set (match_dup 0) (minus:P (match_dup 3) (match_dup 0)))])]
9ebbca7d 13893 "")
f9562f27 13894
ce45ef46
DE
13895(define_insn "*neg_gtu<mode>"
13896 [(set (match_operand:P 0 "gpc_reg_operand" "=r")
13897 (neg:P (gtu:P (match_operand:P 1 "gpc_reg_operand" "r")
13898 (match_operand:P 2 "reg_or_short_operand" "rI"))))]
13899 ""
ca7f5001 13900 "{sf%I2|subf%I2c} %0,%1,%2\;{sfe|subfe} %0,%0,%0"
943c15ed 13901 [(set_attr "type" "two")
c0600ecd 13902 (set_attr "length" "8")])
f9562f27 13903
1fd4e8c1
RK
13904\f
13905;; Define both directions of branch and return. If we need a reload
13906;; register, we'd rather use CR0 since it is much easier to copy a
13907;; register CC value to there.
13908
13909(define_insn ""
13910 [(set (pc)
13911 (if_then_else (match_operator 1 "branch_comparison_operator"
13912 [(match_operand 2
b54cf83a 13913 "cc_reg_operand" "y")
1fd4e8c1
RK
13914 (const_int 0)])
13915 (label_ref (match_operand 0 "" ""))
13916 (pc)))]
13917 ""
b19003d8
RK
13918 "*
13919{
12a4e8c5 13920 return output_cbranch (operands[1], \"%l0\", 0, insn);
b19003d8
RK
13921}"
13922 [(set_attr "type" "branch")])
13923
1fd4e8c1
RK
13924(define_insn ""
13925 [(set (pc)
13926 (if_then_else (match_operator 0 "branch_comparison_operator"
13927 [(match_operand 1
b54cf83a 13928 "cc_reg_operand" "y")
1fd4e8c1
RK
13929 (const_int 0)])
13930 (return)
13931 (pc)))]
13932 "direct_return ()"
12a4e8c5
GK
13933 "*
13934{
13935 return output_cbranch (operands[0], NULL, 0, insn);
13936}"
9c6fdb46 13937 [(set_attr "type" "jmpreg")
39a10a29 13938 (set_attr "length" "4")])
1fd4e8c1
RK
13939
13940(define_insn ""
13941 [(set (pc)
13942 (if_then_else (match_operator 1 "branch_comparison_operator"
13943 [(match_operand 2
b54cf83a 13944 "cc_reg_operand" "y")
1fd4e8c1
RK
13945 (const_int 0)])
13946 (pc)
13947 (label_ref (match_operand 0 "" ""))))]
13948 ""
b19003d8
RK
13949 "*
13950{
12a4e8c5 13951 return output_cbranch (operands[1], \"%l0\", 1, insn);
b19003d8
RK
13952}"
13953 [(set_attr "type" "branch")])
1fd4e8c1
RK
13954
13955(define_insn ""
13956 [(set (pc)
13957 (if_then_else (match_operator 0 "branch_comparison_operator"
13958 [(match_operand 1
b54cf83a 13959 "cc_reg_operand" "y")
1fd4e8c1
RK
13960 (const_int 0)])
13961 (pc)
13962 (return)))]
13963 "direct_return ()"
12a4e8c5
GK
13964 "*
13965{
13966 return output_cbranch (operands[0], NULL, 1, insn);
13967}"
9c6fdb46 13968 [(set_attr "type" "jmpreg")
39a10a29
GK
13969 (set_attr "length" "4")])
13970
13971;; Logic on condition register values.
13972
13973; This pattern matches things like
13974; (set (reg:CCEQ 68) (compare:CCEQ (ior:SI (gt:SI (reg:CCFP 68) (const_int 0))
13975; (eq:SI (reg:CCFP 68) (const_int 0)))
13976; (const_int 1)))
13977; which are generated by the branch logic.
b54cf83a 13978; Prefer destructive operations where BT = BB (for crXX BT,BA,BB)
39a10a29 13979
423c1189 13980(define_insn "*cceq_ior_compare"
b54cf83a 13981 [(set (match_operand:CCEQ 0 "cc_reg_operand" "=y,?y")
39a10a29 13982 (compare:CCEQ (match_operator:SI 1 "boolean_operator"
b54cf83a 13983 [(match_operator:SI 2
39a10a29
GK
13984 "branch_positive_comparison_operator"
13985 [(match_operand 3
b54cf83a 13986 "cc_reg_operand" "y,y")
39a10a29 13987 (const_int 0)])
b54cf83a 13988 (match_operator:SI 4
39a10a29
GK
13989 "branch_positive_comparison_operator"
13990 [(match_operand 5
b54cf83a 13991 "cc_reg_operand" "0,y")
39a10a29
GK
13992 (const_int 0)])])
13993 (const_int 1)))]
24fab1d3 13994 ""
39a10a29 13995 "cr%q1 %E0,%j2,%j4"
b54cf83a 13996 [(set_attr "type" "cr_logical,delayed_cr")])
39a10a29
GK
13997
13998; Why is the constant -1 here, but 1 in the previous pattern?
13999; Because ~1 has all but the low bit set.
14000(define_insn ""
b54cf83a 14001 [(set (match_operand:CCEQ 0 "cc_reg_operand" "=y,?y")
39a10a29 14002 (compare:CCEQ (match_operator:SI 1 "boolean_or_operator"
b54cf83a 14003 [(not:SI (match_operator:SI 2
39a10a29
GK
14004 "branch_positive_comparison_operator"
14005 [(match_operand 3
b54cf83a 14006 "cc_reg_operand" "y,y")
39a10a29
GK
14007 (const_int 0)]))
14008 (match_operator:SI 4
14009 "branch_positive_comparison_operator"
14010 [(match_operand 5
b54cf83a 14011 "cc_reg_operand" "0,y")
39a10a29
GK
14012 (const_int 0)])])
14013 (const_int -1)))]
14014 ""
14015 "cr%q1 %E0,%j2,%j4"
b54cf83a 14016 [(set_attr "type" "cr_logical,delayed_cr")])
39a10a29 14017
423c1189 14018(define_insn "*cceq_rev_compare"
b54cf83a 14019 [(set (match_operand:CCEQ 0 "cc_reg_operand" "=y,?y")
6c873122 14020 (compare:CCEQ (match_operator:SI 1
39a10a29 14021 "branch_positive_comparison_operator"
6c873122 14022 [(match_operand 2
b54cf83a 14023 "cc_reg_operand" "0,y")
39a10a29
GK
14024 (const_int 0)])
14025 (const_int 0)))]
423c1189 14026 ""
251b3667 14027 "{crnor %E0,%j1,%j1|crnot %E0,%j1}"
b54cf83a 14028 [(set_attr "type" "cr_logical,delayed_cr")])
39a10a29
GK
14029
14030;; If we are comparing the result of two comparisons, this can be done
14031;; using creqv or crxor.
14032
14033(define_insn_and_split ""
14034 [(set (match_operand:CCEQ 0 "cc_reg_operand" "=y")
14035 (compare:CCEQ (match_operator 1 "branch_comparison_operator"
14036 [(match_operand 2 "cc_reg_operand" "y")
14037 (const_int 0)])
14038 (match_operator 3 "branch_comparison_operator"
14039 [(match_operand 4 "cc_reg_operand" "y")
14040 (const_int 0)])))]
14041 ""
14042 "#"
14043 ""
14044 [(set (match_dup 0) (compare:CCEQ (xor:SI (match_dup 1) (match_dup 3))
14045 (match_dup 5)))]
14046 "
14047{
14048 int positive_1, positive_2;
14049
364849ee
DE
14050 positive_1 = branch_positive_comparison_operator (operands[1],
14051 GET_MODE (operands[1]));
14052 positive_2 = branch_positive_comparison_operator (operands[3],
14053 GET_MODE (operands[3]));
39a10a29
GK
14054
14055 if (! positive_1)
1c563bed 14056 operands[1] = gen_rtx_fmt_ee (rs6000_reverse_condition (GET_MODE (operands[2]),
0f4c242b
KH
14057 GET_CODE (operands[1])),
14058 SImode,
14059 operands[2], const0_rtx);
39a10a29 14060 else if (GET_MODE (operands[1]) != SImode)
0f4c242b
KH
14061 operands[1] = gen_rtx_fmt_ee (GET_CODE (operands[1]), SImode,
14062 operands[2], const0_rtx);
39a10a29
GK
14063
14064 if (! positive_2)
1c563bed 14065 operands[3] = gen_rtx_fmt_ee (rs6000_reverse_condition (GET_MODE (operands[4]),
0f4c242b
KH
14066 GET_CODE (operands[3])),
14067 SImode,
14068 operands[4], const0_rtx);
39a10a29 14069 else if (GET_MODE (operands[3]) != SImode)
0f4c242b
KH
14070 operands[3] = gen_rtx_fmt_ee (GET_CODE (operands[3]), SImode,
14071 operands[4], const0_rtx);
39a10a29
GK
14072
14073 if (positive_1 == positive_2)
251b3667
DE
14074 {
14075 operands[1] = gen_rtx_NOT (SImode, operands[1]);
14076 operands[5] = constm1_rtx;
14077 }
14078 else
14079 {
14080 operands[5] = const1_rtx;
14081 }
39a10a29 14082}")
1fd4e8c1
RK
14083
14084;; Unconditional branch and return.
14085
14086(define_insn "jump"
14087 [(set (pc)
14088 (label_ref (match_operand 0 "" "")))]
14089 ""
b7ff3d82
DE
14090 "b %l0"
14091 [(set_attr "type" "branch")])
1fd4e8c1
RK
14092
14093(define_insn "return"
14094 [(return)]
14095 "direct_return ()"
324e52cc
TG
14096 "{br|blr}"
14097 [(set_attr "type" "jmpreg")])
1fd4e8c1 14098
0ad91047 14099(define_expand "indirect_jump"
4ae234b0 14100 [(set (pc) (match_operand 0 "register_operand" ""))])
0ad91047 14101
4ae234b0
GK
14102(define_insn "*indirect_jump<mode>"
14103 [(set (pc) (match_operand:P 0 "register_operand" "c,*l"))]
14104 ""
b92b324d
DE
14105 "@
14106 bctr
14107 {br|blr}"
324e52cc 14108 [(set_attr "type" "jmpreg")])
1fd4e8c1
RK
14109
14110;; Table jump for switch statements:
14111(define_expand "tablejump"
e6ca2c17
DE
14112 [(use (match_operand 0 "" ""))
14113 (use (label_ref (match_operand 1 "" "")))]
14114 ""
14115 "
14116{
14117 if (TARGET_32BIT)
14118 emit_jump_insn (gen_tablejumpsi (operands[0], operands[1]));
14119 else
14120 emit_jump_insn (gen_tablejumpdi (operands[0], operands[1]));
14121 DONE;
14122}")
14123
14124(define_expand "tablejumpsi"
1fd4e8c1
RK
14125 [(set (match_dup 3)
14126 (plus:SI (match_operand:SI 0 "" "")
14127 (match_dup 2)))
14128 (parallel [(set (pc) (match_dup 3))
14129 (use (label_ref (match_operand 1 "" "")))])]
0ad91047 14130 "TARGET_32BIT"
1fd4e8c1
RK
14131 "
14132{ operands[0] = force_reg (SImode, operands[0]);
c5c76735 14133 operands[2] = force_reg (SImode, gen_rtx_LABEL_REF (SImode, operands[1]));
1fd4e8c1
RK
14134 operands[3] = gen_reg_rtx (SImode);
14135}")
14136
e6ca2c17 14137(define_expand "tablejumpdi"
6ae08853 14138 [(set (match_dup 4)
e42ac3de 14139 (sign_extend:DI (match_operand:SI 0 "lwa_operand" "")))
9ebbca7d
GK
14140 (set (match_dup 3)
14141 (plus:DI (match_dup 4)
e6ca2c17
DE
14142 (match_dup 2)))
14143 (parallel [(set (pc) (match_dup 3))
14144 (use (label_ref (match_operand 1 "" "")))])]
0ad91047 14145 "TARGET_64BIT"
e6ca2c17 14146 "
9ebbca7d 14147{ operands[2] = force_reg (DImode, gen_rtx_LABEL_REF (DImode, operands[1]));
e6ca2c17 14148 operands[3] = gen_reg_rtx (DImode);
9ebbca7d 14149 operands[4] = gen_reg_rtx (DImode);
e6ca2c17
DE
14150}")
14151
ce45ef46 14152(define_insn "*tablejump<mode>_internal1"
1fd4e8c1 14153 [(set (pc)
4ae234b0 14154 (match_operand:P 0 "register_operand" "c,*l"))
1fd4e8c1 14155 (use (label_ref (match_operand 1 "" "")))]
4ae234b0 14156 ""
c859cda6
DJ
14157 "@
14158 bctr
14159 {br|blr}"
a6845123 14160 [(set_attr "type" "jmpreg")])
1fd4e8c1
RK
14161
14162(define_insn "nop"
14163 [(const_int 0)]
14164 ""
ca7f5001 14165 "{cror 0,0,0|nop}")
1fd4e8c1 14166\f
7e69e155 14167;; Define the subtract-one-and-jump insns, starting with the template
c225ba7b
RK
14168;; so loop.c knows what to generate.
14169
5527bf14
RH
14170(define_expand "doloop_end"
14171 [(use (match_operand 0 "" "")) ; loop pseudo
14172 (use (match_operand 1 "" "")) ; iterations; zero if unknown
14173 (use (match_operand 2 "" "")) ; max iterations
14174 (use (match_operand 3 "" "")) ; loop level
14175 (use (match_operand 4 "" ""))] ; label
0ad91047
DE
14176 ""
14177 "
14178{
5527bf14
RH
14179 /* Only use this on innermost loops. */
14180 if (INTVAL (operands[3]) > 1)
14181 FAIL;
683bdff7 14182 if (TARGET_64BIT)
5527bf14
RH
14183 {
14184 if (GET_MODE (operands[0]) != DImode)
14185 FAIL;
14186 emit_jump_insn (gen_ctrdi (operands[0], operands[4]));
14187 }
0ad91047 14188 else
5527bf14
RH
14189 {
14190 if (GET_MODE (operands[0]) != SImode)
14191 FAIL;
14192 emit_jump_insn (gen_ctrsi (operands[0], operands[4]));
14193 }
0ad91047
DE
14194 DONE;
14195}")
14196
4ae234b0 14197(define_expand "ctr<mode>"
3cb999d8 14198 [(parallel [(set (pc)
4ae234b0 14199 (if_then_else (ne (match_operand:P 0 "register_operand" "")
3cb999d8
DE
14200 (const_int 1))
14201 (label_ref (match_operand 1 "" ""))
14202 (pc)))
b6c9286a 14203 (set (match_dup 0)
4ae234b0 14204 (plus:P (match_dup 0)
b6c9286a 14205 (const_int -1)))
5f81043f 14206 (clobber (match_scratch:CC 2 ""))
4ae234b0
GK
14207 (clobber (match_scratch:P 3 ""))])]
14208 ""
61c07d3c 14209 "")
c225ba7b 14210
1fd4e8c1
RK
14211;; We need to be able to do this for any operand, including MEM, or we
14212;; will cause reload to blow up since we don't allow output reloads on
7e69e155 14213;; JUMP_INSNs.
0ad91047 14214;; For the length attribute to be calculated correctly, the
5f81043f
RK
14215;; label MUST be operand 0.
14216
4ae234b0 14217(define_insn "*ctr<mode>_internal1"
0ad91047 14218 [(set (pc)
4ae234b0 14219 (if_then_else (ne (match_operand:P 1 "register_operand" "c,*r,*r,*r")
0ad91047
DE
14220 (const_int 1))
14221 (label_ref (match_operand 0 "" ""))
14222 (pc)))
4ae234b0
GK
14223 (set (match_operand:P 2 "nonimmediate_operand" "=1,*r,m,*q*c*l")
14224 (plus:P (match_dup 1)
0ad91047 14225 (const_int -1)))
43b68ce5 14226 (clobber (match_scratch:CC 3 "=X,&x,&x,&x"))
4ae234b0
GK
14227 (clobber (match_scratch:P 4 "=X,X,&r,r"))]
14228 ""
0ad91047
DE
14229 "*
14230{
14231 if (which_alternative != 0)
14232 return \"#\";
856a6884 14233 else if (get_attr_length (insn) == 4)
0ad91047
DE
14234 return \"{bdn|bdnz} %l0\";
14235 else
f607bc57 14236 return \"bdz $+8\;b %l0\";
0ad91047
DE
14237}"
14238 [(set_attr "type" "branch")
5a195cb5 14239 (set_attr "length" "*,12,16,16")])
0ad91047 14240
4ae234b0 14241(define_insn "*ctr<mode>_internal2"
0ad91047 14242 [(set (pc)
4ae234b0 14243 (if_then_else (ne (match_operand:P 1 "register_operand" "c,*r,*r,*r")
0ad91047
DE
14244 (const_int 1))
14245 (pc)
14246 (label_ref (match_operand 0 "" ""))))
4ae234b0
GK
14247 (set (match_operand:P 2 "nonimmediate_operand" "=1,*r,m,*q*c*l")
14248 (plus:P (match_dup 1)
0ad91047 14249 (const_int -1)))
43b68ce5 14250 (clobber (match_scratch:CC 3 "=X,&x,&x,&x"))
4ae234b0
GK
14251 (clobber (match_scratch:P 4 "=X,X,&r,r"))]
14252 ""
5f81043f
RK
14253 "*
14254{
14255 if (which_alternative != 0)
14256 return \"#\";
856a6884 14257 else if (get_attr_length (insn) == 4)
5f81043f
RK
14258 return \"bdz %l0\";
14259 else
f607bc57 14260 return \"{bdn|bdnz} $+8\;b %l0\";
5f81043f
RK
14261}"
14262 [(set_attr "type" "branch")
5a195cb5 14263 (set_attr "length" "*,12,16,16")])
5f81043f 14264
0ad91047
DE
14265;; Similar but use EQ
14266
4ae234b0 14267(define_insn "*ctr<mode>_internal5"
5f81043f 14268 [(set (pc)
4ae234b0 14269 (if_then_else (eq (match_operand:P 1 "register_operand" "c,*r,*r,*r")
1fd4e8c1 14270 (const_int 1))
a6845123 14271 (label_ref (match_operand 0 "" ""))
1fd4e8c1 14272 (pc)))
4ae234b0
GK
14273 (set (match_operand:P 2 "nonimmediate_operand" "=1,*r,m,*q*c*l")
14274 (plus:P (match_dup 1)
0ad91047 14275 (const_int -1)))
43b68ce5 14276 (clobber (match_scratch:CC 3 "=X,&x,&x,&x"))
4ae234b0
GK
14277 (clobber (match_scratch:P 4 "=X,X,&r,r"))]
14278 ""
0ad91047
DE
14279 "*
14280{
14281 if (which_alternative != 0)
14282 return \"#\";
856a6884 14283 else if (get_attr_length (insn) == 4)
0ad91047
DE
14284 return \"bdz %l0\";
14285 else
f607bc57 14286 return \"{bdn|bdnz} $+8\;b %l0\";
0ad91047
DE
14287}"
14288 [(set_attr "type" "branch")
5a195cb5 14289 (set_attr "length" "*,12,16,16")])
0ad91047 14290
4ae234b0 14291(define_insn "*ctr<mode>_internal6"
0ad91047 14292 [(set (pc)
4ae234b0 14293 (if_then_else (eq (match_operand:P 1 "register_operand" "c,*r,*r,*r")
0ad91047
DE
14294 (const_int 1))
14295 (pc)
14296 (label_ref (match_operand 0 "" ""))))
4ae234b0
GK
14297 (set (match_operand:P 2 "nonimmediate_operand" "=1,*r,m,*q*c*l")
14298 (plus:P (match_dup 1)
0ad91047 14299 (const_int -1)))
43b68ce5 14300 (clobber (match_scratch:CC 3 "=X,&x,&x,&x"))
4ae234b0
GK
14301 (clobber (match_scratch:P 4 "=X,X,&r,r"))]
14302 ""
5f81043f
RK
14303 "*
14304{
14305 if (which_alternative != 0)
14306 return \"#\";
856a6884 14307 else if (get_attr_length (insn) == 4)
5f81043f
RK
14308 return \"{bdn|bdnz} %l0\";
14309 else
f607bc57 14310 return \"bdz $+8\;b %l0\";
5f81043f
RK
14311}"
14312 [(set_attr "type" "branch")
5a195cb5 14313 (set_attr "length" "*,12,16,16")])
5f81043f 14314
0ad91047
DE
14315;; Now the splitters if we could not allocate the CTR register
14316
1fd4e8c1
RK
14317(define_split
14318 [(set (pc)
14319 (if_then_else (match_operator 2 "comparison_operator"
4ae234b0 14320 [(match_operand:P 1 "gpc_reg_operand" "")
0ad91047 14321 (const_int 1)])
61c07d3c
DE
14322 (match_operand 5 "" "")
14323 (match_operand 6 "" "")))
4ae234b0
GK
14324 (set (match_operand:P 0 "gpc_reg_operand" "")
14325 (plus:P (match_dup 1) (const_int -1)))
0ad91047 14326 (clobber (match_scratch:CC 3 ""))
4ae234b0
GK
14327 (clobber (match_scratch:P 4 ""))]
14328 "reload_completed"
0ad91047 14329 [(parallel [(set (match_dup 3)
4ae234b0 14330 (compare:CC (plus:P (match_dup 1)
0ad91047
DE
14331 (const_int -1))
14332 (const_int 0)))
14333 (set (match_dup 0)
4ae234b0 14334 (plus:P (match_dup 1)
0ad91047 14335 (const_int -1)))])
61c07d3c
DE
14336 (set (pc) (if_then_else (match_dup 7)
14337 (match_dup 5)
14338 (match_dup 6)))]
0ad91047 14339 "
0f4c242b
KH
14340{ operands[7] = gen_rtx_fmt_ee (GET_CODE (operands[2]), VOIDmode,
14341 operands[3], const0_rtx); }")
0ad91047
DE
14342
14343(define_split
14344 [(set (pc)
14345 (if_then_else (match_operator 2 "comparison_operator"
4ae234b0 14346 [(match_operand:P 1 "gpc_reg_operand" "")
0ad91047 14347 (const_int 1)])
61c07d3c
DE
14348 (match_operand 5 "" "")
14349 (match_operand 6 "" "")))
4ae234b0
GK
14350 (set (match_operand:P 0 "nonimmediate_operand" "")
14351 (plus:P (match_dup 1) (const_int -1)))
0ad91047 14352 (clobber (match_scratch:CC 3 ""))
4ae234b0
GK
14353 (clobber (match_scratch:P 4 ""))]
14354 "reload_completed && ! gpc_reg_operand (operands[0], SImode)"
0ad91047 14355 [(parallel [(set (match_dup 3)
4ae234b0 14356 (compare:CC (plus:P (match_dup 1)
0ad91047
DE
14357 (const_int -1))
14358 (const_int 0)))
14359 (set (match_dup 4)
4ae234b0 14360 (plus:P (match_dup 1)
0ad91047
DE
14361 (const_int -1)))])
14362 (set (match_dup 0)
14363 (match_dup 4))
61c07d3c
DE
14364 (set (pc) (if_then_else (match_dup 7)
14365 (match_dup 5)
14366 (match_dup 6)))]
0ad91047 14367 "
0f4c242b
KH
14368{ operands[7] = gen_rtx_fmt_ee (GET_CODE (operands[2]), VOIDmode,
14369 operands[3], const0_rtx); }")
e0cd0770
JC
14370\f
14371(define_insn "trap"
14372 [(trap_if (const_int 1) (const_int 0))]
14373 ""
44cd321e
PS
14374 "{t 31,0,0|trap}"
14375 [(set_attr "type" "trap")])
e0cd0770
JC
14376
14377(define_expand "conditional_trap"
14378 [(trap_if (match_operator 0 "trap_comparison_operator"
14379 [(match_dup 2) (match_dup 3)])
14380 (match_operand 1 "const_int_operand" ""))]
14381 ""
14382 "if (rs6000_compare_fp_p || operands[1] != const0_rtx) FAIL;
14383 operands[2] = rs6000_compare_op0;
14384 operands[3] = rs6000_compare_op1;")
14385
14386(define_insn ""
14387 [(trap_if (match_operator 0 "trap_comparison_operator"
4ae234b0
GK
14388 [(match_operand:GPR 1 "register_operand" "r")
14389 (match_operand:GPR 2 "reg_or_short_operand" "rI")])
e0cd0770
JC
14390 (const_int 0))]
14391 ""
44cd321e
PS
14392 "{t|t<wd>}%V0%I2 %1,%2"
14393 [(set_attr "type" "trap")])
9ebbca7d
GK
14394\f
14395;; Insns related to generating the function prologue and epilogue.
14396
14397(define_expand "prologue"
14398 [(use (const_int 0))]
14399 "TARGET_SCHED_PROLOG"
14400 "
14401{
14402 rs6000_emit_prologue ();
14403 DONE;
14404}")
14405
2c4a9cff
DE
14406(define_insn "*movesi_from_cr_one"
14407 [(match_parallel 0 "mfcr_operation"
14408 [(set (match_operand:SI 1 "gpc_reg_operand" "=r")
14409 (unspec:SI [(match_operand:CC 2 "cc_reg_operand" "y")
14410 (match_operand 3 "immediate_operand" "n")]
14411 UNSPEC_MOVESI_FROM_CR))])]
14412 "TARGET_MFCRF"
14413 "*
14414{
14415 int mask = 0;
14416 int i;
14417 for (i = 0; i < XVECLEN (operands[0], 0); i++)
14418 {
14419 mask = INTVAL (XVECEXP (SET_SRC (XVECEXP (operands[0], 0, i)), 0, 1));
14420 operands[4] = GEN_INT (mask);
14421 output_asm_insn (\"mfcr %1,%4\", operands);
14422 }
14423 return \"\";
14424}"
14425 [(set_attr "type" "mfcrf")])
14426
9ebbca7d
GK
14427(define_insn "movesi_from_cr"
14428 [(set (match_operand:SI 0 "gpc_reg_operand" "=r")
1de43f85
DE
14429 (unspec:SI [(reg:CC CR0_REGNO) (reg:CC CR1_REGNO)
14430 (reg:CC CR2_REGNO) (reg:CC CR3_REGNO)
14431 (reg:CC CR4_REGNO) (reg:CC CR5_REGNO)
14432 (reg:CC CR6_REGNO) (reg:CC CR7_REGNO)]
615158e2 14433 UNSPEC_MOVESI_FROM_CR))]
9ebbca7d 14434 ""
309323c2 14435 "mfcr %0"
b54cf83a 14436 [(set_attr "type" "mfcr")])
9ebbca7d
GK
14437
14438(define_insn "*stmw"
e033a023
DE
14439 [(match_parallel 0 "stmw_operation"
14440 [(set (match_operand:SI 1 "memory_operand" "=m")
14441 (match_operand:SI 2 "gpc_reg_operand" "r"))])]
14442 "TARGET_MULTIPLE"
9c6fdb46
DE
14443 "{stm|stmw} %2,%1"
14444 [(set_attr "type" "store_ux")])
6ae08853 14445
f78c3290
NF
14446(define_insn "*save_gpregs_<mode>"
14447 [(match_parallel 0 "any_parallel_operand"
14448 [(clobber (reg:P 65))
14449 (use (match_operand:P 1 "symbol_ref_operand" "s"))
14450 (use (match_operand:P 2 "gpc_reg_operand" "r"))
14451 (set (match_operand:P 3 "memory_operand" "=m")
14452 (match_operand:P 4 "gpc_reg_operand" "r"))])]
14453 ""
14454 "bl %z1"
14455 [(set_attr "type" "branch")
14456 (set_attr "length" "4")])
14457
4ae234b0 14458(define_insn "*save_fpregs_<mode>"
85d346f1 14459 [(match_parallel 0 "any_parallel_operand"
e65a3857 14460 [(clobber (reg:P 65))
f78c3290
NF
14461 (use (match_operand:P 1 "symbol_ref_operand" "s"))
14462 (use (match_operand:P 2 "gpc_reg_operand" "r"))
14463 (set (match_operand:DF 3 "memory_operand" "=m")
14464 (match_operand:DF 4 "gpc_reg_operand" "f"))])]
4ae234b0 14465 ""
e65a3857 14466 "bl %z1"
e033a023
DE
14467 [(set_attr "type" "branch")
14468 (set_attr "length" "4")])
9ebbca7d
GK
14469
14470; These are to explain that changes to the stack pointer should
14471; not be moved over stores to stack memory.
14472(define_insn "stack_tie"
14473 [(set (match_operand:BLK 0 "memory_operand" "+m")
615158e2 14474 (unspec:BLK [(match_dup 0)] UNSPEC_TIE))]
9ebbca7d
GK
14475 ""
14476 ""
14477 [(set_attr "length" "0")])
14478
14479
14480(define_expand "epilogue"
14481 [(use (const_int 0))]
14482 "TARGET_SCHED_PROLOG"
14483 "
14484{
14485 rs6000_emit_epilogue (FALSE);
14486 DONE;
14487}")
14488
14489; On some processors, doing the mtcrf one CC register at a time is
14490; faster (like on the 604e). On others, doing them all at once is
14491; faster; for instance, on the 601 and 750.
14492
14493(define_expand "movsi_to_cr_one"
e42ac3de
RS
14494 [(set (match_operand:CC 0 "cc_reg_operand" "")
14495 (unspec:CC [(match_operand:SI 1 "gpc_reg_operand" "")
615158e2 14496 (match_dup 2)] UNSPEC_MOVESI_TO_CR))]
35aba846
DE
14497 ""
14498 "operands[2] = GEN_INT (1 << (75 - REGNO (operands[0])));")
9ebbca7d
GK
14499
14500(define_insn "*movsi_to_cr"
35aba846
DE
14501 [(match_parallel 0 "mtcrf_operation"
14502 [(set (match_operand:CC 1 "cc_reg_operand" "=y")
14503 (unspec:CC [(match_operand:SI 2 "gpc_reg_operand" "r")
14504 (match_operand 3 "immediate_operand" "n")]
615158e2 14505 UNSPEC_MOVESI_TO_CR))])]
9ebbca7d 14506 ""
e35b9579
GK
14507 "*
14508{
14509 int mask = 0;
14510 int i;
14511 for (i = 0; i < XVECLEN (operands[0], 0); i++)
14512 mask |= INTVAL (XVECEXP (SET_SRC (XVECEXP (operands[0], 0, i)), 0, 1));
14513 operands[4] = GEN_INT (mask);
14514 return \"mtcrf %4,%2\";
309323c2 14515}"
b54cf83a 14516 [(set_attr "type" "mtcr")])
9ebbca7d 14517
b54cf83a 14518(define_insn "*mtcrfsi"
309323c2
DE
14519 [(set (match_operand:CC 0 "cc_reg_operand" "=y")
14520 (unspec:CC [(match_operand:SI 1 "gpc_reg_operand" "r")
615158e2
JJ
14521 (match_operand 2 "immediate_operand" "n")]
14522 UNSPEC_MOVESI_TO_CR))]
6ae08853 14523 "GET_CODE (operands[0]) == REG
309323c2
DE
14524 && CR_REGNO_P (REGNO (operands[0]))
14525 && GET_CODE (operands[2]) == CONST_INT
14526 && INTVAL (operands[2]) == 1 << (75 - REGNO (operands[0]))"
14527 "mtcrf %R0,%1"
b54cf83a 14528 [(set_attr "type" "mtcr")])
9ebbca7d
GK
14529
14530; The load-multiple instructions have similar properties.
14531; Note that "load_multiple" is a name known to the machine-independent
9c6fdb46 14532; code that actually corresponds to the PowerPC load-string.
9ebbca7d
GK
14533
14534(define_insn "*lmw"
35aba846
DE
14535 [(match_parallel 0 "lmw_operation"
14536 [(set (match_operand:SI 1 "gpc_reg_operand" "=r")
14537 (match_operand:SI 2 "memory_operand" "m"))])]
14538 "TARGET_MULTIPLE"
9c6fdb46
DE
14539 "{lm|lmw} %1,%2"
14540 [(set_attr "type" "load_ux")])
6ae08853 14541
4ae234b0 14542(define_insn "*return_internal_<mode>"
e35b9579 14543 [(return)
4ae234b0
GK
14544 (use (match_operand:P 0 "register_operand" "lc"))]
14545 ""
cccf3bdc 14546 "b%T0"
9ebbca7d
GK
14547 [(set_attr "type" "jmpreg")])
14548
14549; FIXME: This would probably be somewhat simpler if the Cygnus sibcall
85d346f1 14550; stuff was in GCC. Oh, and "any_parallel_operand" is a bit flexible...
9ebbca7d 14551
f78c3290
NF
14552(define_insn "*restore_gpregs_<mode>"
14553 [(match_parallel 0 "any_parallel_operand"
14554 [(clobber (match_operand:P 1 "register_operand" "=l"))
14555 (use (match_operand:P 2 "symbol_ref_operand" "s"))
14556 (use (match_operand:P 3 "gpc_reg_operand" "r"))
14557 (set (match_operand:P 4 "gpc_reg_operand" "=r")
14558 (match_operand:P 5 "memory_operand" "m"))])]
14559 ""
14560 "bl %z2"
14561 [(set_attr "type" "branch")
14562 (set_attr "length" "4")])
14563
14564(define_insn "*return_and_restore_gpregs_<mode>"
14565 [(match_parallel 0 "any_parallel_operand"
14566 [(return)
14567 (clobber (match_operand:P 1 "register_operand" "=l"))
14568 (use (match_operand:P 2 "symbol_ref_operand" "s"))
14569 (use (match_operand:P 3 "gpc_reg_operand" "r"))
14570 (set (match_operand:P 4 "gpc_reg_operand" "=r")
14571 (match_operand:P 5 "memory_operand" "m"))])]
14572 ""
14573 "b %z2"
14574 [(set_attr "type" "branch")
14575 (set_attr "length" "4")])
14576
4ae234b0 14577(define_insn "*return_and_restore_fpregs_<mode>"
85d346f1 14578 [(match_parallel 0 "any_parallel_operand"
e35b9579 14579 [(return)
f78c3290
NF
14580 (clobber (match_operand:P 1 "register_operand" "=l"))
14581 (use (match_operand:P 2 "symbol_ref_operand" "s"))
14582 (use (match_operand:P 3 "gpc_reg_operand" "r"))
14583 (set (match_operand:DF 4 "gpc_reg_operand" "=f")
14584 (match_operand:DF 5 "memory_operand" "m"))])]
4ae234b0 14585 ""
f78c3290
NF
14586 "b %z2"
14587 [(set_attr "type" "branch")
14588 (set_attr "length" "4")])
9ebbca7d 14589
83720594
RH
14590; This is used in compiling the unwind routines.
14591(define_expand "eh_return"
34dc173c 14592 [(use (match_operand 0 "general_operand" ""))]
9ebbca7d
GK
14593 ""
14594 "
14595{
83720594 14596 if (TARGET_32BIT)
34dc173c 14597 emit_insn (gen_eh_set_lr_si (operands[0]));
9ebbca7d 14598 else
34dc173c 14599 emit_insn (gen_eh_set_lr_di (operands[0]));
9ebbca7d
GK
14600 DONE;
14601}")
14602
83720594 14603; We can't expand this before we know where the link register is stored.
4ae234b0
GK
14604(define_insn "eh_set_lr_<mode>"
14605 [(unspec_volatile [(match_operand:P 0 "register_operand" "r")]
615158e2 14606 UNSPECV_EH_RR)
4ae234b0
GK
14607 (clobber (match_scratch:P 1 "=&b"))]
14608 ""
83720594 14609 "#")
9ebbca7d
GK
14610
14611(define_split
615158e2 14612 [(unspec_volatile [(match_operand 0 "register_operand" "")] UNSPECV_EH_RR)
83720594
RH
14613 (clobber (match_scratch 1 ""))]
14614 "reload_completed"
14615 [(const_int 0)]
9ebbca7d
GK
14616 "
14617{
d1d0c603 14618 rs6000_emit_eh_reg_restore (operands[0], operands[1]);
83720594
RH
14619 DONE;
14620}")
0ac081f6 14621
01a2ccd0 14622(define_insn "prefetch"
3256a76e 14623 [(prefetch (match_operand 0 "indexed_or_indirect_address" "a")
6041bf2f
DE
14624 (match_operand:SI 1 "const_int_operand" "n")
14625 (match_operand:SI 2 "const_int_operand" "n"))]
01a2ccd0 14626 "TARGET_POWERPC"
6041bf2f
DE
14627 "*
14628{
01a2ccd0
DE
14629 if (GET_CODE (operands[0]) == REG)
14630 return INTVAL (operands[1]) ? \"dcbtst 0,%0\" : \"dcbt 0,%0\";
14631 return INTVAL (operands[1]) ? \"dcbtst %a0\" : \"dcbt %a0\";
6041bf2f
DE
14632}"
14633 [(set_attr "type" "load")])
915167f5 14634\f
a3170dc6 14635
f565b0a1 14636(include "sync.md")
10ed84db 14637(include "altivec.md")
a3170dc6 14638(include "spe.md")
7393f7f8 14639(include "dfp.md")
96038623 14640(include "paired.md")