diff mbox

[rs6000] Add testcases for vec_cnttz

Message ID 1500063632.474.34.camel@us.ibm.com
State New
Headers show

Commit Message

Carl Love July 14, 2017, 8:20 p.m. UTC
GCC Maintainers:

The following patch add testcases and documentation for the 

-------------------------------------------------------

gcc/ChangeLog:

2017-07-14  Carl Love  <cel@us.ibm.com>

	* doc/extend.texi: Update the built-in documentation file for the
	existing built-in functions
	vector signed char vec_cnttz (vector signed char);
	vector unsigned char vec_cnttz (vector unsigned char);
	vector signed short vec_cnttz (vector signed short);
	vector unsigned short vec_cnttz (vector unsigned short);
	vector signed int vec_cnttz (vector signed int);
	vector unsigned int vec_cnttz (vector unsigned int);
	vector signed long long vec_cnttz (vector signed long long);
	vector unsigned long long vec_cnttz (vector unsigned long long);

gcc/testsuite/ChangeLog:

2017-07-14  Carl Love  <cel@us.ibm.com>

	* gcc.target/powerpc/builtins-4-9-runable.c:  Add test file for
	vec_cnttz builtins.
---
 gcc/doc/extend.texi                                |  9 ++
 .../gcc.target/powerpc/builtins-4-p9-runnable.c    | 95 ++++++++++++++++++++++
 2 files changed, 104 insertions(+)
 create mode 100644 gcc/testsuite/gcc.target/powerpc/builtins-4-p9-runnable.c

Comments

Segher Boessenkool July 14, 2017, 8:58 p.m. UTC | #1
Hi Carl,

On Fri, Jul 14, 2017 at 01:20:32PM -0700, Carl Love wrote:
> --- /dev/null
> +++ b/gcc/testsuite/gcc.target/powerpc/builtins-4-p9-runnable.c
> @@ -0,0 +1,95 @@
> +/* { dg-do run { target { powerpc64*-*-* && { lp64 && p9vector_hw } } } } */

powerpc*-*-* instead.

> +/* { dg-skip-if "do not override -mcpu" { powerpc*-*-* } { "-mcpu=*" } { "-mcpu=power9" } } */
> +/* { dg-options "-mcpu=power9 -O2 -mupper-regs-di" } */

Does this need to be restricted to 64-bit?  Please test.

Okay modulo those nits, thanks!


Segher
Carl Love July 24, 2017, 8:51 p.m. UTC | #2
On Fri, 2017-07-14 at 15:58 -0500, Segher Boessenkool wrote:
> Hi Carl,
> 
> On Fri, Jul 14, 2017 at 01:20:32PM -0700, Carl Love wrote:
> > --- /dev/null
> > +++ b/gcc/testsuite/gcc.target/powerpc/builtins-4-p9-runnable.c
> > @@ -0,0 +1,95 @@
> > +/* { dg-do run { target { powerpc64*-*-* && { lp64 && p9vector_hw } } } } */
> 
> powerpc*-*-* instead.
> 
> > +/* { dg-skip-if "do not override -mcpu" { powerpc*-*-* } { "-mcpu=*" } { "-mcpu=power9" } } */
> > +/* { dg-options "-mcpu=power9 -O2 -mupper-regs-di" } */
> 
> Does this need to be restricted to 64-bit?  Please test.

Segher:

I tested with the command:

make -k check-gcc RUNTESTFLAGS="powerpc.exp=builtins-4-p9-runnable.c
--target_board=unix'{-m64,-m32}' " > out



The test passed for -m64 and failed on -m32

Test run by carll on Mon Jul 24 15:44:47 2017
Native configuration is powerpc64le-unknown-linux-gnu

		=== gcc tests ===

Schedule of variations:
    unix/-m64
    unix/-m32

Running target unix/-m64
Using /usr/share/dejagnu/baseboards/unix.exp as board description file for targe
t.
Using /usr/share/dejagnu/config/unix.exp as generic interface file for target.
Using /home/carll/GCC/gcc-patch-testing/gcc/testsuite/config/default.exp as tool
-and-target-specific interface file.
Running /home/carll/GCC/gcc-patch-testing/gcc/testsuite/gcc.target/powerpc/power
pc.exp ...

		=== gcc Summary for unix/-m64 ===

