re PR c++/85077 (V[248][SD]F abs not optimized to)
authorJakub Jelinek <jakub@redhat.com>
Tue, 27 Mar 2018 20:00:56 +0000 (22:00 +0200)
committerJakub Jelinek <jakub@gcc.gnu.org>
Tue, 27 Mar 2018 20:00:56 +0000 (22:00 +0200)
PR c++/85077
* cp-gimplify.c (cp_fold) <case CONSTRUCTOR>: For ctors with vector
type call fold to generate VECTOR_CSTs when possible.

* g++.dg/ext/vector35.C: New test.

From-SVN: r258903

gcc/cp/ChangeLog
gcc/cp/cp-gimplify.c
gcc/testsuite/ChangeLog
gcc/testsuite/g++.dg/ext/vector35.C [new file with mode: 0644]

index b410f3d003e4473c248aec1ea86919db1699e281..1799d8a9b146b50fa783b84d81dc62c5b7dff2f1 100644 (file)
@@ -1,5 +1,9 @@
 2018-03-27  Jakub Jelinek  <jakub@redhat.com>
 
+       PR c++/85077
+       * cp-gimplify.c (cp_fold) <case CONSTRUCTOR>: For ctors with vector
+       type call fold to generate VECTOR_CSTs when possible.
+
        PR c++/85076
        * tree.c (cp_build_reference_type): If to_type is error_mark_node,
        return it right away.
index 3edecf24c92758dcba97375a7c31bd3ce28d72f0..fd0c37f9be280b280fbef24b5e39649f7b961015 100644 (file)
@@ -2504,6 +2504,8 @@ cp_fold (tree x)
            CONSTRUCTOR_PLACEHOLDER_BOUNDARY (x)
              = CONSTRUCTOR_PLACEHOLDER_BOUNDARY (org_x);
          }
+       if (VECTOR_TYPE_P (TREE_TYPE (x)))
+         x = fold (x);
        break;
       }
     case TREE_VEC:
index 93557dda655c079b719db3a7de05b8d11dd98daa..ba8ba77c42c73a504fae03ef4556efb15bb02810 100644 (file)
@@ -1,5 +1,8 @@
 2018-03-27  Jakub Jelinek  <jakub@redhat.com>
 
+       PR c++/85077
+       * g++.dg/ext/vector35.C: New test.
+
        PR c++/85061
        * g++.dg/ext/builtin-offsetof3.C: New test.
 
diff --git a/gcc/testsuite/g++.dg/ext/vector35.C b/gcc/testsuite/g++.dg/ext/vector35.C
new file mode 100644 (file)
index 0000000..22ff513
--- /dev/null
@@ -0,0 +1,22 @@
+// PR c++/85077
+// { dg-do compile }
+// { dg-options "-Ofast -fdump-tree-forwprop1" }
+
+typedef float V __attribute__((vector_size (4 * sizeof (float))));
+typedef double W __attribute__((vector_size (2 * sizeof (double))));
+
+void
+foo (V *y)
+{
+  V x = *y;
+  *y = x < 0 ? -x : x;
+}
+
+void
+bar (W *y)
+{
+  W x = *y;
+  *y = x < 0 ? -x : x;
+}
+
+// { dg-final { scan-tree-dump-times "ABS_EXPR <" 2 "forwprop1" } }