public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
* [PATCH] i386: Fix infinite loop under -mrelax-cmpxchg-loop [PR 103069]
@ 2022-04-13  7:06 Hongyu Wang
  2022-04-13  7:37 ` Uros Bizjak
  0 siblings, 1 reply; 2+ messages in thread
From: Hongyu Wang @ 2022-04-13  7:06 UTC (permalink / raw)
  To: ubizjak; +Cc: gcc-patches

Hi,

For -mrelax-cmpxchg-loop which relaxes atomic_fetch_<logic> loops,
there is a missing set to %eax when compare fails, which would result
in infinite loop in some benchmark. Add set to %eax to avoid it.

Bootstraped/regtested on x86_64-pc-linux-gnu{-m32,}

Ok for master?

gcc/ChangeLog:

	PR target/103069
	* config/i386/i386-expand.cc (ix86_expand_cmpxchg_loop):
	  Add missing set to target_val at pause label.
---
 gcc/config/i386/i386-expand.cc | 1 +
 1 file changed, 1 insertion(+)

diff --git a/gcc/config/i386/i386-expand.cc b/gcc/config/i386/i386-expand.cc
index 794315ee2f7..2144d3f968d 100644
--- a/gcc/config/i386/i386-expand.cc
+++ b/gcc/config/i386/i386-expand.cc
@@ -23388,6 +23388,7 @@ void ix86_expand_cmpxchg_loop (rtx *ptarget_bool, rtx target_val,
 
     /* If mem is not expected, pause and loop back.  */
     emit_label (cmp_label);
+    emit_move_insn (target_val, new_mem);
     emit_insn (gen_pause ());
     emit_jump_insn (gen_jump (loop_label));
     emit_barrier ();
-- 
2.18.1


^ permalink raw reply	[flat|nested] 2+ messages in thread

* Re: [PATCH] i386: Fix infinite loop under -mrelax-cmpxchg-loop [PR 103069]
  2022-04-13  7:06 [PATCH] i386: Fix infinite loop under -mrelax-cmpxchg-loop [PR 103069] Hongyu Wang
@ 2022-04-13  7:37 ` Uros Bizjak
  0 siblings, 0 replies; 2+ messages in thread
From: Uros Bizjak @ 2022-04-13  7:37 UTC (permalink / raw)
  To: Hongyu Wang; +Cc: gcc-patches

On Wed, Apr 13, 2022 at 9:07 AM Hongyu Wang <hongyu.wang@intel.com> wrote:
>
> Hi,
>
> For -mrelax-cmpxchg-loop which relaxes atomic_fetch_<logic> loops,
> there is a missing set to %eax when compare fails, which would result
> in infinite loop in some benchmark. Add set to %eax to avoid it.
>
> Bootstraped/regtested on x86_64-pc-linux-gnu{-m32,}
>
> Ok for master?
>
> gcc/ChangeLog:
>
>         PR target/103069
>         * config/i386/i386-expand.cc (ix86_expand_cmpxchg_loop):
>           Add missing set to target_val at pause label.

LGTM.

Uros.

> ---
>  gcc/config/i386/i386-expand.cc | 1 +
>  1 file changed, 1 insertion(+)
>
> diff --git a/gcc/config/i386/i386-expand.cc b/gcc/config/i386/i386-expand.cc
> index 794315ee2f7..2144d3f968d 100644
> --- a/gcc/config/i386/i386-expand.cc
> +++ b/gcc/config/i386/i386-expand.cc
> @@ -23388,6 +23388,7 @@ void ix86_expand_cmpxchg_loop (rtx *ptarget_bool, rtx target_val,
>
>      /* If mem is not expected, pause and loop back.  */
>      emit_label (cmp_label);
> +    emit_move_insn (target_val, new_mem);
>      emit_insn (gen_pause ());
>      emit_jump_insn (gen_jump (loop_label));
>      emit_barrier ();
> --
> 2.18.1
>

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2022-04-13  7:38 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-04-13  7:06 [PATCH] i386: Fix infinite loop under -mrelax-cmpxchg-loop [PR 103069] Hongyu Wang
2022-04-13  7:37 ` Uros Bizjak

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).