https://gcc.gnu.org/bugzilla/show_bug.cgi?id=83325
--- Comment #4 from Richard Biener <rguenth at gcc dot gnu.org> ---
Got distracted by analysis... we don't do anything "wrong" but hit the latent
issue that we're allowing x_1 -> y_3 lattice transitions. Those are
unfortunately required by the redundant IV removal testcases
tree-ssa/pr19590.c and tree-ssa/ssa-sccvn-{1,2,4}.c who all are very similar.
Index: gcc/tree-ssa-sccvn.c
===================================================================
--- gcc/tree-ssa-sccvn.c (revision 258272)
+++ gcc/tree-ssa-sccvn.c (working copy)
@@ -3283,6 +3283,20 @@ set_ssa_val_to (tree from, tree to)
&& (to == from || SSA_VAL (to) == to))
|| is_gimple_min_invariant (to)));
+ bool changed = false;
+ if (currval != to
+ && !operand_equal_p (currval, to, 0)
+ /* ??? For addresses involving volatile objects or types
operand_equal_p
+ does not reliably detect ADDR_EXPRs as equal. We know we are only
+ getting invariant gimple addresses here, so can use
+ get_addr_base_and_unit_offset to do this comparison. */
+ && !(TREE_CODE (currval) == ADDR_EXPR
+ && TREE_CODE (to) == ADDR_EXPR
+ && (get_addr_base_and_unit_offset (TREE_OPERAND (currval, 0), &coff)
+ == get_addr_base_and_unit_offset (TREE_OPERAND (to, 0), &toff))
+ && coff == toff))
+ changed = true;
+
if (from != to)
{
if (currval == from)
@@ -3297,9 +3311,10 @@ set_ssa_val_to (tree from, tree to)
}
return false;
}
- else if (currval != VN_TOP
- && ! is_gimple_min_invariant (currval)
- && is_gimple_min_invariant (to))
+ else if (changed
+ && currval != VN_TOP
+ && !(is_gimple_min_invariant (currval)
+ && !is_gimple_min_invariant (to)))
{
if (dump_file && (dump_flags & TDF_DETAILS))
{
@@ -3308,9 +3323,9 @@ set_ssa_val_to (tree from, tree to)
print_generic_expr (dump_file, from, 0);
fprintf (dump_file, " from ");
print_generic_expr (dump_file, currval, 0);
- fprintf (dump_file, " (non-constant) to ");
+ fprintf (dump_file, " to ");
print_generic_expr (dump_file, to, 0);
- fprintf (dump_file, " (constant)\n");
+ fprintf (dump_file, "\n");
}
to = from;
}
@@ -3327,17 +3342,7 @@ set_ssa_val_to (tree from, tree to)
print_generic_expr (dump_file, to, 0);
}
- if (currval != to
- && !operand_equal_p (currval, to, 0)
- /* ??? For addresses involving volatile objects or types
operand_equal_p
- does not reliably detect ADDR_EXPRs as equal. We know we are only
- getting invariant gimple addresses here, so can use
- get_addr_base_and_unit_offset to do this comparison. */
- && !(TREE_CODE (currval) == ADDR_EXPR
- && TREE_CODE (to) == ADDR_EXPR
- && (get_addr_base_and_unit_offset (TREE_OPERAND (currval, 0), &coff)
- == get_addr_base_and_unit_offset (TREE_OPERAND (to, 0), &toff))
- && coff == toff))
+ if (changed)
{
/* If we equate two SSA names we have to make the side-band info
of the leader conservative (and remember whatever original value