------- Comment #51 from dsilvers at digital-scurf dot org 2008-12-10 15:49 ------- I'd like to raise here that bug 38453 which was marked as a duplicate of this is in fact an example not only of wrong optimisation, but of missed optimisation as well.
The compiler emits the loop in the bug report *and* then emits the umod call despite already having the same answer in a register. If the compiler had only emitted the umod call then at least it wouldn't have done the work twice. I think it's critical that there be costs applied to these builtins -- especially for platforms where they are a full function call away rather than being instructions. -- http://gcc.gnu.org/bugzilla/show_bug.cgi?id=32044