[llvm] [RISCV][GlobalISel] Legalize Scalable Vector Loads (PR #84965)

Jiahan Xie via llvm-commits llvm-commits at lists.llvm.org
Mon Mar 25 14:36:33 PDT 2024


================
@@ -220,7 +220,8 @@ struct TypePairAndMemDesc {
            Align >= Other.Align &&
            // FIXME: This perhaps should be stricter, but the current legality
            // rules are written only considering the size.
-           MemTy.getSizeInBits() == Other.MemTy.getSizeInBits();
----------------
jiahanxie353 wrote:

Make sense, thanks!
To answer your question:
> Did this really cause a problem? It looks like TypeSize::operator== should not cause a crash for scalable vectors: ...

The answer is yes. And the reason why I was changing to `MemTy.getSizeInBits().getKnownMinValue() == Other.MemTy.getSizeInBits().getKnownMinValue()` is because I have:
https://github.com/llvm/llvm-project/blob/87504bb181af547827d01574912962e14043e1ae/llvm/lib/Target/RISCV/GISel/RISCVLegalizerInfo.cpp#L213-L218
In this case, `MemTy` is `nxv1s8` and `Other.MemTy` is `s8`. Therefore, based on our discussion, they should be incompatible. And seems like the only solution to make them compatible is:
```cpp
.legalForTypesWithMemDesc({{s32, p0, s8, 8},
                                                     {s32, p0, s16, 16},
                                                     {s32, p0, s32, 32},
                                                     {p0, p0, sXLen, XLen},
                                                     {nxv1s8, p0, nxv1s8, 8}});
```
But this doesn't look right to me..

https://github.com/llvm/llvm-project/pull/84965


More information about the llvm-commits mailing list