# of expected passes		2
Running target unix/-m32
Using /usr/share/dejagnu/baseboards/unix.exp as board description file for targe
t.
Using /usr/share/dejagnu/config/unix.exp as generic interface file for target.
Using /home/carll/GCC/gcc-patch-testing/gcc/testsuite/config/default.exp as tool
-and-target-specific interface file.
Running /home/carll/GCC/gcc-patch-testing/gcc/testsuite/gcc.target/powerpc/power
pc.exp ...

		=== gcc Summary for unix/-m32 ===

# of unsupported tests		1

		=== gcc Summary ===

# of expected passes		2
# of unsupported tests		1

So, I think we need to leave it as: powerpc64*-*-*

/* { dg-do run { target { powerpc64*-*-* && { lp64 && p9vector_hw } } } } */

Do you agree?

                Carl Love
Segher Boessenkool July 25, 2017, 11:19 a.m. UTC | #3
Hi!

On Mon, Jul 24, 2017 at 01:51:20PM -0700, Carl Love wrote:
> On Fri, 2017-07-14 at 15:58 -0500, Segher Boessenkool wrote:
> > On Fri, Jul 14, 2017 at 01:20:32PM -0700, Carl Love wrote:
> > > --- /dev/null
> > > +++ b/gcc/testsuite/gcc.target/powerpc/builtins-4-p9-runnable.c
> > > @@ -0,0 +1,95 @@
> > > +/* { dg-do run { target { powerpc64*-*-* && { lp64 && p9vector_hw } } } } */
> > 
> > powerpc*-*-* instead.
> > 
> > > +/* { dg-skip-if "do not override -mcpu" { powerpc*-*-* } { "-mcpu=*" } { "-mcpu=power9" } } */
> > > +/* { dg-options "-mcpu=power9 -O2 -mupper-regs-di" } */
> > 
> > Does this need to be restricted to 64-bit?  Please test.

I mean: do you need the "lp64".  So, does

/* { dg-do run { target { powerpc*-*-* && { p9vector_hw } } } } */

work?

> The test passed for -m64 and failed on -m32

> 		=== gcc Summary for unix/-m32 ===
> 
> # of unsupported tests		1

That's not a fail.  But why is it unsupported?  Did you leave in
powerpc64*-*-*?  Or maybe it is the -mupper-regs-di?  That option is
has been deleted now btw.


Segher
Carl Love July 25, 2017, 4:53 p.m. UTC | #4
On Tue, 2017-07-25 at 06:19 -0500, Segher Boessenkool wrote:
> Hi!
> 
> On Mon, Jul 24, 2017 at 01:51:20PM -0700, Carl Love wrote:
> > On Fri, 2017-07-14 at 15:58 -0500, Segher Boessenkool wrote:
> > > On Fri, Jul 14, 2017 at 01:20:32PM -0700, Carl Love wrote:
> > > > --- /dev/null
> > > > +++ b/gcc/testsuite/gcc.target/powerpc/builtins-4-p9-runnable.c
> > > > @@ -0,0 +1,95 @@
> > > > +/* { dg-do run { target { powerpc64*-*-* && { lp64 && p9vector_hw } } } } */
> > > 
> > > powerpc*-*-* instead.
> > > 
> > > > +/* { dg-skip-if "do not override -mcpu" { powerpc*-*-* } { "-mcpu=*" } { "-mcpu=power9" } } */
> > > > +/* { dg-options "-mcpu=power9 -O2 -mupper-regs-di" } */
> > > 
> > > Does this need to be restricted to 64-bit?  Please test.
> 
> I mean: do you need the "lp64".  So, does
> 
> /* { dg-do run { target { powerpc*-*-* && { p9vector_hw } } } } */
> 
> work?

/* { dg-do run { target { powerpc*-*-* && { p9vector_hw } } } } */
/* { dg-skip-if "do not override -mcpu" { powerpc*-*-* } { "-mcpu=*" } { "-mcpu=power9" } } */
/* { dg-options "-mcpu=power9 -O2 -mupper-regs-di" } */

m64  2 test passes
m32  1 unsupported test

