This is an archive of the discontinued LLVM Phabricator instance.

GlobalISel: Introduce bitcast legalize action
ClosedPublic

Authored by arsenm on Feb 13 2020, 1:46 PM.

Details

Summary

For some operations, the type is unimportant and only the number of
bits matters. For example I don't want to treat <4 x s8> as a legal
type, but I also don't want to decompose loads of this into smaller
pieces to get legal register types.

On AMDGPU in SelectionDAG, we legalize a number of operations (most
notably load and store) by coercing all types to vectors of i32. For
GlobalISel, I'm trying very hard to avoid doing this for every type,
but I don't think this strategy can be completely avoided. I'm trying
to avoid bitcasts for any legitimately legal type we can operate on,
since the intervening bitcasts have proven to be a hassle.

For loads, I think I can get away without ever casting the result
type, and handling any arbitrary bitwidth during selection (I will
eventually want new tablegen support to help with this, rather than
having to add every possible type as legal). The unmerge required to
do anything with the value should expand to the expected shifts. This
is trickier for stores, since it would now require handling a wide
array of truncates during selection which I don't want.

Future potentially interesting case are for vector indexing, where
sub-dword type should be indexed in s32 pieces.

Diff Detail

Event Timeline

arsenm created this revision.Feb 13 2020, 1:46 PM
Herald added a project: Restricted Project. · View Herald TranscriptFeb 13 2020, 1:46 PM
paquette added inline comments.Mar 24 2020, 10:29 AM
llvm/lib/CodeGen/GlobalISel/LegalizerHelper.cpp
2150–2152

Would some debug output be useful here?

arsenm updated this revision to Diff 252388.Mar 24 2020, 12:04 PM

Debug print, rebase

This revision is now accepted and ready to land.Mar 24 2020, 2:01 PM