public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
From: "rguenth at gcc dot gnu dot org" <gcc-bugzilla@gcc.gnu.org>
To: gcc-bugs@gcc.gnu.org
Subject: [Bug middle-end/33887] [4.2/4.3 Regression] Reference to bitfield gets wrong value when optimizing
Date: Tue, 11 Dec 2007 12:50:00 -0000	[thread overview]
Message-ID: <20071211125033.23928.qmail@sourceware.org> (raw)
In-Reply-To: <bug-33887-1313@http.gcc.gnu.org/bugzilla/>



------- Comment #7 from rguenth at gcc dot gnu dot org  2007-12-11 12:50 -------
Reduced testcase:

extern "C" void abort() __attribute__ ((noreturn));

struct s
{
  unsigned long long f1 : 40;
  unsigned int f2 : 24;
} sv;

int main()
{
  int f2;
  sv.f2 = (1 << 24) - 1;
  __asm__ volatile ("" : : : "memory");
  ++sv.f2;
  f2 = sv.f2;
  if (f2 != 0)
    abort();
  return 0;
}

it doesn't fail with the C frontend though, even though the IL before
expansion is the same:

  <unnamed-unsigned:24> D.1548;

<bb 2>:
  sv.f2 = 16777215;
  __asm__ __volatile__("":::"memory");
  D.1548 = sv.f2 + 1;
  sv.f2 = D.1548;
  if (D.1548 != 0)

