https://gcc.gnu.org/bugzilla/show_bug.cgi?id=126169

--- Comment #3 from GCC Commits <cvs-commit at gcc dot gnu.org> ---
The trunk branch has been updated by Richard Sandiford <[email protected]>:

https://gcc.gnu.org/g:00f6d24737cd35594dcd621aae412d0d41258370

commit r17-2287-g00f6d24737cd35594dcd621aae412d0d41258370
Author: Richard Sandiford <[email protected]>
Date:   Thu Jul 9 22:44:54 2026 +0100

    cselib: Restore 32-bit hash [PR126169]

    r17-629-g582adc3c97b1e0 shrank cselib_val::hash to 30 bits in order
    to free up two bits for new flags.  However, I hadn't realised that
    cselib_hash_rtx uses zero as an error return and so requires the hash
    to be nonzero.  In the PR, trimming the hash to 30 bits had the effect
    of dropping the only nonzero bits, leading cselib_lookup_1 to fail even
    when the "create" parameter was true.

    Rather than fight against the system, it seemed better to restore the
    hash to 32 bits and get the space another way: by moving the uid field
    from cselib_val to the u2 field of the VALUE rtx.  This slightly
    complicates some uses and slightly simplifies others.

    There is currently a 1:1 mapping between VALUEs and cselib_vals.
    The only time val_rtx is set is in new_cselib_val:

      e->val_rtx = (rtx_def*) value_pool.allocate ();

    and the only times CSELIB_VAL_PTR is set are in new_cselib_val:

      CSELIB_VAL_PTR (e->val_rtx) = e;

    and discard_useless_values:

          CSELIB_VAL_PTR (v->val_rtx) = NULL;

    If in future we allowed multiple VALUEs to point to the same cselib_val
    (e.g. for canonical_cselib_val), we would need to copy CSELIB_VAL_UID at
    the same time as copying CSELIB_VAL_PTR.

    gcc/
            PR debug/126169
            * rtl.h (rtx_def::u2): Add value_uid to the union.
            (CSELIB_VAL_UID): New macro.
            * cselib.h (cselib_val::HASH_MASK): Delete.
            (cselib_val::hash): Restore to a full int.
            (cselib_val::uid): Delete.
            (canonical_cselib_val): Use CSELIB_VAL_UID instead of
cselib_val::uid.
            * alias.cc (refs_newer_value_p): Likewise.
            * dse.cc (canon_address): Likewise.
            * print-rtl.cc (rtx_writer::print_rtx_operand_code_0): Likewise.
            * var-tracking.cc (dv_uid, canon_value_cmp): Likewise.
            (variable_post_merge_new_vals): Likewise.
            * cselib.cc (new_elt_loc_list, new_cselib_val): Likewise.
            (cselib_lookup): Likewise.
            (cselib_find_slot): Remove use of cselib_val::HASH_MASK.

Reply via email to