[Bug tree-optimization/101001] New: wrong code at -O3 on x86_64-linux-gnu

2021-06-09 Thread qrzhang at gatech dot edu via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=101001

Bug ID: 101001
   Summary: wrong code at -O3 on x86_64-linux-gnu
   Product: gcc
   Version: unknown
Status: UNCONFIRMED
  Severity: normal
  Priority: P3
 Component: tree-optimization
  Assignee: unassigned at gcc dot gnu.org
  Reporter: qrzhang at gatech dot edu
  Target Milestone: ---

It affects gcc-8 to the trunk. Gcc-7 works fine.



$ gcc-trunk -v
gcc version 12.0.0 20210609 (experimental) [master revision
174e75a2107:3b61ba37fe1:5bfcfe3087eb05b76395c9efbfc1abbf3f9e1a03] (GCC)


$ gcc-trunk abc.c ; ./a.out
0


$ gcc-trunk -O3 abc.c ; ./a.out
Segmentation fault


$ cat abc.c
int a;
volatile char b;
int main() {
  char c;
  int d, f = 5;
  short e;
  e = 0;
  for (; e != -15; e--) {
d = 0;
for (; d > -16; d = d - 4) {
  f || b;
  c = 0;
  for (; c != 2; c = c - 3)
f = 0;
}
  }
  printf("%X\n", a);
}

[Bug tree-optimization/101025] New: wrong code at -O3 on x86_64-linux-gnu

2021-06-10 Thread qrzhang at gatech dot edu via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=101025

Bug ID: 101025
   Summary: wrong code at -O3 on x86_64-linux-gnu
   Product: gcc
   Version: unknown
Status: UNCONFIRMED
  Severity: normal
  Priority: P3
 Component: tree-optimization
  Assignee: unassigned at gcc dot gnu.org
  Reporter: qrzhang at gatech dot edu
  Target Milestone: ---

It appears to be a recent regression.

Bisection points to g:128f43cf679e51564202b41f23fae4146347f93d



$ gcc-trunk -v
Supported LTO compression algorithms: zlib
gcc version 12.0.0 20210610 (experimental) [master revision
5ad76ad7f5b:c64ab1c4fe0:cce1697e6fe0134616ebc8f7040d99e66c12241a] (GCC)


$ gcc-trunk abc.c ; ./a.out
0

$ gcc-trunk -O3 abc.c ; ./a.out
4

$ cat abc.c
int a[10];
int b, d, g;
volatile char c;
short e;
volatile int f;
int main() {
  for (; d <= 9; d++) {
b = e = 0;
for (; e < 10; e++)
  a[e] = 4;
for (; b <= 9; b++)
  if (g)
f = 0;
  else
a[b] = c;
  }
  printf("%d\n", a[1]);
}

[Bug tree-optimization/101031] New: wrong code at -O2 on x86_64-linux-gnu

2021-06-11 Thread qrzhang at gatech dot edu via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=101031

Bug ID: 101031
   Summary: wrong code at -O2 on x86_64-linux-gnu
   Product: gcc
   Version: unknown
Status: UNCONFIRMED
  Severity: normal
  Priority: P3
 Component: tree-optimization
  Assignee: unassigned at gcc dot gnu.org
  Reporter: qrzhang at gatech dot edu
  Target Milestone: ---

It appears to be a recent regression.


$ gcc-trunk -v
Supported LTO compression algorithms: zlib
gcc version 12.0.0 20210611 (experimental) [master revision
336c41dbcb2:00da4bcb67d:36943c6bdd3d3b535b24872bbd802d91ef0c6299] (GCC)


$ gcc-trunk abc.c ; ./a.out
0

$ gcc-trunk -O2 abc.c ; ./a.out
1


$ cat abc.c
int a;
char b, e;
static char *c = &b;
static long d;
void f(void);
void h() {
  int g = 0;
  for (; g < 2; ++g) {
d = *c;
*c = 1;
b = 0;
  }
  f();
}
void f() {
  if (d++)
c = &e;
  for (; a;)
;
}
int main() {
  h();
  printf("%d\n", b);
}

[Bug tree-optimization/101031] wrong code at -O2 on x86_64-linux-gnu

2021-06-11 Thread qrzhang at gatech dot edu via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=101031

Qirun Zhang  changed:

   What|Removed |Added

 CC||rguenther at suse dot de

--- Comment #1 from Qirun Zhang  ---
My bisection points to g:d1d01a66012a93cc8cb7dafbe1b5ec453e

