Minimal repro from #70336 (comment)
staticintTest(){varcns=Vector128.Create(1,2,3,4);inti=0;do{i=(cns+Vector128.Create(i)).ToScalar();}while(i<100);returni;}Despite the fact I declared the constant vector outside of the loop it ends up inside leading to a memory load each iteration:
x64:
; Method C:Test():intG_M43325_IG01:vzeroupperG_M43325_IG02:xoreax,eaxalign[11 bytes for IG03]G_M43325_IG03: vmovd xmm0,eaxvpbroadcastdxmm0,xmm0vpadddxmm0,xmm0, xmmword ptr [reloc @RWD00] vmovd eax,xmm0cmpeax,100jl SHORT G_M43325_IG03G_M43325_IG04:retRWD00 dq 0000000200000001h,0000000400000003h; Total bytes of code: 43
Arm64:
; Method C:Test():intG_M43325_IG01: stp fp, lr,[sp,#-16]!mov fp,spG_M43325_IG02:mov w0, wzrG_M43325_IG03: dup v16.4s, w0 ldr q17,[@RWD00]add v16.4s, v17.4s, v16.4s smov x0, v16.s[0]cmp w0, #100 blt G_M43325_IG03G_M43325_IG04: ldp fp, lr,[sp],#16ret lrRWD00 dq 0000000200000001h,0000000400000003h; Total bytes of code: 44
Minimal repro from #70336 (comment)
Despite the fact I declared the constant vector outside of the loop it ends up inside leading to a memory load each iteration:
x64:
Arm64: