On 11/12/20 7:02 PM, Xionghu Luo via Gcc wrote:
> Hi all,
>
> In PR51505(https://gcc.gnu.org/bugzilla/show_bug.cgi?id=51505), Paolo Bonzini 
> added the code to delete REG_EQUAL notes in df_remove_dead_eq_notes:
>
> gcc/df-problems.c:
> df_remove_dead_eq_notes (rtx_insn *insn, bitmap live)
> {
> ...
>       case REG_EQUAL:
>       case REG_EQUIV:
>         {
>           /* Remove the notes that refer to dead registers.  As we have at 
> most
>              one REG_EQUAL/EQUIV note, all of EQ_USES will refer to this note
>              so we need to purge the complete EQ_USES vector when removing
>              the note using df_notes_rescan.  */
>           df_ref use;
>           bool deleted = false;
>
>           FOR_EACH_INSN_EQ_USE (use, insn)
>             if (DF_REF_REGNO (use) >= FIRST_PSEUDO_REGISTER
>                 && DF_REF_LOC (use)
>                 && (DF_REF_FLAGS (use) & DF_REF_IN_NOTE)
>                 && !bitmap_bit_p (live, DF_REF_REGNO (use))
>                 && loc_mentioned_in_p (DF_REF_LOC (use), XEXP (link, 0)))
>               {
>                 deleted = true;
>                 break;
>               }
>           if (deleted)
>             {
>               rtx next;
>               if (REG_DEAD_DEBUGGING)
>                 df_print_note ("deleting: ", insn, link);
>               next = XEXP (link, 1);
>               free_EXPR_LIST_node (link);
>               *pprev = link = next;
>               df_notes_rescan (insn);
>             }
> ...
> }
>
>
> while I have a test case as below:
>
>
> typedef long myint_t;
> __attribute__ ((noinline)) myint_t
> hash_loop (myint_t nblocks, myint_t hash)
> {
>     int i;
>     for (i = 0; i < nblocks; i++)
>       hash = ((hash + 13) | hash) + 0x66546b64;
>     return hash;
> }
>
> before cse1:
>
>    22: L22:
>    16: NOTE_INSN_BASIC_BLOCK 4
>    17: r125:DI=r120:DI+0xd
>    18: r118:DI=r125:DI|r120:DI
>    19: r126:DI=r118:DI+0x66540000
>    20: r120:DI=r126:DI+0x6b64
>       REG_EQUAL r118:DI+0x66546b64
>    21: r119:DI=r119:DI-0x1
>    23: r127:CC=cmp(r119:DI,0)
>    24: pc={(r127:CC!=0)?L22:pc}
>       REG_BR_PROB 955630228
>
> The dump in cse1:
>
>    16: NOTE_INSN_BASIC_BLOCK 4
>    17: r125:DI=r120:DI+0xd
>    18: r118:DI=r125:DI|r120:DI
>       REG_DEAD r125:DI
>       REG_DEAD r120:DI
>    19: r126:DI=r118:DI+0x66540000
>       REG_DEAD r118:DI
>    20: r120:DI=r126:DI+0x6b64
>       REG_DEAD r126:DI
>    21: r119:DI=r119:DI-0x1
>    23: r127:CC=cmp(r119:DI,0)
>    24: pc={(r127:CC!=0)?L22:pc}
>       REG_DEAD r127:CC
>       REG_BR_PROB 955630228
>       ; pc falls through to BB 6
>
>
> The output shows "REQ_EQUAL r118:DI+0x66546b64" is deleted by 
> df_remove_dead_eq_notes,
> but r120:DI is not REG_DEAD here, so is it correct here to check insn use and 
> find that
> r118:DI is dead then do the delete?

It doesn't matter where the death occurs, any REG_DEAD note will cause
the REG_EQUAL note to be removed.  So given the death note for r118,
then any REG_EQUAL note that references r118 will be removed.  This is
overly pessimistic as the note may still be valid/useful at some
points.  See

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


Jeff


ps.  Note that a REG_EQUAL note is valid at a particular point in the IL
-- it is not a function-wide equivalence.  So you have to be careful
using such values as they can be invalidated by other statements. 
Contrast to a REG_EQUIV note where the equivalence is global and you
don't have to worry about invalidation.



Reply via email to