On Fri, Sep 10, 2010 at 3:15 PM, Paulo J. Matos <pocma...@gmail.com> wrote:
> Hello,
>
> I am working on the new pass (previously discussed), to optimise switch
> cases.
>
> I am almost finishing it, however, for practical reasons I am
> implementing it first over GCC4.3 and once tested, will port it to svn
> trunk and post it on gcc-patches.
>
> There are something that are still not working. Mainly the issue is that
> GCC doesn't really accept the code I generate during the patch.
>
> Some issues:
>
> 1. To generate a conditional (like if(...){} else {}) I am using a
> COND_EXPR;
> 2. And when I have a complex condition I generate a TRUTH_ANDIF_EXPR and
> then corresponding LE_EXPR, or LT_EXPR, etc.
> 3. To iterate through the tree I am using a tree_stmt_iterator. And
> using tsi_delink to remove stmts from the tree and tsi_link_before/after
> to add stmts to the tree.

Which is wrong.  You need to use block_stmt_iterator and
bsi_remove and ... (I don't remember, 4.3 is so old).

> After my pass is run I get:
> ,----
> | switch_compact.c: In function 'g':
> | switch_compact.c:7: error: bb_for_stmt (stmt) is set to a wrong basic
> | block
> | switch_compact.c:7: error: invalid conditional operand
> | 8 <= n_1(D) && n_1(D) <= 17;
> |
> | switch_compact.c:7: internal compiler error: verify_stmts failed
> `----
>
> Could you please comment on the above issues so I can try to track down
> the problem?

You need to properly update the CFG

> PS. Note that the reason why I am not posting the patch is simply
> because I assume you only look at patches for gcc-trunk. However, if you
> don't mind taking a look at a pass for GCC4.3 at this point, do let me
> know and I will post it (either here on in gcc-patches).

You will have to transition to a completely different GIMPLE representation
when moving to trunk, so I think you are wasting time here.

Richard.

Reply via email to