public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
* [PATCH GCC][4/6]Relax minimal segment length of DR_B for merging alias check
@ 2017-05-23 17:06 Bin Cheng
  2017-05-25 15:18 ` Bin.Cheng
  0 siblings, 1 reply; 5+ messages in thread
From: Bin Cheng @ 2017-05-23 17:06 UTC (permalink / raw)
  To: gcc-patches; +Cc: nd

[-- Attachment #1: Type: text/plain, Size: 604 bytes --]

Hi,
As commented in https://gcc.gnu.org/bugzilla/show_bug.cgi?id=80815#c1,
We can relax minimal segment length of DR_B for merging.  With this change,
the new test can be improved to only one alias check.  Note the
condition is still accurate after this patch, it won't introduce false
alias.
Bootstrap and test on x86_64 and AArch64, is it OK?

2017-05-22  Bin Cheng  <bin.cheng@arm.com>

	* tree-data-ref.c (prune_runtime_alias_test_list): Relax minimal
	segment length for dr_b.

gcc/testsuite/ChangeLog
2017-05-22  Bin Cheng  <bin.cheng@arm.com>

	* gcc.dg/vect/pr80815-3.c: New test.

[-- Attachment #2: 0004-minimal-seg-length-for-dr_b-20170516.txt --]
[-- Type: text/plain, Size: 2217 bytes --]

From 8a570eb93cfaff6fcecdce6b91dd665a81d38e29 Mon Sep 17 00:00:00 2001
From: Bin Cheng <binche01@e108451-lin.cambridge.arm.com>
Date: Mon, 22 May 2017 11:34:18 +0100
Subject: [PATCH 4/6] minimal-seg-length-for-dr_b-20170516.txt

---
 gcc/testsuite/gcc.dg/vect/pr80815-3.c | 45 +++++++++++++++++++++++++++++++++++
 gcc/tree-data-ref.c                   |  5 +++-
 2 files changed, 49 insertions(+), 1 deletion(-)
 create mode 100644 gcc/testsuite/gcc.dg/vect/pr80815-3.c

diff --git a/gcc/testsuite/gcc.dg/vect/pr80815-3.c b/gcc/testsuite/gcc.dg/vect/pr80815-3.c
new file mode 100644
index 0000000..dae01fa
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/vect/pr80815-3.c
@@ -0,0 +1,45 @@
+/* { dg-require-effective-target vect_int } */
+
+#include "tree-vect.h"
+int arr[2048];
+int res[100] = { 2148, 2146, 2144, 2142, 2140, 2138, 2136, 2134, 2132, 2130,
+		 2128, 2126, 2124, 2122, 2120, 2118, 2116, 2114, 2112, 2110,
+		 2108, 2106, 2104, 2102, 2100, 2098, 2096, 2094, 2092, 2090,
+		 2088, 2086, 2084, 2082, 2080, 2078, 2076, 2074, 2072, 2070,
+		 2068, 2066, 2064, 2062, 2060, 2058, 2056, 2054, 3078, 2050};
+
+__attribute__ ((noinline)) int
+foo (int *a, int *b, int len)
+{
+  int i;
+  int *a1 = a;
+  int *a0 = a1 - 4;
+  for (i = 0; i < len; i++)
+    {
+      *b = *a0 + *a1;
+      b--;
+      a0++;
+      a1++;
+    }
+  return 0;
+}
+
+int main (void)
+{
+  int *a = &arr[1027];
+  int *b = &arr[1024];
+
+  int i;
+  for (i = 0; i < 2048; i++)
+    arr[i] = i;
+
+  foo (a, b, 50);
+
+  for (i = 975; i < 1025; i++)
+    if (arr[i] != res[i - 975])
+      abort ();
+
+  return 0;
+}
+
+/* { dg-final { scan-tree-dump "improved number of alias checks from \[0-9\]* to 1" "vect" } } */
diff --git a/gcc/tree-data-ref.c b/gcc/tree-data-ref.c
index f0799d9..5d9054d 100644
--- a/gcc/tree-data-ref.c
+++ b/gcc/tree-data-ref.c
@@ -1286,7 +1286,10 @@ prune_runtime_alias_test_list (vec<dr_with_seg_len_pair_t> *alias_pairs,
 		min_seg_len_b = 0 - min_seg_len_b;
 	    }
 	  else
-	    min_seg_len_b = factor;
+	    {
+	      min_seg_len_b = factor;
+	      min_seg_len_b *= absu_hwi (tree_to_shwi (DR_STEP (dr_b1->dr)));
+	    }
 
 	  /* Now we try to merge alias check dr_a1 & dr_b and dr_a2 & dr_b.
 
-- 
1.9.1


^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [PATCH GCC][4/6]Relax minimal segment length of DR_B for merging alias check
  2017-05-23 17:06 [PATCH GCC][4/6]Relax minimal segment length of DR_B for merging alias check Bin Cheng
@ 2017-05-25 15:18 ` Bin.Cheng
  2017-05-30 11:29   ` Richard Biener
  0 siblings, 1 reply; 5+ messages in thread
From: Bin.Cheng @ 2017-05-25 15:18 UTC (permalink / raw)
  Cc: gcc-patches

[-- Attachment #1: Type: text/plain, Size: 811 bytes --]

On Tue, May 23, 2017 at 5:23 PM, Bin Cheng <Bin.Cheng@arm.com> wrote:
> Hi,
> As commented in https://gcc.gnu.org/bugzilla/show_bug.cgi?id=80815#c1,
> We can relax minimal segment length of DR_B for merging.  With this change,
> the new test can be improved to only one alias check.  Note the
> condition is still accurate after this patch, it won't introduce false
> alias.
> Bootstrap and test on x86_64 and AArch64, is it OK?
Updated patch wrto change of previous patch.

Bootstrap and test on x86_64 and AArch64.

Thanks,
bin
>
> 2017-05-22  Bin Cheng  <bin.cheng@arm.com>
>
>         * tree-data-ref.c (prune_runtime_alias_test_list): Relax minimal
>         segment length for dr_b.
>
> gcc/testsuite/ChangeLog
> 2017-05-22  Bin Cheng  <bin.cheng@arm.com>
>
>         * gcc.dg/vect/pr80815-3.c: New test.

[-- Attachment #2: 0004-minimal-seg-length-for-dr_b-20170519.txt --]
[-- Type: text/plain, Size: 2229 bytes --]

From 654996fde92852a50c49fefeff79489e01d7db97 Mon Sep 17 00:00:00 2001
From: Bin Cheng <binche01@e108451-lin.cambridge.arm.com>
Date: Mon, 22 May 2017 11:34:18 +0100
Subject: [PATCH 4/6] minimal-seg-length-for-dr_b-20170519.txt

---
 gcc/testsuite/gcc.dg/vect/pr80815-3.c | 45 +++++++++++++++++++++++++++++++++++
 gcc/tree-data-ref.c                   |  4 +++-
 2 files changed, 48 insertions(+), 1 deletion(-)
 create mode 100644 gcc/testsuite/gcc.dg/vect/pr80815-3.c

diff --git a/gcc/testsuite/gcc.dg/vect/pr80815-3.c b/gcc/testsuite/gcc.dg/vect/pr80815-3.c
new file mode 100644
index 0000000..dae01fa
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/vect/pr80815-3.c
@@ -0,0 +1,45 @@
+/* { dg-require-effective-target vect_int } */
+
+#include "tree-vect.h"
+int arr[2048];
+int res[100] = { 2148, 2146, 2144, 2142, 2140, 2138, 2136, 2134, 2132, 2130,
+		 2128, 2126, 2124, 2122, 2120, 2118, 2116, 2114, 2112, 2110,
+		 2108, 2106, 2104, 2102, 2100, 2098, 2096, 2094, 2092, 2090,
+		 2088, 2086, 2084, 2082, 2080, 2078, 2076, 2074, 2072, 2070,
+		 2068, 2066, 2064, 2062, 2060, 2058, 2056, 2054, 3078, 2050};
+
+__attribute__ ((noinline)) int
+foo (int *a, int *b, int len)
+{
+  int i;
+  int *a1 = a;
+  int *a0 = a1 - 4;
+  for (i = 0; i < len; i++)
+    {
+      *b = *a0 + *a1;
+      b--;
+      a0++;
+      a1++;
+    }
+  return 0;
+}
+
+int main (void)
+{
+  int *a = &arr[1027];
+  int *b = &arr[1024];
+
+  int i;
+  for (i = 0; i < 2048; i++)
+    arr[i] = i;
+
+  foo (a, b, 50);
+
+  for (i = 975; i < 1025; i++)
+    if (arr[i] != res[i - 975])
+      abort ();
+
+  return 0;
+}
+
+/* { dg-final { scan-tree-dump "improved number of alias checks from \[0-9\]* to 1" "vect" } } */
diff --git a/gcc/tree-data-ref.c b/gcc/tree-data-ref.c
index 1a28000..0b5fd1b 100644
--- a/gcc/tree-data-ref.c
+++ b/gcc/tree-data-ref.c
@@ -1287,7 +1287,9 @@ prune_runtime_alias_test_list (vec<dr_with_seg_len_pair_t> *alias_pairs,
 		min_seg_len_b = wi::neg (min_seg_len_b);
 	    }
 	  else
-	    min_seg_len_b = wi::uhwi (factor, TYPE_PRECISION (sizetype));
+	    {
+	      min_seg_len_b = wi::mul (factor, wi::abs (DR_STEP (dr_b1->dr)));
+	    }
 
 	  /* Now we try to merge alias check dr_a1 & dr_b and dr_a2 & dr_b.
 
-- 
1.9.1


^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [PATCH GCC][4/6]Relax minimal segment length of DR_B for merging alias check
  2017-05-25 15:18 ` Bin.Cheng
