aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJakub Jelinek <jakub@redhat.com>2018-03-27 22:00:56 +0200
committerJakub Jelinek <jakub@gcc.gnu.org>2018-03-27 22:00:56 +0200
commit153dba6cbb3b37ad07d23d212890b2bd055ac05f (patch)
treeea10fd34e5bb3a747c9941d1ae3cc3fc692e200a
parenta7dea61705009a47b788ecafed0816ab8b54e3ac (diff)
downloadgcc-153dba6cbb3b37ad07d23d212890b2bd055ac05f.zip
gcc-153dba6cbb3b37ad07d23d212890b2bd055ac05f.tar.gz
gcc-153dba6cbb3b37ad07d23d212890b2bd055ac05f.tar.bz2
re PR c++/85077 (V[248][SD]F abs not optimized to)
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
-rw-r--r--gcc/cp/ChangeLog4
-rw-r--r--gcc/cp/cp-gimplify.c2
-rw-r--r--gcc/testsuite/ChangeLog3
-rw-r--r--gcc/testsuite/g++.dg/ext/vector35.C22
4 files changed, 31 insertions, 0 deletions
diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog
index b410f3d..1799d8a 100644
--- a/gcc/cp/ChangeLog
+++ b/gcc/cp/ChangeLog
@@ -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.
diff --git a/gcc/cp/cp-gimplify.c b/gcc/cp/cp-gimplify.c
index 3edecf2..fd0c37f 100644
--- a/gcc/cp/cp-gimplify.c
+++ b/gcc/cp/cp-gimplify.c
@@ -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:
diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog
index 93557dd..ba8ba77 100644
--- a/gcc/testsuite/ChangeLog
+++ b/gcc/testsuite/ChangeLog
@@ -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
index 0000000..22ff513
--- /dev/null
+++ b/gcc/testsuite/g++.dg/ext/vector35.C
@@ -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" } }