Skip to content

Incorrect codegen for Vector256.Create(0, 0, 0, 0, 1, 1, 1, 1) #47236

@Sergio0694

Description

@Sergio0694

Description

Stumbled upon this issue while working on SixLabors/ImageSharp#1513.
Looks like that Vector256.Create(0, 0, 0, 0, 1, 1, 1, 1) results in just a vxorps, so it effectively just zeroes the register.
You can repro this by just creating a value into a local and calling ToString() on it: all values are just 0.

Configuration

  • .NET 5.0.101
  • Checked with both sharplab, and locally with disasmo on a recent CoreCLR build

Regression?

Yes, it seems to work fine on .NET Core 3.1.

Codegen (disasmo)

public static void Foo(ref Vector256<int> x)
{
    x = Vector256.Create(0, 0, 0, 0, 1, 1, 1, 1);
}
; Assembly listing for method Vector256CreateRepro.Program:Foo(byref)
; Emitting BLENDED_CODE for X64 CPU with AVX - Windows
; optimized code
; rsp based frame
; partially interruptible
; Final local variable assignments
;
;  V00 arg0         [V00,T00] (  3,  3   )   byref  ->  rcx        
;# V01 OutArgs      [V01    ] (  1,  1   )  lclBlk ( 0) [rsp+0x00]   "OutgoingArgSpace"
;
; Lcl frame size = 0

G_M21017_IG01:
       vzeroupper 
						;; bbWeight=1    PerfScore 1.00
G_M21017_IG02:
       vxorps   ymm0, ymm0, ymm0
       vmovupd  ymmword ptr[rcx], ymm0
						;; bbWeight=1    PerfScore 3.33
G_M21017_IG03:
       vzeroupper 
       ret      
						;; bbWeight=1    PerfScore 2.00

; Total bytes of code 15, prolog size 3, PerfScore 8.03, instruction count 5 (MethodHash=f2a3ade6) for method Vector256CreateRepro.Program:Foo(byref)
; ============================================================

Metadata

Metadata

Assignees

Labels

area-CodeGen-coreclrCLR JIT compiler in src/coreclr/src/jit and related components such as SuperPMIbug

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions