Take the following example: int f(int i, int j) { if (i <= j - 1) if (i >= 0) { return i >= j; } return 0; }
Note this might show up somewhere but I don't know if it actually does (I made this up while looking into some missed optimizations due the patch which fixes PR 23666). The problem if I am looking at this correctly is that: Visiting statement: D.1631_3 = j_2 - 1; Found new range for D.1631_3: VARYING we say the range for D.1631_3 is varying but shouldn't we say the range is [j_2 - 1, j_2 - 1] ? That should fix the issue as we then we get the upper bound correctly as shown by: int f(int i, int j) { if (i < j) if (i >= 0) { return i >= j; } return 0; } Note as I said before, I don't know how many times this shows but I don't doubt that people would write i <= j -1 instead of i < j all the time to show what it really does for integers and loops. -- Summary: missed VRP opportunity 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=25145