Patchwork Fix PR48805: Do not instantiate ADDR_EXPRs

login
register
mail settings
Submitter Sebastian Pop
Date July 23, 2011, 2:35 p.m.
Message ID <1311431756-16262-1-git-send-email-sebpop@gmail.com>
Download mbox | patch
Permalink /patch/106473/
State New
Headers show

Comments

Sebastian Pop - July 23, 2011, 2:35 p.m.
With this patch we avoid instantiating ADDR_EXPR: it makes no sense
to translate b[i] into b[{0, +, 1}_1].

Bootstrapped and tested on amd64-linux.

2011-07-22  Sebastian Pop  <sebastian.pop@amd.com>

	PR middle-end/48805
	* tree-scalar-evolution.c (instantiate_scev_r): Return
	chrec_dont_know for ADDR_EXPR.

	* gcc.dg/graphite/id-pr48805.c: New.
---
 gcc/ChangeLog                              |    6 ++++++
 gcc/testsuite/ChangeLog                    |    5 +++++
 gcc/testsuite/gcc.dg/graphite/id-pr48805.c |   20 ++++++++++++++++++++
 gcc/tree-scalar-evolution.c                |    1 +
 4 files changed, 32 insertions(+), 0 deletions(-)
 create mode 100644 gcc/testsuite/gcc.dg/graphite/id-pr48805.c
Sebastian Pop - July 23, 2011, 2:38 p.m.
On Sat, Jul 23, 2011 at 09:35, Sebastian Pop <sebpop@gmail.com> wrote:
> With this patch we avoid instantiating ADDR_EXPR: it makes no sense
> to translate b[i] into b[{0, +, 1}_1].
>

This should have been &b[i] and &b[{0, +, 1}_1].

Ok for trunk?

Thanks,
Sebastian

> Bootstrapped and tested on amd64-linux.
>
> 2011-07-22  Sebastian Pop  <sebastian.pop@amd.com>
>
>        PR middle-end/48805
>        * tree-scalar-evolution.c (instantiate_scev_r): Return
>        chrec_dont_know for ADDR_EXPR.
>
>        * gcc.dg/graphite/id-pr48805.c: New.
> ---
>  gcc/ChangeLog                              |    6 ++++++
>  gcc/testsuite/ChangeLog                    |    5 +++++
>  gcc/testsuite/gcc.dg/graphite/id-pr48805.c |   20 ++++++++++++++++++++
>  gcc/tree-scalar-evolution.c                |    1 +
>  4 files changed, 32 insertions(+), 0 deletions(-)
>  create mode 100644 gcc/testsuite/gcc.dg/graphite/id-pr48805.c
>
> diff --git a/gcc/ChangeLog b/gcc/ChangeLog
> index 303c9c9..6a343b9 100644
> --- a/gcc/ChangeLog
> +++ b/gcc/ChangeLog
> @@ -1,5 +1,11 @@
>  2011-07-22  Sebastian Pop  <sebastian.pop@amd.com>
>
> +       PR middle-end/48805
> +       * tree-scalar-evolution.c (instantiate_scev_r): Return
> +       chrec_dont_know for ADDR_EXPR.
> +
> +2011-07-22  Sebastian Pop  <sebastian.pop@amd.com>
> +
>        PR middle-end/48648
>        * graphite-clast-to-gimple.c (clast_get_body_of_loop): Handle
>        CLAST assignments.
> diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog
> index bfdbcfb..9c59a43 100644
> --- a/gcc/testsuite/ChangeLog
> +++ b/gcc/testsuite/ChangeLog
> @@ -1,5 +1,10 @@
>  2011-07-22  Sebastian Pop  <sebastian.pop@amd.com>
>
> +       PR middle-end/48805
> +       * gcc.dg/graphite/id-pr48805.c: New.
> +
> +2011-07-22  Sebastian Pop  <sebastian.pop@amd.com>
> +
>        PR middle-end/48648
>        * gcc.dg/graphite/id-pr48648.c: New.
>
> diff --git a/gcc/testsuite/gcc.dg/graphite/id-pr48805.c b/gcc/testsuite/gcc.dg/graphite/id-pr48805.c
> new file mode 100644
> index 0000000..f13a828
> --- /dev/null
> +++ b/gcc/testsuite/gcc.dg/graphite/id-pr48805.c
> @@ -0,0 +1,20 @@
> +void *A(const void *a);
> +void C(void);
> +
> +static void B(unsigned short a[])
> +{
> +  long i, j, tmp;
> +
> +  for(i = 0; i < 3; i++) {
> +    for(j = 1; j <= 3; j++)
> +      tmp -= a[i - j];
> +
> +    a[i] = (unsigned short)(tmp >> 1);
> +  }
> +}
> +void C(void)
> +{
> +  unsigned short a[3], b[3];
> +  B(b + 1);
> +  A(a);
> +}
> diff --git a/gcc/tree-scalar-evolution.c b/gcc/tree-scalar-evolution.c
> index bfa8c93..00fcd3f 100644
> --- a/gcc/tree-scalar-evolution.c
> +++ b/gcc/tree-scalar-evolution.c
> @@ -2645,6 +2645,7 @@ instantiate_scev_r (basic_block instantiate_below,
>                                   TREE_OPERAND (chrec, 0),
>                                   fold_conversions, cache, size_expr);
>
> +    case ADDR_EXPR:
>     case SCEV_NOT_KNOWN:
>       return chrec_dont_know;
>
> --
> 1.7.4.1
>
>
Richard Guenther - July 24, 2011, 10:36 a.m.
On Sat, Jul 23, 2011 at 4:38 PM, Sebastian Pop <sebpop@gmail.com> wrote:
> On Sat, Jul 23, 2011 at 09:35, Sebastian Pop <sebpop@gmail.com> wrote:
>> With this patch we avoid instantiating ADDR_EXPR: it makes no sense
>> to translate b[i] into b[{0, +, 1}_1].
>>
>
> This should have been &b[i] and &b[{0, +, 1}_1].
>
> Ok for trunk?

