OSDN Git Service

* config/rs6000/rs6000.md (UNSPEC constants): Add UNSPEC_STFIWX.
[pf3gnuchains/gcc-fork.git] / gcc / config / rs6000 / rs6000.md
index f39e849..b9fa39c 100644 (file)
@@ -1,6 +1,6 @@
 ;; Machine description for IBM RISC System 6000 (POWER) for GNU C compiler
 ;; Copyright (C) 1990, 1991, 1992, 1993, 1994, 1995, 1996, 1997, 1998,
-;; 1999, 2000, 2001, 2002, 2003 Free Software Foundation, Inc.
+;; 1999, 2000, 2001, 2002, 2003, 2004, 2005 Free Software Foundation, Inc.
 ;; Contributed by Richard Kenner (kenner@vlsi1.ultra.nyu.edu)
 
 ;; This file is part of GCC.
@@ -49,6 +49,9 @@
    (UNSPEC_TLSTPRELLO          27)
    (UNSPEC_TLSGOTTPREL         28)
    (UNSPEC_TLSTLS              29)
+   (UNSPEC_FIX_TRUNC_TF                30)     ; fadd, rounding towards zero
+   (UNSPEC_MV_CR_GT            31)     ; move_from_CR_eq_bit
+   (UNSPEC_STFIWX              32)
   ])
 
 ;;
 \f
 ;; Define an insn type attribute.  This is used in function unit delay
 ;; computations.
-(define_attr "type" "integer,load,load_ext,load_ext_u,load_ext_ux,load_ux,load_u,store,store_ux,store_u,fpload,fpload_ux,fpload_u,fpstore,fpstore_ux,fpstore_u,vecload,vecstore,imul,imul2,imul3,lmul,idiv,ldiv,insert_word,branch,cmp,fast_compare,compare,delayed_compare,imul_compare,lmul_compare,fpcompare,cr_logical,delayed_cr,mfcr,mfcrf,mtcr,mfjmpr,mtjmpr,fp,fpsimple,dmul,sdiv,ddiv,ssqrt,dsqrt,jmpreg,brinc,vecsimple,veccomplex,vecdiv,veccmp,veccmpsimple,vecperm,vecfloat,vecfdiv"
+(define_attr "type" "integer,two,three,load,load_ext,load_ext_u,load_ext_ux,load_ux,load_u,store,store_ux,store_u,fpload,fpload_ux,fpload_u,fpstore,fpstore_ux,fpstore_u,vecload,vecstore,imul,imul2,imul3,lmul,idiv,ldiv,insert_word,branch,cmp,fast_compare,compare,delayed_compare,imul_compare,lmul_compare,fpcompare,cr_logical,delayed_cr,mfcr,mfcrf,mtcr,mfjmpr,mtjmpr,fp,fpsimple,dmul,sdiv,ddiv,ssqrt,dsqrt,jmpreg,brinc,vecsimple,veccomplex,vecdiv,veccmp,veccmpsimple,vecperm,vecfloat,vecfdiv"
   (const_string "integer"))
 
 ;; Length (in bytes).
-; '(pc)' in the following doesn't include the instruction itself; it is 
+; '(pc)' in the following doesn't include the instruction itself; it is
 ; calculated as if the instruction had zero size.
 (define_attr "length" ""
   (if_then_else (eq_attr "type" "branch")
@@ -81,7 +84,7 @@
 ;; Processor type -- this attribute must exactly match the processor_type
 ;; enumeration in rs6000.h.
 
-(define_attr "cpu" "rios1,rios2,rs64a,mpccore,ppc403,ppc405,ppc440,ppc601,ppc603,ppc604,ppc604e,ppc620,ppc630,ppc750,ppc7400,ppc7450,ppc8540,power4"
+(define_attr "cpu" "rios1,rios2,rs64a,mpccore,ppc403,ppc405,ppc440,ppc601,ppc603,ppc604,ppc604e,ppc620,ppc630,ppc750,ppc7400,ppc7450,ppc8540,power4,power5"
   (const (symbol_ref "rs6000_cpu_attr")))
 
 (automata_option "ndfa")
 (include "7450.md")
 (include "8540.md")
 (include "power4.md")
+(include "power5.md")
+
+(include "predicates.md")
+
+(include "darwin.md")
 
 \f
+;; This mode macro allows :P to be used for patterns that operate on
+;; pointer-sized quantities.  Exactly one of the two alternatives will match.
+(define_mode_macro P [(SI "Pmode == SImode") (DI "Pmode == DImode")])
+
 ;; Start with fixed-point load and store insns.  Here we put only the more
 ;; complex forms.  Basic data transfer is done later.
 
        (compare:CC (zero_extend:DI (match_operand:QI 1 "gpc_reg_operand" "r,r"))
                    (const_int 0)))
    (clobber (match_scratch:DI 2 "=r,r"))]
-  "TARGET_POWERPC64"
+  "TARGET_64BIT"
   "@
    rldicl. %2,%1,0,56
    #"
                    (const_int 0)))
    (set (match_operand:DI 0 "gpc_reg_operand" "=r,r")
        (zero_extend:DI (match_dup 1)))]
-  "TARGET_POWERPC64"
+  "TARGET_64BIT"
   "@
    rldicl. %0,%1,0,56
    #"
        (compare:CC (sign_extend:DI (match_operand:QI 1 "gpc_reg_operand" "r,r"))
                    (const_int 0)))
    (clobber (match_scratch:DI 2 "=r,r"))]
-  "TARGET_POWERPC64"
+  "TARGET_64BIT"
   "@
    extsb. %2,%1
    #"
                    (const_int 0)))
    (set (match_operand:DI 0 "gpc_reg_operand" "=r,r")
        (sign_extend:DI (match_dup 1)))]
-  "TARGET_POWERPC64"
+  "TARGET_64BIT"
   "@
    extsb. %0,%1
    #"
        (compare:CC (zero_extend:DI (match_operand:HI 1 "gpc_reg_operand" "r,r"))
                    (const_int 0)))
    (clobber (match_scratch:DI 2 "=r,r"))]
-  "TARGET_POWERPC64"
+  "TARGET_64BIT"
   "@
    rldicl. %2,%1,0,48
    #"
                    (const_int 0)))
    (set (match_operand:DI 0 "gpc_reg_operand" "=r,r")
        (zero_extend:DI (match_dup 1)))]
-  "TARGET_POWERPC64"
+  "TARGET_64BIT"
   "@
    rldicl. %0,%1,0,48
    #"
        (compare:CC (sign_extend:DI (match_operand:HI 1 "gpc_reg_operand" "r,r"))
                    (const_int 0)))
    (clobber (match_scratch:DI 2 "=r,r"))]
-  "TARGET_POWERPC64"
+  "TARGET_64BIT"
   "@
    extsh. %2,%1
    #"
                    (const_int 0)))
    (set (match_operand:DI 0 "gpc_reg_operand" "=r,r")
        (sign_extend:DI (match_dup 1)))]
-  "TARGET_POWERPC64"
+  "TARGET_64BIT"
   "@
    extsh. %0,%1
    #"
        (compare:CC (zero_extend:DI (match_operand:SI 1 "gpc_reg_operand" "r,r"))
                    (const_int 0)))
    (clobber (match_scratch:DI 2 "=r,r"))]
-  "TARGET_POWERPC64"
+  "TARGET_64BIT"
   "@
    rldicl. %2,%1,0,32
    #"
                    (const_int 0)))
    (set (match_operand:DI 0 "gpc_reg_operand" "=r,r")
        (zero_extend:DI (match_dup 1)))]
-  "TARGET_POWERPC64"
+  "TARGET_64BIT"
   "@
    rldicl. %0,%1,0,32
    #"
        (compare:CC (sign_extend:DI (match_operand:SI 1 "gpc_reg_operand" "r,r"))
                    (const_int 0)))
    (clobber (match_scratch:DI 2 "=r,r"))]
-  "TARGET_POWERPC64"
+  "TARGET_64BIT"
   "@
    extsw. %2,%1
    #"
                    (const_int 0)))
    (set (match_operand:DI 0 "gpc_reg_operand" "=r,r")
        (sign_extend:DI (match_dup 1)))]
-  "TARGET_POWERPC64"
+  "TARGET_64BIT"
   "@
    extsw. %0,%1
    #"
                             (match_operand:SI 2 "reg_or_short_operand" "r,I,r,I"))
                    (const_int 0)))
    (clobber (match_scratch:SI 3 "=r,r,r,r"))]
-  "! TARGET_POWERPC64"
+  "TARGET_32BIT"
   "@
    {cax.|add.} %3,%1,%2
    {ai.|addic.} %3,%1,%2
                             (match_operand:SI 2 "reg_or_short_operand" ""))
                    (const_int 0)))
    (clobber (match_scratch:SI 3 ""))]
-  "! TARGET_POWERPC64 && reload_completed"
+  "TARGET_32BIT && reload_completed"
   [(set (match_dup 3)
        (plus:SI (match_dup 1)
                 (match_dup 2)))
    (set (match_operand:SI 0 "gpc_reg_operand" "=r,r,r,r")
        (plus:SI (match_dup 1)
                 (match_dup 2)))]
-  "! TARGET_POWERPC64"
+  "TARGET_32BIT"
   "@
    {cax.|add.} %0,%1,%2
    {ai.|addic.} %0,%1,%2
                    (const_int 0)))
    (set (match_operand:SI 0 "gpc_reg_operand" "")
        (plus:SI (match_dup 1) (match_dup 2)))]
-  "! TARGET_POWERPC64 && reload_completed"
+  "TARGET_32BIT && reload_completed"
   [(set (match_dup 0)
        (plus:SI (match_dup 1)
                 (match_dup 2)))
        (compare:CC (not:SI (match_operand:SI 1 "gpc_reg_operand" "r,r"))
                    (const_int 0)))
    (clobber (match_scratch:SI 2 "=r,r"))]
-  "! TARGET_POWERPC64"
+  "TARGET_32BIT"
   "@
    nor. %2,%1,%1
    #"
        (compare:CC (not:SI (match_operand:SI 1 "gpc_reg_operand" ""))
                    (const_int 0)))
    (clobber (match_scratch:SI 2 ""))]
-  "! TARGET_POWERPC64 && reload_completed"
+  "TARGET_32BIT && reload_completed"
   [(set (match_dup 2)
        (not:SI (match_dup 1)))
    (set (match_dup 0)
                    (const_int 0)))
    (set (match_operand:SI 0 "gpc_reg_operand" "=r,r")
        (not:SI (match_dup 1)))]
-  "! TARGET_POWERPC64"
+  "TARGET_32BIT"
   "@
    nor. %0,%1,%1
    #"
                    (const_int 0)))
    (set (match_operand:SI 0 "gpc_reg_operand" "")
        (not:SI (match_dup 1)))]
-  "! TARGET_POWERPC64 && reload_completed"
+  "TARGET_32BIT && reload_completed"
   [(set (match_dup 0)
        (not:SI (match_dup 1)))
    (set (match_dup 2)
                              (match_operand:SI 2 "gpc_reg_operand" "r,r"))
                    (const_int 0)))
    (clobber (match_scratch:SI 3 "=r,r"))]
-  "TARGET_POWERPC && ! TARGET_POWERPC64"
+  "TARGET_POWERPC && TARGET_32BIT"
   "@
    subf. %3,%2,%1
    #"
                              (match_operand:SI 2 "gpc_reg_operand" ""))
                    (const_int 0)))
    (clobber (match_scratch:SI 3 ""))]
-  "! TARGET_POWERPC64 && reload_completed"
+  "TARGET_32BIT && reload_completed"
   [(set (match_dup 3)
        (minus:SI (match_dup 1)
                  (match_dup 2)))
    (set (match_operand:SI 0 "gpc_reg_operand" "=r,r")
        (minus:SI (match_dup 1)
                  (match_dup 2)))]
-  "TARGET_POWERPC && ! TARGET_POWERPC64"
+  "TARGET_POWERPC && TARGET_32BIT"
   "@
    subf. %0,%2,%1
    #"
    (set (match_operand:SI 0 "gpc_reg_operand" "")
        (minus:SI (match_dup 1)
                  (match_dup 2)))]
-  "! TARGET_POWERPC64 && reload_completed"
+  "TARGET_32BIT && reload_completed"
   [(set (match_dup 0)
        (minus:SI (match_dup 1)
                  (match_dup 2)))
 (define_insn_and_split "abssi2_isel"
   [(set (match_operand:SI 0 "gpc_reg_operand" "=r")
         (abs:SI (match_operand:SI 1 "gpc_reg_operand" "b")))
-   (clobber (match_scratch:SI 2 "=b"))
+   (clobber (match_scratch:SI 2 "=&b"))
    (clobber (match_scratch:CC 3 "=y"))]
   "TARGET_ISEL"
   "#"
        (compare:CC (neg:SI (match_operand:SI 1 "gpc_reg_operand" "r,r"))
                    (const_int 0)))
    (clobber (match_scratch:SI 2 "=r,r"))]
-  "! TARGET_POWERPC64"
+  "TARGET_32BIT"
   "@
    neg. %2,%1
    #"
        (compare:CC (neg:SI (match_operand:SI 1 "gpc_reg_operand" ""))
                    (const_int 0)))
    (clobber (match_scratch:SI 2 ""))]
-  "! TARGET_POWERPC64 && reload_completed"
+  "TARGET_32BIT && reload_completed"
   [(set (match_dup 2)
        (neg:SI (match_dup 1)))
    (set (match_dup 0)
                    (const_int 0)))
    (set (match_operand:SI 0 "gpc_reg_operand" "=r,r")
        (neg:SI (match_dup 1)))]
-  "! TARGET_POWERPC64"
+  "TARGET_32BIT"
   "@
    neg. %0,%1
    #"
                    (const_int 0)))
    (set (match_operand:SI 0 "gpc_reg_operand" "")
        (neg:SI (match_dup 1)))]
-  "! TARGET_POWERPC64 && reload_completed"
+  "TARGET_32BIT && reload_completed"
   [(set (match_dup 0)
        (neg:SI (match_dup 1)))
    (set (match_dup 2)
      operands[3] = gen_reg_rtx (SImode);
      operands[4] = gen_reg_rtx (SImode);
   })
-  
+
 (define_expand "ffssi2"
   [(set (match_dup 2)
        (neg:SI (match_operand:SI 1 "gpc_reg_operand" "r")))
      operands[3] = gen_reg_rtx (SImode);
      operands[4] = gen_reg_rtx (SImode);
   })
-  
+
 (define_expand "mulsi3"
   [(use (match_operand:SI 0 "gpc_reg_operand" ""))
    (use (match_operand:SI 1 "gpc_reg_operand" ""))
   "@
    {muls|mullw} %0,%1,%2
    {muli|mulli} %0,%1,%2"
-   [(set (attr "type") 
+   [(set (attr "type")
       (cond [(match_operand:SI 2 "s8bit_cint_operand" "")
                (const_string "imul3")
-             (match_operand:SI 2 "short_cint_operand" "") 
+             (match_operand:SI 2 "short_cint_operand" "")
                (const_string "imul2")]
        (const_string "imul")))])
 
   "@
    {muls|mullw} %0,%1,%2
    {muli|mulli} %0,%1,%2"
-   [(set (attr "type") 
+   [(set (attr "type")
       (cond [(match_operand:SI 2 "s8bit_cint_operand" "")
                (const_string "imul3")
-             (match_operand:SI 2 "short_cint_operand" "") 
+             (match_operand:SI 2 "short_cint_operand" "")
                (const_string "imul2")]
        (const_string "imul")))])
 
                (match_operand:SI 2 "exact_log2_cint_operand" "N")))]
   ""
   "{srai|srawi} %0,%1,%p2\;{aze|addze} %0,%0"
-  [(set_attr "length" "8")])
+  [(set_attr "type" "two")
+   (set_attr "length" "8")])
 
 (define_insn ""
   [(set (match_operand:CC 0 "cc_reg_operand" "=x,?y")
    and %0,%1,%2
    {rlinm|rlwinm} %0,%1,0,%m2,%M2
    {andil.|andi.} %0,%1,%b2
-   {andiu.|andis.} %0,%1,%u2")
+   {andiu.|andis.} %0,%1,%u2"
+  [(set_attr "type" "*,*,compare,compare")])
 
 ;; Note to set cr's other than cr0 we do the and immediate and then
 ;; the test again -- this avoids a mfcr which on the higher end
                    (const_int 0)))
    (clobber (match_scratch:SI 3 "=r,r,r,r,r,r,r,r"))
    (clobber (match_scratch:CC 4 "=X,X,X,X,X,x,x,X"))]
-  "! TARGET_POWERPC64"
+  "TARGET_32BIT"
   "@
    and. %3,%1,%2
    {andil.|andi.} %3,%1,%b2
                    (const_int 0)))
    (clobber (match_scratch:SI 3 "=r,r,r,r,r,r,r,r"))
    (clobber (match_scratch:CC 4 "=X,X,X,X,X,x,x,X"))]
-  "TARGET_POWERPC64"
+  "TARGET_64BIT"
   "@
    #
    {andil.|andi.} %3,%1,%b2
        (and:SI (match_dup 1)
                (match_dup 2)))
    (clobber (match_scratch:CC 4 "=X,X,X,X,X,x,x,X"))]
-  "! TARGET_POWERPC64"
+  "TARGET_32BIT"
   "@
    and. %0,%1,%2
    {andil.|andi.} %0,%1,%b2
        (and:SI (match_dup 1)
                (match_dup 2)))
    (clobber (match_scratch:CC 4 "=X,X,X,X,X,x,x,X"))]
-  "TARGET_POWERPC64"
+  "TARGET_64BIT"
   "@
    #
    {andil.|andi.} %0,%1,%b2
 }"
   [(set_attr "length" "8")])
 
-(define_insn_and_split "*andsi3_internal7"
-  [(set (match_operand:CC 2 "cc_reg_operand" "=x,?y")
-       (compare:CC (and:SI (match_operand:SI 0 "gpc_reg_operand" "r,r")
-                           (match_operand:SI 1 "mask_operand_wrap" "i,i"))
-                   (const_int 0)))
-   (clobber (match_scratch:SI 3 "=r,r"))]
-  "TARGET_POWERPC64"
-  "#"
-  "TARGET_POWERPC64"
-  [(parallel [(set (match_dup 2)
-                  (compare:CC (and:SI (rotate:SI (match_dup 0) (match_dup 4))
-                                      (match_dup 5))
-                              (const_int 0)))
-             (clobber (match_dup 3))])]
-  "
-{
-  int mb = extract_MB (operands[1]);
-  int me = extract_ME (operands[1]);
-  operands[4] = GEN_INT (me + 1);
-  operands[5] = GEN_INT (~((HOST_WIDE_INT) -1 << (33 + me - mb)));
-}"
-  [(set_attr "type" "delayed_compare,compare")
-   (set_attr "length" "4,8")])
-
-(define_insn_and_split "*andsi3_internal8"
-  [(set (match_operand:CC 3 "cc_reg_operand" "=x,??y")
-       (compare:CC (and:SI (match_operand:SI 1 "gpc_reg_operand" "r,r")
-                           (match_operand:SI 2 "mask_operand_wrap" "i,i"))
-                   (const_int 0)))
-   (set (match_operand:SI 0 "gpc_reg_operand" "=r,r")
-       (and:SI (match_dup 1)
-               (match_dup 2)))]
-  "TARGET_POWERPC64"
-  "#"
-  "TARGET_POWERPC64"
-  [(parallel [(set (match_dup 3)
-                  (compare:CC (and:SI (rotate:SI (match_dup 1) (match_dup 4))
-                                      (match_dup 5))
-                              (const_int 0)))
-             (set (match_dup 0)
-                  (and:SI (rotate:SI (match_dup 1) (match_dup 4))
-                          (match_dup 5)))])
-   (set (match_dup 0)
-       (rotate:SI (match_dup 0) (match_dup 6)))]
-  "
-{
-  int mb = extract_MB (operands[2]);
-  int me = extract_ME (operands[2]);
-  operands[4] = GEN_INT (me + 1);
-  operands[6] = GEN_INT (32 - (me + 1));
-  operands[5] = GEN_INT (~((HOST_WIDE_INT) -1 << (33 + me - mb)));
-}"
-  [(set_attr "type" "delayed_compare,compare")
-   (set_attr "length" "8,12")])
-
 (define_expand "iorsi3"
   [(set (match_operand:SI 0 "gpc_reg_operand" "")
        (ior:SI (match_operand:SI 1 "gpc_reg_operand" "")
          (match_operand:SI 2 "gpc_reg_operand" "r,r")])
         (const_int 0)))
    (clobber (match_scratch:SI 3 "=r,r"))]
-  "! TARGET_POWERPC64"
+  "TARGET_32BIT"
   "@
    %q4. %3,%1,%2
    #"
          (match_operand:SI 2 "gpc_reg_operand" "")])
         (const_int 0)))
    (clobber (match_scratch:SI 3 ""))]
-  "! TARGET_POWERPC64 && reload_completed"
+  "TARGET_32BIT && reload_completed"
   [(set (match_dup 3) (match_dup 4))
    (set (match_dup 0)
        (compare:CC (match_dup 3)
         (const_int 0)))
    (set (match_operand:SI 0 "gpc_reg_operand" "=r,r")
        (match_dup 4))]
-  "! TARGET_POWERPC64"
+  "TARGET_32BIT"
   "@
    %q4. %0,%1,%2
    #"
         (const_int 0)))
    (set (match_operand:SI 0 "gpc_reg_operand" "")
        (match_dup 4))]
-  "! TARGET_POWERPC64 && reload_completed"
+  "TARGET_32BIT && reload_completed"
   [(set (match_dup 0) (match_dup 4))
    (set (match_dup 3)
        (compare:CC (match_dup 0)
                    (const_int 0)))]
   "")
 
-;; Split a logical operation that we can't do in one insn into two insns, 
+;; Split a logical operation that we can't do in one insn into two insns,
 ;; each of which does one 16-bit part.  This is used by combine.
 
 (define_split
 {
   rtx i;
   i = GEN_INT (INTVAL (operands[2]) & (~ (HOST_WIDE_INT) 0xffff));
-  operands[4] = gen_rtx (GET_CODE (operands[3]), SImode,
-                        operands[1], i);
+  operands[4] = gen_rtx_fmt_ee (GET_CODE (operands[3]), SImode,
+                               operands[1], i);
   i = GEN_INT (INTVAL (operands[2]) & 0xffff);
-  operands[5] = gen_rtx (GET_CODE (operands[3]), SImode,
-                        operands[0], i);
+  operands[5] = gen_rtx_fmt_ee (GET_CODE (operands[3]), SImode,
+                               operands[0], i);
 }")
 
 (define_insn "*boolcsi3_internal1"
          (match_operand:SI 2 "gpc_reg_operand" "r,r")])
         (const_int 0)))
    (clobber (match_scratch:SI 3 "=r,r"))]
-  "! TARGET_POWERPC64"
+  "TARGET_32BIT"
   "@
    %q4. %3,%2,%1
    #"
          (match_operand:SI 2 "gpc_reg_operand" "")])
         (const_int 0)))
    (clobber (match_scratch:SI 3 ""))]
-  "! TARGET_POWERPC64 && reload_completed"
+  "TARGET_32BIT && reload_completed"
   [(set (match_dup 3) (match_dup 4))
    (set (match_dup 0)
        (compare:CC (match_dup 3)
         (const_int 0)))
    (set (match_operand:SI 0 "gpc_reg_operand" "=r,r")
        (match_dup 4))]
-  "! TARGET_POWERPC64"
+  "TARGET_32BIT"
   "@
    %q4. %0,%2,%1
    #"
         (const_int 0)))
    (set (match_operand:SI 0 "gpc_reg_operand" "")
        (match_dup 4))]
-  "! TARGET_POWERPC64 && reload_completed"
+  "TARGET_32BIT && reload_completed"
   [(set (match_dup 0) (match_dup 4))
    (set (match_dup 3)
        (compare:CC (match_dup 0)
          (not:SI (match_operand:SI 2 "gpc_reg_operand" "r,r"))])
         (const_int 0)))
    (clobber (match_scratch:SI 3 "=r,r"))]
-  "! TARGET_POWERPC64"
+  "TARGET_32BIT"
   "@
    %q4. %3,%1,%2
    #"
          (not:SI (match_operand:SI 2 "gpc_reg_operand" ""))])
         (const_int 0)))
    (clobber (match_scratch:SI 3 ""))]
-  "! TARGET_POWERPC64 && reload_completed"
+  "TARGET_32BIT && reload_completed"
   [(set (match_dup 3) (match_dup 4))
    (set (match_dup 0)
        (compare:CC (match_dup 3)
         (const_int 0)))
    (set (match_operand:SI 0 "gpc_reg_operand" "=r,r")
        (match_dup 4))]
-  "! TARGET_POWERPC64"
+  "TARGET_32BIT"
   "@
    %q4. %0,%1,%2
    #"
         (const_int 0)))
    (set (match_operand:SI 0 "gpc_reg_operand" "")
        (match_dup 4))]
-  "! TARGET_POWERPC64 && reload_completed"
+  "TARGET_32BIT && reload_completed"
   [(set (match_dup 0) (match_dup 4))
    (set (match_dup 3)
        (compare:CC (match_dup 0)
 }"
   [(set_attr "type" "insert_word")])
 
+;; combine patterns for rlwimi
+(define_insn "*insvsi_internal5"
+  [(set (match_operand:SI 0 "gpc_reg_operand" "=r")
+        (ior:SI (and:SI (match_operand:SI 4 "gpc_reg_operand" "0")
+                        (match_operand:SI 1 "mask_operand" "i"))
+                (and:SI (lshiftrt:SI (match_operand:SI 3 "gpc_reg_operand" "r")
+                                     (match_operand:SI 2 "const_int_operand" "i"))
+                        (match_operand:SI 5 "mask_operand" "i"))))]
+  "TARGET_POWERPC && INTVAL(operands[1]) == ~INTVAL(operands[5])"
+  "*
+{
+ int me = extract_ME(operands[5]);
+ int mb = extract_MB(operands[5]);
+ operands[4] = GEN_INT(32 - INTVAL(operands[2]));
+ operands[2] = GEN_INT(mb);
+ operands[1] = GEN_INT(me);
+ return \"{rlimi|rlwimi} %0,%3,%h4,%h2,%h1\";
+}"
+  [(set_attr "type" "insert_word")])
+
+(define_insn "*insvsi_internal6"
+  [(set (match_operand:SI 0 "gpc_reg_operand" "=r")
+        (ior:SI (and:SI (lshiftrt:SI (match_operand:SI 3 "gpc_reg_operand" "r")
+                                     (match_operand:SI 2 "const_int_operand" "i"))
+                        (match_operand:SI 5 "mask_operand" "i"))
+                (and:SI (match_operand:SI 4 "gpc_reg_operand" "0")
+                        (match_operand:SI 1 "mask_operand" "i"))))]
+  "TARGET_POWERPC && INTVAL(operands[1]) == ~INTVAL(operands[5])"
+  "*
+{
+ int me = extract_ME(operands[5]);
+ int mb = extract_MB(operands[5]);
+ operands[4] = GEN_INT(32 - INTVAL(operands[2]));
+ operands[2] = GEN_INT(mb);
+ operands[1] = GEN_INT(me);
+ return \"{rlimi|rlwimi} %0,%3,%h4,%h2,%h1\";
+}"
+  [(set_attr "type" "insert_word")])
+
 (define_insn "insvdi"
   [(set (zero_extract:DI (match_operand:DI 0 "gpc_reg_operand" "+r")
                         (match_operand:SI 1 "const_int_operand" "i")
   return \"rldimi %0,%3,%H1,%H2\";
 }")
 
+(define_insn "*insvdi_internal2"
+  [(set (zero_extract:DI (match_operand:DI 0 "gpc_reg_operand" "+r")
+                        (match_operand:SI 1 "const_int_operand" "i")
+                        (match_operand:SI 2 "const_int_operand" "i"))
+       (ashiftrt:DI (match_operand:DI 3 "gpc_reg_operand" "r")
+                    (match_operand:SI 4 "const_int_operand" "i")))]
+  "TARGET_POWERPC64
+   && insvdi_rshift_rlwimi_p (operands[1], operands[2], operands[4])"
+  "*
+{
+  int shift = INTVAL (operands[4]) & 63;
+  int start = (INTVAL (operands[2]) & 63) - 32;
+  int size = INTVAL (operands[1]) & 63;
+
+  operands[4] = GEN_INT (64 - shift - start - size);
+  operands[2] = GEN_INT (start);
+  operands[1] = GEN_INT (start + size - 1);
+  return \"rlwimi %0,%3,%h4,%h2,%h1\";
+}")
+
+(define_insn "*insvdi_internal3"
+  [(set (zero_extract:DI (match_operand:DI 0 "gpc_reg_operand" "+r")
+                        (match_operand:SI 1 "const_int_operand" "i")
+                        (match_operand:SI 2 "const_int_operand" "i"))
+       (lshiftrt:DI (match_operand:DI 3 "gpc_reg_operand" "r")
+                    (match_operand:SI 4 "const_int_operand" "i")))]
+  "TARGET_POWERPC64
+   && insvdi_rshift_rlwimi_p (operands[1], operands[2], operands[4])"
+  "*
+{
+  int shift = INTVAL (operands[4]) & 63;
+  int start = (INTVAL (operands[2]) & 63) - 32;
+  int size = INTVAL (operands[1]) & 63;
+
+  operands[4] = GEN_INT (64 - shift - start - size);
+  operands[2] = GEN_INT (start);
+  operands[1] = GEN_INT (start + size - 1);
+  return \"rlwimi %0,%3,%h4,%h2,%h1\";
+}")
+
 (define_expand "extzv"
   [(set (match_operand 0 "gpc_reg_operand" "")
        (zero_extract (match_operand 1 "gpc_reg_operand" "")
                         (match_operand:SI 3 "const_int_operand" "i"))
                    (const_int 0)))
    (clobber (match_scratch:DI 4 "=r"))]
-  "TARGET_POWERPC64"
+  "TARGET_64BIT"
   "*
 {
   int start = INTVAL (operands[3]) & 63;
     operands[3] = GEN_INT (start + size);
   operands[2] = GEN_INT (64 - size);
   return \"rldicl. %4,%1,%3,%2\";
-}")
+}"
+  [(set_attr "type" "compare")])
 
 (define_insn "*extzvdi_internal2"
   [(set (match_operand:CC 4 "gpc_reg_operand" "=x")
                    (const_int 0)))
    (set (match_operand:DI 0 "gpc_reg_operand" "=r")
        (zero_extract:DI (match_dup 1) (match_dup 2) (match_dup 3)))]
-  "TARGET_POWERPC64"
+  "TARGET_64BIT"
   "*
 {
   int start = INTVAL (operands[3]) & 63;
     operands[3] = GEN_INT (start + size);
   operands[2] = GEN_INT (64 - size);
   return \"rldicl. %0,%1,%3,%2\";
-}")
+}"
+  [(set_attr "type" "compare")])
 
 (define_insn "rotlsi3"
   [(set (match_operand:SI 0 "gpc_reg_operand" "=r")
                               (match_operand:SI 2 "reg_or_cint_operand" "ri,ri"))
                    (const_int 0)))
    (clobber (match_scratch:SI 3 "=r,r"))]
-  "! TARGET_POWER && ! TARGET_POWERPC64"
+  "! TARGET_POWER && TARGET_32BIT"
   "@
    {sl|slw}%I2. %3,%1,%h2
    #"
                               (match_operand:SI 2 "reg_or_cint_operand" ""))
                    (const_int 0)))
    (clobber (match_scratch:SI 3 ""))]
-  "! TARGET_POWER && ! TARGET_POWERPC64 && reload_completed"
+  "! TARGET_POWER && TARGET_32BIT && reload_completed"
   [(set (match_dup 3)
        (ashift:SI (match_dup 1) (match_dup 2)))
    (set (match_dup 0)
                    (const_int 0)))
    (set (match_operand:SI 0 "gpc_reg_operand" "=r,r")
        (ashift:SI (match_dup 1) (match_dup 2)))]
-  "! TARGET_POWER && ! TARGET_POWERPC64"
+  "! TARGET_POWER && TARGET_32BIT"
   "@
    {sl|slw}%I2. %0,%1,%h2
    #"
                    (const_int 0)))
    (set (match_operand:SI 0 "gpc_reg_operand" "")
        (ashift:SI (match_dup 1) (match_dup 2)))]
-  "! TARGET_POWER && ! TARGET_POWERPC64 && reload_completed"
+  "! TARGET_POWER && TARGET_32BIT && reload_completed"
   [(set (match_dup 0)
        (ashift:SI (match_dup 1) (match_dup 2)))
    (set (match_dup 3)
                                 (match_operand:SI 2 "reg_or_cint_operand" "O,ri,O,ri"))
                    (const_int 0)))
    (clobber (match_scratch:SI 3 "=X,r,X,r"))]
