public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug inline-asm/15228] New: useless copies of floating point operands
@ 2004-04-30 15:56 sylvain dot pion at sophia dot inria dot fr
  2004-04-30 15:57 ` [Bug inline-asm/15228] " sylvain dot pion at sophia dot inria dot fr
                   ` (6 more replies)
  0 siblings, 7 replies; 8+ messages in thread
From: sylvain dot pion at sophia dot inria dot fr @ 2004-04-30 15:56 UTC (permalink / raw)
  To: gcc-bugs

Consider the following function :

// Forces a double to memory
double force2memdouble(double x) {
  asm("" : "=m"(x) : "m"(x));
  return x;
}

This is used to force a double value in memory for platforms like x86
where the FP registers have too much precision.

It gets compiled by GCC (3.4 and 3.3.3, with -O2 -fomit-frame-pointer) to :

force2memdouble:
        subl    $12, %esp
        fldl    16(%esp)
        fstpl   (%esp)
        fldl    (%esp)
        addl    $12, %esp
        ret

I believe that the store/load is useless, and that the function could be
compiled as simply :

force2memdouble:
        fldl    4(%esp)
        ret


It is interesting to note that when using "int", "float" or "long double"
instead of "double", then there is no such useless store/load.


So, is this something that could be improved in GCC ?

Maybe the code responsible for asm() adds too many requirements
on the operands for doubles ?

-- 
           Summary: useless copies of floating point operands
           Product: gcc
           Version: 3.4.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P2
         Component: inline-asm
        AssignedTo: unassigned at gcc dot gnu dot org
        ReportedBy: sylvain dot pion at sophia dot inria dot fr
                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=15228


^ permalink raw reply	[flat|nested] 8+ messages in thread

* [Bug inline-asm/15228] useless copies of floating point operands
  2004-04-30 15:56 [Bug inline-asm/15228] New: useless copies of floating point operands sylvain dot pion at sophia dot inria dot fr
@ 2004-04-30 15:57 ` sylvain dot pion at sophia dot inria dot fr
  2004-04-30 16:15 ` [Bug inline-asm/15228] [3.3/3.4/3.5 Regression] " pinskia at gcc dot gnu dot org
                   ` (5 subsequent siblings)
  6 siblings, 0 replies; 8+ messages in thread
From: sylvain dot pion at sophia dot inria dot fr @ 2004-04-30 15:57 UTC (permalink / raw)
  To: gcc-bugs


------- Additional Comments From sylvain dot pion at sophia dot inria dot fr  2004-04-30 15:51 -------
I still have gcc 2.95 around, so I have tested with it as well.
It produces the better code that I expected :

force2memdouble:
#APP
#NO_APP
        fldl 4(%esp)
        ret


So, if the code is correct, then this problem is a regression on code quality
compared to 2.95.


I want to mention that this asm() is critical when implementing interval
arithmetic.  Also, GMP uses that kind of asm() in mpz_get_d_2exp.


-- 


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=15228


^ permalink raw reply	[flat|nested] 8+ messages in thread

* [Bug inline-asm/15228] [3.3/3.4/3.5 Regression] useless copies of floating point operands
  2004-04-30 15:56 [Bug inline-asm/15228] New: useless copies of floating point operands sylvain dot pion at sophia dot inria dot fr
  2004-04-30 15:57 ` [Bug inline-asm/15228] " sylvain dot pion at sophia dot inria dot fr
