https://gcc.gnu.org/bugzilla/show_bug.cgi?id=112662

--- Comment #2 from gooncreeper <goon.pri.low at gmail dot com> ---
I believe I got my initial optimized function wrong, it should actually be this


unsigned opt(unsigned a) {
    if (++a > 999) a = 0;
    return a;
}

opt:
        lea     eax, [rdi+1]
        xor     edx, edx
        cmp     eax, 1000
        cmovnb  eax, edx
        ret

Which is a bit more clear also.

Reply via email to