* [Bug middle-end/104067] [12 Regression] wrong code compiling QEMU since r12-4790-g4b3a325f07acebf4
2022-01-17 14:00 [Bug middle-end/104067] New: wrong code compiling QEMU bonzini at gnu dot org
@ 2022-01-17 14:08 ` marxin at gcc dot gnu.org
2022-01-17 14:09 ` marxin at gcc dot gnu.org
` (6 subsequent siblings)
7 siblings, 0 replies; 9+ messages in thread
From: marxin at gcc dot gnu.org @ 2022-01-17 14:08 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=104067
Martin Liška <marxin at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
Ever confirmed|0 |1
Last reconfirmed| |2022-01-17
CC| |aldyh at gcc dot gnu.org,
| |amacleod at redhat dot com,
| |marxin at gcc dot gnu.org
Summary|wrong code compiling QEMU |[12 Regression] wrong code
| |compiling QEMU since
| |r12-4790-g4b3a325f07acebf4
Status|UNCONFIRMED |NEW
--- Comment #1 from Martin Liška <marxin at gcc dot gnu.org> ---
Started with r12-4790-g4b3a325f07acebf4.
One needs only -O2 option.
^ permalink raw reply [flat|nested] 9+ messages in thread
* [Bug middle-end/104067] [12 Regression] wrong code compiling QEMU since r12-4790-g4b3a325f07acebf4
2022-01-17 14:00 [Bug middle-end/104067] New: wrong code compiling QEMU bonzini at gnu dot org
2022-01-17 14:08 ` [Bug middle-end/104067] [12 Regression] wrong code compiling QEMU since r12-4790-g4b3a325f07acebf4 marxin at gcc dot gnu.org
@ 2022-01-17 14:09 ` marxin at gcc dot gnu.org
2022-01-17 15:50 ` jakub at gcc dot gnu.org
` (5 subsequent siblings)
7 siblings, 0 replies; 9+ messages in thread
From: marxin at gcc dot gnu.org @ 2022-01-17 14:09 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=104067
Martin Liška <marxin at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
See Also| |https://gcc.gnu.org/bugzill
| |a/show_bug.cgi?id=103721
--- Comment #2 from Martin Liška <marxin at gcc dot gnu.org> ---
Likely dup of PR103721.
^ permalink raw reply [flat|nested] 9+ messages in thread
* [Bug middle-end/104067] [12 Regression] wrong code compiling QEMU since r12-4790-g4b3a325f07acebf4
2022-01-17 14:00 [Bug middle-end/104067] New: wrong code compiling QEMU bonzini at gnu dot org
2022-01-17 14:08 ` [Bug middle-end/104067] [12 Regression] wrong code compiling QEMU since r12-4790-g4b3a325f07acebf4 marxin at gcc dot gnu.org
2022-01-17 14:09 ` marxin at gcc dot gnu.org
@ 2022-01-17 15:50 ` jakub at gcc dot gnu.org
2022-01-17 16:16 ` jakub at gcc dot gnu.org
` (4 subsequent siblings)
7 siblings, 0 replies; 9+ messages in thread
From: jakub at gcc dot gnu.org @ 2022-01-17 15:50 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=104067
Jakub Jelinek <jakub at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
Priority|P3 |P1
CC| |jakub at gcc dot gnu.org
Target Milestone|--- |12.0
^ permalink raw reply [flat|nested] 9+ messages in thread
* [Bug middle-end/104067] [12 Regression] wrong code compiling QEMU since r12-4790-g4b3a325f07acebf4
2022-01-17 14:00 [Bug middle-end/104067] New: wrong code compiling QEMU bonzini at gnu dot org
` (2 preceding siblings ...)
2022-01-17 15:50 ` jakub at gcc dot gnu.org
@ 2022-01-17 16:16 ` jakub at gcc dot gnu.org
2022-01-17 18:04 ` amacleod at redhat dot com
` (3 subsequent siblings)
7 siblings, 0 replies; 9+ messages in thread
From: jakub at gcc dot gnu.org @ 2022-01-17 16:16 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=104067
Jakub Jelinek <jakub at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
CC| |law at gcc dot gnu.org
--- Comment #3 from Jakub Jelinek <jakub at gcc dot gnu.org> ---
extern void abort ();
struct S { int x; } a[10];
struct S *b;
int
main ()
{
int i, j = 0;
struct S *q = a;
for (i = 100; --i > 0; )
{
struct S *p;
j++;
if (j >= 10)
j = 0;
p = &a[j];
if (p == q)
abort ();
__atomic_thread_fence (__ATOMIC_SEQ_CST);
q = p;
}
return 0;
}
This goes wrong in threadfull2, strlen1 looks correct to me:
<bb 2> [local count: 10737416]:
<bb 3> [local count: 1063004409]:
# j_17 = PHI <j_2(9), 0(2)>
# q_18 = PHI <prephitmp_16(9), &a(2)>
# ivtmp_4 = PHI <ivtmp_3(9), 99(2)>
j_8 = j_17 + 1;
if (j_8 == 10)
goto <bb 5>; [34.00%]
else
goto <bb 4>; [66.00%]
<bb 4> [local count: 701582906]:
_1 = (sizetype) j_8;
_15 = _1 * 4;
_14 = &a + _15;
<bb 5> [local count: 1063004409]:
# j_2 = PHI <j_8(4), 0(3)>
# prephitmp_16 = PHI <_14(4), &a(3)>
if (prephitmp_16 == q_18)
goto <bb 6>; [0.00%]
else
goto <bb 7>; [100.00%]
<bb 6> [count: 0]:
abort ();
<bb 7> [local count: 1063004409]:
__atomic_thread_fence (5);
ivtmp_3 = ivtmp_4 - 1;
if (ivtmp_3 != 0)
goto <bb 9>; [99.00%]
else
goto <bb 8>; [1.00%]
<bb 9> [local count: 1052374367]:
goto <bb 3>; [100.00%]
<bb 8> [local count: 10737416]:
return 0;
but threadfull2 turns that into something that weirdly starts with:
<bb 2> [local count: 10737416]:
j_8 = 1;
if (j_8 == 10)
goto <bb 4>; [34.00%]
else
goto <bb 3>; [66.00%]
<bb 3> [local count: 701582906]:
# ivtmp_22 = PHI <99(2), ivtmp_12(7)>
# j_24 = PHI <j_8(2), j_20(7)>
# q_25 = PHI <&a(2), q_7(7)>
_1 = (sizetype) j_24;
_15 = _1 * 4;
_14 = &a + _15;
<bb 4> [local count: 705197120]:
# j_2 = PHI <j_24(3), 0(2)>
# prephitmp_16 = PHI <_14(3), &a(2)>
# ivtmp_23 = PHI <ivtmp_22(3), 99(2)>
# q_26 = PHI <q_25(3), &a(2)>
if (prephitmp_16 == q_26)
goto <bb 5>; [0.00%]
else
goto <bb 6>; [100.00%]
<bb 5> [count: 0]:
abort ();
and for j == 10 turns it into unconditional abort:
j_20 = j_21 + 1;
if (j_20 == 10)
goto <bb 8>; [34.00%]
else
goto <bb 3>; [66.00%]
<bb 8> [local count: 357807289]:
# j_5 = PHI <0(7)>
# prephitmp_9 = PHI <&a(7)>
goto <bb 5>; [100.00%]
^ permalink raw reply [flat|nested] 9+ messages in thread
* [Bug middle-end/104067] [12 Regression] wrong code compiling QEMU since r12-4790-g4b3a325f07acebf4
2022-01-17 14:00 [Bug middle-end/104067] New: wrong code compiling QEMU bonzini at gnu dot org
` (3 preceding siblings ...)
2022-01-17 16:16 ` jakub at gcc dot gnu.org
@ 2022-01-17 18:04 ` amacleod at redhat dot com
2022-01-17 18:39 ` law at gcc dot gnu.org
` (2 subsequent siblings)
7 siblings, 0 replies; 9+ messages in thread
From: amacleod at redhat dot com @ 2022-01-17 18:04 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=104067
--- Comment #4 from Andrew Macleod <amacleod at redhat dot com> ---
(In reply to Martin Liška from comment #2)
> Likely dup of PR103721.
I think so too. It looks eerily familiar. Aldy will be back this week and
will have a look.
^ permalink raw reply [flat|nested] 9+ messages in thread
* [Bug middle-end/104067] [12 Regression] wrong code compiling QEMU since r12-4790-g4b3a325f07acebf4
2022-01-17 14:00 [Bug middle-end/104067] New: wrong code compiling QEMU bonzini at gnu dot org
` (4 preceding siblings ...)
2022-01-17 18:04 ` amacleod at redhat dot com
@ 2022-01-17 18:39 ` law at gcc dot gnu.org
2022-01-20 10:24 ` aldyh at gcc dot gnu.org
2022-01-20 13:28 ` aldyh at gcc dot gnu.org
7 siblings, 0 replies; 9+ messages in thread
From: law at gcc dot gnu.org @ 2022-01-17 18:39 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=104067
--- Comment #5 from Jeffrey A. Law <law at gcc dot gnu.org> ---
I briefly looked at the other BZ last week, but didn't make much headway. The
first thing that stood out was why are we threading around the loop. I thought
that was disabled. Anyway, Aldy and/or I will take both of these in the coming
days.
^ permalink raw reply [flat|nested] 9+ messages in thread
* [Bug middle-end/104067] [12 Regression] wrong code compiling QEMU since r12-4790-g4b3a325f07acebf4
2022-01-17 14:00 [Bug middle-end/104067] New: wrong code compiling QEMU bonzini at gnu dot org
` (5 preceding siblings ...)
2022-01-17 18:39 ` law at gcc dot gnu.org
@ 2022-01-20 10:24 ` aldyh at gcc dot gnu.org
2022-01-20 13:28 ` aldyh at gcc dot gnu.org
7 siblings, 0 replies; 9+ messages in thread
From: aldyh at gcc dot gnu.org @ 2022-01-20 10:24 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=104067
--- Comment #6 from Aldy Hernandez <aldyh at gcc dot gnu.org> ---
(In reply to Jeffrey A. Law from comment #5)
> I briefly looked at the other BZ last week, but didn't make much headway.
> The first thing that stood out was why are we threading around the loop. I
> thought that was disabled. Anyway, Aldy and/or I will take both of these in
> the coming days.
This is the threadfull2 pass which is the most aggressive of the threaders.
Loop optimizations have completed, so anything goes wrt loops (as per
jt_path_registry::cancel_invalid_paths).
Note that the issue here is not exactly a backedge problem as in PR103721, but
a domination problem. I will comment in the other PR as they are related.
^ permalink raw reply [flat|nested] 9+ messages in thread
* [Bug middle-end/104067] [12 Regression] wrong code compiling QEMU since r12-4790-g4b3a325f07acebf4
2022-01-17 14:00 [Bug middle-end/104067] New: wrong code compiling QEMU bonzini at gnu dot org
` (6 preceding siblings ...)
2022-01-20 10:24 ` aldyh at gcc dot gnu.org
@ 2022-01-20 13:28 ` aldyh at gcc dot gnu.org
7 siblings, 0 replies; 9+ messages in thread
From: aldyh at gcc dot gnu.org @ 2022-01-20 13:28 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=104067
Aldy Hernandez <aldyh at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
Resolution|--- |DUPLICATE
Status|NEW |RESOLVED
--- Comment #7 from Aldy Hernandez <aldyh at gcc dot gnu.org> ---
dup
*** This bug has been marked as a duplicate of bug 103721 ***
^ permalink raw reply [flat|nested] 9+ messages in thread