aboutsummaryrefslogtreecommitdiff
path: root/gcc/tree-ssa-loop-niter.c
diff options
context:
space:
mode:
authorManuel López-Ibáñez <manu@gcc.gnu.org>2015-09-21 10:11:24 +0000
committerManuel López-Ibáñez <manu@gcc.gnu.org>2015-09-21 10:11:24 +0000
commit973dabae60a2129374b5cbe54ea0d6bd1e6f9f9a (patch)
tree99fcda1134c2e7c64285192a0c3d824825d844cb /gcc/tree-ssa-loop-niter.c
parent6ad9ac88388d049d48364b59a58d1cb72c50c7c6 (diff)
downloadgcc-973dabae60a2129374b5cbe54ea0d6bd1e6f9f9a.zip
gcc-973dabae60a2129374b5cbe54ea0d6bd1e6f9f9a.tar.gz
gcc-973dabae60a2129374b5cbe54ea0d6bd1e6f9f9a.tar.bz2
[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 <manu@gcc.gnu.org> PR middle-end/60832 * gcc.dg/pr53265.c: Update. gcc/ChangeLog: 2015-09-21 Manuel López-Ibáñez <manu@gcc.gnu.org> 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
Diffstat (limited to 'gcc/tree-ssa-loop-niter.c')
-rw-r--r--gcc/tree-ssa-loop-niter.c9
1 files changed, 5 insertions, 4 deletions
diff --git a/gcc/tree-ssa-loop-niter.c b/gcc/tree-ssa-loop-niter.c
index 70bdb84..5125af4 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;
}