This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
[Bug c/44806] New: 4.5.0 i686 code generation regression with -O2
- From: "jim at meyering dot net" <gcc-bugzilla at gcc dot gnu dot org>
- To: gcc-bugs at gcc dot gnu dot org
- Date: 3 Jul 2010 16:35:13 -0000
- Subject: [Bug c/44806] New: 4.5.0 i686 code generation regression with -O2
- Reply-to: gcc-bugzilla at gcc dot gnu dot org
This bug manifests on i686, and not on x86_64.
[FYI, pared down from a proposed patch for coreutils' du.c. ]
The following code, compiled with 4.5.0 and -O2 exits with status 1.
Compile with 4.4.4 and any optimization or 4.5.0 with -O1 and it exits with
status 0.
$ cat k.c
#include <stdint.h>
#define N_DEV_BITS_4 5
#define N_INO_BITS_4 (32 - N_DEV_BITS_4 - 2 - 1)
#define N_DEV_BITS_8 8
#define N_INO_BITS_8 (64 - N_DEV_BITS_8 - 2 - 1)
struct dev_ino_4
{
uint32_t mode:2;
uint32_t short_ino:N_INO_BITS_4;
uint32_t mapped_dev:N_DEV_BITS_4;
uint32_t always_set:1;
};
struct dev_ino_8
{
uint32_t mode:2;
uint64_t short_ino:N_INO_BITS_8;
uint32_t mapped_dev:N_DEV_BITS_8;
uint32_t always_set:1;
};
struct dev_ino_full
{
uint32_t mode:2;
uint32_t dev;
uint32_t ino;
};
enum di_mode
{
DI_MODE_4 = 1,
DI_MODE_8 = 2,
DI_MODE_FULL = 3
};
struct di_ent
{
union
{
struct dev_ino_4 di4;
struct dev_ino_8 di8;
struct dev_ino_full full;
uint32_t u32;
uint64_t u64;
void *ptr;
} u;
};
static struct di_ent
decode_ptr (struct di_ent const *v)
{
struct di_ent di;
di.u.ptr = (void *) v;
return di;
}
static int
di_ent_equal (void const *x, void const *y)
{
struct di_ent a = decode_ptr (x);
struct di_ent b = decode_ptr (y);
if (a.u.di4.mode != b.u.di4.mode)
return 0;
if (a.u.di4.mode == DI_MODE_4)
return (a.u.di4.short_ino == b.u.di4.short_ino
&& a.u.di4.mapped_dev == b.u.di4.mapped_dev);
if (a.u.di8.mode == DI_MODE_8)
return (a.u.di8.short_ino == b.u.di8.short_ino
&& a.u.di8.mapped_dev == b.u.di8.mapped_dev);
return (a.u.full.ino == b.u.full.ino
&& a.u.full.dev == b.u.full.dev);
}
int
main ()
{
return di_ent_equal ((void *) 0x80143c4d, (void *) 0x80173851);
}
$ /p/p/gcc-4.5.0/bin/gcc -Wall -O2 k.c && ./a.out
[Exit 1]
$ /p/p/gcc-4.5.0/bin/gcc -Wall -O1 k.c && ./a.out; echo $?
0
$ gcc -v 2>&1|tail -1
gcc version 4.4.4 20100503 (Red Hat 4.4.4-2) (GCC)
$ gcc -Wall -O2 k.c && ./a.out; echo $?
0
configured with: ../configure --disable-nls --enable-languages=c
--prefix=/p/p/gcc-4.5.0
--
Summary: 4.5.0 i686 code generation regression with -O2
Product: gcc
Version: 4.5.0
Status: UNCONFIRMED
Severity: normal
Priority: P3
Component: c
AssignedTo: unassigned at gcc dot gnu dot org
ReportedBy: jim at meyering dot net
GCC build triplet: i686-pc-linux-gnu
GCC host triplet: i686-pc-linux-gnu
GCC target triplet: i686-pc-linux-gnu
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=44806