| Issue |
61638
|
| Summary |
[aarch64] bitcasting between small vectors and integers always spills to the stack.
|
| Labels |
|
| Assignees |
|
| Reporter |
Sp00ph
|
I tried this code:
```ll
define <2 x i16> @from_int(i32 %word) {
%ret = bitcast i32 %word to <2 x i16>
ret <2 x i16> %ret
}
define i32 @to_int(<2 x i16> %vec) {
%ret = bitcast <2 x i16> %vec to i32
ret i32 %ret
}
```
I expected to see something similar to this:
```asm
from_int:
fmov s0, w0
ret
to_int:
fmov w0, s0
ret
```
But LLVM currently generates this:
```asm
from_int:
sub sp, sp, #16
add x8, sp, #12
str w0, [sp, #12]
ld1 { v0.h }[0], [x8]
orr x8, x8, #0x2
ld1 { v0.h }[2], [x8]
add sp, sp, #16
ret
to_int:
sub sp, sp, #16
mov w8, v0.s[1]
fmov w9, s0
strh w9, [sp, #12]
strh w8, [sp, #14]
ldr w0, [sp, #12]
add sp, sp, #16
ret
```
For 64/128-Bit vectors the codegen matches the expected output.
Interestingly, if you use `<4 x i8>` instead of `<2 x i16>` in the example, `to_int` allocates stack space but never accesses it:
```asm
to_int:
sub sp, sp, #16
xtn v0.8b, v0.8h
fmov w0, s0
add sp, sp, #16
ret
```
_______________________________________________
llvm-bugs mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-bugs