From 711421af001b8f4f044f485c78f1d07ed5201656 Mon Sep 17 00:00:00 2001 From: Richard Sandiford Date: Tue, 14 Jan 2020 22:24:37 +0000 Subject: [PATCH] PR tree-optimization/93247 - ICE in get_load_store_type My earlier update_epilogue_loop_vinfo patch introduced an ICE on these tests for AVX512. If we use pattern stmts, STMT_VINFO_GATHER_SCATTER_P is valid for both the original stmt and the pattern stmt, but STMT_VINFO_MEMORY_ACCESS_TYPE is valid only for the latter. 2020-01-15 Richard Sandiford gcc/ PR tree-optimization/93247 * tree-vect-loop.c (update_epilogue_loop_vinfo): Check the access type of the stmt that we're going to vectorize. gcc/testsuite/ PR tree-optimization/93247 * gcc.dg/vect/pr93247-1.c: New test. * gcc.dg/vect/pr93247-2.c: Likewise. --- gcc/ChangeLog | 6 ++++ gcc/testsuite/ChangeLog | 6 ++++ gcc/testsuite/gcc.dg/vect/pr93247-1.c | 49 +++++++++++++++++++++++++++ gcc/testsuite/gcc.dg/vect/pr93247-2.c | 12 +++++++ gcc/tree-vect-loop.c | 3 +- 5 files changed, 75 insertions(+), 1 deletion(-) create mode 100644 gcc/testsuite/gcc.dg/vect/pr93247-1.c create mode 100644 gcc/testsuite/gcc.dg/vect/pr93247-2.c diff --git a/gcc/ChangeLog b/gcc/ChangeLog index aa161fdd9bc..3099ec4143c 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -1,3 +1,9 @@ +2020-01-15 Richard Sandiford + + PR tree-optimization/93247 + * tree-vect-loop.c (update_epilogue_loop_vinfo): Check the access + type of the stmt that we're going to vectorize. + 2020-01-15 Richard Sandiford * tree-vect-slp.c (vectorize_slp_instance_root_stmt): Use a diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index dc1952b2d18..0f0f1778719 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,9 @@ +2020-01-15 Richard Sandiford + + PR tree-optimization/93247 + * gcc.dg/vect/pr93247-1.c: New test. + * gcc.dg/vect/pr93247-2.c: Likewise. + 2020-01-15 Martin Sebor * gcc.dg/Wstringop-overflow-17.c: Tweak test to avoid unrelated diff --git a/gcc/testsuite/gcc.dg/vect/pr93247-1.c b/gcc/testsuite/gcc.dg/vect/pr93247-1.c new file mode 100644 index 00000000000..a3087b81d67 --- /dev/null +++ b/gcc/testsuite/gcc.dg/vect/pr93247-1.c @@ -0,0 +1,49 @@ +/* { dg-do compile } */ +/* { dg-additional-options "-march=skylake" { target x86_64-*-* i?86-*-* } } */ + +typedef struct { + unsigned num; +} VEC_tree_base; + +enum { + LTO_DECL_STREAM_NAMESPACE_DECL, + LTO_DECL_STREAM_LABEL_DECL, + LTO_N_DECL_STREAMS +}; + +struct lto_tree_ref_encoder { + VEC_tree_base *trees; +} typedef *lto_out_decl_state_ptr; + +typedef struct { + lto_out_decl_state_ptr vec[1]; +} VEC_lto_out_decl_state_ptr_base; + +VEC_lto_out_decl_state_ptr_base *a; +int f; +long g; +int +fn1(struct lto_tree_ref_encoder *p1) { + int i; + long b; + i = 0; + for (; i < LTO_N_DECL_STREAMS; i++) { + struct lto_tree_ref_encoder c = *p1; + int d; + VEC_tree_base *e = c.trees; + d = e ? e->num : 0; + b += d; + } + return b; +} +int +fn2() { + lto_out_decl_state_ptr h; + struct lto_tree_ref_encoder j; + unsigned k; + for (; k < f; k++) { + h = a->vec[k]; + j = *h; + g += fn1(&j); + } +} diff --git a/gcc/testsuite/gcc.dg/vect/pr93247-2.c b/gcc/testsuite/gcc.dg/vect/pr93247-2.c new file mode 100644 index 00000000000..e229e15d87a --- /dev/null +++ b/gcc/testsuite/gcc.dg/vect/pr93247-2.c @@ -0,0 +1,12 @@ +/* { dg-do compile } */ +/* { dg-additional-options "-march=skylake-avx512" { target x86_64-*-* i?86-*-* } } */ + +int +foo (int *a, double *b, int *c) +{ + int f, g = 0; + for (f = 0; f < 100; f++) + if (b[f] && c[a[f]]) + g++; + return g; +} diff --git a/gcc/tree-vect-loop.c b/gcc/tree-vect-loop.c index faf816116de..8e318a037a7 100644 --- a/gcc/tree-vect-loop.c +++ b/gcc/tree-vect-loop.c @@ -8452,7 +8452,8 @@ update_epilogue_loop_vinfo (class loop *epilogue, tree advance) updated offset we set using ADVANCE. Instead we have to make sure the reference in the data references point to the corresponding copy of the original in the epilogue. */ - if (STMT_VINFO_MEMORY_ACCESS_TYPE (stmt_vinfo) == VMAT_GATHER_SCATTER) + if (STMT_VINFO_MEMORY_ACCESS_TYPE (vect_stmt_to_vectorize (stmt_vinfo)) + == VMAT_GATHER_SCATTER) { DR_REF (dr) = simplify_replace_tree (DR_REF (dr), NULL_TREE, NULL_TREE, -- 2.30.2