I looked in gcc/testsuite/gcc/gcc.log and found the following message
about the -m32

cc1: error: -m32 not supported in this configuration^M
compiler exited with status 1
testcase /home/carll/GCC/gcc-patch-testing/gcc/testsuite/gcc.target/powerpc/pow\
erpc.exp completed in 1 seconds

                === gcc Summary for unix/-m32 ===

# of unsupported tests          1

                === gcc Summary ===

# of expected passes            2
# of unsupported tests          1

> Or maybe it is the -mupper-regs-di?  That option is
> has been deleted now btw.
> 

So, next I tried removing the -mupper-regs-di option.

/* { dg-do run { target { powerpc*-*-* && { p9vector_hw } } } } */
/* { dg-skip-if "do not override -mcpu" { powerpc*-*-* } { "-mcpu=*" } { "-mcpu=power9" } } */
/* { dg-options "-mcpu=power9 -O2 " } */

With the same results as above.  Note, I am running on perch.aus.stglabs.ibm.com which 
is a Power 9 system.  Is -m32 not supported on Power 9?

So it looks like we do not need the lp64 or -mupper-regs-di options as we get the same results
either way.  

              Carl
Peter Bergner July 25, 2017, 5:21 p.m. UTC | #5
On 7/25/17 11:53 AM, Carl Love wrote:
> /* { dg-do run { target { powerpc*-*-* && { p9vector_hw } } } } */
> /* { dg-skip-if "do not override -mcpu" { powerpc*-*-* } { "-mcpu=*" } { "-mcpu=power9" } } */
> /* { dg-options "-mcpu=power9 -O2 " } */
> 
> With the same results as above.  Note, I am running on perch.aus.stglabs.ibm.com which 
> is a Power 9 system.  Is -m32 not supported on Power 9?

-m32 is supported on POWER9, it's only not supported on little endian.

Peter
Segher Boessenkool July 25, 2017, 10:52 p.m. UTC | #6
On Tue, Jul 25, 2017 at 09:53:21AM -0700, Carl Love wrote:
> /* { dg-do run { target { powerpc*-*-* && { p9vector_hw } } } } */
> /* { dg-skip-if "do not override -mcpu" { powerpc*-*-* } { "-mcpu=*" } { "-mcpu=power9" } } */
> /* { dg-options "-mcpu=power9 -O2 -mupper-regs-di" } */
> 
> m64  2 test passes
> m32  1 unsupported test
> 
> I looked in gcc/testsuite/gcc/gcc.log and found the following message
> about the -m32
> 
> cc1: error: -m32 not supported in this configuration^M

Ah, heh.  You are testing -m32 on a powerpc64le system.  That won't fly.

If you remove the -mupper-regs-di from the above, it is okay to commit
like that.  Thanks!


Segher
diff mbox

Patch

