https://gcc.gnu.org/bugzilla/show_bug.cgi?id=94693
--- Comment #5 from Andrew Pinski <pinskia at gcc dot gnu.org> --- I think since GCC 12, this is fixed. Via ipa mod-ref. I tested all testcases here and GCC 12+ could optimize this via `-O3 -fno-inline` and turning off DSE (`-fno-tree-dse`), kept the around the function call. I am not sure what else needs to be done here though.