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);