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

Reply via email to