testsuite: Fix up pr109011-*.c tests for powerpc [PR109572]

Message ID ZEOZPwDFcqYdSnaN@tucnak
State Unresolved
Headers
Series testsuite: Fix up pr109011-*.c tests for powerpc [PR109572] |

Checks

Context Check Description
snail/gcc-patch-check warning Git am fail log

Commit Message

Jakub Jelinek April 22, 2023, 8:22 a.m. UTC
  Hi!

As reported, pr109011-{4,5}.c tests fail on powerpc.
I thought they should have the same counts as the corresponding -{2,3}.c
tests, the only difference is that -{2,3}.c are int while -{4,5}.c are
long long.  But there are 2 issues.  One is that in the foo
function the vectorization costs comparison triggered in, while in -{2,3}.c
we use vectorization factor 4 and it was found beneficial, when using
long long it was just vf 2 and the scalar cost of doing
p[i] = __builtin_ctzll (q[i]) twice looked smaller than the vectorizated
statements.  I could disable the cost model, but instead chose to add
some further arithmetics to those functions to make it beneficial even
with vf 2.
After that change, pr109011-4.c still failed; I was expecting 4 .CTZ calls
there on power9, 3 vectorized and one in scalar code, but for some reason
the scalar one didn't trigger.  As I really want to count just the
vectorized calls, I've added the vect prefix on the variables to ensure
I'm only counting vectorized calls and decreased the 4 counts to 3.

With this, the tests pass on x86_64-linux, i686-linux, powerpc64le-linux
and powerpc64-linux (the last one -m32/-m64).  Ok for trunk?

2023-04-22  Jakub Jelinek  <jakub@redhat.com>

	PR testsuite/109572
	* gcc.dg/vect/pr109011-1.c: In scan-tree-dump-times regexps match also
	vect prefix to make sure we only count vectorized calls.
	* gcc.dg/vect/pr109011-2.c: Likewise.  On powerpc* expect just count 3
	rather than 4.
	* gcc.dg/vect/pr109011-3.c: In scan-tree-dump-times regexps match also
	vect prefix to make sure we only count vectorized calls.
	* gcc.dg/vect/pr109011-4.c: Likewise.  On powerpc* expect just count 3
	rather than 4.
	(foo): Add 2 further arithmetic ops to the loop to make it appear
	worthwhile for vectorization heuristics on powerpc.
	* gcc.dg/vect/pr109011-5.c: In scan-tree-dump-times regexps match also
	vect prefix to make sure we only count vectorized calls.
	(foo): Add 2 further arithmetic ops to the loop to make it appear
	worthwhile for vectorization heuristics on powerpc.


	Jakub
  

Comments

Richard Biener April 22, 2023, 5:38 p.m. UTC | #1
> Am 22.04.2023 um 10:23 schrieb Jakub Jelinek <jakub@redhat.com>:
> 
> Hi!
> 
> As reported, pr109011-{4,5}.c tests fail on powerpc.
> I thought they should have the same counts as the corresponding -{2,3}.c
> tests, the only difference is that -{2,3}.c are int while -{4,5}.c are
> long long.  But there are 2 issues.  One is that in the foo
> function the vectorization costs comparison triggered in, while in -{2,3}.c
> we use vectorization factor 4 and it was found beneficial, when using
> long long it was just vf 2 and the scalar cost of doing
> p[i] = __builtin_ctzll (q[i]) twice looked smaller than the vectorizated
> statements.  I could disable the cost model, but instead chose to add
> some further arithmetics to those functions to make it beneficial even
> with vf 2.
> After that change, pr109011-4.c still failed; I was expecting 4 .CTZ calls
> there on power9, 3 vectorized and one in scalar code, but for some reason
> the scalar one didn't trigger.  As I really want to count just the
> vectorized calls, I've added the vect prefix on the variables to ensure
> I'm only counting vectorized calls and decreased the 4 counts to 3.
> 
> With this, the tests pass on x86_64-linux, i686-linux, powerpc64le-linux
> and powerpc64-linux (the last one -m32/-m64).  Ok for trunk?

Ok


