diff mbox series

tree-optimization/109491 - ICE in expressions_equal_p

Message ID 20230413130040.A2C5A385701C@sourceware.org
State New
Headers show
Series tree-optimization/109491 - ICE in expressions_equal_p | expand

Commit Message

Richard Biener April 13, 2023, 1 p.m. UTC
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.

Bootstrapped and tested on x86_64-unknown-linux-gnu, pushed.

	PR tree-optimization/109491
	* tree-ssa-sccvn.cc (expressions_equal_p): Restore the
	NULL operands test.
---
 gcc/tree-ssa-sccvn.cc | 7 +++++++
 1 file changed, 7 insertions(+)
diff mbox series

Patch

diff --git a/gcc/tree-ssa-sccvn.cc b/gcc/tree-ssa-sccvn.cc
index 99609538f54..9692911e31b 100644
--- a/gcc/tree-ssa-sccvn.cc
+++ b/gcc/tree-ssa-sccvn.cc
@@ -6407,6 +6407,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;