@@ -1011,6 +1011,7 @@ record_equivalences_from_phis (basic_block bb)
10111011 tree rhs = NULL ;
10121012 size_t i ;
10131013
1014+ bool ignored_phi_arg = false;
10141015 for (i = 0 ; i < gimple_phi_num_args (phi ); i ++ )
10151016 {
10161017 tree t = gimple_phi_arg_def (phi , i );
@@ -1021,10 +1022,14 @@ record_equivalences_from_phis (basic_block bb)
10211022 if (lhs == t )
10221023 continue ;
10231024
1024- /* If the associated edge is not marked as executable, then it
1025- can be ignored. */
1025+ /* We want to track if we ignored any PHI arguments because
1026+ their associated edges were not executable. This impacts
1027+ whether or not we can use any equivalence we might discover. */
10261028 if ((gimple_phi_arg_edge (phi , i )-> flags & EDGE_EXECUTABLE ) == 0 )
1027- continue ;
1029+ {
1030+ ignored_phi_arg = true;
1031+ continue ;
1032+ }
10281033
10291034 t = dom_valueize (t );
10301035
@@ -1049,9 +1054,15 @@ record_equivalences_from_phis (basic_block bb)
10491054 a useful equivalence. We do not need to record unwind data for
10501055 this, since this is a true assignment and not an equivalence
10511056 inferred from a comparison. All uses of this ssa name are dominated
1052- by this assignment, so unwinding just costs time and space. */
1057+ by this assignment, so unwinding just costs time and space.
1058+
1059+ Note that if we ignored a PHI argument and the resulting equivalence
1060+ is SSA_NAME = SSA_NAME. Then we can not use the equivalence as the
1061+ uses of the LHS SSA_NAME are not necessarily dominated by the
1062+ assignment of the RHS SSA_NAME. */
10531063 if (i == gimple_phi_num_args (phi )
1054- && may_propagate_copy (lhs , rhs ))
1064+ && may_propagate_copy (lhs , rhs )
1065+ && (!ignored_phi_arg || TREE_CODE (rhs ) != SSA_NAME ))
10551066 set_ssa_name_value (lhs , rhs );
10561067 }
10571068}
0 commit comments