public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
* [PATCH, rs6000]  Fix vec_mulo and vec_mule builtin implementations
@ 2017-06-06 22:55 Carl E. Love
  2017-06-07 21:16 ` Segher Boessenkool
  0 siblings, 1 reply; 2+ messages in thread
From: Carl E. Love @ 2017-06-06 22:55 UTC (permalink / raw)
  To: gcc-patches, David Edelsohn, Segher Boessenkool; +Cc: Bill Schmidt, cel

GCC Maintainers:

The support for the vec_mulo and vec_mule that was recently submitted
has a couple of bugs.  Specifically, they were implemented with
int/unsigned int args and return int/unsigned int.  The return types
should have been long long/unsigned long long.  Additionally it was
noted that unsigned version returned a signed version by mistake.  

The following patch fixes these issues.  The patch has been tested on
powerpc64le-unknown-linux-gnu (Power 8 LE) and on
powerpc64-unknown-linux-gnu (Power 8 BE) with no regressions.

Is the patch OK for gcc mainline?

                  Carl Love
-----------------------------------------------------------------------

gcc/ChangeLog:

2017-06-08  Carl Love  <cel@us.ibm.com>

	* config/rs6000/rs6000-c: The return type of the following
	built-in functions was implemented as int not long long.  Fix sign
	of return value for the unsigned version of vec_mulo and vec_mule.
	vector unsigned long long vec_bperm (vector unsigned long long,
	                                     vector unsigned char)
	vector signed long long vec_mule (vector signed int,
	                                  vector signed int)
	vector unsigned long long vec_mule (vector unsigned int,
	                                    vector unsigned int)
	vector signed long long vec_mulo (vector signed int,
	                                  vector signed int)
	vector unsigned long long vec_mulo (vector unsigned int,
	                                    vector unsigned int)
	* doc/extend.texi: Fix the documentation for the
	built-in functions.

gcc/testsuite/ChangeLog:

2017-06-08  Carl Love  <cel@us.ibm.com>

	* gcc.target/powerpc/builtins-3.c: Fix vec_mule, vec_mulo test cases.
---
 gcc/config/rs6000/rs6000-c.c                  | 12 +++++------
 gcc/doc/extend.texi                           | 13 +++++++-----
 gcc/testsuite/gcc.target/powerpc/builtins-3.c | 30 ++++++++++++++-------------
 3 files changed, 30 insertions(+), 25 deletions(-)

diff --git a/gcc/config/rs6000/rs6000-c.c b/gcc/config/rs6000/rs6000-c.c
index b602dee..a917ea7 100644
--- a/gcc/config/rs6000/rs6000-c.c
+++ b/gcc/config/rs6000/rs6000-c.c
@@ -2212,9 +2212,9 @@ const struct altivec_builtin_types altivec_overloaded_builtins[] = {
   { ALTIVEC_BUILTIN_VEC_MULE, ALTIVEC_BUILTIN_VMULESH,
     RS6000_BTI_V4SI, RS6000_BTI_V8HI, RS6000_BTI_V8HI, 0 },
   { ALTIVEC_BUILTIN_VEC_MULE, ALTIVEC_BUILTIN_VMULESH,
-    RS6000_BTI_V4SI, RS6000_BTI_V4SI, RS6000_BTI_V4SI, 0 },
-  { ALTIVEC_BUILTIN_VEC_MULE, ALTIVEC_BUILTIN_VMULESH,
-    RS6000_BTI_unsigned_V4SI, RS6000_BTI_unsigned_V4SI,
+    RS6000_BTI_V2DI, RS6000_BTI_V4SI, RS6000_BTI_V4SI, 0 },
+  { ALTIVEC_BUILTIN_VEC_MULE, ALTIVEC_BUILTIN_VMULEUH,
+    RS6000_BTI_unsigned_V2DI, RS6000_BTI_unsigned_V4SI,
     RS6000_BTI_unsigned_V4SI, 0 },
   { ALTIVEC_BUILTIN_VEC_VMULEUB, ALTIVEC_BUILTIN_VMULEUB,
     RS6000_BTI_unsigned_V8HI, RS6000_BTI_unsigned_V16QI, RS6000_BTI_unsigned_V16QI, 0 },
@@ -2231,9 +2231,9 @@ const struct altivec_builtin_types altivec_overloaded_builtins[] = {
   { ALTIVEC_BUILTIN_VEC_MULO, ALTIVEC_BUILTIN_VMULOUH,
     RS6000_BTI_unsigned_V4SI, RS6000_BTI_unsigned_V8HI, RS6000_BTI_unsigned_V8HI, 0 },
   { ALTIVEC_BUILTIN_VEC_MULO, ALTIVEC_BUILTIN_VMULOSH,
-    RS6000_BTI_V4SI, RS6000_BTI_V4SI, RS6000_BTI_V4SI, 0 },
-  { ALTIVEC_BUILTIN_VEC_MULO, ALTIVEC_BUILTIN_VMULOSH,
-    RS6000_BTI_unsigned_V4SI, RS6000_BTI_unsigned_V4SI,
+    RS6000_BTI_V2DI, RS6000_BTI_V4SI, RS6000_BTI_V4SI, 0 },
+  { ALTIVEC_BUILTIN_VEC_MULO, ALTIVEC_BUILTIN_VMULOUH,
+    RS6000_BTI_unsigned_V2DI, RS6000_BTI_unsigned_V4SI,
     RS6000_BTI_unsigned_V4SI, 0 },
   { ALTIVEC_BUILTIN_VEC_MULO, ALTIVEC_BUILTIN_VMULOSH,
     RS6000_BTI_V4SI, RS6000_BTI_V8HI, RS6000_BTI_V8HI, 0 },
diff --git a/gcc/doc/extend.texi b/gcc/doc/extend.texi
index d147d5a..d467a16 100644
--- a/gcc/doc/extend.texi
+++ b/gcc/doc/extend.texi
@@ -16345,10 +16345,10 @@ vector signed short vec_mule (vector signed char,
 vector unsigned int vec_mule (vector unsigned short,
                               vector unsigned short);
 vector signed int vec_mule (vector signed short, vector signed short);
-vector unsigned int vec_mule (vector unsigned int,
-                              vector unsigned int);
-vector signed int vec_mule (vector signed int,
-                            vector signed int);
+vector unsigned long long vec_mule (vector unsigned int,
+                                    vector unsigned int);
+vector signed long long vec_mule (vector signed int,
+                                  vector signed int);
 
 vector signed int vec_vmulesh (vector signed short,
                                vector signed short);
@@ -16368,7 +16368,10 @@ vector signed short vec_mulo (vector signed char, vector signed char);
 vector unsigned int vec_mulo (vector unsigned short,
                               vector unsigned short);
 vector signed int vec_mulo (vector signed short, vector signed short);
-vector unsigned int vec_mulo (vector unsigned short, vector unsigned short);
+vector unsigned long long vec_mulo (vector unsigned int,
+                                    vector unsigned int);
+vector signed long long vec_mulo (vector signed int,
+                                  vector signed int);
 
 vector signed int vec_vmulosh (vector signed short,
                                vector signed short);
diff --git a/gcc/testsuite/gcc.target/powerpc/builtins-3.c b/gcc/testsuite/gcc.target/powerpc/builtins-3.c
index 5cbac81..b252488 100644
--- a/gcc/testsuite/gcc.target/powerpc/builtins-3.c
+++ b/gcc/testsuite/gcc.target/powerpc/builtins-3.c
@@ -112,26 +112,26 @@ test_vull_slo_vull_vuc (vector unsigned long long x, vector unsigned char y)
 	return vec_slo (x, y);
 }
 
-vector signed int
-test_vsi_mule_vsi_vsi (vector signed int x, vector signed int y)
+vector signed long long
+test_vsll_mule_vsi_vsi (vector signed int x, vector signed int y)
 {
 	return vec_mule (x, y);
 }
 
-vector unsigned int
-test_vui_mule_vui_vui (vector unsigned int x, vector unsigned int y)
+vector unsigned long long
+test_vull_mule_vui_vui (vector unsigned int x, vector unsigned int y)
 {
 	return vec_mule (x, y);
 }
 
-vector signed int
-test_vsi_mulo_vsi_vsi (vector signed int x, vector signed int y)
+vector signed long long
+test_vsll_mulo_vsi_vsi (vector signed int x, vector signed int y)
 {
 	return vec_mulo (x, y);
 }
 
-vector unsigned int
-test_vui_mulo_vui_vui (vector unsigned int x, vector unsigned int y)
+vector unsigned long long
+test_vull_mulo_vui_vui (vector unsigned int x, vector unsigned int y)
 {
 	return vec_mulo (x, y);
 }
@@ -207,10 +207,10 @@ test_vul_sldw_vul_vul (vector unsigned long long x,
      test_vsll_slo_vsll_vuc    1 vslo
      test_vull_slo_vsll_vsc    1 vslo
      test_vull_slo_vsll_vuc    1 vslo
-     test_vsi_mulo_vsi_vsi     1 vmulosh
-     test_vui_mulo_vui_vui     1 vmulosh
-     test_vsi_mule_vsi_vsi     1 vmulesh
-     test_vui_mule_vui_vui     1 vmulesh
+     test_vsll_mulo_vsi_vsi    1 vmulosh
+     test_vull_mulo_vui_vui    1 vmulouh
+     test_vsll_mule_vsi_vsi    1 vmulesh
+     test_vull_mule_vui_vui    1 vmuleuh
      test_vsc_mulo_vsc_vsc     1 xxsldwi
      test_vuc_mulo_vuc_vuc     1 xxsldwi
      test_vssi_mulo_vssi_vssi  1 xxsldwi
@@ -236,6 +236,8 @@ test_vul_sldw_vul_vul (vector unsigned long long x,
 /* { dg-final { scan-assembler-times "xvnegsp"  1 } } */
 /* { dg-final { scan-assembler-times "xvnegdp"  1 } } */
 /* { dg-final { scan-assembler-times "vslo"     4 } } */
-/* { dg-final { scan-assembler-times "vmulosh"  2 } } */
-/* { dg-final { scan-assembler-times "vmulesh"  2 } } */
+/* { dg-final { scan-assembler-times "vmulosh"  1 } } */
+/* { dg-final { scan-assembler-times "vmulouh"  1 } } */
+/* { dg-final { scan-assembler-times "vmulesh"  1 } } */
+/* { dg-final { scan-assembler-times "vmuleuh"  1 } } */
 /* { dg-final { scan-assembler-times "xxsldwi"  8 } } */
-- 
1.9.1



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

* Re: [PATCH, rs6000]  Fix vec_mulo and vec_mule builtin implementations
  2017-06-06 22:55 [PATCH, rs6000] Fix vec_mulo and vec_mule builtin implementations Carl E. Love
@ 2017-06-07 21:16 ` Segher Boessenkool
  0 siblings, 0 replies; 2+ messages in thread
