public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug middle-end/45017]  New: miscompile with bitfield and optimization
@ 2010-07-21 11:23 borntraeger at de dot ibm dot com
  2010-07-21 16:21 ` [Bug middle-end/45017] " rguenth at gcc dot gnu dot org
                   ` (13 more replies)
  0 siblings, 14 replies; 15+ messages in thread
From: borntraeger at de dot ibm dot com @ 2010-07-21 11:23 UTC (permalink / raw)
  To: gcc-bugs

The following testcase has a different result with 4.6 and -O1/2/3

gcc4.5: all optimizations:
r1: 15 r2: 2

gcc4.6: -O0
r1: 15 r2: 2

gcc4.6: -O1,-O2..
r1: 47 r2: 2

#include <stdio.h>

int tester(char *bytes)
{
        union {
                struct {
                        unsigned int r1:4;
                        unsigned int r2:4;
                } fmt;
                char value[1];
        } ovl;

        ovl.value[0] = bytes[0];
        printf("r1: %d r2: %d\n", ovl.fmt.r1, ovl.fmt.r2);
        return 0;
}

int main()
{
        char buff = 0x2f;
        return tester(&buff);
}


-- 
           Summary: miscompile with bitfield and optimization
           Product: gcc
           Version: 4.6.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: middle-end
        AssignedTo: unassigned at gcc dot gnu dot org
        ReportedBy: borntraeger at de dot ibm dot com
 GCC build triplet: i686-pc-linux-gnu and s390x-ibm-linux-gnu
  GCC host triplet: i686-pc-linux-gnu and s390x-ibm-linux-gnu
GCC target triplet: i686-pc-linux-gnu and s390x-ibm-linux-gnu


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


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

* [Bug middle-end/45017] miscompile with bitfield and optimization
  2010-07-21 11:23 [Bug middle-end/45017] New: miscompile with bitfield and optimization borntraeger at de dot ibm dot com
@ 2010-07-21 16:21 ` rguenth at gcc dot gnu dot org
  2010-07-22 12:15 ` rguenth at gcc dot gnu dot org
                   ` (12 subsequent siblings)
  13 siblings, 0 replies; 15+ messages in thread
From: rguenth at gcc dot gnu dot org @ 2010-07-21 16:21 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #1 from rguenth at gcc dot gnu dot org  2010-07-21 16:20 -------
Confirmed.  This is caused by mem-ref & VN.  Thus, 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         |2010-07-21 16:20:44
               date|                            |


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


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

* [Bug middle-end/45017] miscompile with bitfield and optimization
  2010-07-21 11:23 [Bug middle-end/45017] New: miscompile with bitfield and optimization borntraeger at de dot ibm dot com
  2010-07-21 16:21 ` [Bug middle-end/45017] " rguenth at gcc dot gnu dot org
  2010-07-22 12:15 ` rguenth at gcc dot gnu dot org
@ 2010-07-22 12:15 ` rguenth at gcc dot gnu dot org
  2010-07-22 12:41 ` borntraeger at de dot ibm dot com
                   ` (10 subsequent siblings)
  13 siblings, 0 replies; 15+ messages in thread
From: rguenth at gcc dot gnu dot org @ 2010-07-22 12:15 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #2 from rguenth at gcc dot gnu dot org  2010-07-22 12:14 -------
Subject: Bug 45017

Author: rguenth
Date: Thu Jul 22 12:14:27 2010
New Revision: 162411

URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=162411
Log:
2010-07-22  Richard Guenther  <rguenther@suse.de>

        PR tree-optimization/45017
        * tree-ssa-sccvn.c (vn_reference_eq): Make sure we honor
        TYPE_PRECISION of integral types in addition to size.

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

Added:
    trunk/gcc/testsuite/gcc.c-torture/execute/pr45017.c
Modified:
    trunk/gcc/ChangeLog
    trunk/gcc/testsuite/ChangeLog
    trunk/gcc/tree-ssa-sccvn.c


-- 


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


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

