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. 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? 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). Cheers, -- PMatos