-
Notifications
You must be signed in to change notification settings - Fork 5.3k
Open
Labels
area-CodeGen-coreclrCLR JIT compiler in src/coreclr/src/jit and related components such as SuperPMICLR JIT compiler in src/coreclr/src/jit and related components such as SuperPMI
Milestone
Description
bool Test1(ref byte a, ref byte b)
{
var a1 = Vector128.LoadUnsafe(ref a);
var a2 = Vector128.LoadUnsafe(ref a, 16);
var b1 = Vector128.LoadUnsafe(ref b);
var b2 = Vector128.LoadUnsafe(ref b, 16);
return a1 == b1 && a2 == b2;
}
// This produces better codegen (that we expect for Test1 too):
bool Test2(ref byte a, ref byte b)
{
var a1 = Vector128.LoadUnsafe(ref a);
var a2 = Vector128.LoadUnsafe(ref a, 16);
var b1 = Vector128.LoadUnsafe(ref b);
var b2 = Vector128.LoadUnsafe(ref b, 16);
return ((a1 ^ b1) | (a2 ^ b2)) == Vector128<byte>.Zero;
}Codegen:
; Method P:Test1(byref,byref):bool:this (FullOpts)
vzeroupper
vmovups xmm0, xmmword ptr [rdx]
vmovups xmm1, xmmword ptr [rdx+10H]
vmovups xmm2, xmmword ptr [r8]
vmovups xmm3, xmmword ptr [r8+10H]
vpcmpeqb xmm0, xmm0, xmm2
vpmovmskb eax, xmm0
xor ecx, ecx
vpcmpeqb xmm0, xmm1, xmm3
vpmovmskb edx, xmm0
cmp edx, 0xFFFF
sete dl
movzx rdx, dl
cmp eax, 0xFFFF
mov eax, edx
cmovne eax, ecx
ret
; Total bytes of code: 64
; Method P:Test2(byref,byref):bool:this (FullOpts)
vzeroupper
vmovups xmm0, xmmword ptr [rdx]
vpxor xmm0, xmm0, xmmword ptr [r8]
vmovups xmm1, xmmword ptr [rdx+10H]
vpxor xmm1, xmm1, xmmword ptr [r8+10H]
vpor xmm0, xmm0, xmm1
vptest xmm0, xmm0
sete al
movzx rax, al
ret
; Total bytes of code: 39Test1 is expected to produce the same codegen as Test2
BrennanConroy, PaulusParssinen and BoyBaykiller
Metadata
Metadata
Assignees
Labels
area-CodeGen-coreclrCLR JIT compiler in src/coreclr/src/jit and related components such as SuperPMICLR JIT compiler in src/coreclr/src/jit and related components such as SuperPMI