Patchwork Fix PR45297: handle ADDR_EXPR in interpret_rhs_expr as in follow_ssa_edge_expr.

login
register
mail settings
Submitter Sebastian Pop
Date Dec. 2, 2010, 5:18 p.m.
Message ID <1291310316-30043-1-git-send-email-sebpop@gmail.com>
Download mbox | patch
Permalink /patch/74000/
State New
Headers show

Comments

Sebastian Pop - Dec. 2, 2010, 5:18 p.m.
Hi,

Here is the amended patch.  The previous patch passed regstrap on
amd64-linux.  I also sent this patch to test and I will commit it
if there are no other comments.

Thanks,
Sebastian

2010-12-01  Sebastian Pop  <sebastian.pop@amd.com>

	PR middle-end/45297
	* tree-scalar-evolution.c (interpret_rhs_expr): Handle ADDR_EXPR
	with MEM_REFs as POINTER_PLUS_EXPR.
---
 gcc/ChangeLog               |    6 ++++++
 gcc/tree-scalar-evolution.c |   14 ++++++++++++--
 2 files changed, 18 insertions(+), 2 deletions(-)

Patch

diff --git a/gcc/ChangeLog b/gcc/ChangeLog
index c72c693..da56fb6 100644
--- a/gcc/ChangeLog
+++ b/gcc/ChangeLog
@@ -1,5 +1,11 @@ 
 2010-12-02  Sebastian Pop  <sebastian.pop@amd.com>
 
+	PR middle-end/45297
+	* tree-scalar-evolution.c (interpret_rhs_expr): Handle ADDR_EXPR
+	with MEM_REFs as POINTER_PLUS_EXPR.
+
+2010-12-02  Sebastian Pop  <sebastian.pop@amd.com>
+
 	PR tree-optimization/45199
 	* tree-data-ref.c (mem_write_stride_of_same_size_as_unit_type_p): New.
 	(stores_zero_from_loop): Call
diff --git a/gcc/tree-scalar-evolution.c b/gcc/tree-scalar-evolution.c
index 8a5797e..4a4bda9 100644
--- a/gcc/tree-scalar-evolution.c
+++ b/gcc/tree-scalar-evolution.c
@@ -1715,12 +1715,22 @@  interpret_rhs_expr (struct loop *loop, gimple at_stmt,
 	  return chrec_convert (type, analyze_scalar_evolution (loop, rhs1),
 				at_stmt);
 	}
-
-      return chrec_dont_know;
     }
 
   switch (code)
     {
+    case ADDR_EXPR:
+      /* Handle &MEM[ptr + CST] which is equivalent to POINTER_PLUS_EXPR.  */
+      if (TREE_CODE (TREE_OPERAND (rhs1, 0)) != MEM_REF)
+	{
+	  res = chrec_dont_know;
+	  break;
+	}
+
+      rhs2 = TREE_OPERAND (TREE_OPERAND (rhs1, 0), 1);
+      rhs1 = TREE_OPERAND (TREE_OPERAND (rhs1, 0), 0);
+      /* Fall through.  */
+
     case POINTER_PLUS_EXPR:
       chrec1 = analyze_scalar_evolution (loop, rhs1);
       chrec2 = analyze_scalar_evolution (loop, rhs2);