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

--- Comment #5 from Andrew Pinski <pinskia at gcc dot gnu.org> ---
(In reply to eggert from comment #3)
> (In reply to Andrew Pinski from comment #2)
> > This seems like a target issue ...
> 
> Although the code generated is target-dependent, the performance problem is
> not limited to x86-64. x86 has the same problem, and I suspect other
> platforms do too. I'll attach the x86 assembler code, where 'f' has one more
> insn than 'g' does even though the two functions have identical behavior.

x86 and x86_64 uses the same back-end so yes it does seem target secific.

AARCH64 produces:
f:
        and     x2, x0, 7
        and     w1, w0, 1
        cmp     x2, 6
        csel    w0, w0, w1, ne
        ret
        .size   f, .-f
        .align  2
        .p2align 3,,7
        .global g
        .type   g, %function
g:
        sub     x2, x0, #6
        and     w1, w0, 1
        tst     x2, 7
        csel    w0, w0, w1, ne
        ret
        .size   g, .-g

Both are similar in terms of performance.

Reply via email to