public inbox for libc-alpha@sourceware.org
 help / color / mirror / Atom feed
* [PATCH v1] x86: Remove SSE3 instruction for broadcast in memset.S (SSE2 Only)
@ 2022-02-07  6:38 Noah Goldstein
  2022-02-07 12:54 ` H.J. Lu
  2022-02-07 19:39 ` [PATCH v2] x86: Remove SSSE3 " Noah Goldstein
  0 siblings, 2 replies; 8+ messages in thread
From: Noah Goldstein @ 2022-02-07  6:38 UTC (permalink / raw)
  To: libc-alpha

commit b62ace2740a106222e124cc86956448fa07abf4d
Author: Noah Goldstein <goldstein.w.n@gmail.com>
Date:   Sun Feb 6 00:54:18 2022 -0600

    x86: Improve vec generation in memset-vec-unaligned-erms.S

Revert usage of 'pshufb' in broadcast logic as it is an SSE3
instruction and memset.S is restricted to only SSE2 instructions.
---
 sysdeps/x86_64/memset.S | 19 ++++++++++---------
 1 file changed, 10 insertions(+), 9 deletions(-)

diff --git a/sysdeps/x86_64/memset.S b/sysdeps/x86_64/memset.S
index ccf036be53..148553cf3d 100644
--- a/sysdeps/x86_64/memset.S
+++ b/sysdeps/x86_64/memset.S
@@ -28,22 +28,23 @@
 #define VMOVU     movups
 #define VMOVA     movaps
 
-# define MEMSET_SET_VEC0_AND_SET_RETURN(d, r) \
+#define MEMSET_SET_VEC0_AND_SET_RETURN(d, r) \
   movd d, %xmm0; \
-  pxor %xmm1, %xmm1; \
-  pshufb %xmm1, %xmm0; \
-  movq r, %rax
+  movq r, %rax; \
+  punpcklbw %xmm0, %xmm0; \
+  punpcklwd %xmm0, %xmm0; \
+  pshufd $0, %xmm0, %xmm0
 
-# define WMEMSET_SET_VEC0_AND_SET_RETURN(d, r) \
+#define WMEMSET_SET_VEC0_AND_SET_RETURN(d, r) \
   movd d, %xmm0; \
   pshufd $0, %xmm0, %xmm0; \
   movq r, %rax
 
-# define MEMSET_VDUP_TO_VEC0_HIGH()
-# define MEMSET_VDUP_TO_VEC0_LOW()
+#define MEMSET_VDUP_TO_VEC0_HIGH()
+#define MEMSET_VDUP_TO_VEC0_LOW()
 
-# define WMEMSET_VDUP_TO_VEC0_HIGH()
-# define WMEMSET_VDUP_TO_VEC0_LOW()
+#define WMEMSET_VDUP_TO_VEC0_HIGH()
+#define WMEMSET_VDUP_TO_VEC0_LOW()
 
 #define SECTION(p)		p
 
-- 
2.25.1


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

* Re: [PATCH v1] x86: Remove SSE3 instruction for broadcast in memset.S (SSE2 Only)
  2022-02-07  6:38 [PATCH v1] x86: Remove SSE3 instruction for broadcast in memset.S (SSE2 Only) Noah Goldstein