* [Bug middle-end/45017] miscompile with bitfield and optimization
  2010-07-21 11:23 [Bug middle-end/45017] New: miscompile with bitfield and optimization borntraeger at de dot ibm dot com
  2010-07-21 16:21 ` [Bug middle-end/45017] " rguenth at gcc dot gnu dot org
@ 2010-07-22 12:15 ` rguenth at gcc dot gnu dot org
  2010-07-22 12:15 ` rguenth at gcc dot gnu dot org
                   ` (11 subsequent siblings)
  13 siblings, 0 replies; 15+ messages in thread
From: rguenth at gcc dot gnu dot org @ 2010-07-22 12:15 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #3 from rguenth at gcc dot gnu dot org  2010-07-22 12:15 -------
Fixed.


-- 

rguenth at gcc dot gnu dot org changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|ASSIGNED                    |RESOLVED
         Resolution|                            |FIXED
   Target Milestone|---                         |4.6.0


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


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

* [Bug middle-end/45017] miscompile with bitfield and optimization
  2010-07-21 11:23 [Bug middle-end/45017] New: miscompile with bitfield and optimization borntraeger at de dot ibm dot com
                   ` (2 preceding siblings ...)
  2010-07-22 12:15 ` rguenth at gcc dot gnu dot org
@ 2010-07-22 12:41 ` borntraeger at de dot ibm dot com
  2010-07-22 12:42 ` rguenther at suse dot de
                   ` (9 subsequent siblings)
  13 siblings, 0 replies; 15+ messages in thread
From: borntraeger at de dot ibm dot com @ 2010-07-22 12:41 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #4 from borntraeger at de dot ibm dot com  2010-07-22 12:41 -------
the testcase will fail on big endian machines.
since r2=f and r1=2 instead of r2=2 and r1=f.
Can you adopt the testcase to check the endianess?


-- 


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


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

* [Bug middle-end/45017] miscompile with bitfield and optimization
  2010-07-21 11:23 [Bug middle-end/45017] New: miscompile with bitfield and optimization borntraeger at de dot ibm dot com
                   ` (3 preceding siblings ...)
  2010-07-22 12:41 ` borntraeger at de dot ibm dot com
@ 2010-07-22 12:42 ` rguenther at suse dot de
  2010-07-22 12:59 ` schwab at linux-m68k dot org
                   ` (8 subsequent siblings)
  13 siblings, 0 replies; 15+ messages in thread
From: rguenther at suse dot de @ 2010-07-22 12:42 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #5 from rguenther at suse dot de  2010-07-22 12:42 -------
Subject: Re:  miscompile with bitfield and
 optimization

On Thu, 22 Jul 2010, borntraeger at de dot ibm dot com wrote:

> ------- Comment #4 from borntraeger at de dot ibm dot com  2010-07-22 12:41 -------
> the testcase will fail on big endian machines.
> since r2=f and r1=2 instead of r2=2 and r1=f.
> Can you adopt the testcase to check the endianess?

Huh?  This is one byte, how does endianess come into play?


-- 


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


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

* [Bug middle-end/45017] miscompile with bitfield and optimization
  2010-07-21 11:23 [Bug middle-end/45017] New: miscompile with bitfield and optimization borntraeger at de dot ibm dot com
                   ` (4 preceding siblings ...)
  2010-07-22 12:42 ` rguenther at suse dot de
@ 2010-07-22 12:59 ` schwab at linux-m68k dot org
  2010-07-23  2:49 ` drow at gcc dot gnu dot org
                   ` (7 subsequent siblings)
  13 siblings, 0 replies; 15+ messages in thread
From: schwab at linux-m68k dot org @ 2010-07-22 12:59 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #6 from schwab at linux-m68k dot org  2010-07-22 12:59 -------
> Huh?  This is one byte, how does endianess come into play?

By the use of bitfields.


-- 


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


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

* [Bug middle-end/45017] miscompile with bitfield and optimization
  2010-07-21 11:23 [Bug middle-end/45017] New: miscompile with bitfield and optimization borntraeger at de dot ibm dot com
                   ` (5 preceding siblings ...)
  2010-07-22 12:59 ` schwab at linux-m68k dot org
@ 2010-07-23  2:49 ` drow at gcc dot gnu dot org
  2010-07-23 13:17 ` danglin at gcc dot gnu dot org
                   ` (6 subsequent siblings)
  13 siblings, 0 replies; 15+ messages in thread