Ok.

Thanks,
Richard.

> Thanks,
> Sebastian
>
>> Bootstrapped and tested on amd64-linux.
>>
>> 2011-07-22  Sebastian Pop  <sebastian.pop@amd.com>
>>
>>        PR middle-end/48805
>>        * tree-scalar-evolution.c (instantiate_scev_r): Return
>>        chrec_dont_know for ADDR_EXPR.
>>
>>        * gcc.dg/graphite/id-pr48805.c: New.
>> ---
>>  gcc/ChangeLog                              |    6 ++++++
>>  gcc/testsuite/ChangeLog                    |    5 +++++
>>  gcc/testsuite/gcc.dg/graphite/id-pr48805.c |   20 ++++++++++++++++++++
>>  gcc/tree-scalar-evolution.c                |    1 +
>>  4 files changed, 32 insertions(+), 0 deletions(-)
>>  create mode 100644 gcc/testsuite/gcc.dg/graphite/id-pr48805.c
>>
>> diff --git a/gcc/ChangeLog b/gcc/ChangeLog
>> index 303c9c9..6a343b9 100644
>> --- a/gcc/ChangeLog
>> +++ b/gcc/ChangeLog
>> @@ -1,5 +1,11 @@
>>  2011-07-22  Sebastian Pop  <sebastian.pop@amd.com>
>>
>> +       PR middle-end/48805
>> +       * tree-scalar-evolution.c (instantiate_scev_r): Return
>> +       chrec_dont_know for ADDR_EXPR.
>> +
>> +2011-07-22  Sebastian Pop  <sebastian.pop@amd.com>
>> +
>>        PR middle-end/48648
>>        * graphite-clast-to-gimple.c (clast_get_body_of_loop): Handle
>>        CLAST assignments.
>> diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog
>> index bfdbcfb..9c59a43 100644
>> --- a/gcc/testsuite/ChangeLog
>> +++ b/gcc/testsuite/ChangeLog
>> @@ -1,5 +1,10 @@
>>  2011-07-22  Sebastian Pop  <sebastian.pop@amd.com>
>>
>> +       PR middle-end/48805
>> +       * gcc.dg/graphite/id-pr48805.c: New.
>> +
>> +2011-07-22  Sebastian Pop  <sebastian.pop@amd.com>
>> +
>>        PR middle-end/48648
>>        * gcc.dg/graphite/id-pr48648.c: New.
>>
>> diff --git a/gcc/testsuite/gcc.dg/graphite/id-pr48805.c b/gcc/testsuite/gcc.dg/graphite/id-pr48805.c
>> new file mode 100644
>> index 0000000..f13a828
>> --- /dev/null
>> +++ b/gcc/testsuite/gcc.dg/graphite/id-pr48805.c
>> @@ -0,0 +1,20 @@
>> +void *A(const void *a);
>> +void C(void);
>> +
>> +static void B(unsigned short a[])
>> +{
>> +  long i, j, tmp;
>> +
>> +  for(i = 0; i < 3; i++) {
>> +    for(j = 1; j <= 3; j++)
>> +      tmp -= a[i - j];
>> +
>> +    a[i] = (unsigned short)(tmp >> 1);
>> +  }
>> +}
>> +void C(void)
>> +{
>> +  unsigned short a[3], b[3];
>> +  B(b + 1);
>> +  A(a);
>> +}
>> diff --git a/gcc/tree-scalar-evolution.c b/gcc/tree-scalar-evolution.c
>> index bfa8c93..00fcd3f 100644
>> --- a/gcc/tree-scalar-evolution.c
>> +++ b/gcc/tree-scalar-evolution.c
>> @@ -2645,6 +2645,7 @@ instantiate_scev_r (basic_block instantiate_below,
>>                                   TREE_OPERAND (chrec, 0),
>>                                   fold_conversions, cache, size_expr);
>>
>> +    case ADDR_EXPR:
>>     case SCEV_NOT_KNOWN:
>>       return chrec_dont_know;
>>
>> --
>> 1.7.4.1
>>
>>
>

