Fix coalescer bug exposed by the gvn-unremovable-phi test.

When we detect interference between the values that have already been
merged into the candidate virtual register and an EBB argument, we first
try to resolve the conflict by splitting. We also check if the existing
interfering value is fundamentally incompatible with the branch
instruction so it needs to be removed from the virtual register,
restarting the merge operation.

However, this existing interfering value is not necessarily the only
interference, so the split is not guaranteed to resolve the conflict. If
it turns out that splitting didn't resolve the conflict, restart the
merge after removing this second conflicting value.
This commit is contained in:
Jakob Stoklund Olesen
2017-10-02 15:38:05 -07:00
parent ef048b8899
commit c091a695e6
2 changed files with 26 additions and 6 deletions

View File

@@ -110,3 +110,15 @@ ebb1(v10: i32):
v11 = iadd_imm v10, 1
return v11
}
function %gvn_unremovable_phi(i32) native {
ebb0(v0: i32):
v2 = iconst.i32 0
jump ebb2(v2, v0)
ebb2(v3: i32, v4: i32):
brnz v3, ebb2(v3, v4)
v5 = iconst.i32 1
brnz v3, ebb2(v2, v5)
return
}