the difference is:

 (insn 13 10 14 3 t5.i:14 (set (reg/f:DI 67)
-        (const:DI (plus:DI (symbol_ref:DI ("sv") <var_decl 0x2b6b88bba320 sv>)
+        (const:DI (plus:DI (symbol_ref:DI ("sv") [flags 0x2] <var_decl
0x2b2e527ee0a0 sv>)
                 (const_int 4 [0x4])))) -1 (nil))

 (insn 14 13 15 3 t5.i:14 (set (reg:SI 69)
@@ -197,59 +185,52 @@
             (const_int 8 [0x8]))
         (nil)))

-(insn 16 15 17 3 t5.i:14 (parallel [
-            (set (reg:SI 58 [ D.1548 ])
+(insn 16 15 18 3 t5.i:14 (parallel [
+            (set (reg:SI 58 [ D.2025 ])
                 (plus:SI (reg:SI 68)
                     (const_int 1 [0x1])))
             (clobber (reg:CC 17 flags))
         ]) -1 (nil))

-(insn 17 16 19 3 t5.i:14 (parallel [
-            (set (reg:SI 58 [ D.1548 ])
-                (and:SI (reg:SI 58 [ D.1548 ])
-                    (const_int 16777215 [0xffffff])))
-            (clobber (reg:CC 17 flags))
-        ]) -1 (nil))
-
-(insn 19 17 20 3 t5.i:14 (set (reg/f:DI 71)
-        (const:DI (plus:DI (symbol_ref:DI ("sv") <var_decl 0x2b6b88bba320 sv>)
+(insn 18 16 19 3 t5.i:14 (set (reg/f:DI 71)
+        (const:DI (plus:DI (symbol_ref:DI ("sv") [flags 0x2] <var_decl
0x2b2e527ee0a0 sv>)
                 (const_int 4 [0x4])))) -1 (nil))

-(insn 20 19 21 3 t5.i:14 (parallel [
+(insn 19 18 20 3 t5.i:14 (parallel [
             (set (reg:SI 72)
-                (ashift:SI (reg:SI 58 [ D.1548 ])
+                (ashift:SI (reg:SI 58 [ D.2025 ])
                     (const_int 8 [0x8])))
             (clobber (reg:CC 17 flags))
         ]) -1 (nil))

...


-- 


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


  parent reply	other threads:[~2007-12-11 12:50 UTC|newest]

Thread overview: 50+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2007-10-24 23:44 [Bug c++/33887] New: " ian at airs dot com
2007-10-24 23:51 ` [Bug c++/33887] " pinskia at gcc dot gnu dot org
2007-10-25  5:07 ` ian at airs dot com
2007-10-25  5:22 ` pinskia at gcc dot gnu dot org
2007-10-25 13:25 ` ian at airs dot com
2007-12-08 20:07 ` [Bug middle-end/33887] [4.2/4.3 Regression] " pinskia at gcc dot gnu dot org
2007-12-11 12:38 ` rguenth at gcc dot gnu dot org
2007-12-11 12:50 ` rguenth at gcc dot gnu dot org [this message]
2007-12-11 13:08 ` [Bug c++/33887] " rguenth at gcc dot gnu dot org
2007-12-11 13:32 ` [Bug c++/33887] [4.1/4.2/4.3 " rguenth at gcc dot gnu dot org
2007-12-11 13:35 ` rguenth at gcc dot gnu dot org
2007-12-11 15:55 ` rguenth at gcc dot gnu dot org
2007-12-11 23:57 ` janis at gcc dot gnu dot org
2007-12-12 20:53 ` mmitchel at gcc dot gnu dot org
2007-12-12 22:04 ` janis at gcc dot gnu dot org
2007-12-12 22:47 ` rguenth at gcc dot gnu dot org
2007-12-14 14:32 ` bonzini at gnu dot org
2007-12-14 14:36 ` rguenther at suse dot de
2008-01-02 15:34 ` rguenth at gcc dot gnu dot org
2008-01-11  7:29 ` aoliva at gcc dot gnu dot org
2008-01-14 16:55 ` rguenth at gcc dot gnu dot org
2008-01-14 19:10 ` rguenth at gcc dot gnu dot org
2008-01-14 19:19 ` rguenth at gcc dot gnu dot org
2008-01-14 21:35 ` aoliva at gcc dot gnu dot org
2008-01-15 10:11 ` rguenth at gcc dot gnu dot org
2008-01-15 14:12 ` rguenth at gcc dot gnu dot org
2008-01-15 14:55 ` rguenth at gcc dot gnu dot org
2008-01-18 18:45 ` aoliva at gcc dot gnu dot org
2008-01-18 19:22 ` aoliva at gcc dot gnu dot org
2008-01-18 19:46 ` aoliva at gcc dot gnu dot org
2008-01-18 22:21 ` rguenth at gcc dot gnu dot org
2008-01-19  1:05 ` aoliva at gcc dot gnu dot org
2008-01-21  9:35 ` rguenth at gcc dot gnu dot org
2008-01-21  9:44 ` rguenth at gcc dot gnu dot org
2008-01-23 15:04 ` rguenth at gcc dot gnu dot org
2008-01-25  7:51 ` mmitchel at gcc dot gnu dot org
2008-01-25 12:15 ` rguenth at gcc dot gnu dot org
2008-01-25 12:56 ` [Bug c++/33887] [4.1/4.2 " rguenth at gcc dot gnu dot org
2008-01-25 20:57 ` tromey at gcc dot gnu dot org
2008-01-25 21:41 ` rguenth at gcc dot gnu dot org
2008-02-01 17:02 ` jsm28 at gcc dot gnu dot org
2008-02-07 18:04 ` rguenth at gcc dot gnu dot org
2008-03-12 14:27 ` rguenth at gcc dot gnu dot org
2008-03-12 14:31 ` rguenth at gcc dot gnu dot org
2008-04-18 14:04 ` aldot at gcc dot gnu dot org
2008-04-18 15:07 ` rguenth at gcc dot gnu dot org
2008-05-07 19:44 ` rguenth at gcc dot gnu dot org
2008-05-19 20:31 ` jsm28 at gcc dot gnu dot org
2008-07-04 22:53 ` [Bug c++/33887] [4.2 " jsm28 at gcc dot gnu dot org
2009-03-31  0:36 ` jsm28 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=20071211125033.23928.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).