Re: [PR middle-end/60832] Do not convert widest_int to tree just for printing it.

2015-09-21 Thread Richard Biener
On Sun, 20 Sep 2015, Manuel López-Ibáñez wrote:

> 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.

I'd add the pretty printer overloads to wide-int-print.[ch], but yes
it would require a change in c-format.c.

> In addition, "iteration 3 invokes undefined behavior within this loop"
> seems to me clearer than  "iteration 3 invokes undefined behavior;
> containing loop".
> 
> Boot in x86_64-linux-gnu
> 
> OK?

Ok.  Let's remember this case and if more of these pop up try working
on a "proper" solution.

Thanks,
Richard.

> gcc/testsuite/ChangeLog:
> 
> 2015-09-20  Manuel López-Ibáñez  
> 
> PR middle-end/60832
> * gcc.dg/pr53265.c: Update.
> 
> gcc/ChangeLog:
> 
> 2015-09-20  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.
> 

-- 
Richard Biener 
SUSE LINUX GmbH, GF: Felix Imendoerffer, Jane Smithard, Graham Norton, HRB 
21284 (AG Nuernberg)

Re: [PR middle-end/60832] Do not convert widest_int to tree just for printing it.

2015-09-21 Thread Manuel López-Ibáñez
On 21 September 2015 at 09:24, Richard Biener  wrote:
> On Sun, 20 Sep 2015, Manuel López-Ibáñez wrote:
>
>> 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.
>
> I'd add the pretty printer overloads to wide-int-print.[ch], but yes
> it would require a change in c-format.c.

That is not enough, some conversion specifier parser needs to handle
the new codes. The one in pretty-print.c is used all over the place
and adding a dependency on wide-int.cc will bring gmp and other stuff
that is currently  not used (nor linked with) various helper programs.
If wide-int is only printed in the middle-end, perhaps it is
sufficient to add it to default_tree_printer. Otherwise, it needs to
be added to every FE. This is not difficult just tedious. The
difficult part is the c-format.c changes (I wish someone would fix
https://gcc.gnu.org/PR47781 so we can use a simpler syntax to define
our custom specifiers; in addition to the positive synergies it will
bring with other GNU projects that use custom specifiers and wish to
use -Wformat).

>> OK?
>
> Ok.  Let's remember this case and if more of these pop up try working
> on a "proper" solution.

Sure, I added my WIP patch to the PR, but I don't plan to keep working on it.

Cheers,

Manuel.