> 2023-04-22  Jakub Jelinek  <jakub@redhat.com>
> 
>    PR testsuite/109572
>    * gcc.dg/vect/pr109011-1.c: In scan-tree-dump-times regexps match also
>    vect prefix to make sure we only count vectorized calls.
>    * gcc.dg/vect/pr109011-2.c: Likewise.  On powerpc* expect just count 3
>    rather than 4.
>    * gcc.dg/vect/pr109011-3.c: In scan-tree-dump-times regexps match also
>    vect prefix to make sure we only count vectorized calls.
>    * gcc.dg/vect/pr109011-4.c: Likewise.  On powerpc* expect just count 3
>    rather than 4.
>    (foo): Add 2 further arithmetic ops to the loop to make it appear
>    worthwhile for vectorization heuristics on powerpc.
>    * gcc.dg/vect/pr109011-5.c: In scan-tree-dump-times regexps match also
>    vect prefix to make sure we only count vectorized calls.
>    (foo): Add 2 further arithmetic ops to the loop to make it appear
>    worthwhile for vectorization heuristics on powerpc.
> 
> --- gcc/testsuite/gcc.dg/vect/pr109011-1.c.jj    2023-04-20 16:30:21.684160677 +0200
> +++ gcc/testsuite/gcc.dg/vect/pr109011-1.c    2023-04-22 10:03:28.403367294 +0200
> @@ -14,8 +14,8 @@ foo (long long *p, long long *q)
>     p[i] = __builtin_popcountll (q[i]);
> }
> 
> -/* { dg-final { scan-tree-dump-times " = \.POPCOUNT \\\(" 1 "optimized" { target { { i?86-*-* x86_64-*-* } && avx512vpopcntdq } } } } */
> -/* { dg-final { scan-tree-dump-times " = \.POPCOUNT \\\(" 1 "optimized" { target { powerpc_p8vector_ok || s390_vx } } } } */
> +/* { dg-final { scan-tree-dump-times " = \.POPCOUNT \\\(vect" 1 "optimized" { target { { i?86-*-* x86_64-*-* } && avx512vpopcntdq } } } } */
> +/* { dg-final { scan-tree-dump-times " = \.POPCOUNT \\\(vect" 1 "optimized" { target { powerpc_p8vector_ok || s390_vx } } } } */
> 
> void
> bar (long long *p, long long *q)
> @@ -25,5 +25,5 @@ bar (long long *p, long long *q)
>     p[i] = __builtin_clzll (q[i]);
> }
> 
> -/* { dg-final { scan-tree-dump-times " = \.CLZ \\\(" 1 "optimized" { target { { i?86-*-* x86_64-*-* } && avx512cd } } } } */
> -/* { dg-final { scan-tree-dump-times " = \.CLZ \\\(" 1 "optimized" { target { powerpc_p8vector_ok || s390_vx } } } } */
> +/* { dg-final { scan-tree-dump-times " = \.CLZ \\\(vect" 1 "optimized" { target { { i?86-*-* x86_64-*-* } && avx512cd } } } } */
> +/* { dg-final { scan-tree-dump-times " = \.CLZ \\\(vect" 1 "optimized" { target { powerpc_p8vector_ok || s390_vx } } } } */
> --- gcc/testsuite/gcc.dg/vect/pr109011-2.c.jj    2023-04-20 16:30:21.684160677 +0200
> +++ gcc/testsuite/gcc.dg/vect/pr109011-2.c    2023-04-22 10:03:47.194092051 +0200
> @@ -29,7 +29,7 @@ baz (int *p, int *q)
>     p[i] = __builtin_ffs (q[i]);
> }
> 
> -/* { dg-final { scan-tree-dump-times " = \.CLZ \\\(" 3 "optimized" { target { { { { i?86-*-* x86_64-*-* } && avx512cd } && lzcnt } && bmi } } } } */
> -/* { dg-final { scan-tree-dump-times " = \.CTZ \\\(" 4 "optimized" { target powerpc_p9vector_ok } } } */
> -/* { dg-final { scan-tree-dump-times " = \.CTZ \\\(" 2 "optimized" { target s390_vx } } } */
> -/* { dg-final { scan-tree-dump-times " = \.POPCOUNT \\\(" 1 "optimized" { target s390_vx } } } */
> +/* { dg-final { scan-tree-dump-times " = \.CLZ \\\(vect" 3 "optimized" { target { { { { i?86-*-* x86_64-*-* } && avx512cd } && lzcnt } && bmi } } } } */
> +/* { dg-final { scan-tree-dump-times " = \.CTZ \\\(vect" 3 "optimized" { target powerpc_p9vector_ok } } } */
> +/* { dg-final { scan-tree-dump-times " = \.CTZ \\\(vect" 2 "optimized" { target s390_vx } } } */
> +/* { dg-final { scan-tree-dump-times " = \.POPCOUNT \\\(vect" 1 "optimized" { target s390_vx } } } */
> --- gcc/testsuite/gcc.dg/vect/pr109011-3.c.jj    2023-04-20 16:30:21.684160677 +0200
> +++ gcc/testsuite/gcc.dg/vect/pr109011-3.c    2023-04-22 10:04:00.481897412 +0200
> @@ -28,5 +28,5 @@ baz (int *p, int *q)
>     p[i] = __builtin_ffs (q[i]);
> }
> 
> -/* { dg-final { scan-tree-dump-times " = \.POPCOUNT \\\(" 3 "optimized" { target { { { { i?86-*-* x86_64-*-* } && avx512vpopcntdq } && lzcnt } && bmi } } } } */
> -/* { dg-final { scan-tree-dump-times " = \.CLZ \\\(" 3 "optimized" { target powerpc_p8vector_ok } } } */
> +/* { dg-final { scan-tree-dump-times " = \.POPCOUNT \\\(vect" 3 "optimized" { target { { { { i?86-*-* x86_64-*-* } && avx512vpopcntdq } && lzcnt } && bmi } } } } */
> +/* { dg-final { scan-tree-dump-times " = \.CLZ \\\(vect" 3 "optimized" { target powerpc_p8vector_ok } } } */
> --- gcc/testsuite/gcc.dg/vect/pr109011-4.c.jj    2023-04-20 16:30:21.684160677 +0200
> +++ gcc/testsuite/gcc.dg/vect/pr109011-4.c    2023-04-22 10:04:15.694674578 +0200
> @@ -10,7 +10,7 @@ foo (long long *p, long long *q)
> {
> #pragma omp simd
>   for (int i = 0; i < 2048; ++i)
> -    p[i] = __builtin_ctzll (q[i]);
> +    p[i] = 2 * q[i] + __builtin_ctzll (q[i]);
> }
> 
> void
> @@ -29,7 +29,7 @@ baz (long long *p, long long *q)
>     p[i] = __builtin_ffsll (q[i]);
> }
> 
> -/* { dg-final { scan-tree-dump-times " = \.CLZ \\\(" 3 "optimized" { target { { { { i?86-*-* x86_64-*-* } && avx512cd } && lzcnt } && bmi } } } } */
> -/* { dg-final { scan-tree-dump-times " = \.CTZ \\\(" 4 "optimized" { target powerpc_p9vector_ok } } } */
> -/* { dg-final { scan-tree-dump-times " = \.CTZ \\\(" 2 "optimized" { target s390_vx } } } */
> -/* { dg-final { scan-tree-dump-times " = \.POPCOUNT \\\(" 1 "optimized" { target s390_vx } } } */
> +/* { dg-final { scan-tree-dump-times " = \.CLZ \\\(vect" 3 "optimized" { target { { { { i?86-*-* x86_64-*-* } && avx512cd } && lzcnt } && bmi } } } } */
> +/* { dg-final { scan-tree-dump-times " = \.CTZ \\\(vect" 3 "optimized" { target powerpc_p9vector_ok } } } */
> +/* { dg-final { scan-tree-dump-times " = \.CTZ \\\(vect" 2 "optimized" { target s390_vx } } } */
> +/* { dg-final { scan-tree-dump-times " = \.POPCOUNT \\\(vect" 1 "optimized" { target s390_vx } } } */
> --- gcc/testsuite/gcc.dg/vect/pr109011-5.c.jj    2023-04-20 16:30:21.684160677 +0200
> +++ gcc/testsuite/gcc.dg/vect/pr109011-5.c    2023-04-22 10:04:28.351489185 +0200
> @@ -9,7 +9,7 @@ foo (long long *p, long long *q)
> {
> #pragma omp simd
>   for (int i = 0; i < 2048; ++i)
> -    p[i] = __builtin_ctzll (q[i]);
> +    p[i] = 2 * q[i] + __builtin_ctzll (q[i]);
> }
> 
> void
> @@ -28,5 +28,5 @@ baz (long long *p, long long *q)
>     p[i] = __builtin_ffsll (q[i]);
> }
> 
> -/* { dg-final { scan-tree-dump-times " = \.POPCOUNT \\\(" 3 "optimized" { target { { { { i?86-*-* x86_64-*-* } && avx512vpopcntdq } && lzcnt } && bmi } } } } */
> -/* { dg-final { scan-tree-dump-times " = \.CLZ \\\(" 3 "optimized" { target powerpc_p8vector_ok } } } */
> +/* { dg-final { scan-tree-dump-times " = \.POPCOUNT \\\(vect" 3 "optimized" { target { { { { i?86-*-* x86_64-*-* } && avx512vpopcntdq } && lzcnt } && bmi } } } } */
> +/* { dg-final { scan-tree-dump-times " = \.CLZ \\\(vect" 3 "optimized" { target powerpc_p8vector_ok } } } */
> 
>    Jakub
>
  

