Re: The conditions when convert from double to float is permitted?

2020-12-11 Thread Segher Boessenkool
On Fri, Dec 11, 2020 at 05:38:30PM +0800, Xionghu Luo wrote: > On 2020/12/11 15:47, Richard Biener wrote: > >> Note that the add/sub sequence is different for (3) and (4) since > >> -funsafe-math-optimizations is implicitly true. "fp-contract=fast" in > >> (1) and (2) could avoid Inf as fmads

Re: The conditions when convert from double to float is permitted?

2020-12-11 Thread Segher Boessenkool
On Fri, Dec 11, 2020 at 03:54:44PM +0800, Xionghu Luo wrote: > +cc. > > > On 2020/12/11 14:25, Xionghu Luo via Gcc wrote: > >Thanks, > > > >On 2020/12/10 17:12, Richard Biener wrote: > >>>2) From PR90070: > >>> > >>>double temp1 = (double)r->red; > >>>double temp2 =

Re: The conditions when convert from double to float is permitted?

2020-12-11 Thread Richard Biener via Gcc
On Fri, Dec 11, 2020 at 10:44 AM Xionghu Luo wrote: > > > On 2020/12/11 15:47, Richard Biener wrote: > >> Note that the add/sub sequence is different for (3) and (4) since > >> -funsafe-math-optimizations is implicitly true. "fp-contract=fast" in > >> (1) and (2) could avoid Inf as fmads could

Re: The conditions when convert from double to float is permitted?

2020-12-11 Thread Xionghu Luo via Gcc
On 2020/12/11 15:47, Richard Biener wrote: >> Note that the add/sub sequence is different for (3) and (4) since >> -funsafe-math-optimizations is implicitly true. "fp-contract=fast" in >> (1) and (2) could avoid Inf as fmads could handle float overflow (verified >> it on Power, not sure other

Re: The conditions when convert from double to float is permitted?

2020-12-11 Thread Xionghu Luo via Gcc
On 2020/12/11 15:47, Richard Biener wrote: >> Note that the add/sub sequence is different for (3) and (4) since >> -funsafe-math-optimizations is implicitly true. "fp-contract=fast" in >> (1) and (2) could avoid Inf as fmads could handle float overflow (verified >> it on Power, not sure other

Re: The conditions when convert from double to float is permitted?

2020-12-10 Thread Xionghu Luo via Gcc
+cc. On 2020/12/11 14:25, Xionghu Luo via Gcc wrote: Thanks, On 2020/12/10 17:12, Richard Biener wrote: 2) From PR90070: double temp1 = (double)r->red; double temp2 = (double)aggregate.red; double temp3 = temp2 + (temp1 * 5.0); temp1 * 5 could be not representable in float but

Re: The conditions when convert from double to float is permitted?

2020-12-10 Thread Richard Biener via Gcc
On Fri, Dec 11, 2020 at 7:26 AM Xionghu Luo wrote: > > Thanks, > > On 2020/12/10 17:12, Richard Biener wrote: > >> 2) From PR90070: > >> > >>double temp1 = (double)r->red; > >>double temp2 = (double)aggregate.red; > >>double temp3 = temp2 + (temp1 * 5.0); > > temp1 * 5 could be not

Re: The conditions when convert from double to float is permitted?

2020-12-10 Thread Xionghu Luo via Gcc
Thanks, On 2020/12/10 17:12, Richard Biener wrote: >> 2) From PR90070: >> >>double temp1 = (double)r->red; >>double temp2 = (double)aggregate.red; >>double temp3 = temp2 + (temp1 * 5.0); > temp1 * 5 could be not representable in float but the > result of the add could so the transform

Re: The conditions when convert from double to float is permitted?

2020-12-10 Thread Marc Glisse
On Thu, 10 Dec 2020, Xionghu Luo via Gcc wrote: I have a maybe silly question about whether there is any *standard* or *options* (like -ffast-math) for GCC that allow double to float demotion optimization? For example, 1) from PR22326: #include float foo(float f, float x, float y) { return

Re: The conditions when convert from double to float is permitted?

2020-12-10 Thread Richard Biener via Gcc
On Thu, Dec 10, 2020 at 9:47 AM Xionghu Luo via Gcc wrote: > > Hi, > > I have a maybe silly question about whether there is any *standard* > or *options* (like -ffast-math) for GCC that allow double to float > demotion optimization? For example, The only option we have to this effect would be

The conditions when convert from double to float is permitted?

2020-12-10 Thread Xionghu Luo via Gcc
Hi, I have a maybe silly question about whether there is any *standard* or *options* (like -ffast-math) for GCC that allow double to float demotion optimization? For example, 1) from PR22326: #include float foo(float f, float x, float y) { return (fabs(f)*x+y); } The fabs will return