]> gcc.gnu.org Git - gcc.git/commitdiff
cse.c (fold_rtx): Use simplify_subreg.
authorJan Hubicka <jh@suse.cz>
Thu, 17 May 2001 18:46:58 +0000 (20:46 +0200)
committerJan Hubicka <hubicka@gcc.gnu.org>
Thu, 17 May 2001 18:46:58 +0000 (18:46 +0000)
* cse.c (fold_rtx): Use simplify_subreg.

* simplify-rtx.c (simplify_replace_rtx): Use simplify_gen_subreg.
(simplify_gen_subreg): New.
(simplify_rtx): Use simplify_subreg.
* rtl.h (simplify_gen_subreg): Declare.

From-SVN: r42221

gcc/ChangeLog
gcc/cse.c
gcc/rtl.h
gcc/simplify-rtx.c

index 50551d9ea0f605b78afa9fafc86cb9ce4ccf7499..b5be8d85fb16bfa5a750b608190195b67372dd0d 100644 (file)
@@ -1,3 +1,12 @@
+Thu May 17 20:43:36 CEST 2001  Jan Hubicka  <jh@suse.cz>
+
+       * cse.c (fold_rtx): Use simplify_subreg.
+
+       * simplify-rtx.c (simplify_replace_rtx): Use simplify_gen_subreg.
+       (simplify_gen_subreg): New.
+       (simplify_rtx): Use simplify_subreg.
+       * rtl.h (simplify_gen_subreg): Declare.
+
 2001-05-17  Mark Mitchell  <mark@codesourcery.com>
 
        * doc/install.texi: Update Solaris information.
index f3978e4b257048c3b96650e2b34d6bce671767de..43cbf9ca020f370ee108579311ad63b31f886945 100644 (file)
--- a/gcc/cse.c
+++ b/gcc/cse.c
@@ -3408,16 +3408,8 @@ fold_rtx (x, insn)
 
       if (folded_arg0 != SUBREG_REG (x))
        {
-         new = 0;
-
-         if (GET_MODE_CLASS (mode) == MODE_INT
-             && GET_MODE_SIZE (mode) == UNITS_PER_WORD
-             && GET_MODE (SUBREG_REG (x)) != VOIDmode)
-           new = operand_subword (folded_arg0,
-                                  (SUBREG_BYTE (x) / UNITS_PER_WORD), 0,
-                                  GET_MODE (SUBREG_REG (x)));
-         if (new == 0 && subreg_lowpart_p (x))
-           new = gen_lowpart_if_possible (mode, folded_arg0);
+         new = simplify_subreg (mode, folded_arg0,
+                                GET_MODE (SUBREG_REG (x)), SUBREG_BYTE (x));
          if (new)
            return new;
        }
index 6aa86136b6f1cc877ded2d3c0a6c5c3890ffd3de..7ba5440ef748e70167ca51edbe6722180b96df72 100644 (file)
--- a/gcc/rtl.h
+++ b/gcc/rtl.h
@@ -1331,6 +1331,10 @@ extern rtx simplify_subreg               PARAMS ((enum machine_mode,
                                                 rtx,
                                                 enum machine_mode,
                                                 unsigned int));
+extern rtx simplify_gen_subreg         PARAMS ((enum machine_mode,
+                                                rtx,
+                                                enum machine_mode,
+                                                unsigned int));
 extern rtx simplify_replace_rtx                PARAMS ((rtx, rtx, rtx));
 extern rtx simplify_rtx                        PARAMS ((rtx));
 
index fd1b6303768b3289621e6dd439ab189a3374448c..a64b33e1836413f6aed56f0fb1dbdea2a82c262d 100644 (file)
@@ -259,13 +259,18 @@ simplify_replace_rtx (x, old, new)
                              simplify_replace_rtx (XEXP (x, 2), old, new));
 
     case 'x':
-      /* The only case we try to handle is a lowpart SUBREG of a single-word
-        CONST_INT.  */
-      if (code == SUBREG && subreg_lowpart_p (x) && old == SUBREG_REG (x)
-         && GET_CODE (new) == CONST_INT
-         && GET_MODE_SIZE (GET_MODE (old)) <= UNITS_PER_WORD)
-       return GEN_INT (INTVAL (new) & GET_MODE_MASK (mode));
-
+      /* The only case we try to handle is a SUBREG.  */
+      if (code == SUBREG)
+       {
+         rtx exp;
+         exp = simplify_gen_subreg (GET_MODE (x),
+                                    simplify_replace_rtx (SUBREG_REG (x),
+                                                          old, new),
+                                    GET_MODE (SUBREG_REG (x)),
+                                    SUBREG_BYTE (x));
+         if (exp)
+          x = exp;
+       }
       return x;
 
     default:
@@ -2385,6 +2390,37 @@ simplify_subreg (outermode, op, innermode, byte)
     }
   return NULL_RTX;
 }
+/* Make a SUBREG operation or equivalent if it folds.  */
+
+rtx
+simplify_gen_subreg (outermode, op, innermode, byte)
+     rtx op;
+     unsigned int byte;
+     enum machine_mode outermode, innermode;
+{
+  rtx new;
+  /* Little bit of sanity checking.  */
+  if (innermode == VOIDmode || outermode == VOIDmode
+      || innermode == BLKmode || outermode == BLKmode)
+    abort ();
+
+  if (GET_MODE (op) != innermode
+      && GET_MODE (op) != VOIDmode)
+    abort ();
+
+  if (byte % GET_MODE_SIZE (outermode)
+      || byte >= GET_MODE_SIZE (innermode))
+    abort ();
+
+  new = simplify_subreg (outermode, op, innermode, byte);
+  if (new)
+    return new;
+
+  if (GET_CODE (op) == SUBREG || GET_MODE (op) == VOIDmode)
+    return NULL_RTX;
+
+  return gen_rtx_SUBREG (outermode, op, byte);
+}
 /* Simplify X, an rtx expression.
 
    Return the simplified expression or NULL if no simplifications
@@ -2454,6 +2490,13 @@ simplify_rtx (x)
                                             ? GET_MODE (XEXP (x, 0))
                                             : GET_MODE (XEXP (x, 1))),
                                            XEXP (x, 0), XEXP (x, 1));
+    case 'x':
+      /* The only case we try to handle is a SUBREG.  */
+      if (code == SUBREG)
+        return simplify_gen_subreg (mode, SUBREG_REG (x),
+                                   GET_MODE (SUBREG_REG (x)),
+                                   SUBREG_BYTE (x));
+      return NULL;
     default:
       return NULL;
     }
This page took 0.090244 seconds and 5 git commands to generate.