For the following Code Snippet void bar () { b1 = foo(1); b2 = foo(1); b3 = foo(1); b4 = foo(1); b5 = foo(1); b6 = foo(1); b7 = foo(1); b8 = foo(1); b9 = foo(1); b10 = foo(1); b11 = foo(1); b12 = foo(1);
array[0] = b1 && b2 && b3 && b4 && b5 && b6 && b7 && b8 && b9 && b10 && b11 && b12; array[1] = b1 && b2 && b3 && b4 && b5 && b6 && b7 && b8 && b9 && b10 && b11 && b12; array[2] = b1 && b2 && b3 && b4 && b5 && b6 && b7 && b8 && b9 && b10 && b11 && b12; array[3] = b1 && b2 && b3 && b4 && b5 && b6 && b7 && b8 && b9 && b10 && b11 && b12; array[4] = b1 && b2 && b3 && b4 && b5 && b6 && b7 && b8 && b9 && b10 && b11 && b12; array[5] = b1 && b2 && b3 && b4 && b5 && b6 && b7 && b8 && b9 && b10 && b11 && b12; array[6] = b1 && b2 && b3 && b4 && b5 && b6 && b7 && b8 && b9 && b10 && b11 && b12; array[7] = b1 && b2 && b3 && b4 && b5 && b6 && b7 && b8 && b9 && b10 && b11 && b12; array[8] = b1 && b2 && b3 && b4 && b5 && b6 && b7 && b8 && b9 && b10 && b11 && b12; array[9] = b1 && b2 && b3 && b4 && b5 && b6 && b7 && b8 && b9 && b10 && b11 && b12; array[10] = b1 && b2 && b3 && b4 && b5 && b6 && b7 && b8 && b9 && b10 && b11 && b12; return; } Where b ( from b1 to b12) are all declared static short b1, static short b2 etc. and array is static short array[11]. This should generate code such as if (b1 == 0) goto L1 else goto L2 L2: if (b2 == 0) goto L1 else goto L3 L3: if (b3 == 0) goto L1 else goto L4 L4: if (b4 == 0) goto L1 else goto L5 L5: if (b5 == 0) goto L1 else goto L6 L6: if (b6 == 0) goto L1 else goto L7 L7: if (b7 == 0) goto L1 else goto L8 L8: if (b8 == 0) goto L1 else goto L9 L9: if (b9 == 0) goto L1 else goto L10 L10: if (b10 == 0) goto L1 else goto L11 L11: if (b11 == 0) goto L1 else goto L12 L12: if (b12 == 0) goto L1 else goto L13 L13: array[i]=1 (for i from 0 to 10) return L1: array[i]=0 (for i from 0 to 10) return This is exactly what 4.1 generates but 4.3 fails to combine the if sequences. Version Details: GNU C version 4.3.0 20070316 (experimental) (arm-none-eabi) compiled by GNU C version 3.4.6 (Ubuntu 3.4.6-1ubuntu2). GGC heuristics: --param ggc-min-expand=30 --param ggc-min-heapsize=4096 -- Summary: Bad Code generation ( Tree optimization ) Product: gcc Version: 4.3.0 Status: UNCONFIRMED Severity: normal Priority: P3 Component: tree-optimization AssignedTo: unassigned at gcc dot gnu dot org ReportedBy: pranav dot bhandarkar at gmail dot com GCC target triplet: arm-none-eabi http://gcc.gnu.org/bugzilla/show_bug.cgi?id=32306