-  "! TARGET_POWER && ! TARGET_POWERPC64"
+  "! TARGET_POWER && TARGET_32BIT"
   "@
    mr. %1,%1
    {sr|srw}%I2. %3,%1,%h2
                                 (match_operand:SI 2 "reg_or_cint_operand" ""))
                    (const_int 0)))
    (clobber (match_scratch:SI 3 ""))]
-  "! TARGET_POWER && ! TARGET_POWERPC64 && reload_completed"
+  "! TARGET_POWER && TARGET_32BIT && reload_completed"
   [(set (match_dup 3)
        (lshiftrt:SI (match_dup 1) (match_dup 2)))
    (set (match_dup 0)
                    (const_int 0)))
    (set (match_operand:SI 0 "gpc_reg_operand" "=r,r,r,r")
        (lshiftrt:SI (match_dup 1) (match_dup 2)))]
-  "! TARGET_POWER && ! TARGET_POWERPC64"
+  "! TARGET_POWER && TARGET_32BIT"
   "@
    mr. %0,%1
    {sr|srw}%I2. %0,%1,%h2
                    (const_int 0)))
    (set (match_operand:SI 0 "gpc_reg_operand" "")
        (lshiftrt:SI (match_dup 1) (match_dup 2)))]
-  "! TARGET_POWER && ! TARGET_POWERPC64 && reload_completed"
+  "! TARGET_POWER && TARGET_32BIT && reload_completed"
   [(set (match_dup 0)
        (lshiftrt:SI (match_dup 1) (match_dup 2)))
    (set (match_dup 3)
 ;; this case, we just lose precision that we would have otherwise gotten but
 ;; is not guaranteed.  Perhaps this should be tightened up at some point.
 
-(define_insn "extendsfdf2"
-  [(set (match_operand:DF 0 "gpc_reg_operand" "=f")
-       (float_extend:DF (match_operand:SF 1 "gpc_reg_operand" "f")))]
+(define_expand "extendsfdf2"
+  [(set (match_operand:DF 0 "gpc_reg_operand" "")
+       (float_extend:DF (match_operand:SF 1 "reg_or_none500mem_operand" "")))]
+  "TARGET_HARD_FLOAT && (TARGET_FPRS || TARGET_E500_DOUBLE)"
+  "")
+
+(define_insn_and_split "*extendsfdf2_fpr"
+  [(set (match_operand:DF 0 "gpc_reg_operand" "=f,?f,f")
+       (float_extend:DF (match_operand:SF 1 "reg_or_mem_operand" "0,f,m")))]
   "TARGET_HARD_FLOAT && TARGET_FPRS"
-  "*
+  "@
+   #
+   fmr %0,%1
+   lfs%U1%X1 %0,%1"
+  "&& reload_completed && REGNO (operands[0]) == REGNO (operands[1])"
+  [(const_int 0)]
 {
-  if (REGNO (operands[0]) == REGNO (operands[1]))
-    return \"\";
-  else
-    return \"fmr %0,%1\";
-}"
-  [(set_attr "type" "fp")])
+  emit_note (NOTE_INSN_DELETED);
+  DONE;
+}
+  [(set_attr "type" "fp,fp,fpload")])
+
+(define_expand "truncdfsf2"
+  [(set (match_operand:SF 0 "gpc_reg_operand" "")
+       (float_truncate:SF (match_operand:DF 1 "gpc_reg_operand" "")))]
+  "TARGET_HARD_FLOAT && (TARGET_FPRS || TARGET_E500_DOUBLE)"
+  "")
 
-(define_insn "truncdfsf2"
+(define_insn "*truncdfsf2_fpr"
   [(set (match_operand:SF 0 "gpc_reg_operand" "=f")
        (float_truncate:SF (match_operand:DF 1 "gpc_reg_operand" "f")))]
   "TARGET_HARD_FLOAT && TARGET_FPRS"
   "fsqrt %0,%1"
   [(set_attr "type" "dsqrt")])
 
+(define_expand "copysignsf3"
+  [(set (match_dup 3)
+        (abs:SF (match_operand:SF 1 "gpc_reg_operand" "")))
+   (set (match_dup 4)
+       (neg:SF (abs:SF (match_dup 1))))
+   (set (match_operand:SF 0 "gpc_reg_operand" "")
+        (if_then_else:SF (ge (match_operand:SF 2 "gpc_reg_operand" "")
+                            (match_dup 5))
+                        (match_dup 3)
+                        (match_dup 4)))]
+  "TARGET_PPC_GFXOPT && TARGET_HARD_FLOAT && TARGET_FPRS
+   && !HONOR_NANS (SFmode) && !HONOR_SIGNED_ZEROS (SFmode)" 
+  {
+     operands[3] = gen_reg_rtx (SFmode);
+     operands[4] = gen_reg_rtx (SFmode);
+     operands[5] = CONST0_RTX (SFmode);
+  })
+
+(define_expand "copysigndf3"
+  [(set (match_dup 3)
+        (abs:DF (match_operand:DF 1 "gpc_reg_operand" "")))
+   (set (match_dup 4)
+       (neg:DF (abs:DF (match_dup 1))))
+   (set (match_operand:DF 0 "gpc_reg_operand" "")
+        (if_then_else:DF (ge (match_operand:DF 2 "gpc_reg_operand" "")
+                            (match_dup 5))
+                        (match_dup 3)
+                        (match_dup 4)))]
+  "TARGET_PPC_GFXOPT && TARGET_HARD_FLOAT && TARGET_FPRS
+   && !HONOR_NANS (DFmode) && !HONOR_SIGNED_ZEROS (DFmode)"
+  {
+     operands[3] = gen_reg_rtx (DFmode);
+     operands[4] = gen_reg_rtx (DFmode);
+     operands[5] = CONST0_RTX (DFmode);
+  })
+
 ;; For MIN, MAX, and conditional move, we use DEFINE_EXPAND's that involve a
 ;; fsel instruction and some auxiliary computations.  Then we just have a
 ;; single DEFINE_INSN for fsel and the define_splits to make them if made by
 ;; combine.
-(define_expand "maxsf3"
+(define_expand "smaxsf3"
   [(set (match_operand:SF 0 "gpc_reg_operand" "")
        (if_then_else:SF (ge (match_operand:SF 1 "gpc_reg_operand" "")
                             (match_operand:SF 2 "gpc_reg_operand" ""))
                         (match_dup 1)
                         (match_dup 2)))]
-  "TARGET_PPC_GFXOPT && TARGET_HARD_FLOAT && TARGET_FPRS"
+  "TARGET_PPC_GFXOPT && TARGET_HARD_FLOAT && TARGET_FPRS && !flag_trapping_math"
   "{ rs6000_emit_minmax (operands[0], SMAX, operands[1], operands[2]); DONE;}")
 
-(define_expand "minsf3"
+(define_expand "sminsf3"
   [(set (match_operand:SF 0 "gpc_reg_operand" "")
        (if_then_else:SF (ge (match_operand:SF 1 "gpc_reg_operand" "")
                             (match_operand:SF 2 "gpc_reg_operand" ""))
                         (match_dup 2)
                         (match_dup 1)))]
-  "TARGET_PPC_GFXOPT && TARGET_HARD_FLOAT && TARGET_FPRS"
+  "TARGET_PPC_GFXOPT && TARGET_HARD_FLOAT && TARGET_FPRS && !flag_trapping_math"
   "{ rs6000_emit_minmax (operands[0], SMIN, operands[1], operands[2]); DONE;}")
 
 (define_split
        (match_operator:SF 3 "min_max_operator"
         [(match_operand:SF 1 "gpc_reg_operand" "")
          (match_operand:SF 2 "gpc_reg_operand" "")]))]
-  "TARGET_PPC_GFXOPT && TARGET_HARD_FLOAT && TARGET_FPRS"
+  "TARGET_PPC_GFXOPT && TARGET_HARD_FLOAT && TARGET_FPRS && !flag_trapping_math"
   [(const_int 0)]
   "
-{ rs6000_emit_minmax (operands[0], GET_CODE (operands[3]), 
+{ rs6000_emit_minmax (operands[0], GET_CODE (operands[3]),
                      operands[1], operands[2]);
   DONE;
 }")
   "fsel %0,%1,%2,%3"
   [(set_attr "type" "fp")])
 
-(define_insn "negdf2"
+(define_expand "negdf2"
+  [(set (match_operand:DF 0 "gpc_reg_operand" "")
+       (neg:DF (match_operand:DF 1 "gpc_reg_operand" "")))]
+  "TARGET_HARD_FLOAT && (TARGET_FPRS || TARGET_E500_DOUBLE)"
+  "")
+
+(define_insn "*negdf2_fpr"
   [(set (match_operand:DF 0 "gpc_reg_operand" "=f")
        (neg:DF (match_operand:DF 1 "gpc_reg_operand" "f")))]
   "TARGET_HARD_FLOAT && TARGET_FPRS"
   "fneg %0,%1"
   [(set_attr "type" "fp")])
 
-(define_insn "absdf2"
+(define_expand "absdf2"
+  [(set (match_operand:DF 0 "gpc_reg_operand" "")
+       (abs:DF (match_operand:DF 1 "gpc_reg_operand" "")))]
+  "TARGET_HARD_FLOAT && (TARGET_FPRS || TARGET_E500_DOUBLE)"
+  "")
+
+(define_insn "*absdf2_fpr"
   [(set (match_operand:DF 0 "gpc_reg_operand" "=f")
        (abs:DF (match_operand:DF 1 "gpc_reg_operand" "f")))]
   "TARGET_HARD_FLOAT && TARGET_FPRS"
   "fabs %0,%1"
   [(set_attr "type" "fp")])
 
-(define_insn ""
+(define_insn "*nabsdf2_fpr"
   [(set (match_operand:DF 0 "gpc_reg_operand" "=f")
        (neg:DF (abs:DF (match_operand:DF 1 "gpc_reg_operand" "f"))))]
   "TARGET_HARD_FLOAT && TARGET_FPRS"
   "fnabs %0,%1"
   [(set_attr "type" "fp")])
 
-(define_insn "adddf3"
+(define_expand "adddf3"
+  [(set (match_operand:DF 0 "gpc_reg_operand" "")
+       (plus:DF (match_operand:DF 1 "gpc_reg_operand" "")
+                (match_operand:DF 2 "gpc_reg_operand" "")))]
+  "TARGET_HARD_FLOAT && (TARGET_FPRS || TARGET_E500_DOUBLE)"
+  "")
+
+(define_insn "*adddf3_fpr"
   [(set (match_operand:DF 0 "gpc_reg_operand" "=f")
        (plus:DF (match_operand:DF 1 "gpc_reg_operand" "%f")
                 (match_operand:DF 2 "gpc_reg_operand" "f")))]
   "{fa|fadd} %0,%1,%2"
   [(set_attr "type" "fp")])
 
-(define_insn "subdf3"
+(define_expand "subdf3"
+  [(set (match_operand:DF 0 "gpc_reg_operand" "")
+       (minus:DF (match_operand:DF 1 "gpc_reg_operand" "")
+                 (match_operand:DF 2 "gpc_reg_operand" "")))]
+  "TARGET_HARD_FLOAT && (TARGET_FPRS || TARGET_E500_DOUBLE)"
+  "")
+
+(define_insn "*subdf3_fpr"
   [(set (match_operand:DF 0 "gpc_reg_operand" "=f")
        (minus:DF (match_operand:DF 1 "gpc_reg_operand" "f")
                  (match_operand:DF 2 "gpc_reg_operand" "f")))]
   "{fs|fsub} %0,%1,%2"
   [(set_attr "type" "fp")])
 
-(define_insn "muldf3"
+(define_expand "muldf3"
+  [(set (match_operand:DF 0 "gpc_reg_operand" "")
+       (mult:DF (match_operand:DF 1 "gpc_reg_operand" "")
+                (match_operand:DF 2 "gpc_reg_operand" "")))]
+  "TARGET_HARD_FLOAT && (TARGET_FPRS || TARGET_E500_DOUBLE)"
+  "")
+
+(define_insn "*muldf3_fpr"
   [(set (match_operand:DF 0 "gpc_reg_operand" "=f")
        (mult:DF (match_operand:DF 1 "gpc_reg_operand" "%f")
                 (match_operand:DF 2 "gpc_reg_operand" "f")))]
   "{fm|fmul} %0,%1,%2"
   [(set_attr "type" "dmul")])
 
-(define_insn "divdf3"
+(define_expand "divdf3"
+  [(set (match_operand:DF 0 "gpc_reg_operand" "")
+       (div:DF (match_operand:DF 1 "gpc_reg_operand" "")
+               (match_operand:DF 2 "gpc_reg_operand" "")))]
+  "TARGET_HARD_FLOAT && (TARGET_FPRS || TARGET_E500_DOUBLE)"
+  "")
+
+(define_insn "*divdf3_fpr"
   [(set (match_operand:DF 0 "gpc_reg_operand" "=f")
        (div:DF (match_operand:DF 1 "gpc_reg_operand" "f")
                (match_operand:DF 2 "gpc_reg_operand" "f")))]
        (minus:DF (match_operand:DF 3 "gpc_reg_operand" "f")
                  (mult:DF (match_operand:DF 1 "gpc_reg_operand" "%f")
                           (match_operand:DF 2 "gpc_reg_operand" "f"))))]
-  "TARGET_HARD_FLOAT && TARGET_FPRS && TARGET_FUSED_MADD 
+  "TARGET_HARD_FLOAT && TARGET_FPRS && TARGET_FUSED_MADD
    && ! HONOR_SIGNED_ZEROS (DFmode)"
   "{fnms|fnmsub} %0,%1,%2,%3"
   [(set_attr "type" "dmul")])
   [(set_attr "type" "dsqrt")])
 
 ;; The conditional move instructions allow us to perform max and min
-;; operations even when 
+;; operations even when
 
-(define_expand "maxdf3"
+(define_expand "smaxdf3"
   [(set (match_operand:DF 0 "gpc_reg_operand" "")
        (if_then_else:DF (ge (match_operand:DF 1 "gpc_reg_operand" "")
                             (match_operand:DF 2 "gpc_reg_operand" ""))
                         (match_dup 1)
                         (match_dup 2)))]
-  "TARGET_PPC_GFXOPT && TARGET_HARD_FLOAT && TARGET_FPRS"
+  "TARGET_PPC_GFXOPT && TARGET_HARD_FLOAT && TARGET_FPRS && !flag_trapping_math"
   "{ rs6000_emit_minmax (operands[0], SMAX, operands[1], operands[2]); DONE;}")
 
-(define_expand "mindf3"
+(define_expand "smindf3"
   [(set (match_operand:DF 0 "gpc_reg_operand" "")
        (if_then_else:DF (ge (match_operand:DF 1 "gpc_reg_operand" "")
                             (match_operand:DF 2 "gpc_reg_operand" ""))
                         (match_dup 2)
                         (match_dup 1)))]
-  "TARGET_PPC_GFXOPT && TARGET_HARD_FLOAT && TARGET_FPRS"
+  "TARGET_PPC_GFXOPT && TARGET_HARD_FLOAT && TARGET_FPRS && !flag_trapping_math"
   "{ rs6000_emit_minmax (operands[0], SMIN, operands[1], operands[2]); DONE;}")
 
 (define_split
        (match_operator:DF 3 "min_max_operator"
         [(match_operand:DF 1 "gpc_reg_operand" "")
          (match_operand:DF 2 "gpc_reg_operand" "")]))]
-  "TARGET_PPC_GFXOPT && TARGET_HARD_FLOAT && TARGET_FPRS"
+  "TARGET_PPC_GFXOPT && TARGET_HARD_FLOAT && TARGET_FPRS && !flag_trapping_math"
   [(const_int 0)]
   "
-{ rs6000_emit_minmax (operands[0], GET_CODE (operands[3]), 
+{ rs6000_emit_minmax (operands[0], GET_CODE (operands[3]),
                      operands[1], operands[2]);
   DONE;
 }")
 \f
 ;; Conversions to and from floating-point.
 
-(define_expand "fixunssfsi2"
+(define_expand "fixuns_truncsfsi2"
   [(set (match_operand:SI 0 "gpc_reg_operand" "")
-       (unsigned_fix:SI (fix:SF (match_operand:SF 1 "gpc_reg_operand" ""))))]
+       (unsigned_fix:SI (match_operand:SF 1 "gpc_reg_operand" "")))]
   "TARGET_HARD_FLOAT && !TARGET_FPRS"
   "")
 
   "TARGET_HARD_FLOAT && TARGET_FPRS"
   "
 {
+  if (TARGET_E500_DOUBLE)
+    {
+      emit_insn (gen_spe_floatsidf2 (operands[0], operands[1]));
+      DONE;
+    }
   if (TARGET_POWERPC64)
     {
       rtx mem = assign_stack_temp (DImode, GET_MODE_SIZE (DImode), 0);
       tmp = highword; highword = lowword; lowword = tmp;
     }
 
-  emit_insn (gen_xorsi3 (operands[6], operands[1], 
+  emit_insn (gen_xorsi3 (operands[6], operands[1],
                         GEN_INT (~ (HOST_WIDE_INT) 0x7fffffff)));
   emit_move_insn (gen_rtx_MEM (SImode, lowword), operands[6]);
   emit_move_insn (gen_rtx_MEM (SImode, highword), operands[2]);
              (use (match_dup 3))
              (clobber (match_dup 4))
              (clobber (match_dup 5))])]
-  "TARGET_HARD_FLOAT && TARGET_FPRS"
+  "TARGET_HARD_FLOAT && (TARGET_FPRS || TARGET_E500_DOUBLE)"
   "
 {
+  if (TARGET_E500_DOUBLE)
+    {
+      emit_insn (gen_spe_floatunssidf2 (operands[0], operands[1]));
+      DONE;
+    }
   if (TARGET_POWERPC64)
     {
       rtx mem = assign_stack_temp (DImode, GET_MODE_SIZE (DImode), 0);
 }")
 
 (define_expand "fix_truncdfsi2"
-  [(parallel [(set (match_operand:SI 0 "gpc_reg_operand" "")
+  [(parallel [(set (match_operand:SI 0 "reg_or_mem_operand" "")
                   (fix:SI (match_operand:DF 1 "gpc_reg_operand" "")))
              (clobber (match_dup 2))
              (clobber (match_dup 3))])]
-  "(TARGET_POWER2 || TARGET_POWERPC) && TARGET_HARD_FLOAT && TARGET_FPRS"
+  "(TARGET_POWER2 || TARGET_POWERPC)
+   && TARGET_HARD_FLOAT && (TARGET_FPRS || TARGET_E500_DOUBLE)"
   "
 {
+  if (TARGET_E500_DOUBLE)
+    {
+     emit_insn (gen_spe_fix_truncdfsi2 (operands[0], operands[1]));
+     DONE;
+    }
   operands[2] = gen_reg_rtx (DImode);
+  if (TARGET_PPC_GFXOPT)
+    {
+      rtx orig_dest = operands[0];
+      if (GET_CODE (orig_dest) != MEM)
+       operands[0] = assign_stack_temp (SImode, GET_MODE_SIZE (SImode), 0);
+      emit_insn (gen_fix_truncdfsi2_internal_gfxopt (operands[0], operands[1],
+                                                    operands[2]));
+      if (operands[0] != orig_dest)
+       emit_move_insn (orig_dest, operands[0]);
+      DONE;
+    }
   operands[3] = assign_stack_temp (DImode, GET_MODE_SIZE (DImode), 0);
 }")
 
-(define_insn "*fix_truncdfsi2_internal"
+(define_insn_and_split "*fix_truncdfsi2_internal"
   [(set (match_operand:SI 0 "gpc_reg_operand" "=r")
        (fix:SI (match_operand:DF 1 "gpc_reg_operand" "f")))
    (clobber (match_operand:DI 2 "gpc_reg_operand" "=f"))
    (clobber (match_operand:DI 3 "memory_operand" "=o"))]
   "(TARGET_POWER2 || TARGET_POWERPC) && TARGET_HARD_FLOAT && TARGET_FPRS"
   "#"
-  [(set_attr "length" "16")])
-
-(define_split
-  [(set (match_operand:SI 0 "gpc_reg_operand" "")
-       (fix:SI (match_operand:DF 1 "gpc_reg_operand" "")))
-   (clobber (match_operand:DI 2 "gpc_reg_operand" ""))
-   (clobber (match_operand:DI 3 "offsettable_mem_operand" ""))]
-  "(TARGET_POWER2 || TARGET_POWERPC) && TARGET_HARD_FLOAT && TARGET_FPRS"
-  [(set (match_operand:SI 0 "gpc_reg_operand" "")
-       (fix:SI (match_operand:DF 1 "gpc_reg_operand" "")))
-   (clobber (match_operand:DI 2 "gpc_reg_operand" ""))
-   (clobber (match_operand:DI 3 "offsettable_mem_operand" ""))]
+  "&& 1"
+  [(pc)]
   "
 {
   rtx lowword;
   emit_move_insn (operands[3], operands[2]);
   emit_move_insn (operands[0], gen_rtx_MEM (SImode, lowword));
   DONE;
-}")
+}"
+  [(set_attr "length" "16")])
+
+(define_insn_and_split "fix_truncdfsi2_internal_gfxopt"
+  [(set (match_operand:SI 0 "memory_operand" "=Z")
+       (fix:SI (match_operand:DF 1 "gpc_reg_operand" "f")))
+   (clobber (match_operand:DI 2 "gpc_reg_operand" "=f"))]
+  "(TARGET_POWER2 || TARGET_POWERPC) && TARGET_HARD_FLOAT && TARGET_FPRS
+   && TARGET_PPC_GFXOPT"
+  "#"
+  "&& 1"
+  [(pc)]
+  "
+{
+  emit_insn (gen_fctiwz (operands[2], operands[1]));
+  emit_insn (gen_stfiwx (operands[0], operands[2]));
+  DONE;
+}"
+  [(set_attr "length" "16")])
 
 ; Here, we use (set (reg) (unspec:DI [(fix:SI ...)] UNSPEC_FCTIWZ))
 ; rather than (set (subreg:SI (reg)) (fix:SI ...))
 ; because the first makes it clear that operand 0 is not live
 ; before the instruction.
 (define_insn "fctiwz"
-  [(set (match_operand:DI 0 "gpc_reg_operand" "=*f")
+  [(set (match_operand:DI 0 "gpc_reg_operand" "=f")
        (unspec:DI [(fix:SI (match_operand:DF 1 "gpc_reg_operand" "f"))]
                   UNSPEC_FCTIWZ))]
   "(TARGET_POWER2 || TARGET_POWERPC) && TARGET_HARD_FLOAT && TARGET_FPRS"
   "{fcirz|fctiwz} %0,%1"
   [(set_attr "type" "fp")])
 
+; An UNSPEC is used so we don't have to support SImode in FP registers.
+(define_insn "stfiwx"
+  [(set (match_operand:SI 0 "memory_operand" "=Z")
+       (unspec:SI [(match_operand:DI 1 "gpc_reg_operand" "f")]
+                  UNSPEC_STFIWX))]
+  "TARGET_PPC_GFXOPT"
+  "stfiwx %1,%y0"
+  [(set_attr "type" "fpstore")])
+
 (define_expand "floatsisf2"
   [(set (match_operand:SF 0 "gpc_reg_operand" "")
         (float:SF (match_operand:SI 1 "gpc_reg_operand" "")))]
    (clobber (match_operand:DI 4 "gpc_reg_operand" "=f"))]
   "TARGET_POWERPC64 && TARGET_HARD_FLOAT && TARGET_FPRS"
   "#"
-  ""
+  "&& 1"
   [(set (match_dup 3) (sign_extend:DI (match_dup 1)))
    (set (match_dup 2) (match_dup 3))
    (set (match_dup 4) (match_dup 2))
    (clobber (match_operand:DI 4 "gpc_reg_operand" "=f"))]
   "TARGET_POWERPC64 && TARGET_HARD_FLOAT && TARGET_FPRS"
   "#"
-  ""
+  "&& 1"
   [(set (match_dup 3) (zero_extend:DI (match_dup 1)))
    (set (match_dup 2) (match_dup 3))
    (set (match_dup 4) (match_dup 2))
   "TARGET_POWERPC64 && TARGET_HARD_FLOAT && TARGET_FPRS"
   "
 {
+  rtx val = operands[1];
   if (!flag_unsafe_math_optimizations)
     {
       rtx label = gen_label_rtx ();
-      emit_insn (gen_floatdisf2_internal2 (operands[1], label));
+      val = gen_reg_rtx (DImode);
+      emit_insn (gen_floatdisf2_internal2 (val, operands[1], label));
       emit_label (label);
     }
-  emit_insn (gen_floatdisf2_internal1 (operands[0], operands[1]));
+  emit_insn (gen_floatdisf2_internal1 (operands[0], val));
   DONE;
 }")
 
 ;; by a bit that won't be lost at that stage, but is below the SFmode
 ;; rounding position.
 (define_expand "floatdisf2_internal2"
-  [(parallel [(set (match_dup 4)
-                  (compare:CC (and:DI (match_operand:DI 0 "" "")
-                                      (const_int 2047))
-                              (const_int 0)))
-             (set (match_dup 2) (and:DI (match_dup 0) (const_int 2047)))
-             (clobber (match_scratch:CC 7 ""))])
-   (set (match_dup 3) (ashiftrt:DI (match_dup 0) (const_int 53)))
-   (set (match_dup 3) (plus:DI (match_dup 3) (const_int 1)))
-   (set (pc) (if_then_else (eq (match_dup 4) (const_int 0))
-                          (label_ref (match_operand:DI 1 "" ""))
-                          (pc)))
-   (set (match_dup 5) (compare:CCUNS (match_dup 3) (const_int 2)))
-   (set (pc) (if_then_else (ltu (match_dup 5) (const_int 0))
-                          (label_ref (match_dup 1))
+  [(set (match_dup 3) (ashiftrt:DI (match_operand:DI 1 "" "")
+                                  (const_int 53)))
+   (parallel [(set (match_operand:DI 0 "" "") (and:DI (match_dup 1)
+                                                     (const_int 2047)))
+             (clobber (scratch:CC))])
+   (set (match_dup 3) (plus:DI (match_dup 3)
+                              (const_int 1)))
+   (set (match_dup 0) (plus:DI (match_dup 0)
+                              (const_int 2047)))
+   (set (match_dup 4) (compare:CCUNS (match_dup 3)
+                                    (const_int 3)))
+   (set (match_dup 0) (ior:DI (match_dup 0)
+                             (match_dup 1)))
+   (parallel [(set (match_dup 0) (and:DI (match_dup 0)
+                                        (const_int -2048)))
+             (clobber (scratch:CC))])
+   (set (pc) (if_then_else (geu (match_dup 4) (const_int 0))
+                          (label_ref (match_operand:DI 2 "" ""))
                           (pc)))
-   (set (match_dup 0) (xor:DI (match_dup 0) (match_dup 2)))
-   (set (match_dup 0) (ior:DI (match_dup 0) (const_int 2048)))]
+   (set (match_dup 0) (match_dup 1))]
   "TARGET_POWERPC64 && TARGET_HARD_FLOAT && TARGET_FPRS"
   "
 {
-  operands[2] = gen_reg_rtx (DImode);
   operands[3] = gen_reg_rtx (DImode);
-  operands[4] = gen_reg_rtx (CCmode);
-  operands[5] = gen_reg_rtx (CCUNSmode);
+  operands[4] = gen_reg_rtx (CCUNSmode);
 }")
 \f
 ;; Define the DImode operations that can be done in a small number
            ? \"{a|addc} %0,%1,%2\;{ae|adde} %L0,%L1,%L2\"
            : \"{ai|addic} %0,%1,%2\;{a%G2e|add%G2e} %L0,%L1\";
 }"
-  [(set_attr "length" "8")])
+  [(set_attr "type" "two")
+   (set_attr "length" "8")])
 
 (define_insn "*subdi3_noppc64"
   [(set (match_operand:DI 0 "gpc_reg_operand" "=&r,&r,r,r,r")
            ? \"{sf|subfc} %0,%2,%1\;{sfe|subfe} %L0,%L2,%L1\"
            : \"{sfi|subfic} %0,%2,%1\;{sf%G1e|subf%G1e} %L0,%L2\";
 }"
-  [(set_attr "length" "8")])
+  [(set_attr "type" "two")
+   (set_attr "length" "8")])
 
 (define_insn "*negdi2_noppc64"
   [(set (match_operand:DI 0 "gpc_reg_operand" "=&r,r")
     ? \"{sfi|subfic} %L0,%L1,0\;{sfze|subfze} %0,%1\"
     : \"{sfi|subfic} %0,%1,0\;{sfze|subfze} %L0,%L1\";
 }"
-  [(set_attr "length" "8")])
+  [(set_attr "type" "two")
+   (set_attr "length" "8")])
 
 (define_expand "mulsidi3"
   [(set (match_operand:DI 0 "gpc_reg_operand" "")
   [(set (match_operand:DI 0 "gpc_reg_operand" "=&r,&r")
        (ashiftrt:DI (match_operand:DI 1 "gpc_reg_operand" "r,r")
                     (match_operand:SI 2 "const_int_operand" "M,i")))]
-  "TARGET_32BIT && !TARGET_POWER"
+  "TARGET_32BIT && !TARGET_POWERPC64 && !TARGET_POWER && WORDS_BIG_ENDIAN"
   "@
    {srai|srawi} %0,%1,31\;{srai|srawi} %L0,%1,%h2
    {sri|srwi} %L0,%L1,%h2\;insrwi %L0,%1,%h2,0\;{srai|srawi} %0,%1,%h2"
-  [(set_attr "length" "8,12")])
+  [(set_attr "type" "two,three")
+   (set_attr "length" "8,12")])
+
+(define_insn "*ashrdisi3_noppc64"
+  [(set (match_operand:SI 0 "gpc_reg_operand" "=r")
+        (subreg:SI (ashiftrt:DI (match_operand:DI 1 "gpc_reg_operand" "r")
+                                (const_int 32)) 4))]
+  "TARGET_32BIT && !TARGET_POWERPC64"
+  "*
+{
+  if (REGNO (operands[0]) == REGNO (operands[1]))
+    return \"\";
+  else
+    return \"mr %0,%1\";
+}"
+   [(set_attr "length" "4")])
+
 \f
 ;; PowerPC64 DImode operations.
 
                             (match_operand:DI 2 "reg_or_short_operand" "r,I,r,I"))
                    (const_int 0)))
    (clobber (match_scratch:DI 3 "=r,r,r,r"))]
-  "TARGET_POWERPC64"
+  "TARGET_64BIT"
   "@
    add. %3,%1,%2
    addic. %3,%1,%2
                    (const_int 0)))
    (set (match_operand:DI 0 "gpc_reg_operand" "=r,r,r,r")
        (plus:DI (match_dup 1) (match_dup 2)))]
-  "TARGET_POWERPC64"
+  "TARGET_64BIT"
   "@
    add. %0,%1,%2
    addic. %0,%1,%2
        (compare:CC (not:DI (match_operand:DI 1 "gpc_reg_operand" "r,r"))
                    (const_int 0)))
    (clobber (match_scratch:DI 2 "=r,r"))]
-  "TARGET_POWERPC64"
+  "TARGET_64BIT"
   "@
    nor. %2,%1,%1
    #"
                    (const_int 0)))
    (set (match_operand:DI 0 "gpc_reg_operand" "=r,r")
        (not:DI (match_dup 1)))]
-  "TARGET_POWERPC64"
+  "TARGET_64BIT"
   "@
    nor. %0,%1,%1
    #"
                              (match_operand:DI 2 "gpc_reg_operand" "r,r"))
                    (const_int 0)))
    (clobber (match_scratch:DI 3 "=r,r"))]
-  "TARGET_POWERPC64"
+  "TARGET_64BIT"
   "@
    subf. %3,%2,%1
    #"
                    (const_int 0)))
    (set (match_operand:DI 0 "gpc_reg_operand" "=r,r")
        (minus:DI (match_dup 1) (match_dup 2)))]
-  "TARGET_POWERPC64"
+  "TARGET_64BIT"
   "@
    subf. %0,%2,%1
    #"
        (compare:CC (neg:DI (match_operand:DI 1 "gpc_reg_operand" "r,r"))
                    (const_int 0)))
    (clobber (match_scratch:DI 2 "=r,r"))]
-  "TARGET_POWERPC64"
+  "TARGET_64BIT"
   "@
    neg. %2,%1
    #"
                    (const_int 0)))
    (set (match_operand:DI 0 "gpc_reg_operand" "=r,r")
        (neg:DI (match_dup 1)))]
