public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug target/18668] New: use prescott's fisttp
@ 2004-11-25  1:03 commie1 at gmx dot net
  2004-11-29 14:27 ` [Bug target/18668] " pinskia at gcc dot gnu dot org
                   ` (7 more replies)
  0 siblings, 8 replies; 9+ messages in thread
From: commie1 at gmx dot net @ 2004-11-25  1:03 UTC (permalink / raw)
  To: gcc-bugs

When compiling code that converts a float to an int using -march=prescott gcc
will often use cvtts[sd]2si, but sometimes it will use the old method of:

        fnstcw  -2(%ebp)             # store the control word
        movzwl  -2(%ebp), %eax
        orw     $3072, %ax           # change it to truncate
        movw    %ax, -4(%ebp)
        fldcw   -4(%ebp)             # load that new value
        fistpll -16(%ebp)            # perform the conversion
        fldcw   -2(%ebp)             # and load the previous value

which prescott (and beyond, presumably) can reduce to: fisttpll -16(%ebp)

The code in this case was:

unsigned int oof(double d)
{
  unsigned int i;
  i = d;
  return i;
}

I've found hardly any mention of this instruction in the mailinglists, the code
or bugzilla (PR12308). Perhaps the cvtts[sd]2si should be used with unsigned as
well, perhaps there are other reasons not to have fisttp, I'd like to know.

-- 
           Summary: use prescott's fisttp
           Product: gcc
           Version: 4.0.0
            Status: UNCONFIRMED
          Severity: enhancement
          Priority: P3
         Component: target
        AssignedTo: unassigned at gcc dot gnu dot org
        ReportedBy: commie1 at gmx dot net
                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=18668


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

* [Bug target/18668] use prescott's fisttp
  2004-11-25  1:03 [Bug target/18668] New: use prescott's fisttp commie1 at gmx dot net
@ 2004-11-29 14:27 ` pinskia at gcc dot gnu dot org
  2005-01-23 19:03 ` steven at gcc dot gnu dot org
                   ` (6 subsequent siblings)
  7 siblings, 0 replies; 9+ messages in thread
From: pinskia at gcc dot gnu dot org @ 2004-11-29 14:27 UTC (permalink / raw)
  To: gcc-bugs


------- Additional Comments From pinskia at gcc dot gnu dot org  2004-11-29 14:27 -------
Confirmed.

-- 
           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|UNCONFIRMED                 |NEW
     Ever Confirmed|                            |1
           Keywords|                            |missed-optimization
   Last reconfirmed|0000-00-00 00:00:00         |2004-11-29 14:27:29
               date|                            |


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


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

* [Bug target/18668] use prescott's fisttp
  2004-11-25  1:03 [Bug target/18668] New: use prescott's fisttp commie1 at gmx dot net
  2004-11-29 14:27 ` [Bug target/18668] " pinskia at gcc dot gnu dot org
@ 2005-01-23 19:03 ` steven at gcc dot gnu dot org
  2005-03-10 11:02 ` uros at kss-loka dot si
                   ` (5 subsequent siblings)
  7 siblings, 0 replies; 9+ messages in thread
From: steven at gcc dot gnu dot org @ 2005-01-23 19:03 UTC (permalink / raw)
  To: gcc-bugs


------- Additional Comments From steven at gcc dot gnu dot org  2005-01-23 19:03 -------
On AMD64 I get the following: 
 
oof: 
        cvttsd2siq      %xmm0, %rax 
        ret 
 
But -O2 -march=prescott 
oof: 
        subl    $20, %esp 
        fnstcw  14(%esp) 
        movzwl  14(%esp), %eax 
        movb    $12, %ah 
        movw    %ax, 12(%esp) 
        fldl    24(%esp) 
        fldcw   12(%esp) 
        fistpll (%esp) 
        fldcw   14(%esp) 
        movl    (%esp), %eax 
        addl    $20, %esp 
        ret 
 

-- 


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


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

* [Bug target/18668] use prescott's fisttp
  2004-11-25  1:03 [Bug target/18668] New: use prescott's fisttp commie1 at gmx dot net
  2004-11-29 14:27 ` [Bug target/18668] " pinskia at gcc dot gnu dot org
  2005-01-23 19:03 ` steven at gcc dot gnu dot org
@ 2005-03-10 11:02 ` uros at kss-loka dot si
  2005-03-10 22:12 ` kcook at gcc dot gnu dot org
                   ` (4 subsequent siblings)
  7 siblings, 0 replies; 9+ messages in thread
From: uros at kss-loka dot si @ 2005-03-10 11:02 UTC (permalink / raw)
  To: gcc-bugs


------- Additional Comments From uros at kss-loka dot si  2005-03-10 11:01 -------
Patch here:
http://gcc.gnu.org/ml/gcc-patches/2005-03/msg01009.html

-- 
           What    |Removed                     |Added
----------------------------------------------------------------------------
         AssignedTo|unassigned at gcc dot gnu   |uros at kss-loka dot si
                   |dot org                     |
             Status|NEW                         |ASSIGNED
   Last reconfirmed|2004-11-29 14:27:29         |2005-03-10 11:01:41
               date|                            |


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


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

