public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c/23324] New: unsigned bitfield in struct not passed correctly as argument
@ 2005-08-11  8:08 lindig at cs dot uni-sb dot de
  2005-08-11  8:11 ` [Bug c/23324] " lindig at cs dot uni-sb dot de
                   ` (9 more replies)
  0 siblings, 10 replies; 11+ messages in thread
From: lindig at cs dot uni-sb dot de @ 2005-08-11  8:08 UTC (permalink / raw)
  To: gcc-bugs

The following (generated) code fails an assertion that checks that values passed to a function are 
received correctly. This fails for one value: 

./gcc-4.1.1-ppc-cpp 
gcc-4.1.1-ppc.c:140: failed assertion `yv7.mv7 == dp7.mv7'
Abort trap

The particular value is an unsigned bitfield as part of a struct. The bug is likely to be related to inlining. 
The bug is detected in caller_bf7 but does not occur when the call to caller_bf6 is removed.

int main( int argc, char **argv )
{
    caller_bf6 ();
    caller_bf7 ();
    return errors;
}

To reproduce the bug compile and run the attached code:

: tmp; /scratch/lindig/bin/gcc -O2 -o gcc-4.1.1-ppc-cpp gcc-4.1.1-ppc-cpp.c
: tmp; ./gcc-4.1.1-ppc-cpp 
gcc-4.1.1-ppc.c:140: failed assertion `yv7.mv7 == dp7.mv7'
Abort trap

: tmp; /scratch/lindig/bin/gcc -v
Using built-in specs.
Target: powerpc-apple-darwin7.9.0
Configured with: ../gcc/configure --prefix=/scratch/lindig --enable-languages=c : (reconfigured) ../
gcc/configure --prefix=/scratch/lindig --enable-languages=c : (reconfigured) ../gcc/configure --
prefix=/scratch/lindig --enable-languages=c --no-create --no-recursion
Thread model: posix
gcc version 4.1.0 20050810 (experimental)

The code was generated by my test-code generator Quest: 
http://www.st.cs.uni-sb.de/~lindig/src/quest/index.html

I have reported the bug yesterday using gccbug but did not receive an email confirming the report. 
Therefore I'm filing it here again because I did not find it in the bug database.

# 1 "gcc-4.1.1-ppc.c"
# 0 "<built-in>"
# 1 "<command line>"
# 1 "gcc-4.1.1-ppc.c"
# 15 "gcc-4.1.1-ppc.c"
# 1 "/usr/include/assert.h" 1 3 4
# 45 "/usr/include/assert.h" 3 4
extern void __eprintf (const char *, const char *, unsigned, const char *)
    __attribute__ ((noreturn));
# 16 "gcc-4.1.1-ppc.c" 2





# 1 "/scratch/lindig/lib/gcc/powerpc-apple-darwin7.9.0/4.1.0/include/stdarg.h" 1 3 4
# 43 "/scratch/lindig/lib/gcc/powerpc-apple-darwin7.9.0/4.1.0/include/stdarg.h" 3 4
typedef __builtin_va_list __gnuc_va_list;
# 105 "/scratch/lindig/lib/gcc/powerpc-apple-darwin7.9.0/4.1.0/include/stdarg.h" 3 4
typedef __gnuc_va_list va_list;
# 22 "gcc-4.1.1-ppc.c" 2

extern int printf (char *, ...);
static int errors = 0;
static void failed( int line )
{ printf ("failed in %s: %d\n", "gcc-4.1.1-ppc.c", line); errors++; }
static union at6 { } vv6 = { };
static
struct et6
{
    struct bt6
    {
        signed av6:6;
        signed bv6:7;
        signed cv6:6;
        signed dv6:5;
        unsigned char ev6;
        unsigned int fv6;
        long int gv6;
    }
    mv6;
    unsigned long int nv6;
    signed ov6:12;
    signed pv6:3;
    signed qv6:2;
    signed rv6:10;
    union ct6 { long int hv6; float iv6; float jv6; } sv6;
    int *tv6;
    union dt6 { double kv6; float lv6; } uv6;
}
wv6
=
    {
        { 8, 9, 2, 4, '\x10', 67426805U, 1047191860L },
        1366022414UL,
        858,
        1,
        1,
        305,
        { 1069379046L },
        (int *) 358273621U,
        { 3318.041978 }
    };
