Maybe more to the point -- for a local variable, one that will likely be allocated as a register (or on the stack, at worst), you don't really gain anything at all by making 'test' small -- there might be reasons of correctness that are worthwhile, but optimization is basically a non-factor. Maybe if the loop appears in a deeply-recursive function, or on a small, embedded system with 4k of memory or something, but not usually. Just use the natural word-size of the machine, usually plain old 'int' -- it will be as fast as (faster, more likely) than the smaller value.
I totally agree with this. I do usually use int, but sometimes it happens that I want to ensure a certain size just because of the value I am testing against. This is not the case here though. Those cases would more likely be uint64_t, even if I would never make anything that iterates that many times...
Classic mistake. There is a generic way to make it work, if you really want to, though:
uint8_t j = 0; do { printf("%i\n", j); } while (++j);
Which is pretty readable, since the while loop is clearly going to terminate as soon as j overflows. And like Ravyne said, it doesn't really make anything faster in general, that said I personally don't see this as an optimization tactic, but more as a type correctness thing, in other words, the loop variable is going to be used as an 8-bit unsigned integer, so let's not lie to ourselves, make it an 8-bit unsigned integer. But with this comes the responsibility of watching out for overflow and other low-level things which generally don't come up when simply using a sufficiently large signed integer like int, people will have their own opinions on that matter
edit: fixed the termination condition error, thanks
Ah this is actually quite clever, lol... I would never write anything like that though, but it is a interesting point of view. :D My solution was, of course, to use an int instead.