From: drow at gcc dot gnu dot org @ 2010-07-23  2:49 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #7 from drow at gcc dot gnu dot org  2010-07-23 02:49 -------
FYI, confirmed to fail for ColdFire.


-- 


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


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

* [Bug middle-end/45017] miscompile with bitfield and optimization
  2010-07-21 11:23 [Bug middle-end/45017] New: miscompile with bitfield and optimization borntraeger at de dot ibm dot com
                   ` (6 preceding siblings ...)
  2010-07-23  2:49 ` drow at gcc dot gnu dot org
@ 2010-07-23 13:17 ` danglin at gcc dot gnu dot org
  2010-07-25 15:44 ` ebotcazou at gcc dot gnu dot org
                   ` (5 subsequent siblings)
  13 siblings, 0 replies; 15+ messages in thread
From: danglin at gcc dot gnu dot org @ 2010-07-23 13:17 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #8 from danglin at gcc dot gnu dot org  2010-07-23 13:17 -------
Test fails on hppa64-hp-hpux11.11.


-- 

danglin at gcc dot gnu dot org changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |danglin at gcc dot gnu dot
                   |                            |org


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


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

* [Bug middle-end/45017] miscompile with bitfield and optimization
  2010-07-21 11:23 [Bug middle-end/45017] New: miscompile with bitfield and optimization borntraeger at de dot ibm dot com
                   ` (7 preceding siblings ...)
  2010-07-23 13:17 ` danglin at gcc dot gnu dot org
@ 2010-07-25 15:44 ` ebotcazou at gcc dot gnu dot org
  2010-07-25 16:46 ` mikpe at it dot uu dot se
                   ` (4 subsequent siblings)
  13 siblings, 0 replies; 15+ messages in thread
From: ebotcazou at gcc dot gnu dot org @ 2010-07-25 15:44 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #9 from ebotcazou at gcc dot gnu dot org  2010-07-25 15:44 -------
On the SPARC as well.


-- 

ebotcazou at gcc dot gnu dot org changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |ebotcazou at gcc dot gnu dot
                   |                            |org


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


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

* [Bug middle-end/45017] miscompile with bitfield and optimization
  2010-07-21 11:23 [Bug middle-end/45017] New: miscompile with bitfield and optimization borntraeger at de dot ibm dot com
                   ` (8 preceding siblings ...)
  2010-07-25 15:44 ` ebotcazou at gcc dot gnu dot org
@ 2010-07-25 16:46 ` mikpe at it dot uu dot se
  2010-07-25 16:54 ` borntraeger at de dot ibm dot com
                   ` (3 subsequent siblings)
  13 siblings, 0 replies; 15+ messages in thread
From: mikpe at it dot uu dot se @ 2010-07-25 16:46 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #10 from mikpe at it dot uu dot se  2010-07-25 16:45 -------
This test fails on powerpc64-linux and sparc64-linux.


-- 

mikpe at it dot uu dot se changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |mikpe at it dot uu dot se


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


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

* [Bug middle-end/45017] miscompile with bitfield and optimization
  2010-07-21 11:23 [Bug middle-end/45017] New: miscompile with bitfield and optimization borntraeger at de dot ibm dot com
                   ` (9 preceding siblings ...)
  2010-07-25 16:46 ` mikpe at it dot uu dot se
@ 2010-07-25 16:54 ` borntraeger at de dot ibm dot com
  2010-07-25 17:13 ` dave at hiauly1 dot hia dot nrc dot ca
                   ` (2 subsequent siblings)
  13 siblings, 0 replies; 15+ messages in thread
From: borntraeger at de dot ibm dot com @ 2010-07-25 16:54 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #11 from borntraeger at de dot ibm dot com  2010-07-25 16:54 -------
Something like the following should do the trick.
Is endian.h available on all supported platforms?


