https://gcc.gnu.org/bugzilla/show_bug.cgi?id=104601
--- Comment #9 from Jakub Jelinek <jakub at gcc dot gnu.org> --- But --- gcc/tree-ssa-sccvn.cc.jj 2022-02-11 00:19:22.432063254 +0100 +++ gcc/tree-ssa-sccvn.cc 2022-02-23 16:07:36.697893998 +0100 @@ -5218,7 +5218,11 @@ visit_reference_op_call (tree lhs, gcall if (vnresult) { - if (vnresult->result_vdef && vdef) + /* If stmt has non-SSA_NAME lhs, don't value number the vdef, + as the call still acts as a lhs store. */ + if (!lhs && gimple_call_lhs (stmt)) + ; + else if (vnresult->result_vdef && vdef) changed |= set_ssa_val_to (vdef, vnresult->result_vdef); else if (vdef) /* If the call was discovered to be pure or const reflect @@ -5248,7 +5252,10 @@ visit_reference_op_call (tree lhs, gcall if (TREE_CODE (fn) == ADDR_EXPR && TREE_CODE (TREE_OPERAND (fn, 0)) == FUNCTION_DECL && (flags_from_decl_or_type (TREE_OPERAND (fn, 0)) - & (ECF_CONST | ECF_PURE))) + & (ECF_CONST | ECF_PURE)) + /* If stmt has non-SSA_NAME lhs, don't value number the + vdef, as the call still acts as a lhs store. */ + && (lhs || gimple_call_lhs (stmt) == NULL_TREE)) vdef_val = vuse_ssa_val (gimple_vuse (stmt)); } changed |= set_ssa_val_to (vdef, vdef_val); results in ICEs later on - the gcc_assert (x != VN_TOP); assert in vuse_ssa_val.