This is an archive of the discontinued LLVM Phabricator instance.

SplitKit: Don't further split subrange mask in buildCopy
ClosedPublic

Authored by ruiling on Aug 10 2021, 7:52 AM.

Details

Summary

We may use several COPY instructions to copy the needed sub-registers
during split. But the way we split the lanes during the COPYs may be
different from the subranges of the old register. This would fail when we
extend the subranges of the new register because the LaneMasks do not
match exactly between subranges of new register and old register.
Since we are bundling the COPYs, I think there is no need to further refine the
subranges of the new register based on the set of LaneMasks of the inserted COPYs.

I am not sure if there will be further breaking cases. But as the subranges of
new register are created based on the LaneMasks of the subranges of old register,
it will be highly possible we will always find an exact LaneMask match.
We can think about how to make the extendPHIKillRanges() work for
subrange mask mismatch case if we meet more such cases in the future.

The test case was from D105065 by @arsenm.

Diff Detail

Event Timeline

ruiling created this revision.Aug 10 2021, 7:52 AM
ruiling requested review of this revision.Aug 10 2021, 7:52 AM
Herald added a project: Restricted Project. · View Herald TranscriptAug 10 2021, 7:52 AM

I'm currently working on yet another patch for this which also apparently works. With this patch, can you delete the subrange handling in extendPHIKillRanges?

This patch does make much more sense to me than the other 2

I'm currently working on yet another patch for this which also apparently works. With this patch, can you delete the subrange handling in extendPHIKillRanges?

Do you mean completely removing the code in the loop for (LiveInterval::SubRange &PS : ParentLI.subranges()) in SplitEditor::extendPHIKillRanges()? I am not sure about this, I may need some further investigation.

I'm currently working on yet another patch for this which also apparently works. With this patch, can you delete the subrange handling in extendPHIKillRanges?

Do you mean completely removing the code in the loop for (LiveInterval::SubRange &PS : ParentLI.subranges()) in SplitEditor::extendPHIKillRanges()? I am not sure about this, I may need some further investigation.

I am not sure why do you think of removing that piece of code? That is used to correctly update the subranges. Did I misunderstand your point?

arsenm accepted this revision.Aug 10 2021, 8:05 AM

I'm currently working on yet another patch for this which also apparently works. With this patch, can you delete the subrange handling in extendPHIKillRanges?

Do you mean completely removing the code in the loop for (LiveInterval::SubRange &PS : ParentLI.subranges()) in SplitEditor::extendPHIKillRanges()? I am not sure about this, I may need some further investigation.

Yes. I'm able to get every test to pass by removing it, and avoiding adding dead subrange defs if the incoming value is a phi def (although I still don't trust this is always correct)

This patch LGTM. Refining subranges after all the copies are inserted makes way more sense. Figuring out why extendPHIKillRanges needs to touch the subranges is another question

This revision is now accepted and ready to land.Aug 10 2021, 8:05 AM

I am going to wait a few days to see if @qcolombet or @kparzysz has any further comments since they all followed D105065.

Looks good to me as well.

Doing the refining after all the copies have been inserted sounds much more reasonable.

This revision was automatically updated to reflect the committed changes.
paklui added a subscriber: paklui.Aug 14 2021, 3:41 PM