https://gcc.gnu.org/bugzilla/show_bug.cgi?id=113059
--- Comment #13 from rguenther at suse dot de <rguenther at suse dot de> --- On Wed, 10 Jan 2024, jakub at gcc dot gnu.org wrote: > https://gcc.gnu.org/bugzilla/show_bug.cgi?id=113059 > > --- Comment #12 from Jakub Jelinek <jakub at gcc dot gnu.org> --- > (In reply to Richard Biener from comment #11) > > IMHO REG_UNUSED notes should stay correct or be removed. Instead of a full > > solution can we just wipe them in postreload-cse as we know that pass will > > break them? Any user then should recompute the notes. Originally pass > > properties were thought of a vehicle indicating these kind of IL features, > > so we > > could add PROP_rtl_unused_notes and if not set treat them as possibly > > invalid when present (instead of actively wiping them), and when a pass > > requires them re-compute them. > > > > The problem with properties is that they are always set/unset irrespective > > of whether a pass did something destroying it. That could be > > circumvented by postreload-cse only clearing the flag when it does > > something. > > > > Not (re-)using pass properties for this but a flag in struct function > > works as well of course (or treat it as part of the DF state). > > I was hoping we could have some df checking which would discover invalid > REG_UNUSED notes and so we would know which passes need tweaking, but I'm > afraid my df knowledge is insufficient for that. > Dunno how often postreload-cse actually extends life time of some register, > which should determine whether we want to drop REG_UNUSED notes > unconditionally > at the end of postreload-cse, or whether we e.g. want just some flag whether > we've extended lifetime of something during it and only remove REG_UNUSED > notes > if that flag is set. In theory the insn analysis could look at REG_UNUSED notes and mark them as "to be extended" (eventually even pointing to the note). When eliminating to a such marked REG we could either remove the note or scrap all notes. That said - not sure how exactly postreload-cse keeps its state.