]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
rs6000: Allow conversions of MMA pointer types [PR106017]
authorPeter Bergner <bergner@linux.ibm.com>
Sun, 28 Aug 2022 00:44:16 +0000 (19:44 -0500)
committerPeter Bergner <bergner@linux.ibm.com>
Tue, 30 Aug 2022 00:24:18 +0000 (19:24 -0500)
GCC incorrectly disables conversions between MMA pointer types, which
are allowed with clang.  The original intent was to disable conversions
between MMA types and other other types, but pointer conversions should
have been allowed.  The fix is to just remove the MMA pointer conversion
handling code altogether.

gcc/
PR target/106017
* config/rs6000/rs6000.c (rs6000_invalid_conversion): Remove handling
of MMA pointer conversions.

gcc/testsuite/
PR target/106017
* gcc.target/powerpc/pr106017.c: New test.

(cherry picked from commit 1ae1325f24cea1698b56e4299d95446a1f7b90a2)

gcc/config/rs6000/rs6000.c
gcc/testsuite/gcc.target/powerpc/pr106017.c [new file with mode: 0644]

index 24696edfb8caff92f4cc8521321afd683fbfbeb3..d6be8b7fb6b1574348524021516ae853fea536ea 100644 (file)
@@ -26888,28 +26888,6 @@ rs6000_invalid_conversion (const_tree fromtype, const_tree totype)
       if (tomode == POImode)
        return N_("invalid conversion to type %<__vector_pair%>");
     }
-  else if (POINTER_TYPE_P (fromtype) && POINTER_TYPE_P (totype))
-    {
-      /* We really care about the modes of the base types.  */
-      frommode = TYPE_MODE (TREE_TYPE (fromtype));
-      tomode = TYPE_MODE (TREE_TYPE (totype));
-
-      /* Do not allow conversions to/from PXImode and POImode pointer
-        types, except to/from void pointers.  */
-      if (frommode != tomode
-         && frommode != VOIDmode
-         && tomode != VOIDmode)
-       {
-         if (frommode == PXImode)
-           return N_("invalid conversion from type %<* __vector_quad%>");
-         if (tomode == PXImode)
-           return N_("invalid conversion to type %<* __vector_quad%>");
-         if (frommode == POImode)
-           return N_("invalid conversion from type %<* __vector_pair%>");
-         if (tomode == POImode)
-           return N_("invalid conversion to type %<* __vector_pair%>");
-       }
-    }
 
   /* Conversion allowed.  */
   return NULL;
diff --git a/gcc/testsuite/gcc.target/powerpc/pr106017.c b/gcc/testsuite/gcc.target/powerpc/pr106017.c
new file mode 100644 (file)
index 0000000..46d6c7a
--- /dev/null
@@ -0,0 +1,19 @@
+/* PR target/106017 */
+/* { dg-options "-O1 -mdejagnu-cpu=power10" } */
+/* { dg-require-effective-target power10_ok } */
+
+/* Make sure we do not flag any errors on the following test cases.  */
+
+void takeacc(__vector_quad *);
+void
+foo (void)
+{
+  __vector_quad arr[4];
+  takeacc (arr);
+}
+
+unsigned char *
+bar (__vector_quad *a)
+{
+  return (unsigned char *)a;
+}