diff options
author | bstarynk <bstarynk@138bc75d-0d04-0410-961f-82ee72b054a4> | 2016-04-15 20:07:15 +0000 |
---|---|---|
committer | bstarynk <bstarynk@138bc75d-0d04-0410-961f-82ee72b054a4> | 2016-04-15 20:07:15 +0000 |
commit | fa9bb8dc72e83d89b2aa40786661dda5b5f69856 (patch) | |
tree | 3f80a50c3fcfae96e4ad234c43d2c52fe02de202 | |
parent | 22623b9c398e31770e33cc73a23fce6b26b95f63 (diff) | |
download | gcc-fa9bb8dc72e83d89b2aa40786661dda5b5f69856.tar.gz |
2016-04-15 Basile Starynkevitch <basile@starynkevitch.net>
{{merging with even more of GCC 6, using subversion 1.9
svn merge -r230171:230180 ^/trunk
}}
git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/branches/melt-branch@235047 138bc75d-0d04-0410-961f-82ee72b054a4
-rw-r--r-- | ChangeLog.MELT | 5 | ||||
-rw-r--r-- | gcc/ChangeLog | 22 | ||||
-rw-r--r-- | gcc/c-family/ChangeLog | 12 | ||||
-rw-r--r-- | gcc/c-family/c-common.c | 22 | ||||
-rw-r--r-- | gcc/c-family/c-common.h | 1 | ||||
-rw-r--r-- | gcc/c-family/c-pragma.c | 6 | ||||
-rw-r--r-- | gcc/c/ChangeLog | 7 | ||||
-rw-r--r-- | gcc/c/c-decl.c | 22 | ||||
-rw-r--r-- | gcc/cp/ChangeLog | 12 | ||||
-rw-r--r-- | gcc/cp/decl.c | 16 | ||||
-rw-r--r-- | gcc/cp/parser.h | 2 | ||||
-rw-r--r-- | gcc/testsuite/ChangeLog | 9 | ||||
-rw-r--r-- | gcc/testsuite/c-c++-common/pr68107.c | 37 | ||||
-rw-r--r-- | gcc/testsuite/g++.dg/init/new38.C | 4 | ||||
-rw-r--r-- | gcc/testsuite/g++.dg/init/new44.C | 238 | ||||
-rw-r--r-- | gcc/tree-vect-data-refs.c | 241 | ||||
-rw-r--r-- | gcc/tree-vect-slp.c | 110 | ||||
-rw-r--r-- | gcc/tree-vectorizer.h | 5 | ||||
-rw-r--r-- | libstdc++-v3/ChangeLog | 11 | ||||
-rw-r--r-- | libstdc++-v3/include/bits/mutex.h | 6 | ||||
-rw-r--r-- | libstdc++-v3/include/bits/stl_pair.h | 2 | ||||
-rw-r--r-- | libstdc++-v3/include/bits/uses_allocator.h | 2 | ||||
-rw-r--r-- | libstdc++-v3/libsupc++/new | 7 | ||||
-rw-r--r-- | libstdc++-v3/testsuite/17_intro/tag_type_explicit_ctor.cc | 60 |
24 files changed, 545 insertions, 314 deletions
diff --git a/ChangeLog.MELT b/ChangeLog.MELT index d5d128dd40e..c06ea7b6120 100644 --- a/ChangeLog.MELT +++ b/ChangeLog.MELT @@ -1,6 +1,11 @@ 2016-04-15 Basile Starynkevitch <basile@starynkevitch.net> {{merging with even more of GCC 6, using subversion 1.9 + svn merge -r230171:230180 ^/trunk + }} + +2016-04-15 Basile Starynkevitch <basile@starynkevitch.net> + {{merging with even more of GCC 6, using subversion 1.9 svn merge -r230161:230170 ^/trunk .. but svn rev 230182 fails to merge... }} diff --git a/gcc/ChangeLog b/gcc/ChangeLog index 408894dd43d..e2576fd1f32 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -1,3 +1,25 @@ +2015-11-11 Richard Biener <rguenther@suse.de> + + * tree-vectorizer.h (vect_slp_analyze_and_verify_instance_alignment): + Declare. + (vect_analyze_data_refs_alignment): Make loop vect specific. + (vect_verify_datarefs_alignment): Likewise. + * tree-vect-data-refs.c (vect_slp_analyze_data_ref_dependences): + Add missing continue. + (vect_compute_data_ref_alignment): Export. + (vect_compute_data_refs_alignment): Merge into... + (vect_analyze_data_refs_alignment): ... this. + (verify_data_ref_alignment): Split out from ... + (vect_verify_datarefs_alignment): ... here. + (vect_slp_analyze_and_verify_node_alignment): New function. + (vect_slp_analyze_and_verify_instance_alignment): Likewise. + * tree-vect-slp.c (vect_supported_load_permutation_p): Remove + misplaced checks on alignment. + (vect_slp_analyze_bb_1): Add fatal output parameter. Do + alignment analysis after SLP discovery and do it per instance. + (vect_slp_bb): When vect_slp_analyze_bb_1 fatally failed do not + bother to re-try using different vector sizes. + 2015-11-11 Nathan Sidwell <nathan@codesourcery.com> Cesar Philippidis <cesar@codesourcery.com> diff --git a/gcc/c-family/ChangeLog b/gcc/c-family/ChangeLog index 0a99798d5fa..eb4d5bfbae2 100644 --- a/gcc/c-family/ChangeLog +++ b/gcc/c-family/ChangeLog @@ -1,3 +1,15 @@ +2015-11-11 Marek Polacek <polacek@redhat.com> + + PR c/68107 + PR c++/68266 + * c-common.c (valid_array_size_p): New function. + * c-common.h (valid_array_size_p): Declare. + +2015-11-11 Dominique d'Humieres <dominiq@lps.ens.fr> + + PR bootstrap/68271 + * c-pragma.c (c_register_pragma_1): Update the gcc_assert to 256. + 2015-11-11 Andrew MacLeod <amacleod@redhat.com> * array-notation-common.c: Remove unused header files. diff --git a/gcc/c-family/c-common.c b/gcc/c-family/c-common.c index 2b5071f6d23..9cf37ebfcd5 100644 --- a/gcc/c-family/c-common.c +++ b/gcc/c-family/c-common.c @@ -13107,4 +13107,26 @@ warn_duplicated_cond_add_or_warn (location_t loc, tree cond, vec<tree> **chain) (*chain)->safe_push (cond); } +/* Check if array size calculations overflow or if the array covers more + than half of the address space. Return true if the size of the array + is valid, false otherwise. TYPE is the type of the array and NAME is + the name of the array, or NULL_TREE for unnamed arrays. */ + +bool +valid_array_size_p (location_t loc, tree type, tree name) +{ + if (type != error_mark_node + && COMPLETE_TYPE_P (type) + && TREE_CODE (TYPE_SIZE_UNIT (type)) == INTEGER_CST + && !valid_constant_size_p (TYPE_SIZE_UNIT (type))) + { + if (name) + error_at (loc, "size of array %qE is too large", name); + else + error_at (loc, "size of unnamed array is too large"); + return false; + } + return true; +} + #include "gt-c-family-c-common.h" diff --git a/gcc/c-family/c-common.h b/gcc/c-family/c-common.h index 8badc9b6ad6..d7fcf387588 100644 --- a/gcc/c-family/c-common.h +++ b/gcc/c-family/c-common.h @@ -1464,5 +1464,6 @@ extern bool check_no_cilk (tree, const char *, const char *, location_t loc = UNKNOWN_LOCATION); extern bool reject_gcc_builtin (const_tree, location_t = UNKNOWN_LOCATION); extern void warn_duplicated_cond_add_or_warn (location_t, tree, vec<tree> **); +extern bool valid_array_size_p (location_t, tree, tree); #endif /* ! GCC_C_COMMON_H */ diff --git a/gcc/c-family/c-pragma.c b/gcc/c-family/c-pragma.c index c1bdf23f479..62755990376 100644 --- a/gcc/c-family/c-pragma.c +++ b/gcc/c-family/c-pragma.c @@ -1366,9 +1366,9 @@ c_register_pragma_1 (const char *space, const char *name, id = registered_pragmas.length (); id += PRAGMA_FIRST_EXTERNAL - 1; - /* The C++ front end allocates 6 bits in cp_token; the C front end - allocates 7 bits in c_token. At present this is sufficient. */ - gcc_assert (id < 64); + /* The C++ front end allocates 8 bits in cp_token; the C front end + allocates 8 bits in c_token. At present this is sufficient. */ + gcc_assert (id < 256); } cpp_register_deferred_pragma (parse_in, space, name, id, diff --git a/gcc/c/ChangeLog b/gcc/c/ChangeLog index 8fb3786df3a..87f6a2d30e3 100644 --- a/gcc/c/ChangeLog +++ b/gcc/c/ChangeLog @@ -1,3 +1,10 @@ +2015-11-11 Marek Polacek <polacek@redhat.com> + + PR c/68107 + PR c++/68266 + * c-decl.c (grokdeclarator): Call valid_array_size_p. Remove code + checking the size of an array. + 2015-11-11 Andrew MacLeod <amacleod@redhat.com> * c-array-notation.c: Remove unused header files. diff --git a/gcc/c/c-decl.c b/gcc/c/c-decl.c index c58dec6022c..a636474862d 100644 --- a/gcc/c/c-decl.c +++ b/gcc/c/c-decl.c @@ -6000,6 +6000,9 @@ grokdeclarator (const struct c_declarator *declarator, TYPE_SIZE_UNIT (type) = size_zero_node; SET_TYPE_STRUCTURAL_EQUALITY (type); } + + if (!valid_array_size_p (loc, type, name)) + type = error_mark_node; } if (decl_context != PARM @@ -6007,7 +6010,8 @@ grokdeclarator (const struct c_declarator *declarator, || array_ptr_attrs != NULL_TREE || array_parm_static)) { - error_at (loc, "static or type qualifiers in non-parameter array declarator"); + error_at (loc, "static or type qualifiers in non-parameter " + "array declarator"); array_ptr_quals = TYPE_UNQUALIFIED; array_ptr_attrs = NULL_TREE; array_parm_static = 0; @@ -6286,22 +6290,6 @@ grokdeclarator (const struct c_declarator *declarator, } } - /* Did array size calculations overflow or does the array cover more - than half of the address-space? */ - if (TREE_CODE (type) == ARRAY_TYPE - && COMPLETE_TYPE_P (type) - && TREE_CODE (TYPE_SIZE_UNIT (type)) == INTEGER_CST - && ! valid_constant_size_p (TYPE_SIZE_UNIT (type))) - { - if (name) - error_at (loc, "size of array %qE is too large", name); - else - error_at (loc, "size of unnamed array is too large"); - /* If we proceed with the array type as it is, we'll eventually - crash in tree_to_[su]hwi(). */ - type = error_mark_node; - } - /* If this is declaring a typedef name, return a TYPE_DECL. */ if (storage_class == csc_typedef) diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog index b2f8b64e2c7..62992eef6ef 100644 --- a/gcc/cp/ChangeLog +++ b/gcc/cp/ChangeLog @@ -1,3 +1,15 @@ +2015-11-11 Marek Polacek <polacek@redhat.com> + + PR c/68107 + PR c++/68266 + * decl.c (grokdeclarator): Call valid_array_size_p. Remove code + checking the size of an array. + +2015-11-11 Dominique d'Humieres <dominiq@lps.ens.fr> + + PR bootstrap/68271 + * parser.h (cp_token): Update pragma_kind to 8. + 2015-11-11 Andrew MacLeod <amacleod@redhat.com> * call.c: Remove unused header files. diff --git a/gcc/cp/decl.c b/gcc/cp/decl.c index 6b9aba1a5da..6abde2aa077 100644 --- a/gcc/cp/decl.c +++ b/gcc/cp/decl.c @@ -9939,6 +9939,9 @@ grokdeclarator (const cp_declarator *declarator, case cdk_array: type = create_array_type_for_decl (dname, type, declarator->u.array.bounds); + if (!valid_array_size_p (input_location, type, dname)) + type = error_mark_node; + if (declarator->std_attributes) /* [dcl.array]/1: @@ -10502,19 +10505,6 @@ grokdeclarator (const cp_declarator *declarator, error ("non-parameter %qs cannot be a parameter pack", name); } - /* Did array size calculations overflow or does the array cover more - than half of the address-space? */ - if (TREE_CODE (type) == ARRAY_TYPE - && COMPLETE_TYPE_P (type) - && TREE_CODE (TYPE_SIZE_UNIT (type)) == INTEGER_CST - && ! valid_constant_size_p (TYPE_SIZE_UNIT (type))) - { - error ("size of array %qs is too large", name); - /* If we proceed with the array type as it is, we'll eventually - crash in tree_to_[su]hwi(). */ - type = error_mark_node; - } - if ((decl_context == FIELD || decl_context == PARM) && !processing_template_decl && variably_modified_type_p (type, NULL_TREE)) diff --git a/gcc/cp/parser.h b/gcc/cp/parser.h index aa090b06544..25e1772402d 100644 --- a/gcc/cp/parser.h +++ b/gcc/cp/parser.h @@ -48,7 +48,7 @@ typedef struct GTY (()) cp_token { /* Token flags. */ unsigned char flags; /* Identifier for the pragma. */ - ENUM_BITFIELD (pragma_kind) pragma_kind : 6; + ENUM_BITFIELD (pragma_kind) pragma_kind : 8; /* True if this token is from a context where it is implicitly extern "C" */ BOOL_BITFIELD implicit_extern_c : 1; /* True if an error has already been reported for this token, such as a diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index 6c2c07a006f..8e973115215 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,12 @@ +2015-11-11 Marek Polacek <polacek@redhat.com> + + PR c/68107 + PR c++/68266 + * c-c++-common/pr68107.c: New test. + * g++.dg/init/new38.C (large_array_char): Adjust dg-error. + (large_array_char_template): Likewise. + * g++.dg/init/new44.C: Adjust dg-error. + 2015-11-11 Nathan Sidwell <nathan@codesourcery.com> * gfortran.dg/goacc/private-3.f95: Remove xfail. diff --git a/gcc/testsuite/c-c++-common/pr68107.c b/gcc/testsuite/c-c++-common/pr68107.c new file mode 100644 index 00000000000..f1ed465e078 --- /dev/null +++ b/gcc/testsuite/c-c++-common/pr68107.c @@ -0,0 +1,37 @@ +/* PR c/68107 */ +/* { dg-do compile } */ + +#define N ((__SIZE_MAX__ / sizeof (int)) / 2 + 1) + +typedef int (*T1)[N]; /* { dg-error "too large" } */ +typedef int (*T2)[N - 1]; +typedef int (*T3)[N][N]; /* { dg-error "too large" } */ +typedef int (*T4)[N - 1][N - 1]; /* { dg-error "too large" } */ +typedef int (**T5)[N]; /* { dg-error "too large" } */ + +struct S { + int (*q1)[N]; /* { dg-error "too large" } */ + int (*q2)[N - 1]; + int (*q3)[N][N]; /* { dg-error "too large" } */ + int (*q4)[N - 1][N - 1]; /* { dg-error "too large" } */ + int (**q5)[N]; /* { dg-error "too large" } */ +}; + +void fn1 (int (*p1)[N]); /* { dg-error "too large" } */ +void fn2 (int (*p1)[N - 1]); +void fn3 (int (*p3)[N][N]); /* { dg-error "too large" } */ +void fn4 (int (*p4)[N - 1][N - 1]); /* { dg-error "too large" } */ +void fn5 (int (**p5)[N]); /* { dg-error "too large" } */ + +void +fn (void) +{ + int (*n1)[N]; /* { dg-error "too large" } */ + int (*n2)[N - 1]; + int (*n3)[N][N]; /* { dg-error "too large" } */ + int (*n4)[N - 1][N - 1]; /* { dg-error "too large" } */ + int (**n5)[N]; /* { dg-error "too large" } */ + + sizeof (int (*)[N]); /* { dg-error "too large" } */ + sizeof (int [N]); /* { dg-error "too large" } */ +} diff --git a/gcc/testsuite/g++.dg/init/new38.C b/gcc/testsuite/g++.dg/init/new38.C index 1672f229d64..37da525bf78 100644 --- a/gcc/testsuite/g++.dg/init/new38.C +++ b/gcc/testsuite/g++.dg/init/new38.C @@ -5,7 +5,7 @@ large_array_char(int n) { new char[n] [1ULL << (sizeof(void *) * 4)] - [1ULL << (sizeof(void *) * 4)]; // { dg-error "size of array" } + [1ULL << (sizeof(void *) * 4)]; // { dg-error "size of unnamed array" } } template <typename T> @@ -14,7 +14,7 @@ large_array_char_template(int n) { new char[n] [1ULL << (sizeof(void *) * 4)] - [1ULL << (sizeof(void *) * 4)]; // { dg-error "size of array" } + [1ULL << (sizeof(void *) * 4)]; // { dg-error "size of unnamed array" } } diff --git a/gcc/testsuite/g++.dg/init/new44.C b/gcc/testsuite/g++.dg/init/new44.C index d6ff86a16c7..ab6e3484cc8 100644 --- a/gcc/testsuite/g++.dg/init/new44.C +++ b/gcc/testsuite/g++.dg/init/new44.C @@ -87,10 +87,10 @@ test_one_dim_short_array () static void __attribute__ ((used)) test_two_dim_char_array () { - p = new char [1][MAX]; // { dg-error "size of array" } - p = new char [1][MAX - 1]; // { dg-error "size of array" } - p = new char [1][MAX - 2]; // { dg-error "size of array" } - p = new char [1][MAX - 99]; // { dg-error "size of array" } + p = new char [1][MAX]; // { dg-error "size of unnamed array" } + p = new char [1][MAX - 1]; // { dg-error "size of unnamed array" } + p = new char [1][MAX - 2]; // { dg-error "size of unnamed array" } + p = new char [1][MAX - 99]; // { dg-error "size of unnamed array" } p = new char [1][MAX / 2]; // { dg-error "size of array" } p = new char [1][MAX / 2 - 1]; // { dg-error "size of array" } p = new char [1][MAX / 2 - 2]; // { dg-error "size of array" } @@ -104,18 +104,18 @@ test_two_dim_char_array () p = new char [1][MAX / 2 - 7]; // okay p = new char [1][MAX / 2 - 8]; // okay - p = new char [2][MAX]; // { dg-error "size of array" } - p = new char [2][MAX - 1]; // { dg-error "size of array" } - p = new char [2][MAX - 2]; // { dg-error "size of array" } + p = new char [2][MAX]; // { dg-error "size of unnamed array" } + p = new char [2][MAX - 1]; // { dg-error "size of unnamed array" } + p = new char [2][MAX - 2]; // { dg-error "size of unnamed array" } p = new char [2][MAX / 2]; // { dg-error "size of array" } p = new char [2][MAX / 2 - 1]; // { dg-error "size of array" } p = new char [2][MAX / 2 - 2]; // { dg-error "size of array" } p = new char [2][MAX / 2 - 7]; // { dg-error "size of array" } p = new char [2][MAX / 2 - 8]; // { dg-error "size of array" } - p = new char [MAX][MAX]; // { dg-error "size of array" } - p = new char [MAX][MAX - 1]; // { dg-error "size of array" } - p = new char [MAX][MAX - 2]; // { dg-error "size of array" } + p = new char [MAX][MAX]; // { dg-error "size of unnamed array" } + p = new char [MAX][MAX - 1]; // { dg-error "size of unnamed array" } + p = new char [MAX][MAX - 2]; // { dg-error "size of unnamed array" } p = new char [MAX][MAX / 2]; // { dg-error "size of array" } p = new char [MAX][MAX / 2 - 1]; // { dg-error "size of array" } p = new char [MAX][MAX / 2 - 2]; // { dg-error "size of array" } @@ -142,10 +142,10 @@ test_two_dim_char_array () static __attribute__ ((used)) void test_three_dim_char_array () { - p = new char [1][1][MAX]; // { dg-error "size of array" } - p = new char [1][1][MAX - 1]; // { dg-error "size of array" } - p = new char [1][1][MAX - 2]; // { dg-error "size of array" } - p = new char [1][1][MAX - 99]; // { dg-error "size of array" } + p = new char [1][1][MAX]; // { dg-error "size of unnamed array" } + p = new char [1][1][MAX - 1]; // { dg-error "size of unnamed array" } + p = new char [1][1][MAX - 2]; // { dg-error "size of unnamed array" } + p = new char [1][1][MAX - 99]; // { dg-error "size of unnamed array" } p = new char [1][1][MAX / 2]; // { dg-error "size of array" } p = new char [1][1][MAX / 2 - 1]; // { dg-error "size of array" } p = new char [1][1][MAX / 2 - 2]; // { dg-error "size of array" } @@ -159,19 +159,19 @@ test_three_dim_char_array () p = new char [1][1][MAX / 2 - 7]; // okay p = new char [1][1][MAX / 2 - 8]; // okay - p = new char [1][2][MAX]; // { dg-error "size of array" } - p = new char [1][2][MAX - 1]; // { dg-error "size of array" } - p = new char [1][2][MAX - 2]; // { dg-error "size of array" } - p = new char [1][2][MAX - 99]; // { dg-error "size of array" } - p = new char [1][2][MAX / 2]; // { dg-error "size of array" } - p = new char [1][2][MAX / 2 - 1]; // { dg-error "size of array" } - p = new char [1][2][MAX / 2 - 2]; // { dg-error "size of array" } - p = new char [1][2][MAX / 2 - 3]; // { dg-error "size of array" } - p = new char [1][2][MAX / 2 - 4]; // { dg-error "size of array" } - p = new char [1][2][MAX / 2 - 5]; // { dg-error "size of array" } - p = new char [1][2][MAX / 2 - 6]; // { dg-error "size of array" } - p = new char [1][2][MAX / 2 - 7]; // { dg-error "size of array" } - p = new char [1][2][MAX / 2 - 8]; // { dg-error "size of array" } + p = new char [1][2][MAX]; // { dg-error "size of unnamed array" } + p = new char [1][2][MAX - 1]; // { dg-error "size of unnamed array" } + p = new char [1][2][MAX - 2]; // { dg-error "size of unnamed array" } + p = new char [1][2][MAX - 99]; // { dg-error "size of unnamed array" } + p = new char [1][2][MAX / 2]; // { dg-error "size of unnamed array" } + p = new char [1][2][MAX / 2 - 1]; // { dg-error "size of unnamed array" } + p = new char [1][2][MAX / 2 - 2]; // { dg-error "size of unnamed array" } + p = new char [1][2][MAX / 2 - 3]; // { dg-error "size of unnamed array" } + p = new char [1][2][MAX / 2 - 4]; // { dg-error "size of unnamed array" } + p = new char [1][2][MAX / 2 - 5]; // { dg-error "size of unnamed array" } + p = new char [1][2][MAX / 2 - 6]; // { dg-error "size of unnamed array" } + p = new char [1][2][MAX / 2 - 7]; // { dg-error "size of unnamed array" } + p = new char [1][2][MAX / 2 - 8]; // { dg-error "size of unnamed array" } p = new char [1][2][MAX / 4]; // { dg-error "size of array" } // Avoid exercising data model-dependent expressions. @@ -181,10 +181,10 @@ test_three_dim_char_array () p = new char [1][2][MAX / 4 - 3]; // okay p = new char [1][2][MAX / 4 - 4]; // okay - p = new char [2][1][MAX]; // { dg-error "size of array" } - p = new char [2][1][MAX - 1]; // { dg-error "size of array" } - p = new char [2][1][MAX - 2]; // { dg-error "size of array" } - p = new char [2][1][MAX - 99]; // { dg-error "size of array" } + p = new char [2][1][MAX]; // { dg-error "size of unnamed array" } + p = new char [2][1][MAX - 1]; // { dg-error "size of unnamed array" } + p = new char [2][1][MAX - 2]; // { dg-error "size of unnamed array" } + p = new char [2][1][MAX - 99]; // { dg-error "size of unnamed array" } p = new char [2][1][MAX / 2]; // { dg-error "size of array" } p = new char [2][1][MAX / 2 - 1]; // { dg-error "size of array" } p = new char [2][1][MAX / 2 - 2]; // { dg-error "size of array" } @@ -203,19 +203,19 @@ test_three_dim_char_array () p = new char [2][1][MAX / 4 - 3]; // okay p = new char [2][1][MAX / 4 - 4]; // okay - p = new char [2][2][MAX]; // { dg-error "size of array" } - p = new char [2][2][MAX - 1]; // { dg-error "size of array" } - p = new char [2][2][MAX - 2]; // { dg-error "size of array" } - p = new char [2][2][MAX - 99]; // { dg-error "size of array" } - p = new char [2][2][MAX / 2]; // { dg-error "size of array" } - p = new char [2][2][MAX / 2 - 1]; // { dg-error "size of array" } - p = new char [2][2][MAX / 2 - 2]; // { dg-error "size of array" } - p = new char [2][2][MAX / 2 - 3]; // { dg-error "size of array" } - p = new char [2][2][MAX / 2 - 4]; // { dg-error "size of array" } - p = new char [2][2][MAX / 2 - 5]; // { dg-error "size of array" } - p = new char [2][2][MAX / 2 - 6]; // { dg-error "size of array" } - p = new char [2][2][MAX / 2 - 7]; // { dg-error "size of array" } - p = new char [2][2][MAX / 2 - 8]; // { dg-error "size of array" } + p = new char [2][2][MAX]; // { dg-error "size of unnamed array" } + p = new char [2][2][MAX - 1]; // { dg-error "size of unnamed array" } + p = new char [2][2][MAX - 2]; // { dg-error "size of unnamed array" } + p = new char [2][2][MAX - 99]; // { dg-error "size of unnamed array" } + p = new char [2][2][MAX / 2]; // { dg-error "size of unnamed array" } + p = new char [2][2][MAX / 2 - 1]; // { dg-error "size of unnamed array" } + p = new char [2][2][MAX / 2 - 2]; // { dg-error "size of unnamed array" } + p = new char [2][2][MAX / 2 - 3]; // { dg-error "size of unnamed array" } + p = new char [2][2][MAX / 2 - 4]; // { dg-error "size of unnamed array" } + p = new char [2][2][MAX / 2 - 5]; // { dg-error "size of unnamed array" } + p = new char [2][2][MAX / 2 - 6]; // { dg-error "size of unnamed array" } + p = new char [2][2][MAX / 2 - 7]; // { dg-error "size of unnamed array" } + p = new char [2][2][MAX / 2 - 8]; // { dg-error "size of unnamed array" } p = new char [2][2][MAX / 4]; // { dg-error "size of array" } p = new char [2][2][MAX / 4 - 1]; // { dg-error "size of array" } p = new char [2][2][MAX / 4 - 2]; // { dg-error "size of array" } @@ -227,19 +227,19 @@ test_three_dim_char_array () p = new char [2][2][MAX / 8 - 2]; p = new char [2][2][MAX / 8 - 3]; - p = new char [2][MAX][2]; // { dg-error "size of array" } - p = new char [2][MAX - 1][2]; // { dg-error "size of array" } - p = new char [2][MAX - 2][2]; // { dg-error "size of array" } - p = new char [2][MAX - 99][2]; // { dg-error "size of array" } - p = new char [2][MAX / 2][2]; // { dg-error "size of array" } - p = new char [2][MAX / 2 - 1][2]; // { dg-error "size of array" } - p = new char [2][MAX / 2 - 2][2]; // { dg-error "size of array" } - p = new char [2][MAX / 2 - 3][2]; // { dg-error "size of array" } - p = new char [2][MAX / 2 - 4][2]; // { dg-error "size of array" } - p = new char [2][MAX / 2 - 5][2]; // { dg-error "size of array" } - p = new char [2][MAX / 2 - 6][2]; // { dg-error "size of array" } - p = new char [2][MAX / 2 - 7][2]; // { dg-error "size of array" } - p = new char [2][MAX / 2 - 8][2]; // { dg-error "size of array" } + p = new char [2][MAX][2]; // { dg-error "size of unnamed array" } + p = new char [2][MAX - 1][2]; // { dg-error "size of unnamed array" } + p = new char [2][MAX - 2][2]; // { dg-error "size of unnamed array" } + p = new char [2][MAX - 99][2]; // { dg-error "size of unnamed array" } + p = new char [2][MAX / 2][2]; // { dg-error "size of unnamed array" } + p = new char [2][MAX / 2 - 1][2]; // { dg-error "size of unnamed array" } + p = new char [2][MAX / 2 - 2][2]; // { dg-error "size of unnamed array" } + p = new char [2][MAX / 2 - 3][2]; // { dg-error "size of unnamed array" } + p = new char [2][MAX / 2 - 4][2]; // { dg-error "size of unnamed array" } + p = new char [2][MAX / 2 - 5][2]; // { dg-error "size of unnamed array" } + p = new char [2][MAX / 2 - 6][2]; // { dg-error "size of unnamed array" } + p = new char [2][MAX / 2 - 7][2]; // { dg-error "size of unnamed array" } + p = new char [2][MAX / 2 - 8][2]; // { dg-error "size of unnamed array" } p = new char [2][MAX / 4][2]; // { dg-error "size of array" } p = new char [2][MAX / 4 - 1][2]; // { dg-error "size of array" } p = new char [2][MAX / 4 - 2][2]; // { dg-error "size of array" } @@ -275,11 +275,11 @@ test_three_dim_char_array () p = new char [MAX / 8 - 2][2][2]; p = new char [MAX / 8 - 3][2][2]; - p = new char [MAX][MAX][MAX]; // { dg-error "size of array" } - p = new char [MAX][MAX][MAX / 2]; // { dg-error "size of array" } - p = new char [MAX][MAX / 2][MAX]; // { dg-error "size of array" } - p = new char [MAX][MAX / 2][MAX / 2]; // { dg-error "size of array" } - p = new char [MAX / 2][MAX / 2][MAX / 2]; // { dg-error "size of array" } + p = new char [MAX][MAX][MAX]; // { dg-error "size of unnamed array" } + p = new char [MAX][MAX][MAX / 2]; // { dg-error "size of unnamed array" } + p = new char [MAX][MAX / 2][MAX]; // { dg-error "size of unnamed array" } + p = new char [MAX][MAX / 2][MAX / 2]; // { dg-error "size of unnamed array" } + p = new char [MAX / 2][MAX / 2][MAX / 2]; // { dg-error "size of unnamed array" } } // Exercise new expression with N-dimensional arrays where N is @@ -342,10 +342,10 @@ test_one_dim_byte_array (void *p) static void __attribute__ ((used)) test_placement_two_dim_byte_struct_array (void *p) { - p = new (p) B [1][MAX]; // { dg-error "size of array" } - p = new (p) B [1][MAX - 1]; // { dg-error "size of array" } - p = new (p) B [1][MAX - 2]; // { dg-error "size of array" } - p = new (p) B [1][MAX - 99]; // { dg-error "size of array" } + p = new (p) B [1][MAX]; // { dg-error "size of unnamed array" } + p = new (p) B [1][MAX - 1]; // { dg-error "size of unnamed array" } + p = new (p) B [1][MAX - 2]; // { dg-error "size of unnamed array" } + p = new (p) B [1][MAX - 99]; // { dg-error "size of unnamed array" } p = new (p) B [1][MAX / 2]; // { dg-error "size of array" } p = new (p) B [1][MAX / 2 - 1]; // { dg-error "size of array" } p = new (p) B [1][MAX / 2 - 2]; // { dg-error "size of array" } @@ -359,18 +359,18 @@ test_placement_two_dim_byte_struct_array (void *p) p = new (p) B [1][MAX / 2 - 7]; // okay p = new (p) B [1][MAX / 2 - 8]; // okay - p = new (p) B [2][MAX]; // { dg-error "size of array" } - p = new (p) B [2][MAX - 1]; // { dg-error "size of array" } - p = new (p) B [2][MAX - 2]; // { dg-error "size of array" } + p = new (p) B [2][MAX]; // { dg-error "size of unnamed array" } + p = new (p) B [2][MAX - 1]; // { dg-error "size of unnamed array" } + p = new (p) B [2][MAX - 2]; // { dg-error "size of unnamed array" } p = new (p) B [2][MAX / 2]; // { dg-error "size of array" } p = new (p) B [2][MAX / 2 - 1]; // { dg-error "size of array" } p = new (p) B [2][MAX / 2 - 2]; // { dg-error "size of array" } p = new (p) B [2][MAX / 2 - 7]; // { dg-error "size of array" } p = new (p) B [2][MAX / 2 - 8]; // { dg-error "size of array" } - p = new (p) B [MAX][MAX]; // { dg-error "size of array" } - p = new (p) B [MAX][MAX - 1]; // { dg-error "size of array" } - p = new (p) B [MAX][MAX - 2]; // { dg-error "size of array" } + p = new (p) B [MAX][MAX]; // { dg-error "size of unnamed array" } + p = new (p) B [MAX][MAX - 1]; // { dg-error "size of unnamed array" } + p = new (p) B [MAX][MAX - 2]; // { dg-error "size of unnamed array" } p = new (p) B [MAX][MAX / 2]; // { dg-error "size of array" } p = new (p) B [MAX][MAX / 2 - 1]; // { dg-error "size of array" } p = new (p) B [MAX][MAX / 2 - 2]; // { dg-error "size of array" } @@ -397,10 +397,10 @@ test_placement_two_dim_byte_struct_array (void *p) static __attribute__ ((used)) void test_placement_three_dim_byte_struct_array (void *p) { - p = new (p) B [1][1][MAX]; // { dg-error "size of array" } - p = new (p) B [1][1][MAX - 1]; // { dg-error "size of array" } - p = new (p) B [1][1][MAX - 2]; // { dg-error "size of array" } - p = new (p) B [1][1][MAX - 99]; // { dg-error "size of array" } + p = new (p) B [1][1][MAX]; // { dg-error "size of unnamed array" } + p = new (p) B [1][1][MAX - 1]; // { dg-error "size of unnamed array" } + p = new (p) B [1][1][MAX - 2]; // { dg-error "size of unnamed array" } + p = new (p) B [1][1][MAX - 99]; // { dg-error "size of unnamed array" } p = new (p) B [1][1][MAX / 2]; // { dg-error "size of array" } p = new (p) B [1][1][MAX / 2 - 1]; // { dg-error "size of array" } p = new (p) B [1][1][MAX / 2 - 2]; // { dg-error "size of array" } @@ -414,19 +414,19 @@ test_placement_three_dim_byte_struct_array (void *p) p = new (p) B [1][1][MAX / 2 - 7]; // okay p = new (p) B [1][1][MAX / 2 - 8]; // okay - p = new (p) B [1][2][MAX]; // { dg-error "size of array" } - p = new (p) B [1][2][MAX - 1]; // { dg-error "size of array" } - p = new (p) B [1][2][MAX - 2]; // { dg-error "size of array" } - p = new (p) B [1][2][MAX - 99]; // { dg-error "size of array" } - p = new (p) B [1][2][MAX / 2]; // { dg-error "size of array" } - p = new (p) B [1][2][MAX / 2 - 1]; // { dg-error "size of array" } - p = new (p) B [1][2][MAX / 2 - 2]; // { dg-error "size of array" } - p = new (p) B [1][2][MAX / 2 - 3]; // { dg-error "size of array" } - p = new (p) B [1][2][MAX / 2 - 4]; // { dg-error "size of array" } - p = new (p) B [1][2][MAX / 2 - 5]; // { dg-error "size of array" } - p = new (p) B [1][2][MAX / 2 - 6]; // { dg-error "size of array" } - p = new (p) B [1][2][MAX / 2 - 7]; // { dg-error "size of array" } - p = new (p) B [1][2][MAX / 2 - 8]; // { dg-error "size of array" } + p = new (p) B [1][2][MAX]; // { dg-error "size of unnamed array" } + p = new (p) B [1][2][MAX - 1]; // { dg-error "size of unnamed array" } + p = new (p) B [1][2][MAX - 2]; // { dg-error "size of unnamed array" } + p = new (p) B [1][2][MAX - 99]; // { dg-error "size of unnamed array" } + p = new (p) B [1][2][MAX / 2]; // { dg-error "size of unnamed array" } + p = new (p) B [1][2][MAX / 2 - 1]; // { dg-error "size of unnamed array" } + p = new (p) B [1][2][MAX / 2 - 2]; // { dg-error "size of unnamed array" } + p = new (p) B [1][2][MAX / 2 - 3]; // { dg-error "size of unnamed array" } + p = new (p) B [1][2][MAX / 2 - 4]; // { dg-error "size of unnamed array" } + p = new (p) B [1][2][MAX / 2 - 5]; // { dg-error "size of unnamed array" } + p = new (p) B [1][2][MAX / 2 - 6]; // { dg-error "size of unnamed array" } + p = new (p) B [1][2][MAX / 2 - 7]; // { dg-error "size of unnamed array" } + p = new (p) B [1][2][MAX / 2 - 8]; // { dg-error "size of unnamed array" } p = new (p) B [1][2][MAX / 4]; // { dg-error "size of array" } // Avoid exercising data model-dependent expressions. @@ -436,10 +436,10 @@ test_placement_three_dim_byte_struct_array (void *p) p = new (p) B [1][2][MAX / 4 - 3]; // okay p = new (p) B [1][2][MAX / 4 - 4]; // okay - p = new (p) B [2][1][MAX]; // { dg-error "size of array" } - p = new (p) B [2][1][MAX - 1]; // { dg-error "size of array" } - p = new (p) B [2][1][MAX - 2]; // { dg-error "size of array" } - p = new (p) B [2][1][MAX - 99]; // { dg-error "size of array" } + p = new (p) B [2][1][MAX]; // { dg-error "size of unnamed array" } + p = new (p) B [2][1][MAX - 1]; // { dg-error "size of unnamed array" } + p = new (p) B [2][1][MAX - 2]; // { dg-error "size of unnamed array" } + p = new (p) B [2][1][MAX - 99]; // { dg-error "size of unnamed array" } p = new (p) B [2][1][MAX / 2]; // { dg-error "size of array" } p = new (p) B [2][1][MAX / 2 - 1]; // { dg-error "size of array" } p = new (p) B [2][1][MAX / 2 - 2]; // { dg-error "size of array" } @@ -458,19 +458,19 @@ test_placement_three_dim_byte_struct_array (void *p) p = new (p) B [2][1][MAX / 4 - 3]; // okay p = new (p) B [2][1][MAX / 4 - 4]; // okay - p = new (p) B [2][2][MAX]; // { dg-error "size of array" } - p = new (p) B [2][2][MAX - 1]; // { dg-error "size of array" } - p = new (p) B [2][2][MAX - 2]; // { dg-error "size of array" } - p = new (p) B [2][2][MAX - 99]; // { dg-error "size of array" } - p = new (p) B [2][2][MAX / 2]; // { dg-error "size of array" } - p = new (p) B [2][2][MAX / 2 - 1]; // { dg-error "size of array" } - p = new (p) B [2][2][MAX / 2 - 2]; // { dg-error "size of array" } - p = new (p) B [2][2][MAX / 2 - 3]; // { dg-error "size of array" } - p = new (p) B [2][2][MAX / 2 - 4]; // { dg-error "size of array" } - p = new (p) B [2][2][MAX / 2 - 5]; // { dg-error "size of array" } - p = new (p) B [2][2][MAX / 2 - 6]; // { dg-error "size of array" } - p = new (p) B [2][2][MAX / 2 - 7]; // { dg-error "size of array" } - p = new (p) B [2][2][MAX / 2 - 8]; // { dg-error "size of array" } + p = new (p) B [2][2][MAX]; // { dg-error "size of unnamed array" } + p = new (p) B [2][2][MAX - 1]; // { dg-error "size of unnamed array" } + p = new (p) B [2][2][MAX - 2]; // { dg-error "size of unnamed array" } + p = new (p) B [2][2][MAX - 99]; // { dg-error "size of unnamed array" } + p = new (p) B [2][2][MAX / 2]; // { dg-error "size of unnamed array" } + p = new (p) B [2][2][MAX / 2 - 1]; // { dg-error "size of unnamed array" } + p = new (p) B [2][2][MAX / 2 - 2]; // { dg-error "size of unnamed array" } + p = new (p) B [2][2][MAX / 2 - 3]; // { dg-error "size of unnamed array" } + p = new (p) B [2][2][MAX / 2 - 4]; // { dg-error "size of unnamed array" } + p = new (p) B [2][2][MAX / 2 - 5]; // { dg-error "size of unnamed array" } + p = new (p) B [2][2][MAX / 2 - 6]; // { dg-error "size of unnamed array" } + p = new (p) B [2][2][MAX / 2 - 7]; // { dg-error "size of unnamed array" } + p = new (p) B [2][2][MAX / 2 - 8]; // { dg-error "size of unnamed array" } p = new (p) B [2][2][MAX / 4]; // { dg-error "size of array" } p = new (p) B [2][2][MAX / 4 - 1]; // { dg-error "size of array" } p = new (p) B [2][2][MAX / 4 - 2]; // { dg-error "size of array" } @@ -482,19 +482,19 @@ test_placement_three_dim_byte_struct_array (void *p) p = new (p) B [2][2][MAX / 8 - 2]; p = new (p) B [2][2][MAX / 8 - 3]; - p = new (p) B [2][MAX][2]; // { dg-error "size of array" } - p = new (p) B [2][MAX - 1][2]; // { dg-error "size of array" } - p = new (p) B [2][MAX - 2][2]; // { dg-error "size of array" } - p = new (p) B [2][MAX - 99][2]; // { dg-error "size of array" } - p = new (p) B [2][MAX / 2][2]; // { dg-error "size of array" } - p = new (p) B [2][MAX / 2 - 1][2]; // { dg-error "size of array" } - p = new (p) B [2][MAX / 2 - 2][2]; // { dg-error "size of array" } - p = new (p) B [2][MAX / 2 - 3][2]; // { dg-error "size of array" } - p = new (p) B [2][MAX / 2 - 4][2]; // { dg-error "size of array" } - p = new (p) B [2][MAX / 2 - 5][2]; // { dg-error "size of array" } - p = new (p) B [2][MAX / 2 - 6][2]; // { dg-error "size of array" } - p = new (p) B [2][MAX / 2 - 7][2]; // { dg-error "size of array" } - p = new (p) B [2][MAX / 2 - 8][2]; // { dg-error "size of array" } + p = new (p) B [2][MAX][2]; // { dg-error "size of unnamed array" } + p = new (p) B [2][MAX - 1][2]; // { dg-error "size of unnamed array" } + p = new (p) B [2][MAX - 2][2]; // { dg-error "size of unnamed array" } + p = new (p) B [2][MAX - 99][2]; // { dg-error "size of unnamed array" } + p = new (p) B [2][MAX / 2][2]; // { dg-error "size of unnamed array" } + p = new (p) B [2][MAX / 2 - 1][2]; // { dg-error "size of unnamed array" } + p = new (p) B [2][MAX / 2 - 2][2]; // { dg-error "size of unnamed array" } + p = new (p) B [2][MAX / 2 - 3][2]; // { dg-error "size of unnamed array" } + p = new (p) B [2][MAX / 2 - 4][2]; // { dg-error "size of unnamed array" } + p = new (p) B [2][MAX / 2 - 5][2]; // { dg-error "size of unnamed array" } + p = new (p) B [2][MAX / 2 - 6][2]; // { dg-error "size of unnamed array" } + p = new (p) B [2][MAX / 2 - 7][2]; // { dg-error "size of unnamed array" } + p = new (p) B [2][MAX / 2 - 8][2]; // { dg-error "size of unnamed array" } p = new (p) B [2][MAX / 4][2]; // { dg-error "size of array" } p = new (p) B [2][MAX / 4 - 1][2]; // { dg-error "size of array" } p = new (p) B [2][MAX / 4 - 2][2]; // { dg-error "size of array" } diff --git a/gcc/tree-vect-data-refs.c b/gcc/tree-vect-data-refs.c index 87936ddee1d..f7471b8a75e 100644 --- a/gcc/tree-vect-data-refs.c +++ b/gcc/tree-vect-data-refs.c @@ -645,6 +645,7 @@ vect_slp_analyze_data_ref_dependences (bb_vec_info bb_vinfo) (SLP_INSTANCE_TREE (instance))[0], 0); vect_free_slp_instance (instance); BB_VINFO_SLP_INSTANCES (bb_vinfo).ordered_remove (i); + continue; } i++; } @@ -668,7 +669,7 @@ vect_slp_analyze_data_ref_dependences (bb_vec_info bb_vinfo) FOR NOW: No analysis is actually performed. Misalignment is calculated only for trivial cases. TODO. */ -static bool +bool vect_compute_data_ref_alignment (struct data_reference *dr) { gimple *stmt = DR_STMT (dr); @@ -838,45 +839,6 @@ vect_compute_data_ref_alignment (struct data_reference *dr) } -/* Function vect_compute_data_refs_alignment - - Compute the misalignment of data references in the loop. - Return FALSE if a data reference is found that cannot be vectorized. */ - -static bool -vect_compute_data_refs_alignment (vec_info *vinfo) -{ - vec<data_reference_p> datarefs = vinfo->datarefs; - struct data_reference *dr; - unsigned int i; - - FOR_EACH_VEC_ELT (datarefs, i, dr) - { - stmt_vec_info stmt_info = vinfo_for_stmt (DR_STMT (dr)); - if (STMT_VINFO_VECTORIZABLE (stmt_info) - && !vect_compute_data_ref_alignment (dr)) - { - /* Strided accesses perform only component accesses, misalignment - information is irrelevant for them. */ - if (STMT_VINFO_STRIDED_P (stmt_info) - && !STMT_VINFO_GROUPED_ACCESS (stmt_info)) - continue; - - if (is_a <bb_vec_info> (vinfo)) - { - /* Mark unsupported statement as unvectorizable. */ - STMT_VINFO_VECTORIZABLE (vinfo_for_stmt (DR_STMT (dr))) = false; - continue; - } - else - return false; - } - } - - return true; -} - - /* Function vect_update_misalignment_for_peel DR - the data reference whose misalignment is to be adjusted. @@ -936,63 +898,76 @@ vect_update_misalignment_for_peel (struct data_reference *dr, } +/* Function verify_data_ref_alignment + + Return TRUE if DR can be handled with respect to alignment. */ + +static bool +verify_data_ref_alignment (data_reference_p dr) +{ + enum dr_alignment_support supportable_dr_alignment; + gimple *stmt = DR_STMT (dr); + stmt_vec_info stmt_info = vinfo_for_stmt (stmt); + + if (!STMT_VINFO_RELEVANT_P (stmt_info)) + return true; + + /* For interleaving, only the alignment of the first access matters. + Skip statements marked as not vectorizable. */ + if ((STMT_VINFO_GROUPED_ACCESS (stmt_info) + && GROUP_FIRST_ELEMENT (stmt_info) != stmt) + || !STMT_VINFO_VECTORIZABLE (stmt_info)) + return true; + + /* Strided accesses perform only component accesses, alignment is + irrelevant for them. */ + if (STMT_VINFO_STRIDED_P (stmt_info) + && !STMT_VINFO_GROUPED_ACCESS (stmt_info)) + return true; + + supportable_dr_alignment = vect_supportable_dr_alignment (dr, false); + if (!supportable_dr_alignment) + { + if (dump_enabled_p ()) + { + if (DR_IS_READ (dr)) + dump_printf_loc (MSG_MISSED_OPTIMIZATION, vect_location, + "not vectorized: unsupported unaligned load."); + else + dump_printf_loc (MSG_MISSED_OPTIMIZATION, vect_location, + "not vectorized: unsupported unaligned " + "store."); + + dump_generic_expr (MSG_MISSED_OPTIMIZATION, TDF_SLIM, + DR_REF (dr)); + dump_printf (MSG_MISSED_OPTIMIZATION, "\n"); + } + return false; + } + + if (supportable_dr_alignment != dr_aligned && dump_enabled_p ()) + dump_printf_loc (MSG_NOTE, vect_location, + "Vectorizing an unaligned access.\n"); + + return true; +} + /* Function vect_verify_datarefs_alignment Return TRUE if all data references in the loop can be handled with respect to alignment. */ bool -vect_verify_datarefs_alignment (vec_info *vinfo) +vect_verify_datarefs_alignment (loop_vec_info vinfo) { vec<data_reference_p> datarefs = vinfo->datarefs; struct data_reference *dr; - enum dr_alignment_support supportable_dr_alignment; unsigned int i; FOR_EACH_VEC_ELT (datarefs, i, dr) - { - gimple *stmt = DR_STMT (dr); - stmt_vec_info stmt_info = vinfo_for_stmt (stmt); - - if (!STMT_VINFO_RELEVANT_P (stmt_info)) - continue; - - /* For interleaving, only the alignment of the first access matters. - Skip statements marked as not vectorizable. */ - if ((STMT_VINFO_GROUPED_ACCESS (stmt_info) - && GROUP_FIRST_ELEMENT (stmt_info) != stmt) - || !STMT_VINFO_VECTORIZABLE (stmt_info)) - continue; - - /* Strided accesses perform only component accesses, alignment is - irrelevant for them. */ - if (STMT_VINFO_STRIDED_P (stmt_info) - && !STMT_VINFO_GROUPED_ACCESS (stmt_info)) - continue; - - supportable_dr_alignment = vect_supportable_dr_alignment (dr, false); - if (!supportable_dr_alignment) - { - if (dump_enabled_p ()) - { - if (DR_IS_READ (dr)) - dump_printf_loc (MSG_MISSED_OPTIMIZATION, vect_location, - "not vectorized: unsupported unaligned load."); - else - dump_printf_loc (MSG_MISSED_OPTIMIZATION, vect_location, - "not vectorized: unsupported unaligned " - "store."); + if (! verify_data_ref_alignment (dr)) + return false; - dump_generic_expr (MSG_MISSED_OPTIMIZATION, TDF_SLIM, - DR_REF (dr)); - dump_printf (MSG_MISSED_OPTIMIZATION, "\n"); - } - return false; - } - if (supportable_dr_alignment != dr_aligned && dump_enabled_p ()) - dump_printf_loc (MSG_NOTE, vect_location, - "Vectorizing an unaligned access.\n"); - } return true; } @@ -2064,7 +2039,7 @@ vect_find_same_alignment_drs (struct data_dependence_relation *ddr, Return FALSE if a data reference is found that cannot be vectorized. */ bool -vect_analyze_data_refs_alignment (vec_info *vinfo) +vect_analyze_data_refs_alignment (loop_vec_info vinfo) { if (dump_enabled_p ()) dump_printf_loc (MSG_NOTE, vect_location, @@ -2072,28 +2047,100 @@ vect_analyze_data_refs_alignment (vec_info *vinfo) /* Mark groups of data references with same alignment using data dependence information. */ - if (is_a <loop_vec_info> (vinfo)) + vec<ddr_p> ddrs = vinfo->ddrs; + struct data_dependence_relation *ddr; + unsigned int i; + + FOR_EACH_VEC_ELT (ddrs, i, ddr) + vect_find_same_alignment_drs (ddr, vinfo); + + vec<data_reference_p> datarefs = vinfo->datarefs; + struct data_reference *dr; + + FOR_EACH_VEC_ELT (datarefs, i, dr) { - vec<ddr_p> ddrs = vinfo->ddrs; - struct data_dependence_relation *ddr; - unsigned int i; + stmt_vec_info stmt_info = vinfo_for_stmt (DR_STMT (dr)); + if (STMT_VINFO_VECTORIZABLE (stmt_info) + && !vect_compute_data_ref_alignment (dr)) + { + /* Strided accesses perform only component accesses, misalignment + information is irrelevant for them. */ + if (STMT_VINFO_STRIDED_P (stmt_info) + && !STMT_VINFO_GROUPED_ACCESS (stmt_info)) + continue; + + if (dump_enabled_p ()) + dump_printf_loc (MSG_MISSED_OPTIMIZATION, vect_location, + "not vectorized: can't calculate alignment " + "for data ref.\n"); - FOR_EACH_VEC_ELT (ddrs, i, ddr) - vect_find_same_alignment_drs (ddr, as_a <loop_vec_info> (vinfo)); + return false; + } } - if (!vect_compute_data_refs_alignment (vinfo)) + return true; +} + + +/* Analyze alignment of DRs of stmts in NODE. */ + +static bool +vect_slp_analyze_and_verify_node_alignment (slp_tree node) +{ + unsigned i; + gimple *stmt; + FOR_EACH_VEC_ELT (SLP_TREE_SCALAR_STMTS (node), i, stmt) { - if (dump_enabled_p ()) - dump_printf_loc (MSG_MISSED_OPTIMIZATION, vect_location, - "not vectorized: can't calculate alignment " - "for data ref.\n"); - return false; + stmt_vec_info stmt_info = vinfo_for_stmt (stmt); + + /* Strided accesses perform only component accesses, misalignment + information is irrelevant for them. */ + if (STMT_VINFO_STRIDED_P (stmt_info) + && !STMT_VINFO_GROUPED_ACCESS (stmt_info)) + continue; + + data_reference_p dr = STMT_VINFO_DATA_REF (stmt_info); + if (! vect_compute_data_ref_alignment (dr) + || ! verify_data_ref_alignment (dr)) + { + if (dump_enabled_p ()) + dump_printf_loc (MSG_MISSED_OPTIMIZATION, vect_location, + "not vectorized: bad data alignment in basic " + "block.\n"); + return false; + } } return true; } +/* Function vect_slp_analyze_instance_alignment + + Analyze the alignment of the data-references in the SLP instance. + Return FALSE if a data reference is found that cannot be vectorized. */ + +bool +vect_slp_analyze_and_verify_instance_alignment (slp_instance instance) +{ + if (dump_enabled_p ()) + dump_printf_loc (MSG_NOTE, vect_location, + "=== vect_slp_analyze_and_verify_instance_alignment ===\n"); + + slp_tree node; + unsigned i; + FOR_EACH_VEC_ELT (SLP_INSTANCE_LOADS (instance), i, node) + if (! vect_slp_analyze_and_verify_node_alignment (node)) + return false; + + node = SLP_INSTANCE_TREE (instance); + if (STMT_VINFO_DATA_REF (vinfo_for_stmt (SLP_TREE_SCALAR_STMTS (node)[0])) + && ! vect_slp_analyze_and_verify_node_alignment + (SLP_INSTANCE_TREE (instance))) + return false; + + return true; +} + /* Analyze groups of accesses: check that DR belongs to a group of accesses of legal size, step, etc. Detect gaps, single element diff --git a/gcc/tree-vect-slp.c b/gcc/tree-vect-slp.c index fe838282777..8c125962b87 100644 --- a/gcc/tree-vect-slp.c +++ b/gcc/tree-vect-slp.c @@ -1300,8 +1300,7 @@ vect_supported_load_permutation_p (slp_instance slp_instn) unsigned int group_size = SLP_INSTANCE_GROUP_SIZE (slp_instn); unsigned int i, j, k, next; slp_tree node; - gimple *stmt, *load, *next_load, *first_load; - struct data_reference *dr; + gimple *stmt, *load, *next_load; if (dump_enabled_p ()) { @@ -1383,33 +1382,6 @@ vect_supported_load_permutation_p (slp_instance slp_instn) } } } - - /* Check that the alignment of the first load in every subchain, i.e., - the first statement in every load node, is supported. - ??? This belongs in alignment checking. */ - FOR_EACH_VEC_ELT (SLP_INSTANCE_LOADS (slp_instn), i, node) - { - first_load = SLP_TREE_SCALAR_STMTS (node)[0]; - if (first_load != GROUP_FIRST_ELEMENT (vinfo_for_stmt (first_load))) - { - dr = STMT_VINFO_DATA_REF (vinfo_for_stmt (first_load)); - if (vect_supportable_dr_alignment (dr, false) - == dr_unaligned_unsupported) - { - if (dump_enabled_p ()) - { - dump_printf_loc (MSG_MISSED_OPTIMIZATION, - vect_location, - "unsupported unaligned load "); - dump_gimple_stmt (MSG_MISSED_OPTIMIZATION, TDF_SLIM, - first_load, 0); - dump_printf (MSG_MISSED_OPTIMIZATION, "\n"); - } - return false; - } - } - } - return true; } @@ -2329,12 +2301,15 @@ vect_bb_vectorization_profitable_p (bb_vec_info bb_vinfo) return true; } -/* Check if the basic block can be vectorized. */ +/* Check if the basic block can be vectorized. Returns a bb_vec_info + if so and sets fatal to true if failure is independent of + current_vector_size. */ static bb_vec_info vect_slp_analyze_bb_1 (gimple_stmt_iterator region_begin, gimple_stmt_iterator region_end, - vec<data_reference_p> datarefs, int n_stmts) + vec<data_reference_p> datarefs, int n_stmts, + bool &fatal) { bb_vec_info bb_vinfo; vec<slp_instance> slp_instances; @@ -2342,6 +2317,9 @@ vect_slp_analyze_bb_1 (gimple_stmt_iterator region_begin, int i; int min_vf = 2; + /* The first group of checks is independent of the vector size. */ + fatal = true; + if (n_stmts > PARAM_VALUE (PARAM_SLP_MAX_INSNS_IN_BB)) { if (dump_enabled_p ()) @@ -2393,19 +2371,25 @@ vect_slp_analyze_bb_1 (gimple_stmt_iterator region_begin, return NULL; } - vect_pattern_recog (bb_vinfo); - - if (!vect_analyze_data_refs_alignment (bb_vinfo)) + /* If there are no grouped stores in the region there is no need + to continue with pattern recog as vect_analyze_slp will fail + anyway. */ + if (bb_vinfo->grouped_stores.is_empty ()) { if (dump_enabled_p ()) - dump_printf_loc (MSG_MISSED_OPTIMIZATION, vect_location, - "not vectorized: bad data alignment in basic " - "block.\n"); + dump_printf_loc (MSG_MISSED_OPTIMIZATION, vect_location, + "not vectorized: no grouped stores in " + "basic block.\n"); destroy_bb_vec_info (bb_vinfo); return NULL; } + /* While the rest of the analysis below depends on it in some way. */ + fatal = false; + + vect_pattern_recog (bb_vinfo); + /* Check the SLP opportunities in the basic block, analyze and build SLP trees. */ if (!vect_analyze_slp (bb_vinfo, n_stmts)) @@ -2423,6 +2407,30 @@ vect_slp_analyze_bb_1 (gimple_stmt_iterator region_begin, return NULL; } + /* Analyze and verify the alignment of data references in the SLP + instances. */ + for (i = 0; BB_VINFO_SLP_INSTANCES (bb_vinfo).iterate (i, &instance); ) + { + if (! vect_slp_analyze_and_verify_instance_alignment (instance)) + { + dump_printf_loc (MSG_NOTE, vect_location, + "removing SLP instance operations starting from: "); + dump_gimple_stmt (MSG_NOTE, TDF_SLIM, + SLP_TREE_SCALAR_STMTS + (SLP_INSTANCE_TREE (instance))[0], 0); + vect_free_slp_instance (instance); + BB_VINFO_SLP_INSTANCES (bb_vinfo).ordered_remove (i); + continue; + } + i++; + } + + if (! BB_VINFO_SLP_INSTANCES (bb_vinfo).length ()) + { + destroy_bb_vec_info (bb_vinfo); + return NULL; + } + slp_instances = BB_VINFO_SLP_INSTANCES (bb_vinfo); /* Mark all the statements that we want to vectorize as pure SLP and @@ -2445,23 +2453,13 @@ vect_slp_analyze_bb_1 (gimple_stmt_iterator region_begin, /* Analyze dependences. At this point all stmts not participating in vectorization have to be marked. Dependence analysis assumes that we either vectorize all SLP instances or none at all. */ - if (!vect_slp_analyze_data_ref_dependences (bb_vinfo)) - { - if (dump_enabled_p ()) - dump_printf_loc (MSG_MISSED_OPTIMIZATION, vect_location, - "not vectorized: unhandled data dependence " - "in basic block.\n"); - - destroy_bb_vec_info (bb_vinfo); - return NULL; - } - - if (!vect_verify_datarefs_alignment (bb_vinfo)) + if (! vect_slp_analyze_data_ref_dependences (bb_vinfo)) { if (dump_enabled_p ()) - dump_printf_loc (MSG_MISSED_OPTIMIZATION, vect_location, - "not vectorized: unsupported alignment in basic " - "block.\n"); + dump_printf_loc (MSG_MISSED_OPTIMIZATION, vect_location, + "not vectorized: unhandled data dependence " + "in basic block.\n"); + destroy_bb_vec_info (bb_vinfo); return NULL; } @@ -2551,8 +2549,9 @@ vect_slp_bb (basic_block bb) gimple_stmt_iterator region_end = gsi; bool vectorized = false; + bool fatal = false; bb_vinfo = vect_slp_analyze_bb_1 (region_begin, region_end, - datarefs, insns); + datarefs, insns, fatal); if (bb_vinfo && dbg_cnt (vect_slp)) { @@ -2577,7 +2576,10 @@ vect_slp_bb (basic_block bb) vector_sizes &= ~current_vector_size; if (vectorized || vector_sizes == 0 - || current_vector_size == 0) + || current_vector_size == 0 + /* If vect_slp_analyze_bb_1 signaled that analysis for all + vector sizes will fail do not bother iterating. */ + || fatal) { if (gsi_end_p (region_end)) break; diff --git a/gcc/tree-vectorizer.h b/gcc/tree-vectorizer.h index 45c2d9bbbe1..878bfd59077 100644 --- a/gcc/tree-vectorizer.h +++ b/gcc/tree-vectorizer.h @@ -1011,8 +1011,9 @@ extern tree vect_get_smallest_scalar_type (gimple *, HOST_WIDE_INT *, extern bool vect_analyze_data_ref_dependences (loop_vec_info, int *); extern bool vect_slp_analyze_data_ref_dependences (bb_vec_info); extern bool vect_enhance_data_refs_alignment (loop_vec_info); -extern bool vect_analyze_data_refs_alignment (vec_info *); -extern bool vect_verify_datarefs_alignment (vec_info *); +extern bool vect_analyze_data_refs_alignment (loop_vec_info); +extern bool vect_verify_datarefs_alignment (loop_vec_info); +extern bool vect_slp_analyze_and_verify_instance_alignment (slp_instance); extern bool vect_analyze_data_ref_accesses (vec_info *); extern bool vect_prune_runtime_alias_test_list (loop_vec_info); extern tree vect_check_gather_scatter (gimple *, loop_vec_info, tree *, tree *, diff --git a/libstdc++-v3/ChangeLog b/libstdc++-v3/ChangeLog index 960a56ca186..3506c0e419d 100644 --- a/libstdc++-v3/ChangeLog +++ b/libstdc++-v3/ChangeLog @@ -1,3 +1,14 @@ +2015-11-11 Ville Voutilainen <ville.voutilainen@gmail.com> + + LWG 2510, make the default constructors of library tag types + explicit. + * include/bits/mutex.h (defer_lock_t, try_lock_t, + adopt_lock_t): Add an explicit default constructor. + * include/bits/stl_pair.h (piecewise_construct_t): Likewise. + * include/bits/uses_allocator.h (allocator_arg_t): Likewise. + * libsupc++/new (nothrow_t): Likewise. + * testsuite/17_intro/tag_type_explicit_ctor.cc: New. + 2015-11-11 Jonathan Wakely <jwakely@redhat.com> PR libstdc++/64651 diff --git a/libstdc++-v3/include/bits/mutex.h b/libstdc++-v3/include/bits/mutex.h index 43f5b0b2d60..dd279899ee9 100644 --- a/libstdc++-v3/include/bits/mutex.h +++ b/libstdc++-v3/include/bits/mutex.h @@ -129,14 +129,14 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION #endif // _GLIBCXX_HAS_GTHREADS /// Do not acquire ownership of the mutex. - struct defer_lock_t { }; + struct defer_lock_t { explicit defer_lock_t() = default; }; /// Try to acquire ownership of the mutex without blocking. - struct try_to_lock_t { }; + struct try_to_lock_t { explicit try_to_lock_t() = default; }; /// Assume the calling thread has already obtained mutex ownership /// and manage it. - struct adopt_lock_t { }; + struct adopt_lock_t { explicit adopt_lock_t() = default; }; constexpr defer_lock_t defer_lock { }; constexpr try_to_lock_t try_to_lock { }; diff --git a/libstdc++-v3/include/bits/stl_pair.h b/libstdc++-v3/include/bits/stl_pair.h index dfcd357fb3c..d6f6b86bd4c 100644 --- a/libstdc++-v3/include/bits/stl_pair.h +++ b/libstdc++-v3/include/bits/stl_pair.h @@ -73,7 +73,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION #if __cplusplus >= 201103L /// piecewise_construct_t - struct piecewise_construct_t { }; + struct piecewise_construct_t { explicit piecewise_construct_t() = default; }; /// piecewise_construct constexpr piecewise_construct_t piecewise_construct = piecewise_construct_t(); diff --git a/libstdc++-v3/include/bits/uses_allocator.h b/libstdc++-v3/include/bits/uses_allocator.h index f9ea7d68ec9..a0f084d9aa9 100644 --- a/libstdc++-v3/include/bits/uses_allocator.h +++ b/libstdc++-v3/include/bits/uses_allocator.h @@ -36,7 +36,7 @@ namespace std _GLIBCXX_VISIBILITY(default) _GLIBCXX_BEGIN_NAMESPACE_VERSION /// [allocator.tag] - struct allocator_arg_t { }; + struct allocator_arg_t { explicit allocator_arg_t() = default; }; constexpr allocator_arg_t allocator_arg = allocator_arg_t(); diff --git a/libstdc++-v3/libsupc++/new b/libstdc++-v3/libsupc++/new index 0f6a05a9b71..8621f73d5c2 100644 --- a/libstdc++-v3/libsupc++/new +++ b/libstdc++-v3/libsupc++/new @@ -79,7 +79,12 @@ namespace std }; #endif - struct nothrow_t { }; + struct nothrow_t + { +#if __cplusplus >= 201103L + explicit nothrow_t() = default; +#endif + }; extern const nothrow_t nothrow; diff --git a/libstdc++-v3/testsuite/17_intro/tag_type_explicit_ctor.cc b/libstdc++-v3/testsuite/17_intro/tag_type_explicit_ctor.cc new file mode 100644 index 00000000000..4b9d217ccdb --- /dev/null +++ b/libstdc++-v3/testsuite/17_intro/tag_type_explicit_ctor.cc @@ -0,0 +1,60 @@ +// { dg-do compile } +// { dg-options "-std=gnu++11" } + +// Copyright (C) 2015 Free Software Foundation, Inc. +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 3, or (at your option) +// any later version. +// +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. +// +// You should have received a copy of the GNU General Public License along +// with this library; see the file COPYING3. If not see +// <http://www.gnu.org/licenses/>. + +#include <new> +#include <utility> +#include <memory> +#include <mutex> + +void f1(std::nothrow_t); +void f2(std::piecewise_construct_t); +void f3(std::allocator_arg_t); +void f4(std::defer_lock_t); +void f5(std::try_to_lock_t); +void f6(std::adopt_lock_t); + + +int main() +{ + std::nothrow_t v1; + std::piecewise_construct_t v2; + std::allocator_arg_t v3; + std::defer_lock_t v4; + std::try_to_lock_t v5; + std::try_to_lock_t v6; + std::nothrow_t v7 = {}; // { dg-error "explicit" } + std::piecewise_construct_t v8 = {}; // { dg-error "explicit" } + std::allocator_arg_t v9 = {}; // { dg-error "explicit" } + std::defer_lock_t v10 = {}; // { dg-error "explicit" } + std::try_to_lock_t v11 = {}; // { dg-error "explicit" } + std::try_to_lock_t v12 = {}; // { dg-error "explicit" } + f1(std::nothrow_t{}); + f2(std::piecewise_construct_t{}); + f3(std::allocator_arg_t{}); + f4(std::defer_lock_t{}); + f5(std::try_to_lock_t{}); + f6(std::adopt_lock_t{}); + f1({}); // { dg-error "explicit" } + f2({}); // { dg-error "explicit" } + f3({}); // { dg-error "explicit" } + f4({}); // { dg-error "explicit" } + f5({}); // { dg-error "explicit" } + f6({}); // { dg-error "explicit" } +} |