[committed] Handle POLY_INT_CST in copy_reference_ops_from_ref
diff mbox series

Message ID mptd0e2ln1q.fsf@arm.com
State New
Headers show
Series
  • [committed] Handle POLY_INT_CST in copy_reference_ops_from_ref
Related show

Commit Message

Richard Sandiford Nov. 8, 2019, 9:44 a.m. UTC
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.

Comments

Christophe Lyon Nov. 10, 2019, 6:23 p.m. UTC | #1
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 } } */
Richard Sandiford Nov. 12, 2019, 3:11 p.m. UTC | #2
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
Andreas Schwab Nov. 12, 2019, 3:51 p.m. UTC | #3
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.

Patch
diff mbox series

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 } } */