From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 48) id 8981B3858409; Tue, 10 Oct 2023 07:56:15 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 8981B3858409 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1696924575; bh=X5ZdbiOA6SgUyoNn1to1VTf/06bdG3J2IP7SHtrKDhw=; h=From:To:Subject:Date:In-Reply-To:References:From; b=BIuvqCSltRJTJ3x+J/Uobj7sT17A4dhf9nsxfMXYrwx7rrDzjLsP2LUNAVtDnfoW/ Awr6alQdpZ1AJuAoDRgMoQavI4pHeWC3uXEDlNnL9j8w8Y9pKvlJWxz2U6bStYiIXH fAERRZsCBg6nPTWzZ9t8FkfLdWFH/EIODdPpglFU= From: "rguenth at gcc dot gnu.org" To: gcc-bugs@gcc.gnu.org Subject: [Bug tree-optimization/111519] [13/14 Regression] Wrong code at -O3 on x86_64-linux-gnu since r13-455-g1fe04c497d Date: Tue, 10 Oct 2023 07:56: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: 14.0 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: 13.3 X-Bugzilla-Flags: X-Bugzilla-Changed-Fields: cc 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=3D111519 Richard Biener changed: What |Removed |Added ---------------------------------------------------------------------------- CC| |jakub at gcc dot gnu.org --- Comment #3 from Richard Biener --- g =3D 0; for (; g <=3D 1; g++) { *n =3D **j; k[g] =3D 0 !=3D &m; *e =3D l && k[0]; } this is g =3D 0; d =3D f; // 0 k[0] =3D 1; f =3D 1; g =3D 1; d =3D f; // 1 k[1] =3D 1; f =3D 1; g =3D 2; that looks still equivalent to what we have after unrolling this loop in cunroll and also after DOM3 which really points to strlen wrongly considering 'd' z= ero. Before strlen we have [local count: 1605787]: _2 =3D e; _3 =3D *_2; k[0] =3D 1; l.8_91 =3D l; if (l.8_91 !=3D 0B) goto ; [70.00%] else goto ; [30.00%] [local count: 1124051]: [local count: 1605787]: # prephitmp_82 =3D PHI <0(7), 1(8)> *_2 =3D prephitmp_82; _7 =3D e; _8 =3D *_7; k[1] =3D 1; l.8_10 =3D l; if (l.8_10 !=3D 0B) goto ; [70.00%] else goto ; [30.00%] [local count: 1124051]: [local count: 14598063]: # prephitmp_89 =3D PHI <1(10), 0(9)> *_7 =3D prephitmp_89; d =3D _8; g =3D 2; if (q_32(D) =3D=3D 0) goto ; [33.00%] else goto ; [67.00%] that's the OK part, now into the tail loop - q_32(D) is 1: [local count: 9780702]: o.16_80 =3D o; if (o.16_80 <=3D 3) goto ; [89.00%] else goto ; [11.00%] [local count: 8704825]: d_lsm0.28_35 =3D d; [local count: 79134774]: # prephitmp_6 =3D PHI _96 =3D (int) d_lsm0.28_35; _85 =3D prephitmp_6 + 1; if (_85 !=3D 4) goto ; [89.00%] else goto ; [11.00%] [local count: 8704825]: a =3D _96; o =3D 4; [local count: 14598063]: a.17_23 =3D a; printf ("%d\n", a.17_23); return 0; and the strlen pass replaces d_lsm0.28_35 =3D d; with d_lsm0.28_35 =3D 0; w= hich is wrong. Your assessment "Here the assignment to *_73 overwrites the value of f (at *e) which then invalidates the use of _72 resulting in the wrong value for d." seems odd, it's exactly writing the correct value (in fact both stores write the value one, only the very original value is zero). I don't know the strlen pass at all so I can't tell where it goes wrong.=