https://gcc.gnu.org/bugzilla/show_bug.cgi?id=49330
--- Comment #24 from Richard Biener <rguenth at gcc dot gnu.org> --- On GCC testcases one large group of MEMs only disambiguated through base_alias_check is disambiguations agains DSEs group_info->base_mem which is BLKmode mems based on some "base" pointer. This base_mem lacks a MEM_EXPR but I think it shouldn't be difficult to add one, like with (completely lacking sanity testing): diff --git a/gcc/dse.c b/gcc/dse.c index 389c52d4284..098c77165de 100644 --- a/gcc/dse.c +++ b/gcc/dse.c @@ -1097,6 +1097,7 @@ canon_address (rtx mem, { machine_mode address_mode = get_address_mode (mem); rtx mem_address = XEXP (mem, 0); + tree mem_expr = MEM_EXPR (mem); rtx expanded_address, address; int expanded; @@ -1165,6 +1166,9 @@ canon_address (rtx mem, && const_or_frame_p (address)) { group_info *group = get_group_info (address); + if (!MEM_EXPR (group->base_mem) + && mem_expr) + set_mem_expr (group->base_mem, get_base_address (mem_expr)); if (dump_file && (dump_flags & TDF_DETAILS)) { btw, the disambiguations like (mem/c:SI (symbol_ref:DI ("g") [flags 0x2] <var_decl 0x7fe01f78a510 g>) [1 g+0 S4 A32]) vs. (mem:DI (pre_dec:DI (reg/f:DI 7 sp)) [0 S8 A8]) are handled through REG_BASE_VALUE which assigns 'sp' (address:DI -1). I believe we should be working towards adding proper MEM_EXPRs to more places and simply make find_base_term more conservative which means simplifying the PLUS/MINUS cases.