@ 2004-04-30 16:15 ` pinskia at gcc dot gnu dot org
  2004-05-17 11:22 ` [Bug inline-asm/15228] [3.4/3.5 " gdr at gcc dot gnu dot org
                   ` (4 subsequent siblings)
  6 siblings, 0 replies; 8+ messages in thread
From: pinskia at gcc dot gnu dot org @ 2004-04-30 16:15 UTC (permalink / raw)
  To: gcc-bugs


------- Additional Comments From pinskia at gcc dot gnu dot org  2004-04-30 15:57 -------
Note before 3.3 and after 2.95.3, the following sequence was used to copy the FP:
        subl    $12, %esp
        movl    16(%esp), %edx
        movl    20(%esp), %ecx
        movl    %edx, (%esp)
        movl    %ecx, 4(%esp)

Confirmed as a regression.

-- 
           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|UNCONFIRMED                 |NEW
     Ever Confirmed|                            |1
           Keywords|                            |pessimizes-code
      Known to fail|                            |3.0.4 3.2.3 3.3.3 3.4.0
                   |                            |3.5.0
      Known to work|                            |2.95.3
   Last reconfirmed|0000-00-00 00:00:00         |2004-04-30 15:57:08
               date|                            |
            Summary|useless copies of floating  |[3.3/3.4/3.5 Regression]
                   |point operands              |useless copies of floating
                   |                            |point operands
   Target Milestone|---                         |3.3.4


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=15228


^ permalink raw reply	[flat|nested] 8+ messages in thread

* [Bug inline-asm/15228] [3.4/3.5 Regression] useless copies of floating point operands
  2004-04-30 15:56 [Bug inline-asm/15228] New: useless copies of floating point operands sylvain dot pion at sophia dot inria dot fr
  2004-04-30 15:57 ` [Bug inline-asm/15228] " sylvain dot pion at sophia dot inria dot fr
  2004-04-30 16:15 ` [Bug inline-asm/15228] [3.3/3.4/3.5 Regression] " pinskia at gcc dot gnu dot org
@ 2004-05-17 11:22 ` gdr at gcc dot gnu dot org
  2004-06-07 19:27 ` rth at gcc dot gnu dot org
                   ` (3 subsequent siblings)
  6 siblings, 0 replies; 8+ messages in thread
From: gdr at gcc dot gnu dot org @ 2004-05-17 11:22 UTC (permalink / raw)
  To: gcc-bugs


------- Additional Comments From gdr at gcc dot gnu dot org  2004-05-16 22:11 -------
Will not fix in 3.3.x.

-- Gaby


-- 
           What    |Removed                     |Added
----------------------------------------------------------------------------
            Summary|[3.3/3.4/3.5 Regression]    |[3.4/3.5 Regression] useless
                   |useless copies of floating  |copies of floating point
                   |point operands              |operands
   Target Milestone|3.3.4                       |3.4.1


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=15228


^ permalink raw reply	[flat|nested] 8+ messages in thread

* [Bug inline-asm/15228] [3.4/3.5 Regression] useless copies of floating point operands
  2004-04-30 15:56 [Bug inline-asm/15228] New: useless copies of floating point operands sylvain dot pion at sophia dot inria dot fr
                   ` (2 preceding siblings ...)
  2004-05-17 11:22 ` [Bug inline-asm/15228] [3.4/3.5 " gdr at gcc dot gnu dot org
@ 2004-06-07 19:27 ` rth at gcc dot gnu dot org
  2004-06-08 16:45 ` [Bug middle-end/15228] " cvs-commit at gcc dot gnu dot org
                   ` (2 subsequent siblings)
  6 siblings, 0 replies; 8+ messages in thread
From: rth at gcc dot gnu dot org @ 2004-06-07 19:27 UTC (permalink / raw)
  To: gcc-bugs


------- Additional Comments From rth at gcc dot gnu dot org  2004-06-07 19:27 -------
Testing a patch.

-- 
           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|rth at redhat dot com       |
         AssignedTo|unassigned at gcc dot gnu   |rth at gcc dot gnu dot org
                   |dot org                     |
             Status|NEW                         |ASSIGNED


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=15228


^ permalink raw reply	[flat|nested] 8+ messages in thread

* [Bug middle-end/15228] [3.4/3.5 Regression] useless copies of floating point operands
  2004-04-30 15:56 [Bug inline-asm/15228] New: useless copies of floating point operands sylvain dot pion at sophia dot inria dot fr
                   ` (3 preceding siblings ...)
  2004-06-07 19:27 ` rth at gcc dot gnu dot org
@ 2004-06-08 16:45 ` cvs-commit at gcc dot gnu dot org
  2004-06-09 23:52 ` rth at gcc dot gnu dot org
  2004-06-09 23:52 ` cvs-commit at gcc dot gnu dot org
  6 siblings, 0 replies; 8+ messages in thread
From: cvs-commit at gcc dot gnu dot org @ 2004-06-08 16:45 UTC (permalink / raw)
  To: gcc-bugs


------- Additional Comments From cvs-commit at gcc dot gnu dot org  2004-06-08 16:45 -------
Subject: Bug 15228

CVSROOT:	/cvs/gcc
Module name:	gcc
Branch: 	gcc-3_4-branch
Changes by:	rth@gcc.gnu.org	2004-06-08 16:44:56

Modified files:
	gcc            : ChangeLog function.c 

Log message:
	PR middle-end/15228
	* function.c (assign_parms): Always set_mem_align with the computed
	FUNCTION_ARG_BOUNDARY.  Don't clear stack_parm if !STRICT_ALIGNMENT.

Patches:
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/ChangeLog.diff?cvsroot=gcc&only_with_tag=gcc-3_4-branch&r1=2.2326.2.481&r2=2.2326.2.482
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/function.c.diff?cvsroot=gcc&only_with_tag=gcc-3_4-branch&r1=1.483.4.13&r2=1.483.4.14



-- 


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=15228


^ permalink raw reply	[flat|nested] 8+ messages in thread

* [Bug middle-end/15228] [3.4/3.5 Regression] useless copies of floating point operands
  2004-04-30 15:56 [Bug inline-asm/15228] New: useless copies of floating point operands sylvain dot pion at sophia dot inria dot fr
                   ` (5 preceding siblings ...)
  2004-06-09 23:52 ` rth at gcc dot gnu dot org
@ 2004-06-09 23:52 ` cvs-commit at gcc dot gnu dot org
  6 siblings, 0 replies; 8+ messages in thread
From: cvs-commit at gcc dot gnu dot org @ 2004-06-09 23:52 UTC (permalink / raw)
  To: gcc-bugs


------- Additional Comments From cvs-commit at gcc dot gnu dot org  2004-06-09 23:52 -------
Subject: Bug 15228

CVSROOT:	/cvs/gcc
Module name:	gcc
Changes by:	rth@gcc.gnu.org	2004-06-09 23:52:15

Modified files:
	gcc            : ChangeLog function.c 

Log message:
	PR middle-end/15228
	* function.c (assign_parms): Always set_mem_align with the computed
	FUNCTION_ARG_BOUNDARY.  Don't clear stack_parm if !STRICT_ALIGNMENT.

Patches:
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/ChangeLog.diff?cvsroot=gcc&r1=2.3901&r2=2.3902
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/function.c.diff?cvsroot=gcc&r1=1.520&r2=1.521



-- 


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=15228


^ permalink raw reply	[flat|nested] 8+ messages in thread

* [Bug middle-end/15228] [3.4/3.5 Regression] useless copies of floating point operands
  2004-04-30 15:56 [Bug inline-asm/15228] New: useless copies of floating point operands sylvain dot pion at sophia dot inria dot fr
                   ` (4 preceding siblings ...)
  2004-06-08 16:45 ` [Bug middle-end/15228] " cvs-commit at gcc dot gnu dot org
@ 2004-06-09 23:52 ` rth at gcc dot gnu dot org
  2004-06-09 23:52 ` cvs-commit at gcc dot gnu dot org
  6 siblings, 0 replies; 8+ messages in thread
From: rth at gcc dot gnu dot org @ 2004-06-09 23:52 UTC (permalink / raw)
  To: gcc-bugs


------- Additional Comments From rth at gcc dot gnu dot org  2004-06-09 23:52 -------
Fixed.

-- 
           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|ASSIGNED                    |RESOLVED
         Resolution|                            |FIXED


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=15228


^ permalink raw reply	[flat|nested] 8+ messages in thread

end of thread, other threads:[~2004-06-09 23:52 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2004-04-30 15:56 [Bug inline-asm/15228] New: useless copies of floating point operands sylvain dot pion at sophia dot inria dot fr
2004-04-30 15:57 ` [Bug inline-asm/15228] " sylvain dot pion at sophia dot inria dot fr
2004-04-30 16:15 ` [Bug inline-asm/15228] [3.3/3.4/3.5 Regression] " pinskia at gcc dot gnu dot org
2004-05-17 11:22 ` [Bug inline-asm/15228] [3.4/3.5 " gdr at gcc dot gnu dot org
2004-06-07 19:27 ` rth at gcc dot gnu dot org
2004-06-08 16:45 ` [Bug middle-end/15228] " cvs-commit at gcc dot gnu dot org
2004-06-09 23:52 ` rth at gcc dot gnu dot org
2004-06-09 23:52 ` cvs-commit 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).