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

--- Comment #10 from Eric Botcazou <ebotcazou at gcc dot gnu.org> ---
> So the original compliant was that if we do that we pessimize code-gen
> because we un-CSE a possibly large sub-expression.

Then maybe the "possibly large sub-expression" should be taken into account.
We already try by means of skip_simple_arithmetic, but it's too simple.

> So you say that any tree-shared expr is only expanded once (as if it were 
> wrapped in a save-expr)?

No, it will be reexpanded if it has no TREE_SIDE_EFFECTS.  What I'm saying is
that you control it by means of TREE_SIDE_EFFECTS.

> Oh, so fold is performing CSE here?  Shouldn't _that_ folding not set
> TREE_SIDE_EFFECTS on the SAVE_EXPR?  Instead of forcing it on every user...

It's not just fold, it's the way SAVE_EXPR works in GENERIC.  You need to be
able to control when the variable is initialized at run time, otherwise it's a
recipe for disaster.

Reply via email to