From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 48) id 1A5AF3857C68; Fri, 29 Jul 2022 12:08:54 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 1A5AF3857C68 From: "rguenth at gcc dot gnu.org" To: gcc-bugs@gcc.gnu.org Subject: [Bug tree-optimization/106073] [12/13 Regression] wrong code at -O3 on x86_64-linux-gnu since r12-3903-g0288527f47cec669 Date: Fri, 29 Jul 2022 12:08:53 +0000 X-Bugzilla-Reason: CC X-Bugzilla-Type: changed X-Bugzilla-Watch-Reason: None X-Bugzilla-Product: gcc X-Bugzilla-Component: tree-optimization X-Bugzilla-Version: 12.1.1 X-Bugzilla-Keywords: wrong-code X-Bugzilla-Severity: normal X-Bugzilla-Who: rguenth at gcc dot gnu.org X-Bugzilla-Status: NEW X-Bugzilla-Resolution: X-Bugzilla-Priority: P2 X-Bugzilla-Assigned-To: unassigned at gcc dot gnu.org X-Bugzilla-Target-Milestone: 12.2 X-Bugzilla-Flags: X-Bugzilla-Changed-Fields: see_also Message-ID: In-Reply-To: References: Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable X-Bugzilla-URL: http://gcc.gnu.org/bugzilla/ Auto-Submitted: auto-generated MIME-Version: 1.0 X-BeenThere: gcc-bugs@gcc.gnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Gcc-bugs mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 29 Jul 2022 12:08:54 -0000 https://gcc.gnu.org/bugzilla/show_bug.cgi?id=3D106073 Richard Biener changed: What |Removed |Added ---------------------------------------------------------------------------- See Also| |https://gcc.gnu.org/bugzill | |a/show_bug.cgi?id=3D90348 --- Comment #4 from Richard Biener --- Options reduced to -O2 -funroll-loops -fno-tree-vectorize -fdisable-tree-cunrolli -fdbg-cnt=3Dgimple_unroll:3-6:8-8 in particular reducing late unrolling more will no longer reproduce the iss= ue. Disabling all threading after cunroll still reproduces the issue, thus adding -fdisable-tree-thread2 -fdisable-tree-threadfull2 -fdisable-tree-vrp2 -fdisable-tree-dom3 disabling IVOPTs hides the issue. Making all functions but main static also still reproduces the issue (so there's just one function left for late opts= ). With that simplification -O2 -funroll-loops -fno-tree-vectorize -fdisable-tree-cunrolli -fdbg-cnt=3Dgimple_unroll:3-6:8-8 -fdisable-tree-thread2 -fdisable-tree-threadfull2 -fdisable-tree-dom3 -fno-tree-vrp -fdump-tree-all -fdbg-cnt=3Divopts_loop:13-13:15-15 reproduces it, less IVOPTs does not. So one difference triggering the issue is (good vs bad in .optimized): @@ -328,20 +326,21 @@ [local count: 60532]: l =3D 0; + ivtmp.151_212 =3D (unsigned long) &bf; + _507 =3D ivtmp.151_212 + 56; [local count: 412224]: - # ai_lsm.108_510 =3D PHI - # ivtmp_511 =3D PHI <8(19), ivtmp_512(21)> - ivtmp_512 =3D ivtmp_511 - 1; - if (ivtmp_512 !=3D 0) + # ivtmp.151_254 =3D PHI + if (ivtmp.151_254 !=3D _507) goto ; [89.00%] else goto ; [11.00%] [local count: 366880]: - bf[ai_lsm.108_510][0] =3D 5; - bf[ai_lsm.108_510][1] =3D 5; - _516 =3D ai_lsm.108_510 + 1; + _506 =3D (void *) ivtmp.151_254; + MEM[(int *)_506] =3D 5; + MEM[(int *)_506 + 4B] =3D 5; + ivtmp.151_380 =3D ivtmp.151_254 + 8; goto ; [100.00%] [local count: 45347]: @@ -353,8 +352,6 @@ [local count: 40253]: bf =3D{v} {CLOBBER(eol)}; - ivtmp.132_498 =3D (unsigned long) &bf; - _480 =3D ivtmp.132_498 + 56; goto ; [100.00%] [local count: 325681]: @@ -364,8 +361,8 @@ ivtmp.132_245 =3D ivtmp.132_383 + 8; [local count: 365933]: - # ivtmp.132_383 =3D PHI - if (ivtmp.132_383 !=3D _480) + # ivtmp.132_383 =3D PHI + if (ivtmp.151_254 !=3D ivtmp.132_383) goto ; [89.00%] else goto ; [11.00%] that already causes quite some assembler changes :/ It's still not clear what goes wrong here. Interestingly again, -fstack-reuse=3Dnone avoids the issue. So maybe the above hints at 'bf' being the issue here: Partition 3: size 56 align 16 av au bf Partition 5: size 56 align 16 av Partition 1: size 44 align 16 at Partition 2: size 8 align 8 au=