static double xv6 = 19239.101269;
static long long int yv6 = 1207859169L;
static int zv6 = 660195606;
static
union at6
callee_af6( struct et6 ap6, double bp6, long long int cp6, int dp6 )
{

    ((void) ((wv6.mv6.av6 == ap6.mv6.av6) ? 0 : (__eprintf ("%s:%u: failed assertion `%s'\n", "gcc-4.1.1-
ppc.c", 72, "wv6.mv6.av6 == ap6.mv6.av6"), 0)));
    ((void) ((wv6.mv6.bv6 == ap6.mv6.bv6) ? 0 : (__eprintf ("%s:%u: failed assertion `%s'\n", "gcc-4.1.1-
ppc.c", 73, "wv6.mv6.bv6 == ap6.mv6.bv6"), 0)));
    ((void) ((wv6.mv6.cv6 == ap6.mv6.cv6) ? 0 : (__eprintf ("%s:%u: failed assertion `%s'\n", "gcc-4.1.1-
ppc.c", 74, "wv6.mv6.cv6 == ap6.mv6.cv6"), 0)));
    ((void) ((wv6.mv6.dv6 == ap6.mv6.dv6) ? 0 : (__eprintf ("%s:%u: failed assertion `%s'\n", "gcc-4.1.1-
ppc.c", 75, "wv6.mv6.dv6 == ap6.mv6.dv6"), 0)));
    ((void) ((wv6.mv6.ev6 == ap6.mv6.ev6) ? 0 : (__eprintf ("%s:%u: failed assertion `%s'\n", "gcc-4.1.1-
ppc.c", 76, "wv6.mv6.ev6 == ap6.mv6.ev6"), 0)));
    ((void) ((wv6.mv6.fv6 == ap6.mv6.fv6) ? 0 : (__eprintf ("%s:%u: failed assertion `%s'\n", "gcc-4.1.1-
ppc.c", 77, "wv6.mv6.fv6 == ap6.mv6.fv6"), 0)));
    ((void) ((wv6.mv6.gv6 == ap6.mv6.gv6) ? 0 : (__eprintf ("%s:%u: failed assertion `%s'\n", "gcc-4.1.1-
ppc.c", 78, "wv6.mv6.gv6 == ap6.mv6.gv6"), 0)));
    ((void) ((wv6.nv6 == ap6.nv6) ? 0 : (__eprintf ("%s:%u: failed assertion `%s'\n", "gcc-4.1.1-ppc.c", 79, 
"wv6.nv6 == ap6.nv6"), 0)));
    ((void) ((wv6.ov6 == ap6.ov6) ? 0 : (__eprintf ("%s:%u: failed assertion `%s'\n", "gcc-4.1.1-ppc.c", 80, 
"wv6.ov6 == ap6.ov6"), 0)));
    ((void) ((wv6.pv6 == ap6.pv6) ? 0 : (__eprintf ("%s:%u: failed assertion `%s'\n", "gcc-4.1.1-ppc.c", 81, 
"wv6.pv6 == ap6.pv6"), 0)));
    ((void) ((wv6.qv6 == ap6.qv6) ? 0 : (__eprintf ("%s:%u: failed assertion `%s'\n", "gcc-4.1.1-ppc.c", 82, 
"wv6.qv6 == ap6.qv6"), 0)));
    ((void) ((wv6.rv6 == ap6.rv6) ? 0 : (__eprintf ("%s:%u: failed assertion `%s'\n", "gcc-4.1.1-ppc.c", 83, 
"wv6.rv6 == ap6.rv6"), 0)));
    ((void) ((wv6.sv6.hv6 == ap6.sv6.hv6) ? 0 : (__eprintf ("%s:%u: failed assertion `%s'\n", "gcc-4.1.1-
ppc.c", 84, "wv6.sv6.hv6 == ap6.sv6.hv6"), 0)));
    ((void) ((wv6.tv6 == ap6.tv6) ? 0 : (__eprintf ("%s:%u: failed assertion `%s'\n", "gcc-4.1.1-ppc.c", 85, 
"wv6.tv6 == ap6.tv6"), 0)));
    ((void) ((wv6.uv6.kv6 == ap6.uv6.kv6) ? 0 : (__eprintf ("%s:%u: failed assertion `%s'\n", "gcc-4.1.1-
ppc.c", 86, "wv6.uv6.kv6 == ap6.uv6.kv6"), 0)));
    ((void) ((xv6 == bp6) ? 0 : (__eprintf ("%s:%u: failed assertion `%s'\n", "gcc-4.1.1-ppc.c", 87, "xv6 == 
bp6"), 0)));
    ((void) ((yv6 == cp6) ? 0 : (__eprintf ("%s:%u: failed assertion `%s'\n", "gcc-4.1.1-ppc.c", 88, "yv6 == 
cp6"), 0)));
    ((void) ((zv6 == dp6) ? 0 : (__eprintf ("%s:%u: failed assertion `%s'\n", "gcc-4.1.1-ppc.c", 89, "zv6 == 
dp6"), 0)));
    return vv6;
}
static void caller_bf6( )
{
    union at6 bav6;
                           bav6 = callee_af6 (wv6, xv6, yv6, zv6);
}
static unsigned char uv7 = '\x46';
static float vv7 = 96636.982442;
static double wv7 = 28450.711801;
static union ct7 { } xv7 = { };
static
struct et7
{
    struct dt7 { float iv7; unsigned short int jv7; } kv7;
    float lv7[0];
    signed mv7:9;
    short int nv7;
    double ov7;
    float pv7;
}
yv7
=
    { { 30135.996213, 42435 }, { }, 170, 22116, 26479.628148, 4082.960685 };
static
union ft7 { float qv7; float *rv7; unsigned int *sv7; } zv7 =
    { 5042.227886 };
static int bav7 = 1345451862;
static struct gt7 { double tv7; } bbv7 = { 47875.491954 };
static long int bcv7[1] = { 1732133482L };
static long long int bdv7 = 381678602L;
static
unsigned char
callee_af7(
    float ap7,
    double bp7,
    union ct7 cp7,
    struct et7 dp7,
    union ft7 ep7,
    int fp7,
    struct gt7 gp7,
    long int hp7[1],
    long long int ip7
)
{

    ((void) ((vv7 == ap7) ? 0 : (__eprintf ("%s:%u: failed assertion `%s'\n", "gcc-4.1.1-ppc.c", 136, "vv7 
== ap7"), 0)));
    ((void) ((wv7 == bp7) ? 0 : (__eprintf ("%s:%u: failed assertion `%s'\n", "gcc-4.1.1-ppc.c", 137, "wv7 
== bp7"), 0)));
    ((void) ((yv7.kv7.iv7 == dp7.kv7.iv7) ? 0 : (__eprintf ("%s:%u: failed assertion `%s'\n", "gcc-4.1.1-
ppc.c", 138, "yv7.kv7.iv7 == dp7.kv7.iv7"), 0)));
    ((void) ((yv7.kv7.jv7 == dp7.kv7.jv7) ? 0 : (__eprintf ("%s:%u: failed assertion `%s'\n", "gcc-4.1.1-
ppc.c", 139, "yv7.kv7.jv7 == dp7.kv7.jv7"), 0)));
    ((void) ((yv7.mv7 == dp7.mv7) ? 0 : (__eprintf ("%s:%u: failed assertion `%s'\n", "gcc-4.1.1-ppc.c", 
140, "yv7.mv7 == dp7.mv7"), 0)));
    ((void) ((yv7.nv7 == dp7.nv7) ? 0 : (__eprintf ("%s:%u: failed assertion `%s'\n", "gcc-4.1.1-ppc.c", 
141, "yv7.nv7 == dp7.nv7"), 0)));
    ((void) ((yv7.ov7 == dp7.ov7) ? 0 : (__eprintf ("%s:%u: failed assertion `%s'\n", "gcc-4.1.1-ppc.c", 142, 
"yv7.ov7 == dp7.ov7"), 0)));
    ((void) ((yv7.pv7 == dp7.pv7) ? 0 : (__eprintf ("%s:%u: failed assertion `%s'\n", "gcc-4.1.1-ppc.c", 
143, "yv7.pv7 == dp7.pv7"), 0)));
    ((void) ((zv7.qv7 == ep7.qv7) ? 0 : (__eprintf ("%s:%u: failed assertion `%s'\n", "gcc-4.1.1-ppc.c", 144, 
"zv7.qv7 == ep7.qv7"), 0)));
    ((void) ((bav7 == fp7) ? 0 : (__eprintf ("%s:%u: failed assertion `%s'\n", "gcc-4.1.1-ppc.c", 145, "bav7 
== fp7"), 0)));
    ((void) ((bbv7.tv7 == gp7.tv7) ? 0 : (__eprintf ("%s:%u: failed assertion `%s'\n", "gcc-4.1.1-ppc.c", 
146, "bbv7.tv7 == gp7.tv7"), 0)));
    ((void) ((bcv7[0] == hp7[0]) ? 0 : (__eprintf ("%s:%u: failed assertion `%s'\n", "gcc-4.1.1-ppc.c", 147, 
"bcv7[0] == hp7[0]"), 0)));
    ((void) ((bdv7 == ip7) ? 0 : (__eprintf ("%s:%u: failed assertion `%s'\n", "gcc-4.1.1-ppc.c", 148, "bdv7 
== ip7"), 0)));
    return uv7;
}
static void caller_bf7( )
{
    unsigned char bev7;

    bev7 = callee_af7 (vv7, wv7, xv7, yv7, zv7, bav7, bbv7, bcv7, bdv7);
    ((void) ((uv7 == bev7) ? 0 : (__eprintf ("%s:%u: failed assertion `%s'\n", "gcc-4.1.1-ppc.c", 156, "uv7 
== bev7"), 0)));
}

int main( int argc, char **argv )
{
    caller_bf6 ();
    caller_bf7 ();
    return errors;
}

-- 
           Summary: unsigned bitfield in struct not passed correctly as
                    argument
           Product: gcc
           Version: 4.1.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P2
         Component: c
        AssignedTo: unassigned at gcc dot gnu dot org
        ReportedBy: lindig at cs dot uni-sb dot de
                CC: gcc-bugs at gcc dot gnu dot org
 GCC build triplet: powerpc-apple-darwin7.9.0
  GCC host triplet: powerpc-apple-darwin7.9.0
GCC target triplet: powerpc-apple-darwin7.9.0


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


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

* [Bug c/23324] unsigned bitfield in struct not passed correctly as argument
  2005-08-11  8:08 [Bug c/23324] New: unsigned bitfield in struct not passed correctly as argument lindig at cs dot uni-sb dot de
@ 2005-08-11  8:11 ` lindig at cs dot uni-sb dot de
  2005-08-11  8:15 ` lindig at cs dot uni-sb dot de
                   ` (8 subsequent siblings)
  9 siblings, 0 replies; 11+ messages in thread
From: lindig at cs dot uni-sb dot de @ 2005-08-11  8:11 UTC (permalink / raw)
  To: gcc-bugs


------- Additional Comments From lindig at cs dot uni-sb dot de  2005-08-11 08:10 -------
Created an attachment (id=9468)
 --> (http://gcc.gnu.org/bugzilla/attachment.cgi?id=9468&action=view)
Test case to reproduce the bug.

This is the same code that I included in the bug description.

-- 


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


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

* [Bug c/23324] unsigned bitfield in struct not passed correctly as argument
  2005-08-11  8:08 [Bug c/23324] New: unsigned bitfield in struct not passed correctly as argument lindig at cs dot uni-sb dot de
  2005-08-11  8:11 ` [Bug c/23324] " lindig at cs dot uni-sb dot de
@ 2005-08-11  8:15 ` lindig at cs dot uni-sb dot de
  2005-08-11 12:13 ` [Bug rtl-optimization/23324] " pinskia at gcc dot gnu dot org
                   ` (7 subsequent siblings)
  9 siblings, 0 replies; 11+ messages in thread
From: lindig at cs dot uni-sb dot de @ 2005-08-11  8:15 UTC (permalink / raw)
  To: gcc-bugs


------- Additional Comments From lindig at cs dot uni-sb dot de  2005-08-11 08:15 -------
The bitfield mv7 is actually signed, not unsigned:

struct et7
{
    struct dt7 { float iv7; unsigned short int jv7; } kv7;
    float lv7[0];
    signed mv7:9;
    short int nv7;
    double ov7;
    float pv7;
}
yv7


-- 


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


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

* [Bug rtl-optimization/23324] unsigned bitfield in struct not passed correctly as argument
  2005-08-11  8:08 [Bug c/23324] New: unsigned bitfield in struct not passed correctly as argument lindig at cs dot uni-sb dot de
  2005-08-11  8:11 ` [Bug c/23324] " lindig at cs dot uni-sb dot de
  2005-08-11  8:15 ` lindig at cs dot uni-sb dot de
@ 2005-08-11 12:13 ` pinskia at gcc dot gnu dot org
  2005-08-11 12:23 ` [Bug rtl-optimization/23324] [4.1 Regression] " pinskia at gcc dot gnu dot org
                   ` (6 subsequent siblings)
  9 siblings, 0 replies; 11+ messages in thread
From: pinskia at gcc dot gnu dot org @ 2005-08-11 12:13 UTC (permalink / raw)
  To: gcc-bugs



-- 
           What    |Removed                     |Added
----------------------------------------------------------------------------
          Component|c                           |rtl-optimization
           Keywords|                            |wrong-code


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


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

* [Bug rtl-optimization/23324] [4.1 Regression] unsigned bitfield in struct not passed correctly as argument
  2005-08-11  8:08 [Bug c/23324] New: unsigned bitfield in struct not passed correctly as argument lindig at cs dot uni-sb dot de
                   ` (2 preceding siblings ...)
  2005-08-11 12:13 ` [Bug rtl-optimization/23324] " pinskia at gcc dot gnu dot org
@ 2005-08-11 12:23 ` pinskia at gcc dot gnu dot org
  2005-08-11 12:24 ` [Bug rtl-optimization/23324] [4.1 Regression] unsigned bitfield in struct not accessed correctly pinskia at gcc dot gnu dot org
                   ` (5 subsequent siblings)
  9 siblings, 0 replies; 11+ messages in thread
From: pinskia at gcc dot gnu dot org @ 2005-08-11 12:23 UTC (permalink / raw)
  To: gcc-bugs


------- Additional Comments From pinskia at gcc dot gnu dot org  2005-08-11 12:22 -------
Confirmed,  This looks like an aliasing issue on the rtl level as -O2 -fno-strict-aliasing works.

This also worked on the 4.0 branch.

-- 
           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|UNCONFIRMED                 |NEW
     Ever Confirmed|                            |1
  GCC build triplet|powerpc-apple-darwin7.9.0   |
   GCC host triplet|powerpc-apple-darwin7.9.0   |
 GCC target triplet|powerpc-apple-darwin7.9.0   |powerpc-*-darwin*
           Keywords|                            |alias
   Last reconfirmed|0000-00-00 00:00:00         |2005-08-11 12:22:54
               date|                            |
            Summary|unsigned bitfield in struct |[4.1 Regression] unsigned
                   |not passed correctly as     |bitfield in struct not
                   |argument                    |passed correctly as argument
   Target Milestone|---                         |4.1.0


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


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

* [Bug rtl-optimization/23324] [4.1 Regression] unsigned bitfield in struct not accessed correctly
  2005-08-11  8:08 [Bug c/23324] New: unsigned bitfield in struct not passed correctly as argument lindig at cs dot uni-sb dot de
                   ` (3 preceding siblings ...)
  2005-08-11 12:23 ` [Bug rtl-optimization/23324] [4.1 Regression] " pinskia at gcc dot gnu dot org
@ 2005-08-11 12:24 ` pinskia at gcc dot gnu dot org
  2005-08-11 12:34 ` pinskia at gcc dot gnu dot org
                   ` (4 subsequent siblings)
  9 siblings, 0 replies; 11+ messages in thread
From: pinskia at gcc dot gnu dot org @ 2005-08-11 12:24 UTC (permalink / raw)
  To: gcc-bugs


------- Additional Comments From pinskia at gcc dot gnu dot org  2005-08-11 12:24 -------
Oh, and this is related to how we inline and then also inline the values of the static const variables (with 
-ftree-store-ccp).

-- 
           What    |Removed                     |Added
----------------------------------------------------------------------------
            Summary|[4.1 Regression] unsigned   |[4.1 Regression] unsigned
                   |bitfield in struct not      |bitfield in struct not
                   |passed correctly as argument|accessed correctly


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


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

* [Bug rtl-optimization/23324] [4.1 Regression] unsigned bitfield in struct not accessed correctly
  2005-08-11  8:08 [Bug c/23324] New: unsigned bitfield in struct not passed correctly as argument lindig at cs dot uni-sb dot de
                   ` (4 preceding siblings ...)
  2005-08-11 12:24 ` [Bug rtl-optimization/23324] [4.1 Regression] unsigned bitfield in struct not accessed correctly pinskia at gcc dot gnu dot org
@ 2005-08-11 12:34 ` pinskia at gcc dot gnu dot org
  2005-09-01  3:48 ` [Bug rtl-optimization/23324] [4.1 Regression] unsigned bitfield in struct not accessed correctly at -O2 and above amodra at bigpond dot net dot au
                   ` (3 subsequent siblings)
  9 siblings, 0 replies; 11+ messages in thread
From: pinskia at gcc dot gnu dot org @ 2005-08-11 12:34 UTC (permalink / raw)
  To: gcc-bugs


------- Additional Comments From pinskia at gcc dot gnu dot org  2005-08-11 12:34 -------
CSE1 is where the differenet is between -O2 and -O2 -fno-strict-aliasing.

-- 


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


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

* [Bug rtl-optimization/23324] [4.1 Regression] unsigned bitfield in struct not accessed correctly at -O2 and above
  2005-08-11  8:08 [Bug c/23324] New: unsigned bitfield in struct not passed correctly as argument lindig at cs dot uni-sb dot de
                   ` (5 preceding siblings ...)
  2005-08-11 12:34 ` pinskia at gcc dot gnu dot org
@ 2005-09-01  3:48 ` amodra at bigpond dot net dot au
  2005-09-07 18:58 ` jakub at gcc dot gnu dot org
                   ` (2 subsequent siblings)
  9 siblings, 0 replies; 11+ messages in thread
From: amodra at bigpond dot net dot au @ 2005-09-01  3:48 UTC (permalink / raw)
  To: gcc-bugs


------- Additional Comments From amodra at bigpond dot net dot au  2005-09-01 03:47 -------
Fails on powerpc-linux -m32 -O2 too.  Passes with -m64 -O2.


-- 
           What    |Removed                     |Added
----------------------------------------------------------------------------
 GCC target triplet|powerpc-*-darwin*           |powerpc-*-*


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


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

* [Bug rtl-optimization/23324] [4.1 Regression] unsigned bitfield in struct not accessed correctly at -O2 and above
  2005-08-11  8:08 [Bug c/23324] New: unsigned bitfield in struct not passed correctly as argument lindig at cs dot uni-sb dot de
                   ` (6 preceding siblings ...)
  2005-09-01  3:48 ` [Bug rtl-optimization/23324] [4.1 Regression] unsigned bitfield in struct not accessed correctly at -O2 and above amodra at bigpond dot net dot au
@ 2005-09-07 18:58 ` jakub at gcc dot gnu dot org
  2005-09-08 14:04 ` jakub at gcc dot gnu dot org
  2005-09-27 16:08 ` [Bug rtl-optimization/23324] [4.0/4.1 " mmitchel at gcc dot gnu dot org
  9 siblings, 0 replies; 11+ messages in thread
From: jakub at gcc dot gnu dot org @ 2005-09-07 18:58 UTC (permalink / raw)
  To: gcc-bugs


------- Additional Comments From jakub at gcc dot gnu dot org  2005-09-07 18:58 -------
Looking into it.

-- 
           What    |Removed                     |Added
----------------------------------------------------------------------------
         AssignedTo|unassigned at gcc dot gnu   |jakub at gcc dot gnu dot org
                   |dot org                     |
             Status|NEW                         |ASSIGNED
   Last reconfirmed|2005-08-11 12:22:54         |2005-09-07 18:58:29
               date|                            |


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


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

* [Bug rtl-optimization/23324] [4.1 Regression] unsigned bitfield in struct not accessed correctly at -O2 and above
  2005-08-11  8:08 [Bug c/23324] New: unsigned bitfield in struct not passed correctly as argument lindig at cs dot uni-sb dot de
                   ` (7 preceding siblings ...)
  2005-09-07 18:58 ` jakub at gcc dot gnu dot org
@ 2005-09-08 14:04 ` jakub at gcc dot gnu dot org
  2005-09-27 16:08 ` [Bug rtl-optimization/23324] [4.0/4.1 " mmitchel at gcc dot gnu dot org
  9 siblings, 0 replies; 11+ messages in thread
From: jakub at gcc dot gnu dot org @ 2005-09-08 14:04 UTC (permalink / raw)
  To: gcc-bugs


------- Additional Comments From jakub at gcc dot gnu dot org  2005-09-08 14:03 -------
This seems to be a serious problem introduced by PR middle-end/9997 fix,
at least if I understand it right.

The testcase I'm looking at is, on ppc64-linux -m32 -O2:
extern void abort (void);
#define A(x) if (!(x)) abort ()

static union at6 {} vv6 = {};
static struct et6
{
  struct bt6
  {
    signed av6:6;
    signed bv6:7;
    signed cv6:6;
    signed dv6:5;
    unsigned char ev6;
    unsigned int fv6;
    long int gv6;
  } mv6;
  unsigned long int nv6;
  signed ov6:12;
  signed pv6:3;
  signed qv6:2;
  signed rv6:10;
  union ct6 { long int hv6; float iv6; float jv6; } sv6;
  int *tv6;
  union dt6 { double kv6; float lv6; } uv6;
} wv6 = {
  { 8, 9, 2, 4, '\x10', 67426805U, 1047191860L },
  1366022414UL, 858, 1, 1, 305,
  { 1069379046L }, (int *) 358273621U,
  { 3318.041978 }
};
static double xv6 = 19239.101269;
static long long int yv6 = 1207859169L;
static int zv6 = 660195606;

static union at6
callee_af6 (struct et6 ap6, double bp6, long long int cp6, int dp6)
{
  A (wv6.mv6.av6 == ap6.mv6.av6);
  A (wv6.mv6.bv6 == ap6.mv6.bv6);
  A (wv6.mv6.cv6 == ap6.mv6.cv6);
  A (wv6.mv6.dv6 == ap6.mv6.dv6);
  A (wv6.mv6.ev6 == ap6.mv6.ev6);
  A (wv6.mv6.fv6 == ap6.mv6.fv6);
  A (wv6.mv6.gv6 == ap6.mv6.gv6);
  A (wv6.nv6 == ap6.nv6);
  A (wv6.ov6 == ap6.ov6);
  A (wv6.pv6 == ap6.pv6);
  A (wv6.qv6 == ap6.qv6);
  A (wv6.rv6 == ap6.rv6);
  A (wv6.sv6.hv6 == ap6.sv6.hv6);
  A (wv6.tv6 == ap6.tv6);
  A (wv6.uv6.kv6 == ap6.uv6.kv6);
  A (xv6 == bp6);
  A (yv6 == cp6);
  A (zv6 == dp6);
  return vv6;
}

static void
caller_bf6 (void)
{
  union at6 bav6;
  bav6 = callee_af6 (wv6, xv6, yv6, zv6);
}

static unsigned char uv7 = '\x46';
static float vv7 = 96636.982442;
static double wv7 = 28450.711801;
static union ct7 {} xv7 = {};
static struct et7
{
  struct dt7
  {
    float iv7;
    unsigned short int jv7;
  } kv7;
  float lv7[0];
  signed mv7:9;
  short int nv7;
  double ov7;
  float pv7;
} yv7 = {
  { 30135.996213, 42435 },
  {}, 170, 22116, 26479.628148, 4082.960685
};
static union ft7
{
  float qv7;
  float *rv7;
  unsigned int *sv7;
} zv7 = { 5042.227886 };
static int bav7 = 1345451862;
static struct gt7 { double tv7; } bbv7 = { 47875.491954 };
static long int bcv7[1] = { 1732133482L };
static long long int bdv7 = 381678602L;

static unsigned char
callee_af7 (float ap7, double bp7, union ct7 cp7, struct et7 dp7,
            union ft7 ep7, int fp7, struct gt7 gp7, long int hp7[1],
            long long int ip7)
{
  A (vv7 == ap7);
  A (wv7 == bp7);
  A (yv7.kv7.iv7 == dp7.kv7.iv7);
  A (yv7.kv7.jv7 == dp7.kv7.jv7);
  A (yv7.mv7 == dp7.mv7);
  A (yv7.nv7 == dp7.nv7);
  A (yv7.ov7 == dp7.ov7);
  A (yv7.pv7 == dp7.pv7);
  A (zv7.qv7 == ep7.qv7);
  A (bav7 == fp7);
  A (bbv7.tv7 == gp7.tv7);
  A (bcv7[0] == hp7[0]);
  A (bdv7 == ip7);
  return uv7;
}

static void
caller_bf7 (void)
{
  unsigned char bev7;

  bev7 = callee_af7 (vv7, wv7, xv7, yv7, zv7, bav7, bbv7, bcv7, bdv7);
  A (uv7 == bev7);
}

int
main ()
{
  caller_bf6 ();
  caller_bf7 ();
  return 0;
}

expand_used_vars is assigning stack slots just to 2 variables, ap6 and dp7.
ap6's alias set (5) has has_zero_child set to 1, as it contains an unsigned char
field (ap6.mv6.ev6), dp7's alias set (13) does not.
But one has_zero_child is enough for alias_sets_conflict_p (5, 13) == 1.
The problem is that add_alias_set_conflicts uses just !alias_sets_conflict_p
and not something stronger to find which variables can't overlap.
ap6 and dp7 MAY conflict (which is correct), but that is not enough to
guarantee the two variables can overlap (they IMHO can't).

When CSE uses later the alias info, it sees a read from ap6.mv6.gv6 field
(long int type, alias set 4) and write, part of initializing whole dp7,
using alias set 13 (dp7's alias set).  But there are no long int fields in
dp7, so alias_sets_conflict_p (4, 13) == 0 and thus CSE decides the write
couldn't possibly invalidate av6.mv6.gv6 value at that location.

Now the question is what add_alias_set_conflicts should check if both vars are
aggregates instead of alias_sets_conflict_p (or better yet in addition to, if
!alias_sets_conflict_p, we know the variables can't overlap quickly).
Certainly for all fields (recursively) of one aggregate it needs to ensure they
may conflict with the other aggregate's alias set and vice versa.
That will handle the case of a MEM reading/writing a field and another MEM
reading/writing the other variable as whole (well, at least using whole
variable's alias set).  Plus if there are fields which themselves are aggregates,
we would I think need to ensure that aggregate subfield may conflict with all
fields in the other variable that might overlap it (i.e. look at field offsets
etc.).



-- 
           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |rth at gcc dot gnu dot org
         AssignedTo|jakub at gcc dot gnu dot org|unassigned at gcc dot gnu
                   |                            |dot org
           Severity|normal                      |critical
             Status|ASSIGNED                    |NEW
   Target Milestone|4.1.0                       |4.0.2


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


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

* [Bug rtl-optimization/23324] [4.0/4.1 Regression] unsigned bitfield in struct not accessed correctly at -O2 and above
  2005-08-11  8:08 [Bug c/23324] New: unsigned bitfield in struct not passed correctly as argument lindig at cs dot uni-sb dot de
                   ` (8 preceding siblings ...)
  2005-09-08 14:04 ` jakub at gcc dot gnu dot org
@ 2005-09-27 16:08 ` mmitchel at gcc dot gnu dot org
  9 siblings, 0 replies; 11+ messages in thread
From: mmitchel at gcc dot gnu dot org @ 2005-09-27 16:08 UTC (permalink / raw)
  To: gcc-bugs



-- 
           What    |Removed                     |Added
----------------------------------------------------------------------------
   Target Milestone|4.0.2                       |4.0.3


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


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

end of thread, other threads:[~2005-09-27 16:08 UTC | newest]

Thread overview: 11+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2005-08-11  8:08 [Bug c/23324] New: unsigned bitfield in struct not passed correctly as argument lindig at cs dot uni-sb dot de
2005-08-11  8:11 ` [Bug c/23324] " lindig at cs dot uni-sb dot de
2005-08-11  8:15 ` lindig at cs dot uni-sb dot de
2005-08-11 12:13 ` [Bug rtl-optimization/23324] " pinskia at gcc dot gnu dot org
2005-08-11 12:23 ` [Bug rtl-optimization/23324] [4.1 Regression] " pinskia at gcc dot gnu dot org
2005-08-11 12:24 ` [Bug rtl-optimization/23324] [4.1 Regression] unsigned bitfield in struct not accessed correctly pinskia at gcc dot gnu dot org
2005-08-11 12:34 ` pinskia at gcc dot gnu dot org
2005-09-01  3:48 ` [Bug rtl-optimization/23324] [4.1 Regression] unsigned bitfield in struct not accessed correctly at -O2 and above amodra at bigpond dot net dot au
2005-09-07 18:58 ` jakub at gcc dot gnu dot org
2005-09-08 14:04 ` jakub at gcc dot gnu dot org
2005-09-27 16:08 ` [Bug rtl-optimization/23324] [4.0/4.1 " mmitchel 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).