This adds support for loops like
unsigned clz(unsigned x) { unsigned w = sizeof (x) * 8; while (x) { w--; x >>= 1; } return w; }
and
unsigned clz(unsigned x) { unsigned w = sizeof (x) * 8 - 1; while (x >>= 1) { w--; } return w; }
To support these we look for add x, -1 as well as add x, 1 that
we already matched. If the value was -1 we need to subtract from
the initial counter value instead of adding to it.
Fixes PR48404.
Preexisting problem, but this is kinda broken.
If we have a second add in the loop,
and it happens to be before the one we are looking for,
we'll fail to detect the idiom.
The detection should not involve linear scan over instructions.