[PATCH] D76086: [Sema][SVE] Reject arithmetic on pointers to sizeless types

Richard Sandiford via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Fri Mar 13 11:50:01 PDT 2020


rsandifo-arm added a comment.

In D76086#1920558 <https://reviews.llvm.org/D76086#1920558>, @efriedma wrote:

> People are going to want to iterate over arrays in memory to write simple intrinsic loops.  If we don't allow `p + i` to work, people will be forced to write `(__SVInt8_t*)((char*)p + i * svcntb())`.  Which is the same thing, just a lot uglier.  And it wouldn't really be that crazy to support `sizeof(__SVInt8_t)`.  I mean, it's effectively just a different way of spelling `svcntb()`.  I guess we can always relax it later, though.


`__SVInt8_t` is only really supposed to be used for short-term working data rather than storage.  Sizelessness is one thing that makes it awkward to use as the target of a pointer iterator.  But another is that the underlying ABI type has an alignment of 16 bytes regardless of how big the vector actually is.  Also, for length-agnostic code, it would be unusual to have two `__SVInt8_t`s side-by-side in memory, since the code doesn't know ahead of time how big each one is.

So for length-agnostic code the expectation is that loops would iterate on `int8_t *` instead of `__SVInt8_t *`.  It's then possible to operate on pointers that aren't 16-byte aligned.  The pointer can also be incremented by `svcntb()` without casting.  The same goes for other combinations, e.g. `int32_t *` and `svcntw()`.

For length-specific code we're working on another solution that allows SVE vector types to be treated like normal fixed-length types.  I hope we'll be able to share that soon.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D76086





More information about the cfe-commits mailing list