Patch

--- gcc/testsuite/gcc.dg/vect/pr109011-1.c.jj	2023-04-20 16:30:21.684160677 +0200
+++ gcc/testsuite/gcc.dg/vect/pr109011-1.c	2023-04-22 10:03:28.403367294 +0200
@@ -14,8 +14,8 @@  foo (long long *p, long long *q)
     p[i] = __builtin_popcountll (q[i]);
 }
 
-/* { dg-final { scan-tree-dump-times " = \.POPCOUNT \\\(" 1 "optimized" { target { { i?86-*-* x86_64-*-* } && avx512vpopcntdq } } } } */
-/* { dg-final { scan-tree-dump-times " = \.POPCOUNT \\\(" 1 "optimized" { target { powerpc_p8vector_ok || s390_vx } } } } */
+/* { dg-final { scan-tree-dump-times " = \.POPCOUNT \\\(vect" 1 "optimized" { target { { i?86-*-* x86_64-*-* } && avx512vpopcntdq } } } } */
+/* { dg-final { scan-tree-dump-times " = \.POPCOUNT \\\(vect" 1 "optimized" { target { powerpc_p8vector_ok || s390_vx } } } } */
 
 void
 bar (long long *p, long long *q)
@@ -25,5 +25,5 @@  bar (long long *p, long long *q)
     p[i] = __builtin_clzll (q[i]);
 }
 
