[Bug target/49071] New: Wrong code with -fschedule-insns (x86-64)
arthur.j.odwyer at gmail dot com
gcc-bugzilla@gcc.gnu.org
Thu May 19 19:27:00 GMT 2011
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=49071
Summary: Wrong code with -fschedule-insns (x86-64)
Product: gcc
Version: 4.7.0
Status: UNCONFIRMED
Severity: normal
Priority: P3
Component: target
AssignedTo: unassigned@gcc.gnu.org
ReportedBy: arthur.j.odwyer@gmail.com
Created attachment 24295
--> http://gcc.gnu.org/bugzilla/attachment.cgi?id=24295
Output of "gcc -O1 -fschedule-insns test.c -v" with GCC 4.4.5
This bug reproduces all the way back to at least 4.4.5, and also reproduces
with trunk revision 173843 (2011-05-17). I'm on Ubuntu 10.10, x86-64.
cat >test.c <<EOF
#include <stdio.h>
#pragma pack(1)
struct S0 {
int f0;
int f1;
unsigned f3 : 6;
int f4;
int f5;
unsigned f6 : 23;
unsigned f8 : 10;
};
static struct S0 g_12 = {0};
static struct S0 g_361 = {0,0,0,0,0,0,55};
static unsigned char g_547 = 1;
static int func_66() {
g_12.f8 |= 1;
return g_12.f6;
}
static struct S0 func_1(void) {
int p;
for (p = 2; p >= 0; --p)
g_547 = 2;
g_361.f8 &= func_66();
return (struct S0){0};
}
int main() {
func_1();
printf("", (unsigned)g_361.f6);
printf("%x\n", (unsigned)g_547);
return 0;
}
EOF
gcc -O1 test.c ; ./a.out // correctly prints "2"
gcc -O2 test.c ; ./a.out // incorrectly prints "1"
You can replace "-O2" with "-O1 -fschedule-insns" and see the same wrong code
generated.
This test case is reduced from the output of Csmith 2.1.0 (git hash 01aa8b04,
https://github.com/Quuxplusone/csmith/), using the following command line:
csmith --paranoid --longlong --no-pointers --arrays --no-jumps --no-consts
--no-volatiles --checksum --divs --no-muls --bitfields --packed-struct -s
591872179
More information about the Gcc-bugs
mailing list