Patchwork [1/3] Call recompute_tree_invariant_for_addr_expr when replacing a constant in an ADDR_EXPR.

login
register
mail settings
Submitter Sebastian Pop
Date Nov. 22, 2010, 11:18 p.m.
Message ID <1290467900-14995-1-git-send-email-sebpop@gmail.com>
Download mbox | patch
Permalink /patch/72611/
State New
Headers show

Comments

Sebastian Pop - Nov. 22, 2010, 11:18 p.m.
Committed to the graphite branch.

2010-11-22  Sebastian Pop  <sebastian.pop@amd.com>

	* sese.c (rename_uses): Call recompute_tree_invariant_for_addr_expr
	when replacing a constant in an ADDR_EXPR.
---
 gcc/ChangeLog.graphite |    5 +++++
 gcc/sese.c             |   13 +++++++++++++
 2 files changed, 18 insertions(+), 0 deletions(-)
Richard Guenther - Nov. 23, 2010, 12:45 p.m.
On Tue, Nov 23, 2010 at 12:18 AM, Sebastian Pop <sebpop@gmail.com> wrote:
> Committed to the graphite branch.
>
> 2010-11-22  Sebastian Pop  <sebastian.pop@amd.com>
>
>        * sese.c (rename_uses): Call recompute_tree_invariant_for_addr_expr
>        when replacing a constant in an ADDR_EXPR.
> ---
>  gcc/ChangeLog.graphite |    5 +++++
>  gcc/sese.c             |   13 +++++++++++++
>  2 files changed, 18 insertions(+), 0 deletions(-)
>
> diff --git a/gcc/ChangeLog.graphite b/gcc/ChangeLog.graphite
> index c2da86f..e5df72e 100644
> --- a/gcc/ChangeLog.graphite
> +++ b/gcc/ChangeLog.graphite
> @@ -1,3 +1,8 @@
> +2010-11-22  Sebastian Pop  <sebastian.pop@amd.com>
> +
> +       * sese.c (rename_uses): Call recompute_tree_invariant_for_addr_expr
> +       when replacing a constant in an ADDR_EXPR.
> +
>  2010-10-20  Sebastian Pop  <sebastian.pop@amd.com>
>
>        * graphite-blocking.c (lst_do_strip_mine_loop): Extra parameter
> diff --git a/gcc/sese.c b/gcc/sese.c
> index ffcb51c..dbb0cd7 100644
> --- a/gcc/sese.c
> +++ b/gcc/sese.c
> @@ -547,6 +547,19 @@ rename_uses (gimple copy, htab_t rename_map, gimple_stmt_iterator *gsi_tgt,
>                                       true, NULL_TREE);
>       gsi_insert_seq_before (gsi_tgt, stmts, GSI_SAME_STMT);
>       replace_exp (use_p, new_expr);
> +
> +
> +      if (TREE_CODE (new_expr) == INTEGER_CST)
> +       {
> +         tree lhs = gimple_assign_lhs (copy);
> +         tree rhs = gimple_assign_rhs1 (copy);
> +
> +         if (TREE_CODE (lhs) == ADDR_EXPR)

The lhs of an assign can never be ADDR_EXPR.

> +           recompute_tree_invariant_for_addr_expr (lhs);
> +         if (TREE_CODE (rhs) == ADDR_EXPR)
> +           recompute_tree_invariant_for_addr_expr (rhs);

And I'm confused anyway - of new_expr is an INTEGER_CST, how
come it is an ADDR_EXPR?

> +       }
> +
>       set_rename (rename_map, old_name, new_expr);
>     }
>  }
> --
> 1.7.0.4
>
>
Sebastian Pop - Nov. 24, 2010, 12:13 a.m.
On Tue, Nov 23, 2010 at 06:45, Richard Guenther
<richard.guenther@gmail.com> wrote:
> On Tue, Nov 23, 2010 at 12:18 AM, Sebastian Pop <sebpop@gmail.com> wrote:
>> Committed to the graphite branch.
>>
>> 2010-11-22  Sebastian Pop  <sebastian.pop@amd.com>
>>
>>        * sese.c (rename_uses): Call recompute_tree_invariant_for_addr_expr
>>        when replacing a constant in an ADDR_EXPR.
>> ---
>>  gcc/ChangeLog.graphite |    5 +++++
>>  gcc/sese.c             |   13 +++++++++++++
>>  2 files changed, 18 insertions(+), 0 deletions(-)
>>
>> diff --git a/gcc/ChangeLog.graphite b/gcc/ChangeLog.graphite
>> index c2da86f..e5df72e 100644
>> --- a/gcc/ChangeLog.graphite
>> +++ b/gcc/ChangeLog.graphite
>> @@ -1,3 +1,8 @@
>> +2010-11-22  Sebastian Pop  <sebastian.pop@amd.com>
>> +
>> +       * sese.c (rename_uses): Call recompute_tree_invariant_for_addr_expr
>> +       when replacing a constant in an ADDR_EXPR.
>> +
>>  2010-10-20  Sebastian Pop  <sebastian.pop@amd.com>
>>
>>        * graphite-blocking.c (lst_do_strip_mine_loop): Extra parameter
>> diff --git a/gcc/sese.c b/gcc/sese.c
>> index ffcb51c..dbb0cd7 100644
>> --- a/gcc/sese.c
>> +++ b/gcc/sese.c
>> @@ -547,6 +547,19 @@ rename_uses (gimple copy, htab_t rename_map, gimple_stmt_iterator *gsi_tgt,
>>                                       true, NULL_TREE);
>>       gsi_insert_seq_before (gsi_tgt, stmts, GSI_SAME_STMT);
>>       replace_exp (use_p, new_expr);
>> +
>> +
>> +      if (TREE_CODE (new_expr) == INTEGER_CST)
>> +       {
>> +         tree lhs = gimple_assign_lhs (copy);
>> +         tree rhs = gimple_assign_rhs1 (copy);
>> +
>> +         if (TREE_CODE (lhs) == ADDR_EXPR)
>
> The lhs of an assign can never be ADDR_EXPR.
>

I removed this.

>> +           recompute_tree_invariant_for_addr_expr (lhs);
>> +         if (TREE_CODE (rhs) == ADDR_EXPR)
>> +           recompute_tree_invariant_for_addr_expr (rhs);
>
> And I'm confused anyway - of new_expr is an INTEGER_CST, how
> come it is an ADDR_EXPR?
>

rhs is an ADDR_EXPR and we replace some SSA_NAME that indexes into
that array with a constant:
for instance, I had an ICE when replacing "i" with "9" in A[i], as in
the new form, A[9] is invariant.

Sebastian
Richard Guenther - Nov. 24, 2010, 11:48 a.m.
On Wed, Nov 24, 2010 at 1:13 AM, Sebastian Pop <sebpop@gmail.com> wrote:
> On Tue, Nov 23, 2010 at 06:45, Richard Guenther
> <richard.guenther@gmail.com> wrote:
>> On Tue, Nov 23, 2010 at 12:18 AM, Sebastian Pop <sebpop@gmail.com> wrote:
>>> Committed to the graphite branch.
>>>
>>> 2010-11-22  Sebastian Pop  <sebastian.pop@amd.com>
>>>
>>>        * sese.c (rename_uses): Call recompute_tree_invariant_for_addr_expr
>>>        when replacing a constant in an ADDR_EXPR.
>>> ---
>>>  gcc/ChangeLog.graphite |    5 +++++
>>>  gcc/sese.c             |   13 +++++++++++++
>>>  2 files changed, 18 insertions(+), 0 deletions(-)
>>>
>>> diff --git a/gcc/ChangeLog.graphite b/gcc/ChangeLog.graphite
>>> index c2da86f..e5df72e 100644
>>> --- a/gcc/ChangeLog.graphite
>>> +++ b/gcc/ChangeLog.graphite
>>> @@ -1,3 +1,8 @@
>>> +2010-11-22  Sebastian Pop  <sebastian.pop@amd.com>
>>> +
>>> +       * sese.c (rename_uses): Call recompute_tree_invariant_for_addr_expr
>>> +       when replacing a constant in an ADDR_EXPR.
>>> +
>>>  2010-10-20  Sebastian Pop  <sebastian.pop@amd.com>
>>>
>>>        * graphite-blocking.c (lst_do_strip_mine_loop): Extra parameter
>>> diff --git a/gcc/sese.c b/gcc/sese.c
>>> index ffcb51c..dbb0cd7 100644
>>> --- a/gcc/sese.c
>>> +++ b/gcc/sese.c
>>> @@ -547,6 +547,19 @@ rename_uses (gimple copy, htab_t rename_map, gimple_stmt_iterator *gsi_tgt,
>>>                                       true, NULL_TREE);
>>>       gsi_insert_seq_before (gsi_tgt, stmts, GSI_SAME_STMT);
>>>       replace_exp (use_p, new_expr);
>>> +
>>> +
>>> +      if (TREE_CODE (new_expr) == INTEGER_CST)
>>> +       {
>>> +         tree lhs = gimple_assign_lhs (copy);
>>> +         tree rhs = gimple_assign_rhs1 (copy);
>>> +
>>> +         if (TREE_CODE (lhs) == ADDR_EXPR)
>>
>> The lhs of an assign can never be ADDR_EXPR.
>>
>
> I removed this.
>
>>> +           recompute_tree_invariant_for_addr_expr (lhs);
>>> +         if (TREE_CODE (rhs) == ADDR_EXPR)
>>> +           recompute_tree_invariant_for_addr_expr (rhs);
>>
>> And I'm confused anyway - of new_expr is an INTEGER_CST, how
>> come it is an ADDR_EXPR?
>>
>
> rhs is an ADDR_EXPR and we replace some SSA_NAME that indexes into
> that array with a constant:
> for instance, I had an ICE when replacing "i" with "9" in A[i], as in
> the new form, A[9] is invariant.

Ah, I see.

Richard.

> Sebastian
>

Patch

diff --git a/gcc/ChangeLog.graphite b/gcc/ChangeLog.graphite
index c2da86f..e5df72e 100644
--- a/gcc/ChangeLog.graphite
+++ b/gcc/ChangeLog.graphite
@@ -1,3 +1,8 @@ 
+2010-11-22  Sebastian Pop  <sebastian.pop@amd.com>
+
+	* sese.c (rename_uses): Call recompute_tree_invariant_for_addr_expr
+	when replacing a constant in an ADDR_EXPR.
+
 2010-10-20  Sebastian Pop  <sebastian.pop@amd.com>
 
 	* graphite-blocking.c (lst_do_strip_mine_loop): Extra parameter
diff --git a/gcc/sese.c b/gcc/sese.c
index ffcb51c..dbb0cd7 100644
--- a/gcc/sese.c
+++ b/gcc/sese.c
@@ -547,6 +547,19 @@  rename_uses (gimple copy, htab_t rename_map, gimple_stmt_iterator *gsi_tgt,
 				       true, NULL_TREE);
       gsi_insert_seq_before (gsi_tgt, stmts, GSI_SAME_STMT);
       replace_exp (use_p, new_expr);
+
+
+      if (TREE_CODE (new_expr) == INTEGER_CST)
+	{
+	  tree lhs = gimple_assign_lhs (copy);
+	  tree rhs = gimple_assign_rhs1 (copy);
+
+	  if (TREE_CODE (lhs) == ADDR_EXPR)
+	    recompute_tree_invariant_for_addr_expr (lhs);
+	  if (TREE_CODE (rhs) == ADDR_EXPR)
+	    recompute_tree_invariant_for_addr_expr (rhs);
+	}
+
       set_rename (rename_map, old_name, new_expr);
     }
 }