summaryrefslogtreecommitdiff
path: root/gcc/cselib.c
diff options
context:
space:
mode:
authorbstarynk <bstarynk@138bc75d-0d04-0410-961f-82ee72b054a4>2010-03-07 21:01:46 +0000
committerbstarynk <bstarynk@138bc75d-0d04-0410-961f-82ee72b054a4>2010-03-07 21:01:46 +0000
commita075603c78f6520dcd415bf785bc952da5e25cb0 (patch)
treeed6cecc568776bc8f00902152f345d61a361cfa0 /gcc/cselib.c
parent825a7fb9aa8ce23af99bd42fed146b99c65f9d61 (diff)
downloadgcc-a075603c78f6520dcd415bf785bc952da5e25cb0.tar.gz
2010-03-07 Basile Starynkevitch <basile@starynkevitch.net>
MELT branch merged with trunk rev 157264 git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/branches/melt-branch@157266 138bc75d-0d04-0410-961f-82ee72b054a4
Diffstat (limited to 'gcc/cselib.c')
-rw-r--r--gcc/cselib.c40
1 files changed, 35 insertions, 5 deletions
diff --git a/gcc/cselib.c b/gcc/cselib.c
index deac835f933..515fc328463 100644
--- a/gcc/cselib.c
+++ b/gcc/cselib.c
@@ -69,6 +69,7 @@ struct expand_value_data
bitmap regs_active;
cselib_expand_callback callback;
void *callback_arg;
+ bool dummy;
};
static rtx cselib_expand_value_rtx_1 (rtx, struct expand_value_data *, int);
@@ -1069,6 +1070,7 @@ cselib_expand_value_rtx (rtx orig, bitmap regs_active, int max_depth)
evd.regs_active = regs_active;
evd.callback = NULL;
evd.callback_arg = NULL;
+ evd.dummy = false;
return cselib_expand_value_rtx_1 (orig, &evd, max_depth);
}
@@ -1088,10 +1090,29 @@ cselib_expand_value_rtx_cb (rtx orig, bitmap regs_active, int max_depth,
evd.regs_active = regs_active;
evd.callback = cb;
evd.callback_arg = data;
+ evd.dummy = false;
return cselib_expand_value_rtx_1 (orig, &evd, max_depth);
}
+/* Similar to cselib_expand_value_rtx_cb, but no rtxs are actually copied
+ or simplified. Useful to find out whether cselib_expand_value_rtx_cb
+ would return NULL or non-NULL, without allocating new rtx. */
+
+bool
+cselib_dummy_expand_value_rtx_cb (rtx orig, bitmap regs_active, int max_depth,
+ cselib_expand_callback cb, void *data)
+{
+ struct expand_value_data evd;
+
+ evd.regs_active = regs_active;
+ evd.callback = cb;
+ evd.callback_arg = data;
+ evd.dummy = true;
+
+ return cselib_expand_value_rtx_1 (orig, &evd, max_depth) != NULL;
+}
+
/* Internal implementation of cselib_expand_value_rtx and
cselib_expand_value_rtx_cb. */
@@ -1249,7 +1270,10 @@ cselib_expand_value_rtx_1 (rtx orig, struct expand_value_data *evd,
that all fields need copying, and then clear the fields that should
not be copied. That is the sensible default behavior, and forces
us to explicitly document why we are *not* copying a flag. */
- copy = shallow_copy_rtx (orig);
+ if (evd->dummy)
+ copy = NULL;
+ else
+ copy = shallow_copy_rtx (orig);
format_ptr = GET_RTX_FORMAT (code);
@@ -1263,7 +1287,8 @@ cselib_expand_value_rtx_1 (rtx orig, struct expand_value_data *evd,
max_depth - 1);
if (!result)
return NULL;
- XEXP (copy, i) = result;
+ if (copy)
+ XEXP (copy, i) = result;
}
break;
@@ -1271,14 +1296,16 @@ cselib_expand_value_rtx_1 (rtx orig, struct expand_value_data *evd,
case 'V':
if (XVEC (orig, i) != NULL)
{
- XVEC (copy, i) = rtvec_alloc (XVECLEN (orig, i));
- for (j = 0; j < XVECLEN (copy, i); j++)
+ if (copy)
+ XVEC (copy, i) = rtvec_alloc (XVECLEN (orig, i));
+ for (j = 0; j < XVECLEN (orig, i); j++)
{
rtx result = cselib_expand_value_rtx_1 (XVECEXP (orig, i, j),
evd, max_depth - 1);
if (!result)
return NULL;
- XVECEXP (copy, i, j) = result;
+ if (copy)
+ XVECEXP (copy, i, j) = result;
}
}
break;
@@ -1299,6 +1326,9 @@ cselib_expand_value_rtx_1 (rtx orig, struct expand_value_data *evd,
gcc_unreachable ();
}
+ if (evd->dummy)
+ return orig;
+
mode = GET_MODE (copy);
/* If an operand has been simplified into CONST_INT, which doesn't
have a mode and the mode isn't derivable from whole rtx's mode,