x86: Add a test for PR tree-optimization/42587

Message ID 20210508141850.42042-1-hjl.tools@gmail.com
State New
Headers show
Series
  • x86: Add a test for PR tree-optimization/42587
Related show

Commit Message

Martin Sebor via Gcc-patches May 8, 2021, 2:18 p.m.
PR tree-optimization/42587
	* gcc.target/i386/pr42587.c: New test.
---
 gcc/testsuite/gcc.target/i386/pr42587.c | 35 +++++++++++++++++++++++++
 1 file changed, 35 insertions(+)
 create mode 100644 gcc/testsuite/gcc.target/i386/pr42587.c

-- 
2.31.1

Comments

Martin Sebor via Gcc-patches May 8, 2021, 2:25 p.m. | #1
On Sat, May 8, 2021 at 7:18 AM H.J. Lu <hjl.tools@gmail.com> wrote:
>

>         PR tree-optimization/42587

>         * gcc.target/i386/pr42587.c: New test.

> ---

>  gcc/testsuite/gcc.target/i386/pr42587.c | 35 +++++++++++++++++++++++++

>  1 file changed, 35 insertions(+)

>  create mode 100644 gcc/testsuite/gcc.target/i386/pr42587.c

>

> diff --git a/gcc/testsuite/gcc.target/i386/pr42587.c b/gcc/testsuite/gcc.target/i386/pr42587.c

> new file mode 100644

> index 00000000000..d4b5143eb6d

> --- /dev/null

> +++ b/gcc/testsuite/gcc.target/i386/pr42587.c

> @@ -0,0 +1,35 @@

> +/* { dg-do compile } */

> +/* { dg-options "-O2 -fdump-tree-store-merging" } */

> +

> +typedef unsigned char u8;

> +typedef unsigned int u32;

> +union __anonunion_out_195

> +{

> +  u32 value;

> +  u8 bytes[4];

> +};

> +union __anonunion_in_196

> +{

> +  u32 value;

> +  u8 bytes[4];

> +};

> +extern void acpi_ut_track_stack_ptr (void);

> +u32 acpi_ut_dword_byte_swap (u32 value);

> +u32

> +acpi_ut_dword_byte_swap (u32 value)

> +{

> +  union __anonunion_out_195 out;

> +  union __anonunion_in_196 in;

> +

> +  {

> +    acpi_ut_track_stack_ptr ();

> +    in.value = value;

> +    out.bytes[0] = in.bytes[3];

> +    out.bytes[1] = in.bytes[2];

> +    out.bytes[2] = in.bytes[1];

> +    out.bytes[3] = in.bytes[0];

> +    return (out.value);

> +  }

> +}

> +

> +/* { dg-final { scan-tree-dump "32 bit bswap implementation found at" "store-merging" } } */

> --

> 2.31.1

>


The v2 patch to add gcc.dg/optimize-bswapsi-6.c.  Which one is
preferred?

-- 
H.J.
Martin Sebor via Gcc-patches May 8, 2021, 6:02 p.m. | #2
On Sat, May 8, 2021 at 7:25 AM H.J. Lu <hjl.tools@gmail.com> wrote:
>

> On Sat, May 8, 2021 at 7:18 AM H.J. Lu <hjl.tools@gmail.com> wrote:

> >

> >         PR tree-optimization/42587

> >         * gcc.target/i386/pr42587.c: New test.

> > ---

> >  gcc/testsuite/gcc.target/i386/pr42587.c | 35 +++++++++++++++++++++++++

> >  1 file changed, 35 insertions(+)

> >  create mode 100644 gcc/testsuite/gcc.target/i386/pr42587.c

> >

> > diff --git a/gcc/testsuite/gcc.target/i386/pr42587.c b/gcc/testsuite/gcc.target/i386/pr42587.c

> > new file mode 100644

> > index 00000000000..d4b5143eb6d

> > --- /dev/null

> > +++ b/gcc/testsuite/gcc.target/i386/pr42587.c

> > @@ -0,0 +1,35 @@

> > +/* { dg-do compile } */

> > +/* { dg-options "-O2 -fdump-tree-store-merging" } */

> > +

> > +typedef unsigned char u8;

> > +typedef unsigned int u32;

> > +union __anonunion_out_195

> > +{

> > +  u32 value;

> > +  u8 bytes[4];

> > +};

> > +union __anonunion_in_196

> > +{

> > +  u32 value;

> > +  u8 bytes[4];

> > +};

> > +extern void acpi_ut_track_stack_ptr (void);

> > +u32 acpi_ut_dword_byte_swap (u32 value);

> > +u32

> > +acpi_ut_dword_byte_swap (u32 value)

> > +{

> > +  union __anonunion_out_195 out;

> > +  union __anonunion_in_196 in;

> > +

> > +  {

> > +    acpi_ut_track_stack_ptr ();

> > +    in.value = value;

> > +    out.bytes[0] = in.bytes[3];

> > +    out.bytes[1] = in.bytes[2];

> > +    out.bytes[2] = in.bytes[1];

> > +    out.bytes[3] = in.bytes[0];

> > +    return (out.value);

> > +  }

> > +}

> > +

> > +/* { dg-final { scan-tree-dump "32 bit bswap implementation found at" "store-merging" } } */

> > --

> > 2.31.1

> >

>

> The v2 patch to add gcc.dg/optimize-bswapsi-6.c.  Which one is

> preferred?

>


If there are no objections, I will check in the v2 testcase and close

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

-- 
H.J.

Patch

diff --git a/gcc/testsuite/gcc.target/i386/pr42587.c b/gcc/testsuite/gcc.target/i386/pr42587.c
new file mode 100644
index 00000000000..d4b5143eb6d
--- /dev/null
+++ b/gcc/testsuite/gcc.target/i386/pr42587.c
@@ -0,0 +1,35 @@ 
+/* { dg-do compile } */
+/* { dg-options "-O2 -fdump-tree-store-merging" } */
+
+typedef unsigned char u8;
+typedef unsigned int u32;
+union __anonunion_out_195
+{
+  u32 value;
+  u8 bytes[4];
+};
+union __anonunion_in_196
+{
+  u32 value;
+  u8 bytes[4];
+};
+extern void acpi_ut_track_stack_ptr (void);
+u32 acpi_ut_dword_byte_swap (u32 value);
+u32
+acpi_ut_dword_byte_swap (u32 value)
+{
+  union __anonunion_out_195 out;
+  union __anonunion_in_196 in;
+
+  {
+    acpi_ut_track_stack_ptr ();
+    in.value = value;
+    out.bytes[0] = in.bytes[3];
+    out.bytes[1] = in.bytes[2];
+    out.bytes[2] = in.bytes[1];
+    out.bytes[3] = in.bytes[0];
+    return (out.value);
+  }
+}
+
+/* { dg-final { scan-tree-dump "32 bit bswap implementation found at" "store-merging" } } */