public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
* [committed] Handle POLY_INT_CST in copy_reference_ops_from_ref
@ 2019-11-08  9:44 Richard Sandiford
  2019-11-10 18:28 ` Christophe Lyon
  0 siblings, 1 reply; 4+ messages in thread
From: Richard Sandiford @ 2019-11-08  9:44 UTC (permalink / raw)
  To: gcc-patches; +Cc: szabolcs.nagy

Tested on aarch64-linux-gnu and x86_64-linux-gnu.  Applied as obvious.

Richard


2019-11-08  Richard Sandiford  <richard.sandiford@arm.com>

gcc/
	* tree-ssa-sccvn.c (copy_reference_ops_from_ref): Handle
	POLY_INT_CST.

gcc/testsuite/
	* gcc.target/aarch64/sve/acle/general/deref_2.c: New test.
	* gcc.target/aarch64/sve/acle/general/whilele_8.c: Likewise.
	* gcc.target/aarch64/sve/acle/general/whilelt_4.c: Likewise.

Index: gcc/tree-ssa-sccvn.c
===================================================================
--- gcc/tree-ssa-sccvn.c	2019-10-31 17:15:21.594544316 +0000
+++ gcc/tree-ssa-sccvn.c	2019-11-08 09:43:07.927488162 +0000
@@ -928,6 +928,7 @@ copy_reference_ops_from_ref (tree ref, v
 	  break;
 	case STRING_CST:
 	case INTEGER_CST:
+	case POLY_INT_CST:
 	case COMPLEX_CST:
 	case VECTOR_CST:
 	case REAL_CST:
Index: gcc/testsuite/gcc.target/aarch64/sve/acle/general/deref_2.c
===================================================================
--- /dev/null	2019-09-17 11:41:18.176664108 +0100
+++ gcc/testsuite/gcc.target/aarch64/sve/acle/general/deref_2.c	2019-11-08 09:43:07.927488162 +0000
@@ -0,0 +1,20 @@
+/* { dg-options "-O2" } */
+
+#include <arm_sve.h>
+#include <string.h>
+
+inline void
+copy (void *dst, svbool_t src)
+{
+  memcpy (dst, &src, svcntd ());
+}
+
+uint64_t
+f (int32_t *x, int32_t *y)
+{
+  union { uint64_t x; char c[8]; } u;
+  svbool_t pg = svptrue_b32 ();
+  copy (u.c, svcmpeq (pg, svld1 (pg, x), 0));
+  copy (u.c + 4, svcmpeq (pg, svld1 (pg, y), 1));
+  return u.x;
+}
Index: gcc/testsuite/gcc.target/aarch64/sve/acle/general/whilele_8.c
===================================================================
--- /dev/null	2019-09-17 11:41:18.176664108 +0100
+++ gcc/testsuite/gcc.target/aarch64/sve/acle/general/whilele_8.c	2019-11-08 09:43:07.927488162 +0000
@@ -0,0 +1,33 @@
+/* { dg-do compile } */
+/* { dg-options "-O2" } */
+
+#include <arm_sve.h>
+
+/* { dg-final { scan-assembler-not {\tptrue\t} } } */
+/* { dg-final { scan-assembler-not {\tpfalse\t} } } */
+
+void
+test1 (svbool_t *ptr)
+{
+  *ptr = svwhilele_b32_s32 (-4, 0);
+}
+
+void
+test2 (svbool_t *ptr)
+{
+  *ptr = svwhilele_b16_s64 (svcntb (), svcntb () + 8);
+}
+
+void
+test3 (svbool_t *ptr)
+{
+  *ptr = svwhilele_b64_s32 (0, 2);
+}
+
+void
+test4 (svbool_t *ptr)
+{
+  *ptr = svwhilele_b8_s64 (16, svcntb ());
+}
+
+/* { dg-final { scan-assembler-times {\twhilel[et]\t} 4 } } */
Index: gcc/testsuite/gcc.target/aarch64/sve/acle/general/whilelt_4.c
===================================================================
--- /dev/null	2019-09-17 11:41:18.176664108 +0100
+++ gcc/testsuite/gcc.target/aarch64/sve/acle/general/whilelt_4.c	2019-11-08 09:43:07.927488162 +0000
@@ -0,0 +1,33 @@
+/* { dg-do compile } */
+/* { dg-options "-O2" } */
+
+#include <arm_sve.h>
+
+/* { dg-final { scan-assembler-not {\tptrue\t} } } */
+/* { dg-final { scan-assembler-not {\tpfalse\t} } } */
+
+void
+test1 (svbool_t *ptr)
+{
+  *ptr = svwhilelt_b32_s32 (-4, 1);
+}
+
+void
+test2 (svbool_t *ptr)
+{
+  *ptr = svwhilelt_b16_s64 (svcntb (), svcntb () + 9);
+}
+
+void
+test3 (svbool_t *ptr)
+{
+  *ptr = svwhilelt_b64_s32 (0, 3);
+}
+
+void
+test4 (svbool_t *ptr)
+{
+  *ptr = svwhilelt_b8_s64 (16, svcntb ());
+}
+
+/* { dg-final { scan-assembler-times {\twhilel[et]\t} 4 } } */

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

* Re: [committed] Handle POLY_INT_CST in copy_reference_ops_from_ref
  2019-11-08  9:44 [committed] Handle POLY_INT_CST in copy_reference_ops_from_ref Richard Sandiford
@ 2019-11-10 18:28 ` Christophe Lyon
  2019-11-12 15:16   ` Richard Sandiford
  0 siblings, 1 reply; 4+ messages in thread
From: Christophe Lyon @ 2019-11-10 18:28 UTC (permalink / raw)
  To: gcc Patches, Szabolcs Nagy, Richard Sandiford

On Fri, 8 Nov 2019 at 10:44, Richard Sandiford
<richard.sandiford@arm.com> wrote:
>
> Tested on aarch64-linux-gnu and x86_64-linux-gnu.  Applied as obvious.
>

Hi Richard,

The new deref_2.c test fails with -mabi=ilp32:
FAIL: gcc.target/aarch64/sve/acle/general/deref_2.c
-march=armv8.2-a+sve (test for excess errors)
Excess errors:
/gcc/testsuite/gcc.target/aarch64/sve/acle/general/deref_2.c:17:39:
error: no matching function for call to 'svld1(svbool_t&, int32_t*&)'
/gcc/testsuite/gcc.target/aarch64/sve/acle/general/deref_2.c:17:38:
error: invalid conversion from 'int32_t*' {aka 'long int*'} to 'const
int*' [-fpermissive]
/gcc/testsuite/gcc.target/aarch64/sve/acle/general/deref_2.c:17:38:
error: invalid conversion from 'int32_t*' {aka 'long int*'} to 'const
unsigned int*' [-fpermissive]
/gcc/testsuite/gcc.target/aarch64/sve/acle/general/deref_2.c:18:43:
error: no matching function for call to 'svld1(svbool_t&, int32_t*&)'
/gcc/testsuite/gcc.target/aarch64/sve/acle/general/deref_2.c:18:42:
error: invalid conversion from 'int32_t*' {aka 'long int*'} to 'const
int*' [-fpermissive]
/gcc/testsuite/gcc.target/aarch64/sve/acle/general/deref_2.c:18:42:
error: invalid conversion from 'int32_t*' {aka 'long int*'} to 'const
unsigned int*' [-fpermissive]

Christophe

> Richard
>
>
> 2019-11-08  Richard Sandiford  <richard.sandiford@arm.com>
>
> gcc/
>         * tree-ssa-sccvn.c (copy_reference_ops_from_ref): Handle
>         POLY_INT_CST.
>
> gcc/testsuite/
>         * gcc.target/aarch64/sve/acle/general/deref_2.c: New test.
>         * gcc.target/aarch64/sve/acle/general/whilele_8.c: Likewise.
>         * gcc.target/aarch64/sve/acle/general/whilelt_4.c: Likewise.
>
> Index: gcc/tree-ssa-sccvn.c
> ===================================================================
> --- gcc/tree-ssa-sccvn.c        2019-10-31 17:15:21.594544316 +0000
> +++ gcc/tree-ssa-sccvn.c        2019-11-08 09:43:07.927488162 +0000
> @@ -928,6 +928,7 @@ copy_reference_ops_from_ref (tree ref, v
>           break;
>         case STRING_CST:
>         case INTEGER_CST:
> +       case POLY_INT_CST:
>         case COMPLEX_CST:
>         case VECTOR_CST:
>         case REAL_CST:
> Index: gcc/testsuite/gcc.target/aarch64/sve/acle/general/deref_2.c
> ===================================================================
> --- /dev/null   2019-09-17 11:41:18.176664108 +0100
> +++ gcc/testsuite/gcc.target/aarch64/sve/acle/general/deref_2.c 2019-11-08 09:43:07.927488162 +0000
> @@ -0,0 +1,20 @@
> +/* { dg-options "-O2" } */
> +
> +#include <arm_sve.h>
> +#include <string.h>
> +
> +inline void
> +copy (void *dst, svbool_t src)
> +{
> +  memcpy (dst, &src, svcntd ());
> +}
> +
> +uint64_t
> +f (int32_t *x, int32_t *y)
> +{
> +  union { uint64_t x; char c[8]; } u;
> +  svbool_t pg = svptrue_b32 ();
> +  copy (u.c, svcmpeq (pg, svld1 (pg, x), 0));
> +  copy (u.c + 4, svcmpeq (pg, svld1 (pg, y), 1));
> +  return u.x;
> +}
> Index: gcc/testsuite/gcc.target/aarch64/sve/acle/general/whilele_8.c
> ===================================================================
> --- /dev/null   2019-09-17 11:41:18.176664108 +0100
> +++ gcc/testsuite/gcc.target/aarch64/sve/acle/general/whilele_8.c       2019-11-08 09:43:07.927488162 +0000
> @@ -0,0 +1,33 @@
> +/* { dg-do compile } */
> +/* { dg-options "-O2" } */
> +
> +#include <arm_sve.h>
> +
> +/* { dg-final { scan-assembler-not {\tptrue\t} } } */
> +/* { dg-final { scan-assembler-not {\tpfalse\t} } } */
> +
> +void
> +test1 (svbool_t *ptr)
> +{
> +  *ptr = svwhilele_b32_s32 (-4, 0);
> +}
> +
> +void
> +test2 (svbool_t *ptr)
> +{
> +  *ptr = svwhilele_b16_s64 (svcntb (), svcntb () + 8);
> +}
> +
> +void
> +test3 (svbool_t *ptr)
> +{
> +  *ptr = svwhilele_b64_s32 (0, 2);
> +}
> +
> +void
> +test4 (svbool_t *ptr)
> +{
> +  *ptr = svwhilele_b8_s64 (16, svcntb ());
> +}
> +
> +/* { dg-final { scan-assembler-times {\twhilel[et]\t} 4 } } */
> Index: gcc/testsuite/gcc.target/aarch64/sve/acle/general/whilelt_4.c
> ===================================================================
> --- /dev/null   2019-09-17 11:41:18.176664108 +0100
> +++ gcc/testsuite/gcc.target/aarch64/sve/acle/general/whilelt_4.c       2019-11-08 09:43:07.927488162 +0000
> @@ -0,0 +1,33 @@
> +/* { dg-do compile } */
> +/* { dg-options "-O2" } */
> +
> +#include <arm_sve.h>
> +
> +/* { dg-final { scan-assembler-not {\tptrue\t} } } */
> +/* { dg-final { scan-assembler-not {\tpfalse\t} } } */
> +
> +void
> +test1 (svbool_t *ptr)
> +{
> +  *ptr = svwhilelt_b32_s32 (-4, 1);
> +}
> +
> +void
> +test2 (svbool_t *ptr)
> +{
> +  *ptr = svwhilelt_b16_s64 (svcntb (), svcntb () + 9);
> +}
> +
> +void
> +test3 (svbool_t *ptr)
> +{
> +  *ptr = svwhilelt_b64_s32 (0, 3);
> +}
> +
> +void
> +test4 (svbool_t *ptr)
> +{
> +  *ptr = svwhilelt_b8_s64 (16, svcntb ());
> +}
> +
> +/* { dg-final { scan-assembler-times {\twhilel[et]\t} 4 } } */

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

* Re: [committed] Handle POLY_INT_CST in copy_reference_ops_from_ref
  2019-11-10 18:28 ` Christophe Lyon
