From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 48) id 02BAA3858C1F; Thu, 30 Mar 2023 12:53:11 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 02BAA3858C1F DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1680180791; bh=WQ8iCZA4X46LcfGa+7TDFPJB5L/67oRi4+p9r3+4GMs=; h=From:To:Subject:Date:In-Reply-To:References:From; b=PkaDnKOxO9XQyI5kOpRT32po+nTFWy0bkORYpngBVsFPSQLue0xaWUB/liy61MG9d jbKTUmg+AbSmuzTo+RUR0ZFSkItwxBGDxZQ6AmgyT1wvAAoMtPCCdPaiPb7IsyH6BZ YR9WVtkxrFmOrSoOoHHy1I3wdzU5B0uuyltqy4K4= From: "rguenth at gcc dot gnu.org" To: gcc-bugs@gcc.gnu.org Subject: [Bug tree-optimization/81958] [10/11/12/13 Regression] spurious -Wmaybe-uninitialized warning in gcc-8, or with -O1 Date: Thu, 30 Mar 2023 12:53:09 +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: 8.0 X-Bugzilla-Keywords: diagnostic, missed-optimization 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: 10.5 X-Bugzilla-Flags: X-Bugzilla-Changed-Fields: keywords 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=3D81958 Richard Biener changed: What |Removed |Added ---------------------------------------------------------------------------- Keywords| |missed-optimization --- Comment #8 from Richard Biener --- We see [count: 0]: # eq_7 =3D PHI # ivtmp.7_23 =3D PHI <0(2), ivtmp.7_24(8)> _25 =3D (unsigned int) ivtmp.7_23; if (maxidx_15(D) > _25) goto ; [0.00%] else goto ; [0.00%] // loop exit [count: 0]: if (maxidx_15(D) =3D=3D _25) goto ; [0.00%] else goto ; [0.00%] [count: 0]: # eq_9 =3D PHI printk (eq_9); [tail call] return; and the appearant uninit use is on the 10->7 edge, when maxidx !=3D _25 but at the same time maxidx > _25. We don't realize that the maxidx =3D=3D _25 condition is always true. The possible easiest way is probably to rewrite the in-loop condition to maxid !=3D _25 somewhere (ivcanon?). uninit analysis itself just sees maxid <=3D _25 && maxid =3D=3D_25 as the initialized cases - it could possibly analyze how _25 evolves when defined in a loop to further optimize this to true.=