-/* { dg-final { scan-tree-dump-times " = \.CLZ \\\(" 1 "optimized" { target { { i?86-*-* x86_64-*-* } && avx512cd } } } } */
-/* { dg-final { scan-tree-dump-times " = \.CLZ \\\(" 1 "optimized" { target { powerpc_p8vector_ok || s390_vx } } } } */
+/* { dg-final { scan-tree-dump-times " = \.CLZ \\\(vect" 1 "optimized" { target { { i?86-*-* x86_64-*-* } && avx512cd } } } } */
+/* { dg-final { scan-tree-dump-times " = \.CLZ \\\(vect" 1 "optimized" { target { powerpc_p8vector_ok || s390_vx } } } } */
--- gcc/testsuite/gcc.dg/vect/pr109011-2.c.jj	2023-04-20 16:30:21.684160677 +0200
+++ gcc/testsuite/gcc.dg/vect/pr109011-2.c	2023-04-22 10:03:47.194092051 +0200
@@ -29,7 +29,7 @@  baz (int *p, int *q)
     p[i] = __builtin_ffs (q[i]);
 }
 
-/* { dg-final { scan-tree-dump-times " = \.CLZ \\\(" 3 "optimized" { target { { { { i?86-*-* x86_64-*-* } && avx512cd } && lzcnt } && bmi } } } } */
-/* { dg-final { scan-tree-dump-times " = \.CTZ \\\(" 4 "optimized" { target powerpc_p9vector_ok } } } */
-/* { dg-final { scan-tree-dump-times " = \.CTZ \\\(" 2 "optimized" { target s390_vx } } } */
-/* { dg-final { scan-tree-dump-times " = \.POPCOUNT \\\(" 1 "optimized" { target s390_vx } } } */
+/* { dg-final { scan-tree-dump-times " = \.CLZ \\\(vect" 3 "optimized" { target { { { { i?86-*-* x86_64-*-* } && avx512cd } && lzcnt } && bmi } } } } */
+/* { dg-final { scan-tree-dump-times " = \.CTZ \\\(vect" 3 "optimized" { target powerpc_p9vector_ok } } } */
+/* { dg-final { scan-tree-dump-times " = \.CTZ \\\(vect" 2 "optimized" { target s390_vx } } } */
+/* { dg-final { scan-tree-dump-times " = \.POPCOUNT \\\(vect" 1 "optimized" { target s390_vx } } } */
--- gcc/testsuite/gcc.dg/vect/pr109011-3.c.jj	2023-04-20 16:30:21.684160677 +0200
+++ gcc/testsuite/gcc.dg/vect/pr109011-3.c	2023-04-22 10:04:00.481897412 +0200
@@ -28,5 +28,5 @@  baz (int *p, int *q)
     p[i] = __builtin_ffs (q[i]);
 }
 