@ 2019-11-12 15:16   ` Richard Sandiford
  2019-11-12 15:57     ` Andreas Schwab
  0 siblings, 1 reply; 4+ messages in thread
From: Richard Sandiford @ 2019-11-12 15:16 UTC (permalink / raw)
  To: Christophe Lyon; +Cc: gcc Patches, Szabolcs Nagy

Christophe Lyon <christophe.lyon@linaro.org> writes:
> On Fri, 8 Nov 2019 at 10:44, Richard Sandiford
> <richard.sandiford@arm.com> wrote:
>>
>> Tested on aarch64-linux-gnu and x86_64-linux-gnu.  Applied as obvious.
>>
>
> Hi Richard,
>
> The new deref_2.c test fails with -mabi=ilp32:
> FAIL: gcc.target/aarch64/sve/acle/general/deref_2.c
> -march=armv8.2-a+sve (test for excess errors)
> Excess errors:
> /gcc/testsuite/gcc.target/aarch64/sve/acle/general/deref_2.c:17:39:
> error: no matching function for call to 'svld1(svbool_t&, int32_t*&)'
> /gcc/testsuite/gcc.target/aarch64/sve/acle/general/deref_2.c:17:38:
> error: invalid conversion from 'int32_t*' {aka 'long int*'} to 'const
> int*' [-fpermissive]
> /gcc/testsuite/gcc.target/aarch64/sve/acle/general/deref_2.c:17:38:
> error: invalid conversion from 'int32_t*' {aka 'long int*'} to 'const
> unsigned int*' [-fpermissive]
> /gcc/testsuite/gcc.target/aarch64/sve/acle/general/deref_2.c:18:43:
> error: no matching function for call to 'svld1(svbool_t&, int32_t*&)'
> /gcc/testsuite/gcc.target/aarch64/sve/acle/general/deref_2.c:18:42:
> error: invalid conversion from 'int32_t*' {aka 'long int*'} to 'const
> int*' [-fpermissive]
> /gcc/testsuite/gcc.target/aarch64/sve/acle/general/deref_2.c:18:42:
> error: invalid conversion from 'int32_t*' {aka 'long int*'} to 'const
> unsigned int*' [-fpermissive]

