[clang] [Clang] Assume unaligned in maksed load / store builtins (PR #156063)
Joseph Huber via cfe-commits
cfe-commits at lists.llvm.org
Wed Sep 10 14:58:30 PDT 2025
jhuber6 wrote:
> Deferencing a pointer, __builtin_memcpy, and most other operations that involve accessing pointers, currently assume pointers are naturally aligned. The exact representation of this in LLVM IR varies, but the fundamental assumption is that you're following normal C/C++ standard rules for pointer alignment.
>
> My concern here is mostly consistency: I don't want to have this small cluster of vector intrinsics to have different rules from everything else.
>
> The reason I mentioned changing the interface before is related to this: if the masked load/store intrinsics take a pointer to the element type, instead of the vector type, that naturally reduces the required alignment. The element pointer will have smaller alignment.
I see, it's certainly possible to just make the pointer to a scalar type and then use the mask's width to infer the overall size. I ended up doing that in https://github.com/llvm/llvm-project/pull/157895 and could apply it here if needed. That would lower the alignment to just the element type I suppose. I'm mostly worried about making this builtin too restrictive by increasing it beyond the 'standard' alignment you get on most platforms (16 AFAIK). Would it be reasonable to do that here? We haven't made a release yet so all this stuff is still able to be changed fortunately.
https://github.com/llvm/llvm-project/pull/156063
More information about the cfe-commits
mailing list