Vector128.WithElement codegen regression in .NET 9.0 #108197
Open
Description
struct HBOARD
{
Vector128<byte> data;
public void Test(int i, byte b)
{
data = data.WithElement(i, b);
}
}
.NET 8.0:
; Assembly listing for method HBOARD:Test(int,ubyte):this (FullOpts)
G_M000_IG01: ;; offset=0x0000
sub rsp, 56
vzeroupper
G_M000_IG02: ;; offset=0x0007
vmovups xmm0, xmmword ptr [rcx]
cmp edx, 16
jae SHORT G_M000_IG04
vmovaps xmmword ptr [rsp+0x20], xmm0
lea rax, bword ptr [rsp+0x20]
movsxd rdx, edx
mov byte ptr [rax+rdx], r8b
vmovaps xmm0, xmmword ptr [rsp+0x20]
vmovups xmmword ptr [rcx], xmm0
G_M000_IG03: ;; offset=0x002C
add rsp, 56
ret
G_M000_IG04: ;; offset=0x0031
mov ecx, 21
call [System.ThrowHelper:ThrowArgumentOutOfRangeException(int)]
int3
; Total bytes of code 61
.NET 9.0:
; Assembly listing for method HBOARD:Test(int,ubyte):this (FullOpts)
G_M56601_IG01: ;; offset=0x0000
push rbx
sub rsp, 64
mov rbx, rcx
mov eax, edx
G_M56601_IG02: ;; offset=0x000A
vmovups xmm0, xmmword ptr [rbx]
vmovaps xmmword ptr [rsp+0x20], xmm0
lea rdx, [rsp+0x20]
lea rcx, [rsp+0x30]
movzx r9, r8b
mov r8d, eax
call [System.Runtime.Intrinsics.Vector128:WithElement[ubyte](System.Runtime.Intrinsics.Vector128`1[ubyte],int,ubyte):System.Runtime.Intrinsics.Vector128`1[ubyte]]
vmovaps xmm0, xmmword ptr [rsp+0x30]
vmovups xmmword ptr [rbx], xmm0
G_M56601_IG03: ;; offset=0x0035
add rsp, 64
pop rbx
ret
; Total bytes of code 59