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

Richard Biener <rguenth at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
           Priority|P3                          |P2
                 CC|                            |rguenth at gcc dot gnu.org
   Target Milestone|---                         |6.5

--- Comment #3 from Richard Biener <rguenth at gcc dot gnu.org> ---
Oops.  But really side-effects should have been handled via

          /* Search for captures not used in the result expression and
dependent
             on TREE_SIDE_EFFECTS emit omit_one_operand.  */
          for (int i = 0; i < s->capture_max + 1; ++i)
            {
              if (cinfo.info[i].same_as != (unsigned)i)
                continue;
              if (!cinfo.info[i].force_no_side_effects_p
                  && !cinfo.info[i].expr_p
                  && cinfo.info[i].result_use_count == 0)
                {
                  fprintf_indent (f, indent,
                                  "if (TREE_SIDE_EFFECTS (captures[%d]))\n",
                                  i);
                  fprintf_indent (f, indent + 2,
                                  "res = build2_loc (loc, COMPOUND_EXPR, type,
"
                                  "fold_ignored_result (captures[%d]),
res);\n",
                                  i);
                }
            }

but I guess that doesn't work because the counting is missing.  OTOH
two same SAVE_EXPRs () are not operand_equal_p but SAVE_EXPRs have
TREE_SIDE_EFFECTS set but we can safely handle SAVE_EXPR + SAVE_EXPR.

So I think a fix needs more thinking.  Obviously simply never treating
things with side-effects the same is a conservative fix.

Reply via email to