This is an archive of the discontinued LLVM Phabricator instance.

GlobalISel: Implement bitcast action for G_EXTRACT_VECTOR_ELEMENT
ClosedPublic

Authored by arsenm on Jun 15 2020, 6:20 PM.

Details

Summary

For AMDGPU, vectors with elements < 32 bits should be indexed in
32-bit elements and the desired bits extracted from there. For
elements > 64-bits, these should be reduce to 64/32 elements to enable
the normal dynamic indexing paths.

In the dynamic index cases, this produces shorter code most of the
time. This does immediately regress the constant index cases, but this
should be fixed once we have the most basic of shift combines.

The element size > 64 case is pretty much ported from the exisiting
DAG implementation for extract element promote. The increasing element size
case is new.

Diff Detail

Event Timeline

arsenm created this revision.Jun 15 2020, 6:20 PM
Herald added a project: Restricted Project. · View Herald TranscriptJun 15 2020, 6:20 PM
arsenm updated this revision to Diff 270936.Jun 15 2020, 6:20 PM
arsenm edited the summary of this revision. (Show Details)

Fix missing part of example comment

aemerson added inline comments.Jul 7 2020, 4:16 PM
llvm/lib/CodeGen/GlobalISel/LegalizerHelper.cpp
2347

I don't think so.

@aditya_nandakumar G_EXTRACT_VECTOR_ELT doesn't extend/truncate the element right?

llvm/lib/CodeGen/GlobalISel/LegalizerHelper.cpp
2347

Nope. Plan was to add a truncating version of it which I didn't get around to doing. Thanks for the reminder though - I'll try to get to it soon.

arsenm updated this revision to Diff 276549.Jul 8 2020, 2:06 PM

Remove unnecessary check

aemerson added inline comments.Jul 24 2020, 4:02 PM
llvm/lib/CodeGen/GlobalISel/LegalizerHelper.cpp
2334

Can you add some comments here to explain what a bitcast action on an extract_vector_elt really does?

arsenm updated this revision to Diff 281777.Jul 29 2020, 6:03 PM

Add comments

aemerson accepted this revision.Jul 31 2020, 2:35 PM

LGTM.

llvm/lib/Target/AMDGPU/AMDGPULegalizerInfo.cpp
73

Nit: Can you add "Of" before 32.

This revision is now accepted and ready to land.Jul 31 2020, 2:35 PM
llvm/test/CodeGen/AMDGPU/GlobalISel/extractelement.i16.ll