-  "TARGET_POWERPC64"
+  "TARGET_64BIT"
   "@
    neg. %0,%1
    #"
 (define_expand "ctzdi2"
   [(set (match_dup 2)
        (neg:DI (match_operand:DI 1 "gpc_reg_operand" "r")))
-   (parallel [(set (match_dup 3) (and:DI (match_dup 1)      
-                                        (match_dup 2)))   
+   (parallel [(set (match_dup 3) (and:DI (match_dup 1)
+                                        (match_dup 2)))
              (clobber (scratch:CC))])
    (set (match_dup 4) (clz:DI (match_dup 3)))
    (set (match_operand:DI 0 "gpc_reg_operand" "=r")
        (minus:DI (const_int 63) (match_dup 4)))]
   "TARGET_POWERPC64"
   {
-     operands[2] = gen_reg_rtx (DImode); 
+     operands[2] = gen_reg_rtx (DImode);
      operands[3] = gen_reg_rtx (DImode);
      operands[4] = gen_reg_rtx (DImode);
   })
 (define_expand "ffsdi2"
   [(set (match_dup 2)
        (neg:DI (match_operand:DI 1 "gpc_reg_operand" "r")))
-   (parallel [(set (match_dup 3) (and:DI (match_dup 1)      
-                                        (match_dup 2)))   
+   (parallel [(set (match_dup 3) (and:DI (match_dup 1)
+                                        (match_dup 2)))
              (clobber (scratch:CC))])
    (set (match_dup 4) (clz:DI (match_dup 3)))
    (set (match_operand:DI 0 "gpc_reg_operand" "=r")
        (minus:DI (const_int 64) (match_dup 4)))]
   "TARGET_POWERPC64"
   {
-     operands[2] = gen_reg_rtx (DImode); 
+     operands[2] = gen_reg_rtx (DImode);
      operands[3] = gen_reg_rtx (DImode);
      operands[4] = gen_reg_rtx (DImode);
   })
                (match_operand:DI 2 "exact_log2_cint_operand" "N")))]
   "TARGET_POWERPC64"
   "sradi %0,%1,%p2\;addze %0,%0"
-  [(set_attr "length" "8")])
+  [(set_attr "type" "two")
+   (set_attr "length" "8")])
 
 (define_insn ""
   [(set (match_operand:CC 0 "cc_reg_operand" "=x,?y")
                            (match_operand:DI 2 "exact_log2_cint_operand" "N,N"))
                    (const_int 0)))
    (clobber (match_scratch:DI 3 "=r,r"))]
-  "TARGET_POWERPC64"
+  "TARGET_64BIT"
   "@
    sradi %3,%1,%p2\;addze. %3,%3
    #"
                    (const_int 0)))
    (set (match_operand:DI 0 "gpc_reg_operand" "=r,r")
        (div:DI (match_dup 1) (match_dup 2)))]
-  "TARGET_POWERPC64"
+  "TARGET_64BIT"
   "@
    sradi %0,%1,%p2\;addze. %0,%0
    #"
                               (match_operand:DI 2 "reg_or_cint_operand" "ri,ri"))
                    (const_int 0)))
    (clobber (match_scratch:DI 3 "=r,r"))]
-  "TARGET_POWERPC64"
+  "TARGET_64BIT"
   "@
    rld%I2cl. %3,%1,%H2,0
    #"
                    (const_int 0)))
    (set (match_operand:DI 0 "gpc_reg_operand" "=r,r")
        (rotate:DI (match_dup 1) (match_dup 2)))]
-  "TARGET_POWERPC64"
+  "TARGET_64BIT"
   "@
    rld%I2cl. %0,%1,%H2,0
    #"
                     (match_operand:DI 3 "mask64_operand" "n,n"))
                    (const_int 0)))
    (clobber (match_scratch:DI 4 "=r,r"))]
-  "TARGET_POWERPC64"
+  "TARGET_64BIT"
   "@
    rld%I2c%B3. %4,%1,%H2,%S3
    #"
                    (const_int 0)))
    (set (match_operand:DI 0 "gpc_reg_operand" "=r,r")
        (and:DI (rotate:DI (match_dup 1) (match_dup 2)) (match_dup 3)))]
-  "TARGET_POWERPC64"
+  "TARGET_64BIT"
   "@
    rld%I2c%B3. %0,%1,%H2,%S3
    #"
                                 (match_operand:DI 2 "reg_or_cint_operand" "ri,ri")) 0))
                    (const_int 0)))
    (clobber (match_scratch:DI 3 "=r,r"))]
-  "TARGET_POWERPC64"
+  "TARGET_64BIT"
   "@
    rld%I2cl. %3,%1,%H2,56
    #"
                    (const_int 0)))
    (set (match_operand:DI 0 "gpc_reg_operand" "=r,r")
        (zero_extend:DI (subreg:QI (rotate:DI (match_dup 1) (match_dup 2)) 0)))]
-  "TARGET_POWERPC64"
+  "TARGET_64BIT"
   "@
    rld%I2cl. %0,%1,%H2,56
    #"
                                 (match_operand:DI 2 "reg_or_cint_operand" "ri,ri")) 0))
                    (const_int 0)))
    (clobber (match_scratch:DI 3 "=r,r"))]
-  "TARGET_POWERPC64"
+  "TARGET_64BIT"
   "@
    rld%I2cl. %3,%1,%H2,48
    #"
                    (const_int 0)))
    (set (match_operand:DI 0 "gpc_reg_operand" "=r,r")
        (zero_extend:DI (subreg:HI (rotate:DI (match_dup 1) (match_dup 2)) 0)))]
-  "TARGET_POWERPC64"
+  "TARGET_64BIT"
   "@
    rld%I2cl. %0,%1,%H2,48
    #"
                                 (match_operand:DI 2 "reg_or_cint_operand" "ri,ri")) 0))
                    (const_int 0)))
    (clobber (match_scratch:DI 3 "=r,r"))]
-  "TARGET_POWERPC64"
+  "TARGET_64BIT"
   "@
    rld%I2cl. %3,%1,%H2,32
    #"
                    (const_int 0)))
    (set (match_operand:DI 0 "gpc_reg_operand" "=r,r")
        (zero_extend:DI (subreg:SI (rotate:DI (match_dup 1) (match_dup 2)) 0)))]
-  "TARGET_POWERPC64"
+  "TARGET_64BIT"
   "@
    rld%I2cl. %0,%1,%H2,32
    #"
        (ashift:DI (match_operand:DI 1 "gpc_reg_operand" "r")
                   (match_operand:SI 2 "reg_or_cint_operand" "ri")))]
   "TARGET_POWERPC64"
-  "sld%I2 %0,%1,%H2"
-  [(set_attr "length" "8")])
-  
+  "sld%I2 %0,%1,%H2")
+
 (define_insn "*ashldi3_internal2"
   [(set (match_operand:CC 0 "cc_reg_operand" "=x,?y")
        (compare:CC (ashift:DI (match_operand:DI 1 "gpc_reg_operand" "r,r")
                               (match_operand:SI 2 "reg_or_cint_operand" "ri,ri"))
                    (const_int 0)))
    (clobber (match_scratch:DI 3 "=r,r"))]
-  "TARGET_POWERPC64"
+  "TARGET_64BIT"
   "@
    sld%I2. %3,%1,%H2
    #"
   [(set_attr "type" "delayed_compare")
    (set_attr "length" "4,8")])
-  
+
 (define_split
   [(set (match_operand:CC 0 "cc_reg_not_cr0_operand" "")
        (compare:CC (ashift:DI (match_operand:DI 1 "gpc_reg_operand" "")
                    (const_int 0)))
    (set (match_operand:DI 0 "gpc_reg_operand" "=r,r")
        (ashift:DI (match_dup 1) (match_dup 2)))]
-  "TARGET_POWERPC64"
+  "TARGET_64BIT"
   "@
    sld%I2. %0,%1,%H2
    #"
                 (match_operand:DI 3 "const_int_operand" "n,n"))
         (const_int 0)))
    (clobber (match_scratch:DI 4 "=r,r"))]
-  "TARGET_POWERPC64 && includes_rldic_lshift_p (operands[2], operands[3])"
+  "TARGET_64BIT && includes_rldic_lshift_p (operands[2], operands[3])"
   "@
    rldic. %4,%1,%H2,%W3
    #"
         (const_int 0)))
    (set (match_operand:DI 0 "gpc_reg_operand" "=r,r")
        (and:DI (ashift:DI (match_dup 1) (match_dup 2)) (match_dup 3)))]
-  "TARGET_POWERPC64 && includes_rldic_lshift_p (operands[2], operands[3])"
+  "TARGET_64BIT && includes_rldic_lshift_p (operands[2], operands[3])"
   "@
    rldic. %0,%1,%H2,%W3
    #"
                 (match_operand:DI 3 "mask64_operand" "n,n"))
         (const_int 0)))
    (clobber (match_scratch:DI 4 "=r,r"))]
-  "TARGET_POWERPC64 && includes_rldicr_lshift_p (operands[2], operands[3])"
+  "TARGET_64BIT && includes_rldicr_lshift_p (operands[2], operands[3])"
   "@
    rldicr. %4,%1,%H2,%S3
    #"
         (const_int 0)))
    (set (match_operand:DI 0 "gpc_reg_operand" "=r,r")
        (and:DI (ashift:DI (match_dup 1) (match_dup 2)) (match_dup 3)))]
-  "TARGET_POWERPC64 && includes_rldicr_lshift_p (operands[2], operands[3])"
+  "TARGET_64BIT && includes_rldicr_lshift_p (operands[2], operands[3])"
   "@
    rldicr. %0,%1,%H2,%S3
    #"
                                 (match_operand:SI 2 "reg_or_cint_operand" "ri,ri"))
                    (const_int 0)))
    (clobber (match_scratch:DI 3 "=r,r"))]
-  "TARGET_POWERPC64"
+  "TARGET_64BIT "
   "@
    srd%I2. %3,%1,%H2
    #"
                    (const_int 0)))
    (set (match_operand:DI 0 "gpc_reg_operand" "=r,r")
        (lshiftrt:DI (match_dup 1) (match_dup 2)))]
-  "TARGET_POWERPC64"
+  "TARGET_64BIT"
   "@
    srd%I2. %0,%1,%H2
    #"
   [(set (match_operand:DI 0 "gpc_reg_operand" "")
        (ashiftrt:DI (match_operand:DI 1 "gpc_reg_operand" "")
                     (match_operand:SI 2 "reg_or_cint_operand" "")))]
-  ""
+  "WORDS_BIG_ENDIAN"
   "
 {
   if (TARGET_POWERPC64)
       emit_insn (gen_ashrdi3_power (operands[0], operands[1], operands[2]));
       DONE;
     }
-  else if (TARGET_32BIT && GET_CODE (operands[2]) == CONST_INT)
+  else if (TARGET_32BIT && GET_CODE (operands[2]) == CONST_INT
+          && WORDS_BIG_ENDIAN)
     {
       emit_insn (gen_ashrdi3_no_power (operands[0], operands[1], operands[2]));
       DONE;
                                 (match_operand:SI 2 "reg_or_cint_operand" "ri,ri"))
                    (const_int 0)))
    (clobber (match_scratch:DI 3 "=r,r"))]
-  "TARGET_POWERPC64"
+  "TARGET_64BIT"
   "@
    srad%I2. %3,%1,%H2
    #"
                    (const_int 0)))
    (set (match_operand:DI 0 "gpc_reg_operand" "=r,r")
        (ashiftrt:DI (match_dup 1) (match_dup 2)))]
-  "TARGET_POWERPC64"
+  "TARGET_64BIT"
   "@
    srad%I2. %0,%1,%H2
    #"
   "")
 
 (define_insn "anddi3"
-  [(set (match_operand:DI 0 "gpc_reg_operand" "=r,r,r,r,r")
-       (and:DI (match_operand:DI 1 "gpc_reg_operand" "%r,r,r,r,r")
-               (match_operand:DI 2 "and64_2_operand" "?r,S,K,J,t")))
-   (clobber (match_scratch:CC 3 "=X,X,x,x,X"))]
+  [(set (match_operand:DI 0 "gpc_reg_operand" "=r,r,r,r,r,r")
+       (and:DI (match_operand:DI 1 "gpc_reg_operand" "%r,r,r,r,r,r")
+               (match_operand:DI 2 "and64_2_operand" "?r,S,T,K,J,t")))
+   (clobber (match_scratch:CC 3 "=X,X,X,x,x,X"))]
   "TARGET_POWERPC64"
   "@
    and %0,%1,%2
    rldic%B2 %0,%1,0,%S2
+   rlwinm %0,%1,0,%m2,%M2
    andi. %0,%1,%b2
    andis. %0,%1,%u2
    #"
-  [(set_attr "length" "4,4,4,4,8")])
+  [(set_attr "type" "*,*,*,compare,compare,*")
+   (set_attr "length" "4,4,4,4,4,8")])
 
 (define_split
   [(set (match_operand:DI 0 "gpc_reg_operand" "")
        (and:DI (rotate:DI (match_dup 0)
                           (match_dup 6))
                (match_dup 7)))]
-  "
 {
   build_mask64_2_operands (operands[2], &operands[4]);
-}")
+})
 
 (define_insn "*anddi3_internal2"
   [(set (match_operand:CC 0 "cc_reg_operand" "=x,x,x,x,x,?y,?y,??y,??y,?y")
                    (const_int 0)))
    (clobber (match_scratch:DI 3 "=r,r,r,r,r,r,r,r,r,r"))
    (clobber (match_scratch:CC 4 "=X,X,X,X,X,X,X,x,x,X"))]
-  "TARGET_POWERPC64"
+  "TARGET_64BIT"
   "@
    and. %3,%1,%2
    rldic%B2. %3,%1,0,%S2
    (set (match_operand:DI 0 "gpc_reg_operand" "=r,r,r,r,r,r,r,r,r,r")
        (and:DI (match_dup 1) (match_dup 2)))
    (clobber (match_scratch:CC 4 "=X,X,X,X,X,X,X,x,x,X"))]
-  "TARGET_POWERPC64"
+  "TARGET_64BIT"
   "@
    and. %0,%1,%2
    rldic%B2. %0,%1,0,%S2
          (match_operand:DI 2 "gpc_reg_operand" "r,r")])
         (const_int 0)))
    (clobber (match_scratch:DI 3 "=r,r"))]
-  "TARGET_POWERPC64"
+  "TARGET_64BIT"
   "@
    %q4. %3,%1,%2
    #"
         (const_int 0)))
    (set (match_operand:DI 0 "gpc_reg_operand" "=r,r")
        (match_dup 4))]
-  "TARGET_POWERPC64"
+  "TARGET_64BIT"
   "@
    %q4. %0,%1,%2
    #"
                    (const_int 0)))]
   "")
 
-;; Split a logical operation that we can't do in one insn into two insns, 
+;; Split a logical operation that we can't do in one insn into two insns,
 ;; each of which does one 16-bit part.  This is used by combine.
 
 (define_split
 "
 {
   rtx i3,i4;
-  
+
   if (GET_CODE (operands[2]) == CONST_DOUBLE)
     {
       HOST_WIDE_INT value = CONST_DOUBLE_LOW (operands[2]);
                             & (~ (HOST_WIDE_INT) 0xffff));
       i4 = GEN_INT (INTVAL (operands[2]) & 0xffff);
     }
-  operands[4] = gen_rtx (GET_CODE (operands[3]), DImode,
-                        operands[1], i3);
-  operands[5] = gen_rtx (GET_CODE (operands[3]), DImode,
-                        operands[0], i4);
+  operands[4] = gen_rtx_fmt_ee (GET_CODE (operands[3]), DImode,
+                               operands[1], i3);
+  operands[5] = gen_rtx_fmt_ee (GET_CODE (operands[3]), DImode,
+                               operands[0], i4);
 }")
 
 (define_insn "*boolcdi3_internal1"
          (match_operand:DI 2 "gpc_reg_operand" "r,r")])
         (const_int 0)))
    (clobber (match_scratch:DI 3 "=r,r"))]
-  "TARGET_POWERPC64"
+  "TARGET_64BIT"
   "@
    %q4. %3,%2,%1
    #"
         (const_int 0)))
    (set (match_operand:DI 0 "gpc_reg_operand" "=r,r")
        (match_dup 4))]
-  "TARGET_POWERPC64"
+  "TARGET_64BIT"
   "@
    %q4. %0,%2,%1
    #"
          (not:DI (match_operand:DI 2 "gpc_reg_operand" "r,r"))])
         (const_int 0)))
    (clobber (match_scratch:DI 3 "=r,r"))]
-  "TARGET_POWERPC64"
+  "TARGET_64BIT"
   "@
    %q4. %3,%1,%2
    #"
         (const_int 0)))
    (set (match_operand:DI 0 "gpc_reg_operand" "=r,r")
        (match_dup 4))]
-  "TARGET_POWERPC64"
+  "TARGET_64BIT"
   "@
    %q4. %0,%1,%2
    #"
     {cal|la} %0,%2@l(%1)
     {ai|addic} %0,%1,%K2")
 
