From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 48) id 119973858D28; Sat, 16 Oct 2021 19:08:56 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 119973858D28 From: "hjl.tools at gmail dot com" To: gcc-bugs@gcc.gnu.org Subject: [Bug tree-optimization/102798] [9/10/11/12 Regression] wrong code with -O3 -fno-tree-pta by r9-2475 Date: Sat, 16 Oct 2021 19:08:55 +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: 12.0 X-Bugzilla-Keywords: alias, wrong-code X-Bugzilla-Severity: normal X-Bugzilla-Who: hjl.tools at gmail dot com X-Bugzilla-Status: NEW X-Bugzilla-Resolution: X-Bugzilla-Priority: P3 X-Bugzilla-Assigned-To: unassigned at gcc dot gnu.org X-Bugzilla-Target-Milestone: 9.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: Sat, 16 Oct 2021 19:08:56 -0000 https://gcc.gnu.org/bugzilla/show_bug.cgi?id=3D102798 --- Comment #6 from H.J. Lu --- A pointer is known to non-null only if we know where the pointer is pointing to. Since the null field is initialized to 0, we need to check both null and anything. This works on the test case: diff --git a/gcc/value-query.cc b/gcc/value-query.cc index ab133aab114..1e8e3b96ea7 100644 --- a/gcc/value-query.cc +++ b/gcc/value-query.cc @@ -302,7 +302,7 @@ get_ssa_name_ptr_info_nonnull (const_tree name) When PTA analysis is improved, pt.anything, pt.nonlocal and pt.escaped may also has to be considered before deciding that pointer cannot point to NULL. */ - return !pi->pt.null; + return !pi->pt.null && !pi->pt.anything; } // Update the global range for NAME into the SSA_RANGE_NAME_INFO and=