This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[PATCH] Improve DOM for PR58483


DOM can handle different shape refs but fails for bases with
differing TBAA behavior currently.  This isn't necessary
and fixed via using OEP_ADDRESS_OF for handling of the base
returned from get_ref_base_and_extent.

Bootstrapped on x86_64-unknown-linux-gnu, testing in progress.

Richard.

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.

Index: gcc/tree-ssa-scopedtables.c
===================================================================
--- gcc/tree-ssa-scopedtables.c	(revision 272843)
+++ gcc/tree-ssa-scopedtables.c	(working copy)
@@ -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
Index: gcc/testsuite/gcc.dg/tree-ssa/ssa-dom-cse-8.c
===================================================================
--- gcc/testsuite/gcc.dg/tree-ssa/ssa-dom-cse-8.c	(nonexistent)
+++ gcc/testsuite/gcc.dg/tree-ssa/ssa-dom-cse-8.c	(working copy)
@@ -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 Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]