public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug rtl-optimization/19463] New: 387 constants still emitted with -mno-80387 & -mfpmath=sse
@ 2005-01-15 20:11 tbptbp at gmail dot com
  2005-01-15 20:40 ` [Bug target/19463] " pinskia at gcc dot gnu dot org
                   ` (3 more replies)
  0 siblings, 4 replies; 5+ messages in thread
From: tbptbp at gmail dot com @ 2005-01-15 20:11 UTC (permalink / raw)
  To: gcc-bugs

Under elusive conditions, hence the rather cluttered testcase, i'm seeing some
387 constants being used here and there; it doesn't have a big performance
impact but it's not uncommon or correct :)

Happens on gcc-40102 and a 2 day old cvs version (post SSE audit).

With: -O2 -march=k8 -fomit-frame-pointer -mfpmath=sse -mno-80387
[-mno-fancy-math-387]
#include <math.h>

struct vec_t {
       float x,y,z;
       vec_t() {}
       vec_t(const float f1,const float f2,const float f3) : x(f1),y(f2),z(f3) {}

       vec_t operator *(const float f)  const { return vec_t(x*f,y*f,z*f); }
       vec_t operator -(const vec_t &v) const { return vec_t(x-v.x,y-v.y,z-v.z); }
       float mag() const { return sqrtf(x*x + y*y + z*z); }
       vec_t normalize() const { return *this * (1.f/mag()); }
       vec_t cross(const vec_t &v) const { return vec_t(y*v.z - z*v.y,z*v.x
- x*v.z, x*v.y - y*v.x); }
};

// needs -O >= 2
void fpu_constant(vec_t &v1, vec_t &v2, vec_t &v3) {
       const vec_t
               d       = (v1-v2).normalize(),
               r       = v3.cross(d).normalize(),
               u       = d.cross(r).normalize();

       v1 = d; v2 = r; v3 = u;
}

// while making the testcase also found that; needs -O >=1
void fpu_load_store(vec_t &v1, vec_t &v2, vec_t &v3) {
       const vec_t
               d       = (v1-v2).normalize(),
               r       = v3.cross(d).normalize(),
               u;//    = d.cross(r).normalize();

       v1 = d; v2 = r; v3 = u;
}

int main() { return 0; }

In fpu_constant i'm seeing:
 401073:       fld1
...
 4010ba:       movss  0x402000,%xmm1
 4010c2:       sqrtss %xmm0,%xmm0
 4010c6:       divss  %xmm0,%xmm1
...
 401123:       fstps  (%esp)
...
 4011c0:       movss  (%esp),%xmm1
 4011c5:       sqrtss %xmm0,%xmm0
 4011c9:       divss  %xmm0,%xmm1

While making that testcase, i've stumbled upon fpu_load_store:
 401220:       flds   0x402004
...
 401325:       fsts   0x8(%ecx)
 401328:       fsts   0x4(%ecx)
 40132b:       fstps  (%ecx)
 40132d:       add    $0x8,%esp
 401330:       pop    %ebx
 401331:       ret

I've also spotted an fldz on occasion (but not in this testcase).

-- 
           Summary: 387 constants still emitted with -mno-80387 & -
                    mfpmath=sse
           Product: gcc
           Version: 4.0.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P2
         Component: rtl-optimization
        AssignedTo: unassigned at gcc dot gnu dot org
        ReportedBy: tbptbp at gmail dot com
                CC: gcc-bugs at gcc dot gnu dot org
  GCC host triplet: cygwin


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


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

* [Bug target/19463] 387 constants still emitted with -mno-80387 & -mfpmath=sse
  2005-01-15 20:11 [Bug rtl-optimization/19463] New: 387 constants still emitted with -mno-80387 & -mfpmath=sse tbptbp at gmail dot com
@ 2005-01-15 20:40 ` pinskia at gcc dot gnu dot org
  2005-01-18 15:22 ` pinskia at gcc dot gnu dot org
                   ` (2 subsequent siblings)
  3 siblings, 0 replies; 5+ messages in thread
From: pinskia at gcc dot gnu dot org @ 2005-01-15 20:40 UTC (permalink / raw)
  To: gcc-bugs


------- Additional Comments From pinskia at gcc dot gnu dot org  2005-01-15 20:39 -------
I would doubt this is target related but really the register allocator sucking.

-- 
           What    |Removed                     |Added
----------------------------------------------------------------------------
           Severity|normal                      |enhancement
          Component|rtl-optimization            |target
           Keywords|                            |missed-optimization, ssemmx
           Priority|P2                          |P3


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


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

* [Bug target/19463] 387 constants still emitted with -mno-80387 & -mfpmath=sse
  2005-01-15 20:11 [Bug rtl-optimization/19463] New: 387 constants still emitted with -mno-80387 & -mfpmath=sse tbptbp at gmail dot com
  2005-01-15 20:40 ` [Bug target/19463] " pinskia at gcc dot gnu dot org