[Bug tree-optimization/101025] [11 Regression] wrong code at -O3 on x86_64-linux-gnu

2021-06-11 Thread qrzhang at gatech dot edu via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=101025

--- Comment #8 from Qirun Zhang  ---
(In reply to Richard Biener from comment #7)
> Fixed on trunk sofar.  Keep more testcases coming ;)  (I have a hunch this
> code has more issues...)

Thanks, Richard. Will do.

[Bug tree-optimization/101105] New: wrong code at -O3 on x86_64-linux-gnu

2021-06-16 Thread qrzhang at gatech dot edu via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=101105

Bug ID: 101105
   Summary: wrong code at -O3 on x86_64-linux-gnu
   Product: gcc
   Version: unknown
Status: UNCONFIRMED
  Severity: normal
  Priority: P3
 Component: tree-optimization
  Assignee: unassigned at gcc dot gnu.org
  Reporter: qrzhang at gatech dot edu
  Target Milestone: ---

It appears to be a regression in 11.

$ gcc-trunk -v
Configured with: ../gcc/configure --prefix=/nethome/qzhang414/trunk/root-gcc
--enable-languages=c,c++ --disable-werror --enable-multilib
Thread model: posix
Supported LTO compression algorithms: zlib
gcc version 12.0.0 20210616 (experimental) [master revision
041f7417707:a530c589490:3155d51bfd1de8b6c4645dcb2292248a8d7cc3c9] (GCC)



$ gcc-trunk abc.c ; ./a.out
2

$ gcc-trunk -O3 abc.c ; ./a.out
Segmentation fault


$ cat abc.c
short a;
int b[5][4] = {2, 2};
long *c;
int d;
short(e)(f) { return f == 0 || a && f == 1 ? 0 : a; }
int main() {
  int g, h;
  g = 3;
  for (; g >= 0; g--) {
h = 3;
for (; h >= 0; h--)
  b[g][h] = b[0][1] && e(1);
  }
  d = b[0][1];
  if (d)
*c = 4073709551611;
  printf("%d\n", 2);
}

[Bug tree-optimization/101105] wrong code at -O3 on x86_64-linux-gnu

2021-06-16 Thread qrzhang at gatech dot edu via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=101105

--- Comment #1 from Qirun Zhang  ---
My bisection points to g:f75211822f8d84bb706421

[Bug tree-optimization/101173] New: wrong code at -O3 on x86_64-linux-gnu

2021-06-22 Thread qrzhang at gatech dot edu via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=101173

Bug ID: 101173
   Summary: wrong code at -O3 on x86_64-linux-gnu
   Product: gcc
   Version: unknown
Status: UNCONFIRMED
  Severity: normal
  Priority: P3
 Component: tree-optimization
  Assignee: unassigned at gcc dot gnu.org
  Reporter: qrzhang at gatech dot edu
  Target Milestone: ---

It affects gcc-8 to the trunk. Gcc-7.5.0 works.

$ gcc-trunk -v
Supported LTO compression algorithms: zlib
gcc version 12.0.0 20210622 (experimental) [master revision
f0e40ea0640:393ac5ed7d8:7822285515cd4dab86f722a9f4969b6952904a37] (GCC)



$ gcc-trunk abc.c ; ./a.out > 1.txt
$ gcc-trunk -O3 abc.c ; ./a.out > 2.txt

$ diff 1.txt 2.txt
11c11
< 0
---
> 8

$ cat abc.c
int a[6][9];
char b, c;
short d;
int e, f;
int main() {
  a[1][3] = 8;
  b = 1;
  for (; b <= 5; b++) {
d = 0;
for (; d <= 5; d++) {
  c = 0;
  for (; c <= 5; c++)
a[b][c] = a[b][c + 2] & 216;
}
  }
  for (; e < 6; e++) {
f = 0;
for (; f < 9; f++)
  printf("%d\n", a[e][f]);
  }
}

[Bug tree-optimization/101173] wrong code at -O3 on x86_64-linux-gnu

2021-06-22 Thread qrzhang at gatech dot edu via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=101173

--- Comment #1 from Qirun Zhang  ---
My bisection points to g:fbdec14e80e9399cd301ed3

[Bug sanitizer/108845] New: Unnecessary signed integer overflow checks

2023-02-18 Thread qrzhang at gatech dot edu via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=108845

