This is an archive of the discontinued LLVM Phabricator instance.

AMDGPU/GlobalISel: Don't use legal v2s16 G_BUILD_VECTOR
ClosedPublic

Authored by arsenm on Jan 24 2020, 2:40 PM.

Details

Reviewers
nhaehnle
kerbowa
Summary

If we have s_pack_* instructions, legalize this to
G_BUILD_VECTOR_TRUNC from s32 elements. This is closer to how how the
s_pack_* instructions really behave.

If we don't have s_pack_ instructions, expand this by creating a merge
to s32 and bitcasting. This expands to the expected bit operations. I
think this eventually should go in a new bitcast legalize action type
in LegalizerHelper.

We already directly emit the shift operations in RegBankSelect for the
vector case. This could possibly be cleaned up, but I also may want to
defer doing this expansion to selection anyway. I'll see about that
when I try to actually match VOP3P instructions.

This breaks the selection of the build_vector since tablegen doesn't
know how to match G_BUILD_VECTOR_TRUNC yet, so just xfail it for now.

Diff Detail

Event Timeline

arsenm created this revision.Jan 24 2020, 2:40 PM
nhaehnle accepted this revision.Feb 5 2020, 7:26 AM

LGTM

This revision is now accepted and ready to land.Feb 5 2020, 7:26 AM
llvm/test/CodeGen/AMDGPU/GlobalISel/regbankselect-build-vector-trunc.v2s16.mir