http://gcc.gnu.org/bugzilla/show_bug.cgi?id=58950

--- Comment #8 from Marc Glisse <glisse at gcc dot gnu.org> ---
(In reply to Eric Botcazou from comment #5)
> > For __builtin_shuffle, the issue is that we now call save_expr, which always
> > sets TREE_SIDE_EFFECTS to 1. I don't know if it would make sense to
> > introduce a maybe_save_expr that is equivalent to save_expr but does not set
> > TREE_SIDE_EFFECTS if its argument doesn't have it.
> 
> No, this would defeat the purpose of the SAVE_EXPR, since you could
> duplicate the expression or move it at will, leading to nasty order of
> evaluation issues.

What I meant was, there are many places in the front-end that do:

if (TREE_SIDE_EFFECTS (op0)) op0 = save_expr (op0);

and I'd like to replace it with

op0 = maybe_save_expr (op0);

that would do the same thing to begin with. Now, if op0 is a long expression
without side-effects, the code I quoted will not call save_expr, it will
duplicate the expression and count on CSE for dedup, whereas we could imagine
having a single version to start with, that optimizations would still be
allowed to duplicate as usual if they consider it worth it.

Of course the uses of SAVE_EXPR that require the stronger protection would be
left alone.

I may still not be making sense, but at least I think I was a little more
precise about what I meant ;-)

Reply via email to