Ugh.  This is because for -mabi=ilp32, newlib's stdint.h defines int32_t
to be long int rather than int.  It's easy to update the ACLE code to use
the right stdint.h type, but the problem is that for ILP32, the C++ code:

  int x;
  f(&x);

does not resolve to any of the overloads:

  void f(int8_t *);
  void f(int16_t *);
  void f(int32_t *);
  void f(int64_t *);

Of course, if int32_t was defined to "int" then the above would fail for
"long int", but it seems especially surprising that this doesn't work
for int.  These days using long int directly is usually a mistake anyway.

I guess this int != int32_t thing is just something that users will have
to live with if they care about compatibility with ILP32 newlib.

I'll try to make the tests ILP32 clean once we're in stage 3, including
fixing the problems that Andreas pointed out.

Thanks,
Richard

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

* Re: [committed] Handle POLY_INT_CST in copy_reference_ops_from_ref
  2019-11-12 15:16   ` Richard Sandiford
@ 2019-11-12 15:57     ` Andreas Schwab
  0 siblings, 0 replies; 4+ messages in thread
From: Andreas Schwab @ 2019-11-12 15:57 UTC (permalink / raw)
  To: Christophe Lyon; +Cc: gcc Patches, Szabolcs Nagy, richard.sandiford

On Nov 12 2019, Richard Sandiford wrote:

> I'll try to make the tests ILP32 clean once we're in stage 3, including
> fixing the problems that Andreas pointed out.

Note that the massive testsuite failures cause the gcc-testresults mail
to become so huge (> 4Mb) that gcc.gnu.org rejects it.

Andreas.

-- 
Andreas Schwab, SUSE Labs, schwab@suse.de
GPG Key fingerprint = 0196 BAD8 1CE9 1970 F4BE  1748 E4D4 88E3 0EEA B9D7
"And now for something completely different."

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

end of thread, other threads:[~2019-11-12 15:51 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-11-08  9:44 [committed] Handle POLY_INT_CST in copy_reference_ops_from_ref Richard Sandiford
2019-11-10 18:28 ` Christophe Lyon
2019-11-12 15:16   ` Richard Sandiford
2019-11-12 15:57     ` Andreas Schwab

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