This is an archive of the discontinued LLVM Phabricator instance.

[TargetLowering] isVectorClearMaskLegal - use ArrayRef<int> instead of const SmallVectorImpl<int>&
ClosedPublic

Authored by RKSimon on Jun 26 2018, 4:02 AM.

Details

Summary

This is more generic and matches isShuffleMaskLegal.

Under what circumstances would people want const SmallVectorImp<>& instead of ArrayRef<>?

Diff Detail

Repository
rL LLVM

Event Timeline

RKSimon created this revision.Jun 26 2018, 4:02 AM
spatel accepted this revision.Jun 26 2018, 5:57 AM

Not sure when the ArrayRef would be insufficient, but it can always be changed back if that is actually necessary.

LGTM.

include/llvm/CodeGen/TargetLowering.h
751–753 ↗(On Diff #152868)

Fix the comment typo since we're making a change - delete "This is used by".

lib/Target/X86/X86ISelLowering.h
996–998 ↗(On Diff #152868)

Shouldn't need to repeat the documentation comment from the base class?

This revision is now accepted and ready to land.Jun 26 2018, 5:57 AM

If it is modified, then SmallVectorImpl is needed, obviously.
Else
If not all users are passing something derived from SmallVectorImpl, then ArrayRef is better.
Else, if all users are derived from SmallVectorImpl, then it is best to pass that,
since it is just a downcast, while construction of ArrayRef is, well, construction.
Example: https://godbolt.org/g/zkYiC4

If it is modified, then SmallVectorImpl is needed, obviously.
Else
If not all users are passing something derived from SmallVectorImpl, then ArrayRef is better.
Else, if all users are derived from SmallVectorImpl, then it is best to pass that,
since it is just a downcast, while construction of ArrayRef is, well, construction.
Example: https://godbolt.org/g/zkYiC4

Ah - thanks for the example. I didn't consider the codegen difference (generality and consistency of the source code are the main motivations here I think, but good to actually know about the potential perf difference).

This revision was automatically updated to reflect the committed changes.