-;; Mach-O PIC trickery.
-(define_insn "macho_high"
-  [(set (match_operand:SI 0 "gpc_reg_operand" "=b*r")
-       (high:SI (match_operand 1 "" "")))]
-  "TARGET_MACHO && ! TARGET_64BIT"
-  "{liu|lis} %0,ha16(%1)")
-
-(define_insn "macho_low"
-  [(set (match_operand:SI 0 "gpc_reg_operand" "=r,r")
-       (lo_sum:SI (match_operand:SI 1 "gpc_reg_operand" "b,!*r")
-                  (match_operand 2 "" "")))]
-   "TARGET_MACHO && ! TARGET_64BIT"
-   "@
-    {cal %0,%a2@l(%1)|la %0,lo16(%2)(%1)}
-    {cal %0,%a2@l(%1)|addic %0,%1,lo16(%2)}")
 
 ;; Set up a register with a value from the GOT table
 
 
 ;; Used by sched, shorten_branches and final when the GOT pseudo reg
 ;; didn't get allocated to a hard register.
-(define_split 
+(define_split
   [(set (match_operand:SI 0 "gpc_reg_operand" "")
        (unspec:SI [(match_operand:SI 1 "got_no_const_operand" "")
                    (match_operand:SI 2 "memory_operand" "")]
   [(set_attr "type" "load")
    (set_attr "length" "4")])
 
-(define_insn "movsi_low_st"
-  [(set (mem:SI (lo_sum:SI (match_operand:SI 1 "gpc_reg_operand" "b")
-                           (match_operand 2 "" "")))
-       (match_operand:SI 0 "gpc_reg_operand" "r"))]
-  "TARGET_MACHO && ! TARGET_64BIT"
-  "{st|stw} %0,lo16(%2)(%1)"
-  [(set_attr "type" "store")
-   (set_attr "length" "4")])
-
-(define_insn "movdf_low"
-  [(set (match_operand:DF 0 "gpc_reg_operand" "=f,!r")
-        (mem:DF (lo_sum:SI (match_operand:SI 1 "gpc_reg_operand" "b,b")
-                           (match_operand 2 "" ""))))]
-  "TARGET_MACHO && TARGET_HARD_FLOAT && TARGET_FPRS && ! TARGET_64BIT"
-  "*
-{
-  switch (which_alternative)
-    {
-      case 0:
-       return \"lfd %0,lo16(%2)(%1)\";
-      case 1:
-       {
-         rtx operands2[4];
-         operands2[0] = operands[0];
-         operands2[1] = operands[1];
-         operands2[2] = operands[2];
-         operands2[3] = gen_rtx_REG (SImode, RS6000_PIC_OFFSET_TABLE_REGNUM);
-         output_asm_insn (\"{l|lwz} %0,lo16(%2)(%1)\", operands);
-#if TARGET_MACHO
-         if (MACHO_DYNAMIC_NO_PIC_P)
-           output_asm_insn (\"{liu|lis} %L0,ha16(%2+4)\", operands);
-         else
-         /* We cannot rely on ha16(low half)==ha16(high half), alas,
-            although in practice it almost always is.  */
-         output_asm_insn (\"{cau|addis} %L0,%3,ha16(%2+4)\", operands2);
-#endif
-         return (\"{l|lwz} %L0,lo16(%2+4)(%L0)\");
-       }
-      default:
-       abort();
-    }
-}"
-  [(set_attr "type" "load")
-   (set_attr "length" "4,12")])
-
-(define_insn "movdf_low_st"
-  [(set (mem:DF (lo_sum:SI (match_operand:SI 1 "gpc_reg_operand" "b")
-                           (match_operand 2 "" "")))
-       (match_operand:DF 0 "gpc_reg_operand" "f"))]
-  "TARGET_MACHO && TARGET_HARD_FLOAT && TARGET_FPRS && ! TARGET_64BIT"
-  "stfd %0,lo16(%2)(%1)"
-  [(set_attr "type" "store")
-   (set_attr "length" "4")])
-
-(define_insn "movsf_low"
-  [(set (match_operand:SF 0 "gpc_reg_operand" "=f,!r")
-        (mem:SF (lo_sum:SI (match_operand:SI 1 "gpc_reg_operand" "b,b")
-                           (match_operand 2 "" ""))))]
-  "TARGET_MACHO && TARGET_HARD_FLOAT && TARGET_FPRS && ! TARGET_64BIT"
-  "@
-   lfs %0,lo16(%2)(%1)
-   {l|lwz} %0,lo16(%2)(%1)"
-  [(set_attr "type" "load")
-   (set_attr "length" "4")])
-
-(define_insn "movsf_low_st"
-  [(set (mem:SF (lo_sum:SI (match_operand:SI 1 "gpc_reg_operand" "b,b")
-                           (match_operand 2 "" "")))
-       (match_operand:SF 0 "gpc_reg_operand" "f,!r"))]
-  "TARGET_MACHO && TARGET_HARD_FLOAT && TARGET_FPRS && ! TARGET_64BIT"
-  "@
-   stfs %0,lo16(%2)(%1)
-   {st|stw} %0,lo16(%2)(%1)"
-  [(set_attr "type" "store")
-   (set_attr "length" "4")])
-
 (define_insn "*movsi_internal1"
-  [(set (match_operand:SI 0 "nonimmediate_operand" "=r,r,r,m,r,r,r,r,r,*q,*c*l,*h,*h")
+  [(set (match_operand:SI 0 "rs6000_nonimmediate_operand" "=r,r,r,m,r,r,r,r,r,*q,*c*l,*h,*h")
        (match_operand:SI 1 "input_operand" "r,U,m,r,I,L,n,R,*h,r,r,r,0"))]
   "gpc_reg_operand (operands[0], SImode)
    || gpc_reg_operand (operands[1], SImode)"
        (compare:CC (match_operand:SI 1 "gpc_reg_operand" "0,r,r")
                    (const_int 0)))
    (set (match_operand:SI 0 "gpc_reg_operand" "=r,r,r") (match_dup 1))]
-  "! TARGET_POWERPC64"
+  "TARGET_32BIT"
   "@
    {cmpi|cmpwi} %2,%0,0
    mr. %0,%1
        (compare:CC (match_operand:SI 1 "gpc_reg_operand" "")
                    (const_int 0)))
    (set (match_operand:SI 0 "gpc_reg_operand" "") (match_dup 1))]
-  "! TARGET_POWERPC64 && reload_completed"
+  "TARGET_32BIT && reload_completed"
   [(set (match_dup 0) (match_dup 1))
    (set (match_dup 2)
        (compare:CC (match_dup 0)
 }")
 
 (define_insn "*movsf_hardfloat"
-  [(set (match_operand:SF 0 "nonimmediate_operand" "=!r,!r,m,f,f,m,!cl,!q,!r,!r,!r")
-       (match_operand:SF 1 "input_operand" "r,m,r,f,m,f,r,r,h,G,Fn"))]
+  [(set (match_operand:SF 0 "nonimmediate_operand" "=!r,!r,m,f,f,m,!cl,!q,!r,!h,!r,!r")
+       (match_operand:SF 1 "input_operand" "r,m,r,f,m,f,r,r,h,0,G,Fn"))]
   "(gpc_reg_operand (operands[0], SFmode)
    || gpc_reg_operand (operands[1], SFmode))
    && (TARGET_HARD_FLOAT && TARGET_FPRS)"
    mt%0 %1
    mt%0 %1
    mf%1 %0
+   {cror 0,0,0|nop}
    #
    #"
-  [(set_attr "type" "*,load,store,fp,fpload,fpstore,*,mtjmpr,*,*,*")
-   (set_attr "length" "4,4,4,4,4,4,4,4,4,4,8")])
+  [(set_attr "type" "*,load,store,fp,fpload,fpstore,*,mtjmpr,*,*,*,*")
+   (set_attr "length" "4,4,4,4,4,4,4,4,4,4,4,8")])
 
 (define_insn "*movsf_softfloat"
   [(set (match_operand:SF 0 "nonimmediate_operand" "=r,cl,q,r,r,m,r,r,r,r,r,*h")
       else
        return \"mr %0,%1\;mr %L0,%L1\";
     case 1:
-      if (offsettable_memref_p (operands[1])
-         || (GET_CODE (operands[1]) == MEM
-             && (GET_CODE (XEXP (operands[1], 0)) == LO_SUM
+      if (GET_CODE (operands[1]) == MEM
+         && (rs6000_legitimate_offset_address_p (DFmode, XEXP (operands[1], 0),
+                       reload_completed || reload_in_progress)
+             || GET_CODE (XEXP (operands[1], 0)) == REG
+             || GET_CODE (XEXP (operands[1], 0)) == LO_SUM
                  || GET_CODE (XEXP (operands[1], 0)) == PRE_INC
-                 || GET_CODE (XEXP (operands[1], 0)) == PRE_DEC)))
+             || GET_CODE (XEXP (operands[1], 0)) == PRE_DEC))
        {
          /* If the low-address word is used in the address, we must load
             it last.  Otherwise, load it first.  Note that we cannot have
            }
        }
     case 2:
-      if (offsettable_memref_p (operands[0])
-         || (GET_CODE (operands[0]) == MEM
-             && (GET_CODE (XEXP (operands[0], 0)) == LO_SUM
+      if (GET_CODE (operands[0]) == MEM
+          && (rs6000_legitimate_offset_address_p (DFmode, XEXP (operands[0], 0),
+                   reload_completed || reload_in_progress)
+             || GET_CODE (XEXP (operands[0], 0)) == REG
+             || GET_CODE (XEXP (operands[0], 0)) == LO_SUM
                  || GET_CODE (XEXP (operands[0], 0)) == PRE_INC
-                 || GET_CODE (XEXP (operands[0], 0)) == PRE_DEC)))
+             || GET_CODE (XEXP (operands[0], 0)) == PRE_DEC))
        return \"{st%U0|stw%U0} %1,%0\;{st|stw} %L1,%L0\";
       else
        {
       return \"#\";
     }
 }"
-  [(set_attr "type" "*,load,store,fp,fpload,fpstore,*,*,*")
+  [(set_attr "type" "two,load,store,fp,fpload,fpstore,*,*,*")
    (set_attr "length" "8,16,16,4,4,4,8,12,16")])
 
 (define_insn "*movdf_softfloat32"
   [(set (match_operand:DF 0 "nonimmediate_operand" "=r,r,m,r,r,r")
        (match_operand:DF 1 "input_operand" "r,m,r,G,H,F"))]
-  "! TARGET_POWERPC64 && (TARGET_SOFT_FLOAT || !TARGET_FPRS)
+  "! TARGET_POWERPC64 && (TARGET_SOFT_FLOAT || TARGET_E500_SINGLE)
    && (gpc_reg_operand (operands[0], DFmode)
        || gpc_reg_operand (operands[1], DFmode))"
   "*
       return \"#\";
     }
 }"
-  [(set_attr "type" "*,load,store,*,*,*")
+  [(set_attr "type" "two,load,store,*,*,*")
    (set_attr "length" "8,8,8,8,12,16")])
 
+; ld/std require word-aligned displacements -> 'Y' constraint.
+; List Y->r and r->Y before r->r for reload.
 (define_insn "*movdf_hardfloat64"
-  [(set (match_operand:DF 0 "nonimmediate_operand" "=!r,??r,m,f,f,m,!cl,!r,!r,!r,!r")
-       (match_operand:DF 1 "input_operand" "r,m,r,f,m,f,r,h,G,H,F"))]
+  [(set (match_operand:DF 0 "nonimmediate_operand" "=Y,r,!r,f,f,m,!cl,!r,!h,!r,!r,!r")
+       (match_operand:DF 1 "input_operand" "r,Y,r,f,m,f,r,h,0,G,H,F"))]
   "TARGET_POWERPC64 && TARGET_HARD_FLOAT && TARGET_FPRS
    && (gpc_reg_operand (operands[0], DFmode)
        || gpc_reg_operand (operands[1], DFmode))"
   "@
-   mr %0,%1
-   ld%U1%X1 %0,%1
    std%U0%X0 %1,%0
+   ld%U1%X1 %0,%1
+   mr %0,%1
    fmr %0,%1
    lfd%U1%X1 %0,%1
    stfd%U0%X0 %1,%0
    mt%0 %1
    mf%1 %0
+   {cror 0,0,0|nop}
    #
    #
    #"
-  [(set_attr "type" "*,load,store,fp,fpload,fpstore,mtjmpr,*,*,*,*")
-   (set_attr "length" "4,4,4,4,4,4,4,4,8,12,16")])
+  [(set_attr "type" "*,load,store,fp,fpload,fpstore,mtjmpr,*,*,*,*,*")
+   (set_attr "length" "4,4,4,4,4,4,4,4,4,8,12,16")])
 
 (define_insn "*movdf_softfloat64"
-  [(set (match_operand:DF 0 "nonimmediate_operand" "=r,cl,r,r,m,r,r,r")
-       (match_operand:DF 1 "input_operand" "r,r,h,m,r,G,H,F"))]
+  [(set (match_operand:DF 0 "nonimmediate_operand" "=r,Y,r,cl,r,r,r,r,*h")
+       (match_operand:DF 1 "input_operand" "Y,r,r,r,h,G,H,F,0"))]
   "TARGET_POWERPC64 && (TARGET_SOFT_FLOAT || !TARGET_FPRS)
    && (gpc_reg_operand (operands[0], DFmode)
        || gpc_reg_operand (operands[1], DFmode))"
   "@
+   ld%U1%X1 %0,%1
+   std%U0%X0 %1,%0
    mr %0,%1
    mt%0 %1
    mf%1 %0
-   ld%U1%X1 %0,%1
-   std%U0%X0 %1,%0
    #
    #
-   #"
-  [(set_attr "type" "*,*,*,load,store,*,*,*")
-   (set_attr "length" "4,4,4,4,4,8,12,16")])
+   #
+   {cror 0,0,0|nop}"
+  [(set_attr "type" "load,store,*,*,*,*,*,*,*")
+   (set_attr "length" "4,4,4,4,4,8,12,16,4")])
 \f
 (define_expand "movtf"
   [(set (match_operand:TF 0 "general_operand" "")
        (match_operand:TF 1 "any_operand" ""))]
-  "DEFAULT_ABI == ABI_AIX && TARGET_HARD_FLOAT && TARGET_FPRS
-   && TARGET_LONG_DOUBLE_128"
+  "(DEFAULT_ABI == ABI_AIX || DEFAULT_ABI == ABI_DARWIN)
+   && TARGET_HARD_FLOAT && TARGET_FPRS && TARGET_LONG_DOUBLE_128"
   "{ rs6000_emit_move (operands[0], operands[1], TFmode); DONE; }")
 
-(define_insn "*movtf_internal"
-  [(set (match_operand:TF 0 "nonimmediate_operand" "=f,f,m,!r,!r,!r")
-       (match_operand:TF 1 "input_operand" "f,m,f,G,H,F"))]
-  "DEFAULT_ABI == ABI_AIX && TARGET_HARD_FLOAT && TARGET_FPRS
-   && TARGET_LONG_DOUBLE_128
+; It's important to list the o->f and f->o moves before f->f because
+; otherwise reload, given m->f, will try to pick f->f and reload it,
+; which doesn't make progress.  Likewise r->Y must be before r->r.
+(define_insn_and_split "*movtf_internal"
+  [(set (match_operand:TF 0 "nonimmediate_operand" "=o,f,f,r,Y,r")
+       (match_operand:TF 1 "input_operand"         "f,o,f,YGHF,r,r"))]
+  "(DEFAULT_ABI == ABI_AIX || DEFAULT_ABI == ABI_DARWIN)
+   && TARGET_HARD_FLOAT && TARGET_FPRS && TARGET_LONG_DOUBLE_128
    && (gpc_reg_operand (operands[0], TFmode)
        || gpc_reg_operand (operands[1], TFmode))"
-  "*
+  "#"
+  "&& reload_completed"
+  [(pc)]
+{ rs6000_split_multireg_move (operands[0], operands[1]); DONE; }
+  [(set_attr "length" "8,8,8,20,20,16")])
+
+(define_expand "extenddftf2"
+  [(parallel [(set (match_operand:TF 0 "nonimmediate_operand" "")
+                  (float_extend:TF (match_operand:DF 1 "input_operand" "")))
+             (use (match_dup 2))])]
+  "(DEFAULT_ABI == ABI_AIX || DEFAULT_ABI == ABI_DARWIN)
+   && TARGET_HARD_FLOAT && TARGET_FPRS && TARGET_LONG_DOUBLE_128"
 {
-  switch (which_alternative)
-    {
-    default:
-      abort ();
-    case 0:
-      /* We normally copy the low-numbered register first.  However, if
-        the first register operand 0 is the same as the second register of
-        operand 1, we must copy in the opposite order.  */
-      if (REGNO (operands[0]) == REGNO (operands[1]) + 1)
-       return \"fmr %L0,%L1\;fmr %0,%1\";
-      else
-       return \"fmr %0,%1\;fmr %L0,%L1\";
-    case 1:
-      return \"lfd %0,%1\;lfd %L0,%Y1\";
-    case 2:
-      return \"stfd %1,%0\;stfd %L1,%Y0\";
-    case 3:
-    case 4:
-    case 5:
-      return \"#\";
-    }
-}"
-  [(set_attr "type" "fp,fpload,fpstore,*,*,*")
-   (set_attr "length" "8,8,8,12,16,20")])
+  operands[2] = CONST0_RTX (DFmode);
+})
 
-(define_split
-  [(set (match_operand:TF 0 "gpc_reg_operand" "")
-       (match_operand:TF 1 "easy_fp_constant" ""))]
+(define_insn_and_split "*extenddftf2_internal"
+  [(set (match_operand:TF 0 "nonimmediate_operand" "=o,f,&f,r")
+       (float_extend:TF (match_operand:DF 1 "input_operand" "fr,mf,mf,rmGHF")))
+   (use (match_operand:DF 2 "zero_reg_mem_operand" "rf,m,f,n"))]
   "(DEFAULT_ABI == ABI_AIX || DEFAULT_ABI == ABI_DARWIN)
-   && TARGET_HARD_FLOAT && TARGET_FPRS && ! TARGET_POWERPC64
-   && TARGET_LONG_DOUBLE_128 && reload_completed
-   && ((GET_CODE (operands[0]) == REG && REGNO (operands[0]) <= 31)
-       || (GET_CODE (operands[0]) == SUBREG
-          && GET_CODE (SUBREG_REG (operands[0])) == REG
-          && REGNO (SUBREG_REG (operands[0])) <= 31))"
-  [(set (match_dup 2) (match_dup 6))
-   (set (match_dup 3) (match_dup 7))
-   (set (match_dup 4) (match_dup 8))
-   (set (match_dup 5) (match_dup 9))]
-  "
+   && TARGET_HARD_FLOAT && TARGET_FPRS && TARGET_LONG_DOUBLE_128"
+  "#"
+  "&& reload_completed"
+  [(pc)]
 {
-  long l[4];
-  REAL_VALUE_TYPE rv;
-
-  REAL_VALUE_FROM_CONST_DOUBLE (rv, operands[1]);
-  REAL_VALUE_TO_TARGET_LONG_DOUBLE (rv, l);
-
-  operands[2] = operand_subword (operands[0], 0, 0, TFmode);
-  operands[3] = operand_subword (operands[0], 1, 0, TFmode);
-  operands[4] = operand_subword (operands[0], 2, 0, TFmode);
-  operands[5] = operand_subword (operands[0], 3, 0, TFmode);
-  operands[6] = gen_int_mode (l[0], SImode);
-  operands[7] = gen_int_mode (l[1], SImode);
-  operands[8] = gen_int_mode (l[2], SImode);
-  operands[9] = gen_int_mode (l[3], SImode);
-}")
+  const int lo_word = FLOAT_WORDS_BIG_ENDIAN ? GET_MODE_SIZE (DFmode) : 0;
+  const int hi_word = FLOAT_WORDS_BIG_ENDIAN ? 0 : GET_MODE_SIZE (DFmode);
+  emit_move_insn (simplify_gen_subreg (DFmode, operands[0], TFmode, hi_word),
+                 operands[1]);
+  emit_move_insn (simplify_gen_subreg (DFmode, operands[0], TFmode, lo_word),
+                 operands[2]);
+  DONE;
+})
 
-(define_split
-  [(set (match_operand:TF 0 "gpc_reg_operand" "")
-       (match_operand:TF 1 "easy_fp_constant" ""))]
+(define_expand "extendsftf2"
+  [(set (match_operand:TF 0 "nonimmediate_operand" "")
+       (float_extend:TF (match_operand:SF 1 "gpc_reg_operand" "")))]
   "(DEFAULT_ABI == ABI_AIX || DEFAULT_ABI == ABI_DARWIN)
-   && TARGET_HARD_FLOAT && TARGET_FPRS && TARGET_POWERPC64
-   && TARGET_LONG_DOUBLE_128 && reload_completed
-   && ((GET_CODE (operands[0]) == REG && REGNO (operands[0]) <= 31)
-       || (GET_CODE (operands[0]) == SUBREG
-          && GET_CODE (SUBREG_REG (operands[0])) == REG
-          && REGNO (SUBREG_REG (operands[0])) <= 31))"
-  [(set (match_dup 2) (match_dup 4))
-   (set (match_dup 3) (match_dup 5))]
-  "
+   && TARGET_HARD_FLOAT && TARGET_FPRS && TARGET_LONG_DOUBLE_128"
 {
-  long l[4];
-  REAL_VALUE_TYPE rv;
-#if HOST_BITS_PER_WIDE_INT >= 64
-  HOST_WIDE_INT val;
-#endif
-
-  REAL_VALUE_FROM_CONST_DOUBLE (rv, operands[1]);
-  REAL_VALUE_TO_TARGET_LONG_DOUBLE (rv, l);
-
-  operands[2] = gen_lowpart (DImode, operands[0]);
-  operands[3] = gen_highpart (DImode, operands[0]);
-#if HOST_BITS_PER_WIDE_INT >= 64
-  val = ((HOST_WIDE_INT)(unsigned long)l[0] << 32
-         | ((HOST_WIDE_INT)(unsigned long)l[1]));
-  operands[4] = gen_int_mode (val, DImode);
-
-  val = ((HOST_WIDE_INT)(unsigned long)l[2] << 32
-         | ((HOST_WIDE_INT)(unsigned long)l[3]));
-  operands[5] = gen_int_mode (val, DImode);
-#else
-  operands[4] = immed_double_const (l[1], l[0], DImode);
-  operands[5] = immed_double_const (l[3], l[2], DImode);
-#endif
-}")
+  rtx tmp = gen_reg_rtx (DFmode);
+  emit_insn (gen_extendsfdf2 (tmp, operands[1]));
+  emit_insn (gen_extenddftf2 (operands[0], tmp));
+  DONE;
+})
 
-(define_insn "extenddftf2"
-  [(set (match_operand:TF 0 "gpc_reg_operand" "=f")
-       (float_extend:TF (match_operand:DF 1 "gpc_reg_operand" "f")))]
-  "DEFAULT_ABI == ABI_AIX && TARGET_HARD_FLOAT && TARGET_FPRS
-   && TARGET_LONG_DOUBLE_128"
-  "*
-{
-  if (REGNO (operands[0]) == REGNO (operands[1]))
-    return \"fsub %L0,%L0,%L0\";
-  else
-    return \"fmr %0,%1\;fsub %L0,%L0,%L0\";
-}"
-  [(set_attr "type" "fp")])
+(define_expand "trunctfdf2"
+  [(set (match_operand:DF 0 "gpc_reg_operand" "")
+       (float_truncate:DF (match_operand:TF 1 "gpc_reg_operand" "")))]
+  "(DEFAULT_ABI == ABI_AIX || DEFAULT_ABI == ABI_DARWIN)
+   && TARGET_HARD_FLOAT && TARGET_FPRS && TARGET_LONG_DOUBLE_128"
+  "")
 
-(define_insn "extendsftf2"
-  [(set (match_operand:TF 0 "gpc_reg_operand" "=f")
-       (float_extend:TF (match_operand:SF 1 "gpc_reg_operand" "f")))]
-  "DEFAULT_ABI == ABI_AIX && TARGET_HARD_FLOAT && TARGET_FPRS
-   && TARGET_LONG_DOUBLE_128"
-  "*
+(define_insn_and_split "trunctfdf2_internal1"
+  [(set (match_operand:DF 0 "gpc_reg_operand" "=f,?f")
+       (float_truncate:DF (match_operand:TF 1 "gpc_reg_operand" "0,f")))]
+  "(DEFAULT_ABI == ABI_AIX || DEFAULT_ABI == ABI_DARWIN) && !TARGET_XL_COMPAT
+   && TARGET_HARD_FLOAT && TARGET_FPRS && TARGET_LONG_DOUBLE_128"
+  "@
+   #
+   fmr %0,%1"
+  "&& reload_completed && REGNO (operands[0]) == REGNO (operands[1])"
+  [(const_int 0)]
 {
-  if (REGNO (operands[0]) == REGNO (operands[1]))
-    return \"fsub %L0,%L0,%L0\";
-  else
-    return \"fmr %0,%1\;fsub %L0,%L0,%L0\";
-}"
+  emit_note (NOTE_INSN_DELETED);
+  DONE;
+}
   [(set_attr "type" "fp")])
 
-(define_insn "trunctfdf2"
+(define_insn "trunctfdf2_internal2"
   [(set (match_operand:DF 0 "gpc_reg_operand" "=f")
        (float_truncate:DF (match_operand:TF 1 "gpc_reg_operand" "f")))]
-  "DEFAULT_ABI == ABI_AIX && TARGET_HARD_FLOAT && TARGET_FPRS
-   && TARGET_LONG_DOUBLE_128"
+  "(DEFAULT_ABI == ABI_AIX || DEFAULT_ABI == ABI_DARWIN) && TARGET_XL_COMPAT
+   && TARGET_HARD_FLOAT && TARGET_FPRS && TARGET_LONG_DOUBLE_128"
   "fadd %0,%1,%L1"
-  [(set_attr "type" "fp")
-   (set_attr "length" "8")])
+  [(set_attr "type" "fp")])
 
 (define_insn_and_split "trunctfsf2"
   [(set (match_operand:SF 0 "gpc_reg_operand" "=f")
        (float_truncate:SF (match_operand:TF 1 "gpc_reg_operand" "f")))
    (clobber (match_scratch:DF 2 "=f"))]
-  "DEFAULT_ABI == ABI_AIX && TARGET_HARD_FLOAT
-   && TARGET_FPRS && TARGET_LONG_DOUBLE_128"
+  "(DEFAULT_ABI == ABI_AIX || DEFAULT_ABI == ABI_DARWIN)
+   && TARGET_HARD_FLOAT && TARGET_FPRS && TARGET_LONG_DOUBLE_128"
   "#"
   "&& reload_completed"
   [(set (match_dup 2)
        (float_truncate:SF (match_dup 2)))]
   "")
 
-(define_insn_and_split "floatditf2"
+(define_expand "floatsitf2"
   [(set (match_operand:TF 0 "gpc_reg_operand" "=f")
-        (float:TF (match_operand:DI 1 "gpc_reg_operand" "*f")))
-   (clobber (match_scratch:DF 2 "=f"))]
-  "DEFAULT_ABI == ABI_AIX && TARGET_POWERPC64
+        (float:TF (match_operand:SI 1 "gpc_reg_operand" "r")))]
+  "(DEFAULT_ABI == ABI_AIX || DEFAULT_ABI == ABI_DARWIN)
    && TARGET_HARD_FLOAT && TARGET_FPRS && TARGET_LONG_DOUBLE_128"
-  "#"
-  "&& reload_completed"
-  [(set (match_dup 2)
-       (float:DF (match_dup 1)))
-   (set (match_dup 0)
-       (float_extend:TF (match_dup 2)))]
-  "")
-
-(define_insn_and_split "floatsitf2"
-  [(set (match_operand:TF 0 "gpc_reg_operand" "=f")
-        (float:TF (match_operand:SI 1 "gpc_reg_operand" "r")))
-   (clobber (match_scratch:DF 2 "=f"))]
-  "DEFAULT_ABI == ABI_AIX && TARGET_HARD_FLOAT && TARGET_FPRS
-   && TARGET_LONG_DOUBLE_128"
-  "#"
-  "&& reload_completed"
-  [(set (match_dup 2)
-       (float:DF (match_dup 1)))
-   (set (match_dup 0)
-       (float_extend:TF (match_dup 2)))]
-  "")
+{
+  rtx tmp = gen_reg_rtx (DFmode);
+  expand_float (tmp, operands[1], false);
+  emit_insn (gen_extenddftf2 (operands[0], tmp));
+  DONE;
+})
 
-(define_insn_and_split "fix_trunctfdi2"
-  [(set (match_operand:DI 0 "gpc_reg_operand" "=*f")
-        (fix:DI (match_operand:TF 1 "gpc_reg_operand" "f")))
-   (clobber (match_scratch:DF 2 "=f"))]
-  "DEFAULT_ABI == ABI_AIX && TARGET_POWERPC64
+; fadd, but rounding towards zero.
+; This is probably not the optimal code sequence.
+(define_insn "fix_trunc_helper"
+  [(set (match_operand:DF 0 "gpc_reg_operand" "=f")
+       (unspec:DF [(match_operand:TF 1 "gpc_reg_operand" "f")]
+                  UNSPEC_FIX_TRUNC_TF))
+   (clobber (match_operand:DF 2 "gpc_reg_operand" "=&f"))]
+  "TARGET_HARD_FLOAT && TARGET_FPRS"
+  "mffs %2\n\tmtfsb1 31\n\tmtfsb0 30\n\tfadd %0,%1,%L1\n\tmtfsf 1,%2"
+  [(set_attr "type" "fp")
+   (set_attr "length" "20")])
+
+(define_expand "fix_trunctfsi2"
+  [(parallel [(set (match_operand:SI 0 "gpc_reg_operand" "")
+                  (fix:SI (match_operand:TF 1 "gpc_reg_operand" "")))
+             (clobber (match_dup 2))
+             (clobber (match_dup 3))
+             (clobber (match_dup 4))
+             (clobber (match_dup 5))])]
+  "(DEFAULT_ABI == ABI_AIX || DEFAULT_ABI == ABI_DARWIN)
+   && (TARGET_POWER2 || TARGET_POWERPC)
    && TARGET_HARD_FLOAT && TARGET_FPRS && TARGET_LONG_DOUBLE_128"
-  "#"
-  "&& reload_completed"
-  [(set (match_dup 2)
-       (float_truncate:DF (match_dup 1)))
-   (set (match_dup 0)
-       (fix:DI (match_dup 2)))]
-  "")
+{
+  operands[2] = gen_reg_rtx (DFmode);
+  operands[3] = gen_reg_rtx (DFmode);
+  operands[4] = gen_reg_rtx (DImode);
+  operands[5] = assign_stack_temp (DImode, GET_MODE_SIZE (DImode), 0);
+})
 
-(define_insn_and_split "fix_trunctfsi2"
+(define_insn_and_split "*fix_trunctfsi2_internal"
   [(set (match_operand:SI 0 "gpc_reg_operand" "=r")
         (fix:SI (match_operand:TF 1 "gpc_reg_operand" "f")))
-   (clobber (match_scratch:DF 2 "=f"))]
-  "DEFAULT_ABI == ABI_AIX && TARGET_HARD_FLOAT && TARGET_FPRS
-   && TARGET_LONG_DOUBLE_128"
+   (clobber (match_operand:DF 2 "gpc_reg_operand" "=f"))
+   (clobber (match_operand:DF 3 "gpc_reg_operand" "=&f"))
+   (clobber (match_operand:DI 4 "gpc_reg_operand" "=f"))
+   (clobber (match_operand:DI 5 "memory_operand" "=o"))]
+  "(DEFAULT_ABI == ABI_AIX || DEFAULT_ABI == ABI_DARWIN)
+   && TARGET_HARD_FLOAT && TARGET_FPRS && TARGET_LONG_DOUBLE_128"
   "#"
   "&& reload_completed"
-  [(set (match_dup 2)
-       (float_truncate:DF (match_dup 1)))
-   (set (match_dup 0)
-       (fix:SI (match_dup 2)))]
-  "")
+  [(pc)]
+{
+  rtx lowword;
+  emit_insn (gen_fix_trunc_helper (operands[2], operands[1], operands[3]));
+
+  if (GET_CODE (operands[5]) != MEM)
+    abort();
+  lowword = XEXP (operands[5], 0);
+  if (WORDS_BIG_ENDIAN)
+    lowword = plus_constant (lowword, 4);
+
+  emit_insn (gen_fctiwz (operands[4], operands[2]));
+  emit_move_insn (operands[5], operands[4]);
+  emit_move_insn (operands[0], gen_rtx_MEM (SImode, lowword));
+  DONE;
+})
 
 (define_insn "negtf2"
   [(set (match_operand:TF 0 "gpc_reg_operand" "=f")
        (neg:TF (match_operand:TF 1 "gpc_reg_operand" "f")))]
-  "DEFAULT_ABI == ABI_AIX && TARGET_HARD_FLOAT && TARGET_FPRS
-   && TARGET_LONG_DOUBLE_128"
+  "(DEFAULT_ABI == ABI_AIX || DEFAULT_ABI == ABI_DARWIN)
+   && TARGET_HARD_FLOAT && TARGET_FPRS && TARGET_LONG_DOUBLE_128"
   "*
 {
   if (REGNO (operands[0]) == REGNO (operands[1]) + 1)
   [(set_attr "type" "fp")
    (set_attr "length" "8")])
 
-(define_insn "abstf2"
+(define_expand "abstf2"
   [(set (match_operand:TF 0 "gpc_reg_operand" "=f")
        (abs:TF (match_operand:TF 1 "gpc_reg_operand" "f")))]
-  "DEFAULT_ABI == ABI_AIX && TARGET_HARD_FLOAT && TARGET_FPRS
-   && TARGET_LONG_DOUBLE_128"
-  "*
+  "(DEFAULT_ABI == ABI_AIX || DEFAULT_ABI == ABI_DARWIN)
+   && TARGET_HARD_FLOAT && TARGET_FPRS && TARGET_LONG_DOUBLE_128"
+  "
 {
-  if (REGNO (operands[0]) == REGNO (operands[1]) + 1)
-    return \"fabs %L0,%L1\;fabs %0,%1\";
-  else
-    return \"fabs %0,%1\;fabs %L0,%L1\";
-}"
-  [(set_attr "type" "fp")
-   (set_attr "length" "8")])
+  rtx label = gen_label_rtx ();
+  emit_insn (gen_abstf2_internal (operands[0], operands[1], label));
+  emit_label (label);
+  DONE;
+}")
 
-(define_insn ""
+(define_expand "abstf2_internal"
   [(set (match_operand:TF 0 "gpc_reg_operand" "=f")
-       (neg:TF (abs:TF (match_operand:TF 1 "gpc_reg_operand" "f"))))]
-  "DEFAULT_ABI == ABI_AIX && TARGET_HARD_FLOAT && TARGET_FPRS
-   && TARGET_LONG_DOUBLE_128"
-  "*
+       (match_operand:TF 1 "gpc_reg_operand" "f"))
+   (set (match_dup 3) (match_dup 5))
+   (set (match_dup 5) (abs:DF (match_dup 5)))
+   (set (match_dup 4) (compare:CCFP (match_dup 3) (match_dup 5)))
+   (set (pc) (if_then_else (eq (match_dup 4) (const_int 0))
+                          (label_ref (match_operand 2 "" ""))
+                          (pc)))
+   (set (match_dup 6) (neg:DF (match_dup 6)))]
+  "(DEFAULT_ABI == ABI_AIX || DEFAULT_ABI == ABI_DARWIN)
+   && TARGET_HARD_FLOAT && TARGET_FPRS && TARGET_LONG_DOUBLE_128"
+  "
 {
-  if (REGNO (operands[0]) == REGNO (operands[1]) + 1)
-    return \"fnabs %L0,%L1\;fnabs %0,%1\";
-  else
-    return \"fnabs %0,%1\;fnabs %L0,%L1\";
-}"
-  [(set_attr "type" "fp")
-   (set_attr "length" "8")])
+  const int hi_word = FLOAT_WORDS_BIG_ENDIAN ? 0 : GET_MODE_SIZE (DFmode);
+  const int lo_word = FLOAT_WORDS_BIG_ENDIAN ? GET_MODE_SIZE (DFmode) : 0;
+  operands[3] = gen_reg_rtx (DFmode);
+  operands[4] = gen_reg_rtx (CCFPmode);
+  operands[5] = simplify_gen_subreg (DFmode, operands[0], TFmode, hi_word);
+  operands[6] = simplify_gen_subreg (DFmode, operands[0], TFmode, lo_word);
+}")
 \f
 ;; Next come the multi-word integer load and store and the load and store
 ;; multiple insns.
   ""
   "{ rs6000_emit_move (operands[0], operands[1], DImode); DONE; }")
 
+; List r->r after r->"o<>", otherwise reload will try to reload a
+; non-offsettable address by using r->r which won't make progress.
 (define_insn "*movdi_internal32"
-  [(set (match_operand:DI 0 "nonimmediate_operand" "=r,r,m,f,f,m,r,r,r,r,r")
-       (match_operand:DI 1 "input_operand" "r,m,r,f,m,f,IJK,n,G,H,F"))]
+  [(set (match_operand:DI 0 "nonimmediate_operand" "=o<>,r,r,*f,*f,m,r")
+       (match_operand:DI 1 "input_operand" "r,r,m,f,m,f,IJKnGHF"))]
   "! TARGET_POWERPC64
    && (gpc_reg_operand (operands[0], DImode)
        || gpc_reg_operand (operands[1], DImode))"
-  "*
-{
-  switch (which_alternative)
-    {
-    default:
-      abort ();
-    case 0:
-      /* We normally copy the low-numbered register first.  However, if
-        the first register operand 0 is the same as the second register of
-        operand 1, we must copy in the opposite order.  */
-      if (REGNO (operands[0]) == REGNO (operands[1]) + 1)
-       return \"mr %L0,%L1\;mr %0,%1\";
-      else
-       return \"mr %0,%1\;mr %L0,%L1\";
-    case 1:
-      /* If the low-address word is used in the address, we must load it
-        last.  Otherwise, load it first.  Note that we cannot have
-        auto-increment in that case since the address register is known to be
-        dead.  */
-      if (refers_to_regno_p (REGNO (operands[0]), REGNO (operands[0]) + 1,
-                            operands[1], 0))
-       return \"{l|lwz} %L0,%L1\;{l|lwz} %0,%1\";
-      else
-       return \"{l%U1|lwz%U1} %0,%1\;{l|lwz} %L0,%L1\";
-    case 2:
-      return \"{st%U0|stw%U0} %1,%0\;{st|stw} %L1,%L0\";
-    case 3:
-      return \"fmr %0,%1\";
-    case 4:
-      return \"lfd%U1%X1 %0,%1\";
-    case 5:
-      return \"stfd%U0%X0 %1,%0\";
-    case 6:
-    case 7:
-    case 8:
-    case 9:
-    case 10:
-      return \"#\";
-    }
-}"
-  [(set_attr "type" "*,load,store,fp,fpload,fpstore,*,*,*,*,*")
-   (set_attr "length" "8,8,8,4,4,4,8,12,8,12,16")])
+  "@
+   #
+   #
+   #
+   fmr %0,%1
+   lfd%U1%X1 %0,%1
+   stfd%U0%X0 %1,%0
+   #"
+  [(set_attr "type" "load,*,store,fp,fpload,fpstore,*")])
 
 (define_split
   [(set (match_operand:DI 0 "gpc_reg_operand" "")
 }")
 
 (define_split
-  [(set (match_operand:DI 0 "gpc_reg_operand" "")
-       (match_operand:DI 1 "const_double_operand" ""))]
-  "HOST_BITS_PER_WIDE_INT == 32 && ! TARGET_POWERPC64 && reload_completed"
-  [(set (match_dup 2) (match_dup 4))
-   (set (match_dup 3) (match_dup 5))]
-  "
-{
-  operands[2] = operand_subword_force (operands[0], WORDS_BIG_ENDIAN == 0,
-                                      DImode);
-  operands[3] = operand_subword_force (operands[0], WORDS_BIG_ENDIAN != 0,
-                                      DImode);
-  operands[4] = GEN_INT (CONST_DOUBLE_HIGH (operands[1]));
-  operands[5] = GEN_INT (CONST_DOUBLE_LOW  (operands[1]));
-}")
-
-(define_split
-  [(set (match_operand:TI 0 "gpc_reg_operand" "")
-       (match_operand:TI 1 "const_double_operand" ""))]
-  "TARGET_POWERPC64"
-  [(set (match_dup 2) (match_dup 4))
-   (set (match_dup 3) (match_dup 5))]
-  "
-{
-  operands[2] = operand_subword_force (operands[0], WORDS_BIG_ENDIAN == 0,
-                                      TImode);
-  operands[3] = operand_subword_force (operands[0], WORDS_BIG_ENDIAN != 0,
-                                      TImode);
-  if (GET_CODE (operands[1]) == CONST_DOUBLE)
-    {
-      operands[4] = GEN_INT (CONST_DOUBLE_HIGH (operands[1]));
-      operands[5] = GEN_INT (CONST_DOUBLE_LOW (operands[1]));
-    }
-  else if (GET_CODE (operands[1]) == CONST_INT)
-    {
-      operands[4] = GEN_INT (- (INTVAL (operands[1]) < 0));
-      operands[5] = operands[1];
-    }
-  else
-    FAIL;
-}")
+  [(set (match_operand:DI 0 "nonimmediate_operand" "")
+        (match_operand:DI 1 "input_operand" ""))]
+  "reload_completed && !TARGET_POWERPC64
+   && gpr_or_gpr_p (operands[0], operands[1])"
+  [(pc)]
+{ rs6000_split_multireg_move (operands[0], operands[1]); DONE; })
 
 (define_insn "*movdi_internal64"
-  [(set (match_operand:DI 0 "nonimmediate_operand" "=r,r,m,r,r,r,r,?f,f,m,r,*h,*h")
+  [(set (match_operand:DI 0 "nonimmediate_operand" "=r,r,m,r,r,r,r,*f,*f,m,r,*h,*h")
        (match_operand:DI 1 "input_operand" "r,m,r,I,L,nF,R,f,m,f,*h,r,0"))]
   "TARGET_POWERPC64
    && (gpc_reg_operand (operands[0], DImode)
        (compare:CC (match_operand:DI 1 "gpc_reg_operand" "0,r,r")
                    (const_int 0)))
    (set (match_operand:DI 0 "gpc_reg_operand" "=r,r,r") (match_dup 1))]
-  "TARGET_POWERPC64"
+  "TARGET_64BIT"
   "@
    cmpdi %2,%0,0
    mr. %0,%1
   [(parallel [(set (match_operand:TI 0 "general_operand" "")
                   (match_operand:TI 1 "general_operand" ""))
              (clobber (scratch:SI))])]
-  "TARGET_STRING || TARGET_POWERPC64"
+  ""
   "{ rs6000_emit_move (operands[0], operands[1], TImode); DONE; }")
 
 ;; We say that MQ is clobbered in the last alternative because the first
 ;; while the 2nd alternative would not.  We put memory cases first so they
 ;; are preferred.  Otherwise, we'd try to reload the output instead of
 ;; giving the SCRATCH mq.
+
 (define_insn "*movti_power"
-  [(set (match_operand:TI 0 "reg_or_mem_operand" "=Q,m,????r,????r,????r")
-       (match_operand:TI 1 "reg_or_mem_operand" "r,r,r,Q,m"))
-   (clobber (match_scratch:SI 2 "=q,q#X,X,X,X"))]
-  "TARGET_STRING && TARGET_POWER && ! TARGET_POWERPC64
+  [(set (match_operand:TI 0 "reg_or_mem_operand" "=Q,m,????r,????r,????r,r")
+       (match_operand:TI 1 "input_operand" "r,r,r,Q,m,n"))
+   (clobber (match_scratch:SI 2 "=q,q#X,X,X,X,X"))]
+  "TARGET_POWER && ! TARGET_POWERPC64
    && (gpc_reg_operand (operands[0], TImode) || gpc_reg_operand (operands[1], TImode))"
   "*
 {
       abort ();
 
     case 0:
-      return \"{stsi|stswi} %1,%P0,16\";
+      if (TARGET_STRING)
+        return \"{stsi|stswi} %1,%P0,16\";
     case 1:
-      return \"{st%U0|stw%U0} %1,%0\;{st|stw} %L1,%L0\;{st|stw} %Y1,%Y0\;{st|stw} %Z1,%Z0\";
     case 2:
-      /* Normally copy registers with lowest numbered register copied first.
-        But copy in the other order if the first register of the output
-        is the second, third, or fourth register in the input.  */
-      if (REGNO (operands[0]) >= REGNO (operands[1]) + 1
-         && REGNO (operands[0]) <= REGNO (operands[1]) + 3)
-       return \"mr %Z0,%Z1\;mr %Y0,%Y1\;mr %L0,%L1\;mr %0,%1\";
-      else
-       return \"mr %0,%1\;mr %L0,%L1\;mr %Y0,%Y1\;mr %Z0,%Z1\";
+      return \"#\";
     case 3:
       /* If the address is not used in the output, we can use lsi.  Otherwise,
         fall through to generating four loads.  */
-      if (! reg_overlap_mentioned_p (operands[0], operands[1]))
+      if (TARGET_STRING
+         && ! reg_overlap_mentioned_p (operands[0], operands[1]))
        return \"{lsi|lswi} %0,%P1,16\";
       /* ... fall through ...  */
     case 4:
-      /* If the address register is the same as the register for the lowest-
-        addressed word, load it last.  Similarly for the next two words.
-        Otherwise load lowest address to highest.  */
-      if (refers_to_regno_p (REGNO (operands[0]), REGNO (operands[0]) + 1,
-                            operands[1], 0))
-       return \"{l|lwz} %L0,%L1\;{l|lwz} %Y0,%Y1\;{l|lwz} %Z0,%Z1\;{l|lwz} %0,%1\";
-      else if (refers_to_regno_p (REGNO (operands[0]) + 1,
-                                 REGNO (operands[0]) + 2, operands[1], 0))
-       return \"{l|lwz} %0,%1\;{l|lwz} %Y0,%Y1\;{l|lwz} %Z0,%Z1\;{l|lwz} %L0,%L1\";
-      else if (refers_to_regno_p (REGNO (operands[0]) + 2,
-                                 REGNO (operands[0]) + 3, operands[1], 0))
-       return \"{l|lwz} %0,%1\;{l|lwz} %L0,%L1\;{l|lwz} %Z0,%Z1\;{l|lwz} %Y0,%Y1\";
-      else
-       return \"{l%U1|lwz%U1} %0,%1\;{l|lwz} %L0,%L1\;{l|lwz} %Y0,%Y1\;{l|lwz} %Z0,%Z1\";
+    case 5:
+      return \"#\";
     }
 }"
-  [(set_attr "type" "store,store,*,load,load")
-   (set_attr "length" "4,16,16,4,16")])
+  [(set_attr "type" "store,store,*,load,load,*")])
 
 (define_insn "*movti_string"
-  [(set (match_operand:TI 0 "reg_or_mem_operand" "=Q,m,????r,????r,????r")
-       (match_operand:TI 1 "reg_or_mem_operand" "r,r,r,Q,m"))]
-  "TARGET_STRING && ! TARGET_POWER && ! TARGET_POWERPC64
+  [(set (match_operand:TI 0 "reg_or_mem_operand" "=Q,o<>,????r,????r,????r,r")
+       (match_operand:TI 1 "input_operand" "r,r,r,Q,m,n"))]
+  "! TARGET_POWER && ! TARGET_POWERPC64
    && (gpc_reg_operand (operands[0], TImode) || gpc_reg_operand (operands[1], TImode))"
   "*
 {
     {
     default:
       abort ();
-
     case 0:
-      return \"{stsi|stswi} %1,%P0,16\";
+      if (TARGET_STRING)
+        return \"{stsi|stswi} %1,%P0,16\";
     case 1:
-      return \"{st%U0|stw%U0} %1,%0\;{st|stw} %L1,%L0\;{st|stw} %Y1,%Y0\;{st|stw} %Z1,%Z0\";
     case 2:
-      /* Normally copy registers with lowest numbered register copied first.
-        But copy in the other order if the first register of the output
-        is the second, third, or fourth register in the input.  */
-      if (REGNO (operands[0]) >= REGNO (operands[1]) + 1
-         && REGNO (operands[0]) <= REGNO (operands[1]) + 3)
-       return \"mr %Z0,%Z1\;mr %Y0,%Y1\;mr %L0,%L1\;mr %0,%1\";
-      else
-       return \"mr %0,%1\;mr %L0,%L1\;mr %Y0,%Y1\;mr %Z0,%Z1\";
+      return \"#\";
     case 3:
       /* If the address is not used in the output, we can use lsi.  Otherwise,
         fall through to generating four loads.  */
-      if (! reg_overlap_mentioned_p (operands[0], operands[1]))
+      if (TARGET_STRING
+          && ! reg_overlap_mentioned_p (operands[0], operands[1]))
        return \"{lsi|lswi} %0,%P1,16\";
       /* ... fall through ...  */
     case 4:
-      /* If the address register is the same as the register for the lowest-
-        addressed word, load it last.  Similarly for the next two words.
-        Otherwise load lowest address to highest.  */
-      if (refers_to_regno_p (REGNO (operands[0]), REGNO (operands[0]) + 1,
-                            operands[1], 0))
-       return \"{l|lwz} %L0,%L1\;{l|lwz} %Y0,%Y1\;{l|lwz} %Z0,%Z1\;{l|lwz} %0,%1\";
-      else if (refers_to_regno_p (REGNO (operands[0]) + 1,
-                                 REGNO (operands[0]) + 2, operands[1], 0))
-       return \"{l|lwz} %0,%1\;{l|lwz} %Y0,%Y1\;{l|lwz} %Z0,%Z1\;{l|lwz} %L0,%L1\";
-      else if (refers_to_regno_p (REGNO (operands[0]) + 2,
-                                 REGNO (operands[0]) + 3, operands[1], 0))
-       return \"{l|lwz} %0,%1\;{l|lwz} %L0,%L1\;{l|lwz} %Z0,%Z1\;{l|lwz} %Y0,%Y1\";
-      else
-       return \"{l%U1|lwz%U1} %0,%1\;{l|lwz} %L0,%L1\;{l|lwz} %Y0,%Y1\;{l|lwz} %Z0,%Z1\";
+    case 5:
+      return \"#\";
     }
 }"
-  [(set_attr "type" "store,store,*,load,load")
-   (set_attr "length" "4,16,16,4,16")])
+  [(set_attr "type" "store,store,*,load,load,*")])
 
 (define_insn "*movti_ppc64"
-  [(set (match_operand:TI 0 "nonimmediate_operand" "=r,r,m")
-       (match_operand:TI 1 "input_operand" "r,m,r"))]
+  [(set (match_operand:TI 0 "nonimmediate_operand" "=r,o<>,r")
+       (match_operand:TI 1 "input_operand" "r,r,m"))]
   "TARGET_POWERPC64 && (gpc_reg_operand (operands[0], TImode)
    || gpc_reg_operand (operands[1], TImode))"
-  "*
+  "#"
+  [(set_attr "type" "*,load,store")])
+
+(define_split
+  [(set (match_operand:TI 0 "gpc_reg_operand" "")
+       (match_operand:TI 1 "const_double_operand" ""))]
+  "TARGET_POWERPC64"
+  [(set (match_dup 2) (match_dup 4))
+   (set (match_dup 3) (match_dup 5))]
+  "
 {
-  switch (which_alternative)
+  operands[2] = operand_subword_force (operands[0], WORDS_BIG_ENDIAN == 0,
+                                      TImode);
+  operands[3] = operand_subword_force (operands[0], WORDS_BIG_ENDIAN != 0,
+                                      TImode);
+  if (GET_CODE (operands[1]) == CONST_DOUBLE)
     {
-    default:
-      abort ();
-    case 0:
-      /* We normally copy the low-numbered register first.  However, if
-        the first register operand 0 is the same as the second register of
-        operand 1, we must copy in the opposite order.  */
-      if (REGNO (operands[0]) == REGNO (operands[1]) + 1)
-       return \"mr %L0,%L1\;mr %0,%1\";
-      else
-       return \"mr %0,%1\;mr %L0,%L1\";
-    case 1:
-      /* If the low-address word is used in the address, we must load it
-        last.  Otherwise, load it first.  Note that we cannot have
-        auto-increment in that case since the address register is known to be
-        dead.  */
-      if (refers_to_regno_p (REGNO (operands[0]), REGNO (operands[0]) + 1,
-                            operands[1], 0))
-       return \"ld %L0,%L1\;ld %0,%1\";
-      else
-       return \"ld%U1 %0,%1\;ld %L0,%L1\";
-    case 2:
-      return \"std%U0 %1,%0\;std %L1,%L0\";
+      operands[4] = GEN_INT (CONST_DOUBLE_HIGH (operands[1]));
+      operands[5] = GEN_INT (CONST_DOUBLE_LOW (operands[1]));
     }
-}"
-  [(set_attr "type" "*,load,store")
-   (set_attr "length" "8,8,8")])
+  else if (GET_CODE (operands[1]) == CONST_INT)
+    {
+      operands[4] = GEN_INT (- (INTVAL (operands[1]) < 0));
+      operands[5] = operands[1];
+    }
+  else
+    FAIL;
+}")
+
+(define_split
+  [(set (match_operand:TI 0 "nonimmediate_operand" "")
+        (match_operand:TI 1 "input_operand" ""))]
+  "reload_completed
+   && gpr_or_gpr_p (operands[0], operands[1])"
+  [(pc)]
+{ rs6000_split_multireg_move (operands[0], operands[1]); DONE; })
 \f
 (define_expand "load_multiple"
   [(match_par_dup 3 [(set (match_operand:SI 0 "" "")
   "{stsi|stswi} %2,%1,%O0"
   [(set_attr "type" "store")])
 \f
+(define_expand "clrmemsi"
+  [(parallel [(set (match_operand:BLK 0 "" "")
+                  (const_int 0))
+             (use (match_operand:SI 1 "" ""))
+             (use (match_operand:SI 2 "" ""))])]
+  ""
+  "
+{
+  if (expand_block_clear (operands))
+    DONE;
+  else
+    FAIL;
+}")
+
 ;; String/block move insn.
 ;; Argument 0 is the destination
 ;; Argument 1 is the source
 ;; Argument 2 is the length
 ;; Argument 3 is the alignment
 
-(define_expand "movstrsi"
+(define_expand "movmemsi"
   [(parallel [(set (match_operand:BLK 0 "" "")
                   (match_operand:BLK 1 "" ""))
              (use (match_operand:SI 2 "" ""))
 ;; Move up to 32 bytes at a time.  The fixed registers are needed because the
 ;; register allocator doesn't have a clue about allocating 8 word registers.
 ;; rD/rS = r5 is preferred, efficient form.
-(define_expand "movstrsi_8reg"
+(define_expand "movmemsi_8reg"
   [(parallel [(set (match_operand 0 "" "")
                   (match_operand 1 "" ""))
              (use (match_operand 2 "" ""))
 ;; Move up to 24 bytes at a time.  The fixed registers are needed because the
 ;; register allocator doesn't have a clue about allocating 6 word registers.
 ;; rD/rS = r5 is preferred, efficient form.
-(define_expand "movstrsi_6reg"
+(define_expand "movmemsi_6reg"
   [(parallel [(set (match_operand 0 "" "")
                   (match_operand 1 "" ""))
              (use (match_operand 2 "" ""))
 ;; Move up to 16 bytes at a time, using 4 fixed registers to avoid spill
 ;; problems with TImode.
 ;; rD/rS = r5 is preferred, efficient form.
-(define_expand "movstrsi_4reg"
+(define_expand "movmemsi_4reg"
   [(parallel [(set (match_operand 0 "" "")
                   (match_operand 1 "" ""))
              (use (match_operand 2 "" ""))
    (set_attr "length" "8")])
 
 ;; Move up to 8 bytes at a time.
-(define_expand "movstrsi_2reg"
+(define_expand "movmemsi_2reg"
   [(parallel [(set (match_operand 0 "" "")
                   (match_operand 1 "" ""))
              (use (match_operand 2 "" ""))
    (set_attr "length" "8")])
 
 ;; Move up to 4 bytes at a time.
-(define_expand "movstrsi_1reg"
+(define_expand "movmemsi_1reg"
   [(parallel [(set (match_operand 0 "" "")
                   (match_operand 1 "" ""))
              (use (match_operand 2 "" ""))
    ldu %3,%2(%0)"
   [(set_attr "type" "load_ux,load_u")])
 
-(define_insn "movdi_update"
-  [(set (mem:DI (plus:DI (match_operand:DI 1 "gpc_reg_operand" "0,0")
-                        (match_operand:DI 2 "reg_or_aligned_short_operand" "r,I")))
+(define_insn "movdi_<mode>_update"
+  [(set (mem:DI (plus:P (match_operand:P 1 "gpc_reg_operand" "0,0")
+                        (match_operand:P 2 "reg_or_aligned_short_operand" "r,I")))
        (match_operand:DI 3 "gpc_reg_operand" "r,r"))
-   (set (match_operand:DI 0 "gpc_reg_operand" "=b,b")
-       (plus:DI (match_dup 1) (match_dup 2)))]
+   (set (match_operand:P 0 "gpc_reg_operand" "=b,b")
+       (plus:P (match_dup 1) (match_dup 2)))]
   "TARGET_POWERPC64 && TARGET_UPDATE"
   "@
    stdux %3,%0,%2
 
 ;; Peephole to convert two consecutive FP loads or stores into lfq/stfq.
 
-(define_peephole
-  [(set (match_operand:DF 0 "gpc_reg_operand" "=f")
+(define_insn "*lfq_power2"
+  [(set (match_operand:TF 0 "gpc_reg_operand" "=f")
+       (match_operand:TF 1 "memory_operand" ""))]
+  "TARGET_POWER2
+   && TARGET_HARD_FLOAT && TARGET_FPRS"
+   "lfq%U1%X1 %0,%1")
+
+(define_peephole2
+  [(set (match_operand:DF 0 "gpc_reg_operand" "")
        (match_operand:DF 1 "memory_operand" ""))
-   (set (match_operand:DF 2 "gpc_reg_operand" "=f")
+   (set (match_operand:DF 2 "gpc_reg_operand" "")
        (match_operand:DF 3 "memory_operand" ""))]
   "TARGET_POWER2
    && TARGET_HARD_FLOAT && TARGET_FPRS
    && registers_ok_for_quad_peep (operands[0], operands[2])
-   && ! MEM_VOLATILE_P (operands[1]) && ! MEM_VOLATILE_P (operands[3])
-   && addrs_ok_for_quad_peep (XEXP (operands[1], 0), XEXP (operands[3], 0))"
-  "lfq%U1%X1 %0,%1")
+   && mems_ok_for_quad_peep (operands[1], operands[3])"
+  [(set (match_dup 0)
+        (match_dup 1))]
+  "operands[1] = widen_memory_access (operands[1], TFmode, 0);
+   operands[0] = gen_rtx_REG (TFmode, REGNO (operands[0]));")
 
-(define_peephole
+(define_insn "*stfq_power2"
+  [(set (match_operand:TF 0 "memory_operand" "")
+       (match_operand:TF 1 "gpc_reg_operand" "f"))]
+  "TARGET_POWER2
+   && TARGET_HARD_FLOAT && TARGET_FPRS"
+  "stfq%U0%X0 %1,%0")
+
+
+(define_peephole2
   [(set (match_operand:DF 0 "memory_operand" "")
-       (match_operand:DF 1 "gpc_reg_operand" "f"))
+       (match_operand:DF 1 "gpc_reg_operand" ""))
    (set (match_operand:DF 2 "memory_operand" "")
-       (match_operand:DF 3 "gpc_reg_operand" "f"))]
+       (match_operand:DF 3 "gpc_reg_operand" ""))]
   "TARGET_POWER2
    && TARGET_HARD_FLOAT && TARGET_FPRS
    && registers_ok_for_quad_peep (operands[1], operands[3])
-   && ! MEM_VOLATILE_P (operands[0]) && ! MEM_VOLATILE_P (operands[2])
-   && addrs_ok_for_quad_peep (XEXP (operands[0], 0), XEXP (operands[2], 0))"
-  "stfq%U0%X0 %1,%0")
+   && mems_ok_for_quad_peep (operands[0], operands[2])"
+  [(set (match_dup 0)
+       (match_dup 1))]
+  "operands[0] = widen_memory_access (operands[0], TFmode, 0);
+   operands[1] = gen_rtx_REG (TFmode, REGNO (operands[1]));")
+
+;; after inserting conditional returns we can sometimes have
+;; unnecessary register moves.  Unfortunately we cannot have a
+;; modeless peephole here, because some single SImode sets have early
+;; clobber outputs.  Although those sets expand to multi-ppc-insn
+;; sequences, using get_attr_length here will smash the operands
+;; array.  Neither is there an early_cobbler_p predicate.
+(define_peephole2
+  [(set (match_operand:DF 0 "gpc_reg_operand" "")
+       (match_operand:DF 1 "any_operand" ""))
+   (set (match_operand:DF 2 "gpc_reg_operand" "")
+       (match_dup 0))]
+  "peep2_reg_dead_p (2, operands[0])"
+  [(set (match_dup 2) (match_dup 1))])
+
+(define_peephole2
+  [(set (match_operand:SF 0 "gpc_reg_operand" "")
+       (match_operand:SF 1 "any_operand" ""))
+   (set (match_operand:SF 2 "gpc_reg_operand" "")
+       (match_dup 0))]
+  "peep2_reg_dead_p (2, operands[0])"
+  [(set (match_dup 2) (match_dup 1))])
+
 \f
 ;; TLS support.
 
 ;; "b" output constraint here and on tls_ld to support tls linker optimization.
 (define_insn "tls_gd_32"
-  [(set (match_operand:SI 0 "register_operand" "=b")
-       (unspec:SI [(match_operand:SI 1 "register_operand" "b")
+  [(set (match_operand:SI 0 "gpc_reg_operand" "=b")
+       (unspec:SI [(match_operand:SI 1 "gpc_reg_operand" "b")
                    (match_operand:SI 2 "rs6000_tls_symbol_ref" "")]
                   UNSPEC_TLSGD))]
   "HAVE_AS_TLS && !TARGET_64BIT"
   "addi %0,%1,%2@got@tlsgd")
 
 (define_insn "tls_gd_64"
-  [(set (match_operand:DI 0 "register_operand" "=b")
-       (unspec:DI [(match_operand:DI 1 "register_operand" "b")
+  [(set (match_operand:DI 0 "gpc_reg_operand" "=b")
+       (unspec:DI [(match_operand:DI 1 "gpc_reg_operand" "b")
                    (match_operand:DI 2 "rs6000_tls_symbol_ref" "")]
                   UNSPEC_TLSGD))]
   "HAVE_AS_TLS && TARGET_64BIT"
   "addi %0,%1,%2@got@tlsgd")
 
 (define_insn "tls_ld_32"
-  [(set (match_operand:SI 0 "register_operand" "=b")
-       (unspec:SI [(match_operand:SI 1 "register_operand" "b")]
+  [(set (match_operand:SI 0 "gpc_reg_operand" "=b")
+       (unspec:SI [(match_operand:SI 1 "gpc_reg_operand" "b")]
                   UNSPEC_TLSLD))]
   "HAVE_AS_TLS && !TARGET_64BIT"
   "addi %0,%1,%&@got@tlsld")
 
 (define_insn "tls_ld_64"
-  [(set (match_operand:DI 0 "register_operand" "=b")
-       (unspec:DI [(match_operand:DI 1 "register_operand" "b")]
+  [(set (match_operand:DI 0 "gpc_reg_operand" "=b")
+       (unspec:DI [(match_operand:DI 1 "gpc_reg_operand" "b")]
                   UNSPEC_TLSLD))]
   "HAVE_AS_TLS && TARGET_64BIT"
   "addi %0,%1,%&@got@tlsld")
 
 (define_insn "tls_dtprel_32"
-  [(set (match_operand:SI 0 "register_operand" "=r")
-       (unspec:SI [(match_operand:SI 1 "register_operand" "b")
+  [(set (match_operand:SI 0 "gpc_reg_operand" "=r")
+       (unspec:SI [(match_operand:SI 1 "gpc_reg_operand" "b")
                    (match_operand:SI 2 "rs6000_tls_symbol_ref" "")]
                   UNSPEC_TLSDTPREL))]
   "HAVE_AS_TLS && !TARGET_64BIT"
   "addi %0,%1,%2@dtprel")
 
 (define_insn "tls_dtprel_64"
-  [(set (match_operand:DI 0 "register_operand" "=r")
-       (unspec:DI [(match_operand:DI 1 "register_operand" "b")
+  [(set (match_operand:DI 0 "gpc_reg_operand" "=r")
+       (unspec:DI [(match_operand:DI 1 "gpc_reg_operand" "b")
                    (match_operand:DI 2 "rs6000_tls_symbol_ref" "")]
                   UNSPEC_TLSDTPREL))]
   "HAVE_AS_TLS && TARGET_64BIT"
   "addi %0,%1,%2@dtprel")
 
 (define_insn "tls_dtprel_ha_32"
-  [(set (match_operand:SI 0 "register_operand" "=r")
-       (unspec:SI [(match_operand:SI 1 "register_operand" "b")
+  [(set (match_operand:SI 0 "gpc_reg_operand" "=r")
+       (unspec:SI [(match_operand:SI 1 "gpc_reg_operand" "b")
                    (match_operand:SI 2 "rs6000_tls_symbol_ref" "")]
                   UNSPEC_TLSDTPRELHA))]
   "HAVE_AS_TLS && !TARGET_64BIT"
   "addis %0,%1,%2@dtprel@ha")
 
 (define_insn "tls_dtprel_ha_64"
-  [(set (match_operand:DI 0 "register_operand" "=r")
-       (unspec:DI [(match_operand:DI 1 "register_operand" "b")
+  [(set (match_operand:DI 0 "gpc_reg_operand" "=r")
+       (unspec:DI [(match_operand:DI 1 "gpc_reg_operand" "b")
                    (match_operand:DI 2 "rs6000_tls_symbol_ref" "")]
                   UNSPEC_TLSDTPRELHA))]
   "HAVE_AS_TLS && TARGET_64BIT"
   "addis %0,%1,%2@dtprel@ha")
 
 (define_insn "tls_dtprel_lo_32"
-  [(set (match_operand:SI 0 "register_operand" "=r")
-       (unspec:SI [(match_operand:SI 1 "register_operand" "b")
+  [(set (match_operand:SI 0 "gpc_reg_operand" "=r")
+       (unspec:SI [(match_operand:SI 1 "gpc_reg_operand" "b")
                    (match_operand:SI 2 "rs6000_tls_symbol_ref" "")]
                   UNSPEC_TLSDTPRELLO))]
   "HAVE_AS_TLS && !TARGET_64BIT"
   "addi %0,%1,%2@dtprel@l")
 
 (define_insn "tls_dtprel_lo_64"
-  [(set (match_operand:DI 0 "register_operand" "=r")
-       (unspec:DI [(match_operand:DI 1 "register_operand" "b")
+  [(set (match_operand:DI 0 "gpc_reg_operand" "=r")
+       (unspec:DI [(match_operand:DI 1 "gpc_reg_operand" "b")
                    (match_operand:DI 2 "rs6000_tls_symbol_ref" "")]
                   UNSPEC_TLSDTPRELLO))]
   "HAVE_AS_TLS && TARGET_64BIT"
   "addi %0,%1,%2@dtprel@l")
 
 (define_insn "tls_got_dtprel_32"
-  [(set (match_operand:SI 0 "register_operand" "=r")
-       (unspec:SI [(match_operand:SI 1 "register_operand" "b")
+  [(set (match_operand:SI 0 "gpc_reg_operand" "=r")
+       (unspec:SI [(match_operand:SI 1 "gpc_reg_operand" "b")
                    (match_operand:SI 2 "rs6000_tls_symbol_ref" "")]
                   UNSPEC_TLSGOTDTPREL))]
   "HAVE_AS_TLS && !TARGET_64BIT"
   "lwz %0,%2@got@dtprel(%1)")
 
 (define_insn "tls_got_dtprel_64"
-  [(set (match_operand:DI 0 "register_operand" "=r")
-       (unspec:DI [(match_operand:DI 1 "register_operand" "b")
+  [(set (match_operand:DI 0 "gpc_reg_operand" "=r")
+       (unspec:DI [(match_operand:DI 1 "gpc_reg_operand" "b")
                    (match_operand:DI 2 "rs6000_tls_symbol_ref" "")]
                   UNSPEC_TLSGOTDTPREL))]
   "HAVE_AS_TLS && TARGET_64BIT"
   "ld %0,%2@got@dtprel(%1)")
 
 (define_insn "tls_tprel_32"
-  [(set (match_operand:SI 0 "register_operand" "=r")
-       (unspec:SI [(match_operand:SI 1 "register_operand" "b")
+  [(set (match_operand:SI 0 "gpc_reg_operand" "=r")
+       (unspec:SI [(match_operand:SI 1 "gpc_reg_operand" "b")
                    (match_operand:SI 2 "rs6000_tls_symbol_ref" "")]
                   UNSPEC_TLSTPREL))]
   "HAVE_AS_TLS && !TARGET_64BIT"
   "addi %0,%1,%2@tprel")
 
 (define_insn "tls_tprel_64"
-  [(set (match_operand:DI 0 "register_operand" "=r")
-       (unspec:DI [(match_operand:DI 1 "register_operand" "b")
+  [(set (match_operand:DI 0 "gpc_reg_operand" "=r")
+       (unspec:DI [(match_operand:DI 1 "gpc_reg_operand" "b")
                    (match_operand:DI 2 "rs6000_tls_symbol_ref" "")]
                   UNSPEC_TLSTPREL))]
   "HAVE_AS_TLS && TARGET_64BIT"
   "addi %0,%1,%2@tprel")
 
 (define_insn "tls_tprel_ha_32"
-  [(set (match_operand:SI 0 "register_operand" "=r")
-       (unspec:SI [(match_operand:SI 1 "register_operand" "b")
+  [(set (match_operand:SI 0 "gpc_reg_operand" "=r")
+       (unspec:SI [(match_operand:SI 1 "gpc_reg_operand" "b")
                    (match_operand:SI 2 "rs6000_tls_symbol_ref" "")]
                   UNSPEC_TLSTPRELHA))]
   "HAVE_AS_TLS && !TARGET_64BIT"
   "addis %0,%1,%2@tprel@ha")
 
 (define_insn "tls_tprel_ha_64"
-  [(set (match_operand:DI 0 "register_operand" "=r")
-       (unspec:DI [(match_operand:DI 1 "register_operand" "b")
+  [(set (match_operand:DI 0 "gpc_reg_operand" "=r")
+       (unspec:DI [(match_operand:DI 1 "gpc_reg_operand" "b")
                    (match_operand:DI 2 "rs6000_tls_symbol_ref" "")]
                   UNSPEC_TLSTPRELHA))]
   "HAVE_AS_TLS && TARGET_64BIT"
   "addis %0,%1,%2@tprel@ha")
 
 (define_insn "tls_tprel_lo_32"
-  [(set (match_operand:SI 0 "register_operand" "=r")
-       (unspec:SI [(match_operand:SI 1 "register_operand" "b")
+  [(set (match_operand:SI 0 "gpc_reg_operand" "=r")
+       (unspec:SI [(match_operand:SI 1 "gpc_reg_operand" "b")
                    (match_operand:SI 2 "rs6000_tls_symbol_ref" "")]
                   UNSPEC_TLSTPRELLO))]
   "HAVE_AS_TLS && !TARGET_64BIT"
   "addi %0,%1,%2@tprel@l")
 
 (define_insn "tls_tprel_lo_64"
-  [(set (match_operand:DI 0 "register_operand" "=r")
-       (unspec:DI [(match_operand:DI 1 "register_operand" "b")
+  [(set (match_operand:DI 0 "gpc_reg_operand" "=r")
+       (unspec:DI [(match_operand:DI 1 "gpc_reg_operand" "b")
                    (match_operand:DI 2 "rs6000_tls_symbol_ref" "")]
                   UNSPEC_TLSTPRELLO))]
   "HAVE_AS_TLS && TARGET_64BIT"
 ;; optimization.  The linker may edit the instructions emitted by a
 ;; tls_got_tprel/tls_tls pair to addis,addi.
 (define_insn "tls_got_tprel_32"
-  [(set (match_operand:SI 0 "register_operand" "=b")
-       (unspec:SI [(match_operand:SI 1 "register_operand" "b")
+  [(set (match_operand:SI 0 "gpc_reg_operand" "=b")
+       (unspec:SI [(match_operand:SI 1 "gpc_reg_operand" "b")
                    (match_operand:SI 2 "rs6000_tls_symbol_ref" "")]
                   UNSPEC_TLSGOTTPREL))]
   "HAVE_AS_TLS && !TARGET_64BIT"
   "lwz %0,%2@got@tprel(%1)")
 
 (define_insn "tls_got_tprel_64"
-  [(set (match_operand:DI 0 "register_operand" "=b")
-       (unspec:DI [(match_operand:DI 1 "register_operand" "b")
+  [(set (match_operand:DI 0 "gpc_reg_operand" "=b")
+       (unspec:DI [(match_operand:DI 1 "gpc_reg_operand" "b")
                    (match_operand:DI 2 "rs6000_tls_symbol_ref" "")]
                   UNSPEC_TLSGOTTPREL))]
   "HAVE_AS_TLS && TARGET_64BIT"
   "ld %0,%2@got@tprel(%1)")
 
 (define_insn "tls_tls_32"
-  [(set (match_operand:SI 0 "register_operand" "=r")
-       (unspec:SI [(match_operand:SI 1 "register_operand" "b")
+  [(set (match_operand:SI 0 "gpc_reg_operand" "=r")
+       (unspec:SI [(match_operand:SI 1 "gpc_reg_operand" "b")
                    (match_operand:SI 2 "rs6000_tls_symbol_ref" "")]
                   UNSPEC_TLSTLS))]
   "HAVE_AS_TLS && !TARGET_64BIT"
   "add %0,%1,%2@tls")
 
 (define_insn "tls_tls_64"
-  [(set (match_operand:DI 0 "register_operand" "=r")
-       (unspec:DI [(match_operand:DI 1 "register_operand" "b")
+  [(set (match_operand:DI 0 "gpc_reg_operand" "=r")
+       (unspec:DI [(match_operand:DI 1 "gpc_reg_operand" "b")
                    (match_operand:DI 2 "rs6000_tls_symbol_ref" "")]
                   UNSPEC_TLSTLS))]
   "HAVE_AS_TLS && TARGET_64BIT"
   if (current_function_limit_stack)
     {
       rtx available;
-      available = expand_binop (Pmode, sub_optab, 
+      available = expand_binop (Pmode, sub_optab,
                                stack_pointer_rtx, stack_limit_rtx,
                                NULL_RTX, 1, OPTAB_WIDEN);
       emit_insn (gen_cond_trap (LTU, available, operands[1], const0_rtx));
     neg_op0 = GEN_INT (- INTVAL (operands[1]));
 
   if (TARGET_UPDATE)
-    emit_insn ((* ((TARGET_32BIT) ? gen_movsi_update : gen_movdi_update))
+    emit_insn ((* ((TARGET_32BIT) ? gen_movsi_update : gen_movdi_di_update))
                (stack_pointer_rtx, stack_pointer_rtx, neg_op0, chain));
 
   else
   "
 {
   rtx temp = gen_reg_rtx (Pmode);
+  int units_per_word = (TARGET_32BIT) ? 4 : 8;
 
   /* Copy the backchain to the first word, sp to the second.  */
   emit_move_insn (temp, gen_rtx_MEM (Pmode, operands[1]));
-  emit_move_insn (operand_subword (operands[0], 0, 0,
-                                  (TARGET_32BIT ? DImode : TImode)),
-                 temp);
-  emit_move_insn (operand_subword (operands[0], 1, 0, (TARGET_32BIT ? DImode : TImode)),
+  emit_move_insn (adjust_address_nv (operands[0], Pmode, 0), temp);
+  emit_move_insn (adjust_address_nv (operands[0], Pmode, units_per_word),
                  operands[1]);
   DONE;
 }")
   "
 {
   rtx temp = gen_reg_rtx (Pmode);
+  int units_per_word = (TARGET_32BIT) ? 4 : 8;
 
   /* Restore the backchain from the first word, sp from the second.  */
   emit_move_insn (temp,
-                 operand_subword (operands[1], 0, 0, (TARGET_32BIT ? DImode : TImode)));
+                 adjust_address_nv (operands[1], Pmode, 0));
   emit_move_insn (operands[0],
-                 operand_subword (operands[1], 1, 0,
-                                  (TARGET_32BIT ? DImode : TImode)));
+                 adjust_address_nv (operands[1], Pmode, units_per_word));
   emit_move_insn (gen_rtx_MEM (Pmode, operands[0]), temp);
   DONE;
 }")
   "{l|lwz} %0,%2-%3(%1)"
   [(set_attr "type" "load")])
 
-(define_insn "load_macho_picbase"
-  [(set (match_operand:SI 0 "register_operand" "=l")
-       (unspec:SI [(match_operand:SI 1 "immediate_operand" "s")]
-                  UNSPEC_LD_MPIC))]
-  "(DEFAULT_ABI == ABI_DARWIN) && flag_pic"
-  "bcl 20,31,%1\\n%1:"
-  [(set_attr "type" "branch")
-   (set_attr "length" "4")])
-
-(define_insn "macho_correct_pic"
-  [(set (match_operand:SI 0 "gpc_reg_operand" "=r")
-       (plus:SI (match_operand:SI 1 "gpc_reg_operand" "r")
-                (unspec:SI [(match_operand:SI 2 "immediate_operand" "s")
-                            (match_operand:SI 3 "immediate_operand" "s")]
-                           UNSPEC_MPIC_CORRECT)))]
-  "DEFAULT_ABI == ABI_DARWIN"
-  "addis %0,%1,ha16(%2-%3)\n\taddi %0,%0,lo16(%2-%3)"
-  [(set_attr "length" "8")])
 
 ;; If the TOC is shared over a translation unit, as happens with all
 ;; the kinds of PIC that we support, we need to restore the TOC
 
   if (GET_CODE (operands[0]) != SYMBOL_REF
       || (DEFAULT_ABI == ABI_AIX && !SYMBOL_REF_FUNCTION_P (operands[0]))
-      || (INTVAL (operands[2]) & CALL_LONG) != 0)
+      || (DEFAULT_ABI != ABI_DARWIN && (INTVAL (operands[2]) & CALL_LONG) != 0))
     {
       if (INTVAL (operands[2]) & CALL_LONG)
        operands[0] = rs6000_longcall_ref (operands[0]);
 
   if (GET_CODE (operands[1]) != SYMBOL_REF
       || (DEFAULT_ABI == ABI_AIX && !SYMBOL_REF_FUNCTION_P (operands[1]))
-      || (INTVAL (operands[3]) & CALL_LONG) != 0)
+      || (DEFAULT_ABI != ABI_DARWIN && (INTVAL (operands[3]) & CALL_LONG) != 0))
     {
       if (INTVAL (operands[3]) & CALL_LONG)
        operands[1] = rs6000_longcall_ref (operands[1]);
 
       if (DEFAULT_ABI == ABI_V4
          || DEFAULT_ABI == ABI_DARWIN)
-       operands[0] = force_reg (Pmode, operands[0]);
+       operands[1] = force_reg (Pmode, operands[1]);
 
       else if (DEFAULT_ABI == ABI_AIX)
        {
         (match_operand 1 "" "g"))
    (use (match_operand:SI 2 "immediate_operand" "O"))
    (clobber (match_scratch:SI 3 "=l"))]
-  "TARGET_64BIT 
+  "TARGET_64BIT
    && DEFAULT_ABI == ABI_AIX
    && (INTVAL (operands[2]) & CALL_LONG) == 0"
   "bl %z0\;%."
              (match_operand 2 "" "g")))
    (use (match_operand:SI 3 "immediate_operand" "O"))
    (clobber (match_scratch:SI 4 "=l"))]
-  "TARGET_64BIT 
+  "TARGET_64BIT
    && DEFAULT_ABI == ABI_AIX
    && (INTVAL (operands[3]) & CALL_LONG) == 0"
   "bl %z1\;%."
         (match_operand 1 "" "g,g"))
    (use (match_operand:SI 2 "immediate_operand" "O,n"))
    (clobber (match_scratch:SI 3 "=l,l"))]
-  "(DEFAULT_ABI == ABI_V4
-    || DEFAULT_ABI == ABI_DARWIN)
-   && (INTVAL (operands[2]) & CALL_LONG) == 0"
+  "(DEFAULT_ABI == ABI_DARWIN
+   || (DEFAULT_ABI == ABI_V4
+       && (INTVAL (operands[2]) & CALL_LONG) == 0))"
 {
   if (INTVAL (operands[2]) & CALL_V4_SET_FP_ARGS)
     output_asm_insn ("crxor 6,6,6", operands);
   else if (INTVAL (operands[2]) & CALL_V4_CLEAR_FP_ARGS)
     output_asm_insn ("creqv 6,6,6", operands);
 
+#if TARGET_MACHO
+  return output_call(insn, operands, 0, 2);
+#else
   return (DEFAULT_ABI == ABI_V4 && flag_pic) ? "bl %z0@plt" : "bl %z0";
+#endif
 }
   [(set_attr "type" "branch,branch")
    (set_attr "length" "4,8")])
              (match_operand 2 "" "g,g")))
    (use (match_operand:SI 3 "immediate_operand" "O,n"))
    (clobber (match_scratch:SI 4 "=l,l"))]
-  "(DEFAULT_ABI == ABI_V4
-    || DEFAULT_ABI == ABI_DARWIN)
-   && (INTVAL (operands[3]) & CALL_LONG) == 0"
+  "(DEFAULT_ABI == ABI_DARWIN
+   || (DEFAULT_ABI == ABI_V4
+       && (INTVAL (operands[3]) & CALL_LONG) == 0))"
 {
   if (INTVAL (operands[3]) & CALL_V4_SET_FP_ARGS)
     output_asm_insn ("crxor 6,6,6", operands);
   else if (INTVAL (operands[3]) & CALL_V4_CLEAR_FP_ARGS)
     output_asm_insn ("creqv 6,6,6", operands);
 
+#if TARGET_MACHO
+  return output_call(insn, operands, 1, 3);
+#else
   return (DEFAULT_ABI == ABI_V4 && flag_pic) ? "bl %z1@plt" : "bl %z1";
+#endif
 }
   [(set_attr "type" "branch,branch")
    (set_attr "length" "4,8")])
    (use (match_operand:SI 2 "immediate_operand" "O"))
    (use (match_operand:SI 3 "register_operand" "l"))
    (return)]
-  "TARGET_64BIT 
+  "TARGET_64BIT
    && DEFAULT_ABI == ABI_AIX
    && (INTVAL (operands[2]) & CALL_LONG) == 0"
   "b %z0"
    (use (match_operand:SI 3 "immediate_operand" "O"))
    (use (match_operand:SI 4 "register_operand" "l"))
    (return)]
-  "TARGET_64BIT 
+  "TARGET_64BIT
    && DEFAULT_ABI == ABI_AIX
    && (INTVAL (operands[3]) & CALL_LONG) == 0"
   "b %z1"
 (define_expand "cmpdf"
   [(set (cc0) (compare (match_operand:DF 0 "gpc_reg_operand" "")
                       (match_operand:DF 1 "gpc_reg_operand" "")))]
-  "TARGET_HARD_FLOAT && TARGET_FPRS"
+  "TARGET_HARD_FLOAT && (TARGET_FPRS || TARGET_E500_DOUBLE)"
   "
 {
   rs6000_compare_op0 = operands[0];
 (define_expand "cmptf"
   [(set (cc0) (compare (match_operand:TF 0 "gpc_reg_operand" "")
                       (match_operand:TF 1 "gpc_reg_operand" "")))]
-  "DEFAULT_ABI == ABI_AIX && TARGET_HARD_FLOAT
-   && TARGET_FPRS && TARGET_LONG_DOUBLE_128"
+  "(DEFAULT_ABI == ABI_AIX || DEFAULT_ABI == ABI_DARWIN)
+   && TARGET_HARD_FLOAT && TARGET_FPRS && TARGET_LONG_DOUBLE_128"
   "
 {
   rs6000_compare_op0 = operands[0];
 
 (define_expand "bunordered"
   [(use (match_operand 0 "" ""))]
-  ""
+  "! (TARGET_HARD_FLOAT && TARGET_E500 && !TARGET_FPRS)"
   "{ rs6000_emit_cbranch (UNORDERED, operands[0]); DONE; }")
 
 (define_expand "bordered"
   [(use (match_operand 0 "" ""))]
-  ""
+  "! (TARGET_HARD_FLOAT && TARGET_E500 && !TARGET_FPRS)"
   "{ rs6000_emit_cbranch (ORDERED, operands[0]); DONE; }")
 
 (define_expand "buneq"
   [(clobber (match_operand:SI 0 "gpc_reg_operand" ""))]
   ""
   "
-{ 
+{
   if (! rs6000_compare_fp_p)
     FAIL;
 
-  rs6000_emit_sCOND (NE, operands[0]); 
+  rs6000_emit_sCOND (NE, operands[0]);
   DONE;
 }")
 
   ""
   "
 {
-  if (! rs6000_compare_fp_p
-      && (! TARGET_POWER || rs6000_compare_op1 == const0_rtx))
+  if (! rs6000_compare_fp_p && rs6000_compare_op1 == const0_rtx)
     FAIL;
 
   rs6000_emit_sCOND (GE, operands[0]);
   ""
   "
 {
-  if (! rs6000_compare_fp_p
-      && (! TARGET_POWER || rs6000_compare_op1 == const0_rtx))
+  if (! rs6000_compare_fp_p && rs6000_compare_op1 == const0_rtx)
     FAIL;
 
-  rs6000_emit_sCOND (GT, operands[0]); 
+  rs6000_emit_sCOND (GT, operands[0]);
   DONE;
 }")
 
   ""
   "
 {
-  if (! rs6000_compare_fp_p
-      && (! TARGET_POWER || rs6000_compare_op1 == const0_rtx))
+  if (! rs6000_compare_fp_p && rs6000_compare_op1 == const0_rtx)
     FAIL;
 
-  rs6000_emit_sCOND (LE, operands[0]); 
+  rs6000_emit_sCOND (LE, operands[0]);
   DONE;
 }")
 
   ""
   "
 {
-  if (! rs6000_compare_fp_p 
-      && (! TARGET_POWER || rs6000_compare_op1 == const0_rtx))
+  if (! rs6000_compare_fp_p && rs6000_compare_op1 == const0_rtx)
     FAIL;
 
-  rs6000_emit_sCOND (LT, operands[0]); 
+  rs6000_emit_sCOND (LT, operands[0]);
   DONE;
 }")
 
 
 (define_expand "sunordered"
   [(clobber (match_operand:SI 0 "gpc_reg_operand" ""))]
-  ""
+  "! (TARGET_HARD_FLOAT && TARGET_E500 && !TARGET_FPRS)"
   "{ rs6000_emit_sCOND (UNORDERED, operands[0]); DONE; }")
 
 (define_expand "sordered"
   [(clobber (match_operand:SI 0 "gpc_reg_operand" ""))]
-  ""
+  "! (TARGET_HARD_FLOAT && TARGET_E500 && !TARGET_FPRS)"
   "{ rs6000_emit_sCOND (ORDERED, operands[0]); DONE; }")
 
 (define_expand "suneq"
   [(set (match_operand:CCFP 0 "cc_reg_operand" "=y")
        (compare:CCFP (match_operand:TF 1 "gpc_reg_operand" "f")
                      (match_operand:TF 2 "gpc_reg_operand" "f")))]
-  "DEFAULT_ABI == ABI_AIX && TARGET_HARD_FLOAT && TARGET_FPRS
-   && TARGET_LONG_DOUBLE_128"
-  "fcmpu %0,%1,%2\;bne %0,$+4\;fcmpu %0,%L1,%L2"
+  "(DEFAULT_ABI == ABI_AIX || DEFAULT_ABI == ABI_DARWIN) && !TARGET_XL_COMPAT
+   && TARGET_HARD_FLOAT && TARGET_FPRS && TARGET_LONG_DOUBLE_128"
+  "fcmpu %0,%1,%2\;bne %0,$+8\;fcmpu %0,%L1,%L2"
   [(set_attr "type" "fpcompare")
    (set_attr "length" "12")])
+
+(define_insn_and_split "*cmptf_internal2"
+  [(set (match_operand:CCFP 0 "cc_reg_operand" "=y")
+       (compare:CCFP (match_operand:TF 1 "gpc_reg_operand" "f")
+                     (match_operand:TF 2 "gpc_reg_operand" "f")))
+    (clobber (match_scratch:DF 3 "=f"))
+    (clobber (match_scratch:DF 4 "=f"))
+    (clobber (match_scratch:DF 5 "=f"))
+    (clobber (match_scratch:DF 6 "=f"))
+    (clobber (match_scratch:DF 7 "=f"))
+    (clobber (match_scratch:DF 8 "=f"))
+    (clobber (match_scratch:DF 9 "=f"))
+    (clobber (match_scratch:DF 10 "=f"))]
+  "(DEFAULT_ABI == ABI_AIX || DEFAULT_ABI == ABI_DARWIN) && TARGET_XL_COMPAT
+   && TARGET_HARD_FLOAT && TARGET_FPRS && TARGET_LONG_DOUBLE_128"
+  "#"
+  "&& reload_completed"
+  [(set (match_dup 3) (match_dup 13))
+   (set (match_dup 4) (match_dup 14))
+   (set (match_dup 9) (abs:DF (match_dup 5)))
+   (set (match_dup 0) (compare:CCFP (match_dup 9) (match_dup 3)))
+   (set (pc) (if_then_else (ne (match_dup 0) (const_int 0))
+                          (label_ref (match_dup 11))
+                          (pc)))
+   (set (match_dup 0) (compare:CCFP (match_dup 5) (match_dup 7)))
+   (set (pc) (label_ref (match_dup 12)))
+   (match_dup 11)
+   (set (match_dup 10) (minus:DF (match_dup 5) (match_dup 7)))
+   (set (match_dup 9) (minus:DF (match_dup 6) (match_dup 8)))
+   (set (match_dup 9) (plus:DF (match_dup 10) (match_dup 9)))
+   (set (match_dup 0) (compare:CCFP (match_dup 7) (match_dup 4)))
+   (match_dup 12)]
+{
+  REAL_VALUE_TYPE rv;
+  const int lo_word = FLOAT_WORDS_BIG_ENDIAN ? GET_MODE_SIZE (DFmode) : 0;
+  const int hi_word = FLOAT_WORDS_BIG_ENDIAN ? 0 : GET_MODE_SIZE (DFmode);
+
+  operands[5] = simplify_gen_subreg (DFmode, operands[1], TFmode, hi_word);
+  operands[6] = simplify_gen_subreg (DFmode, operands[1], TFmode, lo_word);
+  operands[7] = simplify_gen_subreg (DFmode, operands[2], TFmode, hi_word);
+  operands[8] = simplify_gen_subreg (DFmode, operands[2], TFmode, lo_word);
+  operands[11] = gen_label_rtx ();
+  operands[12] = gen_label_rtx ();
+  real_inf (&rv);
+  operands[13] = force_const_mem (DFmode,
+                                 CONST_DOUBLE_FROM_REAL_VALUE (rv, DFmode));
+  operands[14] = force_const_mem (DFmode,
+                                 CONST_DOUBLE_FROM_REAL_VALUE (dconst0,
+                                                               DFmode));
+  if (TARGET_TOC)
+    {
+      operands[13] = gen_const_mem (DFmode,
+                                   create_TOC_reference (XEXP (operands[13], 0)));
+      operands[14] = gen_const_mem (DFmode,
+                                   create_TOC_reference (XEXP (operands[14], 0)));
+      set_mem_alias_set (operands[13], get_TOC_alias_set ());
+      set_mem_alias_set (operands[14], get_TOC_alias_set ());
+    }
+})
 \f
 ;; Now we have the scc insns.  We can do some combinations because of the
 ;; way the machine works.
                (const_string "mfcrf")
           ]
        (const_string "mfcr")))
-   (set_attr "length" "12")])
+   (set_attr "length" "8")])
+
+;; Same as above, but get the GT bit.
+(define_insn "move_from_CR_gt_bit"
+  [(set (match_operand:SI 0 "gpc_reg_operand" "=r")
+       (unspec:SI [(match_operand 1 "cc_reg_operand" "y")] UNSPEC_MV_CR_GT))]
+  "TARGET_E500"
+  "mfcr %0\;{rlinm|rlwinm} %0,%0,%D1,31,31"
+  [(set_attr "type" "mfcr")
+   (set_attr "length" "8")])
 
 ;; Same as above, but get the OV/ORDERED bit.
 (define_insn "move_from_CR_ov_bit"
   "TARGET_ISEL"
   "mfcr %0\;{rlinm|rlwinm} %0,%0,%t1,1"
   [(set_attr "type" "mfcr")
-   (set_attr "length" "12")])
+   (set_attr "length" "8")])
 
 (define_insn ""
   [(set (match_operand:DI 0 "gpc_reg_operand" "=r")
                (const_string "mfcrf")
           ]
        (const_string "mfcr")))
-   (set_attr "length" "12")])
+   (set_attr "length" "8")])
 
 (define_insn ""
   [(set (match_operand:CC 0 "cc_reg_operand" "=x,?y")
                    (const_int 0)))
    (set (match_operand:SI 3 "gpc_reg_operand" "=r,r")
        (match_op_dup 1 [(match_dup 2) (const_int 0)]))]
-  "! TARGET_POWERPC64"
+  "TARGET_32BIT"
   "@
    mfcr %3%Q2\;{rlinm.|rlwinm.} %3,%3,%J1,1
    #"
   [(set_attr "type" "delayed_compare")
-   (set_attr "length" "12,16")])
+   (set_attr "length" "8,16")])
 
 (define_split
   [(set (match_operand:CC 0 "cc_reg_not_cr0_operand" "")
                    (const_int 0)))
    (set (match_operand:SI 3 "gpc_reg_operand" "")
        (match_op_dup 1 [(match_dup 2) (const_int 0)]))]
-  "! TARGET_POWERPC64 && reload_completed"
+  "TARGET_32BIT && reload_completed"
   [(set (match_dup 3)
        (match_op_dup 1 [(match_dup 2) (const_int 0)]))
    (set (match_dup 0)
                (const_string "mfcrf")
           ]
        (const_string "mfcr")))
-   (set_attr "length" "12")])
+   (set_attr "length" "8")])
 
 (define_insn ""
   [(set (match_operand:CC 0 "cc_reg_operand" "=x,?y")
   return \"mfcr %4%Q2\;{rlinm.|rlwinm.} %4,%4,%5,%6,%6\";
 }"
   [(set_attr "type" "delayed_compare")
-   (set_attr "length" "12,16")])
+   (set_attr "length" "8,16")])
 
 (define_split
   [(set (match_operand:CC 0 "cc_reg_not_cr0_operand" "")
   "REGNO (operands[2]) != REGNO (operands[5])"
   "mfcr %3\;{rlinm|rlwinm} %0,%3,%J1,1\;{rlinm|rlwinm} %3,%3,%J4,1"
   [(set_attr "type" "mfcr")
-   (set_attr "length" "20")])
+   (set_attr "length" "12")])
 
 (define_peephole
   [(set (match_operand:DI 0 "gpc_reg_operand" "=r")
   "TARGET_POWERPC64 && REGNO (operands[2]) != REGNO (operands[5])"
   "mfcr %3\;{rlinm|rlwinm} %0,%3,%J1,1\;{rlinm|rlwinm} %3,%3,%J4,1"
   [(set_attr "type" "mfcr")
-   (set_attr "length" "20")])
+   (set_attr "length" "12")])
 
 ;; There are some scc insns that can be done directly, without a compare.
 ;; These are faster because they don't involve the communications between
        (eq:SI (match_operand:SI 1 "gpc_reg_operand" "%r,r,r,r,r")
               (match_operand:SI 2 "reg_or_cint_operand" "r,O,K,L,I")))
    (clobber (match_scratch:SI 3 "=r,&r,r,r,r"))]
-  "! TARGET_POWERPC64"
+  "TARGET_32BIT"
   "@
    xor %0,%1,%2\;{sfi|subfic} %3,%0,0\;{ae|adde} %0,%3,%0
    {sfi|subfic} %3,%1,0\;{ae|adde} %0,%3,%1
    {xoril|xori} %0,%1,%b2\;{sfi|subfic} %3,%0,0\;{ae|adde} %0,%3,%0
    {xoriu|xoris} %0,%1,%u2\;{sfi|subfic} %3,%0,0\;{ae|adde} %0,%3,%0
    {sfi|subfic} %0,%1,%2\;{sfi|subfic} %3,%0,0\;{ae|adde} %0,%3,%0"
-  [(set_attr "length" "12,8,12,12,12")])
+  [(set_attr "type" "three,two,three,three,three")
+   (set_attr "length" "12,8,12,12,12")])
 
 (define_insn ""
   [(set (match_operand:DI 0 "gpc_reg_operand" "=r,r,r,r,r")
        (eq:DI (match_operand:DI 1 "gpc_reg_operand" "%r,r,r,r,r")
               (match_operand:DI 2 "reg_or_cint_operand" "r,O,K,J,I")))
    (clobber (match_scratch:DI 3 "=r,&r,r,r,r"))]
-  "TARGET_POWERPC64"
+  "TARGET_64BIT"
   "@
    xor %0,%1,%2\;subfic %3,%0,0\;adde %0,%3,%0
    subfic %3,%1,0\;adde %0,%3,%1
    xori %0,%1,%b2\;subfic %3,%0,0\;adde %0,%3,%0
    xoris %0,%1,%u2\;subfic %3,%0,0\;adde %0,%3,%0
    subfic %0,%1,%2\;subfic %3,%0,0\;adde %0,%3,%0"
-  [(set_attr "length" "12,8,12,12,12")])
+  [(set_attr "type" "three,two,three,three,three")
+   (set_attr "length" "12,8,12,12,12")])
 
 (define_insn ""
   [(set (match_operand:CC 4 "cc_reg_operand" "=x,x,x,x,x,?y,?y,?y,?y,?y")
    (set (match_operand:SI 0 "gpc_reg_operand" "=r,r,r,r,r,r,r,r,r,r")
        (eq:SI (match_dup 1) (match_dup 2)))
    (clobber (match_scratch:SI 3 "=r,&r,r,r,r,r,&r,r,r,r"))]
-  "! TARGET_POWERPC64"
+  "TARGET_32BIT"
   "@
    xor %0,%1,%2\;{sfi|subfic} %3,%0,0\;{ae.|adde.} %0,%3,%0
    {sfi|subfic} %3,%1,0\;{ae.|adde.} %0,%3,%1
    (set (match_operand:SI 0 "gpc_reg_operand" "")
        (eq:SI (match_dup 1) (match_dup 2)))
    (clobber (match_scratch:SI 3 ""))]
-  "! TARGET_POWERPC64 && reload_completed"
+  "TARGET_32BIT && reload_completed"
   [(parallel [(set (match_dup 0)
        (eq:SI (match_dup 1) (match_dup 2)))
    (clobber (match_dup 3))])
    (set (match_operand:DI 0 "gpc_reg_operand" "=r,r,r,r,r,r,r,r,r,r")
        (eq:DI (match_dup 1) (match_dup 2)))
    (clobber (match_scratch:DI 3 "=r,&r,r,r,r,r,&r,r,r,r"))]
-  "TARGET_POWERPC64"
+  "TARGET_64BIT"
   "@
    xor %0,%1,%2\;subfic %3,%0,0\;adde. %0,%3,%0
    subfic %3,%1,0\;adde. %0,%3,%1
    (set (match_operand:DI 0 "gpc_reg_operand" "")
        (eq:DI (match_dup 1) (match_dup 2)))
    (clobber (match_scratch:DI 3 ""))]
-  "TARGET_POWERPC64 && reload_completed"
+  "TARGET_64BIT && reload_completed"
   [(parallel [(set (match_dup 0)
        (eq:DI (match_dup 1) (match_dup 2)))
    (clobber (match_dup 3))])
        (plus:SI (eq:SI (match_operand:SI 1 "gpc_reg_operand" "%r,r,r,r,r")
                        (match_operand:SI 2 "reg_or_cint_operand" "r,O,K,L,I"))
                 (match_operand:SI 3 "gpc_reg_operand" "r,r,r,r,r")))]
-  "! TARGET_POWERPC64"
+  "TARGET_32BIT"
   "@
    xor %0,%1,%2\;{sfi|subfic} %0,%0,0\;{aze|addze} %0,%3
    {sfi|subfic} %0,%1,0\;{aze|addze} %0,%3
    {xoril|xori} %0,%1,%b2\;{sfi|subfic} %0,%0,0\;{aze|addze} %0,%3
    {xoriu|xoris} %0,%1,%u2\;{sfi|subfic} %0,%0,0\;{aze|addze} %0,%3
    {sfi|subfic} %0,%1,%2\;{sfi|subfic} %0,%0,0\;{aze|addze} %0,%3"
-  [(set_attr "length" "12,8,12,12,12")])
+  [(set_attr "type" "three,two,three,three,three")
+   (set_attr "length" "12,8,12,12,12")])
 
 (define_insn ""
   [(set (match_operand:CC 0 "cc_reg_operand" "=x,x,x,x,x,?y,?y,?y,?y,?y")
          (match_operand:SI 3 "gpc_reg_operand" "r,r,r,r,r,r,r,r,r,r"))
         (const_int 0)))
    (clobber (match_scratch:SI 4 "=&r,&r,&r,&r,&r,&r,&r,&r,&r,&r"))]
-  "! TARGET_POWERPC64"
+  "TARGET_32BIT"
   "@
    xor %4,%1,%2\;{sfi|subfic} %4,%4,0\;{aze.|addze.} %4,%3
    {sfi|subfic} %4,%1,0\;{aze.|addze.} %4,%3
          (match_operand:SI 3 "gpc_reg_operand" ""))
         (const_int 0)))
    (clobber (match_scratch:SI 4 ""))]
-  "! TARGET_POWERPC64 && reload_completed"
+  "TARGET_32BIT && reload_completed"
   [(set (match_dup 4)
        (plus:SI (eq:SI (match_dup 1)
                 (match_dup 2))
         (const_int 0)))
    (set (match_operand:SI 0 "gpc_reg_operand" "=&r,&r,&r,&r,&r,&r,&r,&r,&r,&r")
        (plus:SI (eq:SI (match_dup 1) (match_dup 2)) (match_dup 3)))]
-  "! TARGET_POWERPC64"
+  "TARGET_32BIT"
   "@
    xor %0,%1,%2\;{sfi|subfic} %0,%0,0\;{aze.|addze.} %0,%3
    {sfi|subfic} %0,%1,0\;{aze.|addze.} %0,%3
         (const_int 0)))
    (set (match_operand:SI 0 "gpc_reg_operand" "")
        (plus:SI (eq:SI (match_dup 1) (match_dup 2)) (match_dup 3)))]
-  "! TARGET_POWERPC64 && reload_completed"
+  "TARGET_32BIT && reload_completed"
   [(set (match_dup 0)
        (plus:SI (eq:SI (match_dup 1) (match_dup 2)) (match_dup 3)))
    (set (match_dup 4)
   [(set (match_operand:SI 0 "gpc_reg_operand" "=r,r,r,r,r")
        (neg:SI (eq:SI (match_operand:SI 1 "gpc_reg_operand" "%r,r,r,r,r")
                       (match_operand:SI 2 "reg_or_cint_operand" "r,O,K,L,I"))))]
-  "! TARGET_POWERPC64"
+  "TARGET_32BIT"
   "@
    xor %0,%1,%2\;{ai|addic} %0,%0,-1\;{sfe|subfe} %0,%0,%0
    {ai|addic} %0,%1,-1\;{sfe|subfe} %0,%0,%0
    {xoril|xori} %0,%1,%b2\;{ai|addic} %0,%0,-1\;{sfe|subfe} %0,%0,%0
    {xoriu|xoris} %0,%1,%u2\;{ai|addic} %0,%0,-1\;{sfe|subfe} %0,%0,%0
    {sfi|subfic} %0,%1,%2\;{ai|addic} %0,%0,-1\;{sfe|subfe} %0,%0,%0"
-   [(set_attr "length" "12,8,12,12,12")])
+   [(set_attr "type" "three,two,three,three,three")
+    (set_attr "length" "12,8,12,12,12")])
 
 ;; Simplify (ne X (const_int 0)) on the PowerPC.  No need to on the Power,
 ;; since it nabs/sr is just as fast.
        (lshiftrt:SI (neg:SI (abs:SI (match_operand:SI 1 "gpc_reg_operand" "r")))
                     (const_int 31)))
    (clobber (match_scratch:SI 2 "=&r"))]
-  "! TARGET_POWER && ! TARGET_POWERPC64 && !TARGET_ISEL"
+  "! TARGET_POWER && TARGET_32BIT && !TARGET_ISEL"
   "{ai|addic} %2,%1,-1\;{sfe|subfe} %0,%2,%1"
-  [(set_attr "length" "8")])
+  [(set_attr "type" "two")
+   (set_attr "length" "8")])
 
 (define_insn ""
   [(set (match_operand:DI 0 "gpc_reg_operand" "=r")
        (lshiftrt:DI (neg:DI (abs:DI (match_operand:DI 1 "gpc_reg_operand" "r")))
                     (const_int 63)))
    (clobber (match_scratch:DI 2 "=&r"))]
-  "TARGET_POWERPC64"
+  "TARGET_64BIT"
   "addic %2,%1,-1\;subfe %0,%2,%1"
-  [(set_attr "length" "8")])
+  [(set_attr "type" "two")
+   (set_attr "length" "8")])
 
 ;; This is what (plus (ne X (const_int 0)) Y) looks like.
 (define_insn ""
                  (const_int 31))
                 (match_operand:SI 2 "gpc_reg_operand" "r")))
    (clobber (match_scratch:SI 3 "=&r"))]
-  "! TARGET_POWERPC64"
+  "TARGET_32BIT"
   "{ai|addic} %3,%1,-1\;{aze|addze} %0,%2"
-  [(set_attr "length" "8")])
+  [(set_attr "type" "two")
+   (set_attr "length" "8")])
 
 (define_insn ""
   [(set (match_operand:DI 0 "gpc_reg_operand" "=r")
                  (const_int 63))
                 (match_operand:DI 2 "gpc_reg_operand" "r")))
    (clobber (match_scratch:DI 3 "=&r"))]
-  "TARGET_POWERPC64"
+  "TARGET_64BIT"
   "addic %3,%1,-1\;addze %0,%2"
-  [(set_attr "length" "8")])
+  [(set_attr "type" "two")
+   (set_attr "length" "8")])
 
 (define_insn ""
   [(set (match_operand:CC 0 "cc_reg_operand" "=x,?y")
         (const_int 0)))
    (clobber (match_scratch:SI 3 "=&r,&r"))
    (clobber (match_scratch:SI 4 "=X,&r"))]
-  "! TARGET_POWERPC64"
+  "TARGET_32BIT"
   "@
    {ai|addic} %3,%1,-1\;{aze.|addze.} %3,%2
    #"
         (const_int 0)))
    (clobber (match_scratch:SI 3 ""))
    (clobber (match_scratch:SI 4 ""))]
-  "! TARGET_POWERPC64 && reload_completed"
+  "TARGET_32BIT && reload_completed"
   [(parallel [(set (match_dup 3)
                   (plus:SI (lshiftrt:SI (neg:SI (abs:SI (match_dup 1)))
                                         (const_int 31))
                  (match_operand:DI 2 "gpc_reg_operand" "r,r"))
         (const_int 0)))
    (clobber (match_scratch:DI 3 "=&r,&r"))]
-  "TARGET_POWERPC64"
+  "TARGET_64BIT"
   "@
    addic %3,%1,-1\;addze. %3,%2
    #"
                  (match_operand:DI 2 "gpc_reg_operand" ""))
         (const_int 0)))
    (clobber (match_scratch:DI 3 ""))]
-  "TARGET_POWERPC64 && reload_completed"
+  "TARGET_64BIT && reload_completed"
   [(set (match_dup 3)
        (plus:DI (lshiftrt:DI (neg:DI (abs:DI (match_dup 1)))
                   (const_int 63))
        (plus:SI (lshiftrt:SI (neg:SI (abs:SI (match_dup 1))) (const_int 31))
                 (match_dup 2)))
    (clobber (match_scratch:SI 3 "=&r,&r"))]
-  "! TARGET_POWERPC64"
+  "TARGET_32BIT"
   "@
    {ai|addic} %3,%1,-1\;{aze.|addze.} %0,%2
    #"
        (plus:SI (lshiftrt:SI (neg:SI (abs:SI (match_dup 1))) (const_int 31))
                 (match_dup 2)))
    (clobber (match_scratch:SI 3 ""))]
-  "! TARGET_POWERPC64 && reload_completed"
+  "TARGET_32BIT && reload_completed"
   [(parallel [(set (match_dup 0)
        (plus:SI (lshiftrt:SI (neg:SI (abs:SI (match_dup 1))) (const_int 31))
                 (match_dup 2)))
        (plus:DI (lshiftrt:DI (neg:DI (abs:DI (match_dup 1))) (const_int 63))
                 (match_dup 2)))
    (clobber (match_scratch:DI 3 "=&r,&r"))]
-  "TARGET_POWERPC64"
+  "TARGET_64BIT"
   "@
    addic %3,%1,-1\;addze. %0,%2
    #"
        (plus:DI (lshiftrt:DI (neg:DI (abs:DI (match_dup 1))) (const_int 63))
                 (match_dup 2)))
    (clobber (match_scratch:DI 3 ""))]
-  "TARGET_POWERPC64 && reload_completed"
+  "TARGET_64BIT && reload_completed"
   [(parallel [(set (match_dup 0)
        (plus:DI (lshiftrt:DI (neg:DI (abs:DI (match_dup 1))) (const_int 63))
                 (match_dup 2)))
   [(set (match_operand:SI 0 "gpc_reg_operand" "=r")
        (leu:SI (match_operand:SI 1 "gpc_reg_operand" "r")
                (match_operand:SI 2 "reg_or_short_operand" "rI")))]
-  "! TARGET_POWERPC64"
+  "TARGET_32BIT"
   "{sf%I2|subf%I2c} %0,%1,%2\;{cal %0,0(0)|li %0,0}\;{ae|adde} %0,%0,%0"
-  [(set_attr "length" "12")])
+  [(set_attr "type" "three")
+   (set_attr "length" "12")])
 
 (define_insn ""
   [(set (match_operand:DI 0 "gpc_reg_operand" "=r")
        (leu:DI (match_operand:DI 1 "gpc_reg_operand" "r")
                (match_operand:DI 2 "reg_or_short_operand" "rI")))]
-  "TARGET_POWERPC64"
+  "TARGET_64BIT"
   "subf%I2c %0,%1,%2\;li %0,0\;adde %0,%0,%0"
-  [(set_attr "length" "12")])
+  [(set_attr "type" "three")
+   (set_attr "length" "12")])
 
 (define_insn ""
   [(set (match_operand:CC 3 "cc_reg_operand" "=x,?y")
         (const_int 0)))
    (set (match_operand:DI 0 "gpc_reg_operand" "=r,r")
        (leu:DI (match_dup 1) (match_dup 2)))]
-  "TARGET_POWERPC64"
+  "TARGET_64BIT"
   "@
    subf%I2c %0,%1,%2\;li %0,0\;adde. %0,%0,%0
    #"
         (const_int 0)))
    (set (match_operand:DI 0 "gpc_reg_operand" "")
        (leu:DI (match_dup 1) (match_dup 2)))]
-  "TARGET_POWERPC64 && reload_completed"
+  "TARGET_64BIT && reload_completed"
   [(set (match_dup 0)
        (leu:DI (match_dup 1) (match_dup 2)))
    (set (match_dup 3)
         (const_int 0)))
    (set (match_operand:SI 0 "gpc_reg_operand" "=r,r")
        (leu:SI (match_dup 1) (match_dup 2)))]
-  "! TARGET_POWERPC64"
+  "TARGET_32BIT"
   "@
    {sf%I2|subf%I2c} %0,%1,%2\;{cal %0,0(0)|li %0,0}\;{ae.|adde.} %0,%0,%0
    #"
         (const_int 0)))
    (set (match_operand:SI 0 "gpc_reg_operand" "")
        (leu:SI (match_dup 1) (match_dup 2)))]
-  "! TARGET_POWERPC64 && reload_completed"
+  "TARGET_32BIT && reload_completed"
   [(set (match_dup 0)
        (leu:SI (match_dup 1) (match_dup 2)))
    (set (match_dup 3)
   "")
 
 (define_insn ""
-  [(set (match_operand:CC 3 "cc_reg_operand" "=x,?y")
-       (compare:CC
-        (leu:DI (match_operand:DI 1 "gpc_reg_operand" "r,r")
-                (match_operand:DI 2 "reg_or_short_operand" "rI,rI"))
-        (const_int 0)))
-   (set (match_operand:DI 0 "gpc_reg_operand" "=r,r")
-       (leu:DI (match_dup 1) (match_dup 2)))]
-  "TARGET_POWERPC64"
-  "@
-   subf%I2c %0,%1,%2\;li %0,0\;adde. %0,%0,%0
-   #"
-  [(set_attr "type" "compare")
-   (set_attr "length" "12,16")])
-
-(define_insn ""
   [(set (match_operand:SI 0 "gpc_reg_operand" "=&r")
        (plus:SI (leu:SI (match_operand:SI 1 "gpc_reg_operand" "r")
                         (match_operand:SI 2 "reg_or_short_operand" "rI"))
                 (match_operand:SI 3 "gpc_reg_operand" "r")))]
-  "! TARGET_POWERPC64"
+  "TARGET_32BIT"
   "{sf%I2|subf%I2c} %0,%1,%2\;{aze|addze} %0,%3"
-  [(set_attr "length" "8")])
+  [(set_attr "type" "two")
+   (set_attr "length" "8")])
 
 (define_insn ""
   [(set (match_operand:CC 0 "cc_reg_operand" "=x,?y")
                  (match_operand:SI 3 "gpc_reg_operand" "r,r"))
         (const_int 0)))
    (clobber (match_scratch:SI 4 "=&r,&r"))]
-  "! TARGET_POWERPC64"
+  "TARGET_32BIT"
   "@
    {sf%I2|subf%I2c} %4,%1,%2\;{aze.|addze.} %4,%3
    #"
                  (match_operand:SI 3 "gpc_reg_operand" ""))
         (const_int 0)))
    (clobber (match_scratch:SI 4 ""))]
-  "! TARGET_POWERPC64 && reload_completed"
+  "TARGET_32BIT && reload_completed"
   [(set (match_dup 4)
        (plus:SI (leu:SI (match_dup 1) (match_dup 2))
                  (match_dup 3)))
         (const_int 0)))
    (set (match_operand:SI 0 "gpc_reg_operand" "=&r,&r")
        (plus:SI (leu:SI (match_dup 1) (match_dup 2)) (match_dup 3)))]
-  "! TARGET_POWERPC64"
+  "TARGET_32BIT"
   "@
    {sf%I2|subf%I2c} %0,%1,%2\;{aze.|addze.} %0,%3
    #"
         (const_int 0)))
    (set (match_operand:SI 0 "gpc_reg_operand" "")
        (plus:SI (leu:SI (match_dup 1) (match_dup 2)) (match_dup 3)))]
-  "! TARGET_POWERPC64 && reload_completed"
+  "TARGET_32BIT && reload_completed"
   [(set (match_dup 0)
        (plus:SI (leu:SI (match_dup 1) (match_dup 2)) (match_dup 3)))
    (set (match_dup 4)
   [(set (match_operand:SI 0 "gpc_reg_operand" "=r")
        (neg:SI (leu:SI (match_operand:SI 1 "gpc_reg_operand" "r")
                        (match_operand:SI 2 "reg_or_short_operand" "rI"))))]
-  "! TARGET_POWERPC64"
+  "TARGET_32BIT"
   "{sf%I2|subf%I2c} %0,%1,%2\;{sfe|subfe} %0,%0,%0\;nand %0,%0,%0"
-   [(set_attr "length" "12")])
+   [(set_attr "type" "three")
+    (set_attr "length" "12")])
 
 (define_insn ""
   [(set (match_operand:SI 0 "gpc_reg_operand" "=&r")
                 (leu:SI (match_operand:SI 1 "gpc_reg_operand" "r")
                         (match_operand:SI 2 "reg_or_short_operand" "rI")))
                (match_operand:SI 3 "gpc_reg_operand" "r")))]
-  "! TARGET_POWERPC64"
+  "TARGET_32BIT"
   "{sf%I2|subf%I2c} %0,%1,%2\;{sfe|subfe} %0,%0,%0\;andc %0,%3,%0"
-  [(set_attr "length" "12")])
+  [(set_attr "type" "three")
+   (set_attr "length" "12")])
 
 (define_insn ""
   [(set (match_operand:CC 0 "cc_reg_operand" "=x,?y")
                 (match_operand:SI 3 "gpc_reg_operand" "r,r"))
         (const_int 0)))
    (clobber (match_scratch:SI 4 "=&r,&r"))]
-  "! TARGET_POWERPC64"
+  "TARGET_32BIT"
   "@
    {sf%I2|subf%I2c} %4,%1,%2\;{sfe|subfe} %4,%4,%4\;andc. %4,%3,%4
    #"
                 (match_operand:SI 3 "gpc_reg_operand" ""))
         (const_int 0)))
    (clobber (match_scratch:SI 4 ""))]
-  "! TARGET_POWERPC64 && reload_completed"
+  "TARGET_32BIT && reload_completed"
   [(set (match_dup 4)
        (and:SI (neg:SI (leu:SI (match_dup 1) (match_dup 2)))
                (match_dup 3)))
         (const_int 0)))
    (set (match_operand:SI 0 "gpc_reg_operand" "=&r,&r")
        (and:SI (neg:SI (leu:SI (match_dup 1) (match_dup 2))) (match_dup 3)))]
-  "! TARGET_POWERPC64"
+  "TARGET_32BIT"
   "@
    {sf%I2|subf%I2c} %0,%1,%2\;{sfe|subfe} %0,%0,%0\;andc. %0,%3,%0
    #"
         (const_int 0)))
    (set (match_operand:SI 0 "gpc_reg_operand" "")
        (and:SI (neg:SI (leu:SI (match_dup 1) (match_dup 2))) (match_dup 3)))]
-  "! TARGET_POWERPC64 && reload_completed"
+  "TARGET_32BIT && reload_completed"
   [(set (match_dup 0)
        (and:SI (neg:SI (leu:SI (match_dup 1) (match_dup 2)))
                (match_dup 3)))
   "doz%I2 %0,%1,%2\;nabs %0,%0\;{srai|srawi} %0,%0,31"
   [(set_attr "length" "12")])
 
-(define_insn ""
+(define_insn_and_split ""
   [(set (match_operand:SI 0 "gpc_reg_operand" "=r,r")
        (ltu:SI (match_operand:SI 1 "gpc_reg_operand" "r,r")
                (match_operand:SI 2 "reg_or_neg_short_operand" "r,P")))]
-  "! TARGET_POWERPC64"
-  "@
-   {sf|subfc} %0,%2,%1\;{sfe|subfe} %0,%0,%0\;neg %0,%0
-   {ai|addic} %0,%1,%n2\;{sfe|subfe} %0,%0,%0\;neg %0,%0"
-  [(set_attr "length" "12")])
+  "TARGET_32BIT"
+  "#"
+  "TARGET_32BIT"
+  [(set (match_dup 0) (neg:SI (ltu:SI (match_dup 1) (match_dup 2))))
+   (set (match_dup 0) (neg:SI (match_dup 0)))]
+  "")
+
+(define_insn_and_split ""
+  [(set (match_operand:DI 0 "gpc_reg_operand" "=r,r")
+       (ltu:DI (match_operand:DI 1 "gpc_reg_operand" "r,r")
+               (match_operand:DI 2 "reg_or_neg_short_operand" "r,P")))]
+  "TARGET_64BIT"
+  "#"
+  "TARGET_64BIT"
+  [(set (match_dup 0) (neg:DI (ltu:DI (match_dup 1) (match_dup 2))))
+   (set (match_dup 0) (neg:DI (match_dup 0)))]
+  "")
 
 (define_insn ""
   [(set (match_operand:CC 3 "cc_reg_operand" "=x,x,?y,?y")
         (const_int 0)))
    (set (match_operand:SI 0 "gpc_reg_operand" "=r,r,r,r")
        (ltu:SI (match_dup 1) (match_dup 2)))]
-  "! TARGET_POWERPC64"
+  "TARGET_32BIT"
   "@
    {sf|subfc} %0,%2,%1\;{sfe|subfe} %0,%0,%0\;neg. %0,%0
    {ai|addic} %0,%1,%n2\;{sfe|subfe} %0,%0,%0\;neg. %0,%0
         (const_int 0)))
    (set (match_operand:SI 0 "gpc_reg_operand" "")
        (ltu:SI (match_dup 1) (match_dup 2)))]
-  "! TARGET_POWERPC64 && reload_completed"
+  "TARGET_32BIT && reload_completed"
   [(set (match_dup 0)
        (ltu:SI (match_dup 1) (match_dup 2)))
    (set (match_dup 3)
                    (const_int 0)))]
   "")
 
-(define_insn ""
-  [(set (match_operand:SI 0 "gpc_reg_operand" "=&r,&r")
+(define_insn_and_split ""
+  [(set (match_operand:SI 0 "gpc_reg_operand" "=&r,r")
        (plus:SI (ltu:SI (match_operand:SI 1 "gpc_reg_operand" "r,r")
                         (match_operand:SI 2 "reg_or_neg_short_operand" "r,P"))
                 (match_operand:SI 3 "reg_or_short_operand" "rI,rI")))]
-  "! TARGET_POWERPC64"
-  "@
-  {sf|subfc} %0,%2,%1\;{sfe|subfe} %0,%0,%0\;{sf%I3|subf%I3c} %0,%0,%3
-  {ai|addic} %0,%1,%n2\;{sfe|subfe} %0,%0,%0\;{sf%I3|subf%I3c} %0,%0,%3"
- [(set_attr "length" "12")])
+  "TARGET_32BIT"
+  "#"
+  "&& !reg_overlap_mentioned_p (operands[0], operands[3])"
+  [(set (match_dup 0) (neg:SI (ltu:SI (match_dup 1) (match_dup 2))))
+   (set (match_dup 0) (minus:SI (match_dup 3) (match_dup 0)))]
+  "")
+
+(define_insn_and_split ""
+  [(set (match_operand:DI 0 "gpc_reg_operand" "=&r,r")
+       (plus:DI (ltu:DI (match_operand:DI 1 "gpc_reg_operand" "r,r")
+                        (match_operand:DI 2 "reg_or_neg_short_operand" "r,P"))
+                (match_operand:DI 3 "reg_or_short_operand" "rI,rI")))]
+  "TARGET_64BIT"
+  "#"
+  "&& !reg_overlap_mentioned_p (operands[0], operands[3])"
+  [(set (match_dup 0) (neg:DI (ltu:DI (match_dup 1) (match_dup 2))))
+   (set (match_dup 0) (minus:DI (match_dup 3) (match_dup 0)))]
+  "")
 
 (define_insn ""
   [(set (match_operand:CC 0 "cc_reg_operand" "=x,x,?y,?y")
                  (match_operand:SI 3 "gpc_reg_operand" "r,r,r,r"))
         (const_int 0)))
    (clobber (match_scratch:SI 4 "=&r,&r,&r,&r"))]
-  "! TARGET_POWERPC64"
+  "TARGET_32BIT"
   "@
-   {sf|subfc} %4,%2,%1\;{sfe|subfe} %4,%4,%4\;{sf.|subfc.} %4,%4,%3
-   {ai|addic} %4,%1,%n2\;{sfe|subfe} %4,%4,%4\;{sf.|subfc.} %4,%4,%3
+   {sf|subfc} %4,%2,%1\;{sfe|subfe} %4,%4,%4\;{sf.|subf.} %4,%4,%3
+   {ai|addic} %4,%1,%n2\;{sfe|subfe} %4,%4,%4\;{sf.|subf.} %4,%4,%3
    #
    #"
   [(set_attr "type" "compare")
                  (match_operand:SI 3 "gpc_reg_operand" ""))
         (const_int 0)))
    (clobber (match_scratch:SI 4 ""))]
-  "! TARGET_POWERPC64 && reload_completed"
+  "TARGET_32BIT && reload_completed"
   [(set (match_dup 4)
        (plus:SI (ltu:SI (match_dup 1) (match_dup 2))
                 (match_dup 3)))
         (const_int 0)))
    (set (match_operand:SI 0 "gpc_reg_operand" "=&r,&r,&r,&r")
        (plus:SI (ltu:SI (match_dup 1) (match_dup 2)) (match_dup 3)))]
-  "! TARGET_POWERPC64"
+  "TARGET_32BIT"
   "@
-   {sf|subfc} %0,%2,%1\;{sfe|subfe} %0,%0,%0\;{sf.|subfc.} %0,%0,%3
-   {ai|addic} %0,%1,%n2\;{sfe|subfe} %0,%0,%0\;{sf.|subfc.} %0,%0,%3
+   {sf|subfc} %0,%2,%1\;{sfe|subfe} %0,%0,%0\;{sf.|subf.} %0,%0,%3
+   {ai|addic} %0,%1,%n2\;{sfe|subfe} %0,%0,%0\;{sf.|subf.} %0,%0,%3
    #
    #"
   [(set_attr "type" "compare")
         (const_int 0)))
    (set (match_operand:SI 0 "gpc_reg_operand" "")
        (plus:SI (ltu:SI (match_dup 1) (match_dup 2)) (match_dup 3)))]
-  "! TARGET_POWERPC64 && reload_completed"
+  "TARGET_32BIT && reload_completed"
   [(set (match_dup 0)
        (plus:SI (ltu:SI (match_dup 1) (match_dup 2)) (match_dup 3)))
    (set (match_dup 4)
   [(set (match_operand:SI 0 "gpc_reg_operand" "=r,r")
        (neg:SI (ltu:SI (match_operand:SI 1 "gpc_reg_operand" "r,r")
                        (match_operand:SI 2 "reg_or_neg_short_operand" "r,P"))))]
-  "! TARGET_POWERPC64"
+  "TARGET_32BIT"
   "@
    {sf|subfc} %0,%2,%1\;{sfe|subfe} %0,%0,%0
    {ai|addic} %0,%1,%n2\;{sfe|subfe} %0,%0,%0"
-  [(set_attr "length" "8")])
+  [(set_attr "type" "two")
+   (set_attr "length" "8")])
+
+(define_insn ""
+  [(set (match_operand:DI 0 "gpc_reg_operand" "=r,r")
+       (neg:DI (ltu:DI (match_operand:DI 1 "gpc_reg_operand" "r,r")
+                       (match_operand:DI 2 "reg_or_neg_short_operand" "r,P"))))]
+  "TARGET_64BIT"
+  "@
+   {sf|subfc} %0,%2,%1\;{sfe|subfe} %0,%0,%0
+   {ai|addic} %0,%1,%n2\;{sfe|subfe} %0,%0,%0"
+  [(set_attr "type" "two")
+   (set_attr "length" "8")])
 
 (define_insn ""
   [(set (match_operand:SI 0 "gpc_reg_operand" "=r")
   [(set (match_operand:SI 0 "gpc_reg_operand" "=r,r")
        (geu:SI (match_operand:SI 1 "gpc_reg_operand" "r,r")
                (match_operand:SI 2 "reg_or_neg_short_operand" "r,P")))]
-  "! TARGET_POWERPC64"
+  "TARGET_32BIT"
   "@
    {sf|subfc} %0,%2,%1\;{cal %0,0(0)|li %0,0}\;{ae|adde} %0,%0,%0
    {ai|addic} %0,%1,%n2\;{cal %0,0(0)|li %0,0}\;{ae|adde} %0,%0,%0"
-  [(set_attr "length" "12")])
+  [(set_attr "type" "three")
+   (set_attr "length" "12")])
 
 (define_insn ""
   [(set (match_operand:DI 0 "gpc_reg_operand" "=r,r")
        (geu:DI (match_operand:DI 1 "gpc_reg_operand" "r,r")
                (match_operand:DI 2 "reg_or_neg_short_operand" "r,P")))]
-  "TARGET_POWERPC64"
+  "TARGET_64BIT"
   "@
    subfc %0,%2,%1\;li %0,0\;adde %0,%0,%0
    addic %0,%1,%n2\;li %0,0\;adde %0,%0,%0"
-  [(set_attr "length" "12")])
+  [(set_attr "type" "three")
+   (set_attr "length" "12")])
 
 (define_insn ""
   [(set (match_operand:CC 3 "cc_reg_operand" "=x,x,?y,?y")
         (const_int 0)))
    (set (match_operand:SI 0 "gpc_reg_operand" "=r,r,r,r")
        (geu:SI (match_dup 1) (match_dup 2)))]
-  "! TARGET_POWERPC64"
+  "TARGET_32BIT"
   "@
    {sf|subfc} %0,%2,%1\;{cal %0,0(0)|li %0,0}\;{ae.|adde.} %0,%0,%0
    {ai|addic} %0,%1,%n2\;{cal %0,0(0)|li %0,0}\;{ae.|adde.} %0,%0,%0
         (const_int 0)))
    (set (match_operand:SI 0 "gpc_reg_operand" "")
        (geu:SI (match_dup 1) (match_dup 2)))]
-  "! TARGET_POWERPC64 && reload_completed"
+  "TARGET_32BIT && reload_completed"
   [(set (match_dup 0)
        (geu:SI (match_dup 1) (match_dup 2)))
    (set (match_dup 3)
         (const_int 0)))
    (set (match_operand:DI 0 "gpc_reg_operand" "=r,r,r,r")
        (geu:DI (match_dup 1) (match_dup 2)))]
-  "TARGET_POWERPC64"
+  "TARGET_64BIT"
   "@
    subfc %0,%2,%1\;li %0,0\;adde. %0,%0,%0
    addic %0,%1,%n2\;li %0,0\;adde. %0,%0,%0
         (const_int 0)))
    (set (match_operand:DI 0 "gpc_reg_operand" "")
        (geu:DI (match_dup 1) (match_dup 2)))]
-  "TARGET_POWERPC64 && reload_completed"
+  "TARGET_64BIT && reload_completed"
   [(set (match_dup 0)
        (geu:DI (match_dup 1) (match_dup 2)))
    (set (match_dup 3)
        (plus:SI (geu:SI (match_operand:SI 1 "gpc_reg_operand" "r,r")
                         (match_operand:SI 2 "reg_or_neg_short_operand" "r,P"))
                 (match_operand:SI 3 "gpc_reg_operand" "r,r")))]
-  "! TARGET_POWERPC64"
+  "TARGET_32BIT"
   "@
    {sf|subfc} %0,%2,%1\;{aze|addze} %0,%3
    {ai|addic} %0,%1,%n2\;{aze|addze} %0,%3"
-  [(set_attr "length" "8")])
+  [(set_attr "type" "two")
+   (set_attr "length" "8")])
 
 (define_insn ""
   [(set (match_operand:CC 0 "cc_reg_operand" "=x,x,?y,?y")
                  (match_operand:SI 3 "gpc_reg_operand" "r,r,r,r"))
         (const_int 0)))
    (clobber (match_scratch:SI 4 "=&r,&r,&r,&r"))]
-  "! TARGET_POWERPC64"
+  "TARGET_32BIT"
   "@
    {sf|subfc} %4,%2,%1\;{aze.|addze.} %4,%3
    {ai|addic} %4,%1,%n2\;{aze.|addze.} %4,%3
                  (match_operand:SI 3 "gpc_reg_operand" ""))
         (const_int 0)))
    (clobber (match_scratch:SI 4 ""))]