@ 2022-02-07 12:54 ` H.J. Lu
  2022-02-07 14:32   ` H.J. Lu
  2022-02-07 19:39 ` [PATCH v2] x86: Remove SSSE3 " Noah Goldstein
  1 sibling, 1 reply; 8+ messages in thread
From: H.J. Lu @ 2022-02-07 12:54 UTC (permalink / raw)
  To: Noah Goldstein; +Cc: GNU C Library, Carlos O'Donell

On Sun, Feb 6, 2022 at 10:39 PM Noah Goldstein <goldstein.w.n@gmail.com> wrote:
>
> commit b62ace2740a106222e124cc86956448fa07abf4d
> Author: Noah Goldstein <goldstein.w.n@gmail.com>
> Date:   Sun Feb 6 00:54:18 2022 -0600
>
>     x86: Improve vec generation in memset-vec-unaligned-erms.S
>
> Revert usage of 'pshufb' in broadcast logic as it is an SSE3
> instruction and memset.S is restricted to only SSE2 instructions.
> ---
>  sysdeps/x86_64/memset.S | 19 ++++++++++---------
>  1 file changed, 10 insertions(+), 9 deletions(-)
>
> diff --git a/sysdeps/x86_64/memset.S b/sysdeps/x86_64/memset.S
> index ccf036be53..148553cf3d 100644
> --- a/sysdeps/x86_64/memset.S
> +++ b/sysdeps/x86_64/memset.S
> @@ -28,22 +28,23 @@
>  #define VMOVU     movups
>  #define VMOVA     movaps
>
> -# define MEMSET_SET_VEC0_AND_SET_RETURN(d, r) \
> +#define MEMSET_SET_VEC0_AND_SET_RETURN(d, r) \
>    movd d, %xmm0; \
> -  pxor %xmm1, %xmm1; \
> -  pshufb %xmm1, %xmm0; \
> -  movq r, %rax
> +  movq r, %rax; \
> +  punpcklbw %xmm0, %xmm0; \
> +  punpcklwd %xmm0, %xmm0; \
> +  pshufd $0, %xmm0, %xmm0
>
> -# define WMEMSET_SET_VEC0_AND_SET_RETURN(d, r) \
> +#define WMEMSET_SET_VEC0_AND_SET_RETURN(d, r) \
>    movd d, %xmm0; \
>    pshufd $0, %xmm0, %xmm0; \
>    movq r, %rax
>
> -# define MEMSET_VDUP_TO_VEC0_HIGH()
> -# define MEMSET_VDUP_TO_VEC0_LOW()
> +#define MEMSET_VDUP_TO_VEC0_HIGH()
> +#define MEMSET_VDUP_TO_VEC0_LOW()

What are these changes for?

> -# define WMEMSET_VDUP_TO_VEC0_HIGH()
> -# define WMEMSET_VDUP_TO_VEC0_LOW()
> +#define WMEMSET_VDUP_TO_VEC0_HIGH()
> +#define WMEMSET_VDUP_TO_VEC0_LOW()

What are these changes for?

>  #define SECTION(p)             p
>
> --
> 2.25.1
>


-- 
H.J.

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

* Re: [PATCH v1] x86: Remove SSE3 instruction for broadcast in memset.S (SSE2 Only)
  2022-02-07 12:54 ` H.J. Lu
@ 2022-02-07 14:32   ` H.J. Lu
  2022-02-07 19:40     ` Noah Goldstein
  0 siblings, 1 reply; 8+ messages in thread
From: H.J. Lu @ 2022-02-07 14:32 UTC (permalink / raw)
  To: Noah Goldstein; +Cc: GNU C Library, Carlos O'Donell

On Mon, Feb 7, 2022 at 4:54 AM H.J. Lu <hjl.tools@gmail.com> wrote:
>
> On Sun, Feb 6, 2022 at 10:39 PM Noah Goldstein <goldstein.w.n@gmail.com> wrote:
> >
> > commit b62ace2740a106222e124cc86956448fa07abf4d
> > Author: Noah Goldstein <goldstein.w.n@gmail.com>
> > Date:   Sun Feb 6 00:54:18 2022 -0600
> >
> >     x86: Improve vec generation in memset-vec-unaligned-erms.S
> >
> > Revert usage of 'pshufb' in broadcast logic as it is an SSE3

pshufb is an SSSE3, not SSE3, instruction.

