public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
From: "jakub at gcc dot gnu.org" <gcc-bugzilla@gcc.gnu.org>
To: gcc-bugs@gcc.gnu.org
Subject: [Bug target/108293] Incorrect assembly emitted for float for BPF target
Date: Thu, 05 Jan 2023 12:43:36 +0000	[thread overview]
Message-ID: <bug-108293-4-BGQrW4DTix@http.gcc.gnu.org/bugzilla/> (raw)
In-Reply-To: <bug-108293-4@http.gcc.gnu.org/bugzilla/>

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=108293

Jakub Jelinek <jakub at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |jakub at gcc dot gnu.org

--- Comment #1 from Jakub Jelinek <jakub at gcc dot gnu.org> ---
The bug is in bpf_print_operand:
    case CONST_DOUBLE:
      if (CONST_DOUBLE_HIGH (op))
        fprintf (file, HOST_WIDE_INT_PRINT_DOUBLE_HEX,
                 CONST_DOUBLE_HIGH (op), CONST_DOUBLE_LOW (op));
      else if (CONST_DOUBLE_LOW (op) < 0)
        fprintf (file, HOST_WIDE_INT_PRINT_HEX, CONST_DOUBLE_LOW (op));
      else
        fprintf (file, HOST_WIDE_INT_PRINT_DEC, CONST_DOUBLE_LOW (op));
      break;
Obviously, the above handling is fine only for integral CONST_DOUBLEs, so for
floating point modes one needs to do something that other targets do, like:
  else if (CONST_DOUBLE_P (x) && GET_MODE (x) == SFmode)
    {
      long l;

      REAL_VALUE_TO_TARGET_SINGLE (*CONST_DOUBLE_REAL_VALUE (x), l);
      fprintf (file, "0x%08x", (unsigned int) l);
    }
for SFmode, or

  else if (CONST_DOUBLE_P (x) && GET_MODE (x) == DFmode)
    {
      long l[2];

      REAL_VALUE_TO_TARGET_DOUBLE (*CONST_DOUBLE_REAL_VALUE (x), l);
      fprintf (file, "0x%lx%08lx", l[1] & 0xffffffff, l[0] & 0xffffffff);
    }
for DFmode.

  reply	other threads:[~2023-01-05 12:43 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-01-05  7:50 [Bug target/108293] New: " dkm at gcc dot gnu.org
2023-01-05 12:43 ` jakub at gcc dot gnu.org [this message]
2023-01-05 12:45 ` [Bug target/108293] " jakub at gcc dot gnu.org
2023-01-05 16:38 ` jemarch at gcc dot gnu.org
2023-01-06 11:15 ` marxin at gcc dot gnu.org
2023-01-11 16:41 ` cvs-commit at gcc dot gnu.org
2023-01-11 17:24 ` jemarch at gcc dot gnu.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-108293-4-BGQrW4DTix@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).