-  "! TARGET_POWERPC64 && reload_completed"
+  "TARGET_32BIT && reload_completed"
   [(set (match_dup 4)
        (plus:SI (geu:SI (match_dup 1) (match_dup 2))
                  (match_dup 3)))
         (const_int 0)))
    (set (match_operand:SI 0 "gpc_reg_operand" "=&r,&r,&r,&r")
        (plus:SI (geu:SI (match_dup 1) (match_dup 2)) (match_dup 3)))]
-  "! TARGET_POWERPC64"
+  "TARGET_32BIT"
   "@
    {sf|subfc} %0,%2,%1\;{aze.|addze.} %0,%3
    {ai|addic} %0,%1,%n2\;{aze.|addze.} %0,%3
         (const_int 0)))
    (set (match_operand:SI 0 "gpc_reg_operand" "")
        (plus:SI (geu:SI (match_dup 1) (match_dup 2)) (match_dup 3)))]
-  "! TARGET_POWERPC64 && reload_completed"
+  "TARGET_32BIT && reload_completed"
   [(set (match_dup 0)
        (plus:SI (geu:SI (match_dup 1) (match_dup 2)) (match_dup 3)))
    (set (match_dup 4)
   [(set (match_operand:SI 0 "gpc_reg_operand" "=r,r")
        (neg:SI (geu:SI (match_operand:SI 1 "gpc_reg_operand" "r,r")
                        (match_operand:SI 2 "reg_or_short_operand" "r,I"))))]
-  "! TARGET_POWERPC64"
+  "TARGET_32BIT"
   "@
    {sf|subfc} %0,%2,%1\;{sfe|subfe} %0,%0,%0\;nand %0,%0,%0
    {sfi|subfic} %0,%1,-1\;{a%I2|add%I2c} %0,%0,%2\;{sfe|subfe} %0,%0,%0"
-  [(set_attr "length" "12")])
+  [(set_attr "type" "three")
+   (set_attr "length" "12")])
 
 (define_insn ""
   [(set (match_operand:SI 0 "gpc_reg_operand" "=&r,&r")
                 (geu:SI (match_operand:SI 1 "gpc_reg_operand" "r,r")
                         (match_operand:SI 2 "reg_or_neg_short_operand" "r,P")))
                (match_operand:SI 3 "gpc_reg_operand" "r,r")))]
