From: Manuel López-Ibáñez Date: Mon, 21 Sep 2015 10:11:24 +0000 (+0000) Subject: [PR middle-end/60832] Do not convert widest_int to tree just for printing it. X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=973dabae60a2129374b5cbe54ea0d6bd1e6f9f9a;p=gcc.git [PR middle-end/60832] Do not convert widest_int to tree just for printing it. In do_warn_aggressive_loop_optimizations, we convert to a tree just to print a widest_int. Apart from overly complicated, this results in printing '3u' instead of just '3'. Unfortunately, adding a printf-like conversion specifier would require making pretty-print.c link with wide-int.cc, which will include a lot of new dependencies into several other programs (gcov-tool for example). It would be possible to add the conversion specifier to every FE pretty-printer, but this still would require updating c-format.c, which is far from trivial. A simpler approach is to convert to a string rather than to a tree. In addition, "iteration 3 invokes undefined behavior within this loop" seems to me clearer than "iteration 3 invokes undefined behavior; containing loop". gcc/testsuite/ChangeLog: 2015-09-21 Manuel López-Ibáñez PR middle-end/60832 * gcc.dg/pr53265.c: Update. gcc/ChangeLog: 2015-09-21 Manuel López-Ibáñez PR middle-end/60832 * tree-ssa-loop-niter.c (do_warn_aggressive_loop_optimizations): Print i_bound without converting it to a tree. From-SVN: r227964 --- diff --git a/gcc/ChangeLog b/gcc/ChangeLog index 93df84b82f1..970ebae979f 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -1,3 +1,9 @@ +2015-09-21 Manuel López-Ibáñez + + PR middle-end/60832 + * tree-ssa-loop-niter.c (do_warn_aggressive_loop_optimizations): + Print i_bound without converting it to a tree. + 2015-09-21 Bilyan Borisov * config/arm/arm.c (thumb_output_move_mem_multiple): Replaced diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index 6aaffbb5e36..82d67739ec4 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,8 @@ +2015-09-21 Manuel López-Ibáñez + + PR middle-end/60832 + * gcc.dg/pr53265.c: Update. + 2015-09-21 Eric Botcazou * gcc.target/arm/stack-checking.c: Skip for Thumb1. diff --git a/gcc/testsuite/gcc.dg/pr53265.c b/gcc/testsuite/gcc.dg/pr53265.c index e1ca6f521e7..d3ab6aa6031 100644 --- a/gcc/testsuite/gcc.dg/pr53265.c +++ b/gcc/testsuite/gcc.dg/pr53265.c @@ -12,8 +12,8 @@ fn1 (void) unsigned int a[128]; int i; - for (i = 0; i < 128; ++i) /* { dg-message "note: containing loop" } */ - a[i] = i * 0x02000001; /* { dg-warning "invokes undefined behavior" } */ + for (i = 0; i < 128; ++i) /* { dg-message "note: within this loop" } */ + a[i] = i * 0x02000001; /* { dg-warning "64 invokes undefined behavior" } */ bar (a); } @@ -23,8 +23,8 @@ fn2 (void) unsigned long long a[128]; int i; - for (i = 0; i < 128; i++) /* { dg-message "note: containing loop" } */ - a[i] = (i + 1LL) * 0x0123456789ABCDEFLL; /* { dg-warning "invokes undefined behavior" } */ + for (i = 0; i < 128; i++) /* { dg-message "note: within this loop" } */ + a[i] = (i + 1LL) * 0x0123456789ABCDEFLL; /* { dg-warning "112 invokes undefined behavior" } */ bar (a); } @@ -35,9 +35,9 @@ fn3 (void) int i; bar (b); - for (i = 0; i < (int) (sizeof (a) / sizeof (a[0])); i++) /* { dg-message "note: containing loop" } */ + for (i = 0; i < (int) (sizeof (a) / sizeof (a[0])); i++) /* { dg-message "note: within this loop" } */ { - c[i + 8] = b[i]; /* { dg-warning "invokes undefined behavior" } */ + c[i + 8] = b[i]; /* { dg-warning "8 invokes undefined behavior" } */ a[i + 8] = b[i + 8]; } bar (a); @@ -50,9 +50,9 @@ fn4 (void) unsigned int *a[32], *o, i; bar (a); - for (i = 0; i <= sizeof (a) / sizeof (a[0]); i++) /* { dg-message "note: containing loop" "" } */ + for (i = 0; i <= sizeof (a) / sizeof (a[0]); i++) /* { dg-message "note: within this loop" "" } */ { - o = a[i]; /* { dg-warning "invokes undefined behavior" "" } */ + o = a[i]; /* { dg-warning "32 invokes undefined behavior" "" } */ bar (o); } } @@ -65,8 +65,8 @@ fn5 (void) int j; bar (b); - for (j = 0; j < 1140; j++) /* { dg-message "note: containing loop" } */ - a[23940 + j - 950] = b[j]; /* { dg-warning "invokes undefined behavior" } */ + for (j = 0; j < 1140; j++) /* { dg-message "note: within this loop" } */ + a[23940 + j - 950] = b[j]; /* { dg-warning "950 invokes undefined behavior" } */ bar (a); } @@ -76,8 +76,8 @@ fn6 (void) double a[4][3], b[12]; int i; bar (b); - for (i = 0; i < 12; i++) /* { dg-message "note: containing loop" } */ - a[0][i] = b[i] / 10000.0; /* { dg-warning "invokes undefined behavior" } */ + for (i = 0; i < 12; i++) /* { dg-message "note: within this loop" } */ + a[0][i] = b[i] / 10000.0; /* { dg-warning "3 invokes undefined behavior" } */ bar (a); } @@ -86,11 +86,11 @@ fn7 (void) { int a[16], b, c; bar (a); - for (b = a[c = 0]; c < 16; b = a[++c]) /* { dg-warning "invokes undefined behavior" "" } */ + for (b = a[c = 0]; c < 16; b = a[++c]) /* { dg-warning "15 invokes undefined behavior" "" } */ baz (b); } -/* { dg-message "note: containing loop" "" { target *-*-* } 89 } */ +/* { dg-message "note: within this loop" "" { target *-*-* } 89 } */ const void *va, *vb, *vc, *vd, *ve; const void *vf[4]; @@ -134,8 +134,8 @@ void fn10 (void) { int i; - for (i = 16; i < 32; i++) /* { dg-message "note: containing loop" } */ - xa[i] = 26; /* { dg-warning "invokes undefined behavior" } */ + for (i = 16; i < 32; i++) /* { dg-message "note: within this loop" } */ + xa[i] = 26; /* { dg-warning "2 invokes undefined behavior" } */ } __attribute__((noinline)) static void diff --git a/gcc/tree-ssa-loop-niter.c b/gcc/tree-ssa-loop-niter.c index 70bdb841245..5125af4d7bd 100644 --- a/gcc/tree-ssa-loop-niter.c +++ b/gcc/tree-ssa-loop-niter.c @@ -2911,11 +2911,12 @@ do_warn_aggressive_loop_optimizations (struct loop *loop, return; gimple *estmt = last_stmt (e->src); + char buf[WIDE_INT_PRINT_BUFFER_SIZE]; + print_dec (i_bound, buf, TYPE_UNSIGNED (TREE_TYPE (loop->nb_iterations)) + ? UNSIGNED : SIGNED); if (warning_at (gimple_location (stmt), OPT_Waggressive_loop_optimizations, - "iteration %E invokes undefined behavior", - wide_int_to_tree (TREE_TYPE (loop->nb_iterations), - i_bound))) - inform (gimple_location (estmt), "containing loop"); + "iteration %s invokes undefined behavior", buf)) + inform (gimple_location (estmt), "within this loop"); loop->warned_aggressive_loop_optimizations = true; }