https://gcc.gnu.org/bugzilla/show_bug.cgi?id=106989
Richard Biener <rguenth at gcc dot gnu.org> changed: What |Removed |Added ---------------------------------------------------------------------------- Status|UNCONFIRMED |NEW Ever confirmed|0 |1 Last reconfirmed| |2022-09-21 CC| |rguenth at gcc dot gnu.org --- Comment #5 from Richard Biener <rguenth at gcc dot gnu.org> --- (In reply to JuzheZhong from comment #4) > (In reply to Andrew Pinski from comment #3) > > The DSE happens but only at the RTL level .... > > Is it a good idea to do data-ref in DSE and remove the first redundant store? Probably - of course that makes things more expensive. The case at hand can probably be handled by what LIMs mem_refs_may_alias_p does, using get_inner_reference_aff (mem1->mem.ref, &off1, &size1); get_inner_reference_aff (mem2->mem.ref, &off2, &size2); aff_combination_expand (&off1, ttae_cache); aff_combination_expand (&off2, ttae_cache); aff_combination_scale (&off1, -1); aff_combination_add (&off2, &off1); if (aff_comb_cannot_overlap_p (&off2, size1, size2)) return false; but I'm not sure we should add more code doing things like that ... If we think that firing up dataref analysis at the point we discover the possible use is too expensive we could also optimistically queue them and only when we find a killing def (and thus the store would be dead), process the queued uses, checking them if they are really important. But well, maybe just try the simplest approach and measure the compile-time effect. That is, in /* If the statement is a use the store is not dead. */ else if (ref_maybe_used_by_stmt_p (use_stmt, ref)) { /* Handle common cases where we can easily build an ao_ref structure for USE_STMT and in doing so we find that the references hit non-live bytes and thus can be ignored. for a gimple assignment, check dr_may_alias_p after analyzing both stmts (we can of course at least cache the DR for 'stmt'). Guarded with flag_expensive_optimizations (thus -O2+). You also need to then initialize loops and SCEV.