@ 2005-01-18 15:22 ` pinskia at gcc dot gnu dot org
  2005-01-18 15:26 ` pinskia at gcc dot gnu dot org
  2005-04-20  2:01 ` pinskia at gcc dot gnu dot org
  3 siblings, 0 replies; 5+ messages in thread
From: pinskia at gcc dot gnu dot org @ 2005-01-18 15:22 UTC (permalink / raw)
  To: gcc-bugs


------- Additional Comments From pinskia at gcc dot gnu dot org  2005-01-18 15:22 -------
This has been fixed now on the mainline:

        subss   8(%rsi), %xmm7
        movss   .LC1(%rip), %xmm6


        movss   .LC0(%rip), %xmm11
        movss   4(%rdx), %xmm2

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


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


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

* [Bug target/19463] 387 constants still emitted with -mno-80387 & -mfpmath=sse
  2005-01-15 20:11 [Bug rtl-optimization/19463] New: 387 constants still emitted with -mno-80387 & -mfpmath=sse tbptbp at gmail dot com
  2005-01-15 20:40 ` [Bug target/19463] " pinskia at gcc dot gnu dot org
  2005-01-18 15:22 ` pinskia at gcc dot gnu dot org
@ 2005-01-18 15:26 ` pinskia at gcc dot gnu dot org
  2005-04-20  2:01 ` pinskia at gcc dot gnu dot org
  3 siblings, 0 replies; 5+ messages in thread
From: pinskia at gcc dot gnu dot org @ 2005-01-18 15:26 UTC (permalink / raw)
  To: gcc-bugs


------- Additional Comments From pinskia at gcc dot gnu dot org  2005-01-18 15:26 -------
(In reply to comment #2)
> This has been fixed now on the mainline:
Note I copied the wrong asm:
        pushl   %ebx
.LCFI5: 
        movl    $0x3f800000, %ebx
        subl    $8, %esp
.LCFI6: 
        movl    16(%esp), %eax
        movl    20(%esp), %edx
        movl    24(%esp), %ecx
        movl    %ebx, 4(%esp)
        movss   4(%eax), %xmm4

 pushl   %ebx
.LCFI3: 
        movl    $0x3f800000, %ebx
        subl    $16, %esp
.LCFI4: 
        movl    24(%esp), %eax
        movl    28(%esp), %edx
        movl    32(%esp), %ecx
        movss   4(%eax), %xmm2
        movss   (%eax), %xmm4
        subss   4(%edx), %xmm2


But it is still fixed.

-- 


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


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

* [Bug target/19463] 387 constants still emitted with -mno-80387 & -mfpmath=sse
  2005-01-15 20:11 [Bug rtl-optimization/19463] New: 387 constants still emitted with -mno-80387 & -mfpmath=sse tbptbp at gmail dot com
                   ` (2 preceding siblings ...)
  2005-01-18 15:26 ` pinskia at gcc dot gnu dot org
@ 2005-04-20  2:01 ` pinskia at gcc dot gnu dot org
  3 siblings, 0 replies; 5+ messages in thread
From: pinskia at gcc dot gnu dot org @ 2005-04-20  2:01 UTC (permalink / raw)
  To: gcc-bugs



-- 
           What    |Removed                     |Added
----------------------------------------------------------------------------
   Target Milestone|---                         |4.0.0


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


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

end of thread, other threads:[~2005-04-20  2:01 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2005-01-15 20:11 [Bug rtl-optimization/19463] New: 387 constants still emitted with -mno-80387 & -mfpmath=sse tbptbp at gmail dot com
2005-01-15 20:40 ` [Bug target/19463] " pinskia at gcc dot gnu dot org
2005-01-18 15:22 ` pinskia at gcc dot gnu dot org
2005-01-18 15:26 ` pinskia at gcc dot gnu dot org
2005-04-20  2: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).