From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 48) id E92B03857C43; Wed, 14 Oct 2020 13:58:34 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org E92B03857C43 From: "acoplan at gcc dot gnu.org" To: gcc-bugs@gcc.gnu.org Subject: [Bug tree-optimization/97421] New: [10/11 Regression] aarch64: Wrong code with -O2 -fmodulo-sched since r10-1318-ga7e8a46 Date: Wed, 14 Oct 2020 13:58:34 +0000 X-Bugzilla-Reason: CC X-Bugzilla-Type: new X-Bugzilla-Watch-Reason: None X-Bugzilla-Product: gcc X-Bugzilla-Component: tree-optimization X-Bugzilla-Version: 11.0 X-Bugzilla-Keywords: X-Bugzilla-Severity: normal X-Bugzilla-Who: acoplan at gcc dot gnu.org X-Bugzilla-Status: UNCONFIRMED X-Bugzilla-Resolution: X-Bugzilla-Priority: P3 X-Bugzilla-Assigned-To: unassigned at gcc dot gnu.org X-Bugzilla-Target-Milestone: --- X-Bugzilla-Flags: X-Bugzilla-Changed-Fields: bug_id short_desc product version bug_status bug_severity priority component assigned_to reporter target_milestone Message-ID: 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: Wed, 14 Oct 2020 13:58:35 -0000 https://gcc.gnu.org/bugzilla/show_bug.cgi?id=3D97421 Bug ID: 97421 Summary: [10/11 Regression] aarch64: Wrong code with -O2 -fmodulo-sched since r10-1318-ga7e8a46 Product: gcc Version: 11.0 Status: UNCONFIRMED Severity: normal Priority: P3 Component: tree-optimization Assignee: unassigned at gcc dot gnu.org Reporter: acoplan at gcc dot gnu.org Target Milestone: --- AArch64 GCC miscompiles the following testcase: int a, b, d, e; int *volatile c =3D &a; __attribute__((noinline)) void f(void) { for (int g =3D 2; g >=3D 0; g--) { d =3D 0; for (b =3D 0; b <=3D 2; b++) ; e =3D *c; } } int main(void) { f(); if (b !=3D 3) __builtin_abort(); } with -O2 -fmodulo-sched since r10-1318-ga7e8a463cd1dbaccf6e7c4fa888768fcd257a30f. Removing -fmodulo-sched, the testcase is compiled correctly (tested at -O0 through -O3). Here is the generated code (current trunk) for f at -O2: f: mov w1, 3 adrp x0, .LANCHOR0 adrp x3, .LANCHOR1 mov w4, w1 add x0, x0, :lo12:.LANCHOR0 // x0 <- &d add x3, x3, :lo12:.LANCHOR1 // x3 <- &c .L2: ldr x2, [x3] // x2 <- c stp wzr, w4, [x0] // d =3D 0, b =3D 3 subs w1, w1, #1 ldr w2, [x2] // w2 <- *c str w2, [x0, 8] // e <- w2 bne .L2 ret and the code for f with -O2 -fmodulo-sched: f: mov w1, 2 adrp x0, .LANCHOR0 mov w4, w1 add x0, x0, :lo12:.LANCHOR0 adrp x3, .LANCHOR1 add x3, x3, :lo12:.LANCHOR1 ldr x2, [x3] // x2 <- c str w1, [x0, 4] // b =3D 2 .L2: str wzr, [x0] // d =3D 0 ldr w2, [x2] // w2 <- *c subs w1, w1, #1=20=20 str w2, [x0, 8] // e <- w2 ldr x2, [x3] // x2 <- c str w4, [x0, 4] // b =3D 2 bne .L2 ldr w2, [x2] // w2 <- *c str w2, [x0, 8] // e <- w2 ret In the latter case we end up with b =3D 2 and make the call to __builtin_ab= ort().=