Bug ID: 108845
   Summary: Unnecessary signed integer overflow checks
   Product: gcc
   Version: unknown
Status: UNCONFIRMED
  Severity: normal
  Priority: P3
 Component: sanitizer
  Assignee: unassigned at gcc dot gnu.org
  Reporter: qrzhang at gatech dot edu
CC: dodji at gcc dot gnu.org, dvyukov at gcc dot gnu.org,
jakub at gcc dot gnu.org, kcc at gcc dot gnu.org, marxin at 
gcc dot gnu.org
  Target Milestone: ---

When compiled with "gcc -fsanitize=signed-integer-overflow -O3" (reproducible
on the latest trunk version), Gcc will produce ".UBSAN_CHECK_SUB" checks for
the following code.

===
void printf();
void main() {
  int a;
  for (a = 0; a != -3; a--)
printf("%d\n", a);
}



I noticed that clang could indeed optimize this program to three printf() calls
with "-fsanitize=signed-integer-overflow -O3". Therefore, no overflow checks
are needed.

Is this behavior in GCC expected? Thanks!

[Bug sanitizer/108845] Unnecessary signed integer overflow checks

2023-02-18 Thread qrzhang at gatech dot edu via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=108845

--- Comment #3 from Qirun Zhang  ---
(In reply to Jakub Jelinek from comment #2)
> I'm not convinced it is a good idea.
> Sure, in the above case it is obvious it will never trigger, but if we say
> use ranger to decide if the operation can or can't overflow, then VRP is in
> many cases based on assumptions which only hold for valid code, but
> sanitizers actually want to diagnose invalid code.


Thanks!

Here is another (similar) example.  Earlier versions of GCC will not inject
UBSAN_CHECK_ADD. However, the latest version of GCC will.

the code example:
==
void main() {
  int a = 0;
  for (; a != 2; a++)
;
}
==

Compile with "gcc-11 -fsanitize=signed-integer-overflow -O3 
-fdump-tree-optimized", we got no UBSAN checks:

==
void main ()
{
  int a;

   [local count: 118111600]:

   [local count: 955630225]:
  # a_6 = PHI <1(3), 0(2)>
  a_3 = a_6 + 1;
  if (a_3 != 2)
goto ; [87.64%]
  else
goto ; [12.36%]

   [local count: 118111600]:
  return;

}
==

Compile with "gcc-trunk -fsanitize=signed-integer-overflow -O3 
-fdump-tree-optimized", we got one:

==
void main ()
{
  int a;

   [local count: 118111600]:

   [local count: 955630225]:
  # a_5 = PHI 
  a_3 = .UBSAN_CHECK_ADD (a_5, 1);
  if (a_3 != 2)
goto ; [89.00%]
  else
goto ; [11.00%]

   [local count: 118111600]:
  return;

}
==

$ gcc-trunk -v
gcc version 13.0.1 20230218 (experimental) [master r13-6132-g32b5875c911] (GCC)

[Bug sanitizer/108845] Unnecessary signed integer overflow checks

2023-02-18 Thread qrzhang at gatech dot edu via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=108845

--- Comment #4 from Qirun Zhang  ---
(In reply to Qirun Zhang from comment #3)
> (In reply to Jakub Jelinek from comment #2)
> > I'm not convinced it is a good idea.
> > Sure, in the above case it is obvious it will never trigger, but if we say
> > use ranger to decide if the operation can or can't overflow, then VRP is in
> > many cases based on assumptions which only hold for valid code, but
> > sanitizers actually want to diagnose invalid code.
> 
> 
> Thanks!
> 
> Here is another (similar) example.  Earlier versions of GCC will not inject
> UBSAN_CHECK_ADD. However, the latest version of GCC will.
> 
> the code example:
> ==
> void main() {
>   int a = 0;
>   for (; a != 2; a++)
> ;
> }
> ==
> 
> Compile with "gcc-11 -fsanitize=signed-integer-overflow -O3 
> -fdump-tree-optimized", we got no UBSAN checks:
> 
> ==
> void main ()
> {
>   int a;
> 
>[local count: 118111600]:
> 
>[local count: 955630225]:
>   # a_6 = PHI <1(3), 0(2)>
>   a_3 = a_6 + 1;
>   if (a_3 != 2)
> goto ; [87.64%]
>   else
> goto ; [12.36%]
> 
>[local count: 118111600]:
>   return;
> 
> }
> ==
> 
> Compile with "gcc-trunk -fsanitize=signed-integer-overflow -O3 
> -fdump-tree-optimized", we got one:
> 
> ==
> void main ()
> {
>   int a;
> 
>[local count: 118111600]:
> 
>[local count: 955630225]:
>   # a_5 = PHI 
>   a_3 = .UBSAN_CHECK_ADD (a_5, 1);
>   if (a_3 != 2)
> goto ; [89.00%]
>   else
> goto ; [11.00%]
> 
>[local count: 118111600]:
>   return;
> 
> }
> ==
> 
> $ gcc-trunk -v
> gcc version 13.0.1 20230218 (experimental) [master r13-6132-g32b5875c911]
> (GCC)

I did a bisect. For the testcase provided in comment #3, the behavior was
introduced in the following commit:


commit 502ffb1f389011b28ee51815242c7397790802d5
Author: Andrew MacLeod 
Date:   Tue Nov 2 21:26:44 2021 -0400

Switch vrp2 to ranger.

This patch flips the default for the VRP2 pass to execute ranger vrp rather
than the assert_expr version of VRP.

* params.opt (param_vrp2_mode): Make ranger the default for VRP2.

[Bug sanitizer/108880] New: slow compilation with "-fsanitize=undefined"

2023-02-21 Thread qrzhang at gatech dot edu via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=108880

Bug ID: 108880
   Summary: slow compilation with "-fsanitize=undefined"
   Product: gcc
   Version: unknown
Status: UNCONFIRMED
  Severity: normal
  Priority: P3
 Component: sanitizer
  Assignee: unassigned at gcc dot gnu.org
  Reporter: qrzhang at gatech dot edu
CC: dodji at gcc dot gnu.org, dvyukov at gcc dot gnu.org,
jakub at gcc dot gnu.org, kcc at gcc dot gnu.org, marxin at 
gcc dot gnu.org
  Target Milestone: ---

gcc-10 works fine.

$ time gcc-10 -fsanitize=undefined  abc.c

real0m0.081s


$ time gcc-11 -fsanitize=undefined  abc.c

real0m7.045s

$ time gcc-trunk -fsanitize=undefined  abc.c

real0m10.346s

$ gcc-trunk -v
gcc version 13.0.1 20230218 (experimental) [master r13-6132-g32b5875c911] (GCC)


$ cat abc.c
long a;
short b, e;
char c;
int d, f, g;
void h() {
  int i;
  f &= i ^= (((g &= 0 / d / d % 8 << 0 << 2) % a >> e) / c >> b) / 1 % 8 << 3;
}
void main() {}

[Bug sanitizer/108995] New: Missed signed integer overflow checks in UBsan?

2023-03-02 Thread qrzhang at gatech dot edu via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=108995

Bug ID: 108995
   Summary: Missed signed integer overflow checks in UBsan?
   Product: gcc
   Version: unknown
Status: UNCONFIRMED
  Severity: normal
  Priority: P3
 Component: sanitizer
  Assignee: unassigned at gcc dot gnu.org
  Reporter: qrzhang at gatech dot edu
CC: dodji at gcc dot gnu.org, dvyukov at gcc dot gnu.org,
jakub at gcc dot gnu.org, kcc at gcc dot gnu.org, marxin at 
gcc dot gnu.org
  Target Milestone: ---

$ cat abc.c
int printf(const char *, ...);
int a;
const int b = 44514;
int *c = &a;
void main(void) {
  *c = 65526 * b / 6;
  printf("%d\n", a);
}

Ubsan did not emit any message. However, the outputs are different.

$ gcc-trunk -O3 -fsanitize=undefined abc.c ; ./a.out
-229690488

$ gcc-trunk  -fsanitize=undefined abc.c ; ./a.out
486137394

[Bug tree-optimization/102149] New: wrong code at -O3 on x86_64-linux-gnu

2021-08-31 Thread qrzhang at gatech dot edu via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=102149

Bug ID: 102149
   Summary: wrong code at -O3 on x86_64-linux-gnu
   Product: gcc
   Version: unknown
Status: UNCONFIRMED
  Severity: normal
  Priority: P3
 Component: tree-optimization
  Assignee: unassigned at gcc dot gnu.org
  Reporter: qrzhang at gatech dot edu
  Target Milestone: ---

Seems to be a recent regression.


$ gcc-trunk -v
gcc version 12.0.0 20210831 (experimental) [master revision
5e57bacf6f3:a82c79a304b:de7a795c321e76826d123c92b99e73e144666b60] (GCC)


$ gcc-trunk abc.c ; ./a.out
1

$ gcc-trunk abc.c ; ./a.out
0

$ cat abc.c
int a[8];
int *b = &a[6];
char c;
int main() {
  int d = 7;
  for (; d >= 0; d--) {
*b = 1;
c = a[d] >> 3;
a[d] = c;
  }
  printf("%d\n", a[6]);
}

[Bug tree-optimization/102149] wrong code at -O3 on x86_64-linux-gnu

2021-08-31 Thread qrzhang at gatech dot edu via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=102149

--- Comment #1 from Qirun Zhang  ---
My bisection points to g:89f33f44addbf9853bc3e6677d

[Bug tree-optimization/101445] New: wrong code at -O3 on x86_64-linux-gnu

2021-07-13 Thread qrzhang at gatech dot edu via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=101445

Bug ID: 101445
   Summary: wrong code at -O3 on x86_64-linux-gnu
   Product: gcc
   Version: unknown
Status: UNCONFIRMED
  Severity: normal
  Priority: P3
 Component: tree-optimization
  Assignee: unassigned at gcc dot gnu.org
  Reporter: qrzhang at gatech dot edu
  Target Milestone: ---

It appears to be a recent regression. Note that -O2 works fine.

$ gcc-trunk -v
Supported LTO compression algorithms: zlib
gcc version 12.0.0 20210713 (experimental) [master revision
7670b6633e5:d2f95d2ac56:1583b8bff0be7e41aa721dde79f90ca0763bd4e2] (GCC)


$ gcc-trunk abc.c ; ./a.out
0
0
0
0
0
0
0



$ gcc-trunk -O3 abc.c ; ./a.out
0
0
3
0
0
0
0



$ cat abc.c
int a[35] = {1, 1, 3};
char b = 4;
int c, d;
int main() {
  char e;
  for (; b >= 0; b--) {
e = 3;
for (; e >= 0; e--)
  a[b * 5 + e] = a[b * 5 + e + 1];
  }
  for (; c < 5; c++)
;
  for (; d < 7; d++)
printf("%d\n", a[c * d]);
}

[Bug tree-optimization/101445] wrong code at -O3 on x86_64-linux-gnu

2021-07-13 Thread qrzhang at gatech dot edu via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=101445

--- Comment #1 from Qirun Zhang  ---
My bisection points to g:f75211822f8d84bb706421d3692e

[Bug tree-optimization/101501] New: wrong code at -O3 on x86_64-linux-gnu

2021-07-18 Thread qrzhang at gatech dot edu via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=101501

Bug ID: 101501
   Summary: wrong code at -O3 on x86_64-linux-gnu
   Product: gcc
   Version: unknown
Status: UNCONFIRMED
  Severity: normal
  Priority: P3
 Component: tree-optimization
  Assignee: unassigned at gcc dot gnu.org
  Reporter: qrzhang at gatech dot edu
  Target Milestone: ---

It appears to be a recent regression. Gcc-10 works fine.

$ gcc-trunk -v
gcc version 12.0.0 20210718 (experimental) [master revision
0103d18dfc9:a1cef02c5e3:853921378bfa149353b4e1c7dde5c02f80072ad7] (GCC)


$ gcc-trunk abc.c ; ./a.out
-1

$ gcc-trunk -O3 abc.c ; ./a.out
40


$ cat abc.c
char a = 55;
int main() {
  int b;
  char c;
d:
  c = a-- * 52;
  b = 3L * c;
  if (b)
goto d;
  printf("%d\n", a);
}

[Bug tree-optimization/101501] wrong code at -O3 on x86_64-linux-gnu

2021-07-18 Thread qrzhang at gatech dot edu via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=101501

--- Comment #1 from Qirun Zhang  ---
My bisection points to g:287522613d661b4c5ba8403b051eb470c1674cba

[Bug tree-optimization/101615] New: wrong code at -O3 on x86_64-linux-gnu

2021-07-24 Thread qrzhang at gatech dot edu via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=101615

Bug ID: 101615
   Summary: wrong code at -O3 on x86_64-linux-gnu
   Product: gcc
   Version: unknown
Status: UNCONFIRMED
  Severity: normal
  Priority: P3
 Component: tree-optimization
  Assignee: unassigned at gcc dot gnu.org
  Reporter: qrzhang at gatech dot edu
  Target Milestone: ---

It appears to be a recent regression.

$ gcc-trunk -v
Supported LTO compression algorithms: zlib
gcc version 12.0.0 20210724 (experimental) [master revision
e314cfc371d:5eb84b79079:ead235f60139edc6eb408d8d083cbb15e417b447] (GCC)

$ gcc-trunk abc.c ; ./a.out
5
7
11
3
3
3



$ gcc-trunk -O3 abc.c ; ./a.out
5
7
3
3
3
11

$ cat abc.c
int a[50] = {5, 5, 8};
short b;
int c, d;
int main() {
  int e;
  for (; b <= 4; b++)
for (; c <= 4; c++) {
  *a |= 1;
  e = 0;
  for (; e <= 4; e++)
a[e + 1] |= 3;
}
  for (; d < 6; d++)
printf("%d\n", a[d]);
}

[Bug tree-optimization/101615] wrong code at -O3 on x86_64-linux-gnu

2021-07-24 Thread qrzhang at gatech dot edu via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=101615

--- Comment #1 from Qirun Zhang  ---
My bisection points to g:6df6055d5c666e669890ff8

[Bug tree-optimization/101885] New: wrong code at -O3 on x86_64-linux-gnu

2021-08-12 Thread qrzhang at gatech dot edu via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=101885

Bug ID: 101885
   Summary: wrong code at -O3 on x86_64-linux-gnu
   Product: gcc
   Version: unknown
Status: UNCONFIRMED
  Severity: normal
  Priority: P3
 Component: tree-optimization
  Assignee: unassigned at gcc dot gnu.org
  Reporter: qrzhang at gatech dot edu
  Target Milestone: ---

It appears a regression in gcc-10. gcc-9 works fine.


$ gcc-trunk -v
gcc version 12.0.0 20210812 (experimental) [master revision
01f8a8b48e5:0eb7800d242:04b4f3152593f85b05974528d1607619dd77d702] (GCC)


$ gcc-trunk abc.c ; ./a.out
0

$ gcc-trunk -O3 abc.c ; ./a.out
3


$ cat abc.c
int a = 3, c;
short b = 5, d, f;
volatile short e;
int main() {
  f = 29;
  for (; f != 33; f++) {
int g = a;
if (b)
  if (a) {
a = b = 0;
for (; b <= 8; b++)
  ;
  }
e;
e;
c = 0;
for (; c != 14; ++c)
  e;
  }
  b = d;
  printf("", 8);
  printf("%d\n", a);
}

[Bug tree-optimization/101885] wrong code at -O3 on x86_64-linux-gnu

2021-08-12 Thread qrzhang at gatech dot edu via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=101885

--- Comment #1 from Qirun Zhang  ---
My bisection points to g:529ea7d9596b26ba103578eeab448e9862a2d2c5

[Bug tree-optimization/101972] New: wrong code at -O2 on x86_64-linux-gnu

2021-08-18 Thread qrzhang at gatech dot edu via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=101972

Bug ID: 101972
   Summary: wrong code at -O2 on x86_64-linux-gnu
   Product: gcc
   Version: unknown
Status: UNCONFIRMED
  Severity: normal
  Priority: P3
 Component: tree-optimization
  Assignee: unassigned at gcc dot gnu.org
  Reporter: qrzhang at gatech dot edu
  Target Milestone: ---

It appears to be a regression in gcc-9. gcc-8 works fine.


$ gcc-trunk -O2 abc.c ; ./a.out
0

$ gcc-trunk abc.c ; ./a.out
30

$ gcc-8 -O2 abc.c ; ./a.out
30

$ cat abc.c
int a, b, c, d, f;
static short e = 63891;
char g = 30;
unsigned h(i, j) { return i << j; }
int *l(int *);
void m() {
  a = 0;
  for (; a >= 0; a--) {
int *k = &b;
*k = e < 0;
  }
  c = b;
  l(&c);
}
int *l(int *i) {
  d = 2;
  for (; d <= 6; d++) {
if (h(d, *i) <= d)
  ;
else
  continue;
g = 0;
return &f;
  }
}
int main() {
  m();
  printf("%d\n", g);
}

[Bug tree-optimization/101972] wrong code at -O2 on x86_64-linux-gnu

2021-08-18 Thread qrzhang at gatech dot edu via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=101972

--- Comment #1 from Qirun Zhang  ---
My bisection points to g:a81e2c6240655f60a49c16e0d8bbfd2ba40bba51