This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
[Bug debug/51746] Segfault in cselib_preserved_value_p
- From: "aoliva at gcc dot gnu.org" <gcc-bugzilla at gcc dot gnu dot org>
- To: gcc-bugs at gcc dot gnu dot org
- Date: Thu, 05 Jan 2012 00:58:13 +0000
- Subject: [Bug debug/51746] Segfault in cselib_preserved_value_p
- Auto-submitted: auto-generated
- References: <bug-51746-4@http.gcc.gnu.org/bugzilla/>
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=51746
--- Comment #6 from Alexandre Oliva <aoliva at gcc dot gnu.org> 2012-01-05 00:58:13 UTC ---
I've now realized the reason we fail to find the (plus:si (reg:si r1)
(const_int -1)) is that reverse_op miscomputes the hash of value 22, because
we're looking up an expr containing a VALUE, and cselib_hash_rtx doesn't handle
that properly. Getting it to support VALUEs as part of expressions, lookup
succeeds and we reuse the value, as expected. Here's the patch I'm testing:
diff --git a/gcc/cselib.c b/gcc/cselib.c
index eeb88e6..ab9c458 100644
--- a/gcc/cselib.c
+++ b/gcc/cselib.c
@@ -1035,6 +1035,10 @@ cselib_hash_rtx (rtx x, int create, enum machine_mode
mem
switch (code)
{
+ case VALUE:
+ e = CSELIB_VAL_PTR (x);
+ return e->hash;
+
case MEM:
case REG:
e = cselib_lookup (x, GET_MODE (x), create, memmode);