> > instruction and memset.S is restricted to only SSE2 instructions.
> > ---
> >  sysdeps/x86_64/memset.S | 19 ++++++++++---------
> >  1 file changed, 10 insertions(+), 9 deletions(-)
> >
> > diff --git a/sysdeps/x86_64/memset.S b/sysdeps/x86_64/memset.S
> > index ccf036be53..148553cf3d 100644
> > --- a/sysdeps/x86_64/memset.S
> > +++ b/sysdeps/x86_64/memset.S
> > @@ -28,22 +28,23 @@
> >  #define VMOVU     movups
> >  #define VMOVA     movaps
> >
> > -# define MEMSET_SET_VEC0_AND_SET_RETURN(d, r) \
> > +#define MEMSET_SET_VEC0_AND_SET_RETURN(d, r) \
> >    movd d, %xmm0; \
> > -  pxor %xmm1, %xmm1; \
> > -  pshufb %xmm1, %xmm0; \
> > -  movq r, %rax
> > +  movq r, %rax; \
> > +  punpcklbw %xmm0, %xmm0; \
> > +  punpcklwd %xmm0, %xmm0; \
> > +  pshufd $0, %xmm0, %xmm0
> >
> > -# define WMEMSET_SET_VEC0_AND_SET_RETURN(d, r) \
> > +#define WMEMSET_SET_VEC0_AND_SET_RETURN(d, r) \
> >    movd d, %xmm0; \
> >    pshufd $0, %xmm0, %xmm0; \
> >    movq r, %rax
> >
> > -# define MEMSET_VDUP_TO_VEC0_HIGH()
> > -# define MEMSET_VDUP_TO_VEC0_LOW()
> > +#define MEMSET_VDUP_TO_VEC0_HIGH()
> > +#define MEMSET_VDUP_TO_VEC0_LOW()
>
> What are these changes for?
>
> > -# define WMEMSET_VDUP_TO_VEC0_HIGH()
> > -# define WMEMSET_VDUP_TO_VEC0_LOW()
> > +#define WMEMSET_VDUP_TO_VEC0_HIGH()
> > +#define WMEMSET_VDUP_TO_VEC0_LOW()
>
> What are these changes for?
>
> >  #define SECTION(p)             p
> >
> > --
> > 2.25.1
> >
>
>
> --
> H.J.



-- 
H.J.

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

* [PATCH v2] x86: Remove SSSE3 instruction for broadcast in memset.S (SSE2 Only)
  2022-02-07  6:38 [PATCH v1] x86: Remove SSE3 instruction for broadcast in memset.S (SSE2 Only) Noah Goldstein
  2022-02-07 12:54 ` H.J. Lu
@ 2022-02-07 19:39 ` Noah Goldstein
  2022-02-07 19:49   ` H.J. Lu
  1 sibling, 1 reply; 8+ messages in thread
From: Noah Goldstein @ 2022-02-07 19:39 UTC (permalink / raw)
  To: libc-alpha

commit b62ace2740a106222e124cc86956448fa07abf4d
Author: Noah Goldstein <goldstein.w.n@gmail.com>
Date:   Sun Feb 6 00:54:18 2022 -0600

    x86: Improve vec generation in memset-vec-unaligned-erms.S

Revert usage of 'pshufb' in broadcast logic as it is an SSSE3
instruction and memset.S is restricted to only SSE2 instructions.
---
 sysdeps/x86_64/memset.S | 7 ++++---
 1 file changed, 4 insertions(+), 3 deletions(-)

diff --git a/sysdeps/x86_64/memset.S b/sysdeps/x86_64/memset.S
index ccf036be53..3f0517bbfc 100644
--- a/sysdeps/x86_64/memset.S
+++ b/sysdeps/x86_64/memset.S
@@ -30,9 +30,10 @@
 
 # define MEMSET_SET_VEC0_AND_SET_RETURN(d, r) \
   movd d, %xmm0; \
-  pxor %xmm1, %xmm1; \
-  pshufb %xmm1, %xmm0; \
-  movq r, %rax
+  movq r, %rax; \
+  punpcklbw %xmm0, %xmm0; \
+  punpcklwd %xmm0, %xmm0; \
+  pshufd $0, %xmm0, %xmm0
 
 # define WMEMSET_SET_VEC0_AND_SET_RETURN(d, r) \
   movd d, %xmm0; \
-- 
2.25.1


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

* Re: [PATCH v1] x86: Remove SSE3 instruction for broadcast in memset.S (SSE2 Only)
  2022-02-07 14:32   ` H.J. Lu
