https://gcc.gnu.org/bugzilla/show_bug.cgi?id=127904
--- Comment #1 from Jakub Jelinek <jakub at gcc dot gnu.org> ---
The problem seems to be in ch2 pass optimizing last non-debug use of x_5:
# x_5 = PHI <a_11(D)(3), b_13(D)(4)>
and then coalescing during bitintlower1 pass not handling the dead SSA_NAME
right.
We have
# x_5 = PHI <a_11(D)(3), b_13(D)(4)>
# DEBUG x => x_5
in one spot (all x_5 is only referenced in these) and then later on
_1 = r_26 + a_11(D);
_2 = _1 + b_13(D);
Coalesce list: (17)r_17 & (25)r_25 [map: 3, 5] : Success -> 3
Coalesce list: (19)x_19 & (28)x_28 [map: 4, 7] : Success -> 4
Coalesce list: (5)x_5 & (11)a_11(D) [map: 0, 1] : Success -> 0
Coalesce list: (5)x_5 & (13)b_13(D) [map: 0, 2] : Fail due to conflict
Coalesce list: (17)r_17 & (26)r_26 [map: 3, 6] : Success -> 3
(5)x_5 & (13)b_13(D) [map: 0, 2] : Fail due to conflict
(5)x_5 & (17)r_17 [map: 0, 3] : Fail due to conflict
(5)x_5 & (19)x_19 [map: 0, 4] : Fail due to conflict
(13)b_13(D) & (17)r_17 [map: 2, 3] : Fail due to conflict
(13)b_13(D) & (19)x_19 [map: 2, 4] : Fail due to conflict
(17)r_17 & (19)x_19 [map: 3, 4] : Fail due to conflict
and
Mapping SSA_NAMEs to decls:
x_5 -> a
a_11(D) -> a
b_13(D) -> b
r_17 -> bitint.7
x_19 -> bitint.8
r_25 -> bitint.7
r_26 -> bitint.7
x_28 -> bitint.8
Obviously, x_5 -> a is wrong when a_11(D) is used later on.
Now, tree-outof-ssa.cc calls eliminate_useless_phis before doing the
coalescing, though I wonder how effective it actually is (nor whether just dead
PHI results are a problem for coalescing and not other dead SSA_NAMEs).
The reason I'm worried about eliminate_useless_phis is that if it finds a dead
phi
/* Also remove real PHIs with no uses. */
if (has_zero_uses (result))
{
remove_gimple_phi_args (phi);
remove_phi_node (&gsi, true);
}
else
gsi_next (&gsi);
then it could that way also remove the last use of some other PHI result. Now,
if it has been walked already, we'll end up with a dead phi, while if we only
process it afterwards, we'll remove it.