* [Bug target/18668] use prescott's fisttp
  2004-11-25  1:03 [Bug target/18668] New: use prescott's fisttp commie1 at gmx dot net
                   ` (2 preceding siblings ...)
  2005-03-10 11:02 ` uros at kss-loka dot si
@ 2005-03-10 22:12 ` kcook at gcc dot gnu dot org
  2005-03-10 23:54 ` commie1 at gmx dot net
                   ` (3 subsequent siblings)
  7 siblings, 0 replies; 9+ messages in thread
From: kcook at gcc dot gnu dot org @ 2005-03-10 22:12 UTC (permalink / raw)
  To: gcc-bugs


------- Additional Comments From kcook at gcc dot gnu dot org  2005-03-10 22:12 -------
Uros,

Instead of making a brand new x86_fsittp flag and TARGET_FSITTP this should just
entirely depend on the existing macro TARGET_SSE3.

Note that the vol 2A of the IA-32 manual [3-251-2] says:

FISTTP: Store Integer with Truncation
...
Protected Mode Exceptions
...
#UD If CPUID.SSE3(ECX bit 0) = 0.

Also note that this would takes care of the other testing problems as AMD64
doesn't include SSE3.

-- 
           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |kcook at gcc dot gnu dot org


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


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

* [Bug target/18668] use prescott's fisttp
  2004-11-25  1:03 [Bug target/18668] New: use prescott's fisttp commie1 at gmx dot net
                   ` (3 preceding siblings ...)
  2005-03-10 22:12 ` kcook at gcc dot gnu dot org
@ 2005-03-10 23:54 ` commie1 at gmx dot net
  2005-03-11  9:31 ` uros at kss-loka dot si
                   ` (2 subsequent siblings)
  7 siblings, 0 replies; 9+ messages in thread
From: commie1 at gmx dot net @ 2005-03-10 23:54 UTC (permalink / raw)
  To: gcc-bugs


------- Additional Comments From commie1 at gmx dot net  2005-03-10 23:54 -------
But it's not technically an SSE instruction, and you might still want to use it
when -march=prescott -mno-sse3 is given.

Anyway, I've tested your patch by bootstrapping a patched gcc with
--with-arch=prescott, and then building mozilla (optimized with -march=prescott
ofcourse) with that one. It works as expected. Thanks.

-- 


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


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

* [Bug target/18668] use prescott's fisttp
  2004-11-25  1:03 [Bug target/18668] New: use prescott's fisttp commie1 at gmx dot net
                   ` (4 preceding siblings ...)
  2005-03-10 23:54 ` commie1 at gmx dot net
