This is an archive of the discontinued LLVM Phabricator instance.

[GlobalISel] Add G_UNMERGE_VALUES(G_MERGE_VALUES) combine
ClosedPublic

Authored by qcolombet on Sep 3 2020, 4:16 PM.

Details

Summary

Add the matching and applying function to the combiner helper for
G_UNMERGE_VALUES(G_MERGE_VALUES).

This combine also supports any merge-like input nodes, like G_BUILD_VECTORS
and is robust against bitcasts in between int unmerge and merge nodes.

When the input type of the merge node and the output type of the unmerge
node are not the same, but the sizes are, the combine still applies but
creates bitcasts between the sources and the destinations instead of
reusing the destinations directly.

Long term, the artifact combiner should probably reuse that helper, but
as of today, it doesn't use any outside helper, so I kept it this way.

Diff Detail

Event Timeline

qcolombet created this revision.Sep 3 2020, 4:16 PM
Herald added a project: Restricted Project. · View Herald TranscriptSep 3 2020, 4:16 PM
qcolombet requested review of this revision.Sep 3 2020, 4:16 PM
arsenm added inline comments.Sep 3 2020, 4:29 PM
llvm/include/llvm/Target/GlobalISel/Combine.td
396

Missing from all combines

llvm/lib/CodeGen/GlobalISel/CombinerHelper.cpp
1558

Since this uses buildCast, this can accept a wider array of cast types (particularly G_PTRTOINT and G_INTTOPTR?)

1602

setInstrAndDebugLoc? (We should probably just make setInstr always set the debug location)

arsenm added inline comments.Sep 3 2020, 4:31 PM
llvm/lib/CodeGen/GlobalISel/CombinerHelper.cpp
1558

Actually I was thinking there should some combines to push casts through merges instead?

qcolombet added inline comments.Sep 4 2020, 10:29 AM
llvm/include/llvm/Target/GlobalISel/Combine.td
396

@arsenm What do you mean?

I've added it to all_combines already, did I miss something else?

llvm/lib/CodeGen/GlobalISel/CombinerHelper.cpp
1558

G_PTRTOINT and G_INTTOPTR may not be no-ops (they may change the size of the types), so I didn't think we wanted to have them here.

1558

Actually I was thinking there should some combines to push casts through merges instead?

The artifact combiner does that, but AFAICT the combiner helper doesn't have such a thing. At least not yet.

1602

Oh, I didn't know about that one. Changing!

qcolombet updated this revision to Diff 289994.Sep 4 2020, 10:32 AM
  • Use setIntrAndDebugLoc
qcolombet marked an inline comment as done.Sep 4 2020, 10:33 AM
arsenm accepted this revision.Sep 14 2020, 1:26 PM
This revision is now accepted and ready to land.Sep 14 2020, 1:26 PM