@@ -1,5 +1,5 @@
/* { dg-do compile } */
-/* { dg-options "-Ofast -fdump-tree-dom2" } */
+/* { dg-options "-Ofast -fdump-tree-dom2 -fdump-tree-optimized-details-blocks" } */
void g (int);
void g1 (int);
@@ -33,3 +33,4 @@ f (long a, long b, long c, long d, long x)
optimization in the backward threader before killing the forward
threader. Similarly for the other phi_on_compare-*.c tests. */
/* { dg-final { scan-tree-dump-times "Removing basic block" 1 "dom2" } } */
+/* { dg-final { scan-tree-dump-not "Invalid sum" "optimized" } } */
@@ -1059,14 +1059,19 @@ ssa_fix_duplicate_block_edges (struct redirection_data *rd,
threading path. */
if (!any_remaining_duplicated_blocks (path, i))
{
- e2 = redirect_edge_and_branch (victim, elast->dest);
- /* If we redirected the edge, then we need to copy PHI arguments
- at the target. If the edge already existed (e2 != victim
- case), then the PHIs in the target already have the correct
- arguments. */
- if (e2 == victim)
- copy_phi_args (e2->dest, elast, e2,
- path, multi_incomings ? 0 : i);
+ if (victim->dest != elast->dest)
+ {
+ e2 = redirect_edge_and_branch (victim, elast->dest);
+ /* If we redirected the edge, then we need to copy PHI arguments
+ at the target. If the edge already existed (e2 != victim
+ case), then the PHIs in the target already have the correct
+ arguments. */
+ if (e2 == victim)
+ copy_phi_args (e2->dest, elast, e2,
+ path, multi_incomings ? 0 : i);
+ }
+ else
+ e2 = victim;
}
else
{