Hi,

When looking into cases where we know an actual argument of a call is
a constant but we don't generate a singleton value-range for the jump
function, I found out that the special handling of pointer constants
does not work well for constant zero pointer values.  However, the
code for other types works well for zeros, so I just added a simple
test.

With this patch, we generate

  [prange] struct S * [0, 0] MASK 0x0 VALUE 0x0

instead of for example:

  [prange] struct S * [0, +INF] MASK 0xfffffffffffffff0 VALUE 0x0

for a zero constant passed in a call.

Bootstrapped and tested on x86_64-linux, the whole patch series has
additionally passed LTO and profiled-LTO bootstrap on the same platform
and a bootstrap and testsuite on ppc64-linux.  Aarch64-linux bootstrap
and testing is in progress.  OK for master is that passes too?

Thanks,

Martin


gcc/ChangeLog:

2024-11-01  Martin Jambor  <mjam...@suse.cz>

        * ipa-prop.cc (ipa_compute_jump_functions_for_edge): When creating
        value-range jump functions from pointer type constant zero, do so
        as if it was not a pointer.
---
 gcc/ipa-prop.cc | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/gcc/ipa-prop.cc b/gcc/ipa-prop.cc
index 9bd2e4bc60c..012f8a32386 100644
--- a/gcc/ipa-prop.cc
+++ b/gcc/ipa-prop.cc
@@ -2368,7 +2368,8 @@ ipa_compute_jump_functions_for_edge (struct 
ipa_func_body_info *fbi,
        }
 
       value_range vr (TREE_TYPE (arg));
-      if (POINTER_TYPE_P (TREE_TYPE (arg)))
+      if (POINTER_TYPE_P (TREE_TYPE (arg))
+         && !zerop (arg))
        {
          bool addr_nonzero = false;
          bool strict_overflow = false;
-- 
2.47.0

Reply via email to