This is an archive of the discontinued LLVM Phabricator instance.

[SelectionDAG] Support integer promotion for VP_LOAD and VP_STORE
Needs ReviewPublic

Authored by frasercrmck on Sep 7 2021, 10:27 AM.

Details

Summary

This patch adds support for integer promotion for VP_LOAD and VP_STORE
by legalizing to extending and truncating forms of each, respectively.

Diff Detail

Unit TestsFailed

Event Timeline

hussainjk created this revision.Sep 7 2021, 10:27 AM
hussainjk requested review of this revision.Sep 7 2021, 10:27 AM
Herald added a project: Restricted Project. · View Herald TranscriptSep 7 2021, 10:27 AM

Tests?

llvm/lib/CodeGen/SelectionDAG/LegalizeIntegerTypes.cpp
1874

Just write the word "or" here instead of the ||.

1876

PromoteTargetBoolean would be incorrect for EVL wouldn't it? EVL should always ZERO_EXTEND right?

1894

Same question as above.

craig.topper added inline comments.Sep 7 2021, 10:43 AM
llvm/lib/CodeGen/SelectionDAG/LegalizeIntegerTypes.cpp
718

Should we choose the extend type from N if it was already an extending VP load? Similar to PromoteIntRes_LOAD.

hussainjk updated this revision to Diff 371156.Sep 7 2021, 12:48 PM

Addressing review comments.

Tests?

Hm how test? Selection doesn't work at this point.

Tests?

Hm how test? Selection doesn't work at this point.

Didn't D108999 add Selection for RISCV?

Hm how test? Selection doesn't work at this point.

Didn't D108999 add Selection for RISCV?

Yes you should be able to test this with RISCV. Anything that's not i1/i8/i16/i32 but is less than i64 will need promoting. Also see D108288 for examples.

llvm/lib/CodeGen/SelectionDAG/LegalizeIntegerTypes.cpp
1875

I don't think we expect EVL to need promoting - do we? It should always be a legal target-specific type, reported by TLI.getVPExplicitVectorLengthTy(). I don't know how well we're asserting on that right now.

hussainjk updated this revision to Diff 371657.Sep 9 2021, 10:51 AM

Fixing some miner logic issues.

hussainjk updated this revision to Diff 371660.Sep 9 2021, 10:54 AM

Adding tests using RISCV lowering

craig.topper added inline comments.Sep 9 2021, 11:07 AM
llvm/lib/CodeGen/SelectionDAG/LegalizeIntegerTypes.cpp
1878

GetPromotedInteger -> ZExtPromotedInteger. We need to force the upper bits to 0.

1879

5 -> 6 if I've counted the number of operands correctly.

1887

Should we assert that the store isn't indexed since this call would be incorrect if it was?

1898

GetPromotedInteger -> ZExtPromotedInteger.

hussainjk updated this revision to Diff 371780.Sep 9 2021, 9:56 PM

Added more legalization to this patch rather than putting it into another patch. Added another form of getLoadVP that was needed by the legalization. Expanded tests to cover vector splitting.

hussainjk updated this revision to Diff 371782.Sep 9 2021, 10:15 PM

Addressing review comments.

craig.topper added inline comments.Sep 9 2021, 10:29 PM
llvm/lib/CodeGen/SelectionDAG/LegalizeIntegerTypes.cpp
1887

Why does this use isIndexed() but load uses N->getAddressingMode() == ISD::UNINDEXED. Are the interfaces for checking indexed different for loads and stores?

llvm/lib/CodeGen/SelectionDAG/SelectionDAG.cpp
7700 ↗(On Diff #371782)

Why should this be different than the assert in getLoad?

hussainjk updated this revision to Diff 371791.Sep 9 2021, 11:22 PM

More assertion fixes.

hussainjk retitled this revision from Integer type legalization for vp_load and vp_store. to type legalization for vp_load and vp_store..Sep 9 2021, 11:32 PM
hussainjk edited the summary of this revision. (Show Details)
frasercrmck added inline comments.Sep 10 2021, 2:02 AM
llvm/test/CodeGen/Generic/fixed-vector-vp-mem-legalization.ll
2 ↗(On Diff #371791)

We shouldn't put RISC-V tests in Generic unless we know the target is built. So either this needs to use REQUIRES: or we put it in CodeGen/RISCV. I prefer the latter as that's where I've seen all other target-specific legalization tests go.

hussainjk added inline comments.Sep 10 2021, 10:48 AM
llvm/lib/CodeGen/SelectionDAG/SelectionDAG.cpp
7700 ↗(On Diff #371782)

These assertions fail on cases that masked loads do not.

Addressing review comments.

craig.topper added inline comments.Sep 10 2021, 1:16 PM
llvm/lib/CodeGen/SelectionDAG/SelectionDAG.cpp
7700 ↗(On Diff #371782)

But why? Seems weird to have an extending load that doesn't extend.

frasercrmck added a project: Restricted Project.

@hussainjk are you still working on this or are you taking over, @bmahjour? I might be able to find time if you're unavailable.

llvm/lib/CodeGen/SelectionDAG/LegalizeIntegerTypes.cpp
1896

Again, I'm not sure whether we ever need to promote the length - it's always a target-specific legal integer type, isn't it?

llvm/lib/CodeGen/SelectionDAG/LegalizeVectorTypes.cpp
2774 ↗(On Diff #371966)

return Lo would simplify this flow a bit

4344 ↗(On Diff #371966)

true here is FillWithZeroes - I don't think we need to do this for VP widening, since we're passing the original length along, right?

5223 ↗(On Diff #371966)

same comment about FillWithZeroes

@hussainjk are you still working on this or are you taking over, @bmahjour? I might be able to find time if you're unavailable.

@frasercrmck, Hussain is not working on this any more. Please feel free to commandeer this revision. Thanks for your help!

frasercrmck commandeered this revision.Jan 11 2022, 2:27 AM
frasercrmck edited reviewers, added: hussainjk; removed: frasercrmck.

restore full patch

  • rebase
  • drop widening and splitting (committed separately in D117235)

Note that while the legalized nodes are correct, the generated code we're
testing is *not*; RISCV ignores extending and truncating operations.

frasercrmck retitled this revision from type legalization for vp_load and vp_store. to [SelectionDAG] Support integer promotion for VP_LOAD and VP_STORE.Mar 1 2022, 7:49 AM
frasercrmck edited the summary of this revision. (Show Details)