From 29764870aaa5da8f73c7c25c0aca5a251beb4103 Mon Sep 17 00:00:00 2001 From: Richard Biener Date: Mon, 1 Jun 2015 10:37:30 +0000 Subject: [PATCH] re PR tree-optimization/66280 (ICE: in vect_get_vec_def_for_operand, at tree-vect-stmts.c:1472) 2015-06-01 Richard Biener PR tree-optimization/66280 * tree-vect-slp.c (vect_detect_hybrid_slp_stmts): Fix pattern def-use walking. * g++.dg/torture/pr66280.C: New testcase. * g++.dg/torture/pr66280-2.C: Likewise. From-SVN: r223927 --- gcc/ChangeLog | 6 +++++ gcc/testsuite/ChangeLog | 6 +++++ gcc/testsuite/g++.dg/torture/pr66280-2.C | 25 ++++++++++++++++++ gcc/testsuite/g++.dg/torture/pr66280.C | 25 ++++++++++++++++++ gcc/tree-vect-slp.c | 32 ++++++++++++++---------- 5 files changed, 81 insertions(+), 13 deletions(-) create mode 100644 gcc/testsuite/g++.dg/torture/pr66280-2.C create mode 100644 gcc/testsuite/g++.dg/torture/pr66280.C diff --git a/gcc/ChangeLog b/gcc/ChangeLog index e75107943a4..4b007b4a0e0 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -1,3 +1,9 @@ +2015-06-01 Richard Biener + + PR tree-optimization/66280 + * tree-vect-slp.c (vect_detect_hybrid_slp_stmts): Fix pattern + def-use walking. + 2015-06-01 Kyrylo Tkachov * config/aarch64/aarch64.md diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index 3cafd133bc5..d25d5a7d9d9 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,9 @@ +2015-06-01 Richard Biener + + PR tree-optimization/66280 + * g++.dg/torture/pr66280.C: New testcase. + * g++.dg/torture/pr66280-2.C: Likewise. + 2015-06-01 Eric Botcazou * gnat.dg/addr9_1.adb: New test. diff --git a/gcc/testsuite/g++.dg/torture/pr66280-2.C b/gcc/testsuite/g++.dg/torture/pr66280-2.C new file mode 100644 index 00000000000..fee53fce7ad --- /dev/null +++ b/gcc/testsuite/g++.dg/torture/pr66280-2.C @@ -0,0 +1,25 @@ +// { dg-do compile } + +typedef struct +{ + short re; + short im; +} cint16_T; +typedef struct +{ + int re; + int im; +} cint32_T; +int a; +short b; +cint16_T *c; +cint32_T *d, *e; +void +fn1 () +{ + for (; a; a++) + { + d[a].re = d[a].im = e[a].im = c[a].im * b; + e[a].re = c[a].re * b; + } +} diff --git a/gcc/testsuite/g++.dg/torture/pr66280.C b/gcc/testsuite/g++.dg/torture/pr66280.C new file mode 100644 index 00000000000..b9f43daeee9 --- /dev/null +++ b/gcc/testsuite/g++.dg/torture/pr66280.C @@ -0,0 +1,25 @@ +// { dg-do compile } + +typedef struct +{ + short re; + short im; +} cint16_T; +typedef struct +{ + int re; + int im; +} cint32_T; +int a; +short b; +cint16_T *c; +cint32_T *d, *e; +void +fn1 () +{ + for (; a; a++) + { + d[a].re = d[a].im = e[a].re = c[a].re * b; + e[a].im = c[a].im * b; + } +} diff --git a/gcc/tree-vect-slp.c b/gcc/tree-vect-slp.c index f38191d9884..fb57dd41111 100644 --- a/gcc/tree-vect-slp.c +++ b/gcc/tree-vect-slp.c @@ -2031,21 +2031,27 @@ vect_detect_hybrid_slp_stmts (slp_tree node, unsigned i, slp_vect_type stype) { /* Check if a pure SLP stmt has uses in non-SLP stmts. */ gcc_checking_assert (PURE_SLP_STMT (stmt_vinfo)); + /* We always get the pattern stmt here, but for immediate + uses we have to use the LHS of the original stmt. */ + gcc_checking_assert (!STMT_VINFO_IN_PATTERN_P (stmt_vinfo)); + if (STMT_VINFO_RELATED_STMT (stmt_vinfo)) + stmt = STMT_VINFO_RELATED_STMT (stmt_vinfo); if (TREE_CODE (gimple_op (stmt, 0)) == SSA_NAME) FOR_EACH_IMM_USE_STMT (use_stmt, imm_iter, gimple_op (stmt, 0)) - if (gimple_bb (use_stmt) - && flow_bb_inside_loop_p (loop, gimple_bb (use_stmt)) - && (use_vinfo = vinfo_for_stmt (use_stmt)) - && !STMT_SLP_TYPE (use_vinfo) - && (STMT_VINFO_RELEVANT (use_vinfo) - || VECTORIZABLE_CYCLE_DEF (STMT_VINFO_DEF_TYPE (use_vinfo)) - || (STMT_VINFO_IN_PATTERN_P (use_vinfo) - && STMT_VINFO_RELATED_STMT (use_vinfo) - && !STMT_SLP_TYPE (vinfo_for_stmt - (STMT_VINFO_RELATED_STMT (use_vinfo))))) - && !(gimple_code (use_stmt) == GIMPLE_PHI - && STMT_VINFO_DEF_TYPE (use_vinfo) == vect_reduction_def)) - stype = hybrid; + { + if (!flow_bb_inside_loop_p (loop, gimple_bb (use_stmt))) + continue; + use_vinfo = vinfo_for_stmt (use_stmt); + if (STMT_VINFO_IN_PATTERN_P (use_vinfo) + && STMT_VINFO_RELATED_STMT (use_vinfo)) + use_vinfo = vinfo_for_stmt (STMT_VINFO_RELATED_STMT (use_vinfo)); + if (!STMT_SLP_TYPE (use_vinfo) + && (STMT_VINFO_RELEVANT (use_vinfo) + || VECTORIZABLE_CYCLE_DEF (STMT_VINFO_DEF_TYPE (use_vinfo))) + && !(gimple_code (use_stmt) == GIMPLE_PHI + && STMT_VINFO_DEF_TYPE (use_vinfo) == vect_reduction_def)) + stype = hybrid; + } } if (stype == hybrid) -- 2.30.2