public inbox for gcc-cvs@sourceware.org
help / color / mirror / Atom feed
* [gcc r9-8872] [PATCH, rs6000] Fix vector long long subtype (PR96139)
@ 2020-09-15 21:46 Will Schmidt
  0 siblings, 0 replies; only message in thread
From: Will Schmidt @ 2020-09-15 21:46 UTC (permalink / raw)
  To: gcc-cvs

https://gcc.gnu.org/g:04a9b796436c68a07c052805631e962a1126dcca

commit r9-8872-g04a9b796436c68a07c052805631e962a1126dcca
Author: Will Schmidt <will_schmidt@vnet.ibm.com>
Date:   Tue Sep 15 15:06:08 2020 -0500

    [PATCH, rs6000] Fix vector long long subtype (PR96139)
    
    Hi,
      This corrects an issue with the powerpc vector long long subtypes.
    As reported by SjMunroe, when building some code with -Wall, and
    attempting to print an element of a "long long vector" with a
    long long printf format string, we will report an error because
    the vector sub-type was improperly defined as int.
    
    When defining a V2DI_type_node we use a TARGET_POWERPC64 ternary to
    define the V2DI_type_node with "vector long" or "vector long long".
    We also need to specify the proper sub-type when we define the type.
    
    Due to some file renames, This is a backport and rework of both
        [PATCH, rs6000] Fix vector long long subtype (PR96139)
    and
        [PATCH, rs6000] Testsuite fixup pr96139 tests
    
    
    PR target/96139
    
    2020-09-03  Will Schmidt  <will_schmidt@vnet.ibm.com>
    
    gcc/ChangeLog:
            * config/rs6000/rs6000.c (rs6000_init_builtin): Update V2DI_type_node
            and unsigned_V2DI_type_node definitions.
    
    gcc/testsuite/ChangeLog:
            * gcc.target/powerpc/pr96139-a.c: New test.
            * gcc.target/powerpc/pr96139-b.c: New test.
            * gcc.target/powerpc/pr96139-c.c: New test.

Diff:
---
 gcc/config/rs6000/rs6000.c                   |  4 ++--
 gcc/testsuite/gcc.target/powerpc/pr96139-a.c | 32 ++++++++++++++++++++++++++++
 gcc/testsuite/gcc.target/powerpc/pr96139-b.c | 32 ++++++++++++++++++++++++++++
 gcc/testsuite/gcc.target/powerpc/pr96139-c.c | 26 ++++++++++++++++++++++
 4 files changed, 92 insertions(+), 2 deletions(-)

diff --git a/gcc/config/rs6000/rs6000.c b/gcc/config/rs6000/rs6000.c
index d5a6150d6c7..d582b324542 100644
--- a/gcc/config/rs6000/rs6000.c
+++ b/gcc/config/rs6000/rs6000.c
@@ -16830,7 +16830,7 @@ rs6000_init_builtins (void)
 
   V2DI_type_node = rs6000_vector_type (TARGET_POWERPC64 ? "__vector long"
 				       : "__vector long long",
-				       intDI_type_node, 2);
+				       long_long_integer_type_node, 2);
   V2DF_type_node = rs6000_vector_type ("__vector double", double_type_node, 2);
   V4SI_type_node = rs6000_vector_type ("__vector signed int",
 				       intSI_type_node, 4);
@@ -16849,7 +16849,7 @@ rs6000_init_builtins (void)
   unsigned_V2DI_type_node = rs6000_vector_type (TARGET_POWERPC64
 				       ? "__vector unsigned long"
 				       : "__vector unsigned long long",
-				       unsigned_intDI_type_node, 2);
+				       long_long_unsigned_type_node, 2);
 
   opaque_V4SI_type_node = build_opaque_vector_type (intSI_type_node, 4);
 
diff --git a/gcc/testsuite/gcc.target/powerpc/pr96139-a.c b/gcc/testsuite/gcc.target/powerpc/pr96139-a.c
new file mode 100644
index 00000000000..12a3383902c
--- /dev/null
+++ b/gcc/testsuite/gcc.target/powerpc/pr96139-a.c
@@ -0,0 +1,32 @@
+/* { dg-do compile } */
+/* { dg-options "-O2 -Wall -m32 -mvsx" } */
+/* { dg-require-effective-target ilp32 } */
+/* { dg-require-effective-target powerpc_vsx_ok } */
+
+#include <stdio.h>
+#include <altivec.h>
+
+void
+try_printing_longlong_a (
+                        __vector signed char cval,
+                        __vector signed int ival,
+                        __vector signed long long int llval,
+                        int x, int y, int z)
+{
+  printf (" %016llx \n", llval[x]);
+  printf (" %016x \n", ival[z]);
+  printf (" %c \n", cval[y]);
+}
+
+void
+try_printing_unsigned_longlong_a (
+                        __vector unsigned char cval,
+                        __vector unsigned int ival,
+                        __vector unsigned long long int llval,
+                        int x, int y, int z)
+{
+  printf (" %016llx \n", llval[x]);
+  printf (" %016x \n", ival[z]);
+  printf (" %c \n", cval[y]);
+}
+
diff --git a/gcc/testsuite/gcc.target/powerpc/pr96139-b.c b/gcc/testsuite/gcc.target/powerpc/pr96139-b.c
new file mode 100644
index 00000000000..379849a591a
--- /dev/null
+++ b/gcc/testsuite/gcc.target/powerpc/pr96139-b.c
@@ -0,0 +1,32 @@
+/* { dg-do compile } */
+/* { dg-options "-O2 -Wall -m64 -mvsx" } */
+/* { dg-require-effective-target lp64 } */
+/* { dg-require-effective-target powerpc_vsx_ok } */
+
+#include <stdio.h>
+#include <altivec.h>
+
+void
+try_printing_longlong_a (
+                        __vector signed char cval,
+                        __vector signed int ival,
+                        __vector signed long long int llval,
+                        int x, int y, int z)
+{
+  printf (" %016llx \n", llval[x]);
+  printf (" %016x \n", ival[z]);
+  printf (" %c \n", cval[y]);
+}
+
+
+void
+try_printing_unsigned_longlong_a (
+                        __vector unsigned char cval,
+                        __vector unsigned int ival,
+                        __vector unsigned long long int llval,
+                        int x, int y, int z)
+{
+  printf (" %016llx \n", llval[x]);
+  printf (" %016x \n", ival[z]);
+  printf (" %c \n", cval[y]);
+}
diff --git a/gcc/testsuite/gcc.target/powerpc/pr96139-c.c b/gcc/testsuite/gcc.target/powerpc/pr96139-c.c
new file mode 100644
index 00000000000..3ada2603428
--- /dev/null
+++ b/gcc/testsuite/gcc.target/powerpc/pr96139-c.c
@@ -0,0 +1,26 @@
+/* { dg-do run } */
+/* { dg-options "-O2 -Wall -maltivec" } */
+/* { dg-require-effective-target powerpc_altivec_ok } */
+
+/*
+ * Based on test created by sjmunroe for pr96139
+ */
+
+#include <stdio.h>
+#include <altivec.h>
+
+volatile vector long long llfoo;
+
+void
+print_v2xint64_b () {
+  printf (" %016llx \n", llfoo[0]);
+  printf (" %016llx \n", llfoo[1]);
+}
+
+int 
+main() {
+llfoo[0]=12345678;
+llfoo[1]=34567890;
+print_v2xint64_b();
+return 0;
+}


^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2020-09-15 21:46 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-09-15 21:46 [gcc r9-8872] [PATCH, rs6000] Fix vector long long subtype (PR96139) Will Schmidt

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