]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
Improve ptr_derefs_may_alias_p for the case of &STRING_CST
authorRichard Biener <rguenther@suse.de>
Tue, 26 Jul 2022 09:02:13 +0000 (11:02 +0200)
committerRichard Biener <rguenther@suse.de>
Tue, 26 Jul 2022 10:08:50 +0000 (12:08 +0200)
When the first pointer happens to be a pointer to a STRING_CST we
give up too early since the 2nd pointer handling could still end
up with a DECL for example which can disambiguate against a STRING_CST
just fine.

* tree-ssa-alias.cc (ptr_derefs_may_alias_p): If ptr1
points to a constant continue checking ptr2.

gcc/tree-ssa-alias.cc

index 390cd875074effb52dabdc42a0d5b0c2c1fa0449..b4c65da5718b61b6ee628765af7a1ac373508fad 100644 (file)
@@ -349,7 +349,9 @@ ptr_derefs_may_alias_p (tree ptr1, tree ptr2)
       else if (base
               && DECL_P (base))
        return ptr_deref_may_alias_decl_p (ptr2, base);
-      else
+      /* Try ptr2 when ptr1 points to a constant.  */
+      else if (base
+              && !CONSTANT_CLASS_P (base))
        return true;
     }
   if (TREE_CODE (ptr2) == ADDR_EXPR)