* Re: [Bug c/43639] New: Missed optimization with complex long double
2010-04-04 6:21 [Bug c/43639] New: Missed optimization with complex long double svfuerst at gmail dot com
@ 2010-04-04 6:28 ` Andrew Pinski
2010-04-04 6:29 ` [Bug c/43639] " pinskia at gmail dot com
` (3 subsequent siblings)
4 siblings, 0 replies; 6+ messages in thread
From: Andrew Pinski @ 2010-04-04 6:28 UTC (permalink / raw)
To: gcc-bugzilla; +Cc: gcc-bugs
Sent from my iPhone
On Apr 3, 2010, at 11:21 PM, "svfuerst at gmail dot com" <gcc-bugzilla@gcc.gnu.org
> wrote:
> gcc 4.4 compiles the following:
>
> _Complex long double foo(long double p1, long double p2)
> {
> return p1 + (__extension__ 1.0iF) * p2;
> }
>
> gcc-4.4 -O3 tgcc.c -c -o tgcc.o
>
> into
>
> 0x0000000000000000 <+0>: fldt 0x8(%rsp)
> 0x0000000000000004 <+4>: fldt 0x18(%rsp)
> 0x0000000000000008 <+8>: fxch %st(1)
> 0x000000000000000a <+10>: retq
>
> This is ok, except for the useless fxch instruction. However, gcc
> 4.5 compiles
> the same code into:
> gcc-4.5 -O3 tgcc.c -c -o tgcc.o
>
> 0x0000000000000000 <+0>: fldt 0x18(%rsp)
> 0x0000000000000004 <+4>: fld %st(0)
> 0x0000000000000006 <+6>: fmuls 0x0(%rip) # 0xc <foo+12>
> 0x000000000000000c <+12>: fldt 0x8(%rsp)
> 0x0000000000000010 <+16>: faddp %st,%st(1)
> 0x0000000000000012 <+18>: retq
>
> which is quite a bit worse.
Except it is needed for handling -0.0 correctly.
>
>
> --
> Summary: Missed optimization with complex long double
> Product: gcc
> Version: unknown
> Status: UNCONFIRMED
> Severity: normal
> Priority: P3
> Component: c
> AssignedTo: unassigned at gcc dot gnu dot org
> ReportedBy: svfuerst at gmail dot com
> GCC build triplet: x86_64-linux
> GCC host triplet: x86_64-linux
> GCC target triplet: x86_64-linux
>
>
> http://gcc.gnu.org/bugzilla/show_bug.cgi?id=43639
>
^ permalink raw reply [flat|nested] 6+ messages in thread
* [Bug c/43639] Missed optimization with complex long double
2010-04-04 6:21 [Bug c/43639] New: Missed optimization with complex long double svfuerst at gmail dot com
2010-04-04 6:28 ` Andrew Pinski
@ 2010-04-04 6:29 ` pinskia at gmail dot com
2010-04-04 16:51 ` svfuerst at gmail dot com
` (2 subsequent siblings)
4 siblings, 0 replies; 6+ messages in thread
From: pinskia at gmail dot com @ 2010-04-04 6:29 UTC (permalink / raw)
To: gcc-bugs
------- Comment #1 from pinskia at gmail dot com 2010-04-04 06:28 -------
Subject: Re: New: Missed optimization with complex long double
Sent from my iPhone
On Apr 3, 2010, at 11:21 PM, "svfuerst at gmail dot com"
<gcc-bugzilla@gcc.gnu.org
> wrote:
> gcc 4.4 compiles the following:
>
> _Complex long double foo(long double p1, long double p2)
> {
> return p1 + (__extension__ 1.0iF) * p2;
> }
>
> gcc-4.4 -O3 tgcc.c -c -o tgcc.o
>
> into
>
> 0x0000000000000000 <+0>: fldt 0x8(%rsp)
> 0x0000000000000004 <+4>: fldt 0x18(%rsp)
> 0x0000000000000008 <+8>: fxch %st(1)
> 0x000000000000000a <+10>: retq
>
> This is ok, except for the useless fxch instruction. However, gcc
> 4.5 compiles
> the same code into:
> gcc-4.5 -O3 tgcc.c -c -o tgcc.o
>
> 0x0000000000000000 <+0>: fldt 0x18(%rsp)
> 0x0000000000000004 <+4>: fld %st(0)
> 0x0000000000000006 <+6>: fmuls 0x0(%rip) # 0xc <foo+12>
> 0x000000000000000c <+12>: fldt 0x8(%rsp)
> 0x0000000000000010 <+16>: faddp %st,%st(1)
> 0x0000000000000012 <+18>: retq
>
> which is quite a bit worse.
Except it is needed for handling -0.0 correctly.
>
>
> --
> Summary: Missed optimization with complex long double
> Product: gcc
> Version: unknown
> Status: UNCONFIRMED
> Severity: normal
> Priority: P3
> Component: c
> AssignedTo: unassigned at gcc dot gnu dot org
> ReportedBy: svfuerst at gmail dot com
> GCC build triplet: x86_64-linux
> GCC host triplet: x86_64-linux
> GCC target triplet: x86_64-linux
>
>
> http://gcc.gnu.org/bugzilla/show_bug.cgi?id=43639
>
--
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=43639
^ permalink raw reply [flat|nested] 6+ messages in thread
* [Bug c/43639] Missed optimization with complex long double
2010-04-04 6:21 [Bug c/43639] New: Missed optimization with complex long double svfuerst at gmail dot com
2010-04-04 6:28 ` Andrew Pinski
2010-04-04 6:29 ` [Bug c/43639] " pinskia at gmail dot com
@ 2010-04-04 16:51 ` svfuerst at gmail dot com
2010-04-04 19:12 ` joseph at codesourcery dot com
2010-05-22 18:43 ` jsm28 at gcc dot gnu dot org
4 siblings, 0 replies; 6+ messages in thread
From: svfuerst at gmail dot com @ 2010-04-04 16:51 UTC (permalink / raw)
To: gcc-bugs
------- Comment #2 from svfuerst at gmail dot com 2010-04-04 16:51 -------
Paragraph 2 in G.5.1 defines multiplication of a real floating point type by an
imaginary floating point type to be an imaginary type, not a complex type.
In addition, the Rationale for Annex G states that
"It allow writing imaginary and complex expressions in common mathematical
style, for example x + I*y. Note that the multiplication here affects
translated code, but does not necessitate an actual floating-point multiply,
nor does the addition necessitate a floating point add."
Which strongly suggests that the naive code generation which ignores the signed
zero issue is the correct one. (Note that the rationale also lists the case
where y=INFINITY as causing problems with signaling NaNs if I is _Complex_I.)
--
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=43639
^ permalink raw reply [flat|nested] 6+ messages in thread
* [Bug c/43639] Missed optimization with complex long double
2010-04-04 6:21 [Bug c/43639] New: Missed optimization with complex long double svfuerst at gmail dot com
` (2 preceding siblings ...)
2010-04-04 16:51 ` svfuerst at gmail dot com
@ 2010-04-04 19:12 ` joseph at codesourcery dot com
2010-05-22 18:43 ` jsm28 at gcc dot gnu dot org
4 siblings, 0 replies; 6+ messages in thread
From: joseph at codesourcery dot com @ 2010-04-04 19:12 UTC (permalink / raw)
To: gcc-bugs
------- Comment #3 from joseph at codesourcery dot com 2010-04-04 19:12 -------
Subject: Re: Missed optimization with complex long double
On Sun, 4 Apr 2010, svfuerst at gmail dot com wrote:
> Paragraph 2 in G.5.1 defines multiplication of a real floating point
> type by an imaginary floating point type to be an imaginary type, not a
> complex type.
GCC does not support imaginary types, so this is irrelevant.
--
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=43639
^ permalink raw reply [flat|nested] 6+ messages in thread
* [Bug c/43639] Missed optimization with complex long double
2010-04-04 6:21 [Bug c/43639] New: Missed optimization with complex long double svfuerst at gmail dot com
` (3 preceding siblings ...)
2010-04-04 19:12 ` joseph at codesourcery dot com
@ 2010-05-22 18:43 ` jsm28 at gcc dot gnu dot org
4 siblings, 0 replies; 6+ messages in thread
From: jsm28 at gcc dot gnu dot org @ 2010-05-22 18:43 UTC (permalink / raw)
To: gcc-bugs
------- Comment #4 from jsm28 at gcc dot gnu dot org 2010-05-22 18:18 -------
This is deliberate, use -fno-signed-zeros to get the optimization you
want with 4.5.
*** This bug has been marked as a duplicate of 24581 ***
--
jsm28 at gcc dot gnu dot org changed:
What |Removed |Added
----------------------------------------------------------------------------
Status|UNCONFIRMED |RESOLVED
Resolution| |DUPLICATE
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=43639
^ permalink raw reply [flat|nested] 6+ messages in thread