No, it has no function of its own. It's bullying gcc into not
performing an optimisation by giving the impression its doing something.
It's consistent with the other functions defined here. I agree it isn't
pretty. If you have a better suggestion, I'm all ears.
On x86-32 it compiles to 26 instructions and 47 bytes of code.
Admittedly it might be smaller inline - or on a 64-bit machine - but I
seriously doubt its suffering a huge performance hit from being out of
line. These days the inline threshold is very small - probably under 10
instructions. A direct call/return is essentially free, since it can be
trivially prefetched.
Because it didn't seem all that unlikely. Besides, it makes not one bit
of difference to the code generated by my compiler.
"rm" isn't x86-specific. I just wanted to give the compiler the freedom
to put the value in either register or memory if it wanted to.
Everything else in the file is exported.
Uh, could you suggest a name? Something along the lines of
prevent_gcc_from_strength_reducing_this_subtraction_loop_into_a_modulo_operation_thanks_oh_and_remember_to_use_it_in_all_the_right_places()
springs to mind.
Rather than putting this unsightly (though with a smear of lipstick)
hack into every open-coded iterative div-mod loop, we may as well
implement it once and just look out for places which should be using it.
I don't think the "worse" code generation is much of an issue, since it
isn't used anywhere performance critical, and moving the code out of
line means there should be an overall reduction in code size.
J
--