]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
tree-optimization/109491 - ICE in expressions_equal_p
authorRichard Biener <rguenther@suse.de>
Thu, 13 Apr 2023 12:09:30 +0000 (14:09 +0200)
committerRichard Biener <rguenther@suse.de>
Mon, 17 Apr 2023 09:13:17 +0000 (11:13 +0200)
At some point I elided the NULL pointer check in expressions_equal_p
because it shouldn't be necessary not realizing that for example
TARGET_MEM_REF has optional operands we cannot substitute with
something non-NULL with the same semantics.  The following does the
simple thing and restore the check removed in r11-4982.

PR tree-optimization/109491
* tree-ssa-sccvn.cc (expressions_equal_p): Restore the
NULL operands test.

(cherry picked from commit a37783de23c067d6a26374ff29c014e49604035c)

gcc/tree-ssa-sccvn.cc

index a63f5c8c3071321f123a9b593017e616de21d9da..cda03e0aa685fd02af60ed29ad6ae1c2c9975e89 100644 (file)
@@ -6034,6 +6034,13 @@ expressions_equal_p (tree e1, tree e2, bool match_vn_top_optimistically)
       && (e1 == VN_TOP || e2 == VN_TOP))
     return true;
 
+  /* If only one of them is null, they cannot be equal.  While in general
+     this should not happen for operations like TARGET_MEM_REF some
+     operands are optional and an identity value we could substitute
+     has differing semantics.  */
+  if (!e1 || !e2)
+    return false;
+
   /* SSA_NAME compare pointer equal.  */
   if (TREE_CODE (e1) == SSA_NAME || TREE_CODE (e2) == SSA_NAME)
     return false;