int f(int x, int y) { int t; for (t = 0; t < 50; t++) g(t>0); } void f1(int x, int y) { int t; for (t = 0; t < 50; t++) g(t!=0); }
-------------- The above two functions should produce the same code with f1 being better than f. If we change it to: void f2(int x, int y) { int t; for (t = 0; t < 50; t++) { int tt; if (t>0) tt = 1; else tt = 0; g(tt); } } ----- We get f1 so we are only folding comparisions in a COND_EXPR which is wrong, we should also be doing them in MODIFY_EXPRs too. -- Summary: missed optimization with non COND_EXPR and vrp and comparisions Product: gcc Version: 4.2.0 Status: UNCONFIRMED Keywords: missed-optimization Severity: enhancement Priority: P3 Component: tree-optimization AssignedTo: unassigned at gcc dot gnu dot org ReportedBy: pinskia at gcc dot gnu dot org http://gcc.gnu.org/bugzilla/show_bug.cgi?id=28794