OSDN Git Service

2005-06-28 Andrew Pinski <pinskia@physics.uc.edu>
[pf3gnuchains/gcc-fork.git] / gcc / config / rs6000 / rs6000.md
index 9cd1350..6d0e581 100644 (file)
@@ -17,8 +17,8 @@
 
 ;; You should have received a copy of the GNU General Public License
 ;; along with GCC; see the file COPYING.  If not, write to the
-;; Free Software Foundation, 59 Temple Place - Suite 330, Boston,
-;; MA 02111-1307, USA.
+;; Free Software Foundation, 51 Franklin Street, Fifth Floor, Boston,
+;; MA 02110-1301, USA.
 
 ;;- See file "rtl.def" for documentation on define_insn, match_*, et. al.
 
 ; (one with a '.') will compare.
 (define_mode_macro P [(SI "TARGET_32BIT") (DI "TARGET_64BIT")])
 
+; Any hardware-supported floating-point mode
+(define_mode_macro FP [(SF "TARGET_HARD_FLOAT")
+  (DF "TARGET_HARD_FLOAT && (TARGET_FPRS || TARGET_E500_DOUBLE)")
+  (TF "(DEFAULT_ABI == ABI_AIX || DEFAULT_ABI == ABI_DARWIN)
+   && TARGET_HARD_FLOAT && TARGET_FPRS && TARGET_LONG_DOUBLE_128")])
+
 ; Various instructions that come in SI and DI forms.
-(define_mode_attr larx [(SI "lwarx") (DI "ldarx")])
-(define_mode_attr stcx [(SI "stwcx.") (DI "stdcx.")])
 ; A generic w/d attribute, for things like cmpw/cmpd.
 (define_mode_attr wd [(SI "w") (DI "d")])
 
 
 ;; Fixed-point arithmetic insns.
 
-(define_mode_attr add_op2 [(SI "reg_or_arith_cint_operand")
-                          (DI "reg_or_add_cint64_operand")])
-
 (define_expand "add<mode>3"
   [(set (match_operand:SDI 0 "gpc_reg_operand" "")
        (plus:SDI (match_operand:SDI 1 "gpc_reg_operand" "")
-                 (match_operand:SDI 2 "<add_op2>" "")))]
+                 (match_operand:SDI 2 "reg_or_add_cint_operand" "")))]
   ""
   "
 {
                    (const_int 0)))]
   "")
 
-(define_mode_attr sub_op2 [(SI "reg_or_arith_cint_operand")
-                          (DI "reg_or_sub_cint64_operand")])
-
 (define_expand "sub<mode>3"
   [(set (match_operand:SDI 0 "gpc_reg_operand" "")
        (minus:SDI (match_operand:SDI 1 "reg_or_short_operand" "")
-                  (match_operand:SDI 2 "<sub_op2>" "")))]
+                  (match_operand:SDI 2 "reg_or_sub_cint_operand" "")))]
   ""
   "
 {
   "divs %0,%1,%2"
   [(set_attr "type" "idiv")])
 
