[Bug tree-optimization/102798] [9/10/11/12 Regression] wrong code with -O3 -fno-tree-pta by r9-2475

hjl.tools at gmail dot com gcc-bugzilla@gcc.gnu.org
Sat Oct 16 19:08:55 GMT 2021


https://gcc.gnu.org/bugzilla/show_bug.cgi?id=102798

--- Comment #6 from H.J. Lu <hjl.tools at gmail dot com> ---
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


More information about the Gcc-bugs mailing list