On Sat, 7 Jul 2018, Marc Glisse wrote: > On Sat, 7 Jul 2018, Jakub Jelinek wrote: > > > 2018-07-07 Jakub Jelinek <ja...@redhat.com> > > > > PR c/86420 > > * real.c (real_nextafter): Return true if result is denormal. > > I have a question on the side: would it be hard / useful, in cases where > nextafter may set errno or some exception flag, to fold the result to a > constant while keeping the function call (ignoring the value it returns)? To > clarify, I mean replace > > _2 = nextafter(DBL_DENORM_MIN, 0); > > with > > nextafter(DBL_DENORM_MIN, 0); > _2 = 0; > > I think we already do that for some other calls, although I can't remember > where. The point would be that we have the value of _2 and can keep folding > its uses.
There's tree-call-dce.c which is doing a related (more complex) transform but nothing doing constant propagation through calls. I think it would be more useful for the target C library to expose sth like set_errno (...) so we can constant fold the errno setting as well. Maybe there's some cheap non-DCEable math function we could abuse... Richard.