https://gcc.gnu.org/bugzilla/show_bug.cgi?id=112727

--- Comment #4 from Jakub Jelinek <jakub at gcc dot gnu.org> ---
BTW, the reason why cp_save_expr wrapped it into a SAVE_EXPR at first was that
the
COND_EXPR at that point wasn't TREE_READONLY, just non-side-effects and all 3
of its arguments were TREE_READONLY.
Though, obviously if it wouldn't be wrapped in SAVE_EXPR at the beginning, it
would probably work fine, as unshare_expr then would unshare the trees deeper.
Dunno, perhaps instead of
+      r = cp_fold (TREE_OPERAND (x, 0));
+      if (tree_invariant_p (r))
+       x = r;
for SAVE_EXPR we should do nothing, the SAVE_EXPR argument will be folded
during cp_fold_r, and if we decided at some point to use a SAVE_EXPR, we better
gimplify it that way.

Other thoughts?

Reply via email to