This is an archive of the discontinued LLVM Phabricator instance.

[LegalizeTypes] Scalarize non-byte sized loads in WidenRecRes_Load and SplitVecResLoad
ClosedPublic

Authored by craig.topper on Feb 13 2020, 10:20 PM.

Details

Diff Detail

Event Timeline

craig.topper created this revision.Feb 13 2020, 10:20 PM
Herald added a project: Restricted Project. · View Herald TranscriptFeb 13 2020, 10:20 PM
Herald added a subscriber: hiraditya. · View Herald Transcript
craig.topper marked an inline comment as done.Feb 13 2020, 10:25 PM
craig.topper added inline comments.
llvm/lib/CodeGen/SelectionDAG/LegalizeVectorTypes.cpp
3675

This is duplicated from the code in TargetLowering because I had to produce a build vector with more results than the original type.

Given that the code in TargetLowering is separated in its own pass inside scalarizeVectorLoad, I wonder if I should just have handle both with a helper function local to LegalizeTypes and not touch scalarizeVectorLoad?

bjope added a subscriber: bjope.Feb 13 2020, 11:11 PM
efriedma added inline comments.Feb 14 2020, 1:11 PM
llvm/lib/CodeGen/SelectionDAG/LegalizeVectorTypes.cpp
3675

Can't you just call scalarizeVectorLoad, then widen the result?

I'd prefer to have one copy of the "load a non-byte-sized vector" code... we already have at least one other version in VectorLegalizer::ExpandLoad . scalarizeVectorLoad seems like a fine place to keep the code in question.

craig.topper marked an inline comment as done.Feb 14 2020, 1:33 PM
craig.topper added inline comments.
llvm/lib/CodeGen/SelectionDAG/LegalizeVectorTypes.cpp
3675

I tried an INSERT_SUBVECTOR with undef to widen it, but that failed for v3i1->v4i1 because splitvecres_insert_subvector got called and tried to create a store of v3i1. Suggestions for other ways to widen it?

This code isn't safe after legalize types, it creates an integer of the full vector size to do the load. That might need its own type legalization. So I'm not sure it makes sense in TargetLowering.

efriedma added inline comments.Feb 14 2020, 3:46 PM
llvm/lib/CodeGen/SelectionDAG/LegalizeVectorTypes.cpp
3675

Can you just ReplaceValueWith the load with the build_vector, and return SDValue()? Then legalization should kick in again to widen the build_vector, I think.

scalarizeVectorLoad can make integers with illegal types even without your patch; for example, if you scalarizeVectorLoad a v2i64 load on a 32-bit target.

Handle the widening case by just replacing all uses and returning SDValue()

This revision is now accepted and ready to land.Feb 24 2020, 12:28 PM
This revision was automatically updated to reflect the committed changes.