public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
* [PATCH PR81408]Turn TREE level unsafe loop optimizations warning to missed optimization message
@ 2017-07-18  8:01 Bin Cheng
  2017-07-18  8:32 ` Richard Biener
  0 siblings, 1 reply; 4+ messages in thread
From: Bin Cheng @ 2017-07-18  8:01 UTC (permalink / raw)
  To: gcc-patches; +Cc: nd

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

Hi,
I removed unsafe loop optimization on TREE level last year, so GCC doesn't do unsafe
loop optimizations on TREE now.  All "unsafe loop optimizations" warnings reported by
TREE optimizers are simply missed optimizations.  This patch turns such warning into
missed optimization messages.  I didn't change when this will be dumped, for now it is
when called from ivopts.
Bootstrap and test on x86_64 and AArch64.  Is it OK?

Thanks,
bin
2017-07-13  Bin Cheng  <bin.cheng@arm.com>

	PR target/81408
	* tree-ssa-loop-niter.c (number_of_iterations_exit): Dump missed
	optimization for loop niter analysis.

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

	PR target/81408
	* g++.dg/tree-ssa/pr81408.C: New.
	* gcc.dg/tree-ssa/pr19210-1.c: Check dump message rather than warning.

[-- Attachment #2: pr81408-201714.txt --]
[-- Type: text/plain, Size: 4062 bytes --]

diff --git a/gcc/testsuite/g++.dg/tree-ssa/pr81408.C b/gcc/testsuite/g++.dg/tree-ssa/pr81408.C
new file mode 100644
index 0000000..354d362
--- /dev/null
+++ b/gcc/testsuite/g++.dg/tree-ssa/pr81408.C
@@ -0,0 +1,93 @@
+/* { dg-do compile } */
+/* { dg-options "-O2 -std=gnu++11 -fdump-tree-ivopts-missed -Wunsafe-loop-optimizations" } */
+
+namespace a {
+void b () __attribute__ ((__noreturn__));
+template <typename> struct d;
+template <typename e> struct d<e *>
+{
+  typedef e f;
+};
+struct g
+{
+  template <typename h> using i = h *;
+};
+}
+using a::d;
+template <typename j, typename> class k
+{
+  j l;
+
+public:
+  typename d<j>::f operator* () {}
+  void operator++ () { ++l; }
+  j
+  aa ()
+  {
+    return l;
+  }
+};
+template <typename m, typename n, typename ab>
+bool
+operator!= (k<m, ab> o, k<n, ab> p2)
+{
+  return o.aa () != p2.aa ();
+}
+struct p;
+namespace a {
+struct F
+{
+  struct q
+  {
+    using ai = g::i<p>;
+  };
+  using r = q::ai;
+};
+class H
+{
+public:
+  k<F::r, int> begin ();
+  k<F::r, int> end ();
+};
+int s;
+class I
+{
+public:
+  void
+  aq (char)
+  {
+    if (s)
+      b ();
+  }
+};
+class u : public I
+{
+public:
+  void
+  operator<< (u o (u))
+  {
+    o (*this);
+  }
+  u operator<< (void *);
+};
+template <typename at, typename au>
+at
+av (au o)
+{
+  o.aq ('\n');
+}
+u ax;
+}
+struct p
+{
+  char *ay;
+};
+a::H t;
+void
+ShowHelpListCommands ()
+{
+  for (auto c : t)
+    a::ax << c.ay << a::av;
+}
+
+/* { dg-final { scan-tree-dump "note: missed loop optimization: niters analysis ends up with assumptions." "ivopts" } } */
diff --git a/gcc/testsuite/gcc.dg/tree-ssa/pr19210-1.c b/gcc/testsuite/gcc.dg/tree-ssa/pr19210-1.c
index 3c8ee06..3c18470 100644
--- a/gcc/testsuite/gcc.dg/tree-ssa/pr19210-1.c
+++ b/gcc/testsuite/gcc.dg/tree-ssa/pr19210-1.c
@@ -1,15 +1,15 @@
 /* { dg-do compile } */
-/* { dg-options "-O2 -Wunsafe-loop-optimizations" } */
+/* { dg-options "-O2 -fdump-tree-ivopts-details -Wunsafe-loop-optimizations" } */
 extern void g(void);
 
 void
 f (unsigned n)
 {
   unsigned k;
-  for(k = 0;k <= n;k++) /* { dg-warning "missed loop optimization.*overflow" } */
+  for(k = 0;k <= n;k++) /* missed optimization for this loop.  */
     g();
 
-  for(k = 0;k <= n;k += 4) /* { dg-warning "missed loop optimization.*overflow" } */
+  for(k = 0;k <= n;k += 4) /* missed optimization for this loop.  */
     g();
 
   /* We used to get warning for this loop.  However, since then # of iterations
@@ -21,9 +21,14 @@ f (unsigned n)
     g();
 
   /* So we need the following loop, instead.  */
-  for(k = 4;k <= n;k += 5) /* { dg-warning "missed loop optimization.*overflow" } */
+  for(k = 4;k <= n;k += 5) /* missed optimization for this loop.  */
     g();
   
-  for(k = 15;k >= n;k--) /* { dg-warning "missed loop optimization.*overflow" } */
+  for(k = 15;k >= n;k--) /* missed optimization for this loop.  */
     g();
 }
+
+/* { dg-final { scan-tree-dump "pr19210-1.c:9:.*: missed loop optimization: niters analysis ends up with assumptions." "ivopts" } } */
+/* { dg-final { scan-tree-dump "pr19210-1.c:12:.*: missed loop optimization: niters analysis ends up with assumptions." "ivopts" } } */
+/* { dg-final { scan-tree-dump "pr19210-1.c:24:.*: missed loop optimization: niters analysis ends up with assumptions." "ivopts" } } */
+/* { dg-final { scan-tree-dump "pr19210-1.c:27:.*: missed loop optimization: niters analysis ends up with assumptions." "ivopts" } } */
diff --git a/gcc/tree-ssa-loop-niter.c b/gcc/tree-ssa-loop-niter.c
index 5a7cab5..1421002 100644
--- a/gcc/tree-ssa-loop-niter.c
+++ b/gcc/tree-ssa-loop-niter.c
@@ -2378,9 +2378,9 @@ number_of_iterations_exit (struct loop *loop, edge exit,
     return true;
 
   if (warn)
-    warning_at (gimple_location_safe (stmt),
-		OPT_Wunsafe_loop_optimizations,
-		"missed loop optimization, the loop counter may overflow");
+    dump_printf_loc (MSG_MISSED_OPTIMIZATION, gimple_location_safe (stmt),
+		     "missed loop optimization: niters analysis ends up "
+		     "with assumptions.\n");
 
   return false;
 }

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

* Re: [PATCH PR81408]Turn TREE level unsafe loop optimizations warning to missed optimization message
  2017-07-18  8:01 [PATCH PR81408]Turn TREE level unsafe loop optimizations warning to missed optimization message Bin Cheng
@ 2017-07-18  8:32 ` Richard Biener
  2017-07-18  9:13   ` Bin.Cheng
  0 siblings, 1 reply; 4+ messages in thread
From: Richard Biener @ 2017-07-18  8:32 UTC (permalink / raw)
  To: Bin Cheng; +Cc: gcc-patches, nd

On Tue, Jul 18, 2017 at 10:00 AM, Bin Cheng <Bin.Cheng@arm.com> wrote:
> Hi,
> I removed unsafe loop optimization on TREE level last year, so GCC doesn't do unsafe
> loop optimizations on TREE now.  All "unsafe loop optimizations" warnings reported by
> TREE optimizers are simply missed optimizations.  This patch turns such warning into
> missed optimization messages.  I didn't change when this will be dumped, for now it is
> when called from ivopts.
> Bootstrap and test on x86_64 and AArch64.  Is it OK?

Ok but can you change the testcase to not scan the ivopts dump but use
-fopt-info-loop-missed?
You should be able to match the output with dg-message.

Thanks,
Richard.

> Thanks,
> bin
> 2017-07-13  Bin Cheng  <bin.cheng@arm.com>
>
>         PR target/81408
>         * tree-ssa-loop-niter.c (number_of_iterations_exit): Dump missed
>         optimization for loop niter analysis.
>
> gcc/testsuite/ChangeLog
> 2017-07-13  Bin Cheng  <bin.cheng@arm.com>
>
>         PR target/81408
>         * g++.dg/tree-ssa/pr81408.C: New.
>         * gcc.dg/tree-ssa/pr19210-1.c: Check dump message rather than warning.

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

* Re: [PATCH PR81408]Turn TREE level unsafe loop optimizations warning to missed optimization message
  2017-07-18  8:32 ` Richard Biener
