From 694dd0e408581c9e3fc0fab4864d9de054c7cc0c Mon Sep 17 00:00:00 2001 From: Bin Cheng Date: Tue, 18 Jul 2017 11:40:38 +0000 Subject: re PR middle-end/81408 (Lots of new -Wunsafe-loop-optimizations warnings with 7 compared to 6) PR target/81408 * tree-ssa-loop-niter.c (number_of_iterations_exit): Dump missed optimization for loop niter analysis. gcc/testsuite * g++.dg/tree-ssa/pr81408.C: New. * gcc.dg/tree-ssa/pr19210-1.c: Check dump message rather than warning. From-SVN: r250304 --- gcc/ChangeLog | 6 ++ gcc/testsuite/ChangeLog | 6 ++ gcc/testsuite/g++.dg/tree-ssa/pr81408.C | 92 +++++++++++++++++++++++++++++++ gcc/testsuite/gcc.dg/tree-ssa/pr19210-1.c | 10 ++-- gcc/tree-ssa-loop-niter.c | 6 +- 5 files changed, 112 insertions(+), 8 deletions(-) create mode 100644 gcc/testsuite/g++.dg/tree-ssa/pr81408.C (limited to 'gcc') diff --git a/gcc/ChangeLog b/gcc/ChangeLog index e221236..3ff4036 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -1,3 +1,9 @@ +2017-07-18 Bin Cheng + + PR target/81408 + * tree-ssa-loop-niter.c (number_of_iterations_exit): Dump missed + optimization for loop niter analysis. + 2017-07-18 Georg-Johann Lay PR target/81473 diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index e808718..91aa26c 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,9 @@ +2017-07-18 Bin Cheng + + PR target/81408 + * g++.dg/tree-ssa/pr81408.C: New. + * gcc.dg/tree-ssa/pr19210-1.c: Check dump message rather than warning. + 2017-07-18 Richard Biener PR tree-optimization/80620 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 struct d; +template struct d +{ + typedef e f; +}; +struct g +{ + template using i = h *; +}; +} +using a::d; +template class k +{ + j l; + +public: + typename d::f operator* () {} + void operator++ () { ++l; } + j + aa () + { + return l; + } +}; +template +bool +operator!= (k o, k p2) +{ + return o.aa () != p2.aa (); +} +struct p; +namespace a { +struct F +{ + struct q + { + using ai = g::i

; + }; + using r = q::ai; +}; +class H +{ +public: + k begin (); + k 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 +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; } -- cgit v1.1