From 366f945f9bc15d885af5a20ed70547e96b2dafae Mon Sep 17 00:00:00 2001
From: Richard Guenther <rguenther@suse.de>
Date: Wed, 7 Apr 2010 10:14:17 +0000
Subject: [PATCH] re PR rtl-optimization/42617 (TARGET_MEM_REF and plain
 INDIRECT_REFs are not handled by the RTL oracle)

2010-04-07  Richard Guenther  <rguenther@suse.de>

	PR middle-end/42617
	* alias.c (ao_ref_from_mem): Without MEM_OFFSET or MEM_SIZE
	preserve points-to related information.

From-SVN: r158046
---
 gcc/ChangeLog |  6 ++++++
 gcc/alias.c   | 27 +++++++++++++++++----------
 2 files changed, 23 insertions(+), 10 deletions(-)

diff --git a/gcc/ChangeLog b/gcc/ChangeLog
index d41b7d504b65..4c9b75ac9b9a 100644
--- a/gcc/ChangeLog
+++ b/gcc/ChangeLog
@@ -1,3 +1,9 @@
+2010-04-07  Richard Guenther  <rguenther@suse.de>
+
+	PR middle-end/42617
+	* alias.c (ao_ref_from_mem): Without MEM_OFFSET or MEM_SIZE
+	preserve points-to related information.
+
 2010-04-07  Richard Guenther  <rguenther@suse.de>
 
 	PR middle-end/42617
diff --git a/gcc/alias.c b/gcc/alias.c
index cd7e2a06bdbb..19a8292b454f 100644
--- a/gcc/alias.c
+++ b/gcc/alias.c
@@ -265,11 +265,6 @@ ao_ref_from_mem (ao_ref *ref, const_rtx mem)
   if (!expr)
     return false;
 
-  /* If MEM_OFFSET or MEM_SIZE are NULL punt.  */
-  if (!MEM_OFFSET (mem)
-      || !MEM_SIZE (mem))
-    return false;
-
   ao_ref_init (ref, expr);
 
   /* Get the base of the reference and see if we have to reject or
@@ -278,17 +273,17 @@ ao_ref_from_mem (ao_ref *ref, const_rtx mem)
   if (base == NULL_TREE)
     return false;
 
+  /* The tree oracle doesn't like to have these.  */
+  if (TREE_CODE (base) == FUNCTION_DECL
+      || TREE_CODE (base) == LABEL_DECL)
+    return false;
+
   /* If this is a pointer dereference of a non-SSA_NAME punt.
      ???  We could replace it with a pointer to anything.  */
   if (INDIRECT_REF_P (base)
       && TREE_CODE (TREE_OPERAND (base, 0)) != SSA_NAME)
     return false;
 
-  /* The tree oracle doesn't like to have these.  */
-  if (TREE_CODE (base) == FUNCTION_DECL
-      || TREE_CODE (base) == LABEL_DECL)
-    return false;
-
   /* If this is a reference based on a partitioned decl replace the
      base with an INDIRECT_REF of the pointer representative we
      created during stack slot partitioning.  */
@@ -307,6 +302,18 @@ ao_ref_from_mem (ao_ref *ref, const_rtx mem)
 
   ref->ref_alias_set = MEM_ALIAS_SET (mem);
 
+  /* If MEM_OFFSET or MEM_SIZE are NULL we have to punt.
+     Keep points-to related information though.  */
+  if (!MEM_OFFSET (mem)
+      || !MEM_SIZE (mem))
+    {
+      ref->ref = NULL_TREE;
+      ref->offset = 0;
+      ref->size = -1;
+      ref->max_size = -1;
+      return true;
+    }
+
   /* If the base decl is a parameter we can have negative MEM_OFFSET in
      case of promoted subregs on bigendian targets.  Trust the MEM_EXPR
      here.  */
-- 
GitLab