From 83a416b095d7bcd52ed95cfefc3ea51baddc5b87 Mon Sep 17 00:00:00 2001
From: Richard Guenther <rguenther@suse.de>
Date: Wed, 7 Apr 2010 10:15:05 +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
	* expr.c (expand_expr_real_1): For TARGET_MEM_REFs with
	pointer bases build simple mem attributes to retain
	points-to information.

From-SVN: r158048
---
 gcc/ChangeLog |  7 +++++++
 gcc/expr.c    | 11 +++++++++++
 2 files changed, 18 insertions(+)

diff --git a/gcc/ChangeLog b/gcc/ChangeLog
index 4c9b75ac9b9a..b4aa73ebee4a 100644
--- a/gcc/ChangeLog
+++ b/gcc/ChangeLog
@@ -1,3 +1,10 @@
+2010-04-07  Richard Guenther  <rguenther@suse.de>
+
+	PR middle-end/42617
+	* expr.c (expand_expr_real_1): For TARGET_MEM_REFs with
+	pointer bases build simple mem attributes to retain
+	points-to information.
+
 2010-04-07  Richard Guenther  <rguenther@suse.de>
 
 	PR middle-end/42617
diff --git a/gcc/expr.c b/gcc/expr.c
index ad66d934d2f3..1f04ffb3bb44 100644
--- a/gcc/expr.c
+++ b/gcc/expr.c
@@ -8730,6 +8730,7 @@ expand_expr_real_1 (tree exp, rtx target, enum machine_mode tmode,
       {
 	addr_space_t as = TYPE_ADDR_SPACE (TREE_TYPE (exp));
 	struct mem_address addr;
+	tree base;
 
 	get_address_description (exp, &addr);
 	op0 = addr_for_mem_ref (&addr, as, true);
@@ -8737,6 +8738,16 @@ expand_expr_real_1 (tree exp, rtx target, enum machine_mode tmode,
 	temp = gen_rtx_MEM (mode, op0);
 	set_mem_attributes (temp, TMR_ORIGINAL (exp), 0);
 	set_mem_addr_space (temp, as);
+	base = get_base_address (TMR_ORIGINAL (exp));
+	if (INDIRECT_REF_P (base)
+	    && TMR_BASE (exp)
+	    && TREE_CODE (TMR_BASE (exp)) == SSA_NAME
+	    && POINTER_TYPE_P (TREE_TYPE (TMR_BASE (exp))))
+	  {
+	    set_mem_expr (temp, build1 (INDIRECT_REF,
+					TREE_TYPE (exp), TMR_BASE (exp)));
+	    set_mem_offset (temp, NULL_RTX);
+	  }
       }
       return temp;
 
-- 
GitLab