From: Segher Boessenkool @ 2017-06-07 21:16 UTC (permalink / raw)
  To: Carl E. Love; +Cc: gcc-patches, David Edelsohn, Bill Schmidt

On Tue, Jun 06, 2017 at 03:55:28PM -0700, Carl E. Love wrote:
> The support for the vec_mulo and vec_mule that was recently submitted
> has a couple of bugs.  Specifically, they were implemented with
> int/unsigned int args and return int/unsigned int.  The return types
> should have been long long/unsigned long long.  Additionally it was
> noted that unsigned version returned a signed version by mistake.  
> 
> The following patch fixes these issues.  The patch has been tested on
> powerpc64le-unknown-linux-gnu (Power 8 LE) and on
> powerpc64-unknown-linux-gnu (Power 8 BE) with no regressions.
> 
> Is the patch OK for gcc mainline?

Looks good.  Thanks!


Segher


> 2017-06-08  Carl Love  <cel@us.ibm.com>
> 
> 	* config/rs6000/rs6000-c: The return type of the following
> 	built-in functions was implemented as int not long long.  Fix sign
> 	of return value for the unsigned version of vec_mulo and vec_mule.
> 	vector unsigned long long vec_bperm (vector unsigned long long,
> 	                                     vector unsigned char)
> 	vector signed long long vec_mule (vector signed int,
> 	                                  vector signed int)
> 	vector unsigned long long vec_mule (vector unsigned int,
> 	                                    vector unsigned int)
> 	vector signed long long vec_mulo (vector signed int,
> 	                                  vector signed int)
> 	vector unsigned long long vec_mulo (vector unsigned int,
> 	                                    vector unsigned int)
> 	* doc/extend.texi: Fix the documentation for the
> 	built-in functions.
> 
> gcc/testsuite/ChangeLog:
> 
> 2017-06-08  Carl Love  <cel@us.ibm.com>
> 
> 	* gcc.target/powerpc/builtins-3.c: Fix vec_mule, vec_mulo test cases.

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

end of thread, other threads:[~2017-06-07 21:16 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2017-06-06 22:55 [PATCH, rs6000] Fix vec_mulo and vec_mule builtin implementations Carl E. Love
2017-06-07 21:16 ` Segher Boessenkool

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