Skip to content

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

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)
; ============================================================

Activity

  1. ghost added
    area-CodeGen-coreclrCLR JIT compiler in src/coreclr/src/jit and related components such as SuperPMI
    on Jan 20, 2021
  2. ghost added
    untriagedNew issue has not been triaged by the area owner
    on Jan 20, 2021
  3. tannergooding commented on Jan 20, 2021

    @tannergooding
    Member

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

  4. Sergio0694 commented on Jan 20, 2021

    @Sergio0694
    ContributorAuthor

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

  5. EgorBo commented on Jan 20, 2021

    @EgorBo
    Member

    Bug-fix: EgorBo@1809af6

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

  6. JulieLeeMSFT commented on Jan 20, 2021

    @JulieLeeMSFT
    Member

    @EgorBo I will assign this to you.

  7. removed
    untriagedNew issue has not been triaged by the area owner
    on Jan 20, 2021
  8. added this to the 6.0.0 milestone on Jan 20, 2021
  9. ghost added
    in-prThere is an active PR which will close this issue when it is merged
    on Jan 24, 2021
  10. ghost removed
    in-prThere is an active PR which will close this issue when it is merged
    on Feb 16, 2021
  11. ghost locked as resolved and limited conversation to collaborators on Mar 18, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

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