public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
From: "amodra at bigpond dot net dot au" <gcc-bugzilla@gcc.gnu.org>
To: gcc-bugs@gcc.gnu.org
Subject: [Bug target/26525]  New: missed opportunity to use value in fp reg
Date: Thu, 02 Mar 2006 02:40:00 -0000	[thread overview]
Message-ID: <bug-26525-1057@http.gcc.gnu.org/bugzilla/> (raw)

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


             reply	other threads:[~2006-03-02  2:40 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2006-03-02  2:40 amodra at bigpond dot net dot au [this message]
2006-03-02  3:07 ` [Bug target/26525] " pinskia at gcc dot gnu dot org
2006-06-23  1:41 ` pinskia at gcc dot gnu dot org
2007-10-23 17:13 ` pinskia at gcc dot gnu dot org
2008-09-14  3:28 ` pinskia at gcc dot gnu dot org
2009-05-14  3:19 ` bje at gcc dot gnu dot org

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=bug-26525-1057@http.gcc.gnu.org/bugzilla/ \
    --to=gcc-bugzilla@gcc.gnu.org \
    --cc=gcc-bugs@gcc.gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).