Page MenuHomePhabricator

GlobalISel: Artifact combine build-vectors and unmerge into unmerge
Needs ReviewPublic

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

Details

Summary

Recognize when vector could have been split to sub-vectors.
Vector source is unmerged to elements which are merged to a few
sub-vectors.
For example 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
1130

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

1144

... 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
1081

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
1081

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)