re PR tree-optimization/58483 (missing optimization opportunity for const std::vector...
authorRichard Biener <rguenther@suse.de>
Tue, 2 Jul 2019 07:35:23 +0000 (07:35 +0000)
committerRichard Biener <rguenth@gcc.gnu.org>
Tue, 2 Jul 2019 07:35:23 +0000 (07:35 +0000)
2019-07-02  Richard Biener  <rguenther@suse.de>

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
gcc/testsuite/ChangeLog
gcc/testsuite/gcc.dg/tree-ssa/ssa-dom-cse-8.c [new file with mode: 0644]
gcc/tree-ssa-scopedtables.c

index 00885e67a5515569b0d7aa2b41506dc0f638e0b5..6a1e932ad739b11819edaab1a2821ecf265d11bb 100644 (file)
@@ -1,3 +1,10 @@
+2019-07-02  Richard Biener  <rguenther@suse.de>
+
+       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  <segher@kernel.crashing.org>
 
        * config/rs6000/rs6000.md (signbit<mode>2_dm): Make this a
index 9d9569d3d5a3d59e1d9e7ca46ae205d33ef4952e..e3a6b7926ecaea2cd1517b23a29c733154c4f12e 100644 (file)
@@ -1,3 +1,8 @@
+2019-07-02  Richard Biener  <rguenther@suse.de>
+
+       PR tree-optimization/58483
+       * gcc.dg/tree-ssa/ssa-dom-cse-8.c: New testcase.
+
 2019-07-01  Andreas Krebbel  <krebbel@linux.ibm.com>
 
        * 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 (file)
index 0000000..b419ce7
--- /dev/null
@@ -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 <int> ((char *)p_1(D) + 4) = 20;
+  _2 = __MEM <const int> ((int *)p_1(D) + 4);
+  return _2;
+}
+
+/* { dg-final { scan-tree-dump "return 20;" "dom2" } } */
index e08e24dfcc1bbf9efe72fc529c5e76457baa9d08..50413eb86c103e23cb63baf01cc1cc511cf78422 100644 (file)
@@ -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