-  "! TARGET_POWERPC64"
+  "TARGET_32BIT"
   "@
    {sf|subfc} %0,%2,%1\;{sfe|subfe} %0,%0,%0\;andc %0,%3,%0
    {ai|addic} %0,%1,%n2\;{sfe|subfe} %0,%0,%0\;andc %0,%3,%0"
-  [(set_attr "length" "12")])
+  [(set_attr "type" "three")
+   (set_attr "length" "12")])
 
 (define_insn ""
   [(set (match_operand:CC 0 "cc_reg_operand" "=x,x,?y,?y")
                 (match_operand:SI 3 "gpc_reg_operand" "r,r,r,r"))
         (const_int 0)))
    (clobber (match_scratch:SI 4 "=&r,&r,&r,&r"))]
-  "! TARGET_POWERPC64"
+  "TARGET_32BIT"
   "@
    {sf|subfc} %4,%2,%1\;{sfe|subfe} %4,%4,%4\;andc. %4,%3,%4
    {ai|addic} %4,%1,%n2\;{sfe|subfe} %4,%4,%4\;andc. %4,%3,%4
                 (match_operand:SI 3 "gpc_reg_operand" ""))
         (const_int 0)))
    (clobber (match_scratch:SI 4 ""))]
-  "! TARGET_POWERPC64 && reload_completed"
+  "TARGET_32BIT && reload_completed"
   [(set (match_dup 4)
        (and:SI (neg:SI (geu:SI (match_dup 1) (match_dup 2)))
                (match_dup 3)))
         (const_int 0)))
    (set (match_operand:SI 0 "gpc_reg_operand" "=&r,&r,&r,&r")
        (and:SI (neg:SI (geu:SI (match_dup 1) (match_dup 2))) (match_dup 3)))]
