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

--- Comment #9 from Eric Botcazou <ebotcazou at gcc dot gnu.org> ---
> 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.

Yes, we do something like that in the Ada front-end, i.e. we call save_expr for
complex expressions without side-effects, see e.g. utils2.c:gnat_protect_expr.
But once the SAVE_EXPR is built, you *cannot* remove TREE_SIDE_EFFECTS on it,
or else you'll run into nasty order of evaluation issues.

Reply via email to