https://gcc.gnu.org/bugzilla/show_bug.cgi?id=70018
--- Comment #12 from Jan Hubicka <hubicka at gcc dot gnu.org> --- Created attachment 38195 --> https://gcc.gnu.org/bugzilla/attachment.cgi?id=38195&action=edit Patch I am testing This patch handles const->pure transition for all functions detected const that are not necessarily binding to current def. I think this is best we can do without tracking down constness from the FE (i.e. before the folding). The patch tries to be careful to optimize some cases (such as take into account that inlined functions will bind locally). I will try to collect some data on code quality effect.