@ 2017-05-30 11:29   ` Richard Biener
  2017-05-30 15:34     ` Bin.Cheng
  0 siblings, 1 reply; 5+ messages in thread
From: Richard Biener @ 2017-05-30 11:29 UTC (permalink / raw)
  To: Bin.Cheng; +Cc: gcc-patches

On Thu, May 25, 2017 at 5:16 PM, Bin.Cheng <amker.cheng@gmail.com> wrote:
> On Tue, May 23, 2017 at 5:23 PM, Bin Cheng <Bin.Cheng@arm.com> wrote:
>> Hi,
>> As commented in https://gcc.gnu.org/bugzilla/show_bug.cgi?id=80815#c1,
>> We can relax minimal segment length of DR_B for merging.  With this change,
>> the new test can be improved to only one alias check.  Note the
>> condition is still accurate after this patch, it won't introduce false
>> alias.
>> Bootstrap and test on x86_64 and AArch64, is it OK?
> Updated patch wrto change of previous patch.
>
> Bootstrap and test on x86_64 and AArch64.

Please omit unnecessary braces.  Ok with that change.

Note that

          if (tree_fits_uhwi_p (dr_b1->seg_len))
            {
              min_seg_len_b = dr_b1->seg_len;
              if (tree_int_cst_sign_bit (dr_b1->seg_len))
                min_seg_len_b = wi::neg (min_seg_len_b);

the tree_fits_uhwi_p check is somewhat bogus now that min_seg_len_b is
a wide-int.
It should probably be changed to TREE_CODE (dr_b1->seg_len) == INTEGER_CST
which also means  that

              min_seg_len_b = wi::abs (dr_b1->seg_len);

should work.

Richard.


> Thanks,
> bin
>>
>> 2017-05-22  Bin Cheng  <bin.cheng@arm.com>
>>
>>         * tree-data-ref.c (prune_runtime_alias_test_list): Relax minimal
>>         segment length for dr_b.
>>
>> gcc/testsuite/ChangeLog
>> 2017-05-22  Bin Cheng  <bin.cheng@arm.com>
>>
>>         * gcc.dg/vect/pr80815-3.c: New test.

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [PATCH GCC][4/6]Relax minimal segment length of DR_B for merging alias check
  2017-05-30 11:29   ` Richard Biener
@ 2017-05-30 15:34     ` Bin.Cheng
  2017-05-31  7:33       ` Richard Biener
  0 siblings, 1 reply; 5+ messages in thread
From: Bin.Cheng @ 2017-05-30 15:34 UTC (permalink / raw)
  To: Richard Biener; +Cc: gcc-patches

[-- Attachment #1: Type: text/plain, Size: 1716 bytes --]

On Tue, May 30, 2017 at 12:27 PM, Richard Biener
<richard.guenther@gmail.com> wrote:
> On Thu, May 25, 2017 at 5:16 PM, Bin.Cheng <amker.cheng@gmail.com> wrote:
>> On Tue, May 23, 2017 at 5:23 PM, Bin Cheng <Bin.Cheng@arm.com> wrote:
>>> Hi,
>>> As commented in https://gcc.gnu.org/bugzilla/show_bug.cgi?id=80815#c1,
>>> We can relax minimal segment length of DR_B for merging.  With this change,
>>> the new test can be improved to only one alias check.  Note the
>>> condition is still accurate after this patch, it won't introduce false
>>> alias.
>>> Bootstrap and test on x86_64 and AArch64, is it OK?
>> Updated patch wrto change of previous patch.
>>
>> Bootstrap and test on x86_64 and AArch64.
>
> Please omit unnecessary braces.  Ok with that change.
>
> Note that
>
>           if (tree_fits_uhwi_p (dr_b1->seg_len))
>             {
>               min_seg_len_b = dr_b1->seg_len;
>               if (tree_int_cst_sign_bit (dr_b1->seg_len))
>                 min_seg_len_b = wi::neg (min_seg_len_b);
>
> the tree_fits_uhwi_p check is somewhat bogus now that min_seg_len_b is
> a wide-int.
> It should probably be changed to TREE_CODE (dr_b1->seg_len) == INTEGER_CST
> which also means  that
>
>               min_seg_len_b = wi::abs (dr_b1->seg_len);
>
> should work.
Thanks for reviewing.  Here is updated patch.  Bootstrap and test on
x86_64.  Is it OK?

Thanks,
bin
>
> Richard.
>
>
>> Thanks,
>> bin
>>>
>>> 2017-05-22  Bin Cheng  <bin.cheng@arm.com>
>>>
>>>         * tree-data-ref.c (prune_runtime_alias_test_list): Relax minimal
>>>         segment length for dr_b.
>>>
>>> gcc/testsuite/ChangeLog
>>> 2017-05-22  Bin Cheng  <bin.cheng@arm.com>
>>>
>>>         * gcc.dg/vect/pr80815-3.c: New test.

[-- Attachment #2: 0004-minimal-seg-length-for-dr_b-20170529.txt --]
[-- Type: text/plain, Size: 2025 bytes --]

diff --git a/gcc/testsuite/gcc.dg/vect/pr80815-3.c b/gcc/testsuite/gcc.dg/vect/pr80815-3.c
new file mode 100644
index 0000000..dae01fa
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/vect/pr80815-3.c
@@ -0,0 +1,45 @@
+/* { dg-require-effective-target vect_int } */
+
+#include "tree-vect.h"
+int arr[2048];
+int res[100] = { 2148, 2146, 2144, 2142, 2140, 2138, 2136, 2134, 2132, 2130,
+		 2128, 2126, 2124, 2122, 2120, 2118, 2116, 2114, 2112, 2110,
+		 2108, 2106, 2104, 2102, 2100, 2098, 2096, 2094, 2092, 2090,
+		 2088, 2086, 2084, 2082, 2080, 2078, 2076, 2074, 2072, 2070,
+		 2068, 2066, 2064, 2062, 2060, 2058, 2056, 2054, 3078, 2050};
+
+__attribute__ ((noinline)) int
+foo (int *a, int *b, int len)
+{
+  int i;
+  int *a1 = a;
+  int *a0 = a1 - 4;
+  for (i = 0; i < len; i++)
+    {
+      *b = *a0 + *a1;
+      b--;
+      a0++;
+      a1++;
+    }
+  return 0;
+}
+
+int main (void)
+{
+  int *a = &arr[1027];
+  int *b = &arr[1024];
+
+  int i;
+  for (i = 0; i < 2048; i++)
+    arr[i] = i;
+
+  foo (a, b, 50);
+
+  for (i = 975; i < 1025; i++)
+    if (arr[i] != res[i - 975])
+      abort ();
+
+  return 0;
+}
+
+/* { dg-final { scan-tree-dump "improved number of alias checks from \[0-9\]* to 1" "vect" } } */
diff --git a/gcc/tree-data-ref.c b/gcc/tree-data-ref.c
index cfff7c2..c4275e2 100644
--- a/gcc/tree-data-ref.c
+++ b/gcc/tree-data-ref.c
@@ -1361,14 +1361,10 @@ prune_runtime_alias_test_list (vec<dr_with_seg_len_pair_t> *alias_pairs,
 	  wide_int min_seg_len_b;
 	  tree new_seg_len;
 
-	  if (tree_fits_uhwi_p (dr_b1->seg_len))
-	    {
-	      min_seg_len_b = dr_b1->seg_len;
-	      if (tree_int_cst_sign_bit (dr_b1->seg_len))
-		min_seg_len_b = wi::neg (min_seg_len_b);
-	    }
+	  if (TREE_CODE (dr_b1->seg_len) == INTEGER_CST)
+	    min_seg_len_b = wi::abs (dr_b1->seg_len);
 	  else
-	    min_seg_len_b = wi::uhwi (factor, TYPE_PRECISION (sizetype));
+	    min_seg_len_b = wi::mul (factor, wi::abs (DR_STEP (dr_b1->dr)));
 
 	  /* Now we try to merge alias check dr_a1 & dr_b and dr_a2 & dr_b.
 

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [PATCH GCC][4/6]Relax minimal segment length of DR_B for merging alias check
  2017-05-30 15:34     ` Bin.Cheng
@ 2017-05-31  7:33       ` Richard Biener
  0 siblings, 0 replies; 5+ messages in thread
From: Richard Biener @ 2017-05-31  7:33 UTC (permalink / raw)
  To: Bin.Cheng; +Cc: gcc-patches

On Tue, May 30, 2017 at 5:29 PM, Bin.Cheng <amker.cheng@gmail.com> wrote:
> On Tue, May 30, 2017 at 12:27 PM, Richard Biener
> <richard.guenther@gmail.com> wrote:
>> On Thu, May 25, 2017 at 5:16 PM, Bin.Cheng <amker.cheng@gmail.com> wrote:
>>> On Tue, May 23, 2017 at 5:23 PM, Bin Cheng <Bin.Cheng@arm.com> wrote:
>>>> Hi,
>>>> As commented in https://gcc.gnu.org/bugzilla/show_bug.cgi?id=80815#c1,
>>>> We can relax minimal segment length of DR_B for merging.  With this change,
>>>> the new test can be improved to only one alias check.  Note the
>>>> condition is still accurate after this patch, it won't introduce false
>>>> alias.
>>>> Bootstrap and test on x86_64 and AArch64, is it OK?
>>> Updated patch wrto change of previous patch.
>>>
>>> Bootstrap and test on x86_64 and AArch64.
>>
>> Please omit unnecessary braces.  Ok with that change.
>>
>> Note that
>>
>>           if (tree_fits_uhwi_p (dr_b1->seg_len))
>>             {
>>               min_seg_len_b = dr_b1->seg_len;
>>               if (tree_int_cst_sign_bit (dr_b1->seg_len))
>>                 min_seg_len_b = wi::neg (min_seg_len_b);
>>
>> the tree_fits_uhwi_p check is somewhat bogus now that min_seg_len_b is
>> a wide-int.
>> It should probably be changed to TREE_CODE (dr_b1->seg_len) == INTEGER_CST
>> which also means  that
>>
>>               min_seg_len_b = wi::abs (dr_b1->seg_len);
>>
>> should work.
> Thanks for reviewing.  Here is updated patch.  Bootstrap and test on
> x86_64.  Is it OK?

Ok.

Richard.

> Thanks,
> bin
>>
>> Richard.
>>
>>
>>> Thanks,
>>> bin
>>>>
>>>> 2017-05-22  Bin Cheng  <bin.cheng@arm.com>
>>>>
>>>>         * tree-data-ref.c (prune_runtime_alias_test_list): Relax minimal
>>>>         segment length for dr_b.
>>>>
>>>> gcc/testsuite/ChangeLog
>>>> 2017-05-22  Bin Cheng  <bin.cheng@arm.com>
>>>>
>>>>         * gcc.dg/vect/pr80815-3.c: New test.

^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2017-05-31  7:25 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2017-05-23 17:06 [PATCH GCC][4/6]Relax minimal segment length of DR_B for merging alias check Bin Cheng
2017-05-25 15:18 ` Bin.Cheng
2017-05-30 11:29   ` Richard Biener
2017-05-30 15:34     ` Bin.Cheng
2017-05-31  7:33       ` Richard Biener

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).