GCC, C loops and dbra...

For those of you working on GCC projects with an eye on code generation, you’ve probably wondered why GCC doesn’t always emit DBRA instructions for C loops. In fact, it rarely emits them - the stars need to be aligned just right. And sometimes you’ll be faced with something so ugly and inexplicable for a loop that it might put you off using the compiler at all… First thing to realise here is that its not always ‘crap compiler’ but often ‘garbage in, garbage out’. »

dml