This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: [patch, wrong-code, 4.2/4.3/4.4 regression] Patch for PR38615


On Tue, Jan 20, 2009 at 11:17 PM, Steve Ellcey <sje@cup.hp.com> wrote:
> On Tue, 2009-01-20 at 13:42 -0800, Andrew Pinski wrote:
>> On Tue, Jan 20, 2009 at 9:42 AM, Steve Ellcey <sje@cup.hp.com> wrote:
>> >
>> > PR middle-end/38615 is a wrong-code bug on the list of 4.4 regressions.
>> >
>> > Promoting a initalitialized const auto variable to static appears to be
>> > an invalid optimization so this patch removes it.  This change could
>> > have a performance impact but I made no attempt to measure it since the
>> > optimization is invalid and just shouldn't be done.
>>
>> I think removing this optimization is not a good idea.  How about just
>> disabling the optimization if TREE_ADDRESS is set on the decl?
>>
>> Thanks,
>> Andrew Pinski
>
> That does seem to fix the bug, I am retesting with this patch which
> fixes the specific test case in the PR:

This variant is ok if you add a comment before the !TREE_ADDRESSABLE
check.  As Paolo notes it may be useful to preserve this optimization,
so please file an enhacement PR with his testcase (I would say we
could simply introduce an optimization option that disregards the
TREE_ADDRESSABLE check).

Thanks,
Richard.

>
> Index: gimplify.c
> ===================================================================
> --- gimplify.c  (revision 143437)
> +++ gimplify.c  (working copy)
> @@ -3526,7 +3526,8 @@ gimplify_init_constructor (tree *expr_p,
>        if (valid_const_initializer
>            && num_nonzero_elements > 1
>            && TREE_READONLY (object)
> -           && TREE_CODE (object) == VAR_DECL)
> +           && TREE_CODE (object) == VAR_DECL
> +           && !TREE_ADDRESSABLE (object))
>          {
>            if (notify_temp_creation)
>              return GS_ERROR;
>
>


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]