https://gcc.gnu.org/bugzilla/show_bug.cgi?id=80297
Richard Biener <rguenth at gcc dot gnu.org> changed: What |Removed |Added ---------------------------------------------------------------------------- CC| |rguenth at gcc dot gnu.org --- Comment #4 from Richard Biener <rguenth at gcc dot gnu.org> --- genmatch (correctly) allows tree sharing in GENERIC, just uses unshare_expr on GENERIC parts that we still have in GIMPLE. folding from inside the gimplifier is tricky for this reason (as it expects unshared GENERIC). I'd say the gimplifier needs to avoid GENERIC folding and/or call unshare_expr on its results... Given we now have "SSA" during gimplification the gimplifier could use fold_stmt (gsi, follow_single_use_edges). But I see this case is even from the gimplify langhook doing the folding ... :/ As said, genmatch not avoiding tree sharing in GENERIC is a feature and mimics what fold-const.c does so the issue isn't new but latent anyway.