public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c/32244]  New: bit-field: optimization BUG
@ 2007-06-07 13:36 s__nakayama at infoseek dot jp
  2007-06-08 10:28 ` [Bug middle-end/32244] " rguenth at gcc dot gnu dot org
                   ` (5 more replies)
  0 siblings, 6 replies; 7+ messages in thread
From: s__nakayama at infoseek dot jp @ 2007-06-07 13:36 UTC (permalink / raw)
  To: gcc-bugs

The output is different by the optimization.

testcase:
#include <stdio.h>

struct foo
{
  unsigned long long b:33;
};


int main()
{
  struct foo x = {2};
  printf("%llx\n",(x.b<<32));
  return 0;
}

result:
$ gcc bit.c -o bit; ./bit
200000000

$ gcc -O bit.c -o bit; ./bit
0


-- 
           Summary: bit-field: optimization BUG
           Product: gcc
           Version: 4.2.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c
        AssignedTo: unassigned at gcc dot gnu dot org
        ReportedBy: s__nakayama at infoseek dot jp


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


^ permalink raw reply	[flat|nested] 7+ messages in thread

* [Bug middle-end/32244] bit-field: optimization BUG
  2007-06-07 13:36 [Bug c/32244] New: bit-field: optimization BUG s__nakayama at infoseek dot jp
@ 2007-06-08 10:28 ` rguenth at gcc dot gnu dot org
  2007-12-11 13:55 ` rguenth at gcc dot gnu dot org
                   ` (4 subsequent siblings)
  5 siblings, 0 replies; 7+ messages in thread
From: rguenth at gcc dot gnu dot org @ 2007-06-08 10:28 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #1 from rguenth at gcc dot gnu dot org  2007-06-08 10:28 -------
Confirmed.  We are wrongly expanding

;; D.2027 = D.2026 << 32
(insn 18 17 0 (parallel [
            (set (reg:DI 59 [ D.2027 ])
                (ashift:DI (reg:DI 60 [ D.2026 ])
                    (const_int 32 [0x20])))
            (clobber (reg:CC 17 flags))
        ]) -1 (nil)
    (nil))

without properly truncating the result to 33 bit precision.

Not a regression.


-- 

rguenth at gcc dot gnu dot org changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |rguenth at gcc dot gnu dot
                   |                            |org
             Status|UNCONFIRMED                 |NEW
          Component|c                           |middle-end
     Ever Confirmed|0                           |1
           Keywords|                            |wrong-code
      Known to fail|                            |2.95.4 4.1.2 4.2.0
   Last reconfirmed|0000-00-00 00:00:00         |2007-06-08 10:28:26
               date|                            |


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


^ permalink raw reply	[flat|nested] 7+ messages in thread

* [Bug middle-end/32244] bit-field: optimization BUG
  2007-06-07 13:36 [Bug c/32244] New: bit-field: optimization BUG s__nakayama at infoseek dot jp
  2007-06-08 10:28 ` [Bug middle-end/32244] " rguenth at gcc dot gnu dot org
@ 2007-12-11 13:55 ` rguenth at gcc dot gnu dot org
  2008-01-25 14:21 ` rguenth at gcc dot gnu dot org
                   ` (3 subsequent siblings)
  5 siblings, 0 replies; 7+ messages in thread
From: rguenth at gcc dot gnu dot org @ 2007-12-11 13:55 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #2 from rguenth at gcc dot gnu dot org  2007-12-11 13:54 -------
Very similar (apart from typeof) to PR30332.


-- 

rguenth at gcc dot gnu dot org changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
  BugsThisDependsOn|                            |30332


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


^ permalink raw reply	[flat|nested] 7+ messages in thread

* [Bug middle-end/32244] bit-field: optimization BUG
  2007-06-07 13:36 [Bug c/32244] New: bit-field: optimization BUG s__nakayama at infoseek dot jp
  2007-06-08 10:28 ` [Bug middle-end/32244] " rguenth at gcc dot gnu dot org
  2007-12-11 13:55 ` rguenth at gcc dot gnu dot org
@ 2008-01-25 14:21 ` rguenth at gcc dot gnu dot org
  2008-01-25 15:36 ` rguenth at gcc dot gnu dot org
                   ` (2 subsequent siblings)
  5 siblings, 0 replies; 7+ messages in thread
From: rguenth at gcc dot gnu dot org @ 2008-01-25 14:21 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #3 from rguenth at gcc dot gnu dot org  2008-01-25 13:23 -------
Uh, all is broken ;)

  1) we don't reduce shift or rotate results

  2) we do wrong folding of rotates

  3) we do wrong expansion of rotates

struct foo
{
  unsigned long long b:40;
} x;

extern void abort (void);

void test1(unsigned long long res)
{
  /* Build a rotate expression on a 40 bit argument.  */
  if ((x.b<<8) + (x.b>>32) != res)
    abort ();
}

