From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 48) id 5A0903858CDB; Fri, 8 Mar 2024 07:25:15 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 5A0903858CDB DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1709882715; bh=RvCi3najbcR6bydDkuJxdV/iHKTPgmDG5lMq975+qB4=; h=From:To:Subject:Date:In-Reply-To:References:From; b=xc5VH8HnPxDxZ4ppTQHsPrSqsrzZZRDucfcBp30rEOSAKp+o1i2OXr7SMg601FtXZ /P0KkHsb8Zk6nFWmbhibJtXFcFcdcXp0lLpMfuQ2Y+MW4eRCW5H8JBWU1bB8EMUUyP 8THei2aNlsWceO+MLpGacNBVyslVfUzeNU5nNwGQ= From: "rguenth at gcc dot gnu.org" To: gcc-bugs@gcc.gnu.org Subject: [Bug tree-optimization/108355] [13/14 Regression] Dead Code Elimination Regression at -O2 since r13-2772-g9baee6181b4e42 Date: Fri, 08 Mar 2024 07:25:15 +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: 13.0 X-Bugzilla-Keywords: missed-optimization, testsuite-fail, xfail X-Bugzilla-Severity: normal X-Bugzilla-Who: rguenth at gcc dot gnu.org X-Bugzilla-Status: ASSIGNED X-Bugzilla-Resolution: X-Bugzilla-Priority: P2 X-Bugzilla-Assigned-To: rguenth at gcc dot gnu.org X-Bugzilla-Target-Milestone: 13.3 X-Bugzilla-Flags: X-Bugzilla-Changed-Fields: 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 List-Id: https://gcc.gnu.org/bugzilla/show_bug.cgi?id=3D108355 --- Comment #12 from Richard Biener --- (In reply to Andrew Pinski from comment #11) > (In reply to Hans-Peter Nilsson from comment #10) > > (In reply to Richard Biener from comment #9) > > > gcc.dg/tree-ssa/ssa-fre-104.c has been XFAILed. > >=20 > > Any obvious target-specific reason for this to XPASS on cris-elf, m68k-= linux > > and pru-elf? > >=20 > > (per recent gcc-testresults posts) >=20 > Most likely because > int e[][1] =3D {0, 0, 0, 0, 0, 1}; >=20 > Is done as a copy from a const static decl vs done via stores to e[i][0]. >=20 > Maybe do s/5/2/ and change the number of elements down to 3 for the array > and you will hit the issue again on those targets. Huh, most likely, but I don't see how that would help ... that should make it _fail_ to optimize this ... So checking cris-elf I see : e[0][0] =3D 0; e[1][0] =3D 0; e[2][0] =3D 0; e[3][0] =3D 0; e[4][0] =3D 0; e[5][0] =3D 1; : bar25_ (); a.0_1 =3D a; _2 =3D e[5][a.0_1]; if (_2 !=3D 0) goto ; [INV] else goto ; [INV] : a.1_3 =3D a; e[a.1_3][0] =3D 0; foo (); goto ; [INV] before FRE, the same IL as on x86_64. A FRE dump diff reveals Setting value number of a.0_1 to a.0_1 (changed) Making available beyond BB3 a.0_1 for value a.0_1 Value numbering stmt =3D _2 =3D e[5][a.0_1]; -Skipping possible redundant definition e[5][0] =3D 1; -Setting value number of _2 to _2 (changed) -Using extra use virtual operand .MEM_5 -Making available beyond BB3 _2 for value _2 +Setting value number of _2 to 1 (changed) that's exactly the reason for the regression - we're now trying to skip the definition on x86_64. And we can do so there because of the alignment of 'e' which on cris seems to be less than the size of 'int' (int is aligned to 1 byte but its size is still 4 bytes). So int a; int *b =3D &a; int **c =3D &b; int d; void bar25_(void); void foo(void); int main() { int __attribute__((aligned(sizeof(int)))) e[][1] =3D {0, 0, 0, 0, 0, 1}; for (;;) { bar25_(); /* We should optimistically treat a =3D=3D 0 because of the bounds of the object. */ if (e[5][a]) break; e[a][0] =3D 0; foo(); } *c =3D &d; } also fails on cris. Let me update the testcase.=