This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
[Bug ada/68590] [6 Regression] FAIL: gnat.dg/loop_optimization19.adb scan-tree-dump-not optimized "Index_Check"
- From: "ebotcazou at gcc dot gnu.org" <gcc-bugzilla at gcc dot gnu dot org>
- To: gcc-bugs at gcc dot gnu dot org
- Date: Tue, 01 Dec 2015 07:19:03 +0000
- Subject: [Bug ada/68590] [6 Regression] FAIL: gnat.dg/loop_optimization19.adb scan-tree-dump-not optimized "Index_Check"
- Auto-submitted: auto-generated
- References: <bug-68590-4 at http dot gcc dot gnu dot org/bugzilla/>
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.