diff options
author | Jakub Jelinek <jakub@redhat.com> | 2019-06-11 15:01:40 +0200 |
---|---|---|
committer | Jakub Jelinek <jakub@gcc.gnu.org> | 2019-06-11 15:01:40 +0200 |
commit | 5a5da48013f29c55bd9a4221ebc72104b80e4982 (patch) | |
tree | 2bc3d382017ed835296e5947bcc18fc10ff41a26 /gcc | |
parent | 7ac9a201848f020a7803c5b3e20dc4768a992c40 (diff) | |
download | gcc-5a5da48013f29c55bd9a4221ebc72104b80e4982.zip gcc-5a5da48013f29c55bd9a4221ebc72104b80e4982.tar.gz gcc-5a5da48013f29c55bd9a4221ebc72104b80e4982.tar.bz2 |
re PR c++/90810 (Different intrinsics behavior on G++ 7.4 and G++ 8.3)
PR c++/90810
* init.c (constant_value_1): Handle VECTOR_CST DECL_INITIAL for
!DECL_INITIALIZED_BY_CONSTANT_EXPRESSION_P decls like CONSTRUCTOR.
* g++.dg/ext/vector37.C: New test.
From-SVN: r272152
Diffstat (limited to 'gcc')
-rw-r--r-- | gcc/cp/ChangeLog | 6 | ||||
-rw-r--r-- | gcc/cp/init.c | 7 | ||||
-rw-r--r-- | gcc/testsuite/ChangeLog | 5 | ||||
-rw-r--r-- | gcc/testsuite/g++.dg/ext/vector37.C | 29 |
4 files changed, 45 insertions, 2 deletions
diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog index f279c7c..757f3fc 100644 --- a/gcc/cp/ChangeLog +++ b/gcc/cp/ChangeLog @@ -1,3 +1,9 @@ +2019-06-11 Jakub Jelinek <jakub@redhat.com> + + PR c++/90810 + * init.c (constant_value_1): Handle VECTOR_CST DECL_INITIAL for + !DECL_INITIALIZED_BY_CONSTANT_EXPRESSION_P decls like CONSTRUCTOR. + 2019-06-11 Martin Liska <mliska@suse.cz> PR c++/87847 diff --git a/gcc/cp/init.c b/gcc/cp/init.c index b206263..e962113 100644 --- a/gcc/cp/init.c +++ b/gcc/cp/init.c @@ -2339,8 +2339,11 @@ constant_value_1 (tree decl, bool strict_p, bool return_aggregate_cst_ok_p) || TREE_CODE (init) == STRING_CST))) break; /* Don't return a CONSTRUCTOR for a variable with partial run-time - initialization, since it doesn't represent the entire value. */ - if (TREE_CODE (init) == CONSTRUCTOR + initialization, since it doesn't represent the entire value. + Similarly for VECTOR_CSTs created by cp_folding those + CONSTRUCTORs. */ + if ((TREE_CODE (init) == CONSTRUCTOR + || TREE_CODE (init) == VECTOR_CST) && !DECL_INITIALIZED_BY_CONSTANT_EXPRESSION_P (decl)) break; /* If the variable has a dynamic initializer, don't use its diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index a40e014..beecd96 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,8 @@ +2019-06-11 Jakub Jelinek <jakub@redhat.com> + + PR c++/90810 + * g++.dg/ext/vector37.C: New test. + 2019-06-10 Matthew Beliveau <mbelivea@redhat.com> PR c++/87250 diff --git a/gcc/testsuite/g++.dg/ext/vector37.C b/gcc/testsuite/g++.dg/ext/vector37.C new file mode 100644 index 0000000..a7baf8d --- /dev/null +++ b/gcc/testsuite/g++.dg/ext/vector37.C @@ -0,0 +1,29 @@ +// PR c++/90810 +// { dg-do run } + +void +foo (float x, float y) +{ + typedef float __attribute__ ((__vector_size__ (4 * sizeof (float)), __may_alias__)) V; + const V a = { x, x, x, x }, b = { y, y, y, y }; + const V c = a / b; + if (c[0] != 6.0f || c[1] != 6.0f || c[2] != 6.0f || c[3] != 6.0f) + __builtin_abort (); +} + +void +bar (float y) +{ + typedef float __attribute__ ((__vector_size__ (4 * sizeof (float)), __may_alias__)) V; + const V a = { 7.0f, 8.0f, 9.0f, 10.0f }, b = { 1.0f, 2.0f, 3.0f, y }; + const V c = a / b; + if (c[0] != 7.0f || c[1] != 4.0f || c[2] != 3.0f || c[3] != 5.0f) + __builtin_abort (); +} + +int +main () +{ + foo (12.0f, 2.0f); + bar (2.0f); +} |