public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
From: "pinskia at gcc dot gnu dot org" <gcc-bugzilla@gcc.gnu.org>
To: gcc-bugs@gcc.gnu.org
Subject: [Bug middle-end/30704] [4.2/4.3 Regression] Incorrect constant generation for long long
Date: Mon, 12 Mar 2007 23:19:00 -0000	[thread overview]
Message-ID: <20070312231852.11053.qmail@sourceware.org> (raw)
In-Reply-To: <bug-30704-276@http.gcc.gnu.org/bugzilla/>



------- Comment #9 from pinskia at gcc dot gnu dot org  2007-03-12 23:18 -------
Here is my new patch:
Index: ../../gcc/fold-const.c
===================================================================
--- ../../gcc/fold-const.c      (revision 122864)
+++ ../../gcc/fold-const.c      (working copy)
@@ -7357,6 +7357,7 @@ native_interpret_real (tree type, unsign
      up to 192 bits.  */
   REAL_VALUE_TYPE r;
   long tmp[6];
+  long tmp1[6];

   total_bytes = GET_MODE_SIZE (TYPE_MODE (type));
   if (total_bytes > len || total_bytes > 24)
@@ -7367,6 +7368,7 @@ native_interpret_real (tree type, unsign
   for (byte = 0; byte < total_bytes; byte++)
     {
       int bitpos = byte * BITS_PER_UNIT;
+      int bytepos;
       if (total_bytes > UNITS_PER_WORD)
        {
          word = byte / UNITS_PER_WORD;
@@ -7381,11 +7383,18 @@ native_interpret_real (tree type, unsign
       else
        offset = BYTES_BIG_ENDIAN ? (total_bytes - 1) - byte : byte;
       value = ptr[offset];
+      bytepos = FLOAT_WORDS_BIG_ENDIAN ? total_bytes / 4 - bitpos / 32 - 1 :
bitpos / 32;

-      tmp[bitpos / 32] |= (unsigned long)value << (bitpos & 31);
+      tmp[bytepos] |= (unsigned long)value << (bitpos & 31);
+      printf("%ld %ld [%d,%d]\n", tmp[0], tmp[1], bytepos, bitpos);
     }

   real_from_target (&r, tmp, mode);
+  real_to_target (tmp1, &r, mode);
+  /* If the encoded real is going to decode differently, then reject the
constant
+     conversion. */
+  if (memcmp (tmp, tmp1, total_bytes) != 0)
+    return NULL;
   return build_real (type, r);
 }



I am not 100 % sure this is correct but we get the correct constant now for
this one.


-- 


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


  parent reply	other threads:[~2007-03-12 23:19 UTC|newest]

Thread overview: 19+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2007-02-05  0:56 [Bug rtl-optimization/30704] New: " danglin at gcc dot gnu dot org
2007-02-05 10:16 ` [Bug rtl-optimization/30704] " rguenth at gcc dot gnu dot org
2007-02-05 19:43 ` [Bug middle-end/30704] [4.2/4.3 Regression] " pinskia at gcc dot gnu dot org
2007-02-19 21:05 ` mmitchel at gcc dot gnu dot org
2007-03-12 20:19 ` dje at gcc dot gnu dot org
2007-03-12 22:21 ` dje at gcc dot gnu dot org
2007-03-12 22:25 ` pinskia at gcc dot gnu dot org
2007-03-12 22:38 ` pinskia at gcc dot gnu dot org
2007-03-12 22:44 ` pinskia at gcc dot gnu dot org
2007-03-12 23:08 ` pinskia at gcc dot gnu dot org
2007-03-12 23:19 ` pinskia at gcc dot gnu dot org [this message]
2007-03-12 23:21 ` pinskia at gcc dot gnu dot org
2007-03-13  0:10 ` pinskia at gcc dot gnu dot org
2007-03-13 22:16 ` pinskia at gcc dot gnu dot org
2007-03-14  6:09 ` pinskia at gcc dot gnu dot org
2007-04-02 13:59 ` jakub at gcc dot gnu dot org
2007-04-03  9:06 ` jakub at gcc dot gnu dot org
2007-04-03  9:23 ` jakub at gcc dot gnu dot org
2007-04-03 11:33 ` jakub 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=20070312231852.11053.qmail@sourceware.org \
    --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).