[PATCH] D110933: [RISCV] Add a test showing incorrect RVV stack alignment

luxufan via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Tue Oct 5 04:55:00 PDT 2021


StephenFan added a comment.

In D110933#3040335 <https://reviews.llvm.org/D110933#3040335>, @frasercrmck wrote:

> In D110933#3039424 <https://reviews.llvm.org/D110933#3039424>, @frasercrmck wrote:
>
>> As @HsiangKai says, since VLEN is at least 64 we know any combination of vector objects is always aligned to at least 8 (I suspect this may add yet another issue when supporting VLEN=32 @craig.topper, @rogfer01). We could possibly track vector object alignment separately and realign the stack pointer if there's anything >= 8. We might need the base pointer in that scenario?
>
> Ah yes I now see why this isn't good enough. We can calculate the base sp alignment easy enough. But if we needed to calculate offsets for multiple aligned objects, e.g.:
>
>   | <vscale x 1 x i64> align 16 | <- SP + alignTo(VLENB, 32) + alignTo(VLENB, 16)
>   |-----------------------------|
>   | <vscale x 1 x i64> align 32 | <- SP + alignTo(VLENB, 32)
>   |-----------------------------|
>   | <vscale x 1 x i64>          | <- SP
>
> If we only know that VLENB >= 8 then we need to dynamically "align" each offset by an unknown amount. This is what you meant by option 2, right @StephenFan?

Yes. But I didn't understand why we need to alignTo(VLENB, 32) rather than just alignTo(32) ? The alignment of vector register is always 8, and the alloca instruction is not related to vector register.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D110933/new/

https://reviews.llvm.org/D110933



More information about the llvm-commits mailing list