This is an archive of the discontinued LLVM Phabricator instance.

[VectorCombine] Enable transform 'foldSingleElementStore' for scalable vector types
ClosedPublic

Authored by benshi001 on Aug 10 2023, 9:51 PM.

Details

Summary

The transform 'foldSingleElementStore' can be applied to scalable
vector types if the index is less than the minimum number of elements.

Diff Detail

Event Timeline

benshi001 created this revision.Aug 10 2023, 9:51 PM
Herald added a project: Restricted Project. · View Herald TranscriptAug 10 2023, 9:51 PM
benshi001 requested review of this revision.Aug 10 2023, 9:51 PM
benshi001 updated this revision to Diff 549565.Aug 11 2023, 7:12 PM
benshi001 edited the summary of this revision. (Show Details)
benshi001 edited the summary of this revision. (Show Details)Aug 11 2023, 7:16 PM

Does this need to be limited to LE? My understanding is that BE and LE vectors would store the elements in the same places, even for scalable vectors. (i.e. it's like an array, where the 0th element ends up first in memory).

llvm/lib/Transforms/Vectorize/VectorCombine.cpp
49

Can you remove the unrelated formatting changes.

benshi001 updated this revision to Diff 550572.EditedAug 15 2023, 6:56 PM
benshi001 edited the summary of this revision. (Show Details)
benshi001 marked an inline comment as done.

Does this need to be limited to LE? My understanding is that BE and LE vectors would store the elements in the same places, even for scalable vectors. (i.e. it's like an array, where the 0th element ends up first in memory).

Thanks. I have checked with AArch64's SVE standard and RISCV V-extension specification, LE/BE are just concepts of byte order within a scalar element, not the order of elements inside a vector.

So I applied my optimization to scalable vector types without check of BE/LE.

Thanks.

benshi001 updated this revision to Diff 550579.Aug 15 2023, 7:26 PM
benshi001 edited the summary of this revision. (Show Details)
benshi001 added a reviewer: MaskRay.
Matt added a subscriber: Matt.Aug 15 2023, 8:17 PM
dmgreen accepted this revision.Aug 15 2023, 11:56 PM

Thanks. That matches my understanding of llvm vectors too. LGTM

This revision is now accepted and ready to land.Aug 15 2023, 11:56 PM
nikic added inline comments.Aug 15 2023, 11:59 PM
llvm/lib/Transforms/Vectorize/VectorCombine.cpp
1023–1026
benshi001 marked an inline comment as done.
benshi001 edited the summary of this revision. (Show Details)