[Bug tree-optimization/104601] [11/12 Regression] Invalid branch elimination at -O2
jakub at gcc dot gnu.org
gcc-bugzilla@gcc.gnu.org
Wed Feb 23 15:20:49 GMT 2022
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=104601
--- Comment #10 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:16:25.873557626 +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 && vdef && gimple_call_lhs (stmt))
+ changed |= set_ssa_val_to (vdef, vdef);
+ 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);
works for the testcase.
More information about the Gcc-bugs
mailing list