[clang] [Clang] Assume unaligned in maksed load / store builtins (PR #156063)

Joseph Huber via cfe-commits cfe-commits at lists.llvm.org
Tue Sep 2 19:24:14 PDT 2025


jhuber6 wrote:

> In theory we can lower masked load/store on any target; it's just a question of how terrible the resulting code is. And on a target that doesn't support unaligned load/store, the answer is, pretty terrible. But basically everything that supports vectors has unaligned access support these days.
> 
> I'm a little concerned the argument types aren't what we want; it isn't great that `__builtin_masked_load(mask,ptr)` is well-defined, but `*ptr` is not.
> 
> We could use EmitPointerWithAlignment() here, and infer whatever alignment that implies. Which allows users to access an unaligned load if they really want. But unaligned vector types are weird: we allow using an "aligned" attribute on typedefs, but we don't represent it as a qualifier internally, so bad things happen with type canonicalization.
> 
> Maybe we could consider changing the interface so it takes a pointer to the element type of the returned vector, instead of a pointer to the returned vector type.

I don't know why these intrinsics take alignment in the first place, the compress / expand variants don't. I think it'd be reasonable to change the intrinsics to derive alignment from the pointer and not an extra argument.

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


More information about the cfe-commits mailing list