Patch

diff --git a/gcc/ChangeLog b/gcc/ChangeLog
index 303c9c9..6a343b9 100644
--- a/gcc/ChangeLog
+++ b/gcc/ChangeLog
@@ -1,5 +1,11 @@ 
 2011-07-22  Sebastian Pop  <sebastian.pop@amd.com>
 
+	PR middle-end/48805
+	* tree-scalar-evolution.c (instantiate_scev_r): Return
+	chrec_dont_know for ADDR_EXPR.
+
+2011-07-22  Sebastian Pop  <sebastian.pop@amd.com>
+
 	PR middle-end/48648
 	* graphite-clast-to-gimple.c (clast_get_body_of_loop): Handle
 	CLAST assignments.
diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog
index bfdbcfb..9c59a43 100644
--- a/gcc/testsuite/ChangeLog
+++ b/gcc/testsuite/ChangeLog
@@ -1,5 +1,10 @@ 
 2011-07-22  Sebastian Pop  <sebastian.pop@amd.com>
 
+	PR middle-end/48805
+	* gcc.dg/graphite/id-pr48805.c: New.
+
+2011-07-22  Sebastian Pop  <sebastian.pop@amd.com>
+
 	PR middle-end/48648
 	* gcc.dg/graphite/id-pr48648.c: New.
 
diff --git a/gcc/testsuite/gcc.dg/graphite/id-pr48805.c b/gcc/testsuite/gcc.dg/graphite/id-pr48805.c
new file mode 100644
index 0000000..f13a828
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/graphite/id-pr48805.c
@@ -0,0 +1,20 @@ 
+void *A(const void *a);
+void C(void);
+
+static void B(unsigned short a[])
+{
+  long i, j, tmp;
+
+  for(i = 0; i < 3; i++) {
+    for(j = 1; j <= 3; j++)
+      tmp -= a[i - j];
+
+    a[i] = (unsigned short)(tmp >> 1);
+  }
+}
+void C(void)
+{
+  unsigned short a[3], b[3];
+  B(b + 1);
+  A(a);
+}
diff --git a/gcc/tree-scalar-evolution.c b/gcc/tree-scalar-evolution.c
index bfa8c93..00fcd3f 100644
--- a/gcc/tree-scalar-evolution.c
+++ b/gcc/tree-scalar-evolution.c
@@ -2645,6 +2645,7 @@  instantiate_scev_r (basic_block instantiate_below,
 				   TREE_OPERAND (chrec, 0),
 				   fold_conversions, cache, size_expr);
 
+    case ADDR_EXPR:
     case SCEV_NOT_KNOWN:
       return chrec_dont_know;