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.
&& (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;