From c0d942d2117b785d768c5f2ab2813e4781e29e43 Mon Sep 17 00:00:00 2001 From: Ulrich Weigand Date: Tue, 10 Apr 2012 10:56:11 +0000 Subject: [PATCH] re PR tree-optimization/52870 (ICE during SLP pattern matching) gcc/ PR tree-optimization/52870 * tree-vect-patterns.c (vect_recog_widen_mult_pattern): Verify that presumed pattern statement is within the same loop or basic block. gcc/testsuite/ PR tree-optimization/52870 * gcc.dg/vect/pr52870.c: New test. From-SVN: r186272 --- gcc/ChangeLog | 6 ++++++ gcc/testsuite/ChangeLog | 5 +++++ gcc/testsuite/gcc.dg/vect/pr52870.c | 17 +++++++++++++++++ gcc/tree-vect-patterns.c | 15 +++++++++++++++ 4 files changed, 43 insertions(+) create mode 100644 gcc/testsuite/gcc.dg/vect/pr52870.c diff --git a/gcc/ChangeLog b/gcc/ChangeLog index 2e39f782f60..64ff386c360 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -1,3 +1,9 @@ +2012-04-10 Ulrich Weigand + + PR tree-optimization/52870 + * tree-vect-patterns.c (vect_recog_widen_mult_pattern): Verify that + presumed pattern statement is within the same loop or basic block. + 2012-04-10 Tristan Gingold * gengtype.c (main): Make uintptr_t a known type. diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index e1ea7f5f86b..a2172b04dfd 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,8 @@ +2012-04-10 Ulrich Weigand + + PR tree-optimization/52870 + * gcc.dg/vect/pr52870.c: New test. + 2012-04-09 Mike Stump * g++.dg/cpp0x/udlit-raw-op.C: Don't use CRLF endings. diff --git a/gcc/testsuite/gcc.dg/vect/pr52870.c b/gcc/testsuite/gcc.dg/vect/pr52870.c new file mode 100644 index 00000000000..38518508bf6 --- /dev/null +++ b/gcc/testsuite/gcc.dg/vect/pr52870.c @@ -0,0 +1,17 @@ +/* { dg-do compile } */ +/* { dg-options "-O1 -ftree-vectorize" } */ + +long +test (int *x) +{ + unsigned long sx, xprec; + + sx = *x >= 0 ? *x : -*x; + + xprec = sx * 64; + + if (sx < 16384) + foo (sx); + + return xprec; +} diff --git a/gcc/tree-vect-patterns.c b/gcc/tree-vect-patterns.c index b871c0ba361..6372a36b3fd 100644 --- a/gcc/tree-vect-patterns.c +++ b/gcc/tree-vect-patterns.c @@ -564,6 +564,16 @@ vect_recog_widen_mult_pattern (VEC (gimple, heap) **stmts, VEC (tree, heap) *dummy_vec; bool op1_ok; bool promotion; + loop_vec_info loop_vinfo; + struct loop *loop = NULL; + bb_vec_info bb_vinfo; + stmt_vec_info stmt_vinfo; + + stmt_vinfo = vinfo_for_stmt (last_stmt); + loop_vinfo = STMT_VINFO_LOOP_VINFO (stmt_vinfo); + bb_vinfo = STMT_VINFO_BB_VINFO (stmt_vinfo); + if (loop_vinfo) + loop = LOOP_VINFO_LOOP (loop_vinfo); if (!is_gimple_assign (last_stmt)) return NULL; @@ -635,6 +645,11 @@ vect_recog_widen_mult_pattern (VEC (gimple, heap) **stmts, || gimple_assign_rhs_code (use_stmt) != NOP_EXPR) return NULL; + if (!gimple_bb (use_stmt) + || (loop && !flow_bb_inside_loop_p (loop, gimple_bb (use_stmt))) + || (!loop && gimple_bb (use_stmt) != BB_VINFO_BB (bb_vinfo))) + return NULL; + use_lhs = gimple_assign_lhs (use_stmt); use_type = TREE_TYPE (use_lhs); if (!INTEGRAL_TYPE_P (use_type)