rs6000-c.c (c/c-tree.h): Add #include.
authorBill Schmidt <wschmidt@linux.vnet.ibm.com>
Fri, 3 Jun 2016 18:40:26 +0000 (18:40 +0000)
committerWilliam Schmidt <wschmidt@gcc.gnu.org>
Fri, 3 Jun 2016 18:40:26 +0000 (18:40 +0000)
[gcc]

2016-06-03  Bill Schmidt  <wschmidt@linux.vnet.ibm.com>

* rs6000-c.c (c/c-tree.h): Add #include.
(altivec_resolve_overloaded_builtin): Handle ARRAY_TYPE arguments
in C++ when found in the base position of vec_ld or vec_st.

[gcc/testsuite]

2016-06-03  Bill Schmidt  <wschmidt@linux.vnet.ibm.com>

* g++.dg/torture/ppc-ldst-array.C: New.

From-SVN: r237077

gcc/ChangeLog
gcc/config/rs6000/rs6000-c.c
gcc/testsuite/ChangeLog
gcc/testsuite/g++.dg/torture/ppc-ldst-array.C [new file with mode: 0644]

index 068b874dd1788924178beceae86bfd02da770f93..6d3974b875ec87bd96d79b03a25c1db3e1ef5777 100644 (file)
@@ -1,3 +1,9 @@
+2016-06-03  Bill Schmidt  <wschmidt@linux.vnet.ibm.com>
+
+       * rs6000-c.c (c/c-tree.h): Add #include.
+       (altivec_resolve_overloaded_builtin): Handle ARRAY_TYPE arguments
+       in C++ when found in the base position of vec_ld or vec_st.
+
 2016-06-03  Jan Hubicka  <hubicka@ucw.cz>
 
        * tree-ssa-loop-niter.c (estimate_numbers_of_iterations_loop): Avoid
index 79ac1158c76fc4719d0f57c61fd916476bba99ca..9e479a98eab23d41e0e85e541c6bbefee9d9bc5a 100644 (file)
@@ -30,6 +30,7 @@
 #include "stor-layout.h"
 #include "c-family/c-pragma.h"
 #include "langhooks.h"
+#include "c/c-tree.h"
 
 
 
@@ -5203,6 +5204,14 @@ assignment for unaligned loads and stores");
            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,
@@ -5256,6 +5265,14 @@ assignment for unaligned loads and stores");
            arg1 = build1 (NOP_EXPR, sizetype, arg1);
 
          tree arg2_type = TREE_TYPE (arg2);
+         if (TREE_CODE (arg2_type) == ARRAY_TYPE)
+           {
+             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);
+           }
+
          tree addr = fold_build2_loc (loc, POINTER_PLUS_EXPR, arg2_type,
                                       arg2, arg1);
          tree aligned = fold_build2_loc (loc, BIT_AND_EXPR, arg2_type, addr,
index 2822de1620a05ed7d514d7f3ce43f4bd5eff88a7..ea1576b11ef171dd3e325b95e0ff8259420275e0 100644 (file)
@@ -1,3 +1,7 @@
+2016-06-03  Bill Schmidt  <wschmidt@linux.vnet.ibm.com>
+
+       * g++.dg/torture/ppc-ldst-array.C: New.
+
 2016-06-03  Joseph Myers  <joseph@codesourcery.com>
 
        PR target/71276
diff --git a/gcc/testsuite/g++.dg/torture/ppc-ldst-array.C b/gcc/testsuite/g++.dg/torture/ppc-ldst-array.C
new file mode 100644 (file)
index 0000000..75862e2
--- /dev/null
@@ -0,0 +1,18 @@
+/* { dg-do compile { target { powerpc64*-*-* } } } */
+/* { dg-skip-if "do not override mcpu" { powerpc*-*-* } { "-mcpu=*" } { "-mcpu=power8" } } */
+/* { dg-options "-mcpu=power8" } */
+
+/* When compiled with C++, this code was breaking because of different
+   tree representations of arrays between C and C++.  */
+
+#include <altivec.h>
+
+extern vector float vf;
+
+void foo ()
+{
+  float __attribute__((aligned (16))) x[4];
+  float __attribute__((aligned (16))) y[4];
+  vf = vec_ld (0, x);
+  vec_st (vf, 0, y);
+}