https://gcc.gnu.org/bugzilla/show_bug.cgi?id=119183
--- Comment #7 from Richard Biener <rguenth at gcc dot gnu.org> --- It would ask for a flag on the tree nodes so we don't repeatedly recurse down the tree. TREE_NO_SIDE_EFFECTS? But yes, limiting the search depth is the simplest solution.