From be7c145ad52e76a1a0fd201dd96bc92e8d3a275d Mon Sep 17 00:00:00 2001 From: Jakub Jelinek Date: Tue, 18 Feb 2020 09:07:15 +0100 Subject: [PATCH] tree-ssa: Fix ICE in build_vector_type [PR93780] The following testcase ICEs, because execute_update_addresses_taken attempts to create a VECTOR_TYPE with non-power of 2 number of elts. Fixed by guarding it with the corresponding predicate. 2020-02-18 Jakub Jelinek PR tree-optimization/93780 * tree-ssa.c (non_rewritable_lvalue_p): Check valid_vector_subparts_p before calling build_vector_type. (execute_update_addresses_taken): Likewise. * gcc.dg/pr93780.c: New test. --- gcc/ChangeLog | 5 +++++ gcc/testsuite/ChangeLog | 7 ++++++- gcc/testsuite/gcc.dg/pr93780.c | 15 +++++++++++++++ gcc/tree-ssa.c | 6 ++++-- 4 files changed, 30 insertions(+), 3 deletions(-) create mode 100644 gcc/testsuite/gcc.dg/pr93780.c diff --git a/gcc/ChangeLog b/gcc/ChangeLog index e8eaf7efd12..99d32c04bfb 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -1,5 +1,10 @@ 2020-02-18 Jakub Jelinek + PR tree-optimization/93780 + * tree-ssa.c (non_rewritable_lvalue_p): Check valid_vector_subparts_p + before calling build_vector_type. + (execute_update_addresses_taken): Likewise. + PR driver/93796 * params.opt (-param=ipa-max-switch-predicate-bounds=): Fix help typo, functoin -> function. diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index 0e7d7bcc4b8..8f2c5b0795e 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,9 +1,14 @@ +2020-02-18 Jakub Jelinek + + PR tree-optimization/93780 + * gcc.dg/pr93780.c: New test. + 2020-02-17 David Malcolm PR analyzer/93775 * gcc.dg/analyzer/20020129-1.c: New test. -2020-02-17 Alexandre Oliva +2020-02-17 Alexandre Oliva * gcc.dg/tls/emutls-3.c: New, combining emutls-2.c and thr-init-2.c into an execution test with explicitly common diff --git a/gcc/testsuite/gcc.dg/pr93780.c b/gcc/testsuite/gcc.dg/pr93780.c new file mode 100644 index 00000000000..d476df69b51 --- /dev/null +++ b/gcc/testsuite/gcc.dg/pr93780.c @@ -0,0 +1,15 @@ +/* PR tree-optimization/93780 */ +/* { dg-do compile } */ +/* { dg-options "-O2" } */ +/* { dg-additional-options "-mavx" { target avx } } */ + +typedef float V __attribute__((vector_size (32))); + +float +foo (void) +{ + const float init[6] = {}; + V v = {}; + __builtin_memcpy (&v, init, sizeof (init)); + return v[0]; +} diff --git a/gcc/tree-ssa.c b/gcc/tree-ssa.c index dbff6045145..344f32d69cf 100644 --- a/gcc/tree-ssa.c +++ b/gcc/tree-ssa.c @@ -1550,7 +1550,8 @@ non_rewritable_lvalue_p (tree lhs) && multiple_p (lhs_bits, tree_to_uhwi (TYPE_SIZE (TREE_TYPE (TREE_TYPE (decl)))), - &nelts)) + &nelts) + && valid_vector_subparts_p (nelts)) { if (known_eq (nelts, 1u)) return false; @@ -1925,7 +1926,8 @@ execute_update_addresses_taken (void) (TYPE_SIZE (TREE_TYPE (TREE_TYPE (sym)))), &nelts) - && maybe_ne (nelts, 1u)) + && maybe_ne (nelts, 1u) + && valid_vector_subparts_p (nelts)) temtype = build_vector_type (temtype, nelts); tree tem = make_ssa_name (temtype); gimple *pun -- 2.30.2