0

I have the following armv8-a code and I am getting the assembler error. I am unable to figure out the error

#include <stdio.h>
#include <arm_neon.h>

void main()
{
char a = 10, b = 10, c = 10, d = 10;
uint8_t *source = (uint8_t*) malloc(sizeof(uint8_t)*40)
for(int i = 0; i < 40; i++)
*(source + i) = rand() % 255;

uint8x8_t src0 = vld1_u8(source);
uint8x8_t src1 = vld1_u8(source + 8);
uint8x8_t src2 = vld1_u8(source + 16);
uint8x8_t src3 = vld1_u8(source + 24);

uint16x8_t dst0 = vmulq_n_u16(vmovl_u8(src0), 32 - a);
uint16x8_t dst1 = vmulq_n_u16(vmovl_u8(src1), b);
uint16x8_t dst2 = vmulq_n_u16(vmovl_u8(src2), 32 - c);
uint16x8_t dst3 = vmulq_n_u16(vmovl_u8(src3), d);
}

Error while compiling on gcc 7.4.0 version (command used gcc -O3 main.c):

/tmp/ccAKq1je.s: Assembler messages:
/tmp/ccAKq1je.s:884: Error: register number out of range 0 to 15 at operand 3 -- `mla v1.8h,v23.8h,v24.h[0]`
/tmp/ccAKq1je.s:906: Error: register number out of range 0 to 15 at operand 3 -- `mla v0.8h,v22.8h,v23.h[0]'

I have similar code that doesn't use vmovl_u8 instruction and gets compiled succesfully. Getting error while using vmovl_u8 instruction. Please help me.

  • Please post a full [MCVE]. These are 4 lines taken out of context - please post the smallest example to reproduce the problem, please add all the `#include` and maybe a short `int main()` that would allow others to get the same problem. What are these variables and functions? How are they defined? – KamilCuk Nov 08 '20 at 09:27
  • Och, that's great! There are some problems tho - `int main(char)` is invalid and `a, b, c, d` variables are uninitialized - that's both undefined behavior. `command used gcc -O3` - and you give no other flags? [Tried to reproduce on godbolt](https://godbolt.org/z/4KaPqE) with no success. Could you please post the output of `uname -a` and `gcc -v -O3 main.c`? Just to be sure, the warnings `passing argument 1 of 'vld1_u8' makes pointer from integer without a cast` are fine? – KamilCuk Nov 08 '20 at 17:13
  • Note duplicate post of this question at https://stackoverflow.com/questions/64739782/why-do-i-get-assembler-error-while-using-vmovl-u8-instruction-of-armv8-a?noredirect=1&lq=1 – Nate Eldredge Nov 09 '20 at 15:05
  • You still have some syntax errors. Could you **please** test that your code compiles and reproduces the error before posting. Don't make updates within the edit box; tweak your code in your own editor, test it, and then paste it verbatim. – Nate Eldredge Nov 09 '20 at 15:09
  • When I compile this with gcc 7.3 with -O3 ([godbolt](https://godbolt.org/z/W9djrn)), everything past the `rand()` loop is optimized out as having no effect, and the output contains no SIMD instructions at all. Again, please make absolutely sure you're showing us the code that actually reproduces the problem for you. (When you do, knowing the assembler version you're using would also help.) – Nate Eldredge Nov 09 '20 at 15:14

0 Answers0