-(define_expand "udivsi3"
-  [(set (match_operand:SI 0 "gpc_reg_operand" "")
-        (udiv:SI (match_operand:SI 1 "gpc_reg_operand" "")
-                 (match_operand:SI 2 "gpc_reg_operand" "")))]
+(define_expand "udiv<mode>3"
+  [(set (match_operand:GPR 0 "gpc_reg_operand" "")
+        (udiv:GPR (match_operand:GPR 1 "gpc_reg_operand" "")
+                 (match_operand:GPR 2 "gpc_reg_operand" "")))]
   "TARGET_POWERPC || (! TARGET_POWER && ! TARGET_POWERPC)"
   "
 {
   [(set_attr "type" "idiv")])
 
 (define_insn "*udivsi3_no_mq"
-  [(set (match_operand:SI 0 "gpc_reg_operand" "=r")
-        (udiv:SI (match_operand:SI 1 "gpc_reg_operand" "r")
-                 (match_operand:SI 2 "gpc_reg_operand" "r")))]
+  [(set (match_operand:GPR 0 "gpc_reg_operand" "=r")
+        (udiv:GPR (match_operand:GPR 1 "gpc_reg_operand" "r")
+                 (match_operand:GPR 2 "gpc_reg_operand" "r")))]
   "TARGET_POWERPC && ! TARGET_POWER"
-  "divwu %0,%1,%2"
+  "div<wd>u %0,%1,%2"
   [(set_attr "type" "idiv")])
 
 ;; For powers of two we can do srai/aze for divide and then adjust for
 ;; modulus.  If it isn't a power of two, FAIL on POWER so divmodsi4 will be
 ;; used; for PowerPC, force operands into register and do a normal divide;
 ;; for AIX common-mode, use quoss call on register operands.
-(define_expand "divsi3"
-  [(set (match_operand:SI 0 "gpc_reg_operand" "")
-       (div:SI (match_operand:SI 1 "gpc_reg_operand" "")
-               (match_operand:SI 2 "reg_or_cint_operand" "")))]
+(define_expand "div<mode>3"
+  [(set (match_operand:GPR 0 "gpc_reg_operand" "")
+       (div:GPR (match_operand:GPR 1 "gpc_reg_operand" "")
+                (match_operand:GPR 2 "reg_or_cint_operand" "")))]
   ""
   "
 {
   "divw %0,%1,%2"
   [(set_attr "type" "idiv")])
 
-(define_insn "*divsi3_no_mq"
-  [(set (match_operand:SI 0 "gpc_reg_operand" "=r")
-        (div:SI (match_operand:SI 1 "gpc_reg_operand" "r")
-                (match_operand:SI 2 "gpc_reg_operand" "r")))]
+(define_insn "*div<mode>3_no_mq"
+  [(set (match_operand:GPR 0 "gpc_reg_operand" "=r")
+        (div:GPR (match_operand:GPR 1 "gpc_reg_operand" "r")
+                (match_operand:GPR 2 "gpc_reg_operand" "r")))]
   "TARGET_POWERPC && ! TARGET_POWER"
-  "divw %0,%1,%2"
+  "div<wd> %0,%1,%2"
   [(set_attr "type" "idiv")])
 
-(define_expand "modsi3"
-  [(use (match_operand:SI 0 "gpc_reg_operand" ""))
-   (use (match_operand:SI 1 "gpc_reg_operand" ""))
-   (use (match_operand:SI 2 "reg_or_cint_operand" ""))]
+(define_expand "mod<mode>3"
+  [(use (match_operand:GPR 0 "gpc_reg_operand" ""))
+   (use (match_operand:GPR 1 "gpc_reg_operand" ""))
+   (use (match_operand:GPR 2 "reg_or_cint_operand" ""))]
   ""
   "
 {
       || (i = exact_log2 (INTVAL (operands[2]))) < 0)
     FAIL;
 
-  temp1 = gen_reg_rtx (SImode);
-  temp2 = gen_reg_rtx (SImode);
+  temp1 = gen_reg_rtx (<MODE>mode);
+  temp2 = gen_reg_rtx (<MODE>mode);
 
-  emit_insn (gen_divsi3 (temp1, operands[1], operands[2]));
-  emit_insn (gen_ashlsi3 (temp2, temp1, GEN_INT (i)));
-  emit_insn (gen_subsi3 (operands[0], operands[1], temp2));
+  emit_insn (gen_div<mode>3 (temp1, operands[1], operands[2]));
+  emit_insn (gen_ashl<mode>3 (temp2, temp1, GEN_INT (i)));
+  emit_insn (gen_sub<mode>3 (operands[0], operands[1], temp2));
   DONE;
 }")
 
 (define_insn ""
-  [(set (match_operand:SI 0 "gpc_reg_operand" "=r")
-       (div:SI (match_operand:SI 1 "gpc_reg_operand" "r")
-               (match_operand:SI 2 "exact_log2_cint_operand" "N")))]
+  [(set (match_operand:GPR 0 "gpc_reg_operand" "=r")
+       (div:GPR (match_operand:GPR 1 "gpc_reg_operand" "r")
+                (match_operand:GPR 2 "exact_log2_cint_operand" "N")))]
   ""
-  "{srai|srawi} %0,%1,%p2\;{aze|addze} %0,%0"
+  "{srai|sra<wd>i} %0,%1,%p2\;{aze|addze} %0,%0"
   [(set_attr "type" "two")
    (set_attr "length" "8")])
 
 (define_insn ""
   [(set (match_operand:CC 0 "cc_reg_operand" "=x,?y")
-       (compare:CC (div:SI (match_operand:SI 1 "gpc_reg_operand" "r,r")
-                           (match_operand:SI 2 "exact_log2_cint_operand" "N,N"))
+       (compare:CC (div:P (match_operand:P 1 "gpc_reg_operand" "r,r")
+                          (match_operand:P 2 "exact_log2_cint_operand" "N,N"))
                    (const_int 0)))
-   (clobber (match_scratch:SI 3 "=r,r"))]
+   (clobber (match_scratch:P 3 "=r,r"))]
   ""
   "@
-   {srai|srawi} %3,%1,%p2\;{aze.|addze.} %3,%3
+   {srai|sra<wd>i} %3,%1,%p2\;{aze.|addze.} %3,%3
    #"
   [(set_attr "type" "compare")
    (set_attr "length" "8,12")])
 
 (define_split
   [(set (match_operand:CC 0 "cc_reg_not_cr0_operand" "")
-       (compare:CC (div:SI (match_operand:SI 1 "gpc_reg_operand" "")
-                           (match_operand:SI 2 "exact_log2_cint_operand" ""))
+       (compare:CC (div:GPR (match_operand:GPR 1 "gpc_reg_operand" "")
+                            (match_operand:GPR 2 "exact_log2_cint_operand"
+                             ""))
                    (const_int 0)))
-   (clobber (match_scratch:SI 3 ""))]
+   (clobber (match_scratch:GPR 3 ""))]
   "reload_completed"
   [(set (match_dup 3)
-       (div:SI (match_dup 1) (match_dup 2)))
+       (div:<MODE> (match_dup 1) (match_dup 2)))
    (set (match_dup 0)
        (compare:CC (match_dup 3)
                    (const_int 0)))]
 
 (define_insn ""
   [(set (match_operand:CC 3 "cc_reg_operand" "=x,?y")
-       (compare:CC (div:SI (match_operand:SI 1 "gpc_reg_operand" "r,r")
-                           (match_operand:SI 2 "exact_log2_cint_operand" "N,N"))
+       (compare:CC (div:P (match_operand:P 1 "gpc_reg_operand" "r,r")
+                          (match_operand:P 2 "exact_log2_cint_operand" "N,N"))
                    (const_int 0)))
-   (set (match_operand:SI 0 "gpc_reg_operand" "=r,r")
-       (div:SI (match_dup 1) (match_dup 2)))]
+   (set (match_operand:P 0 "gpc_reg_operand" "=r,r")
+       (div:P (match_dup 1) (match_dup 2)))]
   ""
   "@
-   {srai|srawi} %0,%1,%p2\;{aze.|addze.} %0,%0
+   {srai|sra<wd>i} %0,%1,%p2\;{aze.|addze.} %0,%0
    #"
   [(set_attr "type" "compare")
    (set_attr "length" "8,12")])
 
 (define_split
   [(set (match_operand:CC 3 "cc_reg_not_cr0_operand" "")
-       (compare:CC (div:SI (match_operand:SI 1 "gpc_reg_operand" "")
-                           (match_operand:SI 2 "exact_log2_cint_operand" ""))
+       (compare:CC (div:GPR (match_operand:GPR 1 "gpc_reg_operand" "")
+                            (match_operand:GPR 2 "exact_log2_cint_operand"
+                             ""))
                    (const_int 0)))
-   (set (match_operand:SI 0 "gpc_reg_operand" "")
-       (div:SI (match_dup 1) (match_dup 2)))]
+   (set (match_operand:GPR 0 "gpc_reg_operand" "")
+       (div:GPR (match_dup 1) (match_dup 2)))]
   "reload_completed"
   [(set (match_dup 0)
-       (div:SI (match_dup 1) (match_dup 2)))
+       (div:<MODE> (match_dup 1) (match_dup 2)))
    (set (match_dup 3)
        (compare:CC (match_dup 0)
                    (const_int 0)))]
 
 (define_split
   [(set (match_operand:CC 0 "cc_reg_not_cr0_operand" "")
-       (compare:CC (and:SI (match_operand:SI 1 "gpc_reg_operand" "")
-                           (match_operand:SI 2 "and_operand" ""))
+       (compare:CC (and:GPR (match_operand:GPR 1 "gpc_reg_operand" "")
+                            (match_operand:GPR 2 "and_operand" ""))
                    (const_int 0)))
-   (clobber (match_scratch:SI 3 ""))
+   (clobber (match_scratch:GPR 3 ""))
    (clobber (match_scratch:CC 4 ""))]
   "reload_completed"
   [(parallel [(set (match_dup 3)
-                  (and:SI (match_dup 1)
-                          (match_dup 2)))
+                  (and:<MODE> (match_dup 1)
+                              (match_dup 2)))
              (clobber (match_dup 4))])
    (set (match_dup 0)
        (compare:CC (match_dup 3)
   "mulhdu %0,%1,%2"
   [(set_attr "type" "lmul")])
 
-(define_expand "divdi3"
-  [(set (match_operand:DI 0 "gpc_reg_operand" "")
-       (div:DI (match_operand:DI 1 "gpc_reg_operand" "")
-               (match_operand:DI 2 "reg_or_cint_operand" "")))]
-  "TARGET_POWERPC64"
-  "
-{
-  if (GET_CODE (operands[2]) == CONST_INT
-      && INTVAL (operands[2]) > 0
-      && exact_log2 (INTVAL (operands[2])) >= 0)
-    ;
-  else
-    operands[2] = force_reg (DImode, operands[2]);
-}")
-
-(define_expand "moddi3"
-  [(use (match_operand:DI 0 "gpc_reg_operand" ""))
-   (use (match_operand:DI 1 "gpc_reg_operand" ""))
-   (use (match_operand:DI 2 "reg_or_cint_operand" ""))]
-  "TARGET_POWERPC64"
-  "
-{
-  int i;
-  rtx temp1;
-  rtx temp2;
-
-  if (GET_CODE (operands[2]) != CONST_INT
-      || INTVAL (operands[2]) <= 0
-      || (i = exact_log2 (INTVAL (operands[2]))) < 0)
-    FAIL;
-
-  temp1 = gen_reg_rtx (DImode);
-  temp2 = gen_reg_rtx (DImode);
-
-  emit_insn (gen_divdi3 (temp1, operands[1], operands[2]));
-  emit_insn (gen_ashldi3 (temp2, temp1, GEN_INT (i)));
-  emit_insn (gen_subdi3 (operands[0], operands[1], temp2));
-  DONE;
-}")
-
-(define_insn ""
-  [(set (match_operand:DI 0 "gpc_reg_operand" "=r")
-       (div:DI (match_operand:DI 1 "gpc_reg_operand" "r")
-               (match_operand:DI 2 "exact_log2_cint_operand" "N")))]
-  "TARGET_POWERPC64"
-  "sradi %0,%1,%p2\;addze %0,%0"
-  [(set_attr "type" "two")
-   (set_attr "length" "8")])
-
-(define_insn ""
-  [(set (match_operand:CC 0 "cc_reg_operand" "=x,?y")
-       (compare:CC (div:DI (match_operand:DI 1 "gpc_reg_operand" "r,r")
-                           (match_operand:DI 2 "exact_log2_cint_operand" "N,N"))
-                   (const_int 0)))
-   (clobber (match_scratch:DI 3 "=r,r"))]
-  "TARGET_64BIT"
-  "@
-   sradi %3,%1,%p2\;addze. %3,%3
-   #"
-  [(set_attr "type" "compare")
-   (set_attr "length" "8,12")])
-
-(define_split
-  [(set (match_operand:CC 0 "cc_reg_not_cr0_operand" "")
-       (compare:CC (div:DI (match_operand:DI 1 "gpc_reg_operand" "")
-                           (match_operand:DI 2 "exact_log2_cint_operand" ""))
-                   (const_int 0)))
-   (clobber (match_scratch:DI 3 ""))]
-  "TARGET_POWERPC64 && reload_completed"
-  [(set (match_dup 3)
-       (div:DI (match_dup 1) (match_dup 2)))
-   (set (match_dup 0)
-       (compare:CC (match_dup 3)
-                   (const_int 0)))]
-  "")
-
-(define_insn ""
-  [(set (match_operand:CC 3 "cc_reg_operand" "=x,?y")
-       (compare:CC (div:DI (match_operand:DI 1 "gpc_reg_operand" "r,r")
-                           (match_operand:DI 2 "exact_log2_cint_operand" "N,N"))
-                   (const_int 0)))
-   (set (match_operand:DI 0 "gpc_reg_operand" "=r,r")
-       (div:DI (match_dup 1) (match_dup 2)))]
-  "TARGET_64BIT"
-  "@
-   sradi %0,%1,%p2\;addze. %0,%0
-   #"
-  [(set_attr "type" "compare")
-   (set_attr "length" "8,12")])
-
-(define_split
-  [(set (match_operand:CC 3 "cc_reg_not_cr0_operand" "")
-       (compare:CC (div:DI (match_operand:DI 1 "gpc_reg_operand" "")
-                           (match_operand:DI 2 "exact_log2_cint_operand" ""))
-                   (const_int 0)))
-   (set (match_operand:DI 0 "gpc_reg_operand" "")
-       (div:DI (match_dup 1) (match_dup 2)))]
-  "TARGET_POWERPC64 && reload_completed"
-  [(set (match_dup 0)
-       (div:DI (match_dup 1) (match_dup 2)))
-   (set (match_dup 3)
-       (compare:CC (match_dup 0)
-                   (const_int 0)))]
-  "")
-
-(define_insn ""
-  [(set (match_operand:DI 0 "gpc_reg_operand" "=r")
-        (div:DI (match_operand:DI 1 "gpc_reg_operand" "r")
-                (match_operand:DI 2 "gpc_reg_operand" "r")))]
-  "TARGET_POWERPC64"
-  "divd %0,%1,%2"
-  [(set_attr "type" "ldiv")])
-
-(define_insn "udivdi3"
-  [(set (match_operand:DI 0 "gpc_reg_operand" "=r")
-        (udiv:DI (match_operand:DI 1 "gpc_reg_operand" "r")
-                 (match_operand:DI 2 "gpc_reg_operand" "r")))]
-  "TARGET_POWERPC64"
-  "divdu %0,%1,%2"
-  [(set_attr "type" "ldiv")])
-
 (define_insn "rotldi3"
   [(set (match_operand:DI 0 "gpc_reg_operand" "=r")
        (rotate:DI (match_operand:DI 1 "gpc_reg_operand" "r")
   [(set (match_operand:DI 0 "gpc_reg_operand" "=r")
        (and:DI (rotate:DI (match_operand:DI 1 "gpc_reg_operand" "r")
                           (match_operand:DI 2 "reg_or_cint_operand" "ri"))
-               (match_operand:DI 3 "mask64_operand" "n")))]
+               (match_operand:DI 3 "mask_operand" "n")))]
   "TARGET_POWERPC64"
   "rld%I2c%B3 %0,%1,%H2,%S3")
 
        (compare:CC (and:DI
                     (rotate:DI (match_operand:DI 1 "gpc_reg_operand" "r,r")
                                (match_operand:DI 2 "reg_or_cint_operand" "ri,ri"))
-                    (match_operand:DI 3 "mask64_operand" "n,n"))
+                    (match_operand:DI 3 "mask_operand" "n,n"))
                    (const_int 0)))
    (clobber (match_scratch:DI 4 "=r,r"))]
   "TARGET_64BIT"
        (compare:CC (and:DI
                     (rotate:DI (match_operand:DI 1 "gpc_reg_operand" "")
                                (match_operand:DI 2 "reg_or_cint_operand" ""))
-                    (match_operand:DI 3 "mask64_operand" ""))
+                    (match_operand:DI 3 "mask_operand" ""))
                    (const_int 0)))
    (clobber (match_scratch:DI 4 ""))]
   "TARGET_POWERPC64 && reload_completed"
        (compare:CC (and:DI
                     (rotate:DI (match_operand:DI 1 "gpc_reg_operand" "r,r")
                                (match_operand:DI 2 "reg_or_cint_operand" "ri,ri"))
-                    (match_operand:DI 3 "mask64_operand" "n,n"))
+                    (match_operand:DI 3 "mask_operand" "n,n"))
                    (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)))]
        (compare:CC (and:DI
                     (rotate:DI (match_operand:DI 1 "gpc_reg_operand" "")
                                (match_operand:DI 2 "reg_or_cint_operand" ""))
-                    (match_operand:DI 3 "mask64_operand" ""))
+                    (match_operand:DI 3 "mask_operand" ""))
                    (const_int 0)))
    (set (match_operand:DI 0 "gpc_reg_operand" "")
        (and:DI (rotate:DI (match_dup 1) (match_dup 2)) (match_dup 3)))]
   [(set (match_operand:DI 0 "gpc_reg_operand" "=r")
        (and:DI (ashift:DI (match_operand:DI 1 "gpc_reg_operand" "r")
                           (match_operand:SI 2 "const_int_operand" "i"))
-               (match_operand:DI 3 "mask64_operand" "n")))]
+               (match_operand:DI 3 "mask_operand" "n")))]
   "TARGET_POWERPC64 && includes_rldicr_lshift_p (operands[2], operands[3])"
   "rldicr %0,%1,%H2,%S3")
 
        (compare:CC
         (and:DI (ashift:DI (match_operand:DI 1 "gpc_reg_operand" "r,r")
                            (match_operand:SI 2 "const_int_operand" "i,i"))
-                (match_operand:DI 3 "mask64_operand" "n,n"))
+                (match_operand:DI 3 "mask_operand" "n,n"))
         (const_int 0)))
    (clobber (match_scratch:DI 4 "=r,r"))]
   "TARGET_64BIT && includes_rldicr_lshift_p (operands[2], operands[3])"
        (compare:CC
         (and:DI (ashift:DI (match_operand:DI 1 "gpc_reg_operand" "")
                            (match_operand:SI 2 "const_int_operand" ""))
-                (match_operand:DI 3 "mask64_operand" ""))
+                (match_operand:DI 3 "mask_operand" ""))
         (const_int 0)))
    (clobber (match_scratch:DI 4 ""))]
   "TARGET_POWERPC64 && reload_completed
        (compare:CC
         (and:DI (ashift:DI (match_operand:DI 1 "gpc_reg_operand" "r,r")
                            (match_operand:SI 2 "const_int_operand" "i,i"))
-                   (match_operand:DI 3 "mask64_operand" "n,n"))
+                   (match_operand:DI 3 "mask_operand" "n,n"))
         (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)))]
        (compare:CC
         (and:DI (ashift:DI (match_operand:DI 1 "gpc_reg_operand" "")
                            (match_operand:SI 2 "const_int_operand" ""))
-                (match_operand:DI 3 "mask64_operand" ""))
+                (match_operand:DI 3 "mask_operand" ""))
         (const_int 0)))
    (set (match_operand:DI 0 "gpc_reg_operand" "")
        (and:DI (ashift:DI (match_dup 1) (match_dup 2)) (match_dup 3)))]
    (clobber (match_scratch:CC 3 ""))]
   "TARGET_POWERPC64
     && (fixed_regs[CR0_REGNO] || !logical_operand (operands[2], DImode))
