Re: [PATCH] Optimize logarithm addition and subtraction

2018-08-06 Thread Jeff Law
On 08/05/2018 12:35 PM, Marc Glisse wrote: > On Sun, 5 Aug 2018, Bernd Edlinger wrote: > >>> merging log a + log b => log a*b and >> >> Maybe a*b could overflow, while adding the logarithms would not? > > Well, that's a discussion that happens every time a new transformation > is added to -funsaf

Re: [PATCH] Optimize logarithm addition and subtraction

2018-08-05 Thread Marc Glisse
On Sun, 5 Aug 2018, MCC CS wrote: Besides, if you think optimizing /* logN(a) + logN(b) -> logN(a * b) */ would be enough, without the coefficients, here's a simpler patch: Index: gcc/match.pd === --- gcc/match.pd(revision 2633

Re: [PATCH] Optimize logarithm addition and subtraction

2018-08-05 Thread MCC CS
> Sent: Sunday, August 05, 2018 at 8:17 PM > From: "Marc Glisse" > To: "MCC CS" > Cc: gcc-patches@gcc.gnu.org > Subject: Re: [PATCH] Optimize logarithm addition and subtraction > > On Sun, 5 Aug 2018, MCC CS wrote: > > > this patch reduces calls

Re: [PATCH] Optimize logarithm addition and subtraction

2018-08-05 Thread Bernd Edlinger
On 08/05/18 20:35, Marc Glisse wrote: > On Sun, 5 Aug 2018, Bernd Edlinger wrote: > >>> merging log a + log b => log a*b and >> >> Maybe a*b could overflow, while adding the logarithms would not? > > Well, that's a discussion that happens every time a new transformation is > added to -funsafe-ma

Re: [PATCH] Optimize logarithm addition and subtraction

2018-08-05 Thread Marc Glisse
On Sun, 5 Aug 2018, Bernd Edlinger wrote: merging log a + log b => log a*b and Maybe a*b could overflow, while adding the logarithms would not? Well, that's a discussion that happens every time a new transformation is added to -funsafe-math-optimizations (I assume this one is under that um

Re: [PATCH] Optimize logarithm addition and subtraction

2018-08-05 Thread Andreas Schwab
On Aug 05 2018, Marc Glisse wrote: > On Sun, 5 Aug 2018, MCC CS wrote: > >> this patch reduces calls to logarithm functions by >> merging log a + log b => log a*b and > > this makes sense. Even when a*b may overflow? Andreas. -- Andreas Schwab, sch...@linux-m68k.org GPG Key fingerprint = 7578

Re: [PATCH] Optimize logarithm addition and subtraction

2018-08-05 Thread Bernd Edlinger
> merging log a + log b => log a*b and Maybe a*b could overflow, while adding the logarithms would not? Bernd.

Re: [PATCH] Optimize logarithm addition and subtraction

2018-08-05 Thread Marc Glisse
On Sun, 5 Aug 2018, MCC CS wrote: this patch reduces calls to logarithm functions by merging log a + log b => log a*b and this makes sense. + /* x * logN(a) + y * logN(b) -> x * y * logN(a * b). */ this on the other hand... Can you explain the math? -- Marc Glisse