Hi, 
  This is a test created during investigation of the feedback on
the rs6000 gimple vector folding code, regarding the handling of
arg1_type.  Inspired by feedback from Richard and Bill.

This was useful to illustrate the issue to me.  Whether this is a
valid test for the testsuite I'll defer to the judgement of the
maintainers.. :-)

OK for trunk? 

[gcc/testsuite]

2017-09-15  Will Schmidt  <will_schm...@vnet.ibm.com>

        * gcc.target/powerpc/fold-vec-ld-misc.c: New.



diff --git a/gcc/testsuite/gcc.target/powerpc/fold-vec-ld-misc.c 
b/gcc/testsuite/gcc.target/powerpc/fold-vec-ld-misc.c
new file mode 100644
index 0000000..01069f6
--- /dev/null
+++ b/gcc/testsuite/gcc.target/powerpc/fold-vec-ld-misc.c
@@ -0,0 +1,54 @@
+/* Verify that overloaded built-ins for vec_ld with 
+   structure pointer / double inputs produce the right code.  */
+
+/* This test is to ensure that when a cast is associated with arg1 on a
+   call to vec_ld (arg0, arg1), that the arg1 type is properly handled
+   through the gimple folding code.
+   We want something like this:
+       D.2736 = MEM[(voidD.44 *)D.2739];
+   We specifically do not want 'struct S' showing up:
+       D.3212 = MEM[(struct S *)D.3215];
+*/
+
+/* { dg-do compile { target lp64 } } */
+/* { dg-require-effective-target powerpc_vsx_ok } */
+/* { dg-options "-mvsx -O2 -mpower8-vector -fdump-tree-gimple" } */
+
+#include <altivec.h>
+#include <stdio.h>
+
+struct S {
+  vector int *i1,*i2;
+  vector long long *ll1;
+  vector double *vd1;
+  vector double *vd2;
+  vector double *vd3;
+  vector double *vd4;
+};
+
+vector double
+testld_struct1 (long long ll1, struct S *p)
+{
+  return __builtin_altivec_lvx_v2df (ll1, (double *)p);
+}
+
+vector double
+testld_struct1b (long long ll1, struct S *p)
+{
+  return vec_ld (ll1, (vector double *)p);
+}
+
+vector double
+testld_struct2 (struct S *p)
+{
+  return vec_ld (16, (vector double *)p);
+}
+
+vector double
+testld_struct3 (struct S *p)
+{
+  return vec_ld (16, (vector double *)p->vd2);
+}
+
+// We do not want the "struct S" reference to show up.
+/* { dg-final { scan-tree-dump-times "MEM\[\(struct S *\)D.\[0-9\]+\]" 0 
"gimple" } } */


Reply via email to