Issue 208731
Summary [clang][armv8] Wrong compilation when using neon intrinsics
Labels clang
Assignees
Reporter M-HT
    I'm using LLVM 22.1.8 on Linux (LLVM-22.1.8-Linux-X64.tar.xz from releases).
I have following test file with a function which should fill the buffer with zeroes:
```c
#include <arm_neon.h>
#include <stdint.h>

void test(int32_t counter, uint8_t * restrict dst)
{
    int16x4_t d0;

    d0 = vmov_n_s16(0);

    do
    {
        vst1_s16((int16_t *)dst, d0);
 dst += 8;
        counter -= 4;
    } while (counter > 0);
}
```

When I compile it with command `clang -c -O2 -Wall -target arm64-unknown-linux-gnu test.c` and disassemble the result with command `llvm-objdump -d test.o`, I get following:
```
test.o:	file format elf64-littleaarch64

Disassembly of section .text:

0000000000000000 <test>:
       0: 52800088     	mov	w8, #0x4                // =4
 4: 7100101f     	cmp	w0, #0x4
       8: 1a88b008     	csel	w8, w0, w8, lt
       c: 4b080008     	sub	w8, w0, w8
      10: aa0103e0 	mov	x0, x1
      14: 2a1f03e1     	mov	w1, wzr
      18: 11000d08 	add	w8, w8, #0x3
      1c: 53027d08     	lsr	w8, w8, #2
      20: d37d7d08     	ubfiz	x8, x8, #3, #32
      24: 91002102     	add	x2, x8, #0x8
      28: 14000000     	b	0x28 <test+0x28>
```

There is no instruction for writing to memory and the last instruction is infinite cycle, so that's clearly not the correct result.
_______________________________________________
llvm-bugs mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-bugs

Reply via email to