diff --git a/gcc/doc/extend.texi b/gcc/doc/extend.texi
index 0135fc7..8df5498 100644
--- a/gcc/doc/extend.texi
+++ b/gcc/doc/extend.texi
@@ -15384,6 +15384,15 @@  vector bool short vec_cmpnez (vector unsigned short arg1, vector unsigned short
 vector bool int vec_cmpnez (vector signed int arg1, vector signed int arg2);
 vector bool int vec_cmpnez (vector unsigned int, vector unsigned int);
 
+vector signed char vec_cnttz (vector signed char);
+vector unsigned char vec_cnttz (vector unsigned char);
+vector signed short vec_cnttz (vector signed short);
+vector unsigned short vec_cnttz (vector unsigned short);
+vector signed int vec_cnttz (vector signed int);
+vector unsigned int vec_cnttz (vector unsigned int);
+vector signed long long vec_cnttz (vector signed long long);
+vector unsigned long long vec_cnttz (vector unsigned long long);
+
 signed int vec_cntlz_lsbb (vector signed char);
 signed int vec_cntlz_lsbb (vector unsigned char);
 
diff --git a/gcc/testsuite/gcc.target/powerpc/builtins-4-p9-runnable.c b/gcc/testsuite/gcc.target/powerpc/builtins-4-p9-runnable.c
new file mode 100644
index 0000000..79fbaa8
--- /dev/null
+++ b/gcc/testsuite/gcc.target/powerpc/builtins-4-p9-runnable.c
@@ -0,0 +1,95 @@ 
+/* { dg-do run { target { powerpc64*-*-* && { lp64 && p9vector_hw } } } } */
+/* { dg-skip-if "do not override -mcpu" { powerpc*-*-* } { "-mcpu=*" } { "-mcpu=power9" } } */
+/* { dg-options "-mcpu=power9 -O2 -mupper-regs-di" } */
+
+#include <altivec.h> // vector
+
+void abort (void);
+
+int main() {
+  int i;
+
+  vector signed char vsca, vscr, vscexpt;
+  vector unsigned char vuca, vucr, vucexpt;
+  vector signed short int vssa, vssr, vssexpt;
+  vector unsigned short int vusa, vusr, vusexpt;
+  vector signed int vsia, vsir, vsiexpt;
+  vector unsigned int vuia, vuir, vuiexpt;
+  vector signed long long vslla, vsllr, vsllexpt;
+  vector unsigned long long vulla, vullr, vullexpt;
+
+  vsca = (vector signed char) {0, 1, 2, 3, 4, 5, 6, 7,
+			       8, 9, 10, 11, 12, 13, 14, 15};
+
+  vscexpt = (vector signed char) {8, 0, 1, 0, 2, 0, 1, 0,
+				  3, 0, 1, 0, 2, 0, 1, 0};
+
+  vuca = (vector unsigned char) {'0', '3', '6', '9', 'A', 'B', 'E', 'F',
+				 'G', 'H', 'I', 'J', 'K', 'L', 'M', 'N'};
+											
+  vucexpt = (vector unsigned char) {4, 0, 1, 0, 0, 1, 0, 1,
+				    0, 3, 0, 1, 0, 2, 0, 1};
+
+  vssa = (vector short int) {0x1, 0x10, 0x100, 0x1000,
+			     0x2, 0x20, 0x200, 0x2000};
+
+  vssexpt = (vector short int) {0, 4, 8, 12, 1, 5, 9, 13};
+
+  vusa = (vector unsigned short int) {0x4, 0x40, 0x400, 0x4000,
+				      0x8, 0x80, 0x800, 0x8000};
+  vusexpt = (vector unsigned short int) {2, 6, 10, 14, 3, 7, 11, 15};
+
+  vsia = (vector int) {0x10000, 0x100000, 0x1000000, 0x10000000};
+  vsiexpt = (vector int){16, 20, 24, 28};
+
+  vuia = (vector unsigned int) {0x2, 0x20, 0x200, 0x2000};
+  vuiexpt = (vector unsigned int){1, 5, 9, 13};
+
+  vslla = (vector long long) {0x0000000000010000LL, 0x0001000100010000LL};
+  vsllexpt = (vector long long){16, 16};
+
+  vulla = (vector unsigned long long) {0x0000400000000000LL, 0x0080000000000000ULL};
+
+  vullexpt = (vector unsigned long long) {46, 55};
+
+  vscr = vec_cnttz (vsca);
+  vucr = vec_cnttz (vuca);
+  vssr = vec_cnttz (vssa);
+  vusr = vec_cnttz (vusa);
+  vsir = vec_cnttz (vsia);
+  vuir = vec_cnttz (vuia);
+  vsllr = vec_cnttz (vslla);
+  vullr = vec_cnttz (vulla);
+
+  for (i=0; i<16; i++) {
+    if (vscr[i] != vscexpt[i])
+      abort();
+
+    if (vucr[i] != vucexpt[i])
+      abort();
+  }
+
+  for (i=0; i<8; i++) {
+    if (vssr[i] != vssexpt[i])
+      abort();
+
+    if (vusr[i] != vusexpt[i])
+      abort();
+  }
+
+  for (i=0; i<4; i++) {
+    if (vsir[i] != vsiexpt[i])
+      abort();
+
+    if (vuir[i] != vuiexpt[i])
+      abort();
+  }
+
+  for (i=0; i<2; i++) {
+    if (vsllr[i] != vsllexpt[i])
+      abort();
+
+    if (vullr[i] != vullexpt[i])
+      abort();
+  }	
+}