Re: Extend tree-call-cdce to calls whose result is used

2015-11-17 Thread Richard Biener
On Tue, Nov 17, 2015 at 10:19 AM, Richard Sandiford wrote: > Richard Biener writes: >> On Fri, Nov 13, 2015 at 2:12 PM, Richard Sandiford >> wrote: >>> Richard Biener writes: On Mon, Nov 9, 2015 at 10:03 PM, Michael Matz wrote: > Hi, > > On Mon, 9 Nov 2015, Richard Sandiford w

Re: Extend tree-call-cdce to calls whose result is used

2015-11-17 Thread Richard Sandiford
Richard Biener writes: > On Fri, Nov 13, 2015 at 2:12 PM, Richard Sandiford > wrote: >> Richard Biener writes: >>> On Mon, Nov 9, 2015 at 10:03 PM, Michael Matz wrote: Hi, On Mon, 9 Nov 2015, Richard Sandiford wrote: > +static bool > +can_use_internal_fn (gcall *call

Re: Extend tree-call-cdce to calls whose result is used

2015-11-16 Thread Michael Matz
Hi, On Mon, 16 Nov 2015, Richard Biener wrote: > >> Which would leave us with a lowering stage early in the main > >> optimization pipeline - I think fold_builtins pass is way too late > >> but any "folding" pass will do (like forwprop or backprop where the > >> latter might be better because

Re: Extend tree-call-cdce to calls whose result is used

2015-11-16 Thread Richard Biener
On Fri, Nov 13, 2015 at 2:12 PM, Richard Sandiford wrote: > Richard Biener writes: >> On Mon, Nov 9, 2015 at 10:03 PM, Michael Matz wrote: >>> Hi, >>> >>> On Mon, 9 Nov 2015, Richard Sandiford wrote: >>> +static bool +can_use_internal_fn (gcall *call) +{ + /* Only replace ca

Re: Extend tree-call-cdce to calls whose result is used

2015-11-13 Thread Richard Sandiford
Richard Biener writes: > On Mon, Nov 9, 2015 at 10:03 PM, Michael Matz wrote: >> Hi, >> >> On Mon, 9 Nov 2015, Richard Sandiford wrote: >> >>> +static bool >>> +can_use_internal_fn (gcall *call) >>> +{ >>> + /* Only replace calls that set errno. */ >>> + if (!gimple_vdef (call)) >>> +retur

Re: Extend tree-call-cdce to calls whose result is used

2015-11-10 Thread Richard Biener
On Mon, Nov 9, 2015 at 10:03 PM, Michael Matz wrote: > Hi, > > On Mon, 9 Nov 2015, Richard Sandiford wrote: > >> +static bool >> +can_use_internal_fn (gcall *call) >> +{ >> + /* Only replace calls that set errno. */ >> + if (!gimple_vdef (call)) >> +return false; > > Oh, I managed to confus

Re: Extend tree-call-cdce to calls whose result is used

2015-11-09 Thread Joseph Myers
On Sat, 7 Nov 2015, Richard Sandiford wrote: > - the call to sqrt is protected by the result of the optab rather > than the input. It would be better to check !(x >= 0), like > tree-call-cdce.c does. Well, no, isless (x, 0) (or !isgreaterequal (x, 0), since it doesn't matter what result a N

Re: Extend tree-call-cdce to calls whose result is used

2015-11-09 Thread Michael Matz
Hi, On Mon, 9 Nov 2015, Richard Sandiford wrote: > +static bool > +can_use_internal_fn (gcall *call) > +{ > + /* Only replace calls that set errno. */ > + if (!gimple_vdef (call)) > +return false; Oh, I managed to confuse this in my head while reading the patch. So, hmm, you don't actua

Re: Extend tree-call-cdce to calls whose result is used

2015-11-09 Thread Richard Sandiford
Michael Matz writes: > On Mon, 9 Nov 2015, Richard Sandiford wrote: > >> -ffast-math would already cause us to treat the function as not setting >> errno, so the code wouldn't be used. > > What is "the code"? I don't see any checking of the relevant flags in > tree-call-cdce.c, so I wonder what

Re: Extend tree-call-cdce to calls whose result is used

2015-11-09 Thread Michael Matz
Hi, On Mon, 9 Nov 2015, Richard Sandiford wrote: > -ffast-math would already cause us to treat the function as not setting > errno, so the code wouldn't be used. What is "the code"? I don't see any checking of the relevant flags in tree-call-cdce.c, so I wonder what would prevent the addition

Re: Extend tree-call-cdce to calls whose result is used

2015-11-09 Thread Richard Sandiford
Michael Matz writes: > On Sat, 7 Nov 2015, Richard Sandiford wrote: >> For -fmath-errno, builtins.c currently expands calls to sqrt to: >> >> y = sqrt_optab (x); >> if (y != y) >> [ sqrt (x); or errno = EDOM; ] >> >> - the call to sqrt is protected by the result of the optab rather

Re: Extend tree-call-cdce to calls whose result is used

2015-11-09 Thread Michael Matz
Hi, On Sat, 7 Nov 2015, Richard Sandiford wrote: > For -fmath-errno, builtins.c currently expands calls to sqrt to: > > y = sqrt_optab (x); > if (y != y) > [ sqrt (x); or errno = EDOM; ] > > - the call to sqrt is protected by the result of the optab rather > than the input. It

Extend tree-call-cdce to calls whose result is used

2015-11-07 Thread Richard Sandiford
For -fmath-errno, builtins.c currently expands calls to sqrt to: y = sqrt_optab (x); if (y != y) [ sqrt (x); or errno = EDOM; ] The drawbacks of this are: - the call to sqrt is protected by the result of the optab rather than the input. It would be better to check !(x >= 0), lik