@ 2022-02-07 19:40     ` Noah Goldstein
  0 siblings, 0 replies; 8+ messages in thread
From: Noah Goldstein @ 2022-02-07 19:40 UTC (permalink / raw)
  To: H.J. Lu; +Cc: GNU C Library, Carlos O'Donell

On Mon, Feb 7, 2022 at 8:33 AM H.J. Lu <hjl.tools@gmail.com> wrote:
>
> On Mon, Feb 7, 2022 at 4:54 AM H.J. Lu <hjl.tools@gmail.com> wrote:
> >
> > On Sun, Feb 6, 2022 at 10:39 PM Noah Goldstein <goldstein.w.n@gmail.com> wrote:
> > >
> > > commit b62ace2740a106222e124cc86956448fa07abf4d
> > > Author: Noah Goldstein <goldstein.w.n@gmail.com>
> > > Date:   Sun Feb 6 00:54:18 2022 -0600
> > >
> > >     x86: Improve vec generation in memset-vec-unaligned-erms.S
> > >
> > > Revert usage of 'pshufb' in broadcast logic as it is an SSE3
>
> pshufb is an SSSE3, not SSE3, instruction.

Fixed. The commit message is different but V2 is up.

>
> > > instruction and memset.S is restricted to only SSE2 instructions.
> > > ---
> > >  sysdeps/x86_64/memset.S | 19 ++++++++++---------
> > >  1 file changed, 10 insertions(+), 9 deletions(-)
> > >
> > > diff --git a/sysdeps/x86_64/memset.S b/sysdeps/x86_64/memset.S
> > > index ccf036be53..148553cf3d 100644
> > > --- a/sysdeps/x86_64/memset.S
> > > +++ b/sysdeps/x86_64/memset.S
> > > @@ -28,22 +28,23 @@
> > >  #define VMOVU     movups
> > >  #define VMOVA     movaps
> > >
> > > -# define MEMSET_SET_VEC0_AND_SET_RETURN(d, r) \
> > > +#define MEMSET_SET_VEC0_AND_SET_RETURN(d, r) \
> > >    movd d, %xmm0; \
> > > -  pxor %xmm1, %xmm1; \
> > > -  pshufb %xmm1, %xmm0; \
> > > -  movq r, %rax
> > > +  movq r, %rax; \
> > > +  punpcklbw %xmm0, %xmm0; \
> > > +  punpcklwd %xmm0, %xmm0; \
> > > +  pshufd $0, %xmm0, %xmm0
> > >
> > > -# define WMEMSET_SET_VEC0_AND_SET_RETURN(d, r) \
> > > +#define WMEMSET_SET_VEC0_AND_SET_RETURN(d, r) \
> > >    movd d, %xmm0; \
> > >    pshufd $0, %xmm0, %xmm0; \
> > >    movq r, %rax
> > >
> > > -# define MEMSET_VDUP_TO_VEC0_HIGH()
> > > -# define MEMSET_VDUP_TO_VEC0_LOW()
> > > +#define MEMSET_VDUP_TO_VEC0_HIGH()
> > > +#define MEMSET_VDUP_TO_VEC0_LOW()
> >
> > What are these changes for?
> >
> > > -# define WMEMSET_VDUP_TO_VEC0_HIGH()
> > > -# define WMEMSET_VDUP_TO_VEC0_LOW()
> > > +#define WMEMSET_VDUP_TO_VEC0_HIGH()
> > > +#define WMEMSET_VDUP_TO_VEC0_LOW()
> >
> > What are these changes for?

Undid them in V2. Realized I had misindented them in my
last commit.
> >
> > >  #define SECTION(p)             p
> > >
> > > --
> > > 2.25.1
> > >
> >
> >
> > --
> > H.J.
>
>
>
> --
> H.J.

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

* Re: [PATCH v2] x86: Remove SSSE3 instruction for broadcast in memset.S (SSE2 Only)
  2022-02-07 19:39 ` [PATCH v2] x86: Remove SSSE3 " Noah Goldstein
@ 2022-02-07 19:49   ` H.J. Lu
  2022-02-07 20:56     ` Noah Goldstein
  0 siblings, 1 reply; 8+ messages in thread
