On 11/16/2016 02:00 PM, Jakub Jelinek wrote:
Hi!

Jason's recent patch to turn reference vars initialized with invariant
addresses broke the first testcase below, because &self->singleton
is considered TREE_CONSTANT (because self is TREE_CONSTANT VAR_DECL and
singleton field has constant offset), but after going into SSA form
it is not supposed to be TREE_CONSTANT anymore (&self_2->singleton),
because SSA_NAMEs don't have TREE_CONSTANT set on them.

The following patch fixes it by gimplifying such vars into their
DECL_INITIAL unless in OpenMP regions, where such folding is deferred
until omplower pass finishes.

Bootstrapped/regtested on x86_64-linux and i686-linux, ok for trunk?

2016-11-16  Jakub Jelinek  <ja...@redhat.com>

        PR c++/78373
        * gimplify.c (gimplify_decl_expr): For TREE_CONSTANT reference
        vars with is_gimple_min_invariant initializer after stripping
        useless conversions keep non-NULL DECL_INITIAL.
        (gimplify_var_or_parm_decl): Add fallback argument.  Gimplify
        TREE_CONSTANT reference vars with is_gimple_min_invariant initializer
        outside of OpenMP contexts to the initializer if fb_rvalue is
        allowed.
        (gimplify_compound_lval, gimplify_expr): Pass through fallback
        argument to gimplify_var_or_parm_decl.
        * omp-low.c (lower_omp_regimplify_p): Return non-zero for
        TREE_CONSTANT reference vars with is_gimple_min_invariant
        initializer.

        * g++.dg/opt/pr78373.C: New test.
        * g++.dg/gomp/pr78373.C: New test.
Is this still relevant?

jeff

Reply via email to