This is an archive of the discontinued LLVM Phabricator instance.

[NFC][TTI] Add Alignment for isLegalMasked[Load/Store]
ClosedPublic

Authored by samparker on Oct 3 2019, 8:42 AM.

Details

Summary

Add an extra parameter so the backend can take the alignment into consideration. I'll need this to continue with D68337.

Diff Detail

Event Timeline

samparker created this revision.Oct 3 2019, 8:42 AM

Seems very sensible to me. There is an Align object recently added to llvm. Should we make use of it here?

I saw that, but wasn't sure how to use it! The alignment is just an unsigned value at all the call sites, so that's why I went for that.

dmgreen added inline comments.Oct 7 2019, 2:57 PM
lib/Target/X86/X86TargetTransformInfo.h
189

", unsigned Alignment" :)

Also the isLegalNTLoad below use the Align. I think they should be fairly simple to use (but haven't used them myself yet, just fixed merge conflicts).

Yes, it turns out Align is simple to use, the constructor just takes the unsigned value... but it will not accept zero and so causes assertion failures.

I think that's what "MaybeAlign" is for, if I read it correctly. It is essentially an Optional<Align> with 0 alignments being the "false" optional state.

Looks like it! I'll try it.

samparker updated this revision to Diff 223809.Oct 8 2019, 2:27 AM
  • Now using MaybeAlign
  • Now using an alignment helper function in the vectorizer.
Herald added a project: Restricted Project. · View Herald TranscriptOct 8 2019, 2:27 AM
Herald added a subscriber: hiraditya. · View Herald Transcript
dmgreen accepted this revision.Oct 8 2019, 6:44 AM

Thanks! LGTM

llvm/lib/Transforms/Vectorize/LoopVectorize.cpp
4543 ↗(On Diff #223809)

Does this need to be a MaybeAlign(Alignment)? Because the constructor is explicit, as far as I understand (hence, needs to look like the others).

This revision is now accepted and ready to land.Oct 8 2019, 6:44 AM
samparker marked an inline comment as done.Oct 14 2019, 12:41 AM
samparker added inline comments.
llvm/lib/Transforms/Vectorize/LoopVectorize.cpp
4543 ↗(On Diff #223809)

These are the internal helper functions, so they're constructed explicitly there. lines 1172 and 1179.

This revision was automatically updated to reflect the committed changes.