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

Martin Liška <marxin at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
         Resolution|---                         |INVALID
             Status|ASSIGNED                    |RESOLVED

--- Comment #3 from Martin Liška <marxin at gcc dot gnu.org> ---
(In reply to Martin Sebor from comment #0)
> The #pragma GCC push_options in the program below should prevent the folding
> of the strlen() call in g() but doesn't.  This has changed in GCC 11 (GCC 10
> behaves as expected).  The dump shows that the optimize attribute has both
> optimization options, -O1 as well as -O2.  That also seems unexpected but it
> has not changed between 10 and 11.

There's a change that caused that:

r11-6922-gefc9ccbfd0ca4da6(27 Jan 2021 10:08)(ja...@redhat.com): [took: 0.596s]
result: FAILED (1)
varpool: Restore GENERIC TREE_READONLY automatic var optimization [PR7260]

In 4.8 and earlier we used to fold the following to 0 during GENERIC folding,
but we don't do that anymore because ctor_for_folding etc. has been turned into
a
GIMPLE centric API, but as the testcase shows, it is invoked even during
GENERIC folding and there the automatic vars still should have meaningful
initializers.  I've verified that the C++ FE drops TREE_READONLY on
automatic vars with const qualified types if they require non-constant
(runtime) initialization.

2021-01-27  Jakub Jelinek  <ja...@redhat.com>

        PR tree-optimization/97260
        * varpool.c: Include tree-pass.h.
        (ctor_for_folding): In GENERIC return DECL_INITIAL for TREE_READONLY
        non-TREE_SIDE_EFFECTS automatic variables.

        * gcc.dg/tree-ssa/pr97260.c: New test.

So the code snippet is optimized out even with -O1. So you should use:
#pragma GCC optimize ("0")

Reply via email to