* [Bug c/107257] Wrong code at -O2 on x86_64-linux-gnu
2022-10-14 8:32 [Bug c/107257] New: Wrong code at -O2 on x86_64-linux-gnu shaohua.li at inf dot ethz.ch
@ 2022-10-14 9:27 ` rguenth at gcc dot gnu.org
2022-10-14 10:00 ` marxin at gcc dot gnu.org
` (8 subsequent siblings)
9 siblings, 0 replies; 11+ messages in thread
From: rguenth at gcc dot gnu.org @ 2022-10-14 9:27 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=107257
Richard Biener <rguenth at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
Status|UNCONFIRMED |NEW
Known to fail| |10.4.0
Last reconfirmed| |2022-10-14
Keywords| |needs-bisection
Ever confirmed|0 |1
^ permalink raw reply [flat|nested] 11+ messages in thread
* [Bug c/107257] Wrong code at -O2 on x86_64-linux-gnu
2022-10-14 8:32 [Bug c/107257] New: Wrong code at -O2 on x86_64-linux-gnu shaohua.li at inf dot ethz.ch
2022-10-14 9:27 ` [Bug c/107257] " rguenth at gcc dot gnu.org
@ 2022-10-14 10:00 ` marxin at gcc dot gnu.org
2022-10-14 10:03 ` marxin at gcc dot gnu.org
` (7 subsequent siblings)
9 siblings, 0 replies; 11+ messages in thread
From: marxin at gcc dot gnu.org @ 2022-10-14 10:00 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=107257
Martin Liška <marxin at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
CC| |marxin at gcc dot gnu.org
--- Comment #1 from Martin Liška <marxin at gcc dot gnu.org> ---
A few notes about reduction: please don't over-reduce the testcase (by removing
of the variable and function types). Moreover, if possible, please use C-Vise
that does not rename identifiers by default.
Anyway, thanks for the test-case!
^ permalink raw reply [flat|nested] 11+ messages in thread
* [Bug c/107257] Wrong code at -O2 on x86_64-linux-gnu
2022-10-14 8:32 [Bug c/107257] New: Wrong code at -O2 on x86_64-linux-gnu shaohua.li at inf dot ethz.ch
2022-10-14 9:27 ` [Bug c/107257] " rguenth at gcc dot gnu.org
2022-10-14 10:00 ` marxin at gcc dot gnu.org
@ 2022-10-14 10:03 ` marxin at gcc dot gnu.org
2022-10-14 12:52 ` rguenth at gcc dot gnu.org
` (6 subsequent siblings)
9 siblings, 0 replies; 11+ messages in thread
From: marxin at gcc dot gnu.org @ 2022-10-14 10:03 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=107257
Martin Liška <marxin at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
Status|NEW |WAITING
--- Comment #2 from Martin Liška <marxin at gcc dot gnu.org> ---
...
> static signed char n();
> s() { n(); }
This seems fishy as you are calling 'n' w/o an argument.
> signed char n(u) {
> for (; u <= 2; u++) {
...
^ permalink raw reply [flat|nested] 11+ messages in thread
* [Bug c/107257] Wrong code at -O2 on x86_64-linux-gnu
2022-10-14 8:32 [Bug c/107257] New: Wrong code at -O2 on x86_64-linux-gnu shaohua.li at inf dot ethz.ch
` (2 preceding siblings ...)
2022-10-14 10:03 ` marxin at gcc dot gnu.org
@ 2022-10-14 12:52 ` rguenth at gcc dot gnu.org
2022-10-17 10:27 ` shaohua.li at inf dot ethz.ch
` (5 subsequent siblings)
9 siblings, 0 replies; 11+ messages in thread
From: rguenth at gcc dot gnu.org @ 2022-10-14 12:52 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=107257
Richard Biener <rguenth at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
Resolution|--- |INVALID
Status|WAITING |RESOLVED
--- Comment #3 from Richard Biener <rguenth at gcc dot gnu.org> ---
Indeed, the bogus expectation is eventually that s(2) gets the argument
register set up for the call to n(), but obviously that's misguided.
^ permalink raw reply [flat|nested] 11+ messages in thread
* [Bug c/107257] Wrong code at -O2 on x86_64-linux-gnu
2022-10-14 8:32 [Bug c/107257] New: Wrong code at -O2 on x86_64-linux-gnu shaohua.li at inf dot ethz.ch
` (3 preceding siblings ...)
2022-10-14 12:52 ` rguenth at gcc dot gnu.org
@ 2022-10-17 10:27 ` shaohua.li at inf dot ethz.ch
2022-10-17 11:05 ` [Bug target/107257] [13 Regression] Wrong code at -O2 on x86_64-linux-gnu since r13-857-gf1652e3343b1ec47 marxin at gcc dot gnu.org
` (4 subsequent siblings)
9 siblings, 0 replies; 11+ messages in thread
From: shaohua.li at inf dot ethz.ch @ 2022-10-17 10:27 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=107257
Li Shaohua <shaohua.li at inf dot ethz.ch> changed:
What |Removed |Added
----------------------------------------------------------------------------
Resolution|INVALID |---
Status|RESOLVED |NEW
--- Comment #4 from Li Shaohua <shaohua.li at inf dot ethz.ch> ---
Hi,
Sorry for my previous over-reduced test case. Here is a well-formed reduction:
```
void printf();
int a, b, c;
int d[3];
int e(int f, int g, int k, int l, int m, int n) {
int h = 4 * f + 2 * (g + l + n) + k + m, j = h >> 4;
return j;
}
void o(int f) {
int i = 0;
for (; i < 3; i++)
d[i] = 4279432140;
for (; - 72 + f - -72 <= 2; f++) {
a = 2;
for (; a >= 0; a--) {
b = 2;
for (; b >= 0; b--) {
int p = !(d[b] > 0 != e(10, 29, 42, 74, 89, -68) + f - 15);
if (p)
break;
}
if (f)
break;
}
}
}
void q() {
int i = 0;
o(0);
if (c)
for (; i < 1;)
for (; i < 1; i++)
;
}
int main() {
q();
printf("%d\n", b);
}
```
Compiler explorer: https://godbolt.org/z/bjjW5q17r
^ permalink raw reply [flat|nested] 11+ messages in thread
* [Bug target/107257] [13 Regression] Wrong code at -O2 on x86_64-linux-gnu since r13-857-gf1652e3343b1ec47
2022-10-14 8:32 [Bug c/107257] New: Wrong code at -O2 on x86_64-linux-gnu shaohua.li at inf dot ethz.ch
` (4 preceding siblings ...)
2022-10-17 10:27 ` shaohua.li at inf dot ethz.ch
@ 2022-10-17 11:05 ` marxin at gcc dot gnu.org
2022-10-17 11:09 ` rguenth at gcc dot gnu.org
` (3 subsequent siblings)
9 siblings, 0 replies; 11+ messages in thread
From: marxin at gcc dot gnu.org @ 2022-10-17 11:05 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=107257
Martin Liška <marxin at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
Keywords|needs-bisection |
Component|c |target
Host| |x86_64-linux-gnu
Summary|Wrong code at -O2 on |[13 Regression] Wrong code
|x86_64-linux-gnu |at -O2 on x86_64-linux-gnu
| |since
| |r13-857-gf1652e3343b1ec47
Target Milestone|--- |13.0
Priority|P3 |P1
CC| |sayle at gcc dot gnu.org
--- Comment #5 from Martin Liška <marxin at gcc dot gnu.org> ---
Thanks, a bit modified:
cat pr107257.c
int a, b, c;
int d[3];
int e(int f, int g, int k, int l, int m, int n) {
int h = 4 * f + 2 * (g + l + n) + k + m, j = h >> 4;
return j;
}
void o(int f) {
int i = 0;
for (; i < 3; i++)
d[i] = 4279432140;
for (; - 72 + f - -72 <= 2; f++) {
a = 2;
for (; a >= 0; a--) {
b = 2;
for (; b >= 0; b--) {
int p = !(d[b] > 0 != e(10, 29, 42, 74, 89, -68) + f - 15);
if (p)
break;
}
if (f)
break;
}
}
}
void q() {
int i = 0;
o(0);
if (c)
for (; i < 1;)
for (; i < 1; i++)
;
}
int main() {
q();
__builtin_printf("%d\n", b);
if (b != -1)
__builtin_abort ();
}
Started with r13-857-gf1652e3343b1ec47.
^ permalink raw reply [flat|nested] 11+ messages in thread
* [Bug target/107257] [13 Regression] Wrong code at -O2 on x86_64-linux-gnu since r13-857-gf1652e3343b1ec47
2022-10-14 8:32 [Bug c/107257] New: Wrong code at -O2 on x86_64-linux-gnu shaohua.li at inf dot ethz.ch
` (5 preceding siblings ...)
2022-10-17 11:05 ` [Bug target/107257] [13 Regression] Wrong code at -O2 on x86_64-linux-gnu since r13-857-gf1652e3343b1ec47 marxin at gcc dot gnu.org
@ 2022-10-17 11:09 ` rguenth at gcc dot gnu.org
2022-10-20 17:25 ` pinskia at gcc dot gnu.org
` (2 subsequent siblings)
9 siblings, 0 replies; 11+ messages in thread
From: rguenth at gcc dot gnu.org @ 2022-10-17 11:09 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=107257
--- Comment #6 from Richard Biener <rguenth at gcc dot gnu.org> ---
With -fno-tree-slp-vectorize the failure goes away. diff in optimized:
__attribute__((noipa, noinline, noclone, no_icf))
void q ()
{
- <bb 2> [local count: 1073742492]:
- MEM <unsigned long> [(int *)&d] = 18380021091030725580;
+ int b_lsm.15;
+ int f;
+ _Bool _5;
+
+ <bb 2> [local count: 1073741824]:
+ MEM <vector(2) int> [(int *)&d] = { -15535156, -15535156 };
d[2] = -15535156;
+
+ <bb 3> [local count: 8687551919]:
+ # f_30 = PHI <f_25(5), 0(2)>
+ if (f_30 == 0)
+ goto <bb 5>; [1.43%]
+ else
+ goto <bb 4>; [98.57%]
+
+ <bb 4> [local count: 4698759900]:
+ if (f_30 != 2)
+ goto <bb 5>; [79.66%]
+ else
+ goto <bb 6>; [20.34%]
+
+ <bb 5> [local count: 7731921808]:
+ # f_25 = PHI <2(4), 1(3)>
+ goto <bb 3>; [100.00%]
+
+ <bb 6> [local count: 1073742492]:
a = 2;
- b = -1;
+ _5 = f_30 == 0;
+ b_lsm.15_33 = _5 ? 2 : -1;
+ b = b_lsm.15_33;
return;
}
both variants look OK so instead RTL expansion looks fishy(?)
;; b = b_lsm.15_33;
(insn 28 26 29 (parallel [
(set (reg:CCC 17 flags)
(ne:CCC (reg/v:SI 83 [ f ])
(const_int 0 [0])))
(set (reg:SI 89)
(neg:SI (reg/v:SI 83 [ f ])))
]) -1
(nil))
(insn 29 28 30 (parallel [
(set (reg:SI 90)
(neg:SI (ltu:SI (reg:CCC 17 flags)
(const_int 0 [0]))))
(clobber (reg:CC 17 flags))
]) -1
(nil))
(insn 30 29 31 (parallel [
(set (reg:SI 90)
(ior:SI (reg:SI 90)
(const_int 2 [0x2])))
(clobber (reg:CC 17 flags))
]) -1
(nil))
(insn 31 30 32 (set (reg:SI 88 [ b_lsm.15 ])
(reg:SI 90)) -1
(nil))
(insn 32 31 0 (set (mem/c:SI (symbol_ref:DI ("b") [flags 0x2] <var_decl
0x7ffff6526d80 b>) [1 b+0 S4 A32])
(reg:SI 88 [ b_lsm.15 ])) -1
(nil))
and we eventually optimize this to
q:
.LFB2:
.cfi_startproc
movq .LC0(%rip), %rax
movl $-15535156, d+8(%rip)
movl $2, a(%rip)
movq %rax, d(%rip)
movl $2, b(%rip)
ret
^ permalink raw reply [flat|nested] 11+ messages in thread
* [Bug target/107257] [13 Regression] Wrong code at -O2 on x86_64-linux-gnu since r13-857-gf1652e3343b1ec47
2022-10-14 8:32 [Bug c/107257] New: Wrong code at -O2 on x86_64-linux-gnu shaohua.li at inf dot ethz.ch
` (6 preceding siblings ...)
2022-10-17 11:09 ` rguenth at gcc dot gnu.org
@ 2022-10-20 17:25 ` pinskia at gcc dot gnu.org
2023-07-27 8:01 ` shaohua.li at inf dot ethz.ch
2023-07-27 14:47 ` shaohua.li at inf dot ethz.ch
9 siblings, 0 replies; 11+ messages in thread
From: pinskia at gcc dot gnu.org @ 2022-10-20 17:25 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=107257
Andrew Pinski <pinskia at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
Status|NEW |RESOLVED
Resolution|--- |DUPLICATE
--- Comment #7 from Andrew Pinski <pinskia at gcc dot gnu.org> ---
(set (reg:CCC 17 flags)
(ne:CCC (reg/v:SI 83 [ f ])
(const_int 0 [0])))
Yes this is broken ...
Which means this is a dup of bug 107172.
*** This bug has been marked as a duplicate of bug 107172 ***
^ permalink raw reply [flat|nested] 11+ messages in thread
* [Bug target/107257] [13 Regression] Wrong code at -O2 on x86_64-linux-gnu since r13-857-gf1652e3343b1ec47
2022-10-14 8:32 [Bug c/107257] New: Wrong code at -O2 on x86_64-linux-gnu shaohua.li at inf dot ethz.ch
` (7 preceding siblings ...)
2022-10-20 17:25 ` pinskia at gcc dot gnu.org
@ 2023-07-27 8:01 ` shaohua.li at inf dot ethz.ch
2023-07-27 14:47 ` shaohua.li at inf dot ethz.ch
9 siblings, 0 replies; 11+ messages in thread
From: shaohua.li at inf dot ethz.ch @ 2023-07-27 8:01 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=107257
Shaohua Li <shaohua.li at inf dot ethz.ch> changed:
What |Removed |Added
----------------------------------------------------------------------------
Resolution|DUPLICATE |---
Status|RESOLVED |WAITING
--- Comment #8 from Shaohua Li <shaohua.li at inf dot ethz.ch> ---
This bug is not a dup of https://gcc.gnu.org/bugzilla/show_bug.cgi?id=107172,
which has been fixed but the trunk is still faulty on this test case.
^ permalink raw reply [flat|nested] 11+ messages in thread
* [Bug target/107257] [13 Regression] Wrong code at -O2 on x86_64-linux-gnu since r13-857-gf1652e3343b1ec47
2022-10-14 8:32 [Bug c/107257] New: Wrong code at -O2 on x86_64-linux-gnu shaohua.li at inf dot ethz.ch
` (8 preceding siblings ...)
2023-07-27 8:01 ` shaohua.li at inf dot ethz.ch
@ 2023-07-27 14:47 ` shaohua.li at inf dot ethz.ch
9 siblings, 0 replies; 11+ messages in thread
From: shaohua.li at inf dot ethz.ch @ 2023-07-27 14:47 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=107257
Shaohua Li <shaohua.li at inf dot ethz.ch> changed:
What |Removed |Added
----------------------------------------------------------------------------
Resolution|--- |DUPLICATE
Status|WAITING |RESOLVED
--- Comment #9 from Shaohua Li <shaohua.li at inf dot ethz.ch> ---
Sorry, this is indeed a dup.
*** This bug has been marked as a duplicate of bug 107172 ***
^ permalink raw reply [flat|nested] 11+ messages in thread