public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug target/21508] New: non-optimal code with __builtin_signbit
@ 2005-05-11 9:15 uros at kss-loka dot si
2005-05-11 11:25 ` [Bug target/21508] " pinskia at gcc dot gnu dot org
2005-06-03 8:13 ` uros at kss-loka dot si
0 siblings, 2 replies; 4+ messages in thread
From: uros at kss-loka dot si @ 2005-05-11 9:15 UTC (permalink / raw)
To: gcc-bugs
This testcase:
int test (double a) {
return __builtin_signbit (a + 1.0);
}
produces quite non-optimal code when compiled with '-O2' (-fomit-frame-pointer):
test:
subl $12, %esp
! xorl %eax, %eax
! movl $1072693248, %edx
! movl %eax, (%esp)
! movl %edx, 4(%esp)
! fldl (%esp)
faddl 16(%esp)
fstpl (%esp)
? movl 4(%esp), %edx
addl $12, %esp
? movl %edx, %eax
andl $-2147483648, %eax
ret
Instructions marked with (!) could be replaced with a fld1.
Instructions marked with (?) could be replaced with a "movl 4(%esp), %eax".
Perhaps fxam could be used in this case? Then the code would look something like:
fldl 4(%esp)
fxam
fnstsw %ax
fstp %st(0)
andl 0x02, %eax
ret
--
Summary: non-optimal code with __builtin_signbit
Product: gcc
Version: 4.1.0
Status: UNCONFIRMED
Severity: normal
Priority: P2
Component: target
AssignedTo: unassigned at gcc dot gnu dot org
ReportedBy: uros at kss-loka dot si
CC: gcc-bugs at gcc dot gnu dot org
GCC build triplet: i686-pc-linux-gnu
GCC host triplet: i686-pc-linux-gnu
GCC target triplet: i686-pc-linux-gnu
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=21508
^ permalink raw reply [flat|nested] 4+ messages in thread
* [Bug target/21508] non-optimal code with __builtin_signbit
2005-05-11 9:15 [Bug target/21508] New: non-optimal code with __builtin_signbit uros at kss-loka dot si
@ 2005-05-11 11:25 ` pinskia at gcc dot gnu dot org
2005-06-03 8:13 ` uros at kss-loka dot si
1 sibling, 0 replies; 4+ messages in thread
From: pinskia at gcc dot gnu dot org @ 2005-05-11 11:25 UTC (permalink / raw)
To: gcc-bugs
------- Additional Comments From pinskia at gcc dot gnu dot org 2005-05-11 11:25 -------
Confirmed.
--
What |Removed |Added
----------------------------------------------------------------------------
Status|UNCONFIRMED |NEW
Ever Confirmed| |1
Keywords| |missed-optimization
Known to fail| |4.0.0 4.1.0
Last reconfirmed|0000-00-00 00:00:00 |2005-05-11 11:25:47
date| |
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=21508
^ permalink raw reply [flat|nested] 4+ messages in thread
* [Bug target/21508] non-optimal code with __builtin_signbit
2005-05-11 9:15 [Bug target/21508] New: non-optimal code with __builtin_signbit uros at kss-loka dot si
2005-05-11 11:25 ` [Bug target/21508] " pinskia at gcc dot gnu dot org
@ 2005-06-03 8:13 ` uros at kss-loka dot si
1 sibling, 0 replies; 4+ messages in thread
From: uros at kss-loka dot si @ 2005-06-03 8:13 UTC (permalink / raw)
To: gcc-bugs
------- Additional Comments From uros at kss-loka dot si 2005-06-03 08:13 -------
It looks that REG_EQUAL notes gets lost between regmove and lreg pass. A
relevant part from compiling an example in description with '-O2' shows:
pr21508.c.19.regmove:
(note:HI 7 6 12 0 NOTE_INSN_FUNCTION_BEG)
(insn:HI 12 7 13 0 (set (reg:DF 62)
(mem/u/i:DF (symbol_ref/u:SI ("*.LC1") [flags 0x2]) [2 S8 A64])) 65
{*movdf_nointeger} (nil)
(expr_list:REG_EQUAL (const_double:DF -2147483648 [0x80000000] 1.0e+0
[0x0.8p+1])
(nil)))
in pr21508.c.22.lreg:
(note:HI 7 6 12 0 NOTE_INSN_FUNCTION_BEG)
(insn:HI 12 7 13 0 (set (reg:DF 62)
(mem/u/i:DF (symbol_ref/u:SI ("*.LC1") [flags 0x2]) [2 S8 A64])) 65
{*movdf_nointeger} (nil)
(nil))
However, compiling a simple program, such as:
double test (double a) {
return a + 1.0;
}
results in fld1 insn being used. REG_EQUAL notes are still present in lreg dump
file:
(note:HI 7 6 11 0 NOTE_INSN_FUNCTION_BEG)
(insn:HI 11 7 12 0 (set (reg:DF 61)
(mem/u/i:DF (symbol_ref/u:SI ("*.LC1") [flags 0x2]) [2 S8 A64])) 65
{*movdf_nointeger} (nil)
(expr_list:REG_EQUAL (const_double:DF -2147483648 [0x80000000] 1.0e+0
[0x0.8p+1])
(nil)))
--
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=21508
^ permalink raw reply [flat|nested] 4+ messages in thread
* [Bug target/21508] non-optimal code with __builtin_signbit
[not found] <bug-21508-1649@http.gcc.gnu.org/bugzilla/>
@ 2006-10-22 21:01 ` pinskia at gcc dot gnu dot org
0 siblings, 0 replies; 4+ messages in thread
From: pinskia at gcc dot gnu dot org @ 2006-10-22 21:01 UTC (permalink / raw)
To: gcc-bugs
------- Comment #3 from pinskia at gcc dot gnu dot org 2006-10-22 21:01 -------
On the mainline we get:
subl $12, %esp
fld1
faddl 16(%esp)
fstpl (%esp)
movl 4(%esp), %eax
addl $12, %esp
andl $-2147483648, %eax
ret
Which is optimial as there is no extra movl and there is fld1.
--
pinskia at gcc dot gnu dot org changed:
What |Removed |Added
----------------------------------------------------------------------------
Status|NEW |RESOLVED
Resolution| |FIXED
Target Milestone|--- |4.3.0
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=21508
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2006-10-22 21:01 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2005-05-11 9:15 [Bug target/21508] New: non-optimal code with __builtin_signbit uros at kss-loka dot si
2005-05-11 11:25 ` [Bug target/21508] " pinskia at gcc dot gnu dot org
2005-06-03 8:13 ` uros at kss-loka dot si
[not found] <bug-21508-1649@http.gcc.gnu.org/bugzilla/>
2006-10-22 21:01 ` pinskia at gcc dot gnu dot org
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).