-  "! TARGET_POWERPC64"
+  "TARGET_32BIT"
   "@
    {sf|subfc} %0,%2,%1\;{sfe|subfe} %0,%0,%0\;andc. %0,%3,%0
    {ai|addic} %0,%1,%n2\;{sfe|subfe} %0,%0,%0\;andc. %0,%3,%0
         (const_int 0)))
    (set (match_operand:SI 0 "gpc_reg_operand" "")
        (and:SI (neg:SI (geu:SI (match_dup 1) (match_dup 2))) (match_dup 3)))]
-  "! TARGET_POWERPC64 && reload_completed"
+  "TARGET_32BIT && reload_completed"
   [(set (match_dup 0)
        (and:SI (neg:SI (geu:SI (match_dup 1) (match_dup 2))) (match_dup 3)))
    (set (match_dup 4)
   [(set (match_operand:SI 0 "gpc_reg_operand" "=r")
        (gt:SI (match_operand:SI 1 "gpc_reg_operand" "r")
               (const_int 0)))]
-  "! TARGET_POWERPC64"
+  "TARGET_32BIT"
   "{sfi|subfic} %0,%1,0\;{ame|addme} %0,%0\;{sri|srwi} %0,%0,31"
-  [(set_attr "length" "12")])
+  [(set_attr "type" "three")
+   (set_attr "length" "12")])
 
 (define_insn ""
   [(set (match_operand:DI 0 "gpc_reg_operand" "=r")
        (gt:DI (match_operand:DI 1 "gpc_reg_operand" "r")
               (const_int 0)))]
-  "TARGET_POWERPC64"
+  "TARGET_64BIT"
   "subfic %0,%1,0\;addme %0,%0\;srdi %0,%0,63"
-  [(set_attr "length" "12")])
+  [(set_attr "type" "three")
+   (set_attr "length" "12")])
 
 (define_insn ""
   [(set (match_operand:CC 2 "cc_reg_operand" "=x,?y")
         (const_int 0)))
    (set (match_operand:SI 0 "gpc_reg_operand" "=r,r")
        (gt:SI (match_dup 1) (const_int 0)))]
-  "! TARGET_POWERPC64"
+  "TARGET_32BIT"
   "@
    {sfi|subfic} %0,%1,0\;{ame|addme} %0,%0\;{sri.|srwi.} %0,%0,31
    #"
         (const_int 0)))
    (set (match_operand:SI 0 "gpc_reg_operand" "")
        (gt:SI (match_dup 1) (const_int 0)))]
-  "! TARGET_POWERPC64 && reload_completed"
+  "TARGET_32BIT && reload_completed"
   [(set (match_dup 0)
        (gt:SI (match_dup 1) (const_int 0)))
    (set (match_dup 2)
         (const_int 0)))
    (set (match_operand:DI 0 "gpc_reg_operand" "=r,r")
        (gt:DI (match_dup 1) (const_int 0)))]
-  "TARGET_POWERPC64"
+  "TARGET_64BIT"
   "@
    subfic %0,%1,0\;addme %0,%0\;srdi. %0,%0,63
    #"
         (const_int 0)))
    (set (match_operand:DI 0 "gpc_reg_operand" "")
        (gt:DI (match_dup 1) (const_int 0)))]
-  "TARGET_POWERPC64 && reload_completed"
+  "TARGET_64BIT && reload_completed"
   [(set (match_dup 0)
        (gt:DI (match_dup 1) (const_int 0)))
    (set (match_dup 2)
        (plus:SI (gt:SI (match_operand:SI 1 "gpc_reg_operand" "r")
                        (const_int 0))
                 (match_operand:SI 2 "gpc_reg_operand" "r")))]
-  "! TARGET_POWERPC64"
+  "TARGET_32BIT"
   "{a|addc} %0,%1,%1\;{sfe|subfe} %0,%1,%0\;{aze|addze} %0,%2"
-  [(set_attr "length" "12")])
+  [(set_attr "type" "three")
+   (set_attr "length" "12")])
 
 (define_insn ""
   [(set (match_operand:DI 0 "gpc_reg_operand" "=&r")
        (plus:DI (gt:DI (match_operand:DI 1 "gpc_reg_operand" "r")
                        (const_int 0))
                 (match_operand:DI 2 "gpc_reg_operand" "r")))]
-  "TARGET_POWERPC64"
+  "TARGET_64BIT"
   "addc %0,%1,%1\;subfe %0,%1,%0\;addze %0,%2"
-  [(set_attr "length" "12")])
+  [(set_attr "type" "three")
+   (set_attr "length" "12")])
 
 (define_insn ""
   [(set (match_operand:CC 0 "cc_reg_operand" "=x,?y")
                  (match_operand:SI 2 "gpc_reg_operand" "r,r"))
         (const_int 0)))
    (clobber (match_scratch:SI 3 "=&r,&r"))]
-  "! TARGET_POWERPC64"
+  "TARGET_32BIT"
   "@
    {a|addc} %3,%1,%1\;{sfe|subfe} %3,%1,%3\;{aze.|addze.} %3,%2
    #"
                  (match_operand:SI 2 "gpc_reg_operand" ""))
         (const_int 0)))
    (clobber (match_scratch:SI 3 ""))]
-  "! TARGET_POWERPC64 && reload_completed"
+  "TARGET_32BIT && reload_completed"
   [(set (match_dup 3)
        (plus:SI (gt:SI (match_dup 1) (const_int 0))
                  (match_dup 2)))
                  (match_operand:DI 2 "gpc_reg_operand" "r,r"))
         (const_int 0)))
    (clobber (match_scratch:DI 3 "=&r,&r"))]
-  "TARGET_POWERPC64"
+  "TARGET_64BIT"
   "@
    addc %3,%1,%1\;subfe %3,%1,%3\;addze. %3,%2
    #"
                  (match_operand:DI 2 "gpc_reg_operand" ""))
         (const_int 0)))
    (clobber (match_scratch:DI 3 ""))]
-  "TARGET_POWERPC64 && reload_completed"
+  "TARGET_64BIT && reload_completed"
   [(set (match_dup 3)
        (plus:DI (gt:DI (match_dup 1) (const_int 0))
                 (match_dup 2)))
         (const_int 0)))
    (set (match_operand:SI 0 "gpc_reg_operand" "=&r,&r")
        (plus:SI (gt:SI (match_dup 1) (const_int 0)) (match_dup 2)))]
-  "! TARGET_POWERPC64"
+  "TARGET_32BIT"
   "@
    {a|addc} %0,%1,%1\;{sfe|subfe} %0,%1,%0\;{aze.|addze.} %0,%2
    #"
         (const_int 0)))
    (set (match_operand:SI 0 "gpc_reg_operand" "")
        (plus:SI (gt:SI (match_dup 1) (const_int 0)) (match_dup 2)))]
-  "! TARGET_POWERPC64 && reload_completed"
+  "TARGET_32BIT && reload_completed"
   [(set (match_dup 0)
        (plus:SI (gt:SI (match_dup 1) (const_int 0)) (match_dup 2)))
    (set (match_dup 3)
         (const_int 0)))
    (set (match_operand:DI 0 "gpc_reg_operand" "=&r,&r")
        (plus:DI (gt:DI (match_dup 1) (const_int 0)) (match_dup 2)))]
-  "TARGET_POWERPC64"
+  "TARGET_64BIT"
   "@
    addc %0,%1,%1\;subfe %0,%1,%0\;addze. %0,%2
    #"
         (const_int 0)))
    (set (match_operand:DI 0 "gpc_reg_operand" "")
        (plus:DI (gt:DI (match_dup 1) (const_int 0)) (match_dup 2)))]
-  "TARGET_POWERPC64 && reload_completed"
+  "TARGET_64BIT && reload_completed"
   [(set (match_dup 0)
        (plus:DI (gt:DI (match_dup 1) (const_int 0)) (match_dup 2)))
    (set (match_dup 3)
   [(set (match_operand:SI 0 "gpc_reg_operand" "=r")
        (neg:SI (gt:SI (match_operand:SI 1 "gpc_reg_operand" "r")
                       (const_int 0))))]
-  "! TARGET_POWERPC64"
+  "TARGET_32BIT"
   "{sfi|subfic} %0,%1,0\;{ame|addme} %0,%0\;{srai|srawi} %0,%0,31"
-  [(set_attr "length" "12")])
+  [(set_attr "type" "three")
+   (set_attr "length" "12")])
 
 (define_insn ""
   [(set (match_operand:DI 0 "gpc_reg_operand" "=r")
        (neg:DI (gt:DI (match_operand:DI 1 "gpc_reg_operand" "r")
                       (const_int 0))))]
-  "TARGET_POWERPC64"
+  "TARGET_64BIT"
   "subfic %0,%1,0\;addme %0,%0\;sradi %0,%0,63"
-  [(set_attr "length" "12")])
+  [(set_attr "type" "three")
+   (set_attr "length" "12")])
 
 (define_insn ""
   [(set (match_operand:SI 0 "gpc_reg_operand" "=r")
   "doz %0,%2,%1\;nabs %0,%0\;{srai|srawi} %0,%0,31"
   [(set_attr "length" "12")])
 
-(define_insn ""
+(define_insn_and_split ""
   [(set (match_operand:SI 0 "gpc_reg_operand" "=r")
-       (gtu:SI (match_operand:SI 1 "gpc_reg_operand" "r")
-               (match_operand:SI 2 "reg_or_short_operand" "rI")))]
-  "! TARGET_POWERPC64"
-  "{sf%I2|subf%I2c} %0,%1,%2\;{sfe|subfe} %0,%0,%0\;neg %0,%0"
-  [(set_attr "length" "12")])
+        (gtu:SI (match_operand:SI 1 "gpc_reg_operand" "r")
+                (match_operand:SI 2 "reg_or_short_operand" "rI")))]
+  "TARGET_32BIT"
+  "#"
+  "TARGET_32BIT"
+  [(set (match_dup 0) (neg:SI (gtu:SI (match_dup 1) (match_dup 2))))
+   (set (match_dup 0) (neg:SI (match_dup 0)))]
+  "")
 
-(define_insn ""
+(define_insn_and_split ""
   [(set (match_operand:DI 0 "gpc_reg_operand" "=r")
-       (gtu:DI (match_operand:DI 1 "gpc_reg_operand" "r")
-               (match_operand:DI 2 "reg_or_short_operand" "rI")))]
-  "TARGET_POWERPC64"
-  "subf%I2c %0,%1,%2\;subfe %0,%0,%0\;neg %0,%0"
-  [(set_attr "length" "12")])
+        (gtu:DI (match_operand:DI 1 "gpc_reg_operand" "r")
+                (match_operand:DI 2 "reg_or_short_operand" "rI")))]
+  "TARGET_64BIT"
+  "#"
+  "TARGET_64BIT"
+  [(set (match_dup 0) (neg:DI (gtu:DI (match_dup 1) (match_dup 2))))
+   (set (match_dup 0) (neg:DI (match_dup 0)))]
+  "")
 
 (define_insn ""
   [(set (match_operand:CC 3 "cc_reg_operand" "=x,?y")
         (const_int 0)))
    (set (match_operand:SI 0 "gpc_reg_operand" "=r,r")
        (gtu:SI (match_dup 1) (match_dup 2)))]
