On Wed, Jun 24, 2026 at 2:25 PM Uros Bizjak <[email protected]> wrote: > > On Wed, Jun 24, 2026 at 8:07 AM H.J. Lu <[email protected]> wrote: > > > > Use the previous scratch register if it is a general purpose register > > wide enough to supply the required mode, or an SSE register which > > is valid in the required mode. If the required mode is QImode, the > > previous scratch register must be valid in QImode. Also match const0_rtx > > against CONST0_RTX. > > > > gcc/ > > > > PR target/125958 > > * config/i386/i386-expand.cc (ix86_expand_lcp_stall_peephole): > > Update previous scratch register check. Match const0_rtx > > against CONST0_RTX. > > > > gcc/testsuite/ > > > > PR target/125958 > > * gcc.target/i386/pr125958a.c: New test. > > * gcc.target/i386/pr125958b.c: Likewise. > > - /* Reject DEST if a register is not wide enough to > - supply MODE or invalid for QImode. */ > - if (!REG_P (dest) > - || (GET_MODE_SIZE (GET_MODE (dest)) > - < GET_MODE_SIZE (mode)) > - || (mode == QImode > - && !ANY_QI_REGNO_P (REGNO (dest)))) > + /* Reject DEST if it isn't a general purpose register > + wide enough to supply MODE or invalid for QImode > + or isn't an SSE register which is invalid for > + MODE. */ > + if ((!GENERAL_REG_P (dest) > > Just change !REG_P (dest) to !GENERAL_REG_P (dest) and don't bother > with SSE regs. >
Fixed in the v2 patch here. -- H.J. --- Require general purpose register as previous scratch register in LCP stall peepholes. gcc/ PR target/125958 * config/i386/i386-expand.cc (ix86_expand_lcp_stall_peephole): Replace !REG_P (dest) with !GENERAL_REG_P (dest). gcc/testsuite/ PR target/125958 * gcc.target/i386/pr125958.c: New test.
From 18df15d937b48743983aee18aadc989d9e6eeca3 Mon Sep 17 00:00:00 2001 From: "H.J. Lu" <[email protected]> Date: Wed, 24 Jun 2026 06:45:11 +0800 Subject: [PATCH v2] x86: Require GPR as previous scratch register in LCP stall peepholes Require general purpose register as previous scratch register in LCP stall peepholes. gcc/ PR target/125958 * config/i386/i386-expand.cc (ix86_expand_lcp_stall_peephole): Replace !REG_P (dest) with !GENERAL_REG_P (dest). gcc/testsuite/ PR target/125958 * gcc.target/i386/pr125958.c: New test. Signed-off-by: H.J. Lu <[email protected]> --- gcc/config/i386/i386-expand.cc | 2 +- gcc/testsuite/gcc.target/i386/pr125958.c | 22 ++++++++++++++++++++++ 2 files changed, 23 insertions(+), 1 deletion(-) create mode 100644 gcc/testsuite/gcc.target/i386/pr125958.c diff --git a/gcc/config/i386/i386-expand.cc b/gcc/config/i386/i386-expand.cc index 429f00f03e9..99b6343106a 100644 --- a/gcc/config/i386/i386-expand.cc +++ b/gcc/config/i386/i386-expand.cc @@ -28315,7 +28315,7 @@ ix86_expand_lcp_stall_peephole (rtx_insn *insn, rtx *operands, /* Reject DEST if a register is not wide enough to supply MODE or invalid for QImode. */ - if (!REG_P (dest) + if (!GENERAL_REG_P (dest) || (GET_MODE_SIZE (GET_MODE (dest)) < GET_MODE_SIZE (mode)) || (mode == QImode diff --git a/gcc/testsuite/gcc.target/i386/pr125958.c b/gcc/testsuite/gcc.target/i386/pr125958.c new file mode 100644 index 00000000000..c747cb97596 --- /dev/null +++ b/gcc/testsuite/gcc.target/i386/pr125958.c @@ -0,0 +1,22 @@ +/* { dg-do compile { target fpic } } */ +/* { dg-options "-O2 -fno-pic -march=x86-64" } */ +/* Keep labels and directives ('.cfi_startproc', '.cfi_endproc'). */ +/* { dg-final { check-function-bodies "**" "" "" { target *-*-* } {^\t?\.} } } */ + +/* +**vcn_init_session_buf_fc: +**.LFB0: +**... +** pxor %xmm0, %xmm0 +** xorl %[a-z0-9]+, %[a-z0-9]+ +** movw %[a-z0-9]+, 16\(%[a-z0-9]+\) +** movups %xmm0, \(%[a-z0-9]+\) +**... +*/ + +const short ar[9] = {}; +void +vcn_init_session_buf_fc (void * r) +{ + __builtin_memcpy (r, ar,sizeof(ar)); +} -- 2.54.0