@ 2005-03-11  9:31 ` uros at kss-loka dot si
  2005-03-15 14:45 ` cvs-commit at gcc dot gnu dot org
  2005-03-15 14:54 ` uros at kss-loka dot si
  7 siblings, 0 replies; 9+ messages in thread
From: uros at kss-loka dot si @ 2005-03-11  9:31 UTC (permalink / raw)
  To: gcc-bugs


------- Additional Comments From uros at kss-loka dot si  2005-03-11 09:31 -------
Updated patch (no need for FLAGS_REG clobber and some mode macro stuff) at
http://gcc.gnu.org/ml/gcc-patches/2005-03/msg01119.html

Regarding comment #4:
I have the same thought as Ferdinand. fisttp insn should not be disabled by
-mno-sse3, that is why TARGET_FISTTP was introduced. As K8 isn't TARGET_FISTTP,
I see no problems here. However for AMD64 instruction set (without fisttp insn),
the generation of fistp and/or cvts?2si should remain exactly the same as
without fisttp patch: cvts?2siq for DImode operands and all -mfpmath settings.

Ferdinand, thanks for testing the patch!


-- 
           What    |Removed                     |Added
----------------------------------------------------------------------------
           Keywords|                            |patch


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


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

* [Bug target/18668] use prescott's fisttp
  2004-11-25  1:03 [Bug target/18668] New: use prescott's fisttp commie1 at gmx dot net
                   ` (5 preceding siblings ...)
  2005-03-11  9:31 ` uros at kss-loka dot si
@ 2005-03-15 14:45 ` cvs-commit at gcc dot gnu dot org
  2005-03-15 14:54 ` uros at kss-loka dot si
  7 siblings, 0 replies; 9+ messages in thread
From: cvs-commit at gcc dot gnu dot org @ 2005-03-15 14:45 UTC (permalink / raw)
  To: gcc-bugs


------- Additional Comments From cvs-commit at gcc dot gnu dot org  2005-03-15 14:44 -------
Subject: Bug 18668

CVSROOT:	/cvs/gcc
Module name:	gcc
Changes by:	uros@gcc.gnu.org	2005-03-15 14:44:13

Modified files:
	gcc            : ChangeLog 
	gcc/config/i386: i386-protos.h i386.c i386.h i386.md 

Log message:
	PR target/18668
	* config/i386/i386.h (x86_fisttp): New.
	(TARGET_FISTTP): New macro.
	* config/i386/i386.c (x86_fisttp): Set for NOCONA.
	(output_fix_trunc): Add fisttp parameter.  Generate fisttp x87
	instruction when fisttp flag is set.
	* config/i386/i386-protos.h (output_fix_trunc): Change declaration.
	
	* config/i386/i386.md (type attribute): Add fisttp.
	(unit attribute): Set to i387 for fisttp type.
	(X87MODEF, X87MODEI, SSEMODEF, SSEMODEI24): New mode macros.
	(fix_truncxfdi2, fix_truncxfsi2): Generate fisttp patterns for
	TARGET_FISTTP.
	(fix_truncdfdi2, fix_truncsfdi2, fix_truncdfsi2, fix_truncsfsi2):
	Generate fisttp patterns for TARGET_FISTTP. Implement using mode
	macros.
	(fix_truncxfhi2, fix_truncdfhi2, fix_truncsfhi2): Generate fisttp
	patterns for TARGET_FISTTP.  Enable patterns for
	(TARGET_FISTTP && !TARGET_SSE_MATH). Implement using mode macros.
	(fix_trunc<mode>_i387_fisttp_1, fix_trunc<mode>_i387_fisttp,
	fix_trunc<mode>_i387_fisttp_with_temp): New instruction patterns to
	implement fisttp x87 insn.
	(fix_trunc*_i387_fisttp splitters): New patterns.
	(*fix_truncdi_i387, *fix_truncsi_i387, *fix_trunchi_i387):
	Rename to *fix_trunc<mode>_i387_1.  Implement using mode macros.
	Disable patterns for TARGET_FISTTP.  Add comment about FLAGS_REG
	clobber.
	(fix_truncdi_memory, fix_truncdi_nomemory, fix_trunchi_nomemory):
	Rename to fix_trunc<mode>_i387 and fix_trunc<mode>_i387_with_temp.
	Implement using mode macros. Disable patterns for TARGET_FISTTP.
	(fix_truncsi_memory, fix_truncsi_nomemory, fix_trunchi_memory,
	fix_trunchi_nomemory): Rename to fix_trunc<mode>_i387 and
	fix_trunc<mode>_i387_with_temp. Implement using mode macros.
	Disable patterns for TARGET_FISTTP.
	(fix_trunc*_i387 splitters): Implement usign mode macros.
	(fix_truncdfdi_sse, fix_truncsfdi_sse, fix_truncdfsi_sse,
	fix_truncsfsi_sse): Disable for (TARGET_FISTTP && !TARGET_SSE_MATH).
	(fix_trunx*_sse peephole2s): Implement using mode macros.

Patches:
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/ChangeLog.diff?cvsroot=gcc&r1=2.7858&r2=2.7859
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/config/i386/i386-protos.h.diff?cvsroot=gcc&r1=1.131&r2=1.132
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/config/i386/i386.c.diff?cvsroot=gcc&r1=1.797&r2=1.798
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/config/i386/i386.h.diff?cvsroot=gcc&r1=1.422&r2=1.423
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/config/i386/i386.md.diff?cvsroot=gcc&r1=1.619&r2=1.620



-- 


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


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

* [Bug target/18668] use prescott's fisttp
  2004-11-25  1:03 [Bug target/18668] New: use prescott's fisttp commie1 at gmx dot net
                   ` (6 preceding siblings ...)
  2005-03-15 14:45 ` cvs-commit at gcc dot gnu dot org
@ 2005-03-15 14:54 ` uros at kss-loka dot si
  7 siblings, 0 replies; 9+ messages in thread
From: uros at kss-loka dot si @ 2005-03-15 14:54 UTC (permalink / raw)
  To: gcc-bugs


------- Additional Comments From uros at kss-loka dot si  2005-03-15 14:53 -------
Patch is comitted to 4.1 mainline. For the testcase in description '-O2
-march=prescott' now generates:

oof:
        pushl   %ebp
        movl    %esp, %ebp
        subl    $8, %esp
        fldl    8(%ebp)
        fisttpll        -8(%ebp)
        movl    -8(%ebp), %eax
        leave
        ret


-- 
           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|ASSIGNED                    |RESOLVED
         Resolution|                            |FIXED
   Target Milestone|---                         |4.1.0


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


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

end of thread, other threads:[~2005-03-15 14:54 UTC | newest]

Thread overview: 9+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2004-11-25  1:03 [Bug target/18668] New: use prescott's fisttp commie1 at gmx dot net
2004-11-29 14:27 ` [Bug target/18668] " pinskia at gcc dot gnu dot org
2005-01-23 19:03 ` steven at gcc dot gnu dot org
2005-03-10 11:02 ` uros at kss-loka dot si
2005-03-10 22:12 ` kcook at gcc dot gnu dot org
2005-03-10 23:54 ` commie1 at gmx dot net
2005-03-11  9:31 ` uros at kss-loka dot si
2005-03-15 14:45 ` cvs-commit at gcc dot gnu dot org
2005-03-15 14:54 ` uros at kss-loka dot si

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).