From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 48) id 3BDD03858D37; Tue, 6 Feb 2024 13:40:47 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 3BDD03858D37 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1707226847; bh=zXVQAkUXsAxXiQYib80LPnyp7hKIQDeSIIuqvwRUe1w=; h=From:To:Subject:Date:From; b=QbXQAxXmjJKiv5THB8KLaiZnETmcTP/E82w/HIDSiN49vqGEpW5E3MTnGEa8Y7sBB iEfnmKPyEMNsLkoFpqzMa/Ywwad5HiW9GUI0wRdAuPFr7hmcbnBsG9u+f/qJ2+T34r suY+BG8WtceXWEYTDmZfcrbbsCUUqh0FYaPJGpD0= From: "acoplan at gcc dot gnu.org" To: gcc-bugs@gcc.gnu.org Subject: [Bug tree-optimization/113787] New: [14 Regression] Wrong code at -O with ipa-modref on aarch64 Date: Tue, 06 Feb 2024 13:40:46 +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: 14.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 List-Id: https://gcc.gnu.org/bugzilla/show_bug.cgi?id=3D113787 Bug ID: 113787 Summary: [14 Regression] Wrong code at -O with ipa-modref on aarch64 Product: gcc Version: 14.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: --- The following testcase appears to be miscompiled on the trunk, on aarch64-linux-gnu: $ cat t.c void foo(int x, int y, int z, int d, int *buf) { for(int i =3D z; i < y-z; ++i) for(int j =3D 0; j < d; ++j) /* buf[x(i+1) + j] =3D buf[x(i+1)-j-1] */ buf[i*x+(x-z+j)] =3D buf[i*x+(x-z-1-j)]; } void bar(int x, int y, int z, int d, int *buf) { for(int i =3D 0; i < d; ++i) for(int j =3D z; j < x-z; ++j) /* buf[j+(y+i)*x] =3D buf[j+(y-1-i)*x] */ buf[j+(y-z+i)*x] =3D buf[j+(y-z-1-i)*x]; } __attribute__((noipa)) void baz(int x, int y, int d, int *buf) { foo(x, y, 0, d, buf); bar(x, y, 0, d, buf); } int main(void) { int a[] =3D { 1, 2, 3 }; baz (1, 2, 1, a); /* foo does: buf[1] =3D buf[0]; buf[2] =3D buf[1]; bar does: buf[2] =3D buf[1]; (no-op) so we should have { 1, 1, 1 }. */ for (int i =3D 0; i < 3; i++) if (a[i] !=3D 1) __builtin_abort (); } $ gcc t.c -O -fno-ipa-modref $ ./a.out $ gcc t.c -O $ ./a.out Aborted The problem seems to be that the call to foo gets incorrectly optimized out from baz when ipa-modref is enabled: $ gcc -c -S -o /dev/null t.c -O -fno-ipa-modref -fdump-tree-optimized=3Dgoo= d.tree $ gcc -c -S -o /dev/null t.c -O -fdump-tree-optimized=3Dbad.tree $ diff -u good.tree bad.tree --- good.tree 2024-02-06 13:23:36.080926703 +0000 +++ bad.tree 2024-02-06 13:23:38.356916302 +0000 @@ -223,7 +223,6 @@ void baz (int x, int y, int d, int * buf) { [local count: 1073741824]: - foo (x_2(D), y_3(D), 0, d_4(D), buf_5(D)); bar (x_2(D), y_3(D), 0, d_4(D), buf_5(D)); return; I can't seem to reproduce the issue with GCC 13 or on x86_64.=