This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
[Bug tree-optimization/57719] [4.8/4.9 Regression] wrong code at -O3 on x86_64-linux-gnu
- From: "su at cs dot ucdavis.edu" <gcc-bugzilla at gcc dot gnu dot org>
- To: gcc-bugs at gcc dot gnu dot org
- Date: Thu, 27 Jun 2013 20:48:15 +0000
- Subject: [Bug tree-optimization/57719] [4.8/4.9 Regression] wrong code at -O3 on x86_64-linux-gnu
- Auto-submitted: auto-generated
- References: <bug-57719-4 at http dot gcc dot gnu dot org/bugzilla/>
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=57719
--- Comment #2 from Zhendong Su <su at cs dot ucdavis.edu> ---
Hi Jakub, below are three additional (possibly related) testcases that may help
you folks diagnose the issue; they (including the original testcase) all
manifest differently:
---------------------
test #2: wrong code from both gcc trunk and 4.8 at -O3 in 32-bit mode only:
int printf (const char *, ...);
int c, e[2], f, g, *l;
long long h;
int foo ()
{
int s[1];
int i = 0;
for (; i < 1; i++)
s[0] = 0;
h = 0;
for (; h; h = 1) {
int *dp[1] = {&s[0]};
*dp[0] = 0;
}
g = 0;
return 0;
}
void bar ()
{
for (; c < 2; c++) {
int *ip = &f;
*ip = 0;
*ip = 0 < foo ();
l = &e[c];
*ip = 1;
*l = 0;
}
}
int main ()
{
bar ();
printf ("%d\n", f);
return 0;
}
---------------------
test #3: wrong code from gcc trunk (but not gcc 4.8) at -O3 in 32-bit mode
only:
int printf (const char *, ...);
int f1;
int a, b, c;
volatile int d;
int e[2], f, g;
long long h;
int j, k, *l;
short fn1 (unsigned short ui1)
{
return ui1 - a;
}
int fn4 (int p)
{
int s[1];
int *tp = &f;
int *cp = &g;
int i = 0;
for (; i < 1; i++)
s[0] = 0;
h = 0;
for (; h; h = 1) {
int *dp[1] = {&s[0]};
*dp[0] = 0;
}
*cp = p % (1 ^ *tp);
return 0;
}
void
fn5 ()
{
unsigned short t = 0;
for (; c < 2; c++) {
int *ip = &f1;
b = 0;
j = 0;
d ^ (*ip = 0);
t = fn1 (k);
*ip = e[0] < fn4 (t);
l = &e[c];
*ip = 1;
*l = 0;
}
}
int
main ()
{
fn5 ();
printf ("%d\n", f1);
return 0;
}
---------------------
test #4: wrong code from gcc trunk (but not gcc 4.8) at -O3 in both 32-bit and
64-bit modes:
int printf (const char *, ...);
int a;
int b;
int c;
volatile int d;
int e;
int f[2];
int g;
int h;
int j;
int *k = &f[0];
int l;
short
fn1 (unsigned short p)
{
return p * a;
}
int
fn2 (int p)
{
int m[1];
int i = 0;
for (; i < 1; i++)
m[0] = 0;
g = 0;
for (; g; g = 1) {
int *n[1] = {&m[0]};
}
l = p % (1 ^ *k);
return 0;
}
int
main ()
{
unsigned short o = 0;
int *p;
for (; c < 2; c++) {
int *q = &e;
b = 0;
h = 0;
d ^ (*q = 0);
o = fn1 (j);
*q = f[0] < fn2 (o);
p = &f[c];
*q = 1;
fn2 (0);
*p = 0;
}
printf ("%d\n", e);
return 0;
}