Take the following code: int test(int v) { int x = 0; for (int u=0;u<2;u++) { if (u>v) // v is input-arg the compiler can't deside at compiletime { if (u%2==1) // can only happen for u==1 (so loops for 0 and 2 does not do x++; // anything. Hoped gcc would notice when unrolling. } } return x; }
We get: <bb 0>: if (v_8 < 0) goto <L1>; else goto <L15>; <L15>:; if (v_8 <= 0) goto <L1>; else goto <L3>; <L1>:; # x_1 = PHI <0(3), 1(1)>; <L3>:; return x_1; } Notice that the if in L15 is always true. The 4.0 branch gets this correct. -- Summary: [4.1 Regression] missed jump threading after unroller Product: gcc Version: 4.0.0 Status: UNCONFIRMED Keywords: missed-optimization Severity: minor Priority: P2 Component: tree-optimization AssignedTo: unassigned at gcc dot gnu dot org ReportedBy: pinskia at gcc dot gnu dot org CC: gcc-bugs at gcc dot gnu dot org http://gcc.gnu.org/bugzilla/show_bug.cgi?id=21829