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

--- Comment #5 from CVS Commits <cvs-commit at gcc dot gnu.org> ---
The master branch has been updated by Hongyu Wang <hong...@gcc.gnu.org>:

https://gcc.gnu.org/g:15f5e70cbb33b40c97325ef9d55557747a148d39

commit r12-5363-g15f5e70cbb33b40c97325ef9d55557747a148d39
Author: Hongyu Wang <hongyu.w...@intel.com>
Date:   Thu Nov 18 14:45:23 2021 +0800

    i386: Fix wrong codegen for -mrelax-cmpxchg-loop

    For -mrelax-cmpxchg-loop introduced by PR 103069/r12-5265, it would
    produce infinite loop. The correct code should be

    .L84:
            movl    (%rdi), %ecx
            movl    %eax, %edx
            orl     %esi, %edx
            cmpl    %eax, %ecx
            jne     .L82
            lock cmpxchgl   %edx, (%rdi)
            jne     .L84
            movl    %r8d, %eax  <<< retval is missing in previous impl
            ret
    .L82:
            rep nop
            jmp     .L84

    Adjust corresponding expander to fix such issue, and fix runtime test
    so the problem would be exposed.

    gcc/ChangeLog:

            * config/i386/i386-expand.c (ix86_expand_atomic_fetch_op_loop):
            Adjust generated cfg to avoid infinite loop.

    gcc/testsuite/ChangeLog:

            * gcc.target/i386/pr103069-2.c: Adjust.

Reply via email to