This is the mail archive of the gcc-bugs@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[Bug target/26525] New: missed opportunity to use value in fp reg


The following compiled with -m64 -O2 -S

double f1 (double xh)
{
  long long hi = (long long) xh;

  if (hi == __LONG_LONG_MAX__)
    {
      xh += -__LONG_LONG_MAX__ - 1;
      xh += 1.0;
    }
  else
    xh -= hi;

  return xh;
}

generates

        fctidz 0,1
        li 0,-1
        rldicl 0,0,0,1
        stfd 0,-16(1)
        ld 9,-16(1)
        cmpd 7,9,0
        beq 7,.L7
        std 9,-16(1)    #
        nop             #
        nop             #
        nop             #
        lfd 13,-16(1)   #
        fcfid 0,13      #
        fsub 1,1,0
        blr
        .p2align 4,,15
.L7:
        lfs 0,.LC1@toc(2)
        lfs 13,.LC3@toc(2)
        fsub 0,1,0
        fadd 1,0,13
        blr

The sequence marked with # could be replaced with just one insn,
        fcfid 0,0
because HI is in fr0 at that point.

A similar function

double f2 (double xh)
{
  long long hi = (long long) xh;

  xh -= hi;
  if (hi == __LONG_LONG_MAX__)
    {
      xh += hi;
      xh += -__LONG_LONG_MAX__ - 1;
      xh += 1.0;
    }

  return xh;
}

does use the value in th fp reg

        fctidz 0,1
        li 0,-1
        rldicl 0,0,0,1
        stfd 0,-16(1)
        fcfid 0,0       <== here
        fsub 1,1,0
        ld 9,-16(1)
        cmpd 7,9,0
        bnelr 7
        fadd 0,0,1
        lfs 13,.LC5@toc(2)
        lfs 12,.LC7@toc(2)
        fsub 0,0,13
        fadd 1,0,12
        blr


-- 
           Summary: missed opportunity to use value in fp reg
           Product: gcc
           Version: 4.2.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: target
        AssignedTo: unassigned at gcc dot gnu dot org
        ReportedBy: amodra at bigpond dot net dot au
GCC target triplet: powerpc64-linux


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


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]