@ 2017-07-18  9:13   ` Bin.Cheng
  2017-07-18 11:22     ` Richard Biener
  0 siblings, 1 reply; 4+ messages in thread
From: Bin.Cheng @ 2017-07-18  9:13 UTC (permalink / raw)
  To: Richard Biener; +Cc: gcc-patches

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

On Tue, Jul 18, 2017 at 9:31 AM, Richard Biener
<richard.guenther@gmail.com> wrote:
> On Tue, Jul 18, 2017 at 10:00 AM, Bin Cheng <Bin.Cheng@arm.com> wrote:
>> Hi,
>> I removed unsafe loop optimization on TREE level last year, so GCC doesn't do unsafe
>> loop optimizations on TREE now.  All "unsafe loop optimizations" warnings reported by
>> TREE optimizers are simply missed optimizations.  This patch turns such warning into
>> missed optimization messages.  I didn't change when this will be dumped, for now it is
>> when called from ivopts.
>> Bootstrap and test on x86_64 and AArch64.  Is it OK?
>
> Ok but can you change the testcase to not scan the ivopts dump but use
> -fopt-info-loop-missed?
> You should be able to match the output with dg-message.
Thanks for reviewing.  New patch with test case updated accordingly.  Is it OK?

Thanks,
bin
>
> Thanks,
> Richard.
>
>> Thanks,
>> bin
>> 2017-07-13  Bin Cheng  <bin.cheng@arm.com>
>>
>>         PR target/81408
>>         * tree-ssa-loop-niter.c (number_of_iterations_exit): Dump missed
>>         optimization for loop niter analysis.
>>
>> gcc/testsuite/ChangeLog
>> 2017-07-13  Bin Cheng  <bin.cheng@arm.com>
>>
>>         PR target/81408
>>         * g++.dg/tree-ssa/pr81408.C: New.
>>         * gcc.dg/tree-ssa/pr19210-1.c: Check dump message rather than warning.

