From 14ec49a7537004633b7fff859178cbebd288ca1d Mon Sep 17 00:00:00 2001 From: Richard Biener Date: Tue, 2 Jul 2019 07:35:23 +0000 Subject: [PATCH] re PR tree-optimization/58483 (missing optimization opportunity for const std::vector compared to std::array) 2019-07-02 Richard Biener PR tree-optimization/58483 * tree-ssa-scopedtables.c (avail_expr_hash): Use OEP_ADDRESS_OF for MEM_REF base hashing. (equal_mem_array_ref_p): Likewise for base comparison. * gcc.dg/tree-ssa/ssa-dom-cse-8.c: New testcase. From-SVN: r272922 --- gcc/ChangeLog | 7 +++++++ gcc/testsuite/ChangeLog | 5 +++++ gcc/testsuite/gcc.dg/tree-ssa/ssa-dom-cse-8.c | 15 +++++++++++++++ gcc/tree-ssa-scopedtables.c | 11 +++++++++-- 4 files changed, 36 insertions(+), 2 deletions(-) create mode 100644 gcc/testsuite/gcc.dg/tree-ssa/ssa-dom-cse-8.c diff --git a/gcc/ChangeLog b/gcc/ChangeLog index 00885e67a55..6a1e932ad73 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -1,3 +1,10 @@ +2019-07-02 Richard Biener + + PR tree-optimization/58483 + * tree-ssa-scopedtables.c (avail_expr_hash): Use OEP_ADDRESS_OF + for MEM_REF base hashing. + (equal_mem_array_ref_p): Likewise for base comparison. + 2019-07-01 Segher Boessenkool * config/rs6000/rs6000.md (signbit2_dm): Make this a diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index 9d9569d3d5a..e3a6b7926ec 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,8 @@ +2019-07-02 Richard Biener + + PR tree-optimization/58483 + * gcc.dg/tree-ssa/ssa-dom-cse-8.c: New testcase. + 2019-07-01 Andreas Krebbel * gcc.target/s390/vector/vec-shift-2.c: New test. diff --git a/gcc/testsuite/gcc.dg/tree-ssa/ssa-dom-cse-8.c b/gcc/testsuite/gcc.dg/tree-ssa/ssa-dom-cse-8.c new file mode 100644 index 00000000000..b419ce76068 --- /dev/null +++ b/gcc/testsuite/gcc.dg/tree-ssa/ssa-dom-cse-8.c @@ -0,0 +1,15 @@ +/* { dg-do compile } */ +/* { dg-options "-O -fgimple -fdump-tree-dom2" } */ + +int __GIMPLE (ssa,startwith("dom")) +foo (void *p) +{ + int _2; + + __BB(2): + __MEM ((char *)p_1(D) + 4) = 20; + _2 = __MEM ((int *)p_1(D) + 4); + return _2; +} + +/* { dg-final { scan-tree-dump "return 20;" "dom2" } } */ diff --git a/gcc/tree-ssa-scopedtables.c b/gcc/tree-ssa-scopedtables.c index e08e24dfcc1..50413eb86c1 100644 --- a/gcc/tree-ssa-scopedtables.c +++ b/gcc/tree-ssa-scopedtables.c @@ -494,7 +494,9 @@ avail_expr_hash (class expr_hash_elt *p) { enum tree_code code = MEM_REF; hstate.add_object (code); - inchash::add_expr (base, hstate); + inchash::add_expr (base, hstate, + TREE_CODE (base) == MEM_REF + ? OEP_ADDRESS_OF : 0); hstate.add_object (offset); hstate.add_object (size); return hstate.end (); @@ -540,7 +542,12 @@ equal_mem_array_ref_p (tree t0, tree t1) if (rev0 != rev1 || maybe_ne (sz0, sz1) || maybe_ne (off0, off1)) return false; - return operand_equal_p (base0, base1, 0); + return operand_equal_p (base0, base1, + (TREE_CODE (base0) == MEM_REF + || TREE_CODE (base0) == TARGET_MEM_REF) + && (TREE_CODE (base1) == MEM_REF + || TREE_CODE (base1) == TARGET_MEM_REF) + ? OEP_ADDRESS_OF : 0); } /* Compare two hashable_expr structures for equivalence. They are -- 2.30.2