Consider a = (x / 39) * 32 + (x % 39) If we have no instruction to produce both the quotient and the remaineder, this can be computed as y = x / 39 z = x - y * 39 a = y * 32 + z
The last line can be simplified by substituting: a = y * 32 + x - y * 39 a = y * (32 - 39) + x a = x - y * 7 Testcase: int i_size; extern void foo (void); int udf_check_anchor_block(int block) { i_size = ( ( ( (block) / 39 ) << 5 ) + ( block % 39 )); return 1; } The tree optimization phase misses this, and this PR should stay open until that is resolved. The combiner can handle it if it is able to look at 4 instructions. -- Summary: Mathematical simplification missed at tree-level Product: gcc Version: 4.6.0 Status: UNCONFIRMED Severity: enhancement Priority: P3 Component: tree-optimization AssignedTo: unassigned at gcc dot gnu dot org ReportedBy: bernds at gcc dot gnu dot org GCC build triplet: i686-pc-linux-gnu GCC host triplet: i686-pc-linux-gnu GCC target triplet: i686-pc-linux-gnu http://gcc.gnu.org/bugzilla/show_bug.cgi?id=45218