*** gcc.c-torture/execute/pr45017.c.orig
--- gcc.c-torture/execute/pr45017.c
***************
*** 1,9 ****
--- 1,17 ----
+ #include <endian.h>
+ 
  int tester(char *bytes)
  {
    union {
        struct {
+ #  if __BYTE_ORDER == __BIG_ENDIAN
+         unsigned int r2:4;
+         unsigned int r1:4;
+ #  endif
+ #  if __BYTE_ORDER == __LITTLE_ENDIAN
          unsigned int r1:4;
          unsigned int r2:4;
+ #  endif
        } fmt;
        char value[1];
    } ovl;


-- 


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


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

* [Bug middle-end/45017] miscompile with bitfield and optimization
  2010-07-21 11:23 [Bug middle-end/45017] New: miscompile with bitfield and optimization borntraeger at de dot ibm dot com
                   ` (10 preceding siblings ...)
  2010-07-25 16:54 ` borntraeger at de dot ibm dot com
@ 2010-07-25 17:13 ` dave at hiauly1 dot hia dot nrc dot ca
  2010-07-25 17:15 ` mikpe at it dot uu dot se
  2010-07-26 10:13 ` borntraeger at de dot ibm dot com
  13 siblings, 0 replies; 15+ messages in thread
From: dave at hiauly1 dot hia dot nrc dot ca @ 2010-07-25 17:13 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #12 from dave at hiauly1 dot hia dot nrc dot ca  2010-07-25 17:13 -------
Subject: Re:  miscompile with bitfield and optimization

> Is endian.h available on all supported platforms?

It is not available on HP-UX.

Dave


-- 


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


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

* [Bug middle-end/45017] miscompile with bitfield and optimization
  2010-07-21 11:23 [Bug middle-end/45017] New: miscompile with bitfield and optimization borntraeger at de dot ibm dot com
                   ` (11 preceding siblings ...)
  2010-07-25 17:13 ` dave at hiauly1 dot hia dot nrc dot ca
@ 2010-07-25 17:15 ` mikpe at it dot uu dot se
  2010-07-26 10:13 ` borntraeger at de dot ibm dot com
  13 siblings, 0 replies; 15+ messages in thread
From: mikpe at it dot uu dot se @ 2010-07-25 17:15 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #13 from mikpe at it dot uu dot se  2010-07-25 17:15 -------
<endian.h> is non-standard.  For instance, Solaris 10 doesn't have it.

Does the test case really require explicit bit fields? Does it work (as in show
the miscompile before the fix) with shift & mask operations instead?


-- 


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


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

* [Bug middle-end/45017] miscompile with bitfield and optimization
  2010-07-21 11:23 [Bug middle-end/45017] New: miscompile with bitfield and optimization borntraeger at de dot ibm dot com
                   ` (12 preceding siblings ...)
  2010-07-25 17:15 ` mikpe at it dot uu dot se
@ 2010-07-26 10:13 ` borntraeger at de dot ibm dot com
  13 siblings, 0 replies; 15+ messages in thread
From: borntraeger at de dot ibm dot com @ 2010-07-26 10:13 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #14 from borntraeger at de dot ibm dot com  2010-07-26 10:13 -------
I have seen the original problem only with bitfields.


-- 


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


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

end of thread, other threads:[~2010-07-26 10:13 UTC | newest]

Thread overview: 15+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2010-07-21 11:23 [Bug middle-end/45017] New: miscompile with bitfield and optimization borntraeger at de dot ibm dot com
2010-07-21 16:21 ` [Bug middle-end/45017] " rguenth at gcc dot gnu dot org
2010-07-22 12:15 ` rguenth at gcc dot gnu dot org
2010-07-22 12:15 ` rguenth at gcc dot gnu dot org
2010-07-22 12:41 ` borntraeger at de dot ibm dot com
2010-07-22 12:42 ` rguenther at suse dot de
2010-07-22 12:59 ` schwab at linux-m68k dot org
2010-07-23  2:49 ` drow at gcc dot gnu dot org
2010-07-23 13:17 ` danglin at gcc dot gnu dot org
2010-07-25 15:44 ` ebotcazou at gcc dot gnu dot org
2010-07-25 16:46 ` mikpe at it dot uu dot se
2010-07-25 16:54 ` borntraeger at de dot ibm dot com
2010-07-25 17:13 ` dave at hiauly1 dot hia dot nrc dot ca
2010-07-25 17:15 ` mikpe at it dot uu dot se
2010-07-26 10:13 ` borntraeger at de dot ibm dot com

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