int main()
{
  x.b = 0x0100000001;
  test1(0x0000000101);
  x.b = 0x0100000000;
  test1(0x0000000001);
  return 0;
}


-- 

rguenth at gcc dot gnu dot org changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
         AssignedTo|unassigned at gcc dot gnu   |rguenth at gcc dot gnu dot
                   |dot org                     |org
             Status|NEW                         |ASSIGNED
   Last reconfirmed|2007-06-08 10:28:26         |2008-01-25 13:23:02
               date|                            |


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


^ permalink raw reply	[flat|nested] 7+ messages in thread

* [Bug middle-end/32244] bit-field: optimization BUG
  2007-06-07 13:36 [Bug c/32244] New: bit-field: optimization BUG s__nakayama at infoseek dot jp
                   ` (2 preceding siblings ...)
  2008-01-25 14:21 ` rguenth at gcc dot gnu dot org
@ 2008-01-25 15:36 ` rguenth at gcc dot gnu dot org
  2008-01-25 15:40 ` rguenth at gcc dot gnu dot org
  2008-01-25 15:45 ` rguenth at gcc dot gnu dot org
  5 siblings, 0 replies; 7+ messages in thread
From: rguenth at gcc dot gnu dot org @ 2008-01-25 15:36 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #4 from rguenth at gcc dot gnu dot org  2008-01-25 14:21 -------
I split off the rotate issues to PR34971.


-- 

rguenth at gcc dot gnu dot org changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                URL|http://gcc.gnu.org/ml/gcc-  |
                   |patches/2008-               |
                   |01/msg01224.html            |


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


^ permalink raw reply	[flat|nested] 7+ messages in thread

* [Bug middle-end/32244] bit-field: optimization BUG
  2007-06-07 13:36 [Bug c/32244] New: bit-field: optimization BUG s__nakayama at infoseek dot jp
                   ` (3 preceding siblings ...)
  2008-01-25 15:36 ` rguenth at gcc dot gnu dot org
@ 2008-01-25 15:40 ` rguenth at gcc dot gnu dot org
  2008-01-25 15:45 ` rguenth at gcc dot gnu dot org
  5 siblings, 0 replies; 7+ messages in thread
From: rguenth at gcc dot gnu dot org @ 2008-01-25 15:40 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #5 from rguenth at gcc dot gnu dot org  2008-01-25 15:33 -------
Subject: Bug 32244

Author: rguenth
Date: Fri Jan 25 15:33:09 2008
New Revision: 131828

URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=131828
Log:
2008-01-25  Richard Guenther  <rguenther@suse.de>

        PR middle-end/32244
        * expr.c (expand_expr_real_1): Reduce result of LSHIFT_EXPR
        to its bitfield precision if required.

        * gcc.c-torture/execute/pr32244-1.c: New testcase.

Added:
    trunk/gcc/testsuite/gcc.c-torture/execute/pr32244-1.c
Modified:
    trunk/gcc/ChangeLog
    trunk/gcc/expr.c
    trunk/gcc/testsuite/ChangeLog


-- 


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


^ permalink raw reply	[flat|nested] 7+ messages in thread

* [Bug middle-end/32244] bit-field: optimization BUG
  2007-06-07 13:36 [Bug c/32244] New: bit-field: optimization BUG s__nakayama at infoseek dot jp
                   ` (4 preceding siblings ...)
  2008-01-25 15:40 ` rguenth at gcc dot gnu dot org
@ 2008-01-25 15:45 ` rguenth at gcc dot gnu dot org
  5 siblings, 0 replies; 7+ messages in thread
From: rguenth at gcc dot gnu dot org @ 2008-01-25 15:45 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #6 from rguenth at gcc dot gnu dot org  2008-01-25 15:37 -------
Fixed.


-- 

rguenth at gcc dot gnu dot org changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|ASSIGNED                    |RESOLVED
      Known to work|                            |4.3.0
         Resolution|                            |FIXED
   Target Milestone|---                         |4.3.0


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


^ permalink raw reply	[flat|nested] 7+ messages in thread

end of thread, other threads:[~2008-01-25 15:37 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2007-06-07 13:36 [Bug c/32244] New: bit-field: optimization BUG s__nakayama at infoseek dot jp
2007-06-08 10:28 ` [Bug middle-end/32244] " rguenth at gcc dot gnu dot org
2007-12-11 13:55 ` rguenth at gcc dot gnu dot org
2008-01-25 14:21 ` rguenth at gcc dot gnu dot org
2008-01-25 15:36 ` rguenth at gcc dot gnu dot org
2008-01-25 15:40 ` rguenth at gcc dot gnu dot org
2008-01-25 15:45 ` rguenth at gcc dot gnu dot org

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).