diff options
author | Richard Biener <rguenther@suse.de> | 2017-07-27 12:01:21 +0000 |
---|---|---|
committer | Richard Biener <rguenth@gcc.gnu.org> | 2017-07-27 12:01:21 +0000 |
commit | 9811e84c99df6269baa406c7f42d479b342087c4 (patch) | |
tree | 691fa8f60a804bf8766bcf2e2a48a5c15e76b058 | |
parent | 0919ce3efe2a0d6a20cb726feabe26dc3503db43 (diff) | |
download | gcc-9811e84c99df6269baa406c7f42d479b342087c4.zip gcc-9811e84c99df6269baa406c7f42d479b342087c4.tar.gz gcc-9811e84c99df6269baa406c7f42d479b342087c4.tar.bz2 |
re PR middle-end/81502 (In some cases the data is moved to memory unnecessarily [partial regression])
2017-07-27 Richard Biener <rguenther@suse.de>
PR tree-optimization/81502
* tree-ssa.c (non_rewritable_lvalue_p): Handle BIT_INSERT_EXPR
with incompatible but same sized type.
(execute_update_addresses_taken): Likewise.
* gcc.target/i386/vect-insert-1.c: New testcase.
From-SVN: r250620
-rw-r--r-- | gcc/ChangeLog | 7 | ||||
-rw-r--r-- | gcc/testsuite/ChangeLog | 5 | ||||
-rw-r--r-- | gcc/testsuite/gcc.target/i386/vect-insert-1.c | 15 | ||||
-rw-r--r-- | gcc/tree-ssa.c | 43 |
4 files changed, 61 insertions, 9 deletions
diff --git a/gcc/ChangeLog b/gcc/ChangeLog index 845dd75..5fcaae2 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -1,3 +1,10 @@ +2017-07-27 Richard Biener <rguenther@suse.de> + + PR tree-optimization/81502 + * tree-ssa.c (non_rewritable_lvalue_p): Handle BIT_INSERT_EXPR + with incompatible but same sized type. + (execute_update_addresses_taken): Likewise. + 2017-07-27 James Greenhalgh <james.greenhalgh@arm.com> * tree-ssa-loop-ch.c (pass_ch::process_loop_p): Guard on diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index cc300dc..292fa5b 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,8 @@ +2017-07-27 Richard Biener <rguenther@suse.de> + + PR tree-optimization/81502 + * gcc.target/i386/vect-insert-1.c: New testcase. + 2017-07-27 Andreas Krebbel <krebbel@linux.vnet.ibm.com> PR target/81534 diff --git a/gcc/testsuite/gcc.target/i386/vect-insert-1.c b/gcc/testsuite/gcc.target/i386/vect-insert-1.c new file mode 100644 index 0000000..55cc523 --- /dev/null +++ b/gcc/testsuite/gcc.target/i386/vect-insert-1.c @@ -0,0 +1,15 @@ +/* { dg-do compile } */ +/* { dg-options "-O -msse2 -fdump-tree-ccp1" } */ + +typedef int v4si __attribute__((vector_size(16))); + +float f; + +v4si foo (v4si a) +{ + __builtin_memcpy ((char *)&a + 4, &f, 4); + return a; +} + +/* { dg-final { scan-tree-dump "Now a gimple register: a" "ccp1" } } */ +/* { dg-final { scan-tree-dump "BIT_INSERT_EXPR <a" "ccp1" } } */ diff --git a/gcc/tree-ssa.c b/gcc/tree-ssa.c index fa8f81e..a67012c 100644 --- a/gcc/tree-ssa.c +++ b/gcc/tree-ssa.c @@ -1513,8 +1513,8 @@ non_rewritable_lvalue_p (tree lhs) if (DECL_P (decl) && VECTOR_TYPE_P (TREE_TYPE (decl)) && TYPE_MODE (TREE_TYPE (decl)) != BLKmode - && types_compatible_p (TREE_TYPE (lhs), - TREE_TYPE (TREE_TYPE (decl))) + && operand_equal_p (TYPE_SIZE_UNIT (TREE_TYPE (lhs)), + TYPE_SIZE_UNIT (TREE_TYPE (TREE_TYPE (decl))), 0) && tree_fits_uhwi_p (TREE_OPERAND (lhs, 1)) && tree_int_cst_lt (TREE_OPERAND (lhs, 1), TYPE_SIZE_UNIT (TREE_TYPE (decl))) @@ -1529,8 +1529,9 @@ non_rewritable_lvalue_p (tree lhs) && DECL_P (TREE_OPERAND (lhs, 0)) && VECTOR_TYPE_P (TREE_TYPE (TREE_OPERAND (lhs, 0))) && TYPE_MODE (TREE_TYPE (TREE_OPERAND (lhs, 0))) != BLKmode - && types_compatible_p (TREE_TYPE (lhs), - TREE_TYPE (TREE_TYPE (TREE_OPERAND (lhs, 0)))) + && operand_equal_p (TYPE_SIZE_UNIT (TREE_TYPE (lhs)), + TYPE_SIZE_UNIT + (TREE_TYPE (TREE_TYPE (TREE_OPERAND (lhs, 0)))), 0) && (tree_to_uhwi (TREE_OPERAND (lhs, 2)) % tree_to_uhwi (TYPE_SIZE (TREE_TYPE (lhs)))) == 0) return false; @@ -1812,14 +1813,26 @@ execute_update_addresses_taken (void) DECL_UID (TREE_OPERAND (lhs, 0))) && VECTOR_TYPE_P (TREE_TYPE (TREE_OPERAND (lhs, 0))) && TYPE_MODE (TREE_TYPE (TREE_OPERAND (lhs, 0))) != BLKmode - && types_compatible_p (TREE_TYPE (lhs), - TREE_TYPE (TREE_TYPE - (TREE_OPERAND (lhs, 0)))) + && operand_equal_p (TYPE_SIZE_UNIT (TREE_TYPE (lhs)), + TYPE_SIZE_UNIT (TREE_TYPE + (TREE_TYPE (TREE_OPERAND (lhs, 0)))), + 0) && (tree_to_uhwi (TREE_OPERAND (lhs, 2)) % tree_to_uhwi (TYPE_SIZE (TREE_TYPE (lhs))) == 0)) { tree var = TREE_OPERAND (lhs, 0); tree val = gimple_assign_rhs1 (stmt); + if (! types_compatible_p (TREE_TYPE (TREE_TYPE (var)), + TREE_TYPE (val))) + { + tree tem = make_ssa_name (TREE_TYPE (TREE_TYPE (var))); + gimple *pun + = gimple_build_assign (tem, + build1 (VIEW_CONVERT_EXPR, + TREE_TYPE (tem), val)); + gsi_insert_before (&gsi, pun, GSI_SAME_STMT); + val = tem; + } tree bitpos = TREE_OPERAND (lhs, 2); gimple_assign_set_lhs (stmt, var); gimple_assign_set_rhs_with_ops @@ -1839,8 +1852,9 @@ execute_update_addresses_taken (void) && bitmap_bit_p (suitable_for_renaming, DECL_UID (sym)) && VECTOR_TYPE_P (TREE_TYPE (sym)) && TYPE_MODE (TREE_TYPE (sym)) != BLKmode - && types_compatible_p (TREE_TYPE (lhs), - TREE_TYPE (TREE_TYPE (sym))) + && operand_equal_p (TYPE_SIZE_UNIT (TREE_TYPE (lhs)), + TYPE_SIZE_UNIT + (TREE_TYPE (TREE_TYPE (sym))), 0) && tree_fits_uhwi_p (TREE_OPERAND (lhs, 1)) && tree_int_cst_lt (TREE_OPERAND (lhs, 1), TYPE_SIZE_UNIT (TREE_TYPE (sym))) @@ -1848,6 +1862,17 @@ execute_update_addresses_taken (void) % tree_to_uhwi (TYPE_SIZE_UNIT (TREE_TYPE (lhs)))) == 0) { tree val = gimple_assign_rhs1 (stmt); + if (! types_compatible_p (TREE_TYPE (val), + TREE_TYPE (TREE_TYPE (sym)))) + { + tree tem = make_ssa_name (TREE_TYPE (TREE_TYPE (sym))); + gimple *pun + = gimple_build_assign (tem, + build1 (VIEW_CONVERT_EXPR, + TREE_TYPE (tem), val)); + gsi_insert_before (&gsi, pun, GSI_SAME_STMT); + val = tem; + } tree bitpos = wide_int_to_tree (bitsizetype, mem_ref_offset (lhs) * BITS_PER_UNIT); |