diff options
author | rguenth <rguenth@138bc75d-0d04-0410-961f-82ee72b054a4> | 2012-05-29 14:40:16 +0000 |
---|---|---|
committer | rguenth <rguenth@138bc75d-0d04-0410-961f-82ee72b054a4> | 2012-05-29 14:40:16 +0000 |
commit | 87c952b895ebe6126c0c908e52d15dac3230678e (patch) | |
tree | defff990b81b71950b63227548cb841b34adf3bd /gcc | |
parent | 9d75589a06dc34107b8d994274b615bda4439c81 (diff) | |
download | gcc-87c952b895ebe6126c0c908e52d15dac3230678e.tar.gz |
2012-05-29 Richard Guenther <rguenther@suse.de>
PR tree-optimization/53516
* tree-data-ref.c (stmt_with_adjacent_zero_store_dr_p): Reject
bitfield accesses.
* tree-vect-data-refs.c (vect_analyze_data_refs): Likewise.
* gcc.dg/torture/pr53516.c: New testcase.
git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@187961 138bc75d-0d04-0410-961f-82ee72b054a4
Diffstat (limited to 'gcc')
-rw-r--r-- | gcc/ChangeLog | 7 | ||||
-rw-r--r-- | gcc/testsuite/ChangeLog | 5 | ||||
-rw-r--r-- | gcc/testsuite/gcc.dg/torture/pr53516.c | 32 | ||||
-rw-r--r-- | gcc/tree-data-ref.c | 23 | ||||
-rw-r--r-- | gcc/tree-vect-data-refs.c | 30 |
5 files changed, 85 insertions, 12 deletions
diff --git a/gcc/ChangeLog b/gcc/ChangeLog index f86c56bc5b2..399da930422 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -1,3 +1,10 @@ +2012-05-29 Richard Guenther <rguenther@suse.de> + + PR tree-optimization/53516 + * tree-data-ref.c (stmt_with_adjacent_zero_store_dr_p): Reject + bitfield accesses. + * tree-vect-data-refs.c (vect_analyze_data_refs): Likewise. + 2012-05-29 Joseph Myers <joseph@codesourcery.com> * LANGUAGES: Fix typos. diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index 1c1b28eeab9..56bb5abc883 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,8 @@ +2012-05-29 Richard Guenther <rguenther@suse.de> + + PR tree-optimization/53516 + * gcc.dg/torture/pr53516.c: New testcase. + 2012-05-29 Dodji Seketeli <dodji@redhat.com> PR preprocessor/53229 diff --git a/gcc/testsuite/gcc.dg/torture/pr53516.c b/gcc/testsuite/gcc.dg/torture/pr53516.c new file mode 100644 index 00000000000..7f8094d19cd --- /dev/null +++ b/gcc/testsuite/gcc.dg/torture/pr53516.c @@ -0,0 +1,32 @@ +/* { dg-do run } */ +/* { dg-options "-ftree-vectorize -ftree-loop-distribute-patterns" } */ + +extern void abort (void); + +struct Foo +{ + char a : 1; + char b : 7; +}; + +struct Foo x[256]; +int y[256]; + +void __attribute__((noinline,noclone)) bar (int n) +{ + int i; + for (i = 0; i < n; ++i) + { + x[i].a = 0; + y[i] = 3; + } +} + +int main() +{ + x[5].b = 7; + bar (256); + if (x[5].b != 7) + abort (); + return 0; +} diff --git a/gcc/tree-data-ref.c b/gcc/tree-data-ref.c index 90b6f70e4a9..8a23efa36dc 100644 --- a/gcc/tree-data-ref.c +++ b/gcc/tree-data-ref.c @@ -5255,26 +5255,33 @@ stores_from_loop (struct loop *loop, VEC (gimple, heap) **stmts) bool stmt_with_adjacent_zero_store_dr_p (gimple stmt) { - tree op0, op1; + tree lhs, rhs; bool res; struct data_reference *dr; if (!stmt || !gimple_vdef (stmt) - || !is_gimple_assign (stmt) - || !gimple_assign_single_p (stmt) - || !(op1 = gimple_assign_rhs1 (stmt)) - || !(integer_zerop (op1) || real_zerop (op1))) + || !gimple_assign_single_p (stmt)) + return false; + + lhs = gimple_assign_lhs (stmt); + rhs = gimple_assign_rhs1 (stmt); + + /* If this is a bitfield store bail out. */ + if (TREE_CODE (lhs) == COMPONENT_REF + && DECL_BIT_FIELD (TREE_OPERAND (lhs, 1))) + return false; + + if (!(integer_zerop (rhs) || real_zerop (rhs))) return false; dr = XCNEW (struct data_reference); - op0 = gimple_assign_lhs (stmt); DR_STMT (dr) = stmt; - DR_REF (dr) = op0; + DR_REF (dr) = lhs; res = dr_analyze_innermost (dr, loop_containing_stmt (stmt)) - && stride_of_unit_type_p (DR_STEP (dr), TREE_TYPE (op0)); + && stride_of_unit_type_p (DR_STEP (dr), TREE_TYPE (lhs)); free_data_ref (dr); return res; diff --git a/gcc/tree-vect-data-refs.c b/gcc/tree-vect-data-refs.c index a5ed0533db6..e34f41a3f1f 100644 --- a/gcc/tree-vect-data-refs.c +++ b/gcc/tree-vect-data-refs.c @@ -2972,10 +2972,6 @@ vect_analyze_data_refs (loop_vec_info loop_vinfo, return false; } - base = unshare_expr (DR_BASE_ADDRESS (dr)); - offset = unshare_expr (DR_OFFSET (dr)); - init = unshare_expr (DR_INIT (dr)); - if (stmt_can_throw_internal (stmt)) { if (vect_print_dump_info (REPORT_UNVECTORIZED_LOCATIONS)) @@ -2997,6 +2993,32 @@ vect_analyze_data_refs (loop_vec_info loop_vinfo, return false; } + if (TREE_CODE (DR_REF (dr)) == COMPONENT_REF + && DECL_BIT_FIELD (TREE_OPERAND (DR_REF (dr), 1))) + { + if (vect_print_dump_info (REPORT_UNVECTORIZED_LOCATIONS)) + { + fprintf (vect_dump, "not vectorized: statement is bitfield " + "access "); + print_gimple_stmt (vect_dump, stmt, 0, TDF_SLIM); + } + + if (bb_vinfo) + { + STMT_VINFO_VECTORIZABLE (stmt_info) = false; + stop_bb_analysis = true; + continue; + } + + if (gather) + free_data_ref (dr); + return false; + } + + base = unshare_expr (DR_BASE_ADDRESS (dr)); + offset = unshare_expr (DR_OFFSET (dr)); + init = unshare_expr (DR_INIT (dr)); + if (is_gimple_call (stmt)) { if (vect_print_dump_info (REPORT_UNVECTORIZED_LOCATIONS)) |