Hi, While trying to optimize pixman, I noticed that gcc is unable to recognize that 'while (n >= 1)' can often be simplified to 'if (n >= 1)'. Consider the following example, where there are loops that operate on larger amounts of data and smaller loops that deal with small or unaligned data.
int sum(const int *l, int n) { int s = 0; while (n >= 2) { s += l[0] + l[1]; l += 2; n -= 2; } while (n >= 1) { s += l[0]; l += 1; n -= 1; } return s; } Clearly the while (n >= 1) loop can never execute more than once, as n must be < 2, and in the body of the loop, n is decremented. The resulting machine code includes the backward branch to the top of the while (n >= 1) loop, which can never be taken. I suppose this is a missed optimization. Is this known, or should I make a new bug report? Thanks, Matt Turner