-/* { dg-final { scan-tree-dump-times " = \.POPCOUNT \\\(" 3 "optimized" { target { { { { i?86-*-* x86_64-*-* } && avx512vpopcntdq } && lzcnt } && bmi } } } } */
-/* { dg-final { scan-tree-dump-times " = \.CLZ \\\(" 3 "optimized" { target powerpc_p8vector_ok } } } */
+/* { dg-final { scan-tree-dump-times " = \.POPCOUNT \\\(vect" 3 "optimized" { target { { { { i?86-*-* x86_64-*-* } && avx512vpopcntdq } && lzcnt } && bmi } } } } */
+/* { dg-final { scan-tree-dump-times " = \.CLZ \\\(vect" 3 "optimized" { target powerpc_p8vector_ok } } } */
--- gcc/testsuite/gcc.dg/vect/pr109011-4.c.jj	2023-04-20 16:30:21.684160677 +0200
+++ gcc/testsuite/gcc.dg/vect/pr109011-4.c	2023-04-22 10:04:15.694674578 +0200
@@ -10,7 +10,7 @@  foo (long long *p, long long *q)
 {
 #pragma omp simd
   for (int i = 0; i < 2048; ++i)
-    p[i] = __builtin_ctzll (q[i]);
+    p[i] = 2 * q[i] + __builtin_ctzll (q[i]);
 }
 
 void
@@ -29,7 +29,7 @@  baz (long long *p, long long *q)
     p[i] = __builtin_ffsll (q[i]);
 }
 
-/* { dg-final { scan-tree-dump-times " = \.CLZ \\\(" 3 "optimized" { target { { { { i?86-*-* x86_64-*-* } && avx512cd } && lzcnt } && bmi } } } } */
-/* { dg-final { scan-tree-dump-times " = \.CTZ \\\(" 4 "optimized" { target powerpc_p9vector_ok } } } */
-/* { dg-final { scan-tree-dump-times " = \.CTZ \\\(" 2 "optimized" { target s390_vx } } } */
-/* { dg-final { scan-tree-dump-times " = \.POPCOUNT \\\(" 1 "optimized" { target s390_vx } } } */
+/* { dg-final { scan-tree-dump-times " = \.CLZ \\\(vect" 3 "optimized" { target { { { { i?86-*-* x86_64-*-* } && avx512cd } && lzcnt } && bmi } } } } */
+/* { dg-final { scan-tree-dump-times " = \.CTZ \\\(vect" 3 "optimized" { target powerpc_p9vector_ok } } } */
+/* { dg-final { scan-tree-dump-times " = \.CTZ \\\(vect" 2 "optimized" { target s390_vx } } } */
+/* { dg-final { scan-tree-dump-times " = \.POPCOUNT \\\(vect" 1 "optimized" { target s390_vx } } } */
--- gcc/testsuite/gcc.dg/vect/pr109011-5.c.jj	2023-04-20 16:30:21.684160677 +0200
+++ gcc/testsuite/gcc.dg/vect/pr109011-5.c	2023-04-22 10:04:28.351489185 +0200
@@ -9,7 +9,7 @@  foo (long long *p, long long *q)
 {
 #pragma omp simd
   for (int i = 0; i < 2048; ++i)
-    p[i] = __builtin_ctzll (q[i]);
+    p[i] = 2 * q[i] + __builtin_ctzll (q[i]);
 }
 
 void
@@ -28,5 +28,5 @@  baz (long long *p, long long *q)
     p[i] = __builtin_ffsll (q[i]);
 }
 
-/* { dg-final { scan-tree-dump-times " = \.POPCOUNT \\\(" 3 "optimized" { target { { { { i?86-*-* x86_64-*-* } && avx512vpopcntdq } && lzcnt } && bmi } } } } */
-/* { dg-final { scan-tree-dump-times " = \.CLZ \\\(" 3 "optimized" { target powerpc_p8vector_ok } } } */
+/* { dg-final { scan-tree-dump-times " = \.POPCOUNT \\\(vect" 3 "optimized" { target { { { { i?86-*-* x86_64-*-* } && avx512vpopcntdq } && lzcnt } && bmi } } } } */
+/* { dg-final { scan-tree-dump-times " = \.CLZ \\\(vect" 3 "optimized" { target powerpc_p8vector_ok } } } */