rs6000.md (div<mode>3): Fix comment.
[platform/upstream/gcc.git] / gcc / config / rs6000 / rs6000.md
1 ;; Machine description for IBM RISC System 6000 (POWER) for GNU C compiler
2 ;; Copyright (C) 1990-2014 Free Software Foundation, Inc.
3 ;; Contributed by Richard Kenner (kenner@vlsi1.ultra.nyu.edu)
4
5 ;; This file is part of GCC.
6
7 ;; GCC is free software; you can redistribute it and/or modify it
8 ;; under the terms of the GNU General Public License as published
9 ;; by the Free Software Foundation; either version 3, or (at your
10 ;; option) any later version.
11
12 ;; GCC is distributed in the hope that it will be useful, but WITHOUT
13 ;; ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
14 ;; or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public
15 ;; License for more details.
16
17 ;; You should have received a copy of the GNU General Public License
18 ;; along with GCC; see the file COPYING3.  If not see
19 ;; <http://www.gnu.org/licenses/>.
20
21 ;;- See file "rtl.def" for documentation on define_insn, match_*, et. al.
22
23 ;;
24 ;; REGNOS
25 ;;
26
27 (define_constants
28   [(FIRST_GPR_REGNO             0)
29    (STACK_POINTER_REGNUM        1)
30    (TOC_REGNUM                  2)
31    (STATIC_CHAIN_REGNUM         11)
32    (HARD_FRAME_POINTER_REGNUM   31)
33    (LAST_GPR_REGNO              31)
34    (FIRST_FPR_REGNO             32)
35    (LAST_FPR_REGNO              63)
36    (LR_REGNO                    65)
37    (CTR_REGNO                   66)
38    (ARG_POINTER_REGNUM          67)
39    (CR0_REGNO                   68)
40    (CR1_REGNO                   69)
41    (CR2_REGNO                   70)
42    (CR3_REGNO                   71)
43    (CR4_REGNO                   72)
44    (CR5_REGNO                   73)
45    (CR6_REGNO                   74)
46    (CR7_REGNO                   75)
47    (MAX_CR_REGNO                75)
48    (CA_REGNO                    76)
49    (FIRST_ALTIVEC_REGNO         77)
50    (LAST_ALTIVEC_REGNO          108)
51    (VRSAVE_REGNO                109)
52    (VSCR_REGNO                  110)
53    (SPE_ACC_REGNO               111)
54    (SPEFSCR_REGNO               112)
55    (FRAME_POINTER_REGNUM        113)
56    (TFHAR_REGNO                 114)
57    (TFIAR_REGNO                 115)
58    (TEXASR_REGNO                116)
59    (FIRST_SPE_HIGH_REGNO        117)
60    (LAST_SPE_HIGH_REGNO         148)
61   ])
62
63 ;;
64 ;; UNSPEC usage
65 ;;
66
67 (define_c_enum "unspec"
68   [UNSPEC_FRSP                  ; frsp for POWER machines
69    UNSPEC_PROBE_STACK           ; probe stack memory reference
70    UNSPEC_TOCPTR                ; address of a word pointing to the TOC
71    UNSPEC_TOC                   ; address of the TOC (more-or-less)
72    UNSPEC_MOVSI_GOT
73    UNSPEC_MV_CR_OV              ; move_from_CR_ov_bit
74    UNSPEC_FCTIWZ
75    UNSPEC_FRIM
76    UNSPEC_FRIN
77    UNSPEC_FRIP
78    UNSPEC_FRIZ
79    UNSPEC_LD_MPIC               ; load_macho_picbase
80    UNSPEC_RELD_MPIC             ; re-load_macho_picbase
81    UNSPEC_MPIC_CORRECT          ; macho_correct_pic
82    UNSPEC_TLSGD
83    UNSPEC_TLSLD
84    UNSPEC_MOVESI_FROM_CR
85    UNSPEC_MOVESI_TO_CR
86    UNSPEC_TLSDTPREL
87    UNSPEC_TLSDTPRELHA
88    UNSPEC_TLSDTPRELLO
89    UNSPEC_TLSGOTDTPREL
90    UNSPEC_TLSTPREL
91    UNSPEC_TLSTPRELHA
92    UNSPEC_TLSTPRELLO
93    UNSPEC_TLSGOTTPREL
94    UNSPEC_TLSTLS
95    UNSPEC_FIX_TRUNC_TF          ; fadd, rounding towards zero
96    UNSPEC_MV_CR_GT              ; move_from_CR_gt_bit
97    UNSPEC_STFIWX
98    UNSPEC_POPCNTB
99    UNSPEC_FRES
100    UNSPEC_SP_SET
101    UNSPEC_SP_TEST
102    UNSPEC_SYNC
103    UNSPEC_LWSYNC
104    UNSPEC_SYNC_OP
105    UNSPEC_ATOMIC
106    UNSPEC_CMPXCHG
107    UNSPEC_XCHG
108    UNSPEC_AND
109    UNSPEC_DLMZB
110    UNSPEC_DLMZB_CR
111    UNSPEC_DLMZB_STRLEN
112    UNSPEC_RSQRT
113    UNSPEC_TOCREL
114    UNSPEC_MACHOPIC_OFFSET
115    UNSPEC_BPERM
116    UNSPEC_COPYSIGN
117    UNSPEC_PARITY
118    UNSPEC_FCTIW
119    UNSPEC_FCTID
120    UNSPEC_LFIWAX
121    UNSPEC_LFIWZX
122    UNSPEC_FCTIWUZ
123    UNSPEC_GRP_END_NOP
124    UNSPEC_P8V_FMRGOW
125    UNSPEC_P8V_MTVSRWZ
126    UNSPEC_P8V_RELOAD_FROM_GPR
127    UNSPEC_P8V_MTVSRD
128    UNSPEC_P8V_XXPERMDI
129    UNSPEC_P8V_RELOAD_FROM_VSX
130    UNSPEC_ADDG6S
131    UNSPEC_CDTBCD
132    UNSPEC_CBCDTD
133    UNSPEC_DIVE
134    UNSPEC_DIVEO
135    UNSPEC_DIVEU
136    UNSPEC_DIVEUO
137    UNSPEC_UNPACK_128BIT
138    UNSPEC_PACK_128BIT
139    UNSPEC_LSQ
140    UNSPEC_FUSION_GPR
141   ])
142
143 ;;
144 ;; UNSPEC_VOLATILE usage
145 ;;
146
147 (define_c_enum "unspecv"
148   [UNSPECV_BLOCK
149    UNSPECV_LL                   ; load-locked
150    UNSPECV_SC                   ; store-conditional
151    UNSPECV_PROBE_STACK_RANGE    ; probe range of stack addresses
152    UNSPECV_EH_RR                ; eh_reg_restore
153    UNSPECV_ISYNC                ; isync instruction
154    UNSPECV_MFTB                 ; move from time base
155    UNSPECV_NLGR                 ; non-local goto receiver
156    UNSPECV_MFFS                 ; Move from FPSCR
157    UNSPECV_MTFSF                ; Move to FPSCR Fields
158   ])
159
160 \f
161 ;; Define an insn type attribute.  This is used in function unit delay
162 ;; computations.
163 (define_attr "type"
164   "integer,two,three,
165    add,logical,shift,insert,
166    mul,halfmul,div,
167    exts,cntlz,popcnt,isel,
168    load,store,fpload,fpstore,vecload,vecstore,
169    cmp,
170    branch,jmpreg,mfjmpr,mtjmpr,trap,isync,sync,load_l,store_c,
171    compare,
172    cr_logical,delayed_cr,mfcr,mfcrf,mtcr,
173    fpcompare,fp,fpsimple,dmul,sdiv,ddiv,ssqrt,dsqrt,
174    brinc,
175    vecsimple,veccomplex,vecdiv,veccmp,veccmpsimple,vecperm,
176    vecfloat,vecfdiv,vecdouble,mffgpr,mftgpr,crypto,
177    htm"
178   (const_string "integer"))
179
180 ;; What data size does this instruction work on?
181 ;; This is used for insert, mul.
182 (define_attr "size" "8,16,32,64" (const_string "32"))
183
184 ;; Is this instruction record form ("dot", signed compare to 0, writing CR0)?
185 ;; This is used for add, logical, shift, exts, mul.
186 (define_attr "dot" "no,yes" (const_string "no"))
187
188 ;; Does this instruction sign-extend its result?
189 ;; This is used for load insns.
190 (define_attr "sign_extend" "no,yes" (const_string "no"))
191
192 ;; Does this instruction use indexed (that is, reg+reg) addressing?
193 ;; This is used for load and store insns.  If operand 0 or 1 is a MEM
194 ;; it is automatically set based on that.  If a load or store instruction
195 ;; has fewer than two operands it needs to set this attribute manually
196 ;; or the compiler will crash.
197 (define_attr "indexed" "no,yes"
198   (if_then_else (ior (match_operand 0 "indexed_address_mem")
199                      (match_operand 1 "indexed_address_mem"))
200                 (const_string "yes")
201                 (const_string "no")))
202
203 ;; Does this instruction use update addressing?
204 ;; This is used for load and store insns.  See the comments for "indexed".
205 (define_attr "update" "no,yes"
206   (if_then_else (ior (match_operand 0 "update_address_mem")
207                      (match_operand 1 "update_address_mem"))
208                 (const_string "yes")
209                 (const_string "no")))
210
211 ;; Is this instruction using operands[2] as shift amount, and can that be a
212 ;; register?
213 ;; This is used for shift insns.
214 (define_attr "maybe_var_shift" "no,yes" (const_string "no"))
215
216 ;; Is this instruction using a shift amount from a register?
217 ;; This is used for shift insns.
218 (define_attr "var_shift" "no,yes"
219   (if_then_else (and (eq_attr "type" "shift")
220                      (eq_attr "maybe_var_shift" "yes"))
221                 (if_then_else (match_operand 2 "gpc_reg_operand")
222                               (const_string "yes")
223                               (const_string "no"))
224                 (const_string "no")))
225
226 ;; Define floating point instruction sub-types for use with Xfpu.md
227 (define_attr "fp_type" "fp_default,fp_addsub_s,fp_addsub_d,fp_mul_s,fp_mul_d,fp_div_s,fp_div_d,fp_maddsub_s,fp_maddsub_d,fp_sqrt_s,fp_sqrt_d" (const_string "fp_default"))
228
229 ;; Length (in bytes).
230 ; '(pc)' in the following doesn't include the instruction itself; it is
231 ; calculated as if the instruction had zero size.
232 (define_attr "length" ""
233   (if_then_else (eq_attr "type" "branch")
234                 (if_then_else (and (ge (minus (match_dup 0) (pc))
235                                        (const_int -32768))
236                                    (lt (minus (match_dup 0) (pc))
237                                        (const_int 32764)))
238                               (const_int 4)
239                               (const_int 8))
240                 (const_int 4)))
241
242 ;; Processor type -- this attribute must exactly match the processor_type
243 ;; enumeration in rs6000-opts.h.
244 (define_attr "cpu"
245   "ppc601,ppc603,ppc604,ppc604e,ppc620,ppc630,
246    ppc750,ppc7400,ppc7450,
247    ppc403,ppc405,ppc440,ppc476,
248    ppc8540,ppc8548,ppce300c2,ppce300c3,ppce500mc,ppce500mc64,ppce5500,ppce6500,
249    power4,power5,power6,power7,power8,
250    rs64a,mpccore,cell,ppca2,titan"
251   (const (symbol_ref "rs6000_cpu_attr")))
252
253
254 ;; If this instruction is microcoded on the CELL processor
255 ; The default for load extended, the recorded instructions and rotate/shifts by a variable is always microcoded
256 (define_attr "cell_micro" "not,conditional,always"
257   (if_then_else (ior (eq_attr "type" "compare")
258                      (and (eq_attr "type" "shift,exts,mul")
259                           (eq_attr "dot" "yes"))
260                      (and (eq_attr "type" "load")
261                           (eq_attr "sign_extend" "yes"))
262                      (and (eq_attr "type" "shift")
263                           (eq_attr "var_shift" "yes")))
264                 (const_string "always")
265                 (const_string "not")))
266
267 (automata_option "ndfa")
268
269 (include "rs64.md")
270 (include "mpc.md")
271 (include "40x.md")
272 (include "440.md")
273 (include "476.md")
274 (include "601.md")
275 (include "603.md")
276 (include "6xx.md")
277 (include "7xx.md")
278 (include "7450.md")
279 (include "8540.md")
280 (include "e300c2c3.md")
281 (include "e500mc.md")
282 (include "e500mc64.md")
283 (include "e5500.md")
284 (include "e6500.md")
285 (include "power4.md")
286 (include "power5.md")
287 (include "power6.md")
288 (include "power7.md")
289 (include "power8.md")
290 (include "cell.md")
291 (include "xfpu.md")
292 (include "a2.md")
293 (include "titan.md")
294
295 (include "predicates.md")
296 (include "constraints.md")
297
298 (include "darwin.md")
299
300 \f
301 ;; Mode iterators
302
303 ; This mode iterator allows :GPR to be used to indicate the allowable size
304 ; of whole values in GPRs.
305 (define_mode_iterator GPR [SI (DI "TARGET_POWERPC64")])
306
307 ; Any supported integer mode.
308 (define_mode_iterator INT [QI HI SI DI TI PTI])
309
310 ; Any supported integer mode that fits in one register.
311 (define_mode_iterator INT1 [QI HI SI (DI "TARGET_POWERPC64")])
312
313 ; Everything we can extend QImode to.
314 (define_mode_iterator EXTQI [HI SI (DI "TARGET_POWERPC64")])
315
316 ; Everything we can extend HImode to.
317 (define_mode_iterator EXTHI [SI (DI "TARGET_POWERPC64")])
318
319 ; Everything we can extend SImode to.
320 (define_mode_iterator EXTSI [(DI "TARGET_POWERPC64")])
321
322 ; QImode or HImode for small atomic ops
323 (define_mode_iterator QHI [QI HI])
324
325 ; HImode or SImode for sign extended fusion ops
326 (define_mode_iterator HSI [HI SI])
327
328 ; SImode or DImode, even if DImode doesn't fit in GPRs.
329 (define_mode_iterator SDI [SI DI])
330
331 ; The size of a pointer.  Also, the size of the value that a record-condition
332 ; (one with a '.') will compare; and the size used for arithmetic carries.
333 (define_mode_iterator P [(SI "TARGET_32BIT") (DI "TARGET_64BIT")])
334
335 ; Iterator to add PTImode along with TImode (TImode can go in VSX registers,
336 ; PTImode is GPR only)
337 (define_mode_iterator TI2 [TI PTI])
338
339 ; Any hardware-supported floating-point mode
340 (define_mode_iterator FP [
341   (SF "TARGET_HARD_FLOAT 
342    && ((TARGET_FPRS && TARGET_SINGLE_FLOAT) || TARGET_E500_SINGLE)")
343   (DF "TARGET_HARD_FLOAT 
344    && ((TARGET_FPRS && TARGET_DOUBLE_FLOAT) || TARGET_E500_DOUBLE)")
345   (TF "!TARGET_IEEEQUAD
346    && TARGET_HARD_FLOAT
347    && (TARGET_FPRS || TARGET_E500_DOUBLE)
348    && TARGET_LONG_DOUBLE_128")
349   (DD "TARGET_DFP")
350   (TD "TARGET_DFP")])
351
352 ; Any fma capable floating-point mode.
353 (define_mode_iterator FMA_F [
354   (SF "TARGET_HARD_FLOAT && TARGET_FPRS && TARGET_SINGLE_FLOAT")
355   (DF "(TARGET_HARD_FLOAT && TARGET_FPRS && TARGET_DOUBLE_FLOAT)
356        || VECTOR_UNIT_VSX_P (DFmode)")
357   (V2SF "TARGET_PAIRED_FLOAT")
358   (V4SF "VECTOR_UNIT_ALTIVEC_OR_VSX_P (V4SFmode)")
359   (V2DF "VECTOR_UNIT_ALTIVEC_OR_VSX_P (V2DFmode)")
360   ])
361
362 ; Floating point move iterators to combine binary and decimal moves
363 (define_mode_iterator FMOVE32 [SF SD])
364 (define_mode_iterator FMOVE64 [DF DD])
365 (define_mode_iterator FMOVE64X [DI DF DD])
366 (define_mode_iterator FMOVE128 [(TF "!TARGET_IEEEQUAD && TARGET_LONG_DOUBLE_128")
367                                 (TD "TARGET_HARD_FLOAT && TARGET_FPRS")])
368
369 ; Iterators for 128 bit types for direct move
370 (define_mode_iterator FMOVE128_GPR [(TI    "TARGET_VSX_TIMODE")
371                                     (V16QI "")
372                                     (V8HI  "")
373                                     (V4SI  "")
374                                     (V4SF  "")
375                                     (V2DI  "")
376                                     (V2DF  "")
377                                     (V1TI  "")])
378
379 ; Whether a floating point move is ok, don't allow SD without hardware FP
380 (define_mode_attr fmove_ok [(SF "")
381                             (DF "")
382                             (SD "TARGET_HARD_FLOAT && TARGET_FPRS")
383                             (DD "")])
384
385 ; Convert REAL_VALUE to the appropriate bits
386 (define_mode_attr real_value_to_target [(SF "REAL_VALUE_TO_TARGET_SINGLE")
387                                         (DF "REAL_VALUE_TO_TARGET_DOUBLE")
388                                         (SD "REAL_VALUE_TO_TARGET_DECIMAL32")
389                                         (DD "REAL_VALUE_TO_TARGET_DECIMAL64")])
390
391 ; Definitions for load to 32-bit fpr register
392 (define_mode_attr f32_lr [(SF "f")               (SD "wz")])
393 (define_mode_attr f32_lm [(SF "m")               (SD "Z")])
394 (define_mode_attr f32_li [(SF "lfs%U1%X1 %0,%1") (SD "lfiwzx %0,%y1")])
395 (define_mode_attr f32_lv [(SF "lxsspx %x0,%y1")  (SD "lxsiwzx %x0,%y1")])
396
397 ; Definitions for store from 32-bit fpr register
398 (define_mode_attr f32_sr [(SF "f")                (SD "wx")])
399 (define_mode_attr f32_sm [(SF "m")                (SD "Z")])
400 (define_mode_attr f32_si [(SF "stfs%U0%X0 %1,%0") (SD "stfiwx %1,%y0")])
401 (define_mode_attr f32_sv [(SF "stxsspx %x1,%y0")  (SD "stxsiwzx %x1,%y0")])
402
403 ; Definitions for 32-bit fpr direct move
404 (define_mode_attr f32_dm [(SF "wn") (SD "wh")])
405
406 ; These modes do not fit in integer registers in 32-bit mode.
407 ; but on e500v2, the gpr are 64 bit registers
408 (define_mode_iterator DIFD [DI (DF "!TARGET_E500_DOUBLE") DD])
409
410 ; Iterator for reciprocal estimate instructions
411 (define_mode_iterator RECIPF [SF DF V4SF V2DF])
412
413 ; Iterator for just SF/DF
414 (define_mode_iterator SFDF [SF DF])
415
416 ; SF/DF suffix for traditional floating instructions
417 (define_mode_attr Ftrad         [(SF "s") (DF "")])
418
419 ; SF/DF suffix for VSX instructions
420 (define_mode_attr Fvsx          [(SF "sp") (DF  "dp")])
421
422 ; SF/DF constraint for arithmetic on traditional floating point registers
423 (define_mode_attr Ff            [(SF "f") (DF "d")])
424
425 ; SF/DF constraint for arithmetic on VSX registers
426 (define_mode_attr Fv            [(SF "wy") (DF "ws")])
427
428 ; s/d suffix for things like fp_addsub_s/fp_addsub_d
429 (define_mode_attr Fs            [(SF "s")  (DF "d")])
430
431 ; FRE/FRES support
432 (define_mode_attr Ffre          [(SF "fres") (DF "fre")])
433 (define_mode_attr FFRE          [(SF "FRES") (DF "FRE")])
434
435 ; Conditional returns.
436 (define_code_iterator any_return [return simple_return])
437 (define_code_attr return_pred [(return "direct_return ()")
438                                (simple_return "1")])
439 (define_code_attr return_str [(return "") (simple_return "simple_")])
440
441 ; Logical operators.
442 (define_code_iterator iorxor [ior xor])
443 (define_code_attr iorxor [(ior "ior") (xor "xor")])
444 (define_code_attr IORXOR [(ior "IOR") (xor "XOR")])
445
446 ; Signed/unsigned variants of ops.
447 (define_code_iterator any_extend [sign_extend zero_extend])
448 (define_code_attr u [(sign_extend "") (zero_extend "u")])
449 (define_code_attr su [(sign_extend "s") (zero_extend "u")])
450
451 ; Various instructions that come in SI and DI forms.
452 ; A generic w/d attribute, for things like cmpw/cmpd.
453 (define_mode_attr wd [(QI    "b")
454                       (HI    "h")
455                       (SI    "w")
456                       (DI    "d")
457                       (V16QI "b")
458                       (V8HI  "h")
459                       (V4SI  "w")
460                       (V2DI  "d")])
461
462 ;; How many bits in this mode?
463 (define_mode_attr bits [(QI "8") (HI "16") (SI "32") (DI "64")])
464
465 ; DImode bits
466 (define_mode_attr dbits [(QI "56") (HI "48") (SI "32")])
467
468 ;; ISEL/ISEL64 target selection
469 (define_mode_attr sel [(SI "") (DI "64")])
470
471 ;; Bitmask for shift instructions
472 (define_mode_attr hH [(SI "h") (DI "H")])
473
474 ;; A mode twice the size of the given mode
475 (define_mode_attr dmode [(SI "di") (DI "ti")])
476 (define_mode_attr DMODE [(SI "DI") (DI "TI")])
477
478 ;; Suffix for reload patterns
479 (define_mode_attr ptrsize [(SI "32bit")
480                            (DI "64bit")])
481
482 (define_mode_attr tptrsize [(SI "TARGET_32BIT")
483                             (DI "TARGET_64BIT")])
484
485 (define_mode_attr mptrsize [(SI "si")
486                             (DI "di")])
487
488 (define_mode_attr ptrload [(SI "lwz")
489                            (DI "ld")])
490
491 (define_mode_attr ptrm [(SI "m")
492                         (DI "Y")])
493
494 (define_mode_attr rreg [(SF   "f")
495                         (DF   "ws")
496                         (TF   "f")
497                         (TD   "f")
498                         (V4SF "wf")
499                         (V2DF "wd")])
500
501 (define_mode_attr rreg2 [(SF   "f")
502                          (DF   "d")])
503
504 (define_mode_attr SI_CONVERT_FP [(SF "TARGET_FCFIDS")
505                                  (DF "TARGET_FCFID")])
506
507 (define_mode_attr E500_CONVERT [(SF "!TARGET_FPRS")
508                                 (DF "TARGET_E500_DOUBLE")])
509
510 (define_mode_attr TARGET_FLOAT [(SF "TARGET_SINGLE_FLOAT")
511                                 (DF "TARGET_DOUBLE_FLOAT")])
512
513 ;; Mode iterator for logical operations on 128-bit types
514 (define_mode_iterator BOOL_128          [TI
515                                          PTI
516                                          (V16QI "TARGET_ALTIVEC")
517                                          (V8HI  "TARGET_ALTIVEC")
518                                          (V4SI  "TARGET_ALTIVEC")
519                                          (V4SF  "TARGET_ALTIVEC")
520                                          (V2DI  "TARGET_ALTIVEC")
521                                          (V2DF  "TARGET_ALTIVEC")
522                                          (V1TI  "TARGET_ALTIVEC")])
523
524 ;; For the GPRs we use 3 constraints for register outputs, two that are the
525 ;; same as the output register, and a third where the output register is an
526 ;; early clobber, so we don't have to deal with register overlaps.  For the
527 ;; vector types, we prefer to use the vector registers.  For TI mode, allow
528 ;; either.
529
530 ;; Mode attribute for boolean operation register constraints for output
531 (define_mode_attr BOOL_REGS_OUTPUT      [(TI    "&r,r,r,wa,v")
532                                          (PTI   "&r,r,r")
533                                          (V16QI "wa,v,&?r,?r,?r")
534                                          (V8HI  "wa,v,&?r,?r,?r")
535                                          (V4SI  "wa,v,&?r,?r,?r")
536                                          (V4SF  "wa,v,&?r,?r,?r")
537                                          (V2DI  "wa,v,&?r,?r,?r")
538                                          (V2DF  "wa,v,&?r,?r,?r")
539                                          (V1TI  "wa,v,&?r,?r,?r")])
540
541 ;; Mode attribute for boolean operation register constraints for operand1
542 (define_mode_attr BOOL_REGS_OP1         [(TI    "r,0,r,wa,v")
543                                          (PTI   "r,0,r")
544                                          (V16QI "wa,v,r,0,r")
545                                          (V8HI  "wa,v,r,0,r")
546                                          (V4SI  "wa,v,r,0,r")
547                                          (V4SF  "wa,v,r,0,r")
548                                          (V2DI  "wa,v,r,0,r")
549                                          (V2DF  "wa,v,r,0,r")
550                                          (V1TI  "wa,v,r,0,r")])
551
552 ;; Mode attribute for boolean operation register constraints for operand2
553 (define_mode_attr BOOL_REGS_OP2         [(TI    "r,r,0,wa,v")
554                                          (PTI   "r,r,0")
555                                          (V16QI "wa,v,r,r,0")
556                                          (V8HI  "wa,v,r,r,0")
557                                          (V4SI  "wa,v,r,r,0")
558                                          (V4SF  "wa,v,r,r,0")
559                                          (V2DI  "wa,v,r,r,0")
560                                          (V2DF  "wa,v,r,r,0")
561                                          (V1TI  "wa,v,r,r,0")])
562
563 ;; Mode attribute for boolean operation register constraints for operand1
564 ;; for one_cmpl.  To simplify things, we repeat the constraint where 0
565 ;; is used for operand1 or operand2
566 (define_mode_attr BOOL_REGS_UNARY       [(TI    "r,0,0,wa,v")
567                                          (PTI   "r,0,0")
568                                          (V16QI "wa,v,r,0,0")
569                                          (V8HI  "wa,v,r,0,0")
570                                          (V4SI  "wa,v,r,0,0")
571                                          (V4SF  "wa,v,r,0,0")
572                                          (V2DI  "wa,v,r,0,0")
573                                          (V2DF  "wa,v,r,0,0")
574                                          (V1TI  "wa,v,r,0,0")])
575 \f
576 ;; Start with fixed-point load and store insns.  Here we put only the more
577 ;; complex forms.  Basic data transfer is done later.
578
579 (define_insn "zero_extendqi<mode>2"
580   [(set (match_operand:EXTQI 0 "gpc_reg_operand" "=r,r")
581         (zero_extend:EXTQI (match_operand:QI 1 "reg_or_mem_operand" "m,r")))]
582   ""
583   "@
584    lbz%U1%X1 %0,%1
585    rlwinm %0,%1,0,0xff"
586   [(set_attr "type" "load,shift")])
587
588 (define_insn_and_split "*zero_extendqi<mode>2_dot"
589   [(set (match_operand:CC 2 "cc_reg_operand" "=x,?y")
590         (compare:CC (zero_extend:EXTQI (match_operand:QI 1 "gpc_reg_operand" "r,r"))
591                     (const_int 0)))
592    (clobber (match_scratch:EXTQI 0 "=r,r"))]
593   "rs6000_gen_cell_microcode"
594   "@
595    andi. %0,%1,0xff
596    #"
597   "&& reload_completed && cc_reg_not_cr0_operand (operands[2], CCmode)"
598   [(set (match_dup 0)
599         (zero_extend:EXTQI (match_dup 1)))
600    (set (match_dup 2)
601         (compare:CC (match_dup 0)
602                     (const_int 0)))]
603   ""
604   [(set_attr "type" "logical")
605    (set_attr "dot" "yes")
606    (set_attr "length" "4,8")])
607
608 (define_insn_and_split "*zero_extendqi<mode>2_dot2"
609   [(set (match_operand:CC 2 "cc_reg_operand" "=x,?y")
610         (compare:CC (zero_extend:EXTQI (match_operand:QI 1 "gpc_reg_operand" "r,r"))
611                     (const_int 0)))
612    (set (match_operand:EXTQI 0 "gpc_reg_operand" "=r,r")
613         (zero_extend:EXTQI (match_dup 1)))]
614   "rs6000_gen_cell_microcode"
615   "@
616    andi. %0,%1,0xff
617    #"
618   "&& reload_completed && cc_reg_not_cr0_operand (operands[2], CCmode)"
619   [(set (match_dup 0)
620         (zero_extend:EXTQI (match_dup 1)))
621    (set (match_dup 2)
622         (compare:CC (match_dup 0)
623                     (const_int 0)))]
624   ""
625   [(set_attr "type" "logical")
626    (set_attr "dot" "yes")
627    (set_attr "length" "4,8")])
628
629
630 (define_insn "zero_extendhi<mode>2"
631   [(set (match_operand:EXTHI 0 "gpc_reg_operand" "=r,r")
632         (zero_extend:EXTHI (match_operand:HI 1 "reg_or_mem_operand" "m,r")))]
633   ""
634   "@
635    lhz%U1%X1 %0,%1
636    rlwinm %0,%1,0,0xffff"
637   [(set_attr "type" "load,shift")])
638
639 (define_insn_and_split "*zero_extendhi<mode>2_dot"
640   [(set (match_operand:CC 2 "cc_reg_operand" "=x,?y")
641         (compare:CC (zero_extend:EXTHI (match_operand:HI 1 "gpc_reg_operand" "r,r"))
642                     (const_int 0)))
643    (clobber (match_scratch:EXTHI 0 "=r,r"))]
644   "rs6000_gen_cell_microcode"
645   "@
646    andi. %0,%1,0xffff
647    #"
648   "&& reload_completed && cc_reg_not_cr0_operand (operands[2], CCmode)"
649   [(set (match_dup 0)
650         (zero_extend:EXTHI (match_dup 1)))
651    (set (match_dup 2)
652         (compare:CC (match_dup 0)
653                     (const_int 0)))]
654   ""
655   [(set_attr "type" "logical")
656    (set_attr "dot" "yes")
657    (set_attr "length" "4,8")])
658
659 (define_insn_and_split "*zero_extendhi<mode>2_dot2"
660   [(set (match_operand:CC 2 "cc_reg_operand" "=x,?y")
661         (compare:CC (zero_extend:EXTHI (match_operand:HI 1 "gpc_reg_operand" "r,r"))
662                     (const_int 0)))
663    (set (match_operand:EXTHI 0 "gpc_reg_operand" "=r,r")
664         (zero_extend:EXTHI (match_dup 1)))]
665   "rs6000_gen_cell_microcode"
666   "@
667    andi. %0,%1,0xffff
668    #"
669   "&& reload_completed && cc_reg_not_cr0_operand (operands[2], CCmode)"
670   [(set (match_dup 0)
671         (zero_extend:EXTHI (match_dup 1)))
672    (set (match_dup 2)
673         (compare:CC (match_dup 0)
674                     (const_int 0)))]
675   ""
676   [(set_attr "type" "logical")
677    (set_attr "dot" "yes")
678    (set_attr "length" "4,8")])
679
680
681 (define_insn "zero_extendsi<mode>2"
682   [(set (match_operand:EXTSI 0 "gpc_reg_operand" "=r,r,??wj,!wz,!wu")
683         (zero_extend:EXTSI (match_operand:SI 1 "reg_or_mem_operand" "m,r,r,Z,Z")))]
684   ""
685   "@
686    lwz%U1%X1 %0,%1
687    rldicl %0,%1,0,32
688    mtvsrwz %x0,%1
689    lfiwzx %0,%y1
690    lxsiwzx %x0,%y1"
691   [(set_attr "type" "load,shift,mffgpr,fpload,fpload")])
692
693 (define_insn_and_split "*zero_extendsi<mode>2_dot"
694   [(set (match_operand:CC 2 "cc_reg_operand" "=x,?y")
695         (compare:CC (zero_extend:EXTSI (match_operand:SI 1 "gpc_reg_operand" "r,r"))
696                     (const_int 0)))
697    (clobber (match_scratch:EXTSI 0 "=r,r"))]
698   "rs6000_gen_cell_microcode"
699   "@
700    rldicl. %0,%1,0,32
701    #"
702   "&& reload_completed && cc_reg_not_cr0_operand (operands[2], CCmode)"
703   [(set (match_dup 0)
704         (zero_extend:DI (match_dup 1)))
705    (set (match_dup 2)
706         (compare:CC (match_dup 0)
707                     (const_int 0)))]
708   ""
709   [(set_attr "type" "shift")
710    (set_attr "dot" "yes")
711    (set_attr "length" "4,8")])
712
713 (define_insn_and_split "*zero_extendsi<mode>2_dot2"
714   [(set (match_operand:CC 2 "cc_reg_operand" "=x,?y")
715         (compare:CC (zero_extend:EXTSI (match_operand:SI 1 "gpc_reg_operand" "r,r"))
716                     (const_int 0)))
717    (set (match_operand:EXTSI 0 "gpc_reg_operand" "=r,r")
718         (zero_extend:EXTSI (match_dup 1)))]
719   "rs6000_gen_cell_microcode"
720   "@
721    rldicl. %0,%1,0,32
722    #"
723   "&& reload_completed && cc_reg_not_cr0_operand (operands[2], CCmode)"
724   [(set (match_dup 0)
725         (zero_extend:EXTSI (match_dup 1)))
726    (set (match_dup 2)
727         (compare:CC (match_dup 0)
728                     (const_int 0)))]
729   ""
730   [(set_attr "type" "shift")
731    (set_attr "dot" "yes")
732    (set_attr "length" "4,8")])
733
734
735 (define_insn "extendqi<mode>2"
736   [(set (match_operand:EXTQI 0 "gpc_reg_operand" "=r")
737         (sign_extend:EXTQI (match_operand:QI 1 "gpc_reg_operand" "r")))]
738   ""
739   "extsb %0,%1"
740   [(set_attr "type" "exts")])
741
742 (define_insn_and_split "*extendqi<mode>2_dot"
743   [(set (match_operand:CC 2 "cc_reg_operand" "=x,?y")
744         (compare:CC (sign_extend:EXTQI (match_operand:QI 1 "gpc_reg_operand" "r,r"))
745                     (const_int 0)))
746    (clobber (match_scratch:EXTQI 0 "=r,r"))]
747   "rs6000_gen_cell_microcode"
748   "@
749    extsb. %0,%1
750    #"
751   "&& reload_completed && cc_reg_not_cr0_operand (operands[2], CCmode)"
752   [(set (match_dup 0)
753         (sign_extend:EXTQI (match_dup 1)))
754    (set (match_dup 2)
755         (compare:CC (match_dup 0)
756                     (const_int 0)))]
757   ""
758   [(set_attr "type" "exts")
759    (set_attr "dot" "yes")
760    (set_attr "length" "4,8")])
761
762 (define_insn_and_split "*extendqi<mode>2_dot2"
763   [(set (match_operand:CC 2 "cc_reg_operand" "=x,?y")
764         (compare:CC (sign_extend:EXTQI (match_operand:QI 1 "gpc_reg_operand" "r,r"))
765                     (const_int 0)))
766    (set (match_operand:EXTQI 0 "gpc_reg_operand" "=r,r")
767         (sign_extend:EXTQI (match_dup 1)))]
768   "rs6000_gen_cell_microcode"
769   "@
770    extsb. %0,%1
771    #"
772   "&& reload_completed && cc_reg_not_cr0_operand (operands[2], CCmode)"
773   [(set (match_dup 0)
774         (sign_extend:EXTQI (match_dup 1)))
775    (set (match_dup 2)
776         (compare:CC (match_dup 0)
777                     (const_int 0)))]
778   ""
779   [(set_attr "type" "exts")
780    (set_attr "dot" "yes")
781    (set_attr "length" "4,8")])
782
783
784 (define_expand "extendhi<mode>2"
785   [(set (match_operand:EXTHI 0 "gpc_reg_operand" "")
786         (sign_extend:EXTHI (match_operand:HI 1 "gpc_reg_operand" "")))]
787   ""
788   "")
789
790 (define_insn "*extendhi<mode>2"
791   [(set (match_operand:EXTHI 0 "gpc_reg_operand" "=r,r")
792         (sign_extend:EXTHI (match_operand:HI 1 "reg_or_mem_operand" "m,r")))]
793   "rs6000_gen_cell_microcode"
794   "@
795    lha%U1%X1 %0,%1
796    extsh %0,%1"
797   [(set_attr "type" "load,exts")
798    (set_attr "sign_extend" "yes")])
799
800 (define_insn "*extendhi<mode>2_noload"
801   [(set (match_operand:EXTHI 0 "gpc_reg_operand" "=r")
802         (sign_extend:EXTHI (match_operand:HI 1 "gpc_reg_operand" "r")))]
803   "!rs6000_gen_cell_microcode"
804   "extsh %0,%1"
805   [(set_attr "type" "exts")])
806
807 (define_insn_and_split "*extendhi<mode>2_dot"
808   [(set (match_operand:CC 2 "cc_reg_operand" "=x,?y")
809         (compare:CC (sign_extend:EXTHI (match_operand:HI 1 "gpc_reg_operand" "r,r"))
810                     (const_int 0)))
811    (clobber (match_scratch:EXTHI 0 "=r,r"))]
812   "rs6000_gen_cell_microcode"
813   "@
814    extsh. %0,%1
815    #"
816   "&& reload_completed && cc_reg_not_cr0_operand (operands[2], CCmode)"
817   [(set (match_dup 0)
818         (sign_extend:EXTHI (match_dup 1)))
819    (set (match_dup 2)
820         (compare:CC (match_dup 0)
821                     (const_int 0)))]
822   ""
823   [(set_attr "type" "exts")
824    (set_attr "dot" "yes")
825    (set_attr "length" "4,8")])
826
827 (define_insn_and_split "*extendhi<mode>2_dot2"
828   [(set (match_operand:CC 2 "cc_reg_operand" "=x,?y")
829         (compare:CC (sign_extend:EXTHI (match_operand:HI 1 "gpc_reg_operand" "r,r"))
830                     (const_int 0)))
831    (set (match_operand:EXTHI 0 "gpc_reg_operand" "=r,r")
832         (sign_extend:EXTHI (match_dup 1)))]
833   "rs6000_gen_cell_microcode"
834   "@
835    extsh. %0,%1
836    #"
837   "&& reload_completed && cc_reg_not_cr0_operand (operands[2], CCmode)"
838   [(set (match_dup 0)
839         (sign_extend:EXTHI (match_dup 1)))
840    (set (match_dup 2)
841         (compare:CC (match_dup 0)
842                     (const_int 0)))]
843   ""
844   [(set_attr "type" "exts")
845    (set_attr "dot" "yes")
846    (set_attr "length" "4,8")])
847
848
849 (define_insn "extendsi<mode>2"
850   [(set (match_operand:EXTSI 0 "gpc_reg_operand" "=r,r,??wj,!wl,!wu")
851         (sign_extend:EXTSI (match_operand:SI 1 "lwa_operand" "Y,r,r,Z,Z")))]
852   ""
853   "@
854    lwa%U1%X1 %0,%1
855    extsw %0,%1
856    mtvsrwa %x0,%1
857    lfiwax %0,%y1
858    lxsiwax %x0,%y1"
859   [(set_attr "type" "load,exts,mffgpr,fpload,fpload")
860    (set_attr "sign_extend" "yes")])
861
862 (define_insn_and_split "*extendsi<mode>2_dot"
863   [(set (match_operand:CC 2 "cc_reg_operand" "=x,?y")
864         (compare:CC (sign_extend:EXTSI (match_operand:SI 1 "gpc_reg_operand" "r,r"))
865                     (const_int 0)))
866    (clobber (match_scratch:EXTSI 0 "=r,r"))]
867   "rs6000_gen_cell_microcode"
868   "@
869    extsw. %0,%1
870    #"
871   "&& reload_completed && cc_reg_not_cr0_operand (operands[2], CCmode)"
872   [(set (match_dup 0)
873         (sign_extend:EXTSI (match_dup 1)))
874    (set (match_dup 2)
875         (compare:CC (match_dup 0)
876                     (const_int 0)))]
877   ""
878   [(set_attr "type" "exts")
879    (set_attr "dot" "yes")
880    (set_attr "length" "4,8")])
881
882 (define_insn_and_split "*extendsi<mode>2_dot2"
883   [(set (match_operand:CC 2 "cc_reg_operand" "=x,?y")
884         (compare:CC (sign_extend:EXTSI (match_operand:SI 1 "gpc_reg_operand" "r,r"))
885                     (const_int 0)))
886    (set (match_operand:EXTSI 0 "gpc_reg_operand" "=r,r")
887         (sign_extend:EXTSI (match_dup 1)))]
888   "rs6000_gen_cell_microcode"
889   "@
890    extsw. %0,%1
891    #"
892   "&& reload_completed && cc_reg_not_cr0_operand (operands[2], CCmode)"
893   [(set (match_dup 0)
894         (sign_extend:EXTSI (match_dup 1)))
895    (set (match_dup 2)
896         (compare:CC (match_dup 0)
897                     (const_int 0)))]
898   ""
899   [(set_attr "type" "exts")
900    (set_attr "dot" "yes")
901    (set_attr "length" "4,8")])
902 \f
903 ;; IBM 405, 440, 464 and 476 half-word multiplication operations.
904
905 (define_insn "*macchwc"
906   [(set (match_operand:CC 3 "cc_reg_operand" "=x")
907         (compare:CC (plus:SI (mult:SI (ashiftrt:SI
908                                        (match_operand:SI 2 "gpc_reg_operand" "r")
909                                        (const_int 16))
910                                       (sign_extend:SI
911                                        (match_operand:HI 1 "gpc_reg_operand" "r")))
912                              (match_operand:SI 4 "gpc_reg_operand" "0"))
913                     (const_int 0)))
914    (set (match_operand:SI 0 "gpc_reg_operand" "=r")
915         (plus:SI (mult:SI (ashiftrt:SI
916                            (match_dup 2)
917                            (const_int 16))
918                           (sign_extend:SI
919                            (match_dup 1)))
920                  (match_dup 4)))]
921   "TARGET_MULHW"
922   "macchw. %0,%1,%2"
923   [(set_attr "type" "halfmul")])
924
925 (define_insn "*macchw"
926   [(set (match_operand:SI 0 "gpc_reg_operand" "=r")
927         (plus:SI (mult:SI (ashiftrt:SI
928                            (match_operand:SI 2 "gpc_reg_operand" "r")
929                            (const_int 16))
930                           (sign_extend:SI
931                            (match_operand:HI 1 "gpc_reg_operand" "r")))
932                  (match_operand:SI 3 "gpc_reg_operand" "0")))]
933   "TARGET_MULHW"
934   "macchw %0,%1,%2"
935   [(set_attr "type" "halfmul")])
936
937 (define_insn "*macchwuc"
938   [(set (match_operand:CC 3 "cc_reg_operand" "=x")
939         (compare:CC (plus:SI (mult:SI (lshiftrt:SI
940                                        (match_operand:SI 2 "gpc_reg_operand" "r")
941                                        (const_int 16))
942                                       (zero_extend:SI
943                                        (match_operand:HI 1 "gpc_reg_operand" "r")))
944                              (match_operand:SI 4 "gpc_reg_operand" "0"))
945                     (const_int 0)))
946    (set (match_operand:SI 0 "gpc_reg_operand" "=r")
947         (plus:SI (mult:SI (lshiftrt:SI
948                            (match_dup 2)
949                            (const_int 16))
950                           (zero_extend:SI
951                            (match_dup 1)))
952                  (match_dup 4)))]
953   "TARGET_MULHW"
954   "macchwu. %0,%1,%2"
955   [(set_attr "type" "halfmul")])
956
957 (define_insn "*macchwu"
958   [(set (match_operand:SI 0 "gpc_reg_operand" "=r")
959         (plus:SI (mult:SI (lshiftrt:SI
960                            (match_operand:SI 2 "gpc_reg_operand" "r")
961                            (const_int 16))
962                           (zero_extend:SI
963                            (match_operand:HI 1 "gpc_reg_operand" "r")))
964                  (match_operand:SI 3 "gpc_reg_operand" "0")))]
965   "TARGET_MULHW"
966   "macchwu %0,%1,%2"
967   [(set_attr "type" "halfmul")])
968
969 (define_insn "*machhwc"
970   [(set (match_operand:CC 3 "cc_reg_operand" "=x")
971         (compare:CC (plus:SI (mult:SI (ashiftrt:SI
972                                        (match_operand:SI 1 "gpc_reg_operand" "%r")
973                                        (const_int 16))
974                                       (ashiftrt:SI
975                                        (match_operand:SI 2 "gpc_reg_operand" "r")
976                                        (const_int 16)))
977                              (match_operand:SI 4 "gpc_reg_operand" "0"))
978                     (const_int 0)))
979    (set (match_operand:SI 0 "gpc_reg_operand" "=r")
980         (plus:SI (mult:SI (ashiftrt:SI
981                            (match_dup 1)
982                            (const_int 16))
983                           (ashiftrt:SI
984                            (match_dup 2)
985                            (const_int 16)))
986                  (match_dup 4)))]
987   "TARGET_MULHW"
988   "machhw. %0,%1,%2"
989   [(set_attr "type" "halfmul")])
990
991 (define_insn "*machhw"
992   [(set (match_operand:SI 0 "gpc_reg_operand" "=r")
993         (plus:SI (mult:SI (ashiftrt:SI
994                            (match_operand:SI 1 "gpc_reg_operand" "%r")
995                            (const_int 16))
996                           (ashiftrt:SI
997                            (match_operand:SI 2 "gpc_reg_operand" "r")
998                            (const_int 16)))
999                  (match_operand:SI 3 "gpc_reg_operand" "0")))]
1000   "TARGET_MULHW"
1001   "machhw %0,%1,%2"
1002   [(set_attr "type" "halfmul")])
1003
1004 (define_insn "*machhwuc"
1005   [(set (match_operand:CC 3 "cc_reg_operand" "=x")
1006         (compare:CC (plus:SI (mult:SI (lshiftrt:SI
1007                                        (match_operand:SI 1 "gpc_reg_operand" "%r")
1008                                        (const_int 16))
1009                                       (lshiftrt:SI
1010                                        (match_operand:SI 2 "gpc_reg_operand" "r")
1011                                        (const_int 16)))
1012                              (match_operand:SI 4 "gpc_reg_operand" "0"))
1013                     (const_int 0)))
1014    (set (match_operand:SI 0 "gpc_reg_operand" "=r")
1015         (plus:SI (mult:SI (lshiftrt:SI
1016                            (match_dup 1)
1017                            (const_int 16))
1018                           (lshiftrt:SI
1019                            (match_dup 2)
1020                            (const_int 16)))
1021                  (match_dup 4)))]
1022   "TARGET_MULHW"
1023   "machhwu. %0,%1,%2"
1024   [(set_attr "type" "halfmul")])
1025
1026 (define_insn "*machhwu"
1027   [(set (match_operand:SI 0 "gpc_reg_operand" "=r")
1028         (plus:SI (mult:SI (lshiftrt:SI
1029                            (match_operand:SI 1 "gpc_reg_operand" "%r")
1030                            (const_int 16))
1031                           (lshiftrt:SI
1032                            (match_operand:SI 2 "gpc_reg_operand" "r")
1033                            (const_int 16)))
1034                  (match_operand:SI 3 "gpc_reg_operand" "0")))]
1035   "TARGET_MULHW"
1036   "machhwu %0,%1,%2"
1037   [(set_attr "type" "halfmul")])
1038
1039 (define_insn "*maclhwc"
1040   [(set (match_operand:CC 3 "cc_reg_operand" "=x")
1041         (compare:CC (plus:SI (mult:SI (sign_extend:SI
1042                                        (match_operand:HI 1 "gpc_reg_operand" "%r"))
1043                                       (sign_extend:SI
1044                                        (match_operand:HI 2 "gpc_reg_operand" "r")))
1045                              (match_operand:SI 4 "gpc_reg_operand" "0"))
1046                     (const_int 0)))
1047    (set (match_operand:SI 0 "gpc_reg_operand" "=r")
1048         (plus:SI (mult:SI (sign_extend:SI
1049                            (match_dup 1))
1050                           (sign_extend:SI
1051                            (match_dup 2)))
1052                  (match_dup 4)))]
1053   "TARGET_MULHW"
1054   "maclhw. %0,%1,%2"
1055   [(set_attr "type" "halfmul")])
1056
1057 (define_insn "*maclhw"
1058   [(set (match_operand:SI 0 "gpc_reg_operand" "=r")
1059         (plus:SI (mult:SI (sign_extend:SI
1060                            (match_operand:HI 1 "gpc_reg_operand" "%r"))
1061                           (sign_extend:SI
1062                            (match_operand:HI 2 "gpc_reg_operand" "r")))
1063                  (match_operand:SI 3 "gpc_reg_operand" "0")))]
1064   "TARGET_MULHW"
1065   "maclhw %0,%1,%2"
1066   [(set_attr "type" "halfmul")])
1067
1068 (define_insn "*maclhwuc"
1069   [(set (match_operand:CC 3 "cc_reg_operand" "=x")
1070         (compare:CC (plus:SI (mult:SI (zero_extend:SI
1071                                        (match_operand:HI 1 "gpc_reg_operand" "%r"))
1072                                       (zero_extend:SI
1073                                        (match_operand:HI 2 "gpc_reg_operand" "r")))
1074                              (match_operand:SI 4 "gpc_reg_operand" "0"))
1075                     (const_int 0)))
1076    (set (match_operand:SI 0 "gpc_reg_operand" "=r")
1077         (plus:SI (mult:SI (zero_extend:SI
1078                            (match_dup 1))
1079                           (zero_extend:SI
1080                            (match_dup 2)))
1081                  (match_dup 4)))]
1082   "TARGET_MULHW"
1083   "maclhwu. %0,%1,%2"
1084   [(set_attr "type" "halfmul")])
1085
1086 (define_insn "*maclhwu"
1087   [(set (match_operand:SI 0 "gpc_reg_operand" "=r")
1088         (plus:SI (mult:SI (zero_extend:SI
1089                            (match_operand:HI 1 "gpc_reg_operand" "%r"))
1090                           (zero_extend:SI
1091                            (match_operand:HI 2 "gpc_reg_operand" "r")))
1092                  (match_operand:SI 3 "gpc_reg_operand" "0")))]
1093   "TARGET_MULHW"
1094   "maclhwu %0,%1,%2"
1095   [(set_attr "type" "halfmul")])
1096
1097 (define_insn "*nmacchwc"
1098   [(set (match_operand:CC 3 "cc_reg_operand" "=x")
1099         (compare:CC (minus:SI (match_operand:SI 4 "gpc_reg_operand" "0")
1100                               (mult:SI (ashiftrt:SI
1101                                         (match_operand:SI 2 "gpc_reg_operand" "r")
1102                                         (const_int 16))
1103                                        (sign_extend:SI
1104                                         (match_operand:HI 1 "gpc_reg_operand" "r"))))
1105                     (const_int 0)))
1106    (set (match_operand:SI 0 "gpc_reg_operand" "=r")
1107         (minus:SI (match_dup 4)
1108                   (mult:SI (ashiftrt:SI
1109                             (match_dup 2)
1110                             (const_int 16))
1111                            (sign_extend:SI
1112                             (match_dup 1)))))]
1113   "TARGET_MULHW"
1114   "nmacchw. %0,%1,%2"
1115   [(set_attr "type" "halfmul")])
1116
1117 (define_insn "*nmacchw"
1118   [(set (match_operand:SI 0 "gpc_reg_operand" "=r")
1119         (minus:SI (match_operand:SI 3 "gpc_reg_operand" "0")
1120                   (mult:SI (ashiftrt:SI
1121                             (match_operand:SI 2 "gpc_reg_operand" "r")
1122                             (const_int 16))
1123                            (sign_extend:SI
1124                             (match_operand:HI 1 "gpc_reg_operand" "r")))))]
1125   "TARGET_MULHW"
1126   "nmacchw %0,%1,%2"
1127   [(set_attr "type" "halfmul")])
1128
1129 (define_insn "*nmachhwc"
1130   [(set (match_operand:CC 3 "cc_reg_operand" "=x")
1131         (compare:CC (minus:SI (match_operand:SI 4 "gpc_reg_operand" "0")
1132                               (mult:SI (ashiftrt:SI
1133                                         (match_operand:SI 1 "gpc_reg_operand" "%r")
1134                                         (const_int 16))
1135                                        (ashiftrt:SI
1136                                         (match_operand:SI 2 "gpc_reg_operand" "r")
1137                                         (const_int 16))))
1138                     (const_int 0)))
1139    (set (match_operand:SI 0 "gpc_reg_operand" "=r")
1140         (minus:SI (match_dup 4)
1141                   (mult:SI (ashiftrt:SI
1142                             (match_dup 1)
1143                             (const_int 16))
1144                            (ashiftrt:SI
1145                             (match_dup 2)
1146                             (const_int 16)))))]
1147   "TARGET_MULHW"
1148   "nmachhw. %0,%1,%2"
1149   [(set_attr "type" "halfmul")])
1150
1151 (define_insn "*nmachhw"
1152   [(set (match_operand:SI 0 "gpc_reg_operand" "=r")
1153         (minus:SI (match_operand:SI 3 "gpc_reg_operand" "0")
1154                   (mult:SI (ashiftrt:SI
1155                             (match_operand:SI 1 "gpc_reg_operand" "%r")
1156                             (const_int 16))
1157                            (ashiftrt:SI
1158                             (match_operand:SI 2 "gpc_reg_operand" "r")
1159                             (const_int 16)))))]
1160   "TARGET_MULHW"
1161   "nmachhw %0,%1,%2"
1162   [(set_attr "type" "halfmul")])
1163
1164 (define_insn "*nmaclhwc"
1165   [(set (match_operand:CC 3 "cc_reg_operand" "=x")
1166         (compare:CC (minus:SI (match_operand:SI 4 "gpc_reg_operand" "0")
1167                               (mult:SI (sign_extend:SI
1168                                         (match_operand:HI 1 "gpc_reg_operand" "%r"))
1169                                        (sign_extend:SI
1170                                         (match_operand:HI 2 "gpc_reg_operand" "r"))))
1171                     (const_int 0)))
1172    (set (match_operand:SI 0 "gpc_reg_operand" "=r")
1173         (minus:SI (match_dup 4)
1174                   (mult:SI (sign_extend:SI
1175                             (match_dup 1))
1176                            (sign_extend:SI
1177                             (match_dup 2)))))]
1178   "TARGET_MULHW"
1179   "nmaclhw. %0,%1,%2"
1180   [(set_attr "type" "halfmul")])
1181
1182 (define_insn "*nmaclhw"
1183   [(set (match_operand:SI 0 "gpc_reg_operand" "=r")
1184         (minus:SI (match_operand:SI 3 "gpc_reg_operand" "0")
1185                   (mult:SI (sign_extend:SI
1186                             (match_operand:HI 1 "gpc_reg_operand" "%r"))
1187                            (sign_extend:SI
1188                             (match_operand:HI 2 "gpc_reg_operand" "r")))))]
1189   "TARGET_MULHW"
1190   "nmaclhw %0,%1,%2"
1191   [(set_attr "type" "halfmul")])
1192
1193 (define_insn "*mulchwc"
1194   [(set (match_operand:CC 3 "cc_reg_operand" "=x")
1195         (compare:CC (mult:SI (ashiftrt:SI
1196                               (match_operand:SI 2 "gpc_reg_operand" "r")
1197                               (const_int 16))
1198                              (sign_extend:SI
1199                               (match_operand:HI 1 "gpc_reg_operand" "r")))
1200                     (const_int 0)))
1201    (set (match_operand:SI 0 "gpc_reg_operand" "=r")
1202         (mult:SI (ashiftrt:SI
1203                   (match_dup 2)
1204                   (const_int 16))
1205                  (sign_extend:SI
1206                   (match_dup 1))))]
1207   "TARGET_MULHW"
1208   "mulchw. %0,%1,%2"
1209   [(set_attr "type" "halfmul")])
1210
1211 (define_insn "*mulchw"
1212   [(set (match_operand:SI 0 "gpc_reg_operand" "=r")
1213         (mult:SI (ashiftrt:SI
1214                   (match_operand:SI 2 "gpc_reg_operand" "r")
1215                   (const_int 16))
1216                  (sign_extend:SI
1217                   (match_operand:HI 1 "gpc_reg_operand" "r"))))]
1218   "TARGET_MULHW"
1219   "mulchw %0,%1,%2"
1220   [(set_attr "type" "halfmul")])
1221
1222 (define_insn "*mulchwuc"
1223   [(set (match_operand:CC 3 "cc_reg_operand" "=x")
1224         (compare:CC (mult:SI (lshiftrt:SI
1225                               (match_operand:SI 2 "gpc_reg_operand" "r")
1226                               (const_int 16))
1227                              (zero_extend:SI
1228                               (match_operand:HI 1 "gpc_reg_operand" "r")))
1229                     (const_int 0)))
1230    (set (match_operand:SI 0 "gpc_reg_operand" "=r")
1231         (mult:SI (lshiftrt:SI
1232                   (match_dup 2)
1233                   (const_int 16))
1234                  (zero_extend:SI
1235                   (match_dup 1))))]
1236   "TARGET_MULHW"
1237   "mulchwu. %0,%1,%2"
1238   [(set_attr "type" "halfmul")])
1239
1240 (define_insn "*mulchwu"
1241   [(set (match_operand:SI 0 "gpc_reg_operand" "=r")
1242         (mult:SI (lshiftrt:SI
1243                   (match_operand:SI 2 "gpc_reg_operand" "r")
1244                   (const_int 16))
1245                  (zero_extend:SI
1246                   (match_operand:HI 1 "gpc_reg_operand" "r"))))]
1247   "TARGET_MULHW"
1248   "mulchwu %0,%1,%2"
1249   [(set_attr "type" "halfmul")])
1250
1251 (define_insn "*mulhhwc"
1252   [(set (match_operand:CC 3 "cc_reg_operand" "=x")
1253         (compare:CC (mult:SI (ashiftrt:SI
1254                               (match_operand:SI 1 "gpc_reg_operand" "%r")
1255                               (const_int 16))
1256                              (ashiftrt:SI
1257                               (match_operand:SI 2 "gpc_reg_operand" "r")
1258                               (const_int 16)))
1259                     (const_int 0)))
1260    (set (match_operand:SI 0 "gpc_reg_operand" "=r")
1261         (mult:SI (ashiftrt:SI
1262                   (match_dup 1)
1263                   (const_int 16))
1264                  (ashiftrt:SI
1265                   (match_dup 2)
1266                   (const_int 16))))]
1267   "TARGET_MULHW"
1268   "mulhhw. %0,%1,%2"
1269   [(set_attr "type" "halfmul")])
1270
1271 (define_insn "*mulhhw"
1272   [(set (match_operand:SI 0 "gpc_reg_operand" "=r")
1273         (mult:SI (ashiftrt:SI
1274                   (match_operand:SI 1 "gpc_reg_operand" "%r")
1275                   (const_int 16))
1276                  (ashiftrt:SI
1277                   (match_operand:SI 2 "gpc_reg_operand" "r")
1278                   (const_int 16))))]
1279   "TARGET_MULHW"
1280   "mulhhw %0,%1,%2"
1281   [(set_attr "type" "halfmul")])
1282
1283 (define_insn "*mulhhwuc"
1284   [(set (match_operand:CC 3 "cc_reg_operand" "=x")
1285         (compare:CC (mult:SI (lshiftrt:SI
1286                               (match_operand:SI 1 "gpc_reg_operand" "%r")
1287                               (const_int 16))
1288                              (lshiftrt:SI
1289                               (match_operand:SI 2 "gpc_reg_operand" "r")
1290                               (const_int 16)))
1291                     (const_int 0)))
1292    (set (match_operand:SI 0 "gpc_reg_operand" "=r")
1293         (mult:SI (lshiftrt:SI
1294                   (match_dup 1)
1295                   (const_int 16))
1296                  (lshiftrt:SI
1297                   (match_dup 2)
1298                   (const_int 16))))]
1299   "TARGET_MULHW"
1300   "mulhhwu. %0,%1,%2"
1301   [(set_attr "type" "halfmul")])
1302
1303 (define_insn "*mulhhwu"
1304   [(set (match_operand:SI 0 "gpc_reg_operand" "=r")
1305         (mult:SI (lshiftrt:SI
1306                   (match_operand:SI 1 "gpc_reg_operand" "%r")
1307                   (const_int 16))
1308                  (lshiftrt:SI
1309                   (match_operand:SI 2 "gpc_reg_operand" "r")
1310                   (const_int 16))))]
1311   "TARGET_MULHW"
1312   "mulhhwu %0,%1,%2"
1313   [(set_attr "type" "halfmul")])
1314
1315 (define_insn "*mullhwc"
1316   [(set (match_operand:CC 3 "cc_reg_operand" "=x")
1317         (compare:CC (mult:SI (sign_extend:SI
1318                               (match_operand:HI 1 "gpc_reg_operand" "%r"))
1319                              (sign_extend:SI
1320                               (match_operand:HI 2 "gpc_reg_operand" "r")))
1321                     (const_int 0)))
1322    (set (match_operand:SI 0 "gpc_reg_operand" "=r")
1323         (mult:SI (sign_extend:SI
1324                   (match_dup 1))
1325                  (sign_extend:SI
1326                   (match_dup 2))))]
1327   "TARGET_MULHW"
1328   "mullhw. %0,%1,%2"
1329   [(set_attr "type" "halfmul")])
1330
1331 (define_insn "*mullhw"
1332   [(set (match_operand:SI 0 "gpc_reg_operand" "=r")
1333         (mult:SI (sign_extend:SI
1334                   (match_operand:HI 1 "gpc_reg_operand" "%r"))
1335                  (sign_extend:SI
1336                   (match_operand:HI 2 "gpc_reg_operand" "r"))))]
1337   "TARGET_MULHW"
1338   "mullhw %0,%1,%2"
1339   [(set_attr "type" "halfmul")])
1340
1341 (define_insn "*mullhwuc"
1342   [(set (match_operand:CC 3 "cc_reg_operand" "=x")
1343         (compare:CC (mult:SI (zero_extend:SI
1344                               (match_operand:HI 1 "gpc_reg_operand" "%r"))
1345                              (zero_extend:SI
1346                               (match_operand:HI 2 "gpc_reg_operand" "r")))
1347                     (const_int 0)))
1348    (set (match_operand:SI 0 "gpc_reg_operand" "=r")
1349         (mult:SI (zero_extend:SI
1350                   (match_dup 1))
1351                  (zero_extend:SI
1352                   (match_dup 2))))]
1353   "TARGET_MULHW"
1354   "mullhwu. %0,%1,%2"
1355   [(set_attr "type" "halfmul")])
1356
1357 (define_insn "*mullhwu"
1358   [(set (match_operand:SI 0 "gpc_reg_operand" "=r")
1359         (mult:SI (zero_extend:SI
1360                   (match_operand:HI 1 "gpc_reg_operand" "%r"))
1361                  (zero_extend:SI
1362                   (match_operand:HI 2 "gpc_reg_operand" "r"))))]
1363   "TARGET_MULHW"
1364   "mullhwu %0,%1,%2"
1365   [(set_attr "type" "halfmul")])
1366 \f
1367 ;; IBM 405, 440, 464 and 476 string-search dlmzb instruction support.
1368 (define_insn "dlmzb"
1369   [(set (match_operand:CC 3 "cc_reg_operand" "=x")
1370         (unspec:CC [(match_operand:SI 1 "gpc_reg_operand" "r")
1371                     (match_operand:SI 2 "gpc_reg_operand" "r")]
1372                    UNSPEC_DLMZB_CR))
1373    (set (match_operand:SI 0 "gpc_reg_operand" "=r")
1374         (unspec:SI [(match_dup 1)
1375                     (match_dup 2)]
1376                    UNSPEC_DLMZB))]
1377   "TARGET_DLMZB"
1378   "dlmzb. %0,%1,%2")
1379
1380 (define_expand "strlensi"
1381   [(set (match_operand:SI 0 "gpc_reg_operand" "")
1382         (unspec:SI [(match_operand:BLK 1 "general_operand" "")
1383                     (match_operand:QI 2 "const_int_operand" "")
1384                     (match_operand 3 "const_int_operand" "")]
1385                    UNSPEC_DLMZB_STRLEN))
1386    (clobber (match_scratch:CC 4 "=x"))]
1387   "TARGET_DLMZB && WORDS_BIG_ENDIAN && !optimize_size"
1388 {
1389   rtx result = operands[0];
1390   rtx src = operands[1];
1391   rtx search_char = operands[2];
1392   rtx align = operands[3];
1393   rtx addr, scratch_string, word1, word2, scratch_dlmzb;
1394   rtx loop_label, end_label, mem, cr0, cond;
1395   if (search_char != const0_rtx
1396       || GET_CODE (align) != CONST_INT
1397       || INTVAL (align) < 8)
1398         FAIL;
1399   word1 = gen_reg_rtx (SImode);
1400   word2 = gen_reg_rtx (SImode);
1401   scratch_dlmzb = gen_reg_rtx (SImode);
1402   scratch_string = gen_reg_rtx (Pmode);
1403   loop_label = gen_label_rtx ();
1404   end_label = gen_label_rtx ();
1405   addr = force_reg (Pmode, XEXP (src, 0));
1406   emit_move_insn (scratch_string, addr);
1407   emit_label (loop_label);
1408   mem = change_address (src, SImode, scratch_string);
1409   emit_move_insn (word1, mem);
1410   emit_move_insn (word2, adjust_address (mem, SImode, 4));
1411   cr0 = gen_rtx_REG (CCmode, CR0_REGNO);
1412   emit_insn (gen_dlmzb (scratch_dlmzb, word1, word2, cr0));
1413   cond = gen_rtx_NE (VOIDmode, cr0, const0_rtx);
1414   emit_jump_insn (gen_rtx_SET (VOIDmode,
1415                                pc_rtx,
1416                                gen_rtx_IF_THEN_ELSE (VOIDmode,
1417                                                      cond,
1418                                                      gen_rtx_LABEL_REF
1419                                                        (VOIDmode,
1420                                                         end_label),
1421                                                      pc_rtx)));
1422   emit_insn (gen_addsi3 (scratch_string, scratch_string, GEN_INT (8)));
1423   emit_jump_insn (gen_rtx_SET (VOIDmode,
1424                                pc_rtx,
1425                                gen_rtx_LABEL_REF (VOIDmode, loop_label)));
1426   emit_barrier ();
1427   emit_label (end_label);
1428   emit_insn (gen_addsi3 (scratch_string, scratch_string, scratch_dlmzb));
1429   emit_insn (gen_subsi3 (result, scratch_string, addr));
1430   emit_insn (gen_addsi3 (result, result, constm1_rtx));
1431   DONE;
1432 })
1433 \f
1434 ;; Fixed-point arithmetic insns.
1435
1436 (define_expand "add<mode>3"
1437   [(set (match_operand:SDI 0 "gpc_reg_operand" "")
1438         (plus:SDI (match_operand:SDI 1 "gpc_reg_operand" "")
1439                   (match_operand:SDI 2 "reg_or_add_cint_operand" "")))]
1440   ""
1441 {
1442   if (<MODE>mode == DImode && ! TARGET_POWERPC64)
1443     {
1444       if (non_short_cint_operand (operands[2], DImode))
1445         FAIL;
1446     }
1447   else if (GET_CODE (operands[2]) == CONST_INT
1448            && ! add_operand (operands[2], <MODE>mode))
1449     {
1450       rtx tmp = ((!can_create_pseudo_p ()
1451                   || rtx_equal_p (operands[0], operands[1]))
1452                  ? operands[0] : gen_reg_rtx (<MODE>mode));
1453
1454       HOST_WIDE_INT val = INTVAL (operands[2]);
1455       HOST_WIDE_INT low = ((val & 0xffff) ^ 0x8000) - 0x8000;
1456       HOST_WIDE_INT rest = trunc_int_for_mode (val - low, <MODE>mode);
1457
1458       if (<MODE>mode == DImode && !satisfies_constraint_L (GEN_INT (rest)))
1459         FAIL;
1460
1461       /* The ordering here is important for the prolog expander.
1462          When space is allocated from the stack, adding 'low' first may
1463          produce a temporary deallocation (which would be bad).  */
1464       emit_insn (gen_add<mode>3 (tmp, operands[1], GEN_INT (rest)));
1465       emit_insn (gen_add<mode>3 (operands[0], tmp, GEN_INT (low)));
1466       DONE;
1467     }
1468 })
1469
1470 ;; Discourage ai/addic because of carry but provide it in an alternative
1471 ;; allowing register zero as source.
1472 (define_insn "*add<mode>3_internal1"
1473   [(set (match_operand:GPR 0 "gpc_reg_operand" "=r,r,?r,r")
1474         (plus:GPR (match_operand:GPR 1 "gpc_reg_operand" "%r,b,r,b")
1475                   (match_operand:GPR 2 "add_operand" "r,I,I,L")))]
1476   "!DECIMAL_FLOAT_MODE_P (GET_MODE (operands[0])) && !DECIMAL_FLOAT_MODE_P (GET_MODE (operands[1]))"
1477   "@
1478    add %0,%1,%2
1479    addi %0,%1,%2
1480    addic %0,%1,%2
1481    addis %0,%1,%v2"
1482   [(set_attr "type" "add")])
1483
1484 (define_insn "addsi3_high"
1485   [(set (match_operand:SI 0 "gpc_reg_operand" "=b")
1486         (plus:SI (match_operand:SI 1 "gpc_reg_operand" "b")
1487                  (high:SI (match_operand 2 "" ""))))]
1488   "TARGET_MACHO && !TARGET_64BIT"
1489   "addis %0,%1,ha16(%2)"
1490   [(set_attr "type" "add")])
1491
1492 (define_insn "*add<mode>3_internal2"
1493   [(set (match_operand:CC 0 "cc_reg_operand" "=x,x,?y,?y")
1494         (compare:CC (plus:P (match_operand:P 1 "gpc_reg_operand" "%r,r,r,r")
1495                             (match_operand:P 2 "reg_or_short_operand" "r,I,r,I"))
1496                     (const_int 0)))
1497    (clobber (match_scratch:P 3 "=r,r,r,r"))]
1498   ""
1499   "@
1500    add. %3,%1,%2
1501    addic. %3,%1,%2
1502    #
1503    #"
1504   [(set_attr "type" "add,compare,compare,compare")
1505    (set_attr "dot" "yes")
1506    (set_attr "length" "4,4,8,8")])
1507
1508 (define_split
1509   [(set (match_operand:CC 0 "cc_reg_not_cr0_operand" "")
1510         (compare:CC (plus:GPR (match_operand:GPR 1 "gpc_reg_operand" "")
1511                               (match_operand:GPR 2 "reg_or_short_operand" ""))
1512                     (const_int 0)))
1513    (clobber (match_scratch:GPR 3 ""))]
1514   "reload_completed"
1515   [(set (match_dup 3)
1516         (plus:GPR (match_dup 1)
1517                  (match_dup 2)))
1518    (set (match_dup 0)
1519         (compare:CC (match_dup 3)
1520                     (const_int 0)))]
1521   "")
1522
1523 (define_insn "*add<mode>3_internal3"
1524   [(set (match_operand:CC 3 "cc_reg_operand" "=x,x,?y,?y")
1525         (compare:CC (plus:P (match_operand:P 1 "gpc_reg_operand" "%r,r,r,r")
1526                             (match_operand:P 2 "reg_or_short_operand" "r,I,r,I"))
1527                     (const_int 0)))
1528    (set (match_operand:P 0 "gpc_reg_operand" "=r,r,r,r")
1529         (plus:P (match_dup 1)
1530                 (match_dup 2)))]
1531   ""
1532   "@
1533    add. %0,%1,%2
1534    addic. %0,%1,%2
1535    #
1536    #"
1537   [(set_attr "type" "add,compare,compare,compare")
1538    (set_attr "dot" "yes")
1539    (set_attr "length" "4,4,8,8")])
1540
1541 (define_split
1542   [(set (match_operand:CC 3 "cc_reg_not_cr0_operand" "")
1543         (compare:CC (plus:P (match_operand:P 1 "gpc_reg_operand" "")
1544                             (match_operand:P 2 "reg_or_short_operand" ""))
1545                     (const_int 0)))
1546    (set (match_operand:P 0 "gpc_reg_operand" "")
1547         (plus:P (match_dup 1) (match_dup 2)))]
1548   "reload_completed"
1549   [(set (match_dup 0)
1550         (plus:P (match_dup 1)
1551                 (match_dup 2)))
1552    (set (match_dup 3)
1553         (compare:CC (match_dup 0)
1554                     (const_int 0)))]
1555   "")
1556
1557 ;; Split an add that we can't do in one insn into two insns, each of which
1558 ;; does one 16-bit part.  This is used by combine.  Note that the low-order
1559 ;; add should be last in case the result gets used in an address.
1560
1561 (define_split
1562   [(set (match_operand:GPR 0 "gpc_reg_operand" "")
1563         (plus:GPR (match_operand:GPR 1 "gpc_reg_operand" "")
1564                   (match_operand:GPR 2 "non_add_cint_operand" "")))]
1565   ""
1566   [(set (match_dup 0) (plus:GPR (match_dup 1) (match_dup 3)))
1567    (set (match_dup 0) (plus:GPR (match_dup 0) (match_dup 4)))]
1568 {
1569   HOST_WIDE_INT val = INTVAL (operands[2]);
1570   HOST_WIDE_INT low = ((val & 0xffff) ^ 0x8000) - 0x8000;
1571   HOST_WIDE_INT rest = trunc_int_for_mode (val - low, <MODE>mode);
1572
1573   operands[4] = GEN_INT (low);
1574   if (<MODE>mode == SImode || satisfies_constraint_L (GEN_INT (rest)))
1575     operands[3] = GEN_INT (rest);
1576   else if (can_create_pseudo_p ())
1577     {
1578       operands[3] = gen_reg_rtx (DImode);
1579       emit_move_insn (operands[3], operands[2]);
1580       emit_insn (gen_adddi3 (operands[0], operands[1], operands[3]));
1581       DONE;
1582     }
1583   else
1584     FAIL;
1585 })
1586
1587 (define_expand "one_cmpl<mode>2"
1588   [(set (match_operand:SDI 0 "gpc_reg_operand" "")
1589         (not:SDI (match_operand:SDI 1 "gpc_reg_operand" "")))]
1590   ""
1591 {
1592   if (<MODE>mode == DImode && !TARGET_POWERPC64)
1593     {
1594       rs6000_split_logical (operands, NOT, false, false, false);
1595       DONE;
1596     }
1597 })
1598
1599 (define_insn "*one_cmpl<mode>2"
1600   [(set (match_operand:GPR 0 "gpc_reg_operand" "=r")
1601         (not:GPR (match_operand:GPR 1 "gpc_reg_operand" "r")))]
1602   ""
1603   "not %0,%1")
1604
1605 (define_insn_and_split "*one_cmpl<mode>2_dot"
1606   [(set (match_operand:CC 2 "cc_reg_operand" "=x,?y")
1607         (compare:CC (not:GPR (match_operand:GPR 1 "gpc_reg_operand" "r,r"))
1608                     (const_int 0)))
1609    (clobber (match_scratch:GPR 0 "=r,r"))]
1610   "<MODE>mode == Pmode && rs6000_gen_cell_microcode"
1611   "@
1612    not. %0,%1
1613    #"
1614   "&& reload_completed && cc_reg_not_cr0_operand (operands[2], CCmode)"
1615   [(set (match_dup 0)
1616         (not:GPR (match_dup 1)))
1617    (set (match_dup 2)
1618         (compare:CC (match_dup 0)
1619                     (const_int 0)))]
1620   ""
1621   [(set_attr "type" "logical")
1622    (set_attr "dot" "yes")
1623    (set_attr "length" "4,8")])
1624
1625 (define_insn_and_split "*one_cmpl<mode>2_dot2"
1626   [(set (match_operand:CC 2 "cc_reg_operand" "=x,?y")
1627         (compare:CC (not:GPR (match_operand:GPR 1 "gpc_reg_operand" "r,r"))
1628                     (const_int 0)))
1629    (set (match_operand:GPR 0 "gpc_reg_operand" "=r,r")
1630         (not:GPR (match_dup 1)))]
1631   "<MODE>mode == Pmode && rs6000_gen_cell_microcode"
1632   "@
1633    not. %0,%1
1634    #"
1635   "&& reload_completed && cc_reg_not_cr0_operand (operands[2], CCmode)"
1636   [(set (match_dup 0)
1637         (not:GPR (match_dup 1)))
1638    (set (match_dup 2)
1639         (compare:CC (match_dup 0)
1640                     (const_int 0)))]
1641   ""
1642   [(set_attr "type" "logical")
1643    (set_attr "dot" "yes")
1644    (set_attr "length" "4,8")])
1645
1646
1647 (define_expand "sub<mode>3"
1648   [(set (match_operand:SDI 0 "gpc_reg_operand" "")
1649         (minus:SDI (match_operand:SDI 1 "reg_or_short_operand" "")
1650                    (match_operand:SDI 2 "gpc_reg_operand" "")))]
1651   ""
1652 {
1653   if (short_cint_operand (operands[1], <MODE>mode)
1654       && !(<MODE>mode == DImode && !TARGET_POWERPC64))
1655     {
1656       emit_insn (gen_subf<mode>3_imm (operands[0], operands[2], operands[1]));
1657       DONE;
1658     }
1659 })
1660
1661 (define_insn "*subf<mode>3"
1662   [(set (match_operand:GPR 0 "gpc_reg_operand" "=r")
1663         (minus:GPR (match_operand:GPR 2 "gpc_reg_operand" "r")
1664                    (match_operand:GPR 1 "gpc_reg_operand" "r")))]
1665   ""
1666   "subf %0,%1,%2"
1667   [(set_attr "type" "add")])
1668
1669 (define_insn_and_split "*subf<mode>3_dot"
1670   [(set (match_operand:CC 3 "cc_reg_operand" "=x,?y")
1671         (compare:CC (minus:GPR (match_operand:GPR 2 "gpc_reg_operand" "r,r")
1672                                (match_operand:GPR 1 "gpc_reg_operand" "r,r"))
1673                     (const_int 0)))
1674    (clobber (match_scratch:GPR 0 "=r,r"))]
1675   "<MODE>mode == Pmode"
1676   "@
1677    subf. %0,%1,%2
1678    #"
1679   "&& reload_completed && cc_reg_not_cr0_operand (operands[3], CCmode)"
1680   [(set (match_dup 0)
1681         (minus:GPR (match_dup 2)
1682                    (match_dup 1)))
1683    (set (match_dup 3)
1684         (compare:CC (match_dup 0)
1685                     (const_int 0)))]
1686   ""
1687   [(set_attr "type" "add")
1688    (set_attr "dot" "yes")
1689    (set_attr "length" "4,8")])
1690
1691 (define_insn_and_split "*subf<mode>3_dot2"
1692   [(set (match_operand:CC 3 "cc_reg_operand" "=x,?y")
1693         (compare:CC (minus:GPR (match_operand:GPR 2 "gpc_reg_operand" "r,r")
1694                                (match_operand:GPR 1 "gpc_reg_operand" "r,r"))
1695                     (const_int 0)))
1696    (set (match_operand:GPR 0 "gpc_reg_operand" "=r,r")
1697         (minus:GPR (match_dup 2)
1698                    (match_dup 1)))]
1699   "<MODE>mode == Pmode"
1700   "@
1701    subf. %0,%1,%2
1702    #"
1703   "&& reload_completed && cc_reg_not_cr0_operand (operands[3], CCmode)"
1704   [(set (match_dup 0)
1705         (minus:GPR (match_dup 2)
1706                    (match_dup 1)))
1707    (set (match_dup 3)
1708         (compare:CC (match_dup 0)
1709                     (const_int 0)))]
1710   ""
1711   [(set_attr "type" "add")
1712    (set_attr "dot" "yes")
1713    (set_attr "length" "4,8")])
1714
1715 (define_insn "subf<mode>3_imm"
1716   [(set (match_operand:GPR 0 "gpc_reg_operand" "=r")
1717         (minus:GPR (match_operand:GPR 2 "short_cint_operand" "I")
1718                    (match_operand:GPR 1 "gpc_reg_operand" "r")))
1719    (clobber (reg:GPR CA_REGNO))]
1720   ""
1721   "subfic %0,%1,%2"
1722   [(set_attr "type" "add")])
1723
1724
1725 (define_expand "neg<mode>2"
1726   [(set (match_operand:SDI 0 "gpc_reg_operand" "")
1727         (neg:SDI (match_operand:SDI 1 "gpc_reg_operand" "")))]
1728   ""
1729   "")
1730
1731 (define_insn "*neg<mode>2"
1732   [(set (match_operand:GPR 0 "gpc_reg_operand" "=r")
1733         (neg:GPR (match_operand:GPR 1 "gpc_reg_operand" "r")))]
1734   ""
1735   "neg %0,%1"
1736   [(set_attr "type" "add")])
1737
1738 (define_insn_and_split "*neg<mode>2_dot"
1739   [(set (match_operand:CC 2 "cc_reg_operand" "=x,?y")
1740         (compare:CC (neg:GPR (match_operand:GPR 1 "gpc_reg_operand" "r,r"))
1741                     (const_int 0)))
1742    (clobber (match_scratch:GPR 0 "=r,r"))]
1743   "<MODE>mode == Pmode"
1744   "@
1745    neg. %0,%1
1746    #"
1747   "&& reload_completed && cc_reg_not_cr0_operand (operands[2], CCmode)"
1748   [(set (match_dup 0)
1749         (neg:GPR (match_dup 1)))
1750    (set (match_dup 2)
1751         (compare:CC (match_dup 0)
1752                     (const_int 0)))]
1753   ""
1754   [(set_attr "type" "add")
1755    (set_attr "dot" "yes")
1756    (set_attr "length" "4,8")])
1757
1758 (define_insn_and_split "*neg<mode>2_dot2"
1759   [(set (match_operand:CC 2 "cc_reg_operand" "=x,?y")
1760         (compare:CC (neg:GPR (match_operand:GPR 1 "gpc_reg_operand" "r,r"))
1761                     (const_int 0)))
1762    (set (match_operand:GPR 0 "gpc_reg_operand" "=r,r")
1763         (neg:GPR (match_dup 1)))]
1764   "<MODE>mode == Pmode"
1765   "@
1766    neg. %0,%1
1767    #"
1768   "&& reload_completed && cc_reg_not_cr0_operand (operands[2], CCmode)"
1769   [(set (match_dup 0)
1770         (neg:GPR (match_dup 1)))
1771    (set (match_dup 2)
1772         (compare:CC (match_dup 0)
1773                     (const_int 0)))]
1774   ""
1775   [(set_attr "type" "add")
1776    (set_attr "dot" "yes")
1777    (set_attr "length" "4,8")])
1778
1779
1780 (define_insn "clz<mode>2"
1781   [(set (match_operand:GPR 0 "gpc_reg_operand" "=r")
1782         (clz:GPR (match_operand:GPR 1 "gpc_reg_operand" "r")))]
1783   ""
1784   "cntlz<wd> %0,%1"
1785   [(set_attr "type" "cntlz")])
1786
1787 (define_expand "ctz<mode>2"
1788   [(set (match_dup 2)
1789         (neg:GPR (match_operand:GPR 1 "gpc_reg_operand" "")))
1790    (set (match_dup 3)
1791         (and:GPR (match_dup 1)
1792                  (match_dup 2)))
1793    (set (match_dup 4)
1794         (clz:GPR (match_dup 3)))
1795    (parallel [(set (match_operand:GPR 0 "gpc_reg_operand" "")
1796                    (minus:GPR (match_dup 5)
1797                               (match_dup 4)))
1798               (clobber (reg:GPR CA_REGNO))])]
1799   ""
1800 {
1801   operands[2] = gen_reg_rtx (<MODE>mode);
1802   operands[3] = gen_reg_rtx (<MODE>mode);
1803   operands[4] = gen_reg_rtx (<MODE>mode);
1804   operands[5] = GEN_INT (GET_MODE_BITSIZE (<MODE>mode) - 1);
1805 })
1806
1807 (define_expand "ffs<mode>2"
1808   [(set (match_dup 2)
1809         (neg:GPR (match_operand:GPR 1 "gpc_reg_operand" "")))
1810    (set (match_dup 3)
1811         (and:GPR (match_dup 1)
1812                  (match_dup 2)))
1813    (set (match_dup 4)
1814         (clz:GPR (match_dup 3)))
1815    (parallel [(set (match_operand:GPR 0 "gpc_reg_operand" "")
1816                    (minus:GPR (match_dup 5)
1817                               (match_dup 4)))
1818               (clobber (reg:GPR CA_REGNO))])]
1819   ""
1820 {
1821   operands[2] = gen_reg_rtx (<MODE>mode);
1822   operands[3] = gen_reg_rtx (<MODE>mode);
1823   operands[4] = gen_reg_rtx (<MODE>mode);
1824   operands[5] = GEN_INT (GET_MODE_BITSIZE (<MODE>mode));
1825 })
1826
1827
1828 (define_expand "popcount<mode>2"
1829   [(set (match_operand:GPR 0 "gpc_reg_operand" "")
1830         (popcount:GPR (match_operand:GPR 1 "gpc_reg_operand" "")))]
1831   "TARGET_POPCNTB || TARGET_POPCNTD"
1832 {
1833   rs6000_emit_popcount (operands[0], operands[1]);
1834   DONE;
1835 })
1836
1837 (define_insn "popcntb<mode>2"
1838   [(set (match_operand:GPR 0 "gpc_reg_operand" "=r")
1839         (unspec:GPR [(match_operand:GPR 1 "gpc_reg_operand" "r")]
1840                     UNSPEC_POPCNTB))]
1841   "TARGET_POPCNTB"
1842   "popcntb %0,%1"
1843   [(set_attr "type" "popcnt")])
1844
1845 (define_insn "popcntd<mode>2"
1846   [(set (match_operand:GPR 0 "gpc_reg_operand" "=r")
1847         (popcount:GPR (match_operand:GPR 1 "gpc_reg_operand" "r")))]
1848   "TARGET_POPCNTD"
1849   "popcnt<wd> %0,%1"
1850   [(set_attr "type" "popcnt")])
1851
1852
1853 (define_expand "parity<mode>2"
1854   [(set (match_operand:GPR 0 "gpc_reg_operand" "")
1855         (parity:GPR (match_operand:GPR 1 "gpc_reg_operand" "")))]
1856   "TARGET_POPCNTB"
1857 {
1858   rs6000_emit_parity (operands[0], operands[1]);
1859   DONE;
1860 })
1861
1862 (define_insn "parity<mode>2_cmpb"
1863   [(set (match_operand:GPR 0 "gpc_reg_operand" "=r")
1864         (unspec:GPR [(match_operand:GPR 1 "gpc_reg_operand" "r")] UNSPEC_PARITY))]
1865   "TARGET_CMPB && TARGET_POPCNTB"
1866   "prty<wd> %0,%1"
1867   [(set_attr "type" "popcnt")])
1868
1869
1870 ;; Since the hardware zeros the upper part of the register, save generating the
1871 ;; AND immediate if we are converting to unsigned
1872 (define_insn "*bswaphi2_extenddi"
1873   [(set (match_operand:DI 0 "gpc_reg_operand" "=r")
1874         (zero_extend:DI
1875          (bswap:HI (match_operand:HI 1 "memory_operand" "Z"))))]
1876   "TARGET_POWERPC64"
1877   "lhbrx %0,%y1"
1878   [(set_attr "length" "4")
1879    (set_attr "type" "load")])
1880
1881 (define_insn "*bswaphi2_extendsi"
1882   [(set (match_operand:SI 0 "gpc_reg_operand" "=r")
1883         (zero_extend:SI
1884          (bswap:HI (match_operand:HI 1 "memory_operand" "Z"))))]
1885   ""
1886   "lhbrx %0,%y1"
1887   [(set_attr "length" "4")
1888    (set_attr "type" "load")])
1889
1890 (define_expand "bswaphi2"
1891   [(parallel [(set (match_operand:HI 0 "reg_or_mem_operand" "")
1892                    (bswap:HI
1893                     (match_operand:HI 1 "reg_or_mem_operand" "")))
1894               (clobber (match_scratch:SI 2 ""))])]
1895   ""
1896 {
1897   if (!REG_P (operands[0]) && !REG_P (operands[1]))
1898     operands[1] = force_reg (HImode, operands[1]);
1899 })
1900
1901 (define_insn "bswaphi2_internal"
1902   [(set (match_operand:HI 0 "reg_or_mem_operand" "=r,Z,&r")
1903         (bswap:HI
1904          (match_operand:HI 1 "reg_or_mem_operand" "Z,r,r")))
1905    (clobber (match_scratch:SI 2 "=X,X,&r"))]
1906   ""
1907   "@
1908    lhbrx %0,%y1
1909    sthbrx %1,%y0
1910    #"
1911   [(set_attr "length" "4,4,12")
1912    (set_attr "type" "load,store,*")])
1913
1914 ;; We are always BITS_BIG_ENDIAN, so the (const_int 16) below is
1915 ;; correct for -mlittle as well as -mbig.
1916 (define_split
1917   [(set (match_operand:HI 0 "gpc_reg_operand" "")
1918         (bswap:HI (match_operand:HI 1 "gpc_reg_operand" "")))
1919    (clobber (match_operand:SI 2 "gpc_reg_operand" ""))]
1920   "reload_completed"
1921   [(set (match_dup 3)
1922         (zero_extract:SI (match_dup 4)
1923                          (const_int 8)
1924                          (const_int 16)))
1925    (set (match_dup 2)
1926         (and:SI (ashift:SI (match_dup 4)
1927                            (const_int 8))
1928                 (const_int 65280)))             ;; 0xff00
1929    (set (match_dup 3)
1930         (ior:SI (match_dup 3)
1931                 (match_dup 2)))]
1932   "
1933 {
1934   operands[3] = simplify_gen_subreg (SImode, operands[0], HImode, 0);
1935   operands[4] = simplify_gen_subreg (SImode, operands[1], HImode, 0);
1936 }")
1937
1938 (define_insn "*bswapsi2_extenddi"
1939   [(set (match_operand:DI 0 "gpc_reg_operand" "=r")
1940         (zero_extend:DI
1941          (bswap:SI (match_operand:SI 1 "memory_operand" "Z"))))]
1942   "TARGET_POWERPC64"
1943   "lwbrx %0,%y1"
1944   [(set_attr "length" "4")
1945    (set_attr "type" "load")])
1946
1947 (define_expand "bswapsi2"
1948   [(set (match_operand:SI 0 "reg_or_mem_operand" "")
1949         (bswap:SI
1950          (match_operand:SI 1 "reg_or_mem_operand" "")))]
1951   ""
1952 {
1953   if (!REG_P (operands[0]) && !REG_P (operands[1]))
1954     operands[1] = force_reg (SImode, operands[1]);
1955 })
1956
1957 (define_insn "*bswapsi2_internal"
1958   [(set (match_operand:SI 0 "reg_or_mem_operand" "=r,Z,&r")
1959         (bswap:SI
1960          (match_operand:SI 1 "reg_or_mem_operand" "Z,r,r")))]
1961   ""
1962   "@
1963    lwbrx %0,%y1
1964    stwbrx %1,%y0
1965    #"
1966   [(set_attr "length" "4,4,12")
1967    (set_attr "type" "load,store,*")])
1968
1969 ;; We are always BITS_BIG_ENDIAN, so the bit positions below in
1970 ;; zero_extract insns do not change for -mlittle.
1971 (define_split
1972   [(set (match_operand:SI 0 "gpc_reg_operand" "")
1973         (bswap:SI (match_operand:SI 1 "gpc_reg_operand" "")))]
1974   "reload_completed"
1975   [(set (match_dup 0)
1976         (rotate:SI (match_dup 1) (const_int 8)))
1977    (set (zero_extract:SI (match_dup 0)
1978                          (const_int 8)
1979                          (const_int 0))
1980         (match_dup 1))
1981    (set (zero_extract:SI (match_dup 0)
1982                          (const_int 8)
1983                          (const_int 16))
1984         (rotate:SI (match_dup 1)
1985                    (const_int 16)))]
1986   "")
1987
1988 (define_expand "bswapdi2"
1989   [(parallel [(set (match_operand:DI 0 "reg_or_mem_operand" "")
1990                    (bswap:DI
1991                     (match_operand:DI 1 "reg_or_mem_operand" "")))
1992               (clobber (match_scratch:DI 2 ""))
1993               (clobber (match_scratch:DI 3 ""))
1994               (clobber (match_scratch:DI 4 ""))])]
1995   ""
1996 {
1997   if (!REG_P (operands[0]) && !REG_P (operands[1]))
1998     operands[1] = force_reg (DImode, operands[1]);
1999
2000   if (!TARGET_POWERPC64)
2001     {
2002       /* 32-bit mode needs fewer scratch registers, but 32-bit addressing mode
2003          that uses 64-bit registers needs the same scratch registers as 64-bit
2004          mode.  */
2005       emit_insn (gen_bswapdi2_32bit (operands[0], operands[1]));
2006       DONE;
2007     }
2008 })
2009
2010 ;; Power7/cell has ldbrx/stdbrx, so use it directly
2011 (define_insn "*bswapdi2_ldbrx"
2012   [(set (match_operand:DI 0 "reg_or_mem_operand" "=&r,Z,??&r")
2013         (bswap:DI (match_operand:DI 1 "reg_or_mem_operand" "Z,r,r")))
2014    (clobber (match_scratch:DI 2 "=X,X,&r"))
2015    (clobber (match_scratch:DI 3 "=X,X,&r"))
2016    (clobber (match_scratch:DI 4 "=X,X,&r"))]
2017   "TARGET_POWERPC64 && TARGET_LDBRX
2018    && (REG_P (operands[0]) || REG_P (operands[1]))"
2019   "@
2020    ldbrx %0,%y1
2021    stdbrx %1,%y0
2022    #"
2023   [(set_attr "length" "4,4,36")
2024    (set_attr "type" "load,store,*")])
2025
2026 ;; Non-power7/cell, fall back to use lwbrx/stwbrx
2027 (define_insn "*bswapdi2_64bit"
2028   [(set (match_operand:DI 0 "reg_or_mem_operand" "=&r,Z,&r")
2029         (bswap:DI (match_operand:DI 1 "reg_or_mem_operand" "Z,r,r")))
2030    (clobber (match_scratch:DI 2 "=&b,&b,&r"))
2031    (clobber (match_scratch:DI 3 "=&r,&r,&r"))
2032    (clobber (match_scratch:DI 4 "=&r,X,&r"))]
2033   "TARGET_POWERPC64 && !TARGET_LDBRX
2034    && (REG_P (operands[0]) || REG_P (operands[1]))
2035    && !(MEM_P (operands[0]) && MEM_VOLATILE_P (operands[0]))
2036    && !(MEM_P (operands[1]) && MEM_VOLATILE_P (operands[1]))"
2037   "#"
2038   [(set_attr "length" "16,12,36")])
2039
2040 (define_split
2041   [(set (match_operand:DI 0 "gpc_reg_operand" "")
2042         (bswap:DI (match_operand:DI 1 "indexed_or_indirect_operand" "")))
2043    (clobber (match_operand:DI 2 "gpc_reg_operand" ""))
2044    (clobber (match_operand:DI 3 "gpc_reg_operand" ""))
2045    (clobber (match_operand:DI 4 "gpc_reg_operand" ""))]
2046   "TARGET_POWERPC64 && !TARGET_LDBRX && reload_completed"
2047   [(const_int 0)]
2048   "
2049 {
2050   rtx dest   = operands[0];
2051   rtx src    = operands[1];
2052   rtx op2    = operands[2];
2053   rtx op3    = operands[3];
2054   rtx op4    = operands[4];
2055   rtx op3_32 = simplify_gen_subreg (SImode, op3, DImode,
2056                                     BYTES_BIG_ENDIAN ? 4 : 0);
2057   rtx op4_32 = simplify_gen_subreg (SImode, op4, DImode,
2058                                     BYTES_BIG_ENDIAN ? 4 : 0);
2059   rtx addr1;
2060   rtx addr2;
2061   rtx word_high;
2062   rtx word_low;
2063
2064   addr1 = XEXP (src, 0);
2065   if (GET_CODE (addr1) == PLUS)
2066     {
2067       emit_insn (gen_add3_insn (op2, XEXP (addr1, 0), GEN_INT (4)));
2068       if (TARGET_AVOID_XFORM)
2069         {
2070           emit_insn (gen_add3_insn (op2, XEXP (addr1, 1), op2));
2071           addr2 = op2;
2072         }
2073       else
2074         addr2 = gen_rtx_PLUS (Pmode, op2, XEXP (addr1, 1));
2075     }
2076   else if (TARGET_AVOID_XFORM)
2077     {
2078       emit_insn (gen_add3_insn (op2, addr1, GEN_INT (4)));
2079       addr2 = op2;
2080     }
2081   else
2082     {
2083       emit_move_insn (op2, GEN_INT (4));
2084       addr2 = gen_rtx_PLUS (Pmode, op2, addr1);
2085     }
2086
2087   if (BYTES_BIG_ENDIAN)
2088     {
2089       word_high = change_address (src, SImode, addr1);
2090       word_low  = change_address (src, SImode, addr2);
2091     }
2092   else
2093     {
2094       word_high = change_address (src, SImode, addr2);
2095       word_low  = change_address (src, SImode, addr1);
2096     }
2097
2098   emit_insn (gen_bswapsi2 (op3_32, word_low));
2099   emit_insn (gen_bswapsi2 (op4_32, word_high));
2100   emit_insn (gen_ashldi3 (dest, op3, GEN_INT (32)));
2101   emit_insn (gen_iordi3 (dest, dest, op4));
2102   DONE;
2103 }")
2104
2105 (define_split
2106   [(set (match_operand:DI 0 "indexed_or_indirect_operand" "")
2107         (bswap:DI (match_operand:DI 1 "gpc_reg_operand" "")))
2108    (clobber (match_operand:DI 2 "gpc_reg_operand" ""))
2109    (clobber (match_operand:DI 3 "gpc_reg_operand" ""))
2110    (clobber (match_operand:DI 4 "" ""))]
2111   "TARGET_POWERPC64 && !TARGET_LDBRX && reload_completed"
2112   [(const_int 0)]
2113   "
2114 {
2115   rtx dest   = operands[0];
2116   rtx src    = operands[1];
2117   rtx op2    = operands[2];
2118   rtx op3    = operands[3];
2119   rtx src_si = simplify_gen_subreg (SImode, src, DImode,
2120                                     BYTES_BIG_ENDIAN ? 4 : 0);
2121   rtx op3_si = simplify_gen_subreg (SImode, op3, DImode,
2122                                     BYTES_BIG_ENDIAN ? 4 : 0);
2123   rtx addr1;
2124   rtx addr2;
2125   rtx word_high;
2126   rtx word_low;
2127
2128   addr1 = XEXP (dest, 0);
2129   if (GET_CODE (addr1) == PLUS)
2130     {
2131       emit_insn (gen_add3_insn (op2, XEXP (addr1, 0), GEN_INT (4)));
2132       if (TARGET_AVOID_XFORM)
2133         {
2134           emit_insn (gen_add3_insn (op2, XEXP (addr1, 1), op2));
2135           addr2 = op2;
2136         }
2137       else
2138         addr2 = gen_rtx_PLUS (Pmode, op2, XEXP (addr1, 1));
2139     }
2140   else if (TARGET_AVOID_XFORM)
2141     {
2142       emit_insn (gen_add3_insn (op2, addr1, GEN_INT (4)));
2143       addr2 = op2;
2144     }
2145   else
2146     {
2147       emit_move_insn (op2, GEN_INT (4));
2148       addr2 = gen_rtx_PLUS (Pmode, op2, addr1);
2149     }
2150
2151   emit_insn (gen_lshrdi3 (op3, src, GEN_INT (32)));
2152   if (BYTES_BIG_ENDIAN)
2153     {
2154       word_high = change_address (dest, SImode, addr1);
2155       word_low  = change_address (dest, SImode, addr2);
2156     }
2157   else
2158     {
2159       word_high = change_address (dest, SImode, addr2);
2160       word_low  = change_address (dest, SImode, addr1);
2161     }
2162   emit_insn (gen_bswapsi2 (word_high, src_si));
2163   emit_insn (gen_bswapsi2 (word_low, op3_si));
2164   DONE;
2165 }")
2166
2167 (define_split
2168   [(set (match_operand:DI 0 "gpc_reg_operand" "")
2169         (bswap:DI (match_operand:DI 1 "gpc_reg_operand" "")))
2170    (clobber (match_operand:DI 2 "gpc_reg_operand" ""))
2171    (clobber (match_operand:DI 3 "gpc_reg_operand" ""))
2172    (clobber (match_operand:DI 4 "" ""))]
2173   "TARGET_POWERPC64 && reload_completed"
2174   [(const_int 0)]
2175   "
2176 {
2177   rtx dest    = operands[0];
2178   rtx src     = operands[1];
2179   rtx op2     = operands[2];
2180   rtx op3     = operands[3];
2181   int lo_off  = BYTES_BIG_ENDIAN ? 4 : 0;
2182   rtx dest_si = simplify_gen_subreg (SImode, dest, DImode, lo_off);
2183   rtx src_si  = simplify_gen_subreg (SImode, src, DImode, lo_off);
2184   rtx op2_si  = simplify_gen_subreg (SImode, op2, DImode, lo_off);
2185   rtx op3_si  = simplify_gen_subreg (SImode, op3, DImode, lo_off);
2186
2187   emit_insn (gen_lshrdi3 (op2, src, GEN_INT (32)));
2188   emit_insn (gen_bswapsi2 (dest_si, src_si));
2189   emit_insn (gen_bswapsi2 (op3_si, op2_si));
2190   emit_insn (gen_ashldi3 (dest, dest, GEN_INT (32)));
2191   emit_insn (gen_iordi3 (dest, dest, op3));
2192   DONE;
2193 }")
2194
2195 (define_insn "bswapdi2_32bit"
2196   [(set (match_operand:DI 0 "reg_or_mem_operand" "=&r,Z,&r")
2197         (bswap:DI (match_operand:DI 1 "reg_or_mem_operand" "Z,r,r")))
2198    (clobber (match_scratch:SI 2 "=&b,&b,X"))]
2199   "!TARGET_POWERPC64 && (REG_P (operands[0]) || REG_P (operands[1]))"
2200   "#"
2201   [(set_attr "length" "16,12,36")])
2202
2203 (define_split
2204   [(set (match_operand:DI 0 "gpc_reg_operand" "")
2205         (bswap:DI (match_operand:DI 1 "indexed_or_indirect_operand" "")))
2206    (clobber (match_operand:SI 2 "gpc_reg_operand" ""))]
2207   "!TARGET_POWERPC64 && reload_completed"
2208   [(const_int 0)]
2209   "
2210 {
2211   rtx dest  = operands[0];
2212   rtx src   = operands[1];
2213   rtx op2   = operands[2];
2214   rtx dest1 = simplify_gen_subreg (SImode, dest, DImode, 0);
2215   rtx dest2 = simplify_gen_subreg (SImode, dest, DImode, 4);
2216   rtx addr1;
2217   rtx addr2;
2218   rtx word1;
2219   rtx word2;
2220
2221   addr1 = XEXP (src, 0);
2222   if (GET_CODE (addr1) == PLUS)
2223     {
2224       emit_insn (gen_add3_insn (op2, XEXP (addr1, 0), GEN_INT (4)));
2225       if (TARGET_AVOID_XFORM)
2226         {
2227           emit_insn (gen_add3_insn (op2, XEXP (addr1, 1), op2));
2228           addr2 = op2;
2229         }
2230       else
2231         addr2 = gen_rtx_PLUS (SImode, op2, XEXP (addr1, 1));
2232     }
2233   else if (TARGET_AVOID_XFORM)
2234     {
2235       emit_insn (gen_add3_insn (op2, addr1, GEN_INT (4)));
2236       addr2 = op2;
2237     }
2238   else
2239     {
2240       emit_move_insn (op2, GEN_INT (4));
2241       addr2 = gen_rtx_PLUS (SImode, op2, addr1);
2242     }
2243
2244   word1 = change_address (src, SImode, addr1);
2245   word2 = change_address (src, SImode, addr2);
2246
2247   emit_insn (gen_bswapsi2 (dest2, word1));
2248   emit_insn (gen_bswapsi2 (dest1, word2));
2249   DONE;
2250 }")
2251
2252 (define_split
2253   [(set (match_operand:DI 0 "indexed_or_indirect_operand" "")
2254         (bswap:DI (match_operand:DI 1 "gpc_reg_operand" "")))
2255    (clobber (match_operand:SI 2 "gpc_reg_operand" ""))]
2256   "!TARGET_POWERPC64 && reload_completed"
2257   [(const_int 0)]
2258   "
2259 {
2260   rtx dest = operands[0];
2261   rtx src  = operands[1];
2262   rtx op2  = operands[2];
2263   rtx src1 = simplify_gen_subreg (SImode, src, DImode, 0);
2264   rtx src2 = simplify_gen_subreg (SImode, src, DImode, 4);
2265   rtx addr1;
2266   rtx addr2;
2267   rtx word1;
2268   rtx word2;
2269
2270   addr1 = XEXP (dest, 0);
2271   if (GET_CODE (addr1) == PLUS)
2272     {
2273       emit_insn (gen_add3_insn (op2, XEXP (addr1, 0), GEN_INT (4)));
2274       if (TARGET_AVOID_XFORM)
2275         {
2276           emit_insn (gen_add3_insn (op2, XEXP (addr1, 1), op2));
2277           addr2 = op2;
2278         }
2279       else
2280         addr2 = gen_rtx_PLUS (SImode, op2, XEXP (addr1, 1));
2281     }
2282   else if (TARGET_AVOID_XFORM)
2283     {
2284       emit_insn (gen_add3_insn (op2, addr1, GEN_INT (4)));
2285       addr2 = op2;
2286     }
2287   else
2288     {
2289       emit_move_insn (op2, GEN_INT (4));
2290       addr2 = gen_rtx_PLUS (SImode, op2, addr1);
2291     }
2292
2293   word1 = change_address (dest, SImode, addr1);
2294   word2 = change_address (dest, SImode, addr2);
2295
2296   emit_insn (gen_bswapsi2 (word2, src1));
2297   emit_insn (gen_bswapsi2 (word1, src2));
2298   DONE;
2299 }")
2300
2301 (define_split
2302   [(set (match_operand:DI 0 "gpc_reg_operand" "")
2303         (bswap:DI (match_operand:DI 1 "gpc_reg_operand" "")))
2304    (clobber (match_operand:SI 2 "" ""))]
2305   "!TARGET_POWERPC64 && reload_completed"
2306   [(const_int 0)]
2307   "
2308 {
2309   rtx dest  = operands[0];
2310   rtx src   = operands[1];
2311   rtx src1  = simplify_gen_subreg (SImode, src, DImode, 0);
2312   rtx src2  = simplify_gen_subreg (SImode, src, DImode, 4);
2313   rtx dest1 = simplify_gen_subreg (SImode, dest, DImode, 0);
2314   rtx dest2 = simplify_gen_subreg (SImode, dest, DImode, 4);
2315
2316   emit_insn (gen_bswapsi2 (dest1, src2));
2317   emit_insn (gen_bswapsi2 (dest2, src1));
2318   DONE;
2319 }")
2320
2321
2322 (define_insn "mul<mode>3"
2323   [(set (match_operand:GPR 0 "gpc_reg_operand" "=r,r")
2324         (mult:GPR (match_operand:GPR 1 "gpc_reg_operand" "%r,r")
2325                   (match_operand:GPR 2 "reg_or_short_operand" "r,I")))]
2326   ""
2327   "@
2328    mull<wd> %0,%1,%2
2329    mulli %0,%1,%2"
2330    [(set_attr "type" "mul")
2331     (set (attr "size")
2332       (cond [(match_operand:GPR 2 "s8bit_cint_operand" "")
2333                 (const_string "8")
2334              (match_operand:GPR 2 "short_cint_operand" "")
2335                 (const_string "16")]
2336         (const_string "<bits>")))])
2337
2338 (define_insn_and_split "*mul<mode>3_dot"
2339   [(set (match_operand:CC 3 "cc_reg_operand" "=x,?y")
2340         (compare:CC (mult:GPR (match_operand:GPR 1 "gpc_reg_operand" "r,r")
2341                               (match_operand:GPR 2 "gpc_reg_operand" "r,r"))
2342                     (const_int 0)))
2343    (clobber (match_scratch:GPR 0 "=r,r"))]
2344   "<MODE>mode == Pmode && rs6000_gen_cell_microcode"
2345   "@
2346    mull<wd>. %0,%1,%2
2347    #"
2348   "&& reload_completed && cc_reg_not_cr0_operand (operands[3], CCmode)"
2349   [(set (match_dup 0)
2350         (mult:GPR (match_dup 1)
2351                   (match_dup 2)))
2352    (set (match_dup 3)
2353         (compare:CC (match_dup 0)
2354                     (const_int 0)))]
2355   ""
2356   [(set_attr "type" "mul")
2357    (set_attr "size" "<bits>")
2358    (set_attr "dot" "yes")
2359    (set_attr "length" "4,8")])
2360
2361 (define_insn_and_split "*mul<mode>3_dot2"
2362   [(set (match_operand:CC 3 "cc_reg_operand" "=x,?y")
2363         (compare:CC (mult:GPR (match_operand:GPR 1 "gpc_reg_operand" "r,r")
2364                               (match_operand:GPR 2 "gpc_reg_operand" "r,r"))
2365                     (const_int 0)))
2366    (set (match_operand:GPR 0 "gpc_reg_operand" "=r,r")
2367         (mult:GPR (match_dup 1)
2368                   (match_dup 2)))]
2369   "<MODE>mode == Pmode && rs6000_gen_cell_microcode"
2370   "@
2371    mull<wd>. %0,%1,%2
2372    #"
2373   "&& reload_completed && cc_reg_not_cr0_operand (operands[3], CCmode)"
2374   [(set (match_dup 0)
2375         (mult:GPR (match_dup 1)
2376                   (match_dup 2)))
2377    (set (match_dup 3)
2378         (compare:CC (match_dup 0)
2379                     (const_int 0)))]
2380   ""
2381   [(set_attr "type" "mul")
2382    (set_attr "size" "<bits>")
2383    (set_attr "dot" "yes")
2384    (set_attr "length" "4,8")])
2385
2386
2387 (define_expand "<su>mul<mode>3_highpart"
2388   [(set (match_operand:GPR 0 "gpc_reg_operand")
2389         (subreg:GPR
2390           (mult:<DMODE> (any_extend:<DMODE>
2391                           (match_operand:GPR 1 "gpc_reg_operand"))
2392                         (any_extend:<DMODE>
2393                           (match_operand:GPR 2 "gpc_reg_operand")))
2394          0))]
2395   ""
2396 {
2397   if (<MODE>mode == SImode && TARGET_POWERPC64)
2398     {
2399       emit_insn (gen_<su>mulsi3_highpart_64 (operands[0], operands[1],
2400                                              operands[2]));
2401       DONE;
2402     }
2403
2404   if (!WORDS_BIG_ENDIAN)
2405     {
2406       emit_insn (gen_<su>mul<mode>3_highpart_le (operands[0], operands[1],
2407                                                  operands[2]));
2408       DONE;
2409     }
2410 })
2411
2412 (define_insn "*<su>mul<mode>3_highpart"
2413   [(set (match_operand:GPR 0 "gpc_reg_operand" "=r")
2414         (subreg:GPR
2415           (mult:<DMODE> (any_extend:<DMODE>
2416                           (match_operand:GPR 1 "gpc_reg_operand" "r"))
2417                         (any_extend:<DMODE>
2418                           (match_operand:GPR 2 "gpc_reg_operand" "r")))
2419          0))]
2420   "WORDS_BIG_ENDIAN && !(<MODE>mode == SImode && TARGET_POWERPC64)"
2421   "mulh<wd><u> %0,%1,%2"
2422   [(set_attr "type" "mul")
2423    (set_attr "size" "<bits>")])
2424
2425 (define_insn "<su>mulsi3_highpart_le"
2426   [(set (match_operand:SI 0 "gpc_reg_operand" "=r")
2427         (subreg:SI
2428           (mult:DI (any_extend:DI
2429                      (match_operand:SI 1 "gpc_reg_operand" "r"))
2430                    (any_extend:DI
2431                      (match_operand:SI 2 "gpc_reg_operand" "r")))
2432          4))]
2433   "!WORDS_BIG_ENDIAN && !TARGET_POWERPC64"
2434   "mulhw<u> %0,%1,%2"
2435   [(set_attr "type" "mul")])
2436
2437 (define_insn "<su>muldi3_highpart_le"
2438   [(set (match_operand:DI 0 "gpc_reg_operand" "=r")
2439         (subreg:DI
2440           (mult:TI (any_extend:TI
2441                      (match_operand:DI 1 "gpc_reg_operand" "r"))
2442                    (any_extend:TI
2443                      (match_operand:DI 2 "gpc_reg_operand" "r")))
2444          8))]
2445   "!WORDS_BIG_ENDIAN && TARGET_POWERPC64"
2446   "mulhd<u> %0,%1,%2"
2447   [(set_attr "type" "mul")
2448    (set_attr "size" "64")])
2449
2450 (define_insn "<su>mulsi3_highpart_64"
2451   [(set (match_operand:SI 0 "gpc_reg_operand" "=r")
2452         (truncate:SI
2453           (lshiftrt:DI
2454             (mult:DI (any_extend:DI
2455                        (match_operand:SI 1 "gpc_reg_operand" "r"))
2456                      (any_extend:DI
2457                        (match_operand:SI 2 "gpc_reg_operand" "r")))
2458             (const_int 32))))]
2459   "TARGET_POWERPC64"
2460   "mulhw<u> %0,%1,%2"
2461   [(set_attr "type" "mul")])
2462
2463 (define_expand "<u>mul<mode><dmode>3"
2464   [(set (match_operand:<DMODE> 0 "gpc_reg_operand")
2465         (mult:<DMODE> (any_extend:<DMODE>
2466                         (match_operand:GPR 1 "gpc_reg_operand"))
2467                       (any_extend:<DMODE>
2468                         (match_operand:GPR 2 "gpc_reg_operand"))))]
2469   "!(<MODE>mode == SImode && TARGET_POWERPC64)"
2470 {
2471   rtx l = gen_reg_rtx (<MODE>mode);
2472   rtx h = gen_reg_rtx (<MODE>mode);
2473   emit_insn (gen_mul<mode>3 (l, operands[1], operands[2]));
2474   emit_insn (gen_<su>mul<mode>3_highpart (h, operands[1], operands[2]));
2475   emit_move_insn (gen_lowpart (<MODE>mode, operands[0]), l);
2476   emit_move_insn (gen_highpart (<MODE>mode, operands[0]), h);
2477   DONE;
2478 })
2479
2480
2481 (define_insn "udiv<mode>3"
2482   [(set (match_operand:GPR 0 "gpc_reg_operand" "=r")
2483         (udiv:GPR (match_operand:GPR 1 "gpc_reg_operand" "r")
2484                   (match_operand:GPR 2 "gpc_reg_operand" "r")))]
2485   ""
2486   "div<wd>u %0,%1,%2"
2487   [(set_attr "type" "div")
2488    (set_attr "size" "<bits>")])
2489
2490
2491 ;; For powers of two we can do sra[wd]i/addze for divide and then adjust for
2492 ;; modulus.  If it isn't a power of two, force operands into register and do
2493 ;; a normal divide.
2494 (define_expand "div<mode>3"
2495   [(set (match_operand:GPR 0 "gpc_reg_operand" "")
2496         (div:GPR (match_operand:GPR 1 "gpc_reg_operand" "")
2497                  (match_operand:GPR 2 "reg_or_cint_operand" "")))]
2498   ""
2499 {
2500   if (CONST_INT_P (operands[2])
2501       && INTVAL (operands[2]) > 0
2502       && exact_log2 (INTVAL (operands[2])) >= 0)
2503     {
2504       emit_insn (gen_div<mode>3_sra (operands[0], operands[1], operands[2]));
2505       DONE;
2506     }
2507
2508   operands[2] = force_reg (<MODE>mode, operands[2]);
2509 })
2510
2511 (define_insn "*div<mode>3"
2512   [(set (match_operand:GPR 0 "gpc_reg_operand" "=r")
2513         (div:GPR (match_operand:GPR 1 "gpc_reg_operand" "r")
2514                  (match_operand:GPR 2 "gpc_reg_operand" "r")))]
2515   ""
2516   "div<wd> %0,%1,%2"
2517   [(set_attr "type" "div")
2518    (set_attr "size" "<bits>")])
2519
2520 (define_insn "div<mode>3_sra"
2521   [(set (match_operand:GPR 0 "gpc_reg_operand" "=r")
2522         (div:GPR (match_operand:GPR 1 "gpc_reg_operand" "r")
2523                  (match_operand:GPR 2 "exact_log2_cint_operand" "N")))
2524    (clobber (reg:GPR CA_REGNO))]
2525   ""
2526   "sra<wd>i %0,%1,%p2\;addze %0,%0"
2527   [(set_attr "type" "two")
2528    (set_attr "length" "8")])
2529
2530 (define_insn_and_split "*div<mode>3_sra_dot"
2531   [(set (match_operand:CC 3 "cc_reg_operand" "=x,?y")
2532         (compare:CC (div:GPR (match_operand:GPR 1 "gpc_reg_operand" "r,r")
2533                              (match_operand:GPR 2 "exact_log2_cint_operand" "N,N"))
2534                     (const_int 0)))
2535    (clobber (match_scratch:GPR 0 "=r,r"))
2536    (clobber (reg:GPR CA_REGNO))]
2537   "<MODE>mode == Pmode"
2538   "@
2539    sra<wd>i %0,%1,%p2\;addze. %0,%0
2540    #"
2541   "&& reload_completed && cc_reg_not_cr0_operand (operands[3], CCmode)"
2542   [(parallel [(set (match_dup 0)
2543                    (div:GPR (match_dup 1)
2544                             (match_dup 2)))
2545               (clobber (reg:GPR CA_REGNO))])
2546    (set (match_dup 3)
2547         (compare:CC (match_dup 0)
2548                     (const_int 0)))]
2549   ""
2550   [(set_attr "type" "two")
2551    (set_attr "length" "8,12")
2552    (set_attr "cell_micro" "not")])
2553
2554 (define_insn_and_split "*div<mode>3_sra_dot2"
2555   [(set (match_operand:CC 3 "cc_reg_operand" "=x,?y")
2556         (compare:CC (div:GPR (match_operand:GPR 1 "gpc_reg_operand" "r,r")
2557                              (match_operand:GPR 2 "exact_log2_cint_operand" "N,N"))
2558                     (const_int 0)))
2559    (set (match_operand:GPR 0 "gpc_reg_operand" "=r,r")
2560         (div:GPR (match_dup 1)
2561                  (match_dup 2)))
2562    (clobber (reg:GPR CA_REGNO))]
2563   "<MODE>mode == Pmode"
2564   "@
2565    sra<wd>i %0,%1,%p2\;addze. %0,%0
2566    #"
2567   "&& reload_completed && cc_reg_not_cr0_operand (operands[3], CCmode)"
2568   [(parallel [(set (match_dup 0)
2569                    (div:GPR (match_dup 1)
2570                             (match_dup 2)))
2571               (clobber (reg:GPR CA_REGNO))])
2572    (set (match_dup 3)
2573         (compare:CC (match_dup 0)
2574                     (const_int 0)))]
2575   ""
2576   [(set_attr "type" "two")
2577    (set_attr "length" "8,12")
2578    (set_attr "cell_micro" "not")])
2579
2580 (define_expand "mod<mode>3"
2581   [(use (match_operand:GPR 0 "gpc_reg_operand" ""))
2582    (use (match_operand:GPR 1 "gpc_reg_operand" ""))
2583    (use (match_operand:GPR 2 "reg_or_cint_operand" ""))]
2584   ""
2585 {
2586   int i;
2587   rtx temp1;
2588   rtx temp2;
2589
2590   if (GET_CODE (operands[2]) != CONST_INT
2591       || INTVAL (operands[2]) <= 0
2592       || (i = exact_log2 (INTVAL (operands[2]))) < 0)
2593     FAIL;
2594
2595   temp1 = gen_reg_rtx (<MODE>mode);
2596   temp2 = gen_reg_rtx (<MODE>mode);
2597
2598   emit_insn (gen_div<mode>3 (temp1, operands[1], operands[2]));
2599   emit_insn (gen_ashl<mode>3 (temp2, temp1, GEN_INT (i)));
2600   emit_insn (gen_sub<mode>3 (operands[0], operands[1], temp2));
2601   DONE;
2602 })
2603 \f
2604 ;; Logical instructions
2605 ;; The logical instructions are mostly combined by using match_operator,
2606 ;; but the plain AND insns are somewhat different because there is no
2607 ;; plain 'andi' (only 'andi.'), no plain 'andis', and there are all
2608 ;; those rotate-and-mask operations.  Thus, the AND insns come first.
2609
2610 (define_expand "and<mode>3"
2611   [(set (match_operand:SDI 0 "gpc_reg_operand" "")
2612         (and:SDI (match_operand:SDI 1 "gpc_reg_operand" "")
2613                  (match_operand:SDI 2 "reg_or_cint_operand" "")))]
2614   ""
2615 {
2616   if (<MODE>mode == DImode && !TARGET_POWERPC64)
2617     {
2618       rs6000_split_logical (operands, AND, false, false, false);
2619       DONE;
2620     }
2621
2622   if (logical_const_operand (operands[2], <MODE>mode)
2623       && !any_mask_operand (operands[2], <MODE>mode))
2624     {
2625       emit_insn (gen_and<mode>3_imm (operands[0], operands[1], operands[2]));
2626       DONE;
2627     }
2628
2629   if ((<MODE>mode == DImode && !and64_2_operand (operands[2], <MODE>mode))
2630       || (<MODE>mode != DImode && !and_operand (operands[2], <MODE>mode)))
2631     operands[2] = force_reg (<MODE>mode, operands[2]);
2632 })
2633
2634
2635 (define_insn "and<mode>3_imm"
2636   [(set (match_operand:GPR 0 "gpc_reg_operand" "=r")
2637         (and:GPR (match_operand:GPR 1 "gpc_reg_operand" "%r")
2638                  (match_operand:GPR 2 "logical_const_operand" "n")))
2639    (clobber (match_scratch:CC 3 "=x"))]
2640   "rs6000_gen_cell_microcode
2641    && !any_mask_operand (operands[2], <MODE>mode)"
2642   "andi%e2. %0,%1,%u2"
2643   [(set_attr "type" "logical")
2644    (set_attr "dot" "yes")])
2645
2646 (define_insn_and_split "*and<mode>3_imm_dot"
2647   [(set (match_operand:CC 3 "cc_reg_operand" "=x,??y")
2648         (compare:CC (and:GPR (match_operand:GPR 1 "gpc_reg_operand" "%r,r")
2649                              (match_operand:GPR 2 "logical_const_operand" "n,n"))
2650                     (const_int 0)))
2651    (clobber (match_scratch:GPR 0 "=r,r"))
2652    (clobber (match_scratch:CC 4 "=X,x"))]
2653   "(<MODE>mode == Pmode || UINTVAL (operands[2]) <= 0x7fffffff)
2654    && rs6000_gen_cell_microcode
2655    && !any_mask_operand (operands[2], <MODE>mode)"
2656   "@
2657    andi%e2. %0,%1,%u2
2658    #"
2659   "&& reload_completed && cc_reg_not_cr0_operand (operands[3], CCmode)"
2660   [(parallel [(set (match_dup 0)
2661                    (and:GPR (match_dup 1)
2662                             (match_dup 2)))
2663               (clobber (match_dup 4))])
2664    (set (match_dup 3)
2665         (compare:CC (match_dup 0)
2666                     (const_int 0)))]
2667   ""
2668   [(set_attr "type" "logical")
2669    (set_attr "dot" "yes")
2670    (set_attr "length" "4,8")])
2671
2672 (define_insn_and_split "*and<mode>3_imm_dot2"
2673   [(set (match_operand:CC 3 "cc_reg_operand" "=x,??y")
2674         (compare:CC (and:GPR (match_operand:GPR 1 "gpc_reg_operand" "%r,r")
2675                              (match_operand:GPR 2 "logical_const_operand" "n,n"))
2676                     (const_int 0)))
2677    (set (match_operand:GPR 0 "gpc_reg_operand" "=r,r")
2678         (and:GPR (match_dup 1)
2679                  (match_dup 2)))
2680    (clobber (match_scratch:CC 4 "=X,x"))]
2681   "(<MODE>mode == Pmode || UINTVAL (operands[2]) <= 0x7fffffff)
2682    && rs6000_gen_cell_microcode
2683    && !any_mask_operand (operands[2], <MODE>mode)"
2684   "@
2685    andi%e2. %0,%1,%u2
2686    #"
2687   "&& reload_completed && cc_reg_not_cr0_operand (operands[3], CCmode)"
2688   [(parallel [(set (match_dup 0)
2689                    (and:GPR (match_dup 1)
2690                             (match_dup 2)))
2691               (clobber (match_dup 4))])
2692    (set (match_dup 3)
2693         (compare:CC (match_dup 0)
2694                     (const_int 0)))]
2695   ""
2696   [(set_attr "type" "logical")
2697    (set_attr "dot" "yes")
2698    (set_attr "length" "4,8")])
2699
2700 (define_insn_and_split "*and<mode>3_imm_mask_dot"
2701   [(set (match_operand:CC 3 "cc_reg_operand" "=x,??y")
2702         (compare:CC (and:GPR (match_operand:GPR 1 "gpc_reg_operand" "%r,r")
2703                              (match_operand:GPR 2 "logical_const_operand" "n,n"))
2704                     (const_int 0)))
2705    (clobber (match_scratch:GPR 0 "=r,r"))]
2706   "(<MODE>mode == Pmode || UINTVAL (operands[2]) <= 0x7fffffff)
2707    && rs6000_gen_cell_microcode
2708    && any_mask_operand (operands[2], <MODE>mode)"
2709   "@
2710    andi%e2. %0,%1,%u2
2711    #"
2712   "&& reload_completed && cc_reg_not_cr0_operand (operands[3], CCmode)"
2713   [(set (match_dup 0)
2714         (and:GPR (match_dup 1)
2715                  (match_dup 2)))
2716    (set (match_dup 3)
2717         (compare:CC (match_dup 0)
2718                     (const_int 0)))]
2719   ""
2720   [(set_attr "type" "logical")
2721    (set_attr "dot" "yes")
2722    (set_attr "length" "4,8")])
2723
2724 (define_insn_and_split "*and<mode>3_imm_mask_dot2"
2725   [(set (match_operand:CC 3 "cc_reg_operand" "=x,??y")
2726         (compare:CC (and:GPR (match_operand:GPR 1 "gpc_reg_operand" "%r,r")
2727                              (match_operand:GPR 2 "logical_const_operand" "n,n"))
2728                     (const_int 0)))
2729    (set (match_operand:GPR 0 "gpc_reg_operand" "=r,r")
2730         (and:GPR (match_dup 1)
2731                  (match_dup 2)))]
2732   "(<MODE>mode == Pmode || UINTVAL (operands[2]) <= 0x7fffffff)
2733    && rs6000_gen_cell_microcode
2734    && any_mask_operand (operands[2], <MODE>mode)"
2735   "@
2736    andi%e2. %0,%1,%u2
2737    #"
2738   "&& reload_completed && cc_reg_not_cr0_operand (operands[3], CCmode)"
2739   [(set (match_dup 0)
2740         (and:GPR (match_dup 1)
2741                  (match_dup 2)))
2742    (set (match_dup 3)
2743         (compare:CC (match_dup 0)
2744                     (const_int 0)))]
2745   ""
2746   [(set_attr "type" "logical")
2747    (set_attr "dot" "yes")
2748    (set_attr "length" "4,8")])
2749
2750
2751 (define_insn "*and<mode>3_mask"
2752   [(set (match_operand:GPR 0 "gpc_reg_operand" "=r,r")
2753         (and:GPR (match_operand:GPR 1 "gpc_reg_operand" "%r,r")
2754                  (match_operand:GPR 2 "any_mask_operand" "S,T")))]
2755   ""
2756   "@
2757    rldic%B2 %0,%1,0,%S2
2758    rlwinm %0,%1,0,%m2,%M2"
2759   [(set_attr "type" "shift")])
2760
2761 (define_insn_and_split "*and<mode>3_mask_dot"
2762   [(set (match_operand:CC 3 "cc_reg_operand" "=x,x,?y,?y")
2763         (compare:CC (and:GPR (match_operand:GPR 1 "gpc_reg_operand" "%r,r,r,r")
2764                              (match_operand:GPR 2 "any_mask_operand" "S,T,S,T"))
2765                     (const_int 0)))
2766    (clobber (match_scratch:GPR 0 "=r,r,r,r"))]
2767   "(<MODE>mode == Pmode || UINTVAL (operands[2]) <= 0x7fffffff)
2768    && rs6000_gen_cell_microcode
2769    && !logical_const_operand (operands[2], <MODE>mode)"
2770   "@
2771    rldic%B2. %0,%1,0,%S2
2772    rlwinm. %0,%1,0,%m2,%M2
2773    #
2774    #"
2775   "&& reload_completed && cc_reg_not_cr0_operand (operands[3], CCmode)"
2776   [(set (match_dup 0)
2777         (and:GPR (match_dup 1)
2778                  (match_dup 2)))
2779    (set (match_dup 3)
2780         (compare:CC (match_dup 0)
2781                     (const_int 0)))]
2782   ""
2783   [(set_attr "type" "shift")
2784    (set_attr "dot" "yes")
2785    (set_attr "length" "4,4,8,8")])
2786
2787 (define_insn_and_split "*and<mode>3_mask_dot2"
2788   [(set (match_operand:CC 3 "cc_reg_operand" "=x,x,?y,?y")
2789         (compare:CC (and:GPR (match_operand:GPR 1 "gpc_reg_operand" "%r,r,r,r")
2790                              (match_operand:GPR 2 "any_mask_operand" "S,T,S,T"))
2791                     (const_int 0)))
2792    (set (match_operand:GPR 0 "gpc_reg_operand" "=r,r,r,r")
2793         (and:GPR (match_dup 1)
2794                  (match_dup 2)))]
2795   "(<MODE>mode == Pmode || UINTVAL (operands[2]) <= 0x7fffffff)
2796    && rs6000_gen_cell_microcode
2797    && !logical_const_operand (operands[2], <MODE>mode)"
2798   "@
2799    rldic%B2. %0,%1,0,%S2
2800    rlwinm. %0,%1,0,%m2,%M2
2801    #
2802    #"
2803   "&& reload_completed && cc_reg_not_cr0_operand (operands[3], CCmode)"
2804   [(set (match_dup 0)
2805         (and:GPR (match_dup 1)
2806                  (match_dup 2)))
2807    (set (match_dup 3)
2808         (compare:CC (match_dup 0)
2809                     (const_int 0)))]
2810   ""
2811   [(set_attr "type" "shift")
2812    (set_attr "dot" "yes")
2813    (set_attr "length" "4,4,8,8")])
2814
2815
2816
2817 (define_insn "andsi3_internal0_nomc"
2818   [(set (match_operand:SI 0 "gpc_reg_operand" "=r,r")
2819         (and:SI (match_operand:SI 1 "gpc_reg_operand" "%r,r")
2820                 (match_operand:SI 2 "and_operand" "?r,T")))]
2821   "!rs6000_gen_cell_microcode"
2822   "@
2823    and %0,%1,%2
2824    rlwinm %0,%1,0,%m2,%M2"
2825   [(set_attr "type" "logical,shift")])
2826
2827
2828 ;; Handle the PowerPC64 rlwinm corner case
2829
2830 (define_insn_and_split "*andsi3_internal6"
2831   [(set (match_operand:SI 0 "gpc_reg_operand" "=r")
2832         (and:SI (match_operand:SI 1 "gpc_reg_operand" "r")
2833                 (match_operand:SI 2 "mask_operand_wrap" "i")))]
2834   "TARGET_POWERPC64"
2835   "#"
2836   "TARGET_POWERPC64"
2837   [(set (match_dup 0)
2838         (and:SI (rotate:SI (match_dup 1) (match_dup 3))
2839                 (match_dup 4)))
2840    (set (match_dup 0)
2841         (rotate:SI (match_dup 0) (match_dup 5)))]
2842   "
2843 {
2844   int mb = extract_MB (operands[2]);
2845   int me = extract_ME (operands[2]);
2846   operands[3] = GEN_INT (me + 1);
2847   operands[5] = GEN_INT (32 - (me + 1));
2848   operands[4] = GEN_INT (~((HOST_WIDE_INT) -1 << (33 + me - mb)));
2849 }"
2850   [(set_attr "length" "8")])
2851
2852
2853 (define_expand "<iorxor><mode>3"
2854   [(set (match_operand:SDI 0 "gpc_reg_operand" "")
2855         (iorxor:SDI (match_operand:SDI 1 "gpc_reg_operand" "")
2856                     (match_operand:SDI 2 "reg_or_cint_operand" "")))]
2857   ""
2858 {
2859   if (<MODE>mode == DImode && !TARGET_POWERPC64)
2860     {
2861       rs6000_split_logical (operands, <IORXOR>, false, false, false);
2862       DONE;
2863     }
2864
2865   if (non_logical_cint_operand (operands[2], <MODE>mode))
2866     {
2867       rtx tmp = ((!can_create_pseudo_p ()
2868                   || rtx_equal_p (operands[0], operands[1]))
2869                  ? operands[0] : gen_reg_rtx (<MODE>mode));
2870
2871       HOST_WIDE_INT value = INTVAL (operands[2]);
2872       HOST_WIDE_INT lo = value & 0xffff;
2873       HOST_WIDE_INT hi = value - lo;
2874
2875       emit_insn (gen_<iorxor><mode>3 (tmp, operands[1], GEN_INT (hi)));
2876       emit_insn (gen_<iorxor><mode>3 (operands[0], tmp, GEN_INT (lo)));
2877       DONE;
2878     }
2879
2880   if (!reg_or_logical_cint_operand (operands[2], <MODE>mode))
2881     operands[2] = force_reg (<MODE>mode, operands[2]);
2882 })
2883
2884 (define_split
2885   [(set (match_operand:GPR 0 "gpc_reg_operand" "")
2886         (iorxor:GPR (match_operand:GPR 1 "gpc_reg_operand" "")
2887                     (match_operand:GPR 2 "non_logical_cint_operand" "")))]
2888   ""
2889   [(set (match_dup 3)
2890         (iorxor:GPR (match_dup 1)
2891                     (match_dup 4)))
2892    (set (match_dup 0)
2893         (iorxor:GPR (match_dup 3)
2894                     (match_dup 5)))]
2895 {
2896   operands[3] = ((!can_create_pseudo_p ()
2897                   || rtx_equal_p (operands[0], operands[1]))
2898                  ? operands[0] : gen_reg_rtx (<MODE>mode));
2899
2900   HOST_WIDE_INT value = INTVAL (operands[2]);
2901   HOST_WIDE_INT lo = value & 0xffff;
2902   HOST_WIDE_INT hi = value - lo;
2903
2904   operands[4] = GEN_INT (hi);
2905   operands[5] = GEN_INT (lo);
2906 })
2907
2908 (define_insn "*bool<mode>3_imm"
2909   [(set (match_operand:GPR 0 "gpc_reg_operand" "=r")
2910         (match_operator:GPR 3 "boolean_or_operator"
2911          [(match_operand:GPR 1 "gpc_reg_operand" "%r")
2912           (match_operand:GPR 2 "logical_const_operand" "n")]))]
2913   ""
2914   "%q3i%e2 %0,%1,%u2"
2915   [(set_attr "type" "logical")])
2916
2917 (define_insn "*bool<mode>3"
2918   [(set (match_operand:GPR 0 "gpc_reg_operand" "=r")
2919         (match_operator:GPR 3 "boolean_operator"
2920          [(match_operand:GPR 1 "gpc_reg_operand" "r")
2921           (match_operand:GPR 2 "gpc_reg_operand" "r")]))]
2922   ""
2923   "%q3 %0,%1,%2"
2924   [(set_attr "type" "logical")])
2925
2926 (define_insn_and_split "*bool<mode>3_dot"
2927   [(set (match_operand:CC 4 "cc_reg_operand" "=x,?y")
2928         (compare:CC (match_operator:GPR 3 "boolean_operator"
2929          [(match_operand:GPR 1 "gpc_reg_operand" "r,r")
2930           (match_operand:GPR 2 "gpc_reg_operand" "r,r")])
2931          (const_int 0)))
2932    (clobber (match_scratch:GPR 0 "=r,r"))]
2933   "<MODE>mode == Pmode && rs6000_gen_cell_microcode"
2934   "@
2935    %q3. %0,%1,%2
2936    #"
2937   "&& reload_completed && cc_reg_not_cr0_operand (operands[4], CCmode)"
2938   [(set (match_dup 0)
2939         (match_dup 3))
2940    (set (match_dup 4)
2941         (compare:CC (match_dup 0)
2942                     (const_int 0)))]
2943   ""
2944   [(set_attr "type" "logical")
2945    (set_attr "dot" "yes")
2946    (set_attr "length" "4,8")])
2947
2948 (define_insn_and_split "*bool<mode>3_dot2"
2949   [(set (match_operand:CC 4 "cc_reg_operand" "=x,?y")
2950         (compare:CC (match_operator:GPR 3 "boolean_operator"
2951          [(match_operand:GPR 1 "gpc_reg_operand" "r,r")
2952           (match_operand:GPR 2 "gpc_reg_operand" "r,r")])
2953          (const_int 0)))
2954    (set (match_operand:GPR 0 "gpc_reg_operand" "=r,r")
2955         (match_dup 3))]
2956   "<MODE>mode == Pmode && rs6000_gen_cell_microcode"
2957   "@
2958    %q3. %0,%1,%2
2959    #"
2960   "&& reload_completed && cc_reg_not_cr0_operand (operands[4], CCmode)"
2961   [(set (match_dup 0)
2962         (match_dup 3))
2963    (set (match_dup 4)
2964         (compare:CC (match_dup 0)
2965                     (const_int 0)))]
2966   ""
2967   [(set_attr "type" "logical")
2968    (set_attr "dot" "yes")
2969    (set_attr "length" "4,8")])
2970
2971
2972 (define_insn "*boolc<mode>3"
2973   [(set (match_operand:GPR 0 "gpc_reg_operand" "=r")
2974         (match_operator:GPR 3 "boolean_operator"
2975          [(not:GPR (match_operand:GPR 2 "gpc_reg_operand" "r"))
2976           (match_operand:GPR 1 "gpc_reg_operand" "r")]))]
2977   ""
2978   "%q3 %0,%1,%2"
2979   [(set_attr "type" "logical")])
2980
2981 (define_insn_and_split "*boolc<mode>3_dot"
2982   [(set (match_operand:CC 4 "cc_reg_operand" "=x,?y")
2983         (compare:CC (match_operator:GPR 3 "boolean_operator"
2984          [(not:GPR (match_operand:GPR 2 "gpc_reg_operand" "r,r"))
2985           (match_operand:GPR 1 "gpc_reg_operand" "r,r")])
2986          (const_int 0)))
2987    (clobber (match_scratch:GPR 0 "=r,r"))]
2988   "<MODE>mode == Pmode && rs6000_gen_cell_microcode"
2989   "@
2990    %q3. %0,%1,%2
2991    #"
2992   "&& reload_completed && cc_reg_not_cr0_operand (operands[4], CCmode)"
2993   [(set (match_dup 0)
2994         (match_dup 3))
2995    (set (match_dup 4)
2996         (compare:CC (match_dup 0)
2997                     (const_int 0)))]
2998   ""
2999   [(set_attr "type" "logical")
3000    (set_attr "dot" "yes")
3001    (set_attr "length" "4,8")])
3002
3003 (define_insn_and_split "*boolc<mode>3_dot2"
3004   [(set (match_operand:CC 4 "cc_reg_operand" "=x,?y")
3005         (compare:CC (match_operator:GPR 3 "boolean_operator"
3006          [(not:GPR (match_operand:GPR 2 "gpc_reg_operand" "r,r"))
3007           (match_operand:GPR 1 "gpc_reg_operand" "r,r")])
3008          (const_int 0)))
3009    (set (match_operand:GPR 0 "gpc_reg_operand" "=r,r")
3010         (match_dup 3))]
3011   "<MODE>mode == Pmode && rs6000_gen_cell_microcode"
3012   "@
3013    %q3. %0,%1,%2
3014    #"
3015   "&& reload_completed && cc_reg_not_cr0_operand (operands[4], CCmode)"
3016   [(set (match_dup 0)
3017         (match_dup 3))
3018    (set (match_dup 4)
3019         (compare:CC (match_dup 0)
3020                     (const_int 0)))]
3021   ""
3022   [(set_attr "type" "logical")
3023    (set_attr "dot" "yes")
3024    (set_attr "length" "4,8")])
3025
3026
3027 (define_insn "*boolcc<mode>3"
3028   [(set (match_operand:GPR 0 "gpc_reg_operand" "=r")
3029         (match_operator:GPR 3 "boolean_operator"
3030          [(not:GPR (match_operand:GPR 1 "gpc_reg_operand" "r"))
3031           (not:GPR (match_operand:GPR 2 "gpc_reg_operand" "r"))]))]
3032   ""
3033   "%q3 %0,%1,%2"
3034   [(set_attr "type" "logical")])
3035
3036 (define_insn_and_split "*boolcc<mode>3_dot"
3037   [(set (match_operand:CC 4 "cc_reg_operand" "=x,?y")
3038         (compare:CC (match_operator:GPR 3 "boolean_operator"
3039          [(not:GPR (match_operand:GPR 1 "gpc_reg_operand" "r,r"))
3040           (not:GPR (match_operand:GPR 2 "gpc_reg_operand" "r,r"))])
3041          (const_int 0)))
3042    (clobber (match_scratch:GPR 0 "=r,r"))]
3043   "<MODE>mode == Pmode && rs6000_gen_cell_microcode"
3044   "@
3045    %q3. %0,%1,%2
3046    #"
3047   "&& reload_completed && cc_reg_not_cr0_operand (operands[4], CCmode)"
3048   [(set (match_dup 0)
3049         (match_dup 3))
3050    (set (match_dup 4)
3051         (compare:CC (match_dup 0)
3052                     (const_int 0)))]
3053   ""
3054   [(set_attr "type" "logical")
3055    (set_attr "dot" "yes")
3056    (set_attr "length" "4,8")])
3057
3058 (define_insn_and_split "*boolcc<mode>3_dot2"
3059   [(set (match_operand:CC 4 "cc_reg_operand" "=x,?y")
3060         (compare:CC (match_operator:GPR 3 "boolean_operator"
3061          [(not:GPR (match_operand:GPR 1 "gpc_reg_operand" "r,r"))
3062           (not:GPR (match_operand:GPR 2 "gpc_reg_operand" "r,r"))])
3063          (const_int 0)))
3064    (set (match_operand:GPR 0 "gpc_reg_operand" "=r,r")
3065         (match_dup 3))]
3066   "<MODE>mode == Pmode && rs6000_gen_cell_microcode"
3067   "@
3068    %q3. %0,%1,%2
3069    #"
3070   "&& reload_completed && cc_reg_not_cr0_operand (operands[4], CCmode)"
3071   [(set (match_dup 0)
3072         (match_dup 3))
3073    (set (match_dup 4)
3074         (compare:CC (match_dup 0)
3075                     (const_int 0)))]
3076   ""
3077   [(set_attr "type" "logical")
3078    (set_attr "dot" "yes")
3079    (set_attr "length" "4,8")])
3080
3081
3082 ;; TODO: Should have dots of this as well.
3083 (define_insn "*eqv<mode>3"
3084   [(set (match_operand:GPR 0 "gpc_reg_operand" "=r")
3085         (not:GPR (xor:GPR (match_operand:GPR 1 "gpc_reg_operand" "r")
3086                           (match_operand:GPR 2 "gpc_reg_operand" "r"))))]
3087   ""
3088   "eqv %0,%1,%2"
3089   [(set_attr "type" "logical")])
3090 \f
3091 ;; Rotate and shift insns, in all their variants.  These support shifts,
3092 ;; field inserts and extracts, and various combinations thereof.
3093 (define_expand "insv"
3094   [(set (zero_extract (match_operand 0 "gpc_reg_operand" "")
3095                        (match_operand:SI 1 "const_int_operand" "")
3096                        (match_operand:SI 2 "const_int_operand" ""))
3097         (match_operand 3 "gpc_reg_operand" ""))]
3098   ""
3099   "
3100 {
3101   /* Do not handle 16/8 bit structures that fit in HI/QI modes directly, since
3102      the (SUBREG:SI (REG:HI xxx)) that is otherwise generated can confuse the
3103      compiler if the address of the structure is taken later.  Likewise, do
3104      not handle invalid E500 subregs.  */
3105   if (GET_CODE (operands[0]) == SUBREG
3106       && (GET_MODE_SIZE (GET_MODE (SUBREG_REG (operands[0]))) < UNITS_PER_WORD
3107           || ((TARGET_E500_DOUBLE || TARGET_SPE)
3108               && invalid_e500_subreg (operands[0], GET_MODE (operands[0])))))
3109     FAIL;
3110
3111   if (TARGET_POWERPC64 && GET_MODE (operands[0]) == DImode)
3112     emit_insn (gen_insvdi_internal (operands[0], operands[1], operands[2],
3113                                     operands[3]));
3114   else
3115     emit_insn (gen_insvsi_internal (operands[0], operands[1], operands[2],
3116                                     operands[3]));
3117   DONE;
3118 }")
3119
3120 (define_insn "insvsi_internal"
3121   [(set (zero_extract:SI (match_operand:SI 0 "gpc_reg_operand" "+r")
3122                          (match_operand:SI 1 "const_int_operand" "i")
3123                          (match_operand:SI 2 "const_int_operand" "i"))
3124         (match_operand:SI 3 "gpc_reg_operand" "r"))]
3125   ""
3126   "*
3127 {
3128   int start = INTVAL (operands[2]) & 31;
3129   int size = INTVAL (operands[1]) & 31;
3130
3131   operands[4] = GEN_INT (32 - start - size);
3132   operands[1] = GEN_INT (start + size - 1);
3133   return \"rlwimi %0,%3,%h4,%h2,%h1\";
3134 }"
3135   [(set_attr "type" "insert")])
3136
3137 (define_insn "*insvsi_internal1"
3138   [(set (zero_extract:SI (match_operand:SI 0 "gpc_reg_operand" "+r")
3139                          (match_operand:SI 1 "const_int_operand" "i")
3140                          (match_operand:SI 2 "const_int_operand" "i"))
3141         (rotate:SI (match_operand:SI 3 "gpc_reg_operand" "r")
3142                    (match_operand:SI 4 "const_int_operand" "i")))]
3143   "(32 - (INTVAL (operands[4]) & 31)) >= INTVAL (operands[1])"
3144   "*
3145 {
3146   int shift = INTVAL (operands[4]) & 31;
3147   int start = INTVAL (operands[2]) & 31;
3148   int size = INTVAL (operands[1]) & 31;
3149
3150   operands[4] = GEN_INT (shift - start - size);
3151   operands[1] = GEN_INT (start + size - 1);
3152   return \"rlwimi %0,%3,%h4,%h2,%h1\";
3153 }"
3154   [(set_attr "type" "insert")])
3155
3156 (define_insn "*insvsi_internal2"
3157   [(set (zero_extract:SI (match_operand:SI 0 "gpc_reg_operand" "+r")
3158                          (match_operand:SI 1 "const_int_operand" "i")
3159                          (match_operand:SI 2 "const_int_operand" "i"))
3160         (ashiftrt:SI (match_operand:SI 3 "gpc_reg_operand" "r")
3161                      (match_operand:SI 4 "const_int_operand" "i")))]
3162   "(32 - (INTVAL (operands[4]) & 31)) >= INTVAL (operands[1])"
3163   "*
3164 {
3165   int shift = INTVAL (operands[4]) & 31;
3166   int start = INTVAL (operands[2]) & 31;
3167   int size = INTVAL (operands[1]) & 31;
3168
3169   operands[4] = GEN_INT (32 - shift - start - size);
3170   operands[1] = GEN_INT (start + size - 1);
3171   return \"rlwimi %0,%3,%h4,%h2,%h1\";
3172 }"
3173   [(set_attr "type" "insert")])
3174
3175 (define_insn "*insvsi_internal3"
3176   [(set (zero_extract:SI (match_operand:SI 0 "gpc_reg_operand" "+r")
3177                          (match_operand:SI 1 "const_int_operand" "i")
3178                          (match_operand:SI 2 "const_int_operand" "i"))
3179         (lshiftrt:SI (match_operand:SI 3 "gpc_reg_operand" "r")
3180                      (match_operand:SI 4 "const_int_operand" "i")))]
3181   "(32 - (INTVAL (operands[4]) & 31)) >= INTVAL (operands[1])"
3182   "*
3183 {
3184   int shift = INTVAL (operands[4]) & 31;
3185   int start = INTVAL (operands[2]) & 31;
3186   int size = INTVAL (operands[1]) & 31;
3187
3188   operands[4] = GEN_INT (32 - shift - start - size);
3189   operands[1] = GEN_INT (start + size - 1);
3190   return \"rlwimi %0,%3,%h4,%h2,%h1\";
3191 }"
3192   [(set_attr "type" "insert")])
3193
3194 (define_insn "*insvsi_internal4"
3195   [(set (zero_extract:SI (match_operand:SI 0 "gpc_reg_operand" "+r")
3196                          (match_operand:SI 1 "const_int_operand" "i")
3197                          (match_operand:SI 2 "const_int_operand" "i"))
3198         (zero_extract:SI (match_operand:SI 3 "gpc_reg_operand" "r")
3199                          (match_operand:SI 4 "const_int_operand" "i")
3200                          (match_operand:SI 5 "const_int_operand" "i")))]
3201   "INTVAL (operands[4]) >= INTVAL (operands[1])"
3202   "*
3203 {
3204   int extract_start = INTVAL (operands[5]) & 31;
3205   int extract_size = INTVAL (operands[4]) & 31;
3206   int insert_start = INTVAL (operands[2]) & 31;
3207   int insert_size = INTVAL (operands[1]) & 31;
3208
3209 /* Align extract field with insert field */
3210   operands[5] = GEN_INT (extract_start + extract_size - insert_start - insert_size);
3211   operands[1] = GEN_INT (insert_start + insert_size - 1);
3212   return \"rlwimi %0,%3,%h5,%h2,%h1\";
3213 }"
3214   [(set_attr "type" "insert")])
3215
3216 ;; combine patterns for rlwimi
3217 (define_insn "*insvsi_internal5"
3218   [(set (match_operand:SI 0 "gpc_reg_operand" "=r")
3219         (ior:SI (and:SI (match_operand:SI 4 "gpc_reg_operand" "0")
3220                         (match_operand:SI 1 "mask_operand" "i"))
3221                 (and:SI (lshiftrt:SI (match_operand:SI 3 "gpc_reg_operand" "r")
3222                                      (match_operand:SI 2 "const_int_operand" "i"))
3223                         (match_operand:SI 5 "mask_operand" "i"))))]
3224   "INTVAL(operands[1]) == ~INTVAL(operands[5])"
3225   "*
3226 {
3227  int me = extract_ME(operands[5]);
3228  int mb = extract_MB(operands[5]);
3229  operands[4] = GEN_INT(32 - INTVAL(operands[2]));
3230  operands[2] = GEN_INT(mb);
3231  operands[1] = GEN_INT(me);
3232  return \"rlwimi %0,%3,%h4,%h2,%h1\";
3233 }"
3234   [(set_attr "type" "insert")])
3235
3236 (define_insn "*insvsi_internal6"
3237   [(set (match_operand:SI 0 "gpc_reg_operand" "=r")
3238         (ior:SI (and:SI (lshiftrt:SI (match_operand:SI 3 "gpc_reg_operand" "r")
3239                                      (match_operand:SI 2 "const_int_operand" "i"))
3240                         (match_operand:SI 5 "mask_operand" "i"))
3241                 (and:SI (match_operand:SI 4 "gpc_reg_operand" "0")
3242                         (match_operand:SI 1 "mask_operand" "i"))))]
3243   "INTVAL(operands[1]) == ~INTVAL(operands[5])"
3244   "*
3245 {
3246  int me = extract_ME(operands[5]);
3247  int mb = extract_MB(operands[5]);
3248  operands[4] = GEN_INT(32 - INTVAL(operands[2]));
3249  operands[2] = GEN_INT(mb);
3250  operands[1] = GEN_INT(me);
3251  return \"rlwimi %0,%3,%h4,%h2,%h1\";
3252 }"
3253   [(set_attr "type" "insert")])
3254
3255 (define_insn "insvdi_internal"
3256   [(set (zero_extract:DI (match_operand:DI 0 "gpc_reg_operand" "+r")
3257                          (match_operand:SI 1 "const_int_operand" "i")
3258                          (match_operand:SI 2 "const_int_operand" "i"))
3259         (match_operand:DI 3 "gpc_reg_operand" "r"))]
3260   "TARGET_POWERPC64"
3261   "*
3262 {
3263   int start = INTVAL (operands[2]) & 63;
3264   int size = INTVAL (operands[1]) & 63;
3265
3266   operands[1] = GEN_INT (64 - start - size);
3267   return \"rldimi %0,%3,%H1,%H2\";
3268 }"
3269   [(set_attr "type" "insert")
3270    (set_attr "size" "64")])
3271
3272 (define_insn "*insvdi_internal2"
3273   [(set (zero_extract:DI (match_operand:DI 0 "gpc_reg_operand" "+r")
3274                          (match_operand:SI 1 "const_int_operand" "i")
3275                          (match_operand:SI 2 "const_int_operand" "i"))
3276         (ashiftrt:DI (match_operand:DI 3 "gpc_reg_operand" "r")
3277                      (match_operand:SI 4 "const_int_operand" "i")))]
3278   "TARGET_POWERPC64
3279    && insvdi_rshift_rlwimi_p (operands[1], operands[2], operands[4])"
3280   "*
3281 {
3282   int shift = INTVAL (operands[4]) & 63;
3283   int start = (INTVAL (operands[2]) & 63) - 32;
3284   int size = INTVAL (operands[1]) & 63;
3285
3286   operands[4] = GEN_INT (64 - shift - start - size);
3287   operands[2] = GEN_INT (start);
3288   operands[1] = GEN_INT (start + size - 1);
3289   return \"rlwimi %0,%3,%h4,%h2,%h1\";
3290 }")
3291
3292 (define_insn "*insvdi_internal3"
3293   [(set (zero_extract:DI (match_operand:DI 0 "gpc_reg_operand" "+r")
3294                          (match_operand:SI 1 "const_int_operand" "i")
3295                          (match_operand:SI 2 "const_int_operand" "i"))
3296         (lshiftrt:DI (match_operand:DI 3 "gpc_reg_operand" "r")
3297                      (match_operand:SI 4 "const_int_operand" "i")))]
3298   "TARGET_POWERPC64
3299    && insvdi_rshift_rlwimi_p (operands[1], operands[2], operands[4])"
3300   "*
3301 {
3302   int shift = INTVAL (operands[4]) & 63;
3303   int start = (INTVAL (operands[2]) & 63) - 32;
3304   int size = INTVAL (operands[1]) & 63;
3305
3306   operands[4] = GEN_INT (64 - shift - start - size);
3307   operands[2] = GEN_INT (start);
3308   operands[1] = GEN_INT (start + size - 1);
3309   return \"rlwimi %0,%3,%h4,%h2,%h1\";
3310 }")
3311
3312 (define_expand "extzv"
3313   [(set (match_operand 0 "gpc_reg_operand" "")
3314         (zero_extract (match_operand 1 "gpc_reg_operand" "")
3315                        (match_operand:SI 2 "const_int_operand" "")
3316                        (match_operand:SI 3 "const_int_operand" "")))]
3317   ""
3318   "
3319 {
3320   /* Do not handle 16/8 bit structures that fit in HI/QI modes directly, since
3321      the (SUBREG:SI (REG:HI xxx)) that is otherwise generated can confuse the
3322      compiler if the address of the structure is taken later.  */
3323   if (GET_CODE (operands[0]) == SUBREG
3324       && (GET_MODE_SIZE (GET_MODE (SUBREG_REG (operands[0]))) < UNITS_PER_WORD))
3325     FAIL;
3326
3327   if (TARGET_POWERPC64 && GET_MODE (operands[1]) == DImode)
3328     emit_insn (gen_extzvdi_internal (operands[0], operands[1], operands[2],
3329                                      operands[3]));
3330   else
3331     emit_insn (gen_extzvsi_internal (operands[0], operands[1], operands[2],
3332                                      operands[3]));
3333   DONE;
3334 }")
3335
3336 (define_insn "extzvsi_internal"
3337   [(set (match_operand:SI 0 "gpc_reg_operand" "=r")
3338         (zero_extract:SI (match_operand:SI 1 "gpc_reg_operand" "r")
3339                          (match_operand:SI 2 "const_int_operand" "i")
3340                          (match_operand:SI 3 "const_int_operand" "i")))]
3341   ""
3342   "*
3343 {
3344   int start = INTVAL (operands[3]) & 31;
3345   int size = INTVAL (operands[2]) & 31;
3346
3347   if (start + size >= 32)
3348     operands[3] = const0_rtx;
3349   else
3350     operands[3] = GEN_INT (start + size);
3351   return \"rlwinm %0,%1,%3,%s2,31\";
3352 }"
3353   [(set_attr "type" "shift")])
3354
3355 (define_insn "*extzvsi_internal1"
3356   [(set (match_operand:CC 0 "cc_reg_operand" "=x,?y")
3357         (compare:CC (zero_extract:SI (match_operand:SI 1 "gpc_reg_operand" "r,r")
3358                          (match_operand:SI 2 "const_int_operand" "i,i")
3359                          (match_operand:SI 3 "const_int_operand" "i,i"))
3360                     (const_int 0)))
3361    (clobber (match_scratch:SI 4 "=r,r"))]
3362   ""
3363   "*
3364 {
3365   int start = INTVAL (operands[3]) & 31;
3366   int size = INTVAL (operands[2]) & 31;
3367
3368   /* Force split for non-cc0 compare.  */
3369   if (which_alternative == 1)
3370      return \"#\";
3371
3372   /* If the bit-field being tested fits in the upper or lower half of a
3373      word, it is possible to use andiu. or andil. to test it.  This is
3374      useful because the condition register set-use delay is smaller for
3375      andi[ul]. than for rlinm.  This doesn't work when the starting bit
3376      position is 0 because the LT and GT bits may be set wrong.  */
3377
3378   if ((start > 0 && start + size <= 16) || start >= 16)
3379     {
3380       operands[3] = GEN_INT (((1 << (16 - (start & 15)))
3381                               - (1 << (16 - (start & 15) - size))));
3382       if (start < 16)
3383         return \"andis. %4,%1,%3\";
3384       else
3385         return \"andi. %4,%1,%3\";
3386     }
3387
3388   if (start + size >= 32)
3389     operands[3] = const0_rtx;
3390   else
3391     operands[3] = GEN_INT (start + size);
3392   return \"rlwinm. %4,%1,%3,%s2,31\";
3393 }"
3394   [(set_attr "type" "shift")
3395    (set_attr "dot" "yes")
3396    (set_attr "length" "4,8")])
3397
3398 (define_split
3399   [(set (match_operand:CC 0 "cc_reg_not_micro_cr0_operand" "")
3400         (compare:CC (zero_extract:SI (match_operand:SI 1 "gpc_reg_operand" "")
3401                          (match_operand:SI 2 "const_int_operand" "")
3402                          (match_operand:SI 3 "const_int_operand" ""))
3403                     (const_int 0)))
3404    (clobber (match_scratch:SI 4 ""))]
3405   "reload_completed"
3406   [(set (match_dup 4)
3407         (zero_extract:SI (match_dup 1) (match_dup 2)
3408                          (match_dup 3)))
3409    (set (match_dup 0)
3410         (compare:CC (match_dup 4)
3411                     (const_int 0)))]
3412   "")
3413
3414 (define_insn "*extzvsi_internal2"
3415   [(set (match_operand:CC 4 "cc_reg_operand" "=x,?y")
3416         (compare:CC (zero_extract:SI (match_operand:SI 1 "gpc_reg_operand" "r,r")
3417                          (match_operand:SI 2 "const_int_operand" "i,i")
3418                          (match_operand:SI 3 "const_int_operand" "i,i"))
3419                     (const_int 0)))
3420    (set (match_operand:SI 0 "gpc_reg_operand" "=r,r")
3421         (zero_extract:SI (match_dup 1) (match_dup 2) (match_dup 3)))]
3422   ""
3423   "*
3424 {
3425   int start = INTVAL (operands[3]) & 31;
3426   int size = INTVAL (operands[2]) & 31;
3427
3428   /* Force split for non-cc0 compare.  */
3429   if (which_alternative == 1)
3430      return \"#\";
3431
3432   /* Since we are using the output value, we can't ignore any need for
3433      a shift.  The bit-field must end at the LSB.  */
3434   if (start >= 16 && start + size == 32)
3435     {
3436       operands[3] = GEN_INT ((1 << size) - 1);
3437       return \"andi. %0,%1,%3\";
3438     }
3439
3440   if (start + size >= 32)
3441     operands[3] = const0_rtx;
3442   else
3443     operands[3] = GEN_INT (start + size);
3444   return \"rlwinm. %0,%1,%3,%s2,31\";
3445 }"
3446   [(set_attr "type" "shift")
3447    (set_attr "dot" "yes")
3448    (set_attr "length" "4,8")])
3449
3450 (define_split
3451   [(set (match_operand:CC 4 "cc_reg_not_micro_cr0_operand" "")
3452         (compare:CC (zero_extract:SI (match_operand:SI 1 "gpc_reg_operand" "")
3453                          (match_operand:SI 2 "const_int_operand" "")
3454                          (match_operand:SI 3 "const_int_operand" ""))
3455                     (const_int 0)))
3456    (set (match_operand:SI 0 "gpc_reg_operand" "")
3457         (zero_extract:SI (match_dup 1) (match_dup 2) (match_dup 3)))]
3458   "reload_completed"
3459   [(set (match_dup 0)
3460         (zero_extract:SI (match_dup 1) (match_dup 2) (match_dup 3)))
3461    (set (match_dup 4)
3462         (compare:CC (match_dup 0)
3463                     (const_int 0)))]
3464   "")
3465
3466 (define_insn "extzvdi_internal"
3467   [(set (match_operand:DI 0 "gpc_reg_operand" "=r")
3468         (zero_extract:DI (match_operand:DI 1 "gpc_reg_operand" "r")
3469                          (match_operand:SI 2 "const_int_operand" "i")
3470                          (match_operand:SI 3 "const_int_operand" "i")))]
3471   "TARGET_POWERPC64"
3472   "*
3473 {
3474   int start = INTVAL (operands[3]) & 63;
3475   int size = INTVAL (operands[2]) & 63;
3476
3477   if (start + size >= 64)
3478     operands[3] = const0_rtx;
3479   else
3480     operands[3] = GEN_INT (start + size);
3481   operands[2] = GEN_INT (64 - size);
3482   return \"rldicl %0,%1,%3,%2\";
3483 }"
3484   [(set_attr "type" "shift")])
3485
3486 (define_insn "*extzvdi_internal1"
3487   [(set (match_operand:CC 0 "gpc_reg_operand" "=x")
3488         (compare:CC (zero_extract:DI (match_operand:DI 1 "gpc_reg_operand" "r")
3489                          (match_operand:SI 2 "const_int_operand" "i")
3490                          (match_operand:SI 3 "const_int_operand" "i"))
3491                     (const_int 0)))
3492    (clobber (match_scratch:DI 4 "=r"))]
3493   "TARGET_64BIT && rs6000_gen_cell_microcode"
3494   "*
3495 {
3496   int start = INTVAL (operands[3]) & 63;
3497   int size = INTVAL (operands[2]) & 63;
3498
3499   if (start + size >= 64)
3500     operands[3] = const0_rtx;
3501   else
3502     operands[3] = GEN_INT (start + size);
3503   operands[2] = GEN_INT (64 - size);
3504   return \"rldicl. %4,%1,%3,%2\";
3505 }"
3506   [(set_attr "type" "shift")
3507    (set_attr "dot" "yes")])
3508
3509 (define_insn "*extzvdi_internal2"
3510   [(set (match_operand:CC 4 "gpc_reg_operand" "=x")
3511         (compare:CC (zero_extract:DI (match_operand:DI 1 "gpc_reg_operand" "r")
3512                          (match_operand:SI 2 "const_int_operand" "i")
3513                          (match_operand:SI 3 "const_int_operand" "i"))
3514                     (const_int 0)))
3515    (set (match_operand:DI 0 "gpc_reg_operand" "=r")
3516         (zero_extract:DI (match_dup 1) (match_dup 2) (match_dup 3)))]
3517   "TARGET_64BIT && rs6000_gen_cell_microcode"
3518   "*
3519 {
3520   int start = INTVAL (operands[3]) & 63;
3521   int size = INTVAL (operands[2]) & 63;
3522
3523   if (start + size >= 64)
3524     operands[3] = const0_rtx;
3525   else
3526     operands[3] = GEN_INT (start + size);
3527   operands[2] = GEN_INT (64 - size);
3528   return \"rldicl. %0,%1,%3,%2\";
3529 }"
3530   [(set_attr "type" "shift")
3531    (set_attr "dot" "yes")])
3532
3533
3534 (define_insn "rotl<mode>3"
3535   [(set (match_operand:GPR 0 "gpc_reg_operand" "=r")
3536         (rotate:GPR (match_operand:GPR 1 "gpc_reg_operand" "r")
3537                     (match_operand:SI 2 "reg_or_cint_operand" "rn")))]
3538   ""
3539   "rotl<wd>%I2 %0,%1,%<hH>2"
3540   [(set_attr "type" "shift")
3541    (set_attr "maybe_var_shift" "yes")])
3542
3543 (define_insn "*rotlsi3_64"
3544   [(set (match_operand:DI 0 "gpc_reg_operand" "=r")
3545         (zero_extend:DI
3546             (rotate:SI (match_operand:SI 1 "gpc_reg_operand" "r")
3547                        (match_operand:SI 2 "reg_or_cint_operand" "rn"))))]
3548   "TARGET_POWERPC64"
3549   "rotlw%I2 %0,%1,%h2"
3550   [(set_attr "type" "shift")
3551    (set_attr "maybe_var_shift" "yes")])
3552
3553 (define_insn_and_split "*rotl<mode>3_dot"
3554   [(set (match_operand:CC 3 "cc_reg_operand" "=x,?y")
3555         (compare:CC (rotate:GPR (match_operand:GPR 1 "gpc_reg_operand" "r,r")
3556                                 (match_operand:SI 2 "reg_or_cint_operand" "rn,rn"))
3557                     (const_int 0)))
3558    (clobber (match_scratch:GPR 0 "=r,r"))]
3559   "<MODE>mode == Pmode && rs6000_gen_cell_microcode"
3560   "@
3561    rotl<wd>%I2. %0,%1,%<hH>2
3562    #"
3563   "&& reload_completed && cc_reg_not_cr0_operand (operands[3], CCmode)"
3564   [(set (match_dup 0)
3565         (rotate:GPR (match_dup 1)
3566                     (match_dup 2)))
3567    (set (match_dup 3)
3568         (compare:CC (match_dup 0)
3569                     (const_int 0)))]
3570   ""
3571   [(set_attr "type" "shift")
3572    (set_attr "maybe_var_shift" "yes")
3573    (set_attr "dot" "yes")
3574    (set_attr "length" "4,8")])
3575
3576 (define_insn_and_split "*rotl<mode>3_dot2"
3577   [(set (match_operand:CC 3 "cc_reg_operand" "=x,?y")
3578         (compare:CC (rotate:GPR (match_operand:GPR 1 "gpc_reg_operand" "r,r")
3579                                 (match_operand:SI 2 "reg_or_cint_operand" "rn,rn"))
3580                     (const_int 0)))
3581    (set (match_operand:GPR 0 "gpc_reg_operand" "=r,r")
3582         (rotate:GPR (match_dup 1)
3583                     (match_dup 2)))]
3584   "<MODE>mode == Pmode && rs6000_gen_cell_microcode"
3585   "@
3586    rotl<wd>%I2. %0,%1,%<hH>2
3587    #"
3588   "&& reload_completed && cc_reg_not_cr0_operand (operands[3], CCmode)"
3589   [(set (match_dup 0)
3590         (rotate:GPR (match_dup 1)
3591                     (match_dup 2)))
3592    (set (match_dup 3)
3593         (compare:CC (match_dup 0)
3594                     (const_int 0)))]
3595   ""
3596   [(set_attr "type" "shift")
3597    (set_attr "maybe_var_shift" "yes")
3598    (set_attr "dot" "yes")
3599    (set_attr "length" "4,8")])
3600
3601
3602 (define_insn "*rotlsi3_internal4"
3603   [(set (match_operand:SI 0 "gpc_reg_operand" "=r")
3604         (and:SI (rotate:SI (match_operand:SI 1 "gpc_reg_operand" "r")
3605                            (match_operand:SI 2 "reg_or_cint_operand" "rn"))
3606                 (match_operand:SI 3 "mask_operand" "n")))]
3607   ""
3608   "rlw%I2nm %0,%1,%h2,%m3,%M3"
3609   [(set_attr "type" "shift")
3610    (set_attr "maybe_var_shift" "yes")])
3611
3612 (define_insn "*rotlsi3_internal5"
3613   [(set (match_operand:CC 0 "cc_reg_operand" "=x,?y")
3614         (compare:CC (and:SI
3615                      (rotate:SI (match_operand:SI 1 "gpc_reg_operand" "r,r")
3616                                 (match_operand:SI 2 "reg_or_cint_operand" "rn,rn"))
3617                      (match_operand:SI 3 "mask_operand" "n,n"))
3618                     (const_int 0)))
3619    (clobber (match_scratch:SI 4 "=r,r"))]
3620   ""
3621   "@
3622    rlw%I2nm. %4,%1,%h2,%m3,%M3
3623    #"
3624   [(set_attr "type" "shift")
3625    (set_attr "maybe_var_shift" "yes")
3626    (set_attr "dot" "yes")
3627    (set_attr "length" "4,8")])
3628
3629 (define_split
3630   [(set (match_operand:CC 0 "cc_reg_not_micro_cr0_operand" "")
3631         (compare:CC (and:SI
3632                      (rotate:SI (match_operand:SI 1 "gpc_reg_operand" "")
3633                                 (match_operand:SI 2 "reg_or_cint_operand" ""))
3634                      (match_operand:SI 3 "mask_operand" ""))
3635                     (const_int 0)))
3636    (clobber (match_scratch:SI 4 ""))]
3637   "reload_completed"
3638   [(set (match_dup 4)
3639         (and:SI (rotate:SI (match_dup 1)
3640                                 (match_dup 2))
3641                      (match_dup 3)))
3642    (set (match_dup 0)
3643         (compare:CC (match_dup 4)
3644                     (const_int 0)))]
3645   "")
3646
3647 (define_insn "*rotlsi3_internal6"
3648   [(set (match_operand:CC 4 "cc_reg_operand" "=x,?y")
3649         (compare:CC (and:SI
3650                      (rotate:SI (match_operand:SI 1 "gpc_reg_operand" "r,r")
3651                                 (match_operand:SI 2 "reg_or_cint_operand" "rn,rn"))
3652                      (match_operand:SI 3 "mask_operand" "n,n"))
3653                     (const_int 0)))
3654    (set (match_operand:SI 0 "gpc_reg_operand" "=r,r")
3655         (and:SI (rotate:SI (match_dup 1) (match_dup 2)) (match_dup 3)))]
3656   ""
3657   "@
3658    rlw%I2nm. %0,%1,%h2,%m3,%M3
3659    #"
3660   [(set_attr "type" "shift")
3661    (set_attr "maybe_var_shift" "yes")
3662    (set_attr "dot" "yes")
3663    (set_attr "length" "4,8")])
3664
3665 (define_split
3666   [(set (match_operand:CC 4 "cc_reg_not_micro_cr0_operand" "")
3667         (compare:CC (and:SI
3668                      (rotate:SI (match_operand:SI 1 "gpc_reg_operand" "")
3669                                 (match_operand:SI 2 "reg_or_cint_operand" ""))
3670                      (match_operand:SI 3 "mask_operand" ""))
3671                     (const_int 0)))
3672    (set (match_operand:SI 0 "gpc_reg_operand" "")
3673         (and:SI (rotate:SI (match_dup 1) (match_dup 2)) (match_dup 3)))]
3674   "reload_completed"
3675   [(set (match_dup 0)
3676         (and:SI (rotate:SI (match_dup 1) (match_dup 2)) (match_dup 3)))
3677    (set (match_dup 4)
3678         (compare:CC (match_dup 0)
3679                     (const_int 0)))]
3680   "")
3681
3682 (define_insn "*rotlsi3_internal7le"
3683   [(set (match_operand:SI 0 "gpc_reg_operand" "=r")
3684         (zero_extend:SI
3685          (subreg:QI
3686           (rotate:SI (match_operand:SI 1 "gpc_reg_operand" "r")
3687                      (match_operand:SI 2 "reg_or_cint_operand" "ri")) 0)))]
3688   "!BYTES_BIG_ENDIAN"
3689   "rlw%I2nm %0,%1,%h2,0xff"
3690   [(set (attr "cell_micro")
3691      (if_then_else (match_operand:SI 2 "const_int_operand" "")
3692         (const_string "not")
3693         (const_string "always")))
3694    (set_attr "type" "shift")])
3695
3696 (define_insn "*rotlsi3_internal7be"
3697   [(set (match_operand:SI 0 "gpc_reg_operand" "=r")
3698         (zero_extend:SI
3699          (subreg:QI
3700           (rotate:SI (match_operand:SI 1 "gpc_reg_operand" "r")
3701                      (match_operand:SI 2 "reg_or_cint_operand" "ri")) 3)))]
3702   "BYTES_BIG_ENDIAN"
3703   "rlw%I2nm %0,%1,%h2,0xff"
3704   [(set (attr "cell_micro")
3705      (if_then_else (match_operand:SI 2 "const_int_operand" "")
3706         (const_string "not")
3707         (const_string "always")))
3708    (set_attr "type" "shift")])
3709
3710 (define_insn "*rotlsi3_internal8le"
3711   [(set (match_operand:CC 0 "cc_reg_operand" "=x,?y")
3712         (compare:CC (zero_extend:SI
3713                      (subreg:QI
3714                       (rotate:SI (match_operand:SI 1 "gpc_reg_operand" "r,r")
3715                                  (match_operand:SI 2 "reg_or_cint_operand" "rn,rn")) 0))
3716                     (const_int 0)))
3717    (clobber (match_scratch:SI 3 "=r,r"))]
3718   "!BYTES_BIG_ENDIAN"
3719   "@
3720    rlw%I2nm. %3,%1,%h2,0xff
3721    #"
3722   [(set_attr "type" "shift")
3723    (set_attr "maybe_var_shift" "yes")
3724    (set_attr "dot" "yes")
3725    (set_attr "length" "4,8")])
3726
3727 (define_insn "*rotlsi3_internal8be"
3728   [(set (match_operand:CC 0 "cc_reg_operand" "=x,?y")
3729         (compare:CC (zero_extend:SI
3730                      (subreg:QI
3731                       (rotate:SI (match_operand:SI 1 "gpc_reg_operand" "r,r")
3732                                  (match_operand:SI 2 "reg_or_cint_operand" "rn,rn")) 3))
3733                     (const_int 0)))
3734    (clobber (match_scratch:SI 3 "=r,r"))]
3735   "BYTES_BIG_ENDIAN"
3736   "@
3737    rlw%I2nm. %3,%1,%h2,0xff
3738    #"
3739   [(set_attr "type" "shift")
3740    (set_attr "maybe_var_shift" "yes")
3741    (set_attr "dot" "yes")
3742    (set_attr "length" "4,8")])
3743
3744 (define_split
3745   [(set (match_operand:CC 0 "cc_reg_not_micro_cr0_operand" "")
3746         (compare:CC (zero_extend:SI
3747                      (subreg:QI
3748                       (rotate:SI (match_operand:SI 1 "gpc_reg_operand" "")
3749                                  (match_operand:SI 2 "reg_or_cint_operand" "")) 0))
3750                     (const_int 0)))
3751    (clobber (match_scratch:SI 3 ""))]
3752   "!BYTES_BIG_ENDIAN && reload_completed"
3753   [(set (match_dup 3)
3754         (zero_extend:SI (subreg:QI
3755                       (rotate:SI (match_dup 1)
3756                                  (match_dup 2)) 0)))
3757    (set (match_dup 0)
3758         (compare:CC (match_dup 3)
3759                     (const_int 0)))]
3760   "")
3761
3762 (define_split
3763   [(set (match_operand:CC 0 "cc_reg_not_micro_cr0_operand" "")
3764         (compare:CC (zero_extend:SI
3765                      (subreg:QI
3766                       (rotate:SI (match_operand:SI 1 "gpc_reg_operand" "")
3767                                  (match_operand:SI 2 "reg_or_cint_operand" "")) 3))
3768                     (const_int 0)))
3769    (clobber (match_scratch:SI 3 ""))]
3770   "BYTES_BIG_ENDIAN && reload_completed"
3771   [(set (match_dup 3)
3772         (zero_extend:SI (subreg:QI
3773                       (rotate:SI (match_dup 1)
3774                                  (match_dup 2)) 3)))
3775    (set (match_dup 0)
3776         (compare:CC (match_dup 3)
3777                     (const_int 0)))]
3778   "")
3779
3780 (define_insn "*rotlsi3_internal9le"
3781   [(set (match_operand:CC 3 "cc_reg_operand" "=x,?y")
3782         (compare:CC (zero_extend:SI
3783                      (subreg:QI
3784                       (rotate:SI (match_operand:SI 1 "gpc_reg_operand" "r,r")
3785                                  (match_operand:SI 2 "reg_or_cint_operand" "rn,rn")) 0))
3786                     (const_int 0)))
3787    (set (match_operand:SI 0 "gpc_reg_operand" "=r,r")
3788         (zero_extend:SI (subreg:QI (rotate:SI (match_dup 1) (match_dup 2)) 0)))]
3789   "!BYTES_BIG_ENDIAN"
3790   "@
3791    rlw%I2nm. %0,%1,%h2,0xff
3792    #"
3793   [(set_attr "type" "shift")
3794    (set_attr "maybe_var_shift" "yes")
3795    (set_attr "dot" "yes")
3796    (set_attr "length" "4,8")])
3797
3798 (define_insn "*rotlsi3_internal9be"
3799   [(set (match_operand:CC 3 "cc_reg_operand" "=x,?y")
3800         (compare:CC (zero_extend:SI
3801                      (subreg:QI
3802                       (rotate:SI (match_operand:SI 1 "gpc_reg_operand" "r,r")
3803                                  (match_operand:SI 2 "reg_or_cint_operand" "rn,rn")) 3))
3804                     (const_int 0)))
3805    (set (match_operand:SI 0 "gpc_reg_operand" "=r,r")
3806         (zero_extend:SI (subreg:QI (rotate:SI (match_dup 1) (match_dup 2)) 3)))]
3807   "BYTES_BIG_ENDIAN"
3808   "@
3809    rlw%I2nm. %0,%1,%h2,0xff
3810    #"
3811   [(set_attr "type" "shift")
3812    (set_attr "maybe_var_shift" "yes")
3813    (set_attr "dot" "yes")
3814    (set_attr "length" "4,8")])
3815
3816 (define_split
3817   [(set (match_operand:CC 3 "cc_reg_not_micro_cr0_operand" "")
3818         (compare:CC (zero_extend:SI
3819                      (subreg:QI
3820                       (rotate:SI (match_operand:SI 1 "gpc_reg_operand" "")
3821                                  (match_operand:SI 2 "reg_or_cint_operand" "")) 0))
3822                     (const_int 0)))
3823    (set (match_operand:SI 0 "gpc_reg_operand" "")
3824         (zero_extend:SI (subreg:QI (rotate:SI (match_dup 1) (match_dup 2)) 0)))]
3825   "!BYTES_BIG_ENDIAN && reload_completed"
3826   [(set (match_dup 0)
3827         (zero_extend:SI (subreg:QI (rotate:SI (match_dup 1) (match_dup 2)) 0)))
3828    (set (match_dup 3)
3829         (compare:CC (match_dup 0)
3830                     (const_int 0)))]
3831   "")
3832
3833 (define_split
3834   [(set (match_operand:CC 3 "cc_reg_not_micro_cr0_operand" "")
3835         (compare:CC (zero_extend:SI
3836                      (subreg:QI
3837                       (rotate:SI (match_operand:SI 1 "gpc_reg_operand" "")
3838                                  (match_operand:SI 2 "reg_or_cint_operand" "")) 3))
3839                     (const_int 0)))
3840    (set (match_operand:SI 0 "gpc_reg_operand" "")
3841         (zero_extend:SI (subreg:QI (rotate:SI (match_dup 1) (match_dup 2)) 3)))]
3842   "BYTES_BIG_ENDIAN && reload_completed"
3843   [(set (match_dup 0)
3844         (zero_extend:SI (subreg:QI (rotate:SI (match_dup 1) (match_dup 2)) 3)))
3845    (set (match_dup 3)
3846         (compare:CC (match_dup 0)
3847                     (const_int 0)))]
3848   "")
3849
3850 (define_insn "*rotlsi3_internal10le"
3851   [(set (match_operand:SI 0 "gpc_reg_operand" "=r")
3852         (zero_extend:SI
3853          (subreg:HI
3854           (rotate:SI (match_operand:SI 1 "gpc_reg_operand" "r")
3855                      (match_operand:SI 2 "reg_or_cint_operand" "rn")) 0)))]
3856   "!BYTES_BIG_ENDIAN"
3857   "rlw%I2nm %0,%1,%h2,0xffff"
3858   [(set_attr "type" "shift")
3859    (set_attr "maybe_var_shift" "yes")])
3860
3861 (define_insn "*rotlsi3_internal10be"
3862   [(set (match_operand:SI 0 "gpc_reg_operand" "=r")
3863         (zero_extend:SI
3864          (subreg:HI
3865           (rotate:SI (match_operand:SI 1 "gpc_reg_operand" "r")
3866                      (match_operand:SI 2 "reg_or_cint_operand" "rn")) 2)))]
3867   "BYTES_BIG_ENDIAN"
3868   "rlw%I2nm %0,%1,%h2,0xffff"
3869   [(set_attr "type" "shift")
3870    (set_attr "maybe_var_shift" "yes")])
3871
3872 (define_insn "*rotlsi3_internal11le"
3873   [(set (match_operand:CC 0 "cc_reg_operand" "=x,?y")
3874         (compare:CC (zero_extend:SI
3875                      (subreg:HI
3876                       (rotate:SI (match_operand:SI 1 "gpc_reg_operand" "r,r")
3877                                  (match_operand:SI 2 "reg_or_cint_operand" "rn,rn")) 0))
3878                     (const_int 0)))
3879    (clobber (match_scratch:SI 3 "=r,r"))]
3880   "!BYTES_BIG_ENDIAN"
3881   "@
3882    rlw%I2nm. %3,%1,%h2,0xffff
3883    #"
3884   [(set_attr "type" "shift")
3885    (set_attr "maybe_var_shift" "yes")
3886    (set_attr "dot" "yes")
3887    (set_attr "length" "4,8")])
3888
3889 (define_insn "*rotlsi3_internal11be"
3890   [(set (match_operand:CC 0 "cc_reg_operand" "=x,?y")
3891         (compare:CC (zero_extend:SI
3892                      (subreg:HI
3893                       (rotate:SI (match_operand:SI 1 "gpc_reg_operand" "r,r")
3894                                  (match_operand:SI 2 "reg_or_cint_operand" "rn,rn")) 2))
3895                     (const_int 0)))
3896    (clobber (match_scratch:SI 3 "=r,r"))]
3897   "BYTES_BIG_ENDIAN"
3898   "@
3899    rlw%I2nm. %3,%1,%h2,0xffff
3900    #"
3901   [(set_attr "type" "shift")
3902    (set_attr "maybe_var_shift" "yes")
3903    (set_attr "dot" "yes")
3904    (set_attr "length" "4,8")])
3905
3906 (define_split
3907   [(set (match_operand:CC 0 "cc_reg_not_micro_cr0_operand" "")
3908         (compare:CC (zero_extend:SI
3909                      (subreg:HI
3910                       (rotate:SI (match_operand:SI 1 "gpc_reg_operand" "")
3911                                  (match_operand:SI 2 "reg_or_cint_operand" "")) 0))
3912                     (const_int 0)))
3913    (clobber (match_scratch:SI 3 ""))]
3914   "!BYTES_BIG_ENDIAN && reload_completed"
3915   [(set (match_dup 3)
3916         (zero_extend:SI (subreg:HI
3917                       (rotate:SI (match_dup 1)
3918                                  (match_dup 2)) 0)))
3919    (set (match_dup 0)
3920         (compare:CC (match_dup 3)
3921                     (const_int 0)))]
3922   "")
3923
3924 (define_split
3925   [(set (match_operand:CC 0 "cc_reg_not_micro_cr0_operand" "")
3926         (compare:CC (zero_extend:SI
3927                      (subreg:HI
3928                       (rotate:SI (match_operand:SI 1 "gpc_reg_operand" "")
3929                                  (match_operand:SI 2 "reg_or_cint_operand" "")) 2))
3930                     (const_int 0)))
3931    (clobber (match_scratch:SI 3 ""))]
3932   "BYTES_BIG_ENDIAN && reload_completed"
3933   [(set (match_dup 3)
3934         (zero_extend:SI (subreg:HI
3935                       (rotate:SI (match_dup 1)
3936                                  (match_dup 2)) 2)))
3937    (set (match_dup 0)
3938         (compare:CC (match_dup 3)
3939                     (const_int 0)))]
3940   "")
3941
3942 (define_insn "*rotlsi3_internal12le"
3943   [(set (match_operand:CC 3 "cc_reg_operand" "=x,?y")
3944         (compare:CC (zero_extend:SI
3945                      (subreg:HI
3946                       (rotate:SI (match_operand:SI 1 "gpc_reg_operand" "r,r")
3947                                  (match_operand:SI 2 "reg_or_cint_operand" "rn,rn")) 0))
3948                     (const_int 0)))
3949    (set (match_operand:SI 0 "gpc_reg_operand" "=r,r")
3950         (zero_extend:SI (subreg:HI (rotate:SI (match_dup 1) (match_dup 2)) 0)))]
3951   "!BYTES_BIG_ENDIAN"
3952   "@
3953    rlw%I2nm. %0,%1,%h2,0xffff
3954    #"
3955   [(set_attr "type" "shift")
3956    (set_attr "maybe_var_shift" "yes")
3957    (set_attr "dot" "yes")
3958    (set_attr "length" "4,8")])
3959
3960 (define_insn "*rotlsi3_internal12be"
3961   [(set (match_operand:CC 3 "cc_reg_operand" "=x,?y")
3962         (compare:CC (zero_extend:SI
3963                      (subreg:HI
3964                       (rotate:SI (match_operand:SI 1 "gpc_reg_operand" "r,r")
3965                                  (match_operand:SI 2 "reg_or_cint_operand" "rn,rn")) 2))
3966                     (const_int 0)))
3967    (set (match_operand:SI 0 "gpc_reg_operand" "=r,r")
3968         (zero_extend:SI (subreg:HI (rotate:SI (match_dup 1) (match_dup 2)) 2)))]
3969   "BYTES_BIG_ENDIAN"
3970   "@
3971    rlw%I2nm. %0,%1,%h2,0xffff
3972    #"
3973   [(set_attr "type" "shift")
3974    (set_attr "maybe_var_shift" "yes")
3975    (set_attr "dot" "yes")
3976    (set_attr "length" "4,8")])
3977
3978 (define_split
3979   [(set (match_operand:CC 3 "cc_reg_not_micro_cr0_operand" "")
3980         (compare:CC (zero_extend:SI
3981                      (subreg:HI
3982                       (rotate:SI (match_operand:SI 1 "gpc_reg_operand" "")
3983                                  (match_operand:SI 2 "reg_or_cint_operand" "")) 0))
3984                     (const_int 0)))
3985    (set (match_operand:SI 0 "gpc_reg_operand" "")
3986         (zero_extend:SI (subreg:HI (rotate:SI (match_dup 1) (match_dup 2)) 0)))]
3987   "!BYTES_BIG_ENDIAN && reload_completed"
3988   [(set (match_dup 0)
3989         (zero_extend:SI (subreg:HI (rotate:SI (match_dup 1) (match_dup 2)) 0)))
3990    (set (match_dup 3)
3991         (compare:CC (match_dup 0)
3992                     (const_int 0)))]
3993   "")
3994
3995 (define_split
3996   [(set (match_operand:CC 3 "cc_reg_not_micro_cr0_operand" "")
3997         (compare:CC (zero_extend:SI
3998                      (subreg:HI
3999                       (rotate:SI (match_operand:SI 1 "gpc_reg_operand" "")
4000                                  (match_operand:SI 2 "reg_or_cint_operand" "")) 2))
4001                     (const_int 0)))
4002    (set (match_operand:SI 0 "gpc_reg_operand" "")
4003         (zero_extend:SI (subreg:HI (rotate:SI (match_dup 1) (match_dup 2)) 2)))]
4004   "BYTES_BIG_ENDIAN && reload_completed"
4005   [(set (match_dup 0)
4006         (zero_extend:SI (subreg:HI (rotate:SI (match_dup 1) (match_dup 2)) 2)))
4007    (set (match_dup 3)
4008         (compare:CC (match_dup 0)
4009                     (const_int 0)))]
4010   "")
4011
4012
4013 (define_insn "ashl<mode>3"
4014   [(set (match_operand:GPR 0 "gpc_reg_operand" "=r")
4015         (ashift:GPR (match_operand:GPR 1 "gpc_reg_operand" "r")
4016                     (match_operand:SI 2 "reg_or_cint_operand" "rn")))]
4017   ""
4018   "sl<wd>%I2 %0,%1,%<hH>2"
4019   [(set_attr "type" "shift")
4020    (set_attr "maybe_var_shift" "yes")])
4021
4022 (define_insn "*ashlsi3_64"
4023   [(set (match_operand:DI 0 "gpc_reg_operand" "=r")
4024         (zero_extend:DI
4025             (ashift:SI (match_operand:SI 1 "gpc_reg_operand" "r")
4026                        (match_operand:SI 2 "reg_or_cint_operand" "rn"))))]
4027   "TARGET_POWERPC64"
4028   "slw%I2 %0,%1,%h2"
4029   [(set_attr "type" "shift")
4030    (set_attr "maybe_var_shift" "yes")])
4031
4032 (define_insn_and_split "*ashl<mode>3_dot"
4033   [(set (match_operand:CC 3 "cc_reg_operand" "=x,?y")
4034         (compare:CC (ashift:GPR (match_operand:GPR 1 "gpc_reg_operand" "r,r")
4035                                 (match_operand:SI 2 "reg_or_cint_operand" "rn,rn"))
4036                     (const_int 0)))
4037    (clobber (match_scratch:GPR 0 "=r,r"))]
4038   "<MODE>mode == Pmode && rs6000_gen_cell_microcode"
4039   "@
4040    sl<wd>%I2. %0,%1,%<hH>2
4041    #"
4042   "&& reload_completed && cc_reg_not_cr0_operand (operands[3], CCmode)"
4043   [(set (match_dup 0)
4044         (ashift:GPR (match_dup 1)
4045                     (match_dup 2)))
4046    (set (match_dup 3)
4047         (compare:CC (match_dup 0)
4048                     (const_int 0)))]
4049   ""
4050   [(set_attr "type" "shift")
4051    (set_attr "maybe_var_shift" "yes")
4052    (set_attr "dot" "yes")
4053    (set_attr "length" "4,8")])
4054
4055 (define_insn_and_split "*ashl<mode>3_dot2"
4056   [(set (match_operand:CC 3 "cc_reg_operand" "=x,?y")
4057         (compare:CC (ashift:GPR (match_operand:GPR 1 "gpc_reg_operand" "r,r")
4058                                 (match_operand:SI 2 "reg_or_cint_operand" "rn,rn"))
4059                     (const_int 0)))
4060    (set (match_operand:GPR 0 "gpc_reg_operand" "=r,r")
4061         (ashift:GPR (match_dup 1)
4062                     (match_dup 2)))]
4063   "<MODE>mode == Pmode && rs6000_gen_cell_microcode"
4064   "@
4065    sl<wd>%I2. %0,%1,%<hH>2
4066    #"
4067   "&& reload_completed && cc_reg_not_cr0_operand (operands[3], CCmode)"
4068   [(set (match_dup 0)
4069         (ashift:GPR (match_dup 1)
4070                     (match_dup 2)))
4071    (set (match_dup 3)
4072         (compare:CC (match_dup 0)
4073                     (const_int 0)))]
4074   ""
4075   [(set_attr "type" "shift")
4076    (set_attr "maybe_var_shift" "yes")
4077    (set_attr "dot" "yes")
4078    (set_attr "length" "4,8")])
4079
4080
4081 (define_insn "rlwinm"
4082   [(set (match_operand:SI 0 "gpc_reg_operand" "=r")
4083         (and:SI (ashift:SI (match_operand:SI 1 "gpc_reg_operand" "r")
4084                            (match_operand:SI 2 "const_int_operand" "i"))
4085                 (match_operand:SI 3 "mask_operand" "n")))]
4086   "includes_lshift_p (operands[2], operands[3])"
4087   "rlwinm %0,%1,%h2,%m3,%M3"
4088   [(set_attr "type" "shift")])
4089
4090 (define_insn ""
4091   [(set (match_operand:CC 0 "cc_reg_operand" "=x,?y")
4092         (compare:CC
4093          (and:SI (ashift:SI (match_operand:SI 1 "gpc_reg_operand" "r,r")
4094                             (match_operand:SI 2 "const_int_operand" "i,i"))
4095                  (match_operand:SI 3 "mask_operand" "n,n"))
4096          (const_int 0)))
4097    (clobber (match_scratch:SI 4 "=r,r"))]
4098   "includes_lshift_p (operands[2], operands[3])"
4099   "@
4100    rlwinm. %4,%1,%h2,%m3,%M3
4101    #"
4102   [(set_attr "type" "shift")
4103    (set_attr "dot" "yes")
4104    (set_attr "length" "4,8")])
4105
4106 (define_split
4107   [(set (match_operand:CC 0 "cc_reg_not_micro_cr0_operand" "")
4108         (compare:CC
4109          (and:SI (ashift:SI (match_operand:SI 1 "gpc_reg_operand" "")
4110                             (match_operand:SI 2 "const_int_operand" ""))
4111                  (match_operand:SI 3 "mask_operand" ""))
4112          (const_int 0)))
4113    (clobber (match_scratch:SI 4 ""))]
4114   "includes_lshift_p (operands[2], operands[3]) && reload_completed"
4115   [(set (match_dup 4)
4116         (and:SI (ashift:SI (match_dup 1) (match_dup 2))
4117                  (match_dup 3)))
4118    (set (match_dup 0)
4119         (compare:CC (match_dup 4)
4120                     (const_int 0)))]
4121   "")
4122
4123 (define_insn ""
4124   [(set (match_operand:CC 4 "cc_reg_operand" "=x,?y")
4125         (compare:CC
4126          (and:SI (ashift:SI (match_operand:SI 1 "gpc_reg_operand" "r,r")
4127                             (match_operand:SI 2 "const_int_operand" "i,i"))
4128                  (match_operand:SI 3 "mask_operand" "n,n"))
4129          (const_int 0)))
4130    (set (match_operand:SI 0 "gpc_reg_operand" "=r,r")
4131         (and:SI (ashift:SI (match_dup 1) (match_dup 2)) (match_dup 3)))]
4132   "includes_lshift_p (operands[2], operands[3])"
4133   "@
4134    rlwinm. %0,%1,%h2,%m3,%M3
4135    #"
4136   [(set_attr "type" "shift")
4137    (set_attr "dot" "yes")
4138    (set_attr "length" "4,8")])
4139
4140 (define_split
4141   [(set (match_operand:CC 4 "cc_reg_not_micro_cr0_operand" "")
4142         (compare:CC
4143          (and:SI (ashift:SI (match_operand:SI 1 "gpc_reg_operand" "")
4144                             (match_operand:SI 2 "const_int_operand" ""))
4145                  (match_operand:SI 3 "mask_operand" ""))
4146          (const_int 0)))
4147    (set (match_operand:SI 0 "gpc_reg_operand" "")
4148         (and:SI (ashift:SI (match_dup 1) (match_dup 2)) (match_dup 3)))]
4149   "includes_lshift_p (operands[2], operands[3]) && reload_completed"
4150   [(set (match_dup 0)
4151         (and:SI (ashift:SI (match_dup 1) (match_dup 2)) (match_dup 3)))
4152    (set (match_dup 4)
4153         (compare:CC (match_dup 0)
4154                     (const_int 0)))]
4155   "")
4156
4157
4158 (define_insn "lshr<mode>3"
4159   [(set (match_operand:GPR 0 "gpc_reg_operand" "=r")
4160         (lshiftrt:GPR (match_operand:GPR 1 "gpc_reg_operand" "r")
4161                       (match_operand:SI 2 "reg_or_cint_operand" "rn")))]
4162   ""
4163   "sr<wd>%I2 %0,%1,%<hH>2"
4164   [(set_attr "type" "shift")
4165    (set_attr "maybe_var_shift" "yes")])
4166
4167 (define_insn "*lshrsi3_64"
4168   [(set (match_operand:DI 0 "gpc_reg_operand" "=r")
4169         (zero_extend:DI
4170             (lshiftrt:SI (match_operand:SI 1 "gpc_reg_operand" "r")
4171                          (match_operand:SI 2 "reg_or_cint_operand" "rn"))))]
4172   "TARGET_POWERPC64"
4173   "srw%I2 %0,%1,%h2"
4174   [(set_attr "type" "shift")
4175    (set_attr "maybe_var_shift" "yes")])
4176
4177 (define_insn_and_split "*lshr<mode>3_dot"
4178   [(set (match_operand:CC 3 "cc_reg_operand" "=x,?y")
4179         (compare:CC (lshiftrt:GPR (match_operand:GPR 1 "gpc_reg_operand" "r,r")
4180                                   (match_operand:SI 2 "reg_or_cint_operand" "rn,rn"))
4181                     (const_int 0)))
4182    (clobber (match_scratch:GPR 0 "=r,r"))]
4183   "<MODE>mode == Pmode && rs6000_gen_cell_microcode"
4184   "@
4185    sr<wd>%I2. %0,%1,%<hH>2
4186    #"
4187   "&& reload_completed && cc_reg_not_cr0_operand (operands[3], CCmode)"
4188   [(set (match_dup 0)
4189         (lshiftrt:GPR (match_dup 1)
4190                       (match_dup 2)))
4191    (set (match_dup 3)
4192         (compare:CC (match_dup 0)
4193                     (const_int 0)))]
4194   ""
4195   [(set_attr "type" "shift")
4196    (set_attr "maybe_var_shift" "yes")
4197    (set_attr "dot" "yes")
4198    (set_attr "length" "4,8")])
4199
4200 (define_insn_and_split "*lshr<mode>3_dot2"
4201   [(set (match_operand:CC 3 "cc_reg_operand" "=x,?y")
4202         (compare:CC (lshiftrt:GPR (match_operand:GPR 1 "gpc_reg_operand" "r,r")
4203                                   (match_operand:SI 2 "reg_or_cint_operand" "rn,rn"))
4204                     (const_int 0)))
4205    (set (match_operand:GPR 0 "gpc_reg_operand" "=r,r")
4206         (lshiftrt:GPR (match_dup 1)
4207                       (match_dup 2)))]
4208   "<MODE>mode == Pmode && rs6000_gen_cell_microcode"
4209   "@
4210    sr<wd>%I2. %0,%1,%<hH>2
4211    #"
4212   "&& reload_completed && cc_reg_not_cr0_operand (operands[3], CCmode)"
4213   [(set (match_dup 0)
4214         (lshiftrt:GPR (match_dup 1)
4215                       (match_dup 2)))
4216    (set (match_dup 3)
4217         (compare:CC (match_dup 0)
4218                     (const_int 0)))]
4219   ""
4220   [(set_attr "type" "shift")
4221    (set_attr "maybe_var_shift" "yes")
4222    (set_attr "dot" "yes")
4223    (set_attr "length" "4,8")])
4224
4225
4226 (define_insn ""
4227   [(set (match_operand:SI 0 "gpc_reg_operand" "=r")
4228         (and:SI (lshiftrt:SI (match_operand:SI 1 "gpc_reg_operand" "r")
4229                              (match_operand:SI 2 "const_int_operand" "i"))
4230                 (match_operand:SI 3 "mask_operand" "n")))]
4231   "includes_rshift_p (operands[2], operands[3])"
4232   "rlwinm %0,%1,%s2,%m3,%M3"
4233   [(set_attr "type" "shift")])
4234
4235 (define_insn ""
4236   [(set (match_operand:CC 0 "cc_reg_operand" "=x,?y")
4237         (compare:CC
4238          (and:SI (lshiftrt:SI (match_operand:SI 1 "gpc_reg_operand" "r,r")
4239                               (match_operand:SI 2 "const_int_operand" "i,i"))
4240                  (match_operand:SI 3 "mask_operand" "n,n"))
4241          (const_int 0)))
4242    (clobber (match_scratch:SI 4 "=r,r"))]
4243   "includes_rshift_p (operands[2], operands[3])"
4244   "@
4245    rlwinm. %4,%1,%s2,%m3,%M3
4246    #"
4247   [(set_attr "type" "shift")
4248    (set_attr "dot" "yes")
4249    (set_attr "length" "4,8")])
4250
4251 (define_split
4252   [(set (match_operand:CC 0 "cc_reg_not_micro_cr0_operand" "")
4253         (compare:CC
4254          (and:SI (lshiftrt:SI (match_operand:SI 1 "gpc_reg_operand" "")
4255                               (match_operand:SI 2 "const_int_operand" ""))
4256                  (match_operand:SI 3 "mask_operand" ""))
4257          (const_int 0)))
4258    (clobber (match_scratch:SI 4 ""))]
4259   "includes_rshift_p (operands[2], operands[3]) && reload_completed"
4260   [(set (match_dup 4)
4261         (and:SI (lshiftrt:SI (match_dup 1) (match_dup 2))
4262                  (match_dup 3)))
4263    (set (match_dup 0)
4264         (compare:CC (match_dup 4)
4265                     (const_int 0)))]
4266   "")
4267
4268 (define_insn ""
4269   [(set (match_operand:CC 4 "cc_reg_operand" "=x,?y")
4270         (compare:CC
4271          (and:SI (lshiftrt:SI (match_operand:SI 1 "gpc_reg_operand" "r,r")
4272                               (match_operand:SI 2 "const_int_operand" "i,i"))
4273                  (match_operand:SI 3 "mask_operand" "n,n"))
4274          (const_int 0)))
4275    (set (match_operand:SI 0 "gpc_reg_operand" "=r,r")
4276         (and:SI (lshiftrt:SI (match_dup 1) (match_dup 2)) (match_dup 3)))]
4277   "includes_rshift_p (operands[2], operands[3])"
4278   "@
4279    rlwinm. %0,%1,%s2,%m3,%M3
4280    #"
4281   [(set_attr "type" "shift")
4282    (set_attr "dot" "yes")
4283    (set_attr "length" "4,8")])
4284
4285 (define_split
4286   [(set (match_operand:CC 4 "cc_reg_not_micro_cr0_operand" "")
4287         (compare:CC
4288          (and:SI (lshiftrt:SI (match_operand:SI 1 "gpc_reg_operand" "")
4289                               (match_operand:SI 2 "const_int_operand" ""))
4290                  (match_operand:SI 3 "mask_operand" ""))
4291          (const_int 0)))
4292    (set (match_operand:SI 0 "gpc_reg_operand" "")
4293         (and:SI (lshiftrt:SI (match_dup 1) (match_dup 2)) (match_dup 3)))]
4294   "includes_rshift_p (operands[2], operands[3]) && reload_completed"
4295   [(set (match_dup 0)
4296         (and:SI (lshiftrt:SI (match_dup 1) (match_dup 2)) (match_dup 3)))
4297    (set (match_dup 4)
4298         (compare:CC (match_dup 0)
4299                     (const_int 0)))]
4300   "")
4301
4302 (define_insn "*lshiftrt_internal1le"
4303   [(set (match_operand:SI 0 "gpc_reg_operand" "=r")
4304         (zero_extend:SI
4305          (subreg:QI
4306           (lshiftrt:SI (match_operand:SI 1 "gpc_reg_operand" "r")
4307                        (match_operand:SI 2 "const_int_operand" "i")) 0)))]
4308   "!BYTES_BIG_ENDIAN && includes_rshift_p (operands[2], GEN_INT (255))"
4309   "rlwinm %0,%1,%s2,0xff"
4310   [(set_attr "type" "shift")])
4311
4312 (define_insn "*lshiftrt_internal1be"
4313   [(set (match_operand:SI 0 "gpc_reg_operand" "=r")
4314         (zero_extend:SI
4315          (subreg:QI
4316           (lshiftrt:SI (match_operand:SI 1 "gpc_reg_operand" "r")
4317                        (match_operand:SI 2 "const_int_operand" "i")) 3)))]
4318   "BYTES_BIG_ENDIAN && includes_rshift_p (operands[2], GEN_INT (255))"
4319   "rlwinm %0,%1,%s2,0xff"
4320   [(set_attr "type" "shift")])
4321
4322 (define_insn "*lshiftrt_internal2le"
4323   [(set (match_operand:CC 0 "cc_reg_operand" "=x,?y")
4324         (compare:CC
4325          (zero_extend:SI
4326           (subreg:QI
4327            (lshiftrt:SI (match_operand:SI 1 "gpc_reg_operand" "r,r")
4328                         (match_operand:SI 2 "const_int_operand" "i,i")) 0))
4329          (const_int 0)))
4330    (clobber (match_scratch:SI 3 "=r,r"))]
4331   "!BYTES_BIG_ENDIAN && includes_rshift_p (operands[2], GEN_INT (255))"
4332   "@
4333    rlwinm. %3,%1,%s2,0xff
4334    #"
4335   [(set_attr "type" "shift")
4336    (set_attr "dot" "yes")
4337    (set_attr "length" "4,8")])
4338
4339 (define_insn "*lshiftrt_internal2be"
4340   [(set (match_operand:CC 0 "cc_reg_operand" "=x,?y")
4341         (compare:CC
4342          (zero_extend:SI
4343           (subreg:QI
4344            (lshiftrt:SI (match_operand:SI 1 "gpc_reg_operand" "r,r")
4345                         (match_operand:SI 2 "const_int_operand" "i,i")) 3))
4346          (const_int 0)))
4347    (clobber (match_scratch:SI 3 "=r,r"))]
4348   "BYTES_BIG_ENDIAN && includes_rshift_p (operands[2], GEN_INT (255))"
4349   "@
4350    rlwinm. %3,%1,%s2,0xff
4351    #"
4352   [(set_attr "type" "shift")
4353    (set_attr "dot" "yes")
4354    (set_attr "length" "4,8")])
4355
4356 (define_split
4357   [(set (match_operand:CC 0 "cc_reg_not_micro_cr0_operand" "")
4358         (compare:CC
4359          (zero_extend:SI
4360           (subreg:QI
4361            (lshiftrt:SI (match_operand:SI 1 "gpc_reg_operand" "")
4362                         (match_operand:SI 2 "const_int_operand" "")) 0))
4363          (const_int 0)))
4364    (clobber (match_scratch:SI 3 ""))]
4365   "!BYTES_BIG_ENDIAN && includes_rshift_p (operands[2], GEN_INT (255)) && reload_completed"
4366   [(set (match_dup 3)
4367         (zero_extend:SI (subreg:QI
4368            (lshiftrt:SI (match_dup 1)
4369                         (match_dup 2)) 0)))
4370    (set (match_dup 0)
4371         (compare:CC (match_dup 3)
4372                     (const_int 0)))]
4373   "")
4374
4375 (define_split
4376   [(set (match_operand:CC 0 "cc_reg_not_micro_cr0_operand" "")
4377         (compare:CC
4378          (zero_extend:SI
4379           (subreg:QI
4380            (lshiftrt:SI (match_operand:SI 1 "gpc_reg_operand" "")
4381                         (match_operand:SI 2 "const_int_operand" "")) 3))
4382          (const_int 0)))
4383    (clobber (match_scratch:SI 3 ""))]
4384   "BYTES_BIG_ENDIAN && includes_rshift_p (operands[2], GEN_INT (255)) && reload_completed"
4385   [(set (match_dup 3)
4386         (zero_extend:SI (subreg:QI
4387            (lshiftrt:SI (match_dup 1)
4388                         (match_dup 2)) 3)))
4389    (set (match_dup 0)
4390         (compare:CC (match_dup 3)
4391                     (const_int 0)))]
4392   "")
4393
4394 (define_insn "*lshiftrt_internal3le"
4395   [(set (match_operand:CC 3 "cc_reg_operand" "=x,?y")
4396         (compare:CC
4397          (zero_extend:SI
4398           (subreg:QI
4399            (lshiftrt:SI (match_operand:SI 1 "gpc_reg_operand" "r,r")
4400                         (match_operand:SI 2 "const_int_operand" "i,i")) 0))
4401          (const_int 0)))
4402    (set (match_operand:SI 0 "gpc_reg_operand" "=r,r")
4403         (zero_extend:SI (subreg:QI (lshiftrt:SI (match_dup 1) (match_dup 2)) 0)))]
4404   "!BYTES_BIG_ENDIAN && includes_rshift_p (operands[2], GEN_INT (255))"
4405   "@
4406    rlwinm. %0,%1,%s2,0xff
4407    #"
4408   [(set_attr "type" "shift")
4409    (set_attr "dot" "yes")
4410    (set_attr "length" "4,8")])
4411
4412 (define_insn "*lshiftrt_internal3be"
4413   [(set (match_operand:CC 3 "cc_reg_operand" "=x,?y")
4414         (compare:CC
4415          (zero_extend:SI
4416           (subreg:QI
4417            (lshiftrt:SI (match_operand:SI 1 "gpc_reg_operand" "r,r")
4418                         (match_operand:SI 2 "const_int_operand" "i,i")) 3))
4419          (const_int 0)))
4420    (set (match_operand:SI 0 "gpc_reg_operand" "=r,r")
4421         (zero_extend:SI (subreg:QI (lshiftrt:SI (match_dup 1) (match_dup 2)) 3)))]
4422   "BYTES_BIG_ENDIAN && includes_rshift_p (operands[2], GEN_INT (255))"
4423   "@
4424    rlwinm. %0,%1,%s2,0xff
4425    #"
4426   [(set_attr "type" "shift")
4427    (set_attr "dot" "yes")
4428    (set_attr "length" "4,8")])
4429
4430 (define_split
4431   [(set (match_operand:CC 3 "cc_reg_not_micro_cr0_operand" "")
4432         (compare:CC
4433          (zero_extend:SI
4434           (subreg:QI
4435            (lshiftrt:SI (match_operand:SI 1 "gpc_reg_operand" "")
4436                         (match_operand:SI 2 "const_int_operand" "")) 0))
4437          (const_int 0)))
4438    (set (match_operand:SI 0 "gpc_reg_operand" "")
4439         (zero_extend:SI (subreg:QI (lshiftrt:SI (match_dup 1) (match_dup 2)) 0)))]
4440   "!BYTES_BIG_ENDIAN && includes_rshift_p (operands[2], GEN_INT (255)) && reload_completed"
4441   [(set (match_dup 0)
4442         (zero_extend:SI (subreg:QI (lshiftrt:SI (match_dup 1) (match_dup 2)) 0)))
4443    (set (match_dup 3)
4444         (compare:CC (match_dup 0)
4445                     (const_int 0)))]
4446   "")
4447
4448 (define_split
4449   [(set (match_operand:CC 3 "cc_reg_not_micro_cr0_operand" "")
4450         (compare:CC
4451          (zero_extend:SI
4452           (subreg:QI
4453            (lshiftrt:SI (match_operand:SI 1 "gpc_reg_operand" "")
4454                         (match_operand:SI 2 "const_int_operand" "")) 3))
4455          (const_int 0)))
4456    (set (match_operand:SI 0 "gpc_reg_operand" "")
4457         (zero_extend:SI (subreg:QI (lshiftrt:SI (match_dup 1) (match_dup 2)) 3)))]
4458   "BYTES_BIG_ENDIAN && includes_rshift_p (operands[2], GEN_INT (255)) && reload_completed"
4459   [(set (match_dup 0)
4460         (zero_extend:SI (subreg:QI (lshiftrt:SI (match_dup 1) (match_dup 2)) 3)))
4461    (set (match_dup 3)
4462         (compare:CC (match_dup 0)
4463                     (const_int 0)))]
4464   "")
4465
4466 (define_insn "*lshiftrt_internal4le"
4467   [(set (match_operand:SI 0 "gpc_reg_operand" "=r")
4468         (zero_extend:SI
4469          (subreg:HI
4470           (lshiftrt:SI (match_operand:SI 1 "gpc_reg_operand" "r")
4471                        (match_operand:SI 2 "const_int_operand" "i")) 0)))]
4472   "!BYTES_BIG_ENDIAN && includes_rshift_p (operands[2], GEN_INT (65535))"
4473   "rlwinm %0,%1,%s2,0xffff"
4474   [(set_attr "type" "shift")])
4475
4476 (define_insn "*lshiftrt_internal4be"
4477   [(set (match_operand:SI 0 "gpc_reg_operand" "=r")
4478         (zero_extend:SI
4479          (subreg:HI
4480           (lshiftrt:SI (match_operand:SI 1 "gpc_reg_operand" "r")
4481                        (match_operand:SI 2 "const_int_operand" "i")) 2)))]
4482   "BYTES_BIG_ENDIAN && includes_rshift_p (operands[2], GEN_INT (65535))"
4483   "rlwinm %0,%1,%s2,0xffff"
4484   [(set_attr "type" "shift")])
4485
4486 (define_insn "*lshiftrt_internal5le"
4487   [(set (match_operand:CC 0 "cc_reg_operand" "=x,?y")
4488         (compare:CC
4489          (zero_extend:SI
4490           (subreg:HI
4491            (lshiftrt:SI (match_operand:SI 1 "gpc_reg_operand" "r,r")
4492                         (match_operand:SI 2 "const_int_operand" "i,i")) 0))
4493          (const_int 0)))
4494    (clobber (match_scratch:SI 3 "=r,r"))]
4495   "!BYTES_BIG_ENDIAN && includes_rshift_p (operands[2], GEN_INT (65535))"
4496   "@
4497    rlwinm. %3,%1,%s2,0xffff
4498    #"
4499   [(set_attr "type" "shift")
4500    (set_attr "dot" "yes")
4501    (set_attr "length" "4,8")])
4502
4503 (define_insn "*lshiftrt_internal5be"
4504   [(set (match_operand:CC 0 "cc_reg_operand" "=x,?y")
4505         (compare:CC
4506          (zero_extend:SI
4507           (subreg:HI
4508            (lshiftrt:SI (match_operand:SI 1 "gpc_reg_operand" "r,r")
4509                         (match_operand:SI 2 "const_int_operand" "i,i")) 2))
4510          (const_int 0)))
4511    (clobber (match_scratch:SI 3 "=r,r"))]
4512   "BYTES_BIG_ENDIAN && includes_rshift_p (operands[2], GEN_INT (65535))"
4513   "@
4514    rlwinm. %3,%1,%s2,0xffff
4515    #"
4516   [(set_attr "type" "shift")
4517    (set_attr "dot" "yes")
4518    (set_attr "length" "4,8")])
4519
4520 (define_split
4521   [(set (match_operand:CC 0 "cc_reg_not_micro_cr0_operand" "")
4522         (compare:CC
4523          (zero_extend:SI
4524           (subreg:HI
4525            (lshiftrt:SI (match_operand:SI 1 "gpc_reg_operand" "")
4526                         (match_operand:SI 2 "const_int_operand" "")) 0))
4527          (const_int 0)))
4528    (clobber (match_scratch:SI 3 ""))]
4529   "!BYTES_BIG_ENDIAN && includes_rshift_p (operands[2], GEN_INT (65535)) && reload_completed"
4530   [(set (match_dup 3)
4531         (zero_extend:SI (subreg:HI
4532            (lshiftrt:SI (match_dup 1)
4533                         (match_dup 2)) 0)))
4534    (set (match_dup 0)
4535         (compare:CC (match_dup 3)
4536                     (const_int 0)))]
4537   "")
4538
4539 (define_split
4540   [(set (match_operand:CC 0 "cc_reg_not_micro_cr0_operand" "")
4541         (compare:CC
4542          (zero_extend:SI
4543           (subreg:HI
4544            (lshiftrt:SI (match_operand:SI 1 "gpc_reg_operand" "")
4545                         (match_operand:SI 2 "const_int_operand" "")) 2))
4546          (const_int 0)))
4547    (clobber (match_scratch:SI 3 ""))]
4548   "BYTES_BIG_ENDIAN && includes_rshift_p (operands[2], GEN_INT (65535)) && reload_completed"
4549   [(set (match_dup 3)
4550         (zero_extend:SI (subreg:HI
4551            (lshiftrt:SI (match_dup 1)
4552                         (match_dup 2)) 2)))
4553    (set (match_dup 0)
4554         (compare:CC (match_dup 3)
4555                     (const_int 0)))]
4556   "")
4557
4558 (define_insn "*lshiftrt_internal5le"
4559   [(set (match_operand:CC 3 "cc_reg_operand" "=x,?y")
4560         (compare:CC
4561          (zero_extend:SI
4562           (subreg:HI
4563            (lshiftrt:SI (match_operand:SI 1 "gpc_reg_operand" "r,r")
4564                         (match_operand:SI 2 "const_int_operand" "i,i")) 0))
4565          (const_int 0)))
4566    (set (match_operand:SI 0 "gpc_reg_operand" "=r,r")
4567         (zero_extend:SI (subreg:HI (lshiftrt:SI (match_dup 1) (match_dup 2)) 0)))]
4568   "!BYTES_BIG_ENDIAN && includes_rshift_p (operands[2], GEN_INT (65535))"
4569   "@
4570    rlwinm. %0,%1,%s2,0xffff
4571    #"
4572   [(set_attr "type" "shift")
4573    (set_attr "dot" "yes")
4574    (set_attr "length" "4,8")])
4575
4576 (define_insn "*lshiftrt_internal5be"
4577   [(set (match_operand:CC 3 "cc_reg_operand" "=x,?y")
4578         (compare:CC
4579          (zero_extend:SI
4580           (subreg:HI
4581            (lshiftrt:SI (match_operand:SI 1 "gpc_reg_operand" "r,r")
4582                         (match_operand:SI 2 "const_int_operand" "i,i")) 2))
4583          (const_int 0)))
4584    (set (match_operand:SI 0 "gpc_reg_operand" "=r,r")
4585         (zero_extend:SI (subreg:HI (lshiftrt:SI (match_dup 1) (match_dup 2)) 2)))]
4586   "BYTES_BIG_ENDIAN && includes_rshift_p (operands[2], GEN_INT (65535))"
4587   "@
4588    rlwinm. %0,%1,%s2,0xffff
4589    #"
4590   [(set_attr "type" "shift")
4591    (set_attr "dot" "yes")
4592    (set_attr "length" "4,8")])
4593
4594 (define_split
4595   [(set (match_operand:CC 3 "cc_reg_not_micro_cr0_operand" "")
4596         (compare:CC
4597          (zero_extend:SI
4598           (subreg:HI
4599            (lshiftrt:SI (match_operand:SI 1 "gpc_reg_operand" "")
4600                         (match_operand:SI 2 "const_int_operand" "")) 0))
4601          (const_int 0)))
4602    (set (match_operand:SI 0 "gpc_reg_operand" "")
4603         (zero_extend:SI (subreg:HI (lshiftrt:SI (match_dup 1) (match_dup 2)) 0)))]
4604   "!BYTES_BIG_ENDIAN && includes_rshift_p (operands[2], GEN_INT (65535)) && reload_completed"
4605   [(set (match_dup 0)
4606         (zero_extend:SI (subreg:HI (lshiftrt:SI (match_dup 1) (match_dup 2)) 0)))
4607    (set (match_dup 3)
4608         (compare:CC (match_dup 0)
4609                     (const_int 0)))]
4610   "")
4611
4612 (define_split
4613   [(set (match_operand:CC 3 "cc_reg_not_micro_cr0_operand" "")
4614         (compare:CC
4615          (zero_extend:SI
4616           (subreg:HI
4617            (lshiftrt:SI (match_operand:SI 1 "gpc_reg_operand" "")
4618                         (match_operand:SI 2 "const_int_operand" "")) 2))
4619          (const_int 0)))
4620    (set (match_operand:SI 0 "gpc_reg_operand" "")
4621         (zero_extend:SI (subreg:HI (lshiftrt:SI (match_dup 1) (match_dup 2)) 2)))]
4622   "BYTES_BIG_ENDIAN && includes_rshift_p (operands[2], GEN_INT (65535)) && reload_completed"
4623   [(set (match_dup 0)
4624         (zero_extend:SI (subreg:HI (lshiftrt:SI (match_dup 1) (match_dup 2)) 2)))
4625    (set (match_dup 3)
4626         (compare:CC (match_dup 0)
4627                     (const_int 0)))]
4628   "")
4629
4630
4631 (define_expand "ashr<mode>3"
4632   [(parallel [(set (match_operand:GPR 0 "gpc_reg_operand" "")
4633                    (ashiftrt:GPR (match_operand:GPR 1 "gpc_reg_operand" "")
4634                                  (match_operand:SI 2 "reg_or_cint_operand" "")))
4635               (clobber (reg:GPR CA_REGNO))])]
4636   ""
4637 {
4638   /* The generic code does not generate optimal code for the low word
4639      (it should be a rlwimi and a rot).  Until we have target code to
4640      solve this generically, keep this expander.  */
4641
4642   if (<MODE>mode == DImode && !TARGET_POWERPC64)
4643     {
4644       if (CONST_INT_P (operands[2]))
4645         {
4646           emit_insn (gen_ashrdi3_no_power (operands[0], operands[1], operands[2]));
4647           DONE;
4648         }
4649       else
4650         FAIL;
4651     }
4652 })
4653
4654 (define_insn "*ashr<mode>3"
4655   [(set (match_operand:GPR 0 "gpc_reg_operand" "=r")
4656         (ashiftrt:GPR (match_operand:GPR 1 "gpc_reg_operand" "r")
4657                       (match_operand:SI 2 "reg_or_cint_operand" "rn")))
4658    (clobber (reg:GPR CA_REGNO))]
4659   ""
4660   "sra<wd>%I2 %0,%1,%<hH>2"
4661   [(set_attr "type" "shift")
4662    (set_attr "maybe_var_shift" "yes")])
4663
4664 (define_insn "*ashrsi3_64"
4665   [(set (match_operand:DI 0 "gpc_reg_operand" "=r")
4666         (sign_extend:DI
4667             (ashiftrt:SI (match_operand:SI 1 "gpc_reg_operand" "r")
4668                          (match_operand:SI 2 "reg_or_cint_operand" "rn"))))
4669    (clobber (reg:SI CA_REGNO))]
4670   "TARGET_POWERPC64"
4671   "sraw%I2 %0,%1,%h2"
4672   [(set_attr "type" "shift")
4673    (set_attr "maybe_var_shift" "yes")])
4674
4675 (define_insn_and_split "*ashr<mode>3_dot"
4676   [(set (match_operand:CC 3 "cc_reg_operand" "=x,?y")
4677         (compare:CC (ashiftrt:GPR (match_operand:GPR 1 "gpc_reg_operand" "r,r")
4678                                   (match_operand:SI 2 "reg_or_cint_operand" "rn,rn"))
4679                     (const_int 0)))
4680    (clobber (match_scratch:GPR 0 "=r,r"))
4681    (clobber (reg:GPR CA_REGNO))]
4682   "<MODE>mode == Pmode && rs6000_gen_cell_microcode"
4683   "@
4684    sra<wd>%I2. %0,%1,%<hH>2
4685    #"
4686   "&& reload_completed && cc_reg_not_cr0_operand (operands[3], CCmode)"
4687   [(parallel [(set (match_dup 0)
4688                    (ashiftrt:GPR (match_dup 1)
4689                                  (match_dup 2)))
4690               (clobber (reg:GPR CA_REGNO))])
4691    (set (match_dup 3)
4692         (compare:CC (match_dup 0)
4693                     (const_int 0)))]
4694   ""
4695   [(set_attr "type" "shift")
4696    (set_attr "maybe_var_shift" "yes")
4697    (set_attr "dot" "yes")
4698    (set_attr "length" "4,8")])
4699
4700 (define_insn_and_split "*ashr<mode>3_dot2"
4701   [(set (match_operand:CC 3 "cc_reg_operand" "=x,?y")
4702         (compare:CC (ashiftrt:GPR (match_operand:GPR 1 "gpc_reg_operand" "r,r")
4703                                   (match_operand:SI 2 "reg_or_cint_operand" "rn,rn"))
4704                     (const_int 0)))
4705    (set (match_operand:GPR 0 "gpc_reg_operand" "=r,r")
4706         (ashiftrt:GPR (match_dup 1)
4707                       (match_dup 2)))
4708    (clobber (reg:GPR CA_REGNO))]
4709   "<MODE>mode == Pmode && rs6000_gen_cell_microcode"
4710   "@
4711    sra<wd>%I2. %0,%1,%<hH>2
4712    #"
4713   "&& reload_completed && cc_reg_not_cr0_operand (operands[3], CCmode)"
4714   [(parallel [(set (match_dup 0)
4715                    (ashiftrt:GPR (match_dup 1)
4716                                  (match_dup 2)))
4717               (clobber (reg:GPR CA_REGNO))])
4718    (set (match_dup 3)
4719         (compare:CC (match_dup 0)
4720                     (const_int 0)))]
4721   ""
4722   [(set_attr "type" "shift")
4723    (set_attr "maybe_var_shift" "yes")
4724    (set_attr "dot" "yes")
4725    (set_attr "length" "4,8")])
4726 \f
4727 ;; Builtins to replace a division to generate FRE reciprocal estimate
4728 ;; instructions and the necessary fixup instructions
4729 (define_expand "recip<mode>3"
4730   [(match_operand:RECIPF 0 "gpc_reg_operand" "")
4731    (match_operand:RECIPF 1 "gpc_reg_operand" "")
4732    (match_operand:RECIPF 2 "gpc_reg_operand" "")]
4733   "RS6000_RECIP_HAVE_RE_P (<MODE>mode)"
4734 {
4735    rs6000_emit_swdiv (operands[0], operands[1], operands[2], false);
4736    DONE;
4737 })
4738
4739 ;; Split to create division from FRE/FRES/etc. and fixup instead of the normal
4740 ;; hardware division.  This is only done before register allocation and with
4741 ;; -ffast-math.  This must appear before the divsf3/divdf3 insns.
4742 (define_split
4743   [(set (match_operand:RECIPF 0 "gpc_reg_operand" "")
4744         (div:RECIPF (match_operand 1 "gpc_reg_operand" "")
4745                     (match_operand 2 "gpc_reg_operand" "")))]
4746   "RS6000_RECIP_AUTO_RE_P (<MODE>mode)
4747    && can_create_pseudo_p () && optimize_insn_for_speed_p ()
4748    && flag_finite_math_only && !flag_trapping_math && flag_reciprocal_math"
4749   [(const_int 0)]
4750 {
4751   rs6000_emit_swdiv (operands[0], operands[1], operands[2], true);
4752   DONE;
4753 })
4754
4755 ;; Builtins to replace 1/sqrt(x) with instructions using RSQRTE and the
4756 ;; appropriate fixup.
4757 (define_expand "rsqrt<mode>2"
4758   [(match_operand:RECIPF 0 "gpc_reg_operand" "")
4759    (match_operand:RECIPF 1 "gpc_reg_operand" "")]
4760   "RS6000_RECIP_HAVE_RSQRTE_P (<MODE>mode)"
4761 {
4762   rs6000_emit_swrsqrt (operands[0], operands[1]);
4763   DONE;
4764 })
4765 \f
4766 ;; Floating-point insns, excluding normal data motion.  We combine the SF/DF
4767 ;; modes here, and also add in conditional vsx/power8-vector support to access
4768 ;; values in the traditional Altivec registers if the appropriate
4769 ;; -mupper-regs-{df,sf} option is enabled.
4770
4771 (define_expand "abs<mode>2"
4772   [(set (match_operand:SFDF 0 "gpc_reg_operand" "")
4773         (abs:SFDF (match_operand:SFDF 1 "gpc_reg_operand" "")))]
4774   "TARGET_<MODE>_INSN"
4775   "")
4776
4777 (define_insn "*abs<mode>2_fpr"
4778   [(set (match_operand:SFDF 0 "gpc_reg_operand" "=<Ff>,<Fv>")
4779         (abs:SFDF (match_operand:SFDF 1 "gpc_reg_operand" "<Ff>,<Fv>")))]
4780   "TARGET_<MODE>_FPR"
4781   "@
4782    fabs %0,%1
4783    xsabsdp %x0,%x1"
4784   [(set_attr "type" "fp")
4785    (set_attr "fp_type" "fp_addsub_<Fs>")])
4786
4787 (define_insn "*nabs<mode>2_fpr"
4788   [(set (match_operand:SFDF 0 "gpc_reg_operand" "=<Ff>,<Fv>")
4789         (neg:SFDF
4790          (abs:SFDF
4791           (match_operand:SFDF 1 "gpc_reg_operand" "<Ff>,<Fv>"))))]
4792   "TARGET_<MODE>_FPR"
4793   "@
4794    fnabs %0,%1
4795    xsnabsdp %x0,%x1"
4796   [(set_attr "type" "fp")
4797    (set_attr "fp_type" "fp_addsub_<Fs>")])
4798
4799 (define_expand "neg<mode>2"
4800   [(set (match_operand:SFDF 0 "gpc_reg_operand" "")
4801         (neg:SFDF (match_operand:SFDF 1 "gpc_reg_operand" "")))]
4802   "TARGET_<MODE>_INSN"
4803   "")
4804
4805 (define_insn "*neg<mode>2_fpr"
4806   [(set (match_operand:SFDF 0 "gpc_reg_operand" "=<Ff>,<Fv>")
4807         (neg:SFDF (match_operand:SFDF 1 "gpc_reg_operand" "<Ff>,<Fv>")))]
4808   "TARGET_<MODE>_FPR"
4809   "@
4810    fneg %0,%1
4811    xsnegdp %x0,%x1"
4812   [(set_attr "type" "fp")
4813    (set_attr "fp_type" "fp_addsub_<Fs>")])
4814
4815 (define_expand "add<mode>3"
4816   [(set (match_operand:SFDF 0 "gpc_reg_operand" "")
4817         (plus:SFDF (match_operand:SFDF 1 "gpc_reg_operand" "")
4818                    (match_operand:SFDF 2 "gpc_reg_operand" "")))]
4819   "TARGET_<MODE>_INSN"
4820   "")
4821
4822 (define_insn "*add<mode>3_fpr"
4823   [(set (match_operand:SFDF 0 "gpc_reg_operand" "=<Ff>,<Fv>")
4824         (plus:SFDF (match_operand:SFDF 1 "gpc_reg_operand" "%<Ff>,<Fv>")
4825                    (match_operand:SFDF 2 "gpc_reg_operand" "<Ff>,<Fv>")))]
4826   "TARGET_<MODE>_FPR"
4827   "@
4828    fadd<Ftrad> %0,%1,%2
4829    xsadd<Fvsx> %x0,%x1,%x2"
4830   [(set_attr "type" "fp")
4831    (set_attr "fp_type" "fp_addsub_<Fs>")])
4832
4833 (define_expand "sub<mode>3"
4834   [(set (match_operand:SFDF 0 "gpc_reg_operand" "")
4835         (minus:SFDF (match_operand:SFDF 1 "gpc_reg_operand" "")
4836                     (match_operand:SFDF 2 "gpc_reg_operand" "")))]
4837   "TARGET_<MODE>_INSN"
4838   "")
4839
4840 (define_insn "*sub<mode>3_fpr"
4841   [(set (match_operand:SFDF 0 "gpc_reg_operand" "=<Ff>,<Fv>")
4842         (minus:SFDF (match_operand:SFDF 1 "gpc_reg_operand" "<Ff>,<Fv>")
4843                     (match_operand:SFDF 2 "gpc_reg_operand" "<Ff>,<Fv>")))]
4844   "TARGET_<MODE>_FPR"
4845   "@
4846    fsub<Ftrad> %0,%1,%2
4847    xssub<Fvsx> %x0,%x1,%x2"
4848   [(set_attr "type" "fp")
4849    (set_attr "fp_type" "fp_addsub_<Fs>")])
4850
4851 (define_expand "mul<mode>3"
4852   [(set (match_operand:SFDF 0 "gpc_reg_operand" "")
4853         (mult:SFDF (match_operand:SFDF 1 "gpc_reg_operand" "")
4854                    (match_operand:SFDF 2 "gpc_reg_operand" "")))]
4855   "TARGET_<MODE>_INSN"
4856   "")
4857
4858 (define_insn "*mul<mode>3_fpr"
4859   [(set (match_operand:SFDF 0 "gpc_reg_operand" "=<Ff>,<Fv>")
4860         (mult:SFDF (match_operand:SFDF 1 "gpc_reg_operand" "%<Ff>,<Fv>")
4861                    (match_operand:SFDF 2 "gpc_reg_operand" "<Ff>,<Fv>")))]
4862   "TARGET_<MODE>_FPR"
4863   "@
4864    fmul<Ftrad> %0,%1,%2
4865    xsmul<Fvsx> %x0,%x1,%x2"
4866   [(set_attr "type" "dmul")
4867    (set_attr "fp_type" "fp_mul_<Fs>")])
4868
4869 (define_expand "div<mode>3"
4870   [(set (match_operand:SFDF 0 "gpc_reg_operand" "")
4871         (div:SFDF (match_operand:SFDF 1 "gpc_reg_operand" "")
4872                   (match_operand:SFDF 2 "gpc_reg_operand" "")))]
4873   "TARGET_<MODE>_INSN && !TARGET_SIMPLE_FPU"
4874   "")
4875
4876 (define_insn "*div<mode>3_fpr"
4877   [(set (match_operand:SFDF 0 "gpc_reg_operand" "=<Ff>,<Fv>")
4878         (div:SFDF (match_operand:SFDF 1 "gpc_reg_operand" "<Ff>,<Fv>")
4879                   (match_operand:SFDF 2 "gpc_reg_operand" "<Ff>,<Fv>")))]
4880   "TARGET_<MODE>_FPR && !TARGET_SIMPLE_FPU"
4881   "@
4882    fdiv<Ftrad> %0,%1,%2
4883    xsdiv<Fvsx> %x0,%x1,%x2"
4884   [(set_attr "type" "<Fs>div")
4885    (set_attr "fp_type" "fp_div_<Fs>")])
4886
4887 (define_insn "sqrt<mode>2"
4888   [(set (match_operand:SFDF 0 "gpc_reg_operand" "=<Ff>,<Fv>")
4889         (sqrt:SFDF (match_operand:SFDF 1 "gpc_reg_operand" "<Ff>,<Fv>")))]
4890   "TARGET_<MODE>_FPR && !TARGET_SIMPLE_FPU
4891    && (TARGET_PPC_GPOPT || (<MODE>mode == SFmode && TARGET_XILINX_FPU))"
4892   "@
4893    fsqrt<Ftrad> %0,%1
4894    xssqrt<Fvsx> %x0,%x1"
4895   [(set_attr "type" "<Fs>sqrt")
4896    (set_attr "fp_type" "fp_sqrt_<Fs>")])
4897
4898 ;; Floating point reciprocal approximation
4899 (define_insn "fre<Fs>"
4900   [(set (match_operand:SFDF 0 "gpc_reg_operand" "=<Ff>,<Fv>")
4901         (unspec:SFDF [(match_operand:SFDF 1 "gpc_reg_operand" "<Ff>,<Fv>")]
4902                      UNSPEC_FRES))]
4903   "TARGET_<FFRE>"
4904   "@
4905    fre<Ftrad> %0,%1
4906    xsre<Fvsx> %x0,%x1"
4907   [(set_attr "type" "fp")])
4908
4909 (define_insn "*rsqrt<mode>2"
4910   [(set (match_operand:SFDF 0 "gpc_reg_operand" "=<Ff>,<Fv>")
4911         (unspec:SFDF [(match_operand:SFDF 1 "gpc_reg_operand" "<Ff>,<Fv>")]
4912                      UNSPEC_RSQRT))]
4913   "RS6000_RECIP_HAVE_RSQRTE_P (<MODE>mode)"
4914   "@
4915    frsqrte<Ftrad> %0,%1
4916    xsrsqrte<Fvsx> %x0,%x1"
4917   [(set_attr "type" "fp")])
4918
4919 ;; Floating point comparisons
4920 (define_insn "*cmp<mode>_fpr"
4921   [(set (match_operand:CCFP 0 "cc_reg_operand" "=y,y")
4922         (compare:CCFP (match_operand:SFDF 1 "gpc_reg_operand" "<Ff>,<Fv>")
4923                       (match_operand:SFDF 2 "gpc_reg_operand" "<Ff>,<Fv>")))]
4924   "TARGET_<MODE>_FPR"
4925   "@
4926    fcmpu %0,%1,%2
4927    xscmpudp %0,%x1,%x2"
4928   [(set_attr "type" "fpcompare")])
4929
4930 ;; Floating point conversions
4931 (define_expand "extendsfdf2"
4932   [(set (match_operand:DF 0 "gpc_reg_operand" "")
4933         (float_extend:DF (match_operand:SF 1 "reg_or_none500mem_operand" "")))]
4934   "TARGET_HARD_FLOAT && ((TARGET_FPRS && TARGET_DOUBLE_FLOAT) || TARGET_E500_DOUBLE)"
4935   "")
4936
4937 (define_insn_and_split "*extendsfdf2_fpr"
4938   [(set (match_operand:DF 0 "gpc_reg_operand" "=d,?d,d,ws,?ws,wv")
4939         (float_extend:DF (match_operand:SF 1 "reg_or_mem_operand" "0,f,m,0,wy,Z")))]
4940   "TARGET_HARD_FLOAT && TARGET_FPRS && TARGET_DOUBLE_FLOAT"
4941   "@
4942    #
4943    fmr %0,%1
4944    lfs%U1%X1 %0,%1
4945    #
4946    xxlor %x0,%x1,%x1
4947    lxsspx %x0,%y1"
4948   "&& reload_completed && REG_P (operands[1]) && REGNO (operands[0]) == REGNO (operands[1])"
4949   [(const_int 0)]
4950 {
4951   emit_note (NOTE_INSN_DELETED);
4952   DONE;
4953 }
4954   [(set_attr "type" "fp,fp,fpload,fp,vecsimple,fpload")])
4955
4956 (define_expand "truncdfsf2"
4957   [(set (match_operand:SF 0 "gpc_reg_operand" "")
4958         (float_truncate:SF (match_operand:DF 1 "gpc_reg_operand" "")))]
4959   "TARGET_HARD_FLOAT && ((TARGET_FPRS && TARGET_DOUBLE_FLOAT) || TARGET_E500_DOUBLE)"
4960   "")
4961
4962 (define_insn "*truncdfsf2_fpr"
4963   [(set (match_operand:SF 0 "gpc_reg_operand" "=f")
4964         (float_truncate:SF (match_operand:DF 1 "gpc_reg_operand" "d")))]
4965   "TARGET_HARD_FLOAT && TARGET_FPRS && TARGET_DOUBLE_FLOAT"
4966   "frsp %0,%1"
4967   [(set_attr "type" "fp")])
4968
4969 ;; This expander is here to avoid FLOAT_WORDS_BIGENDIAN tests in
4970 ;; builtins.c and optabs.c that are not correct for IBM long double
4971 ;; when little-endian.
4972 (define_expand "signbittf2"
4973   [(set (match_dup 2)
4974         (float_truncate:DF (match_operand:TF 1 "gpc_reg_operand" "")))
4975    (set (match_dup 3)
4976         (subreg:DI (match_dup 2) 0))
4977    (set (match_dup 4)
4978         (match_dup 5))
4979    (set (match_operand:SI 0 "gpc_reg_operand" "")
4980         (match_dup 6))]
4981   "!TARGET_IEEEQUAD
4982    && TARGET_HARD_FLOAT
4983    && (TARGET_FPRS || TARGET_E500_DOUBLE)
4984    && TARGET_LONG_DOUBLE_128"
4985 {
4986   operands[2] = gen_reg_rtx (DFmode);
4987   operands[3] = gen_reg_rtx (DImode);
4988   if (TARGET_POWERPC64)
4989     {
4990       operands[4] = gen_reg_rtx (DImode);
4991       operands[5] = gen_rtx_LSHIFTRT (DImode, operands[3], GEN_INT (63));
4992       operands[6] = gen_rtx_SUBREG (SImode, operands[4],
4993                                     WORDS_BIG_ENDIAN ? 4 : 0);
4994     }
4995   else
4996     {
4997       operands[4] = gen_reg_rtx (SImode);
4998       operands[5] = gen_rtx_SUBREG (SImode, operands[3],
4999                                     WORDS_BIG_ENDIAN ? 0 : 4);
5000       operands[6] = gen_rtx_LSHIFTRT (SImode, operands[4], GEN_INT (31));
5001     }
5002 })
5003
5004 (define_expand "copysign<mode>3"
5005   [(set (match_dup 3)
5006         (abs:SFDF (match_operand:SFDF 1 "gpc_reg_operand" "")))
5007    (set (match_dup 4)
5008         (neg:SFDF (abs:SFDF (match_dup 1))))
5009    (set (match_operand:SFDF 0 "gpc_reg_operand" "")
5010         (if_then_else:SFDF (ge (match_operand:SFDF 2 "gpc_reg_operand" "")
5011                                (match_dup 5))
5012                          (match_dup 3)
5013                          (match_dup 4)))]
5014   "TARGET_HARD_FLOAT && TARGET_FPRS && <TARGET_FLOAT>
5015    && ((TARGET_PPC_GFXOPT
5016         && !HONOR_NANS (<MODE>mode)
5017         && !HONOR_SIGNED_ZEROS (<MODE>mode))
5018        || TARGET_CMPB
5019        || VECTOR_UNIT_VSX_P (<MODE>mode))"
5020 {
5021   if (TARGET_CMPB || VECTOR_UNIT_VSX_P (<MODE>mode))
5022     {
5023       emit_insn (gen_copysign<mode>3_fcpsgn (operands[0], operands[1],
5024                                              operands[2]));
5025       DONE;
5026     }
5027
5028    operands[3] = gen_reg_rtx (<MODE>mode);
5029    operands[4] = gen_reg_rtx (<MODE>mode);
5030    operands[5] = CONST0_RTX (<MODE>mode);
5031   })
5032
5033 ;; Use an unspec rather providing an if-then-else in RTL, to prevent the
5034 ;; compiler from optimizing -0.0
5035 (define_insn "copysign<mode>3_fcpsgn"
5036   [(set (match_operand:SFDF 0 "gpc_reg_operand" "=<Ff>,<Fv>")
5037         (unspec:SFDF [(match_operand:SFDF 1 "gpc_reg_operand" "<Ff>,<Fv>")
5038                       (match_operand:SFDF 2 "gpc_reg_operand" "<Ff>,<Fv>")]
5039                      UNSPEC_COPYSIGN))]
5040   "TARGET_<MODE>_FPR && TARGET_CMPB"
5041   "@
5042    fcpsgn %0,%2,%1
5043    xscpsgn<Fvsx> %x0,%x2,%x1"
5044   [(set_attr "type" "fp")])
5045
5046 ;; For MIN, MAX, and conditional move, we use DEFINE_EXPAND's that involve a
5047 ;; fsel instruction and some auxiliary computations.  Then we just have a
5048 ;; single DEFINE_INSN for fsel and the define_splits to make them if made by
5049 ;; combine.
5050 ;; For MIN, MAX on non-VSX machines, and conditional move all of the time, we
5051 ;; use DEFINE_EXPAND's that involve a fsel instruction and some auxiliary
5052 ;; computations.  Then we just have a single DEFINE_INSN for fsel and the
5053 ;; define_splits to make them if made by combine.  On VSX machines we have the
5054 ;; min/max instructions.
5055 ;;
5056 ;; On VSX, we only check for TARGET_VSX instead of checking for a vsx/p8 vector
5057 ;; to allow either DF/SF to use only traditional registers.
5058
5059 (define_expand "smax<mode>3"
5060   [(set (match_operand:SFDF 0 "gpc_reg_operand" "")
5061         (if_then_else:SFDF (ge (match_operand:SFDF 1 "gpc_reg_operand" "")
5062                                (match_operand:SFDF 2 "gpc_reg_operand" ""))
5063                            (match_dup 1)
5064                            (match_dup 2)))]
5065   "TARGET_<MODE>_FPR && TARGET_PPC_GFXOPT && !flag_trapping_math"
5066 {
5067   rs6000_emit_minmax (operands[0], SMAX, operands[1], operands[2]);
5068   DONE;
5069 })
5070
5071 (define_insn "*smax<mode>3_vsx"
5072   [(set (match_operand:SFDF 0 "gpc_reg_operand" "=<Ff>,<Fv>")
5073         (smax:SFDF (match_operand:SFDF 1 "gpc_reg_operand" "%<Ff>,<Fv>")
5074                    (match_operand:SFDF 2 "gpc_reg_operand" "<Ff>,<Fv>")))]
5075   "TARGET_<MODE>_FPR && TARGET_VSX"
5076   "xsmaxdp %x0,%x1,%x2"
5077   [(set_attr "type" "fp")])
5078
5079 (define_expand "smin<mode>3"
5080   [(set (match_operand:SFDF 0 "gpc_reg_operand" "")
5081         (if_then_else:SFDF (ge (match_operand:SFDF 1 "gpc_reg_operand" "")
5082                                (match_operand:SFDF 2 "gpc_reg_operand" ""))
5083                            (match_dup 2)
5084                            (match_dup 1)))]
5085   "TARGET_<MODE>_FPR && TARGET_PPC_GFXOPT && !flag_trapping_math"
5086 {
5087   rs6000_emit_minmax (operands[0], SMIN, operands[1], operands[2]);
5088   DONE;
5089 })
5090
5091 (define_insn "*smin<mode>3_vsx"
5092   [(set (match_operand:SFDF 0 "gpc_reg_operand" "=<Ff>,<Fv>")
5093         (smin:SFDF (match_operand:SFDF 1 "gpc_reg_operand" "%<Ff>,<Fv>")
5094                    (match_operand:SFDF 2 "gpc_reg_operand" "<Ff>,<Fv>")))]
5095   "TARGET_<MODE>_FPR && TARGET_VSX"
5096   "xsmindp %x0,%x1,%x2"
5097   [(set_attr "type" "fp")])
5098
5099 (define_split
5100   [(set (match_operand:SFDF 0 "gpc_reg_operand" "")
5101         (match_operator:SFDF 3 "min_max_operator"
5102          [(match_operand:SFDF 1 "gpc_reg_operand" "")
5103           (match_operand:SFDF 2 "gpc_reg_operand" "")]))]
5104   "TARGET_<MODE>_FPR && TARGET_PPC_GFXOPT && !flag_trapping_math
5105    && !TARGET_VSX"
5106   [(const_int 0)]
5107 {
5108   rs6000_emit_minmax (operands[0], GET_CODE (operands[3]), operands[1],
5109                       operands[2]);
5110   DONE;
5111 })
5112
5113 (define_split
5114   [(set (match_operand:SF 0 "gpc_reg_operand" "")
5115         (match_operator:SF 3 "min_max_operator"
5116          [(match_operand:SF 1 "gpc_reg_operand" "")
5117           (match_operand:SF 2 "gpc_reg_operand" "")]))]
5118   "TARGET_PPC_GFXOPT && TARGET_HARD_FLOAT && TARGET_FPRS 
5119    && TARGET_SINGLE_FLOAT && !flag_trapping_math"
5120   [(const_int 0)]
5121   "
5122 { rs6000_emit_minmax (operands[0], GET_CODE (operands[3]),
5123                       operands[1], operands[2]);
5124   DONE;
5125 }")
5126
5127 (define_expand "mov<mode>cc"
5128    [(set (match_operand:GPR 0 "gpc_reg_operand" "")
5129          (if_then_else:GPR (match_operand 1 "comparison_operator" "")
5130                            (match_operand:GPR 2 "gpc_reg_operand" "")
5131                            (match_operand:GPR 3 "gpc_reg_operand" "")))]
5132   "TARGET_ISEL<sel>"
5133   "
5134 {
5135   if (rs6000_emit_cmove (operands[0], operands[1], operands[2], operands[3]))
5136     DONE;
5137   else
5138     FAIL;
5139 }")
5140
5141 ;; We use the BASE_REGS for the isel input operands because, if rA is
5142 ;; 0, the value of 0 is placed in rD upon truth.  Similarly for rB
5143 ;; because we may switch the operands and rB may end up being rA.
5144 ;;
5145 ;; We need 2 patterns: an unsigned and a signed pattern.  We could
5146 ;; leave out the mode in operand 4 and use one pattern, but reload can
5147 ;; change the mode underneath our feet and then gets confused trying
5148 ;; to reload the value.
5149 (define_insn "isel_signed_<mode>"
5150   [(set (match_operand:GPR 0 "gpc_reg_operand" "=r,r")
5151         (if_then_else:GPR
5152          (match_operator 1 "scc_comparison_operator"
5153                          [(match_operand:CC 4 "cc_reg_operand" "y,y")
5154                           (const_int 0)])
5155          (match_operand:GPR 2 "reg_or_cint_operand" "O,b")
5156          (match_operand:GPR 3 "gpc_reg_operand" "r,r")))]
5157   "TARGET_ISEL<sel>"
5158   "*
5159 { return output_isel (operands); }"
5160   [(set_attr "type" "isel")
5161    (set_attr "length" "4")])
5162
5163 (define_insn "isel_unsigned_<mode>"
5164   [(set (match_operand:GPR 0 "gpc_reg_operand" "=r,r")
5165         (if_then_else:GPR
5166          (match_operator 1 "scc_comparison_operator"
5167                          [(match_operand:CCUNS 4 "cc_reg_operand" "y,y")
5168                           (const_int 0)])
5169          (match_operand:GPR 2 "reg_or_cint_operand" "O,b")
5170          (match_operand:GPR 3 "gpc_reg_operand" "r,r")))]
5171   "TARGET_ISEL<sel>"
5172   "*
5173 { return output_isel (operands); }"
5174   [(set_attr "type" "isel")
5175    (set_attr "length" "4")])
5176
5177 ;; These patterns can be useful for combine; they let combine know that
5178 ;; isel can handle reversed comparisons so long as the operands are
5179 ;; registers.
5180
5181 (define_insn "*isel_reversed_signed_<mode>"
5182   [(set (match_operand:GPR 0 "gpc_reg_operand" "=r")
5183         (if_then_else:GPR
5184          (match_operator 1 "scc_rev_comparison_operator"
5185                          [(match_operand:CC 4 "cc_reg_operand" "y")
5186                           (const_int 0)])
5187          (match_operand:GPR 2 "gpc_reg_operand" "b")
5188          (match_operand:GPR 3 "gpc_reg_operand" "b")))]
5189   "TARGET_ISEL<sel>"
5190   "*
5191 { return output_isel (operands); }"
5192   [(set_attr "type" "isel")
5193    (set_attr "length" "4")])
5194
5195 (define_insn "*isel_reversed_unsigned_<mode>"
5196   [(set (match_operand:GPR 0 "gpc_reg_operand" "=r")
5197         (if_then_else:GPR
5198          (match_operator 1 "scc_rev_comparison_operator"
5199                          [(match_operand:CCUNS 4 "cc_reg_operand" "y")
5200                           (const_int 0)])
5201          (match_operand:GPR 2 "gpc_reg_operand" "b")
5202          (match_operand:GPR 3 "gpc_reg_operand" "b")))]
5203   "TARGET_ISEL<sel>"
5204   "*
5205 { return output_isel (operands); }"
5206   [(set_attr "type" "isel")
5207    (set_attr "length" "4")])
5208
5209 (define_expand "movsfcc"
5210    [(set (match_operand:SF 0 "gpc_reg_operand" "")
5211          (if_then_else:SF (match_operand 1 "comparison_operator" "")
5212                           (match_operand:SF 2 "gpc_reg_operand" "")
5213                           (match_operand:SF 3 "gpc_reg_operand" "")))]
5214   "TARGET_PPC_GFXOPT && TARGET_HARD_FLOAT && TARGET_FPRS && TARGET_SINGLE_FLOAT"
5215   "
5216 {
5217   if (rs6000_emit_cmove (operands[0], operands[1], operands[2], operands[3]))
5218     DONE;
5219   else
5220     FAIL;
5221 }")
5222
5223 (define_insn "*fselsfsf4"
5224   [(set (match_operand:SF 0 "gpc_reg_operand" "=f")
5225         (if_then_else:SF (ge (match_operand:SF 1 "gpc_reg_operand" "f")
5226                              (match_operand:SF 4 "zero_fp_constant" "F"))
5227                          (match_operand:SF 2 "gpc_reg_operand" "f")
5228                          (match_operand:SF 3 "gpc_reg_operand" "f")))]
5229   "TARGET_PPC_GFXOPT && TARGET_HARD_FLOAT && TARGET_FPRS && TARGET_SINGLE_FLOAT"
5230   "fsel %0,%1,%2,%3"
5231   [(set_attr "type" "fp")])
5232
5233 (define_insn "*fseldfsf4"
5234   [(set (match_operand:SF 0 "gpc_reg_operand" "=f")
5235         (if_then_else:SF (ge (match_operand:DF 1 "gpc_reg_operand" "d")
5236                              (match_operand:DF 4 "zero_fp_constant" "F"))
5237                          (match_operand:SF 2 "gpc_reg_operand" "f")
5238                          (match_operand:SF 3 "gpc_reg_operand" "f")))]
5239   "TARGET_PPC_GFXOPT && TARGET_HARD_FLOAT && TARGET_FPRS && TARGET_DOUBLE_FLOAT && TARGET_SINGLE_FLOAT"
5240   "fsel %0,%1,%2,%3"
5241   [(set_attr "type" "fp")])
5242
5243 ;; The conditional move instructions allow us to perform max and min
5244 ;; operations even when
5245
5246 (define_split
5247   [(set (match_operand:DF 0 "gpc_reg_operand" "")
5248         (match_operator:DF 3 "min_max_operator"
5249          [(match_operand:DF 1 "gpc_reg_operand" "")
5250           (match_operand:DF 2 "gpc_reg_operand" "")]))]
5251   "TARGET_PPC_GFXOPT && TARGET_HARD_FLOAT && TARGET_FPRS && TARGET_DOUBLE_FLOAT 
5252    && !flag_trapping_math"
5253   [(const_int 0)]
5254   "
5255 { rs6000_emit_minmax (operands[0], GET_CODE (operands[3]),
5256                       operands[1], operands[2]);
5257   DONE;
5258 }")
5259
5260 (define_expand "movdfcc"
5261    [(set (match_operand:DF 0 "gpc_reg_operand" "")
5262          (if_then_else:DF (match_operand 1 "comparison_operator" "")
5263                           (match_operand:DF 2 "gpc_reg_operand" "")
5264                           (match_operand:DF 3 "gpc_reg_operand" "")))]
5265   "TARGET_PPC_GFXOPT && TARGET_HARD_FLOAT && TARGET_FPRS && TARGET_DOUBLE_FLOAT"
5266   "
5267 {
5268   if (rs6000_emit_cmove (operands[0], operands[1], operands[2], operands[3]))
5269     DONE;
5270   else
5271     FAIL;
5272 }")
5273
5274 (define_insn "*fseldfdf4"
5275   [(set (match_operand:DF 0 "gpc_reg_operand" "=d")
5276         (if_then_else:DF (ge (match_operand:DF 1 "gpc_reg_operand" "d")
5277                              (match_operand:DF 4 "zero_fp_constant" "F"))
5278                          (match_operand:DF 2 "gpc_reg_operand" "d")
5279                          (match_operand:DF 3 "gpc_reg_operand" "d")))]
5280   "TARGET_PPC_GFXOPT && TARGET_HARD_FLOAT && TARGET_FPRS && TARGET_DOUBLE_FLOAT"
5281   "fsel %0,%1,%2,%3"
5282   [(set_attr "type" "fp")])
5283
5284 (define_insn "*fselsfdf4"
5285   [(set (match_operand:DF 0 "gpc_reg_operand" "=d")
5286         (if_then_else:DF (ge (match_operand:SF 1 "gpc_reg_operand" "f")
5287                              (match_operand:SF 4 "zero_fp_constant" "F"))
5288                          (match_operand:DF 2 "gpc_reg_operand" "d")
5289                          (match_operand:DF 3 "gpc_reg_operand" "d")))]
5290   "TARGET_PPC_GFXOPT && TARGET_HARD_FLOAT && TARGET_FPRS && TARGET_DOUBLE_FLOAT && TARGET_SINGLE_FLOAT"
5291   "fsel %0,%1,%2,%3"
5292   [(set_attr "type" "fp")])
5293 \f
5294 ;; Conversions to and from floating-point.
5295
5296 ; We don't define lfiwax/lfiwzx with the normal definition, because we
5297 ; don't want to support putting SImode in FPR registers.
5298 (define_insn "lfiwax"
5299   [(set (match_operand:DI 0 "gpc_reg_operand" "=d,wj,!wj")
5300         (unspec:DI [(match_operand:SI 1 "reg_or_indexed_operand" "Z,Z,r")]
5301                    UNSPEC_LFIWAX))]
5302   "TARGET_HARD_FLOAT && TARGET_FPRS && TARGET_DOUBLE_FLOAT && TARGET_LFIWAX"
5303   "@
5304    lfiwax %0,%y1
5305    lxsiwax %x0,%y1
5306    mtvsrwa %x0,%1"
5307   [(set_attr "type" "fpload,fpload,mffgpr")])
5308
5309 ; This split must be run before register allocation because it allocates the
5310 ; memory slot that is needed to move values to/from the FPR.  We don't allocate
5311 ; it earlier to allow for the combiner to merge insns together where it might
5312 ; not be needed and also in case the insns are deleted as dead code.
5313
5314 (define_insn_and_split "floatsi<mode>2_lfiwax"
5315   [(set (match_operand:SFDF 0 "gpc_reg_operand" "=d")
5316         (float:SFDF (match_operand:SI 1 "nonimmediate_operand" "r")))
5317    (clobber (match_scratch:DI 2 "=d"))]
5318   "TARGET_HARD_FLOAT && TARGET_FPRS && TARGET_DOUBLE_FLOAT && TARGET_LFIWAX
5319    && <SI_CONVERT_FP> && can_create_pseudo_p ()"
5320   "#"
5321   ""
5322   [(pc)]
5323   "
5324 {
5325   rtx dest = operands[0];
5326   rtx src = operands[1];
5327   rtx tmp;
5328
5329   if (!MEM_P (src) && TARGET_POWERPC64
5330       && (TARGET_MFPGPR || TARGET_DIRECT_MOVE))
5331     tmp = convert_to_mode (DImode, src, false);
5332   else
5333     {
5334       tmp = operands[2];
5335       if (GET_CODE (tmp) == SCRATCH)
5336         tmp = gen_reg_rtx (DImode);
5337       if (MEM_P (src))
5338         {
5339           src = rs6000_address_for_fpconvert (src);
5340           emit_insn (gen_lfiwax (tmp, src));
5341         }
5342       else
5343         {
5344           rtx stack = rs6000_allocate_stack_temp (SImode, false, true);
5345           emit_move_insn (stack, src);
5346           emit_insn (gen_lfiwax (tmp, stack));
5347         }
5348     }
5349   emit_insn (gen_floatdi<mode>2 (dest, tmp));
5350   DONE;
5351 }"
5352   [(set_attr "length" "12")
5353    (set_attr "type" "fpload")])
5354
5355 (define_insn_and_split "floatsi<mode>2_lfiwax_mem"
5356   [(set (match_operand:SFDF 0 "gpc_reg_operand" "=d,<rreg2>")
5357         (float:SFDF
5358          (sign_extend:DI
5359           (match_operand:SI 1 "indexed_or_indirect_operand" "Z,Z"))))
5360    (clobber (match_scratch:DI 2 "=0,d"))]
5361   "TARGET_HARD_FLOAT && TARGET_FPRS && TARGET_DOUBLE_FLOAT && TARGET_LFIWAX
5362    && <SI_CONVERT_FP>"
5363   "#"
5364   ""
5365   [(pc)]
5366   "
5367 {
5368   operands[1] = rs6000_address_for_fpconvert (operands[1]);
5369   if (GET_CODE (operands[2]) == SCRATCH)
5370     operands[2] = gen_reg_rtx (DImode);
5371   emit_insn (gen_lfiwax (operands[2], operands[1]));
5372   emit_insn (gen_floatdi<mode>2 (operands[0], operands[2]));
5373   DONE;
5374 }"
5375   [(set_attr "length" "8")
5376    (set_attr "type" "fpload")])
5377
5378 (define_insn "lfiwzx"
5379   [(set (match_operand:DI 0 "gpc_reg_operand" "=d,wj,!wj")
5380         (unspec:DI [(match_operand:SI 1 "reg_or_indexed_operand" "Z,Z,r")]
5381                    UNSPEC_LFIWZX))]
5382   "TARGET_HARD_FLOAT && TARGET_FPRS && TARGET_DOUBLE_FLOAT && TARGET_LFIWZX"
5383   "@
5384    lfiwzx %0,%y1
5385    lxsiwzx %x0,%y1
5386    mtvsrwz %x0,%1"
5387   [(set_attr "type" "fpload,fpload,mftgpr")])
5388
5389 (define_insn_and_split "floatunssi<mode>2_lfiwzx"
5390   [(set (match_operand:SFDF 0 "gpc_reg_operand" "=d")
5391         (unsigned_float:SFDF (match_operand:SI 1 "nonimmediate_operand" "r")))
5392    (clobber (match_scratch:DI 2 "=d"))]
5393   "TARGET_HARD_FLOAT && TARGET_FPRS && TARGET_DOUBLE_FLOAT && TARGET_LFIWZX
5394    && <SI_CONVERT_FP>"
5395   "#"
5396   ""
5397   [(pc)]
5398   "
5399 {
5400   rtx dest = operands[0];
5401   rtx src = operands[1];
5402   rtx tmp;
5403
5404   if (!MEM_P (src) && TARGET_POWERPC64
5405       && (TARGET_MFPGPR || TARGET_DIRECT_MOVE))
5406     tmp = convert_to_mode (DImode, src, true);
5407   else
5408     {
5409       tmp = operands[2];
5410       if (GET_CODE (tmp) == SCRATCH)
5411         tmp = gen_reg_rtx (DImode);
5412       if (MEM_P (src))
5413         {
5414           src = rs6000_address_for_fpconvert (src);
5415           emit_insn (gen_lfiwzx (tmp, src));
5416         }
5417       else
5418         {
5419           rtx stack = rs6000_allocate_stack_temp (SImode, false, true);
5420           emit_move_insn (stack, src);
5421           emit_insn (gen_lfiwzx (tmp, stack));
5422         }
5423     }
5424   emit_insn (gen_floatdi<mode>2 (dest, tmp));
5425   DONE;
5426 }"
5427   [(set_attr "length" "12")
5428    (set_attr "type" "fpload")])
5429
5430 (define_insn_and_split "floatunssi<mode>2_lfiwzx_mem"
5431   [(set (match_operand:SFDF 0 "gpc_reg_operand" "=d,<rreg2>")
5432         (unsigned_float:SFDF
5433          (zero_extend:DI
5434           (match_operand:SI 1 "indexed_or_indirect_operand" "Z,Z"))))
5435    (clobber (match_scratch:DI 2 "=0,d"))]
5436   "TARGET_HARD_FLOAT && TARGET_FPRS && TARGET_DOUBLE_FLOAT && TARGET_LFIWZX
5437    && <SI_CONVERT_FP>"
5438   "#"
5439   ""
5440   [(pc)]
5441   "
5442 {
5443   operands[1] = rs6000_address_for_fpconvert (operands[1]);
5444   if (GET_CODE (operands[2]) == SCRATCH)
5445     operands[2] = gen_reg_rtx (DImode);
5446   emit_insn (gen_lfiwzx (operands[2], operands[1]));
5447   emit_insn (gen_floatdi<mode>2 (operands[0], operands[2]));
5448   DONE;
5449 }"
5450   [(set_attr "length" "8")
5451    (set_attr "type" "fpload")])
5452
5453 ; For each of these conversions, there is a define_expand, a define_insn
5454 ; with a '#' template, and a define_split (with C code).  The idea is
5455 ; to allow constant folding with the template of the define_insn,
5456 ; then to have the insns split later (between sched1 and final).
5457
5458 (define_expand "floatsidf2"
5459   [(parallel [(set (match_operand:DF 0 "gpc_reg_operand" "")
5460                    (float:DF (match_operand:SI 1 "nonimmediate_operand" "")))
5461               (use (match_dup 2))
5462               (use (match_dup 3))
5463               (clobber (match_dup 4))
5464               (clobber (match_dup 5))
5465               (clobber (match_dup 6))])]
5466   "TARGET_HARD_FLOAT 
5467    && ((TARGET_FPRS && TARGET_DOUBLE_FLOAT) || TARGET_E500_DOUBLE)"
5468   "
5469 {
5470   if (TARGET_E500_DOUBLE)
5471     {
5472       if (!REG_P (operands[1]))
5473         operands[1] = force_reg (SImode, operands[1]);
5474       emit_insn (gen_spe_floatsidf2 (operands[0], operands[1]));
5475       DONE;
5476     }
5477   else if (TARGET_LFIWAX && TARGET_FCFID)
5478     {
5479       emit_insn (gen_floatsidf2_lfiwax (operands[0], operands[1]));
5480       DONE;
5481     }
5482   else if (TARGET_FCFID)
5483     {
5484       rtx dreg = operands[1];
5485       if (!REG_P (dreg))
5486         dreg = force_reg (SImode, dreg);
5487       dreg = convert_to_mode (DImode, dreg, false);
5488       emit_insn (gen_floatdidf2 (operands[0], dreg));
5489       DONE;
5490     }
5491
5492   if (!REG_P (operands[1]))
5493     operands[1] = force_reg (SImode, operands[1]);
5494   operands[2] = force_reg (SImode, GEN_INT (0x43300000));
5495   operands[3] = force_reg (DFmode, CONST_DOUBLE_ATOF (\"4503601774854144\", DFmode));
5496   operands[4] = rs6000_allocate_stack_temp (DFmode, true, false);
5497   operands[5] = gen_reg_rtx (DFmode);
5498   operands[6] = gen_reg_rtx (SImode);
5499 }")
5500
5501 (define_insn_and_split "*floatsidf2_internal"
5502   [(set (match_operand:DF 0 "gpc_reg_operand" "=&d")
5503         (float:DF (match_operand:SI 1 "gpc_reg_operand" "r")))
5504    (use (match_operand:SI 2 "gpc_reg_operand" "r"))
5505    (use (match_operand:DF 3 "gpc_reg_operand" "d"))
5506    (clobber (match_operand:DF 4 "offsettable_mem_operand" "=o"))
5507    (clobber (match_operand:DF 5 "gpc_reg_operand" "=&d"))
5508    (clobber (match_operand:SI 6 "gpc_reg_operand" "=&r"))]
5509   "! TARGET_FCFID && TARGET_HARD_FLOAT && TARGET_FPRS && TARGET_DOUBLE_FLOAT"
5510   "#"
5511   ""
5512   [(pc)]
5513   "
5514 {
5515   rtx lowword, highword;
5516   gcc_assert (MEM_P (operands[4]));
5517   highword = adjust_address (operands[4], SImode, 0);
5518   lowword = adjust_address (operands[4], SImode, 4);
5519   if (! WORDS_BIG_ENDIAN)
5520     {
5521       rtx tmp;
5522       tmp = highword; highword = lowword; lowword = tmp;
5523     }
5524
5525   emit_insn (gen_xorsi3 (operands[6], operands[1],
5526                          GEN_INT (~ (HOST_WIDE_INT) 0x7fffffff)));
5527   emit_move_insn (lowword, operands[6]);
5528   emit_move_insn (highword, operands[2]);
5529   emit_move_insn (operands[5], operands[4]);
5530   emit_insn (gen_subdf3 (operands[0], operands[5], operands[3]));
5531   DONE;
5532 }"
5533   [(set_attr "length" "24")
5534    (set_attr "type" "fp")])
5535
5536 ;; If we don't have a direct conversion to single precision, don't enable this
5537 ;; conversion for 32-bit without fast math, because we don't have the insn to
5538 ;; generate the fixup swizzle to avoid double rounding problems.
5539 (define_expand "floatunssisf2"
5540   [(set (match_operand:SF 0 "gpc_reg_operand" "")
5541         (unsigned_float:SF (match_operand:SI 1 "nonimmediate_operand" "")))]
5542   "TARGET_HARD_FLOAT && TARGET_SINGLE_FLOAT
5543    && (!TARGET_FPRS
5544        || (TARGET_FPRS
5545            && ((TARGET_FCFIDUS && TARGET_LFIWZX)
5546                || (TARGET_DOUBLE_FLOAT && TARGET_FCFID
5547                    && (TARGET_POWERPC64 || flag_unsafe_math_optimizations)))))"
5548   "
5549 {
5550   if (!TARGET_FPRS)
5551     {
5552       if (!REG_P (operands[1]))
5553         operands[1] = force_reg (SImode, operands[1]);
5554     }
5555   else if (TARGET_LFIWZX && TARGET_FCFIDUS)
5556     {
5557       emit_insn (gen_floatunssisf2_lfiwzx (operands[0], operands[1]));
5558       DONE;
5559     }
5560   else
5561     {
5562       rtx dreg = operands[1];
5563       if (!REG_P (dreg))
5564         dreg = force_reg (SImode, dreg);
5565       dreg = convert_to_mode (DImode, dreg, true);
5566       emit_insn (gen_floatdisf2 (operands[0], dreg));
5567       DONE;
5568     }
5569 }")
5570
5571 (define_expand "floatunssidf2"
5572   [(parallel [(set (match_operand:DF 0 "gpc_reg_operand" "")
5573                    (unsigned_float:DF (match_operand:SI 1 "nonimmediate_operand" "")))
5574               (use (match_dup 2))
5575               (use (match_dup 3))
5576               (clobber (match_dup 4))
5577               (clobber (match_dup 5))])]
5578   "TARGET_HARD_FLOAT
5579    && ((TARGET_FPRS && TARGET_DOUBLE_FLOAT) || TARGET_E500_DOUBLE)"
5580   "
5581 {
5582   if (TARGET_E500_DOUBLE)
5583     {
5584       if (!REG_P (operands[1]))
5585         operands[1] = force_reg (SImode, operands[1]);
5586       emit_insn (gen_spe_floatunssidf2 (operands[0], operands[1]));
5587       DONE;
5588     }
5589   else if (TARGET_LFIWZX && TARGET_FCFID)
5590     {
5591       emit_insn (gen_floatunssidf2_lfiwzx (operands[0], operands[1]));
5592       DONE;
5593     }
5594   else if (TARGET_FCFID)
5595     {
5596       rtx dreg = operands[1];
5597       if (!REG_P (dreg))
5598         dreg = force_reg (SImode, dreg);
5599       dreg = convert_to_mode (DImode, dreg, true);
5600       emit_insn (gen_floatdidf2 (operands[0], dreg));
5601       DONE;
5602     }
5603
5604   if (!REG_P (operands[1]))
5605     operands[1] = force_reg (SImode, operands[1]);
5606   operands[2] = force_reg (SImode, GEN_INT (0x43300000));
5607   operands[3] = force_reg (DFmode, CONST_DOUBLE_ATOF (\"4503599627370496\", DFmode));
5608   operands[4] = rs6000_allocate_stack_temp (DFmode, true, false);
5609   operands[5] = gen_reg_rtx (DFmode);
5610 }")
5611
5612 (define_insn_and_split "*floatunssidf2_internal"
5613   [(set (match_operand:DF 0 "gpc_reg_operand" "=&d")
5614         (unsigned_float:DF (match_operand:SI 1 "gpc_reg_operand" "r")))
5615    (use (match_operand:SI 2 "gpc_reg_operand" "r"))
5616    (use (match_operand:DF 3 "gpc_reg_operand" "d"))
5617    (clobber (match_operand:DF 4 "offsettable_mem_operand" "=o"))
5618    (clobber (match_operand:DF 5 "gpc_reg_operand" "=&d"))]
5619   "! TARGET_FCFIDU && TARGET_HARD_FLOAT && TARGET_FPRS && TARGET_DOUBLE_FLOAT
5620    && !(TARGET_FCFID && TARGET_POWERPC64)"
5621   "#"
5622   ""
5623   [(pc)]
5624   "
5625 {
5626   rtx lowword, highword;
5627   gcc_assert (MEM_P (operands[4]));
5628   highword = adjust_address (operands[4], SImode, 0);
5629   lowword = adjust_address (operands[4], SImode, 4);
5630   if (! WORDS_BIG_ENDIAN)
5631     {
5632       rtx tmp;
5633       tmp = highword; highword = lowword; lowword = tmp;
5634     }
5635
5636   emit_move_insn (lowword, operands[1]);
5637   emit_move_insn (highword, operands[2]);
5638   emit_move_insn (operands[5], operands[4]);
5639   emit_insn (gen_subdf3 (operands[0], operands[5], operands[3]));
5640   DONE;
5641 }"
5642   [(set_attr "length" "20")
5643    (set_attr "type" "fp")])
5644
5645 (define_expand "fix_trunc<mode>si2"
5646   [(set (match_operand:SI 0 "gpc_reg_operand" "")
5647         (fix:SI (match_operand:SFDF 1 "gpc_reg_operand" "")))]
5648   "TARGET_HARD_FLOAT && ((TARGET_FPRS && <TARGET_FLOAT>) || <E500_CONVERT>)"
5649   "
5650 {
5651   if (!<E500_CONVERT>)
5652     {
5653       rtx tmp, stack;
5654
5655       if (TARGET_STFIWX)
5656         emit_insn (gen_fix_trunc<mode>si2_stfiwx (operands[0], operands[1]));
5657       else
5658         {
5659           tmp = gen_reg_rtx (DImode);
5660           stack = rs6000_allocate_stack_temp (DImode, true, false);
5661           emit_insn (gen_fix_trunc<mode>si2_internal (operands[0], operands[1],
5662                                                       tmp, stack));
5663         }
5664       DONE;
5665     }
5666 }")
5667
5668 ; Like the convert to float patterns, this insn must be split before
5669 ; register allocation so that it can allocate the memory slot if it
5670 ; needed
5671 (define_insn_and_split "fix_trunc<mode>si2_stfiwx"
5672   [(set (match_operand:SI 0 "nonimmediate_operand" "=rm")
5673         (fix:SI (match_operand:SFDF 1 "gpc_reg_operand" "d")))
5674    (clobber (match_scratch:DI 2 "=d"))]
5675   "TARGET_HARD_FLOAT && TARGET_FPRS && TARGET_DOUBLE_FLOAT
5676    && (<MODE>mode != SFmode || TARGET_SINGLE_FLOAT)
5677    && TARGET_STFIWX && can_create_pseudo_p ()"
5678   "#"
5679   ""
5680   [(pc)]
5681 {
5682   rtx dest = operands[0];
5683   rtx src = operands[1];
5684   rtx tmp = operands[2];
5685
5686   if (GET_CODE (tmp) == SCRATCH)
5687     tmp = gen_reg_rtx (DImode);
5688
5689   emit_insn (gen_fctiwz_<mode> (tmp, src));
5690   if (MEM_P (dest))
5691     {
5692       dest = rs6000_address_for_fpconvert (dest);
5693       emit_insn (gen_stfiwx (dest, tmp));
5694       DONE;
5695     }
5696   else if (TARGET_POWERPC64 && (TARGET_MFPGPR || TARGET_DIRECT_MOVE))
5697     {
5698       dest = gen_lowpart (DImode, dest);
5699       emit_move_insn (dest, tmp);
5700       DONE;
5701     }
5702   else
5703     {
5704       rtx stack = rs6000_allocate_stack_temp (SImode, false, true);
5705       emit_insn (gen_stfiwx (stack, tmp));
5706       emit_move_insn (dest, stack);
5707       DONE;
5708     }
5709 }
5710   [(set_attr "length" "12")
5711    (set_attr "type" "fp")])
5712
5713 (define_insn_and_split "fix_trunc<mode>si2_internal"
5714   [(set (match_operand:SI 0 "gpc_reg_operand" "=r,?r")
5715         (fix:SI (match_operand:SFDF 1 "gpc_reg_operand" "d,<rreg>")))
5716    (clobber (match_operand:DI 2 "gpc_reg_operand" "=1,d"))
5717    (clobber (match_operand:DI 3 "offsettable_mem_operand" "=o,o"))]
5718   "TARGET_HARD_FLOAT && TARGET_FPRS && TARGET_DOUBLE_FLOAT"
5719   "#"
5720   ""
5721   [(pc)]
5722   "
5723 {
5724   rtx lowword;
5725   gcc_assert (MEM_P (operands[3]));
5726   lowword = adjust_address (operands[3], SImode, WORDS_BIG_ENDIAN ? 4 : 0);
5727
5728   emit_insn (gen_fctiwz_<mode> (operands[2], operands[1]));
5729   emit_move_insn (operands[3], operands[2]);
5730   emit_move_insn (operands[0], lowword);
5731   DONE;
5732 }"
5733   [(set_attr "length" "16")
5734    (set_attr "type" "fp")])
5735
5736 (define_expand "fix_trunc<mode>di2"
5737   [(set (match_operand:DI 0 "gpc_reg_operand" "")
5738         (fix:DI (match_operand:SFDF 1 "gpc_reg_operand" "")))]
5739   "TARGET_HARD_FLOAT && TARGET_DOUBLE_FLOAT && TARGET_FPRS
5740    && TARGET_FCFID"
5741   "")
5742
5743 (define_insn "*fix_trunc<mode>di2_fctidz"
5744   [(set (match_operand:DI 0 "gpc_reg_operand" "=d")
5745         (fix:DI (match_operand:SFDF 1 "gpc_reg_operand" "d")))]
5746   "TARGET_HARD_FLOAT && TARGET_DOUBLE_FLOAT && TARGET_FPRS
5747     && TARGET_FCFID && !VECTOR_UNIT_VSX_P (<MODE>mode)"
5748   "fctidz %0,%1"
5749   [(set_attr "type" "fp")])
5750
5751 (define_expand "fixuns_trunc<mode>si2"
5752   [(set (match_operand:SI 0 "gpc_reg_operand" "")
5753         (unsigned_fix:SI (match_operand:SFDF 1 "gpc_reg_operand" "")))]
5754   "TARGET_HARD_FLOAT
5755    && ((TARGET_FPRS && <TARGET_FLOAT> && TARGET_FCTIWUZ && TARGET_STFIWX)
5756        || <E500_CONVERT>)"
5757   "
5758 {
5759   if (!<E500_CONVERT>)
5760     {
5761       emit_insn (gen_fixuns_trunc<mode>si2_stfiwx (operands[0], operands[1]));
5762       DONE;
5763     }
5764 }")
5765
5766 (define_insn_and_split "fixuns_trunc<mode>si2_stfiwx"
5767   [(set (match_operand:SI 0 "nonimmediate_operand" "=rm")
5768         (unsigned_fix:SI (match_operand:SFDF 1 "gpc_reg_operand" "d")))
5769    (clobber (match_scratch:DI 2 "=d"))]
5770   "TARGET_HARD_FLOAT && TARGET_FPRS && <TARGET_FLOAT> && TARGET_FCTIWUZ
5771    && TARGET_STFIWX && can_create_pseudo_p ()"
5772   "#"
5773   ""
5774   [(pc)]
5775 {
5776   rtx dest = operands[0];
5777   rtx src = operands[1];
5778   rtx tmp = operands[2];
5779
5780   if (GET_CODE (tmp) == SCRATCH)
5781     tmp = gen_reg_rtx (DImode);
5782
5783   emit_insn (gen_fctiwuz_<mode> (tmp, src));
5784   if (MEM_P (dest))
5785     {
5786       dest = rs6000_address_for_fpconvert (dest);
5787       emit_insn (gen_stfiwx (dest, tmp));
5788       DONE;
5789     }
5790   else if (TARGET_POWERPC64 && (TARGET_MFPGPR || TARGET_DIRECT_MOVE))
5791     {
5792       dest = gen_lowpart (DImode, dest);
5793       emit_move_insn (dest, tmp);
5794       DONE;
5795     }
5796   else
5797     {
5798       rtx stack = rs6000_allocate_stack_temp (SImode, false, true);
5799       emit_insn (gen_stfiwx (stack, tmp));
5800       emit_move_insn (dest, stack);
5801       DONE;
5802     }
5803 }
5804   [(set_attr "length" "12")
5805    (set_attr "type" "fp")])
5806
5807 (define_expand "fixuns_trunc<mode>di2"
5808   [(set (match_operand:DI 0 "register_operand" "")
5809         (unsigned_fix:DI (match_operand:SFDF 1 "register_operand" "")))]
5810   "TARGET_HARD_FLOAT && (TARGET_FCTIDUZ || VECTOR_UNIT_VSX_P (<MODE>mode))"
5811   "")
5812
5813 (define_insn "*fixuns_trunc<mode>di2_fctiduz"
5814   [(set (match_operand:DI 0 "gpc_reg_operand" "=d")
5815         (unsigned_fix:DI (match_operand:SFDF 1 "gpc_reg_operand" "d")))]
5816   "TARGET_HARD_FLOAT && TARGET_DOUBLE_FLOAT && TARGET_FPRS
5817     && TARGET_FCTIDUZ && !VECTOR_UNIT_VSX_P (<MODE>mode)"
5818   "fctiduz %0,%1"
5819   [(set_attr "type" "fp")])
5820
5821 ; Here, we use (set (reg) (unspec:DI [(fix:SI ...)] UNSPEC_FCTIWZ))
5822 ; rather than (set (subreg:SI (reg)) (fix:SI ...))
5823 ; because the first makes it clear that operand 0 is not live
5824 ; before the instruction.
5825 (define_insn "fctiwz_<mode>"
5826   [(set (match_operand:DI 0 "gpc_reg_operand" "=d")
5827         (unspec:DI [(fix:SI (match_operand:SFDF 1 "gpc_reg_operand" "d"))]
5828                    UNSPEC_FCTIWZ))]
5829   "TARGET_HARD_FLOAT && TARGET_FPRS && TARGET_DOUBLE_FLOAT"
5830   "fctiwz %0,%1"
5831   [(set_attr "type" "fp")])
5832
5833 (define_insn "fctiwuz_<mode>"
5834   [(set (match_operand:DI 0 "gpc_reg_operand" "=d")
5835         (unspec:DI [(unsigned_fix:SI
5836                      (match_operand:SFDF 1 "gpc_reg_operand" "<rreg2>"))]
5837                    UNSPEC_FCTIWUZ))]
5838   "TARGET_HARD_FLOAT && TARGET_FPRS && <TARGET_FLOAT> && TARGET_FCTIWUZ"
5839   "fctiwuz %0,%1"
5840   [(set_attr "type" "fp")])
5841
5842 ;; Only optimize (float (fix x)) -> frz if we are in fast-math mode, since
5843 ;; since the friz instruction does not truncate the value if the floating
5844 ;; point value is < LONG_MIN or > LONG_MAX.
5845 (define_insn "*friz"
5846   [(set (match_operand:DF 0 "gpc_reg_operand" "=d")
5847         (float:DF (fix:DI (match_operand:DF 1 "gpc_reg_operand" "d"))))]
5848   "TARGET_HARD_FLOAT && TARGET_FPRS && TARGET_DOUBLE_FLOAT && TARGET_FPRND
5849    && !VECTOR_UNIT_VSX_P (DFmode) && flag_unsafe_math_optimizations
5850    && !flag_trapping_math && TARGET_FRIZ"
5851   "friz %0,%1"
5852   [(set_attr "type" "fp")])
5853
5854 ;; Since FCTIWZ doesn't sign extend the upper bits, we have to do a store and a
5855 ;; load to properly sign extend the value, but at least doing a store, load
5856 ;; into a GPR to sign extend, a store from the GPR and a load back into the FPR
5857 ;; if we have 32-bit memory ops
5858 (define_insn_and_split "*round32<mode>2_fprs"
5859   [(set (match_operand:SFDF 0 "gpc_reg_operand" "=d")
5860         (float:SFDF
5861          (fix:SI (match_operand:SFDF 1 "gpc_reg_operand" "d"))))
5862    (clobber (match_scratch:DI 2 "=d"))
5863    (clobber (match_scratch:DI 3 "=d"))]
5864   "TARGET_HARD_FLOAT && TARGET_FPRS && TARGET_DOUBLE_FLOAT
5865    && <SI_CONVERT_FP> && TARGET_LFIWAX && TARGET_STFIWX && TARGET_FCFID
5866    && can_create_pseudo_p ()"
5867   "#"
5868   ""
5869   [(pc)]
5870 {
5871   rtx dest = operands[0];
5872   rtx src = operands[1];
5873   rtx tmp1 = operands[2];
5874   rtx tmp2 = operands[3];
5875   rtx stack = rs6000_allocate_stack_temp (SImode, false, true);
5876
5877   if (GET_CODE (tmp1) == SCRATCH)
5878     tmp1 = gen_reg_rtx (DImode);
5879   if (GET_CODE (tmp2) == SCRATCH)
5880     tmp2 = gen_reg_rtx (DImode);
5881
5882   emit_insn (gen_fctiwz_<mode> (tmp1, src));
5883   emit_insn (gen_stfiwx (stack, tmp1));
5884   emit_insn (gen_lfiwax (tmp2, stack));
5885   emit_insn (gen_floatdi<mode>2 (dest, tmp2));
5886   DONE;
5887 }
5888   [(set_attr "type" "fpload")
5889    (set_attr "length" "16")])
5890
5891 (define_insn_and_split "*roundu32<mode>2_fprs"
5892   [(set (match_operand:SFDF 0 "gpc_reg_operand" "=d")
5893         (unsigned_float:SFDF
5894          (unsigned_fix:SI (match_operand:SFDF 1 "gpc_reg_operand" "d"))))
5895    (clobber (match_scratch:DI 2 "=d"))
5896    (clobber (match_scratch:DI 3 "=d"))]
5897   "TARGET_HARD_FLOAT && TARGET_FPRS && TARGET_DOUBLE_FLOAT
5898    && TARGET_LFIWZX && TARGET_STFIWX && TARGET_FCFIDU
5899    && can_create_pseudo_p ()"
5900   "#"
5901   ""
5902   [(pc)]
5903 {
5904   rtx dest = operands[0];
5905   rtx src = operands[1];
5906   rtx tmp1 = operands[2];
5907   rtx tmp2 = operands[3];
5908   rtx stack = rs6000_allocate_stack_temp (SImode, false, true);
5909
5910   if (GET_CODE (tmp1) == SCRATCH)
5911     tmp1 = gen_reg_rtx (DImode);
5912   if (GET_CODE (tmp2) == SCRATCH)
5913     tmp2 = gen_reg_rtx (DImode);
5914
5915   emit_insn (gen_fctiwuz_<mode> (tmp1, src));
5916   emit_insn (gen_stfiwx (stack, tmp1));
5917   emit_insn (gen_lfiwzx (tmp2, stack));
5918   emit_insn (gen_floatdi<mode>2 (dest, tmp2));
5919   DONE;
5920 }
5921   [(set_attr "type" "fpload")
5922    (set_attr "length" "16")])
5923
5924 ;; No VSX equivalent to fctid
5925 (define_insn "lrint<mode>di2"
5926   [(set (match_operand:DI 0 "gpc_reg_operand" "=d")
5927         (unspec:DI [(match_operand:SFDF 1 "gpc_reg_operand" "<rreg2>")]
5928                    UNSPEC_FCTID))]
5929   "TARGET_<MODE>_FPR && TARGET_FPRND"
5930   "fctid %0,%1"
5931   [(set_attr "type" "fp")])
5932
5933 (define_insn "btrunc<mode>2"
5934   [(set (match_operand:SFDF 0 "gpc_reg_operand" "=<Ff>,<Fv>")
5935         (unspec:SFDF [(match_operand:SFDF 1 "gpc_reg_operand" "<Ff>,<Fv>")]
5936                      UNSPEC_FRIZ))]
5937   "TARGET_<MODE>_FPR && TARGET_FPRND"
5938   "@
5939    friz %0,%1
5940    xsrdpiz %x0,%x1"
5941   [(set_attr "type" "fp")
5942    (set_attr "fp_type" "fp_addsub_<Fs>")])
5943
5944 (define_insn "ceil<mode>2"
5945   [(set (match_operand:SFDF 0 "gpc_reg_operand" "=<Ff>,<Fv>")
5946         (unspec:SFDF [(match_operand:SFDF 1 "gpc_reg_operand" "<Ff>,<Fv>")]
5947                      UNSPEC_FRIP))]
5948   "TARGET_<MODE>_FPR && TARGET_FPRND"
5949   "@
5950    frip %0,%1
5951    xsrdpip %x0,%x1"
5952   [(set_attr "type" "fp")
5953    (set_attr "fp_type" "fp_addsub_<Fs>")])
5954
5955 (define_insn "floor<mode>2"
5956   [(set (match_operand:SFDF 0 "gpc_reg_operand" "=<Ff>,<Fv>")
5957         (unspec:SFDF [(match_operand:SFDF 1 "gpc_reg_operand" "<Ff>,<Fv>")]
5958                      UNSPEC_FRIM))]
5959   "TARGET_<MODE>_FPR && TARGET_FPRND"
5960   "@
5961    frim %0,%1
5962    xsrdpim %x0,%x1"
5963   [(set_attr "type" "fp")
5964    (set_attr "fp_type" "fp_addsub_<Fs>")])
5965
5966 ;; No VSX equivalent to frin
5967 (define_insn "round<mode>2"
5968   [(set (match_operand:SFDF 0 "gpc_reg_operand" "=<rreg2>")
5969         (unspec:SFDF [(match_operand:SFDF 1 "gpc_reg_operand" "<rreg2>")]
5970                      UNSPEC_FRIN))]
5971   "TARGET_<MODE>_FPR && TARGET_FPRND"
5972   "frin %0,%1"
5973   [(set_attr "type" "fp")
5974    (set_attr "fp_type" "fp_addsub_<Fs>")])
5975
5976 ; An UNSPEC is used so we don't have to support SImode in FP registers.
5977 (define_insn "stfiwx"
5978   [(set (match_operand:SI 0 "memory_operand" "=Z")
5979         (unspec:SI [(match_operand:DI 1 "gpc_reg_operand" "d")]
5980                    UNSPEC_STFIWX))]
5981   "TARGET_PPC_GFXOPT"
5982   "stfiwx %1,%y0"
5983   [(set_attr "type" "fpstore")])
5984
5985 ;; If we don't have a direct conversion to single precision, don't enable this
5986 ;; conversion for 32-bit without fast math, because we don't have the insn to
5987 ;; generate the fixup swizzle to avoid double rounding problems.
5988 (define_expand "floatsisf2"
5989   [(set (match_operand:SF 0 "gpc_reg_operand" "")
5990         (float:SF (match_operand:SI 1 "nonimmediate_operand" "")))]
5991   "TARGET_HARD_FLOAT && TARGET_SINGLE_FLOAT
5992    && (!TARGET_FPRS
5993        || (TARGET_FPRS
5994            && ((TARGET_FCFIDS && TARGET_LFIWAX)
5995                || (TARGET_DOUBLE_FLOAT && TARGET_FCFID
5996                    && (TARGET_POWERPC64 || flag_unsafe_math_optimizations)))))"
5997   "
5998 {
5999   if (!TARGET_FPRS)
6000     {
6001       if (!REG_P (operands[1]))
6002         operands[1] = force_reg (SImode, operands[1]);
6003     }
6004   else if (TARGET_FCFIDS && TARGET_LFIWAX)
6005     {
6006       emit_insn (gen_floatsisf2_lfiwax (operands[0], operands[1]));
6007       DONE;
6008     }
6009   else if (TARGET_FCFID && TARGET_LFIWAX)
6010     {
6011       rtx dfreg = gen_reg_rtx (DFmode);
6012       emit_insn (gen_floatsidf2_lfiwax (dfreg, operands[1]));
6013       emit_insn (gen_truncdfsf2 (operands[0], dfreg));
6014       DONE;
6015     }
6016   else
6017     {
6018       rtx dreg = operands[1];
6019       if (!REG_P (dreg))
6020         dreg = force_reg (SImode, dreg);
6021       dreg = convert_to_mode (DImode, dreg, false);
6022       emit_insn (gen_floatdisf2 (operands[0], dreg));
6023       DONE;
6024     }
6025 }")
6026
6027 (define_expand "floatdidf2"
6028   [(set (match_operand:DF 0 "gpc_reg_operand" "")
6029         (float:DF (match_operand:DI 1 "gpc_reg_operand" "")))]
6030   "TARGET_FCFID && TARGET_HARD_FLOAT && TARGET_DOUBLE_FLOAT && TARGET_FPRS"
6031   "")
6032
6033 (define_insn "*floatdidf2_fpr"
6034   [(set (match_operand:DF 0 "gpc_reg_operand" "=d")
6035         (float:DF (match_operand:DI 1 "gpc_reg_operand" "d")))]
6036   "TARGET_FCFID && TARGET_HARD_FLOAT && TARGET_DOUBLE_FLOAT && TARGET_FPRS
6037    && !VECTOR_UNIT_VSX_P (DFmode)"
6038   "fcfid %0,%1"
6039   [(set_attr "type" "fp")])
6040
6041 ; Allow the combiner to merge source memory operands to the conversion so that
6042 ; the optimizer/register allocator doesn't try to load the value too early in a
6043 ; GPR and then use store/load to move it to a FPR and suffer from a store-load
6044 ; hit.  We will split after reload to avoid the trip through the GPRs
6045
6046 (define_insn_and_split "*floatdidf2_mem"
6047   [(set (match_operand:DF 0 "gpc_reg_operand" "=d")
6048         (float:DF (match_operand:DI 1 "memory_operand" "m")))
6049    (clobber (match_scratch:DI 2 "=d"))]
6050   "TARGET_HARD_FLOAT && TARGET_DOUBLE_FLOAT && TARGET_FPRS && TARGET_FCFID"
6051   "#"
6052   "&& reload_completed"
6053   [(set (match_dup 2) (match_dup 1))
6054    (set (match_dup 0) (float:DF (match_dup 2)))]
6055   ""
6056   [(set_attr "length" "8")
6057    (set_attr "type" "fpload")])
6058
6059 (define_expand "floatunsdidf2"
6060   [(set (match_operand:DF 0 "gpc_reg_operand" "")
6061         (unsigned_float:DF
6062          (match_operand:DI 1 "gpc_reg_operand" "")))]
6063   "TARGET_HARD_FLOAT && (TARGET_FCFIDU || VECTOR_UNIT_VSX_P (DFmode))"
6064   "")
6065
6066 (define_insn "*floatunsdidf2_fcfidu"
6067   [(set (match_operand:DF 0 "gpc_reg_operand" "=d")
6068         (unsigned_float:DF (match_operand:DI 1 "gpc_reg_operand" "d")))]
6069   "TARGET_HARD_FLOAT && TARGET_FCFIDU && !VECTOR_UNIT_VSX_P (DFmode)"
6070   "fcfidu %0,%1"
6071   [(set_attr "type" "fp")
6072    (set_attr "length" "4")])
6073
6074 (define_insn_and_split "*floatunsdidf2_mem"
6075   [(set (match_operand:DF 0 "gpc_reg_operand" "=d")
6076         (unsigned_float:DF (match_operand:DI 1 "memory_operand" "m")))
6077    (clobber (match_scratch:DI 2 "=d"))]
6078   "TARGET_HARD_FLOAT && (TARGET_FCFIDU || VECTOR_UNIT_VSX_P (DFmode))"
6079   "#"
6080   "&& reload_completed"
6081   [(set (match_dup 2) (match_dup 1))
6082    (set (match_dup 0) (unsigned_float:DF (match_dup 2)))]
6083   ""
6084   [(set_attr "length" "8")
6085    (set_attr "type" "fpload")])
6086
6087 (define_expand "floatdisf2"
6088   [(set (match_operand:SF 0 "gpc_reg_operand" "")
6089         (float:SF (match_operand:DI 1 "gpc_reg_operand" "")))]
6090   "TARGET_FCFID && TARGET_HARD_FLOAT && TARGET_FPRS && TARGET_SINGLE_FLOAT
6091    && (TARGET_FCFIDS || TARGET_POWERPC64 || flag_unsafe_math_optimizations)"
6092   "
6093 {
6094   if (!TARGET_FCFIDS)
6095     {
6096       rtx val = operands[1];
6097       if (!flag_unsafe_math_optimizations)
6098         {
6099           rtx label = gen_label_rtx ();
6100           val = gen_reg_rtx (DImode);
6101           emit_insn (gen_floatdisf2_internal2 (val, operands[1], label));
6102           emit_label (label);
6103         }
6104       emit_insn (gen_floatdisf2_internal1 (operands[0], val));
6105       DONE;
6106     }
6107 }")
6108
6109 (define_insn "floatdisf2_fcfids"
6110   [(set (match_operand:SF 0 "gpc_reg_operand" "=f")
6111         (float:SF (match_operand:DI 1 "gpc_reg_operand" "d")))]
6112   "TARGET_HARD_FLOAT && TARGET_FPRS && TARGET_SINGLE_FLOAT
6113    && TARGET_DOUBLE_FLOAT && TARGET_FCFIDS"
6114   "fcfids %0,%1"
6115   [(set_attr "type" "fp")])
6116
6117 (define_insn_and_split "*floatdisf2_mem"
6118   [(set (match_operand:SF 0 "gpc_reg_operand" "=f")
6119         (float:SF (match_operand:DI 1 "memory_operand" "m")))
6120    (clobber (match_scratch:DI 2 "=f"))]
6121   "TARGET_HARD_FLOAT && TARGET_FPRS && TARGET_SINGLE_FLOAT
6122    && TARGET_DOUBLE_FLOAT && TARGET_FCFIDS"
6123   "#"
6124   "&& reload_completed"
6125   [(pc)]
6126   "
6127 {
6128   emit_move_insn (operands[2], operands[1]);
6129   emit_insn (gen_floatdisf2_fcfids (operands[0], operands[2]));
6130   DONE;
6131 }"
6132   [(set_attr "length" "8")])
6133
6134 ;; This is not IEEE compliant if rounding mode is "round to nearest".
6135 ;; If the DI->DF conversion is inexact, then it's possible to suffer
6136 ;; from double rounding.
6137 ;; Instead of creating a new cpu type for two FP operations, just use fp
6138 (define_insn_and_split "floatdisf2_internal1"
6139   [(set (match_operand:SF 0 "gpc_reg_operand" "=f")
6140         (float:SF (match_operand:DI 1 "gpc_reg_operand" "d")))
6141    (clobber (match_scratch:DF 2 "=d"))]
6142   "TARGET_FCFID && TARGET_HARD_FLOAT && TARGET_FPRS && TARGET_SINGLE_FLOAT"
6143   "#"
6144   "&& reload_completed"
6145   [(set (match_dup 2)
6146         (float:DF (match_dup 1)))
6147    (set (match_dup 0)
6148         (float_truncate:SF (match_dup 2)))]
6149   ""
6150   [(set_attr "length" "8")
6151    (set_attr "type" "fp")])
6152
6153 ;; Twiddles bits to avoid double rounding.
6154 ;; Bits that might be truncated when converting to DFmode are replaced
6155 ;; by a bit that won't be lost at that stage, but is below the SFmode
6156 ;; rounding position.
6157 (define_expand "floatdisf2_internal2"
6158   [(parallel [(set (match_dup 3) (ashiftrt:DI (match_operand:DI 1 "" "")
6159                                               (const_int 53)))
6160               (clobber (reg:DI CA_REGNO))])
6161    (set (match_operand:DI 0 "" "") (and:DI (match_dup 1)
6162                                            (const_int 2047)))
6163    (set (match_dup 3) (plus:DI (match_dup 3)
6164                                (const_int 1)))
6165    (set (match_dup 0) (plus:DI (match_dup 0)
6166                                (const_int 2047)))
6167    (set (match_dup 4) (compare:CCUNS (match_dup 3)
6168                                      (const_int 2)))
6169    (set (match_dup 0) (ior:DI (match_dup 0)
6170                               (match_dup 1)))
6171    (set (match_dup 0) (and:DI (match_dup 0)
6172                               (const_int -2048)))
6173    (set (pc) (if_then_else (geu (match_dup 4) (const_int 0))
6174                            (label_ref (match_operand:DI 2 "" ""))
6175                            (pc)))
6176    (set (match_dup 0) (match_dup 1))]
6177   "TARGET_POWERPC64 && TARGET_HARD_FLOAT && TARGET_FPRS && TARGET_SINGLE_FLOAT"
6178   "
6179 {
6180   operands[3] = gen_reg_rtx (DImode);
6181   operands[4] = gen_reg_rtx (CCUNSmode);
6182 }")
6183
6184 (define_expand "floatunsdisf2"
6185   [(set (match_operand:SF 0 "gpc_reg_operand" "")
6186         (unsigned_float:SF (match_operand:DI 1 "gpc_reg_operand" "")))]
6187   "TARGET_HARD_FLOAT && TARGET_FPRS && TARGET_SINGLE_FLOAT
6188    && TARGET_DOUBLE_FLOAT && TARGET_FCFIDUS"
6189   "")
6190
6191 (define_insn "floatunsdisf2_fcfidus"
6192   [(set (match_operand:SF 0 "gpc_reg_operand" "=f")
6193         (unsigned_float:SF (match_operand:DI 1 "gpc_reg_operand" "d")))]
6194   "TARGET_HARD_FLOAT && TARGET_FPRS && TARGET_SINGLE_FLOAT
6195    && TARGET_DOUBLE_FLOAT && TARGET_FCFIDUS"
6196   "fcfidus %0,%1"
6197   [(set_attr "type" "fp")])
6198
6199 (define_insn_and_split "*floatunsdisf2_mem"
6200   [(set (match_operand:SF 0 "gpc_reg_operand" "=f")
6201         (unsigned_float:SF (match_operand:DI 1 "memory_operand" "m")))
6202    (clobber (match_scratch:DI 2 "=f"))]
6203   "TARGET_HARD_FLOAT && TARGET_FPRS && TARGET_SINGLE_FLOAT
6204    && TARGET_DOUBLE_FLOAT && TARGET_FCFIDUS"
6205   "#"
6206   "&& reload_completed"
6207   [(pc)]
6208   "
6209 {
6210   emit_move_insn (operands[2], operands[1]);
6211   emit_insn (gen_floatunsdisf2_fcfidus (operands[0], operands[2]));
6212   DONE;
6213 }"
6214   [(set_attr "length" "8")
6215    (set_attr "type" "fpload")])
6216 \f
6217 ;; Define the TImode operations that can be done in a small number
6218 ;; of instructions.  The & constraints are to prevent the register
6219 ;; allocator from allocating registers that overlap with the inputs
6220 ;; (for example, having an input in 7,8 and an output in 6,7).  We
6221 ;; also allow for the output being the same as one of the inputs.
6222
6223 (define_insn "addti3"
6224   [(set (match_operand:TI 0 "gpc_reg_operand" "=&r,&r,r,r")
6225         (plus:TI (match_operand:TI 1 "gpc_reg_operand" "%r,r,0,0")
6226                  (match_operand:TI 2 "reg_or_short_operand" "r,I,r,I")))]
6227   "TARGET_64BIT"
6228 {
6229   if (WORDS_BIG_ENDIAN)
6230     return (GET_CODE (operands[2])) != CONST_INT
6231             ? \"addc %L0,%L1,%L2\;adde %0,%1,%2\"
6232             : \"addic %L0,%L1,%2\;add%G2e %0,%1\";
6233   else
6234     return (GET_CODE (operands[2])) != CONST_INT
6235             ? \"addc %0,%1,%2\;adde %L0,%L1,%L2\"
6236             : \"addic %0,%1,%2\;add%G2e %L0,%L1\";
6237 }
6238   [(set_attr "type" "two")
6239    (set_attr "length" "8")])
6240
6241 (define_insn "subti3"
6242   [(set (match_operand:TI 0 "gpc_reg_operand" "=&r,&r,r,r,r")
6243         (minus:TI (match_operand:TI 1 "reg_or_short_operand" "r,I,0,r,I")
6244                   (match_operand:TI 2 "gpc_reg_operand" "r,r,r,0,0")))]
6245   "TARGET_64BIT"
6246 {
6247   if (WORDS_BIG_ENDIAN)
6248     return (GET_CODE (operands[1]) != CONST_INT)
6249             ? \"subfc %L0,%L2,%L1\;subfe %0,%2,%1\"
6250             : \"subfic %L0,%L2,%1\;subf%G1e %0,%2\";
6251   else
6252     return (GET_CODE (operands[1]) != CONST_INT)
6253             ? \"subfc %0,%2,%1\;subfe %L0,%L2,%L1\"
6254             : \"subfic %0,%2,%1\;subf%G1e %L0,%L2\";
6255 }
6256   [(set_attr "type" "two")
6257    (set_attr "length" "8")])
6258
6259
6260 ;; Define the DImode operations that can be done in a small number
6261 ;; of instructions.  The & constraints are to prevent the register
6262 ;; allocator from allocating registers that overlap with the inputs
6263 ;; (for example, having an input in 7,8 and an output in 6,7).  We
6264 ;; also allow for the output being the same as one of the inputs.
6265
6266 (define_insn "*adddi3_noppc64"
6267   [(set (match_operand:DI 0 "gpc_reg_operand" "=&r,&r,r,r")
6268         (plus:DI (match_operand:DI 1 "gpc_reg_operand" "%r,r,0,0")
6269                  (match_operand:DI 2 "reg_or_short_operand" "r,I,r,I")))]
6270   "! TARGET_POWERPC64"
6271   "*
6272 {
6273   if (WORDS_BIG_ENDIAN)
6274     return (GET_CODE (operands[2])) != CONST_INT
6275             ? \"addc %L0,%L1,%L2\;adde %0,%1,%2\"
6276             : \"addic %L0,%L1,%2\;add%G2e %0,%1\";
6277   else
6278     return (GET_CODE (operands[2])) != CONST_INT
6279             ? \"addc %0,%1,%2\;adde %L0,%L1,%L2\"
6280             : \"addic %0,%1,%2\;add%G2e %L0,%L1\";
6281 }"
6282   [(set_attr "type" "two")
6283    (set_attr "length" "8")])
6284
6285 (define_insn "*subdi3_noppc64"
6286   [(set (match_operand:DI 0 "gpc_reg_operand" "=&r,&r,r,r,r")
6287         (minus:DI (match_operand:DI 1 "reg_or_short_operand" "r,I,0,r,I")
6288                   (match_operand:DI 2 "gpc_reg_operand" "r,r,r,0,0")))]
6289   "! TARGET_POWERPC64"
6290   "*
6291 {
6292   if (WORDS_BIG_ENDIAN)
6293     return (GET_CODE (operands[1]) != CONST_INT)
6294             ? \"subfc %L0,%L2,%L1\;subfe %0,%2,%1\"
6295             : \"subfic %L0,%L2,%1\;subf%G1e %0,%2\";
6296   else
6297     return (GET_CODE (operands[1]) != CONST_INT)
6298             ? \"subfc %0,%2,%1\;subfe %L0,%L2,%L1\"
6299             : \"subfic %0,%2,%1\;subf%G1e %L0,%L2\";
6300 }"
6301   [(set_attr "type" "two")
6302    (set_attr "length" "8")])
6303
6304 (define_insn "*negdi2_noppc64"
6305   [(set (match_operand:DI 0 "gpc_reg_operand" "=&r,r")
6306         (neg:DI (match_operand:DI 1 "gpc_reg_operand" "r,0")))]
6307   "! TARGET_POWERPC64"
6308   "*
6309 {
6310   return (WORDS_BIG_ENDIAN)
6311     ? \"subfic %L0,%L1,0\;subfze %0,%1\"
6312     : \"subfic %0,%1,0\;subfze %L0,%L1\";
6313 }"
6314   [(set_attr "type" "two")
6315    (set_attr "length" "8")])
6316
6317
6318 ;; Shift by a variable amount is too complex to be worth open-coding.  We
6319 ;; just handle shifts by constants.
6320 (define_insn "ashrdi3_no_power"
6321   [(set (match_operand:DI 0 "gpc_reg_operand" "=&r,&r")
6322         (ashiftrt:DI (match_operand:DI 1 "gpc_reg_operand" "r,r")
6323                      (match_operand:SI 2 "const_int_operand" "M,i")))
6324    (clobber (reg:SI CA_REGNO))]
6325   "!TARGET_POWERPC64"
6326 {
6327   switch (which_alternative)
6328     {
6329     default:
6330       gcc_unreachable ();
6331     case 0:
6332       if (WORDS_BIG_ENDIAN)
6333         return \"srawi %0,%1,31\;srawi %L0,%1,%h2\";
6334       else
6335         return \"srawi %L0,%L1,31\;srawi %0,%L1,%h2\";
6336     case 1:
6337       if (WORDS_BIG_ENDIAN)
6338         return \"srwi %L0,%L1,%h2\;insrwi %L0,%1,%h2,0\;srawi %0,%1,%h2\";
6339       else
6340         return \"srwi %0,%1,%h2\;insrwi %0,%L1,%h2,0\;srawi %L0,%L1,%h2\";
6341     }
6342 }
6343   [(set_attr "type" "two,three")
6344    (set_attr "length" "8,12")])
6345
6346 (define_insn "*ashrdisi3_noppc64be"
6347   [(set (match_operand:SI 0 "gpc_reg_operand" "=r")
6348         (subreg:SI (ashiftrt:DI (match_operand:DI 1 "gpc_reg_operand" "r")
6349                                 (const_int 32)) 4))]
6350   "TARGET_32BIT && !TARGET_POWERPC64 && WORDS_BIG_ENDIAN"
6351   "*
6352 {
6353   if (REGNO (operands[0]) == REGNO (operands[1]))
6354     return \"\";
6355   else
6356     return \"mr %0,%1\";
6357 }"
6358    [(set_attr "length" "4")])
6359
6360 \f
6361 ;; PowerPC64 DImode operations.
6362
6363 (define_insn "*rotldi3_internal4"
6364   [(set (match_operand:DI 0 "gpc_reg_operand" "=r")
6365         (and:DI (rotate:DI (match_operand:DI 1 "gpc_reg_operand" "r")
6366                            (match_operand:DI 2 "reg_or_cint_operand" "rn"))
6367                 (match_operand:DI 3 "mask64_operand" "n")))]
6368   "TARGET_POWERPC64"
6369   "rld%I2c%B3 %0,%1,%H2,%S3"
6370   [(set_attr "type" "shift")
6371    (set_attr "maybe_var_shift" "yes")])
6372
6373 (define_insn "*rotldi3_internal5"
6374   [(set (match_operand:CC 0 "cc_reg_operand" "=x,?y")
6375         (compare:CC (and:DI
6376                      (rotate:DI (match_operand:DI 1 "gpc_reg_operand" "r,r")
6377                                 (match_operand:DI 2 "reg_or_cint_operand" "rn,rn"))
6378                      (match_operand:DI 3 "mask64_operand" "n,n"))
6379                     (const_int 0)))
6380    (clobber (match_scratch:DI 4 "=r,r"))]
6381   "TARGET_64BIT"
6382   "@
6383    rld%I2c%B3. %4,%1,%H2,%S3
6384    #"
6385   [(set_attr "type" "shift")
6386    (set_attr "maybe_var_shift" "yes")
6387    (set_attr "dot" "yes")
6388    (set_attr "length" "4,8")])
6389
6390 (define_split
6391   [(set (match_operand:CC 0 "cc_reg_not_micro_cr0_operand" "")
6392         (compare:CC (and:DI
6393                      (rotate:DI (match_operand:DI 1 "gpc_reg_operand" "")
6394                                 (match_operand:DI 2 "reg_or_cint_operand" ""))
6395                      (match_operand:DI 3 "mask64_operand" ""))
6396                     (const_int 0)))
6397    (clobber (match_scratch:DI 4 ""))]
6398   "TARGET_POWERPC64 && reload_completed"
6399   [(set (match_dup 4)
6400         (and:DI (rotate:DI (match_dup 1)
6401                                 (match_dup 2))
6402                      (match_dup 3)))
6403    (set (match_dup 0)
6404         (compare:CC (match_dup 4)
6405                     (const_int 0)))]
6406   "")
6407
6408 (define_insn "*rotldi3_internal6"
6409   [(set (match_operand:CC 4 "cc_reg_operand" "=x,?y")
6410         (compare:CC (and:DI
6411                      (rotate:DI (match_operand:DI 1 "gpc_reg_operand" "r,r")
6412                                 (match_operand:DI 2 "reg_or_cint_operand" "rn,rn"))
6413                      (match_operand:DI 3 "mask64_operand" "n,n"))
6414                     (const_int 0)))
6415    (set (match_operand:DI 0 "gpc_reg_operand" "=r,r")
6416         (and:DI (rotate:DI (match_dup 1) (match_dup 2)) (match_dup 3)))]
6417   "TARGET_64BIT"
6418   "@
6419    rld%I2c%B3. %0,%1,%H2,%S3
6420    #"
6421   [(set_attr "type" "shift")
6422    (set_attr "maybe_var_shift" "yes")
6423    (set_attr "dot" "yes")
6424    (set_attr "length" "4,8")])
6425
6426 (define_split
6427   [(set (match_operand:CC 4 "cc_reg_not_micro_cr0_operand" "")
6428         (compare:CC (and:DI
6429                      (rotate:DI (match_operand:DI 1 "gpc_reg_operand" "")
6430                                 (match_operand:DI 2 "reg_or_cint_operand" ""))
6431                      (match_operand:DI 3 "mask64_operand" ""))
6432                     (const_int 0)))
6433    (set (match_operand:DI 0 "gpc_reg_operand" "")
6434         (and:DI (rotate:DI (match_dup 1) (match_dup 2)) (match_dup 3)))]
6435   "TARGET_POWERPC64 && reload_completed"
6436   [(set (match_dup 0)
6437         (and:DI (rotate:DI (match_dup 1) (match_dup 2)) (match_dup 3)))
6438    (set (match_dup 4)
6439         (compare:CC (match_dup 0)
6440                     (const_int 0)))]
6441   "")
6442
6443 (define_insn "*rotldi3_internal7le"
6444   [(set (match_operand:DI 0 "gpc_reg_operand" "=r")
6445         (zero_extend:DI
6446          (subreg:QI
6447           (rotate:DI (match_operand:DI 1 "gpc_reg_operand" "r")
6448                      (match_operand:DI 2 "reg_or_cint_operand" "rn")) 0)))]
6449   "TARGET_POWERPC64 && !BYTES_BIG_ENDIAN"
6450   "rld%I2cl %0,%1,%H2,56"
6451   [(set_attr "type" "shift")
6452    (set_attr "maybe_var_shift" "yes")])
6453
6454 (define_insn "*rotldi3_internal7be"
6455   [(set (match_operand:DI 0 "gpc_reg_operand" "=r")
6456         (zero_extend:DI
6457          (subreg:QI
6458           (rotate:DI (match_operand:DI 1 "gpc_reg_operand" "r")
6459                      (match_operand:DI 2 "reg_or_cint_operand" "rn")) 7)))]
6460   "TARGET_POWERPC64 && BYTES_BIG_ENDIAN"
6461   "rld%I2cl %0,%1,%H2,56"
6462   [(set_attr "type" "shift")
6463    (set_attr "maybe_var_shift" "yes")])
6464
6465 (define_insn "*rotldi3_internal8le"
6466   [(set (match_operand:CC 0 "cc_reg_operand" "=x,?y")
6467         (compare:CC (zero_extend:DI
6468                      (subreg:QI
6469                       (rotate:DI (match_operand:DI 1 "gpc_reg_operand" "r,r")
6470                                  (match_operand:DI 2 "reg_or_cint_operand" "rn,rn")) 0))
6471                     (const_int 0)))
6472    (clobber (match_scratch:DI 3 "=r,r"))]
6473   "TARGET_64BIT && !BYTES_BIG_ENDIAN"
6474   "@
6475    rld%I2cl. %3,%1,%H2,56
6476    #"
6477   [(set_attr "type" "shift")
6478    (set_attr "maybe_var_shift" "yes")
6479    (set_attr "dot" "yes")
6480    (set_attr "length" "4,8")])
6481
6482 (define_insn "*rotldi3_internal8be"
6483   [(set (match_operand:CC 0 "cc_reg_operand" "=x,?y")
6484         (compare:CC (zero_extend:DI
6485                      (subreg:QI
6486                       (rotate:DI (match_operand:DI 1 "gpc_reg_operand" "r,r")
6487                                  (match_operand:DI 2 "reg_or_cint_operand" "rn,rn")) 7))
6488                     (const_int 0)))
6489    (clobber (match_scratch:DI 3 "=r,r"))]
6490   "TARGET_64BIT && BYTES_BIG_ENDIAN"
6491   "@
6492    rld%I2cl. %3,%1,%H2,56
6493    #"
6494   [(set_attr "type" "shift")
6495    (set_attr "maybe_var_shift" "yes")
6496    (set_attr "dot" "yes")
6497    (set_attr "length" "4,8")])
6498
6499 (define_split
6500   [(set (match_operand:CC 0 "cc_reg_not_micro_cr0_operand" "")
6501         (compare:CC (zero_extend:DI
6502                      (subreg:QI
6503                       (rotate:DI (match_operand:DI 1 "gpc_reg_operand" "")
6504                                  (match_operand:DI 2 "reg_or_cint_operand" "")) 0))
6505                     (const_int 0)))
6506    (clobber (match_scratch:DI 3 ""))]
6507   "TARGET_POWERPC64 && !BYTES_BIG_ENDIAN && reload_completed"
6508   [(set (match_dup 3)
6509         (zero_extend:DI (subreg:QI
6510                       (rotate:DI (match_dup 1)
6511                                  (match_dup 2)) 0)))
6512    (set (match_dup 0)
6513         (compare:CC (match_dup 3)
6514                     (const_int 0)))]
6515   "")
6516
6517 (define_split
6518   [(set (match_operand:CC 0 "cc_reg_not_micro_cr0_operand" "")
6519         (compare:CC (zero_extend:DI
6520                      (subreg:QI
6521                       (rotate:DI (match_operand:DI 1 "gpc_reg_operand" "")
6522                                  (match_operand:DI 2 "reg_or_cint_operand" "")) 7))
6523                     (const_int 0)))
6524    (clobber (match_scratch:DI 3 ""))]
6525   "TARGET_POWERPC64 && BYTES_BIG_ENDIAN && reload_completed"
6526   [(set (match_dup 3)
6527         (zero_extend:DI (subreg:QI
6528                       (rotate:DI (match_dup 1)
6529                                  (match_dup 2)) 7)))
6530    (set (match_dup 0)
6531         (compare:CC (match_dup 3)
6532                     (const_int 0)))]
6533   "")
6534
6535 (define_insn "*rotldi3_internal9le"
6536   [(set (match_operand:CC 3 "cc_reg_operand" "=x,?y")
6537         (compare:CC (zero_extend:DI
6538                      (subreg:QI
6539                       (rotate:DI (match_operand:DI 1 "gpc_reg_operand" "r,r")
6540                                  (match_operand:DI 2 "reg_or_cint_operand" "rn,rn")) 0))
6541                     (const_int 0)))
6542    (set (match_operand:DI 0 "gpc_reg_operand" "=r,r")
6543         (zero_extend:DI (subreg:QI (rotate:DI (match_dup 1) (match_dup 2)) 0)))]
6544   "TARGET_64BIT && !BYTES_BIG_ENDIAN"
6545   "@
6546    rld%I2cl. %0,%1,%H2,56
6547    #"
6548   [(set_attr "type" "shift")
6549    (set_attr "maybe_var_shift" "yes")
6550    (set_attr "dot" "yes")
6551    (set_attr "length" "4,8")])
6552
6553 (define_insn "*rotldi3_internal9be"
6554   [(set (match_operand:CC 3 "cc_reg_operand" "=x,?y")
6555         (compare:CC (zero_extend:DI
6556                      (subreg:QI
6557                       (rotate:DI (match_operand:DI 1 "gpc_reg_operand" "r,r")
6558                                  (match_operand:DI 2 "reg_or_cint_operand" "rn,rn")) 7))
6559                     (const_int 0)))
6560    (set (match_operand:DI 0 "gpc_reg_operand" "=r,r")
6561         (zero_extend:DI (subreg:QI (rotate:DI (match_dup 1) (match_dup 2)) 7)))]
6562   "TARGET_64BIT && BYTES_BIG_ENDIAN"
6563   "@
6564    rld%I2cl. %0,%1,%H2,56
6565    #"
6566   [(set_attr "type" "shift")
6567    (set_attr "maybe_var_shift" "yes")
6568    (set_attr "dot" "yes")
6569    (set_attr "length" "4,8")])
6570
6571 (define_split
6572   [(set (match_operand:CC 3 "cc_reg_not_micro_cr0_operand" "")
6573         (compare:CC (zero_extend:DI
6574                      (subreg:QI
6575                       (rotate:DI (match_operand:DI 1 "gpc_reg_operand" "")
6576                                  (match_operand:DI 2 "reg_or_cint_operand" "")) 0))
6577                     (const_int 0)))
6578    (set (match_operand:DI 0 "gpc_reg_operand" "")
6579         (zero_extend:DI (subreg:QI (rotate:DI (match_dup 1) (match_dup 2)) 0)))]
6580   "TARGET_POWERPC64 && !BYTES_BIG_ENDIAN && reload_completed"
6581   [(set (match_dup 0)
6582         (zero_extend:DI (subreg:QI (rotate:DI (match_dup 1) (match_dup 2)) 0)))
6583    (set (match_dup 3)
6584         (compare:CC (match_dup 0)
6585                     (const_int 0)))]
6586   "")
6587
6588 (define_split
6589   [(set (match_operand:CC 3 "cc_reg_not_micro_cr0_operand" "")
6590         (compare:CC (zero_extend:DI
6591                      (subreg:QI
6592                       (rotate:DI (match_operand:DI 1 "gpc_reg_operand" "")
6593                                  (match_operand:DI 2 "reg_or_cint_operand" "")) 7))
6594                     (const_int 0)))
6595    (set (match_operand:DI 0 "gpc_reg_operand" "")
6596         (zero_extend:DI (subreg:QI (rotate:DI (match_dup 1) (match_dup 2)) 7)))]
6597   "TARGET_POWERPC64 && BYTES_BIG_ENDIAN && reload_completed"
6598   [(set (match_dup 0)
6599         (zero_extend:DI (subreg:QI (rotate:DI (match_dup 1) (match_dup 2)) 7)))
6600    (set (match_dup 3)
6601         (compare:CC (match_dup 0)
6602                     (const_int 0)))]
6603   "")
6604
6605 (define_insn "*rotldi3_internal10le"
6606   [(set (match_operand:DI 0 "gpc_reg_operand" "=r")
6607         (zero_extend:DI
6608          (subreg:HI
6609           (rotate:DI (match_operand:DI 1 "gpc_reg_operand" "r")
6610                      (match_operand:DI 2 "reg_or_cint_operand" "rn")) 0)))]
6611   "TARGET_POWERPC64 && !BYTES_BIG_ENDIAN"
6612   "rld%I2cl %0,%1,%H2,48"
6613   [(set_attr "type" "shift")
6614    (set_attr "maybe_var_shift" "yes")])
6615
6616 (define_insn "*rotldi3_internal10be"
6617   [(set (match_operand:DI 0 "gpc_reg_operand" "=r")
6618         (zero_extend:DI
6619          (subreg:HI
6620           (rotate:DI (match_operand:DI 1 "gpc_reg_operand" "r")
6621                      (match_operand:DI 2 "reg_or_cint_operand" "rn")) 6)))]
6622   "TARGET_POWERPC64 && BYTES_BIG_ENDIAN"
6623   "rld%I2cl %0,%1,%H2,48"
6624   [(set_attr "type" "shift")
6625    (set_attr "maybe_var_shift" "yes")])
6626
6627 (define_insn "*rotldi3_internal11le"
6628   [(set (match_operand:CC 0 "cc_reg_operand" "=x,?y")
6629         (compare:CC (zero_extend:DI
6630                      (subreg:HI
6631                       (rotate:DI (match_operand:DI 1 "gpc_reg_operand" "r,r")
6632                                  (match_operand:DI 2 "reg_or_cint_operand" "rn,rn")) 0))
6633                     (const_int 0)))
6634    (clobber (match_scratch:DI 3 "=r,r"))]
6635   "TARGET_64BIT && !BYTES_BIG_ENDIAN"
6636   "@
6637    rld%I2cl. %3,%1,%H2,48
6638    #"
6639   [(set_attr "type" "shift")
6640    (set_attr "maybe_var_shift" "yes")
6641    (set_attr "dot" "yes")
6642    (set_attr "length" "4,8")])
6643
6644 (define_insn "*rotldi3_internal11be"
6645   [(set (match_operand:CC 0 "cc_reg_operand" "=x,?y")
6646         (compare:CC (zero_extend:DI
6647                      (subreg:HI
6648                       (rotate:DI (match_operand:DI 1 "gpc_reg_operand" "r,r")
6649                                  (match_operand:DI 2 "reg_or_cint_operand" "rn,rn")) 6))
6650                     (const_int 0)))
6651    (clobber (match_scratch:DI 3 "=r,r"))]
6652   "TARGET_64BIT && BYTES_BIG_ENDIAN"
6653   "@
6654    rld%I2cl. %3,%1,%H2,48
6655    #"
6656   [(set_attr "type" "shift")
6657    (set_attr "maybe_var_shift" "yes")
6658    (set_attr "dot" "yes")
6659    (set_attr "length" "4,8")])
6660
6661 (define_split
6662   [(set (match_operand:CC 0 "cc_reg_not_micro_cr0_operand" "")
6663         (compare:CC (zero_extend:DI
6664                      (subreg:HI
6665                       (rotate:DI (match_operand:DI 1 "gpc_reg_operand" "")
6666                                  (match_operand:DI 2 "reg_or_cint_operand" "")) 0))
6667                     (const_int 0)))
6668    (clobber (match_scratch:DI 3 ""))]
6669   "TARGET_POWERPC64 && !BYTES_BIG_ENDIAN && reload_completed"
6670   [(set (match_dup 3)
6671         (zero_extend:DI (subreg:HI
6672                       (rotate:DI (match_dup 1)
6673                                  (match_dup 2)) 0)))
6674    (set (match_dup 0)
6675         (compare:CC (match_dup 3)
6676                     (const_int 0)))]
6677   "")
6678
6679 (define_split
6680   [(set (match_operand:CC 0 "cc_reg_not_micro_cr0_operand" "")
6681         (compare:CC (zero_extend:DI
6682                      (subreg:HI
6683                       (rotate:DI (match_operand:DI 1 "gpc_reg_operand" "")
6684                                  (match_operand:DI 2 "reg_or_cint_operand" "")) 6))
6685                     (const_int 0)))
6686    (clobber (match_scratch:DI 3 ""))]
6687   "TARGET_POWERPC64 && BYTES_BIG_ENDIAN && reload_completed"
6688   [(set (match_dup 3)
6689         (zero_extend:DI (subreg:HI
6690                       (rotate:DI (match_dup 1)
6691                                  (match_dup 2)) 6)))
6692    (set (match_dup 0)
6693         (compare:CC (match_dup 3)
6694                     (const_int 0)))]
6695   "")
6696
6697 (define_insn "*rotldi3_internal12le"
6698   [(set (match_operand:CC 3 "cc_reg_operand" "=x,?y")
6699         (compare:CC (zero_extend:DI
6700                      (subreg:HI
6701                       (rotate:DI (match_operand:DI 1 "gpc_reg_operand" "r,r")
6702                                  (match_operand:DI 2 "reg_or_cint_operand" "rn,rn")) 0))
6703                     (const_int 0)))
6704    (set (match_operand:DI 0 "gpc_reg_operand" "=r,r")
6705         (zero_extend:DI (subreg:HI (rotate:DI (match_dup 1) (match_dup 2)) 0)))]
6706   "TARGET_64BIT && !BYTES_BIG_ENDIAN"
6707   "@
6708    rld%I2cl. %0,%1,%H2,48
6709    #"
6710   [(set_attr "type" "shift")
6711    (set_attr "maybe_var_shift" "yes")
6712    (set_attr "dot" "yes")
6713    (set_attr "length" "4,8")])
6714
6715 (define_insn "*rotldi3_internal12be"
6716   [(set (match_operand:CC 3 "cc_reg_operand" "=x,?y")
6717         (compare:CC (zero_extend:DI
6718                      (subreg:HI
6719                       (rotate:DI (match_operand:DI 1 "gpc_reg_operand" "r,r")
6720                                  (match_operand:DI 2 "reg_or_cint_operand" "rn,rn")) 6))
6721                     (const_int 0)))
6722    (set (match_operand:DI 0 "gpc_reg_operand" "=r,r")
6723         (zero_extend:DI (subreg:HI (rotate:DI (match_dup 1) (match_dup 2)) 6)))]
6724   "TARGET_64BIT && BYTES_BIG_ENDIAN"
6725   "@
6726    rld%I2cl. %0,%1,%H2,48
6727    #"
6728   [(set_attr "type" "shift")
6729    (set_attr "maybe_var_shift" "yes")
6730    (set_attr "dot" "yes")
6731    (set_attr "length" "4,8")])
6732
6733 (define_split
6734   [(set (match_operand:CC 3 "cc_reg_not_micro_cr0_operand" "")
6735         (compare:CC (zero_extend:DI
6736                      (subreg:HI
6737                       (rotate:DI (match_operand:DI 1 "gpc_reg_operand" "")
6738                                  (match_operand:DI 2 "reg_or_cint_operand" "")) 0))
6739                     (const_int 0)))
6740    (set (match_operand:DI 0 "gpc_reg_operand" "")
6741         (zero_extend:DI (subreg:HI (rotate:DI (match_dup 1) (match_dup 2)) 0)))]
6742   "TARGET_POWERPC64 && !BYTES_BIG_ENDIAN && reload_completed"
6743   [(set (match_dup 0)
6744         (zero_extend:DI (subreg:HI (rotate:DI (match_dup 1) (match_dup 2)) 0)))
6745    (set (match_dup 3)
6746         (compare:CC (match_dup 0)
6747                     (const_int 0)))]
6748   "")
6749
6750 (define_split
6751   [(set (match_operand:CC 3 "cc_reg_not_micro_cr0_operand" "")
6752         (compare:CC (zero_extend:DI
6753                      (subreg:HI
6754                       (rotate:DI (match_operand:DI 1 "gpc_reg_operand" "")
6755                                  (match_operand:DI 2 "reg_or_cint_operand" "")) 6))
6756                     (const_int 0)))
6757    (set (match_operand:DI 0 "gpc_reg_operand" "")
6758         (zero_extend:DI (subreg:HI (rotate:DI (match_dup 1) (match_dup 2)) 6)))]
6759   "TARGET_POWERPC64 && BYTES_BIG_ENDIAN && reload_completed"
6760   [(set (match_dup 0)
6761         (zero_extend:DI (subreg:HI (rotate:DI (match_dup 1) (match_dup 2)) 6)))
6762    (set (match_dup 3)
6763         (compare:CC (match_dup 0)
6764                     (const_int 0)))]
6765   "")
6766
6767 (define_insn "*rotldi3_internal13le"
6768   [(set (match_operand:DI 0 "gpc_reg_operand" "=r")
6769         (zero_extend:DI
6770          (subreg:SI
6771           (rotate:DI (match_operand:DI 1 "gpc_reg_operand" "r")
6772                      (match_operand:DI 2 "reg_or_cint_operand" "rn")) 0)))]
6773   "TARGET_POWERPC64 && !BYTES_BIG_ENDIAN"
6774   "rld%I2cl %0,%1,%H2,32"
6775   [(set_attr "type" "shift")
6776    (set_attr "maybe_var_shift" "yes")])
6777
6778 (define_insn "*rotldi3_internal13be"
6779   [(set (match_operand:DI 0 "gpc_reg_operand" "=r")
6780         (zero_extend:DI
6781          (subreg:SI
6782           (rotate:DI (match_operand:DI 1 "gpc_reg_operand" "r")
6783                      (match_operand:DI 2 "reg_or_cint_operand" "rn")) 4)))]
6784   "TARGET_POWERPC64 && BYTES_BIG_ENDIAN"
6785   "rld%I2cl %0,%1,%H2,32"
6786   [(set_attr "type" "shift")
6787    (set_attr "maybe_var_shift" "yes")])
6788
6789 (define_insn "*rotldi3_internal14le"
6790   [(set (match_operand:CC 0 "cc_reg_operand" "=x,?y")
6791         (compare:CC (zero_extend:DI
6792                      (subreg:SI
6793                       (rotate:DI (match_operand:DI 1 "gpc_reg_operand" "r,r")
6794                                  (match_operand:DI 2 "reg_or_cint_operand" "rn,rn")) 0))
6795                     (const_int 0)))
6796    (clobber (match_scratch:DI 3 "=r,r"))]
6797   "TARGET_64BIT && !BYTES_BIG_ENDIAN"
6798   "@
6799    rld%I2cl. %3,%1,%H2,32
6800    #"
6801   [(set_attr "type" "shift")
6802    (set_attr "maybe_var_shift" "yes")
6803    (set_attr "dot" "yes")
6804    (set_attr "length" "4,8")])
6805
6806 (define_insn "*rotldi3_internal14be"
6807   [(set (match_operand:CC 0 "cc_reg_operand" "=x,?y")
6808         (compare:CC (zero_extend:DI
6809                      (subreg:SI
6810                       (rotate:DI (match_operand:DI 1 "gpc_reg_operand" "r,r")
6811                                  (match_operand:DI 2 "reg_or_cint_operand" "rn,rn")) 4))
6812                     (const_int 0)))
6813    (clobber (match_scratch:DI 3 "=r,r"))]
6814   "TARGET_64BIT && BYTES_BIG_ENDIAN"
6815   "@
6816    rld%I2cl. %3,%1,%H2,32
6817    #"
6818   [(set_attr "type" "shift")
6819    (set_attr "maybe_var_shift" "yes")
6820    (set_attr "dot" "yes")
6821    (set_attr "length" "4,8")])
6822
6823 (define_split
6824   [(set (match_operand:CC 0 "cc_reg_not_micro_cr0_operand" "")
6825         (compare:CC (zero_extend:DI
6826                      (subreg:SI
6827                       (rotate:DI (match_operand:DI 1 "gpc_reg_operand" "")
6828                                  (match_operand:DI 2 "reg_or_cint_operand" "")) 0))
6829                     (const_int 0)))
6830    (clobber (match_scratch:DI 3 ""))]
6831   "TARGET_POWERPC64 && !BYTES_BIG_ENDIAN && reload_completed"
6832   [(set (match_dup 3)
6833         (zero_extend:DI (subreg:SI
6834                       (rotate:DI (match_dup 1)
6835                                  (match_dup 2)) 0)))
6836    (set (match_dup 0)
6837         (compare:CC (match_dup 3)
6838                     (const_int 0)))]
6839   "")
6840
6841 (define_split
6842   [(set (match_operand:CC 0 "cc_reg_not_micro_cr0_operand" "")
6843         (compare:CC (zero_extend:DI
6844                      (subreg:SI
6845                       (rotate:DI (match_operand:DI 1 "gpc_reg_operand" "")
6846                                  (match_operand:DI 2 "reg_or_cint_operand" "")) 4))
6847                     (const_int 0)))
6848    (clobber (match_scratch:DI 3 ""))]
6849   "TARGET_POWERPC64 && BYTES_BIG_ENDIAN && reload_completed"
6850   [(set (match_dup 3)
6851         (zero_extend:DI (subreg:SI
6852                       (rotate:DI (match_dup 1)
6853                                  (match_dup 2)) 4)))
6854    (set (match_dup 0)
6855         (compare:CC (match_dup 3)
6856                     (const_int 0)))]
6857   "")
6858
6859 (define_insn "*rotldi3_internal15le"
6860   [(set (match_operand:CC 3 "cc_reg_operand" "=x,?y")
6861         (compare:CC (zero_extend:DI
6862                      (subreg:SI
6863                       (rotate:DI (match_operand:DI 1 "gpc_reg_operand" "r,r")
6864                                  (match_operand:DI 2 "reg_or_cint_operand" "rn,rn")) 0))
6865                     (const_int 0)))
6866    (set (match_operand:DI 0 "gpc_reg_operand" "=r,r")
6867         (zero_extend:DI (subreg:SI (rotate:DI (match_dup 1) (match_dup 2)) 0)))]
6868   "TARGET_64BIT && !BYTES_BIG_ENDIAN"
6869   "@
6870    rld%I2cl. %0,%1,%H2,32
6871    #"
6872   [(set_attr "type" "shift")
6873    (set_attr "maybe_var_shift" "yes")
6874    (set_attr "dot" "yes")
6875    (set_attr "length" "4,8")])
6876
6877 (define_insn "*rotldi3_internal15be"
6878   [(set (match_operand:CC 3 "cc_reg_operand" "=x,?y")
6879         (compare:CC (zero_extend:DI
6880                      (subreg:SI
6881                       (rotate:DI (match_operand:DI 1 "gpc_reg_operand" "r,r")
6882                                  (match_operand:DI 2 "reg_or_cint_operand" "rn,rn")) 4))
6883                     (const_int 0)))
6884    (set (match_operand:DI 0 "gpc_reg_operand" "=r,r")
6885         (zero_extend:DI (subreg:SI (rotate:DI (match_dup 1) (match_dup 2)) 4)))]
6886   "TARGET_64BIT && BYTES_BIG_ENDIAN"
6887   "@
6888    rld%I2cl. %0,%1,%H2,32
6889    #"
6890   [(set_attr "type" "shift")
6891    (set_attr "maybe_var_shift" "yes")
6892    (set_attr "dot" "yes")
6893    (set_attr "length" "4,8")])
6894
6895 (define_split
6896   [(set (match_operand:CC 3 "cc_reg_not_micro_cr0_operand" "")
6897         (compare:CC (zero_extend:DI
6898                      (subreg:SI
6899                       (rotate:DI (match_operand:DI 1 "gpc_reg_operand" "")
6900                                  (match_operand:DI 2 "reg_or_cint_operand" "")) 0))
6901                     (const_int 0)))
6902    (set (match_operand:DI 0 "gpc_reg_operand" "")
6903         (zero_extend:DI (subreg:SI (rotate:DI (match_dup 1) (match_dup 2)) 0)))]
6904   "TARGET_POWERPC64 && !BYTES_BIG_ENDIAN && reload_completed"
6905   [(set (match_dup 0)
6906         (zero_extend:DI (subreg:SI (rotate:DI (match_dup 1) (match_dup 2)) 0)))
6907    (set (match_dup 3)
6908         (compare:CC (match_dup 0)
6909                     (const_int 0)))]
6910   "")
6911
6912 (define_split
6913   [(set (match_operand:CC 3 "cc_reg_not_micro_cr0_operand" "")
6914         (compare:CC (zero_extend:DI
6915                      (subreg:SI
6916                       (rotate:DI (match_operand:DI 1 "gpc_reg_operand" "")
6917                                  (match_operand:DI 2 "reg_or_cint_operand" "")) 4))
6918                     (const_int 0)))
6919    (set (match_operand:DI 0 "gpc_reg_operand" "")
6920         (zero_extend:DI (subreg:SI (rotate:DI (match_dup 1) (match_dup 2)) 4)))]
6921   "TARGET_POWERPC64 && BYTES_BIG_ENDIAN && reload_completed"
6922   [(set (match_dup 0)
6923         (zero_extend:DI (subreg:SI (rotate:DI (match_dup 1) (match_dup 2)) 4)))
6924    (set (match_dup 3)
6925         (compare:CC (match_dup 0)
6926                     (const_int 0)))]
6927   "")
6928
6929 (define_insn "*ashldi3_internal4"
6930   [(set (match_operand:DI 0 "gpc_reg_operand" "=r")
6931         (and:DI (ashift:DI (match_operand:DI 1 "gpc_reg_operand" "r")
6932                            (match_operand:SI 2 "const_int_operand" "i"))
6933                 (match_operand:DI 3 "const_int_operand" "n")))]
6934   "TARGET_POWERPC64 && includes_rldic_lshift_p (operands[2], operands[3])"
6935   "rldic %0,%1,%H2,%W3"
6936   [(set_attr "type" "shift")])
6937
6938 (define_insn "ashldi3_internal5"
6939   [(set (match_operand:CC 0 "cc_reg_operand" "=x,?y")
6940         (compare:CC
6941          (and:DI (ashift:DI (match_operand:DI 1 "gpc_reg_operand" "r,r")
6942                             (match_operand:SI 2 "const_int_operand" "i,i"))
6943                  (match_operand:DI 3 "const_int_operand" "n,n"))
6944          (const_int 0)))
6945    (clobber (match_scratch:DI 4 "=r,r"))]
6946   "TARGET_64BIT && includes_rldic_lshift_p (operands[2], operands[3])"
6947   "@
6948    rldic. %4,%1,%H2,%W3
6949    #"
6950   [(set_attr "type" "shift")
6951    (set_attr "dot" "yes")
6952    (set_attr "length" "4,8")])
6953
6954 (define_split
6955   [(set (match_operand:CC 0 "cc_reg_not_micro_cr0_operand" "")
6956         (compare:CC
6957          (and:DI (ashift:DI (match_operand:DI 1 "gpc_reg_operand" "")
6958                             (match_operand:SI 2 "const_int_operand" ""))
6959                  (match_operand:DI 3 "const_int_operand" ""))
6960          (const_int 0)))
6961    (clobber (match_scratch:DI 4 ""))]
6962   "TARGET_POWERPC64 && reload_completed
6963    && includes_rldic_lshift_p (operands[2], operands[3])"
6964   [(set (match_dup 4)
6965         (and:DI (ashift:DI (match_dup 1) (match_dup 2))
6966                 (match_dup 3)))
6967    (set (match_dup 0)
6968         (compare:CC (match_dup 4)
6969                     (const_int 0)))]
6970   "")
6971
6972 (define_insn "*ashldi3_internal6"
6973   [(set (match_operand:CC 4 "cc_reg_operand" "=x,?y")
6974         (compare:CC
6975          (and:DI (ashift:DI (match_operand:DI 1 "gpc_reg_operand" "r,r")
6976                             (match_operand:SI 2 "const_int_operand" "i,i"))
6977                     (match_operand:DI 3 "const_int_operand" "n,n"))
6978          (const_int 0)))
6979    (set (match_operand:DI 0 "gpc_reg_operand" "=r,r")
6980         (and:DI (ashift:DI (match_dup 1) (match_dup 2)) (match_dup 3)))]
6981   "TARGET_64BIT && includes_rldic_lshift_p (operands[2], operands[3])"
6982   "@
6983    rldic. %0,%1,%H2,%W3
6984    #"
6985   [(set_attr "type" "shift")
6986    (set_attr "dot" "yes")
6987    (set_attr "length" "4,8")])
6988
6989 (define_split
6990   [(set (match_operand:CC 4 "cc_reg_not_micro_cr0_operand" "")
6991         (compare:CC
6992          (and:DI (ashift:DI (match_operand:DI 1 "gpc_reg_operand" "")
6993                             (match_operand:SI 2 "const_int_operand" ""))
6994                  (match_operand:DI 3 "const_int_operand" ""))
6995          (const_int 0)))
6996    (set (match_operand:DI 0 "gpc_reg_operand" "")
6997         (and:DI (ashift:DI (match_dup 1) (match_dup 2)) (match_dup 3)))]
6998   "TARGET_POWERPC64 && reload_completed
6999    && includes_rldic_lshift_p (operands[2], operands[3])"
7000   [(set (match_dup 0)
7001         (and:DI (ashift:DI (match_dup 1) (match_dup 2))
7002                 (match_dup 3)))
7003    (set (match_dup 4)
7004         (compare:CC (match_dup 0)
7005                     (const_int 0)))]
7006   "")
7007
7008 (define_insn "*ashldi3_internal7"
7009   [(set (match_operand:DI 0 "gpc_reg_operand" "=r")
7010         (and:DI (ashift:DI (match_operand:DI 1 "gpc_reg_operand" "r")
7011                            (match_operand:SI 2 "const_int_operand" "i"))
7012                 (match_operand:DI 3 "mask64_operand" "n")))]
7013   "TARGET_POWERPC64 && includes_rldicr_lshift_p (operands[2], operands[3])"
7014   "rldicr %0,%1,%H2,%S3"
7015   [(set_attr "type" "shift")])
7016
7017 (define_insn "ashldi3_internal8"
7018   [(set (match_operand:CC 0 "cc_reg_operand" "=x,?y")
7019         (compare:CC
7020          (and:DI (ashift:DI (match_operand:DI 1 "gpc_reg_operand" "r,r")
7021                             (match_operand:SI 2 "const_int_operand" "i,i"))
7022                  (match_operand:DI 3 "mask64_operand" "n,n"))
7023          (const_int 0)))
7024    (clobber (match_scratch:DI 4 "=r,r"))]
7025   "TARGET_64BIT && includes_rldicr_lshift_p (operands[2], operands[3])"
7026   "@
7027    rldicr. %4,%1,%H2,%S3
7028    #"
7029   [(set_attr "type" "shift")
7030    (set_attr "dot" "yes")
7031    (set_attr "length" "4,8")])
7032
7033 (define_split
7034   [(set (match_operand:CC 0 "cc_reg_not_micro_cr0_operand" "")
7035         (compare:CC
7036          (and:DI (ashift:DI (match_operand:DI 1 "gpc_reg_operand" "")
7037                             (match_operand:SI 2 "const_int_operand" ""))
7038                  (match_operand:DI 3 "mask64_operand" ""))
7039          (const_int 0)))
7040    (clobber (match_scratch:DI 4 ""))]
7041   "TARGET_POWERPC64 && reload_completed
7042    && includes_rldicr_lshift_p (operands[2], operands[3])"
7043   [(set (match_dup 4)
7044         (and:DI (ashift:DI (match_dup 1) (match_dup 2))
7045                 (match_dup 3)))
7046    (set (match_dup 0)
7047         (compare:CC (match_dup 4)
7048                     (const_int 0)))]
7049   "")
7050
7051 (define_insn "*ashldi3_internal9"
7052   [(set (match_operand:CC 4 "cc_reg_operand" "=x,?y")
7053         (compare:CC
7054          (and:DI (ashift:DI (match_operand:DI 1 "gpc_reg_operand" "r,r")
7055                             (match_operand:SI 2 "const_int_operand" "i,i"))
7056                     (match_operand:DI 3 "mask64_operand" "n,n"))
7057          (const_int 0)))
7058    (set (match_operand:DI 0 "gpc_reg_operand" "=r,r")
7059         (and:DI (ashift:DI (match_dup 1) (match_dup 2)) (match_dup 3)))]
7060   "TARGET_64BIT && includes_rldicr_lshift_p (operands[2], operands[3])"
7061   "@
7062    rldicr. %0,%1,%H2,%S3
7063    #"
7064   [(set_attr "type" "shift")
7065    (set_attr "dot" "yes")
7066    (set_attr "length" "4,8")])
7067
7068 (define_split
7069   [(set (match_operand:CC 4 "cc_reg_not_micro_cr0_operand" "")
7070         (compare:CC
7071          (and:DI (ashift:DI (match_operand:DI 1 "gpc_reg_operand" "")
7072                             (match_operand:SI 2 "const_int_operand" ""))
7073                  (match_operand:DI 3 "mask64_operand" ""))
7074          (const_int 0)))
7075    (set (match_operand:DI 0 "gpc_reg_operand" "")
7076         (and:DI (ashift:DI (match_dup 1) (match_dup 2)) (match_dup 3)))]
7077   "TARGET_POWERPC64 && reload_completed
7078    && includes_rldicr_lshift_p (operands[2], operands[3])"
7079   [(set (match_dup 0)
7080         (and:DI (ashift:DI (match_dup 1) (match_dup 2))
7081                 (match_dup 3)))
7082    (set (match_dup 4)
7083         (compare:CC (match_dup 0)
7084                     (const_int 0)))]
7085   "")
7086
7087
7088 (define_insn_and_split "*anddi3_2rld"
7089   [(set (match_operand:DI 0 "gpc_reg_operand" "=r")
7090         (and:DI (match_operand:DI 1 "gpc_reg_operand" "%r")
7091                 (match_operand:DI 2 "and_2rld_operand" "n")))]
7092   "TARGET_POWERPC64"
7093   "#"
7094   ""
7095   [(set (match_dup 0)
7096         (and:DI (rotate:DI (match_dup 1)
7097                            (match_dup 4))
7098                 (match_dup 5)))
7099    (set (match_dup 0)
7100         (and:DI (rotate:DI (match_dup 0)
7101                            (match_dup 6))
7102                 (match_dup 7)))]
7103 {
7104   build_mask64_2_operands (operands[2], &operands[4]);
7105 }
7106   [(set_attr "length" "8")])
7107
7108 (define_insn_and_split "*anddi3_2rld_dot"
7109   [(set (match_operand:CC 3 "cc_reg_operand" "=x,?y")
7110         (compare:CC (and:DI (match_operand:DI 1 "gpc_reg_operand" "%r,r")
7111                             (match_operand:DI 2 "and_2rld_operand" "n,n"))
7112                     (const_int 0)))
7113    (clobber (match_scratch:DI 0 "=r,r"))]
7114   "TARGET_64BIT && rs6000_gen_cell_microcode"
7115   "@
7116    #
7117    #"
7118   "&& reload_completed"
7119   [(set (match_dup 0)
7120         (and:DI (rotate:DI (match_dup 1)
7121                            (match_dup 4))
7122                 (match_dup 5)))
7123    (parallel [(set (match_dup 3)
7124                    (compare:CC (and:DI (rotate:DI (match_dup 0)
7125                                                   (match_dup 6))
7126                                        (match_dup 7))
7127                                (const_int 0)))
7128               (clobber (match_dup 0))])]
7129 {
7130   build_mask64_2_operands (operands[2], &operands[4]);
7131 }
7132   [(set_attr "type" "compare")
7133    (set_attr "dot" "yes")
7134    (set_attr "length" "8,12")])
7135
7136 (define_insn_and_split "*anddi3_2rld_dot2"
7137   [(set (match_operand:CC 3 "cc_reg_operand" "=x,?y")
7138         (compare:CC (and:DI (match_operand:DI 1 "gpc_reg_operand" "%r,r")
7139                             (match_operand:DI 2 "and_2rld_operand" "n,n"))
7140                     (const_int 0)))
7141    (set (match_operand:DI 0 "gpc_reg_operand" "=r,r")
7142         (and:DI (match_dup 1)
7143                 (match_dup 2)))]
7144   "TARGET_64BIT && rs6000_gen_cell_microcode"
7145   "@
7146    #
7147    #"
7148   "&& reload_completed"
7149   [(set (match_dup 0)
7150         (and:DI (rotate:DI (match_dup 1)
7151                            (match_dup 4))
7152                 (match_dup 5)))
7153    (parallel [(set (match_dup 3)
7154                    (compare:CC (and:DI (rotate:DI (match_dup 0)
7155                                                   (match_dup 6))
7156                                        (match_dup 7))
7157                                (const_int 0)))
7158               (set (match_dup 0)
7159                    (and:DI (rotate:DI (match_dup 0)
7160                                       (match_dup 6))
7161                            (match_dup 7)))])]
7162 {
7163   build_mask64_2_operands (operands[2], &operands[4]);
7164 }
7165   [(set_attr "type" "compare")
7166    (set_attr "dot" "yes")
7167    (set_attr "length" "8,12")])
7168 \f
7169 ;; 128-bit logical operations expanders
7170
7171 (define_expand "and<mode>3"
7172   [(set (match_operand:BOOL_128 0 "vlogical_operand" "")
7173         (and:BOOL_128 (match_operand:BOOL_128 1 "vlogical_operand" "")
7174                       (match_operand:BOOL_128 2 "vlogical_operand" "")))]
7175   ""
7176   "")
7177
7178 (define_expand "ior<mode>3"
7179   [(set (match_operand:BOOL_128 0 "vlogical_operand" "")
7180         (ior:BOOL_128 (match_operand:BOOL_128 1 "vlogical_operand" "")
7181                       (match_operand:BOOL_128 2 "vlogical_operand" "")))]
7182   ""
7183   "")
7184
7185 (define_expand "xor<mode>3"
7186   [(set (match_operand:BOOL_128 0 "vlogical_operand" "")
7187         (xor:BOOL_128 (match_operand:BOOL_128 1 "vlogical_operand" "")
7188                       (match_operand:BOOL_128 2 "vlogical_operand" "")))]
7189   ""
7190   "")
7191
7192 (define_expand "one_cmpl<mode>2"
7193   [(set (match_operand:BOOL_128 0 "vlogical_operand" "")
7194         (not:BOOL_128 (match_operand:BOOL_128 1 "vlogical_operand" "")))]
7195   ""
7196   "")
7197
7198 (define_expand "nor<mode>3"
7199   [(set (match_operand:BOOL_128 0 "vlogical_operand" "")
7200         (and:BOOL_128
7201          (not:BOOL_128 (match_operand:BOOL_128 1 "vlogical_operand" ""))
7202          (not:BOOL_128 (match_operand:BOOL_128 2 "vlogical_operand" ""))))]
7203   ""
7204   "")
7205
7206 (define_expand "andc<mode>3"
7207   [(set (match_operand:BOOL_128 0 "vlogical_operand" "")
7208         (and:BOOL_128
7209          (not:BOOL_128 (match_operand:BOOL_128 2 "vlogical_operand" ""))
7210          (match_operand:BOOL_128 1 "vlogical_operand" "")))]
7211   ""
7212   "")
7213
7214 ;; Power8 vector logical instructions.
7215 (define_expand "eqv<mode>3"
7216   [(set (match_operand:BOOL_128 0 "vlogical_operand" "")
7217         (not:BOOL_128
7218          (xor:BOOL_128 (match_operand:BOOL_128 1 "vlogical_operand" "")
7219                        (match_operand:BOOL_128 2 "vlogical_operand" ""))))]
7220   "<MODE>mode == TImode || <MODE>mode == PTImode || TARGET_P8_VECTOR"
7221   "")
7222
7223 ;; Rewrite nand into canonical form
7224 (define_expand "nand<mode>3"
7225   [(set (match_operand:BOOL_128 0 "vlogical_operand" "")
7226         (ior:BOOL_128
7227          (not:BOOL_128 (match_operand:BOOL_128 1 "vlogical_operand" ""))
7228          (not:BOOL_128 (match_operand:BOOL_128 2 "vlogical_operand" ""))))]
7229   "<MODE>mode == TImode || <MODE>mode == PTImode || TARGET_P8_VECTOR"
7230   "")
7231
7232 ;; The canonical form is to have the negated element first, so we need to
7233 ;; reverse arguments.
7234 (define_expand "orc<mode>3"
7235   [(set (match_operand:BOOL_128 0 "vlogical_operand" "")
7236         (ior:BOOL_128
7237          (not:BOOL_128 (match_operand:BOOL_128 2 "vlogical_operand" ""))
7238          (match_operand:BOOL_128 1 "vlogical_operand" "")))]
7239   "<MODE>mode == TImode || <MODE>mode == PTImode || TARGET_P8_VECTOR"
7240   "")
7241
7242 ;; 128-bit logical operations insns and split operations
7243 (define_insn_and_split "*and<mode>3_internal"
7244   [(set (match_operand:BOOL_128 0 "vlogical_operand" "=<BOOL_REGS_OUTPUT>")
7245         (and:BOOL_128
7246          (match_operand:BOOL_128 1 "vlogical_operand" "%<BOOL_REGS_OP1>")
7247          (match_operand:BOOL_128 2 "vlogical_operand" "<BOOL_REGS_OP2>")))]
7248   ""
7249 {
7250   if (TARGET_VSX && vsx_register_operand (operands[0], <MODE>mode))
7251     return "xxland %x0,%x1,%x2";
7252
7253   if (TARGET_ALTIVEC && altivec_register_operand (operands[0], <MODE>mode))
7254     return "vand %0,%1,%2";
7255
7256   return "#";
7257 }
7258   "reload_completed && int_reg_operand (operands[0], <MODE>mode)"
7259   [(const_int 0)]
7260 {
7261   rs6000_split_logical (operands, AND, false, false, false);
7262   DONE;
7263 }
7264   [(set (attr "type")
7265       (if_then_else
7266         (match_test "vsx_register_operand (operands[0], <MODE>mode)")
7267         (const_string "vecsimple")
7268         (const_string "integer")))
7269    (set (attr "length")
7270       (if_then_else
7271         (match_test "vsx_register_operand (operands[0], <MODE>mode)")
7272         (const_string "4")
7273         (if_then_else
7274          (match_test "TARGET_POWERPC64")
7275          (const_string "8")
7276          (const_string "16"))))])
7277
7278 ;; 128-bit IOR/XOR
7279 (define_insn_and_split "*bool<mode>3_internal"
7280   [(set (match_operand:BOOL_128 0 "vlogical_operand" "=<BOOL_REGS_OUTPUT>")
7281         (match_operator:BOOL_128 3 "boolean_or_operator"
7282          [(match_operand:BOOL_128 1 "vlogical_operand" "%<BOOL_REGS_OP1>")
7283           (match_operand:BOOL_128 2 "vlogical_operand" "<BOOL_REGS_OP2>")]))]
7284   ""
7285 {
7286   if (TARGET_VSX && vsx_register_operand (operands[0], <MODE>mode))
7287     return "xxl%q3 %x0,%x1,%x2";
7288
7289   if (TARGET_ALTIVEC && altivec_register_operand (operands[0], <MODE>mode))
7290     return "v%q3 %0,%1,%2";
7291
7292   return "#";
7293 }
7294   "reload_completed && int_reg_operand (operands[0], <MODE>mode)"
7295   [(const_int 0)]
7296 {
7297   rs6000_split_logical (operands, GET_CODE (operands[3]), false, false, false);
7298   DONE;
7299 }
7300   [(set (attr "type")
7301       (if_then_else
7302         (match_test "vsx_register_operand (operands[0], <MODE>mode)")
7303         (const_string "vecsimple")
7304         (const_string "integer")))
7305    (set (attr "length")
7306       (if_then_else
7307         (match_test "vsx_register_operand (operands[0], <MODE>mode)")
7308         (const_string "4")
7309         (if_then_else
7310          (match_test "TARGET_POWERPC64")
7311          (const_string "8")
7312          (const_string "16"))))])
7313
7314 ;; 128-bit ANDC/ORC
7315 (define_insn_and_split "*boolc<mode>3_internal1"
7316   [(set (match_operand:BOOL_128 0 "vlogical_operand" "=<BOOL_REGS_OUTPUT>")
7317         (match_operator:BOOL_128 3 "boolean_operator"
7318          [(not:BOOL_128
7319            (match_operand:BOOL_128 2 "vlogical_operand" "<BOOL_REGS_OP1>"))
7320           (match_operand:BOOL_128 1 "vlogical_operand" "<BOOL_REGS_OP2>")]))]
7321   "TARGET_P8_VECTOR || (GET_CODE (operands[3]) == AND)"
7322 {
7323   if (TARGET_VSX && vsx_register_operand (operands[0], <MODE>mode))
7324     return "xxl%q3 %x0,%x1,%x2";
7325
7326   if (TARGET_ALTIVEC && altivec_register_operand (operands[0], <MODE>mode))
7327     return "v%q3 %0,%1,%2";
7328
7329   return "#";
7330 }
7331   "(TARGET_P8_VECTOR || (GET_CODE (operands[3]) == AND))
7332    && reload_completed && int_reg_operand (operands[0], <MODE>mode)"
7333   [(const_int 0)]
7334 {
7335   rs6000_split_logical (operands, GET_CODE (operands[3]), false, true, false);
7336   DONE;
7337 }
7338   [(set (attr "type")
7339       (if_then_else
7340         (match_test "vsx_register_operand (operands[0], <MODE>mode)")
7341         (const_string "vecsimple")
7342         (const_string "integer")))
7343    (set (attr "length")
7344       (if_then_else
7345         (match_test "vsx_register_operand (operands[0], <MODE>mode)")
7346         (const_string "4")
7347         (if_then_else
7348          (match_test "TARGET_POWERPC64")
7349          (const_string "8")
7350          (const_string "16"))))])
7351
7352 (define_insn_and_split "*boolc<mode>3_internal2"
7353   [(set (match_operand:TI2 0 "int_reg_operand" "=&r,r,r")
7354         (match_operator:TI2 3 "boolean_operator"
7355          [(not:TI2
7356            (match_operand:TI2 1 "int_reg_operand" "r,0,r"))
7357           (match_operand:TI2 2 "int_reg_operand" "r,r,0")]))]
7358   "!TARGET_P8_VECTOR && (GET_CODE (operands[3]) != AND)"
7359   "#"
7360   "reload_completed && !TARGET_P8_VECTOR && (GET_CODE (operands[3]) != AND)"
7361   [(const_int 0)]
7362 {
7363   rs6000_split_logical (operands, GET_CODE (operands[3]), false, true, false);
7364   DONE;
7365 }
7366   [(set_attr "type" "integer")
7367    (set (attr "length")
7368         (if_then_else
7369          (match_test "TARGET_POWERPC64")
7370          (const_string "8")
7371          (const_string "16")))])
7372
7373 ;; 128-bit NAND/NOR
7374 (define_insn_and_split "*boolcc<mode>3_internal1"
7375   [(set (match_operand:BOOL_128 0 "vlogical_operand" "=<BOOL_REGS_OUTPUT>")
7376         (match_operator:BOOL_128 3 "boolean_operator"
7377          [(not:BOOL_128
7378            (match_operand:BOOL_128 1 "vlogical_operand" "<BOOL_REGS_OP1>"))
7379           (not:BOOL_128
7380            (match_operand:BOOL_128 2 "vlogical_operand" "<BOOL_REGS_OP2>"))]))]
7381   "TARGET_P8_VECTOR || (GET_CODE (operands[3]) == AND)"
7382 {
7383   if (TARGET_VSX && vsx_register_operand (operands[0], <MODE>mode))
7384     return "xxl%q3 %x0,%x1,%x2";
7385
7386   if (TARGET_ALTIVEC && altivec_register_operand (operands[0], <MODE>mode))
7387     return "v%q3 %0,%1,%2";
7388
7389   return "#";
7390 }
7391   "(TARGET_P8_VECTOR || (GET_CODE (operands[3]) == AND))
7392    && reload_completed && int_reg_operand (operands[0], <MODE>mode)"
7393   [(const_int 0)]
7394 {
7395   rs6000_split_logical (operands, GET_CODE (operands[3]), false, true, true);
7396   DONE;
7397 }
7398   [(set (attr "type")
7399       (if_then_else
7400         (match_test "vsx_register_operand (operands[0], <MODE>mode)")
7401         (const_string "vecsimple")
7402         (const_string "integer")))
7403    (set (attr "length")
7404       (if_then_else
7405         (match_test "vsx_register_operand (operands[0], <MODE>mode)")
7406         (const_string "4")
7407         (if_then_else
7408          (match_test "TARGET_POWERPC64")
7409          (const_string "8")
7410          (const_string "16"))))])
7411
7412 (define_insn_and_split "*boolcc<mode>3_internal2"
7413   [(set (match_operand:TI2 0 "int_reg_operand" "=&r,r,r")
7414         (match_operator:TI2 3 "boolean_operator"
7415          [(not:TI2
7416            (match_operand:TI2 1 "int_reg_operand" "r,0,r"))
7417           (not:TI2
7418            (match_operand:TI2 2 "int_reg_operand" "r,r,0"))]))]
7419   "!TARGET_P8_VECTOR && (GET_CODE (operands[3]) != AND)"
7420   "#"
7421   "reload_completed && !TARGET_P8_VECTOR && (GET_CODE (operands[3]) != AND)"
7422   [(const_int 0)]
7423 {
7424   rs6000_split_logical (operands, GET_CODE (operands[3]), false, true, true);
7425   DONE;
7426 }
7427   [(set_attr "type" "integer")
7428    (set (attr "length")
7429         (if_then_else
7430          (match_test "TARGET_POWERPC64")
7431          (const_string "8")
7432          (const_string "16")))])
7433
7434
7435 ;; 128-bit EQV
7436 (define_insn_and_split "*eqv<mode>3_internal1"
7437   [(set (match_operand:BOOL_128 0 "vlogical_operand" "=<BOOL_REGS_OUTPUT>")
7438         (not:BOOL_128
7439          (xor:BOOL_128
7440           (match_operand:BOOL_128 1 "vlogical_operand" "<BOOL_REGS_OP1>")
7441           (match_operand:BOOL_128 2 "vlogical_operand" "<BOOL_REGS_OP2>"))))]
7442   "TARGET_P8_VECTOR"
7443 {
7444   if (vsx_register_operand (operands[0], <MODE>mode))
7445     return "xxleqv %x0,%x1,%x2";
7446
7447   return "#";
7448 }
7449   "TARGET_P8_VECTOR && reload_completed
7450    && int_reg_operand (operands[0], <MODE>mode)"
7451   [(const_int 0)]
7452 {
7453   rs6000_split_logical (operands, XOR, true, false, false);
7454   DONE;
7455 }
7456   [(set (attr "type")
7457       (if_then_else
7458         (match_test "vsx_register_operand (operands[0], <MODE>mode)")
7459         (const_string "vecsimple")
7460         (const_string "integer")))
7461    (set (attr "length")
7462       (if_then_else
7463         (match_test "vsx_register_operand (operands[0], <MODE>mode)")
7464         (const_string "4")
7465         (if_then_else
7466          (match_test "TARGET_POWERPC64")
7467          (const_string "8")
7468          (const_string "16"))))])
7469
7470 (define_insn_and_split "*eqv<mode>3_internal2"
7471   [(set (match_operand:TI2 0 "int_reg_operand" "=&r,r,r")
7472         (not:TI2
7473          (xor:TI2
7474           (match_operand:TI2 1 "int_reg_operand" "r,0,r")
7475           (match_operand:TI2 2 "int_reg_operand" "r,r,0"))))]
7476   "!TARGET_P8_VECTOR"
7477   "#"
7478   "reload_completed && !TARGET_P8_VECTOR"
7479   [(const_int 0)]
7480 {
7481   rs6000_split_logical (operands, XOR, true, false, false);
7482   DONE;
7483 }
7484   [(set_attr "type" "integer")
7485    (set (attr "length")
7486         (if_then_else
7487          (match_test "TARGET_POWERPC64")
7488          (const_string "8")
7489          (const_string "16")))])
7490
7491 ;; 128-bit one's complement
7492 (define_insn_and_split "*one_cmpl<mode>3_internal"
7493   [(set (match_operand:BOOL_128 0 "vlogical_operand" "=<BOOL_REGS_OUTPUT>")
7494         (not:BOOL_128
7495           (match_operand:BOOL_128 1 "vlogical_operand" "<BOOL_REGS_UNARY>")))]
7496   ""
7497 {
7498   if (TARGET_VSX && vsx_register_operand (operands[0], <MODE>mode))
7499     return "xxlnor %x0,%x1,%x1";
7500
7501   if (TARGET_ALTIVEC && altivec_register_operand (operands[0], <MODE>mode))
7502     return "vnor %0,%1,%1";
7503
7504   return "#";
7505 }
7506   "reload_completed && int_reg_operand (operands[0], <MODE>mode)"
7507   [(const_int 0)]
7508 {
7509   rs6000_split_logical (operands, NOT, false, false, false);
7510   DONE;
7511 }
7512   [(set (attr "type")
7513       (if_then_else
7514         (match_test "vsx_register_operand (operands[0], <MODE>mode)")
7515         (const_string "vecsimple")
7516         (const_string "integer")))
7517    (set (attr "length")
7518       (if_then_else
7519         (match_test "vsx_register_operand (operands[0], <MODE>mode)")
7520         (const_string "4")
7521         (if_then_else
7522          (match_test "TARGET_POWERPC64")
7523          (const_string "8")
7524          (const_string "16"))))])
7525
7526 \f
7527 ;; Now define ways of moving data around.
7528
7529 ;; Set up a register with a value from the GOT table
7530
7531 (define_expand "movsi_got"
7532   [(set (match_operand:SI 0 "gpc_reg_operand" "")
7533         (unspec:SI [(match_operand:SI 1 "got_operand" "")
7534                     (match_dup 2)] UNSPEC_MOVSI_GOT))]
7535   "DEFAULT_ABI == ABI_V4 && flag_pic == 1"
7536   "
7537 {
7538   if (GET_CODE (operands[1]) == CONST)
7539     {
7540       rtx offset = const0_rtx;
7541       HOST_WIDE_INT value;
7542
7543       operands[1] = eliminate_constant_term (XEXP (operands[1], 0), &offset);
7544       value = INTVAL (offset);
7545       if (value != 0)
7546         {
7547           rtx tmp = (!can_create_pseudo_p ()
7548                      ? operands[0]
7549                      : gen_reg_rtx (Pmode));
7550           emit_insn (gen_movsi_got (tmp, operands[1]));
7551           emit_insn (gen_addsi3 (operands[0], tmp, offset));
7552           DONE;
7553         }
7554     }
7555
7556   operands[2] = rs6000_got_register (operands[1]);
7557 }")
7558
7559 (define_insn "*movsi_got_internal"
7560   [(set (match_operand:SI 0 "gpc_reg_operand" "=r")
7561         (unspec:SI [(match_operand:SI 1 "got_no_const_operand" "")
7562                     (match_operand:SI 2 "gpc_reg_operand" "b")]
7563                    UNSPEC_MOVSI_GOT))]
7564   "DEFAULT_ABI == ABI_V4 && flag_pic == 1"
7565   "lwz %0,%a1@got(%2)"
7566   [(set_attr "type" "load")])
7567
7568 ;; Used by sched, shorten_branches and final when the GOT pseudo reg
7569 ;; didn't get allocated to a hard register.
7570 (define_split
7571   [(set (match_operand:SI 0 "gpc_reg_operand" "")
7572         (unspec:SI [(match_operand:SI 1 "got_no_const_operand" "")
7573                     (match_operand:SI 2 "memory_operand" "")]
7574                    UNSPEC_MOVSI_GOT))]
7575   "DEFAULT_ABI == ABI_V4
7576     && flag_pic == 1
7577     && (reload_in_progress || reload_completed)"
7578   [(set (match_dup 0) (match_dup 2))
7579    (set (match_dup 0) (unspec:SI [(match_dup 1)(match_dup 0)]
7580                                  UNSPEC_MOVSI_GOT))]
7581   "")
7582
7583 ;; For SI, we special-case integers that can't be loaded in one insn.  We
7584 ;; do the load 16-bits at a time.  We could do this by loading from memory,
7585 ;; and this is even supposed to be faster, but it is simpler not to get
7586 ;; integers in the TOC.
7587 (define_insn "movsi_low"
7588   [(set (match_operand:SI 0 "gpc_reg_operand" "=r")
7589         (mem:SI (lo_sum:SI (match_operand:SI 1 "gpc_reg_operand" "b")
7590                            (match_operand 2 "" ""))))]
7591   "TARGET_MACHO && ! TARGET_64BIT"
7592   "lwz %0,lo16(%2)(%1)"
7593   [(set_attr "type" "load")
7594    (set_attr "length" "4")])
7595
7596 (define_insn "*movsi_internal1"
7597   [(set (match_operand:SI 0 "rs6000_nonimmediate_operand" "=r,r,r,m,r,r,r,r,*c*l,*h,*h")
7598         (match_operand:SI 1 "input_operand" "r,U,m,r,I,L,n,*h,r,r,0"))]
7599   "!TARGET_SINGLE_FPU &&
7600    (gpc_reg_operand (operands[0], SImode) || gpc_reg_operand (operands[1], SImode))"
7601   "@
7602    mr %0,%1
7603    la %0,%a1
7604    lwz%U1%X1 %0,%1
7605    stw%U0%X0 %1,%0
7606    li %0,%1
7607    lis %0,%v1
7608    #
7609    mf%1 %0
7610    mt%0 %1
7611    mt%0 %1
7612    nop"
7613   [(set_attr "type" "*,*,load,store,*,*,*,mfjmpr,mtjmpr,*,*")
7614    (set_attr "length" "4,4,4,4,4,4,8,4,4,4,4")])
7615
7616 (define_insn "*movsi_internal1_single"
7617   [(set (match_operand:SI 0 "rs6000_nonimmediate_operand" "=r,r,r,m,r,r,r,r,*c*l,*h,*h,m,*f")
7618         (match_operand:SI 1 "input_operand" "r,U,m,r,I,L,n,*h,r,r,0,f,m"))]
7619   "TARGET_SINGLE_FPU &&
7620    (gpc_reg_operand (operands[0], SImode) || gpc_reg_operand (operands[1], SImode))"
7621   "@
7622    mr %0,%1
7623    la %0,%a1
7624    lwz%U1%X1 %0,%1
7625    stw%U0%X0 %1,%0
7626    li %0,%1
7627    lis %0,%v1
7628    #
7629    mf%1 %0
7630    mt%0 %1
7631    mt%0 %1
7632    nop
7633    stfs%U0%X0 %1,%0
7634    lfs%U1%X1 %0,%1"
7635   [(set_attr "type" "*,*,load,store,*,*,*,mfjmpr,mtjmpr,*,*,fpstore,fpload")
7636    (set_attr "length" "4,4,4,4,4,4,8,4,4,4,4,4,4")])
7637
7638 ;; Split a load of a large constant into the appropriate two-insn
7639 ;; sequence.
7640
7641 (define_split
7642   [(set (match_operand:SI 0 "gpc_reg_operand" "")
7643         (match_operand:SI 1 "const_int_operand" ""))]
7644   "(unsigned HOST_WIDE_INT) (INTVAL (operands[1]) + 0x8000) >= 0x10000
7645    && (INTVAL (operands[1]) & 0xffff) != 0"
7646   [(set (match_dup 0)
7647         (match_dup 2))
7648    (set (match_dup 0)
7649         (ior:SI (match_dup 0)
7650                 (match_dup 3)))]
7651   "
7652 {
7653   if (rs6000_emit_set_const (operands[0], operands[1]))
7654     DONE;
7655   else
7656     FAIL;
7657 }")
7658
7659 (define_insn "*mov<mode>_internal2"
7660   [(set (match_operand:CC 2 "cc_reg_operand" "=y,x,?y")
7661         (compare:CC (match_operand:P 1 "gpc_reg_operand" "0,r,r")
7662                     (const_int 0)))
7663    (set (match_operand:P 0 "gpc_reg_operand" "=r,r,r") (match_dup 1))]
7664   ""
7665   "@
7666    cmp<wd>i %2,%0,0
7667    mr. %0,%1
7668    #"
7669   [(set_attr "type" "cmp,logical,cmp")
7670    (set_attr "dot" "yes")
7671    (set_attr "length" "4,4,8")])
7672
7673 (define_split
7674   [(set (match_operand:CC 2 "cc_reg_not_micro_cr0_operand" "")
7675         (compare:CC (match_operand:P 1 "gpc_reg_operand" "")
7676                     (const_int 0)))
7677    (set (match_operand:P 0 "gpc_reg_operand" "") (match_dup 1))]
7678   "reload_completed"
7679   [(set (match_dup 0) (match_dup 1))
7680    (set (match_dup 2)
7681         (compare:CC (match_dup 0)
7682                     (const_int 0)))]
7683   "")
7684 \f
7685 (define_insn "*movhi_internal"
7686   [(set (match_operand:HI 0 "nonimmediate_operand" "=r,r,m,r,r,*c*l,*h")
7687         (match_operand:HI 1 "input_operand" "r,m,r,i,*h,r,0"))]
7688   "gpc_reg_operand (operands[0], HImode)
7689    || gpc_reg_operand (operands[1], HImode)"
7690   "@
7691    mr %0,%1
7692    lhz%U1%X1 %0,%1
7693    sth%U0%X0 %1,%0
7694    li %0,%w1
7695    mf%1 %0
7696    mt%0 %1
7697    nop"
7698   [(set_attr "type" "*,load,store,*,mfjmpr,mtjmpr,*")])
7699
7700 (define_expand "mov<mode>"
7701   [(set (match_operand:INT 0 "general_operand" "")
7702         (match_operand:INT 1 "any_operand" ""))]
7703   ""
7704   "{ rs6000_emit_move (operands[0], operands[1], <MODE>mode); DONE; }")
7705
7706 (define_insn "*movqi_internal"
7707   [(set (match_operand:QI 0 "nonimmediate_operand" "=r,r,m,r,r,*c*l,*h")
7708         (match_operand:QI 1 "input_operand" "r,m,r,i,*h,r,0"))]
7709   "gpc_reg_operand (operands[0], QImode)
7710    || gpc_reg_operand (operands[1], QImode)"
7711   "@
7712    mr %0,%1
7713    lbz%U1%X1 %0,%1
7714    stb%U0%X0 %1,%0
7715    li %0,%1
7716    mf%1 %0
7717    mt%0 %1
7718    nop"
7719   [(set_attr "type" "*,load,store,*,mfjmpr,mtjmpr,*")])
7720 \f
7721 ;; Here is how to move condition codes around.  When we store CC data in
7722 ;; an integer register or memory, we store just the high-order 4 bits.
7723 ;; This lets us not shift in the most common case of CR0.
7724 (define_expand "movcc"
7725   [(set (match_operand:CC 0 "nonimmediate_operand" "")
7726         (match_operand:CC 1 "nonimmediate_operand" ""))]
7727   ""
7728   "")
7729
7730 (define_insn "*movcc_internal1"
7731   [(set (match_operand:CC 0 "nonimmediate_operand" "=y,x,?y,y,r,r,r,r,r,cl,r,m")
7732         (match_operand:CC 1 "general_operand" "y,r,r,O,x,y,r,I,h,r,m,r"))]
7733   "register_operand (operands[0], CCmode)
7734    || register_operand (operands[1], CCmode)"
7735   "@
7736    mcrf %0,%1
7737    mtcrf 128,%1
7738    rlwinm %1,%1,%F0,0xffffffff\;mtcrf %R0,%1\;rlwinm %1,%1,%f0,0xffffffff
7739    crxor %0,%0,%0
7740    mfcr %0%Q1
7741    mfcr %0%Q1\;rlwinm %0,%0,%f1,0xf0000000
7742    mr %0,%1
7743    li %0,%1
7744    mf%1 %0
7745    mt%0 %1
7746    lwz%U1%X1 %0,%1
7747    stw%U0%X0 %1,%0"
7748   [(set (attr "type")
7749      (cond [(eq_attr "alternative" "0,3")
7750                 (const_string "cr_logical")
7751             (eq_attr "alternative" "1,2")
7752                 (const_string "mtcr")
7753             (eq_attr "alternative" "6,7")
7754                 (const_string "integer")
7755             (eq_attr "alternative" "8")
7756                 (const_string "mfjmpr")
7757             (eq_attr "alternative" "9")
7758                 (const_string "mtjmpr")
7759             (eq_attr "alternative" "10")
7760                 (const_string "load")
7761             (eq_attr "alternative" "11")
7762                 (const_string "store")
7763             (match_test "TARGET_MFCRF")
7764                 (const_string "mfcrf")
7765            ]
7766         (const_string "mfcr")))
7767    (set_attr "length" "4,4,12,4,4,8,4,4,4,4,4,4")])
7768 \f
7769 ;; For floating-point, we normally deal with the floating-point registers
7770 ;; unless -msoft-float is used.  The sole exception is that parameter passing
7771 ;; can produce floating-point values in fixed-point registers.  Unless the
7772 ;; value is a simple constant or already in memory, we deal with this by
7773 ;; allocating memory and copying the value explicitly via that memory location.
7774
7775 ;; Move 32-bit binary/decimal floating point
7776 (define_expand "mov<mode>"
7777   [(set (match_operand:FMOVE32 0 "nonimmediate_operand" "")
7778         (match_operand:FMOVE32 1 "any_operand" ""))]
7779   "<fmove_ok>"
7780   "{ rs6000_emit_move (operands[0], operands[1], <MODE>mode); DONE; }")
7781
7782 (define_split
7783   [(set (match_operand:FMOVE32 0 "gpc_reg_operand" "")
7784         (match_operand:FMOVE32 1 "const_double_operand" ""))]
7785   "reload_completed
7786    && ((GET_CODE (operands[0]) == REG && REGNO (operands[0]) <= 31)
7787        || (GET_CODE (operands[0]) == SUBREG
7788            && GET_CODE (SUBREG_REG (operands[0])) == REG
7789            && REGNO (SUBREG_REG (operands[0])) <= 31))"
7790   [(set (match_dup 2) (match_dup 3))]
7791   "
7792 {
7793   long l;
7794   REAL_VALUE_TYPE rv;
7795
7796   REAL_VALUE_FROM_CONST_DOUBLE (rv, operands[1]);
7797   <real_value_to_target> (rv, l);
7798
7799   if (! TARGET_POWERPC64)
7800     operands[2] = operand_subword (operands[0], 0, 0, <MODE>mode);
7801   else
7802     operands[2] = gen_lowpart (SImode, operands[0]);
7803
7804   operands[3] = gen_int_mode (l, SImode);
7805 }")
7806
7807 (define_insn "mov<mode>_hardfloat"
7808   [(set (match_operand:FMOVE32 0 "nonimmediate_operand" "=!r,!r,m,f,wa,wa,<f32_lr>,<f32_sm>,wu,Z,?<f32_dm>,?r,*c*l,!r,*h,!r,!r")
7809         (match_operand:FMOVE32 1 "input_operand" "r,m,r,f,wa,j,<f32_lm>,<f32_sr>,Z,wu,r,<f32_dm>,r,h,0,G,Fn"))]
7810   "(gpc_reg_operand (operands[0], <MODE>mode)
7811    || gpc_reg_operand (operands[1], <MODE>mode))
7812    && (TARGET_HARD_FLOAT && TARGET_FPRS && TARGET_SINGLE_FLOAT)"
7813   "@
7814    mr %0,%1
7815    lwz%U1%X1 %0,%1
7816    stw%U0%X0 %1,%0
7817    fmr %0,%1
7818    xxlor %x0,%x1,%x1
7819    xxlxor %x0,%x0,%x0
7820    <f32_li>
7821    <f32_si>
7822    <f32_lv>
7823    <f32_sv>
7824    mtvsrwz %x0,%1
7825    mfvsrwz %0,%x1
7826    mt%0 %1
7827    mf%1 %0
7828    nop
7829    #
7830    #"
7831   [(set_attr "type" "*,load,store,fp,vecsimple,vecsimple,fpload,fpstore,fpload,fpstore,mftgpr,mffgpr,mtjmpr,mfjmpr,*,*,*")
7832    (set_attr "length" "4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,8")])
7833
7834 (define_insn "*mov<mode>_softfloat"
7835   [(set (match_operand:FMOVE32 0 "nonimmediate_operand" "=r,cl,r,r,m,r,r,r,r,*h")
7836         (match_operand:FMOVE32 1 "input_operand" "r,r,h,m,r,I,L,G,Fn,0"))]
7837   "(gpc_reg_operand (operands[0], <MODE>mode)
7838    || gpc_reg_operand (operands[1], <MODE>mode))
7839    && (TARGET_SOFT_FLOAT || !TARGET_FPRS)"
7840   "@
7841    mr %0,%1
7842    mt%0 %1
7843    mf%1 %0
7844    lwz%U1%X1 %0,%1
7845    stw%U0%X0 %1,%0
7846    li %0,%1
7847    lis %0,%v1
7848    #
7849    #
7850    nop"
7851   [(set_attr "type" "*,mtjmpr,mfjmpr,load,store,*,*,*,*,*")
7852    (set_attr "length" "4,4,4,4,4,4,4,4,8,4")])
7853
7854 \f
7855 ;; Move 64-bit binary/decimal floating point
7856 (define_expand "mov<mode>"
7857   [(set (match_operand:FMOVE64 0 "nonimmediate_operand" "")
7858         (match_operand:FMOVE64 1 "any_operand" ""))]
7859   ""
7860   "{ rs6000_emit_move (operands[0], operands[1], <MODE>mode); DONE; }")
7861
7862 (define_split
7863   [(set (match_operand:FMOVE64 0 "gpc_reg_operand" "")
7864         (match_operand:FMOVE64 1 "const_int_operand" ""))]
7865   "! TARGET_POWERPC64 && reload_completed
7866    && ((GET_CODE (operands[0]) == REG && REGNO (operands[0]) <= 31)
7867        || (GET_CODE (operands[0]) == SUBREG
7868            && GET_CODE (SUBREG_REG (operands[0])) == REG
7869            && REGNO (SUBREG_REG (operands[0])) <= 31))"
7870   [(set (match_dup 2) (match_dup 4))
7871    (set (match_dup 3) (match_dup 1))]
7872   "
7873 {
7874   int endian = (WORDS_BIG_ENDIAN == 0);
7875   HOST_WIDE_INT value = INTVAL (operands[1]);
7876
7877   operands[2] = operand_subword (operands[0], endian, 0, <MODE>mode);
7878   operands[3] = operand_subword (operands[0], 1 - endian, 0, <MODE>mode);
7879   operands[4] = GEN_INT (value >> 32);
7880   operands[1] = GEN_INT (((value & 0xffffffff) ^ 0x80000000) - 0x80000000);
7881 }")
7882
7883 (define_split
7884   [(set (match_operand:FMOVE64 0 "gpc_reg_operand" "")
7885         (match_operand:FMOVE64 1 "const_double_operand" ""))]
7886   "! TARGET_POWERPC64 && reload_completed
7887    && ((GET_CODE (operands[0]) == REG && REGNO (operands[0]) <= 31)
7888        || (GET_CODE (operands[0]) == SUBREG
7889            && GET_CODE (SUBREG_REG (operands[0])) == REG
7890            && REGNO (SUBREG_REG (operands[0])) <= 31))"
7891   [(set (match_dup 2) (match_dup 4))
7892    (set (match_dup 3) (match_dup 5))]
7893   "
7894 {
7895   int endian = (WORDS_BIG_ENDIAN == 0);
7896   long l[2];
7897   REAL_VALUE_TYPE rv;
7898
7899   REAL_VALUE_FROM_CONST_DOUBLE (rv, operands[1]);
7900   <real_value_to_target> (rv, l);
7901
7902   operands[2] = operand_subword (operands[0], endian, 0, <MODE>mode);
7903   operands[3] = operand_subword (operands[0], 1 - endian, 0, <MODE>mode);
7904   operands[4] = gen_int_mode (l[endian], SImode);
7905   operands[5] = gen_int_mode (l[1 - endian], SImode);
7906 }")
7907
7908 (define_split
7909   [(set (match_operand:FMOVE64 0 "gpc_reg_operand" "")
7910         (match_operand:FMOVE64 1 "const_double_operand" ""))]
7911   "TARGET_POWERPC64 && reload_completed
7912    && ((GET_CODE (operands[0]) == REG && REGNO (operands[0]) <= 31)
7913        || (GET_CODE (operands[0]) == SUBREG
7914            && GET_CODE (SUBREG_REG (operands[0])) == REG
7915            && REGNO (SUBREG_REG (operands[0])) <= 31))"
7916   [(set (match_dup 2) (match_dup 3))]
7917   "
7918 {
7919   int endian = (WORDS_BIG_ENDIAN == 0);
7920   long l[2];
7921   REAL_VALUE_TYPE rv;
7922   HOST_WIDE_INT val;
7923
7924   REAL_VALUE_FROM_CONST_DOUBLE (rv, operands[1]);
7925   <real_value_to_target> (rv, l);
7926
7927   operands[2] = gen_lowpart (DImode, operands[0]);
7928   /* HIGHPART is lower memory address when WORDS_BIG_ENDIAN.  */
7929   val = ((HOST_WIDE_INT)(unsigned long)l[endian] << 32
7930          | ((HOST_WIDE_INT)(unsigned long)l[1 - endian]));
7931
7932   operands[3] = gen_int_mode (val, DImode);
7933 }")
7934
7935 ;; Don't have reload use general registers to load a constant.  It is
7936 ;; less efficient than loading the constant into an FP register, since
7937 ;; it will probably be used there.
7938
7939 ;; The move constraints are ordered to prefer floating point registers before
7940 ;; general purpose registers to avoid doing a store and a load to get the value
7941 ;; into a floating point register when it is needed for a floating point
7942 ;; operation.  Prefer traditional floating point registers over VSX registers,
7943 ;; since the D-form version of the memory instructions does not need a GPR for
7944 ;; reloading.
7945
7946 (define_insn "*mov<mode>_hardfloat32"
7947   [(set (match_operand:FMOVE64 0 "nonimmediate_operand" "=m,d,d,wv,Z,wa,wa,Y,r,!r,!r,!r,!r")
7948         (match_operand:FMOVE64 1 "input_operand" "d,m,d,Z,wv,wa,j,r,Y,r,G,H,F"))]
7949   "! TARGET_POWERPC64 && TARGET_HARD_FLOAT && TARGET_FPRS && TARGET_DOUBLE_FLOAT 
7950    && (gpc_reg_operand (operands[0], <MODE>mode)
7951        || gpc_reg_operand (operands[1], <MODE>mode))"
7952   "@
7953    stfd%U0%X0 %1,%0
7954    lfd%U1%X1 %0,%1
7955    fmr %0,%1
7956    lxsd%U1x %x0,%y1
7957    stxsd%U0x %x1,%y0
7958    xxlor %x0,%x1,%x1
7959    xxlxor %x0,%x0,%x0
7960    #
7961    #
7962    #
7963    #
7964    #
7965    #"
7966   [(set_attr "type" "fpstore,fpload,fp,fpload,fpstore,vecsimple,vecsimple,store,load,two,fp,fp,*")
7967    (set_attr "length" "4,4,4,4,4,4,4,8,8,8,8,12,16")])
7968
7969 (define_insn "*mov<mode>_softfloat32"
7970   [(set (match_operand:FMOVE64 0 "nonimmediate_operand" "=Y,r,r,r,r,r")
7971         (match_operand:FMOVE64 1 "input_operand" "r,Y,r,G,H,F"))]
7972   "! TARGET_POWERPC64 
7973    && ((TARGET_FPRS && TARGET_SINGLE_FLOAT) 
7974        || TARGET_SOFT_FLOAT || TARGET_E500_SINGLE
7975        || (<MODE>mode == DDmode && TARGET_E500_DOUBLE))
7976    && (gpc_reg_operand (operands[0], <MODE>mode)
7977        || gpc_reg_operand (operands[1], <MODE>mode))"
7978   "#"
7979   [(set_attr "type" "store,load,two,*,*,*")
7980    (set_attr "length" "8,8,8,8,12,16")])
7981
7982 ; ld/std require word-aligned displacements -> 'Y' constraint.
7983 ; List Y->r and r->Y before r->r for reload.
7984 (define_insn "*mov<mode>_hardfloat64"
7985   [(set (match_operand:FMOVE64 0 "nonimmediate_operand" "=m,d,d,wv,Z,wa,wa,Y,r,!r,*c*l,!r,*h,!r,!r,!r,r,wg,r,wk")
7986         (match_operand:FMOVE64 1 "input_operand" "d,m,d,Z,wv,wa,j,r,Y,r,r,h,0,G,H,F,wg,r,wk,r"))]
7987   "TARGET_POWERPC64 && TARGET_HARD_FLOAT && TARGET_FPRS && TARGET_DOUBLE_FLOAT
7988    && (gpc_reg_operand (operands[0], <MODE>mode)
7989        || gpc_reg_operand (operands[1], <MODE>mode))"
7990   "@
7991    stfd%U0%X0 %1,%0
7992    lfd%U1%X1 %0,%1
7993    fmr %0,%1
7994    lxsd%U1x %x0,%y1
7995    stxsd%U0x %x1,%y0
7996    xxlor %x0,%x1,%x1
7997    xxlxor %x0,%x0,%x0
7998    std%U0%X0 %1,%0
7999    ld%U1%X1 %0,%1
8000    mr %0,%1
8001    mt%0 %1
8002    mf%1 %0
8003    nop
8004    #
8005    #
8006    #
8007    mftgpr %0,%1
8008    mffgpr %0,%1
8009    mfvsrd %0,%x1
8010    mtvsrd %x0,%1"
8011   [(set_attr "type" "fpstore,fpload,fp,fpload,fpstore,vecsimple,vecsimple,store,load,*,mtjmpr,mfjmpr,*,*,*,*,mftgpr,mffgpr,mftgpr,mffgpr")
8012    (set_attr "length" "4,4,4,4,4,4,4,4,4,4,4,4,4,8,12,16,4,4,4,4")])
8013
8014 (define_insn "*mov<mode>_softfloat64"
8015   [(set (match_operand:FMOVE64 0 "nonimmediate_operand" "=Y,r,r,cl,r,r,r,r,*h")
8016         (match_operand:FMOVE64 1 "input_operand" "r,Y,r,r,h,G,H,F,0"))]
8017   "TARGET_POWERPC64 && (TARGET_SOFT_FLOAT || !TARGET_FPRS)
8018    && (gpc_reg_operand (operands[0], <MODE>mode)
8019        || gpc_reg_operand (operands[1], <MODE>mode))"
8020   "@
8021    std%U0%X0 %1,%0
8022    ld%U1%X1 %0,%1
8023    mr %0,%1
8024    mt%0 %1
8025    mf%1 %0
8026    #
8027    #
8028    #
8029    nop"
8030   [(set_attr "type" "store,load,*,mtjmpr,mfjmpr,*,*,*,*")
8031    (set_attr "length" "4,4,4,4,4,8,12,16,4")])
8032 \f
8033 (define_expand "mov<mode>"
8034   [(set (match_operand:FMOVE128 0 "general_operand" "")
8035         (match_operand:FMOVE128 1 "any_operand" ""))]
8036   ""
8037   "{ rs6000_emit_move (operands[0], operands[1], <MODE>mode); DONE; }")
8038
8039 ;; It's important to list Y->r and r->Y before r->r because otherwise
8040 ;; reload, given m->r, will try to pick r->r and reload it, which
8041 ;; doesn't make progress.
8042
8043 ;; We can't split little endian direct moves of TDmode, because the words are
8044 ;; not swapped like they are for TImode or TFmode.  Subregs therefore are
8045 ;; problematical.  Don't allow direct move for this case.
8046
8047 (define_insn_and_split "*mov<mode>_64bit_dm"
8048   [(set (match_operand:FMOVE128 0 "nonimmediate_operand" "=m,d,d,Y,r,r,r,wm")
8049         (match_operand:FMOVE128 1 "input_operand" "d,m,d,r,YGHF,r,wm,r"))]
8050   "TARGET_HARD_FLOAT && TARGET_FPRS && TARGET_POWERPC64
8051    && (<MODE>mode != TDmode || WORDS_BIG_ENDIAN)
8052    && (gpc_reg_operand (operands[0], <MODE>mode)
8053        || gpc_reg_operand (operands[1], <MODE>mode))"
8054   "#"
8055   "&& reload_completed"
8056   [(pc)]
8057 { rs6000_split_multireg_move (operands[0], operands[1]); DONE; }
8058   [(set_attr "length" "8,8,8,12,12,8,8,8")])
8059
8060 (define_insn_and_split "*movtd_64bit_nodm"
8061   [(set (match_operand:TD 0 "nonimmediate_operand" "=m,d,d,Y,r,r")
8062         (match_operand:TD 1 "input_operand" "d,m,d,r,YGHF,r"))]
8063   "TARGET_HARD_FLOAT && TARGET_FPRS && TARGET_POWERPC64 && !WORDS_BIG_ENDIAN
8064    && (gpc_reg_operand (operands[0], TDmode)
8065        || gpc_reg_operand (operands[1], TDmode))"
8066   "#"
8067   "&& reload_completed"
8068   [(pc)]
8069 { rs6000_split_multireg_move (operands[0], operands[1]); DONE; }
8070   [(set_attr "length" "8,8,8,12,12,8")])
8071
8072 (define_insn_and_split "*mov<mode>_32bit"
8073   [(set (match_operand:FMOVE128 0 "nonimmediate_operand" "=m,d,d,Y,r,r")
8074         (match_operand:FMOVE128 1 "input_operand" "d,m,d,r,YGHF,r"))]
8075   "TARGET_HARD_FLOAT && TARGET_FPRS && !TARGET_POWERPC64
8076    && (gpc_reg_operand (operands[0], <MODE>mode)
8077        || gpc_reg_operand (operands[1], <MODE>mode))"
8078   "#"
8079   "&& reload_completed"
8080   [(pc)]
8081 { rs6000_split_multireg_move (operands[0], operands[1]); DONE; }
8082   [(set_attr "length" "8,8,8,20,20,16")])
8083
8084 (define_insn_and_split "*mov<mode>_softfloat"
8085   [(set (match_operand:FMOVE128 0 "rs6000_nonimmediate_operand" "=Y,r,r")
8086         (match_operand:FMOVE128 1 "input_operand" "r,YGHF,r"))]
8087   "(TARGET_SOFT_FLOAT || !TARGET_FPRS)
8088    && (gpc_reg_operand (operands[0], <MODE>mode)
8089        || gpc_reg_operand (operands[1], <MODE>mode))"
8090   "#"
8091   "&& reload_completed"
8092   [(pc)]
8093 { rs6000_split_multireg_move (operands[0], operands[1]); DONE; }
8094   [(set_attr "length" "20,20,16")])
8095
8096 (define_expand "extenddftf2"
8097   [(set (match_operand:TF 0 "nonimmediate_operand" "")
8098         (float_extend:TF (match_operand:DF 1 "input_operand" "")))]
8099   "!TARGET_IEEEQUAD
8100    && TARGET_HARD_FLOAT
8101    && (TARGET_FPRS || TARGET_E500_DOUBLE)
8102    && TARGET_LONG_DOUBLE_128"
8103 {
8104   if (TARGET_E500_DOUBLE)
8105     emit_insn (gen_spe_extenddftf2 (operands[0], operands[1]));
8106   else
8107     emit_insn (gen_extenddftf2_fprs (operands[0], operands[1]));
8108   DONE;
8109 })
8110
8111 (define_expand "extenddftf2_fprs"
8112   [(parallel [(set (match_operand:TF 0 "nonimmediate_operand" "")
8113                    (float_extend:TF (match_operand:DF 1 "input_operand" "")))
8114               (use (match_dup 2))])]
8115   "!TARGET_IEEEQUAD
8116    && TARGET_HARD_FLOAT && TARGET_FPRS && TARGET_DOUBLE_FLOAT 
8117    && TARGET_LONG_DOUBLE_128"
8118 {
8119   operands[2] = CONST0_RTX (DFmode);
8120   /* Generate GOT reference early for SVR4 PIC.  */
8121   if (DEFAULT_ABI == ABI_V4 && flag_pic)
8122     operands[2] = validize_mem (force_const_mem (DFmode, operands[2]));
8123 })
8124
8125 (define_insn_and_split "*extenddftf2_internal"
8126   [(set (match_operand:TF 0 "nonimmediate_operand" "=m,Y,d,&d,r")
8127        (float_extend:TF (match_operand:DF 1 "input_operand" "d,r,md,md,rmGHF")))
8128    (use (match_operand:DF 2 "zero_reg_mem_operand" "d,r,m,d,n"))]
8129   "!TARGET_IEEEQUAD
8130    && TARGET_HARD_FLOAT && TARGET_FPRS && TARGET_DOUBLE_FLOAT 
8131    && TARGET_LONG_DOUBLE_128"
8132   "#"
8133   "&& reload_completed"
8134   [(pc)]
8135 {
8136   const int lo_word = LONG_DOUBLE_LARGE_FIRST ? GET_MODE_SIZE (DFmode) : 0;
8137   const int hi_word = LONG_DOUBLE_LARGE_FIRST ? 0 : GET_MODE_SIZE (DFmode);
8138   emit_move_insn (simplify_gen_subreg (DFmode, operands[0], TFmode, hi_word),
8139                   operands[1]);
8140   emit_move_insn (simplify_gen_subreg (DFmode, operands[0], TFmode, lo_word),
8141                   operands[2]);
8142   DONE;
8143 })
8144
8145 (define_expand "extendsftf2"
8146   [(set (match_operand:TF 0 "nonimmediate_operand" "")
8147         (float_extend:TF (match_operand:SF 1 "gpc_reg_operand" "")))]
8148   "!TARGET_IEEEQUAD
8149    && TARGET_HARD_FLOAT
8150    && (TARGET_FPRS || TARGET_E500_DOUBLE)
8151    && TARGET_LONG_DOUBLE_128"
8152 {
8153   rtx tmp = gen_reg_rtx (DFmode);
8154   emit_insn (gen_extendsfdf2 (tmp, operands[1]));
8155   emit_insn (gen_extenddftf2 (operands[0], tmp));
8156   DONE;
8157 })
8158
8159 (define_expand "trunctfdf2"
8160   [(set (match_operand:DF 0 "gpc_reg_operand" "")
8161         (float_truncate:DF (match_operand:TF 1 "gpc_reg_operand" "")))]
8162   "!TARGET_IEEEQUAD
8163    && TARGET_HARD_FLOAT
8164    && (TARGET_FPRS || TARGET_E500_DOUBLE)
8165    && TARGET_LONG_DOUBLE_128"
8166   "")
8167
8168 (define_insn_and_split "trunctfdf2_internal1"
8169   [(set (match_operand:DF 0 "gpc_reg_operand" "=d,?d")
8170         (float_truncate:DF (match_operand:TF 1 "gpc_reg_operand" "0,d")))]
8171   "!TARGET_IEEEQUAD && !TARGET_XL_COMPAT
8172    && TARGET_HARD_FLOAT && TARGET_FPRS && TARGET_LONG_DOUBLE_128"
8173   "@
8174    #
8175    fmr %0,%1"
8176   "&& reload_completed && REGNO (operands[0]) == REGNO (operands[1])"
8177   [(const_int 0)]
8178 {
8179   emit_note (NOTE_INSN_DELETED);
8180   DONE;
8181 }
8182   [(set_attr "type" "fp")])
8183
8184 (define_insn "trunctfdf2_internal2"
8185   [(set (match_operand:DF 0 "gpc_reg_operand" "=d")
8186         (float_truncate:DF (match_operand:TF 1 "gpc_reg_operand" "d")))]
8187   "!TARGET_IEEEQUAD && TARGET_XL_COMPAT
8188    && TARGET_HARD_FLOAT && TARGET_FPRS && TARGET_DOUBLE_FLOAT 
8189    && TARGET_LONG_DOUBLE_128"
8190   "fadd %0,%1,%L1"
8191   [(set_attr "type" "fp")
8192    (set_attr "fp_type" "fp_addsub_d")])
8193
8194 (define_expand "trunctfsf2"
8195   [(set (match_operand:SF 0 "gpc_reg_operand" "")
8196         (float_truncate:SF (match_operand:TF 1 "gpc_reg_operand" "")))]
8197   "!TARGET_IEEEQUAD
8198    && TARGET_HARD_FLOAT
8199    && (TARGET_FPRS || TARGET_E500_DOUBLE)
8200    && TARGET_LONG_DOUBLE_128"
8201 {
8202   if (TARGET_E500_DOUBLE)
8203     emit_insn (gen_spe_trunctfsf2 (operands[0], operands[1]));
8204   else
8205     emit_insn (gen_trunctfsf2_fprs (operands[0], operands[1]));
8206   DONE;
8207 })
8208
8209 (define_insn_and_split "trunctfsf2_fprs"
8210   [(set (match_operand:SF 0 "gpc_reg_operand" "=f")
8211         (float_truncate:SF (match_operand:TF 1 "gpc_reg_operand" "d")))
8212    (clobber (match_scratch:DF 2 "=d"))]
8213   "!TARGET_IEEEQUAD
8214    && TARGET_HARD_FLOAT && TARGET_FPRS && TARGET_SINGLE_FLOAT 
8215    && TARGET_LONG_DOUBLE_128"
8216   "#"
8217   "&& reload_completed"
8218   [(set (match_dup 2)
8219         (float_truncate:DF (match_dup 1)))
8220    (set (match_dup 0)
8221         (float_truncate:SF (match_dup 2)))]
8222   "")
8223
8224 (define_expand "floatsitf2"
8225   [(set (match_operand:TF 0 "gpc_reg_operand" "")
8226         (float:TF (match_operand:SI 1 "gpc_reg_operand" "")))]
8227   "!TARGET_IEEEQUAD
8228    && TARGET_HARD_FLOAT
8229    && (TARGET_FPRS || TARGET_E500_DOUBLE)
8230    && TARGET_LONG_DOUBLE_128"
8231 {
8232   rtx tmp = gen_reg_rtx (DFmode);
8233   expand_float (tmp, operands[1], false);
8234   emit_insn (gen_extenddftf2 (operands[0], tmp));
8235   DONE;
8236 })
8237
8238 ; fadd, but rounding towards zero.
8239 ; This is probably not the optimal code sequence.
8240 (define_insn "fix_trunc_helper"
8241   [(set (match_operand:DF 0 "gpc_reg_operand" "=d")
8242         (unspec:DF [(match_operand:TF 1 "gpc_reg_operand" "d")]
8243                    UNSPEC_FIX_TRUNC_TF))
8244    (clobber (match_operand:DF 2 "gpc_reg_operand" "=&d"))]
8245   "TARGET_HARD_FLOAT && TARGET_FPRS && TARGET_DOUBLE_FLOAT"
8246   "mffs %2\n\tmtfsb1 31\n\tmtfsb0 30\n\tfadd %0,%1,%L1\n\tmtfsf 1,%2"
8247   [(set_attr "type" "fp")
8248    (set_attr "length" "20")])
8249
8250 (define_expand "fix_trunctfsi2"
8251   [(set (match_operand:SI 0 "gpc_reg_operand" "")
8252         (fix:SI (match_operand:TF 1 "gpc_reg_operand" "")))]
8253   "!TARGET_IEEEQUAD && TARGET_HARD_FLOAT
8254    && (TARGET_FPRS || TARGET_E500_DOUBLE) && TARGET_LONG_DOUBLE_128"
8255 {
8256   if (TARGET_E500_DOUBLE)
8257     emit_insn (gen_spe_fix_trunctfsi2 (operands[0], operands[1]));
8258   else
8259     emit_insn (gen_fix_trunctfsi2_fprs (operands[0], operands[1]));
8260   DONE;
8261 })
8262
8263 (define_expand "fix_trunctfsi2_fprs"
8264   [(parallel [(set (match_operand:SI 0 "gpc_reg_operand" "")
8265                    (fix:SI (match_operand:TF 1 "gpc_reg_operand" "")))
8266               (clobber (match_dup 2))
8267               (clobber (match_dup 3))
8268               (clobber (match_dup 4))
8269               (clobber (match_dup 5))])]
8270   "!TARGET_IEEEQUAD
8271    && TARGET_HARD_FLOAT && TARGET_FPRS && TARGET_LONG_DOUBLE_128"
8272 {
8273   operands[2] = gen_reg_rtx (DFmode);
8274   operands[3] = gen_reg_rtx (DFmode);
8275   operands[4] = gen_reg_rtx (DImode);
8276   operands[5] = assign_stack_temp (DImode, GET_MODE_SIZE (DImode));
8277 })
8278
8279 (define_insn_and_split "*fix_trunctfsi2_internal"
8280   [(set (match_operand:SI 0 "gpc_reg_operand" "=r")
8281         (fix:SI (match_operand:TF 1 "gpc_reg_operand" "d")))
8282    (clobber (match_operand:DF 2 "gpc_reg_operand" "=d"))
8283    (clobber (match_operand:DF 3 "gpc_reg_operand" "=&d"))
8284    (clobber (match_operand:DI 4 "gpc_reg_operand" "=d"))
8285    (clobber (match_operand:DI 5 "offsettable_mem_operand" "=o"))]
8286   "!TARGET_IEEEQUAD
8287    && TARGET_HARD_FLOAT && TARGET_FPRS && TARGET_LONG_DOUBLE_128"
8288   "#"
8289   ""
8290   [(pc)]
8291 {
8292   rtx lowword;
8293   emit_insn (gen_fix_trunc_helper (operands[2], operands[1], operands[3]));
8294
8295   gcc_assert (MEM_P (operands[5]));
8296   lowword = adjust_address (operands[5], SImode, WORDS_BIG_ENDIAN ? 4 : 0);
8297
8298   emit_insn (gen_fctiwz_df (operands[4], operands[2]));
8299   emit_move_insn (operands[5], operands[4]);
8300   emit_move_insn (operands[0], lowword);
8301   DONE;
8302 })
8303
8304 (define_expand "negtf2"
8305   [(set (match_operand:TF 0 "gpc_reg_operand" "")
8306         (neg:TF (match_operand:TF 1 "gpc_reg_operand" "")))]
8307   "!TARGET_IEEEQUAD
8308    && TARGET_HARD_FLOAT
8309    && (TARGET_FPRS || TARGET_E500_DOUBLE)
8310    && TARGET_LONG_DOUBLE_128"
8311   "")
8312
8313 (define_insn "negtf2_internal"
8314   [(set (match_operand:TF 0 "gpc_reg_operand" "=d")
8315         (neg:TF (match_operand:TF 1 "gpc_reg_operand" "d")))]
8316   "!TARGET_IEEEQUAD
8317    && TARGET_HARD_FLOAT && TARGET_FPRS && TARGET_LONG_DOUBLE_128"
8318   "*
8319 {
8320   if (REGNO (operands[0]) == REGNO (operands[1]) + 1)
8321     return \"fneg %L0,%L1\;fneg %0,%1\";
8322   else
8323     return \"fneg %0,%1\;fneg %L0,%L1\";
8324 }"
8325   [(set_attr "type" "fp")
8326    (set_attr "length" "8")])
8327
8328 (define_expand "abstf2"
8329   [(set (match_operand:TF 0 "gpc_reg_operand" "")
8330         (abs:TF (match_operand:TF 1 "gpc_reg_operand" "")))]
8331   "!TARGET_IEEEQUAD
8332    && TARGET_HARD_FLOAT
8333    && (TARGET_FPRS || TARGET_E500_DOUBLE)
8334    && TARGET_LONG_DOUBLE_128"
8335   "
8336 {
8337   rtx label = gen_label_rtx ();
8338   if (TARGET_E500_DOUBLE)
8339     {
8340       if (flag_finite_math_only && !flag_trapping_math)
8341         emit_insn (gen_spe_abstf2_tst (operands[0], operands[1], label));
8342       else
8343         emit_insn (gen_spe_abstf2_cmp (operands[0], operands[1], label));
8344     }
8345   else
8346     emit_insn (gen_abstf2_internal (operands[0], operands[1], label));
8347   emit_label (label);
8348   DONE;
8349 }")
8350
8351 (define_expand "abstf2_internal"
8352   [(set (match_operand:TF 0 "gpc_reg_operand" "")
8353         (match_operand:TF 1 "gpc_reg_operand" ""))
8354    (set (match_dup 3) (match_dup 5))
8355    (set (match_dup 5) (abs:DF (match_dup 5)))
8356    (set (match_dup 4) (compare:CCFP (match_dup 3) (match_dup 5)))
8357    (set (pc) (if_then_else (eq (match_dup 4) (const_int 0))
8358                            (label_ref (match_operand 2 "" ""))
8359                            (pc)))
8360    (set (match_dup 6) (neg:DF (match_dup 6)))]
8361   "!TARGET_IEEEQUAD
8362    && TARGET_HARD_FLOAT && TARGET_FPRS && TARGET_DOUBLE_FLOAT 
8363    && TARGET_LONG_DOUBLE_128"
8364   "
8365 {
8366   const int hi_word = LONG_DOUBLE_LARGE_FIRST ? 0 : GET_MODE_SIZE (DFmode);
8367   const int lo_word = LONG_DOUBLE_LARGE_FIRST ? GET_MODE_SIZE (DFmode) : 0;
8368   operands[3] = gen_reg_rtx (DFmode);
8369   operands[4] = gen_reg_rtx (CCFPmode);
8370   operands[5] = simplify_gen_subreg (DFmode, operands[0], TFmode, hi_word);
8371   operands[6] = simplify_gen_subreg (DFmode, operands[0], TFmode, lo_word);
8372 }")
8373 \f
8374 ;; Reload helper functions used by rs6000_secondary_reload.  The patterns all
8375 ;; must have 3 arguments, and scratch register constraint must be a single
8376 ;; constraint.
8377
8378 ;; Reload patterns to support gpr load/store with misaligned mem.
8379 ;; and multiple gpr load/store at offset >= 0xfffc
8380 (define_expand "reload_<mode>_store"
8381   [(parallel [(match_operand 0 "memory_operand" "=m")
8382               (match_operand 1 "gpc_reg_operand" "r")
8383               (match_operand:GPR 2 "register_operand" "=&b")])]
8384   ""
8385 {
8386   rs6000_secondary_reload_gpr (operands[1], operands[0], operands[2], true);
8387   DONE;
8388 })
8389
8390 (define_expand "reload_<mode>_load"
8391   [(parallel [(match_operand 0 "gpc_reg_operand" "=r")
8392               (match_operand 1 "memory_operand" "m")
8393               (match_operand:GPR 2 "register_operand" "=b")])]
8394   ""
8395 {
8396   rs6000_secondary_reload_gpr (operands[0], operands[1], operands[2], false);
8397   DONE;
8398 })
8399
8400 \f
8401 ;; Power8 merge instructions to allow direct move to/from floating point
8402 ;; registers in 32-bit mode.  We use TF mode to get two registers to move the
8403 ;; individual 32-bit parts across.  Subreg doesn't work too well on the TF
8404 ;; value, since it is allocated in reload and not all of the flow information
8405 ;; is setup for it.  We have two patterns to do the two moves between gprs and
8406 ;; fprs.  There isn't a dependancy between the two, but we could potentially
8407 ;; schedule other instructions between the two instructions.  TFmode is
8408 ;; currently limited to traditional FPR registers.  If/when this is changed, we
8409 ;; will need to revist %L to make sure it works with VSX registers, or add an
8410 ;; %x version of %L.
8411
8412 (define_insn "p8_fmrgow_<mode>"
8413   [(set (match_operand:FMOVE64X 0 "register_operand" "=d")
8414         (unspec:FMOVE64X [(match_operand:TF 1 "register_operand" "d")]
8415                          UNSPEC_P8V_FMRGOW))]
8416   "!TARGET_POWERPC64 && TARGET_DIRECT_MOVE"
8417   "fmrgow %0,%1,%L1"
8418   [(set_attr "type" "vecperm")])
8419
8420 (define_insn "p8_mtvsrwz_1"
8421   [(set (match_operand:TF 0 "register_operand" "=d")
8422         (unspec:TF [(match_operand:SI 1 "register_operand" "r")]
8423                    UNSPEC_P8V_MTVSRWZ))]
8424   "!TARGET_POWERPC64 && TARGET_DIRECT_MOVE"
8425   "mtvsrwz %x0,%1"
8426   [(set_attr "type" "mftgpr")])
8427
8428 (define_insn "p8_mtvsrwz_2"
8429   [(set (match_operand:TF 0 "register_operand" "+d")
8430         (unspec:TF [(match_dup 0)
8431                     (match_operand:SI 1 "register_operand" "r")]
8432                    UNSPEC_P8V_MTVSRWZ))]
8433   "!TARGET_POWERPC64 && TARGET_DIRECT_MOVE"
8434   "mtvsrwz %L0,%1"
8435   [(set_attr "type" "mftgpr")])
8436
8437 (define_insn_and_split "reload_fpr_from_gpr<mode>"
8438   [(set (match_operand:FMOVE64X 0 "register_operand" "=ws")
8439         (unspec:FMOVE64X [(match_operand:FMOVE64X 1 "register_operand" "r")]
8440                          UNSPEC_P8V_RELOAD_FROM_GPR))
8441    (clobber (match_operand:TF 2 "register_operand" "=d"))]
8442   "!TARGET_POWERPC64 && TARGET_DIRECT_MOVE"
8443   "#"
8444   "&& reload_completed"
8445   [(const_int 0)]
8446 {
8447   rtx dest = operands[0];
8448   rtx src = operands[1];
8449   rtx tmp = operands[2];
8450   rtx gpr_hi_reg = gen_highpart (SImode, src);
8451   rtx gpr_lo_reg = gen_lowpart (SImode, src);
8452
8453   emit_insn (gen_p8_mtvsrwz_1 (tmp, gpr_hi_reg));
8454   emit_insn (gen_p8_mtvsrwz_2 (tmp, gpr_lo_reg));
8455   emit_insn (gen_p8_fmrgow_<mode> (dest, tmp));
8456   DONE;
8457 }
8458   [(set_attr "length" "12")
8459    (set_attr "type" "three")])
8460
8461 ;; Move 128 bit values from GPRs to VSX registers in 64-bit mode
8462 (define_insn "p8_mtvsrd_1"
8463   [(set (match_operand:TF 0 "register_operand" "=ws")
8464         (unspec:TF [(match_operand:DI 1 "register_operand" "r")]
8465                    UNSPEC_P8V_MTVSRD))]
8466   "TARGET_POWERPC64 && TARGET_DIRECT_MOVE"
8467   "mtvsrd %0,%1"
8468   [(set_attr "type" "mftgpr")])
8469
8470 (define_insn "p8_mtvsrd_2"
8471   [(set (match_operand:TF 0 "register_operand" "+ws")
8472         (unspec:TF [(match_dup 0)
8473                     (match_operand:DI 1 "register_operand" "r")]
8474                    UNSPEC_P8V_MTVSRD))]
8475   "TARGET_POWERPC64 && TARGET_DIRECT_MOVE"
8476   "mtvsrd %L0,%1"
8477   [(set_attr "type" "mftgpr")])
8478
8479 (define_insn "p8_xxpermdi_<mode>"
8480   [(set (match_operand:FMOVE128_GPR 0 "register_operand" "=wa")
8481         (unspec:FMOVE128_GPR [(match_operand:TF 1 "register_operand" "ws")]
8482                              UNSPEC_P8V_XXPERMDI))]
8483   "TARGET_POWERPC64 && TARGET_DIRECT_MOVE"
8484   "xxpermdi %x0,%1,%L1,0"
8485   [(set_attr "type" "vecperm")])
8486
8487 (define_insn_and_split "reload_vsx_from_gpr<mode>"
8488   [(set (match_operand:FMOVE128_GPR 0 "register_operand" "=wa")
8489         (unspec:FMOVE128_GPR
8490          [(match_operand:FMOVE128_GPR 1 "register_operand" "r")]
8491          UNSPEC_P8V_RELOAD_FROM_GPR))
8492    (clobber (match_operand:TF 2 "register_operand" "=ws"))]
8493   "TARGET_POWERPC64 && TARGET_DIRECT_MOVE"
8494   "#"
8495   "&& reload_completed"
8496   [(const_int 0)]
8497 {
8498   rtx dest = operands[0];
8499   rtx src = operands[1];
8500   rtx tmp = operands[2];
8501   rtx gpr_hi_reg = gen_highpart (DImode, src);
8502   rtx gpr_lo_reg = gen_lowpart (DImode, src);
8503
8504   emit_insn (gen_p8_mtvsrd_1 (tmp, gpr_hi_reg));
8505   emit_insn (gen_p8_mtvsrd_2 (tmp, gpr_lo_reg));
8506   emit_insn (gen_p8_xxpermdi_<mode> (dest, tmp));
8507 }
8508   [(set_attr "length" "12")
8509    (set_attr "type" "three")])
8510
8511 (define_split
8512   [(set (match_operand:FMOVE128_GPR 0 "nonimmediate_operand" "")
8513         (match_operand:FMOVE128_GPR 1 "input_operand" ""))]
8514   "reload_completed
8515    && (int_reg_operand (operands[0], <MODE>mode)
8516        || int_reg_operand (operands[1], <MODE>mode))"
8517   [(pc)]
8518 { rs6000_split_multireg_move (operands[0], operands[1]); DONE; })
8519
8520 ;; Move SFmode to a VSX from a GPR register.  Because scalar floating point
8521 ;; type is stored internally as double precision in the VSX registers, we have
8522 ;; to convert it from the vector format.
8523
8524 (define_insn_and_split "reload_vsx_from_gprsf"
8525   [(set (match_operand:SF 0 "register_operand" "=wa")
8526         (unspec:SF [(match_operand:SF 1 "register_operand" "r")]
8527                    UNSPEC_P8V_RELOAD_FROM_GPR))
8528    (clobber (match_operand:DI 2 "register_operand" "=r"))]
8529   "TARGET_POWERPC64 && TARGET_DIRECT_MOVE"
8530   "#"
8531   "&& reload_completed"
8532   [(const_int 0)]
8533 {
8534   rtx op0 = operands[0];
8535   rtx op1 = operands[1];
8536   rtx op2 = operands[2];
8537   /* Also use the destination register to hold the unconverted DImode value.
8538      This is conceptually a separate value from OP0, so we use gen_rtx_REG
8539      rather than simplify_gen_subreg.  */
8540   rtx op0_di = gen_rtx_REG (DImode, REGNO (op0));
8541   rtx op1_di = simplify_gen_subreg (DImode, op1, SFmode, 0);
8542
8543   /* Move SF value to upper 32-bits for xscvspdpn.  */
8544   emit_insn (gen_ashldi3 (op2, op1_di, GEN_INT (32)));
8545   emit_move_insn (op0_di, op2);
8546   emit_insn (gen_vsx_xscvspdpn_directmove (op0, op0_di));
8547   DONE;
8548 }
8549   [(set_attr "length" "8")
8550    (set_attr "type" "two")])
8551
8552 ;; Move 128 bit values from VSX registers to GPRs in 64-bit mode by doing a
8553 ;; normal 64-bit move, followed by an xxpermdi to get the bottom 64-bit value,
8554 ;; and then doing a move of that.
8555 (define_insn "p8_mfvsrd_3_<mode>"
8556   [(set (match_operand:DF 0 "register_operand" "=r")
8557         (unspec:DF [(match_operand:FMOVE128_GPR 1 "register_operand" "wa")]
8558                    UNSPEC_P8V_RELOAD_FROM_VSX))]
8559   "TARGET_POWERPC64 && TARGET_DIRECT_MOVE"
8560   "mfvsrd %0,%x1"
8561   [(set_attr "type" "mftgpr")])
8562
8563 (define_insn_and_split "reload_gpr_from_vsx<mode>"
8564   [(set (match_operand:FMOVE128_GPR 0 "register_operand" "=r")
8565         (unspec:FMOVE128_GPR
8566          [(match_operand:FMOVE128_GPR 1 "register_operand" "wa")]
8567          UNSPEC_P8V_RELOAD_FROM_VSX))
8568    (clobber (match_operand:FMOVE128_GPR 2 "register_operand" "=wa"))]
8569   "TARGET_POWERPC64 && TARGET_DIRECT_MOVE"
8570   "#"
8571   "&& reload_completed"
8572   [(const_int 0)]
8573 {
8574   rtx dest = operands[0];
8575   rtx src = operands[1];
8576   rtx tmp = operands[2];
8577   rtx gpr_hi_reg = gen_highpart (DFmode, dest);
8578   rtx gpr_lo_reg = gen_lowpart (DFmode, dest);
8579
8580   emit_insn (gen_p8_mfvsrd_3_<mode> (gpr_hi_reg, src));
8581   emit_insn (gen_vsx_xxpermdi_<mode> (tmp, src, src, GEN_INT (3)));
8582   emit_insn (gen_p8_mfvsrd_3_<mode> (gpr_lo_reg, tmp));
8583 }
8584   [(set_attr "length" "12")
8585    (set_attr "type" "three")])
8586
8587 ;; Move SFmode to a GPR from a VSX register.  Because scalar floating point
8588 ;; type is stored internally as double precision, we have to convert it to the
8589 ;; vector format.
8590
8591 (define_insn_and_split "reload_gpr_from_vsxsf"
8592   [(set (match_operand:SF 0 "register_operand" "=r")
8593         (unspec:SF [(match_operand:SF 1 "register_operand" "wa")]
8594                    UNSPEC_P8V_RELOAD_FROM_VSX))
8595    (clobber (match_operand:V4SF 2 "register_operand" "=wa"))]
8596   "TARGET_POWERPC64 && TARGET_DIRECT_MOVE"
8597   "#"
8598   "&& reload_completed"
8599   [(const_int 0)]
8600 {
8601   rtx op0 = operands[0];
8602   rtx op1 = operands[1];
8603   rtx op2 = operands[2];
8604   rtx diop0 = simplify_gen_subreg (DImode, op0, SFmode, 0);
8605
8606   emit_insn (gen_vsx_xscvdpspn_scalar (op2, op1));
8607   emit_insn (gen_p8_mfvsrd_4_disf (diop0, op2));
8608   emit_insn (gen_lshrdi3 (diop0, diop0, GEN_INT (32)));
8609   DONE;
8610 }
8611   [(set_attr "length" "12")
8612    (set_attr "type" "three")])
8613
8614 (define_insn "p8_mfvsrd_4_disf"
8615   [(set (match_operand:DI 0 "register_operand" "=r")
8616         (unspec:DI [(match_operand:V4SF 1 "register_operand" "wa")]
8617                    UNSPEC_P8V_RELOAD_FROM_VSX))]
8618   "TARGET_POWERPC64 && TARGET_DIRECT_MOVE"
8619   "mfvsrd %0,%x1"
8620   [(set_attr "type" "mftgpr")])
8621
8622 \f
8623 ;; Next come the multi-word integer load and store and the load and store
8624 ;; multiple insns.
8625
8626 ;; List r->r after r->Y, otherwise reload will try to reload a
8627 ;; non-offsettable address by using r->r which won't make progress.
8628 ;; Use of fprs is disparaged slightly otherwise reload prefers to reload
8629 ;; a gpr into a fpr instead of reloading an invalid 'Y' address
8630 (define_insn "*movdi_internal32"
8631   [(set (match_operand:DI 0 "rs6000_nonimmediate_operand" "=Y,r,r,?m,?*d,?*d,r")
8632         (match_operand:DI 1 "input_operand" "r,Y,r,d,m,d,IJKnGHF"))]
8633   "! TARGET_POWERPC64
8634    && (gpc_reg_operand (operands[0], DImode)
8635        || gpc_reg_operand (operands[1], DImode))"
8636   "@
8637    #
8638    #
8639    #
8640    stfd%U0%X0 %1,%0
8641    lfd%U1%X1 %0,%1
8642    fmr %0,%1
8643    #"
8644   [(set_attr "type" "store,load,*,fpstore,fpload,fp,*")])
8645
8646 (define_split
8647   [(set (match_operand:DI 0 "gpc_reg_operand" "")
8648         (match_operand:DI 1 "const_int_operand" ""))]
8649   "! TARGET_POWERPC64 && reload_completed
8650    && gpr_or_gpr_p (operands[0], operands[1])
8651    && !direct_move_p (operands[0], operands[1])"
8652   [(set (match_dup 2) (match_dup 4))
8653    (set (match_dup 3) (match_dup 1))]
8654   "
8655 {
8656   HOST_WIDE_INT value = INTVAL (operands[1]);
8657   operands[2] = operand_subword_force (operands[0], WORDS_BIG_ENDIAN == 0,
8658                                        DImode);
8659   operands[3] = operand_subword_force (operands[0], WORDS_BIG_ENDIAN != 0,
8660                                        DImode);
8661   operands[4] = GEN_INT (value >> 32);
8662   operands[1] = GEN_INT (((value & 0xffffffff) ^ 0x80000000) - 0x80000000);
8663 }")
8664
8665 (define_split
8666   [(set (match_operand:DIFD 0 "rs6000_nonimmediate_operand" "")
8667         (match_operand:DIFD 1 "input_operand" ""))]
8668   "reload_completed && !TARGET_POWERPC64
8669    && gpr_or_gpr_p (operands[0], operands[1])
8670    && !direct_move_p (operands[0], operands[1])"
8671   [(pc)]
8672 { rs6000_split_multireg_move (operands[0], operands[1]); DONE; })
8673
8674 (define_insn "*movdi_internal64"
8675   [(set (match_operand:DI 0 "nonimmediate_operand" "=Y,r,r,r,r,r,?m,?*d,?*d,r,*h,*h,r,?*wg,r,?*wj,?*wi")
8676         (match_operand:DI 1 "input_operand" "r,Y,r,I,L,nF,d,m,d,*h,r,0,*wg,r,*wj,r,O"))]
8677   "TARGET_POWERPC64
8678    && (gpc_reg_operand (operands[0], DImode)
8679        || gpc_reg_operand (operands[1], DImode))"
8680   "@
8681    std%U0%X0 %1,%0
8682    ld%U1%X1 %0,%1
8683    mr %0,%1
8684    li %0,%1
8685    lis %0,%v1
8686    #
8687    stfd%U0%X0 %1,%0
8688    lfd%U1%X1 %0,%1
8689    fmr %0,%1
8690    mf%1 %0
8691    mt%0 %1
8692    nop
8693    mftgpr %0,%1
8694    mffgpr %0,%1
8695    mfvsrd %0,%x1
8696    mtvsrd %x0,%1
8697    xxlxor %x0,%x0,%x0"
8698   [(set_attr "type" "store,load,*,*,*,*,fpstore,fpload,fp,mfjmpr,mtjmpr,*,mftgpr,mffgpr,mftgpr,mffgpr,vecsimple")
8699    (set_attr "length" "4,4,4,4,4,20,4,4,4,4,4,4,4,4,4,4,4")])
8700
8701 ;; Generate all one-bits and clear left or right.
8702 ;; Use (and:DI (rotate:DI ...)) to avoid anddi3 unnecessary clobber.
8703 (define_split
8704   [(set (match_operand:DI 0 "gpc_reg_operand" "")
8705         (match_operand:DI 1 "mask64_operand" ""))]
8706   "TARGET_POWERPC64 && num_insns_constant (operands[1], DImode) > 1"
8707   [(set (match_dup 0) (const_int -1))
8708    (set (match_dup 0)
8709         (and:DI (rotate:DI (match_dup 0)
8710                            (const_int 0))
8711                 (match_dup 1)))]
8712   "")
8713
8714 ;; Split a load of a large constant into the appropriate five-instruction
8715 ;; sequence.  Handle anything in a constant number of insns.
8716 ;; When non-easy constants can go in the TOC, this should use
8717 ;; easy_fp_constant predicate.
8718 (define_split
8719   [(set (match_operand:DI 0 "gpc_reg_operand" "")
8720         (match_operand:DI 1 "const_int_operand" ""))]
8721   "TARGET_POWERPC64 && num_insns_constant (operands[1], DImode) > 1"
8722   [(set (match_dup 0) (match_dup 2))
8723    (set (match_dup 0) (plus:DI (match_dup 0) (match_dup 3)))]
8724   "
8725 {
8726   if (rs6000_emit_set_const (operands[0], operands[1]))
8727     DONE;
8728   else
8729     FAIL;
8730 }")
8731
8732 (define_split
8733   [(set (match_operand:DI 0 "gpc_reg_operand" "")
8734         (match_operand:DI 1 "const_scalar_int_operand" ""))]
8735   "TARGET_POWERPC64 && num_insns_constant (operands[1], DImode) > 1"
8736   [(set (match_dup 0) (match_dup 2))
8737    (set (match_dup 0) (plus:DI (match_dup 0) (match_dup 3)))]
8738   "
8739 {
8740   if (rs6000_emit_set_const (operands[0], operands[1]))
8741     DONE;
8742   else
8743     FAIL;
8744 }")
8745 \f
8746 ;; TImode/PTImode is similar, except that we usually want to compute the
8747 ;; address into a register and use lsi/stsi (the exception is during reload).
8748
8749 (define_insn "*mov<mode>_string"
8750   [(set (match_operand:TI2 0 "reg_or_mem_operand" "=Q,Y,????r,????r,????r,r")
8751         (match_operand:TI2 1 "input_operand" "r,r,Q,Y,r,n"))]
8752   "! TARGET_POWERPC64
8753    && (<MODE>mode != TImode || VECTOR_MEM_NONE_P (TImode))
8754    && (gpc_reg_operand (operands[0], <MODE>mode)
8755        || gpc_reg_operand (operands[1], <MODE>mode))"
8756   "*
8757 {
8758   switch (which_alternative)
8759     {
8760     default:
8761       gcc_unreachable ();
8762     case 0:
8763       if (TARGET_STRING)
8764         return \"stswi %1,%P0,16\";
8765     case 1:
8766       return \"#\";
8767     case 2:
8768       /* If the address is not used in the output, we can use lsi.  Otherwise,
8769          fall through to generating four loads.  */
8770       if (TARGET_STRING
8771           && ! reg_overlap_mentioned_p (operands[0], operands[1]))
8772         return \"lswi %0,%P1,16\";
8773       /* ... fall through ...  */
8774     case 3:
8775     case 4:
8776     case 5:
8777       return \"#\";
8778     }
8779 }"
8780   [(set_attr "type" "store,store,load,load,*,*")
8781    (set_attr "update" "yes")
8782    (set_attr "indexed" "yes")
8783    (set (attr "cell_micro") (if_then_else (match_test "TARGET_STRING")
8784                                           (const_string "always")
8785                                           (const_string "conditional")))])
8786
8787 (define_insn "*mov<mode>_ppc64"
8788   [(set (match_operand:TI2 0 "nonimmediate_operand" "=wQ,Y,r,r,r,r")
8789         (match_operand:TI2 1 "input_operand" "r,r,wQ,Y,r,n"))]
8790   "(TARGET_POWERPC64 && VECTOR_MEM_NONE_P (<MODE>mode)
8791    && (gpc_reg_operand (operands[0], <MODE>mode)
8792        || gpc_reg_operand (operands[1], <MODE>mode)))"
8793 {
8794   return rs6000_output_move_128bit (operands);
8795 }
8796   [(set_attr "type" "store,store,load,load,*,*")
8797    (set_attr "length" "8")])
8798
8799 (define_split
8800   [(set (match_operand:TI2 0 "int_reg_operand" "")
8801         (match_operand:TI2 1 "const_scalar_int_operand" ""))]
8802   "TARGET_POWERPC64
8803    && (VECTOR_MEM_NONE_P (<MODE>mode)
8804        || (reload_completed && INT_REGNO_P (REGNO (operands[0]))))"
8805   [(set (match_dup 2) (match_dup 4))
8806    (set (match_dup 3) (match_dup 5))]
8807   "
8808 {
8809   operands[2] = operand_subword_force (operands[0], WORDS_BIG_ENDIAN == 0,
8810                                        <MODE>mode);
8811   operands[3] = operand_subword_force (operands[0], WORDS_BIG_ENDIAN != 0,
8812                                        <MODE>mode);
8813   if (CONST_WIDE_INT_P (operands[1]))
8814     {
8815       operands[4] = GEN_INT (CONST_WIDE_INT_ELT (operands[1], 1));
8816       operands[5] = GEN_INT (CONST_WIDE_INT_ELT (operands[1], 0));
8817     }
8818   else if (CONST_INT_P (operands[1]))
8819     {
8820       operands[4] = GEN_INT (- (INTVAL (operands[1]) < 0));
8821       operands[5] = operands[1];
8822     }
8823   else
8824     FAIL;
8825 }")
8826
8827 (define_split
8828   [(set (match_operand:TI2 0 "nonimmediate_operand" "")
8829         (match_operand:TI2 1 "input_operand" ""))]
8830   "reload_completed
8831    && gpr_or_gpr_p (operands[0], operands[1])
8832    && !direct_move_p (operands[0], operands[1])
8833    && !quad_load_store_p (operands[0], operands[1])"
8834   [(pc)]
8835 { rs6000_split_multireg_move (operands[0], operands[1]); DONE; })
8836 \f
8837 (define_expand "load_multiple"
8838   [(match_par_dup 3 [(set (match_operand:SI 0 "" "")
8839                           (match_operand:SI 1 "" ""))
8840                      (use (match_operand:SI 2 "" ""))])]
8841   "TARGET_STRING && !TARGET_POWERPC64"
8842   "
8843 {
8844   int regno;
8845   int count;
8846   rtx op1;
8847   int i;
8848
8849   /* Support only loading a constant number of fixed-point registers from
8850      memory and only bother with this if more than two; the machine
8851      doesn't support more than eight.  */
8852   if (GET_CODE (operands[2]) != CONST_INT
8853       || INTVAL (operands[2]) <= 2
8854       || INTVAL (operands[2]) > 8
8855       || GET_CODE (operands[1]) != MEM
8856       || GET_CODE (operands[0]) != REG
8857       || REGNO (operands[0]) >= 32)
8858     FAIL;
8859
8860   count = INTVAL (operands[2]);
8861   regno = REGNO (operands[0]);
8862
8863   operands[3] = gen_rtx_PARALLEL (VOIDmode, rtvec_alloc (count));
8864   op1 = replace_equiv_address (operands[1],
8865                                force_reg (SImode, XEXP (operands[1], 0)));
8866
8867   for (i = 0; i < count; i++)
8868     XVECEXP (operands[3], 0, i)
8869       = gen_rtx_SET (VOIDmode, gen_rtx_REG (SImode, regno + i),
8870                      adjust_address_nv (op1, SImode, i * 4));
8871 }")
8872
8873 (define_insn "*ldmsi8"
8874   [(match_parallel 0 "load_multiple_operation"
8875     [(set (match_operand:SI 2 "gpc_reg_operand" "")
8876           (mem:SI (match_operand:SI 1 "gpc_reg_operand" "b")))
8877      (set (match_operand:SI 3 "gpc_reg_operand" "")
8878           (mem:SI (plus:SI (match_dup 1) (const_int 4))))
8879      (set (match_operand:SI 4 "gpc_reg_operand" "")
8880           (mem:SI (plus:SI (match_dup 1) (const_int 8))))
8881      (set (match_operand:SI 5 "gpc_reg_operand" "")
8882           (mem:SI (plus:SI (match_dup 1) (const_int 12))))
8883      (set (match_operand:SI 6 "gpc_reg_operand" "")
8884           (mem:SI (plus:SI (match_dup 1) (const_int 16))))
8885      (set (match_operand:SI 7 "gpc_reg_operand" "")
8886           (mem:SI (plus:SI (match_dup 1) (const_int 20))))
8887      (set (match_operand:SI 8 "gpc_reg_operand" "")
8888           (mem:SI (plus:SI (match_dup 1) (const_int 24))))
8889      (set (match_operand:SI 9 "gpc_reg_operand" "")
8890           (mem:SI (plus:SI (match_dup 1) (const_int 28))))])]
8891   "TARGET_STRING && XVECLEN (operands[0], 0) == 8"
8892   "*
8893 { return rs6000_output_load_multiple (operands); }"
8894   [(set_attr "type" "load")
8895    (set_attr "update" "yes")
8896    (set_attr "indexed" "yes")
8897    (set_attr "length" "32")])
8898
8899 (define_insn "*ldmsi7"
8900   [(match_parallel 0 "load_multiple_operation"
8901     [(set (match_operand:SI 2 "gpc_reg_operand" "")
8902           (mem:SI (match_operand:SI 1 "gpc_reg_operand" "b")))
8903      (set (match_operand:SI 3 "gpc_reg_operand" "")
8904           (mem:SI (plus:SI (match_dup 1) (const_int 4))))
8905      (set (match_operand:SI 4 "gpc_reg_operand" "")
8906           (mem:SI (plus:SI (match_dup 1) (const_int 8))))
8907      (set (match_operand:SI 5 "gpc_reg_operand" "")
8908           (mem:SI (plus:SI (match_dup 1) (const_int 12))))
8909      (set (match_operand:SI 6 "gpc_reg_operand" "")
8910           (mem:SI (plus:SI (match_dup 1) (const_int 16))))
8911      (set (match_operand:SI 7 "gpc_reg_operand" "")
8912           (mem:SI (plus:SI (match_dup 1) (const_int 20))))
8913      (set (match_operand:SI 8 "gpc_reg_operand" "")
8914           (mem:SI (plus:SI (match_dup 1) (const_int 24))))])]
8915   "TARGET_STRING && XVECLEN (operands[0], 0) == 7"
8916   "*
8917 { return rs6000_output_load_multiple (operands); }"
8918   [(set_attr "type" "load")
8919    (set_attr "update" "yes")
8920    (set_attr "indexed" "yes")
8921    (set_attr "length" "32")])
8922
8923 (define_insn "*ldmsi6"
8924   [(match_parallel 0 "load_multiple_operation"
8925     [(set (match_operand:SI 2 "gpc_reg_operand" "")
8926           (mem:SI (match_operand:SI 1 "gpc_reg_operand" "b")))
8927      (set (match_operand:SI 3 "gpc_reg_operand" "")
8928           (mem:SI (plus:SI (match_dup 1) (const_int 4))))
8929      (set (match_operand:SI 4 "gpc_reg_operand" "")
8930           (mem:SI (plus:SI (match_dup 1) (const_int 8))))
8931      (set (match_operand:SI 5 "gpc_reg_operand" "")
8932           (mem:SI (plus:SI (match_dup 1) (const_int 12))))
8933      (set (match_operand:SI 6 "gpc_reg_operand" "")
8934           (mem:SI (plus:SI (match_dup 1) (const_int 16))))
8935      (set (match_operand:SI 7 "gpc_reg_operand" "")
8936           (mem:SI (plus:SI (match_dup 1) (const_int 20))))])]
8937   "TARGET_STRING && XVECLEN (operands[0], 0) == 6"
8938   "*
8939 { return rs6000_output_load_multiple (operands); }"
8940   [(set_attr "type" "load")
8941    (set_attr "update" "yes")
8942    (set_attr "indexed" "yes")
8943    (set_attr "length" "32")])
8944
8945 (define_insn "*ldmsi5"
8946   [(match_parallel 0 "load_multiple_operation"
8947     [(set (match_operand:SI 2 "gpc_reg_operand" "")
8948           (mem:SI (match_operand:SI 1 "gpc_reg_operand" "b")))
8949      (set (match_operand:SI 3 "gpc_reg_operand" "")
8950           (mem:SI (plus:SI (match_dup 1) (const_int 4))))
8951      (set (match_operand:SI 4 "gpc_reg_operand" "")
8952           (mem:SI (plus:SI (match_dup 1) (const_int 8))))
8953      (set (match_operand:SI 5 "gpc_reg_operand" "")
8954           (mem:SI (plus:SI (match_dup 1) (const_int 12))))
8955      (set (match_operand:SI 6 "gpc_reg_operand" "")
8956           (mem:SI (plus:SI (match_dup 1) (const_int 16))))])]
8957   "TARGET_STRING && XVECLEN (operands[0], 0) == 5"
8958   "*
8959 { return rs6000_output_load_multiple (operands); }"
8960   [(set_attr "type" "load")
8961    (set_attr "update" "yes")
8962    (set_attr "indexed" "yes")
8963    (set_attr "length" "32")])
8964
8965 (define_insn "*ldmsi4"
8966   [(match_parallel 0 "load_multiple_operation"
8967     [(set (match_operand:SI 2 "gpc_reg_operand" "")
8968           (mem:SI (match_operand:SI 1 "gpc_reg_operand" "b")))
8969      (set (match_operand:SI 3 "gpc_reg_operand" "")
8970           (mem:SI (plus:SI (match_dup 1) (const_int 4))))
8971      (set (match_operand:SI 4 "gpc_reg_operand" "")
8972           (mem:SI (plus:SI (match_dup 1) (const_int 8))))
8973      (set (match_operand:SI 5 "gpc_reg_operand" "")
8974           (mem:SI (plus:SI (match_dup 1) (const_int 12))))])]
8975   "TARGET_STRING && XVECLEN (operands[0], 0) == 4"
8976   "*
8977 { return rs6000_output_load_multiple (operands); }"
8978   [(set_attr "type" "load")
8979    (set_attr "update" "yes")
8980    (set_attr "indexed" "yes")
8981    (set_attr "length" "32")])
8982
8983 (define_insn "*ldmsi3"
8984   [(match_parallel 0 "load_multiple_operation"
8985     [(set (match_operand:SI 2 "gpc_reg_operand" "")
8986           (mem:SI (match_operand:SI 1 "gpc_reg_operand" "b")))
8987      (set (match_operand:SI 3 "gpc_reg_operand" "")
8988           (mem:SI (plus:SI (match_dup 1) (const_int 4))))
8989      (set (match_operand:SI 4 "gpc_reg_operand" "")
8990           (mem:SI (plus:SI (match_dup 1) (const_int 8))))])]
8991   "TARGET_STRING && XVECLEN (operands[0], 0) == 3"
8992   "*
8993 { return rs6000_output_load_multiple (operands); }"
8994   [(set_attr "type" "load")
8995    (set_attr "update" "yes")
8996    (set_attr "indexed" "yes")
8997    (set_attr "length" "32")])
8998
8999 (define_expand "store_multiple"
9000   [(match_par_dup 3 [(set (match_operand:SI 0 "" "")
9001                           (match_operand:SI 1 "" ""))
9002                      (clobber (scratch:SI))
9003                      (use (match_operand:SI 2 "" ""))])]
9004   "TARGET_STRING && !TARGET_POWERPC64"
9005   "
9006 {
9007   int regno;
9008   int count;
9009   rtx to;
9010   rtx op0;
9011   int i;
9012
9013   /* Support only storing a constant number of fixed-point registers to
9014      memory and only bother with this if more than two; the machine
9015      doesn't support more than eight.  */
9016   if (GET_CODE (operands[2]) != CONST_INT
9017       || INTVAL (operands[2]) <= 2
9018       || INTVAL (operands[2]) > 8
9019       || GET_CODE (operands[0]) != MEM
9020       || GET_CODE (operands[1]) != REG
9021       || REGNO (operands[1]) >= 32)
9022     FAIL;
9023
9024   count = INTVAL (operands[2]);
9025   regno = REGNO (operands[1]);
9026
9027   operands[3] = gen_rtx_PARALLEL (VOIDmode, rtvec_alloc (count + 1));
9028   to = force_reg (SImode, XEXP (operands[0], 0));
9029   op0 = replace_equiv_address (operands[0], to);
9030
9031   XVECEXP (operands[3], 0, 0)
9032     = gen_rtx_SET (VOIDmode, adjust_address_nv (op0, SImode, 0), operands[1]);
9033   XVECEXP (operands[3], 0, 1) = gen_rtx_CLOBBER (VOIDmode,
9034                                                  gen_rtx_SCRATCH (SImode));
9035
9036   for (i = 1; i < count; i++)
9037     XVECEXP (operands[3], 0, i + 1)
9038       = gen_rtx_SET (VOIDmode,
9039                      adjust_address_nv (op0, SImode, i * 4),
9040                      gen_rtx_REG (SImode, regno + i));
9041 }")
9042
9043 (define_insn "*stmsi8"
9044   [(match_parallel 0 "store_multiple_operation"
9045     [(set (mem:SI (match_operand:SI 1 "gpc_reg_operand" "b"))
9046           (match_operand:SI 2 "gpc_reg_operand" "r"))
9047      (clobber (match_scratch:SI 3 "=X"))
9048      (set (mem:SI (plus:SI (match_dup 1) (const_int 4)))
9049           (match_operand:SI 4 "gpc_reg_operand" "r"))
9050      (set (mem:SI (plus:SI (match_dup 1) (const_int 8)))
9051           (match_operand:SI 5 "gpc_reg_operand" "r"))
9052      (set (mem:SI (plus:SI (match_dup 1) (const_int 12)))
9053           (match_operand:SI 6 "gpc_reg_operand" "r"))
9054      (set (mem:SI (plus:SI (match_dup 1) (const_int 16)))
9055           (match_operand:SI 7 "gpc_reg_operand" "r"))
9056      (set (mem:SI (plus:SI (match_dup 1) (const_int 20)))
9057           (match_operand:SI 8 "gpc_reg_operand" "r"))
9058      (set (mem:SI (plus:SI (match_dup 1) (const_int 24)))
9059           (match_operand:SI 9 "gpc_reg_operand" "r"))
9060      (set (mem:SI (plus:SI (match_dup 1) (const_int 28)))
9061           (match_operand:SI 10 "gpc_reg_operand" "r"))])]
9062   "TARGET_STRING && XVECLEN (operands[0], 0) == 9"
9063   "stswi %2,%1,%O0"
9064   [(set_attr "type" "store")
9065    (set_attr "update" "yes")
9066    (set_attr "indexed" "yes")
9067    (set_attr "cell_micro" "always")])
9068
9069 (define_insn "*stmsi7"
9070   [(match_parallel 0 "store_multiple_operation"
9071     [(set (mem:SI (match_operand:SI 1 "gpc_reg_operand" "b"))
9072           (match_operand:SI 2 "gpc_reg_operand" "r"))
9073      (clobber (match_scratch:SI 3 "=X"))
9074      (set (mem:SI (plus:SI (match_dup 1) (const_int 4)))
9075           (match_operand:SI 4 "gpc_reg_operand" "r"))
9076      (set (mem:SI (plus:SI (match_dup 1) (const_int 8)))
9077           (match_operand:SI 5 "gpc_reg_operand" "r"))
9078      (set (mem:SI (plus:SI (match_dup 1) (const_int 12)))
9079           (match_operand:SI 6 "gpc_reg_operand" "r"))
9080      (set (mem:SI (plus:SI (match_dup 1) (const_int 16)))
9081           (match_operand:SI 7 "gpc_reg_operand" "r"))
9082      (set (mem:SI (plus:SI (match_dup 1) (const_int 20)))
9083           (match_operand:SI 8 "gpc_reg_operand" "r"))
9084      (set (mem:SI (plus:SI (match_dup 1) (const_int 24)))
9085           (match_operand:SI 9 "gpc_reg_operand" "r"))])]
9086   "TARGET_STRING && XVECLEN (operands[0], 0) == 8"
9087   "stswi %2,%1,%O0"
9088   [(set_attr "type" "store")
9089    (set_attr "update" "yes")
9090    (set_attr "indexed" "yes")
9091    (set_attr "cell_micro" "always")])
9092
9093 (define_insn "*stmsi6"
9094   [(match_parallel 0 "store_multiple_operation"
9095     [(set (mem:SI (match_operand:SI 1 "gpc_reg_operand" "b"))
9096           (match_operand:SI 2 "gpc_reg_operand" "r"))
9097      (clobber (match_scratch:SI 3 "=X"))
9098      (set (mem:SI (plus:SI (match_dup 1) (const_int 4)))
9099           (match_operand:SI 4 "gpc_reg_operand" "r"))
9100      (set (mem:SI (plus:SI (match_dup 1) (const_int 8)))
9101           (match_operand:SI 5 "gpc_reg_operand" "r"))
9102      (set (mem:SI (plus:SI (match_dup 1) (const_int 12)))
9103           (match_operand:SI 6 "gpc_reg_operand" "r"))
9104      (set (mem:SI (plus:SI (match_dup 1) (const_int 16)))
9105           (match_operand:SI 7 "gpc_reg_operand" "r"))
9106      (set (mem:SI (plus:SI (match_dup 1) (const_int 20)))
9107           (match_operand:SI 8 "gpc_reg_operand" "r"))])]
9108   "TARGET_STRING && XVECLEN (operands[0], 0) == 7"
9109   "stswi %2,%1,%O0"
9110   [(set_attr "type" "store")
9111    (set_attr "update" "yes")
9112    (set_attr "indexed" "yes")
9113    (set_attr "cell_micro" "always")])
9114
9115 (define_insn "*stmsi5"
9116   [(match_parallel 0 "store_multiple_operation"
9117     [(set (mem:SI (match_operand:SI 1 "gpc_reg_operand" "b"))
9118           (match_operand:SI 2 "gpc_reg_operand" "r"))
9119      (clobber (match_scratch:SI 3 "=X"))
9120      (set (mem:SI (plus:SI (match_dup 1) (const_int 4)))
9121           (match_operand:SI 4 "gpc_reg_operand" "r"))
9122      (set (mem:SI (plus:SI (match_dup 1) (const_int 8)))
9123           (match_operand:SI 5 "gpc_reg_operand" "r"))
9124      (set (mem:SI (plus:SI (match_dup 1) (const_int 12)))
9125           (match_operand:SI 6 "gpc_reg_operand" "r"))
9126      (set (mem:SI (plus:SI (match_dup 1) (const_int 16)))
9127           (match_operand:SI 7 "gpc_reg_operand" "r"))])]
9128   "TARGET_STRING && XVECLEN (operands[0], 0) == 6"
9129   "stswi %2,%1,%O0"
9130   [(set_attr "type" "store")
9131    (set_attr "update" "yes")
9132    (set_attr "indexed" "yes")
9133    (set_attr "cell_micro" "always")])
9134
9135 (define_insn "*stmsi4"
9136   [(match_parallel 0 "store_multiple_operation"
9137     [(set (mem:SI (match_operand:SI 1 "gpc_reg_operand" "b"))
9138           (match_operand:SI 2 "gpc_reg_operand" "r"))
9139      (clobber (match_scratch:SI 3 "=X"))
9140      (set (mem:SI (plus:SI (match_dup 1) (const_int 4)))
9141           (match_operand:SI 4 "gpc_reg_operand" "r"))
9142      (set (mem:SI (plus:SI (match_dup 1) (const_int 8)))
9143           (match_operand:SI 5 "gpc_reg_operand" "r"))
9144      (set (mem:SI (plus:SI (match_dup 1) (const_int 12)))
9145           (match_operand:SI 6 "gpc_reg_operand" "r"))])]
9146   "TARGET_STRING && XVECLEN (operands[0], 0) == 5"
9147   "stswi %2,%1,%O0"
9148   [(set_attr "type" "store")
9149    (set_attr "update" "yes")
9150    (set_attr "indexed" "yes")
9151    (set_attr "cell_micro" "always")])
9152
9153 (define_insn "*stmsi3"
9154   [(match_parallel 0 "store_multiple_operation"
9155     [(set (mem:SI (match_operand:SI 1 "gpc_reg_operand" "b"))
9156           (match_operand:SI 2 "gpc_reg_operand" "r"))
9157      (clobber (match_scratch:SI 3 "=X"))
9158      (set (mem:SI (plus:SI (match_dup 1) (const_int 4)))
9159           (match_operand:SI 4 "gpc_reg_operand" "r"))
9160      (set (mem:SI (plus:SI (match_dup 1) (const_int 8)))
9161           (match_operand:SI 5 "gpc_reg_operand" "r"))])]
9162   "TARGET_STRING && XVECLEN (operands[0], 0) == 4"
9163   "stswi %2,%1,%O0"
9164   [(set_attr "type" "store")
9165    (set_attr "update" "yes")
9166    (set_attr "indexed" "yes")
9167    (set_attr "cell_micro" "always")])
9168 \f
9169 (define_expand "setmemsi"
9170   [(parallel [(set (match_operand:BLK 0 "" "")
9171                    (match_operand 2 "const_int_operand" ""))
9172               (use (match_operand:SI 1 "" ""))
9173               (use (match_operand:SI 3 "" ""))])]
9174   ""
9175   "
9176 {
9177   /* If value to set is not zero, use the library routine.  */
9178   if (operands[2] != const0_rtx)
9179     FAIL;
9180
9181   if (expand_block_clear (operands))
9182     DONE;
9183   else
9184     FAIL;
9185 }")
9186
9187 ;; String/block move insn.
9188 ;; Argument 0 is the destination
9189 ;; Argument 1 is the source
9190 ;; Argument 2 is the length
9191 ;; Argument 3 is the alignment
9192
9193 (define_expand "movmemsi"
9194   [(parallel [(set (match_operand:BLK 0 "" "")
9195                    (match_operand:BLK 1 "" ""))
9196               (use (match_operand:SI 2 "" ""))
9197               (use (match_operand:SI 3 "" ""))])]
9198   ""
9199   "
9200 {
9201   if (expand_block_move (operands))
9202     DONE;
9203   else
9204     FAIL;
9205 }")
9206
9207 ;; Move up to 32 bytes at a time.  The fixed registers are needed because the
9208 ;; register allocator doesn't have a clue about allocating 8 word registers.
9209 ;; rD/rS = r5 is preferred, efficient form.
9210 (define_expand "movmemsi_8reg"
9211   [(parallel [(set (match_operand 0 "" "")
9212                    (match_operand 1 "" ""))
9213               (use (match_operand 2 "" ""))
9214               (use (match_operand 3 "" ""))
9215               (clobber (reg:SI  5))
9216               (clobber (reg:SI  6))
9217               (clobber (reg:SI  7))
9218               (clobber (reg:SI  8))
9219               (clobber (reg:SI  9))
9220               (clobber (reg:SI 10))
9221               (clobber (reg:SI 11))
9222               (clobber (reg:SI 12))
9223               (clobber (match_scratch:SI 4 ""))])]
9224   "TARGET_STRING"
9225   "")
9226
9227 (define_insn ""
9228   [(set (mem:BLK (match_operand:P 0 "gpc_reg_operand" "b"))
9229         (mem:BLK (match_operand:P 1 "gpc_reg_operand" "b")))
9230    (use (match_operand:SI 2 "immediate_operand" "i"))
9231    (use (match_operand:SI 3 "immediate_operand" "i"))
9232    (clobber (match_operand:SI 4 "gpc_reg_operand" "=&r"))
9233    (clobber (reg:SI  6))
9234    (clobber (reg:SI  7))
9235    (clobber (reg:SI  8))
9236    (clobber (reg:SI  9))
9237    (clobber (reg:SI 10))
9238    (clobber (reg:SI 11))
9239    (clobber (reg:SI 12))
9240    (clobber (match_scratch:SI 5 "=X"))]
9241   "TARGET_STRING
9242    && ((INTVAL (operands[2]) > 24 && INTVAL (operands[2]) < 32)
9243        || INTVAL (operands[2]) == 0)
9244    && (REGNO (operands[0]) < 5 || REGNO (operands[0]) > 12)
9245    && (REGNO (operands[1]) < 5 || REGNO (operands[1]) > 12)
9246    && REGNO (operands[4]) == 5"
9247   "lswi %4,%1,%2\;stswi %4,%0,%2"
9248   [(set_attr "type" "store")
9249    (set_attr "update" "yes")
9250    (set_attr "indexed" "yes")
9251    (set_attr "cell_micro" "always")
9252    (set_attr "length" "8")])
9253
9254 ;; Move up to 24 bytes at a time.  The fixed registers are needed because the
9255 ;; register allocator doesn't have a clue about allocating 6 word registers.
9256 ;; rD/rS = r5 is preferred, efficient form.
9257 (define_expand "movmemsi_6reg"
9258   [(parallel [(set (match_operand 0 "" "")
9259                    (match_operand 1 "" ""))
9260               (use (match_operand 2 "" ""))
9261               (use (match_operand 3 "" ""))
9262               (clobber (reg:SI  5))
9263               (clobber (reg:SI  6))
9264               (clobber (reg:SI  7))
9265               (clobber (reg:SI  8))
9266               (clobber (reg:SI  9))
9267               (clobber (reg:SI 10))
9268               (clobber (match_scratch:SI 4 ""))])]
9269   "TARGET_STRING"
9270   "")
9271
9272 (define_insn ""
9273   [(set (mem:BLK (match_operand:P 0 "gpc_reg_operand" "b"))
9274         (mem:BLK (match_operand:P 1 "gpc_reg_operand" "b")))
9275    (use (match_operand:SI 2 "immediate_operand" "i"))
9276    (use (match_operand:SI 3 "immediate_operand" "i"))
9277    (clobber (match_operand:SI 4 "gpc_reg_operand" "=&r"))
9278    (clobber (reg:SI  6))
9279    (clobber (reg:SI  7))
9280    (clobber (reg:SI  8))
9281    (clobber (reg:SI  9))
9282    (clobber (reg:SI 10))
9283    (clobber (match_scratch:SI 5 "=X"))]
9284   "TARGET_STRING
9285    && INTVAL (operands[2]) > 16 && INTVAL (operands[2]) <= 32
9286    && (REGNO (operands[0]) < 5 || REGNO (operands[0]) > 10)
9287    && (REGNO (operands[1]) < 5 || REGNO (operands[1]) > 10)
9288    && REGNO (operands[4]) == 5"
9289   "lswi %4,%1,%2\;stswi %4,%0,%2"
9290   [(set_attr "type" "store")
9291    (set_attr "update" "yes")
9292    (set_attr "indexed" "yes")
9293    (set_attr "cell_micro" "always")
9294    (set_attr "length" "8")])
9295
9296 ;; Move up to 16 bytes at a time, using 4 fixed registers to avoid spill
9297 ;; problems with TImode.
9298 ;; rD/rS = r5 is preferred, efficient form.
9299 (define_expand "movmemsi_4reg"
9300   [(parallel [(set (match_operand 0 "" "")
9301                    (match_operand 1 "" ""))
9302               (use (match_operand 2 "" ""))
9303               (use (match_operand 3 "" ""))
9304               (clobber (reg:SI 5))
9305               (clobber (reg:SI 6))
9306               (clobber (reg:SI 7))
9307               (clobber (reg:SI 8))
9308               (clobber (match_scratch:SI 4 ""))])]
9309   "TARGET_STRING"
9310   "")
9311
9312 (define_insn ""
9313   [(set (mem:BLK (match_operand:P 0 "gpc_reg_operand" "b"))
9314         (mem:BLK (match_operand:P 1 "gpc_reg_operand" "b")))
9315    (use (match_operand:SI 2 "immediate_operand" "i"))
9316    (use (match_operand:SI 3 "immediate_operand" "i"))
9317    (clobber (match_operand:SI 4 "gpc_reg_operand" "=&r"))
9318    (clobber (reg:SI 6))
9319    (clobber (reg:SI 7))
9320    (clobber (reg:SI 8))
9321    (clobber (match_scratch:SI 5 "=X"))]
9322   "TARGET_STRING
9323    && INTVAL (operands[2]) > 8 && INTVAL (operands[2]) <= 16
9324    && (REGNO (operands[0]) < 5 || REGNO (operands[0]) > 8)
9325    && (REGNO (operands[1]) < 5 || REGNO (operands[1]) > 8)
9326    && REGNO (operands[4]) == 5"
9327   "lswi %4,%1,%2\;stswi %4,%0,%2"
9328   [(set_attr "type" "store")
9329    (set_attr "update" "yes")
9330    (set_attr "indexed" "yes")
9331    (set_attr "cell_micro" "always")
9332    (set_attr "length" "8")])
9333
9334 ;; Move up to 8 bytes at a time.
9335 (define_expand "movmemsi_2reg"
9336   [(parallel [(set (match_operand 0 "" "")
9337                    (match_operand 1 "" ""))
9338               (use (match_operand 2 "" ""))
9339               (use (match_operand 3 "" ""))
9340               (clobber (match_scratch:DI 4 ""))
9341               (clobber (match_scratch:SI 5 ""))])]
9342   "TARGET_STRING && ! TARGET_POWERPC64"
9343   "")
9344
9345 (define_insn ""
9346   [(set (mem:BLK (match_operand:SI 0 "gpc_reg_operand" "b"))
9347         (mem:BLK (match_operand:SI 1 "gpc_reg_operand" "b")))
9348    (use (match_operand:SI 2 "immediate_operand" "i"))
9349    (use (match_operand:SI 3 "immediate_operand" "i"))
9350    (clobber (match_scratch:DI 4 "=&r"))
9351    (clobber (match_scratch:SI 5 "=X"))]
9352   "TARGET_STRING && ! TARGET_POWERPC64
9353    && INTVAL (operands[2]) > 4 && INTVAL (operands[2]) <= 8"
9354   "lswi %4,%1,%2\;stswi %4,%0,%2"
9355   [(set_attr "type" "store")
9356    (set_attr "update" "yes")
9357    (set_attr "indexed" "yes")
9358    (set_attr "cell_micro" "always")
9359    (set_attr "length" "8")])
9360
9361 ;; Move up to 4 bytes at a time.
9362 (define_expand "movmemsi_1reg"
9363   [(parallel [(set (match_operand 0 "" "")
9364                    (match_operand 1 "" ""))
9365               (use (match_operand 2 "" ""))
9366               (use (match_operand 3 "" ""))
9367               (clobber (match_scratch:SI 4 ""))
9368               (clobber (match_scratch:SI 5 ""))])]
9369   "TARGET_STRING"
9370   "")
9371
9372 (define_insn ""
9373   [(set (mem:BLK (match_operand:P 0 "gpc_reg_operand" "b"))
9374         (mem:BLK (match_operand:P 1 "gpc_reg_operand" "b")))
9375    (use (match_operand:SI 2 "immediate_operand" "i"))
9376    (use (match_operand:SI 3 "immediate_operand" "i"))
9377    (clobber (match_scratch:SI 4 "=&r"))
9378    (clobber (match_scratch:SI 5 "=X"))]
9379   "TARGET_STRING && INTVAL (operands[2]) > 0 && INTVAL (operands[2]) <= 4"
9380   "lswi %4,%1,%2\;stswi %4,%0,%2"
9381   [(set_attr "type" "store")
9382    (set_attr "update" "yes")
9383    (set_attr "indexed" "yes")
9384    (set_attr "cell_micro" "always")
9385    (set_attr "length" "8")])
9386 \f
9387 ;; Define insns that do load or store with update.  Some of these we can
9388 ;; get by using pre-decrement or pre-increment, but the hardware can also
9389 ;; do cases where the increment is not the size of the object.
9390 ;;
9391 ;; In all these cases, we use operands 0 and 1 for the register being
9392 ;; incremented because those are the operands that local-alloc will
9393 ;; tie and these are the pair most likely to be tieable (and the ones
9394 ;; that will benefit the most).
9395
9396 (define_insn "*movdi_update1"
9397   [(set (match_operand:DI 3 "gpc_reg_operand" "=r,r")
9398         (mem:DI (plus:DI (match_operand:DI 1 "gpc_reg_operand" "0,0")
9399                          (match_operand:DI 2 "reg_or_aligned_short_operand" "r,I"))))
9400    (set (match_operand:DI 0 "gpc_reg_operand" "=b,b")
9401         (plus:DI (match_dup 1) (match_dup 2)))]
9402   "TARGET_POWERPC64 && TARGET_UPDATE
9403    && (!avoiding_indexed_address_p (DImode)
9404        || !gpc_reg_operand (operands[2], DImode))"
9405   "@
9406    ldux %3,%0,%2
9407    ldu %3,%2(%0)"
9408   [(set_attr "type" "load")
9409    (set_attr "update" "yes")
9410    (set_attr "indexed" "yes,no")])
9411
9412 (define_insn "movdi_<mode>_update"
9413   [(set (mem:DI (plus:P (match_operand:P 1 "gpc_reg_operand" "0,0")
9414                          (match_operand:P 2 "reg_or_aligned_short_operand" "r,I")))
9415         (match_operand:DI 3 "gpc_reg_operand" "r,r"))
9416    (set (match_operand:P 0 "gpc_reg_operand" "=b,b")
9417         (plus:P (match_dup 1) (match_dup 2)))]
9418   "TARGET_POWERPC64 && TARGET_UPDATE
9419    && (!avoiding_indexed_address_p (Pmode)
9420        || !gpc_reg_operand (operands[2], Pmode)
9421        || (REG_P (operands[0])
9422            && REGNO (operands[0]) == STACK_POINTER_REGNUM))"
9423   "@
9424    stdux %3,%0,%2
9425    stdu %3,%2(%0)"
9426   [(set_attr "type" "store")
9427    (set_attr "update" "yes")
9428    (set_attr "indexed" "yes,no")])
9429
9430 ;; This pattern is only conditional on TARGET_POWERPC64, as it is
9431 ;; needed for stack allocation, even if the user passes -mno-update.
9432 (define_insn "movdi_<mode>_update_stack"
9433   [(set (mem:DI (plus:P (match_operand:P 1 "gpc_reg_operand" "0,0")
9434                          (match_operand:P 2 "reg_or_aligned_short_operand" "r,I")))
9435         (match_operand:DI 3 "gpc_reg_operand" "r,r"))
9436    (set (match_operand:P 0 "gpc_reg_operand" "=b,b")
9437         (plus:P (match_dup 1) (match_dup 2)))]
9438   "TARGET_POWERPC64"
9439   "@
9440    stdux %3,%0,%2
9441    stdu %3,%2(%0)"
9442   [(set_attr "type" "store")
9443    (set_attr "update" "yes")
9444    (set_attr "indexed" "yes,no")])
9445
9446 (define_insn "*movsi_update1"
9447   [(set (match_operand:SI 3 "gpc_reg_operand" "=r,r")
9448         (mem:SI (plus:SI (match_operand:SI 1 "gpc_reg_operand" "0,0")
9449                          (match_operand:SI 2 "reg_or_short_operand" "r,I"))))
9450    (set (match_operand:SI 0 "gpc_reg_operand" "=b,b")
9451         (plus:SI (match_dup 1) (match_dup 2)))]
9452   "TARGET_UPDATE
9453    && (!avoiding_indexed_address_p (SImode)
9454        || !gpc_reg_operand (operands[2], SImode))"
9455   "@
9456    lwzux %3,%0,%2
9457    lwzu %3,%2(%0)"
9458   [(set_attr "type" "load")
9459    (set_attr "update" "yes")
9460    (set_attr "indexed" "yes,no")])
9461
9462 (define_insn "*movsi_update2"
9463   [(set (match_operand:DI 3 "gpc_reg_operand" "=r")
9464         (sign_extend:DI
9465          (mem:SI (plus:DI (match_operand:DI 1 "gpc_reg_operand" "0")
9466                           (match_operand:DI 2 "gpc_reg_operand" "r")))))
9467    (set (match_operand:DI 0 "gpc_reg_operand" "=b")
9468         (plus:DI (match_dup 1) (match_dup 2)))]
9469   "TARGET_POWERPC64 && rs6000_gen_cell_microcode
9470    && !avoiding_indexed_address_p (DImode)"
9471   "lwaux %3,%0,%2"
9472   [(set_attr "type" "load")
9473    (set_attr "sign_extend" "yes")
9474    (set_attr "update" "yes")
9475    (set_attr "indexed" "yes")])
9476
9477 (define_insn "movsi_update"
9478   [(set (mem:SI (plus:SI (match_operand:SI 1 "gpc_reg_operand" "0,0")
9479                          (match_operand:SI 2 "reg_or_short_operand" "r,I")))
9480         (match_operand:SI 3 "gpc_reg_operand" "r,r"))
9481    (set (match_operand:SI 0 "gpc_reg_operand" "=b,b")
9482         (plus:SI (match_dup 1) (match_dup 2)))]
9483   "TARGET_UPDATE
9484    && (!avoiding_indexed_address_p (SImode)
9485        || !gpc_reg_operand (operands[2], SImode)
9486        || (REG_P (operands[0])
9487            && REGNO (operands[0]) == STACK_POINTER_REGNUM))"
9488   "@
9489    stwux %3,%0,%2
9490    stwu %3,%2(%0)"
9491   [(set_attr "type" "store")
9492    (set_attr "update" "yes")
9493    (set_attr "indexed" "yes,no")])
9494
9495 ;; This is an unconditional pattern; needed for stack allocation, even
9496 ;; if the user passes -mno-update.
9497 (define_insn "movsi_update_stack"
9498   [(set (mem:SI (plus:SI (match_operand:SI 1 "gpc_reg_operand" "0,0")
9499                          (match_operand:SI 2 "reg_or_short_operand" "r,I")))
9500         (match_operand:SI 3 "gpc_reg_operand" "r,r"))
9501    (set (match_operand:SI 0 "gpc_reg_operand" "=b,b")
9502         (plus:SI (match_dup 1) (match_dup 2)))]
9503   ""
9504   "@
9505    stwux %3,%0,%2
9506    stwu %3,%2(%0)"
9507   [(set_attr "type" "store")
9508    (set_attr "update" "yes")
9509    (set_attr "indexed" "yes,no")])
9510
9511 (define_insn "*movhi_update1"
9512   [(set (match_operand:HI 3 "gpc_reg_operand" "=r,r")
9513         (mem:HI (plus:SI (match_operand:SI 1 "gpc_reg_operand" "0,0")
9514                          (match_operand:SI 2 "reg_or_short_operand" "r,I"))))
9515    (set (match_operand:SI 0 "gpc_reg_operand" "=b,b")
9516         (plus:SI (match_dup 1) (match_dup 2)))]
9517   "TARGET_UPDATE
9518    && (!avoiding_indexed_address_p (SImode)
9519        || !gpc_reg_operand (operands[2], SImode))"
9520   "@
9521    lhzux %3,%0,%2
9522    lhzu %3,%2(%0)"
9523   [(set_attr "type" "load")
9524    (set_attr "update" "yes")
9525    (set_attr "indexed" "yes,no")])
9526
9527 (define_insn "*movhi_update2"
9528   [(set (match_operand:SI 3 "gpc_reg_operand" "=r,r")
9529         (zero_extend:SI
9530          (mem:HI (plus:SI (match_operand:SI 1 "gpc_reg_operand" "0,0")
9531                           (match_operand:SI 2 "reg_or_short_operand" "r,I")))))
9532    (set (match_operand:SI 0 "gpc_reg_operand" "=b,b")
9533         (plus:SI (match_dup 1) (match_dup 2)))]
9534   "TARGET_UPDATE
9535    && (!avoiding_indexed_address_p (SImode)
9536        || !gpc_reg_operand (operands[2], SImode))"
9537   "@
9538    lhzux %3,%0,%2
9539    lhzu %3,%2(%0)"
9540   [(set_attr "type" "load")
9541    (set_attr "update" "yes")
9542    (set_attr "indexed" "yes,no")])
9543
9544 (define_insn "*movhi_update3"
9545   [(set (match_operand:SI 3 "gpc_reg_operand" "=r,r")
9546         (sign_extend:SI
9547          (mem:HI (plus:SI (match_operand:SI 1 "gpc_reg_operand" "0,0")
9548                           (match_operand:SI 2 "reg_or_short_operand" "r,I")))))
9549    (set (match_operand:SI 0 "gpc_reg_operand" "=b,b")
9550         (plus:SI (match_dup 1) (match_dup 2)))]
9551   "TARGET_UPDATE && rs6000_gen_cell_microcode
9552    && (!avoiding_indexed_address_p (SImode)
9553        || !gpc_reg_operand (operands[2], SImode))"
9554   "@
9555    lhaux %3,%0,%2
9556    lhau %3,%2(%0)"
9557   [(set_attr "type" "load")
9558    (set_attr "sign_extend" "yes")
9559    (set_attr "update" "yes")
9560    (set_attr "indexed" "yes,no")])
9561
9562 (define_insn "*movhi_update4"
9563   [(set (mem:HI (plus:SI (match_operand:SI 1 "gpc_reg_operand" "0,0")
9564                          (match_operand:SI 2 "reg_or_short_operand" "r,I")))
9565         (match_operand:HI 3 "gpc_reg_operand" "r,r"))
9566    (set (match_operand:SI 0 "gpc_reg_operand" "=b,b")
9567         (plus:SI (match_dup 1) (match_dup 2)))]
9568   "TARGET_UPDATE
9569    && (!avoiding_indexed_address_p (SImode)
9570        || !gpc_reg_operand (operands[2], SImode))"
9571   "@
9572    sthux %3,%0,%2
9573    sthu %3,%2(%0)"
9574   [(set_attr "type" "store")
9575    (set_attr "update" "yes")
9576    (set_attr "indexed" "yes,no")])
9577
9578 (define_insn "*movqi_update1"
9579   [(set (match_operand:QI 3 "gpc_reg_operand" "=r,r")
9580         (mem:QI (plus:SI (match_operand:SI 1 "gpc_reg_operand" "0,0")
9581                          (match_operand:SI 2 "reg_or_short_operand" "r,I"))))
9582    (set (match_operand:SI 0 "gpc_reg_operand" "=b,b")
9583         (plus:SI (match_dup 1) (match_dup 2)))]
9584   "TARGET_UPDATE
9585    && (!avoiding_indexed_address_p (SImode)
9586        || !gpc_reg_operand (operands[2], SImode))"
9587   "@
9588    lbzux %3,%0,%2
9589    lbzu %3,%2(%0)"
9590   [(set_attr "type" "load")
9591    (set_attr "update" "yes")
9592    (set_attr "indexed" "yes,no")])
9593
9594 (define_insn "*movqi_update2"
9595   [(set (match_operand:SI 3 "gpc_reg_operand" "=r,r")
9596         (zero_extend:SI
9597          (mem:QI (plus:SI (match_operand:SI 1 "gpc_reg_operand" "0,0")
9598                           (match_operand:SI 2 "reg_or_short_operand" "r,I")))))
9599    (set (match_operand:SI 0 "gpc_reg_operand" "=b,b")
9600         (plus:SI (match_dup 1) (match_dup 2)))]
9601   "TARGET_UPDATE
9602    && (!avoiding_indexed_address_p (SImode)
9603        || !gpc_reg_operand (operands[2], SImode))"
9604   "@
9605    lbzux %3,%0,%2
9606    lbzu %3,%2(%0)"
9607   [(set_attr "type" "load")
9608    (set_attr "update" "yes")
9609    (set_attr "indexed" "yes,no")])
9610
9611 (define_insn "*movqi_update3"
9612   [(set (mem:QI (plus:SI (match_operand:SI 1 "gpc_reg_operand" "0,0")
9613                          (match_operand:SI 2 "reg_or_short_operand" "r,I")))
9614         (match_operand:QI 3 "gpc_reg_operand" "r,r"))
9615    (set (match_operand:SI 0 "gpc_reg_operand" "=b,b")
9616         (plus:SI (match_dup 1) (match_dup 2)))]
9617   "TARGET_UPDATE
9618    && (!avoiding_indexed_address_p (SImode)
9619        || !gpc_reg_operand (operands[2], SImode))"
9620   "@
9621    stbux %3,%0,%2
9622    stbu %3,%2(%0)"
9623   [(set_attr "type" "store")
9624    (set_attr "update" "yes")
9625    (set_attr "indexed" "yes,no")])
9626
9627 (define_insn "*movsf_update1"
9628   [(set (match_operand:SF 3 "gpc_reg_operand" "=f,f")
9629         (mem:SF (plus:SI (match_operand:SI 1 "gpc_reg_operand" "0,0")
9630                          (match_operand:SI 2 "reg_or_short_operand" "r,I"))))
9631    (set (match_operand:SI 0 "gpc_reg_operand" "=b,b")
9632         (plus:SI (match_dup 1) (match_dup 2)))]
9633   "TARGET_HARD_FLOAT && TARGET_FPRS && TARGET_SINGLE_FLOAT && TARGET_UPDATE
9634    && (!avoiding_indexed_address_p (SImode)
9635        || !gpc_reg_operand (operands[2], SImode))"
9636   "@
9637    lfsux %3,%0,%2
9638    lfsu %3,%2(%0)"
9639   [(set_attr "type" "fpload")
9640    (set_attr "update" "yes")
9641    (set_attr "indexed" "yes,no")])
9642
9643 (define_insn "*movsf_update2"
9644   [(set (mem:SF (plus:SI (match_operand:SI 1 "gpc_reg_operand" "0,0")
9645                          (match_operand:SI 2 "reg_or_short_operand" "r,I")))
9646         (match_operand:SF 3 "gpc_reg_operand" "f,f"))
9647    (set (match_operand:SI 0 "gpc_reg_operand" "=b,b")
9648         (plus:SI (match_dup 1) (match_dup 2)))]
9649   "TARGET_HARD_FLOAT && TARGET_FPRS && TARGET_SINGLE_FLOAT && TARGET_UPDATE
9650    && (!avoiding_indexed_address_p (SImode)
9651        || !gpc_reg_operand (operands[2], SImode))"
9652   "@
9653    stfsux %3,%0,%2
9654    stfsu %3,%2(%0)"
9655   [(set_attr "type" "fpstore")
9656    (set_attr "update" "yes")
9657    (set_attr "indexed" "yes,no")])
9658
9659 (define_insn "*movsf_update3"
9660   [(set (match_operand:SF 3 "gpc_reg_operand" "=r,r")
9661         (mem:SF (plus:SI (match_operand:SI 1 "gpc_reg_operand" "0,0")
9662                          (match_operand:SI 2 "reg_or_short_operand" "r,I"))))
9663    (set (match_operand:SI 0 "gpc_reg_operand" "=b,b")
9664         (plus:SI (match_dup 1) (match_dup 2)))]
9665   "(TARGET_SOFT_FLOAT || !TARGET_FPRS) && TARGET_UPDATE
9666    && (!avoiding_indexed_address_p (SImode)
9667        || !gpc_reg_operand (operands[2], SImode))"
9668   "@
9669    lwzux %3,%0,%2
9670    lwzu %3,%2(%0)"
9671   [(set_attr "type" "load")
9672    (set_attr "update" "yes")
9673    (set_attr "indexed" "yes,no")])
9674
9675 (define_insn "*movsf_update4"
9676   [(set (mem:SF (plus:SI (match_operand:SI 1 "gpc_reg_operand" "0,0")
9677                          (match_operand:SI 2 "reg_or_short_operand" "r,I")))
9678         (match_operand:SF 3 "gpc_reg_operand" "r,r"))
9679    (set (match_operand:SI 0 "gpc_reg_operand" "=b,b")
9680         (plus:SI (match_dup 1) (match_dup 2)))]
9681   "(TARGET_SOFT_FLOAT || !TARGET_FPRS) && TARGET_UPDATE
9682    && (!avoiding_indexed_address_p (SImode)
9683        || !gpc_reg_operand (operands[2], SImode))"
9684   "@
9685    stwux %3,%0,%2
9686    stwu %3,%2(%0)"
9687   [(set_attr "type" "store")
9688    (set_attr "update" "yes")
9689    (set_attr "indexed" "yes,no")])
9690
9691 (define_insn "*movdf_update1"
9692   [(set (match_operand:DF 3 "gpc_reg_operand" "=d,d")
9693         (mem:DF (plus:SI (match_operand:SI 1 "gpc_reg_operand" "0,0")
9694                          (match_operand:SI 2 "reg_or_short_operand" "r,I"))))
9695    (set (match_operand:SI 0 "gpc_reg_operand" "=b,b")
9696         (plus:SI (match_dup 1) (match_dup 2)))]
9697   "TARGET_HARD_FLOAT && TARGET_FPRS && TARGET_DOUBLE_FLOAT && TARGET_UPDATE
9698    && (!avoiding_indexed_address_p (SImode)
9699        || !gpc_reg_operand (operands[2], SImode))"
9700   "@
9701    lfdux %3,%0,%2
9702    lfdu %3,%2(%0)"
9703   [(set_attr "type" "fpload")
9704    (set_attr "update" "yes")
9705    (set_attr "indexed" "yes,no")])
9706
9707 (define_insn "*movdf_update2"
9708   [(set (mem:DF (plus:SI (match_operand:SI 1 "gpc_reg_operand" "0,0")
9709                          (match_operand:SI 2 "reg_or_short_operand" "r,I")))
9710         (match_operand:DF 3 "gpc_reg_operand" "d,d"))
9711    (set (match_operand:SI 0 "gpc_reg_operand" "=b,b")
9712         (plus:SI (match_dup 1) (match_dup 2)))]
9713   "TARGET_HARD_FLOAT && TARGET_FPRS && TARGET_DOUBLE_FLOAT && TARGET_UPDATE
9714    && (!avoiding_indexed_address_p (SImode)
9715        || !gpc_reg_operand (operands[2], SImode))"
9716   "@
9717    stfdux %3,%0,%2
9718    stfdu %3,%2(%0)"
9719   [(set_attr "type" "fpstore")
9720    (set_attr "update" "yes")
9721    (set_attr "indexed" "yes,no")])
9722
9723
9724 ;; After inserting conditional returns we can sometimes have
9725 ;; unnecessary register moves.  Unfortunately we cannot have a
9726 ;; modeless peephole here, because some single SImode sets have early
9727 ;; clobber outputs.  Although those sets expand to multi-ppc-insn
9728 ;; sequences, using get_attr_length here will smash the operands
9729 ;; array.  Neither is there an early_cobbler_p predicate.
9730 ;; Disallow subregs for E500 so we don't munge frob_di_df_2.
9731 (define_peephole2
9732   [(set (match_operand:DF 0 "gpc_reg_operand" "")
9733         (match_operand:DF 1 "any_operand" ""))
9734    (set (match_operand:DF 2 "gpc_reg_operand" "")
9735         (match_dup 0))]
9736   "!(TARGET_E500_DOUBLE && GET_CODE (operands[2]) == SUBREG)
9737    && peep2_reg_dead_p (2, operands[0])"
9738   [(set (match_dup 2) (match_dup 1))])
9739
9740 (define_peephole2
9741   [(set (match_operand:SF 0 "gpc_reg_operand" "")
9742         (match_operand:SF 1 "any_operand" ""))
9743    (set (match_operand:SF 2 "gpc_reg_operand" "")
9744         (match_dup 0))]
9745   "peep2_reg_dead_p (2, operands[0])"
9746   [(set (match_dup 2) (match_dup 1))])
9747
9748 \f
9749 ;; TLS support.
9750
9751 ;; Mode attributes for different ABIs.
9752 (define_mode_iterator TLSmode [(SI "! TARGET_64BIT") (DI "TARGET_64BIT")])
9753 (define_mode_attr tls_abi_suffix [(SI "32") (DI "64")])
9754 (define_mode_attr tls_sysv_suffix [(SI "si") (DI "di")])
9755 (define_mode_attr tls_insn_suffix [(SI "wz") (DI "d")])
9756
9757 (define_insn_and_split "tls_gd_aix<TLSmode:tls_abi_suffix>"
9758   [(set (match_operand:TLSmode 0 "gpc_reg_operand" "=b")
9759         (call (mem:TLSmode (match_operand:TLSmode 3 "symbol_ref_operand" "s"))
9760               (match_operand 4 "" "g")))
9761    (unspec:TLSmode [(match_operand:TLSmode 1 "gpc_reg_operand" "b")
9762                     (match_operand:TLSmode 2 "rs6000_tls_symbol_ref" "")]
9763                    UNSPEC_TLSGD)
9764    (clobber (reg:SI LR_REGNO))]
9765   "HAVE_AS_TLS && (DEFAULT_ABI == ABI_AIX || DEFAULT_ABI == ABI_ELFv2)"
9766 {
9767   if (TARGET_CMODEL != CMODEL_SMALL)
9768     return "addis %0,%1,%2@got@tlsgd@ha\;addi %0,%0,%2@got@tlsgd@l\;"
9769            "bl %z3\;nop";
9770   else
9771     return "addi %0,%1,%2@got@tlsgd\;bl %z3\;nop";
9772 }
9773   "&& TARGET_TLS_MARKERS"
9774   [(set (match_dup 0)
9775         (unspec:TLSmode [(match_dup 1)
9776                          (match_dup 2)]
9777                         UNSPEC_TLSGD))
9778    (parallel [(set (match_dup 0)
9779                    (call (mem:TLSmode (match_dup 3))
9780                          (match_dup 4)))
9781               (unspec:TLSmode [(match_dup 2)] UNSPEC_TLSGD)
9782               (clobber (reg:SI LR_REGNO))])]
9783   ""
9784   [(set_attr "type" "two")
9785    (set (attr "length")
9786      (if_then_else (ne (symbol_ref "TARGET_CMODEL") (symbol_ref "CMODEL_SMALL"))
9787                    (const_int 16)
9788                    (const_int 12)))])
9789
9790 (define_insn_and_split "tls_gd_sysv<TLSmode:tls_sysv_suffix>"
9791   [(set (match_operand:TLSmode 0 "gpc_reg_operand" "=b")
9792         (call (mem:TLSmode (match_operand:TLSmode 3 "symbol_ref_operand" "s"))
9793               (match_operand 4 "" "g")))
9794    (unspec:TLSmode [(match_operand:TLSmode 1 "gpc_reg_operand" "b")
9795                     (match_operand:TLSmode 2 "rs6000_tls_symbol_ref" "")]
9796                    UNSPEC_TLSGD)
9797    (clobber (reg:SI LR_REGNO))]
9798   "HAVE_AS_TLS && DEFAULT_ABI == ABI_V4"
9799 {
9800   if (flag_pic)
9801     {
9802       if (TARGET_SECURE_PLT && flag_pic == 2)
9803         return "addi %0,%1,%2@got@tlsgd\;bl %z3+32768@plt";
9804       else
9805         return "addi %0,%1,%2@got@tlsgd\;bl %z3@plt";
9806     }
9807   else
9808     return "addi %0,%1,%2@got@tlsgd\;bl %z3";
9809 }
9810   "&& TARGET_TLS_MARKERS"
9811   [(set (match_dup 0)
9812         (unspec:TLSmode [(match_dup 1)
9813                          (match_dup 2)]
9814                         UNSPEC_TLSGD))
9815    (parallel [(set (match_dup 0)
9816                    (call (mem:TLSmode (match_dup 3))
9817                          (match_dup 4)))
9818               (unspec:TLSmode [(match_dup 2)] UNSPEC_TLSGD)
9819               (clobber (reg:SI LR_REGNO))])]
9820   ""
9821   [(set_attr "type" "two")
9822    (set_attr "length" "8")])
9823
9824 (define_insn_and_split "*tls_gd<TLSmode:tls_abi_suffix>"
9825   [(set (match_operand:TLSmode 0 "gpc_reg_operand" "=b")
9826         (unspec:TLSmode [(match_operand:TLSmode 1 "gpc_reg_operand" "b")
9827                          (match_operand:TLSmode 2 "rs6000_tls_symbol_ref" "")]
9828                         UNSPEC_TLSGD))]
9829   "HAVE_AS_TLS && TARGET_TLS_MARKERS"
9830   "addi %0,%1,%2@got@tlsgd"
9831   "&& TARGET_CMODEL != CMODEL_SMALL"
9832   [(set (match_dup 3)
9833         (high:TLSmode
9834             (unspec:TLSmode [(match_dup 1) (match_dup 2)] UNSPEC_TLSGD)))
9835    (set (match_dup 0)
9836         (lo_sum:TLSmode (match_dup 3)
9837             (unspec:TLSmode [(match_dup 1) (match_dup 2)] UNSPEC_TLSGD)))]
9838   "
9839 {
9840   operands[3] = gen_reg_rtx (TARGET_64BIT ? DImode : SImode);
9841 }"
9842   [(set (attr "length")
9843      (if_then_else (ne (symbol_ref "TARGET_CMODEL") (symbol_ref "CMODEL_SMALL"))
9844                    (const_int 8)
9845                    (const_int 4)))])
9846
9847 (define_insn "*tls_gd_high<TLSmode:tls_abi_suffix>"
9848   [(set (match_operand:TLSmode 0 "gpc_reg_operand" "=b")
9849      (high:TLSmode
9850        (unspec:TLSmode [(match_operand:TLSmode 1 "gpc_reg_operand" "b")
9851                         (match_operand:TLSmode 2 "rs6000_tls_symbol_ref" "")]
9852                        UNSPEC_TLSGD)))]
9853   "HAVE_AS_TLS && TARGET_TLS_MARKERS && TARGET_CMODEL != CMODEL_SMALL"
9854   "addis %0,%1,%2@got@tlsgd@ha"
9855   [(set_attr "length" "4")])
9856
9857 (define_insn "*tls_gd_low<TLSmode:tls_abi_suffix>"
9858   [(set (match_operand:TLSmode 0 "gpc_reg_operand" "=b")
9859      (lo_sum:TLSmode (match_operand:TLSmode 1 "gpc_reg_operand" "b")
9860        (unspec:TLSmode [(match_operand:TLSmode 3 "gpc_reg_operand" "b")
9861                         (match_operand:TLSmode 2 "rs6000_tls_symbol_ref" "")]
9862                        UNSPEC_TLSGD)))]
9863   "HAVE_AS_TLS && TARGET_TLS_MARKERS && TARGET_CMODEL != CMODEL_SMALL"
9864   "addi %0,%1,%2@got@tlsgd@l"
9865   [(set_attr "length" "4")])
9866
9867 (define_insn "*tls_gd_call_aix<TLSmode:tls_abi_suffix>"
9868   [(set (match_operand:TLSmode 0 "gpc_reg_operand" "=b")
9869         (call (mem:TLSmode (match_operand:TLSmode 1 "symbol_ref_operand" "s"))
9870               (match_operand 2 "" "g")))
9871    (unspec:TLSmode [(match_operand:TLSmode 3 "rs6000_tls_symbol_ref" "")]
9872                    UNSPEC_TLSGD)
9873    (clobber (reg:SI LR_REGNO))]
9874   "HAVE_AS_TLS && TARGET_TLS_MARKERS
9875    && (DEFAULT_ABI == ABI_AIX || DEFAULT_ABI == ABI_ELFv2)"
9876   "bl %z1(%3@tlsgd)\;nop"
9877   [(set_attr "type" "branch")
9878    (set_attr "length" "8")])
9879
9880 (define_insn "*tls_gd_call_sysv<TLSmode:tls_abi_suffix>"
9881   [(set (match_operand:TLSmode 0 "gpc_reg_operand" "=b")
9882         (call (mem:TLSmode (match_operand:TLSmode 1 "symbol_ref_operand" "s"))
9883               (match_operand 2 "" "g")))
9884    (unspec:TLSmode [(match_operand:TLSmode 3 "rs6000_tls_symbol_ref" "")]
9885                    UNSPEC_TLSGD)
9886    (clobber (reg:SI LR_REGNO))]
9887   "HAVE_AS_TLS && DEFAULT_ABI == ABI_V4 && TARGET_TLS_MARKERS"
9888 {
9889   if (flag_pic)
9890     {
9891       if (TARGET_SECURE_PLT && flag_pic == 2)
9892         return "bl %z1+32768(%3@tlsgd)@plt";
9893       return "bl %z1(%3@tlsgd)@plt";
9894     }
9895   return "bl %z1(%3@tlsgd)";
9896 }
9897   [(set_attr "type" "branch")
9898    (set_attr "length" "4")])
9899
9900 (define_insn_and_split "tls_ld_aix<TLSmode:tls_abi_suffix>"
9901   [(set (match_operand:TLSmode 0 "gpc_reg_operand" "=b")
9902         (call (mem:TLSmode (match_operand:TLSmode 2 "symbol_ref_operand" "s"))
9903               (match_operand 3 "" "g")))
9904    (unspec:TLSmode [(match_operand:TLSmode 1 "gpc_reg_operand" "b")]
9905                    UNSPEC_TLSLD)
9906    (clobber (reg:SI LR_REGNO))]
9907   "HAVE_AS_TLS && (DEFAULT_ABI == ABI_AIX || DEFAULT_ABI == ABI_ELFv2)"
9908 {
9909   if (TARGET_CMODEL != CMODEL_SMALL)
9910     return "addis %0,%1,%&@got@tlsld@ha\;addi %0,%0,%&@got@tlsld@l\;"
9911            "bl %z2\;nop";
9912   else
9913     return "addi %0,%1,%&@got@tlsld\;bl %z2\;nop";
9914 }
9915   "&& TARGET_TLS_MARKERS"
9916   [(set (match_dup 0)
9917         (unspec:TLSmode [(match_dup 1)]
9918                         UNSPEC_TLSLD))
9919    (parallel [(set (match_dup 0)
9920                    (call (mem:TLSmode (match_dup 2))
9921                          (match_dup 3)))
9922               (unspec:TLSmode [(const_int 0)] UNSPEC_TLSLD)
9923               (clobber (reg:SI LR_REGNO))])]
9924   ""
9925   [(set_attr "type" "two")
9926    (set (attr "length")
9927      (if_then_else (ne (symbol_ref "TARGET_CMODEL") (symbol_ref "CMODEL_SMALL"))
9928                    (const_int 16)
9929                    (const_int 12)))])
9930
9931 (define_insn_and_split "tls_ld_sysv<TLSmode:tls_sysv_suffix>"
9932   [(set (match_operand:TLSmode 0 "gpc_reg_operand" "=b")
9933         (call (mem:TLSmode (match_operand:TLSmode 2 "symbol_ref_operand" "s"))
9934               (match_operand 3 "" "g")))
9935    (unspec:TLSmode [(match_operand:TLSmode 1 "gpc_reg_operand" "b")]
9936                    UNSPEC_TLSLD)
9937    (clobber (reg:SI LR_REGNO))]
9938   "HAVE_AS_TLS && DEFAULT_ABI == ABI_V4"
9939 {
9940   if (flag_pic)
9941     {
9942       if (TARGET_SECURE_PLT && flag_pic == 2)
9943         return "addi %0,%1,%&@got@tlsld\;bl %z2+32768@plt";
9944       else
9945         return "addi %0,%1,%&@got@tlsld\;bl %z2@plt";
9946     }
9947   else
9948     return "addi %0,%1,%&@got@tlsld\;bl %z2";
9949 }
9950   "&& TARGET_TLS_MARKERS"
9951   [(set (match_dup 0)
9952         (unspec:TLSmode [(match_dup 1)]
9953                         UNSPEC_TLSLD))
9954    (parallel [(set (match_dup 0)
9955                    (call (mem:TLSmode (match_dup 2))
9956                          (match_dup 3)))
9957               (unspec:TLSmode [(const_int 0)] UNSPEC_TLSLD)
9958               (clobber (reg:SI LR_REGNO))])]
9959   ""
9960   [(set_attr "length" "8")])
9961
9962 (define_insn_and_split "*tls_ld<TLSmode:tls_abi_suffix>"
9963   [(set (match_operand:TLSmode 0 "gpc_reg_operand" "=b")
9964         (unspec:TLSmode [(match_operand:TLSmode 1 "gpc_reg_operand" "b")]
9965                         UNSPEC_TLSLD))]
9966   "HAVE_AS_TLS && TARGET_TLS_MARKERS"
9967   "addi %0,%1,%&@got@tlsld"
9968   "&& TARGET_CMODEL != CMODEL_SMALL"
9969   [(set (match_dup 2)
9970         (high:TLSmode
9971             (unspec:TLSmode [(const_int 0) (match_dup 1)] UNSPEC_TLSLD)))
9972    (set (match_dup 0)
9973         (lo_sum:TLSmode (match_dup 2)
9974             (unspec:TLSmode [(const_int 0) (match_dup 1)] UNSPEC_TLSLD)))]
9975   "
9976 {
9977   operands[2] = gen_reg_rtx (TARGET_64BIT ? DImode : SImode);
9978 }"
9979   [(set (attr "length")
9980      (if_then_else (ne (symbol_ref "TARGET_CMODEL") (symbol_ref "CMODEL_SMALL"))
9981                    (const_int 8)
9982                    (const_int 4)))])
9983
9984 (define_insn "*tls_ld_high<TLSmode:tls_abi_suffix>"
9985   [(set (match_operand:TLSmode 0 "gpc_reg_operand" "=b")
9986      (high:TLSmode
9987        (unspec:TLSmode [(const_int 0)
9988                         (match_operand:TLSmode 1 "gpc_reg_operand" "b")]
9989                        UNSPEC_TLSLD)))]
9990   "HAVE_AS_TLS && TARGET_TLS_MARKERS && TARGET_CMODEL != CMODEL_SMALL"
9991   "addis %0,%1,%&@got@tlsld@ha"
9992   [(set_attr "length" "4")])
9993
9994 (define_insn "*tls_ld_low<TLSmode:tls_abi_suffix>"
9995   [(set (match_operand:TLSmode 0 "gpc_reg_operand" "=b")
9996      (lo_sum:TLSmode (match_operand:TLSmode 1 "gpc_reg_operand" "b")
9997        (unspec:TLSmode [(const_int 0)
9998                         (match_operand:TLSmode 2 "gpc_reg_operand" "b")]
9999                        UNSPEC_TLSLD)))]
10000   "HAVE_AS_TLS && TARGET_TLS_MARKERS && TARGET_CMODEL != CMODEL_SMALL"
10001   "addi %0,%1,%&@got@tlsld@l"
10002   [(set_attr "length" "4")])
10003
10004 (define_insn "*tls_ld_call_aix<TLSmode:tls_abi_suffix>"
10005   [(set (match_operand:TLSmode 0 "gpc_reg_operand" "=b")
10006         (call (mem:TLSmode (match_operand:TLSmode 1 "symbol_ref_operand" "s"))
10007               (match_operand 2 "" "g")))
10008    (unspec:TLSmode [(const_int 0)] UNSPEC_TLSLD)
10009    (clobber (reg:SI LR_REGNO))]
10010   "HAVE_AS_TLS && TARGET_TLS_MARKERS
10011    && (DEFAULT_ABI == ABI_AIX || DEFAULT_ABI == ABI_ELFv2)"
10012   "bl %z1(%&@tlsld)\;nop"
10013   [(set_attr "type" "branch")
10014    (set_attr "length" "8")])
10015
10016 (define_insn "*tls_ld_call_sysv<TLSmode:tls_abi_suffix>"
10017   [(set (match_operand:TLSmode 0 "gpc_reg_operand" "=b")
10018         (call (mem:TLSmode (match_operand:TLSmode 1 "symbol_ref_operand" "s"))
10019               (match_operand 2 "" "g")))
10020    (unspec:TLSmode [(const_int 0)] UNSPEC_TLSLD)
10021    (clobber (reg:SI LR_REGNO))]
10022   "HAVE_AS_TLS && DEFAULT_ABI == ABI_V4 && TARGET_TLS_MARKERS"
10023 {
10024   if (flag_pic)
10025     {
10026       if (TARGET_SECURE_PLT && flag_pic == 2)
10027         return "bl %z1+32768(%&@tlsld)@plt";
10028       return "bl %z1(%&@tlsld)@plt";
10029     }
10030   return "bl %z1(%&@tlsld)";
10031 }
10032   [(set_attr "type" "branch")
10033    (set_attr "length" "4")])
10034
10035 (define_insn "tls_dtprel_<TLSmode:tls_abi_suffix>"
10036   [(set (match_operand:TLSmode 0 "gpc_reg_operand" "=r")
10037         (unspec:TLSmode [(match_operand:TLSmode 1 "gpc_reg_operand" "b")
10038                          (match_operand:TLSmode 2 "rs6000_tls_symbol_ref" "")]
10039                         UNSPEC_TLSDTPREL))]
10040   "HAVE_AS_TLS"
10041   "addi %0,%1,%2@dtprel")
10042
10043 (define_insn "tls_dtprel_ha_<TLSmode:tls_abi_suffix>"
10044   [(set (match_operand:TLSmode 0 "gpc_reg_operand" "=r")
10045         (unspec:TLSmode [(match_operand:TLSmode 1 "gpc_reg_operand" "b")
10046                          (match_operand:TLSmode 2 "rs6000_tls_symbol_ref" "")]
10047                         UNSPEC_TLSDTPRELHA))]
10048   "HAVE_AS_TLS"
10049   "addis %0,%1,%2@dtprel@ha")
10050
10051 (define_insn "tls_dtprel_lo_<TLSmode:tls_abi_suffix>"
10052   [(set (match_operand:TLSmode 0 "gpc_reg_operand" "=r")
10053         (unspec:TLSmode [(match_operand:TLSmode 1 "gpc_reg_operand" "b")
10054                          (match_operand:TLSmode 2 "rs6000_tls_symbol_ref" "")]
10055                         UNSPEC_TLSDTPRELLO))]
10056   "HAVE_AS_TLS"
10057   "addi %0,%1,%2@dtprel@l")
10058
10059 (define_insn_and_split "tls_got_dtprel_<TLSmode:tls_abi_suffix>"
10060   [(set (match_operand:TLSmode 0 "gpc_reg_operand" "=r")
10061         (unspec:TLSmode [(match_operand:TLSmode 1 "gpc_reg_operand" "b")
10062                          (match_operand:TLSmode 2 "rs6000_tls_symbol_ref" "")]
10063                         UNSPEC_TLSGOTDTPREL))]
10064   "HAVE_AS_TLS"
10065   "l<TLSmode:tls_insn_suffix> %0,%2@got@dtprel(%1)"
10066   "&& TARGET_CMODEL != CMODEL_SMALL"
10067   [(set (match_dup 3)
10068         (high:TLSmode
10069             (unspec:TLSmode [(match_dup 1) (match_dup 2)] UNSPEC_TLSGOTDTPREL)))
10070    (set (match_dup 0)
10071         (lo_sum:TLSmode (match_dup 3)
10072             (unspec:TLSmode [(match_dup 1) (match_dup 2)] UNSPEC_TLSGOTDTPREL)))]
10073   "
10074 {
10075   operands[3] = gen_reg_rtx (TARGET_64BIT ? DImode : SImode);
10076 }"
10077   [(set (attr "length")
10078      (if_then_else (ne (symbol_ref "TARGET_CMODEL") (symbol_ref "CMODEL_SMALL"))
10079                    (const_int 8)
10080                    (const_int 4)))])
10081
10082 (define_insn "*tls_got_dtprel_high<TLSmode:tls_abi_suffix>"
10083   [(set (match_operand:TLSmode 0 "gpc_reg_operand" "=b")
10084      (high:TLSmode
10085        (unspec:TLSmode [(match_operand:TLSmode 1 "gpc_reg_operand" "b")
10086                         (match_operand:TLSmode 2 "rs6000_tls_symbol_ref" "")]
10087                        UNSPEC_TLSGOTDTPREL)))]
10088   "HAVE_AS_TLS && TARGET_CMODEL != CMODEL_SMALL"
10089   "addis %0,%1,%2@got@dtprel@ha"
10090   [(set_attr "length" "4")])
10091
10092 (define_insn "*tls_got_dtprel_low<TLSmode:tls_abi_suffix>"
10093   [(set (match_operand:TLSmode 0 "gpc_reg_operand" "=r")
10094      (lo_sum:TLSmode (match_operand:TLSmode 1 "gpc_reg_operand" "b")
10095          (unspec:TLSmode [(match_operand:TLSmode 3 "gpc_reg_operand" "b")
10096                           (match_operand:TLSmode 2 "rs6000_tls_symbol_ref" "")]
10097                          UNSPEC_TLSGOTDTPREL)))]
10098   "HAVE_AS_TLS && TARGET_CMODEL != CMODEL_SMALL"
10099   "l<TLSmode:tls_insn_suffix> %0,%2@got@dtprel@l(%1)"
10100   [(set_attr "length" "4")])
10101
10102 (define_insn "tls_tprel_<TLSmode:tls_abi_suffix>"
10103   [(set (match_operand:TLSmode 0 "gpc_reg_operand" "=r")
10104         (unspec:TLSmode [(match_operand:TLSmode 1 "gpc_reg_operand" "b")
10105                          (match_operand:TLSmode 2 "rs6000_tls_symbol_ref" "")]
10106                         UNSPEC_TLSTPREL))]
10107   "HAVE_AS_TLS"
10108   "addi %0,%1,%2@tprel")
10109
10110 (define_insn "tls_tprel_ha_<TLSmode:tls_abi_suffix>"
10111   [(set (match_operand:TLSmode 0 "gpc_reg_operand" "=r")
10112         (unspec:TLSmode [(match_operand:TLSmode 1 "gpc_reg_operand" "b")
10113                          (match_operand:TLSmode 2 "rs6000_tls_symbol_ref" "")]
10114                         UNSPEC_TLSTPRELHA))]
10115   "HAVE_AS_TLS"
10116   "addis %0,%1,%2@tprel@ha")
10117
10118 (define_insn "tls_tprel_lo_<TLSmode:tls_abi_suffix>"
10119   [(set (match_operand:TLSmode 0 "gpc_reg_operand" "=r")
10120         (unspec:TLSmode [(match_operand:TLSmode 1 "gpc_reg_operand" "b")
10121                          (match_operand:TLSmode 2 "rs6000_tls_symbol_ref" "")]
10122                         UNSPEC_TLSTPRELLO))]
10123   "HAVE_AS_TLS"
10124   "addi %0,%1,%2@tprel@l")
10125
10126 ;; "b" output constraint here and on tls_tls input to support linker tls
10127 ;; optimization.  The linker may edit the instructions emitted by a
10128 ;; tls_got_tprel/tls_tls pair to addis,addi.
10129 (define_insn_and_split "tls_got_tprel_<TLSmode:tls_abi_suffix>"
10130   [(set (match_operand:TLSmode 0 "gpc_reg_operand" "=b")
10131         (unspec:TLSmode [(match_operand:TLSmode 1 "gpc_reg_operand" "b")
10132                          (match_operand:TLSmode 2 "rs6000_tls_symbol_ref" "")]
10133                         UNSPEC_TLSGOTTPREL))]
10134   "HAVE_AS_TLS"
10135   "l<TLSmode:tls_insn_suffix> %0,%2@got@tprel(%1)"
10136   "&& TARGET_CMODEL != CMODEL_SMALL"
10137   [(set (match_dup 3)
10138         (high:TLSmode
10139             (unspec:TLSmode [(match_dup 1) (match_dup 2)] UNSPEC_TLSGOTTPREL)))
10140    (set (match_dup 0)
10141         (lo_sum:TLSmode (match_dup 3)
10142             (unspec:TLSmode [(match_dup 1) (match_dup 2)] UNSPEC_TLSGOTTPREL)))]
10143   "
10144 {
10145   operands[3] = gen_reg_rtx (TARGET_64BIT ? DImode : SImode);
10146 }"
10147   [(set (attr "length")
10148      (if_then_else (ne (symbol_ref "TARGET_CMODEL") (symbol_ref "CMODEL_SMALL"))
10149                    (const_int 8)
10150                    (const_int 4)))])
10151
10152 (define_insn "*tls_got_tprel_high<TLSmode:tls_abi_suffix>"
10153   [(set (match_operand:TLSmode 0 "gpc_reg_operand" "=b")
10154      (high:TLSmode
10155        (unspec:TLSmode [(match_operand:TLSmode 1 "gpc_reg_operand" "b")
10156                         (match_operand:TLSmode 2 "rs6000_tls_symbol_ref" "")]
10157                        UNSPEC_TLSGOTTPREL)))]
10158   "HAVE_AS_TLS && TARGET_CMODEL != CMODEL_SMALL"
10159   "addis %0,%1,%2@got@tprel@ha"
10160   [(set_attr "length" "4")])
10161
10162 (define_insn "*tls_got_tprel_low<TLSmode:tls_abi_suffix>"
10163   [(set (match_operand:TLSmode 0 "gpc_reg_operand" "=r")
10164      (lo_sum:TLSmode (match_operand:TLSmode 1 "gpc_reg_operand" "b")
10165          (unspec:TLSmode [(match_operand:TLSmode 3 "gpc_reg_operand" "b")
10166                           (match_operand:TLSmode 2 "rs6000_tls_symbol_ref" "")]
10167                          UNSPEC_TLSGOTTPREL)))]
10168   "HAVE_AS_TLS && TARGET_CMODEL != CMODEL_SMALL"
10169   "l<TLSmode:tls_insn_suffix> %0,%2@got@tprel@l(%1)"
10170   [(set_attr "length" "4")])
10171
10172 (define_insn "tls_tls_<TLSmode:tls_abi_suffix>"
10173   [(set (match_operand:TLSmode 0 "gpc_reg_operand" "=r")
10174         (unspec:TLSmode [(match_operand:TLSmode 1 "gpc_reg_operand" "b")
10175                          (match_operand:TLSmode 2 "rs6000_tls_symbol_ref" "")]
10176                         UNSPEC_TLSTLS))]
10177   "TARGET_ELF && HAVE_AS_TLS"
10178   "add %0,%1,%2@tls")
10179
10180 (define_expand "tls_get_tpointer"
10181   [(set (match_operand:SI 0 "gpc_reg_operand" "")
10182         (unspec:SI [(const_int 0)] UNSPEC_TLSTLS))]
10183   "TARGET_XCOFF && HAVE_AS_TLS"
10184   "
10185 {
10186   emit_insn (gen_tls_get_tpointer_internal ());
10187   emit_move_insn (operands[0], gen_rtx_REG (SImode, 3));
10188   DONE;
10189 }")
10190
10191 (define_insn "tls_get_tpointer_internal"
10192   [(set (reg:SI 3)
10193         (unspec:SI [(const_int 0)] UNSPEC_TLSTLS))
10194    (clobber (reg:SI LR_REGNO))]
10195   "TARGET_XCOFF && HAVE_AS_TLS"
10196   "bla __get_tpointer")
10197
10198 (define_expand "tls_get_addr<mode>"
10199   [(set (match_operand:P 0 "gpc_reg_operand" "")
10200         (unspec:P [(match_operand:P 1 "gpc_reg_operand" "")
10201                    (match_operand:P 2 "gpc_reg_operand" "")] UNSPEC_TLSTLS))]
10202   "TARGET_XCOFF && HAVE_AS_TLS"
10203   "
10204 {
10205   emit_move_insn (gen_rtx_REG (Pmode, 3), operands[1]);
10206   emit_move_insn (gen_rtx_REG (Pmode, 4), operands[2]);
10207   emit_insn (gen_tls_get_addr_internal<mode> ());
10208   emit_move_insn (operands[0], gen_rtx_REG (Pmode, 3));
10209   DONE;
10210 }")
10211
10212 (define_insn "tls_get_addr_internal<mode>"
10213   [(set (reg:P 3)
10214         (unspec:P [(reg:P 3) (reg:P 4)] UNSPEC_TLSTLS))
10215    (clobber (reg:P 0))
10216    (clobber (reg:P 4))
10217    (clobber (reg:P 5))
10218    (clobber (reg:P 11))
10219    (clobber (reg:CC CR0_REGNO))
10220    (clobber (reg:P LR_REGNO))]
10221   "TARGET_XCOFF && HAVE_AS_TLS"
10222   "bla __tls_get_addr")
10223 \f
10224 ;; Next come insns related to the calling sequence.
10225 ;;
10226 ;; First, an insn to allocate new stack space for dynamic use (e.g., alloca).
10227 ;; We move the back-chain and decrement the stack pointer.
10228
10229 (define_expand "allocate_stack"
10230   [(set (match_operand 0 "gpc_reg_operand" "")
10231         (minus (reg 1) (match_operand 1 "reg_or_short_operand" "")))
10232    (set (reg 1)
10233         (minus (reg 1) (match_dup 1)))]
10234   ""
10235   "
10236 { rtx chain = gen_reg_rtx (Pmode);
10237   rtx stack_bot = gen_rtx_MEM (Pmode, stack_pointer_rtx);
10238   rtx neg_op0;
10239   rtx insn, par, set, mem;
10240
10241   emit_move_insn (chain, stack_bot);
10242
10243   /* Check stack bounds if necessary.  */
10244   if (crtl->limit_stack)
10245     {
10246       rtx available;
10247       available = expand_binop (Pmode, sub_optab,
10248                                 stack_pointer_rtx, stack_limit_rtx,
10249                                 NULL_RTX, 1, OPTAB_WIDEN);
10250       emit_insn (gen_cond_trap (LTU, available, operands[1], const0_rtx));
10251     }
10252
10253   if (GET_CODE (operands[1]) != CONST_INT
10254       || INTVAL (operands[1]) < -32767
10255       || INTVAL (operands[1]) > 32768)
10256     {
10257       neg_op0 = gen_reg_rtx (Pmode);
10258       if (TARGET_32BIT)
10259         emit_insn (gen_negsi2 (neg_op0, operands[1]));
10260       else
10261         emit_insn (gen_negdi2 (neg_op0, operands[1]));
10262     }
10263   else
10264     neg_op0 = GEN_INT (- INTVAL (operands[1]));
10265
10266   insn = emit_insn ((* ((TARGET_32BIT) ? gen_movsi_update_stack
10267                                        : gen_movdi_di_update_stack))
10268                         (stack_pointer_rtx, stack_pointer_rtx, neg_op0,
10269                          chain));
10270   /* Since we didn't use gen_frame_mem to generate the MEM, grab
10271      it now and set the alias set/attributes. The above gen_*_update
10272      calls will generate a PARALLEL with the MEM set being the first
10273      operation. */
10274   par = PATTERN (insn);
10275   gcc_assert (GET_CODE (par) == PARALLEL);
10276   set = XVECEXP (par, 0, 0);
10277   gcc_assert (GET_CODE (set) == SET);
10278   mem = SET_DEST (set);
10279   gcc_assert (MEM_P (mem));
10280   MEM_NOTRAP_P (mem) = 1;
10281   set_mem_alias_set (mem, get_frame_alias_set ());
10282
10283   emit_move_insn (operands[0], virtual_stack_dynamic_rtx);
10284   DONE;
10285 }")
10286
10287 ;; These patterns say how to save and restore the stack pointer.  We need not
10288 ;; save the stack pointer at function level since we are careful to
10289 ;; preserve the backchain.  At block level, we have to restore the backchain
10290 ;; when we restore the stack pointer.
10291 ;;
10292 ;; For nonlocal gotos, we must save both the stack pointer and its
10293 ;; backchain and restore both.  Note that in the nonlocal case, the
10294 ;; save area is a memory location.
10295
10296 (define_expand "save_stack_function"
10297   [(match_operand 0 "any_operand" "")
10298    (match_operand 1 "any_operand" "")]
10299   ""
10300   "DONE;")
10301
10302 (define_expand "restore_stack_function"
10303   [(match_operand 0 "any_operand" "")
10304    (match_operand 1 "any_operand" "")]
10305   ""
10306   "DONE;")
10307
10308 ;; Adjust stack pointer (op0) to a new value (op1).
10309 ;; First copy old stack backchain to new location, and ensure that the
10310 ;; scheduler won't reorder the sp assignment before the backchain write.
10311 (define_expand "restore_stack_block"
10312   [(set (match_dup 2) (match_dup 3))
10313    (set (match_dup 4) (match_dup 2))
10314    (match_dup 5)
10315    (set (match_operand 0 "register_operand" "")
10316         (match_operand 1 "register_operand" ""))]
10317   ""
10318   "
10319 {
10320   rtvec p;
10321
10322   operands[1] = force_reg (Pmode, operands[1]);
10323   operands[2] = gen_reg_rtx (Pmode);
10324   operands[3] = gen_frame_mem (Pmode, operands[0]);
10325   operands[4] = gen_frame_mem (Pmode, operands[1]);
10326   p = rtvec_alloc (1);
10327   RTVEC_ELT (p, 0) = gen_rtx_SET (VOIDmode,
10328                                   gen_frame_mem (BLKmode, operands[0]),
10329                                   const0_rtx);
10330   operands[5] = gen_rtx_PARALLEL (VOIDmode, p);
10331 }")
10332
10333 (define_expand "save_stack_nonlocal"
10334   [(set (match_dup 3) (match_dup 4))
10335    (set (match_operand 0 "memory_operand" "") (match_dup 3))
10336    (set (match_dup 2) (match_operand 1 "register_operand" ""))]
10337   ""
10338   "
10339 {
10340   int units_per_word = (TARGET_32BIT) ? 4 : 8;
10341
10342   /* Copy the backchain to the first word, sp to the second.  */
10343   operands[0] = adjust_address_nv (operands[0], Pmode, 0);
10344   operands[2] = adjust_address_nv (operands[0], Pmode, units_per_word);
10345   operands[3] = gen_reg_rtx (Pmode);
10346   operands[4] = gen_frame_mem (Pmode, operands[1]);
10347 }")
10348
10349 (define_expand "restore_stack_nonlocal"
10350   [(set (match_dup 2) (match_operand 1 "memory_operand" ""))
10351    (set (match_dup 3) (match_dup 4))
10352    (set (match_dup 5) (match_dup 2))
10353    (match_dup 6)
10354    (set (match_operand 0 "register_operand" "") (match_dup 3))]
10355   ""
10356   "
10357 {
10358   int units_per_word = (TARGET_32BIT) ? 4 : 8;
10359   rtvec p;
10360
10361   /* Restore the backchain from the first word, sp from the second.  */
10362   operands[2] = gen_reg_rtx (Pmode);
10363   operands[3] = gen_reg_rtx (Pmode);
10364   operands[1] = adjust_address_nv (operands[1], Pmode, 0);
10365   operands[4] = adjust_address_nv (operands[1], Pmode, units_per_word);
10366   operands[5] = gen_frame_mem (Pmode, operands[3]);
10367   p = rtvec_alloc (1);
10368   RTVEC_ELT (p, 0) = gen_rtx_SET (VOIDmode,
10369                                   gen_frame_mem (BLKmode, operands[0]),
10370                                   const0_rtx);
10371   operands[6] = gen_rtx_PARALLEL (VOIDmode, p);
10372 }")
10373 \f
10374 ;; TOC register handling.
10375
10376 ;; Code to initialize the TOC register...
10377
10378 (define_insn "load_toc_aix_si"
10379   [(parallel [(set (match_operand:SI 0 "gpc_reg_operand" "=r")
10380                    (unspec:SI [(const_int 0)] UNSPEC_TOC))
10381               (use (reg:SI 2))])]
10382   "(DEFAULT_ABI == ABI_AIX || DEFAULT_ABI == ABI_ELFv2) && TARGET_32BIT"
10383   "*
10384 {
10385   char buf[30];
10386   ASM_GENERATE_INTERNAL_LABEL (buf, \"LCTOC\", 1);
10387   operands[1] = gen_rtx_SYMBOL_REF (Pmode, ggc_strdup (buf));
10388   operands[2] = gen_rtx_REG (Pmode, 2);
10389   return \"lwz %0,%1(%2)\";
10390 }"
10391   [(set_attr "type" "load")
10392    (set_attr "update" "no")
10393    (set_attr "indexed" "no")])
10394
10395 (define_insn "load_toc_aix_di"
10396   [(parallel [(set (match_operand:DI 0 "gpc_reg_operand" "=r")
10397                    (unspec:DI [(const_int 0)] UNSPEC_TOC))
10398               (use (reg:DI 2))])]
10399   "(DEFAULT_ABI == ABI_AIX || DEFAULT_ABI == ABI_ELFv2) && TARGET_64BIT"
10400   "*
10401 {
10402   char buf[30];
10403 #ifdef TARGET_RELOCATABLE
10404   ASM_GENERATE_INTERNAL_LABEL (buf, \"LCTOC\",
10405                                !TARGET_MINIMAL_TOC || TARGET_RELOCATABLE);
10406 #else
10407   ASM_GENERATE_INTERNAL_LABEL (buf, \"LCTOC\", 1);
10408 #endif
10409   if (TARGET_ELF)
10410     strcat (buf, \"@toc\");
10411   operands[1] = gen_rtx_SYMBOL_REF (Pmode, ggc_strdup (buf));
10412   operands[2] = gen_rtx_REG (Pmode, 2);
10413   return \"ld %0,%1(%2)\";
10414 }"
10415   [(set_attr "type" "load")
10416    (set_attr "update" "no")
10417    (set_attr "indexed" "no")])
10418
10419 (define_insn "load_toc_v4_pic_si"
10420   [(set (reg:SI LR_REGNO)
10421         (unspec:SI [(const_int 0)] UNSPEC_TOC))]
10422   "DEFAULT_ABI == ABI_V4 && flag_pic == 1 && TARGET_32BIT"
10423   "bl _GLOBAL_OFFSET_TABLE_@local-4"
10424   [(set_attr "type" "branch")
10425    (set_attr "length" "4")])
10426
10427 (define_expand "load_toc_v4_PIC_1"
10428   [(parallel [(set (reg:SI LR_REGNO)
10429                    (match_operand:SI 0 "immediate_operand" "s"))
10430               (use (unspec [(match_dup 0)] UNSPEC_TOC))])]
10431   "TARGET_ELF && DEFAULT_ABI == ABI_V4
10432    && (flag_pic == 2 || (flag_pic && TARGET_SECURE_PLT))"
10433   "")
10434
10435 (define_insn "load_toc_v4_PIC_1_normal"
10436   [(set (reg:SI LR_REGNO)
10437         (match_operand:SI 0 "immediate_operand" "s"))
10438    (use (unspec [(match_dup 0)] UNSPEC_TOC))]
10439   "!TARGET_LINK_STACK && TARGET_ELF && DEFAULT_ABI == ABI_V4
10440    && (flag_pic == 2 || (flag_pic && TARGET_SECURE_PLT))"
10441   "bcl 20,31,%0\\n%0:"
10442   [(set_attr "type" "branch")
10443    (set_attr "length" "4")])
10444
10445 (define_insn "load_toc_v4_PIC_1_476"
10446   [(set (reg:SI LR_REGNO)
10447         (match_operand:SI 0 "immediate_operand" "s"))
10448    (use (unspec [(match_dup 0)] UNSPEC_TOC))]
10449   "TARGET_LINK_STACK && TARGET_ELF && DEFAULT_ABI == ABI_V4
10450    && (flag_pic == 2 || (flag_pic && TARGET_SECURE_PLT))"
10451   "*
10452 {
10453   char name[32];
10454   static char templ[32];
10455
10456   get_ppc476_thunk_name (name);
10457   sprintf (templ, \"bl %s\\n%%0:\", name);
10458   return templ;
10459 }"
10460   [(set_attr "type" "branch")
10461    (set_attr "length" "4")])
10462
10463 (define_expand "load_toc_v4_PIC_1b"
10464   [(parallel [(set (reg:SI LR_REGNO)
10465                    (unspec:SI [(match_operand:SI 0 "immediate_operand" "s")
10466                                (label_ref (match_operand 1 "" ""))]
10467                            UNSPEC_TOCPTR))
10468               (match_dup 1)])]
10469   "TARGET_ELF && DEFAULT_ABI == ABI_V4 && flag_pic == 2"
10470   "")
10471
10472 (define_insn "load_toc_v4_PIC_1b_normal"
10473   [(set (reg:SI LR_REGNO)
10474         (unspec:SI [(match_operand:SI 0 "immediate_operand" "s")
10475                     (label_ref (match_operand 1 "" ""))]
10476                 UNSPEC_TOCPTR))
10477    (match_dup 1)]
10478   "!TARGET_LINK_STACK && TARGET_ELF && DEFAULT_ABI == ABI_V4 && flag_pic == 2"
10479   "bcl 20,31,$+8\;.long %0-$"
10480   [(set_attr "type" "branch")
10481    (set_attr "length" "8")])
10482
10483 (define_insn "load_toc_v4_PIC_1b_476"
10484   [(set (reg:SI LR_REGNO)
10485         (unspec:SI [(match_operand:SI 0 "immediate_operand" "s")
10486                     (label_ref (match_operand 1 "" ""))]
10487                 UNSPEC_TOCPTR))
10488    (match_dup 1)]
10489   "TARGET_LINK_STACK && TARGET_ELF && DEFAULT_ABI == ABI_V4 && flag_pic == 2"
10490   "*
10491 {
10492   char name[32];
10493   static char templ[32];
10494
10495   get_ppc476_thunk_name (name);
10496   sprintf (templ, \"bl %s\\n\\tb $+8\\n\\t.long %%0-$\", name);
10497   return templ;
10498 }"
10499   [(set_attr "type" "branch")
10500    (set_attr "length" "16")])
10501
10502 (define_insn "load_toc_v4_PIC_2"
10503   [(set (match_operand:SI 0 "gpc_reg_operand" "=r")
10504         (mem:SI (plus:SI (match_operand:SI 1 "gpc_reg_operand" "b")
10505                    (minus:SI (match_operand:SI 2 "immediate_operand" "s")
10506                              (match_operand:SI 3 "immediate_operand" "s")))))]
10507   "TARGET_ELF && DEFAULT_ABI == ABI_V4 && flag_pic == 2"
10508   "lwz %0,%2-%3(%1)"
10509   [(set_attr "type" "load")])
10510
10511 (define_insn "load_toc_v4_PIC_3b"
10512   [(set (match_operand:SI 0 "gpc_reg_operand" "=r")
10513         (plus:SI (match_operand:SI 1 "gpc_reg_operand" "b")
10514                  (high:SI
10515                    (minus:SI (match_operand:SI 2 "symbol_ref_operand" "s")
10516                              (match_operand:SI 3 "symbol_ref_operand" "s")))))]
10517   "TARGET_ELF && TARGET_SECURE_PLT && DEFAULT_ABI == ABI_V4 && flag_pic"
10518   "addis %0,%1,%2-%3@ha")
10519
10520 (define_insn "load_toc_v4_PIC_3c"
10521   [(set (match_operand:SI 0 "gpc_reg_operand" "=r")
10522         (lo_sum:SI (match_operand:SI 1 "gpc_reg_operand" "b")
10523                    (minus:SI (match_operand:SI 2 "symbol_ref_operand" "s")
10524                              (match_operand:SI 3 "symbol_ref_operand" "s"))))]
10525   "TARGET_ELF && TARGET_SECURE_PLT && DEFAULT_ABI == ABI_V4 && flag_pic"
10526   "addi %0,%1,%2-%3@l")
10527
10528 ;; If the TOC is shared over a translation unit, as happens with all
10529 ;; the kinds of PIC that we support, we need to restore the TOC
10530 ;; pointer only when jumping over units of translation.
10531 ;; On Darwin, we need to reload the picbase.
10532
10533 (define_expand "builtin_setjmp_receiver"
10534   [(use (label_ref (match_operand 0 "" "")))]
10535   "(DEFAULT_ABI == ABI_V4 && flag_pic == 1)
10536    || (TARGET_TOC && TARGET_MINIMAL_TOC)
10537    || (DEFAULT_ABI == ABI_DARWIN && flag_pic)"
10538   "
10539 {
10540 #if TARGET_MACHO
10541   if (DEFAULT_ABI == ABI_DARWIN)
10542     {
10543       rtx picrtx = gen_rtx_SYMBOL_REF (Pmode, MACHOPIC_FUNCTION_BASE_NAME);
10544       rtx picreg = gen_rtx_REG (Pmode, RS6000_PIC_OFFSET_TABLE_REGNUM);
10545       rtx tmplabrtx;
10546       char tmplab[20];
10547
10548       crtl->uses_pic_offset_table = 1;
10549       ASM_GENERATE_INTERNAL_LABEL(tmplab, \"LSJR\",
10550                                   CODE_LABEL_NUMBER (operands[0]));
10551       tmplabrtx = gen_rtx_SYMBOL_REF (Pmode, ggc_strdup (tmplab));
10552
10553       emit_insn (gen_load_macho_picbase (tmplabrtx));
10554       emit_move_insn (picreg, gen_rtx_REG (Pmode, LR_REGNO));
10555       emit_insn (gen_macho_correct_pic (picreg, picreg, picrtx, tmplabrtx));
10556     }
10557   else
10558 #endif
10559     rs6000_emit_load_toc_table (FALSE);
10560   DONE;
10561 }")
10562
10563 ;; Largetoc support
10564 (define_insn "*largetoc_high"
10565   [(set (match_operand:DI 0 "gpc_reg_operand" "=b*r")
10566         (high:DI
10567           (unspec [(match_operand:DI 1 "" "")
10568                    (match_operand:DI 2 "gpc_reg_operand" "b")]
10569                   UNSPEC_TOCREL)))]
10570    "TARGET_ELF && TARGET_CMODEL != CMODEL_SMALL"
10571    "addis %0,%2,%1@toc@ha")
10572
10573 (define_insn "*largetoc_high_aix<mode>"
10574   [(set (match_operand:P 0 "gpc_reg_operand" "=b*r")
10575         (high:P
10576           (unspec [(match_operand:P 1 "" "")
10577                    (match_operand:P 2 "gpc_reg_operand" "b")]
10578                   UNSPEC_TOCREL)))]
10579    "TARGET_XCOFF && TARGET_CMODEL != CMODEL_SMALL"
10580    "addis %0,%1@u(%2)")
10581
10582 (define_insn "*largetoc_high_plus"
10583   [(set (match_operand:DI 0 "gpc_reg_operand" "=b*r")
10584         (high:DI
10585           (plus:DI
10586             (unspec [(match_operand:DI 1 "" "")
10587                      (match_operand:DI 2 "gpc_reg_operand" "b")]
10588                     UNSPEC_TOCREL)
10589             (match_operand:DI 3 "add_cint_operand" "n"))))]
10590    "TARGET_ELF && TARGET_CMODEL != CMODEL_SMALL"
10591    "addis %0,%2,%1+%3@toc@ha")
10592
10593 (define_insn "*largetoc_high_plus_aix<mode>"
10594   [(set (match_operand:P 0 "gpc_reg_operand" "=b*r")
10595         (high:P
10596           (plus:P
10597             (unspec [(match_operand:P 1 "" "")
10598                      (match_operand:P 2 "gpc_reg_operand" "b")]
10599                     UNSPEC_TOCREL)
10600             (match_operand:P 3 "add_cint_operand" "n"))))]
10601    "TARGET_XCOFF && TARGET_CMODEL != CMODEL_SMALL"
10602    "addis %0,%1+%3@u(%2)")
10603
10604 (define_insn "*largetoc_low"
10605   [(set (match_operand:DI 0 "gpc_reg_operand" "=r,r")
10606         (lo_sum:DI (match_operand:DI 1 "gpc_reg_operand" "b,!*r")
10607                    (match_operand:DI 2 "" "")))]
10608    "TARGET_ELF && TARGET_CMODEL != CMODEL_SMALL"
10609    "@
10610     addi %0,%1,%2@l
10611     addic %0,%1,%2@l")
10612
10613 (define_insn "*largetoc_low_aix<mode>"
10614   [(set (match_operand:P 0 "gpc_reg_operand" "=r")
10615         (lo_sum:P (match_operand:P 1 "gpc_reg_operand" "b")
10616                    (match_operand:P 2 "" "")))]
10617    "TARGET_XCOFF && TARGET_CMODEL != CMODEL_SMALL"
10618    "la %0,%2@l(%1)")
10619
10620 (define_insn_and_split "*tocref<mode>"
10621   [(set (match_operand:P 0 "gpc_reg_operand" "=b*r")
10622         (match_operand:P 1 "small_toc_ref" "R"))]
10623    "TARGET_TOC"
10624    "la %0,%a1"
10625    "&& TARGET_CMODEL != CMODEL_SMALL && reload_completed"
10626   [(set (match_dup 0) (high:P (match_dup 1)))
10627    (set (match_dup 0) (lo_sum:P (match_dup 0) (match_dup 1)))])
10628
10629 ;; Elf specific ways of loading addresses for non-PIC code.
10630 ;; The output of this could be r0, but we make a very strong
10631 ;; preference for a base register because it will usually
10632 ;; be needed there.
10633 (define_insn "elf_high"
10634   [(set (match_operand:SI 0 "gpc_reg_operand" "=b*r")
10635         (high:SI (match_operand 1 "" "")))]
10636   "TARGET_ELF && ! TARGET_64BIT"
10637   "lis %0,%1@ha")
10638
10639 (define_insn "elf_low"
10640   [(set (match_operand:SI 0 "gpc_reg_operand" "=r,r")
10641         (lo_sum:SI (match_operand:SI 1 "gpc_reg_operand" "b,!*r")
10642                    (match_operand 2 "" "")))]
10643    "TARGET_ELF && ! TARGET_64BIT"
10644    "@
10645     la %0,%2@l(%1)
10646     addic %0,%1,%K2")
10647 \f
10648 ;; Call and call_value insns
10649 (define_expand "call"
10650   [(parallel [(call (mem:SI (match_operand 0 "address_operand" ""))
10651                     (match_operand 1 "" ""))
10652               (use (match_operand 2 "" ""))
10653               (clobber (reg:SI LR_REGNO))])]
10654   ""
10655   "
10656 {
10657 #if TARGET_MACHO
10658   if (MACHOPIC_INDIRECT)
10659     operands[0] = machopic_indirect_call_target (operands[0]);
10660 #endif
10661
10662   gcc_assert (GET_CODE (operands[0]) == MEM);
10663   gcc_assert (GET_CODE (operands[1]) == CONST_INT);
10664
10665   operands[0] = XEXP (operands[0], 0);
10666
10667   if (DEFAULT_ABI == ABI_AIX || DEFAULT_ABI == ABI_ELFv2)
10668     {
10669       rs6000_call_aix (NULL_RTX, operands[0], operands[1], operands[2]);
10670       DONE;
10671     }
10672
10673   if (GET_CODE (operands[0]) != SYMBOL_REF
10674       || (DEFAULT_ABI != ABI_DARWIN && (INTVAL (operands[2]) & CALL_LONG) != 0))
10675     {
10676       if (INTVAL (operands[2]) & CALL_LONG)
10677         operands[0] = rs6000_longcall_ref (operands[0]);
10678
10679       switch (DEFAULT_ABI)
10680         {
10681         case ABI_V4:
10682         case ABI_DARWIN:
10683           operands[0] = force_reg (Pmode, operands[0]);
10684           break;
10685
10686         default:
10687           gcc_unreachable ();
10688         }
10689     }
10690 }")
10691
10692 (define_expand "call_value"
10693   [(parallel [(set (match_operand 0 "" "")
10694                    (call (mem:SI (match_operand 1 "address_operand" ""))
10695                          (match_operand 2 "" "")))
10696               (use (match_operand 3 "" ""))
10697               (clobber (reg:SI LR_REGNO))])]
10698   ""
10699   "
10700 {
10701 #if TARGET_MACHO
10702   if (MACHOPIC_INDIRECT)
10703     operands[1] = machopic_indirect_call_target (operands[1]);
10704 #endif
10705
10706   gcc_assert (GET_CODE (operands[1]) == MEM);
10707   gcc_assert (GET_CODE (operands[2]) == CONST_INT);
10708
10709   operands[1] = XEXP (operands[1], 0);
10710
10711   if (DEFAULT_ABI == ABI_AIX || DEFAULT_ABI == ABI_ELFv2)
10712     {
10713       rs6000_call_aix (operands[0], operands[1], operands[2], operands[3]);
10714       DONE;
10715     }
10716
10717   if (GET_CODE (operands[1]) != SYMBOL_REF
10718       || (DEFAULT_ABI != ABI_DARWIN && (INTVAL (operands[3]) & CALL_LONG) != 0))
10719     {
10720       if (INTVAL (operands[3]) & CALL_LONG)
10721         operands[1] = rs6000_longcall_ref (operands[1]);
10722
10723       switch (DEFAULT_ABI)
10724         {
10725         case ABI_V4:
10726         case ABI_DARWIN:
10727           operands[1] = force_reg (Pmode, operands[1]);
10728           break;
10729
10730         default:
10731           gcc_unreachable ();
10732         }
10733     }
10734 }")
10735
10736 ;; Call to function in current module.  No TOC pointer reload needed.
10737 ;; Operand2 is nonzero if we are using the V.4 calling sequence and
10738 ;; either the function was not prototyped, or it was prototyped as a
10739 ;; variable argument function.  It is > 0 if FP registers were passed
10740 ;; and < 0 if they were not.
10741
10742 (define_insn "*call_local32"
10743   [(call (mem:SI (match_operand:SI 0 "current_file_function_operand" "s,s"))
10744          (match_operand 1 "" "g,g"))
10745    (use (match_operand:SI 2 "immediate_operand" "O,n"))
10746    (clobber (reg:SI LR_REGNO))]
10747   "(INTVAL (operands[2]) & CALL_LONG) == 0"
10748   "*
10749 {
10750   if (INTVAL (operands[2]) & CALL_V4_SET_FP_ARGS)
10751     output_asm_insn (\"crxor 6,6,6\", operands);
10752
10753   else if (INTVAL (operands[2]) & CALL_V4_CLEAR_FP_ARGS)
10754     output_asm_insn (\"creqv 6,6,6\", operands);
10755
10756   return (DEFAULT_ABI == ABI_V4 && flag_pic) ? \"bl %z0@local\" : \"bl %z0\";
10757 }"
10758   [(set_attr "type" "branch")
10759    (set_attr "length" "4,8")])
10760
10761 (define_insn "*call_local64"
10762   [(call (mem:SI (match_operand:DI 0 "current_file_function_operand" "s,s"))
10763          (match_operand 1 "" "g,g"))
10764    (use (match_operand:SI 2 "immediate_operand" "O,n"))
10765    (clobber (reg:SI LR_REGNO))]
10766   "TARGET_64BIT && (INTVAL (operands[2]) & CALL_LONG) == 0"
10767   "*
10768 {
10769   if (INTVAL (operands[2]) & CALL_V4_SET_FP_ARGS)
10770     output_asm_insn (\"crxor 6,6,6\", operands);
10771
10772   else if (INTVAL (operands[2]) & CALL_V4_CLEAR_FP_ARGS)
10773     output_asm_insn (\"creqv 6,6,6\", operands);
10774
10775   return (DEFAULT_ABI == ABI_V4 && flag_pic) ? \"bl %z0@local\" : \"bl %z0\";
10776 }"
10777   [(set_attr "type" "branch")
10778    (set_attr "length" "4,8")])
10779
10780 (define_insn "*call_value_local32"
10781   [(set (match_operand 0 "" "")
10782         (call (mem:SI (match_operand:SI 1 "current_file_function_operand" "s,s"))
10783               (match_operand 2 "" "g,g")))
10784    (use (match_operand:SI 3 "immediate_operand" "O,n"))
10785    (clobber (reg:SI LR_REGNO))]
10786   "(INTVAL (operands[3]) & CALL_LONG) == 0"
10787   "*
10788 {
10789   if (INTVAL (operands[3]) & CALL_V4_SET_FP_ARGS)
10790     output_asm_insn (\"crxor 6,6,6\", operands);
10791
10792   else if (INTVAL (operands[3]) & CALL_V4_CLEAR_FP_ARGS)
10793     output_asm_insn (\"creqv 6,6,6\", operands);
10794
10795   return (DEFAULT_ABI == ABI_V4 && flag_pic) ? \"bl %z1@local\" : \"bl %z1\";
10796 }"
10797   [(set_attr "type" "branch")
10798    (set_attr "length" "4,8")])
10799
10800
10801 (define_insn "*call_value_local64"
10802   [(set (match_operand 0 "" "")
10803         (call (mem:SI (match_operand:DI 1 "current_file_function_operand" "s,s"))
10804               (match_operand 2 "" "g,g")))
10805    (use (match_operand:SI 3 "immediate_operand" "O,n"))
10806    (clobber (reg:SI LR_REGNO))]
10807   "TARGET_64BIT && (INTVAL (operands[3]) & CALL_LONG) == 0"
10808   "*
10809 {
10810   if (INTVAL (operands[3]) & CALL_V4_SET_FP_ARGS)
10811     output_asm_insn (\"crxor 6,6,6\", operands);
10812
10813   else if (INTVAL (operands[3]) & CALL_V4_CLEAR_FP_ARGS)
10814     output_asm_insn (\"creqv 6,6,6\", operands);
10815
10816   return (DEFAULT_ABI == ABI_V4 && flag_pic) ? \"bl %z1@local\" : \"bl %z1\";
10817 }"
10818   [(set_attr "type" "branch")
10819    (set_attr "length" "4,8")])
10820
10821
10822 ;; A function pointer under System V is just a normal pointer
10823 ;; operands[0] is the function pointer
10824 ;; operands[1] is the stack size to clean up
10825 ;; operands[2] is the value FUNCTION_ARG returns for the VOID argument
10826 ;; which indicates how to set cr1
10827
10828 (define_insn "*call_indirect_nonlocal_sysv<mode>"
10829   [(call (mem:SI (match_operand:P 0 "register_operand" "c,*l,c,*l"))
10830          (match_operand 1 "" "g,g,g,g"))
10831    (use (match_operand:SI 2 "immediate_operand" "O,O,n,n"))
10832    (clobber (reg:SI LR_REGNO))]
10833   "DEFAULT_ABI == ABI_V4
10834    || DEFAULT_ABI == ABI_DARWIN"
10835 {
10836   if (INTVAL (operands[2]) & CALL_V4_SET_FP_ARGS)
10837     output_asm_insn ("crxor 6,6,6", operands);
10838
10839   else if (INTVAL (operands[2]) & CALL_V4_CLEAR_FP_ARGS)
10840     output_asm_insn ("creqv 6,6,6", operands);
10841
10842   return "b%T0l";
10843 }
10844   [(set_attr "type" "jmpreg,jmpreg,jmpreg,jmpreg")
10845    (set_attr "length" "4,4,8,8")])
10846
10847 (define_insn_and_split "*call_nonlocal_sysv<mode>"
10848   [(call (mem:SI (match_operand:P 0 "symbol_ref_operand" "s,s"))
10849          (match_operand 1 "" "g,g"))
10850    (use (match_operand:SI 2 "immediate_operand" "O,n"))
10851    (clobber (reg:SI LR_REGNO))]
10852   "(DEFAULT_ABI == ABI_DARWIN
10853    || (DEFAULT_ABI == ABI_V4
10854        && (INTVAL (operands[2]) & CALL_LONG) == 0))"
10855 {
10856   if (INTVAL (operands[2]) & CALL_V4_SET_FP_ARGS)
10857     output_asm_insn ("crxor 6,6,6", operands);
10858
10859   else if (INTVAL (operands[2]) & CALL_V4_CLEAR_FP_ARGS)
10860     output_asm_insn ("creqv 6,6,6", operands);
10861
10862 #if TARGET_MACHO
10863   return output_call(insn, operands, 0, 2);
10864 #else
10865   if (DEFAULT_ABI == ABI_V4 && flag_pic)
10866     {
10867       gcc_assert (!TARGET_SECURE_PLT);
10868       return "bl %z0@plt";
10869     }
10870   else
10871     return "bl %z0";
10872 #endif
10873 }
10874   "DEFAULT_ABI == ABI_V4
10875    && TARGET_SECURE_PLT && flag_pic && !SYMBOL_REF_LOCAL_P (operands[0])
10876    && (INTVAL (operands[2]) & CALL_LONG) == 0"
10877   [(parallel [(call (mem:SI (match_dup 0))
10878                     (match_dup 1))
10879               (use (match_dup 2))
10880               (use (match_dup 3))
10881               (clobber (reg:SI LR_REGNO))])]
10882 {
10883   operands[3] = pic_offset_table_rtx;
10884 }
10885   [(set_attr "type" "branch,branch")
10886    (set_attr "length" "4,8")])
10887
10888 (define_insn "*call_nonlocal_sysv_secure<mode>"
10889   [(call (mem:SI (match_operand:P 0 "symbol_ref_operand" "s,s"))
10890          (match_operand 1 "" "g,g"))
10891    (use (match_operand:SI 2 "immediate_operand" "O,n"))
10892    (use (match_operand:SI 3 "register_operand" "r,r"))
10893    (clobber (reg:SI LR_REGNO))]
10894   "(DEFAULT_ABI == ABI_V4
10895     && TARGET_SECURE_PLT && flag_pic && !SYMBOL_REF_LOCAL_P (operands[0])
10896     && (INTVAL (operands[2]) & CALL_LONG) == 0)"
10897 {
10898   if (INTVAL (operands[2]) & CALL_V4_SET_FP_ARGS)
10899     output_asm_insn ("crxor 6,6,6", operands);
10900
10901   else if (INTVAL (operands[2]) & CALL_V4_CLEAR_FP_ARGS)
10902     output_asm_insn ("creqv 6,6,6", operands);
10903
10904   if (flag_pic == 2)
10905     /* The magic 32768 offset here and in the other sysv call insns
10906        corresponds to the offset of r30 in .got2, as given by LCTOC1.
10907        See sysv4.h:toc_section.  */
10908     return "bl %z0+32768@plt";
10909   else
10910     return "bl %z0@plt";
10911 }
10912   [(set_attr "type" "branch,branch")
10913    (set_attr "length" "4,8")])
10914
10915 (define_insn "*call_value_indirect_nonlocal_sysv<mode>"
10916   [(set (match_operand 0 "" "")
10917         (call (mem:SI (match_operand:P 1 "register_operand" "c,*l,c,*l"))
10918               (match_operand 2 "" "g,g,g,g")))
10919    (use (match_operand:SI 3 "immediate_operand" "O,O,n,n"))
10920    (clobber (reg:SI LR_REGNO))]
10921   "DEFAULT_ABI == ABI_V4
10922    || DEFAULT_ABI == ABI_DARWIN"
10923 {
10924   if (INTVAL (operands[3]) & CALL_V4_SET_FP_ARGS)
10925     output_asm_insn ("crxor 6,6,6", operands);
10926
10927   else if (INTVAL (operands[3]) & CALL_V4_CLEAR_FP_ARGS)
10928     output_asm_insn ("creqv 6,6,6", operands);
10929
10930   return "b%T1l";
10931 }
10932   [(set_attr "type" "jmpreg,jmpreg,jmpreg,jmpreg")
10933    (set_attr "length" "4,4,8,8")])
10934
10935 (define_insn_and_split "*call_value_nonlocal_sysv<mode>"
10936   [(set (match_operand 0 "" "")
10937         (call (mem:SI (match_operand:P 1 "symbol_ref_operand" "s,s"))
10938               (match_operand 2 "" "g,g")))
10939    (use (match_operand:SI 3 "immediate_operand" "O,n"))
10940    (clobber (reg:SI LR_REGNO))]
10941   "(DEFAULT_ABI == ABI_DARWIN
10942    || (DEFAULT_ABI == ABI_V4
10943        && (INTVAL (operands[3]) & CALL_LONG) == 0))"
10944 {
10945   if (INTVAL (operands[3]) & CALL_V4_SET_FP_ARGS)
10946     output_asm_insn ("crxor 6,6,6", operands);
10947
10948   else if (INTVAL (operands[3]) & CALL_V4_CLEAR_FP_ARGS)
10949     output_asm_insn ("creqv 6,6,6", operands);
10950
10951 #if TARGET_MACHO
10952   return output_call(insn, operands, 1, 3);
10953 #else
10954   if (DEFAULT_ABI == ABI_V4 && flag_pic)
10955     {
10956       gcc_assert (!TARGET_SECURE_PLT);
10957       return "bl %z1@plt";
10958     }
10959   else
10960     return "bl %z1";
10961 #endif
10962 }
10963   "DEFAULT_ABI == ABI_V4
10964    && TARGET_SECURE_PLT && flag_pic && !SYMBOL_REF_LOCAL_P (operands[1])
10965    && (INTVAL (operands[3]) & CALL_LONG) == 0"
10966   [(parallel [(set (match_dup 0)
10967                    (call (mem:SI (match_dup 1))
10968                          (match_dup 2)))
10969               (use (match_dup 3))
10970               (use (match_dup 4))
10971               (clobber (reg:SI LR_REGNO))])]
10972 {
10973   operands[4] = pic_offset_table_rtx;
10974 }
10975   [(set_attr "type" "branch,branch")
10976    (set_attr "length" "4,8")])
10977
10978 (define_insn "*call_value_nonlocal_sysv_secure<mode>"
10979   [(set (match_operand 0 "" "")
10980         (call (mem:SI (match_operand:P 1 "symbol_ref_operand" "s,s"))
10981               (match_operand 2 "" "g,g")))
10982    (use (match_operand:SI 3 "immediate_operand" "O,n"))
10983    (use (match_operand:SI 4 "register_operand" "r,r"))
10984    (clobber (reg:SI LR_REGNO))]
10985   "(DEFAULT_ABI == ABI_V4
10986     && TARGET_SECURE_PLT && flag_pic && !SYMBOL_REF_LOCAL_P (operands[1])
10987     && (INTVAL (operands[3]) & CALL_LONG) == 0)"
10988 {
10989   if (INTVAL (operands[3]) & CALL_V4_SET_FP_ARGS)
10990     output_asm_insn ("crxor 6,6,6", operands);
10991
10992   else if (INTVAL (operands[3]) & CALL_V4_CLEAR_FP_ARGS)
10993     output_asm_insn ("creqv 6,6,6", operands);
10994
10995   if (flag_pic == 2)
10996     return "bl %z1+32768@plt";
10997   else
10998     return "bl %z1@plt";
10999 }
11000   [(set_attr "type" "branch,branch")
11001    (set_attr "length" "4,8")])
11002
11003
11004 ;; Call to AIX abi function in the same module.
11005
11006 (define_insn "*call_local_aix<mode>"
11007   [(call (mem:SI (match_operand:P 0 "current_file_function_operand" "s"))
11008          (match_operand 1 "" "g"))
11009    (clobber (reg:P LR_REGNO))]
11010   "DEFAULT_ABI == ABI_AIX || DEFAULT_ABI == ABI_ELFv2"
11011   "bl %z0"
11012   [(set_attr "type" "branch")
11013    (set_attr "length" "4")])
11014
11015 (define_insn "*call_value_local_aix<mode>"
11016   [(set (match_operand 0 "" "")
11017         (call (mem:SI (match_operand:P 1 "current_file_function_operand" "s"))
11018               (match_operand 2 "" "g")))
11019    (clobber (reg:P LR_REGNO))]
11020   "DEFAULT_ABI == ABI_AIX || DEFAULT_ABI == ABI_ELFv2"
11021   "bl %z1"
11022   [(set_attr "type" "branch")
11023    (set_attr "length" "4")])
11024
11025 ;; Call to AIX abi function which may be in another module.
11026 ;; Restore the TOC pointer (r2) after the call.
11027
11028 (define_insn "*call_nonlocal_aix<mode>"
11029   [(call (mem:SI (match_operand:P 0 "symbol_ref_operand" "s"))
11030          (match_operand 1 "" "g"))
11031    (clobber (reg:P LR_REGNO))]
11032   "DEFAULT_ABI == ABI_AIX || DEFAULT_ABI == ABI_ELFv2"
11033   "bl %z0\;nop"
11034   [(set_attr "type" "branch")
11035    (set_attr "length" "8")])
11036
11037 (define_insn "*call_value_nonlocal_aix<mode>"
11038   [(set (match_operand 0 "" "")
11039         (call (mem:SI (match_operand:P 1 "symbol_ref_operand" "s"))
11040               (match_operand 2 "" "g")))
11041    (clobber (reg:P LR_REGNO))]
11042   "DEFAULT_ABI == ABI_AIX || DEFAULT_ABI == ABI_ELFv2"
11043   "bl %z1\;nop"
11044   [(set_attr "type" "branch")
11045    (set_attr "length" "8")])
11046
11047 ;; Call to indirect functions with the AIX abi using a 3 word descriptor.
11048 ;; Operand0 is the addresss of the function to call
11049 ;; Operand2 is the location in the function descriptor to load r2 from
11050 ;; Operand3 is the stack location to hold the current TOC pointer
11051
11052 (define_insn "*call_indirect_aix<mode>"
11053   [(call (mem:SI (match_operand:P 0 "register_operand" "c,*l"))
11054          (match_operand 1 "" "g,g"))
11055    (use (match_operand:P 2 "memory_operand" "<ptrm>,<ptrm>"))
11056    (set (reg:P TOC_REGNUM) (match_operand:P 3 "memory_operand" "<ptrm>,<ptrm>"))
11057    (clobber (reg:P LR_REGNO))]
11058   "DEFAULT_ABI == ABI_AIX"
11059   "<ptrload> 2,%2\;b%T0l\;<ptrload> 2,%3"
11060   [(set_attr "type" "jmpreg")
11061    (set_attr "length" "12")])
11062
11063 (define_insn "*call_value_indirect_aix<mode>"
11064   [(set (match_operand 0 "" "")
11065         (call (mem:SI (match_operand:P 1 "register_operand" "c,*l"))
11066               (match_operand 2 "" "g,g")))
11067    (use (match_operand:P 3 "memory_operand" "<ptrm>,<ptrm>"))
11068    (set (reg:P TOC_REGNUM) (match_operand:P 4 "memory_operand" "<ptrm>,<ptrm>"))
11069    (clobber (reg:P LR_REGNO))]
11070   "DEFAULT_ABI == ABI_AIX"
11071   "<ptrload> 2,%3\;b%T1l\;<ptrload> 2,%4"
11072   [(set_attr "type" "jmpreg")
11073    (set_attr "length" "12")])
11074
11075 ;; Call to indirect functions with the ELFv2 ABI.
11076 ;; Operand0 is the addresss of the function to call
11077 ;; Operand2 is the stack location to hold the current TOC pointer
11078
11079 (define_insn "*call_indirect_elfv2<mode>"
11080   [(call (mem:SI (match_operand:P 0 "register_operand" "c,*l"))
11081          (match_operand 1 "" "g,g"))
11082    (set (reg:P TOC_REGNUM) (match_operand:P 2 "memory_operand" "<ptrm>,<ptrm>"))
11083    (clobber (reg:P LR_REGNO))]
11084   "DEFAULT_ABI == ABI_ELFv2"
11085   "b%T0l\;<ptrload> 2,%2"
11086   [(set_attr "type" "jmpreg")
11087    (set_attr "length" "8")])
11088
11089 (define_insn "*call_value_indirect_elfv2<mode>"
11090   [(set (match_operand 0 "" "")
11091         (call (mem:SI (match_operand:P 1 "register_operand" "c,*l"))
11092               (match_operand 2 "" "g,g")))
11093    (set (reg:P TOC_REGNUM) (match_operand:P 3 "memory_operand" "<ptrm>,<ptrm>"))
11094    (clobber (reg:P LR_REGNO))]
11095   "DEFAULT_ABI == ABI_ELFv2"
11096   "b%T1l\;<ptrload> 2,%3"
11097   [(set_attr "type" "jmpreg")
11098    (set_attr "length" "8")])
11099
11100
11101 ;; Call subroutine returning any type.
11102 (define_expand "untyped_call"
11103   [(parallel [(call (match_operand 0 "" "")
11104                     (const_int 0))
11105               (match_operand 1 "" "")
11106               (match_operand 2 "" "")])]
11107   ""
11108   "
11109 {
11110   int i;
11111
11112   emit_call_insn (GEN_CALL (operands[0], const0_rtx, const0_rtx, const0_rtx));
11113
11114   for (i = 0; i < XVECLEN (operands[2], 0); i++)
11115     {
11116       rtx set = XVECEXP (operands[2], 0, i);
11117       emit_move_insn (SET_DEST (set), SET_SRC (set));
11118     }
11119
11120   /* The optimizer does not know that the call sets the function value
11121      registers we stored in the result block.  We avoid problems by
11122      claiming that all hard registers are used and clobbered at this
11123      point.  */
11124   emit_insn (gen_blockage ());
11125
11126   DONE;
11127 }")
11128
11129 ;; sibling call patterns
11130 (define_expand "sibcall"
11131   [(parallel [(call (mem:SI (match_operand 0 "address_operand" ""))
11132                     (match_operand 1 "" ""))
11133               (use (match_operand 2 "" ""))
11134               (use (reg:SI LR_REGNO))
11135               (simple_return)])]
11136   ""
11137   "
11138 {
11139 #if TARGET_MACHO
11140   if (MACHOPIC_INDIRECT)
11141     operands[0] = machopic_indirect_call_target (operands[0]);
11142 #endif
11143
11144   gcc_assert (GET_CODE (operands[0]) == MEM);
11145   gcc_assert (GET_CODE (operands[1]) == CONST_INT);
11146
11147   operands[0] = XEXP (operands[0], 0);
11148
11149   if (DEFAULT_ABI == ABI_AIX || DEFAULT_ABI == ABI_ELFv2)
11150     {
11151       rs6000_sibcall_aix (NULL_RTX, operands[0], operands[1], operands[2]);
11152       DONE;
11153     }
11154 }")
11155
11156 (define_expand "sibcall_value"
11157   [(parallel [(set (match_operand 0 "register_operand" "")
11158                 (call (mem:SI (match_operand 1 "address_operand" ""))
11159                       (match_operand 2 "" "")))
11160               (use (match_operand 3 "" ""))
11161               (use (reg:SI LR_REGNO))
11162               (simple_return)])]
11163   ""
11164   "
11165 {
11166 #if TARGET_MACHO
11167   if (MACHOPIC_INDIRECT)
11168     operands[1] = machopic_indirect_call_target (operands[1]);
11169 #endif
11170
11171   gcc_assert (GET_CODE (operands[1]) == MEM);
11172   gcc_assert (GET_CODE (operands[2]) == CONST_INT);
11173
11174   operands[1] = XEXP (operands[1], 0);
11175
11176   if (DEFAULT_ABI == ABI_AIX || DEFAULT_ABI == ABI_ELFv2)
11177     {
11178       rs6000_sibcall_aix (operands[0], operands[1], operands[2], operands[3]);
11179       DONE;
11180     }
11181 }")
11182
11183 ;; this and similar patterns must be marked as using LR, otherwise
11184 ;; dataflow will try to delete the store into it.  This is true
11185 ;; even when the actual reg to jump to is in CTR, when LR was
11186 ;; saved and restored around the PIC-setting BCL.
11187 (define_insn "*sibcall_local32"
11188   [(call (mem:SI (match_operand:SI 0 "current_file_function_operand" "s,s"))
11189          (match_operand 1 "" "g,g"))
11190    (use (match_operand:SI 2 "immediate_operand" "O,n"))
11191    (use (reg:SI LR_REGNO))
11192    (simple_return)]
11193   "(INTVAL (operands[2]) & CALL_LONG) == 0"
11194   "*
11195 {
11196   if (INTVAL (operands[2]) & CALL_V4_SET_FP_ARGS)
11197     output_asm_insn (\"crxor 6,6,6\", operands);
11198
11199   else if (INTVAL (operands[2]) & CALL_V4_CLEAR_FP_ARGS)
11200     output_asm_insn (\"creqv 6,6,6\", operands);
11201
11202   return (DEFAULT_ABI == ABI_V4 && flag_pic) ? \"b %z0@local\" : \"b %z0\";
11203 }"
11204   [(set_attr "type" "branch")
11205    (set_attr "length" "4,8")])
11206
11207 (define_insn "*sibcall_local64"
11208   [(call (mem:SI (match_operand:DI 0 "current_file_function_operand" "s,s"))
11209          (match_operand 1 "" "g,g"))
11210    (use (match_operand:SI 2 "immediate_operand" "O,n"))
11211    (use (reg:SI LR_REGNO))
11212    (simple_return)]
11213   "TARGET_64BIT && (INTVAL (operands[2]) & CALL_LONG) == 0"
11214   "*
11215 {
11216   if (INTVAL (operands[2]) & CALL_V4_SET_FP_ARGS)
11217     output_asm_insn (\"crxor 6,6,6\", operands);
11218
11219   else if (INTVAL (operands[2]) & CALL_V4_CLEAR_FP_ARGS)
11220     output_asm_insn (\"creqv 6,6,6\", operands);
11221
11222   return (DEFAULT_ABI == ABI_V4 && flag_pic) ? \"b %z0@local\" : \"b %z0\";
11223 }"
11224   [(set_attr "type" "branch")
11225    (set_attr "length" "4,8")])
11226
11227 (define_insn "*sibcall_value_local32"
11228   [(set (match_operand 0 "" "")
11229         (call (mem:SI (match_operand:SI 1 "current_file_function_operand" "s,s"))
11230               (match_operand 2 "" "g,g")))
11231    (use (match_operand:SI 3 "immediate_operand" "O,n"))
11232    (use (reg:SI LR_REGNO))
11233    (simple_return)]
11234   "(INTVAL (operands[3]) & CALL_LONG) == 0"
11235   "*
11236 {
11237   if (INTVAL (operands[3]) & CALL_V4_SET_FP_ARGS)
11238     output_asm_insn (\"crxor 6,6,6\", operands);
11239
11240   else if (INTVAL (operands[3]) & CALL_V4_CLEAR_FP_ARGS)
11241     output_asm_insn (\"creqv 6,6,6\", operands);
11242
11243   return (DEFAULT_ABI == ABI_V4 && flag_pic) ? \"b %z1@local\" : \"b %z1\";
11244 }"
11245   [(set_attr "type" "branch")
11246    (set_attr "length" "4,8")])
11247
11248 (define_insn "*sibcall_value_local64"
11249   [(set (match_operand 0 "" "")
11250         (call (mem:SI (match_operand:DI 1 "current_file_function_operand" "s,s"))
11251               (match_operand 2 "" "g,g")))
11252    (use (match_operand:SI 3 "immediate_operand" "O,n"))
11253    (use (reg:SI LR_REGNO))
11254    (simple_return)]
11255   "TARGET_64BIT && (INTVAL (operands[3]) & CALL_LONG) == 0"
11256   "*
11257 {
11258   if (INTVAL (operands[3]) & CALL_V4_SET_FP_ARGS)
11259     output_asm_insn (\"crxor 6,6,6\", operands);
11260
11261   else if (INTVAL (operands[3]) & CALL_V4_CLEAR_FP_ARGS)
11262     output_asm_insn (\"creqv 6,6,6\", operands);
11263
11264   return (DEFAULT_ABI == ABI_V4 && flag_pic) ? \"b %z1@local\" : \"b %z1\";
11265 }"
11266   [(set_attr "type" "branch")
11267    (set_attr "length" "4,8")])
11268
11269 (define_insn "*sibcall_nonlocal_sysv<mode>"
11270   [(call (mem:SI (match_operand:P 0 "call_operand" "s,s,c,c"))
11271          (match_operand 1 "" ""))
11272    (use (match_operand 2 "immediate_operand" "O,n,O,n"))
11273    (use (reg:SI LR_REGNO))
11274    (simple_return)]
11275   "(DEFAULT_ABI == ABI_DARWIN
11276     || DEFAULT_ABI == ABI_V4)
11277    && (INTVAL (operands[2]) & CALL_LONG) == 0"
11278   "*
11279 {
11280   if (INTVAL (operands[2]) & CALL_V4_SET_FP_ARGS)
11281     output_asm_insn (\"crxor 6,6,6\", operands);
11282
11283   else if (INTVAL (operands[2]) & CALL_V4_CLEAR_FP_ARGS)
11284     output_asm_insn (\"creqv 6,6,6\", operands);
11285
11286   if (which_alternative >= 2)
11287     return \"b%T0\";
11288   else if (DEFAULT_ABI == ABI_V4 && flag_pic)
11289     {
11290       gcc_assert (!TARGET_SECURE_PLT);
11291       return \"b %z0@plt\";
11292     }
11293   else
11294     return \"b %z0\";
11295 }"
11296   [(set_attr "type" "branch")
11297    (set_attr "length" "4,8,4,8")])
11298
11299 (define_insn "*sibcall_value_nonlocal_sysv<mode>"
11300   [(set (match_operand 0 "" "")
11301         (call (mem:SI (match_operand:P 1 "call_operand" "s,s,c,c"))
11302               (match_operand 2 "" "")))
11303    (use (match_operand:SI 3 "immediate_operand" "O,n,O,n"))
11304    (use (reg:SI LR_REGNO))
11305    (simple_return)]
11306   "(DEFAULT_ABI == ABI_DARWIN
11307     || DEFAULT_ABI == ABI_V4)
11308    && (INTVAL (operands[3]) & CALL_LONG) == 0"
11309   "*
11310 {
11311   if (INTVAL (operands[3]) & CALL_V4_SET_FP_ARGS)
11312     output_asm_insn (\"crxor 6,6,6\", operands);
11313
11314   else if (INTVAL (operands[3]) & CALL_V4_CLEAR_FP_ARGS)
11315     output_asm_insn (\"creqv 6,6,6\", operands);
11316
11317   if (which_alternative >= 2)
11318     return \"b%T1\";
11319   else if (DEFAULT_ABI == ABI_V4 && flag_pic)
11320     {
11321       gcc_assert (!TARGET_SECURE_PLT);
11322       return \"b %z1@plt\";
11323     }
11324   else
11325     return \"b %z1\";
11326 }"
11327   [(set_attr "type" "branch")
11328    (set_attr "length" "4,8,4,8")])
11329
11330 ;; AIX ABI sibling call patterns.
11331
11332 (define_insn "*sibcall_aix<mode>"
11333   [(call (mem:SI (match_operand:P 0 "call_operand" "s,c"))
11334          (match_operand 1 "" "g,g"))
11335    (simple_return)]
11336   "DEFAULT_ABI == ABI_AIX || DEFAULT_ABI == ABI_ELFv2"
11337   "@
11338    b %z0
11339    b%T0"
11340   [(set_attr "type" "branch")
11341    (set_attr "length" "4")])
11342
11343 (define_insn "*sibcall_value_aix<mode>"
11344   [(set (match_operand 0 "" "")
11345         (call (mem:SI (match_operand:P 1 "call_operand" "s,c"))
11346               (match_operand 2 "" "g,g")))
11347    (simple_return)]
11348   "DEFAULT_ABI == ABI_AIX || DEFAULT_ABI == ABI_ELFv2"
11349   "@
11350    b %z1
11351    b%T1"
11352   [(set_attr "type" "branch")
11353    (set_attr "length" "4")])
11354
11355 (define_expand "sibcall_epilogue"
11356   [(use (const_int 0))]
11357   ""
11358 {
11359   if (!TARGET_SCHED_PROLOG)
11360     emit_insn (gen_blockage ());
11361   rs6000_emit_epilogue (TRUE);
11362   DONE;
11363 })
11364
11365 ;; UNSPEC_VOLATILE is considered to use and clobber all hard registers and
11366 ;; all of memory.  This blocks insns from being moved across this point.
11367
11368 (define_insn "blockage"
11369   [(unspec_volatile [(const_int 0)] UNSPECV_BLOCK)]
11370   ""
11371   "")
11372
11373 (define_expand "probe_stack"
11374   [(set (match_operand 0 "memory_operand" "=m")
11375         (unspec [(const_int 0)] UNSPEC_PROBE_STACK))]
11376   ""
11377 {
11378   if (TARGET_64BIT)
11379     emit_insn (gen_probe_stack_di (operands[0]));
11380   else
11381     emit_insn (gen_probe_stack_si (operands[0]));
11382   DONE;
11383 })
11384
11385 (define_insn "probe_stack_<mode>"
11386   [(set (match_operand:P 0 "memory_operand" "=m")
11387         (unspec:P [(const_int 0)] UNSPEC_PROBE_STACK))]
11388   ""
11389 {
11390   operands[1] = gen_rtx_REG (Pmode, 0);
11391   return "st<wd>%U0%X0 %1,%0";
11392 }
11393   [(set_attr "type" "store")
11394    (set (attr "update")
11395         (if_then_else (match_operand 0 "update_address_mem")
11396                       (const_string "yes")
11397                       (const_string "no")))
11398    (set (attr "indexed")
11399         (if_then_else (match_operand 0 "indexed_address_mem")
11400                       (const_string "yes")
11401                       (const_string "no")))
11402    (set_attr "length" "4")])
11403
11404 (define_insn "probe_stack_range<P:mode>"
11405   [(set (match_operand:P 0 "register_operand" "=r")
11406         (unspec_volatile:P [(match_operand:P 1 "register_operand" "0")
11407                             (match_operand:P 2 "register_operand" "r")]
11408                            UNSPECV_PROBE_STACK_RANGE))]
11409   ""
11410   "* return output_probe_stack_range (operands[0], operands[2]);"
11411   [(set_attr "type" "three")])
11412 \f
11413 ;; Compare insns are next.  Note that the RS/6000 has two types of compares,
11414 ;; signed & unsigned, and one type of branch.
11415 ;;
11416 ;; Start with the DEFINE_EXPANDs to generate the rtl for compares, scc
11417 ;; insns, and branches.
11418
11419 (define_expand "cbranch<mode>4"
11420   [(use (match_operator 0 "rs6000_cbranch_operator"
11421          [(match_operand:GPR 1 "gpc_reg_operand" "")
11422           (match_operand:GPR 2 "reg_or_short_operand" "")]))
11423    (use (match_operand 3 ""))]
11424   ""
11425   "
11426 {
11427   /* Take care of the possibility that operands[2] might be negative but
11428      this might be a logical operation.  That insn doesn't exist.  */
11429   if (GET_CODE (operands[2]) == CONST_INT
11430       && INTVAL (operands[2]) < 0)
11431     {
11432       operands[2] = force_reg (<MODE>mode, operands[2]);
11433       operands[0] = gen_rtx_fmt_ee (GET_CODE (operands[0]),
11434                                     GET_MODE (operands[0]),
11435                                     operands[1], operands[2]);
11436    }
11437
11438   rs6000_emit_cbranch (<MODE>mode, operands);
11439   DONE;
11440 }")
11441
11442 (define_expand "cbranch<mode>4"
11443   [(use (match_operator 0 "rs6000_cbranch_operator"
11444          [(match_operand:FP 1 "gpc_reg_operand" "")
11445           (match_operand:FP 2 "gpc_reg_operand" "")]))
11446    (use (match_operand 3 ""))]
11447   ""
11448   "
11449 {
11450   rs6000_emit_cbranch (<MODE>mode, operands);
11451   DONE;
11452 }")
11453
11454 (define_expand "cstore<mode>4"
11455   [(use (match_operator 1 "rs6000_cbranch_operator"
11456          [(match_operand:GPR 2 "gpc_reg_operand" "")
11457           (match_operand:GPR 3 "reg_or_short_operand" "")]))
11458    (clobber (match_operand:SI 0 "register_operand"))]
11459   ""
11460   "
11461 {
11462   /* Take care of the possibility that operands[3] might be negative but
11463      this might be a logical operation.  That insn doesn't exist.  */
11464   if (GET_CODE (operands[3]) == CONST_INT
11465       && INTVAL (operands[3]) < 0)
11466     {
11467       operands[3] = force_reg (<MODE>mode, operands[3]);
11468       operands[1] = gen_rtx_fmt_ee (GET_CODE (operands[1]),
11469                                     GET_MODE (operands[1]),
11470                                     operands[2], operands[3]);
11471     }
11472
11473   /* For SNE, we would prefer that the xor/abs sequence be used for integers.
11474      For SEQ, likewise, except that comparisons with zero should be done
11475      with an scc insns.  However, due to the order that combine see the
11476      resulting insns, we must, in fact, allow SEQ for integers.  Fail in
11477      the cases we don't want to handle or are best handled by portable
11478      code.  */
11479   if (GET_CODE (operands[1]) == NE)
11480     FAIL;
11481   if ((GET_CODE (operands[1]) == LT || GET_CODE (operands[1]) == LE
11482        || GET_CODE (operands[1]) == GT || GET_CODE (operands[1]) == GE)
11483       && operands[3] == const0_rtx)
11484     FAIL;
11485   rs6000_emit_sCOND (<MODE>mode, operands);
11486   DONE;
11487 }")
11488
11489 (define_expand "cstore<mode>4"
11490   [(use (match_operator 1 "rs6000_cbranch_operator"
11491          [(match_operand:FP 2 "gpc_reg_operand" "")
11492           (match_operand:FP 3 "gpc_reg_operand" "")]))
11493    (clobber (match_operand:SI 0 "register_operand"))]
11494   ""
11495   "
11496 {
11497   rs6000_emit_sCOND (<MODE>mode, operands);
11498   DONE;
11499 }")
11500
11501
11502 (define_expand "stack_protect_set"
11503   [(match_operand 0 "memory_operand" "")
11504    (match_operand 1 "memory_operand" "")]
11505   ""
11506 {
11507 #ifdef TARGET_THREAD_SSP_OFFSET
11508   rtx tlsreg = gen_rtx_REG (Pmode, TARGET_64BIT ? 13 : 2);
11509   rtx addr = gen_rtx_PLUS (Pmode, tlsreg, GEN_INT (TARGET_THREAD_SSP_OFFSET));
11510   operands[1] = gen_rtx_MEM (Pmode, addr);
11511 #endif
11512   if (TARGET_64BIT)
11513     emit_insn (gen_stack_protect_setdi (operands[0], operands[1]));
11514   else
11515     emit_insn (gen_stack_protect_setsi (operands[0], operands[1]));
11516   DONE;
11517 })
11518
11519 (define_insn "stack_protect_setsi"
11520   [(set (match_operand:SI 0 "memory_operand" "=m")
11521         (unspec:SI [(match_operand:SI 1 "memory_operand" "m")] UNSPEC_SP_SET))
11522    (set (match_scratch:SI 2 "=&r") (const_int 0))]
11523   "TARGET_32BIT"
11524   "lwz%U1%X1 %2,%1\;stw%U0%X0 %2,%0\;li %2,0"
11525   [(set_attr "type" "three")
11526    (set_attr "length" "12")])
11527
11528 (define_insn "stack_protect_setdi"
11529   [(set (match_operand:DI 0 "memory_operand" "=Y")
11530         (unspec:DI [(match_operand:DI 1 "memory_operand" "Y")] UNSPEC_SP_SET))
11531    (set (match_scratch:DI 2 "=&r") (const_int 0))]
11532   "TARGET_64BIT"
11533   "ld%U1%X1 %2,%1\;std%U0%X0 %2,%0\;li %2,0"
11534   [(set_attr "type" "three")
11535    (set_attr "length" "12")])
11536
11537 (define_expand "stack_protect_test"
11538   [(match_operand 0 "memory_operand" "")
11539    (match_operand 1 "memory_operand" "")
11540    (match_operand 2 "" "")]
11541   ""
11542 {
11543   rtx test, op0, op1;
11544 #ifdef TARGET_THREAD_SSP_OFFSET
11545   rtx tlsreg = gen_rtx_REG (Pmode, TARGET_64BIT ? 13 : 2);
11546   rtx addr = gen_rtx_PLUS (Pmode, tlsreg, GEN_INT (TARGET_THREAD_SSP_OFFSET));
11547   operands[1] = gen_rtx_MEM (Pmode, addr);
11548 #endif
11549   op0 = operands[0];
11550   op1 = gen_rtx_UNSPEC (Pmode, gen_rtvec (1, operands[1]), UNSPEC_SP_TEST);
11551   test = gen_rtx_EQ (VOIDmode, op0, op1);
11552   emit_jump_insn (gen_cbranchsi4 (test, op0, op1, operands[2]));
11553   DONE;
11554 })
11555
11556 (define_insn "stack_protect_testsi"
11557   [(set (match_operand:CCEQ 0 "cc_reg_operand" "=x,?y")
11558         (unspec:CCEQ [(match_operand:SI 1 "memory_operand" "m,m")
11559                       (match_operand:SI 2 "memory_operand" "m,m")]
11560                      UNSPEC_SP_TEST))
11561    (set (match_scratch:SI 4 "=r,r") (const_int 0))
11562    (clobber (match_scratch:SI 3 "=&r,&r"))]
11563   "TARGET_32BIT"
11564   "@
11565    lwz%U1%X1 %3,%1\;lwz%U2%X2 %4,%2\;xor. %3,%3,%4\;li %4,0
11566    lwz%U1%X1 %3,%1\;lwz%U2%X2 %4,%2\;cmplw %0,%3,%4\;li %3,0\;li %4,0"
11567   [(set_attr "length" "16,20")])
11568
11569 (define_insn "stack_protect_testdi"
11570   [(set (match_operand:CCEQ 0 "cc_reg_operand" "=x,?y")
11571         (unspec:CCEQ [(match_operand:DI 1 "memory_operand" "Y,Y")
11572                       (match_operand:DI 2 "memory_operand" "Y,Y")]
11573                      UNSPEC_SP_TEST))
11574    (set (match_scratch:DI 4 "=r,r") (const_int 0))
11575    (clobber (match_scratch:DI 3 "=&r,&r"))]
11576   "TARGET_64BIT"
11577   "@
11578    ld%U1%X1 %3,%1\;ld%U2%X2 %4,%2\;xor. %3,%3,%4\;li %4,0
11579    ld%U1%X1 %3,%1\;ld%U2%X2 %4,%2\;cmpld %0,%3,%4\;li %3,0\;li %4,0"
11580   [(set_attr "length" "16,20")])
11581
11582 \f
11583 ;; Here are the actual compare insns.
11584 (define_insn "*cmp<mode>_internal1"
11585   [(set (match_operand:CC 0 "cc_reg_operand" "=y")
11586         (compare:CC (match_operand:GPR 1 "gpc_reg_operand" "r")
11587                     (match_operand:GPR 2 "reg_or_short_operand" "rI")))]
11588   ""
11589   "cmp<wd>%I2 %0,%1,%2"
11590   [(set_attr "type" "cmp")])
11591
11592 ;; If we are comparing a register for equality with a large constant,
11593 ;; we can do this with an XOR followed by a compare.  But this is profitable
11594 ;; only if the large constant is only used for the comparison (and in this
11595 ;; case we already have a register to reuse as scratch).
11596 ;;
11597 ;; For 64-bit registers, we could only do so if the constant's bit 15 is clear:
11598 ;; otherwise we'd need to XOR with FFFFFFFF????0000 which is not available.
11599
11600 (define_peephole2
11601   [(set (match_operand:SI 0 "register_operand")
11602         (match_operand:SI 1 "logical_const_operand" ""))
11603    (set (match_dup 0) (match_operator:SI 3 "boolean_or_operator"
11604                        [(match_dup 0)
11605                         (match_operand:SI 2 "logical_const_operand" "")]))
11606    (set (match_operand:CC 4 "cc_reg_operand" "")
11607         (compare:CC (match_operand:SI 5 "gpc_reg_operand" "")
11608                     (match_dup 0)))
11609    (set (pc)
11610         (if_then_else (match_operator 6 "equality_operator"
11611                        [(match_dup 4) (const_int 0)])
11612                       (match_operand 7 "" "")
11613                       (match_operand 8 "" "")))]
11614   "peep2_reg_dead_p (3, operands[0])
11615    && peep2_reg_dead_p (4, operands[4])"
11616  [(set (match_dup 0) (xor:SI (match_dup 5) (match_dup 9)))
11617   (set (match_dup 4) (compare:CC (match_dup 0) (match_dup 10)))
11618   (set (pc) (if_then_else (match_dup 6) (match_dup 7) (match_dup 8)))]
11619  
11620 {
11621   /* Get the constant we are comparing against, and see what it looks like
11622      when sign-extended from 16 to 32 bits.  Then see what constant we could
11623      XOR with SEXTC to get the sign-extended value.  */
11624   rtx cnst = simplify_const_binary_operation (GET_CODE (operands[3]),
11625                                               SImode,
11626                                               operands[1], operands[2]);
11627   HOST_WIDE_INT c = INTVAL (cnst);
11628   HOST_WIDE_INT sextc = ((c & 0xffff) ^ 0x8000) - 0x8000;
11629   HOST_WIDE_INT xorv = c ^ sextc;
11630
11631   operands[9] = GEN_INT (xorv);
11632   operands[10] = GEN_INT (sextc);
11633 })
11634
11635 (define_insn "*cmpsi_internal2"
11636   [(set (match_operand:CCUNS 0 "cc_reg_operand" "=y")
11637         (compare:CCUNS (match_operand:SI 1 "gpc_reg_operand" "r")
11638                        (match_operand:SI 2 "reg_or_u_short_operand" "rK")))]
11639   ""
11640   "cmplw%I2 %0,%1,%b2"
11641   [(set_attr "type" "cmp")])
11642
11643 (define_insn "*cmpdi_internal2"
11644   [(set (match_operand:CCUNS 0 "cc_reg_operand" "=y")
11645         (compare:CCUNS (match_operand:DI 1 "gpc_reg_operand" "r")
11646                        (match_operand:DI 2 "reg_or_u_short_operand" "rK")))]
11647   ""
11648   "cmpld%I2 %0,%1,%b2"
11649   [(set_attr "type" "cmp")])
11650
11651 ;; The following two insns don't exist as single insns, but if we provide
11652 ;; them, we can swap an add and compare, which will enable us to overlap more
11653 ;; of the required delay between a compare and branch.  We generate code for
11654 ;; them by splitting.
11655
11656 (define_insn ""
11657   [(set (match_operand:CC 3 "cc_reg_operand" "=y")
11658         (compare:CC (match_operand:SI 1 "gpc_reg_operand" "r")
11659                     (match_operand:SI 2 "short_cint_operand" "i")))
11660    (set (match_operand:SI 0 "gpc_reg_operand" "=r")
11661         (plus:SI (match_dup 1) (match_operand:SI 4 "short_cint_operand" "i")))]
11662   ""
11663   "#"
11664   [(set_attr "length" "8")])
11665
11666 (define_insn ""
11667   [(set (match_operand:CCUNS 3 "cc_reg_operand" "=y")
11668         (compare:CCUNS (match_operand:SI 1 "gpc_reg_operand" "r")
11669                        (match_operand:SI 2 "u_short_cint_operand" "i")))
11670    (set (match_operand:SI 0 "gpc_reg_operand" "=r")
11671         (plus:SI (match_dup 1) (match_operand:SI 4 "short_cint_operand" "i")))]
11672   ""
11673   "#"
11674   [(set_attr "length" "8")])
11675
11676 (define_split
11677   [(set (match_operand:CC 3 "cc_reg_operand" "")
11678         (compare:CC (match_operand:SI 1 "gpc_reg_operand" "")
11679                     (match_operand:SI 2 "short_cint_operand" "")))
11680    (set (match_operand:SI 0 "gpc_reg_operand" "")
11681         (plus:SI (match_dup 1) (match_operand:SI 4 "short_cint_operand" "")))]
11682   ""
11683   [(set (match_dup 3) (compare:CC (match_dup 1) (match_dup 2)))
11684    (set (match_dup 0) (plus:SI (match_dup 1) (match_dup 4)))])
11685
11686 (define_split
11687   [(set (match_operand:CCUNS 3 "cc_reg_operand" "")
11688         (compare:CCUNS (match_operand:SI 1 "gpc_reg_operand" "")
11689                        (match_operand:SI 2 "u_short_cint_operand" "")))
11690    (set (match_operand:SI 0 "gpc_reg_operand" "")
11691         (plus:SI (match_dup 1) (match_operand:SI 4 "short_cint_operand" "")))]
11692   ""
11693   [(set (match_dup 3) (compare:CCUNS (match_dup 1) (match_dup 2)))
11694    (set (match_dup 0) (plus:SI (match_dup 1) (match_dup 4)))])
11695
11696 ;; Only need to compare second words if first words equal
11697 (define_insn "*cmptf_internal1"
11698   [(set (match_operand:CCFP 0 "cc_reg_operand" "=y")
11699         (compare:CCFP (match_operand:TF 1 "gpc_reg_operand" "d")
11700                       (match_operand:TF 2 "gpc_reg_operand" "d")))]
11701   "!TARGET_IEEEQUAD && !TARGET_XL_COMPAT
11702    && TARGET_HARD_FLOAT && TARGET_FPRS && TARGET_DOUBLE_FLOAT && TARGET_LONG_DOUBLE_128"
11703   "fcmpu %0,%1,%2\;bne %0,$+8\;fcmpu %0,%L1,%L2"
11704   [(set_attr "type" "fpcompare")
11705    (set_attr "length" "12")])
11706
11707 (define_insn_and_split "*cmptf_internal2"
11708   [(set (match_operand:CCFP 0 "cc_reg_operand" "=y")
11709         (compare:CCFP (match_operand:TF 1 "gpc_reg_operand" "d")
11710                       (match_operand:TF 2 "gpc_reg_operand" "d")))
11711     (clobber (match_scratch:DF 3 "=d"))
11712     (clobber (match_scratch:DF 4 "=d"))
11713     (clobber (match_scratch:DF 5 "=d"))
11714     (clobber (match_scratch:DF 6 "=d"))
11715     (clobber (match_scratch:DF 7 "=d"))
11716     (clobber (match_scratch:DF 8 "=d"))
11717     (clobber (match_scratch:DF 9 "=d"))
11718     (clobber (match_scratch:DF 10 "=d"))
11719     (clobber (match_scratch:GPR 11 "=b"))]
11720   "!TARGET_IEEEQUAD && TARGET_XL_COMPAT
11721    && TARGET_HARD_FLOAT && TARGET_FPRS && TARGET_DOUBLE_FLOAT && TARGET_LONG_DOUBLE_128"
11722   "#"
11723   "&& reload_completed"
11724   [(set (match_dup 3) (match_dup 14))
11725    (set (match_dup 4) (match_dup 15))
11726    (set (match_dup 9) (abs:DF (match_dup 5)))
11727    (set (match_dup 0) (compare:CCFP (match_dup 9) (match_dup 3)))
11728    (set (pc) (if_then_else (ne (match_dup 0) (const_int 0))
11729                            (label_ref (match_dup 12))
11730                            (pc)))
11731    (set (match_dup 0) (compare:CCFP (match_dup 5) (match_dup 7)))
11732    (set (pc) (label_ref (match_dup 13)))
11733    (match_dup 12)
11734    (set (match_dup 10) (minus:DF (match_dup 5) (match_dup 7)))
11735    (set (match_dup 9) (minus:DF (match_dup 6) (match_dup 8)))
11736    (set (match_dup 9) (plus:DF (match_dup 10) (match_dup 9)))
11737    (set (match_dup 0) (compare:CCFP (match_dup 9) (match_dup 4)))
11738    (match_dup 13)]
11739 {
11740   REAL_VALUE_TYPE rv;
11741   const int lo_word = LONG_DOUBLE_LARGE_FIRST ? GET_MODE_SIZE (DFmode) : 0;
11742   const int hi_word = LONG_DOUBLE_LARGE_FIRST ? 0 : GET_MODE_SIZE (DFmode);
11743
11744   operands[5] = simplify_gen_subreg (DFmode, operands[1], TFmode, hi_word);
11745   operands[6] = simplify_gen_subreg (DFmode, operands[1], TFmode, lo_word);
11746   operands[7] = simplify_gen_subreg (DFmode, operands[2], TFmode, hi_word);
11747   operands[8] = simplify_gen_subreg (DFmode, operands[2], TFmode, lo_word);
11748   operands[12] = gen_label_rtx ();
11749   operands[13] = gen_label_rtx ();
11750   real_inf (&rv);
11751   operands[14] = force_const_mem (DFmode,
11752                                   CONST_DOUBLE_FROM_REAL_VALUE (rv, DFmode));
11753   operands[15] = force_const_mem (DFmode,
11754                                   CONST_DOUBLE_FROM_REAL_VALUE (dconst0,
11755                                                                 DFmode));
11756   if (TARGET_TOC)
11757     {
11758       rtx tocref;
11759       tocref = create_TOC_reference (XEXP (operands[14], 0), operands[11]);
11760       operands[14] = gen_const_mem (DFmode, tocref);
11761       tocref = create_TOC_reference (XEXP (operands[15], 0), operands[11]);
11762       operands[15] = gen_const_mem (DFmode, tocref);
11763       set_mem_alias_set (operands[14], get_TOC_alias_set ());
11764       set_mem_alias_set (operands[15], get_TOC_alias_set ());
11765     }
11766 })
11767 \f
11768 ;; Now we have the scc insns.  We can do some combinations because of the
11769 ;; way the machine works.
11770 ;;
11771 ;; Note that this is probably faster if we can put an insn between the
11772 ;; mfcr and rlinm, but this is tricky.  Let's leave it for now.  In most
11773 ;; cases the insns below which don't use an intermediate CR field will
11774 ;; be used instead.
11775 (define_insn ""
11776   [(set (match_operand:SI 0 "gpc_reg_operand" "=r")
11777         (match_operator:SI 1 "scc_comparison_operator"
11778                            [(match_operand 2 "cc_reg_operand" "y")
11779                             (const_int 0)]))]
11780   ""
11781   "mfcr %0%Q2\;rlwinm %0,%0,%J1,1"
11782   [(set (attr "type")
11783      (cond [(match_test "TARGET_MFCRF")
11784                 (const_string "mfcrf")
11785            ]
11786         (const_string "mfcr")))
11787    (set_attr "length" "8")])
11788
11789 ;; Same as above, but get the GT bit.
11790 (define_insn "move_from_CR_gt_bit"
11791   [(set (match_operand:SI 0 "gpc_reg_operand" "=r")
11792         (unspec:SI [(match_operand 1 "cc_reg_operand" "y")] UNSPEC_MV_CR_GT))]
11793   "TARGET_HARD_FLOAT && !TARGET_FPRS"
11794   "mfcr %0\;rlwinm %0,%0,%D1,31,31"
11795   [(set_attr "type" "mfcr")
11796    (set_attr "length" "8")])
11797
11798 ;; Same as above, but get the OV/ORDERED bit.
11799 (define_insn "move_from_CR_ov_bit"
11800   [(set (match_operand:SI 0 "gpc_reg_operand" "=r")
11801         (unspec:SI [(match_operand:CC 1 "cc_reg_operand" "y")]
11802                    UNSPEC_MV_CR_OV))]
11803   "TARGET_ISEL"
11804   "mfcr %0\;rlwinm %0,%0,%t1,1"
11805   [(set_attr "type" "mfcr")
11806    (set_attr "length" "8")])
11807
11808 (define_insn ""
11809   [(set (match_operand:DI 0 "gpc_reg_operand" "=r")
11810         (match_operator:DI 1 "scc_comparison_operator"
11811                            [(match_operand 2 "cc_reg_operand" "y")
11812                             (const_int 0)]))]
11813   "TARGET_POWERPC64"
11814   "mfcr %0%Q2\;rlwinm %0,%0,%J1,1"
11815   [(set (attr "type")
11816      (cond [(match_test "TARGET_MFCRF")
11817                 (const_string "mfcrf")
11818            ]
11819         (const_string "mfcr")))
11820    (set_attr "length" "8")])
11821
11822 (define_insn ""
11823   [(set (match_operand:CC 0 "cc_reg_operand" "=x,?y")
11824         (compare:CC (match_operator:SI 1 "scc_comparison_operator"
11825                                        [(match_operand 2 "cc_reg_operand" "y,y")
11826                                         (const_int 0)])
11827                     (const_int 0)))
11828    (set (match_operand:SI 3 "gpc_reg_operand" "=r,r")
11829         (match_op_dup 1 [(match_dup 2) (const_int 0)]))]
11830   "TARGET_32BIT"
11831   "@
11832    mfcr %3%Q2\;rlwinm. %3,%3,%J1,1
11833    #"
11834   [(set_attr "type" "shift")
11835    (set_attr "dot" "yes")
11836    (set_attr "length" "8,16")])
11837
11838 (define_split
11839   [(set (match_operand:CC 0 "cc_reg_not_cr0_operand" "")
11840         (compare:CC (match_operator:SI 1 "scc_comparison_operator"
11841                                        [(match_operand 2 "cc_reg_operand" "")
11842                                         (const_int 0)])
11843                     (const_int 0)))
11844    (set (match_operand:SI 3 "gpc_reg_operand" "")
11845         (match_op_dup 1 [(match_dup 2) (const_int 0)]))]
11846   "TARGET_32BIT && reload_completed"
11847   [(set (match_dup 3)
11848         (match_op_dup 1 [(match_dup 2) (const_int 0)]))
11849    (set (match_dup 0)
11850         (compare:CC (match_dup 3)
11851                     (const_int 0)))]
11852   "")
11853
11854 (define_insn ""
11855   [(set (match_operand:SI 0 "gpc_reg_operand" "=r")
11856         (ashift:SI (match_operator:SI 1 "scc_comparison_operator"
11857                                       [(match_operand 2 "cc_reg_operand" "y")
11858                                        (const_int 0)])
11859                    (match_operand:SI 3 "const_int_operand" "n")))]
11860   ""
11861   "*
11862 {
11863   int is_bit = ccr_bit (operands[1], 1);
11864   int put_bit = 31 - (INTVAL (operands[3]) & 31);
11865   int count;
11866
11867   if (is_bit >= put_bit)
11868     count = is_bit - put_bit;
11869   else
11870     count = 32 - (put_bit - is_bit);
11871
11872   operands[4] = GEN_INT (count);
11873   operands[5] = GEN_INT (put_bit);
11874
11875   return \"mfcr %0%Q2\;rlwinm %0,%0,%4,%5,%5\";
11876 }"
11877   [(set (attr "type")
11878      (cond [(match_test "TARGET_MFCRF")
11879                 (const_string "mfcrf")
11880            ]
11881         (const_string "mfcr")))
11882    (set_attr "length" "8")])
11883
11884 (define_insn ""
11885   [(set (match_operand:CC 0 "cc_reg_operand" "=x,?y")
11886         (compare:CC
11887          (ashift:SI (match_operator:SI 1 "scc_comparison_operator"
11888                                        [(match_operand 2 "cc_reg_operand" "y,y")
11889                                         (const_int 0)])
11890                     (match_operand:SI 3 "const_int_operand" "n,n"))
11891          (const_int 0)))
11892    (set (match_operand:SI 4 "gpc_reg_operand" "=r,r")
11893         (ashift:SI (match_op_dup 1 [(match_dup 2) (const_int 0)])
11894                    (match_dup 3)))]
11895   ""
11896   "*
11897 {
11898   int is_bit = ccr_bit (operands[1], 1);
11899   int put_bit = 31 - (INTVAL (operands[3]) & 31);
11900   int count;
11901
11902   /* Force split for non-cc0 compare.  */
11903   if (which_alternative == 1)
11904      return \"#\";
11905
11906   if (is_bit >= put_bit)
11907     count = is_bit - put_bit;
11908   else
11909     count = 32 - (put_bit - is_bit);
11910
11911   operands[5] = GEN_INT (count);
11912   operands[6] = GEN_INT (put_bit);
11913
11914   return \"mfcr %4%Q2\;rlwinm. %4,%4,%5,%6,%6\";
11915 }"
11916   [(set_attr "type" "shift")
11917    (set_attr "dot" "yes")
11918    (set_attr "length" "8,16")])
11919
11920 (define_split
11921   [(set (match_operand:CC 0 "cc_reg_not_micro_cr0_operand" "")
11922         (compare:CC
11923          (ashift:SI (match_operator:SI 1 "scc_comparison_operator"
11924                                        [(match_operand 2 "cc_reg_operand" "")
11925                                         (const_int 0)])
11926                     (match_operand:SI 3 "const_int_operand" ""))
11927          (const_int 0)))
11928    (set (match_operand:SI 4 "gpc_reg_operand" "")
11929         (ashift:SI (match_op_dup 1 [(match_dup 2) (const_int 0)])
11930                    (match_dup 3)))]
11931   "reload_completed"
11932   [(set (match_dup 4)
11933         (ashift:SI (match_op_dup 1 [(match_dup 2) (const_int 0)])
11934                    (match_dup 3)))
11935    (set (match_dup 0)
11936         (compare:CC (match_dup 4)
11937                     (const_int 0)))]
11938   "")
11939
11940 ;; There is a 3 cycle delay between consecutive mfcr instructions
11941 ;; so it is useful to combine 2 scc instructions to use only one mfcr.
11942
11943 (define_peephole
11944   [(set (match_operand:SI 0 "gpc_reg_operand" "=r")
11945         (match_operator:SI 1 "scc_comparison_operator"
11946                            [(match_operand 2 "cc_reg_operand" "y")
11947                             (const_int 0)]))
11948    (set (match_operand:SI 3 "gpc_reg_operand" "=r")
11949         (match_operator:SI 4 "scc_comparison_operator"
11950                            [(match_operand 5 "cc_reg_operand" "y")
11951                             (const_int 0)]))]
11952   "REGNO (operands[2]) != REGNO (operands[5])"
11953   "mfcr %3\;rlwinm %0,%3,%J1,1\;rlwinm %3,%3,%J4,1"
11954   [(set_attr "type" "mfcr")
11955    (set_attr "length" "12")])
11956
11957 (define_peephole
11958   [(set (match_operand:DI 0 "gpc_reg_operand" "=r")
11959         (match_operator:DI 1 "scc_comparison_operator"
11960                            [(match_operand 2 "cc_reg_operand" "y")
11961                             (const_int 0)]))
11962    (set (match_operand:DI 3 "gpc_reg_operand" "=r")
11963         (match_operator:DI 4 "scc_comparison_operator"
11964                            [(match_operand 5 "cc_reg_operand" "y")
11965                             (const_int 0)]))]
11966   "TARGET_POWERPC64 && REGNO (operands[2]) != REGNO (operands[5])"
11967   "mfcr %3\;rlwinm %0,%3,%J1,1\;rlwinm %3,%3,%J4,1"
11968   [(set_attr "type" "mfcr")
11969    (set_attr "length" "12")])
11970
11971 ;; There are some scc insns that can be done directly, without a compare.
11972 ;; These are faster because they don't involve the communications between
11973 ;; the FXU and branch units.   In fact, we will be replacing all of the
11974 ;; integer scc insns here or in the portable methods in emit_store_flag.
11975 ;;
11976 ;; Also support (neg (scc ..)) since that construct is used to replace
11977 ;; branches, (plus (scc ..) ..) since that construct is common and
11978 ;; takes no more insns than scc, and (and (neg (scc ..)) ..) in the
11979 ;; cases where it is no more expensive than (neg (scc ..)).
11980
11981 ;; Have reload force a constant into a register for the simple insns that
11982 ;; otherwise won't accept constants.  We do this because it is faster than
11983 ;; the cmp/mfcr sequence we would otherwise generate.
11984
11985 (define_mode_attr scc_eq_op2 [(SI "rKLI")
11986                               (DI "rKJI")])
11987
11988 (define_insn_and_split "*eq<mode>"
11989   [(set (match_operand:GPR 0 "gpc_reg_operand" "=r")
11990         (eq:GPR (match_operand:GPR 1 "gpc_reg_operand" "r")
11991                 (match_operand:GPR 2 "scc_eq_operand" "<scc_eq_op2>")))]
11992   ""
11993   "#"
11994   ""
11995   [(set (match_dup 0)
11996         (clz:GPR (match_dup 3)))
11997    (set (match_dup 0)
11998         (lshiftrt:GPR (match_dup 0) (match_dup 4)))]
11999   {
12000     if (GET_CODE (operands[2]) != CONST_INT || INTVAL (operands[2]) != 0)
12001       {
12002         /* Use output operand as intermediate.  */
12003         operands[3] = operands[0];
12004
12005         if (logical_operand (operands[2], <MODE>mode))
12006           emit_insn (gen_rtx_SET (VOIDmode, operands[3],
12007                                   gen_rtx_XOR (<MODE>mode,
12008                                                operands[1], operands[2])));
12009         else
12010           emit_insn (gen_rtx_SET (VOIDmode, operands[3],
12011                                   gen_rtx_PLUS (<MODE>mode, operands[1],
12012                                                 negate_rtx (<MODE>mode,
12013                                                             operands[2]))));
12014       }
12015     else
12016       operands[3] = operands[1];
12017
12018     operands[4] = GEN_INT (exact_log2 (GET_MODE_BITSIZE (<MODE>mode)));
12019   })
12020
12021 (define_insn_and_split "*eq<mode>_compare"
12022   [(set (match_operand:CC 3 "cc_reg_operand" "=y")
12023         (compare:CC
12024          (eq:P (match_operand:P 1 "gpc_reg_operand" "=r")
12025                (match_operand:P 2 "scc_eq_operand" "<scc_eq_op2>"))
12026          (const_int 0)))
12027    (set (match_operand:P 0 "gpc_reg_operand" "=r")
12028         (eq:P (match_dup 1) (match_dup 2)))]
12029   "optimize_size"
12030   "#"
12031   "optimize_size"
12032   [(set (match_dup 0)
12033         (clz:P (match_dup 4)))
12034    (parallel [(set (match_dup 3)
12035                    (compare:CC (lshiftrt:P (match_dup 0) (match_dup 5))
12036                                (const_int 0)))
12037               (set (match_dup 0)
12038                    (lshiftrt:P (match_dup 0) (match_dup 5)))])]
12039   {
12040     if (GET_CODE (operands[2]) != CONST_INT || INTVAL (operands[2]) != 0)
12041       {
12042         /* Use output operand as intermediate.  */
12043         operands[4] = operands[0];
12044
12045         if (logical_operand (operands[2], <MODE>mode))
12046           emit_insn (gen_rtx_SET (VOIDmode, operands[4],
12047                                   gen_rtx_XOR (<MODE>mode,
12048                                                operands[1], operands[2])));
12049         else
12050           emit_insn (gen_rtx_SET (VOIDmode, operands[4],
12051                                   gen_rtx_PLUS (<MODE>mode, operands[1],
12052                                                 negate_rtx (<MODE>mode,
12053                                                             operands[2]))));
12054       }
12055     else
12056       operands[4] = operands[1];
12057
12058     operands[5] = GEN_INT (exact_log2 (GET_MODE_BITSIZE (<MODE>mode)));
12059   })
12060
12061 ;; We have insns of the form shown by the first define_insn below.  If
12062 ;; there is something inside the comparison operation, we must split it.
12063 (define_split
12064   [(set (match_operand:SI 0 "gpc_reg_operand" "")
12065         (plus:SI (match_operator 1 "comparison_operator"
12066                                  [(match_operand:SI 2 "" "")
12067                                   (match_operand:SI 3
12068                                                     "reg_or_cint_operand" "")])
12069                  (match_operand:SI 4 "gpc_reg_operand" "")))
12070    (clobber (match_operand:SI 5 "register_operand" ""))]
12071   "! gpc_reg_operand (operands[2], SImode)"
12072   [(set (match_dup 5) (match_dup 2))
12073    (set (match_dup 0) (plus:SI (match_op_dup 1 [(match_dup 5) (match_dup 3)])
12074                                (match_dup 4)))])
12075
12076 (define_insn "*plus_eqsi"
12077   [(set (match_operand:SI 0 "gpc_reg_operand" "=&r,&r,&r,&r,&r")
12078         (plus:SI (eq:SI (match_operand:SI 1 "gpc_reg_operand" "%r,r,r,r,r")
12079                         (match_operand:SI 2 "scc_eq_operand" "r,O,K,L,I"))
12080                  (match_operand:SI 3 "gpc_reg_operand" "r,r,r,r,r")))]
12081   "TARGET_32BIT"
12082   "@
12083    xor %0,%1,%2\;subfic %0,%0,0\;addze %0,%3
12084    subfic %0,%1,0\;addze %0,%3
12085    xori %0,%1,%b2\;subfic %0,%0,0\;addze %0,%3
12086    xoris %0,%1,%u2\;subfic %0,%0,0\;addze %0,%3
12087    subfic %0,%1,%2\;subfic %0,%0,0\;addze %0,%3"
12088   [(set_attr "type" "three,two,three,three,three")
12089    (set_attr "length" "12,8,12,12,12")])
12090
12091 (define_insn "*compare_plus_eqsi"
12092   [(set (match_operand:CC 0 "cc_reg_operand" "=x,x,x,x,x,?y,?y,?y,?y,?y")
12093         (compare:CC
12094          (plus:SI
12095           (eq:SI (match_operand:SI 1 "gpc_reg_operand" "%r,r,r,r,r,r,r,r,r,r")
12096                  (match_operand:SI 2 "scc_eq_operand" "r,O,K,L,I,r,O,K,L,I"))
12097           (match_operand:SI 3 "gpc_reg_operand" "r,r,r,r,r,r,r,r,r,r"))
12098          (const_int 0)))
12099    (clobber (match_scratch:SI 4 "=&r,&r,&r,&r,&r,&r,&r,&r,&r,&r"))]
12100   "TARGET_32BIT && optimize_size"
12101   "@
12102    xor %4,%1,%2\;subfic %4,%4,0\;addze. %4,%3
12103    subfic %4,%1,0\;addze. %4,%3
12104    xori %4,%1,%b2\;subfic %4,%4,0\;addze. %4,%3
12105    xoris %4,%1,%u2\;subfic %4,%4,0\;addze. %4,%3
12106    subfic %4,%1,%2\;subfic %4,%4,0\;addze. %4,%3
12107    #
12108    #
12109    #
12110    #
12111    #"
12112   [(set_attr "type" "compare")
12113    (set_attr "length" "12,8,12,12,12,16,12,16,16,16")])
12114
12115 (define_split
12116   [(set (match_operand:CC 0 "cc_reg_not_cr0_operand" "")
12117         (compare:CC
12118          (plus:SI
12119           (eq:SI (match_operand:SI 1 "gpc_reg_operand" "")
12120                  (match_operand:SI 2 "scc_eq_operand" ""))
12121           (match_operand:SI 3 "gpc_reg_operand" ""))
12122          (const_int 0)))
12123    (clobber (match_scratch:SI 4 ""))]
12124   "TARGET_32BIT && optimize_size && reload_completed"
12125   [(set (match_dup 4)
12126         (plus:SI (eq:SI (match_dup 1)
12127                  (match_dup 2))
12128           (match_dup 3)))
12129    (set (match_dup 0)
12130         (compare:CC (match_dup 4)
12131                     (const_int 0)))]
12132   "")
12133
12134 (define_insn "*plus_eqsi_compare"
12135   [(set (match_operand:CC 4 "cc_reg_operand" "=x,x,x,x,x,?y,?y,?y,?y,?y")
12136         (compare:CC
12137          (plus:SI
12138           (eq:SI (match_operand:SI 1 "gpc_reg_operand" "%r,r,r,r,r,r,r,r,r,r")
12139                  (match_operand:SI 2 "scc_eq_operand" "r,O,K,L,I,r,O,K,L,I"))
12140           (match_operand:SI 3 "gpc_reg_operand" "r,r,r,r,r,r,r,r,r,r"))
12141          (const_int 0)))
12142    (set (match_operand:SI 0 "gpc_reg_operand" "=&r,&r,&r,&r,&r,&r,&r,&r,&r,&r")
12143         (plus:SI (eq:SI (match_dup 1) (match_dup 2)) (match_dup 3)))]
12144   "TARGET_32BIT && optimize_size"
12145   "@
12146    xor %0,%1,%2\;subfic %0,%0,0\;addze. %0,%3
12147    subfic %0,%1,0\;addze. %0,%3
12148    xori %0,%1,%b2\;subfic %0,%0,0\;addze. %0,%3
12149    xoris %0,%1,%u2\;subfic %0,%0,0\;addze. %0,%3
12150    subfic %0,%1,%2\;subfic %0,%0,0\;addze. %0,%3
12151    #
12152    #
12153    #
12154    #
12155    #"
12156   [(set_attr "type" "compare")
12157    (set_attr "length" "12,8,12,12,12,16,12,16,16,16")])
12158
12159 (define_split
12160   [(set (match_operand:CC 4 "cc_reg_not_cr0_operand" "")
12161         (compare:CC
12162          (plus:SI
12163           (eq:SI (match_operand:SI 1 "gpc_reg_operand" "")
12164                  (match_operand:SI 2 "scc_eq_operand" ""))
12165           (match_operand:SI 3 "gpc_reg_operand" ""))
12166          (const_int 0)))
12167    (set (match_operand:SI 0 "gpc_reg_operand" "")
12168         (plus:SI (eq:SI (match_dup 1) (match_dup 2)) (match_dup 3)))]
12169   "TARGET_32BIT && optimize_size && reload_completed"
12170   [(set (match_dup 0)
12171         (plus:SI (eq:SI (match_dup 1) (match_dup 2)) (match_dup 3)))
12172    (set (match_dup 4)
12173         (compare:CC (match_dup 0)
12174                     (const_int 0)))]
12175   "")
12176
12177 (define_insn "*neg_eq0<mode>"
12178   [(set (match_operand:P 0 "gpc_reg_operand" "=r")
12179         (neg:P (eq:P (match_operand:P 1 "gpc_reg_operand" "r")
12180                      (const_int 0))))]
12181   ""
12182   "addic %0,%1,-1\;subfe %0,%0,%0"
12183   [(set_attr "type" "two")
12184    (set_attr "length" "8")])
12185
12186 (define_insn_and_split "*neg_eq<mode>"
12187   [(set (match_operand:P 0 "gpc_reg_operand" "=r")
12188         (neg:P (eq:P (match_operand:P 1 "gpc_reg_operand" "%r")
12189                      (match_operand:P 2 "scc_eq_operand" "<scc_eq_op2>"))))]
12190   ""
12191   "#"
12192   ""
12193   [(set (match_dup 0) (neg:P (eq:P (match_dup 3) (const_int 0))))]
12194   {
12195     if (GET_CODE (operands[2]) != CONST_INT || INTVAL (operands[2]) != 0)
12196       {
12197         /* Use output operand as intermediate.  */
12198         operands[3] = operands[0];
12199
12200         if (logical_operand (operands[2], <MODE>mode))
12201           emit_insn (gen_rtx_SET (VOIDmode, operands[3],
12202                                   gen_rtx_XOR (<MODE>mode,
12203                                                operands[1], operands[2])));
12204         else
12205           emit_insn (gen_rtx_SET (VOIDmode, operands[3],
12206                                   gen_rtx_PLUS (<MODE>mode, operands[1],
12207                                                 negate_rtx (<MODE>mode,
12208                                                             operands[2]))));
12209       }
12210     else
12211       operands[3] = operands[1];
12212   })
12213
12214 (define_insn "*ne0_<mode>"
12215   [(set (match_operand:P 0 "gpc_reg_operand" "=r")
12216         (ne:P (match_operand:P 1 "gpc_reg_operand" "r")
12217               (const_int 0)))
12218    (clobber (match_scratch:P 2 "=&r"))]
12219   "!(TARGET_32BIT && TARGET_ISEL)"
12220   "addic %2,%1,-1\;subfe %0,%2,%1"
12221   [(set_attr "type" "two")
12222    (set_attr "length" "8")])
12223
12224 (define_insn "*plus_ne0_<mode>"
12225   [(set (match_operand:P 0 "gpc_reg_operand" "=r")
12226         (plus:P (ne:P (match_operand:P 1 "gpc_reg_operand" "r")
12227                       (const_int 0))
12228                 (match_operand:P 2 "gpc_reg_operand" "r")))
12229    (clobber (match_scratch:P 3 "=&r"))]
12230   ""
12231   "addic %3,%1,-1\;addze %0,%2"
12232   [(set_attr "type" "two")
12233    (set_attr "length" "8")])
12234
12235 (define_insn "*compare_plus_ne0_<mode>"
12236   [(set (match_operand:CC 0 "cc_reg_operand" "=x,?y")
12237         (compare:CC (plus:P (ne:P (match_operand:P 1 "gpc_reg_operand" "r,r")
12238                                   (const_int 0))
12239                             (match_operand:P 2 "gpc_reg_operand" "r,r"))
12240                     (const_int 0)))
12241    (clobber (match_scratch:P 3 "=&r,&r"))
12242    (clobber (match_scratch:P 4 "=X,&r"))]
12243   ""
12244   "@
12245    addic %3,%1,-1\;addze. %3,%2
12246    #"
12247   [(set_attr "type" "compare")
12248    (set_attr "length" "8,12")])
12249
12250 (define_split
12251   [(set (match_operand:CC 0 "cc_reg_not_micro_cr0_operand" "")
12252         (compare:CC (ne:P (match_operand:SI 1 "gpc_reg_operand" "")
12253                           (const_int 0))
12254                     (neg:P (match_operand:P 2 "gpc_reg_operand" ""))))
12255    (clobber (match_scratch:P 3 ""))
12256    (clobber (match_scratch:P 4 ""))]
12257   "reload_completed"
12258   [(parallel [(set (match_dup 3)
12259                    (plus:P (ne:P (match_dup 1)
12260                                  (const_int 0))
12261                            (match_dup 2)))
12262               (clobber (match_dup 4))])
12263    (set (match_dup 0)
12264         (compare:CC (match_dup 3)
12265                     (const_int 0)))]
12266   "")
12267
12268 ; For combine.
12269 (define_insn "*compare_plus_ne0_<mode>_1"
12270   [(set (match_operand:CCEQ 0 "cc_reg_operand" "=x,?y")
12271         (compare:CCEQ (ne:P (match_operand:P 1 "gpc_reg_operand" "r,r")
12272                             (const_int 0))
12273                       (neg:P (match_operand:P 2 "gpc_reg_operand" "r,r"))))
12274    (clobber (match_scratch:P 3 "=&r,&r"))
12275    (clobber (match_scratch:P 4 "=X,&r"))]
12276   ""
12277   "@
12278    addic %3,%1,-1\;addze. %3,%2
12279    #"
12280   [(set_attr "type" "compare")
12281    (set_attr "length" "8,12")])
12282
12283 (define_split
12284   [(set (match_operand:CCEQ 0 "cc_reg_not_micro_cr0_operand" "")
12285         (compare:CCEQ (ne:P (match_operand:SI 1 "gpc_reg_operand" "")
12286                             (const_int 0))
12287                       (neg:P (match_operand:P 2 "gpc_reg_operand" ""))))
12288    (clobber (match_scratch:P 3 ""))
12289    (clobber (match_scratch:P 4 ""))]
12290   "reload_completed"
12291   [(parallel [(set (match_dup 3)
12292                    (plus:P (ne:P (match_dup 1)
12293                                  (const_int 0))
12294                            (match_dup 2)))
12295               (clobber (match_dup 4))])
12296    (set (match_dup 0)
12297         (compare:CC (match_dup 3)
12298                     (const_int 0)))]
12299   "")
12300
12301 (define_insn "*plus_ne0_<mode>_compare"
12302   [(set (match_operand:CC 4 "cc_reg_operand" "=x,?y")
12303         (compare:CC
12304          (plus:P (ne:P (match_operand:P 1 "gpc_reg_operand" "r,r")
12305                        (const_int 0))
12306                  (match_operand:P 2 "gpc_reg_operand" "r,r"))
12307          (const_int 0)))
12308    (set (match_operand:P 0 "gpc_reg_operand" "=r,r")
12309         (plus:P (ne:P (match_dup 1)
12310                       (const_int 0))
12311                 (match_dup 2)))
12312    (clobber (match_scratch:P 3 "=&r,&r"))]
12313   ""
12314   "@
12315    addic %3,%1,-1\;addze. %0,%2
12316    #"
12317   [(set_attr "type" "compare")
12318    (set_attr "length" "8,12")])
12319
12320 (define_split
12321   [(set (match_operand:CC 4 "cc_reg_not_micro_cr0_operand" "")
12322         (compare:CC
12323          (plus:P (ne:P (match_operand:P 1 "gpc_reg_operand" "")
12324                        (const_int 0))
12325                  (match_operand:P 2 "gpc_reg_operand" ""))
12326          (const_int 0)))
12327    (set (match_operand:P 0 "gpc_reg_operand" "")
12328         (plus:P (ne:P (match_dup 1)
12329                       (const_int 0))
12330                 (match_dup 2)))
12331    (clobber (match_scratch:P 3 ""))]
12332   "reload_completed"
12333   [(parallel [(set (match_dup 0)
12334                    (plus:P (ne:P (match_dup 1)
12335                                  (const_int 0))
12336                            (match_dup 2)))
12337               (clobber (match_dup 3))])
12338    (set (match_dup 4)
12339         (compare:CC (match_dup 0)
12340                     (const_int 0)))]
12341   "")
12342
12343 (define_insn "*leu<mode>"
12344   [(set (match_operand:P 0 "gpc_reg_operand" "=r")
12345         (leu:P (match_operand:P 1 "gpc_reg_operand" "r")
12346                (match_operand:P 2 "reg_or_short_operand" "rI")))]
12347   ""
12348   "subf%I2c %0,%1,%2\;li %0,0\;adde %0,%0,%0"
12349   [(set_attr "type" "three")
12350    (set_attr "length" "12")])
12351
12352 (define_insn "*leu<mode>_compare"
12353   [(set (match_operand:CC 3 "cc_reg_operand" "=x,?y")
12354         (compare:CC
12355          (leu:P (match_operand:P 1 "gpc_reg_operand" "r,r")
12356                 (match_operand:P 2 "reg_or_short_operand" "rI,rI"))
12357          (const_int 0)))
12358    (set (match_operand:P 0 "gpc_reg_operand" "=r,r")
12359         (leu:P (match_dup 1) (match_dup 2)))]
12360   ""
12361   "@
12362    subf%I2c %0,%1,%2\;li %0,0\;adde. %0,%0,%0
12363    #"
12364   [(set_attr "type" "compare")
12365    (set_attr "length" "12,16")])
12366
12367 (define_split
12368   [(set (match_operand:CC 3 "cc_reg_not_cr0_operand" "")
12369         (compare:CC
12370          (leu:P (match_operand:P 1 "gpc_reg_operand" "")
12371                 (match_operand:P 2 "reg_or_short_operand" ""))
12372          (const_int 0)))
12373    (set (match_operand:P 0 "gpc_reg_operand" "")
12374         (leu:P (match_dup 1) (match_dup 2)))]
12375   "reload_completed"
12376   [(set (match_dup 0)
12377         (leu:P (match_dup 1) (match_dup 2)))
12378    (set (match_dup 3)
12379         (compare:CC (match_dup 0)
12380                     (const_int 0)))]
12381   "")
12382
12383 (define_insn "*plus_leu<mode>"
12384   [(set (match_operand:P 0 "gpc_reg_operand" "=&r")
12385         (plus:P (leu:P (match_operand:P 1 "gpc_reg_operand" "r")
12386                        (match_operand:P 2 "reg_or_short_operand" "rI"))
12387                 (match_operand:P 3 "gpc_reg_operand" "r")))]
12388   ""
12389   "subf%I2c %0,%1,%2\;addze %0,%3"
12390   [(set_attr "type" "two")
12391    (set_attr "length" "8")])
12392
12393 (define_insn ""
12394   [(set (match_operand:CC 0 "cc_reg_operand" "=x,?y")
12395         (compare:CC
12396          (plus:SI (leu:SI (match_operand:SI 1 "gpc_reg_operand" "r,r")
12397                           (match_operand:SI 2 "reg_or_short_operand" "rI,rI"))
12398                   (match_operand:SI 3 "gpc_reg_operand" "r,r"))
12399          (const_int 0)))
12400    (clobber (match_scratch:SI 4 "=&r,&r"))]
12401   "TARGET_32BIT"
12402   "@
12403    subf%I2c %4,%1,%2\;addze. %4,%3
12404    #"
12405   [(set_attr "type" "compare")
12406    (set_attr "length" "8,12")])
12407
12408 (define_split
12409   [(set (match_operand:CC 0 "cc_reg_not_cr0_operand" "")
12410         (compare:CC
12411          (plus:SI (leu:SI (match_operand:SI 1 "gpc_reg_operand" "")
12412                           (match_operand:SI 2 "reg_or_short_operand" ""))
12413                   (match_operand:SI 3 "gpc_reg_operand" ""))
12414          (const_int 0)))
12415    (clobber (match_scratch:SI 4 ""))]
12416   "TARGET_32BIT && reload_completed"
12417   [(set (match_dup 4)
12418         (plus:SI (leu:SI (match_dup 1) (match_dup 2))
12419                   (match_dup 3)))
12420    (set (match_dup 0)
12421         (compare:CC (match_dup 4)
12422                     (const_int 0)))]
12423   "")
12424
12425 (define_insn ""
12426   [(set (match_operand:CC 4 "cc_reg_operand" "=x,?y")
12427         (compare:CC
12428          (plus:SI (leu:SI (match_operand:SI 1 "gpc_reg_operand" "r,r")
12429                           (match_operand:SI 2 "reg_or_short_operand" "rI,rI"))
12430                   (match_operand:SI 3 "gpc_reg_operand" "r,r"))
12431          (const_int 0)))
12432    (set (match_operand:SI 0 "gpc_reg_operand" "=&r,&r")
12433         (plus:SI (leu:SI (match_dup 1) (match_dup 2)) (match_dup 3)))]
12434   "TARGET_32BIT"
12435   "@
12436    subf%I2c %0,%1,%2\;addze. %0,%3
12437    #"
12438   [(set_attr "type" "compare")
12439    (set_attr "length" "8,12")])
12440
12441 (define_split
12442   [(set (match_operand:CC 4 "cc_reg_not_cr0_operand" "")
12443         (compare:CC
12444          (plus:SI (leu:SI (match_operand:SI 1 "gpc_reg_operand" "")
12445                           (match_operand:SI 2 "reg_or_short_operand" ""))
12446                   (match_operand:SI 3 "gpc_reg_operand" ""))
12447          (const_int 0)))
12448    (set (match_operand:SI 0 "gpc_reg_operand" "")
12449         (plus:SI (leu:SI (match_dup 1) (match_dup 2)) (match_dup 3)))]
12450   "TARGET_32BIT && reload_completed"
12451   [(set (match_dup 0)
12452         (plus:SI (leu:SI (match_dup 1) (match_dup 2)) (match_dup 3)))
12453    (set (match_dup 4)
12454         (compare:CC (match_dup 0)
12455                     (const_int 0)))]
12456   "")
12457
12458 (define_insn "*neg_leu<mode>"
12459   [(set (match_operand:P 0 "gpc_reg_operand" "=r")
12460         (neg:P (leu:P (match_operand:P 1 "gpc_reg_operand" "r")
12461                       (match_operand:P 2 "reg_or_short_operand" "rI"))))]
12462   ""
12463   "subf%I2c %0,%1,%2\;subfe %0,%0,%0\;nand %0,%0,%0"
12464    [(set_attr "type" "three")
12465     (set_attr "length" "12")])
12466
12467 (define_insn "*and_neg_leu<mode>"
12468   [(set (match_operand:P 0 "gpc_reg_operand" "=&r")
12469         (and:P (neg:P
12470                  (leu:P (match_operand:P 1 "gpc_reg_operand" "r")
12471                         (match_operand:P 2 "reg_or_short_operand" "rI")))
12472                 (match_operand:P 3 "gpc_reg_operand" "r")))]
12473   ""
12474   "subf%I2c %0,%1,%2\;subfe %0,%0,%0\;andc %0,%3,%0"
12475   [(set_attr "type" "three")
12476    (set_attr "length" "12")])
12477
12478 (define_insn ""
12479   [(set (match_operand:CC 0 "cc_reg_operand" "=x,?y")
12480         (compare:CC
12481          (and:SI (neg:SI
12482                   (leu:SI (match_operand:SI 1 "gpc_reg_operand" "r,r")
12483                           (match_operand:SI 2 "reg_or_short_operand" "rI,rI")))
12484                  (match_operand:SI 3 "gpc_reg_operand" "r,r"))
12485          (const_int 0)))
12486    (clobber (match_scratch:SI 4 "=&r,&r"))]
12487   "TARGET_32BIT"
12488   "@
12489    subf%I2c %4,%1,%2\;subfe %4,%4,%4\;andc. %4,%3,%4
12490    #"
12491   [(set_attr "type" "compare")
12492    (set_attr "length" "12,16")])
12493
12494 (define_split
12495   [(set (match_operand:CC 0 "cc_reg_not_cr0_operand" "")
12496         (compare:CC
12497          (and:SI (neg:SI
12498                   (leu:SI (match_operand:SI 1 "gpc_reg_operand" "")
12499                           (match_operand:SI 2 "reg_or_short_operand" "")))
12500                  (match_operand:SI 3 "gpc_reg_operand" ""))
12501          (const_int 0)))
12502    (clobber (match_scratch:SI 4 ""))]
12503   "TARGET_32BIT && reload_completed"
12504   [(set (match_dup 4)
12505         (and:SI (neg:SI (leu:SI (match_dup 1) (match_dup 2)))
12506                 (match_dup 3)))
12507    (set (match_dup 0)
12508         (compare:CC (match_dup 4)
12509                     (const_int 0)))]
12510   "")
12511
12512 (define_insn ""
12513   [(set (match_operand:CC 4 "cc_reg_operand" "=x,?y")
12514         (compare:CC
12515          (and:SI (neg:SI
12516                   (leu:SI (match_operand:SI 1 "gpc_reg_operand" "r,r")
12517                           (match_operand:SI 2 "reg_or_short_operand" "rI,rI")))
12518                  (match_operand:SI 3 "gpc_reg_operand" "r,r"))
12519          (const_int 0)))
12520    (set (match_operand:SI 0 "gpc_reg_operand" "=&r,&r")
12521         (and:SI (neg:SI (leu:SI (match_dup 1) (match_dup 2))) (match_dup 3)))]
12522   "TARGET_32BIT"
12523   "@
12524    subf%I2c %0,%1,%2\;subfe %0,%0,%0\;andc. %0,%3,%0
12525    #"
12526   [(set_attr "type" "compare")
12527    (set_attr "length" "12,16")])
12528
12529 (define_split
12530   [(set (match_operand:CC 4 "cc_reg_not_cr0_operand" "")
12531         (compare:CC
12532          (and:SI (neg:SI
12533                   (leu:SI (match_operand:SI 1 "gpc_reg_operand" "")
12534                           (match_operand:SI 2 "reg_or_short_operand" "")))
12535                  (match_operand:SI 3 "gpc_reg_operand" ""))
12536          (const_int 0)))
12537    (set (match_operand:SI 0 "gpc_reg_operand" "")
12538         (and:SI (neg:SI (leu:SI (match_dup 1) (match_dup 2))) (match_dup 3)))]
12539   "TARGET_32BIT && reload_completed"
12540   [(set (match_dup 0)
12541         (and:SI (neg:SI (leu:SI (match_dup 1) (match_dup 2)))
12542                 (match_dup 3)))
12543    (set (match_dup 4)
12544         (compare:CC (match_dup 0)
12545                     (const_int 0)))]
12546   "")
12547
12548 (define_insn_and_split "*ltu<mode>"
12549   [(set (match_operand:P 0 "gpc_reg_operand" "=r,r")
12550         (ltu:P (match_operand:P 1 "gpc_reg_operand" "r,r")
12551                (match_operand:P 2 "reg_or_neg_short_operand" "r,P")))]
12552   ""
12553   "#"
12554   ""
12555   [(set (match_dup 0) (neg:P (ltu:P (match_dup 1) (match_dup 2))))
12556    (set (match_dup 0) (neg:P (match_dup 0)))]
12557   "")
12558
12559 (define_insn_and_split "*ltu<mode>_compare"
12560   [(set (match_operand:CC 3 "cc_reg_operand" "=x,x,?y,?y")
12561         (compare:CC
12562          (ltu:P (match_operand:P 1 "gpc_reg_operand" "r,r,r,r")
12563                 (match_operand:P 2 "reg_or_neg_short_operand" "r,P,r,P"))
12564          (const_int 0)))
12565    (set (match_operand:P 0 "gpc_reg_operand" "=r,r,r,r")
12566         (ltu:P (match_dup 1) (match_dup 2)))]
12567   ""
12568   "#"
12569   ""
12570   [(set (match_dup 0) (neg:P (ltu:P (match_dup 1) (match_dup 2))))
12571    (parallel [(set (match_dup 3)
12572                    (compare:CC (neg:P (match_dup 0)) (const_int 0)))
12573               (set (match_dup 0) (neg:P (match_dup 0)))])]
12574   "")
12575
12576 (define_insn_and_split "*plus_ltu<mode>"
12577   [(set (match_operand:P 0 "gpc_reg_operand" "=&r,r")
12578         (plus:P (ltu:P (match_operand:P 1 "gpc_reg_operand" "r,r")
12579                        (match_operand:P 2 "reg_or_neg_short_operand" "r,P"))
12580                 (match_operand:P 3 "gpc_reg_operand" "r,r")))]
12581   ""
12582   "#"
12583   "&& !reg_overlap_mentioned_p (operands[0], operands[3])"
12584   [(set (match_dup 0) (neg:P (ltu:P (match_dup 1) (match_dup 2))))
12585    (set (match_dup 0) (minus:P (match_dup 3) (match_dup 0)))]
12586   "")
12587
12588 (define_insn_and_split "*plus_ltu<mode>_1"
12589   [(set (match_operand:P 0 "gpc_reg_operand" "=&r,r")
12590         (plus:P (ltu:P (match_operand:P 1 "gpc_reg_operand" "r,r")
12591                        (match_operand:P 2 "reg_or_neg_short_operand" "r,P"))
12592                 (match_operand:P 3 "short_cint_operand" "I,I")))]
12593   ""
12594   "#"
12595   "&& !reg_overlap_mentioned_p (operands[0], operands[3])"
12596   [(set (match_dup 0) (neg:P (ltu:P (match_dup 1) (match_dup 2))))
12597    (parallel [(set (match_dup 0) (minus:P (match_dup 3) (match_dup 0)))
12598               (clobber (reg:P CA_REGNO))])]
12599   "")
12600
12601 (define_insn_and_split "*plus_ltu<mode>_compare"
12602   [(set (match_operand:CC 4 "cc_reg_operand" "=x,x,?y,?y")
12603         (compare:CC
12604          (plus:P (ltu:P (match_operand:P 1 "gpc_reg_operand" "r,r,r,r")
12605                         (match_operand:P 2 "reg_or_neg_short_operand" "r,P,r,P"))
12606                  (match_operand:P 3 "gpc_reg_operand" "r,r,r,r"))
12607          (const_int 0)))
12608    (set (match_operand:P 0 "gpc_reg_operand" "=&r,&r,&r,&r")
12609         (plus:P (ltu:P (match_dup 1) (match_dup 2)) (match_dup 3)))]
12610   ""
12611   "#"
12612   "&& !reg_overlap_mentioned_p (operands[0], operands[3])"
12613   [(set (match_dup 0) (neg:P (ltu:P (match_dup 1) (match_dup 2))))
12614    (parallel [(set (match_dup 4)
12615                    (compare:CC (minus:P (match_dup 3) (match_dup 0))
12616                                (const_int 0)))
12617               (set (match_dup 0) (minus:P (match_dup 3) (match_dup 0)))])]
12618   "")
12619
12620 (define_insn "*neg_ltu<mode>"
12621   [(set (match_operand:P 0 "gpc_reg_operand" "=r,r")
12622         (neg:P (ltu:P (match_operand:P 1 "gpc_reg_operand" "r,r")
12623                       (match_operand:P 2 "reg_or_neg_short_operand" "r,P"))))]
12624   ""
12625   "@
12626    subfc %0,%2,%1\;subfe %0,%0,%0
12627    addic %0,%1,%n2\;subfe %0,%0,%0"
12628   [(set_attr "type" "two")
12629    (set_attr "length" "8")])
12630
12631 (define_insn "*geu<mode>"
12632   [(set (match_operand:P 0 "gpc_reg_operand" "=r,r")
12633         (geu:P (match_operand:P 1 "gpc_reg_operand" "r,r")
12634                (match_operand:P 2 "reg_or_neg_short_operand" "r,P")))]
12635   ""
12636   "@
12637    subfc %0,%2,%1\;li %0,0\;adde %0,%0,%0
12638    addic %0,%1,%n2\;li %0,0\;adde %0,%0,%0"
12639   [(set_attr "type" "three")
12640    (set_attr "length" "12")])
12641
12642 (define_insn "*geu<mode>_compare"
12643   [(set (match_operand:CC 3 "cc_reg_operand" "=x,x,?y,?y")
12644         (compare:CC
12645          (geu:P (match_operand:P 1 "gpc_reg_operand" "r,r,r,r")
12646                 (match_operand:P 2 "reg_or_neg_short_operand" "r,P,r,P"))
12647          (const_int 0)))
12648    (set (match_operand:P 0 "gpc_reg_operand" "=r,r,r,r")
12649         (geu:P (match_dup 1) (match_dup 2)))]
12650   ""
12651   "@
12652    subfc %0,%2,%1\;li %0,0\;adde. %0,%0,%0
12653    addic %0,%1,%n2\;li %0,0\;adde. %0,%0,%0
12654    #
12655    #"
12656   [(set_attr "type" "compare")
12657    (set_attr "length" "12,12,16,16")])
12658
12659 (define_split
12660   [(set (match_operand:CC 3 "cc_reg_not_micro_cr0_operand" "")
12661         (compare:CC
12662          (geu:P (match_operand:P 1 "gpc_reg_operand" "")
12663                 (match_operand:P 2 "reg_or_neg_short_operand" ""))
12664          (const_int 0)))
12665    (set (match_operand:P 0 "gpc_reg_operand" "")
12666         (geu:P (match_dup 1) (match_dup 2)))]
12667   "reload_completed"
12668   [(set (match_dup 0)
12669         (geu:P (match_dup 1) (match_dup 2)))
12670    (set (match_dup 3)
12671         (compare:CC (match_dup 0)
12672                     (const_int 0)))]
12673   "")
12674
12675 (define_insn "*plus_geu<mode>"
12676   [(set (match_operand:P 0 "gpc_reg_operand" "=&r,&r")
12677         (plus:P (geu:P (match_operand:P 1 "gpc_reg_operand" "r,r")
12678                        (match_operand:P 2 "reg_or_neg_short_operand" "r,P"))
12679                 (match_operand:P 3 "gpc_reg_operand" "r,r")))]
12680   ""
12681   "@
12682    subfc %0,%2,%1\;addze %0,%3
12683    addic %0,%1,%n2\;addze %0,%3"
12684   [(set_attr "type" "two")
12685    (set_attr "length" "8")])
12686
12687 (define_insn ""
12688   [(set (match_operand:CC 0 "cc_reg_operand" "=x,x,?y,?y")
12689         (compare:CC
12690          (plus:SI (geu:SI (match_operand:SI 1 "gpc_reg_operand" "r,r,r,r")
12691                           (match_operand:SI 2 "reg_or_neg_short_operand" "r,P,r,P"))
12692                   (match_operand:SI 3 "gpc_reg_operand" "r,r,r,r"))
12693          (const_int 0)))
12694    (clobber (match_scratch:SI 4 "=&r,&r,&r,&r"))]
12695   "TARGET_32BIT"
12696   "@
12697    subfc %4,%2,%1\;addze. %4,%3
12698    addic %4,%1,%n2\;addze. %4,%3
12699    #
12700    #"
12701   [(set_attr "type" "compare")
12702    (set_attr "length" "8,8,12,12")])
12703
12704 (define_split
12705   [(set (match_operand:CC 0 "cc_reg_not_cr0_operand" "")
12706         (compare:CC
12707          (plus:SI (geu:SI (match_operand:SI 1 "gpc_reg_operand" "")
12708                           (match_operand:SI 2 "reg_or_neg_short_operand" ""))
12709                   (match_operand:SI 3 "gpc_reg_operand" ""))
12710          (const_int 0)))
12711    (clobber (match_scratch:SI 4 ""))]
12712   "TARGET_32BIT && reload_completed"
12713   [(set (match_dup 4)
12714         (plus:SI (geu:SI (match_dup 1) (match_dup 2))
12715                   (match_dup 3)))
12716    (set (match_dup 0)
12717         (compare:CC (match_dup 4)
12718                     (const_int 0)))]
12719   "")
12720
12721 (define_insn ""
12722   [(set (match_operand:CC 4 "cc_reg_operand" "=x,x,?y,?y")
12723         (compare:CC
12724          (plus:SI (geu:SI (match_operand:SI 1 "gpc_reg_operand" "r,r,r,r")
12725                           (match_operand:SI 2 "reg_or_neg_short_operand" "r,P,r,P"))
12726                   (match_operand:SI 3 "gpc_reg_operand" "r,r,r,r"))
12727          (const_int 0)))
12728    (set (match_operand:SI 0 "gpc_reg_operand" "=&r,&r,&r,&r")
12729         (plus:SI (geu:SI (match_dup 1) (match_dup 2)) (match_dup 3)))]
12730   "TARGET_32BIT"
12731   "@
12732    subfc %0,%2,%1\;addze. %0,%3
12733    addic %0,%1,%n2\;addze. %0,%3
12734    #
12735    #"
12736   [(set_attr "type" "compare")
12737    (set_attr "length" "8,8,12,12")])
12738
12739 (define_split
12740   [(set (match_operand:CC 4 "cc_reg_not_cr0_operand" "")
12741         (compare:CC
12742          (plus:SI (geu:SI (match_operand:SI 1 "gpc_reg_operand" "")
12743                           (match_operand:SI 2 "reg_or_neg_short_operand" ""))
12744                   (match_operand:SI 3 "gpc_reg_operand" ""))
12745          (const_int 0)))
12746    (set (match_operand:SI 0 "gpc_reg_operand" "")
12747         (plus:SI (geu:SI (match_dup 1) (match_dup 2)) (match_dup 3)))]
12748   "TARGET_32BIT && reload_completed"
12749   [(set (match_dup 0)
12750         (plus:SI (geu:SI (match_dup 1) (match_dup 2)) (match_dup 3)))
12751    (set (match_dup 4)
12752         (compare:CC (match_dup 0)
12753                     (const_int 0)))]
12754   "")
12755
12756 (define_insn "*neg_geu<mode>"
12757   [(set (match_operand:P 0 "gpc_reg_operand" "=r,r")
12758         (neg:P (geu:P (match_operand:P 1 "gpc_reg_operand" "r,r")
12759                       (match_operand:P 2 "reg_or_short_operand" "r,I"))))]
12760   ""
12761   "@
12762    subfc %0,%2,%1\;subfe %0,%0,%0\;nand %0,%0,%0
12763    subfic %0,%1,-1\;add%I2c %0,%0,%2\;subfe %0,%0,%0"
12764   [(set_attr "type" "three")
12765    (set_attr "length" "12")])
12766
12767 (define_insn "*and_neg_geu<mode>"
12768   [(set (match_operand:P 0 "gpc_reg_operand" "=&r,&r")
12769         (and:P (neg:P
12770                  (geu:P (match_operand:P 1 "gpc_reg_operand" "r,r")
12771                         (match_operand:P 2 "reg_or_neg_short_operand" "r,P")))
12772                 (match_operand:P 3 "gpc_reg_operand" "r,r")))]
12773   ""
12774   "@
12775    subfc %0,%2,%1\;subfe %0,%0,%0\;andc %0,%3,%0
12776    addic %0,%1,%n2\;subfe %0,%0,%0\;andc %0,%3,%0"
12777   [(set_attr "type" "three")
12778    (set_attr "length" "12")])
12779
12780 (define_insn ""
12781   [(set (match_operand:CC 0 "cc_reg_operand" "=x,x,?y,?y")
12782         (compare:CC
12783          (and:SI (neg:SI
12784                   (geu:SI (match_operand:SI 1 "gpc_reg_operand" "r,r,r,r")
12785                           (match_operand:SI 2 "reg_or_neg_short_operand" "r,P,r,P")))
12786                  (match_operand:SI 3 "gpc_reg_operand" "r,r,r,r"))
12787          (const_int 0)))
12788    (clobber (match_scratch:SI 4 "=&r,&r,&r,&r"))]
12789   "TARGET_32BIT"
12790   "@
12791    subfc %4,%2,%1\;subfe %4,%4,%4\;andc. %4,%3,%4
12792    addic %4,%1,%n2\;subfe %4,%4,%4\;andc. %4,%3,%4
12793    #
12794    #"
12795   [(set_attr "type" "compare")
12796    (set_attr "length" "12,12,16,16")])
12797
12798 (define_split
12799   [(set (match_operand:CC 0 "cc_reg_not_cr0_operand" "")
12800         (compare:CC
12801          (and:SI (neg:SI
12802                   (geu:SI (match_operand:SI 1 "gpc_reg_operand" "")
12803                           (match_operand:SI 2 "reg_or_neg_short_operand" "")))
12804                  (match_operand:SI 3 "gpc_reg_operand" ""))
12805          (const_int 0)))
12806    (clobber (match_scratch:SI 4 ""))]
12807   "TARGET_32BIT && reload_completed"
12808   [(set (match_dup 4)
12809         (and:SI (neg:SI (geu:SI (match_dup 1) (match_dup 2)))
12810                 (match_dup 3)))
12811    (set (match_dup 0)
12812         (compare:CC (match_dup 4)
12813                     (const_int 0)))]
12814   "")
12815
12816 (define_insn ""
12817   [(set (match_operand:CC 4 "cc_reg_operand" "=x,x,?y,?y")
12818         (compare:CC
12819          (and:SI (neg:SI
12820                   (geu:SI (match_operand:SI 1 "gpc_reg_operand" "r,r,r,r")
12821                           (match_operand:SI 2 "reg_or_neg_short_operand" "r,P,r,P")))
12822                  (match_operand:SI 3 "gpc_reg_operand" "r,r,r,r"))
12823          (const_int 0)))
12824    (set (match_operand:SI 0 "gpc_reg_operand" "=&r,&r,&r,&r")
12825         (and:SI (neg:SI (geu:SI (match_dup 1) (match_dup 2))) (match_dup 3)))]
12826   "TARGET_32BIT"
12827   "@
12828    subfc %0,%2,%1\;subfe %0,%0,%0\;andc. %0,%3,%0
12829    addic %0,%1,%n2\;subfe %0,%0,%0\;andc. %0,%3,%0
12830    #
12831    #"
12832   [(set_attr "type" "compare")
12833    (set_attr "length" "12,12,16,16")])
12834
12835 (define_split
12836   [(set (match_operand:CC 4 "cc_reg_not_cr0_operand" "")
12837         (compare:CC
12838          (and:SI (neg:SI
12839                   (geu:SI (match_operand:SI 1 "gpc_reg_operand" "")
12840                           (match_operand:SI 2 "reg_or_neg_short_operand" "")))
12841                  (match_operand:SI 3 "gpc_reg_operand" ""))
12842          (const_int 0)))
12843    (set (match_operand:SI 0 "gpc_reg_operand" "")
12844         (and:SI (neg:SI (geu:SI (match_dup 1) (match_dup 2))) (match_dup 3)))]
12845   "TARGET_32BIT && reload_completed"
12846   [(set (match_dup 0)
12847         (and:SI (neg:SI (geu:SI (match_dup 1) (match_dup 2))) (match_dup 3)))
12848    (set (match_dup 4)
12849         (compare:CC (match_dup 0)
12850                     (const_int 0)))]
12851   "")
12852
12853 (define_insn "*plus_gt0<mode>"
12854   [(set (match_operand:P 0 "gpc_reg_operand" "=&r")
12855         (plus:P (gt:P (match_operand:P 1 "gpc_reg_operand" "r")
12856                       (const_int 0))
12857                  (match_operand:P 2 "gpc_reg_operand" "r")))]
12858   ""
12859   "addc %0,%1,%1\;subfe %0,%1,%0\;addze %0,%2"
12860   [(set_attr "type" "three")
12861    (set_attr "length" "12")])
12862
12863 (define_insn ""
12864   [(set (match_operand:CC 0 "cc_reg_operand" "=x,?y")
12865         (compare:CC
12866          (plus:SI (gt:SI (match_operand:SI 1 "gpc_reg_operand" "r,r")
12867                          (const_int 0))
12868                   (match_operand:SI 2 "gpc_reg_operand" "r,r"))
12869          (const_int 0)))
12870    (clobber (match_scratch:SI 3 "=&r,&r"))]
12871   "TARGET_32BIT"
12872   "@
12873    addc %3,%1,%1\;subfe %3,%1,%3\;addze. %3,%2
12874    #"
12875   [(set_attr "type" "compare")
12876    (set_attr "length" "12,16")])
12877
12878 (define_split
12879   [(set (match_operand:CC 0 "cc_reg_not_cr0_operand" "")
12880         (compare:CC
12881          (plus:SI (gt:SI (match_operand:SI 1 "gpc_reg_operand" "")
12882                          (const_int 0))
12883                   (match_operand:SI 2 "gpc_reg_operand" ""))
12884          (const_int 0)))
12885    (clobber (match_scratch:SI 3 ""))]
12886   "TARGET_32BIT && reload_completed"
12887   [(set (match_dup 3)
12888         (plus:SI (gt:SI (match_dup 1) (const_int 0))
12889                   (match_dup 2)))
12890    (set (match_dup 0)
12891         (compare:CC (match_dup 3)
12892                     (const_int 0)))]
12893   "")
12894
12895 (define_insn ""
12896   [(set (match_operand:CC 0 "cc_reg_operand" "=x,?y")
12897         (compare:CC
12898          (plus:DI (gt:DI (match_operand:DI 1 "gpc_reg_operand" "r,r")
12899                          (const_int 0))
12900                   (match_operand:DI 2 "gpc_reg_operand" "r,r"))
12901          (const_int 0)))
12902    (clobber (match_scratch:DI 3 "=&r,&r"))]
12903   "TARGET_64BIT"
12904   "@
12905    addc %3,%1,%1\;subfe %3,%1,%3\;addze. %3,%2
12906    #"
12907   [(set_attr "type" "compare")
12908    (set_attr "length" "12,16")])
12909
12910 (define_split
12911   [(set (match_operand:CC 0 "cc_reg_not_micro_cr0_operand" "")
12912         (compare:CC
12913          (plus:DI (gt:DI (match_operand:DI 1 "gpc_reg_operand" "")
12914                          (const_int 0))
12915                   (match_operand:DI 2 "gpc_reg_operand" ""))
12916          (const_int 0)))
12917    (clobber (match_scratch:DI 3 ""))]
12918   "TARGET_64BIT && reload_completed"
12919   [(set (match_dup 3)
12920         (plus:DI (gt:DI (match_dup 1) (const_int 0))
12921                  (match_dup 2)))
12922    (set (match_dup 0)
12923         (compare:CC (match_dup 3)
12924                     (const_int 0)))]
12925   "")
12926
12927 (define_insn ""
12928   [(set (match_operand:CC 3 "cc_reg_operand" "=x,?y")
12929         (compare:CC
12930          (plus:SI (gt:SI (match_operand:SI 1 "gpc_reg_operand" "r,r")
12931                          (const_int 0))
12932                   (match_operand:SI 2 "gpc_reg_operand" "r,r"))
12933          (const_int 0)))
12934    (set (match_operand:SI 0 "gpc_reg_operand" "=&r,&r")
12935         (plus:SI (gt:SI (match_dup 1) (const_int 0)) (match_dup 2)))]
12936   "TARGET_32BIT"
12937   "@
12938    addc %0,%1,%1\;subfe %0,%1,%0\;addze. %0,%2
12939    #"
12940   [(set_attr "type" "compare")
12941    (set_attr "length" "12,16")])
12942
12943 (define_split
12944   [(set (match_operand:CC 3 "cc_reg_not_cr0_operand" "")
12945         (compare:CC
12946          (plus:SI (gt:SI (match_operand:SI 1 "gpc_reg_operand" "")
12947                          (const_int 0))
12948                   (match_operand:SI 2 "gpc_reg_operand" ""))
12949          (const_int 0)))
12950    (set (match_operand:SI 0 "gpc_reg_operand" "")
12951         (plus:SI (gt:SI (match_dup 1) (const_int 0)) (match_dup 2)))]
12952   "TARGET_32BIT && reload_completed"
12953   [(set (match_dup 0)
12954         (plus:SI (gt:SI (match_dup 1) (const_int 0)) (match_dup 2)))
12955    (set (match_dup 3)
12956         (compare:CC (match_dup 0)
12957                     (const_int 0)))]
12958   "")
12959
12960 (define_insn ""
12961   [(set (match_operand:CC 3 "cc_reg_operand" "=x,?y")
12962         (compare:CC
12963          (plus:DI (gt:DI (match_operand:DI 1 "gpc_reg_operand" "r,r")
12964                          (const_int 0))
12965                   (match_operand:DI 2 "gpc_reg_operand" "r,r"))
12966          (const_int 0)))
12967    (set (match_operand:DI 0 "gpc_reg_operand" "=&r,&r")
12968         (plus:DI (gt:DI (match_dup 1) (const_int 0)) (match_dup 2)))]
12969   "TARGET_64BIT"
12970   "@
12971    addc %0,%1,%1\;subfe %0,%1,%0\;addze. %0,%2
12972    #"
12973   [(set_attr "type" "compare")
12974    (set_attr "length" "12,16")])
12975
12976 (define_split
12977   [(set (match_operand:CC 3 "cc_reg_not_micro_cr0_operand" "")
12978         (compare:CC
12979          (plus:DI (gt:DI (match_operand:DI 1 "gpc_reg_operand" "")
12980                          (const_int 0))
12981                   (match_operand:DI 2 "gpc_reg_operand" ""))
12982          (const_int 0)))
12983    (set (match_operand:DI 0 "gpc_reg_operand" "")
12984         (plus:DI (gt:DI (match_dup 1) (const_int 0)) (match_dup 2)))]
12985   "TARGET_64BIT && reload_completed"
12986   [(set (match_dup 0)
12987         (plus:DI (gt:DI (match_dup 1) (const_int 0)) (match_dup 2)))
12988    (set (match_dup 3)
12989         (compare:CC (match_dup 0)
12990                     (const_int 0)))]
12991   "")
12992
12993 (define_insn_and_split "*gtu<mode>"
12994   [(set (match_operand:P 0 "gpc_reg_operand" "=r")
12995         (gtu:P (match_operand:P 1 "gpc_reg_operand" "r")
12996                (match_operand:P 2 "reg_or_short_operand" "rI")))]
12997   ""
12998   "#"
12999   ""
13000   [(set (match_dup 0) (neg:P (gtu:P (match_dup 1) (match_dup 2))))
13001    (set (match_dup 0) (neg:P (match_dup 0)))]
13002   "")
13003
13004 (define_insn_and_split "*gtu<mode>_compare"
13005   [(set (match_operand:CC 3 "cc_reg_operand" "=x,?y")
13006         (compare:CC
13007          (gtu:P (match_operand:P 1 "gpc_reg_operand" "r,r")
13008                  (match_operand:P 2 "reg_or_short_operand" "rI,rI"))
13009          (const_int 0)))
13010    (set (match_operand:P 0 "gpc_reg_operand" "=r,r")
13011         (gtu:P (match_dup 1) (match_dup 2)))]
13012   ""
13013   "#"
13014   ""
13015   [(set (match_dup 0) (neg:P (gtu:P (match_dup 1) (match_dup 2))))
13016    (parallel [(set (match_dup 3)
13017                    (compare:CC (neg:P (match_dup 0)) (const_int 0)))
13018               (set (match_dup 0) (neg:P (match_dup 0)))])]
13019   "")
13020
13021 (define_insn_and_split "*plus_gtu<mode>"
13022   [(set (match_operand:P 0 "gpc_reg_operand" "=&r")
13023         (plus:P (gtu:P (match_operand:P 1 "gpc_reg_operand" "r")
13024                        (match_operand:P 2 "reg_or_short_operand" "rI"))
13025                 (match_operand:P 3 "gpc_reg_operand" "r")))]
13026   ""
13027   "#"
13028   "&& !reg_overlap_mentioned_p (operands[0], operands[3])"
13029   [(set (match_dup 0) (neg:P (gtu:P (match_dup 1) (match_dup 2))))
13030    (set (match_dup 0) (minus:P (match_dup 3) (match_dup 0)))]
13031   "")
13032
13033 (define_insn_and_split "*plus_gtu<mode>_1"
13034   [(set (match_operand:P 0 "gpc_reg_operand" "=&r")
13035         (plus:P (gtu:P (match_operand:P 1 "gpc_reg_operand" "r")
13036                        (match_operand:P 2 "reg_or_short_operand" "rI"))
13037                 (match_operand:P 3 "short_cint_operand" "I")))]
13038   ""
13039   "#"
13040   "&& !reg_overlap_mentioned_p (operands[0], operands[3])"
13041   [(set (match_dup 0) (neg:P (gtu:P (match_dup 1) (match_dup 2))))
13042    (parallel [(set (match_dup 0) (minus:P (match_dup 3) (match_dup 0)))
13043               (clobber (reg:P CA_REGNO))])]
13044   "")
13045
13046 (define_insn_and_split "*plus_gtu<mode>_compare"
13047   [(set (match_operand:CC 4 "cc_reg_operand" "=x,x,?y,?y")
13048         (compare:CC
13049          (plus:P (gtu:P (match_operand:P 1 "gpc_reg_operand" "r,r,r,r")
13050                         (match_operand:P 2 "reg_or_short_operand" "I,r,I,r"))
13051                  (match_operand:P 3 "gpc_reg_operand" "r,r,r,r"))
13052          (const_int 0)))
13053    (set (match_operand:P 0 "gpc_reg_operand" "=&r,&r,&r,&r")
13054         (plus:P (gtu:P (match_dup 1) (match_dup 2)) (match_dup 3)))]
13055   ""
13056   "#"
13057   "&& !reg_overlap_mentioned_p (operands[0], operands[3])"
13058   [(set (match_dup 0) (neg:P (gtu:P (match_dup 1) (match_dup 2))))
13059    (parallel [(set (match_dup 4)
13060                    (compare:CC (minus:P (match_dup 3) (match_dup 0))
13061                                (const_int 0)))
13062               (set (match_dup 0) (minus:P (match_dup 3) (match_dup 0)))])]
13063   "")
13064
13065 (define_insn "*neg_gtu<mode>"
13066   [(set (match_operand:P 0 "gpc_reg_operand" "=r")
13067         (neg:P (gtu:P (match_operand:P 1 "gpc_reg_operand" "r")
13068                       (match_operand:P 2 "reg_or_short_operand" "rI"))))]
13069   ""
13070   "subf%I2c %0,%1,%2\;subfe %0,%0,%0"
13071   [(set_attr "type" "two")
13072    (set_attr "length" "8")])
13073
13074 \f
13075 ;; Define both directions of branch and return.  If we need a reload
13076 ;; register, we'd rather use CR0 since it is much easier to copy a
13077 ;; register CC value to there.
13078
13079 (define_insn ""
13080   [(set (pc)
13081         (if_then_else (match_operator 1 "branch_comparison_operator"
13082                                       [(match_operand 2
13083                                                       "cc_reg_operand" "y")
13084                                        (const_int 0)])
13085                       (label_ref (match_operand 0 "" ""))
13086                       (pc)))]
13087   ""
13088   "*
13089 {
13090   return output_cbranch (operands[1], \"%l0\", 0, insn);
13091 }"
13092   [(set_attr "type" "branch")])
13093
13094 (define_insn ""
13095   [(set (pc)
13096         (if_then_else (match_operator 0 "branch_comparison_operator"
13097                                       [(match_operand 1
13098                                                       "cc_reg_operand" "y")
13099                                        (const_int 0)])
13100                       (any_return)
13101                       (pc)))]
13102   "<return_pred>"
13103   "*
13104 {
13105   return output_cbranch (operands[0], NULL, 0, insn);
13106 }"
13107   [(set_attr "type" "jmpreg")
13108    (set_attr "length" "4")])
13109
13110 (define_insn ""
13111   [(set (pc)
13112         (if_then_else (match_operator 1 "branch_comparison_operator"
13113                                       [(match_operand 2
13114                                                       "cc_reg_operand" "y")
13115                                        (const_int 0)])
13116                       (pc)
13117                       (label_ref (match_operand 0 "" ""))))]
13118   ""
13119   "*
13120 {
13121   return output_cbranch (operands[1], \"%l0\", 1, insn);
13122 }"
13123   [(set_attr "type" "branch")])
13124
13125 (define_insn ""
13126   [(set (pc)
13127         (if_then_else (match_operator 0 "branch_comparison_operator"
13128                                       [(match_operand 1
13129                                                       "cc_reg_operand" "y")
13130                                        (const_int 0)])
13131                       (pc)
13132                       (any_return)))]
13133   "<return_pred>"
13134   "*
13135 {
13136   return output_cbranch (operands[0], NULL, 1, insn);
13137 }"
13138   [(set_attr "type" "jmpreg")
13139    (set_attr "length" "4")])
13140
13141 ;; Logic on condition register values.
13142
13143 ; This pattern matches things like
13144 ; (set (reg:CCEQ 68) (compare:CCEQ (ior:SI (gt:SI (reg:CCFP 68) (const_int 0))
13145 ;                                          (eq:SI (reg:CCFP 68) (const_int 0)))
13146 ;                                  (const_int 1)))
13147 ; which are generated by the branch logic.
13148 ; Prefer destructive operations where BT = BB (for crXX BT,BA,BB)
13149
13150 (define_insn "*cceq_ior_compare"
13151   [(set (match_operand:CCEQ 0 "cc_reg_operand" "=y,?y")
13152         (compare:CCEQ (match_operator:SI 1 "boolean_operator"
13153                         [(match_operator:SI 2
13154                                       "branch_positive_comparison_operator"
13155                                       [(match_operand 3
13156                                                       "cc_reg_operand" "y,y")
13157                                        (const_int 0)])
13158                          (match_operator:SI 4
13159                                       "branch_positive_comparison_operator"
13160                                       [(match_operand 5
13161                                                       "cc_reg_operand" "0,y")
13162                                        (const_int 0)])])
13163                       (const_int 1)))]
13164   ""
13165   "cr%q1 %E0,%j2,%j4"
13166   [(set_attr "type" "cr_logical,delayed_cr")])
13167
13168 ; Why is the constant -1 here, but 1 in the previous pattern?
13169 ; Because ~1 has all but the low bit set.
13170 (define_insn ""
13171   [(set (match_operand:CCEQ 0 "cc_reg_operand" "=y,?y")
13172         (compare:CCEQ (match_operator:SI 1 "boolean_or_operator"
13173                         [(not:SI (match_operator:SI 2
13174                                       "branch_positive_comparison_operator"
13175                                       [(match_operand 3
13176                                                       "cc_reg_operand" "y,y")
13177                                        (const_int 0)]))
13178                          (match_operator:SI 4
13179                                 "branch_positive_comparison_operator"
13180                                 [(match_operand 5
13181                                                 "cc_reg_operand" "0,y")
13182                                  (const_int 0)])])
13183                       (const_int -1)))]
13184   ""
13185   "cr%q1 %E0,%j2,%j4"
13186   [(set_attr "type" "cr_logical,delayed_cr")])
13187
13188 (define_insn "*cceq_rev_compare"
13189   [(set (match_operand:CCEQ 0 "cc_reg_operand" "=y,?y")
13190         (compare:CCEQ (match_operator:SI 1
13191                                       "branch_positive_comparison_operator"
13192                                       [(match_operand 2
13193                                                       "cc_reg_operand" "0,y")
13194                                        (const_int 0)])
13195                       (const_int 0)))]
13196   ""
13197   "crnot %E0,%j1"
13198   [(set_attr "type" "cr_logical,delayed_cr")])
13199
13200 ;; If we are comparing the result of two comparisons, this can be done
13201 ;; using creqv or crxor.
13202
13203 (define_insn_and_split ""
13204   [(set (match_operand:CCEQ 0 "cc_reg_operand" "=y")
13205         (compare:CCEQ (match_operator 1 "branch_comparison_operator"
13206                               [(match_operand 2 "cc_reg_operand" "y")
13207                                (const_int 0)])
13208                       (match_operator 3 "branch_comparison_operator"
13209                               [(match_operand 4 "cc_reg_operand" "y")
13210                                (const_int 0)])))]
13211   ""
13212   "#"
13213   ""
13214   [(set (match_dup 0) (compare:CCEQ (xor:SI (match_dup 1) (match_dup 3))
13215                                     (match_dup 5)))]
13216   "
13217 {
13218   int positive_1, positive_2;
13219
13220   positive_1 = branch_positive_comparison_operator (operands[1],
13221                                                     GET_MODE (operands[1]));
13222   positive_2 = branch_positive_comparison_operator (operands[3],
13223                                                     GET_MODE (operands[3]));
13224
13225   if (! positive_1)
13226     operands[1] = gen_rtx_fmt_ee (rs6000_reverse_condition (GET_MODE (operands[2]),
13227                                                             GET_CODE (operands[1])),
13228                                   SImode,
13229                                   operands[2], const0_rtx);
13230   else if (GET_MODE (operands[1]) != SImode)
13231     operands[1] = gen_rtx_fmt_ee (GET_CODE (operands[1]), SImode,
13232                                   operands[2], const0_rtx);
13233
13234   if (! positive_2)
13235     operands[3] = gen_rtx_fmt_ee (rs6000_reverse_condition (GET_MODE (operands[4]),
13236                                                             GET_CODE (operands[3])),
13237                                   SImode,
13238                                   operands[4], const0_rtx);
13239   else if (GET_MODE (operands[3]) != SImode)
13240     operands[3] = gen_rtx_fmt_ee (GET_CODE (operands[3]), SImode,
13241                                   operands[4], const0_rtx);
13242
13243   if (positive_1 == positive_2)
13244     {
13245       operands[1] = gen_rtx_NOT (SImode, operands[1]);
13246       operands[5] = constm1_rtx;
13247     }
13248   else
13249     {
13250       operands[5] = const1_rtx;
13251     }
13252 }")
13253
13254 ;; Unconditional branch and return.
13255
13256 (define_insn "jump"
13257   [(set (pc)
13258         (label_ref (match_operand 0 "" "")))]
13259   ""
13260   "b %l0"
13261   [(set_attr "type" "branch")])
13262
13263 (define_insn "<return_str>return"
13264   [(any_return)]
13265   "<return_pred>"
13266   "blr"
13267   [(set_attr "type" "jmpreg")])
13268
13269 (define_expand "indirect_jump"
13270   [(set (pc) (match_operand 0 "register_operand" ""))])
13271
13272 (define_insn "*indirect_jump<mode>"
13273   [(set (pc) (match_operand:P 0 "register_operand" "c,*l"))]
13274   ""
13275   "@
13276    bctr
13277    blr"
13278   [(set_attr "type" "jmpreg")])
13279
13280 ;; Table jump for switch statements:
13281 (define_expand "tablejump"
13282   [(use (match_operand 0 "" ""))
13283    (use (label_ref (match_operand 1 "" "")))]
13284   ""
13285   "
13286 {
13287   if (TARGET_32BIT)
13288     emit_jump_insn (gen_tablejumpsi (operands[0], operands[1]));
13289   else
13290     emit_jump_insn (gen_tablejumpdi (operands[0], operands[1]));
13291   DONE;
13292 }")
13293
13294 (define_expand "tablejumpsi"
13295   [(set (match_dup 3)
13296         (plus:SI (match_operand:SI 0 "" "")
13297                  (match_dup 2)))
13298    (parallel [(set (pc) (match_dup 3))
13299               (use (label_ref (match_operand 1 "" "")))])]
13300   "TARGET_32BIT"
13301   "
13302 { operands[0] = force_reg (SImode, operands[0]);
13303   operands[2] = force_reg (SImode, gen_rtx_LABEL_REF (SImode, operands[1]));
13304   operands[3] = gen_reg_rtx (SImode);
13305 }")
13306
13307 (define_expand "tablejumpdi"
13308   [(set (match_dup 4)
13309         (sign_extend:DI (match_operand:SI 0 "lwa_operand" "")))
13310    (set (match_dup 3)
13311         (plus:DI (match_dup 4)
13312                  (match_dup 2)))
13313    (parallel [(set (pc) (match_dup 3))
13314               (use (label_ref (match_operand 1 "" "")))])]
13315   "TARGET_64BIT"
13316   "
13317 { operands[2] = force_reg (DImode, gen_rtx_LABEL_REF (DImode, operands[1]));
13318   operands[3] = gen_reg_rtx (DImode);
13319   operands[4] = gen_reg_rtx (DImode);
13320 }")
13321
13322 (define_insn "*tablejump<mode>_internal1"
13323   [(set (pc)
13324         (match_operand:P 0 "register_operand" "c,*l"))
13325    (use (label_ref (match_operand 1 "" "")))]
13326   ""
13327   "@
13328    bctr
13329    blr"
13330   [(set_attr "type" "jmpreg")])
13331
13332 (define_insn "nop"
13333   [(const_int 0)]
13334   ""
13335   "nop")
13336
13337 (define_insn "group_ending_nop"
13338   [(unspec [(const_int 0)] UNSPEC_GRP_END_NOP)]
13339   ""
13340   "*
13341 {
13342   if (rs6000_cpu_attr == CPU_POWER6)
13343     return \"ori 1,1,0\";
13344   return \"ori 2,2,0\";
13345 }")
13346 \f
13347 ;; Define the subtract-one-and-jump insns, starting with the template
13348 ;; so loop.c knows what to generate.
13349
13350 (define_expand "doloop_end"
13351   [(use (match_operand 0 "" ""))        ; loop pseudo
13352    (use (match_operand 1 "" ""))]       ; label
13353   ""
13354   "
13355 {
13356   if (TARGET_64BIT)
13357     {
13358       if (GET_MODE (operands[0]) != DImode)
13359         FAIL;
13360       emit_jump_insn (gen_ctrdi (operands[0], operands[1]));
13361     }
13362   else
13363     {
13364       if (GET_MODE (operands[0]) != SImode)
13365         FAIL;
13366       emit_jump_insn (gen_ctrsi (operands[0], operands[1]));
13367     }
13368   DONE;
13369 }")
13370
13371 (define_expand "ctr<mode>"
13372   [(parallel [(set (pc)
13373                    (if_then_else (ne (match_operand:P 0 "register_operand" "")
13374                                      (const_int 1))
13375                                  (label_ref (match_operand 1 "" ""))
13376                                  (pc)))
13377               (set (match_dup 0)
13378                    (plus:P (match_dup 0)
13379                             (const_int -1)))
13380               (clobber (match_scratch:CC 2 ""))
13381               (clobber (match_scratch:P 3 ""))])]
13382   ""
13383   "")
13384
13385 ;; We need to be able to do this for any operand, including MEM, or we
13386 ;; will cause reload to blow up since we don't allow output reloads on
13387 ;; JUMP_INSNs.
13388 ;; For the length attribute to be calculated correctly, the
13389 ;; label MUST be operand 0.
13390
13391 (define_insn "*ctr<mode>_internal1"
13392   [(set (pc)
13393         (if_then_else (ne (match_operand:P 1 "register_operand" "c,*r,*r,*r")
13394                           (const_int 1))
13395                       (label_ref (match_operand 0 "" ""))
13396                       (pc)))
13397    (set (match_operand:P 2 "nonimmediate_operand" "=1,*r,m,*c*l")
13398         (plus:P (match_dup 1)
13399                  (const_int -1)))
13400    (clobber (match_scratch:CC 3 "=X,&x,&x,&x"))
13401    (clobber (match_scratch:P 4 "=X,X,&r,r"))]
13402   ""
13403   "*
13404 {
13405   if (which_alternative != 0)
13406     return \"#\";
13407   else if (get_attr_length (insn) == 4)
13408     return \"bdnz %l0\";
13409   else
13410     return \"bdz $+8\;b %l0\";
13411 }"
13412   [(set_attr "type" "branch")
13413    (set_attr "length" "*,12,16,16")])
13414
13415 (define_insn "*ctr<mode>_internal2"
13416   [(set (pc)
13417         (if_then_else (ne (match_operand:P 1 "register_operand" "c,*r,*r,*r")
13418                           (const_int 1))
13419                       (pc)
13420                       (label_ref (match_operand 0 "" ""))))
13421    (set (match_operand:P 2 "nonimmediate_operand" "=1,*r,m,*c*l")
13422         (plus:P (match_dup 1)
13423                  (const_int -1)))
13424    (clobber (match_scratch:CC 3 "=X,&x,&x,&x"))
13425    (clobber (match_scratch:P 4 "=X,X,&r,r"))]
13426   ""
13427   "*
13428 {
13429   if (which_alternative != 0)
13430     return \"#\";
13431   else if (get_attr_length (insn) == 4)
13432     return \"bdz %l0\";
13433   else
13434     return \"bdnz $+8\;b %l0\";
13435 }"
13436   [(set_attr "type" "branch")
13437    (set_attr "length" "*,12,16,16")])
13438
13439 ;; Similar but use EQ
13440
13441 (define_insn "*ctr<mode>_internal5"
13442   [(set (pc)
13443         (if_then_else (eq (match_operand:P 1 "register_operand" "c,*r,*r,*r")
13444                           (const_int 1))
13445                       (label_ref (match_operand 0 "" ""))
13446                       (pc)))
13447    (set (match_operand:P 2 "nonimmediate_operand" "=1,*r,m,*c*l")
13448         (plus:P (match_dup 1)
13449                  (const_int -1)))
13450    (clobber (match_scratch:CC 3 "=X,&x,&x,&x"))
13451    (clobber (match_scratch:P 4 "=X,X,&r,r"))]
13452   ""
13453   "*
13454 {
13455   if (which_alternative != 0)
13456     return \"#\";
13457   else if (get_attr_length (insn) == 4)
13458     return \"bdz %l0\";
13459   else
13460     return \"bdnz $+8\;b %l0\";
13461 }"
13462   [(set_attr "type" "branch")
13463    (set_attr "length" "*,12,16,16")])
13464
13465 (define_insn "*ctr<mode>_internal6"
13466   [(set (pc)
13467         (if_then_else (eq (match_operand:P 1 "register_operand" "c,*r,*r,*r")
13468                           (const_int 1))
13469                       (pc)
13470                       (label_ref (match_operand 0 "" ""))))
13471    (set (match_operand:P 2 "nonimmediate_operand" "=1,*r,m,*c*l")
13472         (plus:P (match_dup 1)
13473                  (const_int -1)))
13474    (clobber (match_scratch:CC 3 "=X,&x,&x,&x"))
13475    (clobber (match_scratch:P 4 "=X,X,&r,r"))]
13476   ""
13477   "*
13478 {
13479   if (which_alternative != 0)
13480     return \"#\";
13481   else if (get_attr_length (insn) == 4)
13482     return \"bdnz %l0\";
13483   else
13484     return \"bdz $+8\;b %l0\";
13485 }"
13486   [(set_attr "type" "branch")
13487    (set_attr "length" "*,12,16,16")])
13488
13489 ;; Now the splitters if we could not allocate the CTR register
13490
13491 (define_split
13492   [(set (pc)
13493         (if_then_else (match_operator 2 "comparison_operator"
13494                                       [(match_operand:P 1 "gpc_reg_operand" "")
13495                                        (const_int 1)])
13496                       (match_operand 5 "" "")
13497                       (match_operand 6 "" "")))
13498    (set (match_operand:P 0 "gpc_reg_operand" "")
13499         (plus:P (match_dup 1) (const_int -1)))
13500    (clobber (match_scratch:CC 3 ""))
13501    (clobber (match_scratch:P 4 ""))]
13502   "reload_completed"
13503   [(parallel [(set (match_dup 3)
13504                    (compare:CC (plus:P (match_dup 1)
13505                                         (const_int -1))
13506                                (const_int 0)))
13507               (set (match_dup 0)
13508                    (plus:P (match_dup 1)
13509                             (const_int -1)))])
13510    (set (pc) (if_then_else (match_dup 7)
13511                            (match_dup 5)
13512                            (match_dup 6)))]
13513   "
13514 { operands[7] = gen_rtx_fmt_ee (GET_CODE (operands[2]), VOIDmode,
13515                                 operands[3], const0_rtx); }")
13516
13517 (define_split
13518   [(set (pc)
13519         (if_then_else (match_operator 2 "comparison_operator"
13520                                       [(match_operand:P 1 "gpc_reg_operand" "")
13521                                        (const_int 1)])
13522                       (match_operand 5 "" "")
13523                       (match_operand 6 "" "")))
13524    (set (match_operand:P 0 "nonimmediate_operand" "")
13525         (plus:P (match_dup 1) (const_int -1)))
13526    (clobber (match_scratch:CC 3 ""))
13527    (clobber (match_scratch:P 4 ""))]
13528   "reload_completed && ! gpc_reg_operand (operands[0], SImode)"
13529   [(parallel [(set (match_dup 3)
13530                    (compare:CC (plus:P (match_dup 1)
13531                                         (const_int -1))
13532                                (const_int 0)))
13533               (set (match_dup 4)
13534                    (plus:P (match_dup 1)
13535                             (const_int -1)))])
13536    (set (match_dup 0)
13537         (match_dup 4))
13538    (set (pc) (if_then_else (match_dup 7)
13539                            (match_dup 5)
13540                            (match_dup 6)))]
13541   "
13542 { operands[7] = gen_rtx_fmt_ee (GET_CODE (operands[2]), VOIDmode,
13543                                 operands[3], const0_rtx); }")
13544 \f
13545 (define_insn "trap"
13546   [(trap_if (const_int 1) (const_int 0))]
13547   ""
13548   "trap"
13549   [(set_attr "type" "trap")])
13550
13551 (define_expand "ctrap<mode>4"
13552   [(trap_if (match_operator 0 "ordered_comparison_operator"
13553                             [(match_operand:GPR 1 "register_operand")
13554                              (match_operand:GPR 2 "reg_or_short_operand")])
13555             (match_operand 3 "zero_constant" ""))]
13556   ""
13557   "")
13558
13559 (define_insn ""
13560   [(trap_if (match_operator 0 "ordered_comparison_operator"
13561                             [(match_operand:GPR 1 "register_operand" "r")
13562                              (match_operand:GPR 2 "reg_or_short_operand" "rI")])
13563             (const_int 0))]
13564   ""
13565   "t<wd>%V0%I2 %1,%2"
13566   [(set_attr "type" "trap")])
13567 \f
13568 ;; Insns related to generating the function prologue and epilogue.
13569
13570 (define_expand "prologue"
13571   [(use (const_int 0))]
13572   ""
13573 {
13574   rs6000_emit_prologue ();
13575   if (!TARGET_SCHED_PROLOG)
13576     emit_insn (gen_blockage ());
13577   DONE;
13578 })
13579
13580 (define_insn "*movesi_from_cr_one"
13581   [(match_parallel 0 "mfcr_operation"
13582                    [(set (match_operand:SI 1 "gpc_reg_operand" "=r")
13583                          (unspec:SI [(match_operand:CC 2 "cc_reg_operand" "y")
13584                                      (match_operand 3 "immediate_operand" "n")]
13585                           UNSPEC_MOVESI_FROM_CR))])]
13586   "TARGET_MFCRF"
13587   "*
13588 {
13589   int mask = 0;
13590   int i;
13591   for (i = 0; i < XVECLEN (operands[0], 0); i++)
13592   {
13593     mask = INTVAL (XVECEXP (SET_SRC (XVECEXP (operands[0], 0, i)), 0, 1));
13594     operands[4] = GEN_INT (mask);
13595     output_asm_insn (\"mfcr %1,%4\", operands);
13596   }
13597   return \"\";
13598 }"
13599   [(set_attr "type" "mfcrf")])
13600
13601 (define_insn "movesi_from_cr"
13602   [(set (match_operand:SI 0 "gpc_reg_operand" "=r")
13603         (unspec:SI [(reg:CC CR0_REGNO) (reg:CC CR1_REGNO)
13604                     (reg:CC CR2_REGNO) (reg:CC CR3_REGNO)
13605                     (reg:CC CR4_REGNO) (reg:CC CR5_REGNO)
13606                     (reg:CC CR6_REGNO) (reg:CC CR7_REGNO)]
13607                    UNSPEC_MOVESI_FROM_CR))]
13608   ""
13609   "mfcr %0"
13610   [(set_attr "type" "mfcr")])
13611
13612 (define_insn "*crsave"
13613   [(match_parallel 0 "crsave_operation"
13614                    [(set (match_operand:SI 1 "memory_operand" "=m")
13615                          (match_operand:SI 2 "gpc_reg_operand" "r"))])]
13616   ""
13617   "stw %2,%1"
13618   [(set_attr "type" "store")])
13619
13620 (define_insn "*stmw"
13621   [(match_parallel 0 "stmw_operation"
13622                    [(set (match_operand:SI 1 "memory_operand" "=m")
13623                          (match_operand:SI 2 "gpc_reg_operand" "r"))])]
13624   "TARGET_MULTIPLE"
13625   "stmw %2,%1"
13626   [(set_attr "type" "store")
13627    (set_attr "update" "yes")
13628    (set_attr "indexed" "yes")])
13629
13630 ; The following comment applies to:
13631 ;     save_gpregs_*
13632 ;     save_fpregs_*
13633 ;     restore_gpregs*
13634 ;     return_and_restore_gpregs*
13635 ;     return_and_restore_fpregs*
13636 ;     return_and_restore_fpregs_aix*
13637 ;
13638 ; The out-of-line save / restore functions expects one input argument.
13639 ; Since those are not standard call_insn's, we must avoid using
13640 ; MATCH_OPERAND for that argument. That way the register rename
13641 ; optimization will not try to rename this register.
13642 ; Each pattern is repeated for each possible register number used in 
13643 ; various ABIs (r11, r1, and for some functions r12)
13644
13645 (define_insn "*save_gpregs_<mode>_r11"
13646   [(match_parallel 0 "any_parallel_operand"
13647                    [(clobber (reg:P 65))
13648                     (use (match_operand:P 1 "symbol_ref_operand" "s"))
13649                     (use (reg:P 11))
13650                     (set (match_operand:P 2 "memory_operand" "=m")
13651                          (match_operand:P 3 "gpc_reg_operand" "r"))])]
13652   ""
13653   "bl %1"
13654   [(set_attr "type" "branch")
13655    (set_attr "length" "4")])
13656
13657 (define_insn "*save_gpregs_<mode>_r12"
13658   [(match_parallel 0 "any_parallel_operand"
13659                    [(clobber (reg:P 65))
13660                     (use (match_operand:P 1 "symbol_ref_operand" "s"))
13661                     (use (reg:P 12))
13662                     (set (match_operand:P 2 "memory_operand" "=m")
13663                          (match_operand:P 3 "gpc_reg_operand" "r"))])]
13664   ""
13665   "bl %1"
13666   [(set_attr "type" "branch")
13667    (set_attr "length" "4")])
13668
13669 (define_insn "*save_gpregs_<mode>_r1"
13670   [(match_parallel 0 "any_parallel_operand"
13671                    [(clobber (reg:P 65))
13672                     (use (match_operand:P 1 "symbol_ref_operand" "s"))
13673                     (use (reg:P 1))
13674                     (set (match_operand:P 2 "memory_operand" "=m")
13675                          (match_operand:P 3 "gpc_reg_operand" "r"))])]
13676   ""
13677   "bl %1"
13678   [(set_attr "type" "branch")
13679    (set_attr "length" "4")])
13680
13681 (define_insn "*save_fpregs_<mode>_r11"
13682   [(match_parallel 0 "any_parallel_operand"
13683                    [(clobber (reg:P 65))
13684                     (use (match_operand:P 1 "symbol_ref_operand" "s"))
13685                     (use (reg:P 11))
13686                     (set (match_operand:DF 2 "memory_operand" "=m")
13687                          (match_operand:DF 3 "gpc_reg_operand" "d"))])]
13688   ""
13689   "bl %1"
13690   [(set_attr "type" "branch")
13691    (set_attr "length" "4")])
13692
13693 (define_insn "*save_fpregs_<mode>_r12"
13694   [(match_parallel 0 "any_parallel_operand"
13695                    [(clobber (reg:P 65))
13696                     (use (match_operand:P 1 "symbol_ref_operand" "s"))
13697                     (use (reg:P 12))
13698                     (set (match_operand:DF 2 "memory_operand" "=m")
13699                          (match_operand:DF 3 "gpc_reg_operand" "d"))])]
13700   ""
13701   "bl %1"
13702   [(set_attr "type" "branch")
13703    (set_attr "length" "4")])
13704
13705 (define_insn "*save_fpregs_<mode>_r1"
13706   [(match_parallel 0 "any_parallel_operand"
13707                    [(clobber (reg:P 65))
13708                     (use (match_operand:P 1 "symbol_ref_operand" "s"))
13709                     (use (reg:P 1))
13710                     (set (match_operand:DF 2 "memory_operand" "=m")
13711                          (match_operand:DF 3 "gpc_reg_operand" "d"))])]
13712   ""
13713   "bl %1"
13714   [(set_attr "type" "branch")
13715    (set_attr "length" "4")])
13716
13717 ; This is to explain that changes to the stack pointer should
13718 ; not be moved over loads from or stores to stack memory.
13719 (define_insn "stack_tie"
13720   [(match_parallel 0 "tie_operand"
13721                    [(set (mem:BLK (reg 1)) (const_int 0))])]
13722   ""
13723   ""
13724   [(set_attr "length" "0")])
13725
13726 (define_expand "epilogue"
13727   [(use (const_int 0))]
13728   ""
13729 {
13730   if (!TARGET_SCHED_PROLOG)
13731     emit_insn (gen_blockage ());
13732   rs6000_emit_epilogue (FALSE);
13733   DONE;
13734 })
13735
13736 ; On some processors, doing the mtcrf one CC register at a time is
13737 ; faster (like on the 604e).  On others, doing them all at once is
13738 ; faster; for instance, on the 601 and 750.
13739
13740 (define_expand "movsi_to_cr_one"
13741   [(set (match_operand:CC 0 "cc_reg_operand" "")
13742         (unspec:CC [(match_operand:SI 1 "gpc_reg_operand" "")
13743                     (match_dup 2)] UNSPEC_MOVESI_TO_CR))]
13744   ""
13745   "operands[2] = GEN_INT (1 << (75 - REGNO (operands[0])));")
13746
13747 (define_insn "*movsi_to_cr"
13748   [(match_parallel 0 "mtcrf_operation"
13749                    [(set (match_operand:CC 1 "cc_reg_operand" "=y")
13750                          (unspec:CC [(match_operand:SI 2 "gpc_reg_operand" "r")
13751                                      (match_operand 3 "immediate_operand" "n")]
13752                                     UNSPEC_MOVESI_TO_CR))])]
13753  ""
13754  "*
13755 {
13756   int mask = 0;
13757   int i;
13758   for (i = 0; i < XVECLEN (operands[0], 0); i++)
13759     mask |= INTVAL (XVECEXP (SET_SRC (XVECEXP (operands[0], 0, i)), 0, 1));
13760   operands[4] = GEN_INT (mask);
13761   return \"mtcrf %4,%2\";
13762 }"
13763   [(set_attr "type" "mtcr")])
13764
13765 (define_insn "*mtcrfsi"
13766   [(set (match_operand:CC 0 "cc_reg_operand" "=y")
13767         (unspec:CC [(match_operand:SI 1 "gpc_reg_operand" "r")
13768                     (match_operand 2 "immediate_operand" "n")]
13769                    UNSPEC_MOVESI_TO_CR))]
13770   "GET_CODE (operands[0]) == REG
13771    && CR_REGNO_P (REGNO (operands[0]))
13772    && GET_CODE (operands[2]) == CONST_INT
13773    && INTVAL (operands[2]) == 1 << (75 - REGNO (operands[0]))"
13774   "mtcrf %R0,%1"
13775   [(set_attr "type" "mtcr")])
13776
13777 ; The load-multiple instructions have similar properties.
13778 ; Note that "load_multiple" is a name known to the machine-independent
13779 ; code that actually corresponds to the PowerPC load-string.
13780
13781 (define_insn "*lmw"
13782   [(match_parallel 0 "lmw_operation"
13783                    [(set (match_operand:SI 1 "gpc_reg_operand" "=r")
13784                          (match_operand:SI 2 "memory_operand" "m"))])]
13785   "TARGET_MULTIPLE"
13786   "lmw %1,%2"
13787   [(set_attr "type" "load")
13788    (set_attr "update" "yes")
13789    (set_attr "indexed" "yes")
13790    (set_attr "cell_micro" "always")])
13791
13792 (define_insn "*return_internal_<mode>"
13793   [(simple_return)
13794    (use (match_operand:P 0 "register_operand" "lc"))]
13795   ""
13796   "b%T0"
13797   [(set_attr "type" "jmpreg")])
13798
13799 ; FIXME: This would probably be somewhat simpler if the Cygnus sibcall
13800 ; stuff was in GCC.  Oh, and "any_parallel_operand" is a bit flexible...
13801
13802 ; The following comment applies to:
13803 ;     save_gpregs_*
13804 ;     save_fpregs_*
13805 ;     restore_gpregs*
13806 ;     return_and_restore_gpregs*
13807 ;     return_and_restore_fpregs*
13808 ;     return_and_restore_fpregs_aix*
13809 ;
13810 ; The out-of-line save / restore functions expects one input argument.
13811 ; Since those are not standard call_insn's, we must avoid using
13812 ; MATCH_OPERAND for that argument. That way the register rename
13813 ; optimization will not try to rename this register.
13814 ; Each pattern is repeated for each possible register number used in 
13815 ; various ABIs (r11, r1, and for some functions r12)
13816
13817 (define_insn "*restore_gpregs_<mode>_r11"
13818  [(match_parallel 0 "any_parallel_operand"
13819                   [(clobber (match_operand:P 1 "register_operand" "=l"))
13820                    (use (match_operand:P 2 "symbol_ref_operand" "s"))
13821                    (use (reg:P 11))
13822                    (set (match_operand:P 3 "gpc_reg_operand" "=r")
13823                         (match_operand:P 4 "memory_operand" "m"))])]
13824  ""
13825  "bl %2"
13826  [(set_attr "type" "branch")
13827   (set_attr "length" "4")])
13828
13829 (define_insn "*restore_gpregs_<mode>_r12"
13830  [(match_parallel 0 "any_parallel_operand"
13831                   [(clobber (match_operand:P 1 "register_operand" "=l"))
13832                    (use (match_operand:P 2 "symbol_ref_operand" "s"))
13833                    (use (reg:P 12))
13834                    (set (match_operand:P 3 "gpc_reg_operand" "=r")
13835                         (match_operand:P 4 "memory_operand" "m"))])]
13836  ""
13837  "bl %2"
13838  [(set_attr "type" "branch")
13839   (set_attr "length" "4")])
13840
13841 (define_insn "*restore_gpregs_<mode>_r1"
13842  [(match_parallel 0 "any_parallel_operand"
13843                   [(clobber (match_operand:P 1 "register_operand" "=l"))
13844                    (use (match_operand:P 2 "symbol_ref_operand" "s"))
13845                    (use (reg:P 1))
13846                    (set (match_operand:P 3 "gpc_reg_operand" "=r")
13847                         (match_operand:P 4 "memory_operand" "m"))])]
13848  ""
13849  "bl %2"
13850  [(set_attr "type" "branch")
13851   (set_attr "length" "4")])
13852
13853 (define_insn "*return_and_restore_gpregs_<mode>_r11"
13854  [(match_parallel 0 "any_parallel_operand"
13855                   [(return)
13856                    (clobber (match_operand:P 1 "register_operand" "=l"))
13857                    (use (match_operand:P 2 "symbol_ref_operand" "s"))
13858                    (use (reg:P 11))
13859                    (set (match_operand:P 3 "gpc_reg_operand" "=r")
13860                         (match_operand:P 4 "memory_operand" "m"))])]
13861  ""
13862  "b %2"
13863  [(set_attr "type" "branch")
13864   (set_attr "length" "4")])
13865
13866 (define_insn "*return_and_restore_gpregs_<mode>_r12"
13867  [(match_parallel 0 "any_parallel_operand"
13868                   [(return)
13869                    (clobber (match_operand:P 1 "register_operand" "=l"))
13870                    (use (match_operand:P 2 "symbol_ref_operand" "s"))
13871                    (use (reg:P 12))
13872                    (set (match_operand:P 3 "gpc_reg_operand" "=r")
13873                         (match_operand:P 4 "memory_operand" "m"))])]
13874  ""
13875  "b %2"
13876  [(set_attr "type" "branch")
13877   (set_attr "length" "4")])
13878
13879 (define_insn "*return_and_restore_gpregs_<mode>_r1"
13880  [(match_parallel 0 "any_parallel_operand"
13881                   [(return)
13882                    (clobber (match_operand:P 1 "register_operand" "=l"))
13883                    (use (match_operand:P 2 "symbol_ref_operand" "s"))
13884                    (use (reg:P 1))
13885                    (set (match_operand:P 3 "gpc_reg_operand" "=r")
13886                         (match_operand:P 4 "memory_operand" "m"))])]
13887  ""
13888  "b %2"
13889  [(set_attr "type" "branch")
13890   (set_attr "length" "4")])
13891
13892 (define_insn "*return_and_restore_fpregs_<mode>_r11"
13893  [(match_parallel 0 "any_parallel_operand"
13894                   [(return)
13895                    (clobber (match_operand:P 1 "register_operand" "=l"))
13896                    (use (match_operand:P 2 "symbol_ref_operand" "s"))
13897                    (use (reg:P 11))
13898                    (set (match_operand:DF 3 "gpc_reg_operand" "=d")
13899                         (match_operand:DF 4 "memory_operand" "m"))])]
13900  ""
13901  "b %2"
13902  [(set_attr "type" "branch")
13903   (set_attr "length" "4")])
13904
13905 (define_insn "*return_and_restore_fpregs_<mode>_r12"
13906  [(match_parallel 0 "any_parallel_operand"
13907                   [(return)
13908                    (clobber (match_operand:P 1 "register_operand" "=l"))
13909                    (use (match_operand:P 2 "symbol_ref_operand" "s"))
13910                    (use (reg:P 12))
13911                    (set (match_operand:DF 3 "gpc_reg_operand" "=d")
13912                         (match_operand:DF 4 "memory_operand" "m"))])]
13913  ""
13914  "b %2"
13915  [(set_attr "type" "branch")
13916   (set_attr "length" "4")])
13917
13918 (define_insn "*return_and_restore_fpregs_<mode>_r1"
13919  [(match_parallel 0 "any_parallel_operand"
13920                   [(return)
13921                    (clobber (match_operand:P 1 "register_operand" "=l"))
13922                    (use (match_operand:P 2 "symbol_ref_operand" "s"))
13923                    (use (reg:P 1))
13924                    (set (match_operand:DF 3 "gpc_reg_operand" "=d")
13925                         (match_operand:DF 4 "memory_operand" "m"))])]
13926  ""
13927  "b %2"
13928  [(set_attr "type" "branch")
13929   (set_attr "length" "4")])
13930
13931 (define_insn "*return_and_restore_fpregs_aix_<mode>_r11"
13932  [(match_parallel 0 "any_parallel_operand"
13933                   [(return)
13934                    (use (match_operand:P 1 "register_operand" "l"))
13935                    (use (match_operand:P 2 "symbol_ref_operand" "s"))
13936                    (use (reg:P 11))
13937                    (set (match_operand:DF 3 "gpc_reg_operand" "=d")
13938                         (match_operand:DF 4 "memory_operand" "m"))])]
13939  ""
13940  "b %2"
13941  [(set_attr "type" "branch")
13942   (set_attr "length" "4")])
13943
13944 (define_insn "*return_and_restore_fpregs_aix_<mode>_r1"
13945  [(match_parallel 0 "any_parallel_operand"
13946                   [(return)
13947                    (use (match_operand:P 1 "register_operand" "l"))
13948                    (use (match_operand:P 2 "symbol_ref_operand" "s"))
13949                    (use (reg:P 1))
13950                    (set (match_operand:DF 3 "gpc_reg_operand" "=d")
13951                         (match_operand:DF 4 "memory_operand" "m"))])]
13952  ""
13953  "b %2"
13954  [(set_attr "type" "branch")
13955   (set_attr "length" "4")])
13956
13957 ; This is used in compiling the unwind routines.
13958 (define_expand "eh_return"
13959   [(use (match_operand 0 "general_operand" ""))]
13960   ""
13961   "
13962 {
13963   if (TARGET_32BIT)
13964     emit_insn (gen_eh_set_lr_si (operands[0]));
13965   else
13966     emit_insn (gen_eh_set_lr_di (operands[0]));
13967   DONE;
13968 }")
13969
13970 ; We can't expand this before we know where the link register is stored.
13971 (define_insn "eh_set_lr_<mode>"
13972   [(unspec_volatile [(match_operand:P 0 "register_operand" "r")]
13973                     UNSPECV_EH_RR)
13974    (clobber (match_scratch:P 1 "=&b"))]
13975   ""
13976   "#")
13977
13978 (define_split
13979   [(unspec_volatile [(match_operand 0 "register_operand" "")] UNSPECV_EH_RR)
13980    (clobber (match_scratch 1 ""))]
13981   "reload_completed"
13982   [(const_int 0)]
13983   "
13984 {
13985   rs6000_emit_eh_reg_restore (operands[0], operands[1]);
13986   DONE;
13987 }")
13988
13989 (define_insn "prefetch"
13990   [(prefetch (match_operand 0 "indexed_or_indirect_address" "a")
13991              (match_operand:SI 1 "const_int_operand" "n")
13992              (match_operand:SI 2 "const_int_operand" "n"))]
13993   ""
13994   "*
13995 {
13996   if (GET_CODE (operands[0]) == REG)
13997     return INTVAL (operands[1]) ? \"dcbtst 0,%0\" : \"dcbt 0,%0\";
13998   return INTVAL (operands[1]) ? \"dcbtst %a0\" : \"dcbt %a0\";
13999 }"
14000   [(set_attr "type" "load")])
14001 \f
14002 (define_insn "bpermd_<mode>"
14003   [(set (match_operand:P 0 "gpc_reg_operand" "=r")
14004         (unspec:P [(match_operand:P 1 "gpc_reg_operand" "r")
14005                    (match_operand:P 2 "gpc_reg_operand" "r")] UNSPEC_BPERM))]
14006   "TARGET_POPCNTD"
14007   "bpermd %0,%1,%2"
14008   [(set_attr "type" "popcnt")])
14009
14010 \f
14011 ;; Builtin fma support.  Handle 
14012 ;; Note that the conditions for expansion are in the FMA_F iterator.
14013
14014 (define_expand "fma<mode>4"
14015   [(set (match_operand:FMA_F 0 "register_operand" "")
14016         (fma:FMA_F
14017           (match_operand:FMA_F 1 "register_operand" "")
14018           (match_operand:FMA_F 2 "register_operand" "")
14019           (match_operand:FMA_F 3 "register_operand" "")))]
14020   ""
14021   "")
14022
14023 (define_insn "*fma<mode>4_fpr"
14024   [(set (match_operand:SFDF 0 "gpc_reg_operand" "=<Ff>,<Fv>,<Fv>")
14025         (fma:SFDF
14026           (match_operand:SFDF 1 "gpc_reg_operand" "%<Ff>,<Fv>,<Fv>")
14027           (match_operand:SFDF 2 "gpc_reg_operand" "<Ff>,<Fv>,0")
14028           (match_operand:SFDF 3 "gpc_reg_operand" "<Ff>,0,<Fv>")))]
14029   "TARGET_<MODE>_FPR"
14030   "@
14031    fmadd<Ftrad> %0,%1,%2,%3
14032    xsmadda<Fvsx> %x0,%x1,%x2
14033    xsmaddm<Fvsx> %x0,%x1,%x3"
14034   [(set_attr "type" "fp")
14035    (set_attr "fp_type" "fp_maddsub_<Fs>")])
14036
14037 ; Altivec only has fma and nfms.
14038 (define_expand "fms<mode>4"
14039   [(set (match_operand:FMA_F 0 "register_operand" "")
14040         (fma:FMA_F
14041           (match_operand:FMA_F 1 "register_operand" "")
14042           (match_operand:FMA_F 2 "register_operand" "")
14043           (neg:FMA_F (match_operand:FMA_F 3 "register_operand" ""))))]
14044   "!VECTOR_UNIT_ALTIVEC_P (<MODE>mode)"
14045   "")
14046
14047 (define_insn "*fms<mode>4_fpr"
14048   [(set (match_operand:SFDF 0 "gpc_reg_operand" "=<Ff>,<Fv>,<Fv>")
14049         (fma:SFDF
14050          (match_operand:SFDF 1 "gpc_reg_operand" "<Ff>,<Fv>,<Fv>")
14051          (match_operand:SFDF 2 "gpc_reg_operand" "<Ff>,<Fv>,0")
14052          (neg:SFDF (match_operand:SFDF 3 "gpc_reg_operand" "<Ff>,0,<Fv>"))))]
14053   "TARGET_<MODE>_FPR"
14054   "@
14055    fmsub<Ftrad> %0,%1,%2,%3
14056    xsmsuba<Fvsx> %x0,%x1,%x2
14057    xsmsubm<Fvsx> %x0,%x1,%x3"
14058   [(set_attr "type" "fp")
14059    (set_attr "fp_type" "fp_maddsub_<Fs>")])
14060
14061 ;; If signed zeros are ignored, -(a * b - c) = -a * b + c.
14062 (define_expand "fnma<mode>4"
14063   [(set (match_operand:FMA_F 0 "register_operand" "")
14064         (neg:FMA_F
14065           (fma:FMA_F
14066             (match_operand:FMA_F 1 "register_operand" "")
14067             (match_operand:FMA_F 2 "register_operand" "")
14068             (neg:FMA_F (match_operand:FMA_F 3 "register_operand" "")))))]
14069   "!HONOR_SIGNED_ZEROS (<MODE>mode)"
14070   "")
14071
14072 ;; If signed zeros are ignored, -(a * b + c) = -a * b - c.
14073 (define_expand "fnms<mode>4"
14074   [(set (match_operand:FMA_F 0 "register_operand" "")
14075         (neg:FMA_F
14076           (fma:FMA_F
14077             (match_operand:FMA_F 1 "register_operand" "")
14078             (match_operand:FMA_F 2 "register_operand" "")
14079             (match_operand:FMA_F 3 "register_operand" ""))))]
14080   "!HONOR_SIGNED_ZEROS (<MODE>mode) && !VECTOR_UNIT_ALTIVEC_P (<MODE>mode)"
14081   "")
14082
14083 ; Not an official optab name, but used from builtins.
14084 (define_expand "nfma<mode>4"
14085   [(set (match_operand:FMA_F 0 "register_operand" "")
14086         (neg:FMA_F
14087           (fma:FMA_F
14088             (match_operand:FMA_F 1 "register_operand" "")
14089             (match_operand:FMA_F 2 "register_operand" "")
14090             (match_operand:FMA_F 3 "register_operand" ""))))]
14091   "!VECTOR_UNIT_ALTIVEC_P (<MODE>mode)"
14092   "")
14093
14094 (define_insn "*nfma<mode>4_fpr"
14095   [(set (match_operand:SFDF 0 "gpc_reg_operand" "=<Ff>,<Fv>,<Fv>")
14096         (neg:SFDF
14097          (fma:SFDF
14098           (match_operand:SFDF 1 "gpc_reg_operand" "<Ff>,<Fv>,<Fv>")
14099           (match_operand:SFDF 2 "gpc_reg_operand" "<Ff>,<Fv>,0")
14100           (match_operand:SFDF 3 "gpc_reg_operand" "<Ff>,0,<Fv>"))))]
14101   "TARGET_<MODE>_FPR"
14102   "@
14103    fnmadd<Ftrad> %0,%1,%2,%3
14104    xsnmadda<Fvsx> %x0,%x1,%x2
14105    xsnmaddm<Fvsx> %x0,%x1,%x3"
14106   [(set_attr "type" "fp")
14107    (set_attr "fp_type" "fp_maddsub_<Fs>")])
14108
14109 ; Not an official optab name, but used from builtins.
14110 (define_expand "nfms<mode>4"
14111   [(set (match_operand:FMA_F 0 "register_operand" "")
14112         (neg:FMA_F
14113           (fma:FMA_F
14114             (match_operand:FMA_F 1 "register_operand" "")
14115             (match_operand:FMA_F 2 "register_operand" "")
14116             (neg:FMA_F (match_operand:FMA_F 3 "register_operand" "")))))]
14117   ""
14118   "")
14119
14120 (define_insn "*nfmssf4_fpr"
14121   [(set (match_operand:SFDF 0 "gpc_reg_operand" "=<Ff>,<Fv>,<Fv>")
14122         (neg:SFDF
14123          (fma:SFDF
14124           (match_operand:SFDF 1 "gpc_reg_operand" "<Ff>,<Fv>,<Fv>")
14125           (match_operand:SFDF 2 "gpc_reg_operand" "<Ff>,<Fv>,0")
14126           (neg:SFDF
14127            (match_operand:SFDF 3 "gpc_reg_operand" "<Ff>,0,<Fv>")))))]
14128   "TARGET_<MODE>_FPR"
14129   "@
14130    fnmsub<Ftrad> %0,%1,%2,%3
14131    xsnmsuba<Fvsx> %x0,%x1,%x2
14132    xsnmsubm<Fvsx> %x0,%x1,%x3"
14133   [(set_attr "type" "fp")
14134    (set_attr "fp_type" "fp_maddsub_<Fs>")])
14135
14136 \f
14137 (define_expand "rs6000_get_timebase"
14138   [(use (match_operand:DI 0 "gpc_reg_operand" ""))]
14139   ""
14140 {
14141   if (TARGET_POWERPC64)
14142     emit_insn (gen_rs6000_mftb_di (operands[0]));
14143   else
14144     emit_insn (gen_rs6000_get_timebase_ppc32 (operands[0]));
14145   DONE;
14146 })
14147
14148 (define_insn "rs6000_get_timebase_ppc32"
14149   [(set (match_operand:DI 0 "gpc_reg_operand" "=r")
14150         (unspec_volatile:DI [(const_int 0)] UNSPECV_MFTB))
14151    (clobber (match_scratch:SI 1 "=r"))
14152    (clobber (match_scratch:CC 2 "=y"))]
14153   "!TARGET_POWERPC64"
14154 {
14155   if (WORDS_BIG_ENDIAN)
14156     if (TARGET_MFCRF)
14157       {
14158         return "mfspr %0,269\;"
14159                "mfspr %L0,268\;"
14160                "mfspr %1,269\;"
14161                "cmpw %2,%0,%1\;"
14162                "bne- %2,$-16";
14163       }
14164     else
14165       {
14166         return "mftbu %0\;"
14167                "mftb %L0\;"
14168                "mftbu %1\;"
14169                "cmpw %2,%0,%1\;"
14170                "bne- %2,$-16";
14171       }
14172   else
14173     if (TARGET_MFCRF)
14174       {
14175         return "mfspr %L0,269\;"
14176                "mfspr %0,268\;"
14177                "mfspr %1,269\;"
14178                "cmpw %2,%L0,%1\;"
14179                "bne- %2,$-16";
14180       }
14181     else
14182       {
14183         return "mftbu %L0\;"
14184                "mftb %0\;"
14185                "mftbu %1\;"
14186                "cmpw %2,%L0,%1\;"
14187                "bne- %2,$-16";
14188       }
14189 }
14190   [(set_attr "length" "20")])
14191
14192 (define_insn "rs6000_mftb_<mode>"
14193   [(set (match_operand:GPR 0 "gpc_reg_operand" "=r")
14194         (unspec_volatile:GPR [(const_int 0)] UNSPECV_MFTB))]
14195   ""
14196 {
14197   if (TARGET_MFCRF)
14198     return "mfspr %0,268";
14199   else
14200     return "mftb %0";
14201 })
14202
14203 \f
14204 (define_insn "rs6000_mffs"
14205   [(set (match_operand:DF 0 "gpc_reg_operand" "=d")
14206         (unspec_volatile:DF [(const_int 0)] UNSPECV_MFFS))]
14207   "TARGET_HARD_FLOAT && TARGET_FPRS"
14208   "mffs %0")
14209
14210 (define_insn "rs6000_mtfsf"
14211   [(unspec_volatile [(match_operand:SI 0 "const_int_operand" "i")
14212                      (match_operand:DF 1 "gpc_reg_operand" "d")]
14213                     UNSPECV_MTFSF)]
14214   "TARGET_HARD_FLOAT && TARGET_FPRS"
14215   "mtfsf %0,%1")
14216
14217 \f
14218 ;; Power8 fusion support for fusing an addis instruction with a D-form load of
14219 ;; a GPR.  The addis instruction must be adjacent to the load, and use the same
14220 ;; register that is being loaded.  The fused ops must be physically adjacent.
14221
14222 ;; Find cases where the addis that feeds into a load instruction is either used
14223 ;; once or is the same as the target register, and replace it with the fusion
14224 ;; insn
14225
14226 (define_peephole2
14227   [(set (match_operand:P 0 "base_reg_operand" "")
14228         (match_operand:P 1 "fusion_gpr_addis" ""))
14229    (set (match_operand:INT1 2 "base_reg_operand" "")
14230         (match_operand:INT1 3 "fusion_gpr_mem_load" ""))]
14231   "TARGET_P8_FUSION
14232    && fusion_gpr_load_p (operands[0], operands[1], operands[2],
14233                          operands[3])"
14234   [(const_int 0)]
14235 {
14236   expand_fusion_gpr_load (operands);
14237   DONE;
14238 })
14239
14240 ;; Fusion insn, created by the define_peephole2 above (and eventually by
14241 ;; reload)
14242
14243 (define_insn "fusion_gpr_load_<mode>"
14244   [(set (match_operand:INT1 0 "base_reg_operand" "=&b")
14245         (unspec:INT1 [(match_operand:INT1 1 "fusion_gpr_mem_combo" "")]
14246                      UNSPEC_FUSION_GPR))]
14247   "TARGET_P8_FUSION"
14248 {
14249   return emit_fusion_gpr_load (operands[0], operands[1]);
14250 }
14251   [(set_attr "type" "load")
14252    (set_attr "length" "8")])
14253
14254 \f
14255 ;; Miscellaneous ISA 2.06 (power7) instructions
14256 (define_insn "addg6s"
14257   [(set (match_operand:SI 0 "register_operand" "=r")
14258         (unspec:SI [(match_operand:SI 1 "register_operand" "r")
14259                     (match_operand:SI 2 "register_operand" "r")]
14260                    UNSPEC_ADDG6S))]
14261   "TARGET_POPCNTD"
14262   "addg6s %0,%1,%2"
14263   [(set_attr "type" "integer")
14264    (set_attr "length" "4")])
14265
14266 (define_insn "cdtbcd"
14267   [(set (match_operand:SI 0 "register_operand" "=r")
14268         (unspec:SI [(match_operand:SI 1 "register_operand" "r")]
14269                    UNSPEC_CDTBCD))]
14270   "TARGET_POPCNTD"
14271   "cdtbcd %0,%1"
14272   [(set_attr "type" "integer")
14273    (set_attr "length" "4")])
14274
14275 (define_insn "cbcdtd"
14276   [(set (match_operand:SI 0 "register_operand" "=r")
14277         (unspec:SI [(match_operand:SI 1 "register_operand" "r")]
14278                    UNSPEC_CBCDTD))]
14279   "TARGET_POPCNTD"
14280   "cbcdtd %0,%1"
14281   [(set_attr "type" "integer")
14282    (set_attr "length" "4")])
14283
14284 (define_int_iterator UNSPEC_DIV_EXTEND [UNSPEC_DIVE
14285                                         UNSPEC_DIVEO
14286                                         UNSPEC_DIVEU
14287                                         UNSPEC_DIVEUO])
14288
14289 (define_int_attr div_extend [(UNSPEC_DIVE       "e")
14290                              (UNSPEC_DIVEO      "eo")
14291                              (UNSPEC_DIVEU      "eu")
14292                              (UNSPEC_DIVEUO     "euo")])
14293
14294 (define_insn "div<div_extend>_<mode>"
14295   [(set (match_operand:GPR 0 "register_operand" "=r")
14296         (unspec:GPR [(match_operand:GPR 1 "register_operand" "r")
14297                      (match_operand:GPR 2 "register_operand" "r")]
14298                     UNSPEC_DIV_EXTEND))]
14299   "TARGET_POPCNTD"
14300   "div<wd><div_extend> %0,%1,%2"
14301   [(set_attr "type" "div")
14302    (set_attr "size" "<bits>")])
14303
14304 \f
14305 ;; Pack/unpack 128-bit floating point types that take 2 scalar registers
14306
14307 ; Type of the 64-bit part when packing/unpacking 128-bit floating point types
14308 (define_mode_attr FP128_64 [(TF "DF") (TD "DI")])
14309
14310 (define_expand "unpack<mode>"
14311   [(set (match_operand:<FP128_64> 0 "nonimmediate_operand" "")
14312         (unspec:<FP128_64>
14313          [(match_operand:FMOVE128 1 "register_operand" "")
14314           (match_operand:QI 2 "const_0_to_1_operand" "")]
14315          UNSPEC_UNPACK_128BIT))]
14316   ""
14317   "")
14318
14319 (define_insn_and_split "unpack<mode>_dm"
14320   [(set (match_operand:<FP128_64> 0 "nonimmediate_operand" "=d,m,d,r,m")
14321         (unspec:<FP128_64>
14322          [(match_operand:FMOVE128 1 "register_operand" "d,d,r,d,r")
14323           (match_operand:QI 2 "const_0_to_1_operand" "i,i,i,i,i")]
14324          UNSPEC_UNPACK_128BIT))]
14325   "TARGET_POWERPC64 && TARGET_DIRECT_MOVE"
14326   "#"
14327   "&& reload_completed"
14328   [(set (match_dup 0) (match_dup 3))]
14329 {
14330   unsigned fp_regno = REGNO (operands[1]) + UINTVAL (operands[2]);
14331
14332   if (REG_P (operands[0]) && REGNO (operands[0]) == fp_regno)
14333     {
14334       emit_note (NOTE_INSN_DELETED);
14335       DONE;
14336     }
14337
14338   operands[3] = gen_rtx_REG (<FP128_64>mode, fp_regno);
14339 }
14340   [(set_attr "type" "fp,fpstore,mffgpr,mftgpr,store")
14341    (set_attr "length" "4")])
14342
14343 (define_insn_and_split "unpack<mode>_nodm"
14344   [(set (match_operand:<FP128_64> 0 "nonimmediate_operand" "=d,m")
14345         (unspec:<FP128_64>
14346          [(match_operand:FMOVE128 1 "register_operand" "d,d")
14347           (match_operand:QI 2 "const_0_to_1_operand" "i,i")]
14348          UNSPEC_UNPACK_128BIT))]
14349   "!TARGET_POWERPC64 || !TARGET_DIRECT_MOVE"
14350   "#"
14351   "&& reload_completed"
14352   [(set (match_dup 0) (match_dup 3))]
14353 {
14354   unsigned fp_regno = REGNO (operands[1]) + UINTVAL (operands[2]);
14355
14356   if (REG_P (operands[0]) && REGNO (operands[0]) == fp_regno)
14357     {
14358       emit_note (NOTE_INSN_DELETED);
14359       DONE;
14360     }
14361
14362   operands[3] = gen_rtx_REG (<FP128_64>mode, fp_regno);
14363 }
14364   [(set_attr "type" "fp,fpstore")
14365    (set_attr "length" "4")])
14366
14367 (define_insn_and_split "pack<mode>"
14368   [(set (match_operand:FMOVE128 0 "register_operand" "=d,&d")
14369         (unspec:FMOVE128
14370          [(match_operand:<FP128_64> 1 "register_operand" "0,d")
14371           (match_operand:<FP128_64> 2 "register_operand" "d,d")]
14372          UNSPEC_PACK_128BIT))]
14373   ""
14374   "@
14375    fmr %L0,%2
14376    #"
14377   "&& reload_completed && REGNO (operands[0]) != REGNO (operands[1])"
14378   [(set (match_dup 3) (match_dup 1))
14379    (set (match_dup 4) (match_dup 2))]
14380 {
14381   unsigned dest_hi = REGNO (operands[0]);
14382   unsigned dest_lo = dest_hi + 1;
14383
14384   gcc_assert (!IN_RANGE (REGNO (operands[1]), dest_hi, dest_lo));
14385   gcc_assert (!IN_RANGE (REGNO (operands[2]), dest_hi, dest_lo));
14386
14387   operands[3] = gen_rtx_REG (<FP128_64>mode, dest_hi);
14388   operands[4] = gen_rtx_REG (<FP128_64>mode, dest_lo);
14389 }
14390   [(set_attr "type" "fp,fp")
14391    (set_attr "length" "4,8")])
14392
14393 (define_insn "unpackv1ti"
14394   [(set (match_operand:DI 0 "register_operand" "=d,d")
14395         (unspec:DI [(match_operand:V1TI 1 "register_operand" "0,wa")
14396                     (match_operand:QI 2 "const_0_to_1_operand" "O,i")]
14397          UNSPEC_UNPACK_128BIT))]
14398   "TARGET_VSX"
14399 {
14400   if (REGNO (operands[0]) == REGNO (operands[1]) && INTVAL (operands[2]) == 0)
14401     return ASM_COMMENT_START " xxpermdi to same register";
14402
14403   operands[3] = GEN_INT (INTVAL (operands[2]) == 0 ? 0 : 3);
14404   return "xxpermdi %x0,%x1,%x1,%3";
14405 }
14406   [(set_attr "type" "vecperm")
14407    (set_attr "length" "4")])
14408
14409 (define_insn "packv1ti"
14410   [(set (match_operand:V1TI 0 "register_operand" "=wa")
14411         (unspec:V1TI
14412          [(match_operand:DI 1 "register_operand" "d")
14413           (match_operand:DI 2 "register_operand" "d")]
14414          UNSPEC_PACK_128BIT))]
14415   "TARGET_VSX"
14416   "xxpermdi %x0,%x1,%x2,0"
14417   [(set_attr "type" "vecperm")
14418    (set_attr "length" "4")])
14419
14420 \f
14421
14422 (include "sync.md")
14423 (include "vector.md")
14424 (include "vsx.md")
14425 (include "altivec.md")
14426 (include "spe.md")
14427 (include "dfp.md")
14428 (include "paired.md")
14429 (include "crypto.md")
14430 (include "htm.md")