-    && !mask64_operand (operands[2], DImode)"
+    && !mask_operand (operands[2], DImode)"
   [(set (match_dup 0)
        (and:DI (rotate:DI (match_dup 1)
                           (match_dup 4))
    (set_attr "length" "4,4,4,4,8,8,8,8,8,12")])
 
 (define_split
-  [(set (match_operand:CC 0 "cc_reg_not_cr0_operand" "")
-        (compare:CC (and:DI (match_operand:DI 1 "gpc_reg_operand" "")
-                            (match_operand:DI 2 "and64_operand" ""))
-                    (const_int 0)))
-   (clobber (match_scratch:DI 3 ""))
-   (clobber (match_scratch:CC 4 ""))]
-  "TARGET_POWERPC64 && reload_completed"
-  [(parallel [(set (match_dup 3)
-                   (and:DI (match_dup 1)
-                           (match_dup 2)))
-              (clobber (match_dup 4))])
-   (set (match_dup 0)
-        (compare:CC (match_dup 3)
-                    (const_int 0)))]
-  "")
-
-(define_split
   [(set (match_operand:CC 0 "cc_reg_operand" "")
         (compare:CC (and:DI (match_operand:DI 1 "gpc_reg_operand" "")
                             (match_operand:DI 2 "mask64_2_operand" ""))
    (clobber (match_scratch:CC 4 ""))]
   "TARGET_POWERPC64 && reload_completed
     && (fixed_regs[CR0_REGNO] || !logical_operand (operands[2], DImode))
-    && !mask64_operand (operands[2], DImode)"
+    && !mask_operand (operands[2], DImode)"
   [(set (match_dup 3)
        (and:DI (rotate:DI (match_dup 1)
                           (match_dup 5))
 (define_split
   [(set (match_operand:CC 3 "cc_reg_not_cr0_operand" "")
        (compare:CC (and:DI (match_operand:DI 1 "gpc_reg_operand" "")
-                           (match_operand:DI 2 "and64_operand" ""))
+                           (match_operand:DI 2 "and_operand" ""))
                    (const_int 0)))
    (set (match_operand:DI 0 "gpc_reg_operand" "")
        (and:DI (match_dup 1) (match_dup 2)))
    (clobber (match_scratch:CC 4 ""))]
   "TARGET_POWERPC64 && reload_completed
     && (fixed_regs[CR0_REGNO] || !logical_operand (operands[2], DImode))
-    && !mask64_operand (operands[2], DImode)"
+    && !mask_operand (operands[2], DImode)"
   [(set (match_dup 0)
        (and:DI (rotate:DI (match_dup 1)
                           (match_dup 5))
 ;; do the load 16-bits at a time.  We could do this by loading from memory,
 ;; and this is even supposed to be faster, but it is simpler not to get
 ;; integers in the TOC.
-(define_expand "movsi"
-  [(set (match_operand:SI 0 "general_operand" "")
-       (match_operand:SI 1 "any_operand" ""))]
-  ""
-  "{ rs6000_emit_move (operands[0], operands[1], SImode); DONE; }")
-
 (define_insn "movsi_low"
   [(set (match_operand:SI 0 "gpc_reg_operand" "=r")
         (mem:SI (lo_sum:SI (match_operand:SI 1 "gpc_reg_operand" "b")
     FAIL;
 }")
 
-(define_insn "*movsi_internal2"
+(define_insn "*mov<mode>_internal2"
   [(set (match_operand:CC 2 "cc_reg_operand" "=y,x,?y")
-       (compare:CC (match_operand:SI 1 "gpc_reg_operand" "0,r,r")
+       (compare:CC (match_operand:P 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_32BIT"
+   (set (match_operand:P 0 "gpc_reg_operand" "=r,r,r") (match_dup 1))]
+  ""
   "@
-   {cmpi|cmpwi} %2,%0,0
+   {cmpi|cmp<wd>i} %2,%0,0
    mr. %0,%1
    #"
   [(set_attr "type" "cmp,compare,cmp")
 
 (define_split
   [(set (match_operand:CC 2 "cc_reg_not_cr0_operand" "")
-       (compare:CC (match_operand:SI 1 "gpc_reg_operand" "")
+       (compare:CC (match_operand:P 1 "gpc_reg_operand" "")
                    (const_int 0)))
-   (set (match_operand:SI 0 "gpc_reg_operand" "") (match_dup 1))]
-  "TARGET_32BIT && reload_completed"
+   (set (match_operand:P 0 "gpc_reg_operand" "") (match_dup 1))]
+  "reload_completed"
   [(set (match_dup 0) (match_dup 1))
    (set (match_dup 2)
        (compare:CC (match_dup 0)
                    (const_int 0)))]
   "")
 \f
-(define_expand "movhi"
-  [(set (match_operand:HI 0 "general_operand" "")
-       (match_operand:HI 1 "any_operand" ""))]
-  ""
-  "{ rs6000_emit_move (operands[0], operands[1], HImode); DONE; }")
-
 (define_insn "*movhi_internal"
   [(set (match_operand:HI 0 "nonimmediate_operand" "=r,r,m,r,r,*q,*c*l,*h")
        (match_operand:HI 1 "input_operand" "r,m,r,i,*h,r,r,0"))]
    {cror 0,0,0|nop}"
   [(set_attr "type" "*,load,store,*,mfjmpr,*,mtjmpr,*")])
 
-(define_expand "movqi"
-  [(set (match_operand:QI 0 "general_operand" "")
-       (match_operand:QI 1 "any_operand" ""))]
+(define_expand "mov<mode>"
+  [(set (match_operand:INT 0 "general_operand" "")
+       (match_operand:INT 1 "any_operand" ""))]
   ""
-  "{ rs6000_emit_move (operands[0], operands[1], QImode); DONE; }")
+  "{ rs6000_emit_move (operands[0], operands[1], <MODE>mode); DONE; }")
 
 (define_insn "*movqi_internal"
   [(set (match_operand:QI 0 "nonimmediate_operand" "=r,r,m,r,r,*q,*c*l,*h")
 \f
 ;; Next come the multi-word integer load and store and the load and store
 ;; multiple insns.
-(define_expand "movdi"
-  [(set (match_operand:DI 0 "general_operand" "")
-       (match_operand:DI 1 "any_operand" ""))]
-  ""
-  "{ 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.
 ;; Use (and:DI (rotate:DI ...)) to avoid anddi3 unnecessary clobber.
 (define_split
   [(set (match_operand:DI 0 "gpc_reg_operand" "")
-       (match_operand:DI 1 "mask64_operand" ""))]
+       (match_operand:DI 1 "mask_operand" ""))]
   "TARGET_POWERPC64 && num_insns_constant (operands[1], DImode) > 1"
   [(set (match_dup 0) (const_int -1))
    (set (match_dup 0)
   else
     FAIL;
 }")
-
-(define_insn "*movdi_internal2"
-  [(set (match_operand:CC 2 "cc_reg_operand" "=y,x,?y")
-       (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_64BIT"
-  "@
-   cmpdi %2,%0,0
-   mr. %0,%1
-   #"
-  [(set_attr "type" "cmp,compare,cmp")
-   (set_attr "length" "4,4,8")])
-
-(define_split
-  [(set (match_operand:CC 2 "cc_reg_not_cr0_operand" "")
-       (compare:CC (match_operand:DI 1 "gpc_reg_operand" "")
-                   (const_int 0)))
-   (set (match_operand:DI 0 "gpc_reg_operand" "") (match_dup 1))]
-  "TARGET_POWERPC64 && reload_completed"
-  [(set (match_dup 0) (match_dup 1))
-   (set (match_dup 2)
-       (compare:CC (match_dup 0)
-                   (const_int 0)))]
-  "")
 \f
 ;; TImode is similar, except that we usually want to compute the address into
 ;; a register and use lsi/stsi (the exception is during reload).  MQ is also
 ;; clobbered in stsi for POWER, so we need a SCRATCH for it.
-(define_expand "movti"
-  [(parallel [(set (match_operand:TI 0 "general_operand" "")
-                  (match_operand:TI 1 "general_operand" ""))
-             (clobber (scratch:SI))])]
-  ""
-  "{ rs6000_emit_move (operands[0], operands[1], TImode); DONE; }")
 
 ;; We say that MQ is clobbered in the last alternative because the first
 ;; alternative would never get used otherwise since it would need a reload
   "{stsi|stswi} %2,%1,%O0"
   [(set_attr "type" "store")])
 \f
-(define_expand "clrmemsi"
+(define_expand "setmemsi"
   [(parallel [(set (match_operand:BLK 0 "" "")
-                  (const_int 0))
+                  (match_operand 2 "const_int_operand" ""))
              (use (match_operand:SI 1 "" ""))
-             (use (match_operand:SI 2 "" ""))])]
+             (use (match_operand:SI 3 "" ""))])]
   ""
   "
 {
+  /* If value to set is not zero, use the library routine.  */
+  if (operands[2] != const0_rtx)
+    FAIL;
+
   if (expand_block_clear (operands))
     DONE;
   else
    (set_attr "length" "8")])
 
 (define_insn ""
-  [(set (mem:BLK (match_operand:SI 0 "gpc_reg_operand" "b"))
-       (mem:BLK (match_operand:SI 1 "gpc_reg_operand" "b")))
+  [(set (mem:BLK (match_operand:P 0 "gpc_reg_operand" "b"))
+       (mem:BLK (match_operand:P 1 "gpc_reg_operand" "b")))
    (use (match_operand:SI 2 "immediate_operand" "i"))
    (use (match_operand:SI 3 "immediate_operand" "i"))
    (clobber (match_operand:SI 4 "gpc_reg_operand" "=r"))
   [(set_attr "type" "load")
    (set_attr "length" "8")])
 
-(define_insn ""
-  [(set (mem:BLK (match_operand:DI 0 "gpc_reg_operand" "b"))
-       (mem:BLK (match_operand:DI 1 "gpc_reg_operand" "b")))
-   (use (match_operand:SI 2 "immediate_operand" "i"))
-   (use (match_operand:SI 3 "immediate_operand" "i"))
-   (clobber (match_operand:SI 4 "gpc_reg_operand" "=r"))
-   (clobber (reg:SI  6))
-   (clobber (reg:SI  7))
-   (clobber (reg:SI  8))
-   (clobber (reg:SI  9))
-   (clobber (reg:SI 10))
-   (clobber (reg:SI 11))
-   (clobber (reg:SI 12))
-   (clobber (match_scratch:SI 5 "X"))]
-  "TARGET_STRING && TARGET_POWERPC64
-   && ((INTVAL (operands[2]) > 24 && INTVAL (operands[2]) < 32)
-       || INTVAL (operands[2]) == 0)
-   && (REGNO (operands[0]) < 5 || REGNO (operands[0]) > 12)
-   && (REGNO (operands[1]) < 5 || REGNO (operands[1]) > 12)
-   && REGNO (operands[4]) == 5"
-  "{lsi|lswi} %4,%1,%2\;{stsi|stswi} %4,%0,%2"
-  [(set_attr "type" "load")
-   (set_attr "length" "8")])
-
 ;; 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.
    (set_attr "length" "8")])
 
 (define_insn ""
-  [(set (mem:BLK (match_operand:SI 0 "gpc_reg_operand" "b"))
-       (mem:BLK (match_operand:SI 1 "gpc_reg_operand" "b")))
+  [(set (mem:BLK (match_operand:P 0 "gpc_reg_operand" "b"))
+       (mem:BLK (match_operand:P 1 "gpc_reg_operand" "b")))
    (use (match_operand:SI 2 "immediate_operand" "i"))
    (use (match_operand:SI 3 "immediate_operand" "i"))
    (clobber (match_operand:SI 4 "gpc_reg_operand" "=r"))
   [(set_attr "type" "load")
    (set_attr "length" "8")])
 
-(define_insn ""
-  [(set (mem:BLK (match_operand:DI 0 "gpc_reg_operand" "b"))
-       (mem:BLK (match_operand:DI 1 "gpc_reg_operand" "b")))
-   (use (match_operand:SI 2 "immediate_operand" "i"))
-   (use (match_operand:SI 3 "immediate_operand" "i"))
-   (clobber (match_operand:SI 4 "gpc_reg_operand" "=r"))
-   (clobber (reg:SI  6))
-   (clobber (reg:SI  7))
-   (clobber (reg:SI  8))
-   (clobber (reg:SI  9))
-   (clobber (reg:SI 10))
-   (clobber (match_scratch:SI 5 "X"))]
-  "TARGET_STRING && TARGET_POWERPC64
-   && INTVAL (operands[2]) > 16 && INTVAL (operands[2]) <= 32
-   && (REGNO (operands[0]) < 5 || REGNO (operands[0]) > 10)
-   && (REGNO (operands[1]) < 5 || REGNO (operands[1]) > 10)
-   && REGNO (operands[4]) == 5"
-  "{lsi|lswi} %4,%1,%2\;{stsi|stswi} %4,%0,%2"
-  [(set_attr "type" "load")
-   (set_attr "length" "8")])
-
 ;; 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.
    (set_attr "length" "8")])
 
 (define_insn ""
-  [(set (mem:BLK (match_operand:SI 0 "gpc_reg_operand" "b"))
-       (mem:BLK (match_operand:SI 1 "gpc_reg_operand" "b")))
+  [(set (mem:BLK (match_operand:P 0 "gpc_reg_operand" "b"))
+       (mem:BLK (match_operand:P 1 "gpc_reg_operand" "b")))
    (use (match_operand:SI 2 "immediate_operand" "i"))
    (use (match_operand:SI 3 "immediate_operand" "i"))
    (clobber (match_operand:SI 4 "gpc_reg_operand" "=r"))
   [(set_attr "type" "load")
    (set_attr "length" "8")])
 
-(define_insn ""
-  [(set (mem:BLK (match_operand:DI 0 "gpc_reg_operand" "b"))
-       (mem:BLK (match_operand:DI 1 "gpc_reg_operand" "b")))
-   (use (match_operand:SI 2 "immediate_operand" "i"))
-   (use (match_operand:SI 3 "immediate_operand" "i"))
-   (clobber (match_operand:SI 4 "gpc_reg_operand" "=r"))
-   (clobber (reg:SI 6))
-   (clobber (reg:SI 7))
-   (clobber (reg:SI 8))
-   (clobber (match_scratch:SI 5 "X"))]
-  "TARGET_STRING && TARGET_POWERPC64
-   && INTVAL (operands[2]) > 8 && INTVAL (operands[2]) <= 16
-   && (REGNO (operands[0]) < 5 || REGNO (operands[0]) > 8)
-   && (REGNO (operands[1]) < 5 || REGNO (operands[1]) > 8)
-   && REGNO (operands[4]) == 5"
-  "{lsi|lswi} %4,%1,%2\;{stsi|stswi} %4,%0,%2"
-  [(set_attr "type" "load")
-   (set_attr "length" "8")])
-
 ;; Move up to 8 bytes at a time.
 (define_expand "movmemsi_2reg"
   [(parallel [(set (match_operand 0 "" "")
    (set_attr "length" "8")])
 
 (define_insn ""
-  [(set (mem:BLK (match_operand:SI 0 "gpc_reg_operand" "b"))
-       (mem:BLK (match_operand:SI 1 "gpc_reg_operand" "b")))
+  [(set (mem:BLK (match_operand:P 0 "gpc_reg_operand" "b"))
+       (mem:BLK (match_operand:P 1 "gpc_reg_operand" "b")))
    (use (match_operand:SI 2 "immediate_operand" "i"))
    (use (match_operand:SI 3 "immediate_operand" "i"))
    (clobber (match_scratch:SI 4 "=&r"))
   "{lsi|lswi} %4,%1,%2\;{stsi|stswi} %4,%0,%2"
   [(set_attr "type" "load")
    (set_attr "length" "8")])
-
-(define_insn ""
-  [(set (mem:BLK (match_operand:DI 0 "gpc_reg_operand" "b"))
-       (mem:BLK (match_operand:DI 1 "gpc_reg_operand" "b")))
-   (use (match_operand:SI 2 "immediate_operand" "i"))
-   (use (match_operand:SI 3 "immediate_operand" "i"))
-   (clobber (match_scratch:SI 4 "=&r"))
-   (clobber (match_scratch:SI 5 "X"))]
-  "TARGET_STRING && TARGET_POWERPC64
-   && INTVAL (operands[2]) > 0 && INTVAL (operands[2]) <= 4"
-  "{lsi|lswi} %4,%1,%2\;{stsi|stswi} %4,%0,%2"
-  [(set_attr "type" "load")
-   (set_attr "length" "8")])
-
 \f
 ;; Define insns that do load or store with update.  Some of these we can
 ;; get by using pre-decrement or pre-increment, but the hardware can also
 ;; Start with the DEFINE_EXPANDs to generate the rtl for compares, scc
 ;; insns, and branches.  We store the operands of compares until we see
 ;; how it is used.
-(define_expand "cmpsi"
+(define_expand "cmp<mode>"
   [(set (cc0)
-        (compare (match_operand:SI 0 "gpc_reg_operand" "")
-                (match_operand:SI 1 "reg_or_short_operand" "")))]
+        (compare (match_operand:GPR 0 "gpc_reg_operand" "")
+                (match_operand:GPR 1 "reg_or_short_operand" "")))]
   ""
   "
 {
      this might be a logical operation.  That insn doesn't exist.  */
   if (GET_CODE (operands[1]) == CONST_INT
       && INTVAL (operands[1]) < 0)
-    operands[1] = force_reg (SImode, operands[1]);
-
-  rs6000_compare_op0 = operands[0];
-  rs6000_compare_op1 = operands[1];
-  rs6000_compare_fp_p = 0;
-  DONE;
-}")
-
-(define_expand "cmpdi"
-  [(set (cc0)
-        (compare (match_operand:DI 0 "gpc_reg_operand" "")
-                (match_operand:DI 1 "reg_or_short_operand" "")))]
-  "TARGET_POWERPC64"
-  "
-{
-  /* Take care of the possibility that operands[1] might be negative but
-     this might be a logical operation.  That insn doesn't exist.  */
-  if (GET_CODE (operands[1]) == CONST_INT
-      && INTVAL (operands[1]) < 0)
-    operands[1] = force_reg (DImode, operands[1]);
+    operands[1] = force_reg (<MODE>mode, operands[1]);
 
   rs6000_compare_op0 = operands[0];
   rs6000_compare_op1 = operands[1];
   DONE;
 }")
 
-(define_expand "cmpsf"
-  [(set (cc0) (compare (match_operand:SF 0 "gpc_reg_operand" "")
-                      (match_operand:SF 1 "gpc_reg_operand" "")))]
-  "TARGET_HARD_FLOAT"
-  "
-{
-  rs6000_compare_op0 = operands[0];
-  rs6000_compare_op1 = operands[1];
-  rs6000_compare_fp_p = 1;
-  DONE;
-}")
-
-(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_E500_DOUBLE)"
-  "
-{
-  rs6000_compare_op0 = operands[0];
-  rs6000_compare_op1 = operands[1];
-  rs6000_compare_fp_p = 1;
-  DONE;
-}")
-
-(define_expand "cmptf"
-  [(set (cc0) (compare (match_operand:TF 0 "gpc_reg_operand" "")
-                      (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_expand "cmp<mode>"
+  [(set (cc0) (compare (match_operand:FP 0 "gpc_reg_operand" "")
+                      (match_operand:FP 1 "gpc_reg_operand" "")))]
+  ""
   "
 {
   rs6000_compare_op0 = operands[0];
 
 \f
 ;; Here are the actual compare insns.
-(define_insn "*cmpsi_internal1"
+(define_insn "*cmp<mode>_internal1"
   [(set (match_operand:CC 0 "cc_reg_operand" "=y")
-       (compare:CC (match_operand:SI 1 "gpc_reg_operand" "r")
-                   (match_operand:SI 2 "reg_or_short_operand" "rI")))]
+       (compare:CC (match_operand:GPR 1 "gpc_reg_operand" "r")
+                   (match_operand:GPR 2 "reg_or_short_operand" "rI")))]
   ""
-  "{cmp%I2|cmpw%I2} %0,%1,%2"
-  [(set_attr "type" "cmp")])
-
-(define_insn "*cmpdi_internal1"
-  [(set (match_operand:CC 0 "cc_reg_operand" "=y")
-       (compare:CC (match_operand:DI 1 "gpc_reg_operand" "r")
-                   (match_operand:DI 2 "reg_or_short_operand" "rI")))]
-  "TARGET_POWERPC64"
-  "cmpd%I2 %0,%1,%2"
+  "{cmp%I2|cmp<wd>%I2} %0,%1,%2"
   [(set_attr "type" "cmp")])
 
 ;; If we are comparing a register for equality with a large constant,
 ;; otherwise won't accept constants.  We do this because it is faster than
 ;; the cmp/mfcr sequence we would otherwise generate.
 
-(define_insn ""
-  [(set (match_operand:SI 0 "gpc_reg_operand" "=r,r,r,r,r")
-       (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,X,r,r,r"))]
-  "TARGET_32BIT"
-  "@
-   xor %0,%1,%2\;{sfi|subfic} %3,%0,0\;{ae|adde} %0,%3,%0
-   #
-   {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 "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,X,r,r,r"))]
-  "TARGET_64BIT"
-  "@
-   xor %0,%1,%2\;subfic %3,%0,0\;adde %0,%3,%0
-   #
-   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 "type" "three,two,three,three,three")
-   (set_attr "length" "12,8,12,12,12")])
+(define_mode_attr scc_eq_op2 [(SI "rKLI")
+                             (DI "rKJI")])
 
-(define_split
-  [(set (match_operand:GPR 0 "gpc_reg_operand" "")
-       (eq:GPR (match_operand:GPR 1 "gpc_reg_operand" "")
-              (match_operand:GPR 2 "zero_constant" "")))
-   (clobber (match_scratch:GPR 3 ""))]
+(define_insn_and_split "*eq<mode>"
+  [(set (match_operand:GPR 0 "gpc_reg_operand" "=r")
+       (eq:GPR (match_operand:GPR 1 "gpc_reg_operand" "r")
+               (match_operand:GPR 2 "scc_eq_operand" "<scc_eq_op2>")))
+   (clobber (match_scratch:GPR 3 "=r"))
+   (clobber (match_scratch:GPR 4 "=r"))]
   ""
-  [(set (match_dup 0)
-       (clz:GPR (match_dup 1)))
+  "#"
+  "reload_completed"
+  [(set (match_dup 3)
+       (clz:GPR (match_dup 4)))
    (set (match_dup 0)
-       (lshiftrt:GPR (match_dup 0) (match_dup 4)))]
+       (lshiftrt:GPR (match_dup 3) (match_dup 5)))]
   {
-    operands[4] = GEN_INT (exact_log2 (GET_MODE_BITSIZE (<MODE>mode)));
-  })
+    if (GET_CODE (operands[2]) != CONST_INT || INTVAL (operands[2]) != 0)
+      {
+       if (logical_operand (operands[2], <MODE>mode))
+         emit_insn (gen_rtx_SET (VOIDmode, operands[4],
+                                 gen_rtx_XOR (<MODE>mode,
+                                              operands[1], operands[2])));
+       else
+         emit_insn (gen_rtx_SET (VOIDmode, operands[4],
+                                 gen_rtx_PLUS (<MODE>mode, operands[1],
+                                               negate_rtx (<MODE>mode,
+                                                           operands[2]))));
+      }
+    else
+      operands[4] = operands[1];
 
-(define_insn ""
-  [(set (match_operand:CC 4 "cc_reg_operand" "=x,x,x,x,x,?y,?y,?y,?y,?y")
-       (compare:CC
-        (eq:SI (match_operand:SI 1 "gpc_reg_operand" "%r,r,r,r,r,r,r,r,r,r")
-               (match_operand:SI 2 "reg_or_cint_operand" "r,O,K,L,I,r,O,K,L,I"))
-        (const_int 0)))
-   (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,X,r,r,r,r,X,r,r,r"))]
-  "TARGET_32BIT"
-  "@
-   xor %0,%1,%2\;{sfi|subfic} %3,%0,0\;{ae.|adde.} %0,%3,%0
-   #
-   {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 "type" "compare")
-   (set_attr "length" "12,8,12,12,12,16,12,16,16,16")])
-
-(define_split
-  [(set (match_operand:CC 4 "cc_reg_not_cr0_operand" "")
-       (compare:CC
-        (eq:SI (match_operand:SI 1 "gpc_reg_operand" "")
-               (match_operand:SI 2 "reg_or_cint_operand" ""))
-        (const_int 0)))
-   (set (match_operand:SI 0 "gpc_reg_operand" "")
-       (eq:SI (match_dup 1) (match_dup 2)))
-   (clobber (match_scratch:SI 3 ""))]
-  "TARGET_32BIT && reload_completed"
-  [(parallel [(set (match_dup 0)
-       (eq:SI (match_dup 1) (match_dup 2)))
-   (clobber (match_dup 3))])
-   (set (match_dup 4)
-       (compare:CC (match_dup 0)
-                   (const_int 0)))]
-  "")
-
-(define_insn ""
-  [(set (match_operand:CC 4 "cc_reg_operand" "=x,x,x,x,x,?y,?y,?y,?y,?y")
-       (compare:CC
-        (eq:DI (match_operand:DI 1 "gpc_reg_operand" "%r,r,r,r,r,r,r,r,r,r")
-               (match_operand:DI 2 "reg_or_cint_operand" "r,O,K,J,I,r,O,K,J,I"))
-        (const_int 0)))
-   (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,X,r,r,r,r,X,r,r,r"))]
-  "TARGET_64BIT"
-  "@
-   xor %0,%1,%2\;subfic %3,%0,0\;adde. %0,%3,%0
-   #
-   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 "type" "compare")
-   (set_attr "length" "12,8,12,12,12,16,12,16,16,16")])
-
-(define_split
-  [(set (match_operand:CC 4 "cc_reg_not_cr0_operand" "")
-       (compare:CC
-        (eq:DI (match_operand:DI 1 "gpc_reg_operand" "")
-               (match_operand:DI 2 "reg_or_cint_operand" ""))
-        (const_int 0)))
-   (set (match_operand:DI 0 "gpc_reg_operand" "")
-       (eq:DI (match_dup 1) (match_dup 2)))
-   (clobber (match_scratch:DI 3 ""))]
-  "TARGET_64BIT && reload_completed"
-  [(parallel [(set (match_dup 0)
-       (eq:DI (match_dup 1) (match_dup 2)))
-   (clobber (match_dup 3))])
-   (set (match_dup 4)
-       (compare:CC (match_dup 0)
-                   (const_int 0)))]
-  "")
+    operands[5] = GEN_INT (exact_log2 (GET_MODE_BITSIZE (<MODE>mode)));
+  })
 
-(define_split
-  [(set (match_operand:CC 4 "cc_reg_operand" "")
+(define_insn_and_split "*eq<mode>_compare"
+  [(set (match_operand:CC 5 "cc_reg_operand" "=y")
        (compare:CC
-        (eq:GPR (match_operand:GPR 1 "gpc_reg_operand" "")
-                (match_operand:GPR 2 "zero_constant" ""))
+        (eq:P (match_operand:P 1 "gpc_reg_operand" "=r")
+              (match_operand:P 2 "scc_eq_operand" "<scc_eq_op2>"))
         (const_int 0)))
-   (set (match_operand:GPR 0 "gpc_reg_operand" "")
-       (eq:GPR (match_dup 1) (match_dup 2)))
-   (clobber (match_scratch:GPR 3 ""))]
+   (set (match_operand:P 0 "gpc_reg_operand" "=r")
+       (eq:P (match_dup 1) (match_dup 2)))
+   (clobber (match_scratch:P 3 "=r"))
+   (clobber (match_scratch:P 4 "=r"))]
   ""
-  [(set (match_dup 0)
-       (clz:GPR (match_dup 1)))
-   (parallel [(set (match_dup 4)
-                  (compare:CC (lshiftrt:GPR (match_dup 0) (match_dup 5))
+  "#"
+  "reload_completed"
+  [(set (match_dup 3)
+       (clz:P (match_dup 4)))
+   (parallel [(set (match_dup 5)
+                  (compare:CC (lshiftrt:P (match_dup 3) (match_dup 6))
                               (const_int 0)))
              (set (match_dup 0)
-                  (lshiftrt:GPR (match_dup 0) (match_dup 5)))])]
+                  (lshiftrt:P (match_dup 3) (match_dup 6)))])]
   {
-    operands[5] = GEN_INT (exact_log2 (GET_MODE_BITSIZE (<MODE>mode)));
+    if (GET_CODE (operands[2]) != CONST_INT || INTVAL (operands[2]) != 0)
+      {
+       if (logical_operand (operands[2], <MODE>mode))
+         emit_insn (gen_rtx_SET (VOIDmode, operands[4],
+                                 gen_rtx_XOR (<MODE>mode,
+                                              operands[1], operands[2])));
+       else
+         emit_insn (gen_rtx_SET (VOIDmode, operands[4],
+                                 gen_rtx_PLUS (<MODE>mode, operands[1],
+                                               negate_rtx (<MODE>mode,
+                                                           operands[2]))));
+      }
+    else
+      operands[4] = operands[1];
+
+    operands[6] = GEN_INT (exact_log2 (GET_MODE_BITSIZE (<MODE>mode)));
   })
 
 ;; We have insns of the form shown by the first define_insn below.  If
 (define_insn ""
   [(set (match_operand:SI 0 "gpc_reg_operand" "=&r,&r,&r,&r,&r")
        (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 2 "scc_eq_operand" "r,O,K,L,I"))
                 (match_operand:SI 3 "gpc_reg_operand" "r,r,r,r,r")))]
   "TARGET_32BIT"
   "@
        (compare:CC
         (plus:SI
          (eq:SI (match_operand:SI 1 "gpc_reg_operand" "%r,r,r,r,r,r,r,r,r,r")
-                (match_operand:SI 2 "reg_or_cint_operand" "r,O,K,L,I,r,O,K,L,I"))
+                (match_operand:SI 2 "scc_eq_operand" "r,O,K,L,I,r,O,K,L,I"))
          (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"))]
        (compare:CC
         (plus:SI
          (eq:SI (match_operand:SI 1 "gpc_reg_operand" "")
-                (match_operand:SI 2 "reg_or_cint_operand" ""))
+                (match_operand:SI 2 "scc_eq_operand" ""))
          (match_operand:SI 3 "gpc_reg_operand" ""))
         (const_int 0)))
    (clobber (match_scratch:SI 4 ""))]
        (compare:CC
         (plus:SI
          (eq:SI (match_operand:SI 1 "gpc_reg_operand" "%r,r,r,r,r,r,r,r,r,r")
-                (match_operand:SI 2 "reg_or_cint_operand" "r,O,K,L,I,r,O,K,L,I"))
+                (match_operand:SI 2 "scc_eq_operand" "r,O,K,L,I,r,O,K,L,I"))
          (match_operand:SI 3 "gpc_reg_operand" "r,r,r,r,r,r,r,r,r,r"))
         (const_int 0)))
    (set (match_operand:SI 0 "gpc_reg_operand" "=&r,&r,&r,&r,&r,&r,&r,&r,&r,&r")
        (compare:CC
         (plus:SI
          (eq:SI (match_operand:SI 1 "gpc_reg_operand" "")
-                (match_operand:SI 2 "reg_or_cint_operand" ""))
+                (match_operand:SI 2 "scc_eq_operand" ""))
          (match_operand:SI 3 "gpc_reg_operand" ""))
         (const_int 0)))
    (set (match_operand:SI 0 "gpc_reg_operand" "")
 (define_insn ""
   [(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"))))]
+                      (match_operand:SI 2 "scc_eq_operand" "r,O,K,L,I"))))]
   "TARGET_32BIT"
   "@
    xor %0,%1,%2\;{ai|addic} %0,%0,-1\;{sfe|subfe} %0,%0,%0
   [(set_attr "type" "jmpreg")])
 
 (define_expand "indirect_jump"
-  [(set (pc) (match_operand 0 "register_operand" ""))]
-  ""
-  "
-{
-  if (TARGET_32BIT)
-    emit_jump_insn (gen_indirect_jumpsi (operands[0]));
-  else
-    emit_jump_insn (gen_indirect_jumpdi (operands[0]));
-  DONE;
-}")
+  [(set (pc) (match_operand 0 "register_operand" ""))])
 
-(define_insn "indirect_jumpsi"
-  [(set (pc) (match_operand:SI 0 "register_operand" "c,*l"))]
-  "TARGET_32BIT"
+(define_insn "*indirect_jump<mode>"
+  [(set (pc) (match_operand:P 0 "register_operand" "c,*l"))]
+  ""
   "@
    bctr
    {br|blr}"
   [(set_attr "type" "jmpreg")])
 
-(define_insn "indirect_jumpdi"
-  [(set (pc) (match_operand:DI 0 "register_operand" "c,*l"))]
-  "TARGET_64BIT"
-  "@
-   bctr
-   blr"
-  [(set_attr "type" "jmpreg")])
-
 ;; Table jump for switch statements:
 (define_expand "tablejump"
   [(use (match_operand 0 "" ""))
 
 (define_insn ""
   [(set (pc)
-       (match_operand:SI 0 "register_operand" "c,*l"))
+       (match_operand:P 0 "register_operand" "c,*l"))
    (use (label_ref (match_operand 1 "" "")))]
-  "TARGET_32BIT"
+  ""
   "@
    bctr
    {br|blr}"
   [(set_attr "type" "jmpreg")])
 
-(define_insn ""
-  [(set (pc)
-       (match_operand:DI 0 "register_operand" "c,*l"))
-   (use (label_ref (match_operand 1 "" "")))]
-  "TARGET_64BIT"
-  "@
-   bctr
-   blr"
-  [(set_attr "type" "jmpreg")])
-
 (define_insn "nop"
   [(const_int 0)]
   ""
   DONE;
 }")
 
-(define_expand "ctrsi"
+(define_expand "ctr<mode>"
   [(parallel [(set (pc)
-                  (if_then_else (ne (match_operand:SI 0 "register_operand" "")
+                  (if_then_else (ne (match_operand:P 0 "register_operand" "")
                                     (const_int 1))
                                 (label_ref (match_operand 1 "" ""))
                                 (pc)))
              (set (match_dup 0)
-                  (plus:SI (match_dup 0)
+                  (plus:P (match_dup 0)
                            (const_int -1)))
              (clobber (match_scratch:CC 2 ""))
-             (clobber (match_scratch:SI 3 ""))])]
-  "TARGET_32BIT"
-  "")
-
-(define_expand "ctrdi"
-  [(parallel [(set (pc)
-                  (if_then_else (ne (match_operand:DI 0 "register_operand" "")
-                                    (const_int 1))
-                                (label_ref (match_operand 1 "" ""))
-                                (pc)))
-             (set (match_dup 0)
-                  (plus:DI (match_dup 0)
-                           (const_int -1)))
-             (clobber (match_scratch:CC 2 ""))
-             (clobber (match_scratch:DI 3 ""))])]
-  "TARGET_64BIT"
+             (clobber (match_scratch:P 3 ""))])]
+  ""
   "")
 
 ;; We need to be able to do this for any operand, including MEM, or we
 ;; For the length attribute to be calculated correctly, the
 ;; label MUST be operand 0.
 
-(define_insn "*ctrsi_internal1"
+(define_insn "*ctr<mode>_internal1"
   [(set (pc)
-       (if_then_else (ne (match_operand:SI 1 "register_operand" "c,*r,*r,*r")
+       (if_then_else (ne (match_operand:P 1 "register_operand" "c,*r,*r,*r")
                          (const_int 1))
                      (label_ref (match_operand 0 "" ""))
                      (pc)))
-   (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_32BIT"
-  "*
-{
-  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" "*,12,16,16")])
-
-(define_insn "*ctrsi_internal2"
-  [(set (pc)
-       (if_then_else (ne (match_operand:SI 1 "register_operand" "c,*r,*r,*r")
-                         (const_int 1))
-                     (pc)
-                     (label_ref (match_operand 0 "" ""))))
-   (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_32BIT"
-  "*
-{
-  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" "*,12,16,16")])
-
-(define_insn "*ctrdi_internal1"
-  [(set (pc)
-       (if_then_else (ne (match_operand:DI 1 "register_operand" "c,*r,*r,*r")
-                         (const_int 1))
-                     (label_ref (match_operand 0 "" ""))
-                     (pc)))
-   (set (match_operand:DI 2 "nonimmediate_operand" "=1,*r,m,*c*l")
-       (plus:DI (match_dup 1)
+   (set (match_operand:P 2 "nonimmediate_operand" "=1,*r,m,*q*c*l")
+       (plus:P (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_64BIT"
+   (clobber (match_scratch:P 4 "=X,X,&r,r"))]
+  ""
   "*
 {
   if (which_alternative != 0)
   [(set_attr "type" "branch")
    (set_attr "length" "*,12,16,16")])
 
-(define_insn "*ctrdi_internal2"
+(define_insn "*ctr<mode>_internal2"
   [(set (pc)
-       (if_then_else (ne (match_operand:DI 1 "register_operand" "c,*r,*r,*r")
+       (if_then_else (ne (match_operand:P 1 "register_operand" "c,*r,*r,*r")
                          (const_int 1))
                      (pc)
                      (label_ref (match_operand 0 "" ""))))
-   (set (match_operand:DI 2 "nonimmediate_operand" "=1,*r,m,*c*l")
-       (plus:DI (match_dup 1)
+   (set (match_operand:P 2 "nonimmediate_operand" "=1,*r,m,*q*c*l")
+       (plus:P (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_64BIT"
+   (clobber (match_scratch:P 4 "=X,X,&r,r"))]
+  ""
   "*
 {
   if (which_alternative != 0)
 
 ;; Similar but use EQ
 
-(define_insn "*ctrsi_internal5"
+(define_insn "*ctr<mode>_internal5"
   [(set (pc)
-       (if_then_else (eq (match_operand:SI 1 "register_operand" "c,*r,*r,*r")
+       (if_then_else (eq (match_operand:P 1 "register_operand" "c,*r,*r,*r")
                          (const_int 1))
                      (label_ref (match_operand 0 "" ""))
                      (pc)))
-   (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_32BIT"
-  "*
-{
-  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" "*,12,16,16")])
-
-(define_insn "*ctrsi_internal6"
-  [(set (pc)
-       (if_then_else (eq (match_operand:SI 1 "register_operand" "c,*r,*r,*r")
-                         (const_int 1))
-                     (pc)
-                     (label_ref (match_operand 0 "" ""))))
-   (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_32BIT"
-  "*
-{
-  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" "*,12,16,16")])
-
-(define_insn "*ctrdi_internal5"
-  [(set (pc)
-       (if_then_else (eq (match_operand:DI 1 "register_operand" "c,*r,*r,*r")
-                         (const_int 1))
-                     (label_ref (match_operand 0 "" ""))
-                     (pc)))
-   (set (match_operand:DI 2 "nonimmediate_operand" "=1,*r,m,*c*l")
-       (plus:DI (match_dup 1)
+   (set (match_operand:P 2 "nonimmediate_operand" "=1,*r,m,*q*c*l")
+       (plus:P (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_64BIT"
+   (clobber (match_scratch:P 4 "=X,X,&r,r"))]
+  ""
   "*
 {
   if (which_alternative != 0)
   [(set_attr "type" "branch")
    (set_attr "length" "*,12,16,16")])
 
-(define_insn "*ctrdi_internal6"
+(define_insn "*ctr<mode>_internal6"
   [(set (pc)
-       (if_then_else (eq (match_operand:DI 1 "register_operand" "c,*r,*r,*r")
+       (if_then_else (eq (match_operand:P 1 "register_operand" "c,*r,*r,*r")
                          (const_int 1))
                      (pc)
                      (label_ref (match_operand 0 "" ""))))
-   (set (match_operand:DI 2 "nonimmediate_operand" "=1,*r,m,*c*l")
-       (plus:DI (match_dup 1)
+   (set (match_operand:P 2 "nonimmediate_operand" "=1,*r,m,*q*c*l")
+       (plus:P (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_64BIT"
+   (clobber (match_scratch:P 4 "=X,X,&r,r"))]
+  ""
   "*
 {
   if (which_alternative != 0)
 (define_split
   [(set (pc)
        (if_then_else (match_operator 2 "comparison_operator"
-                                     [(match_operand:SI 1 "gpc_reg_operand" "")
+                                     [(match_operand:P 1 "gpc_reg_operand" "")
                                       (const_int 1)])
                      (match_operand 5 "" "")
                      (match_operand 6 "" "")))
-   (set (match_operand:SI 0 "gpc_reg_operand" "")
-       (plus:SI (match_dup 1)
-                (const_int -1)))
-   (clobber (match_scratch:CC 3 ""))
-   (clobber (match_scratch:SI 4 ""))]
-  "TARGET_32BIT && reload_completed"
-  [(parallel [(set (match_dup 3)
-                  (compare:CC (plus:SI (match_dup 1)
-                                       (const_int -1))
-                              (const_int 0)))
-             (set (match_dup 0)
-                  (plus:SI (match_dup 1)
-                           (const_int -1)))])
-   (set (pc) (if_then_else (match_dup 7)
-                          (match_dup 5)
-                          (match_dup 6)))]
-  "
-{ 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"
-                                     [(match_operand:SI 1 "gpc_reg_operand" "")
-                                      (const_int 1)])
-                     (match_operand 5 "" "")
-                     (match_operand 6 "" "")))
-   (set (match_operand:SI 0 "nonimmediate_operand" "")
-       (plus:SI (match_dup 1) (const_int -1)))
-   (clobber (match_scratch:CC 3 ""))
-   (clobber (match_scratch:SI 4 ""))]
-  "TARGET_32BIT && reload_completed
-   && ! gpc_reg_operand (operands[0], SImode)"
-  [(parallel [(set (match_dup 3)
-                  (compare:CC (plus:SI (match_dup 1)
-                                       (const_int -1))
-                              (const_int 0)))
-             (set (match_dup 4)
-                  (plus:SI (match_dup 1)
-                           (const_int -1)))])
-   (set (match_dup 0)
-       (match_dup 4))
-   (set (pc) (if_then_else (match_dup 7)
-                          (match_dup 5)
-                          (match_dup 6)))]
-  "
-{ 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"
-                                     [(match_operand:DI 1 "gpc_reg_operand" "")
-                                      (const_int 1)])
-                     (match_operand 5 "" "")
-                     (match_operand 6 "" "")))
-   (set (match_operand:DI 0 "gpc_reg_operand" "")
-       (plus:DI (match_dup 1)
-                (const_int -1)))
+   (set (match_operand:P 0 "gpc_reg_operand" "")
+       (plus:P (match_dup 1) (const_int -1)))
    (clobber (match_scratch:CC 3 ""))
-   (clobber (match_scratch:DI 4 ""))]
-  "TARGET_64BIT && reload_completed"
+   (clobber (match_scratch:P 4 ""))]
+  "reload_completed"
   [(parallel [(set (match_dup 3)
-                  (compare:CC (plus:DI (match_dup 1)
+                  (compare:CC (plus:P (match_dup 1)
                                        (const_int -1))
                               (const_int 0)))
              (set (match_dup 0)
-                  (plus:DI (match_dup 1)
+                  (plus:P (match_dup 1)
                            (const_int -1)))])
    (set (pc) (if_then_else (match_dup 7)
                           (match_dup 5)
 (define_split
   [(set (pc)
        (if_then_else (match_operator 2 "comparison_operator"
-                                     [(match_operand:DI 1 "gpc_reg_operand" "")
+                                     [(match_operand:P 1 "gpc_reg_operand" "")
                                       (const_int 1)])
                      (match_operand 5 "" "")
                      (match_operand 6 "" "")))
-   (set (match_operand:DI 0 "nonimmediate_operand" "")
-       (plus:DI (match_dup 1) (const_int -1)))
+   (set (match_operand:P 0 "nonimmediate_operand" "")
+       (plus:P (match_dup 1) (const_int -1)))
    (clobber (match_scratch:CC 3 ""))
-   (clobber (match_scratch:DI 4 ""))]
-  "TARGET_64BIT && reload_completed
-   && ! gpc_reg_operand (operands[0], DImode)"
+   (clobber (match_scratch:P 4 ""))]
+  "reload_completed && ! gpc_reg_operand (operands[0], SImode)"
   [(parallel [(set (match_dup 3)
-                  (compare:CC (plus:DI (match_dup 1)
+                  (compare:CC (plus:P (match_dup 1)
                                        (const_int -1))
                               (const_int 0)))
              (set (match_dup 4)
-                  (plus:DI (match_dup 1)
+                  (plus:P (match_dup 1)
                            (const_int -1)))])
    (set (match_dup 0)
        (match_dup 4))
 
 (define_insn ""
   [(trap_if (match_operator 0 "trap_comparison_operator"
-                            [(match_operand:SI 1 "register_operand" "r")
-                             (match_operand:SI 2 "reg_or_short_operand" "rI")])
+                            [(match_operand:GPR 1 "register_operand" "r")
+                             (match_operand:GPR 2 "reg_or_short_operand" "rI")])
            (const_int 0))]
   ""
-  "{t|tw}%V0%I2 %1,%2")
-
-(define_insn ""
-  [(trap_if (match_operator 0 "trap_comparison_operator"
-                            [(match_operand:DI 1 "register_operand" "r")
-                             (match_operand:DI 2 "reg_or_short_operand" "rI")])
-           (const_int 0))]
-  "TARGET_POWERPC64"
-  "td%V0%I2 %1,%2")
+  "{t|t<wd>}%V0%I2 %1,%2")
 \f
 ;; Insns related to generating the function prologue and epilogue.
 
   "TARGET_MULTIPLE"
   "{stm|stmw} %2,%1")
 
-(define_insn "*save_fpregs_si"
+(define_insn "*save_fpregs_<mode>"
   [(match_parallel 0 "any_parallel_operand"
-                  [(clobber (match_operand:SI 1 "register_operand" "=l"))
-                   (use (match_operand:SI 2 "call_operand" "s"))
+                  [(clobber (match_operand:P 1 "register_operand" "=l"))
+                   (use (match_operand:P 2 "call_operand" "s"))
                    (set (match_operand:DF 3 "memory_operand" "=m")
                         (match_operand:DF 4 "gpc_reg_operand" "f"))])]
-  "TARGET_32BIT"
-  "bl %z2"
-  [(set_attr "type" "branch")
-   (set_attr "length" "4")])
-
-(define_insn "*save_fpregs_di"
-  [(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")
-                        (match_operand:DF 4 "gpc_reg_operand" "f"))])]
-  "TARGET_64BIT"
+  ""
   "bl %z2"
   [(set_attr "type" "branch")
    (set_attr "length" "4")])
   "TARGET_MULTIPLE"
   "{lm|lmw} %1,%2")
 
-(define_insn "*return_internal_si"
+(define_insn "*return_internal_<mode>"
   [(return)
-   (use (match_operand:SI 0 "register_operand" "lc"))]
-  "TARGET_32BIT"
-  "b%T0"
-  [(set_attr "type" "jmpreg")])
-
-(define_insn "*return_internal_di"
-  [(return)
-   (use (match_operand:DI 0 "register_operand" "lc"))]
-  "TARGET_64BIT"
+   (use (match_operand:P 0 "register_operand" "lc"))]
+  ""
   "b%T0"
   [(set_attr "type" "jmpreg")])
 
 ; FIXME: This would probably be somewhat simpler if the Cygnus sibcall
 ; stuff was in GCC.  Oh, and "any_parallel_operand" is a bit flexible...
 
-(define_insn "*return_and_restore_fpregs_si"
- [(match_parallel 0 "any_parallel_operand"
-                  [(return)
-                  (use (match_operand:SI 1 "register_operand" "l"))
-                  (use (match_operand:SI 2 "call_operand" "s"))
-                  (set (match_operand:DF 3 "gpc_reg_operand" "=f")
-                       (match_operand:DF 4 "memory_operand" "m"))])]
- "TARGET_32BIT"
- "b %z2")
-
-(define_insn "*return_and_restore_fpregs_di"
+(define_insn "*return_and_restore_fpregs_<mode>"
  [(match_parallel 0 "any_parallel_operand"
                   [(return)
-                  (use (match_operand:DI 1 "register_operand" "l"))
-                  (use (match_operand:DI 2 "call_operand" "s"))
+                  (use (match_operand:P 1 "register_operand" "l"))
+                  (use (match_operand:P 2 "call_operand" "s"))
                   (set (match_operand:DF 3 "gpc_reg_operand" "=f")
                        (match_operand:DF 4 "memory_operand" "m"))])]
- "TARGET_64BIT"
+ ""
  "b %z2")
 
 ; This is used in compiling the unwind routines.
 }")
 
 ; We can't expand this before we know where the link register is stored.
-(define_insn "eh_set_lr_si"
-  [(unspec_volatile [(match_operand:SI 0 "register_operand" "r")]
+(define_insn "eh_set_lr_<mode>"
+  [(unspec_volatile [(match_operand:P 0 "register_operand" "r")]
                    UNSPECV_EH_RR)
-   (clobber (match_scratch:SI 1 "=&b"))]
-  "TARGET_32BIT"
-  "#")
-
-(define_insn "eh_set_lr_di"
-  [(unspec_volatile [(match_operand:DI 0 "register_operand" "r")]
-                   UNSPECV_EH_RR)
-   (clobber (match_scratch:DI 1 "=&b"))]
-  "TARGET_64BIT"
+   (clobber (match_scratch:P 1 "=&b"))]
+  ""
   "#")
 
 (define_split
 }"
   [(set_attr "type" "load")])
 \f
-; Atomic instructions
-
-(define_insn "memory_barrier"
-  [(set (mem:BLK (match_scratch 0 "X"))
-       (unspec:BLK [(mem:BLK (match_scratch 1 "X"))] UNSPEC_SYNC))]
-  ""
-  "{ics|sync}")
-
-(define_insn "sync_compare_and_swap<mode>"
-  [(set (match_operand:GPR 1 "memory_operand" "+Z")
-       (unspec:GPR [(match_dup 1)
-                    (match_operand:GPR 2 "reg_or_short_operand" "rI")
-                    (match_operand:GPR 3 "gpc_reg_operand" "r")]
-                   UNSPEC_SYNC_SWAP))
-   (set (match_operand:GPR 0 "gpc_reg_operand" "=&r") (match_dup 1))
-   (set (mem:BLK (match_scratch 5 "X"))
-       (unspec:BLK [(mem:BLK (match_scratch 6 "X"))] UNSPEC_SYNC))
-   (clobber (match_scratch:CC 4 "=&x"))]
-  "TARGET_POWERPC"
-  "sync\n\t<larx> %0,%y1\n\tcmp<wd>%I2 %0,%2\n\tbne- $+12\n\t<stcx> %3,%y1\n\tbne- $-16\n\tisync"
-  [(set_attr "length" "28")])
-
-(define_expand "sync_add<mode>"
-  [(use (match_operand:INT1 0 "memory_operand" ""))
-   (use (match_operand:INT1 1 "add_operand" ""))]
-  "TARGET_POWERPC"
-  "
-{
-  rs6000_emit_sync (PLUS, <MODE>mode, operands[0], operands[1], 
-                   NULL_RTX, NULL_RTX, true);
-  DONE;
-}")
-
-(define_expand "sync_sub<mode>"
-  [(use (match_operand:GPR 0 "memory_operand" ""))
-   (use (match_operand:GPR 1 "gpc_reg_operand" ""))]
-  "TARGET_POWERPC"
-  "
-{
-  rs6000_emit_sync (MINUS, <MODE>mode, operands[0], operands[1], 
-                   NULL_RTX, NULL_RTX, true);
-  DONE;
-}")
-
-(define_expand "sync_ior<mode>"
-  [(use (match_operand:INT1 0 "memory_operand" ""))
-   (use (match_operand:INT1 1 "logical_operand" ""))]
-  "TARGET_POWERPC"
-  "
-{
-  rs6000_emit_sync (IOR, <MODE>mode, operands[0], operands[1], 
-                   NULL_RTX, NULL_RTX, true);
-  DONE;
-}")
-
-(define_expand "sync_and<mode>"
-  [(use (match_operand:INT1 0 "memory_operand" ""))
-   (use (match_operand:INT1 1 "and_operand" ""))]
-  "TARGET_POWERPC"
-  "
-{
-  rs6000_emit_sync (AND, <MODE>mode, operands[0], operands[1], 
-                   NULL_RTX, NULL_RTX, true);
-  DONE;
-}")
-
-(define_expand "sync_xor<mode>"
-  [(use (match_operand:INT1 0 "memory_operand" ""))
-   (use (match_operand:INT1 1 "logical_operand" ""))]
-  "TARGET_POWERPC"
-  "
-{
-  rs6000_emit_sync (XOR, <MODE>mode, operands[0], operands[1], 
-                   NULL_RTX, NULL_RTX, true);
-  DONE;
-}")
-
-(define_expand "sync_nand<mode>"
-  [(use (match_operand:INT1 0 "memory_operand" ""))
-   (use (match_operand:INT1 1 "gpc_reg_operand" ""))]
-  "TARGET_POWERPC"
-  "
-{
-  rs6000_emit_sync (AND, <MODE>mode, 
-                   gen_rtx_NOT (<MODE>mode, operands[0]),
-                   operands[1],
-                   NULL_RTX, NULL_RTX, true);
-  DONE;
-}")
-
-(define_expand "sync_old_add<mode>"
-  [(use (match_operand:INT1 0 "gpc_reg_operand" ""))
-   (use (match_operand:INT1 1 "memory_operand" ""))
-   (use (match_operand:INT1 2 "add_operand" ""))]
-  "TARGET_POWERPC"
-  "
-{
-  rs6000_emit_sync (PLUS, <MODE>mode, operands[1], operands[2], 
-                   operands[0], NULL_RTX, true);
-  DONE;
-}")
-
-(define_expand "sync_old_sub<mode>"
-  [(use (match_operand:GPR 0 "gpc_reg_operand" ""))
-   (use (match_operand:GPR 1 "memory_operand" ""))
-   (use (match_operand:GPR 2 "gpc_reg_operand" ""))]
-  "TARGET_POWERPC"
-  "
-{
-  rs6000_emit_sync (MINUS, <MODE>mode, operands[1], operands[2], 
-                   operands[0], NULL_RTX, true);
-  DONE;
-}")
-
-(define_expand "sync_old_ior<mode>"
-  [(use (match_operand:INT1 0 "gpc_reg_operand" ""))
-   (use (match_operand:INT1 1 "memory_operand" ""))
-   (use (match_operand:INT1 2 "logical_operand" ""))]
-  "TARGET_POWERPC"
-  "
-{
-  rs6000_emit_sync (IOR, <MODE>mode, operands[1], operands[2], 
-                   operands[0], NULL_RTX, true);
-  DONE;
-}")
-
-(define_expand "sync_old_and<mode>"
-  [(use (match_operand:INT1 0 "gpc_reg_operand" ""))
-   (use (match_operand:INT1 1 "memory_operand" ""))
-   (use (match_operand:INT1 2 "and_operand" ""))]
-  "TARGET_POWERPC"
-  "
-{
-  rs6000_emit_sync (AND, <MODE>mode, operands[1], operands[2], 
-                   operands[0], NULL_RTX, true);
-  DONE;
-}")
-
-(define_expand "sync_old_xor<mode>"
-  [(use (match_operand:INT1 0 "gpc_reg_operand" ""))
-   (use (match_operand:INT1 1 "memory_operand" ""))
-   (use (match_operand:INT1 2 "logical_operand" ""))]
-  "TARGET_POWERPC"
-  "
-{
-  rs6000_emit_sync (XOR, <MODE>mode, operands[1], operands[2], 
-                   operands[0], NULL_RTX, true);
-  DONE;
-}")
-
-(define_expand "sync_old_nand<mode>"
-  [(use (match_operand:INT1 0 "gpc_reg_operand" ""))
-   (use (match_operand:INT1 1 "memory_operand" ""))
-   (use (match_operand:INT1 2 "gpc_reg_operand" ""))]
-  "TARGET_POWERPC"
-  "
-{
-  rs6000_emit_sync (AND, <MODE>mode, 
-                   gen_rtx_NOT (<MODE>mode, operands[1]),
-                   operands[2],
-                   operands[0], NULL_RTX, true);
-  DONE;
-}")
-
-(define_expand "sync_new_add<mode>"
-  [(use (match_operand:INT1 0 "gpc_reg_operand" ""))
-   (use (match_operand:INT1 1 "memory_operand" ""))
-   (use (match_operand:INT1 2 "add_operand" ""))]
-  "TARGET_POWERPC"
-  "
-{
-  rs6000_emit_sync (PLUS, <MODE>mode, operands[1], operands[2], 
-                   NULL_RTX, operands[0], true);
-  DONE;
-}")
-
-(define_expand "sync_new_sub<mode>"
-  [(use (match_operand:GPR 0 "gpc_reg_operand" ""))
-   (use (match_operand:GPR 1 "memory_operand" ""))
-   (use (match_operand:GPR 2 "gpc_reg_operand" ""))]
-  "TARGET_POWERPC"
-  "
-{
-  rs6000_emit_sync (MINUS, <MODE>mode, operands[1], operands[2], 
-                   NULL_RTX, operands[0], true);
-  DONE;
-}")
-
-(define_expand "sync_new_ior<mode>"
-  [(use (match_operand:INT1 0 "gpc_reg_operand" ""))
-   (use (match_operand:INT1 1 "memory_operand" ""))
-   (use (match_operand:INT1 2 "logical_operand" ""))]
-  "TARGET_POWERPC"
-  "
-{
-  rs6000_emit_sync (IOR, <MODE>mode, operands[1], operands[2], 
-                   NULL_RTX, operands[0], true);
-  DONE;
-}")
-
-(define_expand "sync_new_and<mode>"
-  [(use (match_operand:INT1 0 "gpc_reg_operand" ""))
-   (use (match_operand:INT1 1 "memory_operand" ""))
-   (use (match_operand:INT1 2 "and_operand" ""))]
-  "TARGET_POWERPC"
-  "
-{
-  rs6000_emit_sync (AND, <MODE>mode, operands[1], operands[2], 
-                   NULL_RTX, operands[0], true);
-  DONE;
-}")
-
-(define_expand "sync_new_xor<mode>"
-  [(use (match_operand:INT1 0 "gpc_reg_operand" ""))
-   (use (match_operand:INT1 1 "memory_operand" ""))
-   (use (match_operand:INT1 2 "logical_operand" ""))]
-  "TARGET_POWERPC"
-  "
-{
-  rs6000_emit_sync (XOR, <MODE>mode, operands[1], operands[2], 
-                   NULL_RTX, operands[0], true);
-  DONE;
-}")
-
-(define_expand "sync_new_nand<mode>"
-  [(use (match_operand:INT1 0 "gpc_reg_operand" ""))
-   (use (match_operand:INT1 1 "memory_operand" ""))
-   (use (match_operand:INT1 2 "gpc_reg_operand" ""))]
-  "TARGET_POWERPC"
-  "
-{
-  rs6000_emit_sync (AND, <MODE>mode, 
-                   gen_rtx_NOT (<MODE>mode, operands[1]),
-                   operands[2],
-                   NULL_RTX, operands[0], true);
-  DONE;
-}")
-
-; the sync_*_internal patterns all have these operands:
-; 0 - memory location
-; 1 - operand
-; 2 - value in memory after operation
-; 3 - value in memory immediately before operation
-
-(define_insn "*sync_add<mode>_internal"
-  [(set (match_operand:GPR 2 "gpc_reg_operand" "=&r,&r")
-       (plus:GPR (match_operand:GPR 0 "memory_operand" "+Z,Z")
-                (match_operand:GPR 1 "add_operand" "rI,L")))
-   (set (match_operand:GPR 3 "gpc_reg_operand" "=&b,&b") (match_dup 0))
-   (set (match_dup 0) 
-       (unspec:GPR [(plus:GPR (match_dup 0) (match_dup 1))]
-                  UNSPEC_SYNC_OP))
-   (clobber (match_scratch:CC 4 "=&x,&x"))]
-  "TARGET_POWERPC"
-  "@
-   <larx> %3,%y0\n\tadd%I1 %2,%3,%1\n\t<stcx> %2,%y0\n\tbne- $-12
-   <larx> %3,%y0\n\taddis %2,%3,%v1\n\t<stcx> %2,%y0\n\tbne- $-12"
-  [(set_attr "length" "16,16")])
-
-(define_insn "*sync_addshort_internal"
-  [(set (match_operand:SI 2 "gpc_reg_operand" "=&r")
-       (ior:SI (and:SI (plus:SI (match_operand:SI 0 "memory_operand" "+Z")
-                                (match_operand:SI 1 "add_operand" "rI"))
-                       (match_operand:SI 4 "gpc_reg_operand" "r"))
-               (and:SI (not:SI (match_dup 4)) (match_dup 0))))
-   (set (match_operand:SI 3 "gpc_reg_operand" "=&b") (match_dup 0))
-   (set (match_dup 0) 
-       (unspec:SI [(ior:SI (and:SI (plus:SI (match_dup 0) (match_dup 1))
-                                   (match_dup 4))
-                           (and:SI (not:SI (match_dup 4)) (match_dup 0)))]
-                  UNSPEC_SYNC_OP))
-   (clobber (match_scratch:CC 5 "=&x"))
-   (clobber (match_scratch:SI 6 "=&r"))]
-  "TARGET_POWERPC"
-  "lwarx %3,%y0\n\tadd%I1 %2,%3,%1\n\tandc %6,%3,%4\n\tand %2,%2,%4\n\tor %2,%2,%6\n\tstwcx. %2,%y0\n\tbne- $-24"
-  [(set_attr "length" "28")])
-
-(define_insn "*sync_sub<mode>_internal"
-  [(set (match_operand:GPR 2 "gpc_reg_operand" "=&r")
-       (minus:GPR (match_operand:GPR 0 "memory_operand" "+Z")
-                 (match_operand:GPR 1 "gpc_reg_operand" "r")))
-   (set (match_operand:GPR 3 "gpc_reg_operand" "=&b") (match_dup 0))
-   (set (match_dup 0) 
-       (unspec:GPR [(minus:GPR (match_dup 0) (match_dup 1))]
-                  UNSPEC_SYNC_OP))
-   (clobber (match_scratch:CC 4 "=&x"))]
-  "TARGET_POWERPC"
-  "<larx> %3,%y0\n\tsubf %2,%1,%3\n\t<stcx> %2,%y0\n\tbne- $-12"
-  [(set_attr "length" "16")])
-
-(define_insn "*sync_andsi_internal"
-  [(set (match_operand:SI 2 "gpc_reg_operand" "=&r,&r,&r,&r")
-       (and:SI (match_operand:SI 0 "memory_operand" "+Z,Z,Z,Z")
-               (match_operand:SI 1 "and_operand" "r,T,K,L")))
-   (set (match_operand:SI 3 "gpc_reg_operand" "=&b,&b,&b,&b") (match_dup 0))
-   (set (match_dup 0) 
-       (unspec:SI [(and:SI (match_dup 0) (match_dup 1))]
-                  UNSPEC_SYNC_OP))
-   (clobber (match_scratch:CC 4 "=&x,&x,&x,&x"))]
-  "TARGET_POWERPC"
-  "@
-   lwarx %3,%y0\n\tand %2,%3,%1\n\tstwcx. %2,%y0\n\tbne- $-12
-   lwarx %3,%y0\n\trlwinm %2,%3,0,%m1,%M1\n\tstwcx. %2,%y0\n\tbne- $-12
-   lwarx %3,%y0\n\tandi. %2,%3,%b1\n\tstwcx. %2,%y0\n\tbne- $-12
-   lwarx %3,%y0\n\tandis. %2,%3,%u1\n\tstwcx. %2,%y0\n\tbne- $-12"
-  [(set_attr "length" "16,16,16,16")])
-
-(define_insn "*sync_anddi_internal"
-  [(set (match_operand:DI 2 "gpc_reg_operand" "=&r,&r,&r,&r,&r")
-       (and:DI (match_operand:DI 0 "memory_operand" "+Z,Z,Z,Z,Z")
-               (match_operand:DI 1 "and_operand" "r,S,T,K,J")))
-   (set (match_operand:DI 3 "gpc_reg_operand" "=&b,&b,&b,&b,&b") (match_dup 0))
-   (set (match_dup 0) 
-       (unspec:DI [(and:DI (match_dup 0) (match_dup 1))]
-                  UNSPEC_SYNC_OP))
-   (clobber (match_scratch:CC 4 "=&x,&x,&x,&x,&x"))]
-  "TARGET_POWERPC64"
-  "@
-   ldarx %3,%y0\n\tand %2,%3,%1\n\tstdcx. %2,%y0\n\tbne- $-12
-   ldarx %3,%y0\n\trldic%B1 %2,%3,0,%S1\n\tstdcx. %2,%y0\n\tbne- $-12
-   ldarx %3,%y0\n\trlwinm %2,%3,0,%m1,%M1\n\tstdcx. %2,%y0\n\tbne- $-12
-   ldarx %3,%y0\n\tandi. %2,%3,%b1\n\tstdcx. %2,%y0\n\tbne- $-12
-   ldarx %3,%y0\n\tandis. %2,%3,%b1\n\tstdcx. %2,%y0\n\tbne- $-12"
-  [(set_attr "length" "16,16,16,16,16")])
-
-(define_insn "*sync_boolsi_internal"
-  [(set (match_operand:SI 2 "gpc_reg_operand" "=&r,&r,&r")
-       (match_operator:SI 4 "boolean_or_operator"
-        [(match_operand:SI 0 "memory_operand" "+Z,Z,Z")
-         (match_operand:SI 1 "logical_operand" "r,K,L")]))
-   (set (match_operand:SI 3 "gpc_reg_operand" "=&b,&b,&b") (match_dup 0))
-   (set (match_dup 0) (unspec:SI [(match_dup 4)] UNSPEC_SYNC_OP))
-   (clobber (match_scratch:CC 5 "=&x,&x,&x"))]
-  "TARGET_POWERPC"
-  "@
-   lwarx %3,%y0\n\t%q4 %2,%3,%1\n\tstwcx. %2,%y0\n\tbne- $-12
-   lwarx %3,%y0\n\t%q4i %2,%3,%b1\n\tstwcx. %2,%y0\n\tbne- $-12
-   lwarx %3,%y0\n\t%q4is %2,%3,%u1\n\tstwcx. %2,%y0\n\tbne- $-12"
-  [(set_attr "length" "16,16,16")])
-
-(define_insn "*sync_booldi_internal"
-  [(set (match_operand:DI 2 "gpc_reg_operand" "=&r,&r,&r")
-       (match_operator:DI 4 "boolean_or_operator"
-        [(match_operand:DI 0 "memory_operand" "+Z,Z,Z")
-         (match_operand:DI 1 "logical_operand" "r,K,JF")]))
-   (set (match_operand:DI 3 "gpc_reg_operand" "=&b,&b,&b") (match_dup 0))
-   (set (match_dup 0) (unspec:DI [(match_dup 4)] UNSPEC_SYNC_OP))
-   (clobber (match_scratch:CC 5 "=&x,&x,&x"))]
-  "TARGET_POWERPC64"
-  "@
-   ldarx %3,%y0\n\t%q4 %2,%3,%1\n\tstdcx. %2,%y0\n\tbne- $-12
-   ldarx %3,%y0\n\t%q4i %2,%3,%b1\n\tstdcx. %2,%y0\n\tbne- $-12
-   ldarx %3,%y0\n\t%q4is %2,%3,%u1\n\tstdcx. %2,%y0\n\tbne- $-12"
-  [(set_attr "length" "16,16,16")])
-
-(define_insn "*sync_boolc<mode>_internal"
-  [(set (match_operand:GPR 2 "gpc_reg_operand" "=&r")
-       (match_operator:GPR 4 "boolean_operator"
-        [(not:GPR (match_operand:GPR 0 "memory_operand" "+Z"))
-         (match_operand:GPR 1 "gpc_reg_operand" "r")]))
-   (set (match_operand:GPR 3 "gpc_reg_operand" "=&b") (match_dup 0))
-   (set (match_dup 0) (unspec:GPR [(match_dup 4)] UNSPEC_SYNC_OP))
-   (clobber (match_scratch:CC 5 "=&x"))]
-  "TARGET_POWERPC"
-  "<larx> %3,%y0\n\t%q4 %2,%1,%3\n\t<stcx> %2,%y0\n\tbne- $-12"
-  [(set_attr "length" "16")])
-
-; This pattern could also take immediate values of operand 1,
-; since the non-NOT version of the operator is used; but this is not
-; very useful, since in practice operand 1 is a full 32-bit value.
-; Likewise, operand 5 is in practice either <= 2^16 or it is a register.
-(define_insn "*sync_boolcshort_internal"
-  [(set (match_operand:SI 2 "gpc_reg_operand" "=&r")
-       (match_operator:SI 4 "boolean_operator"
-        [(xor:SI (match_operand:SI 0 "memory_operand" "+Z")
-                 (match_operand:SI 5 "logical_operand" "rK"))
-         (match_operand:SI 1 "gpc_reg_operand" "r")]))
-   (set (match_operand:SI 3 "gpc_reg_operand" "=&b") (match_dup 0))
-   (set (match_dup 0) (unspec:SI [(match_dup 4)] UNSPEC_SYNC_OP))
-   (clobber (match_scratch:CC 6 "=&x"))]
-  "TARGET_POWERPC"
-  "lwarx %3,%y0\n\txor%I2 %2,%3,%5\n\t%q4 %2,%2,%1\n\tstwcx. %2,%y0\n\tbne- $-16"
-  [(set_attr "length" "20")])
-
-(define_insn "*sync_boolc<mode>_internal2"
-  [(set (match_operand:GPR 2 "gpc_reg_operand" "=&r")
-       (match_operator:GPR 4 "boolean_operator"
-        [(not:GPR (match_operand:GPR 1 "gpc_reg_operand" "r"))
-         (match_operand:GPR 0 "memory_operand" "+Z")]))
-   (set (match_operand:GPR 3 "gpc_reg_operand" "=&b") (match_dup 0))
-   (set (match_dup 0) (unspec:GPR [(match_dup 4)] UNSPEC_SYNC_OP))
-   (clobber (match_scratch:CC 5 "=&x"))]
-  "TARGET_POWERPC"
-  "<larx> %3,%y0\n\t%q4 %2,%3,%1\n\t<stcx> %2,%y0\n\tbne- $-12"
-  [(set_attr "length" "16")])
-
-(define_insn "*sync_boolcc<mode>_internal"
-  [(set (match_operand:GPR 2 "gpc_reg_operand" "=&r")
-       (match_operator:GPR 4 "boolean_operator"
-        [(not:GPR (match_operand:GPR 0 "memory_operand" "+Z"))
-         (not:GPR (match_operand:GPR 1 "gpc_reg_operand" "r"))]))
-   (set (match_operand:GPR 3 "gpc_reg_operand" "=&b") (match_dup 0))
-   (set (match_dup 0) (unspec:GPR [(match_dup 4)] UNSPEC_SYNC_OP))
-   (clobber (match_scratch:CC 5 "=&x"))]
-  "TARGET_POWERPC"
-  "<larx> %3,%y0\n\t%q4 %2,%1,%3\n\t<stcx> %2,%y0\n\tbne- $-12"
-  [(set_attr "length" "16")])
-
-(define_insn "isync"
-  [(set (mem:BLK (match_scratch 0 "X"))
-        (unspec:BLK [(mem:BLK (match_scratch 1 "X"))] UNSPEC_ISYNC))]
-  "TARGET_POWERPC"
-  "isync")
-
-(define_insn "sync_lock_test_and_set<mode>"
-  [(set (match_operand:GPR 0 "gpc_reg_operand" "=&r")
-       (match_operand:GPR 1 "memory_operand" "+Z"))
-   (set (match_dup 1) (unspec:GPR [(match_operand:GPR 2 "gpc_reg_operand" "r")] 
-                                UNSPEC_SYNC_OP))
-   (clobber (match_scratch:CC 3 "=&x"))
-   (set (mem:BLK (match_scratch 4 "X"))
-        (unspec:BLK [(mem:BLK (match_scratch 5 "X"))] UNSPEC_ISYNC))]
-  "TARGET_POWERPC"
-  "<larx> %0,%y1\n\t<stcx> %2,%y1\n\tbne- $-8\n\tisync"
-  [(set_attr "length" "16")])
-
-(define_expand "sync_lock_release<mode>"
-  [(set (match_operand:INT 0 "memory_operand")
-       (match_operand:INT 1 "any_operand"))]
-  ""
-  "
-{
-  emit_insn (gen_lwsync ());
-  emit_move_insn (operands[0], operands[1]);
-  DONE;
-}")
-
-; Some AIX assemblers don't accept lwsync, so we use a .long.
-(define_insn "lwsync"
-  [(set (mem:BLK (match_scratch 0 "X"))
-        (unspec:BLK [(mem:BLK (match_scratch 1 "X"))] UNSPEC_LWSYNC))]
-  ""
-  ".long 0x7c2004ac")
-
-\f
 
+(include "sync.md")
 (include "altivec.md")
 (include "spe.md")