Page MenuHomePhabricator

[GlobalISel] Combine (build_vector_trunc x, undef) -> (bitcast x)
Needs ReviewPublic

Authored by foad on Oct 19 2021, 4:34 AM.

Details

Summary

This mostly benefits AMDGPU where arguments to IMAGE instructions are
sometimes packed into the two 16-bit halves of a 32-bit register.

Diff Detail

Event Timeline

foad created this revision.Oct 19 2021, 4:34 AM
foad requested review of this revision.Oct 19 2021, 4:34 AM
Herald added a project: Restricted Project. · View Herald TranscriptOct 19 2021, 4:34 AM
foad added inline comments.
llvm/test/CodeGen/AMDGPU/GlobalISel/inst-select-build-vector-trunc.v2s16.mir
157 ↗(On Diff #380646)

I could just remove all these "undef" test cases, since there is no longer any code in AMDGPUInstructionSelector that handles IMPLICIT_DEF specially.

Should add some MIR tests specifically for this in case we decide to stop using G_BUILD_VECTOR_TRUNC someday

llvm/lib/Target/AMDGPU/AMDGPUInstructionSelector.cpp
630–637 ↗(On Diff #380646)

I think deleting this should be split into a separate patch

llvm/test/CodeGen/AMDGPU/GlobalISel/inst-select-build-vector-trunc.v2s16.mir
157 ↗(On Diff #380646)

Yes

Ravi added a comment.Oct 25 2021, 4:58 AM

Good to see the unnecessary 'shifts' and 'movs' removed. LGTM.

foad updated this revision to Diff 388172.Thu, Nov 18, 6:00 AM

Rebase. Add MIR tests.

foad updated this revision to Diff 388174.Thu, Nov 18, 6:05 AM

Rebase.

foad marked 2 inline comments as done.Fri, Nov 19, 3:25 AM