This is an archive of the discontinued LLVM Phabricator instance.

GlobalISel: Artifact combine merge-like and unmerge into unmerge
ClosedPublic

Authored by Petar.Avramovic on Sep 3 2021, 9:21 AM.

Details

Summary

Recognize when source could have been unmerged to pieces with DstTy
without having to split source to smaller elements
and then merge small elements into DstTy pieces.
This happens when vector was meant to be split to sub-vectors but there
was leftover. At this point artifact combiner have already dealt with
leftover and we can continue to use sub-vectors.

Diff Detail

Event Timeline

Petar.Avramovic created this revision.Sep 3 2021, 9:21 AM
Petar.Avramovic requested review of this revision.Sep 3 2021, 9:21 AM
Herald added a project: Restricted Project. · View Herald TranscriptSep 3 2021, 9:21 AM
foad added inline comments.Sep 6 2021, 5:32 AM
llvm/include/llvm/CodeGen/GlobalISel/LegalizationArtifactCombiner.h
1173

Wouldn't it be simpler to check that FirstEltIdx is a multiple of DstTy.getNumElements()?

1187

... and FirstEltIdx / DstTy.getNumElements() here.

llvm/lib/CodeGen/GlobalISel/MachineIRBuilder.cpp
616 ↗(On Diff #370600)

Just use a constructor that initialized this to N copies of Res?

arsenm added inline comments.Sep 7 2021, 4:54 PM
llvm/include/llvm/CodeGen/GlobalISel/LegalizationArtifactCombiner.h
1159

Needs a comment. Also is misleading. What does it mean by merge exactly? Is this supposed to cover G_CONCAT_VECTORS?

Petar.Avramovic added inline comments.Sep 8 2021, 4:16 AM
llvm/include/llvm/CodeGen/GlobalISel/LegalizationArtifactCombiner.h
1159

I thought that this combine could also work for scalar types but that can be added later (I did not consider how useful would it be for code that comes from llvm-ir, and it could introduce infinite loops if se do some legalization on merge/unmerge_values). "Merge" is any of the opcodes we could get when using buildMerge. Changing name since this patch and the next one only consider vectors.

Petar.Avramovic retitled this revision from [GlobalISel] Build_vector artifact combine into unmerge_values to GlobalISel: Artifact combine build-vectors and unmerge into unmerge.
Petar.Avramovic edited the summary of this revision. (Show Details)
Herald added a project: Restricted Project. · View Herald TranscriptSep 29 2022, 8:05 AM
Herald added a subscriber: kosarev. · View Herald Transcript
arsenm added inline comments.Sep 29 2022, 12:30 PM
llvm/include/llvm/CodeGen/GlobalISel/LegalizationArtifactCombiner.h
1173

Should be the same unless this is going to handle the pointer casting (or future FP types)

Petar.Avramovic retitled this revision from GlobalISel: Artifact combine build-vectors and unmerge into unmerge to GlobalISel: Artifact combine merge-like and unmerge into unmerge.
Petar.Avramovic edited the summary of this revision. (Show Details)

Use Value finder to search for unmerged elements. In some tests skips a few combine steps since value finder looks through artifacts.

arsenm accepted this revision.Oct 21 2022, 9:43 AM
This revision is now accepted and ready to land.Oct 21 2022, 9:43 AM
This revision was landed with ongoing or failed builds.Oct 24 2022, 4:34 AM
This revision was automatically updated to reflect the committed changes.