[-- Attachment #2: pr81408-20170718.txt --]
[-- Type: text/plain, Size: 3583 bytes --]

diff --git a/gcc/testsuite/g++.dg/tree-ssa/pr81408.C b/gcc/testsuite/g++.dg/tree-ssa/pr81408.C
new file mode 100644
index 0000000..f94544b
--- /dev/null
+++ b/gcc/testsuite/g++.dg/tree-ssa/pr81408.C
@@ -0,0 +1,92 @@
+/* { dg-do compile } */
+/* { dg-options "-O2 -std=gnu++11 -fopt-info-loop-missed -Wunsafe-loop-optimizations" } */
+
+namespace a {
+void b () __attribute__ ((__noreturn__));
+template <typename> struct d;
+template <typename e> struct d<e *>
+{
+  typedef e f;
+};
+struct g
+{
+  template <typename h> using i = h *;
+};
+}
+using a::d;
+template <typename j, typename> class k
+{
+  j l;
+
+public:
+  typename d<j>::f operator* () {}
+  void operator++ () { ++l; }
+  j
+  aa ()
+  {
+    return l;
+  }
+};
+template <typename m, typename n, typename ab>
+bool
+operator!= (k<m, ab> o, k<n, ab> p2)
+{
+  return o.aa () != p2.aa ();
+}
+struct p;
+namespace a {
+struct F
+{
+  struct q
+  {
+    using ai = g::i<p>;
+  };
+  using r = q::ai;
+};
+class H
+{
+public:
+  k<F::r, int> begin ();
+  k<F::r, int> end ();
+};
+int s;
+class I
+{
+public:
+  void
+  aq (char)
+  {
+    if (s)
+      b ();
+  }
+};
+class u : public I
+{
+public:
+  void
+  operator<< (u o (u))
+  {
+    o (*this);
+  }
+  u operator<< (void *);
+};
+template <typename at, typename au>
+at
+av (au o)
+{
+  o.aq ('\n');
+}
+u ax;
+}
+struct p
+{
+  char *ay;
+};
+a::H t;
+void
+ShowHelpListCommands ()
+{
+  for (auto c : t) /* { dg-message "note: missed loop optimization: niters analysis .*" } */
+    a::ax << c.ay << a::av;
+}
+
diff --git a/gcc/testsuite/gcc.dg/tree-ssa/pr19210-1.c b/gcc/testsuite/gcc.dg/tree-ssa/pr19210-1.c
index 3c8ee06..0fa5600 100644
--- a/gcc/testsuite/gcc.dg/tree-ssa/pr19210-1.c
+++ b/gcc/testsuite/gcc.dg/tree-ssa/pr19210-1.c
@@ -1,15 +1,15 @@
 /* { dg-do compile } */
-/* { dg-options "-O2 -Wunsafe-loop-optimizations" } */
+/* { dg-options "-O2 -fopt-info-loop-missed -Wunsafe-loop-optimizations" } */
 extern void g(void);
 
 void
 f (unsigned n)
 {
   unsigned k;
-  for(k = 0;k <= n;k++) /* { dg-warning "missed loop optimization.*overflow" } */
+  for(k = 0;k <= n;k++) /* { dg-message "note: missed loop optimization: niters analysis .*" } */
     g();
 
-  for(k = 0;k <= n;k += 4) /* { dg-warning "missed loop optimization.*overflow" } */
+  for(k = 0;k <= n;k += 4) /* { dg-message "note: missed loop optimization: niters analysis .*" } */
     g();
 
   /* We used to get warning for this loop.  However, since then # of iterations
@@ -21,9 +21,9 @@ f (unsigned n)
     g();
 
   /* So we need the following loop, instead.  */
-  for(k = 4;k <= n;k += 5) /* { dg-warning "missed loop optimization.*overflow" } */
+  for(k = 4;k <= n;k += 5) /* { dg-message "note: missed loop optimization: niters analysis .*" } */
     g();
   
-  for(k = 15;k >= n;k--) /* { dg-warning "missed loop optimization.*overflow" } */
+  for(k = 15;k >= n;k--) /* { dg-message "note: missed loop optimization: niters analysis .*" } */
     g();
 }
diff --git a/gcc/tree-ssa-loop-niter.c b/gcc/tree-ssa-loop-niter.c
index 5a7cab5..1421002 100644
--- a/gcc/tree-ssa-loop-niter.c
+++ b/gcc/tree-ssa-loop-niter.c
@@ -2378,9 +2378,9 @@ number_of_iterations_exit (struct loop *loop, edge exit,
     return true;
 
   if (warn)
-    warning_at (gimple_location_safe (stmt),
-		OPT_Wunsafe_loop_optimizations,
-		"missed loop optimization, the loop counter may overflow");
+    dump_printf_loc (MSG_MISSED_OPTIMIZATION, gimple_location_safe (stmt),
+		     "missed loop optimization: niters analysis ends up "
+		     "with assumptions.\n");
 
   return false;
 }

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

* Re: [PATCH PR81408]Turn TREE level unsafe loop optimizations warning to missed optimization message
  2017-07-18  9:13   ` Bin.Cheng
@ 2017-07-18 11:22     ` Richard Biener
  0 siblings, 0 replies; 4+ messages in thread
From: Richard Biener @ 2017-07-18 11:22 UTC (permalink / raw)
  To: Bin.Cheng; +Cc: gcc-patches

On Tue, Jul 18, 2017 at 11:13 AM, Bin.Cheng <amker.cheng@gmail.com> wrote:
> On Tue, Jul 18, 2017 at 9:31 AM, Richard Biener
> <richard.guenther@gmail.com> wrote:
>> On Tue, Jul 18, 2017 at 10:00 AM, Bin Cheng <Bin.Cheng@arm.com> wrote:
>>> Hi,
>>> I removed unsafe loop optimization on TREE level last year, so GCC doesn't do unsafe
>>> loop optimizations on TREE now.  All "unsafe loop optimizations" warnings reported by
>>> TREE optimizers are simply missed optimizations.  This patch turns such warning into
>>> missed optimization messages.  I didn't change when this will be dumped, for now it is
>>> when called from ivopts.
>>> Bootstrap and test on x86_64 and AArch64.  Is it OK?
>>
>> Ok but can you change the testcase to not scan the ivopts dump but use
>> -fopt-info-loop-missed?
>> You should be able to match the output with dg-message.
> Thanks for reviewing.  New patch with test case updated accordingly.  Is it OK?

Ok.

Richard.

> Thanks,
> bin
>>
>> Thanks,
>> Richard.
>>
>>> Thanks,
>>> bin
>>> 2017-07-13  Bin Cheng  <bin.cheng@arm.com>
>>>
>>>         PR target/81408
>>>         * tree-ssa-loop-niter.c (number_of_iterations_exit): Dump missed
>>>         optimization for loop niter analysis.
>>>
>>> gcc/testsuite/ChangeLog
>>> 2017-07-13  Bin Cheng  <bin.cheng@arm.com>
>>>
>>>         PR target/81408
>>>         * g++.dg/tree-ssa/pr81408.C: New.
>>>         * gcc.dg/tree-ssa/pr19210-1.c: Check dump message rather than warning.

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

end of thread, other threads:[~2017-07-18 11:22 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2017-07-18  8:01 [PATCH PR81408]Turn TREE level unsafe loop optimizations warning to missed optimization message Bin Cheng
2017-07-18  8:32 ` Richard Biener
2017-07-18  9:13   ` Bin.Cheng
2017-07-18 11:22     ` 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).