But that performs very poorly on all architectures.
A smart compiler will be able to narrow it down in a limited set of scenarios, but all we need to do is put an accumulator into a loop to see that bounding an integer is equivalent to the halting problem. Or for another example, should we expect our "smart" compiler to bound y in the following? The bound on x is a freebie.
bigint n(uint64_t x) {
bigint i = 0;
bigint y = x;
while (y != 1) {
i++;
if (y%2) y = y//2;
else y = 3*y-1;
}
return i;
}