On Tue, 23 May 2023, Richard Biener wrote:
> > Ah, no, I deliberately decided against that, because that way we would go
> > via gimplify_arg, which would emit all side effects in *pre_p. That seems
> > wrong if arguments had side-effects that should go in *post_p.
> 
> Ah, true - that warrants a comment though.

Incrementally fixed up in my tree like this:

diff --git a/gcc/c-family/c-gimplify.cc b/gcc/c-family/c-gimplify.cc
index f7635d3b0c..17b0610a89 100644
--- a/gcc/c-family/c-gimplify.cc
+++ b/gcc/c-family/c-gimplify.cc
@@ -803,6 +803,7 @@ c_gimplify_expr (tree *expr_p, gimple_seq *pre_p 
ATTRIBUTE_UNUSED,
                else
                  ops[2] = build1 (NEGATE_EXPR, type, ops[2]);
              }
+           /* Avoid gimplify_arg: it emits all side effects into *PRE_P.  */
            for (auto &&op : ops)
              if (gimplify_expr (&op, pre_p, post_p, is_gimple_val, fb_rvalue)
                  == GS_ERROR)

Alexander

Reply via email to