From 153dba6cbb3b37ad07d23d212890b2bd055ac05f Mon Sep 17 00:00:00 2001 From: Jakub Jelinek Date: Tue, 27 Mar 2018 22:00:56 +0200 Subject: [PATCH] re PR c++/85077 (V[248][SD]F abs not optimized to) PR c++/85077 * cp-gimplify.c (cp_fold) : 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 | 4 ++++ gcc/cp/cp-gimplify.c | 2 ++ gcc/testsuite/ChangeLog | 3 +++ gcc/testsuite/g++.dg/ext/vector35.C | 22 ++++++++++++++++++++++ 4 files changed, 31 insertions(+) create mode 100644 gcc/testsuite/g++.dg/ext/vector35.C diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog index b410f3d003e..1799d8a9b14 100644 --- a/gcc/cp/ChangeLog +++ b/gcc/cp/ChangeLog @@ -1,5 +1,9 @@ 2018-03-27 Jakub Jelinek + PR c++/85077 + * cp-gimplify.c (cp_fold) : 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 3edecf24c92..fd0c37f9be2 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 93557dda655..ba8ba77c42c 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,5 +1,8 @@ 2018-03-27 Jakub Jelinek + 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 00000000000..22ff513091a --- /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" } } -- 2.30.2