https://gcc.gnu.org/bugzilla/show_bug.cgi?id=97260
Jakub Jelinek <jakub at gcc dot gnu.org> changed: What |Removed |Added ---------------------------------------------------------------------------- CC| |jakub at gcc dot gnu.org --- Comment #5 from Jakub Jelinek <jakub at gcc dot gnu.org> --- So, can't we just restore back the folding in the FE to get rid of the regression, e.g. by (completely untested so far): --- gcc/varpool.c.jj 2021-01-04 10:25:37.347250651 +0100 +++ gcc/varpool.c 2021-01-25 16:35:58.475198684 +0100 @@ -412,6 +412,12 @@ ctor_for_folding (tree decl) if (!TREE_STATIC (decl) && !DECL_EXTERNAL (decl)) { gcc_assert (!TREE_PUBLIC (decl)); + /* Unless this is called during FE folding. */ + if (!in_gimple_form + && TREE_READONLY (decl) + && !TREE_SIDE_EFFECTS (decl) + && DECL_INITIAL (decl)) + return DECL_INITIAL (decl); return error_mark_node; } As for strlen pass, it has currently infrastructure only for tracking 0 vs. non-zero byte length, not exact constant bytes pointed by each pointer, that would make the pass significantly more expensive. Sure, we could have some hacks to handle some common cases where a variable is initialized just once by some string literal or other constant byte sequence and then never modified later, but that doesn't look like GCC 11 material.