From: H.J. Lu @ 2022-02-07 19:49 UTC (permalink / raw)
  To: Noah Goldstein; +Cc: GNU C Library, Carlos O'Donell

On Mon, Feb 7, 2022 at 11:39 AM Noah Goldstein <goldstein.w.n@gmail.com> wrote:
>
> commit b62ace2740a106222e124cc86956448fa07abf4d
> Author: Noah Goldstein <goldstein.w.n@gmail.com>
> Date:   Sun Feb 6 00:54:18 2022 -0600
>
>     x86: Improve vec generation in memset-vec-unaligned-erms.S
>
> Revert usage of 'pshufb' in broadcast logic as it is an SSSE3
> instruction and memset.S is restricted to only SSE2 instructions.
> ---
>  sysdeps/x86_64/memset.S | 7 ++++---
>  1 file changed, 4 insertions(+), 3 deletions(-)
>
> diff --git a/sysdeps/x86_64/memset.S b/sysdeps/x86_64/memset.S
> index ccf036be53..3f0517bbfc 100644
> --- a/sysdeps/x86_64/memset.S
> +++ b/sysdeps/x86_64/memset.S
> @@ -30,9 +30,10 @@
>
>  # define MEMSET_SET_VEC0_AND_SET_RETURN(d, r) \
>    movd d, %xmm0; \
> -  pxor %xmm1, %xmm1; \
> -  pshufb %xmm1, %xmm0; \
> -  movq r, %rax
> +  movq r, %rax; \
> +  punpcklbw %xmm0, %xmm0; \
> +  punpcklwd %xmm0, %xmm0; \
> +  pshufd $0, %xmm0, %xmm0
>
>  # define WMEMSET_SET_VEC0_AND_SET_RETURN(d, r) \
>    movd d, %xmm0; \
> --
> 2.25.1
>

LGTM.

Reviewed-by: H.J. Lu <hjl.tools@gmail.com>

Thanks.

-- 
H.J.

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

* Re: [PATCH v2] x86: Remove SSSE3 instruction for broadcast in memset.S (SSE2 Only)
  2022-02-07 19:49   ` H.J. Lu
@ 2022-02-07 20:56     ` Noah Goldstein
  2022-05-04  5:48       ` Sunil Pandey
  0 siblings, 1 reply; 8+ messages in thread
From: Noah Goldstein @ 2022-02-07 20:56 UTC (permalink / raw)
  To: H.J. Lu; +Cc: GNU C Library, Carlos O'Donell

On Mon, Feb 7, 2022 at 1:49 PM H.J. Lu <hjl.tools@gmail.com> wrote:
>
> On Mon, Feb 7, 2022 at 11:39 AM Noah Goldstein <goldstein.w.n@gmail.com> wrote:
> >
> > commit b62ace2740a106222e124cc86956448fa07abf4d
> > Author: Noah Goldstein <goldstein.w.n@gmail.com>
> > Date:   Sun Feb 6 00:54:18 2022 -0600
> >
> >     x86: Improve vec generation in memset-vec-unaligned-erms.S
> >
> > Revert usage of 'pshufb' in broadcast logic as it is an SSSE3
> > instruction and memset.S is restricted to only SSE2 instructions.
> > ---
> >  sysdeps/x86_64/memset.S | 7 ++++---
> >  1 file changed, 4 insertions(+), 3 deletions(-)
> >
> > diff --git a/sysdeps/x86_64/memset.S b/sysdeps/x86_64/memset.S
> > index ccf036be53..3f0517bbfc 100644
> > --- a/sysdeps/x86_64/memset.S
> > +++ b/sysdeps/x86_64/memset.S
> > @@ -30,9 +30,10 @@
> >
> >  # define MEMSET_SET_VEC0_AND_SET_RETURN(d, r) \
> >    movd d, %xmm0; \
> > -  pxor %xmm1, %xmm1; \
> > -  pshufb %xmm1, %xmm0; \
> > -  movq r, %rax
> > +  movq r, %rax; \
> > +  punpcklbw %xmm0, %xmm0; \
> > +  punpcklwd %xmm0, %xmm0; \
> > +  pshufd $0, %xmm0, %xmm0
> >
> >  # define WMEMSET_SET_VEC0_AND_SET_RETURN(d, r) \
> >    movd d, %xmm0; \
> > --
> > 2.25.1
> >
>
> LGTM.
>
> Reviewed-by: H.J. Lu <hjl.tools@gmail.com>
>
> Thanks.

Thanks pushed.
>
> --
> H.J.

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

* Re: [PATCH v2] x86: Remove SSSE3 instruction for broadcast in memset.S (SSE2 Only)
  2022-02-07 20:56     ` Noah Goldstein
