From 8dc35712198be33bcd9c89f8718dbbf108ff8fb1 Mon Sep 17 00:00:00 2001 From: Alan Hayward Date: Wed, 15 Jun 2016 15:45:47 +0000 Subject: [PATCH] =?utf8?q?re=20PR=20tree-optimization/71483=20(g++=20ICE?= =?utf8?q?=20at=20-O3=20on=20valid=20code=20on=20x86=5F64-linux-gnu=20with?= =?utf8?q?=20=E2=80=9CFloating=20point=20exception=E2=80=9D)?= MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit 2016-06-15 Alan Hayward gcc/ PR tree-optimization/71483 * tree-vect-loop.c (vectorizable_live_operation): Pick correct index for slp testsuite/ PR tree-optimization/71483 * g++.dg/vect/pr71483.c: New From-SVN: r237483 --- gcc/ChangeLog | 6 ++++++ gcc/testsuite/ChangeLog | 5 +++++ gcc/testsuite/g++.dg/vect/pr71483.c | 11 +++++++++++ gcc/tree-vect-loop.c | 18 +++++++----------- 4 files changed, 29 insertions(+), 11 deletions(-) create mode 100644 gcc/testsuite/g++.dg/vect/pr71483.c diff --git a/gcc/ChangeLog b/gcc/ChangeLog index 01d50905dff..88c1e0f253b 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -1,3 +1,9 @@ +2016-06-15 Alan Hayward + + PR tree-optimization/71483 + * tree-vect-loop.c (vectorizable_live_operation): Pick correct index + for slp + 2016-06-15 Martin Liska * predict.c (tree_predict_by_opcode): Call predict_edge_def diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index d9dd04db118..60c3192c90b 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,8 @@ +2016-06-15 Alan Hayward + + PR tree-optimization/71483 + * g++.dg/vect/pr71483.c: New + 2016-06-15 Paolo Carlini PR c++/70202 diff --git a/gcc/testsuite/g++.dg/vect/pr71483.c b/gcc/testsuite/g++.dg/vect/pr71483.c new file mode 100644 index 00000000000..77f879c9a89 --- /dev/null +++ b/gcc/testsuite/g++.dg/vect/pr71483.c @@ -0,0 +1,11 @@ +/* { dg-do compile } */ +int b, c, d; +short *e; +void fn1() { + for (; b; b--) { + d = *e >> 2; + *e++ = d; + c = *e; + *e++ = d; + } +} diff --git a/gcc/tree-vect-loop.c b/gcc/tree-vect-loop.c index 4c8678505df..a2413bf9c67 100644 --- a/gcc/tree-vect-loop.c +++ b/gcc/tree-vect-loop.c @@ -6368,24 +6368,20 @@ vectorizable_live_operation (gimple *stmt, int num_scalar = SLP_TREE_SCALAR_STMTS (slp_node).length (); int num_vec = SLP_TREE_NUMBER_OF_VEC_STMTS (slp_node); - int scalar_per_vec = num_scalar / num_vec; - /* There are three possibilites here: - 1: All scalar stmts fit in a single vector. - 2: All scalar stmts fit multiple times into a single vector. - We must choose the last occurence of stmt in the vector. - 3: Scalar stmts are split across multiple vectors. - We must choose the correct vector and mod the lane accordingly. */ + /* Get the last occurrence of the scalar index from the concatenation of + all the slp vectors. Calculate which slp vector it is and the index + within. */ + int pos = (num_vec * nunits) - num_scalar + slp_index; + int vec_entry = pos / nunits; + int vec_index = pos % nunits; /* Get the correct slp vectorized stmt. */ - int vec_entry = slp_index / scalar_per_vec; vec_lhs = gimple_get_lhs (SLP_TREE_VEC_STMTS (slp_node)[vec_entry]); /* Get entry to use. */ - bitstart = build_int_cst (unsigned_type_node, - scalar_per_vec - (slp_index % scalar_per_vec)); + bitstart = build_int_cst (unsigned_type_node, vec_index); bitstart = int_const_binop (MULT_EXPR, bitsize, bitstart); - bitstart = int_const_binop (MINUS_EXPR, vec_bitsize, bitstart); } else { -- 2.30.2