This is an archive of the discontinued LLVM Phabricator instance.

[SVE] Disable some BUILD_VECTOR related code generator features.
ClosedPublic

Authored by paulwalker-arm on Jul 8 2020, 9:57 AM.

Details

Summary

Fixed length vector code generation for SVE does not yet custom
lower BUILD_VECTOR and instead relies on expansion. At the same
time custom lowering for VECTOR_SHUFFLE is also not available so
this patch disables using VECTOR_SHUFFLE to expand BUILD_VECTOR.

Related to this it also prevents the merging of stores after
legalisation because this only works when BUILD_VECTOR is either
legal or can be elminated. When this is not the case the code
generator enters an infinite legalisation loop.

Diff Detail

Event Timeline

paulwalker-arm created this revision.Jul 8 2020, 9:57 AM
efriedma added inline comments.Jul 8 2020, 12:38 PM
llvm/lib/Target/AArch64/AArch64ISelLowering.cpp
3569

Would it be enough to just fix isShuffleMaskLegal, instead of overriding this?

llvm/lib/Target/AArch64/AArch64ISelLowering.h
745

This affects code that isn't using wide vectors, right?

If this is supposed to be a temporary hack, I guess it's fine, but please explicitly state that in the comment.

paulwalker-arm marked 2 inline comments as done.Jul 8 2020, 2:13 PM
paulwalker-arm added inline comments.
llvm/lib/Target/AArch64/AArch64ISelLowering.cpp
3569

We expand VECTOR_SHUFFLE (using BUILD_VECTOR) so at this stage I think it's better to just prevent extra VECTOR_SHUFFLE instances/code paths as early as possible.

llvm/lib/Target/AArch64/AArch64ISelLowering.h
745

Sadly it affects all vectors but the interface doesn't have the necessary information. I can see other targets have hit the same issue but I've restricted our version as best I can (only taking affect when wide vectors are enabled). I've added a comment saying we can revert the change once we fully support BUILD_VECTOR when using the wide vectors.

Added comment saying when we can revert the mergeStoresAfterLegalization change.

efriedma added inline comments.Jul 8 2020, 2:17 PM
llvm/lib/Target/AArch64/AArch64ISelLowering.cpp
3569

I'm not sure what "early" means in this context; the LegalizeDAG code that checks shouldExpandBuildVectorWithShuffles also checks isShuffleMaskLegal.

Removed shouldExpandBuildVectorWithShuffles override and updated isShuffleMaskLegal instead.

efriedma accepted this revision.Jul 8 2020, 2:56 PM

LGTM

This revision is now accepted and ready to land.Jul 8 2020, 2:56 PM
paulwalker-arm marked an inline comment as done.Jul 8 2020, 2:56 PM
paulwalker-arm added inline comments.
llvm/lib/Target/AArch64/AArch64ISelLowering.cpp
3569

I was worried about the else clause but see that's unlikely to affect vectors >128bit. Updating isShuffleMaskLegal looks to work and check-llvm didn't highlight any unwanted side effects so this works for me.

This revision was automatically updated to reflect the committed changes.