aboutsummaryrefslogtreecommitdiff
path: root/gcc
diff options
context:
space:
mode:
authorRichard Sandiford <rdsandiford@googlemail.com>2009-10-22 22:30:12 +0000
committerRichard Sandiford <rsandifo@gcc.gnu.org>2009-10-22 22:30:12 +0000
commitbd7960b1e4ce9d64b2631d0b644eb8bf83845005 (patch)
tree4f4554809ba030c1b41d267109a8f8706fa58231 /gcc
parent2a31793e324e29c237dc9e46064280aa626374ad (diff)
downloadgcc-bd7960b1e4ce9d64b2631d0b644eb8bf83845005.zip
gcc-bd7960b1e4ce9d64b2631d0b644eb8bf83845005.tar.gz
gcc-bd7960b1e4ce9d64b2631d0b644eb8bf83845005.tar.bz2
rtl.h (shallow_copy_rtvec): Declare.
gcc/ * rtl.h (shallow_copy_rtvec): Declare. * rtl.c (shallow_copy_rtvec): New function. * cselib.c (cselib_subst_to_values): Use it. Only modify an rtx field if the subrtx has changed. From-SVN: r153475
Diffstat (limited to 'gcc')
-rw-r--r--gcc/ChangeLog7
-rw-r--r--gcc/cselib.c29
-rw-r--r--gcc/rtl.c14
-rw-r--r--gcc/rtl.h1
4 files changed, 37 insertions, 14 deletions
diff --git a/gcc/ChangeLog b/gcc/ChangeLog
index 002a22a..18460ea 100644
--- a/gcc/ChangeLog
+++ b/gcc/ChangeLog
@@ -1,3 +1,10 @@
+2009-10-22 Richard Sandiford <rdsandiford@googlemail.com>
+
+ * rtl.h (shallow_copy_rtvec): Declare.
+ * rtl.c (shallow_copy_rtvec): New function.
+ * cselib.c (cselib_subst_to_values): Use it. Only modify an
+ rtx field if the subrtx has changed.
+
2009-10-22 Anatoly Sokolov <aesok@post.ru>
* config/m32c/m32c.c (m32c_function_value_regno_p): New function.
diff --git a/gcc/cselib.c b/gcc/cselib.c
index aa5f7b0..7065429 100644
--- a/gcc/cselib.c
+++ b/gcc/cselib.c
@@ -1422,30 +1422,31 @@ cselib_subst_to_values (rtx x)
{
rtx t = cselib_subst_to_values (XEXP (x, i));
- if (t != XEXP (x, i) && x == copy)
- copy = shallow_copy_rtx (x);
-
- XEXP (copy, i) = t;
+ if (t != XEXP (x, i))
+ {
+ if (x == copy)
+ copy = shallow_copy_rtx (x);
+ XEXP (copy, i) = t;
+ }
}
else if (fmt[i] == 'E')
{
- int j, k;
+ int j;
for (j = 0; j < XVECLEN (x, i); j++)
{
rtx t = cselib_subst_to_values (XVECEXP (x, i, j));
- if (t != XVECEXP (x, i, j) && XVEC (x, i) == XVEC (copy, i))
+ if (t != XVECEXP (x, i, j))
{
- if (x == copy)
- copy = shallow_copy_rtx (x);
-
- XVEC (copy, i) = rtvec_alloc (XVECLEN (x, i));
- for (k = 0; k < j; k++)
- XVECEXP (copy, i, k) = XVECEXP (x, i, k);
+ if (XVEC (x, i) == XVEC (copy, i))
+ {
+ if (x == copy)
+ copy = shallow_copy_rtx (x);
+ XVEC (copy, i) = shallow_copy_rtvec (XVEC (x, i));
+ }
+ XVECEXP (copy, i, j) = t;
}
-
- XVECEXP (copy, i, j) = t;
}
}
}
diff --git a/gcc/rtl.c b/gcc/rtl.c
index 53a4992..aefbbf3 100644
--- a/gcc/rtl.c
+++ b/gcc/rtl.c
@@ -164,6 +164,20 @@ rtvec_alloc (int n)
return rt;
}
+/* Create a bitwise copy of VEC. */
+
+rtvec
+shallow_copy_rtvec (rtvec vec)
+{
+ rtvec newvec;
+ int n;
+
+ n = GET_NUM_ELEM (vec);
+ newvec = rtvec_alloc (n);
+ memcpy (&newvec->elem[0], &vec->elem[0], sizeof (rtx) * n);
+ return newvec;
+}
+
/* Return the number of bytes occupied by rtx value X. */
unsigned int
diff --git a/gcc/rtl.h b/gcc/rtl.h
index ee464b7..0f7044e 100644
--- a/gcc/rtl.h
+++ b/gcc/rtl.h
@@ -1568,6 +1568,7 @@ extern rtx rtx_alloc_stat (RTX_CODE MEM_STAT_DECL);
#define rtx_alloc(c) rtx_alloc_stat (c MEM_STAT_INFO)
extern rtvec rtvec_alloc (int);
+extern rtvec shallow_copy_rtvec (rtvec);
extern bool shared_const_p (const_rtx);
extern rtx copy_rtx (rtx);
extern void dump_rtx_statistics (void);