This is the mail archive of the gcc@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]

TREE_SIDE_EFFECTS vs STATEMENT_LIST vs recompute_side_effects


I was looking at the recent failures for gcc.dg/tree-ssa/20030709-2.c
and ran into this interesting little tidbit.

Given an COND_EXPR with arbitrarily complex true/false arms we start
the gimplification process by turning that into something like this:


        COND_EXPR
     /      |        \
COND    MODIFY_EXPR   MODIFY_EXPR
          /   \          /    \
       iftmp  whatever  iftmp  whatever

Which is all fine and good.

The two MODIFY_EXPR expressions are (of course) marked with 
TREE_SIDE_EFFECTS.

Our next step is to gimplify the MODIFY_EXPRs and put them into
distinct TREE_STATEMENT_LIST nodes resulting in something like 
this:

        COND_EXPR
     /      |        \
COND    STMT_LIST   STMT_LIST
            |           |
        MODIFY_EXPR   MODIFY_EXPR
          /   \          /    \
       iftmp  whatever  iftmp  whatever

The TREE_SIDE_EFFECTS bit is going to be set of the STATEMENT_LIST
nodes.  That seems relatively reasonable since the list of
statements has side effects.

Then we call recompute_side_effects on the toplevel COND_EXPR
node.  Since the attached STATEMENT_LIST nodes have TREE_SIDE_EFFECTS
set we set TREE_SIDE_EFFECTS on the COND_EXPR node itself.

That seems awfully wrong.  In gimple, COND_EXPRs shouldn't have any
side effects whatsoever.  Particularly since the STATEMENT_LISTS
hanging off the COND_EXPR are going to be broken off into distinct
statements during the lowering process.


It seems to me that for the purposes of recalculate_side_effects we
probably ought to be ignoring STATEMENT_LIST nodes.

Or alternately we could just blindly clear TREE_SIDE_EFFECTS on
COND_EXPR nodes.  However, I suspect there are other places where
the TREE_SIDE_EFFECTS bit from STATEMENT_LIST nodes is being
propagated up the tree structure into nodes where it should not
be set.

Thoughts?

jeff



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