@ 2022-05-04  5:48       ` Sunil Pandey
  0 siblings, 0 replies; 8+ messages in thread
From: Sunil Pandey @ 2022-05-04  5:48 UTC (permalink / raw)
  To: Noah Goldstein, Libc-stable Mailing List; +Cc: H.J. Lu, GNU C Library

On Mon, Feb 7, 2022 at 12:56 PM Noah Goldstein via Libc-alpha
<libc-alpha@sourceware.org> wrote:
>
> On Mon, Feb 7, 2022 at 1:49 PM H.J. Lu <hjl.tools@gmail.com> wrote:
> >
> > On Mon, Feb 7, 2022 at 11:39 AM Noah Goldstein <goldstein.w.n@gmail.com> wrote:
> > >
> > > commit b62ace2740a106222e124cc86956448fa07abf4d
> > > Author: Noah Goldstein <goldstein.w.n@gmail.com>
> > > Date:   Sun Feb 6 00:54:18 2022 -0600
> > >
> > >     x86: Improve vec generation in memset-vec-unaligned-erms.S
> > >
> > > Revert usage of 'pshufb' in broadcast logic as it is an SSSE3
> > > instruction and memset.S is restricted to only SSE2 instructions.
> > > ---
> > >  sysdeps/x86_64/memset.S | 7 ++++---
> > >  1 file changed, 4 insertions(+), 3 deletions(-)
> > >
> > > diff --git a/sysdeps/x86_64/memset.S b/sysdeps/x86_64/memset.S
> > > index ccf036be53..3f0517bbfc 100644
> > > --- a/sysdeps/x86_64/memset.S
> > > +++ b/sysdeps/x86_64/memset.S
> > > @@ -30,9 +30,10 @@
> > >
> > >  # define MEMSET_SET_VEC0_AND_SET_RETURN(d, r) \
> > >    movd d, %xmm0; \
> > > -  pxor %xmm1, %xmm1; \
> > > -  pshufb %xmm1, %xmm0; \
> > > -  movq r, %rax
> > > +  movq r, %rax; \
> > > +  punpcklbw %xmm0, %xmm0; \
> > > +  punpcklwd %xmm0, %xmm0; \
> > > +  pshufd $0, %xmm0, %xmm0
> > >
> > >  # define WMEMSET_SET_VEC0_AND_SET_RETURN(d, r) \
> > >    movd d, %xmm0; \
> > > --
> > > 2.25.1
> > >
> >
> > LGTM.
> >
> > Reviewed-by: H.J. Lu <hjl.tools@gmail.com>
> >
> > Thanks.
>
> Thanks pushed.
> >
> > --
> > H.J.

I would like to backport this patch to release branches.
Any comments or objections?

--Sunil

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

end of thread, other threads:[~2022-05-04  5:48 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-02-07  6:38 [PATCH v1] x86: Remove SSE3 instruction for broadcast in memset.S (SSE2 Only) Noah Goldstein
2022-02-07 12:54 ` H.J. Lu
2022-02-07 14:32   ` H.J. Lu
2022-02-07 19:40     ` Noah Goldstein
2022-02-07 19:39 ` [PATCH v2] x86: Remove SSSE3 " Noah Goldstein
2022-02-07 19:49   ` H.J. Lu
2022-02-07 20:56     ` Noah Goldstein
2022-05-04  5:48       ` Sunil Pandey

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).