From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 48) id C67BC38708A8; Thu, 25 Feb 2021 09:21:56 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org C67BC38708A8 From: "cvs-commit at gcc dot gnu.org" To: gcc-bugs@gcc.gnu.org Subject: [Bug tree-optimization/80635] [8/9/10/11 regression] std::optional and bogus -Wmaybe-uninitialized warning Date: Thu, 25 Feb 2021 09:21:56 +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.2.0 X-Bugzilla-Keywords: diagnostic, patch X-Bugzilla-Severity: normal X-Bugzilla-Who: cvs-commit at gcc dot gnu.org X-Bugzilla-Status: ASSIGNED X-Bugzilla-Resolution: X-Bugzilla-Priority: P2 X-Bugzilla-Assigned-To: jakub at gcc dot gnu.org X-Bugzilla-Target-Milestone: 8.5 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 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: Thu, 25 Feb 2021 09:21:56 -0000 https://gcc.gnu.org/bugzilla/show_bug.cgi?id=3D80635 --- Comment #61 from CVS Commits --- The master branch has been updated by Jakub Jelinek : https://gcc.gnu.org/g:3cf52b87ff6938e30883b8f8f542a638635d507d commit r11-7383-g3cf52b87ff6938e30883b8f8f542a638635d507d Author: Jakub Jelinek Date: Thu Feb 25 10:16:55 2021 +0100 vrp: Handle VCE in vrp_simplify_cond_using_ranges [PR80635] > So I wonder what other optimizations are prevented here? > Why does uninit warn with VCE but not with NOP_EXPR? Or does the > warning disappear because of those other optimizations you mention? The optimization that it prevents is in this particular case in tree-vr= p.c (vrp_simplify_cond_using_ranges): if (!is_gimple_assign (def_stmt) || !CONVERT_EXPR_CODE_P (gimple_assign_rhs_code (def_stmt))) return; so it punts on VIEW_CONVERT_EXPR, with NOP_EXPR it optimizes that: _9 =3D (bool) maybe_a$4_7; if (_9 !=3D 0) into: _9 =3D (bool) maybe_a$4_7; if (maybe_a$4_7 !=3D 0) Now, if I apply my patch but manually disable this vrp_simplify_cond_using_ranges optimization, then the uninit warning is back, so on the uninit side it is not about VIEW_CONVERT_EXPR vs. NOP_E= XPR, both are bad there, uninit wants the guarding condition to be that SSA_NAME and not some demotion cast thereof. We have: # maybe_a$m_6 =3D PHI <_5(4), maybe_a$m_4(D)(6)> # maybe_a$4_7 =3D PHI <1(4), 0(6)> ... One of: _9 =3D VIEW_CONVERT_EXPR(maybe_a$4_7); if (_9 !=3D 0) or: _9 =3D (bool) maybe_a$4_7; if (_9 !=3D 0) or: if (maybe_a$4_7 !=3D 0) followed by: goto ; [0.00%] else goto ; [0.00%] ... [count: 0]: set (maybe_a$m_6); and uninit wants to see that maybe_a$m_4(D) is not used if bb 11 is encountered. This patch fixes it by teaching vrp_simplify_cond_using_ranges to handle VCE (when from an integral type) in addition to NOP_EXPR/CONVERT_EXPR, of course as long as the VCE or demotion doesn't change any values, i.e. when the range of the VCE or conversion operand fits into the target type. 2021-02-25 Jakub Jelinek PR tree-optimization/80635 * tree-vrp.c (vrp_simplify_cond_using_ranges): Also handle VIEW_CONVERT_EXPR if modes are the same, innerop is integral and has mode precision. * g++.dg/warn/pr80635-1.C: New test. * g++.dg/warn/pr80635-2.C: New test.=