-  "! TARGET_POWERPC64"
+  "TARGET_32BIT"
   "@
    {sf%I2|subf%I2c} %0,%1,%2\;{sfe|subfe} %0,%0,%0\;neg. %0,%0
    #"
         (const_int 0)))
    (set (match_operand:SI 0 "gpc_reg_operand" "")
        (gtu:SI (match_dup 1) (match_dup 2)))]
-  "! TARGET_POWERPC64 && reload_completed"
+  "TARGET_32BIT && reload_completed"
   [(set (match_dup 0)
        (gtu:SI (match_dup 1) (match_dup 2)))
    (set (match_dup 3)
         (const_int 0)))
    (set (match_operand:DI 0 "gpc_reg_operand" "=r,r")
        (gtu:DI (match_dup 1) (match_dup 2)))]
-  "TARGET_POWERPC64"
+  "TARGET_64BIT"
   "@
    subf%I2c %0,%1,%2\;subfe %0,%0,%0\;neg. %0,%0
    #"
         (const_int 0)))
    (set (match_operand:DI 0 "gpc_reg_operand" "")
        (gtu:DI (match_dup 1) (match_dup 2)))]
-  "TARGET_POWERPC64 && reload_completed"
+  "TARGET_64BIT && reload_completed"
   [(set (match_dup 0)
        (gtu:DI (match_dup 1) (match_dup 2)))
    (set (match_dup 3)
                    (const_int 0)))]
   "")
 
-(define_insn ""
-  [(set (match_operand:SI 0 "gpc_reg_operand" "=&r,&r")
-       (plus:SI (gtu:SI (match_operand:SI 1 "gpc_reg_operand" "r,r")
-                        (match_operand:SI 2 "reg_or_short_operand" "I,rI"))
-                (match_operand:SI 3 "reg_or_short_operand" "r,rI")))]
-  "! TARGET_POWERPC64"
-  "@
-   {ai|addic} %0,%1,%k2\;{aze|addze} %0,%3
-   {sf%I2|subf%I2c} %0,%1,%2\;{sfe|subfe} %0,%0,%0\;{sf%I3|subf%I3c} %0,%0,%3"
-  [(set_attr "length" "8,12")])
+(define_insn_and_split ""
+  [(set (match_operand:SI 0 "gpc_reg_operand" "=&r")
+        (plus:SI (gtu:SI (match_operand:SI 1 "gpc_reg_operand" "r")
+                         (match_operand:SI 2 "reg_or_short_operand" "rI"))
+                 (match_operand:SI 3 "reg_or_short_operand" "rI")))]
+  "TARGET_32BIT"
+  "#"
+  "&& !reg_overlap_mentioned_p (operands[0], operands[3])"
+  [(set (match_dup 0) (neg:SI (gtu:SI (match_dup 1) (match_dup 2))))
+   (set (match_dup 0) (minus:SI (match_dup 3) (match_dup 0)))]
+  "")
 
-(define_insn ""
-  [(set (match_operand:DI 0 "gpc_reg_operand" "=&r,&r")
-       (plus:DI (gtu:DI (match_operand:DI 1 "gpc_reg_operand" "r,r")
-                        (match_operand:DI 2 "reg_or_short_operand" "I,rI"))
-                (match_operand:DI 3 "reg_or_short_operand" "r,rI")))]
-  "TARGET_POWERPC64"
-  "@
-   addic %0,%1,%k2\;addze %0,%3
-   subf%I2c %0,%1,%2\;subfe %0,%0,%0\;subf%I3c %0,%0,%3"
-  [(set_attr "length" "8,12")])
+(define_insn_and_split ""
+  [(set (match_operand:DI 0 "gpc_reg_operand" "=&r")
+        (plus:DI (gtu:DI (match_operand:DI 1 "gpc_reg_operand" "r")
+                         (match_operand:DI 2 "reg_or_short_operand" "rI"))
+                 (match_operand:DI 3 "reg_or_short_operand" "rI")))]
+  "TARGET_64BIT"
+  "#"
+  "&& !reg_overlap_mentioned_p (operands[0], operands[3])"
+  [(set (match_dup 0) (neg:DI (gtu:DI (match_dup 1) (match_dup 2))))
+   (set (match_dup 0) (minus:DI (match_dup 3) (match_dup 0)))]
+  "")
 
 (define_insn ""
   [(set (match_operand:CC 0 "cc_reg_operand" "=x,x,?y,?y")
                  (match_operand:SI 3 "gpc_reg_operand" "r,r,r,r"))
         (const_int 0)))
    (clobber (match_scratch:SI 4 "=&r,&r,&r,&r"))]
-  "! TARGET_POWERPC64"
+  "TARGET_32BIT"
   "@
    {ai|addic} %4,%1,%k2\;{aze.|addze.} %4,%3
-   {sf%I2|subf%I2c} %4,%1,%2\;{sfe|subfe} %4,%4,%4\;{sf.|subfc.} %4,%4,%3
+   {sf%I2|subf%I2c} %4,%1,%2\;{sfe|subfe} %4,%4,%4\;{sf.|subf.} %4,%4,%3
    #
    #"
   [(set_attr "type" "compare")
                  (match_operand:SI 3 "gpc_reg_operand" ""))
         (const_int 0)))
    (clobber (match_scratch:SI 4 ""))]
-  "! TARGET_POWERPC64 && reload_completed"
+  "TARGET_32BIT && reload_completed"
   [(set (match_dup 4)
        (plus:SI (gtu:SI (match_dup 1) (match_dup 2))
                 (match_dup 3)))
                  (match_operand:DI 3 "gpc_reg_operand" "r,r,r,r"))
         (const_int 0)))
    (clobber (match_scratch:DI 4 "=&r,&r,&r,&r"))]
-  "TARGET_POWERPC64"
+  "TARGET_64BIT"
   "@
    addic %4,%1,%k2\;addze. %4,%3
-   subf%I2c %4,%1,%2\;subfe %4,%4,%4\;subfc. %4,%4,%3
+   subf%I2c %4,%1,%2\;subfe %4,%4,%4\;subf. %4,%4,%3
    #
    #"
   [(set_attr "type" "compare")
                  (match_operand:DI 3 "gpc_reg_operand" ""))
         (const_int 0)))
    (clobber (match_scratch:DI 4 ""))]
-  "TARGET_POWERPC64 && reload_completed"
+  "TARGET_64BIT && reload_completed"
   [(set (match_dup 4)
        (plus:DI (gtu:DI (match_dup 1) (match_dup 2))
                  (match_dup 3)))
         (const_int 0)))
    (set (match_operand:SI 0 "gpc_reg_operand" "=&r,&r,&r,&r")
        (plus:SI (gtu:SI (match_dup 1) (match_dup 2)) (match_dup 3)))]
-  "! TARGET_POWERPC64"
+  "TARGET_32BIT"
   "@
    {ai|addic} %0,%1,%k2\;{aze.|addze.} %0,%3
-   {sf%I2|subf%I2c} %0,%1,%2\;{sfe|subfe} %0,%0,%0\;{sf.|subfc.} %0,%0,%3
+   {sf%I2|subf%I2c} %0,%1,%2\;{sfe|subfe} %0,%0,%0\;{sf.|subf.} %0,%0,%3
    #
    #"
   [(set_attr "type" "compare")
         (const_int 0)))
    (set (match_operand:SI 0 "gpc_reg_operand" "")
        (plus:SI (gtu:SI (match_dup 1) (match_dup 2)) (match_dup 3)))]
-  "! TARGET_POWERPC64 && reload_completed"
+  "TARGET_32BIT && reload_completed"
   [(set (match_dup 0)
        (plus:SI (gtu:SI (match_dup 1) (match_dup 2)) (match_dup 3)))
    (set (match_dup 4)
         (const_int 0)))
    (set (match_operand:DI 0 "gpc_reg_operand" "=&r,&r,&r,&r")
        (plus:DI (gtu:DI (match_dup 1) (match_dup 2)) (match_dup 3)))]
-  "TARGET_POWERPC64"
+  "TARGET_64BIT"
   "@
    addic %0,%1,%k2\;addze. %0,%3
-   subf%I2c %0,%1,%2\;subfe %0,%0,%0\;subfc. %0,%0,%3
+   subf%I2c %0,%1,%2\;subfe %0,%0,%0\;subf. %0,%0,%3
    #
    #"
   [(set_attr "type" "compare")
         (const_int 0)))
    (set (match_operand:DI 0 "gpc_reg_operand" "")
        (plus:DI (gtu:DI (match_dup 1) (match_dup 2)) (match_dup 3)))]
-  "TARGET_POWERPC64 && reload_completed"
+  "TARGET_64BIT && reload_completed"
   [(set (match_dup 0)
        (plus:DI (gtu:DI (match_dup 1) (match_dup 2)) (match_dup 3)))
    (set (match_dup 4)
   [(set (match_operand:SI 0 "gpc_reg_operand" "=r")
        (neg:SI (gtu:SI (match_operand:SI 1 "gpc_reg_operand" "r")
                        (match_operand:SI 2 "reg_or_short_operand" "rI"))))]
-  "! TARGET_POWERPC64"
+  "TARGET_32BIT"
   "{sf%I2|subf%I2c} %0,%1,%2\;{sfe|subfe} %0,%0,%0"
-  [(set_attr "length" "8")])
+  [(set_attr "type" "two")
+   (set_attr "length" "8")])
 
 (define_insn ""
   [(set (match_operand:DI 0 "gpc_reg_operand" "=r")
        (neg:DI (gtu:DI (match_operand:DI 1 "gpc_reg_operand" "r")
                        (match_operand:DI 2 "reg_or_short_operand" "rI"))))]
-  "TARGET_POWERPC64"
+  "TARGET_64BIT"
   "subf%I2c %0,%1,%2\;subfe %0,%0,%0"
-  [(set_attr "length" "8")])
+  [(set_attr "type" "two")
+   (set_attr "length" "8")])
 \f
 ;; Define both directions of branch and return.  If we need a reload
 ;; register, we'd rather use CR0 since it is much easier to copy a
 ; which are generated by the branch logic.
 ; Prefer destructive operations where BT = BB (for crXX BT,BA,BB)
 
-(define_insn ""
+(define_insn "*cceq_ior_compare"
   [(set (match_operand:CCEQ 0 "cc_reg_operand" "=y,?y")
         (compare:CCEQ (match_operator:SI 1 "boolean_operator"
                        [(match_operator:SI 2
   "cr%q1 %E0,%j2,%j4"
   [(set_attr "type" "cr_logical,delayed_cr")])
 
-(define_insn ""
+(define_insn "*cceq_rev_compare"
   [(set (match_operand:CCEQ 0 "cc_reg_operand" "=y,?y")
        (compare:CCEQ (match_operator:SI 1
                                      "branch_positive_comparison_operator"
                                                      "cc_reg_operand" "0,y")
                                       (const_int 0)])
                      (const_int 0)))]
-  "!TARGET_SPE"
+  ""
   "{crnor %E0,%j1,%j1|crnot %E0,%j1}"
   [(set_attr "type" "cr_logical,delayed_cr")])
 
 {
   int positive_1, positive_2;
 
-  positive_1 = branch_positive_comparison_operator (operands[1], CCEQmode);
-  positive_2 = branch_positive_comparison_operator (operands[3], CCEQmode);
+  positive_1 = branch_positive_comparison_operator (operands[1],
+                                                   GET_MODE (operands[1]));
+  positive_2 = branch_positive_comparison_operator (operands[3],
+                                                   GET_MODE (operands[3]));
 
   if (! positive_1)
-    operands[1] = gen_rtx (rs6000_reverse_condition (GET_MODE (operands[2]),
-                                                    GET_CODE (operands[1])),
-                          SImode,
-                          operands[2], const0_rtx);
+    operands[1] = gen_rtx_fmt_ee (rs6000_reverse_condition (GET_MODE (operands[2]),
+                                                           GET_CODE (operands[1])),
+                                 SImode,
+                                 operands[2], const0_rtx);
   else if (GET_MODE (operands[1]) != SImode)
-    operands[1] = gen_rtx (GET_CODE (operands[1]),
-                          SImode,
-                          operands[2], const0_rtx);
+    operands[1] = gen_rtx_fmt_ee (GET_CODE (operands[1]), SImode,
+                                 operands[2], const0_rtx);
 
   if (! positive_2)
-    operands[3] = gen_rtx (rs6000_reverse_condition (GET_MODE (operands[4]),
-                                                    GET_CODE (operands[3])),
-                          SImode,
-                          operands[4], const0_rtx);
+    operands[3] = gen_rtx_fmt_ee (rs6000_reverse_condition (GET_MODE (operands[4]),
+                                                           GET_CODE (operands[3])),
+                                 SImode,
+                                 operands[4], const0_rtx);
   else if (GET_MODE (operands[3]) != SImode)
-    operands[3] = gen_rtx (GET_CODE (operands[3]),
-                          SImode,
-                          operands[4], const0_rtx);
+    operands[3] = gen_rtx_fmt_ee (GET_CODE (operands[3]), SImode,
+                                 operands[4], const0_rtx);
 
   if (positive_1 == positive_2)
     {
 }")
 
 (define_expand "tablejumpdi"
-  [(set (match_dup 4) 
+  [(set (match_dup 4)
         (sign_extend:DI (match_operand:SI 0 "lwa_operand" "rm")))
    (set (match_dup 3)
        (plus:DI (match_dup 4)
   /* Only use this on innermost loops.  */
   if (INTVAL (operands[3]) > 1)
     FAIL;
-  if (TARGET_POWERPC64)
+  if (TARGET_64BIT)
     {
       if (GET_MODE (operands[0]) != DImode)
        FAIL;
                            (const_int -1)))
              (clobber (match_scratch:CC 2 ""))
              (clobber (match_scratch:SI 3 ""))])]
-  "! TARGET_POWERPC64"
+  "TARGET_32BIT"
   "")
 
 (define_expand "ctrdi"
                            (const_int -1)))
              (clobber (match_scratch:CC 2 ""))
              (clobber (match_scratch:DI 3 ""))])]
-  "TARGET_POWERPC64"
+  "TARGET_64BIT"
   "")
 
 ;; We need to be able to do this for any operand, including MEM, or we
                          (const_int 1))
                      (label_ref (match_operand 0 "" ""))
                      (pc)))
-   (set (match_operand:SI 2 "register_operand" "=1,*r,m,*q*c*l")
+   (set (match_operand:SI 2 "nonimmediate_operand" "=1,*r,m,*q*c*l")
        (plus:SI (match_dup 1)
                 (const_int -1)))
    (clobber (match_scratch:CC 3 "=X,&x,&x,&x"))
    (clobber (match_scratch:SI 4 "=X,X,&r,r"))]
-  "! TARGET_POWERPC64"
+  "TARGET_32BIT"
   "*
 {
   if (which_alternative != 0)
     return \"bdz $+8\;b %l0\";
 }"
   [(set_attr "type" "branch")
-   (set_attr "length" "4,12,16,16")])
+   (set_attr "length" "*,12,16,16")])
 
 (define_insn "*ctrsi_internal2"
   [(set (pc)
                          (const_int 1))
                      (pc)
                      (label_ref (match_operand 0 "" ""))))
-   (set (match_operand:SI 2 "register_operand" "=1,*r,m,*q*c*l")
+   (set (match_operand:SI 2 "nonimmediate_operand" "=1,*r,m,*q*c*l")
        (plus:SI (match_dup 1)
                 (const_int -1)))
    (clobber (match_scratch:CC 3 "=X,&x,&x,&x"))
    (clobber (match_scratch:SI 4 "=X,X,&r,r"))]
-  "! TARGET_POWERPC64"
+  "TARGET_32BIT"
   "*
 {
   if (which_alternative != 0)
     return \"{bdn|bdnz} $+8\;b %l0\";
 }"
   [(set_attr "type" "branch")
-   (set_attr "length" "4,12,16,16")])
+   (set_attr "length" "*,12,16,16")])
 
 (define_insn "*ctrdi_internal1"
   [(set (pc)
                          (const_int 1))
                      (label_ref (match_operand 0 "" ""))
                      (pc)))
-   (set (match_operand:DI 2 "register_operand" "=1,*r,m,*c*l")
+   (set (match_operand:DI 2 "nonimmediate_operand" "=1,*r,m,*c*l")
        (plus:DI (match_dup 1)
                 (const_int -1)))
    (clobber (match_scratch:CC 3 "=X,&x,&x,&x"))
    (clobber (match_scratch:DI 4 "=X,X,&r,r"))]
-  "TARGET_POWERPC64"
+  "TARGET_64BIT"
   "*
 {
   if (which_alternative != 0)
     return \"bdz $+8\;b %l0\";
 }"
   [(set_attr "type" "branch")
-   (set_attr "length" "4,12,16,16")])
+   (set_attr "length" "*,12,16,16")])
 
 (define_insn "*ctrdi_internal2"
   [(set (pc)
                          (const_int 1))
                      (pc)
                      (label_ref (match_operand 0 "" ""))))
-   (set (match_operand:DI 2 "register_operand" "=1,*r,m,*c*l")
-       (plus:DI (match_dup 1)
-                (const_int -1)))
-   (clobber (match_scratch:CC 3 "=X,&x,&x,&x"))
-   (clobber (match_scratch:DI 4 "=X,X,&r,r"))]
-  "TARGET_POWERPC64"
-  "*
-{
-  if (which_alternative != 0)
-    return \"#\";
-  else if (get_attr_length (insn) == 4)
-    return \"bdz %l0\";
-  else
-    return \"{bdn|bdnz} $+8\;b %l0\";
-}"
-  [(set_attr "type" "branch")
-   (set_attr "length" "4,12,16,16")])
-
-;; Similar, but we can use GE since we have a REG_NONNEG.
-
-(define_insn "*ctrsi_internal3"
-  [(set (pc)
-       (if_then_else (ge (match_operand:SI 1 "register_operand" "c,*r,*r,*r")
-                         (const_int 0))
-                     (label_ref (match_operand 0 "" ""))
-                     (pc)))
-   (set (match_operand:SI 2 "register_operand" "=1,*r,m,*q*c*l")
-       (plus:SI (match_dup 1)
-                (const_int -1)))
-   (clobber (match_scratch:CC 3 "=X,&x,&x,&x"))
-   (clobber (match_scratch:SI 4 "=X,X,&r,r"))]
-  "! TARGET_POWERPC64 && find_reg_note (insn, REG_NONNEG, 0)"
-  "*
-{
-  if (which_alternative != 0)
-    return \"#\";
-  else if (get_attr_length (insn) == 4)
-    return \"{bdn|bdnz} %l0\";
-  else
-    return \"bdz $+8\;b %l0\";
-}"
-  [(set_attr "type" "branch")
-   (set_attr "length" "4,12,16,16")])
-
-(define_insn "*ctrsi_internal4"
-  [(set (pc)
-       (if_then_else (ge (match_operand:SI 1 "register_operand" "c,*r,*r,*r")
-                         (const_int 0))
-                     (pc)
-                     (label_ref (match_operand 0 "" ""))))
-   (set (match_operand:SI 2 "register_operand" "=1,*r,m,*q*c*l")
-       (plus:SI (match_dup 1)
-                (const_int -1)))
-   (clobber (match_scratch:CC 3 "=X,&x,&x,&x"))
-   (clobber (match_scratch:SI 4 "=X,X,&r,r"))]
-  "! TARGET_POWERPC64 && find_reg_note (insn, REG_NONNEG, 0)"
-  "*
-{
-  if (which_alternative != 0)
-    return \"#\";
-  else if (get_attr_length (insn) == 4)
-    return \"bdz %l0\";
-  else
-    return \"{bdn|bdnz} $+8\;b %l0\";
-}"
-  [(set_attr "type" "branch")
-   (set_attr "length" "4,12,16,16")])
-
-(define_insn "*ctrdi_internal3"
-  [(set (pc)
-       (if_then_else (ge (match_operand:DI 1 "register_operand" "c,*r,*r,*r")
-                         (const_int 0))
-                     (label_ref (match_operand 0 "" ""))
-                     (pc)))
-   (set (match_operand:DI 2 "register_operand" "=1,*r,m,*c*l")
-       (plus:DI (match_dup 1)
-                (const_int -1)))
-   (clobber (match_scratch:CC 3 "=X,&x,&x,&x"))
-   (clobber (match_scratch:DI 4 "=X,X,&r,r"))]
-  "TARGET_POWERPC64 && find_reg_note (insn, REG_NONNEG, 0)"
-  "*
-{
-  if (which_alternative != 0)
-    return \"#\";
-  else if (get_attr_length (insn) == 4)
-    return \"{bdn|bdnz} %l0\";
-  else
-    return \"bdz $+8\;b %l0\";
-}"
-  [(set_attr "type" "branch")
-   (set_attr "length" "4,12,16,16")])
-
-(define_insn "*ctrdi_internal4"
-  [(set (pc)
-       (if_then_else (ge (match_operand:DI 1 "register_operand" "c,*r,*r,*r")
-                         (const_int 0))
-                     (pc)
-                     (label_ref (match_operand 0 "" ""))))
-   (set (match_operand:DI 2 "register_operand" "=1,*r,m,*c*l")
+   (set (match_operand:DI 2 "nonimmediate_operand" "=1,*r,m,*c*l")
        (plus:DI (match_dup 1)
                 (const_int -1)))
    (clobber (match_scratch:CC 3 "=X,&x,&x,&x"))
    (clobber (match_scratch:DI 4 "=X,X,&r,r"))]
-  "TARGET_POWERPC64 && find_reg_note (insn, REG_NONNEG, 0)"
+  "TARGET_64BIT"
   "*
 {
   if (which_alternative != 0)
     return \"{bdn|bdnz} $+8\;b %l0\";
 }"
   [(set_attr "type" "branch")
-   (set_attr "length" "4,12,16,16")])
+   (set_attr "length" "*,12,16,16")])
 
 ;; Similar but use EQ
 
                          (const_int 1))
                      (label_ref (match_operand 0 "" ""))
                      (pc)))
-   (set (match_operand:SI 2 "register_operand" "=1,*r,m,*q*c*l")
+   (set (match_operand:SI 2 "nonimmediate_operand" "=1,*r,m,*q*c*l")
        (plus:SI (match_dup 1)
                 (const_int -1)))
    (clobber (match_scratch:CC 3 "=X,&x,&x,&x"))
    (clobber (match_scratch:SI 4 "=X,X,&r,r"))]
-  "! TARGET_POWERPC64"
+  "TARGET_32BIT"
   "*
 {
   if (which_alternative != 0)
     return \"{bdn|bdnz} $+8\;b %l0\";
 }"
   [(set_attr "type" "branch")
-   (set_attr "length" "4,12,16,16")])
+   (set_attr "length" "*,12,16,16")])
 
 (define_insn "*ctrsi_internal6"
   [(set (pc)
                          (const_int 1))
                      (pc)
                      (label_ref (match_operand 0 "" ""))))
-   (set (match_operand:SI 2 "register_operand" "=1,*r,m,*q*c*l")
+   (set (match_operand:SI 2 "nonimmediate_operand" "=1,*r,m,*q*c*l")
        (plus:SI (match_dup 1)
                 (const_int -1)))
    (clobber (match_scratch:CC 3 "=X,&x,&x,&x"))
    (clobber (match_scratch:SI 4 "=X,X,&r,r"))]
-  "! TARGET_POWERPC64"
+  "TARGET_32BIT"
   "*
 {
   if (which_alternative != 0)
     return \"bdz $+8\;b %l0\";
 }"
   [(set_attr "type" "branch")
-   (set_attr "length" "4,12,16,16")])
+   (set_attr "length" "*,12,16,16")])
 
 (define_insn "*ctrdi_internal5"
   [(set (pc)
                          (const_int 1))
                      (label_ref (match_operand 0 "" ""))
                      (pc)))
-   (set (match_operand:DI 2 "register_operand" "=1,*r,m,*c*l")
+   (set (match_operand:DI 2 "nonimmediate_operand" "=1,*r,m,*c*l")
        (plus:DI (match_dup 1)
                 (const_int -1)))
    (clobber (match_scratch:CC 3 "=X,&x,&x,&x"))
    (clobber (match_scratch:DI 4 "=X,X,&r,r"))]
-  "TARGET_POWERPC64"
+  "TARGET_64BIT"
   "*
 {
   if (which_alternative != 0)
     return \"{bdn|bdnz} $+8\;b %l0\";
 }"
   [(set_attr "type" "branch")
-   (set_attr "length" "4,12,16,16")])
+   (set_attr "length" "*,12,16,16")])
 
 (define_insn "*ctrdi_internal6"
   [(set (pc)
                          (const_int 1))
                      (pc)
                      (label_ref (match_operand 0 "" ""))))
-   (set (match_operand:DI 2 "register_operand" "=1,*r,m,*c*l")
+   (set (match_operand:DI 2 "nonimmediate_operand" "=1,*r,m,*c*l")
        (plus:DI (match_dup 1)
                 (const_int -1)))
    (clobber (match_scratch:CC 3 "=X,&x,&x,&x"))
    (clobber (match_scratch:DI 4 "=X,X,&r,r"))]
-  "TARGET_POWERPC64"
+  "TARGET_64BIT"
   "*
 {
   if (which_alternative != 0)
     return \"bdz $+8\;b %l0\";
 }"
   [(set_attr "type" "branch")
-   (set_attr "length" "4,12,16,16")])
+   (set_attr "length" "*,12,16,16")])
 
 ;; Now the splitters if we could not allocate the CTR register
 
                 (const_int -1)))
    (clobber (match_scratch:CC 3 ""))
    (clobber (match_scratch:SI 4 ""))]
-  "! TARGET_POWERPC64 && reload_completed"
+  "TARGET_32BIT && reload_completed"
   [(parallel [(set (match_dup 3)
                   (compare:CC (plus:SI (match_dup 1)
                                        (const_int -1))
                           (match_dup 5)
                           (match_dup 6)))]
   "
-{ operands[7] = gen_rtx (GET_CODE (operands[2]), VOIDmode, operands[3],
-                        const0_rtx); }")
+{ operands[7] = gen_rtx_fmt_ee (GET_CODE (operands[2]), VOIDmode,
+                               operands[3], const0_rtx); }")
 
 (define_split
   [(set (pc)
        (plus:SI (match_dup 1) (const_int -1)))
    (clobber (match_scratch:CC 3 ""))
    (clobber (match_scratch:SI 4 ""))]
-  "! TARGET_POWERPC64 && reload_completed
+  "TARGET_32BIT && reload_completed
    && ! gpc_reg_operand (operands[0], SImode)"
   [(parallel [(set (match_dup 3)
                   (compare:CC (plus:SI (match_dup 1)
                           (match_dup 5)
                           (match_dup 6)))]
   "
-{ operands[7] = gen_rtx (GET_CODE (operands[2]), VOIDmode, operands[3],
-                        const0_rtx); }")
+{ operands[7] = gen_rtx_fmt_ee (GET_CODE (operands[2]), VOIDmode,
+                               operands[3], const0_rtx); }")
 (define_split
   [(set (pc)
        (if_then_else (match_operator 2 "comparison_operator"
                 (const_int -1)))
    (clobber (match_scratch:CC 3 ""))
    (clobber (match_scratch:DI 4 ""))]
-  "TARGET_POWERPC64 && reload_completed"
+  "TARGET_64BIT && reload_completed"
   [(parallel [(set (match_dup 3)
                   (compare:CC (plus:DI (match_dup 1)
                                        (const_int -1))
                           (match_dup 5)
                           (match_dup 6)))]
   "
-{ operands[7] = gen_rtx (GET_CODE (operands[2]), VOIDmode, operands[3],
-                        const0_rtx); }")
+{ operands[7] = gen_rtx_fmt_ee (GET_CODE (operands[2]), VOIDmode,
+                               operands[3], const0_rtx); }")
 
 (define_split
   [(set (pc)
        (plus:DI (match_dup 1) (const_int -1)))
    (clobber (match_scratch:CC 3 ""))
    (clobber (match_scratch:DI 4 ""))]
-  "TARGET_POWERPC64 && reload_completed
+  "TARGET_64BIT && reload_completed
    && ! gpc_reg_operand (operands[0], DImode)"
   [(parallel [(set (match_dup 3)
                   (compare:CC (plus:DI (match_dup 1)
                           (match_dup 5)
                           (match_dup 6)))]
   "
-{ operands[7] = gen_rtx (GET_CODE (operands[2]), VOIDmode, operands[3],
-                        const0_rtx); }")
-
+{ operands[7] = gen_rtx_fmt_ee (GET_CODE (operands[2]), VOIDmode,
+                               operands[3], const0_rtx); }")
 \f
 (define_insn "trap"
   [(trap_if (const_int 1) (const_int 0))]
 
 (define_insn "movesi_from_cr"
   [(set (match_operand:SI 0 "gpc_reg_operand" "=r")
-        (unspec:SI [(reg:CC 68) (reg:CC 69) (reg:CC 70) (reg:CC 71) 
+        (unspec:SI [(reg:CC 68) (reg:CC 69) (reg:CC 70) (reg:CC 71)
                    (reg:CC 72) (reg:CC 73) (reg:CC 74) (reg:CC 75)]
                   UNSPEC_MOVESI_FROM_CR))]
   ""
                                 (match_operand:SI 2 "gpc_reg_operand" "r"))])]
   "TARGET_MULTIPLE"
   "{stm|stmw} %2,%1")
+
 (define_insn "*save_fpregs_si"
-  [(match_parallel 0 "any_operand"
+  [(match_parallel 0 "any_parallel_operand"
                   [(clobber (match_operand:SI 1 "register_operand" "=l"))
                    (use (match_operand:SI 2 "call_operand" "s"))
                    (set (match_operand:DF 3 "memory_operand" "=m")
    (set_attr "length" "4")])
 
 (define_insn "*save_fpregs_di"
-  [(match_parallel 0 "any_operand"
+  [(match_parallel 0 "any_parallel_operand"
                   [(clobber (match_operand:DI 1 "register_operand" "=l"))
                    (use (match_operand:DI 2 "call_operand" "s"))
                    (set (match_operand:DF 3 "memory_operand" "=m")
         (unspec:CC [(match_operand:SI 1 "gpc_reg_operand" "r")
                    (match_operand 2 "immediate_operand" "n")]
                   UNSPEC_MOVESI_TO_CR))]
-  "GET_CODE (operands[0]) == REG 
+  "GET_CODE (operands[0]) == REG
    && CR_REGNO_P (REGNO (operands[0]))
    && GET_CODE (operands[2]) == CONST_INT
    && INTVAL (operands[2]) == 1 << (75 - REGNO (operands[0]))"
                                 (match_operand:SI 2 "memory_operand" "m"))])]
   "TARGET_MULTIPLE"
   "{lm|lmw} %1,%2")
+
 (define_insn "*return_internal_si"
   [(return)
    (use (match_operand:SI 0 "register_operand" "lc"))]
   [(set_attr "type" "jmpreg")])
 
 ; FIXME: This would probably be somewhat simpler if the Cygnus sibcall
-; stuff was in GCC.  Oh, and "any_operand" is a bit flexible...
+; stuff was in GCC.  Oh, and "any_parallel_operand" is a bit flexible...
 
 (define_insn "*return_and_restore_fpregs_si"
- [(match_parallel 0 "any_operand"
+ [(match_parallel 0 "any_parallel_operand"
                   [(return)
                   (use (match_operand:SI 1 "register_operand" "l"))
                   (use (match_operand:SI 2 "call_operand" "s"))
  "b %z2")
 
 (define_insn "*return_and_restore_fpregs_di"
- [(match_parallel 0 "any_operand"
+ [(match_parallel 0 "any_parallel_operand"
                   [(return)
                   (use (match_operand:DI 1 "register_operand" "l"))
                   (use (match_operand:DI 2 "call_operand" "s"))
   [(const_int 0)]
   "
 {
-  rs6000_stack_t *info = rs6000_stack_info ();
-
-  if (info->lr_save_p)
-    {
-      rtx frame_rtx = stack_pointer_rtx;
-      int sp_offset = 0;
-      rtx tmp;
-
-      if (frame_pointer_needed
-         || current_function_calls_alloca
-         || info->total_size > 32767)
-       {
-         emit_move_insn (operands[1], gen_rtx_MEM (Pmode, frame_rtx));
-         frame_rtx = operands[1];
-       }
-      else if (info->push_p)
-       sp_offset = info->total_size;
-
-      tmp = plus_constant (frame_rtx, info->lr_save_offset + sp_offset);
-      tmp = gen_rtx_MEM (Pmode, tmp);
-      emit_move_insn (tmp, operands[0]);
-    }
-  else
-    emit_move_insn (gen_rtx_REG (Pmode, LINK_REGISTER_REGNUM), operands[0]);
+  rs6000_emit_eh_reg_restore (operands[0], operands[1]);
   DONE;
 }")