public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug middle-end/34971]  New: bitfield rotates are folded and expanded wrong
@ 2008-01-25 15:25 rguenth at gcc dot gnu dot org
  2008-01-25 15:34 ` [Bug middle-end/34971] " rguenth at gcc dot gnu dot org
                   ` (4 more replies)
  0 siblings, 5 replies; 6+ messages in thread
From: rguenth at gcc dot gnu dot org @ 2008-01-25 15:25 UTC (permalink / raw)
  To: gcc-bugs

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;
}

Patch to fix the most obvious problems:

http://gcc.gnu.org/ml/gcc-patches/2008-01/msg01224.html

the (maybe better) alternative is to not allow ROTATE_EXPRs that
operate on entities whose precision doesn't match their modes bitsize.


-- 
           Summary: bitfield rotates are folded and expanded wrong
           Product: gcc
           Version: 4.3.0
            Status: UNCONFIRMED
          Keywords: wrong-code
          Severity: normal
          Priority: P3
         Component: middle-end
        AssignedTo: unassigned at gcc dot gnu dot org
        ReportedBy: rguenth at gcc dot gnu dot org


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


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

* [Bug middle-end/34971] bitfield rotates are folded and expanded wrong
  2008-01-25 15:25 [Bug middle-end/34971] New: bitfield rotates are folded and expanded wrong rguenth at gcc dot gnu dot org
@ 2008-01-25 15:34 ` rguenth at gcc dot gnu dot org
  2008-02-27  9:51 ` rguenth at gcc dot gnu dot org
                   ` (3 subsequent siblings)
  4 siblings, 0 replies; 6+ messages in thread
From: rguenth at gcc dot gnu dot org @ 2008-01-25 15:34 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #1 from rguenth at gcc dot gnu dot org  2008-01-25 14:21 -------
Mine.


-- 

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|UNCONFIRMED                 |ASSIGNED
     Ever Confirmed|0                           |1
   Last reconfirmed|0000-00-00 00:00:00         |2008-01-25 14:21:13
               date|                            |


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


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

* [Bug middle-end/34971] bitfield rotates are folded and expanded wrong
  2008-01-25 15:25 [Bug middle-end/34971] New: bitfield rotates are folded and expanded wrong rguenth at gcc dot gnu dot org
  2008-01-25 15:34 ` [Bug middle-end/34971] " rguenth at gcc dot gnu dot org
  2008-02-27  9:51 ` rguenth at gcc dot gnu dot org
@ 2008-02-27  9:51 ` rguenth at gcc dot gnu dot org
  2008-02-27 14:14 ` rguenth at gcc dot gnu dot org
  2008-02-27 14:15 ` rguenth at gcc dot gnu dot org
  4 siblings, 0 replies; 6+ messages in thread
From: rguenth at gcc dot gnu dot org @ 2008-02-27  9:51 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #3 from rguenth at gcc dot gnu dot org  2008-02-27 09:50 -------
Subject: Bug 34971

Author: rguenth
Date: Wed Feb 27 09:50:04 2008
New Revision: 132706

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

        PR middle-end/34971
        * expr.c (expand_expr_real_1): Assert on rotates that operate
        on partial modes.
        * fold-const.c (fold_binary): Use the types precision, not the
        bitsize of the mode if folding rotate expressions.  Build rotates
        only for full modes.

        * gcc.c-torture/execute/pr34971.c: New testcase.

Added:
    trunk/gcc/testsuite/gcc.c-torture/execute/pr34971.c
Modified:
    trunk/gcc/ChangeLog
    trunk/gcc/expr.c
    trunk/gcc/fold-const.c
    trunk/gcc/testsuite/ChangeLog


-- 


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


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

* [Bug middle-end/34971] bitfield rotates are folded and expanded wrong
  2008-01-25 15:25 [Bug middle-end/34971] New: bitfield rotates are folded and expanded wrong rguenth at gcc dot gnu dot org
  2008-01-25 15:34 ` [Bug middle-end/34971] " rguenth at gcc dot gnu dot org
@ 2008-02-27  9:51 ` rguenth at gcc dot gnu dot org
  2008-02-27  9:51 ` rguenth at gcc dot gnu dot org
                   ` (2 subsequent siblings)
  4 siblings, 0 replies; 6+ messages in thread
From: rguenth at gcc dot gnu dot org @ 2008-02-27  9:51 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #2 from rguenth at gcc dot gnu dot org  2008-02-27 09:50 -------
I'll apply this for 4.3.1 as well.


-- 

rguenth at gcc dot gnu dot org changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
      Known to work|                            |4.4.0


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


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

* [Bug middle-end/34971] bitfield rotates are folded and expanded wrong
  2008-01-25 15:25 [Bug middle-end/34971] New: bitfield rotates are folded and expanded wrong rguenth at gcc dot gnu dot org
                   ` (2 preceding siblings ...)
  2008-02-27  9:51 ` rguenth at gcc dot gnu dot org
@ 2008-02-27 14:14 ` rguenth at gcc dot gnu dot org
  2008-02-27 14:15 ` rguenth at gcc dot gnu dot org
  4 siblings, 0 replies; 6+ messages in thread
From: rguenth at gcc dot gnu dot org @ 2008-02-27 14:14 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #4 from rguenth at gcc dot gnu dot org  2008-02-27 14:13 -------
Subject: Bug 34971

Author: rguenth
Date: Wed Feb 27 14:12:33 2008
New Revision: 132712

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

        PR middle-end/35390
        * fold-const.c (fold_unary): Return the correct argument,
        converted to the result type.

        * gcc.c-torture/execute/pr35390.c: New testcase.

        PR middle-end/34971
        * fold-const.c (fold_binary): Use the types precision, not the
        bitsize of the mode if folding rotate expressions.  Build rotates
        only for full modes.

        * gcc.c-torture/execute/pr34971.c: New testcase.

Added:
    branches/gcc-4_3-branch/gcc/testsuite/gcc.c-torture/execute/pr34971.c
    branches/gcc-4_3-branch/gcc/testsuite/gcc.c-torture/execute/pr35390.c
Modified:
    branches/gcc-4_3-branch/gcc/ChangeLog
    branches/gcc-4_3-branch/gcc/fold-const.c
    branches/gcc-4_3-branch/gcc/testsuite/ChangeLog


-- 


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


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

* [Bug middle-end/34971] bitfield rotates are folded and expanded wrong
  2008-01-25 15:25 [Bug middle-end/34971] New: bitfield rotates are folded and expanded wrong rguenth at gcc dot gnu dot org
                   ` (3 preceding siblings ...)
  2008-02-27 14:14 ` rguenth at gcc dot gnu dot org
@ 2008-02-27 14:15 ` rguenth at gcc dot gnu dot org
  4 siblings, 0 replies; 6+ messages in thread
From: rguenth at gcc dot gnu dot org @ 2008-02-27 14:15 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #5 from rguenth at gcc dot gnu dot org  2008-02-27 14:14 -------
Fixed for 4.3.0.


-- 

rguenth at gcc dot gnu dot org changed:

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


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


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

end of thread, other threads:[~2008-02-27 14:15 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2008-01-25 15:25 [Bug middle-end/34971] New: bitfield rotates are folded and expanded wrong rguenth at gcc dot gnu dot org
2008-01-25 15:34 ` [Bug middle-end/34971] " rguenth at gcc dot gnu dot org
2008-02-27  9:51 ` rguenth at gcc dot gnu dot org
2008-02-27  9:51 ` rguenth at gcc dot gnu dot org
2008-02-27 14:14 ` rguenth at gcc dot gnu dot org
2008-02-27 14:15 ` 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).