Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Closed
Sergio0694 opened this issue Jan 20, 2021 · 4 comments · Fixed by #47385
Closed

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

Sergio0694 opened this issue Jan 20, 2021 · 4 comments · Fixed by #47385
Assignees
Labels
area-CodeGen-coreclr CLR JIT compiler in src/coreclr/src/jit and related components such as SuperPMI bug
Milestone

Comments

@Sergio0694
Copy link
Contributor

Sergio0694 commented Jan 20, 2021

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)
; ============================================================
@dotnet-issue-labeler dotnet-issue-labeler bot added area-CodeGen-coreclr CLR JIT compiler in src/coreclr/src/jit and related components such as SuperPMI untriaged New issue has not been triaged by the area owner labels Jan 20, 2021
@tannergooding
Copy link
Member

I was able to repro, however, this no longer repros if you change any of the values in the Create constant.

Sergio0694 added a commit to SixLabors/ImageSharp that referenced this issue Jan 20, 2021
@Sergio0694
Copy link
Contributor Author

Yeah it seems like this only happens with exactly (0, 0, 0, 0, 1, 1, 1, 1) as arguments 🤔

@EgorBo
Copy link
Member

EgorBo commented Jan 20, 2021

Bug-fix: EgorBo@1809af6

The bug should also reproduce for e.g. (0, 0, 0, 0, 5, 5, 5, 5)

@JulieLeeMSFT
Copy link
Member

@EgorBo I will assign this to you.

@JulieLeeMSFT JulieLeeMSFT removed the untriaged New issue has not been triaged by the area owner label Jan 20, 2021
@JulieLeeMSFT JulieLeeMSFT added this to the 6.0.0 milestone Jan 20, 2021
@ghost ghost added the in-pr There is an active PR which will close this issue when it is merged label Jan 24, 2021
@ghost ghost removed the in-pr There is an active PR which will close this issue when it is merged label Feb 16, 2021
JimBobSquarePants pushed a commit to SixLabors/ImageSharp that referenced this issue Mar 13, 2021
@ghost ghost locked as resolved and limited conversation to collaborators Mar 18, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
area-CodeGen-coreclr CLR JIT compiler in src/coreclr/src/jit and related components such as SuperPMI bug
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants