Attacking quadratic behaviors associated with SWITCH_EXPR

Zdenek Dvorak
Sun Oct 24 19:17:00 GMT 2004


> First, I am thinking about improving "CASE_LABEL_EXPR -> edge" as
> follows.
> 1. add "edge e;" to stmt_ann_d
> 2. allocate stmt_ann for each CASE_LABEL_EXPR
> 3. stop using CASE_LABEL of CASE_LABEL_EXPR after CFG is created.  In
>    fact, we should probably put null in CASE_LABEL so that people
>    won't mistakenly use it.
> Then we should be able to do
>   stmt_ann (switch_stmt)->e
> to get an edge equivalent to find_edge (label_to_block (CASE_LABEL ()))
> in constant time.  Now the obvious concern is memory consumption
> arising from having edge for every statement with stmt_ann.  I need
> come clever ideas here.  Maybe a hash table mapping CASE_LABEL_EXPR to
> edge?

statement annotations are huge, so this would indeed be a bad idea.
I think it would be better to avoid using tree for CASE_LABEL_EXPR
inside switch statement completely.  I.e. TREE_OPERAND (switch, 2)
would no longer be a TREE_VEC of CASE_LABEL_EXPRs, but instead
a wrapper tree node (of type tcc_exceptional) containing
a VEC(case_label_type), where case_label_type would contain just the
fields necessary for the case label.  This should also save some
memory over the current approach, since it is a bit less bloated


More information about the Gcc mailing list