Closed lawben closed 4 months ago
The most straightforward way (yet, probably not very efficient) would be to fallback to vshlq_u8
:
/*...*/
return vshlq_u8(data, vdupq_n_u8(shift));
Another approach would be to change the interface and pass the shift value as an integral constant.
FYI: This also hold for vshrq_n_*
(right shift). The common fix for this is to use a left shift with negative values.
This should be fixed with #97.
Thank you for pointing out the issue! As for the common fix: AFAIK left-shift using negative values is undefined behavior and not standard conforming.
I would thus not include the workaround and rather rely on the vdup for now until we come up with something better.
That may be true fur C++ as a language, but specifically in NEON, this is well-defined and documented:
If the signed integer value is negative, it results in a right shift.
When downloading the current tar.gz from v0.1.9-rc5 (and probably ones before that but I didn't check), I cannot compile the NEON stuff on Mac with LLVM/Clang 18. I get the following error multiple times.
which is the expanded macro for:
When looking at the NEON specs, this error is correct, as
vshlq_n_u8
requires aconst int
as the second argument. I'm not sure how this should be handled, but probably this needs avdup_n_*
for the runtime value before the shift.