On 02/08/18 20:18, James Greenhalgh wrote:
On Tue, Jul 31, 2018 at 04:53:19AM -0500, Matthew Malcomson wrote:
Fixing the ilp32 issue that Christophe found.

The existing testcase uses `long` to represent a 64 bit integer.
This breaks when compiled using the `-mabi=ilp32` flag.
We switch the use of int/long for int32_t/int64_t to avoid this problem
and show the requirement of a widening operation more clearly.
Normally we try to avoid pulling more headers than we need in the testsuite.

Have you seen this construct:

   typedef unsigned __attribute__((mode(DI))) uint64_t;

It can be a good way to ensure you have the right type for the patterns you
are adding.

Thanks,
James
Thanks! No I hadn't seen that construct before.
Have attached a patch using that construct.

Matthew
diff --git a/gcc/testsuite/gcc.target/aarch64/simd/vect_su_add_sub.c b/gcc/testsuite/gcc.target/aarch64/simd/vect_su_add_sub.c
index 338da54f6281c90e1c6b1c59fa50d9b719005c77..921c5f15c74ce02d106f9b5290244532fc56d480 100644
--- a/gcc/testsuite/gcc.target/aarch64/simd/vect_su_add_sub.c
+++ b/gcc/testsuite/gcc.target/aarch64/simd/vect_su_add_sub.c
@@ -1,21 +1,27 @@
 /* { dg-do compile } */
 /* { dg-options "-O3" } */
 
+typedef int __attribute__ ((mode (SI))) int32_t;
+typedef int __attribute__ ((mode (DI))) int64_t;
+typedef unsigned __attribute__ ((mode (SI))) size_t;
+typedef unsigned __attribute__ ((mode (SI))) uint32_t;
+typedef unsigned __attribute__ ((mode (DI))) uint64_t;
+
 /* Ensure we use the signed/unsigned extend vectorized add and sub
    instructions.  */
 #define N 1024
 
-int a[N];
-long c[N];
-long d[N];
-unsigned int ua[N];
-unsigned long uc[N];
-unsigned long ud[N];
+int32_t a[N];
+int64_t c[N];
+int64_t d[N];
+uint32_t ua[N];
+uint64_t uc[N];
+uint64_t ud[N];
 
 void
 add ()
 {
-  for (int i = 0; i < N; i++)
+  for (size_t i = 0; i < N; i++)
     d[i] = a[i] + c[i];
 }
 /* { dg-final { scan-assembler-times "\[ \t\]saddw2\[ \t\]+" 1 } } */
@@ -24,7 +30,7 @@ add ()
 void
 subtract ()
 {
-  for (int i = 0; i < N; i++)
+  for (size_t i = 0; i < N; i++)
     d[i] = c[i] - a[i];
 }
 /* { dg-final { scan-assembler-times "\[ \t\]ssubw2\[ \t\]+" 1 } } */
@@ -33,7 +39,7 @@ subtract ()
 void
 uadd ()
 {
-  for (int i = 0; i < N; i++)
+  for (size_t i = 0; i < N; i++)
     ud[i] = ua[i] + uc[i];
 }
 /* { dg-final { scan-assembler-times "\[ \t\]uaddw2\[ \t\]+" 1 } } */
@@ -42,7 +48,7 @@ uadd ()
 void
 usubtract ()
 {
-  for (int i = 0; i < N; i++)
+  for (size_t i = 0; i < N; i++)
     ud[i] = uc[i] - ua[i];
 }
 /* { dg-final { scan-assembler-times "\[ \t\]usubw2\[ \t\]+" 1 } } */

Reply via email to