This is an archive of the discontinued LLVM Phabricator instance.

[RISCV] Consolidate legality checking for strided load/store [nfc]
ClosedPublic

Authored by reames on Apr 27 2023, 11:55 AM.

Details

Summary

Note that the strided load from concat_vector combine was using the wrong legality test. It happened to work out as the alignment requirement is based on the scalar type either way, but unless I'm missing something allowsMisalignedAccess is expecting a contiguous memory access.

Posting for review mostly to see if anyone had a better suggestion than getting the LLVM type from the VT. That's a bit ugly, but I didn't see a cleaner way as the element type check is in terms of Type, not MVT.

Diff Detail

Event Timeline

reames created this revision.Apr 27 2023, 11:55 AM
Herald added a project: Restricted Project. · View Herald TranscriptApr 27 2023, 11:55 AM
reames requested review of this revision.Apr 27 2023, 11:55 AM
Herald added a project: Restricted Project. · View Herald TranscriptApr 27 2023, 11:55 AM
craig.topper added inline comments.Apr 27 2023, 10:09 PM
llvm/lib/Target/RISCV/RISCVISelLowering.cpp
11255

Is WideScalarBitWidth guaranteed to be a valid MVT? Like can we get i256, i512, i1024, etc. here?

llvm/lib/Target/RISCV/RISCVISelLowering.h
707

Exceeds 80 columns I think

luke added inline comments.Apr 28 2023, 1:55 AM
llvm/lib/Target/RISCV/RISCVISelLowering.cpp
11255

I presume if it's not then WideVecVT won't be legal below and we'll fail the legality check

luke accepted this revision.Apr 28 2023, 2:14 AM

LGTM on my end

llvm/lib/Target/RISCV/RISCVISelLowering.cpp
15646

Maybe we could refactor useRVVForFixedLengthVectors to use MVTs and have the Type users call getValueType. But that's for another patch.

This revision is now accepted and ready to land.Apr 28 2023, 2:14 AM
reames added inline comments.Apr 28 2023, 8:07 AM
llvm/lib/Target/RISCV/RISCVISelLowering.cpp
11255

This was my reasoning as well.

This revision was landed with ongoing or failed builds.Apr 28 2023, 8:13 AM
This revision was automatically updated to reflect the committed changes.
craig.topper added inline comments.Apr 28 2023, 9:20 AM
llvm/lib/Target/RISCV/RISCVISelLowering.cpp
11255

My concern is that MVT::getIntegerVT might assert first.

reames added inline comments.Apr 28 2023, 9:38 AM
llvm/lib/Target/RISCV/RISCVISelLowering.cpp
11255

Just to be clear, you're talking about a possible bug in the code before my change right? I don't see anything in this diff which sounds relevant to your last clarification.

If so, yes, I agree that looks suspicious.

craig.topper added inline comments.Apr 28 2023, 9:43 AM
llvm/lib/Target/RISCV/RISCVISelLowering.cpp
11255

Yes it would be a bug before your change. Your patch just made me focus more on the type checking than I did in the original review.

luke added inline comments.Apr 28 2023, 9:53 AM
llvm/lib/Target/RISCV/RISCVISelLowering.cpp
11255

Argh, I forgot these were MVTs not EVTs.