re PR target/82112 (internal compiler error: in fold_convert_loc, at fold-const.c...
authorJakub Jelinek <jakub@redhat.com>
Tue, 12 Sep 2017 15:25:15 +0000 (17:25 +0200)
committerJakub Jelinek <jakub@gcc.gnu.org>
Tue, 12 Sep 2017 15:25:15 +0000 (17:25 +0200)
PR target/82112
* config/rs6000/rs6000-c.c (altivec_resolve_overloaded_builtin): For
ALTIVEC_BUILTIN_VEC_LD if arg1 has array type call default_conversion
on it early, rather than manual conversion late.  For
ALTIVEC_BUILTIN_VEC_ST if arg2 has array type call default_conversion
instead of performing manual conversion.

* gcc.target/powerpc/pr82112.c: New test.
* g++.dg/ext/altivec-18.C: New test.

From-SVN: r252028

gcc/ChangeLog
gcc/config/rs6000/rs6000-c.c
gcc/testsuite/ChangeLog
gcc/testsuite/g++.dg/ext/altivec-18.C [new file with mode: 0644]
gcc/testsuite/gcc.target/powerpc/pr82112.c [new file with mode: 0644]

index 20c1e2c75f0b59da4de8465e33830c1e01941a9a..eb73164a896dbe975804621d05dc93c0e70295e6 100644 (file)
@@ -1,3 +1,12 @@
+2017-09-12  Jakub Jelinek  <jakub@redhat.com>
+
+       PR target/82112
+       * config/rs6000/rs6000-c.c (altivec_resolve_overloaded_builtin): For
+       ALTIVEC_BUILTIN_VEC_LD if arg1 has array type call default_conversion
+       on it early, rather than manual conversion late.  For
+       ALTIVEC_BUILTIN_VEC_ST if arg2 has array type call default_conversion
+       instead of performing manual conversion.
+
 2017-09-12  Carl Love  <cel@us.ibm.com>
 
         * config/rs6000/altivec.md (vec_widen_umult_even_v4si,
index fbab0a2543e2602d96f7242e0231df3bbb72fa08..d27f5635c82cd7c113fc5040a6c3a189cdd89773 100644 (file)
@@ -6489,7 +6489,13 @@ altivec_resolve_overloaded_builtin (location_t loc, tree fndecl,
 
       /* Strip qualifiers like "const" from the pointer arg.  */
       tree arg1_type = TREE_TYPE (arg1);
-      if (!POINTER_TYPE_P (arg1_type) && TREE_CODE (arg1_type) != ARRAY_TYPE)
+      if (TREE_CODE (arg1_type) == ARRAY_TYPE && c_dialect_cxx ())
+       {
+         /* Force array-to-pointer decay for C++.  */
+         arg1 = default_conversion (arg1);
+         arg1_type = TREE_TYPE (arg1);
+       }
+      if (!POINTER_TYPE_P (arg1_type))
        goto bad;
 
       tree inner_type = TREE_TYPE (arg1_type);
@@ -6509,15 +6515,6 @@ altivec_resolve_overloaded_builtin (location_t loc, tree fndecl,
          if (!ptrofftype_p (TREE_TYPE (arg0)))
            arg0 = build1 (NOP_EXPR, sizetype, arg0);
 
-         tree arg1_type = TREE_TYPE (arg1);
-         if (TREE_CODE (arg1_type) == ARRAY_TYPE)
-           {
-             arg1_type = TYPE_POINTER_TO (TREE_TYPE (arg1_type));
-             tree const0 = build_int_cstu (sizetype, 0);
-             tree arg1_elt0 = build_array_ref (loc, arg1, const0);
-             arg1 = build1 (ADDR_EXPR, arg1_type, arg1_elt0);
-           }
-
          tree addr = fold_build2_loc (loc, POINTER_PLUS_EXPR, arg1_type,
                                       arg1, arg0);
          tree aligned = fold_build2_loc (loc, BIT_AND_EXPR, arg1_type, addr,
@@ -6572,12 +6569,11 @@ altivec_resolve_overloaded_builtin (location_t loc, tree fndecl,
            arg1 = build1 (NOP_EXPR, sizetype, arg1);
 
          tree arg2_type = TREE_TYPE (arg2);
-         if (TREE_CODE (arg2_type) == ARRAY_TYPE)
+         if (TREE_CODE (arg2_type) == ARRAY_TYPE && c_dialect_cxx ())
            {
-             arg2_type = TYPE_POINTER_TO (TREE_TYPE (arg2_type));
-             tree const0 = build_int_cstu (sizetype, 0);
-             tree arg2_elt0 = build_array_ref (loc, arg2, const0);
-             arg2 = build1 (ADDR_EXPR, arg2_type, arg2_elt0);
+             /* Force array-to-pointer decay for C++.  */
+             arg2 = default_conversion (arg2);
+             arg2_type = TREE_TYPE (arg2);
            }
 
          /* Find the built-in to make sure a compatible one exists; if not
index e7835ef53d5285a58bf3a383bf27e473ff2d99c5..a3ccc129d11a2c0db5a25d023dd6b8ea8f769f62 100644 (file)
@@ -1,3 +1,9 @@
+2017-09-12  Jakub Jelinek  <jakub@redhat.com>
+
+       PR target/82112
+       * gcc.target/powerpc/pr82112.c: New test.
+       * g++.dg/ext/altivec-18.C: New test.
+
 2017-09-12  Martin Liska  <mliska@suse.cz>
 
        PR testsuite/82114
diff --git a/gcc/testsuite/g++.dg/ext/altivec-18.C b/gcc/testsuite/g++.dg/ext/altivec-18.C
new file mode 100644 (file)
index 0000000..5b83028
--- /dev/null
@@ -0,0 +1,14 @@
+// PR target/82112
+// { dg-do compile { target powerpc*-*-* } }
+// { dg-require-effective-target powerpc_altivec_ok }
+// { dg-options "-maltivec" }
+
+#include <altivec.h>
+
+__attribute__((aligned (16))) extern const unsigned char c[16];
+
+void
+foo (void)
+{
+  vec_ld (0, c);
+}
diff --git a/gcc/testsuite/gcc.target/powerpc/pr82112.c b/gcc/testsuite/gcc.target/powerpc/pr82112.c
new file mode 100644 (file)
index 0000000..fbb0f9d
--- /dev/null
@@ -0,0 +1,16 @@
+/* PR target/82112 */
+/* { dg-do compile } */
+/* { dg-require-effective-target powerpc_altivec_ok } */
+/* { dg-options "-maltivec -std=gnu90" } */
+
+#include <altivec.h>
+
+struct __attribute__((aligned (16))) S { unsigned char c[64]; } bar (void);
+vector unsigned char v;
+
+void
+foo (void)
+{
+  vec_ld (0, bar ().c);        /* { dg-error "invalid parameter combination for AltiVec intrinsic" } */
+  vec_st (v, 0, bar ().c);     /* { dg-error "invalid parameter combination for AltiVec intrinsic" } */
+}